@markus-global/cli 0.4.2 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/connectors/_template.json +22 -0
- package/connectors/hermes.json +30 -0
- package/connectors/openclaw.json +32 -0
- package/dist/commands/connect.d.ts +3 -0
- package/dist/commands/connect.d.ts.map +1 -0
- package/dist/commands/connect.js +267 -0
- package/dist/commands/connect.js.map +1 -0
- package/dist/commands/external-agent.d.ts.map +1 -1
- package/dist/commands/external-agent.js +9 -4
- package/dist/commands/external-agent.js.map +1 -1
- package/dist/commands/init.d.ts +10 -3
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +167 -40
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/install-agent.d.ts +3 -0
- package/dist/commands/install-agent.d.ts.map +1 -0
- package/dist/commands/install-agent.js +146 -0
- package/dist/commands/install-agent.js.map +1 -0
- package/dist/commands/start.js +53 -15
- package/dist/commands/start.js.map +1 -1
- package/dist/connector-service.d.ts +53 -0
- package/dist/connector-service.d.ts.map +1 -0
- package/dist/connector-service.js +225 -0
- package/dist/connector-service.js.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/markus.mjs +4012 -1139
- package/dist/web-ui/assets/index-Bolfhnhg.js +63 -0
- package/dist/web-ui/assets/index-d4taGsNz.css +1 -0
- package/dist/web-ui/index.html +2 -2
- package/package.json +3 -2
- package/templates/openclaw-markus-skill/AGENTS.md +9 -9
- package/templates/openclaw-markus-skill/TOOLS.md +4 -4
- package/templates/openclaw-markus-skill/heartbeat.md +1 -1
- package/templates/roles/SHARED.md +4 -4
- package/templates/roles/developer/HEARTBEAT.md +2 -2
- package/templates/roles/operations/HEARTBEAT.md +2 -2
- package/templates/roles/org-manager/HEARTBEAT.md +2 -2
- package/templates/roles/org-manager/ROLE.md +1 -1
- package/templates/roles/product-manager/HEARTBEAT.md +2 -2
- package/templates/roles/product-manager/ROLE.md +1 -1
- package/templates/roles/reviewer/HEARTBEAT.md +2 -2
- package/templates/roles/secretary/HEARTBEAT.md +2 -2
- package/templates/skills/chrome-devtools/SKILL.md +107 -122
- package/templates/skills/markus-project-cli/SKILL.md +4 -3
- package/dist/web-ui/assets/index-Bcc58A3R.css +0 -1
- package/dist/web-ui/assets/index-eYuP972k.js +0 -61
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))l(o);new MutationObserver(o=>{for(const d of o)if(d.type==="childList")for(const c of d.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&l(c)}).observe(document,{childList:!0,subtree:!0});function s(o){const d={};return o.integrity&&(d.integrity=o.integrity),o.referrerPolicy&&(d.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?d.credentials="include":o.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function l(o){if(o.ep)return;o.ep=!0;const d=s(o);fetch(o.href,d)}})();function Fd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var fh={exports:{}},Zi={};var sb;function O2(){if(sb)return Zi;sb=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function s(l,o,d){var c=null;if(d!==void 0&&(c=""+d),o.key!==void 0&&(c=""+o.key),"key"in o){d={};for(var h in o)h!=="key"&&(d[h]=o[h])}else d=o;return o=d.ref,{$$typeof:e,type:l,key:c,ref:o!==void 0?o:null,props:d}}return Zi.Fragment=r,Zi.jsx=s,Zi.jsxs=s,Zi}var ab;function R2(){return ab||(ab=1,fh.exports=O2()),fh.exports}var t=R2(),hh={exports:{}},Et={};var lb;function L2(){if(lb)return Et;lb=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),d=Symbol.for("react.consumer"),c=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),p=Symbol.iterator;function y(H){return H===null||typeof H!="object"?null:(H=p&&H[p]||H["@@iterator"],typeof H=="function"?H:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,E={};function A(H,X,L){this.props=H,this.context=X,this.refs=E,this.updater=L||w}A.prototype.isReactComponent={},A.prototype.setState=function(H,X){if(typeof H!="object"&&typeof H!="function"&&H!=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,H,X,"setState")},A.prototype.forceUpdate=function(H){this.updater.enqueueForceUpdate(this,H,"forceUpdate")};function C(){}C.prototype=A.prototype;function k(H,X,L){this.props=H,this.context=X,this.refs=E,this.updater=L||w}var S=k.prototype=new C;S.constructor=k,N(S,A.prototype),S.isPureReactComponent=!0;var O=Array.isArray;function R(){}var G={H:null,A:null,T:null,S:null},I=Object.prototype.hasOwnProperty;function Q(H,X,L){var M=L.ref;return{$$typeof:e,type:H,key:X,ref:M!==void 0?M:null,props:L}}function $(H,X){return Q(H.type,X,H.props)}function F(H){return typeof H=="object"&&H!==null&&H.$$typeof===e}function B(H){var X={"=":"=0",":":"=2"};return"$"+H.replace(/[=:]/g,function(L){return X[L]})}var T=/\/+/g;function D(H,X){return typeof H=="object"&&H!==null&&H.key!=null?B(""+H.key):X.toString(36)}function z(H){switch(H.status){case"fulfilled":return H.value;case"rejected":throw H.reason;default:switch(typeof H.status=="string"?H.then(R,R):(H.status="pending",H.then(function(X){H.status==="pending"&&(H.status="fulfilled",H.value=X)},function(X){H.status==="pending"&&(H.status="rejected",H.reason=X)})),H.status){case"fulfilled":return H.value;case"rejected":throw H.reason}}throw H}function _(H,X,L,M,q){var K=typeof H;(K==="undefined"||K==="boolean")&&(H=null);var ee=!1;if(H===null)ee=!0;else switch(K){case"bigint":case"string":case"number":ee=!0;break;case"object":switch(H.$$typeof){case e:case r:ee=!0;break;case x:return ee=H._init,_(ee(H._payload),X,L,M,q)}}if(ee)return q=q(H),ee=M===""?"."+D(H,0):M,O(q)?(L="",ee!=null&&(L=ee.replace(T,"$&/")+"/"),_(q,X,L,"",function(xe){return xe})):q!=null&&(F(q)&&(q=$(q,L+(q.key==null||H&&H.key===q.key?"":(""+q.key).replace(T,"$&/")+"/")+ee)),X.push(q)),1;ee=0;var te=M===""?".":M+":";if(O(H))for(var se=0;se<H.length;se++)M=H[se],K=te+D(M,se),ee+=_(M,X,L,K,q);else if(se=y(H),typeof se=="function")for(H=se.call(H),se=0;!(M=H.next()).done;)M=M.value,K=te+D(M,se++),ee+=_(M,X,L,K,q);else if(K==="object"){if(typeof H.then=="function")return _(z(H),X,L,M,q);throw X=String(H),Error("Objects are not valid as a React child (found: "+(X==="[object Object]"?"object with keys {"+Object.keys(H).join(", ")+"}":X)+"). If you meant to render a collection of children, use an array instead.")}return ee}function Y(H,X,L){if(H==null)return H;var M=[],q=0;return _(H,M,"","",function(K){return X.call(L,K,q++)}),M}function V(H){if(H._status===-1){var X=H._result;X=X(),X.then(function(L){(H._status===0||H._status===-1)&&(H._status=1,H._result=L)},function(L){(H._status===0||H._status===-1)&&(H._status=2,H._result=L)}),H._status===-1&&(H._status=0,H._result=X)}if(H._status===1)return H._result.default;throw H._result}var J=typeof reportError=="function"?reportError:function(H){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var X=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof H=="object"&&H!==null&&typeof H.message=="string"?String(H.message):String(H),error:H});if(!window.dispatchEvent(X))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",H);return}console.error(H)},U={map:Y,forEach:function(H,X,L){Y(H,function(){X.apply(this,arguments)},L)},count:function(H){var X=0;return Y(H,function(){X++}),X},toArray:function(H){return Y(H,function(X){return X})||[]},only:function(H){if(!F(H))throw Error("React.Children.only expected to receive a single React element child.");return H}};return Et.Activity=g,Et.Children=U,Et.Component=A,Et.Fragment=s,Et.Profiler=o,Et.PureComponent=k,Et.StrictMode=l,Et.Suspense=m,Et.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=G,Et.__COMPILER_RUNTIME={__proto__:null,c:function(H){return G.H.useMemoCache(H)}},Et.cache=function(H){return function(){return H.apply(null,arguments)}},Et.cacheSignal=function(){return null},Et.cloneElement=function(H,X,L){if(H==null)throw Error("The argument must be a React element, but you passed "+H+".");var M=N({},H.props),q=H.key;if(X!=null)for(K in X.key!==void 0&&(q=""+X.key),X)!I.call(X,K)||K==="key"||K==="__self"||K==="__source"||K==="ref"&&X.ref===void 0||(M[K]=X[K]);var K=arguments.length-2;if(K===1)M.children=L;else if(1<K){for(var ee=Array(K),te=0;te<K;te++)ee[te]=arguments[te+2];M.children=ee}return Q(H.type,q,M)},Et.createContext=function(H){return H={$$typeof:c,_currentValue:H,_currentValue2:H,_threadCount:0,Provider:null,Consumer:null},H.Provider=H,H.Consumer={$$typeof:d,_context:H},H},Et.createElement=function(H,X,L){var M,q={},K=null;if(X!=null)for(M in X.key!==void 0&&(K=""+X.key),X)I.call(X,M)&&M!=="key"&&M!=="__self"&&M!=="__source"&&(q[M]=X[M]);var ee=arguments.length-2;if(ee===1)q.children=L;else if(1<ee){for(var te=Array(ee),se=0;se<ee;se++)te[se]=arguments[se+2];q.children=te}if(H&&H.defaultProps)for(M in ee=H.defaultProps,ee)q[M]===void 0&&(q[M]=ee[M]);return Q(H,K,q)},Et.createRef=function(){return{current:null}},Et.forwardRef=function(H){return{$$typeof:h,render:H}},Et.isValidElement=F,Et.lazy=function(H){return{$$typeof:x,_payload:{_status:-1,_result:H},_init:V}},Et.memo=function(H,X){return{$$typeof:f,type:H,compare:X===void 0?null:X}},Et.startTransition=function(H){var X=G.T,L={};G.T=L;try{var M=H(),q=G.S;q!==null&&q(L,M),typeof M=="object"&&M!==null&&typeof M.then=="function"&&M.then(R,J)}catch(K){J(K)}finally{X!==null&&L.types!==null&&(X.types=L.types),G.T=X}},Et.unstable_useCacheRefresh=function(){return G.H.useCacheRefresh()},Et.use=function(H){return G.H.use(H)},Et.useActionState=function(H,X,L){return G.H.useActionState(H,X,L)},Et.useCallback=function(H,X){return G.H.useCallback(H,X)},Et.useContext=function(H){return G.H.useContext(H)},Et.useDebugValue=function(){},Et.useDeferredValue=function(H,X){return G.H.useDeferredValue(H,X)},Et.useEffect=function(H,X){return G.H.useEffect(H,X)},Et.useEffectEvent=function(H){return G.H.useEffectEvent(H)},Et.useId=function(){return G.H.useId()},Et.useImperativeHandle=function(H,X,L){return G.H.useImperativeHandle(H,X,L)},Et.useInsertionEffect=function(H,X){return G.H.useInsertionEffect(H,X)},Et.useLayoutEffect=function(H,X){return G.H.useLayoutEffect(H,X)},Et.useMemo=function(H,X){return G.H.useMemo(H,X)},Et.useOptimistic=function(H,X){return G.H.useOptimistic(H,X)},Et.useReducer=function(H,X,L){return G.H.useReducer(H,X,L)},Et.useRef=function(H){return G.H.useRef(H)},Et.useState=function(H){return G.H.useState(H)},Et.useSyncExternalStore=function(H,X,L){return G.H.useSyncExternalStore(H,X,L)},Et.useTransition=function(){return G.H.useTransition()},Et.version="19.2.4",Et}var ib;function Ro(){return ib||(ib=1,hh.exports=L2()),hh.exports}var v=Ro();const z2=Fd(v);var mh={exports:{}},Qi={},xh={exports:{}},gh={};var ob;function I2(){return ob||(ob=1,(function(e){function r(_,Y){var V=_.length;_.push(Y);e:for(;0<V;){var J=V-1>>>1,U=_[J];if(0<o(U,Y))_[J]=Y,_[V]=U,V=J;else break e}}function s(_){return _.length===0?null:_[0]}function l(_){if(_.length===0)return null;var Y=_[0],V=_.pop();if(V!==Y){_[0]=V;e:for(var J=0,U=_.length,H=U>>>1;J<H;){var X=2*(J+1)-1,L=_[X],M=X+1,q=_[M];if(0>o(L,V))M<U&&0>o(q,L)?(_[J]=q,_[M]=V,J=M):(_[J]=L,_[X]=V,J=X);else if(M<U&&0>o(q,V))_[J]=q,_[M]=V,J=M;else break e}}return Y}function o(_,Y){var V=_.sortIndex-Y.sortIndex;return V!==0?V:_.id-Y.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var d=performance;e.unstable_now=function(){return d.now()}}else{var c=Date,h=c.now();e.unstable_now=function(){return c.now()-h}}var m=[],f=[],x=1,g=null,p=3,y=!1,w=!1,N=!1,E=!1,A=typeof setTimeout=="function"?setTimeout:null,C=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;function S(_){for(var Y=s(f);Y!==null;){if(Y.callback===null)l(f);else if(Y.startTime<=_)l(f),Y.sortIndex=Y.expirationTime,r(m,Y);else break;Y=s(f)}}function O(_){if(N=!1,S(_),!w)if(s(m)!==null)w=!0,R||(R=!0,B());else{var Y=s(f);Y!==null&&z(O,Y.startTime-_)}}var R=!1,G=-1,I=5,Q=-1;function $(){return E?!0:!(e.unstable_now()-Q<I)}function F(){if(E=!1,R){var _=e.unstable_now();Q=_;var Y=!0;try{e:{w=!1,N&&(N=!1,C(G),G=-1),y=!0;var V=p;try{t:{for(S(_),g=s(m);g!==null&&!(g.expirationTime>_&&$());){var J=g.callback;if(typeof J=="function"){g.callback=null,p=g.priorityLevel;var U=J(g.expirationTime<=_);if(_=e.unstable_now(),typeof U=="function"){g.callback=U,S(_),Y=!0;break t}g===s(m)&&l(m),S(_)}else l(m);g=s(m)}if(g!==null)Y=!0;else{var H=s(f);H!==null&&z(O,H.startTime-_),Y=!1}}break e}finally{g=null,p=V,y=!1}Y=void 0}}finally{Y?B():R=!1}}}var B;if(typeof k=="function")B=function(){k(F)};else if(typeof MessageChannel<"u"){var T=new MessageChannel,D=T.port2;T.port1.onmessage=F,B=function(){D.postMessage(null)}}else B=function(){A(F,0)};function z(_,Y){G=A(function(){_(e.unstable_now())},Y)}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(_){_.callback=null},e.unstable_forceFrameRate=function(_){0>_||125<_?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):I=0<_?Math.floor(1e3/_):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_next=function(_){switch(p){case 1:case 2:case 3:var Y=3;break;default:Y=p}var V=p;p=Y;try{return _()}finally{p=V}},e.unstable_requestPaint=function(){E=!0},e.unstable_runWithPriority=function(_,Y){switch(_){case 1:case 2:case 3:case 4:case 5:break;default:_=3}var V=p;p=_;try{return Y()}finally{p=V}},e.unstable_scheduleCallback=function(_,Y,V){var J=e.unstable_now();switch(typeof V=="object"&&V!==null?(V=V.delay,V=typeof V=="number"&&0<V?J+V:J):V=J,_){case 1:var U=-1;break;case 2:U=250;break;case 5:U=1073741823;break;case 4:U=1e4;break;default:U=5e3}return U=V+U,_={id:x++,callback:Y,priorityLevel:_,startTime:V,expirationTime:U,sortIndex:-1},V>J?(_.sortIndex=V,r(f,_),s(m)===null&&_===s(f)&&(N?(C(G),G=-1):N=!0,z(O,V-J))):(_.sortIndex=U,r(m,_),w||y||(w=!0,R||(R=!0,B()))),_},e.unstable_shouldYield=$,e.unstable_wrapCallback=function(_){var Y=p;return function(){var V=p;p=Y;try{return _.apply(this,arguments)}finally{p=V}}}})(gh)),gh}var cb;function $2(){return cb||(cb=1,xh.exports=I2()),xh.exports}var ph={exports:{}},ar={};var db;function B2(){if(db)return ar;db=1;var e=Ro();function r(m){var f="https://react.dev/errors/"+m;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var x=2;x<arguments.length;x++)f+="&args[]="+encodeURIComponent(arguments[x])}return"Minified React error #"+m+"; visit "+f+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(){}var l={d:{f:s,r:function(){throw Error(r(522))},D:s,C:s,L:s,m:s,X:s,S:s,M:s},p:0,findDOMNode:null},o=Symbol.for("react.portal");function d(m,f,x){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:g==null?null:""+g,children:m,containerInfo:f,implementation:x}}var c=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(m,f){if(m==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return ar.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=l,ar.createPortal=function(m,f){var x=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)throw Error(r(299));return d(m,f,null,x)},ar.flushSync=function(m){var f=c.T,x=l.p;try{if(c.T=null,l.p=2,m)return m()}finally{c.T=f,l.p=x,l.d.f()}},ar.preconnect=function(m,f){typeof m=="string"&&(f?(f=f.crossOrigin,f=typeof f=="string"?f==="use-credentials"?f:"":void 0):f=null,l.d.C(m,f))},ar.prefetchDNS=function(m){typeof m=="string"&&l.d.D(m)},ar.preinit=function(m,f){if(typeof m=="string"&&f&&typeof f.as=="string"){var x=f.as,g=h(x,f.crossOrigin),p=typeof f.integrity=="string"?f.integrity:void 0,y=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;x==="style"?l.d.S(m,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:g,integrity:p,fetchPriority:y}):x==="script"&&l.d.X(m,{crossOrigin:g,integrity:p,fetchPriority:y,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},ar.preinitModule=function(m,f){if(typeof m=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var x=h(f.as,f.crossOrigin);l.d.M(m,{crossOrigin:x,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0})}}else f==null&&l.d.M(m)},ar.preload=function(m,f){if(typeof m=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var x=f.as,g=h(x,f.crossOrigin);l.d.L(m,x,{crossOrigin:g,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0,type:typeof f.type=="string"?f.type:void 0,fetchPriority:typeof f.fetchPriority=="string"?f.fetchPriority:void 0,referrerPolicy:typeof f.referrerPolicy=="string"?f.referrerPolicy:void 0,imageSrcSet:typeof f.imageSrcSet=="string"?f.imageSrcSet:void 0,imageSizes:typeof f.imageSizes=="string"?f.imageSizes:void 0,media:typeof f.media=="string"?f.media:void 0})}},ar.preloadModule=function(m,f){if(typeof m=="string")if(f){var x=h(f.as,f.crossOrigin);l.d.m(m,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:x,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else l.d.m(m)},ar.requestFormReset=function(m){l.d.r(m)},ar.unstable_batchedUpdates=function(m,f){return m(f)},ar.useFormState=function(m,f,x){return c.H.useFormState(m,f,x)},ar.useFormStatus=function(){return c.H.useHostTransitionStatus()},ar.version="19.2.4",ar}var ub;function r1(){if(ub)return ph.exports;ub=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(r){console.error(r)}}return e(),ph.exports=B2(),ph.exports}var fb;function H2(){if(fb)return Qi;fb=1;var e=$2(),r=Ro(),s=r1();function l(n){var a="https://react.dev/errors/"+n;if(1<arguments.length){a+="?args[]="+encodeURIComponent(arguments[1]);for(var i=2;i<arguments.length;i++)a+="&args[]="+encodeURIComponent(arguments[i])}return"Minified React error #"+n+"; visit "+a+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function d(n){var a=n,i=n;if(n.alternate)for(;a.return;)a=a.return;else{n=a;do a=n,(a.flags&4098)!==0&&(i=a.return),n=a.return;while(n)}return a.tag===3?i:null}function c(n){if(n.tag===13){var a=n.memoizedState;if(a===null&&(n=n.alternate,n!==null&&(a=n.memoizedState)),a!==null)return a.dehydrated}return null}function h(n){if(n.tag===31){var a=n.memoizedState;if(a===null&&(n=n.alternate,n!==null&&(a=n.memoizedState)),a!==null)return a.dehydrated}return null}function m(n){if(d(n)!==n)throw Error(l(188))}function f(n){var a=n.alternate;if(!a){if(a=d(n),a===null)throw Error(l(188));return a!==n?null:n}for(var i=n,u=a;;){var b=i.return;if(b===null)break;var j=b.alternate;if(j===null){if(u=b.return,u!==null){i=u;continue}break}if(b.child===j.child){for(j=b.child;j;){if(j===i)return m(b),n;if(j===u)return m(b),a;j=j.sibling}throw Error(l(188))}if(i.return!==u.return)i=b,u=j;else{for(var P=!1,W=b.child;W;){if(W===i){P=!0,i=b,u=j;break}if(W===u){P=!0,u=b,i=j;break}W=W.sibling}if(!P){for(W=j.child;W;){if(W===i){P=!0,i=j,u=b;break}if(W===u){P=!0,u=j,i=b;break}W=W.sibling}if(!P)throw Error(l(189))}}if(i.alternate!==u)throw Error(l(190))}if(i.tag!==3)throw Error(l(188));return i.stateNode.current===i?n:a}function x(n){var a=n.tag;if(a===5||a===26||a===27||a===6)return n;for(n=n.child;n!==null;){if(a=x(n),a!==null)return a;n=n.sibling}return null}var g=Object.assign,p=Symbol.for("react.element"),y=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),C=Symbol.for("react.consumer"),k=Symbol.for("react.context"),S=Symbol.for("react.forward_ref"),O=Symbol.for("react.suspense"),R=Symbol.for("react.suspense_list"),G=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),Q=Symbol.for("react.activity"),$=Symbol.for("react.memo_cache_sentinel"),F=Symbol.iterator;function B(n){return n===null||typeof n!="object"?null:(n=F&&n[F]||n["@@iterator"],typeof n=="function"?n:null)}var T=Symbol.for("react.client.reference");function D(n){if(n==null)return null;if(typeof n=="function")return n.$$typeof===T?null:n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case N:return"Fragment";case A:return"Profiler";case E:return"StrictMode";case O:return"Suspense";case R:return"SuspenseList";case Q:return"Activity"}if(typeof n=="object")switch(n.$$typeof){case w:return"Portal";case k:return n.displayName||"Context";case C:return(n._context.displayName||"Context")+".Consumer";case S:var a=n.render;return n=n.displayName,n||(n=a.displayName||a.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case G:return a=n.displayName||null,a!==null?a:D(n.type)||"Memo";case I:a=n._payload,n=n._init;try{return D(n(a))}catch{}}return null}var z=Array.isArray,_=r.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Y=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V={pending:!1,data:null,method:null,action:null},J=[],U=-1;function H(n){return{current:n}}function X(n){0>U||(n.current=J[U],J[U]=null,U--)}function L(n,a){U++,J[U]=n.current,n.current=a}var M=H(null),q=H(null),K=H(null),ee=H(null);function te(n,a){switch(L(K,a),L(q,n),L(M,null),a.nodeType){case 9:case 11:n=(n=a.documentElement)&&(n=n.namespaceURI)?E0(n):0;break;default:if(n=a.tagName,a=a.namespaceURI)a=E0(a),n=T0(a,n);else switch(n){case"svg":n=1;break;case"math":n=2;break;default:n=0}}X(M),L(M,n)}function se(){X(M),X(q),X(K)}function xe(n){n.memoizedState!==null&&L(ee,n);var a=M.current,i=T0(a,n.type);a!==i&&(L(q,n),L(M,i))}function ke(n){q.current===n&&(X(M),X(q)),ee.current===n&&(X(ee),Vi._currentValue=V)}var De,ge;function ye(n){if(De===void 0)try{throw Error()}catch(i){var a=i.stack.trim().match(/\n( *(at )?)/);De=a&&a[1]||"",ge=-1<i.stack.indexOf(`
|
|
2
|
+
at`)?" (<anonymous>)":-1<i.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
3
|
+
`+De+n+ge}var Ce=!1;function ze(n,a){if(!n||Ce)return"";Ce=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var u={DetermineComponentFrameRoot:function(){try{if(a){var _e=function(){throw Error()};if(Object.defineProperty(_e.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(_e,[])}catch(Ne){var ve=Ne}Reflect.construct(n,[],_e)}else{try{_e.call()}catch(Ne){ve=Ne}n.call(_e.prototype)}}else{try{throw Error()}catch(Ne){ve=Ne}(_e=n())&&typeof _e.catch=="function"&&_e.catch(function(){})}}catch(Ne){if(Ne&&ve&&typeof Ne.stack=="string")return[Ne.stack,ve.stack]}return[null,null]}};u.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var b=Object.getOwnPropertyDescriptor(u.DetermineComponentFrameRoot,"name");b&&b.configurable&&Object.defineProperty(u.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var j=u.DetermineComponentFrameRoot(),P=j[0],W=j[1];if(P&&W){var le=P.split(`
|
|
4
|
+
`),be=W.split(`
|
|
5
|
+
`);for(b=u=0;u<le.length&&!le[u].includes("DetermineComponentFrameRoot");)u++;for(;b<be.length&&!be[b].includes("DetermineComponentFrameRoot");)b++;if(u===le.length||b===be.length)for(u=le.length-1,b=be.length-1;1<=u&&0<=b&&le[u]!==be[b];)b--;for(;1<=u&&0<=b;u--,b--)if(le[u]!==be[b]){if(u!==1||b!==1)do if(u--,b--,0>b||le[u]!==be[b]){var Ee=`
|
|
6
|
+
`+le[u].replace(" at new "," at ");return n.displayName&&Ee.includes("<anonymous>")&&(Ee=Ee.replace("<anonymous>",n.displayName)),Ee}while(1<=u&&0<=b);break}}}finally{Ce=!1,Error.prepareStackTrace=i}return(i=n?n.displayName||n.name:"")?ye(i):""}function tt(n,a){switch(n.tag){case 26:case 27:case 5:return ye(n.type);case 16:return ye("Lazy");case 13:return n.child!==a&&a!==null?ye("Suspense Fallback"):ye("Suspense");case 19:return ye("SuspenseList");case 0:case 15:return ze(n.type,!1);case 11:return ze(n.type.render,!1);case 1:return ze(n.type,!0);case 31:return ye("Activity");default:return""}}function Xe(n){try{var a="",i=null;do a+=tt(n,i),i=n,n=n.return;while(n);return a}catch(u){return`
|
|
7
|
+
Error generating stack: `+u.message+`
|
|
8
|
+
`+u.stack}}var dt=Object.prototype.hasOwnProperty,wt=e.unstable_scheduleCallback,ae=e.unstable_cancelCallback,Te=e.unstable_shouldYield,Ze=e.unstable_requestPaint,xt=e.unstable_now,dn=e.unstable_getCurrentPriorityLevel,we=e.unstable_ImmediatePriority,Re=e.unstable_UserBlockingPriority,qe=e.unstable_NormalPriority,et=e.unstable_LowPriority,nt=e.unstable_IdlePriority,zt=e.log,Yt=e.unstable_setDisableYieldValue,Lt=null,Tt=null;function qt(n){if(typeof zt=="function"&&Yt(n),Tt&&typeof Tt.setStrictMode=="function")try{Tt.setStrictMode(Lt,n)}catch{}}var yt=Math.clz32?Math.clz32:je,sn=Math.log,Xt=Math.LN2;function je(n){return n>>>=0,n===0?32:31-(sn(n)/Xt|0)|0}var Pe=256,vt=262144,Nt=4194304;function ut(n){var a=n&42;if(a!==0)return a;switch(n&-n){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 n&261888;case 262144:case 524288:case 1048576:case 2097152:return n&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return n&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return n}}function Wt(n,a,i){var u=n.pendingLanes;if(u===0)return 0;var b=0,j=n.suspendedLanes,P=n.pingedLanes;n=n.warmLanes;var W=u&134217727;return W!==0?(u=W&~j,u!==0?b=ut(u):(P&=W,P!==0?b=ut(P):i||(i=W&~n,i!==0&&(b=ut(i))))):(W=u&~j,W!==0?b=ut(W):P!==0?b=ut(P):i||(i=u&~n,i!==0&&(b=ut(i)))),b===0?0:a!==0&&a!==b&&(a&j)===0&&(j=b&-b,i=a&-a,j>=i||j===32&&(i&4194048)!==0)?a:b}function en(n,a){return(n.pendingLanes&~(n.suspendedLanes&~n.pingedLanes)&a)===0}function Ct(n,a){switch(n){case 1:case 2:case 4:case 8:case 64:return a+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 a+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 de(){var n=Nt;return Nt<<=1,(Nt&62914560)===0&&(Nt=4194304),n}function Be(n){for(var a=[],i=0;31>i;i++)a.push(n);return a}function Le(n,a){n.pendingLanes|=a,a!==268435456&&(n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0)}function ot(n,a,i,u,b,j){var P=n.pendingLanes;n.pendingLanes=i,n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0,n.expiredLanes&=i,n.entangledLanes&=i,n.errorRecoveryDisabledLanes&=i,n.shellSuspendCounter=0;var W=n.entanglements,le=n.expirationTimes,be=n.hiddenUpdates;for(i=P&~i;0<i;){var Ee=31-yt(i),_e=1<<Ee;W[Ee]=0,le[Ee]=-1;var ve=be[Ee];if(ve!==null)for(be[Ee]=null,Ee=0;Ee<ve.length;Ee++){var Ne=ve[Ee];Ne!==null&&(Ne.lane&=-536870913)}i&=~_e}u!==0&&Qe(n,u,0),j!==0&&b===0&&n.tag!==0&&(n.suspendedLanes|=j&~(P&~a))}function Qe(n,a,i){n.pendingLanes|=a,n.suspendedLanes&=~a;var u=31-yt(a);n.entangledLanes|=a,n.entanglements[u]=n.entanglements[u]|1073741824|i&261930}function ft(n,a){var i=n.entangledLanes|=a;for(n=n.entanglements;i;){var u=31-yt(i),b=1<<u;b&a|n[u]&a&&(n[u]|=a),i&=~b}}function Zt(n,a){var i=a&-a;return i=(i&42)!==0?1:it(i),(i&(n.suspendedLanes|a))!==0?0:i}function it(n){switch(n){case 2:n=1;break;case 8:n=4;break;case 32:n=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:n=128;break;case 268435456:n=134217728;break;default:n=0}return n}function gt(n){return n&=-n,2<n?8<n?(n&134217727)!==0?32:268435456:8:2}function wn(){var n=Y.p;return n!==0?n:(n=window.event,n===void 0?32:K0(n.type))}function an(n,a){var i=Y.p;try{return Y.p=n,a()}finally{Y.p=i}}var Qt=Math.random().toString(36).slice(2),At="__reactFiber$"+Qt,un="__reactProps$"+Qt,En="__reactContainer$"+Qt,fe="__reactEvents$"+Qt,Fe="__reactListeners$"+Qt,kt="__reactHandles$"+Qt,St="__reactResources$"+Qt,Tn="__reactMarker$"+Qt;function Qn(n){delete n[At],delete n[un],delete n[fe],delete n[Fe],delete n[kt]}function hr(n){var a=n[At];if(a)return a;for(var i=n.parentNode;i;){if(a=i[En]||i[At]){if(i=a.alternate,a.child!==null||i!==null&&i.child!==null)for(n=L0(n);n!==null;){if(i=n[At])return i;n=L0(n)}return a}n=i,i=n.parentNode}return null}function or(n){if(n=n[At]||n[En]){var a=n.tag;if(a===5||a===6||a===13||a===31||a===26||a===27||a===3)return n}return null}function tr(n){var a=n.tag;if(a===5||a===26||a===27||a===6)return n.stateNode;throw Error(l(33))}function cr(n){var a=n[St];return a||(a=n[St]={hoistableStyles:new Map,hoistableScripts:new Map}),a}function fn(n){n[Tn]=!0}var os=new Set,Sr={};function nr(n,a){rr(n,a),rr(n+"Capture",a)}function rr(n,a){for(Sr[n]=a,n=0;n<a.length;n++)os.add(a[n])}var Cs=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]*$"),ie={},Se={};function He(n){return dt.call(Se,n)?!0:dt.call(ie,n)?!1:Cs.test(n)?Se[n]=!0:(ie[n]=!0,!1)}function Mt(n,a,i){if(He(a))if(i===null)n.removeAttribute(a);else{switch(typeof i){case"undefined":case"function":case"symbol":n.removeAttribute(a);return;case"boolean":var u=a.toLowerCase().slice(0,5);if(u!=="data-"&&u!=="aria-"){n.removeAttribute(a);return}}n.setAttribute(a,""+i)}}function Gn(n,a,i){if(i===null)n.removeAttribute(a);else{switch(typeof i){case"undefined":case"function":case"symbol":case"boolean":n.removeAttribute(a);return}n.setAttribute(a,""+i)}}function On(n,a,i,u){if(u===null)n.removeAttribute(i);else{switch(typeof u){case"undefined":case"function":case"symbol":case"boolean":n.removeAttribute(i);return}n.setAttributeNS(a,i,""+u)}}function tn(n){switch(typeof n){case"bigint":case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function Hr(n){var a=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(a==="checkbox"||a==="radio")}function Js(n,a,i){var u=Object.getOwnPropertyDescriptor(n.constructor.prototype,a);if(!n.hasOwnProperty(a)&&typeof u<"u"&&typeof u.get=="function"&&typeof u.set=="function"){var b=u.get,j=u.set;return Object.defineProperty(n,a,{configurable:!0,get:function(){return b.call(this)},set:function(P){i=""+P,j.call(this,P)}}),Object.defineProperty(n,a,{enumerable:u.enumerable}),{getValue:function(){return i},setValue:function(P){i=""+P},stopTracking:function(){n._valueTracker=null,delete n[a]}}}}function mr(n){if(!n._valueTracker){var a=Hr(n)?"checked":"value";n._valueTracker=Js(n,a,""+n[a])}}function dr(n){if(!n)return!1;var a=n._valueTracker;if(!a)return!0;var i=a.getValue(),u="";return n&&(u=Hr(n)?n.checked?"true":"false":n.value),n=u,n!==i?(a.setValue(n),!0):!1}function Cr(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}var Er=/[\n"\\]/g;function An(n){return n.replace(Er,function(a){return"\\"+a.charCodeAt(0).toString(16)+" "})}function Tr(n,a,i,u,b,j,P,W){n.name="",P!=null&&typeof P!="function"&&typeof P!="symbol"&&typeof P!="boolean"?n.type=P:n.removeAttribute("type"),a!=null?P==="number"?(a===0&&n.value===""||n.value!=a)&&(n.value=""+tn(a)):n.value!==""+tn(a)&&(n.value=""+tn(a)):P!=="submit"&&P!=="reset"||n.removeAttribute("value"),a!=null?Kr(n,P,tn(a)):i!=null?Kr(n,P,tn(i)):u!=null&&n.removeAttribute("value"),b==null&&j!=null&&(n.defaultChecked=!!j),b!=null&&(n.checked=b&&typeof b!="function"&&typeof b!="symbol"),W!=null&&typeof W!="function"&&typeof W!="symbol"&&typeof W!="boolean"?n.name=""+tn(W):n.removeAttribute("name")}function cs(n,a,i,u,b,j,P,W){if(j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"&&(n.type=j),a!=null||i!=null){if(!(j!=="submit"&&j!=="reset"||a!=null)){mr(n);return}i=i!=null?""+tn(i):"",a=a!=null?""+tn(a):i,W||a===n.value||(n.value=a),n.defaultValue=a}u=u??b,u=typeof u!="function"&&typeof u!="symbol"&&!!u,n.checked=W?n.checked:!!u,n.defaultChecked=!!u,P!=null&&typeof P!="function"&&typeof P!="symbol"&&typeof P!="boolean"&&(n.name=P),mr(n)}function Kr(n,a,i){a==="number"&&Cr(n.ownerDocument)===n||n.defaultValue===""+i||(n.defaultValue=""+i)}function ne(n,a,i,u){if(n=n.options,a){a={};for(var b=0;b<i.length;b++)a["$"+i[b]]=!0;for(i=0;i<n.length;i++)b=a.hasOwnProperty("$"+n[i].value),n[i].selected!==b&&(n[i].selected=b),b&&u&&(n[i].defaultSelected=!0)}else{for(i=""+tn(i),a=null,b=0;b<n.length;b++){if(n[b].value===i){n[b].selected=!0,u&&(n[b].defaultSelected=!0);return}a!==null||n[b].disabled||(a=n[b])}a!==null&&(a.selected=!0)}}function Z(n,a,i){if(a!=null&&(a=""+tn(a),a!==n.value&&(n.value=a),i==null)){n.defaultValue!==a&&(n.defaultValue=a);return}n.defaultValue=i!=null?""+tn(i):""}function oe(n,a,i,u){if(a==null){if(u!=null){if(i!=null)throw Error(l(92));if(z(u)){if(1<u.length)throw Error(l(93));u=u[0]}i=u}i==null&&(i=""),a=i}i=tn(a),n.defaultValue=i,u=n.textContent,u===i&&u!==""&&u!==null&&(n.value=u),mr(n)}function me(n,a){if(a){var i=n.firstChild;if(i&&i===n.lastChild&&i.nodeType===3){i.nodeValue=a;return}}n.textContent=a}var Ie=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 Me(n,a,i){var u=a.indexOf("--")===0;i==null||typeof i=="boolean"||i===""?u?n.setProperty(a,""):a==="float"?n.cssFloat="":n[a]="":u?n.setProperty(a,i):typeof i!="number"||i===0||Ie.has(a)?a==="float"?n.cssFloat=i:n[a]=(""+i).trim():n[a]=i+"px"}function Ue(n,a,i){if(a!=null&&typeof a!="object")throw Error(l(62));if(n=n.style,i!=null){for(var u in i)!i.hasOwnProperty(u)||a!=null&&a.hasOwnProperty(u)||(u.indexOf("--")===0?n.setProperty(u,""):u==="float"?n.cssFloat="":n[u]="");for(var b in a)u=a[b],a.hasOwnProperty(b)&&i[b]!==u&&Me(n,b,u)}else for(var j in a)a.hasOwnProperty(j)&&Me(n,j,a[j])}function Ve(n){if(n.indexOf("-")===-1)return!1;switch(n){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 Oe=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"]]),bt=/^[\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 Gt(n){return bt.test(""+n)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":n}function Dt(){}var _n=null;function at(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var ht=null,Ye=null;function Ke(n){var a=or(n);if(a&&(n=a.stateNode)){var i=n[un]||null;e:switch(n=a.stateNode,a.type){case"input":if(Tr(n,i.value,i.defaultValue,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name),a=i.name,i.type==="radio"&&a!=null){for(i=n;i.parentNode;)i=i.parentNode;for(i=i.querySelectorAll('input[name="'+An(""+a)+'"][type="radio"]'),a=0;a<i.length;a++){var u=i[a];if(u!==n&&u.form===n.form){var b=u[un]||null;if(!b)throw Error(l(90));Tr(u,b.value,b.defaultValue,b.defaultValue,b.checked,b.defaultChecked,b.type,b.name)}}for(a=0;a<i.length;a++)u=i[a],u.form===n.form&&dr(u)}break e;case"textarea":Z(n,i.value,i.defaultValue);break e;case"select":a=i.value,a!=null&&ne(n,!!i.multiple,a,!1)}}}var Je=!1;function st(n,a,i){if(Je)return n(a,i);Je=!0;try{var u=n(a);return u}finally{if(Je=!1,(ht!==null||Ye!==null)&&(_c(),ht&&(a=ht,n=Ye,Ye=ht=null,Ke(a),n)))for(a=0;a<n.length;a++)Ke(n[a])}}function Ge(n,a){var i=n.stateNode;if(i===null)return null;var u=i[un]||null;if(u===null)return null;i=u[a];e:switch(a){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)||(n=n.type,u=!(n==="button"||n==="input"||n==="select"||n==="textarea")),n=!u;break e;default:n=!1}if(n)return null;if(i&&typeof i!="function")throw Error(l(231,a,typeof i));return i}var rn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),sr=!1;if(rn)try{var Es={};Object.defineProperty(Es,"passive",{get:function(){sr=!0}}),window.addEventListener("test",Es,Es),window.removeEventListener("test",Es,Es)}catch{sr=!1}var ds=null,fu=null,Fo=null;function Tx(){if(Fo)return Fo;var n,a=fu,i=a.length,u,b="value"in ds?ds.value:ds.textContent,j=b.length;for(n=0;n<i&&a[n]===b[n];n++);var P=i-n;for(u=1;u<=P&&a[i-u]===b[j-u];u++);return Fo=b.slice(n,1<u?1-u:void 0)}function Vo(n){var a=n.keyCode;return"charCode"in n?(n=n.charCode,n===0&&a===13&&(n=13)):n=a,n===10&&(n=13),32<=n||n===13?n:0}function Yo(){return!0}function Ax(){return!1}function xr(n){function a(i,u,b,j,P){this._reactName=i,this._targetInst=b,this.type=u,this.nativeEvent=j,this.target=P,this.currentTarget=null;for(var W in n)n.hasOwnProperty(W)&&(i=n[W],this[W]=i?i(j):j[W]);return this.isDefaultPrevented=(j.defaultPrevented!=null?j.defaultPrevented:j.returnValue===!1)?Yo:Ax,this.isPropagationStopped=Ax,this}return g(a.prototype,{preventDefault:function(){this.defaultPrevented=!0;var i=this.nativeEvent;i&&(i.preventDefault?i.preventDefault():typeof i.returnValue!="unknown"&&(i.returnValue=!1),this.isDefaultPrevented=Yo)},stopPropagation:function(){var i=this.nativeEvent;i&&(i.stopPropagation?i.stopPropagation():typeof i.cancelBubble!="unknown"&&(i.cancelBubble=!0),this.isPropagationStopped=Yo)},persist:function(){},isPersistent:Yo}),a}var Oa={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Go=xr(Oa),di=g({},Oa,{view:0,detail:0}),MN=xr(di),hu,mu,ui,Xo=g({},di,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:gu,button:0,buttons:0,relatedTarget:function(n){return n.relatedTarget===void 0?n.fromElement===n.srcElement?n.toElement:n.fromElement:n.relatedTarget},movementX:function(n){return"movementX"in n?n.movementX:(n!==ui&&(ui&&n.type==="mousemove"?(hu=n.screenX-ui.screenX,mu=n.screenY-ui.screenY):mu=hu=0,ui=n),hu)},movementY:function(n){return"movementY"in n?n.movementY:mu}}),_x=xr(Xo),DN=g({},Xo,{dataTransfer:0}),ON=xr(DN),RN=g({},di,{relatedTarget:0}),xu=xr(RN),LN=g({},Oa,{animationName:0,elapsedTime:0,pseudoElement:0}),zN=xr(LN),IN=g({},Oa,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),$N=xr(IN),BN=g({},Oa,{data:0}),Mx=xr(BN),HN={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},PN={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"},UN={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function qN(n){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(n):(n=UN[n])?!!a[n]:!1}function gu(){return qN}var FN=g({},di,{key:function(n){if(n.key){var a=HN[n.key]||n.key;if(a!=="Unidentified")return a}return n.type==="keypress"?(n=Vo(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?PN[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:gu,charCode:function(n){return n.type==="keypress"?Vo(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?Vo(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),VN=xr(FN),YN=g({},Xo,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Dx=xr(YN),GN=g({},di,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:gu}),XN=xr(GN),ZN=g({},Oa,{propertyName:0,elapsedTime:0,pseudoElement:0}),QN=xr(ZN),KN=g({},Xo,{deltaX:function(n){return"deltaX"in n?n.deltaX:"wheelDeltaX"in n?-n.wheelDeltaX:0},deltaY:function(n){return"deltaY"in n?n.deltaY:"wheelDeltaY"in n?-n.wheelDeltaY:"wheelDelta"in n?-n.wheelDelta:0},deltaZ:0,deltaMode:0}),JN=xr(KN),WN=g({},Oa,{newState:0,oldState:0}),e5=xr(WN),t5=[9,13,27,32],pu=rn&&"CompositionEvent"in window,fi=null;rn&&"documentMode"in document&&(fi=document.documentMode);var n5=rn&&"TextEvent"in window&&!fi,Ox=rn&&(!pu||fi&&8<fi&&11>=fi),Rx=" ",Lx=!1;function zx(n,a){switch(n){case"keyup":return t5.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ix(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var dl=!1;function r5(n,a){switch(n){case"compositionend":return Ix(a);case"keypress":return a.which!==32?null:(Lx=!0,Rx);case"textInput":return n=a.data,n===Rx&&Lx?null:n;default:return null}}function s5(n,a){if(dl)return n==="compositionend"||!pu&&zx(n,a)?(n=Tx(),Fo=fu=ds=null,dl=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(a.ctrlKey||a.altKey||a.metaKey)||a.ctrlKey&&a.altKey){if(a.char&&1<a.char.length)return a.char;if(a.which)return String.fromCharCode(a.which)}return null;case"compositionend":return Ox&&a.locale!=="ko"?null:a.data;default:return null}}var a5={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 $x(n){var a=n&&n.nodeName&&n.nodeName.toLowerCase();return a==="input"?!!a5[n.type]:a==="textarea"}function Bx(n,a,i,u){ht?Ye?Ye.push(u):Ye=[u]:ht=u,a=Ic(a,"onChange"),0<a.length&&(i=new Go("onChange","change",null,i,u),n.push({event:i,listeners:a}))}var hi=null,mi=null;function l5(n){j0(n,0)}function Zo(n){var a=tr(n);if(dr(a))return n}function Hx(n,a){if(n==="change")return a}var Px=!1;if(rn){var bu;if(rn){var yu="oninput"in document;if(!yu){var Ux=document.createElement("div");Ux.setAttribute("oninput","return;"),yu=typeof Ux.oninput=="function"}bu=yu}else bu=!1;Px=bu&&(!document.documentMode||9<document.documentMode)}function qx(){hi&&(hi.detachEvent("onpropertychange",Fx),mi=hi=null)}function Fx(n){if(n.propertyName==="value"&&Zo(mi)){var a=[];Bx(a,mi,n,at(n)),st(l5,a)}}function i5(n,a,i){n==="focusin"?(qx(),hi=a,mi=i,hi.attachEvent("onpropertychange",Fx)):n==="focusout"&&qx()}function o5(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return Zo(mi)}function c5(n,a){if(n==="click")return Zo(a)}function d5(n,a){if(n==="input"||n==="change")return Zo(a)}function u5(n,a){return n===a&&(n!==0||1/n===1/a)||n!==n&&a!==a}var Ar=typeof Object.is=="function"?Object.is:u5;function xi(n,a){if(Ar(n,a))return!0;if(typeof n!="object"||n===null||typeof a!="object"||a===null)return!1;var i=Object.keys(n),u=Object.keys(a);if(i.length!==u.length)return!1;for(u=0;u<i.length;u++){var b=i[u];if(!dt.call(a,b)||!Ar(n[b],a[b]))return!1}return!0}function Vx(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function Yx(n,a){var i=Vx(n);n=0;for(var u;i;){if(i.nodeType===3){if(u=n+i.textContent.length,n<=a&&u>=a)return{node:i,offset:a-n};n=u}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Vx(i)}}function Gx(n,a){return n&&a?n===a?!0:n&&n.nodeType===3?!1:a&&a.nodeType===3?Gx(n,a.parentNode):"contains"in n?n.contains(a):n.compareDocumentPosition?!!(n.compareDocumentPosition(a)&16):!1:!1}function Xx(n){n=n!=null&&n.ownerDocument!=null&&n.ownerDocument.defaultView!=null?n.ownerDocument.defaultView:window;for(var a=Cr(n.document);a instanceof n.HTMLIFrameElement;){try{var i=typeof a.contentWindow.location.href=="string"}catch{i=!1}if(i)n=a.contentWindow;else break;a=Cr(n.document)}return a}function vu(n){var a=n&&n.nodeName&&n.nodeName.toLowerCase();return a&&(a==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||a==="textarea"||n.contentEditable==="true")}var f5=rn&&"documentMode"in document&&11>=document.documentMode,ul=null,ju=null,gi=null,wu=!1;function Zx(n,a,i){var u=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;wu||ul==null||ul!==Cr(u)||(u=ul,"selectionStart"in u&&vu(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}),gi&&xi(gi,u)||(gi=u,u=Ic(ju,"onSelect"),0<u.length&&(a=new Go("onSelect","select",null,a,i),n.push({event:a,listeners:u}),a.target=ul)))}function Ra(n,a){var i={};return i[n.toLowerCase()]=a.toLowerCase(),i["Webkit"+n]="webkit"+a,i["Moz"+n]="moz"+a,i}var fl={animationend:Ra("Animation","AnimationEnd"),animationiteration:Ra("Animation","AnimationIteration"),animationstart:Ra("Animation","AnimationStart"),transitionrun:Ra("Transition","TransitionRun"),transitionstart:Ra("Transition","TransitionStart"),transitioncancel:Ra("Transition","TransitionCancel"),transitionend:Ra("Transition","TransitionEnd")},Nu={},Qx={};rn&&(Qx=document.createElement("div").style,"AnimationEvent"in window||(delete fl.animationend.animation,delete fl.animationiteration.animation,delete fl.animationstart.animation),"TransitionEvent"in window||delete fl.transitionend.transition);function La(n){if(Nu[n])return Nu[n];if(!fl[n])return n;var a=fl[n],i;for(i in a)if(a.hasOwnProperty(i)&&i in Qx)return Nu[n]=a[i];return n}var Kx=La("animationend"),Jx=La("animationiteration"),Wx=La("animationstart"),h5=La("transitionrun"),m5=La("transitionstart"),x5=La("transitioncancel"),eg=La("transitionend"),tg=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 Jr(n,a){tg.set(n,a),nr(a,[n])}var Qo=typeof reportError=="function"?reportError:function(n){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var a=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof n=="object"&&n!==null&&typeof n.message=="string"?String(n.message):String(n),error:n});if(!window.dispatchEvent(a))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",n);return}console.error(n)},Pr=[],hl=0,Su=0;function Ko(){for(var n=hl,a=Su=hl=0;a<n;){var i=Pr[a];Pr[a++]=null;var u=Pr[a];Pr[a++]=null;var b=Pr[a];Pr[a++]=null;var j=Pr[a];if(Pr[a++]=null,u!==null&&b!==null){var P=u.pending;P===null?b.next=b:(b.next=P.next,P.next=b),u.pending=b}j!==0&&ng(i,b,j)}}function Jo(n,a,i,u){Pr[hl++]=n,Pr[hl++]=a,Pr[hl++]=i,Pr[hl++]=u,Su|=u,n.lanes|=u,n=n.alternate,n!==null&&(n.lanes|=u)}function Cu(n,a,i,u){return Jo(n,a,i,u),Wo(n)}function za(n,a){return Jo(n,null,null,a),Wo(n)}function ng(n,a,i){n.lanes|=i;var u=n.alternate;u!==null&&(u.lanes|=i);for(var b=!1,j=n.return;j!==null;)j.childLanes|=i,u=j.alternate,u!==null&&(u.childLanes|=i),j.tag===22&&(n=j.stateNode,n===null||n._visibility&1||(b=!0)),n=j,j=j.return;return n.tag===3?(j=n.stateNode,b&&a!==null&&(b=31-yt(i),n=j.hiddenUpdates,u=n[b],u===null?n[b]=[a]:u.push(a),a.lane=i|536870912),j):null}function Wo(n){if(50<$i)throw $i=0,zf=null,Error(l(185));for(var a=n.return;a!==null;)n=a,a=n.return;return n.tag===3?n.stateNode:null}var ml={};function g5(n,a,i,u){this.tag=n,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=a,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 _r(n,a,i,u){return new g5(n,a,i,u)}function Eu(n){return n=n.prototype,!(!n||!n.isReactComponent)}function Ts(n,a){var i=n.alternate;return i===null?(i=_r(n.tag,a,n.key,n.mode),i.elementType=n.elementType,i.type=n.type,i.stateNode=n.stateNode,i.alternate=n,n.alternate=i):(i.pendingProps=a,i.type=n.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=n.flags&65011712,i.childLanes=n.childLanes,i.lanes=n.lanes,i.child=n.child,i.memoizedProps=n.memoizedProps,i.memoizedState=n.memoizedState,i.updateQueue=n.updateQueue,a=n.dependencies,i.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext},i.sibling=n.sibling,i.index=n.index,i.ref=n.ref,i.refCleanup=n.refCleanup,i}function rg(n,a){n.flags&=65011714;var i=n.alternate;return i===null?(n.childLanes=0,n.lanes=a,n.child=null,n.subtreeFlags=0,n.memoizedProps=null,n.memoizedState=null,n.updateQueue=null,n.dependencies=null,n.stateNode=null):(n.childLanes=i.childLanes,n.lanes=i.lanes,n.child=i.child,n.subtreeFlags=0,n.deletions=null,n.memoizedProps=i.memoizedProps,n.memoizedState=i.memoizedState,n.updateQueue=i.updateQueue,n.type=i.type,a=i.dependencies,n.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext}),n}function ec(n,a,i,u,b,j){var P=0;if(u=n,typeof n=="function")Eu(n)&&(P=1);else if(typeof n=="string")P=j2(n,i,M.current)?26:n==="html"||n==="head"||n==="body"?27:5;else e:switch(n){case Q:return n=_r(31,i,a,b),n.elementType=Q,n.lanes=j,n;case N:return Ia(i.children,b,j,a);case E:P=8,b|=24;break;case A:return n=_r(12,i,a,b|2),n.elementType=A,n.lanes=j,n;case O:return n=_r(13,i,a,b),n.elementType=O,n.lanes=j,n;case R:return n=_r(19,i,a,b),n.elementType=R,n.lanes=j,n;default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case k:P=10;break e;case C:P=9;break e;case S:P=11;break e;case G:P=14;break e;case I:P=16,u=null;break e}P=29,i=Error(l(130,n===null?"null":typeof n,"")),u=null}return a=_r(P,i,a,b),a.elementType=n,a.type=u,a.lanes=j,a}function Ia(n,a,i,u){return n=_r(7,n,u,a),n.lanes=i,n}function Tu(n,a,i){return n=_r(6,n,null,a),n.lanes=i,n}function sg(n){var a=_r(18,null,null,0);return a.stateNode=n,a}function Au(n,a,i){return a=_r(4,n.children!==null?n.children:[],n.key,a),a.lanes=i,a.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},a}var ag=new WeakMap;function Ur(n,a){if(typeof n=="object"&&n!==null){var i=ag.get(n);return i!==void 0?i:(a={value:n,source:a,stack:Xe(a)},ag.set(n,a),a)}return{value:n,source:a,stack:Xe(a)}}var xl=[],gl=0,tc=null,pi=0,qr=[],Fr=0,Ws=null,us=1,fs="";function As(n,a){xl[gl++]=pi,xl[gl++]=tc,tc=n,pi=a}function lg(n,a,i){qr[Fr++]=us,qr[Fr++]=fs,qr[Fr++]=Ws,Ws=n;var u=us;n=fs;var b=32-yt(u)-1;u&=~(1<<b),i+=1;var j=32-yt(a)+b;if(30<j){var P=b-b%5;j=(u&(1<<P)-1).toString(32),u>>=P,b-=P,us=1<<32-yt(a)+b|i<<b|u,fs=j+n}else us=1<<j|i<<b|u,fs=n}function _u(n){n.return!==null&&(As(n,1),lg(n,1,0))}function Mu(n){for(;n===tc;)tc=xl[--gl],xl[gl]=null,pi=xl[--gl],xl[gl]=null;for(;n===Ws;)Ws=qr[--Fr],qr[Fr]=null,fs=qr[--Fr],qr[Fr]=null,us=qr[--Fr],qr[Fr]=null}function ig(n,a){qr[Fr++]=us,qr[Fr++]=fs,qr[Fr++]=Ws,us=a.id,fs=a.overflow,Ws=n}var Kn=null,yn=null,Ut=!1,ea=null,Vr=!1,Du=Error(l(519));function ta(n){var a=Error(l(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw bi(Ur(a,n)),Du}function og(n){var a=n.stateNode,i=n.type,u=n.memoizedProps;switch(a[At]=n,a[un]=u,i){case"dialog":$t("cancel",a),$t("close",a);break;case"iframe":case"object":case"embed":$t("load",a);break;case"video":case"audio":for(i=0;i<Hi.length;i++)$t(Hi[i],a);break;case"source":$t("error",a);break;case"img":case"image":case"link":$t("error",a),$t("load",a);break;case"details":$t("toggle",a);break;case"input":$t("invalid",a),cs(a,u.value,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name,!0);break;case"select":$t("invalid",a);break;case"textarea":$t("invalid",a),oe(a,u.value,u.defaultValue,u.children)}i=u.children,typeof i!="string"&&typeof i!="number"&&typeof i!="bigint"||a.textContent===""+i||u.suppressHydrationWarning===!0||S0(a.textContent,i)?(u.popover!=null&&($t("beforetoggle",a),$t("toggle",a)),u.onScroll!=null&&$t("scroll",a),u.onScrollEnd!=null&&$t("scrollend",a),u.onClick!=null&&(a.onclick=Dt),a=!0):a=!1,a||ta(n,!0)}function cg(n){for(Kn=n.return;Kn;)switch(Kn.tag){case 5:case 31:case 13:Vr=!1;return;case 27:case 3:Vr=!0;return;default:Kn=Kn.return}}function pl(n){if(n!==Kn)return!1;if(!Ut)return cg(n),Ut=!0,!1;var a=n.tag,i;if((i=a!==3&&a!==27)&&((i=a===5)&&(i=n.type,i=!(i!=="form"&&i!=="button")||Kf(n.type,n.memoizedProps)),i=!i),i&&yn&&ta(n),cg(n),a===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(l(317));yn=R0(n)}else if(a===31){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(l(317));yn=R0(n)}else a===27?(a=yn,xa(n.type)?(n=nh,nh=null,yn=n):yn=a):yn=Kn?Gr(n.stateNode.nextSibling):null;return!0}function $a(){yn=Kn=null,Ut=!1}function Ou(){var n=ea;return n!==null&&(yr===null?yr=n:yr.push.apply(yr,n),ea=null),n}function bi(n){ea===null?ea=[n]:ea.push(n)}var Ru=H(null),Ba=null,_s=null;function na(n,a,i){L(Ru,a._currentValue),a._currentValue=i}function Ms(n){n._currentValue=Ru.current,X(Ru)}function Lu(n,a,i){for(;n!==null;){var u=n.alternate;if((n.childLanes&a)!==a?(n.childLanes|=a,u!==null&&(u.childLanes|=a)):u!==null&&(u.childLanes&a)!==a&&(u.childLanes|=a),n===i)break;n=n.return}}function zu(n,a,i,u){var b=n.child;for(b!==null&&(b.return=n);b!==null;){var j=b.dependencies;if(j!==null){var P=b.child;j=j.firstContext;e:for(;j!==null;){var W=j;j=b;for(var le=0;le<a.length;le++)if(W.context===a[le]){j.lanes|=i,W=j.alternate,W!==null&&(W.lanes|=i),Lu(j.return,i,n),u||(P=null);break e}j=W.next}}else if(b.tag===18){if(P=b.return,P===null)throw Error(l(341));P.lanes|=i,j=P.alternate,j!==null&&(j.lanes|=i),Lu(P,i,n),P=null}else P=b.child;if(P!==null)P.return=b;else for(P=b;P!==null;){if(P===n){P=null;break}if(b=P.sibling,b!==null){b.return=P.return,P=b;break}P=P.return}b=P}}function bl(n,a,i,u){n=null;for(var b=a,j=!1;b!==null;){if(!j){if((b.flags&524288)!==0)j=!0;else if((b.flags&262144)!==0)break}if(b.tag===10){var P=b.alternate;if(P===null)throw Error(l(387));if(P=P.memoizedProps,P!==null){var W=b.type;Ar(b.pendingProps.value,P.value)||(n!==null?n.push(W):n=[W])}}else if(b===ee.current){if(P=b.alternate,P===null)throw Error(l(387));P.memoizedState.memoizedState!==b.memoizedState.memoizedState&&(n!==null?n.push(Vi):n=[Vi])}b=b.return}n!==null&&zu(a,n,i,u),a.flags|=262144}function nc(n){for(n=n.firstContext;n!==null;){if(!Ar(n.context._currentValue,n.memoizedValue))return!0;n=n.next}return!1}function Ha(n){Ba=n,_s=null,n=n.dependencies,n!==null&&(n.firstContext=null)}function Jn(n){return dg(Ba,n)}function rc(n,a){return Ba===null&&Ha(n),dg(n,a)}function dg(n,a){var i=a._currentValue;if(a={context:a,memoizedValue:i,next:null},_s===null){if(n===null)throw Error(l(308));_s=a,n.dependencies={lanes:0,firstContext:a},n.flags|=524288}else _s=_s.next=a;return i}var p5=typeof AbortController<"u"?AbortController:function(){var n=[],a=this.signal={aborted:!1,addEventListener:function(i,u){n.push(u)}};this.abort=function(){a.aborted=!0,n.forEach(function(i){return i()})}},b5=e.unstable_scheduleCallback,y5=e.unstable_NormalPriority,In={$$typeof:k,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Iu(){return{controller:new p5,data:new Map,refCount:0}}function yi(n){n.refCount--,n.refCount===0&&b5(y5,function(){n.controller.abort()})}var vi=null,$u=0,yl=0,vl=null;function v5(n,a){if(vi===null){var i=vi=[];$u=0,yl=Uf(),vl={status:"pending",value:void 0,then:function(u){i.push(u)}}}return $u++,a.then(ug,ug),a}function ug(){if(--$u===0&&vi!==null){vl!==null&&(vl.status="fulfilled");var n=vi;vi=null,yl=0,vl=null;for(var a=0;a<n.length;a++)(0,n[a])()}}function j5(n,a){var i=[],u={status:"pending",value:null,reason:null,then:function(b){i.push(b)}};return n.then(function(){u.status="fulfilled",u.value=a;for(var b=0;b<i.length;b++)(0,i[b])(a)},function(b){for(u.status="rejected",u.reason=b,b=0;b<i.length;b++)(0,i[b])(void 0)}),u}var fg=_.S;_.S=function(n,a){Zp=xt(),typeof a=="object"&&a!==null&&typeof a.then=="function"&&v5(n,a),fg!==null&&fg(n,a)};var Pa=H(null);function Bu(){var n=Pa.current;return n!==null?n:gn.pooledCache}function sc(n,a){a===null?L(Pa,Pa.current):L(Pa,a.pool)}function hg(){var n=Bu();return n===null?null:{parent:In._currentValue,pool:n}}var jl=Error(l(460)),Hu=Error(l(474)),ac=Error(l(542)),lc={then:function(){}};function mg(n){return n=n.status,n==="fulfilled"||n==="rejected"}function xg(n,a,i){switch(i=n[i],i===void 0?n.push(a):i!==a&&(a.then(Dt,Dt),a=i),a.status){case"fulfilled":return a.value;case"rejected":throw n=a.reason,pg(n),n;default:if(typeof a.status=="string")a.then(Dt,Dt);else{if(n=gn,n!==null&&100<n.shellSuspendCounter)throw Error(l(482));n=a,n.status="pending",n.then(function(u){if(a.status==="pending"){var b=a;b.status="fulfilled",b.value=u}},function(u){if(a.status==="pending"){var b=a;b.status="rejected",b.reason=u}})}switch(a.status){case"fulfilled":return a.value;case"rejected":throw n=a.reason,pg(n),n}throw qa=a,jl}}function Ua(n){try{var a=n._init;return a(n._payload)}catch(i){throw i!==null&&typeof i=="object"&&typeof i.then=="function"?(qa=i,jl):i}}var qa=null;function gg(){if(qa===null)throw Error(l(459));var n=qa;return qa=null,n}function pg(n){if(n===jl||n===ac)throw Error(l(483))}var wl=null,ji=0;function ic(n){var a=ji;return ji+=1,wl===null&&(wl=[]),xg(wl,n,a)}function wi(n,a){a=a.props.ref,n.ref=a!==void 0?a:null}function oc(n,a){throw a.$$typeof===p?Error(l(525)):(n=Object.prototype.toString.call(a),Error(l(31,n==="[object Object]"?"object with keys {"+Object.keys(a).join(", ")+"}":n)))}function bg(n){function a(ue,ce){if(n){var pe=ue.deletions;pe===null?(ue.deletions=[ce],ue.flags|=16):pe.push(ce)}}function i(ue,ce){if(!n)return null;for(;ce!==null;)a(ue,ce),ce=ce.sibling;return null}function u(ue){for(var ce=new Map;ue!==null;)ue.key!==null?ce.set(ue.key,ue):ce.set(ue.index,ue),ue=ue.sibling;return ce}function b(ue,ce){return ue=Ts(ue,ce),ue.index=0,ue.sibling=null,ue}function j(ue,ce,pe){return ue.index=pe,n?(pe=ue.alternate,pe!==null?(pe=pe.index,pe<ce?(ue.flags|=67108866,ce):pe):(ue.flags|=67108866,ce)):(ue.flags|=1048576,ce)}function P(ue){return n&&ue.alternate===null&&(ue.flags|=67108866),ue}function W(ue,ce,pe,Ae){return ce===null||ce.tag!==6?(ce=Tu(pe,ue.mode,Ae),ce.return=ue,ce):(ce=b(ce,pe),ce.return=ue,ce)}function le(ue,ce,pe,Ae){var ct=pe.type;return ct===N?Ee(ue,ce,pe.props.children,Ae,pe.key):ce!==null&&(ce.elementType===ct||typeof ct=="object"&&ct!==null&&ct.$$typeof===I&&Ua(ct)===ce.type)?(ce=b(ce,pe.props),wi(ce,pe),ce.return=ue,ce):(ce=ec(pe.type,pe.key,pe.props,null,ue.mode,Ae),wi(ce,pe),ce.return=ue,ce)}function be(ue,ce,pe,Ae){return ce===null||ce.tag!==4||ce.stateNode.containerInfo!==pe.containerInfo||ce.stateNode.implementation!==pe.implementation?(ce=Au(pe,ue.mode,Ae),ce.return=ue,ce):(ce=b(ce,pe.children||[]),ce.return=ue,ce)}function Ee(ue,ce,pe,Ae,ct){return ce===null||ce.tag!==7?(ce=Ia(pe,ue.mode,Ae,ct),ce.return=ue,ce):(ce=b(ce,pe),ce.return=ue,ce)}function _e(ue,ce,pe){if(typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint")return ce=Tu(""+ce,ue.mode,pe),ce.return=ue,ce;if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case y:return pe=ec(ce.type,ce.key,ce.props,null,ue.mode,pe),wi(pe,ce),pe.return=ue,pe;case w:return ce=Au(ce,ue.mode,pe),ce.return=ue,ce;case I:return ce=Ua(ce),_e(ue,ce,pe)}if(z(ce)||B(ce))return ce=Ia(ce,ue.mode,pe,null),ce.return=ue,ce;if(typeof ce.then=="function")return _e(ue,ic(ce),pe);if(ce.$$typeof===k)return _e(ue,rc(ue,ce),pe);oc(ue,ce)}return null}function ve(ue,ce,pe,Ae){var ct=ce!==null?ce.key:null;if(typeof pe=="string"&&pe!==""||typeof pe=="number"||typeof pe=="bigint")return ct!==null?null:W(ue,ce,""+pe,Ae);if(typeof pe=="object"&&pe!==null){switch(pe.$$typeof){case y:return pe.key===ct?le(ue,ce,pe,Ae):null;case w:return pe.key===ct?be(ue,ce,pe,Ae):null;case I:return pe=Ua(pe),ve(ue,ce,pe,Ae)}if(z(pe)||B(pe))return ct!==null?null:Ee(ue,ce,pe,Ae,null);if(typeof pe.then=="function")return ve(ue,ce,ic(pe),Ae);if(pe.$$typeof===k)return ve(ue,ce,rc(ue,pe),Ae);oc(ue,pe)}return null}function Ne(ue,ce,pe,Ae,ct){if(typeof Ae=="string"&&Ae!==""||typeof Ae=="number"||typeof Ae=="bigint")return ue=ue.get(pe)||null,W(ce,ue,""+Ae,ct);if(typeof Ae=="object"&&Ae!==null){switch(Ae.$$typeof){case y:return ue=ue.get(Ae.key===null?pe:Ae.key)||null,le(ce,ue,Ae,ct);case w:return ue=ue.get(Ae.key===null?pe:Ae.key)||null,be(ce,ue,Ae,ct);case I:return Ae=Ua(Ae),Ne(ue,ce,pe,Ae,ct)}if(z(Ae)||B(Ae))return ue=ue.get(pe)||null,Ee(ce,ue,Ae,ct,null);if(typeof Ae.then=="function")return Ne(ue,ce,pe,ic(Ae),ct);if(Ae.$$typeof===k)return Ne(ue,ce,pe,rc(ce,Ae),ct);oc(ce,Ae)}return null}function We(ue,ce,pe,Ae){for(var ct=null,Kt=null,rt=ce,Ot=ce=0,Pt=null;rt!==null&&Ot<pe.length;Ot++){rt.index>Ot?(Pt=rt,rt=null):Pt=rt.sibling;var Jt=ve(ue,rt,pe[Ot],Ae);if(Jt===null){rt===null&&(rt=Pt);break}n&&rt&&Jt.alternate===null&&a(ue,rt),ce=j(Jt,ce,Ot),Kt===null?ct=Jt:Kt.sibling=Jt,Kt=Jt,rt=Pt}if(Ot===pe.length)return i(ue,rt),Ut&&As(ue,Ot),ct;if(rt===null){for(;Ot<pe.length;Ot++)rt=_e(ue,pe[Ot],Ae),rt!==null&&(ce=j(rt,ce,Ot),Kt===null?ct=rt:Kt.sibling=rt,Kt=rt);return Ut&&As(ue,Ot),ct}for(rt=u(rt);Ot<pe.length;Ot++)Pt=Ne(rt,ue,Ot,pe[Ot],Ae),Pt!==null&&(n&&Pt.alternate!==null&&rt.delete(Pt.key===null?Ot:Pt.key),ce=j(Pt,ce,Ot),Kt===null?ct=Pt:Kt.sibling=Pt,Kt=Pt);return n&&rt.forEach(function(va){return a(ue,va)}),Ut&&As(ue,Ot),ct}function pt(ue,ce,pe,Ae){if(pe==null)throw Error(l(151));for(var ct=null,Kt=null,rt=ce,Ot=ce=0,Pt=null,Jt=pe.next();rt!==null&&!Jt.done;Ot++,Jt=pe.next()){rt.index>Ot?(Pt=rt,rt=null):Pt=rt.sibling;var va=ve(ue,rt,Jt.value,Ae);if(va===null){rt===null&&(rt=Pt);break}n&&rt&&va.alternate===null&&a(ue,rt),ce=j(va,ce,Ot),Kt===null?ct=va:Kt.sibling=va,Kt=va,rt=Pt}if(Jt.done)return i(ue,rt),Ut&&As(ue,Ot),ct;if(rt===null){for(;!Jt.done;Ot++,Jt=pe.next())Jt=_e(ue,Jt.value,Ae),Jt!==null&&(ce=j(Jt,ce,Ot),Kt===null?ct=Jt:Kt.sibling=Jt,Kt=Jt);return Ut&&As(ue,Ot),ct}for(rt=u(rt);!Jt.done;Ot++,Jt=pe.next())Jt=Ne(rt,ue,Ot,Jt.value,Ae),Jt!==null&&(n&&Jt.alternate!==null&&rt.delete(Jt.key===null?Ot:Jt.key),ce=j(Jt,ce,Ot),Kt===null?ct=Jt:Kt.sibling=Jt,Kt=Jt);return n&&rt.forEach(function(D2){return a(ue,D2)}),Ut&&As(ue,Ot),ct}function xn(ue,ce,pe,Ae){if(typeof pe=="object"&&pe!==null&&pe.type===N&&pe.key===null&&(pe=pe.props.children),typeof pe=="object"&&pe!==null){switch(pe.$$typeof){case y:e:{for(var ct=pe.key;ce!==null;){if(ce.key===ct){if(ct=pe.type,ct===N){if(ce.tag===7){i(ue,ce.sibling),Ae=b(ce,pe.props.children),Ae.return=ue,ue=Ae;break e}}else if(ce.elementType===ct||typeof ct=="object"&&ct!==null&&ct.$$typeof===I&&Ua(ct)===ce.type){i(ue,ce.sibling),Ae=b(ce,pe.props),wi(Ae,pe),Ae.return=ue,ue=Ae;break e}i(ue,ce);break}else a(ue,ce);ce=ce.sibling}pe.type===N?(Ae=Ia(pe.props.children,ue.mode,Ae,pe.key),Ae.return=ue,ue=Ae):(Ae=ec(pe.type,pe.key,pe.props,null,ue.mode,Ae),wi(Ae,pe),Ae.return=ue,ue=Ae)}return P(ue);case w:e:{for(ct=pe.key;ce!==null;){if(ce.key===ct)if(ce.tag===4&&ce.stateNode.containerInfo===pe.containerInfo&&ce.stateNode.implementation===pe.implementation){i(ue,ce.sibling),Ae=b(ce,pe.children||[]),Ae.return=ue,ue=Ae;break e}else{i(ue,ce);break}else a(ue,ce);ce=ce.sibling}Ae=Au(pe,ue.mode,Ae),Ae.return=ue,ue=Ae}return P(ue);case I:return pe=Ua(pe),xn(ue,ce,pe,Ae)}if(z(pe))return We(ue,ce,pe,Ae);if(B(pe)){if(ct=B(pe),typeof ct!="function")throw Error(l(150));return pe=ct.call(pe),pt(ue,ce,pe,Ae)}if(typeof pe.then=="function")return xn(ue,ce,ic(pe),Ae);if(pe.$$typeof===k)return xn(ue,ce,rc(ue,pe),Ae);oc(ue,pe)}return typeof pe=="string"&&pe!==""||typeof pe=="number"||typeof pe=="bigint"?(pe=""+pe,ce!==null&&ce.tag===6?(i(ue,ce.sibling),Ae=b(ce,pe),Ae.return=ue,ue=Ae):(i(ue,ce),Ae=Tu(pe,ue.mode,Ae),Ae.return=ue,ue=Ae),P(ue)):i(ue,ce)}return function(ue,ce,pe,Ae){try{ji=0;var ct=xn(ue,ce,pe,Ae);return wl=null,ct}catch(rt){if(rt===jl||rt===ac)throw rt;var Kt=_r(29,rt,null,ue.mode);return Kt.lanes=Ae,Kt.return=ue,Kt}}}var Fa=bg(!0),yg=bg(!1),ra=!1;function Pu(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Uu(n,a){n=n.updateQueue,a.updateQueue===n&&(a.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,callbacks:null})}function sa(n){return{lane:n,tag:0,payload:null,callback:null,next:null}}function aa(n,a,i){var u=n.updateQueue;if(u===null)return null;if(u=u.shared,(nn&2)!==0){var b=u.pending;return b===null?a.next=a:(a.next=b.next,b.next=a),u.pending=a,a=Wo(n),ng(n,null,i),a}return Jo(n,u,a,i),Wo(n)}function Ni(n,a,i){if(a=a.updateQueue,a!==null&&(a=a.shared,(i&4194048)!==0)){var u=a.lanes;u&=n.pendingLanes,i|=u,a.lanes=i,ft(n,i)}}function qu(n,a){var i=n.updateQueue,u=n.alternate;if(u!==null&&(u=u.updateQueue,i===u)){var b=null,j=null;if(i=i.firstBaseUpdate,i!==null){do{var P={lane:i.lane,tag:i.tag,payload:i.payload,callback:null,next:null};j===null?b=j=P:j=j.next=P,i=i.next}while(i!==null);j===null?b=j=a:j=j.next=a}else b=j=a;i={baseState:u.baseState,firstBaseUpdate:b,lastBaseUpdate:j,shared:u.shared,callbacks:u.callbacks},n.updateQueue=i;return}n=i.lastBaseUpdate,n===null?i.firstBaseUpdate=a:n.next=a,i.lastBaseUpdate=a}var Fu=!1;function ki(){if(Fu){var n=vl;if(n!==null)throw n}}function Si(n,a,i,u){Fu=!1;var b=n.updateQueue;ra=!1;var j=b.firstBaseUpdate,P=b.lastBaseUpdate,W=b.shared.pending;if(W!==null){b.shared.pending=null;var le=W,be=le.next;le.next=null,P===null?j=be:P.next=be,P=le;var Ee=n.alternate;Ee!==null&&(Ee=Ee.updateQueue,W=Ee.lastBaseUpdate,W!==P&&(W===null?Ee.firstBaseUpdate=be:W.next=be,Ee.lastBaseUpdate=le))}if(j!==null){var _e=b.baseState;P=0,Ee=be=le=null,W=j;do{var ve=W.lane&-536870913,Ne=ve!==W.lane;if(Ne?(Ht&ve)===ve:(u&ve)===ve){ve!==0&&ve===yl&&(Fu=!0),Ee!==null&&(Ee=Ee.next={lane:0,tag:W.tag,payload:W.payload,callback:null,next:null});e:{var We=n,pt=W;ve=a;var xn=i;switch(pt.tag){case 1:if(We=pt.payload,typeof We=="function"){_e=We.call(xn,_e,ve);break e}_e=We;break e;case 3:We.flags=We.flags&-65537|128;case 0:if(We=pt.payload,ve=typeof We=="function"?We.call(xn,_e,ve):We,ve==null)break e;_e=g({},_e,ve);break e;case 2:ra=!0}}ve=W.callback,ve!==null&&(n.flags|=64,Ne&&(n.flags|=8192),Ne=b.callbacks,Ne===null?b.callbacks=[ve]:Ne.push(ve))}else Ne={lane:ve,tag:W.tag,payload:W.payload,callback:W.callback,next:null},Ee===null?(be=Ee=Ne,le=_e):Ee=Ee.next=Ne,P|=ve;if(W=W.next,W===null){if(W=b.shared.pending,W===null)break;Ne=W,W=Ne.next,Ne.next=null,b.lastBaseUpdate=Ne,b.shared.pending=null}}while(!0);Ee===null&&(le=_e),b.baseState=le,b.firstBaseUpdate=be,b.lastBaseUpdate=Ee,j===null&&(b.shared.lanes=0),da|=P,n.lanes=P,n.memoizedState=_e}}function vg(n,a){if(typeof n!="function")throw Error(l(191,n));n.call(a)}function jg(n,a){var i=n.callbacks;if(i!==null)for(n.callbacks=null,n=0;n<i.length;n++)vg(i[n],a)}var Nl=H(null),cc=H(0);function wg(n,a){n=Hs,L(cc,n),L(Nl,a),Hs=n|a.baseLanes}function Vu(){L(cc,Hs),L(Nl,Nl.current)}function Yu(){Hs=cc.current,X(Nl),X(cc)}var Mr=H(null),Yr=null;function la(n){var a=n.alternate;L(Rn,Rn.current&1),L(Mr,n),Yr===null&&(a===null||Nl.current!==null||a.memoizedState!==null)&&(Yr=n)}function Gu(n){L(Rn,Rn.current),L(Mr,n),Yr===null&&(Yr=n)}function Ng(n){n.tag===22?(L(Rn,Rn.current),L(Mr,n),Yr===null&&(Yr=n)):ia()}function ia(){L(Rn,Rn.current),L(Mr,Mr.current)}function Dr(n){X(Mr),Yr===n&&(Yr=null),X(Rn)}var Rn=H(0);function dc(n){for(var a=n;a!==null;){if(a.tag===13){var i=a.memoizedState;if(i!==null&&(i=i.dehydrated,i===null||eh(i)||th(i)))return a}else if(a.tag===19&&(a.memoizedProps.revealOrder==="forwards"||a.memoizedProps.revealOrder==="backwards"||a.memoizedProps.revealOrder==="unstable_legacy-backwards"||a.memoizedProps.revealOrder==="together")){if((a.flags&128)!==0)return a}else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===n)break;for(;a.sibling===null;){if(a.return===null||a.return===n)return null;a=a.return}a.sibling.return=a.return,a=a.sibling}return null}var Ds=0,_t=null,hn=null,$n=null,uc=!1,kl=!1,Va=!1,fc=0,Ci=0,Sl=null,w5=0;function Mn(){throw Error(l(321))}function Xu(n,a){if(a===null)return!1;for(var i=0;i<a.length&&i<n.length;i++)if(!Ar(n[i],a[i]))return!1;return!0}function Zu(n,a,i,u,b,j){return Ds=j,_t=a,a.memoizedState=null,a.updateQueue=null,a.lanes=0,_.H=n===null||n.memoizedState===null?lp:uf,Va=!1,j=i(u,b),Va=!1,kl&&(j=Sg(a,i,u,b)),kg(n),j}function kg(n){_.H=Ai;var a=hn!==null&&hn.next!==null;if(Ds=0,$n=hn=_t=null,uc=!1,Ci=0,Sl=null,a)throw Error(l(300));n===null||Bn||(n=n.dependencies,n!==null&&nc(n)&&(Bn=!0))}function Sg(n,a,i,u){_t=n;var b=0;do{if(kl&&(Sl=null),Ci=0,kl=!1,25<=b)throw Error(l(301));if(b+=1,$n=hn=null,n.updateQueue!=null){var j=n.updateQueue;j.lastEffect=null,j.events=null,j.stores=null,j.memoCache!=null&&(j.memoCache.index=0)}_.H=ip,j=a(i,u)}while(kl);return j}function N5(){var n=_.H,a=n.useState()[0];return a=typeof a.then=="function"?Ei(a):a,n=n.useState()[0],(hn!==null?hn.memoizedState:null)!==n&&(_t.flags|=1024),a}function Qu(){var n=fc!==0;return fc=0,n}function Ku(n,a,i){a.updateQueue=n.updateQueue,a.flags&=-2053,n.lanes&=~i}function Ju(n){if(uc){for(n=n.memoizedState;n!==null;){var a=n.queue;a!==null&&(a.pending=null),n=n.next}uc=!1}Ds=0,$n=hn=_t=null,kl=!1,Ci=fc=0,Sl=null}function ur(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return $n===null?_t.memoizedState=$n=n:$n=$n.next=n,$n}function Ln(){if(hn===null){var n=_t.alternate;n=n!==null?n.memoizedState:null}else n=hn.next;var a=$n===null?_t.memoizedState:$n.next;if(a!==null)$n=a,hn=n;else{if(n===null)throw _t.alternate===null?Error(l(467)):Error(l(310));hn=n,n={memoizedState:hn.memoizedState,baseState:hn.baseState,baseQueue:hn.baseQueue,queue:hn.queue,next:null},$n===null?_t.memoizedState=$n=n:$n=$n.next=n}return $n}function hc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ei(n){var a=Ci;return Ci+=1,Sl===null&&(Sl=[]),n=xg(Sl,n,a),a=_t,($n===null?a.memoizedState:$n.next)===null&&(a=a.alternate,_.H=a===null||a.memoizedState===null?lp:uf),n}function mc(n){if(n!==null&&typeof n=="object"){if(typeof n.then=="function")return Ei(n);if(n.$$typeof===k)return Jn(n)}throw Error(l(438,String(n)))}function Wu(n){var a=null,i=_t.updateQueue;if(i!==null&&(a=i.memoCache),a==null){var u=_t.alternate;u!==null&&(u=u.updateQueue,u!==null&&(u=u.memoCache,u!=null&&(a={data:u.data.map(function(b){return b.slice()}),index:0})))}if(a==null&&(a={data:[],index:0}),i===null&&(i=hc(),_t.updateQueue=i),i.memoCache=a,i=a.data[a.index],i===void 0)for(i=a.data[a.index]=Array(n),u=0;u<n;u++)i[u]=$;return a.index++,i}function Os(n,a){return typeof a=="function"?a(n):a}function xc(n){var a=Ln();return ef(a,hn,n)}function ef(n,a,i){var u=n.queue;if(u===null)throw Error(l(311));u.lastRenderedReducer=i;var b=n.baseQueue,j=u.pending;if(j!==null){if(b!==null){var P=b.next;b.next=j.next,j.next=P}a.baseQueue=b=j,u.pending=null}if(j=n.baseState,b===null)n.memoizedState=j;else{a=b.next;var W=P=null,le=null,be=a,Ee=!1;do{var _e=be.lane&-536870913;if(_e!==be.lane?(Ht&_e)===_e:(Ds&_e)===_e){var ve=be.revertLane;if(ve===0)le!==null&&(le=le.next={lane:0,revertLane:0,gesture:null,action:be.action,hasEagerState:be.hasEagerState,eagerState:be.eagerState,next:null}),_e===yl&&(Ee=!0);else if((Ds&ve)===ve){be=be.next,ve===yl&&(Ee=!0);continue}else _e={lane:0,revertLane:be.revertLane,gesture:null,action:be.action,hasEagerState:be.hasEagerState,eagerState:be.eagerState,next:null},le===null?(W=le=_e,P=j):le=le.next=_e,_t.lanes|=ve,da|=ve;_e=be.action,Va&&i(j,_e),j=be.hasEagerState?be.eagerState:i(j,_e)}else ve={lane:_e,revertLane:be.revertLane,gesture:be.gesture,action:be.action,hasEagerState:be.hasEagerState,eagerState:be.eagerState,next:null},le===null?(W=le=ve,P=j):le=le.next=ve,_t.lanes|=_e,da|=_e;be=be.next}while(be!==null&&be!==a);if(le===null?P=j:le.next=W,!Ar(j,n.memoizedState)&&(Bn=!0,Ee&&(i=vl,i!==null)))throw i;n.memoizedState=j,n.baseState=P,n.baseQueue=le,u.lastRenderedState=j}return b===null&&(u.lanes=0),[n.memoizedState,u.dispatch]}function tf(n){var a=Ln(),i=a.queue;if(i===null)throw Error(l(311));i.lastRenderedReducer=n;var u=i.dispatch,b=i.pending,j=a.memoizedState;if(b!==null){i.pending=null;var P=b=b.next;do j=n(j,P.action),P=P.next;while(P!==b);Ar(j,a.memoizedState)||(Bn=!0),a.memoizedState=j,a.baseQueue===null&&(a.baseState=j),i.lastRenderedState=j}return[j,u]}function Cg(n,a,i){var u=_t,b=Ln(),j=Ut;if(j){if(i===void 0)throw Error(l(407));i=i()}else i=a();var P=!Ar((hn||b).memoizedState,i);if(P&&(b.memoizedState=i,Bn=!0),b=b.queue,sf(Ag.bind(null,u,b,n),[n]),b.getSnapshot!==a||P||$n!==null&&$n.memoizedState.tag&1){if(u.flags|=2048,Cl(9,{destroy:void 0},Tg.bind(null,u,b,i,a),null),gn===null)throw Error(l(349));j||(Ds&127)!==0||Eg(u,a,i)}return i}function Eg(n,a,i){n.flags|=16384,n={getSnapshot:a,value:i},a=_t.updateQueue,a===null?(a=hc(),_t.updateQueue=a,a.stores=[n]):(i=a.stores,i===null?a.stores=[n]:i.push(n))}function Tg(n,a,i,u){a.value=i,a.getSnapshot=u,_g(a)&&Mg(n)}function Ag(n,a,i){return i(function(){_g(a)&&Mg(n)})}function _g(n){var a=n.getSnapshot;n=n.value;try{var i=a();return!Ar(n,i)}catch{return!0}}function Mg(n){var a=za(n,2);a!==null&&vr(a,n,2)}function nf(n){var a=ur();if(typeof n=="function"){var i=n;if(n=i(),Va){qt(!0);try{i()}finally{qt(!1)}}}return a.memoizedState=a.baseState=n,a.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Os,lastRenderedState:n},a}function Dg(n,a,i,u){return n.baseState=i,ef(n,hn,typeof u=="function"?u:Os)}function k5(n,a,i,u,b){if(bc(n))throw Error(l(485));if(n=a.action,n!==null){var j={payload:b,action:n,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(P){j.listeners.push(P)}};_.T!==null?i(!0):j.isTransition=!1,u(j),i=a.pending,i===null?(j.next=a.pending=j,Og(a,j)):(j.next=i.next,a.pending=i.next=j)}}function Og(n,a){var i=a.action,u=a.payload,b=n.state;if(a.isTransition){var j=_.T,P={};_.T=P;try{var W=i(b,u),le=_.S;le!==null&&le(P,W),Rg(n,a,W)}catch(be){rf(n,a,be)}finally{j!==null&&P.types!==null&&(j.types=P.types),_.T=j}}else try{j=i(b,u),Rg(n,a,j)}catch(be){rf(n,a,be)}}function Rg(n,a,i){i!==null&&typeof i=="object"&&typeof i.then=="function"?i.then(function(u){Lg(n,a,u)},function(u){return rf(n,a,u)}):Lg(n,a,i)}function Lg(n,a,i){a.status="fulfilled",a.value=i,zg(a),n.state=i,a=n.pending,a!==null&&(i=a.next,i===a?n.pending=null:(i=i.next,a.next=i,Og(n,i)))}function rf(n,a,i){var u=n.pending;if(n.pending=null,u!==null){u=u.next;do a.status="rejected",a.reason=i,zg(a),a=a.next;while(a!==u)}n.action=null}function zg(n){n=n.listeners;for(var a=0;a<n.length;a++)(0,n[a])()}function Ig(n,a){return a}function $g(n,a){if(Ut){var i=gn.formState;if(i!==null){e:{var u=_t;if(Ut){if(yn){t:{for(var b=yn,j=Vr;b.nodeType!==8;){if(!j){b=null;break t}if(b=Gr(b.nextSibling),b===null){b=null;break t}}j=b.data,b=j==="F!"||j==="F"?b:null}if(b){yn=Gr(b.nextSibling),u=b.data==="F!";break e}}ta(u)}u=!1}u&&(a=i[0])}}return i=ur(),i.memoizedState=i.baseState=a,u={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ig,lastRenderedState:a},i.queue=u,i=rp.bind(null,_t,u),u.dispatch=i,u=nf(!1),j=df.bind(null,_t,!1,u.queue),u=ur(),b={state:a,dispatch:null,action:n,pending:null},u.queue=b,i=k5.bind(null,_t,b,j,i),b.dispatch=i,u.memoizedState=n,[a,i,!1]}function Bg(n){var a=Ln();return Hg(a,hn,n)}function Hg(n,a,i){if(a=ef(n,a,Ig)[0],n=xc(Os)[0],typeof a=="object"&&a!==null&&typeof a.then=="function")try{var u=Ei(a)}catch(P){throw P===jl?ac:P}else u=a;a=Ln();var b=a.queue,j=b.dispatch;return i!==a.memoizedState&&(_t.flags|=2048,Cl(9,{destroy:void 0},S5.bind(null,b,i),null)),[u,j,n]}function S5(n,a){n.action=a}function Pg(n){var a=Ln(),i=hn;if(i!==null)return Hg(a,i,n);Ln(),a=a.memoizedState,i=Ln();var u=i.queue.dispatch;return i.memoizedState=n,[a,u,!1]}function Cl(n,a,i,u){return n={tag:n,create:i,deps:u,inst:a,next:null},a=_t.updateQueue,a===null&&(a=hc(),_t.updateQueue=a),i=a.lastEffect,i===null?a.lastEffect=n.next=n:(u=i.next,i.next=n,n.next=u,a.lastEffect=n),n}function Ug(){return Ln().memoizedState}function gc(n,a,i,u){var b=ur();_t.flags|=n,b.memoizedState=Cl(1|a,{destroy:void 0},i,u===void 0?null:u)}function pc(n,a,i,u){var b=Ln();u=u===void 0?null:u;var j=b.memoizedState.inst;hn!==null&&u!==null&&Xu(u,hn.memoizedState.deps)?b.memoizedState=Cl(a,j,i,u):(_t.flags|=n,b.memoizedState=Cl(1|a,j,i,u))}function qg(n,a){gc(8390656,8,n,a)}function sf(n,a){pc(2048,8,n,a)}function C5(n){_t.flags|=4;var a=_t.updateQueue;if(a===null)a=hc(),_t.updateQueue=a,a.events=[n];else{var i=a.events;i===null?a.events=[n]:i.push(n)}}function Fg(n){var a=Ln().memoizedState;return C5({ref:a,nextImpl:n}),function(){if((nn&2)!==0)throw Error(l(440));return a.impl.apply(void 0,arguments)}}function Vg(n,a){return pc(4,2,n,a)}function Yg(n,a){return pc(4,4,n,a)}function Gg(n,a){if(typeof a=="function"){n=n();var i=a(n);return function(){typeof i=="function"?i():a(null)}}if(a!=null)return n=n(),a.current=n,function(){a.current=null}}function Xg(n,a,i){i=i!=null?i.concat([n]):null,pc(4,4,Gg.bind(null,a,n),i)}function af(){}function Zg(n,a){var i=Ln();a=a===void 0?null:a;var u=i.memoizedState;return a!==null&&Xu(a,u[1])?u[0]:(i.memoizedState=[n,a],n)}function Qg(n,a){var i=Ln();a=a===void 0?null:a;var u=i.memoizedState;if(a!==null&&Xu(a,u[1]))return u[0];if(u=n(),Va){qt(!0);try{n()}finally{qt(!1)}}return i.memoizedState=[u,a],u}function lf(n,a,i){return i===void 0||(Ds&1073741824)!==0&&(Ht&261930)===0?n.memoizedState=a:(n.memoizedState=i,n=Kp(),_t.lanes|=n,da|=n,i)}function Kg(n,a,i,u){return Ar(i,a)?i:Nl.current!==null?(n=lf(n,i,u),Ar(n,a)||(Bn=!0),n):(Ds&42)===0||(Ds&1073741824)!==0&&(Ht&261930)===0?(Bn=!0,n.memoizedState=i):(n=Kp(),_t.lanes|=n,da|=n,a)}function Jg(n,a,i,u,b){var j=Y.p;Y.p=j!==0&&8>j?j:8;var P=_.T,W={};_.T=W,df(n,!1,a,i);try{var le=b(),be=_.S;if(be!==null&&be(W,le),le!==null&&typeof le=="object"&&typeof le.then=="function"){var Ee=j5(le,u);Ti(n,a,Ee,Lr(n))}else Ti(n,a,u,Lr(n))}catch(_e){Ti(n,a,{then:function(){},status:"rejected",reason:_e},Lr())}finally{Y.p=j,P!==null&&W.types!==null&&(P.types=W.types),_.T=P}}function E5(){}function of(n,a,i,u){if(n.tag!==5)throw Error(l(476));var b=Wg(n).queue;Jg(n,b,a,V,i===null?E5:function(){return ep(n),i(u)})}function Wg(n){var a=n.memoizedState;if(a!==null)return a;a={memoizedState:V,baseState:V,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Os,lastRenderedState:V},next:null};var i={};return a.next={memoizedState:i,baseState:i,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Os,lastRenderedState:i},next:null},n.memoizedState=a,n=n.alternate,n!==null&&(n.memoizedState=a),a}function ep(n){var a=Wg(n);a.next===null&&(a=n.alternate.memoizedState),Ti(n,a.next.queue,{},Lr())}function cf(){return Jn(Vi)}function tp(){return Ln().memoizedState}function np(){return Ln().memoizedState}function T5(n){for(var a=n.return;a!==null;){switch(a.tag){case 24:case 3:var i=Lr();n=sa(i);var u=aa(a,n,i);u!==null&&(vr(u,a,i),Ni(u,a,i)),a={cache:Iu()},n.payload=a;return}a=a.return}}function A5(n,a,i){var u=Lr();i={lane:u,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},bc(n)?sp(a,i):(i=Cu(n,a,i,u),i!==null&&(vr(i,n,u),ap(i,a,u)))}function rp(n,a,i){var u=Lr();Ti(n,a,i,u)}function Ti(n,a,i,u){var b={lane:u,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null};if(bc(n))sp(a,b);else{var j=n.alternate;if(n.lanes===0&&(j===null||j.lanes===0)&&(j=a.lastRenderedReducer,j!==null))try{var P=a.lastRenderedState,W=j(P,i);if(b.hasEagerState=!0,b.eagerState=W,Ar(W,P))return Jo(n,a,b,0),gn===null&&Ko(),!1}catch{}if(i=Cu(n,a,b,u),i!==null)return vr(i,n,u),ap(i,a,u),!0}return!1}function df(n,a,i,u){if(u={lane:2,revertLane:Uf(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},bc(n)){if(a)throw Error(l(479))}else a=Cu(n,i,u,2),a!==null&&vr(a,n,2)}function bc(n){var a=n.alternate;return n===_t||a!==null&&a===_t}function sp(n,a){kl=uc=!0;var i=n.pending;i===null?a.next=a:(a.next=i.next,i.next=a),n.pending=a}function ap(n,a,i){if((i&4194048)!==0){var u=a.lanes;u&=n.pendingLanes,i|=u,a.lanes=i,ft(n,i)}}var Ai={readContext:Jn,use:mc,useCallback:Mn,useContext:Mn,useEffect:Mn,useImperativeHandle:Mn,useLayoutEffect:Mn,useInsertionEffect:Mn,useMemo:Mn,useReducer:Mn,useRef:Mn,useState:Mn,useDebugValue:Mn,useDeferredValue:Mn,useTransition:Mn,useSyncExternalStore:Mn,useId:Mn,useHostTransitionStatus:Mn,useFormState:Mn,useActionState:Mn,useOptimistic:Mn,useMemoCache:Mn,useCacheRefresh:Mn};Ai.useEffectEvent=Mn;var lp={readContext:Jn,use:mc,useCallback:function(n,a){return ur().memoizedState=[n,a===void 0?null:a],n},useContext:Jn,useEffect:qg,useImperativeHandle:function(n,a,i){i=i!=null?i.concat([n]):null,gc(4194308,4,Gg.bind(null,a,n),i)},useLayoutEffect:function(n,a){return gc(4194308,4,n,a)},useInsertionEffect:function(n,a){gc(4,2,n,a)},useMemo:function(n,a){var i=ur();a=a===void 0?null:a;var u=n();if(Va){qt(!0);try{n()}finally{qt(!1)}}return i.memoizedState=[u,a],u},useReducer:function(n,a,i){var u=ur();if(i!==void 0){var b=i(a);if(Va){qt(!0);try{i(a)}finally{qt(!1)}}}else b=a;return u.memoizedState=u.baseState=b,n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:b},u.queue=n,n=n.dispatch=A5.bind(null,_t,n),[u.memoizedState,n]},useRef:function(n){var a=ur();return n={current:n},a.memoizedState=n},useState:function(n){n=nf(n);var a=n.queue,i=rp.bind(null,_t,a);return a.dispatch=i,[n.memoizedState,i]},useDebugValue:af,useDeferredValue:function(n,a){var i=ur();return lf(i,n,a)},useTransition:function(){var n=nf(!1);return n=Jg.bind(null,_t,n.queue,!0,!1),ur().memoizedState=n,[!1,n]},useSyncExternalStore:function(n,a,i){var u=_t,b=ur();if(Ut){if(i===void 0)throw Error(l(407));i=i()}else{if(i=a(),gn===null)throw Error(l(349));(Ht&127)!==0||Eg(u,a,i)}b.memoizedState=i;var j={value:i,getSnapshot:a};return b.queue=j,qg(Ag.bind(null,u,j,n),[n]),u.flags|=2048,Cl(9,{destroy:void 0},Tg.bind(null,u,j,i,a),null),i},useId:function(){var n=ur(),a=gn.identifierPrefix;if(Ut){var i=fs,u=us;i=(u&~(1<<32-yt(u)-1)).toString(32)+i,a="_"+a+"R_"+i,i=fc++,0<i&&(a+="H"+i.toString(32)),a+="_"}else i=w5++,a="_"+a+"r_"+i.toString(32)+"_";return n.memoizedState=a},useHostTransitionStatus:cf,useFormState:$g,useActionState:$g,useOptimistic:function(n){var a=ur();a.memoizedState=a.baseState=n;var i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return a.queue=i,a=df.bind(null,_t,!0,i),i.dispatch=a,[n,a]},useMemoCache:Wu,useCacheRefresh:function(){return ur().memoizedState=T5.bind(null,_t)},useEffectEvent:function(n){var a=ur(),i={impl:n};return a.memoizedState=i,function(){if((nn&2)!==0)throw Error(l(440));return i.impl.apply(void 0,arguments)}}},uf={readContext:Jn,use:mc,useCallback:Zg,useContext:Jn,useEffect:sf,useImperativeHandle:Xg,useInsertionEffect:Vg,useLayoutEffect:Yg,useMemo:Qg,useReducer:xc,useRef:Ug,useState:function(){return xc(Os)},useDebugValue:af,useDeferredValue:function(n,a){var i=Ln();return Kg(i,hn.memoizedState,n,a)},useTransition:function(){var n=xc(Os)[0],a=Ln().memoizedState;return[typeof n=="boolean"?n:Ei(n),a]},useSyncExternalStore:Cg,useId:tp,useHostTransitionStatus:cf,useFormState:Bg,useActionState:Bg,useOptimistic:function(n,a){var i=Ln();return Dg(i,hn,n,a)},useMemoCache:Wu,useCacheRefresh:np};uf.useEffectEvent=Fg;var ip={readContext:Jn,use:mc,useCallback:Zg,useContext:Jn,useEffect:sf,useImperativeHandle:Xg,useInsertionEffect:Vg,useLayoutEffect:Yg,useMemo:Qg,useReducer:tf,useRef:Ug,useState:function(){return tf(Os)},useDebugValue:af,useDeferredValue:function(n,a){var i=Ln();return hn===null?lf(i,n,a):Kg(i,hn.memoizedState,n,a)},useTransition:function(){var n=tf(Os)[0],a=Ln().memoizedState;return[typeof n=="boolean"?n:Ei(n),a]},useSyncExternalStore:Cg,useId:tp,useHostTransitionStatus:cf,useFormState:Pg,useActionState:Pg,useOptimistic:function(n,a){var i=Ln();return hn!==null?Dg(i,hn,n,a):(i.baseState=n,[n,i.queue.dispatch])},useMemoCache:Wu,useCacheRefresh:np};ip.useEffectEvent=Fg;function ff(n,a,i,u){a=n.memoizedState,i=i(u,a),i=i==null?a:g({},a,i),n.memoizedState=i,n.lanes===0&&(n.updateQueue.baseState=i)}var hf={enqueueSetState:function(n,a,i){n=n._reactInternals;var u=Lr(),b=sa(u);b.payload=a,i!=null&&(b.callback=i),a=aa(n,b,u),a!==null&&(vr(a,n,u),Ni(a,n,u))},enqueueReplaceState:function(n,a,i){n=n._reactInternals;var u=Lr(),b=sa(u);b.tag=1,b.payload=a,i!=null&&(b.callback=i),a=aa(n,b,u),a!==null&&(vr(a,n,u),Ni(a,n,u))},enqueueForceUpdate:function(n,a){n=n._reactInternals;var i=Lr(),u=sa(i);u.tag=2,a!=null&&(u.callback=a),a=aa(n,u,i),a!==null&&(vr(a,n,i),Ni(a,n,i))}};function op(n,a,i,u,b,j,P){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(u,j,P):a.prototype&&a.prototype.isPureReactComponent?!xi(i,u)||!xi(b,j):!0}function cp(n,a,i,u){n=a.state,typeof a.componentWillReceiveProps=="function"&&a.componentWillReceiveProps(i,u),typeof a.UNSAFE_componentWillReceiveProps=="function"&&a.UNSAFE_componentWillReceiveProps(i,u),a.state!==n&&hf.enqueueReplaceState(a,a.state,null)}function Ya(n,a){var i=a;if("ref"in a){i={};for(var u in a)u!=="ref"&&(i[u]=a[u])}if(n=n.defaultProps){i===a&&(i=g({},i));for(var b in n)i[b]===void 0&&(i[b]=n[b])}return i}function dp(n){Qo(n)}function up(n){console.error(n)}function fp(n){Qo(n)}function yc(n,a){try{var i=n.onUncaughtError;i(a.value,{componentStack:a.stack})}catch(u){setTimeout(function(){throw u})}}function hp(n,a,i){try{var u=n.onCaughtError;u(i.value,{componentStack:i.stack,errorBoundary:a.tag===1?a.stateNode:null})}catch(b){setTimeout(function(){throw b})}}function mf(n,a,i){return i=sa(i),i.tag=3,i.payload={element:null},i.callback=function(){yc(n,a)},i}function mp(n){return n=sa(n),n.tag=3,n}function xp(n,a,i,u){var b=i.type.getDerivedStateFromError;if(typeof b=="function"){var j=u.value;n.payload=function(){return b(j)},n.callback=function(){hp(a,i,u)}}var P=i.stateNode;P!==null&&typeof P.componentDidCatch=="function"&&(n.callback=function(){hp(a,i,u),typeof b!="function"&&(ua===null?ua=new Set([this]):ua.add(this));var W=u.stack;this.componentDidCatch(u.value,{componentStack:W!==null?W:""})})}function _5(n,a,i,u,b){if(i.flags|=32768,u!==null&&typeof u=="object"&&typeof u.then=="function"){if(a=i.alternate,a!==null&&bl(a,i,b,!0),i=Mr.current,i!==null){switch(i.tag){case 31:case 13:return Yr===null?Mc():i.alternate===null&&Dn===0&&(Dn=3),i.flags&=-257,i.flags|=65536,i.lanes=b,u===lc?i.flags|=16384:(a=i.updateQueue,a===null?i.updateQueue=new Set([u]):a.add(u),Bf(n,u,b)),!1;case 22:return i.flags|=65536,u===lc?i.flags|=16384:(a=i.updateQueue,a===null?(a={transitions:null,markerInstances:null,retryQueue:new Set([u])},i.updateQueue=a):(i=a.retryQueue,i===null?a.retryQueue=new Set([u]):i.add(u)),Bf(n,u,b)),!1}throw Error(l(435,i.tag))}return Bf(n,u,b),Mc(),!1}if(Ut)return a=Mr.current,a!==null?((a.flags&65536)===0&&(a.flags|=256),a.flags|=65536,a.lanes=b,u!==Du&&(n=Error(l(422),{cause:u}),bi(Ur(n,i)))):(u!==Du&&(a=Error(l(423),{cause:u}),bi(Ur(a,i))),n=n.current.alternate,n.flags|=65536,b&=-b,n.lanes|=b,u=Ur(u,i),b=mf(n.stateNode,u,b),qu(n,b),Dn!==4&&(Dn=2)),!1;var j=Error(l(520),{cause:u});if(j=Ur(j,i),Ii===null?Ii=[j]:Ii.push(j),Dn!==4&&(Dn=2),a===null)return!0;u=Ur(u,i),i=a;do{switch(i.tag){case 3:return i.flags|=65536,n=b&-b,i.lanes|=n,n=mf(i.stateNode,u,n),qu(i,n),!1;case 1:if(a=i.type,j=i.stateNode,(i.flags&128)===0&&(typeof a.getDerivedStateFromError=="function"||j!==null&&typeof j.componentDidCatch=="function"&&(ua===null||!ua.has(j))))return i.flags|=65536,b&=-b,i.lanes|=b,b=mp(b),xp(b,n,i,u),qu(i,b),!1}i=i.return}while(i!==null);return!1}var xf=Error(l(461)),Bn=!1;function Wn(n,a,i,u){a.child=n===null?yg(a,null,i,u):Fa(a,n.child,i,u)}function gp(n,a,i,u,b){i=i.render;var j=a.ref;if("ref"in u){var P={};for(var W in u)W!=="ref"&&(P[W]=u[W])}else P=u;return Ha(a),u=Zu(n,a,i,P,j,b),W=Qu(),n!==null&&!Bn?(Ku(n,a,b),Rs(n,a,b)):(Ut&&W&&_u(a),a.flags|=1,Wn(n,a,u,b),a.child)}function pp(n,a,i,u,b){if(n===null){var j=i.type;return typeof j=="function"&&!Eu(j)&&j.defaultProps===void 0&&i.compare===null?(a.tag=15,a.type=j,bp(n,a,j,u,b)):(n=ec(i.type,null,u,a,a.mode,b),n.ref=a.ref,n.return=a,a.child=n)}if(j=n.child,!Nf(n,b)){var P=j.memoizedProps;if(i=i.compare,i=i!==null?i:xi,i(P,u)&&n.ref===a.ref)return Rs(n,a,b)}return a.flags|=1,n=Ts(j,u),n.ref=a.ref,n.return=a,a.child=n}function bp(n,a,i,u,b){if(n!==null){var j=n.memoizedProps;if(xi(j,u)&&n.ref===a.ref)if(Bn=!1,a.pendingProps=u=j,Nf(n,b))(n.flags&131072)!==0&&(Bn=!0);else return a.lanes=n.lanes,Rs(n,a,b)}return gf(n,a,i,u,b)}function yp(n,a,i,u){var b=u.children,j=n!==null?n.memoizedState:null;if(n===null&&a.stateNode===null&&(a.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),u.mode==="hidden"){if((a.flags&128)!==0){if(j=j!==null?j.baseLanes|i:i,n!==null){for(u=a.child=n.child,b=0;u!==null;)b=b|u.lanes|u.childLanes,u=u.sibling;u=b&~j}else u=0,a.child=null;return vp(n,a,j,i,u)}if((i&536870912)!==0)a.memoizedState={baseLanes:0,cachePool:null},n!==null&&sc(a,j!==null?j.cachePool:null),j!==null?wg(a,j):Vu(),Ng(a);else return u=a.lanes=536870912,vp(n,a,j!==null?j.baseLanes|i:i,i,u)}else j!==null?(sc(a,j.cachePool),wg(a,j),ia(),a.memoizedState=null):(n!==null&&sc(a,null),Vu(),ia());return Wn(n,a,b,i),a.child}function _i(n,a){return n!==null&&n.tag===22||a.stateNode!==null||(a.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),a.sibling}function vp(n,a,i,u,b){var j=Bu();return j=j===null?null:{parent:In._currentValue,pool:j},a.memoizedState={baseLanes:i,cachePool:j},n!==null&&sc(a,null),Vu(),Ng(a),n!==null&&bl(n,a,u,!0),a.childLanes=b,null}function vc(n,a){return a=wc({mode:a.mode,children:a.children},n.mode),a.ref=n.ref,n.child=a,a.return=n,a}function jp(n,a,i){return Fa(a,n.child,null,i),n=vc(a,a.pendingProps),n.flags|=2,Dr(a),a.memoizedState=null,n}function M5(n,a,i){var u=a.pendingProps,b=(a.flags&128)!==0;if(a.flags&=-129,n===null){if(Ut){if(u.mode==="hidden")return n=vc(a,u),a.lanes=536870912,_i(null,n);if(Gu(a),(n=yn)?(n=O0(n,Vr),n=n!==null&&n.data==="&"?n:null,n!==null&&(a.memoizedState={dehydrated:n,treeContext:Ws!==null?{id:us,overflow:fs}:null,retryLane:536870912,hydrationErrors:null},i=sg(n),i.return=a,a.child=i,Kn=a,yn=null)):n=null,n===null)throw ta(a);return a.lanes=536870912,null}return vc(a,u)}var j=n.memoizedState;if(j!==null){var P=j.dehydrated;if(Gu(a),b)if(a.flags&256)a.flags&=-257,a=jp(n,a,i);else if(a.memoizedState!==null)a.child=n.child,a.flags|=128,a=null;else throw Error(l(558));else if(Bn||bl(n,a,i,!1),b=(i&n.childLanes)!==0,Bn||b){if(u=gn,u!==null&&(P=Zt(u,i),P!==0&&P!==j.retryLane))throw j.retryLane=P,za(n,P),vr(u,n,P),xf;Mc(),a=jp(n,a,i)}else n=j.treeContext,yn=Gr(P.nextSibling),Kn=a,Ut=!0,ea=null,Vr=!1,n!==null&&ig(a,n),a=vc(a,u),a.flags|=4096;return a}return n=Ts(n.child,{mode:u.mode,children:u.children}),n.ref=a.ref,a.child=n,n.return=a,n}function jc(n,a){var i=a.ref;if(i===null)n!==null&&n.ref!==null&&(a.flags|=4194816);else{if(typeof i!="function"&&typeof i!="object")throw Error(l(284));(n===null||n.ref!==i)&&(a.flags|=4194816)}}function gf(n,a,i,u,b){return Ha(a),i=Zu(n,a,i,u,void 0,b),u=Qu(),n!==null&&!Bn?(Ku(n,a,b),Rs(n,a,b)):(Ut&&u&&_u(a),a.flags|=1,Wn(n,a,i,b),a.child)}function wp(n,a,i,u,b,j){return Ha(a),a.updateQueue=null,i=Sg(a,u,i,b),kg(n),u=Qu(),n!==null&&!Bn?(Ku(n,a,j),Rs(n,a,j)):(Ut&&u&&_u(a),a.flags|=1,Wn(n,a,i,j),a.child)}function Np(n,a,i,u,b){if(Ha(a),a.stateNode===null){var j=ml,P=i.contextType;typeof P=="object"&&P!==null&&(j=Jn(P)),j=new i(u,j),a.memoizedState=j.state!==null&&j.state!==void 0?j.state:null,j.updater=hf,a.stateNode=j,j._reactInternals=a,j=a.stateNode,j.props=u,j.state=a.memoizedState,j.refs={},Pu(a),P=i.contextType,j.context=typeof P=="object"&&P!==null?Jn(P):ml,j.state=a.memoizedState,P=i.getDerivedStateFromProps,typeof P=="function"&&(ff(a,i,P,u),j.state=a.memoizedState),typeof i.getDerivedStateFromProps=="function"||typeof j.getSnapshotBeforeUpdate=="function"||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(P=j.state,typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount(),P!==j.state&&hf.enqueueReplaceState(j,j.state,null),Si(a,u,j,b),ki(),j.state=a.memoizedState),typeof j.componentDidMount=="function"&&(a.flags|=4194308),u=!0}else if(n===null){j=a.stateNode;var W=a.memoizedProps,le=Ya(i,W);j.props=le;var be=j.context,Ee=i.contextType;P=ml,typeof Ee=="object"&&Ee!==null&&(P=Jn(Ee));var _e=i.getDerivedStateFromProps;Ee=typeof _e=="function"||typeof j.getSnapshotBeforeUpdate=="function",W=a.pendingProps!==W,Ee||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(W||be!==P)&&cp(a,j,u,P),ra=!1;var ve=a.memoizedState;j.state=ve,Si(a,u,j,b),ki(),be=a.memoizedState,W||ve!==be||ra?(typeof _e=="function"&&(ff(a,i,_e,u),be=a.memoizedState),(le=ra||op(a,i,le,u,ve,be,P))?(Ee||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount()),typeof j.componentDidMount=="function"&&(a.flags|=4194308)):(typeof j.componentDidMount=="function"&&(a.flags|=4194308),a.memoizedProps=u,a.memoizedState=be),j.props=u,j.state=be,j.context=P,u=le):(typeof j.componentDidMount=="function"&&(a.flags|=4194308),u=!1)}else{j=a.stateNode,Uu(n,a),P=a.memoizedProps,Ee=Ya(i,P),j.props=Ee,_e=a.pendingProps,ve=j.context,be=i.contextType,le=ml,typeof be=="object"&&be!==null&&(le=Jn(be)),W=i.getDerivedStateFromProps,(be=typeof W=="function"||typeof j.getSnapshotBeforeUpdate=="function")||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(P!==_e||ve!==le)&&cp(a,j,u,le),ra=!1,ve=a.memoizedState,j.state=ve,Si(a,u,j,b),ki();var Ne=a.memoizedState;P!==_e||ve!==Ne||ra||n!==null&&n.dependencies!==null&&nc(n.dependencies)?(typeof W=="function"&&(ff(a,i,W,u),Ne=a.memoizedState),(Ee=ra||op(a,i,Ee,u,ve,Ne,le)||n!==null&&n.dependencies!==null&&nc(n.dependencies))?(be||typeof j.UNSAFE_componentWillUpdate!="function"&&typeof j.componentWillUpdate!="function"||(typeof j.componentWillUpdate=="function"&&j.componentWillUpdate(u,Ne,le),typeof j.UNSAFE_componentWillUpdate=="function"&&j.UNSAFE_componentWillUpdate(u,Ne,le)),typeof j.componentDidUpdate=="function"&&(a.flags|=4),typeof j.getSnapshotBeforeUpdate=="function"&&(a.flags|=1024)):(typeof j.componentDidUpdate!="function"||P===n.memoizedProps&&ve===n.memoizedState||(a.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||P===n.memoizedProps&&ve===n.memoizedState||(a.flags|=1024),a.memoizedProps=u,a.memoizedState=Ne),j.props=u,j.state=Ne,j.context=le,u=Ee):(typeof j.componentDidUpdate!="function"||P===n.memoizedProps&&ve===n.memoizedState||(a.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||P===n.memoizedProps&&ve===n.memoizedState||(a.flags|=1024),u=!1)}return j=u,jc(n,a),u=(a.flags&128)!==0,j||u?(j=a.stateNode,i=u&&typeof i.getDerivedStateFromError!="function"?null:j.render(),a.flags|=1,n!==null&&u?(a.child=Fa(a,n.child,null,b),a.child=Fa(a,null,i,b)):Wn(n,a,i,b),a.memoizedState=j.state,n=a.child):n=Rs(n,a,b),n}function kp(n,a,i,u){return $a(),a.flags|=256,Wn(n,a,i,u),a.child}var pf={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function bf(n){return{baseLanes:n,cachePool:hg()}}function yf(n,a,i){return n=n!==null?n.childLanes&~i:0,a&&(n|=Rr),n}function Sp(n,a,i){var u=a.pendingProps,b=!1,j=(a.flags&128)!==0,P;if((P=j)||(P=n!==null&&n.memoizedState===null?!1:(Rn.current&2)!==0),P&&(b=!0,a.flags&=-129),P=(a.flags&32)!==0,a.flags&=-33,n===null){if(Ut){if(b?la(a):ia(),(n=yn)?(n=O0(n,Vr),n=n!==null&&n.data!=="&"?n:null,n!==null&&(a.memoizedState={dehydrated:n,treeContext:Ws!==null?{id:us,overflow:fs}:null,retryLane:536870912,hydrationErrors:null},i=sg(n),i.return=a,a.child=i,Kn=a,yn=null)):n=null,n===null)throw ta(a);return th(n)?a.lanes=32:a.lanes=536870912,null}var W=u.children;return u=u.fallback,b?(ia(),b=a.mode,W=wc({mode:"hidden",children:W},b),u=Ia(u,b,i,null),W.return=a,u.return=a,W.sibling=u,a.child=W,u=a.child,u.memoizedState=bf(i),u.childLanes=yf(n,P,i),a.memoizedState=pf,_i(null,u)):(la(a),vf(a,W))}var le=n.memoizedState;if(le!==null&&(W=le.dehydrated,W!==null)){if(j)a.flags&256?(la(a),a.flags&=-257,a=jf(n,a,i)):a.memoizedState!==null?(ia(),a.child=n.child,a.flags|=128,a=null):(ia(),W=u.fallback,b=a.mode,u=wc({mode:"visible",children:u.children},b),W=Ia(W,b,i,null),W.flags|=2,u.return=a,W.return=a,u.sibling=W,a.child=u,Fa(a,n.child,null,i),u=a.child,u.memoizedState=bf(i),u.childLanes=yf(n,P,i),a.memoizedState=pf,a=_i(null,u));else if(la(a),th(W)){if(P=W.nextSibling&&W.nextSibling.dataset,P)var be=P.dgst;P=be,u=Error(l(419)),u.stack="",u.digest=P,bi({value:u,source:null,stack:null}),a=jf(n,a,i)}else if(Bn||bl(n,a,i,!1),P=(i&n.childLanes)!==0,Bn||P){if(P=gn,P!==null&&(u=Zt(P,i),u!==0&&u!==le.retryLane))throw le.retryLane=u,za(n,u),vr(P,n,u),xf;eh(W)||Mc(),a=jf(n,a,i)}else eh(W)?(a.flags|=192,a.child=n.child,a=null):(n=le.treeContext,yn=Gr(W.nextSibling),Kn=a,Ut=!0,ea=null,Vr=!1,n!==null&&ig(a,n),a=vf(a,u.children),a.flags|=4096);return a}return b?(ia(),W=u.fallback,b=a.mode,le=n.child,be=le.sibling,u=Ts(le,{mode:"hidden",children:u.children}),u.subtreeFlags=le.subtreeFlags&65011712,be!==null?W=Ts(be,W):(W=Ia(W,b,i,null),W.flags|=2),W.return=a,u.return=a,u.sibling=W,a.child=u,_i(null,u),u=a.child,W=n.child.memoizedState,W===null?W=bf(i):(b=W.cachePool,b!==null?(le=In._currentValue,b=b.parent!==le?{parent:le,pool:le}:b):b=hg(),W={baseLanes:W.baseLanes|i,cachePool:b}),u.memoizedState=W,u.childLanes=yf(n,P,i),a.memoizedState=pf,_i(n.child,u)):(la(a),i=n.child,n=i.sibling,i=Ts(i,{mode:"visible",children:u.children}),i.return=a,i.sibling=null,n!==null&&(P=a.deletions,P===null?(a.deletions=[n],a.flags|=16):P.push(n)),a.child=i,a.memoizedState=null,i)}function vf(n,a){return a=wc({mode:"visible",children:a},n.mode),a.return=n,n.child=a}function wc(n,a){return n=_r(22,n,null,a),n.lanes=0,n}function jf(n,a,i){return Fa(a,n.child,null,i),n=vf(a,a.pendingProps.children),n.flags|=2,a.memoizedState=null,n}function Cp(n,a,i){n.lanes|=a;var u=n.alternate;u!==null&&(u.lanes|=a),Lu(n.return,a,i)}function wf(n,a,i,u,b,j){var P=n.memoizedState;P===null?n.memoizedState={isBackwards:a,rendering:null,renderingStartTime:0,last:u,tail:i,tailMode:b,treeForkCount:j}:(P.isBackwards=a,P.rendering=null,P.renderingStartTime=0,P.last=u,P.tail=i,P.tailMode=b,P.treeForkCount=j)}function Ep(n,a,i){var u=a.pendingProps,b=u.revealOrder,j=u.tail;u=u.children;var P=Rn.current,W=(P&2)!==0;if(W?(P=P&1|2,a.flags|=128):P&=1,L(Rn,P),Wn(n,a,u,i),u=Ut?pi:0,!W&&n!==null&&(n.flags&128)!==0)e:for(n=a.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&Cp(n,i,a);else if(n.tag===19)Cp(n,i,a);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===a)break e;for(;n.sibling===null;){if(n.return===null||n.return===a)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}switch(b){case"forwards":for(i=a.child,b=null;i!==null;)n=i.alternate,n!==null&&dc(n)===null&&(b=i),i=i.sibling;i=b,i===null?(b=a.child,a.child=null):(b=i.sibling,i.sibling=null),wf(a,!1,b,i,j,u);break;case"backwards":case"unstable_legacy-backwards":for(i=null,b=a.child,a.child=null;b!==null;){if(n=b.alternate,n!==null&&dc(n)===null){a.child=b;break}n=b.sibling,b.sibling=i,i=b,b=n}wf(a,!0,i,null,j,u);break;case"together":wf(a,!1,null,null,void 0,u);break;default:a.memoizedState=null}return a.child}function Rs(n,a,i){if(n!==null&&(a.dependencies=n.dependencies),da|=a.lanes,(i&a.childLanes)===0)if(n!==null){if(bl(n,a,i,!1),(i&a.childLanes)===0)return null}else return null;if(n!==null&&a.child!==n.child)throw Error(l(153));if(a.child!==null){for(n=a.child,i=Ts(n,n.pendingProps),a.child=i,i.return=a;n.sibling!==null;)n=n.sibling,i=i.sibling=Ts(n,n.pendingProps),i.return=a;i.sibling=null}return a.child}function Nf(n,a){return(n.lanes&a)!==0?!0:(n=n.dependencies,!!(n!==null&&nc(n)))}function D5(n,a,i){switch(a.tag){case 3:te(a,a.stateNode.containerInfo),na(a,In,n.memoizedState.cache),$a();break;case 27:case 5:xe(a);break;case 4:te(a,a.stateNode.containerInfo);break;case 10:na(a,a.type,a.memoizedProps.value);break;case 31:if(a.memoizedState!==null)return a.flags|=128,Gu(a),null;break;case 13:var u=a.memoizedState;if(u!==null)return u.dehydrated!==null?(la(a),a.flags|=128,null):(i&a.child.childLanes)!==0?Sp(n,a,i):(la(a),n=Rs(n,a,i),n!==null?n.sibling:null);la(a);break;case 19:var b=(n.flags&128)!==0;if(u=(i&a.childLanes)!==0,u||(bl(n,a,i,!1),u=(i&a.childLanes)!==0),b){if(u)return Ep(n,a,i);a.flags|=128}if(b=a.memoizedState,b!==null&&(b.rendering=null,b.tail=null,b.lastEffect=null),L(Rn,Rn.current),u)break;return null;case 22:return a.lanes=0,yp(n,a,i,a.pendingProps);case 24:na(a,In,n.memoizedState.cache)}return Rs(n,a,i)}function Tp(n,a,i){if(n!==null)if(n.memoizedProps!==a.pendingProps)Bn=!0;else{if(!Nf(n,i)&&(a.flags&128)===0)return Bn=!1,D5(n,a,i);Bn=(n.flags&131072)!==0}else Bn=!1,Ut&&(a.flags&1048576)!==0&&lg(a,pi,a.index);switch(a.lanes=0,a.tag){case 16:e:{var u=a.pendingProps;if(n=Ua(a.elementType),a.type=n,typeof n=="function")Eu(n)?(u=Ya(n,u),a.tag=1,a=Np(null,a,n,u,i)):(a.tag=0,a=gf(null,a,n,u,i));else{if(n!=null){var b=n.$$typeof;if(b===S){a.tag=11,a=gp(null,a,n,u,i);break e}else if(b===G){a.tag=14,a=pp(null,a,n,u,i);break e}}throw a=D(n)||n,Error(l(306,a,""))}}return a;case 0:return gf(n,a,a.type,a.pendingProps,i);case 1:return u=a.type,b=Ya(u,a.pendingProps),Np(n,a,u,b,i);case 3:e:{if(te(a,a.stateNode.containerInfo),n===null)throw Error(l(387));u=a.pendingProps;var j=a.memoizedState;b=j.element,Uu(n,a),Si(a,u,null,i);var P=a.memoizedState;if(u=P.cache,na(a,In,u),u!==j.cache&&zu(a,[In],i,!0),ki(),u=P.element,j.isDehydrated)if(j={element:u,isDehydrated:!1,cache:P.cache},a.updateQueue.baseState=j,a.memoizedState=j,a.flags&256){a=kp(n,a,u,i);break e}else if(u!==b){b=Ur(Error(l(424)),a),bi(b),a=kp(n,a,u,i);break e}else for(n=a.stateNode.containerInfo,n.nodeType===9?n=n.body:n=n.nodeName==="HTML"?n.ownerDocument.body:n,yn=Gr(n.firstChild),Kn=a,Ut=!0,ea=null,Vr=!0,i=yg(a,null,u,i),a.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if($a(),u===b){a=Rs(n,a,i);break e}Wn(n,a,u,i)}a=a.child}return a;case 26:return jc(n,a),n===null?(i=B0(a.type,null,a.pendingProps,null))?a.memoizedState=i:Ut||(i=a.type,n=a.pendingProps,u=$c(K.current).createElement(i),u[At]=a,u[un]=n,er(u,i,n),fn(u),a.stateNode=u):a.memoizedState=B0(a.type,n.memoizedProps,a.pendingProps,n.memoizedState),null;case 27:return xe(a),n===null&&Ut&&(u=a.stateNode=z0(a.type,a.pendingProps,K.current),Kn=a,Vr=!0,b=yn,xa(a.type)?(nh=b,yn=Gr(u.firstChild)):yn=b),Wn(n,a,a.pendingProps.children,i),jc(n,a),n===null&&(a.flags|=4194304),a.child;case 5:return n===null&&Ut&&((b=u=yn)&&(u=o2(u,a.type,a.pendingProps,Vr),u!==null?(a.stateNode=u,Kn=a,yn=Gr(u.firstChild),Vr=!1,b=!0):b=!1),b||ta(a)),xe(a),b=a.type,j=a.pendingProps,P=n!==null?n.memoizedProps:null,u=j.children,Kf(b,j)?u=null:P!==null&&Kf(b,P)&&(a.flags|=32),a.memoizedState!==null&&(b=Zu(n,a,N5,null,null,i),Vi._currentValue=b),jc(n,a),Wn(n,a,u,i),a.child;case 6:return n===null&&Ut&&((n=i=yn)&&(i=c2(i,a.pendingProps,Vr),i!==null?(a.stateNode=i,Kn=a,yn=null,n=!0):n=!1),n||ta(a)),null;case 13:return Sp(n,a,i);case 4:return te(a,a.stateNode.containerInfo),u=a.pendingProps,n===null?a.child=Fa(a,null,u,i):Wn(n,a,u,i),a.child;case 11:return gp(n,a,a.type,a.pendingProps,i);case 7:return Wn(n,a,a.pendingProps,i),a.child;case 8:return Wn(n,a,a.pendingProps.children,i),a.child;case 12:return Wn(n,a,a.pendingProps.children,i),a.child;case 10:return u=a.pendingProps,na(a,a.type,u.value),Wn(n,a,u.children,i),a.child;case 9:return b=a.type._context,u=a.pendingProps.children,Ha(a),b=Jn(b),u=u(b),a.flags|=1,Wn(n,a,u,i),a.child;case 14:return pp(n,a,a.type,a.pendingProps,i);case 15:return bp(n,a,a.type,a.pendingProps,i);case 19:return Ep(n,a,i);case 31:return M5(n,a,i);case 22:return yp(n,a,i,a.pendingProps);case 24:return Ha(a),u=Jn(In),n===null?(b=Bu(),b===null&&(b=gn,j=Iu(),b.pooledCache=j,j.refCount++,j!==null&&(b.pooledCacheLanes|=i),b=j),a.memoizedState={parent:u,cache:b},Pu(a),na(a,In,b)):((n.lanes&i)!==0&&(Uu(n,a),Si(a,null,null,i),ki()),b=n.memoizedState,j=a.memoizedState,b.parent!==u?(b={parent:u,cache:u},a.memoizedState=b,a.lanes===0&&(a.memoizedState=a.updateQueue.baseState=b),na(a,In,u)):(u=j.cache,na(a,In,u),u!==b.cache&&zu(a,[In],i,!0))),Wn(n,a,a.pendingProps.children,i),a.child;case 29:throw a.pendingProps}throw Error(l(156,a.tag))}function Ls(n){n.flags|=4}function kf(n,a,i,u,b){if((a=(n.mode&32)!==0)&&(a=!1),a){if(n.flags|=16777216,(b&335544128)===b)if(n.stateNode.complete)n.flags|=8192;else if(t0())n.flags|=8192;else throw qa=lc,Hu}else n.flags&=-16777217}function Ap(n,a){if(a.type!=="stylesheet"||(a.state.loading&4)!==0)n.flags&=-16777217;else if(n.flags|=16777216,!F0(a))if(t0())n.flags|=8192;else throw qa=lc,Hu}function Nc(n,a){a!==null&&(n.flags|=4),n.flags&16384&&(a=n.tag!==22?de():536870912,n.lanes|=a,_l|=a)}function Mi(n,a){if(!Ut)switch(n.tailMode){case"hidden":a=n.tail;for(var i=null;a!==null;)a.alternate!==null&&(i=a),a=a.sibling;i===null?n.tail=null:i.sibling=null;break;case"collapsed":i=n.tail;for(var u=null;i!==null;)i.alternate!==null&&(u=i),i=i.sibling;u===null?a||n.tail===null?n.tail=null:n.tail.sibling=null:u.sibling=null}}function vn(n){var a=n.alternate!==null&&n.alternate.child===n.child,i=0,u=0;if(a)for(var b=n.child;b!==null;)i|=b.lanes|b.childLanes,u|=b.subtreeFlags&65011712,u|=b.flags&65011712,b.return=n,b=b.sibling;else for(b=n.child;b!==null;)i|=b.lanes|b.childLanes,u|=b.subtreeFlags,u|=b.flags,b.return=n,b=b.sibling;return n.subtreeFlags|=u,n.childLanes=i,a}function O5(n,a,i){var u=a.pendingProps;switch(Mu(a),a.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return vn(a),null;case 1:return vn(a),null;case 3:return i=a.stateNode,u=null,n!==null&&(u=n.memoizedState.cache),a.memoizedState.cache!==u&&(a.flags|=2048),Ms(In),se(),i.pendingContext&&(i.context=i.pendingContext,i.pendingContext=null),(n===null||n.child===null)&&(pl(a)?Ls(a):n===null||n.memoizedState.isDehydrated&&(a.flags&256)===0||(a.flags|=1024,Ou())),vn(a),null;case 26:var b=a.type,j=a.memoizedState;return n===null?(Ls(a),j!==null?(vn(a),Ap(a,j)):(vn(a),kf(a,b,null,u,i))):j?j!==n.memoizedState?(Ls(a),vn(a),Ap(a,j)):(vn(a),a.flags&=-16777217):(n=n.memoizedProps,n!==u&&Ls(a),vn(a),kf(a,b,n,u,i)),null;case 27:if(ke(a),i=K.current,b=a.type,n!==null&&a.stateNode!=null)n.memoizedProps!==u&&Ls(a);else{if(!u){if(a.stateNode===null)throw Error(l(166));return vn(a),null}n=M.current,pl(a)?og(a):(n=z0(b,u,i),a.stateNode=n,Ls(a))}return vn(a),null;case 5:if(ke(a),b=a.type,n!==null&&a.stateNode!=null)n.memoizedProps!==u&&Ls(a);else{if(!u){if(a.stateNode===null)throw Error(l(166));return vn(a),null}if(j=M.current,pl(a))og(a);else{var P=$c(K.current);switch(j){case 1:j=P.createElementNS("http://www.w3.org/2000/svg",b);break;case 2:j=P.createElementNS("http://www.w3.org/1998/Math/MathML",b);break;default:switch(b){case"svg":j=P.createElementNS("http://www.w3.org/2000/svg",b);break;case"math":j=P.createElementNS("http://www.w3.org/1998/Math/MathML",b);break;case"script":j=P.createElement("div"),j.innerHTML="<script><\/script>",j=j.removeChild(j.firstChild);break;case"select":j=typeof u.is=="string"?P.createElement("select",{is:u.is}):P.createElement("select"),u.multiple?j.multiple=!0:u.size&&(j.size=u.size);break;default:j=typeof u.is=="string"?P.createElement(b,{is:u.is}):P.createElement(b)}}j[At]=a,j[un]=u;e:for(P=a.child;P!==null;){if(P.tag===5||P.tag===6)j.appendChild(P.stateNode);else if(P.tag!==4&&P.tag!==27&&P.child!==null){P.child.return=P,P=P.child;continue}if(P===a)break e;for(;P.sibling===null;){if(P.return===null||P.return===a)break e;P=P.return}P.sibling.return=P.return,P=P.sibling}a.stateNode=j;e:switch(er(j,b,u),b){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&Ls(a)}}return vn(a),kf(a,a.type,n===null?null:n.memoizedProps,a.pendingProps,i),null;case 6:if(n&&a.stateNode!=null)n.memoizedProps!==u&&Ls(a);else{if(typeof u!="string"&&a.stateNode===null)throw Error(l(166));if(n=K.current,pl(a)){if(n=a.stateNode,i=a.memoizedProps,u=null,b=Kn,b!==null)switch(b.tag){case 27:case 5:u=b.memoizedProps}n[At]=a,n=!!(n.nodeValue===i||u!==null&&u.suppressHydrationWarning===!0||S0(n.nodeValue,i)),n||ta(a,!0)}else n=$c(n).createTextNode(u),n[At]=a,a.stateNode=n}return vn(a),null;case 31:if(i=a.memoizedState,n===null||n.memoizedState!==null){if(u=pl(a),i!==null){if(n===null){if(!u)throw Error(l(318));if(n=a.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(l(557));n[At]=a}else $a(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;vn(a),n=!1}else i=Ou(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=i),n=!0;if(!n)return a.flags&256?(Dr(a),a):(Dr(a),null);if((a.flags&128)!==0)throw Error(l(558))}return vn(a),null;case 13:if(u=a.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(b=pl(a),u!==null&&u.dehydrated!==null){if(n===null){if(!b)throw Error(l(318));if(b=a.memoizedState,b=b!==null?b.dehydrated:null,!b)throw Error(l(317));b[At]=a}else $a(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;vn(a),b=!1}else b=Ou(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=b),b=!0;if(!b)return a.flags&256?(Dr(a),a):(Dr(a),null)}return Dr(a),(a.flags&128)!==0?(a.lanes=i,a):(i=u!==null,n=n!==null&&n.memoizedState!==null,i&&(u=a.child,b=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(b=u.alternate.memoizedState.cachePool.pool),j=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(j=u.memoizedState.cachePool.pool),j!==b&&(u.flags|=2048)),i!==n&&i&&(a.child.flags|=8192),Nc(a,a.updateQueue),vn(a),null);case 4:return se(),n===null&&Yf(a.stateNode.containerInfo),vn(a),null;case 10:return Ms(a.type),vn(a),null;case 19:if(X(Rn),u=a.memoizedState,u===null)return vn(a),null;if(b=(a.flags&128)!==0,j=u.rendering,j===null)if(b)Mi(u,!1);else{if(Dn!==0||n!==null&&(n.flags&128)!==0)for(n=a.child;n!==null;){if(j=dc(n),j!==null){for(a.flags|=128,Mi(u,!1),n=j.updateQueue,a.updateQueue=n,Nc(a,n),a.subtreeFlags=0,n=i,i=a.child;i!==null;)rg(i,n),i=i.sibling;return L(Rn,Rn.current&1|2),Ut&&As(a,u.treeForkCount),a.child}n=n.sibling}u.tail!==null&&xt()>Tc&&(a.flags|=128,b=!0,Mi(u,!1),a.lanes=4194304)}else{if(!b)if(n=dc(j),n!==null){if(a.flags|=128,b=!0,n=n.updateQueue,a.updateQueue=n,Nc(a,n),Mi(u,!0),u.tail===null&&u.tailMode==="hidden"&&!j.alternate&&!Ut)return vn(a),null}else 2*xt()-u.renderingStartTime>Tc&&i!==536870912&&(a.flags|=128,b=!0,Mi(u,!1),a.lanes=4194304);u.isBackwards?(j.sibling=a.child,a.child=j):(n=u.last,n!==null?n.sibling=j:a.child=j,u.last=j)}return u.tail!==null?(n=u.tail,u.rendering=n,u.tail=n.sibling,u.renderingStartTime=xt(),n.sibling=null,i=Rn.current,L(Rn,b?i&1|2:i&1),Ut&&As(a,u.treeForkCount),n):(vn(a),null);case 22:case 23:return Dr(a),Yu(),u=a.memoizedState!==null,n!==null?n.memoizedState!==null!==u&&(a.flags|=8192):u&&(a.flags|=8192),u?(i&536870912)!==0&&(a.flags&128)===0&&(vn(a),a.subtreeFlags&6&&(a.flags|=8192)):vn(a),i=a.updateQueue,i!==null&&Nc(a,i.retryQueue),i=null,n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(i=n.memoizedState.cachePool.pool),u=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(u=a.memoizedState.cachePool.pool),u!==i&&(a.flags|=2048),n!==null&&X(Pa),null;case 24:return i=null,n!==null&&(i=n.memoizedState.cache),a.memoizedState.cache!==i&&(a.flags|=2048),Ms(In),vn(a),null;case 25:return null;case 30:return null}throw Error(l(156,a.tag))}function R5(n,a){switch(Mu(a),a.tag){case 1:return n=a.flags,n&65536?(a.flags=n&-65537|128,a):null;case 3:return Ms(In),se(),n=a.flags,(n&65536)!==0&&(n&128)===0?(a.flags=n&-65537|128,a):null;case 26:case 27:case 5:return ke(a),null;case 31:if(a.memoizedState!==null){if(Dr(a),a.alternate===null)throw Error(l(340));$a()}return n=a.flags,n&65536?(a.flags=n&-65537|128,a):null;case 13:if(Dr(a),n=a.memoizedState,n!==null&&n.dehydrated!==null){if(a.alternate===null)throw Error(l(340));$a()}return n=a.flags,n&65536?(a.flags=n&-65537|128,a):null;case 19:return X(Rn),null;case 4:return se(),null;case 10:return Ms(a.type),null;case 22:case 23:return Dr(a),Yu(),n!==null&&X(Pa),n=a.flags,n&65536?(a.flags=n&-65537|128,a):null;case 24:return Ms(In),null;case 25:return null;default:return null}}function _p(n,a){switch(Mu(a),a.tag){case 3:Ms(In),se();break;case 26:case 27:case 5:ke(a);break;case 4:se();break;case 31:a.memoizedState!==null&&Dr(a);break;case 13:Dr(a);break;case 19:X(Rn);break;case 10:Ms(a.type);break;case 22:case 23:Dr(a),Yu(),n!==null&&X(Pa);break;case 24:Ms(In)}}function Di(n,a){try{var i=a.updateQueue,u=i!==null?i.lastEffect:null;if(u!==null){var b=u.next;i=b;do{if((i.tag&n)===n){u=void 0;var j=i.create,P=i.inst;u=j(),P.destroy=u}i=i.next}while(i!==b)}}catch(W){on(a,a.return,W)}}function oa(n,a,i){try{var u=a.updateQueue,b=u!==null?u.lastEffect:null;if(b!==null){var j=b.next;u=j;do{if((u.tag&n)===n){var P=u.inst,W=P.destroy;if(W!==void 0){P.destroy=void 0,b=a;var le=i,be=W;try{be()}catch(Ee){on(b,le,Ee)}}}u=u.next}while(u!==j)}}catch(Ee){on(a,a.return,Ee)}}function Mp(n){var a=n.updateQueue;if(a!==null){var i=n.stateNode;try{jg(a,i)}catch(u){on(n,n.return,u)}}}function Dp(n,a,i){i.props=Ya(n.type,n.memoizedProps),i.state=n.memoizedState;try{i.componentWillUnmount()}catch(u){on(n,a,u)}}function Oi(n,a){try{var i=n.ref;if(i!==null){switch(n.tag){case 26:case 27:case 5:var u=n.stateNode;break;case 30:u=n.stateNode;break;default:u=n.stateNode}typeof i=="function"?n.refCleanup=i(u):i.current=u}}catch(b){on(n,a,b)}}function hs(n,a){var i=n.ref,u=n.refCleanup;if(i!==null)if(typeof u=="function")try{u()}catch(b){on(n,a,b)}finally{n.refCleanup=null,n=n.alternate,n!=null&&(n.refCleanup=null)}else if(typeof i=="function")try{i(null)}catch(b){on(n,a,b)}else i.current=null}function Op(n){var a=n.type,i=n.memoizedProps,u=n.stateNode;try{e:switch(a){case"button":case"input":case"select":case"textarea":i.autoFocus&&u.focus();break e;case"img":i.src?u.src=i.src:i.srcSet&&(u.srcset=i.srcSet)}}catch(b){on(n,n.return,b)}}function Sf(n,a,i){try{var u=n.stateNode;n2(u,n.type,i,a),u[un]=a}catch(b){on(n,n.return,b)}}function Rp(n){return n.tag===5||n.tag===3||n.tag===26||n.tag===27&&xa(n.type)||n.tag===4}function Cf(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||Rp(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.tag===27&&xa(n.type)||n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function Ef(n,a,i){var u=n.tag;if(u===5||u===6)n=n.stateNode,a?(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i).insertBefore(n,a):(a=i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,a.appendChild(n),i=i._reactRootContainer,i!=null||a.onclick!==null||(a.onclick=Dt));else if(u!==4&&(u===27&&xa(n.type)&&(i=n.stateNode,a=null),n=n.child,n!==null))for(Ef(n,a,i),n=n.sibling;n!==null;)Ef(n,a,i),n=n.sibling}function kc(n,a,i){var u=n.tag;if(u===5||u===6)n=n.stateNode,a?i.insertBefore(n,a):i.appendChild(n);else if(u!==4&&(u===27&&xa(n.type)&&(i=n.stateNode),n=n.child,n!==null))for(kc(n,a,i),n=n.sibling;n!==null;)kc(n,a,i),n=n.sibling}function Lp(n){var a=n.stateNode,i=n.memoizedProps;try{for(var u=n.type,b=a.attributes;b.length;)a.removeAttributeNode(b[0]);er(a,u,i),a[At]=n,a[un]=i}catch(j){on(n,n.return,j)}}var zs=!1,Hn=!1,Tf=!1,zp=typeof WeakSet=="function"?WeakSet:Set,Xn=null;function L5(n,a){if(n=n.containerInfo,Zf=Vc,n=Xx(n),vu(n)){if("selectionStart"in n)var i={start:n.selectionStart,end:n.selectionEnd};else e:{i=(i=n.ownerDocument)&&i.defaultView||window;var u=i.getSelection&&i.getSelection();if(u&&u.rangeCount!==0){i=u.anchorNode;var b=u.anchorOffset,j=u.focusNode;u=u.focusOffset;try{i.nodeType,j.nodeType}catch{i=null;break e}var P=0,W=-1,le=-1,be=0,Ee=0,_e=n,ve=null;t:for(;;){for(var Ne;_e!==i||b!==0&&_e.nodeType!==3||(W=P+b),_e!==j||u!==0&&_e.nodeType!==3||(le=P+u),_e.nodeType===3&&(P+=_e.nodeValue.length),(Ne=_e.firstChild)!==null;)ve=_e,_e=Ne;for(;;){if(_e===n)break t;if(ve===i&&++be===b&&(W=P),ve===j&&++Ee===u&&(le=P),(Ne=_e.nextSibling)!==null)break;_e=ve,ve=_e.parentNode}_e=Ne}i=W===-1||le===-1?null:{start:W,end:le}}else i=null}i=i||{start:0,end:0}}else i=null;for(Qf={focusedElem:n,selectionRange:i},Vc=!1,Xn=a;Xn!==null;)if(a=Xn,n=a.child,(a.subtreeFlags&1028)!==0&&n!==null)n.return=a,Xn=n;else for(;Xn!==null;){switch(a=Xn,j=a.alternate,n=a.flags,a.tag){case 0:if((n&4)!==0&&(n=a.updateQueue,n=n!==null?n.events:null,n!==null))for(i=0;i<n.length;i++)b=n[i],b.ref.impl=b.nextImpl;break;case 11:case 15:break;case 1:if((n&1024)!==0&&j!==null){n=void 0,i=a,b=j.memoizedProps,j=j.memoizedState,u=i.stateNode;try{var We=Ya(i.type,b);n=u.getSnapshotBeforeUpdate(We,j),u.__reactInternalSnapshotBeforeUpdate=n}catch(pt){on(i,i.return,pt)}}break;case 3:if((n&1024)!==0){if(n=a.stateNode.containerInfo,i=n.nodeType,i===9)Wf(n);else if(i===1)switch(n.nodeName){case"HEAD":case"HTML":case"BODY":Wf(n);break;default:n.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((n&1024)!==0)throw Error(l(163))}if(n=a.sibling,n!==null){n.return=a.return,Xn=n;break}Xn=a.return}}function Ip(n,a,i){var u=i.flags;switch(i.tag){case 0:case 11:case 15:$s(n,i),u&4&&Di(5,i);break;case 1:if($s(n,i),u&4)if(n=i.stateNode,a===null)try{n.componentDidMount()}catch(P){on(i,i.return,P)}else{var b=Ya(i.type,a.memoizedProps);a=a.memoizedState;try{n.componentDidUpdate(b,a,n.__reactInternalSnapshotBeforeUpdate)}catch(P){on(i,i.return,P)}}u&64&&Mp(i),u&512&&Oi(i,i.return);break;case 3:if($s(n,i),u&64&&(n=i.updateQueue,n!==null)){if(a=null,i.child!==null)switch(i.child.tag){case 27:case 5:a=i.child.stateNode;break;case 1:a=i.child.stateNode}try{jg(n,a)}catch(P){on(i,i.return,P)}}break;case 27:a===null&&u&4&&Lp(i);case 26:case 5:$s(n,i),a===null&&u&4&&Op(i),u&512&&Oi(i,i.return);break;case 12:$s(n,i);break;case 31:$s(n,i),u&4&&Hp(n,i);break;case 13:$s(n,i),u&4&&Pp(n,i),u&64&&(n=i.memoizedState,n!==null&&(n=n.dehydrated,n!==null&&(i=F5.bind(null,i),d2(n,i))));break;case 22:if(u=i.memoizedState!==null||zs,!u){a=a!==null&&a.memoizedState!==null||Hn,b=zs;var j=Hn;zs=u,(Hn=a)&&!j?Bs(n,i,(i.subtreeFlags&8772)!==0):$s(n,i),zs=b,Hn=j}break;case 30:break;default:$s(n,i)}}function $p(n){var a=n.alternate;a!==null&&(n.alternate=null,$p(a)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(a=n.stateNode,a!==null&&Qn(a)),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}var Nn=null,gr=!1;function Is(n,a,i){for(i=i.child;i!==null;)Bp(n,a,i),i=i.sibling}function Bp(n,a,i){if(Tt&&typeof Tt.onCommitFiberUnmount=="function")try{Tt.onCommitFiberUnmount(Lt,i)}catch{}switch(i.tag){case 26:Hn||hs(i,a),Is(n,a,i),i.memoizedState?i.memoizedState.count--:i.stateNode&&(i=i.stateNode,i.parentNode.removeChild(i));break;case 27:Hn||hs(i,a);var u=Nn,b=gr;xa(i.type)&&(Nn=i.stateNode,gr=!1),Is(n,a,i),Ui(i.stateNode),Nn=u,gr=b;break;case 5:Hn||hs(i,a);case 6:if(u=Nn,b=gr,Nn=null,Is(n,a,i),Nn=u,gr=b,Nn!==null)if(gr)try{(Nn.nodeType===9?Nn.body:Nn.nodeName==="HTML"?Nn.ownerDocument.body:Nn).removeChild(i.stateNode)}catch(j){on(i,a,j)}else try{Nn.removeChild(i.stateNode)}catch(j){on(i,a,j)}break;case 18:Nn!==null&&(gr?(n=Nn,M0(n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n,i.stateNode),$l(n)):M0(Nn,i.stateNode));break;case 4:u=Nn,b=gr,Nn=i.stateNode.containerInfo,gr=!0,Is(n,a,i),Nn=u,gr=b;break;case 0:case 11:case 14:case 15:oa(2,i,a),Hn||oa(4,i,a),Is(n,a,i);break;case 1:Hn||(hs(i,a),u=i.stateNode,typeof u.componentWillUnmount=="function"&&Dp(i,a,u)),Is(n,a,i);break;case 21:Is(n,a,i);break;case 22:Hn=(u=Hn)||i.memoizedState!==null,Is(n,a,i),Hn=u;break;default:Is(n,a,i)}}function Hp(n,a){if(a.memoizedState===null&&(n=a.alternate,n!==null&&(n=n.memoizedState,n!==null))){n=n.dehydrated;try{$l(n)}catch(i){on(a,a.return,i)}}}function Pp(n,a){if(a.memoizedState===null&&(n=a.alternate,n!==null&&(n=n.memoizedState,n!==null&&(n=n.dehydrated,n!==null))))try{$l(n)}catch(i){on(a,a.return,i)}}function z5(n){switch(n.tag){case 31:case 13:case 19:var a=n.stateNode;return a===null&&(a=n.stateNode=new zp),a;case 22:return n=n.stateNode,a=n._retryCache,a===null&&(a=n._retryCache=new zp),a;default:throw Error(l(435,n.tag))}}function Sc(n,a){var i=z5(n);a.forEach(function(u){if(!i.has(u)){i.add(u);var b=V5.bind(null,n,u);u.then(b,b)}})}function pr(n,a){var i=a.deletions;if(i!==null)for(var u=0;u<i.length;u++){var b=i[u],j=n,P=a,W=P;e:for(;W!==null;){switch(W.tag){case 27:if(xa(W.type)){Nn=W.stateNode,gr=!1;break e}break;case 5:Nn=W.stateNode,gr=!1;break e;case 3:case 4:Nn=W.stateNode.containerInfo,gr=!0;break e}W=W.return}if(Nn===null)throw Error(l(160));Bp(j,P,b),Nn=null,gr=!1,j=b.alternate,j!==null&&(j.return=null),b.return=null}if(a.subtreeFlags&13886)for(a=a.child;a!==null;)Up(a,n),a=a.sibling}var Wr=null;function Up(n,a){var i=n.alternate,u=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:pr(a,n),br(n),u&4&&(oa(3,n,n.return),Di(3,n),oa(5,n,n.return));break;case 1:pr(a,n),br(n),u&512&&(Hn||i===null||hs(i,i.return)),u&64&&zs&&(n=n.updateQueue,n!==null&&(u=n.callbacks,u!==null&&(i=n.shared.hiddenCallbacks,n.shared.hiddenCallbacks=i===null?u:i.concat(u))));break;case 26:var b=Wr;if(pr(a,n),br(n),u&512&&(Hn||i===null||hs(i,i.return)),u&4){var j=i!==null?i.memoizedState:null;if(u=n.memoizedState,i===null)if(u===null)if(n.stateNode===null){e:{u=n.type,i=n.memoizedProps,b=b.ownerDocument||b;t:switch(u){case"title":j=b.getElementsByTagName("title")[0],(!j||j[Tn]||j[At]||j.namespaceURI==="http://www.w3.org/2000/svg"||j.hasAttribute("itemprop"))&&(j=b.createElement(u),b.head.insertBefore(j,b.querySelector("head > title"))),er(j,u,i),j[At]=n,fn(j),u=j;break e;case"link":var P=U0("link","href",b).get(u+(i.href||""));if(P){for(var W=0;W<P.length;W++)if(j=P[W],j.getAttribute("href")===(i.href==null||i.href===""?null:i.href)&&j.getAttribute("rel")===(i.rel==null?null:i.rel)&&j.getAttribute("title")===(i.title==null?null:i.title)&&j.getAttribute("crossorigin")===(i.crossOrigin==null?null:i.crossOrigin)){P.splice(W,1);break t}}j=b.createElement(u),er(j,u,i),b.head.appendChild(j);break;case"meta":if(P=U0("meta","content",b).get(u+(i.content||""))){for(W=0;W<P.length;W++)if(j=P[W],j.getAttribute("content")===(i.content==null?null:""+i.content)&&j.getAttribute("name")===(i.name==null?null:i.name)&&j.getAttribute("property")===(i.property==null?null:i.property)&&j.getAttribute("http-equiv")===(i.httpEquiv==null?null:i.httpEquiv)&&j.getAttribute("charset")===(i.charSet==null?null:i.charSet)){P.splice(W,1);break t}}j=b.createElement(u),er(j,u,i),b.head.appendChild(j);break;default:throw Error(l(468,u))}j[At]=n,fn(j),u=j}n.stateNode=u}else q0(b,n.type,n.stateNode);else n.stateNode=P0(b,u,n.memoizedProps);else j!==u?(j===null?i.stateNode!==null&&(i=i.stateNode,i.parentNode.removeChild(i)):j.count--,u===null?q0(b,n.type,n.stateNode):P0(b,u,n.memoizedProps)):u===null&&n.stateNode!==null&&Sf(n,n.memoizedProps,i.memoizedProps)}break;case 27:pr(a,n),br(n),u&512&&(Hn||i===null||hs(i,i.return)),i!==null&&u&4&&Sf(n,n.memoizedProps,i.memoizedProps);break;case 5:if(pr(a,n),br(n),u&512&&(Hn||i===null||hs(i,i.return)),n.flags&32){b=n.stateNode;try{me(b,"")}catch(We){on(n,n.return,We)}}u&4&&n.stateNode!=null&&(b=n.memoizedProps,Sf(n,b,i!==null?i.memoizedProps:b)),u&1024&&(Tf=!0);break;case 6:if(pr(a,n),br(n),u&4){if(n.stateNode===null)throw Error(l(162));u=n.memoizedProps,i=n.stateNode;try{i.nodeValue=u}catch(We){on(n,n.return,We)}}break;case 3:if(Pc=null,b=Wr,Wr=Bc(a.containerInfo),pr(a,n),Wr=b,br(n),u&4&&i!==null&&i.memoizedState.isDehydrated)try{$l(a.containerInfo)}catch(We){on(n,n.return,We)}Tf&&(Tf=!1,qp(n));break;case 4:u=Wr,Wr=Bc(n.stateNode.containerInfo),pr(a,n),br(n),Wr=u;break;case 12:pr(a,n),br(n);break;case 31:pr(a,n),br(n),u&4&&(u=n.updateQueue,u!==null&&(n.updateQueue=null,Sc(n,u)));break;case 13:pr(a,n),br(n),n.child.flags&8192&&n.memoizedState!==null!=(i!==null&&i.memoizedState!==null)&&(Ec=xt()),u&4&&(u=n.updateQueue,u!==null&&(n.updateQueue=null,Sc(n,u)));break;case 22:b=n.memoizedState!==null;var le=i!==null&&i.memoizedState!==null,be=zs,Ee=Hn;if(zs=be||b,Hn=Ee||le,pr(a,n),Hn=Ee,zs=be,br(n),u&8192)e:for(a=n.stateNode,a._visibility=b?a._visibility&-2:a._visibility|1,b&&(i===null||le||zs||Hn||Ga(n)),i=null,a=n;;){if(a.tag===5||a.tag===26){if(i===null){le=i=a;try{if(j=le.stateNode,b)P=j.style,typeof P.setProperty=="function"?P.setProperty("display","none","important"):P.display="none";else{W=le.stateNode;var _e=le.memoizedProps.style,ve=_e!=null&&_e.hasOwnProperty("display")?_e.display:null;W.style.display=ve==null||typeof ve=="boolean"?"":(""+ve).trim()}}catch(We){on(le,le.return,We)}}}else if(a.tag===6){if(i===null){le=a;try{le.stateNode.nodeValue=b?"":le.memoizedProps}catch(We){on(le,le.return,We)}}}else if(a.tag===18){if(i===null){le=a;try{var Ne=le.stateNode;b?D0(Ne,!0):D0(le.stateNode,!1)}catch(We){on(le,le.return,We)}}}else if((a.tag!==22&&a.tag!==23||a.memoizedState===null||a===n)&&a.child!==null){a.child.return=a,a=a.child;continue}if(a===n)break e;for(;a.sibling===null;){if(a.return===null||a.return===n)break e;i===a&&(i=null),a=a.return}i===a&&(i=null),a.sibling.return=a.return,a=a.sibling}u&4&&(u=n.updateQueue,u!==null&&(i=u.retryQueue,i!==null&&(u.retryQueue=null,Sc(n,i))));break;case 19:pr(a,n),br(n),u&4&&(u=n.updateQueue,u!==null&&(n.updateQueue=null,Sc(n,u)));break;case 30:break;case 21:break;default:pr(a,n),br(n)}}function br(n){var a=n.flags;if(a&2){try{for(var i,u=n.return;u!==null;){if(Rp(u)){i=u;break}u=u.return}if(i==null)throw Error(l(160));switch(i.tag){case 27:var b=i.stateNode,j=Cf(n);kc(n,j,b);break;case 5:var P=i.stateNode;i.flags&32&&(me(P,""),i.flags&=-33);var W=Cf(n);kc(n,W,P);break;case 3:case 4:var le=i.stateNode.containerInfo,be=Cf(n);Ef(n,be,le);break;default:throw Error(l(161))}}catch(Ee){on(n,n.return,Ee)}n.flags&=-3}a&4096&&(n.flags&=-4097)}function qp(n){if(n.subtreeFlags&1024)for(n=n.child;n!==null;){var a=n;qp(a),a.tag===5&&a.flags&1024&&a.stateNode.reset(),n=n.sibling}}function $s(n,a){if(a.subtreeFlags&8772)for(a=a.child;a!==null;)Ip(n,a.alternate,a),a=a.sibling}function Ga(n){for(n=n.child;n!==null;){var a=n;switch(a.tag){case 0:case 11:case 14:case 15:oa(4,a,a.return),Ga(a);break;case 1:hs(a,a.return);var i=a.stateNode;typeof i.componentWillUnmount=="function"&&Dp(a,a.return,i),Ga(a);break;case 27:Ui(a.stateNode);case 26:case 5:hs(a,a.return),Ga(a);break;case 22:a.memoizedState===null&&Ga(a);break;case 30:Ga(a);break;default:Ga(a)}n=n.sibling}}function Bs(n,a,i){for(i=i&&(a.subtreeFlags&8772)!==0,a=a.child;a!==null;){var u=a.alternate,b=n,j=a,P=j.flags;switch(j.tag){case 0:case 11:case 15:Bs(b,j,i),Di(4,j);break;case 1:if(Bs(b,j,i),u=j,b=u.stateNode,typeof b.componentDidMount=="function")try{b.componentDidMount()}catch(be){on(u,u.return,be)}if(u=j,b=u.updateQueue,b!==null){var W=u.stateNode;try{var le=b.shared.hiddenCallbacks;if(le!==null)for(b.shared.hiddenCallbacks=null,b=0;b<le.length;b++)vg(le[b],W)}catch(be){on(u,u.return,be)}}i&&P&64&&Mp(j),Oi(j,j.return);break;case 27:Lp(j);case 26:case 5:Bs(b,j,i),i&&u===null&&P&4&&Op(j),Oi(j,j.return);break;case 12:Bs(b,j,i);break;case 31:Bs(b,j,i),i&&P&4&&Hp(b,j);break;case 13:Bs(b,j,i),i&&P&4&&Pp(b,j);break;case 22:j.memoizedState===null&&Bs(b,j,i),Oi(j,j.return);break;case 30:break;default:Bs(b,j,i)}a=a.sibling}}function Af(n,a){var i=null;n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(i=n.memoizedState.cachePool.pool),n=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(n=a.memoizedState.cachePool.pool),n!==i&&(n!=null&&n.refCount++,i!=null&&yi(i))}function _f(n,a){n=null,a.alternate!==null&&(n=a.alternate.memoizedState.cache),a=a.memoizedState.cache,a!==n&&(a.refCount++,n!=null&&yi(n))}function es(n,a,i,u){if(a.subtreeFlags&10256)for(a=a.child;a!==null;)Fp(n,a,i,u),a=a.sibling}function Fp(n,a,i,u){var b=a.flags;switch(a.tag){case 0:case 11:case 15:es(n,a,i,u),b&2048&&Di(9,a);break;case 1:es(n,a,i,u);break;case 3:es(n,a,i,u),b&2048&&(n=null,a.alternate!==null&&(n=a.alternate.memoizedState.cache),a=a.memoizedState.cache,a!==n&&(a.refCount++,n!=null&&yi(n)));break;case 12:if(b&2048){es(n,a,i,u),n=a.stateNode;try{var j=a.memoizedProps,P=j.id,W=j.onPostCommit;typeof W=="function"&&W(P,a.alternate===null?"mount":"update",n.passiveEffectDuration,-0)}catch(le){on(a,a.return,le)}}else es(n,a,i,u);break;case 31:es(n,a,i,u);break;case 13:es(n,a,i,u);break;case 23:break;case 22:j=a.stateNode,P=a.alternate,a.memoizedState!==null?j._visibility&2?es(n,a,i,u):Ri(n,a):j._visibility&2?es(n,a,i,u):(j._visibility|=2,El(n,a,i,u,(a.subtreeFlags&10256)!==0||!1)),b&2048&&Af(P,a);break;case 24:es(n,a,i,u),b&2048&&_f(a.alternate,a);break;default:es(n,a,i,u)}}function El(n,a,i,u,b){for(b=b&&((a.subtreeFlags&10256)!==0||!1),a=a.child;a!==null;){var j=n,P=a,W=i,le=u,be=P.flags;switch(P.tag){case 0:case 11:case 15:El(j,P,W,le,b),Di(8,P);break;case 23:break;case 22:var Ee=P.stateNode;P.memoizedState!==null?Ee._visibility&2?El(j,P,W,le,b):Ri(j,P):(Ee._visibility|=2,El(j,P,W,le,b)),b&&be&2048&&Af(P.alternate,P);break;case 24:El(j,P,W,le,b),b&&be&2048&&_f(P.alternate,P);break;default:El(j,P,W,le,b)}a=a.sibling}}function Ri(n,a){if(a.subtreeFlags&10256)for(a=a.child;a!==null;){var i=n,u=a,b=u.flags;switch(u.tag){case 22:Ri(i,u),b&2048&&Af(u.alternate,u);break;case 24:Ri(i,u),b&2048&&_f(u.alternate,u);break;default:Ri(i,u)}a=a.sibling}}var Li=8192;function Tl(n,a,i){if(n.subtreeFlags&Li)for(n=n.child;n!==null;)Vp(n,a,i),n=n.sibling}function Vp(n,a,i){switch(n.tag){case 26:Tl(n,a,i),n.flags&Li&&n.memoizedState!==null&&w2(i,Wr,n.memoizedState,n.memoizedProps);break;case 5:Tl(n,a,i);break;case 3:case 4:var u=Wr;Wr=Bc(n.stateNode.containerInfo),Tl(n,a,i),Wr=u;break;case 22:n.memoizedState===null&&(u=n.alternate,u!==null&&u.memoizedState!==null?(u=Li,Li=16777216,Tl(n,a,i),Li=u):Tl(n,a,i));break;default:Tl(n,a,i)}}function Yp(n){var a=n.alternate;if(a!==null&&(n=a.child,n!==null)){a.child=null;do a=n.sibling,n.sibling=null,n=a;while(n!==null)}}function zi(n){var a=n.deletions;if((n.flags&16)!==0){if(a!==null)for(var i=0;i<a.length;i++){var u=a[i];Xn=u,Xp(u,n)}Yp(n)}if(n.subtreeFlags&10256)for(n=n.child;n!==null;)Gp(n),n=n.sibling}function Gp(n){switch(n.tag){case 0:case 11:case 15:zi(n),n.flags&2048&&oa(9,n,n.return);break;case 3:zi(n);break;case 12:zi(n);break;case 22:var a=n.stateNode;n.memoizedState!==null&&a._visibility&2&&(n.return===null||n.return.tag!==13)?(a._visibility&=-3,Cc(n)):zi(n);break;default:zi(n)}}function Cc(n){var a=n.deletions;if((n.flags&16)!==0){if(a!==null)for(var i=0;i<a.length;i++){var u=a[i];Xn=u,Xp(u,n)}Yp(n)}for(n=n.child;n!==null;){switch(a=n,a.tag){case 0:case 11:case 15:oa(8,a,a.return),Cc(a);break;case 22:i=a.stateNode,i._visibility&2&&(i._visibility&=-3,Cc(a));break;default:Cc(a)}n=n.sibling}}function Xp(n,a){for(;Xn!==null;){var i=Xn;switch(i.tag){case 0:case 11:case 15:oa(8,i,a);break;case 23:case 22:if(i.memoizedState!==null&&i.memoizedState.cachePool!==null){var u=i.memoizedState.cachePool.pool;u!=null&&u.refCount++}break;case 24:yi(i.memoizedState.cache)}if(u=i.child,u!==null)u.return=i,Xn=u;else e:for(i=n;Xn!==null;){u=Xn;var b=u.sibling,j=u.return;if($p(u),u===i){Xn=null;break e}if(b!==null){b.return=j,Xn=b;break e}Xn=j}}}var I5={getCacheForType:function(n){var a=Jn(In),i=a.data.get(n);return i===void 0&&(i=n(),a.data.set(n,i)),i},cacheSignal:function(){return Jn(In).controller.signal}},$5=typeof WeakMap=="function"?WeakMap:Map,nn=0,gn=null,It=null,Ht=0,ln=0,Or=null,ca=!1,Al=!1,Mf=!1,Hs=0,Dn=0,da=0,Xa=0,Df=0,Rr=0,_l=0,Ii=null,yr=null,Of=!1,Ec=0,Zp=0,Tc=1/0,Ac=null,ua=null,Vn=0,fa=null,Ml=null,Ps=0,Rf=0,Lf=null,Qp=null,$i=0,zf=null;function Lr(){return(nn&2)!==0&&Ht!==0?Ht&-Ht:_.T!==null?Uf():wn()}function Kp(){if(Rr===0)if((Ht&536870912)===0||Ut){var n=vt;vt<<=1,(vt&3932160)===0&&(vt=262144),Rr=n}else Rr=536870912;return n=Mr.current,n!==null&&(n.flags|=32),Rr}function vr(n,a,i){(n===gn&&(ln===2||ln===9)||n.cancelPendingCommit!==null)&&(Dl(n,0),ha(n,Ht,Rr,!1)),Le(n,i),((nn&2)===0||n!==gn)&&(n===gn&&((nn&2)===0&&(Xa|=i),Dn===4&&ha(n,Ht,Rr,!1)),ms(n))}function Jp(n,a,i){if((nn&6)!==0)throw Error(l(327));var u=!i&&(a&127)===0&&(a&n.expiredLanes)===0||en(n,a),b=u?P5(n,a):$f(n,a,!0),j=u;do{if(b===0){Al&&!u&&ha(n,a,0,!1);break}else{if(i=n.current.alternate,j&&!B5(i)){b=$f(n,a,!1),j=!1;continue}if(b===2){if(j=a,n.errorRecoveryDisabledLanes&j)var P=0;else P=n.pendingLanes&-536870913,P=P!==0?P:P&536870912?536870912:0;if(P!==0){a=P;e:{var W=n;b=Ii;var le=W.current.memoizedState.isDehydrated;if(le&&(Dl(W,P).flags|=256),P=$f(W,P,!1),P!==2){if(Mf&&!le){W.errorRecoveryDisabledLanes|=j,Xa|=j,b=4;break e}j=yr,yr=b,j!==null&&(yr===null?yr=j:yr.push.apply(yr,j))}b=P}if(j=!1,b!==2)continue}}if(b===1){Dl(n,0),ha(n,a,0,!0);break}e:{switch(u=n,j=b,j){case 0:case 1:throw Error(l(345));case 4:if((a&4194048)!==a)break;case 6:ha(u,a,Rr,!ca);break e;case 2:yr=null;break;case 3:case 5:break;default:throw Error(l(329))}if((a&62914560)===a&&(b=Ec+300-xt(),10<b)){if(ha(u,a,Rr,!ca),Wt(u,0,!0)!==0)break e;Ps=a,u.timeoutHandle=A0(Wp.bind(null,u,i,yr,Ac,Of,a,Rr,Xa,_l,ca,j,"Throttled",-0,0),b);break e}Wp(u,i,yr,Ac,Of,a,Rr,Xa,_l,ca,j,null,-0,0)}}break}while(!0);ms(n)}function Wp(n,a,i,u,b,j,P,W,le,be,Ee,_e,ve,Ne){if(n.timeoutHandle=-1,_e=a.subtreeFlags,_e&8192||(_e&16785408)===16785408){_e={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Dt},Vp(a,j,_e);var We=(j&62914560)===j?Ec-xt():(j&4194048)===j?Zp-xt():0;if(We=N2(_e,We),We!==null){Ps=j,n.cancelPendingCommit=We(i0.bind(null,n,a,j,i,u,b,P,W,le,Ee,_e,null,ve,Ne)),ha(n,j,P,!be);return}}i0(n,a,j,i,u,b,P,W,le)}function B5(n){for(var a=n;;){var i=a.tag;if((i===0||i===11||i===15)&&a.flags&16384&&(i=a.updateQueue,i!==null&&(i=i.stores,i!==null)))for(var u=0;u<i.length;u++){var b=i[u],j=b.getSnapshot;b=b.value;try{if(!Ar(j(),b))return!1}catch{return!1}}if(i=a.child,a.subtreeFlags&16384&&i!==null)i.return=a,a=i;else{if(a===n)break;for(;a.sibling===null;){if(a.return===null||a.return===n)return!0;a=a.return}a.sibling.return=a.return,a=a.sibling}}return!0}function ha(n,a,i,u){a&=~Df,a&=~Xa,n.suspendedLanes|=a,n.pingedLanes&=~a,u&&(n.warmLanes|=a),u=n.expirationTimes;for(var b=a;0<b;){var j=31-yt(b),P=1<<j;u[j]=-1,b&=~P}i!==0&&Qe(n,i,a)}function _c(){return(nn&6)===0?(Bi(0),!1):!0}function If(){if(It!==null){if(ln===0)var n=It.return;else n=It,_s=Ba=null,Ju(n),wl=null,ji=0,n=It;for(;n!==null;)_p(n.alternate,n),n=n.return;It=null}}function Dl(n,a){var i=n.timeoutHandle;i!==-1&&(n.timeoutHandle=-1,a2(i)),i=n.cancelPendingCommit,i!==null&&(n.cancelPendingCommit=null,i()),Ps=0,If(),gn=n,It=i=Ts(n.current,null),Ht=a,ln=0,Or=null,ca=!1,Al=en(n,a),Mf=!1,_l=Rr=Df=Xa=da=Dn=0,yr=Ii=null,Of=!1,(a&8)!==0&&(a|=a&32);var u=n.entangledLanes;if(u!==0)for(n=n.entanglements,u&=a;0<u;){var b=31-yt(u),j=1<<b;a|=n[b],u&=~j}return Hs=a,Ko(),i}function e0(n,a){_t=null,_.H=Ai,a===jl||a===ac?(a=gg(),ln=3):a===Hu?(a=gg(),ln=4):ln=a===xf?8:a!==null&&typeof a=="object"&&typeof a.then=="function"?6:1,Or=a,It===null&&(Dn=1,yc(n,Ur(a,n.current)))}function t0(){var n=Mr.current;return n===null?!0:(Ht&4194048)===Ht?Yr===null:(Ht&62914560)===Ht||(Ht&536870912)!==0?n===Yr:!1}function n0(){var n=_.H;return _.H=Ai,n===null?Ai:n}function r0(){var n=_.A;return _.A=I5,n}function Mc(){Dn=4,ca||(Ht&4194048)!==Ht&&Mr.current!==null||(Al=!0),(da&134217727)===0&&(Xa&134217727)===0||gn===null||ha(gn,Ht,Rr,!1)}function $f(n,a,i){var u=nn;nn|=2;var b=n0(),j=r0();(gn!==n||Ht!==a)&&(Ac=null,Dl(n,a)),a=!1;var P=Dn;e:do try{if(ln!==0&&It!==null){var W=It,le=Or;switch(ln){case 8:If(),P=6;break e;case 3:case 2:case 9:case 6:Mr.current===null&&(a=!0);var be=ln;if(ln=0,Or=null,Ol(n,W,le,be),i&&Al){P=0;break e}break;default:be=ln,ln=0,Or=null,Ol(n,W,le,be)}}H5(),P=Dn;break}catch(Ee){e0(n,Ee)}while(!0);return a&&n.shellSuspendCounter++,_s=Ba=null,nn=u,_.H=b,_.A=j,It===null&&(gn=null,Ht=0,Ko()),P}function H5(){for(;It!==null;)s0(It)}function P5(n,a){var i=nn;nn|=2;var u=n0(),b=r0();gn!==n||Ht!==a?(Ac=null,Tc=xt()+500,Dl(n,a)):Al=en(n,a);e:do try{if(ln!==0&&It!==null){a=It;var j=Or;t:switch(ln){case 1:ln=0,Or=null,Ol(n,a,j,1);break;case 2:case 9:if(mg(j)){ln=0,Or=null,a0(a);break}a=function(){ln!==2&&ln!==9||gn!==n||(ln=7),ms(n)},j.then(a,a);break e;case 3:ln=7;break e;case 4:ln=5;break e;case 7:mg(j)?(ln=0,Or=null,a0(a)):(ln=0,Or=null,Ol(n,a,j,7));break;case 5:var P=null;switch(It.tag){case 26:P=It.memoizedState;case 5:case 27:var W=It;if(P?F0(P):W.stateNode.complete){ln=0,Or=null;var le=W.sibling;if(le!==null)It=le;else{var be=W.return;be!==null?(It=be,Dc(be)):It=null}break t}}ln=0,Or=null,Ol(n,a,j,5);break;case 6:ln=0,Or=null,Ol(n,a,j,6);break;case 8:If(),Dn=6;break e;default:throw Error(l(462))}}U5();break}catch(Ee){e0(n,Ee)}while(!0);return _s=Ba=null,_.H=u,_.A=b,nn=i,It!==null?0:(gn=null,Ht=0,Ko(),Dn)}function U5(){for(;It!==null&&!Te();)s0(It)}function s0(n){var a=Tp(n.alternate,n,Hs);n.memoizedProps=n.pendingProps,a===null?Dc(n):It=a}function a0(n){var a=n,i=a.alternate;switch(a.tag){case 15:case 0:a=wp(i,a,a.pendingProps,a.type,void 0,Ht);break;case 11:a=wp(i,a,a.pendingProps,a.type.render,a.ref,Ht);break;case 5:Ju(a);default:_p(i,a),a=It=rg(a,Hs),a=Tp(i,a,Hs)}n.memoizedProps=n.pendingProps,a===null?Dc(n):It=a}function Ol(n,a,i,u){_s=Ba=null,Ju(a),wl=null,ji=0;var b=a.return;try{if(_5(n,b,a,i,Ht)){Dn=1,yc(n,Ur(i,n.current)),It=null;return}}catch(j){if(b!==null)throw It=b,j;Dn=1,yc(n,Ur(i,n.current)),It=null;return}a.flags&32768?(Ut||u===1?n=!0:Al||(Ht&536870912)!==0?n=!1:(ca=n=!0,(u===2||u===9||u===3||u===6)&&(u=Mr.current,u!==null&&u.tag===13&&(u.flags|=16384))),l0(a,n)):Dc(a)}function Dc(n){var a=n;do{if((a.flags&32768)!==0){l0(a,ca);return}n=a.return;var i=O5(a.alternate,a,Hs);if(i!==null){It=i;return}if(a=a.sibling,a!==null){It=a;return}It=a=n}while(a!==null);Dn===0&&(Dn=5)}function l0(n,a){do{var i=R5(n.alternate,n);if(i!==null){i.flags&=32767,It=i;return}if(i=n.return,i!==null&&(i.flags|=32768,i.subtreeFlags=0,i.deletions=null),!a&&(n=n.sibling,n!==null)){It=n;return}It=n=i}while(n!==null);Dn=6,It=null}function i0(n,a,i,u,b,j,P,W,le){n.cancelPendingCommit=null;do Oc();while(Vn!==0);if((nn&6)!==0)throw Error(l(327));if(a!==null){if(a===n.current)throw Error(l(177));if(j=a.lanes|a.childLanes,j|=Su,ot(n,i,j,P,W,le),n===gn&&(It=gn=null,Ht=0),Ml=a,fa=n,Ps=i,Rf=j,Lf=b,Qp=u,(a.subtreeFlags&10256)!==0||(a.flags&10256)!==0?(n.callbackNode=null,n.callbackPriority=0,Y5(qe,function(){return f0(),null})):(n.callbackNode=null,n.callbackPriority=0),u=(a.flags&13878)!==0,(a.subtreeFlags&13878)!==0||u){u=_.T,_.T=null,b=Y.p,Y.p=2,P=nn,nn|=4;try{L5(n,a,i)}finally{nn=P,Y.p=b,_.T=u}}Vn=1,o0(),c0(),d0()}}function o0(){if(Vn===1){Vn=0;var n=fa,a=Ml,i=(a.flags&13878)!==0;if((a.subtreeFlags&13878)!==0||i){i=_.T,_.T=null;var u=Y.p;Y.p=2;var b=nn;nn|=4;try{Up(a,n);var j=Qf,P=Xx(n.containerInfo),W=j.focusedElem,le=j.selectionRange;if(P!==W&&W&&W.ownerDocument&&Gx(W.ownerDocument.documentElement,W)){if(le!==null&&vu(W)){var be=le.start,Ee=le.end;if(Ee===void 0&&(Ee=be),"selectionStart"in W)W.selectionStart=be,W.selectionEnd=Math.min(Ee,W.value.length);else{var _e=W.ownerDocument||document,ve=_e&&_e.defaultView||window;if(ve.getSelection){var Ne=ve.getSelection(),We=W.textContent.length,pt=Math.min(le.start,We),xn=le.end===void 0?pt:Math.min(le.end,We);!Ne.extend&&pt>xn&&(P=xn,xn=pt,pt=P);var ue=Yx(W,pt),ce=Yx(W,xn);if(ue&&ce&&(Ne.rangeCount!==1||Ne.anchorNode!==ue.node||Ne.anchorOffset!==ue.offset||Ne.focusNode!==ce.node||Ne.focusOffset!==ce.offset)){var pe=_e.createRange();pe.setStart(ue.node,ue.offset),Ne.removeAllRanges(),pt>xn?(Ne.addRange(pe),Ne.extend(ce.node,ce.offset)):(pe.setEnd(ce.node,ce.offset),Ne.addRange(pe))}}}}for(_e=[],Ne=W;Ne=Ne.parentNode;)Ne.nodeType===1&&_e.push({element:Ne,left:Ne.scrollLeft,top:Ne.scrollTop});for(typeof W.focus=="function"&&W.focus(),W=0;W<_e.length;W++){var Ae=_e[W];Ae.element.scrollLeft=Ae.left,Ae.element.scrollTop=Ae.top}}Vc=!!Zf,Qf=Zf=null}finally{nn=b,Y.p=u,_.T=i}}n.current=a,Vn=2}}function c0(){if(Vn===2){Vn=0;var n=fa,a=Ml,i=(a.flags&8772)!==0;if((a.subtreeFlags&8772)!==0||i){i=_.T,_.T=null;var u=Y.p;Y.p=2;var b=nn;nn|=4;try{Ip(n,a.alternate,a)}finally{nn=b,Y.p=u,_.T=i}}Vn=3}}function d0(){if(Vn===4||Vn===3){Vn=0,Ze();var n=fa,a=Ml,i=Ps,u=Qp;(a.subtreeFlags&10256)!==0||(a.flags&10256)!==0?Vn=5:(Vn=0,Ml=fa=null,u0(n,n.pendingLanes));var b=n.pendingLanes;if(b===0&&(ua=null),gt(i),a=a.stateNode,Tt&&typeof Tt.onCommitFiberRoot=="function")try{Tt.onCommitFiberRoot(Lt,a,void 0,(a.current.flags&128)===128)}catch{}if(u!==null){a=_.T,b=Y.p,Y.p=2,_.T=null;try{for(var j=n.onRecoverableError,P=0;P<u.length;P++){var W=u[P];j(W.value,{componentStack:W.stack})}}finally{_.T=a,Y.p=b}}(Ps&3)!==0&&Oc(),ms(n),b=n.pendingLanes,(i&261930)!==0&&(b&42)!==0?n===zf?$i++:($i=0,zf=n):$i=0,Bi(0)}}function u0(n,a){(n.pooledCacheLanes&=a)===0&&(a=n.pooledCache,a!=null&&(n.pooledCache=null,yi(a)))}function Oc(){return o0(),c0(),d0(),f0()}function f0(){if(Vn!==5)return!1;var n=fa,a=Rf;Rf=0;var i=gt(Ps),u=_.T,b=Y.p;try{Y.p=32>i?32:i,_.T=null,i=Lf,Lf=null;var j=fa,P=Ps;if(Vn=0,Ml=fa=null,Ps=0,(nn&6)!==0)throw Error(l(331));var W=nn;if(nn|=4,Gp(j.current),Fp(j,j.current,P,i),nn=W,Bi(0,!1),Tt&&typeof Tt.onPostCommitFiberRoot=="function")try{Tt.onPostCommitFiberRoot(Lt,j)}catch{}return!0}finally{Y.p=b,_.T=u,u0(n,a)}}function h0(n,a,i){a=Ur(i,a),a=mf(n.stateNode,a,2),n=aa(n,a,2),n!==null&&(Le(n,2),ms(n))}function on(n,a,i){if(n.tag===3)h0(n,n,i);else for(;a!==null;){if(a.tag===3){h0(a,n,i);break}else if(a.tag===1){var u=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(ua===null||!ua.has(u))){n=Ur(i,n),i=mp(2),u=aa(a,i,2),u!==null&&(xp(i,u,a,n),Le(u,2),ms(u));break}}a=a.return}}function Bf(n,a,i){var u=n.pingCache;if(u===null){u=n.pingCache=new $5;var b=new Set;u.set(a,b)}else b=u.get(a),b===void 0&&(b=new Set,u.set(a,b));b.has(i)||(Mf=!0,b.add(i),n=q5.bind(null,n,a,i),a.then(n,n))}function q5(n,a,i){var u=n.pingCache;u!==null&&u.delete(a),n.pingedLanes|=n.suspendedLanes&i,n.warmLanes&=~i,gn===n&&(Ht&i)===i&&(Dn===4||Dn===3&&(Ht&62914560)===Ht&&300>xt()-Ec?(nn&2)===0&&Dl(n,0):Df|=i,_l===Ht&&(_l=0)),ms(n)}function m0(n,a){a===0&&(a=de()),n=za(n,a),n!==null&&(Le(n,a),ms(n))}function F5(n){var a=n.memoizedState,i=0;a!==null&&(i=a.retryLane),m0(n,i)}function V5(n,a){var i=0;switch(n.tag){case 31:case 13:var u=n.stateNode,b=n.memoizedState;b!==null&&(i=b.retryLane);break;case 19:u=n.stateNode;break;case 22:u=n.stateNode._retryCache;break;default:throw Error(l(314))}u!==null&&u.delete(a),m0(n,i)}function Y5(n,a){return wt(n,a)}var Rc=null,Rl=null,Hf=!1,Lc=!1,Pf=!1,ma=0;function ms(n){n!==Rl&&n.next===null&&(Rl===null?Rc=Rl=n:Rl=Rl.next=n),Lc=!0,Hf||(Hf=!0,X5())}function Bi(n,a){if(!Pf&&Lc){Pf=!0;do for(var i=!1,u=Rc;u!==null;){if(n!==0){var b=u.pendingLanes;if(b===0)var j=0;else{var P=u.suspendedLanes,W=u.pingedLanes;j=(1<<31-yt(42|n)+1)-1,j&=b&~(P&~W),j=j&201326741?j&201326741|1:j?j|2:0}j!==0&&(i=!0,b0(u,j))}else j=Ht,j=Wt(u,u===gn?j:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(j&3)===0||en(u,j)||(i=!0,b0(u,j));u=u.next}while(i);Pf=!1}}function G5(){x0()}function x0(){Lc=Hf=!1;var n=0;ma!==0&&s2()&&(n=ma);for(var a=xt(),i=null,u=Rc;u!==null;){var b=u.next,j=g0(u,a);j===0?(u.next=null,i===null?Rc=b:i.next=b,b===null&&(Rl=i)):(i=u,(n!==0||(j&3)!==0)&&(Lc=!0)),u=b}Vn!==0&&Vn!==5||Bi(n),ma!==0&&(ma=0)}function g0(n,a){for(var i=n.suspendedLanes,u=n.pingedLanes,b=n.expirationTimes,j=n.pendingLanes&-62914561;0<j;){var P=31-yt(j),W=1<<P,le=b[P];le===-1?((W&i)===0||(W&u)!==0)&&(b[P]=Ct(W,a)):le<=a&&(n.expiredLanes|=W),j&=~W}if(a=gn,i=Ht,i=Wt(n,n===a?i:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),u=n.callbackNode,i===0||n===a&&(ln===2||ln===9)||n.cancelPendingCommit!==null)return u!==null&&u!==null&&ae(u),n.callbackNode=null,n.callbackPriority=0;if((i&3)===0||en(n,i)){if(a=i&-i,a===n.callbackPriority)return a;switch(u!==null&&ae(u),gt(i)){case 2:case 8:i=Re;break;case 32:i=qe;break;case 268435456:i=nt;break;default:i=qe}return u=p0.bind(null,n),i=wt(i,u),n.callbackPriority=a,n.callbackNode=i,a}return u!==null&&u!==null&&ae(u),n.callbackPriority=2,n.callbackNode=null,2}function p0(n,a){if(Vn!==0&&Vn!==5)return n.callbackNode=null,n.callbackPriority=0,null;var i=n.callbackNode;if(Oc()&&n.callbackNode!==i)return null;var u=Ht;return u=Wt(n,n===gn?u:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),u===0?null:(Jp(n,u,a),g0(n,xt()),n.callbackNode!=null&&n.callbackNode===i?p0.bind(null,n):null)}function b0(n,a){if(Oc())return null;Jp(n,a,!0)}function X5(){l2(function(){(nn&6)!==0?wt(we,G5):x0()})}function Uf(){if(ma===0){var n=yl;n===0&&(n=Pe,Pe<<=1,(Pe&261888)===0&&(Pe=256)),ma=n}return ma}function y0(n){return n==null||typeof n=="symbol"||typeof n=="boolean"?null:typeof n=="function"?n:Gt(""+n)}function v0(n,a){var i=a.ownerDocument.createElement("input");return i.name=a.name,i.value=a.value,n.id&&i.setAttribute("form",n.id),a.parentNode.insertBefore(i,a),n=new FormData(n),i.parentNode.removeChild(i),n}function Z5(n,a,i,u,b){if(a==="submit"&&i&&i.stateNode===b){var j=y0((b[un]||null).action),P=u.submitter;P&&(a=(a=P[un]||null)?y0(a.formAction):P.getAttribute("formAction"),a!==null&&(j=a,P=null));var W=new Go("action","action",null,u,b);n.push({event:W,listeners:[{instance:null,listener:function(){if(u.defaultPrevented){if(ma!==0){var le=P?v0(b,P):new FormData(b);of(i,{pending:!0,data:le,method:b.method,action:j},null,le)}}else typeof j=="function"&&(W.preventDefault(),le=P?v0(b,P):new FormData(b),of(i,{pending:!0,data:le,method:b.method,action:j},j,le))},currentTarget:b}]})}}for(var qf=0;qf<ku.length;qf++){var Ff=ku[qf],Q5=Ff.toLowerCase(),K5=Ff[0].toUpperCase()+Ff.slice(1);Jr(Q5,"on"+K5)}Jr(Kx,"onAnimationEnd"),Jr(Jx,"onAnimationIteration"),Jr(Wx,"onAnimationStart"),Jr("dblclick","onDoubleClick"),Jr("focusin","onFocus"),Jr("focusout","onBlur"),Jr(h5,"onTransitionRun"),Jr(m5,"onTransitionStart"),Jr(x5,"onTransitionCancel"),Jr(eg,"onTransitionEnd"),rr("onMouseEnter",["mouseout","mouseover"]),rr("onMouseLeave",["mouseout","mouseover"]),rr("onPointerEnter",["pointerout","pointerover"]),rr("onPointerLeave",["pointerout","pointerover"]),nr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),nr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),nr("onBeforeInput",["compositionend","keypress","textInput","paste"]),nr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),nr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),nr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Hi="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(" "),J5=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Hi));function j0(n,a){a=(a&4)!==0;for(var i=0;i<n.length;i++){var u=n[i],b=u.event;u=u.listeners;e:{var j=void 0;if(a)for(var P=u.length-1;0<=P;P--){var W=u[P],le=W.instance,be=W.currentTarget;if(W=W.listener,le!==j&&b.isPropagationStopped())break e;j=W,b.currentTarget=be;try{j(b)}catch(Ee){Qo(Ee)}b.currentTarget=null,j=le}else for(P=0;P<u.length;P++){if(W=u[P],le=W.instance,be=W.currentTarget,W=W.listener,le!==j&&b.isPropagationStopped())break e;j=W,b.currentTarget=be;try{j(b)}catch(Ee){Qo(Ee)}b.currentTarget=null,j=le}}}}function $t(n,a){var i=a[fe];i===void 0&&(i=a[fe]=new Set);var u=n+"__bubble";i.has(u)||(w0(a,n,2,!1),i.add(u))}function Vf(n,a,i){var u=0;a&&(u|=4),w0(i,n,u,a)}var zc="_reactListening"+Math.random().toString(36).slice(2);function Yf(n){if(!n[zc]){n[zc]=!0,os.forEach(function(i){i!=="selectionchange"&&(J5.has(i)||Vf(i,!1,n),Vf(i,!0,n))});var a=n.nodeType===9?n:n.ownerDocument;a===null||a[zc]||(a[zc]=!0,Vf("selectionchange",!1,a))}}function w0(n,a,i,u){switch(K0(a)){case 2:var b=C2;break;case 8:b=E2;break;default:b=ih}i=b.bind(null,a,i,n),b=void 0,!sr||a!=="touchstart"&&a!=="touchmove"&&a!=="wheel"||(b=!0),u?b!==void 0?n.addEventListener(a,i,{capture:!0,passive:b}):n.addEventListener(a,i,!0):b!==void 0?n.addEventListener(a,i,{passive:b}):n.addEventListener(a,i,!1)}function Gf(n,a,i,u,b){var j=u;if((a&1)===0&&(a&2)===0&&u!==null)e:for(;;){if(u===null)return;var P=u.tag;if(P===3||P===4){var W=u.stateNode.containerInfo;if(W===b)break;if(P===4)for(P=u.return;P!==null;){var le=P.tag;if((le===3||le===4)&&P.stateNode.containerInfo===b)return;P=P.return}for(;W!==null;){if(P=hr(W),P===null)return;if(le=P.tag,le===5||le===6||le===26||le===27){u=j=P;continue e}W=W.parentNode}}u=u.return}st(function(){var be=j,Ee=at(i),_e=[];e:{var ve=tg.get(n);if(ve!==void 0){var Ne=Go,We=n;switch(n){case"keypress":if(Vo(i)===0)break e;case"keydown":case"keyup":Ne=VN;break;case"focusin":We="focus",Ne=xu;break;case"focusout":We="blur",Ne=xu;break;case"beforeblur":case"afterblur":Ne=xu;break;case"click":if(i.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ne=_x;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ne=ON;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ne=XN;break;case Kx:case Jx:case Wx:Ne=zN;break;case eg:Ne=QN;break;case"scroll":case"scrollend":Ne=MN;break;case"wheel":Ne=JN;break;case"copy":case"cut":case"paste":Ne=$N;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ne=Dx;break;case"toggle":case"beforetoggle":Ne=e5}var pt=(a&4)!==0,xn=!pt&&(n==="scroll"||n==="scrollend"),ue=pt?ve!==null?ve+"Capture":null:ve;pt=[];for(var ce=be,pe;ce!==null;){var Ae=ce;if(pe=Ae.stateNode,Ae=Ae.tag,Ae!==5&&Ae!==26&&Ae!==27||pe===null||ue===null||(Ae=Ge(ce,ue),Ae!=null&&pt.push(Pi(ce,Ae,pe))),xn)break;ce=ce.return}0<pt.length&&(ve=new Ne(ve,We,null,i,Ee),_e.push({event:ve,listeners:pt}))}}if((a&7)===0){e:{if(ve=n==="mouseover"||n==="pointerover",Ne=n==="mouseout"||n==="pointerout",ve&&i!==_n&&(We=i.relatedTarget||i.fromElement)&&(hr(We)||We[En]))break e;if((Ne||ve)&&(ve=Ee.window===Ee?Ee:(ve=Ee.ownerDocument)?ve.defaultView||ve.parentWindow:window,Ne?(We=i.relatedTarget||i.toElement,Ne=be,We=We?hr(We):null,We!==null&&(xn=d(We),pt=We.tag,We!==xn||pt!==5&&pt!==27&&pt!==6)&&(We=null)):(Ne=null,We=be),Ne!==We)){if(pt=_x,Ae="onMouseLeave",ue="onMouseEnter",ce="mouse",(n==="pointerout"||n==="pointerover")&&(pt=Dx,Ae="onPointerLeave",ue="onPointerEnter",ce="pointer"),xn=Ne==null?ve:tr(Ne),pe=We==null?ve:tr(We),ve=new pt(Ae,ce+"leave",Ne,i,Ee),ve.target=xn,ve.relatedTarget=pe,Ae=null,hr(Ee)===be&&(pt=new pt(ue,ce+"enter",We,i,Ee),pt.target=pe,pt.relatedTarget=xn,Ae=pt),xn=Ae,Ne&&We)t:{for(pt=W5,ue=Ne,ce=We,pe=0,Ae=ue;Ae;Ae=pt(Ae))pe++;Ae=0;for(var ct=ce;ct;ct=pt(ct))Ae++;for(;0<pe-Ae;)ue=pt(ue),pe--;for(;0<Ae-pe;)ce=pt(ce),Ae--;for(;pe--;){if(ue===ce||ce!==null&&ue===ce.alternate){pt=ue;break t}ue=pt(ue),ce=pt(ce)}pt=null}else pt=null;Ne!==null&&N0(_e,ve,Ne,pt,!1),We!==null&&xn!==null&&N0(_e,xn,We,pt,!0)}}e:{if(ve=be?tr(be):window,Ne=ve.nodeName&&ve.nodeName.toLowerCase(),Ne==="select"||Ne==="input"&&ve.type==="file")var Kt=Hx;else if($x(ve))if(Px)Kt=d5;else{Kt=o5;var rt=i5}else Ne=ve.nodeName,!Ne||Ne.toLowerCase()!=="input"||ve.type!=="checkbox"&&ve.type!=="radio"?be&&Ve(be.elementType)&&(Kt=Hx):Kt=c5;if(Kt&&(Kt=Kt(n,be))){Bx(_e,Kt,i,Ee);break e}rt&&rt(n,ve,be),n==="focusout"&&be&&ve.type==="number"&&be.memoizedProps.value!=null&&Kr(ve,"number",ve.value)}switch(rt=be?tr(be):window,n){case"focusin":($x(rt)||rt.contentEditable==="true")&&(ul=rt,ju=be,gi=null);break;case"focusout":gi=ju=ul=null;break;case"mousedown":wu=!0;break;case"contextmenu":case"mouseup":case"dragend":wu=!1,Zx(_e,i,Ee);break;case"selectionchange":if(f5)break;case"keydown":case"keyup":Zx(_e,i,Ee)}var Ot;if(pu)e:{switch(n){case"compositionstart":var Pt="onCompositionStart";break e;case"compositionend":Pt="onCompositionEnd";break e;case"compositionupdate":Pt="onCompositionUpdate";break e}Pt=void 0}else dl?zx(n,i)&&(Pt="onCompositionEnd"):n==="keydown"&&i.keyCode===229&&(Pt="onCompositionStart");Pt&&(Ox&&i.locale!=="ko"&&(dl||Pt!=="onCompositionStart"?Pt==="onCompositionEnd"&&dl&&(Ot=Tx()):(ds=Ee,fu="value"in ds?ds.value:ds.textContent,dl=!0)),rt=Ic(be,Pt),0<rt.length&&(Pt=new Mx(Pt,n,null,i,Ee),_e.push({event:Pt,listeners:rt}),Ot?Pt.data=Ot:(Ot=Ix(i),Ot!==null&&(Pt.data=Ot)))),(Ot=n5?r5(n,i):s5(n,i))&&(Pt=Ic(be,"onBeforeInput"),0<Pt.length&&(rt=new Mx("onBeforeInput","beforeinput",null,i,Ee),_e.push({event:rt,listeners:Pt}),rt.data=Ot)),Z5(_e,n,be,i,Ee)}j0(_e,a)})}function Pi(n,a,i){return{instance:n,listener:a,currentTarget:i}}function Ic(n,a){for(var i=a+"Capture",u=[];n!==null;){var b=n,j=b.stateNode;if(b=b.tag,b!==5&&b!==26&&b!==27||j===null||(b=Ge(n,i),b!=null&&u.unshift(Pi(n,b,j)),b=Ge(n,a),b!=null&&u.push(Pi(n,b,j))),n.tag===3)return u;n=n.return}return[]}function W5(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5&&n.tag!==27);return n||null}function N0(n,a,i,u,b){for(var j=a._reactName,P=[];i!==null&&i!==u;){var W=i,le=W.alternate,be=W.stateNode;if(W=W.tag,le!==null&&le===u)break;W!==5&&W!==26&&W!==27||be===null||(le=be,b?(be=Ge(i,j),be!=null&&P.unshift(Pi(i,be,le))):b||(be=Ge(i,j),be!=null&&P.push(Pi(i,be,le)))),i=i.return}P.length!==0&&n.push({event:a,listeners:P})}var e2=/\r\n?/g,t2=/\u0000|\uFFFD/g;function k0(n){return(typeof n=="string"?n:""+n).replace(e2,`
|
|
9
|
+
`).replace(t2,"")}function S0(n,a){return a=k0(a),k0(n)===a}function mn(n,a,i,u,b,j){switch(i){case"children":typeof u=="string"?a==="body"||a==="textarea"&&u===""||me(n,u):(typeof u=="number"||typeof u=="bigint")&&a!=="body"&&me(n,""+u);break;case"className":Gn(n,"class",u);break;case"tabIndex":Gn(n,"tabindex",u);break;case"dir":case"role":case"viewBox":case"width":case"height":Gn(n,i,u);break;case"style":Ue(n,u,j);break;case"data":if(a!=="object"){Gn(n,"data",u);break}case"src":case"href":if(u===""&&(a!=="a"||i!=="href")){n.removeAttribute(i);break}if(u==null||typeof u=="function"||typeof u=="symbol"||typeof u=="boolean"){n.removeAttribute(i);break}u=Gt(""+u),n.setAttribute(i,u);break;case"action":case"formAction":if(typeof u=="function"){n.setAttribute(i,"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 j=="function"&&(i==="formAction"?(a!=="input"&&mn(n,a,"name",b.name,b,null),mn(n,a,"formEncType",b.formEncType,b,null),mn(n,a,"formMethod",b.formMethod,b,null),mn(n,a,"formTarget",b.formTarget,b,null)):(mn(n,a,"encType",b.encType,b,null),mn(n,a,"method",b.method,b,null),mn(n,a,"target",b.target,b,null)));if(u==null||typeof u=="symbol"||typeof u=="boolean"){n.removeAttribute(i);break}u=Gt(""+u),n.setAttribute(i,u);break;case"onClick":u!=null&&(n.onclick=Dt);break;case"onScroll":u!=null&&$t("scroll",n);break;case"onScrollEnd":u!=null&&$t("scrollend",n);break;case"dangerouslySetInnerHTML":if(u!=null){if(typeof u!="object"||!("__html"in u))throw Error(l(61));if(i=u.__html,i!=null){if(b.children!=null)throw Error(l(60));n.innerHTML=i}}break;case"multiple":n.multiple=u&&typeof u!="function"&&typeof u!="symbol";break;case"muted":n.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"){n.removeAttribute("xlink:href");break}i=Gt(""+u),n.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",i);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"?n.setAttribute(i,""+u):n.removeAttribute(i);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"?n.setAttribute(i,""):n.removeAttribute(i);break;case"capture":case"download":u===!0?n.setAttribute(i,""):u!==!1&&u!=null&&typeof u!="function"&&typeof u!="symbol"?n.setAttribute(i,u):n.removeAttribute(i);break;case"cols":case"rows":case"size":case"span":u!=null&&typeof u!="function"&&typeof u!="symbol"&&!isNaN(u)&&1<=u?n.setAttribute(i,u):n.removeAttribute(i);break;case"rowSpan":case"start":u==null||typeof u=="function"||typeof u=="symbol"||isNaN(u)?n.removeAttribute(i):n.setAttribute(i,u);break;case"popover":$t("beforetoggle",n),$t("toggle",n),Mt(n,"popover",u);break;case"xlinkActuate":On(n,"http://www.w3.org/1999/xlink","xlink:actuate",u);break;case"xlinkArcrole":On(n,"http://www.w3.org/1999/xlink","xlink:arcrole",u);break;case"xlinkRole":On(n,"http://www.w3.org/1999/xlink","xlink:role",u);break;case"xlinkShow":On(n,"http://www.w3.org/1999/xlink","xlink:show",u);break;case"xlinkTitle":On(n,"http://www.w3.org/1999/xlink","xlink:title",u);break;case"xlinkType":On(n,"http://www.w3.org/1999/xlink","xlink:type",u);break;case"xmlBase":On(n,"http://www.w3.org/XML/1998/namespace","xml:base",u);break;case"xmlLang":On(n,"http://www.w3.org/XML/1998/namespace","xml:lang",u);break;case"xmlSpace":On(n,"http://www.w3.org/XML/1998/namespace","xml:space",u);break;case"is":Mt(n,"is",u);break;case"innerText":case"textContent":break;default:(!(2<i.length)||i[0]!=="o"&&i[0]!=="O"||i[1]!=="n"&&i[1]!=="N")&&(i=Oe.get(i)||i,Mt(n,i,u))}}function Xf(n,a,i,u,b,j){switch(i){case"style":Ue(n,u,j);break;case"dangerouslySetInnerHTML":if(u!=null){if(typeof u!="object"||!("__html"in u))throw Error(l(61));if(i=u.__html,i!=null){if(b.children!=null)throw Error(l(60));n.innerHTML=i}}break;case"children":typeof u=="string"?me(n,u):(typeof u=="number"||typeof u=="bigint")&&me(n,""+u);break;case"onScroll":u!=null&&$t("scroll",n);break;case"onScrollEnd":u!=null&&$t("scrollend",n);break;case"onClick":u!=null&&(n.onclick=Dt);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Sr.hasOwnProperty(i))e:{if(i[0]==="o"&&i[1]==="n"&&(b=i.endsWith("Capture"),a=i.slice(2,b?i.length-7:void 0),j=n[un]||null,j=j!=null?j[i]:null,typeof j=="function"&&n.removeEventListener(a,j,b),typeof u=="function")){typeof j!="function"&&j!==null&&(i in n?n[i]=null:n.hasAttribute(i)&&n.removeAttribute(i)),n.addEventListener(a,u,b);break e}i in n?n[i]=u:u===!0?n.setAttribute(i,""):Mt(n,i,u)}}}function er(n,a,i){switch(a){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":$t("error",n),$t("load",n);var u=!1,b=!1,j;for(j in i)if(i.hasOwnProperty(j)){var P=i[j];if(P!=null)switch(j){case"src":u=!0;break;case"srcSet":b=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(l(137,a));default:mn(n,a,j,P,i,null)}}b&&mn(n,a,"srcSet",i.srcSet,i,null),u&&mn(n,a,"src",i.src,i,null);return;case"input":$t("invalid",n);var W=j=P=b=null,le=null,be=null;for(u in i)if(i.hasOwnProperty(u)){var Ee=i[u];if(Ee!=null)switch(u){case"name":b=Ee;break;case"type":P=Ee;break;case"checked":le=Ee;break;case"defaultChecked":be=Ee;break;case"value":j=Ee;break;case"defaultValue":W=Ee;break;case"children":case"dangerouslySetInnerHTML":if(Ee!=null)throw Error(l(137,a));break;default:mn(n,a,u,Ee,i,null)}}cs(n,j,W,le,be,P,b,!1);return;case"select":$t("invalid",n),u=P=j=null;for(b in i)if(i.hasOwnProperty(b)&&(W=i[b],W!=null))switch(b){case"value":j=W;break;case"defaultValue":P=W;break;case"multiple":u=W;default:mn(n,a,b,W,i,null)}a=j,i=P,n.multiple=!!u,a!=null?ne(n,!!u,a,!1):i!=null&&ne(n,!!u,i,!0);return;case"textarea":$t("invalid",n),j=b=u=null;for(P in i)if(i.hasOwnProperty(P)&&(W=i[P],W!=null))switch(P){case"value":u=W;break;case"defaultValue":b=W;break;case"children":j=W;break;case"dangerouslySetInnerHTML":if(W!=null)throw Error(l(91));break;default:mn(n,a,P,W,i,null)}oe(n,u,b,j);return;case"option":for(le in i)i.hasOwnProperty(le)&&(u=i[le],u!=null)&&(le==="selected"?n.selected=u&&typeof u!="function"&&typeof u!="symbol":mn(n,a,le,u,i,null));return;case"dialog":$t("beforetoggle",n),$t("toggle",n),$t("cancel",n),$t("close",n);break;case"iframe":case"object":$t("load",n);break;case"video":case"audio":for(u=0;u<Hi.length;u++)$t(Hi[u],n);break;case"image":$t("error",n),$t("load",n);break;case"details":$t("toggle",n);break;case"embed":case"source":case"link":$t("error",n),$t("load",n);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(be in i)if(i.hasOwnProperty(be)&&(u=i[be],u!=null))switch(be){case"children":case"dangerouslySetInnerHTML":throw Error(l(137,a));default:mn(n,a,be,u,i,null)}return;default:if(Ve(a)){for(Ee in i)i.hasOwnProperty(Ee)&&(u=i[Ee],u!==void 0&&Xf(n,a,Ee,u,i,void 0));return}}for(W in i)i.hasOwnProperty(W)&&(u=i[W],u!=null&&mn(n,a,W,u,i,null))}function n2(n,a,i,u){switch(a){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var b=null,j=null,P=null,W=null,le=null,be=null,Ee=null;for(Ne in i){var _e=i[Ne];if(i.hasOwnProperty(Ne)&&_e!=null)switch(Ne){case"checked":break;case"value":break;case"defaultValue":le=_e;default:u.hasOwnProperty(Ne)||mn(n,a,Ne,null,u,_e)}}for(var ve in u){var Ne=u[ve];if(_e=i[ve],u.hasOwnProperty(ve)&&(Ne!=null||_e!=null))switch(ve){case"type":j=Ne;break;case"name":b=Ne;break;case"checked":be=Ne;break;case"defaultChecked":Ee=Ne;break;case"value":P=Ne;break;case"defaultValue":W=Ne;break;case"children":case"dangerouslySetInnerHTML":if(Ne!=null)throw Error(l(137,a));break;default:Ne!==_e&&mn(n,a,ve,Ne,u,_e)}}Tr(n,P,W,le,be,Ee,j,b);return;case"select":Ne=P=W=ve=null;for(j in i)if(le=i[j],i.hasOwnProperty(j)&&le!=null)switch(j){case"value":break;case"multiple":Ne=le;default:u.hasOwnProperty(j)||mn(n,a,j,null,u,le)}for(b in u)if(j=u[b],le=i[b],u.hasOwnProperty(b)&&(j!=null||le!=null))switch(b){case"value":ve=j;break;case"defaultValue":W=j;break;case"multiple":P=j;default:j!==le&&mn(n,a,b,j,u,le)}a=W,i=P,u=Ne,ve!=null?ne(n,!!i,ve,!1):!!u!=!!i&&(a!=null?ne(n,!!i,a,!0):ne(n,!!i,i?[]:"",!1));return;case"textarea":Ne=ve=null;for(W in i)if(b=i[W],i.hasOwnProperty(W)&&b!=null&&!u.hasOwnProperty(W))switch(W){case"value":break;case"children":break;default:mn(n,a,W,null,u,b)}for(P in u)if(b=u[P],j=i[P],u.hasOwnProperty(P)&&(b!=null||j!=null))switch(P){case"value":ve=b;break;case"defaultValue":Ne=b;break;case"children":break;case"dangerouslySetInnerHTML":if(b!=null)throw Error(l(91));break;default:b!==j&&mn(n,a,P,b,u,j)}Z(n,ve,Ne);return;case"option":for(var We in i)ve=i[We],i.hasOwnProperty(We)&&ve!=null&&!u.hasOwnProperty(We)&&(We==="selected"?n.selected=!1:mn(n,a,We,null,u,ve));for(le in u)ve=u[le],Ne=i[le],u.hasOwnProperty(le)&&ve!==Ne&&(ve!=null||Ne!=null)&&(le==="selected"?n.selected=ve&&typeof ve!="function"&&typeof ve!="symbol":mn(n,a,le,ve,u,Ne));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 pt in i)ve=i[pt],i.hasOwnProperty(pt)&&ve!=null&&!u.hasOwnProperty(pt)&&mn(n,a,pt,null,u,ve);for(be in u)if(ve=u[be],Ne=i[be],u.hasOwnProperty(be)&&ve!==Ne&&(ve!=null||Ne!=null))switch(be){case"children":case"dangerouslySetInnerHTML":if(ve!=null)throw Error(l(137,a));break;default:mn(n,a,be,ve,u,Ne)}return;default:if(Ve(a)){for(var xn in i)ve=i[xn],i.hasOwnProperty(xn)&&ve!==void 0&&!u.hasOwnProperty(xn)&&Xf(n,a,xn,void 0,u,ve);for(Ee in u)ve=u[Ee],Ne=i[Ee],!u.hasOwnProperty(Ee)||ve===Ne||ve===void 0&&Ne===void 0||Xf(n,a,Ee,ve,u,Ne);return}}for(var ue in i)ve=i[ue],i.hasOwnProperty(ue)&&ve!=null&&!u.hasOwnProperty(ue)&&mn(n,a,ue,null,u,ve);for(_e in u)ve=u[_e],Ne=i[_e],!u.hasOwnProperty(_e)||ve===Ne||ve==null&&Ne==null||mn(n,a,_e,ve,u,Ne)}function C0(n){switch(n){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function r2(){if(typeof performance.getEntriesByType=="function"){for(var n=0,a=0,i=performance.getEntriesByType("resource"),u=0;u<i.length;u++){var b=i[u],j=b.transferSize,P=b.initiatorType,W=b.duration;if(j&&W&&C0(P)){for(P=0,W=b.responseEnd,u+=1;u<i.length;u++){var le=i[u],be=le.startTime;if(be>W)break;var Ee=le.transferSize,_e=le.initiatorType;Ee&&C0(_e)&&(le=le.responseEnd,P+=Ee*(le<W?1:(W-be)/(le-be)))}if(--u,a+=8*(j+P)/(b.duration/1e3),n++,10<n)break}}if(0<n)return a/n/1e6}return navigator.connection&&(n=navigator.connection.downlink,typeof n=="number")?n:5}var Zf=null,Qf=null;function $c(n){return n.nodeType===9?n:n.ownerDocument}function E0(n){switch(n){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function T0(n,a){if(n===0)switch(a){case"svg":return 1;case"math":return 2;default:return 0}return n===1&&a==="foreignObject"?0:n}function Kf(n,a){return n==="textarea"||n==="noscript"||typeof a.children=="string"||typeof a.children=="number"||typeof a.children=="bigint"||typeof a.dangerouslySetInnerHTML=="object"&&a.dangerouslySetInnerHTML!==null&&a.dangerouslySetInnerHTML.__html!=null}var Jf=null;function s2(){var n=window.event;return n&&n.type==="popstate"?n===Jf?!1:(Jf=n,!0):(Jf=null,!1)}var A0=typeof setTimeout=="function"?setTimeout:void 0,a2=typeof clearTimeout=="function"?clearTimeout:void 0,_0=typeof Promise=="function"?Promise:void 0,l2=typeof queueMicrotask=="function"?queueMicrotask:typeof _0<"u"?function(n){return _0.resolve(null).then(n).catch(i2)}:A0;function i2(n){setTimeout(function(){throw n})}function xa(n){return n==="head"}function M0(n,a){var i=a,u=0;do{var b=i.nextSibling;if(n.removeChild(i),b&&b.nodeType===8)if(i=b.data,i==="/$"||i==="/&"){if(u===0){n.removeChild(b),$l(a);return}u--}else if(i==="$"||i==="$?"||i==="$~"||i==="$!"||i==="&")u++;else if(i==="html")Ui(n.ownerDocument.documentElement);else if(i==="head"){i=n.ownerDocument.head,Ui(i);for(var j=i.firstChild;j;){var P=j.nextSibling,W=j.nodeName;j[Tn]||W==="SCRIPT"||W==="STYLE"||W==="LINK"&&j.rel.toLowerCase()==="stylesheet"||i.removeChild(j),j=P}}else i==="body"&&Ui(n.ownerDocument.body);i=b}while(i);$l(a)}function D0(n,a){var i=n;n=0;do{var u=i.nextSibling;if(i.nodeType===1?a?(i._stashedDisplay=i.style.display,i.style.display="none"):(i.style.display=i._stashedDisplay||"",i.getAttribute("style")===""&&i.removeAttribute("style")):i.nodeType===3&&(a?(i._stashedText=i.nodeValue,i.nodeValue=""):i.nodeValue=i._stashedText||""),u&&u.nodeType===8)if(i=u.data,i==="/$"){if(n===0)break;n--}else i!=="$"&&i!=="$?"&&i!=="$~"&&i!=="$!"||n++;i=u}while(i)}function Wf(n){var a=n.firstChild;for(a&&a.nodeType===10&&(a=a.nextSibling);a;){var i=a;switch(a=a.nextSibling,i.nodeName){case"HTML":case"HEAD":case"BODY":Wf(i),Qn(i);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(i.rel.toLowerCase()==="stylesheet")continue}n.removeChild(i)}}function o2(n,a,i,u){for(;n.nodeType===1;){var b=i;if(n.nodeName.toLowerCase()!==a.toLowerCase()){if(!u&&(n.nodeName!=="INPUT"||n.type!=="hidden"))break}else if(u){if(!n[Tn])switch(a){case"meta":if(!n.hasAttribute("itemprop"))break;return n;case"link":if(j=n.getAttribute("rel"),j==="stylesheet"&&n.hasAttribute("data-precedence"))break;if(j!==b.rel||n.getAttribute("href")!==(b.href==null||b.href===""?null:b.href)||n.getAttribute("crossorigin")!==(b.crossOrigin==null?null:b.crossOrigin)||n.getAttribute("title")!==(b.title==null?null:b.title))break;return n;case"style":if(n.hasAttribute("data-precedence"))break;return n;case"script":if(j=n.getAttribute("src"),(j!==(b.src==null?null:b.src)||n.getAttribute("type")!==(b.type==null?null:b.type)||n.getAttribute("crossorigin")!==(b.crossOrigin==null?null:b.crossOrigin))&&j&&n.hasAttribute("async")&&!n.hasAttribute("itemprop"))break;return n;default:return n}}else if(a==="input"&&n.type==="hidden"){var j=b.name==null?null:""+b.name;if(b.type==="hidden"&&n.getAttribute("name")===j)return n}else return n;if(n=Gr(n.nextSibling),n===null)break}return null}function c2(n,a,i){if(a==="")return null;for(;n.nodeType!==3;)if((n.nodeType!==1||n.nodeName!=="INPUT"||n.type!=="hidden")&&!i||(n=Gr(n.nextSibling),n===null))return null;return n}function O0(n,a){for(;n.nodeType!==8;)if((n.nodeType!==1||n.nodeName!=="INPUT"||n.type!=="hidden")&&!a||(n=Gr(n.nextSibling),n===null))return null;return n}function eh(n){return n.data==="$?"||n.data==="$~"}function th(n){return n.data==="$!"||n.data==="$?"&&n.ownerDocument.readyState!=="loading"}function d2(n,a){var i=n.ownerDocument;if(n.data==="$~")n._reactRetry=a;else if(n.data!=="$?"||i.readyState!=="loading")a();else{var u=function(){a(),i.removeEventListener("DOMContentLoaded",u)};i.addEventListener("DOMContentLoaded",u),n._reactRetry=u}}function Gr(n){for(;n!=null;n=n.nextSibling){var a=n.nodeType;if(a===1||a===3)break;if(a===8){if(a=n.data,a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"||a==="F!"||a==="F")break;if(a==="/$"||a==="/&")return null}}return n}var nh=null;function R0(n){n=n.nextSibling;for(var a=0;n;){if(n.nodeType===8){var i=n.data;if(i==="/$"||i==="/&"){if(a===0)return Gr(n.nextSibling);a--}else i!=="$"&&i!=="$!"&&i!=="$?"&&i!=="$~"&&i!=="&"||a++}n=n.nextSibling}return null}function L0(n){n=n.previousSibling;for(var a=0;n;){if(n.nodeType===8){var i=n.data;if(i==="$"||i==="$!"||i==="$?"||i==="$~"||i==="&"){if(a===0)return n;a--}else i!=="/$"&&i!=="/&"||a++}n=n.previousSibling}return null}function z0(n,a,i){switch(a=$c(i),n){case"html":if(n=a.documentElement,!n)throw Error(l(452));return n;case"head":if(n=a.head,!n)throw Error(l(453));return n;case"body":if(n=a.body,!n)throw Error(l(454));return n;default:throw Error(l(451))}}function Ui(n){for(var a=n.attributes;a.length;)n.removeAttributeNode(a[0]);Qn(n)}var Xr=new Map,I0=new Set;function Bc(n){return typeof n.getRootNode=="function"?n.getRootNode():n.nodeType===9?n:n.ownerDocument}var Us=Y.d;Y.d={f:u2,r:f2,D:h2,C:m2,L:x2,m:g2,X:b2,S:p2,M:y2};function u2(){var n=Us.f(),a=_c();return n||a}function f2(n){var a=or(n);a!==null&&a.tag===5&&a.type==="form"?ep(a):Us.r(n)}var Ll=typeof document>"u"?null:document;function $0(n,a,i){var u=Ll;if(u&&typeof a=="string"&&a){var b=An(a);b='link[rel="'+n+'"][href="'+b+'"]',typeof i=="string"&&(b+='[crossorigin="'+i+'"]'),I0.has(b)||(I0.add(b),n={rel:n,crossOrigin:i,href:a},u.querySelector(b)===null&&(a=u.createElement("link"),er(a,"link",n),fn(a),u.head.appendChild(a)))}}function h2(n){Us.D(n),$0("dns-prefetch",n,null)}function m2(n,a){Us.C(n,a),$0("preconnect",n,a)}function x2(n,a,i){Us.L(n,a,i);var u=Ll;if(u&&n&&a){var b='link[rel="preload"][as="'+An(a)+'"]';a==="image"&&i&&i.imageSrcSet?(b+='[imagesrcset="'+An(i.imageSrcSet)+'"]',typeof i.imageSizes=="string"&&(b+='[imagesizes="'+An(i.imageSizes)+'"]')):b+='[href="'+An(n)+'"]';var j=b;switch(a){case"style":j=zl(n);break;case"script":j=Il(n)}Xr.has(j)||(n=g({rel:"preload",href:a==="image"&&i&&i.imageSrcSet?void 0:n,as:a},i),Xr.set(j,n),u.querySelector(b)!==null||a==="style"&&u.querySelector(qi(j))||a==="script"&&u.querySelector(Fi(j))||(a=u.createElement("link"),er(a,"link",n),fn(a),u.head.appendChild(a)))}}function g2(n,a){Us.m(n,a);var i=Ll;if(i&&n){var u=a&&typeof a.as=="string"?a.as:"script",b='link[rel="modulepreload"][as="'+An(u)+'"][href="'+An(n)+'"]',j=b;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":j=Il(n)}if(!Xr.has(j)&&(n=g({rel:"modulepreload",href:n},a),Xr.set(j,n),i.querySelector(b)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(i.querySelector(Fi(j)))return}u=i.createElement("link"),er(u,"link",n),fn(u),i.head.appendChild(u)}}}function p2(n,a,i){Us.S(n,a,i);var u=Ll;if(u&&n){var b=cr(u).hoistableStyles,j=zl(n);a=a||"default";var P=b.get(j);if(!P){var W={loading:0,preload:null};if(P=u.querySelector(qi(j)))W.loading=5;else{n=g({rel:"stylesheet",href:n,"data-precedence":a},i),(i=Xr.get(j))&&rh(n,i);var le=P=u.createElement("link");fn(le),er(le,"link",n),le._p=new Promise(function(be,Ee){le.onload=be,le.onerror=Ee}),le.addEventListener("load",function(){W.loading|=1}),le.addEventListener("error",function(){W.loading|=2}),W.loading|=4,Hc(P,a,u)}P={type:"stylesheet",instance:P,count:1,state:W},b.set(j,P)}}}function b2(n,a){Us.X(n,a);var i=Ll;if(i&&n){var u=cr(i).hoistableScripts,b=Il(n),j=u.get(b);j||(j=i.querySelector(Fi(b)),j||(n=g({src:n,async:!0},a),(a=Xr.get(b))&&sh(n,a),j=i.createElement("script"),fn(j),er(j,"link",n),i.head.appendChild(j)),j={type:"script",instance:j,count:1,state:null},u.set(b,j))}}function y2(n,a){Us.M(n,a);var i=Ll;if(i&&n){var u=cr(i).hoistableScripts,b=Il(n),j=u.get(b);j||(j=i.querySelector(Fi(b)),j||(n=g({src:n,async:!0,type:"module"},a),(a=Xr.get(b))&&sh(n,a),j=i.createElement("script"),fn(j),er(j,"link",n),i.head.appendChild(j)),j={type:"script",instance:j,count:1,state:null},u.set(b,j))}}function B0(n,a,i,u){var b=(b=K.current)?Bc(b):null;if(!b)throw Error(l(446));switch(n){case"meta":case"title":return null;case"style":return typeof i.precedence=="string"&&typeof i.href=="string"?(a=zl(i.href),i=cr(b).hoistableStyles,u=i.get(a),u||(u={type:"style",instance:null,count:0,state:null},i.set(a,u)),u):{type:"void",instance:null,count:0,state:null};case"link":if(i.rel==="stylesheet"&&typeof i.href=="string"&&typeof i.precedence=="string"){n=zl(i.href);var j=cr(b).hoistableStyles,P=j.get(n);if(P||(b=b.ownerDocument||b,P={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},j.set(n,P),(j=b.querySelector(qi(n)))&&!j._p&&(P.instance=j,P.state.loading=5),Xr.has(n)||(i={rel:"preload",as:"style",href:i.href,crossOrigin:i.crossOrigin,integrity:i.integrity,media:i.media,hrefLang:i.hrefLang,referrerPolicy:i.referrerPolicy},Xr.set(n,i),j||v2(b,n,i,P.state))),a&&u===null)throw Error(l(528,""));return P}if(a&&u!==null)throw Error(l(529,""));return null;case"script":return a=i.async,i=i.src,typeof i=="string"&&a&&typeof a!="function"&&typeof a!="symbol"?(a=Il(i),i=cr(b).hoistableScripts,u=i.get(a),u||(u={type:"script",instance:null,count:0,state:null},i.set(a,u)),u):{type:"void",instance:null,count:0,state:null};default:throw Error(l(444,n))}}function zl(n){return'href="'+An(n)+'"'}function qi(n){return'link[rel="stylesheet"]['+n+"]"}function H0(n){return g({},n,{"data-precedence":n.precedence,precedence:null})}function v2(n,a,i,u){n.querySelector('link[rel="preload"][as="style"]['+a+"]")?u.loading=1:(a=n.createElement("link"),u.preload=a,a.addEventListener("load",function(){return u.loading|=1}),a.addEventListener("error",function(){return u.loading|=2}),er(a,"link",i),fn(a),n.head.appendChild(a))}function Il(n){return'[src="'+An(n)+'"]'}function Fi(n){return"script[async]"+n}function P0(n,a,i){if(a.count++,a.instance===null)switch(a.type){case"style":var u=n.querySelector('style[data-href~="'+An(i.href)+'"]');if(u)return a.instance=u,fn(u),u;var b=g({},i,{"data-href":i.href,"data-precedence":i.precedence,href:null,precedence:null});return u=(n.ownerDocument||n).createElement("style"),fn(u),er(u,"style",b),Hc(u,i.precedence,n),a.instance=u;case"stylesheet":b=zl(i.href);var j=n.querySelector(qi(b));if(j)return a.state.loading|=4,a.instance=j,fn(j),j;u=H0(i),(b=Xr.get(b))&&rh(u,b),j=(n.ownerDocument||n).createElement("link"),fn(j);var P=j;return P._p=new Promise(function(W,le){P.onload=W,P.onerror=le}),er(j,"link",u),a.state.loading|=4,Hc(j,i.precedence,n),a.instance=j;case"script":return j=Il(i.src),(b=n.querySelector(Fi(j)))?(a.instance=b,fn(b),b):(u=i,(b=Xr.get(j))&&(u=g({},i),sh(u,b)),n=n.ownerDocument||n,b=n.createElement("script"),fn(b),er(b,"link",u),n.head.appendChild(b),a.instance=b);case"void":return null;default:throw Error(l(443,a.type))}else a.type==="stylesheet"&&(a.state.loading&4)===0&&(u=a.instance,a.state.loading|=4,Hc(u,i.precedence,n));return a.instance}function Hc(n,a,i){for(var u=i.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),b=u.length?u[u.length-1]:null,j=b,P=0;P<u.length;P++){var W=u[P];if(W.dataset.precedence===a)j=W;else if(j!==b)break}j?j.parentNode.insertBefore(n,j.nextSibling):(a=i.nodeType===9?i.head:i,a.insertBefore(n,a.firstChild))}function rh(n,a){n.crossOrigin==null&&(n.crossOrigin=a.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=a.referrerPolicy),n.title==null&&(n.title=a.title)}function sh(n,a){n.crossOrigin==null&&(n.crossOrigin=a.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=a.referrerPolicy),n.integrity==null&&(n.integrity=a.integrity)}var Pc=null;function U0(n,a,i){if(Pc===null){var u=new Map,b=Pc=new Map;b.set(i,u)}else b=Pc,u=b.get(i),u||(u=new Map,b.set(i,u));if(u.has(n))return u;for(u.set(n,null),i=i.getElementsByTagName(n),b=0;b<i.length;b++){var j=i[b];if(!(j[Tn]||j[At]||n==="link"&&j.getAttribute("rel")==="stylesheet")&&j.namespaceURI!=="http://www.w3.org/2000/svg"){var P=j.getAttribute(a)||"";P=n+P;var W=u.get(P);W?W.push(j):u.set(P,[j])}}return u}function q0(n,a,i){n=n.ownerDocument||n,n.head.insertBefore(i,a==="title"?n.querySelector("head > title"):null)}function j2(n,a,i){if(i===1||a.itemProp!=null)return!1;switch(n){case"meta":case"title":return!0;case"style":if(typeof a.precedence!="string"||typeof a.href!="string"||a.href==="")break;return!0;case"link":if(typeof a.rel!="string"||typeof a.href!="string"||a.href===""||a.onLoad||a.onError)break;return a.rel==="stylesheet"?(n=a.disabled,typeof a.precedence=="string"&&n==null):!0;case"script":if(a.async&&typeof a.async!="function"&&typeof a.async!="symbol"&&!a.onLoad&&!a.onError&&a.src&&typeof a.src=="string")return!0}return!1}function F0(n){return!(n.type==="stylesheet"&&(n.state.loading&3)===0)}function w2(n,a,i,u){if(i.type==="stylesheet"&&(typeof u.media!="string"||matchMedia(u.media).matches!==!1)&&(i.state.loading&4)===0){if(i.instance===null){var b=zl(u.href),j=a.querySelector(qi(b));if(j){a=j._p,a!==null&&typeof a=="object"&&typeof a.then=="function"&&(n.count++,n=Uc.bind(n),a.then(n,n)),i.state.loading|=4,i.instance=j,fn(j);return}j=a.ownerDocument||a,u=H0(u),(b=Xr.get(b))&&rh(u,b),j=j.createElement("link"),fn(j);var P=j;P._p=new Promise(function(W,le){P.onload=W,P.onerror=le}),er(j,"link",u),i.instance=j}n.stylesheets===null&&(n.stylesheets=new Map),n.stylesheets.set(i,a),(a=i.state.preload)&&(i.state.loading&3)===0&&(n.count++,i=Uc.bind(n),a.addEventListener("load",i),a.addEventListener("error",i))}}var ah=0;function N2(n,a){return n.stylesheets&&n.count===0&&Fc(n,n.stylesheets),0<n.count||0<n.imgCount?function(i){var u=setTimeout(function(){if(n.stylesheets&&Fc(n,n.stylesheets),n.unsuspend){var j=n.unsuspend;n.unsuspend=null,j()}},6e4+a);0<n.imgBytes&&ah===0&&(ah=62500*r2());var b=setTimeout(function(){if(n.waitingForImages=!1,n.count===0&&(n.stylesheets&&Fc(n,n.stylesheets),n.unsuspend)){var j=n.unsuspend;n.unsuspend=null,j()}},(n.imgBytes>ah?50:800)+a);return n.unsuspend=i,function(){n.unsuspend=null,clearTimeout(u),clearTimeout(b)}}:null}function Uc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Fc(this,this.stylesheets);else if(this.unsuspend){var n=this.unsuspend;this.unsuspend=null,n()}}}var qc=null;function Fc(n,a){n.stylesheets=null,n.unsuspend!==null&&(n.count++,qc=new Map,a.forEach(k2,n),qc=null,Uc.call(n))}function k2(n,a){if(!(a.state.loading&4)){var i=qc.get(n);if(i)var u=i.get(null);else{i=new Map,qc.set(n,i);for(var b=n.querySelectorAll("link[data-precedence],style[data-precedence]"),j=0;j<b.length;j++){var P=b[j];(P.nodeName==="LINK"||P.getAttribute("media")!=="not all")&&(i.set(P.dataset.precedence,P),u=P)}u&&i.set(null,u)}b=a.instance,P=b.getAttribute("data-precedence"),j=i.get(P)||u,j===u&&i.set(null,b),i.set(P,b),this.count++,u=Uc.bind(this),b.addEventListener("load",u),b.addEventListener("error",u),j?j.parentNode.insertBefore(b,j.nextSibling):(n=n.nodeType===9?n.head:n,n.insertBefore(b,n.firstChild)),a.state.loading|=4}}var Vi={$$typeof:k,Provider:null,Consumer:null,_currentValue:V,_currentValue2:V,_threadCount:0};function S2(n,a,i,u,b,j,P,W,le){this.tag=1,this.containerInfo=n,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=Be(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Be(0),this.hiddenUpdates=Be(null),this.identifierPrefix=u,this.onUncaughtError=b,this.onCaughtError=j,this.onRecoverableError=P,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=le,this.incompleteTransitions=new Map}function V0(n,a,i,u,b,j,P,W,le,be,Ee,_e){return n=new S2(n,a,i,P,le,be,Ee,_e,W),a=1,j===!0&&(a|=24),j=_r(3,null,null,a),n.current=j,j.stateNode=n,a=Iu(),a.refCount++,n.pooledCache=a,a.refCount++,j.memoizedState={element:u,isDehydrated:i,cache:a},Pu(j),n}function Y0(n){return n?(n=ml,n):ml}function G0(n,a,i,u,b,j){b=Y0(b),u.context===null?u.context=b:u.pendingContext=b,u=sa(a),u.payload={element:i},j=j===void 0?null:j,j!==null&&(u.callback=j),i=aa(n,u,a),i!==null&&(vr(i,n,a),Ni(i,n,a))}function X0(n,a){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var i=n.retryLane;n.retryLane=i!==0&&i<a?i:a}}function lh(n,a){X0(n,a),(n=n.alternate)&&X0(n,a)}function Z0(n){if(n.tag===13||n.tag===31){var a=za(n,67108864);a!==null&&vr(a,n,67108864),lh(n,67108864)}}function Q0(n){if(n.tag===13||n.tag===31){var a=Lr();a=it(a);var i=za(n,a);i!==null&&vr(i,n,a),lh(n,a)}}var Vc=!0;function C2(n,a,i,u){var b=_.T;_.T=null;var j=Y.p;try{Y.p=2,ih(n,a,i,u)}finally{Y.p=j,_.T=b}}function E2(n,a,i,u){var b=_.T;_.T=null;var j=Y.p;try{Y.p=8,ih(n,a,i,u)}finally{Y.p=j,_.T=b}}function ih(n,a,i,u){if(Vc){var b=oh(u);if(b===null)Gf(n,a,u,Yc,i),J0(n,u);else if(A2(b,n,a,i,u))u.stopPropagation();else if(J0(n,u),a&4&&-1<T2.indexOf(n)){for(;b!==null;){var j=or(b);if(j!==null)switch(j.tag){case 3:if(j=j.stateNode,j.current.memoizedState.isDehydrated){var P=ut(j.pendingLanes);if(P!==0){var W=j;for(W.pendingLanes|=2,W.entangledLanes|=2;P;){var le=1<<31-yt(P);W.entanglements[1]|=le,P&=~le}ms(j),(nn&6)===0&&(Tc=xt()+500,Bi(0))}}break;case 31:case 13:W=za(j,2),W!==null&&vr(W,j,2),_c(),lh(j,2)}if(j=oh(u),j===null&&Gf(n,a,u,Yc,i),j===b)break;b=j}b!==null&&u.stopPropagation()}else Gf(n,a,u,null,i)}}function oh(n){return n=at(n),ch(n)}var Yc=null;function ch(n){if(Yc=null,n=hr(n),n!==null){var a=d(n);if(a===null)n=null;else{var i=a.tag;if(i===13){if(n=c(a),n!==null)return n;n=null}else if(i===31){if(n=h(a),n!==null)return n;n=null}else if(i===3){if(a.stateNode.current.memoizedState.isDehydrated)return a.tag===3?a.stateNode.containerInfo:null;n=null}else a!==n&&(n=null)}}return Yc=n,null}function K0(n){switch(n){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(dn()){case we:return 2;case Re:return 8;case qe:case et:return 32;case nt:return 268435456;default:return 32}default:return 32}}var dh=!1,ga=null,pa=null,ba=null,Yi=new Map,Gi=new Map,ya=[],T2="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 J0(n,a){switch(n){case"focusin":case"focusout":ga=null;break;case"dragenter":case"dragleave":pa=null;break;case"mouseover":case"mouseout":ba=null;break;case"pointerover":case"pointerout":Yi.delete(a.pointerId);break;case"gotpointercapture":case"lostpointercapture":Gi.delete(a.pointerId)}}function Xi(n,a,i,u,b,j){return n===null||n.nativeEvent!==j?(n={blockedOn:a,domEventName:i,eventSystemFlags:u,nativeEvent:j,targetContainers:[b]},a!==null&&(a=or(a),a!==null&&Z0(a)),n):(n.eventSystemFlags|=u,a=n.targetContainers,b!==null&&a.indexOf(b)===-1&&a.push(b),n)}function A2(n,a,i,u,b){switch(a){case"focusin":return ga=Xi(ga,n,a,i,u,b),!0;case"dragenter":return pa=Xi(pa,n,a,i,u,b),!0;case"mouseover":return ba=Xi(ba,n,a,i,u,b),!0;case"pointerover":var j=b.pointerId;return Yi.set(j,Xi(Yi.get(j)||null,n,a,i,u,b)),!0;case"gotpointercapture":return j=b.pointerId,Gi.set(j,Xi(Gi.get(j)||null,n,a,i,u,b)),!0}return!1}function W0(n){var a=hr(n.target);if(a!==null){var i=d(a);if(i!==null){if(a=i.tag,a===13){if(a=c(i),a!==null){n.blockedOn=a,an(n.priority,function(){Q0(i)});return}}else if(a===31){if(a=h(i),a!==null){n.blockedOn=a,an(n.priority,function(){Q0(i)});return}}else if(a===3&&i.stateNode.current.memoizedState.isDehydrated){n.blockedOn=i.tag===3?i.stateNode.containerInfo:null;return}}}n.blockedOn=null}function Gc(n){if(n.blockedOn!==null)return!1;for(var a=n.targetContainers;0<a.length;){var i=oh(n.nativeEvent);if(i===null){i=n.nativeEvent;var u=new i.constructor(i.type,i);_n=u,i.target.dispatchEvent(u),_n=null}else return a=or(i),a!==null&&Z0(a),n.blockedOn=i,!1;a.shift()}return!0}function eb(n,a,i){Gc(n)&&i.delete(a)}function _2(){dh=!1,ga!==null&&Gc(ga)&&(ga=null),pa!==null&&Gc(pa)&&(pa=null),ba!==null&&Gc(ba)&&(ba=null),Yi.forEach(eb),Gi.forEach(eb)}function Xc(n,a){n.blockedOn===a&&(n.blockedOn=null,dh||(dh=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,_2)))}var Zc=null;function tb(n){Zc!==n&&(Zc=n,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Zc===n&&(Zc=null);for(var a=0;a<n.length;a+=3){var i=n[a],u=n[a+1],b=n[a+2];if(typeof u!="function"){if(ch(u||i)===null)continue;break}var j=or(i);j!==null&&(n.splice(a,3),a-=3,of(j,{pending:!0,data:b,method:i.method,action:u},u,b))}}))}function $l(n){function a(le){return Xc(le,n)}ga!==null&&Xc(ga,n),pa!==null&&Xc(pa,n),ba!==null&&Xc(ba,n),Yi.forEach(a),Gi.forEach(a);for(var i=0;i<ya.length;i++){var u=ya[i];u.blockedOn===n&&(u.blockedOn=null)}for(;0<ya.length&&(i=ya[0],i.blockedOn===null);)W0(i),i.blockedOn===null&&ya.shift();if(i=(n.ownerDocument||n).$$reactFormReplay,i!=null)for(u=0;u<i.length;u+=3){var b=i[u],j=i[u+1],P=b[un]||null;if(typeof j=="function")P||tb(i);else if(P){var W=null;if(j&&j.hasAttribute("formAction")){if(b=j,P=j[un]||null)W=P.formAction;else if(ch(b)!==null)continue}else W=P.action;typeof W=="function"?i[u+1]=W:(i.splice(u,3),u-=3),tb(i)}}}function nb(){function n(j){j.canIntercept&&j.info==="react-transition"&&j.intercept({handler:function(){return new Promise(function(P){return b=P})},focusReset:"manual",scroll:"manual"})}function a(){b!==null&&(b(),b=null),u||setTimeout(i,20)}function i(){if(!u&&!navigation.transition){var j=navigation.currentEntry;j&&j.url!=null&&navigation.navigate(j.url,{state:j.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var u=!1,b=null;return navigation.addEventListener("navigate",n),navigation.addEventListener("navigatesuccess",a),navigation.addEventListener("navigateerror",a),setTimeout(i,100),function(){u=!0,navigation.removeEventListener("navigate",n),navigation.removeEventListener("navigatesuccess",a),navigation.removeEventListener("navigateerror",a),b!==null&&(b(),b=null)}}}function uh(n){this._internalRoot=n}Qc.prototype.render=uh.prototype.render=function(n){var a=this._internalRoot;if(a===null)throw Error(l(409));var i=a.current,u=Lr();G0(i,u,n,a,null,null)},Qc.prototype.unmount=uh.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var a=n.containerInfo;G0(n.current,2,null,n,null,null),_c(),a[En]=null}};function Qc(n){this._internalRoot=n}Qc.prototype.unstable_scheduleHydration=function(n){if(n){var a=wn();n={blockedOn:null,target:n,priority:a};for(var i=0;i<ya.length&&a!==0&&a<ya[i].priority;i++);ya.splice(i,0,n),i===0&&W0(n)}};var rb=r.version;if(rb!=="19.2.4")throw Error(l(527,rb,"19.2.4"));Y.findDOMNode=function(n){var a=n._reactInternals;if(a===void 0)throw typeof n.render=="function"?Error(l(188)):(n=Object.keys(n).join(","),Error(l(268,n)));return n=f(a),n=n!==null?x(n):null,n=n===null?null:n.stateNode,n};var M2={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:_,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Kc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Kc.isDisabled&&Kc.supportsFiber)try{Lt=Kc.inject(M2),Tt=Kc}catch{}}return Qi.createRoot=function(n,a){if(!o(n))throw Error(l(299));var i=!1,u="",b=dp,j=up,P=fp;return a!=null&&(a.unstable_strictMode===!0&&(i=!0),a.identifierPrefix!==void 0&&(u=a.identifierPrefix),a.onUncaughtError!==void 0&&(b=a.onUncaughtError),a.onCaughtError!==void 0&&(j=a.onCaughtError),a.onRecoverableError!==void 0&&(P=a.onRecoverableError)),a=V0(n,1,!1,null,null,i,u,null,b,j,P,nb),n[En]=a.current,Yf(n),new uh(a)},Qi.hydrateRoot=function(n,a,i){if(!o(n))throw Error(l(299));var u=!1,b="",j=dp,P=up,W=fp,le=null;return i!=null&&(i.unstable_strictMode===!0&&(u=!0),i.identifierPrefix!==void 0&&(b=i.identifierPrefix),i.onUncaughtError!==void 0&&(j=i.onUncaughtError),i.onCaughtError!==void 0&&(P=i.onCaughtError),i.onRecoverableError!==void 0&&(W=i.onRecoverableError),i.formState!==void 0&&(le=i.formState)),a=V0(n,1,!0,a,i??null,u,b,le,j,P,W,nb),a.context=Y0(null),i=a.current,u=Lr(),u=it(u),b=sa(u),b.callback=null,aa(i,b,u),i=u,a.current.lanes=i,Le(a,i),ms(a),n[En]=a.current,Yf(n),new Qc(a)},Qi.version="19.2.4",Qi}var hb;function P2(){if(hb)return mh.exports;hb=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(r){console.error(r)}}return e(),mh.exports=H2(),mh.exports}var U2=P2();const s1="/api";async function he(e,r){const s=await fetch(`${s1}${e}`,{headers:{"Content-Type":"application/json"},credentials:"include",...r,body:r?.body?typeof r.body=="string"?r.body:JSON.stringify(r.body):void 0});if(!s.ok){let l="";try{const o=await s.json();l=o.error??o.message??""}catch{}throw new Error(l||`API error: ${s.status}`)}return s.json()}const re={agents:{list:()=>he("/agents"),get:e=>he(`/agents/${e}`),create:(e,r,s,l)=>he("/agents",{method:"POST",body:JSON.stringify({name:e,roleName:r,agentRole:s,teamId:l})}),start:e=>he(`/agents/${e}/start`,{method:"POST"}),stop:e=>he(`/agents/${e}/stop`,{method:"POST"}),remove:(e,r)=>he(`/agents/${e}${r?.purgeFiles?"?purgeFiles=true":""}`,{method:"DELETE"}),updateConfig:(e,r)=>he(`/agents/${e}/config`,{method:"PATCH",body:JSON.stringify(r)}),getMemory:e=>he(`/agents/${e}/memory`),getMemorySession:(e,r)=>he(`/agents/${e}/memory/sessions/${encodeURIComponent(r)}`),updateDailyMemory:(e,r)=>he(`/agents/${e}/memory/daily`,{method:"PUT",body:JSON.stringify({content:r})}),updateLongTermMemory:(e,r,s)=>he(`/agents/${e}/memory/longterm`,{method:"PUT",body:JSON.stringify({key:r,content:s})}),getFiles:e=>he(`/agents/${e}/files`),getFilesMap:e=>he(`/agents/${e}/files`),updateFile:(e,r,s)=>he(`/agents/${e}/files/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify({content:s})}),updateSystemPrompt:(e,r)=>he(`/agents/${e}/system-prompt`,{method:"PUT",body:JSON.stringify({systemPrompt:r})}),roleStatus:e=>he(`/agents/${e}/role-status`),roleDiff:(e,r="ROLE.md")=>he(`/agents/${e}/role-diff?file=${encodeURIComponent(r)}`),roleSync:(e,r)=>he(`/agents/${e}/role-sync`,{method:"POST",body:JSON.stringify(r?{files:r}:{})}),roleUpdates:()=>he("/agents/role-updates"),addSkill:(e,r)=>he(`/agents/${e}/skills`,{method:"POST",body:JSON.stringify({skillName:r})}),removeSkill:(e,r)=>he(`/agents/${e}/skills/${encodeURIComponent(r)}`,{method:"DELETE"}),getHeartbeat:e=>he(`/agents/${e}/heartbeat`),triggerHeartbeat:e=>he(`/agents/${e}/heartbeat/trigger`,{method:"POST"}),getRecentActivities:e=>he(`/agents/${e}/recent-activities`),getActivityLogs:(e,r)=>he(`/agents/${e}/activity-logs?activityId=${encodeURIComponent(r)}`),getActivities:(e,r)=>{const s=new URLSearchParams;r?.type&&s.set("type",r.type),r?.limit&&s.set("limit",String(r.limit)),r?.before&&s.set("before",r.before);const l=s.toString();return he(`/agents/${e}/activities${l?"?"+l:""}`)},message:(e,r,s,l)=>he(`/agents/${e}/message`,{method:"POST",body:JSON.stringify({text:r,images:s,sessionId:l??void 0})}),messageStream:(e,r,s,l,o,d,c)=>new Promise(async(h,m)=>{let f="",x;try{const g=await fetch(`${s1}/agents/${e}/message`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({text:r,stream:!0,images:d,sessionId:c??void 0}),signal:o});if(!g.ok){m(new Error(`API error: ${g.status}`));return}const p=g.body?.getReader();if(!p){m(new Error("No reader"));return}const y=new TextDecoder;let w="";for(;;){const{done:N,value:E}=await p.read();if(N)break;w+=y.decode(E,{stream:!0});const A=w.split(`
|
|
10
|
+
`);w=A.pop()??"";for(const C of A){const k=C.trim();if(k.startsWith("data: "))try{const S=JSON.parse(k.slice(6));if(S.type==="text_delta"&&S.text)f+=S.text,s(S.text);else if(S.type==="thinking_delta"&&S.thinking)s?.(`<think>${S.thinking}</think>`);else if(S.type==="done")f=S.content??f,S.sessionId&&(x=S.sessionId);else if(S.type==="error"){const O=S;O.sessionId&&(x=O.sessionId);const R=new Error(O.message??O.error??"Unknown stream error");R.sessionId=O.sessionId,m(R),p.cancel().catch(()=>{});return}else S.type==="tool_call_start"&&S.toolCall?.name?l?.({tool:S.toolCall.name,phase:"start"}):S.type==="agent_tool"&&S.tool&&S.phase?S.phase==="start"?l?.({tool:S.tool,phase:"start",arguments:S.arguments}):S.phase==="end"&&l?.({tool:S.tool,phase:"end",success:S.success,arguments:S.arguments,result:S.result,error:S.error,durationMs:S.durationMs}):S.type==="tool_output"&&S.tool?l?.({tool:S.tool,phase:"output",output:S.text}):S.type==="subagent_progress"&&S.tool&&l?.({tool:S.tool,phase:"subagent_progress",subagentEvent:S.subagentEvent})}catch{}}}h({content:f,sessionId:x})}catch(g){g instanceof Error&&g.name==="AbortError"?h({content:f,sessionId:x}):m(g)}})},roles:{list:()=>he("/roles")},teams:{list:e=>he(`/teams?orgId=${e??"default"}`),create:(e,r)=>he("/teams",{method:"POST",body:JSON.stringify({name:e,description:r})}),update:(e,r)=>he(`/teams/${e}`,{method:"PATCH",body:JSON.stringify(r)}),delete:(e,r,s)=>he(`/teams/${e}?deleteMembers=${r?"true":"false"}${s?.purgeFiles?"&purgeFiles=true":""}`,{method:"DELETE"}),addMember:(e,r,s)=>he(`/teams/${e}/members`,{method:"POST",body:JSON.stringify({memberId:r,memberType:s})}),removeMember:(e,r)=>he(`/teams/${e}/members/${r}`,{method:"DELETE"}),startAll:e=>he(`/teams/${e}/start`,{method:"POST"}),stopAll:e=>he(`/teams/${e}/stop`,{method:"POST"}),pauseAll:(e,r)=>he(`/teams/${e}/pause`,{method:"POST",body:JSON.stringify({reason:r})}),resumeAll:e=>he(`/teams/${e}/resume`,{method:"POST"}),status:e=>he(`/teams/${e}/status`),getFiles:e=>he(`/teams/${e}/files`),getFile:(e,r)=>he(`/teams/${e}/files/${encodeURIComponent(r)}`),updateFile:(e,r,s)=>he(`/teams/${e}/files/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify({content:s})}),exportTeam:e=>he(`/teams/${e}/export`,{method:"POST"}),getFilesMap:e=>he(`/teams/${e}/export`)},externalAgents:{list:e=>he(`/external-agents?orgId=${e??"default"}`)},tasks:{list:e=>{const r=new URLSearchParams;e?.assignedAgentId&&r.set("assignedAgentId",e.assignedAgentId),e?.status&&r.set("status",e.status),e?.projectId&&r.set("projectId",e.projectId),e?.requirementId&&r.set("requirementId",e.requirementId),e?.priority&&r.set("priority",e.priority),e?.search&&r.set("search",e.search),e?.sortBy&&r.set("sortBy",e.sortBy),e?.sortOrder&&r.set("sortOrder",e.sortOrder),e?.page!==null&&e?.page!==void 0&&r.set("page",String(e.page)),e?.pageSize!==null&&e?.pageSize!==void 0&&r.set("pageSize",String(e.pageSize));const s=r.toString();return he(`/tasks${s?`?${s}`:""}`)},get:e=>he(`/tasks/${e}`),create:(e,r,s,l,o,d,c,h,m,f)=>he("/tasks",{method:"POST",body:JSON.stringify({title:e,description:r,assignedAgentId:s,reviewerAgentId:l,priority:o,projectId:d,blockedBy:c,requirementId:h,taskType:m,scheduleConfig:f})}),update:(e,r)=>he(`/tasks/${e}`,{method:"PUT",body:JSON.stringify(r)}),updateStatus:(e,r)=>he(`/tasks/${e}`,{method:"PUT",body:JSON.stringify({status:r})}),assign:(e,r)=>he(`/tasks/${e}`,{method:"PUT",body:JSON.stringify({assignedAgentId:r})}),approve:e=>he(`/tasks/${e}/approve`,{method:"POST"}),reject:e=>he(`/tasks/${e}/reject`,{method:"POST"}),cancel:(e,r=!1)=>he(`/tasks/${e}/cancel`,{method:"POST",body:JSON.stringify({cascade:r})}),getDependentCount:e=>he(`/tasks/${e}/dependents`),board:e=>{const r=new URLSearchParams;e?.projectId&&r.set("projectId",e.projectId);const s=r.toString();return he(`/taskboard${s?`?${s}`:""}`)},listSubtasks:e=>he(`/tasks/${e}/subtasks`),createSubtask:(e,r)=>he(`/tasks/${e}/subtasks`,{method:"POST",body:JSON.stringify({title:r})}),completeSubtask:(e,r)=>he(`/tasks/${e}/subtasks/${r}/complete`,{method:"POST"}),cancelSubtask:(e,r)=>he(`/tasks/${e}/subtasks/${r}/cancel`,{method:"POST"}),deleteSubtask:(e,r)=>he(`/tasks/${e}/subtasks/${r}`,{method:"DELETE"}),run:e=>he(`/tasks/${e}/run`,{method:"POST"}),getLogs:(e,r)=>he(`/tasks/${e}/logs${r!=null?`?round=${r}`:""}`),getLogsSummary:e=>he(`/tasks/${e}/logs/summary`),accept:(e,r)=>he(`/tasks/${e}/accept`,{method:"POST",body:JSON.stringify({reviewerAgentId:r??"human"})}),revision:(e,r,s)=>he(`/tasks/${e}/revision`,{method:"POST",body:JSON.stringify({reason:r,reviewerAgentId:s??"human"})}),archive:e=>he(`/tasks/${e}/archive`,{method:"POST"}),pause:e=>he(`/tasks/${e}/pause`,{method:"POST"}),resume:e=>he(`/tasks/${e}/resume`,{method:"POST"}),retry:e=>he(`/tasks/${e}/retry`,{method:"POST"}),getComments:e=>he(`/tasks/${e}/comments`),addComment:(e,r,s,l,o,d)=>he(`/tasks/${e}/comments`,{method:"POST",body:JSON.stringify({content:r,authorId:o??"human",authorName:s??"User",authorType:"human",attachments:l,mentions:d})}),pauseSchedule:e=>he(`/tasks/${e}/schedule/pause`,{method:"POST"}),resumeSchedule:e=>he(`/tasks/${e}/schedule/resume`,{method:"POST"}),runNow:e=>he(`/tasks/${e}/schedule/run-now`,{method:"POST"}),deliverables:e=>{const r=e?`?projectId=${encodeURIComponent(e)}`:"";return he(`/tasks/deliverables${r}`)}},files:{preview:e=>he(`/files/preview?path=${encodeURIComponent(e)}`),reveal:e=>he("/files/reveal",{method:"POST",body:JSON.stringify({path:e})})},requirements:{list:e=>{const r=new URLSearchParams;e?.orgId&&r.set("orgId",e.orgId),e?.status&&r.set("status",e.status),e?.source&&r.set("source",e.source),e?.projectId&&r.set("projectId",e.projectId);const s=r.toString();return he(`/requirements${s?`?${s}`:""}`)},get:e=>he(`/requirements/${e}`),create:e=>he("/requirements",{method:"POST",body:JSON.stringify(e)}),update:(e,r)=>he(`/requirements/${e}`,{method:"PUT",body:JSON.stringify(r)}),updateStatus:(e,r)=>he(`/requirements/${e}/status`,{method:"POST",body:JSON.stringify({status:r})}),approve:e=>he(`/requirements/${e}/approve`,{method:"POST"}),reject:(e,r)=>he(`/requirements/${e}/reject`,{method:"POST",body:JSON.stringify({reason:r})}),cancel:e=>he(`/requirements/${e}/cancel`,{method:"POST"}),delete:e=>he(`/requirements/${e}`,{method:"DELETE"}),getComments:e=>he(`/requirements/${e}/comments`),addComment:(e,r,s,l,o)=>he(`/requirements/${e}/comments`,{method:"POST",body:JSON.stringify({content:r,authorId:l??"human",authorName:s??"User",authorType:"human",mentions:o})})},users:{list:e=>he(`/users?orgId=${e??"default"}`),create:(e,r,s,l,o,d)=>he("/users",{method:"POST",body:JSON.stringify({name:e,role:r,orgId:s,email:l,password:o,teamId:d})}),remove:e=>he(`/users/${e}`,{method:"DELETE"})},teamTemplates:{list:e=>{const r=e?`?q=${encodeURIComponent(e)}`:"";return he(`/team-templates${r}`)},get:e=>he(`/team-templates/${e}`)},ops:{dashboard:(e="24h")=>he(`/ops/dashboard?period=${e}`)},agentMetrics:(e,r="24h")=>he(`/agents/${e}/metrics?period=${r}`),usage:{summary:(e="default",r)=>{const s=new URLSearchParams({orgId:e});return r&&s.set("period",r),he(`/usage?${s}`)},agents:(e="default")=>he(`/usage/agents?orgId=${e}`)},health:()=>he("/health"),system:{openPath:e=>he("/system/open-path",{method:"POST",body:JSON.stringify({path:e})}),storage:()=>he("/system/storage"),orphans:()=>he("/system/storage/orphans"),purgeOrphans:e=>he("/system/storage/orphans",{method:"DELETE",body:e?JSON.stringify({ids:e}):void 0})},settings:{getLlm:()=>he("/settings/llm"),getAgent:()=>he("/settings/agent"),updateAgent:e=>he("/settings/agent",{method:"POST",body:JSON.stringify(e)})},skills:{list:()=>he("/skills"),builtin:()=>he("/skills/builtin"),registry:e=>he(`/skills/registry${e?`?source=${e}`:""}`),registrySkillhub:e=>{const r=new URLSearchParams;e?.q&&r.set("q",e.q),e?.category&&r.set("category",e.category),e?.page&&r.set("page",String(e.page)),e?.limit&&r.set("limit",String(e.limit)),e?.sort&&r.set("sort",e.sort);const s=r.toString();return he(`/skills/registry/skillhub${s?`?${s}`:""}`)},registrySkillssh:e=>he(`/skills/registry/skillssh${e?`?q=${encodeURIComponent(e)}`:""}`),import:(e,r,s,l)=>he("/skills/import",{method:"POST",body:JSON.stringify({name:e,sourceUrl:r,description:s,category:l})}),install:e=>he("/skills/install",{method:"POST",body:JSON.stringify(e)}),uninstall:e=>he(`/skills/installed/${encodeURIComponent(e)}`,{method:"DELETE"}),getFilesMap:e=>he(`/skills/${encodeURIComponent(e)}/files`)},builder:{artifacts:{list:()=>he("/builder/artifacts"),get:(e,r)=>he(`/builder/artifacts/${e}s/${encodeURIComponent(r)}`),save:(e,r)=>he("/builder/artifacts/save",{method:"POST",body:JSON.stringify({mode:e,artifact:r})}),import:(e,r,s,l)=>he("/builder/artifacts/import",{method:"POST",body:JSON.stringify({type:e,name:r,files:s,source:l})}),install:(e,r)=>he(`/builder/artifacts/${e}s/${encodeURIComponent(r)}/install`,{method:"POST"}),uninstall:(e,r)=>he(`/builder/artifacts/${e}s/${encodeURIComponent(r)}/uninstall`,{method:"POST"}),delete:(e,r)=>he(`/builder/artifacts/${e}s/${encodeURIComponent(r)}`,{method:"DELETE"}),installed:()=>he("/builder/artifacts/installed")}},auth:{login:(e,r)=>he("/auth/login",{method:"POST",body:JSON.stringify({email:e,password:r})}),logout:()=>he("/auth/logout",{method:"POST"}),me:()=>he("/auth/me"),changePassword:(e,r)=>he("/auth/change-password",{method:"POST",body:JSON.stringify({currentPassword:e,newPassword:r})})},sessions:{listByAgent:(e,r=20)=>he(`/agents/${e}/sessions?limit=${r}`),getMessages:(e,r=50,s)=>he(`/sessions/${e}/messages?limit=${r}${s?`&before=${s}`:""}`),delete:e=>he(`/sessions/${e}`,{method:"DELETE"})},channels:{getMessages:(e,r=50,s)=>he(`/channels/${encodeURIComponent(e)}/messages?limit=${r}${s?`&before=${s}`:""}`),sendMessage:(e,r)=>he(`/channels/${encodeURIComponent(e)}/messages`,{method:"POST",body:JSON.stringify(r)})},governance:{getSystemStatus:()=>he("/system/status"),pauseAll:e=>he("/system/pause-all",{method:"POST",body:JSON.stringify({reason:e})}),resumeAll:()=>he("/system/resume-all",{method:"POST"}),emergencyStop:e=>he("/system/emergency-stop",{method:"POST",body:JSON.stringify({reason:e})}),getAnnouncements:()=>he("/system/announcements"),createAnnouncement:e=>he("/system/announcements",{method:"POST",body:JSON.stringify(e)}),getPolicy:()=>he("/governance/policy"),setPolicy:e=>he("/governance/policy",{method:"PUT",body:JSON.stringify(e)})},approvals:{list:e=>{const r=e?`?status=${e}`:"";return he(`/approvals${r}`)},respond:(e,r,s)=>he(`/approvals/${e}`,{method:"POST",body:JSON.stringify({approved:r,respondedBy:s})})},notifications:{list:(e,r)=>{const s=new URLSearchParams;return e&&s.set("userId",e),r&&s.set("unread","true"),he(`/notifications?${s}`)},markRead:e=>he(`/notifications/${e}`,{method:"POST"})},projects:{list:e=>{const r=e?`?orgId=${e}`:"";return he(`/projects${r}`)},get:e=>he(`/projects/${e}`),create:e=>he("/projects",{method:"POST",body:JSON.stringify(e)}),update:(e,r)=>he(`/projects/${e}`,{method:"PUT",body:JSON.stringify(r)}),delete:e=>he(`/projects/${e}`,{method:"DELETE"})},knowledge:{search:(e,r,s)=>{const l=new URLSearchParams;return e&&l.set("query",e),r&&l.set("scope",r),s&&l.set("category",s),he(`/knowledge/search?${l}`)},contribute:e=>he("/knowledge",{method:"POST",body:JSON.stringify(e)}),flagOutdated:(e,r)=>he(`/knowledge/${e}/flag-outdated`,{method:"POST",body:JSON.stringify({reason:r})}),verify:e=>he(`/knowledge/${e}/verify`,{method:"POST",body:JSON.stringify({verifiedBy:"human"})}),remove:e=>he(`/knowledge/${e}`,{method:"DELETE"})},deliverables:{search:e=>{const r=new URLSearchParams;return e?.q&&r.set("q",e.q),e?.projectId&&r.set("projectId",e.projectId),e?.agentId&&r.set("agentId",e.agentId),e?.taskId&&r.set("taskId",e.taskId),e?.type&&r.set("type",e.type),e?.status&&r.set("status",e.status),e?.artifactType&&r.set("artifactType",e.artifactType),e?.offset&&r.set("offset",String(e.offset)),e?.limit&&r.set("limit",String(e.limit)),he(`/deliverables?${r}`)},create:e=>he("/deliverables",{method:"POST",body:JSON.stringify(e)}),update:(e,r)=>he(`/deliverables/${e}`,{method:"PUT",body:JSON.stringify(r)}),remove:e=>he(`/deliverables/${e}`,{method:"DELETE"}),verify:e=>he(`/deliverables/${e}`,{method:"PUT",body:JSON.stringify({status:"verified"})})},codeReviews:{list:(e,r=20)=>{const s=new URLSearchParams;return e&&s.set("taskId",e),s.set("limit",String(r)),he(`/reviews?${s}`)},get:e=>he(`/reviews/${e}`),run:e=>he("/reviews",{method:"POST",body:JSON.stringify(e)})},reports:{list:()=>he("/reports"),get:e=>he(`/reports/${e}`),generate:e=>he("/reports/generate",{method:"POST",body:JSON.stringify(e)}),approvePlan:(e,r)=>he(`/reports/${e}/plan/approve`,{method:"POST",body:JSON.stringify(r)}),rejectPlan:(e,r)=>he(`/reports/${e}/plan/reject`,{method:"POST",body:JSON.stringify(r)}),addFeedback:(e,r)=>he(`/reports/${e}/feedback`,{method:"POST",body:JSON.stringify(r)}),getFeedback:e=>he(`/reports/${e}/feedback`)},executionLogs:{get:(e,r)=>he(`/execution-logs?sourceType=${encodeURIComponent(e)}&sourceId=${encodeURIComponent(r)}`)}};function jd(e){return{id:e.id,sourceType:"task",sourceId:e.taskId,agentId:e.agentId,seq:e.seq,type:e.type,content:e.content,metadata:e.metadata,executionRound:e.executionRound,createdAt:e.createdAt}}function a1(e,r,s){return e.type==="llm_request"?null:{id:`alog_${r}_${e.seq}`,sourceType:"activity",sourceId:r,agentId:s,seq:e.seq,type:e.type,content:e.content,metadata:e.metadata,createdAt:e.createdAt}}class q2{ws=null;handlers=new Map;reconnectTimer=null;intentionalClose=!1;connect(){if(this.ws&&(this.ws.readyState===WebSocket.CONNECTING||this.ws.readyState===WebSocket.OPEN))return;this.intentionalClose=!1;const s=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`,l=new WebSocket(s);this.ws=l,l.onmessage=o=>{if(this.ws===l)try{const d=JSON.parse(o.data),c=this.handlers.get(d.type);if(c)for(const m of c)m(d);const h=this.handlers.get("*");if(h)for(const m of h)m(d)}catch{}},l.onclose=()=>{this.intentionalClose||(this.reconnectTimer=setTimeout(()=>this.connect(),3e3))},l.onerror=()=>{l.close()}}disconnect(){this.intentionalClose=!0,this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.ws&&(this.ws.onclose=null,this.ws.close(),this.ws=null)}on(r,s){return this.handlers.has(r)||this.handlers.set(r,new Set),this.handlers.get(r).add(s),()=>this.handlers.get(r)?.delete(s)}}const kn=new q2;let vo=window.__MARKUS_HUB_URL__??"https://markus.global";he("/settings/hub").then(e=>{e.hubUrl&&(vo=e.hubUrl);const r=localStorage.getItem("markus_hub_token");r&&he("/settings/hub-token",{method:"POST",body:JSON.stringify({token:r})}).catch(()=>{})}).catch(()=>{});const Hm="markus_hub_token",Pm="markus_hub_user";function Ta(){return localStorage.getItem(Hm)}function F2(){try{const e=localStorage.getItem(Pm);return e?JSON.parse(e):null}catch{return null}}function l1(){localStorage.removeItem(Hm),localStorage.removeItem(Pm),i1(null)}function am(e,r){localStorage.setItem(Hm,e),localStorage.setItem(Pm,JSON.stringify(r)),i1(e)}function i1(e){he("/settings/hub-token",{method:"POST",body:JSON.stringify({token:e})}).catch(()=>{})}let Ki=null;function ja(){if(Ta())return Promise.resolve();if(Ki)return Ki;const e=`cs_${Date.now()}_${Math.random().toString(36).slice(2,10)}`;return Ki=new Promise((r,s)=>{const l=`${vo}/auth/connect?session=${encodeURIComponent(e)}`,o=460,d=580,c=Math.round(window.screenX+(window.outerWidth-o)/2),h=Math.round(window.screenY+(window.outerHeight-d)/2),m=window.open(l,"markus_hub_auth",`popup=yes,width=${o},height=${d},left=${c},top=${h}`);let f=!1;const x=()=>{clearInterval(g),clearInterval(p),Ki=null},g=setInterval(async()=>{if(!f)try{const w=await(await fetch(`${vo}/api/auth/connect-status?session=${encodeURIComponent(e)}`)).json();w.ready&&w.token&&w.user&&(f=!0,am(w.token,w.user),x(),m?.close(),r())}catch{}},1500),p=setInterval(()=>{f||m?.closed&&(f=!0,x(),Ta()?r():s(new Error("Hub login cancelled")))},500)}),Ki}async function Zr(e,r){const s=Ta(),l={"Content-Type":"application/json",...r?.headers};s&&(l.Authorization=`Bearer ${s}`);const o=await fetch(`${vo}/api${e}`,{...r,headers:l}),d=await o.json();if(o.status===401&&s&&l1(),!o.ok)throw new Error(d.error??`Hub HTTP ${o.status}`);return d}const Un={getUrl:()=>vo,isAuthenticated:()=>!!Ta(),getUser:F2,logout:()=>{l1()},ensureAuth:ja,login:async(e,r)=>{const s=await Zr("/auth/login",{method:"POST",body:JSON.stringify({email:e,password:r})});return am(s.token,s.user),s},register:async(e,r,s)=>{const l=await Zr("/auth/register",{method:"POST",body:JSON.stringify({username:e,email:r,password:s})});return am(l.token,l.user),l},search:e=>{const r=new URLSearchParams;e?.type&&r.set("type",e.type),e?.q&&r.set("q",e.q),e?.category&&r.set("category",e.category),e?.sort&&r.set("sort",e.sort),e?.page&&r.set("page",String(e.page)),e?.limit&&r.set("limit",String(e.limit));const s=r.toString();return Zr(`/items${s?`?${s}`:""}`)},getItem:e=>Zr(`/items/${e}`),download:async e=>{await ja();try{return await Zr(`/items/${e}/download`,{method:"POST"})}catch(r){if(!Ta())return await ja(),Zr(`/items/${e}/download`,{method:"POST"});throw r}},publish:async e=>{await ja();try{return await Zr("/items",{method:"POST",body:JSON.stringify(e)})}catch(r){if(!Ta())return await ja(),Zr("/items",{method:"POST",body:JSON.stringify(e)});throw r}},publishViaProxy:async e=>{await ja();try{return await Zr("/items",{method:"POST",body:JSON.stringify(e)})}catch(r){if(!Ta())return await ja(),Zr("/items",{method:"POST",body:JSON.stringify(e)});throw r}},myItems:async()=>Ta()?Zr("/items/mine"):{items:[]},deleteItem:async e=>(await ja(),Zr(`/items/${e}`,{method:"DELETE"}))};let mb=null;const jt={setHandler(e){mb=e},navigate(e,r){r&&Object.entries(r).forEach(([s,l])=>localStorage.setItem(`markus_nav_${s}`,l)),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:e,params:r}})),mb?.(e,r)}};function xb(){const[e,r]=v.useState([]),[s,l]=v.useState([]),[o,d]=v.useState({}),[c,h]=v.useState(null),[m,f]=v.useState("24h"),[x,g]=v.useState([]),[p,y]=v.useState(null),w=()=>{re.agents.list().then(I=>r(I.agents)).catch(()=>{}),re.teams.list().then(I=>l(I.teams)).catch(()=>{}),re.tasks.board().then(I=>d(I.board)).catch(()=>{}),re.ops.dashboard(m).then(h).catch(()=>{}),re.requirements.list({source:"agent"}).then(I=>{g(I.requirements.filter(Q=>Q.status==="pending"))}).catch(()=>{}),re.system.storage().then(y).catch(()=>{})};v.useEffect(()=>{w();const I=setInterval(w,3e4),Q=()=>w();return window.addEventListener("markus:data-changed",Q),()=>{clearInterval(I),window.removeEventListener("markus:data-changed",Q)}},[m]);const N=I=>I,E={};for(const[I,Q]of Object.entries(o)){const $=N(Q).length;$>0&&(E[I]=$)}const A=E.pending??0,C=E.in_progress??0,k=E.completed??0;E.failed;const S=Object.values(E).reduce((I,Q)=>I+Q,0),O=e.filter(I=>I.status==="idle"||I.status==="working").length,R=e.filter(I=>I.status==="working").length,G=v.useMemo(()=>{const I=new Map(e.map(Q=>[Q.id,Q]));return s.map(Q=>{const $=Q.members.filter(T=>T.type==="agent").map(T=>I.get(T.id)).filter(T=>!!T),F=$.filter(T=>T.status==="working").length,B=$.filter(T=>T.status==="idle"||T.status==="working").length;return{team:Q,agents:$,working:F,active:B,total:$.length}})},[s,e]);return t.jsxs("div",{className:"flex-1 overflow-y-auto",children:[t.jsxs("div",{className:"flex items-center justify-between px-6 h-14 border-b border-border-default bg-surface-secondary",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Overview"}),t.jsx("div",{className:"flex gap-1 bg-surface-elevated rounded-lg p-0.5",children:["1h","24h","7d"].map(I=>t.jsx("button",{onClick:()=>f(I),className:`px-2.5 py-1 text-xs rounded-md transition-colors ${m===I?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary"}`,children:I},I))})]}),t.jsx("div",{className:"flex gap-2",children:t.jsx("button",{onClick:()=>jt.navigate("agents"),className:"px-4 py-2 bg-brand-600 hover:bg-brand-500 text-white text-sm rounded-lg transition-colors",children:"+ Hire Agent"})})]}),t.jsxs("div",{className:"p-7 space-y-6",children:[t.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsx(Jc,{label:"Active Agents",value:O,total:e.length,color:"indigo",onClick:()=>jt.navigate("team")}),t.jsx(Jc,{label:"Tasks In Progress",value:C,color:"blue",onClick:()=>jt.navigate("tasks")}),t.jsx(Jc,{label:"Pending Queue",value:A,color:"amber",onClick:()=>jt.navigate("tasks")}),t.jsx(Jc,{label:"Completed",value:k,total:S>0?S:void 0,color:"green",onClick:()=>jt.navigate("tasks")})]}),S===0&&(!c||c.taskKPI.recentActivity.length===0)&&t.jsxs("div",{className:"bg-surface-secondary border border-brand-500/20 rounded-xl p-6",children:[t.jsx("h3",{className:"text-sm font-semibold text-fg-primary mb-1",children:"Your AI workforce is ready"}),t.jsx("p",{className:"text-xs text-fg-secondary mb-4",children:"Get started in under a minute — describe what you need and let your team take it from here."}),t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[{label:"Describe Your Goal",desc:"Chat with the Secretary — it will assemble a team and break down tasks",page:"chat"},{label:"Hire Agents",desc:"Browse templates: developers, researchers, writers, analysts, and more",page:"agents"},{label:"Create a Project",desc:"Set up requirements and let agents plan, execute, and deliver",page:"projects"}].map(I=>t.jsxs("button",{onClick:()=>jt.navigate(I.page),className:"text-left bg-surface-elevated/50 hover:bg-surface-elevated border border-border-default/50 hover:border-brand-500/30 rounded-lg p-4 transition-colors",children:[t.jsx("div",{className:"text-xs font-medium text-fg-primary",children:I.label}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1",children:I.desc})]},I.label))})]}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[t.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[S>0&&t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 cursor-pointer hover:border-gray-600 transition-colors",onClick:()=>jt.navigate("tasks"),children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider mb-4",children:"Task Distribution"}),t.jsx(Y2,{statusCounts:E,total:S}),(E.blocked??0)>0&&t.jsxs("div",{className:"mt-3 text-xs text-amber-600 flex items-center gap-1.5",children:[t.jsx("span",{className:"w-1.5 h-1.5 bg-amber-400 rounded-full"}),E.blocked," blocked — needs attention"]})]}),t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider",children:"Team Status"}),t.jsx("button",{onClick:()=>jt.navigate("team"),className:"text-[11px] text-fg-tertiary hover:text-fg-secondary",children:"View all →"})]}),G.length===0&&e.length===0?t.jsx("div",{className:"text-sm text-fg-tertiary py-4 text-center cursor-pointer",onClick:()=>jt.navigate("team"),children:"No teams yet. Create a team or hire agents to get started."}):t.jsxs("div",{className:"space-y-4",children:[G.map(I=>t.jsxs("div",{className:"bg-surface-elevated/30 border border-border-default/30 rounded-lg p-4 hover:border-brand-500/20 transition-colors cursor-pointer",onClick:()=>jt.navigate("team"),children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-7 h-7 rounded-lg bg-brand-600/30 flex items-center justify-center text-xs font-bold text-brand-500",children:I.team.name.charAt(0)}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium",children:I.team.name}),I.team.description&&t.jsx("div",{className:"text-[11px] text-fg-tertiary truncate max-w-[200px]",children:I.team.description})]})]}),t.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-fg-tertiary",children:[t.jsxs("span",{children:[I.total," members"]}),I.working>0&&t.jsxs("span",{className:"text-brand-500",children:[I.working," working"]}),t.jsxs("span",{className:I.active===I.total?"text-green-600":"",children:[I.active," active"]})]})]}),t.jsxs("div",{className:"flex gap-2 flex-wrap",children:[I.agents.slice(0,6).map(Q=>t.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded bg-surface-overlay/30",onClick:$=>{$.stopPropagation(),jt.navigate("team",{selectAgent:Q.id})},children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${Q.status==="idle"?"bg-green-400":Q.status==="working"?"bg-brand-400 animate-pulse":"bg-gray-600"}`}),t.jsx("span",{className:"text-[11px] text-fg-secondary",children:Q.name})]},Q.id)),I.agents.length>6&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary self-center",children:["+",I.agents.length-6," more"]})]})]},I.team.id)),(()=>{const I=new Set(s.flatMap($=>$.members.filter(F=>F.type==="agent").map(F=>F.id))),Q=e.filter($=>!I.has($.id));return Q.length===0?null:t.jsxs("div",{className:"bg-surface-elevated/20 border border-border-default/20 rounded-lg p-4",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("div",{className:"text-xs text-fg-tertiary font-medium",children:"Unassigned Agents"}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[Q.length," agents"]})]}),t.jsxs("div",{className:"flex gap-2 flex-wrap",children:[Q.slice(0,6).map($=>t.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded bg-surface-overlay/30 cursor-pointer",onClick:()=>jt.navigate("team",{selectAgent:$.id}),children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${$.status==="idle"?"bg-green-400":$.status==="working"?"bg-brand-400 animate-pulse":"bg-gray-600"}`}),t.jsx("span",{className:"text-[11px] text-fg-secondary",children:$.name})]},$.id)),Q.length>6&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary self-center",children:["+",Q.length-6," more"]})]})]})})()]})]})]}),t.jsxs("div",{className:"space-y-6",children:[x.length>0&&t.jsxs("div",{className:"bg-surface-secondary border border-amber-500/30 rounded-xl p-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"w-2 h-2 bg-amber-400 rounded-full animate-pulse"}),t.jsx("h3",{className:"text-xs font-semibold text-amber-600 uppercase tracking-wider",children:"Pending Reviews"})]}),t.jsx("button",{onClick:()=>jt.navigate("projects"),className:"text-[11px] text-fg-tertiary hover:text-fg-secondary",children:"Review →"})]}),t.jsxs("div",{className:"space-y-2",children:[x.slice(0,5).map(I=>t.jsxs("div",{className:"flex items-start gap-2.5 py-2 px-2.5 rounded-lg bg-surface-elevated/40 hover:bg-surface-elevated/60 transition-colors cursor-pointer",onClick:()=>jt.navigate("projects"),children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs text-fg-primary font-medium truncate",children:I.title}),t.jsxs("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:["proposed by ",I.createdBy," · ",I.priority]})]}),t.jsx("span",{className:"text-[10px] bg-amber-500/15 text-amber-600 px-1.5 py-0.5 rounded-full shrink-0",children:I.source==="agent"?"Agent":"User"})]},I.id)),x.length>5&&t.jsxs("div",{className:"text-[10px] text-fg-tertiary text-center pt-1",children:["+",x.length-5," more"]})]}),t.jsxs("p",{className:"text-[10px] text-fg-tertiary mt-3",children:["Agents proposed ",x.length," requirement",x.length>1?"s":""," — review to authorize work."]})]}),c&&c.taskKPI.recentActivity.length>0&&t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider",children:"Recent Activity"}),t.jsx("button",{onClick:()=>jt.navigate("tasks"),className:"text-[11px] text-fg-tertiary hover:text-fg-secondary",children:"View all →"})]}),t.jsx("div",{className:"space-y-1.5",children:c.taskKPI.recentActivity.slice(0,8).map(I=>t.jsxs("div",{className:"flex items-center gap-2.5 py-1.5 px-2 rounded-lg hover:bg-surface-elevated/40 transition-colors cursor-pointer",onClick:()=>jt.navigate("tasks",{openTask:I.taskId}),children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${lm[I.status]??"bg-gray-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1",children:I.title}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date(I.updatedAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]},I.taskId))})]}),c&&t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider mb-4",children:"System Health"}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(Ji,{label:"Health Score",value:c.systemHealth.overallScore,max:100,unit:"%",color:c.systemHealth.overallScore>=80?"green":c.systemHealth.overallScore>=50?"amber":"red"}),t.jsx(Ji,{label:"Success Rate",value:c.taskKPI.successRate,max:100,unit:"%",color:c.taskKPI.successRate>=80?"green":"amber"}),t.jsx(Ji,{label:"Active / Total",value:O,max:e.length||1,unit:`/${e.length}`,color:"brand"}),t.jsx(Ji,{label:"Token Cost",value:parseFloat(c.systemHealth.totalTokenCost.toFixed(2)),max:Math.max(1,Math.ceil(c.systemHealth.totalTokenCost*2)),unit:"$",color:"brand",raw:!0}),t.jsx(Ji,{label:"Working Now",value:R,max:e.length||1,unit:`/${e.length}`,color:"blue"})]}),c.systemHealth.criticalAgents.length>0&&t.jsx("div",{className:"mt-4 pt-3 border-t border-border-default",children:t.jsxs("div",{className:"flex items-center gap-2 text-xs text-red-500 flex-wrap",children:[t.jsx("span",{className:"w-2 h-2 bg-red-500 rounded-full animate-pulse"}),"Needs attention:",c.systemHealth.criticalAgents.map(I=>t.jsxs("span",{className:"px-2 py-0.5 bg-red-500/10 rounded text-red-500 cursor-pointer hover:bg-red-500/20",onClick:()=>jt.navigate("team",{selectAgent:I.id}),children:[I.name," (",I.score,"%)"]},I.id))]})})]}),p&&t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 cursor-pointer hover:border-brand-500/30 transition-colors",onClick:()=>jt.navigate("settings"),children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider mb-3",children:"Storage"}),t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.jsx("span",{className:"text-2xl font-bold text-fg-primary",children:gb(p.totalSize)}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:"total"})]}),t.jsxs("div",{className:"mt-2 flex gap-4 text-xs text-fg-tertiary",children:[t.jsxs("span",{children:["DB: ",gb(p.database.size)]}),t.jsxs("span",{children:["Agents: ",p.agents.length]})]}),t.jsx("div",{className:"mt-2 text-[10px] text-fg-tertiary",children:"Click to view details in Settings"})]})]})]})]})]})}const lm={pending:"bg-amber-500",in_progress:"bg-brand-500",blocked:"bg-red-500",review:"bg-blue-500",completed:"bg-green-500",failed:"bg-red-500",rejected:"bg-red-500",cancelled:"bg-gray-600"},V2={pending:"text-amber-600",in_progress:"text-brand-500",blocked:"text-red-500",review:"text-blue-600",completed:"text-green-600",failed:"text-red-500",rejected:"text-red-500",cancelled:"text-fg-tertiary"};function Y2({statusCounts:e,total:r}){const s=Object.entries(e).filter(([,l])=>l>0).sort(([,l],[,o])=>o-l);return t.jsxs("div",{children:[t.jsx("div",{className:"flex h-4 rounded-full overflow-hidden gap-0.5 mb-4",children:s.map(([l,o])=>t.jsx("div",{className:`${lm[l]??"bg-gray-600"} transition-all`,style:{width:`${o/r*100}%`},title:`${l}: ${o}`},l))}),t.jsx("div",{className:"flex gap-4 flex-wrap",children:s.map(([l,o])=>t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:`w-2.5 h-2.5 rounded-sm ${lm[l]??"bg-gray-600"}`}),t.jsx("span",{className:"text-xs text-fg-secondary capitalize",children:l.replace(/_/g," ")}),t.jsx("span",{className:`text-xs font-semibold ${V2[l]??"text-fg-secondary"}`,children:o})]},l))})]})}function Jc({label:e,value:r,total:s,color:l,onClick:o}){const d={indigo:{text:"text-brand-500",border:"border-l-brand-500"},blue:{text:"text-blue-600",border:"border-l-blue-500"},amber:{text:"text-amber-600",border:"border-l-amber-500"},green:{text:"text-green-600",border:"border-l-green-500"}},c=d[l]??d.indigo;return t.jsxs("div",{onClick:o,className:`bg-surface-secondary border border-border-default ${c.border} border-l-2 rounded-xl p-5 cursor-pointer hover:bg-surface-elevated transition-all`,children:[t.jsx("div",{className:"text-xs text-fg-tertiary mb-2",children:e}),t.jsxs("div",{className:`text-3xl font-bold ${c.text}`,children:[r,s!==void 0&&t.jsxs("span",{className:"text-base font-normal text-fg-muted",children:["/",s]})]})]})}function Ji({label:e,value:r,max:s,unit:l,color:o,raw:d}){const c=s>0?Math.min(r/s*100,100):0,h={green:"bg-green-400",amber:"bg-amber-400",red:"bg-red-400",brand:"bg-brand-400",blue:"bg-blue-400"},m={green:"text-green-600",amber:"text-amber-600",red:"text-red-500",brand:"text-brand-500",blue:"text-blue-600"},f=h[o]??"bg-gray-400",x=m[o]??"text-fg-secondary";return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-baseline justify-between mb-1.5",children:[t.jsx("span",{className:"text-[11px] text-fg-tertiary",children:e}),t.jsx("span",{className:`text-sm font-semibold ${x}`,children:d?`${l}${r}`:t.jsxs(t.Fragment,{children:[r,t.jsx("span",{className:"text-[10px] font-normal text-fg-tertiary",children:l})]})})]}),t.jsx("div",{className:"w-full h-1.5 bg-surface-elevated rounded-full overflow-hidden",children:t.jsx("div",{className:`h-full rounded-full ${f} transition-all`,style:{width:`${c}%`}})})]})}function gb(e){if(e===0)return"0 B";const r=["B","KB","MB","GB"],s=Math.min(Math.floor(Math.log(e)/Math.log(1024)),r.length-1),l=e/Math.pow(1024,s);return`${l<10?l.toFixed(1):Math.round(l)} ${r[s]}`}function G2(e,r){const s={};return(e[e.length-1]===""?[...e,""]:e).join((s.padRight?" ":"")+","+(s.padLeft===!1?"":" ")).trim()}const X2=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Z2=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Q2={};function pb(e,r){return(Q2.jsx?Z2:X2).test(e)}const K2=/[ \t\n\f\r]/g;function J2(e){return typeof e=="object"?e.type==="text"?bb(e.value):!1:bb(e)}function bb(e){return e.replace(K2,"")===""}class Lo{constructor(r,s,l){this.normal=s,this.property=r,l&&(this.space=l)}}Lo.prototype.normal={};Lo.prototype.property={};Lo.prototype.space=void 0;function o1(e,r){const s={},l={};for(const o of e)Object.assign(s,o.property),Object.assign(l,o.normal);return new Lo(s,l,r)}function im(e){return e.toLowerCase()}class kr{constructor(r,s){this.attribute=s,this.property=r}}kr.prototype.attribute="";kr.prototype.booleanish=!1;kr.prototype.boolean=!1;kr.prototype.commaOrSpaceSeparated=!1;kr.prototype.commaSeparated=!1;kr.prototype.defined=!1;kr.prototype.mustUseProperty=!1;kr.prototype.number=!1;kr.prototype.overloadedBoolean=!1;kr.prototype.property="";kr.prototype.spaceSeparated=!1;kr.prototype.space=void 0;let W2=0;const Rt=cl(),Pn=cl(),om=cl(),$e=cl(),bn=cl(),Zl=cl(),zr=cl();function cl(){return 2**++W2}const cm=Object.freeze(Object.defineProperty({__proto__:null,boolean:Rt,booleanish:Pn,commaOrSpaceSeparated:zr,commaSeparated:Zl,number:$e,overloadedBoolean:om,spaceSeparated:bn},Symbol.toStringTag,{value:"Module"})),bh=Object.keys(cm);class Um extends kr{constructor(r,s,l,o){let d=-1;if(super(r,s),yb(this,"space",o),typeof l=="number")for(;++d<bh.length;){const c=bh[d];yb(this,bh[d],(l&cm[c])===cm[c])}}}Um.prototype.defined=!0;function yb(e,r,s){s&&(e[r]=s)}function oi(e){const r={},s={};for(const[l,o]of Object.entries(e.properties)){const d=new Um(l,e.transform(e.attributes||{},l),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(l)&&(d.mustUseProperty=!0),r[l]=d,s[im(l)]=l,s[im(d.attribute)]=l}return new Lo(r,s,e.space)}const c1=oi({properties:{ariaActiveDescendant:null,ariaAtomic:Pn,ariaAutoComplete:null,ariaBusy:Pn,ariaChecked:Pn,ariaColCount:$e,ariaColIndex:$e,ariaColSpan:$e,ariaControls:bn,ariaCurrent:null,ariaDescribedBy:bn,ariaDetails:null,ariaDisabled:Pn,ariaDropEffect:bn,ariaErrorMessage:null,ariaExpanded:Pn,ariaFlowTo:bn,ariaGrabbed:Pn,ariaHasPopup:null,ariaHidden:Pn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:bn,ariaLevel:$e,ariaLive:null,ariaModal:Pn,ariaMultiLine:Pn,ariaMultiSelectable:Pn,ariaOrientation:null,ariaOwns:bn,ariaPlaceholder:null,ariaPosInSet:$e,ariaPressed:Pn,ariaReadOnly:Pn,ariaRelevant:null,ariaRequired:Pn,ariaRoleDescription:bn,ariaRowCount:$e,ariaRowIndex:$e,ariaRowSpan:$e,ariaSelected:Pn,ariaSetSize:$e,ariaSort:null,ariaValueMax:$e,ariaValueMin:$e,ariaValueNow:$e,ariaValueText:null,role:null},transform(e,r){return r==="role"?r:"aria-"+r.slice(4).toLowerCase()}});function d1(e,r){return r in e?e[r]:r}function u1(e,r){return d1(e,r.toLowerCase())}const ek=oi({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Zl,acceptCharset:bn,accessKey:bn,action:null,allow:null,allowFullScreen:Rt,allowPaymentRequest:Rt,allowUserMedia:Rt,alt:null,as:null,async:Rt,autoCapitalize:null,autoComplete:bn,autoFocus:Rt,autoPlay:Rt,blocking:bn,capture:null,charSet:null,checked:Rt,cite:null,className:bn,cols:$e,colSpan:null,content:null,contentEditable:Pn,controls:Rt,controlsList:bn,coords:$e|Zl,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Rt,defer:Rt,dir:null,dirName:null,disabled:Rt,download:om,draggable:Pn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Rt,formTarget:null,headers:bn,height:$e,hidden:om,high:$e,href:null,hrefLang:null,htmlFor:bn,httpEquiv:bn,id:null,imageSizes:null,imageSrcSet:null,inert:Rt,inputMode:null,integrity:null,is:null,isMap:Rt,itemId:null,itemProp:bn,itemRef:bn,itemScope:Rt,itemType:bn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Rt,low:$e,manifest:null,max:null,maxLength:$e,media:null,method:null,min:null,minLength:$e,multiple:Rt,muted:Rt,name:null,nonce:null,noModule:Rt,noValidate:Rt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Rt,optimum:$e,pattern:null,ping:bn,placeholder:null,playsInline:Rt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Rt,referrerPolicy:null,rel:bn,required:Rt,reversed:Rt,rows:$e,rowSpan:$e,sandbox:bn,scope:null,scoped:Rt,seamless:Rt,selected:Rt,shadowRootClonable:Rt,shadowRootDelegatesFocus:Rt,shadowRootMode:null,shape:null,size:$e,sizes:null,slot:null,span:$e,spellCheck:Pn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:$e,step:null,style:null,tabIndex:$e,target:null,title:null,translate:null,type:null,typeMustMatch:Rt,useMap:null,value:Pn,width:$e,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:bn,axis:null,background:null,bgColor:null,border:$e,borderColor:null,bottomMargin:$e,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Rt,declare:Rt,event:null,face:null,frame:null,frameBorder:null,hSpace:$e,leftMargin:$e,link:null,longDesc:null,lowSrc:null,marginHeight:$e,marginWidth:$e,noResize:Rt,noHref:Rt,noShade:Rt,noWrap:Rt,object:null,profile:null,prompt:null,rev:null,rightMargin:$e,rules:null,scheme:null,scrolling:Pn,standby:null,summary:null,text:null,topMargin:$e,valueType:null,version:null,vAlign:null,vLink:null,vSpace:$e,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Rt,disableRemotePlayback:Rt,prefix:null,property:null,results:$e,security:null,unselectable:null},space:"html",transform:u1}),tk=oi({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:zr,accentHeight:$e,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:$e,amplitude:$e,arabicForm:null,ascent:$e,attributeName:null,attributeType:null,azimuth:$e,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:$e,by:null,calcMode:null,capHeight:$e,className:bn,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:$e,diffuseConstant:$e,direction:null,display:null,dur:null,divisor:$e,dominantBaseline:null,download:Rt,dx:null,dy:null,edgeMode:null,editable:null,elevation:$e,enableBackground:null,end:null,event:null,exponent:$e,externalResourcesRequired:null,fill:null,fillOpacity:$e,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Zl,g2:Zl,glyphName:Zl,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:$e,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:$e,horizOriginX:$e,horizOriginY:$e,id:null,ideographic:$e,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:$e,k:$e,k1:$e,k2:$e,k3:$e,k4:$e,kernelMatrix:zr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:$e,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:$e,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:$e,overlineThickness:$e,paintOrder:null,panose1:null,path:null,pathLength:$e,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:bn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:$e,pointsAtY:$e,pointsAtZ:$e,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:zr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:zr,rev:zr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:zr,requiredFeatures:zr,requiredFonts:zr,requiredFormats:zr,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:$e,specularExponent:$e,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:$e,strikethroughThickness:$e,string:null,stroke:null,strokeDashArray:zr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:$e,strokeOpacity:$e,strokeWidth:null,style:null,surfaceScale:$e,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:zr,tabIndex:$e,tableValues:null,target:null,targetX:$e,targetY:$e,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:zr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:$e,underlineThickness:$e,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:$e,values:null,vAlphabetic:$e,vMathematical:$e,vectorEffect:null,vHanging:$e,vIdeographic:$e,version:null,vertAdvY:$e,vertOriginX:$e,vertOriginY:$e,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:$e,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:d1}),f1=oi({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,r){return"xlink:"+r.slice(5).toLowerCase()}}),h1=oi({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:u1}),m1=oi({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,r){return"xml:"+r.slice(3).toLowerCase()}}),nk={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},rk=/[A-Z]/g,vb=/-[a-z]/g,sk=/^data[-\w.:]+$/i;function ak(e,r){const s=im(r);let l=r,o=kr;if(s in e.normal)return e.property[e.normal[s]];if(s.length>4&&s.slice(0,4)==="data"&&sk.test(r)){if(r.charAt(4)==="-"){const d=r.slice(5).replace(vb,ik);l="data"+d.charAt(0).toUpperCase()+d.slice(1)}else{const d=r.slice(4);if(!vb.test(d)){let c=d.replace(rk,lk);c.charAt(0)!=="-"&&(c="-"+c),r="data"+c}}o=Um}return new o(l,r)}function lk(e){return"-"+e.toLowerCase()}function ik(e){return e.charAt(1).toUpperCase()}const ok=o1([c1,ek,f1,h1,m1],"html"),qm=o1([c1,tk,f1,h1,m1],"svg");function ck(e){return e.join(" ").trim()}var Bl={},yh,jb;function dk(){if(jb)return yh;jb=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,s=/^\s*/,l=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,d=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,h=/^\s+|\s+$/g,m=`
|
|
11
|
+
`,f="/",x="*",g="",p="comment",y="declaration";function w(E,A){if(typeof E!="string")throw new TypeError("First argument must be a string");if(!E)return[];A=A||{};var C=1,k=1;function S(D){var z=D.match(r);z&&(C+=z.length);var _=D.lastIndexOf(m);k=~_?D.length-_:k+D.length}function O(){var D={line:C,column:k};return function(z){return z.position=new R(D),Q(),z}}function R(D){this.start=D,this.end={line:C,column:k},this.source=A.source}R.prototype.content=E;function G(D){var z=new Error(A.source+":"+C+":"+k+": "+D);if(z.reason=D,z.filename=A.source,z.line=C,z.column=k,z.source=E,!A.silent)throw z}function I(D){var z=D.exec(E);if(z){var _=z[0];return S(_),E=E.slice(_.length),z}}function Q(){I(s)}function $(D){var z;for(D=D||[];z=F();)z!==!1&&D.push(z);return D}function F(){var D=O();if(!(f!=E.charAt(0)||x!=E.charAt(1))){for(var z=2;g!=E.charAt(z)&&(x!=E.charAt(z)||f!=E.charAt(z+1));)++z;if(z+=2,g===E.charAt(z-1))return G("End of comment missing");var _=E.slice(2,z-2);return k+=2,S(_),E=E.slice(z),k+=2,D({type:p,comment:_})}}function B(){var D=O(),z=I(l);if(z){if(F(),!I(o))return G("property missing ':'");var _=I(d),Y=D({type:y,property:N(z[0].replace(e,g)),value:_?N(_[0].replace(e,g)):g});return I(c),Y}}function T(){var D=[];$(D);for(var z;z=B();)z!==!1&&(D.push(z),$(D));return D}return Q(),T()}function N(E){return E?E.replace(h,g):g}return yh=w,yh}var wb;function uk(){if(wb)return Bl;wb=1;var e=Bl&&Bl.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(Bl,"__esModule",{value:!0}),Bl.default=s;const r=e(dk());function s(l,o){let d=null;if(!l||typeof l!="string")return d;const c=(0,r.default)(l),h=typeof o=="function";return c.forEach(m=>{if(m.type!=="declaration")return;const{property:f,value:x}=m;h?o(f,x,m):x&&(d=d||{},d[f]=x)}),d}return Bl}var Wi={},Nb;function fk(){if(Nb)return Wi;Nb=1,Object.defineProperty(Wi,"__esModule",{value:!0}),Wi.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,r=/-([a-z])/g,s=/^[^-]+$/,l=/^-(webkit|moz|ms|o|khtml)-/,o=/^-(ms)-/,d=function(f){return!f||s.test(f)||e.test(f)},c=function(f,x){return x.toUpperCase()},h=function(f,x){return"".concat(x,"-")},m=function(f,x){return x===void 0&&(x={}),d(f)?f:(f=f.toLowerCase(),x.reactCompat?f=f.replace(o,h):f=f.replace(l,h),f.replace(r,c))};return Wi.camelCase=m,Wi}var eo,kb;function hk(){if(kb)return eo;kb=1;var e=eo&&eo.__importDefault||function(o){return o&&o.__esModule?o:{default:o}},r=e(uk()),s=fk();function l(o,d){var c={};return!o||typeof o!="string"||(0,r.default)(o,function(h,m){h&&m&&(c[(0,s.camelCase)(h,d)]=m)}),c}return l.default=l,eo=l,eo}var mk=hk();const xk=Fd(mk),x1=g1("end"),Fm=g1("start");function g1(e){return r;function r(s){const l=s&&s.position&&s.position[e]||{};if(typeof l.line=="number"&&l.line>0&&typeof l.column=="number"&&l.column>0)return{line:l.line,column:l.column,offset:typeof l.offset=="number"&&l.offset>-1?l.offset:void 0}}}function gk(e){const r=Fm(e),s=x1(e);if(r&&s)return{start:r,end:s}}function mo(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Sb(e.position):"start"in e||"end"in e?Sb(e):"line"in e||"column"in e?dm(e):""}function dm(e){return Cb(e&&e.line)+":"+Cb(e&&e.column)}function Sb(e){return dm(e&&e.start)+"-"+dm(e&&e.end)}function Cb(e){return e&&typeof e=="number"?e:1}class ir extends Error{constructor(r,s,l){super(),typeof s=="string"&&(l=s,s=void 0);let o="",d={},c=!1;if(s&&("line"in s&&"column"in s?d={place:s}:"start"in s&&"end"in s?d={place:s}:"type"in s?d={ancestors:[s],place:s.position}:d={...s}),typeof r=="string"?o=r:!d.cause&&r&&(c=!0,o=r.message,d.cause=r),!d.ruleId&&!d.source&&typeof l=="string"){const m=l.indexOf(":");m===-1?d.ruleId=l:(d.source=l.slice(0,m),d.ruleId=l.slice(m+1))}if(!d.place&&d.ancestors&&d.ancestors){const m=d.ancestors[d.ancestors.length-1];m&&(d.place=m.position)}const h=d.place&&"start"in d.place?d.place.start:d.place;this.ancestors=d.ancestors||void 0,this.cause=d.cause||void 0,this.column=h?h.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=h?h.line:void 0,this.name=mo(d.place)||"1:1",this.place=d.place||void 0,this.reason=this.message,this.ruleId=d.ruleId||void 0,this.source=d.source||void 0,this.stack=c&&d.cause&&typeof d.cause.stack=="string"?d.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}ir.prototype.file="";ir.prototype.name="";ir.prototype.reason="";ir.prototype.message="";ir.prototype.stack="";ir.prototype.column=void 0;ir.prototype.line=void 0;ir.prototype.ancestors=void 0;ir.prototype.cause=void 0;ir.prototype.fatal=void 0;ir.prototype.place=void 0;ir.prototype.ruleId=void 0;ir.prototype.source=void 0;const Vm={}.hasOwnProperty,pk=new Map,bk=/[A-Z]/g,yk=new Set(["table","tbody","thead","tfoot","tr"]),vk=new Set(["td","th"]),p1="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function jk(e,r){if(!r||r.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const s=r.filePath||void 0;let l;if(r.development){if(typeof r.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");l=Ak(s,r.jsxDEV)}else{if(typeof r.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof r.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");l=Tk(s,r.jsx,r.jsxs)}const o={Fragment:r.Fragment,ancestors:[],components:r.components||{},create:l,elementAttributeNameCase:r.elementAttributeNameCase||"react",evaluater:r.createEvaluater?r.createEvaluater():void 0,filePath:s,ignoreInvalidStyle:r.ignoreInvalidStyle||!1,passKeys:r.passKeys!==!1,passNode:r.passNode||!1,schema:r.space==="svg"?qm:ok,stylePropertyNameCase:r.stylePropertyNameCase||"dom",tableCellAlignToStyle:r.tableCellAlignToStyle!==!1},d=b1(o,e,void 0);return d&&typeof d!="string"?d:o.create(e,o.Fragment,{children:d||void 0},void 0)}function b1(e,r,s){if(r.type==="element")return wk(e,r,s);if(r.type==="mdxFlowExpression"||r.type==="mdxTextExpression")return Nk(e,r);if(r.type==="mdxJsxFlowElement"||r.type==="mdxJsxTextElement")return Sk(e,r,s);if(r.type==="mdxjsEsm")return kk(e,r);if(r.type==="root")return Ck(e,r,s);if(r.type==="text")return Ek(e,r)}function wk(e,r,s){const l=e.schema;let o=l;r.tagName.toLowerCase()==="svg"&&l.space==="html"&&(o=qm,e.schema=o),e.ancestors.push(r);const d=v1(e,r.tagName,!1),c=_k(e,r);let h=Gm(e,r);return yk.has(r.tagName)&&(h=h.filter(function(m){return typeof m=="string"?!J2(m):!0})),y1(e,c,d,r),Ym(c,h),e.ancestors.pop(),e.schema=l,e.create(r,d,c,s)}function Nk(e,r){if(r.data&&r.data.estree&&e.evaluater){const l=r.data.estree.body[0];return l.type,e.evaluater.evaluateExpression(l.expression)}jo(e,r.position)}function kk(e,r){if(r.data&&r.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(r.data.estree);jo(e,r.position)}function Sk(e,r,s){const l=e.schema;let o=l;r.name==="svg"&&l.space==="html"&&(o=qm,e.schema=o),e.ancestors.push(r);const d=r.name===null?e.Fragment:v1(e,r.name,!0),c=Mk(e,r),h=Gm(e,r);return y1(e,c,d,r),Ym(c,h),e.ancestors.pop(),e.schema=l,e.create(r,d,c,s)}function Ck(e,r,s){const l={};return Ym(l,Gm(e,r)),e.create(r,e.Fragment,l,s)}function Ek(e,r){return r.value}function y1(e,r,s,l){typeof s!="string"&&s!==e.Fragment&&e.passNode&&(r.node=l)}function Ym(e,r){if(r.length>0){const s=r.length>1?r:r[0];s&&(e.children=s)}}function Tk(e,r,s){return l;function l(o,d,c,h){const f=Array.isArray(c.children)?s:r;return h?f(d,c,h):f(d,c)}}function Ak(e,r){return s;function s(l,o,d,c){const h=Array.isArray(d.children),m=Fm(l);return r(o,d,c,h,{columnNumber:m?m.column-1:void 0,fileName:e,lineNumber:m?m.line:void 0},void 0)}}function _k(e,r){const s={};let l,o;for(o in r.properties)if(o!=="children"&&Vm.call(r.properties,o)){const d=Dk(e,o,r.properties[o]);if(d){const[c,h]=d;e.tableCellAlignToStyle&&c==="align"&&typeof h=="string"&&vk.has(r.tagName)?l=h:s[c]=h}}if(l){const d=s.style||(s.style={});d[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=l}return s}function Mk(e,r){const s={};for(const l of r.attributes)if(l.type==="mdxJsxExpressionAttribute")if(l.data&&l.data.estree&&e.evaluater){const d=l.data.estree.body[0];d.type;const c=d.expression;c.type;const h=c.properties[0];h.type,Object.assign(s,e.evaluater.evaluateExpression(h.argument))}else jo(e,r.position);else{const o=l.name;let d;if(l.value&&typeof l.value=="object")if(l.value.data&&l.value.data.estree&&e.evaluater){const h=l.value.data.estree.body[0];h.type,d=e.evaluater.evaluateExpression(h.expression)}else jo(e,r.position);else d=l.value===null?!0:l.value;s[o]=d}return s}function Gm(e,r){const s=[];let l=-1;const o=e.passKeys?new Map:pk;for(;++l<r.children.length;){const d=r.children[l];let c;if(e.passKeys){const m=d.type==="element"?d.tagName:d.type==="mdxJsxFlowElement"||d.type==="mdxJsxTextElement"?d.name:void 0;if(m){const f=o.get(m)||0;c=m+"-"+f,o.set(m,f+1)}}const h=b1(e,d,c);h!==void 0&&s.push(h)}return s}function Dk(e,r,s){const l=ak(e.schema,r);if(!(s==null||typeof s=="number"&&Number.isNaN(s))){if(Array.isArray(s)&&(s=l.commaSeparated?G2(s):ck(s)),l.property==="style"){let o=typeof s=="object"?s:Ok(e,String(s));return e.stylePropertyNameCase==="css"&&(o=Rk(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&l.space?nk[l.property]||l.property:l.attribute,s]}}function Ok(e,r){try{return xk(r,{reactCompat:!0})}catch(s){if(e.ignoreInvalidStyle)return{};const l=s,o=new ir("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:l,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw o.file=e.filePath||void 0,o.url=p1+"#cannot-parse-style-attribute",o}}function v1(e,r,s){let l;if(!s)l={type:"Literal",value:r};else if(r.includes(".")){const o=r.split(".");let d=-1,c;for(;++d<o.length;){const h=pb(o[d])?{type:"Identifier",name:o[d]}:{type:"Literal",value:o[d]};c=c?{type:"MemberExpression",object:c,property:h,computed:!!(d&&h.type==="Literal"),optional:!1}:h}l=c}else l=pb(r)&&!/^[a-z]/.test(r)?{type:"Identifier",name:r}:{type:"Literal",value:r};if(l.type==="Literal"){const o=l.value;return Vm.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(l);jo(e)}function jo(e,r){const s=new ir("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:r,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw s.file=e.filePath||void 0,s.url=p1+"#cannot-handle-mdx-estrees-without-createevaluater",s}function Rk(e){const r={};let s;for(s in e)Vm.call(e,s)&&(r[Lk(s)]=e[s]);return r}function Lk(e){let r=e.replace(bk,zk);return r.slice(0,3)==="ms-"&&(r="-"+r),r}function zk(e){return"-"+e.toLowerCase()}const vh={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},Ik={};function Xm(e,r){const s=Ik,l=typeof s.includeImageAlt=="boolean"?s.includeImageAlt:!0,o=typeof s.includeHtml=="boolean"?s.includeHtml:!0;return j1(e,l,o)}function j1(e,r,s){if($k(e)){if("value"in e)return e.type==="html"&&!s?"":e.value;if(r&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Eb(e.children,r,s)}return Array.isArray(e)?Eb(e,r,s):""}function Eb(e,r,s){const l=[];let o=-1;for(;++o<e.length;)l[o]=j1(e[o],r,s);return l.join("")}function $k(e){return!!(e&&typeof e=="object")}const Tb=document.createElement("i");function Zm(e){const r="&"+e+";";Tb.innerHTML=r;const s=Tb.textContent;return s.charCodeAt(s.length-1)===59&&e!=="semi"||s===r?!1:s}function $r(e,r,s,l){const o=e.length;let d=0,c;if(r<0?r=-r>o?0:o+r:r=r>o?o:r,s=s>0?s:0,l.length<1e4)c=Array.from(l),c.unshift(r,s),e.splice(...c);else for(s&&e.splice(r,s);d<l.length;)c=l.slice(d,d+1e4),c.unshift(r,0),e.splice(...c),d+=1e4,r+=1e4}function Qr(e,r){return e.length>0?($r(e,e.length,0,r),e):r}const Ab={}.hasOwnProperty;function w1(e){const r={};let s=-1;for(;++s<e.length;)Bk(r,e[s]);return r}function Bk(e,r){let s;for(s in r){const o=(Ab.call(e,s)?e[s]:void 0)||(e[s]={}),d=r[s];let c;if(d)for(c in d){Ab.call(o,c)||(o[c]=[]);const h=d[c];Hk(o[c],Array.isArray(h)?h:h?[h]:[])}}}function Hk(e,r){let s=-1;const l=[];for(;++s<r.length;)(r[s].add==="after"?e:l).push(r[s]);$r(e,0,0,l)}function N1(e,r){const s=Number.parseInt(e,r);return s<9||s===11||s>13&&s<32||s>126&&s<160||s>55295&&s<57344||s>64975&&s<65008||(s&65535)===65535||(s&65535)===65534||s>1114111?"�":String.fromCodePoint(s)}function as(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const fr=Da(/[A-Za-z]/),lr=Da(/[\dA-Za-z]/),Pk=Da(/[#-'*+\--9=?A-Z^-~]/);function wd(e){return e!==null&&(e<32||e===127)}const um=Da(/\d/),Uk=Da(/[\dA-Fa-f]/),qk=Da(/[!-/:-@[-`{-~]/);function mt(e){return e!==null&&e<-2}function pn(e){return e!==null&&(e<0||e===32)}function Bt(e){return e===-2||e===-1||e===32}const Vd=Da(new RegExp("\\p{P}|\\p{S}","u")),rl=Da(/\s/);function Da(e){return r;function r(s){return s!==null&&s>-1&&e.test(String.fromCharCode(s))}}function ci(e){const r=[];let s=-1,l=0,o=0;for(;++s<e.length;){const d=e.charCodeAt(s);let c="";if(d===37&&lr(e.charCodeAt(s+1))&&lr(e.charCodeAt(s+2)))o=2;else if(d<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(d))||(c=String.fromCharCode(d));else if(d>55295&&d<57344){const h=e.charCodeAt(s+1);d<56320&&h>56319&&h<57344?(c=String.fromCharCode(d,h),o=1):c="�"}else c=String.fromCharCode(d);c&&(r.push(e.slice(l,s),encodeURIComponent(c)),l=s+o+1,c=""),o&&(s+=o,o=0)}return r.join("")+e.slice(l)}function Ft(e,r,s,l){const o=l?l-1:Number.POSITIVE_INFINITY;let d=0;return c;function c(m){return Bt(m)?(e.enter(s),h(m)):r(m)}function h(m){return Bt(m)&&d++<o?(e.consume(m),h):(e.exit(s),r(m))}}const Fk={tokenize:Vk};function Vk(e){const r=e.attempt(this.parser.constructs.contentInitial,l,o);let s;return r;function l(h){if(h===null){e.consume(h);return}return e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),Ft(e,r,"linePrefix")}function o(h){return e.enter("paragraph"),d(h)}function d(h){const m=e.enter("chunkText",{contentType:"text",previous:s});return s&&(s.next=m),s=m,c(h)}function c(h){if(h===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(h);return}return mt(h)?(e.consume(h),e.exit("chunkText"),d):(e.consume(h),c)}}const Yk={tokenize:Gk},_b={tokenize:Xk};function Gk(e){const r=this,s=[];let l=0,o,d,c;return h;function h(k){if(l<s.length){const S=s[l];return r.containerState=S[1],e.attempt(S[0].continuation,m,f)(k)}return f(k)}function m(k){if(l++,r.containerState._closeFlow){r.containerState._closeFlow=void 0,o&&C();const S=r.events.length;let O=S,R;for(;O--;)if(r.events[O][0]==="exit"&&r.events[O][1].type==="chunkFlow"){R=r.events[O][1].end;break}A(l);let G=S;for(;G<r.events.length;)r.events[G][1].end={...R},G++;return $r(r.events,O+1,0,r.events.slice(S)),r.events.length=G,f(k)}return h(k)}function f(k){if(l===s.length){if(!o)return p(k);if(o.currentConstruct&&o.currentConstruct.concrete)return w(k);r.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return r.containerState={},e.check(_b,x,g)(k)}function x(k){return o&&C(),A(l),p(k)}function g(k){return r.parser.lazy[r.now().line]=l!==s.length,c=r.now().offset,w(k)}function p(k){return r.containerState={},e.attempt(_b,y,w)(k)}function y(k){return l++,s.push([r.currentConstruct,r.containerState]),p(k)}function w(k){if(k===null){o&&C(),A(0),e.consume(k);return}return o=o||r.parser.flow(r.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:d}),N(k)}function N(k){if(k===null){E(e.exit("chunkFlow"),!0),A(0),e.consume(k);return}return mt(k)?(e.consume(k),E(e.exit("chunkFlow")),l=0,r.interrupt=void 0,h):(e.consume(k),N)}function E(k,S){const O=r.sliceStream(k);if(S&&O.push(null),k.previous=d,d&&(d.next=k),d=k,o.defineSkip(k.start),o.write(O),r.parser.lazy[k.start.line]){let R=o.events.length;for(;R--;)if(o.events[R][1].start.offset<c&&(!o.events[R][1].end||o.events[R][1].end.offset>c))return;const G=r.events.length;let I=G,Q,$;for(;I--;)if(r.events[I][0]==="exit"&&r.events[I][1].type==="chunkFlow"){if(Q){$=r.events[I][1].end;break}Q=!0}for(A(l),R=G;R<r.events.length;)r.events[R][1].end={...$},R++;$r(r.events,I+1,0,r.events.slice(G)),r.events.length=R}}function A(k){let S=s.length;for(;S-- >k;){const O=s[S];r.containerState=O[1],O[0].exit.call(r,e)}s.length=k}function C(){o.write([null]),d=void 0,o=void 0,r.containerState._closeFlow=void 0}}function Xk(e,r,s){return Ft(e,e.attempt(this.parser.constructs.document,r,s),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Jl(e){if(e===null||pn(e)||rl(e))return 1;if(Vd(e))return 2}function Yd(e,r,s){const l=[];let o=-1;for(;++o<e.length;){const d=e[o].resolveAll;d&&!l.includes(d)&&(r=d(r,s),l.push(d))}return r}const fm={name:"attention",resolveAll:Zk,tokenize:Qk};function Zk(e,r){let s=-1,l,o,d,c,h,m,f,x;for(;++s<e.length;)if(e[s][0]==="enter"&&e[s][1].type==="attentionSequence"&&e[s][1]._close){for(l=s;l--;)if(e[l][0]==="exit"&&e[l][1].type==="attentionSequence"&&e[l][1]._open&&r.sliceSerialize(e[l][1]).charCodeAt(0)===r.sliceSerialize(e[s][1]).charCodeAt(0)){if((e[l][1]._close||e[s][1]._open)&&(e[s][1].end.offset-e[s][1].start.offset)%3&&!((e[l][1].end.offset-e[l][1].start.offset+e[s][1].end.offset-e[s][1].start.offset)%3))continue;m=e[l][1].end.offset-e[l][1].start.offset>1&&e[s][1].end.offset-e[s][1].start.offset>1?2:1;const g={...e[l][1].end},p={...e[s][1].start};Mb(g,-m),Mb(p,m),c={type:m>1?"strongSequence":"emphasisSequence",start:g,end:{...e[l][1].end}},h={type:m>1?"strongSequence":"emphasisSequence",start:{...e[s][1].start},end:p},d={type:m>1?"strongText":"emphasisText",start:{...e[l][1].end},end:{...e[s][1].start}},o={type:m>1?"strong":"emphasis",start:{...c.start},end:{...h.end}},e[l][1].end={...c.start},e[s][1].start={...h.end},f=[],e[l][1].end.offset-e[l][1].start.offset&&(f=Qr(f,[["enter",e[l][1],r],["exit",e[l][1],r]])),f=Qr(f,[["enter",o,r],["enter",c,r],["exit",c,r],["enter",d,r]]),f=Qr(f,Yd(r.parser.constructs.insideSpan.null,e.slice(l+1,s),r)),f=Qr(f,[["exit",d,r],["enter",h,r],["exit",h,r],["exit",o,r]]),e[s][1].end.offset-e[s][1].start.offset?(x=2,f=Qr(f,[["enter",e[s][1],r],["exit",e[s][1],r]])):x=0,$r(e,l-1,s-l+3,f),s=l+f.length-x-2;break}}for(s=-1;++s<e.length;)e[s][1].type==="attentionSequence"&&(e[s][1].type="data");return e}function Qk(e,r){const s=this.parser.constructs.attentionMarkers.null,l=this.previous,o=Jl(l);let d;return c;function c(m){return d=m,e.enter("attentionSequence"),h(m)}function h(m){if(m===d)return e.consume(m),h;const f=e.exit("attentionSequence"),x=Jl(m),g=!x||x===2&&o||s.includes(m),p=!o||o===2&&x||s.includes(l);return f._open=!!(d===42?g:g&&(o||!p)),f._close=!!(d===42?p:p&&(x||!g)),r(m)}}function Mb(e,r){e.column+=r,e.offset+=r,e._bufferIndex+=r}const Kk={name:"autolink",tokenize:Jk};function Jk(e,r,s){let l=0;return o;function o(y){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),d}function d(y){return fr(y)?(e.consume(y),c):y===64?s(y):f(y)}function c(y){return y===43||y===45||y===46||lr(y)?(l=1,h(y)):f(y)}function h(y){return y===58?(e.consume(y),l=0,m):(y===43||y===45||y===46||lr(y))&&l++<32?(e.consume(y),h):(l=0,f(y))}function m(y){return y===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),r):y===null||y===32||y===60||wd(y)?s(y):(e.consume(y),m)}function f(y){return y===64?(e.consume(y),x):Pk(y)?(e.consume(y),f):s(y)}function x(y){return lr(y)?g(y):s(y)}function g(y){return y===46?(e.consume(y),l=0,x):y===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),r):p(y)}function p(y){if((y===45||lr(y))&&l++<63){const w=y===45?p:g;return e.consume(y),w}return s(y)}}const zo={partial:!0,tokenize:Wk};function Wk(e,r,s){return l;function l(d){return Bt(d)?Ft(e,o,"linePrefix")(d):o(d)}function o(d){return d===null||mt(d)?r(d):s(d)}}const k1={continuation:{tokenize:tS},exit:nS,name:"blockQuote",tokenize:eS};function eS(e,r,s){const l=this;return o;function o(c){if(c===62){const h=l.containerState;return h.open||(e.enter("blockQuote",{_container:!0}),h.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(c),e.exit("blockQuoteMarker"),d}return s(c)}function d(c){return Bt(c)?(e.enter("blockQuotePrefixWhitespace"),e.consume(c),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),r):(e.exit("blockQuotePrefix"),r(c))}}function tS(e,r,s){const l=this;return o;function o(c){return Bt(c)?Ft(e,d,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c):d(c)}function d(c){return e.attempt(k1,r,s)(c)}}function nS(e){e.exit("blockQuote")}const S1={name:"characterEscape",tokenize:rS};function rS(e,r,s){return l;function l(d){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(d),e.exit("escapeMarker"),o}function o(d){return qk(d)?(e.enter("characterEscapeValue"),e.consume(d),e.exit("characterEscapeValue"),e.exit("characterEscape"),r):s(d)}}const C1={name:"characterReference",tokenize:sS};function sS(e,r,s){const l=this;let o=0,d,c;return h;function h(g){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),m}function m(g){return g===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(g),e.exit("characterReferenceMarkerNumeric"),f):(e.enter("characterReferenceValue"),d=31,c=lr,x(g))}function f(g){return g===88||g===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(g),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),d=6,c=Uk,x):(e.enter("characterReferenceValue"),d=7,c=um,x(g))}function x(g){if(g===59&&o){const p=e.exit("characterReferenceValue");return c===lr&&!Zm(l.sliceSerialize(p))?s(g):(e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),e.exit("characterReference"),r)}return c(g)&&o++<d?(e.consume(g),x):s(g)}}const Db={partial:!0,tokenize:lS},Ob={concrete:!0,name:"codeFenced",tokenize:aS};function aS(e,r,s){const l=this,o={partial:!0,tokenize:O};let d=0,c=0,h;return m;function m(R){return f(R)}function f(R){const G=l.events[l.events.length-1];return d=G&&G[1].type==="linePrefix"?G[2].sliceSerialize(G[1],!0).length:0,h=R,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),x(R)}function x(R){return R===h?(c++,e.consume(R),x):c<3?s(R):(e.exit("codeFencedFenceSequence"),Bt(R)?Ft(e,g,"whitespace")(R):g(R))}function g(R){return R===null||mt(R)?(e.exit("codeFencedFence"),l.interrupt?r(R):e.check(Db,N,S)(R)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(R))}function p(R){return R===null||mt(R)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),g(R)):Bt(R)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ft(e,y,"whitespace")(R)):R===96&&R===h?s(R):(e.consume(R),p)}function y(R){return R===null||mt(R)?g(R):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),w(R))}function w(R){return R===null||mt(R)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),g(R)):R===96&&R===h?s(R):(e.consume(R),w)}function N(R){return e.attempt(o,S,E)(R)}function E(R){return e.enter("lineEnding"),e.consume(R),e.exit("lineEnding"),A}function A(R){return d>0&&Bt(R)?Ft(e,C,"linePrefix",d+1)(R):C(R)}function C(R){return R===null||mt(R)?e.check(Db,N,S)(R):(e.enter("codeFlowValue"),k(R))}function k(R){return R===null||mt(R)?(e.exit("codeFlowValue"),C(R)):(e.consume(R),k)}function S(R){return e.exit("codeFenced"),r(R)}function O(R,G,I){let Q=0;return $;function $(z){return R.enter("lineEnding"),R.consume(z),R.exit("lineEnding"),F}function F(z){return R.enter("codeFencedFence"),Bt(z)?Ft(R,B,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(z):B(z)}function B(z){return z===h?(R.enter("codeFencedFenceSequence"),T(z)):I(z)}function T(z){return z===h?(Q++,R.consume(z),T):Q>=c?(R.exit("codeFencedFenceSequence"),Bt(z)?Ft(R,D,"whitespace")(z):D(z)):I(z)}function D(z){return z===null||mt(z)?(R.exit("codeFencedFence"),G(z)):I(z)}}}function lS(e,r,s){const l=this;return o;function o(c){return c===null?s(c):(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),d)}function d(c){return l.parser.lazy[l.now().line]?s(c):r(c)}}const jh={name:"codeIndented",tokenize:oS},iS={partial:!0,tokenize:cS};function oS(e,r,s){const l=this;return o;function o(f){return e.enter("codeIndented"),Ft(e,d,"linePrefix",5)(f)}function d(f){const x=l.events[l.events.length-1];return x&&x[1].type==="linePrefix"&&x[2].sliceSerialize(x[1],!0).length>=4?c(f):s(f)}function c(f){return f===null?m(f):mt(f)?e.attempt(iS,c,m)(f):(e.enter("codeFlowValue"),h(f))}function h(f){return f===null||mt(f)?(e.exit("codeFlowValue"),c(f)):(e.consume(f),h)}function m(f){return e.exit("codeIndented"),r(f)}}function cS(e,r,s){const l=this;return o;function o(c){return l.parser.lazy[l.now().line]?s(c):mt(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o):Ft(e,d,"linePrefix",5)(c)}function d(c){const h=l.events[l.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?r(c):mt(c)?o(c):s(c)}}const dS={name:"codeText",previous:fS,resolve:uS,tokenize:hS};function uS(e){let r=e.length-4,s=3,l,o;if((e[s][1].type==="lineEnding"||e[s][1].type==="space")&&(e[r][1].type==="lineEnding"||e[r][1].type==="space")){for(l=s;++l<r;)if(e[l][1].type==="codeTextData"){e[s][1].type="codeTextPadding",e[r][1].type="codeTextPadding",s+=2,r-=2;break}}for(l=s-1,r++;++l<=r;)o===void 0?l!==r&&e[l][1].type!=="lineEnding"&&(o=l):(l===r||e[l][1].type==="lineEnding")&&(e[o][1].type="codeTextData",l!==o+2&&(e[o][1].end=e[l-1][1].end,e.splice(o+2,l-o-2),r-=l-o-2,l=o+2),o=void 0);return e}function fS(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function hS(e,r,s){let l=0,o,d;return c;function c(g){return e.enter("codeText"),e.enter("codeTextSequence"),h(g)}function h(g){return g===96?(e.consume(g),l++,h):(e.exit("codeTextSequence"),m(g))}function m(g){return g===null?s(g):g===32?(e.enter("space"),e.consume(g),e.exit("space"),m):g===96?(d=e.enter("codeTextSequence"),o=0,x(g)):mt(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),m):(e.enter("codeTextData"),f(g))}function f(g){return g===null||g===32||g===96||mt(g)?(e.exit("codeTextData"),m(g)):(e.consume(g),f)}function x(g){return g===96?(e.consume(g),o++,x):o===l?(e.exit("codeTextSequence"),e.exit("codeText"),r(g)):(d.type="codeTextData",f(g))}}class mS{constructor(r){this.left=r?[...r]:[],this.right=[]}get(r){if(r<0||r>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+r+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return r<this.left.length?this.left[r]:this.right[this.right.length-r+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(r,s){const l=s??Number.POSITIVE_INFINITY;return l<this.left.length?this.left.slice(r,l):r>this.left.length?this.right.slice(this.right.length-l+this.left.length,this.right.length-r+this.left.length).reverse():this.left.slice(r).concat(this.right.slice(this.right.length-l+this.left.length).reverse())}splice(r,s,l){const o=s||0;this.setCursor(Math.trunc(r));const d=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return l&&to(this.left,l),d.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(r){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(r)}pushMany(r){this.setCursor(Number.POSITIVE_INFINITY),to(this.left,r)}unshift(r){this.setCursor(0),this.right.push(r)}unshiftMany(r){this.setCursor(0),to(this.right,r.reverse())}setCursor(r){if(!(r===this.left.length||r>this.left.length&&this.right.length===0||r<0&&this.left.length===0))if(r<this.left.length){const s=this.left.splice(r,Number.POSITIVE_INFINITY);to(this.right,s.reverse())}else{const s=this.right.splice(this.left.length+this.right.length-r,Number.POSITIVE_INFINITY);to(this.left,s.reverse())}}}function to(e,r){let s=0;if(r.length<1e4)e.push(...r);else for(;s<r.length;)e.push(...r.slice(s,s+1e4)),s+=1e4}function E1(e){const r={};let s=-1,l,o,d,c,h,m,f;const x=new mS(e);for(;++s<x.length;){for(;s in r;)s=r[s];if(l=x.get(s),s&&l[1].type==="chunkFlow"&&x.get(s-1)[1].type==="listItemPrefix"&&(m=l[1]._tokenizer.events,d=0,d<m.length&&m[d][1].type==="lineEndingBlank"&&(d+=2),d<m.length&&m[d][1].type==="content"))for(;++d<m.length&&m[d][1].type!=="content";)m[d][1].type==="chunkText"&&(m[d][1]._isInFirstContentOfListItem=!0,d++);if(l[0]==="enter")l[1].contentType&&(Object.assign(r,xS(x,s)),s=r[s],f=!0);else if(l[1]._container){for(d=s,o=void 0;d--;)if(c=x.get(d),c[1].type==="lineEnding"||c[1].type==="lineEndingBlank")c[0]==="enter"&&(o&&(x.get(o)[1].type="lineEndingBlank"),c[1].type="lineEnding",o=d);else if(!(c[1].type==="linePrefix"||c[1].type==="listItemIndent"))break;o&&(l[1].end={...x.get(o)[1].start},h=x.slice(o,s),h.unshift(l),x.splice(o,s-o+1,h))}}return $r(e,0,Number.POSITIVE_INFINITY,x.slice(0)),!f}function xS(e,r){const s=e.get(r)[1],l=e.get(r)[2];let o=r-1;const d=[];let c=s._tokenizer;c||(c=l.parser[s.contentType](s.start),s._contentTypeTextTrailing&&(c._contentTypeTextTrailing=!0));const h=c.events,m=[],f={};let x,g,p=-1,y=s,w=0,N=0;const E=[N];for(;y;){for(;e.get(++o)[1]!==y;);d.push(o),y._tokenizer||(x=l.sliceStream(y),y.next||x.push(null),g&&c.defineSkip(y.start),y._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=!0),c.write(x),y._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=void 0)),g=y,y=y.next}for(y=s;++p<h.length;)h[p][0]==="exit"&&h[p-1][0]==="enter"&&h[p][1].type===h[p-1][1].type&&h[p][1].start.line!==h[p][1].end.line&&(N=p+1,E.push(N),y._tokenizer=void 0,y.previous=void 0,y=y.next);for(c.events=[],y?(y._tokenizer=void 0,y.previous=void 0):E.pop(),p=E.length;p--;){const A=h.slice(E[p],E[p+1]),C=d.pop();m.push([C,C+A.length-1]),e.splice(C,2,A)}for(m.reverse(),p=-1;++p<m.length;)f[w+m[p][0]]=w+m[p][1],w+=m[p][1]-m[p][0]-1;return f}const gS={resolve:bS,tokenize:yS},pS={partial:!0,tokenize:vS};function bS(e){return E1(e),e}function yS(e,r){let s;return l;function l(h){return e.enter("content"),s=e.enter("chunkContent",{contentType:"content"}),o(h)}function o(h){return h===null?d(h):mt(h)?e.check(pS,c,d)(h):(e.consume(h),o)}function d(h){return e.exit("chunkContent"),e.exit("content"),r(h)}function c(h){return e.consume(h),e.exit("chunkContent"),s.next=e.enter("chunkContent",{contentType:"content",previous:s}),s=s.next,o}}function vS(e,r,s){const l=this;return o;function o(c){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),Ft(e,d,"linePrefix")}function d(c){if(c===null||mt(c))return s(c);const h=l.events[l.events.length-1];return!l.parser.constructs.disable.null.includes("codeIndented")&&h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?r(c):e.interrupt(l.parser.constructs.flow,s,r)(c)}}function T1(e,r,s,l,o,d,c,h,m){const f=m||Number.POSITIVE_INFINITY;let x=0;return g;function g(A){return A===60?(e.enter(l),e.enter(o),e.enter(d),e.consume(A),e.exit(d),p):A===null||A===32||A===41||wd(A)?s(A):(e.enter(l),e.enter(c),e.enter(h),e.enter("chunkString",{contentType:"string"}),N(A))}function p(A){return A===62?(e.enter(d),e.consume(A),e.exit(d),e.exit(o),e.exit(l),r):(e.enter(h),e.enter("chunkString",{contentType:"string"}),y(A))}function y(A){return A===62?(e.exit("chunkString"),e.exit(h),p(A)):A===null||A===60||mt(A)?s(A):(e.consume(A),A===92?w:y)}function w(A){return A===60||A===62||A===92?(e.consume(A),y):y(A)}function N(A){return!x&&(A===null||A===41||pn(A))?(e.exit("chunkString"),e.exit(h),e.exit(c),e.exit(l),r(A)):x<f&&A===40?(e.consume(A),x++,N):A===41?(e.consume(A),x--,N):A===null||A===32||A===40||wd(A)?s(A):(e.consume(A),A===92?E:N)}function E(A){return A===40||A===41||A===92?(e.consume(A),N):N(A)}}function A1(e,r,s,l,o,d){const c=this;let h=0,m;return f;function f(y){return e.enter(l),e.enter(o),e.consume(y),e.exit(o),e.enter(d),x}function x(y){return h>999||y===null||y===91||y===93&&!m||y===94&&!h&&"_hiddenFootnoteSupport"in c.parser.constructs?s(y):y===93?(e.exit(d),e.enter(o),e.consume(y),e.exit(o),e.exit(l),r):mt(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),x):(e.enter("chunkString",{contentType:"string"}),g(y))}function g(y){return y===null||y===91||y===93||mt(y)||h++>999?(e.exit("chunkString"),x(y)):(e.consume(y),m||(m=!Bt(y)),y===92?p:g)}function p(y){return y===91||y===92||y===93?(e.consume(y),h++,g):g(y)}}function _1(e,r,s,l,o,d){let c;return h;function h(p){return p===34||p===39||p===40?(e.enter(l),e.enter(o),e.consume(p),e.exit(o),c=p===40?41:p,m):s(p)}function m(p){return p===c?(e.enter(o),e.consume(p),e.exit(o),e.exit(l),r):(e.enter(d),f(p))}function f(p){return p===c?(e.exit(d),m(c)):p===null?s(p):mt(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),Ft(e,f,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),x(p))}function x(p){return p===c||p===null||mt(p)?(e.exit("chunkString"),f(p)):(e.consume(p),p===92?g:x)}function g(p){return p===c||p===92?(e.consume(p),x):x(p)}}function xo(e,r){let s;return l;function l(o){return mt(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s=!0,l):Bt(o)?Ft(e,l,s?"linePrefix":"lineSuffix")(o):r(o)}}const jS={name:"definition",tokenize:NS},wS={partial:!0,tokenize:kS};function NS(e,r,s){const l=this;let o;return d;function d(y){return e.enter("definition"),c(y)}function c(y){return A1.call(l,e,h,s,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function h(y){return o=as(l.sliceSerialize(l.events[l.events.length-1][1]).slice(1,-1)),y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),m):s(y)}function m(y){return pn(y)?xo(e,f)(y):f(y)}function f(y){return T1(e,x,s,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function x(y){return e.attempt(wS,g,g)(y)}function g(y){return Bt(y)?Ft(e,p,"whitespace")(y):p(y)}function p(y){return y===null||mt(y)?(e.exit("definition"),l.parser.defined.push(o),r(y)):s(y)}}function kS(e,r,s){return l;function l(h){return pn(h)?xo(e,o)(h):s(h)}function o(h){return _1(e,d,s,"definitionTitle","definitionTitleMarker","definitionTitleString")(h)}function d(h){return Bt(h)?Ft(e,c,"whitespace")(h):c(h)}function c(h){return h===null||mt(h)?r(h):s(h)}}const SS={name:"hardBreakEscape",tokenize:CS};function CS(e,r,s){return l;function l(d){return e.enter("hardBreakEscape"),e.consume(d),o}function o(d){return mt(d)?(e.exit("hardBreakEscape"),r(d)):s(d)}}const ES={name:"headingAtx",resolve:TS,tokenize:AS};function TS(e,r){let s=e.length-2,l=3,o,d;return e[l][1].type==="whitespace"&&(l+=2),s-2>l&&e[s][1].type==="whitespace"&&(s-=2),e[s][1].type==="atxHeadingSequence"&&(l===s-1||s-4>l&&e[s-2][1].type==="whitespace")&&(s-=l+1===s?2:4),s>l&&(o={type:"atxHeadingText",start:e[l][1].start,end:e[s][1].end},d={type:"chunkText",start:e[l][1].start,end:e[s][1].end,contentType:"text"},$r(e,l,s-l+1,[["enter",o,r],["enter",d,r],["exit",d,r],["exit",o,r]])),e}function AS(e,r,s){let l=0;return o;function o(x){return e.enter("atxHeading"),d(x)}function d(x){return e.enter("atxHeadingSequence"),c(x)}function c(x){return x===35&&l++<6?(e.consume(x),c):x===null||pn(x)?(e.exit("atxHeadingSequence"),h(x)):s(x)}function h(x){return x===35?(e.enter("atxHeadingSequence"),m(x)):x===null||mt(x)?(e.exit("atxHeading"),r(x)):Bt(x)?Ft(e,h,"whitespace")(x):(e.enter("atxHeadingText"),f(x))}function m(x){return x===35?(e.consume(x),m):(e.exit("atxHeadingSequence"),h(x))}function f(x){return x===null||x===35||pn(x)?(e.exit("atxHeadingText"),h(x)):(e.consume(x),f)}}const _S=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Rb=["pre","script","style","textarea"],MS={concrete:!0,name:"htmlFlow",resolveTo:RS,tokenize:LS},DS={partial:!0,tokenize:IS},OS={partial:!0,tokenize:zS};function RS(e){let r=e.length;for(;r--&&!(e[r][0]==="enter"&&e[r][1].type==="htmlFlow"););return r>1&&e[r-2][1].type==="linePrefix"&&(e[r][1].start=e[r-2][1].start,e[r+1][1].start=e[r-2][1].start,e.splice(r-2,2)),e}function LS(e,r,s){const l=this;let o,d,c,h,m;return f;function f(L){return x(L)}function x(L){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(L),g}function g(L){return L===33?(e.consume(L),p):L===47?(e.consume(L),d=!0,N):L===63?(e.consume(L),o=3,l.interrupt?r:U):fr(L)?(e.consume(L),c=String.fromCharCode(L),E):s(L)}function p(L){return L===45?(e.consume(L),o=2,y):L===91?(e.consume(L),o=5,h=0,w):fr(L)?(e.consume(L),o=4,l.interrupt?r:U):s(L)}function y(L){return L===45?(e.consume(L),l.interrupt?r:U):s(L)}function w(L){const M="CDATA[";return L===M.charCodeAt(h++)?(e.consume(L),h===M.length?l.interrupt?r:B:w):s(L)}function N(L){return fr(L)?(e.consume(L),c=String.fromCharCode(L),E):s(L)}function E(L){if(L===null||L===47||L===62||pn(L)){const M=L===47,q=c.toLowerCase();return!M&&!d&&Rb.includes(q)?(o=1,l.interrupt?r(L):B(L)):_S.includes(c.toLowerCase())?(o=6,M?(e.consume(L),A):l.interrupt?r(L):B(L)):(o=7,l.interrupt&&!l.parser.lazy[l.now().line]?s(L):d?C(L):k(L))}return L===45||lr(L)?(e.consume(L),c+=String.fromCharCode(L),E):s(L)}function A(L){return L===62?(e.consume(L),l.interrupt?r:B):s(L)}function C(L){return Bt(L)?(e.consume(L),C):$(L)}function k(L){return L===47?(e.consume(L),$):L===58||L===95||fr(L)?(e.consume(L),S):Bt(L)?(e.consume(L),k):$(L)}function S(L){return L===45||L===46||L===58||L===95||lr(L)?(e.consume(L),S):O(L)}function O(L){return L===61?(e.consume(L),R):Bt(L)?(e.consume(L),O):k(L)}function R(L){return L===null||L===60||L===61||L===62||L===96?s(L):L===34||L===39?(e.consume(L),m=L,G):Bt(L)?(e.consume(L),R):I(L)}function G(L){return L===m?(e.consume(L),m=null,Q):L===null||mt(L)?s(L):(e.consume(L),G)}function I(L){return L===null||L===34||L===39||L===47||L===60||L===61||L===62||L===96||pn(L)?O(L):(e.consume(L),I)}function Q(L){return L===47||L===62||Bt(L)?k(L):s(L)}function $(L){return L===62?(e.consume(L),F):s(L)}function F(L){return L===null||mt(L)?B(L):Bt(L)?(e.consume(L),F):s(L)}function B(L){return L===45&&o===2?(e.consume(L),_):L===60&&o===1?(e.consume(L),Y):L===62&&o===4?(e.consume(L),H):L===63&&o===3?(e.consume(L),U):L===93&&o===5?(e.consume(L),J):mt(L)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(DS,X,T)(L)):L===null||mt(L)?(e.exit("htmlFlowData"),T(L)):(e.consume(L),B)}function T(L){return e.check(OS,D,X)(L)}function D(L){return e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),z}function z(L){return L===null||mt(L)?T(L):(e.enter("htmlFlowData"),B(L))}function _(L){return L===45?(e.consume(L),U):B(L)}function Y(L){return L===47?(e.consume(L),c="",V):B(L)}function V(L){if(L===62){const M=c.toLowerCase();return Rb.includes(M)?(e.consume(L),H):B(L)}return fr(L)&&c.length<8?(e.consume(L),c+=String.fromCharCode(L),V):B(L)}function J(L){return L===93?(e.consume(L),U):B(L)}function U(L){return L===62?(e.consume(L),H):L===45&&o===2?(e.consume(L),U):B(L)}function H(L){return L===null||mt(L)?(e.exit("htmlFlowData"),X(L)):(e.consume(L),H)}function X(L){return e.exit("htmlFlow"),r(L)}}function zS(e,r,s){const l=this;return o;function o(c){return mt(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),d):s(c)}function d(c){return l.parser.lazy[l.now().line]?s(c):r(c)}}function IS(e,r,s){return l;function l(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(zo,r,s)}}const $S={name:"htmlText",tokenize:BS};function BS(e,r,s){const l=this;let o,d,c;return h;function h(U){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(U),m}function m(U){return U===33?(e.consume(U),f):U===47?(e.consume(U),O):U===63?(e.consume(U),k):fr(U)?(e.consume(U),I):s(U)}function f(U){return U===45?(e.consume(U),x):U===91?(e.consume(U),d=0,w):fr(U)?(e.consume(U),C):s(U)}function x(U){return U===45?(e.consume(U),y):s(U)}function g(U){return U===null?s(U):U===45?(e.consume(U),p):mt(U)?(c=g,Y(U)):(e.consume(U),g)}function p(U){return U===45?(e.consume(U),y):g(U)}function y(U){return U===62?_(U):U===45?p(U):g(U)}function w(U){const H="CDATA[";return U===H.charCodeAt(d++)?(e.consume(U),d===H.length?N:w):s(U)}function N(U){return U===null?s(U):U===93?(e.consume(U),E):mt(U)?(c=N,Y(U)):(e.consume(U),N)}function E(U){return U===93?(e.consume(U),A):N(U)}function A(U){return U===62?_(U):U===93?(e.consume(U),A):N(U)}function C(U){return U===null||U===62?_(U):mt(U)?(c=C,Y(U)):(e.consume(U),C)}function k(U){return U===null?s(U):U===63?(e.consume(U),S):mt(U)?(c=k,Y(U)):(e.consume(U),k)}function S(U){return U===62?_(U):k(U)}function O(U){return fr(U)?(e.consume(U),R):s(U)}function R(U){return U===45||lr(U)?(e.consume(U),R):G(U)}function G(U){return mt(U)?(c=G,Y(U)):Bt(U)?(e.consume(U),G):_(U)}function I(U){return U===45||lr(U)?(e.consume(U),I):U===47||U===62||pn(U)?Q(U):s(U)}function Q(U){return U===47?(e.consume(U),_):U===58||U===95||fr(U)?(e.consume(U),$):mt(U)?(c=Q,Y(U)):Bt(U)?(e.consume(U),Q):_(U)}function $(U){return U===45||U===46||U===58||U===95||lr(U)?(e.consume(U),$):F(U)}function F(U){return U===61?(e.consume(U),B):mt(U)?(c=F,Y(U)):Bt(U)?(e.consume(U),F):Q(U)}function B(U){return U===null||U===60||U===61||U===62||U===96?s(U):U===34||U===39?(e.consume(U),o=U,T):mt(U)?(c=B,Y(U)):Bt(U)?(e.consume(U),B):(e.consume(U),D)}function T(U){return U===o?(e.consume(U),o=void 0,z):U===null?s(U):mt(U)?(c=T,Y(U)):(e.consume(U),T)}function D(U){return U===null||U===34||U===39||U===60||U===61||U===96?s(U):U===47||U===62||pn(U)?Q(U):(e.consume(U),D)}function z(U){return U===47||U===62||pn(U)?Q(U):s(U)}function _(U){return U===62?(e.consume(U),e.exit("htmlTextData"),e.exit("htmlText"),r):s(U)}function Y(U){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(U),e.exit("lineEnding"),V}function V(U){return Bt(U)?Ft(e,J,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(U):J(U)}function J(U){return e.enter("htmlTextData"),c(U)}}const Qm={name:"labelEnd",resolveAll:qS,resolveTo:FS,tokenize:VS},HS={tokenize:YS},PS={tokenize:GS},US={tokenize:XS};function qS(e){let r=-1;const s=[];for(;++r<e.length;){const l=e[r][1];if(s.push(e[r]),l.type==="labelImage"||l.type==="labelLink"||l.type==="labelEnd"){const o=l.type==="labelImage"?4:2;l.type="data",r+=o}}return e.length!==s.length&&$r(e,0,e.length,s),e}function FS(e,r){let s=e.length,l=0,o,d,c,h;for(;s--;)if(o=e[s][1],d){if(o.type==="link"||o.type==="labelLink"&&o._inactive)break;e[s][0]==="enter"&&o.type==="labelLink"&&(o._inactive=!0)}else if(c){if(e[s][0]==="enter"&&(o.type==="labelImage"||o.type==="labelLink")&&!o._balanced&&(d=s,o.type!=="labelLink")){l=2;break}}else o.type==="labelEnd"&&(c=s);const m={type:e[d][1].type==="labelLink"?"link":"image",start:{...e[d][1].start},end:{...e[e.length-1][1].end}},f={type:"label",start:{...e[d][1].start},end:{...e[c][1].end}},x={type:"labelText",start:{...e[d+l+2][1].end},end:{...e[c-2][1].start}};return h=[["enter",m,r],["enter",f,r]],h=Qr(h,e.slice(d+1,d+l+3)),h=Qr(h,[["enter",x,r]]),h=Qr(h,Yd(r.parser.constructs.insideSpan.null,e.slice(d+l+4,c-3),r)),h=Qr(h,[["exit",x,r],e[c-2],e[c-1],["exit",f,r]]),h=Qr(h,e.slice(c+1)),h=Qr(h,[["exit",m,r]]),$r(e,d,e.length,h),e}function VS(e,r,s){const l=this;let o=l.events.length,d,c;for(;o--;)if((l.events[o][1].type==="labelImage"||l.events[o][1].type==="labelLink")&&!l.events[o][1]._balanced){d=l.events[o][1];break}return h;function h(p){return d?d._inactive?g(p):(c=l.parser.defined.includes(as(l.sliceSerialize({start:d.end,end:l.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelEnd"),m):s(p)}function m(p){return p===40?e.attempt(HS,x,c?x:g)(p):p===91?e.attempt(PS,x,c?f:g)(p):c?x(p):g(p)}function f(p){return e.attempt(US,x,g)(p)}function x(p){return r(p)}function g(p){return d._balanced=!0,s(p)}}function YS(e,r,s){return l;function l(g){return e.enter("resource"),e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),o}function o(g){return pn(g)?xo(e,d)(g):d(g)}function d(g){return g===41?x(g):T1(e,c,h,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(g)}function c(g){return pn(g)?xo(e,m)(g):x(g)}function h(g){return s(g)}function m(g){return g===34||g===39||g===40?_1(e,f,s,"resourceTitle","resourceTitleMarker","resourceTitleString")(g):x(g)}function f(g){return pn(g)?xo(e,x)(g):x(g)}function x(g){return g===41?(e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),e.exit("resource"),r):s(g)}}function GS(e,r,s){const l=this;return o;function o(h){return A1.call(l,e,d,c,"reference","referenceMarker","referenceString")(h)}function d(h){return l.parser.defined.includes(as(l.sliceSerialize(l.events[l.events.length-1][1]).slice(1,-1)))?r(h):s(h)}function c(h){return s(h)}}function XS(e,r,s){return l;function l(d){return e.enter("reference"),e.enter("referenceMarker"),e.consume(d),e.exit("referenceMarker"),o}function o(d){return d===93?(e.enter("referenceMarker"),e.consume(d),e.exit("referenceMarker"),e.exit("reference"),r):s(d)}}const ZS={name:"labelStartImage",resolveAll:Qm.resolveAll,tokenize:QS};function QS(e,r,s){const l=this;return o;function o(h){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(h),e.exit("labelImageMarker"),d}function d(h){return h===91?(e.enter("labelMarker"),e.consume(h),e.exit("labelMarker"),e.exit("labelImage"),c):s(h)}function c(h){return h===94&&"_hiddenFootnoteSupport"in l.parser.constructs?s(h):r(h)}}const KS={name:"labelStartLink",resolveAll:Qm.resolveAll,tokenize:JS};function JS(e,r,s){const l=this;return o;function o(c){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelLink"),d}function d(c){return c===94&&"_hiddenFootnoteSupport"in l.parser.constructs?s(c):r(c)}}const wh={name:"lineEnding",tokenize:WS};function WS(e,r){return s;function s(l){return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),Ft(e,r,"linePrefix")}}const md={name:"thematicBreak",tokenize:eC};function eC(e,r,s){let l=0,o;return d;function d(f){return e.enter("thematicBreak"),c(f)}function c(f){return o=f,h(f)}function h(f){return f===o?(e.enter("thematicBreakSequence"),m(f)):l>=3&&(f===null||mt(f))?(e.exit("thematicBreak"),r(f)):s(f)}function m(f){return f===o?(e.consume(f),l++,m):(e.exit("thematicBreakSequence"),Bt(f)?Ft(e,h,"whitespace")(f):h(f))}}const jr={continuation:{tokenize:sC},exit:lC,name:"list",tokenize:rC},tC={partial:!0,tokenize:iC},nC={partial:!0,tokenize:aC};function rC(e,r,s){const l=this,o=l.events[l.events.length-1];let d=o&&o[1].type==="linePrefix"?o[2].sliceSerialize(o[1],!0).length:0,c=0;return h;function h(y){const w=l.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!l.containerState.marker||y===l.containerState.marker:um(y)){if(l.containerState.type||(l.containerState.type=w,e.enter(w,{_container:!0})),w==="listUnordered")return e.enter("listItemPrefix"),y===42||y===45?e.check(md,s,f)(y):f(y);if(!l.interrupt||y===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),m(y)}return s(y)}function m(y){return um(y)&&++c<10?(e.consume(y),m):(!l.interrupt||c<2)&&(l.containerState.marker?y===l.containerState.marker:y===41||y===46)?(e.exit("listItemValue"),f(y)):s(y)}function f(y){return e.enter("listItemMarker"),e.consume(y),e.exit("listItemMarker"),l.containerState.marker=l.containerState.marker||y,e.check(zo,l.interrupt?s:x,e.attempt(tC,p,g))}function x(y){return l.containerState.initialBlankLine=!0,d++,p(y)}function g(y){return Bt(y)?(e.enter("listItemPrefixWhitespace"),e.consume(y),e.exit("listItemPrefixWhitespace"),p):s(y)}function p(y){return l.containerState.size=d+l.sliceSerialize(e.exit("listItemPrefix"),!0).length,r(y)}}function sC(e,r,s){const l=this;return l.containerState._closeFlow=void 0,e.check(zo,o,d);function o(h){return l.containerState.furtherBlankLines=l.containerState.furtherBlankLines||l.containerState.initialBlankLine,Ft(e,r,"listItemIndent",l.containerState.size+1)(h)}function d(h){return l.containerState.furtherBlankLines||!Bt(h)?(l.containerState.furtherBlankLines=void 0,l.containerState.initialBlankLine=void 0,c(h)):(l.containerState.furtherBlankLines=void 0,l.containerState.initialBlankLine=void 0,e.attempt(nC,r,c)(h))}function c(h){return l.containerState._closeFlow=!0,l.interrupt=void 0,Ft(e,e.attempt(jr,r,s),"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(h)}}function aC(e,r,s){const l=this;return Ft(e,o,"listItemIndent",l.containerState.size+1);function o(d){const c=l.events[l.events.length-1];return c&&c[1].type==="listItemIndent"&&c[2].sliceSerialize(c[1],!0).length===l.containerState.size?r(d):s(d)}}function lC(e){e.exit(this.containerState.type)}function iC(e,r,s){const l=this;return Ft(e,o,"listItemPrefixWhitespace",l.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(d){const c=l.events[l.events.length-1];return!Bt(d)&&c&&c[1].type==="listItemPrefixWhitespace"?r(d):s(d)}}const Lb={name:"setextUnderline",resolveTo:oC,tokenize:cC};function oC(e,r){let s=e.length,l,o,d;for(;s--;)if(e[s][0]==="enter"){if(e[s][1].type==="content"){l=s;break}e[s][1].type==="paragraph"&&(o=s)}else e[s][1].type==="content"&&e.splice(s,1),!d&&e[s][1].type==="definition"&&(d=s);const c={type:"setextHeading",start:{...e[l][1].start},end:{...e[e.length-1][1].end}};return e[o][1].type="setextHeadingText",d?(e.splice(o,0,["enter",c,r]),e.splice(d+1,0,["exit",e[l][1],r]),e[l][1].end={...e[d][1].end}):e[l][1]=c,e.push(["exit",c,r]),e}function cC(e,r,s){const l=this;let o;return d;function d(f){let x=l.events.length,g;for(;x--;)if(l.events[x][1].type!=="lineEnding"&&l.events[x][1].type!=="linePrefix"&&l.events[x][1].type!=="content"){g=l.events[x][1].type==="paragraph";break}return!l.parser.lazy[l.now().line]&&(l.interrupt||g)?(e.enter("setextHeadingLine"),o=f,c(f)):s(f)}function c(f){return e.enter("setextHeadingLineSequence"),h(f)}function h(f){return f===o?(e.consume(f),h):(e.exit("setextHeadingLineSequence"),Bt(f)?Ft(e,m,"lineSuffix")(f):m(f))}function m(f){return f===null||mt(f)?(e.exit("setextHeadingLine"),r(f)):s(f)}}const dC={tokenize:uC};function uC(e){const r=this,s=e.attempt(zo,l,e.attempt(this.parser.constructs.flowInitial,o,Ft(e,e.attempt(this.parser.constructs.flow,o,e.attempt(gS,o)),"linePrefix")));return s;function l(d){if(d===null){e.consume(d);return}return e.enter("lineEndingBlank"),e.consume(d),e.exit("lineEndingBlank"),r.currentConstruct=void 0,s}function o(d){if(d===null){e.consume(d);return}return e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),r.currentConstruct=void 0,s}}const fC={resolveAll:D1()},hC=M1("string"),mC=M1("text");function M1(e){return{resolveAll:D1(e==="text"?xC:void 0),tokenize:r};function r(s){const l=this,o=this.parser.constructs[e],d=s.attempt(o,c,h);return c;function c(x){return f(x)?d(x):h(x)}function h(x){if(x===null){s.consume(x);return}return s.enter("data"),s.consume(x),m}function m(x){return f(x)?(s.exit("data"),d(x)):(s.consume(x),m)}function f(x){if(x===null)return!0;const g=o[x];let p=-1;if(g)for(;++p<g.length;){const y=g[p];if(!y.previous||y.previous.call(l,l.previous))return!0}return!1}}}function D1(e){return r;function r(s,l){let o=-1,d;for(;++o<=s.length;)d===void 0?s[o]&&s[o][1].type==="data"&&(d=o,o++):(!s[o]||s[o][1].type!=="data")&&(o!==d+2&&(s[d][1].end=s[o-1][1].end,s.splice(d+2,o-d-2),o=d+2),d=void 0);return e?e(s,l):s}}function xC(e,r){let s=0;for(;++s<=e.length;)if((s===e.length||e[s][1].type==="lineEnding")&&e[s-1][1].type==="data"){const l=e[s-1][1],o=r.sliceStream(l);let d=o.length,c=-1,h=0,m;for(;d--;){const f=o[d];if(typeof f=="string"){for(c=f.length;f.charCodeAt(c-1)===32;)h++,c--;if(c)break;c=-1}else if(f===-2)m=!0,h++;else if(f!==-1){d++;break}}if(r._contentTypeTextTrailing&&s===e.length&&(h=0),h){const f={type:s===e.length||m||h<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:d?c:l.start._bufferIndex+c,_index:l.start._index+d,line:l.end.line,column:l.end.column-h,offset:l.end.offset-h},end:{...l.end}};l.end={...f.start},l.start.offset===l.end.offset?Object.assign(l,f):(e.splice(s,0,["enter",f,r],["exit",f,r]),s+=2)}s++}return e}const gC={42:jr,43:jr,45:jr,48:jr,49:jr,50:jr,51:jr,52:jr,53:jr,54:jr,55:jr,56:jr,57:jr,62:k1},pC={91:jS},bC={[-2]:jh,[-1]:jh,32:jh},yC={35:ES,42:md,45:[Lb,md],60:MS,61:Lb,95:md,96:Ob,126:Ob},vC={38:C1,92:S1},jC={[-5]:wh,[-4]:wh,[-3]:wh,33:ZS,38:C1,42:fm,60:[Kk,$S],91:KS,92:[SS,S1],93:Qm,95:fm,96:dS},wC={null:[fm,fC]},NC={null:[42,95]},kC={null:[]},SC=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:NC,contentInitial:pC,disable:kC,document:gC,flow:yC,flowInitial:bC,insideSpan:wC,string:vC,text:jC},Symbol.toStringTag,{value:"Module"}));function CC(e,r,s){let l={_bufferIndex:-1,_index:0,line:s&&s.line||1,column:s&&s.column||1,offset:s&&s.offset||0};const o={},d=[];let c=[],h=[];const m={attempt:G(O),check:G(R),consume:C,enter:k,exit:S,interrupt:G(R,{interrupt:!0})},f={code:null,containerState:{},defineSkip:N,events:[],now:w,parser:e,previous:null,sliceSerialize:p,sliceStream:y,write:g};let x=r.tokenize.call(f,m);return r.resolveAll&&d.push(r),f;function g(F){return c=Qr(c,F),E(),c[c.length-1]!==null?[]:(I(r,0),f.events=Yd(d,f.events,f),f.events)}function p(F,B){return TC(y(F),B)}function y(F){return EC(c,F)}function w(){const{_bufferIndex:F,_index:B,line:T,column:D,offset:z}=l;return{_bufferIndex:F,_index:B,line:T,column:D,offset:z}}function N(F){o[F.line]=F.column,$()}function E(){let F;for(;l._index<c.length;){const B=c[l._index];if(typeof B=="string")for(F=l._index,l._bufferIndex<0&&(l._bufferIndex=0);l._index===F&&l._bufferIndex<B.length;)A(B.charCodeAt(l._bufferIndex));else A(B)}}function A(F){x=x(F)}function C(F){mt(F)?(l.line++,l.column=1,l.offset+=F===-3?2:1,$()):F!==-1&&(l.column++,l.offset++),l._bufferIndex<0?l._index++:(l._bufferIndex++,l._bufferIndex===c[l._index].length&&(l._bufferIndex=-1,l._index++)),f.previous=F}function k(F,B){const T=B||{};return T.type=F,T.start=w(),f.events.push(["enter",T,f]),h.push(T),T}function S(F){const B=h.pop();return B.end=w(),f.events.push(["exit",B,f]),B}function O(F,B){I(F,B.from)}function R(F,B){B.restore()}function G(F,B){return T;function T(D,z,_){let Y,V,J,U;return Array.isArray(D)?X(D):"tokenize"in D?X([D]):H(D);function H(K){return ee;function ee(te){const se=te!==null&&K[te],xe=te!==null&&K.null,ke=[...Array.isArray(se)?se:se?[se]:[],...Array.isArray(xe)?xe:xe?[xe]:[]];return X(ke)(te)}}function X(K){return Y=K,V=0,K.length===0?_:L(K[V])}function L(K){return ee;function ee(te){return U=Q(),J=K,K.partial||(f.currentConstruct=K),K.name&&f.parser.constructs.disable.null.includes(K.name)?q():K.tokenize.call(B?Object.assign(Object.create(f),B):f,m,M,q)(te)}}function M(K){return F(J,U),z}function q(K){return U.restore(),++V<Y.length?L(Y[V]):_}}}function I(F,B){F.resolveAll&&!d.includes(F)&&d.push(F),F.resolve&&$r(f.events,B,f.events.length-B,F.resolve(f.events.slice(B),f)),F.resolveTo&&(f.events=F.resolveTo(f.events,f))}function Q(){const F=w(),B=f.previous,T=f.currentConstruct,D=f.events.length,z=Array.from(h);return{from:D,restore:_};function _(){l=F,f.previous=B,f.currentConstruct=T,f.events.length=D,h=z,$()}}function $(){l.line in o&&l.column<2&&(l.column=o[l.line],l.offset+=o[l.line]-1)}}function EC(e,r){const s=r.start._index,l=r.start._bufferIndex,o=r.end._index,d=r.end._bufferIndex;let c;if(s===o)c=[e[s].slice(l,d)];else{if(c=e.slice(s,o),l>-1){const h=c[0];typeof h=="string"?c[0]=h.slice(l):c.shift()}d>0&&c.push(e[o].slice(0,d))}return c}function TC(e,r){let s=-1;const l=[];let o;for(;++s<e.length;){const d=e[s];let c;if(typeof d=="string")c=d;else switch(d){case-5:{c="\r";break}case-4:{c=`
|
|
12
|
+
`;break}case-3:{c=`\r
|
|
13
|
+
`;break}case-2:{c=r?" ":" ";break}case-1:{if(!r&&o)continue;c=" ";break}default:c=String.fromCharCode(d)}o=d===-2,l.push(c)}return l.join("")}function AC(e){const l={constructs:w1([SC,...(e||{}).extensions||[]]),content:o(Fk),defined:[],document:o(Yk),flow:o(dC),lazy:{},string:o(hC),text:o(mC)};return l;function o(d){return c;function c(h){return CC(l,d,h)}}}function _C(e){for(;!E1(e););return e}const zb=/[\0\t\n\r]/g;function MC(){let e=1,r="",s=!0,l;return o;function o(d,c,h){const m=[];let f,x,g,p,y;for(d=r+(typeof d=="string"?d.toString():new TextDecoder(c||void 0).decode(d)),g=0,r="",s&&(d.charCodeAt(0)===65279&&g++,s=void 0);g<d.length;){if(zb.lastIndex=g,f=zb.exec(d),p=f&&f.index!==void 0?f.index:d.length,y=d.charCodeAt(p),!f){r=d.slice(g);break}if(y===10&&g===p&&l)m.push(-3),l=void 0;else switch(l&&(m.push(-5),l=void 0),g<p&&(m.push(d.slice(g,p)),e+=p-g),y){case 0:{m.push(65533),e++;break}case 9:{for(x=Math.ceil(e/4)*4,m.push(-2);e++<x;)m.push(-1);break}case 10:{m.push(-4),e=1;break}default:l=!0,e=1}g=p+1}return h&&(l&&m.push(-5),r&&m.push(r),m.push(null)),m}}const DC=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function OC(e){return e.replace(DC,RC)}function RC(e,r,s){if(r)return r;if(s.charCodeAt(0)===35){const o=s.charCodeAt(1),d=o===120||o===88;return N1(s.slice(d?2:1),d?16:10)}return Zm(s)||e}const O1={}.hasOwnProperty;function LC(e,r,s){return r&&typeof r=="object"&&(s=r,r=void 0),zC(s)(_C(AC(s).document().write(MC()(e,r,!0))))}function zC(e){const r={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:d(dt),autolinkProtocol:Q,autolinkEmail:Q,atxHeading:d(Ce),blockQuote:d(xe),characterEscape:Q,characterReference:Q,codeFenced:d(ke),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:d(ke,c),codeText:d(De,c),codeTextData:Q,data:Q,codeFlowValue:Q,definition:d(ge),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:d(ye),hardBreakEscape:d(ze),hardBreakTrailing:d(ze),htmlFlow:d(tt,c),htmlFlowData:Q,htmlText:d(tt,c),htmlTextData:Q,image:d(Xe),label:c,link:d(dt),listItem:d(ae),listItemValue:p,listOrdered:d(wt,g),listUnordered:d(wt),paragraph:d(Te),reference:L,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:d(Ce),strong:d(Ze),thematicBreak:d(dn)},exit:{atxHeading:m(),atxHeadingSequence:O,autolink:m(),autolinkEmail:se,autolinkProtocol:te,blockQuote:m(),characterEscapeValue:$,characterReferenceMarkerHexadecimal:q,characterReferenceMarkerNumeric:q,characterReferenceValue:K,characterReference:ee,codeFenced:m(E),codeFencedFence:N,codeFencedFenceInfo:y,codeFencedFenceMeta:w,codeFlowValue:$,codeIndented:m(A),codeText:m(z),codeTextData:$,data:$,definition:m(),definitionDestinationString:S,definitionLabelString:C,definitionTitleString:k,emphasis:m(),hardBreakEscape:m(B),hardBreakTrailing:m(B),htmlFlow:m(T),htmlFlowData:$,htmlText:m(D),htmlTextData:$,image:m(Y),label:J,labelText:V,lineEnding:F,link:m(_),listItem:m(),listOrdered:m(),listUnordered:m(),paragraph:m(),referenceString:M,resourceDestinationString:U,resourceTitleString:H,resource:X,setextHeading:m(I),setextHeadingLineSequence:G,setextHeadingText:R,strong:m(),thematicBreak:m()}};R1(r,(e||{}).mdastExtensions||[]);const s={};return l;function l(we){let Re={type:"root",children:[]};const qe={stack:[Re],tokenStack:[],config:r,enter:h,exit:f,buffer:c,resume:x,data:s},et=[];let nt=-1;for(;++nt<we.length;)if(we[nt][1].type==="listOrdered"||we[nt][1].type==="listUnordered")if(we[nt][0]==="enter")et.push(nt);else{const zt=et.pop();nt=o(we,zt,nt)}for(nt=-1;++nt<we.length;){const zt=r[we[nt][0]];O1.call(zt,we[nt][1].type)&&zt[we[nt][1].type].call(Object.assign({sliceSerialize:we[nt][2].sliceSerialize},qe),we[nt][1])}if(qe.tokenStack.length>0){const zt=qe.tokenStack[qe.tokenStack.length-1];(zt[1]||Ib).call(qe,void 0,zt[0])}for(Re.position={start:wa(we.length>0?we[0][1].start:{line:1,column:1,offset:0}),end:wa(we.length>0?we[we.length-2][1].end:{line:1,column:1,offset:0})},nt=-1;++nt<r.transforms.length;)Re=r.transforms[nt](Re)||Re;return Re}function o(we,Re,qe){let et=Re-1,nt=-1,zt=!1,Yt,Lt,Tt,qt;for(;++et<=qe;){const yt=we[et];switch(yt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{yt[0]==="enter"?nt++:nt--,qt=void 0;break}case"lineEndingBlank":{yt[0]==="enter"&&(Yt&&!qt&&!nt&&!Tt&&(Tt=et),qt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:qt=void 0}if(!nt&&yt[0]==="enter"&&yt[1].type==="listItemPrefix"||nt===-1&&yt[0]==="exit"&&(yt[1].type==="listUnordered"||yt[1].type==="listOrdered")){if(Yt){let sn=et;for(Lt=void 0;sn--;){const Xt=we[sn];if(Xt[1].type==="lineEnding"||Xt[1].type==="lineEndingBlank"){if(Xt[0]==="exit")continue;Lt&&(we[Lt][1].type="lineEndingBlank",zt=!0),Xt[1].type="lineEnding",Lt=sn}else if(!(Xt[1].type==="linePrefix"||Xt[1].type==="blockQuotePrefix"||Xt[1].type==="blockQuotePrefixWhitespace"||Xt[1].type==="blockQuoteMarker"||Xt[1].type==="listItemIndent"))break}Tt&&(!Lt||Tt<Lt)&&(Yt._spread=!0),Yt.end=Object.assign({},Lt?we[Lt][1].start:yt[1].end),we.splice(Lt||et,0,["exit",Yt,yt[2]]),et++,qe++}if(yt[1].type==="listItemPrefix"){const sn={type:"listItem",_spread:!1,start:Object.assign({},yt[1].start),end:void 0};Yt=sn,we.splice(et,0,["enter",sn,yt[2]]),et++,qe++,Tt=void 0,qt=!0}}}return we[Re][1]._spread=zt,qe}function d(we,Re){return qe;function qe(et){h.call(this,we(et),et),Re&&Re.call(this,et)}}function c(){this.stack.push({type:"fragment",children:[]})}function h(we,Re,qe){this.stack[this.stack.length-1].children.push(we),this.stack.push(we),this.tokenStack.push([Re,qe||void 0]),we.position={start:wa(Re.start),end:void 0}}function m(we){return Re;function Re(qe){we&&we.call(this,qe),f.call(this,qe)}}function f(we,Re){const qe=this.stack.pop(),et=this.tokenStack.pop();if(et)et[0].type!==we.type&&(Re?Re.call(this,we,et[0]):(et[1]||Ib).call(this,we,et[0]));else throw new Error("Cannot close `"+we.type+"` ("+mo({start:we.start,end:we.end})+"): it’s not open");qe.position.end=wa(we.end)}function x(){return Xm(this.stack.pop())}function g(){this.data.expectingFirstListItemValue=!0}function p(we){if(this.data.expectingFirstListItemValue){const Re=this.stack[this.stack.length-2];Re.start=Number.parseInt(this.sliceSerialize(we),10),this.data.expectingFirstListItemValue=void 0}}function y(){const we=this.resume(),Re=this.stack[this.stack.length-1];Re.lang=we}function w(){const we=this.resume(),Re=this.stack[this.stack.length-1];Re.meta=we}function N(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function E(){const we=this.resume(),Re=this.stack[this.stack.length-1];Re.value=we.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function A(){const we=this.resume(),Re=this.stack[this.stack.length-1];Re.value=we.replace(/(\r?\n|\r)$/g,"")}function C(we){const Re=this.resume(),qe=this.stack[this.stack.length-1];qe.label=Re,qe.identifier=as(this.sliceSerialize(we)).toLowerCase()}function k(){const we=this.resume(),Re=this.stack[this.stack.length-1];Re.title=we}function S(){const we=this.resume(),Re=this.stack[this.stack.length-1];Re.url=we}function O(we){const Re=this.stack[this.stack.length-1];if(!Re.depth){const qe=this.sliceSerialize(we).length;Re.depth=qe}}function R(){this.data.setextHeadingSlurpLineEnding=!0}function G(we){const Re=this.stack[this.stack.length-1];Re.depth=this.sliceSerialize(we).codePointAt(0)===61?1:2}function I(){this.data.setextHeadingSlurpLineEnding=void 0}function Q(we){const qe=this.stack[this.stack.length-1].children;let et=qe[qe.length-1];(!et||et.type!=="text")&&(et=xt(),et.position={start:wa(we.start),end:void 0},qe.push(et)),this.stack.push(et)}function $(we){const Re=this.stack.pop();Re.value+=this.sliceSerialize(we),Re.position.end=wa(we.end)}function F(we){const Re=this.stack[this.stack.length-1];if(this.data.atHardBreak){const qe=Re.children[Re.children.length-1];qe.position.end=wa(we.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&r.canContainEols.includes(Re.type)&&(Q.call(this,we),$.call(this,we))}function B(){this.data.atHardBreak=!0}function T(){const we=this.resume(),Re=this.stack[this.stack.length-1];Re.value=we}function D(){const we=this.resume(),Re=this.stack[this.stack.length-1];Re.value=we}function z(){const we=this.resume(),Re=this.stack[this.stack.length-1];Re.value=we}function _(){const we=this.stack[this.stack.length-1];if(this.data.inReference){const Re=this.data.referenceType||"shortcut";we.type+="Reference",we.referenceType=Re,delete we.url,delete we.title}else delete we.identifier,delete we.label;this.data.referenceType=void 0}function Y(){const we=this.stack[this.stack.length-1];if(this.data.inReference){const Re=this.data.referenceType||"shortcut";we.type+="Reference",we.referenceType=Re,delete we.url,delete we.title}else delete we.identifier,delete we.label;this.data.referenceType=void 0}function V(we){const Re=this.sliceSerialize(we),qe=this.stack[this.stack.length-2];qe.label=OC(Re),qe.identifier=as(Re).toLowerCase()}function J(){const we=this.stack[this.stack.length-1],Re=this.resume(),qe=this.stack[this.stack.length-1];if(this.data.inReference=!0,qe.type==="link"){const et=we.children;qe.children=et}else qe.alt=Re}function U(){const we=this.resume(),Re=this.stack[this.stack.length-1];Re.url=we}function H(){const we=this.resume(),Re=this.stack[this.stack.length-1];Re.title=we}function X(){this.data.inReference=void 0}function L(){this.data.referenceType="collapsed"}function M(we){const Re=this.resume(),qe=this.stack[this.stack.length-1];qe.label=Re,qe.identifier=as(this.sliceSerialize(we)).toLowerCase(),this.data.referenceType="full"}function q(we){this.data.characterReferenceType=we.type}function K(we){const Re=this.sliceSerialize(we),qe=this.data.characterReferenceType;let et;qe?(et=N1(Re,qe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):et=Zm(Re);const nt=this.stack[this.stack.length-1];nt.value+=et}function ee(we){const Re=this.stack.pop();Re.position.end=wa(we.end)}function te(we){$.call(this,we);const Re=this.stack[this.stack.length-1];Re.url=this.sliceSerialize(we)}function se(we){$.call(this,we);const Re=this.stack[this.stack.length-1];Re.url="mailto:"+this.sliceSerialize(we)}function xe(){return{type:"blockquote",children:[]}}function ke(){return{type:"code",lang:null,meta:null,value:""}}function De(){return{type:"inlineCode",value:""}}function ge(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ye(){return{type:"emphasis",children:[]}}function Ce(){return{type:"heading",depth:0,children:[]}}function ze(){return{type:"break"}}function tt(){return{type:"html",value:""}}function Xe(){return{type:"image",title:null,url:"",alt:null}}function dt(){return{type:"link",title:null,url:"",children:[]}}function wt(we){return{type:"list",ordered:we.type==="listOrdered",start:null,spread:we._spread,children:[]}}function ae(we){return{type:"listItem",spread:we._spread,checked:null,children:[]}}function Te(){return{type:"paragraph",children:[]}}function Ze(){return{type:"strong",children:[]}}function xt(){return{type:"text",value:""}}function dn(){return{type:"thematicBreak"}}}function wa(e){return{line:e.line,column:e.column,offset:e.offset}}function R1(e,r){let s=-1;for(;++s<r.length;){const l=r[s];Array.isArray(l)?R1(e,l):IC(e,l)}}function IC(e,r){let s;for(s in r)if(O1.call(r,s))switch(s){case"canContainEols":{const l=r[s];l&&e[s].push(...l);break}case"transforms":{const l=r[s];l&&e[s].push(...l);break}case"enter":case"exit":{const l=r[s];l&&Object.assign(e[s],l);break}}}function Ib(e,r){throw e?new Error("Cannot close `"+e.type+"` ("+mo({start:e.start,end:e.end})+"): a different token (`"+r.type+"`, "+mo({start:r.start,end:r.end})+") is open"):new Error("Cannot close document, a token (`"+r.type+"`, "+mo({start:r.start,end:r.end})+") is still open")}function $C(e){const r=this;r.parser=s;function s(l){return LC(l,{...r.data("settings"),...e,extensions:r.data("micromarkExtensions")||[],mdastExtensions:r.data("fromMarkdownExtensions")||[]})}}function BC(e,r){const s={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(r),!0)};return e.patch(r,s),e.applyData(r,s)}function HC(e,r){const s={type:"element",tagName:"br",properties:{},children:[]};return e.patch(r,s),[e.applyData(r,s),{type:"text",value:`
|
|
14
|
+
`}]}function PC(e,r){const s=r.value?r.value+`
|
|
15
|
+
`:"",l={},o=r.lang?r.lang.split(/\s+/):[];o.length>0&&(l.className=["language-"+o[0]]);let d={type:"element",tagName:"code",properties:l,children:[{type:"text",value:s}]};return r.meta&&(d.data={meta:r.meta}),e.patch(r,d),d=e.applyData(r,d),d={type:"element",tagName:"pre",properties:{},children:[d]},e.patch(r,d),d}function UC(e,r){const s={type:"element",tagName:"del",properties:{},children:e.all(r)};return e.patch(r,s),e.applyData(r,s)}function qC(e,r){const s={type:"element",tagName:"em",properties:{},children:e.all(r)};return e.patch(r,s),e.applyData(r,s)}function FC(e,r){const s=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",l=String(r.identifier).toUpperCase(),o=ci(l.toLowerCase()),d=e.footnoteOrder.indexOf(l);let c,h=e.footnoteCounts.get(l);h===void 0?(h=0,e.footnoteOrder.push(l),c=e.footnoteOrder.length):c=d+1,h+=1,e.footnoteCounts.set(l,h);const m={type:"element",tagName:"a",properties:{href:"#"+s+"fn-"+o,id:s+"fnref-"+o+(h>1?"-"+h:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(c)}]};e.patch(r,m);const f={type:"element",tagName:"sup",properties:{},children:[m]};return e.patch(r,f),e.applyData(r,f)}function VC(e,r){const s={type:"element",tagName:"h"+r.depth,properties:{},children:e.all(r)};return e.patch(r,s),e.applyData(r,s)}function YC(e,r){if(e.options.allowDangerousHtml){const s={type:"raw",value:r.value};return e.patch(r,s),e.applyData(r,s)}}function L1(e,r){const s=r.referenceType;let l="]";if(s==="collapsed"?l+="[]":s==="full"&&(l+="["+(r.label||r.identifier)+"]"),r.type==="imageReference")return[{type:"text",value:"!["+r.alt+l}];const o=e.all(r),d=o[0];d&&d.type==="text"?d.value="["+d.value:o.unshift({type:"text",value:"["});const c=o[o.length-1];return c&&c.type==="text"?c.value+=l:o.push({type:"text",value:l}),o}function GC(e,r){const s=String(r.identifier).toUpperCase(),l=e.definitionById.get(s);if(!l)return L1(e,r);const o={src:ci(l.url||""),alt:r.alt};l.title!==null&&l.title!==void 0&&(o.title=l.title);const d={type:"element",tagName:"img",properties:o,children:[]};return e.patch(r,d),e.applyData(r,d)}function XC(e,r){const s={src:ci(r.url)};r.alt!==null&&r.alt!==void 0&&(s.alt=r.alt),r.title!==null&&r.title!==void 0&&(s.title=r.title);const l={type:"element",tagName:"img",properties:s,children:[]};return e.patch(r,l),e.applyData(r,l)}function ZC(e,r){const s={type:"text",value:r.value.replace(/\r?\n|\r/g," ")};e.patch(r,s);const l={type:"element",tagName:"code",properties:{},children:[s]};return e.patch(r,l),e.applyData(r,l)}function QC(e,r){const s=String(r.identifier).toUpperCase(),l=e.definitionById.get(s);if(!l)return L1(e,r);const o={href:ci(l.url||"")};l.title!==null&&l.title!==void 0&&(o.title=l.title);const d={type:"element",tagName:"a",properties:o,children:e.all(r)};return e.patch(r,d),e.applyData(r,d)}function KC(e,r){const s={href:ci(r.url)};r.title!==null&&r.title!==void 0&&(s.title=r.title);const l={type:"element",tagName:"a",properties:s,children:e.all(r)};return e.patch(r,l),e.applyData(r,l)}function JC(e,r,s){const l=e.all(r),o=s?WC(s):z1(r),d={},c=[];if(typeof r.checked=="boolean"){const x=l[0];let g;x&&x.type==="element"&&x.tagName==="p"?g=x:(g={type:"element",tagName:"p",properties:{},children:[]},l.unshift(g)),g.children.length>0&&g.children.unshift({type:"text",value:" "}),g.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:r.checked,disabled:!0},children:[]}),d.className=["task-list-item"]}let h=-1;for(;++h<l.length;){const x=l[h];(o||h!==0||x.type!=="element"||x.tagName!=="p")&&c.push({type:"text",value:`
|
|
16
|
+
`}),x.type==="element"&&x.tagName==="p"&&!o?c.push(...x.children):c.push(x)}const m=l[l.length-1];m&&(o||m.type!=="element"||m.tagName!=="p")&&c.push({type:"text",value:`
|
|
17
|
+
`});const f={type:"element",tagName:"li",properties:d,children:c};return e.patch(r,f),e.applyData(r,f)}function WC(e){let r=!1;if(e.type==="list"){r=e.spread||!1;const s=e.children;let l=-1;for(;!r&&++l<s.length;)r=z1(s[l])}return r}function z1(e){const r=e.spread;return r??e.children.length>1}function eE(e,r){const s={},l=e.all(r);let o=-1;for(typeof r.start=="number"&&r.start!==1&&(s.start=r.start);++o<l.length;){const c=l[o];if(c.type==="element"&&c.tagName==="li"&&c.properties&&Array.isArray(c.properties.className)&&c.properties.className.includes("task-list-item")){s.className=["contains-task-list"];break}}const d={type:"element",tagName:r.ordered?"ol":"ul",properties:s,children:e.wrap(l,!0)};return e.patch(r,d),e.applyData(r,d)}function tE(e,r){const s={type:"element",tagName:"p",properties:{},children:e.all(r)};return e.patch(r,s),e.applyData(r,s)}function nE(e,r){const s={type:"root",children:e.wrap(e.all(r))};return e.patch(r,s),e.applyData(r,s)}function rE(e,r){const s={type:"element",tagName:"strong",properties:{},children:e.all(r)};return e.patch(r,s),e.applyData(r,s)}function sE(e,r){const s=e.all(r),l=s.shift(),o=[];if(l){const c={type:"element",tagName:"thead",properties:{},children:e.wrap([l],!0)};e.patch(r.children[0],c),o.push(c)}if(s.length>0){const c={type:"element",tagName:"tbody",properties:{},children:e.wrap(s,!0)},h=Fm(r.children[1]),m=x1(r.children[r.children.length-1]);h&&m&&(c.position={start:h,end:m}),o.push(c)}const d={type:"element",tagName:"table",properties:{},children:e.wrap(o,!0)};return e.patch(r,d),e.applyData(r,d)}function aE(e,r,s){const l=s?s.children:void 0,d=(l?l.indexOf(r):1)===0?"th":"td",c=s&&s.type==="table"?s.align:void 0,h=c?c.length:r.children.length;let m=-1;const f=[];for(;++m<h;){const g=r.children[m],p={},y=c?c[m]:void 0;y&&(p.align=y);let w={type:"element",tagName:d,properties:p,children:[]};g&&(w.children=e.all(g),e.patch(g,w),w=e.applyData(g,w)),f.push(w)}const x={type:"element",tagName:"tr",properties:{},children:e.wrap(f,!0)};return e.patch(r,x),e.applyData(r,x)}function lE(e,r){const s={type:"element",tagName:"td",properties:{},children:e.all(r)};return e.patch(r,s),e.applyData(r,s)}const $b=9,Bb=32;function iE(e){const r=String(e),s=/\r?\n|\r/g;let l=s.exec(r),o=0;const d=[];for(;l;)d.push(Hb(r.slice(o,l.index),o>0,!0),l[0]),o=l.index+l[0].length,l=s.exec(r);return d.push(Hb(r.slice(o),o>0,!1)),d.join("")}function Hb(e,r,s){let l=0,o=e.length;if(r){let d=e.codePointAt(l);for(;d===$b||d===Bb;)l++,d=e.codePointAt(l)}if(s){let d=e.codePointAt(o-1);for(;d===$b||d===Bb;)o--,d=e.codePointAt(o-1)}return o>l?e.slice(l,o):""}function oE(e,r){const s={type:"text",value:iE(String(r.value))};return e.patch(r,s),e.applyData(r,s)}function cE(e,r){const s={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(r,s),e.applyData(r,s)}const dE={blockquote:BC,break:HC,code:PC,delete:UC,emphasis:qC,footnoteReference:FC,heading:VC,html:YC,imageReference:GC,image:XC,inlineCode:ZC,linkReference:QC,link:KC,listItem:JC,list:eE,paragraph:tE,root:nE,strong:rE,table:sE,tableCell:lE,tableRow:aE,text:oE,thematicBreak:cE,toml:Wc,yaml:Wc,definition:Wc,footnoteDefinition:Wc};function Wc(){}const I1=-1,Gd=0,go=1,Nd=2,Km=3,Jm=4,Wm=5,ex=6,$1=7,B1=8,Pb=typeof self=="object"?self:globalThis,uE=(e,r)=>{const s=(o,d)=>(e.set(d,o),o),l=o=>{if(e.has(o))return e.get(o);const[d,c]=r[o];switch(d){case Gd:case I1:return s(c,o);case go:{const h=s([],o);for(const m of c)h.push(l(m));return h}case Nd:{const h=s({},o);for(const[m,f]of c)h[l(m)]=l(f);return h}case Km:return s(new Date(c),o);case Jm:{const{source:h,flags:m}=c;return s(new RegExp(h,m),o)}case Wm:{const h=s(new Map,o);for(const[m,f]of c)h.set(l(m),l(f));return h}case ex:{const h=s(new Set,o);for(const m of c)h.add(l(m));return h}case $1:{const{name:h,message:m}=c;return s(new Pb[h](m),o)}case B1:return s(BigInt(c),o);case"BigInt":return s(Object(BigInt(c)),o);case"ArrayBuffer":return s(new Uint8Array(c).buffer,c);case"DataView":{const{buffer:h}=new Uint8Array(c);return s(new DataView(h),c)}}return s(new Pb[d](c),o)};return l},Ub=e=>uE(new Map,e)(0),Hl="",{toString:fE}={},{keys:hE}=Object,no=e=>{const r=typeof e;if(r!=="object"||!e)return[Gd,r];const s=fE.call(e).slice(8,-1);switch(s){case"Array":return[go,Hl];case"Object":return[Nd,Hl];case"Date":return[Km,Hl];case"RegExp":return[Jm,Hl];case"Map":return[Wm,Hl];case"Set":return[ex,Hl];case"DataView":return[go,s]}return s.includes("Array")?[go,s]:s.includes("Error")?[$1,s]:[Nd,s]},ed=([e,r])=>e===Gd&&(r==="function"||r==="symbol"),mE=(e,r,s,l)=>{const o=(c,h)=>{const m=l.push(c)-1;return s.set(h,m),m},d=c=>{if(s.has(c))return s.get(c);let[h,m]=no(c);switch(h){case Gd:{let x=c;switch(m){case"bigint":h=B1,x=c.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+m);x=null;break;case"undefined":return o([I1],c)}return o([h,x],c)}case go:{if(m){let p=c;return m==="DataView"?p=new Uint8Array(c.buffer):m==="ArrayBuffer"&&(p=new Uint8Array(c)),o([m,[...p]],c)}const x=[],g=o([h,x],c);for(const p of c)x.push(d(p));return g}case Nd:{if(m)switch(m){case"BigInt":return o([m,c.toString()],c);case"Boolean":case"Number":case"String":return o([m,c.valueOf()],c)}if(r&&"toJSON"in c)return d(c.toJSON());const x=[],g=o([h,x],c);for(const p of hE(c))(e||!ed(no(c[p])))&&x.push([d(p),d(c[p])]);return g}case Km:return o([h,c.toISOString()],c);case Jm:{const{source:x,flags:g}=c;return o([h,{source:x,flags:g}],c)}case Wm:{const x=[],g=o([h,x],c);for(const[p,y]of c)(e||!(ed(no(p))||ed(no(y))))&&x.push([d(p),d(y)]);return g}case ex:{const x=[],g=o([h,x],c);for(const p of c)(e||!ed(no(p)))&&x.push(d(p));return g}}const{message:f}=c;return o([h,{name:m,message:f}],c)};return d},qb=(e,{json:r,lossy:s}={})=>{const l=[];return mE(!(r||s),!!r,new Map,l)(e),l},kd=typeof structuredClone=="function"?(e,r)=>r&&("json"in r||"lossy"in r)?Ub(qb(e,r)):structuredClone(e):(e,r)=>Ub(qb(e,r));function xE(e,r){const s=[{type:"text",value:"↩"}];return r>1&&s.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(r)}]}),s}function gE(e,r){return"Back to reference "+(e+1)+(r>1?"-"+r:"")}function pE(e){const r=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",s=e.options.footnoteBackContent||xE,l=e.options.footnoteBackLabel||gE,o=e.options.footnoteLabel||"Footnotes",d=e.options.footnoteLabelTagName||"h2",c=e.options.footnoteLabelProperties||{className:["sr-only"]},h=[];let m=-1;for(;++m<e.footnoteOrder.length;){const f=e.footnoteById.get(e.footnoteOrder[m]);if(!f)continue;const x=e.all(f),g=String(f.identifier).toUpperCase(),p=ci(g.toLowerCase());let y=0;const w=[],N=e.footnoteCounts.get(g);for(;N!==void 0&&++y<=N;){w.length>0&&w.push({type:"text",value:" "});let C=typeof s=="string"?s:s(m,y);typeof C=="string"&&(C={type:"text",value:C}),w.push({type:"element",tagName:"a",properties:{href:"#"+r+"fnref-"+p+(y>1?"-"+y:""),dataFootnoteBackref:"",ariaLabel:typeof l=="string"?l:l(m,y),className:["data-footnote-backref"]},children:Array.isArray(C)?C:[C]})}const E=x[x.length-1];if(E&&E.type==="element"&&E.tagName==="p"){const C=E.children[E.children.length-1];C&&C.type==="text"?C.value+=" ":E.children.push({type:"text",value:" "}),E.children.push(...w)}else x.push(...w);const A={type:"element",tagName:"li",properties:{id:r+"fn-"+p},children:e.wrap(x,!0)};e.patch(f,A),h.push(A)}if(h.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:d,properties:{...kd(c),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:`
|
|
18
|
+
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(h,!0)},{type:"text",value:`
|
|
19
|
+
`}]}}const Xd=(function(e){if(e==null)return jE;if(typeof e=="function")return Zd(e);if(typeof e=="object")return Array.isArray(e)?bE(e):yE(e);if(typeof e=="string")return vE(e);throw new Error("Expected function, string, or object as test")});function bE(e){const r=[];let s=-1;for(;++s<e.length;)r[s]=Xd(e[s]);return Zd(l);function l(...o){let d=-1;for(;++d<r.length;)if(r[d].apply(this,o))return!0;return!1}}function yE(e){const r=e;return Zd(s);function s(l){const o=l;let d;for(d in e)if(o[d]!==r[d])return!1;return!0}}function vE(e){return Zd(r);function r(s){return s&&s.type===e}}function Zd(e){return r;function r(s,l,o){return!!(wE(s)&&e.call(this,s,typeof l=="number"?l:void 0,o||void 0))}}function jE(){return!0}function wE(e){return e!==null&&typeof e=="object"&&"type"in e}const H1=[],NE=!0,hm=!1,kE="skip";function P1(e,r,s,l){let o;typeof r=="function"&&typeof s!="function"?(l=s,s=r):o=r;const d=Xd(o),c=l?-1:1;h(e,void 0,[])();function h(m,f,x){const g=m&&typeof m=="object"?m:{};if(typeof g.type=="string"){const y=typeof g.tagName=="string"?g.tagName:typeof g.name=="string"?g.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(m.type+(y?"<"+y+">":""))+")"})}return p;function p(){let y=H1,w,N,E;if((!r||d(m,f,x[x.length-1]||void 0))&&(y=SE(s(m,x)),y[0]===hm))return y;if("children"in m&&m.children){const A=m;if(A.children&&y[0]!==kE)for(N=(l?A.children.length:-1)+c,E=x.concat(A);N>-1&&N<A.children.length;){const C=A.children[N];if(w=h(C,N,E)(),w[0]===hm)return w;N=typeof w[1]=="number"?w[1]:N+c}}return y}}}function SE(e){return Array.isArray(e)?e:typeof e=="number"?[NE,e]:e==null?H1:[e]}function tx(e,r,s,l){let o,d,c;typeof r=="function"&&typeof s!="function"?(d=void 0,c=r,o=s):(d=r,c=s,o=l),P1(e,d,h,o);function h(m,f){const x=f[f.length-1],g=x?x.children.indexOf(m):void 0;return c(m,g,x)}}const mm={}.hasOwnProperty,CE={};function EE(e,r){const s=r||CE,l=new Map,o=new Map,d=new Map,c={...dE,...s.handlers},h={all:f,applyData:AE,definitionById:l,footnoteById:o,footnoteCounts:d,footnoteOrder:[],handlers:c,one:m,options:s,patch:TE,wrap:ME};return tx(e,function(x){if(x.type==="definition"||x.type==="footnoteDefinition"){const g=x.type==="definition"?l:o,p=String(x.identifier).toUpperCase();g.has(p)||g.set(p,x)}}),h;function m(x,g){const p=x.type,y=h.handlers[p];if(mm.call(h.handlers,p)&&y)return y(h,x,g);if(h.options.passThrough&&h.options.passThrough.includes(p)){if("children"in x){const{children:N,...E}=x,A=kd(E);return A.children=h.all(x),A}return kd(x)}return(h.options.unknownHandler||_E)(h,x,g)}function f(x){const g=[];if("children"in x){const p=x.children;let y=-1;for(;++y<p.length;){const w=h.one(p[y],x);if(w){if(y&&p[y-1].type==="break"&&(!Array.isArray(w)&&w.type==="text"&&(w.value=Fb(w.value)),!Array.isArray(w)&&w.type==="element")){const N=w.children[0];N&&N.type==="text"&&(N.value=Fb(N.value))}Array.isArray(w)?g.push(...w):g.push(w)}}}return g}}function TE(e,r){e.position&&(r.position=gk(e))}function AE(e,r){let s=r;if(e&&e.data){const l=e.data.hName,o=e.data.hChildren,d=e.data.hProperties;if(typeof l=="string")if(s.type==="element")s.tagName=l;else{const c="children"in s?s.children:[s];s={type:"element",tagName:l,properties:{},children:c}}s.type==="element"&&d&&Object.assign(s.properties,kd(d)),"children"in s&&s.children&&o!==null&&o!==void 0&&(s.children=o)}return s}function _E(e,r){const s=r.data||{},l="value"in r&&!(mm.call(s,"hProperties")||mm.call(s,"hChildren"))?{type:"text",value:r.value}:{type:"element",tagName:"div",properties:{},children:e.all(r)};return e.patch(r,l),e.applyData(r,l)}function ME(e,r){const s=[];let l=-1;for(r&&s.push({type:"text",value:`
|
|
20
|
+
`});++l<e.length;)l&&s.push({type:"text",value:`
|
|
21
|
+
`}),s.push(e[l]);return r&&e.length>0&&s.push({type:"text",value:`
|
|
22
|
+
`}),s}function Fb(e){let r=0,s=e.charCodeAt(r);for(;s===9||s===32;)r++,s=e.charCodeAt(r);return e.slice(r)}function Vb(e,r){const s=EE(e,r),l=s.one(e,void 0),o=pE(s),d=Array.isArray(l)?{type:"root",children:l}:l||{type:"root",children:[]};return o&&d.children.push({type:"text",value:`
|
|
23
|
+
`},o),d}function DE(e,r){return e&&"run"in e?async function(s,l){const o=Vb(s,{file:l,...r});await e.run(o,l)}:function(s,l){return Vb(s,{file:l,...e||r})}}function Yb(e){if(e)throw e}var Nh,Gb;function OE(){if(Gb)return Nh;Gb=1;var e=Object.prototype.hasOwnProperty,r=Object.prototype.toString,s=Object.defineProperty,l=Object.getOwnPropertyDescriptor,o=function(f){return typeof Array.isArray=="function"?Array.isArray(f):r.call(f)==="[object Array]"},d=function(f){if(!f||r.call(f)!=="[object Object]")return!1;var x=e.call(f,"constructor"),g=f.constructor&&f.constructor.prototype&&e.call(f.constructor.prototype,"isPrototypeOf");if(f.constructor&&!x&&!g)return!1;var p;for(p in f);return typeof p>"u"||e.call(f,p)},c=function(f,x){s&&x.name==="__proto__"?s(f,x.name,{enumerable:!0,configurable:!0,value:x.newValue,writable:!0}):f[x.name]=x.newValue},h=function(f,x){if(x==="__proto__")if(e.call(f,x)){if(l)return l(f,x).value}else return;return f[x]};return Nh=function m(){var f,x,g,p,y,w,N=arguments[0],E=1,A=arguments.length,C=!1;for(typeof N=="boolean"&&(C=N,N=arguments[1]||{},E=2),(N==null||typeof N!="object"&&typeof N!="function")&&(N={});E<A;++E)if(f=arguments[E],f!=null)for(x in f)g=h(N,x),p=h(f,x),N!==p&&(C&&p&&(d(p)||(y=o(p)))?(y?(y=!1,w=g&&o(g)?g:[]):w=g&&d(g)?g:{},c(N,{name:x,newValue:m(C,w,p)})):typeof p<"u"&&c(N,{name:x,newValue:p}));return N},Nh}var RE=OE();const kh=Fd(RE);function xm(e){if(typeof e!="object"||e===null)return!1;const r=Object.getPrototypeOf(e);return(r===null||r===Object.prototype||Object.getPrototypeOf(r)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function LE(){const e=[],r={run:s,use:l};return r;function s(...o){let d=-1;const c=o.pop();if(typeof c!="function")throw new TypeError("Expected function as last argument, not "+c);h(null,...o);function h(m,...f){const x=e[++d];let g=-1;if(m){c(m);return}for(;++g<o.length;)(f[g]===null||f[g]===void 0)&&(f[g]=o[g]);o=f,x?zE(x,h)(...f):c(null,...f)}}function l(o){if(typeof o!="function")throw new TypeError("Expected `middelware` to be a function, not "+o);return e.push(o),r}}function zE(e,r){let s;return l;function l(...c){const h=e.length>c.length;let m;h&&c.push(o);try{m=e.apply(this,c)}catch(f){const x=f;if(h&&s)throw x;return o(x)}h||(m&&m.then&&typeof m.then=="function"?m.then(d,o):m instanceof Error?o(m):d(m))}function o(c,...h){s||(s=!0,r(c,...h))}function d(c){o(null,c)}}const bs={basename:IE,dirname:$E,extname:BE,join:HE,sep:"/"};function IE(e,r){if(r!==void 0&&typeof r!="string")throw new TypeError('"ext" argument must be a string');Io(e);let s=0,l=-1,o=e.length,d;if(r===void 0||r.length===0||r.length>e.length){for(;o--;)if(e.codePointAt(o)===47){if(d){s=o+1;break}}else l<0&&(d=!0,l=o+1);return l<0?"":e.slice(s,l)}if(r===e)return"";let c=-1,h=r.length-1;for(;o--;)if(e.codePointAt(o)===47){if(d){s=o+1;break}}else c<0&&(d=!0,c=o+1),h>-1&&(e.codePointAt(o)===r.codePointAt(h--)?h<0&&(l=o):(h=-1,l=c));return s===l?l=c:l<0&&(l=e.length),e.slice(s,l)}function $E(e){if(Io(e),e.length===0)return".";let r=-1,s=e.length,l;for(;--s;)if(e.codePointAt(s)===47){if(l){r=s;break}}else l||(l=!0);return r<0?e.codePointAt(0)===47?"/":".":r===1&&e.codePointAt(0)===47?"//":e.slice(0,r)}function BE(e){Io(e);let r=e.length,s=-1,l=0,o=-1,d=0,c;for(;r--;){const h=e.codePointAt(r);if(h===47){if(c){l=r+1;break}continue}s<0&&(c=!0,s=r+1),h===46?o<0?o=r:d!==1&&(d=1):o>-1&&(d=-1)}return o<0||s<0||d===0||d===1&&o===s-1&&o===l+1?"":e.slice(o,s)}function HE(...e){let r=-1,s;for(;++r<e.length;)Io(e[r]),e[r]&&(s=s===void 0?e[r]:s+"/"+e[r]);return s===void 0?".":PE(s)}function PE(e){Io(e);const r=e.codePointAt(0)===47;let s=UE(e,!r);return s.length===0&&!r&&(s="."),s.length>0&&e.codePointAt(e.length-1)===47&&(s+="/"),r?"/"+s:s}function UE(e,r){let s="",l=0,o=-1,d=0,c=-1,h,m;for(;++c<=e.length;){if(c<e.length)h=e.codePointAt(c);else{if(h===47)break;h=47}if(h===47){if(!(o===c-1||d===1))if(o!==c-1&&d===2){if(s.length<2||l!==2||s.codePointAt(s.length-1)!==46||s.codePointAt(s.length-2)!==46){if(s.length>2){if(m=s.lastIndexOf("/"),m!==s.length-1){m<0?(s="",l=0):(s=s.slice(0,m),l=s.length-1-s.lastIndexOf("/")),o=c,d=0;continue}}else if(s.length>0){s="",l=0,o=c,d=0;continue}}r&&(s=s.length>0?s+"/..":"..",l=2)}else s.length>0?s+="/"+e.slice(o+1,c):s=e.slice(o+1,c),l=c-o-1;o=c,d=0}else h===46&&d>-1?d++:d=-1}return s}function Io(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const qE={cwd:FE};function FE(){return"/"}function gm(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function VE(e){if(typeof e=="string")e=new URL(e);else if(!gm(e)){const r=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw r.code="ERR_INVALID_ARG_TYPE",r}if(e.protocol!=="file:"){const r=new TypeError("The URL must be of scheme file");throw r.code="ERR_INVALID_URL_SCHEME",r}return YE(e)}function YE(e){if(e.hostname!==""){const l=new TypeError('File URL host must be "localhost" or empty on darwin');throw l.code="ERR_INVALID_FILE_URL_HOST",l}const r=e.pathname;let s=-1;for(;++s<r.length;)if(r.codePointAt(s)===37&&r.codePointAt(s+1)===50){const l=r.codePointAt(s+2);if(l===70||l===102){const o=new TypeError("File URL path must not include encoded / characters");throw o.code="ERR_INVALID_FILE_URL_PATH",o}}return decodeURIComponent(r)}const Sh=["history","path","basename","stem","extname","dirname"];class U1{constructor(r){let s;r?gm(r)?s={path:r}:typeof r=="string"||GE(r)?s={value:r}:s=r:s={},this.cwd="cwd"in s?"":qE.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let l=-1;for(;++l<Sh.length;){const d=Sh[l];d in s&&s[d]!==void 0&&s[d]!==null&&(this[d]=d==="history"?[...s[d]]:s[d])}let o;for(o in s)Sh.includes(o)||(this[o]=s[o])}get basename(){return typeof this.path=="string"?bs.basename(this.path):void 0}set basename(r){Eh(r,"basename"),Ch(r,"basename"),this.path=bs.join(this.dirname||"",r)}get dirname(){return typeof this.path=="string"?bs.dirname(this.path):void 0}set dirname(r){Xb(this.basename,"dirname"),this.path=bs.join(r||"",this.basename)}get extname(){return typeof this.path=="string"?bs.extname(this.path):void 0}set extname(r){if(Ch(r,"extname"),Xb(this.dirname,"extname"),r){if(r.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(r.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=bs.join(this.dirname,this.stem+(r||""))}get path(){return this.history[this.history.length-1]}set path(r){gm(r)&&(r=VE(r)),Eh(r,"path"),this.path!==r&&this.history.push(r)}get stem(){return typeof this.path=="string"?bs.basename(this.path,this.extname):void 0}set stem(r){Eh(r,"stem"),Ch(r,"stem"),this.path=bs.join(this.dirname||"",r+(this.extname||""))}fail(r,s,l){const o=this.message(r,s,l);throw o.fatal=!0,o}info(r,s,l){const o=this.message(r,s,l);return o.fatal=void 0,o}message(r,s,l){const o=new ir(r,s,l);return this.path&&(o.name=this.path+":"+o.name,o.file=this.path),o.fatal=!1,this.messages.push(o),o}toString(r){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(r||void 0).decode(this.value)}}function Ch(e,r){if(e&&e.includes(bs.sep))throw new Error("`"+r+"` cannot be a path: did not expect `"+bs.sep+"`")}function Eh(e,r){if(!e)throw new Error("`"+r+"` cannot be empty")}function Xb(e,r){if(!e)throw new Error("Setting `"+r+"` requires `path` to be set too")}function GE(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const XE=(function(e){const l=this.constructor.prototype,o=l[e],d=function(){return o.apply(d,arguments)};return Object.setPrototypeOf(d,l),d}),ZE={}.hasOwnProperty;class nx extends XE{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=LE()}copy(){const r=new nx;let s=-1;for(;++s<this.attachers.length;){const l=this.attachers[s];r.use(...l)}return r.data(kh(!0,{},this.namespace)),r}data(r,s){return typeof r=="string"?arguments.length===2?(_h("data",this.frozen),this.namespace[r]=s,this):ZE.call(this.namespace,r)&&this.namespace[r]||void 0:r?(_h("data",this.frozen),this.namespace=r,this):this.namespace}freeze(){if(this.frozen)return this;const r=this;for(;++this.freezeIndex<this.attachers.length;){const[s,...l]=this.attachers[this.freezeIndex];if(l[0]===!1)continue;l[0]===!0&&(l[0]=void 0);const o=s.call(r,...l);typeof o=="function"&&this.transformers.use(o)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(r){this.freeze();const s=td(r),l=this.parser||this.Parser;return Th("parse",l),l(String(s),s)}process(r,s){const l=this;return this.freeze(),Th("process",this.parser||this.Parser),Ah("process",this.compiler||this.Compiler),s?o(void 0,s):new Promise(o);function o(d,c){const h=td(r),m=l.parse(h);l.run(m,h,function(x,g,p){if(x||!g||!p)return f(x);const y=g,w=l.stringify(y,p);JE(w)?p.value=w:p.result=w,f(x,p)});function f(x,g){x||!g?c(x):d?d(g):s(void 0,g)}}}processSync(r){let s=!1,l;return this.freeze(),Th("processSync",this.parser||this.Parser),Ah("processSync",this.compiler||this.Compiler),this.process(r,o),Qb("processSync","process",s),l;function o(d,c){s=!0,Yb(d),l=c}}run(r,s,l){Zb(r),this.freeze();const o=this.transformers;return!l&&typeof s=="function"&&(l=s,s=void 0),l?d(void 0,l):new Promise(d);function d(c,h){const m=td(s);o.run(r,m,f);function f(x,g,p){const y=g||r;x?h(x):c?c(y):l(void 0,y,p)}}}runSync(r,s){let l=!1,o;return this.run(r,s,d),Qb("runSync","run",l),o;function d(c,h){Yb(c),o=h,l=!0}}stringify(r,s){this.freeze();const l=td(s),o=this.compiler||this.Compiler;return Ah("stringify",o),Zb(r),o(r,l)}use(r,...s){const l=this.attachers,o=this.namespace;if(_h("use",this.frozen),r!=null)if(typeof r=="function")m(r,s);else if(typeof r=="object")Array.isArray(r)?h(r):c(r);else throw new TypeError("Expected usable value, not `"+r+"`");return this;function d(f){if(typeof f=="function")m(f,[]);else if(typeof f=="object")if(Array.isArray(f)){const[x,...g]=f;m(x,g)}else c(f);else throw new TypeError("Expected usable value, not `"+f+"`")}function c(f){if(!("plugins"in f)&&!("settings"in f))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");h(f.plugins),f.settings&&(o.settings=kh(!0,o.settings,f.settings))}function h(f){let x=-1;if(f!=null)if(Array.isArray(f))for(;++x<f.length;){const g=f[x];d(g)}else throw new TypeError("Expected a list of plugins, not `"+f+"`")}function m(f,x){let g=-1,p=-1;for(;++g<l.length;)if(l[g][0]===f){p=g;break}if(p===-1)l.push([f,...x]);else if(x.length>0){let[y,...w]=x;const N=l[p][1];xm(N)&&xm(y)&&(y=kh(!0,N,y)),l[p]=[f,y,...w]}}}}const QE=new nx().freeze();function Th(e,r){if(typeof r!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Ah(e,r){if(typeof r!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function _h(e,r){if(r)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Zb(e){if(!xm(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Qb(e,r,s){if(!s)throw new Error("`"+e+"` finished async. Use `"+r+"` instead")}function td(e){return KE(e)?e:new U1(e)}function KE(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function JE(e){return typeof e=="string"||WE(e)}function WE(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const e3="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Kb=[],Jb={allowDangerousHtml:!0},t3=/^(https?|ircs?|mailto|xmpp)$/i,n3=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Wb(e){const r=r3(e),s=s3(e);return a3(r.runSync(r.parse(s),s),e)}function r3(e){const r=e.rehypePlugins||Kb,s=e.remarkPlugins||Kb,l=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Jb}:Jb;return QE().use($C).use(s).use(DE,l).use(r)}function s3(e){const r=e.children||"",s=new U1;return typeof r=="string"&&(s.value=r),s}function a3(e,r){const s=r.allowedElements,l=r.allowElement,o=r.components,d=r.disallowedElements,c=r.skipHtml,h=r.unwrapDisallowed,m=r.urlTransform||l3;for(const x of n3)Object.hasOwn(r,x.from)&&(""+x.from+(x.to?"use `"+x.to+"` instead":"remove it")+e3+x.id,void 0);return tx(e,f),jk(e,{Fragment:t.Fragment,components:o,ignoreInvalidStyle:!0,jsx:t.jsx,jsxs:t.jsxs,passKeys:!0,passNode:!0});function f(x,g,p){if(x.type==="raw"&&p&&typeof g=="number")return c?p.children.splice(g,1):p.children[g]={type:"text",value:x.value},g;if(x.type==="element"){let y;for(y in vh)if(Object.hasOwn(vh,y)&&Object.hasOwn(x.properties,y)){const w=x.properties[y],N=vh[y];(N===null||N.includes(x.tagName))&&(x.properties[y]=m(String(w||""),y,x))}}if(x.type==="element"){let y=s?!s.includes(x.tagName):d?d.includes(x.tagName):!1;if(!y&&l&&typeof g=="number"&&(y=!l(x,g,p)),y&&p&&typeof g=="number")return h&&x.children?p.children.splice(g,1,...x.children):p.children.splice(g,1),g}}}function l3(e){const r=e.indexOf(":"),s=e.indexOf("?"),l=e.indexOf("#"),o=e.indexOf("/");return r===-1||o!==-1&&r>o||s!==-1&&r>s||l!==-1&&r>l||t3.test(e.slice(0,r))?e:""}function ey(e,r){const s=String(e);if(typeof r!="string")throw new TypeError("Expected character");let l=0,o=s.indexOf(r);for(;o!==-1;)l++,o=s.indexOf(r,o+r.length);return l}function i3(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function o3(e,r,s){const o=Xd((s||{}).ignore||[]),d=c3(r);let c=-1;for(;++c<d.length;)P1(e,"text",h);function h(f,x){let g=-1,p;for(;++g<x.length;){const y=x[g],w=p?p.children:void 0;if(o(y,w?w.indexOf(y):void 0,p))return;p=y}if(p)return m(f,x)}function m(f,x){const g=x[x.length-1],p=d[c][0],y=d[c][1];let w=0;const E=g.children.indexOf(f);let A=!1,C=[];p.lastIndex=0;let k=p.exec(f.value);for(;k;){const S=k.index,O={index:k.index,input:k.input,stack:[...x,f]};let R=y(...k,O);if(typeof R=="string"&&(R=R.length>0?{type:"text",value:R}:void 0),R===!1?p.lastIndex=S+1:(w!==S&&C.push({type:"text",value:f.value.slice(w,S)}),Array.isArray(R)?C.push(...R):R&&C.push(R),w=S+k[0].length,A=!0),!p.global)break;k=p.exec(f.value)}return A?(w<f.value.length&&C.push({type:"text",value:f.value.slice(w)}),g.children.splice(E,1,...C)):C=[f],E+C.length}}function c3(e){const r=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const s=!e[0]||Array.isArray(e[0])?e:[e];let l=-1;for(;++l<s.length;){const o=s[l];r.push([d3(o[0]),u3(o[1])])}return r}function d3(e){return typeof e=="string"?new RegExp(i3(e),"g"):e}function u3(e){return typeof e=="function"?e:function(){return e}}const Mh="phrasing",Dh=["autolink","link","image","label"];function f3(){return{transforms:[y3],enter:{literalAutolink:m3,literalAutolinkEmail:Oh,literalAutolinkHttp:Oh,literalAutolinkWww:Oh},exit:{literalAutolink:b3,literalAutolinkEmail:p3,literalAutolinkHttp:x3,literalAutolinkWww:g3}}}function h3(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Mh,notInConstruct:Dh},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Mh,notInConstruct:Dh},{character:":",before:"[ps]",after:"\\/",inConstruct:Mh,notInConstruct:Dh}]}}function m3(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Oh(e){this.config.enter.autolinkProtocol.call(this,e)}function x3(e){this.config.exit.autolinkProtocol.call(this,e)}function g3(e){this.config.exit.data.call(this,e);const r=this.stack[this.stack.length-1];r.type,r.url="http://"+this.sliceSerialize(e)}function p3(e){this.config.exit.autolinkEmail.call(this,e)}function b3(e){this.exit(e)}function y3(e){o3(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,v3],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),j3]],{ignore:["link","linkReference"]})}function v3(e,r,s,l,o){let d="";if(!q1(o)||(/^w/i.test(r)&&(s=r+s,r="",d="http://"),!w3(s)))return!1;const c=N3(s+l);if(!c[0])return!1;const h={type:"link",title:null,url:d+r+c[0],children:[{type:"text",value:r+c[0]}]};return c[1]?[h,{type:"text",value:c[1]}]:h}function j3(e,r,s,l){return!q1(l,!0)||/[-\d_]$/.test(s)?!1:{type:"link",title:null,url:"mailto:"+r+"@"+s,children:[{type:"text",value:r+"@"+s}]}}function w3(e){const r=e.split(".");return!(r.length<2||r[r.length-1]&&(/_/.test(r[r.length-1])||!/[a-zA-Z\d]/.test(r[r.length-1]))||r[r.length-2]&&(/_/.test(r[r.length-2])||!/[a-zA-Z\d]/.test(r[r.length-2])))}function N3(e){const r=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!r)return[e,void 0];e=e.slice(0,r.index);let s=r[0],l=s.indexOf(")");const o=ey(e,"(");let d=ey(e,")");for(;l!==-1&&o>d;)e+=s.slice(0,l+1),s=s.slice(l+1),l=s.indexOf(")"),d++;return[e,s]}function q1(e,r){const s=e.input.charCodeAt(e.index-1);return(e.index===0||rl(s)||Vd(s))&&(!r||s!==47)}F1.peek=D3;function k3(){this.buffer()}function S3(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function C3(){this.buffer()}function E3(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function T3(e){const r=this.resume(),s=this.stack[this.stack.length-1];s.type,s.identifier=as(this.sliceSerialize(e)).toLowerCase(),s.label=r}function A3(e){this.exit(e)}function _3(e){const r=this.resume(),s=this.stack[this.stack.length-1];s.type,s.identifier=as(this.sliceSerialize(e)).toLowerCase(),s.label=r}function M3(e){this.exit(e)}function D3(){return"["}function F1(e,r,s,l){const o=s.createTracker(l);let d=o.move("[^");const c=s.enter("footnoteReference"),h=s.enter("reference");return d+=o.move(s.safe(s.associationId(e),{after:"]",before:d})),h(),c(),d+=o.move("]"),d}function O3(){return{enter:{gfmFootnoteCallString:k3,gfmFootnoteCall:S3,gfmFootnoteDefinitionLabelString:C3,gfmFootnoteDefinition:E3},exit:{gfmFootnoteCallString:T3,gfmFootnoteCall:A3,gfmFootnoteDefinitionLabelString:_3,gfmFootnoteDefinition:M3}}}function R3(e){let r=!1;return e&&e.firstLineBlank&&(r=!0),{handlers:{footnoteDefinition:s,footnoteReference:F1},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function s(l,o,d,c){const h=d.createTracker(c);let m=h.move("[^");const f=d.enter("footnoteDefinition"),x=d.enter("label");return m+=h.move(d.safe(d.associationId(l),{before:m,after:"]"})),x(),m+=h.move("]:"),l.children&&l.children.length>0&&(h.shift(4),m+=h.move((r?`
|
|
24
|
+
`:" ")+d.indentLines(d.containerFlow(l,h.current()),r?V1:L3))),f(),m}}function L3(e,r,s){return r===0?e:V1(e,r,s)}function V1(e,r,s){return(s?"":" ")+e}const z3=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Y1.peek=P3;function I3(){return{canContainEols:["delete"],enter:{strikethrough:B3},exit:{strikethrough:H3}}}function $3(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:z3}],handlers:{delete:Y1}}}function B3(e){this.enter({type:"delete",children:[]},e)}function H3(e){this.exit(e)}function Y1(e,r,s,l){const o=s.createTracker(l),d=s.enter("strikethrough");let c=o.move("~~");return c+=s.containerPhrasing(e,{...o.current(),before:c,after:"~"}),c+=o.move("~~"),d(),c}function P3(){return"~"}function U3(e){return e.length}function q3(e,r){const s=r||{},l=(s.align||[]).concat(),o=s.stringLength||U3,d=[],c=[],h=[],m=[];let f=0,x=-1;for(;++x<e.length;){const N=[],E=[];let A=-1;for(e[x].length>f&&(f=e[x].length);++A<e[x].length;){const C=F3(e[x][A]);if(s.alignDelimiters!==!1){const k=o(C);E[A]=k,(m[A]===void 0||k>m[A])&&(m[A]=k)}N.push(C)}c[x]=N,h[x]=E}let g=-1;if(typeof l=="object"&&"length"in l)for(;++g<f;)d[g]=ty(l[g]);else{const N=ty(l);for(;++g<f;)d[g]=N}g=-1;const p=[],y=[];for(;++g<f;){const N=d[g];let E="",A="";N===99?(E=":",A=":"):N===108?E=":":N===114&&(A=":");let C=s.alignDelimiters===!1?1:Math.max(1,m[g]-E.length-A.length);const k=E+"-".repeat(C)+A;s.alignDelimiters!==!1&&(C=E.length+C+A.length,C>m[g]&&(m[g]=C),y[g]=C),p[g]=k}c.splice(1,0,p),h.splice(1,0,y),x=-1;const w=[];for(;++x<c.length;){const N=c[x],E=h[x];g=-1;const A=[];for(;++g<f;){const C=N[g]||"";let k="",S="";if(s.alignDelimiters!==!1){const O=m[g]-(E[g]||0),R=d[g];R===114?k=" ".repeat(O):R===99?O%2?(k=" ".repeat(O/2+.5),S=" ".repeat(O/2-.5)):(k=" ".repeat(O/2),S=k):S=" ".repeat(O)}s.delimiterStart!==!1&&!g&&A.push("|"),s.padding!==!1&&!(s.alignDelimiters===!1&&C==="")&&(s.delimiterStart!==!1||g)&&A.push(" "),s.alignDelimiters!==!1&&A.push(k),A.push(C),s.alignDelimiters!==!1&&A.push(S),s.padding!==!1&&A.push(" "),(s.delimiterEnd!==!1||g!==f-1)&&A.push("|")}w.push(s.delimiterEnd===!1?A.join("").replace(/ +$/,""):A.join(""))}return w.join(`
|
|
25
|
+
`)}function F3(e){return e==null?"":String(e)}function ty(e){const r=typeof e=="string"?e.codePointAt(0):0;return r===67||r===99?99:r===76||r===108?108:r===82||r===114?114:0}function V3(e,r,s,l){const o=s.enter("blockquote"),d=s.createTracker(l);d.move("> "),d.shift(2);const c=s.indentLines(s.containerFlow(e,d.current()),Y3);return o(),c}function Y3(e,r,s){return">"+(s?"":" ")+e}function G3(e,r){return ny(e,r.inConstruct,!0)&&!ny(e,r.notInConstruct,!1)}function ny(e,r,s){if(typeof r=="string"&&(r=[r]),!r||r.length===0)return s;let l=-1;for(;++l<r.length;)if(e.includes(r[l]))return!0;return!1}function ry(e,r,s,l){let o=-1;for(;++o<s.unsafe.length;)if(s.unsafe[o].character===`
|
|
26
|
+
`&&G3(s.stack,s.unsafe[o]))return/[ \t]/.test(l.before)?"":" ";return`\\
|
|
27
|
+
`}function X3(e,r){const s=String(e);let l=s.indexOf(r),o=l,d=0,c=0;if(typeof r!="string")throw new TypeError("Expected substring");for(;l!==-1;)l===o?++d>c&&(c=d):d=1,o=l+r.length,l=s.indexOf(r,o);return c}function Z3(e,r){return!!(r.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function Q3(e){const r=e.options.fence||"`";if(r!=="`"&&r!=="~")throw new Error("Cannot serialize code with `"+r+"` for `options.fence`, expected `` ` `` or `~`");return r}function K3(e,r,s,l){const o=Q3(s),d=e.value||"",c=o==="`"?"GraveAccent":"Tilde";if(Z3(e,s)){const g=s.enter("codeIndented"),p=s.indentLines(d,J3);return g(),p}const h=s.createTracker(l),m=o.repeat(Math.max(X3(d,o)+1,3)),f=s.enter("codeFenced");let x=h.move(m);if(e.lang){const g=s.enter(`codeFencedLang${c}`);x+=h.move(s.safe(e.lang,{before:x,after:" ",encode:["`"],...h.current()})),g()}if(e.lang&&e.meta){const g=s.enter(`codeFencedMeta${c}`);x+=h.move(" "),x+=h.move(s.safe(e.meta,{before:x,after:`
|
|
28
|
+
`,encode:["`"],...h.current()})),g()}return x+=h.move(`
|
|
29
|
+
`),d&&(x+=h.move(d+`
|
|
30
|
+
`)),x+=h.move(m),f(),x}function J3(e,r,s){return(s?"":" ")+e}function rx(e){const r=e.options.quote||'"';if(r!=='"'&&r!=="'")throw new Error("Cannot serialize title with `"+r+"` for `options.quote`, expected `\"`, or `'`");return r}function W3(e,r,s,l){const o=rx(s),d=o==='"'?"Quote":"Apostrophe",c=s.enter("definition");let h=s.enter("label");const m=s.createTracker(l);let f=m.move("[");return f+=m.move(s.safe(s.associationId(e),{before:f,after:"]",...m.current()})),f+=m.move("]: "),h(),!e.url||/[\0- \u007F]/.test(e.url)?(h=s.enter("destinationLiteral"),f+=m.move("<"),f+=m.move(s.safe(e.url,{before:f,after:">",...m.current()})),f+=m.move(">")):(h=s.enter("destinationRaw"),f+=m.move(s.safe(e.url,{before:f,after:e.title?" ":`
|
|
31
|
+
`,...m.current()}))),h(),e.title&&(h=s.enter(`title${d}`),f+=m.move(" "+o),f+=m.move(s.safe(e.title,{before:f,after:o,...m.current()})),f+=m.move(o),h()),c(),f}function e4(e){const r=e.options.emphasis||"*";if(r!=="*"&&r!=="_")throw new Error("Cannot serialize emphasis with `"+r+"` for `options.emphasis`, expected `*`, or `_`");return r}function wo(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Sd(e,r,s){const l=Jl(e),o=Jl(r);return l===void 0?o===void 0?s==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:o===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:l===1?o===void 0?{inside:!1,outside:!1}:o===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:o===void 0?{inside:!1,outside:!1}:o===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}G1.peek=t4;function G1(e,r,s,l){const o=e4(s),d=s.enter("emphasis"),c=s.createTracker(l),h=c.move(o);let m=c.move(s.containerPhrasing(e,{after:o,before:h,...c.current()}));const f=m.charCodeAt(0),x=Sd(l.before.charCodeAt(l.before.length-1),f,o);x.inside&&(m=wo(f)+m.slice(1));const g=m.charCodeAt(m.length-1),p=Sd(l.after.charCodeAt(0),g,o);p.inside&&(m=m.slice(0,-1)+wo(g));const y=c.move(o);return d(),s.attentionEncodeSurroundingInfo={after:p.outside,before:x.outside},h+m+y}function t4(e,r,s){return s.options.emphasis||"*"}function n4(e,r){let s=!1;return tx(e,function(l){if("value"in l&&/\r?\n|\r/.test(l.value)||l.type==="break")return s=!0,hm}),!!((!e.depth||e.depth<3)&&Xm(e)&&(r.options.setext||s))}function r4(e,r,s,l){const o=Math.max(Math.min(6,e.depth||1),1),d=s.createTracker(l);if(n4(e,s)){const x=s.enter("headingSetext"),g=s.enter("phrasing"),p=s.containerPhrasing(e,{...d.current(),before:`
|
|
32
|
+
`,after:`
|
|
33
|
+
`});return g(),x(),p+`
|
|
34
|
+
`+(o===1?"=":"-").repeat(p.length-(Math.max(p.lastIndexOf("\r"),p.lastIndexOf(`
|
|
35
|
+
`))+1))}const c="#".repeat(o),h=s.enter("headingAtx"),m=s.enter("phrasing");d.move(c+" ");let f=s.containerPhrasing(e,{before:"# ",after:`
|
|
36
|
+
`,...d.current()});return/^[\t ]/.test(f)&&(f=wo(f.charCodeAt(0))+f.slice(1)),f=f?c+" "+f:c,s.options.closeAtx&&(f+=" "+c),m(),h(),f}X1.peek=s4;function X1(e){return e.value||""}function s4(){return"<"}Z1.peek=a4;function Z1(e,r,s,l){const o=rx(s),d=o==='"'?"Quote":"Apostrophe",c=s.enter("image");let h=s.enter("label");const m=s.createTracker(l);let f=m.move("![");return f+=m.move(s.safe(e.alt,{before:f,after:"]",...m.current()})),f+=m.move("]("),h(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(h=s.enter("destinationLiteral"),f+=m.move("<"),f+=m.move(s.safe(e.url,{before:f,after:">",...m.current()})),f+=m.move(">")):(h=s.enter("destinationRaw"),f+=m.move(s.safe(e.url,{before:f,after:e.title?" ":")",...m.current()}))),h(),e.title&&(h=s.enter(`title${d}`),f+=m.move(" "+o),f+=m.move(s.safe(e.title,{before:f,after:o,...m.current()})),f+=m.move(o),h()),f+=m.move(")"),c(),f}function a4(){return"!"}Q1.peek=l4;function Q1(e,r,s,l){const o=e.referenceType,d=s.enter("imageReference");let c=s.enter("label");const h=s.createTracker(l);let m=h.move("![");const f=s.safe(e.alt,{before:m,after:"]",...h.current()});m+=h.move(f+"]["),c();const x=s.stack;s.stack=[],c=s.enter("reference");const g=s.safe(s.associationId(e),{before:m,after:"]",...h.current()});return c(),s.stack=x,d(),o==="full"||!f||f!==g?m+=h.move(g+"]"):o==="shortcut"?m=m.slice(0,-1):m+=h.move("]"),m}function l4(){return"!"}K1.peek=i4;function K1(e,r,s){let l=e.value||"",o="`",d=-1;for(;new RegExp("(^|[^`])"+o+"([^`]|$)").test(l);)o+="`";for(/[^ \r\n]/.test(l)&&(/^[ \r\n]/.test(l)&&/[ \r\n]$/.test(l)||/^`|`$/.test(l))&&(l=" "+l+" ");++d<s.unsafe.length;){const c=s.unsafe[d],h=s.compilePattern(c);let m;if(c.atBreak)for(;m=h.exec(l);){let f=m.index;l.charCodeAt(f)===10&&l.charCodeAt(f-1)===13&&f--,l=l.slice(0,f)+" "+l.slice(m.index+1)}}return o+l+o}function i4(){return"`"}function J1(e,r){const s=Xm(e);return!!(!r.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(s===e.url||"mailto:"+s===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}W1.peek=o4;function W1(e,r,s,l){const o=rx(s),d=o==='"'?"Quote":"Apostrophe",c=s.createTracker(l);let h,m;if(J1(e,s)){const x=s.stack;s.stack=[],h=s.enter("autolink");let g=c.move("<");return g+=c.move(s.containerPhrasing(e,{before:g,after:">",...c.current()})),g+=c.move(">"),h(),s.stack=x,g}h=s.enter("link"),m=s.enter("label");let f=c.move("[");return f+=c.move(s.containerPhrasing(e,{before:f,after:"](",...c.current()})),f+=c.move("]("),m(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(m=s.enter("destinationLiteral"),f+=c.move("<"),f+=c.move(s.safe(e.url,{before:f,after:">",...c.current()})),f+=c.move(">")):(m=s.enter("destinationRaw"),f+=c.move(s.safe(e.url,{before:f,after:e.title?" ":")",...c.current()}))),m(),e.title&&(m=s.enter(`title${d}`),f+=c.move(" "+o),f+=c.move(s.safe(e.title,{before:f,after:o,...c.current()})),f+=c.move(o),m()),f+=c.move(")"),h(),f}function o4(e,r,s){return J1(e,s)?"<":"["}ej.peek=c4;function ej(e,r,s,l){const o=e.referenceType,d=s.enter("linkReference");let c=s.enter("label");const h=s.createTracker(l);let m=h.move("[");const f=s.containerPhrasing(e,{before:m,after:"]",...h.current()});m+=h.move(f+"]["),c();const x=s.stack;s.stack=[],c=s.enter("reference");const g=s.safe(s.associationId(e),{before:m,after:"]",...h.current()});return c(),s.stack=x,d(),o==="full"||!f||f!==g?m+=h.move(g+"]"):o==="shortcut"?m=m.slice(0,-1):m+=h.move("]"),m}function c4(){return"["}function sx(e){const r=e.options.bullet||"*";if(r!=="*"&&r!=="+"&&r!=="-")throw new Error("Cannot serialize items with `"+r+"` for `options.bullet`, expected `*`, `+`, or `-`");return r}function d4(e){const r=sx(e),s=e.options.bulletOther;if(!s)return r==="*"?"-":"*";if(s!=="*"&&s!=="+"&&s!=="-")throw new Error("Cannot serialize items with `"+s+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(s===r)throw new Error("Expected `bullet` (`"+r+"`) and `bulletOther` (`"+s+"`) to be different");return s}function u4(e){const r=e.options.bulletOrdered||".";if(r!=="."&&r!==")")throw new Error("Cannot serialize items with `"+r+"` for `options.bulletOrdered`, expected `.` or `)`");return r}function tj(e){const r=e.options.rule||"*";if(r!=="*"&&r!=="-"&&r!=="_")throw new Error("Cannot serialize rules with `"+r+"` for `options.rule`, expected `*`, `-`, or `_`");return r}function f4(e,r,s,l){const o=s.enter("list"),d=s.bulletCurrent;let c=e.ordered?u4(s):sx(s);const h=e.ordered?c==="."?")":".":d4(s);let m=r&&s.bulletLastUsed?c===s.bulletLastUsed:!1;if(!e.ordered){const x=e.children?e.children[0]:void 0;if((c==="*"||c==="-")&&x&&(!x.children||!x.children[0])&&s.stack[s.stack.length-1]==="list"&&s.stack[s.stack.length-2]==="listItem"&&s.stack[s.stack.length-3]==="list"&&s.stack[s.stack.length-4]==="listItem"&&s.indexStack[s.indexStack.length-1]===0&&s.indexStack[s.indexStack.length-2]===0&&s.indexStack[s.indexStack.length-3]===0&&(m=!0),tj(s)===c&&x){let g=-1;for(;++g<e.children.length;){const p=e.children[g];if(p&&p.type==="listItem"&&p.children&&p.children[0]&&p.children[0].type==="thematicBreak"){m=!0;break}}}}m&&(c=h),s.bulletCurrent=c;const f=s.containerFlow(e,l);return s.bulletLastUsed=c,s.bulletCurrent=d,o(),f}function h4(e){const r=e.options.listItemIndent||"one";if(r!=="tab"&&r!=="one"&&r!=="mixed")throw new Error("Cannot serialize items with `"+r+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return r}function m4(e,r,s,l){const o=h4(s);let d=s.bulletCurrent||sx(s);r&&r.type==="list"&&r.ordered&&(d=(typeof r.start=="number"&&r.start>-1?r.start:1)+(s.options.incrementListMarker===!1?0:r.children.indexOf(e))+d);let c=d.length+1;(o==="tab"||o==="mixed"&&(r&&r.type==="list"&&r.spread||e.spread))&&(c=Math.ceil(c/4)*4);const h=s.createTracker(l);h.move(d+" ".repeat(c-d.length)),h.shift(c);const m=s.enter("listItem"),f=s.indentLines(s.containerFlow(e,h.current()),x);return m(),f;function x(g,p,y){return p?(y?"":" ".repeat(c))+g:(y?d:d+" ".repeat(c-d.length))+g}}function x4(e,r,s,l){const o=s.enter("paragraph"),d=s.enter("phrasing"),c=s.containerPhrasing(e,l);return d(),o(),c}const g4=Xd(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function p4(e,r,s,l){return(e.children.some(function(c){return g4(c)})?s.containerPhrasing:s.containerFlow).call(s,e,l)}function b4(e){const r=e.options.strong||"*";if(r!=="*"&&r!=="_")throw new Error("Cannot serialize strong with `"+r+"` for `options.strong`, expected `*`, or `_`");return r}nj.peek=y4;function nj(e,r,s,l){const o=b4(s),d=s.enter("strong"),c=s.createTracker(l),h=c.move(o+o);let m=c.move(s.containerPhrasing(e,{after:o,before:h,...c.current()}));const f=m.charCodeAt(0),x=Sd(l.before.charCodeAt(l.before.length-1),f,o);x.inside&&(m=wo(f)+m.slice(1));const g=m.charCodeAt(m.length-1),p=Sd(l.after.charCodeAt(0),g,o);p.inside&&(m=m.slice(0,-1)+wo(g));const y=c.move(o+o);return d(),s.attentionEncodeSurroundingInfo={after:p.outside,before:x.outside},h+m+y}function y4(e,r,s){return s.options.strong||"*"}function v4(e,r,s,l){return s.safe(e.value,l)}function j4(e){const r=e.options.ruleRepetition||3;if(r<3)throw new Error("Cannot serialize rules with repetition `"+r+"` for `options.ruleRepetition`, expected `3` or more");return r}function w4(e,r,s){const l=(tj(s)+(s.options.ruleSpaces?" ":"")).repeat(j4(s));return s.options.ruleSpaces?l.slice(0,-1):l}const rj={blockquote:V3,break:ry,code:K3,definition:W3,emphasis:G1,hardBreak:ry,heading:r4,html:X1,image:Z1,imageReference:Q1,inlineCode:K1,link:W1,linkReference:ej,list:f4,listItem:m4,paragraph:x4,root:p4,strong:nj,text:v4,thematicBreak:w4};function N4(){return{enter:{table:k4,tableData:sy,tableHeader:sy,tableRow:C4},exit:{codeText:E4,table:S4,tableData:Rh,tableHeader:Rh,tableRow:Rh}}}function k4(e){const r=e._align;this.enter({type:"table",align:r.map(function(s){return s==="none"?null:s}),children:[]},e),this.data.inTable=!0}function S4(e){this.exit(e),this.data.inTable=void 0}function C4(e){this.enter({type:"tableRow",children:[]},e)}function Rh(e){this.exit(e)}function sy(e){this.enter({type:"tableCell",children:[]},e)}function E4(e){let r=this.resume();this.data.inTable&&(r=r.replace(/\\([\\|])/g,T4));const s=this.stack[this.stack.length-1];s.type,s.value=r,this.exit(e)}function T4(e,r){return r==="|"?r:e}function A4(e){const r=e||{},s=r.tableCellPadding,l=r.tablePipeAlign,o=r.stringLength,d=s?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
37
|
+
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:p,table:c,tableCell:m,tableRow:h}};function c(y,w,N,E){return f(x(y,N,E),y.align)}function h(y,w,N,E){const A=g(y,N,E),C=f([A]);return C.slice(0,C.indexOf(`
|
|
38
|
+
`))}function m(y,w,N,E){const A=N.enter("tableCell"),C=N.enter("phrasing"),k=N.containerPhrasing(y,{...E,before:d,after:d});return C(),A(),k}function f(y,w){return q3(y,{align:w,alignDelimiters:l,padding:s,stringLength:o})}function x(y,w,N){const E=y.children;let A=-1;const C=[],k=w.enter("table");for(;++A<E.length;)C[A]=g(E[A],w,N);return k(),C}function g(y,w,N){const E=y.children;let A=-1;const C=[],k=w.enter("tableRow");for(;++A<E.length;)C[A]=m(E[A],y,w,N);return k(),C}function p(y,w,N){let E=rj.inlineCode(y,w,N);return N.stack.includes("tableCell")&&(E=E.replace(/\|/g,"\\$&")),E}}function _4(){return{exit:{taskListCheckValueChecked:ay,taskListCheckValueUnchecked:ay,paragraph:D4}}}function M4(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:O4}}}function ay(e){const r=this.stack[this.stack.length-2];r.type,r.checked=e.type==="taskListCheckValueChecked"}function D4(e){const r=this.stack[this.stack.length-2];if(r&&r.type==="listItem"&&typeof r.checked=="boolean"){const s=this.stack[this.stack.length-1];s.type;const l=s.children[0];if(l&&l.type==="text"){const o=r.children;let d=-1,c;for(;++d<o.length;){const h=o[d];if(h.type==="paragraph"){c=h;break}}c===s&&(l.value=l.value.slice(1),l.value.length===0?s.children.shift():s.position&&l.position&&typeof l.position.start.offset=="number"&&(l.position.start.column++,l.position.start.offset++,s.position.start=Object.assign({},l.position.start)))}}this.exit(e)}function O4(e,r,s,l){const o=e.children[0],d=typeof e.checked=="boolean"&&o&&o.type==="paragraph",c="["+(e.checked?"x":" ")+"] ",h=s.createTracker(l);d&&h.move(c);let m=rj.listItem(e,r,s,{...l,...h.current()});return d&&(m=m.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,f)),m;function f(x){return x+c}}function R4(){return[f3(),O3(),I3(),N4(),_4()]}function L4(e){return{extensions:[h3(),R3(e),$3(),A4(e),M4()]}}const z4={tokenize:U4,partial:!0},sj={tokenize:q4,partial:!0},aj={tokenize:F4,partial:!0},lj={tokenize:V4,partial:!0},I4={tokenize:Y4,partial:!0},ij={name:"wwwAutolink",tokenize:H4,previous:cj},oj={name:"protocolAutolink",tokenize:P4,previous:dj},Qs={name:"emailAutolink",tokenize:B4,previous:uj},Ns={};function $4(){return{text:Ns}}let Za=48;for(;Za<123;)Ns[Za]=Qs,Za++,Za===58?Za=65:Za===91&&(Za=97);Ns[43]=Qs;Ns[45]=Qs;Ns[46]=Qs;Ns[95]=Qs;Ns[72]=[Qs,oj];Ns[104]=[Qs,oj];Ns[87]=[Qs,ij];Ns[119]=[Qs,ij];function B4(e,r,s){const l=this;let o,d;return c;function c(g){return!pm(g)||!uj.call(l,l.previous)||ax(l.events)?s(g):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),h(g))}function h(g){return pm(g)?(e.consume(g),h):g===64?(e.consume(g),m):s(g)}function m(g){return g===46?e.check(I4,x,f)(g):g===45||g===95||lr(g)?(d=!0,e.consume(g),m):x(g)}function f(g){return e.consume(g),o=!0,m}function x(g){return d&&o&&fr(l.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),r(g)):s(g)}}function H4(e,r,s){const l=this;return o;function o(c){return c!==87&&c!==119||!cj.call(l,l.previous)||ax(l.events)?s(c):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(z4,e.attempt(sj,e.attempt(aj,d),s),s)(c))}function d(c){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),r(c)}}function P4(e,r,s){const l=this;let o="",d=!1;return c;function c(g){return(g===72||g===104)&&dj.call(l,l.previous)&&!ax(l.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(g),e.consume(g),h):s(g)}function h(g){if(fr(g)&&o.length<5)return o+=String.fromCodePoint(g),e.consume(g),h;if(g===58){const p=o.toLowerCase();if(p==="http"||p==="https")return e.consume(g),m}return s(g)}function m(g){return g===47?(e.consume(g),d?f:(d=!0,m)):s(g)}function f(g){return g===null||wd(g)||pn(g)||rl(g)||Vd(g)?s(g):e.attempt(sj,e.attempt(aj,x),s)(g)}function x(g){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),r(g)}}function U4(e,r,s){let l=0;return o;function o(c){return(c===87||c===119)&&l<3?(l++,e.consume(c),o):c===46&&l===3?(e.consume(c),d):s(c)}function d(c){return c===null?s(c):r(c)}}function q4(e,r,s){let l,o,d;return c;function c(f){return f===46||f===95?e.check(lj,m,h)(f):f===null||pn(f)||rl(f)||f!==45&&Vd(f)?m(f):(d=!0,e.consume(f),c)}function h(f){return f===95?l=!0:(o=l,l=void 0),e.consume(f),c}function m(f){return o||l||!d?s(f):r(f)}}function F4(e,r){let s=0,l=0;return o;function o(c){return c===40?(s++,e.consume(c),o):c===41&&l<s?d(c):c===33||c===34||c===38||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===60||c===63||c===93||c===95||c===126?e.check(lj,r,d)(c):c===null||pn(c)||rl(c)?r(c):(e.consume(c),o)}function d(c){return c===41&&l++,e.consume(c),o}}function V4(e,r,s){return l;function l(h){return h===33||h===34||h===39||h===41||h===42||h===44||h===46||h===58||h===59||h===63||h===95||h===126?(e.consume(h),l):h===38?(e.consume(h),d):h===93?(e.consume(h),o):h===60||h===null||pn(h)||rl(h)?r(h):s(h)}function o(h){return h===null||h===40||h===91||pn(h)||rl(h)?r(h):l(h)}function d(h){return fr(h)?c(h):s(h)}function c(h){return h===59?(e.consume(h),l):fr(h)?(e.consume(h),c):s(h)}}function Y4(e,r,s){return l;function l(d){return e.consume(d),o}function o(d){return lr(d)?s(d):r(d)}}function cj(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||pn(e)}function dj(e){return!fr(e)}function uj(e){return!(e===47||pm(e))}function pm(e){return e===43||e===45||e===46||e===95||lr(e)}function ax(e){let r=e.length,s=!1;for(;r--;){const l=e[r][1];if((l.type==="labelLink"||l.type==="labelImage")&&!l._balanced){s=!0;break}if(l._gfmAutolinkLiteralWalkedInto){s=!1;break}}return e.length>0&&!s&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),s}const G4={tokenize:tT,partial:!0};function X4(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:J4,continuation:{tokenize:W4},exit:eT}},text:{91:{name:"gfmFootnoteCall",tokenize:K4},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Z4,resolveTo:Q4}}}}function Z4(e,r,s){const l=this;let o=l.events.length;const d=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let c;for(;o--;){const m=l.events[o][1];if(m.type==="labelImage"){c=m;break}if(m.type==="gfmFootnoteCall"||m.type==="labelLink"||m.type==="label"||m.type==="image"||m.type==="link")break}return h;function h(m){if(!c||!c._balanced)return s(m);const f=as(l.sliceSerialize({start:c.end,end:l.now()}));return f.codePointAt(0)!==94||!d.includes(f.slice(1))?s(m):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),r(m))}}function Q4(e,r){let s=e.length;for(;s--;)if(e[s][1].type==="labelImage"&&e[s][0]==="enter"){e[s][1];break}e[s+1][1].type="data",e[s+3][1].type="gfmFootnoteCallLabelMarker";const l={type:"gfmFootnoteCall",start:Object.assign({},e[s+3][1].start),end:Object.assign({},e[e.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},e[s+3][1].end),end:Object.assign({},e[s+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const d={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},e[e.length-1][1].start)},c={type:"chunkString",contentType:"string",start:Object.assign({},d.start),end:Object.assign({},d.end)},h=[e[s+1],e[s+2],["enter",l,r],e[s+3],e[s+4],["enter",o,r],["exit",o,r],["enter",d,r],["enter",c,r],["exit",c,r],["exit",d,r],e[e.length-2],e[e.length-1],["exit",l,r]];return e.splice(s,e.length-s+1,...h),e}function K4(e,r,s){const l=this,o=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let d=0,c;return h;function h(g){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),m}function m(g){return g!==94?s(g):(e.enter("gfmFootnoteCallMarker"),e.consume(g),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",f)}function f(g){if(d>999||g===93&&!c||g===null||g===91||pn(g))return s(g);if(g===93){e.exit("chunkString");const p=e.exit("gfmFootnoteCallString");return o.includes(as(l.sliceSerialize(p)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),r):s(g)}return pn(g)||(c=!0),d++,e.consume(g),g===92?x:f}function x(g){return g===91||g===92||g===93?(e.consume(g),d++,f):f(g)}}function J4(e,r,s){const l=this,o=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let d,c=0,h;return m;function m(w){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),f}function f(w){return w===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",x):s(w)}function x(w){if(c>999||w===93&&!h||w===null||w===91||pn(w))return s(w);if(w===93){e.exit("chunkString");const N=e.exit("gfmFootnoteDefinitionLabelString");return d=as(l.sliceSerialize(N)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),p}return pn(w)||(h=!0),c++,e.consume(w),w===92?g:x}function g(w){return w===91||w===92||w===93?(e.consume(w),c++,x):x(w)}function p(w){return w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),o.includes(d)||o.push(d),Ft(e,y,"gfmFootnoteDefinitionWhitespace")):s(w)}function y(w){return r(w)}}function W4(e,r,s){return e.check(zo,r,e.attempt(G4,r,s))}function eT(e){e.exit("gfmFootnoteDefinition")}function tT(e,r,s){const l=this;return Ft(e,o,"gfmFootnoteDefinitionIndent",5);function o(d){const c=l.events[l.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?r(d):s(d)}}function nT(e){let s=(e||{}).singleTilde;const l={name:"strikethrough",tokenize:d,resolveAll:o};return s==null&&(s=!0),{text:{126:l},insideSpan:{null:[l]},attentionMarkers:{null:[126]}};function o(c,h){let m=-1;for(;++m<c.length;)if(c[m][0]==="enter"&&c[m][1].type==="strikethroughSequenceTemporary"&&c[m][1]._close){let f=m;for(;f--;)if(c[f][0]==="exit"&&c[f][1].type==="strikethroughSequenceTemporary"&&c[f][1]._open&&c[m][1].end.offset-c[m][1].start.offset===c[f][1].end.offset-c[f][1].start.offset){c[m][1].type="strikethroughSequence",c[f][1].type="strikethroughSequence";const x={type:"strikethrough",start:Object.assign({},c[f][1].start),end:Object.assign({},c[m][1].end)},g={type:"strikethroughText",start:Object.assign({},c[f][1].end),end:Object.assign({},c[m][1].start)},p=[["enter",x,h],["enter",c[f][1],h],["exit",c[f][1],h],["enter",g,h]],y=h.parser.constructs.insideSpan.null;y&&$r(p,p.length,0,Yd(y,c.slice(f+1,m),h)),$r(p,p.length,0,[["exit",g,h],["enter",c[m][1],h],["exit",c[m][1],h],["exit",x,h]]),$r(c,f-1,m-f+3,p),m=f+p.length-2;break}}for(m=-1;++m<c.length;)c[m][1].type==="strikethroughSequenceTemporary"&&(c[m][1].type="data");return c}function d(c,h,m){const f=this.previous,x=this.events;let g=0;return p;function p(w){return f===126&&x[x.length-1][1].type!=="characterEscape"?m(w):(c.enter("strikethroughSequenceTemporary"),y(w))}function y(w){const N=Jl(f);if(w===126)return g>1?m(w):(c.consume(w),g++,y);if(g<2&&!s)return m(w);const E=c.exit("strikethroughSequenceTemporary"),A=Jl(w);return E._open=!A||A===2&&!!N,E._close=!N||N===2&&!!A,h(w)}}}class rT{constructor(){this.map=[]}add(r,s,l){sT(this,r,s,l)}consume(r){if(this.map.sort(function(d,c){return d[0]-c[0]}),this.map.length===0)return;let s=this.map.length;const l=[];for(;s>0;)s-=1,l.push(r.slice(this.map[s][0]+this.map[s][1]),this.map[s][2]),r.length=this.map[s][0];l.push(r.slice()),r.length=0;let o=l.pop();for(;o;){for(const d of o)r.push(d);o=l.pop()}this.map.length=0}}function sT(e,r,s,l){let o=0;if(!(s===0&&l.length===0)){for(;o<e.map.length;){if(e.map[o][0]===r){e.map[o][1]+=s,e.map[o][2].push(...l);return}o+=1}e.map.push([r,s,l])}}function aT(e,r){let s=!1;const l=[];for(;r<e.length;){const o=e[r];if(s){if(o[0]==="enter")o[1].type==="tableContent"&&l.push(e[r+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(e[r-1][1].type==="tableDelimiterMarker"){const d=l.length-1;l[d]=l[d]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(s=!0);r+=1}return l}function lT(){return{flow:{null:{name:"table",tokenize:iT,resolveAll:oT}}}}function iT(e,r,s){const l=this;let o=0,d=0,c;return h;function h($){let F=l.events.length-1;for(;F>-1;){const D=l.events[F][1].type;if(D==="lineEnding"||D==="linePrefix")F--;else break}const B=F>-1?l.events[F][1].type:null,T=B==="tableHead"||B==="tableRow"?R:m;return T===R&&l.parser.lazy[l.now().line]?s($):T($)}function m($){return e.enter("tableHead"),e.enter("tableRow"),f($)}function f($){return $===124||(c=!0,d+=1),x($)}function x($){return $===null?s($):mt($)?d>1?(d=0,l.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume($),e.exit("lineEnding"),y):s($):Bt($)?Ft(e,x,"whitespace")($):(d+=1,c&&(c=!1,o+=1),$===124?(e.enter("tableCellDivider"),e.consume($),e.exit("tableCellDivider"),c=!0,x):(e.enter("data"),g($)))}function g($){return $===null||$===124||pn($)?(e.exit("data"),x($)):(e.consume($),$===92?p:g)}function p($){return $===92||$===124?(e.consume($),g):g($)}function y($){return l.interrupt=!1,l.parser.lazy[l.now().line]?s($):(e.enter("tableDelimiterRow"),c=!1,Bt($)?Ft(e,w,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)($):w($))}function w($){return $===45||$===58?E($):$===124?(c=!0,e.enter("tableCellDivider"),e.consume($),e.exit("tableCellDivider"),N):O($)}function N($){return Bt($)?Ft(e,E,"whitespace")($):E($)}function E($){return $===58?(d+=1,c=!0,e.enter("tableDelimiterMarker"),e.consume($),e.exit("tableDelimiterMarker"),A):$===45?(d+=1,A($)):$===null||mt($)?S($):O($)}function A($){return $===45?(e.enter("tableDelimiterFiller"),C($)):O($)}function C($){return $===45?(e.consume($),C):$===58?(c=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume($),e.exit("tableDelimiterMarker"),k):(e.exit("tableDelimiterFiller"),k($))}function k($){return Bt($)?Ft(e,S,"whitespace")($):S($)}function S($){return $===124?w($):$===null||mt($)?!c||o!==d?O($):(e.exit("tableDelimiterRow"),e.exit("tableHead"),r($)):O($)}function O($){return s($)}function R($){return e.enter("tableRow"),G($)}function G($){return $===124?(e.enter("tableCellDivider"),e.consume($),e.exit("tableCellDivider"),G):$===null||mt($)?(e.exit("tableRow"),r($)):Bt($)?Ft(e,G,"whitespace")($):(e.enter("data"),I($))}function I($){return $===null||$===124||pn($)?(e.exit("data"),G($)):(e.consume($),$===92?Q:I)}function Q($){return $===92||$===124?(e.consume($),I):I($)}}function oT(e,r){let s=-1,l=!0,o=0,d=[0,0,0,0],c=[0,0,0,0],h=!1,m=0,f,x,g;const p=new rT;for(;++s<e.length;){const y=e[s],w=y[1];y[0]==="enter"?w.type==="tableHead"?(h=!1,m!==0&&(ly(p,r,m,f,x),x=void 0,m=0),f={type:"table",start:Object.assign({},w.start),end:Object.assign({},w.end)},p.add(s,0,[["enter",f,r]])):w.type==="tableRow"||w.type==="tableDelimiterRow"?(l=!0,g=void 0,d=[0,0,0,0],c=[0,s+1,0,0],h&&(h=!1,x={type:"tableBody",start:Object.assign({},w.start),end:Object.assign({},w.end)},p.add(s,0,[["enter",x,r]])),o=w.type==="tableDelimiterRow"?2:x?3:1):o&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")?(l=!1,c[2]===0&&(d[1]!==0&&(c[0]=c[1],g=nd(p,r,d,o,void 0,g),d=[0,0,0,0]),c[2]=s)):w.type==="tableCellDivider"&&(l?l=!1:(d[1]!==0&&(c[0]=c[1],g=nd(p,r,d,o,void 0,g)),d=c,c=[d[1],s,0,0])):w.type==="tableHead"?(h=!0,m=s):w.type==="tableRow"||w.type==="tableDelimiterRow"?(m=s,d[1]!==0?(c[0]=c[1],g=nd(p,r,d,o,s,g)):c[1]!==0&&(g=nd(p,r,c,o,s,g)),o=0):o&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")&&(c[3]=s)}for(m!==0&&ly(p,r,m,f,x),p.consume(r.events),s=-1;++s<r.events.length;){const y=r.events[s];y[0]==="enter"&&y[1].type==="table"&&(y[1]._align=aT(r.events,s))}return e}function nd(e,r,s,l,o,d){const c=l===1?"tableHeader":l===2?"tableDelimiter":"tableData",h="tableContent";s[0]!==0&&(d.end=Object.assign({},Fl(r.events,s[0])),e.add(s[0],0,[["exit",d,r]]));const m=Fl(r.events,s[1]);if(d={type:c,start:Object.assign({},m),end:Object.assign({},m)},e.add(s[1],0,[["enter",d,r]]),s[2]!==0){const f=Fl(r.events,s[2]),x=Fl(r.events,s[3]),g={type:h,start:Object.assign({},f),end:Object.assign({},x)};if(e.add(s[2],0,[["enter",g,r]]),l!==2){const p=r.events[s[2]],y=r.events[s[3]];if(p[1].end=Object.assign({},y[1].end),p[1].type="chunkText",p[1].contentType="text",s[3]>s[2]+1){const w=s[2]+1,N=s[3]-s[2]-1;e.add(w,N,[])}}e.add(s[3]+1,0,[["exit",g,r]])}return o!==void 0&&(d.end=Object.assign({},Fl(r.events,o)),e.add(o,0,[["exit",d,r]]),d=void 0),d}function ly(e,r,s,l,o){const d=[],c=Fl(r.events,s);o&&(o.end=Object.assign({},c),d.push(["exit",o,r])),l.end=Object.assign({},c),d.push(["exit",l,r]),e.add(s+1,0,d)}function Fl(e,r){const s=e[r],l=s[0]==="enter"?"start":"end";return s[1][l]}const cT={name:"tasklistCheck",tokenize:uT};function dT(){return{text:{91:cT}}}function uT(e,r,s){const l=this;return o;function o(m){return l.previous!==null||!l._gfmTasklistFirstContentOfListItem?s(m):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(m),e.exit("taskListCheckMarker"),d)}function d(m){return pn(m)?(e.enter("taskListCheckValueUnchecked"),e.consume(m),e.exit("taskListCheckValueUnchecked"),c):m===88||m===120?(e.enter("taskListCheckValueChecked"),e.consume(m),e.exit("taskListCheckValueChecked"),c):s(m)}function c(m){return m===93?(e.enter("taskListCheckMarker"),e.consume(m),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),h):s(m)}function h(m){return mt(m)?r(m):Bt(m)?e.check({tokenize:fT},r,s)(m):s(m)}}function fT(e,r,s){return Ft(e,l,"whitespace");function l(o){return o===null?s(o):r(o)}}function hT(e){return w1([$4(),X4(),nT(e),lT(),dT()])}const mT={};function iy(e){const r=this,s=e||mT,l=r.data(),o=l.micromarkExtensions||(l.micromarkExtensions=[]),d=l.fromMarkdownExtensions||(l.fromMarkdownExtensions=[]),c=l.toMarkdownExtensions||(l.toMarkdownExtensions=[]);o.push(hT(s)),d.push(R4()),c.push(L4(s))}const xT=/<think>([\s\S]*?)<\/think>/g;function gT(e){const r=[],s=e.replace(xT,(l,o)=>{const d=o.trim();return d&&r.push(d),""});return{thinking:r,rest:s.trim()}}const bm="#mention:";function pT(e){return e.replace(/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu,(r,s,l)=>{const o=s??l;return`[@${o}](${bm}${encodeURIComponent(o)})`})}const Lh={p:({children:e})=>t.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed",children:e}),h1:({children:e})=>t.jsx("h1",{className:"text-base font-bold mb-2 mt-3 first:mt-0",children:e}),h2:({children:e})=>t.jsx("h2",{className:"text-sm font-bold mb-2 mt-3 first:mt-0",children:e}),h3:({children:e})=>t.jsx("h3",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0",children:e}),ul:({children:e})=>t.jsx("ul",{className:"list-disc pl-4 mb-2 space-y-0.5",children:e}),ol:({children:e})=>t.jsx("ol",{className:"list-decimal pl-4 mb-2 space-y-0.5",children:e}),li:({children:e})=>t.jsx("li",{className:"leading-relaxed",children:e}),code:({children:e,className:r})=>r?.includes("language-")?t.jsx("code",{className:"text-fg-secondary font-mono",children:e}):t.jsx("code",{className:"bg-surface-secondary px-1.5 py-0.5 rounded text-xs font-mono text-brand-500 break-all",children:e}),pre:({children:e})=>t.jsx("pre",{className:"bg-surface-secondary rounded-lg p-3 overflow-x-auto my-2 text-xs [&>code]:bg-transparent [&>code]:p-0 [&>code]:rounded-none [&>code]:text-fg-secondary",children:e}),strong:({children:e})=>t.jsx("strong",{className:"font-semibold text-fg-primary",children:e}),em:({children:e})=>t.jsx("em",{className:"italic text-fg-secondary",children:e}),blockquote:({children:e})=>t.jsx("blockquote",{className:"border-l-2 border-brand-500 pl-3 my-2 text-fg-secondary italic",children:e}),a:({href:e,children:r})=>t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500 underline break-all",children:r}),hr:()=>t.jsx("hr",{className:"border-border-default my-3"}),table:({children:e})=>t.jsx("div",{className:"overflow-x-auto my-2",children:t.jsx("table",{className:"min-w-full text-xs border-collapse border border-border-default",children:e})}),thead:({children:e})=>t.jsx("thead",{className:"bg-surface-elevated",children:e}),tbody:({children:e})=>t.jsx("tbody",{className:"divide-y divide-gray-700/50",children:e}),tr:({children:e})=>t.jsx("tr",{className:"hover:bg-surface-elevated/50 transition-colors",children:e}),th:({children:e})=>t.jsx("th",{className:"px-3 py-1.5 text-left text-xs font-semibold text-fg-secondary border border-border-default",children:e}),td:({children:e})=>t.jsx("td",{className:"px-3 py-1.5 text-xs text-fg-secondary border border-border-default",children:e})};function Zn({content:e,className:r="",onMentionClick:s}){const{thinking:l,rest:o}=gT(e),d=v.useMemo(()=>s?pT(o):o,[o,s]),c=v.useMemo(()=>s?{...Lh,a:({href:h,children:m})=>{if(h?.startsWith(bm)){const f=decodeURIComponent(h.slice(bm.length));return t.jsx("span",{className:"text-brand-500 font-medium cursor-pointer hover:underline",onClick:x=>{x.preventDefault(),x.stopPropagation(),s(f,x)},title:f,children:m})}return t.jsx("a",{href:h,target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500 underline break-all",children:m})}}:Lh,[s]);return t.jsxs("div",{className:`prose prose-sm max-w-none break-words ${r}`,children:[l.length>0&&(()=>{const h=l.join(`
|
|
39
|
+
|
|
40
|
+
`),m=h.split(`
|
|
41
|
+
`)[0]??"",f=m.length>80?m.slice(0,80)+"…":m;return t.jsxs("details",{className:"mb-3 rounded-lg bg-surface-elevated/60 border border-border-default/50 overflow-hidden group/think",children:[t.jsxs("summary",{className:"cursor-pointer select-none px-3 py-2 text-xs text-fg-secondary hover:text-fg-secondary transition-colors flex items-center gap-1.5 min-w-0",children:[t.jsx("svg",{className:"w-3 h-3 shrink-0 transition-transform group-open/think:rotate-90",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z",clipRule:"evenodd"})}),t.jsx("span",{className:"shrink-0",children:"思考过程"}),t.jsx("span",{className:"truncate text-fg-tertiary ml-1 group-open/think:hidden",children:f})]}),t.jsx("div",{className:"px-3 pb-3 border-t border-border-default/50",children:t.jsx("div",{className:"mt-2 pl-3 border-l-2 border-brand-500/40 text-xs text-fg-secondary leading-relaxed",children:t.jsx(Wb,{remarkPlugins:[iy],components:Lh,children:h})})})]})})(),t.jsx(Wb,{remarkPlugins:[iy],components:c,children:d})]})}const oy={shell_execute:{label:"Running command",icon:"⌨"},file_read:{label:"Reading file",icon:"📄"},file_write:{label:"Writing file",icon:"✏"},file_edit:{label:"Editing file",icon:"✏"},file_list:{label:"Listing files",icon:"📂"},web_fetch:{label:"Fetching page",icon:"🌐"},web_search:{label:"Searching web",icon:"🔍"},web_extract:{label:"Extracting content",icon:"📑"},create_task:{label:"Creating task",icon:"📌"},task_create:{label:"Creating task",icon:"📌"},create_subtask:{label:"Adding subtask",icon:"📌"},update_task:{label:"Updating task",icon:"✅"},task_update:{label:"Updating task",icon:"✅"},add_task_note:{label:"Adding note",icon:"📝"},task_add_note:{label:"Adding note",icon:"📝"},task_list:{label:"Listing tasks",icon:"📋"},requirement_propose:{label:"Proposing requirement",icon:"📋"},requirement_list:{label:"Listing requirements",icon:"📋"},git_status:{label:"Git status",icon:"🔀"},git_diff:{label:"Git diff",icon:"🔀"},git_log:{label:"Git log",icon:"📜"},git_branch:{label:"Git branch",icon:"🌿"},git_add:{label:"Git add",icon:"➕"},git_commit:{label:"Git commit",icon:"💾"},code_search:{label:"Searching code",icon:"🔍"},project_structure:{label:"Project structure",icon:"🗂"},code_stats:{label:"Code stats",icon:"📊"},navigate_page:{label:"Opening page",icon:"🌐"},new_page:{label:"Opening new tab",icon:"🌐"},close_page:{label:"Closing tab",icon:"🌐"},select_page:{label:"Switching tab",icon:"🌐"},list_pages:{label:"Listing tabs",icon:"🌐"},click:{label:"Clicking element",icon:"👆"},hover:{label:"Hovering element",icon:"👆"},fill:{label:"Filling field",icon:"⌨"},fill_form:{label:"Filling form",icon:"⌨"},type_text:{label:"Typing text",icon:"⌨"},press_key:{label:"Pressing key",icon:"⌨"},take_screenshot:{label:"Screenshot",icon:"📸"},take_snapshot:{label:"Page snapshot",icon:"📋"},evaluate_script:{label:"Running script",icon:"⚙"},wait_for:{label:"Waiting",icon:"⏳"},list_console_messages:{label:"Console logs",icon:"🔍"},list_network_requests:{label:"Network requests",icon:"🔍"},lighthouse_audit:{label:"Running audit",icon:"📊"},agent_send_message:{label:"Messaging colleague",icon:"💬"},agent_list:{label:"Checking team",icon:"👥"},memory_save:{label:"Saving memory",icon:"💾"},memory_search:{label:"Searching memory",icon:"🔍"},feishu_send_message:{label:"Sending Feishu msg",icon:"✉"},feishu_search_docs:{label:"Searching Feishu",icon:"🔍"},spawn_subagent:{label:"Spawn Subagent",icon:"◎"},spawn_subagents:{label:"Spawn Subagents",icon:"◎"}};function sl(e){const r=e.includes("__")?e.split("__").pop():e;return oy[r]??oy[e]??{label:r.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase()),icon:"⚙"}}function lx(e){return e==null?"":e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function bT(e){const r=new Date(e);if(isNaN(r.getTime()))return e;const s=String(r.getMonth()+1).padStart(2,"0"),l=String(r.getDate()).padStart(2,"0"),o=String(r.getHours()).padStart(2,"0"),d=String(r.getMinutes()).padStart(2,"0"),c=String(r.getSeconds()).padStart(2,"0");return`${s}-${l} ${o}:${d}:${c}`}function ym(e,r){return e.length<=r?e:e.slice(0,r)+"…"}function cy(e){try{const r=JSON.parse(e);return JSON.stringify(r,null,2)}catch{return e}}function yT(e){return!e||typeof e!="object"?[]:Object.entries(e).filter(([,s])=>s!=null).map(([s,l])=>({key:s,value:typeof l=="string"?l:JSON.stringify(l,null,2)}))}function vT(e){if(e.tool!=="shell_execute"||!e.args||typeof e.args!="object")return null;const r=e.args.command;return typeof r=="string"?r:null}function Cd(e){const r=new Set;for(let s=0;s<e.length;s++){const l=e[s];if(l.type==="tool"&&(l.info.status==="done"||l.info.status==="error"))for(let o=s-1;o>=0;o--){const d=e[o];if(d.type==="tool"&&d.info.status==="running"&&d.info.tool===l.info.tool&&!r.has(o)){r.add(o);break}}}return e.filter((s,l)=>!r.has(l))}function Ed(e){const r=bT(e.createdAt),s=e.createdAt,l=e.metadata;switch(e.type){case"text":return l?.isThinking?{type:"thinking",content:e.content,time:r,timestamp:s}:{type:"text",content:e.content,time:r,timestamp:s};case"status":{const o=l?.action;return o&&["chat","chat_stream","task_execution","respond_in_session"].includes(o)?null:{type:"status",content:e.content,time:r,timestamp:s}}case"error":return{type:"error",content:e.content,time:r,timestamp:s};case"tool_start":return{type:"tool",time:r,timestamp:s,key:`es_${e.seq}`,info:{tool:e.content,status:"running",args:l?.arguments}};case"tool_end":return{type:"tool",time:r,timestamp:s,key:`ee_${e.seq}`,info:{tool:e.content,status:l?.success===!1?"error":"done",args:l?.arguments,result:l?.result,error:l?.error,durationMs:l?.durationMs}};default:return null}}function fj(e,r){if(e!=="task_create"&&e!=="create_task"||!r)return null;try{const s=JSON.parse(r);if(!s.task)return null;const l=s.task;return{taskId:l.id,title:l.title,description:l.description,assignedAgentId:l.assignedAgentId,priority:l.priority}}catch{return null}}function hj(e,r){if(e!=="requirement_propose"||!r)return null;try{const s=JSON.parse(r);if(s.status!=="success"||!s.requirement)return null;const l=s.requirement;return l.status!=="pending"?null:{requirementId:l.id,title:l.title,description:l.description,priority:l.priority}}catch{return null}}function jT(e){const r=[];for(const s of e)if(s.phase!=="output"){if(s.phase==="start"){const l=`${s.tool}_${s.ts}`;r.push({key:l,tool:s.tool,status:"running"})}else for(let l=r.length-1;l>=0;l--)if(r[l].tool===s.tool&&r[l].status==="running"){r[l]={...r[l],status:s.success===!1?"error":"done"};break}}return r}function mj(){return t.jsxs("svg",{className:"w-3 h-3 animate-spin text-brand-500 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}function wT(){return t.jsx("span",{className:"flex items-center gap-0.5",children:[0,150,300].map(e=>t.jsx("span",{className:"w-1 h-1 rounded-full bg-brand-400 animate-bounce",style:{animationDelay:`${e}ms`,animationDuration:"1s"}},e))})}function dy({item:e,idx:r,total:s}){const l=sl(e.tool);return t.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[t.jsxs("div",{className:"flex flex-col items-center self-stretch w-3 shrink-0",children:[r>0&&t.jsx("div",{className:"w-px h-2 bg-surface-overlay"}),t.jsx("div",{className:`w-2.5 h-2.5 rounded-full border flex items-center justify-center text-[8px] shrink-0 ${e.status==="running"?"border-brand-500 bg-brand-500/15":e.status==="error"?"border-red-500 bg-red-500/15 text-red-500":"border-gray-600 bg-surface-elevated text-fg-tertiary"}`,children:e.status==="done"?"✓":e.status==="error"?"✗":""}),r<s-1&&t.jsx("div",{className:"w-px flex-1 bg-surface-overlay mt-0.5"})]}),t.jsxs("div",{className:`flex items-center gap-1.5 text-xs ${e.status==="running"?"text-brand-500":e.status==="error"?"text-red-500 opacity-60":"text-fg-tertiary"}`,children:[t.jsx("span",{className:"opacity-70",children:l.icon}),t.jsxs("span",{children:[l.label,e.status==="running"?"…":""]}),e.status==="running"&&t.jsx(mj,{})]})]})}function NT({activities:e,isActive:r,persistent:s}){const l=jT(e),[o,d]=v.useState(!1),[c,h]=v.useState(!1),m=v.useRef(null);if(v.useEffect(()=>(s||r||e.length>0?(d(!0),m.current&&clearTimeout(m.current)):m.current=setTimeout(()=>d(!1),800),()=>{m.current&&clearTimeout(m.current)}),[s,r,e.length]),!o)return null;const f=l.length>0,x=f&&l.every(y=>y.status!=="running"),g=r&&!f,p=r&&f&&x;if(s&&x){const y=l.filter(N=>N.status==="error").length,w=l.filter(N=>N.status==="done").length;return t.jsxs("div",{className:"mb-3 border-b border-border-default/50 pb-2",children:[t.jsxs("button",{onClick:()=>h(N=>!N),className:"flex items-center gap-1.5 text-xs text-fg-tertiary hover:text-fg-secondary transition-colors select-none",children:[t.jsx("span",{className:`transition-transform duration-150 ${c?"rotate-90":""}`,children:"▶"}),t.jsxs("span",{className:"font-medium",children:[w," step",w!==1?"s":""]}),y>0&&t.jsxs("span",{className:"text-red-500 ml-0.5",children:["· ",y," failed"]}),!c&&t.jsxs("span",{className:"ml-1 flex gap-0.5",children:[l.slice(0,5).map(N=>t.jsx("span",{className:"text-[10px] opacity-60",title:sl(N.tool).label,children:sl(N.tool).icon},N.key)),l.length>5&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["+",l.length-5]})]})]}),c&&t.jsx("div",{className:"mt-2 space-y-0.5",children:l.map((N,E)=>t.jsx(dy,{item:N,idx:E,total:l.length},N.key))})]})}return t.jsxs("div",{className:"mb-2 space-y-0.5",children:[l.map((y,w)=>t.jsx(dy,{item:y,idx:w,total:l.length},y.key)),g&&t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-fg-secondary py-0.5",children:[t.jsx("span",{className:"mr-0.5",children:"Thinking"}),t.jsx(wT,{})]}),p&&t.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",children:[t.jsxs("div",{className:"flex flex-col items-center self-stretch w-3 shrink-0",children:[t.jsx("div",{className:"w-px h-2 bg-surface-overlay"}),t.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-brand-500 bg-brand-500/15 shrink-0"})]}),t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-brand-500",children:[t.jsx(mj,{}),t.jsx("span",{children:"Writing response…"})]})]})]})}function vm({label:e="Thinking"}){return t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-fg-secondary py-0.5",children:[t.jsx("span",{children:e}),t.jsx("span",{className:"flex gap-0.5",children:[0,150,300].map(r=>t.jsx("span",{className:"w-1 h-1 rounded-full bg-brand-400 animate-bounce",style:{animationDelay:`${r}ms`,animationDuration:"1s"}},r))})]})}function jm({content:e,className:r}){return t.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg px-3 py-2.5 my-1 min-w-0 overflow-hidden",children:[t.jsx(Zn,{content:e,className:r??"text-sm text-fg-secondary break-words"}),t.jsx("span",{className:"inline-block w-0.5 h-4 bg-brand-400 animate-pulse ml-0.5 align-middle"})]})}function kT({info:e,onClose:r}){const s=sl(e.tool),l=yT(e.args),o=e.status!=="error";return v.useEffect(()=>{const d=c=>{c.key==="Escape"&&r()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[r]),t.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",onClick:r,children:[t.jsx("div",{className:"absolute inset-0 bg-black/60"}),t.jsxs("div",{className:"relative bg-surface-secondary border border-border-default rounded-xl shadow-2xl w-[560px] max-w-[92vw] max-h-[80vh] overflow-hidden flex flex-col",onClick:d=>d.stopPropagation(),children:[t.jsxs("div",{className:"px-5 py-3 border-b border-border-default flex items-center justify-between shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"opacity-60 text-sm",children:s.icon}),t.jsx("span",{className:`text-sm font-semibold ${o?"text-fg-primary":"text-red-500"}`,children:s.label}),t.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${o?"bg-green-500/15 text-green-600":"bg-red-500/15 text-red-500"}`,children:o?"Success":"Failed"})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[e.durationMs!=null&&t.jsx("span",{className:"text-xs text-fg-tertiary",children:lx(e.durationMs)}),t.jsx("button",{onClick:r,className:"text-fg-tertiary hover:text-fg-secondary text-lg leading-none",children:"×"})]})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-4",children:[l.length>0&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2",children:"Arguments"}),t.jsx("div",{className:"space-y-2",children:l.map(({key:d,value:c})=>t.jsxs("div",{children:[t.jsx("div",{className:"text-[11px] text-brand-500 font-medium mb-0.5",children:d}),t.jsx("pre",{className:"text-xs text-fg-secondary bg-surface-elevated/70 rounded-lg px-3 py-2 overflow-x-auto max-h-80 overflow-y-auto whitespace-pre-wrap break-all font-mono",children:c})]},d))})]}),e.result&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2",children:"Result"}),t.jsx("pre",{className:"text-xs text-fg-secondary bg-surface-elevated/70 rounded-lg px-3 py-2 overflow-x-auto overflow-y-auto max-h-[60vh] whitespace-pre-wrap break-all font-mono",children:cy(e.result)})]}),e.error&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-[10px] font-semibold text-red-500 uppercase tracking-wider mb-2",children:"Error"}),t.jsx("pre",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/20 rounded-lg px-3 py-2 overflow-x-auto max-h-40 whitespace-pre-wrap break-all font-mono",children:cy(String(e.error))})]}),!l.length&&!e.result&&!e.error&&t.jsx("div",{className:"text-sm text-fg-tertiary italic py-4 text-center",children:"No detailed data recorded for this tool call."})]})]})]})}const xj={urgent:"text-red-500",high:"text-amber-500",medium:"text-blue-500",low:"text-fg-tertiary"},uy={pending:"pending",in_progress:"in_progress",completed:"completed",review:"review",blocked:"blocked",failed:"failed",cancelled:"cancelled",archived:"archived"},fy={pending:{icon:"⏳",label:"Pending Approval",borderClass:"border-amber-500/40",bgClass:"bg-amber-500/5",badgeClass:"bg-amber-500/15 text-amber-600",textClass:""},approving:{icon:"⏳",label:"Approving…",borderClass:"border-amber-500/40",bgClass:"bg-amber-500/5",badgeClass:"bg-amber-500/15 text-amber-600",textClass:""},rejecting:{icon:"⏳",label:"Rejecting…",borderClass:"border-amber-500/40",bgClass:"bg-amber-500/5",badgeClass:"bg-amber-500/15 text-amber-600",textClass:""},in_progress:{icon:"▶",label:"In Progress",borderClass:"border-blue-500/40",bgClass:"bg-blue-500/5",badgeClass:"bg-blue-500/15 text-blue-500",textClass:"text-blue-500"},completed:{icon:"✅",label:"Completed",borderClass:"border-green-500/30",bgClass:"bg-green-500/5",badgeClass:"bg-green-500/15 text-green-500",textClass:"text-green-500"},review:{icon:"👀",label:"In Review",borderClass:"border-purple-500/40",bgClass:"bg-purple-500/5",badgeClass:"bg-purple-500/15 text-purple-500",textClass:"text-purple-500"},blocked:{icon:"🚫",label:"Blocked",borderClass:"border-orange-500/40",bgClass:"bg-orange-500/5",badgeClass:"bg-orange-500/15 text-orange-500",textClass:"text-orange-500"},failed:{icon:"❌",label:"Failed",borderClass:"border-red-500/30",bgClass:"bg-red-500/5",badgeClass:"bg-red-500/15 text-red-500",textClass:"text-red-500"},cancelled:{icon:"⊘",label:"Cancelled",borderClass:"border-border-default/40",bgClass:"bg-surface-secondary/30",badgeClass:"bg-surface-elevated text-fg-tertiary",textClass:"text-fg-tertiary"},archived:{icon:"📦",label:"Archived",borderClass:"border-border-default/40",bgClass:"bg-surface-secondary/30",badgeClass:"bg-surface-elevated text-fg-tertiary",textClass:"text-fg-tertiary"},loading:{icon:"⏳",label:"Loading…",borderClass:"border-border-default/40",bgClass:"bg-surface-secondary/30",badgeClass:"bg-surface-elevated text-fg-tertiary",textClass:""}};function gj({info:e}){const[r,s]=v.useState("loading");v.useEffect(()=>{let m=!1;return re.tasks.get(e.taskId).then(({task:f})=>{m||s(uy[f.status]??"pending")}).catch(()=>{m||s("pending")}),()=>{m=!0}},[e.taskId]),v.useEffect(()=>kn.on("task:update",m=>{const f=m.payload;f.taskId===e.taskId&&f.status&&s(uy[f.status]??"pending")}),[e.taskId]);const l=async()=>{s("approving");try{await re.tasks.approve(e.taskId),s("in_progress")}catch{s("pending")}},o=async()=>{s("rejecting");try{await re.tasks.reject(e.taskId),s("cancelled")}catch{s("pending")}},d=r==="pending"||r==="approving"||r==="rejecting",c=fy[r]??fy.loading,h=()=>jt.navigate("tasks",{openTask:e.taskId});return t.jsxs("div",{className:`my-2 rounded-lg border ${c.borderClass} ${c.bgClass} p-3 max-w-md transition-colors`,children:[t.jsxs("div",{className:"flex items-start gap-2 mb-1 cursor-pointer group",role:"button",tabIndex:0,onClick:h,onKeyDown:m=>m.key==="Enter"&&h(),children:[t.jsx("span",{className:"text-sm mt-0.5",children:c.icon}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${c.badgeClass}`,children:"Task"}),!d&&r!=="loading"&&t.jsx("span",{className:`text-[10px] font-medium ${c.textClass}`,children:c.label})]}),t.jsx("div",{className:`text-sm font-medium truncate mt-1 group-hover:underline ${!d&&r!=="loading"?"text-fg-secondary":"text-fg-primary"}`,children:e.title}),e.description&&t.jsx("div",{className:"text-xs text-fg-secondary mt-0.5 line-clamp-2",children:e.description}),t.jsxs("div",{className:"flex items-center gap-2 mt-1.5 text-[11px] text-fg-tertiary",children:[e.priority&&t.jsx("span",{className:xj[e.priority]??"text-fg-tertiary",children:e.priority}),t.jsxs("span",{className:"opacity-50",children:["ID: ",e.taskId.slice(0,8),"..."]})]})]})]}),d&&t.jsxs("div",{className:"flex items-center gap-2 mt-2 pt-2 border-t border-border-default/30",children:[t.jsx("button",{onClick:l,disabled:r!=="pending",className:"flex-1 px-3 py-1.5 text-xs font-medium rounded-md bg-green-600 hover:bg-green-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:r==="approving"?"Approving…":"Approve"}),t.jsx("button",{onClick:o,disabled:r!=="pending",className:"flex-1 px-3 py-1.5 text-xs font-medium rounded-md bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:r==="rejecting"?"Rejecting…":"Reject"})]})]})}const hy={pending:"pending",in_progress:"in_progress",completed:"completed",rejected:"rejected",cancelled:"cancelled",archived:"archived"},my={pending:{icon:"📋",label:"Pending Approval",borderClass:"border-amber-500/40",bgClass:"bg-amber-500/5",badgeClass:"bg-amber-500/15 text-amber-600",textClass:""},approving:{icon:"⏳",label:"Approving…",borderClass:"border-amber-500/40",bgClass:"bg-amber-500/5",badgeClass:"bg-amber-500/15 text-amber-600",textClass:""},rejecting:{icon:"⏳",label:"Rejecting…",borderClass:"border-amber-500/40",bgClass:"bg-amber-500/5",badgeClass:"bg-amber-500/15 text-amber-600",textClass:""},in_progress:{icon:"▶",label:"In Progress",borderClass:"border-blue-500/40",bgClass:"bg-blue-500/5",badgeClass:"bg-blue-500/15 text-blue-500",textClass:"text-blue-500"},completed:{icon:"✅",label:"Completed",borderClass:"border-green-500/30",bgClass:"bg-green-500/5",badgeClass:"bg-green-500/15 text-green-500",textClass:"text-green-500"},rejected:{icon:"❌",label:"Rejected",borderClass:"border-red-500/30",bgClass:"bg-red-500/5",badgeClass:"bg-red-500/15 text-red-500",textClass:"text-red-500"},cancelled:{icon:"⊘",label:"Cancelled",borderClass:"border-border-default/40",bgClass:"bg-surface-secondary/30",badgeClass:"bg-surface-elevated text-fg-tertiary",textClass:"text-fg-tertiary"},archived:{icon:"📦",label:"Archived",borderClass:"border-border-default/40",bgClass:"bg-surface-secondary/30",badgeClass:"bg-surface-elevated text-fg-tertiary",textClass:"text-fg-tertiary"},loading:{icon:"⏳",label:"Loading…",borderClass:"border-border-default/40",bgClass:"bg-surface-secondary/30",badgeClass:"bg-surface-elevated text-fg-tertiary",textClass:""}},ST=["requirement:approved","requirement:rejected","requirement:updated","requirement:completed","requirement:cancelled","requirement:resubmitted"];function pj({info:e}){const[r,s]=v.useState("loading"),[l,o]=v.useState(""),[d,c]=v.useState(!1);v.useEffect(()=>{let g=!1;return re.requirements.get(e.requirementId).then(({requirement:p})=>{g||s(hy[p.status]??"pending")}).catch(()=>{g||s("pending")}),()=>{g=!0}},[e.requirementId]),v.useEffect(()=>{const g=ST.map(p=>kn.on(p,y=>{const w=y.payload;w.id===e.requirementId&&w.status&&s(hy[w.status]??"pending")}));return()=>g.forEach(p=>p())},[e.requirementId]);const h=async()=>{s("approving");try{await re.requirements.approve(e.requirementId),s("in_progress")}catch{s("pending")}},m=async()=>{if(!d){c(!0);return}if(l.trim()){s("rejecting");try{await re.requirements.reject(e.requirementId,l.trim()),s("rejected")}catch{s("pending")}}},f=r==="pending"||r==="approving"||r==="rejecting",x=my[r]??my.loading;return t.jsxs("div",{className:`my-2 rounded-lg border ${x.borderClass} ${x.bgClass} p-3 max-w-md transition-colors`,children:[t.jsxs("div",{className:"flex items-start gap-2 mb-1",children:[t.jsx("span",{className:"text-sm mt-0.5",children:x.icon}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${x.badgeClass}`,children:"REQ"}),!f&&r!=="loading"&&t.jsx("span",{className:`text-[10px] font-medium ${x.textClass}`,children:x.label})]}),t.jsx("div",{className:`text-sm font-medium truncate mt-1 ${!f&&r!=="loading"?"text-fg-secondary":"text-fg-primary"}`,children:e.title}),e.description&&t.jsx("div",{className:"text-xs text-fg-secondary mt-0.5 line-clamp-3",children:e.description}),t.jsxs("div",{className:"flex items-center gap-2 mt-1.5 text-[11px] text-fg-tertiary",children:[e.priority&&t.jsx("span",{className:xj[e.priority]??"text-fg-tertiary",children:e.priority}),t.jsxs("span",{className:"opacity-50",children:["ID: ",e.requirementId.slice(0,8),"..."]})]})]})]}),f&&t.jsxs("div",{className:"mt-2 pt-2 border-t border-border-default/30 space-y-2",children:[d&&t.jsx("input",{type:"text",value:l,onChange:g=>o(g.target.value),placeholder:"Rejection reason...",className:"w-full px-2 py-1.5 text-xs rounded-md bg-surface-secondary border border-border-default text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:border-brand-500",onKeyDown:g=>g.key==="Enter"&&m(),autoFocus:!0}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:h,disabled:r!=="pending",className:"flex-1 px-3 py-1.5 text-xs font-medium rounded-md bg-green-600 hover:bg-green-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:r==="approving"?"Approving…":"Approve"}),t.jsx("button",{onClick:m,disabled:r!=="pending"||d&&!l.trim(),className:"flex-1 px-3 py-1.5 text-xs font-medium rounded-md bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:r==="rejecting"?"Rejecting…":"Reject"})]})]})]})}function CT({info:e,showTime:r,time:s,isLast:l}){const o=sl(e.tool),[d,c]=v.useState(!1),h=e.status!=="running",m=e.status==="stopped",x=(e.tool==="spawn_subagent"||e.tool==="spawn_subagents")&&e.subagentLogs&&e.subagentLogs.length>0,g=h||x,p=vT(e),y=v.useRef(null);return v.useEffect(()=>{y.current&&(y.current.scrollTop=y.current.scrollHeight)},[e.liveOutput]),t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`relative flex items-start gap-2 py-0.5 min-w-0 ${l?"":"border-b border-border-default/30 pb-1.5 mb-0.5"} ${g?"cursor-pointer rounded hover:bg-surface-elevated/30 transition-colors":""}`,onClick:()=>h&&c(!0),children:[r&&s&&t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0 w-24 text-right tabular-nums mt-0.5 hidden md:inline",children:s}),t.jsx("div",{className:"flex flex-col items-center shrink-0 mt-0.5",style:{width:14},children:t.jsx("div",{className:`w-3 h-3 rounded-full border flex items-center justify-center text-[8px] shrink-0 ${e.status==="running"?"border-brand-500 bg-brand-500/15 animate-pulse":e.status==="error"?"border-red-500 bg-red-500/15 text-red-500":m?"border-gray-500 bg-surface-secondary text-fg-tertiary":"border-green-500 bg-green-500/15 text-green-500"}`,children:e.status==="done"?"✓":e.status==="error"?"✗":m?"■":""})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:`flex items-center gap-1 text-xs leading-snug ${e.status==="running"?"text-brand-500":e.status==="error"?"text-red-500 line-through opacity-50":m?"text-fg-tertiary opacity-60":"text-fg-tertiary"}`,children:[t.jsx("span",{className:"opacity-60",children:o.icon}),t.jsxs("span",{children:[o.label,e.status==="running"?"…":""]}),e.status==="running"&&t.jsxs("svg",{className:"w-3 h-3 animate-spin ml-0.5 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),e.durationMs!=null&&e.status!=="running"&&t.jsx("span",{className:"text-[10px] text-fg-tertiary ml-0.5",children:lx(e.durationMs)}),x&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary ml-0.5 opacity-60",children:["(",e.subagentLogs.filter(w=>w.eventType==="tool_end").length," steps)"]})]}),p&&t.jsxs("div",{className:`mt-0.5 font-mono text-[11px] truncate max-w-full ${e.status==="running"?"text-fg-secondary":"text-fg-tertiary"}`,title:p,children:[t.jsx("span",{className:"text-fg-tertiary select-none",children:"$ "}),ym(p,120)]}),e.liveOutput&&e.status==="running"&&t.jsx("pre",{ref:y,className:"mt-1 font-mono text-[11px] text-fg-tertiary bg-surface-secondary/60 rounded px-2 py-1.5 max-h-32 overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-all",children:e.liveOutput})]})]}),d&&t.jsx(kT,{info:e,onClose:()=>c(!1)}),h&&(()=>{const w=fj(e.tool,e.result);if(w)return t.jsx(gj,{info:w});const N=hj(e.tool,e.result);return N?t.jsx(pj,{info:N}):null})()]})}function ET({content:e,time:r,showTime:s}){const[l,o]=v.useState(!1);return t.jsxs("div",{className:"flex items-start gap-2",children:[s&&r&&t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0 w-24 text-right tabular-nums mt-2.5 hidden md:inline",children:r}),t.jsxs("div",{className:"flex-1 min-w-0 my-1 overflow-hidden",children:[t.jsxs("button",{onClick:()=>o(!l),className:"flex items-center gap-1.5 text-xs text-purple-400 hover:text-purple-300 transition-colors",children:[t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-purple-400/60 shrink-0"}),t.jsx("span",{children:"Thinking"}),t.jsxs("span",{className:"text-fg-tertiary text-[10px]",children:["(",e.length," chars)"]}),t.jsx("svg",{className:`w-3 h-3 transition-transform ${l?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),l&&t.jsx("div",{className:"mt-1.5 bg-purple-500/[0.06] border border-purple-500/15 rounded-lg px-3 py-2.5 overflow-hidden",children:t.jsx(Zn,{content:e,className:"text-xs text-fg-tertiary break-words"})})]})]})}const Td=v.memo(bj);function bj({entry:e,showTime:r,isLast:s}){if(e.type==="tool")return t.jsx(CT,{info:e.info,showTime:r,time:e.time,isLast:s},e.key);if(e.type==="thinking")return t.jsx(ET,{content:e.content,time:e.time,showTime:r});if(e.type==="text")return t.jsxs("div",{className:"flex items-start gap-2 ",children:[r&&e.time&&t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0 w-24 text-right tabular-nums mt-2.5 hidden md:inline",children:e.time}),t.jsx("div",{className:"flex-1 min-w-0 bg-surface-elevated/50 rounded-lg px-3 py-2.5 my-1 overflow-hidden",children:t.jsx(Zn,{content:e.content,className:"text-sm text-fg-secondary break-words"})})]});if(e.type==="status"){const l=e.content==="completed"||e.content==="execution_finished",o=e.content==="started",d=e.content==="resumed",c=l?"text-green-600":o?"text-blue-600":d?"text-amber-600":"text-fg-tertiary",h=l?"bg-green-400":o?"bg-blue-400":d?"bg-amber-400":"bg-gray-500";return t.jsxs("div",{className:"flex items-center gap-2 py-0.5 px-1",children:[r&&e.time&&t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0 w-24 text-right tabular-nums hidden md:inline",children:e.time}),t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${h}`}),t.jsx("span",{className:`text-xs capitalize ${c}`,children:e.content})]})}return e.type==="error"?t.jsxs("div",{className:"flex items-start gap-2 ",children:[r&&e.time&&t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0 w-24 text-right tabular-nums mt-2 hidden md:inline",children:e.time}),t.jsxs("div",{className:"flex-1 min-w-0 text-xs text-red-500 bg-red-500/10 border border-red-500/20 rounded px-2.5 py-2 my-1 leading-relaxed break-words overflow-hidden",children:[t.jsx("span",{className:"font-medium",children:"Error:"})," ",e.content]})]}):null}function Qd({entries:e,streamingText:r,isActive:s,onExpand:l,showRounds:o,embedded:d}){const c=e.length>0?e[e.length-1]:null,h=e.filter(k=>k.type==="tool_end").length,m=e.filter(k=>k.type==="error").length,f=e.length>0?new Date(e[0].createdAt).getTime():Date.now(),x=c?new Date(c.createdAt).getTime():Date.now(),g=s?Date.now()-f:x-f,p=new Set(e.filter(k=>k.executionRound!=null).map(k=>k.executionRound)),y=p.size>0?Math.max(...p):void 0,w=o&&p.size>1;let N,E,A=null;if(!s)m>0&&c?.type==="error"?(N="❌",E="Failed"):(N="✅",E="Completed");else if(r)N="✍",E="Writing response...",A=ym(r.split(`
|
|
42
|
+
`).pop()??"",80);else if(c?.type==="tool_start"){const k=sl(c.content);N=k.icon,E=`${k.label}...`;const S=c.metadata?.arguments&&typeof c.metadata.arguments=="object"?c.metadata.arguments.command:void 0;S&&(A=`$ ${ym(S,80)}`)}else if(c?.type==="tool_end"){const k=sl(c.content);N=k.icon,E=k.label}else N="💭",E="Thinking...";const C=lx(g);return t.jsx("div",{onClick:l,className:`overflow-hidden transition-all cursor-pointer min-w-0 ${d?"hover:bg-surface-elevated/20":`rounded-lg border hover:brightness-110 ${s?"border-2 exec-card-active":"border border-border-default bg-surface-elevated/30 hover:border-brand-500/40"}`}`,children:t.jsxs("div",{className:d?"py-2":"px-3 py-2.5 bg-surface-primary/80",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s?t.jsxs("svg",{className:"w-3.5 h-3.5 animate-spin text-brand-500 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}):t.jsx("span",{className:"text-sm shrink-0",children:N}),t.jsx("span",{className:`text-xs font-medium truncate ${s?"text-fg-primary":"text-fg-secondary"}`,children:E})]}),C&&t.jsx("span",{className:"text-[10px] text-fg-tertiary tabular-nums shrink-0",children:C})]}),r?t.jsx("div",{className:"mt-1.5 ml-5.5 text-xs text-fg-secondary max-h-32 overflow-y-auto whitespace-pre-wrap break-words leading-relaxed",children:t.jsx(Zn,{content:r,className:"text-xs"})}):A?t.jsx("div",{className:"mt-1 ml-5.5 text-[11px] font-mono text-fg-tertiary truncate",children:A}):null,t.jsxs("div",{className:"flex items-center justify-between mt-2",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary",children:[h>0&&t.jsxs("span",{children:["🔧 ",h," tool",h!==1?"s":""]}),e.some(k=>k.type==="text"&&!k.metadata?.isThinking)&&t.jsx("span",{children:"💬 text"}),e.some(k=>k.type==="text"&&k.metadata?.isThinking)&&t.jsx("span",{className:"text-purple-400",children:"💭 thinking"}),w&&y!=null&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"opacity-30",children:"·"}),t.jsxs("span",{children:["Round #",y]}),t.jsx("span",{className:"opacity-30",children:"·"}),t.jsxs("span",{children:[p.size," rounds"]})]})]}),t.jsxs("span",{className:"text-[10px] text-brand-500 flex items-center gap-0.5",children:["Show Full Log",t.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]})]})]})})}function TT(e){const r=new Map;for(const s of e){const l=s.executionRound??1;r.has(l)||r.set(l,[]);const o=Ed(s);o&&r.get(l).push(o)}return Array.from(r.entries()).sort(([s],[l])=>s-l).map(([s,l])=>({round:s,entries:l}))}function Kd({entries:e,streamingText:r,isActive:s,onCollapse:l,showRounds:o,embedded:d}){const c=v.useRef(null),[h,m]=v.useState(new Set),f=TT(e),x=o&&f.length>1;v.useEffect(()=>{f.length>0&&m(w=>{const N=new Set(w);return N.add(f[f.length-1].round),N})},[f.length]),v.useEffect(()=>{d||!c.current||!s||(c.current.scrollTop=c.current.scrollHeight)},[e.length,r,s,d]);const g=w=>{m(N=>{const E=new Set(N);return E.has(w)?E.delete(w):E.add(w),E})},p=x?null:e.map(Ed).filter(w=>w!==null),y=p?Cd(p):null;return t.jsxs("div",{className:`min-w-0 overflow-hidden ${d?"":"rounded-lg border border-border-default bg-surface-primary/50"}`,children:[t.jsxs("div",{onClick:l,className:`flex items-center cursor-pointer hover:bg-surface-elevated/40 transition-colors ${d?"justify-end py-0.5":"justify-between px-3 py-1.5 border-b border-border-default"}`,children:[!d&&t.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium uppercase tracking-wider",children:"Execution Log"}),t.jsxs("span",{className:"text-[10px] text-brand-500 flex items-center gap-0.5",children:["Collapse",t.jsx("svg",{className:"w-3 h-3 rotate-180",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]})]}),t.jsxs("div",{ref:d?void 0:c,className:`space-y-0.5 min-w-0 overflow-x-hidden ${d?"py-1":"px-3 py-2 max-h-[60vh] overflow-y-auto scrollbar-thin"}`,children:[x?f.map(w=>{const N=h.has(w.round),E=Cd(w.entries),A=w.entries.filter(C=>C.type==="tool"&&C.info?.status!=="running").length;return t.jsxs("div",{className:"border border-border-default/50 rounded-lg mb-2 overflow-hidden",children:[t.jsxs("button",{onClick:()=>g(w.round),className:"w-full flex items-center justify-between px-3 py-1.5 bg-surface-elevated/30 hover:bg-surface-elevated/50 transition-colors",children:[t.jsxs("span",{className:"text-xs text-fg-secondary font-medium",children:["Round #",w.round]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[A," tool",A!==1?"s":""]}),t.jsx("svg",{className:`w-3 h-3 text-fg-tertiary transition-transform ${N?"rotate-180":""}`,viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]})]}),N&&t.jsx("div",{className:"px-3 py-1.5 space-y-0.5",children:E.map((C,k)=>t.jsx(Td,{entry:C,showTime:!0,isLast:k===E.length-1},k))})]},w.round)}):y&&y.map((w,N)=>t.jsx(Td,{entry:w,showTime:!0,isLast:N===y.length-1},N)),s&&r&&t.jsx(jm,{content:r}),s&&!r&&t.jsx(vm,{})]})]})}var ix=r1();function AT({agents:e,filter:r,anchorRef:s,onSelect:l,selectedIndex:o,onIndexChange:d}){const[c,h]=v.useState(null),m=v.useRef(null),f=e.filter(x=>x.name.toLowerCase().includes(r));return v.useEffect(()=>{const x=s.current;if(!x)return;const g=x.getBoundingClientRect();h({top:g.top+window.scrollY-4,left:g.left+window.scrollX+8})},[s,r]),v.useEffect(()=>{if(!m.current||!c)return;if(m.current.getBoundingClientRect().top<8){const g=s.current;if(!g)return;const p=g.getBoundingClientRect();h({top:p.bottom+window.scrollY+4,left:c.left})}},[c,s]),v.useEffect(()=>{o>=f.length&&d(Math.max(0,f.length-1))},[f.length,o,d]),v.useEffect(()=>{if(!m.current)return;m.current.querySelector('[data-selected="true"]')?.scrollIntoView({block:"nearest"})},[o]),!c||f.length===0?null:ix.createPortal(t.jsxs("div",{ref:m,style:{position:"absolute",top:c.top,left:c.left,transform:"translateY(-100%)"},className:"w-60 bg-surface-overlay border border-border-default rounded-lg shadow-xl z-[9999] max-h-48 overflow-y-auto",children:[t.jsx("div",{className:"px-2.5 py-1.5 text-[10px] text-fg-tertiary font-medium uppercase tracking-wider border-b border-border-default",children:"Mention an agent"}),f.map((x,g)=>t.jsxs("button",{"data-selected":g===o,onMouseDown:p=>{p.preventDefault(),l(x)},onMouseEnter:()=>d(g),className:`w-full text-left px-3 py-2 text-xs flex items-center gap-2 transition-colors ${g===o?"bg-brand-500/15 text-brand-500":"hover:bg-surface-elevated"}`,children:[t.jsx("span",{className:"w-6 h-6 rounded-full bg-brand-500/20 flex items-center justify-center text-[10px] font-bold text-brand-500 shrink-0",children:x.name.slice(0,2).toUpperCase()}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-fg-primary font-medium",children:x.name}),t.jsx("span",{className:"text-fg-tertiary text-[10px] ml-1.5",children:x.role})]}),t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${x.status==="idle"||x.status==="working"?"bg-green-400":"bg-gray-500"}`})]},x.id))]}),document.body)}function _T(e){return/^\w+$/.test(e)?`@${e}`:`@[${e}]`}const Ad=/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu;function MT(e){const r=[];let s;for(Ad.lastIndex=0;(s=Ad.exec(e))!==null;)r.push(s[1]??s[2]);return r}function xy(e,r,s){const l=[],o=new RegExp(Ad.source,Ad.flags);let d=0,c,h=0;for(;(c=o.exec(e))!==null;){c.index>d&&l.push(t.jsx("span",{children:e.slice(d,c.index)},h++));const m=c[1]??c[2],f=r.find(x=>x.name.toLowerCase()===m.toLowerCase());l.push(t.jsxs("span",{className:"text-brand-500 font-medium ",onClick:void 0,title:f?`${f.name} (${f.role})`:void 0,children:["@",m]},h++)),d=c.index+c[0].length}return d<e.length&&l.push(t.jsx("span",{children:e.slice(d)},h++)),l.length>0?l:[t.jsx("span",{children:e},0)]}function yj({agents:e,onSubmit:r,placeholder:s}){const[l,o]=v.useState(""),[d,c]=v.useState(!1),[h,m]=v.useState(null),[f,x]=v.useState(!1),[g,p]=v.useState(""),[y,w]=v.useState([]),[N,E]=v.useState(0),A=v.useRef(null),C=v.useRef(null),k=e.filter($=>$.name.toLowerCase().includes(g)),S=async()=>{if(l.trim()){c(!0),m(null),C.current={content:l,mentions:[...y]};try{await r(l,y),o(""),w([]),C.current=null}catch($){m(String($ instanceof Error?$.message:$)||"Failed to send comment")}c(!1)}},O=async()=>{if(!C.current)return;const{content:$,mentions:F}=C.current;c(!0),m(null);try{await r($,F),o(""),w([]),C.current=null}catch(B){m(String(B instanceof Error?B.message:B)||"Failed to send comment")}c(!1)},R=v.useCallback($=>{o(F=>{const B=F.lastIndexOf("@"),T=_T($.name);return B>=0?F.slice(0,B)+T+" ":F+T+" "}),y.includes($.id)||w(F=>[...F,$.id]),x(!1),p(""),E(0),A.current?.focus()},[y]),G=$=>{o($),m(null);const F=$.lastIndexOf("@");if(F>=0&&(F===0||$[F-1]===" ")){const T=$.slice(F+1).toLowerCase();if(e.some(z=>z.name.toLowerCase().includes(T))){p(T),x(!0),E(0);return}}x(!1)},I=$=>{if(f&&k.length>0){const F=$.key==="ArrowUp"||$.ctrlKey&&$.key==="p",B=$.key==="ArrowDown"||$.ctrlKey&&$.key==="n",T=$.key==="Enter"||$.key==="Tab",D=$.key==="Escape";if(F){$.preventDefault(),E(z=>(z-1+k.length)%k.length);return}if(B){$.preventDefault(),E(z=>(z+1)%k.length);return}if(T){$.preventDefault();const z=k[N];z&&R(z);return}if(D){$.preventDefault(),x(!1);return}}$.key==="Enter"&&!$.shiftKey&&($.preventDefault(),S())},Q=v.useCallback(()=>{setTimeout(()=>x(!1),200)},[]);return t.jsxs("div",{className:"relative",children:[f&&t.jsx(AT,{agents:e,filter:g,anchorRef:A,onSelect:R,selectedIndex:N,onIndexChange:E}),t.jsxs("div",{className:"border border-border-default rounded-lg bg-surface-elevated",children:[y.length>0&&t.jsx("div",{className:"flex gap-1 px-2.5 pt-2 flex-wrap",children:y.map($=>{const F=e.find(B=>B.id===$);return t.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] bg-brand-500/15 text-brand-500 rounded-full",children:["@",F?.name??$,t.jsx("button",{onClick:()=>w(B=>B.filter(T=>T!==$)),className:"hover:text-red-400",children:"×"})]},$)})}),t.jsx("textarea",{ref:A,value:l,onChange:$=>G($.target.value),onKeyDown:I,onBlur:Q,placeholder:s??"Add a comment… (type @ to mention an agent)",rows:2,className:"w-full px-2.5 py-2 text-xs bg-transparent text-fg-primary placeholder-fg-tertiary outline-none resize-none"}),h&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 pb-1.5",children:[t.jsx("span",{className:"text-[11px] text-red-400 flex-1 truncate",children:h}),t.jsxs("button",{onClick:O,disabled:d,className:"text-[11px] text-amber-500 hover:text-amber-400 font-medium transition-colors flex items-center gap-1",children:[t.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("polyline",{points:"23 4 23 10 17 10"}),t.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),"Retry"]})]}),t.jsx("div",{className:"flex justify-end px-2.5 pb-2",children:t.jsx("button",{onClick:S,disabled:!l.trim()||d,className:"px-3 py-1 text-[11px] font-medium bg-brand-500 text-white rounded-md hover:bg-brand-600 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:d?"Sending…":"Comment"})})]})]})}const DT="(max-width: 767px)";let zh=null;function vj(){return zh||(zh=window.matchMedia(DT)),zh}function OT(e){const r=vj();return r.addEventListener("change",e),()=>r.removeEventListener("change",e)}function RT(){return vj().matches}function LT(){return!1}function ks(){return v.useSyncExternalStore(OT,RT,LT)}function jj({title:e,message:r,confirmLabel:s="Confirm",checkboxes:l,onConfirm:o,onCancel:d}){const[c,h]=v.useState(()=>{const m={};for(const f of l??[])m[f.id]=f.defaultChecked??!1;return m});return t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:d,children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[360px] shadow-2xl",onClick:m=>m.stopPropagation(),children:[t.jsx("h3",{className:"font-semibold text-base mb-2",children:e}),t.jsx("p",{className:"text-sm text-fg-secondary mb-4 leading-relaxed",children:r}),l&&l.length>0&&t.jsx("div",{className:"mb-4 space-y-2",children:l.map(m=>t.jsxs("label",{className:"flex items-center gap-2 text-sm text-fg-secondary cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:c[m.id]??!1,onChange:f=>h(x=>({...x,[m.id]:f.target.checked})),className:"rounded bg-surface-elevated border-border-default"}),m.label]},m.id))}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{onClick:d,className:"px-4 py-1.5 text-sm border border-border-default rounded-lg hover:bg-surface-elevated transition-colors",children:"Cancel"}),t.jsx("button",{onClick:()=>o(l?c:void 0),className:"px-4 py-1.5 text-sm bg-red-600 hover:bg-red-500 text-white rounded-lg transition-colors",children:s})]})]})})}function Jd({children:e,onClose:r,title:s,width:l="w-[440px]"}){return t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:r,children:t.jsxs("div",{className:`bg-surface-secondary border border-border-default rounded-xl p-6 ${l} shadow-2xl max-h-[90vh] overflow-y-auto`,onClick:o=>o.stopPropagation(),children:[t.jsx("h3",{className:"text-base font-semibold mb-5",children:s}),e]})})}function Gs({label:e,children:r}){return t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-secondary mb-1.5 font-medium",children:e}),r]})}function zT({onClose:e,onCreate:r}){const[s,l]=v.useState(""),[o,d]=v.useState("");return t.jsx(Jd,{onClose:e,title:"Create a New Team",children:t.jsxs("div",{className:"space-y-4",children:[t.jsx(Gs,{label:"Team Name",children:t.jsx("input",{value:s,onChange:c=>l(c.target.value),placeholder:"e.g. Engineering, Marketing, Support",className:"input",autoFocus:!0,onKeyDown:c=>{c.key==="Enter"&&s.trim()&&r(s.trim(),o.trim()||void 0)}})}),t.jsx(Gs,{label:"Description (optional)",children:t.jsx("textarea",{value:o,onChange:c=>d(c.target.value),placeholder:"What does this team work on?",className:"input",rows:2})}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:"You can add human and AI members to this team after creating it."}),t.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[t.jsx("button",{onClick:e,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:"Cancel"}),t.jsx("button",{onClick:()=>s.trim()&&r(s.trim(),o.trim()||void 0),disabled:!s.trim(),className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-40 rounded-lg text-white",children:"Create Team"})]})]})})}function IT({teamId:e,teams:r,onClose:s,onAdd:l}){const[o,d]=v.useState(""),[c,h]=v.useState("member"),[m,f]=v.useState(""),[x,g]=v.useState(""),[p,y]=v.useState(""),[w,N]=v.useState(e??""),[E,A]=v.useState(""),C=()=>{if(A(""),!o.trim()){A("Name is required");return}if(x&&x!==p){A("Passwords do not match");return}l(o.trim(),c,m||void 0,x||void 0,w||void 0)};return t.jsx(Jd,{onClose:s,title:"Add Human Team Member",width:"w-[460px]",children:t.jsxs("div",{className:"space-y-4",children:[t.jsx(Gs,{label:"Name *",children:t.jsx("input",{value:o,onChange:k=>d(k.target.value),placeholder:"Full name",className:"input",autoFocus:!0})}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsx(Gs,{label:"Role",children:t.jsxs("select",{value:c,onChange:k=>h(k.target.value),className:"input",children:[t.jsx("option",{value:"owner",children:"Owner"}),t.jsx("option",{value:"admin",children:"Admin"}),t.jsx("option",{value:"member",children:"Member"}),t.jsx("option",{value:"guest",children:"Guest"})]})}),t.jsx(Gs,{label:"Assign to Team",children:t.jsxs("select",{value:w,onChange:k=>N(k.target.value),className:"input",children:[t.jsx("option",{value:"",children:"No team"}),r.map(k=>t.jsx("option",{value:k.id,children:k.name},k.id))]})})]}),t.jsx(Gs,{label:"Email",children:t.jsx("input",{value:m,onChange:k=>f(k.target.value),type:"email",placeholder:"Optional (required for login)",className:"input"})}),t.jsxs("div",{className:"border-t border-border-default pt-3",children:[t.jsx("div",{className:"text-xs text-fg-tertiary mb-3",children:"Set a password to allow this person to log in."}),t.jsx(Gs,{label:"Password",children:t.jsx("input",{value:x,onChange:k=>g(k.target.value),type:"password",placeholder:"Leave blank for no login access",className:"input"})}),x&&t.jsx("div",{className:"mt-3",children:t.jsx(Gs,{label:"Confirm Password",children:t.jsx("input",{value:p,onChange:k=>y(k.target.value),type:"password",placeholder:"Repeat password",className:"input"})})})]}),E&&t.jsx("div",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/30 rounded-lg px-3 py-2",children:E}),t.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[t.jsx("button",{onClick:s,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:"Cancel"}),t.jsx("button",{onClick:C,className:"px-4 py-2 text-sm bg-green-700 hover:bg-green-600 rounded-lg text-white",children:"Add Member"})]})]})})}function $T({teamId:e,ungrouped:r,onClose:s,onAdd:l}){return t.jsx(Jd,{onClose:s,title:"Add Existing Member to Team",children:t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Select an ungrouped member to add to this team."}),r.length===0?t.jsx("div",{className:"text-center py-8 text-sm text-fg-tertiary",children:"All members are already in a team."}):t.jsx("div",{className:"space-y-2 max-h-72 overflow-y-auto",children:r.map(o=>t.jsxs("button",{onClick:()=>l(o.id,o.type),className:"w-full flex items-center gap-3 px-4 py-3 rounded-lg border border-border-default hover:border-brand-500 hover:bg-brand-500/10 text-left transition-all",children:[t.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center text-xs font-bold text-white ${o.type==="agent"?"bg-brand-600":"bg-green-600"}`,children:o.name.charAt(0)}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-sm",children:o.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[o.role," · ",o.type==="agent"?"AI":"Human"]})]}),o.status&&t.jsx("span",{className:`w-2 h-2 rounded-full ${o.status==="idle"?"bg-green-400":o.status==="working"?"bg-brand-400":"bg-gray-600"}`})]},o.id))}),t.jsx("div",{className:"flex justify-end pt-2",children:t.jsx("button",{onClick:s,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:"Close"})})]})})}function BT({onClose:e,onConnected:r}){const[s,l]=v.useState(""),[o,d]=v.useState(""),[c,h]=v.useState(!1),[m,f]=v.useState(null),[x,g]=v.useState(null),p=async()=>{if(!s.trim()){d("Agent name is required");return}const w=s.trim().toLowerCase().replace(/\s+/g,"-");h(!0),d("");try{const N=await fetch("/api/external-agents/register",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({externalAgentId:w,agentName:s.trim(),orgId:"default",capabilities:["general"]})});if(!N.ok){const A=await N.json().catch(()=>({}));throw new Error(A.error??`HTTP ${N.status}`)}const E=await N.json();f({externalAgentId:w,markusAgentId:E.registration?.markusAgentId,token:E.token,gatewayUrl:E.gatewayUrl})}catch(N){d(String(N))}h(!1)},y=(w,N)=>{navigator.clipboard.writeText(w),g(N),setTimeout(()=>g(null),2e3)};return t.jsx(Jd,{onClose:e,title:"Import OpenClaw Agent",width:"w-[560px]",children:m?(()=>{const w=m.gatewayUrl??`${window.location.origin}/api/gateway`,N=`Connect to the Markus AI platform as an external agent.
|
|
43
|
+
|
|
44
|
+
Gateway URL: ${w}
|
|
45
|
+
Agent ID: ${m.externalAgentId}
|
|
46
|
+
${m.token?`Bearer Token: ${m.token}`:""}
|
|
47
|
+
|
|
48
|
+
Step 1: Read the integration handbook at GET ${w}/manual (set header Authorization: Bearer <token above>). It describes the full Markus concept model, API endpoints, and collaboration patterns.
|
|
49
|
+
Step 2: Start a sync loop — call POST ${w}/sync every 30 seconds with your status. The response includes assigned tasks, inbox messages, team context (colleagues), and project context (requirements).
|
|
50
|
+
Step 3: Accept and execute tasks, report progress, and communicate with teammates via the sync message system.`;return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"text-center py-6",children:[t.jsx("div",{className:"text-3xl mb-3 text-green-600",children:"✓"}),t.jsx("div",{className:"text-base text-green-600 font-medium mb-1",children:"Agent registered"}),t.jsx("div",{className:"text-sm text-fg-secondary mt-1",children:t.jsx("strong",{children:s})})]}),t.jsxs("div",{className:"bg-brand-500/10 border border-brand-500/30 rounded-xl p-4",children:[t.jsx("div",{className:"text-xs text-fg-secondary mb-3",children:"Copy this prompt and paste it into your OpenClaw agent, Cursor, or any AI assistant."}),t.jsx("button",{onClick:()=>y(N,"prompt"),className:`w-full py-2.5 text-sm font-medium rounded-lg transition-colors ${x==="prompt"?"bg-green-600 text-white":"bg-brand-700 hover:bg-brand-600 text-white"}`,children:x==="prompt"?"Copied!":"Copy Connection Prompt"})]}),t.jsx("div",{className:"flex justify-end pt-5",children:t.jsx("button",{onClick:()=>{r()},className:"px-5 py-2 text-sm bg-surface-elevated hover:bg-surface-overlay rounded-lg text-fg-secondary border border-border-default",children:"Done"})})]})})():t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"text-xs text-fg-secondary mb-4",children:"Register an OpenClaw agent to join your Markus organization. After registration, you'll get a ready-to-use connection config."}),t.jsxs("div",{className:"space-y-4",children:[t.jsx(Gs,{label:"Agent Name *",children:t.jsx("input",{className:"input",placeholder:"e.g. Alice",value:s,onChange:w=>l(w.target.value),autoFocus:!0})}),o&&t.jsx("div",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/30 rounded-lg px-3 py-2",children:o}),t.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[t.jsx("button",{onClick:e,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:"Cancel"}),t.jsx("button",{onClick:p,disabled:c,className:"px-4 py-2 text-sm bg-brand-700 hover:bg-brand-600 rounded-lg text-white disabled:opacity-50",children:c?"Connecting...":"Import Agent"})]})]})]})})}let gy=new Map;function HT(e){return e.split(" ").map(r=>r[0]).join("").toUpperCase().slice(0,2)}function PT({authUser:e,agents:r,teams:s,humans:l,tasks:o,externalAgents:d,groupChats:c,chatMode:h,selectedAgent:m,activeChannel:f,activeDmUserId:x,onSelectAgent:g,onSelectChannel:p,onSelectDm:y,onRefreshTeams:w,onRefreshAgents:N,onViewProfile:E,width:A,onResizeStart:C,hidden:k}){const S=ks(),O=e?.role==="owner"||e?.role==="admin",R=v.useMemo(()=>new Set(d.map(de=>de.markusAgentId).filter(Boolean)),[d]),[G,I]=v.useState([]),[Q,$]=v.useState(new Set),[F,B]=v.useState(!1),[T,D]=v.useState(null),[z,_]=v.useState(null),[Y,V]=v.useState(!1),[J,U]=v.useState(null),[H,X]=v.useState(null),[L,M]=v.useState(null),[q,K]=v.useState(!1),ee=v.useRef(null),[te,se]=v.useState(null),xe=(de,Be="success")=>{se({message:de,type:Be}),setTimeout(()=>se(null),3e3)},[ke,De]=v.useState(null),ge=(de,Be,Le,ot,Qe)=>{De({title:de,message:Be,onConfirm:Le,confirmLabel:ot,checkboxes:Qe})},[ye,Ce]=v.useState(null),[ze,tt]=v.useState(null),Xe=v.useRef(null),dt=v.useRef(null),[wt,ae]=v.useState(!1),[Te,Ze]=v.useState(null),[xt,dn]=v.useState(""),we=v.useCallback(de=>{if(!de)return;const Be=de.getBoundingClientRect(),Le=8;Be.bottom>window.innerHeight&&(de.style.top=`${Math.max(Le,window.innerHeight-Be.height-Le)}px`),Be.right>window.innerWidth&&(de.style.left=`${Math.max(Le,window.innerWidth-Be.width-Le)}px`)},[]),[Re,qe]=v.useState(gy),et=v.useMemo(()=>r.map(de=>de.id).sort().join(","),[r]);v.useEffect(()=>{if(!r.length)return;let de=!1;const Be=async()=>{const ot=[];if(await Promise.allSettled(r.map(async Qe=>{try{const{sessions:ft}=await re.sessions.listByAgent(Qe.id,1);if(!ft.length)return;const{messages:Zt}=await re.sessions.getMessages(ft[0].id,1);if(Zt.length){const it=Zt[0],gt=it.metadata?.segments;let wn=it.content;if(gt&>.length>0){const Qt=[...gt].reverse().find(At=>At.type==="text");Qt&&Qt.type==="text"&&(wn=Qt.content)}const an=wn.replace(/<think>[\s\S]*?<\/think>/g,"").replace(/\n+/g," ").trim().slice(0,80);an&&ot.push([Qe.id,an])}}catch{}})),!de){const Qe=new Map(ot);gy=Qe,qe(Qe)}};Be();const Le=setInterval(Be,3e4);return()=>{de=!0,clearInterval(Le)}},[et]);const nt=v.useCallback(()=>{re.teams.list().then(de=>I(de.ungrouped)).catch(()=>{})},[]);v.useEffect(()=>{nt()},[nt]),v.useEffect(()=>kn.on("*",nt),[nt]),v.useEffect(()=>{if(!J&&!H&&!q)return;const de=Be=>{U(null),X(null),K(!1)};return setTimeout(()=>document.addEventListener("click",de),0),()=>document.removeEventListener("click",de)},[J,H,q]);const zt=(de,Be)=>{ge(`Delete "${Be}"?`,"This team will be removed from the database. Check options below to also delete members and disk files.",async Le=>{const ot=Le?.deleteMembers??!0,Qe=Le?.purgeFiles??!1;await re.teams.delete(de,ot,{purgeFiles:Qe}),w(),nt(),window.dispatchEvent(new CustomEvent("markus:data-changed"))},"Delete Team",[{id:"deleteMembers",label:"Also delete all members in this team",defaultChecked:!0},{id:"purgeFiles",label:"Also delete disk files (workspace, memory, logs)",defaultChecked:!1}])},Yt=async(de,Be)=>{try{const ot=await(Be==="start"?re.teams.startAll:Be==="stop"?re.teams.stopAll:Be==="pause"?re.teams.pauseAll:re.teams.resumeAll)(de),Qe=ot.success?.length??0,ft=ot.failed?.length??0,Zt={start:"started",stop:"stopped",pause:"paused",resume:"resumed"};ft>0?xe(`${Be}: ${Qe} succeeded, ${ft} failed`,"error"):Qe>0&&xe(`${Qe} agent${Qe>1?"s":""} ${Zt[Be]}`,"success"),N()}catch(Le){xe(`Failed to ${Be}: ${Le instanceof Error?Le.message:String(Le)}`,"error")}},Lt=async(de,Be,Le)=>{await re.teams.update(de,{managerId:Be,managerType:Le}),w()},Tt=async de=>{if(!xt.trim()){Ze(null);return}await re.teams.update(de,{name:xt.trim()}),Ze(null),w()},qt=async(de,Be)=>{Be==="offline"?await re.agents.start(de):await re.agents.stop(de),N()},yt=(de,Be)=>{ge("Remove from team?","This member will be moved to Ungrouped.",async()=>{await re.teams.removeMember(de,Be),w(),nt()},"Remove")},sn=(de,Be,Le)=>{ge(`Remove "${Be}"?`,"This agent will be removed from the database. Check the option below to also delete its workspace, memory, and other files from disk.",async ot=>{{const Qe=ot?.purgeFiles??!1;await re.agents.remove(de,{purgeFiles:Qe})}N(),w(),nt(),window.dispatchEvent(new CustomEvent("markus:data-changed"))},"Remove",[{id:"purgeFiles",label:"Also delete disk files (workspace, memory, logs)",defaultChecked:!1}])},Xt=(de,Be,Le)=>{dt.current={x:de.clientX,y:de.clientY},Xe.current=setTimeout(()=>{Ce({agentId:Be,fromTeamId:Le}),ae(!0)},200)},je=de=>{if(!dt.current||!Xe.current)return;const Be=Math.abs(de.clientX-dt.current.x),Le=Math.abs(de.clientY-dt.current.y);(Be>5||Le>5)&&(wt||(clearTimeout(Xe.current),Xe.current=null))},Pe=async()=>{if(Xe.current&&(clearTimeout(Xe.current),Xe.current=null),dt.current=null,wt&&ye&&ze){const de=ze==="_ungrouped"?void 0:ze;try{if(ye.fromTeamId&&ye.fromTeamId!==de&&await re.teams.removeMember(ye.fromTeamId,ye.agentId),de&&de!==ye.fromTeamId){const Be=r.find(Le=>Le.id===ye.agentId);await re.teams.addMember(de,ye.agentId,"agent")}w(),N(),nt()}catch(Be){xe(`Move failed: ${Be instanceof Error?Be.message:String(Be)}`,"error")}}Ce(null),tt(null),ae(!1)},vt=v.useMemo(()=>new Map(s.map(de=>[de.id,de])),[s]),Nt=v.useMemo(()=>{const de=new Map,Be=[];for(const Le of r)if(Le.teamId&&vt.has(Le.teamId)){const ot=de.get(Le.teamId)??[];ot.push(Le),de.set(Le.teamId,ot)}else Be.push(Le);return{byTeam:de,ungrouped:Be}},[r,vt]);s.filter(de=>Nt.byTeam.has(de.id)||de.members?.length>0).map(de=>de.id);const ut=de=>$(Be=>{const Le=new Set(Be);return Le.has(de)?Le.delete(de):Le.add(de),Le}),Wt=(de,Be)=>{const Le=h==="direct"&&m===de.id,ot=R.has(de.id),Qe=de.status==="idle"?"bg-green-500":de.status==="working"?"bg-blue-500 animate-pulse":de.status==="error"?"bg-red-500":de.status==="paused"?"bg-amber-500":"bg-gray-600",Zt=(Be?vt.get(Be):void 0)?.managerId===de.id,it=de.role?.toLowerCase().replace(/[-_]/g," ").trim(),gt=de.name.toLowerCase().trim(),wn=it&&it!==gt,an=Re.get(de.id)||de.currentActivity?.label?.slice(0,60)||"",Qt=de.status==="idle"?"Online":de.status==="working"?"Working":de.status==="error"?"Error":de.status==="paused"?"Paused":"Offline";return t.jsx("div",{className:`relative mb-0.5 ${wt&&ye?.agentId===de.id?"opacity-40":""}`,onPointerDown:At=>Xt(At,de.id,Be),onPointerMove:je,onPointerUp:Pe,children:t.jsxs("button",{onClick:()=>{wt||g(de.id)},onContextMenu:At=>{O&&(At.preventDefault(),X({agentId:de.id,teamId:Be,x:At.clientX,y:At.clientY}))},className:`w-full flex items-center gap-2.5 px-2 py-1.5 rounded-lg text-xs transition-colors select-none ${S?"":"touch-none"} ${Le?"bg-brand-600/20 text-brand-500":"text-fg-secondary hover:bg-surface-elevated"}`,children:[t.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-bold shrink-0 ${Le?"bg-brand-600 text-white":"bg-surface-overlay text-fg-secondary"}`,children:HT(de.name)}),t.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"truncate font-medium text-[11px] leading-tight",children:de.name}),wn&&t.jsxs("span",{className:"text-[9px] text-fg-tertiary shrink-0 truncate max-w-[60px]",children:["(",de.role,")"]}),Zt&&t.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"currentColor",className:"text-amber-600 shrink-0",children:t.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),ot&&t.jsx("span",{className:"text-[8px] px-1 py-0 rounded bg-brand-500/20 text-brand-500 font-medium shrink-0 leading-relaxed",children:"EXT"})]}),t.jsx("div",{className:"truncate text-[10px] leading-tight mt-0.5 text-fg-tertiary",children:an||" "})]}),t.jsx("span",{title:Qt,onClick:At=>{At.stopPropagation(),E(de.id)},className:`w-2 h-2 rounded-full shrink-0 cursor-pointer transition-transform duration-150 hover:scale-[2] ${Qe}`})]})},de.id)},en=(de,Be,Le,ot)=>{const Qe=Q.has(de),ft=wt&&ze===de&&ye?.fromTeamId!==de,Zt=de!=="_ungrouped"?(Ct.byTeam.get(de)??[])[0]:void 0,it=Zt&&h==="channel"&&f===Zt.channelKey;return t.jsxs("div",{className:`mb-1 rounded-lg transition-colors ${ft?"ring-1 ring-brand-500/50 bg-brand-500/5":""}`,onPointerEnter:()=>{wt&&tt(de)},onPointerLeave:()=>{wt&&ze===de&&tt(null)},children:[t.jsxs("div",{className:"group/teamhdr flex items-center gap-0.5",children:[t.jsxs("button",{onClick:()=>{Zt?p(Zt.channelKey):ut(de)},onContextMenu:gt=>{!O||!Be||(gt.preventDefault(),U({teamId:de,x:gt.clientX,y:gt.clientY}))},className:`flex-1 flex items-center gap-2 px-2 py-1.5 rounded-lg text-xs transition-colors min-w-0 ${it?"bg-brand-600/20 text-brand-500":"text-fg-secondary hover:bg-surface-elevated"}`,children:[t.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center shrink-0 ${it?"bg-brand-600 text-white":"bg-surface-overlay text-fg-secondary"}`,children:t.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"9",cy:"7",r:"4"}),t.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),t.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}),t.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[Te===de?t.jsx("input",{className:"bg-transparent border-b border-brand-500 text-fg-secondary text-[11px] font-medium outline-none w-full",value:xt,onChange:gt=>dn(gt.target.value),onBlur:()=>Tt(de),onKeyDown:gt=>{gt.key==="Enter"&&Tt(de),gt.key==="Escape"&&Ze(null)},onClick:gt=>gt.stopPropagation(),autoFocus:!0}):t.jsx("span",{className:"truncate font-medium text-[11px] leading-tight block",children:ot}),t.jsxs("div",{className:"text-[10px] text-fg-tertiary leading-tight mt-0.5",children:[Le.length," members"]})]})]}),t.jsx("button",{onClick:()=>ut(de),className:"w-5 h-5 flex items-center justify-center text-fg-tertiary hover:text-fg-secondary rounded transition-colors shrink-0 opacity-60 hover:opacity-100",title:Qe?"Expand":"Collapse",children:t.jsx("svg",{className:`w-3 h-3 transition-transform duration-150 ${Qe?"":"rotate-90"}`,fill:"currentColor",viewBox:"0 0 20 20",children:t.jsx("path",{fillRule:"evenodd",d:"M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z",clipRule:"evenodd"})})}),O&&Be&&t.jsx("button",{onClick:gt=>{gt.stopPropagation(),U({teamId:de,x:gt.clientX,y:gt.clientY})},className:"w-5 h-5 flex items-center justify-center text-fg-tertiary hover:text-fg-secondary rounded transition-colors shrink-0 opacity-0 group-hover/teamhdr:opacity-100",title:"More options",children:t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"1"}),t.jsx("circle",{cx:"12",cy:"5",r:"1"}),t.jsx("circle",{cx:"12",cy:"19",r:"1"})]})})]}),ft&&wt&&t.jsx("div",{className:"text-[9px] text-brand-500 px-4 py-0.5 animate-pulse",children:"Drop here"}),!Qe&&t.jsx("div",{className:"ml-1",children:Le.map(gt=>Wt(gt,de==="_ungrouped"?void 0:de))})]},de)},Ct=v.useMemo(()=>{const de=new Map,Be=[];for(const Le of c)if(Le.teamId){const ot=de.get(Le.teamId)??[];ot.push(Le),de.set(Le.teamId,ot)}else{const ot=s.find(Qe=>Le.name.toLowerCase().includes(Qe.name.toLowerCase())||Qe.name.toLowerCase().includes(Le.name.toLowerCase()));if(ot){const Qe=de.get(ot.id)??[];Qe.push(Le),de.set(ot.id,Qe)}else Be.push(Le)}return{byTeam:de,unmatched:Be}},[c,s]);return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`bg-surface-secondary/60 border-r border-border-default flex flex-col ${A!=null?"shrink-0":"flex-1 min-w-0"}`,style:k?{display:"none"}:A!=null?{width:A}:void 0,children:[t.jsx("div",{className:"px-4 h-14 flex items-center border-b border-border-default shrink-0",children:t.jsx("h2",{className:"text-lg font-semibold",children:"Chat"})}),O&&t.jsx("div",{className:"px-3 pt-2 pb-1 flex items-center gap-1.5",ref:ee,children:t.jsxs("div",{className:"relative flex-1",children:[t.jsxs("button",{onClick:()=>K(!q),className:"w-full flex items-center justify-center gap-1 px-2 py-1.5 text-[10px] font-medium text-fg-secondary hover:text-fg-primary bg-surface-elevated/60 hover:bg-surface-elevated rounded-lg transition-colors",children:[t.jsx("span",{className:"text-brand-500",children:"+"})," Manage",t.jsx("svg",{className:`w-2.5 h-2.5 ml-auto transition-transform ${q?"rotate-180":""}`,fill:"currentColor",viewBox:"0 0 20 20",children:t.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]}),q&&t.jsxs("div",{className:"absolute left-0 top-full mt-1 w-48 bg-surface-secondary border border-border-default rounded-lg shadow-xl z-30 overflow-hidden",children:[t.jsxs("button",{onClick:()=>{K(!1),B(!0)},className:"w-full text-left px-4 py-2.5 text-xs text-fg-secondary hover:bg-surface-elevated transition-colors",children:[t.jsxs("div",{className:"font-medium flex items-center gap-1.5",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"9",cy:"7",r:"4"}),t.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),t.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),"New Team"]}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5 pl-[18px]",children:"Create an empty team"})]}),t.jsxs("button",{onClick:()=>{K(!1),jt.navigate("agents")},className:"w-full text-left px-4 py-2.5 text-xs text-fg-secondary hover:bg-surface-elevated border-t border-border-default transition-colors",children:[t.jsxs("div",{className:"font-medium flex items-center gap-1.5",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"3",width:"7",height:"7"}),t.jsx("rect",{x:"14",y:"3",width:"7",height:"7"}),t.jsx("rect",{x:"14",y:"14",width:"7",height:"7"}),t.jsx("rect",{x:"3",y:"14",width:"7",height:"7"})]}),"Add Agent"]}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5 pl-[18px]",children:"Create from templates"})]}),t.jsxs("button",{onClick:()=>{K(!1),V(!0)},className:"w-full text-left px-4 py-2.5 text-xs text-brand-500 hover:bg-surface-elevated border-t border-border-default transition-colors",children:[t.jsxs("div",{className:"font-medium flex items-center gap-1.5",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M21 12a9 9 0 0 1-9 9m9-9a9 9 0 0 0-9-9m9 9H3m9 9a9 9 0 0 1-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 0 1 9-9"})}),"Import OpenClaw"]}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5 pl-[18px]",children:"Connect an external agent"})]}),t.jsxs("button",{onClick:()=>{K(!1),D({})},className:"w-full text-left px-4 py-2.5 text-xs text-green-600 hover:bg-surface-elevated border-t border-border-default transition-colors",children:[t.jsxs("div",{className:"font-medium flex items-center gap-1.5",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"8.5",cy:"7",r:"4"}),t.jsx("line",{x1:"20",y1:"8",x2:"20",y2:"14"}),t.jsx("line",{x1:"23",y1:"11",x2:"17",y2:"11"})]}),"Add Human"]}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5 pl-[18px]",children:"Add a human team member"})]})]})]})}),t.jsxs("div",{className:"flex-1 overflow-y-auto px-3 py-2 flex flex-col",children:[r.length===0&&s.length===0&&t.jsx("p",{className:"text-xs text-fg-tertiary px-1 mb-2",children:"No agents yet"}),Ct.unmatched.map(de=>t.jsxs("button",{onClick:()=>p(de.channelKey),className:`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-xs mb-0.5 transition-colors ${h==="channel"&&f===de.channelKey?"bg-brand-600/20 text-brand-500":"text-fg-secondary hover:bg-surface-elevated"}`,children:[t.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center shrink-0 ${h==="channel"&&f===de.channelKey?"bg-brand-600 text-white":"bg-surface-overlay text-fg-secondary"}`,children:t.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),t.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[t.jsx("span",{className:"truncate font-medium text-[11px] leading-tight block",children:de.name}),t.jsx("div",{className:"text-[10px] text-fg-tertiary leading-tight mt-0.5",children:"Group Chat"})]}),de.memberCount!==void 0&&de.memberCount>0&&t.jsx("span",{className:"text-[9px] text-fg-tertiary shrink-0",children:de.memberCount})]},de.id)),s.map(de=>{const Be=Nt.byTeam.get(de.id)??[];return Be.length===0&&(!de.members||de.members.length===0)?null:en(de.id,de,Be,de.name)}),s.filter(de=>(Nt.byTeam.get(de.id)??[]).length===0&&de.members&&de.members.length>0).map(de=>en(de.id,de,[],de.name)),Nt.ungrouped.length>0&&en("_ungrouped",null,Nt.ungrouped,"Other"),s.length===0&&r.length>0&&r.map(de=>Wt(de)),t.jsxs("div",{className:"mt-3 pt-2 border-t border-border-default/60",children:[t.jsx("p",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2",children:"People"}),e&&t.jsxs("button",{onClick:()=>y(e.id),className:`w-full flex items-center gap-2.5 px-2 py-1.5 rounded-lg text-xs mb-0.5 transition-colors ${h==="dm"&&(x===e.id||!x)?"bg-brand-600/20 text-brand-500":"text-fg-secondary hover:bg-surface-elevated"}`,children:[t.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-bold shrink-0 ${h==="dm"&&(x===e.id||!x)?"bg-brand-600 text-white":"bg-brand-500/15 text-brand-500"}`,children:e.name[0]?.toUpperCase()}),t.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[t.jsx("div",{className:"truncate font-medium text-[11px] leading-tight",children:e.name}),t.jsx("div",{className:"text-fg-tertiary truncate text-[10px] leading-tight mt-0.5",children:"My Notes"})]}),t.jsx("span",{className:"text-fg-tertiary shrink-0",children:t.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})})]}),l.filter(de=>de.id!==e?.id).map(de=>t.jsxs("button",{onClick:()=>y(de.id),className:`w-full flex items-center gap-2.5 px-2 py-1.5 rounded-lg text-xs mb-0.5 transition-colors ${h==="dm"&&x===de.id?"bg-green-500/10 text-green-600":"text-fg-secondary hover:bg-surface-elevated"}`,children:[t.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-bold shrink-0 ${h==="dm"&&x===de.id?"bg-green-600 text-white":"bg-green-500/10 text-green-600"}`,children:de.name[0]?.toUpperCase()}),t.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[t.jsx("div",{className:"truncate font-medium text-[11px] leading-tight",children:de.name}),t.jsx("div",{className:"text-fg-tertiary truncate text-[10px] leading-tight mt-0.5",children:de.email||de.role})]}),t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 shrink-0"})]},de.id))]})]})]}),C&&t.jsx("div",{className:"w-1 cursor-col-resize shrink-0 group relative",onMouseDown:C,children:t.jsx("div",{className:"absolute inset-y-0 -left-0.5 -right-0.5 group-hover:bg-brand-500/30 group-active:bg-brand-500/50 transition-colors"})}),J&&(()=>{const de=Nt.byTeam.get(J.teamId)??[],Be=de.some(ft=>ft.status==="offline"),Le=de.some(ft=>ft.status==="idle"||ft.status==="working"),ot=de.some(ft=>ft.status==="paused"),Qe=de.some(ft=>ft.status!=="offline");return t.jsxs("div",{ref:we,className:"fixed bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 z-50 w-44",style:{left:J.x,top:J.y},onClick:ft=>ft.stopPropagation(),children:[t.jsxs("button",{onClick:()=>{const ft=vt.get(J.teamId);ft&&(Ze(J.teamId),dn(ft.name)),U(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),"Rename Team"]}),Be&&t.jsxs("button",{onClick:()=>{Yt(J.teamId,"start"),U(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-green-600 flex items-center gap-2",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),"Start All"]}),Qe&&t.jsxs("button",{onClick:()=>{Yt(J.teamId,"stop"),U(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),"Stop All"]}),Le&&t.jsxs("button",{onClick:()=>{Yt(J.teamId,"pause"),U(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-amber-600 flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:[t.jsx("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1"}),t.jsx("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1"})]}),"Pause All"]}),ot&&t.jsxs("button",{onClick:()=>{Yt(J.teamId,"resume"),U(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-blue-600 flex items-center gap-2",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),"Resume All"]}),t.jsx("div",{className:"border-t border-border-default/50 my-1"}),t.jsxs("button",{onClick:()=>{U(null),jt.navigate("agents")},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-brand-500 flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),t.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Add Agent"]}),t.jsxs("button",{onClick:()=>{U(null),D({teamId:J.teamId})},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-green-600 flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"8.5",cy:"7",r:"4"}),t.jsx("line",{x1:"20",y1:"8",x2:"20",y2:"14"}),t.jsx("line",{x1:"23",y1:"11",x2:"17",y2:"11"})]}),"Add Human"]}),G.length>0&&t.jsxs("button",{onClick:()=>{U(null),_(J.teamId)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"8.5",cy:"7",r:"4"}),t.jsx("polyline",{points:"17 11 19 13 23 9"})]}),"Add Existing"]}),t.jsx("div",{className:"border-t border-border-default/50 my-1"}),t.jsxs("button",{onClick:()=>{const ft=vt.get(J.teamId);ft&&zt(J.teamId,ft.name),U(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),"Delete Team"]})]})})(),H&&(()=>{const de=r.find(Qe=>Qe.id===H.agentId);if(!de)return null;const Le=(H.teamId?vt.get(H.teamId):void 0)?.managerId===de.id,ot=de.id===e?.id;return t.jsxs("div",{ref:we,className:"fixed bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 z-50 w-44",style:{left:H.x,top:H.y},onClick:Qe=>Qe.stopPropagation(),children:[t.jsxs("button",{onClick:()=>{X(null),E(de.id)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-brand-500 flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"12",cy:"7",r:"4"})]}),"View Profile"]}),de.status==="offline"?t.jsxs("button",{onClick:()=>{qt(de.id,"offline"),X(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-green-600 flex items-center gap-2",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),"Start"]}):t.jsxs("button",{onClick:()=>{qt(de.id,de.status??"idle"),X(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),"Stop"]}),H.teamId&&!Le&&t.jsxs("button",{onClick:()=>{Lt(H.teamId,de.id,"agent"),X(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-amber-600 flex items-center gap-2",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),"Set as Manager"]}),H.teamId&&t.jsxs("button",{onClick:()=>{yt(H.teamId,de.id),X(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"9 14 4 9 9 4"}),t.jsx("path",{d:"M20 20v-7a4 4 0 0 0-4-4H4"})]}),"Remove from team"]}),s.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border-t border-border-default/50 my-1"}),t.jsxs("div",{className:"px-3 py-1 text-[10px] text-fg-tertiary uppercase flex items-center gap-1.5",children:[t.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5 12h14"}),t.jsx("path",{d:"M12 5l7 7-7 7"})]}),"Move to"]}),s.filter(Qe=>Qe.id!==H.teamId).map(Qe=>t.jsx("button",{onClick:async()=>{H.teamId&&await re.teams.removeMember(H.teamId,de.id),await re.teams.addMember(Qe.id,de.id,"agent"),w(),N(),nt(),X(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary pl-7",children:Qe.name},Qe.id))]}),t.jsx("div",{className:"border-t border-border-default/50 my-1"}),!ot&&t.jsxs("button",{onClick:()=>{sn(de.id,de.name),X(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),"Remove from org"]})]})})(),F&&t.jsx(zT,{onClose:()=>B(!1),onCreate:async(de,Be)=>{await re.teams.create(de,Be),B(!1),w()}}),T!==null&&t.jsx(IT,{teamId:T.teamId,teams:s,onClose:()=>D(null),onAdd:async(de,Be,Le,ot,Qe)=>{await re.users.create(de,Be,void 0,Le,ot,Qe),D(null),w()}}),z!==null&&t.jsx($T,{teamId:z,ungrouped:G,onClose:()=>_(null),onAdd:async(de,Be)=>{await re.teams.addMember(z,de,Be),_(null),w(),nt()}}),Y&&t.jsx(BT,{onClose:()=>V(!1),onConnected:()=>{V(!1),N(),w()}}),ke&&t.jsx(jj,{title:ke.title,message:ke.message,confirmLabel:ke.confirmLabel,checkboxes:ke.checkboxes,onConfirm:de=>{ke.onConfirm(de),De(null)},onCancel:()=>De(null)}),te&&t.jsx("div",{className:`fixed bottom-6 left-1/2 -translate-x-1/2 z-50 px-4 py-2.5 rounded-lg shadow-xl text-sm font-medium ${te.type==="error"?"bg-red-500/10 text-red-500 border border-red-500/30":"bg-surface-elevated/95 text-fg-primary border border-border-default/50"}`,children:te.message})]})}const UT=[{key:"overview",label:"Overview",icon:"▦"},{key:"activity",label:"Activity",icon:"⏱"},{key:"files",label:"Files",icon:"📄"},{key:"tools",label:"Tools",icon:"⚒"},{key:"skills",label:"Skills",icon:"◆"},{key:"memory",label:"Memory",icon:"🧠"},{key:"heartbeat",label:"Heartbeat",icon:"♡"}],qT={idle:"bg-green-400",working:"bg-brand-400 animate-pulse",paused:"bg-amber-400",offline:"bg-gray-500",error:"bg-red-400"};function xd(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString()}function FT({agentId:e,onBack:r,inline:s}){const[l,o]=v.useState(null),[d,c]=v.useState("overview"),[h,m]=v.useState(null),f=v.useCallback(()=>{re.agents.get(e).then(o).catch(()=>{})},[e]);if(v.useEffect(()=>(c("overview"),m(null),f(),re.externalAgents.list().then(p=>{const y=p.agents.find(w=>w.markusAgentId===e);m(y??null)}).catch(()=>{}),kn.on("agent:update",p=>{p.payload.agentId===e&&f()})),[e,f]),!l)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm",children:"Loading agent..."});const x=qT[l.state.status]??"bg-gray-500";return t.jsxs("div",{className:"flex-1 overflow-y-auto bg-surface-primary",children:[t.jsxs("div",{className:"px-5 py-3.5 border-b border-border-default bg-surface-secondary sticky top-0 z-10",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-xl bg-brand-600 text-white flex items-center justify-center text-lg font-bold shrink-0",children:l.name.charAt(0)}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("h2",{className:"text-base font-semibold",children:l.name}),t.jsx("span",{className:`w-2 h-2 rounded-full ${x}`}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:l.state.status}),h&&t.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-brand-500/15 text-brand-500 rounded font-medium",children:"External"}),l.agentRole==="manager"&&t.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-amber-500/15 text-amber-600 rounded font-medium",children:"Manager"})]}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[l.role,l.roleDescription?` — ${l.roleDescription}`:""]})]}),t.jsxs("div",{className:"flex gap-1.5 shrink-0",children:[t.jsxs("button",{onClick:()=>jt.navigate("chat",{agentId:e}),className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors flex items-center gap-1",children:[t.jsx("span",{children:"◈"})," Chat"]}),t.jsxs("button",{onClick:async()=>{if(l)try{const{filesMap:g}=await re.agents.getFilesMap(e),p={type:"agent",name:l.name.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"")||l.name,displayName:l.name,version:"1.0.0",description:l.roleDescription??l.role,author:"",category:"general",tags:[],agent:{roleName:l.role,agentRole:l.agentRole},dependencies:{skills:l.skills??[]}};await Un.publishViaProxy({itemType:"agent",name:l.name,description:p.description,category:"general",config:p,files:g}),alert(`Published "${l.name}" to Markus Hub`)}catch(g){alert(`Failed to publish: ${g}`)}},className:"px-3 py-1.5 text-xs bg-green-600 hover:bg-green-500 text-white rounded-lg transition-colors flex items-center gap-1",title:"Publish to Markus Hub",children:[t.jsx("span",{children:"↑"})," Hub"]}),s&&t.jsx("button",{onClick:r,className:"p-1.5 text-fg-tertiary hover:text-fg-secondary text-lg leading-none",children:"×"})]})]}),t.jsx("div",{className:"flex gap-1 mt-3 -mb-[1px] overflow-x-auto",children:UT.filter(g=>!h||["overview","activity"].includes(g.key)).map(g=>t.jsxs("button",{onClick:()=>c(g.key),className:`px-3 py-1.5 text-xs rounded-t-lg border border-b-0 transition-colors whitespace-nowrap ${d===g.key?"bg-surface-primary text-fg-primary border-border-default":"text-fg-tertiary border-transparent hover:text-fg-secondary hover:bg-surface-elevated/50"}`,children:[t.jsx("span",{className:"mr-1",children:g.icon}),g.label]},g.key))})]}),t.jsxs("div",{className:"p-5",children:[d==="overview"&&t.jsx(VT,{agent:l,onUpdate:f,externalInfo:h}),d==="activity"&&t.jsx(tA,{agentId:e}),d==="files"&&t.jsx(YT,{agentId:e}),d==="tools"&&t.jsx(ZT,{tools:l.tools??[]}),d==="skills"&&t.jsx(QT,{agent:l}),d==="memory"&&t.jsx(KT,{agentId:e}),d==="heartbeat"&&t.jsx(JT,{agentId:e,initialData:l.heartbeat})]})]})}function VT({agent:e,onUpdate:r,externalInfo:s}){const[l,o]=v.useState(!1),[d,c]=v.useState(e.name),[h,m]=v.useState(e.agentRole),[f,x]=v.useState(e.config?.llmConfig?.modelMode??"default"),[g,p]=v.useState(e.config?.llmConfig.primary??""),[y,w]=v.useState(e.config?.llmConfig.fallback??""),[N,E]=v.useState(!1),[A,C]=v.useState({}),[k,S]=v.useState(""),[O,R]=v.useState([]),[G,I]=v.useState(null),[Q,$]=v.useState(null),[F,B]=v.useState([]),[T,D]=v.useState(null),[z,_]=v.useState(null),[Y,V]=v.useState("");v.useEffect(()=>{re.settings.getLlm().then(M=>{C(M.providers),S(M.defaultProvider)}).catch(()=>{}),re.tasks.list({assignedAgentId:e.id}).then(M=>R(M.tasks.slice(0,5))).catch(()=>{}),re.usage.agents().then(M=>{const q=M.agents.find(K=>K.agentId===e.id);q&&I(q)}).catch(()=>{}),re.agents.getRecentActivities(e.id).then(M=>B(M.activities)).catch(()=>{}),re.system.storage().then(M=>{V(M.dataDir+"/agents/"+e.id);const q=M.agents.find(K=>K.id===e.id);q&&_(q)}).catch(()=>{})},[e.id]);const J=Object.entries(A).filter(([,M])=>M.configured).map(([M])=>M),U=e.config?.llmConfig?.modelMode??"default",H=async()=>{E(!0);try{await re.agents.updateConfig(e.id,{name:d,agentRole:h,llmConfig:{modelMode:f,primary:f==="custom"?g:k,fallback:y||void 0}}),r(),o(!1)}catch{}E(!1)},X=()=>{e.state.status==="offline"?re.agents.start(e.id).then(r):re.agents.stop(e.id).then(r)},L={pending:"bg-gray-400",assigned:"bg-blue-400",in_progress:"bg-brand-400",completed:"bg-green-400",failed:"bg-red-400",cancelled:"bg-gray-600"};if(s){const M=[{method:"POST",path:"/api/gateway/sync",desc:"Exchange status, tasks, messages, team & project context"},{method:"GET",path:"/api/gateway/manual",desc:"Download integration handbook (dynamic, includes colleagues & projects)"},{method:"GET",path:"/api/gateway/team",desc:"Query team members, roles, and manager"},{method:"GET",path:"/api/gateway/projects",desc:"List projects with governance"},{method:"GET",path:"/api/gateway/requirements",desc:"Query requirements (filter by project/status)"}],q=[{field:"assignedTasks",desc:"Tasks with requirement & project traceability"},{field:"inboxMessages",desc:"Messages from teammates"},{field:"teamContext",desc:"Colleagues (id, name, role, status) + manager"},{field:"projectContext",desc:"Projects and active requirements"}];return t.jsxs("div",{className:"space-y-4",children:[t.jsx(jn,{title:"Identity",children:t.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:[t.jsx(zn,{label:"Name",children:e.name}),t.jsx(zn,{label:"Agent Role",children:t.jsx("span",{className:e.agentRole==="manager"?"text-amber-600":"text-blue-600",children:e.agentRole==="manager"?"★ Manager":"◆ Worker"})}),t.jsx(zn,{label:"Role Template",children:e.role}),t.jsx(zn,{label:"Markus Agent ID",mono:!0,children:e.id}),t.jsx(zn,{label:"Organization",children:e.config?.orgId??"default"}),t.jsx(zn,{label:"Created",children:e.config?.createdAt?new Date(e.config.createdAt).toLocaleDateString():"—"})]})}),t.jsx(jn,{title:"Connection Status",children:t.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[t.jsx(Yn,{label:"Connection",value:s.connected?"Online":"Offline",color:s.connected?"green":"gray"}),t.jsx(Yn,{label:"Platform",value:"OpenClaw"}),t.jsx(Yn,{label:"Active Tasks",value:String(e.state.activeTaskIds?.length??0)}),t.jsx(Yn,{label:"Last Sync",value:s.lastHeartbeat?new Date(s.lastHeartbeat).toLocaleTimeString():"Never"})]})}),t.jsx(jn,{title:"External Agent Details",children:t.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:[t.jsx(zn,{label:"External Agent ID",mono:!0,children:s.externalAgentId}),t.jsx(zn,{label:"Registered",children:new Date(s.registeredAt).toLocaleString()}),t.jsx(zn,{label:"Capabilities",children:s.capabilities.length>0?s.capabilities.join(", "):"none declared"}),t.jsx(zn,{label:"Last Heartbeat",children:s.lastHeartbeat?new Date(s.lastHeartbeat).toLocaleString():"Never"})]})}),t.jsx(jn,{title:"Sync Context (received every sync cycle)",children:t.jsx("div",{className:"space-y-1.5",children:q.map(K=>t.jsxs("div",{className:"flex items-start gap-2.5 px-3 py-2 rounded-lg bg-surface-elevated/30 border border-border-default/30",children:[t.jsx("span",{className:"font-mono text-[10px] text-brand-500 shrink-0 pt-0.5",children:K.field}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:K.desc})]},K.field))})}),t.jsx(jn,{title:"Gateway API Endpoints",children:t.jsx("div",{className:"space-y-1.5",children:M.map(K=>t.jsxs("div",{className:"flex items-start gap-2.5 px-3 py-2 rounded-lg bg-surface-elevated/30 border border-border-default/30",children:[t.jsx("span",{className:`text-[10px] font-semibold shrink-0 pt-0.5 ${K.method==="POST"?"text-amber-600":"text-green-600"}`,children:K.method}),t.jsx("span",{className:"font-mono text-[10px] text-fg-secondary shrink-0 pt-0.5",children:K.path}),t.jsx("span",{className:"text-[10px] text-fg-tertiary ml-auto",children:K.desc})]},K.path))})}),O.length>0&&t.jsx(jn,{title:"Recent Tasks",action:t.jsx("button",{onClick:()=>jt.navigate("projects"),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"View all →"}),children:t.jsx("div",{className:"divide-y divide-gray-800/50 -mx-5",children:O.map(K=>t.jsxs("div",{className:"flex items-center gap-2.5 px-5 py-2.5",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${L[K.status]??"bg-gray-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:K.title}),t.jsx("span",{className:"text-[10px] text-fg-tertiary capitalize shrink-0",children:K.status.replace(/_/g," ")})]},K.id))})})]})}return t.jsxs("div",{className:"space-y-4",children:[t.jsx(jn,{title:"Identity",action:l?t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>o(!1),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Cancel"}),t.jsx("button",{onClick:H,disabled:N,className:"text-xs text-brand-500 hover:text-brand-500",children:N?"Saving...":"Save"})]}):t.jsx("button",{onClick:()=>{o(!0),c(e.name),m(e.agentRole),x(e.config?.llmConfig?.modelMode??"default"),p(e.config?.llmConfig.primary??""),w(e.config?.llmConfig.fallback??"")},className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Edit"}),children:t.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:[t.jsx(zn,{label:"Name",children:l?t.jsx("input",{className:"input-sm",value:d,onChange:M=>c(M.target.value)}):e.name}),t.jsx(zn,{label:"Agent Role",children:l?t.jsx("div",{className:"flex gap-1.5",children:["worker","manager"].map(M=>t.jsx("button",{onClick:()=>m(M),className:`px-2 py-1 text-[10px] rounded border transition-colors capitalize ${h===M?M==="manager"?"bg-amber-500/15 text-amber-600 border-amber-500/30":"bg-blue-500/15 text-blue-600 border-blue-500/30":"bg-surface-elevated text-fg-tertiary border-border-default"}`,children:M},M))}):t.jsx("span",{className:e.agentRole==="manager"?"text-amber-600":"text-blue-600",children:e.agentRole==="manager"?"★ Manager":"◆ Worker"})}),t.jsx(zn,{label:"Role Template",children:e.role}),t.jsx(zn,{label:"Agent ID",mono:!0,children:e.id}),t.jsx(zn,{label:"Organization",children:e.config?.orgId??"default"}),t.jsx(zn,{label:"Created",children:e.config?.createdAt?new Date(e.config.createdAt).toLocaleDateString():"—"})]})}),t.jsxs(jn,{title:"Runtime Status",children:[t.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[t.jsx(Yn,{label:"Status",value:e.state.status,color:e.state.status==="idle"?"green":e.state.status==="working"?"indigo":e.state.status==="error"?"red":"gray"}),t.jsx(Yn,{label:"Tokens Today",value:String(e.state.tokensUsedToday)}),t.jsx(Yn,{label:"Active Tasks",value:String(e.state.activeTaskIds?.length??0)}),t.jsx(Yn,{label:"Last Heartbeat",value:e.state.lastHeartbeat?new Date(e.state.lastHeartbeat).toLocaleTimeString():"Never"})]}),e.state.status==="error"&&t.jsxs("div",{className:"mt-3 bg-red-500/10 border border-red-500/20 rounded-lg p-3",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[t.jsx("span",{className:"w-2 h-2 rounded-full bg-red-500 animate-pulse"}),t.jsx("span",{className:"text-xs font-medium text-red-500",children:"Error Details"}),e.state.lastErrorAt&&t.jsx("span",{className:"text-[10px] text-red-500/50 ml-auto",children:new Date(e.state.lastErrorAt).toLocaleString()})]}),t.jsx("pre",{className:"text-[11px] text-red-500/80 leading-relaxed whitespace-pre-wrap break-all font-mono bg-red-500/5 rounded p-2",children:e.state.lastError||"Agent encountered an error. Check logs for more details."})]}),e.state.status==="working"&&(e.state.activeTaskIds?.length??0)>0&&t.jsxs("div",{className:"mt-3 bg-brand-500/10 border border-brand-500/20 rounded-lg p-3",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[t.jsx("span",{className:"w-2 h-2 rounded-full bg-brand-400 animate-pulse"}),t.jsx("span",{className:"text-xs font-medium text-brand-500",children:"Currently Working"}),t.jsxs("span",{className:"text-[10px] text-brand-500/50 ml-auto",children:[e.state.activeTaskIds.length," active task",e.state.activeTaskIds.length>1?"s":""]})]}),t.jsx("div",{className:"space-y-1",children:O.filter(M=>e.state.activeTaskIds?.includes(M.id)).map(M=>t.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-400 animate-pulse shrink-0"}),t.jsx("span",{className:"text-fg-secondary truncate flex-1",children:M.title}),t.jsx("span",{className:"text-fg-tertiary capitalize shrink-0",children:M.status.replace(/_/g," ")})]},M.id))})]}),t.jsx("div",{className:"flex gap-2 mt-4 pt-3 border-t border-border-default/50",children:t.jsx("button",{onClick:X,className:"px-3 py-1.5 text-xs border border-border-default rounded-lg hover:border-brand-500 transition-colors",children:e.state.status==="offline"?"▶ Start":"⏹ Stop"})})]}),G&&t.jsx(jn,{title:"Usage",children:t.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[t.jsx(Yn,{label:"Total Tokens",value:xd(G.totalTokens)}),t.jsx(Yn,{label:"Requests",value:String(G.requestCount)}),t.jsx(Yn,{label:"Tool Calls",value:String(G.toolCalls)}),t.jsx(Yn,{label:"Prompt Tokens",value:xd(G.promptTokens)}),t.jsx(Yn,{label:"Completion Tokens",value:xd(G.completionTokens)}),t.jsx(Yn,{label:"Est. Cost",value:`$${G.estimatedCost<.01?G.estimatedCost.toFixed(4):G.estimatedCost.toFixed(2)}`})]})}),z&&t.jsxs(jn,{title:"Storage",action:t.jsx("button",{onClick:()=>{re.system.openPath(Y)},className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Open folder →"}),children:[t.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[t.jsx("span",{className:"text-lg font-bold text-fg-primary",children:py(z.size)}),t.jsx("span",{className:"text-xs text-fg-tertiary font-mono truncate",children:Y})]}),t.jsx("div",{className:"grid grid-cols-3 gap-3",children:z.subItems.filter(M=>M.size>0).map(M=>t.jsx(Yn,{label:M.name,value:py(M.size)},M.name))})]}),t.jsx(jn,{title:"LLM Configuration",children:t.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:[t.jsx(zn,{label:"Model Mode",children:l?t.jsx("div",{className:"flex gap-1.5",children:["default","custom"].map(M=>t.jsx("button",{onClick:()=>x(M),className:`px-2.5 py-1 text-[10px] rounded border transition-colors capitalize ${f===M?M==="default"?"bg-brand-500/15 text-brand-500 border-brand-500/30":"bg-amber-500/15 text-amber-600 border-amber-500/30":"bg-surface-elevated text-fg-tertiary border-border-default"}`,children:M==="default"?"System Default":"Custom"},M))}):t.jsx("span",{className:`text-xs ${U==="custom"?"text-amber-600":"text-brand-500"}`,children:U==="custom"?"⚙ Custom":"◎ System Default"})}),t.jsx(zn,{label:"Primary Model",children:l?f==="custom"?t.jsxs("select",{className:"input-sm",value:g,onChange:M=>p(M.target.value),children:[J.map(M=>t.jsxs("option",{value:M,children:[M," (",A[M]?.model,")"]},M)),!J.includes(g)&&g&&t.jsx("option",{value:g,children:g})]}):t.jsxs("span",{className:"text-xs text-fg-secondary italic",children:["follows system default (",k||"...",")"]}):t.jsx("span",{className:"font-mono text-xs",children:U==="custom"?e.config?.llmConfig.primary??"—":t.jsxs("span",{className:"text-fg-secondary",children:[k||e.config?.llmConfig.primary||"—"," ",t.jsx("span",{className:"text-fg-tertiary",children:"(system default)"})]})})}),t.jsx(zn,{label:"Fallback",children:l?t.jsxs("select",{className:"input-sm",value:y,onChange:M=>w(M.target.value),children:[t.jsx("option",{value:"",children:"none"}),J.map(M=>t.jsx("option",{value:M,children:M},M))]}):t.jsx("span",{className:"font-mono text-xs",children:e.config?.llmConfig.fallback??"none"})}),t.jsx(zn,{label:"Max Tokens/Request",children:e.config?.llmConfig.maxTokensPerRequest??"default"}),t.jsx(zn,{label:"Max Tokens/Day",children:e.config?.llmConfig.maxTokensPerDay??"unlimited"})]})}),O.length>0&&t.jsx(jn,{title:"Recent Tasks",action:t.jsx("button",{onClick:()=>jt.navigate("projects"),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"View all →"}),children:t.jsx("div",{className:"divide-y divide-gray-800/50 -mx-5",children:O.map(M=>{const q=Q===M.id,K=["in_progress","failed","completed","review"].includes(M.status);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>K?$(q?null:M.id):void 0,className:`w-full flex items-center gap-2.5 px-5 py-2.5 text-left transition-colors ${K?"hover:bg-surface-elevated/40 cursor-pointer":"cursor-default"}`,children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${L[M.status]??"bg-gray-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:M.title}),t.jsx("span",{className:"text-[10px] text-fg-tertiary capitalize shrink-0",children:M.status.replace(/_/g," ")}),K&&t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:q?"▲":"▼"})]}),q&&t.jsx("div",{className:"border-t border-border-default/60 bg-surface-primary/40",children:t.jsx(wj,{taskId:M.id,isLive:M.status==="in_progress"})})]},M.id)})})}),F.filter(M=>M.type==="heartbeat").length>0&&t.jsx(jn,{title:"Recent Heartbeats",action:t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[F.filter(M=>M.type==="heartbeat").length," runs"]}),children:t.jsx("div",{className:"divide-y divide-gray-800/50 -mx-5",children:F.filter(M=>M.type==="heartbeat").map(M=>{const q=T===M.id;return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>D(q?null:M.id),className:"w-full flex items-center gap-2.5 px-5 py-2.5 text-left transition-colors hover:bg-surface-elevated/40 cursor-pointer",children:[t.jsx("span",{className:"w-2 h-2 rounded-full shrink-0 bg-green-400"}),t.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:M.label}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date(M.startedAt).toLocaleString()}),t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:q?"▲":"▼"})]}),q&&t.jsx("div",{className:"border-t border-border-default/60 bg-surface-primary/40",children:t.jsx(_d,{agentId:e.id,activityId:M.id})})]},M.id)})})}),F.filter(M=>M.type==="chat").length>0&&t.jsx(jn,{title:"Recent A2A Communications",action:t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[F.filter(M=>M.type==="chat").length," conversations"]}),children:t.jsx("div",{className:"divide-y divide-gray-800/50 -mx-5",children:F.filter(M=>M.type==="chat").map(M=>{const q=T===M.id;return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>D(q?null:M.id),className:"w-full flex items-center gap-2.5 px-5 py-2.5 text-left transition-colors hover:bg-surface-elevated/40 cursor-pointer",children:[t.jsx("span",{className:"w-2 h-2 rounded-full shrink-0 bg-blue-400"}),t.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:M.label}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date(M.startedAt).toLocaleString()}),t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:q?"▲":"▼"})]}),q&&t.jsx("div",{className:"border-t border-border-default/60 bg-surface-primary/40",children:t.jsx(_d,{agentId:e.id,activityId:M.id})})]},M.id)})})})]})}function YT({agentId:e}){const[r,s]=v.useState([]),[l,o]=v.useState(!0),[d,c]=v.useState(null),[h,m]=v.useState(""),[f,x]=v.useState(!1),[g,p]=v.useState(!1),[y,w]=v.useState(null),[N,E]=v.useState(!1),[A,C]=v.useState(null),k=v.useCallback(()=>{o(!0),Promise.all([re.agents.getFiles(e),re.agents.roleStatus(e).catch(()=>null)]).then(([B,T])=>{s(B.files),w(T),B.files.length>0&&!d&&(c(B.files[0].name),m(B.files[0].content))}).catch(()=>{}).finally(()=>o(!1))},[e]);v.useEffect(()=>{k()},[k]);const S=B=>{const T=r.find(D=>D.name===B);T&&(c(B),m(T.content),p(!1),C(null))},O=async()=>{if(d){x(!0);try{await re.agents.updateFile(e,d,h),s(B=>B.map(T=>T.name===d?{...T,content:h}:T)),p(!1),d==="ROLE.md"&&await re.agents.updateSystemPrompt(e,h)}catch{}x(!1)}},R=async B=>{E(!0);try{await re.agents.roleSync(e,B?[B]:void 0),C(null),p(!1),k()}catch{}E(!1)},G=async B=>{if(A?.file===B){C(null);return}try{const T=await re.agents.roleDiff(e,B);T.agentContent!=null&&T.templateContent!=null&&C({file:B,agent:T.agentContent,template:T.templateContent})}catch{}};if(l)return t.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:"Loading files..."});const I={"ROLE.md":"System Prompt / Role Definition","HEARTBEAT.md":"Heartbeat Tasks","POLICIES.md":"Policies & Guardrails","CONTEXT.md":"Context & Instructions"},Q=y?.files.filter(B=>B.status==="modified"||B.status==="added_in_template")??[],$=y?.hasTemplate&&!y.isUpToDate,F=d?Q.some(B=>B.file===d):!1;return t.jsxs("div",{className:"space-y-4",children:[$&&t.jsxs("div",{className:"bg-amber-500/8 border border-amber-500/25 rounded-xl p-4 flex items-start gap-3",children:[t.jsx("span",{className:"text-amber-600 text-sm mt-0.5",children:"↻"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs text-amber-600 font-medium",children:"Template Update Available"}),t.jsxs("div",{className:"text-[11px] text-amber-600/70 mt-0.5",children:[Q.length," file",Q.length>1?"s":""," differ from the ",t.jsx("code",{className:"px-1 py-0.5 bg-amber-500/10 rounded text-amber-600",children:y.templateId})," template:"," ",Q.map(B=>B.file).join(", ")]})]}),t.jsx("button",{onClick:()=>R(),disabled:N,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors shrink-0 disabled:opacity-50",children:N?"Syncing...":"Sync All"})]}),t.jsxs(jn,{title:"Agent Configuration Files",action:y?.hasTemplate?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`inline-block w-1.5 h-1.5 rounded-full ${y.isUpToDate?"bg-green-400":"bg-amber-400"}`}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["Template: ",t.jsx("span",{className:"text-fg-secondary",children:y.templateId}),y.isUpToDate?" (up to date)":" (updates available)"]})]}):t.jsx("div",{className:"text-[10px] text-fg-tertiary",children:"Custom agent — no linked template"}),children:[t.jsx("div",{className:"flex gap-2 mb-4 flex-wrap",children:r.map(B=>{const T=Q.some(D=>D.file===B.name);return t.jsxs("button",{onClick:()=>S(B.name),className:`px-3 py-1.5 text-xs rounded-lg border transition-colors relative ${d===B.name?"bg-brand-600/15 border-brand-500/40 text-brand-500":"border-border-default text-fg-tertiary hover:text-fg-secondary"}`,children:[B.name,T&&t.jsx("span",{className:"absolute -top-1 -right-1 w-2 h-2 bg-amber-400 rounded-full"})]},B.name)})}),d&&t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("div",{className:"text-xs text-fg-secondary",children:I[d]??d}),t.jsxs("div",{className:"flex gap-2 items-center",children:[F&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>G(d),className:"px-2.5 py-1 text-[11px] text-amber-600 hover:text-amber-600 border border-amber-500/30 hover:border-amber-500/50 rounded-lg transition-colors",children:A?.file===d?"Hide Diff":"View Diff"}),t.jsx("button",{onClick:()=>R(d),disabled:N,className:"px-2.5 py-1 text-[11px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:N?"Syncing...":"Sync This File"})]}),g&&t.jsx("span",{className:"text-[10px] text-amber-600",children:"unsaved"}),t.jsx("button",{onClick:O,disabled:f||!g,className:`px-3 py-1 text-xs rounded-lg transition-colors ${g?"bg-brand-600 hover:bg-brand-500 text-white":"bg-surface-elevated text-fg-tertiary cursor-default"}`,children:f?"Saving...":"Save"})]})]}),A?.file===d&&t.jsxs("div",{className:"mb-3 border border-border-default rounded-lg overflow-hidden",children:[t.jsxs("div",{className:"grid grid-cols-2 text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider bg-surface-elevated/80",children:[t.jsx("div",{className:"px-3 py-2 border-r border-border-default",children:"Current (Agent)"}),t.jsxs("div",{className:"px-3 py-2",children:["Template (",y?.templateId,")"]})]}),t.jsxs("div",{className:"grid grid-cols-2 max-h-60 overflow-y-auto",children:[t.jsx("pre",{className:"px-3 py-2 text-[11px] font-mono text-red-500/70 bg-red-500/5 border-r border-border-default whitespace-pre-wrap break-words overflow-x-hidden",children:A.agent}),t.jsx("pre",{className:"px-3 py-2 text-[11px] font-mono text-green-600/70 bg-green-500/5 whitespace-pre-wrap break-words overflow-x-hidden",children:A.template})]})]}),t.jsx("textarea",{value:h,onChange:B=>{m(B.target.value),p(!0)},className:"w-full h-80 bg-surface-elevated/60 border border-border-default rounded-lg p-4 text-xs font-mono text-fg-secondary leading-relaxed resize-y focus:border-brand-500 outline-none",spellCheck:!1}),d==="ROLE.md"&&t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-2",children:"Changes to ROLE.md will update the agent's runtime system prompt immediately."})]}),r.length===0&&t.jsx(Yl,{text:"No configuration files found for this role"})]})]})}const GT={Files:["file_read","file_write","file_edit","apply_patch"],Search:["grep_search","glob_find","list_directory"],Runtime:["shell_execute","background_exec","process"],Web:["web_search","web_fetch","web_extract"],Tasks:["task_create","task_list","task_update","task_get","task_assign","task_note","task_comment","task_submit_review","subtask_create","subtask_complete","subtask_list","task_check_duplicates","task_cleanup_duplicates","task_board_health"],Requirements:["requirement_propose","requirement_list","requirement_update_status","requirement_comment"],Projects:["list_projects","get_project","project_info"],Deliverables:["deliverable_create","deliverable_search","deliverable_list","deliverable_update"],Communication:["agent_send_message","agent_list_colleagues","agent_send_group_message","agent_create_group_chat","agent_list_group_chats","agent_broadcast_status","agent_delegate_task"],Memory:["memory_save","memory_search","memory_list","memory_update_longterm"],Planning:["todo_write","todo_read"],"Team (Manager)":["team_list","team_status","delegate_message","create_task"],Subagents:["spawn_subagent","spawn_subagents"],LLM:["llm_list_providers","llm_switch_model","llm_switch_default_provider","llm_add_provider","llm_edit_provider","llm_add_model"]};function XT(e){const r=new Map,s=new Set;for(const[d,c]of Object.entries(GT)){const h=e.filter(m=>c.some(f=>m.name.startsWith(f)));h.length>0&&(r.set(d,h),h.forEach(m=>s.add(m.name)))}const l=e.filter(d=>!s.has(d.name));for(const d of l){const c=d.name.indexOf("__");if(c>0){const m=`MCP: ${d.name.slice(0,c)}`;r.has(m)||r.set(m,[]),r.get(m).push(d),s.add(d.name)}}const o=e.filter(d=>!s.has(d.name));return o.length>0&&r.set("Other",o),[...r.entries()].map(([d,c])=>({category:d,tools:c}))}function ZT({tools:e}){const r=XT(e);return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[e.length," tools registered"]}),r.map(s=>t.jsx(jn,{title:s.category,children:t.jsx("div",{className:"grid grid-cols-2 gap-2",children:s.tools.map(l=>t.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg bg-surface-elevated/30 border border-border-default/30",children:[t.jsx("div",{className:"w-2 h-2 rounded-full bg-green-400 shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs font-medium font-mono",children:l.name}),t.jsx("div",{className:"text-[10px] text-fg-tertiary truncate",children:l.description})]})]},l.name))})},s.category)),e.length===0&&t.jsx("div",{className:"text-center py-12 text-fg-tertiary text-sm",children:"No tools registered"})]})}function QT({agent:e}){const r=e.proficiency??{},[s,l]=v.useState(null),[o,d]=v.useState(null),[c,h]=v.useState(!1),m=e.availableSkills??[],f=new Map;for(const N of m){const E=N.category||"custom";f.has(E)||f.set(E,[]),f.get(E).push(N)}const x=async N=>{if(s===N){l(null),d(null);return}l(N),h(!0);try{const E=await fetch(`/api/skills/${encodeURIComponent(N)}`);if(E.ok){const A=await E.json();d(A.skill)}else d(null)}catch{d(null)}h(!1)},g={development:"bg-blue-500/15 text-blue-600",devops:"bg-amber-500/15 text-amber-600",communication:"bg-green-500/15 text-green-600",data:"bg-brand-500/15 text-brand-500",productivity:"bg-amber-500/15 text-amber-600",browser:"bg-blue-500/15 text-blue-600",custom:"bg-gray-500/15 text-fg-secondary",platform:"bg-purple-500/15 text-purple-500"},p=N=>{const E=r[N.name],A=E&&E.uses>0?Math.round(E.successes/E.uses*100):null,C=s===N.name;return t.jsxs("div",{children:[t.jsxs("div",{className:`flex items-center gap-3 px-4 py-2.5 rounded-lg border cursor-pointer transition-all ${C?"bg-brand-500/10 border-brand-500/40":"bg-surface-elevated/30 border-border-default/30 hover:border-gray-600/50"}`,onClick:()=>x(N.name),children:[t.jsx("span",{className:`text-sm transition-transform ${C?"rotate-90":""}`,children:"▶"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-medium",children:N.name}),N.alwaysOn&&t.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-medium bg-green-500/15 text-green-500",children:"always-on"}),N.builtIn&&!N.alwaysOn&&t.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-medium bg-surface-overlay/40 text-fg-tertiary",children:"built-in"}),!N.builtIn&&t.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-medium bg-brand-500/15 text-brand-400",children:"installed"})]}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5 truncate",children:N.description}),E&&t.jsxs("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:[E.uses," uses · ",E.successes," successes",E.lastUsed&&` · last ${new Date(E.lastUsed).toLocaleDateString()}`]})]}),A!==null&&t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[t.jsx("div",{className:"w-16 h-1.5 bg-surface-overlay rounded-full overflow-hidden",children:t.jsx("div",{className:`h-full rounded-full ${A>=80?"bg-green-400":A>=50?"bg-amber-400":"bg-red-400"}`,style:{width:`${A}%`}})}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary w-8 text-right",children:[A,"%"]})]})]}),C&&t.jsx("div",{className:"ml-6 mt-1 mb-2 p-4 bg-surface-elevated/30 rounded-lg border border-border-default/20 space-y-3",children:c?t.jsx("div",{className:"text-[10px] text-fg-tertiary py-3 text-center",children:"Loading skill details…"}):o?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] font-medium ${g[o.category]??g.custom}`,children:o.category}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["v",o.version]}),o.author&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["by ",o.author]}),o.requiredPermissions?.map(k=>t.jsx("span",{className:"px-1.5 py-0.5 bg-amber-500/10 text-amber-600 text-[10px] rounded",children:k},k))]}),o.description&&t.jsx("p",{className:"text-xs text-fg-secondary leading-relaxed",children:o.description}),o.tags&&o.tags.length>0&&t.jsx("div",{className:"flex gap-1 flex-wrap",children:o.tags.map(k=>t.jsxs("span",{className:"px-1.5 py-0.5 bg-surface-overlay/40 text-fg-tertiary text-[10px] rounded",children:["#",k]},k))}),(o.toolDetails??o.tools??[]).length>0&&t.jsxs("div",{children:[t.jsxs("div",{className:"text-[10px] text-fg-tertiary font-semibold uppercase tracking-wider mb-2",children:["Tools (",(o.toolDetails??o.tools??[]).length,")"]}),t.jsx("div",{className:"space-y-1.5",children:(o.toolDetails??o.tools??[]).map(k=>t.jsxs("div",{className:"px-3 py-2 bg-surface-secondary/50 rounded border border-border-default/20",children:[t.jsx("div",{className:"text-xs font-medium text-brand-500",children:k.name}),k.description&&t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:k.description})]},k.name))})]})]}):t.jsx("div",{className:"text-[10px] text-fg-tertiary py-3 text-center",children:"Skill details not available (skill may not be registered in the store)"})})]},N.name)},y=["development","productivity","browser","communication","devops","data","platform","custom"],w=[...f.entries()].sort((N,E)=>{const A=y.indexOf(N[0]),C=y.indexOf(E[0]);return(A===-1?999:A)-(C===-1?999:C)});return t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"flex items-center justify-between",children:t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[m.length," skills installed — descriptions auto-injected into agent context"]})}),w.map(([N,E])=>t.jsx(jn,{title:t.jsxs("span",{className:"capitalize",children:[N," ",t.jsxs("span",{className:"text-fg-tertiary font-normal",children:["(",E.length,")"]})]}),children:t.jsx("div",{className:"space-y-2",children:E.map(A=>p(A))})},N)),m.length===0&&t.jsx(Yl,{text:"No skills installed"})]})}function KT({agentId:e}){const[r,s]=v.useState(null),[l,o]=v.useState(!0),[d,c]=v.useState("entries"),[h,m]=v.useState(!1),[f,x]=v.useState(""),[g,p]=v.useState(!1),[y,w]=v.useState(""),[N,E]=v.useState(!1),[A,C]=v.useState(null),[k,S]=v.useState(null),[O,R]=v.useState([]),[G,I]=v.useState(!1),Q=v.useCallback(()=>{o(!0),re.agents.getMemory(e).then(T=>{s(T),x(T.recentDailyLogs??""),w(T.longTermMemory??"")}).catch(()=>{}).finally(()=>o(!1))},[e]);v.useEffect(()=>{Q()},[Q]);const $=async()=>{E(!0),await re.agents.updateDailyMemory(e,f).catch(()=>{}),E(!1),m(!1),Q()},F=async()=>{E(!0),await re.agents.updateLongTermMemory(e,"User-edited",y).catch(()=>{}),E(!1),p(!1),Q()};if(l)return t.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:"Loading memory..."});if(!r)return t.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:"Failed to load memory data"});const B=[{key:"entries",label:`Recent (${r.entries.length})`},{key:"sessions",label:`Sessions (${r.sessions.length})`},{key:"daily",label:"Daily Logs"},{key:"longterm",label:"Long-term"}];return t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"flex gap-2",children:B.map(T=>t.jsx("button",{onClick:()=>c(T.key),className:`px-3 py-1.5 text-xs rounded-lg border transition-colors ${d===T.key?"bg-brand-600/15 border-brand-500/40 text-brand-500":"border-border-default text-fg-tertiary hover:text-fg-secondary"}`,children:T.label},T.key))}),d==="entries"&&t.jsx(jn,{title:"Recent Memory Entries",children:r.entries.length===0?t.jsx(Yl,{text:"No memory entries"}):t.jsx("div",{className:"space-y-1.5 max-h-[600px] overflow-y-auto",children:r.entries.map((T,D)=>{const z=A===D;return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>C(z?null:D),className:"w-full flex gap-2 px-3 py-2 rounded-lg bg-surface-elevated/20 text-xs text-left hover:bg-surface-elevated/40 transition-colors cursor-pointer",children:[t.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium shrink-0 ${T.type==="fact"?"bg-blue-500/15 text-blue-600":T.type==="task"?"bg-green-500/15 text-green-600":T.type==="note"?"bg-brand-500/15 text-brand-500":"bg-surface-overlay text-fg-secondary"}`,children:T.type}),t.jsx("span",{className:`text-fg-secondary flex-1 min-w-0 ${z?"":"line-clamp-2"}`,children:T.content}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[T.importance!=null&&t.jsxs("span",{className:`px-1 py-0.5 rounded text-[9px] font-medium ${T.importance>=7?"bg-red-500/15 text-red-500":T.importance>=4?"bg-amber-500/15 text-amber-600":"bg-surface-overlay text-fg-tertiary"}`,children:["P",T.importance]}),t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:new Date(T.timestamp).toLocaleTimeString()}),t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:z?"▲":"▼"})]})]}),z&&t.jsxs("div",{className:"mx-3 mt-1 mb-2 p-3 bg-surface-elevated/30 rounded-lg border border-border-default/20",children:[t.jsx("pre",{className:"text-xs text-fg-secondary whitespace-pre-wrap font-mono leading-relaxed break-words",children:T.content}),t.jsxs("div",{className:"flex gap-3 mt-2 pt-2 border-t border-border-default/30 text-[10px] text-fg-tertiary",children:[t.jsxs("span",{children:["Type: ",T.type]}),T.importance!=null&&t.jsxs("span",{children:["Importance: ",T.importance]}),t.jsx("span",{children:new Date(T.timestamp).toLocaleString()})]})]})]},D)})})}),d==="sessions"&&t.jsx(jn,{title:"Chat Sessions",children:r.sessions.length===0?t.jsx(Yl,{text:"No sessions"}):t.jsx("div",{className:"space-y-1.5 max-h-[600px] overflow-y-auto",children:r.sessions.map(T=>{const D=k===T.id,z=async()=>{if(D){S(null),R([]);return}S(T.id),I(!0);try{const _=await re.agents.getMemorySession(e,T.id);R(_.messages)}catch{R([])}I(!1)};return t.jsxs("div",{children:[t.jsxs("button",{onClick:z,className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-lg bg-surface-elevated/20 hover:bg-surface-elevated/40 transition-colors cursor-pointer text-left",children:[t.jsx("div",{className:"text-xs text-fg-secondary font-mono flex-1 truncate",children:T.id}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[T.messageCount," msgs"]}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:new Date(T.updatedAt).toLocaleDateString()}),t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:D?"▲":"▼"})]}),D&&t.jsx("div",{className:"mx-3 mt-1 mb-2 bg-surface-elevated/30 rounded-lg border border-border-default/20 max-h-96 overflow-y-auto",children:G?t.jsx("div",{className:"text-[10px] text-fg-tertiary py-3 text-center",children:"Loading messages..."}):O.length===0?t.jsx("div",{className:"text-[10px] text-fg-tertiary py-3 text-center",children:"No messages in this session"}):(()=>{const _=new Map;for(const Y of O)Y.role==="tool"&&Y.toolCallId&&_.set(Y.toolCallId,Y.content);return t.jsx("div",{className:"divide-y divide-gray-700/30",children:O.filter(Y=>Y.role!=="tool").map((Y,V)=>t.jsxs("div",{className:"px-3 py-2",children:[(Y.role==="user"||Y.role==="system")&&t.jsxs("div",{children:[t.jsx("span",{className:`inline-block px-1.5 py-0.5 rounded text-[10px] font-medium mb-1 ${Y.role==="user"?"bg-blue-500/15 text-blue-600":"bg-surface-overlay text-fg-secondary"}`,children:Y.role}),t.jsx("div",{className:"text-xs text-fg-secondary",children:t.jsx(Zn,{content:Y.content,className:"text-xs text-fg-secondary"})})]}),Y.role==="assistant"&&t.jsxs("div",{className:"space-y-1",children:[Y.content&&t.jsxs("div",{children:[t.jsx("span",{className:"inline-block px-1.5 py-0.5 rounded text-[10px] font-medium mb-1 bg-green-500/15 text-green-600",children:"assistant"}),t.jsx("div",{className:"text-xs text-fg-secondary",children:t.jsx(Zn,{content:Y.content,className:"text-xs text-fg-secondary"})})]}),Y.toolCalls&&Y.toolCalls.length>0&&t.jsx("div",{className:"space-y-0.5",children:Y.toolCalls.map(J=>{let U;try{U=JSON.parse(J.arguments)}catch{}const H={tool:J.name,status:"done",args:U,result:_.get(J.id)};return t.jsx(bj,{entry:{type:"tool",info:H}},J.id)})})]})]},V))})})()})]},T.id)})})}),d==="daily"&&t.jsx(jn,{title:"Daily Logs",action:h?t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>m(!1),className:"text-xs text-fg-tertiary",children:"Cancel"}),t.jsx("button",{onClick:$,disabled:N,className:"text-xs text-brand-500",children:N?"Saving...":"Save"})]}):t.jsx("button",{onClick:()=>m(!0),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Edit"}),children:h?t.jsx("textarea",{value:f,onChange:T=>x(T.target.value),className:"w-full h-64 bg-surface-elevated/60 border border-border-default rounded-lg p-4 text-xs font-mono text-fg-secondary leading-relaxed resize-y focus:border-brand-500 outline-none"}):r.recentDailyLogs?t.jsx("pre",{className:"text-xs text-fg-secondary whitespace-pre-wrap font-mono leading-relaxed bg-surface-elevated/30 rounded-lg p-4 max-h-96 overflow-y-auto",children:r.recentDailyLogs}):t.jsx(Yl,{text:"No daily logs"})}),d==="longterm"&&t.jsx(jn,{title:"Long-term Memory",action:g?t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>p(!1),className:"text-xs text-fg-tertiary",children:"Cancel"}),t.jsx("button",{onClick:F,disabled:N,className:"text-xs text-brand-500",children:N?"Saving...":"Save"})]}):t.jsx("button",{onClick:()=>p(!0),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Edit"}),children:g?t.jsx("textarea",{value:y,onChange:T=>w(T.target.value),className:"w-full h-64 bg-surface-elevated/60 border border-border-default rounded-lg p-4 text-xs font-mono text-fg-secondary leading-relaxed resize-y focus:border-brand-500 outline-none"}):r.longTermMemory?t.jsx("pre",{className:"text-xs text-fg-secondary whitespace-pre-wrap font-mono leading-relaxed bg-surface-elevated/30 rounded-lg p-4 max-h-96 overflow-y-auto",children:r.longTermMemory}):t.jsx(Yl,{text:"No long-term memory stored"})})]})}function JT({agentId:e,initialData:r}){const[s,l]=v.useState(r??null),[o,d]=v.useState(!r),[c,h]=v.useState([]),[m,f]=v.useState(null),[x,g]=v.useState(!1),[p,y]=v.useState(null),w=v.useCallback(()=>{re.agents.getHeartbeat(e).then(l).catch(()=>{}),re.agents.getRecentActivities(e).then(C=>{h(C.activities.filter(k=>k.type==="heartbeat"))}).catch(()=>{})},[e]);v.useEffect(()=>{d(!0),w(),d(!1)},[w]),v.useEffect(()=>kn.on("agent:update",k=>{k.payload?.agentId===e&&w()}),[e,w]);const N=async()=>{g(!0),y(null);try{const C=await re.agents.triggerHeartbeat(e);y(C.message),setTimeout(()=>y(null),4e3),setTimeout(w,2e3)}catch(C){y(String(C).replace("Error: ",""))}g(!1)};if(o)return t.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:"Loading heartbeat data..."});if(!s)return t.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:"No heartbeat data available"});const E=C=>C?C<1e3?`${C}ms`:C<6e4?`${(C/1e3).toFixed(1)}s`:`${(C/6e4).toFixed(1)}m`:null,A=C=>{if(!C)return null;const k=Date.now()-new Date(C).getTime();if(k<0){const S=Math.abs(k);return S<6e4?`in ${Math.ceil(S/1e3)}s`:S<36e5?`in ${Math.ceil(S/6e4)}m`:`in ${(S/36e5).toFixed(1)}h`}return k<6e4?`${Math.floor(k/1e3)}s ago`:k<36e5?`${Math.floor(k/6e4)}m ago`:`${(k/36e5).toFixed(1)}h ago`};return t.jsxs("div",{className:"space-y-4",children:[t.jsxs(jn,{title:"Heartbeat Scheduler",action:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:w,className:"text-[10px] text-fg-tertiary hover:text-fg-secondary transition-colors",children:"Refresh"}),t.jsx("button",{onClick:N,disabled:x||!s.running,className:"text-[10px] px-2.5 py-1 rounded-md bg-blue-600/20 text-blue-600 hover:bg-blue-600/30 border border-blue-500/30 transition-colors disabled:opacity-40",children:x?"Triggering...":"Trigger Now"})]}),children:[t.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[t.jsx(Yn,{label:"Status",value:s.running?"Running":"Stopped",color:s.running?"green":"gray"}),t.jsx(Yn,{label:"Interval",value:E(s.intervalMs)??"—"}),t.jsx(Yn,{label:"Last Run",value:s.lastHeartbeat?A(s.lastHeartbeat)??"—":"Never"}),t.jsx(Yn,{label:"Next Run",value:s.nextRunAt?A(s.nextRunAt)??"—":s.running?"Pending":"—"})]}),p&&t.jsx("div",{className:"mt-3 text-[11px] text-blue-600 bg-blue-500/10 border border-blue-500/20 rounded-lg px-3 py-2",children:p})]}),s.lastSummary&&t.jsx(jn,{title:"Last Heartbeat Summary",action:s.lastSummaryAt?t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:new Date(s.lastSummaryAt).toLocaleString()}):void 0,children:t.jsx("div",{className:"bg-surface-primary/50 rounded-lg px-4 py-3",children:t.jsx(Zn,{content:s.lastSummary,className:"text-xs text-fg-secondary leading-relaxed"})})}),c.length>0?t.jsx(jn,{title:"Recent Runs",action:t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[c.length," runs this session"]}),children:t.jsx("div",{className:"divide-y divide-gray-800/50 -mx-5",children:[...c].reverse().map(C=>{const k=m===C.id;return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>f(k?null:C.id),className:"w-full flex items-center gap-2.5 px-5 py-2.5 text-left transition-colors hover:bg-surface-elevated/40 cursor-pointer",children:[t.jsx("span",{className:"w-2 h-2 rounded-full shrink-0 bg-blue-400"}),t.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:C.label}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:[C.logCount," actions"]}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date(C.startedAt).toLocaleString()}),t.jsx("svg",{className:`w-3 h-3 text-fg-tertiary shrink-0 transition-transform ${k?"rotate-180":""}`,viewBox:"0 0 12 12",fill:"currentColor",children:t.jsx("path",{d:"M3 4.5l3 3 3-3",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})]}),k&&t.jsx("div",{className:"border-t border-border-default/60 bg-surface-primary/40",children:t.jsx(_d,{agentId:e,activityId:C.id})})]},C.id)})})}):s.lastHeartbeat?null:t.jsx(jn,{title:"Recent Runs",children:t.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[t.jsx("div",{className:"text-xl mb-2 opacity-40",children:"♡"}),t.jsx("p",{className:"text-xs text-fg-tertiary",children:"No heartbeat runs yet this session."}),t.jsx("p",{className:"text-[10px] text-fg-tertiary mt-1",children:s.running?`First heartbeat will trigger in ~${E(s.intervalMs-s.uptimeMs%s.intervalMs)??"soon"}.`:"Heartbeat scheduler is stopped."}),s.running&&t.jsx("button",{onClick:N,disabled:x,className:"mt-3 text-[10px] px-3 py-1.5 rounded-md bg-blue-600/15 text-blue-600 hover:bg-blue-600/25 border border-blue-500/25 transition-colors disabled:opacity-40",children:x?"Triggering...":"Run First Heartbeat Now"})]})})]})}function wj({taskId:e,isLive:r}){const[s,l]=v.useState([]),[o,d]=v.useState(""),[c,h]=v.useState(!0),[m,f]=v.useState("compact");if(v.useEffect(()=>{h(!0),d(""),re.tasks.getLogs(e).then(p=>{l(p.logs),h(!1)}).catch(()=>h(!1))},[e]),v.useEffect(()=>{if(!r)return;const p=kn.on("task:log",w=>{const N=w.payload;if(N.taskId!==e)return;const E={id:N.id,taskId:N.taskId,agentId:N.agentId,seq:N.seq,type:N.logType,content:N.content,metadata:N.metadata,createdAt:N.createdAt};l(A=>E.id&&A.some(C=>C.id===E.id)?A:[...A,E]),E.type==="text"&&d("")}),y=kn.on("task:log:delta",w=>{const N=w.payload;N.taskId===e&&d(E=>E+N.text)});return()=>{p(),y()}},[e,r]),c)return t.jsx("div",{className:"px-4 py-3 text-xs text-fg-tertiary",children:"Loading..."});if(s.length===0&&!o)return t.jsx("div",{className:"px-4 py-3 text-xs text-fg-tertiary",children:"No execution logs yet."});const x=s.map(p=>jd(p)),g=new Set(x.filter(p=>p.executionRound!=null).map(p=>p.executionRound)).size>1;return t.jsx("div",{className:"px-3 py-2",children:m==="compact"?t.jsx(Qd,{entries:x,streamingText:o,isActive:r,onExpand:()=>f("full"),showRounds:g}):t.jsx(Kd,{entries:x,streamingText:o,isActive:r,onCollapse:()=>f("compact"),showRounds:g})})}function _d({agentId:e,activityId:r}){const[s,l]=v.useState([]),[o,d]=v.useState(!0),[c,h]=v.useState("compact");if(v.useEffect(()=>{d(!0),re.agents.getActivityLogs(e,r).then(f=>{l(f.logs),d(!1)}).catch(()=>d(!1))},[e,r]),o)return t.jsx("div",{className:"px-4 py-3 text-xs text-fg-tertiary",children:"Loading..."});if(s.length===0)return t.jsx("div",{className:"px-4 py-3 text-xs text-fg-tertiary",children:"No activity logs available."});const m=s.map(f=>a1(f,r,e)).filter(f=>f!==null);return t.jsx("div",{className:"px-3 py-2",children:c==="compact"?t.jsx(Qd,{entries:m,isActive:!1,onExpand:()=>h("full")}):t.jsx(Kd,{entries:m,isActive:!1,onCollapse:()=>h("compact")})})}function jn({title:e,action:r,children:s}){return t.jsxs("div",{className:"bg-surface-secondary/60 border border-border-default rounded-xl p-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h3",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider",children:e}),r]}),s]})}function zn({label:e,mono:r,children:s}){return t.jsxs("div",{className:"flex flex-col gap-0.5",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:e}),t.jsx("span",{className:`text-xs text-fg-secondary ${r?"font-mono text-[10px]":""}`,children:s})]})}function Yn({label:e,value:r,color:s}){const l=s==="green"?"text-green-600":s==="indigo"?"text-brand-500":s==="red"?"text-red-500":"text-fg-secondary";return t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:`text-lg font-semibold ${l}`,children:r}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:e})]})}function Yl({text:e}){return t.jsx("div",{className:"text-xs text-fg-tertiary py-6 text-center",children:e})}function py(e){if(e===0)return"0 B";const r=["B","KB","MB","GB"],s=Math.min(Math.floor(Math.log(e)/Math.log(1024)),r.length-1),l=e/Math.pow(1024,s);return`${l<10?l.toFixed(1):Math.round(l)} ${r[s]}`}const WT=[{key:"all",label:"All"},{key:"task",label:"Task"},{key:"chat",label:"Chat"},{key:"heartbeat",label:"Heartbeat"},{key:"a2a",label:"A2A"},{key:"internal",label:"Internal"},{key:"respond_in_session",label:"Session"}],eA={task:"☑",chat:"💬",heartbeat:"♡",a2a:"🔗",internal:"⚙",respond_in_session:"↩"};function tA({agentId:e}){const[r,s]=v.useState([]),[l,o]=v.useState("all"),[d,c]=v.useState(!0),[h,m]=v.useState(null),[f,x]=v.useState(!0),g=v.useCallback(async y=>{c(!0);try{const w=l==="all"?void 0:l,N=await re.agents.getActivities(e,{type:w,limit:30,before:y});s(y?E=>[...E,...N.activities]:N.activities),x(N.activities.length>=30)}catch{}c(!1)},[e,l]);v.useEffect(()=>{s([]),m(null),g()},[g]);const p=()=>{if(r.length>0){const y=r[r.length-1];g(y.startedAt)}};return t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{className:"flex gap-1.5 flex-wrap",children:WT.map(y=>t.jsx("button",{onClick:()=>o(y.key),className:`px-2.5 py-1 text-xs rounded-md border transition-colors ${l===y.key?"bg-brand-500/20 border-brand-500/40 text-brand-300":"bg-surface-2 border-border-subtle text-fg-secondary hover:bg-surface-3"}`,children:y.label},y.key))}),d&&r.length===0&&t.jsx("div",{className:"text-xs text-fg-tertiary text-center py-8",children:"Loading activities..."}),!d&&r.length===0&&t.jsx("div",{className:"text-xs text-fg-tertiary text-center py-8",children:"No activity history found."}),t.jsx("div",{className:"space-y-1.5",children:r.map(y=>t.jsxs("div",{className:"bg-surface-2 rounded-lg border border-border-subtle",children:[t.jsxs("button",{className:"w-full px-3 py-2.5 flex items-start gap-2.5 text-left hover:bg-surface-3/50 transition-colors rounded-lg",onClick:()=>m(h===y.id?null:y.id),children:[t.jsx("span",{className:"text-sm mt-0.5",children:h===y.id?"▾":"▸"}),t.jsx("span",{className:"text-sm",children:eA[y.type]??"●"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs font-medium text-fg-primary truncate",children:y.label}),t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${y.success?"bg-green-500/15 text-green-400":"bg-red-500/15 text-red-400"}`,children:y.success?"✓":"✗"})]}),t.jsxs("div",{className:"text-[10px] text-fg-tertiary mt-0.5 flex gap-2",children:[t.jsx("span",{children:new Date(y.startedAt).toLocaleString()}),y.endedAt&&t.jsxs("span",{children:["→ ",new Date(y.endedAt).toLocaleTimeString()]}),y.totalTokens>0&&t.jsxs("span",{children:[xd(y.totalTokens)," tokens"]}),y.totalTools>0&&t.jsxs("span",{children:[y.totalTools," tools"]})]})]}),t.jsx("span",{className:"text-[10px] text-fg-tertiary bg-surface-3 px-1.5 py-0.5 rounded",children:y.type})]}),h===y.id&&t.jsx("div",{className:"border-t border-border-subtle",children:y.type==="task"&&y.taskId?t.jsx(wj,{taskId:y.taskId,isLive:!y.endedAt}):t.jsx(_d,{agentId:e,activityId:y.id})})]},y.id))}),f&&r.length>0&&t.jsx("div",{className:"text-center",children:t.jsx("button",{onClick:p,disabled:d,className:"text-xs text-brand-400 hover:text-brand-300 transition-colors disabled:opacity-50",children:d?"Loading...":"Load Earlier..."})})]})}const nA=[{key:"overview",label:"Overview",icon:"▦"},{key:"members",label:"Members",icon:"◉"},{key:"announcements",label:"Announcements",icon:"◈"},{key:"norms",label:"Norms",icon:"☰"},{key:"settings",label:"Settings",icon:"⚙"}],by={idle:"bg-green-400",working:"bg-brand-400 animate-pulse",paused:"bg-amber-400",offline:"bg-gray-500",error:"bg-red-400"};function rA({teamId:e,onBack:r,inline:s}){const[l,o]=v.useState(null),[d,c]=v.useState("overview"),[h,m]=v.useState(""),[f,x]=v.useState(""),[g,p]=v.useState(!1),[y,w]=v.useState(!1),[N,E]=v.useState(""),[A,C]=v.useState(""),[k,S]=v.useState(!1),[O,R]=v.useState(!1),[G,I]=v.useState(""),[Q,$]=v.useState(""),[F,B]=v.useState(!1),[T,D]=v.useState([]),z=v.useRef(null),_=v.useCallback(async()=>{try{const M=(await re.teams.list()).teams.find(K=>K.id===e);M&&o(M);const q=await re.teams.status(e);D(q.agents)}catch{}},[e]),Y=v.useCallback(async()=>{try{const L=await re.teams.getFile(e,"ANNOUNCEMENT.md");m(L.content)}catch{m("")}try{const L=await re.teams.getFile(e,"NORMS.md");x(L.content)}catch{x("")}},[e]);v.useEffect(()=>{c("overview"),_(),Y()},[e,_,Y]);const V=async(L,M)=>{S(!0);try{await re.teams.updateFile(e,L,M),L==="ANNOUNCEMENT.md"?(m(M),p(!1)):(x(M),w(!1))}catch{}S(!1)},J=async()=>{G.trim()&&(await re.teams.update(e,{name:G.trim()}),R(!1),_())},U=async()=>{await re.teams.update(e,{description:Q}),B(!1),_()};if(!l)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm",children:"Loading team..."});const H=l.members.find(L=>L.agentRole==="manager"),X=T.filter(L=>L.status!=="offline").length;return t.jsxs("div",{className:"flex-1 overflow-y-auto bg-surface-primary",children:[t.jsxs("div",{className:"px-5 py-3.5 border-b border-border-default bg-surface-secondary sticky top-0 z-10",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-xl bg-brand-600 text-white flex items-center justify-center text-lg font-bold shrink-0",children:t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"9",cy:"7",r:"4"}),t.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),t.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("h2",{className:"text-base font-semibold",children:l.name}),t.jsxs("span",{className:"px-1.5 py-0.5 text-[10px] bg-brand-500/15 text-brand-500 rounded font-medium",children:[l.members.length," members"]}),t.jsxs("span",{className:"px-1.5 py-0.5 text-[10px] bg-green-500/15 text-green-600 rounded font-medium",children:[X," online"]})]}),t.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:l.description||"No description"})]}),t.jsxs("button",{onClick:async()=>{if(l)try{const{files:L}=await re.teams.getFilesMap(l.id),M=l.members.filter(K=>K.type==="agent"),q={type:"team",name:l.name.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"")||l.name,displayName:l.name,version:"1.0.0",description:l.description??"",author:"",category:"general",tags:[],team:{members:M.map(K=>({name:K.name,roleName:K.role,role:K.agentRole??"worker",count:1,skills:[]}))}};await Un.publishViaProxy({itemType:"team",name:l.name,description:l.description??"",category:"general",config:q,files:L}),alert(`Published "${l.name}" to Markus Hub`)}catch(L){alert(`Failed to publish: ${L}`)}},className:"px-3 py-1.5 text-xs bg-green-600 hover:bg-green-500 text-white rounded-lg transition-colors flex items-center gap-1",title:"Publish to Markus Hub",children:[t.jsx("span",{children:"↑"})," Hub"]}),s&&t.jsx("button",{onClick:r,className:"p-1.5 text-fg-tertiary hover:text-fg-secondary text-lg leading-none",children:"×"})]}),t.jsx("div",{className:"flex gap-1 mt-3 -mb-[1px] overflow-x-auto",children:nA.map(L=>t.jsxs("button",{onClick:()=>c(L.key),className:`px-3 py-1.5 text-xs rounded-t-lg whitespace-nowrap transition-colors ${d===L.key?"bg-surface-primary text-fg-primary border border-border-default border-b-gray-950":"text-fg-tertiary hover:text-fg-secondary"}`,children:[L.icon," ",L.label]},L.key))})]}),t.jsxs("div",{className:"p-5",children:[d==="overview"&&t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default",children:[t.jsx("div",{className:"text-xs text-fg-tertiary mb-1",children:"Manager"}),t.jsx("div",{className:"text-sm font-medium",children:H?.name??l.managerName??"None"})]}),t.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default",children:[t.jsx("div",{className:"text-xs text-fg-tertiary mb-1",children:"Team ID"}),t.jsx("div",{className:"text-sm font-mono text-fg-secondary truncate",children:l.id})]})]}),h.trim()&&t.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default",children:[t.jsx("div",{className:"text-xs text-fg-tertiary mb-2 font-medium",children:"Latest Announcement"}),t.jsxs("div",{className:"text-sm text-fg-secondary whitespace-pre-wrap",children:[h.slice(0,500),h.length>500?"...":""]})]}),t.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default",children:[t.jsx("div",{className:"text-xs text-fg-tertiary mb-2 font-medium",children:"Members"}),t.jsx("div",{className:"space-y-2",children:l.members.map(L=>{const M=T.find(K=>K.id===L.id),q=by[M?.status??"offline"]??"bg-gray-500";return t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${q}`}),t.jsx("span",{className:"font-medium",children:L.name}),t.jsx("span",{className:"text-fg-tertiary",children:L.role}),L.agentRole==="manager"&&t.jsx("span",{className:"text-[10px] px-1 py-0.5 bg-amber-500/15 text-amber-600 rounded",children:"Manager"})]},L.id)})})]})]}),d==="members"&&t.jsxs("div",{className:"space-y-3",children:[l.members.map(L=>{const M=T.find(K=>K.id===L.id),q=by[M?.status??"offline"]??"bg-gray-500";return t.jsxs("div",{className:"p-3 bg-surface-secondary rounded-xl border border-border-default flex items-center gap-3",children:[t.jsx("div",{className:"w-8 h-8 rounded-lg bg-surface-elevated flex items-center justify-center text-sm font-bold shrink-0",children:L.name.charAt(0)}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-medium",children:L.name}),t.jsx("span",{className:`w-2 h-2 rounded-full ${q}`}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:M?.status??"offline"}),L.agentRole==="manager"&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-amber-500/15 text-amber-600 rounded font-medium",children:"Manager"})]}),t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[L.role," · ",L.type]})]})]},L.id)}),l.members.length===0&&t.jsx("div",{className:"text-sm text-fg-tertiary text-center py-8",children:"No members"})]}),d==="announcements"&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h3",{className:"text-sm font-medium text-fg-secondary",children:"Team Announcements"}),!g&&t.jsx("button",{onClick:()=>{E(h),p(!0)},className:"px-3 py-1 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary rounded-lg transition-colors",children:"Edit"})]}),g?t.jsxs("div",{className:"space-y-3",children:[t.jsx("textarea",{value:N,onChange:L=>E(L.target.value),className:"w-full h-64 bg-surface-secondary border border-border-default rounded-xl p-3 text-sm text-fg-primary resize-y focus:outline-none focus:border-brand-500 font-mono",placeholder:"Write team announcements here (Markdown supported)..."}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>V("ANNOUNCEMENT.md",N),disabled:k,className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:k?"Saving...":"Save"}),t.jsx("button",{onClick:()=>p(!1),className:"px-4 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary rounded-lg transition-colors",children:"Cancel"})]})]}):t.jsx("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default min-h-[120px]",children:h.trim()?t.jsx("div",{className:"text-sm text-fg-secondary whitespace-pre-wrap",children:h}):t.jsx("div",{className:"text-sm text-fg-tertiary italic",children:"No announcements yet. Click Edit to add."})})]}),d==="norms"&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h3",{className:"text-sm font-medium text-fg-secondary",children:"Team Working Norms"}),!y&&t.jsx("button",{onClick:()=>{C(f),w(!0)},className:"px-3 py-1 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary rounded-lg transition-colors",children:"Edit"})]}),y?t.jsxs("div",{className:"space-y-3",children:[t.jsx("textarea",{value:A,onChange:L=>C(L.target.value),className:"w-full h-64 bg-surface-secondary border border-border-default rounded-xl p-3 text-sm text-fg-primary resize-y focus:outline-none focus:border-brand-500 font-mono",placeholder:"Define team norms and working agreements (Markdown supported)..."}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>V("NORMS.md",A),disabled:k,className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:k?"Saving...":"Save"}),t.jsx("button",{onClick:()=>w(!1),className:"px-4 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary rounded-lg transition-colors",children:"Cancel"})]})]}):t.jsx("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default min-h-[120px]",children:f.trim()?t.jsx("div",{className:"text-sm text-fg-secondary whitespace-pre-wrap",children:f}):t.jsx("div",{className:"text-sm text-fg-tertiary italic",children:"No norms defined yet. Click Edit to add."})})]}),d==="settings"&&t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default space-y-4",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-xs text-fg-tertiary mb-1",children:"Team Name"}),O?t.jsxs("div",{className:"flex gap-2 items-center",children:[t.jsx("input",{ref:z,value:G,onChange:L=>I(L.target.value),onKeyDown:L=>L.key==="Enter"&&J(),className:"flex-1 bg-surface-elevated border border-border-default rounded-lg px-3 py-1.5 text-sm text-fg-primary focus:outline-none focus:border-brand-500",autoFocus:!0}),t.jsx("button",{onClick:J,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 rounded-lg text-white",children:"Save"}),t.jsx("button",{onClick:()=>R(!1),className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay rounded-lg text-fg-secondary",children:"Cancel"})]}):t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm",children:l.name}),t.jsx("button",{onClick:()=>{I(l.name),R(!0)},className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Edit"})]})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-xs text-fg-tertiary mb-1",children:"Description"}),F?t.jsxs("div",{className:"space-y-2",children:[t.jsx("textarea",{value:Q,onChange:L=>$(L.target.value),className:"w-full bg-surface-elevated border border-border-default rounded-lg px-3 py-1.5 text-sm text-fg-primary resize-y focus:outline-none focus:border-brand-500",rows:3,autoFocus:!0}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:U,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 rounded-lg text-white",children:"Save"}),t.jsx("button",{onClick:()=>B(!1),className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay rounded-lg text-fg-secondary",children:"Cancel"})]})]}):t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm text-fg-secondary",children:l.description||"No description"}),t.jsx("button",{onClick:()=>{$(l.description??""),B(!0)},className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Edit"})]})]})]}),t.jsx(sA,{teamId:e,teamName:l.name,onDeleted:r})]})]})]})}function sA({teamId:e,teamName:r,onDeleted:s}){const[l,o]=v.useState(!1),[d,c]=v.useState(!1),[h,m]=v.useState(!1),[f,x]=v.useState(!1);return t.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-red-900/30 space-y-3",children:[t.jsx("div",{className:"text-sm font-medium text-red-500",children:"Danger Zone"}),l?t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"text-xs text-fg-secondary",children:['Delete team "',r,'"? This removes the team record from the database.']}),t.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg-secondary cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:h,onChange:g=>m(g.target.checked),className:"rounded"}),"Also delete all members in this team"]}),t.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg-secondary cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:d,onChange:g=>c(g.target.checked),className:"rounded"}),"Also delete disk files (workspace, memory, logs)"]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:f,onClick:async()=>{x(!0);try{await re.teams.delete(e,h,{purgeFiles:d}),window.dispatchEvent(new CustomEvent("markus:data-changed")),s()}catch{x(!1)}},className:"px-4 py-1.5 text-xs bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors disabled:opacity-50",children:f?"Deleting...":"Confirm Delete"}),t.jsx("button",{onClick:()=>o(!1),className:"px-4 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary rounded-lg transition-colors border border-border-default",children:"Cancel"})]})]}):t.jsx("button",{onClick:()=>o(!0),className:"px-4 py-1.5 text-xs bg-red-600/20 hover:bg-red-600/30 text-red-500 rounded-lg transition-colors border border-red-500/30",children:"Delete Team"})]})}function Wd({side:e,defaultWidth:r,minWidth:s,maxWidth:l,collapsedWidth:o=0,storageKey:d}){const[c,h]=v.useState(()=>{try{const y=localStorage.getItem(`${d}_w`);if(y)return Math.max(s,Math.min(l,parseInt(y,10)))}catch{}return r}),[m,f]=v.useState(()=>{try{return localStorage.getItem(`${d}_c`)==="1"}catch{return!1}}),x=v.useRef(!1);v.useEffect(()=>{try{localStorage.setItem(`${d}_w`,String(c))}catch{}},[c,d]),v.useEffect(()=>{try{localStorage.setItem(`${d}_c`,m?"1":"0")}catch{}},[m,d]);const g=v.useCallback(y=>{y.preventDefault(),x.current=!0;const w=y.clientX,N=c,E=C=>{if(!x.current)return;const k=e==="left"?C.clientX-w:w-C.clientX;h(Math.max(s,Math.min(l,N+k)))},A=()=>{x.current=!1,document.removeEventListener("mousemove",E),document.removeEventListener("mouseup",A),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",E),document.addEventListener("mouseup",A),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[c,e,s,l]),p=v.useCallback(()=>f(y=>!y),[]);return{width:m?o:c,rawWidth:c,collapsed:m,toggle:p,setCollapsed:f,onResizeStart:g}}function yy(e){const r={id:e.id,sender:e.role==="user"?"user":"agent",text:e.content,time:new Date(e.createdAt).toLocaleTimeString(),agentId:e.role!=="user"?e.agentId:void 0};return e.role!=="user"&&e.metadata?.segments&&e.metadata.segments.length>0&&(r.segments=e.metadata.segments.map((s,l)=>s.type==="tool"?{type:"tool",key:`${s.tool}_${l}`,tool:s.tool,status:s.status,args:s.arguments,result:s.result,error:s.error,durationMs:s.durationMs}:{type:"text",content:s.content})),(e.metadata?.isError||e.role==="assistant"&&e.content.startsWith("⚠"))&&(r.isError=!0),e.metadata?.isStopped&&(r.isStopped=!0),e.metadata?.images?.length&&(r.images=e.metadata.images),r}function ro(e){const r=e.senderType==="system"||e.senderType==="agent"&&e.text.startsWith("⚠"),s={id:e.id,sender:e.senderType==="human"?"user":"agent",text:e.text,time:new Date(e.createdAt).toLocaleTimeString(),agentName:e.senderType!=="human"?e.senderName:void 0,agentId:e.senderType!=="human"?e.senderId:void 0,isError:r};if(e.metadata&&e.senderType==="agent"){const l=[],o=e.metadata;if(o.thinking?.length&&l.push({type:"text",content:"",thinking:o.thinking.join(`
|
|
51
|
+
|
|
52
|
+
`)}),o.toolCalls?.length)for(let d=0;d<o.toolCalls.length;d++){const c=o.toolCalls[d];l.push({type:"tool",key:`${c.tool}_${d}`,tool:c.tool,status:c.status==="error"?"error":"done",args:c.arguments,result:c.result,durationMs:c.durationMs})}l.length>0&&(l.push({type:"text",content:e.text}),s.segments=l)}return s}function Nj(e){return e.split(" ").map(r=>r[0]).join("").toUpperCase().slice(0,2)}function aA({name:e,agentId:r,agents:s,onViewProfile:l}){const[o,d]=v.useState(!1),c=v.useRef(null),h=r?s.find(m=>m.id===r):s.find(m=>m.name===e);return v.useEffect(()=>{if(!o)return;const m=f=>{c.current&&!c.current.contains(f.target)&&d(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[o]),h?t.jsxs("span",{ref:c,className:"relative inline-block",children:[t.jsx("button",{onClick:()=>d(!o),className:"text-fg-tertiary hover:text-brand-500 cursor-pointer transition-colors",children:e}),o&&t.jsxs("div",{className:"absolute left-0 top-full mt-1.5 bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-40 w-56 p-3 space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-7 h-7 rounded-full bg-brand-500/15 flex items-center justify-center text-[10px] font-bold text-brand-600",children:Nj(h.name)}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs text-fg-primary font-medium truncate",children:h.name}),t.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:[h.role," · ",h.agentRole??"worker"]})]}),t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${h.status==="working"?"bg-blue-400 animate-pulse":h.status==="error"?"bg-red-400":"bg-green-400"}`})]}),t.jsx("button",{onClick:()=>{d(!1),l?.(h.id)},className:"w-full text-center text-[10px] text-brand-500 hover:text-brand-500 border border-border-default hover:border-gray-600 rounded-lg py-1 transition-colors",children:"View Profile →"})]})]}):t.jsx("span",{children:e})}function lA({agent:e,anchorRect:r,onClose:s,onViewProfile:l}){const o=v.useRef(null);v.useEffect(()=>{const h=m=>{o.current&&!o.current.contains(m.target)&&s()};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[s]);const d=e.status==="idle"?"bg-green-400":e.status==="working"?"bg-blue-400 animate-pulse":e.status==="error"?"bg-red-400":"bg-gray-500",c=e.status==="idle"?"Online":e.status==="working"?"Working":e.status==="error"?"Error":e.status==="paused"?"Paused":"Offline";return t.jsxs("div",{ref:o,className:"fixed z-50 w-64 bg-surface-secondary border border-border-default rounded-xl shadow-2xl p-4 space-y-3",style:{top:r.top+40,left:r.left},children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-full bg-brand-500/15 flex items-center justify-center text-sm font-bold text-brand-600",children:Nj(e.name)}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary font-medium truncate",children:e.name}),t.jsx("div",{className:"text-[11px] text-fg-tertiary",children:e.role}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${d}`}),t.jsx("span",{className:"text-[10px] text-fg-secondary",children:c}),e.agentRole&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["· ",e.agentRole]})]})]})]}),t.jsx("button",{onClick:()=>{s(),l(e.id)},className:"w-full py-1.5 text-xs text-brand-500 hover:text-brand-500 border border-border-default hover:border-gray-600 rounded-lg transition-colors text-center",children:"View Profile →"})]})}function vy(e){const r=String(e);if(r.includes("AbortError")||r.includes("abort"))return"";let s="";const l=r.match(/\{[\s\S]*\}/);if(l)try{const o=JSON.parse(l[0]);s=o.error?.message??o.message??""}catch{}if(!s){const o=r.lastIndexOf(": ");o>=0&&(s=r.slice(o+2).trim())}return r.includes("402")||/insufficient.?balance/i.test(r)?`⚠ AI service error: ${s||"Insufficient credits"}. Please top up the API balance or contact your administrator.`:r.includes("401")||/unauthorized|invalid.?api.?key/i.test(r)?`⚠ AI service authentication failed: ${s||"Invalid API key"}. Please check the configuration.`:r.includes("429")||/rate.?limit/i.test(r)?`⚠ Rate limit exceeded: ${s||"Too many requests"}. Please wait a moment and try again.`:r.includes("503")||/service.?unavailable/i.test(r)?`⚠ AI service unavailable: ${s||"Service temporarily down"}. Please try again later.`:`⚠ AI service error: ${s||r.slice(0,120)}`}function jy({msg:e,onCopy:r,onRetry:s,isCopied:l}){const o=e.isError||e.sender==="agent"&&e.text.startsWith("⚠"),d=e.isStopped;return t.jsxs("div",{className:"flex items-center gap-0.5 mt-1",children:[t.jsxs("button",{onClick:()=>r(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-fg-tertiary hover:text-fg-primary hover:bg-surface-overlay/60 transition-colors",title:"Copy",children:[l?t.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.jsx("polyline",{points:"20 6 9 17 4 12"})}):t.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),t.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),l?"Copied":"Copy"]}),d&&s&&t.jsxs("button",{onClick:()=>s(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-brand-500 hover:text-brand-500 hover:bg-brand-500/10 transition-colors",title:"Re-ask",children:[t.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("polyline",{points:"23 4 23 10 17 10"}),t.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),"Re-ask"]}),o&&!d&&s&&t.jsxs("button",{onClick:()=>s(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-amber-600 hover:text-amber-600 hover:bg-amber-500/10 transition-colors",title:"Retry",children:[t.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("polyline",{points:"23 4 23 10 17 10"}),t.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),"Retry"]})]})}function iA(e,r){if(!e)return[];const s=[];let l=0;const o=new Date().toISOString(),d=r??"";for(const c of e)c.type==="tool"?(s.push({id:`cseg_${l}`,sourceType:"chat",sourceId:"",agentId:d,seq:l++,type:"tool_start",content:c.tool,metadata:{arguments:c.args},createdAt:o}),c.status!=="running"&&s.push({id:`cseg_${l}`,sourceType:"chat",sourceId:"",agentId:d,seq:l++,type:"tool_end",content:c.tool,metadata:{arguments:c.args,result:c.result,error:c.error,durationMs:c.durationMs,success:c.status!=="error"},createdAt:o})):c.content&&s.push({id:`cseg_${l}`,sourceType:"chat",sourceId:"",agentId:d,seq:l++,type:"text",content:c.content,createdAt:o});return s}function oA({msg:e,isStreaming:r,liveActivities:s,onViewModeChange:l}){const o=e.segments,d=e.isStopped,[c,h]=v.useState("compact"),m=v.useCallback(x=>{h(x),l?.(x)},[l]);if(o!==void 0){const x=o.some(C=>C.type==="tool"),g=iA(o,e.agentId),p=r?o.filter(C=>C.type==="text").map(C=>C.content).join("").slice(-200):void 0,y=o.filter(C=>C.type==="text"),w=r?null:y.map(C=>C.content).join(""),N=!r&&y.length>0?y[y.length-1].content:null,E=c==="compact"?N:w,A=[];if(c==="compact")for(const C of o){if(C.type!=="tool")continue;const k=fj(C.tool,C.result);if(k){A.push({key:`task-${k.taskId}`,kind:"task",info:k});continue}const S=hj(C.tool,C.result);S&&A.push({key:`req-${S.requirementId}`,kind:"req",info:S})}return t.jsxs("div",{className:"space-y-2 min-h-[1em] min-w-0 overflow-hidden",children:[(x||r)&&(c==="compact"?t.jsx(Qd,{entries:g,streamingText:p,isActive:r,onExpand:()=>m("full"),embedded:!0}):t.jsx(Kd,{entries:g,streamingText:p,isActive:r,onCollapse:()=>m("compact"),embedded:!0})),c==="compact"&&A.map(C=>C.kind==="task"?t.jsx(gj,{info:C.info},C.key):t.jsx(pj,{info:C.info},C.key)),c==="compact"&&E&&t.jsx(Zn,{content:E}),d&&t.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5 text-[11px] text-fg-tertiary",children:[t.jsx("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),t.jsx("span",{children:"Stopped"})]})]})}const f=(e.activities?.length??0)>0;return t.jsxs(t.Fragment,{children:[(r||f)&&t.jsx(NT,{activities:r?s:e.activities??[],isActive:r,persistent:!r&&f}),e.text?t.jsx(Zn,{content:e.text}):null,d&&t.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5 text-[11px] text-fg-tertiary",children:[t.jsx("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),t.jsx("span",{children:"Stopped"})]})]})}const wm=new Set;function cA(){return window.location.hash}function dA(e){return wm.add(e),()=>{wm.delete(e)}}typeof window<"u"&&window.addEventListener("hashchange",()=>wm.forEach(e=>e()));function wy({initialAgentId:e,authUser:r}={}){const[s,l]=v.useState([]),[o,d]=v.useState([]),c=ks(),h=v.useSyncExternalStore(dA,cA),m=c&&h.startsWith("#chat/"),f=v.useCallback(()=>{window.location.hash="chat/d"},[]);v.useEffect(()=>{if(!c)return;const ne=()=>{p.current==="profile"&&g("chat")};return window.addEventListener("popstate",ne),()=>window.removeEventListener("popstate",ne)},[c]);const[x,g]=v.useState("chat"),p=v.useRef("chat");p.current=x;const y=Wd({side:"left",defaultWidth:224,minWidth:160,maxWidth:360,storageKey:"markus_chat_sidebar"}),[w,N]=v.useState(null),E=v.useCallback(()=>{g("profile"),c&&history.pushState({mobileProfile:!0},"",window.location.hash)},[c]),A=v.useCallback(ne=>{k("direct"),O(ne),E(),N(null)},[E]),[C,k]=v.useState(()=>e?"direct":localStorage.getItem("markus_chat_mode")??"direct"),[S,O]=v.useState(()=>e??localStorage.getItem("markus_chat_agent")??""),[R,G]=v.useState(()=>localStorage.getItem("markus_chat_channel")??"#general"),[I,Q]=v.useState(""),$=v.useRef(new Map),F=v.useRef(new Map),B=v.useRef(new Set),T=v.useRef(""),[D,z]=v.useState([]),[_,Y]=v.useState(""),[V,J]=v.useState(!1),[U,H]=v.useState([]),[X,L]=v.useState(!1),[M,q]=v.useState(!1),[K,ee]=v.useState([]),te=v.useRef(null),se=v.useRef(null),xe="__new_chat__",[ke,De]=v.useState([]),[ge,ye]=v.useState(null),[Ce,ze]=v.useState(!1),[tt,Xe]=v.useState([]),dt=v.useRef(new Map),wt=v.useRef(new Map),ae=v.useRef(null),Te=v.useRef(null),Ze=v.useRef(null),xt=v.useRef(null),[dn,we]=v.useState([]),[Re,qe]=v.useState([]),[et,nt]=v.useState([]),[zt,Yt]=v.useState([]),[Lt,Tt]=v.useState(null),[qt,yt]=v.useState(!1),[sn,Xt]=v.useState(""),[je,Pe]=v.useState(!1),[vt,Nt]=v.useState(""),[ut,Wt]=v.useState(0),en=C==="channel"?dn.find(ne=>ne.channelKey===R)?.teamId:void 0,Ct=v.useRef(null),de=v.useRef(null),Be=v.useRef(null),Le=v.useRef(void 0),ot=v.useRef(!1),Qe=v.useRef(!0);v.useEffect(()=>{if(!Ce)return;const ne=Z=>{Te.current&&!Te.current.contains(Z.target)&&ae.current&&!ae.current.contains(Z.target)&&ze(!1)};return document.addEventListener("mousedown",ne),()=>document.removeEventListener("mousedown",ne)},[Ce]);const ft=(ne,Z)=>{if(!Z||ne===Z)return`notes:${ne}`;const[oe,me]=[ne,Z].sort();return`dm:${oe}:${me}`},Zt=(ne,Z,oe,me)=>ne==="channel"?`ch:${oe}`:ne==="dm"?`dm:${me??""}`:Z||"_direct",it=v.useCallback((ne,Z)=>{const oe=Z($.current.get(ne)??[]);$.current.set(ne,oe),T.current===ne&&z(oe)},[]),gt=(ne,Z)=>{const oe=[...F.current.get(ne)??[],Z];F.current.set(ne,oe),T.current===ne&&H(oe)};v.useEffect(()=>{localStorage.setItem("markus_chat_mode",C)},[C]),v.useEffect(()=>{localStorage.setItem("markus_chat_agent",S)},[S]),v.useEffect(()=>{localStorage.setItem("markus_chat_channel",R)},[R]);const wn=v.useCallback(()=>re.agents.list().then(ne=>l(ne.agents)).catch(()=>{}),[]),an=v.useCallback(()=>re.teams.list().then(ne=>qe(ne.teams)).catch(()=>{}),[]);v.useEffect(()=>{wn(),re.users.list().then(Ue=>d(Ue.users)).catch(()=>{}),re.tasks.list().then(Ue=>Yt(Ue.tasks)).catch(()=>{}),an(),re.externalAgents.list().then(Ue=>nt(Ue.agents)).catch(()=>{}),fetch("/api/group-chats").then(Ue=>Ue.json()).then(Ue=>we(Ue.chats)).catch(()=>{});const ne=setInterval(wn,8e3),Z=setInterval(an,15e3),oe=kn.on("agent:update",wn),me=kn.on("*",an),Ie=kn.on("chat:group_created",()=>{fetch("/api/group-chats").then(Ue=>Ue.json()).then(Ue=>we(Ue.chats)).catch(()=>{})}),Me=()=>{wn(),an()};return window.addEventListener("markus:data-changed",Me),()=>{clearInterval(ne),clearInterval(Z),oe(),me(),Ie(),window.removeEventListener("markus:data-changed",Me)}},[]),v.useEffect(()=>{const ne=me=>{const Ie=me.detail;(Ie.page==="chat"||Ie.page==="team")&&(Ie.params?.agentId&&(k("direct"),O(Ie.params.agentId)),Ie.params?.selectAgent&&A(Ie.params.selectAgent),Ie.params?.openHire)},Z=localStorage.getItem("markus_nav_agentId");Z&&(localStorage.removeItem("markus_nav_agentId"),k("direct"),O(Z));const oe=localStorage.getItem("markus_nav_selectAgent");return oe&&(localStorage.removeItem("markus_nav_selectAgent"),A(oe)),window.addEventListener("markus:navigate",ne),()=>window.removeEventListener("markus:navigate",ne)},[]);const Qt=v.useRef(!1);v.useEffect(()=>{const ne=de.current;if(!ne)return;const Z=()=>ne.scrollHeight-ne.scrollTop-ne.clientHeight<80,oe=()=>{Qt.current=!0},me=()=>{Qt.current&&Z()?(Qt.current=!1,Qe.current=!0):Qt.current&&(Qe.current=!1)};return ne.addEventListener("wheel",oe,{passive:!0}),ne.addEventListener("touchmove",oe,{passive:!0}),ne.addEventListener("scroll",me,{passive:!0}),()=>{ne.removeEventListener("wheel",oe),ne.removeEventListener("touchmove",oe),ne.removeEventListener("scroll",me)}},[]),v.useLayoutEffect(()=>{if(ot.current){ot.current=!1;return}Qe.current&&Ct.current?.scrollIntoView({behavior:"instant"})},[D,U]);const At=v.useCallback(async ne=>{const Z=`ch:${ne}`;try{const oe=await re.channels.getMessages(ne,50),me=oe.messages.map(ro);$.current.set(Z,me),T.current===Z&&(z(me),L(oe.hasMore),Ze.current=oe.messages[0]?new Date(oe.messages[0].createdAt).toISOString():null)}catch{T.current===Z&&(z([]),L(!1))}},[]),un=v.useCallback(async(ne,Z)=>{xt.current=ne;try{const oe=await re.sessions.getMessages(ne,50),me=oe.messages.map(yy);$.current.set(Z,me),T.current===Z&&xt.current===ne&&(z(me),L(oe.hasMore),Ze.current=oe.messages[0]?new Date(oe.messages[0].createdAt).toISOString():null)}catch{T.current===Z&&xt.current===ne&&(z([]),L(!1),Ze.current=null)}},[]),En=v.useCallback(async ne=>{if(!ne)return De([]),[];try{const{sessions:Z}=await re.sessions.listByAgent(ne,10);return De(Z),Z}catch{return De([]),[]}},[]),fe=v.useCallback(async()=>{if(!(M||!X||!Ze.current)){q(!0);try{const ne=T.current;if(C==="channel"||C==="dm"){const Z=C==="dm"?ft(r?.id??"",I):R,oe=await re.channels.getMessages(Z,50,Ze.current),me=oe.messages.map(ro);ot.current=!0,z(Ie=>{const Me=[...me,...Ie];return $.current.set(ne,Me),Me}),L(oe.hasMore),oe.messages[0]&&(Ze.current=new Date(oe.messages[0].createdAt).toISOString())}else if(ge){const Z=await re.sessions.getMessages(ge,50,Ze.current),oe=Z.messages.map(yy);ot.current=!0,z(me=>{const Ie=[...oe,...me];return $.current.set(ne,Ie),Ie}),L(Z.hasMore),Z.messages[0]&&(Ze.current=new Date(Z.messages[0].createdAt).toISOString())}}catch{}finally{q(!1)}}},[M,X,C,R,ge,r?.id,I]);v.useEffect(()=>{const ne=Zt(C,S,R,I),Z=T.current;T.current=ne,Z&&Z!==ne&&(dt.current.set(Z,tt),wt.current.set(Z,ge));const oe=$.current.get(ne),me=F.current.get(ne)??[],Ie=B.current.has(ne);H(me),J(Ie),C==="direct"&&S&&En(S);const Me=dt.current.get(ne),Ue=wt.current.get(ne);if(Me&&Me.length>0&&Xe(Me),ze(!1),oe!==void 0)z(oe),L(!1),Ue!==void 0&&ye(Ue),(!Me||Me.length===0)&&Xe([]);else if(z([]),L(!1),Ze.current=null,C==="channel"||C==="dm"){const Ve=C==="dm"?ft(r?.id??"",I):R;At(Ve),(!Me||Me.length===0)&&Xe([])}else C==="direct"&&S&&En(S).then(Ve=>{if(T.current===ne)if(Ve.length>0){const Oe=Me&&Me.length>0?Me:Ve.slice(0,5),bt=Ue!==void 0?Ue:Oe[0].id,Gt=bt&&Oe.some(Dt=>Dt.id===bt)?bt:Oe[0].id;ye(Gt),Xe(Oe),un(Gt,ne)}else{ye(null),(!Me||Me.length===0)&&Xe([]);const Oe=(()=>{const bt=(navigator.language||"").toLowerCase();return bt.startsWith("zh")?"介绍一下你自己":bt.startsWith("ja")?"自己紹介をしてください":bt.startsWith("ko")?"자기소개를 해주세요":bt.startsWith("fr")?"Présentez-vous":bt.startsWith("de")?"Stell dich vor":bt.startsWith("es")?"Preséntate":bt.startsWith("pt")?"Apresente-se":bt.startsWith("ru")?"Представьтесь":"Introduce yourself"})();setTimeout(()=>Le.current?.(Oe),150)}})},[C,S,R,I]),v.useEffect(()=>C!=="channel"?void 0:kn.on("chat:message",Z=>{const oe=Z.payload,me=oe.channel??"";if(!me||me!==R)return;const Ie=oe.senderType??"agent",Me=oe.text??oe.message??"",Ue=oe.senderId??oe.agentId??"",Ve=oe.senderName??oe.agentId??"Agent",Oe=oe.metadata,bt={id:`ws_${Date.now()}_${Ue}`,sender:Ie==="human"?"user":"agent",text:Me,time:new Date().toLocaleTimeString(),agentName:Ie==="agent"?Ve:void 0,agentId:Ie==="agent"?Ue:void 0};if(Oe&&Ie==="agent"){const Dt=[];if(Oe.thinking?.length&&Dt.push({type:"text",content:"",thinking:Oe.thinking.join(`
|
|
53
|
+
|
|
54
|
+
`)}),Oe.toolCalls?.length)for(let _n=0;_n<Oe.toolCalls.length;_n++){const at=Oe.toolCalls[_n];Dt.push({type:"tool",key:`${at.tool}_${_n}`,tool:at.tool,status:at.status==="error"?"error":"done",args:at.arguments,result:at.result,durationMs:at.durationMs})}Dt.length>0&&(Dt.push({type:"text",content:Me}),bt.segments=Dt)}const Gt=Zt("channel",S,R,I);it(Gt,Dt=>[...Dt,bt])}),[C,R,S,I,it]),v.useEffect(()=>kn.on("chat:proactive_message",Z=>{const oe=Z.payload,me=oe.agentId??"",Ie=oe.agentName??"Agent",Me=oe.message??"",Ue=oe.sessionId??"";if(!(!me||!Me)&&C==="direct"&&S===me){const Ve={id:`proactive_${Date.now()}`,sender:"agent",text:Me,time:new Date().toLocaleTimeString(),agentName:Ie,agentId:me},Oe=Zt("direct",me,R,I);it(Oe,bt=>[...bt,Ve]),Ue&&ge!==Ue&&ye(Ue)}}),[C,S,R,I,ge,it]),zt.find(ne=>ne.id===Lt),v.useEffect(()=>{Tt(null)},[S]);const Fe=ne=>MT(ne),kt=()=>{Be.current?.abort(),Be.current=null;const ne=T.current;B.current.delete(ne),F.current.delete(ne),J(!1),H([])},St=async ne=>{const Z=(ne??_).trim();if(!Z&&K.length===0||C==="direct"&&!S)return;if(Qe.current=!0,Qt.current=!1,V){Be.current?.abort(),Be.current=null;const Me=T.current;B.current.delete(Me),F.current.delete(Me),it(Me,Ue=>{const Ve=[...Ue];for(let Oe=Ve.length-1;Oe>=0;Oe--)if(Ve[Oe].sender==="agent"&&!Ve[Oe].isStopped&&!Ve[Oe].isError){const bt=Ve[Oe],Gt=(bt.segments??[]).map(Dt=>Dt.type==="tool"&&Dt.status==="running"?{...Dt,status:"stopped"}:Dt);Ve[Oe]={...bt,isStopped:!0,segments:Gt};break}return Ve}),J(!1),H([]),await new Promise(Ue=>setTimeout(Ue,50))}const oe=K.length>0?K.map(Me=>Me.dataUrl):void 0,me=Zt(C,S,R,I);ne||(Y(""),se.current&&(se.current.style.height="auto")),ee([]),Pe(!1);const Ie=C==="dm";if(B.current.add(me),F.current.set(me,[]),T.current===me&&!Ie&&(J(!0),H([])),C==="dm"){const Me=ft(r?.id??"",I),Ue=`opt_${Date.now()}`;it(me,Ve=>[...Ve,{id:Ue,sender:"user",text:Z,time:new Date().toLocaleTimeString()}]);try{const Ve=await re.channels.sendMessage(Me,{text:Z,senderName:r?.name??"You",senderId:r?.id,mentions:[],orgId:"default",humanOnly:!0});it(me,Oe=>{const bt=Oe.filter(Dt=>Dt.id!==Ue),Gt=[];return Ve.userMessage&&Gt.push(ro(Ve.userMessage)),Gt.length>0?[...bt,...Gt]:Oe})}catch(Ve){it(me,Oe=>[...Oe,{id:`err_${Date.now()}`,sender:"agent",text:`Error: ${String(Ve)}`,time:new Date().toLocaleTimeString(),agentName:"System",isError:!0}])}B.current.delete(me),T.current===me&&J(!1)}else if(C==="channel"){const Me=`opt_${Date.now()}`;it(me,Ue=>[...Ue,{id:Me,sender:"user",text:Z,time:new Date().toLocaleTimeString()}]);try{const Ue=Fe(Z),Ve=Ue.length>0?s.find(bt=>bt.name.toLowerCase()===Ue[0].toLowerCase()):null,Oe=await re.channels.sendMessage(R,{text:Z,senderName:r?.name??"You",mentions:Ue,senderId:r?.id,targetAgentId:Ve?.id,orgId:"default"});it(me,bt=>{const Gt=bt.filter(_n=>_n.id!==Me),Dt=[];return Oe.userMessage&&Dt.push(ro(Oe.userMessage)),Oe.agentMessage&&Dt.push(ro(Oe.agentMessage)),Dt.length>0?[...Gt,...Dt]:bt})}catch(Ue){const Ve=vy(Ue)||`Error: ${String(Ue)}`;it(me,Oe=>[...Oe,{id:`err_${Date.now()}`,sender:"agent",text:Ve,time:new Date().toLocaleTimeString(),agentName:"System",isError:!0}])}B.current.delete(me),T.current===me&&J(!1)}else{const Me=`a_${Date.now()}`,Ue={id:`u_${Date.now()}`,sender:"user",text:Z,time:new Date().toLocaleTimeString()};oe?.length&&(Ue.images=oe),it(me,at=>[...at,Ue,{id:Me,sender:"agent",text:"",time:new Date().toLocaleTimeString(),segments:[]}]);const Ve=at=>{it(me,ht=>{const Ye=[...ht],Ke=Ye.findIndex(ds=>ds.id===Me);if(Ke<0)return ht;const Je=Ye[Ke].segments??[],st=Je[Je.length-1];let Ge,rn=at;const sr=at.match(/<think>([\s\S]*?)<\/think>/);sr&&(Ge=(st?.type==="text"?st.thinking??"":"")+sr[1],rn=at.replace(/<think>[\s\S]*?<\/think>/,""));const Es=st?.type==="text"?[...Je.slice(0,-1),{type:"text",content:st.content+rn,thinking:Ge??st.thinking}]:[...Je,{type:"text",content:rn,thinking:Ge}];return Ye[Ke]={...Ye[Ke],text:Ye[Ke].text+rn,segments:Es},Ye})},Oe=at=>{(at.phase==="start"||at.phase==="end")&>(me,{...at,phase:at.phase,ts:Date.now()}),at.phase==="start"?it(me,ht=>{const Ye=[...ht],Ke=Ye.findIndex(Ge=>Ge.id===Me);if(Ke<0)return ht;const Je=[...Ye[Ke].segments??[]];let st=!1;if(at.arguments)for(let Ge=Je.length-1;Ge>=0;Ge--){const rn=Je[Ge];if(rn.type==="tool"&&rn.tool===at.tool&&rn.status==="running"){Je[Ge]={...rn,args:at.arguments},st=!0;break}}if(!st){const Ge=`${at.tool}_${Date.now()}`;Je.push({type:"tool",key:Ge,tool:at.tool,status:"running",args:at.arguments})}return Ye[Ke]={...Ye[Ke],segments:Je},Ye}):at.phase==="output"?it(me,ht=>{const Ye=[...ht],Ke=Ye.findIndex(st=>st.id===Me);if(Ke<0)return ht;const Je=[...Ye[Ke].segments??[]];for(let st=Je.length-1;st>=0;st--){const Ge=Je[st];if(Ge.type==="tool"&&Ge.tool===at.tool&&Ge.status==="running"){Je[st]={...Ge,liveOutput:(Ge.liveOutput??"")+(at.output??"")};break}}return Ye[Ke]={...Ye[Ke],segments:Je},Ye}):at.phase==="subagent_progress"&&at.subagentEvent?it(me,ht=>{const Ye=[...ht],Ke=Ye.findIndex(st=>st.id===Me);if(Ke<0)return ht;const Je=[...Ye[Ke].segments??[]];for(let st=Je.length-1;st>=0;st--){const Ge=Je[st];if(Ge.type==="tool"&&(Ge.tool==="spawn_subagent"||Ge.tool==="spawn_subagents")&&Ge.status==="running"){Je[st]={...Ge,subagentLogs:[...Ge.subagentLogs??[],at.subagentEvent]};break}}return Ye[Ke]={...Ye[Ke],segments:Je},Ye}):it(me,ht=>{const Ye=[...ht],Ke=Ye.findIndex(st=>st.id===Me);if(Ke<0)return ht;const Je=[...Ye[Ke].segments??[]];for(let st=Je.length-1;st>=0;st--){const Ge=Je[st];if(Ge.type==="tool"&&Ge.tool===at.tool&&Ge.status==="running"){Je[st]={...Ge,status:at.success===!1?"error":"done",args:at.arguments,result:at.result,error:at.error,durationMs:at.durationMs,liveOutput:void 0};break}}return Ye[Ke]={...Ye[Ke],segments:Je},Ye})},bt=new AbortController;Be.current=bt;try{const at=ge===xe?null:ge,ht=await re.agents.messageStream(S,Z,Ve,Oe,bt.signal,oe,at);T.current===me&&(ht.sessionId&&(ye(ht.sessionId),Xe(Ye=>Ye.map(Ke=>Ke.id===xe?{...Ke,id:ht.sessionId}:Ke))),En(S).then(Ye=>{if(T.current===me&&(De(Ye),ht.sessionId)){const Ke=Ye.find(Je=>Je.id===ht.sessionId);Ke&&Xe(Je=>Je.some(Ge=>Ge.id===Ke.id)?Je.map(Ge=>Ge.id===Ke.id?Ke:Ge):[Ke,...Je.filter(Ge=>Ge.id!==xe)])}}))}catch(at){const ht=at?.sessionId;ht&&C==="direct"&&T.current===me&&(ye(ht),Xe(Ke=>Ke.map(Je=>Je.id===xe?{...Je,id:ht}:Je)),En(S).then(Ke=>{if(T.current!==me)return;De(Ke);const Je=Ke.find(st=>st.id===ht);Je&&Xe(st=>st.some(rn=>rn.id===Je.id)?st.map(rn=>rn.id===Je.id?Je:rn):[Je,...st])}));const Ye=vy(at);Ye?it(me,Ke=>{const Je=[...Ke],st=Je.findIndex(Ge=>Ge.id===Me);if(st>=0){const Ge=Je[st].segments??[];Je[st]={...Je[st],text:Ye,isError:!0,segments:[...Ge,{type:"text",content:Ye}]}}return Je}):it(me,Ke=>{const Je=[...Ke],st=Je.findIndex(Ge=>Ge.id===Me);if(st>=0){const Ge=Je[st];if(!(Ge.text||Ge.segments&&Ge.segments.length>0&&Ge.segments.some(sr=>sr.type==="text"&&sr.content||sr.type==="tool")))return Ke.filter(sr=>sr.id!==Me);Je[st]={...Ge,isStopped:!0}}return Je})}it(me,at=>{const ht=[...at],Ye=ht.findIndex(Ke=>Ke.id===Me);if(Ye>=0){const Ke=(ht[Ye].segments??[]).map(Je=>Je.type==="tool"&&Je.status==="running"?{...Je,status:"stopped"}:Je);ht[Ye]={...ht[Ye],segments:Ke}}return ht}),bt.signal.aborted&&it(me,at=>{const ht=[...at],Ye=ht.findIndex(Ke=>Ke.id===Me);if(Ye>=0){const Ke=ht[Ye];if(!(Ke.text||Ke.segments&&Ke.segments.length>0&&Ke.segments.some(st=>st.type==="text"&&st.content||st.type==="tool")))return at.filter(st=>st.id!==Me);ht[Ye]={...Ke,isStopped:!0}}return ht});const Dt=($.current.get(me)??[]).find(at=>at.id===Me),_n=ge&&ge!==xe?ge:null;Dt&&!Dt.text&&C==="direct"&&_n&&!bt.signal.aborted&&(async(ht,Ye)=>{for(let Ke=0;Ke<ht;Ke++){await new Promise(Je=>setTimeout(Je,Ye));try{const st=(await re.sessions.getMessages(_n,2)).messages.find(Ge=>Ge.role==="assistant");if(st?.content){it(me,Ge=>{const rn=[...Ge],sr=rn.findIndex(Es=>Es.id===Me);return sr>=0&&(rn[sr]={...rn[sr],text:st.content,segments:[{type:"text",content:st.content}]}),rn});return}}catch{}}})(5,3e3)}Be.current=null,B.current.delete(me),F.current.delete(me),T.current===me&&(J(!1),H([]))};Le.current=St;const[Tn,Qn]=v.useState(null),[hr,or]=v.useState(new Set),tr=v.useCallback(ne=>{const Z=ne.segments?ne.segments.filter(oe=>oe.type==="text").map(oe=>oe.content).join(`
|
|
55
|
+
`):ne.text;navigator.clipboard.writeText(Z),Qn(ne.id),setTimeout(()=>Qn(oe=>oe===ne.id?null:oe),2e3)},[]),cr=v.useCallback(ne=>{const Z=T.current,oe=$.current.get(Z)??D,me=oe.findIndex(Ue=>Ue.id===ne.id);if(me<0)return;const Ie=me>0&&oe[me-1]?.sender==="user"?oe[me-1]:null,Me=Ie?.text??"";Me&&(it(Z,Ue=>Ue.filter(Ve=>Ve.id!==ne.id&&(Ie?Ve.id!==Ie.id:!0))),St(Me))},[D,it]),fn=async ne=>{ye(ne.id),ze(!1),L(!1),Ze.current=null;const Z=T.current;$.current.delete(Z),z([]),Xe(oe=>oe.some(me=>me.id===ne.id)?oe:[...oe,ne]),await un(ne.id,Z)},os=ne=>{if(Xe(Z=>Z.filter(oe=>oe.id!==ne)),ge===ne){const Z=tt.filter(oe=>oe.id!==ne);Z.length>0?fn(Z[Z.length-1]):Sr()}},Sr=()=>{ye(xe);const ne=T.current;$.current.delete(ne),z([]),L(!1),Ze.current=null,ze(!1),Xe(Z=>{const oe=Z.filter(me=>me.id!==xe);return[{id:xe,agentId:S??"",userId:null,title:"New Chat",createdAt:new Date().toISOString(),lastMessageAt:new Date().toISOString()},...oe]})},nr=ne=>{if(Y(ne),C!=="channel"){Pe(!1);return}const Z=ne.lastIndexOf("@");if(Z>=0&&(Z===0||ne[Z-1]===" ")){const me=ne.slice(Z+1).toLowerCase();if(s.some(Me=>Me.name.toLowerCase().includes(me))){Pe(!0),Nt(me),Wt(0);return}}Pe(!1)},rr=ne=>{const Z=_.lastIndexOf("@"),oe=ne.includes(" ")?`@[${ne}]`:`@${ne}`;Y(_.slice(0,Z)+oe+" "),Pe(!1),Wt(0)},Cs=4*1024*1024,ie=5,Se=v.useCallback(ne=>{const Z=Array.from(ne).filter(oe=>oe.type.startsWith("image/"));if(Z.length!==0)for(const oe of Z){if(oe.size>Cs)continue;const me=new FileReader;me.onload=()=>{const Ie=me.result;ee(Me=>Me.length>=ie||Me.some(Ue=>Ue.dataUrl===Ie)?Me:[...Me,{id:`img_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,dataUrl:Ie,name:oe.name}])},me.readAsDataURL(oe)}},[]),He=v.useCallback(ne=>{ee(Z=>Z.filter(oe=>oe.id!==ne))},[]),Mt=v.useCallback(ne=>{const Z=ne.clipboardData?.files;if(Z&&Z.length>0){const oe=Array.from(Z).filter(me=>me.type.startsWith("image/"));oe.length>0&&(ne.preventDefault(),Se(oe))}},[Se]),Gn=v.useCallback(ne=>{ne.preventDefault();const Z=ne.dataTransfer?.files;Z&&Z.length>0&&Se(Array.from(Z).filter(oe=>oe.type.startsWith("image/")))},[Se]),On=v.useCallback(ne=>{ne.preventDefault()},[]),tn=s.find(ne=>ne.id===S),Hr=r?.name??"You",Js=D[D.length-1],mr=V&&Js?.sender==="agent",dr=s.filter(ne=>ne.name.toLowerCase().includes(vt)),Cr=o.find(ne=>ne.id===I),Er=I===r?.id||!I,An=dn.find(ne=>ne.channelKey===R),Tr=C==="channel"?An?.name??R:C==="direct"?tn?.name??"Select Agent":C==="dm"?Er?"My Notes":Cr?.name??"Direct Message":"Chat",cs=C==="channel"?An?`Message ${An.name}…`:`Message ${R}… (use @name to mention)`:C==="dm"?Er?"Write a note to yourself…":`Message ${Cr?.name??""}…`:S?"Type a message…":"Select an agent to start chatting",Kr=c&&m;return t.jsxs("div",{className:"flex-1 overflow-hidden flex",children:[t.jsx(PT,{authUser:r,agents:s,teams:Re,humans:o,tasks:zt,externalAgents:et,groupChats:dn,chatMode:C,selectedAgent:S,activeChannel:R,activeDmUserId:I,onSelectAgent:ne=>{k("direct"),O(ne),g("chat"),c&&f()},onSelectChannel:ne=>{k("channel"),G(ne),g("chat"),c&&f()},onSelectDm:ne=>{k("dm"),Q(ne),g("chat"),c&&f()},onRefreshTeams:an,onRefreshAgents:wn,onViewProfile:A,width:c?void 0:y.width,onResizeStart:c?void 0:y.onResizeStart,hidden:c&&m}),(!c||Kr)&&t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col min-w-0",children:[t.jsxs("div",{className:"border-b border-border-default bg-surface-secondary shrink-0 relative",children:[c?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center px-3 h-11 gap-2",children:[t.jsx("button",{onClick:()=>{window.location.hash="chat"},className:"text-fg-secondary hover:text-fg-primary transition-colors p-1 -ml-1 shrink-0",children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"15 18 9 12 15 6"})})}),t.jsx("span",{className:"font-semibold text-sm truncate min-w-0 flex-1",children:Tr}),C==="direct"&&tn&&t.jsx(Ny,{agent:tn,tasks:zt,onViewProfile:A})]}),t.jsxs("div",{className:"flex items-center px-3 h-9 gap-1 border-t border-border-default/40",children:[t.jsx("button",{onClick:()=>{x==="profile"?history.back():g("chat")},className:`px-2.5 py-1 text-xs font-medium rounded-md transition-colors ${x==="chat"?"bg-brand-500/15 text-brand-500":"text-fg-tertiary"}`,children:"Chat"}),t.jsx("button",{onClick:()=>{x!=="profile"&&E()},className:`px-2.5 py-1 text-xs font-medium rounded-md transition-colors ${x==="profile"?"bg-brand-500/15 text-brand-500":"text-fg-tertiary"}`,children:C==="channel"?"Team":"Profile"}),t.jsx("div",{className:"flex-1"}),C==="direct"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:Sr,className:"text-[11px] text-brand-500 px-2 py-1 rounded-md bg-brand-500/10 font-medium shrink-0",children:"+ New"}),t.jsx("button",{ref:ae,onClick:()=>ze(!Ce),className:`p-1 rounded-md transition-colors shrink-0 ${Ce?"bg-surface-overlay text-fg-primary":"text-fg-tertiary"}`,children:t.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z"})})})]})]})]}):t.jsxs("div",{className:"flex items-center px-6 h-14 gap-3",children:[t.jsx("span",{className:"font-semibold text-sm truncate",children:Tr}),C==="direct"&&tn&&t.jsx(Ny,{agent:tn,tasks:zt,onViewProfile:A}),(C==="channel"||C==="dm")&&t.jsxs("span",{className:"text-xs text-fg-tertiary",children:[D.length," messages"]}),C==="dm"&&t.jsx("span",{className:"text-xs text-fg-tertiary ml-1",children:Er?"· Private notepad":`· Direct message with ${Cr?.name??""}`}),(C==="direct"&&S||C==="channel"&&en)&&t.jsxs("div",{className:"flex items-center gap-0.5 ml-4 -mb-px",children:[t.jsx("button",{onClick:()=>g("chat"),className:`px-3 py-1.5 text-xs font-medium border-b-2 transition-colors ${x==="chat"?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary hover:text-fg-secondary"}`,children:"Chat"}),t.jsx("button",{onClick:()=>g("profile"),className:`px-3 py-1.5 text-xs font-medium border-b-2 transition-colors ${x==="profile"?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary hover:text-fg-secondary"}`,children:C==="channel"?"Team":"Profile"})]}),C==="direct"&&tn&&t.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[t.jsx("button",{onClick:Sr,className:"text-xs text-brand-500 hover:text-brand-500 px-2.5 py-1 rounded-md hover:bg-brand-500/10 border border-brand-500/20 transition-colors flex items-center gap-1",children:"+ New Chat"}),t.jsx("button",{ref:ae,onClick:()=>ze(!Ce),className:`p-1.5 rounded-md transition-colors ${Ce?"bg-surface-overlay text-fg-primary":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,title:"History",children:t.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z"})})})]})]}),C==="direct"&&S&&x==="chat"&&tt.length>0&&t.jsx("div",{className:"flex items-center gap-0 px-3 overflow-x-auto scrollbar-hide border-t border-border-default/50",children:tt.map(ne=>t.jsxs("div",{className:`group flex items-center gap-1.5 px-3 py-1.5 text-xs cursor-pointer border-b-2 transition-colors shrink-0 max-w-[180px] ${ne.id===ge?"border-brand-500 text-brand-500 bg-brand-500/5":"border-transparent text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated/50"}`,onClick:()=>{if(ne.id===xe){ye(xe);const Z=T.current;$.current.delete(Z),z([])}else fn(ne)},children:[t.jsx("span",{className:"truncate",children:ne.id===xe?"New Chat":ne.title||"Conversation"}),t.jsx("button",{onClick:Z=>{Z.stopPropagation(),os(ne.id)},className:"opacity-0 group-hover:opacity-100 text-fg-tertiary hover:text-fg-secondary transition-opacity shrink-0",children:"✕"})]},ne.id))}),C==="direct"&&S&&Ce&&t.jsxs("div",{ref:Te,className:"absolute right-4 top-full mt-1 w-72 max-h-[420px] bg-surface-secondary border border-border-default rounded-xl shadow-2xl shadow-black/40 z-50 flex flex-col overflow-hidden",children:[t.jsxs("div",{className:"px-4 py-3 border-b border-border-default flex items-center justify-between",children:[t.jsx("span",{className:"text-xs font-semibold text-fg-secondary uppercase tracking-wider",children:"History"}),t.jsx("button",{onClick:()=>ze(!1),className:"text-fg-tertiary hover:text-fg-secondary text-xs",children:"✕"})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[ke.length===0&&t.jsx("div",{className:"text-xs text-fg-tertiary text-center py-6",children:"No conversations yet"}),(()=>{const ne=new Date,Z=new Date(ne.getFullYear(),ne.getMonth(),ne.getDate()).getTime(),oe=Z-864e5,me=Z-7*864e5,Ie=[],Me=[],Ue=[],Ve=[],Oe=[];for(const bt of ke){const Gt=new Date(bt.lastMessageAt).getTime();Gt>=Z?Me.push(bt):Gt>=oe?Ue.push(bt):Gt>=me?Ve.push(bt):Oe.push(bt)}return Me.length>0&&Ie.push({label:"Today",items:Me}),Ue.length>0&&Ie.push({label:"Yesterday",items:Ue}),Ve.length>0&&Ie.push({label:"Previous 7 days",items:Ve}),Oe.length>0&&Ie.push({label:"Older",items:Oe}),Ie.map(bt=>t.jsxs("div",{className:"mb-2",children:[t.jsx("div",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider px-3 py-1.5",children:bt.label}),bt.items.map(Gt=>t.jsxs("button",{onClick:()=>{fn(Gt)},className:`w-full text-left px-3 py-2.5 rounded-lg text-xs mb-0.5 transition-colors ${Gt.id===ge?"bg-brand-600/20 text-brand-500":"text-fg-secondary hover:bg-surface-elevated"}`,children:[t.jsx("div",{className:"truncate font-medium",children:Gt.title||"Conversation"}),t.jsx("div",{className:"text-fg-tertiary text-[10px] mt-0.5",children:new Date(Gt.lastMessageAt).toLocaleString()})]},Gt.id))]},bt.label))})()]})]})]}),x==="profile"&&C==="direct"&&S&&t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsx(FT,{agentId:S,onBack:()=>g("chat"),inline:!0})}),x==="profile"&&C==="channel"&&en&&t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsx(rA,{teamId:en,onBack:()=>g("chat"),inline:!0})}),t.jsxs("div",{ref:de,className:`flex-1 overflow-y-auto space-y-3 ${c?"p-2.5":"p-5"} ${x!=="chat"?"hidden":""}`,children:[X&&t.jsx("div",{className:"flex justify-center py-2",children:t.jsx("button",{onClick:()=>{fe()},disabled:M,className:"text-xs text-brand-500 hover:text-brand-500 disabled:opacity-50 px-4 py-1.5 border border-brand-500/30 rounded-lg",children:M?"Loading…":"↑ Load earlier messages"})}),D.length===0&&!V&&t.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-fg-tertiary text-sm space-y-2",children:[t.jsx("div",{className:"opacity-20",children:t.jsx("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:C==="channel"?t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H6l-4 4V6c0-1.1.9-2 2-2z"}),t.jsx("line",{x1:"8",y1:"10",x2:"16",y2:"10"}),t.jsx("line",{x1:"8",y1:"14",x2:"13",y2:"14"})]}):t.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),C==="channel"&&t.jsxs("div",{children:["No messages in ",An?.name??R," yet."]}),C==="direct"&&!S&&t.jsx("div",{children:"Select an agent from the sidebar to start."}),C==="direct"&&S&&t.jsxs("div",{children:["Start a new conversation with ",tn?.name,"."]})]}),C==="channel"?D.map(ne=>t.jsxs("div",{className:"group/msg flex gap-3",children:[t.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center text-xs font-bold shrink-0 cursor-pointer ${ne.sender==="user"?"bg-brand-600 text-white":"bg-brand-500/15 text-brand-600 hover:ring-1 hover:ring-brand-500/40"}`,onClick:Z=>{if(ne.sender==="agent"&&ne.agentId){const oe=Z.currentTarget.getBoundingClientRect();N({agentId:ne.agentId,top:oe.top,left:oe.right+8})}},children:ne.sender==="user"?Hr?.[0]??"Y":ne.agentName?.[0]??"A"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.jsx("span",{className:"text-sm font-medium text-fg-primary",children:ne.sender==="user"?Hr??"You":ne.agentName??"Agent"}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:ne.time})]}),t.jsx("div",{className:ne.isError||ne.sender==="agent"&&ne.text.startsWith("⚠")?"mt-0.5 px-3 py-2 rounded-lg border-b-2 border-red-500/60":"mt-0.5",children:ne.sender==="agent"?t.jsx(Zn,{content:ne.text,className:"text-sm text-fg-secondary"}):t.jsxs("div",{className:"text-sm text-fg-secondary whitespace-pre-wrap",children:[ne.images&&ne.images.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1",children:ne.images.map((Z,oe)=>t.jsx("img",{src:Z,alt:"",className:"max-w-[200px] max-h-[150px] rounded-lg object-cover cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>window.open(Z,"_blank")},oe))}),xy(ne.text,s)]})}),t.jsx("div",{className:"opacity-0 group-hover/msg:opacity-100 transition-opacity",children:t.jsx(jy,{msg:ne,onCopy:tr,onRetry:cr,isCopied:Tn===ne.id})})]})]},ne.id)):D.map((ne,Z)=>{const me=mr&&Z===D.length-1&&V,Ie=!me||ne.isStopped;return t.jsx("div",{className:`group/msg flex ${ne.sender==="user"?"justify-end":"justify-start"}`,children:t.jsxs("div",{className:ne.sender==="agent"&&hr.has(ne.id)?"max-w-full w-full":c?"max-w-[95%]":"max-w-[75%]",children:[t.jsxs("div",{className:"text-xs text-fg-tertiary mb-1",children:[ne.sender==="user"?Hr??"You":t.jsx(aA,{name:ne.agentName??(C==="direct"?tn?.name??"Agent":"Agent"),agentId:ne.agentId??(C==="direct"?tn?.id:void 0),agents:s,onViewProfile:A})," · ",ne.time]}),t.jsx("div",{className:`rounded-2xl text-sm ${c?"px-3 py-2":"px-4 py-3"} ${ne.sender==="user"?"bg-brand-600 text-white rounded-br-sm":ne.isError||ne.sender==="agent"&&ne.text.startsWith("⚠")?"bg-surface-chat-bubble text-fg-primary rounded-bl-sm border-b-2 border-red-500/60":"bg-surface-chat-bubble text-fg-primary rounded-bl-sm"}`,children:ne.sender==="user"?t.jsxs(t.Fragment,{children:[ne.images&&ne.images.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:ne.images.map((Me,Ue)=>t.jsx("img",{src:Me,alt:"",className:"max-w-[200px] max-h-[150px] rounded-lg object-cover cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>window.open(Me,"_blank")},Ue))}),ne.text&&t.jsx("span",{className:"whitespace-pre-wrap leading-relaxed",children:xy(ne.text,s)})]}):t.jsx(oA,{msg:ne,isStreaming:me,liveActivities:me?U:[],onViewModeChange:Me=>or(Ue=>{const Ve=new Set(Ue);return Me==="full"?Ve.add(ne.id):Ve.delete(ne.id),Ve})})}),Ie&&t.jsx("div",{className:`transition-opacity ${ne.isStopped?"opacity-100":"opacity-0 group-hover/msg:opacity-100"} ${ne.sender==="user"?"flex justify-end":""}`,children:t.jsx(jy,{msg:ne,onCopy:tr,onRetry:cr,isCopied:Tn===ne.id})})]})},ne.id)}),C==="channel"&&V&&t.jsx("div",{className:"text-xs text-fg-tertiary animate-pulse ml-11",children:"Agent is thinking…"}),t.jsx("div",{ref:Ct})]}),w&&(()=>{const ne=s.find(Z=>Z.id===w.agentId);return ne?t.jsx(lA,{agent:ne,anchorRect:{top:w.top,left:w.left},onClose:()=>N(null),onViewProfile:A}):null})(),t.jsxs("div",{className:`p-4 border-t border-border-default bg-surface-secondary relative shrink-0 ${x!=="chat"?"hidden":""}`,onDrop:Gn,onDragOver:On,children:[je&&dr.length>0&&t.jsxs("div",{className:"absolute bottom-full left-4 mb-1 bg-surface-elevated border border-border-default rounded-lg shadow-xl overflow-hidden z-10 max-h-48 overflow-y-auto",children:[t.jsx("div",{className:"px-3 py-1.5 text-[10px] text-fg-tertiary font-medium uppercase tracking-wider border-b border-border-default",children:"Mention an agent"}),dr.map((ne,Z)=>t.jsxs("button",{onClick:()=>rr(ne.name),onMouseEnter:()=>Wt(Z),className:`w-full text-left px-4 py-2 text-sm flex items-center gap-2 transition-colors ${Z===ut?"bg-brand-500/15 text-brand-500":"text-fg-secondary hover:bg-surface-overlay"}`,children:[t.jsx("span",{className:"w-6 h-6 rounded-full bg-brand-500/20 flex items-center justify-center text-[10px] font-bold text-brand-500 shrink-0",children:ne.name.slice(0,2).toUpperCase()}),t.jsx("span",{className:"flex-1 min-w-0",children:ne.name}),t.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:ne.role})]},ne.id))]}),K.length>0&&t.jsxs("div",{className:"flex items-center gap-2 mb-2 overflow-x-auto pb-1",children:[K.map(ne=>t.jsxs("div",{className:"relative group/img shrink-0",children:[t.jsx("img",{src:ne.dataUrl,alt:ne.name,className:"w-16 h-16 rounded-lg object-cover border border-border-default"}),t.jsx("button",{onClick:()=>He(ne.id),className:"absolute -top-1.5 -right-1.5 w-5 h-5 bg-surface-secondary border border-gray-600 rounded-full flex items-center justify-center text-fg-secondary hover:text-red-500 hover:border-red-500 text-xs opacity-0 group-hover/img:opacity-100 transition-opacity",children:"×"})]},ne.id)),K.length<ie&&t.jsx("button",{onClick:()=>te.current?.click(),className:"w-16 h-16 rounded-lg border border-dashed border-gray-600 flex items-center justify-center text-fg-tertiary hover:text-fg-secondary hover:border-gray-400 transition-colors shrink-0",title:"Add more images",children:t.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.jsx("path",{d:"M12 5v14M5 12h14"})})})]}),t.jsx("input",{ref:te,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:ne=>{ne.target.files&&Se(ne.target.files),ne.target.value=""}}),t.jsxs("div",{className:"flex gap-2 items-end",children:[t.jsx("button",{onClick:()=>te.current?.click(),disabled:C==="direct"&&!S,className:"px-2.5 py-2.5 text-fg-tertiary hover:text-fg-secondary disabled:opacity-40 transition-colors rounded-xl hover:bg-surface-elevated",title:"Attach images",children:t.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3"}),t.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),t.jsx("path",{d:"M21 15l-5-5L5 21"})]})}),t.jsx("textarea",{ref:se,value:_,onChange:ne=>{nr(ne.target.value),ne.target.style.height="auto";const Z=Math.min(ne.target.scrollHeight,120);ne.target.style.height=`${Z}px`,ne.target.style.overflowY=Z>=120?"auto":"hidden"},onKeyDown:ne=>{if(je&&dr.length>0){const Z=ne.key==="ArrowUp"||ne.ctrlKey&&ne.key==="p",oe=ne.key==="ArrowDown"||ne.ctrlKey&&ne.key==="n",me=ne.key==="Enter"||ne.key==="Tab",Ie=ne.key==="Escape";if(Z){ne.preventDefault(),Wt(Me=>(Me-1+dr.length)%dr.length);return}if(oe){ne.preventDefault(),Wt(Me=>(Me+1)%dr.length);return}if(me){ne.preventDefault();const Me=dr[ut];Me&&rr(Me.name);return}if(Ie){ne.preventDefault(),Pe(!1);return}}ne.key==="Enter"&&!ne.shiftKey&&(ne.preventDefault(),St())},onPaste:Mt,placeholder:cs,disabled:C==="direct"&&!S,rows:1,className:"flex-1 px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm focus:border-brand-500 outline-none disabled:opacity-40 transition-colors resize-none overflow-hidden leading-5",style:{maxHeight:"120px"}}),V&&C!=="dm"&&t.jsx("button",{onClick:kt,className:"px-3 py-2.5 bg-red-600 hover:bg-red-500 text-white text-sm rounded-xl transition-colors flex items-center gap-1.5",title:"Stop agent",children:t.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})})}),t.jsx("button",{onClick:()=>{St()},disabled:C==="direct"&&!S||!_.trim()&&K.length===0,className:"px-5 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-xl transition-colors",children:"Send"})]})]})]})]})}function Ny({agent:e,tasks:r,onViewProfile:s}){const[l,o]=v.useState(!1),[d,c]=v.useState(!1),h=v.useRef(null),m=e.status==="working",f=e.status==="error",x=m?r.find(N=>N.assignedAgentId===e.id&&N.status==="in_progress"):null,g=e.currentActivity;v.useEffect(()=>{if(!l)return;const N=E=>{h.current&&!h.current.contains(E.target)&&o(!1)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[l]);const p=f?"bg-red-400 animate-pulse":m?"bg-blue-400 animate-pulse":"bg-green-400",y=f?"error":m?"working":"idle",w=g?g.type==="heartbeat"?`Heartbeat: ${g.heartbeatName??g.label}`:g.type==="chat"?g.label:g.type==="task"?`Task: ${g.label}`:g.label:"Processing...";return t.jsxs("div",{className:"relative",ref:h,children:[t.jsxs("button",{onClick:()=>o(N=>!N),className:`flex items-center gap-1.5 px-2 py-0.5 rounded-full transition-colors ${m?"bg-amber-500/10 border border-amber-500/20 hover:bg-amber-500/20":f?"bg-red-500/10 border border-red-500/20 hover:bg-red-500/20":"bg-green-500/10 border border-green-500/20 hover:bg-green-500/20"}`,children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${p}`}),t.jsx("span",{className:`text-xs ${f?"text-red-500":m?"text-amber-600":"text-green-600"}`,children:y})]}),l&&f&&t.jsxs("div",{className:"absolute top-full left-0 mt-1.5 bg-surface-secondary border border-red-500/30 rounded-xl shadow-2xl z-30 w-80 p-3 space-y-2",children:[t.jsx("p",{className:"text-[10px] text-red-500 uppercase font-semibold",children:"Error Details"}),t.jsxs("div",{className:"bg-red-500/10 border border-red-500/20 rounded-lg p-2.5",children:[t.jsx("pre",{className:"text-[10px] text-red-500/80 leading-relaxed whitespace-pre-wrap break-all font-mono line-clamp-6",children:e.lastError||"Agent encountered an error. Check profile for details."}),e.lastErrorAt&&t.jsx("div",{className:"text-[9px] text-red-500/50 mt-1.5 border-t border-red-500/10 pt-1",children:new Date(e.lastErrorAt).toLocaleString()})]}),t.jsx("button",{onClick:()=>{o(!1),s?.(e.id)},className:"w-full text-center text-[10px] text-red-500 hover:text-red-500 border border-red-500/30 hover:border-red-500/50 rounded-lg py-1 transition-colors",children:"View Agent Profile →"})]}),l&&m&&t.jsxs("div",{className:"absolute top-full left-0 mt-1.5 bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-30 w-80 p-3 space-y-2",children:[t.jsx("p",{className:"text-[10px] text-fg-tertiary uppercase font-semibold",children:"Current Activity"}),x?t.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-brand-500/10 border border-brand-500/30 cursor-pointer hover:bg-brand-500/10 transition-colors",onClick:()=>{o(!1),jt.navigate("tasks",{openTask:x.id})},children:[t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-400 animate-pulse shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs text-brand-500 truncate",children:x.title}),t.jsx("div",{className:"text-[10px] text-fg-tertiary",children:"Working on task · Click to view"})]}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:"→"})]}):t.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-surface-elevated/50",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${g?.type==="heartbeat"||g?.type==="chat","bg-blue-400 animate-pulse"}`}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs text-fg-secondary",children:w}),t.jsx("div",{className:"text-[10px] text-fg-tertiary",children:g?.type==="heartbeat"?"Periodic check-in task":g?.type==="chat"?"Responding to conversation":"Agent is thinking or communicating"})]})]}),t.jsx("button",{onClick:()=>{o(!1),c(!0)},className:"w-full text-center text-[10px] text-brand-500 hover:text-brand-500 border border-border-default hover:border-gray-600 rounded-lg py-1.5 transition-colors",children:"View Execution Log →"})]}),d&&t.jsx(uA,{agent:e,currentTask:x,onClose:()=>c(!1),onGoToTask:x?()=>{c(!1),jt.navigate("tasks",{openTask:x.id})}:void 0})]})}function ky({entries:e,isActive:r,showRounds:s}){const[l,o]=v.useState("compact");return e.length===0?null:l==="compact"?t.jsx(Qd,{entries:e,isActive:r,onExpand:()=>o("full"),showRounds:s}):t.jsx(Kd,{entries:e,isActive:r,onCollapse:()=>o("compact"),showRounds:s})}function uA({agent:e,currentTask:r,onClose:s,onGoToTask:l}){const o=e.currentActivity,[d,c]=v.useState([]),[h,m]=v.useState([]),[f,x]=v.useState(!0),g=v.useRef(null),p=v.useRef(null),y=v.useRef(!0);v.useEffect(()=>{const C=p.current;if(!C)return;const k=()=>{y.current=C.scrollHeight-C.scrollTop-C.clientHeight<80};return C.addEventListener("scroll",k,{passive:!0}),()=>C.removeEventListener("scroll",k)},[]);const w=r?.id,N=o?.id;v.useEffect(()=>{x(!0),w?re.tasks.getLogs(w).then(C=>{c(C.logs),x(!1)}).catch(()=>x(!1)):N?re.agents.getActivityLogs(e.id,N).then(C=>{m(C.logs),x(!1)}).catch(()=>x(!1)):x(!1)},[e.id,N,w]),v.useEffect(()=>w?kn.on("task:log",k=>{const S=k.payload;if(S.taskId!==w)return;const O={id:S.id,taskId:S.taskId,agentId:S.agentId,seq:S.seq,type:S.logType,content:S.content,metadata:S.metadata,createdAt:S.createdAt};c(R=>O.id&&R.some(G=>G.id===O.id)?R:[...R,O])}):void 0,[w]),v.useEffect(()=>!N||w?void 0:kn.on("agent:activity_log",k=>{const S=k.payload;if(S.agentId!==e.id||S.activityId!==N)return;const O={seq:S.seq,type:S.type,content:S.content,metadata:S.metadata,createdAt:S.createdAt};m(R=>R.some(G=>G.seq===O.seq)?R:[...R,O])}),[e.id,N,w]),v.useEffect(()=>{y.current&&g.current?.scrollIntoView({behavior:"smooth"})},[d,h]);const E=o?.type==="heartbeat"?"Heartbeat Task":o?.type==="chat"?"Chat Response":o?.type==="task"?"Task Execution":"Processing",A=o?.type==="heartbeat"||o?.type==="chat"?"text-blue-600":"text-brand-500";return t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:s,children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl w-[780px] max-w-[95vw] max-h-[75vh] flex flex-col shadow-2xl",onClick:C=>C.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5 border-b border-border-default",children:[t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${o?.type==="heartbeat"||o?.type==="chat","bg-blue-400 animate-pulse"}`}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-medium",children:e.name}),t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded-full border ${A} border-current/20 bg-current/5`,children:E})]}),t.jsx("div",{className:"text-xs text-fg-secondary truncate mt-0.5",children:o?.label??r?.title??"Processing..."}),o?.startedAt&&t.jsxs("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:["Started ",new Date(o.startedAt).toLocaleTimeString()]})]})]}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[l&&t.jsx("button",{onClick:l,className:"px-2.5 py-1 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors",children:"Go to Task →"}),t.jsx("button",{onClick:s,className:"text-fg-tertiary hover:text-fg-secondary text-lg leading-none px-1",children:"×"})]})]}),t.jsxs("div",{ref:p,className:"flex-1 overflow-y-auto p-4",children:[f?t.jsx("div",{className:"text-center py-8 text-xs text-fg-tertiary",children:"Loading logs…"}):r&&d.length>0?t.jsx(ky,{entries:d.map(C=>jd(C)),isActive:e.status==="working",showRounds:new Set(d.filter(C=>C.executionRound!=null).map(C=>C.executionRound)).size>1}):h.length>0?t.jsx(ky,{entries:h.map(C=>a1(C,o?.id??"",e.id)).filter(C=>C!==null),isActive:e.status==="working"}):e.status==="working"?t.jsxs("div",{className:"text-center py-8 space-y-2",children:[t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Agent just started processing..."}),t.jsx("div",{className:"text-[10px] text-fg-tertiary",children:"Execution logs will appear here as the agent makes progress."})]}):t.jsx("div",{className:"text-center py-8 text-xs text-fg-tertiary",children:"No execution logs available."}),t.jsx("div",{ref:g})]})]})})}function kj({theme:e,onThemeChange:r}={}){const[s,l]=v.useState(null),[o,d]=v.useState(null),[c,h]=v.useState(""),[m,f]=v.useState(!1),[x,g]=v.useState(null),[p,y]=v.useState(null),[w,N]=v.useState(null),[E,A]=v.useState(null),[C,k]=v.useState(!1),[S,O]=v.useState(null),[R,G]=v.useState(null),[I,Q]=v.useState(!1),[$,F]=v.useState(null),[B,T]=v.useState({}),[D,z]=v.useState(!1),[_,Y]=v.useState([]),[V,J]=v.useState([]),[U,H]=v.useState(null),[X,L]=v.useState(null),[M,q]=v.useState(""),[K,ee]=v.useState(null),te=v.useRef(null),se=v.useRef(!1),[xe,ke]=v.useState(!1),[De,ge]=v.useState(200),[ye,Ce]=v.useState(!1),[ze,tt]=v.useState(null),[Xe,dt]=v.useState(null),[wt,ae]=v.useState(!1),[Te,Ze]=v.useState(new Set),[xt,dn]=v.useState(null),[we,Re]=v.useState(!1),qe=()=>({"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("markus_token")??""}`}),et=v.useCallback(()=>{re.health().then(l).catch(()=>{}),fetch("/api/settings/llm").then(ie=>ie.ok?ie.json():Promise.reject(ie.status)).then(ie=>{ie&&typeof ie=="object"&&"providers"in ie&&(d(ie),h(ie.defaultProvider))}).catch(()=>{})},[]),nt=v.useCallback(()=>{fetch("/api/settings/oauth/providers").then(ie=>ie.ok?ie.json():Promise.reject(ie.status)).then(ie=>Y(ie.providers??[])).catch(()=>{})},[]),zt=v.useCallback(()=>{fetch("/api/settings/oauth/profiles",{headers:qe()}).then(ie=>ie.ok?ie.json():Promise.reject(ie.status)).then(ie=>J(ie.profiles??[])).catch(()=>{})},[]),Yt=v.useCallback(()=>{re.settings.getAgent().then(ie=>{ie&&typeof ie.maxToolIterations=="number"&&ge(ie.maxToolIterations)}).catch(()=>{})},[]),Lt=v.useCallback(()=>{ae(!0),re.system.storage().then(dt).catch(()=>{}).finally(()=>ae(!1)),re.system.orphans().then(dn).catch(()=>{})},[]);v.useEffect(()=>{et(),nt(),zt(),Yt(),Lt()},[et,nt,zt,Yt,Lt]),v.useEffect(()=>{const ie=()=>Lt();return window.addEventListener("markus:data-changed",ie),()=>window.removeEventListener("markus:data-changed",ie)},[Lt]);const Tt=v.useCallback(async()=>{Q(!0),F(null),G(null),T({});try{const ie=await fetch("/api/settings/env-models",{headers:qe()});if(!ie.ok){F({type:"err",text:`Detection failed (HTTP ${ie.status})`});return}const Se=await ie.json();if(G(Se),Se.detected.length===0)F({type:"err",text:"No model API keys found in environment variables"});else{const He={};for(const Mt of Se.detected)He[Mt.provider]=!0;T(He)}}catch{F({type:"err",text:"Failed to detect environment variables"})}finally{Q(!1)}},[]),qt=o?Object.values(o.providers).some(ie=>ie.configured):!1;v.useEffect(()=>{o&&!qt&&!se.current&&(se.current=!0,Tt())},[o,qt,Tt]);const yt=async()=>{if(!(!c||c===o?.defaultProvider)){f(!0),g(null);try{const ie=await fetch("/api/settings/llm",{method:"POST",headers:qe(),body:JSON.stringify({defaultProvider:c})}),Se=await ie.json();ie.ok?(d(Se),g({type:"ok",text:`Default provider updated to ${Se.defaultProvider}`})):g({type:"err",text:Se.error??"Save failed"})}catch{g({type:"err",text:"Network error"})}finally{f(!1)}}},sn=async(ie,Se)=>{N(ie);try{const He=await fetch(`/api/settings/llm/providers/${ie}/toggle`,{method:"POST",headers:qe(),body:JSON.stringify({enabled:Se})});if(He.ok){const Mt=await He.json();d(Mt)}}catch{}finally{N(null)}},Xt=async()=>{k(!0),O(null);try{const Se=await(await fetch("/api/settings/import/openclaw",{method:"POST",headers:qe(),body:JSON.stringify({preview:!0})})).json();"error"in Se?O({type:"err",text:Se.error}):A(Se)}catch{O({type:"err",text:"Detection failed"})}finally{k(!1)}},je=async()=>{k(!0),O(null);try{const Se=await(await fetch("/api/settings/import/openclaw",{method:"POST",headers:qe(),body:JSON.stringify({preview:!1})})).json();"error"in Se?O({type:"err",text:Se.error}):(O({type:"ok",text:`Imported ${Se.appliedModels} model configs from OpenClaw`}),et())}catch{O({type:"err",text:"Import failed"})}finally{k(!1)}},Pe=async()=>{if(!R)return;const ie=R.detected.filter(Se=>B[Se.provider]);if(ie.length===0){F({type:"err",text:"Select at least one provider to apply"});return}z(!0),F(null);try{const Se=await fetch("/api/settings/env-models",{method:"POST",headers:qe(),body:JSON.stringify({providers:ie.map(Mt=>({provider:Mt.provider,model:Mt.model,baseUrl:Mt.baseUrl,enabled:!0}))})});if(!Se.ok){F({type:"err",text:`Apply failed (HTTP ${Se.status})`});return}const He=await Se.json();F({type:"ok",text:He.message}),G(null),T({}),et()}catch{F({type:"err",text:"Failed to apply environment configs"})}finally{z(!1)}},vt=async ie=>{H(ie),L(null);try{const Se=await fetch("/api/settings/oauth/login",{method:"POST",headers:qe(),body:JSON.stringify({provider:ie})}),He=await Se.json();if(!Se.ok||He.error){L({type:"err",text:He.error??"Login failed"});return}He.authorizeUrl&&(window.open(He.authorizeUrl,"_blank","noopener"),ee(ie),L({type:"ok",text:"Browser opened for authorization. Complete the login in the browser window..."}),te.current&&clearInterval(te.current),te.current=setInterval(async()=>{try{const Gn=await(await fetch(`/api/settings/oauth/status?provider=${ie}`,{headers:qe()})).json();!Gn.pending&&Gn.profiles.some(On=>On.provider===ie&&On.hasOAuth)&&(te.current&&clearInterval(te.current),te.current=null,ee(null),J(Gn.profiles),L({type:"ok",text:`Connected to ${ie} via OAuth`}),et())}catch{}},2e3))}catch{L({type:"err",text:"Network error during OAuth login"})}finally{H(null)}},Nt=async()=>{if(M.trim()){H("manual"),L(null);try{const ie=await fetch("/api/settings/oauth/callback",{method:"POST",headers:qe(),body:JSON.stringify({callbackUrl:M})}),Se=await ie.json();if(!ie.ok||Se.error){L({type:"err",text:Se.error??"Callback failed"});return}L({type:"ok",text:`Connected to ${Se.profile?.provider??"provider"} via OAuth`}),q(""),ee(null),te.current&&(clearInterval(te.current),te.current=null),zt(),et()}catch{L({type:"err",text:"Network error"})}finally{H(null)}}},ut=async ie=>{try{(await fetch(`/api/settings/oauth/profiles/${encodeURIComponent(ie)}`,{method:"DELETE",headers:qe()})).ok&&(zt(),et(),L({type:"ok",text:"Auth profile deleted"}))}catch{}};v.useEffect(()=>()=>{te.current&&clearInterval(te.current)},[]);const[Wt,en]=v.useState(!1),[Ct,de]=v.useState({name:"",apiKey:"",baseUrl:"",model:""}),[Be,Le]=v.useState(!1),[ot,Qe]=v.useState(null),[ft,Zt]=v.useState(null),[it,gt]=v.useState({apiKey:"",baseUrl:"",model:""}),[wn,an]=v.useState(!1),[Qt,At]=v.useState(null),[un,En]=v.useState(null),[fe,Fe]=v.useState({id:"",name:"",contextWindow:128e3,maxOutputTokens:16384,costInput:1,costOutput:5,reasoning:!1,vision:!1}),[kt,St]=v.useState(!1),Tn=async()=>{if(!(!Ct.name||!Ct.model)){Le(!0),Qe(null);try{const ie=await fetch("/api/settings/llm/providers",{method:"POST",headers:qe(),body:JSON.stringify({name:Ct.name,apiKey:Ct.apiKey||void 0,baseUrl:Ct.baseUrl||void 0,model:Ct.model})}),Se=await ie.json();ie.ok?(d(Se),en(!1),de({name:"",apiKey:"",baseUrl:"",model:""}),Qe({type:"ok",text:`Provider ${Ct.name} added`})):Qe({type:"err",text:Se.error??"Failed to add"})}catch{Qe({type:"err",text:"Network error"})}finally{Le(!1)}}},Qn=(ie,Se)=>{Zt(ie),gt({apiKey:"",baseUrl:Se.baseUrl??"",model:Se.model})},hr=async ie=>{an(!0);try{const Se={};it.apiKey&&(Se.apiKey=it.apiKey),it.baseUrl!==void 0&&(Se.baseUrl=it.baseUrl),it.model&&(Se.model=it.model);const He=await fetch(`/api/settings/llm/providers/${ie}`,{method:"PUT",headers:qe(),body:JSON.stringify(Se)});if(He.ok){const Mt=await He.json();d(Mt),Zt(null)}}catch{}finally{an(!1)}},or=async ie=>{At(ie);try{const Se=await fetch(`/api/settings/llm/providers/${ie}`,{method:"DELETE",headers:qe()});if(Se.ok){const He=await Se.json();d(He),h(He.defaultProvider)}}catch{}finally{At(null)}},tr=async ie=>{if(!(!fe.id||!fe.name)){St(!0);try{const Se=await fetch(`/api/settings/llm/providers/${ie}/models`,{method:"POST",headers:qe(),body:JSON.stringify({id:fe.id,name:fe.name,contextWindow:fe.contextWindow,maxOutputTokens:fe.maxOutputTokens,cost:{input:fe.costInput,output:fe.costOutput},reasoning:fe.reasoning||void 0,inputTypes:fe.vision?["text","image"]:["text"]})});if(Se.ok){const He=await Se.json();d(He),En(null),Fe({id:"",name:"",contextWindow:128e3,maxOutputTokens:16384,costInput:1,costOutput:5,reasoning:!1,vision:!1})}}catch{}finally{St(!1)}}},cr=async(ie,Se)=>{try{const He=await fetch(`/api/settings/llm/providers/${ie}/models/${encodeURIComponent(Se)}`,{method:"DELETE",headers:qe()});if(He.ok){const Mt=await He.json();d(Mt)}}catch{}},fn=new Set(["claude-opus-4-6","claude-sonnet-4-20250514","claude-3-5-haiku-20241022","gpt-5.4","gpt-4o","o4-mini","gemini-3-1-pro","gemini-2.5-flash","MiniMax-M2.7","MiniMax-M2.5","xiaomi/mimo-v2-pro","anthropic/claude-opus-4-6","openai/gpt-5.4","google/gemini-3-1-pro"]),[os,Sr]=v.useState(null),nr=async(ie,Se)=>{Sr(`${ie}:${Se}`);try{const He=await fetch(`/api/settings/llm/providers/${ie}/model`,{method:"POST",headers:qe(),body:JSON.stringify({model:Se})});if(He.ok){const Mt=await He.json();d(Mt)}}catch{}finally{Sr(null)}},rr=o?.providers?Object.entries(o.providers).filter(([,ie])=>ie.configured&&ie.enabled).map(([ie])=>ie):[],Cs=o&&!qt&&!xe;return t.jsxs("div",{className:"flex-1 overflow-y-auto",children:[t.jsx("div",{className:"px-6 h-14 flex items-center border-b border-border-default bg-surface-secondary",children:t.jsx("h2",{className:"text-lg font-semibold",children:"Settings"})}),t.jsxs("div",{className:"p-7 space-y-10 max-w-4xl",children:[t.jsx(qs,{title:"Appearance",children:t.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium",children:"Theme"}),t.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:"Choose light, dark, or follow your system preference"})]}),t.jsx("div",{className:"flex gap-1 bg-surface-elevated rounded-lg p-0.5",children:[["system","System"],["light","Light"],["dark","Dark"]].map(([ie,Se])=>t.jsx("button",{onClick:()=>r?.(ie),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${e===ie?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary"}`,children:Se},ie))})]})})}),Cs&&t.jsxs("div",{className:"relative bg-gradient-to-br from-brand-500/10 to-surface-secondary border border-brand-500/20 rounded-2xl p-6 space-y-5",children:[t.jsx("button",{onClick:()=>ke(!0),className:"absolute top-4 right-4 text-fg-tertiary hover:text-fg-secondary text-xs",children:"Skip"}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:"Welcome — Configure Your LLM"}),t.jsx("p",{className:"text-sm text-fg-secondary mt-1",children:"Markus needs at least one LLM provider to work. Choose a way to get started:"})]}),t.jsxs(Ih,{step:"1",title:"From Environment Variables",description:"Automatically detected API keys from .env or system environment.",active:!!(R&&R.detected.length>0),children:[I&&t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Detecting..."}),R&&R.detected.length>0&&t.jsxs("div",{className:"space-y-2",children:[R.detected.map(ie=>t.jsxs("label",{className:"flex items-center gap-3 bg-surface-elevated/30 rounded-lg px-3 py-2 cursor-pointer hover:bg-surface-elevated/50 transition-colors",children:[t.jsx("input",{type:"checkbox",checked:B[ie.provider]??!1,onChange:Se=>T({...B,[ie.provider]:Se.target.checked}),className:"w-4 h-4 rounded bg-surface-overlay border-gray-600 text-brand-500 focus:ring-brand-500"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-fg-primary",children:ie.displayName}),t.jsx("span",{className:"text-xs text-fg-tertiary ml-2",children:ie.model})]}),t.jsx("code",{className:"text-[10px] text-fg-tertiary",children:ie.apiKeyPreview})]},ie.provider)),t.jsx("button",{onClick:()=>{Pe()},disabled:D||Object.values(B).filter(Boolean).length===0,className:"w-full px-4 py-2 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-lg transition-colors",children:D?"Applying...":`Apply ${Object.values(B).filter(Boolean).length} Provider(s)`})]}),R&&R.detected.length===0&&t.jsxs("div",{className:"text-xs text-fg-tertiary",children:["No API keys found. Set environment variables like ",t.jsx("code",{className:"text-fg-secondary",children:"ANTHROPIC_API_KEY"})," or ",t.jsx("code",{className:"text-fg-secondary",children:"OPENAI_API_KEY"})," and restart the server."]}),$&&t.jsx(Na,{type:$.type,text:$.text})]}),t.jsxs(Ih,{step:"2",title:"From OpenClaw Config",description:"Import model configs from an existing OpenClaw installation.",children:[E?E.found?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"text-xs text-green-600",children:["Found: ",t.jsx("code",{className:"text-fg-secondary",children:E.summary.configPath})]}),E.summary.models&&t.jsxs("div",{className:"text-xs text-fg-secondary",children:[E.summary.models.providerCount," providers, ",E.summary.models.providers.reduce((ie,Se)=>ie+Se.modelCount,0)," models"]}),t.jsx("button",{onClick:()=>{je()},disabled:C,className:"w-full px-4 py-2 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-lg transition-colors",children:C?"Importing...":"Import Model Configs"})]}):t.jsx("div",{className:"text-xs text-fg-tertiary",children:"No OpenClaw config found."}):t.jsx("button",{onClick:()=>{Xt()},disabled:C,className:"px-4 py-2 border border-border-default hover:bg-surface-elevated disabled:opacity-40 text-fg-secondary text-sm rounded-lg transition-colors",children:C?"Detecting...":"Detect OpenClaw"}),S&&t.jsx(Na,{type:S.type,text:S.text})]}),t.jsx(Ih,{step:"3",title:"Manual Configuration",description:t.jsxs(t.Fragment,{children:["Edit ",t.jsx("code",{className:"text-fg-secondary",children:"~/.markus/markus.json"})," directly, then restart the server."]})})]}),t.jsx(qs,{title:"System Status",children:s?t.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[t.jsx($h,{label:"Status",value:s.status==="ok"?"Healthy":s.status,color:"green"}),t.jsx($h,{label:"Version",value:s.version,color:"indigo"}),t.jsx($h,{label:"Active Agents",value:String(s.agents),color:"purple"})]}):t.jsx("div",{className:"text-sm text-fg-tertiary",children:"Loading..."})}),t.jsx(qs,{title:"Default LLM Provider",children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium",children:"Primary Provider"}),t.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:"Used for all agent interactions unless overridden"})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[o?t.jsx("select",{value:c,onChange:ie=>{h(ie.target.value),g(null)},className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm w-48 focus:border-brand-500 outline-none",children:rr.length>0?rr.map(ie=>t.jsx("option",{value:ie,children:o.providers[ie]?.displayName??ie},ie)):t.jsx("option",{value:"",children:"No providers configured"})}):t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Loading..."}),c!==o?.defaultProvider&&t.jsx("button",{onClick:()=>{yt()},disabled:m,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white rounded-lg transition-colors",children:m?"Saving...":"Save"})]})]}),x&&t.jsx(Na,{type:x.type,text:x.text})]})}),_.length>0&&t.jsx(qs,{title:"OAuth Authentication",children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 space-y-5",children:[t.jsx("div",{className:"text-sm text-fg-secondary",children:"Connect to LLM providers using your existing subscription via OAuth. No API key required."}),t.jsx("div",{className:"space-y-3",children:_.map(ie=>{const Se=V.find(Mt=>Mt.provider===ie.name&&Mt.hasOAuth),He=K===ie.name;return t.jsxs("div",{className:"flex items-center justify-between bg-surface-elevated/30 rounded-lg px-4 py-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${Se?"bg-green-400":"bg-gray-600"}`}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:ie.displayName}),Se&&t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:[Se.accountId&&t.jsxs("span",{children:["Account: ",Se.accountId]}),Se.oauthExpired&&t.jsx("span",{className:"text-amber-500 ml-2",children:"Token expired"}),!Se.oauthExpired&&t.jsx("span",{className:"text-green-600 ml-2",children:"Connected"})]})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[Se&&t.jsx("button",{onClick:()=>{ut(Se.id)},className:"px-2 py-1 text-xs text-red-400 hover:text-red-300 hover:bg-red-500/10 rounded transition-colors",title:"Disconnect",children:"Disconnect"}),t.jsx("button",{onClick:()=>{vt(ie.name)},disabled:U===ie.name||He,className:`px-4 py-1.5 text-xs rounded-lg transition-colors ${Se?"border border-border-default text-fg-secondary hover:bg-surface-elevated":"bg-brand-600 hover:bg-brand-500 text-white"} disabled:opacity-40`,children:U===ie.name?"Starting...":He?"Waiting...":Se?"Reconnect":"Connect"})]})]},ie.name)})}),K&&t.jsxs("div",{className:"border-t border-border-default pt-4 space-y-3",children:[t.jsx("div",{className:"text-xs text-fg-tertiary",children:"If the browser didn't open or you're on a remote machine, paste the redirect URL here:"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{type:"text",value:M,onChange:ie=>q(ie.target.value),placeholder:"http://localhost:1455/auth/callback?code=...&state=...",className:"flex-1 px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"}),t.jsx("button",{onClick:()=>{Nt()},disabled:!M.trim()||U==="manual",className:"px-4 py-2 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-xs rounded-lg transition-colors",children:U==="manual"?"Processing...":"Submit"})]})]}),V.length>0&&t.jsxs("div",{className:"border-t border-border-default pt-4 space-y-2",children:[t.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:"Auth Profiles"}),V.map(ie=>t.jsxs("div",{className:"flex items-center justify-between text-xs px-3 py-2 bg-surface-elevated/20 rounded-lg",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${ie.hasOAuth&&!ie.oauthExpired?"bg-green-400":ie.oauthExpired?"bg-amber-400":"bg-gray-500"}`}),t.jsx("span",{className:"text-fg-secondary",children:ie.label??ie.id}),t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-surface-overlay text-fg-tertiary",children:ie.authType})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[ie.accountId&&t.jsx("span",{className:"text-fg-tertiary",children:ie.accountId}),t.jsx("span",{className:"text-fg-tertiary",children:new Date(ie.updatedAt).toLocaleDateString()}),t.jsx("button",{onClick:()=>{ut(ie.id)},className:"text-red-400 hover:text-red-300 transition-colors",title:"Delete",children:t.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})]},ie.id))]}),X&&t.jsx(Na,{type:X.type,text:X.text})]})}),t.jsxs(qs,{title:"Model Providers & Pricing",children:[t.jsx("div",{className:"space-y-3",children:o&&Object.entries(o.providers).map(([ie,Se])=>t.jsxs("div",{className:`bg-surface-secondary border rounded-xl overflow-hidden transition-colors ${Se.configured?"border-border-default hover:border-gray-600":"border-border-default/50 opacity-60"}`,children:[t.jsxs("div",{className:"flex items-center justify-between px-5 py-4 cursor-pointer",onClick:()=>y(p===ie?null:ie),children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${Se.configured&&Se.enabled?"bg-green-400":Se.configured?"bg-amber-400":"bg-gray-600"}`}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-medium",children:Se.displayName??ie}),ie===o.defaultProvider&&t.jsx("span",{className:"text-[10px] bg-brand-500/15 text-brand-500 px-1.5 py-0.5 rounded",children:"default"}),Se.configured&&!Se.enabled&&t.jsx("span",{className:"text-[10px] bg-amber-500/15 text-amber-600 px-1.5 py-0.5 rounded",children:"disabled"}),Se.oauthConnected&&t.jsx("span",{className:"text-[10px] bg-green-500/15 text-green-600 px-1.5 py-0.5 rounded",children:"OAuth"})]}),t.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:Se.model||"Not configured"})]})]}),t.jsxs("div",{className:"flex items-center gap-4",children:[Se.configured&&t.jsx("button",{onClick:He=>{He.stopPropagation(),sn(ie,!Se.enabled)},disabled:w===ie,className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${Se.enabled?"bg-green-500":"bg-gray-600"} ${w===ie?"opacity-50":""}`,title:Se.enabled?"Click to disable":"Click to enable",children:t.jsx("span",{className:`inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform ${Se.enabled?"translate-x-4":"translate-x-1"}`})}),Se.contextWindow&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[(Se.contextWindow/1e3).toFixed(0),"K ctx"]}),Se.cost&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["$",Se.cost.input,"/",Se.cost.output," per 1M"]}),t.jsx("span",{className:"text-fg-tertiary text-xs",children:p===ie?"▲":"▼"})]})]}),p===ie&&t.jsxs("div",{className:"px-5 pb-4 border-t border-border-default pt-4 space-y-4",children:[Se.configured&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[t.jsx(ka,{label:"Model",value:Se.model}),t.jsx(ka,{label:"Context Window",value:Se.contextWindow?`${(Se.contextWindow/1e3).toFixed(0)}K tokens`:"N/A"}),t.jsx(ka,{label:"Max Output",value:Se.maxOutputTokens?`${(Se.maxOutputTokens/1e3).toFixed(0)}K tokens`:"N/A"}),t.jsx(ka,{label:"Base URL",value:Se.baseUrl??"Default"})]}),ft===ie?t.jsxs("div",{className:"bg-surface-elevated/40 rounded-lg p-4 space-y-3",children:[t.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:"Edit Provider"}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"API Key"}),t.jsx("input",{type:"password",value:it.apiKey,onChange:He=>gt({...it,apiKey:He.target.value}),placeholder:"Leave blank to keep current",className:"w-full px-3 py-1.5 text-xs bg-surface-primary border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"Base URL"}),t.jsx("input",{type:"text",value:it.baseUrl,onChange:He=>gt({...it,baseUrl:He.target.value}),placeholder:"Default",className:"w-full px-3 py-1.5 text-xs bg-surface-primary border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"Model"}),t.jsx("input",{type:"text",value:it.model,onChange:He=>gt({...it,model:He.target.value}),className:"w-full px-3 py-1.5 text-xs bg-surface-primary border border-border-default rounded-lg text-fg-primary focus:border-brand-500 outline-none"})]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>{hr(ie)},disabled:wn,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white rounded-lg transition-colors",children:wn?"Saving...":"Save"}),t.jsx("button",{onClick:()=>Zt(null),className:"px-3 py-1.5 text-xs border border-border-default text-fg-secondary hover:bg-surface-elevated rounded-lg transition-colors",children:"Cancel"})]})]}):t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:He=>{He.stopPropagation(),Qn(ie,Se)},className:"px-3 py-1.5 text-xs border border-border-default text-fg-secondary hover:bg-surface-elevated rounded-lg transition-colors",children:"Edit"}),t.jsx("button",{onClick:He=>{He.stopPropagation(),confirm(`Delete provider "${Se.displayName??ie}"?`)&&or(ie)},disabled:Qt===ie,className:"px-3 py-1.5 text-xs border border-red-500/30 text-red-400 hover:bg-red-500/10 rounded-lg transition-colors disabled:opacity-40",children:Qt===ie?"Deleting...":"Delete"})]})]}),Se.cost&&t.jsxs("div",{className:"bg-surface-elevated/40 rounded-lg p-3",children:[t.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider mb-2",children:"Pricing (per 1M tokens)"}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[t.jsx(ka,{label:"Input",value:`$${Se.cost.input}`}),t.jsx(ka,{label:"Output",value:`$${Se.cost.output}`}),Se.cost.cacheRead!=null&&t.jsx(ka,{label:"Cache Read",value:`$${Se.cost.cacheRead}`}),Se.cost.cacheWrite!=null&&t.jsx(ka,{label:"Cache Write",value:`$${Se.cost.cacheWrite}`})]})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:"Available Models"}),Se.configured&&un!==ie&&t.jsx("button",{onClick:()=>{En(ie),Fe({id:"",name:"",contextWindow:128e3,maxOutputTokens:16384,costInput:1,costOutput:5,reasoning:!1,vision:!1})},className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:"+ Add Model"})]}),un===ie&&t.jsxs("div",{className:"bg-surface-elevated/40 rounded-lg p-3 mb-2 space-y-2",children:[t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:[t.jsx("input",{type:"text",placeholder:"Model ID",value:fe.id,onChange:He=>Fe({...fe,id:He.target.value}),className:"px-2 py-1 text-xs bg-surface-primary border border-border-default rounded text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"}),t.jsx("input",{type:"text",placeholder:"Display Name",value:fe.name,onChange:He=>Fe({...fe,name:He.target.value}),className:"px-2 py-1 text-xs bg-surface-primary border border-border-default rounded text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"}),t.jsx("input",{type:"number",placeholder:"Context (tokens)",value:fe.contextWindow,onChange:He=>Fe({...fe,contextWindow:Number(He.target.value)}),className:"px-2 py-1 text-xs bg-surface-primary border border-border-default rounded text-fg-primary focus:border-brand-500 outline-none"}),t.jsx("input",{type:"number",placeholder:"Max Output",value:fe.maxOutputTokens,onChange:He=>Fe({...fe,maxOutputTokens:Number(He.target.value)}),className:"px-2 py-1 text-xs bg-surface-primary border border-border-default rounded text-fg-primary focus:border-brand-500 outline-none"})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:"$/1M in:"}),t.jsx("input",{type:"number",step:"0.01",value:fe.costInput,onChange:He=>Fe({...fe,costInput:Number(He.target.value)}),className:"w-16 px-2 py-1 text-xs bg-surface-primary border border-border-default rounded text-fg-primary focus:border-brand-500 outline-none"})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:"out:"}),t.jsx("input",{type:"number",step:"0.01",value:fe.costOutput,onChange:He=>Fe({...fe,costOutput:Number(He.target.value)}),className:"w-16 px-2 py-1 text-xs bg-surface-primary border border-border-default rounded text-fg-primary focus:border-brand-500 outline-none"})]}),t.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-fg-tertiary cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:fe.reasoning,onChange:He=>Fe({...fe,reasoning:He.target.checked}),className:"rounded"}),"reasoning"]}),t.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-fg-tertiary cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:fe.vision,onChange:He=>Fe({...fe,vision:He.target.checked}),className:"rounded"}),"vision"]}),t.jsx("div",{className:"flex-1"}),t.jsx("button",{onClick:()=>{tr(ie)},disabled:kt||!fe.id||!fe.name,className:"px-2 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white rounded transition-colors",children:kt?"Adding...":"Add"}),t.jsx("button",{onClick:()=>En(null),className:"px-2 py-1 text-[10px] border border-border-default text-fg-secondary hover:bg-surface-elevated rounded transition-colors",children:"Cancel"})]})]}),Se.models&&Se.models.length>0&&t.jsx("div",{className:"space-y-1.5",children:Se.models.map(He=>{const Mt=He.id===Se.model,Gn=os===`${ie}:${He.id}`,On=!fn.has(He.id);return t.jsxs("div",{className:`flex items-center justify-between px-3 py-2 rounded-lg text-xs transition-colors ${Mt?"bg-brand-500/15 border border-brand-500/30":Se.configured?"bg-surface-elevated/30 hover:bg-surface-elevated/60 cursor-pointer":"bg-surface-elevated/30"}`,onClick:()=>{!Mt&&Se.configured&&!Gn&&nr(ie,He.id)},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[Mt&&t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-500 shrink-0"}),t.jsx("span",{className:Mt?"text-brand-500 font-medium":"text-fg-secondary",children:He.name}),He.reasoning&&t.jsx("span",{className:"text-[9px] bg-amber-500/15 text-amber-600 px-1 py-0.5 rounded",children:"reasoning"}),He.inputTypes?.includes("image")&&t.jsx("span",{className:"text-[9px] bg-blue-500/15 text-blue-600 px-1 py-0.5 rounded",children:"vision"}),On&&t.jsx("span",{className:"text-[9px] bg-purple-500/15 text-purple-400 px-1 py-0.5 rounded",children:"custom"})]}),t.jsxs("div",{className:"flex items-center gap-3 text-fg-tertiary",children:[t.jsxs("span",{children:[(He.contextWindow/1e3).toFixed(0),"K ctx"]}),t.jsxs("span",{children:["$",He.cost.input,"/$",He.cost.output]}),Se.configured&&!Mt&&t.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded transition-colors ${Gn?"bg-brand-500/30 text-brand-400":"bg-surface-overlay text-fg-tertiary hover:bg-brand-500/20 hover:text-brand-500"}`,children:Gn?"Switching...":"Use"}),Mt&&t.jsx("span",{className:"text-[9px] bg-brand-500/15 text-brand-500 px-1.5 py-0.5 rounded",children:"active"}),On&&!Mt&&t.jsx("button",{onClick:tn=>{tn.stopPropagation(),cr(ie,He.id)},className:"text-red-400 hover:text-red-300 transition-colors",title:"Delete custom model",children:t.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]},He.id)})})]}),!Se.configured&&t.jsx("div",{className:"text-xs text-fg-tertiary",children:'Not configured. Use the "Add Provider" button below, or set API keys in environment variables.'})]})]},ie))}),Wt?t.jsxs("div",{className:"mt-3 bg-surface-secondary border border-brand-500/30 rounded-xl p-5 space-y-4",children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:"Add New Provider"}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"Provider Name"}),t.jsx("input",{type:"text",value:Ct.name,onChange:ie=>de({...Ct,name:ie.target.value}),placeholder:"e.g. deepseek, openrouter, my-provider",className:"w-full px-3 py-2 text-sm bg-surface-elevated border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-1",children:"Use anthropic, openai, google, ollama for first-party; any other name uses OpenAI-compatible API"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"API Key"}),t.jsx("input",{type:"password",value:Ct.apiKey,onChange:ie=>de({...Ct,apiKey:ie.target.value}),placeholder:"sk-...",className:"w-full px-3 py-2 text-sm bg-surface-elevated border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"Base URL (optional)"}),t.jsx("input",{type:"text",value:Ct.baseUrl,onChange:ie=>de({...Ct,baseUrl:ie.target.value}),placeholder:"https://api.example.com/v1",className:"w-full px-3 py-2 text-sm bg-surface-elevated border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"Default Model"}),t.jsx("input",{type:"text",value:Ct.model,onChange:ie=>de({...Ct,model:ie.target.value}),placeholder:"e.g. deepseek-chat, gpt-4o",className:"w-full px-3 py-2 text-sm bg-surface-elevated border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"})]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>{Tn()},disabled:Be||!Ct.name||!Ct.model,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white rounded-lg transition-colors",children:Be?"Adding...":"Add Provider"}),t.jsx("button",{onClick:()=>{en(!1),Qe(null)},className:"px-4 py-2 text-sm border border-border-default text-fg-secondary hover:bg-surface-elevated rounded-lg transition-colors",children:"Cancel"})]}),ot&&t.jsx(Na,{type:ot.type,text:ot.text})]}):t.jsx("button",{onClick:()=>en(!0),className:"w-full mt-3 px-4 py-3 border border-dashed border-border-default hover:border-brand-500/50 hover:bg-brand-500/5 rounded-xl text-sm text-fg-tertiary hover:text-brand-500 transition-colors",children:"+ Add Provider"})]}),t.jsx("div",{className:"border-t border-border-default"}),t.jsx(qs,{title:"Environment Variable Configuration",children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 space-y-4",children:[t.jsx("div",{className:"text-sm text-fg-secondary",children:"Detect model API keys from environment variables and write them to the config file."}),t.jsxs("button",{onClick:()=>{Tt()},disabled:I,className:"px-4 py-2 border border-border-default hover:bg-surface-elevated disabled:opacity-40 text-fg-secondary text-sm rounded-lg transition-colors flex items-center gap-2",children:[t.jsx("svg",{className:`w-4 h-4 ${I?"animate-spin":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),I?"Detecting...":"Refresh Environment Variables"]}),R&&R.detected.length>0&&t.jsxs("div",{className:"border-t border-border-default pt-4 space-y-3",children:[t.jsx("div",{className:"text-xs text-fg-tertiary uppercase tracking-wider",children:"Detected Providers — select to apply:"}),R.detected.map(ie=>t.jsxs("label",{className:"flex items-center justify-between bg-surface-elevated/30 rounded-lg px-4 py-3 cursor-pointer hover:bg-surface-elevated/50 transition-colors",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("input",{type:"checkbox",checked:B[ie.provider]??!1,onChange:Se=>T({...B,[ie.provider]:Se.target.checked}),className:"w-4 h-4 rounded bg-surface-overlay border-gray-600 text-brand-500 focus:ring-brand-500"}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm text-fg-primary font-medium",children:ie.displayName}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:["Key: ",t.jsx("code",{className:"text-fg-secondary",children:ie.apiKeyPreview})," / ","Model: ",t.jsx("code",{className:"text-fg-secondary",children:ie.model}),ie.baseUrl&&t.jsxs(t.Fragment,{children:[" / ","URL: ",t.jsx("code",{className:"text-fg-secondary",children:ie.baseUrl})]})]})]})]}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:Object.keys(ie.envVars).map(Se=>t.jsx("div",{children:t.jsx("code",{children:Se})},Se))})]},ie.provider)),R.timeoutMs&&t.jsxs("div",{className:"text-xs text-fg-tertiary",children:["LLM Timeout: ",t.jsxs("code",{className:"text-fg-secondary",children:[R.timeoutMs,"ms"]})," (from ",t.jsx("code",{children:"LLM_TIMEOUT_MS"}),")"]}),t.jsx("button",{onClick:()=>{Pe()},disabled:D||Object.values(B).filter(Boolean).length===0,className:"px-4 py-2 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-lg transition-colors",children:D?"Applying...":`Apply ${Object.values(B).filter(Boolean).length} Provider(s) to Config`})]}),$&&t.jsx(Na,{type:$.type,text:$.text})]})}),t.jsx(qs,{title:"Import from OpenClaw",children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 space-y-4",children:[t.jsx("div",{className:"text-sm text-fg-secondary",children:"Detect and import LLM configurations from an existing OpenClaw installation."}),t.jsx("div",{className:"flex gap-3",children:t.jsx("button",{onClick:()=>{Xt()},disabled:C,className:"px-4 py-2 border border-border-default hover:bg-surface-elevated disabled:opacity-40 text-fg-secondary text-sm rounded-lg transition-colors",children:C?"Detecting...":"Detect OpenClaw Config"})}),E&&E.found&&t.jsxs("div",{className:"border-t border-border-default pt-4 space-y-3",children:[t.jsxs("div",{className:"text-xs text-green-600",children:["Found OpenClaw config at: ",t.jsx("code",{className:"text-fg-secondary",children:E.summary.configPath})]}),E.summary.models&&t.jsxs("div",{className:"bg-surface-elevated/30 rounded-lg p-3",children:[t.jsxs("div",{className:"text-xs text-fg-tertiary mb-2",children:[E.summary.models.providerCount," model providers found:"]}),t.jsx("div",{className:"space-y-1",children:E.summary.models.providers.map(ie=>t.jsxs("div",{className:"flex items-center justify-between text-xs",children:[t.jsx("span",{className:"text-fg-secondary",children:ie.name}),t.jsxs("span",{className:"text-fg-tertiary",children:[ie.modelCount," models ",ie.baseUrl?`(${ie.baseUrl})`:""]})]},ie.name))})]}),E.summary.channels&&E.summary.channels.length>0&&t.jsx("div",{className:"bg-surface-elevated/30 rounded-lg p-3",children:t.jsxs("div",{className:"text-xs text-fg-tertiary mb-1",children:["Channels: ",E.summary.channels.join(", ")]})}),t.jsx("button",{onClick:()=>{je()},disabled:C,className:"px-4 py-2 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-lg transition-colors",children:C?"Importing...":"Import Model Configs"})]}),S&&t.jsx(Na,{type:S.type,text:S.text})]})}),t.jsx(qs,{title:"Agent Execution",children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:"Max Tool Iterations"}),t.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:"Safety cap on tool call loops per agent turn (0 = unlimited, applies to all agents and subagents)"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"number",min:0,value:De,onChange:ie=>{ge(Number(ie.target.value)),tt(null)},className:"w-24 px-3 py-1.5 text-sm border border-border-default rounded-lg bg-surface-primary text-fg-primary text-right"}),t.jsx("button",{disabled:ye,onClick:async()=>{Ce(!0),tt(null);try{const ie=await re.settings.updateAgent({maxToolIterations:De});ge(ie.maxToolIterations),tt({type:"ok",text:"Saved"})}catch{tt({type:"err",text:"Failed to save"})}Ce(!1)},className:"px-3 py-1.5 text-xs bg-brand-500 text-white rounded-lg hover:bg-brand-600 transition-colors disabled:opacity-40",children:ye?"Saving…":"Save"})]})]}),ze&&t.jsx(Na,{type:ze.type,text:ze.text})]})}),t.jsx(qs,{title:"Data & Storage",children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 space-y-5",children:[wt&&!Xe&&t.jsx("div",{className:"text-sm text-fg-tertiary",children:"Scanning storage..."}),Xe&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-lg font-semibold text-fg-primary",children:ys(Xe.totalSize)}),t.jsx("div",{className:"text-xs text-fg-tertiary font-mono mt-0.5",children:Xe.dataDir})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>Lt(),disabled:wt,className:"px-3 py-1.5 text-xs border border-border-default hover:bg-surface-elevated rounded-lg text-fg-secondary transition-colors disabled:opacity-40",children:wt?"Scanning...":"Refresh"}),t.jsx("button",{onClick:()=>{re.system.openPath(Xe.dataDir)},className:"px-3 py-1.5 text-xs border border-border-default hover:bg-surface-elevated rounded-lg text-fg-secondary transition-colors",children:"Open in Finder"})]})]}),t.jsxs("div",{className:"border-t border-border-default pt-4",children:[t.jsx("h4",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Storage Breakdown"}),t.jsx("div",{className:"space-y-1.5",children:Xe.breakdown.filter(ie=>ie.size>0).map(ie=>t.jsxs("div",{className:"flex items-center justify-between py-1.5 px-3 rounded-lg bg-surface-elevated/40",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("span",{className:"text-sm text-fg-primary",children:ie.name}),t.jsx("span",{className:"text-xs text-fg-tertiary ml-2",children:ie.description})]}),t.jsx("span",{className:"text-sm font-medium text-fg-secondary tabular-nums shrink-0 ml-3",children:ys(ie.size)})]},ie.name))})]}),Xe.agents.length>0&&t.jsxs("div",{className:"border-t border-border-default pt-4",children:[t.jsxs("h4",{className:"text-xs font-semibold text-fg-secondary mb-3",children:["Agent Storage (",Xe.agents.length,")"]}),t.jsx("div",{className:"space-y-1",children:Xe.agents.map(ie=>{const Se=Te.has(ie.id);return t.jsxs("div",{className:"rounded-lg bg-surface-elevated/40 overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between py-2 px-3 cursor-pointer hover:bg-surface-elevated/70",onClick:()=>Ze(He=>{const Mt=new Set(He);return Mt.has(ie.id)?Mt.delete(ie.id):Mt.add(ie.id),Mt}),children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:Se?"▼":"▶"}),t.jsx("button",{onClick:He=>{He.stopPropagation(),jt.navigate("chat",{agentId:ie.id})},className:"text-sm text-brand-500 hover:text-brand-400 truncate",children:ie.name}),t.jsx("span",{className:"text-[10px] text-fg-tertiary font-mono truncate",children:ie.id})]}),t.jsx("span",{className:"text-xs font-medium text-fg-secondary tabular-nums shrink-0 ml-3",children:ys(ie.size)})]}),Se&&t.jsxs("div",{className:"px-3 pb-2 pt-0.5 space-y-0.5",children:[ie.subItems.filter(He=>He.size>0).map(He=>t.jsxs("div",{className:"flex items-center justify-between text-xs py-0.5 pl-5",children:[t.jsx("span",{className:"text-fg-tertiary",children:He.name}),t.jsx("span",{className:"text-fg-secondary tabular-nums",children:ys(He.size)})]},He.name)),t.jsx("div",{className:"pl-5 pt-1",children:t.jsx("button",{onClick:()=>{re.system.openPath(Xe.dataDir+"/agents/"+ie.id)},className:"text-[10px] text-fg-tertiary hover:text-fg-secondary underline",children:"Open folder"})})]})]},ie.id)})})]}),xt&&(xt.orphanAgents.length>0||xt.orphanTeams.length>0)&&t.jsx(fA,{orphanInfo:xt,dataDir:Xe.dataDir,onPurged:Lt})]})]})}),t.jsx("div",{className:"h-8"})]})]})}function Ih({step:e,title:r,description:s,active:l,children:o}){return t.jsxs("div",{className:`rounded-xl border p-4 space-y-3 transition-colors ${l?"border-brand-500/60 bg-brand-500/10":"border-border-default bg-surface-secondary/60"}`,children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("span",{className:"flex-none w-6 h-6 rounded-full bg-surface-overlay flex items-center justify-center text-xs font-bold text-fg-secondary",children:e}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:r}),t.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:s})]})]}),o&&t.jsx("div",{className:"pl-9",children:o})]})}function Na({type:e,text:r}){return t.jsx("div",{className:`text-xs px-3 py-2 rounded-lg ${e==="ok"?"bg-green-500/10 text-green-600 border border-green-500/30":"bg-red-500/10 text-red-500 border border-red-500/30"}`,children:r})}function qs({title:e,children:r}){return t.jsxs("section",{children:[t.jsx("h3",{className:"text-sm font-semibold text-fg-secondary uppercase tracking-wider mb-4",children:e}),t.jsx("div",{className:"space-y-4",children:r})]})}function $h({label:e,value:r,color:s}){const l=s==="green"?"bg-green-500/10 text-green-600":"bg-brand-500/10 text-brand-500";return t.jsxs("div",{className:`rounded-xl px-5 py-4 ${l}`,children:[t.jsx("div",{className:"text-2xl font-bold",children:r}),t.jsx("div",{className:"text-xs mt-1 opacity-70",children:e})]})}function ka({label:e,value:r}){return t.jsxs("div",{children:[t.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase",children:e}),t.jsx("div",{className:"text-xs text-fg-secondary mt-0.5 truncate",children:r})]})}function ys(e){if(e===0)return"0 B";const r=["B","KB","MB","GB"],s=Math.min(Math.floor(Math.log(e)/Math.log(1024)),r.length-1),l=e/Math.pow(1024,s);return`${l<10?l.toFixed(1):Math.round(l)} ${r[s]}`}function fA({orphanInfo:e,dataDir:r,onPurged:s}){const l=[...e.orphanAgents.map(N=>({...N,kind:"agent"})),...e.orphanTeams.map(N=>({...N,kind:"team"}))],[o,d]=v.useState(new Set),[c,h]=v.useState(!1),[m,f]=v.useState(null),x=N=>d(E=>{const A=new Set(E);return A.has(N)?A.delete(N):A.add(N),A}),g=o.size===l.length&&l.length>0,p=()=>d(g?new Set:new Set(l.map(N=>N.id))),y=l.filter(N=>o.has(N.id)).reduce((N,E)=>N+E.size,0),w=async N=>{h(!0),f(null);try{const E=await re.system.purgeOrphans(N),A=E.purgedAgents.length+E.purgedTeams.length;f(`Cleaned ${A} dir${A!==1?"s":""}, freed ${ys(E.freedBytes)}${E.failures.length?` (${E.failures.length} failed)`:""}`),d(new Set),s()}catch{f("Cleanup failed")}finally{h(!1)}};return t.jsxs("div",{className:"border-t border-border-default pt-4",children:[t.jsx("h4",{className:"text-xs font-semibold text-amber-500 mb-2",children:"Orphaned Directories"}),t.jsxs("p",{className:"text-xs text-fg-tertiary mb-3",children:["These directories have no matching database record and were likely left behind when agents or teams were deleted. Total: ",ys(e.totalOrphanSize)," across ",l.length," director",l.length===1?"y":"ies","."]}),t.jsxs("div",{className:"flex items-center gap-2 mb-2 px-1",children:[t.jsxs("label",{className:"flex items-center gap-1.5 text-[10px] text-fg-tertiary cursor-pointer select-none",children:[t.jsx("input",{type:"checkbox",checked:g,onChange:p,className:"rounded"}),"Select all"]}),o.size>0&&t.jsxs("span",{className:"text-[10px] text-fg-secondary",children:[o.size," selected (",ys(y),")"]})]}),t.jsx("div",{className:"space-y-0.5 mb-3 max-h-52 overflow-y-auto",children:l.map(N=>t.jsxs("div",{className:`flex items-center gap-2 text-xs py-1.5 px-2 rounded transition-colors ${o.has(N.id)?"bg-amber-500/10":"bg-surface-elevated/30 hover:bg-surface-elevated/50"}`,children:[t.jsx("input",{type:"checkbox",checked:o.has(N.id),onChange:()=>x(N.id),className:"rounded shrink-0"}),N.kind==="team"&&t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:"team"}),t.jsx("span",{className:"text-fg-tertiary font-mono truncate min-w-0 flex-1",children:N.id}),t.jsx("span",{className:"text-fg-secondary tabular-nums shrink-0",children:ys(N.size)}),t.jsx("button",{onClick:()=>{re.system.openPath(N.path)},className:"text-[10px] text-fg-tertiary hover:text-fg-secondary shrink-0 underline",children:"Open"})]},N.id))}),t.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[o.size>0&&t.jsx("button",{disabled:c,onClick:()=>{w([...o])},className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:c?"Cleaning...":`Clean Selected (${ys(y)})`}),t.jsx("button",{disabled:c,onClick:()=>{w()},className:"px-3 py-1.5 text-xs border border-amber-600/50 hover:bg-amber-600/10 text-amber-500 rounded-lg transition-colors disabled:opacity-50",children:c?"Cleaning...":`Clean All (${ys(e.totalOrphanSize)})`})]}),m&&t.jsx("div",{className:"text-xs text-fg-tertiary mt-2",children:m})]})}const Md=new Map;function Qa(e,r){Md.has(e)||Md.set(e,r().catch(()=>{}))}function Wa(e){const r=Md.get(e);return Md.delete(e),r}const wr={builderArtifacts:"builder.artifacts",builderAgents:"builder.agents",builderHubMyItems:"builder.hubMyItems",builderInstalled:"builder.installed",hubAgents:"hub.agents",hubTeams:"hub.teams",hubSkills:"hub.skills"};function Sj(e,r){const s=e.split(".").map(Number),l=r.split(".").map(Number);for(let o=0;o<Math.max(s.length,l.length);o++){const d=s[o]??0,c=l[o]??0;if(d>c)return!0;if(d<c)return!1}return!1}const Bh={development:"bg-blue-500/15 text-blue-600",devops:"bg-amber-500/15 text-amber-600",productivity:"bg-green-500/15 text-green-600",custom:"bg-gray-500/15 text-fg-secondary",browser:"bg-brand-500/15 text-brand-500",communication:"bg-green-500/15 text-green-600",data:"bg-brand-500/15 text-brand-500","AI 智能":"bg-brand-500/15 text-brand-500",开发工具:"bg-blue-500/15 text-blue-600",效率提升:"bg-green-500/15 text-green-600",数据分析:"bg-brand-500/15 text-brand-500",内容创作:"bg-brand-500/15 text-brand-500",安全合规:"bg-red-500/15 text-red-500",通讯协作:"bg-green-500/15 text-green-600"},hA=[{id:"installed",label:"Installed"},{id:"builtin",label:"Built-in"},{id:"skillhub",label:"SkillHub"},{id:"skillssh",label:"skills.sh"},{id:"markus-hub",label:"Markus Hub"}];function mA({item:e,installedSkills:r,onMsg:s,onRefresh:l}){const[o,d]=v.useState(!1),c=e.name.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed",h=r.find(g=>g.name===e.name||g.name===c),m=!!h,f=m&&e.version&&h?.version&&Sj(e.version,h.version),x=async()=>{if(!o){d(!0);try{const g=await Un.download(e.id),p=g.name||e.name,y=p.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed",w={type:"hub",hubItemId:e.id};if(g.files&&Object.keys(g.files).length>0)await re.builder.artifacts.import("skill",y,g.files,w);else{const N={...g.config,name:p,description:e.description,source:w};await re.builder.artifacts.save("skill",N)}await re.builder.artifacts.install("skill",y),s(f?`Upgraded ${e.name}`:`Installed ${e.name}`,"success"),l(),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{s("Install failed","error")}finally{d(!1)}}};return f?t.jsx("button",{onClick:()=>{x()},disabled:o,className:"px-2.5 py-1 text-[10px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50",children:o?"Upgrading...":`Upgrade → v${e.version}`}):m?t.jsxs("span",{className:"px-2.5 py-1 text-[10px] bg-surface-overlay text-fg-secondary rounded-lg",children:["Installed",h?.version?` (v${h.version})`:""]}):t.jsx("button",{onClick:()=>{x()},disabled:o,className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:o?"Installing...":"Install"})}function Cj(){const e=ks(),[r,s]=v.useState("installed"),[l,o]=v.useState(null),[d,c]=v.useState(new Set),[h,m]=v.useState([]),[f,x]=v.useState(!0),[g,p]=v.useState(""),[y,w]=v.useState([]),[N,E]=v.useState(0),[A,C]=v.useState(1),[k,S]=v.useState([]),[O,R]=v.useState(""),[G,I]=v.useState("score"),[Q,$]=v.useState(""),[F,B]=v.useState(!1),[T,D]=v.useState([]),[z,_]=v.useState(!1),[Y,V]=v.useState([]),[J,U]=v.useState(""),[H,X]=v.useState(!1),[L,M]=v.useState([]),[q,K]=v.useState(!1),[ee,te]=v.useState(""),se=(ae,Te="success")=>{o({text:ae,type:Te}),setTimeout(()=>o(null),Te==="error"?1e4:4e3)},xe=v.useCallback(async()=>{x(!0);try{const ae=await re.skills.list();m(ae.skills)}catch{}x(!1)},[]),ke=v.useCallback(async()=>{_(!0);try{const ae=await re.skills.builtin();D(ae.skills)}catch{}_(!1)},[]),De=v.useCallback(async ae=>{B(!0);try{const Te=await re.skills.registrySkillhub({q:ae?.q,category:ae?.category,page:ae?.page??1,limit:24,sort:ae?.sort??G});w(Te.skills),E(Te.total),Te.categories?.length&&S(Te.categories)}catch{}B(!1)},[G]),ge=v.useCallback(async ae=>{X(!0);try{const Te=await re.skills.registrySkillssh(ae);V(Te.skills)}catch{}X(!1)},[]),ye=v.useCallback(async ae=>{K(!0);try{const Ze=await(ae?Un.search({type:"skill",q:ae,limit:50}):Wa(wr.hubSkills)??Un.search({type:"skill",limit:50}));M(Ze?.items??[])}catch{}K(!1)},[]);v.useEffect(()=>{xe(),ke(),De(),ge()},[]),v.useEffect(()=>{r==="markus-hub"&&ye(ee)},[r,ee,ye]);const Ce=async ae=>{c(Te=>new Set(Te).add(ae.name));try{const Te=await re.skills.install({name:ae.name,source:"skillhub",slug:ae.slug,sourceUrl:ae.homepage,description:ae.description_zh??ae.description,category:"custom",version:ae.version});await xe(),se(`"${ae.name}" installed (${Te.method}) → ${Te.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{se(`Download failed for "${ae.name}". You can try manually from: ${ae.homepage}`,"error")}c(Te=>{const Ze=new Set(Te);return Ze.delete(ae.name),Ze})},ze=async ae=>{c(Te=>new Set(Te).add(ae.name));try{const Te=await re.skills.install({name:ae.name,source:"skillssh",sourceUrl:ae.url,githubRepo:`${ae.author}/${ae.repo}`,githubSkillPath:ae.name});await xe(),se(`"${ae.name}" installed (${Te.method}) → ${Te.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{se(`Download failed for "${ae.name}". You can try manually from: ${ae.url}`,"error")}c(Te=>{const Ze=new Set(Te);return Ze.delete(ae.name),Ze})},tt=async ae=>{c(Te=>new Set(Te).add(ae.name));try{const Te=await re.skills.install({name:ae.name,source:"builtin"});await xe(),await ke(),se(`"${ae.name}" installed (${Te.method}) → ${Te.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(Te){se(`Install failed for "${ae.name}": ${Te}`,"error")}c(Te=>{const Ze=new Set(Te);return Ze.delete(ae.name),Ze})},Xe=async ae=>{if(confirm(`Uninstall "${ae}"? This will delete the skill files from ~/.markus/skills/.`))try{await re.skills.uninstall(ae),await xe(),se(`"${ae}" uninstalled`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(Te){se(`Uninstall failed: ${Te}`,"error")}},dt=h.filter(ae=>{if(!g)return!0;const Te=g.toLowerCase();return ae.name.toLowerCase().includes(Te)||ae.description?.toLowerCase().includes(Te)}),wt=Y.filter(ae=>{if(!J)return!0;const Te=J.toLowerCase();return ae.name.toLowerCase().includes(Te)||ae.repo.toLowerCase().includes(Te)});return t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[t.jsxs("div",{className:`${e?"px-4":"px-6"} border-b border-border-default bg-surface-secondary shrink-0`,children:[t.jsx("div",{className:"flex items-center h-14",children:t.jsx("h2",{className:"text-lg font-semibold",children:"Skill Store"})}),t.jsx("div",{className:`flex ${e?"flex-wrap":""} gap-1 pb-2 overflow-x-auto scrollbar-hide`,children:hA.map(ae=>t.jsx("button",{onClick:()=>s(ae.id),className:`px-3 py-1.5 text-xs rounded-lg transition-colors shrink-0 ${r===ae.id?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:ae.label},ae.id))})]}),l&&t.jsx("div",{className:`mx-7 mt-2 px-3 py-1.5 text-xs rounded-lg shrink-0 ${l.type==="error"?"bg-red-500/10 text-red-500":"bg-green-500/10 text-green-600"}`,children:l.text}),r==="installed"&&t.jsxs("div",{className:`flex-1 overflow-y-auto ${e?"p-4":"p-6"}`,children:[t.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[t.jsx("input",{value:g,onChange:ae=>p(ae.target.value),placeholder:"Search installed skills...",className:`px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none ${e?"flex-1 min-w-0":"w-72"}`}),t.jsxs("span",{className:"text-xs text-fg-tertiary shrink-0",children:[dt.length," skill",dt.length!==1?"s":""]})]}),f?t.jsx("div",{className:"text-center text-fg-tertiary py-20",children:"Loading..."}):dt.length===0?t.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[t.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◆"}),t.jsx("div",{children:"No installed skills found."}),t.jsx("div",{className:"text-xs mt-1",children:"Browse SkillHub or skills.sh to discover and install skills."})]}):t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:dt.map(ae=>t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 hover:border-gray-600 transition-colors",children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"font-semibold text-sm truncate",children:ae.name}),t.jsx("span",{className:`px-1.5 py-0.5 rounded text-[9px] shrink-0 ${ae.type==="builtin"?"bg-blue-500/15 text-blue-600":ae.type==="filesystem"?"bg-green-500/15 text-green-600":"bg-amber-500/15 text-amber-600"}`,children:ae.type==="builtin"?"built-in":ae.type==="filesystem"?"local":"imported"})]}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:[ae.author?`by ${ae.author} · `:"",ae.version?`v${ae.version}`:"",ae.sourcePath&&t.jsxs("span",{className:"ml-1 text-fg-tertiary",title:ae.sourcePath,children:["📁 ",ae.sourcePath.replace(/^.*\/\.([^/]+)\/skills\//,"~/.$1/skills/")]})]})]}),t.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium ${Bh[ae.category??""]??"bg-gray-500/15 text-fg-secondary"} capitalize shrink-0 ml-2`,children:ae.category??"custom"})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-2 line-clamp-2",children:ae.description??"No description"}),t.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:ae.tags?.slice(0,3).map(Te=>t.jsx("span",{className:"px-2 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded-full",children:Te},Te))}),t.jsxs("div",{className:"mt-3 pt-2 border-t border-border-default flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[ae.tools&&ae.tools.length>0&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[ae.tools.length," tool",ae.tools.length!==1?"s":""]}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:"Auto-discovered by agents"})]}),ae.type!=="builtin"&&t.jsx("button",{onClick:()=>{Xe(ae.name)},className:"px-2 py-0.5 text-[10px] text-red-500 hover:text-red-500 hover:bg-red-500/10 rounded transition-colors",children:"Uninstall"})]})]},ae.name))})]}),r==="builtin"&&t.jsxs("div",{className:`flex-1 overflow-y-auto ${e?"p-4":"p-6"}`,children:[t.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[t.jsxs("span",{className:"text-xs text-fg-tertiary",children:[T.length," built-in skill",T.length!==1?"s":""," available"]}),t.jsx("button",{onClick:()=>{ke()},className:"text-xs text-brand-500 hover:text-brand-500 transition-colors",children:"Refresh"})]}),z?t.jsx("div",{className:"text-center text-fg-tertiary py-20",children:t.jsx("div",{className:"animate-pulse",children:"Loading built-in skills..."})}):T.length===0?t.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[t.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◇"}),t.jsx("div",{children:"No built-in skills found."}),t.jsx("div",{className:"text-xs mt-1",children:"Built-in skills are provided in templates/skills/."})]}):t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:T.map(ae=>t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 hover:border-gray-600 transition-colors",children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"font-semibold text-sm truncate",children:ae.name}),ae.hasMcpServers&&t.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] bg-blue-500/15 text-blue-600 shrink-0",children:"MCP"})]}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:[ae.author?`by ${ae.author} · `:"","v",ae.version]})]}),t.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium ${Bh[ae.category??""]??"bg-gray-500/15 text-fg-secondary"} capitalize shrink-0 ml-2`,children:ae.category??"custom"})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-2 line-clamp-2",children:ae.description??"No description"}),t.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:ae.tags.slice(0,4).map(Te=>t.jsx("span",{className:"px-2 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded-full",children:Te},Te))}),ae.requiredPermissions.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:ae.requiredPermissions.map(Te=>t.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-amber-500/10 text-amber-500 rounded",children:Te},Te))}),t.jsxs("div",{className:"mt-3 pt-2 border-t border-border-default flex items-center justify-between",children:[ae.installed&&ae.installedVersion?t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["v",ae.installedVersion]}):t.jsx("span",{}),ae.installed&&ae.installedVersion&&Sj(ae.version,ae.installedVersion)?t.jsx("button",{onClick:()=>{tt(ae)},disabled:d.has(ae.name),className:"px-2.5 py-1 text-[10px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:d.has(ae.name)?"Upgrading...":`Upgrade → v${ae.version}`}):ae.installed?t.jsx("span",{className:"px-2.5 py-1 text-[10px] bg-surface-overlay text-fg-secondary rounded-lg",children:"Installed"}):t.jsx("button",{onClick:()=>{tt(ae)},disabled:d.has(ae.name),className:"px-2.5 py-1 text-[10px] bg-green-600 hover:bg-green-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:d.has(ae.name)?"Installing...":"Install"})]})]},ae.name))})]}),r==="skillhub"&&t.jsxs("div",{className:`flex-1 overflow-y-auto ${e?"p-4":"p-6"}`,children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[t.jsxs("select",{value:O,onChange:ae=>{R(ae.target.value),C(1),De({q:Q||void 0,category:ae.target.value||void 0,page:1})},className:"px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-secondary outline-none",children:[t.jsx("option",{value:"",children:"全部分类"}),k.map(ae=>t.jsx("option",{value:ae,children:ae},ae))]}),t.jsxs("select",{value:G,onChange:ae=>{I(ae.target.value),C(1),De({q:Q||void 0,category:O||void 0,page:1,sort:ae.target.value})},className:"px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-secondary outline-none",children:[t.jsx("option",{value:"score",children:"综合排序"}),t.jsx("option",{value:"downloads",children:"下载量"}),t.jsx("option",{value:"stars",children:"收藏数"}),t.jsx("option",{value:"installs",children:"安装量"})]}),!e&&t.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:t.jsx("a",{href:"https://skillhub.tencent.com",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:"Visit site →"})})]}),t.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[t.jsx("input",{value:Q,onChange:ae=>$(ae.target.value),onKeyDown:ae=>{ae.key==="Enter"&&(C(1),De({q:Q||void 0,category:O||void 0,page:1}))},placeholder:"搜索 SkillHub 技能...",className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none flex-1 min-w-0"}),t.jsx("button",{onClick:()=>{C(1),De({q:Q||void 0,category:O||void 0,page:1})},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg shrink-0",children:"Search"})]}),F?t.jsx("div",{className:"text-center text-fg-tertiary py-20",children:t.jsx("div",{className:"animate-pulse",children:"正在加载 SkillHub 技能..."})}):y.length===0?t.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[t.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◎"}),t.jsx("div",{children:"未找到匹配的技能"})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"text-xs text-fg-tertiary mb-3",children:["共 ",N.toLocaleString()," 个技能"]}),t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:y.map(ae=>{const Te=h.some(Ze=>Ze.name===ae.name||Ze.name===ae.slug);return t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 hover:border-gray-600 transition-colors",children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"font-semibold text-sm truncate",children:ae.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:["v",ae.version]})]}),t.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium shrink-0 ml-2 ${ae.tags?.[0]?Bh[ae.tags[0]]??"bg-brand-500/15 text-brand-500":"bg-brand-500/15 text-brand-500"}`,children:ae.tags?.[0]??"SkillHub"})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-2 line-clamp-2",children:ae.description_zh??ae.description??"No description"}),t.jsxs("div",{className:"mt-2 pt-2 border-t border-border-default flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[ae.stars>0&&t.jsxs("span",{className:"text-[10px] text-amber-600",children:["★ ",ae.stars.toLocaleString()]}),ae.downloads>0&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[ae.downloads>=1e4?`${(ae.downloads/1e4).toFixed(1)}万`:ae.downloads.toLocaleString()," 下载"]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("a",{href:ae.homepage,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-brand-500 hover:text-brand-500",children:"View →"}),Te?t.jsx("span",{className:"px-2.5 py-1 text-[10px] bg-surface-overlay text-fg-secondary rounded-lg",children:"Installed"}):t.jsx("button",{onClick:()=>{Ce(ae)},disabled:d.has(ae.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:d.has(ae.name)?"...":"Install"})]})]})]},ae.slug)})}),N>24&&t.jsxs("div",{className:"flex items-center justify-center gap-2 mt-6",children:[t.jsx("button",{disabled:A<=1,onClick:()=>{const ae=A-1;C(ae),De({q:Q||void 0,category:O||void 0,page:ae})},className:"px-3 py-1.5 text-xs bg-surface-elevated text-fg-secondary rounded-lg hover:bg-surface-overlay disabled:opacity-30",children:"← 上一页"}),t.jsxs("span",{className:"text-xs text-fg-tertiary",children:["第 ",A," / ",Math.ceil(N/24)," 页"]}),t.jsx("button",{disabled:A>=Math.ceil(N/24),onClick:()=>{const ae=A+1;C(ae),De({q:Q||void 0,category:O||void 0,page:ae})},className:"px-3 py-1.5 text-xs bg-surface-elevated text-fg-secondary rounded-lg hover:bg-surface-overlay disabled:opacity-30",children:"下一页 →"})]})]})]}),r==="skillssh"&&t.jsxs("div",{className:`flex-1 overflow-y-auto ${e?"p-4":"p-6"}`,children:[t.jsxs("div",{className:`flex ${e?"flex-wrap":""} items-center gap-2 mb-5`,children:[t.jsx("input",{value:J,onChange:ae=>U(ae.target.value),onKeyDown:ae=>{ae.key==="Enter"&&J.trim()&&ge(J)},placeholder:"Search skills.sh...",className:`px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none ${e?"flex-1 min-w-0":"w-72"}`}),t.jsx("button",{onClick:()=>{J.trim()&&ge(J)},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg shrink-0",children:"Search"}),!e&&t.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:t.jsx("a",{href:"https://skills.sh",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:"Visit site →"})})]}),H?t.jsx("div",{className:"text-center text-fg-tertiary py-20",children:t.jsx("div",{className:"animate-pulse",children:"Searching skills.sh..."})}):wt.length===0?t.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[t.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"⬡"}),t.jsx("div",{children:"Browse 84,000+ skills on skills.sh"}),t.jsx("div",{className:"text-xs mt-1",children:"Top skills are loaded automatically. Search for specific skills above."})]}):t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:wt.map(ae=>{const Te=h.some(Ze=>Ze.name===ae.name);return t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 hover:border-gray-600 transition-colors",children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"font-semibold text-sm truncate",children:ae.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:[ae.author," / ",ae.repo]})]}),t.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-medium bg-gray-500/15 text-fg-secondary shrink-0 ml-2",children:"skills.sh"})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-2 line-clamp-2",children:ae.description||"No description"}),t.jsxs("div",{className:"mt-2 pt-2 border-t border-border-default flex items-center justify-between",children:[t.jsx("div",{className:"flex items-center gap-3",children:ae.installs&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[ae.installs," installs"]})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("a",{href:ae.url,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-brand-500 hover:text-brand-500",children:"View →"}),Te?t.jsx("span",{className:"px-2.5 py-1 text-[10px] bg-surface-overlay text-fg-secondary rounded-lg",children:"Installed"}):t.jsx("button",{onClick:()=>{ze(ae)},disabled:d.has(ae.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:d.has(ae.name)?"...":"Install"})]})]})]},`${ae.author}-${ae.name}`)})})]}),r==="markus-hub"&&t.jsxs("div",{className:`flex-1 overflow-y-auto ${e?"p-4":"p-6"}`,children:[t.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[t.jsx("input",{value:ee,onChange:ae=>te(ae.target.value),placeholder:"Search Markus Hub skills...",className:`px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none ${e?"flex-1 min-w-0":"w-72"}`}),!e&&t.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:"Community skills from Markus Hub"})]}),q?t.jsx("div",{className:"text-center text-fg-tertiary py-20",children:t.jsx("div",{className:"animate-pulse",children:"Loading from Hub..."})}):L.length===0?t.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[t.jsx("div",{className:"text-4xl mb-3",children:"🏪"}),t.jsx("div",{children:"No skills found on Markus Hub"}),t.jsx("div",{className:"text-xs mt-1",children:"Hub may be offline or empty. Run the hub server at port 8059."})]}):t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:L.map(ae=>t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 hover:border-gray-600 transition-colors",children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"font-semibold text-sm truncate",children:ae.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:["by ",ae.author?.displayName??ae.author?.username]})]}),t.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-medium bg-green-500/15 text-green-600 shrink-0 ml-2",children:"Hub"})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-2 line-clamp-2",children:ae.description}),t.jsxs("div",{className:"mt-2 text-xs text-amber-600",children:["★".repeat(Math.round(parseFloat(ae.avgRating))),"☆".repeat(5-Math.round(parseFloat(ae.avgRating))),t.jsxs("span",{className:"text-fg-tertiary ml-1",children:["(",ae.ratingCount,") · ↓ ",ae.downloadCount]})]}),t.jsx("div",{className:"mt-2 pt-2 border-t border-border-default flex items-center justify-end gap-2",children:t.jsx(mA,{item:ae,installedSkills:h,onMsg:se,onRefresh:()=>{xe()}})})]},ae.id))})]})]})}function Ej(e){return e.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed"}function xA(e,r){const s=e.split(".").map(Number),l=r.split(".").map(Number);for(let o=0;o<Math.max(s.length,l.length);o++){const d=s[o]??0,c=l[o]??0;if(d>c)return!0;if(d<c)return!1}return!1}const ox={development:"{ }",devops:"⚙",management:"◎",productivity:"⚡",general:"◆"},cx={development:"bg-blue-500/15 text-blue-600 border-blue-500/20",devops:"bg-amber-500/15 text-amber-600 border-amber-500/20",management:"bg-brand-500/15 text-brand-500 border-brand-500/20",productivity:"bg-green-500/15 text-green-600 border-green-500/20",general:"bg-gray-500/15 text-fg-secondary border-gray-500/20"},Tj={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function Aj({authUser:e}={}){const[r,s]=v.useState("all"),[l,o]=v.useState(""),[d,c]=v.useState([]),[h,m]=v.useState([]),[f,x]=v.useState(null),[g,p]=v.useState(!1),[y,w]=v.useState(!0),[N,E]=v.useState(new Map),A=v.useCallback(async()=>{try{const[S,O]=await Promise.all([re.builder.artifacts.list().catch(()=>({artifacts:[]})),re.builder.artifacts.installed().catch(()=>({installed:{}}))]),R=new Map;for(const G of S.artifacts){if(G.type!=="agent")continue;const I=!!O.installed[`agent/${G.name}`];R.set(G.name,{installed:I,localVersion:G.meta.version||void 0,localUpdatedAt:G.updatedAt})}E(R)}catch{}},[]),C=v.useCallback(async()=>{w(!0);try{if(r==="hub"){const S=l?Un.search({type:"agent",q:l,limit:50}):Wa(wr.hubAgents)??Un.search({type:"agent",limit:50}),[O]=await Promise.all([S.catch(()=>({items:[],total:0})),A()]);m(O?.items??[]),c([])}else{m([]);const S=new URLSearchParams;l&&S.set("q",l);const O=await fetch("/api/templates?"+S.toString()).then(R=>R.json()).catch(()=>({templates:[]}));c(Array.isArray(O.templates)?O.templates:[])}}catch{c([]),m([])}finally{w(!1)}},[r,l,A]);v.useEffect(()=>{C()},[C]);const k=async(S,O,R)=>{try{const G=await fetch("/api/templates/instantiate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({templateId:S,name:O,orgId:"default",teamId:R})});if(!G.ok)throw new Error(`Failed: ${G.status}`);p(!1),x(null)}catch(G){alert(`Failed to create agent: ${G}`)}};return t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[t.jsx("div",{className:"px-6 h-14 flex items-center border-b border-border-default bg-surface-secondary shrink-0",children:t.jsx("h2",{className:"text-lg font-semibold",children:"Agent Store"})}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-6 py-2 border-b border-border-default/50 bg-surface-secondary/50 shrink-0",children:[t.jsx("div",{className:"flex gap-1",children:[{id:"all",label:"Built-in"},{id:"hub",label:"Markus Hub"}].map(S=>t.jsx("button",{onClick:()=>{s(S.id),x(null)},className:`px-3 py-1 text-xs rounded-md transition-colors ${r===S.id?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:S.label},S.id))}),r==="all"&&t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[d.length," agent",d.length!==1?"s":""," available"]}),t.jsx("div",{className:"flex-1 min-w-[120px]",children:t.jsx("input",{type:"text",placeholder:"Search agents...",value:l,onChange:S=>o(S.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm w-full focus:border-brand-500 focus:outline-none"})})]}),t.jsx("div",{className:"flex-1 overflow-y-auto p-7",children:y?t.jsx("div",{className:"text-center text-fg-tertiary py-20 animate-pulse",children:"Loading agents..."}):r==="hub"?h.length===0?t.jsxs("div",{className:"text-center py-16",children:[t.jsx("div",{className:"text-fg-tertiary text-3xl mb-3",children:"🏪"}),t.jsx("p",{className:"text-sm text-fg-tertiary",children:"No agents found on Markus Hub"}),t.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:"Hub may be offline or empty. Start the hub server at port 8059."})]}):t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:h.map(S=>t.jsx(gA,{item:S,localInfo:N.get(Ej(S.name)),onStatusChange:A},S.id))}):d.length===0?t.jsxs("div",{className:"text-center py-20",children:[t.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),t.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:l?`No agents match "${l}"`:"No agents found"}),t.jsx("div",{className:"text-fg-tertiary text-sm",children:l?"Try different search terms.":"Agents come from the built-in registry."})]}):t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:d.map(S=>t.jsx(pA,{template:S,isSelected:f?.id===S.id,onSelect:()=>x(f?.id===S.id?null:S)},S.id))})}),f&&r==="all"&&t.jsx("div",{className:"border-t border-border-default bg-surface-secondary shrink-0 max-h-72 overflow-y-auto",children:t.jsxs("div",{className:"p-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center text-lg ${cx[f.category]??"bg-surface-overlay text-fg-secondary"}`,children:ox[f.category]??"?"}),t.jsxs("div",{children:[t.jsx("h3",{className:"font-semibold text-fg-primary",children:f.name}),t.jsx("p",{className:"text-xs text-fg-tertiary mt-0.5",children:f.description})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:()=>p(!0),className:"px-5 py-2 bg-brand-600 text-white text-sm rounded-lg hover:bg-brand-500 transition-colors font-medium",children:"Hire Agent"}),t.jsx("button",{onClick:()=>x(null),className:"text-fg-tertiary hover:text-fg-secondary text-lg px-2",children:"×"})]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-5",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-2",children:"Skills"}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[f.skills.map(S=>t.jsx("span",{className:"px-2.5 py-1 text-xs bg-brand-500/10 text-brand-500 rounded-lg border border-brand-500/20",children:S},S)),f.skills.length===0&&t.jsx("span",{className:"text-xs text-fg-tertiary italic",children:"No required skills"})]})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-2",children:"Role Configuration"}),t.jsxs("div",{className:"space-y-1.5 text-sm",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-fg-tertiary w-16",children:"Role:"}),t.jsx("span",{className:"text-fg-secondary font-mono text-xs bg-surface-elevated px-2 py-0.5 rounded",children:f.roleId})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-fg-tertiary w-16",children:"Position:"}),t.jsx("span",{className:`px-2 py-0.5 rounded text-xs capitalize ${Tj[f.agentRole]??""}`,children:f.agentRole})]})]})]}),f.starterTasks&&f.starterTasks.length>0&&t.jsxs("div",{children:[t.jsx("div",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-2",children:"Starter Tasks"}),t.jsx("div",{className:"space-y-1.5",children:f.starterTasks.map((S,O)=>t.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-secondary",children:[t.jsx("span",{className:`inline-block w-1.5 h-1.5 rounded-full shrink-0 ${S.priority==="high"?"bg-red-400":S.priority==="medium"?"bg-amber-400":"bg-green-400"}`}),S.title]},O))})]})]})]})}),g&&f&&t.jsx(bA,{template:f,onClose:()=>p(!1),onHire:k})]})}function gA({item:e,localInfo:r,onStatusChange:s}){const[l,o]=v.useState(!1),[d,c]=v.useState(""),h=r?.installed??!1,m=h&&e.version&&r?.localVersion&&xA(e.version,r.localVersion),f=async x=>{if(x.stopPropagation(),!l){o(!0),c("");try{const g=await Un.download(e.id),p=g.name||e.name,y=Ej(p),w=g.itemType==="team"?"team":g.itemType==="skill"?"skill":"agent",N={type:"hub",hubItemId:e.id};if(g.files&&Object.keys(g.files).length>0)await re.builder.artifacts.import(w,y,g.files,N);else{const E={...g.config,name:p,description:e.description,source:N};await re.builder.artifacts.save(w,E)}await re.builder.artifacts.install(w,y),c(m?"Upgraded!":"Installed!"),s(),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{c("Failed")}finally{o(!1)}}};return t.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default hover:border-brand-600/50 cursor-pointer transition-all",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("span",{className:"text-lg",children:"🤖"}),t.jsx("h3",{className:"text-sm font-semibold truncate flex-1",children:e.name}),e.version&&t.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 bg-brand-500/15 text-brand-500 rounded",children:["v",e.version]}),t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-green-500/15 text-green-600 rounded",children:"Hub"})]}),t.jsx("p",{className:"text-xs text-fg-tertiary line-clamp-2 mb-2",children:e.description}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-fg-tertiary",children:[t.jsxs("span",{className:"text-amber-600",children:["★".repeat(Math.round(parseFloat(e.avgRating))),"☆".repeat(5-Math.round(parseFloat(e.avgRating)))]}),t.jsxs("span",{children:["↓"," ",e.downloadCount]}),t.jsx("span",{children:e.author?.displayName??e.author?.username})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[m?t.jsx("button",{onClick:x=>{f(x)},disabled:l,className:"px-3 py-1 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:l?"Upgrading...":`Upgrade → v${e.version}`}):h?t.jsxs("span",{className:"px-3 py-1 text-xs bg-surface-overlay text-fg-secondary rounded-lg",children:["Installed",r?.localVersion?` (v${r.localVersion})`:""]}):t.jsx("button",{onClick:x=>{f(x)},disabled:l,className:"px-3 py-1 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:l?"Installing...":"Install"}),d&&t.jsx("span",{className:`text-[10px] ${d==="Failed"?"text-red-500":"text-green-600"}`,children:d})]})]})}function pA({template:e,isSelected:r,onSelect:s}){return t.jsxs("div",{onClick:s,className:`bg-surface-secondary border rounded-xl p-5 cursor-pointer transition-all hover:shadow-lg hover:shadow-black/20 ${r?"border-brand-500 ring-1 ring-brand-500/30":"border-border-default hover:border-gray-600"}`,children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center text-sm shrink-0 border ${cx[e.category]??"bg-surface-overlay text-fg-secondary"}`,children:ox[e.category]??"?"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"font-semibold text-fg-primary truncate",children:e.name}),t.jsxs("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-medium shrink-0 bg-brand-500/20 text-brand-500",children:["v",e.version]})]}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:["by ",e.author]})]})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-3 line-clamp-2 leading-relaxed",children:e.description}),t.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-3",children:[e.skills.slice(0,4).map(l=>t.jsx("span",{className:"px-2 py-0.5 text-[10px] bg-brand-500/10 text-brand-500/80 rounded-full border border-brand-500/10",children:l},l)),e.skills.length>4&&t.jsxs("span",{className:"px-2 py-0.5 text-[10px] text-fg-tertiary",children:["+",e.skills.length-4," more"]})]}),t.jsxs("div",{className:"mt-3 pt-3 border-t border-border-default flex items-center gap-2 text-xs text-fg-tertiary",children:[t.jsx("span",{className:`inline-block px-2 py-0.5 rounded text-[10px] font-medium capitalize ${Tj[e.agentRole]??"bg-surface-overlay text-fg-secondary"}`,children:e.agentRole}),e.tags.length>0&&t.jsx("span",{className:"text-fg-tertiary",children:e.tags.slice(0,2).join(", ")})]})]})}function bA({template:e,onClose:r,onHire:s}){const[l,o]=v.useState(`${e.name} Agent`),[d,c]=v.useState(""),[h,m]=v.useState([]),[f,x]=v.useState(!1);v.useEffect(()=>{fetch("/api/teams",{credentials:"include"}).then(p=>p.json()).then(p=>m(p.teams??[])).catch(()=>{})},[]);const g=async()=>{if(l.trim()){x(!0);try{await s(e.id,l.trim(),d||void 0)}finally{x(!1)}}};return t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:r,children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[440px] shadow-2xl",onClick:p=>p.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[t.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center text-sm ${cx[e.category]??"bg-surface-overlay text-fg-secondary"}`,children:ox[e.category]??"?"}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-base font-semibold",children:"Hire Agent"}),t.jsxs("p",{className:"text-xs text-fg-tertiary",children:['Creating agent from "',e.name,'"']})]})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:"Agent Name"}),t.jsx("input",{type:"text",value:l,onChange:p=>o(p.target.value),className:"input-field",autoFocus:!0})]}),h.length>0&&t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:"Assign to Team (optional)"}),t.jsxs("select",{value:d,onChange:p=>c(p.target.value),className:"input-field",children:[t.jsx("option",{value:"",children:"No team"}),h.map(p=>t.jsx("option",{value:p.id,children:p.name},p.id))]})]}),t.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg p-3",children:[t.jsx("div",{className:"text-xs text-fg-tertiary mb-2 font-medium",children:"Agent Configuration"}),t.jsxs("div",{className:"grid grid-cols-2 gap-y-1.5 gap-x-4 text-xs",children:[t.jsx("div",{className:"text-fg-tertiary",children:"Role:"}),t.jsx("div",{className:"text-fg-secondary font-mono",children:e.roleId}),t.jsx("div",{className:"text-fg-tertiary",children:"Position:"}),t.jsx("div",{className:"text-fg-secondary capitalize",children:e.agentRole}),t.jsx("div",{className:"text-fg-tertiary",children:"Skills:"}),t.jsx("div",{className:"text-fg-secondary",children:e.skills.join(", ")||"None"})]})]})]}),t.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[t.jsx("button",{onClick:r,className:"btn-secondary",children:"Cancel"}),t.jsx("button",{onClick:g,disabled:!l.trim()||f,className:"btn-primary",children:f?"Creating...":"Create Agent"})]})]})})}const _j={development:"{ }",review:"⊘",operations:"⚙",general:"◎"},Dd={development:"bg-blue-500/15 text-blue-600 border-blue-500/20",review:"bg-brand-500/15 text-brand-500 border-brand-500/20",operations:"bg-amber-500/15 text-amber-600 border-amber-500/20",general:"bg-gray-500/15 text-fg-secondary border-gray-500/20"};function Mj(e){return e.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed"}function yA(e,r){const s=e.split(".").map(Number),l=r.split(".").map(Number);for(let o=0;o<Math.max(s.length,l.length);o++){const d=s[o]??0,c=l[o]??0;if(d>c)return!0;if(d<c)return!1}return!1}function Dj(){const[e,r]=v.useState("all"),[s,l]=v.useState(""),[o,d]=v.useState([]),[c,h]=v.useState([]),[m,f]=v.useState(null),[x,g]=v.useState(!0),[p,y]=v.useState(!1),[w,N]=v.useState(null),[E,A]=v.useState(new Map),C=v.useCallback(async()=>{try{const[O,R]=await Promise.all([re.builder.artifacts.list().catch(()=>({artifacts:[]})),re.builder.artifacts.installed().catch(()=>({installed:{}}))]),G=new Map;for(const I of O.artifacts){if(I.type!=="team")continue;const Q=!!R.installed[`team/${I.name}`];G.set(I.name,{installed:Q,localVersion:I.meta.version||void 0,localUpdatedAt:I.updatedAt})}A(G)}catch{}},[]),k=v.useCallback(async()=>{g(!0);try{if(e==="hub"){const O=s?Un.search({type:"team",q:s,limit:50}):Wa(wr.hubTeams)??Un.search({type:"team",limit:50}),[R]=await Promise.all([O.catch(()=>({items:[],total:0})),C()]);h(R?.items??[]),d([])}else{h([]);const O=await re.teamTemplates.list(s||void 0);d(O?.templates??[])}}catch{d([]),h([])}finally{g(!1)}},[e,s,C]);v.useEffect(()=>{k()},[k]);const S=async O=>{y(!0),N(null);try{const G=(await re.teams.create(O.name,O.description)).team.id;let I,Q=0;const $=[];for(const B of O.members){const T=B.count??1;for(let D=0;D<T;D++){const z=B.name??`${O.name} Agent ${D+1}`,_=T>1?`${z} ${D+1}`:z,Y=B.roleName??B.templateId??"developer";try{const V=await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({name:_,roleName:Y,orgId:"default",teamId:G,agentRole:B.role??"worker",skills:B.skills??[]})});if(V.ok){Q++;const J=await V.json();B.role==="manager"&&!I&&(I=J.agent?.id)}else{const J=await V.json().catch(()=>({error:`HTTP ${V.status}`}));$.push(`${_}: ${J.error??V.statusText}`)}}catch(V){$.push(`${_}: ${String(V)}`)}}}I&&await re.teams.update(G,{managerId:I,managerType:"agent"}).catch(()=>{});const F=$.length>0?` (${$.length} failed: ${$[0]})`:"";N({ok:Q>0,message:`Team "${O.name}" deployed with ${Q} agent(s)${F}`})}catch(R){N({ok:!1,message:`Failed: ${R}`})}finally{y(!1)}};return t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[t.jsx("div",{className:"px-6 h-14 flex items-center border-b border-border-default bg-surface-secondary shrink-0",children:t.jsx("h2",{className:"text-lg font-semibold",children:"Team Store"})}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-6 py-2 border-b border-border-default/50 bg-surface-secondary/50 shrink-0",children:[t.jsx("div",{className:"flex gap-1",children:[{id:"all",label:"Built-in"},{id:"hub",label:"Markus Hub"}].map(O=>t.jsx("button",{onClick:()=>{r(O.id),f(null),N(null)},className:`px-3 py-1 text-xs rounded-md transition-colors ${e===O.id?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:O.label},O.id))}),e==="all"&&t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[o.length," team",o.length!==1?"s":""," available"]}),t.jsx("div",{className:"flex-1 min-w-[120px]",children:t.jsx("input",{type:"text",placeholder:"Search teams...",value:s,onChange:O=>l(O.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm w-full focus:border-brand-500 focus:outline-none"})})]}),t.jsx("div",{className:"flex-1 overflow-y-auto p-7",children:x?t.jsx("div",{className:"text-center text-fg-tertiary py-20 animate-pulse",children:"Loading teams..."}):e==="hub"?c.length===0?t.jsxs("div",{className:"text-center py-16",children:[t.jsx("div",{className:"text-fg-tertiary text-3xl mb-3",children:"🏪"}),t.jsx("p",{className:"text-sm text-fg-tertiary",children:"No teams found on Markus Hub"}),t.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:"Hub may be offline or empty. Start the hub server at port 8059."})]}):t.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:c.map(O=>t.jsx(vA,{item:O,localInfo:E.get(Mj(O.name)),onStatusChange:C},O.id))}):o.length===0?t.jsxs("div",{className:"text-center py-20",children:[t.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"◉"}),t.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:s?`No teams match "${s}"`:"No teams available"}),t.jsx("div",{className:"text-fg-tertiary text-sm",children:s?"Try different search terms.":"Go to the Builder page to create a team."})]}):t.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-5",children:o.map(O=>t.jsx(jA,{template:O,isSelected:m?.id===O.id,onSelect:()=>f(m?.id===O.id?null:O)},O.id))})}),m&&e==="all"&&t.jsx("div",{className:"border-t border-border-default bg-surface-secondary shrink-0 max-h-80 overflow-y-auto",children:t.jsxs("div",{className:"p-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center text-lg border ${Dd[m.category??"general"]??Dd.general}`,children:_j[m.category??"general"]??"◎"}),t.jsxs("div",{children:[t.jsx("h3",{className:"font-semibold text-fg-primary",children:m.name}),t.jsx("p",{className:"text-xs text-fg-tertiary mt-0.5",children:m.description})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:()=>S(m),disabled:p,className:"px-5 py-2 bg-brand-600 text-white text-sm rounded-lg hover:bg-brand-500 transition-colors font-medium disabled:opacity-50",children:p?"Deploying...":"Deploy Team"}),t.jsx("button",{onClick:()=>{f(null),N(null)},className:"text-fg-tertiary hover:text-fg-secondary text-lg px-2",children:"×"})]})]}),w&&t.jsx("div",{className:`mb-4 px-4 py-2.5 rounded-lg text-sm ${w.ok?"bg-green-500/10 text-green-600 border border-green-500/20":"bg-red-500/10 text-red-500 border border-red-500/20"}`,children:w.message}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-5",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:"Team Composition"}),t.jsx("div",{className:"space-y-2",children:m.members.map((O,R)=>t.jsxs("div",{className:"flex items-center gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[t.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center text-xs font-bold shrink-0 ${O.role==="manager"?"bg-brand-500/20 text-brand-500":"bg-blue-500/20 text-blue-600"}`,children:O.role==="manager"?"★":R+1}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-fg-primary",children:O.name??O.roleName??O.templateId}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary font-mono",children:O.roleName??O.templateId}),t.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] capitalize ${O.role==="manager"?"bg-brand-500/15 text-brand-500":"bg-blue-500/15 text-blue-600"}`,children:O.role??"worker"}),(O.count??1)>1&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["x",O.count]})]})]})]},R))})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:"Details"}),t.jsxs("div",{className:"space-y-2 text-sm",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-fg-tertiary w-20",children:"Version:"}),t.jsx("span",{className:"text-fg-secondary font-mono text-xs",children:m.version})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-fg-tertiary w-20",children:"Author:"}),t.jsx("span",{className:"text-fg-secondary",children:m.author})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-fg-tertiary w-20",children:"Members:"}),t.jsxs("span",{className:"text-fg-secondary",children:[m.members.reduce((O,R)=>O+(R.count??1),0)," agents"]})]}),m.tags&&m.tags.length>0&&t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"text-fg-tertiary w-20 pt-0.5",children:"Tags:"}),t.jsx("div",{className:"flex flex-wrap gap-1.5",children:m.tags.map(O=>t.jsx("span",{className:"px-2 py-0.5 text-[10px] bg-surface-elevated text-fg-secondary rounded-full border border-border-default",children:O},O))})]})]})]})]})]})})]})}function vA({item:e,localInfo:r,onStatusChange:s}){const[l,o]=v.useState(!1),[d,c]=v.useState(""),h=r?.installed??!1,m=h&&e.version&&r?.localVersion&&yA(e.version,r.localVersion),f=async x=>{if(x.stopPropagation(),!l){o(!0),c("");try{const g=await Un.download(e.id),p=g.name||e.name,y=Mj(p),w={type:"hub",hubItemId:e.id};if(g.files&&Object.keys(g.files).length>0)await re.builder.artifacts.import("team",y,g.files,w);else{const N={...g.config,name:p,description:e.description,source:w};await re.builder.artifacts.save("team",N)}await re.builder.artifacts.install("team",y),c(m?"Upgraded!":"Installed!"),s(),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{c("Failed")}finally{o(!1)}}};return t.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default hover:border-brand-600/50 cursor-pointer transition-all",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("span",{className:"text-lg",children:"👥"}),t.jsx("h3",{className:"text-sm font-semibold truncate flex-1",children:e.name}),e.version&&t.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 bg-brand-500/15 text-brand-500 rounded",children:["v",e.version]}),t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-green-500/15 text-green-600 rounded",children:"Hub"})]}),t.jsx("p",{className:"text-xs text-fg-tertiary line-clamp-2 mb-2",children:e.description}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-fg-tertiary",children:[t.jsxs("span",{className:"text-amber-600",children:["★".repeat(Math.round(parseFloat(e.avgRating))),"☆".repeat(5-Math.round(parseFloat(e.avgRating)))]}),t.jsxs("span",{children:["↓"," ",e.downloadCount]}),t.jsx("span",{children:e.author?.displayName??e.author?.username})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[m?t.jsx("button",{onClick:x=>{f(x)},disabled:l,className:"px-3 py-1 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:l?"Upgrading...":`Upgrade → v${e.version}`}):h?t.jsxs("span",{className:"px-3 py-1 text-xs bg-surface-overlay text-fg-secondary rounded-lg",children:["Installed",r?.localVersion?` (v${r.localVersion})`:""]}):t.jsx("button",{onClick:x=>{f(x)},disabled:l,className:"px-3 py-1 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:l?"Installing...":"Install"}),d&&t.jsx("span",{className:`text-[10px] ${d==="Failed"?"text-red-500":"text-green-600"}`,children:d})]})]})}function jA({template:e,isSelected:r,onSelect:s}){const l=e.members.reduce((c,h)=>c+(h.count??1),0),o=e.members.some(c=>c.role==="manager"),d=e.category??"general";return t.jsxs("div",{onClick:s,className:`bg-surface-secondary border rounded-xl p-5 cursor-pointer transition-all hover:shadow-lg hover:shadow-black/20 ${r?"border-brand-500 ring-1 ring-brand-500/30":"border-border-default hover:border-gray-600"}`,children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center text-sm shrink-0 border ${Dd[d]??Dd.general}`,children:_j[d]??"◎"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"font-semibold text-fg-primary truncate",children:e.name}),t.jsxs("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-medium shrink-0 bg-brand-500/20 text-brand-500",children:["v",e.version]})]}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:["by ",e.author]})]})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-3 line-clamp-2 leading-relaxed",children:e.description}),t.jsx("div",{className:"flex flex-wrap gap-1.5 mt-3",children:e.members.map((c,h)=>t.jsxs("span",{className:`px-2 py-0.5 text-[10px] rounded-full border ${c.role==="manager"?"bg-brand-500/10 text-brand-500 border-brand-500/15":"bg-blue-500/10 text-blue-600 border-blue-500/15"}`,children:[c.name??c.roleName??c.templateId,(c.count??1)>1?` x${c.count}`:""]},h))}),t.jsxs("div",{className:"mt-3 pt-3 border-t border-border-default flex items-center gap-3 text-xs text-fg-tertiary",children:[t.jsxs("span",{children:[l," agent",l!==1?"s":""]}),o&&t.jsx("span",{className:"text-brand-500/60",children:"has manager"}),e.tags&&e.tags.length>0&&t.jsx("span",{className:"text-fg-tertiary",children:e.tags.slice(0,3).join(", ")})]})]})}function wA(e){const r=e.indexOf(".markus/builder-artifacts/");return r>=0?"~/"+e.slice(r):e}const Hh=[{roleId:"agent-father",roleName:"Agent Father",icon:"✦",color:"from-brand-500 to-purple-600",borderColor:"border-brand-500/30 hover:border-brand-400/50",bgColor:"bg-brand-500/10",desc:"AI Agent Architect",detail:"Design and create powerful AI agents through natural conversation. Describe the agent you need and Agent Father will configure it with the right role, skills, tools, and system prompt.",examples:["A senior full-stack developer who specializes in React and Node.js","A DevOps engineer for CI/CD pipeline management","A code reviewer who enforces best practices"]},{roleId:"team-factory",roleName:"Team Factory",icon:"◈",color:"from-blue-500 to-blue-600",borderColor:"border-blue-500/30 hover:border-blue-400/50",bgColor:"bg-blue-500/10",desc:"AI Team Composer",detail:"Compose optimal agent teams for any project. Describe your goal and Team Factory will design the lineup with the right mix of managers, developers, reviewers, and specialists.",examples:["A web development team with PM, developers, and QA","A content team for a tech blog","A data engineering squad"]},{roleId:"skill-architect",roleName:"Skill Architect",icon:"⬡",color:"from-green-500 to-green-600",borderColor:"border-green-500/30 hover:border-green-400/50",bgColor:"bg-green-500/10",desc:"AI Skill Designer",detail:"Create new agent skills and tool definitions. Describe the capability you want and Skill Architect will design the complete skill manifest with tools, schemas, and permissions.",examples:["A skill that analyzes Git repos and generates changelogs","A web scraping skill for extracting structured data","A database migration tool with rollback support"]}],Sy={agent:{icon:"✦",color:"text-brand-500",bg:"bg-brand-500/10"},team:{icon:"◈",color:"text-blue-600",bg:"bg-blue-500/10"},skill:{icon:"⬡",color:"text-green-600",bg:"bg-green-500/10"}};function Cy({message:e,onConfirm:r,onCancel:s}){return t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:s,children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 max-w-sm mx-4 shadow-2xl",onClick:l=>l.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[t.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/15 flex items-center justify-center shrink-0",children:t.jsxs("svg",{className:"w-5 h-5 text-red-500",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"10"}),t.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),t.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:"Confirm Delete"}),t.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:e})]})]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{onClick:s,className:"px-4 py-1.5 text-xs text-fg-secondary hover:text-fg-primary border border-border-default hover:border-gray-600 rounded-lg transition-colors",children:"Cancel"}),t.jsx("button",{onClick:r,className:"px-4 py-1.5 text-xs bg-red-600 hover:bg-red-500 text-white rounded-lg transition-colors",children:"Delete"})]})]})})}function Oj(){const e=ks(),[r,s]=v.useState([]),[l,o]=v.useState([]),[d,c]=v.useState(!1),[h,m]=v.useState("all"),[f,x]=v.useState(null),[g,p]=v.useState(new Map),[y,w]=v.useState(null),[N,E]=v.useState(new Map),[A,C]=v.useState(null),[k,S]=v.useState(null);new Set(Hh.map(T=>T.roleName));const O=v.useCallback(()=>{c(!0),Promise.all([(Wa(wr.builderArtifacts)??re.builder.artifacts.list()).then(T=>T?.artifacts??[]).catch(()=>[]),(Wa(wr.builderAgents)??re.agents.list()).then(T=>T?.agents??[]).catch(()=>[]),(Wa(wr.builderHubMyItems)??Un.myItems()).then(T=>T?.items??[]).catch(()=>[]),(Wa(wr.builderInstalled)??re.builder.artifacts.installed()).then(T=>T?.installed??{}).catch(()=>({}))]).then(([T,D,z,_])=>{if(o(T),s(D),z.length>0){const V=new Map;for(const J of z){const U=J.itemType==="agent"?"agent":J.itemType==="team"?"team":"skill";for(const H of T)H.type===U&&(J.slug===H.name||J.name===(H.meta.displayName||H.meta.name||H.name))&&V.set(`${H.type}/${H.name}`,{id:J.id,name:J.name,slug:J.slug||H.name})}V.size>0&&E(J=>{const U=new Map(J);for(const[H,X]of V)U.set(H,X);return U})}const Y=new Map;for(const V of T){const J=`${V.type}/${V.name}`,U=_[J];U&&Y.set(J,{agentId:U.agentId,agentIds:U.agentIds,teamId:U.teamId})}p(Y)}).finally(()=>c(!1))},[]);v.useEffect(()=>{O();const T=D=>{D.detail?.page==="builder"&&O()};return window.addEventListener("markus:navigate",T),()=>window.removeEventListener("markus:navigate",T)},[O]);const R=(T,D)=>{const z=r.find(_=>_.role===D||_.name===D);z?jt.navigate("chat",{agentId:z.id}):jt.navigate("chat")},G=async T=>{const D=`${T.type}/${T.name}`;if(!g.has(D)){x(D);try{const z=await re.builder.artifacts.install(T.type,T.name),_={};z.agent&&typeof z.agent=="object"&&(_.agentId=z.agent.id),z.team&&typeof z.team=="object"&&(_.teamId=z.team.id),Array.isArray(z.agents)&&(_.agentIds=z.agents.map(Y=>Y.id)),p(Y=>new Map(Y).set(D,_)),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(z){console.error("Install failed:",z),alert(`Install failed: ${z}`)}finally{x(null)}}},I=async T=>{const D=`${T.type}/${T.name}`;if(g.has(D)){x(D);try{await re.builder.artifacts.uninstall(T.type,T.name),p(z=>{const _=new Map(z);return _.delete(D),_}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(z){console.error("Uninstall failed:",z),alert(`Uninstall failed: ${z}`)}finally{x(null)}}},Q=async T=>{const D=`${T.type}/${T.name}`;if(!N.has(D)){x(D);try{const z=await re.builder.artifacts.get(T.type,T.name),_=T.meta.displayName||T.meta.name||T.name,Y=T.meta.description||"",V=T.meta.category||"general",J=Array.isArray(T.meta.tags)?T.meta.tags:[],U=T.name,H=await Un.publishViaProxy({itemType:T.type==="team"?"team":T.type==="skill"?"skill":"agent",name:_,slug:U,description:Y,category:V,tags:J,config:T.meta,files:z.files&&Object.keys(z.files).length>0?z.files:void 0});H.id&&E(X=>{const L=new Map(X);return L.set(D,{id:H.id,name:_,slug:H.slug??U}),L})}catch(z){console.error("Share failed:",z),alert(`Share failed: ${z}`)}finally{x(null)}}},$=async()=>{if(!A)return;const{key:T}=A,D=N.get(T);if(C(null),!D)return;const z=D.id;x(T);try{await Un.deleteItem(z),E(_=>{const Y=new Map(_);return Y.delete(T),Y})}catch(_){console.error("Hub delete failed:",_),alert(`Failed to remove from Hub: ${_}`)}finally{x(null)}},F=async()=>{if(!y)return;const T=y,D=`${T.type}/${T.name}`;w(null),x(D);try{await re.builder.artifacts.delete(T.type,T.name),o(z=>z.filter(_=>!(_.type===T.type&&_.name===T.name))),p(z=>{const _=new Map(z);return _.delete(D),_}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(z){console.error("Delete failed:",z)}finally{x(null)}},B=h==="all"?l:l.filter(T=>T.type===h);return t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsxs("div",{className:`max-w-4xl ${e?"px-4 py-5":"px-6 py-10"}`,children:[t.jsxs("div",{className:"mb-10",children:[t.jsx("h1",{className:"text-2xl font-bold text-fg-primary",children:"Builder"}),t.jsx("p",{className:"text-sm text-fg-tertiary mt-2",children:"Create agents, teams, and skills through AI-powered conversations. Choose a builder to get started."})]}),t.jsx("div",{className:"grid gap-5",children:Hh.map(T=>t.jsx("button",{onClick:()=>R(T.roleId,T.roleName),className:`group text-left w-full rounded-xl border ${T.borderColor} bg-surface-secondary/60 ${e?"p-4":"p-6"} transition-all hover:bg-surface-secondary/80 hover:shadow-lg`,children:t.jsxs("div",{className:`flex items-start ${e?"gap-3":"gap-5"}`,children:[t.jsx("div",{className:`${e?"w-10 h-10 text-xl":"w-14 h-14 text-2xl"} rounded-xl ${T.bgColor} flex items-center justify-center shrink-0`,children:T.icon}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[t.jsx("h3",{className:`${e?"text-base":"text-lg"} font-semibold bg-gradient-to-r ${T.color} bg-clip-text text-transparent`,children:T.roleName}),t.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium uppercase tracking-wider",children:T.desc}),r.find(D=>D.role===T.roleName||D.name===T.roleName)&&t.jsx("span",{className:"w-2 h-2 rounded-full bg-green-500 shrink-0",title:"Agent online"})]}),t.jsx("p",{className:"text-sm text-fg-secondary leading-relaxed",children:T.detail}),t.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:T.examples.map((D,z)=>t.jsxs("span",{className:"text-[11px] text-fg-tertiary bg-surface-elevated/60 rounded-full px-3 py-1 border border-border-default",children:["“",D,"”"]},z))})]}),t.jsx("svg",{className:"w-5 h-5 text-fg-muted group-hover:text-fg-secondary transition-colors shrink-0 mt-1",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"9 18 15 12 9 6"})})]})},T.roleId))}),r.length>0&&!r.some(T=>Hh.some(D=>T.role===D.roleName||T.name===D.roleName))&&t.jsx("div",{className:"mt-8 p-4 rounded-lg border border-amber-500/30 bg-amber-500/10 text-amber-600 text-xs",children:"Builder agents have not been created yet. They will be automatically seeded on next server restart."}),t.jsxs("div",{className:"mt-14 mb-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-fg-primary",children:"My Creations"}),t.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:"Saved builder artifacts — install to deploy, or share to Markus Hub."})]}),t.jsx("button",{onClick:O,className:"text-xs text-fg-tertiary hover:text-fg-secondary transition-colors px-3 py-1.5 rounded-lg border border-border-default hover:border-gray-600",children:"Refresh"})]}),t.jsx("div",{className:"flex gap-2 mt-4",children:["all","agent","team","skill"].map(T=>t.jsx("button",{onClick:()=>m(T),className:`text-xs px-3 py-1.5 rounded-full border transition-colors ${h===T?"border-gray-600 bg-surface-elevated text-fg-primary":"border-border-default text-fg-tertiary hover:text-fg-secondary hover:border-gray-600"}`,children:T==="all"?"All":T.charAt(0).toUpperCase()+T.slice(1)+"s"},T))})]}),d&&l.length===0?t.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:"Loading artifacts..."}):B.length===0?t.jsxs("div",{className:"text-center py-12",children:[t.jsx("div",{className:"text-fg-tertiary text-sm",children:"No artifacts found."}),t.jsx("div",{className:"text-fg-muted text-xs mt-1",children:"Use a builder above to create agents, teams, or skills."})]}):t.jsx("div",{className:"grid gap-3",children:B.map(T=>{const D=Sy[T.type]??Sy.agent,z=T.meta.displayName||T.meta.name||T.name,_=T.meta.description||"",Y=`${T.type}/${T.name}`,V=f===Y,J=t.jsxs("div",{className:`flex items-center gap-1.5 ${e?"flex-wrap":"shrink-0"}`,children:[g.has(Y)?t.jsx("button",{onClick:()=>I(T),disabled:V,className:"text-xs px-3 py-1.5 rounded-lg border border-green-600/30 text-green-600 hover:bg-red-500/10 hover:text-red-500 hover:border-red-500/30 transition-colors disabled:opacity-50",children:V?"Uninstalling...":"Uninstall"}):t.jsx("button",{onClick:()=>G(T),disabled:V,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50",children:V?"Installing...":"Install"}),N.has(Y)?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:()=>C({key:Y,name:T.meta.displayName||T.meta.name||T.name}),disabled:V,className:"text-xs px-3 py-1.5 rounded-lg border border-green-600/30 text-green-600 hover:text-red-500 hover:border-red-500/30 hover:bg-red-500/10 transition-colors disabled:opacity-50",title:"Remove from Markus Hub",children:"Shared"}),t.jsx("button",{onClick:()=>{const U=N.get(Y),H=Un.getUser();if(!U||!H)return;const X=`${Un.getUrl()}/${encodeURIComponent(H.username)}/${encodeURIComponent(U.slug)}`;navigator.clipboard.writeText(X).then(()=>{S(Y),setTimeout(()=>S(L=>L===Y?null:L),2e3)}).catch(()=>{})},className:"text-xs px-2 py-1.5 rounded-lg border border-green-600/20 text-green-500 hover:text-green-600 hover:border-green-500/40 transition-colors",title:"Copy Hub link",children:k===Y?t.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"20 6 9 17 4 12"})}):t.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),t.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})})]}):t.jsx("button",{onClick:()=>Q(T),disabled:V,className:"text-xs px-3 py-1.5 rounded-lg border border-border-default text-fg-secondary hover:text-green-600 hover:border-green-500/30 transition-colors disabled:opacity-50",children:V?"Sharing...":"Share"}),t.jsx("button",{onClick:()=>w(T),disabled:V,className:"text-xs px-2 py-1.5 rounded-lg text-fg-tertiary hover:text-red-500 hover:bg-red-500/10 transition-colors disabled:opacity-50",title:"Delete",children:t.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})})]});return t.jsxs("div",{className:"group rounded-lg border border-border-default bg-surface-secondary/60 p-4 hover:border-gray-600 transition-all overflow-hidden",children:[t.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[t.jsx("div",{className:`w-9 h-9 rounded-lg ${D.bg} flex items-center justify-center text-lg shrink-0`,children:D.icon}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[t.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:z}),t.jsx("span",{className:`text-[10px] font-medium uppercase tracking-wider ${D.color}`,children:T.type})]}),_&&t.jsx("p",{className:"text-xs text-fg-tertiary line-clamp-2",children:_}),t.jsxs("div",{className:"flex items-center gap-3 mt-2 text-[10px] text-fg-tertiary min-w-0",children:[t.jsx("button",{onClick:U=>{U.stopPropagation(),re.system.openPath(T.path).catch(()=>{})},className:"hover:text-fg-secondary transition-colors truncate min-w-0",title:T.path,children:wA(T.path)}),t.jsx("span",{className:"shrink-0",children:new Date(T.updatedAt).toLocaleDateString()})]})]}),!e&&J]}),e&&t.jsx("div",{className:"mt-3 pt-3 border-t border-border-default/50",children:J})]},Y)})}),y&&t.jsx(Cy,{message:`Delete "${y.meta.displayName||y.meta.name||y.name}"? This cannot be undone.`,onConfirm:F,onCancel:()=>w(null)}),A&&t.jsx(Cy,{message:`Remove "${A.name}" from Markus Hub? It will no longer be available for others to download.`,onConfirm:()=>{$()},onCancel:()=>C(null)})]})})}function Rj(){const[e,r]=v.useState(null),[s,l]=v.useState([]),[o,d]=v.useState(null),[c,h]=v.useState(!0),[m,f]=v.useState(""),[x,g]=v.useState(!1),[p,y]=v.useState(""),[w,N]=v.useState(""),[E,A]=v.useState("normal"),[C,k]=v.useState(""),[S,O]=v.useState(!1),[R,G]=v.useState(!1),[I,Q]=v.useState("auto"),[$,F]=v.useState(10),[B,T]=v.useState(!0),D=v.useCallback(async()=>{try{const[H,X,L]=await Promise.all([re.governance.getSystemStatus(),re.governance.getAnnouncements(),re.governance.getPolicy()]);r(H),l(X.announcements),d(L.policy)}catch{}h(!1)},[]);v.useEffect(()=>{D()},[D]);const z=H=>{f(H),setTimeout(()=>f(""),3e3)},_=async()=>{try{await re.governance.pauseAll(C||void 0),z("All agents paused"),O(!1),k(""),D()}catch(H){z(`Error: ${H}`)}},Y=async()=>{try{await re.governance.resumeAll(),z("All agents resumed"),D()}catch(H){z(`Error: ${H}`)}},V=async()=>{if(confirm("EMERGENCY STOP will terminate all agents immediately. Continue?"))try{await re.governance.emergencyStop("Manual emergency stop from UI"),z("EMERGENCY STOP executed"),D()}catch(H){z(`Error: ${H}`)}},J=async()=>{if(p.trim())try{await re.governance.createAnnouncement({title:p,message:w,priority:E,scope:"all"}),g(!1),y(""),N(""),z("Announcement created"),D()}catch(H){z(`Error: ${H}`)}},U=async()=>{try{const H={defaultApprovalTier:I,maxTasksPerAgent:$,requireRequirement:B};await re.governance.setPolicy(H),z("Policy updated"),G(!1),D()}catch(H){z(`Error: ${H}`)}};return c?t.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary",children:"Loading…"}):t.jsxs("div",{className:"flex-1 overflow-y-auto",children:[t.jsxs("div",{className:"sticky top-0 z-10 bg-surface-secondary border-b border-border-default px-6 h-14 flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-fg-primary",children:"Governance"}),t.jsx("p",{className:"text-xs text-fg-tertiary",children:"System controls, announcements, and governance policy"})]}),m&&t.jsx("div",{className:"px-3 py-1.5 bg-green-500/10 text-green-600 text-xs rounded-lg",children:m})]}),t.jsxs("div",{className:"p-6 space-y-6 max-w-5xl",children:[t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsx("h3",{className:"text-sm font-semibold text-fg-secondary mb-4",children:"System Status"}),t.jsxs("div",{className:"flex items-center gap-4 mb-5",children:[t.jsx(Ey,{label:"Global",active:!e?.globalPaused,activeText:"Running",inactiveText:"Paused"}),t.jsx(Ey,{label:"Emergency",active:!e?.emergencyMode,activeText:"Normal",inactiveText:"ACTIVE",danger:!0})]}),t.jsxs("div",{className:"flex flex-wrap gap-3",children:[e?.globalPaused?t.jsx("button",{onClick:Y,className:"btn-primary text-sm px-4 py-2 rounded-lg bg-green-600 hover:bg-green-500",children:"▶ Resume All Agents"}):t.jsx("button",{onClick:()=>O(!0),className:"text-sm px-4 py-2 rounded-lg bg-amber-600 hover:bg-amber-500 text-white",children:"⏸ Pause All Agents"}),t.jsx("button",{onClick:V,className:"text-sm px-4 py-2 rounded-lg bg-red-700 hover:bg-red-600 text-white",children:"⚠ Emergency Stop"})]})]}),t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("h3",{className:"text-sm font-semibold text-fg-secondary",children:"Governance Policy"}),t.jsx("button",{onClick:()=>{G(!R),o&&(Q(o.defaultApprovalTier),F(o.maxTasksPerAgent??10),T(o.requireRequirement??!0))},className:"text-xs text-brand-500 hover:text-brand-500",children:R?"Cancel":"Edit"})]}),R?t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-xs text-fg-tertiary block mb-1",children:"Default Approval Tier"}),t.jsxs("select",{value:I,onChange:H=>Q(H.target.value),className:"bg-surface-elevated border border-border-default rounded-lg px-3 py-2 text-sm text-fg-primary w-48",children:[t.jsx("option",{value:"auto",children:"Auto (no approval)"}),t.jsx("option",{value:"manager",children:"Manager Approval"}),t.jsx("option",{value:"human",children:"Human Approval"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-xs text-fg-tertiary block mb-1",children:"Max Tasks per Agent"}),t.jsx("input",{type:"number",value:$,onChange:H=>F(Number(H.target.value)),className:"bg-surface-elevated border border-border-default rounded-lg px-3 py-2 text-sm text-fg-primary w-32"})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:B,onChange:H=>T(H.target.checked),className:"sr-only peer"}),t.jsx("div",{className:"w-9 h-5 bg-surface-overlay peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-brand-600"})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-xs text-fg-secondary",children:"Require Requirement for Tasks"}),t.jsx("p",{className:"text-[10px] text-fg-tertiary",children:"Top-level tasks must link to an approved requirement"})]})]}),t.jsx("button",{onClick:U,className:"btn-primary text-sm px-4 py-2 rounded-lg",children:"Save Policy"})]}):o?t.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-fg-tertiary",children:"Approval Tier:"}),t.jsx("span",{className:"ml-2 text-fg-primary",children:o.defaultApprovalTier})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-fg-tertiary",children:"Max Tasks/Agent:"}),t.jsx("span",{className:"ml-2 text-fg-primary",children:o.maxTasksPerAgent??"—"})]}),t.jsxs("div",{className:"col-span-2",children:[t.jsx("span",{className:"text-fg-tertiary",children:"Require Requirement:"}),t.jsx("span",{className:`ml-2 px-2 py-0.5 rounded-full text-xs font-medium ${o.requireRequirement!==!1?"bg-brand-500/10 text-brand-500":"bg-surface-overlay text-fg-secondary"}`,children:o.requireRequirement!==!1?"Enabled":"Disabled"})]}),o.rules&&o.rules.length>0&&t.jsxs("div",{className:"col-span-2",children:[t.jsx("span",{className:"text-fg-tertiary",children:"Rules:"}),t.jsx("div",{className:"mt-1 space-y-1",children:o.rules.map((H,X)=>t.jsxs("div",{className:"text-xs bg-surface-elevated rounded px-2 py-1 text-fg-secondary",children:["When ",t.jsx("code",{className:"text-amber-600",children:H.condition})," → ",t.jsx("span",{className:"text-brand-500",children:H.approvalTier})]},X))})]})]}):t.jsx("p",{className:"text-sm text-fg-tertiary",children:"No governance policy configured. Click Edit to set one."})]}),t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("h3",{className:"text-sm font-semibold text-fg-secondary",children:"System Announcements"}),t.jsx("button",{onClick:()=>g(!x),className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white",children:"+ New Announcement"})]}),x&&t.jsxs("div",{className:"mb-4 p-4 bg-surface-elevated rounded-lg space-y-3",children:[t.jsx("input",{value:p,onChange:H=>y(H.target.value),placeholder:"Title",className:"w-full bg-surface-overlay border border-gray-600 rounded-lg px-3 py-2 text-sm text-fg-primary"}),t.jsx("textarea",{value:w,onChange:H=>N(H.target.value),placeholder:"Message (optional)",className:"w-full bg-surface-overlay border border-gray-600 rounded-lg px-3 py-2 text-sm text-fg-primary h-20 resize-none"}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("select",{value:E,onChange:H=>A(H.target.value),className:"bg-surface-overlay border border-gray-600 rounded-lg px-3 py-2 text-sm text-fg-primary",children:[t.jsx("option",{value:"low",children:"Low"}),t.jsx("option",{value:"normal",children:"Normal"}),t.jsx("option",{value:"high",children:"High"}),t.jsx("option",{value:"critical",children:"Critical"})]}),t.jsx("button",{onClick:J,className:"btn-primary text-sm px-4 py-2 rounded-lg",children:"Publish"}),t.jsx("button",{onClick:()=>g(!1),className:"text-sm text-fg-tertiary hover:text-fg-secondary",children:"Cancel"})]})]}),s.length===0?t.jsx("p",{className:"text-sm text-fg-tertiary",children:"No announcements."}):t.jsx("div",{className:"space-y-2",children:s.map(H=>t.jsxs("div",{className:"flex items-start gap-3 p-3 bg-surface-elevated/50 rounded-lg",children:[t.jsx(NA,{priority:H.priority}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:H.title}),H.message&&t.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:H.message}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-1",children:new Date(H.createdAt).toLocaleString()})]})]},H.id))})]})]}),S&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-96 space-y-4",children:[t.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:"Pause All Agents"}),t.jsx("p",{className:"text-sm text-fg-secondary",children:"All agents will be paused. They will stop processing tasks until resumed."}),t.jsx("input",{value:C,onChange:H=>k(H.target.value),placeholder:"Reason (optional)",className:"w-full bg-surface-elevated border border-border-default rounded-lg px-3 py-2 text-sm text-fg-primary"}),t.jsxs("div",{className:"flex justify-end gap-3",children:[t.jsx("button",{onClick:()=>O(!1),className:"text-sm text-fg-tertiary hover:text-fg-secondary",children:"Cancel"}),t.jsx("button",{onClick:_,className:"text-sm px-4 py-2 rounded-lg bg-amber-600 hover:bg-amber-500 text-white",children:"Pause All"})]})]})})]})}function Ey({label:e,active:r,activeText:s,inactiveText:l,danger:o}){return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"text-xs text-fg-tertiary",children:[e,":"]}),t.jsx("span",{className:`px-2.5 py-1 rounded-full text-xs font-medium ${r?"bg-green-500/10 text-green-600":o?"bg-red-500/10 text-red-500 animate-pulse":"bg-amber-500/10 text-amber-600"}`,children:r?s:l})]})}function NA({priority:e}){const r=e==="critical"?"bg-red-500":e==="high"?"bg-amber-500":e==="normal"?"bg-blue-500":"bg-gray-500";return t.jsx("div",{className:`w-2 h-2 rounded-full mt-1.5 shrink-0 ${r}`})}function Fn(e){if(typeof e=="string"||typeof e=="number")return""+e;let r="";if(Array.isArray(e))for(let s=0,l;s<e.length;s++)(l=Fn(e[s]))!==""&&(r+=(r&&" ")+l);else for(let s in e)e[s]&&(r+=(r&&" ")+s);return r}var kA={value:()=>{}};function eu(){for(var e=0,r=arguments.length,s={},l;e<r;++e){if(!(l=arguments[e]+"")||l in s||/[\s.]/.test(l))throw new Error("illegal type: "+l);s[l]=[]}return new gd(s)}function gd(e){this._=e}function SA(e,r){return e.trim().split(/^|\s+/).map(function(s){var l="",o=s.indexOf(".");if(o>=0&&(l=s.slice(o+1),s=s.slice(0,o)),s&&!r.hasOwnProperty(s))throw new Error("unknown type: "+s);return{type:s,name:l}})}gd.prototype=eu.prototype={constructor:gd,on:function(e,r){var s=this._,l=SA(e+"",s),o,d=-1,c=l.length;if(arguments.length<2){for(;++d<c;)if((o=(e=l[d]).type)&&(o=CA(s[o],e.name)))return o;return}if(r!=null&&typeof r!="function")throw new Error("invalid callback: "+r);for(;++d<c;)if(o=(e=l[d]).type)s[o]=Ty(s[o],e.name,r);else if(r==null)for(o in s)s[o]=Ty(s[o],e.name,null);return this},copy:function(){var e={},r=this._;for(var s in r)e[s]=r[s].slice();return new gd(e)},call:function(e,r){if((o=arguments.length-2)>0)for(var s=new Array(o),l=0,o,d;l<o;++l)s[l]=arguments[l+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(d=this._[e],l=0,o=d.length;l<o;++l)d[l].value.apply(r,s)},apply:function(e,r,s){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var l=this._[e],o=0,d=l.length;o<d;++o)l[o].value.apply(r,s)}};function CA(e,r){for(var s=0,l=e.length,o;s<l;++s)if((o=e[s]).name===r)return o.value}function Ty(e,r,s){for(var l=0,o=e.length;l<o;++l)if(e[l].name===r){e[l]=kA,e=e.slice(0,l).concat(e.slice(l+1));break}return s!=null&&e.push({name:r,value:s}),e}var Nm="http://www.w3.org/1999/xhtml";const Ay={svg:"http://www.w3.org/2000/svg",xhtml:Nm,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function tu(e){var r=e+="",s=r.indexOf(":");return s>=0&&(r=e.slice(0,s))!=="xmlns"&&(e=e.slice(s+1)),Ay.hasOwnProperty(r)?{space:Ay[r],local:e}:e}function EA(e){return function(){var r=this.ownerDocument,s=this.namespaceURI;return s===Nm&&r.documentElement.namespaceURI===Nm?r.createElement(e):r.createElementNS(s,e)}}function TA(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Lj(e){var r=tu(e);return(r.local?TA:EA)(r)}function AA(){}function dx(e){return e==null?AA:function(){return this.querySelector(e)}}function _A(e){typeof e!="function"&&(e=dx(e));for(var r=this._groups,s=r.length,l=new Array(s),o=0;o<s;++o)for(var d=r[o],c=d.length,h=l[o]=new Array(c),m,f,x=0;x<c;++x)(m=d[x])&&(f=e.call(m,m.__data__,x,d))&&("__data__"in m&&(f.__data__=m.__data__),h[x]=f);return new Br(l,this._parents)}function MA(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function DA(){return[]}function zj(e){return e==null?DA:function(){return this.querySelectorAll(e)}}function OA(e){return function(){return MA(e.apply(this,arguments))}}function RA(e){typeof e=="function"?e=OA(e):e=zj(e);for(var r=this._groups,s=r.length,l=[],o=[],d=0;d<s;++d)for(var c=r[d],h=c.length,m,f=0;f<h;++f)(m=c[f])&&(l.push(e.call(m,m.__data__,f,c)),o.push(m));return new Br(l,o)}function Ij(e){return function(){return this.matches(e)}}function $j(e){return function(r){return r.matches(e)}}var LA=Array.prototype.find;function zA(e){return function(){return LA.call(this.children,e)}}function IA(){return this.firstElementChild}function $A(e){return this.select(e==null?IA:zA(typeof e=="function"?e:$j(e)))}var BA=Array.prototype.filter;function HA(){return Array.from(this.children)}function PA(e){return function(){return BA.call(this.children,e)}}function UA(e){return this.selectAll(e==null?HA:PA(typeof e=="function"?e:$j(e)))}function qA(e){typeof e!="function"&&(e=Ij(e));for(var r=this._groups,s=r.length,l=new Array(s),o=0;o<s;++o)for(var d=r[o],c=d.length,h=l[o]=[],m,f=0;f<c;++f)(m=d[f])&&e.call(m,m.__data__,f,d)&&h.push(m);return new Br(l,this._parents)}function Bj(e){return new Array(e.length)}function FA(){return new Br(this._enter||this._groups.map(Bj),this._parents)}function Od(e,r){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=r}Od.prototype={constructor:Od,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,r){return this._parent.insertBefore(e,r)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function VA(e){return function(){return e}}function YA(e,r,s,l,o,d){for(var c=0,h,m=r.length,f=d.length;c<f;++c)(h=r[c])?(h.__data__=d[c],l[c]=h):s[c]=new Od(e,d[c]);for(;c<m;++c)(h=r[c])&&(o[c]=h)}function GA(e,r,s,l,o,d,c){var h,m,f=new Map,x=r.length,g=d.length,p=new Array(x),y;for(h=0;h<x;++h)(m=r[h])&&(p[h]=y=c.call(m,m.__data__,h,r)+"",f.has(y)?o[h]=m:f.set(y,m));for(h=0;h<g;++h)y=c.call(e,d[h],h,d)+"",(m=f.get(y))?(l[h]=m,m.__data__=d[h],f.delete(y)):s[h]=new Od(e,d[h]);for(h=0;h<x;++h)(m=r[h])&&f.get(p[h])===m&&(o[h]=m)}function XA(e){return e.__data__}function ZA(e,r){if(!arguments.length)return Array.from(this,XA);var s=r?GA:YA,l=this._parents,o=this._groups;typeof e!="function"&&(e=VA(e));for(var d=o.length,c=new Array(d),h=new Array(d),m=new Array(d),f=0;f<d;++f){var x=l[f],g=o[f],p=g.length,y=QA(e.call(x,x&&x.__data__,f,l)),w=y.length,N=h[f]=new Array(w),E=c[f]=new Array(w),A=m[f]=new Array(p);s(x,g,N,E,A,y,r);for(var C=0,k=0,S,O;C<w;++C)if(S=N[C]){for(C>=k&&(k=C+1);!(O=E[k])&&++k<w;);S._next=O||null}}return c=new Br(c,l),c._enter=h,c._exit=m,c}function QA(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function KA(){return new Br(this._exit||this._groups.map(Bj),this._parents)}function JA(e,r,s){var l=this.enter(),o=this,d=this.exit();return typeof e=="function"?(l=e(l),l&&(l=l.selection())):l=l.append(e+""),r!=null&&(o=r(o),o&&(o=o.selection())),s==null?d.remove():s(d),l&&o?l.merge(o).order():o}function WA(e){for(var r=e.selection?e.selection():e,s=this._groups,l=r._groups,o=s.length,d=l.length,c=Math.min(o,d),h=new Array(o),m=0;m<c;++m)for(var f=s[m],x=l[m],g=f.length,p=h[m]=new Array(g),y,w=0;w<g;++w)(y=f[w]||x[w])&&(p[w]=y);for(;m<o;++m)h[m]=s[m];return new Br(h,this._parents)}function e_(){for(var e=this._groups,r=-1,s=e.length;++r<s;)for(var l=e[r],o=l.length-1,d=l[o],c;--o>=0;)(c=l[o])&&(d&&c.compareDocumentPosition(d)^4&&d.parentNode.insertBefore(c,d),d=c);return this}function t_(e){e||(e=n_);function r(g,p){return g&&p?e(g.__data__,p.__data__):!g-!p}for(var s=this._groups,l=s.length,o=new Array(l),d=0;d<l;++d){for(var c=s[d],h=c.length,m=o[d]=new Array(h),f,x=0;x<h;++x)(f=c[x])&&(m[x]=f);m.sort(r)}return new Br(o,this._parents).order()}function n_(e,r){return e<r?-1:e>r?1:e>=r?0:NaN}function r_(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function s_(){return Array.from(this)}function a_(){for(var e=this._groups,r=0,s=e.length;r<s;++r)for(var l=e[r],o=0,d=l.length;o<d;++o){var c=l[o];if(c)return c}return null}function l_(){let e=0;for(const r of this)++e;return e}function i_(){return!this.node()}function o_(e){for(var r=this._groups,s=0,l=r.length;s<l;++s)for(var o=r[s],d=0,c=o.length,h;d<c;++d)(h=o[d])&&e.call(h,h.__data__,d,o);return this}function c_(e){return function(){this.removeAttribute(e)}}function d_(e){return function(){this.removeAttributeNS(e.space,e.local)}}function u_(e,r){return function(){this.setAttribute(e,r)}}function f_(e,r){return function(){this.setAttributeNS(e.space,e.local,r)}}function h_(e,r){return function(){var s=r.apply(this,arguments);s==null?this.removeAttribute(e):this.setAttribute(e,s)}}function m_(e,r){return function(){var s=r.apply(this,arguments);s==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,s)}}function x_(e,r){var s=tu(e);if(arguments.length<2){var l=this.node();return s.local?l.getAttributeNS(s.space,s.local):l.getAttribute(s)}return this.each((r==null?s.local?d_:c_:typeof r=="function"?s.local?m_:h_:s.local?f_:u_)(s,r))}function Hj(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function g_(e){return function(){this.style.removeProperty(e)}}function p_(e,r,s){return function(){this.style.setProperty(e,r,s)}}function b_(e,r,s){return function(){var l=r.apply(this,arguments);l==null?this.style.removeProperty(e):this.style.setProperty(e,l,s)}}function y_(e,r,s){return arguments.length>1?this.each((r==null?g_:typeof r=="function"?b_:p_)(e,r,s??"")):Wl(this.node(),e)}function Wl(e,r){return e.style.getPropertyValue(r)||Hj(e).getComputedStyle(e,null).getPropertyValue(r)}function v_(e){return function(){delete this[e]}}function j_(e,r){return function(){this[e]=r}}function w_(e,r){return function(){var s=r.apply(this,arguments);s==null?delete this[e]:this[e]=s}}function N_(e,r){return arguments.length>1?this.each((r==null?v_:typeof r=="function"?w_:j_)(e,r)):this.node()[e]}function Pj(e){return e.trim().split(/^|\s+/)}function ux(e){return e.classList||new Uj(e)}function Uj(e){this._node=e,this._names=Pj(e.getAttribute("class")||"")}Uj.prototype={add:function(e){var r=this._names.indexOf(e);r<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var r=this._names.indexOf(e);r>=0&&(this._names.splice(r,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function qj(e,r){for(var s=ux(e),l=-1,o=r.length;++l<o;)s.add(r[l])}function Fj(e,r){for(var s=ux(e),l=-1,o=r.length;++l<o;)s.remove(r[l])}function k_(e){return function(){qj(this,e)}}function S_(e){return function(){Fj(this,e)}}function C_(e,r){return function(){(r.apply(this,arguments)?qj:Fj)(this,e)}}function E_(e,r){var s=Pj(e+"");if(arguments.length<2){for(var l=ux(this.node()),o=-1,d=s.length;++o<d;)if(!l.contains(s[o]))return!1;return!0}return this.each((typeof r=="function"?C_:r?k_:S_)(s,r))}function T_(){this.textContent=""}function A_(e){return function(){this.textContent=e}}function __(e){return function(){var r=e.apply(this,arguments);this.textContent=r??""}}function M_(e){return arguments.length?this.each(e==null?T_:(typeof e=="function"?__:A_)(e)):this.node().textContent}function D_(){this.innerHTML=""}function O_(e){return function(){this.innerHTML=e}}function R_(e){return function(){var r=e.apply(this,arguments);this.innerHTML=r??""}}function L_(e){return arguments.length?this.each(e==null?D_:(typeof e=="function"?R_:O_)(e)):this.node().innerHTML}function z_(){this.nextSibling&&this.parentNode.appendChild(this)}function I_(){return this.each(z_)}function $_(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function B_(){return this.each($_)}function H_(e){var r=typeof e=="function"?e:Lj(e);return this.select(function(){return this.appendChild(r.apply(this,arguments))})}function P_(){return null}function U_(e,r){var s=typeof e=="function"?e:Lj(e),l=r==null?P_:typeof r=="function"?r:dx(r);return this.select(function(){return this.insertBefore(s.apply(this,arguments),l.apply(this,arguments)||null)})}function q_(){var e=this.parentNode;e&&e.removeChild(this)}function F_(){return this.each(q_)}function V_(){var e=this.cloneNode(!1),r=this.parentNode;return r?r.insertBefore(e,this.nextSibling):e}function Y_(){var e=this.cloneNode(!0),r=this.parentNode;return r?r.insertBefore(e,this.nextSibling):e}function G_(e){return this.select(e?Y_:V_)}function X_(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Z_(e){return function(r){e.call(this,r,this.__data__)}}function Q_(e){return e.trim().split(/^|\s+/).map(function(r){var s="",l=r.indexOf(".");return l>=0&&(s=r.slice(l+1),r=r.slice(0,l)),{type:r,name:s}})}function K_(e){return function(){var r=this.__on;if(r){for(var s=0,l=-1,o=r.length,d;s<o;++s)d=r[s],(!e.type||d.type===e.type)&&d.name===e.name?this.removeEventListener(d.type,d.listener,d.options):r[++l]=d;++l?r.length=l:delete this.__on}}}function J_(e,r,s){return function(){var l=this.__on,o,d=Z_(r);if(l){for(var c=0,h=l.length;c<h;++c)if((o=l[c]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=d,o.options=s),o.value=r;return}}this.addEventListener(e.type,d,s),o={type:e.type,name:e.name,value:r,listener:d,options:s},l?l.push(o):this.__on=[o]}}function W_(e,r,s){var l=Q_(e+""),o,d=l.length,c;if(arguments.length<2){var h=this.node().__on;if(h){for(var m=0,f=h.length,x;m<f;++m)for(o=0,x=h[m];o<d;++o)if((c=l[o]).type===x.type&&c.name===x.name)return x.value}return}for(h=r?J_:K_,o=0;o<d;++o)this.each(h(l[o],r,s));return this}function Vj(e,r,s){var l=Hj(e),o=l.CustomEvent;typeof o=="function"?o=new o(r,s):(o=l.document.createEvent("Event"),s?(o.initEvent(r,s.bubbles,s.cancelable),o.detail=s.detail):o.initEvent(r,!1,!1)),e.dispatchEvent(o)}function e6(e,r){return function(){return Vj(this,e,r)}}function t6(e,r){return function(){return Vj(this,e,r.apply(this,arguments))}}function n6(e,r){return this.each((typeof r=="function"?t6:e6)(e,r))}function*r6(){for(var e=this._groups,r=0,s=e.length;r<s;++r)for(var l=e[r],o=0,d=l.length,c;o<d;++o)(c=l[o])&&(yield c)}var Yj=[null];function Br(e,r){this._groups=e,this._parents=r}function $o(){return new Br([[document.documentElement]],Yj)}function s6(){return this}Br.prototype=$o.prototype={constructor:Br,select:_A,selectAll:RA,selectChild:$A,selectChildren:UA,filter:qA,data:ZA,enter:FA,exit:KA,join:JA,merge:WA,selection:s6,order:e_,sort:t_,call:r_,nodes:s_,node:a_,size:l_,empty:i_,each:o_,attr:x_,style:y_,property:N_,classed:E_,text:M_,html:L_,raise:I_,lower:B_,append:H_,insert:U_,remove:F_,clone:G_,datum:X_,on:W_,dispatch:n6,[Symbol.iterator]:r6};function Ir(e){return typeof e=="string"?new Br([[document.querySelector(e)]],[document.documentElement]):new Br([[e]],Yj)}function a6(e){let r;for(;r=e.sourceEvent;)e=r;return e}function ts(e,r){if(e=a6(e),r===void 0&&(r=e.currentTarget),r){var s=r.ownerSVGElement||r;if(s.createSVGPoint){var l=s.createSVGPoint();return l.x=e.clientX,l.y=e.clientY,l=l.matrixTransform(r.getScreenCTM().inverse()),[l.x,l.y]}if(r.getBoundingClientRect){var o=r.getBoundingClientRect();return[e.clientX-o.left-r.clientLeft,e.clientY-o.top-r.clientTop]}}return[e.pageX,e.pageY]}const l6={passive:!1},No={capture:!0,passive:!1};function Ph(e){e.stopImmediatePropagation()}function Ql(e){e.preventDefault(),e.stopImmediatePropagation()}function Gj(e){var r=e.document.documentElement,s=Ir(e).on("dragstart.drag",Ql,No);"onselectstart"in r?s.on("selectstart.drag",Ql,No):(r.__noselect=r.style.MozUserSelect,r.style.MozUserSelect="none")}function Xj(e,r){var s=e.document.documentElement,l=Ir(e).on("dragstart.drag",null);r&&(l.on("click.drag",Ql,No),setTimeout(function(){l.on("click.drag",null)},0)),"onselectstart"in s?l.on("selectstart.drag",null):(s.style.MozUserSelect=s.__noselect,delete s.__noselect)}const rd=e=>()=>e;function km(e,{sourceEvent:r,subject:s,target:l,identifier:o,active:d,x:c,y:h,dx:m,dy:f,dispatch:x}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:s,enumerable:!0,configurable:!0},target:{value:l,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:d,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:h,enumerable:!0,configurable:!0},dx:{value:m,enumerable:!0,configurable:!0},dy:{value:f,enumerable:!0,configurable:!0},_:{value:x}})}km.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function i6(e){return!e.ctrlKey&&!e.button}function o6(){return this.parentNode}function c6(e,r){return r??{x:e.x,y:e.y}}function d6(){return navigator.maxTouchPoints||"ontouchstart"in this}function Zj(){var e=i6,r=o6,s=c6,l=d6,o={},d=eu("start","drag","end"),c=0,h,m,f,x,g=0;function p(S){S.on("mousedown.drag",y).filter(l).on("touchstart.drag",E).on("touchmove.drag",A,l6).on("touchend.drag touchcancel.drag",C).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function y(S,O){if(!(x||!e.call(this,S,O))){var R=k(this,r.call(this,S,O),S,O,"mouse");R&&(Ir(S.view).on("mousemove.drag",w,No).on("mouseup.drag",N,No),Gj(S.view),Ph(S),f=!1,h=S.clientX,m=S.clientY,R("start",S))}}function w(S){if(Ql(S),!f){var O=S.clientX-h,R=S.clientY-m;f=O*O+R*R>g}o.mouse("drag",S)}function N(S){Ir(S.view).on("mousemove.drag mouseup.drag",null),Xj(S.view,f),Ql(S),o.mouse("end",S)}function E(S,O){if(e.call(this,S,O)){var R=S.changedTouches,G=r.call(this,S,O),I=R.length,Q,$;for(Q=0;Q<I;++Q)($=k(this,G,S,O,R[Q].identifier,R[Q]))&&(Ph(S),$("start",S,R[Q]))}}function A(S){var O=S.changedTouches,R=O.length,G,I;for(G=0;G<R;++G)(I=o[O[G].identifier])&&(Ql(S),I("drag",S,O[G]))}function C(S){var O=S.changedTouches,R=O.length,G,I;for(x&&clearTimeout(x),x=setTimeout(function(){x=null},500),G=0;G<R;++G)(I=o[O[G].identifier])&&(Ph(S),I("end",S,O[G]))}function k(S,O,R,G,I,Q){var $=d.copy(),F=ts(Q||R,O),B,T,D;if((D=s.call(S,new km("beforestart",{sourceEvent:R,target:p,identifier:I,active:c,x:F[0],y:F[1],dx:0,dy:0,dispatch:$}),G))!=null)return B=D.x-F[0]||0,T=D.y-F[1]||0,function z(_,Y,V){var J=F,U;switch(_){case"start":o[I]=z,U=c++;break;case"end":delete o[I],--c;case"drag":F=ts(V||Y,O),U=c;break}$.call(_,S,new km(_,{sourceEvent:Y,subject:D,target:p,identifier:I,active:U,x:F[0]+B,y:F[1]+T,dx:F[0]-J[0],dy:F[1]-J[1],dispatch:$}),G)}}return p.filter=function(S){return arguments.length?(e=typeof S=="function"?S:rd(!!S),p):e},p.container=function(S){return arguments.length?(r=typeof S=="function"?S:rd(S),p):r},p.subject=function(S){return arguments.length?(s=typeof S=="function"?S:rd(S),p):s},p.touchable=function(S){return arguments.length?(l=typeof S=="function"?S:rd(!!S),p):l},p.on=function(){var S=d.on.apply(d,arguments);return S===d?p:S},p.clickDistance=function(S){return arguments.length?(g=(S=+S)*S,p):Math.sqrt(g)},p}function fx(e,r,s){e.prototype=r.prototype=s,s.constructor=e}function Qj(e,r){var s=Object.create(e.prototype);for(var l in r)s[l]=r[l];return s}function Bo(){}var ko=.7,Rd=1/ko,Kl="\\s*([+-]?\\d+)\\s*",So="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",js="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",u6=/^#([0-9a-f]{3,8})$/,f6=new RegExp(`^rgb\\(${Kl},${Kl},${Kl}\\)$`),h6=new RegExp(`^rgb\\(${js},${js},${js}\\)$`),m6=new RegExp(`^rgba\\(${Kl},${Kl},${Kl},${So}\\)$`),x6=new RegExp(`^rgba\\(${js},${js},${js},${So}\\)$`),g6=new RegExp(`^hsl\\(${So},${js},${js}\\)$`),p6=new RegExp(`^hsla\\(${So},${js},${js},${So}\\)$`),_y={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};fx(Bo,al,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:My,formatHex:My,formatHex8:b6,formatHsl:y6,formatRgb:Dy,toString:Dy});function My(){return this.rgb().formatHex()}function b6(){return this.rgb().formatHex8()}function y6(){return Kj(this).formatHsl()}function Dy(){return this.rgb().formatRgb()}function al(e){var r,s;return e=(e+"").trim().toLowerCase(),(r=u6.exec(e))?(s=r[1].length,r=parseInt(r[1],16),s===6?Oy(r):s===3?new Nr(r>>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):s===8?sd(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):s===4?sd(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|r&240,((r&15)<<4|r&15)/255):null):(r=f6.exec(e))?new Nr(r[1],r[2],r[3],1):(r=h6.exec(e))?new Nr(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=m6.exec(e))?sd(r[1],r[2],r[3],r[4]):(r=x6.exec(e))?sd(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=g6.exec(e))?zy(r[1],r[2]/100,r[3]/100,1):(r=p6.exec(e))?zy(r[1],r[2]/100,r[3]/100,r[4]):_y.hasOwnProperty(e)?Oy(_y[e]):e==="transparent"?new Nr(NaN,NaN,NaN,0):null}function Oy(e){return new Nr(e>>16&255,e>>8&255,e&255,1)}function sd(e,r,s,l){return l<=0&&(e=r=s=NaN),new Nr(e,r,s,l)}function v6(e){return e instanceof Bo||(e=al(e)),e?(e=e.rgb(),new Nr(e.r,e.g,e.b,e.opacity)):new Nr}function Sm(e,r,s,l){return arguments.length===1?v6(e):new Nr(e,r,s,l??1)}function Nr(e,r,s,l){this.r=+e,this.g=+r,this.b=+s,this.opacity=+l}fx(Nr,Sm,Qj(Bo,{brighter(e){return e=e==null?Rd:Math.pow(Rd,e),new Nr(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?ko:Math.pow(ko,e),new Nr(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Nr(tl(this.r),tl(this.g),tl(this.b),Ld(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:Ry,formatHex:Ry,formatHex8:j6,formatRgb:Ly,toString:Ly}));function Ry(){return`#${el(this.r)}${el(this.g)}${el(this.b)}`}function j6(){return`#${el(this.r)}${el(this.g)}${el(this.b)}${el((isNaN(this.opacity)?1:this.opacity)*255)}`}function Ly(){const e=Ld(this.opacity);return`${e===1?"rgb(":"rgba("}${tl(this.r)}, ${tl(this.g)}, ${tl(this.b)}${e===1?")":`, ${e})`}`}function Ld(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function tl(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function el(e){return e=tl(e),(e<16?"0":"")+e.toString(16)}function zy(e,r,s,l){return l<=0?e=r=s=NaN:s<=0||s>=1?e=r=NaN:r<=0&&(e=NaN),new ns(e,r,s,l)}function Kj(e){if(e instanceof ns)return new ns(e.h,e.s,e.l,e.opacity);if(e instanceof Bo||(e=al(e)),!e)return new ns;if(e instanceof ns)return e;e=e.rgb();var r=e.r/255,s=e.g/255,l=e.b/255,o=Math.min(r,s,l),d=Math.max(r,s,l),c=NaN,h=d-o,m=(d+o)/2;return h?(r===d?c=(s-l)/h+(s<l)*6:s===d?c=(l-r)/h+2:c=(r-s)/h+4,h/=m<.5?d+o:2-d-o,c*=60):h=m>0&&m<1?0:c,new ns(c,h,m,e.opacity)}function w6(e,r,s,l){return arguments.length===1?Kj(e):new ns(e,r,s,l??1)}function ns(e,r,s,l){this.h=+e,this.s=+r,this.l=+s,this.opacity=+l}fx(ns,w6,Qj(Bo,{brighter(e){return e=e==null?Rd:Math.pow(Rd,e),new ns(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?ko:Math.pow(ko,e),new ns(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,r=isNaN(e)||isNaN(this.s)?0:this.s,s=this.l,l=s+(s<.5?s:1-s)*r,o=2*s-l;return new Nr(Uh(e>=240?e-240:e+120,o,l),Uh(e,o,l),Uh(e<120?e+240:e-120,o,l),this.opacity)},clamp(){return new ns(Iy(this.h),ad(this.s),ad(this.l),Ld(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=Ld(this.opacity);return`${e===1?"hsl(":"hsla("}${Iy(this.h)}, ${ad(this.s)*100}%, ${ad(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Iy(e){return e=(e||0)%360,e<0?e+360:e}function ad(e){return Math.max(0,Math.min(1,e||0))}function Uh(e,r,s){return(e<60?r+(s-r)*e/60:e<180?s:e<240?r+(s-r)*(240-e)/60:r)*255}const hx=e=>()=>e;function N6(e,r){return function(s){return e+s*r}}function k6(e,r,s){return e=Math.pow(e,s),r=Math.pow(r,s)-e,s=1/s,function(l){return Math.pow(e+l*r,s)}}function S6(e){return(e=+e)==1?Jj:function(r,s){return s-r?k6(r,s,e):hx(isNaN(r)?s:r)}}function Jj(e,r){var s=r-e;return s?N6(e,s):hx(isNaN(e)?r:e)}const zd=(function e(r){var s=S6(r);function l(o,d){var c=s((o=Sm(o)).r,(d=Sm(d)).r),h=s(o.g,d.g),m=s(o.b,d.b),f=Jj(o.opacity,d.opacity);return function(x){return o.r=c(x),o.g=h(x),o.b=m(x),o.opacity=f(x),o+""}}return l.gamma=e,l})(1);function C6(e,r){r||(r=[]);var s=e?Math.min(r.length,e.length):0,l=r.slice(),o;return function(d){for(o=0;o<s;++o)l[o]=e[o]*(1-d)+r[o]*d;return l}}function E6(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function T6(e,r){var s=r?r.length:0,l=e?Math.min(s,e.length):0,o=new Array(l),d=new Array(s),c;for(c=0;c<l;++c)o[c]=po(e[c],r[c]);for(;c<s;++c)d[c]=r[c];return function(h){for(c=0;c<l;++c)d[c]=o[c](h);return d}}function A6(e,r){var s=new Date;return e=+e,r=+r,function(l){return s.setTime(e*(1-l)+r*l),s}}function vs(e,r){return e=+e,r=+r,function(s){return e*(1-s)+r*s}}function _6(e,r){var s={},l={},o;(e===null||typeof e!="object")&&(e={}),(r===null||typeof r!="object")&&(r={});for(o in r)o in e?s[o]=po(e[o],r[o]):l[o]=r[o];return function(d){for(o in s)l[o]=s[o](d);return l}}var Cm=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,qh=new RegExp(Cm.source,"g");function M6(e){return function(){return e}}function D6(e){return function(r){return e(r)+""}}function Wj(e,r){var s=Cm.lastIndex=qh.lastIndex=0,l,o,d,c=-1,h=[],m=[];for(e=e+"",r=r+"";(l=Cm.exec(e))&&(o=qh.exec(r));)(d=o.index)>s&&(d=r.slice(s,d),h[c]?h[c]+=d:h[++c]=d),(l=l[0])===(o=o[0])?h[c]?h[c]+=o:h[++c]=o:(h[++c]=null,m.push({i:c,x:vs(l,o)})),s=qh.lastIndex;return s<r.length&&(d=r.slice(s),h[c]?h[c]+=d:h[++c]=d),h.length<2?m[0]?D6(m[0].x):M6(r):(r=m.length,function(f){for(var x=0,g;x<r;++x)h[(g=m[x]).i]=g.x(f);return h.join("")})}function po(e,r){var s=typeof r,l;return r==null||s==="boolean"?hx(r):(s==="number"?vs:s==="string"?(l=al(r))?(r=l,zd):Wj:r instanceof al?zd:r instanceof Date?A6:E6(r)?C6:Array.isArray(r)?T6:typeof r.valueOf!="function"&&typeof r.toString!="function"||isNaN(r)?_6:vs)(e,r)}var $y=180/Math.PI,Em={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ew(e,r,s,l,o,d){var c,h,m;return(c=Math.sqrt(e*e+r*r))&&(e/=c,r/=c),(m=e*s+r*l)&&(s-=e*m,l-=r*m),(h=Math.sqrt(s*s+l*l))&&(s/=h,l/=h,m/=h),e*l<r*s&&(e=-e,r=-r,m=-m,c=-c),{translateX:o,translateY:d,rotate:Math.atan2(r,e)*$y,skewX:Math.atan(m)*$y,scaleX:c,scaleY:h}}var ld;function O6(e){const r=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return r.isIdentity?Em:ew(r.a,r.b,r.c,r.d,r.e,r.f)}function R6(e){return e==null||(ld||(ld=document.createElementNS("http://www.w3.org/2000/svg","g")),ld.setAttribute("transform",e),!(e=ld.transform.baseVal.consolidate()))?Em:(e=e.matrix,ew(e.a,e.b,e.c,e.d,e.e,e.f))}function tw(e,r,s,l){function o(f){return f.length?f.pop()+" ":""}function d(f,x,g,p,y,w){if(f!==g||x!==p){var N=y.push("translate(",null,r,null,s);w.push({i:N-4,x:vs(f,g)},{i:N-2,x:vs(x,p)})}else(g||p)&&y.push("translate("+g+r+p+s)}function c(f,x,g,p){f!==x?(f-x>180?x+=360:x-f>180&&(f+=360),p.push({i:g.push(o(g)+"rotate(",null,l)-2,x:vs(f,x)})):x&&g.push(o(g)+"rotate("+x+l)}function h(f,x,g,p){f!==x?p.push({i:g.push(o(g)+"skewX(",null,l)-2,x:vs(f,x)}):x&&g.push(o(g)+"skewX("+x+l)}function m(f,x,g,p,y,w){if(f!==g||x!==p){var N=y.push(o(y)+"scale(",null,",",null,")");w.push({i:N-4,x:vs(f,g)},{i:N-2,x:vs(x,p)})}else(g!==1||p!==1)&&y.push(o(y)+"scale("+g+","+p+")")}return function(f,x){var g=[],p=[];return f=e(f),x=e(x),d(f.translateX,f.translateY,x.translateX,x.translateY,g,p),c(f.rotate,x.rotate,g,p),h(f.skewX,x.skewX,g,p),m(f.scaleX,f.scaleY,x.scaleX,x.scaleY,g,p),f=x=null,function(y){for(var w=-1,N=p.length,E;++w<N;)g[(E=p[w]).i]=E.x(y);return g.join("")}}}var L6=tw(O6,"px, ","px)","deg)"),z6=tw(R6,", ",")",")"),I6=1e-12;function By(e){return((e=Math.exp(e))+1/e)/2}function $6(e){return((e=Math.exp(e))-1/e)/2}function B6(e){return((e=Math.exp(2*e))-1)/(e+1)}const pd=(function e(r,s,l){function o(d,c){var h=d[0],m=d[1],f=d[2],x=c[0],g=c[1],p=c[2],y=x-h,w=g-m,N=y*y+w*w,E,A;if(N<I6)A=Math.log(p/f)/r,E=function(G){return[h+G*y,m+G*w,f*Math.exp(r*G*A)]};else{var C=Math.sqrt(N),k=(p*p-f*f+l*N)/(2*f*s*C),S=(p*p-f*f-l*N)/(2*p*s*C),O=Math.log(Math.sqrt(k*k+1)-k),R=Math.log(Math.sqrt(S*S+1)-S);A=(R-O)/r,E=function(G){var I=G*A,Q=By(O),$=f/(s*C)*(Q*B6(r*I+O)-$6(O));return[h+$*y,m+$*w,f*Q/By(r*I+O)]}}return E.duration=A*1e3*r/Math.SQRT2,E}return o.rho=function(d){var c=Math.max(.001,+d),h=c*c,m=h*h;return e(c,h,m)},o})(Math.SQRT2,2,4);var ei=0,uo=0,so=0,nw=1e3,Id,fo,$d=0,ll=0,nu=0,Co=typeof performance=="object"&&performance.now?performance:Date,rw=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function mx(){return ll||(rw(H6),ll=Co.now()+nu)}function H6(){ll=0}function Bd(){this._call=this._time=this._next=null}Bd.prototype=sw.prototype={constructor:Bd,restart:function(e,r,s){if(typeof e!="function")throw new TypeError("callback is not a function");s=(s==null?mx():+s)+(r==null?0:+r),!this._next&&fo!==this&&(fo?fo._next=this:Id=this,fo=this),this._call=e,this._time=s,Tm()},stop:function(){this._call&&(this._call=null,this._time=1/0,Tm())}};function sw(e,r,s){var l=new Bd;return l.restart(e,r,s),l}function P6(){mx(),++ei;for(var e=Id,r;e;)(r=ll-e._time)>=0&&e._call.call(void 0,r),e=e._next;--ei}function Hy(){ll=($d=Co.now())+nu,ei=uo=0;try{P6()}finally{ei=0,q6(),ll=0}}function U6(){var e=Co.now(),r=e-$d;r>nw&&(nu-=r,$d=e)}function q6(){for(var e,r=Id,s,l=1/0;r;)r._call?(l>r._time&&(l=r._time),e=r,r=r._next):(s=r._next,r._next=null,r=e?e._next=s:Id=s);fo=e,Tm(l)}function Tm(e){if(!ei){uo&&(uo=clearTimeout(uo));var r=e-ll;r>24?(e<1/0&&(uo=setTimeout(Hy,e-Co.now()-nu)),so&&(so=clearInterval(so))):(so||($d=Co.now(),so=setInterval(U6,nw)),ei=1,rw(Hy))}}function Py(e,r,s){var l=new Bd;return r=r==null?0:+r,l.restart(o=>{l.stop(),e(o+r)},r,s),l}var F6=eu("start","end","cancel","interrupt"),V6=[],aw=0,Uy=1,Am=2,bd=3,qy=4,_m=5,yd=6;function ru(e,r,s,l,o,d){var c=e.__transition;if(!c)e.__transition={};else if(s in c)return;Y6(e,s,{name:r,index:l,group:o,on:F6,tween:V6,time:d.time,delay:d.delay,duration:d.duration,ease:d.ease,timer:null,state:aw})}function xx(e,r){var s=is(e,r);if(s.state>aw)throw new Error("too late; already scheduled");return s}function Ss(e,r){var s=is(e,r);if(s.state>bd)throw new Error("too late; already running");return s}function is(e,r){var s=e.__transition;if(!s||!(s=s[r]))throw new Error("transition not found");return s}function Y6(e,r,s){var l=e.__transition,o;l[r]=s,s.timer=sw(d,0,s.time);function d(f){s.state=Uy,s.timer.restart(c,s.delay,s.time),s.delay<=f&&c(f-s.delay)}function c(f){var x,g,p,y;if(s.state!==Uy)return m();for(x in l)if(y=l[x],y.name===s.name){if(y.state===bd)return Py(c);y.state===qy?(y.state=yd,y.timer.stop(),y.on.call("interrupt",e,e.__data__,y.index,y.group),delete l[x]):+x<r&&(y.state=yd,y.timer.stop(),y.on.call("cancel",e,e.__data__,y.index,y.group),delete l[x])}if(Py(function(){s.state===bd&&(s.state=qy,s.timer.restart(h,s.delay,s.time),h(f))}),s.state=Am,s.on.call("start",e,e.__data__,s.index,s.group),s.state===Am){for(s.state=bd,o=new Array(p=s.tween.length),x=0,g=-1;x<p;++x)(y=s.tween[x].value.call(e,e.__data__,s.index,s.group))&&(o[++g]=y);o.length=g+1}}function h(f){for(var x=f<s.duration?s.ease.call(null,f/s.duration):(s.timer.restart(m),s.state=_m,1),g=-1,p=o.length;++g<p;)o[g].call(e,x);s.state===_m&&(s.on.call("end",e,e.__data__,s.index,s.group),m())}function m(){s.state=yd,s.timer.stop(),delete l[r];for(var f in l)return;delete e.__transition}}function vd(e,r){var s=e.__transition,l,o,d=!0,c;if(s){r=r==null?null:r+"";for(c in s){if((l=s[c]).name!==r){d=!1;continue}o=l.state>Am&&l.state<_m,l.state=yd,l.timer.stop(),l.on.call(o?"interrupt":"cancel",e,e.__data__,l.index,l.group),delete s[c]}d&&delete e.__transition}}function G6(e){return this.each(function(){vd(this,e)})}function X6(e,r){var s,l;return function(){var o=Ss(this,e),d=o.tween;if(d!==s){l=s=d;for(var c=0,h=l.length;c<h;++c)if(l[c].name===r){l=l.slice(),l.splice(c,1);break}}o.tween=l}}function Z6(e,r,s){var l,o;if(typeof s!="function")throw new Error;return function(){var d=Ss(this,e),c=d.tween;if(c!==l){o=(l=c).slice();for(var h={name:r,value:s},m=0,f=o.length;m<f;++m)if(o[m].name===r){o[m]=h;break}m===f&&o.push(h)}d.tween=o}}function Q6(e,r){var s=this._id;if(e+="",arguments.length<2){for(var l=is(this.node(),s).tween,o=0,d=l.length,c;o<d;++o)if((c=l[o]).name===e)return c.value;return null}return this.each((r==null?X6:Z6)(s,e,r))}function gx(e,r,s){var l=e._id;return e.each(function(){var o=Ss(this,l);(o.value||(o.value={}))[r]=s.apply(this,arguments)}),function(o){return is(o,l).value[r]}}function lw(e,r){var s;return(typeof r=="number"?vs:r instanceof al?zd:(s=al(r))?(r=s,zd):Wj)(e,r)}function K6(e){return function(){this.removeAttribute(e)}}function J6(e){return function(){this.removeAttributeNS(e.space,e.local)}}function W6(e,r,s){var l,o=s+"",d;return function(){var c=this.getAttribute(e);return c===o?null:c===l?d:d=r(l=c,s)}}function eM(e,r,s){var l,o=s+"",d;return function(){var c=this.getAttributeNS(e.space,e.local);return c===o?null:c===l?d:d=r(l=c,s)}}function tM(e,r,s){var l,o,d;return function(){var c,h=s(this),m;return h==null?void this.removeAttribute(e):(c=this.getAttribute(e),m=h+"",c===m?null:c===l&&m===o?d:(o=m,d=r(l=c,h)))}}function nM(e,r,s){var l,o,d;return function(){var c,h=s(this),m;return h==null?void this.removeAttributeNS(e.space,e.local):(c=this.getAttributeNS(e.space,e.local),m=h+"",c===m?null:c===l&&m===o?d:(o=m,d=r(l=c,h)))}}function rM(e,r){var s=tu(e),l=s==="transform"?z6:lw;return this.attrTween(e,typeof r=="function"?(s.local?nM:tM)(s,l,gx(this,"attr."+e,r)):r==null?(s.local?J6:K6)(s):(s.local?eM:W6)(s,l,r))}function sM(e,r){return function(s){this.setAttribute(e,r.call(this,s))}}function aM(e,r){return function(s){this.setAttributeNS(e.space,e.local,r.call(this,s))}}function lM(e,r){var s,l;function o(){var d=r.apply(this,arguments);return d!==l&&(s=(l=d)&&aM(e,d)),s}return o._value=r,o}function iM(e,r){var s,l;function o(){var d=r.apply(this,arguments);return d!==l&&(s=(l=d)&&sM(e,d)),s}return o._value=r,o}function oM(e,r){var s="attr."+e;if(arguments.length<2)return(s=this.tween(s))&&s._value;if(r==null)return this.tween(s,null);if(typeof r!="function")throw new Error;var l=tu(e);return this.tween(s,(l.local?lM:iM)(l,r))}function cM(e,r){return function(){xx(this,e).delay=+r.apply(this,arguments)}}function dM(e,r){return r=+r,function(){xx(this,e).delay=r}}function uM(e){var r=this._id;return arguments.length?this.each((typeof e=="function"?cM:dM)(r,e)):is(this.node(),r).delay}function fM(e,r){return function(){Ss(this,e).duration=+r.apply(this,arguments)}}function hM(e,r){return r=+r,function(){Ss(this,e).duration=r}}function mM(e){var r=this._id;return arguments.length?this.each((typeof e=="function"?fM:hM)(r,e)):is(this.node(),r).duration}function xM(e,r){if(typeof r!="function")throw new Error;return function(){Ss(this,e).ease=r}}function gM(e){var r=this._id;return arguments.length?this.each(xM(r,e)):is(this.node(),r).ease}function pM(e,r){return function(){var s=r.apply(this,arguments);if(typeof s!="function")throw new Error;Ss(this,e).ease=s}}function bM(e){if(typeof e!="function")throw new Error;return this.each(pM(this._id,e))}function yM(e){typeof e!="function"&&(e=Ij(e));for(var r=this._groups,s=r.length,l=new Array(s),o=0;o<s;++o)for(var d=r[o],c=d.length,h=l[o]=[],m,f=0;f<c;++f)(m=d[f])&&e.call(m,m.__data__,f,d)&&h.push(m);return new Zs(l,this._parents,this._name,this._id)}function vM(e){if(e._id!==this._id)throw new Error;for(var r=this._groups,s=e._groups,l=r.length,o=s.length,d=Math.min(l,o),c=new Array(l),h=0;h<d;++h)for(var m=r[h],f=s[h],x=m.length,g=c[h]=new Array(x),p,y=0;y<x;++y)(p=m[y]||f[y])&&(g[y]=p);for(;h<l;++h)c[h]=r[h];return new Zs(c,this._parents,this._name,this._id)}function jM(e){return(e+"").trim().split(/^|\s+/).every(function(r){var s=r.indexOf(".");return s>=0&&(r=r.slice(0,s)),!r||r==="start"})}function wM(e,r,s){var l,o,d=jM(r)?xx:Ss;return function(){var c=d(this,e),h=c.on;h!==l&&(o=(l=h).copy()).on(r,s),c.on=o}}function NM(e,r){var s=this._id;return arguments.length<2?is(this.node(),s).on.on(e):this.each(wM(s,e,r))}function kM(e){return function(){var r=this.parentNode;for(var s in this.__transition)if(+s!==e)return;r&&r.removeChild(this)}}function SM(){return this.on("end.remove",kM(this._id))}function CM(e){var r=this._name,s=this._id;typeof e!="function"&&(e=dx(e));for(var l=this._groups,o=l.length,d=new Array(o),c=0;c<o;++c)for(var h=l[c],m=h.length,f=d[c]=new Array(m),x,g,p=0;p<m;++p)(x=h[p])&&(g=e.call(x,x.__data__,p,h))&&("__data__"in x&&(g.__data__=x.__data__),f[p]=g,ru(f[p],r,s,p,f,is(x,s)));return new Zs(d,this._parents,r,s)}function EM(e){var r=this._name,s=this._id;typeof e!="function"&&(e=zj(e));for(var l=this._groups,o=l.length,d=[],c=[],h=0;h<o;++h)for(var m=l[h],f=m.length,x,g=0;g<f;++g)if(x=m[g]){for(var p=e.call(x,x.__data__,g,m),y,w=is(x,s),N=0,E=p.length;N<E;++N)(y=p[N])&&ru(y,r,s,N,p,w);d.push(p),c.push(x)}return new Zs(d,c,r,s)}var TM=$o.prototype.constructor;function AM(){return new TM(this._groups,this._parents)}function _M(e,r){var s,l,o;return function(){var d=Wl(this,e),c=(this.style.removeProperty(e),Wl(this,e));return d===c?null:d===s&&c===l?o:o=r(s=d,l=c)}}function iw(e){return function(){this.style.removeProperty(e)}}function MM(e,r,s){var l,o=s+"",d;return function(){var c=Wl(this,e);return c===o?null:c===l?d:d=r(l=c,s)}}function DM(e,r,s){var l,o,d;return function(){var c=Wl(this,e),h=s(this),m=h+"";return h==null&&(m=h=(this.style.removeProperty(e),Wl(this,e))),c===m?null:c===l&&m===o?d:(o=m,d=r(l=c,h))}}function OM(e,r){var s,l,o,d="style."+r,c="end."+d,h;return function(){var m=Ss(this,e),f=m.on,x=m.value[d]==null?h||(h=iw(r)):void 0;(f!==s||o!==x)&&(l=(s=f).copy()).on(c,o=x),m.on=l}}function RM(e,r,s){var l=(e+="")=="transform"?L6:lw;return r==null?this.styleTween(e,_M(e,l)).on("end.style."+e,iw(e)):typeof r=="function"?this.styleTween(e,DM(e,l,gx(this,"style."+e,r))).each(OM(this._id,e)):this.styleTween(e,MM(e,l,r),s).on("end.style."+e,null)}function LM(e,r,s){return function(l){this.style.setProperty(e,r.call(this,l),s)}}function zM(e,r,s){var l,o;function d(){var c=r.apply(this,arguments);return c!==o&&(l=(o=c)&&LM(e,c,s)),l}return d._value=r,d}function IM(e,r,s){var l="style."+(e+="");if(arguments.length<2)return(l=this.tween(l))&&l._value;if(r==null)return this.tween(l,null);if(typeof r!="function")throw new Error;return this.tween(l,zM(e,r,s??""))}function $M(e){return function(){this.textContent=e}}function BM(e){return function(){var r=e(this);this.textContent=r??""}}function HM(e){return this.tween("text",typeof e=="function"?BM(gx(this,"text",e)):$M(e==null?"":e+""))}function PM(e){return function(r){this.textContent=e.call(this,r)}}function UM(e){var r,s;function l(){var o=e.apply(this,arguments);return o!==s&&(r=(s=o)&&PM(o)),r}return l._value=e,l}function qM(e){var r="text";if(arguments.length<1)return(r=this.tween(r))&&r._value;if(e==null)return this.tween(r,null);if(typeof e!="function")throw new Error;return this.tween(r,UM(e))}function FM(){for(var e=this._name,r=this._id,s=ow(),l=this._groups,o=l.length,d=0;d<o;++d)for(var c=l[d],h=c.length,m,f=0;f<h;++f)if(m=c[f]){var x=is(m,r);ru(m,e,s,f,c,{time:x.time+x.delay+x.duration,delay:0,duration:x.duration,ease:x.ease})}return new Zs(l,this._parents,e,s)}function VM(){var e,r,s=this,l=s._id,o=s.size();return new Promise(function(d,c){var h={value:c},m={value:function(){--o===0&&d()}};s.each(function(){var f=Ss(this,l),x=f.on;x!==e&&(r=(e=x).copy(),r._.cancel.push(h),r._.interrupt.push(h),r._.end.push(m)),f.on=r}),o===0&&d()})}var YM=0;function Zs(e,r,s,l){this._groups=e,this._parents=r,this._name=s,this._id=l}function ow(){return++YM}var Fs=$o.prototype;Zs.prototype={constructor:Zs,select:CM,selectAll:EM,selectChild:Fs.selectChild,selectChildren:Fs.selectChildren,filter:yM,merge:vM,selection:AM,transition:FM,call:Fs.call,nodes:Fs.nodes,node:Fs.node,size:Fs.size,empty:Fs.empty,each:Fs.each,on:NM,attr:rM,attrTween:oM,style:RM,styleTween:IM,text:HM,textTween:qM,remove:SM,tween:Q6,delay:uM,duration:mM,ease:gM,easeVarying:bM,end:VM,[Symbol.iterator]:Fs[Symbol.iterator]};function GM(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var XM={time:null,delay:0,duration:250,ease:GM};function ZM(e,r){for(var s;!(s=e.__transition)||!(s=s[r]);)if(!(e=e.parentNode))throw new Error(`transition ${r} not found`);return s}function QM(e){var r,s;e instanceof Zs?(r=e._id,e=e._name):(r=ow(),(s=XM).time=mx(),e=e==null?null:e+"");for(var l=this._groups,o=l.length,d=0;d<o;++d)for(var c=l[d],h=c.length,m,f=0;f<h;++f)(m=c[f])&&ru(m,e,r,f,c,s||ZM(m,r));return new Zs(l,this._parents,e,r)}$o.prototype.interrupt=G6;$o.prototype.transition=QM;const id=e=>()=>e;function KM(e,{sourceEvent:r,target:s,transform:l,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},transform:{value:l,enumerable:!0,configurable:!0},_:{value:o}})}function Xs(e,r,s){this.k=e,this.x=r,this.y=s}Xs.prototype={constructor:Xs,scale:function(e){return e===1?this:new Xs(this.k*e,this.x,this.y)},translate:function(e,r){return e===0&r===0?this:new Xs(this.k,this.x+this.k*e,this.y+this.k*r)},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 su=new Xs(1,0,0);cw.prototype=Xs.prototype;function cw(e){for(;!e.__zoom;)if(!(e=e.parentNode))return su;return e.__zoom}function Fh(e){e.stopImmediatePropagation()}function ao(e){e.preventDefault(),e.stopImmediatePropagation()}function JM(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function WM(){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 Fy(){return this.__zoom||su}function eD(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function tD(){return navigator.maxTouchPoints||"ontouchstart"in this}function nD(e,r,s){var l=e.invertX(r[0][0])-s[0][0],o=e.invertX(r[1][0])-s[1][0],d=e.invertY(r[0][1])-s[0][1],c=e.invertY(r[1][1])-s[1][1];return e.translate(o>l?(l+o)/2:Math.min(0,l)||Math.max(0,o),c>d?(d+c)/2:Math.min(0,d)||Math.max(0,c))}function dw(){var e=JM,r=WM,s=nD,l=eD,o=tD,d=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],h=250,m=pd,f=eu("start","zoom","end"),x,g,p,y=500,w=150,N=0,E=10;function A(D){D.property("__zoom",Fy).on("wheel.zoom",I,{passive:!1}).on("mousedown.zoom",Q).on("dblclick.zoom",$).filter(o).on("touchstart.zoom",F).on("touchmove.zoom",B).on("touchend.zoom touchcancel.zoom",T).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}A.transform=function(D,z,_,Y){var V=D.selection?D.selection():D;V.property("__zoom",Fy),D!==V?O(D,z,_,Y):V.interrupt().each(function(){R(this,arguments).event(Y).start().zoom(null,typeof z=="function"?z.apply(this,arguments):z).end()})},A.scaleBy=function(D,z,_,Y){A.scaleTo(D,function(){var V=this.__zoom.k,J=typeof z=="function"?z.apply(this,arguments):z;return V*J},_,Y)},A.scaleTo=function(D,z,_,Y){A.transform(D,function(){var V=r.apply(this,arguments),J=this.__zoom,U=_==null?S(V):typeof _=="function"?_.apply(this,arguments):_,H=J.invert(U),X=typeof z=="function"?z.apply(this,arguments):z;return s(k(C(J,X),U,H),V,c)},_,Y)},A.translateBy=function(D,z,_,Y){A.transform(D,function(){return s(this.__zoom.translate(typeof z=="function"?z.apply(this,arguments):z,typeof _=="function"?_.apply(this,arguments):_),r.apply(this,arguments),c)},null,Y)},A.translateTo=function(D,z,_,Y,V){A.transform(D,function(){var J=r.apply(this,arguments),U=this.__zoom,H=Y==null?S(J):typeof Y=="function"?Y.apply(this,arguments):Y;return s(su.translate(H[0],H[1]).scale(U.k).translate(typeof z=="function"?-z.apply(this,arguments):-z,typeof _=="function"?-_.apply(this,arguments):-_),J,c)},Y,V)};function C(D,z){return z=Math.max(d[0],Math.min(d[1],z)),z===D.k?D:new Xs(z,D.x,D.y)}function k(D,z,_){var Y=z[0]-_[0]*D.k,V=z[1]-_[1]*D.k;return Y===D.x&&V===D.y?D:new Xs(D.k,Y,V)}function S(D){return[(+D[0][0]+ +D[1][0])/2,(+D[0][1]+ +D[1][1])/2]}function O(D,z,_,Y){D.on("start.zoom",function(){R(this,arguments).event(Y).start()}).on("interrupt.zoom end.zoom",function(){R(this,arguments).event(Y).end()}).tween("zoom",function(){var V=this,J=arguments,U=R(V,J).event(Y),H=r.apply(V,J),X=_==null?S(H):typeof _=="function"?_.apply(V,J):_,L=Math.max(H[1][0]-H[0][0],H[1][1]-H[0][1]),M=V.__zoom,q=typeof z=="function"?z.apply(V,J):z,K=m(M.invert(X).concat(L/M.k),q.invert(X).concat(L/q.k));return function(ee){if(ee===1)ee=q;else{var te=K(ee),se=L/te[2];ee=new Xs(se,X[0]-te[0]*se,X[1]-te[1]*se)}U.zoom(null,ee)}})}function R(D,z,_){return!_&&D.__zooming||new G(D,z)}function G(D,z){this.that=D,this.args=z,this.active=0,this.sourceEvent=null,this.extent=r.apply(D,z),this.taps=0}G.prototype={event:function(D){return D&&(this.sourceEvent=D),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(D,z){return this.mouse&&D!=="mouse"&&(this.mouse[1]=z.invert(this.mouse[0])),this.touch0&&D!=="touch"&&(this.touch0[1]=z.invert(this.touch0[0])),this.touch1&&D!=="touch"&&(this.touch1[1]=z.invert(this.touch1[0])),this.that.__zoom=z,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(D){var z=Ir(this.that).datum();f.call(D,this.that,new KM(D,{sourceEvent:this.sourceEvent,target:A,transform:this.that.__zoom,dispatch:f}),z)}};function I(D,...z){if(!e.apply(this,arguments))return;var _=R(this,z).event(D),Y=this.__zoom,V=Math.max(d[0],Math.min(d[1],Y.k*Math.pow(2,l.apply(this,arguments)))),J=ts(D);if(_.wheel)(_.mouse[0][0]!==J[0]||_.mouse[0][1]!==J[1])&&(_.mouse[1]=Y.invert(_.mouse[0]=J)),clearTimeout(_.wheel);else{if(Y.k===V)return;_.mouse=[J,Y.invert(J)],vd(this),_.start()}ao(D),_.wheel=setTimeout(U,w),_.zoom("mouse",s(k(C(Y,V),_.mouse[0],_.mouse[1]),_.extent,c));function U(){_.wheel=null,_.end()}}function Q(D,...z){if(p||!e.apply(this,arguments))return;var _=D.currentTarget,Y=R(this,z,!0).event(D),V=Ir(D.view).on("mousemove.zoom",X,!0).on("mouseup.zoom",L,!0),J=ts(D,_),U=D.clientX,H=D.clientY;Gj(D.view),Fh(D),Y.mouse=[J,this.__zoom.invert(J)],vd(this),Y.start();function X(M){if(ao(M),!Y.moved){var q=M.clientX-U,K=M.clientY-H;Y.moved=q*q+K*K>N}Y.event(M).zoom("mouse",s(k(Y.that.__zoom,Y.mouse[0]=ts(M,_),Y.mouse[1]),Y.extent,c))}function L(M){V.on("mousemove.zoom mouseup.zoom",null),Xj(M.view,Y.moved),ao(M),Y.event(M).end()}}function $(D,...z){if(e.apply(this,arguments)){var _=this.__zoom,Y=ts(D.changedTouches?D.changedTouches[0]:D,this),V=_.invert(Y),J=_.k*(D.shiftKey?.5:2),U=s(k(C(_,J),Y,V),r.apply(this,z),c);ao(D),h>0?Ir(this).transition().duration(h).call(O,U,Y,D):Ir(this).call(A.transform,U,Y,D)}}function F(D,...z){if(e.apply(this,arguments)){var _=D.touches,Y=_.length,V=R(this,z,D.changedTouches.length===Y).event(D),J,U,H,X;for(Fh(D),U=0;U<Y;++U)H=_[U],X=ts(H,this),X=[X,this.__zoom.invert(X),H.identifier],V.touch0?!V.touch1&&V.touch0[2]!==X[2]&&(V.touch1=X,V.taps=0):(V.touch0=X,J=!0,V.taps=1+!!x);x&&(x=clearTimeout(x)),J&&(V.taps<2&&(g=X[0],x=setTimeout(function(){x=null},y)),vd(this),V.start())}}function B(D,...z){if(this.__zooming){var _=R(this,z).event(D),Y=D.changedTouches,V=Y.length,J,U,H,X;for(ao(D),J=0;J<V;++J)U=Y[J],H=ts(U,this),_.touch0&&_.touch0[2]===U.identifier?_.touch0[0]=H:_.touch1&&_.touch1[2]===U.identifier&&(_.touch1[0]=H);if(U=_.that.__zoom,_.touch1){var L=_.touch0[0],M=_.touch0[1],q=_.touch1[0],K=_.touch1[1],ee=(ee=q[0]-L[0])*ee+(ee=q[1]-L[1])*ee,te=(te=K[0]-M[0])*te+(te=K[1]-M[1])*te;U=C(U,Math.sqrt(ee/te)),H=[(L[0]+q[0])/2,(L[1]+q[1])/2],X=[(M[0]+K[0])/2,(M[1]+K[1])/2]}else if(_.touch0)H=_.touch0[0],X=_.touch0[1];else return;_.zoom("touch",s(k(U,H,X),_.extent,c))}}function T(D,...z){if(this.__zooming){var _=R(this,z).event(D),Y=D.changedTouches,V=Y.length,J,U;for(Fh(D),p&&clearTimeout(p),p=setTimeout(function(){p=null},y),J=0;J<V;++J)U=Y[J],_.touch0&&_.touch0[2]===U.identifier?delete _.touch0:_.touch1&&_.touch1[2]===U.identifier&&delete _.touch1;if(_.touch1&&!_.touch0&&(_.touch0=_.touch1,delete _.touch1),_.touch0)_.touch0[1]=this.__zoom.invert(_.touch0[0]);else if(_.end(),_.taps===2&&(U=ts(U,this),Math.hypot(g[0]-U[0],g[1]-U[1])<E)){var H=Ir(this).on("dblclick.zoom");H&&H.apply(this,arguments)}}}return A.wheelDelta=function(D){return arguments.length?(l=typeof D=="function"?D:id(+D),A):l},A.filter=function(D){return arguments.length?(e=typeof D=="function"?D:id(!!D),A):e},A.touchable=function(D){return arguments.length?(o=typeof D=="function"?D:id(!!D),A):o},A.extent=function(D){return arguments.length?(r=typeof D=="function"?D:id([[+D[0][0],+D[0][1]],[+D[1][0],+D[1][1]]]),A):r},A.scaleExtent=function(D){return arguments.length?(d[0]=+D[0],d[1]=+D[1],A):[d[0],d[1]]},A.translateExtent=function(D){return arguments.length?(c[0][0]=+D[0][0],c[1][0]=+D[1][0],c[0][1]=+D[0][1],c[1][1]=+D[1][1],A):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},A.constrain=function(D){return arguments.length?(s=D,A):s},A.duration=function(D){return arguments.length?(h=+D,A):h},A.interpolate=function(D){return arguments.length?(m=D,A):m},A.on=function(){var D=f.on.apply(f,arguments);return D===f?A:D},A.clickDistance=function(D){return arguments.length?(N=(D=+D)*D,A):Math.sqrt(N)},A.tapDistance=function(D){return arguments.length?(E=+D,A):E},A}const ws={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:r,sourceHandle:s,targetHandle:l})=>`Couldn't create edge for ${e} handle id: "${e==="source"?s:l}", edge id: ${r}.`,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."},Eo=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],uw=["Enter"," ","Escape"],fw={"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:r,y:s})=>`Moved selected node ${e}. New position, x: ${r}, y: ${s}`,"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 ti;(function(e){e.Strict="strict",e.Loose="loose"})(ti||(ti={}));var nl;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(nl||(nl={}));var To;(function(e){e.Partial="partial",e.Full="full"})(To||(To={}));const hw={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Aa;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Aa||(Aa={}));var ni;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(ni||(ni={}));var lt;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(lt||(lt={}));const Vy={[lt.Left]:lt.Right,[lt.Right]:lt.Left,[lt.Top]:lt.Bottom,[lt.Bottom]:lt.Top};function mw(e){return e===null?null:e?"valid":"invalid"}const xw=e=>"id"in e&&"source"in e&&"target"in e,rD=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),px=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Ho=(e,r=[0,0])=>{const{width:s,height:l}=Ks(e),o=e.origin??r,d=s*o[0],c=l*o[1];return{x:e.position.x-d,y:e.position.y-c}},sD=(e,r={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const s=e.reduce((l,o)=>{const d=typeof o=="string";let c=!r.nodeLookup&&!d?o:void 0;r.nodeLookup&&(c=d?r.nodeLookup.get(o):px(o)?o:r.nodeLookup.get(o.id));const h=c?Hd(c,r.nodeOrigin):{x:0,y:0,x2:0,y2:0};return au(l,h)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return lu(s)},Po=(e,r={})=>{let s={x:1/0,y:1/0,x2:-1/0,y2:-1/0},l=!1;return e.forEach(o=>{(r.filter===void 0||r.filter(o))&&(s=au(s,Hd(o)),l=!0)}),l?lu(s):{x:0,y:0,width:0,height:0}},bx=(e,r,[s,l,o]=[0,0,1],d=!1,c=!1)=>{const h={...qo(r,[s,l,o]),width:r.width/o,height:r.height/o},m=[];for(const f of e.values()){const{measured:x,selectable:g=!0,hidden:p=!1}=f;if(c&&!g||p)continue;const y=x.width??f.width??f.initialWidth??null,w=x.height??f.height??f.initialHeight??null,N=Ao(h,si(f)),E=(y??0)*(w??0),A=d&&N>0;(!f.internals.handleBounds||A||N>=E||f.dragging)&&m.push(f)}return m},aD=(e,r)=>{const s=new Set;return e.forEach(l=>{s.add(l.id)}),r.filter(l=>s.has(l.source)||s.has(l.target))};function lD(e,r){const s=new Map,l=r?.nodes?new Set(r.nodes.map(o=>o.id)):null;return e.forEach(o=>{o.measured.width&&o.measured.height&&(r?.includeHiddenNodes||!o.hidden)&&(!l||l.has(o.id))&&s.set(o.id,o)}),s}async function iD({nodes:e,width:r,height:s,panZoom:l,minZoom:o,maxZoom:d},c){if(e.size===0)return Promise.resolve(!0);const h=lD(e,c),m=Po(h),f=yx(m,r,s,c?.minZoom??o,c?.maxZoom??d,c?.padding??.1);return await l.setViewport(f,{duration:c?.duration,ease:c?.ease,interpolate:c?.interpolate}),Promise.resolve(!0)}function gw({nodeId:e,nextPosition:r,nodeLookup:s,nodeOrigin:l=[0,0],nodeExtent:o,onError:d}){const c=s.get(e),h=c.parentId?s.get(c.parentId):void 0,{x:m,y:f}=h?h.internals.positionAbsolute:{x:0,y:0},x=c.origin??l;let g=c.extent||o;if(c.extent==="parent"&&!c.expandParent)if(!h)d?.("005",ws.error005());else{const y=h.measured.width,w=h.measured.height;y&&w&&(g=[[m,f],[m+y,f+w]])}else h&&ai(c.extent)&&(g=[[c.extent[0][0]+m,c.extent[0][1]+f],[c.extent[1][0]+m,c.extent[1][1]+f]]);const p=ai(g)?il(r,g,c.measured):r;return(c.measured.width===void 0||c.measured.height===void 0)&&d?.("015",ws.error015()),{position:{x:p.x-m+(c.measured.width??0)*x[0],y:p.y-f+(c.measured.height??0)*x[1]},positionAbsolute:p}}async function oD({nodesToRemove:e=[],edgesToRemove:r=[],nodes:s,edges:l,onBeforeDelete:o}){const d=new Set(e.map(p=>p.id)),c=[];for(const p of s){if(p.deletable===!1)continue;const y=d.has(p.id),w=!y&&p.parentId&&c.find(N=>N.id===p.parentId);(y||w)&&c.push(p)}const h=new Set(r.map(p=>p.id)),m=l.filter(p=>p.deletable!==!1),x=aD(c,m);for(const p of m)h.has(p.id)&&!x.find(w=>w.id===p.id)&&x.push(p);if(!o)return{edges:x,nodes:c};const g=await o({nodes:c,edges:x});return typeof g=="boolean"?g?{edges:x,nodes:c}:{edges:[],nodes:[]}:g}const ri=(e,r=0,s=1)=>Math.min(Math.max(e,r),s),il=(e={x:0,y:0},r,s)=>({x:ri(e.x,r[0][0],r[1][0]-(s?.width??0)),y:ri(e.y,r[0][1],r[1][1]-(s?.height??0))});function pw(e,r,s){const{width:l,height:o}=Ks(s),{x:d,y:c}=s.internals.positionAbsolute;return il(e,[[d,c],[d+l,c+o]],r)}const Yy=(e,r,s)=>e<r?ri(Math.abs(e-r),1,r)/r:e>s?-ri(Math.abs(e-s),1,r)/r:0,bw=(e,r,s=15,l=40)=>{const o=Yy(e.x,l,r.width-l)*s,d=Yy(e.y,l,r.height-l)*s;return[o,d]},au=(e,r)=>({x:Math.min(e.x,r.x),y:Math.min(e.y,r.y),x2:Math.max(e.x2,r.x2),y2:Math.max(e.y2,r.y2)}),Mm=({x:e,y:r,width:s,height:l})=>({x:e,y:r,x2:e+s,y2:r+l}),lu=({x:e,y:r,x2:s,y2:l})=>({x:e,y:r,width:s-e,height:l-r}),si=(e,r=[0,0])=>{const{x:s,y:l}=px(e)?e.internals.positionAbsolute:Ho(e,r);return{x:s,y:l,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},Hd=(e,r=[0,0])=>{const{x:s,y:l}=px(e)?e.internals.positionAbsolute:Ho(e,r);return{x:s,y:l,x2:s+(e.measured?.width??e.width??e.initialWidth??0),y2:l+(e.measured?.height??e.height??e.initialHeight??0)}},yw=(e,r)=>lu(au(Mm(e),Mm(r))),Ao=(e,r)=>{const s=Math.max(0,Math.min(e.x+e.width,r.x+r.width)-Math.max(e.x,r.x)),l=Math.max(0,Math.min(e.y+e.height,r.y+r.height)-Math.max(e.y,r.y));return Math.ceil(s*l)},Gy=e=>rs(e.width)&&rs(e.height)&&rs(e.x)&&rs(e.y),rs=e=>!isNaN(e)&&isFinite(e),cD=(e,r)=>{},Uo=(e,r=[1,1])=>({x:r[0]*Math.round(e.x/r[0]),y:r[1]*Math.round(e.y/r[1])}),qo=({x:e,y:r},[s,l,o],d=!1,c=[1,1])=>{const h={x:(e-s)/o,y:(r-l)/o};return d?Uo(h,c):h},Pd=({x:e,y:r},[s,l,o])=>({x:e*o+s,y:r*o+l});function Pl(e,r){if(typeof e=="number")return Math.floor((r-r/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const s=parseFloat(e);if(!Number.isNaN(s))return Math.floor(s)}if(typeof e=="string"&&e.endsWith("%")){const s=parseFloat(e);if(!Number.isNaN(s))return Math.floor(r*s*.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 dD(e,r,s){if(typeof e=="string"||typeof e=="number"){const l=Pl(e,s),o=Pl(e,r);return{top:l,right:o,bottom:l,left:o,x:o*2,y:l*2}}if(typeof e=="object"){const l=Pl(e.top??e.y??0,s),o=Pl(e.bottom??e.y??0,s),d=Pl(e.left??e.x??0,r),c=Pl(e.right??e.x??0,r);return{top:l,right:c,bottom:o,left:d,x:d+c,y:l+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function uD(e,r,s,l,o,d){const{x:c,y:h}=Pd(e,[r,s,l]),{x:m,y:f}=Pd({x:e.x+e.width,y:e.y+e.height},[r,s,l]),x=o-m,g=d-f;return{left:Math.floor(c),top:Math.floor(h),right:Math.floor(x),bottom:Math.floor(g)}}const yx=(e,r,s,l,o,d)=>{const c=dD(d,r,s),h=(r-c.x)/e.width,m=(s-c.y)/e.height,f=Math.min(h,m),x=ri(f,l,o),g=e.x+e.width/2,p=e.y+e.height/2,y=r/2-g*x,w=s/2-p*x,N=uD(e,y,w,x,r,s),E={left:Math.min(N.left-c.left,0),top:Math.min(N.top-c.top,0),right:Math.min(N.right-c.right,0),bottom:Math.min(N.bottom-c.bottom,0)};return{x:y-E.left+E.right,y:w-E.top+E.bottom,zoom:x}},_o=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function ai(e){return e!=null&&e!=="parent"}function Ks(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function vw(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function jw(e,r={width:0,height:0},s,l,o){const d={...e},c=l.get(s);if(c){const h=c.origin||o;d.x+=c.internals.positionAbsolute.x-(r.width??0)*h[0],d.y+=c.internals.positionAbsolute.y-(r.height??0)*h[1]}return d}function Xy(e,r){if(e.size!==r.size)return!1;for(const s of e)if(!r.has(s))return!1;return!0}function fD(){let e,r;return{promise:new Promise((l,o)=>{e=l,r=o}),resolve:e,reject:r}}function hD(e){return{...fw,...e||{}}}function bo(e,{snapGrid:r=[0,0],snapToGrid:s=!1,transform:l,containerBounds:o}){const{x:d,y:c}=ss(e),h=qo({x:d-(o?.left??0),y:c-(o?.top??0)},l),{x:m,y:f}=s?Uo(h,r):h;return{xSnapped:m,ySnapped:f,...h}}const vx=e=>({width:e.offsetWidth,height:e.offsetHeight}),ww=e=>e?.getRootNode?.()||window?.document,mD=["INPUT","SELECT","TEXTAREA"];function Nw(e){const r=e.composedPath?.()?.[0]||e.target;return r?.nodeType!==1?!1:mD.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const kw=e=>"clientX"in e,ss=(e,r)=>{const s=kw(e),l=s?e.clientX:e.touches?.[0].clientX,o=s?e.clientY:e.touches?.[0].clientY;return{x:l-(r?.left??0),y:o-(r?.top??0)}},Zy=(e,r,s,l,o)=>{const d=r.querySelectorAll(`.${e}`);return!d||!d.length?null:Array.from(d).map(c=>{const h=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:e,nodeId:o,position:c.getAttribute("data-handlepos"),x:(h.left-s.left)/l,y:(h.top-s.top)/l,...vx(c)}})};function Sw({sourceX:e,sourceY:r,targetX:s,targetY:l,sourceControlX:o,sourceControlY:d,targetControlX:c,targetControlY:h}){const m=e*.125+o*.375+c*.375+s*.125,f=r*.125+d*.375+h*.375+l*.125,x=Math.abs(m-e),g=Math.abs(f-r);return[m,f,x,g]}function od(e,r){return e>=0?.5*e:r*25*Math.sqrt(-e)}function Qy({pos:e,x1:r,y1:s,x2:l,y2:o,c:d}){switch(e){case lt.Left:return[r-od(r-l,d),s];case lt.Right:return[r+od(l-r,d),s];case lt.Top:return[r,s-od(s-o,d)];case lt.Bottom:return[r,s+od(o-s,d)]}}function Cw({sourceX:e,sourceY:r,sourcePosition:s=lt.Bottom,targetX:l,targetY:o,targetPosition:d=lt.Top,curvature:c=.25}){const[h,m]=Qy({pos:s,x1:e,y1:r,x2:l,y2:o,c}),[f,x]=Qy({pos:d,x1:l,y1:o,x2:e,y2:r,c}),[g,p,y,w]=Sw({sourceX:e,sourceY:r,targetX:l,targetY:o,sourceControlX:h,sourceControlY:m,targetControlX:f,targetControlY:x});return[`M${e},${r} C${h},${m} ${f},${x} ${l},${o}`,g,p,y,w]}function Ew({sourceX:e,sourceY:r,targetX:s,targetY:l}){const o=Math.abs(s-e)/2,d=s<e?s+o:s-o,c=Math.abs(l-r)/2,h=l<r?l+c:l-c;return[d,h,o,c]}function xD({sourceNode:e,targetNode:r,selected:s=!1,zIndex:l=0,elevateOnSelect:o=!1,zIndexMode:d="basic"}){if(d==="manual")return l;const c=o&&s?l+1e3:l,h=Math.max(e.parentId||o&&e.selected?e.internals.z:0,r.parentId||o&&r.selected?r.internals.z:0);return c+h}function gD({sourceNode:e,targetNode:r,width:s,height:l,transform:o}){const d=au(Hd(e),Hd(r));d.x===d.x2&&(d.x2+=1),d.y===d.y2&&(d.y2+=1);const c={x:-o[0]/o[2],y:-o[1]/o[2],width:s/o[2],height:l/o[2]};return Ao(c,lu(d))>0}const pD=({source:e,sourceHandle:r,target:s,targetHandle:l})=>`xy-edge__${e}${r||""}-${s}${l||""}`,bD=(e,r)=>r.some(s=>s.source===e.source&&s.target===e.target&&(s.sourceHandle===e.sourceHandle||!s.sourceHandle&&!e.sourceHandle)&&(s.targetHandle===e.targetHandle||!s.targetHandle&&!e.targetHandle)),yD=(e,r,s={})=>{if(!e.source||!e.target)return r;const l=s.getEdgeId||pD;let o;return xw(e)?o={...e}:o={...e,id:l(e)},bD(o,r)?r:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,r.concat(o))};function Tw({sourceX:e,sourceY:r,targetX:s,targetY:l}){const[o,d,c,h]=Ew({sourceX:e,sourceY:r,targetX:s,targetY:l});return[`M ${e},${r}L ${s},${l}`,o,d,c,h]}const Ky={[lt.Left]:{x:-1,y:0},[lt.Right]:{x:1,y:0},[lt.Top]:{x:0,y:-1},[lt.Bottom]:{x:0,y:1}},vD=({source:e,sourcePosition:r=lt.Bottom,target:s})=>r===lt.Left||r===lt.Right?e.x<s.x?{x:1,y:0}:{x:-1,y:0}:e.y<s.y?{x:0,y:1}:{x:0,y:-1},Jy=(e,r)=>Math.sqrt(Math.pow(r.x-e.x,2)+Math.pow(r.y-e.y,2));function jD({source:e,sourcePosition:r=lt.Bottom,target:s,targetPosition:l=lt.Top,center:o,offset:d,stepPosition:c}){const h=Ky[r],m=Ky[l],f={x:e.x+h.x*d,y:e.y+h.y*d},x={x:s.x+m.x*d,y:s.y+m.y*d},g=vD({source:f,sourcePosition:r,target:x}),p=g.x!==0?"x":"y",y=g[p];let w=[],N,E;const A={x:0,y:0},C={x:0,y:0},[,,k,S]=Ew({sourceX:e.x,sourceY:e.y,targetX:s.x,targetY:s.y});if(h[p]*m[p]===-1){p==="x"?(N=o.x??f.x+(x.x-f.x)*c,E=o.y??(f.y+x.y)/2):(N=o.x??(f.x+x.x)/2,E=o.y??f.y+(x.y-f.y)*c);const R=[{x:N,y:f.y},{x:N,y:x.y}],G=[{x:f.x,y:E},{x:x.x,y:E}];h[p]===y?w=p==="x"?R:G:w=p==="x"?G:R}else{const R=[{x:f.x,y:x.y}],G=[{x:x.x,y:f.y}];if(p==="x"?w=h.x===y?G:R:w=h.y===y?R:G,r===l){const B=Math.abs(e[p]-s[p]);if(B<=d){const T=Math.min(d-1,d-B);h[p]===y?A[p]=(f[p]>e[p]?-1:1)*T:C[p]=(x[p]>s[p]?-1:1)*T}}if(r!==l){const B=p==="x"?"y":"x",T=h[p]===m[B],D=f[B]>x[B],z=f[B]<x[B];(h[p]===1&&(!T&&D||T&&z)||h[p]!==1&&(!T&&z||T&&D))&&(w=p==="x"?R:G)}const I={x:f.x+A.x,y:f.y+A.y},Q={x:x.x+C.x,y:x.y+C.y},$=Math.max(Math.abs(I.x-w[0].x),Math.abs(Q.x-w[0].x)),F=Math.max(Math.abs(I.y-w[0].y),Math.abs(Q.y-w[0].y));$>=F?(N=(I.x+Q.x)/2,E=w[0].y):(N=w[0].x,E=(I.y+Q.y)/2)}return[[e,{x:f.x+A.x,y:f.y+A.y},...w,{x:x.x+C.x,y:x.y+C.y},s],N,E,k,S]}function wD(e,r,s,l){const o=Math.min(Jy(e,r)/2,Jy(r,s)/2,l),{x:d,y:c}=r;if(e.x===d&&d===s.x||e.y===c&&c===s.y)return`L${d} ${c}`;if(e.y===c){const f=e.x<s.x?-1:1,x=e.y<s.y?1:-1;return`L ${d+o*f},${c}Q ${d},${c} ${d},${c+o*x}`}const h=e.x<s.x?1:-1,m=e.y<s.y?-1:1;return`L ${d},${c+o*m}Q ${d},${c} ${d+o*h},${c}`}function Dm({sourceX:e,sourceY:r,sourcePosition:s=lt.Bottom,targetX:l,targetY:o,targetPosition:d=lt.Top,borderRadius:c=5,centerX:h,centerY:m,offset:f=20,stepPosition:x=.5}){const[g,p,y,w,N]=jD({source:{x:e,y:r},sourcePosition:s,target:{x:l,y:o},targetPosition:d,center:{x:h,y:m},offset:f,stepPosition:x});return[g.reduce((A,C,k)=>{let S="";return k>0&&k<g.length-1?S=wD(g[k-1],C,g[k+1],c):S=`${k===0?"M":"L"}${C.x} ${C.y}`,A+=S,A},""),p,y,w,N]}function Wy(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function ND(e){const{sourceNode:r,targetNode:s}=e;if(!Wy(r)||!Wy(s))return null;const l=r.internals.handleBounds||ev(r.handles),o=s.internals.handleBounds||ev(s.handles),d=tv(l?.source??[],e.sourceHandle),c=tv(e.connectionMode===ti.Strict?o?.target??[]:(o?.target??[]).concat(o?.source??[]),e.targetHandle);if(!d||!c)return e.onError?.("008",ws.error008(d?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const h=d?.position||lt.Bottom,m=c?.position||lt.Top,f=ol(r,d,h),x=ol(s,c,m);return{sourceX:f.x,sourceY:f.y,targetX:x.x,targetY:x.y,sourcePosition:h,targetPosition:m}}function ev(e){if(!e)return null;const r=[],s=[];for(const l of e)l.width=l.width??1,l.height=l.height??1,l.type==="source"?r.push(l):l.type==="target"&&s.push(l);return{source:r,target:s}}function ol(e,r,s=lt.Left,l=!1){const o=(r?.x??0)+e.internals.positionAbsolute.x,d=(r?.y??0)+e.internals.positionAbsolute.y,{width:c,height:h}=r??Ks(e);if(l)return{x:o+c/2,y:d+h/2};switch(r?.position??s){case lt.Top:return{x:o+c/2,y:d};case lt.Right:return{x:o+c,y:d+h/2};case lt.Bottom:return{x:o+c/2,y:d+h};case lt.Left:return{x:o,y:d+h/2}}}function tv(e,r){return e&&(r?e.find(s=>s.id===r):e[0])||null}function Om(e,r){return e?typeof e=="string"?e:`${r?`${r}__`:""}${Object.keys(e).sort().map(l=>`${l}=${e[l]}`).join("&")}`:""}function kD(e,{id:r,defaultColor:s,defaultMarkerStart:l,defaultMarkerEnd:o}){const d=new Set;return e.reduce((c,h)=>([h.markerStart||l,h.markerEnd||o].forEach(m=>{if(m&&typeof m=="object"){const f=Om(m,r);d.has(f)||(c.push({id:f,color:m.color||s,...m}),d.add(f))}}),c),[]).sort((c,h)=>c.id.localeCompare(h.id))}const Aw=1e3,SD=10,jx={nodeOrigin:[0,0],nodeExtent:Eo,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},CD={...jx,checkEquality:!0};function wx(e,r){const s={...e};for(const l in r)r[l]!==void 0&&(s[l]=r[l]);return s}function ED(e,r,s){const l=wx(jx,s);for(const o of e.values())if(o.parentId)kx(o,e,r,l);else{const d=Ho(o,l.nodeOrigin),c=ai(o.extent)?o.extent:l.nodeExtent,h=il(d,c,Ks(o));o.internals.positionAbsolute=h}}function TD(e,r){if(!e.handles)return e.measured?r?.internals.handleBounds:void 0;const s=[],l=[];for(const o of e.handles){const d={id:o.id,width:o.width??1,height:o.height??1,nodeId:e.id,x:o.x,y:o.y,position:o.position,type:o.type};o.type==="source"?s.push(d):o.type==="target"&&l.push(d)}return{source:s,target:l}}function Nx(e){return e==="manual"}function Rm(e,r,s,l={}){const o=wx(CD,l),d={i:0},c=new Map(r),h=o?.elevateNodesOnSelect&&!Nx(o.zIndexMode)?Aw:0;let m=e.length>0;r.clear(),s.clear();for(const f of e){let x=c.get(f.id);if(o.checkEquality&&f===x?.internals.userNode)r.set(f.id,x);else{const g=Ho(f,o.nodeOrigin),p=ai(f.extent)?f.extent:o.nodeExtent,y=il(g,p,Ks(f));x={...o.defaults,...f,measured:{width:f.measured?.width,height:f.measured?.height},internals:{positionAbsolute:y,handleBounds:TD(f,x),z:_w(f,h,o.zIndexMode),userNode:f}},r.set(f.id,x)}(x.measured===void 0||x.measured.width===void 0||x.measured.height===void 0)&&!x.hidden&&(m=!1),f.parentId&&kx(x,r,s,l,d)}return m}function AD(e,r){if(!e.parentId)return;const s=r.get(e.parentId);s?s.set(e.id,e):r.set(e.parentId,new Map([[e.id,e]]))}function kx(e,r,s,l,o){const{elevateNodesOnSelect:d,nodeOrigin:c,nodeExtent:h,zIndexMode:m}=wx(jx,l),f=e.parentId,x=r.get(f);if(!x){console.warn(`Parent node ${f} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}AD(e,s),o&&!x.parentId&&x.internals.rootParentIndex===void 0&&m==="auto"&&(x.internals.rootParentIndex=++o.i,x.internals.z=x.internals.z+o.i*SD),o&&x.internals.rootParentIndex!==void 0&&(o.i=x.internals.rootParentIndex);const g=d&&!Nx(m)?Aw:0,{x:p,y,z:w}=_D(e,x,c,h,g,m),{positionAbsolute:N}=e.internals,E=p!==N.x||y!==N.y;(E||w!==e.internals.z)&&r.set(e.id,{...e,internals:{...e.internals,positionAbsolute:E?{x:p,y}:N,z:w}})}function _w(e,r,s){const l=rs(e.zIndex)?e.zIndex:0;return Nx(s)?l:l+(e.selected?r:0)}function _D(e,r,s,l,o,d){const{x:c,y:h}=r.internals.positionAbsolute,m=Ks(e),f=Ho(e,s),x=ai(e.extent)?il(f,e.extent,m):f;let g=il({x:c+x.x,y:h+x.y},l,m);e.extent==="parent"&&(g=pw(g,m,r));const p=_w(e,o,d),y=r.internals.z??0;return{x:g.x,y:g.y,z:y>=p?y+1:p}}function Sx(e,r,s,l=[0,0]){const o=[],d=new Map;for(const c of e){const h=r.get(c.parentId);if(!h)continue;const m=d.get(c.parentId)?.expandedRect??si(h),f=yw(m,c.rect);d.set(c.parentId,{expandedRect:f,parent:h})}return d.size>0&&d.forEach(({expandedRect:c,parent:h},m)=>{const f=h.internals.positionAbsolute,x=Ks(h),g=h.origin??l,p=c.x<f.x?Math.round(Math.abs(f.x-c.x)):0,y=c.y<f.y?Math.round(Math.abs(f.y-c.y)):0,w=Math.max(x.width,Math.round(c.width)),N=Math.max(x.height,Math.round(c.height)),E=(w-x.width)*g[0],A=(N-x.height)*g[1];(p>0||y>0||E||A)&&(o.push({id:m,type:"position",position:{x:h.position.x-p+E,y:h.position.y-y+A}}),s.get(m)?.forEach(C=>{e.some(k=>k.id===C.id)||o.push({id:C.id,type:"position",position:{x:C.position.x+p,y:C.position.y+y}})})),(x.width<c.width||x.height<c.height||p||y)&&o.push({id:m,type:"dimensions",setAttributes:!0,dimensions:{width:w+(p?g[0]*p-E:0),height:N+(y?g[1]*y-A:0)}})}),o}function MD(e,r,s,l,o,d,c){const h=l?.querySelector(".xyflow__viewport");let m=!1;if(!h)return{changes:[],updatedInternals:m};const f=[],x=window.getComputedStyle(h),{m22:g}=new window.DOMMatrixReadOnly(x.transform),p=[];for(const y of e.values()){const w=r.get(y.id);if(!w)continue;if(w.hidden){r.set(w.id,{...w,internals:{...w.internals,handleBounds:void 0}}),m=!0;continue}const N=vx(y.nodeElement),E=w.measured.width!==N.width||w.measured.height!==N.height;if(!!(N.width&&N.height&&(E||!w.internals.handleBounds||y.force))){const C=y.nodeElement.getBoundingClientRect(),k=ai(w.extent)?w.extent:d;let{positionAbsolute:S}=w.internals;w.parentId&&w.extent==="parent"?S=pw(S,N,r.get(w.parentId)):k&&(S=il(S,k,N));const O={...w,measured:N,internals:{...w.internals,positionAbsolute:S,handleBounds:{source:Zy("source",y.nodeElement,C,g,w.id),target:Zy("target",y.nodeElement,C,g,w.id)}}};r.set(w.id,O),w.parentId&&kx(O,r,s,{nodeOrigin:o,zIndexMode:c}),m=!0,E&&(f.push({id:w.id,type:"dimensions",dimensions:N}),w.expandParent&&w.parentId&&p.push({id:w.id,parentId:w.parentId,rect:si(O,o)}))}}if(p.length>0){const y=Sx(p,r,s,o);f.push(...y)}return{changes:f,updatedInternals:m}}async function DD({delta:e,panZoom:r,transform:s,translateExtent:l,width:o,height:d}){if(!r||!e.x&&!e.y)return Promise.resolve(!1);const c=await r.setViewportConstrained({x:s[0]+e.x,y:s[1]+e.y,zoom:s[2]},[[0,0],[o,d]],l),h=!!c&&(c.x!==s[0]||c.y!==s[1]||c.k!==s[2]);return Promise.resolve(h)}function nv(e,r,s,l,o,d){let c=o;const h=l.get(c)||new Map;l.set(c,h.set(s,r)),c=`${o}-${e}`;const m=l.get(c)||new Map;if(l.set(c,m.set(s,r)),d){c=`${o}-${e}-${d}`;const f=l.get(c)||new Map;l.set(c,f.set(s,r))}}function Mw(e,r,s){e.clear(),r.clear();for(const l of s){const{source:o,target:d,sourceHandle:c=null,targetHandle:h=null}=l,m={edgeId:l.id,source:o,target:d,sourceHandle:c,targetHandle:h},f=`${o}-${c}--${d}-${h}`,x=`${d}-${h}--${o}-${c}`;nv("source",m,x,e,o,c),nv("target",m,f,e,d,h),r.set(l.id,l)}}function Dw(e,r){if(!e.parentId)return!1;const s=r.get(e.parentId);return s?s.selected?!0:Dw(s,r):!1}function rv(e,r,s){let l=e;do{if(l?.matches?.(r))return!0;if(l===s)return!1;l=l?.parentElement}while(l);return!1}function OD(e,r,s,l){const o=new Map;for(const[d,c]of e)if((c.selected||c.id===l)&&(!c.parentId||!Dw(c,e))&&(c.draggable||r&&typeof c.draggable>"u")){const h=e.get(d);h&&o.set(d,{id:d,position:h.position||{x:0,y:0},distance:{x:s.x-h.internals.positionAbsolute.x,y:s.y-h.internals.positionAbsolute.y},extent:h.extent,parentId:h.parentId,origin:h.origin,expandParent:h.expandParent,internals:{positionAbsolute:h.internals.positionAbsolute||{x:0,y:0}},measured:{width:h.measured.width??0,height:h.measured.height??0}})}return o}function Vh({nodeId:e,dragItems:r,nodeLookup:s,dragging:l=!0}){const o=[];for(const[c,h]of r){const m=s.get(c)?.internals.userNode;m&&o.push({...m,position:h.position,dragging:l})}if(!e)return[o[0],o];const d=s.get(e)?.internals.userNode;return[d?{...d,position:r.get(e)?.position||d.position,dragging:l}:o[0],o]}function RD({dragItems:e,snapGrid:r,x:s,y:l}){const o=e.values().next().value;if(!o)return null;const d={x:s-o.distance.x,y:l-o.distance.y},c=Uo(d,r);return{x:c.x-d.x,y:c.y-d.y}}function LD({onNodeMouseDown:e,getStoreItems:r,onDragStart:s,onDrag:l,onDragStop:o}){let d={x:null,y:null},c=0,h=new Map,m=!1,f={x:0,y:0},x=null,g=!1,p=null,y=!1,w=!1,N=null;function E({noDragClassName:C,handleSelector:k,domNode:S,isSelectable:O,nodeId:R,nodeClickDistance:G=0}){p=Ir(S);function I({x:B,y:T}){const{nodeLookup:D,nodeExtent:z,snapGrid:_,snapToGrid:Y,nodeOrigin:V,onNodeDrag:J,onSelectionDrag:U,onError:H,updateNodePositions:X}=r();d={x:B,y:T};let L=!1;const M=h.size>1,q=M&&z?Mm(Po(h)):null,K=M&&Y?RD({dragItems:h,snapGrid:_,x:B,y:T}):null;for(const[ee,te]of h){if(!D.has(ee))continue;let se={x:B-te.distance.x,y:T-te.distance.y};Y&&(se=K?{x:Math.round(se.x+K.x),y:Math.round(se.y+K.y)}:Uo(se,_));let xe=null;if(M&&z&&!te.extent&&q){const{positionAbsolute:ge}=te.internals,ye=ge.x-q.x+z[0][0],Ce=ge.x+te.measured.width-q.x2+z[1][0],ze=ge.y-q.y+z[0][1],tt=ge.y+te.measured.height-q.y2+z[1][1];xe=[[ye,ze],[Ce,tt]]}const{position:ke,positionAbsolute:De}=gw({nodeId:ee,nextPosition:se,nodeLookup:D,nodeExtent:xe||z,nodeOrigin:V,onError:H});L=L||te.position.x!==ke.x||te.position.y!==ke.y,te.position=ke,te.internals.positionAbsolute=De}if(w=w||L,!!L&&(X(h,!0),N&&(l||J||!R&&U))){const[ee,te]=Vh({nodeId:R,dragItems:h,nodeLookup:D});l?.(N,h,ee,te),J?.(N,ee,te),R||U?.(N,te)}}async function Q(){if(!x)return;const{transform:B,panBy:T,autoPanSpeed:D,autoPanOnNodeDrag:z}=r();if(!z){m=!1,cancelAnimationFrame(c);return}const[_,Y]=bw(f,x,D);(_!==0||Y!==0)&&(d.x=(d.x??0)-_/B[2],d.y=(d.y??0)-Y/B[2],await T({x:_,y:Y})&&I(d)),c=requestAnimationFrame(Q)}function $(B){const{nodeLookup:T,multiSelectionActive:D,nodesDraggable:z,transform:_,snapGrid:Y,snapToGrid:V,selectNodesOnDrag:J,onNodeDragStart:U,onSelectionDragStart:H,unselectNodesAndEdges:X}=r();g=!0,(!J||!O)&&!D&&R&&(T.get(R)?.selected||X()),O&&J&&R&&e?.(R);const L=bo(B.sourceEvent,{transform:_,snapGrid:Y,snapToGrid:V,containerBounds:x});if(d=L,h=OD(T,z,L,R),h.size>0&&(s||U||!R&&H)){const[M,q]=Vh({nodeId:R,dragItems:h,nodeLookup:T});s?.(B.sourceEvent,h,M,q),U?.(B.sourceEvent,M,q),R||H?.(B.sourceEvent,q)}}const F=Zj().clickDistance(G).on("start",B=>{const{domNode:T,nodeDragThreshold:D,transform:z,snapGrid:_,snapToGrid:Y}=r();x=T?.getBoundingClientRect()||null,y=!1,w=!1,N=B.sourceEvent,D===0&&$(B),d=bo(B.sourceEvent,{transform:z,snapGrid:_,snapToGrid:Y,containerBounds:x}),f=ss(B.sourceEvent,x)}).on("drag",B=>{const{autoPanOnNodeDrag:T,transform:D,snapGrid:z,snapToGrid:_,nodeDragThreshold:Y,nodeLookup:V}=r(),J=bo(B.sourceEvent,{transform:D,snapGrid:z,snapToGrid:_,containerBounds:x});if(N=B.sourceEvent,(B.sourceEvent.type==="touchmove"&&B.sourceEvent.touches.length>1||R&&!V.has(R))&&(y=!0),!y){if(!m&&T&&g&&(m=!0,Q()),!g){const U=ss(B.sourceEvent,x),H=U.x-f.x,X=U.y-f.y;Math.sqrt(H*H+X*X)>Y&&$(B)}(d.x!==J.xSnapped||d.y!==J.ySnapped)&&h&&g&&(f=ss(B.sourceEvent,x),I(J))}}).on("end",B=>{if(!(!g||y)&&(m=!1,g=!1,cancelAnimationFrame(c),h.size>0)){const{nodeLookup:T,updateNodePositions:D,onNodeDragStop:z,onSelectionDragStop:_}=r();if(w&&(D(h,!1),w=!1),o||z||!R&&_){const[Y,V]=Vh({nodeId:R,dragItems:h,nodeLookup:T,dragging:!1});o?.(B.sourceEvent,h,Y,V),z?.(B.sourceEvent,Y,V),R||_?.(B.sourceEvent,V)}}}).filter(B=>{const T=B.target;return!B.button&&(!C||!rv(T,`.${C}`,S))&&(!k||rv(T,k,S))});p.call(F)}function A(){p?.on(".drag",null)}return{update:E,destroy:A}}function zD(e,r,s){const l=[],o={x:e.x-s,y:e.y-s,width:s*2,height:s*2};for(const d of r.values())Ao(o,si(d))>0&&l.push(d);return l}const ID=250;function $D(e,r,s,l){let o=[],d=1/0;const c=zD(e,s,r+ID);for(const h of c){const m=[...h.internals.handleBounds?.source??[],...h.internals.handleBounds?.target??[]];for(const f of m){if(l.nodeId===f.nodeId&&l.type===f.type&&l.id===f.id)continue;const{x,y:g}=ol(h,f,f.position,!0),p=Math.sqrt(Math.pow(x-e.x,2)+Math.pow(g-e.y,2));p>r||(p<d?(o=[{...f,x,y:g}],d=p):p===d&&o.push({...f,x,y:g}))}}if(!o.length)return null;if(o.length>1){const h=l.type==="source"?"target":"source";return o.find(m=>m.type===h)??o[0]}return o[0]}function Ow(e,r,s,l,o,d=!1){const c=l.get(e);if(!c)return null;const h=o==="strict"?c.internals.handleBounds?.[r]:[...c.internals.handleBounds?.source??[],...c.internals.handleBounds?.target??[]],m=(s?h?.find(f=>f.id===s):h?.[0])??null;return m&&d?{...m,...ol(c,m,m.position,!0)}:m}function Rw(e,r){return e||(r?.classList.contains("target")?"target":r?.classList.contains("source")?"source":null)}function BD(e,r){let s=null;return r?s=!0:e&&!r&&(s=!1),s}const Lw=()=>!0;function HD(e,{connectionMode:r,connectionRadius:s,handleId:l,nodeId:o,edgeUpdaterType:d,isTarget:c,domNode:h,nodeLookup:m,lib:f,autoPanOnConnect:x,flowId:g,panBy:p,cancelConnection:y,onConnectStart:w,onConnect:N,onConnectEnd:E,isValidConnection:A=Lw,onReconnectEnd:C,updateConnection:k,getTransform:S,getFromHandle:O,autoPanSpeed:R,dragThreshold:G=1,handleDomNode:I}){const Q=ww(e.target);let $=0,F;const{x:B,y:T}=ss(e),D=Rw(d,I),z=h?.getBoundingClientRect();let _=!1;if(!z||!D)return;const Y=Ow(o,D,l,m,r);if(!Y)return;let V=ss(e,z),J=!1,U=null,H=!1,X=null;function L(){if(!x||!z)return;const[ke,De]=bw(V,z,R);p({x:ke,y:De}),$=requestAnimationFrame(L)}const M={...Y,nodeId:o,type:D,position:Y.position},q=m.get(o);let ee={inProgress:!0,isValid:null,from:ol(q,M,lt.Left,!0),fromHandle:M,fromPosition:M.position,fromNode:q,to:V,toHandle:null,toPosition:Vy[M.position],toNode:null,pointer:V};function te(){_=!0,k(ee),w?.(e,{nodeId:o,handleId:l,handleType:D})}G===0&&te();function se(ke){if(!_){const{x:tt,y:Xe}=ss(ke),dt=tt-B,wt=Xe-T;if(!(dt*dt+wt*wt>G*G))return;te()}if(!O()||!M){xe(ke);return}const De=S();V=ss(ke,z),F=$D(qo(V,De,!1,[1,1]),s,m,M),J||(L(),J=!0);const ge=zw(ke,{handle:F,connectionMode:r,fromNodeId:o,fromHandleId:l,fromType:c?"target":"source",isValidConnection:A,doc:Q,lib:f,flowId:g,nodeLookup:m});X=ge.handleDomNode,U=ge.connection,H=BD(!!F,ge.isValid);const ye=m.get(o),Ce=ye?ol(ye,M,lt.Left,!0):ee.from,ze={...ee,from:Ce,isValid:H,to:ge.toHandle&&H?Pd({x:ge.toHandle.x,y:ge.toHandle.y},De):V,toHandle:ge.toHandle,toPosition:H&&ge.toHandle?ge.toHandle.position:Vy[M.position],toNode:ge.toHandle?m.get(ge.toHandle.nodeId):null,pointer:V};k(ze),ee=ze}function xe(ke){if(!("touches"in ke&&ke.touches.length>0)){if(_){(F||X)&&U&&H&&N?.(U);const{inProgress:De,...ge}=ee,ye={...ge,toPosition:ee.toHandle?ee.toPosition:null};E?.(ke,ye),d&&C?.(ke,ye)}y(),cancelAnimationFrame($),J=!1,H=!1,U=null,X=null,Q.removeEventListener("mousemove",se),Q.removeEventListener("mouseup",xe),Q.removeEventListener("touchmove",se),Q.removeEventListener("touchend",xe)}}Q.addEventListener("mousemove",se),Q.addEventListener("mouseup",xe),Q.addEventListener("touchmove",se),Q.addEventListener("touchend",xe)}function zw(e,{handle:r,connectionMode:s,fromNodeId:l,fromHandleId:o,fromType:d,doc:c,lib:h,flowId:m,isValidConnection:f=Lw,nodeLookup:x}){const g=d==="target",p=r?c.querySelector(`.${h}-flow__handle[data-id="${m}-${r?.nodeId}-${r?.id}-${r?.type}"]`):null,{x:y,y:w}=ss(e),N=c.elementFromPoint(y,w),E=N?.classList.contains(`${h}-flow__handle`)?N:p,A={handleDomNode:E,isValid:!1,connection:null,toHandle:null};if(E){const C=Rw(void 0,E),k=E.getAttribute("data-nodeid"),S=E.getAttribute("data-handleid"),O=E.classList.contains("connectable"),R=E.classList.contains("connectableend");if(!k||!C)return A;const G={source:g?k:l,sourceHandle:g?S:o,target:g?l:k,targetHandle:g?o:S};A.connection=G;const Q=O&&R&&(s===ti.Strict?g&&C==="source"||!g&&C==="target":k!==l||S!==o);A.isValid=Q&&f(G),A.toHandle=Ow(k,C,S,x,s,!0)}return A}const Lm={onPointerDown:HD,isValid:zw};function PD({domNode:e,panZoom:r,getTransform:s,getViewScale:l}){const o=Ir(e);function d({translateExtent:h,width:m,height:f,zoomStep:x=1,pannable:g=!0,zoomable:p=!0,inversePan:y=!1}){const w=k=>{if(k.sourceEvent.type!=="wheel"||!r)return;const S=s(),O=k.sourceEvent.ctrlKey&&_o()?10:1,R=-k.sourceEvent.deltaY*(k.sourceEvent.deltaMode===1?.05:k.sourceEvent.deltaMode?1:.002)*x,G=S[2]*Math.pow(2,R*O);r.scaleTo(G)};let N=[0,0];const E=k=>{(k.sourceEvent.type==="mousedown"||k.sourceEvent.type==="touchstart")&&(N=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY])},A=k=>{const S=s();if(k.sourceEvent.type!=="mousemove"&&k.sourceEvent.type!=="touchmove"||!r)return;const O=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY],R=[O[0]-N[0],O[1]-N[1]];N=O;const G=l()*Math.max(S[2],Math.log(S[2]))*(y?-1:1),I={x:S[0]-R[0]*G,y:S[1]-R[1]*G},Q=[[0,0],[m,f]];r.setViewportConstrained({x:I.x,y:I.y,zoom:S[2]},Q,h)},C=dw().on("start",E).on("zoom",g?A:null).on("zoom.wheel",p?w:null);o.call(C,{})}function c(){o.on("zoom",null)}return{update:d,destroy:c,pointer:ts}}const iu=e=>({x:e.x,y:e.y,zoom:e.k}),Yh=({x:e,y:r,zoom:s})=>su.translate(e,r).scale(s),Gl=(e,r)=>e.target.closest(`.${r}`),Iw=(e,r)=>r===2&&Array.isArray(e)&&e.includes(2),UD=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Gh=(e,r=0,s=UD,l=()=>{})=>{const o=typeof r=="number"&&r>0;return o||l(),o?e.transition().duration(r).ease(s).on("end",l):e},$w=e=>{const r=e.ctrlKey&&_o()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*r};function qD({zoomPanValues:e,noWheelClassName:r,d3Selection:s,d3Zoom:l,panOnScrollMode:o,panOnScrollSpeed:d,zoomOnPinch:c,onPanZoomStart:h,onPanZoom:m,onPanZoomEnd:f}){return x=>{if(Gl(x,r))return x.ctrlKey&&x.preventDefault(),!1;x.preventDefault(),x.stopImmediatePropagation();const g=s.property("__zoom").k||1;if(x.ctrlKey&&c){const E=ts(x),A=$w(x),C=g*Math.pow(2,A);l.scaleTo(s,C,E,x);return}const p=x.deltaMode===1?20:1;let y=o===nl.Vertical?0:x.deltaX*p,w=o===nl.Horizontal?0:x.deltaY*p;!_o()&&x.shiftKey&&o!==nl.Vertical&&(y=x.deltaY*p,w=0),l.translateBy(s,-(y/g)*d,-(w/g)*d,{internal:!0});const N=iu(s.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(m?.(x,N),e.panScrollTimeout=setTimeout(()=>{f?.(x,N),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,h?.(x,N))}}function FD({noWheelClassName:e,preventScrolling:r,d3ZoomHandler:s}){return function(l,o){const d=l.type==="wheel",c=!r&&d&&!l.ctrlKey,h=Gl(l,e);if(l.ctrlKey&&d&&h&&l.preventDefault(),c||h)return null;l.preventDefault(),s.call(this,l,o)}}function VD({zoomPanValues:e,onDraggingChange:r,onPanZoomStart:s}){return l=>{if(l.sourceEvent?.internal)return;const o=iu(l.transform);e.mouseButton=l.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=o,l.sourceEvent?.type==="mousedown"&&r(!0),s&&s?.(l.sourceEvent,o)}}function YD({zoomPanValues:e,panOnDrag:r,onPaneContextMenu:s,onTransformChange:l,onPanZoom:o}){return d=>{e.usedRightMouseButton=!!(s&&Iw(r,e.mouseButton??0)),d.sourceEvent?.sync||l([d.transform.x,d.transform.y,d.transform.k]),o&&!d.sourceEvent?.internal&&o?.(d.sourceEvent,iu(d.transform))}}function GD({zoomPanValues:e,panOnDrag:r,panOnScroll:s,onDraggingChange:l,onPanZoomEnd:o,onPaneContextMenu:d}){return c=>{if(!c.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,d&&Iw(r,e.mouseButton??0)&&!e.usedRightMouseButton&&c.sourceEvent&&d(c.sourceEvent),e.usedRightMouseButton=!1,l(!1),o)){const h=iu(c.transform);e.prevViewport=h,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o?.(c.sourceEvent,h)},s?150:0)}}}function XD({zoomActivationKeyPressed:e,zoomOnScroll:r,zoomOnPinch:s,panOnDrag:l,panOnScroll:o,zoomOnDoubleClick:d,userSelectionActive:c,noWheelClassName:h,noPanClassName:m,lib:f,connectionInProgress:x}){return g=>{const p=e||r,y=s&&g.ctrlKey,w=g.type==="wheel";if(g.button===1&&g.type==="mousedown"&&(Gl(g,`${f}-flow__node`)||Gl(g,`${f}-flow__edge`)))return!0;if(!l&&!p&&!o&&!d&&!s||c||x&&!w||Gl(g,h)&&w||Gl(g,m)&&(!w||o&&w&&!e)||!s&&g.ctrlKey&&w)return!1;if(!s&&g.type==="touchstart"&&g.touches?.length>1)return g.preventDefault(),!1;if(!p&&!o&&!y&&w||!l&&(g.type==="mousedown"||g.type==="touchstart")||Array.isArray(l)&&!l.includes(g.button)&&g.type==="mousedown")return!1;const N=Array.isArray(l)&&l.includes(g.button)||!g.button||g.button<=1;return(!g.ctrlKey||w)&&N}}function ZD({domNode:e,minZoom:r,maxZoom:s,translateExtent:l,viewport:o,onPanZoom:d,onPanZoomStart:c,onPanZoomEnd:h,onDraggingChange:m}){const f={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},x=e.getBoundingClientRect(),g=dw().scaleExtent([r,s]).translateExtent(l),p=Ir(e).call(g);C({x:o.x,y:o.y,zoom:ri(o.zoom,r,s)},[[0,0],[x.width,x.height]],l);const y=p.on("wheel.zoom"),w=p.on("dblclick.zoom");g.wheelDelta($w);function N(F,B){return p?new Promise(T=>{g?.interpolate(B?.interpolate==="linear"?po:pd).transform(Gh(p,B?.duration,B?.ease,()=>T(!0)),F)}):Promise.resolve(!1)}function E({noWheelClassName:F,noPanClassName:B,onPaneContextMenu:T,userSelectionActive:D,panOnScroll:z,panOnDrag:_,panOnScrollMode:Y,panOnScrollSpeed:V,preventScrolling:J,zoomOnPinch:U,zoomOnScroll:H,zoomOnDoubleClick:X,zoomActivationKeyPressed:L,lib:M,onTransformChange:q,connectionInProgress:K,paneClickDistance:ee,selectionOnDrag:te}){D&&!f.isZoomingOrPanning&&A();const se=z&&!L&&!D;g.clickDistance(te?1/0:!rs(ee)||ee<0?0:ee);const xe=se?qD({zoomPanValues:f,noWheelClassName:F,d3Selection:p,d3Zoom:g,panOnScrollMode:Y,panOnScrollSpeed:V,zoomOnPinch:U,onPanZoomStart:c,onPanZoom:d,onPanZoomEnd:h}):FD({noWheelClassName:F,preventScrolling:J,d3ZoomHandler:y});if(p.on("wheel.zoom",xe,{passive:!1}),!D){const De=VD({zoomPanValues:f,onDraggingChange:m,onPanZoomStart:c});g.on("start",De);const ge=YD({zoomPanValues:f,panOnDrag:_,onPaneContextMenu:!!T,onPanZoom:d,onTransformChange:q});g.on("zoom",ge);const ye=GD({zoomPanValues:f,panOnDrag:_,panOnScroll:z,onPaneContextMenu:T,onPanZoomEnd:h,onDraggingChange:m});g.on("end",ye)}const ke=XD({zoomActivationKeyPressed:L,panOnDrag:_,zoomOnScroll:H,panOnScroll:z,zoomOnDoubleClick:X,zoomOnPinch:U,userSelectionActive:D,noPanClassName:B,noWheelClassName:F,lib:M,connectionInProgress:K});g.filter(ke),X?p.on("dblclick.zoom",w):p.on("dblclick.zoom",null)}function A(){g.on("zoom",null)}async function C(F,B,T){const D=Yh(F),z=g?.constrain()(D,B,T);return z&&await N(z),new Promise(_=>_(z))}async function k(F,B){const T=Yh(F);return await N(T,B),new Promise(D=>D(T))}function S(F){if(p){const B=Yh(F),T=p.property("__zoom");(T.k!==F.zoom||T.x!==F.x||T.y!==F.y)&&g?.transform(p,B,null,{sync:!0})}}function O(){const F=p?cw(p.node()):{x:0,y:0,k:1};return{x:F.x,y:F.y,zoom:F.k}}function R(F,B){return p?new Promise(T=>{g?.interpolate(B?.interpolate==="linear"?po:pd).scaleTo(Gh(p,B?.duration,B?.ease,()=>T(!0)),F)}):Promise.resolve(!1)}function G(F,B){return p?new Promise(T=>{g?.interpolate(B?.interpolate==="linear"?po:pd).scaleBy(Gh(p,B?.duration,B?.ease,()=>T(!0)),F)}):Promise.resolve(!1)}function I(F){g?.scaleExtent(F)}function Q(F){g?.translateExtent(F)}function $(F){const B=!rs(F)||F<0?0:F;g?.clickDistance(B)}return{update:E,destroy:A,setViewport:k,setViewportConstrained:C,getViewport:O,scaleTo:R,scaleBy:G,setScaleExtent:I,setTranslateExtent:Q,syncViewport:S,setClickDistance:$}}var li;(function(e){e.Line="line",e.Handle="handle"})(li||(li={}));function QD({width:e,prevWidth:r,height:s,prevHeight:l,affectsX:o,affectsY:d}){const c=e-r,h=s-l,m=[c>0?1:c<0?-1:0,h>0?1:h<0?-1:0];return c&&o&&(m[0]=m[0]*-1),h&&d&&(m[1]=m[1]*-1),m}function sv(e){const r=e.includes("right")||e.includes("left"),s=e.includes("bottom")||e.includes("top"),l=e.includes("left"),o=e.includes("top");return{isHorizontal:r,isVertical:s,affectsX:l,affectsY:o}}function Sa(e,r){return Math.max(0,r-e)}function Ca(e,r){return Math.max(0,e-r)}function cd(e,r,s){return Math.max(0,r-e,e-s)}function av(e,r){return e?!r:r}function KD(e,r,s,l,o,d,c,h){let{affectsX:m,affectsY:f}=r;const{isHorizontal:x,isVertical:g}=r,p=x&&g,{xSnapped:y,ySnapped:w}=s,{minWidth:N,maxWidth:E,minHeight:A,maxHeight:C}=l,{x:k,y:S,width:O,height:R,aspectRatio:G}=e;let I=Math.floor(x?y-e.pointerX:0),Q=Math.floor(g?w-e.pointerY:0);const $=O+(m?-I:I),F=R+(f?-Q:Q),B=-d[0]*O,T=-d[1]*R;let D=cd($,N,E),z=cd(F,A,C);if(c){let V=0,J=0;m&&I<0?V=Sa(k+I+B,c[0][0]):!m&&I>0&&(V=Ca(k+$+B,c[1][0])),f&&Q<0?J=Sa(S+Q+T,c[0][1]):!f&&Q>0&&(J=Ca(S+F+T,c[1][1])),D=Math.max(D,V),z=Math.max(z,J)}if(h){let V=0,J=0;m&&I>0?V=Ca(k+I,h[0][0]):!m&&I<0&&(V=Sa(k+$,h[1][0])),f&&Q>0?J=Ca(S+Q,h[0][1]):!f&&Q<0&&(J=Sa(S+F,h[1][1])),D=Math.max(D,V),z=Math.max(z,J)}if(o){if(x){const V=cd($/G,A,C)*G;if(D=Math.max(D,V),c){let J=0;!m&&!f||m&&!f&&p?J=Ca(S+T+$/G,c[1][1])*G:J=Sa(S+T+(m?I:-I)/G,c[0][1])*G,D=Math.max(D,J)}if(h){let J=0;!m&&!f||m&&!f&&p?J=Sa(S+$/G,h[1][1])*G:J=Ca(S+(m?I:-I)/G,h[0][1])*G,D=Math.max(D,J)}}if(g){const V=cd(F*G,N,E)/G;if(z=Math.max(z,V),c){let J=0;!m&&!f||f&&!m&&p?J=Ca(k+F*G+B,c[1][0])/G:J=Sa(k+(f?Q:-Q)*G+B,c[0][0])/G,z=Math.max(z,J)}if(h){let J=0;!m&&!f||f&&!m&&p?J=Sa(k+F*G,h[1][0])/G:J=Ca(k+(f?Q:-Q)*G,h[0][0])/G,z=Math.max(z,J)}}}Q=Q+(Q<0?z:-z),I=I+(I<0?D:-D),o&&(p?$>F*G?Q=(av(m,f)?-I:I)/G:I=(av(m,f)?-Q:Q)*G:x?(Q=I/G,f=m):(I=Q*G,m=f));const _=m?k+I:k,Y=f?S+Q:S;return{width:O+(m?-I:I),height:R+(f?-Q:Q),x:d[0]*I*(m?-1:1)+_,y:d[1]*Q*(f?-1:1)+Y}}const Bw={width:0,height:0,x:0,y:0},JD={...Bw,pointerX:0,pointerY:0,aspectRatio:1};function WD(e){return[[0,0],[e.measured.width,e.measured.height]]}function eO(e,r,s){const l=r.position.x+e.position.x,o=r.position.y+e.position.y,d=e.measured.width??0,c=e.measured.height??0,h=s[0]*d,m=s[1]*c;return[[l-h,o-m],[l+d-h,o+c-m]]}function tO({domNode:e,nodeId:r,getStoreItems:s,onChange:l,onEnd:o}){const d=Ir(e);let c={controlDirection:sv("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function h({controlPosition:f,boundaries:x,keepAspectRatio:g,resizeDirection:p,onResizeStart:y,onResize:w,onResizeEnd:N,shouldResize:E}){let A={...Bw},C={...JD};c={boundaries:x,resizeDirection:p,keepAspectRatio:g,controlDirection:sv(f)};let k,S=null,O=[],R,G,I,Q=!1;const $=Zj().on("start",F=>{const{nodeLookup:B,transform:T,snapGrid:D,snapToGrid:z,nodeOrigin:_,paneDomNode:Y}=s();if(k=B.get(r),!k)return;S=Y?.getBoundingClientRect()??null;const{xSnapped:V,ySnapped:J}=bo(F.sourceEvent,{transform:T,snapGrid:D,snapToGrid:z,containerBounds:S});A={width:k.measured.width??0,height:k.measured.height??0,x:k.position.x??0,y:k.position.y??0},C={...A,pointerX:V,pointerY:J,aspectRatio:A.width/A.height},R=void 0,k.parentId&&(k.extent==="parent"||k.expandParent)&&(R=B.get(k.parentId),G=R&&k.extent==="parent"?WD(R):void 0),O=[],I=void 0;for(const[U,H]of B)if(H.parentId===r&&(O.push({id:U,position:{...H.position},extent:H.extent}),H.extent==="parent"||H.expandParent)){const X=eO(H,k,H.origin??_);I?I=[[Math.min(X[0][0],I[0][0]),Math.min(X[0][1],I[0][1])],[Math.max(X[1][0],I[1][0]),Math.max(X[1][1],I[1][1])]]:I=X}y?.(F,{...A})}).on("drag",F=>{const{transform:B,snapGrid:T,snapToGrid:D,nodeOrigin:z}=s(),_=bo(F.sourceEvent,{transform:B,snapGrid:T,snapToGrid:D,containerBounds:S}),Y=[];if(!k)return;const{x:V,y:J,width:U,height:H}=A,X={},L=k.origin??z,{width:M,height:q,x:K,y:ee}=KD(C,c.controlDirection,_,c.boundaries,c.keepAspectRatio,L,G,I),te=M!==U,se=q!==H,xe=K!==V&&te,ke=ee!==J&&se;if(!xe&&!ke&&!te&&!se)return;if((xe||ke||L[0]===1||L[1]===1)&&(X.x=xe?K:A.x,X.y=ke?ee:A.y,A.x=X.x,A.y=X.y,O.length>0)){const Ce=K-V,ze=ee-J;for(const tt of O)tt.position={x:tt.position.x-Ce+L[0]*(M-U),y:tt.position.y-ze+L[1]*(q-H)},Y.push(tt)}if((te||se)&&(X.width=te&&(!c.resizeDirection||c.resizeDirection==="horizontal")?M:A.width,X.height=se&&(!c.resizeDirection||c.resizeDirection==="vertical")?q:A.height,A.width=X.width,A.height=X.height),R&&k.expandParent){const Ce=L[0]*(X.width??0);X.x&&X.x<Ce&&(A.x=Ce,C.x=C.x-(X.x-Ce));const ze=L[1]*(X.height??0);X.y&&X.y<ze&&(A.y=ze,C.y=C.y-(X.y-ze))}const De=QD({width:A.width,prevWidth:U,height:A.height,prevHeight:H,affectsX:c.controlDirection.affectsX,affectsY:c.controlDirection.affectsY}),ge={...A,direction:De};E?.(F,ge)!==!1&&(Q=!0,w?.(F,ge),l(X,Y))}).on("end",F=>{Q&&(N?.(F,{...A}),o?.({...A}),Q=!1)});d.call($)}function m(){d.on(".drag",null)}return{update:h,destroy:m}}var Xh={exports:{}},Zh={},Qh={exports:{}},Kh={};var lv;function nO(){if(lv)return Kh;lv=1;var e=Ro();function r(g,p){return g===p&&(g!==0||1/g===1/p)||g!==g&&p!==p}var s=typeof Object.is=="function"?Object.is:r,l=e.useState,o=e.useEffect,d=e.useLayoutEffect,c=e.useDebugValue;function h(g,p){var y=p(),w=l({inst:{value:y,getSnapshot:p}}),N=w[0].inst,E=w[1];return d(function(){N.value=y,N.getSnapshot=p,m(N)&&E({inst:N})},[g,y,p]),o(function(){return m(N)&&E({inst:N}),g(function(){m(N)&&E({inst:N})})},[g]),c(y),y}function m(g){var p=g.getSnapshot;g=g.value;try{var y=p();return!s(g,y)}catch{return!0}}function f(g,p){return p()}var x=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:h;return Kh.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:x,Kh}var iv;function rO(){return iv||(iv=1,Qh.exports=nO()),Qh.exports}var ov;function sO(){if(ov)return Zh;ov=1;var e=Ro(),r=rO();function s(f,x){return f===x&&(f!==0||1/f===1/x)||f!==f&&x!==x}var l=typeof Object.is=="function"?Object.is:s,o=r.useSyncExternalStore,d=e.useRef,c=e.useEffect,h=e.useMemo,m=e.useDebugValue;return Zh.useSyncExternalStoreWithSelector=function(f,x,g,p,y){var w=d(null);if(w.current===null){var N={hasValue:!1,value:null};w.current=N}else N=w.current;w=h(function(){function A(R){if(!C){if(C=!0,k=R,R=p(R),y!==void 0&&N.hasValue){var G=N.value;if(y(G,R))return S=G}return S=R}if(G=S,l(k,R))return G;var I=p(R);return y!==void 0&&y(G,I)?(k=R,G):(k=R,S=I)}var C=!1,k,S,O=g===void 0?null:g;return[function(){return A(x())},O===null?void 0:function(){return A(O())}]},[x,g,p,y]);var E=o(f,w[0],w[1]);return c(function(){N.hasValue=!0,N.value=E},[E]),m(E),E},Zh}var cv;function aO(){return cv||(cv=1,Xh.exports=sO()),Xh.exports}var lO=aO();const iO=Fd(lO),oO={},dv=e=>{let r;const s=new Set,l=(x,g)=>{const p=typeof x=="function"?x(r):x;if(!Object.is(p,r)){const y=r;r=g??(typeof p!="object"||p===null)?p:Object.assign({},r,p),s.forEach(w=>w(r,y))}},o=()=>r,m={setState:l,getState:o,getInitialState:()=>f,subscribe:x=>(s.add(x),()=>s.delete(x)),destroy:()=>{(oO?"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."),s.clear()}},f=r=e(l,o,m);return m},cO=e=>e?dv(e):dv,{useDebugValue:dO}=z2,{useSyncExternalStoreWithSelector:uO}=iO,fO=e=>e;function Hw(e,r=fO,s){const l=uO(e.subscribe,e.getState,e.getServerState||e.getInitialState,r,s);return dO(l),l}const uv=(e,r)=>{const s=cO(e),l=(o,d=r)=>Hw(s,o,d);return Object.assign(l,s),l},hO=(e,r)=>e?uv(e,r):uv;function Sn(e,r){if(Object.is(e,r))return!0;if(typeof e!="object"||e===null||typeof r!="object"||r===null)return!1;if(e instanceof Map&&r instanceof Map){if(e.size!==r.size)return!1;for(const[l,o]of e)if(!Object.is(o,r.get(l)))return!1;return!0}if(e instanceof Set&&r instanceof Set){if(e.size!==r.size)return!1;for(const l of e)if(!r.has(l))return!1;return!0}const s=Object.keys(e);if(s.length!==Object.keys(r).length)return!1;for(const l of s)if(!Object.prototype.hasOwnProperty.call(r,l)||!Object.is(e[l],r[l]))return!1;return!0}const ou=v.createContext(null),mO=ou.Provider,Pw=ws.error001();function Vt(e,r){const s=v.useContext(ou);if(s===null)throw new Error(Pw);return Hw(s,e,r)}function Cn(){const e=v.useContext(ou);if(e===null)throw new Error(Pw);return v.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const fv={display:"none"},xO={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Uw="react-flow__node-desc",qw="react-flow__edge-desc",gO="react-flow__aria-live",pO=e=>e.ariaLiveMessage,bO=e=>e.ariaLabelConfig;function yO({rfId:e}){const r=Vt(pO);return t.jsx("div",{id:`${gO}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:xO,children:r})}function vO({rfId:e,disableKeyboardA11y:r}){const s=Vt(bO);return t.jsxs(t.Fragment,{children:[t.jsx("div",{id:`${Uw}-${e}`,style:fv,children:r?s["node.a11yDescription.default"]:s["node.a11yDescription.keyboardDisabled"]}),t.jsx("div",{id:`${qw}-${e}`,style:fv,children:s["edge.a11yDescription.default"]}),!r&&t.jsx(yO,{rfId:e})]})}const cu=v.forwardRef(({position:e="top-left",children:r,className:s,style:l,...o},d)=>{const c=`${e}`.split("-");return t.jsx("div",{className:Fn(["react-flow__panel",s,...c]),style:l,ref:d,...o,children:r})});cu.displayName="Panel";function jO({proOptions:e,position:r="bottom-right"}){return e?.hideAttribution?null:t.jsx(cu,{position:r,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:t.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const wO=e=>{const r=[],s=[];for(const[,l]of e.nodeLookup)l.selected&&r.push(l.internals.userNode);for(const[,l]of e.edgeLookup)l.selected&&s.push(l);return{selectedNodes:r,selectedEdges:s}},dd=e=>e.id;function NO(e,r){return Sn(e.selectedNodes.map(dd),r.selectedNodes.map(dd))&&Sn(e.selectedEdges.map(dd),r.selectedEdges.map(dd))}function kO({onSelectionChange:e}){const r=Cn(),{selectedNodes:s,selectedEdges:l}=Vt(wO,NO);return v.useEffect(()=>{const o={nodes:s,edges:l};e?.(o),r.getState().onSelectionChangeHandlers.forEach(d=>d(o))},[s,l,e]),null}const SO=e=>!!e.onSelectionChangeHandlers;function CO({onSelectionChange:e}){const r=Vt(SO);return e||r?t.jsx(kO,{onSelectionChange:e}):null}const Fw=[0,0],EO={x:0,y:0,zoom:1},TO=["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"],hv=[...TO,"rfId"],AO=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}),mv={translateExtent:Eo,nodeOrigin:Fw,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function _O(e){const{setNodes:r,setEdges:s,setMinZoom:l,setMaxZoom:o,setTranslateExtent:d,setNodeExtent:c,reset:h,setDefaultNodesAndEdges:m}=Vt(AO,Sn),f=Cn();v.useEffect(()=>(m(e.defaultNodes,e.defaultEdges),()=>{x.current=mv,h()}),[]);const x=v.useRef(mv);return v.useEffect(()=>{for(const g of hv){const p=e[g],y=x.current[g];p!==y&&(typeof e[g]>"u"||(g==="nodes"?r(p):g==="edges"?s(p):g==="minZoom"?l(p):g==="maxZoom"?o(p):g==="translateExtent"?d(p):g==="nodeExtent"?c(p):g==="ariaLabelConfig"?f.setState({ariaLabelConfig:hD(p)}):g==="fitView"?f.setState({fitViewQueued:p}):g==="fitViewOptions"?f.setState({fitViewOptions:p}):f.setState({[g]:p})))}x.current=e},hv.map(g=>e[g])),null}function xv(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function MO(e){const[r,s]=v.useState(e==="system"?null:e);return v.useEffect(()=>{if(e!=="system"){s(e);return}const l=xv(),o=()=>s(l?.matches?"dark":"light");return o(),l?.addEventListener("change",o),()=>{l?.removeEventListener("change",o)}},[e]),r!==null?r:xv()?.matches?"dark":"light"}const gv=typeof document<"u"?document:null;function Mo(e=null,r={target:gv,actInsideInputWithModifier:!0}){const[s,l]=v.useState(!1),o=v.useRef(!1),d=v.useRef(new Set([])),[c,h]=v.useMemo(()=>{if(e!==null){const f=(Array.isArray(e)?e:[e]).filter(g=>typeof g=="string").map(g=>g.replace("+",`
|
|
56
|
+
`).replace(`
|
|
57
|
+
|
|
58
|
+
`,`
|
|
59
|
+
+`).split(`
|
|
60
|
+
`)),x=f.reduce((g,p)=>g.concat(...p),[]);return[f,x]}return[[],[]]},[e]);return v.useEffect(()=>{const m=r?.target??gv,f=r?.actInsideInputWithModifier??!0;if(e!==null){const x=y=>{if(o.current=y.ctrlKey||y.metaKey||y.shiftKey||y.altKey,(!o.current||o.current&&!f)&&Nw(y))return!1;const N=bv(y.code,h);if(d.current.add(y[N]),pv(c,d.current,!1)){const E=y.composedPath?.()?.[0]||y.target,A=E?.nodeName==="BUTTON"||E?.nodeName==="A";r.preventDefault!==!1&&(o.current||!A)&&y.preventDefault(),l(!0)}},g=y=>{const w=bv(y.code,h);pv(c,d.current,!0)?(l(!1),d.current.clear()):d.current.delete(y[w]),y.key==="Meta"&&d.current.clear(),o.current=!1},p=()=>{d.current.clear(),l(!1)};return m?.addEventListener("keydown",x),m?.addEventListener("keyup",g),window.addEventListener("blur",p),window.addEventListener("contextmenu",p),()=>{m?.removeEventListener("keydown",x),m?.removeEventListener("keyup",g),window.removeEventListener("blur",p),window.removeEventListener("contextmenu",p)}}},[e,l]),s}function pv(e,r,s){return e.filter(l=>s||l.length===r.size).some(l=>l.every(o=>r.has(o)))}function bv(e,r){return r.includes(e)?"code":"key"}const DO=()=>{const e=Cn();return v.useMemo(()=>({zoomIn:r=>{const{panZoom:s}=e.getState();return s?s.scaleBy(1.2,{duration:r?.duration}):Promise.resolve(!1)},zoomOut:r=>{const{panZoom:s}=e.getState();return s?s.scaleBy(1/1.2,{duration:r?.duration}):Promise.resolve(!1)},zoomTo:(r,s)=>{const{panZoom:l}=e.getState();return l?l.scaleTo(r,{duration:s?.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(r,s)=>{const{transform:[l,o,d],panZoom:c}=e.getState();return c?(await c.setViewport({x:r.x??l,y:r.y??o,zoom:r.zoom??d},s),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[r,s,l]=e.getState().transform;return{x:r,y:s,zoom:l}},setCenter:async(r,s,l)=>e.getState().setCenter(r,s,l),fitBounds:async(r,s)=>{const{width:l,height:o,minZoom:d,maxZoom:c,panZoom:h}=e.getState(),m=yx(r,l,o,d,c,s?.padding??.1);return h?(await h.setViewport(m,{duration:s?.duration,ease:s?.ease,interpolate:s?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(r,s={})=>{const{transform:l,snapGrid:o,snapToGrid:d,domNode:c}=e.getState();if(!c)return r;const{x:h,y:m}=c.getBoundingClientRect(),f={x:r.x-h,y:r.y-m},x=s.snapGrid??o,g=s.snapToGrid??d;return qo(f,l,g,x)},flowToScreenPosition:r=>{const{transform:s,domNode:l}=e.getState();if(!l)return r;const{x:o,y:d}=l.getBoundingClientRect(),c=Pd(r,s);return{x:c.x+o,y:c.y+d}}}),[])};function Vw(e,r){const s=[],l=new Map,o=[];for(const d of e)if(d.type==="add"){o.push(d);continue}else if(d.type==="remove"||d.type==="replace")l.set(d.id,[d]);else{const c=l.get(d.id);c?c.push(d):l.set(d.id,[d])}for(const d of r){const c=l.get(d.id);if(!c){s.push(d);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){s.push({...c[0].item});continue}const h={...d};for(const m of c)OO(m,h);s.push(h)}return o.length&&o.forEach(d=>{d.index!==void 0?s.splice(d.index,0,{...d.item}):s.push({...d.item})}),s}function OO(e,r){switch(e.type){case"select":{r.selected=e.selected;break}case"position":{typeof e.position<"u"&&(r.position=e.position),typeof e.dragging<"u"&&(r.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(r.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(r.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(r.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(r.resizing=e.resizing);break}}}function Yw(e,r){return Vw(e,r)}function Gw(e,r){return Vw(e,r)}function Ja(e,r){return{id:e,type:"select",selected:r}}function Xl(e,r=new Set,s=!1){const l=[];for(const[o,d]of e){const c=r.has(o);!(d.selected===void 0&&!c)&&d.selected!==c&&(s&&(d.selected=c),l.push(Ja(d.id,c)))}return l}function yv({items:e=[],lookup:r}){const s=[],l=new Map(e.map(o=>[o.id,o]));for(const[o,d]of e.entries()){const c=r.get(d.id),h=c?.internals?.userNode??c;h!==void 0&&h!==d&&s.push({id:d.id,item:d,type:"replace"}),h===void 0&&s.push({item:d,type:"add",index:o})}for(const[o]of r)l.get(o)===void 0&&s.push({id:o,type:"remove"});return s}function vv(e){return{id:e.id,type:"remove"}}const jv=e=>rD(e),RO=e=>xw(e);function Xw(e){return v.forwardRef(e)}const LO=typeof window<"u"?v.useLayoutEffect:v.useEffect;function wv(e){const[r,s]=v.useState(BigInt(0)),[l]=v.useState(()=>zO(()=>s(o=>o+BigInt(1))));return LO(()=>{const o=l.get();o.length&&(e(o),l.reset())},[r]),l}function zO(e){let r=[];return{get:()=>r,reset:()=>{r=[]},push:s=>{r.push(s),e()}}}const Zw=v.createContext(null);function IO({children:e}){const r=Cn(),s=v.useCallback(h=>{const{nodes:m=[],setNodes:f,hasDefaultNodes:x,onNodesChange:g,nodeLookup:p,fitViewQueued:y,onNodesChangeMiddlewareMap:w}=r.getState();let N=m;for(const A of h)N=typeof A=="function"?A(N):A;let E=yv({items:N,lookup:p});for(const A of w.values())E=A(E);x&&f(N),E.length>0?g?.(E):y&&window.requestAnimationFrame(()=>{const{fitViewQueued:A,nodes:C,setNodes:k}=r.getState();A&&k(C)})},[]),l=wv(s),o=v.useCallback(h=>{const{edges:m=[],setEdges:f,hasDefaultEdges:x,onEdgesChange:g,edgeLookup:p}=r.getState();let y=m;for(const w of h)y=typeof w=="function"?w(y):w;x?f(y):g&&g(yv({items:y,lookup:p}))},[]),d=wv(o),c=v.useMemo(()=>({nodeQueue:l,edgeQueue:d}),[]);return t.jsx(Zw.Provider,{value:c,children:e})}function $O(){const e=v.useContext(Zw);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const BO=e=>!!e.panZoom;function Cx(){const e=DO(),r=Cn(),s=$O(),l=Vt(BO),o=v.useMemo(()=>{const d=g=>r.getState().nodeLookup.get(g),c=g=>{s.nodeQueue.push(g)},h=g=>{s.edgeQueue.push(g)},m=g=>{const{nodeLookup:p,nodeOrigin:y}=r.getState(),w=jv(g)?g:p.get(g.id),N=w.parentId?jw(w.position,w.measured,w.parentId,p,y):w.position,E={...w,position:N,width:w.measured?.width??w.width,height:w.measured?.height??w.height};return si(E)},f=(g,p,y={replace:!1})=>{c(w=>w.map(N=>{if(N.id===g){const E=typeof p=="function"?p(N):p;return y.replace&&jv(E)?E:{...N,...E}}return N}))},x=(g,p,y={replace:!1})=>{h(w=>w.map(N=>{if(N.id===g){const E=typeof p=="function"?p(N):p;return y.replace&&RO(E)?E:{...N,...E}}return N}))};return{getNodes:()=>r.getState().nodes.map(g=>({...g})),getNode:g=>d(g)?.internals.userNode,getInternalNode:d,getEdges:()=>{const{edges:g=[]}=r.getState();return g.map(p=>({...p}))},getEdge:g=>r.getState().edgeLookup.get(g),setNodes:c,setEdges:h,addNodes:g=>{const p=Array.isArray(g)?g:[g];s.nodeQueue.push(y=>[...y,...p])},addEdges:g=>{const p=Array.isArray(g)?g:[g];s.edgeQueue.push(y=>[...y,...p])},toObject:()=>{const{nodes:g=[],edges:p=[],transform:y}=r.getState(),[w,N,E]=y;return{nodes:g.map(A=>({...A})),edges:p.map(A=>({...A})),viewport:{x:w,y:N,zoom:E}}},deleteElements:async({nodes:g=[],edges:p=[]})=>{const{nodes:y,edges:w,onNodesDelete:N,onEdgesDelete:E,triggerNodeChanges:A,triggerEdgeChanges:C,onDelete:k,onBeforeDelete:S}=r.getState(),{nodes:O,edges:R}=await oD({nodesToRemove:g,edgesToRemove:p,nodes:y,edges:w,onBeforeDelete:S}),G=R.length>0,I=O.length>0;if(G){const Q=R.map(vv);E?.(R),C(Q)}if(I){const Q=O.map(vv);N?.(O),A(Q)}return(I||G)&&k?.({nodes:O,edges:R}),{deletedNodes:O,deletedEdges:R}},getIntersectingNodes:(g,p=!0,y)=>{const w=Gy(g),N=w?g:m(g),E=y!==void 0;return N?(y||r.getState().nodes).filter(A=>{const C=r.getState().nodeLookup.get(A.id);if(C&&!w&&(A.id===g.id||!C.internals.positionAbsolute))return!1;const k=si(E?A:C),S=Ao(k,N);return p&&S>0||S>=k.width*k.height||S>=N.width*N.height}):[]},isNodeIntersecting:(g,p,y=!0)=>{const N=Gy(g)?g:m(g);if(!N)return!1;const E=Ao(N,p);return y&&E>0||E>=p.width*p.height||E>=N.width*N.height},updateNode:f,updateNodeData:(g,p,y={replace:!1})=>{f(g,w=>{const N=typeof p=="function"?p(w):p;return y.replace?{...w,data:N}:{...w,data:{...w.data,...N}}},y)},updateEdge:x,updateEdgeData:(g,p,y={replace:!1})=>{x(g,w=>{const N=typeof p=="function"?p(w):p;return y.replace?{...w,data:N}:{...w,data:{...w.data,...N}}},y)},getNodesBounds:g=>{const{nodeLookup:p,nodeOrigin:y}=r.getState();return sD(g,{nodeLookup:p,nodeOrigin:y})},getHandleConnections:({type:g,id:p,nodeId:y})=>Array.from(r.getState().connectionLookup.get(`${y}-${g}${p?`-${p}`:""}`)?.values()??[]),getNodeConnections:({type:g,handleId:p,nodeId:y})=>Array.from(r.getState().connectionLookup.get(`${y}${g?p?`-${g}-${p}`:`-${g}`:""}`)?.values()??[]),fitView:async g=>{const p=r.getState().fitViewResolver??fD();return r.setState({fitViewQueued:!0,fitViewOptions:g,fitViewResolver:p}),s.nodeQueue.push(y=>[...y]),p.promise}}},[]);return v.useMemo(()=>({...o,...e,viewportInitialized:l}),[l])}const Nv=e=>e.selected,HO=typeof window<"u"?window:void 0;function PO({deleteKeyCode:e,multiSelectionKeyCode:r}){const s=Cn(),{deleteElements:l}=Cx(),o=Mo(e,{actInsideInputWithModifier:!1}),d=Mo(r,{target:HO});v.useEffect(()=>{if(o){const{edges:c,nodes:h}=s.getState();l({nodes:h.filter(Nv),edges:c.filter(Nv)}),s.setState({nodesSelectionActive:!1})}},[o]),v.useEffect(()=>{s.setState({multiSelectionActive:d})},[d])}function UO(e){const r=Cn();v.useEffect(()=>{const s=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const l=vx(e.current);(l.height===0||l.width===0)&&r.getState().onError?.("004",ws.error004()),r.setState({width:l.width||500,height:l.height||500})};if(e.current){s(),window.addEventListener("resize",s);const l=new ResizeObserver(()=>s());return l.observe(e.current),()=>{window.removeEventListener("resize",s),l&&e.current&&l.unobserve(e.current)}}},[])}const du={position:"absolute",width:"100%",height:"100%",top:0,left:0},qO=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function FO({onPaneContextMenu:e,zoomOnScroll:r=!0,zoomOnPinch:s=!0,panOnScroll:l=!1,panOnScrollSpeed:o=.5,panOnScrollMode:d=nl.Free,zoomOnDoubleClick:c=!0,panOnDrag:h=!0,defaultViewport:m,translateExtent:f,minZoom:x,maxZoom:g,zoomActivationKeyCode:p,preventScrolling:y=!0,children:w,noWheelClassName:N,noPanClassName:E,onViewportChange:A,isControlledViewport:C,paneClickDistance:k,selectionOnDrag:S}){const O=Cn(),R=v.useRef(null),{userSelectionActive:G,lib:I,connectionInProgress:Q}=Vt(qO,Sn),$=Mo(p),F=v.useRef();UO(R);const B=v.useCallback(T=>{A?.({x:T[0],y:T[1],zoom:T[2]}),C||O.setState({transform:T})},[A,C]);return v.useEffect(()=>{if(R.current){F.current=ZD({domNode:R.current,minZoom:x,maxZoom:g,translateExtent:f,viewport:m,onDraggingChange:_=>O.setState(Y=>Y.paneDragging===_?Y:{paneDragging:_}),onPanZoomStart:(_,Y)=>{const{onViewportChangeStart:V,onMoveStart:J}=O.getState();J?.(_,Y),V?.(Y)},onPanZoom:(_,Y)=>{const{onViewportChange:V,onMove:J}=O.getState();J?.(_,Y),V?.(Y)},onPanZoomEnd:(_,Y)=>{const{onViewportChangeEnd:V,onMoveEnd:J}=O.getState();J?.(_,Y),V?.(Y)}});const{x:T,y:D,zoom:z}=F.current.getViewport();return O.setState({panZoom:F.current,transform:[T,D,z],domNode:R.current.closest(".react-flow")}),()=>{F.current?.destroy()}}},[]),v.useEffect(()=>{F.current?.update({onPaneContextMenu:e,zoomOnScroll:r,zoomOnPinch:s,panOnScroll:l,panOnScrollSpeed:o,panOnScrollMode:d,zoomOnDoubleClick:c,panOnDrag:h,zoomActivationKeyPressed:$,preventScrolling:y,noPanClassName:E,userSelectionActive:G,noWheelClassName:N,lib:I,onTransformChange:B,connectionInProgress:Q,selectionOnDrag:S,paneClickDistance:k})},[e,r,s,l,o,d,c,h,$,y,E,G,N,I,B,Q,S,k]),t.jsx("div",{className:"react-flow__renderer",ref:R,style:du,children:w})}const VO=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function YO(){const{userSelectionActive:e,userSelectionRect:r}=Vt(VO,Sn);return e&&r?t.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}const Jh=(e,r)=>s=>{s.target===r.current&&e?.(s)},GO=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function XO({isSelecting:e,selectionKeyPressed:r,selectionMode:s=To.Full,panOnDrag:l,paneClickDistance:o,selectionOnDrag:d,onSelectionStart:c,onSelectionEnd:h,onPaneClick:m,onPaneContextMenu:f,onPaneScroll:x,onPaneMouseEnter:g,onPaneMouseMove:p,onPaneMouseLeave:y,children:w}){const N=Cn(),{userSelectionActive:E,elementsSelectable:A,dragging:C,connectionInProgress:k}=Vt(GO,Sn),S=A&&(e||E),O=v.useRef(null),R=v.useRef(),G=v.useRef(new Set),I=v.useRef(new Set),Q=v.useRef(!1),$=V=>{if(Q.current||k){Q.current=!1;return}m?.(V),N.getState().resetSelectedElements(),N.setState({nodesSelectionActive:!1})},F=V=>{if(Array.isArray(l)&&l?.includes(2)){V.preventDefault();return}f?.(V)},B=x?V=>x(V):void 0,T=V=>{Q.current&&(V.stopPropagation(),Q.current=!1)},D=V=>{const{domNode:J}=N.getState();if(R.current=J?.getBoundingClientRect(),!R.current)return;const U=V.target===O.current;if(!U&&!!V.target.closest(".nokey")||!e||!(d&&U||r)||V.button!==0||!V.isPrimary)return;V.target?.setPointerCapture?.(V.pointerId),Q.current=!1;const{x:L,y:M}=ss(V.nativeEvent,R.current);N.setState({userSelectionRect:{width:0,height:0,startX:L,startY:M,x:L,y:M}}),U||(V.stopPropagation(),V.preventDefault())},z=V=>{const{userSelectionRect:J,transform:U,nodeLookup:H,edgeLookup:X,connectionLookup:L,triggerNodeChanges:M,triggerEdgeChanges:q,defaultEdgeOptions:K,resetSelectedElements:ee}=N.getState();if(!R.current||!J)return;const{x:te,y:se}=ss(V.nativeEvent,R.current),{startX:xe,startY:ke}=J;if(!Q.current){const ze=r?0:o;if(Math.hypot(te-xe,se-ke)<=ze)return;ee(),c?.(V)}Q.current=!0;const De={startX:xe,startY:ke,x:te<xe?te:xe,y:se<ke?se:ke,width:Math.abs(te-xe),height:Math.abs(se-ke)},ge=G.current,ye=I.current;G.current=new Set(bx(H,De,U,s===To.Partial,!0).map(ze=>ze.id)),I.current=new Set;const Ce=K?.selectable??!0;for(const ze of G.current){const tt=L.get(ze);if(tt)for(const{edgeId:Xe}of tt.values()){const dt=X.get(Xe);dt&&(dt.selectable??Ce)&&I.current.add(Xe)}}if(!Xy(ge,G.current)){const ze=Xl(H,G.current,!0);M(ze)}if(!Xy(ye,I.current)){const ze=Xl(X,I.current);q(ze)}N.setState({userSelectionRect:De,userSelectionActive:!0,nodesSelectionActive:!1})},_=V=>{V.button===0&&(V.target?.releasePointerCapture?.(V.pointerId),!E&&V.target===O.current&&N.getState().userSelectionRect&&$?.(V),N.setState({userSelectionActive:!1,userSelectionRect:null}),Q.current&&(h?.(V),N.setState({nodesSelectionActive:G.current.size>0})))},Y=l===!0||Array.isArray(l)&&l.includes(0);return t.jsxs("div",{className:Fn(["react-flow__pane",{draggable:Y,dragging:C,selection:e}]),onClick:S?void 0:Jh($,O),onContextMenu:Jh(F,O),onWheel:Jh(B,O),onPointerEnter:S?void 0:g,onPointerMove:S?z:p,onPointerUp:S?_:void 0,onPointerDownCapture:S?D:void 0,onClickCapture:S?T:void 0,onPointerLeave:y,ref:O,style:du,children:[w,t.jsx(YO,{})]})}function zm({id:e,store:r,unselect:s=!1,nodeRef:l}){const{addSelectedNodes:o,unselectNodesAndEdges:d,multiSelectionActive:c,nodeLookup:h,onError:m}=r.getState(),f=h.get(e);if(!f){m?.("012",ws.error012(e));return}r.setState({nodesSelectionActive:!1}),f.selected?(s||f.selected&&c)&&(d({nodes:[f],edges:[]}),requestAnimationFrame(()=>l?.current?.blur())):o([e])}function Qw({nodeRef:e,disabled:r=!1,noDragClassName:s,handleSelector:l,nodeId:o,isSelectable:d,nodeClickDistance:c}){const h=Cn(),[m,f]=v.useState(!1),x=v.useRef();return v.useEffect(()=>{x.current=LD({getStoreItems:()=>h.getState(),onNodeMouseDown:g=>{zm({id:g,store:h,nodeRef:e})},onDragStart:()=>{f(!0)},onDragStop:()=>{f(!1)}})},[]),v.useEffect(()=>{if(!(r||!e.current||!x.current))return x.current.update({noDragClassName:s,handleSelector:l,domNode:e.current,isSelectable:d,nodeId:o,nodeClickDistance:c}),()=>{x.current?.destroy()}},[s,l,r,d,e,o,c]),m}const ZO=e=>r=>r.selected&&(r.draggable||e&&typeof r.draggable>"u");function Kw(){const e=Cn();return v.useCallback(s=>{const{nodeExtent:l,snapToGrid:o,snapGrid:d,nodesDraggable:c,onError:h,updateNodePositions:m,nodeLookup:f,nodeOrigin:x}=e.getState(),g=new Map,p=ZO(c),y=o?d[0]:5,w=o?d[1]:5,N=s.direction.x*y*s.factor,E=s.direction.y*w*s.factor;for(const[,A]of f){if(!p(A))continue;let C={x:A.internals.positionAbsolute.x+N,y:A.internals.positionAbsolute.y+E};o&&(C=Uo(C,d));const{position:k,positionAbsolute:S}=gw({nodeId:A.id,nextPosition:C,nodeLookup:f,nodeExtent:l,nodeOrigin:x,onError:h});A.position=k,A.internals.positionAbsolute=S,g.set(A.id,A)}m(g)},[])}const Ex=v.createContext(null),QO=Ex.Provider;Ex.Consumer;const Jw=()=>v.useContext(Ex),KO=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),JO=(e,r,s)=>l=>{const{connectionClickStartHandle:o,connectionMode:d,connection:c}=l,{fromHandle:h,toHandle:m,isValid:f}=c,x=m?.nodeId===e&&m?.id===r&&m?.type===s;return{connectingFrom:h?.nodeId===e&&h?.id===r&&h?.type===s,connectingTo:x,clickConnecting:o?.nodeId===e&&o?.id===r&&o?.type===s,isPossibleEndHandle:d===ti.Strict?h?.type!==s:e!==h?.nodeId||r!==h?.id,connectionInProcess:!!h,clickConnectionInProcess:!!o,valid:x&&f}};function WO({type:e="source",position:r=lt.Top,isValidConnection:s,isConnectable:l=!0,isConnectableStart:o=!0,isConnectableEnd:d=!0,id:c,onConnect:h,children:m,className:f,onMouseDown:x,onTouchStart:g,...p},y){const w=c||null,N=e==="target",E=Cn(),A=Jw(),{connectOnClick:C,noPanClassName:k,rfId:S}=Vt(KO,Sn),{connectingFrom:O,connectingTo:R,clickConnecting:G,isPossibleEndHandle:I,connectionInProcess:Q,clickConnectionInProcess:$,valid:F}=Vt(JO(A,w,e),Sn);A||E.getState().onError?.("010",ws.error010());const B=z=>{const{defaultEdgeOptions:_,onConnect:Y,hasDefaultEdges:V}=E.getState(),J={..._,...z};if(V){const{edges:U,setEdges:H}=E.getState();H(yD(J,U))}Y?.(J),h?.(J)},T=z=>{if(!A)return;const _=kw(z.nativeEvent);if(o&&(_&&z.button===0||!_)){const Y=E.getState();Lm.onPointerDown(z.nativeEvent,{handleDomNode:z.currentTarget,autoPanOnConnect:Y.autoPanOnConnect,connectionMode:Y.connectionMode,connectionRadius:Y.connectionRadius,domNode:Y.domNode,nodeLookup:Y.nodeLookup,lib:Y.lib,isTarget:N,handleId:w,nodeId:A,flowId:Y.rfId,panBy:Y.panBy,cancelConnection:Y.cancelConnection,onConnectStart:Y.onConnectStart,onConnectEnd:(...V)=>E.getState().onConnectEnd?.(...V),updateConnection:Y.updateConnection,onConnect:B,isValidConnection:s||((...V)=>E.getState().isValidConnection?.(...V)??!0),getTransform:()=>E.getState().transform,getFromHandle:()=>E.getState().connection.fromHandle,autoPanSpeed:Y.autoPanSpeed,dragThreshold:Y.connectionDragThreshold})}_?x?.(z):g?.(z)},D=z=>{const{onClickConnectStart:_,onClickConnectEnd:Y,connectionClickStartHandle:V,connectionMode:J,isValidConnection:U,lib:H,rfId:X,nodeLookup:L,connection:M}=E.getState();if(!A||!V&&!o)return;if(!V){_?.(z.nativeEvent,{nodeId:A,handleId:w,handleType:e}),E.setState({connectionClickStartHandle:{nodeId:A,type:e,id:w}});return}const q=ww(z.target),K=s||U,{connection:ee,isValid:te}=Lm.isValid(z.nativeEvent,{handle:{nodeId:A,id:w,type:e},connectionMode:J,fromNodeId:V.nodeId,fromHandleId:V.id||null,fromType:V.type,isValidConnection:K,flowId:X,doc:q,lib:H,nodeLookup:L});te&&ee&&B(ee);const se=structuredClone(M);delete se.inProgress,se.toPosition=se.toHandle?se.toHandle.position:null,Y?.(z,se),E.setState({connectionClickStartHandle:null})};return t.jsx("div",{"data-handleid":w,"data-nodeid":A,"data-handlepos":r,"data-id":`${S}-${A}-${w}-${e}`,className:Fn(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",k,f,{source:!N,target:N,connectable:l,connectablestart:o,connectableend:d,clickconnecting:G,connectingfrom:O,connectingto:R,valid:F,connectionindicator:l&&(!Q||I)&&(Q||$?d:o)}]),onMouseDown:T,onTouchStart:T,onClick:C?D:void 0,ref:y,...p,children:m})}const Ma=v.memo(Xw(WO));function eR({data:e,isConnectable:r,sourcePosition:s=lt.Bottom}){return t.jsxs(t.Fragment,{children:[e?.label,t.jsx(Ma,{type:"source",position:s,isConnectable:r})]})}function tR({data:e,isConnectable:r,targetPosition:s=lt.Top,sourcePosition:l=lt.Bottom}){return t.jsxs(t.Fragment,{children:[t.jsx(Ma,{type:"target",position:s,isConnectable:r}),e?.label,t.jsx(Ma,{type:"source",position:l,isConnectable:r})]})}function nR(){return null}function rR({data:e,isConnectable:r,targetPosition:s=lt.Top}){return t.jsxs(t.Fragment,{children:[t.jsx(Ma,{type:"target",position:s,isConnectable:r}),e?.label]})}const Ud={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},kv={input:eR,default:tR,output:rR,group:nR};function sR(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 aR=e=>{const{width:r,height:s,x:l,y:o}=Po(e.nodeLookup,{filter:d=>!!d.selected});return{width:rs(r)?r:null,height:rs(s)?s:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${l}px,${o}px)`}};function lR({onSelectionContextMenu:e,noPanClassName:r,disableKeyboardA11y:s}){const l=Cn(),{width:o,height:d,transformString:c,userSelectionActive:h}=Vt(aR,Sn),m=Kw(),f=v.useRef(null);v.useEffect(()=>{s||f.current?.focus({preventScroll:!0})},[s]);const x=!h&&o!==null&&d!==null;if(Qw({nodeRef:f,disabled:!x}),!x)return null;const g=e?y=>{const w=l.getState().nodes.filter(N=>N.selected);e(y,w)}:void 0,p=y=>{Object.prototype.hasOwnProperty.call(Ud,y.key)&&(y.preventDefault(),m({direction:Ud[y.key],factor:y.shiftKey?4:1}))};return t.jsx("div",{className:Fn(["react-flow__nodesselection","react-flow__container",r]),style:{transform:c},children:t.jsx("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:g,tabIndex:s?void 0:-1,onKeyDown:s?void 0:p,style:{width:o,height:d}})})}const Sv=typeof window<"u"?window:void 0,iR=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Ww({children:e,onPaneClick:r,onPaneMouseEnter:s,onPaneMouseMove:l,onPaneMouseLeave:o,onPaneContextMenu:d,onPaneScroll:c,paneClickDistance:h,deleteKeyCode:m,selectionKeyCode:f,selectionOnDrag:x,selectionMode:g,onSelectionStart:p,onSelectionEnd:y,multiSelectionKeyCode:w,panActivationKeyCode:N,zoomActivationKeyCode:E,elementsSelectable:A,zoomOnScroll:C,zoomOnPinch:k,panOnScroll:S,panOnScrollSpeed:O,panOnScrollMode:R,zoomOnDoubleClick:G,panOnDrag:I,defaultViewport:Q,translateExtent:$,minZoom:F,maxZoom:B,preventScrolling:T,onSelectionContextMenu:D,noWheelClassName:z,noPanClassName:_,disableKeyboardA11y:Y,onViewportChange:V,isControlledViewport:J}){const{nodesSelectionActive:U,userSelectionActive:H}=Vt(iR,Sn),X=Mo(f,{target:Sv}),L=Mo(N,{target:Sv}),M=L||I,q=L||S,K=x&&M!==!0,ee=X||H||K;return PO({deleteKeyCode:m,multiSelectionKeyCode:w}),t.jsx(FO,{onPaneContextMenu:d,elementsSelectable:A,zoomOnScroll:C,zoomOnPinch:k,panOnScroll:q,panOnScrollSpeed:O,panOnScrollMode:R,zoomOnDoubleClick:G,panOnDrag:!X&&M,defaultViewport:Q,translateExtent:$,minZoom:F,maxZoom:B,zoomActivationKeyCode:E,preventScrolling:T,noWheelClassName:z,noPanClassName:_,onViewportChange:V,isControlledViewport:J,paneClickDistance:h,selectionOnDrag:K,children:t.jsxs(XO,{onSelectionStart:p,onSelectionEnd:y,onPaneClick:r,onPaneMouseEnter:s,onPaneMouseMove:l,onPaneMouseLeave:o,onPaneContextMenu:d,onPaneScroll:c,panOnDrag:M,isSelecting:!!ee,selectionMode:g,selectionKeyPressed:X,paneClickDistance:h,selectionOnDrag:K,children:[e,U&&t.jsx(lR,{onSelectionContextMenu:D,noPanClassName:_,disableKeyboardA11y:Y})]})})}Ww.displayName="FlowRenderer";const oR=v.memo(Ww),cR=e=>r=>e?bx(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(s=>s.id):Array.from(r.nodeLookup.keys());function dR(e){return Vt(v.useCallback(cR(e),[e]),Sn)}const uR=e=>e.updateNodeInternals;function fR(){const e=Vt(uR),[r]=v.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(s=>{const l=new Map;s.forEach(o=>{const d=o.target.getAttribute("data-id");l.set(d,{id:d,nodeElement:o.target,force:!0})}),e(l)}));return v.useEffect(()=>()=>{r?.disconnect()},[r]),r}function hR({node:e,nodeType:r,hasDimensions:s,resizeObserver:l}){const o=Cn(),d=v.useRef(null),c=v.useRef(null),h=v.useRef(e.sourcePosition),m=v.useRef(e.targetPosition),f=v.useRef(r),x=s&&!!e.internals.handleBounds;return v.useEffect(()=>{d.current&&!e.hidden&&(!x||c.current!==d.current)&&(c.current&&l?.unobserve(c.current),l?.observe(d.current),c.current=d.current)},[x,e.hidden]),v.useEffect(()=>()=>{c.current&&(l?.unobserve(c.current),c.current=null)},[]),v.useEffect(()=>{if(d.current){const g=f.current!==r,p=h.current!==e.sourcePosition,y=m.current!==e.targetPosition;(g||p||y)&&(f.current=r,h.current=e.sourcePosition,m.current=e.targetPosition,o.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:d.current,force:!0}]])))}},[e.id,r,e.sourcePosition,e.targetPosition]),d}function mR({id:e,onClick:r,onMouseEnter:s,onMouseMove:l,onMouseLeave:o,onContextMenu:d,onDoubleClick:c,nodesDraggable:h,elementsSelectable:m,nodesConnectable:f,nodesFocusable:x,resizeObserver:g,noDragClassName:p,noPanClassName:y,disableKeyboardA11y:w,rfId:N,nodeTypes:E,nodeClickDistance:A,onError:C}){const{node:k,internals:S,isParent:O}=Vt(te=>{const se=te.nodeLookup.get(e),xe=te.parentLookup.has(e);return{node:se,internals:se.internals,isParent:xe}},Sn);let R=k.type||"default",G=E?.[R]||kv[R];G===void 0&&(C?.("003",ws.error003(R)),R="default",G=E?.default||kv.default);const I=!!(k.draggable||h&&typeof k.draggable>"u"),Q=!!(k.selectable||m&&typeof k.selectable>"u"),$=!!(k.connectable||f&&typeof k.connectable>"u"),F=!!(k.focusable||x&&typeof k.focusable>"u"),B=Cn(),T=vw(k),D=hR({node:k,nodeType:R,hasDimensions:T,resizeObserver:g}),z=Qw({nodeRef:D,disabled:k.hidden||!I,noDragClassName:p,handleSelector:k.dragHandle,nodeId:e,isSelectable:Q,nodeClickDistance:A}),_=Kw();if(k.hidden)return null;const Y=Ks(k),V=sR(k),J=Q||I||r||s||l||o,U=s?te=>s(te,{...S.userNode}):void 0,H=l?te=>l(te,{...S.userNode}):void 0,X=o?te=>o(te,{...S.userNode}):void 0,L=d?te=>d(te,{...S.userNode}):void 0,M=c?te=>c(te,{...S.userNode}):void 0,q=te=>{const{selectNodesOnDrag:se,nodeDragThreshold:xe}=B.getState();Q&&(!se||!I||xe>0)&&zm({id:e,store:B,nodeRef:D}),r&&r(te,{...S.userNode})},K=te=>{if(!(Nw(te.nativeEvent)||w)){if(uw.includes(te.key)&&Q){const se=te.key==="Escape";zm({id:e,store:B,unselect:se,nodeRef:D})}else if(I&&k.selected&&Object.prototype.hasOwnProperty.call(Ud,te.key)){te.preventDefault();const{ariaLabelConfig:se}=B.getState();B.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:te.key.replace("Arrow","").toLowerCase(),x:~~S.positionAbsolute.x,y:~~S.positionAbsolute.y})}),_({direction:Ud[te.key],factor:te.shiftKey?4:1})}}},ee=()=>{if(w||!D.current?.matches(":focus-visible"))return;const{transform:te,width:se,height:xe,autoPanOnNodeFocus:ke,setCenter:De}=B.getState();if(!ke)return;bx(new Map([[e,k]]),{x:0,y:0,width:se,height:xe},te,!0).length>0||De(k.position.x+Y.width/2,k.position.y+Y.height/2,{zoom:te[2]})};return t.jsx("div",{className:Fn(["react-flow__node",`react-flow__node-${R}`,{[y]:I},k.className,{selected:k.selected,selectable:Q,parent:O,draggable:I,dragging:z}]),ref:D,style:{zIndex:S.z,transform:`translate(${S.positionAbsolute.x}px,${S.positionAbsolute.y}px)`,pointerEvents:J?"all":"none",visibility:T?"visible":"hidden",...k.style,...V},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:U,onMouseMove:H,onMouseLeave:X,onContextMenu:L,onClick:q,onDoubleClick:M,onKeyDown:F?K:void 0,tabIndex:F?0:void 0,onFocus:F?ee:void 0,role:k.ariaRole??(F?"group":void 0),"aria-roledescription":"node","aria-describedby":w?void 0:`${Uw}-${N}`,"aria-label":k.ariaLabel,...k.domAttributes,children:t.jsx(QO,{value:e,children:t.jsx(G,{id:e,data:k.data,type:R,positionAbsoluteX:S.positionAbsolute.x,positionAbsoluteY:S.positionAbsolute.y,selected:k.selected??!1,selectable:Q,draggable:I,deletable:k.deletable??!0,isConnectable:$,sourcePosition:k.sourcePosition,targetPosition:k.targetPosition,dragging:z,dragHandle:k.dragHandle,zIndex:S.z,parentId:k.parentId,...Y})})})}var xR=v.memo(mR);const gR=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function eN(e){const{nodesDraggable:r,nodesConnectable:s,nodesFocusable:l,elementsSelectable:o,onError:d}=Vt(gR,Sn),c=dR(e.onlyRenderVisibleElements),h=fR();return t.jsx("div",{className:"react-flow__nodes",style:du,children:c.map(m=>t.jsx(xR,{id:m,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:h,nodesDraggable:r,nodesConnectable:s,nodesFocusable:l,elementsSelectable:o,nodeClickDistance:e.nodeClickDistance,onError:d},m))})}eN.displayName="NodeRenderer";const pR=v.memo(eN);function bR(e){return Vt(v.useCallback(s=>{if(!e)return s.edges.map(o=>o.id);const l=[];if(s.width&&s.height)for(const o of s.edges){const d=s.nodeLookup.get(o.source),c=s.nodeLookup.get(o.target);d&&c&&gD({sourceNode:d,targetNode:c,width:s.width,height:s.height,transform:s.transform})&&l.push(o.id)}return l},[e]),Sn)}const yR=({color:e="none",strokeWidth:r=1})=>{const s={strokeWidth:r,...e&&{stroke:e}};return t.jsx("polyline",{className:"arrow",style:s,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},vR=({color:e="none",strokeWidth:r=1})=>{const s={strokeWidth:r,...e&&{stroke:e,fill:e}};return t.jsx("polyline",{className:"arrowclosed",style:s,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Cv={[ni.Arrow]:yR,[ni.ArrowClosed]:vR};function jR(e){const r=Cn();return v.useMemo(()=>Object.prototype.hasOwnProperty.call(Cv,e)?Cv[e]:(r.getState().onError?.("009",ws.error009(e)),null),[e])}const wR=({id:e,type:r,color:s,width:l=12.5,height:o=12.5,markerUnits:d="strokeWidth",strokeWidth:c,orient:h="auto-start-reverse"})=>{const m=jR(r);return m?t.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${l}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:d,orient:h,refX:"0",refY:"0",children:t.jsx(m,{color:s,strokeWidth:c})}):null},tN=({defaultColor:e,rfId:r})=>{const s=Vt(d=>d.edges),l=Vt(d=>d.defaultEdgeOptions),o=v.useMemo(()=>kD(s,{id:r,defaultColor:e,defaultMarkerStart:l?.markerStart,defaultMarkerEnd:l?.markerEnd}),[s,l,r,e]);return o.length?t.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:t.jsx("defs",{children:o.map(d=>t.jsx(wR,{id:d.id,type:d.type,color:d.color,width:d.width,height:d.height,markerUnits:d.markerUnits,strokeWidth:d.strokeWidth,orient:d.orient},d.id))})}):null};tN.displayName="MarkerDefinitions";var NR=v.memo(tN);function nN({x:e,y:r,label:s,labelStyle:l,labelShowBg:o=!0,labelBgStyle:d,labelBgPadding:c=[2,4],labelBgBorderRadius:h=2,children:m,className:f,...x}){const[g,p]=v.useState({x:1,y:0,width:0,height:0}),y=Fn(["react-flow__edge-textwrapper",f]),w=v.useRef(null);return v.useEffect(()=>{if(w.current){const N=w.current.getBBox();p({x:N.x,y:N.y,width:N.width,height:N.height})}},[s]),s?t.jsxs("g",{transform:`translate(${e-g.width/2} ${r-g.height/2})`,className:y,visibility:g.width?"visible":"hidden",...x,children:[o&&t.jsx("rect",{width:g.width+2*c[0],x:-c[0],y:-c[1],height:g.height+2*c[1],className:"react-flow__edge-textbg",style:d,rx:h,ry:h}),t.jsx("text",{className:"react-flow__edge-text",y:g.height/2,dy:"0.3em",ref:w,style:l,children:s}),m]}):null}nN.displayName="EdgeText";const kR=v.memo(nN);function uu({path:e,labelX:r,labelY:s,label:l,labelStyle:o,labelShowBg:d,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:m,interactionWidth:f=20,...x}){return t.jsxs(t.Fragment,{children:[t.jsx("path",{...x,d:e,fill:"none",className:Fn(["react-flow__edge-path",x.className])}),f?t.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:f,className:"react-flow__edge-interaction"}):null,l&&rs(r)&&rs(s)?t.jsx(kR,{x:r,y:s,label:l,labelStyle:o,labelShowBg:d,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:m}):null]})}function Ev({pos:e,x1:r,y1:s,x2:l,y2:o}){return e===lt.Left||e===lt.Right?[.5*(r+l),s]:[r,.5*(s+o)]}function rN({sourceX:e,sourceY:r,sourcePosition:s=lt.Bottom,targetX:l,targetY:o,targetPosition:d=lt.Top}){const[c,h]=Ev({pos:s,x1:e,y1:r,x2:l,y2:o}),[m,f]=Ev({pos:d,x1:l,y1:o,x2:e,y2:r}),[x,g,p,y]=Sw({sourceX:e,sourceY:r,targetX:l,targetY:o,sourceControlX:c,sourceControlY:h,targetControlX:m,targetControlY:f});return[`M${e},${r} C${c},${h} ${m},${f} ${l},${o}`,x,g,p,y]}function sN(e){return v.memo(({id:r,sourceX:s,sourceY:l,targetX:o,targetY:d,sourcePosition:c,targetPosition:h,label:m,labelStyle:f,labelShowBg:x,labelBgStyle:g,labelBgPadding:p,labelBgBorderRadius:y,style:w,markerEnd:N,markerStart:E,interactionWidth:A})=>{const[C,k,S]=rN({sourceX:s,sourceY:l,sourcePosition:c,targetX:o,targetY:d,targetPosition:h}),O=e.isInternal?void 0:r;return t.jsx(uu,{id:O,path:C,labelX:k,labelY:S,label:m,labelStyle:f,labelShowBg:x,labelBgStyle:g,labelBgPadding:p,labelBgBorderRadius:y,style:w,markerEnd:N,markerStart:E,interactionWidth:A})})}const SR=sN({isInternal:!1}),aN=sN({isInternal:!0});SR.displayName="SimpleBezierEdge";aN.displayName="SimpleBezierEdgeInternal";function lN(e){return v.memo(({id:r,sourceX:s,sourceY:l,targetX:o,targetY:d,label:c,labelStyle:h,labelShowBg:m,labelBgStyle:f,labelBgPadding:x,labelBgBorderRadius:g,style:p,sourcePosition:y=lt.Bottom,targetPosition:w=lt.Top,markerEnd:N,markerStart:E,pathOptions:A,interactionWidth:C})=>{const[k,S,O]=Dm({sourceX:s,sourceY:l,sourcePosition:y,targetX:o,targetY:d,targetPosition:w,borderRadius:A?.borderRadius,offset:A?.offset,stepPosition:A?.stepPosition}),R=e.isInternal?void 0:r;return t.jsx(uu,{id:R,path:k,labelX:S,labelY:O,label:c,labelStyle:h,labelShowBg:m,labelBgStyle:f,labelBgPadding:x,labelBgBorderRadius:g,style:p,markerEnd:N,markerStart:E,interactionWidth:C})})}const iN=lN({isInternal:!1}),oN=lN({isInternal:!0});iN.displayName="SmoothStepEdge";oN.displayName="SmoothStepEdgeInternal";function cN(e){return v.memo(({id:r,...s})=>{const l=e.isInternal?void 0:r;return t.jsx(iN,{...s,id:l,pathOptions:v.useMemo(()=>({borderRadius:0,offset:s.pathOptions?.offset}),[s.pathOptions?.offset])})})}const CR=cN({isInternal:!1}),dN=cN({isInternal:!0});CR.displayName="StepEdge";dN.displayName="StepEdgeInternal";function uN(e){return v.memo(({id:r,sourceX:s,sourceY:l,targetX:o,targetY:d,label:c,labelStyle:h,labelShowBg:m,labelBgStyle:f,labelBgPadding:x,labelBgBorderRadius:g,style:p,markerEnd:y,markerStart:w,interactionWidth:N})=>{const[E,A,C]=Tw({sourceX:s,sourceY:l,targetX:o,targetY:d}),k=e.isInternal?void 0:r;return t.jsx(uu,{id:k,path:E,labelX:A,labelY:C,label:c,labelStyle:h,labelShowBg:m,labelBgStyle:f,labelBgPadding:x,labelBgBorderRadius:g,style:p,markerEnd:y,markerStart:w,interactionWidth:N})})}const ER=uN({isInternal:!1}),fN=uN({isInternal:!0});ER.displayName="StraightEdge";fN.displayName="StraightEdgeInternal";function hN(e){return v.memo(({id:r,sourceX:s,sourceY:l,targetX:o,targetY:d,sourcePosition:c=lt.Bottom,targetPosition:h=lt.Top,label:m,labelStyle:f,labelShowBg:x,labelBgStyle:g,labelBgPadding:p,labelBgBorderRadius:y,style:w,markerEnd:N,markerStart:E,pathOptions:A,interactionWidth:C})=>{const[k,S,O]=Cw({sourceX:s,sourceY:l,sourcePosition:c,targetX:o,targetY:d,targetPosition:h,curvature:A?.curvature}),R=e.isInternal?void 0:r;return t.jsx(uu,{id:R,path:k,labelX:S,labelY:O,label:m,labelStyle:f,labelShowBg:x,labelBgStyle:g,labelBgPadding:p,labelBgBorderRadius:y,style:w,markerEnd:N,markerStart:E,interactionWidth:C})})}const TR=hN({isInternal:!1}),mN=hN({isInternal:!0});TR.displayName="BezierEdge";mN.displayName="BezierEdgeInternal";const Tv={default:mN,straight:fN,step:dN,smoothstep:oN,simplebezier:aN},Av={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},AR=(e,r,s)=>s===lt.Left?e-r:s===lt.Right?e+r:e,_R=(e,r,s)=>s===lt.Top?e-r:s===lt.Bottom?e+r:e,_v="react-flow__edgeupdater";function Mv({position:e,centerX:r,centerY:s,radius:l=10,onMouseDown:o,onMouseEnter:d,onMouseOut:c,type:h}){return t.jsx("circle",{onMouseDown:o,onMouseEnter:d,onMouseOut:c,className:Fn([_v,`${_v}-${h}`]),cx:AR(r,l,e),cy:_R(s,l,e),r:l,stroke:"transparent",fill:"transparent"})}function MR({isReconnectable:e,reconnectRadius:r,edge:s,sourceX:l,sourceY:o,targetX:d,targetY:c,sourcePosition:h,targetPosition:m,onReconnect:f,onReconnectStart:x,onReconnectEnd:g,setReconnecting:p,setUpdateHover:y}){const w=Cn(),N=(S,O)=>{if(S.button!==0)return;const{autoPanOnConnect:R,domNode:G,connectionMode:I,connectionRadius:Q,lib:$,onConnectStart:F,cancelConnection:B,nodeLookup:T,rfId:D,panBy:z,updateConnection:_}=w.getState(),Y=O.type==="target",V=(H,X)=>{p(!1),g?.(H,s,O.type,X)},J=H=>f?.(s,H),U=(H,X)=>{p(!0),x?.(S,s,O.type),F?.(H,X)};Lm.onPointerDown(S.nativeEvent,{autoPanOnConnect:R,connectionMode:I,connectionRadius:Q,domNode:G,handleId:O.id,nodeId:O.nodeId,nodeLookup:T,isTarget:Y,edgeUpdaterType:O.type,lib:$,flowId:D,cancelConnection:B,panBy:z,isValidConnection:(...H)=>w.getState().isValidConnection?.(...H)??!0,onConnect:J,onConnectStart:U,onConnectEnd:(...H)=>w.getState().onConnectEnd?.(...H),onReconnectEnd:V,updateConnection:_,getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,dragThreshold:w.getState().connectionDragThreshold,handleDomNode:S.currentTarget})},E=S=>N(S,{nodeId:s.target,id:s.targetHandle??null,type:"target"}),A=S=>N(S,{nodeId:s.source,id:s.sourceHandle??null,type:"source"}),C=()=>y(!0),k=()=>y(!1);return t.jsxs(t.Fragment,{children:[(e===!0||e==="source")&&t.jsx(Mv,{position:h,centerX:l,centerY:o,radius:r,onMouseDown:E,onMouseEnter:C,onMouseOut:k,type:"source"}),(e===!0||e==="target")&&t.jsx(Mv,{position:m,centerX:d,centerY:c,radius:r,onMouseDown:A,onMouseEnter:C,onMouseOut:k,type:"target"})]})}function DR({id:e,edgesFocusable:r,edgesReconnectable:s,elementsSelectable:l,onClick:o,onDoubleClick:d,onContextMenu:c,onMouseEnter:h,onMouseMove:m,onMouseLeave:f,reconnectRadius:x,onReconnect:g,onReconnectStart:p,onReconnectEnd:y,rfId:w,edgeTypes:N,noPanClassName:E,onError:A,disableKeyboardA11y:C}){let k=Vt(De=>De.edgeLookup.get(e));const S=Vt(De=>De.defaultEdgeOptions);k=S?{...S,...k}:k;let O=k.type||"default",R=N?.[O]||Tv[O];R===void 0&&(A?.("011",ws.error011(O)),O="default",R=N?.default||Tv.default);const G=!!(k.focusable||r&&typeof k.focusable>"u"),I=typeof g<"u"&&(k.reconnectable||s&&typeof k.reconnectable>"u"),Q=!!(k.selectable||l&&typeof k.selectable>"u"),$=v.useRef(null),[F,B]=v.useState(!1),[T,D]=v.useState(!1),z=Cn(),{zIndex:_,sourceX:Y,sourceY:V,targetX:J,targetY:U,sourcePosition:H,targetPosition:X}=Vt(v.useCallback(De=>{const ge=De.nodeLookup.get(k.source),ye=De.nodeLookup.get(k.target);if(!ge||!ye)return{zIndex:k.zIndex,...Av};const Ce=ND({id:e,sourceNode:ge,targetNode:ye,sourceHandle:k.sourceHandle||null,targetHandle:k.targetHandle||null,connectionMode:De.connectionMode,onError:A});return{zIndex:xD({selected:k.selected,zIndex:k.zIndex,sourceNode:ge,targetNode:ye,elevateOnSelect:De.elevateEdgesOnSelect,zIndexMode:De.zIndexMode}),...Ce||Av}},[k.source,k.target,k.sourceHandle,k.targetHandle,k.selected,k.zIndex]),Sn),L=v.useMemo(()=>k.markerStart?`url('#${Om(k.markerStart,w)}')`:void 0,[k.markerStart,w]),M=v.useMemo(()=>k.markerEnd?`url('#${Om(k.markerEnd,w)}')`:void 0,[k.markerEnd,w]);if(k.hidden||Y===null||V===null||J===null||U===null)return null;const q=De=>{const{addSelectedEdges:ge,unselectNodesAndEdges:ye,multiSelectionActive:Ce}=z.getState();Q&&(z.setState({nodesSelectionActive:!1}),k.selected&&Ce?(ye({nodes:[],edges:[k]}),$.current?.blur()):ge([e])),o&&o(De,k)},K=d?De=>{d(De,{...k})}:void 0,ee=c?De=>{c(De,{...k})}:void 0,te=h?De=>{h(De,{...k})}:void 0,se=m?De=>{m(De,{...k})}:void 0,xe=f?De=>{f(De,{...k})}:void 0,ke=De=>{if(!C&&uw.includes(De.key)&&Q){const{unselectNodesAndEdges:ge,addSelectedEdges:ye}=z.getState();De.key==="Escape"?($.current?.blur(),ge({edges:[k]})):ye([e])}};return t.jsx("svg",{style:{zIndex:_},children:t.jsxs("g",{className:Fn(["react-flow__edge",`react-flow__edge-${O}`,k.className,E,{selected:k.selected,animated:k.animated,inactive:!Q&&!o,updating:F,selectable:Q}]),onClick:q,onDoubleClick:K,onContextMenu:ee,onMouseEnter:te,onMouseMove:se,onMouseLeave:xe,onKeyDown:G?ke:void 0,tabIndex:G?0:void 0,role:k.ariaRole??(G?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":k.ariaLabel===null?void 0:k.ariaLabel||`Edge from ${k.source} to ${k.target}`,"aria-describedby":G?`${qw}-${w}`:void 0,ref:$,...k.domAttributes,children:[!T&&t.jsx(R,{id:e,source:k.source,target:k.target,type:k.type,selected:k.selected,animated:k.animated,selectable:Q,deletable:k.deletable??!0,label:k.label,labelStyle:k.labelStyle,labelShowBg:k.labelShowBg,labelBgStyle:k.labelBgStyle,labelBgPadding:k.labelBgPadding,labelBgBorderRadius:k.labelBgBorderRadius,sourceX:Y,sourceY:V,targetX:J,targetY:U,sourcePosition:H,targetPosition:X,data:k.data,style:k.style,sourceHandleId:k.sourceHandle,targetHandleId:k.targetHandle,markerStart:L,markerEnd:M,pathOptions:"pathOptions"in k?k.pathOptions:void 0,interactionWidth:k.interactionWidth}),I&&t.jsx(MR,{edge:k,isReconnectable:I,reconnectRadius:x,onReconnect:g,onReconnectStart:p,onReconnectEnd:y,sourceX:Y,sourceY:V,targetX:J,targetY:U,sourcePosition:H,targetPosition:X,setUpdateHover:B,setReconnecting:D})]})})}var OR=v.memo(DR);const RR=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function xN({defaultMarkerColor:e,onlyRenderVisibleElements:r,rfId:s,edgeTypes:l,noPanClassName:o,onReconnect:d,onEdgeContextMenu:c,onEdgeMouseEnter:h,onEdgeMouseMove:m,onEdgeMouseLeave:f,onEdgeClick:x,reconnectRadius:g,onEdgeDoubleClick:p,onReconnectStart:y,onReconnectEnd:w,disableKeyboardA11y:N}){const{edgesFocusable:E,edgesReconnectable:A,elementsSelectable:C,onError:k}=Vt(RR,Sn),S=bR(r);return t.jsxs("div",{className:"react-flow__edges",children:[t.jsx(NR,{defaultColor:e,rfId:s}),S.map(O=>t.jsx(OR,{id:O,edgesFocusable:E,edgesReconnectable:A,elementsSelectable:C,noPanClassName:o,onReconnect:d,onContextMenu:c,onMouseEnter:h,onMouseMove:m,onMouseLeave:f,onClick:x,reconnectRadius:g,onDoubleClick:p,onReconnectStart:y,onReconnectEnd:w,rfId:s,onError:k,edgeTypes:l,disableKeyboardA11y:N},O))]})}xN.displayName="EdgeRenderer";const LR=v.memo(xN),zR=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function IR({children:e}){const r=Vt(zR);return t.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:r},children:e})}function $R(e){const r=Cx(),s=v.useRef(!1);v.useEffect(()=>{!s.current&&r.viewportInitialized&&e&&(setTimeout(()=>e(r),1),s.current=!0)},[e,r.viewportInitialized])}const BR=e=>e.panZoom?.syncViewport;function HR(e){const r=Vt(BR),s=Cn();return v.useEffect(()=>{e&&(r?.(e),s.setState({transform:[e.x,e.y,e.zoom]}))},[e,r]),null}function PR(e){return e.connection.inProgress?{...e.connection,to:qo(e.connection.to,e.transform)}:{...e.connection}}function UR(e){return PR}function qR(e){const r=UR();return Vt(r,Sn)}const FR=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function VR({containerStyle:e,style:r,type:s,component:l}){const{nodesConnectable:o,width:d,height:c,isValid:h,inProgress:m}=Vt(FR,Sn);return!(d&&o&&m)?null:t.jsx("svg",{style:e,width:d,height:c,className:"react-flow__connectionline react-flow__container",children:t.jsx("g",{className:Fn(["react-flow__connection",mw(h)]),children:t.jsx(gN,{style:r,type:s,CustomComponent:l,isValid:h})})})}const gN=({style:e,type:r=Aa.Bezier,CustomComponent:s,isValid:l})=>{const{inProgress:o,from:d,fromNode:c,fromHandle:h,fromPosition:m,to:f,toNode:x,toHandle:g,toPosition:p,pointer:y}=qR();if(!o)return;if(s)return t.jsx(s,{connectionLineType:r,connectionLineStyle:e,fromNode:c,fromHandle:h,fromX:d.x,fromY:d.y,toX:f.x,toY:f.y,fromPosition:m,toPosition:p,connectionStatus:mw(l),toNode:x,toHandle:g,pointer:y});let w="";const N={sourceX:d.x,sourceY:d.y,sourcePosition:m,targetX:f.x,targetY:f.y,targetPosition:p};switch(r){case Aa.Bezier:[w]=Cw(N);break;case Aa.SimpleBezier:[w]=rN(N);break;case Aa.Step:[w]=Dm({...N,borderRadius:0});break;case Aa.SmoothStep:[w]=Dm(N);break;default:[w]=Tw(N)}return t.jsx("path",{d:w,fill:"none",className:"react-flow__connection-path",style:e})};gN.displayName="ConnectionLine";const YR={};function Dv(e=YR){v.useRef(e),Cn(),v.useEffect(()=>{},[e])}function GR(){Cn(),v.useRef(!1),v.useEffect(()=>{},[])}function pN({nodeTypes:e,edgeTypes:r,onInit:s,onNodeClick:l,onEdgeClick:o,onNodeDoubleClick:d,onEdgeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:m,onNodeMouseLeave:f,onNodeContextMenu:x,onSelectionContextMenu:g,onSelectionStart:p,onSelectionEnd:y,connectionLineType:w,connectionLineStyle:N,connectionLineComponent:E,connectionLineContainerStyle:A,selectionKeyCode:C,selectionOnDrag:k,selectionMode:S,multiSelectionKeyCode:O,panActivationKeyCode:R,zoomActivationKeyCode:G,deleteKeyCode:I,onlyRenderVisibleElements:Q,elementsSelectable:$,defaultViewport:F,translateExtent:B,minZoom:T,maxZoom:D,preventScrolling:z,defaultMarkerColor:_,zoomOnScroll:Y,zoomOnPinch:V,panOnScroll:J,panOnScrollSpeed:U,panOnScrollMode:H,zoomOnDoubleClick:X,panOnDrag:L,onPaneClick:M,onPaneMouseEnter:q,onPaneMouseMove:K,onPaneMouseLeave:ee,onPaneScroll:te,onPaneContextMenu:se,paneClickDistance:xe,nodeClickDistance:ke,onEdgeContextMenu:De,onEdgeMouseEnter:ge,onEdgeMouseMove:ye,onEdgeMouseLeave:Ce,reconnectRadius:ze,onReconnect:tt,onReconnectStart:Xe,onReconnectEnd:dt,noDragClassName:wt,noWheelClassName:ae,noPanClassName:Te,disableKeyboardA11y:Ze,nodeExtent:xt,rfId:dn,viewport:we,onViewportChange:Re}){return Dv(e),Dv(r),GR(),$R(s),HR(we),t.jsx(oR,{onPaneClick:M,onPaneMouseEnter:q,onPaneMouseMove:K,onPaneMouseLeave:ee,onPaneContextMenu:se,onPaneScroll:te,paneClickDistance:xe,deleteKeyCode:I,selectionKeyCode:C,selectionOnDrag:k,selectionMode:S,onSelectionStart:p,onSelectionEnd:y,multiSelectionKeyCode:O,panActivationKeyCode:R,zoomActivationKeyCode:G,elementsSelectable:$,zoomOnScroll:Y,zoomOnPinch:V,zoomOnDoubleClick:X,panOnScroll:J,panOnScrollSpeed:U,panOnScrollMode:H,panOnDrag:L,defaultViewport:F,translateExtent:B,minZoom:T,maxZoom:D,onSelectionContextMenu:g,preventScrolling:z,noDragClassName:wt,noWheelClassName:ae,noPanClassName:Te,disableKeyboardA11y:Ze,onViewportChange:Re,isControlledViewport:!!we,children:t.jsxs(IR,{children:[t.jsx(LR,{edgeTypes:r,onEdgeClick:o,onEdgeDoubleClick:c,onReconnect:tt,onReconnectStart:Xe,onReconnectEnd:dt,onlyRenderVisibleElements:Q,onEdgeContextMenu:De,onEdgeMouseEnter:ge,onEdgeMouseMove:ye,onEdgeMouseLeave:Ce,reconnectRadius:ze,defaultMarkerColor:_,noPanClassName:Te,disableKeyboardA11y:Ze,rfId:dn}),t.jsx(VR,{style:N,type:w,component:E,containerStyle:A}),t.jsx("div",{className:"react-flow__edgelabel-renderer"}),t.jsx(pR,{nodeTypes:e,onNodeClick:l,onNodeDoubleClick:d,onNodeMouseEnter:h,onNodeMouseMove:m,onNodeMouseLeave:f,onNodeContextMenu:x,nodeClickDistance:ke,onlyRenderVisibleElements:Q,noPanClassName:Te,noDragClassName:wt,disableKeyboardA11y:Ze,nodeExtent:xt,rfId:dn}),t.jsx("div",{className:"react-flow__viewport-portal"})]})})}pN.displayName="GraphView";const XR=v.memo(pN),Ov=({nodes:e,edges:r,defaultNodes:s,defaultEdges:l,width:o,height:d,fitView:c,fitViewOptions:h,minZoom:m=.5,maxZoom:f=2,nodeOrigin:x,nodeExtent:g,zIndexMode:p="basic"}={})=>{const y=new Map,w=new Map,N=new Map,E=new Map,A=l??r??[],C=s??e??[],k=x??[0,0],S=g??Eo;Mw(N,E,A);const O=Rm(C,y,w,{nodeOrigin:k,nodeExtent:S,zIndexMode:p});let R=[0,0,1];if(c&&o&&d){const G=Po(y,{filter:F=>!!((F.width||F.initialWidth)&&(F.height||F.initialHeight))}),{x:I,y:Q,zoom:$}=yx(G,o,d,m,f,h?.padding??.1);R=[I,Q,$]}return{rfId:"1",width:o??0,height:d??0,transform:R,nodes:C,nodesInitialized:O,nodeLookup:y,parentLookup:w,edges:A,edgeLookup:E,connectionLookup:N,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:s!==void 0,hasDefaultEdges:l!==void 0,panZoom:null,minZoom:m,maxZoom:f,translateExtent:Eo,nodeExtent:S,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:ti.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:k,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:h,fitViewResolver:null,connection:{...hw},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:cD,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:fw,zIndexMode:p,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},ZR=({nodes:e,edges:r,defaultNodes:s,defaultEdges:l,width:o,height:d,fitView:c,fitViewOptions:h,minZoom:m,maxZoom:f,nodeOrigin:x,nodeExtent:g,zIndexMode:p})=>hO((y,w)=>{async function N(){const{nodeLookup:E,panZoom:A,fitViewOptions:C,fitViewResolver:k,width:S,height:O,minZoom:R,maxZoom:G}=w();A&&(await iD({nodes:E,width:S,height:O,panZoom:A,minZoom:R,maxZoom:G},C),k?.resolve(!0),y({fitViewResolver:null}))}return{...Ov({nodes:e,edges:r,width:o,height:d,fitView:c,fitViewOptions:h,minZoom:m,maxZoom:f,nodeOrigin:x,nodeExtent:g,defaultNodes:s,defaultEdges:l,zIndexMode:p}),setNodes:E=>{const{nodeLookup:A,parentLookup:C,nodeOrigin:k,elevateNodesOnSelect:S,fitViewQueued:O,zIndexMode:R}=w(),G=Rm(E,A,C,{nodeOrigin:k,nodeExtent:g,elevateNodesOnSelect:S,checkEquality:!0,zIndexMode:R});O&&G?(N(),y({nodes:E,nodesInitialized:G,fitViewQueued:!1,fitViewOptions:void 0})):y({nodes:E,nodesInitialized:G})},setEdges:E=>{const{connectionLookup:A,edgeLookup:C}=w();Mw(A,C,E),y({edges:E})},setDefaultNodesAndEdges:(E,A)=>{if(E){const{setNodes:C}=w();C(E),y({hasDefaultNodes:!0})}if(A){const{setEdges:C}=w();C(A),y({hasDefaultEdges:!0})}},updateNodeInternals:E=>{const{triggerNodeChanges:A,nodeLookup:C,parentLookup:k,domNode:S,nodeOrigin:O,nodeExtent:R,debug:G,fitViewQueued:I,zIndexMode:Q}=w(),{changes:$,updatedInternals:F}=MD(E,C,k,S,O,R,Q);F&&(ED(C,k,{nodeOrigin:O,nodeExtent:R,zIndexMode:Q}),I?(N(),y({fitViewQueued:!1,fitViewOptions:void 0})):y({}),$?.length>0&&(G&&console.log("React Flow: trigger node changes",$),A?.($)))},updateNodePositions:(E,A=!1)=>{const C=[];let k=[];const{nodeLookup:S,triggerNodeChanges:O,connection:R,updateConnection:G,onNodesChangeMiddlewareMap:I}=w();for(const[Q,$]of E){const F=S.get(Q),B=!!(F?.expandParent&&F?.parentId&&$?.position),T={id:Q,type:"position",position:B?{x:Math.max(0,$.position.x),y:Math.max(0,$.position.y)}:$.position,dragging:A};if(F&&R.inProgress&&R.fromNode.id===F.id){const D=ol(F,R.fromHandle,lt.Left,!0);G({...R,from:D})}B&&F.parentId&&C.push({id:Q,parentId:F.parentId,rect:{...$.internals.positionAbsolute,width:$.measured.width??0,height:$.measured.height??0}}),k.push(T)}if(C.length>0){const{parentLookup:Q,nodeOrigin:$}=w(),F=Sx(C,S,Q,$);k.push(...F)}for(const Q of I.values())k=Q(k);O(k)},triggerNodeChanges:E=>{const{onNodesChange:A,setNodes:C,nodes:k,hasDefaultNodes:S,debug:O}=w();if(E?.length){if(S){const R=Yw(E,k);C(R)}O&&console.log("React Flow: trigger node changes",E),A?.(E)}},triggerEdgeChanges:E=>{const{onEdgesChange:A,setEdges:C,edges:k,hasDefaultEdges:S,debug:O}=w();if(E?.length){if(S){const R=Gw(E,k);C(R)}O&&console.log("React Flow: trigger edge changes",E),A?.(E)}},addSelectedNodes:E=>{const{multiSelectionActive:A,edgeLookup:C,nodeLookup:k,triggerNodeChanges:S,triggerEdgeChanges:O}=w();if(A){const R=E.map(G=>Ja(G,!0));S(R);return}S(Xl(k,new Set([...E]),!0)),O(Xl(C))},addSelectedEdges:E=>{const{multiSelectionActive:A,edgeLookup:C,nodeLookup:k,triggerNodeChanges:S,triggerEdgeChanges:O}=w();if(A){const R=E.map(G=>Ja(G,!0));O(R);return}O(Xl(C,new Set([...E]))),S(Xl(k,new Set,!0))},unselectNodesAndEdges:({nodes:E,edges:A}={})=>{const{edges:C,nodes:k,nodeLookup:S,triggerNodeChanges:O,triggerEdgeChanges:R}=w(),G=E||k,I=A||C,Q=[];for(const F of G){if(!F.selected)continue;const B=S.get(F.id);B&&(B.selected=!1),Q.push(Ja(F.id,!1))}const $=[];for(const F of I)F.selected&&$.push(Ja(F.id,!1));O(Q),R($)},setMinZoom:E=>{const{panZoom:A,maxZoom:C}=w();A?.setScaleExtent([E,C]),y({minZoom:E})},setMaxZoom:E=>{const{panZoom:A,minZoom:C}=w();A?.setScaleExtent([C,E]),y({maxZoom:E})},setTranslateExtent:E=>{w().panZoom?.setTranslateExtent(E),y({translateExtent:E})},resetSelectedElements:()=>{const{edges:E,nodes:A,triggerNodeChanges:C,triggerEdgeChanges:k,elementsSelectable:S}=w();if(!S)return;const O=A.reduce((G,I)=>I.selected?[...G,Ja(I.id,!1)]:G,[]),R=E.reduce((G,I)=>I.selected?[...G,Ja(I.id,!1)]:G,[]);C(O),k(R)},setNodeExtent:E=>{const{nodes:A,nodeLookup:C,parentLookup:k,nodeOrigin:S,elevateNodesOnSelect:O,nodeExtent:R,zIndexMode:G}=w();E[0][0]===R[0][0]&&E[0][1]===R[0][1]&&E[1][0]===R[1][0]&&E[1][1]===R[1][1]||(Rm(A,C,k,{nodeOrigin:S,nodeExtent:E,elevateNodesOnSelect:O,checkEquality:!1,zIndexMode:G}),y({nodeExtent:E}))},panBy:E=>{const{transform:A,width:C,height:k,panZoom:S,translateExtent:O}=w();return DD({delta:E,panZoom:S,transform:A,translateExtent:O,width:C,height:k})},setCenter:async(E,A,C)=>{const{width:k,height:S,maxZoom:O,panZoom:R}=w();if(!R)return Promise.resolve(!1);const G=typeof C?.zoom<"u"?C.zoom:O;return await R.setViewport({x:k/2-E*G,y:S/2-A*G,zoom:G},{duration:C?.duration,ease:C?.ease,interpolate:C?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{y({connection:{...hw}})},updateConnection:E=>{y({connection:E})},reset:()=>y({...Ov()})}},Object.is);function QR({initialNodes:e,initialEdges:r,defaultNodes:s,defaultEdges:l,initialWidth:o,initialHeight:d,initialMinZoom:c,initialMaxZoom:h,initialFitViewOptions:m,fitView:f,nodeOrigin:x,nodeExtent:g,zIndexMode:p,children:y}){const[w]=v.useState(()=>ZR({nodes:e,edges:r,defaultNodes:s,defaultEdges:l,width:o,height:d,fitView:f,minZoom:c,maxZoom:h,fitViewOptions:m,nodeOrigin:x,nodeExtent:g,zIndexMode:p}));return t.jsx(mO,{value:w,children:t.jsx(IO,{children:y})})}function KR({children:e,nodes:r,edges:s,defaultNodes:l,defaultEdges:o,width:d,height:c,fitView:h,fitViewOptions:m,minZoom:f,maxZoom:x,nodeOrigin:g,nodeExtent:p,zIndexMode:y}){return v.useContext(ou)?t.jsx(t.Fragment,{children:e}):t.jsx(QR,{initialNodes:r,initialEdges:s,defaultNodes:l,defaultEdges:o,initialWidth:d,initialHeight:c,fitView:h,initialFitViewOptions:m,initialMinZoom:f,initialMaxZoom:x,nodeOrigin:g,nodeExtent:p,zIndexMode:y,children:e})}const JR={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function WR({nodes:e,edges:r,defaultNodes:s,defaultEdges:l,className:o,nodeTypes:d,edgeTypes:c,onNodeClick:h,onEdgeClick:m,onInit:f,onMove:x,onMoveStart:g,onMoveEnd:p,onConnect:y,onConnectStart:w,onConnectEnd:N,onClickConnectStart:E,onClickConnectEnd:A,onNodeMouseEnter:C,onNodeMouseMove:k,onNodeMouseLeave:S,onNodeContextMenu:O,onNodeDoubleClick:R,onNodeDragStart:G,onNodeDrag:I,onNodeDragStop:Q,onNodesDelete:$,onEdgesDelete:F,onDelete:B,onSelectionChange:T,onSelectionDragStart:D,onSelectionDrag:z,onSelectionDragStop:_,onSelectionContextMenu:Y,onSelectionStart:V,onSelectionEnd:J,onBeforeDelete:U,connectionMode:H,connectionLineType:X=Aa.Bezier,connectionLineStyle:L,connectionLineComponent:M,connectionLineContainerStyle:q,deleteKeyCode:K="Backspace",selectionKeyCode:ee="Shift",selectionOnDrag:te=!1,selectionMode:se=To.Full,panActivationKeyCode:xe="Space",multiSelectionKeyCode:ke=_o()?"Meta":"Control",zoomActivationKeyCode:De=_o()?"Meta":"Control",snapToGrid:ge,snapGrid:ye,onlyRenderVisibleElements:Ce=!1,selectNodesOnDrag:ze,nodesDraggable:tt,autoPanOnNodeFocus:Xe,nodesConnectable:dt,nodesFocusable:wt,nodeOrigin:ae=Fw,edgesFocusable:Te,edgesReconnectable:Ze,elementsSelectable:xt=!0,defaultViewport:dn=EO,minZoom:we=.5,maxZoom:Re=2,translateExtent:qe=Eo,preventScrolling:et=!0,nodeExtent:nt,defaultMarkerColor:zt="#b1b1b7",zoomOnScroll:Yt=!0,zoomOnPinch:Lt=!0,panOnScroll:Tt=!1,panOnScrollSpeed:qt=.5,panOnScrollMode:yt=nl.Free,zoomOnDoubleClick:sn=!0,panOnDrag:Xt=!0,onPaneClick:je,onPaneMouseEnter:Pe,onPaneMouseMove:vt,onPaneMouseLeave:Nt,onPaneScroll:ut,onPaneContextMenu:Wt,paneClickDistance:en=1,nodeClickDistance:Ct=0,children:de,onReconnect:Be,onReconnectStart:Le,onReconnectEnd:ot,onEdgeContextMenu:Qe,onEdgeDoubleClick:ft,onEdgeMouseEnter:Zt,onEdgeMouseMove:it,onEdgeMouseLeave:gt,reconnectRadius:wn=10,onNodesChange:an,onEdgesChange:Qt,noDragClassName:At="nodrag",noWheelClassName:un="nowheel",noPanClassName:En="nopan",fitView:fe,fitViewOptions:Fe,connectOnClick:kt,attributionPosition:St,proOptions:Tn,defaultEdgeOptions:Qn,elevateNodesOnSelect:hr=!0,elevateEdgesOnSelect:or=!1,disableKeyboardA11y:tr=!1,autoPanOnConnect:cr,autoPanOnNodeDrag:fn,autoPanSpeed:os,connectionRadius:Sr,isValidConnection:nr,onError:rr,style:Cs,id:ie,nodeDragThreshold:Se,connectionDragThreshold:He,viewport:Mt,onViewportChange:Gn,width:On,height:tn,colorMode:Hr="light",debug:Js,onScroll:mr,ariaLabelConfig:dr,zIndexMode:Cr="basic",...Er},An){const Tr=ie||"1",cs=MO(Hr),Kr=v.useCallback(ne=>{ne.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),mr?.(ne)},[mr]);return t.jsx("div",{"data-testid":"rf__wrapper",...Er,onScroll:Kr,style:{...Cs,...JR},ref:An,className:Fn(["react-flow",o,cs]),id:ie,role:"application",children:t.jsxs(KR,{nodes:e,edges:r,width:On,height:tn,fitView:fe,fitViewOptions:Fe,minZoom:we,maxZoom:Re,nodeOrigin:ae,nodeExtent:nt,zIndexMode:Cr,children:[t.jsx(XR,{onInit:f,onNodeClick:h,onEdgeClick:m,onNodeMouseEnter:C,onNodeMouseMove:k,onNodeMouseLeave:S,onNodeContextMenu:O,onNodeDoubleClick:R,nodeTypes:d,edgeTypes:c,connectionLineType:X,connectionLineStyle:L,connectionLineComponent:M,connectionLineContainerStyle:q,selectionKeyCode:ee,selectionOnDrag:te,selectionMode:se,deleteKeyCode:K,multiSelectionKeyCode:ke,panActivationKeyCode:xe,zoomActivationKeyCode:De,onlyRenderVisibleElements:Ce,defaultViewport:dn,translateExtent:qe,minZoom:we,maxZoom:Re,preventScrolling:et,zoomOnScroll:Yt,zoomOnPinch:Lt,zoomOnDoubleClick:sn,panOnScroll:Tt,panOnScrollSpeed:qt,panOnScrollMode:yt,panOnDrag:Xt,onPaneClick:je,onPaneMouseEnter:Pe,onPaneMouseMove:vt,onPaneMouseLeave:Nt,onPaneScroll:ut,onPaneContextMenu:Wt,paneClickDistance:en,nodeClickDistance:Ct,onSelectionContextMenu:Y,onSelectionStart:V,onSelectionEnd:J,onReconnect:Be,onReconnectStart:Le,onReconnectEnd:ot,onEdgeContextMenu:Qe,onEdgeDoubleClick:ft,onEdgeMouseEnter:Zt,onEdgeMouseMove:it,onEdgeMouseLeave:gt,reconnectRadius:wn,defaultMarkerColor:zt,noDragClassName:At,noWheelClassName:un,noPanClassName:En,rfId:Tr,disableKeyboardA11y:tr,nodeExtent:nt,viewport:Mt,onViewportChange:Gn}),t.jsx(_O,{nodes:e,edges:r,defaultNodes:s,defaultEdges:l,onConnect:y,onConnectStart:w,onConnectEnd:N,onClickConnectStart:E,onClickConnectEnd:A,nodesDraggable:tt,autoPanOnNodeFocus:Xe,nodesConnectable:dt,nodesFocusable:wt,edgesFocusable:Te,edgesReconnectable:Ze,elementsSelectable:xt,elevateNodesOnSelect:hr,elevateEdgesOnSelect:or,minZoom:we,maxZoom:Re,nodeExtent:nt,onNodesChange:an,onEdgesChange:Qt,snapToGrid:ge,snapGrid:ye,connectionMode:H,translateExtent:qe,connectOnClick:kt,defaultEdgeOptions:Qn,fitView:fe,fitViewOptions:Fe,onNodesDelete:$,onEdgesDelete:F,onDelete:B,onNodeDragStart:G,onNodeDrag:I,onNodeDragStop:Q,onSelectionDrag:z,onSelectionDragStart:D,onSelectionDragStop:_,onMove:x,onMoveStart:g,onMoveEnd:p,noPanClassName:En,nodeOrigin:ae,rfId:Tr,autoPanOnConnect:cr,autoPanOnNodeDrag:fn,autoPanSpeed:os,onError:rr,connectionRadius:Sr,isValidConnection:nr,selectNodesOnDrag:ze,nodeDragThreshold:Se,connectionDragThreshold:He,onBeforeDelete:U,debug:Js,ariaLabelConfig:dr,zIndexMode:Cr}),t.jsx(CO,{onSelectionChange:T}),de,t.jsx(jO,{proOptions:Tn,position:St}),t.jsx(vO,{rfId:Tr,disableKeyboardA11y:tr})]})})}var eL=Xw(WR);function tL(e){const[r,s]=v.useState(e),l=v.useCallback(o=>s(d=>Yw(o,d)),[]);return[r,s,l]}function nL(e){const[r,s]=v.useState(e),l=v.useCallback(o=>s(d=>Gw(o,d)),[]);return[r,s,l]}function rL({dimensions:e,lineWidth:r,variant:s,className:l}){return t.jsx("path",{strokeWidth:r,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Fn(["react-flow__background-pattern",s,l])})}function sL({radius:e,className:r}){return t.jsx("circle",{cx:e,cy:e,r:e,className:Fn(["react-flow__background-pattern","dots",r])})}var _a;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(_a||(_a={}));const aL={[_a.Dots]:1,[_a.Lines]:1,[_a.Cross]:6},lL=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function bN({id:e,variant:r=_a.Dots,gap:s=20,size:l,lineWidth:o=1,offset:d=0,color:c,bgColor:h,style:m,className:f,patternClassName:x}){const g=v.useRef(null),{transform:p,patternId:y}=Vt(lL,Sn),w=l||aL[r],N=r===_a.Dots,E=r===_a.Cross,A=Array.isArray(s)?s:[s,s],C=[A[0]*p[2]||1,A[1]*p[2]||1],k=w*p[2],S=Array.isArray(d)?d:[d,d],O=E?[k,k]:C,R=[S[0]*p[2]||1+O[0]/2,S[1]*p[2]||1+O[1]/2],G=`${y}${e||""}`;return t.jsxs("svg",{className:Fn(["react-flow__background",f]),style:{...m,...du,"--xy-background-color-props":h,"--xy-background-pattern-color-props":c},ref:g,"data-testid":"rf__background",children:[t.jsx("pattern",{id:G,x:p[0]%C[0],y:p[1]%C[1],width:C[0],height:C[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${R[0]},-${R[1]})`,children:N?t.jsx(sL,{radius:k/2,className:x}):t.jsx(rL,{dimensions:O,lineWidth:o,variant:r,className:x})}),t.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${G})`})]})}bN.displayName="Background";const iL=v.memo(bN);function oL(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:t.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function cL(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:t.jsx("path",{d:"M0 0h32v4.2H0z"})})}function dL(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:t.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 uL(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:t.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 fL(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:t.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 ud({children:e,className:r,...s}){return t.jsx("button",{type:"button",className:Fn(["react-flow__controls-button",r]),...s,children:e})}const hL=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function yN({style:e,showZoom:r=!0,showFitView:s=!0,showInteractive:l=!0,fitViewOptions:o,onZoomIn:d,onZoomOut:c,onFitView:h,onInteractiveChange:m,className:f,children:x,position:g="bottom-left",orientation:p="vertical","aria-label":y}){const w=Cn(),{isInteractive:N,minZoomReached:E,maxZoomReached:A,ariaLabelConfig:C}=Vt(hL,Sn),{zoomIn:k,zoomOut:S,fitView:O}=Cx(),R=()=>{k(),d?.()},G=()=>{S(),c?.()},I=()=>{O(o),h?.()},Q=()=>{w.setState({nodesDraggable:!N,nodesConnectable:!N,elementsSelectable:!N}),m?.(!N)},$=p==="horizontal"?"horizontal":"vertical";return t.jsxs(cu,{className:Fn(["react-flow__controls",$,f]),position:g,style:e,"data-testid":"rf__controls","aria-label":y??C["controls.ariaLabel"],children:[r&&t.jsxs(t.Fragment,{children:[t.jsx(ud,{onClick:R,className:"react-flow__controls-zoomin",title:C["controls.zoomIn.ariaLabel"],"aria-label":C["controls.zoomIn.ariaLabel"],disabled:A,children:t.jsx(oL,{})}),t.jsx(ud,{onClick:G,className:"react-flow__controls-zoomout",title:C["controls.zoomOut.ariaLabel"],"aria-label":C["controls.zoomOut.ariaLabel"],disabled:E,children:t.jsx(cL,{})})]}),s&&t.jsx(ud,{className:"react-flow__controls-fitview",onClick:I,title:C["controls.fitView.ariaLabel"],"aria-label":C["controls.fitView.ariaLabel"],children:t.jsx(dL,{})}),l&&t.jsx(ud,{className:"react-flow__controls-interactive",onClick:Q,title:C["controls.interactive.ariaLabel"],"aria-label":C["controls.interactive.ariaLabel"],children:N?t.jsx(fL,{}):t.jsx(uL,{})}),x]})}yN.displayName="Controls";const mL=v.memo(yN);function xL({id:e,x:r,y:s,width:l,height:o,style:d,color:c,strokeColor:h,strokeWidth:m,className:f,borderRadius:x,shapeRendering:g,selected:p,onClick:y}){const{background:w,backgroundColor:N}=d||{},E=c||w||N;return t.jsx("rect",{className:Fn(["react-flow__minimap-node",{selected:p},f]),x:r,y:s,rx:x,ry:x,width:l,height:o,style:{fill:E,stroke:h,strokeWidth:m},shapeRendering:g,onClick:y?A=>y(A,e):void 0})}const gL=v.memo(xL),pL=e=>e.nodes.map(r=>r.id),Wh=e=>e instanceof Function?e:()=>e;function bL({nodeStrokeColor:e,nodeColor:r,nodeClassName:s="",nodeBorderRadius:l=5,nodeStrokeWidth:o,nodeComponent:d=gL,onClick:c}){const h=Vt(pL,Sn),m=Wh(r),f=Wh(e),x=Wh(s),g=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return t.jsx(t.Fragment,{children:h.map(p=>t.jsx(vL,{id:p,nodeColorFunc:m,nodeStrokeColorFunc:f,nodeClassNameFunc:x,nodeBorderRadius:l,nodeStrokeWidth:o,NodeComponent:d,onClick:c,shapeRendering:g},p))})}function yL({id:e,nodeColorFunc:r,nodeStrokeColorFunc:s,nodeClassNameFunc:l,nodeBorderRadius:o,nodeStrokeWidth:d,shapeRendering:c,NodeComponent:h,onClick:m}){const{node:f,x,y:g,width:p,height:y}=Vt(w=>{const N=w.nodeLookup.get(e);if(!N)return{node:void 0,x:0,y:0,width:0,height:0};const E=N.internals.userNode,{x:A,y:C}=N.internals.positionAbsolute,{width:k,height:S}=Ks(E);return{node:E,x:A,y:C,width:k,height:S}},Sn);return!f||f.hidden||!vw(f)?null:t.jsx(h,{x,y:g,width:p,height:y,style:f.style,selected:!!f.selected,className:l(f),color:r(f),borderRadius:o,strokeColor:s(f),strokeWidth:d,shapeRendering:c,onClick:m,id:f.id})}const vL=v.memo(yL);var jL=v.memo(bL);const wL=200,NL=150,kL=e=>!e.hidden,SL=e=>{const r={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:r,boundingRect:e.nodeLookup.size>0?yw(Po(e.nodeLookup,{filter:kL}),r):r,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},CL="react-flow__minimap-desc";function vN({style:e,className:r,nodeStrokeColor:s,nodeColor:l,nodeClassName:o="",nodeBorderRadius:d=5,nodeStrokeWidth:c,nodeComponent:h,bgColor:m,maskColor:f,maskStrokeColor:x,maskStrokeWidth:g,position:p="bottom-right",onClick:y,onNodeClick:w,pannable:N=!1,zoomable:E=!1,ariaLabel:A,inversePan:C,zoomStep:k=1,offsetScale:S=5}){const O=Cn(),R=v.useRef(null),{boundingRect:G,viewBB:I,rfId:Q,panZoom:$,translateExtent:F,flowWidth:B,flowHeight:T,ariaLabelConfig:D}=Vt(SL,Sn),z=e?.width??wL,_=e?.height??NL,Y=G.width/z,V=G.height/_,J=Math.max(Y,V),U=J*z,H=J*_,X=S*J,L=G.x-(U-G.width)/2-X,M=G.y-(H-G.height)/2-X,q=U+X*2,K=H+X*2,ee=`${CL}-${Q}`,te=v.useRef(0),se=v.useRef();te.current=J,v.useEffect(()=>{if(R.current&&$)return se.current=PD({domNode:R.current,panZoom:$,getTransform:()=>O.getState().transform,getViewScale:()=>te.current}),()=>{se.current?.destroy()}},[$]),v.useEffect(()=>{se.current?.update({translateExtent:F,width:B,height:T,inversePan:C,pannable:N,zoomStep:k,zoomable:E})},[N,E,C,k,F,B,T]);const xe=y?ge=>{const[ye,Ce]=se.current?.pointer(ge)||[0,0];y(ge,{x:ye,y:Ce})}:void 0,ke=w?v.useCallback((ge,ye)=>{const Ce=O.getState().nodeLookup.get(ye).internals.userNode;w(ge,Ce)},[]):void 0,De=A??D["minimap.ariaLabel"];return t.jsx(cu,{position:p,style:{...e,"--xy-minimap-background-color-props":typeof m=="string"?m:void 0,"--xy-minimap-mask-background-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-color-props":typeof x=="string"?x:void 0,"--xy-minimap-mask-stroke-width-props":typeof g=="number"?g*J:void 0,"--xy-minimap-node-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-node-stroke-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:Fn(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:t.jsxs("svg",{width:z,height:_,viewBox:`${L} ${M} ${q} ${K}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ee,ref:R,onClick:xe,children:[De&&t.jsx("title",{id:ee,children:De}),t.jsx(jL,{onClick:ke,nodeColor:l,nodeStrokeColor:s,nodeBorderRadius:d,nodeClassName:o,nodeStrokeWidth:c,nodeComponent:h}),t.jsx("path",{className:"react-flow__minimap-mask",d:`M${L-X},${M-X}h${q+X*2}v${K+X*2}h${-q-X*2}z
|
|
61
|
+
M${I.x},${I.y}h${I.width}v${I.height}h${-I.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}vN.displayName="MiniMap";const EL=v.memo(vN),TL=e=>r=>e?`${Math.max(1/r.transform[2],1)}`:void 0,AL={[li.Line]:"right",[li.Handle]:"bottom-right"};function _L({nodeId:e,position:r,variant:s=li.Handle,className:l,style:o=void 0,children:d,color:c,minWidth:h=10,minHeight:m=10,maxWidth:f=Number.MAX_VALUE,maxHeight:x=Number.MAX_VALUE,keepAspectRatio:g=!1,resizeDirection:p,autoScale:y=!0,shouldResize:w,onResizeStart:N,onResize:E,onResizeEnd:A}){const C=Jw(),k=typeof e=="string"?e:C,S=Cn(),O=v.useRef(null),R=s===li.Handle,G=Vt(v.useCallback(TL(R&&y),[R,y]),Sn),I=v.useRef(null),Q=r??AL[s];v.useEffect(()=>{if(!(!O.current||!k))return I.current||(I.current=tO({domNode:O.current,nodeId:k,getStoreItems:()=>{const{nodeLookup:F,transform:B,snapGrid:T,snapToGrid:D,nodeOrigin:z,domNode:_}=S.getState();return{nodeLookup:F,transform:B,snapGrid:T,snapToGrid:D,nodeOrigin:z,paneDomNode:_}},onChange:(F,B)=>{const{triggerNodeChanges:T,nodeLookup:D,parentLookup:z,nodeOrigin:_}=S.getState(),Y=[],V={x:F.x,y:F.y},J=D.get(k);if(J&&J.expandParent&&J.parentId){const U=J.origin??_,H=F.width??J.measured.width??0,X=F.height??J.measured.height??0,L={id:J.id,parentId:J.parentId,rect:{width:H,height:X,...jw({x:F.x??J.position.x,y:F.y??J.position.y},{width:H,height:X},J.parentId,D,U)}},M=Sx([L],D,z,_);Y.push(...M),V.x=F.x?Math.max(U[0]*H,F.x):void 0,V.y=F.y?Math.max(U[1]*X,F.y):void 0}if(V.x!==void 0&&V.y!==void 0){const U={id:k,type:"position",position:{...V}};Y.push(U)}if(F.width!==void 0&&F.height!==void 0){const H={id:k,type:"dimensions",resizing:!0,setAttributes:p?p==="horizontal"?"width":"height":!0,dimensions:{width:F.width,height:F.height}};Y.push(H)}for(const U of B){const H={...U,type:"position"};Y.push(H)}T(Y)},onEnd:({width:F,height:B})=>{const T={id:k,type:"dimensions",resizing:!1,dimensions:{width:F,height:B}};S.getState().triggerNodeChanges([T])}})),I.current.update({controlPosition:Q,boundaries:{minWidth:h,minHeight:m,maxWidth:f,maxHeight:x},keepAspectRatio:g,resizeDirection:p,onResizeStart:N,onResize:E,onResizeEnd:A,shouldResize:w}),()=>{I.current?.destroy()}},[Q,h,m,f,x,g,N,E,A,w]);const $=Q.split("-");return t.jsx("div",{className:Fn(["react-flow__resize-control","nodrag",...$,s,l]),ref:O,style:{...o,scale:G,...c&&{[R?"backgroundColor":"borderColor"]:c}},children:d})}v.memo(_L);var cn=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),ls=cn((e,r)=>{var s=Object.defineProperty,l=(T,D,z)=>D in T?s(T,D,{enumerable:!0,configurable:!0,writable:!0,value:z}):T[D]=z,o=(T,D)=>()=>(D||T((D={exports:{}}).exports,D),D.exports),d=(T,D,z)=>l(T,typeof D!="symbol"?D+"":D,z),c=o((T,D)=>{var z="\0",_="\0",Y="",V=class{constructor(M){d(this,"_isDirected",!0),d(this,"_isMultigraph",!1),d(this,"_isCompound",!1),d(this,"_label"),d(this,"_defaultNodeLabelFn",()=>{}),d(this,"_defaultEdgeLabelFn",()=>{}),d(this,"_nodes",{}),d(this,"_in",{}),d(this,"_preds",{}),d(this,"_out",{}),d(this,"_sucs",{}),d(this,"_edgeObjs",{}),d(this,"_edgeLabels",{}),d(this,"_nodeCount",0),d(this,"_edgeCount",0),d(this,"_parent"),d(this,"_children"),M&&(this._isDirected=Object.hasOwn(M,"directed")?M.directed:!0,this._isMultigraph=Object.hasOwn(M,"multigraph")?M.multigraph:!1,this._isCompound=Object.hasOwn(M,"compound")?M.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[_]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(M){return this._label=M,this}graph(){return this._label}setDefaultNodeLabel(M){return this._defaultNodeLabelFn=M,typeof M!="function"&&(this._defaultNodeLabelFn=()=>M),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var M=this;return this.nodes().filter(q=>Object.keys(M._in[q]).length===0)}sinks(){var M=this;return this.nodes().filter(q=>Object.keys(M._out[q]).length===0)}setNodes(M,q){var K=arguments,ee=this;return M.forEach(function(te){K.length>1?ee.setNode(te,q):ee.setNode(te)}),this}setNode(M,q){return Object.hasOwn(this._nodes,M)?(arguments.length>1&&(this._nodes[M]=q),this):(this._nodes[M]=arguments.length>1?q:this._defaultNodeLabelFn(M),this._isCompound&&(this._parent[M]=_,this._children[M]={},this._children[_][M]=!0),this._in[M]={},this._preds[M]={},this._out[M]={},this._sucs[M]={},++this._nodeCount,this)}node(M){return this._nodes[M]}hasNode(M){return Object.hasOwn(this._nodes,M)}removeNode(M){var q=this;if(Object.hasOwn(this._nodes,M)){var K=ee=>q.removeEdge(q._edgeObjs[ee]);delete this._nodes[M],this._isCompound&&(this._removeFromParentsChildList(M),delete this._parent[M],this.children(M).forEach(function(ee){q.setParent(ee)}),delete this._children[M]),Object.keys(this._in[M]).forEach(K),delete this._in[M],delete this._preds[M],Object.keys(this._out[M]).forEach(K),delete this._out[M],delete this._sucs[M],--this._nodeCount}return this}setParent(M,q){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(q===void 0)q=_;else{q+="";for(var K=q;K!==void 0;K=this.parent(K))if(K===M)throw new Error("Setting "+q+" as parent of "+M+" would create a cycle");this.setNode(q)}return this.setNode(M),this._removeFromParentsChildList(M),this._parent[M]=q,this._children[q][M]=!0,this}_removeFromParentsChildList(M){delete this._children[this._parent[M]][M]}parent(M){if(this._isCompound){var q=this._parent[M];if(q!==_)return q}}children(M=_){if(this._isCompound){var q=this._children[M];if(q)return Object.keys(q)}else{if(M===_)return this.nodes();if(this.hasNode(M))return[]}}predecessors(M){var q=this._preds[M];if(q)return Object.keys(q)}successors(M){var q=this._sucs[M];if(q)return Object.keys(q)}neighbors(M){var q=this.predecessors(M);if(q){let ee=new Set(q);for(var K of this.successors(M))ee.add(K);return Array.from(ee.values())}}isLeaf(M){var q;return this.isDirected()?q=this.successors(M):q=this.neighbors(M),q.length===0}filterNodes(M){var q=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});q.setGraph(this.graph());var K=this;Object.entries(this._nodes).forEach(function([se,xe]){M(se)&&q.setNode(se,xe)}),Object.values(this._edgeObjs).forEach(function(se){q.hasNode(se.v)&&q.hasNode(se.w)&&q.setEdge(se,K.edge(se))});var ee={};function te(se){var xe=K.parent(se);return xe===void 0||q.hasNode(xe)?(ee[se]=xe,xe):xe in ee?ee[xe]:te(xe)}return this._isCompound&&q.nodes().forEach(se=>q.setParent(se,te(se))),q}setDefaultEdgeLabel(M){return this._defaultEdgeLabelFn=M,typeof M!="function"&&(this._defaultEdgeLabelFn=()=>M),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(M,q){var K=this,ee=arguments;return M.reduce(function(te,se){return ee.length>1?K.setEdge(te,se,q):K.setEdge(te,se),se}),this}setEdge(){var M,q,K,ee,te=!1,se=arguments[0];typeof se=="object"&&se!==null&&"v"in se?(M=se.v,q=se.w,K=se.name,arguments.length===2&&(ee=arguments[1],te=!0)):(M=se,q=arguments[1],K=arguments[3],arguments.length>2&&(ee=arguments[2],te=!0)),M=""+M,q=""+q,K!==void 0&&(K=""+K);var xe=H(this._isDirected,M,q,K);if(Object.hasOwn(this._edgeLabels,xe))return te&&(this._edgeLabels[xe]=ee),this;if(K!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(M),this.setNode(q),this._edgeLabels[xe]=te?ee:this._defaultEdgeLabelFn(M,q,K);var ke=X(this._isDirected,M,q,K);return M=ke.v,q=ke.w,Object.freeze(ke),this._edgeObjs[xe]=ke,J(this._preds[q],M),J(this._sucs[M],q),this._in[q][xe]=ke,this._out[M][xe]=ke,this._edgeCount++,this}edge(M,q,K){var ee=arguments.length===1?L(this._isDirected,arguments[0]):H(this._isDirected,M,q,K);return this._edgeLabels[ee]}edgeAsObj(){let M=this.edge(...arguments);return typeof M!="object"?{label:M}:M}hasEdge(M,q,K){var ee=arguments.length===1?L(this._isDirected,arguments[0]):H(this._isDirected,M,q,K);return Object.hasOwn(this._edgeLabels,ee)}removeEdge(M,q,K){var ee=arguments.length===1?L(this._isDirected,arguments[0]):H(this._isDirected,M,q,K),te=this._edgeObjs[ee];return te&&(M=te.v,q=te.w,delete this._edgeLabels[ee],delete this._edgeObjs[ee],U(this._preds[q],M),U(this._sucs[M],q),delete this._in[q][ee],delete this._out[M][ee],this._edgeCount--),this}inEdges(M,q){return this.isDirected()?this.filterEdges(this._in[M],M,q):this.nodeEdges(M,q)}outEdges(M,q){return this.isDirected()?this.filterEdges(this._out[M],M,q):this.nodeEdges(M,q)}nodeEdges(M,q){if(M in this._nodes)return this.filterEdges({...this._in[M],...this._out[M]},M,q)}filterEdges(M,q,K){if(M){var ee=Object.values(M);return K?ee.filter(function(te){return te.v===q&&te.w===K||te.v===K&&te.w===q}):ee}}};function J(M,q){M[q]?M[q]++:M[q]=1}function U(M,q){--M[q]||delete M[q]}function H(M,q,K,ee){var te=""+q,se=""+K;if(!M&&te>se){var xe=te;te=se,se=xe}return te+Y+se+Y+(ee===void 0?z:ee)}function X(M,q,K,ee){var te=""+q,se=""+K;if(!M&&te>se){var xe=te;te=se,se=xe}var ke={v:te,w:se};return ee&&(ke.name=ee),ke}function L(M,q){return H(M,q.v,q.w,q.name)}D.exports=V}),h=o((T,D)=>{D.exports="3.0.2"}),m=o((T,D)=>{D.exports={Graph:c(),version:h()}}),f=o((T,D)=>{var z=c();D.exports={write:_,read:J};function _(U){var H={options:{directed:U.isDirected(),multigraph:U.isMultigraph(),compound:U.isCompound()},nodes:Y(U),edges:V(U)};return U.graph()!==void 0&&(H.value=structuredClone(U.graph())),H}function Y(U){return U.nodes().map(function(H){var X=U.node(H),L=U.parent(H),M={v:H};return X!==void 0&&(M.value=X),L!==void 0&&(M.parent=L),M})}function V(U){return U.edges().map(function(H){var X=U.edge(H),L={v:H.v,w:H.w};return H.name!==void 0&&(L.name=H.name),X!==void 0&&(L.value=X),L})}function J(U){var H=new z(U.options).setGraph(U.value);return U.nodes.forEach(function(X){H.setNode(X.v,X.value),X.parent&&H.setParent(X.v,X.parent)}),U.edges.forEach(function(X){H.setEdge({v:X.v,w:X.w,name:X.name},X.value)}),H}}),x=o((T,D)=>{D.exports=_;var z=()=>1;function _(V,J,U,H){return Y(V,String(J),U||z,H||function(X){return V.outEdges(X)})}function Y(V,J,U,H){var X={},L=!0,M=0,q=V.nodes(),K=function(xe){var ke=U(xe);X[xe.v].distance+ke<X[xe.w].distance&&(X[xe.w]={distance:X[xe.v].distance+ke,predecessor:xe.v},L=!0)},ee=function(){q.forEach(function(xe){H(xe).forEach(function(ke){var De=ke.v===xe?ke.v:ke.w,ge=De===ke.v?ke.w:ke.v;K({v:De,w:ge})})})};q.forEach(function(xe){var ke=xe===J?0:Number.POSITIVE_INFINITY;X[xe]={distance:ke}});for(var te=q.length,se=1;se<te&&(L=!1,M++,ee(),!!L);se++);if(M===te-1&&(L=!1,ee(),L))throw new Error("The graph contains a negative weight cycle");return X}}),g=o((T,D)=>{D.exports=z;function z(_){var Y={},V=[],J;function U(H){Object.hasOwn(Y,H)||(Y[H]=!0,J.push(H),_.successors(H).forEach(U),_.predecessors(H).forEach(U))}return _.nodes().forEach(function(H){J=[],U(H),J.length&&V.push(J)}),V}}),p=o((T,D)=>{var z=class{constructor(){d(this,"_arr",[]),d(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(_){return _.key})}has(_){return Object.hasOwn(this._keyIndices,_)}priority(_){var Y=this._keyIndices[_];if(Y!==void 0)return this._arr[Y].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(_,Y){var V=this._keyIndices;if(_=String(_),!Object.hasOwn(V,_)){var J=this._arr,U=J.length;return V[_]=U,J.push({key:_,priority:Y}),this._decrease(U),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var _=this._arr.pop();return delete this._keyIndices[_.key],this._heapify(0),_.key}decrease(_,Y){var V=this._keyIndices[_];if(Y>this._arr[V].priority)throw new Error("New priority is greater than current priority. Key: "+_+" Old: "+this._arr[V].priority+" New: "+Y);this._arr[V].priority=Y,this._decrease(V)}_heapify(_){var Y=this._arr,V=2*_,J=V+1,U=_;V<Y.length&&(U=Y[V].priority<Y[U].priority?V:U,J<Y.length&&(U=Y[J].priority<Y[U].priority?J:U),U!==_&&(this._swap(_,U),this._heapify(U)))}_decrease(_){for(var Y=this._arr,V=Y[_].priority,J;_!==0&&(J=_>>1,!(Y[J].priority<V));)this._swap(_,J),_=J}_swap(_,Y){var V=this._arr,J=this._keyIndices,U=V[_],H=V[Y];V[_]=H,V[Y]=U,J[H.key]=_,J[U.key]=Y}};D.exports=z}),y=o((T,D)=>{var z=p();D.exports=Y;var _=()=>1;function Y(J,U,H,X){var L=function(M){return J.outEdges(M)};return V(J,String(U),H||_,X||L)}function V(J,U,H,X){var L={},M=new z,q,K,ee=function(te){var se=te.v!==q?te.v:te.w,xe=L[se],ke=H(te),De=K.distance+ke;if(ke<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+te+" Weight: "+ke);De<xe.distance&&(xe.distance=De,xe.predecessor=q,M.decrease(se,De))};for(J.nodes().forEach(function(te){var se=te===U?0:Number.POSITIVE_INFINITY;L[te]={distance:se},M.add(te,se)});M.size()>0&&(q=M.removeMin(),K=L[q],K.distance!==Number.POSITIVE_INFINITY);)X(q).forEach(ee);return L}}),w=o((T,D)=>{var z=y();D.exports=_;function _(Y,V,J){return Y.nodes().reduce(function(U,H){return U[H]=z(Y,H,V,J),U},{})}}),N=o((T,D)=>{D.exports=z;function z(Y,V,J){if(Y[V].predecessor!==void 0)throw new Error("Invalid source vertex");if(Y[J].predecessor===void 0&&J!==V)throw new Error("Invalid destination vertex");return{weight:Y[J].distance,path:_(Y,V,J)}}function _(Y,V,J){for(var U=[],H=J;H!==V;)U.push(H),H=Y[H].predecessor;return U.push(V),U.reverse()}}),E=o((T,D)=>{D.exports=z;function z(_){var Y=0,V=[],J={},U=[];function H(X){var L=J[X]={onStack:!0,lowlink:Y,index:Y++};if(V.push(X),_.successors(X).forEach(function(K){Object.hasOwn(J,K)?J[K].onStack&&(L.lowlink=Math.min(L.lowlink,J[K].index)):(H(K),L.lowlink=Math.min(L.lowlink,J[K].lowlink))}),L.lowlink===L.index){var M=[],q;do q=V.pop(),J[q].onStack=!1,M.push(q);while(X!==q);U.push(M)}}return _.nodes().forEach(function(X){Object.hasOwn(J,X)||H(X)}),U}}),A=o((T,D)=>{var z=E();D.exports=_;function _(Y){return z(Y).filter(function(V){return V.length>1||V.length===1&&Y.hasEdge(V[0],V[0])})}}),C=o((T,D)=>{D.exports=_;var z=()=>1;function _(V,J,U){return Y(V,J||z,U||function(H){return V.outEdges(H)})}function Y(V,J,U){var H={},X=V.nodes();return X.forEach(function(L){H[L]={},H[L][L]={distance:0},X.forEach(function(M){L!==M&&(H[L][M]={distance:Number.POSITIVE_INFINITY})}),U(L).forEach(function(M){var q=M.v===L?M.w:M.v,K=J(M);H[L][q]={distance:K,predecessor:L}})}),X.forEach(function(L){var M=H[L];X.forEach(function(q){var K=H[q];X.forEach(function(ee){var te=K[L],se=M[ee],xe=K[ee],ke=te.distance+se.distance;ke<xe.distance&&(xe.distance=ke,xe.predecessor=se.predecessor)})})}),H}}),k=o((T,D)=>{function z(Y){var V={},J={},U=[];function H(X){if(Object.hasOwn(J,X))throw new _;Object.hasOwn(V,X)||(J[X]=!0,V[X]=!0,Y.predecessors(X).forEach(H),delete J[X],U.push(X))}if(Y.sinks().forEach(H),Object.keys(V).length!==Y.nodeCount())throw new _;return U}var _=class extends Error{constructor(){super(...arguments)}};D.exports=z,z.CycleException=_}),S=o((T,D)=>{var z=k();D.exports=_;function _(Y){try{z(Y)}catch(V){if(V instanceof z.CycleException)return!1;throw V}return!0}}),O=o((T,D)=>{D.exports=z;function z(Y,V,J,U,H){Array.isArray(V)||(V=[V]);var X=(Y.isDirected()?Y.successors:Y.neighbors).bind(Y),L={};return V.forEach(function(M){if(!Y.hasNode(M))throw new Error("Graph does not have node: "+M);H=_(Y,M,J==="post",L,X,U,H)}),H}function _(Y,V,J,U,H,X,L){return Object.hasOwn(U,V)||(U[V]=!0,J||(L=X(L,V)),H(V).forEach(function(M){L=_(Y,M,J,U,H,X,L)}),J&&(L=X(L,V))),L}}),R=o((T,D)=>{var z=O();D.exports=_;function _(Y,V,J){return z(Y,V,J,function(U,H){return U.push(H),U},[])}}),G=o((T,D)=>{var z=R();D.exports=_;function _(Y,V){return z(Y,V,"post")}}),I=o((T,D)=>{var z=R();D.exports=_;function _(Y,V){return z(Y,V,"pre")}}),Q=o((T,D)=>{var z=c(),_=p();D.exports=Y;function Y(V,J){var U=new z,H={},X=new _,L;function M(K){var ee=K.v===L?K.w:K.v,te=X.priority(ee);if(te!==void 0){var se=J(K);se<te&&(H[ee]=L,X.decrease(ee,se))}}if(V.nodeCount()===0)return U;V.nodes().forEach(function(K){X.add(K,Number.POSITIVE_INFINITY),U.setNode(K)}),X.decrease(V.nodes()[0],0);for(var q=!1;X.size()>0;){if(L=X.removeMin(),Object.hasOwn(H,L))U.setEdge(L,H[L]);else{if(q)throw new Error("Input graph is not connected: "+V);q=!0}V.nodeEdges(L).forEach(M)}return U}}),$=o((T,D)=>{var z=y(),_=x();D.exports=Y;function Y(J,U,H,X){return V(J,U,H,X||function(L){return J.outEdges(L)})}function V(J,U,H,X){if(H===void 0)return z(J,U,H,X);for(var L=!1,M=J.nodes(),q=0;q<M.length;q++){for(var K=X(M[q]),ee=0;ee<K.length;ee++){var te=K[ee],se=te.v===M[q]?te.v:te.w,xe=se===te.v?te.w:te.v;H({v:se,w:xe})<0&&(L=!0)}if(L)return _(J,U,H,X)}return z(J,U,H,X)}}),F=o((T,D)=>{D.exports={bellmanFord:x(),components:g(),dijkstra:y(),dijkstraAll:w(),extractPath:N(),findCycles:A(),floydWarshall:C(),isAcyclic:S(),postorder:G(),preorder:I(),prim:Q(),shortestPaths:$(),reduce:O(),tarjan:E(),topsort:k()}}),B=m();r.exports={Graph:B.Graph,json:f(),alg:F(),version:B.version}}),ML=cn((e,r)=>{var s=class{constructor(){let d={};d._next=d._prev=d,this._sentinel=d}dequeue(){let d=this._sentinel,c=d._prev;if(c!==d)return l(c),c}enqueue(d){let c=this._sentinel;d._prev&&d._next&&l(d),d._next=c._next,c._next._prev=d,c._next=d,d._prev=c}toString(){let d=[],c=this._sentinel,h=c._prev;for(;h!==c;)d.push(JSON.stringify(h,o)),h=h._prev;return"["+d.join(", ")+"]"}};function l(d){d._prev._next=d._next,d._next._prev=d._prev,delete d._next,delete d._prev}function o(d,c){if(d!=="_next"&&d!=="_prev")return c}r.exports=s}),DL=cn((e,r)=>{var s=ls().Graph,l=ML();r.exports=d;var o=()=>1;function d(g,p){if(g.nodeCount()<=1)return[];let y=m(g,p||o);return c(y.graph,y.buckets,y.zeroIdx).flatMap(w=>g.outEdges(w.v,w.w))}function c(g,p,y){let w=[],N=p[p.length-1],E=p[0],A;for(;g.nodeCount();){for(;A=E.dequeue();)h(g,p,y,A);for(;A=N.dequeue();)h(g,p,y,A);if(g.nodeCount()){for(let C=p.length-2;C>0;--C)if(A=p[C].dequeue(),A){w=w.concat(h(g,p,y,A,!0));break}}}return w}function h(g,p,y,w,N){let E=N?[]:void 0;return g.inEdges(w.v).forEach(A=>{let C=g.edge(A),k=g.node(A.v);N&&E.push({v:A.v,w:A.w}),k.out-=C,f(p,y,k)}),g.outEdges(w.v).forEach(A=>{let C=g.edge(A),k=A.w,S=g.node(k);S.in-=C,f(p,y,S)}),g.removeNode(w.v),E}function m(g,p){let y=new s,w=0,N=0;g.nodes().forEach(C=>{y.setNode(C,{v:C,in:0,out:0})}),g.edges().forEach(C=>{let k=y.edge(C.v,C.w)||0,S=p(C),O=k+S;y.setEdge(C.v,C.w,O),N=Math.max(N,y.node(C.v).out+=S),w=Math.max(w,y.node(C.w).in+=S)});let E=x(N+w+3).map(()=>new l),A=w+1;return y.nodes().forEach(C=>{f(E,A,y.node(C))}),{graph:y,buckets:E,zeroIdx:A}}function f(g,p,y){y.out?y.in?g[y.out-y.in+p].enqueue(y):g[g.length-1].enqueue(y):g[0].enqueue(y)}function x(g){let p=[];for(let y=0;y<g;y++)p.push(y);return p}}),qn=cn((e,r)=>{var s=ls().Graph;r.exports={addBorderNode:p,addDummyNode:l,applyWithChunking:N,asNonCompoundGraph:d,buildLayerMatrix:f,intersectRect:m,mapValues:I,maxRank:E,normalizeRanks:x,notime:k,partition:A,pick:G,predecessorWeights:h,range:R,removeEmptyRanks:g,simplify:o,successorWeights:c,time:C,uniqueId:O,zipObject:Q};function l($,F,B,T){for(var D=T;$.hasNode(D);)D=O(T);return B.dummy=F,$.setNode(D,B),D}function o($){let F=new s().setGraph($.graph());return $.nodes().forEach(B=>F.setNode(B,$.node(B))),$.edges().forEach(B=>{let T=F.edge(B.v,B.w)||{weight:0,minlen:1},D=$.edge(B);F.setEdge(B.v,B.w,{weight:T.weight+D.weight,minlen:Math.max(T.minlen,D.minlen)})}),F}function d($){let F=new s({multigraph:$.isMultigraph()}).setGraph($.graph());return $.nodes().forEach(B=>{$.children(B).length||F.setNode(B,$.node(B))}),$.edges().forEach(B=>{F.setEdge(B,$.edge(B))}),F}function c($){let F=$.nodes().map(B=>{let T={};return $.outEdges(B).forEach(D=>{T[D.w]=(T[D.w]||0)+$.edge(D).weight}),T});return Q($.nodes(),F)}function h($){let F=$.nodes().map(B=>{let T={};return $.inEdges(B).forEach(D=>{T[D.v]=(T[D.v]||0)+$.edge(D).weight}),T});return Q($.nodes(),F)}function m($,F){let B=$.x,T=$.y,D=F.x-B,z=F.y-T,_=$.width/2,Y=$.height/2;if(!D&&!z)throw new Error("Not possible to find intersection inside of the rectangle");let V,J;return Math.abs(z)*_>Math.abs(D)*Y?(z<0&&(Y=-Y),V=Y*D/z,J=Y):(D<0&&(_=-_),V=_,J=_*z/D),{x:B+V,y:T+J}}function f($){let F=R(E($)+1).map(()=>[]);return $.nodes().forEach(B=>{let T=$.node(B),D=T.rank;D!==void 0&&(F[D][T.order]=B)}),F}function x($){let F=$.nodes().map(T=>{let D=$.node(T).rank;return D===void 0?Number.MAX_VALUE:D}),B=N(Math.min,F);$.nodes().forEach(T=>{let D=$.node(T);Object.hasOwn(D,"rank")&&(D.rank-=B)})}function g($){let F=$.nodes().map(_=>$.node(_).rank).filter(_=>_!==void 0),B=N(Math.min,F),T=[];$.nodes().forEach(_=>{let Y=$.node(_).rank-B;T[Y]||(T[Y]=[]),T[Y].push(_)});let D=0,z=$.graph().nodeRankFactor;Array.from(T).forEach((_,Y)=>{_===void 0&&Y%z!==0?--D:_!==void 0&&D&&_.forEach(V=>$.node(V).rank+=D)})}function p($,F,B,T){let D={width:0,height:0};return arguments.length>=4&&(D.rank=B,D.order=T),l($,"border",D,F)}function y($,F=w){let B=[];for(let T=0;T<$.length;T+=F){let D=$.slice(T,T+F);B.push(D)}return B}var w=65535;function N($,F){if(F.length>w){let B=y(F);return $.apply(null,B.map(T=>$.apply(null,T)))}else return $.apply(null,F)}function E($){let F=$.nodes().map(B=>{let T=$.node(B).rank;return T===void 0?Number.MIN_VALUE:T});return N(Math.max,F)}function A($,F){let B={lhs:[],rhs:[]};return $.forEach(T=>{F(T)?B.lhs.push(T):B.rhs.push(T)}),B}function C($,F){let B=Date.now();try{return F()}finally{console.log($+" time: "+(Date.now()-B)+"ms")}}function k($,F){return F()}var S=0;function O($){var F=++S;return $+(""+F)}function R($,F,B=1){F==null&&(F=$,$=0);let T=z=>z<F;B<0&&(T=z=>F<z);let D=[];for(let z=$;T(z);z+=B)D.push(z);return D}function G($,F){let B={};for(let T of F)$[T]!==void 0&&(B[T]=$[T]);return B}function I($,F){let B=F;return typeof F=="string"&&(B=T=>T[F]),Object.entries($).reduce((T,[D,z])=>(T[D]=B(z,D),T),{})}function Q($,F){return $.reduce((B,T,D)=>(B[T]=F[D],B),{})}}),OL=cn((e,r)=>{var s=DL(),l=qn().uniqueId;r.exports={run:o,undo:c};function o(h){(h.graph().acyclicer==="greedy"?s(h,m(h)):d(h)).forEach(f=>{let x=h.edge(f);h.removeEdge(f),x.forwardName=f.name,x.reversed=!0,h.setEdge(f.w,f.v,x,l("rev"))});function m(f){return x=>f.edge(x).weight}}function d(h){let m=[],f={},x={};function g(p){Object.hasOwn(x,p)||(x[p]=!0,f[p]=!0,h.outEdges(p).forEach(y=>{Object.hasOwn(f,y.w)?m.push(y):g(y.w)}),delete f[p])}return h.nodes().forEach(g),m}function c(h){h.edges().forEach(m=>{let f=h.edge(m);if(f.reversed){h.removeEdge(m);let x=f.forwardName;delete f.reversed,delete f.forwardName,h.setEdge(m.w,m.v,f,x)}})}}),RL=cn((e,r)=>{var s=qn();r.exports={run:l,undo:d};function l(c){c.graph().dummyChains=[],c.edges().forEach(h=>o(c,h))}function o(c,h){let m=h.v,f=c.node(m).rank,x=h.w,g=c.node(x).rank,p=h.name,y=c.edge(h),w=y.labelRank;if(g===f+1)return;c.removeEdge(h);let N,E,A;for(A=0,++f;f<g;++A,++f)y.points=[],E={width:0,height:0,edgeLabel:y,edgeObj:h,rank:f},N=s.addDummyNode(c,"edge",E,"_d"),f===w&&(E.width=y.width,E.height=y.height,E.dummy="edge-label",E.labelpos=y.labelpos),c.setEdge(m,N,{weight:y.weight},p),A===0&&c.graph().dummyChains.push(N),m=N;c.setEdge(m,x,{weight:y.weight},p)}function d(c){c.graph().dummyChains.forEach(h=>{let m=c.node(h),f=m.edgeLabel,x;for(c.setEdge(m.edgeObj,f);m.dummy;)x=c.successors(h)[0],c.removeNode(h),f.points.push({x:m.x,y:m.y}),m.dummy==="edge-label"&&(f.x=m.x,f.y=m.y,f.width=m.width,f.height=m.height),h=x,m=c.node(h)})}}),qd=cn((e,r)=>{var{applyWithChunking:s}=qn();r.exports={longestPath:l,slack:o};function l(d){var c={};function h(m){var f=d.node(m);if(Object.hasOwn(c,m))return f.rank;c[m]=!0;let x=d.outEdges(m).map(p=>p==null?Number.POSITIVE_INFINITY:h(p.w)-d.edge(p).minlen);var g=s(Math.min,x);return g===Number.POSITIVE_INFINITY&&(g=0),f.rank=g}d.sources().forEach(h)}function o(d,c){return d.node(c.w).rank-d.node(c.v).rank-d.edge(c).minlen}}),jN=cn((e,r)=>{var s=ls().Graph,l=qd().slack;r.exports=o;function o(m){var f=new s({directed:!1}),x=m.nodes()[0],g=m.nodeCount();f.setNode(x,{});for(var p,y;d(f,m)<g;)p=c(f,m),y=f.hasNode(p.v)?l(m,p):-l(m,p),h(f,m,y);return f}function d(m,f){function x(g){f.nodeEdges(g).forEach(p=>{var y=p.v,w=g===y?p.w:y;!m.hasNode(w)&&!l(f,p)&&(m.setNode(w,{}),m.setEdge(g,w,{}),x(w))})}return m.nodes().forEach(x),m.nodeCount()}function c(m,f){return f.edges().reduce((x,g)=>{let p=Number.POSITIVE_INFINITY;return m.hasNode(g.v)!==m.hasNode(g.w)&&(p=l(f,g)),p<x[0]?[p,g]:x},[Number.POSITIVE_INFINITY,null])[1]}function h(m,f,x){m.nodes().forEach(g=>f.node(g).rank+=x)}}),LL=cn((e,r)=>{var s=jN(),l=qd().slack,o=qd().longestPath,d=ls().alg.preorder,c=ls().alg.postorder,h=qn().simplify;r.exports=m,m.initLowLimValues=p,m.initCutValues=f,m.calcCutValue=g,m.leaveEdge=w,m.enterEdge=N,m.exchangeEdges=E;function m(S){S=h(S),o(S);var O=s(S);p(O),f(O,S);for(var R,G;R=w(O);)G=N(O,S,R),E(O,S,R,G)}function f(S,O){var R=c(S,S.nodes());R=R.slice(0,R.length-1),R.forEach(G=>x(S,O,G))}function x(S,O,R){var G=S.node(R),I=G.parent;S.edge(R,I).cutvalue=g(S,O,R)}function g(S,O,R){var G=S.node(R),I=G.parent,Q=!0,$=O.edge(R,I),F=0;return $||(Q=!1,$=O.edge(I,R)),F=$.weight,O.nodeEdges(R).forEach(B=>{var T=B.v===R,D=T?B.w:B.v;if(D!==I){var z=T===Q,_=O.edge(B).weight;if(F+=z?_:-_,C(S,R,D)){var Y=S.edge(R,D).cutvalue;F+=z?-Y:Y}}}),F}function p(S,O){arguments.length<2&&(O=S.nodes()[0]),y(S,{},1,O)}function y(S,O,R,G,I){var Q=R,$=S.node(G);return O[G]=!0,S.neighbors(G).forEach(F=>{Object.hasOwn(O,F)||(R=y(S,O,R,F,G))}),$.low=Q,$.lim=R++,I?$.parent=I:delete $.parent,R}function w(S){return S.edges().find(O=>S.edge(O).cutvalue<0)}function N(S,O,R){var G=R.v,I=R.w;O.hasEdge(G,I)||(G=R.w,I=R.v);var Q=S.node(G),$=S.node(I),F=Q,B=!1;Q.lim>$.lim&&(F=$,B=!0);var T=O.edges().filter(D=>B===k(S,S.node(D.v),F)&&B!==k(S,S.node(D.w),F));return T.reduce((D,z)=>l(O,z)<l(O,D)?z:D)}function E(S,O,R,G){var I=R.v,Q=R.w;S.removeEdge(I,Q),S.setEdge(G.v,G.w,{}),p(S),f(S,O),A(S,O)}function A(S,O){var R=S.nodes().find(I=>!O.node(I).parent),G=d(S,R);G=G.slice(1),G.forEach(I=>{var Q=S.node(I).parent,$=O.edge(I,Q),F=!1;$||($=O.edge(Q,I),F=!0),O.node(I).rank=O.node(Q).rank+(F?$.minlen:-$.minlen)})}function C(S,O,R){return S.hasEdge(O,R)}function k(S,O,R){return R.low<=O.lim&&O.lim<=R.lim}}),zL=cn((e,r)=>{var s=qd(),l=s.longestPath,o=jN(),d=LL();r.exports=c;function c(x){var g=x.graph().ranker;if(g instanceof Function)return g(x);switch(x.graph().ranker){case"network-simplex":f(x);break;case"tight-tree":m(x);break;case"longest-path":h(x);break;case"none":break;default:f(x)}}var h=l;function m(x){l(x),o(x)}function f(x){d(x)}}),IL=cn((e,r)=>{r.exports=s;function s(d){let c=o(d);d.graph().dummyChains.forEach(h=>{let m=d.node(h),f=m.edgeObj,x=l(d,c,f.v,f.w),g=x.path,p=x.lca,y=0,w=g[y],N=!0;for(;h!==f.w;){if(m=d.node(h),N){for(;(w=g[y])!==p&&d.node(w).maxRank<m.rank;)y++;w===p&&(N=!1)}if(!N){for(;y<g.length-1&&d.node(w=g[y+1]).minRank<=m.rank;)y++;w=g[y]}d.setParent(h,w),h=d.successors(h)[0]}})}function l(d,c,h,m){let f=[],x=[],g=Math.min(c[h].low,c[m].low),p=Math.max(c[h].lim,c[m].lim),y,w;y=h;do y=d.parent(y),f.push(y);while(y&&(c[y].low>g||p>c[y].lim));for(w=y,y=m;(y=d.parent(y))!==w;)x.push(y);return{path:f.concat(x.reverse()),lca:w}}function o(d){let c={},h=0;function m(f){let x=h;d.children(f).forEach(m),c[f]={low:x,lim:h++}}return d.children().forEach(m),c}}),$L=cn((e,r)=>{var s=qn();r.exports={run:l,cleanup:h};function l(m){let f=s.addDummyNode(m,"root",{},"_root"),x=d(m),g=Object.values(x),p=s.applyWithChunking(Math.max,g)-1,y=2*p+1;m.graph().nestingRoot=f,m.edges().forEach(N=>m.edge(N).minlen*=y);let w=c(m)+1;m.children().forEach(N=>o(m,f,y,w,p,x,N)),m.graph().nodeRankFactor=y}function o(m,f,x,g,p,y,w){let N=m.children(w);if(!N.length){w!==f&&m.setEdge(f,w,{weight:0,minlen:x});return}let E=s.addBorderNode(m,"_bt"),A=s.addBorderNode(m,"_bb"),C=m.node(w);m.setParent(E,w),C.borderTop=E,m.setParent(A,w),C.borderBottom=A,N.forEach(k=>{o(m,f,x,g,p,y,k);let S=m.node(k),O=S.borderTop?S.borderTop:k,R=S.borderBottom?S.borderBottom:k,G=S.borderTop?g:2*g,I=O!==R?1:p-y[w]+1;m.setEdge(E,O,{weight:G,minlen:I,nestingEdge:!0}),m.setEdge(R,A,{weight:G,minlen:I,nestingEdge:!0})}),m.parent(w)||m.setEdge(f,E,{weight:0,minlen:p+y[w]})}function d(m){var f={};function x(g,p){var y=m.children(g);y&&y.length&&y.forEach(w=>x(w,p+1)),f[g]=p}return m.children().forEach(g=>x(g,1)),f}function c(m){return m.edges().reduce((f,x)=>f+m.edge(x).weight,0)}function h(m){var f=m.graph();m.removeNode(f.nestingRoot),delete f.nestingRoot,m.edges().forEach(x=>{var g=m.edge(x);g.nestingEdge&&m.removeEdge(x)})}}),BL=cn((e,r)=>{var s=qn();r.exports=l;function l(d){function c(h){let m=d.children(h),f=d.node(h);if(m.length&&m.forEach(c),Object.hasOwn(f,"minRank")){f.borderLeft=[],f.borderRight=[];for(let x=f.minRank,g=f.maxRank+1;x<g;++x)o(d,"borderLeft","_bl",h,f,x),o(d,"borderRight","_br",h,f,x)}}d.children().forEach(c)}function o(d,c,h,m,f,x){let g={width:0,height:0,rank:x,borderType:c},p=f[c][x-1],y=s.addDummyNode(d,"border",g,h);f[c][x]=y,d.setParent(y,m),p&&d.setEdge(p,y,{weight:1})}}),HL=cn((e,r)=>{r.exports={adjust:s,undo:l};function s(x){let g=x.graph().rankdir.toLowerCase();(g==="lr"||g==="rl")&&o(x)}function l(x){let g=x.graph().rankdir.toLowerCase();(g==="bt"||g==="rl")&&c(x),(g==="lr"||g==="rl")&&(m(x),o(x))}function o(x){x.nodes().forEach(g=>d(x.node(g))),x.edges().forEach(g=>d(x.edge(g)))}function d(x){let g=x.width;x.width=x.height,x.height=g}function c(x){x.nodes().forEach(g=>h(x.node(g))),x.edges().forEach(g=>{let p=x.edge(g);p.points.forEach(h),Object.hasOwn(p,"y")&&h(p)})}function h(x){x.y=-x.y}function m(x){x.nodes().forEach(g=>f(x.node(g))),x.edges().forEach(g=>{let p=x.edge(g);p.points.forEach(f),Object.hasOwn(p,"x")&&f(p)})}function f(x){let g=x.x;x.x=x.y,x.y=g}}),PL=cn((e,r)=>{var s=qn();r.exports=l;function l(o){let d={},c=o.nodes().filter(g=>!o.children(g).length),h=c.map(g=>o.node(g).rank),m=s.applyWithChunking(Math.max,h),f=s.range(m+1).map(()=>[]);function x(g){if(d[g])return;d[g]=!0;let p=o.node(g);f[p.rank].push(g),o.successors(g).forEach(x)}return c.sort((g,p)=>o.node(g).rank-o.node(p).rank).forEach(x),f}}),UL=cn((e,r)=>{var s=qn().zipObject;r.exports=l;function l(d,c){let h=0;for(let m=1;m<c.length;++m)h+=o(d,c[m-1],c[m]);return h}function o(d,c,h){let m=s(h,h.map((w,N)=>N)),f=c.flatMap(w=>d.outEdges(w).map(N=>({pos:m[N.w],weight:d.edge(N).weight})).sort((N,E)=>N.pos-E.pos)),x=1;for(;x<h.length;)x<<=1;let g=2*x-1;x-=1;let p=new Array(g).fill(0),y=0;return f.forEach(w=>{let N=w.pos+x;p[N]+=w.weight;let E=0;for(;N>0;)N%2&&(E+=p[N+1]),N=N-1>>1,p[N]+=w.weight;y+=w.weight*E}),y}}),qL=cn((e,r)=>{r.exports=s;function s(l,o=[]){return o.map(d=>{let c=l.inEdges(d);if(c.length){let h=c.reduce((m,f)=>{let x=l.edge(f),g=l.node(f.v);return{sum:m.sum+x.weight*g.order,weight:m.weight+x.weight}},{sum:0,weight:0});return{v:d,barycenter:h.sum/h.weight,weight:h.weight}}else return{v:d}})}}),FL=cn((e,r)=>{var s=qn();r.exports=l;function l(c,h){let m={};c.forEach((x,g)=>{let p=m[x.v]={indegree:0,in:[],out:[],vs:[x.v],i:g};x.barycenter!==void 0&&(p.barycenter=x.barycenter,p.weight=x.weight)}),h.edges().forEach(x=>{let g=m[x.v],p=m[x.w];g!==void 0&&p!==void 0&&(p.indegree++,g.out.push(m[x.w]))});let f=Object.values(m).filter(x=>!x.indegree);return o(f)}function o(c){let h=[];function m(x){return g=>{g.merged||(g.barycenter===void 0||x.barycenter===void 0||g.barycenter>=x.barycenter)&&d(x,g)}}function f(x){return g=>{g.in.push(x),--g.indegree===0&&c.push(g)}}for(;c.length;){let x=c.pop();h.push(x),x.in.reverse().forEach(m(x)),x.out.forEach(f(x))}return h.filter(x=>!x.merged).map(x=>s.pick(x,["vs","i","barycenter","weight"]))}function d(c,h){let m=0,f=0;c.weight&&(m+=c.barycenter*c.weight,f+=c.weight),h.weight&&(m+=h.barycenter*h.weight,f+=h.weight),c.vs=h.vs.concat(c.vs),c.barycenter=m/f,c.weight=f,c.i=Math.min(h.i,c.i),h.merged=!0}}),VL=cn((e,r)=>{var s=qn();r.exports=l;function l(c,h){let m=s.partition(c,E=>Object.hasOwn(E,"barycenter")),f=m.lhs,x=m.rhs.sort((E,A)=>A.i-E.i),g=[],p=0,y=0,w=0;f.sort(d(!!h)),w=o(g,x,w),f.forEach(E=>{w+=E.vs.length,g.push(E.vs),p+=E.barycenter*E.weight,y+=E.weight,w=o(g,x,w)});let N={vs:g.flat(!0)};return y&&(N.barycenter=p/y,N.weight=y),N}function o(c,h,m){let f;for(;h.length&&(f=h[h.length-1]).i<=m;)h.pop(),c.push(f.vs),m++;return m}function d(c){return(h,m)=>h.barycenter<m.barycenter?-1:h.barycenter>m.barycenter?1:c?m.i-h.i:h.i-m.i}}),YL=cn((e,r)=>{var s=qL(),l=FL(),o=VL();r.exports=d;function d(m,f,x,g){let p=m.children(f),y=m.node(f),w=y?y.borderLeft:void 0,N=y?y.borderRight:void 0,E={};w&&(p=p.filter(S=>S!==w&&S!==N));let A=s(m,p);A.forEach(S=>{if(m.children(S.v).length){let O=d(m,S.v,x,g);E[S.v]=O,Object.hasOwn(O,"barycenter")&&h(S,O)}});let C=l(A,x);c(C,E);let k=o(C,g);if(w&&(k.vs=[w,k.vs,N].flat(!0),m.predecessors(w).length)){let S=m.node(m.predecessors(w)[0]),O=m.node(m.predecessors(N)[0]);Object.hasOwn(k,"barycenter")||(k.barycenter=0,k.weight=0),k.barycenter=(k.barycenter*k.weight+S.order+O.order)/(k.weight+2),k.weight+=2}return k}function c(m,f){m.forEach(x=>{x.vs=x.vs.flatMap(g=>f[g]?f[g].vs:g)})}function h(m,f){m.barycenter!==void 0?(m.barycenter=(m.barycenter*m.weight+f.barycenter*f.weight)/(m.weight+f.weight),m.weight+=f.weight):(m.barycenter=f.barycenter,m.weight=f.weight)}}),GL=cn((e,r)=>{var s=ls().Graph,l=qn();r.exports=o;function o(c,h,m,f){f||(f=c.nodes());let x=d(c),g=new s({compound:!0}).setGraph({root:x}).setDefaultNodeLabel(p=>c.node(p));return f.forEach(p=>{let y=c.node(p),w=c.parent(p);(y.rank===h||y.minRank<=h&&h<=y.maxRank)&&(g.setNode(p),g.setParent(p,w||x),c[m](p).forEach(N=>{let E=N.v===p?N.w:N.v,A=g.edge(E,p),C=A!==void 0?A.weight:0;g.setEdge(E,p,{weight:c.edge(N).weight+C})}),Object.hasOwn(y,"minRank")&&g.setNode(p,{borderLeft:y.borderLeft[h],borderRight:y.borderRight[h]}))}),g}function d(c){for(var h;c.hasNode(h=l.uniqueId("_root")););return h}}),XL=cn((e,r)=>{r.exports=s;function s(l,o,d){let c={},h;d.forEach(m=>{let f=l.parent(m),x,g;for(;f;){if(x=l.parent(f),x?(g=c[x],c[x]=f):(g=h,h=f),g&&g!==f){o.setEdge(g,f);return}f=x}})}}),ZL=cn((e,r)=>{var s=PL(),l=UL(),o=YL(),d=GL(),c=XL(),h=ls().Graph,m=qn();r.exports=f;function f(y,w={}){if(typeof w.customOrder=="function"){w.customOrder(y,f);return}let N=m.maxRank(y),E=x(y,m.range(1,N+1),"inEdges"),A=x(y,m.range(N-1,-1,-1),"outEdges"),C=s(y);if(p(y,C),w.disableOptimalOrderHeuristic)return;let k=Number.POSITIVE_INFINITY,S,O=w.constraints||[];for(let R=0,G=0;G<4;++R,++G){g(R%2?E:A,R%4>=2,O),C=m.buildLayerMatrix(y);let I=l(y,C);I<k?(G=0,S=Object.assign({},C),k=I):I===k&&(S=structuredClone(C))}p(y,S)}function x(y,w,N){let E=new Map,A=(C,k)=>{E.has(C)||E.set(C,[]),E.get(C).push(k)};for(let C of y.nodes()){let k=y.node(C);if(typeof k.rank=="number"&&A(k.rank,C),typeof k.minRank=="number"&&typeof k.maxRank=="number")for(let S=k.minRank;S<=k.maxRank;S++)S!==k.rank&&A(S,C)}return w.map(function(C){return d(y,C,N,E.get(C)||[])})}function g(y,w,N){let E=new h;y.forEach(function(A){N.forEach(S=>E.setEdge(S.left,S.right));let C=A.graph().root,k=o(A,C,E,w);k.vs.forEach((S,O)=>A.node(S).order=O),c(A,E,k.vs)})}function p(y,w){Object.values(w).forEach(N=>N.forEach((E,A)=>y.node(E).order=A))}}),QL=cn((e,r)=>{var s=ls().Graph,l=qn();r.exports={positionX:N,findType1Conflicts:o,findType2Conflicts:d,addConflict:h,hasConflict:m,verticalAlignment:f,horizontalCompaction:x,alignCoordinates:y,findSmallestWidthAlignment:p,balance:w};function o(C,k){let S={};function O(R,G){let I=0,Q=0,$=R.length,F=G[G.length-1];return G.forEach((B,T)=>{let D=c(C,B),z=D?C.node(D).order:$;(D||B===F)&&(G.slice(Q,T+1).forEach(_=>{C.predecessors(_).forEach(Y=>{let V=C.node(Y),J=V.order;(J<I||z<J)&&!(V.dummy&&C.node(_).dummy)&&h(S,Y,_)})}),Q=T+1,I=z)}),G}return k.length&&k.reduce(O),S}function d(C,k){let S={};function O(G,I,Q,$,F){let B;l.range(I,Q).forEach(T=>{B=G[T],C.node(B).dummy&&C.predecessors(B).forEach(D=>{let z=C.node(D);z.dummy&&(z.order<$||z.order>F)&&h(S,D,B)})})}function R(G,I){let Q=-1,$,F=0;return I.forEach((B,T)=>{if(C.node(B).dummy==="border"){let D=C.predecessors(B);D.length&&($=C.node(D[0]).order,O(I,F,T,Q,$),F=T,Q=$)}O(I,F,I.length,$,G.length)}),I}return k.length&&k.reduce(R),S}function c(C,k){if(C.node(k).dummy)return C.predecessors(k).find(S=>C.node(S).dummy)}function h(C,k,S){if(k>S){let R=k;k=S,S=R}let O=C[k];O||(C[k]=O={}),O[S]=!0}function m(C,k,S){if(k>S){let O=k;k=S,S=O}return!!C[k]&&Object.hasOwn(C[k],S)}function f(C,k,S,O){let R={},G={},I={};return k.forEach(Q=>{Q.forEach(($,F)=>{R[$]=$,G[$]=$,I[$]=F})}),k.forEach(Q=>{let $=-1;Q.forEach(F=>{let B=O(F);if(B.length){B=B.sort((D,z)=>I[D]-I[z]);let T=(B.length-1)/2;for(let D=Math.floor(T),z=Math.ceil(T);D<=z;++D){let _=B[D];G[F]===F&&$<I[_]&&!m(S,F,_)&&(G[_]=F,G[F]=R[F]=R[_],$=I[_])}}})}),{root:R,align:G}}function x(C,k,S,O,R){let G={},I=g(C,k,S,R),Q=R?"borderLeft":"borderRight";function $(T,D){let z=I.nodes().slice(),_={},Y=z.pop();for(;Y;){if(_[Y])T(Y);else{_[Y]=!0,z.push(Y);for(let V of D(Y))z.push(V)}Y=z.pop()}}function F(T){G[T]=I.inEdges(T).reduce((D,z)=>Math.max(D,G[z.v]+I.edge(z)),0)}function B(T){let D=I.outEdges(T).reduce((_,Y)=>Math.min(_,G[Y.w]-I.edge(Y)),Number.POSITIVE_INFINITY),z=C.node(T);D!==Number.POSITIVE_INFINITY&&z.borderType!==Q&&(G[T]=Math.max(G[T],D))}return $(F,I.predecessors.bind(I)),$(B,I.successors.bind(I)),Object.keys(O).forEach(T=>G[T]=G[S[T]]),G}function g(C,k,S,O){let R=new s,G=C.graph(),I=E(G.nodesep,G.edgesep,O);return k.forEach(Q=>{let $;Q.forEach(F=>{let B=S[F];if(R.setNode(B),$){var T=S[$],D=R.edge(T,B);R.setEdge(T,B,Math.max(I(C,F,$),D||0))}$=F})}),R}function p(C,k){return Object.values(k).reduce((S,O)=>{let R=Number.NEGATIVE_INFINITY,G=Number.POSITIVE_INFINITY;Object.entries(O).forEach(([Q,$])=>{let F=A(C,Q)/2;R=Math.max($+F,R),G=Math.min($-F,G)});let I=R-G;return I<S[0]&&(S=[I,O]),S},[Number.POSITIVE_INFINITY,null])[1]}function y(C,k){let S=Object.values(k),O=l.applyWithChunking(Math.min,S),R=l.applyWithChunking(Math.max,S);["u","d"].forEach(G=>{["l","r"].forEach(I=>{let Q=G+I,$=C[Q];if($===k)return;let F=Object.values($),B=O-l.applyWithChunking(Math.min,F);I!=="l"&&(B=R-l.applyWithChunking(Math.max,F)),B&&(C[Q]=l.mapValues($,T=>T+B))})})}function w(C,k){return l.mapValues(C.ul,(S,O)=>{if(k)return C[k.toLowerCase()][O];{let R=Object.values(C).map(G=>G[O]).sort((G,I)=>G-I);return(R[1]+R[2])/2}})}function N(C){let k=l.buildLayerMatrix(C),S=Object.assign(o(C,k),d(C,k)),O={},R;["u","d"].forEach(I=>{R=I==="u"?k:Object.values(k).reverse(),["l","r"].forEach(Q=>{Q==="r"&&(R=R.map(T=>Object.values(T).reverse()));let $=(I==="u"?C.predecessors:C.successors).bind(C),F=f(C,R,S,$),B=x(C,R,F.root,F.align,Q==="r");Q==="r"&&(B=l.mapValues(B,T=>-T)),O[I+Q]=B})});let G=p(C,O);return y(O,G),w(O,C.graph().align)}function E(C,k,S){return(O,R,G)=>{let I=O.node(R),Q=O.node(G),$=0,F;if($+=I.width/2,Object.hasOwn(I,"labelpos"))switch(I.labelpos.toLowerCase()){case"l":F=-I.width/2;break;case"r":F=I.width/2;break}if(F&&($+=S?F:-F),F=0,$+=(I.dummy?k:C)/2,$+=(Q.dummy?k:C)/2,$+=Q.width/2,Object.hasOwn(Q,"labelpos"))switch(Q.labelpos.toLowerCase()){case"l":F=Q.width/2;break;case"r":F=-Q.width/2;break}return F&&($+=S?F:-F),F=0,$}}function A(C,k){return C.node(k).width}}),KL=cn((e,r)=>{var s=qn(),l=QL().positionX;r.exports=o;function o(c){c=s.asNonCompoundGraph(c),d(c),Object.entries(l(c)).forEach(([h,m])=>c.node(h).x=m)}function d(c){let h=s.buildLayerMatrix(c),m=c.graph().ranksep,f=c.graph().rankalign,x=0;h.forEach(g=>{let p=g.reduce((y,w)=>{let N=c.node(w).height;return y>N?y:N},0);g.forEach(y=>{let w=c.node(y);f==="top"?w.y=x+w.height/2:f==="bottom"?w.y=x+p-w.height/2:w.y=x+p/2}),x+=p+m})}}),JL=cn((e,r)=>{var s=OL(),l=RL(),o=zL(),d=qn().normalizeRanks,c=IL(),h=qn().removeEmptyRanks,m=$L(),f=BL(),x=HL(),g=ZL(),p=KL(),y=qn(),w=ls().Graph;r.exports=N;function N(q,K={}){let ee=K.debugTiming?y.time:y.notime;return ee("layout",()=>{let te=ee(" buildLayoutGraph",()=>$(q));return ee(" runLayout",()=>E(te,ee,K)),ee(" updateInputGraph",()=>A(q,te)),te})}function E(q,K,ee){K(" makeSpaceForEdgeLabels",()=>F(q)),K(" removeSelfEdges",()=>U(q)),K(" acyclic",()=>s.run(q)),K(" nestingGraph.run",()=>m.run(q)),K(" rank",()=>o(y.asNonCompoundGraph(q))),K(" injectEdgeLabelProxies",()=>B(q)),K(" removeEmptyRanks",()=>h(q)),K(" nestingGraph.cleanup",()=>m.cleanup(q)),K(" normalizeRanks",()=>d(q)),K(" assignRankMinMax",()=>T(q)),K(" removeEdgeLabelProxies",()=>D(q)),K(" normalize.run",()=>l.run(q)),K(" parentDummyChains",()=>c(q)),K(" addBorderSegments",()=>f(q)),K(" order",()=>g(q,ee)),K(" insertSelfEdges",()=>H(q)),K(" adjustCoordinateSystem",()=>x.adjust(q)),K(" position",()=>p(q)),K(" positionSelfEdges",()=>X(q)),K(" removeBorderNodes",()=>J(q)),K(" normalize.undo",()=>l.undo(q)),K(" fixupEdgeLabelCoords",()=>Y(q)),K(" undoCoordinateSystem",()=>x.undo(q)),K(" translateGraph",()=>z(q)),K(" assignNodeIntersects",()=>_(q)),K(" reversePoints",()=>V(q)),K(" acyclic.undo",()=>s.undo(q))}function A(q,K){q.nodes().forEach(ee=>{let te=q.node(ee),se=K.node(ee);te&&(te.x=se.x,te.y=se.y,te.order=se.order,te.rank=se.rank,K.children(ee).length&&(te.width=se.width,te.height=se.height))}),q.edges().forEach(ee=>{let te=q.edge(ee),se=K.edge(ee);te.points=se.points,Object.hasOwn(se,"x")&&(te.x=se.x,te.y=se.y)}),q.graph().width=K.graph().width,q.graph().height=K.graph().height}var C=["nodesep","edgesep","ranksep","marginx","marginy"],k={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb",rankalign:"center"},S=["acyclicer","ranker","rankdir","align","rankalign"],O=["width","height","rank"],R={width:0,height:0},G=["minlen","weight","width","height","labeloffset"],I={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Q=["labelpos"];function $(q){let K=new w({multigraph:!0,compound:!0}),ee=M(q.graph());return K.setGraph(Object.assign({},k,L(ee,C),y.pick(ee,S))),q.nodes().forEach(te=>{let se=M(q.node(te)),xe=L(se,O);Object.keys(R).forEach(ke=>{xe[ke]===void 0&&(xe[ke]=R[ke])}),K.setNode(te,xe),K.setParent(te,q.parent(te))}),q.edges().forEach(te=>{let se=M(q.edge(te));K.setEdge(te,Object.assign({},I,L(se,G),y.pick(se,Q)))}),K}function F(q){let K=q.graph();K.ranksep/=2,q.edges().forEach(ee=>{let te=q.edge(ee);te.minlen*=2,te.labelpos.toLowerCase()!=="c"&&(K.rankdir==="TB"||K.rankdir==="BT"?te.width+=te.labeloffset:te.height+=te.labeloffset)})}function B(q){q.edges().forEach(K=>{let ee=q.edge(K);if(ee.width&&ee.height){let te=q.node(K.v),se={rank:(q.node(K.w).rank-te.rank)/2+te.rank,e:K};y.addDummyNode(q,"edge-proxy",se,"_ep")}})}function T(q){let K=0;q.nodes().forEach(ee=>{let te=q.node(ee);te.borderTop&&(te.minRank=q.node(te.borderTop).rank,te.maxRank=q.node(te.borderBottom).rank,K=Math.max(K,te.maxRank))}),q.graph().maxRank=K}function D(q){q.nodes().forEach(K=>{let ee=q.node(K);ee.dummy==="edge-proxy"&&(q.edge(ee.e).labelRank=ee.rank,q.removeNode(K))})}function z(q){let K=Number.POSITIVE_INFINITY,ee=0,te=Number.POSITIVE_INFINITY,se=0,xe=q.graph(),ke=xe.marginx||0,De=xe.marginy||0;function ge(ye){let Ce=ye.x,ze=ye.y,tt=ye.width,Xe=ye.height;K=Math.min(K,Ce-tt/2),ee=Math.max(ee,Ce+tt/2),te=Math.min(te,ze-Xe/2),se=Math.max(se,ze+Xe/2)}q.nodes().forEach(ye=>ge(q.node(ye))),q.edges().forEach(ye=>{let Ce=q.edge(ye);Object.hasOwn(Ce,"x")&&ge(Ce)}),K-=ke,te-=De,q.nodes().forEach(ye=>{let Ce=q.node(ye);Ce.x-=K,Ce.y-=te}),q.edges().forEach(ye=>{let Ce=q.edge(ye);Ce.points.forEach(ze=>{ze.x-=K,ze.y-=te}),Object.hasOwn(Ce,"x")&&(Ce.x-=K),Object.hasOwn(Ce,"y")&&(Ce.y-=te)}),xe.width=ee-K+ke,xe.height=se-te+De}function _(q){q.edges().forEach(K=>{let ee=q.edge(K),te=q.node(K.v),se=q.node(K.w),xe,ke;ee.points?(xe=ee.points[0],ke=ee.points[ee.points.length-1]):(ee.points=[],xe=se,ke=te),ee.points.unshift(y.intersectRect(te,xe)),ee.points.push(y.intersectRect(se,ke))})}function Y(q){q.edges().forEach(K=>{let ee=q.edge(K);if(Object.hasOwn(ee,"x"))switch((ee.labelpos==="l"||ee.labelpos==="r")&&(ee.width-=ee.labeloffset),ee.labelpos){case"l":ee.x-=ee.width/2+ee.labeloffset;break;case"r":ee.x+=ee.width/2+ee.labeloffset;break}})}function V(q){q.edges().forEach(K=>{let ee=q.edge(K);ee.reversed&&ee.points.reverse()})}function J(q){q.nodes().forEach(K=>{if(q.children(K).length){let ee=q.node(K),te=q.node(ee.borderTop),se=q.node(ee.borderBottom),xe=q.node(ee.borderLeft[ee.borderLeft.length-1]),ke=q.node(ee.borderRight[ee.borderRight.length-1]);ee.width=Math.abs(ke.x-xe.x),ee.height=Math.abs(se.y-te.y),ee.x=xe.x+ee.width/2,ee.y=te.y+ee.height/2}}),q.nodes().forEach(K=>{q.node(K).dummy==="border"&&q.removeNode(K)})}function U(q){q.edges().forEach(K=>{if(K.v===K.w){var ee=q.node(K.v);ee.selfEdges||(ee.selfEdges=[]),ee.selfEdges.push({e:K,label:q.edge(K)}),q.removeEdge(K)}})}function H(q){var K=y.buildLayerMatrix(q);K.forEach(ee=>{var te=0;ee.forEach((se,xe)=>{var ke=q.node(se);ke.order=xe+te,(ke.selfEdges||[]).forEach(De=>{y.addDummyNode(q,"selfedge",{width:De.label.width,height:De.label.height,rank:ke.rank,order:xe+ ++te,e:De.e,label:De.label},"_se")}),delete ke.selfEdges})})}function X(q){q.nodes().forEach(K=>{var ee=q.node(K);if(ee.dummy==="selfedge"){var te=q.node(ee.e.v),se=te.x+te.width/2,xe=te.y,ke=ee.x-se,De=te.height/2;q.setEdge(ee.e,ee.label),q.removeNode(K),ee.label.points=[{x:se+2*ke/3,y:xe-De},{x:se+5*ke/6,y:xe-De},{x:se+ke,y:xe},{x:se+5*ke/6,y:xe+De},{x:se+2*ke/3,y:xe+De}],ee.label.x=ee.x,ee.label.y=ee.y}})}function L(q,K){return y.mapValues(y.pick(q,K),Number)}function M(q){var K={};return q&&Object.entries(q).forEach(([ee,te])=>{typeof ee=="string"&&(ee=ee.toLowerCase()),K[ee]=te}),K}}),WL=cn((e,r)=>{var s=qn(),l=ls().Graph;r.exports={debugOrdering:o};function o(d){let c=s.buildLayerMatrix(d),h=new l({compound:!0,multigraph:!0}).setGraph({});return d.nodes().forEach(m=>{h.setNode(m,{label:m}),h.setParent(m,"layer"+d.node(m).rank)}),d.edges().forEach(m=>h.setEdge(m.v,m.w,{},m.name)),c.forEach((m,f)=>{let x="layer"+f;h.setNode(x,{rank:"same"}),m.reduce((g,p)=>(h.setEdge(g,p,{style:"invis"}),p))}),h}}),ez=cn((e,r)=>{r.exports="2.0.4"}),tz=cn((e,r)=>{r.exports={graphlib:ls(),layout:JL(),debug:WL(),util:{time:qn().time,notime:qn().notime},version:ez()}});const Rv=tz();const Lv={pending:{bg:"bg-blue-500/10",border:"border-blue-500/30",text:"text-blue-500"},in_progress:{bg:"bg-amber-500/10",border:"border-amber-500/30",text:"text-amber-600"},blocked:{bg:"bg-red-500/8",border:"border-red-500/25",text:"text-red-500"},review:{bg:"bg-brand-500/10",border:"border-brand-500/30",text:"text-brand-500"},completed:{bg:"bg-green-500/10",border:"border-green-500/30",text:"text-green-600"},failed:{bg:"bg-red-500/10",border:"border-red-500/30",text:"text-red-500"},rejected:{bg:"bg-red-500/8",border:"border-red-500/25",text:"text-red-500"},cancelled:{bg:"bg-gray-500/8",border:"border-gray-500/20",text:"text-fg-tertiary"},archived:{bg:"bg-gray-500/5",border:"border-gray-500/15",text:"text-fg-tertiary"}},nz={critical:"bg-red-500",high:"bg-amber-500",medium:"bg-amber-500",low:"bg-blue-500"};function rz({data:e}){const{task:r,agentName:s,selected:l}=e,o=Lv[r.status]??Lv.pending,d=r.taskType==="scheduled"&&!!r.scheduleConfig,c=d?r.scheduleConfig.every?`Every ${r.scheduleConfig.every}`:r.scheduleConfig.cron?"Cron":"":"";return t.jsxs("div",{className:`rounded-lg border px-3 py-2 min-w-[180px] max-w-[220px] shadow-md backdrop-blur-sm ${d?`${o.bg} border-blue-500/40 ring-1 ring-blue-500/20`:`${o.bg} ${o.border}`} ${l?"ring-2 ring-brand-500 shadow-brand-500/25 shadow-lg":""}`,children:[t.jsx(Ma,{type:"target",position:lt.Top,className:"!bg-border-default !w-2 !h-2"}),t.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${nz[r.priority]??"bg-gray-500"}`}),t.jsx("span",{className:`text-[10px] font-medium uppercase tracking-wider ${o.text}`,children:r.status.replace("_"," ")}),d&&t.jsxs("span",{className:"text-[9px] px-1 py-0.5 rounded bg-blue-500/15 text-blue-600 ml-auto whitespace-nowrap inline-flex items-center gap-0.5",children:[t.jsx("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.3"})}),c]})]}),t.jsx("div",{className:"text-xs font-medium text-fg-primary leading-snug line-clamp-2 mb-1",children:r.title}),s&&t.jsx("div",{className:"text-[10px] text-fg-tertiary truncate",children:s}),r.blockedBy&&r.blockedBy.length>0&&t.jsxs("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:[r.blockedBy.length," dep",r.blockedBy.length>1?"s":""]}),t.jsx(Ma,{type:"source",position:lt.Bottom,className:"!bg-border-default !w-2 !h-2"})]})}const zv={pending:{bg:"bg-amber-500/10",border:"border-amber-500/30",text:"text-amber-600"},in_progress:{bg:"bg-brand-500/10",border:"border-brand-500/30",text:"text-brand-500"},completed:{bg:"bg-green-500/10",border:"border-green-500/30",text:"text-green-600"},rejected:{bg:"bg-red-500/10",border:"border-red-500/30",text:"text-red-500"},cancelled:{bg:"bg-gray-500/8",border:"border-gray-500/20",text:"text-fg-tertiary"}},Iv={pending:"todo",in_progress:"in_progress",completed:"done",rejected:"done",cancelled:"done"};function sz({data:e}){const{req:r,selected:s}=e,l=zv[r.status]??zv.pending;return t.jsxs("div",{className:`rounded-lg border-2 border-dashed px-3 py-2 min-w-[180px] max-w-[220px] shadow-lg ${l.bg} ${l.border} ${s?"ring-2 ring-brand-500 shadow-brand-500/25":""}`,children:[t.jsx(Ma,{type:"target",position:lt.Top,className:"!bg-border-default !w-2 !h-2"}),t.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[t.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded font-semibold bg-amber-500/15 text-amber-600",children:"REQ"}),t.jsx("span",{className:`text-[10px] font-medium uppercase tracking-wider ${l.text}`,children:r.status.replace("_"," ")})]}),t.jsx("div",{className:"text-xs font-medium text-fg-primary leading-snug line-clamp-2 mb-1",children:r.title}),r.taskIds.length>0&&t.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:[r.taskIds.length," task",r.taskIds.length>1?"s":""]}),t.jsx(Ma,{type:"source",position:lt.Bottom,className:"!bg-border-default !w-2 !h-2"})]})}const az={task:rz,requirement:sz},lz=()=>document.documentElement.classList.contains("light")||!document.documentElement.classList.contains("dark")&&window.matchMedia("(prefers-color-scheme: light)").matches,iz=e=>{const r=new MutationObserver(e);r.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]});const s=window.matchMedia("(prefers-color-scheme: light)");return s.addEventListener("change",e),()=>{r.disconnect(),s.removeEventListener("change",e)}};function oz(){return v.useSyncExternalStore(iz,lz,()=>!1)}const Im=200,$m=80;function $v(e,r,s="TB"){const l=new Rv.graphlib.Graph;l.setDefaultEdgeLabel(()=>({})),l.setGraph({rankdir:s,nodesep:40,ranksep:60});for(const o of e)l.setNode(o.id,{width:Im,height:$m});for(const o of r)l.setEdge(o.source,o.target);return Rv.layout(l),e.map(o=>{const d=l.node(o.id);return{...o,position:{x:(d?.x??0)-Im/2,y:(d?.y??0)-$m/2}}})}function cz(e,r){const s=new Map,l=new Map;for(const c of e)l.set(c.id,c),s.set(c.id,new Set);for(const c of r)s.get(c.source)?.add(c.target),s.get(c.target)?.add(c.source);const o=new Set,d=[];for(const c of e){if(o.has(c.id))continue;const h=new Set,m=[c.id];for(;m.length>0;){const f=m.pop();if(!o.has(f)){o.add(f),h.add(f);for(const x of s.get(f)??[])o.has(x)||m.push(x)}}d.push({nodes:e.filter(f=>h.has(f.id)),edges:r.filter(f=>h.has(f.source)&&h.has(f.target))})}return d}function dz(e,r){if(e.length===0)return[];const s=cz(e,r);if(s.length===1)return $v(e,r);const l=s.map(g=>{const p=$v(g.nodes,g.edges);let y=1/0,w=-1/0,N=1/0,E=-1/0;for(const A of p)y=Math.min(y,A.position.x),w=Math.max(w,A.position.x+Im),N=Math.min(N,A.position.y),E=Math.max(E,A.position.y+$m);for(const A of p)A.position.x-=y,A.position.y-=N;return{nodes:p,w:w-y,h:E-N}});l.sort((g,p)=>p.h-g.h);const o=60,d=l.reduce((g,p)=>g+(p.w+o)*(p.h+o),0),c=Math.sqrt(d)*1.1,h=[];let m=0,f=0,x=0;for(const g of l){m>0&&m+g.w>c&&(m=0,f+=x+o,x=0);for(const p of g.nodes)h.push({...p,position:{x:p.position.x+m,y:p.position.y+f}});m+=g.w+o,x=Math.max(x,g.h)}return h}function uz(e,r,s){const l=new Set,o=[r];for(;o.length>0;){const d=o.pop();if(d===s)return!0;if(l.has(d))continue;l.add(d);const c=e.get(d);if(c?.blockedBy)for(const h of c.blockedBy)o.push(h)}return!1}const ho=[{id:"todo",label:"To Do",statuses:new Set(["pending"]),color:{bg:"bg-blue-500/10",border:"border-blue-500/30",text:"text-blue-500"}},{id:"in_progress",label:"In Progress",statuses:new Set(["in_progress","blocked"]),color:{bg:"bg-amber-500/10",border:"border-amber-500/30",text:"text-amber-600"}},{id:"review",label:"In Review",statuses:new Set(["review"]),color:{bg:"bg-brand-500/10",border:"border-brand-500/30",text:"text-brand-500"}},{id:"done",label:"Done",statuses:new Set(["completed","failed","rejected","cancelled"]),color:{bg:"bg-green-500/10",border:"border-green-500/30",text:"text-green-600"}}],em=new Set(ho.map(e=>e.id)),fz=1440*60*1e3,Bv=e=>e.status==="completed"&&e.updatedAt&&Date.now()-new Date(e.updatedAt).getTime()>fz;function hz({tasks:e,requirements:r=[],agents:s,showArchived:l,onShowArchivedChange:o,onTaskClick:d,onReqClick:c,onDependencyChange:h,selectedTaskId:m,selectedReqId:f}){const x=oz(),[g,p]=v.useState(null),[y,w]=v.useState(null),[N,E]=v.useState(new Set(em)),[A,C]=v.useState(l??!1),k=l??A,S=v.useCallback(ge=>{const ye=typeof ge=="function"?ge(k):ge;C(ye),o?.(ye)},[k,o]);v.useEffect(()=>{l!==void 0&&C(l)},[l]);const O=v.useMemo(()=>e.filter(ge=>Bv(ge)).length,[e]),R=v.useMemo(()=>{const ge=new Set;for(const ye of ho)if(N.has(ye.id))for(const Ce of ye.statuses)ge.add(Ce);return ge},[N]),G=v.useMemo(()=>{const ge=new Set;for(const ye of e)for(const Ce of ho)if(Ce.statuses.has(ye.status)){ge.add(Ce.id);break}for(const ye of r){const Ce=Iv[ye.status];Ce&&ge.add(Ce)}return ho.filter(ye=>ge.has(ye.id))},[e,r]),I=v.useCallback(ge=>{E(ye=>{const Ce=new Set(ye);return Ce.has(ge)?Ce.delete(ge):Ce.add(ge),Ce})},[]),Q=v.useCallback((ge,ye="success")=>{p({msg:ge,type:ye}),setTimeout(()=>p(null),2500)},[]),$=v.useMemo(()=>{const ge=new Map;for(const ye of s)ge.set(ye.id,ye.name);return ge},[s]),F=v.useMemo(()=>{const ge=new Map;for(const ye of e)ge.set(ye.id,ye);return ge},[e]),B=v.useMemo(()=>{const ge=new Map;for(const ye of r)ge.set(ye.id,ye);return ge},[r]),T=x?"#94a3b8":"#6b7280",D=v.useCallback((ge,ye,Ce)=>({id:`${ge}->${ye}`,source:ge,target:ye,animated:Ce==="blocked",markerEnd:{type:ni.ArrowClosed,width:14,height:14,color:Ce==="blocked"?"#ef4444":T},style:{stroke:Ce==="blocked"?"#ef4444":T,strokeWidth:1.5,cursor:"pointer"}}),[T]),{initialNodes:z,initialEdges:_}=v.useMemo(()=>{const ge=e.filter(Te=>R.has(Te.status)&&(k||!Bv(Te))),ye=ge.map(Te=>({id:Te.id,type:"task",data:{task:Te,agentName:Te.assignedAgentId?$.get(Te.assignedAgentId):void 0,selected:Te.id===m},position:{x:0,y:0}})),Ce=new Set(ye.map(Te=>Te.id)),ze=new Set;for(const Te of ho)N.has(Te.id)&&ze.add(Te.id);const tt=r.filter(Te=>{const Ze=Iv[Te.status];return Ze&&ze.has(Ze)});for(const Te of tt){const Ze=`req-${Te.id}`;ye.push({id:Ze,type:"requirement",data:{req:Te,selected:Te.id===f},position:{x:0,y:0}}),Ce.add(Ze)}const Xe=[];for(const Te of ge)if(Te.blockedBy)for(const Ze of Te.blockedBy)Ce.has(Ze)&&Xe.push(D(Ze,Te.id,Te.status));const dt=new Set,wt=(Te,Ze)=>{const xt=`${Te}->${Ze}`;dt.has(xt)||(dt.add(xt),Xe.push({id:xt,source:Te,target:Ze,markerEnd:{type:ni.ArrowClosed,width:14,height:14,color:"#8b5cf6"},style:{stroke:"#8b5cf6",strokeWidth:1.5,strokeDasharray:"4 2"}}))};for(const Te of tt){const Ze=`req-${Te.id}`;for(const xt of Te.taskIds)Ce.has(xt)&&wt(Ze,xt)}for(const Te of ge)if(Te.requirementId){const Ze=`req-${Te.requirementId}`;Ce.has(Ze)&&wt(Ze,Te.id)}return{initialNodes:dz(ye,Xe),initialEdges:Xe}},[e,r,$,F,D,R,N,k,m,f]),[Y,V,J]=tL(z),[U,H,X]=nL(_),L=v.useRef(null),M=v.useRef(!1),q=v.useRef({groupFilter:N,showArchived:k});v.useEffect(()=>{const ge=q.current;(ge.groupFilter!==N||ge.showArchived!==k)&&(M.current=!1,q.current={groupFilter:N,showArchived:k})},[N,k]),v.useEffect(()=>{V(z),H(_),M.current||requestAnimationFrame(()=>{L.current?.fitView({padding:.2,duration:300})})},[z,_,V,H]);const K=v.useCallback(ge=>{ge&&(M.current=!0)},[]),ee=v.useCallback((ge,ye)=>{if(ye.id.startsWith("req-")){const Ce=B.get(ye.id.slice(4));Ce&&c&&c(Ce)}else{const Ce=F.get(ye.id);Ce&&d&&d(Ce)}},[F,B,d,c]),te=v.useCallback(async ge=>{const{source:ye,target:Ce}=ge;if(!ye||!Ce||ye===Ce)return;const ze=F.get(Ce);if(!ze)return;if(ze.blockedBy?.includes(ye)){Q("Dependency already exists","error");return}if(uz(F,ye,Ce)){Q("Cannot add: would create a cycle","error");return}const tt=[...ze.blockedBy??[],ye];try{await re.tasks.update(Ce,{blockedBy:tt}),Q("Dependency added"),h?.()}catch(Xe){Q(`Failed: ${Xe instanceof Error?Xe.message:String(Xe)}`,"error")}},[F,Q,h]),se=v.useCallback((ge,ye)=>{w(ye)},[]),xe=v.useCallback(async()=>{if(!y)return;const ge=F.get(y.target);if(!ge){w(null);return}const ye=(ge.blockedBy??[]).filter(Ce=>Ce!==y.source);try{await re.tasks.update(y.target,{blockedBy:ye}),Q("Dependency removed"),h?.()}catch(Ce){Q(`Failed: ${Ce instanceof Error?Ce.message:String(Ce)}`,"error")}w(null)},[y,F,Q,h]);if(e.length===0)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm",children:"No tasks to display"});const ke=y?F.get(y.source):null,De=y?F.get(y.target):null;return t.jsxs("div",{className:"flex-1 min-h-0 relative",style:{height:"100%"},children:[t.jsxs(eL,{nodes:Y,edges:U,onNodesChange:J,onEdgesChange:X,onNodeClick:ee,onConnect:te,onEdgeClick:se,onMoveEnd:K,onInit:ge=>{L.current=ge},nodeTypes:az,fitView:!0,minZoom:.3,maxZoom:2,proOptions:{hideAttribution:!0},connectionLineStyle:{stroke:"#818cf8",strokeWidth:2,strokeDasharray:"6 3"},children:[t.jsx(iL,{color:x?"#cbd5e1":"#374151",gap:20,size:1}),t.jsx(mL,{showInteractive:!1,className:"!bg-surface-secondary !border-border-default !shadow-xl [&>button]:!bg-surface-elevated [&>button]:!border-border-default [&>button]:!text-fg-secondary [&>button:hover]:!bg-surface-overlay"}),t.jsx(EL,{nodeColor:ge=>{const ye=ge.data?.task,Ce=ye?.status;return ye?.taskType==="scheduled"?"#06b6d4":Ce==="completed"||Ce==="accepted"?"#10b981":Ce==="in_progress"?"#f59e0b":Ce==="blocked"||Ce==="failed"?"#ef4444":x?"#94a3b8":"#6b7280"},maskColor:x?"rgba(255,255,255,0.7)":"rgba(0,0,0,0.7)",className:"!bg-surface-secondary !border-border-default"})]}),t.jsxs("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 px-3 py-1.5 bg-surface-secondary/90 border border-border-default rounded-lg backdrop-blur-sm z-10 flex flex-col items-center gap-1",children:[t.jsxs("div",{className:"flex items-center gap-1 flex-wrap justify-center",children:[G.map(ge=>{const ye=N.has(ge.id);return t.jsx("button",{onClick:()=>I(ge.id),className:`text-[10px] px-1.5 py-0.5 rounded border transition-colors ${ye?`${ge.color.bg} ${ge.color.border} ${ge.color.text}`:"bg-surface-elevated/50 border-border-default/50 text-fg-tertiary"}`,children:ge.label},ge.id)}),O>0&&t.jsxs("button",{onClick:()=>S(ge=>!ge),className:`text-[10px] px-1.5 py-0.5 rounded border transition-colors ${k?"bg-surface-overlay/60 border-gray-500/50 text-fg-secondary":"bg-surface-elevated/50 border-border-default/50 text-fg-tertiary"}`,children:["Archived ",O]}),N.size<em.size&&t.jsx("button",{onClick:()=>{E(new Set(em)),S(!1)},className:"text-[10px] text-fg-tertiary hover:text-fg-secondary px-1",children:"Reset"})]}),t.jsx("div",{className:"text-[10px] text-fg-tertiary select-none",children:"Drag to add dependency · Click edge to remove"})]}),g&&t.jsx("div",{className:`absolute bottom-4 left-1/2 -translate-x-1/2 px-4 py-2 rounded-lg text-xs font-medium shadow-xl border backdrop-blur-sm transition-opacity ${g.type==="success"?"bg-green-500/15 border-green-500/30 text-green-600":"bg-red-500/15 border-red-500/30 text-red-600"}`,children:g.msg}),y&&t.jsx("div",{className:"absolute inset-0 bg-black/40 flex items-center justify-center z-50 backdrop-blur-[2px]",onClick:()=>w(null),children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 shadow-2xl max-w-sm",onClick:ge=>ge.stopPropagation(),children:[t.jsx("h4",{className:"text-sm font-semibold text-fg-primary mb-2",children:"Remove dependency?"}),t.jsxs("p",{className:"text-xs text-fg-secondary mb-4 leading-relaxed",children:[t.jsx("span",{className:"text-fg-secondary font-medium",children:De?.title??y.target.slice(-8)})," ","will no longer be blocked by"," ",t.jsx("span",{className:"text-fg-secondary font-medium",children:ke?.title??y.source.slice(-8)}),"."]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{onClick:()=>w(null),className:"px-3 py-1.5 text-xs text-fg-secondary hover:text-fg-primary bg-surface-elevated rounded-lg border border-border-default hover:border-gray-600 transition-colors",children:"Cancel"}),t.jsx("button",{onClick:xe,className:"px-3 py-1.5 text-xs text-red-500 bg-red-600/20 hover:bg-red-600/30 rounded-lg border border-red-500/40 hover:border-red-500/60 transition-colors",children:"Remove"})]})]})})]})}function wN({orgId:e,onCreated:r,onClose:s}){const[l,o]=v.useState(""),[d,c]=v.useState(""),[h,m]=v.useState(""),[f,x]=v.useState("main"),[g,p]=v.useState([]),[y,w]=v.useState([]),[N,E]=v.useState(!1),[A,C]=v.useState(""),[k,S]=v.useState(!1),O=ks();v.useEffect(()=>{re.teams.list().then(I=>w(I.teams)).catch(()=>{})},[]);const R=v.useCallback(async I=>{if(I?.preventDefault(),S(!0),!(!l.trim()||N)){E(!0),C("");try{const Q=h.trim()?[{url:h.trim(),defaultBranch:f.trim()||"main"}]:[],$=await re.projects.create({name:l.trim(),description:d.trim()||void 0,repositories:Q.length>0?Q:void 0,teamIds:g.length>0?g:void 0,orgId:e??"default"});r($.project)}catch(Q){C(Q instanceof Error?Q.message:"Failed to create project")}E(!1)}},[l,d,h,f,g,e,N,r]),G=k&&!l.trim();return ix.createPortal(t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50 p-3",onClick:s,children:t.jsxs("form",{className:`bg-surface-secondary border border-border-default rounded-xl p-6 shadow-2xl max-h-[90dvh] overflow-y-auto ${O?"w-full":"w-[520px]"}`,onClick:I=>I.stopPropagation(),onSubmit:R,children:[t.jsx("h3",{className:"text-base font-semibold mb-5",children:"New Project"}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-secondary mb-1.5 font-medium",children:"Project Name *"}),t.jsx("input",{value:l,onChange:I=>{o(I.target.value),C("")},onBlur:()=>S(!0),placeholder:"e.g. Mobile App, Website Redesign",className:`input ${G?"!border-red-500 focus:!ring-red-500/25":""}`,autoFocus:!O}),G&&t.jsx("p",{className:"text-[11px] text-red-400 mt-1",children:"Project name is required"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-secondary mb-1.5 font-medium",children:"Description"}),t.jsx("textarea",{value:d,onChange:I=>c(I.target.value),placeholder:"What is this project about?",className:"input",rows:3})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-secondary mb-1.5 font-medium",children:"Assign Teams"}),y.length===0?t.jsx("div",{className:"text-[11px] text-fg-tertiary py-2",children:"No teams available"}):t.jsx("div",{className:"space-y-1 max-h-32 overflow-y-auto",children:y.map(I=>{const Q=g.includes(I.id);return t.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg-secondary cursor-pointer hover:text-fg-primary py-0.5",children:[t.jsx("input",{type:"checkbox",checked:Q,onChange:()=>p($=>Q?$.filter(F=>F!==I.id):[...$,I.id]),className:"accent-brand-500"}),t.jsx("span",{className:"truncate",children:I.name})]},I.id)})})]}),t.jsxs("div",{className:"grid grid-cols-[1fr_auto] gap-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-secondary mb-1.5 font-medium",children:"Repository URL"}),t.jsx("input",{value:h,onChange:I=>m(I.target.value),placeholder:"https://github.com/org/repo (optional)",className:"input"})]}),h.trim()&&t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-secondary mb-1.5 font-medium",children:"Branch"}),t.jsx("input",{value:f,onChange:I=>x(I.target.value),placeholder:"main",className:"input !w-24"})]})]}),A&&t.jsx("div",{className:"text-xs text-red-400 bg-red-500/10 rounded-lg px-3 py-2",children:A}),t.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[t.jsx("button",{type:"button",onClick:s,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated text-fg-secondary",children:"Cancel"}),t.jsx("button",{type:"submit",disabled:!l.trim()||N,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-40 rounded-lg text-white",children:N?"Creating...":"Create Project"})]})]})]})}),document.body)}function ii(e,r,s){if(!e)return null;const l=r.find(d=>d.id===e);if(l)return l.name;const o=s.find(d=>d.id===e);return o?o.name:e==="anonymous"?"Admin":null}function mz({value:e,onSave:r,className:s,placeholder:l}){const[o,d]=v.useState(!1),[c,h]=v.useState(e),m=v.useRef(null);v.useEffect(()=>{h(e)},[e]),v.useEffect(()=>{o&&m.current?.focus()},[o]);const f=async()=>{d(!1);const x=c.trim();if(x&&x!==e)try{await r(x)}catch{h(e)}else h(e)};return o?t.jsx("input",{ref:m,value:c,onChange:x=>h(x.target.value),onBlur:()=>{f()},onKeyDown:x=>{x.key==="Enter"&&f(),x.key==="Escape"&&(h(e),d(!1))},className:`bg-transparent border-b border-brand-500/50 outline-none ${s??""}`,placeholder:l}):t.jsx("span",{onClick:()=>d(!0),className:`cursor-pointer hover:border-b hover:border-gray-600 transition-colors ${s??""}`,title:"Click to edit",children:e||t.jsx("span",{className:"text-fg-tertiary italic",children:l??"Click to edit"})})}function xz({value:e,onSave:r,className:s,placeholder:l}){const[o,d]=v.useState(!1),[c,h]=v.useState(e),m=v.useRef(null);v.useEffect(()=>{h(e)},[e]),v.useEffect(()=>{o&&m.current&&(m.current.focus(),m.current.style.height="auto",m.current.style.height=m.current.scrollHeight+"px")},[o]);const f=async()=>{d(!1);const x=c.trim();if(x!==e)try{await r(x)}catch{h(e)}else h(e)};return o?t.jsx("textarea",{ref:m,value:c,onChange:x=>{h(x.target.value),x.target.style.height="auto",x.target.style.height=x.target.scrollHeight+"px"},onBlur:()=>{f()},onKeyDown:x=>{x.key==="Escape"&&(h(e),d(!1))},className:`bg-transparent border border-brand-500/30 rounded-lg p-2 outline-none resize-none w-full ${s??""}`,placeholder:l,rows:2}):t.jsx("p",{onClick:()=>d(!0),className:`cursor-pointer hover:bg-surface-elevated/50 rounded-lg transition-colors px-2 py-1 -mx-2 -my-1 ${s??""}`,title:"Click to edit",children:e||t.jsx("span",{className:"text-fg-tertiary italic",children:l??"Add a description…"})})}const gz=/^\[([^\]]+?)(?:\s+by\s+([^\]]+))?\]\s*([\s\S]*)$/;function NN(e){const r=e.match(gz);return r?{timestamp:r[1].trim(),author:r[2]?.trim()??"System",content:r[3].trim()}:{timestamp:"",author:"",content:e}}function pz(e){if(!e)return"";const r=e.match(/^(\d{4})[/-](\d{2})[/-](\d{2})\s+(\d{2}):(\d{2})(?::(\d{2}))?/);if(!r)return e;const s=new Date,l=+r[1],o=+r[2]-1,d=+r[3],c=+r[4],h=+r[5],m=new Date(l,o,d,c,h),f=s.getTime()-m.getTime();return f<6e4?"just now":f<36e5?`${Math.floor(f/6e4)}m ago`:f<864e5?`${Math.floor(f/36e5)}h ago`:f<6048e5?`${Math.floor(f/864e5)}d ago`:`${l}-${String(o+1).padStart(2,"0")}-${String(d).padStart(2,"0")}`}const Hv=[{bg:"bg-brand-600/30",text:"text-brand-500",border:"border-brand-500/30"},{bg:"bg-blue-600/30",text:"text-blue-400",border:"border-blue-500/30"},{bg:"bg-green-600/30",text:"text-green-400",border:"border-green-500/30"},{bg:"bg-amber-600/30",text:"text-amber-400",border:"border-amber-500/30"},{bg:"bg-purple-600/30",text:"text-purple-400",border:"border-purple-500/30"},{bg:"bg-pink-600/30",text:"text-pink-400",border:"border-pink-500/30"}];function bz(e){let r=0;for(let s=0;s<e.length;s++)r=(r<<5)-r+e.charCodeAt(s)|0;return Hv[Math.abs(r)%Hv.length]}function yz({note:e,compact:r}){const s=NN(e),l=bz(s.author||"System"),o=s.author?s.author.split(/[\s_-]+/).map(h=>h[0]).join("").slice(0,2).toUpperCase():"SY",d=pz(s.timestamp),c=!s.author||s.author==="System";return r?t.jsxs("div",{className:"flex gap-2.5 group",children:[t.jsx("div",{className:`w-6 h-6 rounded-full ${l.bg} flex items-center justify-center text-[9px] font-bold ${l.text} shrink-0 mt-0.5`,children:o}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-baseline gap-1.5 mb-0.5",children:[t.jsx("span",{className:`text-[11px] font-medium ${c?"text-fg-tertiary":l.text}`,children:s.author||"System"}),d&&t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:d})]}),t.jsx("div",{className:"text-xs text-fg-secondary",children:t.jsx(Zn,{content:s.content,className:"text-xs text-fg-secondary"})})]})]}):t.jsxs("div",{className:"flex gap-3 group",children:[t.jsxs("div",{className:"flex flex-col items-center shrink-0",children:[t.jsx("div",{className:`w-7 h-7 rounded-full ${l.bg} flex items-center justify-center text-[10px] font-bold ${l.text}`,children:o}),t.jsx("div",{className:"w-px flex-1 bg-border-default/60 mt-1.5"})]}),t.jsx("div",{className:"flex-1 min-w-0 pb-4",children:t.jsxs("div",{className:`border ${l.border} rounded-lg overflow-hidden`,children:[t.jsxs("div",{className:`flex items-center gap-2 px-3 py-1.5 ${l.bg} border-b ${l.border}`,children:[t.jsx("span",{className:`text-[11px] font-medium ${c?"text-fg-secondary":l.text}`,children:s.author||"System"}),d&&t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:d})]}),t.jsx("div",{className:"px-3 py-2.5",children:t.jsx(Zn,{content:s.content,className:"text-xs text-fg-secondary"})})]})})]})}const Do=[{id:"failed",label:"Failed",statuses:["failed"],accent:"border-t-red-500",dropStatus:"failed"},{id:"todo",label:"To Do",statuses:["pending"],accent:"border-t-amber-500",dropStatus:"pending"},{id:"in_progress",label:"In Progress",statuses:["in_progress","blocked"],accent:"border-t-brand-500",dropStatus:"in_progress"},{id:"review",label:"In Review",statuses:["review"],accent:"border-t-purple-500",dropStatus:"review"},{id:"done",label:"Done",statuses:["completed"],accent:"border-t-green-500",dropStatus:"completed"},{id:"closed",label:"Closed",statuses:["rejected","cancelled"],accent:"border-t-gray-500",dropStatus:"cancelled"}],kN={pending:{label:"Pending",cls:"bg-amber-500/15 text-amber-600"},blocked:{label:"Blocked",cls:"bg-amber-500/15 text-amber-600"},failed:{label:"Failed",cls:"bg-red-500/15 text-red-500"},rejected:{label:"Rejected",cls:"bg-red-500/15 text-red-500"}},Bm={pending:{label:"Pending",cls:"bg-amber-500/15 text-amber-600"},in_progress:{label:"In Progress",cls:"bg-blue-500/15 text-blue-500"},blocked:{label:"Blocked",cls:"bg-orange-500/15 text-orange-500"},review:{label:"In Review",cls:"bg-purple-500/15 text-purple-500"},completed:{label:"Completed",cls:"bg-green-500/15 text-green-600"},failed:{label:"Failed",cls:"bg-red-500/15 text-red-500"},rejected:{label:"Rejected",cls:"bg-red-500/15 text-red-500"},cancelled:{label:"Cancelled",cls:"bg-gray-500/15 text-fg-tertiary"},archived:{label:"Archived",cls:"bg-gray-500/15 text-fg-tertiary"}},vz={urgent:"border-l-red-500",high:"border-l-amber-500",medium:"border-l-blue-500",low:"border-l-gray-500"},Pv={low:{label:"Low",cls:"bg-gray-500/15 text-fg-tertiary"},medium:{label:"Medium",cls:"bg-blue-500/15 text-blue-500"},high:{label:"High",cls:"bg-amber-500/15 text-amber-600"},urgent:{label:"Urgent",cls:"bg-red-500/15 text-red-500"}},jz=["low","medium","high","urgent"],wz=["pending","in_progress","blocked","review","completed","failed","rejected","cancelled"],Nz=["pending","in_progress","completed","rejected","cancelled"],SN={pending:"bg-amber-400",in_progress:"bg-brand-400",blocked:"bg-amber-400",review:"bg-brand-400",completed:"bg-green-400",failed:"bg-red-400",rejected:"bg-red-400",cancelled:"bg-gray-600",archived:"bg-surface-overlay"};function kz({agent:e,anchorRect:r,onClose:s}){const l=v.useRef(null);v.useEffect(()=>{const c=h=>{l.current&&!l.current.contains(h.target)&&s()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]);const o=e.status==="idle"?"bg-green-400":e.status==="working"?"bg-blue-400 animate-pulse":e.status==="error"?"bg-red-400":"bg-gray-500",d=e.status==="idle"?"Online":e.status==="working"?"Working":e.status==="error"?"Error":e.status==="paused"?"Paused":"Offline";return t.jsxs("div",{ref:l,className:"fixed z-50 w-56 bg-surface-secondary border border-border-default rounded-xl shadow-2xl p-3 space-y-2",style:{top:r.top+4,left:r.left},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-7 h-7 rounded-full bg-brand-500/15 flex items-center justify-center text-[10px] font-bold text-brand-600 shrink-0",children:e.name.slice(0,2).toUpperCase()}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs text-fg-primary font-medium truncate",children:e.name}),t.jsx("div",{className:"text-[10px] text-fg-tertiary",children:e.role}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${o}`}),t.jsx("span",{className:"text-[10px] text-fg-secondary",children:d})]})]})]}),t.jsx("button",{onClick:()=>{s(),jt.navigate("chat",{selectAgent:e.id})},className:"w-full text-center text-[10px] text-brand-500 hover:text-brand-500 border border-border-default hover:border-gray-600 rounded-lg py-1 transition-colors",children:"View Profile →"})]})}function yo({comment:e,agents:r}){const s=e.authorType==="agent"||e.authorType==="system",l=new Date(e.createdAt),o=l.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),d=l.toLocaleDateString([],{month:"short",day:"numeric"}),[c,h]=v.useState(null),m=v.useCallback((f,x)=>{const g=r.find(p=>p.name.toLowerCase()===f.toLowerCase());if(g){const p=x.target.getBoundingClientRect();h({agent:g,top:p.bottom,left:p.left})}},[r]);return t.jsxs("div",{className:"flex gap-2.5 group py-1",children:[t.jsx("div",{className:`flex-shrink-0 w-6 h-6 rounded-full flex items-center justify-center text-[10px] mt-0.5 ${s?"bg-indigo-500/20 text-indigo-400":"bg-blue-500/20 text-blue-400"}`,children:e.authorName.slice(0,2).toUpperCase()}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-baseline gap-1.5 mb-0.5",children:[t.jsx("span",{className:`text-[11px] font-medium ${s?"text-indigo-400":"text-blue-400"}`,children:e.authorName}),t.jsxs("span",{className:"text-fg-tertiary text-[10px]",children:[d," ",o]})]}),t.jsx(Zn,{content:e.content,className:"text-xs text-fg-primary",onMentionClick:m}),e.attachments?.map((f,x)=>f.type==="image"?t.jsx("img",{src:f.url,alt:f.name,className:"mt-1 max-w-[200px] rounded"},x):null)]}),c&&t.jsx(kz,{agent:c.agent,anchorRect:{top:c.top,left:c.left},onClose:()=>h(null)})]})}function Sz({task:e,agents:r,users:s,authUser:l}){const[o,d]=v.useState([]);v.useEffect(()=>{re.tasks.getComments(e.id).then(m=>d(m.comments)).catch(()=>{})},[e.id]),v.useEffect(()=>kn.on("task:comment",f=>{f.payload?.taskId===e.id&&f.payload.comment&&d(x=>x.some(g=>g.id===f.payload.comment.id)?x:[...x,f.payload.comment])}),[e.id]);const c=v.useMemo(()=>{const m=[];for(const f of e.notes??[]){const x=NN(f);let g;if(x.timestamp){const p=x.timestamp.match(/^(\d{4})[/-](\d{2})[/-](\d{2})\s+(\d{2}):(\d{2})(?::(\d{2}))?/);g=p?new Date(+p[1],+p[2]-1,+p[3],+p[4],+p[5],+(p[6]??0)):new Date(0)}else g=new Date(0);m.push({type:"note",note:f,ts:g})}for(const f of o)m.push({type:"comment",comment:f,ts:new Date(f.createdAt)});return m.sort((f,x)=>f.ts.getTime()-x.ts.getTime()),m},[e.notes,o]),h=async(m,f)=>{await re.tasks.addComment(e.id,m,l?.name,void 0,l?.id,f.length>0?f:void 0)};return t.jsxs("div",{className:"mt-5",children:[t.jsx("p",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider mb-3",children:"Activity & Comments"}),t.jsxs("div",{className:"space-y-0.5 mb-3",children:[c.length===0&&t.jsx("div",{className:"text-xs text-fg-tertiary text-center py-6",children:"No activity yet. Post the first comment below."}),c.map((m,f)=>m.type==="note"?t.jsx(yz,{note:m.note,compact:!0},`n-${f}`):t.jsx(yo,{comment:m.comment,agents:r},`c-${m.comment.id}`))]}),t.jsx(yj,{agents:r,onSubmit:h})]})}function Cz({taskId:e,isRunning:r,authUser:s,agents:l}){const[o,d]=v.useState([]),[c,h]=v.useState(new Map),[m,f]=v.useState(new Set),[x,g]=v.useState([]),[p,y]=v.useState(""),[w,N]=v.useState(r),[E,A]=v.useState(!0),[C,k]=v.useState(new Set),[S,O]=v.useState(""),[R,G]=v.useState(!1),[I,Q]=v.useState([]),$=v.useRef(null),F=v.useRef(null);v.useEffect(()=>{N(r)},[r]),v.useEffect(()=>{A(!0),Promise.all([re.tasks.getLogsSummary(e).catch(()=>({rounds:[]})),re.tasks.getComments(e).catch(()=>({comments:[]}))]).then(([X,L])=>{const M=X.rounds;if(d(M),g(L.comments),M.length===0){A(!1);return}const q=M[M.length-1].round;k(new Set([q])),re.tasks.getLogs(e,q).catch(()=>({logs:[]})).then(K=>{h(new Map([[q,K.logs]])),A(!1)})})},[e]);const B=v.useCallback(X=>{c.has(X)||m.has(X)||(f(L=>new Set(L).add(X)),re.tasks.getLogs(e,X).catch(()=>({logs:[]})).then(L=>{h(M=>new Map(M).set(X,L.logs)),f(M=>{const q=new Set(M);return q.delete(X),q})}))},[e,c,m]),T=v.useCallback(X=>{k(L=>{const M=new Set(L);return M.has(X)?M.delete(X):(M.add(X),c.has(X)||B(X)),M})},[c,B]);v.useEffect(()=>{const X=kn.on("task:log",q=>{const K=q.payload;if(K.taskId!==e)return;const ee={id:K.id,taskId:K.taskId,agentId:K.agentId,seq:K.seq,type:K.logType,content:K.content,metadata:K.metadata,executionRound:K.executionRound,createdAt:K.createdAt},te=ee.executionRound??1;d(se=>se.find(ke=>ke.round===te)?se:[...se,{round:te,logCount:0,toolCount:0,firstAt:ee.createdAt,lastAt:ee.createdAt,status:"running"}]),k(se=>se.has(te)?se:new Set(se).add(te)),h(se=>{const xe=se.get(te)??[];return ee.id&&xe.some(ke=>ke.id===ee.id)?se:new Map(se).set(te,[...xe,ee])}),ee.type==="text"&&y(""),ee.type==="status"&&(ee.content==="started"||ee.content==="resumed"?N(!0):["completed","failed","cancelled","execution_finished"].includes(ee.content)&&(N(!1),d(se=>se.map(xe=>xe.round===te?{...xe,status:ee.content}:xe)))),ee.type==="error"&&N(!1)}),L=kn.on("task:log:delta",q=>{const K=q.payload;K.taskId===e&&y(ee=>ee+K.text)}),M=kn.on("task:comment",q=>{const K=q.payload;if(K.taskId!==e)return;const ee=K.comment;g(te=>te.some(se=>se.id===ee.id)?te:[...te,ee])});return()=>{X(),L(),M()}},[e]);const D=v.useMemo(()=>{const X=[];for(const[,L]of c)X.push(...L);return X.sort((L,M)=>L.seq-M.seq),X},[c]),z=v.useMemo(()=>D.map(X=>jd(X)),[D]),_=o.length>1,Y=X=>{const L=X.target.files;if(L){for(const M of Array.from(L)){if(!M.type.startsWith("image/"))continue;const q=new FileReader;q.onload=()=>{Q(K=>[...K,{type:"image",url:q.result,name:M.name}])},q.readAsDataURL(M)}X.target.value=""}},V=async()=>{if(!(!S.trim()&&I.length===0)){G(!0);try{const X=await re.tasks.addComment(e,S,s?.name,I.length>0?I:void 0,s?.id);X.comment&&g(L=>L.some(M=>M.id===X.comment.id)?L:[...L,X.comment]),O(""),Q([])}catch{}G(!1)}},J=t.jsxs("div",{className:"border-t border-border-default px-4 py-3 sticky bottom-0 bg-surface-secondary z-10",children:[I.length>0&&t.jsx("div",{className:"flex gap-2 mb-2 flex-wrap",children:I.map((X,L)=>t.jsxs("div",{className:"relative group",children:[t.jsx("img",{src:X.url,alt:X.name,className:"w-16 h-16 object-cover rounded-lg border border-border-default"}),t.jsx("button",{onClick:()=>Q(M=>M.filter((q,K)=>K!==L)),className:"absolute -top-1 -right-1 w-4 h-4 rounded-full bg-red-600 text-white text-[10px] flex items-center justify-center opacity-0 group-hover:opacity-100",children:"×"})]},L))}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{type:"text",value:S,onChange:X=>O(X.target.value),onKeyDown:X=>{X.key==="Enter"&&!X.shiftKey&&(X.preventDefault(),V())},placeholder:"Add a comment or instruction…",className:"flex-1 px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-blue-500 outline-none text-fg-primary placeholder-gray-600"}),t.jsx("input",{type:"file",ref:$,accept:"image/*",multiple:!0,onChange:Y,className:"hidden"}),t.jsx("button",{onClick:()=>$.current?.click(),className:"px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-fg-secondary hover:text-fg-primary text-sm",title:"Attach image",children:"📎"}),t.jsx("button",{onClick:()=>{V()},disabled:R||!S.trim()&&I.length===0,className:"px-3 py-1.5 bg-blue-600 hover:bg-blue-500 rounded-lg text-white text-xs disabled:opacity-50",children:"Send"})]})]});if(E)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-xs text-fg-tertiary",children:"Loading logs…"});if(o.length===0&&!p)return t.jsxs("div",{className:"flex flex-col flex-1",children:[t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsxs("div",{className:"text-center text-fg-tertiary",children:[t.jsx("div",{className:"text-2xl mb-2",children:"📋"}),t.jsxs("div",{className:"text-xs",children:["No execution logs yet.",t.jsx("br",{}),'Click "Run with Agent" to start.']})]})}),J]});if(!_){const X=z.map(q=>Ed(q)).filter(q=>q!==null),L=Cd(X),M=[...L.map(q=>({kind:"entry",entry:q,ts:q.timestamp?new Date(q.timestamp).getTime():0})),...x.map(q=>({kind:"comment",comment:q,ts:new Date(q.createdAt).getTime()}))];return M.sort((q,K)=>q.ts-K.ts),t.jsxs("div",{className:"flex flex-col flex-1",children:[t.jsxs("div",{className:"px-4 py-3 flex-1 space-y-0.5",children:[M.map((q,K)=>q.kind==="comment"?t.jsx(yo,{comment:q.comment,agents:l},`c-${q.comment.id}`):t.jsx(Td,{entry:q.entry,showTime:!0,isLast:K===M.length-1},`e-${K}`)),w&&p&&t.jsx(jm,{content:p}),w&&!p&&L.length>0&&t.jsx(vm,{})]}),J]})}const U=(X,L)=>{const M=X.firstAt?new Date(X.firstAt).getTime():0,q=L?.firstAt?new Date(L.firstAt).getTime():1/0;return x.filter(K=>{const ee=new Date(K.createdAt).getTime();return ee>=M&&ee<q})},H=o.length>0?x.filter(X=>new Date(X.createdAt).getTime()<new Date(o[0].firstAt).getTime()):[];return t.jsxs("div",{className:"flex flex-col flex-1",children:[t.jsx("div",{ref:F}),t.jsxs("div",{className:"px-4 py-3 flex-1 space-y-2",children:[H.length>0&&t.jsx("div",{className:"space-y-0.5",children:H.map(X=>t.jsx(yo,{comment:X,agents:l},X.id))}),o.map((X,L)=>{const M=C.has(X.round),q=X.round===o[o.length-1].round,K=c.get(X.round),ee=m.has(X.round),te=U(X,o[L+1]),se=X.status==="completed"||X.status==="execution_finished"?"✅":X.status==="failed"?"❌":X.status==="cancelled"?"⏹":"🔄",xe=X.lastAt&&X.firstAt?Math.max(0,new Date(X.lastAt).getTime()-new Date(X.firstAt).getTime()):0,ke=xe>=6e4?`${Math.floor(xe/6e4)}m ${Math.floor(xe%6e4/1e3)}s`:xe>=1e3?`${Math.floor(xe/1e3)}s`:"";return t.jsxs("div",{className:"border border-border-default/50 rounded-lg overflow-hidden",children:[t.jsxs("button",{onClick:()=>T(X.round),className:"w-full flex items-center justify-between px-3 py-2 bg-surface-elevated/30 hover:bg-surface-elevated/50 transition-colors",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm",children:se}),t.jsxs("span",{className:"text-xs text-fg-secondary font-medium",children:["Round #",X.round]}),te.length>0&&t.jsxs("span",{className:"text-[10px] text-blue-400",children:["💬 ",te.length]}),q&&w&&t.jsxs("svg",{className:"w-3 h-3 animate-spin text-brand-500",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[X.toolCount," tool",X.toolCount!==1?"s":""]}),ke&&t.jsx("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:ke}),t.jsx("svg",{className:`w-3 h-3 text-fg-tertiary transition-transform ${M?"rotate-180":""}`,viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]})]}),M&&t.jsxs("div",{className:"px-3 py-1.5 space-y-0.5",children:[ee&&t.jsxs("div",{className:"text-xs text-fg-tertiary py-2 text-center",children:["Loading round #",X.round,"…"]}),K&&(()=>{const ge=K.map(ze=>jd(ze)).map(ze=>Ed(ze)).filter(ze=>ze!==null),Ce=[...Cd(ge).map(ze=>({kind:"entry",entry:ze,ts:ze.timestamp?new Date(ze.timestamp).getTime():0})),...te.map(ze=>({kind:"comment",comment:ze,ts:new Date(ze.createdAt).getTime()}))];return Ce.sort((ze,tt)=>ze.ts-tt.ts),Ce.map((ze,tt)=>ze.kind==="comment"?t.jsx(yo,{comment:ze.comment,agents:l},`c-${ze.comment.id}`):t.jsx(Td,{entry:ze.entry,showTime:!0,isLast:tt===Ce.length-1},`e-${tt}`))})(),q&&w&&p&&t.jsx(jm,{content:p}),q&&w&&!p&&!ee&&t.jsx(vm,{})]})]},X.round)})]}),J]})}function Ez({filePath:e,onClose:r}){const[s,l]=v.useState(null),[o,d]=v.useState(null),[c,h]=v.useState(!0);v.useEffect(()=>{h(!0),d(null),re.files.preview(e).then(f=>l(f)).catch(f=>d(String(f))).finally(()=>h(!1))},[e]);const m=e.split("/").pop()??e;return t.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",onClick:r,children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl w-[720px] max-w-[92vw] max-h-[85vh] flex flex-col shadow-2xl",onClick:f=>f.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border-default shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsxs("svg",{className:"w-4 h-4 text-fg-tertiary shrink-0",viewBox:"0 0 16 16",fill:"currentColor",children:[t.jsx("path",{d:"M3 1h7l4 4v10H3V1zm7 1H4v12h10V5.5L10 2z"}),t.jsx("path",{d:"M10 1v4h4",fill:"none",stroke:"currentColor",strokeWidth:"1"})]}),t.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:m})]}),t.jsx("button",{onClick:r,className:"text-fg-tertiary hover:text-fg-secondary text-lg shrink-0 ml-3",children:"×"})]}),t.jsx("div",{className:"px-4 py-1 border-b border-border-default/60",children:t.jsx("p",{className:"text-[10px] text-fg-tertiary font-mono truncate",children:e})}),t.jsxs("div",{className:"flex-1 overflow-auto min-h-0 p-5",children:[c&&t.jsx("div",{className:"text-sm text-fg-tertiary text-center py-8",children:"Loading..."}),o&&t.jsx("div",{className:"text-sm text-red-500 text-center py-8",children:o}),s&&s.type==="image"&&t.jsx("div",{className:"flex justify-center",children:t.jsx("img",{src:`data:${s.mimeType};base64,${s.content}`,alt:s.name,className:"max-w-full max-h-[60vh] rounded-lg"})}),s&&s.type==="markdown"&&t.jsx(Zn,{content:s.content,className:"text-sm text-fg-secondary leading-relaxed"}),s&&s.type==="text"&&t.jsx("pre",{className:"text-xs text-fg-secondary font-mono whitespace-pre-wrap break-words bg-surface-primary/50 rounded-lg p-4 leading-relaxed",children:s.content})]})]})})}function Tz({task:e,agents:r,projects:s,requirements:l,allTasks:o,users:d,onClose:c,onRefresh:h,authUser:m}){const[f,x]=v.useState([]),[g,p]=v.useState(""),[y,w]=v.useState(!1),[N,E]=v.useState(!1),[A,C]=v.useState(null),[k,S]=v.useState(null),[O,R]=v.useState(!1),[G,I]=v.useState("details"),Q=v.useRef(null),[$,F]=v.useState("none"),B=v.useCallback(je=>{I(je),requestAnimationFrame(()=>{Q.current?.scrollTo({top:0,behavior:"instant"})})},[]);v.useEffect(()=>{const je=Q.current;if(!je)return;const Pe=()=>{const{scrollTop:Nt,scrollHeight:ut,clientHeight:Wt}=je;if(!(ut>Wt+50)){F("none");return}const Ct=Nt<30,de=Nt+Wt>=ut-30;F(Ct?"top":de?"bottom":"middle")};Pe(),je.addEventListener("scroll",Pe,{passive:!0});const vt=new ResizeObserver(Pe);return vt.observe(je),()=>{je.removeEventListener("scroll",Pe),vt.disconnect()}},[G]);const[T,D]=v.useState(!1),[z,_]=v.useState(null),[Y,V]=v.useState(null),[J,U]=v.useState(!1),[H,X]=v.useState(e.description),[L,M]=v.useState(!1),[q,K]=v.useState(""),[ee,te]=v.useState(1),[se,xe]=v.useState(!1),ke=ks(),De=20,ge=v.useCallback(async()=>{try{const je=await re.tasks.listSubtasks(e.id);x(je.subtasks)}catch{}},[e.id]);v.useEffect(()=>{ge()},[ge]);const ye=async je=>{if(!O){R(!0);try{await je(),h(),await ge()}catch(Pe){_(String(Pe).replace("Error: ",""))}finally{R(!1)}}},Ce=je=>ye(()=>re.tasks.update(e.id,{priority:je})),ze=je=>ye(()=>re.tasks.assign(e.id,je||null)),tt=je=>ye(()=>re.tasks.update(e.id,{projectId:je||null})),Xe=async()=>{if(!O){R(!0);try{await re.tasks.pause(e.id),h()}finally{R(!1)}}},dt=async()=>{if(!T){D(!0),_(null),B("logs");try{await re.tasks.resume(e.id),h()}catch(je){_(String(je).replace("Error: API error: 400","Server error").replace("Error: ",""))}finally{D(!1)}}},wt=async()=>{g.trim()&&(await re.tasks.createSubtask(e.id,g.trim()),p(""),w(!1),ge(),h())},ae=async je=>{je.status==="completed"?await re.tasks.cancelSubtask(e.id,je.id):await re.tasks.completeSubtask(e.id,je.id),ge(),h()},Te=async je=>{await re.tasks.deleteSubtask(e.id,je.id),C(null),ge(),h()},Ze=async()=>{if(!O){R(!0);try{await re.tasks.updateStatus(e.id,"pending"),h()}finally{R(!1)}}},xt=async()=>{if(!O){R(!0),_(null),B("logs");try{await re.tasks.retry(e.id),h()}catch(je){_(String(je).replace("Error: API error: 400","Server error").replace("Error: ",""))}finally{R(!1)}}},dn=async()=>{if(!T){D(!0),_(null),B("logs");try{await re.tasks.runNow(e.id),h()}catch(je){_(String(je).replace("Error: API error: 400","Server error").replace("Error: ","")),h()}finally{D(!1)}}},we=v.useRef(h);we.current=h,v.useEffect(()=>kn.on("task:update",Pe=>{Pe.payload.taskId===e.id&&(ge(),we.current())}),[e.id,ge]);const Re=f.filter(je=>je.status==="completed").length,qe=e.status==="in_progress",et=e.status==="blocked",nt=e.status==="completed",zt=e.status==="failed",Yt=e.status==="cancelled",Lt=e.status==="archived",Tt=nt||zt||Yt||Lt,qt=e.taskType==="scheduled"&&!!e.scheduleConfig,yt=qt&&!!e.scheduleConfig?.paused,sn=s.find(je=>je.id===e.projectId),Xt=l.find(je=>je.id===e.requirementId);return r.find(je=>je.id===e.assignedAgentId),t.jsxs("div",{className:"flex flex-col h-full overflow-hidden bg-surface-secondary",children:[t.jsxs("div",{className:"flex items-start justify-between px-6 pt-5 pb-3 border-b border-border-default shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1 pr-4",children:[ke&&t.jsx("button",{onClick:c,className:"text-fg-secondary hover:text-fg-primary transition-colors p-1 -ml-1 shrink-0",children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"15 18 9 12 15 6"})})}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap flex-1 min-w-0",children:[t.jsx("h3",{className:"text-base font-semibold leading-snug truncate",children:e.title}),(()=>{const je=Bm[e.status];return je?t.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full font-medium whitespace-nowrap ${je.cls}`,children:je.label}):t.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-medium bg-gray-500/15 text-fg-tertiary whitespace-nowrap",children:e.status.replace(/_/g," ")})})()]})]}),!ke&&t.jsx("button",{onClick:c,className:"text-fg-tertiary hover:text-fg-secondary text-lg shrink-0",children:"×"})]}),t.jsxs("div",{className:"flex gap-1 px-6 pt-2 pb-0 border-b border-border-default shrink-0 bg-surface-secondary",children:[t.jsx("button",{onClick:()=>B("details"),className:`px-3 py-1.5 text-xs rounded-t-md transition-colors ${G==="details"?"bg-surface-elevated text-fg-primary font-medium":"text-fg-tertiary hover:text-fg-secondary"}`,children:"Details"}),t.jsxs("button",{onClick:()=>B("logs"),className:`px-3 py-1.5 text-xs rounded-t-md transition-colors flex items-center gap-1.5 ${G==="logs"?"bg-surface-elevated text-fg-primary font-medium":"text-fg-tertiary hover:text-fg-secondary"}`,children:["Execution Log",qe&&t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-400 animate-pulse"})]}),t.jsxs("button",{onClick:()=>B("deliverables"),className:`px-3 py-1.5 text-xs rounded-t-md transition-colors flex items-center gap-1.5 ${G==="deliverables"?"bg-surface-elevated text-fg-primary font-medium":"text-fg-tertiary hover:text-fg-secondary"}`,children:["Deliverables",(()=>{const je=(e.deliverables??[]).filter(Pe=>Pe.type!=="branch"&&typeof Pe.reference=="string"&&Pe.reference.length>0).length;return je>0?t.jsx("span",{className:"text-[10px] text-fg-tertiary font-normal",children:je}):null})()]})]}),t.jsxs("div",{className:"flex-1 min-h-0 relative",children:[t.jsxs("div",{ref:Q,className:"h-full overflow-y-auto",children:[G==="logs"&&t.jsxs("div",{className:"overflow-x-hidden min-w-0",children:[z&&t.jsxs("div",{className:"mx-4 mt-3 px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:[t.jsx("span",{className:"font-medium",children:"Failed to start:"})," ",z]}),t.jsx(Cz,{taskId:e.id,isRunning:e.status==="in_progress",authUser:m,agents:r})]}),G==="details"&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-6 pt-4 pb-3 border-b border-border-default",children:J?t.jsxs("div",{className:"space-y-2",children:[t.jsx("textarea",{value:H,onChange:je=>X(je.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none resize-y min-h-[80px]",rows:4,placeholder:"Add a description…"}),t.jsxs("div",{className:"flex gap-2 justify-end",children:[t.jsx("button",{onClick:()=>{U(!1),X(e.description)},className:"px-2.5 py-1 text-xs border border-border-default rounded-lg hover:bg-surface-elevated",children:"Cancel"}),t.jsx("button",{onClick:()=>{ye(()=>re.tasks.update(e.id,{description:H})),U(!1)},disabled:O,className:"px-2.5 py-1 text-xs bg-brand-600 hover:bg-brand-500 rounded-lg text-white disabled:opacity-50",children:"Save"})]})]}):t.jsxs("div",{className:"group relative",children:[e.description?t.jsxs("div",{children:[t.jsx("div",{className:ke&&!se?"line-clamp-3":"",children:t.jsx(Zn,{content:e.description,className:"text-sm text-fg-secondary leading-relaxed"})}),ke&&e.description.length>150&&t.jsx("button",{onClick:()=>xe(!se),className:"text-[11px] text-brand-500 mt-1 font-medium",children:se?"Collapse":"Show more"})]}):t.jsx("p",{className:"text-sm text-fg-tertiary italic",children:"No description"}),t.jsx("button",{onClick:()=>{X(e.description),U(!0)},className:"absolute top-0 right-0 text-[10px] text-fg-tertiary hover:text-brand-500 opacity-0 group-hover:opacity-100 transition-opacity",children:"Edit"})]})}),(sn||Xt)&&t.jsxs("div",{className:"px-6 py-2.5 border-b border-border-default flex flex-wrap items-center gap-2",children:[sn&&t.jsxs("span",{className:"flex items-center gap-1 text-[11px] px-2 py-0.5 bg-brand-500/10 text-brand-500 rounded-full",children:[t.jsx("span",{className:"text-[9px] text-brand-500/60",children:"Project"}),sn.name]}),Xt&&t.jsxs("span",{className:"flex items-center gap-1 text-[11px] px-2 py-0.5 bg-brand-500/10 text-brand-500 rounded-full",children:[t.jsx("span",{className:"text-[9px] text-brand-500/60",children:"Req"}),Xt.title.length>40?Xt.title.slice(0,40)+"…":Xt.title]})]}),t.jsxs("div",{className:"px-6 py-2.5 border-b border-border-default",children:[t.jsx("div",{className:"flex items-center justify-between mb-1.5",children:t.jsx("span",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider",children:"Dependencies"})}),e.blockedBy&&e.blockedBy.length>0?t.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:e.blockedBy.map(je=>{const Pe=o.find(Nt=>Nt.id===je),vt=Pe&&(Pe.status==="completed"||Pe.status==="cancelled");return t.jsxs("span",{className:`inline-flex items-center gap-1 text-[11px] px-2 py-1 rounded-full ${vt?"bg-green-500/10 text-green-600":"bg-amber-500/10 text-amber-600"}`,children:[t.jsx("span",{className:"text-[9px]",children:vt?"✓":"⏳"}),t.jsx("span",{className:`font-mono ${vt?"line-through opacity-60":""}`,children:Pe?Pe.title.slice(0,30):je.slice(-8)}),!Tt&&t.jsx("button",{onClick:async()=>{const Nt=(e.blockedBy??[]).filter(ut=>ut!==je);await re.tasks.update(e.id,{blockedBy:Nt}),h()},className:"ml-0.5 text-current opacity-40 hover:opacity-100 transition-opacity",title:"Remove dependency",children:"×"})]},je)})}):t.jsx("p",{className:"text-[11px] text-fg-tertiary mb-2",children:"No dependencies"}),!Tt&&t.jsxs("select",{value:"",onChange:async je=>{const Pe=je.target.value;if(!Pe)return;const vt=[...e.blockedBy??[],Pe];await re.tasks.update(e.id,{blockedBy:vt}),h()},className:"w-full px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-[11px] text-fg-secondary focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"",children:"+ Add dependency…"}),o.filter(je=>je.id!==e.id&&!(e.blockedBy??[]).includes(je.id)).map(je=>t.jsx("option",{value:je.id,children:je.title},je.id))]})]}),t.jsxs("div",{className:"px-6 py-4 border-b border-border-default/60 space-y-3",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-1",children:"Project"}),t.jsxs("select",{value:e.projectId??"",onChange:je=>{tt(je.target.value)},disabled:O,className:"w-full px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-primary focus:border-brand-500 outline-none disabled:opacity-50 cursor-pointer",children:[t.jsx("option",{value:"",children:"No Project"}),s.map(je=>t.jsx("option",{value:je.id,children:je.name},je.id))]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-1",children:"Requirement"}),t.jsxs("select",{value:e.requirementId??"",onChange:je=>ye(()=>re.tasks.update(e.id,{requirementId:je.target.value||null})),disabled:O,className:"w-full px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-primary focus:border-brand-500 outline-none disabled:opacity-50 cursor-pointer",children:[t.jsx("option",{value:"",children:"No Requirement"}),l.filter(je=>!e.projectId||je.projectId===e.projectId).map(je=>t.jsx("option",{value:je.id,children:je.title},je.id))]})]})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-1",children:"Assignee"}),t.jsxs("select",{value:e.assignedAgentId??"",onChange:je=>{ze(je.target.value)},disabled:O,className:"w-full px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-primary focus:border-brand-500 outline-none disabled:opacity-50 cursor-pointer",children:[t.jsx("option",{value:"",children:"Unassigned"}),r.map(je=>t.jsxs("option",{value:je.id,children:[je.name," (",je.status,")"]},je.id))]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-1",children:"Reviewer"}),t.jsx("select",{value:e.reviewerAgentId??"",onChange:je=>{je.target.value&&je.target.value!==e.reviewerAgentId&&ye(()=>re.tasks.update(e.id,{reviewerAgentId:je.target.value}))},disabled:O,className:"w-full px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-primary focus:border-brand-500 outline-none disabled:opacity-50 cursor-pointer",children:r.map(je=>t.jsx("option",{value:je.id,children:je.name},je.id))})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-1",children:"Priority"}),t.jsxs("select",{value:e.priority,onChange:je=>{Ce(je.target.value)},disabled:O,className:"w-full px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-primary focus:border-brand-500 outline-none disabled:opacity-50 cursor-pointer",children:[t.jsx("option",{value:"low",children:"Low"}),t.jsx("option",{value:"medium",children:"Medium"}),t.jsx("option",{value:"high",children:"High"}),t.jsx("option",{value:"urgent",children:"Urgent"})]})]})]})]}),t.jsxs("div",{className:"px-6 py-3 border-b border-border-default/60 flex flex-wrap items-center gap-x-4 gap-y-1.5 text-[11px] text-fg-tertiary",children:[e.createdBy&&t.jsxs("span",{children:["Created by ",t.jsx("span",{className:"text-fg-secondary",children:ii(e.createdBy,r,d)??e.createdBy})]}),e.updatedBy&&t.jsxs("span",{children:["Updated by ",t.jsx("span",{className:"text-fg-secondary",children:ii(e.updatedBy,r,d)??e.updatedBy})]}),e.createdAt&&t.jsx("span",{children:new Date(e.createdAt).toLocaleDateString()}),e.startedAt&&t.jsxs("span",{children:["Started ",new Date(e.startedAt).toLocaleDateString()]}),e.updatedAt&&t.jsxs("span",{children:["Updated ",new Date(e.updatedAt).toLocaleDateString()]}),e.projectId&&t.jsxs("span",{className:"font-mono text-blue-600/70",children:["task/",e.id]}),(e.executionRound??1)>1&&t.jsxs("span",{className:"text-amber-600",children:["Round ",e.executionRound]})]}),t.jsxs("div",{className:"px-6 py-4",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("span",{className:"text-xs font-semibold text-fg-secondary uppercase tracking-wider",children:["Subtasks ",f.length>0&&t.jsxs("span",{className:"ml-1.5 text-fg-tertiary font-normal normal-case",children:[Re,"/",f.length," done"]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[Re>0&&t.jsx("button",{onClick:()=>E(je=>!je),className:`text-[10px] px-2 py-0.5 rounded-full border transition-colors ${N?"bg-brand-500/15 text-brand-500 border-brand-500/30":"text-fg-tertiary border-border-default hover:text-fg-secondary"}`,children:N?"Hide completed":`Show completed (${Re})`}),t.jsx("button",{onClick:()=>w(!0),className:"text-xs text-brand-500 hover:text-brand-500 transition-colors",children:"+ Add subtask"})]})]}),(()=>{const je=N?f:f.filter(Pe=>Pe.status!=="completed");return je.length>0?t.jsx("div",{className:"space-y-1.5 mb-3",children:je.map(Pe=>t.jsxs("div",{className:"group flex items-center gap-2.5 py-1.5 px-2 rounded-lg hover:bg-surface-elevated/50 transition-colors",children:[t.jsx("button",{onClick:()=>{ae(Pe)},className:`shrink-0 w-4 h-4 rounded border flex items-center justify-center transition-colors ${Pe.status==="completed"?"bg-green-600 border-green-600 text-white":"border-gray-600 hover:border-brand-500"}`,children:Pe.status==="completed"&&t.jsx("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 12 12",fill:"none",children:t.jsx("path",{d:"M2 6l3 3 5-5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),t.jsx("span",{className:`flex-1 text-sm ${Pe.status==="completed"?"line-through text-fg-tertiary":"text-fg-secondary"}`,children:Pe.title}),t.jsx("button",{onClick:()=>C(Pe),className:"shrink-0 opacity-0 group-hover:opacity-100 text-fg-tertiary hover:text-red-500 transition-all text-xs",children:"✕"})]},Pe.id))}):null})(),f.length===0&&!y&&t.jsx("div",{className:"text-xs text-fg-tertiary text-center py-4",children:"No subtasks yet."}),y&&t.jsxs("div",{className:"flex gap-2 mt-2",children:[t.jsx("input",{autoFocus:!0,value:g,onChange:je=>p(je.target.value),onKeyDown:je=>{je.key==="Enter"&&wt(),je.key==="Escape"&&(w(!1),p(""))},placeholder:"Subtask title...",className:"flex-1 px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none"}),t.jsx("button",{onClick:()=>{wt()},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg",children:"Add"}),t.jsx("button",{onClick:()=>{w(!1),p("")},className:"px-3 py-1.5 border border-border-default text-xs rounded-lg hover:bg-surface-elevated",children:"Cancel"})]}),(()=>{const je=(e.deliverables??[]).filter(Nt=>Nt.type!=="branch"&&typeof Nt.reference=="string"&&Nt.reference.length>0);if(je.length===0)return null;const Pe={file:"bg-blue-500/15 text-blue-600",document:"bg-blue-500/15 text-blue-600",report:"bg-brand-500/15 text-brand-500",directory:"bg-green-500/15 text-green-600",url:"bg-brand-500/15 text-brand-500",text:"bg-gray-500/15 text-fg-secondary"},vt=je.slice(0,3);return t.jsxs("div",{className:"mt-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsxs("p",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider",children:["Deliverables ",t.jsxs("span",{className:"text-fg-tertiary font-normal",children:["(",je.length,")"]})]}),je.length>3&&t.jsx("button",{onClick:()=>B("deliverables"),className:"text-[10px] text-brand-500 hover:text-brand-500",children:"View all →"})]}),t.jsx("div",{className:"space-y-1.5",children:vt.map((Nt,ut)=>{const Wt=Nt.reference.split("/").pop()??Nt.reference;return t.jsxs("div",{className:"flex items-start gap-2.5 bg-surface-elevated/60 rounded-lg px-3 py-2 group hover:bg-surface-elevated/80 transition-colors",children:[t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium shrink-0 mt-0.5 ${Pe[Nt.type]??"bg-gray-500/15 text-fg-secondary"}`,children:Nt.type}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("button",{onClick:()=>V(Nt.reference),className:"text-sm text-brand-500 hover:text-brand-500 font-medium truncate block max-w-full text-left hover:underline",title:Nt.reference,children:Wt}),Nt.summary&&t.jsx("p",{className:"text-[11px] text-fg-secondary mt-0.5 line-clamp-2",children:Nt.summary}),t.jsx("p",{className:"text-[10px] text-fg-tertiary font-mono truncate mt-0.5",children:Nt.reference})]})]},ut)})})]})})(),t.jsx(Sz,{task:e,agents:r,users:d,authUser:m})]})]}),G==="deliverables"&&t.jsx("div",{className:"px-6 py-4",children:(()=>{const je=(e.deliverables??[]).filter(ut=>ut.type!=="branch"&&typeof ut.reference=="string"&&ut.reference.length>0);if(je.length===0)return t.jsx("div",{className:"flex items-center justify-center py-12 text-xs text-fg-tertiary",children:"No deliverables yet."});const Pe={file:"bg-blue-500/15 text-blue-600",document:"bg-blue-500/15 text-blue-600",report:"bg-brand-500/15 text-brand-500",directory:"bg-green-500/15 text-green-600",url:"bg-brand-500/15 text-brand-500",text:"bg-gray-500/15 text-fg-secondary"},vt=Math.ceil(je.length/De),Nt=je.slice((ee-1)*De,ee*De);return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("p",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider",children:["Deliverables ",t.jsxs("span",{className:"text-fg-tertiary font-normal",children:["(",je.length,")"]})]}),vt>1&&t.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-fg-tertiary",children:[t.jsx("button",{disabled:ee<=1,onClick:()=>te(ut=>ut-1),className:"px-1.5 py-0.5 rounded bg-surface-elevated hover:bg-surface-overlay disabled:opacity-30",children:"‹"}),t.jsxs("span",{children:[ee,"/",vt]}),t.jsx("button",{disabled:ee>=vt,onClick:()=>te(ut=>ut+1),className:"px-1.5 py-0.5 rounded bg-surface-elevated hover:bg-surface-overlay disabled:opacity-30",children:"›"})]})]}),t.jsx("div",{className:"space-y-1.5",children:Nt.map((ut,Wt)=>{const en=ut.reference.split("/").pop()??ut.reference;return t.jsxs("div",{className:"flex items-start gap-2.5 bg-surface-elevated/60 rounded-lg px-3 py-2 group hover:bg-surface-elevated/80 transition-colors",children:[t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium shrink-0 mt-0.5 ${Pe[ut.type]??"bg-gray-500/15 text-fg-secondary"}`,children:ut.type}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("button",{onClick:()=>V(ut.reference),className:"text-sm text-brand-500 hover:text-brand-500 font-medium truncate block max-w-full text-left hover:underline",title:ut.reference,children:en}),ut.summary&&t.jsx("p",{className:"text-[11px] text-fg-secondary mt-0.5 line-clamp-2",children:ut.summary}),t.jsx("p",{className:"text-[10px] text-fg-tertiary font-mono truncate mt-0.5",children:ut.reference})]})]},Wt)})})]})})()})]}),$!=="none"&&t.jsxs("div",{className:"absolute bottom-3 right-3 flex flex-col gap-1.5 z-10",children:[$!=="top"&&t.jsx("button",{onClick:()=>Q.current?.scrollTo({top:0,behavior:"smooth"}),className:"w-8 h-8 rounded-full bg-surface-overlay/90 border border-border-default shadow-lg flex items-center justify-center text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated transition-colors backdrop-blur-sm",title:"Scroll to top",children:t.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M14.77 12.79a.75.75 0 01-1.06-.02L10 8.832l-3.71 3.938a.75.75 0 11-1.08-1.04l4.25-4.5a.75.75 0 011.08 0l4.25 4.5a.75.75 0 01-.02 1.06z",clipRule:"evenodd"})})}),$!=="bottom"&&t.jsx("button",{onClick:()=>{const je=Q.current;je&&je.scrollTo({top:je.scrollHeight,behavior:"smooth"})},className:"w-8 h-8 rounded-full bg-surface-overlay/90 border border-border-default shadow-lg flex items-center justify-center text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated transition-colors backdrop-blur-sm",title:"Scroll to bottom",children:t.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})})]})]}),qt&&e.scheduleConfig&&t.jsxs("div",{className:`mx-6 mt-3 mb-0 px-4 py-2.5 rounded-lg border text-xs ${yt?"bg-amber-500/5 border-amber-500/20":"bg-brand-500/5 border-brand-500/20"}`,children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("span",{className:yt?"text-amber-600":"text-brand-500",children:yt?"⏸ Schedule Paused":t.jsxs(t.Fragment,{children:[t.jsx("svg",{className:"w-3.5 h-3.5 inline -mt-0.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.3"})})," Scheduled"]})}),t.jsx("span",{className:"text-fg-tertiary",children:"·"}),t.jsx("span",{className:"text-fg-secondary",children:e.scheduleConfig.every?`Every ${e.scheduleConfig.every}`:e.scheduleConfig.cron?`Cron: ${e.scheduleConfig.cron}`:e.scheduleConfig.runAt?"One-shot":"N/A"}),!yt&&e.scheduleConfig.nextRunAt&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-fg-tertiary",children:"·"}),t.jsxs("span",{className:"text-fg-secondary",children:["Next: ",(()=>{const je=new Date(e.scheduleConfig.nextRunAt).getTime()-Date.now();if(je<=0)return"due now";const Pe=Math.floor(je/6e4);if(Pe<60)return`in ${Pe}m`;const vt=Math.floor(Pe/60);return vt<24?`in ${vt}h ${Pe%60}m`:`in ${Math.floor(vt/24)}d ${vt%24}h`})()]})]})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-1 text-fg-tertiary",children:[t.jsxs("span",{children:["Runs: ",e.scheduleConfig.currentRuns??0,e.scheduleConfig.maxRuns!=null?` / ${e.scheduleConfig.maxRuns}`:""]}),e.scheduleConfig.lastRunAt&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"·"}),t.jsxs("span",{children:["Last: ",(()=>{const je=Date.now()-new Date(e.scheduleConfig.lastRunAt).getTime(),Pe=Math.floor(je/6e4);if(Pe<1)return"just now";if(Pe<60)return`${Pe}m ago`;const vt=Math.floor(Pe/60);return vt<24?`${vt}h ${Pe%60}m ago`:`${Math.floor(vt/24)}d ago`})()]})]})]})]}),t.jsx("div",{className:"px-6 py-4 border-t border-border-default flex items-center justify-between gap-2",children:t.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.status==="pending"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>ye(()=>re.tasks.approve(e.id)),disabled:O,className:"px-3 py-1.5 text-xs bg-green-600 hover:bg-green-500 rounded-lg text-white disabled:opacity-50",children:"Approve"}),t.jsx("button",{onClick:()=>ye(()=>re.tasks.reject(e.id)),disabled:O,className:"px-3 py-1.5 text-xs text-red-500 border border-red-500/30 rounded-lg hover:bg-red-500/10 disabled:opacity-50",children:"Reject"})]}),e.status==="review"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{ye(()=>re.tasks.accept(e.id,m?.id))},disabled:O,className:"px-3 py-1.5 text-xs bg-green-600 hover:bg-green-500 rounded-lg text-white disabled:opacity-50",children:"✓ Approve"}),L?t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("input",{type:"text",value:q,onChange:je=>K(je.target.value),onKeyDown:je=>{je.key==="Enter"&&q.trim()&&(ye(()=>re.tasks.revision(e.id,q.trim(),m?.id)),M(!1),K(""))},placeholder:"Revision reason…",autoFocus:!0,className:"px-2 py-1 text-xs bg-surface-elevated border border-amber-500/40 rounded-lg text-fg-primary focus:border-amber-400 outline-none w-48"}),t.jsx("button",{onClick:()=>{ye(()=>re.tasks.revision(e.id,q.trim()||"Revisions needed",m?.id)),M(!1),K("")},disabled:O,className:"px-2.5 py-1 text-xs bg-amber-600 hover:bg-amber-500 rounded-lg text-white disabled:opacity-50",children:"Send"}),t.jsx("button",{onClick:()=>{M(!1),K("")},className:"px-1.5 py-1 text-xs text-fg-secondary hover:text-fg-primary",children:"✕"})]}):t.jsx("button",{onClick:()=>M(!0),disabled:O,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 rounded-lg text-white disabled:opacity-50",children:"↻ Request Revision"})]}),qe&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:()=>{Xe()},disabled:O,className:"px-3 py-1.5 text-xs border border-amber-500/30 text-amber-600 rounded-lg hover:bg-amber-500/10 disabled:opacity-50 flex items-center gap-1",children:[t.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 12 12",fill:"currentColor",children:[t.jsx("rect",{x:"2",y:"1.5",width:"3",height:"9",rx:"0.5"}),t.jsx("rect",{x:"7",y:"1.5",width:"3",height:"9",rx:"0.5"})]}),"Pause"]}),t.jsxs("button",{onClick:()=>{xt()},disabled:O,className:"px-3 py-1.5 text-xs border border-blue-500/30 text-blue-600 rounded-lg hover:bg-blue-500/10 disabled:opacity-50 flex items-center gap-1",children:[t.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[t.jsx("path",{d:"M1.5 6a4.5 4.5 0 1 1 1.3 3.2",strokeLinecap:"round"}),t.jsx("path",{d:"M1 3.5V6h2.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),"Retry"]})]}),et&&t.jsx("button",{onClick:()=>{dt()},disabled:T,className:"px-3 py-1.5 text-xs bg-green-600 hover:bg-green-500 rounded-lg text-white disabled:opacity-50 flex items-center gap-1",children:T?t.jsx(t.Fragment,{children:"Resuming…"}):t.jsxs(t.Fragment,{children:[t.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 12 12",fill:"currentColor",children:t.jsx("path",{d:"M3 1.5v9l7-4.5-7-4.5z"})}),"Resume"]})}),zt&&t.jsxs("button",{onClick:()=>{xt()},disabled:O,className:"px-3 py-1.5 text-xs bg-blue-600 hover:bg-blue-500 rounded-lg text-white disabled:opacity-50 flex items-center gap-1",children:[t.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[t.jsx("path",{d:"M1.5 6a4.5 4.5 0 1 1 1.3 3.2",strokeLinecap:"round"}),t.jsx("path",{d:"M1 3.5V6h2.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),"Retry"]}),qt&&(nt||zt)&&t.jsx("button",{onClick:()=>{dn()},disabled:T,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 rounded-lg text-white disabled:opacity-50 flex items-center gap-1.5",children:T?t.jsx(t.Fragment,{children:"Running…"}):t.jsxs(t.Fragment,{children:[t.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 12 12",fill:"currentColor",children:t.jsx("path",{d:"M3 1.5v9l7-4.5-7-4.5z"})}),"Run Now"]})}),qt&&!qe&&(yt?t.jsx("button",{onClick:()=>{ye(()=>re.tasks.resumeSchedule(e.id))},disabled:O,className:"px-3 py-1.5 text-xs bg-green-600 hover:bg-green-500 rounded-lg text-white disabled:opacity-50",children:"▶ Resume Schedule"}):t.jsx("button",{onClick:()=>{ye(()=>re.tasks.pauseSchedule(e.id))},disabled:O,className:"px-3 py-1.5 text-xs border border-amber-500/30 text-amber-600 rounded-lg hover:bg-amber-500/10 disabled:opacity-50",children:"⏸ Pause Schedule"})),nt&&t.jsx("button",{onClick:()=>ye(()=>re.tasks.archive(e.id)),disabled:O,className:"px-3 py-1.5 text-xs bg-gray-600 hover:bg-gray-500 rounded-lg text-white disabled:opacity-50",children:"Archive"}),Tt&&t.jsx("button",{onClick:()=>{Ze()},disabled:O,className:"px-3 py-1.5 text-xs border border-border-default hover:bg-surface-elevated rounded-lg text-fg-secondary disabled:opacity-50",children:"Reopen"}),!Tt&&e.status!=="pending"&&t.jsx("button",{onClick:async()=>{const{count:je}=await re.tasks.getDependentCount(e.id);je>0?S({dependentCount:je}):ye(()=>re.tasks.cancel(e.id))},disabled:O,className:"px-3 py-1.5 text-xs text-red-500 border border-red-500/30 rounded-lg hover:bg-red-500/10 disabled:opacity-50",children:"Cancel"})]})}),A&&t.jsx(jj,{title:`Delete subtask "${A.title}"?`,message:"This subtask will be permanently deleted.",confirmLabel:"Delete",onConfirm:()=>{Te(A)},onCancel:()=>C(null)}),k&&t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:()=>S(null),children:t.jsxs("div",{className:"bg-surface-default border border-border-default rounded-xl p-6 max-w-md w-full shadow-2xl",onClick:je=>je.stopPropagation(),children:[t.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-2",children:"Cancel Task"}),t.jsxs("p",{className:"text-sm text-fg-secondary mb-4",children:["This task has ",t.jsx("span",{className:"text-amber-600 font-medium",children:k.dependentCount})," dependent task",k.dependentCount>1?"s":""," that ",k.dependentCount>1?"are":"is"," currently blocked by it."]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs("button",{onClick:()=>{S(null),ye(()=>re.tasks.cancel(e.id,!1))},className:"w-full px-4 py-2.5 text-sm bg-surface-elevated border border-border-default rounded-lg hover:bg-surface-overlay text-fg-primary text-left",children:[t.jsx("span",{className:"font-medium",children:"Cancel this task only"}),t.jsx("span",{className:"block text-xs text-fg-tertiary mt-0.5",children:"Dependent tasks will start if they have no other blockers"})]}),t.jsxs("button",{onClick:()=>{S(null),ye(()=>re.tasks.cancel(e.id,!0))},className:"w-full px-4 py-2.5 text-sm bg-red-500/10 border border-red-500/30 rounded-lg hover:bg-red-500/20 text-red-500 text-left",children:[t.jsx("span",{className:"font-medium",children:"Cancel with all dependents"}),t.jsxs("span",{className:"block text-xs text-red-500/70 mt-0.5",children:["Also cancels ",k.dependentCount," blocked task",k.dependentCount>1?"s":""]})]}),t.jsx("button",{onClick:()=>S(null),className:"w-full px-4 py-2 text-sm text-fg-tertiary hover:text-fg-secondary",children:"Keep task running"})]})]})}),Y&&t.jsx(Ez,{filePath:Y,onClose:()=>V(null)})]})}function Az({project:e,tasks:r,requirements:s,agents:l,onDeleteProject:o,onUpdateProject:d,onRefresh:c}){const h=v.useMemo(()=>r.filter(I=>I.projectId===e.id),[r,e.id]),m=v.useMemo(()=>s.filter(I=>I.projectId===e.id),[s,e.id]),f=v.useMemo(()=>{const I={total:h.length,completed:0,inProgress:0,inReview:0,blocked:0,pending:0,failed:0,reqs:m.length,reqsDone:0};for(const Q of h)Q.status==="completed"||Q.status==="accepted"?I.completed++:Q.status==="in_progress"?I.inProgress++:Q.status==="review"||Q.status==="revision"?I.inReview++:Q.status==="blocked"?I.blocked++:Q.status==="failed"?I.failed++:I.pending++;for(const Q of m)Q.status==="completed"&&I.reqsDone++;return I},[h,m]),x=v.useMemo(()=>new Set(h.map(I=>I.assignedAgentId).filter(Boolean)),[h]),g=v.useMemo(()=>l.filter(I=>x.has(I.id)),[l,x]),[p,y]=v.useState(!1),[w,N]=v.useState(""),[E,A]=v.useState("main"),[C,k]=v.useState(!1),S=[{value:"active",label:"Active",desc:"Work is ongoing"},{value:"paused",label:"Paused",desc:"Temporarily on hold"},{value:"archived",label:"Archived",desc:"No longer active"}],O=async I=>{if(I!==e.status){k(!0);try{await d({status:I}),c()}finally{k(!1)}}},R=async()=>{const I=w.trim();if(!I)return;const Q=[...e.repositories??[],{url:"",localPath:I,defaultBranch:E||"main"}];await d({repositories:Q}),N(""),A("main"),y(!1),c()},G=async I=>{const Q=(e.repositories??[]).filter(($,F)=>F!==I);await d({repositories:Q}),c()};return t.jsxs("div",{className:"p-5 space-y-5 max-w-3xl",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsx(xz,{value:e.description??"",onSave:async I=>{await d({description:I}),c()},className:"text-sm text-fg-secondary",placeholder:"Add a project description…"}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-fg-tertiary",children:[e.createdAt&&t.jsxs("span",{children:["Created ",new Date(e.createdAt).toLocaleDateString()]}),e.updatedAt&&t.jsxs("span",{children:["Updated ",new Date(e.updatedAt).toLocaleDateString()]})]})]}),t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-4",children:[t.jsx("h4",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Project Status"}),t.jsx("div",{className:"flex gap-2",children:S.map(I=>t.jsxs("button",{disabled:C,onClick:()=>O(I.value),className:`flex-1 px-3 py-2 rounded-lg text-xs font-medium transition-all ${e.status===I.value?I.value==="active"?"bg-green-500/15 text-green-600 ring-1 ring-green-500/30":I.value==="paused"?"bg-amber-500/15 text-amber-600 ring-1 ring-amber-500/30":"bg-gray-500/15 text-fg-tertiary ring-1 ring-gray-500/30":"bg-surface-elevated text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay"} ${C?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:[t.jsx("div",{children:I.label}),t.jsx("div",{className:"text-[10px] opacity-70 mt-0.5",children:I.desc})]},I.value))})]}),t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-4",children:[t.jsx("h4",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Task Overview"}),t.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-6 gap-3",children:[t.jsx(Vs,{label:"Total",value:f.total,color:"text-fg-primary"}),t.jsx(Vs,{label:"Completed",value:f.completed,color:"text-green-600"}),t.jsx(Vs,{label:"In Progress",value:f.inProgress,color:"text-brand-500"}),t.jsx(Vs,{label:"In Review",value:f.inReview,color:"text-brand-500"}),t.jsx(Vs,{label:"Blocked",value:f.blocked,color:"text-amber-600"}),t.jsx(Vs,{label:"Failed",value:f.failed,color:"text-red-500"})]}),f.total>0&&t.jsxs("div",{className:"mt-3 flex h-2 rounded-full overflow-hidden bg-surface-elevated",children:[f.completed>0&&t.jsx("div",{className:"bg-green-500",style:{width:`${f.completed/f.total*100}%`}}),f.inProgress>0&&t.jsx("div",{className:"bg-brand-500",style:{width:`${f.inProgress/f.total*100}%`}}),f.inReview>0&&t.jsx("div",{className:"bg-brand-500",style:{width:`${f.inReview/f.total*100}%`}}),f.blocked>0&&t.jsx("div",{className:"bg-amber-500",style:{width:`${f.blocked/f.total*100}%`}}),f.pending>0&&t.jsx("div",{className:"bg-blue-500/40",style:{width:`${f.pending/f.total*100}%`}}),f.failed>0&&t.jsx("div",{className:"bg-red-500",style:{width:`${f.failed/f.total*100}%`}})]})]}),t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-4",children:[t.jsx("h4",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Requirements"}),t.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[t.jsx(Vs,{label:"Total",value:f.reqs,color:"text-fg-primary"}),t.jsx(Vs,{label:"Completed",value:f.reqsDone,color:"text-green-600"}),t.jsx(Vs,{label:"Active",value:f.reqs-f.reqsDone,color:"text-brand-500"})]})]}),g.length>0&&t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-4",children:[t.jsxs("h4",{className:"text-xs font-semibold text-fg-secondary mb-3",children:["Agents (",g.length,")"]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:g.map(I=>{const Q=h.filter(F=>F.assignedAgentId===I.id),$=Q.filter(F=>!["completed","failed","cancelled","archived"].includes(F.status));return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-surface-elevated/60 rounded-lg",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${I.status==="working"?"bg-blue-500":I.status==="idle"?"bg-green-500":"bg-gray-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary",children:I.name}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[$.length," active / ",Q.length," total"]})]},I.id)})})]}),t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-4",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h4",{className:"text-xs font-semibold text-fg-secondary",children:"Repositories"}),t.jsx("button",{onClick:()=>y(!p),className:"text-[10px] text-brand-500 hover:text-brand-500",children:p?"Cancel":"+ Add"})]}),(e.repositories??[]).length===0&&!p&&t.jsx("p",{className:"text-xs text-fg-tertiary",children:"No repositories linked."}),(e.repositories??[]).map((I,Q)=>t.jsxs("div",{className:"flex items-center gap-2 py-1.5 group",children:[t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-fg-tertiary shrink-0",children:[t.jsx("path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"}),t.jsx("path",{d:"M9 18c-4.51 2-5-2-7-2"})]}),t.jsx("span",{className:"text-xs text-fg-secondary flex-1 min-w-0 truncate",children:I.url||I.localPath}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:I.defaultBranch}),t.jsx("button",{onClick:()=>G(Q),className:"text-fg-tertiary hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",title:"Remove repository",children:t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},Q)),p&&t.jsxs("div",{className:"mt-2 space-y-2 p-3 bg-surface-elevated rounded-lg border border-border-default",children:[t.jsx("input",{value:w,onChange:I=>N(I.target.value),placeholder:"Local path (e.g. /Users/me/project)",className:"w-full px-2.5 py-1.5 text-xs bg-surface-primary border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{value:E,onChange:I=>A(I.target.value),placeholder:"Branch (default: main)",className:"flex-1 px-2.5 py-1.5 text-xs bg-surface-primary border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary"}),t.jsx("button",{onClick:R,disabled:!w.trim(),className:"px-3 py-1.5 text-xs bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:"Add"})]})]})]}),t.jsxs("div",{className:"border border-red-500/20 rounded-xl p-4",children:[t.jsx("h4",{className:"text-xs font-semibold text-red-500/80 mb-2",children:"Danger Zone"}),t.jsx("p",{className:"text-[11px] text-fg-tertiary mb-3",children:"Deleting a project is permanent and cannot be undone. Tasks and requirements will be unlinked."}),t.jsx("button",{onClick:o,className:"px-3 py-1.5 text-xs text-red-500 border border-red-500/30 hover:bg-red-500/10 rounded-lg transition-colors",children:"Delete Project"})]})]})}function Vs({label:e,value:r,color:s}){return t.jsxs("div",{className:"text-center py-2",children:[t.jsx("div",{className:`text-xl font-bold ${s}`,children:r}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:e})]})}const Oo={pending:{label:"Pending",cls:"bg-amber-500/15 text-amber-600"},in_progress:{label:"Active",cls:"bg-brand-500/15 text-brand-500"},completed:{label:"Done",cls:"bg-green-500/15 text-green-600"},rejected:{label:"Rejected",cls:"bg-red-500/15 text-red-500"},cancelled:{label:"Cancelled",cls:"bg-gray-600/15 text-fg-tertiary"}},CN={pending:"todo",in_progress:"in_progress",completed:"done",rejected:"closed",cancelled:"closed"},EN={failed:"rejected",todo:"pending",in_progress:"in_progress",review:"in_progress",done:"completed",closed:"cancelled"},_z={urgent:0,high:1,medium:2,low:3},Uv={failed:0,todo:1,in_progress:2,review:3,done:4,closed:5},Mz={failed:"border-l-red-500 bg-red-500/5",todo:"border-l-blue-500 bg-blue-500/5",in_progress:"border-l-brand-500 bg-brand-500/5",review:"border-l-purple-500 bg-brand-500/5",done:"border-l-green-500 bg-green-500/5",closed:"border-l-gray-500 bg-gray-500/5"},Dz={failed:"border-l-red-500 text-red-500",todo:"border-l-blue-500 text-blue-600",in_progress:"border-l-brand-500 text-brand-500",review:"border-l-purple-500 text-brand-500",done:"border-l-green-500 text-green-600",closed:"border-l-gray-500 text-fg-tertiary"},Oz=["pending","in_progress","completed","rejected","cancelled"];function Rz(e){for(const r of Do)if(r.statuses.includes(e))return r.id;return"closed"}function Lz(e){const r=Date.now()-new Date(e).getTime(),s=Math.floor(r/6e4);if(s<1)return"just now";if(s<60)return`${s}m ago`;const l=Math.floor(s/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`}function qv({value:e,options:r,onSelect:s}){const[l,o]=v.useState(!1),d=v.useRef(null),c=v.useRef(null),h=r.find(m=>m.value===e);return v.useEffect(()=>{if(!l)return;const m=f=>{c.current&&!c.current.contains(f.target)&&d.current&&!d.current.contains(f.target)&&o(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[l]),t.jsxs("div",{className:"relative",children:[t.jsx("button",{ref:d,onClick:()=>o(m=>!m),className:`text-[11px] px-2 py-0.5 rounded-full font-medium transition-colors cursor-pointer hover:ring-1 hover:ring-current/30 ${h?.cls??"bg-gray-500/15 text-fg-tertiary"}`,children:h?.label??e}),l&&t.jsx("div",{ref:c,className:"absolute top-full left-0 mt-1 w-40 bg-surface-overlay border border-border-default rounded-lg shadow-xl z-50 py-1 max-h-64 overflow-y-auto",children:r.map(m=>t.jsxs("button",{onClick:()=>{m.value!==e&&s(m.value),o(!1)},className:`w-full text-left px-3 py-1.5 text-[11px] flex items-center gap-2 transition-colors ${m.value===e?"bg-surface-elevated":"hover:bg-surface-elevated/60"}`,children:[t.jsx("span",{className:`inline-block w-2 h-2 rounded-full shrink-0 ${m.cls.split(" ")[0]}`}),t.jsx("span",{className:`font-medium ${m.value===e?"text-fg-primary":"text-fg-secondary"}`,children:m.label}),m.value===e&&t.jsx("svg",{className:"w-3 h-3 ml-auto text-brand-500",viewBox:"0 0 12 12",fill:"none",children:t.jsx("path",{d:"M2 6l3 3 5-5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]},m.value))})]})}function Fv({row:e,idx:r,dragIdx:s,agentMap:l,projMap:o,onTaskClick:d,onReqClick:c,onRowDragStart:h,onRowDragEnd:m,handleStatusChange:f,handlePriorityChange:x,selected:g}){const p=e.data.status,y=e.data.priority,w=e.kind==="task"?l.get(e.data.assignedAgentId??""):void 0,N=o.get((e.kind==="task",e.data.projectId??""));return t.jsxs("div",{draggable:!0,onDragStart:E=>h(E,r),onDragEnd:m,onClick:()=>e.kind==="task"?d(e.data):c(e.data),className:`flex items-center gap-2 px-6 py-2 border-b border-border-default/40 cursor-pointer transition-colors border-l-2 ${Mz[e.group]??"border-l-gray-700"} ${s===r?"opacity-40":""} ${g?"bg-brand-500/10 border-l-brand-500 hover:bg-brand-500/15":"hover:bg-surface-elevated/50"}`,children:[t.jsx("div",{className:"w-12 shrink-0",children:e.kind==="req"?t.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded font-semibold bg-amber-500/15 text-amber-600",children:"REQ"}):e.data.taskType==="scheduled"?t.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded font-semibold bg-blue-500/15 text-blue-600 inline-flex items-center gap-0.5",title:"Scheduled task",children:"SCHED"}):t.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded font-semibold bg-gray-500/15 text-fg-secondary",children:"TASK"})}),t.jsx("div",{className:"flex-1 min-w-[200px] text-sm text-fg-primary truncate",children:e.data.title}),t.jsx("div",{className:"w-[130px] shrink-0",onClick:E=>E.stopPropagation(),children:t.jsx(qv,{value:p,options:e.kind==="task"?wz.map(E=>({value:E,label:Bm[E]?.label??E,cls:Bm[E]?.cls??"bg-gray-500/15 text-fg-tertiary"})):Nz.map(E=>({value:E,label:Oo[E]?.label??E,cls:Oo[E]?.cls??"bg-gray-500/15 text-fg-tertiary"})),onSelect:E=>{f(e,E)}})}),t.jsx("div",{className:"w-[100px] shrink-0",onClick:E=>E.stopPropagation(),children:t.jsx(qv,{value:y,options:jz.map(E=>({value:E,label:Pv[E]?.label??E,cls:Pv[E]?.cls??"bg-gray-500/15 text-fg-tertiary"})),onSelect:E=>{x(e,E)}})}),t.jsx("div",{className:"w-[120px] shrink-0 text-[11px] text-fg-secondary truncate",children:w?t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${SN[w.status]??"bg-gray-500"}`}),w.name]}):t.jsx("span",{className:"text-fg-tertiary",children:"—"})}),t.jsx("div",{className:"w-[120px] shrink-0 text-[11px] text-fg-tertiary truncate",children:N?.name??t.jsx("span",{className:"text-fg-muted",children:"—"})}),t.jsx("div",{className:"w-[90px] shrink-0 text-[10px] text-fg-tertiary text-right",children:Lz(e.data.updatedAt??"")})]})}function zz({tasks:e,requirements:r,agents:s,projects:l,onTaskClick:o,onReqClick:d,onRefresh:c,selectedTaskId:h,selectedReqId:m}){const[f,x]=v.useState("status"),[g,p]=v.useState(null),[y,w]=v.useState(null),N=v.useMemo(()=>{const T=[];for(const D of e){const z=Rz(D.status);T.push({kind:"task",data:D,group:z,groupOrder:Uv[z]??5})}for(const D of r){const z=CN[D.status]??"todo";T.push({kind:"req",data:D,group:z,groupOrder:Uv[z]??5})}if(f==="status")T.sort((D,z)=>{if(D.groupOrder!==z.groupOrder)return D.groupOrder-z.groupOrder;const _=new Date(D.data.updatedAt??0).getTime();return new Date(z.data.updatedAt??0).getTime()-_});else{const D=z=>_z[z.data.priority]??2;T.sort((z,_)=>{const Y=D(z),V=D(_);return Y!==V?Y-V:new Date(_.data.updatedAt??0).getTime()-new Date(z.data.updatedAt??0).getTime()})}return T},[e,r,f]),E=async(T,D)=>{try{T.kind==="task"?await re.tasks.updateStatus(T.data.id,D):await re.requirements.updateStatus(T.data.id,D),c()}catch{}},A=async(T,D)=>{try{T.kind==="task"?await re.tasks.update(T.data.id,{priority:D}):await re.requirements.update(T.data.id,{priority:D}),c()}catch{}},C=(T,D)=>{p(D),T.dataTransfer.effectAllowed="move",T.dataTransfer.setData("text/plain",String(D)),T.currentTarget.style.opacity="0.4"},k=T=>{T.currentTarget.style.opacity="1",p(null),w(null)},S=(T,D)=>{T.preventDefault(),T.dataTransfer.dropEffect="move",y!==D&&w(D)},O=async(T,D)=>{if(T.preventDefault(),w(null),g==null)return;const z=N[g];if(!z||z.group===D)return;const _=Do.find(Y=>Y.id===D);if(_){try{if(z.kind==="task"){if(z.data.status==="pending")return;await re.tasks.updateStatus(z.data.id,_.dropStatus)}else{const Y=EN[D];Y&&await re.requirements.updateStatus(z.data.id,Y)}c()}catch{}p(null)}},R=v.useMemo(()=>new Map(s.map(T=>[T.id,T])),[s]),G=v.useMemo(()=>new Map(l.map(T=>[T.id,T])),[l]),I=["todo","in_progress","review","done"],Q=v.useMemo(()=>{const T={};for(const D of N)T[D.group]=(T[D.group]??0)+1;return T},[N]),{rowsByGroup:$,rowIndexMap:F}=v.useMemo(()=>{const T=new Map,D=new Map;for(let z=0;z<N.length;z++){const _=N[z];D.set(_,z);const Y=T.get(_.group)??[];Y.push(_),T.set(_.group,Y)}return{rowsByGroup:T,rowIndexMap:D}},[N]),B=v.useMemo(()=>{if(f!=="status")return null;const T=new Set(N.map(_=>_.group)),D=[],z=new Set;T.has("failed")&&(D.push("failed"),z.add("failed"));for(const _ of I)D.push(_),z.add(_);for(const _ of N)z.has(_.group)||(D.push(_.group),z.add(_.group));return D},[N,f]);return t.jsx("div",{className:"flex-1 min-h-0 overflow-auto bg-surface-secondary",children:t.jsxs("div",{className:"w-fit min-w-full",children:[t.jsxs("div",{className:"flex items-center gap-2 px-6 py-2 border-b border-border-default text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider sticky top-0 z-20 bg-surface-secondary",children:[t.jsx("div",{className:"w-12 shrink-0 text-fg-muted normal-case font-normal",children:N.length}),t.jsx("div",{className:"flex-1 min-w-[200px]",children:"Title"}),t.jsxs("button",{onClick:()=>x("status"),className:`w-[130px] shrink-0 text-left flex items-center gap-1 transition-colors ${f==="status"?"text-brand-500":"hover:text-fg-secondary"}`,children:["Status ",f==="status"&&t.jsx("span",{className:"text-[8px]",children:"▼"})]}),t.jsxs("button",{onClick:()=>x("priority"),className:`w-[100px] shrink-0 text-left flex items-center gap-1 transition-colors ${f==="priority"?"text-brand-500":"hover:text-fg-secondary"}`,children:["Priority ",f==="priority"&&t.jsx("span",{className:"text-[8px]",children:"▼"})]}),t.jsx("div",{className:"w-[120px] shrink-0",children:"Assignee"}),t.jsx("div",{className:"w-[120px] shrink-0",children:"Project"}),t.jsx("div",{className:"w-[90px] shrink-0 text-right",children:"Updated"})]}),t.jsxs("div",{children:[f==="status"&&B?B.map(T=>{const D=Do.find(_=>_.id===T),z=$.get(T)??[];return t.jsxs("div",{children:[t.jsxs("div",{className:`flex items-center gap-2 px-6 py-2 border-l-2 bg-surface-secondary/60 sticky top-0 z-10 ${Dz[T]??""} ${y===T?"ring-1 ring-brand-500/40":""}`,onDragOver:_=>S(_,T),onDragLeave:()=>w(null),onDrop:_=>{O(_,T)},children:[t.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider",children:D?.label??T}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:Q[T]??0})]}),z.map(_=>t.jsx(Fv,{row:_,idx:F.get(_)??0,dragIdx:g,agentMap:R,projMap:G,onTaskClick:o,onReqClick:d,onRowDragStart:C,onRowDragEnd:k,handleStatusChange:E,handlePriorityChange:A,selected:_.kind==="task"?_.data.id===h:_.data.id===m},`${_.kind}-${_.data.id}`))]},T)}):N.map((T,D)=>t.jsx(Fv,{row:T,idx:D,dragIdx:g,agentMap:R,projMap:G,onTaskClick:o,onReqClick:d,onRowDragStart:C,onRowDragEnd:k,handleStatusChange:E,handlePriorityChange:A,selected:T.kind==="task"?T.data.id===h:T.data.id===m},`${T.kind}-${T.data.id}`)),N.length===0&&t.jsx("div",{className:"flex items-center justify-center py-16 text-sm text-fg-tertiary",children:"No items"})]})]})})}function Vv({authUser:e}){const r=ks(),s=Wd({side:"right",defaultWidth:Math.round(window.innerWidth*2/3),minWidth:380,maxWidth:Math.round(window.innerWidth*.8),storageKey:"markus_projects_detail_v3"}),[l,o]=v.useState(!1),d=v.useRef(l);d.current=l;const[c,h]=v.useState([]),[m,f]=v.useState("all"),[x,g]=v.useState(null),[p,y]=v.useState({}),[w,N]=v.useState([]),[E,A]=v.useState([]),[C,k]=v.useState([]),[S,O]=v.useState(!0),[R,G]=v.useState(""),[I,Q]=v.useState(!1),$=v.useCallback(()=>{Wt(x??""),yt(!0)},[x]),[F,B]=v.useState(!1),[T,D]=v.useState(!1),[z,_]=v.useState(""),[Y,V]=v.useState(""),[J,U]=v.useState("medium"),[H,X]=v.useState(""),[L,M]=v.useState(""),[q,K]=v.useState(""),[ee,te]=v.useState(""),[se,xe]=v.useState([]),[ke,De]=v.useState("standard"),[ge,ye]=v.useState("4h"),[Ce,ze]=v.useState(null),[tt,Xe]=v.useState(null),[dt,wt]=v.useState(new Set),[ae,Te]=v.useState(new Set),Ze=v.useRef(new Set),xt=v.useRef(new Set),[dn,we]=v.useState(null),[Re,qe]=v.useState("backlog"),[et,nt]=v.useState(!1),[zt,Yt]=v.useState(!1),Lt=v.useRef(null),Tt=v.useRef(null),[qt,yt]=v.useState(!1),[sn,Xt]=v.useState(""),[je,Pe]=v.useState(""),[vt,Nt]=v.useState("medium"),[ut,Wt]=v.useState(""),[en,Ct]=v.useState(null),[de,Be]=v.useState(""),Le=Z=>{G(Z),setTimeout(()=>G(""),3e3)},ot=c.find(Z=>Z.id===x)??null;v.useEffect(()=>{xt.current=ae},[ae]);const Qe=v.useCallback(async()=>{try{const{projects:Z}=await re.projects.list();h(Z)}catch{}},[]),ft=v.useCallback(async()=>{const Z={};m==="project"&&x&&(Z.projectId=x);try{const{board:oe}=await re.tasks.board(Z);y(oe)}catch{}},[m,x]),Zt=v.useCallback(async()=>{try{const{agents:Z}=await re.agents.list();N(Z)}catch{}},[]),it=v.useCallback(async()=>{try{const{users:Z}=await re.users.list(e?.orgId);A(Z)}catch{}},[e?.orgId]),gt=v.useCallback(async()=>{try{const{requirements:Z}=await re.requirements.list({});k(Z)}catch{}},[]),wn=v.useCallback(async()=>{await Promise.all([Qe(),ft(),Zt(),it(),gt()]),O(!1)},[Qe,ft,Zt,it,gt]);v.useEffect(()=>{wn()},[wn]);const an=v.useCallback(Z=>{ze(oe=>oe?.id===Z.id?(r&&d.current&&o(!1),null):(r&&(o(!0),history.pushState({mobileDetail:"projects"},"",window.location.hash)),Z)),Xe(null)},[r]),Qt=v.useCallback(Z=>{Xe(oe=>oe?.id===Z.id?(r&&d.current&&o(!1),null):(r&&(o(!0),history.pushState({mobileDetail:"projects"},"",window.location.hash)),Z)),ze(null)},[r]),At=v.useCallback(()=>{ze(null),Xe(null),r&&d.current&&o(!1)},[r]);v.useEffect(()=>{if(!r)return;const Z=()=>{d.current&&(o(!1),ze(null),Xe(null))};return window.addEventListener("popstate",Z),()=>window.removeEventListener("popstate",Z)},[r]);const un=v.useRef(Ce);un.current=Ce,v.useEffect(()=>{const oe=setInterval(()=>{ft(),Zt(),gt()},Ce?6e4:15e3),me=kn.on("task:update",Ie=>{un.current||(ft(),gt());const Me=Ie?.payload;Me?.taskId&&ze(Ue=>{if(!Ue||Ue.id!==Me.taskId)return Ue;const Ve={};return typeof Me.status=="string"&&(Ve.status=Me.status),Array.isArray(Me.deliverables)&&(Ve.deliverables=Me.deliverables),Array.isArray(Me.notes)&&(Ve.notes=Me.notes),Me.result!==void 0&&(Ve.result=Me.result),{...Ue,...Ve}})});return()=>{clearInterval(oe),me()}},[ft,Zt,gt,Ce]);const En=v.useRef(p);En.current=p;const fe=v.useCallback(Z=>{if(!Z)return;const oe=xt.current;oe.size>0&&!oe.has(Z)&&Te(me=>new Set([...me,Z]))},[]);v.useEffect(()=>{const Z=localStorage.getItem("markus_nav_openTask");if(!Z)return;const me=Object.values(p).flat().find(Ie=>Ie.id===Z);me&&(fe(me.projectId),an(me),localStorage.removeItem("markus_nav_openTask"))},[p,an,fe]),v.useEffect(()=>{const Z=window.location.hash.slice(1).split("/");if(Z[0]==="projects"&&Z[1])Fe(Z[1]);else{const oe=localStorage.getItem("markus_nav_projectId");oe&&(localStorage.removeItem("markus_nav_projectId"),Fe(oe))}},[]),v.useEffect(()=>{const Z=()=>{const me=window.location.hash.slice(1).split("/");me[0]==="projects"&&me[1]?Fe(me[1]):me[0]==="projects"&&kt()},oe=me=>{const Ie=me.detail;if(Ie.page==="tasks"||Ie.page==="projects"){if(Ie.params?.openTask){const Ue=Object.values(En.current).flat().find(Ve=>Ve.id===Ie.params.openTask);Ue&&(fe(Ue.projectId),an(Ue),localStorage.removeItem("markus_nav_openTask"))}Ie.params?.projectId&&Fe(Ie.params.projectId),!Ie.params?.projectId&&!Ie.params?.openTask&&kt()}};return window.addEventListener("markus:navigate",oe),window.addEventListener("hashchange",Z),()=>{window.removeEventListener("markus:navigate",oe),window.removeEventListener("hashchange",Z)}},[]);const Fe=Z=>{xt.current.size>0&&(Ze.current=new Set(xt.current)),Te(new Set),g(Z),f("project"),Q(!1),history.replaceState(null,"","#projects/"+Z)},kt=()=>{Te(Ze.current),g(null),f("all"),Q(!1),history.replaceState(null,"","#projects")},St=()=>{B(!1),Le("Project created"),Qe()},Tn=async Z=>{if(confirm("Delete this project and unlink all its tasks?"))try{await re.projects.delete(Z),x===Z&&kt(),Le("Project deleted"),Qe(),ft()}catch(oe){Le(`Error: ${oe}`)}},Qn=async()=>{if(!z||!H||!L)return;if(H===L){Le("Assigned agent and reviewer must be different");return}const Z=q||void 0,oe=ee||void 0;try{await re.tasks.create(z,Y,H,L,J,Z,se.length>0?se:void 0,oe,ke!=="standard"?ke:void 0,ke==="scheduled"?{every:ge}:void 0),_(""),V(""),xe([]),te(""),De("standard"),ye("4h"),D(!1),ft()}catch(me){Le(`Error creating task: ${me}`)}},hr=()=>{ft(),Ce&&setTimeout(()=>{const Z={};m==="project"&&x&&(Z.projectId=x),re.tasks.board(Z).then(oe=>{const Ie=Object.values(oe.board).flat().find(Me=>Me.id===Ce.id);ze(Ie||null)}).catch(()=>{})},150)},or=async()=>{if(!sn.trim()){Le("Please enter a title for this requirement");return}if(!je.trim()){Le("Please enter a description for this requirement");return}if(!ut){Le("Please select a project for this requirement");return}try{await re.requirements.create({title:sn.trim(),description:je.trim(),priority:vt,projectId:ut}),Le("Requirement created"),Xt(""),Pe(""),yt(!1),gt()}catch(Z){Le(`Error: ${Z}`)}},tr=async Z=>{try{await re.requirements.approve(Z),Le("Requirement approved"),gt(),ft()}catch(oe){Le(`Error: ${oe}`)}},cr=async()=>{if(en)try{await re.requirements.reject(en,de),Le("Requirement rejected"),Ct(null),Be(""),gt()}catch(Z){Le(`Error: ${Z}`)}},fn=async Z=>{try{await re.requirements.cancel(Z),Le("Requirement cancelled"),gt()}catch(oe){Le(`Error: ${oe}`)}},os=(Z,oe)=>{Lt.current=oe,Tt.current=null,Z.dataTransfer.effectAllowed="move",Z.dataTransfer.setData("text/plain",`task:${oe.id}`),Z.currentTarget.style.opacity="0.4"},Sr=(Z,oe)=>{Tt.current=oe,Lt.current=null,Z.dataTransfer.effectAllowed="move",Z.dataTransfer.setData("text/plain",`req:${oe.id}`),Z.currentTarget.style.opacity="0.4"},nr=Z=>{Z.currentTarget.style.opacity="1",Lt.current=null,Tt.current=null,we(null)},rr=(Z,oe)=>{Z.preventDefault(),Z.dataTransfer.dropEffect="move",dn!==oe&&we(oe)},Cs=(Z,oe)=>{const me=Z.currentTarget.getBoundingClientRect(),{clientX:Ie,clientY:Me}=Z;(Ie<me.left||Ie>me.right||Me<me.top||Me>me.bottom)&&dn===oe&&we(null)},ie=async(Z,oe)=>{Z.preventDefault(),we(null);const me=Lt.current,Ie=Tt.current;if(me){const Me=Do.find(Ve=>Ve.id===oe);if(!Me)return;const Ue=Me.dropStatus;if(me.status===Ue||me.status==="pending")return;try{await re.tasks.updateStatus(me.id,Ue),ft()}catch{}}else if(Ie){const Me=EN[oe];if(!Me||Ie.status===Me)return;try{await re.requirements.updateStatus(Ie.id,Me),gt()}catch{}}},Se=Z=>{wt(oe=>{const me=new Set(oe);return me.has(Z)?me.delete(Z):me.add(Z),me})},He=Z=>{Te(oe=>{const me=new Set(oe);return me.has(Z)?me.delete(Z):me.add(Z),me})},Mt=1440*60*1e3,Gn=Date.now(),On=Z=>Z.updatedAt&&Gn-new Date(Z.updatedAt).getTime()>Mt,tn=Z=>(Z.status==="completed"||Z.status==="cancelled")&&On(Z),Hr=(Z,oe=!1)=>{let me=Z.filter(Ie=>et||oe||!tn(Ie));return m==="project"&&x&&(me=me.filter(Ie=>Ie.projectId===x)),ae.size>0&&(me=me.filter(Ie=>Ie.projectId&&ae.has(Ie.projectId))),dt.size>0&&(me=me.filter(Ie=>Ie.assignedAgentId&&dt.has(Ie.assignedAgentId))),me},Js=Z=>Z.statuses.flatMap(oe=>Hr(p[oe]??[])),mr=v.useMemo(()=>{let Z=C;return et||(Z=Z.filter(oe=>!tn(oe))),m==="project"&&x&&(Z=Z.filter(oe=>oe.projectId===x)),ae.size>0&&(Z=Z.filter(oe=>oe.projectId&&ae.has(oe.projectId))),dt.size>0&&(Z=Z.filter(oe=>dt.has(oe.createdBy))),Z},[C,et,m,x,ae,dt]),dr=v.useCallback(Z=>mr.filter(oe=>CN[oe.status]===Z.id),[mr]),Cr=Do.filter(Z=>{if(Z.id==="failed"||Z.id==="closed"){const oe=Js(Z),me=dr(Z);return oe.length+me.length>0}return!0}),Er=Object.values(p).flat().filter(Z=>tn(Z)).length+C.filter(Z=>tn(Z)).length,An=v.useMemo(()=>{const Z=new Set(["completed","failed","cancelled","archived"]),oe=Object.values(p).flat(),me=new Set;for(const Ie of oe)Ie.assignedAgentId&&!Z.has(Ie.status)&&(!x||Ie.projectId===x)&&me.add(Ie.assignedAgentId);return[...w].sort((Ie,Me)=>{const Ue=me.has(Ie.id)?0:1,Ve=me.has(Me.id)?0:1;return Ue-Ve})},[w,p,x]),Tr=v.useMemo(()=>{const Z=new Set(["completed","failed","cancelled","archived"]),oe=Object.values(p).flat(),me=new Set;for(const Ie of oe)Ie.projectId&&!Z.has(Ie.status)&&me.add(Ie.projectId);return[...c].sort((Ie,Me)=>{const Ue=me.has(Ie.id)?0:1,Ve=me.has(Me.id)?0:1;return Ue-Ve})},[c,p]),cs=v.useMemo(()=>{const Z={};for(const oe of Object.values(p))for(const me of oe){const Ie=me.projectId??"__none__";Z[Ie]=(Z[Ie]??0)+1}return Z},[p]),Kr=Object.values(cs).reduce((Z,oe)=>Z+oe,0);if(S)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary",children:"Loading…"});const ne=!!(Ce||tt);return t.jsxs("div",{className:"flex-1 overflow-hidden flex bg-surface-secondary",children:[t.jsxs("div",{className:`${r?"flex-1 min-w-0":ne?"shrink-0":"flex-1"} overflow-hidden flex flex-col bg-surface-secondary`,style:r?l?{display:"none"}:void 0:ne?{width:`calc(100% - ${s.width}px - 4px)`}:void 0,children:[R&&t.jsx("div",{className:"mx-6 mt-2 px-3 py-1.5 bg-green-500/15 text-green-600 text-xs rounded-lg",children:R}),r?t.jsxs("div",{className:"border-b border-border-default bg-surface-secondary/80 shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 h-11",children:[ot?t.jsxs("div",{className:"flex items-center gap-1 min-w-0 flex-1",children:[t.jsx("span",{className:"text-sm font-semibold text-fg-primary truncate",children:ot.name}),t.jsx("button",{onClick:()=>Q(!I),className:`w-6 h-6 flex items-center justify-center rounded-md transition-colors shrink-0 ${I?"bg-surface-overlay text-fg-primary":"text-fg-tertiary"}`,children:t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"3"}),t.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]})})]}):t.jsx("h2",{className:"text-sm font-semibold text-fg-primary min-w-0 flex-1 truncate",children:c.length===1?c[0].name:`${c.length} Projects`}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.jsx("button",{onClick:()=>B(!0),className:"px-2 py-1 text-[11px] border border-border-default text-fg-secondary rounded-md",children:"+ Project"}),t.jsx("button",{onClick:$,className:"px-2 py-1 text-[11px] bg-brand-600 text-white rounded-md",children:"+ Req"}),t.jsx("button",{onClick:()=>{K(x??""),D(!0)},className:"px-2 py-1 text-[11px] border border-border-default text-fg-secondary rounded-md",children:"+ Task"})]})]}),t.jsxs("div",{className:"flex items-center gap-2 px-3 h-9 border-t border-border-default/40",children:[t.jsx("div",{className:"flex items-center border border-border-default/60 rounded-md overflow-hidden shrink-0",children:["backlog","kanban","dag"].map(Z=>t.jsx("button",{onClick:()=>qe(Z),className:`px-2 py-0.5 text-[10px] font-medium transition-colors ${Re===Z?"bg-brand-600/25 text-brand-500":"text-fg-tertiary"}`,children:Z==="backlog"?"Backlog":Z==="kanban"?"Kanban":"DAG"},Z))}),Er>0&&t.jsx("button",{onClick:()=>nt(Z=>!Z),className:`text-[10px] shrink-0 px-2 py-0.5 rounded-md transition-colors ${et?"bg-surface-overlay text-fg-secondary":"text-fg-tertiary"}`,children:et?"Hide archived":`${Er} archived`}),t.jsx("div",{className:"flex-1"}),(ae.size>0||dt.size>0||c.length>1||w.length>0)&&t.jsxs("button",{onClick:()=>Yt(!0),className:`px-2 py-1 text-[11px] rounded-md font-medium transition-colors flex items-center gap-1 ${ae.size>0||dt.size>0?"bg-brand-600/20 text-brand-500 ring-1 ring-brand-500/30":"border border-border-default text-fg-secondary"}`,children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),"Filter",ae.size+dt.size>0?` (${ae.size+dt.size})`:""]})]})]}):t.jsxs("div",{className:"flex items-center gap-3 px-6 h-14 border-b border-border-default bg-surface-secondary/80 shrink-0",children:[ot?t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.jsx(mz,{value:ot.name,onSave:async Z=>{await re.projects.update(ot.id,{name:Z}),Qe()},className:"text-sm font-semibold text-fg-primary"}),t.jsx("button",{onClick:()=>Q(!I),className:`w-6 h-6 flex items-center justify-center rounded-md transition-colors ${I?"bg-surface-overlay text-fg-primary":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,title:"Project settings",children:t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"3"}),t.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]})})]}):t.jsx("h2",{className:"text-sm font-semibold text-fg-primary shrink-0",children:c.length===1?c[0].name:`${c.length} Projects`}),Er>0&&t.jsx("button",{onClick:()=>nt(Z=>!Z),className:`text-[10px] shrink-0 px-2 py-0.5 rounded-md transition-colors ${et?"bg-surface-overlay text-fg-secondary":"text-fg-tertiary hover:text-fg-secondary"}`,children:et?`Hide ${Er} archived`:`${Er} archived`}),t.jsx("div",{className:"flex items-center border border-border-default/60 rounded-md overflow-hidden shrink-0",children:["backlog","kanban","dag"].map(Z=>t.jsx("button",{onClick:()=>qe(Z),className:`px-2.5 py-1 text-[10px] font-medium transition-colors ${Re===Z?"bg-brand-600/25 text-brand-500":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:Z==="backlog"?"Backlog":Z==="kanban"?"Kanban":"DAG"},Z))}),t.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[t.jsx("button",{onClick:$,className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg font-medium transition-colors",children:"+ Requirement"}),t.jsx("button",{onClick:()=>{K(x??""),D(!0)},className:"px-3 py-1.5 border border-border-default hover:bg-surface-elevated text-fg-secondary text-xs rounded-lg font-medium transition-colors",children:"+ Task"})]}),t.jsx("div",{className:"flex-1"})]}),!r&&c.length>1&&!x&&!I&&(Kr>0||C.length>0)&&t.jsxs("div",{className:"px-6 py-1.5 border-b border-border-default/60 flex items-center gap-1.5 overflow-x-auto scrollbar-hide shrink-0",children:[t.jsx("button",{onClick:()=>Te(new Set),className:`text-[10px] text-fg-tertiary hover:text-fg-secondary px-2 py-1 rounded-md bg-surface-elevated/60 hover:bg-surface-overlay shrink-0 transition-all ${ae.size>0?"visible opacity-100":"invisible opacity-0"}`,children:"Clear"}),Tr.map(Z=>{const oe=ae.has(Z.id),me=cs[Z.id]??0;return t.jsxs("button",{onClick:()=>He(Z.id),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[11px] shrink-0 transition-all ${oe?"bg-brand-500/15 text-brand-600 ring-1 ring-brand-500/30":"text-fg-tertiary hover:bg-surface-elevated hover:text-fg-secondary"}`,children:[t.jsx("span",{className:`w-4 h-4 rounded-sm flex items-center justify-center text-[9px] font-bold shrink-0 ${oe?"bg-brand-600 text-white":"bg-surface-overlay text-fg-secondary"}`,children:Z.name[0]?.toUpperCase()}),Z.name,me>0&&t.jsx("span",{className:"text-[9px] text-fg-tertiary ml-0.5",children:me})]},Z.id)})]}),!r&&w.length>0&&!I&&(Kr>0||C.length>0)&&t.jsxs("div",{className:"px-6 py-1.5 border-b border-border-default/60 flex items-center gap-1.5 overflow-x-auto scrollbar-hide shrink-0",children:[t.jsx("button",{onClick:()=>wt(new Set),className:`text-[10px] text-fg-tertiary hover:text-fg-secondary px-2 py-1 rounded-md bg-surface-elevated/60 hover:bg-surface-overlay shrink-0 transition-all ${dt.size>0?"visible opacity-100":"invisible opacity-0"}`,children:"Clear"}),An.map(Z=>{const oe=dt.has(Z.id);return t.jsxs("button",{onClick:()=>Se(Z.id),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[11px] shrink-0 transition-all ${oe?"bg-brand-600/20 text-brand-500 ring-1 ring-brand-500/40":"text-fg-tertiary hover:bg-surface-elevated hover:text-fg-secondary"}`,children:[t.jsx("span",{className:`w-4 h-4 rounded-full flex items-center justify-center text-[9px] font-bold shrink-0 ${oe?"bg-brand-600 text-white":"bg-surface-overlay text-fg-secondary"}`,children:Z.name[0]?.toUpperCase()}),Z.name]},Z.id)})]}),I&&ot?t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsx(Az,{project:ot,tasks:Object.values(p).flat(),requirements:C,agents:w,onDeleteProject:()=>Tn(ot.id),onUpdateProject:async Z=>{await re.projects.update(ot.id,Z)},onRefresh:()=>{Qe()}})}):Kr===0&&mr.length===0?t.jsx("div",{className:"flex-1 flex items-center justify-center p-8",children:t.jsxs("div",{className:"max-w-sm w-full text-center space-y-3",children:[t.jsx("div",{className:"w-10 h-10 mx-auto rounded-lg bg-surface-elevated flex items-center justify-center",children:t.jsx("span",{className:"text-fg-tertiary text-lg",children:"☐"})}),t.jsx("h3",{className:"text-sm font-medium text-fg-secondary",children:"No items yet"}),t.jsxs("p",{className:"text-xs text-fg-tertiary leading-relaxed",children:["Create a requirement to tell agents what you need.",t.jsx("br",{}),"Once approved, tasks will appear here automatically."]}),t.jsx("button",{onClick:$,className:"text-xs text-brand-500 hover:text-brand-500 font-medium",children:"+ Create a requirement"})]})}):Re==="backlog"?t.jsx(zz,{tasks:Hr(Object.values(p).flat()),requirements:mr,agents:w,projects:c,onTaskClick:Z=>an(Z),onReqClick:Z=>Qt(Z),onRefresh:()=>{ft(),gt()},selectedTaskId:Ce?.id,selectedReqId:tt?.id}):Re==="dag"?t.jsx(hz,{tasks:Hr(Object.values(p).flat(),!0),requirements:mr,agents:w,showArchived:et,onShowArchivedChange:nt,onTaskClick:Z=>an(Z),onReqClick:Z=>Qt(Z),onDependencyChange:ft,selectedTaskId:Ce?.id,selectedReqId:tt?.id}):t.jsx("div",{className:"flex-1 min-h-0 overflow-x-auto overflow-y-hidden px-4 py-5",children:t.jsx("div",{className:"flex gap-3 h-full",children:Cr.map(Z=>{const oe=Js(Z),me=dr(Z),Ie=oe.length+me.length,Me=dn===Z.id;return t.jsxs("div",{className:`w-[280px] shrink-0 rounded-xl flex flex-col h-full transition-colors ${Me?"bg-surface-elevated/60 ring-1 ring-brand-500/30":"bg-surface-secondary/50"}`,onDragOver:Ue=>rr(Ue,Z.id),onDragLeave:Ue=>Cs(Ue,Z.id),onDrop:Ue=>{ie(Ue,Z.id)},children:[t.jsxs("div",{className:"flex justify-between items-center px-3 py-2.5 shrink-0 border-b border-border-default/30",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${Z.accent.replace("border-t-","bg-")}`}),t.jsx("span",{className:"text-xs font-semibold text-fg-secondary uppercase tracking-wider",children:Z.label})]}),t.jsx("span",{className:"text-[11px] text-fg-tertiary font-medium tabular-nums",children:Ie})]}),t.jsx("div",{className:"space-y-2 flex-1 min-h-0 overflow-y-auto scrollbar-thin px-2 py-2",children:(()=>{const Ue=[...me.map(Ve=>({kind:"req",data:Ve,time:new Date(Ve.updatedAt??Ve.createdAt).getTime()})),...oe.map(Ve=>({kind:"task",data:Ve,time:new Date(Ve.updatedAt??Ve.createdAt??0).getTime()}))];return Ue.sort((Ve,Oe)=>Oe.time-Ve.time),Ue.map(Ve=>{if(Ve.kind==="req"){const Oe=Ve.data,bt=Oo[Oe.status]??{label:Oe.status,cls:"bg-gray-500/15 text-fg-secondary"},Dt=Oe.source==="agent"&&Oe.status==="pending",_n=m==="all"&&Oe.projectId?c.find(Ye=>Ye.id===Oe.projectId):null,at=ii(Oe.createdBy,w,E)??Oe.createdBy.slice(0,10),ht=tt?.id===Oe.id;return t.jsxs("div",{role:"button",tabIndex:0,draggable:!0,onDragStart:Ye=>Sr(Ye,Oe),onDragEnd:nr,onClick:()=>Qt(Oe),onKeyDown:Ye=>Ye.key==="Enter"&&Qt(Oe),className:`group rounded-lg p-2.5 border border-transparent transition-all cursor-grab active:cursor-grabbing
|
|
62
|
+
${Dt?"bg-amber-500/[0.06] border-amber-500/30 ring-1 ring-amber-500/15":"bg-surface-elevated/80 hover:bg-surface-elevated border-border-default/50 hover:border-brand-400/40"}
|
|
63
|
+
${ht?"ring-2 ring-brand-500/50 border-brand-500/40":""}`,children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[t.jsx("span",{className:"w-1 h-1 rounded-full bg-purple-500 shrink-0"}),t.jsx("span",{className:"text-[10px] font-semibold text-purple-500 uppercase tracking-wide shrink-0",children:"REQ"}),t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded-md shrink-0 ml-auto ${bt.cls}`,children:bt.label})]}),t.jsx("div",{className:"text-[13px] font-medium leading-snug text-fg-primary line-clamp-2 mb-1",children:Oe.title}),Oe.description&&t.jsx("div",{className:"text-[11px] text-fg-tertiary line-clamp-1 mb-1.5",children:Oe.description}),t.jsxs("div",{className:"flex items-center justify-between mt-auto pt-1.5 border-t border-border-default/20",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[_n&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-overlay/60 text-fg-secondary rounded truncate max-w-[90px]",title:_n.name,children:_n.name}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:Oe.priority}),t.jsxs("span",{className:"text-[10px] text-fg-quaternary",children:["by ",at]})]}),t.jsx("div",{className:"flex items-center gap-1",children:Oe.taskIds.length>0&&t.jsxs("span",{className:"text-[10px] text-brand-500/70 bg-brand-500/8 px-1.5 py-0.5 rounded-md",children:["📋 ",Oe.taskIds.length]})})]}),Dt&&t.jsxs("div",{className:"flex items-center gap-2 mt-2 pt-2 border-t border-amber-500/15",children:[t.jsx("button",{onClick:Ye=>{Ye.stopPropagation(),tr(Oe.id)},className:"flex-1 py-1 bg-green-600 hover:bg-green-500 text-white text-[10px] rounded-md font-medium transition-colors",children:"Approve"}),t.jsx("button",{onClick:Ye=>{Ye.stopPropagation(),Ct(Oe.id)},className:"flex-1 py-1 border border-red-500/30 hover:bg-red-500/10 text-red-500 text-[10px] rounded-md font-medium transition-colors",children:"Reject"})]})]},`req-${Oe.id}`)}else{const Oe=Ve.data,bt=Oe.subtasks?.length??0,Gt=kN[Oe.status],Dt=Oe.status==="pending",_n=Oe.taskType==="scheduled"&&!!Oe.scheduleConfig,at=_n?Oe.scheduleConfig.every?`Every ${Oe.scheduleConfig.every}`:Oe.scheduleConfig.cron?"Cron":"Scheduled":null,ht=m==="all"&&Oe.projectId?c.find(Ge=>Ge.id===Oe.projectId)?.name:null,Ye=Oe.requirementId?C.find(Ge=>Ge.id===Oe.requirementId)?.title:null,Ke=Oe.createdBy?ii(Oe.createdBy,w,E)??Oe.createdBy:null,Je=Ce?.id===Oe.id,st={urgent:"bg-red-500",high:"bg-amber-500",medium:"bg-blue-500",low:"bg-gray-400"};return t.jsxs("div",{role:"button",tabIndex:0,"aria-label":Oe.title,draggable:!Dt,onDragStart:Ge=>!Dt&&os(Ge,Oe),onDragEnd:nr,onClick:()=>an(Oe),onKeyDown:Ge=>Ge.key==="Enter"&&an(Oe),className:`group rounded-lg p-2.5 border border-transparent transition-all ${Dt?"bg-amber-500/[0.06] border-amber-500/30 ring-1 ring-amber-500/15 cursor-pointer":_n?"bg-blue-500/[0.04] border-blue-500/20 hover:border-blue-400/40 cursor-pointer":"bg-surface-elevated/80 hover:bg-surface-elevated border-border-default/50 hover:border-brand-400/40 cursor-grab active:cursor-grabbing"} ${Je?"ring-2 ring-brand-500/50 border-brand-500/40":""}`,children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${st[Oe.priority]??"bg-gray-400"}`,title:Oe.priority}),_n&&t.jsx("span",{className:"text-blue-500 shrink-0",title:at??"Scheduled",children:t.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.3"})})}),_n&&at&&t.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-md bg-blue-500/10 text-blue-500 whitespace-nowrap",children:at}),Gt&&t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded-md ml-auto shrink-0 ${Gt.cls}`,children:Gt.label})]}),t.jsx("div",{className:"text-[13px] font-medium leading-snug text-fg-primary line-clamp-2 mb-1",children:Oe.title}),Oe.description&&t.jsx("div",{className:"text-[11px] text-fg-tertiary line-clamp-1 mb-1.5",children:Oe.description}),(ht||Ye||Oe.blockedBy&&Oe.blockedBy.length>0)&&t.jsxs("div",{className:"flex flex-wrap gap-1 mb-1.5",children:[ht&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-overlay/60 text-fg-secondary rounded-md truncate max-w-[100px]",title:ht,children:ht}),Ye&&t.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 bg-brand-500/8 text-brand-500 rounded-md truncate max-w-[110px]",title:Ye,children:["# ",Ye]}),Oe.blockedBy&&Oe.blockedBy.length>0&&t.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 bg-amber-500/10 text-amber-600 rounded-md",children:["⏳ ",Oe.blockedBy.length," dep",Oe.blockedBy.length>1?"s":""]})]}),t.jsxs("div",{className:"flex items-center justify-between mt-auto pt-1.5 border-t border-border-default/20",children:[t.jsx("div",{className:"flex items-center gap-1.5",children:Ke&&t.jsxs("span",{className:"text-[10px] text-fg-quaternary",title:`by ${Ke}`,children:["by ",Ke]})}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[bt>0&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["⋮ ",bt]}),Oe.notes&&Oe.notes.length>0&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["📝 ",Oe.notes.length]}),Oe.assignedAgentId&&t.jsxs("span",{className:"text-[10px] text-brand-500 bg-brand-500/8 px-1.5 py-0.5 rounded-md flex items-center gap-1",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${SN[w.find(Ge=>Ge.id===Oe.assignedAgentId)?.status??""]??"bg-gray-500"}`}),w.find(Ge=>Ge.id===Oe.assignedAgentId)?.name??Oe.assignedAgentId.slice(0,8)]})]})]})]},Oe.id)}})})()}),Me&&t.jsx("div",{className:"mx-2 mb-2 border-2 border-dashed border-brand-500/25 rounded-lg h-10 flex items-center justify-center shrink-0",children:t.jsx("span",{className:"text-[11px] text-brand-500/50",children:"Drop here"})})]},Z.id)})})})]}),!r&&ne&&t.jsx("div",{className:"w-1 shrink-0 cursor-col-resize bg-border-default/40 hover:bg-brand-500/30 active:bg-brand-500/50 transition-colors",onMouseDown:s.onResizeStart}),(!r||l)&&ne&&t.jsx("div",{className:`${r?"flex-1":"shrink-0"} overflow-hidden min-w-0 border-l border-border-default`,style:r?void 0:{width:s.width},children:Ce?t.jsx(Tz,{task:Ce,agents:w,projects:c,requirements:C,allTasks:Object.values(p).flat(),users:E,onClose:At,onRefresh:hr,authUser:e}):tt?t.jsx($z,{req:tt,agents:w,projects:c,allTasks:Object.values(p).flat(),users:E,onClose:At,onApprove:Z=>{tr(Z),At()},onReject:Z=>{Ct(Z),At()},onCancel:Z=>{fn(Z),At()},onStatusChange:async(Z,oe)=>{try{await re.requirements.updateStatus(Z,oe),Le(`Requirement status → ${oe}`),gt(),ft()}catch(me){Le(`Error: ${me}`)}},onRefresh:gt,authUser:e}):null}),F&&t.jsx(wN,{orgId:e?.orgId,onCreated:St,onClose:()=>B(!1)}),T&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-3",onClick:()=>D(!1),children:t.jsxs("div",{className:`bg-surface-secondary border border-border-default rounded-xl p-6 space-y-4 max-h-[90dvh] overflow-y-auto ${r?"w-full":"w-[28rem]"}`,onClick:Z=>Z.stopPropagation(),children:[t.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:"New Task"}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Project"}),t.jsxs("select",{value:q,onChange:Z=>K(Z.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"",children:"No Project"}),c.map(Z=>t.jsx("option",{value:Z.id,children:Z.name},Z.id))]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Requirement"}),t.jsxs("select",{value:ee,onChange:Z=>te(Z.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"",children:"Select a requirement…"}),C.filter(Z=>Z.status==="in_progress"&&(!q||Z.projectId===q)).map(Z=>t.jsx("option",{value:Z.id,children:Z.title},Z.id))]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Title"}),t.jsx("input",{autoFocus:!r,value:z,onChange:Z=>_(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&Qn()},className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Description"}),t.jsx("textarea",{value:Y,onChange:Z=>V(Z.target.value),rows:2,className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none resize-none"})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Priority"}),t.jsxs("select",{value:J,onChange:Z=>U(Z.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"low",children:"Low"}),t.jsx("option",{value:"medium",children:"Medium"}),t.jsx("option",{value:"high",children:"High"}),t.jsx("option",{value:"urgent",children:"Urgent"})]})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm text-fg-secondary mb-1.5",children:["Assign to ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsxs("select",{value:H,onChange:Z=>X(Z.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"",children:"Select agent…"}),w.map(Z=>t.jsx("option",{value:Z.id,children:Z.name},Z.id))]})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm text-fg-secondary mb-1.5",children:["Reviewer ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsxs("select",{value:L,onChange:Z=>M(Z.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"",children:"Select reviewer…"}),w.filter(Z=>Z.id!==H).map(Z=>t.jsx("option",{value:Z.id,children:Z.name},Z.id))]})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Task Type"}),t.jsxs("select",{value:ke,onChange:Z=>De(Z.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"standard",children:"Standard"}),t.jsx("option",{value:"scheduled",children:"Scheduled (recurring)"})]})]}),ke==="scheduled"&&t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Frequency"}),t.jsxs("select",{value:ge,onChange:Z=>ye(Z.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"30m",children:"Every 30 min"}),t.jsx("option",{value:"1h",children:"Every 1 hour"}),t.jsx("option",{value:"2h",children:"Every 2 hours"}),t.jsx("option",{value:"4h",children:"Every 4 hours"}),t.jsx("option",{value:"8h",children:"Every 8 hours"}),t.jsx("option",{value:"12h",children:"Every 12 hours"}),t.jsx("option",{value:"1d",children:"Every day"}),t.jsx("option",{value:"1w",children:"Every week"})]})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Blocked By (dependencies)"}),t.jsxs("select",{value:"",onChange:Z=>{const oe=Z.target.value;oe&&!se.includes(oe)&&xe([...se,oe])},className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"",children:"Select a task to depend on…"}),Object.values(p).flat().filter(Z=>Z.status!=="completed"&&Z.status!=="cancelled"&&!se.includes(Z.id)).map(Z=>t.jsx("option",{value:Z.id,children:Z.title},Z.id))]}),se.length>0&&t.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:se.map(Z=>{const oe=Object.values(p).flat().find(me=>me.id===Z);return t.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] px-2 py-1 bg-amber-500/10 text-amber-600 rounded-full",children:["⏳ ",oe?oe.title.slice(0,30):Z.slice(-8),t.jsx("button",{onClick:()=>xe(se.filter(me=>me!==Z)),className:"ml-0.5 text-amber-600/60 hover:text-amber-600",children:"×"})]},Z)})})]}),t.jsxs("div",{className:"flex justify-end gap-3 pt-1",children:[t.jsx("button",{onClick:()=>D(!1),className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated text-fg-secondary",children:"Cancel"}),t.jsx("button",{onClick:()=>{Qn()},disabled:!H||!L,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 rounded-lg text-white disabled:opacity-50",children:"Create"})]})]})}),qt&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-3",onClick:()=>{yt(!1),Xt(""),Pe("")},children:t.jsxs("div",{className:`bg-surface-secondary border border-border-default rounded-xl p-6 space-y-4 max-h-[90dvh] overflow-y-auto ${r?"w-full":"w-[28rem]"}`,onClick:Z=>Z.stopPropagation(),children:[t.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:"New Requirement"}),t.jsx("p",{className:"text-xs text-fg-tertiary -mt-2",children:"Describe what you need. Agents will break approved requirements into tasks."}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Project"}),t.jsxs("select",{value:ut,onChange:Z=>Wt(Z.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"",children:"Select a project…"}),c.map(Z=>t.jsx("option",{value:Z.id,children:Z.name},Z.id))]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Title"}),t.jsx("input",{value:sn,onChange:Z=>Xt(Z.target.value),placeholder:"e.g. Add user authentication",className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none",autoFocus:!r,onKeyDown:Z=>{Z.key==="Enter"&&sn.trim()&&or()}})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Description"}),t.jsx("textarea",{value:je,onChange:Z=>Pe(Z.target.value),placeholder:"What is needed and why...",rows:3,className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none resize-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Priority"}),t.jsxs("select",{value:vt,onChange:Z=>Nt(Z.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"low",children:"Low"}),t.jsx("option",{value:"medium",children:"Medium"}),t.jsx("option",{value:"high",children:"High"}),t.jsx("option",{value:"urgent",children:"Urgent"})]})]}),t.jsxs("div",{className:"flex justify-end gap-3 pt-1",children:[t.jsx("button",{onClick:()=>{yt(!1),Xt(""),Pe("")},className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated text-fg-secondary",children:"Cancel"}),t.jsx("button",{onClick:()=>{or()},disabled:!sn.trim()||!je.trim()||!ut,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 rounded-lg text-white disabled:opacity-40 disabled:cursor-not-allowed",children:"Create"})]})]})}),en&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-3",onClick:()=>Ct(null),children:t.jsxs("div",{className:`bg-surface-secondary border border-border-default rounded-xl p-6 space-y-4 ${r?"w-full":"w-96"}`,onClick:Z=>Z.stopPropagation(),children:[t.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:"Reject Requirement"}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Reason"}),t.jsx("textarea",{value:de,onChange:Z=>Be(Z.target.value),placeholder:"Why is this being rejected...",rows:3,className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-red-500 outline-none resize-none",autoFocus:!r})]}),t.jsxs("div",{className:"flex justify-end gap-3",children:[t.jsx("button",{onClick:()=>Ct(null),className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated text-fg-secondary",children:"Cancel"}),t.jsx("button",{onClick:()=>{cr()},className:"px-4 py-2 text-sm bg-red-600 hover:bg-red-500 rounded-lg text-white",children:"Reject"})]})]})}),zt&&t.jsxs("div",{className:"fixed inset-0 z-[60] flex flex-col justify-end",onClick:()=>Yt(!1),children:[t.jsx("div",{className:"absolute inset-0 bg-black/50"}),t.jsxs("div",{className:"relative bg-surface-secondary rounded-t-2xl border-t border-border-default max-h-[70vh] overflow-y-auto pb-16",onClick:Z=>Z.stopPropagation(),children:[t.jsxs("div",{className:"sticky top-0 bg-surface-secondary z-10 px-4 pt-3 pb-2 flex items-center justify-between border-b border-border-default/60",children:[t.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:"Filters"}),t.jsxs("div",{className:"flex items-center gap-2",children:[(ae.size>0||dt.size>0)&&t.jsx("button",{onClick:()=>{Te(new Set),wt(new Set)},className:"text-[11px] text-brand-500 font-medium",children:"Clear all"}),t.jsx("button",{onClick:()=>Yt(!1),className:"w-7 h-7 flex items-center justify-center rounded-full bg-surface-elevated text-fg-tertiary",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),c.length>1&&t.jsxs("div",{className:"px-4 py-3",children:[t.jsx("div",{className:"text-[11px] text-fg-tertiary font-medium uppercase tracking-wider mb-2",children:"Projects"}),t.jsx("div",{className:"flex flex-wrap gap-1.5",children:Tr.map(Z=>{const oe=ae.has(Z.id),me=cs[Z.id]??0;return t.jsxs("button",{onClick:()=>He(Z.id),className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-[11px] transition-all ${oe?"bg-brand-500/15 text-brand-600 ring-1 ring-brand-500/30":"bg-surface-elevated text-fg-secondary"}`,children:[t.jsx("span",{className:`w-4 h-4 rounded-sm flex items-center justify-center text-[9px] font-bold shrink-0 ${oe?"bg-brand-600 text-white":"bg-surface-overlay text-fg-tertiary"}`,children:Z.name[0]?.toUpperCase()}),Z.name,me>0&&t.jsx("span",{className:"text-[9px] text-fg-tertiary",children:me})]},Z.id)})})]}),w.length>0&&t.jsxs("div",{className:"px-4 py-3 border-t border-border-default/40",children:[t.jsx("div",{className:"text-[11px] text-fg-tertiary font-medium uppercase tracking-wider mb-2",children:"Agents"}),t.jsx("div",{className:"flex flex-wrap gap-1.5",children:An.map(Z=>{const oe=dt.has(Z.id);return t.jsxs("button",{onClick:()=>Se(Z.id),className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-[11px] transition-all ${oe?"bg-brand-600/20 text-brand-500 ring-1 ring-brand-500/40":"bg-surface-elevated text-fg-secondary"}`,children:[t.jsx("span",{className:`w-4 h-4 rounded-full flex items-center justify-center text-[9px] font-bold shrink-0 ${oe?"bg-brand-600 text-white":"bg-surface-overlay text-fg-tertiary"}`,children:Z.name[0]?.toUpperCase()}),Z.name]},Z.id)})})]}),t.jsx("div",{className:"h-[env(safe-area-inset-bottom,0px)]"})]})]})]})}function Iz({requirementId:e,agents:r,authUser:s}){const[l,o]=v.useState([]);v.useEffect(()=>{re.requirements.getComments(e).then(c=>o(c.comments)).catch(()=>{})},[e]),v.useEffect(()=>kn.on("requirement:comment",h=>{h.payload?.requirementId===e&&h.payload.comment&&o(m=>m.some(f=>f.id===h.payload.comment.id)?m:[...m,h.payload.comment])}),[e]);const d=async(c,h)=>{await re.requirements.addComment(e,c,s?.name,s?.id,h.length>0?h:void 0)};return t.jsxs("div",{children:[t.jsxs("label",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2 block",children:["Comments ",l.length>0&&t.jsxs("span",{className:"font-normal",children:["(",l.length,")"]})]}),t.jsxs("div",{className:"space-y-0.5 mb-3",children:[l.length===0&&t.jsx("p",{className:"text-xs text-fg-tertiary text-center py-4",children:"No comments yet."}),l.map(c=>t.jsx(yo,{comment:c,agents:r},c.id))]}),t.jsx(yj,{agents:r,onSubmit:d})]})}function $z({req:e,agents:r,projects:s,allTasks:l,users:o,onClose:d,onApprove:c,onReject:h,onCancel:m,onStatusChange:f,onRefresh:x,authUser:g}){const p=ks(),[y,w]=v.useState(!1),[N,E]=v.useState(e.description),[A,C]=v.useState(!1),k=Oo[e.status]??{label:e.status,cls:"bg-gray-500/15 text-fg-secondary"},S=e.source==="agent",O=S&&e.status==="pending",R=e.status==="pending"||e.status==="in_progress",G=e.status==="completed"||e.status==="rejected"||e.status==="cancelled",I=e.projectId?s.find(F=>F.id===e.projectId):null,Q=ii(e.createdBy,r,o)??e.createdBy.slice(0,12),$=l.filter(F=>e.taskIds.includes(F.id));return v.useEffect(()=>{E(e.description),w(!1)},[e.id,e.description]),t.jsxs("div",{className:"flex flex-col h-full overflow-hidden bg-surface-secondary",children:[t.jsxs("div",{className:"flex items-start justify-between gap-4 p-5 pb-0 border-b border-border-default",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[p&&t.jsx("button",{onClick:d,className:"text-fg-secondary hover:text-fg-primary transition-colors p-1 -ml-1 shrink-0",children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"15 18 9 12 15 6"})})}),t.jsxs("div",{className:"flex-1 min-w-0 pb-4",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("span",{className:"text-[10px] font-bold text-brand-500 bg-brand-500/15 px-2 py-0.5 rounded",children:"REQ"}),t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded-full font-medium ${k.cls}`,children:k.label}),e.priority==="high"||e.priority==="urgent"?t.jsx("span",{className:`text-[10px] font-medium ${e.priority==="urgent"?"text-red-500":"text-amber-600"}`,children:e.priority}):t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:e.priority})]}),t.jsx("h2",{className:"text-lg font-semibold text-fg-primary leading-snug",children:e.title})]})]}),!p&&t.jsx("button",{onClick:d,className:"text-fg-tertiary hover:text-fg-secondary text-xl leading-none shrink-0 mt-1",children:"×"})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto p-5 space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-1 block",children:"Description"}),y?t.jsxs("div",{className:"space-y-2",children:[t.jsx("textarea",{value:N,onChange:F=>E(F.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none resize-y min-h-[80px]",rows:4,autoFocus:!0}),t.jsxs("div",{className:"flex gap-2 justify-end",children:[t.jsx("button",{onClick:()=>{w(!1),E(e.description)},className:"px-2.5 py-1 text-xs border border-border-default rounded-lg hover:bg-surface-elevated",children:"Cancel"}),t.jsx("button",{onClick:async()=>{C(!0);try{await re.requirements.update(e.id,{description:N}),w(!1),x?.()}catch{}finally{C(!1)}},disabled:A,className:"px-2.5 py-1 text-xs bg-brand-600 hover:bg-brand-500 rounded-lg text-white disabled:opacity-50",children:"Save"})]})]}):t.jsxs("div",{className:"group relative",children:[e.description?t.jsx(Zn,{content:e.description,className:"text-sm text-fg-secondary leading-relaxed"}):t.jsx("p",{className:"text-sm text-fg-tertiary italic",children:"No description"}),!G&&t.jsx("button",{onClick:()=>{E(e.description),w(!0)},className:"absolute top-0 right-0 text-[10px] text-fg-tertiary hover:text-brand-500 opacity-0 group-hover:opacity-100 transition-opacity",children:"Edit"})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-3 text-xs",children:[t.jsxs("div",{className:"bg-surface-elevated/60 rounded-lg p-2.5",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary block mb-1",children:"Created by"}),t.jsx("span",{className:"text-fg-secondary",children:Q}),S&&t.jsx("span",{className:"text-[10px] text-brand-500 ml-1.5",children:"(Agent)"})]}),t.jsxs("div",{className:"bg-surface-elevated/60 rounded-lg p-2.5",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary block mb-1",children:"Created"}),t.jsx("span",{className:"text-fg-secondary",children:new Date(e.createdAt).toLocaleString()})]}),I&&t.jsxs("div",{className:"bg-surface-elevated/60 rounded-lg p-2.5",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary block mb-1",children:"Project"}),t.jsx("span",{className:"text-fg-secondary",children:I.name})]}),e.approvedBy&&t.jsxs("div",{className:"bg-surface-elevated/60 rounded-lg p-2.5",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary block mb-1",children:"Approved by"}),t.jsx("span",{className:"text-fg-secondary",children:ii(e.approvedBy,r,o)??e.approvedBy.slice(0,12)}),e.approvedAt&&t.jsx("span",{className:"text-[10px] text-fg-tertiary ml-1",children:new Date(e.approvedAt).toLocaleDateString()})]})]}),e.rejectedReason&&t.jsxs("div",{className:"bg-red-500/10 border border-red-500/20 rounded-lg p-3",children:[t.jsx("span",{className:"text-[10px] font-semibold text-red-500 uppercase tracking-wider block mb-1",children:"Rejection Reason"}),t.jsx("p",{className:"text-sm text-red-500/80",children:e.rejectedReason})]}),Array.isArray(e.tags)&&e.tags.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1",children:e.tags.map(F=>t.jsxs("span",{className:"text-[10px] bg-surface-elevated text-fg-secondary px-2 py-0.5 rounded-full",children:["#",F]},F))}),$.length>0&&t.jsxs("div",{children:[t.jsxs("label",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2 block",children:["Linked Tasks (",$.length,")"]}),t.jsx("div",{className:"space-y-1.5",children:$.map(F=>{const B=kN[F.status];return t.jsxs("div",{className:"flex items-center gap-2 bg-surface-elevated/60 rounded-lg px-3 py-2",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${vz[F.priority]?.replace("border-l-","bg-")??"bg-gray-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:F.title}),B&&t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded shrink-0 ${B.cls}`,children:B.label})]},F.id)})})]}),t.jsx(Iz,{requirementId:e.id,agents:r,authUser:g})]}),t.jsxs("div",{className:"flex items-center gap-2 p-5 pt-3 border-t border-border-default",children:[O&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>c(e.id),className:"px-4 py-2 bg-green-600 hover:bg-green-500 text-white text-sm rounded-lg font-medium transition-colors",children:"Approve"}),t.jsx("button",{onClick:()=>h(e.id),className:"px-4 py-2 border border-red-500/30 hover:bg-red-500/10 text-red-500 text-sm rounded-lg font-medium transition-colors",children:"Reject"})]}),!O&&f&&!G&&t.jsx("select",{value:e.status,onChange:F=>{F.target.value!==e.status&&f(e.id,F.target.value)},className:"px-2 py-1.5 text-xs bg-surface-elevated border border-border-default rounded-lg text-fg-secondary cursor-pointer hover:border-gray-500 transition-colors",children:Oz.map(F=>{const B=Oo[F];return t.jsx("option",{value:F,children:B?.label??F},F)})}),G&&f&&t.jsx("button",{onClick:()=>f(e.id,"in_progress"),className:"px-3 py-1.5 text-xs border border-border-default hover:bg-surface-elevated rounded-lg text-fg-secondary transition-colors",children:"Reopen"}),t.jsx("div",{className:"flex-1"}),R&&!O&&t.jsx("button",{onClick:()=>m(e.id),className:"px-3 py-1.5 text-xs text-red-500/70 hover:text-red-500 hover:bg-red-500/10 border border-transparent hover:border-red-500/20 rounded-lg transition-colors",children:"Cancel Requirement"})]})]})}function xs(e){return Array.isArray(e)?e.map(r=>String(r).trim()).filter(Boolean):typeof e=="string"&&e?e.split(",").map(r=>r.trim()).filter(Boolean):[]}function Bz(e){return e.files&&typeof e.files=="object"&&!Array.isArray(e.files)?e.files:null}function Ka({label:e,value:r}){return r?t.jsxs("div",{children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:e}),t.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:r})]}):null}function Ul({label:e,value:r,color:s}){if(!r)return null;const l={purple:"bg-brand-500/15 text-brand-500",cyan:"bg-blue-500/15 text-blue-600",indigo:"bg-brand-500/15 text-brand-500",gray:"bg-gray-500/15 text-fg-secondary",emerald:"bg-green-500/15 text-green-600"};return t.jsxs("div",{children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:e}),t.jsx("div",{className:`mt-0.5 px-2 py-0.5 rounded-full text-[10px] font-medium ${l[s]??l.gray} capitalize inline-block`,children:r})]})}function tm({files:e}){const[r,s]=v.useState(Object.keys(e)[0]??""),l=Object.keys(e);return l.length===0?null:t.jsxs("div",{children:[t.jsxs("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:["Files (",l.length,")"]}),t.jsxs("div",{className:"mt-1 bg-surface-elevated/50 rounded-lg border border-border-default/30 overflow-hidden",children:[t.jsx("div",{className:"flex gap-0.5 px-1.5 py-1 border-b border-border-default/30 overflow-x-auto",children:l.map(o=>t.jsx("button",{onClick:()=>s(o),className:`px-2 py-0.5 text-[10px] rounded whitespace-nowrap transition-colors ${r===o?"bg-brand-600/30 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:o},o))}),r&&e[r]!=null&&t.jsx("pre",{className:"p-2 text-[10px] text-fg-secondary max-h-[120px] overflow-auto whitespace-pre-wrap font-mono",children:e[r]})]})]})}function Hz({artifact:e,mode:r}){const s=Bz(e),l=e.agent,o=e.team,d=e.dependencies,c=e.displayName??e.name;if(r==="agent"){const h=l?.roleName,m=l?.agentRole,f=l?.llmProvider,x=l?.llmModel,g=xs(d?.env),p=xs(d?.skills);return t.jsxs("div",{className:"space-y-3 text-sm",children:[t.jsx(Ka,{label:"Name",value:c}),t.jsx(Ka,{label:"Description",value:e.description}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(Ul,{label:"Role Template",value:h,color:"indigo"}),t.jsx(Ul,{label:"Agent Role",value:m,color:m==="manager"?"purple":"cyan"})]}),xs(e.tags).length>0&&t.jsx("div",{className:"flex flex-wrap gap-1",children:xs(e.tags).map(y=>t.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:y},y))}),(f||x)&&t.jsxs("div",{className:"flex gap-2",children:[f&&t.jsx(Ul,{label:"LLM Provider",value:f,color:"gray"}),x&&t.jsx(Ul,{label:"LLM Model",value:x,color:"gray"})]}),g.length>0&&t.jsxs("div",{children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:"Required Env"}),t.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:g.map(y=>t.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-amber-500/10 text-amber-600 rounded font-mono",children:y},y))})]}),p.length>0&&t.jsx(Ka,{label:"Skills",value:p.join(", ")}),s&&t.jsx(tm,{files:s})]})}if(r==="team"){const m=o?.members??[];return t.jsxs("div",{className:"space-y-3 text-sm",children:[t.jsx(Ka,{label:"Name",value:c}),t.jsx(Ka,{label:"Description",value:e.description}),t.jsx("div",{className:"flex flex-wrap gap-2",children:t.jsx(Ul,{label:"Category",value:e.category,color:"indigo"})}),xs(e.tags).length>0&&t.jsx("div",{className:"flex flex-wrap gap-1",children:xs(e.tags).map(f=>t.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:f},f))}),s&&t.jsx(tm,{files:s}),t.jsxs("div",{children:[t.jsxs("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:["Members (",m.length,")"]}),t.jsx("div",{className:"mt-1.5 space-y-1.5",children:m.map((f,x)=>t.jsxs("div",{className:"bg-surface-elevated/30 rounded-lg px-2 py-1.5 border border-border-default/20",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`w-5 h-5 rounded flex items-center justify-center text-[10px] font-bold ${f.role==="manager"?"bg-brand-500/20 text-brand-500":"bg-blue-500/20 text-blue-600"}`,children:f.role==="manager"?"★":x+1}),t.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:f.name}),typeof f.roleName=="string"&&f.roleName&&t.jsx("span",{className:"text-[10px] text-brand-500/70 font-mono",children:f.roleName}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["x",String(f.count??1)]})]}),xs(f.skills).length>0&&t.jsx("div",{className:"mt-1 ml-7 flex flex-wrap gap-1",children:xs(f.skills).map(g=>t.jsx("span",{className:"px-1 py-0.5 text-[9px] bg-green-500/10 text-green-600 rounded font-mono",children:g},g))})]},x))})]})]})}return t.jsxs("div",{className:"space-y-3 text-sm",children:[t.jsx(Ka,{label:"Name",value:c}),t.jsx(Ka,{label:"Description",value:e.description}),t.jsx("div",{className:"flex gap-2",children:t.jsx(Ul,{label:"Category",value:e.category,color:"indigo"})}),s&&t.jsx(tm,{files:s}),xs(e.tags).length>0&&t.jsx("div",{className:"flex flex-wrap gap-1",children:xs(e.tags).map(h=>t.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:h},h))})]})}const lo={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},Yv={active:{label:"Active",color:"text-green-600 bg-green-500/10"},verified:{label:"Verified",color:"text-blue-600 bg-blue-500/10"},outdated:{label:"Outdated",color:"text-red-500 bg-red-500/10"}},Gv=["file","directory"],gs={agent:{icon:"✦",label:"Agent",color:"bg-brand-500/10 text-brand-500"},team:{icon:"◈",label:"Team",color:"bg-blue-500/10 text-blue-600"},skill:{icon:"⬡",label:"Skill",color:"bg-amber-500/10 text-amber-600"}};function Xv(){const e=ks(),r=Wd({side:"left",defaultWidth:384,minWidth:280,maxWidth:600,storageKey:"markus_deliverables_list"}),[s,l]=v.useState(!1),o=v.useRef(s);o.current=s,v.useEffect(()=>{if(!e)return;const fe=()=>{o.current&&l(!1)};return window.addEventListener("popstate",fe),()=>window.removeEventListener("popstate",fe)},[e]);const d=100,[c,h]=v.useState([]),[m,f]=v.useState(0),[x,g]=v.useState(!1),[p,y]=v.useState([]),[w,N]=v.useState([]),[E,A]=v.useState(!0),[C,k]=v.useState(""),[S,O]=v.useState(""),[R,G]=v.useState(""),[I,Q]=v.useState(""),[$,F]=v.useState(""),[B,T]=v.useState(""),[D,z]=v.useState(""),[_,Y]=v.useState("date"),[V,J]=v.useState(null),[U,H]=v.useState(null),[X,L]=v.useState(""),[M,q]=v.useState(!1),[K,ee]=v.useState(!1),[te,se]=v.useState(new Set),xe=v.useRef(null),[ke,De]=v.useState("file"),[ge,ye]=v.useState(""),[Ce,ze]=v.useState(""),[tt,Xe]=v.useState(""),[dt,wt]=v.useState(""),[ae,Te]=v.useState(""),[Ze,xt]=v.useState(null),[dn,we]=v.useState(null),[Re,qe]=v.useState(!1),[et,nt]=v.useState(!1),[zt,Yt]=v.useState(!1),[Lt,Tt]=v.useState(!1),qt=v.useRef(null),yt=v.useRef(null),[sn,Xt]=v.useState(""),je=v.useRef(void 0),Pe=(fe,Fe)=>{H({type:fe,text:Fe}),setTimeout(()=>H(null),3e3)},vt=async fe=>{try{return await navigator.clipboard.writeText(fe),!0}catch{try{const Fe=document.createElement("textarea");Fe.value=fe,Fe.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0",document.body.appendChild(Fe),Fe.select();const kt=document.execCommand("copy");return document.body.removeChild(Fe),kt}catch{return!1}}},Nt=async fe=>{await vt(fe)?(Tt(!0),setTimeout(()=>Tt(!1),1500)):Pe("error","Copy failed — try long-pressing to copy manually")},ut=v.useMemo(()=>new Map(w.map(fe=>[fe.id,fe])),[w]),Wt=v.useMemo(()=>new Map(p.map(fe=>[fe.id,fe])),[p]);v.useEffect(()=>{re.projects.list().then(fe=>y(fe.projects)).catch(()=>{}),re.agents.list().then(fe=>N(fe.agents??[])).catch(()=>{}),re.system.storage().then(fe=>Xt(fe.dataDir+"/shared")).catch(()=>{})},[]),v.useEffect(()=>(je.current=setTimeout(()=>O(C),300),()=>clearTimeout(je.current)),[C]);const en=v.useMemo(()=>({q:S||void 0,projectId:I||void 0,agentId:$||void 0,type:R||void 0,status:B||void 0,artifactType:D||void 0}),[S,I,$,R,B,D]),Ct=v.useCallback(async()=>{A(!0);try{const{results:fe,total:Fe}=await re.deliverables.search({...en,offset:0,limit:d});h(fe),f(Fe)}catch{h([]),f(0)}A(!1)},[en]),de=v.useCallback(async()=>{if(!(x||c.length>=m)){g(!0);try{const{results:fe,total:Fe}=await re.deliverables.search({...en,offset:c.length,limit:d});h(kt=>[...kt,...fe]),f(Fe)}catch{}g(!1)}},[en,c.length,m,x]);v.useEffect(()=>{Ct()},[Ct]),v.useEffect(()=>kn.on("deliverable:created",()=>Ct()),[Ct]);const Be=v.useCallback(()=>{const fe=xe.current;!fe||E||x||c.length>=m||fe.scrollHeight<=fe.clientHeight+100&&de()},[E,x,c.length,m,de]);v.useEffect(()=>{const fe=xe.current;if(!fe)return;const Fe=()=>{fe.scrollTop+fe.clientHeight>=fe.scrollHeight-100&&de()};return fe.addEventListener("scroll",Fe,{passive:!0}),()=>fe.removeEventListener("scroll",Fe)},[de]),v.useEffect(()=>{Be()},[Be,te]);const Le=v.useMemo(()=>{const fe=new Map;for(const kt of c){let St,Tn;if(_==="project")St=kt.projectId??"_none",Tn=kt.projectId?Wt.get(kt.projectId)?.name??kt.projectId:"No Project";else if(_==="agent")St=kt.agentId??"_none",Tn=kt.agentId?ut.get(kt.agentId)?.name??kt.agentId:"Unknown";else if(_==="type")St=kt.type,Tn=kt.type.charAt(0).toUpperCase()+kt.type.slice(1);else{const Qn=new Date(kt.updatedAt);St=`${Qn.getFullYear()}-${String(Qn.getMonth()+1).padStart(2,"0")}-${String(Qn.getDate()).padStart(2,"0")}`,Tn=St}fe.has(St)||fe.set(St,{label:Tn,items:[]}),fe.get(St).items.push(kt)}const Fe=[...fe.entries()];return _==="date"?Fe.sort((kt,St)=>St[0].localeCompare(kt[0])):Fe.sort((kt,St)=>kt[1].label.localeCompare(St[1].label)),Fe},[c,_,Wt,ut]),ot=async()=>{if(!(!ge.trim()||!Ce.trim())){ee(!0);try{await re.deliverables.create({type:ke,title:ge,summary:Ce,reference:tt,projectId:dt||void 0,tags:ae.split(",").map(fe=>fe.trim()).filter(Boolean)}),q(!1),Pe("success","Deliverable created"),Ct()}catch(fe){Pe("error",`Error: ${fe}`)}ee(!1)}},Qe=async fe=>{L("verify");try{await re.deliverables.verify(fe.id),Pe("success","Verified"),J({...fe,status:"verified"}),Ct()}catch(Fe){Pe("error",`Error: ${Fe}`)}L("")},ft=async fe=>{L("flag");try{await re.deliverables.update(fe.id,{status:"outdated"}),Pe("success","Flagged as outdated"),J({...fe,status:"outdated"}),Ct()}catch(Fe){Pe("error",`Error: ${Fe}`)}L("")},Zt=async fe=>{L("remove");try{await re.deliverables.remove(fe.id),Pe("success","Removed"),J(null),Ct()}catch(Fe){Pe("error",`Error: ${Fe}`)}L("")},it=()=>{jt.navigate("builder")},gt=async fe=>{if(fe.reference){if(fe.type==="directory"){nt(!0);return}qe(!0);try{const Fe=await re.files.preview(fe.reference);Fe.type==="image"&&Fe.mimeType?we({src:`data:${Fe.mimeType};base64,${Fe.content}`,name:Fe.name}):xt(Fe.content)}catch{xt(null),fe.type==="file"&&nt(!0)}qe(!1)}};v.useEffect(()=>{xt(null),we(null),nt(!1),Yt(!1),V&>(V)},[V?.id]),v.useEffect(()=>{if(!zt)return;const fe=Fe=>{yt.current&&!yt.current.contains(Fe.target)&&Yt(!1)};return document.addEventListener("mousedown",fe),()=>document.removeEventListener("mousedown",fe)},[zt]);const wn=async(fe,Fe)=>{const kt=qt.current?.firstElementChild;if(!kt)return;const St=Pz(kt,fe);try{await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([St],{type:"text/html"}),"text/plain":new Blob([Fe],{type:"text/plain"})})]),Pe("success",fe==="light"?"HTML (light) copied":"HTML (dark) copied")}catch{const Tn=await vt(Fe);Pe(Tn?"success":"error",Tn?"Text copied (HTML not supported)":"Copy failed")}Yt(!1)},an=fe=>t.jsxs("div",{className:"relative group/preview",children:[t.jsxs("div",{className:"absolute -top-1 -right-1 z-10",ref:yt,children:[t.jsx("button",{onClick:()=>Yt(Fe=>!Fe),className:"p-1.5 rounded-lg bg-surface-elevated/80 hover:bg-surface-overlay text-fg-secondary hover:text-fg-primary backdrop-blur-sm border border-border-default/50 transition-all",title:"Copy content",children:t.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),zt&&t.jsxs("div",{className:"absolute right-0 top-full mt-1 bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 min-w-[180px]",children:[t.jsxs("button",{onClick:async()=>{const Fe=await vt(fe);Pe(Fe?"success":"error",Fe?"Markdown source copied":"Copy failed"),Yt(!1)},className:"w-full px-3 py-2 text-left text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-2",children:[t.jsx("span",{className:"w-4 text-center text-fg-tertiary shrink-0 font-mono text-[10px]",children:"Md"}),"Copy Markdown Source"]}),t.jsxs("button",{onClick:()=>wn("light",fe),className:"w-full px-3 py-2 text-left text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-2",children:[t.jsx("span",{className:"w-4 text-center shrink-0",children:"☀️"}),"Copy HTML (Light)"]}),t.jsxs("button",{onClick:()=>wn("dark",fe),className:"w-full px-3 py-2 text-left text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-2",children:[t.jsx("span",{className:"w-4 text-center shrink-0",children:"🌙"}),"Copy HTML (Dark)"]})]})]}),t.jsx("div",{ref:qt,children:t.jsx(Zn,{content:fe,className:"text-fg-secondary text-sm"})})]}),Qt=v.useCallback(fe=>{se(Fe=>{const kt=new Set(Fe);return kt.has(fe)?kt.delete(fe):kt.add(fe),kt})},[]),At=v.useCallback(()=>{te.size===Le.length?se(new Set):se(new Set(Le.map(([fe])=>fe)))},[te.size,Le]),un=()=>{ye(""),ze(""),Xe(""),Te(""),De("file"),p.length>0&&wt(p[0].id),q(!0)},En=fe=>{J(fe),e&&(l(!0),history.pushState({mobileDetail:"deliverables"},"",window.location.hash))};return t.jsxs("div",{className:"flex-1 overflow-hidden flex",children:[t.jsxs("div",{className:`${e?"flex-1 min-w-0":"shrink-0"} border-r border-border-default flex flex-col bg-surface-primary`,style:e?s?{display:"none"}:void 0:{width:r.width},children:[t.jsxs("div",{className:"p-4 border-b border-border-default space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("h2",{className:"text-sm font-semibold text-fg-secondary",children:["Deliverables",m>0&&t.jsxs("span",{className:"ml-1.5 text-fg-tertiary font-normal",children:["(",m,")"]})]}),t.jsx("button",{onClick:un,className:"text-xs px-2.5 py-1 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:"+ Create"})]}),t.jsx("input",{value:C,onChange:fe=>k(fe.target.value),placeholder:"Search deliverables...",className:"w-full bg-surface-elevated border border-border-default rounded-lg px-3 py-2 text-sm text-fg-primary focus:border-brand-500 focus:outline-none transition-colors"}),sn&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1.5 bg-surface-elevated/50 border border-border-default rounded-lg text-[10px] text-fg-tertiary",children:[t.jsx("span",{className:"truncate font-mono",children:sn}),t.jsx("button",{onClick:()=>{re.system.openPath(sn)},className:"shrink-0 underline hover:text-fg-secondary transition-colors",children:"Open"})]}),t.jsxs("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:[t.jsx(Ea,{label:"All types",value:"",current:R||D||"",onClick:()=>{G(""),z("")}}),Gv.map(fe=>t.jsx(Ea,{label:`${lo[fe]?.icon??""} ${fe}`,value:fe,current:R,onClick:Fe=>{G(Fe),z("")}},fe)),["agent","team","skill"].map(fe=>t.jsx(Ea,{label:`${gs[fe].icon} ${gs[fe].label}`,value:fe,current:D,onClick:Fe=>{z(Fe),G("")}},fe))]}),p.length>0&&t.jsxs("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:[t.jsx(Ea,{label:"All projects",value:"",current:I,onClick:Q}),p.map(fe=>t.jsx(Ea,{label:fe.name,value:fe.id,current:I,onClick:Q},fe.id))]}),t.jsxs("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:[t.jsx(Ea,{label:"Active",value:"",current:B,onClick:T}),t.jsx(Ea,{label:"Verified",value:"verified",current:B,onClick:T}),t.jsx(Ea,{label:"Outdated",value:"outdated",current:B,onClick:T})]}),t.jsxs("div",{className:"flex gap-1.5 items-center",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:"Group:"}),["date","project","agent","type"].map(fe=>t.jsx("button",{onClick:()=>{Y(fe),se(new Set)},className:`px-2 py-1 rounded text-xs transition-colors ${_===fe?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:bg-surface-overlay"}`,children:fe.charAt(0).toUpperCase()+fe.slice(1)},fe)),Le.length>1&&t.jsx("button",{onClick:At,className:"ml-auto px-1.5 py-1 rounded text-[10px] text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated transition-colors",title:te.size===Le.length?"Expand all":"Collapse all",children:te.size===Le.length?"▶ Expand":"▼ Collapse"})]})]}),U&&t.jsx("div",{className:`mx-4 mt-2 px-3 py-1.5 text-xs rounded-lg ${U.type==="success"?"bg-green-500/15 text-green-600":"bg-red-500/15 text-red-500"}`,children:U.text}),t.jsxs("div",{ref:xe,className:"flex-1 overflow-y-auto p-2 space-y-1",children:[E?t.jsx("div",{className:"p-4 space-y-3",children:[1,2,3].map(fe=>t.jsxs("div",{className:"animate-pulse space-y-2",children:[t.jsx("div",{className:"h-4 bg-surface-elevated rounded w-3/4"}),t.jsx("div",{className:"h-3 bg-surface-elevated rounded w-1/2"})]},fe))}):c.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-6 text-center",children:[t.jsx("svg",{className:"w-12 h-12 text-fg-muted mb-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),t.jsx("p",{className:"text-sm text-fg-secondary",children:"No deliverables yet"}),t.jsx("p",{className:"text-xs text-fg-tertiary mt-1 mb-3",children:"Deliverables are created when tasks complete or manually"}),t.jsx("button",{onClick:un,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:"+ Create first"})]}):Le.map(([fe,Fe])=>{const kt=te.has(fe);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>Qt(fe),className:"w-full flex items-center gap-1.5 px-2 py-1.5 rounded-md hover:bg-surface-elevated/50 transition-colors group/header",children:[t.jsx("svg",{className:`w-3 h-3 text-fg-tertiary transition-transform duration-200 shrink-0 ${kt?"":"rotate-90"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),t.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider truncate",children:Fe.label}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:["(",Fe.items.length,")"]})]}),!kt&&Fe.items.map(St=>t.jsxs("button",{onClick:()=>En(St),className:`w-full text-left p-3 rounded-lg transition-colors ${V?.id===St.id?"bg-brand-600/20 border border-brand-500/30":"hover:bg-surface-elevated/60 border border-transparent"}`,children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:St.title}),t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[St.artifactType&&gs[St.artifactType]?t.jsxs("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${gs[St.artifactType].color}`,children:[gs[St.artifactType].icon," ",gs[St.artifactType].label]}):t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium uppercase ${lo[St.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:St.type}),t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${Yv[St.status]?.color??"bg-surface-elevated text-fg-tertiary"}`,children:St.status}),St.agentId&&t.jsx("span",{className:"text-[10px] text-fg-tertiary truncate",children:ut.get(St.agentId)?.name??"Agent"})]})]},St.id))]},fe)}),x&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-fg-tertiary",children:[t.jsx(nm,{})," ",t.jsx("span",{className:"text-[10px]",children:"Loading more..."})]}),!E&&c.length>0&&t.jsx("div",{className:"text-center text-[10px] text-fg-tertiary py-2",children:c.length<m?`${c.length} / ${m} deliverables`:`${m} deliverables`})]})]}),!e&&t.jsx("div",{className:"w-1 shrink-0 cursor-col-resize hover:bg-brand-500/30 active:bg-brand-500/50 transition-colors",onMouseDown:r.onResizeStart}),(!e||s)&&t.jsxs("div",{className:"flex-1 overflow-y-auto min-w-0",children:[e&&t.jsxs("div",{className:"sticky top-0 z-10 bg-surface-secondary border-b border-border-default px-4 py-2.5 flex items-center gap-2",children:[t.jsx("button",{onClick:()=>history.back(),className:"text-fg-secondary hover:text-fg-primary transition-colors p-1 -ml-1",children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"15 18 9 12 15 6"})})}),t.jsx("span",{className:"text-sm font-medium truncate",children:V?.title??"Details"})]}),V?t.jsxs("div",{className:"p-6 space-y-5",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-semibold text-fg-primary",children:V.title}),t.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[V.status!=="verified"&&t.jsx("button",{onClick:()=>Qe(V),disabled:!!X,className:"px-3 py-1.5 text-xs rounded-lg bg-green-600/20 text-green-600 hover:bg-green-600/30 disabled:opacity-50 transition-colors",children:X==="verify"?"Verifying...":"Verify"}),V.status!=="outdated"&&t.jsx("button",{onClick:()=>ft(V),disabled:!!X,className:"px-3 py-1.5 text-xs rounded-lg bg-amber-600/20 text-amber-600 hover:bg-amber-600/30 disabled:opacity-50 transition-colors",children:X==="flag"?"Flagging...":"Flag Outdated"}),t.jsx("button",{onClick:()=>Zt(V),disabled:!!X,className:"px-3 py-1.5 text-xs rounded-lg bg-red-600/20 text-red-500 hover:bg-red-600/30 disabled:opacity-50 transition-colors",children:X==="remove"?"Removing...":"Remove"})]}),t.jsxs("div",{className:"flex items-center gap-3 mt-2 flex-wrap",children:[t.jsxs("span",{className:`px-2 py-0.5 rounded text-xs font-medium uppercase ${lo[V.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:[lo[V.type]?.icon??""," ",V.type]}),t.jsx("span",{className:`px-2 py-0.5 rounded text-xs ${Yv[V.status]?.color??"bg-surface-elevated text-fg-tertiary"}`,children:V.status}),V.artifactType&&gs[V.artifactType]&&t.jsxs("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${gs[V.artifactType].color}`,children:[gs[V.artifactType].icon," Builder ",gs[V.artifactType].label]})]}),V.reference&&(V.type==="file"||V.type==="directory")&&t.jsxs("div",{className:"flex items-center gap-2 mt-2 bg-surface-secondary/60 border border-border-default rounded-lg px-3 py-2",children:[t.jsx("button",{onClick:()=>{re.files.reveal(V.reference).catch(()=>Pe("error","Failed to open file browser"))},className:"text-xs font-mono text-brand-500 hover:text-brand-500 hover:underline truncate flex-1 text-left cursor-pointer",title:"Open in file browser",children:V.reference}),t.jsx("button",{onClick:()=>{re.files.reveal(V.reference).catch(()=>Pe("error","Failed to open file browser"))},className:"px-2 py-1 text-[10px] rounded bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",title:"Reveal in Finder",children:"Open"}),t.jsx("button",{onClick:()=>Nt(V.reference),className:`px-2 py-1 text-[10px] rounded transition-colors shrink-0 ${Lt?"bg-green-500/20 text-green-600":"bg-surface-overlay/50 text-fg-secondary hover:bg-surface-overlay"}`,title:"Copy path to clipboard",children:Lt?"Copied!":"Copy"})]}),V.reference&&V.type!=="file"&&V.type!=="directory"&&t.jsx("div",{className:"mt-2",children:t.jsx("span",{className:"text-xs text-fg-tertiary font-mono break-all",children:V.reference})})]}),V.artifactType&&V.artifactData?t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:t.jsx(Hz,{artifact:V.artifactData,mode:V.artifactType})}),V.reference&&t.jsxs("div",{className:"px-3 py-2 bg-surface-secondary/50 border border-border-default rounded-lg",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider block mb-1",children:"Artifact Directory"}),t.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all",children:V.reference})]}),t.jsx("div",{className:"flex gap-2",children:t.jsx("button",{onClick:it,className:"flex-1 px-4 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-sm font-medium rounded-lg transition-colors",children:"Open in Builder"})}),V.summary&&t.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:t.jsx(Zn,{content:V.summary,className:"text-fg-secondary text-sm"})})]}):t.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:Re?t.jsxs("div",{className:"flex items-center gap-2 text-fg-tertiary text-sm",children:[t.jsx(nm,{})," Loading preview..."]}):dn?t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx("img",{src:dn.src,alt:dn.name,className:"max-w-full max-h-[60vh] rounded-lg object-contain"}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:dn.name})]}):Ze?an(Ze):et?t.jsxs("div",{className:"space-y-3",children:[t.jsxs("p",{className:"text-sm text-fg-secondary",children:["This ",V.type," cannot be previewed in the browser."]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:()=>{re.files.reveal(V.reference).catch(()=>Pe("error","Failed to open"))},className:"text-xs bg-surface-elevated px-3 py-2 rounded text-brand-500 hover:text-brand-500 hover:underline flex-1 truncate text-left cursor-pointer font-mono",title:"Open in file browser",children:V.reference}),t.jsx("button",{onClick:()=>{re.files.reveal(V.reference).catch(()=>Pe("error","Failed to open"))},className:"px-3 py-2 text-xs rounded-lg bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",children:"Open"}),t.jsx("button",{onClick:()=>Nt(V.reference),className:`px-3 py-2 text-xs rounded-lg transition-colors shrink-0 ${Lt?"bg-green-500/20 text-green-600":"bg-surface-overlay/50 text-fg-secondary hover:bg-surface-overlay"}`,children:Lt?"Copied!":"Copy"})]})]}):V.summary?an(V.summary):t.jsx("p",{className:"text-sm text-fg-tertiary italic",children:"No content"})}),(V.diffStats||V.testResults)&&t.jsxs("div",{className:"flex gap-4 flex-wrap",children:[V.diffStats&&t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-lg px-4 py-3 text-xs space-y-1",children:[t.jsx("div",{className:"text-fg-tertiary font-medium",children:"Diff Stats"}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("span",{className:"text-fg-secondary",children:[V.diffStats.filesChanged," files"]}),t.jsxs("span",{className:"text-green-600",children:["+",V.diffStats.additions]}),t.jsxs("span",{className:"text-red-500",children:["-",V.diffStats.deletions]})]})]}),V.testResults&&t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-lg px-4 py-3 text-xs space-y-1",children:[t.jsx("div",{className:"text-fg-tertiary font-medium",children:"Tests"}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("span",{className:"text-green-600",children:[V.testResults.passed," passed"]}),t.jsxs("span",{className:"text-red-500",children:[V.testResults.failed," failed"]}),t.jsxs("span",{className:"text-fg-secondary",children:[V.testResults.skipped," skipped"]})]})]})]}),V.tags.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1.5",children:V.tags.map(fe=>t.jsx("span",{className:"px-2 py-0.5 text-xs bg-surface-elevated text-fg-secondary rounded",children:fe},fe))}),t.jsxs("div",{className:"border-t border-border-default pt-4 space-y-2",children:[t.jsx("div",{className:"text-xs text-fg-tertiary font-medium",children:"Links"}),t.jsxs("div",{className:"flex gap-3 flex-wrap",children:[V.taskId&&t.jsxs("button",{onClick:()=>jt.navigate("projects",{openTask:V.taskId}),className:"text-xs text-brand-500 hover:underline bg-brand-500/10 px-2.5 py-1 rounded",children:["Task: ",V.taskId.slice(0,12),"..."]}),V.agentId&&t.jsxs("button",{onClick:()=>jt.navigate("team",{selectAgent:V.agentId}),className:"text-xs text-blue-600 hover:underline bg-blue-500/10 px-2.5 py-1 rounded",children:["Agent: ",ut.get(V.agentId)?.name??V.agentId.slice(0,12)]}),V.projectId&&t.jsxs("button",{onClick:()=>jt.navigate("projects",{projectId:V.projectId}),className:"text-xs text-blue-600 hover:underline bg-blue-500/10 px-2.5 py-1 rounded",children:["Project: ",Wt.get(V.projectId)?.name??V.projectId.slice(0,12)]})]})]}),t.jsxs("div",{className:"text-xs text-fg-tertiary space-y-1 border-t border-border-default pt-4",children:[t.jsxs("div",{className:"flex gap-6 flex-wrap",children:[t.jsxs("span",{children:["Created: ",t.jsx("span",{className:"text-fg-secondary",children:new Date(V.createdAt).toLocaleString()})]}),t.jsxs("span",{children:["Updated: ",t.jsx("span",{className:"text-fg-secondary",children:new Date(V.updatedAt).toLocaleString()})]}),t.jsxs("span",{children:["Accessed: ",t.jsxs("span",{className:"text-fg-secondary",children:[V.accessCount,"x"]})]})]}),t.jsxs("div",{className:"text-fg-muted select-all",children:["ID: ",V.id]})]})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center h-full",children:t.jsxs("div",{className:"text-center text-fg-tertiary space-y-2",children:[t.jsx("svg",{className:"w-12 h-12 mx-auto text-fg-muted",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),t.jsx("p",{className:"text-sm",children:"Select a deliverable to view details"})]})})]}),M&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:()=>!K&&q(!1),children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[36rem] space-y-4",onClick:fe=>fe.stopPropagation(),children:[t.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:"Create Deliverable"}),t.jsxs("div",{children:[t.jsx("label",{className:"text-xs text-fg-tertiary block mb-1",children:"Type"}),t.jsx("select",{value:ke,onChange:fe=>De(fe.target.value),className:"w-full bg-surface-elevated border border-border-default rounded-lg px-3 py-2 text-sm text-fg-primary",children:Gv.map(fe=>t.jsxs("option",{value:fe,children:[lo[fe]?.icon??""," ",fe]},fe))})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"text-xs text-fg-tertiary block mb-1",children:["Title ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{value:ge,onChange:fe=>ye(fe.target.value),placeholder:"Clear, searchable title",className:"w-full bg-surface-elevated border border-border-default rounded-lg px-3 py-2 text-sm text-fg-primary focus:border-brand-500 focus:outline-none transition-colors"})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"text-xs text-fg-tertiary block mb-1",children:["Reference ",t.jsx("span",{className:"text-fg-tertiary",children:"(file path, URL, branch name)"})]}),t.jsx("input",{value:tt,onChange:fe=>Xe(fe.target.value),placeholder:"/path/to/file or https://...",className:"w-full bg-surface-elevated border border-border-default rounded-lg px-3 py-2 text-sm text-fg-primary focus:border-brand-500 focus:outline-none transition-colors font-mono"})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"text-xs text-fg-tertiary block mb-1",children:["Summary ",t.jsx("span",{className:"text-red-500",children:"*"})," ",t.jsx("span",{className:"text-fg-tertiary",children:"(Markdown)"})]}),t.jsx("textarea",{value:Ce,onChange:fe=>ze(fe.target.value),placeholder:"Describe the deliverable...",className:"w-full bg-surface-elevated border border-border-default rounded-lg px-3 py-2 text-sm text-fg-primary h-36 resize-none focus:border-brand-500 focus:outline-none transition-colors font-mono"})]}),t.jsxs("div",{className:"flex gap-4",children:[t.jsxs("div",{className:"flex-1",children:[t.jsxs("label",{className:"text-xs text-fg-tertiary block mb-1",children:["Tags ",t.jsx("span",{className:"text-fg-tertiary",children:"(comma separated)"})]}),t.jsx("input",{value:ae,onChange:fe=>Te(fe.target.value),placeholder:"react, api, docs",className:"w-full bg-surface-elevated border border-border-default rounded-lg px-3 py-2 text-sm text-fg-primary focus:border-brand-500 focus:outline-none transition-colors"})]}),t.jsxs("div",{className:"flex-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary block mb-1",children:"Project"}),t.jsxs("select",{value:dt,onChange:fe=>wt(fe.target.value),className:"w-full bg-surface-elevated border border-border-default rounded-lg px-3 py-2 text-sm text-fg-primary",children:[t.jsx("option",{value:"",children:"None"}),p.map(fe=>t.jsx("option",{value:fe.id,children:fe.name},fe.id))]})]})]}),t.jsxs("div",{className:"flex justify-end gap-3 pt-1 border-t border-border-default",children:[t.jsx("button",{onClick:()=>q(!1),disabled:K,className:"text-sm text-fg-tertiary hover:text-fg-secondary disabled:opacity-50 transition-colors py-2",children:"Cancel"}),t.jsxs("button",{onClick:ot,disabled:K||!ge.trim()||!Ce.trim(),className:"bg-brand-600 hover:bg-brand-500 text-white text-sm px-4 py-2 rounded-lg disabled:opacity-50 flex items-center gap-2 transition-colors",children:[K&&t.jsx(nm,{}),K?"Creating...":"Create"]})]})]})})]})}function Pz(e,r){const s=e.cloneNode(!0),l=r==="light"?{bg:"#ffffff",text:"#24292f",heading:"#1f2328",strong:"#1f2328",link:"#0969da",codeBg:"#eff1f3",codeText:"#24292f",preBg:"#f6f8fa",preText:"#24292f",preBorder:"#d0d7de",border:"#d0d7de",blockquoteBorder:"#d0d7de",blockquoteText:"#656d76",tableBorder:"#d0d7de",tableHeaderBg:"#f6f8fa",tableHeaderText:"#24292f",hrColor:"#d8dee4"}:{bg:"#0d1117",text:"#e6edf3",heading:"#f0f6fc",strong:"#f0f6fc",link:"#58a6ff",codeBg:"#161b22",codeText:"#e6edf3",preBg:"#161b22",preText:"#e6edf3",preBorder:"#30363d",border:"#30363d",blockquoteBorder:"#3b82f6",blockquoteText:"#8b949e",tableBorder:"#30363d",tableHeaderBg:"#161b22",tableHeaderText:"#e6edf3",hrColor:"#21262d"},o={p:`margin:0 0 10px;color:${l.text};line-height:1.7;`,h1:`font-size:1.6em;font-weight:700;color:${l.heading};margin:20px 0 10px;line-height:1.3;border-bottom:1px solid ${l.border};padding-bottom:6px;`,h2:`font-size:1.35em;font-weight:700;color:${l.heading};margin:18px 0 8px;line-height:1.3;`,h3:`font-size:1.15em;font-weight:600;color:${l.heading};margin:14px 0 6px;line-height:1.3;`,h4:`font-size:1em;font-weight:600;color:${l.heading};margin:12px 0 4px;`,strong:`font-weight:600;color:${l.strong};`,em:"font-style:italic;",a:`color:${l.link};text-decoration:underline;`,ul:"padding-left:1.5em;margin:0 0 10px;",ol:"padding-left:1.5em;margin:0 0 10px;",li:`margin:3px 0;line-height:1.7;color:${l.text};`,blockquote:`border-left:3px solid ${l.blockquoteBorder};padding:2px 0 2px 14px;margin:10px 0;color:${l.blockquoteText};`,hr:`border:none;border-top:1px solid ${l.hrColor};margin:20px 0;`,table:"border-collapse:collapse;width:100%;margin:10px 0;",thead:`background:${l.tableHeaderBg};`,th:`border:1px solid ${l.tableBorder};padding:8px 12px;text-align:left;font-weight:600;color:${l.tableHeaderText};`,td:`border:1px solid ${l.tableBorder};padding:8px 12px;color:${l.text};`,img:"max-width:100%;height:auto;"};function d(c){c.removeAttribute("class");const h=c.tagName.toLowerCase();if(h==="pre"){c.setAttribute("style",`background:${l.preBg};color:${l.preText};padding:14px;border-radius:6px;overflow-x:auto;margin:10px 0;font-size:0.88em;line-height:1.5;border:1px solid ${l.preBorder};`);const m=c.querySelector("code");m&&(m.removeAttribute("class"),m.setAttribute("style","background:transparent;padding:0;border-radius:0;color:inherit;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;font-size:inherit;"));return}h==="code"?c.setAttribute("style",`background:${l.codeBg};color:${l.codeText};padding:2px 6px;border-radius:4px;font-size:0.9em;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;`):o[h]&&c.setAttribute("style",o[h]),Array.from(c.children).forEach(d)}return s.removeAttribute("class"),Array.from(s.children).forEach(c=>d(c)),`<div style="background:${l.bg};color:${l.text};padding:20px 24px;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI','Noto Sans',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.7;max-width:800px;">${s.innerHTML}</div>`}function Ea({label:e,value:r,current:s,onClick:l}){return t.jsx("button",{onClick:()=>l(s===r?"":r),className:`px-2 py-1 rounded text-xs whitespace-nowrap shrink-0 transition-colors ${s===r?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:bg-surface-overlay"}`,children:e})}function nm(){return t.jsxs("svg",{className:"animate-spin h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}function Ys(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString()}function Vl(e){return e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function Uz(e){return e>=1024*1024*1024?`${(e/(1024*1024*1024)).toFixed(1)} GB`:e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${(e/1024).toFixed(1)} KB`:`${e} B`}function TN({authUser:e}){const[r,s]=v.useState("weekly"),[l,o]=v.useState(null),[d,c]=v.useState(!0),[h,m]=v.useState(""),[f,x]=v.useState(null),[g,p]=v.useState([]),[y,w]=v.useState("totalTokens"),[N,E]=v.useState(!0),[A,C]=v.useState("generate"),[k,S]=v.useState([]),[O,R]=v.useState(null),[G,I]=v.useState([]),[Q,$]=v.useState(""),[F,B]=v.useState(""),T=M=>{B(M),setTimeout(()=>B(""),3e3)},D=v.useCallback(async M=>{c(!0),m("");try{const{report:q}=await re.reports.generate({period:M,scope:"org",orgId:"default"});o(q)}catch(q){m(String(q)),o(null)}c(!1)},[]),z=v.useCallback(()=>{re.usage.summary().then(M=>x(M.usage)).catch(()=>{}),re.usage.agents().then(M=>p(M.agents)).catch(()=>{})},[]),_=v.useCallback(async()=>{try{const{reports:M}=await re.reports.list();S(M)}catch{}},[]),Y=v.useCallback(async M=>{R(M);try{const{feedback:q}=await re.reports.getFeedback(M.id);I(q)}catch{I([])}},[]);v.useEffect(()=>{D(r)},[r,D]),v.useEffect(()=>{z();const M=setInterval(z,3e4);return()=>clearInterval(M)},[z]),v.useEffect(()=>{A==="history"&&_()},[A,_]);const V=v.useMemo(()=>[...g].sort((M,q)=>{const K=M[y],ee=q[y];return N?ee-K:K-ee}),[g,y,N]),J=g.reduce((M,q)=>M+q.estimatedCost,0),U=g.reduce((M,q)=>M+q.tokensUsedToday,0),H=Math.max(1,...g.map(M=>M.totalTokens)),X=M=>{y===M?E(!N):(w(M),E(!0))},L={daily:"Today",weekly:"This Week",monthly:"This Month"};return t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsxs("div",{className:"max-w-5xl p-6 space-y-6",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx("h1",{className:"text-xl font-semibold text-fg-primary",children:"Reports"}),t.jsxs("div",{className:"flex gap-1 bg-surface-elevated rounded-lg p-0.5",children:[t.jsx("button",{onClick:()=>C("generate"),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${A==="generate"?"bg-surface-overlay text-fg-primary shadow-sm":"text-fg-tertiary hover:text-fg-secondary"}`,children:"Generate"}),t.jsxs("button",{onClick:()=>C("history"),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${A==="history"?"bg-surface-overlay text-fg-primary shadow-sm":"text-fg-tertiary hover:text-fg-secondary"}`,children:["History",k.length>0?` (${k.length})`:""]})]})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[F&&t.jsx("span",{className:"px-2.5 py-1 bg-green-500/10 text-green-600 text-xs rounded-lg",children:F}),A==="generate"&&t.jsx("div",{className:"flex gap-1 bg-surface-elevated rounded-lg p-0.5",children:["daily","weekly","monthly"].map(M=>t.jsx("button",{onClick:()=>s(M),className:`px-3 py-1.5 text-xs rounded-md transition-colors capitalize ${r===M?"bg-surface-overlay text-fg-primary shadow-sm":"text-fg-tertiary hover:text-fg-secondary"}`,children:M},M))})]})]}),A==="history"&&!O&&t.jsx("section",{className:"bg-surface-secondary border border-border-default rounded-xl overflow-hidden",children:k.length===0?t.jsx("div",{className:"p-8 text-center text-fg-tertiary text-sm",children:"No reports generated yet. Use the Generate tab to create one."}):t.jsx("div",{className:"divide-y divide-border-default/50",children:k.map(M=>t.jsxs("button",{onClick:()=>Y(M),className:"w-full text-left px-5 py-3 flex items-center gap-4 hover:bg-surface-elevated/30 transition-colors",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"text-sm font-medium text-fg-primary",children:[M.type," Report"]}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:[new Date(M.periodStart).toLocaleDateString()," — ",new Date(M.periodEnd).toLocaleDateString()]})]}),M.plan&&t.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium shrink-0 ${M.plan.status==="approved"?"bg-green-500/10 text-green-600":M.plan.status==="rejected"?"bg-red-500/10 text-red-500":"bg-amber-500/10 text-amber-600"}`,children:M.plan.status==="pending"?"Plan pending":`Plan ${M.plan.status}`}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date(M.generatedAt).toLocaleDateString()})]},M.id))})}),A==="history"&&O&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>{R(null),I([])},className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"← Back to list"}),t.jsxs("span",{className:"text-sm font-medium text-fg-primary",children:[O.type," Report"]}),t.jsxs("span",{className:"text-xs text-fg-tertiary",children:[new Date(O.periodStart).toLocaleDateString()," — ",new Date(O.periodEnd).toLocaleDateString()]})]}),O.metrics&&t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Task Metrics"}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[t.jsx(ps,{label:"Completed",value:O.metrics.tasksCompleted,color:"text-green-600"}),t.jsx(ps,{label:"In Progress",value:O.metrics.tasksInProgress,color:"text-brand-500"}),t.jsx(ps,{label:"Created",value:O.metrics.tasksCreated,color:"text-blue-600"}),t.jsx(ps,{label:"Blocked",value:O.metrics.tasksBlocked,color:"text-amber-600"}),t.jsx(ps,{label:"Failed",value:O.metrics.tasksFailed,color:"text-red-500"})]})]}),O.costSummary&&t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Cost Overview"}),t.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:O.costSummary.totalTokens.toLocaleString()}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Total Tokens"})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:Vl(O.costSummary.totalEstimatedCost)}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Estimated Cost"})]}),t.jsxs("div",{children:[t.jsxs("div",{className:`text-2xl font-bold ${O.costSummary.trend==="decreasing"?"text-green-600":O.costSummary.trend==="increasing"?"text-red-500":"text-fg-primary"}`,children:[O.costSummary.trend==="decreasing"?"↓":O.costSummary.trend==="increasing"?"↑":"→"," ",O.costSummary.trend]}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Trend"})]})]}),O.costSummary.byAgent&&O.costSummary.byAgent.length>0&&t.jsx("div",{className:"mt-4 pt-3 border-t border-border-default/50 space-y-1.5",children:O.costSummary.byAgent.map((M,q)=>t.jsxs("div",{className:"flex items-center justify-between text-xs",children:[t.jsx("span",{className:"text-fg-secondary",children:M.agentId}),t.jsxs("span",{className:"text-fg-tertiary tabular-nums",children:[Ys(M.tokens)," tokens · ",Vl(M.cost)]})]},q))})]}),O.taskSummary&&t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Task Summary"}),t.jsxs("div",{className:"space-y-4",children:[O.taskSummary.completed.length>0&&t.jsx(ql,{title:`Completed (${O.taskSummary.completed.length})`,color:"emerald",items:O.taskSummary.completed.map(M=>({id:M.id,label:M.title,sub:M.agent}))}),O.taskSummary.inProgress.length>0&&t.jsx(ql,{title:`In Progress (${O.taskSummary.inProgress.length})`,color:"indigo",items:O.taskSummary.inProgress.map(M=>({id:M.id,label:M.title,sub:M.agent}))}),O.taskSummary.blocked.length>0&&t.jsx(ql,{title:`Blocked (${O.taskSummary.blocked.length})`,color:"amber",items:O.taskSummary.blocked.map(M=>({id:M.id,label:M.title,sub:M.reason||M.agent}))}),O.taskSummary.completed.length===0&&O.taskSummary.inProgress.length===0&&O.taskSummary.blocked.length===0&&t.jsx("p",{className:"text-sm text-fg-tertiary",children:"No tasks in this period."})]})]}),O.highlights&&O.highlights.length>0&&t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-2",children:"Highlights"}),t.jsx("ul",{className:"list-disc list-inside space-y-1 text-sm text-fg-secondary",children:O.highlights.map((M,q)=>t.jsx("li",{children:M},q))})]}),O.blockers&&O.blockers.length>0&&t.jsxs("section",{className:"bg-surface-secondary border border-amber-500/20 rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-amber-600 mb-2",children:"Blockers"}),t.jsx("ul",{className:"list-disc list-inside space-y-1 text-sm text-fg-secondary",children:O.blockers.map((M,q)=>t.jsx("li",{children:M},q))})]}),O.plan&&t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("h3",{className:"text-xs font-semibold text-fg-secondary",children:["Upcoming Plan",t.jsx("span",{className:`ml-2 px-1.5 py-0.5 rounded text-[10px] font-medium ${O.plan.status==="approved"?"bg-green-500/10 text-green-600":O.plan.status==="rejected"?"bg-red-500/10 text-red-500":"bg-amber-500/10 text-amber-600"}`,children:O.plan.status})]}),O.plan.status==="pending"&&t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:async()=>{try{const{report:M}=await re.reports.approvePlan(O.id,{approvedBy:e?.id??"admin"});R(M),T("Plan approved"),_()}catch(M){T(`Error: ${M}`)}},className:"px-3 py-1.5 text-xs font-medium bg-green-600 text-white rounded-lg hover:bg-green-500 transition-colors",children:"Approve Plan"}),t.jsx("button",{onClick:async()=>{const M=prompt("Rejection reason:");if(M)try{const{report:q}=await re.reports.rejectPlan(O.id,{rejectedBy:e?.id??"admin",reason:M});R(q),T("Plan rejected"),_()}catch(q){T(`Error: ${q}`)}},className:"px-3 py-1.5 text-xs font-medium border border-border-default text-fg-secondary rounded-lg hover:bg-surface-overlay transition-colors",children:"Reject Plan"})]})]}),O.plan.items&&O.plan.items.length>0&&t.jsx("div",{className:"space-y-1.5",children:O.plan.items.map((M,q)=>t.jsxs("div",{className:"flex items-center gap-2 text-sm text-fg-secondary",children:[t.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${M.priority==="high"?"bg-red-500/10 text-red-500":M.priority==="medium"?"bg-amber-500/10 text-amber-600":"bg-gray-500/10 text-fg-tertiary"}`,children:M.priority}),t.jsx("span",{children:M.title}),M.assignee&&t.jsx("span",{className:"text-[10px] text-fg-tertiary ml-auto",children:M.assignee})]},q))})]}),!O.metrics&&!O.taskSummary&&!O.costSummary&&t.jsx("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-8 text-center",children:t.jsx("p",{className:"text-sm text-fg-tertiary",children:"This report does not contain detailed metrics data."})}),t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsxs("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:["Feedback (",G.length,")"]}),G.length>0&&t.jsx("div",{className:"space-y-2 mb-4",children:G.map(M=>t.jsxs("div",{className:"p-3 bg-surface-elevated/50 rounded-lg",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary mb-1",children:[t.jsx("span",{className:"font-medium text-fg-secondary",children:M.authorName}),t.jsx("span",{children:M.type}),t.jsx("span",{children:new Date(M.createdAt).toLocaleDateString()})]}),t.jsx("p",{className:"text-xs text-fg-secondary",children:M.content})]},M.id))}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{value:Q,onChange:M=>$(M.target.value),placeholder:"Add feedback or instructions…",className:"flex-1 px-3 py-2 text-xs bg-surface-elevated border border-border-default rounded-lg text-fg-primary placeholder:text-fg-tertiary",onKeyDown:M=>{M.key==="Enter"&&Q.trim()&&re.reports.addFeedback(O.id,{author:e?.id??"admin",type:"comment",content:Q.trim()}).then(({feedback:q})=>{I(K=>[...K,q]),$(""),T("Feedback added")}).catch(q=>T(`Error: ${q}`))}}),t.jsx("button",{onClick:()=>{Q.trim()&&re.reports.addFeedback(O.id,{author:e?.id??"admin",type:"comment",content:Q.trim()}).then(({feedback:M})=>{I(q=>[...q,M]),$(""),T("Feedback added")}).catch(M=>T(`Error: ${M}`))},disabled:!Q.trim(),className:"px-3 py-2 text-xs bg-brand-600 text-white rounded-lg hover:bg-brand-500 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:"Send"})]})]})]}),A==="generate"&&f&&t.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsx(fd,{label:"LLM Tokens (this month)",value:Ys(f.llmTokens),color:"text-brand-500"}),t.jsx(fd,{label:"Tool Calls (today)",value:Ys(f.toolCalls),color:"text-blue-600"}),t.jsx(fd,{label:"Messages (today)",value:Ys(f.messages),color:"text-green-600"}),t.jsx(fd,{label:"Storage",value:Uz(f.storageBytes),color:"text-amber-600"})]}),A==="generate"&&(d?t.jsx("div",{className:"flex items-center justify-center h-32 text-fg-tertiary text-sm",children:"Loading…"}):h?t.jsx("div",{className:"flex items-center justify-center h-32 text-red-500 text-sm",children:h}):l?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[L[r]," · ",new Date(l.periodStart).toLocaleDateString()," — ",new Date(l.periodEnd).toLocaleDateString()]}),l.metrics&&t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Task Metrics"}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[t.jsx(ps,{label:"Completed",value:l.metrics.tasksCompleted,color:"text-green-600"}),t.jsx(ps,{label:"In Progress",value:l.metrics.tasksInProgress,color:"text-brand-500"}),t.jsx(ps,{label:"Created",value:l.metrics.tasksCreated,color:"text-blue-600"}),t.jsx(ps,{label:"Blocked",value:l.metrics.tasksBlocked,color:"text-amber-600"}),t.jsx(ps,{label:"Failed",value:l.metrics.tasksFailed,color:"text-red-500"})]})]}),t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Cost Overview"}),t.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:Vl(J)}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Est. Cost (all time)"})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:Ys(U)}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Tokens Today"})]}),l.costSummary&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:l.costSummary.totalTokens.toLocaleString()}),t.jsxs("div",{className:"text-xs text-fg-tertiary",children:["Tokens (",L[r],")"]})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:Vl(l.costSummary.totalEstimatedCost)}),t.jsxs("div",{className:"text-xs text-fg-tertiary",children:["Cost (",L[r],")"]})]})]})]})]}),l.taskSummary&&t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Task Summary"}),t.jsxs("div",{className:"space-y-4",children:[l.taskSummary.completed.length>0&&t.jsx(ql,{title:`Completed (${l.taskSummary.completed.length})`,color:"emerald",items:l.taskSummary.completed.map(M=>({id:M.id,label:M.title,sub:M.agent}))}),l.taskSummary.inProgress.length>0&&t.jsx(ql,{title:`In Progress (${l.taskSummary.inProgress.length})`,color:"indigo",items:l.taskSummary.inProgress.map(M=>({id:M.id,label:M.title,sub:M.agent}))}),l.taskSummary.blocked.length>0&&t.jsx(ql,{title:`Blocked (${l.taskSummary.blocked.length})`,color:"amber",items:l.taskSummary.blocked.map(M=>({id:M.id,label:M.title,sub:M.reason||M.agent}))}),l.taskSummary.completed.length===0&&l.taskSummary.inProgress.length===0&&l.taskSummary.blocked.length===0&&t.jsx("p",{className:"text-sm text-fg-tertiary",children:"No tasks in this period."})]})]})]}):null),A==="generate"&&t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl overflow-hidden",children:[t.jsx("div",{className:"px-5 py-4 border-b border-border-default",children:t.jsx("h3",{className:"text-sm font-semibold text-fg-secondary",children:"Per-Agent Usage"})}),g.length===0?t.jsx("div",{className:"p-8 text-center text-fg-tertiary text-sm",children:"No agent usage data yet."}):t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-border-default text-xs text-fg-tertiary uppercase tracking-wider",children:[t.jsx("th",{className:"px-4 py-3 text-left font-medium",children:"Agent"}),t.jsx(io,{label:"Total Tokens",col:"totalTokens",current:y,desc:N,onSort:X}),t.jsx(io,{label:"Today",col:"tokensUsedToday",current:y,desc:N,onSort:X}),t.jsx(io,{label:"Requests",col:"requestCount",current:y,desc:N,onSort:X}),t.jsx(io,{label:"Tool Calls",col:"toolCalls",current:y,desc:N,onSort:X}),t.jsx(io,{label:"Est. Cost",col:"estimatedCost",current:y,desc:N,onSort:X,align:"right"})]})}),t.jsx("tbody",{children:V.map(M=>t.jsx(qz,{agent:M,maxTokens:H},M.agentId))}),t.jsx("tfoot",{children:t.jsxs("tr",{className:"border-t border-border-default bg-surface-elevated/30",children:[t.jsxs("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary",children:["Total (",g.length," agents)"]}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:Ys(g.reduce((M,q)=>M+q.totalTokens,0))}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:Ys(U)}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:g.reduce((M,q)=>M+q.requestCount,0)}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:g.reduce((M,q)=>M+q.toolCalls,0)}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-right text-fg-secondary tabular-nums",children:Vl(J)})]})})]})})]})]})})}function ps({label:e,value:r,color:s}){return t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:`text-2xl font-bold ${s}`,children:r}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:e})]})}function ql({title:e,color:r,items:s}){return t.jsxs("div",{children:[t.jsx("div",{className:`text-xs font-medium text-${r}-400 mb-1.5`,children:e}),t.jsx("div",{className:"space-y-1",children:s.map((l,o)=>t.jsxs("div",{className:`text-sm text-fg-secondary flex items-center gap-2 ${l.id?"cursor-pointer hover:text-fg-primary group":""}`,onClick:l.id?()=>jt.navigate("projects",{openTask:l.id}):void 0,children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full bg-${r}-500 shrink-0`}),t.jsx("span",{className:`truncate ${l.id?"group-hover:text-brand-500 transition-colors":""}`,children:l.label}),l.sub&&l.sub!=="unassigned"&&t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:l.sub})]},l.id??o))})]})}function fd({label:e,value:r,color:s}){return t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsx("div",{className:"text-sm text-fg-secondary mb-2",children:e}),t.jsx("div",{className:`text-2xl font-bold ${s}`,children:r})]})}function io({label:e,col:r,current:s,desc:l,onSort:o,align:d}){const c=s===r?l?"↓":"↑":"↕",h=s===r?"text-brand-500":"text-fg-muted";return t.jsxs("th",{className:`px-4 py-3 ${d==="right"?"text-right":"text-left"} font-medium cursor-pointer select-none hover:text-fg-secondary`,onClick:()=>o(r),children:[e,t.jsx("span",{className:`ml-1 ${h}`,children:c})]})}function qz({agent:e,maxTokens:r}){const s=r>0?Math.min(100,e.totalTokens/r*100):0,l=e.status==="working"?"bg-blue-500":e.status==="idle"?"bg-green-500":e.status==="paused"?"bg-amber-500":e.status==="error"?"bg-red-500":"bg-gray-600";return t.jsxs("tr",{className:"border-b border-border-default/50 hover:bg-surface-elevated/30 transition-colors cursor-pointer",onClick:()=>jt.navigate("team",{selectAgent:e.agentId}),children:[t.jsx("td",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex items-center gap-2.5",children:[t.jsx("div",{className:`w-2 h-2 rounded-full ${l}`}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary hover:text-brand-500 transition-colors",children:e.agentName}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:e.role})]})]})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"flex-1 bg-surface-elevated rounded-full h-1.5 overflow-hidden max-w-[120px]",children:t.jsx("div",{className:"h-full bg-brand-500 rounded-full",style:{width:`${s}%`}})}),t.jsx("span",{className:"text-sm text-fg-secondary tabular-nums",children:Ys(e.totalTokens)})]})}),t.jsx("td",{className:"px-4 py-3 text-sm text-fg-secondary tabular-nums",children:Ys(e.tokensUsedToday)}),t.jsx("td",{className:"px-4 py-3 text-sm text-fg-secondary tabular-nums",children:e.requestCount}),t.jsx("td",{className:"px-4 py-3 text-sm text-fg-secondary tabular-nums",children:e.toolCalls}),t.jsx("td",{className:"px-4 py-3 text-sm text-right text-fg-secondary tabular-nums",children:Vl(e.estimatedCost)})]})}const Zv={urgent:"bg-red-500",high:"bg-amber-500",normal:"bg-blue-500",low:"bg-gray-400"},rm={approval_request:"M9 12l2 2 4-4 M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z",task_completed:"M22 11.08V12a10 10 0 1 1-5.93-9.14 M22 4L12 14.01l-3-3",agent_alert:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z M12 9v4 M12 17h.01",bounty_posted:"M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z M19 10v2a7 7 0 0 1-14 0v-2",system:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"};function Qv(e){const r=Date.now()-new Date(e).getTime(),s=Math.floor(r/6e4);if(s<1)return"now";if(s<60)return`${s}m`;const l=Math.floor(s/60);return l<24?`${l}h`:`${Math.floor(l/24)}d`}function Kv({collapsed:e,userId:r}){const[s,l]=v.useState(!1),[o,d]=v.useState("approvals"),[c,h]=v.useState([]),[m,f]=v.useState([]),[x,g]=v.useState(null),p=v.useRef(null),y=v.useRef(null),[w,N]=v.useState({top:0,left:0}),E=v.useCallback(async()=>{try{const[B,T]=await Promise.all([re.notifications.list(r,!1),re.approvals.list()]);h(B.notifications),f(T.approvals)}catch{}},[r]);v.useEffect(()=>{E();const B=setInterval(E,15e3),T=()=>E();return window.addEventListener("markus:notifications-changed",T),()=>{clearInterval(B),window.removeEventListener("markus:notifications-changed",T)}},[E]),v.useLayoutEffect(()=>{if(!s||!p.current)return;const B=p.current.getBoundingClientRect();N({top:B.top,left:B.right+8})},[s]),v.useEffect(()=>{if(!s)return;const B=T=>{p.current?.contains(T.target)||y.current?.contains(T.target)||l(!1)};return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[s]);const A=new Set(m.map(B=>B.id)),C=c.filter(B=>!(B.type==="approval_request"&&B.metadata?.approvalId&&A.has(B.metadata.approvalId))),k=C.filter(B=>!B.read).length,S=m.filter(B=>B.status==="pending").length,O=k+S,R=async B=>{await re.notifications.markRead(B),h(T=>T.map(D=>D.id===B?{...D,read:!0}:D))},G=B=>{const T=B.metadata??{};switch(B.type){case"approval_request":{const D=T.approvalId,_=(D?m.find(Y=>Y.id===D):void 0)?.details?.taskId??T.taskId;_?jt.navigate("projects",{openTask:_}):jt.navigate("projects");break}case"task_completed":T.taskId?jt.navigate("projects",{openTask:T.taskId}):jt.navigate("projects");break;case"agent_alert":T.agentId?jt.navigate("team",{selectAgent:T.agentId}):jt.navigate("team");break;case"bounty_posted":jt.navigate("governance");break;default:T.taskId?jt.navigate("projects",{openTask:T.taskId}):T.projectId?jt.navigate("projects",{projectId:T.projectId}):T.agentId&&jt.navigate("team",{selectAgent:T.agentId});break}},I=async B=>{B.read||R(B.id),G(B),l(!1)},Q=async(B,T)=>{g(B);try{const{approval:D}=await re.approvals.respond(B,T,r);f(_=>_.map(Y=>Y.id===B?D:Y));const z=c.find(_=>_.type==="approval_request"&&_.metadata?.approvalId===B);z&&!z.read&&(re.notifications.markRead(z.id),h(_=>_.map(Y=>Y.id===z.id?{...Y,read:!0}:Y))),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}catch{}g(null)},$=async()=>{const B=C.filter(T=>!T.read);await Promise.all(B.map(T=>re.notifications.markRead(T.id))),h(T=>T.map(D=>({...D,read:!0})))},F=B=>{const T=B.details?.taskId;T?jt.navigate("projects",{openTask:T}):jt.navigate("projects"),l(!1)};return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:p,onClick:()=>{l(!s),s||E()},className:`relative flex items-center justify-center rounded-md transition-colors ${e?"w-8 h-8":"w-7 h-7"} ${s?"bg-surface-overlay text-fg-primary":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay"}`,title:"Notifications",children:[t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),t.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),O>0&&t.jsx("span",{className:"absolute -top-0.5 -right-0.5 min-w-[16px] h-4 px-1 rounded-full bg-red-500 text-white text-[10px] font-bold flex items-center justify-center leading-none",children:O>99?"99+":O})]}),s&&ix.createPortal(t.jsxs("div",{ref:y,className:"fixed w-80 max-h-[28rem] bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:w.top,left:w.left},children:[t.jsxs("div",{className:"flex border-b border-border-default shrink-0",children:[t.jsxs("button",{onClick:()=>d("approvals"),className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${o==="approvals"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:["Approvals",S>0?` (${S})`:""]}),t.jsxs("button",{onClick:()=>d("notifications"),className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${o==="notifications"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:["Notifications",k>0?` (${k})`:""]})]}),o==="notifications"&&k>0&&t.jsx("div",{className:"flex justify-end px-3 py-1.5 border-b border-border-default/50 shrink-0",children:t.jsx("button",{onClick:$,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:"Mark all read"})}),t.jsxs("div",{className:"flex-1 overflow-y-auto",children:[o==="approvals"&&(m.length===0?t.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:"No approval requests"}):t.jsxs("div",{className:"divide-y divide-border-default/50",children:[m.filter(B=>B.status==="pending").map(B=>t.jsxs("div",{className:"px-3 py-3 space-y-2",children:[t.jsxs("button",{onClick:()=>F(B),className:"w-full text-left flex items-start gap-2 hover:bg-surface-overlay rounded transition-colors",children:[t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-amber-500 mt-0.5 shrink-0",children:t.jsx("path",{d:rm.approval_request})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs text-fg-primary font-medium",children:B.title}),t.jsxs("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:[B.agentName," · ",Qv(B.requestedAt)]}),t.jsx("p",{className:"text-[11px] text-fg-secondary mt-1 line-clamp-3",children:B.description})]})]}),t.jsxs("div",{className:"flex gap-2 pl-5",children:[t.jsx("button",{disabled:x===B.id,onClick:()=>Q(B.id,!0),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors",children:"Approve"}),t.jsx("button",{disabled:x===B.id,onClick:()=>Q(B.id,!1),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay disabled:opacity-50 transition-colors",children:"Reject"})]})]},B.id)),m.filter(B=>B.status!=="pending").slice(0,20).map(B=>t.jsx("button",{onClick:()=>F(B),className:"w-full text-left px-3 py-2.5 opacity-50 hover:opacity-70 transition-colors",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${B.status==="approved"?"bg-green-500":"bg-red-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1",children:B.title}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:B.status})]})},B.id))]})),o==="notifications"&&(C.length===0?t.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:"No notifications"}):t.jsx("div",{className:"divide-y divide-border-default/50",children:C.slice(0,50).map(B=>t.jsxs("button",{onClick:()=>I(B),className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors ${B.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[t.jsx("div",{className:"shrink-0 mt-0.5",children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-fg-tertiary",children:t.jsx("path",{d:rm[B.type]??rm.system})})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[!B.read&&t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Zv[B.priority]??Zv.normal}`}),t.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:B.title})]}),t.jsx("p",{className:"text-[11px] text-fg-tertiary line-clamp-2 mt-0.5",children:B.body}),t.jsx("span",{className:"text-[10px] text-fg-muted mt-0.5",children:Qv(B.createdAt)})]}),t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-fg-muted shrink-0 mt-1 opacity-0 group-hover:opacity-100",children:t.jsx("polyline",{points:"9 18 15 12 9 6"})})]},B.id))}))]})]}),document.body)]})}function oo({d:e,size:r=18}){return t.jsx("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:t.jsx("path",{d:e})})}const co={dashboard:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z M9 22V12h6v10",projects:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z",chat:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",reports:"M18 20V10 M12 20V4 M6 20v-6",deliverables:"M4 19.5A2.5 2.5 0 0 1 6.5 17H20 M4 19.5A2.5 2.5 0 0 0 6.5 22H20V2H6.5A2.5 2.5 0 0 0 4 4.5v15z",usage:"M21.21 15.89A10 10 0 1 1 8 2.83 M22 12A10 10 0 0 0 12 2v10z",builder:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",agents:"M8 3H5a2 2 0 0 0-2 2v3 M21 8V5a2 2 0 0 0-2-2h-3 M3 16v3a2 2 0 0 0 2 2h3 M16 21h3a2 2 0 0 0 2-2v-3 M9 9h6v6H9z",teams:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2 M9 3a4 4 0 1 0 0 8 4 4 0 0 0 0-8z M23 21v-2a4 4 0 0 0-3-3.87 M16 3.13a4 4 0 0 1 0 7.75",skills:"M12 2L2 7l10 5 10-5-10-5z M2 17l10 5 10-5 M2 12l10 5 10-5",governance:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",settings:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"},Fz={active:"bg-green-500",paused:"bg-amber-500",completed:"bg-gray-500",archived:"bg-gray-600"},Vz=[{id:"dashboard",label:"Overview",section:"workspace"},{id:"chat",label:"Chat",section:"workspace"},{id:"deliverables",label:"Deliverables",section:"workspace"},{id:"builder",label:"Builder",section:"build"},{id:"agents",label:"Agents",section:"build"},{id:"teams",label:"Teams",section:"build"},{id:"skills",label:"Skills",section:"build"},{id:"governance",label:"Governance",section:"system"},{id:"reports",label:"Reports",section:"system"},{id:"settings",label:"Settings",section:"system"}],Yz=[{key:"workspace",label:"WORKSPACE"},{key:"build",label:"BUILD"},{key:"system",label:"SYSTEM"}],Jv=5;function Gz({currentPage:e,onNavigate:r,authUser:s,onLogout:l,collapsed:o,onToggleCollapse:d}){const[c,h]=v.useState([]),[m,f]=v.useState(!1),[x,g]=v.useState(null),[p,y]=v.useState(!1),w=v.useCallback(()=>{re.projects.list().then(C=>h(C.projects)).catch(()=>{})},[]);v.useEffect(()=>{w();const C=setInterval(w,3e4);return()=>clearInterval(C)},[w]),v.useEffect(()=>{if(e!=="projects"){g(null);return}const k=window.location.hash.slice(1).split("/");k[0]==="projects"&&k[1]&&g(k[1])},[e]);const N=async()=>{try{await re.auth.logout()}catch{}l?.()},E=m?c:c.slice(0,Jv),A=c.length>Jv;return t.jsxs("aside",{className:"h-dvh bg-surface-secondary flex flex-col shrink-0 overflow-hidden border-r border-border-subtle",children:[t.jsx("div",{className:`flex items-center ${o?"px-2 py-3.5 justify-center":"px-4 h-14 justify-between"}`,children:o?t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx("button",{onClick:d,title:"Expand sidebar",className:"group",children:t.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-8 h-8 rounded-lg group-hover:ring-2 group-hover:ring-brand-500/40 transition-all"})}),t.jsx(Kv,{collapsed:!0,userId:s?.id})]}):t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:d,className:"flex items-center gap-2.5 min-w-0 group",title:"Collapse sidebar",children:[t.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-8 h-8 rounded-lg shadow-md shadow-black/30 shrink-0 group-hover:ring-2 group-hover:ring-brand-500/40 transition-all"}),t.jsx("span",{className:"text-[15px] font-bold tracking-tight text-fg-primary whitespace-nowrap",children:"Markus"})]}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.jsx(Kv,{userId:s?.id}),t.jsx("button",{onClick:d,className:"text-fg-tertiary hover:text-fg-secondary transition-colors p-1 rounded-md hover:bg-surface-overlay",title:"Collapse sidebar",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"11 17 6 12 11 7"}),t.jsx("polyline",{points:"18 17 13 12 18 7"})]})})]})]})}),t.jsx("nav",{className:`${o?"p-1.5":"p-3"} flex-1 overflow-y-auto`,children:Yz.map((C,k)=>t.jsx("div",{children:t.jsxs("div",{className:"mb-3",children:[!o&&t.jsx("div",{className:"px-3 py-1.5 text-[11px] font-semibold text-fg-tertiary uppercase tracking-widest",children:C.label}),o&&k>0&&t.jsx("div",{className:"my-2 mx-1"}),Vz.filter(S=>S.section===C.key&&!(C.key==="workspace"&&S.id==="deliverables")).map(S=>{const O=e===S.id;return t.jsxs("button",{onClick:()=>r(S.id),title:o?S.label:void 0,className:`w-full flex items-center ${o?"justify-center px-2 py-2":"gap-3 px-3 py-2"} rounded-lg text-sm mb-0.5 transition-all ${O?"bg-brand-600 text-white shadow-sm shadow-brand-900/30":"text-fg-primary hover:bg-surface-overlay"}`,children:[t.jsx(oo,{d:co[S.id]??""}),!o&&S.label]},S.id)}),C.key==="workspace"&&o&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{g(null),r("projects")},title:"Projects",className:`w-full flex items-center justify-center px-2 py-2 rounded-lg text-sm mb-0.5 transition-all ${e==="projects"&&!x?"bg-brand-600 text-white shadow-sm shadow-brand-900/30":e==="projects"?"bg-brand-600/15 text-fg-primary":"text-fg-primary hover:bg-surface-overlay"}`,children:t.jsx(oo,{d:co.projects})}),t.jsx("button",{onClick:()=>r("deliverables"),title:"Deliverables",className:`w-full flex items-center justify-center px-2 py-2 rounded-lg text-sm mb-0.5 transition-colors ${e==="deliverables"?"bg-brand-600 text-white":"text-fg-primary hover:bg-surface-elevated"}`,children:t.jsx(oo,{d:co.deliverables})})]}),C.key==="workspace"&&!o&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center mb-0.5",children:[t.jsxs("button",{onClick:()=>{g(null),window.location.hash="projects",r("projects")},className:`flex-1 flex items-center gap-3 px-3 py-2 rounded-lg text-sm transition-colors ${e==="projects"&&!x?"bg-brand-600 text-white":"text-fg-primary hover:bg-surface-elevated"}`,children:[t.jsx(oo,{d:co.projects}),"Projects"]}),t.jsx("button",{onClick:()=>y(!0),className:"text-fg-tertiary hover:text-fg-secondary transition-colors p-1.5 rounded hover:bg-surface-elevated shrink-0",title:"New Project",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),t.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]}),c.length===0&&t.jsxs("button",{onClick:()=>y(!0),className:"w-full flex items-center gap-2 pl-9 pr-3 py-1.5 text-xs text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated/50 rounded-lg transition-colors",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),t.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Create your first project"]}),E.map(S=>{const O=e==="projects"&&x===S.id;return t.jsxs("button",{onClick:()=>{g(S.id),e!=="projects"&&r("projects"),window.location.hash="projects/"+S.id},className:`w-full flex items-center gap-2.5 pl-9 pr-3 py-1.5 rounded-lg text-sm mb-0.5 transition-colors ${O?"bg-brand-600 text-white":"text-fg-secondary hover:bg-surface-elevated"}`,children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${Fz[S.status]??"bg-gray-600"}`}),t.jsx("span",{className:"truncate text-xs",children:S.name})]},S.id)}),A&&!m&&t.jsxs("button",{onClick:()=>f(!0),className:"w-full pl-9 pr-3 py-1 text-[11px] text-fg-tertiary hover:text-fg-secondary transition-colors text-left",children:["Show all ",c.length," projects..."]}),t.jsxs("button",{onClick:()=>r("deliverables"),className:`w-full flex items-center gap-3 px-3 py-2 rounded-lg text-sm mb-0.5 transition-colors ${e==="deliverables"?"bg-brand-600 text-white":"text-fg-primary hover:bg-surface-elevated"}`,children:[t.jsx(oo,{d:co.deliverables}),"Deliverables"]})]})]})},C.key))}),t.jsxs("div",{className:`${o?"p-2 flex flex-col items-center gap-2":"px-4 py-3 space-y-2"}`,children:[s&&(o?t.jsx("button",{onClick:N,title:`${s.name??s.email} — Sign out`,className:"w-7 h-7 rounded-full bg-brand-600 flex items-center justify-center text-white text-xs font-bold shrink-0 hover:ring-2 hover:ring-brand-500/50 transition-all",children:s.name?.[0]?.toUpperCase()??"A"}):t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-7 h-7 rounded-full bg-brand-600 flex items-center justify-center text-white text-xs font-bold shrink-0",children:s.name?.[0]?.toUpperCase()??"A"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs text-fg-secondary truncate",children:s.name??s.email}),t.jsx("div",{className:"text-[11px] text-fg-tertiary truncate",children:s.email??s.role?.[0]?.toUpperCase()+s.role?.slice(1)})]}),t.jsx("button",{onClick:N,title:"Sign out",className:"text-fg-tertiary hover:text-fg-secondary transition-colors text-sm",children:"⇥"})]})),!o&&t.jsxs("div",{className:"text-[10px] text-fg-muted",children:["v","0.4.4"]})]}),p&&t.jsx(wN,{orgId:s?.orgId,onCreated:()=>{y(!1),w()},onClose:()=>y(!1)})]})}const Xz={dashboard:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z M9 22V12h6v10",chat:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",projects:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z",deliverables:"M4 19.5A2.5 2.5 0 0 1 6.5 17H20 M4 19.5A2.5 2.5 0 0 0 6.5 22H20V2H6.5A2.5 2.5 0 0 0 4 4.5v15z",builder:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",settings:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"},Zz=[{id:"dashboard",label:"Home",iconKey:"dashboard",group:["dashboard"]},{id:"chat",label:"Chat",iconKey:"chat",group:["chat"]},{id:"projects",label:"Projects",iconKey:"projects",group:["projects"]},{id:"deliverables",label:"Deliverables",iconKey:"deliverables",group:["deliverables"]},{id:"builder",label:"Builder",iconKey:"builder",group:["builder","agents","teams","skills"]},{id:"settings",label:"Settings",iconKey:"settings",group:["settings","governance","reports"]}];function Qz({currentPage:e,onNavigate:r}){return t.jsx("nav",{className:"fixed bottom-0 left-0 right-0 z-50 bg-surface-secondary border-t border-border-default flex items-stretch h-14 safe-area-bottom",children:Zz.map(s=>{const l=s.group.includes(e);return t.jsxs("button",{onClick:()=>r(s.id),className:`flex-1 flex flex-col items-center justify-center gap-0.5 transition-colors ${l?"text-brand-500":"text-fg-tertiary active:text-fg-secondary"}`,children:[t.jsx("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:l?2:1.75,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:t.jsx("path",{d:Xz[s.iconKey]})}),t.jsx("span",{className:`text-[10px] leading-tight ${l?"font-semibold":""}`,children:s.label})]},s.id)})})}const Kz=50,Jz=30;function AN(e,r,s){const l=v.useRef(0),o=v.useRef(0),d=v.useCallback(h=>{l.current=h.touches[0].clientX,o.current=h.touches[0].clientY},[]),c=v.useCallback(h=>{const m=h.changedTouches[0].clientX-l.current,f=h.changedTouches[0].clientY-o.current,x=Math.abs(m),g=Math.abs(f);if(x<Kz||Math.atan2(g,x)*(180/Math.PI)>Jz)return;const y=e.findIndex(w=>w.id===r);m<0&&y<e.length-1?s(e[y+1].id):m>0&&y>0&&s(e[y-1].id)},[e,r,s]);return{onTouchStart:d,onTouchEnd:c}}const Wv=[{id:"builder",label:"Builder"},{id:"agents",label:"Agents"},{id:"teams",label:"Teams"},{id:"skills",label:"Skills"}];function Wz({authUser:e}){const[r,s]=v.useState("builder"),l=AN(Wv,r,s);return t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:l.onTouchStart,onTouchEnd:l.onTouchEnd,children:[t.jsx("div",{className:"flex border-b border-border-default bg-surface-secondary shrink-0 overflow-x-auto scrollbar-hide",children:Wv.map(o=>t.jsx("button",{onClick:()=>s(o.id),className:`flex-1 min-w-0 px-3 py-2.5 text-xs font-medium text-center whitespace-nowrap transition-colors border-b-2 ${r===o.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:o.label},o.id))}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[r==="builder"&&t.jsx(Oj,{}),r==="agents"&&t.jsx(Aj,{authUser:e}),r==="teams"&&t.jsx(Dj,{}),r==="skills"&&t.jsx(Cj,{})]})]})}const e1=[{id:"settings",label:"Settings"},{id:"governance",label:"Governance"},{id:"reports",label:"Reports"}];function eI({theme:e,onThemeChange:r}){const[s,l]=v.useState("settings"),o=AN(e1,s,l);return t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:o.onTouchStart,onTouchEnd:o.onTouchEnd,children:[t.jsx("div",{className:"flex border-b border-border-default bg-surface-secondary shrink-0 overflow-x-auto scrollbar-hide",children:e1.map(d=>t.jsx("button",{onClick:()=>l(d.id),className:`flex-1 min-w-0 px-3 py-2.5 text-xs font-medium text-center whitespace-nowrap transition-colors border-b-2 ${s===d.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:d.label},d.id))}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s==="settings"&&t.jsx(kj,{theme:e,onThemeChange:r}),s==="governance"&&t.jsx(Rj,{}),s==="reports"&&t.jsx(TN,{})]})]})}const t1=2;function tI({onComplete:e,theme:r,onThemeChange:s}){const[l,o]=v.useState(0),[d,c]=v.useState(null),[h,m]=v.useState(!1),[f,x]=v.useState({}),[g,p]=v.useState(!1),[y,w]=v.useState(null),[N,E]=v.useState(!1),[A,C]=v.useState(!1),[k,S]=v.useState(null),O=v.useRef(!1),R=()=>({"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("markus_token")??""}`});v.useEffect(()=>{fetch("/api/settings/llm").then(z=>z.ok?z.json():null).then(z=>{z?.providers&&Object.values(z.providers).some(_=>_.configured)&&C(!0)}).catch(()=>{})},[]),v.useEffect(()=>{l===t1&&!O.current&&!A&&(O.current=!0,G())},[l,A]);const G=async()=>{m(!0);try{const z=await fetch("/api/settings/env-models",{headers:R()});if(z.ok){const _=await z.json();if(c(_),_.detected.length>0){const Y={};for(const V of _.detected)Y[V.provider]=!0;x(Y)}}}catch{}finally{m(!1)}},I=async()=>{if(!d)return;const z=d.detected.filter(_=>f[_.provider]);if(z.length!==0){p(!0),S(null);try{const _=await fetch("/api/settings/env-models",{method:"POST",headers:R(),body:JSON.stringify({providers:z.map(Y=>({provider:Y.provider,model:Y.model,baseUrl:Y.baseUrl,enabled:!0}))})});if(_.ok){const Y=await _.json();S({type:"ok",text:Y.message}),C(!0)}else S({type:"err",text:"Failed to apply"})}catch{S({type:"err",text:"Network error"})}finally{p(!1)}}},Q=async()=>{E(!0);try{const _=await(await fetch("/api/settings/import/openclaw",{method:"POST",headers:R(),body:JSON.stringify({preview:!0})})).json();"error"in _||w(_)}catch{}finally{E(!1)}},$=async()=>{E(!0),S(null);try{const _=await(await fetch("/api/settings/import/openclaw",{method:"POST",headers:R(),body:JSON.stringify({preview:!1})})).json();"error"in _?S({type:"err",text:_.error}):(S({type:"ok",text:`Imported ${_.appliedModels} model configs`}),C(!0))}catch{S({type:"err",text:"Import failed"})}finally{E(!1)}},F=[{value:"system",label:"System",icon:"💻",desc:"Follow your OS setting"},{value:"light",label:"Light",icon:"☀️",desc:"Always light background"},{value:"dark",label:"Dark",icon:"🌙",desc:"Always dark background"}],B=[{title:"Welcome to Markus",subtitle:"Your AI workforce, ready in minutes",content:t.jsxs("div",{className:"space-y-4 text-fg-secondary text-sm leading-relaxed",children:[t.jsxs("p",{children:["Markus runs ",t.jsx("strong",{className:"text-fg-primary",children:"complete AI teams"})," — developers, researchers, writers, analysts that work autonomously, collaborate with each other, and deliver results around the clock."]}),t.jsx("div",{className:"grid grid-cols-2 gap-3 mt-6",children:[["24/7 Operation","Agents work while you sleep via heartbeat"],["Team Collaboration","Agents delegate, review, and coordinate"],["Persistent Memory","Five memory layers survive restarts"],["Any LLM Provider","Anthropic, OpenAI, Google, Ollama & more"]].map(([z,_])=>t.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg p-3",children:[t.jsx("div",{className:"font-medium text-fg-primary text-xs",children:z}),t.jsx("div",{className:"text-fg-secondary text-xs mt-1",children:_})]},z))})]})},{title:"Choose Your Theme",subtitle:"You can change this anytime in Settings",content:t.jsx("div",{className:"grid grid-cols-3 gap-3",children:F.map(z=>t.jsxs("button",{onClick:()=>s(z.value),className:`flex flex-col items-center gap-2 rounded-xl border-2 p-5 transition-all ${r===z.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[t.jsx("span",{className:"text-2xl",children:z.icon}),t.jsx("span",{className:"text-sm font-medium text-fg-primary",children:z.label}),t.jsx("span",{className:"text-[11px] text-fg-tertiary leading-tight text-center",children:z.desc})]},z.value))})},{title:"Configure LLM",subtitle:"Agents need an LLM to think and act",content:A?t.jsxs("div",{className:"flex items-center gap-3 bg-green-500/10 border border-green-500/30 rounded-xl p-4",children:[t.jsx("span",{className:"text-green-600 text-lg",children:"✓"}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-green-600",children:"LLM provider configured"}),t.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:"You can manage providers anytime in Settings."})]})]}):t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"text-xs text-fg-secondary uppercase tracking-wider",children:"From Environment Variables"}),h&&t.jsx("div",{className:"text-xs text-fg-tertiary animate-pulse",children:"Detecting API keys..."}),d&&d.detected.length>0&&t.jsxs("div",{className:"space-y-2",children:[d.detected.map(z=>t.jsxs("label",{className:"flex items-center gap-3 bg-surface-elevated/40 rounded-lg px-3 py-2.5 cursor-pointer hover:bg-surface-elevated/60 transition-colors",children:[t.jsx("input",{type:"checkbox",checked:f[z.provider]??!1,onChange:_=>x({...f,[z.provider]:_.target.checked}),className:"w-4 h-4 rounded bg-surface-overlay border-gray-600 text-brand-500 focus:ring-brand-500"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-fg-primary",children:z.displayName}),t.jsx("span",{className:"text-xs text-fg-tertiary ml-2",children:z.model})]}),t.jsx("code",{className:"text-[10px] text-fg-tertiary",children:z.apiKeyPreview})]},z.provider)),t.jsx("button",{onClick:()=>{I()},disabled:g||Object.values(f).filter(Boolean).length===0,className:"w-full px-4 py-2 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-lg transition-colors",children:g?"Applying...":`Apply ${Object.values(f).filter(Boolean).length} Provider(s)`})]}),d&&d.detected.length===0&&!h&&t.jsxs("div",{className:"text-xs text-fg-tertiary bg-surface-elevated/30 rounded-lg p-3",children:["No API keys found. Set ",t.jsx("code",{className:"text-fg-secondary",children:"ANTHROPIC_API_KEY"}),", ",t.jsx("code",{className:"text-fg-secondary",children:"OPENAI_API_KEY"}),", etc. in your ",t.jsx("code",{className:"text-fg-secondary",children:".env"})," file and restart."]})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"flex-1 h-px bg-border-default"}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:"or"}),t.jsx("div",{className:"flex-1 h-px bg-border-default"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"text-xs text-fg-secondary uppercase tracking-wider",children:"From OpenClaw"}),y?y.found?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"text-xs text-green-600",children:["Found: ",t.jsx("code",{className:"text-fg-secondary",children:y.summary.configPath}),y.summary.models&&t.jsxs("span",{className:"text-fg-tertiary ml-1",children:["(",y.summary.models.providerCount," providers)"]})]}),t.jsx("button",{onClick:()=>{$()},disabled:N,className:"w-full px-4 py-2 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-lg transition-colors",children:N?"Importing...":"Import Model Configs"})]}):t.jsx("div",{className:"text-xs text-fg-tertiary bg-surface-elevated/30 rounded-lg p-3",children:"No OpenClaw config found."}):t.jsx("button",{onClick:()=>{Q()},disabled:N,className:"px-4 py-2 border border-border-default hover:bg-surface-elevated disabled:opacity-40 text-fg-secondary text-sm rounded-lg transition-colors w-full",children:N?"Detecting...":"Detect OpenClaw Config"})]}),k&&t.jsx("div",{className:`text-xs px-3 py-2 rounded-lg ${k.type==="ok"?"bg-green-500/10 text-green-600 border border-green-500/30":"bg-red-500/10 text-red-500 border border-red-500/30"}`,children:k.text})]})},{title:"You're All Set",subtitle:"Start building your AI workforce",content:t.jsx("div",{className:"space-y-2 text-fg-secondary text-sm",children:[["Chat","Talk to agents or use Smart Route to auto-delegate tasks"],["Projects","Create projects with requirements, tasks, and deliverables"],["Builder","Hire new agents from templates or build custom roles"],["Settings","Manage LLM providers, integrations, and governance"]].map(([z,_])=>t.jsxs("div",{className:"flex gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[t.jsx("div",{className:"text-brand-500 mt-0.5 shrink-0",children:"→"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-fg-primary text-xs",children:z}),t.jsx("div",{className:"text-fg-secondary text-xs",children:_})]})]},z))})}],T=()=>{l<B.length-1?o(l+1):e()},D=B[l];return t.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4",children:t.jsx("div",{className:"w-full max-w-lg",children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-2xl p-8",children:[t.jsx("div",{className:"flex gap-1.5 mb-8",children:B.map((z,_)=>t.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${_<=l?"bg-brand-500":"bg-surface-elevated"}`},_))}),t.jsx("h2",{className:"text-2xl font-bold text-fg-primary",children:D.title}),t.jsx("p",{className:"text-sm text-fg-secondary mt-1 mb-6",children:D.subtitle}),D.content,t.jsxs("div",{className:"flex justify-between mt-8",children:[l>0?t.jsx("button",{onClick:()=>o(l-1),className:"px-4 py-2 text-sm text-fg-secondary hover:text-fg-primary transition-colors",children:"Back"}):t.jsx("button",{onClick:e,className:"px-4 py-2 text-sm text-fg-tertiary hover:text-fg-secondary transition-colors",children:"Skip"}),t.jsxs("div",{className:"flex items-center gap-3",children:[l===t1&&!A&&t.jsx("button",{onClick:T,className:"px-4 py-2 text-sm text-fg-tertiary hover:text-fg-secondary transition-colors",children:"Skip for now"}),t.jsx("button",{onClick:T,className:"px-6 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-sm rounded-xl transition-colors",children:l===B.length-1?"Get Started":"Next"})]})]})]})})})}const nI="markus123";function rI({onLogin:e}){const[r,s]=v.useState("admin@markus.local"),[l,o]=v.useState(""),[d,c]=v.useState(""),[h,m]=v.useState(!1),f=async x=>{if(x.preventDefault(),!(!r.trim()||!l)){c(""),m(!0);try{const{user:g}=await re.auth.login(r.trim(),l);e(g,l===nI)}catch{c("Invalid email or password")}finally{m(!1)}}};return t.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[t.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),t.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[t.jsxs("div",{className:"text-center mb-8",children:[t.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),t.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),t.jsx("div",{className:"text-sm text-fg-tertiary",children:"AI Digital Employee Platform"})]}),t.jsxs("form",{onSubmit:f,className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-5 shadow-2xl shadow-black/30",children:[t.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:"Sign in"}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:"Email"}),t.jsx("input",{type:"email",value:r,onChange:x=>s(x.target.value),autoComplete:"email",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:"Password"}),t.jsx("input",{type:"password",value:l,onChange:x=>o(x.target.value),autoComplete:"current-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),d&&t.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:d}),t.jsx("button",{type:"submit",disabled:h||!r||!l,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-medium rounded-xl transition-all shadow-md shadow-brand-900/40 hover:shadow-lg hover:shadow-brand-900/50",children:h?"Signing in…":"Sign in"}),t.jsx("p",{className:"text-center text-xs text-fg-tertiary",children:"Default: admin@markus.local / markus123"})]})]})]})}function sI({onComplete:e,isFirstTime:r}){const[s,l]=v.useState(""),[o,d]=v.useState(""),[c,h]=v.useState(""),[m,f]=v.useState(""),[x,g]=v.useState(!1),p=async y=>{if(y.preventDefault(),f(""),o.length<6){f("Password must be at least 6 characters");return}if(o!==c){f("Passwords do not match");return}g(!0);try{await re.auth.changePassword(s,o),e()}catch{f("Failed to change password. Check your current password.")}finally{g(!1)}};return t.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[t.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),t.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[t.jsxs("div",{className:"text-center mb-8",children:[t.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),t.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),t.jsx("div",{className:"text-sm text-fg-tertiary",children:"AI Digital Employee Platform"})]}),t.jsxs("form",{onSubmit:p,className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-5 shadow-2xl shadow-black/30",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:r?"Set Your Password":"Change Password"}),r&&t.jsx("p",{className:"text-xs text-amber-600/80 text-center mt-2",children:"You're using the default password. Please set a new one before continuing."})]}),!r&&t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:"Current Password"}),t.jsx("input",{type:"password",value:s,onChange:y=>l(y.target.value),autoComplete:"current-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:"New Password"}),t.jsx("input",{type:"password",value:o,onChange:y=>d(y.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0,minLength:6})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:"Confirm New Password"}),t.jsx("input",{type:"password",value:c,onChange:y=>h(y.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),m&&t.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:m}),t.jsx("button",{type:"submit",disabled:x||!o||!c,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-medium rounded-xl transition-colors",children:x?"Saving…":r?"Set Password & Continue":"Change Password"})]})]})]})}const _N="markus-theme";function n1(e){const r=document.documentElement;r.classList.remove("light","dark"),e==="light"?r.classList.add("light"):e==="dark"&&r.classList.add("dark")}function aI(){try{const e=localStorage.getItem(_N);if(e==="light"||e==="dark"||e==="system")return e}catch{}return"system"}function lI(){const[e,r]=v.useState(aI),s=v.useCallback(l=>{r(l);try{localStorage.setItem(_N,l)}catch{}n1(l)},[]);return v.useEffect(()=>{n1(e)},[e]),{mode:e,setMode:s}}const iI=["dashboard","tasks","chat","team","usage","skills","agents","teams","builder","prompts","settings","governance","projects","deliverables","reports"];function hd(){const e=window.location.hash.slice(1).split("/")[0];return e==="team"?"chat":e==="tasks"?"projects":e==="usage"?"reports":e==="prompts"?"builder":e==="templates"?"agents":e==="knowledge"?"deliverables":iI.includes(e)?e:"dashboard"}const sm={};function oI(){const[e,r]=v.useState(hd),[s,l]=v.useState(()=>!localStorage.getItem("markus_onboarded")),[o,d]=v.useState(!0),c=ks(),h=lI(),m=Wd({side:"left",defaultWidth:240,minWidth:180,maxWidth:400,collapsedWidth:48,storageKey:"markus_sidebar"}),[f,x]=v.useState(()=>new Set([hd()])),[g,p]=v.useState("loading"),[y,w]=v.useState(!1),[N,E]=v.useState(null),[A,C]=v.useState(!1),k=v.useCallback(G=>{let I=G==="tasks"?"projects":G==="team"?"chat":G==="usage"?"reports":G==="prompts"?"builder":G==="templates"?"agents":G;c&&((I==="agents"||I==="teams"||I==="skills")&&(I="builder"),(I==="governance"||I==="reports")&&(I="settings"));const Q=hd(),$=window.location.hash.slice(1);$!==Q?sm[Q]=$:delete sm[Q];const F=sm[I];F&&F!==I?(history.pushState(null,"","#"+I),history.pushState(null,"","#"+F)):history.pushState(null,"","#"+I),window.dispatchEvent(new HashChangeEvent("hashchange")),r(I),x(B=>B.has(I)?B:new Set([...B,I]))},[c]);v.useEffect(()=>{jt.setHandler(G=>k(G))},[k]);const S=v.useCallback(()=>{fetch("/api/settings/llm").then(G=>G.ok?G.json():null).then(G=>{if(G?.providers){const I=Object.values(G.providers).some(Q=>Q.configured);E(I)}}).catch(()=>{})},[]);v.useEffect(()=>{re.auth.me().then(({user:I})=>{p(I),S(),Qa(wr.builderArtifacts,()=>re.builder.artifacts.list()),Qa(wr.builderAgents,()=>re.agents.list()),Qa(wr.builderHubMyItems,()=>Un.myItems()),Qa(wr.builderInstalled,()=>re.builder.artifacts.installed()),Qa(wr.hubAgents,()=>Un.search({type:"agent",limit:50})),Qa(wr.hubTeams,()=>Un.search({type:"team",limit:50})),Qa(wr.hubSkills,()=>Un.search({type:"skill",limit:50}))}).catch(()=>p(null)),kn.connect();const G=()=>{const I=hd();r(I),x(Q=>Q.has(I)?Q:new Set([...Q,I]))};return window.addEventListener("hashchange",G),()=>{kn.disconnect(),window.removeEventListener("hashchange",G)}},[]);const O=g!=="loading"&&g!==null?g:void 0,R=v.useMemo(()=>c?{dashboard:t.jsx(xb,{}),chat:t.jsx(wy,{authUser:O}),builder:t.jsx(Wz,{authUser:O}),settings:t.jsx(eI,{theme:h.mode,onThemeChange:h.setMode}),projects:t.jsx(Vv,{authUser:O}),deliverables:t.jsx(Xv,{})}:{dashboard:t.jsx(xb,{}),chat:t.jsx(wy,{authUser:O}),settings:t.jsx(kj,{theme:h.mode,onThemeChange:h.setMode}),skills:t.jsx(Cj,{}),agents:t.jsx(Aj,{authUser:O}),teams:t.jsx(Dj,{}),builder:t.jsx(Oj,{}),governance:t.jsx(Rj,{}),projects:t.jsx(Vv,{authUser:O}),deliverables:t.jsx(Xv,{}),reports:t.jsx(TN,{authUser:O})},[O?.id,h.mode,c]);return g==="loading"?t.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center",children:t.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:"Loading…"})}):g===null?t.jsx(rI,{onLogin:(G,I)=>{p(G),I&&w(!0)}}):y?t.jsx(sI,{onComplete:()=>w(!1),isFirstTime:!0}):s?t.jsx(tI,{theme:h.mode,onThemeChange:h.setMode,onComplete:()=>{localStorage.setItem("markus_onboarded","1"),l(!1),S()}}):t.jsxs("div",{className:`flex h-dvh bg-surface-primary text-fg-primary ${c?"flex-col":""}`,children:[!c&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"relative z-40 shrink-0",style:{width:m.width},children:t.jsx(Gz,{currentPage:e,onNavigate:G=>{k(G),d(!1)},authUser:g,onLogout:()=>p(null),collapsed:m.collapsed,onToggleCollapse:m.toggle})}),!m.collapsed&&t.jsx("div",{className:"w-1 cursor-col-resize shrink-0 group relative z-10",onMouseDown:m.onResizeStart,children:t.jsx("div",{className:"absolute inset-y-0 -left-0.5 -right-0.5 group-hover:bg-brand-500/30 group-active:bg-brand-500/50 transition-colors"})})]}),t.jsxs("div",{className:`flex-1 overflow-hidden flex flex-col min-w-0 ${c?"pb-14":""}`,children:[N===!1&&!A&&e!=="settings"&&t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-amber-500/10 border-b border-amber-500/30 text-amber-600 text-sm shrink-0",children:[t.jsx("span",{className:c?"text-xs":"",children:"No LLM provider configured — agents cannot process requests."}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>{k("settings")},className:"px-3 py-1 bg-amber-700/50 hover:bg-amber-700/70 text-white text-xs rounded-lg transition-colors",children:"Go to Settings"}),t.jsx("button",{onClick:()=>C(!0),className:"text-amber-500 hover:text-amber-600 text-xs",children:"Dismiss"})]})]}),t.jsx("main",{className:"flex-1 overflow-hidden flex flex-col",children:Object.keys(R).map(G=>f.has(G)?t.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",style:{display:G===e?"flex":"none"},children:R[G]},G):null)})]}),c&&t.jsx(Qz,{currentPage:e,onNavigate:k})]})}U2.createRoot(document.getElementById("root")).render(t.jsx(v.StrictMode,{children:t.jsx(oI,{})}));
|