@markus-global/cli 0.4.19 → 0.4.21
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/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +163 -30
- package/dist/commands/start.js.map +1 -1
- package/dist/markus.mjs +3685 -1398
- package/dist/paths.js +4 -4
- package/dist/paths.js.map +1 -1
- package/dist/web-ui/assets/index-BWjiUsem.js +66 -0
- package/dist/web-ui/assets/index-BgcwiZ1h.css +1 -0
- package/dist/web-ui/index.html +2 -2
- package/package.json +1 -1
- package/templates/roles/SHARED.md +7 -6
- package/templates/roles/developer/HEARTBEAT.md +4 -4
- package/templates/roles/operations/HEARTBEAT.md +4 -4
- package/templates/roles/org-manager/HEARTBEAT.md +5 -5
- package/templates/roles/product-manager/HEARTBEAT.md +4 -4
- package/templates/roles/reviewer/HEARTBEAT.md +4 -4
- package/templates/roles/secretary/HEARTBEAT.md +4 -4
- package/templates/skills/chrome-devtools/SKILL.md +33 -14
- package/templates/skills/markitdown/SKILL.md +56 -0
- package/templates/skills/markitdown/skill.json +20 -0
- package/templates/skills/self-evolution/SKILL.md +128 -150
- package/templates/skills/self-evolution/skill.json +1 -1
- package/dist/web-ui/assets/index-3aaspe8C.css +0 -1
- package/dist/web-ui/assets/index-DVrJcKF4.js +0 -64
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))i(l);new MutationObserver(l=>{for(const d of l)if(d.type==="childList")for(const c of d.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&i(c)}).observe(document,{childList:!0,subtree:!0});function s(l){const d={};return l.integrity&&(d.integrity=l.integrity),l.referrerPolicy&&(d.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?d.credentials="include":l.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function i(l){if(l.ep)return;l.ep=!0;const d=s(l);fetch(l.href,d)}})();function su(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var wh={exports:{}},xo={};var yb;function Y2(){if(yb)return xo;yb=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function s(i,l,d){var c=null;if(d!==void 0&&(c=""+d),l.key!==void 0&&(c=""+l.key),"key"in l){d={};for(var h in l)h!=="key"&&(d[h]=l[h])}else d=l;return l=d.ref,{$$typeof:e,type:i,key:c,ref:l!==void 0?l:null,props:d}}return xo.Fragment=n,xo.jsx=s,xo.jsxs=s,xo}var vb;function G2(){return vb||(vb=1,wh.exports=Y2()),wh.exports}var t=G2(),Nh={exports:{}},Mt={};var jb;function X2(){if(jb)return Mt;jb=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),l=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"),p=Symbol.for("react.activity"),g=Symbol.iterator;function y(O){return O===null||typeof O!="object"?null:(O=g&&O[g]||O["@@iterator"],typeof O=="function"?O:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,T={};function C(O,V,I){this.props=O,this.context=V,this.refs=T,this.updater=I||w}C.prototype.isReactComponent={},C.prototype.setState=function(O,V){if(typeof O!="object"&&typeof O!="function"&&O!=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,O,V,"setState")},C.prototype.forceUpdate=function(O){this.updater.enqueueForceUpdate(this,O,"forceUpdate")};function _(){}_.prototype=C.prototype;function k(O,V,I){this.props=O,this.context=V,this.refs=T,this.updater=I||w}var M=k.prototype=new _;M.constructor=k,N(M,C.prototype),M.isPureReactComponent=!0;var D=Array.isArray;function A(){}var G={H:null,A:null,T:null,S:null},X=Object.prototype.hasOwnProperty;function K(O,V,I){var S=I.ref;return{$$typeof:e,type:O,key:V,ref:S!==void 0?S:null,props:I}}function $(O,V){return K(O.type,V,O.props)}function q(O){return typeof O=="object"&&O!==null&&O.$$typeof===e}function U(O){var V={"=":"=0",":":"=2"};return"$"+O.replace(/[=:]/g,function(I){return V[I]})}var z=/\/+/g;function E(O,V){return typeof O=="object"&&O!==null&&O.key!=null?U(""+O.key):V.toString(36)}function L(O){switch(O.status){case"fulfilled":return O.value;case"rejected":throw O.reason;default:switch(typeof O.status=="string"?O.then(A,A):(O.status="pending",O.then(function(V){O.status==="pending"&&(O.status="fulfilled",O.value=V)},function(V){O.status==="pending"&&(O.status="rejected",O.reason=V)})),O.status){case"fulfilled":return O.value;case"rejected":throw O.reason}}throw O}function R(O,V,I,S,H){var W=typeof O;(W==="undefined"||W==="boolean")&&(O=null);var ee=!1;if(O===null)ee=!0;else switch(W){case"bigint":case"string":case"number":ee=!0;break;case"object":switch(O.$$typeof){case e:case n:ee=!0;break;case x:return ee=O._init,R(ee(O._payload),V,I,S,H)}}if(ee)return H=H(O),ee=S===""?"."+E(O,0):S,D(H)?(I="",ee!=null&&(I=ee.replace(z,"$&/")+"/"),R(H,V,I,"",function(he){return he})):H!=null&&(q(H)&&(H=$(H,I+(H.key==null||O&&O.key===H.key?"":(""+H.key).replace(z,"$&/")+"/")+ee)),V.push(H)),1;ee=0;var te=S===""?".":S+":";if(D(O))for(var ae=0;ae<O.length;ae++)S=O[ae],W=te+E(S,ae),ee+=R(S,V,I,W,H);else if(ae=y(O),typeof ae=="function")for(O=ae.call(O),ae=0;!(S=O.next()).done;)S=S.value,W=te+E(S,ae++),ee+=R(S,V,I,W,H);else if(W==="object"){if(typeof O.then=="function")return R(L(O),V,I,S,H);throw V=String(O),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys(O).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.")}return ee}function F(O,V,I){if(O==null)return O;var S=[],H=0;return R(O,S,"","",function(W){return V.call(I,W,H++)}),S}function Y(O){if(O._status===-1){var V=O._result;V=V(),V.then(function(I){(O._status===0||O._status===-1)&&(O._status=1,O._result=I)},function(I){(O._status===0||O._status===-1)&&(O._status=2,O._result=I)}),O._status===-1&&(O._status=0,O._result=V)}if(O._status===1)return O._result.default;throw O._result}var Z=typeof reportError=="function"?reportError:function(O){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var V=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof O=="object"&&O!==null&&typeof O.message=="string"?String(O.message):String(O),error:O});if(!window.dispatchEvent(V))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",O);return}console.error(O)},B={map:F,forEach:function(O,V,I){F(O,function(){V.apply(this,arguments)},I)},count:function(O){var V=0;return F(O,function(){V++}),V},toArray:function(O){return F(O,function(V){return V})||[]},only:function(O){if(!q(O))throw Error("React.Children.only expected to receive a single React element child.");return O}};return Mt.Activity=p,Mt.Children=B,Mt.Component=C,Mt.Fragment=s,Mt.Profiler=l,Mt.PureComponent=k,Mt.StrictMode=i,Mt.Suspense=m,Mt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=G,Mt.__COMPILER_RUNTIME={__proto__:null,c:function(O){return G.H.useMemoCache(O)}},Mt.cache=function(O){return function(){return O.apply(null,arguments)}},Mt.cacheSignal=function(){return null},Mt.cloneElement=function(O,V,I){if(O==null)throw Error("The argument must be a React element, but you passed "+O+".");var S=N({},O.props),H=O.key;if(V!=null)for(W in V.key!==void 0&&(H=""+V.key),V)!X.call(V,W)||W==="key"||W==="__self"||W==="__source"||W==="ref"&&V.ref===void 0||(S[W]=V[W]);var W=arguments.length-2;if(W===1)S.children=I;else if(1<W){for(var ee=Array(W),te=0;te<W;te++)ee[te]=arguments[te+2];S.children=ee}return K(O.type,H,S)},Mt.createContext=function(O){return O={$$typeof:c,_currentValue:O,_currentValue2:O,_threadCount:0,Provider:null,Consumer:null},O.Provider=O,O.Consumer={$$typeof:d,_context:O},O},Mt.createElement=function(O,V,I){var S,H={},W=null;if(V!=null)for(S in V.key!==void 0&&(W=""+V.key),V)X.call(V,S)&&S!=="key"&&S!=="__self"&&S!=="__source"&&(H[S]=V[S]);var ee=arguments.length-2;if(ee===1)H.children=I;else if(1<ee){for(var te=Array(ee),ae=0;ae<ee;ae++)te[ae]=arguments[ae+2];H.children=te}if(O&&O.defaultProps)for(S in ee=O.defaultProps,ee)H[S]===void 0&&(H[S]=ee[S]);return K(O,W,H)},Mt.createRef=function(){return{current:null}},Mt.forwardRef=function(O){return{$$typeof:h,render:O}},Mt.isValidElement=q,Mt.lazy=function(O){return{$$typeof:x,_payload:{_status:-1,_result:O},_init:Y}},Mt.memo=function(O,V){return{$$typeof:f,type:O,compare:V===void 0?null:V}},Mt.startTransition=function(O){var V=G.T,I={};G.T=I;try{var S=O(),H=G.S;H!==null&&H(I,S),typeof S=="object"&&S!==null&&typeof S.then=="function"&&S.then(A,Z)}catch(W){Z(W)}finally{V!==null&&I.types!==null&&(V.types=I.types),G.T=V}},Mt.unstable_useCacheRefresh=function(){return G.H.useCacheRefresh()},Mt.use=function(O){return G.H.use(O)},Mt.useActionState=function(O,V,I){return G.H.useActionState(O,V,I)},Mt.useCallback=function(O,V){return G.H.useCallback(O,V)},Mt.useContext=function(O){return G.H.useContext(O)},Mt.useDebugValue=function(){},Mt.useDeferredValue=function(O,V){return G.H.useDeferredValue(O,V)},Mt.useEffect=function(O,V){return G.H.useEffect(O,V)},Mt.useEffectEvent=function(O){return G.H.useEffectEvent(O)},Mt.useId=function(){return G.H.useId()},Mt.useImperativeHandle=function(O,V,I){return G.H.useImperativeHandle(O,V,I)},Mt.useInsertionEffect=function(O,V){return G.H.useInsertionEffect(O,V)},Mt.useLayoutEffect=function(O,V){return G.H.useLayoutEffect(O,V)},Mt.useMemo=function(O,V){return G.H.useMemo(O,V)},Mt.useOptimistic=function(O,V){return G.H.useOptimistic(O,V)},Mt.useReducer=function(O,V,I){return G.H.useReducer(O,V,I)},Mt.useRef=function(O){return G.H.useRef(O)},Mt.useState=function(O){return G.H.useState(O)},Mt.useSyncExternalStore=function(O,V,I){return G.H.useSyncExternalStore(O,V,I)},Mt.useTransition=function(){return G.H.useTransition()},Mt.version="19.2.4",Mt}var wb;function ec(){return wb||(wb=1,Nh.exports=X2()),Nh.exports}var v=ec();const K2=su(v);var kh={exports:{}},po={},Sh={exports:{}},Ch={};var Nb;function W2(){return Nb||(Nb=1,(function(e){function n(R,F){var Y=R.length;R.push(F);e:for(;0<Y;){var Z=Y-1>>>1,B=R[Z];if(0<l(B,F))R[Z]=F,R[Y]=B,Y=Z;else break e}}function s(R){return R.length===0?null:R[0]}function i(R){if(R.length===0)return null;var F=R[0],Y=R.pop();if(Y!==F){R[0]=Y;e:for(var Z=0,B=R.length,O=B>>>1;Z<O;){var V=2*(Z+1)-1,I=R[V],S=V+1,H=R[S];if(0>l(I,Y))S<B&&0>l(H,I)?(R[Z]=H,R[S]=Y,Z=S):(R[Z]=I,R[V]=Y,Z=V);else if(S<B&&0>l(H,Y))R[Z]=H,R[S]=Y,Z=S;else break e}}return F}function l(R,F){var Y=R.sortIndex-F.sortIndex;return Y!==0?Y:R.id-F.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,p=null,g=3,y=!1,w=!1,N=!1,T=!1,C=typeof setTimeout=="function"?setTimeout:null,_=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;function M(R){for(var F=s(f);F!==null;){if(F.callback===null)i(f);else if(F.startTime<=R)i(f),F.sortIndex=F.expirationTime,n(m,F);else break;F=s(f)}}function D(R){if(N=!1,M(R),!w)if(s(m)!==null)w=!0,A||(A=!0,U());else{var F=s(f);F!==null&&L(D,F.startTime-R)}}var A=!1,G=-1,X=5,K=-1;function $(){return T?!0:!(e.unstable_now()-K<X)}function q(){if(T=!1,A){var R=e.unstable_now();K=R;var F=!0;try{e:{w=!1,N&&(N=!1,_(G),G=-1),y=!0;var Y=g;try{t:{for(M(R),p=s(m);p!==null&&!(p.expirationTime>R&&$());){var Z=p.callback;if(typeof Z=="function"){p.callback=null,g=p.priorityLevel;var B=Z(p.expirationTime<=R);if(R=e.unstable_now(),typeof B=="function"){p.callback=B,M(R),F=!0;break t}p===s(m)&&i(m),M(R)}else i(m);p=s(m)}if(p!==null)F=!0;else{var O=s(f);O!==null&&L(D,O.startTime-R),F=!1}}break e}finally{p=null,g=Y,y=!1}F=void 0}}finally{F?U():A=!1}}}var U;if(typeof k=="function")U=function(){k(q)};else if(typeof MessageChannel<"u"){var z=new MessageChannel,E=z.port2;z.port1.onmessage=q,U=function(){E.postMessage(null)}}else U=function(){C(q,0)};function L(R,F){G=C(function(){R(e.unstable_now())},F)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(R){R.callback=null},e.unstable_forceFrameRate=function(R){0>R||125<R?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):X=0<R?Math.floor(1e3/R):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_next=function(R){switch(g){case 1:case 2:case 3:var F=3;break;default:F=g}var Y=g;g=F;try{return R()}finally{g=Y}},e.unstable_requestPaint=function(){T=!0},e.unstable_runWithPriority=function(R,F){switch(R){case 1:case 2:case 3:case 4:case 5:break;default:R=3}var Y=g;g=R;try{return F()}finally{g=Y}},e.unstable_scheduleCallback=function(R,F,Y){var Z=e.unstable_now();switch(typeof Y=="object"&&Y!==null?(Y=Y.delay,Y=typeof Y=="number"&&0<Y?Z+Y:Z):Y=Z,R){case 1:var B=-1;break;case 2:B=250;break;case 5:B=1073741823;break;case 4:B=1e4;break;default:B=5e3}return B=Y+B,R={id:x++,callback:F,priorityLevel:R,startTime:Y,expirationTime:B,sortIndex:-1},Y>Z?(R.sortIndex=Y,n(f,R),s(m)===null&&R===s(f)&&(N?(_(G),G=-1):N=!0,L(D,Y-Z))):(R.sortIndex=B,n(m,R),w||y||(w=!0,A||(A=!0,U()))),R},e.unstable_shouldYield=$,e.unstable_wrapCallback=function(R){var F=g;return function(){var Y=g;g=F;try{return R.apply(this,arguments)}finally{g=Y}}}})(Ch)),Ch}var kb;function Q2(){return kb||(kb=1,Sh.exports=W2()),Sh.exports}var Eh={exports:{}},pr={};var Sb;function Z2(){if(Sb)return pr;Sb=1;var e=ec();function n(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 i={d:{f:s,r:function(){throw Error(n(522))},D:s,C:s,L:s,m:s,X:s,S:s,M:s},p:0,findDOMNode:null},l=Symbol.for("react.portal");function d(m,f,x){var p=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:l,key:p==null?null:""+p,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 pr.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,pr.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(n(299));return d(m,f,null,x)},pr.flushSync=function(m){var f=c.T,x=i.p;try{if(c.T=null,i.p=2,m)return m()}finally{c.T=f,i.p=x,i.d.f()}},pr.preconnect=function(m,f){typeof m=="string"&&(f?(f=f.crossOrigin,f=typeof f=="string"?f==="use-credentials"?f:"":void 0):f=null,i.d.C(m,f))},pr.prefetchDNS=function(m){typeof m=="string"&&i.d.D(m)},pr.preinit=function(m,f){if(typeof m=="string"&&f&&typeof f.as=="string"){var x=f.as,p=h(x,f.crossOrigin),g=typeof f.integrity=="string"?f.integrity:void 0,y=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;x==="style"?i.d.S(m,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:p,integrity:g,fetchPriority:y}):x==="script"&&i.d.X(m,{crossOrigin:p,integrity:g,fetchPriority:y,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},pr.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);i.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&&i.d.M(m)},pr.preload=function(m,f){if(typeof m=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var x=f.as,p=h(x,f.crossOrigin);i.d.L(m,x,{crossOrigin:p,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})}},pr.preloadModule=function(m,f){if(typeof m=="string")if(f){var x=h(f.as,f.crossOrigin);i.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 i.d.m(m)},pr.requestFormReset=function(m){i.d.r(m)},pr.unstable_batchedUpdates=function(m,f){return m(f)},pr.useFormState=function(m,f,x){return c.H.useFormState(m,f,x)},pr.useFormStatus=function(){return c.H.useHostTransitionStatus()},pr.version="19.2.4",pr}var Cb;function E1(){if(Cb)return Eh.exports;Cb=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(n){console.error(n)}}return e(),Eh.exports=Z2(),Eh.exports}var Eb;function J2(){if(Eb)return po;Eb=1;var e=Q2(),n=ec(),s=E1();function i(r){var a="https://react.dev/errors/"+r;if(1<arguments.length){a+="?args[]="+encodeURIComponent(arguments[1]);for(var o=2;o<arguments.length;o++)a+="&args[]="+encodeURIComponent(arguments[o])}return"Minified React error #"+r+"; visit "+a+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function l(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11)}function d(r){var a=r,o=r;if(r.alternate)for(;a.return;)a=a.return;else{r=a;do a=r,(a.flags&4098)!==0&&(o=a.return),r=a.return;while(r)}return a.tag===3?o:null}function c(r){if(r.tag===13){var a=r.memoizedState;if(a===null&&(r=r.alternate,r!==null&&(a=r.memoizedState)),a!==null)return a.dehydrated}return null}function h(r){if(r.tag===31){var a=r.memoizedState;if(a===null&&(r=r.alternate,r!==null&&(a=r.memoizedState)),a!==null)return a.dehydrated}return null}function m(r){if(d(r)!==r)throw Error(i(188))}function f(r){var a=r.alternate;if(!a){if(a=d(r),a===null)throw Error(i(188));return a!==r?null:r}for(var o=r,u=a;;){var b=o.return;if(b===null)break;var j=b.alternate;if(j===null){if(u=b.return,u!==null){o=u;continue}break}if(b.child===j.child){for(j=b.child;j;){if(j===o)return m(b),r;if(j===u)return m(b),a;j=j.sibling}throw Error(i(188))}if(o.return!==u.return)o=b,u=j;else{for(var P=!1,J=b.child;J;){if(J===o){P=!0,o=b,u=j;break}if(J===u){P=!0,u=b,o=j;break}J=J.sibling}if(!P){for(J=j.child;J;){if(J===o){P=!0,o=j,u=b;break}if(J===u){P=!0,u=j,o=b;break}J=J.sibling}if(!P)throw Error(i(189))}}if(o.alternate!==u)throw Error(i(190))}if(o.tag!==3)throw Error(i(188));return o.stateNode.current===o?r:a}function x(r){var a=r.tag;if(a===5||a===26||a===27||a===6)return r;for(r=r.child;r!==null;){if(a=x(r),a!==null)return a;r=r.sibling}return null}var p=Object.assign,g=Symbol.for("react.element"),y=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),_=Symbol.for("react.consumer"),k=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),D=Symbol.for("react.suspense"),A=Symbol.for("react.suspense_list"),G=Symbol.for("react.memo"),X=Symbol.for("react.lazy"),K=Symbol.for("react.activity"),$=Symbol.for("react.memo_cache_sentinel"),q=Symbol.iterator;function U(r){return r===null||typeof r!="object"?null:(r=q&&r[q]||r["@@iterator"],typeof r=="function"?r:null)}var z=Symbol.for("react.client.reference");function E(r){if(r==null)return null;if(typeof r=="function")return r.$$typeof===z?null:r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case N:return"Fragment";case C:return"Profiler";case T:return"StrictMode";case D:return"Suspense";case A:return"SuspenseList";case K:return"Activity"}if(typeof r=="object")switch(r.$$typeof){case w:return"Portal";case k:return r.displayName||"Context";case _:return(r._context.displayName||"Context")+".Consumer";case M:var a=r.render;return r=r.displayName,r||(r=a.displayName||a.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case G:return a=r.displayName||null,a!==null?a:E(r.type)||"Memo";case X:a=r._payload,r=r._init;try{return E(r(a))}catch{}}return null}var L=Array.isArray,R=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Y={pending:!1,data:null,method:null,action:null},Z=[],B=-1;function O(r){return{current:r}}function V(r){0>B||(r.current=Z[B],Z[B]=null,B--)}function I(r,a){B++,Z[B]=r.current,r.current=a}var S=O(null),H=O(null),W=O(null),ee=O(null);function te(r,a){switch(I(W,a),I(H,r),I(S,null),a.nodeType){case 9:case 11:r=(r=a.documentElement)&&(r=r.namespaceURI)?q0(r):0;break;default:if(r=a.tagName,a=a.namespaceURI)a=q0(a),r=U0(a,r);else switch(r){case"svg":r=1;break;case"math":r=2;break;default:r=0}}V(S),I(S,r)}function ae(){V(S),V(H),V(W)}function he(r){r.memoizedState!==null&&I(ee,r);var a=S.current,o=U0(a,r.type);a!==o&&(I(H,r),I(S,o))}function Ne(r){H.current===r&&(V(S),V(H)),ee.current===r&&(V(ee),uo._currentValue=Y)}var De,je;function ke(r){if(De===void 0)try{throw Error()}catch(o){var a=o.stack.trim().match(/\n( *(at )?)/);De=a&&a[1]||"",je=-1<o.stack.indexOf(`
|
|
2
|
-
at`)?" (<anonymous>)":-1<o.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
3
|
-
`+De+r+je}var Se=!1;function Le(r,a){if(!r||Se)return"";Se=!0;var o=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var u={DetermineComponentFrameRoot:function(){try{if(a){var Oe=function(){throw Error()};if(Object.defineProperty(Oe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Oe,[])}catch(we){var ve=we}Reflect.construct(r,[],Oe)}else{try{Oe.call()}catch(we){ve=we}r.call(Oe.prototype)}}else{try{throw Error()}catch(we){ve=we}(Oe=r())&&typeof Oe.catch=="function"&&Oe.catch(function(){})}}catch(we){if(we&&ve&&typeof we.stack=="string")return[we.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],J=j[1];if(P&&J){var ie=P.split(`
|
|
4
|
-
`),ge=J.split(`
|
|
5
|
-
`);for(b=u=0;u<ie.length&&!ie[u].includes("DetermineComponentFrameRoot");)u++;for(;b<ge.length&&!ge[b].includes("DetermineComponentFrameRoot");)b++;if(u===ie.length||b===ge.length)for(u=ie.length-1,b=ge.length-1;1<=u&&0<=b&&ie[u]!==ge[b];)b--;for(;1<=u&&0<=b;u--,b--)if(ie[u]!==ge[b]){if(u!==1||b!==1)do if(u--,b--,0>b||ie[u]!==ge[b]){var Ee=`
|
|
6
|
-
`+ie[u].replace(" at new "," at ");return r.displayName&&Ee.includes("<anonymous>")&&(Ee=Ee.replace("<anonymous>",r.displayName)),Ee}while(1<=u&&0<=b);break}}}finally{Se=!1,Error.prepareStackTrace=o}return(o=r?r.displayName||r.name:"")?ke(o):""}function nt(r,a){switch(r.tag){case 26:case 27:case 5:return ke(r.type);case 16:return ke("Lazy");case 13:return r.child!==a&&a!==null?ke("Suspense Fallback"):ke("Suspense");case 19:return ke("SuspenseList");case 0:case 15:return Le(r.type,!1);case 11:return Le(r.type.render,!1);case 1:return Le(r.type,!0);case 31:return ke("Activity");default:return""}}function rt(r){try{var a="",o=null;do a+=nt(r,o),o=r,r=r.return;while(r);return a}catch(u){return`
|
|
7
|
-
Error generating stack: `+u.message+`
|
|
8
|
-
`+u.stack}}var yt=Object.prototype.hasOwnProperty,Rt=e.unstable_scheduleCallback,re=e.unstable_cancelCallback,_e=e.unstable_shouldYield,st=e.unstable_requestPaint,dt=e.unstable_now,Yt=e.unstable_getCurrentPriorityLevel,ye=e.unstable_ImmediatePriority,Ae=e.unstable_UserBlockingPriority,Fe=e.unstable_NormalPriority,Qe=e.unstable_LowPriority,xt=e.unstable_IdlePriority,nn=e.log,cn=e.unstable_setDisableYieldValue,Tt=null,gt=null;function Bt(r){if(typeof nn=="function"&&cn(r),gt&&typeof gt.setStrictMode=="function")try{gt.setStrictMode(Tt,r)}catch{}}var _t=Math.clz32?Math.clz32:bn,Ht=Math.log,rn=Math.LN2;function bn(r){return r>>>=0,r===0?32:31-(Ht(r)/rn|0)|0}var Hn=256,Cn=262144,xe=4194304;function Re(r){var a=r&42;if(a!==0)return a;switch(r&-r){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 r&261888;case 262144:case 524288:case 1048576:case 2097152:return r&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return r&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return r}}function vt(r,a,o){var u=r.pendingLanes;if(u===0)return 0;var b=0,j=r.suspendedLanes,P=r.pingedLanes;r=r.warmLanes;var J=u&134217727;return J!==0?(u=J&~j,u!==0?b=Re(u):(P&=J,P!==0?b=Re(P):o||(o=J&~r,o!==0&&(b=Re(o))))):(J=u&~j,J!==0?b=Re(J):P!==0?b=Re(P):o||(o=u&~r,o!==0&&(b=Re(o)))),b===0?0:a!==0&&a!==b&&(a&j)===0&&(j=b&-b,o=a&-a,j>=o||j===32&&(o&4194048)!==0)?a:b}function At(r,a){return(r.pendingLanes&~(r.suspendedLanes&~r.pingedLanes)&a)===0}function Dt(r,a){switch(r){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 On(){var r=xe;return xe<<=1,(xe&62914560)===0&&(xe=4194304),r}function an(r){for(var a=[],o=0;31>o;o++)a.push(r);return a}function dn(r,a){r.pendingLanes|=a,a!==268435456&&(r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0)}function Dn(r,a,o,u,b,j){var P=r.pendingLanes;r.pendingLanes=o,r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0,r.expiredLanes&=o,r.entangledLanes&=o,r.errorRecoveryDisabledLanes&=o,r.shellSuspendCounter=0;var J=r.entanglements,ie=r.expirationTimes,ge=r.hiddenUpdates;for(o=P&~o;0<o;){var Ee=31-_t(o),Oe=1<<Ee;J[Ee]=0,ie[Ee]=-1;var ve=ge[Ee];if(ve!==null)for(ge[Ee]=null,Ee=0;Ee<ve.length;Ee++){var we=ve[Ee];we!==null&&(we.lane&=-536870913)}o&=~Oe}u!==0&&Nt(r,u,0),j!==0&&b===0&&r.tag!==0&&(r.suspendedLanes|=j&~(P&~a))}function Nt(r,a,o){r.pendingLanes|=a,r.suspendedLanes&=~a;var u=31-_t(a);r.entangledLanes|=a,r.entanglements[u]=r.entanglements[u]|1073741824|o&261930}function hn(r,a){var o=r.entangledLanes|=a;for(r=r.entanglements;o;){var u=31-_t(o),b=1<<u;b&a|r[u]&a&&(r[u]|=a),o&=~b}}function lr(r,a){var o=a&-a;return o=(o&42)!==0?1:le(o),(o&(r.suspendedLanes|a))!==0?0:o}function le(r){switch(r){case 2:r=1;break;case 8:r=4;break;case 32:r=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:r=128;break;case 268435456:r=134217728;break;default:r=0}return r}function $e(r){return r&=-r,2<r?8<r?(r&134217727)!==0?32:268435456:8:2}function Ue(){var r=F.p;return r!==0?r:(r=window.event,r===void 0?32:fb(r.type))}function We(r,a){var o=F.p;try{return F.p=r,a()}finally{F.p=o}}var Ke=Math.random().toString(36).slice(2),qe="__reactFiber$"+Ke,Je="__reactProps$"+Ke,Wt="__reactContainer$"+Ke,Zt="__reactEvents$"+Ke,Pt="__reactListeners$"+Ke,En="__reactHandles$"+Ke,be="__reactResources$"+Ke,ze="__reactMarker$"+Ke;function Et(r){delete r[qe],delete r[Je],delete r[Zt],delete r[Pt],delete r[En]}function kt(r){var a=r[qe];if(a)return a;for(var o=r.parentNode;o;){if(a=o[Wt]||o[qe]){if(o=a.alternate,a.child!==null||o!==null&&o.child!==null)for(r=W0(r);r!==null;){if(o=r[qe])return o;r=W0(r)}return a}r=o,o=r.parentNode}return null}function yn(r){if(r=r[qe]||r[Wt]){var a=r.tag;if(a===5||a===6||a===13||a===31||a===26||a===27||a===3)return r}return null}function _n(r){var a=r.tag;if(a===5||a===26||a===27||a===6)return r.stateNode;throw Error(i(33))}function or(r){var a=r[be];return a||(a=r[be]={hoistableStyles:new Map,hoistableScripts:new Map}),a}function Nn(r){r[ze]=!0}var yr=new Set,Hr={};function de(r,a){Te(r,a),Te(r+"Capture",a)}function Te(r,a){for(Hr[r]=a,r=0;r<a.length;r++)yr.add(a[r])}var Ve=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]*$"),qt={},vr={};function ts(r){return yt.call(vr,r)?!0:yt.call(qt,r)?!1:Ve.test(r)?vr[r]=!0:(qt[r]=!0,!1)}function Nr(r,a,o){if(ts(a))if(o===null)r.removeAttribute(a);else{switch(typeof o){case"undefined":case"function":case"symbol":r.removeAttribute(a);return;case"boolean":var u=a.toLowerCase().slice(0,5);if(u!=="data-"&&u!=="aria-"){r.removeAttribute(a);return}}r.setAttribute(a,""+o)}}function Ns(r,a,o){if(o===null)r.removeAttribute(a);else{switch(typeof o){case"undefined":case"function":case"symbol":case"boolean":r.removeAttribute(a);return}r.setAttribute(a,""+o)}}function xr(r,a,o,u){if(u===null)r.removeAttribute(o);else{switch(typeof u){case"undefined":case"function":case"symbol":case"boolean":r.removeAttribute(o);return}r.setAttributeNS(a,o,""+u)}}function tr(r){switch(typeof r){case"bigint":case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function $s(r){var a=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(a==="checkbox"||a==="radio")}function Bs(r,a,o){var u=Object.getOwnPropertyDescriptor(r.constructor.prototype,a);if(!r.hasOwnProperty(a)&&typeof u<"u"&&typeof u.get=="function"&&typeof u.set=="function"){var b=u.get,j=u.set;return Object.defineProperty(r,a,{configurable:!0,get:function(){return b.call(this)},set:function(P){o=""+P,j.call(this,P)}}),Object.defineProperty(r,a,{enumerable:u.enumerable}),{getValue:function(){return o},setValue:function(P){o=""+P},stopTracking:function(){r._valueTracker=null,delete r[a]}}}}function Pr(r){if(!r._valueTracker){var a=$s(r)?"checked":"value";r._valueTracker=Bs(r,a,""+r[a])}}function ha(r){if(!r)return!1;var a=r._valueTracker;if(!a)return!0;var o=a.getValue(),u="";return r&&(u=$s(r)?r.checked?"true":"false":r.value),r=u,r!==o?(a.setValue(r),!0):!1}function qr(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}var ma=/[\n"\\]/g;function Yn(r){return r.replace(ma,function(a){return"\\"+a.charCodeAt(0).toString(16)+" "})}function kr(r,a,o,u,b,j,P,J){r.name="",P!=null&&typeof P!="function"&&typeof P!="symbol"&&typeof P!="boolean"?r.type=P:r.removeAttribute("type"),a!=null?P==="number"?(a===0&&r.value===""||r.value!=a)&&(r.value=""+tr(a)):r.value!==""+tr(a)&&(r.value=""+tr(a)):P!=="submit"&&P!=="reset"||r.removeAttribute("value"),a!=null?Sr(r,P,tr(a)):o!=null?Sr(r,P,tr(o)):u!=null&&r.removeAttribute("value"),b==null&&j!=null&&(r.defaultChecked=!!j),b!=null&&(r.checked=b&&typeof b!="function"&&typeof b!="symbol"),J!=null&&typeof J!="function"&&typeof J!="symbol"&&typeof J!="boolean"?r.name=""+tr(J):r.removeAttribute("name")}function fs(r,a,o,u,b,j,P,J){if(j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"&&(r.type=j),a!=null||o!=null){if(!(j!=="submit"&&j!=="reset"||a!=null)){Pr(r);return}o=o!=null?""+tr(o):"",a=a!=null?""+tr(a):o,J||a===r.value||(r.value=a),r.defaultValue=a}u=u??b,u=typeof u!="function"&&typeof u!="symbol"&&!!u,r.checked=J?r.checked:!!u,r.defaultChecked=!!u,P!=null&&typeof P!="function"&&typeof P!="symbol"&&typeof P!="boolean"&&(r.name=P),Pr(r)}function Sr(r,a,o){a==="number"&&qr(r.ownerDocument)===r||r.defaultValue===""+o||(r.defaultValue=""+o)}function cr(r,a,o,u){if(r=r.options,a){a={};for(var b=0;b<o.length;b++)a["$"+o[b]]=!0;for(o=0;o<r.length;o++)b=a.hasOwnProperty("$"+r[o].value),r[o].selected!==b&&(r[o].selected=b),b&&u&&(r[o].defaultSelected=!0)}else{for(o=""+tr(o),a=null,b=0;b<r.length;b++){if(r[b].value===o){r[b].selected=!0,u&&(r[b].defaultSelected=!0);return}a!==null||r[b].disabled||(a=r[b])}a!==null&&(a.selected=!0)}}function Wa(r,a,o){if(a!=null&&(a=""+tr(a),a!==r.value&&(r.value=a),o==null)){r.defaultValue!==a&&(r.defaultValue=a);return}r.defaultValue=o!=null?""+tr(o):""}function _i(r,a,o,u){if(a==null){if(u!=null){if(o!=null)throw Error(i(92));if(L(u)){if(1<u.length)throw Error(i(93));u=u[0]}o=u}o==null&&(o=""),a=o}o=tr(a),r.defaultValue=o,u=r.textContent,u===o&&u!==""&&u!==null&&(r.value=u),Pr(r)}function Cr(r,a){if(a){var o=r.firstChild;if(o&&o===r.lastChild&&o.nodeType===3){o.nodeValue=a;return}}r.textContent=a}var Er=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 Hs(r,a,o){var u=a.indexOf("--")===0;o==null||typeof o=="boolean"||o===""?u?r.setProperty(a,""):a==="float"?r.cssFloat="":r[a]="":u?r.setProperty(a,o):typeof o!="number"||o===0||Er.has(a)?a==="float"?r.cssFloat=o:r[a]=(""+o).trim():r[a]=o+"px"}function xa(r,a,o){if(a!=null&&typeof a!="object")throw Error(i(62));if(r=r.style,o!=null){for(var u in o)!o.hasOwnProperty(u)||a!=null&&a.hasOwnProperty(u)||(u.indexOf("--")===0?r.setProperty(u,""):u==="float"?r.cssFloat="":r[u]="");for(var b in a)u=a[b],a.hasOwnProperty(b)&&o[b]!==u&&Hs(r,b,u)}else for(var j in a)a.hasOwnProperty(j)&&Hs(r,j,a[j])}function Ps(r){if(r.indexOf("-")===-1)return!1;switch(r){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 Tr=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"]]),ne=/^[\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 Ie(r){return ne.test(""+r)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":r}function Ye(){}var it=null;function sn(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var mn=null,Q=null;function oe(r){var a=yn(r);if(a&&(r=a.stateNode)){var o=r[Je]||null;e:switch(r=a.stateNode,a.type){case"input":if(kr(r,o.value,o.defaultValue,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name),a=o.name,o.type==="radio"&&a!=null){for(o=r;o.parentNode;)o=o.parentNode;for(o=o.querySelectorAll('input[name="'+Yn(""+a)+'"][type="radio"]'),a=0;a<o.length;a++){var u=o[a];if(u!==r&&u.form===r.form){var b=u[Je]||null;if(!b)throw Error(i(90));kr(u,b.value,b.defaultValue,b.defaultValue,b.checked,b.defaultChecked,b.type,b.name)}}for(a=0;a<o.length;a++)u=o[a],u.form===r.form&&ha(u)}break e;case"textarea":Wa(r,o.value,o.defaultValue);break e;case"select":a=o.value,a!=null&&cr(r,!!o.multiple,a,!1)}}}var Ce=!1;function Ge(r,a,o){if(Ce)return r(a,o);Ce=!0;try{var u=r(a);return u}finally{if(Ce=!1,(mn!==null||Q!==null)&&(Yc(),mn&&(a=mn,r=Q,Q=mn=null,oe(a),r)))for(a=0;a<r.length;a++)oe(r[a])}}function Be(r,a){var o=r.stateNode;if(o===null)return null;var u=o[Je]||null;if(u===null)return null;o=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)||(r=r.type,u=!(r==="button"||r==="input"||r==="select"||r==="textarea")),r=!u;break e;default:r=!1}if(r)return null;if(o&&typeof o!="function")throw Error(i(231,a,typeof o));return o}var He=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ct=!1;if(He)try{var Ze={};Object.defineProperty(Ze,"passive",{get:function(){ct=!0}}),window.addEventListener("test",Ze,Ze),window.removeEventListener("test",Ze,Ze)}catch{ct=!1}var Xe=null,at=null,jt=null;function Gt(){if(jt)return jt;var r,a=at,o=a.length,u,b="value"in Xe?Xe.value:Xe.textContent,j=b.length;for(r=0;r<o&&a[r]===b[r];r++);var P=o-r;for(u=1;u<=P&&a[o-u]===b[j-u];u++);return jt=b.slice(r,1<u?1-u:void 0)}function It(r){var a=r.keyCode;return"charCode"in r?(r=r.charCode,r===0&&a===13&&(r=13)):r=a,r===10&&(r=13),32<=r||r===13?r:0}function un(){return!0}function _r(){return!1}function Ln(r){function a(o,u,b,j,P){this._reactName=o,this._targetInst=b,this.type=u,this.nativeEvent=j,this.target=P,this.currentTarget=null;for(var J in r)r.hasOwnProperty(J)&&(o=r[J],this[J]=o?o(j):j[J]);return this.isDefaultPrevented=(j.defaultPrevented!=null?j.defaultPrevented:j.returnValue===!1)?un:_r,this.isPropagationStopped=_r,this}return p(a.prototype,{preventDefault:function(){this.defaultPrevented=!0;var o=this.nativeEvent;o&&(o.preventDefault?o.preventDefault():typeof o.returnValue!="unknown"&&(o.returnValue=!1),this.isDefaultPrevented=un)},stopPropagation:function(){var o=this.nativeEvent;o&&(o.stopPropagation?o.stopPropagation():typeof o.cancelBubble!="unknown"&&(o.cancelBubble=!0),this.isPropagationStopped=un)},persist:function(){},isPersistent:un}),a}var wt={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ot=Ln(wt),pt=p({},wt,{view:0,detail:0}),lt=Ln(pt),et,ut,ft,In=p({},pt,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Cu,button:0,buttons:0,relatedTarget:function(r){return r.relatedTarget===void 0?r.fromElement===r.srcElement?r.toElement:r.fromElement:r.relatedTarget},movementX:function(r){return"movementX"in r?r.movementX:(r!==ft&&(ft&&r.type==="mousemove"?(et=r.screenX-ft.screenX,ut=r.screenY-ft.screenY):ut=et=0,ft=r),et)},movementY:function(r){return"movementY"in r?r.movementY:ut}}),sr=Ln(In),dr=p({},In,{dataTransfer:0}),dc=Ln(dr),Su=p({},pt,{relatedTarget:0}),Ur=Ln(Su),XN=p({},wt,{animationName:0,elapsedTime:0,pseudoElement:0}),KN=Ln(XN),WN=p({},wt,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),QN=Ln(WN),ZN=p({},wt,{data:0}),Yx=Ln(ZN),JN={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},e5={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"},t5={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function n5(r){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(r):(r=t5[r])?!!a[r]:!1}function Cu(){return n5}var r5=p({},pt,{key:function(r){if(r.key){var a=JN[r.key]||r.key;if(a!=="Unidentified")return a}return r.type==="keypress"?(r=It(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?e5[r.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Cu,charCode:function(r){return r.type==="keypress"?It(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?It(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),s5=Ln(r5),a5=p({},In,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Gx=Ln(a5),i5=p({},pt,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Cu}),l5=Ln(i5),o5=p({},wt,{propertyName:0,elapsedTime:0,pseudoElement:0}),c5=Ln(o5),d5=p({},In,{deltaX:function(r){return"deltaX"in r?r.deltaX:"wheelDeltaX"in r?-r.wheelDeltaX:0},deltaY:function(r){return"deltaY"in r?r.deltaY:"wheelDeltaY"in r?-r.wheelDeltaY:"wheelDelta"in r?-r.wheelDelta:0},deltaZ:0,deltaMode:0}),u5=Ln(d5),f5=p({},wt,{newState:0,oldState:0}),h5=Ln(f5),m5=[9,13,27,32],Eu=He&&"CompositionEvent"in window,Ml=null;He&&"documentMode"in document&&(Ml=document.documentMode);var x5=He&&"TextEvent"in window&&!Ml,Xx=He&&(!Eu||Ml&&8<Ml&&11>=Ml),Kx=" ",Wx=!1;function Qx(r,a){switch(r){case"keyup":return m5.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Zx(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var Ai=!1;function p5(r,a){switch(r){case"compositionend":return Zx(a);case"keypress":return a.which!==32?null:(Wx=!0,Kx);case"textInput":return r=a.data,r===Kx&&Wx?null:r;default:return null}}function g5(r,a){if(Ai)return r==="compositionend"||!Eu&&Qx(r,a)?(r=Gt(),jt=at=Xe=null,Ai=!1,r):null;switch(r){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 Xx&&a.locale!=="ko"?null:a.data;default:return null}}var b5={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 Jx(r){var a=r&&r.nodeName&&r.nodeName.toLowerCase();return a==="input"?!!b5[r.type]:a==="textarea"}function ep(r,a,o,u){mn?Q?Q.push(u):Q=[u]:mn=u,a=Jc(a,"onChange"),0<a.length&&(o=new Ot("onChange","change",null,o,u),r.push({event:o,listeners:a}))}var Rl=null,Ol=null;function y5(r){I0(r,0)}function uc(r){var a=_n(r);if(ha(a))return r}function tp(r,a){if(r==="change")return a}var np=!1;if(He){var Tu;if(He){var _u="oninput"in document;if(!_u){var rp=document.createElement("div");rp.setAttribute("oninput","return;"),_u=typeof rp.oninput=="function"}Tu=_u}else Tu=!1;np=Tu&&(!document.documentMode||9<document.documentMode)}function sp(){Rl&&(Rl.detachEvent("onpropertychange",ap),Ol=Rl=null)}function ap(r){if(r.propertyName==="value"&&uc(Ol)){var a=[];ep(a,Ol,r,sn(r)),Ge(y5,a)}}function v5(r,a,o){r==="focusin"?(sp(),Rl=a,Ol=o,Rl.attachEvent("onpropertychange",ap)):r==="focusout"&&sp()}function j5(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return uc(Ol)}function w5(r,a){if(r==="click")return uc(a)}function N5(r,a){if(r==="input"||r==="change")return uc(a)}function k5(r,a){return r===a&&(r!==0||1/r===1/a)||r!==r&&a!==a}var Vr=typeof Object.is=="function"?Object.is:k5;function Dl(r,a){if(Vr(r,a))return!0;if(typeof r!="object"||r===null||typeof a!="object"||a===null)return!1;var o=Object.keys(r),u=Object.keys(a);if(o.length!==u.length)return!1;for(u=0;u<o.length;u++){var b=o[u];if(!yt.call(a,b)||!Vr(r[b],a[b]))return!1}return!0}function ip(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function lp(r,a){var o=ip(r);r=0;for(var u;o;){if(o.nodeType===3){if(u=r+o.textContent.length,r<=a&&u>=a)return{node:o,offset:a-r};r=u}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=ip(o)}}function op(r,a){return r&&a?r===a?!0:r&&r.nodeType===3?!1:a&&a.nodeType===3?op(r,a.parentNode):"contains"in r?r.contains(a):r.compareDocumentPosition?!!(r.compareDocumentPosition(a)&16):!1:!1}function cp(r){r=r!=null&&r.ownerDocument!=null&&r.ownerDocument.defaultView!=null?r.ownerDocument.defaultView:window;for(var a=qr(r.document);a instanceof r.HTMLIFrameElement;){try{var o=typeof a.contentWindow.location.href=="string"}catch{o=!1}if(o)r=a.contentWindow;else break;a=qr(r.document)}return a}function Au(r){var a=r&&r.nodeName&&r.nodeName.toLowerCase();return a&&(a==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||a==="textarea"||r.contentEditable==="true")}var S5=He&&"documentMode"in document&&11>=document.documentMode,Mi=null,Mu=null,Ll=null,Ru=!1;function dp(r,a,o){var u=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Ru||Mi==null||Mi!==qr(u)||(u=Mi,"selectionStart"in u&&Au(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}),Ll&&Dl(Ll,u)||(Ll=u,u=Jc(Mu,"onSelect"),0<u.length&&(a=new Ot("onSelect","select",null,a,o),r.push({event:a,listeners:u}),a.target=Mi)))}function Qa(r,a){var o={};return o[r.toLowerCase()]=a.toLowerCase(),o["Webkit"+r]="webkit"+a,o["Moz"+r]="moz"+a,o}var Ri={animationend:Qa("Animation","AnimationEnd"),animationiteration:Qa("Animation","AnimationIteration"),animationstart:Qa("Animation","AnimationStart"),transitionrun:Qa("Transition","TransitionRun"),transitionstart:Qa("Transition","TransitionStart"),transitioncancel:Qa("Transition","TransitionCancel"),transitionend:Qa("Transition","TransitionEnd")},Ou={},up={};He&&(up=document.createElement("div").style,"AnimationEvent"in window||(delete Ri.animationend.animation,delete Ri.animationiteration.animation,delete Ri.animationstart.animation),"TransitionEvent"in window||delete Ri.transitionend.transition);function Za(r){if(Ou[r])return Ou[r];if(!Ri[r])return r;var a=Ri[r],o;for(o in a)if(a.hasOwnProperty(o)&&o in up)return Ou[r]=a[o];return r}var fp=Za("animationend"),hp=Za("animationiteration"),mp=Za("animationstart"),C5=Za("transitionrun"),E5=Za("transitionstart"),T5=Za("transitioncancel"),xp=Za("transitionend"),pp=new Map,Du="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(" ");Du.push("scrollEnd");function hs(r,a){pp.set(r,a),de(a,[r])}var fc=typeof reportError=="function"?reportError:function(r){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var a=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof r=="object"&&r!==null&&typeof r.message=="string"?String(r.message):String(r),error:r});if(!window.dispatchEvent(a))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",r);return}console.error(r)},ns=[],Oi=0,Lu=0;function hc(){for(var r=Oi,a=Lu=Oi=0;a<r;){var o=ns[a];ns[a++]=null;var u=ns[a];ns[a++]=null;var b=ns[a];ns[a++]=null;var j=ns[a];if(ns[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&&gp(o,b,j)}}function mc(r,a,o,u){ns[Oi++]=r,ns[Oi++]=a,ns[Oi++]=o,ns[Oi++]=u,Lu|=u,r.lanes|=u,r=r.alternate,r!==null&&(r.lanes|=u)}function Iu(r,a,o,u){return mc(r,a,o,u),xc(r)}function Ja(r,a){return mc(r,null,null,a),xc(r)}function gp(r,a,o){r.lanes|=o;var u=r.alternate;u!==null&&(u.lanes|=o);for(var b=!1,j=r.return;j!==null;)j.childLanes|=o,u=j.alternate,u!==null&&(u.childLanes|=o),j.tag===22&&(r=j.stateNode,r===null||r._visibility&1||(b=!0)),r=j,j=j.return;return r.tag===3?(j=r.stateNode,b&&a!==null&&(b=31-_t(o),r=j.hiddenUpdates,u=r[b],u===null?r[b]=[a]:u.push(a),a.lane=o|536870912),j):null}function xc(r){if(50<ro)throw ro=0,Yf=null,Error(i(185));for(var a=r.return;a!==null;)r=a,a=r.return;return r.tag===3?r.stateNode:null}var Di={};function _5(r,a,o,u){this.tag=r,this.key=o,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 Fr(r,a,o,u){return new _5(r,a,o,u)}function zu(r){return r=r.prototype,!(!r||!r.isReactComponent)}function qs(r,a){var o=r.alternate;return o===null?(o=Fr(r.tag,a,r.key,r.mode),o.elementType=r.elementType,o.type=r.type,o.stateNode=r.stateNode,o.alternate=r,r.alternate=o):(o.pendingProps=a,o.type=r.type,o.flags=0,o.subtreeFlags=0,o.deletions=null),o.flags=r.flags&65011712,o.childLanes=r.childLanes,o.lanes=r.lanes,o.child=r.child,o.memoizedProps=r.memoizedProps,o.memoizedState=r.memoizedState,o.updateQueue=r.updateQueue,a=r.dependencies,o.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext},o.sibling=r.sibling,o.index=r.index,o.ref=r.ref,o.refCleanup=r.refCleanup,o}function bp(r,a){r.flags&=65011714;var o=r.alternate;return o===null?(r.childLanes=0,r.lanes=a,r.child=null,r.subtreeFlags=0,r.memoizedProps=null,r.memoizedState=null,r.updateQueue=null,r.dependencies=null,r.stateNode=null):(r.childLanes=o.childLanes,r.lanes=o.lanes,r.child=o.child,r.subtreeFlags=0,r.deletions=null,r.memoizedProps=o.memoizedProps,r.memoizedState=o.memoizedState,r.updateQueue=o.updateQueue,r.type=o.type,a=o.dependencies,r.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext}),r}function pc(r,a,o,u,b,j){var P=0;if(u=r,typeof r=="function")zu(r)&&(P=1);else if(typeof r=="string")P=D2(r,o,S.current)?26:r==="html"||r==="head"||r==="body"?27:5;else e:switch(r){case K:return r=Fr(31,o,a,b),r.elementType=K,r.lanes=j,r;case N:return ei(o.children,b,j,a);case T:P=8,b|=24;break;case C:return r=Fr(12,o,a,b|2),r.elementType=C,r.lanes=j,r;case D:return r=Fr(13,o,a,b),r.elementType=D,r.lanes=j,r;case A:return r=Fr(19,o,a,b),r.elementType=A,r.lanes=j,r;default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case k:P=10;break e;case _:P=9;break e;case M:P=11;break e;case G:P=14;break e;case X:P=16,u=null;break e}P=29,o=Error(i(130,r===null?"null":typeof r,"")),u=null}return a=Fr(P,o,a,b),a.elementType=r,a.type=u,a.lanes=j,a}function ei(r,a,o,u){return r=Fr(7,r,u,a),r.lanes=o,r}function $u(r,a,o){return r=Fr(6,r,null,a),r.lanes=o,r}function yp(r){var a=Fr(18,null,null,0);return a.stateNode=r,a}function Bu(r,a,o){return a=Fr(4,r.children!==null?r.children:[],r.key,a),a.lanes=o,a.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},a}var vp=new WeakMap;function rs(r,a){if(typeof r=="object"&&r!==null){var o=vp.get(r);return o!==void 0?o:(a={value:r,source:a,stack:rt(a)},vp.set(r,a),a)}return{value:r,source:a,stack:rt(a)}}var Li=[],Ii=0,gc=null,Il=0,ss=[],as=0,pa=null,ks=1,Ss="";function Us(r,a){Li[Ii++]=Il,Li[Ii++]=gc,gc=r,Il=a}function jp(r,a,o){ss[as++]=ks,ss[as++]=Ss,ss[as++]=pa,pa=r;var u=ks;r=Ss;var b=32-_t(u)-1;u&=~(1<<b),o+=1;var j=32-_t(a)+b;if(30<j){var P=b-b%5;j=(u&(1<<P)-1).toString(32),u>>=P,b-=P,ks=1<<32-_t(a)+b|o<<b|u,Ss=j+r}else ks=1<<j|o<<b|u,Ss=r}function Hu(r){r.return!==null&&(Us(r,1),jp(r,1,0))}function Pu(r){for(;r===gc;)gc=Li[--Ii],Li[Ii]=null,Il=Li[--Ii],Li[Ii]=null;for(;r===pa;)pa=ss[--as],ss[as]=null,Ss=ss[--as],ss[as]=null,ks=ss[--as],ss[as]=null}function wp(r,a){ss[as++]=ks,ss[as++]=Ss,ss[as++]=pa,ks=a.id,Ss=a.overflow,pa=r}var ur=null,An=null,Qt=!1,ga=null,is=!1,qu=Error(i(519));function ba(r){var a=Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw zl(rs(a,r)),qu}function Np(r){var a=r.stateNode,o=r.type,u=r.memoizedProps;switch(a[qe]=r,a[Je]=u,o){case"dialog":Vt("cancel",a),Vt("close",a);break;case"iframe":case"object":case"embed":Vt("load",a);break;case"video":case"audio":for(o=0;o<ao.length;o++)Vt(ao[o],a);break;case"source":Vt("error",a);break;case"img":case"image":case"link":Vt("error",a),Vt("load",a);break;case"details":Vt("toggle",a);break;case"input":Vt("invalid",a),fs(a,u.value,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name,!0);break;case"select":Vt("invalid",a);break;case"textarea":Vt("invalid",a),_i(a,u.value,u.defaultValue,u.children)}o=u.children,typeof o!="string"&&typeof o!="number"&&typeof o!="bigint"||a.textContent===""+o||u.suppressHydrationWarning===!0||H0(a.textContent,o)?(u.popover!=null&&(Vt("beforetoggle",a),Vt("toggle",a)),u.onScroll!=null&&Vt("scroll",a),u.onScrollEnd!=null&&Vt("scrollend",a),u.onClick!=null&&(a.onclick=Ye),a=!0):a=!1,a||ba(r,!0)}function kp(r){for(ur=r.return;ur;)switch(ur.tag){case 5:case 31:case 13:is=!1;return;case 27:case 3:is=!0;return;default:ur=ur.return}}function zi(r){if(r!==ur)return!1;if(!Qt)return kp(r),Qt=!0,!1;var a=r.tag,o;if((o=a!==3&&a!==27)&&((o=a===5)&&(o=r.type,o=!(o!=="form"&&o!=="button")||lh(r.type,r.memoizedProps)),o=!o),o&&An&&ba(r),kp(r),a===13){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(i(317));An=K0(r)}else if(a===31){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(i(317));An=K0(r)}else a===27?(a=An,Ra(r.type)?(r=fh,fh=null,An=r):An=a):An=ur?os(r.stateNode.nextSibling):null;return!0}function ti(){An=ur=null,Qt=!1}function Uu(){var r=ga;return r!==null&&(Or===null?Or=r:Or.push.apply(Or,r),ga=null),r}function zl(r){ga===null?ga=[r]:ga.push(r)}var Vu=O(null),ni=null,Vs=null;function ya(r,a,o){I(Vu,a._currentValue),a._currentValue=o}function Fs(r){r._currentValue=Vu.current,V(Vu)}function Fu(r,a,o){for(;r!==null;){var u=r.alternate;if((r.childLanes&a)!==a?(r.childLanes|=a,u!==null&&(u.childLanes|=a)):u!==null&&(u.childLanes&a)!==a&&(u.childLanes|=a),r===o)break;r=r.return}}function Yu(r,a,o,u){var b=r.child;for(b!==null&&(b.return=r);b!==null;){var j=b.dependencies;if(j!==null){var P=b.child;j=j.firstContext;e:for(;j!==null;){var J=j;j=b;for(var ie=0;ie<a.length;ie++)if(J.context===a[ie]){j.lanes|=o,J=j.alternate,J!==null&&(J.lanes|=o),Fu(j.return,o,r),u||(P=null);break e}j=J.next}}else if(b.tag===18){if(P=b.return,P===null)throw Error(i(341));P.lanes|=o,j=P.alternate,j!==null&&(j.lanes|=o),Fu(P,o,r),P=null}else P=b.child;if(P!==null)P.return=b;else for(P=b;P!==null;){if(P===r){P=null;break}if(b=P.sibling,b!==null){b.return=P.return,P=b;break}P=P.return}b=P}}function $i(r,a,o,u){r=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(i(387));if(P=P.memoizedProps,P!==null){var J=b.type;Vr(b.pendingProps.value,P.value)||(r!==null?r.push(J):r=[J])}}else if(b===ee.current){if(P=b.alternate,P===null)throw Error(i(387));P.memoizedState.memoizedState!==b.memoizedState.memoizedState&&(r!==null?r.push(uo):r=[uo])}b=b.return}r!==null&&Yu(a,r,o,u),a.flags|=262144}function bc(r){for(r=r.firstContext;r!==null;){if(!Vr(r.context._currentValue,r.memoizedValue))return!0;r=r.next}return!1}function ri(r){ni=r,Vs=null,r=r.dependencies,r!==null&&(r.firstContext=null)}function fr(r){return Sp(ni,r)}function yc(r,a){return ni===null&&ri(r),Sp(r,a)}function Sp(r,a){var o=a._currentValue;if(a={context:a,memoizedValue:o,next:null},Vs===null){if(r===null)throw Error(i(308));Vs=a,r.dependencies={lanes:0,firstContext:a},r.flags|=524288}else Vs=Vs.next=a;return o}var A5=typeof AbortController<"u"?AbortController:function(){var r=[],a=this.signal={aborted:!1,addEventListener:function(o,u){r.push(u)}};this.abort=function(){a.aborted=!0,r.forEach(function(o){return o()})}},M5=e.unstable_scheduleCallback,R5=e.unstable_NormalPriority,Gn={$$typeof:k,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Gu(){return{controller:new A5,data:new Map,refCount:0}}function $l(r){r.refCount--,r.refCount===0&&M5(R5,function(){r.controller.abort()})}var Bl=null,Xu=0,Bi=0,Hi=null;function O5(r,a){if(Bl===null){var o=Bl=[];Xu=0,Bi=Zf(),Hi={status:"pending",value:void 0,then:function(u){o.push(u)}}}return Xu++,a.then(Cp,Cp),a}function Cp(){if(--Xu===0&&Bl!==null){Hi!==null&&(Hi.status="fulfilled");var r=Bl;Bl=null,Bi=0,Hi=null;for(var a=0;a<r.length;a++)(0,r[a])()}}function D5(r,a){var o=[],u={status:"pending",value:null,reason:null,then:function(b){o.push(b)}};return r.then(function(){u.status="fulfilled",u.value=a;for(var b=0;b<o.length;b++)(0,o[b])(a)},function(b){for(u.status="rejected",u.reason=b,b=0;b<o.length;b++)(0,o[b])(void 0)}),u}var Ep=R.S;R.S=function(r,a){d0=dt(),typeof a=="object"&&a!==null&&typeof a.then=="function"&&O5(r,a),Ep!==null&&Ep(r,a)};var si=O(null);function Ku(){var r=si.current;return r!==null?r:kn.pooledCache}function vc(r,a){a===null?I(si,si.current):I(si,a.pool)}function Tp(){var r=Ku();return r===null?null:{parent:Gn._currentValue,pool:r}}var Pi=Error(i(460)),Wu=Error(i(474)),jc=Error(i(542)),wc={then:function(){}};function _p(r){return r=r.status,r==="fulfilled"||r==="rejected"}function Ap(r,a,o){switch(o=r[o],o===void 0?r.push(a):o!==a&&(a.then(Ye,Ye),a=o),a.status){case"fulfilled":return a.value;case"rejected":throw r=a.reason,Rp(r),r;default:if(typeof a.status=="string")a.then(Ye,Ye);else{if(r=kn,r!==null&&100<r.shellSuspendCounter)throw Error(i(482));r=a,r.status="pending",r.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 r=a.reason,Rp(r),r}throw ii=a,Pi}}function ai(r){try{var a=r._init;return a(r._payload)}catch(o){throw o!==null&&typeof o=="object"&&typeof o.then=="function"?(ii=o,Pi):o}}var ii=null;function Mp(){if(ii===null)throw Error(i(459));var r=ii;return ii=null,r}function Rp(r){if(r===Pi||r===jc)throw Error(i(483))}var qi=null,Hl=0;function Nc(r){var a=Hl;return Hl+=1,qi===null&&(qi=[]),Ap(qi,r,a)}function Pl(r,a){a=a.props.ref,r.ref=a!==void 0?a:null}function kc(r,a){throw a.$$typeof===g?Error(i(525)):(r=Object.prototype.toString.call(a),Error(i(31,r==="[object Object]"?"object with keys {"+Object.keys(a).join(", ")+"}":r)))}function Op(r){function a(ue,ce){if(r){var pe=ue.deletions;pe===null?(ue.deletions=[ce],ue.flags|=16):pe.push(ce)}}function o(ue,ce){if(!r)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=qs(ue,ce),ue.index=0,ue.sibling=null,ue}function j(ue,ce,pe){return ue.index=pe,r?(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 r&&ue.alternate===null&&(ue.flags|=67108866),ue}function J(ue,ce,pe,Me){return ce===null||ce.tag!==6?(ce=$u(pe,ue.mode,Me),ce.return=ue,ce):(ce=b(ce,pe),ce.return=ue,ce)}function ie(ue,ce,pe,Me){var bt=pe.type;return bt===N?Ee(ue,ce,pe.props.children,Me,pe.key):ce!==null&&(ce.elementType===bt||typeof bt=="object"&&bt!==null&&bt.$$typeof===X&&ai(bt)===ce.type)?(ce=b(ce,pe.props),Pl(ce,pe),ce.return=ue,ce):(ce=pc(pe.type,pe.key,pe.props,null,ue.mode,Me),Pl(ce,pe),ce.return=ue,ce)}function ge(ue,ce,pe,Me){return ce===null||ce.tag!==4||ce.stateNode.containerInfo!==pe.containerInfo||ce.stateNode.implementation!==pe.implementation?(ce=Bu(pe,ue.mode,Me),ce.return=ue,ce):(ce=b(ce,pe.children||[]),ce.return=ue,ce)}function Ee(ue,ce,pe,Me,bt){return ce===null||ce.tag!==7?(ce=ei(pe,ue.mode,Me,bt),ce.return=ue,ce):(ce=b(ce,pe),ce.return=ue,ce)}function Oe(ue,ce,pe){if(typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint")return ce=$u(""+ce,ue.mode,pe),ce.return=ue,ce;if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case y:return pe=pc(ce.type,ce.key,ce.props,null,ue.mode,pe),Pl(pe,ce),pe.return=ue,pe;case w:return ce=Bu(ce,ue.mode,pe),ce.return=ue,ce;case X:return ce=ai(ce),Oe(ue,ce,pe)}if(L(ce)||U(ce))return ce=ei(ce,ue.mode,pe,null),ce.return=ue,ce;if(typeof ce.then=="function")return Oe(ue,Nc(ce),pe);if(ce.$$typeof===k)return Oe(ue,yc(ue,ce),pe);kc(ue,ce)}return null}function ve(ue,ce,pe,Me){var bt=ce!==null?ce.key:null;if(typeof pe=="string"&&pe!==""||typeof pe=="number"||typeof pe=="bigint")return bt!==null?null:J(ue,ce,""+pe,Me);if(typeof pe=="object"&&pe!==null){switch(pe.$$typeof){case y:return pe.key===bt?ie(ue,ce,pe,Me):null;case w:return pe.key===bt?ge(ue,ce,pe,Me):null;case X:return pe=ai(pe),ve(ue,ce,pe,Me)}if(L(pe)||U(pe))return bt!==null?null:Ee(ue,ce,pe,Me,null);if(typeof pe.then=="function")return ve(ue,ce,Nc(pe),Me);if(pe.$$typeof===k)return ve(ue,ce,yc(ue,pe),Me);kc(ue,pe)}return null}function we(ue,ce,pe,Me,bt){if(typeof Me=="string"&&Me!==""||typeof Me=="number"||typeof Me=="bigint")return ue=ue.get(pe)||null,J(ce,ue,""+Me,bt);if(typeof Me=="object"&&Me!==null){switch(Me.$$typeof){case y:return ue=ue.get(Me.key===null?pe:Me.key)||null,ie(ce,ue,Me,bt);case w:return ue=ue.get(Me.key===null?pe:Me.key)||null,ge(ce,ue,Me,bt);case X:return Me=ai(Me),we(ue,ce,pe,Me,bt)}if(L(Me)||U(Me))return ue=ue.get(pe)||null,Ee(ce,ue,Me,bt,null);if(typeof Me.then=="function")return we(ue,ce,pe,Nc(Me),bt);if(Me.$$typeof===k)return we(ue,ce,pe,yc(ce,Me),bt);kc(ce,Me)}return null}function tt(ue,ce,pe,Me){for(var bt=null,ln=null,ot=ce,zt=ce=0,Kt=null;ot!==null&&zt<pe.length;zt++){ot.index>zt?(Kt=ot,ot=null):Kt=ot.sibling;var on=ve(ue,ot,pe[zt],Me);if(on===null){ot===null&&(ot=Kt);break}r&&ot&&on.alternate===null&&a(ue,ot),ce=j(on,ce,zt),ln===null?bt=on:ln.sibling=on,ln=on,ot=Kt}if(zt===pe.length)return o(ue,ot),Qt&&Us(ue,zt),bt;if(ot===null){for(;zt<pe.length;zt++)ot=Oe(ue,pe[zt],Me),ot!==null&&(ce=j(ot,ce,zt),ln===null?bt=ot:ln.sibling=ot,ln=ot);return Qt&&Us(ue,zt),bt}for(ot=u(ot);zt<pe.length;zt++)Kt=we(ot,ue,zt,pe[zt],Me),Kt!==null&&(r&&Kt.alternate!==null&&ot.delete(Kt.key===null?zt:Kt.key),ce=j(Kt,ce,zt),ln===null?bt=Kt:ln.sibling=Kt,ln=Kt);return r&&ot.forEach(function(za){return a(ue,za)}),Qt&&Us(ue,zt),bt}function Ct(ue,ce,pe,Me){if(pe==null)throw Error(i(151));for(var bt=null,ln=null,ot=ce,zt=ce=0,Kt=null,on=pe.next();ot!==null&&!on.done;zt++,on=pe.next()){ot.index>zt?(Kt=ot,ot=null):Kt=ot.sibling;var za=ve(ue,ot,on.value,Me);if(za===null){ot===null&&(ot=Kt);break}r&&ot&&za.alternate===null&&a(ue,ot),ce=j(za,ce,zt),ln===null?bt=za:ln.sibling=za,ln=za,ot=Kt}if(on.done)return o(ue,ot),Qt&&Us(ue,zt),bt;if(ot===null){for(;!on.done;zt++,on=pe.next())on=Oe(ue,on.value,Me),on!==null&&(ce=j(on,ce,zt),ln===null?bt=on:ln.sibling=on,ln=on);return Qt&&Us(ue,zt),bt}for(ot=u(ot);!on.done;zt++,on=pe.next())on=we(ot,ue,zt,on.value,Me),on!==null&&(r&&on.alternate!==null&&ot.delete(on.key===null?zt:on.key),ce=j(on,ce,zt),ln===null?bt=on:ln.sibling=on,ln=on);return r&&ot.forEach(function(F2){return a(ue,F2)}),Qt&&Us(ue,zt),bt}function wn(ue,ce,pe,Me){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 bt=pe.key;ce!==null;){if(ce.key===bt){if(bt=pe.type,bt===N){if(ce.tag===7){o(ue,ce.sibling),Me=b(ce,pe.props.children),Me.return=ue,ue=Me;break e}}else if(ce.elementType===bt||typeof bt=="object"&&bt!==null&&bt.$$typeof===X&&ai(bt)===ce.type){o(ue,ce.sibling),Me=b(ce,pe.props),Pl(Me,pe),Me.return=ue,ue=Me;break e}o(ue,ce);break}else a(ue,ce);ce=ce.sibling}pe.type===N?(Me=ei(pe.props.children,ue.mode,Me,pe.key),Me.return=ue,ue=Me):(Me=pc(pe.type,pe.key,pe.props,null,ue.mode,Me),Pl(Me,pe),Me.return=ue,ue=Me)}return P(ue);case w:e:{for(bt=pe.key;ce!==null;){if(ce.key===bt)if(ce.tag===4&&ce.stateNode.containerInfo===pe.containerInfo&&ce.stateNode.implementation===pe.implementation){o(ue,ce.sibling),Me=b(ce,pe.children||[]),Me.return=ue,ue=Me;break e}else{o(ue,ce);break}else a(ue,ce);ce=ce.sibling}Me=Bu(pe,ue.mode,Me),Me.return=ue,ue=Me}return P(ue);case X:return pe=ai(pe),wn(ue,ce,pe,Me)}if(L(pe))return tt(ue,ce,pe,Me);if(U(pe)){if(bt=U(pe),typeof bt!="function")throw Error(i(150));return pe=bt.call(pe),Ct(ue,ce,pe,Me)}if(typeof pe.then=="function")return wn(ue,ce,Nc(pe),Me);if(pe.$$typeof===k)return wn(ue,ce,yc(ue,pe),Me);kc(ue,pe)}return typeof pe=="string"&&pe!==""||typeof pe=="number"||typeof pe=="bigint"?(pe=""+pe,ce!==null&&ce.tag===6?(o(ue,ce.sibling),Me=b(ce,pe),Me.return=ue,ue=Me):(o(ue,ce),Me=$u(pe,ue.mode,Me),Me.return=ue,ue=Me),P(ue)):o(ue,ce)}return function(ue,ce,pe,Me){try{Hl=0;var bt=wn(ue,ce,pe,Me);return qi=null,bt}catch(ot){if(ot===Pi||ot===jc)throw ot;var ln=Fr(29,ot,null,ue.mode);return ln.lanes=Me,ln.return=ue,ln}}}var li=Op(!0),Dp=Op(!1),va=!1;function Qu(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Zu(r,a){r=r.updateQueue,a.updateQueue===r&&(a.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,callbacks:null})}function ja(r){return{lane:r,tag:0,payload:null,callback:null,next:null}}function wa(r,a,o){var u=r.updateQueue;if(u===null)return null;if(u=u.shared,(fn&2)!==0){var b=u.pending;return b===null?a.next=a:(a.next=b.next,b.next=a),u.pending=a,a=xc(r),gp(r,null,o),a}return mc(r,u,a,o),xc(r)}function ql(r,a,o){if(a=a.updateQueue,a!==null&&(a=a.shared,(o&4194048)!==0)){var u=a.lanes;u&=r.pendingLanes,o|=u,a.lanes=o,hn(r,o)}}function Ju(r,a){var o=r.updateQueue,u=r.alternate;if(u!==null&&(u=u.updateQueue,o===u)){var b=null,j=null;if(o=o.firstBaseUpdate,o!==null){do{var P={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};j===null?b=j=P:j=j.next=P,o=o.next}while(o!==null);j===null?b=j=a:j=j.next=a}else b=j=a;o={baseState:u.baseState,firstBaseUpdate:b,lastBaseUpdate:j,shared:u.shared,callbacks:u.callbacks},r.updateQueue=o;return}r=o.lastBaseUpdate,r===null?o.firstBaseUpdate=a:r.next=a,o.lastBaseUpdate=a}var ef=!1;function Ul(){if(ef){var r=Hi;if(r!==null)throw r}}function Vl(r,a,o,u){ef=!1;var b=r.updateQueue;va=!1;var j=b.firstBaseUpdate,P=b.lastBaseUpdate,J=b.shared.pending;if(J!==null){b.shared.pending=null;var ie=J,ge=ie.next;ie.next=null,P===null?j=ge:P.next=ge,P=ie;var Ee=r.alternate;Ee!==null&&(Ee=Ee.updateQueue,J=Ee.lastBaseUpdate,J!==P&&(J===null?Ee.firstBaseUpdate=ge:J.next=ge,Ee.lastBaseUpdate=ie))}if(j!==null){var Oe=b.baseState;P=0,Ee=ge=ie=null,J=j;do{var ve=J.lane&-536870913,we=ve!==J.lane;if(we?(Xt&ve)===ve:(u&ve)===ve){ve!==0&&ve===Bi&&(ef=!0),Ee!==null&&(Ee=Ee.next={lane:0,tag:J.tag,payload:J.payload,callback:null,next:null});e:{var tt=r,Ct=J;ve=a;var wn=o;switch(Ct.tag){case 1:if(tt=Ct.payload,typeof tt=="function"){Oe=tt.call(wn,Oe,ve);break e}Oe=tt;break e;case 3:tt.flags=tt.flags&-65537|128;case 0:if(tt=Ct.payload,ve=typeof tt=="function"?tt.call(wn,Oe,ve):tt,ve==null)break e;Oe=p({},Oe,ve);break e;case 2:va=!0}}ve=J.callback,ve!==null&&(r.flags|=64,we&&(r.flags|=8192),we=b.callbacks,we===null?b.callbacks=[ve]:we.push(ve))}else we={lane:ve,tag:J.tag,payload:J.payload,callback:J.callback,next:null},Ee===null?(ge=Ee=we,ie=Oe):Ee=Ee.next=we,P|=ve;if(J=J.next,J===null){if(J=b.shared.pending,J===null)break;we=J,J=we.next,we.next=null,b.lastBaseUpdate=we,b.shared.pending=null}}while(!0);Ee===null&&(ie=Oe),b.baseState=ie,b.firstBaseUpdate=ge,b.lastBaseUpdate=Ee,j===null&&(b.shared.lanes=0),Ea|=P,r.lanes=P,r.memoizedState=Oe}}function Lp(r,a){if(typeof r!="function")throw Error(i(191,r));r.call(a)}function Ip(r,a){var o=r.callbacks;if(o!==null)for(r.callbacks=null,r=0;r<o.length;r++)Lp(o[r],a)}var Ui=O(null),Sc=O(0);function zp(r,a){r=ea,I(Sc,r),I(Ui,a),ea=r|a.baseLanes}function tf(){I(Sc,ea),I(Ui,Ui.current)}function nf(){ea=Sc.current,V(Ui),V(Sc)}var Yr=O(null),ls=null;function Na(r){var a=r.alternate;I(Un,Un.current&1),I(Yr,r),ls===null&&(a===null||Ui.current!==null||a.memoizedState!==null)&&(ls=r)}function rf(r){I(Un,Un.current),I(Yr,r),ls===null&&(ls=r)}function $p(r){r.tag===22?(I(Un,Un.current),I(Yr,r),ls===null&&(ls=r)):ka()}function ka(){I(Un,Un.current),I(Yr,Yr.current)}function Gr(r){V(Yr),ls===r&&(ls=null),V(Un)}var Un=O(0);function Cc(r){for(var a=r;a!==null;){if(a.tag===13){var o=a.memoizedState;if(o!==null&&(o=o.dehydrated,o===null||dh(o)||uh(o)))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===r)break;for(;a.sibling===null;){if(a.return===null||a.return===r)return null;a=a.return}a.sibling.return=a.return,a=a.sibling}return null}var Ys=0,Lt=null,vn=null,Xn=null,Ec=!1,Vi=!1,oi=!1,Tc=0,Fl=0,Fi=null,L5=0;function Pn(){throw Error(i(321))}function sf(r,a){if(a===null)return!1;for(var o=0;o<a.length&&o<r.length;o++)if(!Vr(r[o],a[o]))return!1;return!0}function af(r,a,o,u,b,j){return Ys=j,Lt=a,a.memoizedState=null,a.updateQueue=null,a.lanes=0,R.H=r===null||r.memoizedState===null?jg:jf,oi=!1,j=o(u,b),oi=!1,Vi&&(j=Hp(a,o,u,b)),Bp(r),j}function Bp(r){R.H=Xl;var a=vn!==null&&vn.next!==null;if(Ys=0,Xn=vn=Lt=null,Ec=!1,Fl=0,Fi=null,a)throw Error(i(300));r===null||Kn||(r=r.dependencies,r!==null&&bc(r)&&(Kn=!0))}function Hp(r,a,o,u){Lt=r;var b=0;do{if(Vi&&(Fi=null),Fl=0,Vi=!1,25<=b)throw Error(i(301));if(b+=1,Xn=vn=null,r.updateQueue!=null){var j=r.updateQueue;j.lastEffect=null,j.events=null,j.stores=null,j.memoCache!=null&&(j.memoCache.index=0)}R.H=wg,j=a(o,u)}while(Vi);return j}function I5(){var r=R.H,a=r.useState()[0];return a=typeof a.then=="function"?Yl(a):a,r=r.useState()[0],(vn!==null?vn.memoizedState:null)!==r&&(Lt.flags|=1024),a}function lf(){var r=Tc!==0;return Tc=0,r}function of(r,a,o){a.updateQueue=r.updateQueue,a.flags&=-2053,r.lanes&=~o}function cf(r){if(Ec){for(r=r.memoizedState;r!==null;){var a=r.queue;a!==null&&(a.pending=null),r=r.next}Ec=!1}Ys=0,Xn=vn=Lt=null,Vi=!1,Fl=Tc=0,Fi=null}function jr(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Xn===null?Lt.memoizedState=Xn=r:Xn=Xn.next=r,Xn}function Vn(){if(vn===null){var r=Lt.alternate;r=r!==null?r.memoizedState:null}else r=vn.next;var a=Xn===null?Lt.memoizedState:Xn.next;if(a!==null)Xn=a,vn=r;else{if(r===null)throw Lt.alternate===null?Error(i(467)):Error(i(310));vn=r,r={memoizedState:vn.memoizedState,baseState:vn.baseState,baseQueue:vn.baseQueue,queue:vn.queue,next:null},Xn===null?Lt.memoizedState=Xn=r:Xn=Xn.next=r}return Xn}function _c(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Yl(r){var a=Fl;return Fl+=1,Fi===null&&(Fi=[]),r=Ap(Fi,r,a),a=Lt,(Xn===null?a.memoizedState:Xn.next)===null&&(a=a.alternate,R.H=a===null||a.memoizedState===null?jg:jf),r}function Ac(r){if(r!==null&&typeof r=="object"){if(typeof r.then=="function")return Yl(r);if(r.$$typeof===k)return fr(r)}throw Error(i(438,String(r)))}function df(r){var a=null,o=Lt.updateQueue;if(o!==null&&(a=o.memoCache),a==null){var u=Lt.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}),o===null&&(o=_c(),Lt.updateQueue=o),o.memoCache=a,o=a.data[a.index],o===void 0)for(o=a.data[a.index]=Array(r),u=0;u<r;u++)o[u]=$;return a.index++,o}function Gs(r,a){return typeof a=="function"?a(r):a}function Mc(r){var a=Vn();return uf(a,vn,r)}function uf(r,a,o){var u=r.queue;if(u===null)throw Error(i(311));u.lastRenderedReducer=o;var b=r.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=r.baseState,b===null)r.memoizedState=j;else{a=b.next;var J=P=null,ie=null,ge=a,Ee=!1;do{var Oe=ge.lane&-536870913;if(Oe!==ge.lane?(Xt&Oe)===Oe:(Ys&Oe)===Oe){var ve=ge.revertLane;if(ve===0)ie!==null&&(ie=ie.next={lane:0,revertLane:0,gesture:null,action:ge.action,hasEagerState:ge.hasEagerState,eagerState:ge.eagerState,next:null}),Oe===Bi&&(Ee=!0);else if((Ys&ve)===ve){ge=ge.next,ve===Bi&&(Ee=!0);continue}else Oe={lane:0,revertLane:ge.revertLane,gesture:null,action:ge.action,hasEagerState:ge.hasEagerState,eagerState:ge.eagerState,next:null},ie===null?(J=ie=Oe,P=j):ie=ie.next=Oe,Lt.lanes|=ve,Ea|=ve;Oe=ge.action,oi&&o(j,Oe),j=ge.hasEagerState?ge.eagerState:o(j,Oe)}else ve={lane:Oe,revertLane:ge.revertLane,gesture:ge.gesture,action:ge.action,hasEagerState:ge.hasEagerState,eagerState:ge.eagerState,next:null},ie===null?(J=ie=ve,P=j):ie=ie.next=ve,Lt.lanes|=Oe,Ea|=Oe;ge=ge.next}while(ge!==null&&ge!==a);if(ie===null?P=j:ie.next=J,!Vr(j,r.memoizedState)&&(Kn=!0,Ee&&(o=Hi,o!==null)))throw o;r.memoizedState=j,r.baseState=P,r.baseQueue=ie,u.lastRenderedState=j}return b===null&&(u.lanes=0),[r.memoizedState,u.dispatch]}function ff(r){var a=Vn(),o=a.queue;if(o===null)throw Error(i(311));o.lastRenderedReducer=r;var u=o.dispatch,b=o.pending,j=a.memoizedState;if(b!==null){o.pending=null;var P=b=b.next;do j=r(j,P.action),P=P.next;while(P!==b);Vr(j,a.memoizedState)||(Kn=!0),a.memoizedState=j,a.baseQueue===null&&(a.baseState=j),o.lastRenderedState=j}return[j,u]}function Pp(r,a,o){var u=Lt,b=Vn(),j=Qt;if(j){if(o===void 0)throw Error(i(407));o=o()}else o=a();var P=!Vr((vn||b).memoizedState,o);if(P&&(b.memoizedState=o,Kn=!0),b=b.queue,xf(Vp.bind(null,u,b,r),[r]),b.getSnapshot!==a||P||Xn!==null&&Xn.memoizedState.tag&1){if(u.flags|=2048,Yi(9,{destroy:void 0},Up.bind(null,u,b,o,a),null),kn===null)throw Error(i(349));j||(Ys&127)!==0||qp(u,a,o)}return o}function qp(r,a,o){r.flags|=16384,r={getSnapshot:a,value:o},a=Lt.updateQueue,a===null?(a=_c(),Lt.updateQueue=a,a.stores=[r]):(o=a.stores,o===null?a.stores=[r]:o.push(r))}function Up(r,a,o,u){a.value=o,a.getSnapshot=u,Fp(a)&&Yp(r)}function Vp(r,a,o){return o(function(){Fp(a)&&Yp(r)})}function Fp(r){var a=r.getSnapshot;r=r.value;try{var o=a();return!Vr(r,o)}catch{return!0}}function Yp(r){var a=Ja(r,2);a!==null&&Dr(a,r,2)}function hf(r){var a=jr();if(typeof r=="function"){var o=r;if(r=o(),oi){Bt(!0);try{o()}finally{Bt(!1)}}}return a.memoizedState=a.baseState=r,a.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Gs,lastRenderedState:r},a}function Gp(r,a,o,u){return r.baseState=o,uf(r,vn,typeof u=="function"?u:Gs)}function z5(r,a,o,u,b){if(Dc(r))throw Error(i(485));if(r=a.action,r!==null){var j={payload:b,action:r,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(P){j.listeners.push(P)}};R.T!==null?o(!0):j.isTransition=!1,u(j),o=a.pending,o===null?(j.next=a.pending=j,Xp(a,j)):(j.next=o.next,a.pending=o.next=j)}}function Xp(r,a){var o=a.action,u=a.payload,b=r.state;if(a.isTransition){var j=R.T,P={};R.T=P;try{var J=o(b,u),ie=R.S;ie!==null&&ie(P,J),Kp(r,a,J)}catch(ge){mf(r,a,ge)}finally{j!==null&&P.types!==null&&(j.types=P.types),R.T=j}}else try{j=o(b,u),Kp(r,a,j)}catch(ge){mf(r,a,ge)}}function Kp(r,a,o){o!==null&&typeof o=="object"&&typeof o.then=="function"?o.then(function(u){Wp(r,a,u)},function(u){return mf(r,a,u)}):Wp(r,a,o)}function Wp(r,a,o){a.status="fulfilled",a.value=o,Qp(a),r.state=o,a=r.pending,a!==null&&(o=a.next,o===a?r.pending=null:(o=o.next,a.next=o,Xp(r,o)))}function mf(r,a,o){var u=r.pending;if(r.pending=null,u!==null){u=u.next;do a.status="rejected",a.reason=o,Qp(a),a=a.next;while(a!==u)}r.action=null}function Qp(r){r=r.listeners;for(var a=0;a<r.length;a++)(0,r[a])()}function Zp(r,a){return a}function Jp(r,a){if(Qt){var o=kn.formState;if(o!==null){e:{var u=Lt;if(Qt){if(An){t:{for(var b=An,j=is;b.nodeType!==8;){if(!j){b=null;break t}if(b=os(b.nextSibling),b===null){b=null;break t}}j=b.data,b=j==="F!"||j==="F"?b:null}if(b){An=os(b.nextSibling),u=b.data==="F!";break e}}ba(u)}u=!1}u&&(a=o[0])}}return o=jr(),o.memoizedState=o.baseState=a,u={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Zp,lastRenderedState:a},o.queue=u,o=bg.bind(null,Lt,u),u.dispatch=o,u=hf(!1),j=vf.bind(null,Lt,!1,u.queue),u=jr(),b={state:a,dispatch:null,action:r,pending:null},u.queue=b,o=z5.bind(null,Lt,b,j,o),b.dispatch=o,u.memoizedState=r,[a,o,!1]}function eg(r){var a=Vn();return tg(a,vn,r)}function tg(r,a,o){if(a=uf(r,a,Zp)[0],r=Mc(Gs)[0],typeof a=="object"&&a!==null&&typeof a.then=="function")try{var u=Yl(a)}catch(P){throw P===Pi?jc:P}else u=a;a=Vn();var b=a.queue,j=b.dispatch;return o!==a.memoizedState&&(Lt.flags|=2048,Yi(9,{destroy:void 0},$5.bind(null,b,o),null)),[u,j,r]}function $5(r,a){r.action=a}function ng(r){var a=Vn(),o=vn;if(o!==null)return tg(a,o,r);Vn(),a=a.memoizedState,o=Vn();var u=o.queue.dispatch;return o.memoizedState=r,[a,u,!1]}function Yi(r,a,o,u){return r={tag:r,create:o,deps:u,inst:a,next:null},a=Lt.updateQueue,a===null&&(a=_c(),Lt.updateQueue=a),o=a.lastEffect,o===null?a.lastEffect=r.next=r:(u=o.next,o.next=r,r.next=u,a.lastEffect=r),r}function rg(){return Vn().memoizedState}function Rc(r,a,o,u){var b=jr();Lt.flags|=r,b.memoizedState=Yi(1|a,{destroy:void 0},o,u===void 0?null:u)}function Oc(r,a,o,u){var b=Vn();u=u===void 0?null:u;var j=b.memoizedState.inst;vn!==null&&u!==null&&sf(u,vn.memoizedState.deps)?b.memoizedState=Yi(a,j,o,u):(Lt.flags|=r,b.memoizedState=Yi(1|a,j,o,u))}function sg(r,a){Rc(8390656,8,r,a)}function xf(r,a){Oc(2048,8,r,a)}function B5(r){Lt.flags|=4;var a=Lt.updateQueue;if(a===null)a=_c(),Lt.updateQueue=a,a.events=[r];else{var o=a.events;o===null?a.events=[r]:o.push(r)}}function ag(r){var a=Vn().memoizedState;return B5({ref:a,nextImpl:r}),function(){if((fn&2)!==0)throw Error(i(440));return a.impl.apply(void 0,arguments)}}function ig(r,a){return Oc(4,2,r,a)}function lg(r,a){return Oc(4,4,r,a)}function og(r,a){if(typeof a=="function"){r=r();var o=a(r);return function(){typeof o=="function"?o():a(null)}}if(a!=null)return r=r(),a.current=r,function(){a.current=null}}function cg(r,a,o){o=o!=null?o.concat([r]):null,Oc(4,4,og.bind(null,a,r),o)}function pf(){}function dg(r,a){var o=Vn();a=a===void 0?null:a;var u=o.memoizedState;return a!==null&&sf(a,u[1])?u[0]:(o.memoizedState=[r,a],r)}function ug(r,a){var o=Vn();a=a===void 0?null:a;var u=o.memoizedState;if(a!==null&&sf(a,u[1]))return u[0];if(u=r(),oi){Bt(!0);try{r()}finally{Bt(!1)}}return o.memoizedState=[u,a],u}function gf(r,a,o){return o===void 0||(Ys&1073741824)!==0&&(Xt&261930)===0?r.memoizedState=a:(r.memoizedState=o,r=f0(),Lt.lanes|=r,Ea|=r,o)}function fg(r,a,o,u){return Vr(o,a)?o:Ui.current!==null?(r=gf(r,o,u),Vr(r,a)||(Kn=!0),r):(Ys&42)===0||(Ys&1073741824)!==0&&(Xt&261930)===0?(Kn=!0,r.memoizedState=o):(r=f0(),Lt.lanes|=r,Ea|=r,a)}function hg(r,a,o,u,b){var j=F.p;F.p=j!==0&&8>j?j:8;var P=R.T,J={};R.T=J,vf(r,!1,a,o);try{var ie=b(),ge=R.S;if(ge!==null&&ge(J,ie),ie!==null&&typeof ie=="object"&&typeof ie.then=="function"){var Ee=D5(ie,u);Gl(r,a,Ee,Wr(r))}else Gl(r,a,u,Wr(r))}catch(Oe){Gl(r,a,{then:function(){},status:"rejected",reason:Oe},Wr())}finally{F.p=j,P!==null&&J.types!==null&&(P.types=J.types),R.T=P}}function H5(){}function bf(r,a,o,u){if(r.tag!==5)throw Error(i(476));var b=mg(r).queue;hg(r,b,a,Y,o===null?H5:function(){return xg(r),o(u)})}function mg(r){var a=r.memoizedState;if(a!==null)return a;a={memoizedState:Y,baseState:Y,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Gs,lastRenderedState:Y},next:null};var o={};return a.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Gs,lastRenderedState:o},next:null},r.memoizedState=a,r=r.alternate,r!==null&&(r.memoizedState=a),a}function xg(r){var a=mg(r);a.next===null&&(a=r.alternate.memoizedState),Gl(r,a.next.queue,{},Wr())}function yf(){return fr(uo)}function pg(){return Vn().memoizedState}function gg(){return Vn().memoizedState}function P5(r){for(var a=r.return;a!==null;){switch(a.tag){case 24:case 3:var o=Wr();r=ja(o);var u=wa(a,r,o);u!==null&&(Dr(u,a,o),ql(u,a,o)),a={cache:Gu()},r.payload=a;return}a=a.return}}function q5(r,a,o){var u=Wr();o={lane:u,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Dc(r)?yg(a,o):(o=Iu(r,a,o,u),o!==null&&(Dr(o,r,u),vg(o,a,u)))}function bg(r,a,o){var u=Wr();Gl(r,a,o,u)}function Gl(r,a,o,u){var b={lane:u,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(Dc(r))yg(a,b);else{var j=r.alternate;if(r.lanes===0&&(j===null||j.lanes===0)&&(j=a.lastRenderedReducer,j!==null))try{var P=a.lastRenderedState,J=j(P,o);if(b.hasEagerState=!0,b.eagerState=J,Vr(J,P))return mc(r,a,b,0),kn===null&&hc(),!1}catch{}if(o=Iu(r,a,b,u),o!==null)return Dr(o,r,u),vg(o,a,u),!0}return!1}function vf(r,a,o,u){if(u={lane:2,revertLane:Zf(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},Dc(r)){if(a)throw Error(i(479))}else a=Iu(r,o,u,2),a!==null&&Dr(a,r,2)}function Dc(r){var a=r.alternate;return r===Lt||a!==null&&a===Lt}function yg(r,a){Vi=Ec=!0;var o=r.pending;o===null?a.next=a:(a.next=o.next,o.next=a),r.pending=a}function vg(r,a,o){if((o&4194048)!==0){var u=a.lanes;u&=r.pendingLanes,o|=u,a.lanes=o,hn(r,o)}}var Xl={readContext:fr,use:Ac,useCallback:Pn,useContext:Pn,useEffect:Pn,useImperativeHandle:Pn,useLayoutEffect:Pn,useInsertionEffect:Pn,useMemo:Pn,useReducer:Pn,useRef:Pn,useState:Pn,useDebugValue:Pn,useDeferredValue:Pn,useTransition:Pn,useSyncExternalStore:Pn,useId:Pn,useHostTransitionStatus:Pn,useFormState:Pn,useActionState:Pn,useOptimistic:Pn,useMemoCache:Pn,useCacheRefresh:Pn};Xl.useEffectEvent=Pn;var jg={readContext:fr,use:Ac,useCallback:function(r,a){return jr().memoizedState=[r,a===void 0?null:a],r},useContext:fr,useEffect:sg,useImperativeHandle:function(r,a,o){o=o!=null?o.concat([r]):null,Rc(4194308,4,og.bind(null,a,r),o)},useLayoutEffect:function(r,a){return Rc(4194308,4,r,a)},useInsertionEffect:function(r,a){Rc(4,2,r,a)},useMemo:function(r,a){var o=jr();a=a===void 0?null:a;var u=r();if(oi){Bt(!0);try{r()}finally{Bt(!1)}}return o.memoizedState=[u,a],u},useReducer:function(r,a,o){var u=jr();if(o!==void 0){var b=o(a);if(oi){Bt(!0);try{o(a)}finally{Bt(!1)}}}else b=a;return u.memoizedState=u.baseState=b,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:b},u.queue=r,r=r.dispatch=q5.bind(null,Lt,r),[u.memoizedState,r]},useRef:function(r){var a=jr();return r={current:r},a.memoizedState=r},useState:function(r){r=hf(r);var a=r.queue,o=bg.bind(null,Lt,a);return a.dispatch=o,[r.memoizedState,o]},useDebugValue:pf,useDeferredValue:function(r,a){var o=jr();return gf(o,r,a)},useTransition:function(){var r=hf(!1);return r=hg.bind(null,Lt,r.queue,!0,!1),jr().memoizedState=r,[!1,r]},useSyncExternalStore:function(r,a,o){var u=Lt,b=jr();if(Qt){if(o===void 0)throw Error(i(407));o=o()}else{if(o=a(),kn===null)throw Error(i(349));(Xt&127)!==0||qp(u,a,o)}b.memoizedState=o;var j={value:o,getSnapshot:a};return b.queue=j,sg(Vp.bind(null,u,j,r),[r]),u.flags|=2048,Yi(9,{destroy:void 0},Up.bind(null,u,j,o,a),null),o},useId:function(){var r=jr(),a=kn.identifierPrefix;if(Qt){var o=Ss,u=ks;o=(u&~(1<<32-_t(u)-1)).toString(32)+o,a="_"+a+"R_"+o,o=Tc++,0<o&&(a+="H"+o.toString(32)),a+="_"}else o=L5++,a="_"+a+"r_"+o.toString(32)+"_";return r.memoizedState=a},useHostTransitionStatus:yf,useFormState:Jp,useActionState:Jp,useOptimistic:function(r){var a=jr();a.memoizedState=a.baseState=r;var o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return a.queue=o,a=vf.bind(null,Lt,!0,o),o.dispatch=a,[r,a]},useMemoCache:df,useCacheRefresh:function(){return jr().memoizedState=P5.bind(null,Lt)},useEffectEvent:function(r){var a=jr(),o={impl:r};return a.memoizedState=o,function(){if((fn&2)!==0)throw Error(i(440));return o.impl.apply(void 0,arguments)}}},jf={readContext:fr,use:Ac,useCallback:dg,useContext:fr,useEffect:xf,useImperativeHandle:cg,useInsertionEffect:ig,useLayoutEffect:lg,useMemo:ug,useReducer:Mc,useRef:rg,useState:function(){return Mc(Gs)},useDebugValue:pf,useDeferredValue:function(r,a){var o=Vn();return fg(o,vn.memoizedState,r,a)},useTransition:function(){var r=Mc(Gs)[0],a=Vn().memoizedState;return[typeof r=="boolean"?r:Yl(r),a]},useSyncExternalStore:Pp,useId:pg,useHostTransitionStatus:yf,useFormState:eg,useActionState:eg,useOptimistic:function(r,a){var o=Vn();return Gp(o,vn,r,a)},useMemoCache:df,useCacheRefresh:gg};jf.useEffectEvent=ag;var wg={readContext:fr,use:Ac,useCallback:dg,useContext:fr,useEffect:xf,useImperativeHandle:cg,useInsertionEffect:ig,useLayoutEffect:lg,useMemo:ug,useReducer:ff,useRef:rg,useState:function(){return ff(Gs)},useDebugValue:pf,useDeferredValue:function(r,a){var o=Vn();return vn===null?gf(o,r,a):fg(o,vn.memoizedState,r,a)},useTransition:function(){var r=ff(Gs)[0],a=Vn().memoizedState;return[typeof r=="boolean"?r:Yl(r),a]},useSyncExternalStore:Pp,useId:pg,useHostTransitionStatus:yf,useFormState:ng,useActionState:ng,useOptimistic:function(r,a){var o=Vn();return vn!==null?Gp(o,vn,r,a):(o.baseState=r,[r,o.queue.dispatch])},useMemoCache:df,useCacheRefresh:gg};wg.useEffectEvent=ag;function wf(r,a,o,u){a=r.memoizedState,o=o(u,a),o=o==null?a:p({},a,o),r.memoizedState=o,r.lanes===0&&(r.updateQueue.baseState=o)}var Nf={enqueueSetState:function(r,a,o){r=r._reactInternals;var u=Wr(),b=ja(u);b.payload=a,o!=null&&(b.callback=o),a=wa(r,b,u),a!==null&&(Dr(a,r,u),ql(a,r,u))},enqueueReplaceState:function(r,a,o){r=r._reactInternals;var u=Wr(),b=ja(u);b.tag=1,b.payload=a,o!=null&&(b.callback=o),a=wa(r,b,u),a!==null&&(Dr(a,r,u),ql(a,r,u))},enqueueForceUpdate:function(r,a){r=r._reactInternals;var o=Wr(),u=ja(o);u.tag=2,a!=null&&(u.callback=a),a=wa(r,u,o),a!==null&&(Dr(a,r,o),ql(a,r,o))}};function Ng(r,a,o,u,b,j,P){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(u,j,P):a.prototype&&a.prototype.isPureReactComponent?!Dl(o,u)||!Dl(b,j):!0}function kg(r,a,o,u){r=a.state,typeof a.componentWillReceiveProps=="function"&&a.componentWillReceiveProps(o,u),typeof a.UNSAFE_componentWillReceiveProps=="function"&&a.UNSAFE_componentWillReceiveProps(o,u),a.state!==r&&Nf.enqueueReplaceState(a,a.state,null)}function ci(r,a){var o=a;if("ref"in a){o={};for(var u in a)u!=="ref"&&(o[u]=a[u])}if(r=r.defaultProps){o===a&&(o=p({},o));for(var b in r)o[b]===void 0&&(o[b]=r[b])}return o}function Sg(r){fc(r)}function Cg(r){console.error(r)}function Eg(r){fc(r)}function Lc(r,a){try{var o=r.onUncaughtError;o(a.value,{componentStack:a.stack})}catch(u){setTimeout(function(){throw u})}}function Tg(r,a,o){try{var u=r.onCaughtError;u(o.value,{componentStack:o.stack,errorBoundary:a.tag===1?a.stateNode:null})}catch(b){setTimeout(function(){throw b})}}function kf(r,a,o){return o=ja(o),o.tag=3,o.payload={element:null},o.callback=function(){Lc(r,a)},o}function _g(r){return r=ja(r),r.tag=3,r}function Ag(r,a,o,u){var b=o.type.getDerivedStateFromError;if(typeof b=="function"){var j=u.value;r.payload=function(){return b(j)},r.callback=function(){Tg(a,o,u)}}var P=o.stateNode;P!==null&&typeof P.componentDidCatch=="function"&&(r.callback=function(){Tg(a,o,u),typeof b!="function"&&(Ta===null?Ta=new Set([this]):Ta.add(this));var J=u.stack;this.componentDidCatch(u.value,{componentStack:J!==null?J:""})})}function U5(r,a,o,u,b){if(o.flags|=32768,u!==null&&typeof u=="object"&&typeof u.then=="function"){if(a=o.alternate,a!==null&&$i(a,o,b,!0),o=Yr.current,o!==null){switch(o.tag){case 31:case 13:return ls===null?Gc():o.alternate===null&&qn===0&&(qn=3),o.flags&=-257,o.flags|=65536,o.lanes=b,u===wc?o.flags|=16384:(a=o.updateQueue,a===null?o.updateQueue=new Set([u]):a.add(u),Kf(r,u,b)),!1;case 22:return o.flags|=65536,u===wc?o.flags|=16384:(a=o.updateQueue,a===null?(a={transitions:null,markerInstances:null,retryQueue:new Set([u])},o.updateQueue=a):(o=a.retryQueue,o===null?a.retryQueue=new Set([u]):o.add(u)),Kf(r,u,b)),!1}throw Error(i(435,o.tag))}return Kf(r,u,b),Gc(),!1}if(Qt)return a=Yr.current,a!==null?((a.flags&65536)===0&&(a.flags|=256),a.flags|=65536,a.lanes=b,u!==qu&&(r=Error(i(422),{cause:u}),zl(rs(r,o)))):(u!==qu&&(a=Error(i(423),{cause:u}),zl(rs(a,o))),r=r.current.alternate,r.flags|=65536,b&=-b,r.lanes|=b,u=rs(u,o),b=kf(r.stateNode,u,b),Ju(r,b),qn!==4&&(qn=2)),!1;var j=Error(i(520),{cause:u});if(j=rs(j,o),no===null?no=[j]:no.push(j),qn!==4&&(qn=2),a===null)return!0;u=rs(u,o),o=a;do{switch(o.tag){case 3:return o.flags|=65536,r=b&-b,o.lanes|=r,r=kf(o.stateNode,u,r),Ju(o,r),!1;case 1:if(a=o.type,j=o.stateNode,(o.flags&128)===0&&(typeof a.getDerivedStateFromError=="function"||j!==null&&typeof j.componentDidCatch=="function"&&(Ta===null||!Ta.has(j))))return o.flags|=65536,b&=-b,o.lanes|=b,b=_g(b),Ag(b,r,o,u),Ju(o,b),!1}o=o.return}while(o!==null);return!1}var Sf=Error(i(461)),Kn=!1;function hr(r,a,o,u){a.child=r===null?Dp(a,null,o,u):li(a,r.child,o,u)}function Mg(r,a,o,u,b){o=o.render;var j=a.ref;if("ref"in u){var P={};for(var J in u)J!=="ref"&&(P[J]=u[J])}else P=u;return ri(a),u=af(r,a,o,P,j,b),J=lf(),r!==null&&!Kn?(of(r,a,b),Xs(r,a,b)):(Qt&&J&&Hu(a),a.flags|=1,hr(r,a,u,b),a.child)}function Rg(r,a,o,u,b){if(r===null){var j=o.type;return typeof j=="function"&&!zu(j)&&j.defaultProps===void 0&&o.compare===null?(a.tag=15,a.type=j,Og(r,a,j,u,b)):(r=pc(o.type,null,u,a,a.mode,b),r.ref=a.ref,r.return=a,a.child=r)}if(j=r.child,!Of(r,b)){var P=j.memoizedProps;if(o=o.compare,o=o!==null?o:Dl,o(P,u)&&r.ref===a.ref)return Xs(r,a,b)}return a.flags|=1,r=qs(j,u),r.ref=a.ref,r.return=a,a.child=r}function Og(r,a,o,u,b){if(r!==null){var j=r.memoizedProps;if(Dl(j,u)&&r.ref===a.ref)if(Kn=!1,a.pendingProps=u=j,Of(r,b))(r.flags&131072)!==0&&(Kn=!0);else return a.lanes=r.lanes,Xs(r,a,b)}return Cf(r,a,o,u,b)}function Dg(r,a,o,u){var b=u.children,j=r!==null?r.memoizedState:null;if(r===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|o:o,r!==null){for(u=a.child=r.child,b=0;u!==null;)b=b|u.lanes|u.childLanes,u=u.sibling;u=b&~j}else u=0,a.child=null;return Lg(r,a,j,o,u)}if((o&536870912)!==0)a.memoizedState={baseLanes:0,cachePool:null},r!==null&&vc(a,j!==null?j.cachePool:null),j!==null?zp(a,j):tf(),$p(a);else return u=a.lanes=536870912,Lg(r,a,j!==null?j.baseLanes|o:o,o,u)}else j!==null?(vc(a,j.cachePool),zp(a,j),ka(),a.memoizedState=null):(r!==null&&vc(a,null),tf(),ka());return hr(r,a,b,o),a.child}function Kl(r,a){return r!==null&&r.tag===22||a.stateNode!==null||(a.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),a.sibling}function Lg(r,a,o,u,b){var j=Ku();return j=j===null?null:{parent:Gn._currentValue,pool:j},a.memoizedState={baseLanes:o,cachePool:j},r!==null&&vc(a,null),tf(),$p(a),r!==null&&$i(r,a,u,!0),a.childLanes=b,null}function Ic(r,a){return a=$c({mode:a.mode,children:a.children},r.mode),a.ref=r.ref,r.child=a,a.return=r,a}function Ig(r,a,o){return li(a,r.child,null,o),r=Ic(a,a.pendingProps),r.flags|=2,Gr(a),a.memoizedState=null,r}function V5(r,a,o){var u=a.pendingProps,b=(a.flags&128)!==0;if(a.flags&=-129,r===null){if(Qt){if(u.mode==="hidden")return r=Ic(a,u),a.lanes=536870912,Kl(null,r);if(rf(a),(r=An)?(r=X0(r,is),r=r!==null&&r.data==="&"?r:null,r!==null&&(a.memoizedState={dehydrated:r,treeContext:pa!==null?{id:ks,overflow:Ss}:null,retryLane:536870912,hydrationErrors:null},o=yp(r),o.return=a,a.child=o,ur=a,An=null)):r=null,r===null)throw ba(a);return a.lanes=536870912,null}return Ic(a,u)}var j=r.memoizedState;if(j!==null){var P=j.dehydrated;if(rf(a),b)if(a.flags&256)a.flags&=-257,a=Ig(r,a,o);else if(a.memoizedState!==null)a.child=r.child,a.flags|=128,a=null;else throw Error(i(558));else if(Kn||$i(r,a,o,!1),b=(o&r.childLanes)!==0,Kn||b){if(u=kn,u!==null&&(P=lr(u,o),P!==0&&P!==j.retryLane))throw j.retryLane=P,Ja(r,P),Dr(u,r,P),Sf;Gc(),a=Ig(r,a,o)}else r=j.treeContext,An=os(P.nextSibling),ur=a,Qt=!0,ga=null,is=!1,r!==null&&wp(a,r),a=Ic(a,u),a.flags|=4096;return a}return r=qs(r.child,{mode:u.mode,children:u.children}),r.ref=a.ref,a.child=r,r.return=a,r}function zc(r,a){var o=a.ref;if(o===null)r!==null&&r.ref!==null&&(a.flags|=4194816);else{if(typeof o!="function"&&typeof o!="object")throw Error(i(284));(r===null||r.ref!==o)&&(a.flags|=4194816)}}function Cf(r,a,o,u,b){return ri(a),o=af(r,a,o,u,void 0,b),u=lf(),r!==null&&!Kn?(of(r,a,b),Xs(r,a,b)):(Qt&&u&&Hu(a),a.flags|=1,hr(r,a,o,b),a.child)}function zg(r,a,o,u,b,j){return ri(a),a.updateQueue=null,o=Hp(a,u,o,b),Bp(r),u=lf(),r!==null&&!Kn?(of(r,a,j),Xs(r,a,j)):(Qt&&u&&Hu(a),a.flags|=1,hr(r,a,o,j),a.child)}function $g(r,a,o,u,b){if(ri(a),a.stateNode===null){var j=Di,P=o.contextType;typeof P=="object"&&P!==null&&(j=fr(P)),j=new o(u,j),a.memoizedState=j.state!==null&&j.state!==void 0?j.state:null,j.updater=Nf,a.stateNode=j,j._reactInternals=a,j=a.stateNode,j.props=u,j.state=a.memoizedState,j.refs={},Qu(a),P=o.contextType,j.context=typeof P=="object"&&P!==null?fr(P):Di,j.state=a.memoizedState,P=o.getDerivedStateFromProps,typeof P=="function"&&(wf(a,o,P,u),j.state=a.memoizedState),typeof o.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&&Nf.enqueueReplaceState(j,j.state,null),Vl(a,u,j,b),Ul(),j.state=a.memoizedState),typeof j.componentDidMount=="function"&&(a.flags|=4194308),u=!0}else if(r===null){j=a.stateNode;var J=a.memoizedProps,ie=ci(o,J);j.props=ie;var ge=j.context,Ee=o.contextType;P=Di,typeof Ee=="object"&&Ee!==null&&(P=fr(Ee));var Oe=o.getDerivedStateFromProps;Ee=typeof Oe=="function"||typeof j.getSnapshotBeforeUpdate=="function",J=a.pendingProps!==J,Ee||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(J||ge!==P)&&kg(a,j,u,P),va=!1;var ve=a.memoizedState;j.state=ve,Vl(a,u,j,b),Ul(),ge=a.memoizedState,J||ve!==ge||va?(typeof Oe=="function"&&(wf(a,o,Oe,u),ge=a.memoizedState),(ie=va||Ng(a,o,ie,u,ve,ge,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=ge),j.props=u,j.state=ge,j.context=P,u=ie):(typeof j.componentDidMount=="function"&&(a.flags|=4194308),u=!1)}else{j=a.stateNode,Zu(r,a),P=a.memoizedProps,Ee=ci(o,P),j.props=Ee,Oe=a.pendingProps,ve=j.context,ge=o.contextType,ie=Di,typeof ge=="object"&&ge!==null&&(ie=fr(ge)),J=o.getDerivedStateFromProps,(ge=typeof J=="function"||typeof j.getSnapshotBeforeUpdate=="function")||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(P!==Oe||ve!==ie)&&kg(a,j,u,ie),va=!1,ve=a.memoizedState,j.state=ve,Vl(a,u,j,b),Ul();var we=a.memoizedState;P!==Oe||ve!==we||va||r!==null&&r.dependencies!==null&&bc(r.dependencies)?(typeof J=="function"&&(wf(a,o,J,u),we=a.memoizedState),(Ee=va||Ng(a,o,Ee,u,ve,we,ie)||r!==null&&r.dependencies!==null&&bc(r.dependencies))?(ge||typeof j.UNSAFE_componentWillUpdate!="function"&&typeof j.componentWillUpdate!="function"||(typeof j.componentWillUpdate=="function"&&j.componentWillUpdate(u,we,ie),typeof j.UNSAFE_componentWillUpdate=="function"&&j.UNSAFE_componentWillUpdate(u,we,ie)),typeof j.componentDidUpdate=="function"&&(a.flags|=4),typeof j.getSnapshotBeforeUpdate=="function"&&(a.flags|=1024)):(typeof j.componentDidUpdate!="function"||P===r.memoizedProps&&ve===r.memoizedState||(a.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||P===r.memoizedProps&&ve===r.memoizedState||(a.flags|=1024),a.memoizedProps=u,a.memoizedState=we),j.props=u,j.state=we,j.context=ie,u=Ee):(typeof j.componentDidUpdate!="function"||P===r.memoizedProps&&ve===r.memoizedState||(a.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||P===r.memoizedProps&&ve===r.memoizedState||(a.flags|=1024),u=!1)}return j=u,zc(r,a),u=(a.flags&128)!==0,j||u?(j=a.stateNode,o=u&&typeof o.getDerivedStateFromError!="function"?null:j.render(),a.flags|=1,r!==null&&u?(a.child=li(a,r.child,null,b),a.child=li(a,null,o,b)):hr(r,a,o,b),a.memoizedState=j.state,r=a.child):r=Xs(r,a,b),r}function Bg(r,a,o,u){return ti(),a.flags|=256,hr(r,a,o,u),a.child}var Ef={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Tf(r){return{baseLanes:r,cachePool:Tp()}}function _f(r,a,o){return r=r!==null?r.childLanes&~o:0,a&&(r|=Kr),r}function Hg(r,a,o){var u=a.pendingProps,b=!1,j=(a.flags&128)!==0,P;if((P=j)||(P=r!==null&&r.memoizedState===null?!1:(Un.current&2)!==0),P&&(b=!0,a.flags&=-129),P=(a.flags&32)!==0,a.flags&=-33,r===null){if(Qt){if(b?Na(a):ka(),(r=An)?(r=X0(r,is),r=r!==null&&r.data!=="&"?r:null,r!==null&&(a.memoizedState={dehydrated:r,treeContext:pa!==null?{id:ks,overflow:Ss}:null,retryLane:536870912,hydrationErrors:null},o=yp(r),o.return=a,a.child=o,ur=a,An=null)):r=null,r===null)throw ba(a);return uh(r)?a.lanes=32:a.lanes=536870912,null}var J=u.children;return u=u.fallback,b?(ka(),b=a.mode,J=$c({mode:"hidden",children:J},b),u=ei(u,b,o,null),J.return=a,u.return=a,J.sibling=u,a.child=J,u=a.child,u.memoizedState=Tf(o),u.childLanes=_f(r,P,o),a.memoizedState=Ef,Kl(null,u)):(Na(a),Af(a,J))}var ie=r.memoizedState;if(ie!==null&&(J=ie.dehydrated,J!==null)){if(j)a.flags&256?(Na(a),a.flags&=-257,a=Mf(r,a,o)):a.memoizedState!==null?(ka(),a.child=r.child,a.flags|=128,a=null):(ka(),J=u.fallback,b=a.mode,u=$c({mode:"visible",children:u.children},b),J=ei(J,b,o,null),J.flags|=2,u.return=a,J.return=a,u.sibling=J,a.child=u,li(a,r.child,null,o),u=a.child,u.memoizedState=Tf(o),u.childLanes=_f(r,P,o),a.memoizedState=Ef,a=Kl(null,u));else if(Na(a),uh(J)){if(P=J.nextSibling&&J.nextSibling.dataset,P)var ge=P.dgst;P=ge,u=Error(i(419)),u.stack="",u.digest=P,zl({value:u,source:null,stack:null}),a=Mf(r,a,o)}else if(Kn||$i(r,a,o,!1),P=(o&r.childLanes)!==0,Kn||P){if(P=kn,P!==null&&(u=lr(P,o),u!==0&&u!==ie.retryLane))throw ie.retryLane=u,Ja(r,u),Dr(P,r,u),Sf;dh(J)||Gc(),a=Mf(r,a,o)}else dh(J)?(a.flags|=192,a.child=r.child,a=null):(r=ie.treeContext,An=os(J.nextSibling),ur=a,Qt=!0,ga=null,is=!1,r!==null&&wp(a,r),a=Af(a,u.children),a.flags|=4096);return a}return b?(ka(),J=u.fallback,b=a.mode,ie=r.child,ge=ie.sibling,u=qs(ie,{mode:"hidden",children:u.children}),u.subtreeFlags=ie.subtreeFlags&65011712,ge!==null?J=qs(ge,J):(J=ei(J,b,o,null),J.flags|=2),J.return=a,u.return=a,u.sibling=J,a.child=u,Kl(null,u),u=a.child,J=r.child.memoizedState,J===null?J=Tf(o):(b=J.cachePool,b!==null?(ie=Gn._currentValue,b=b.parent!==ie?{parent:ie,pool:ie}:b):b=Tp(),J={baseLanes:J.baseLanes|o,cachePool:b}),u.memoizedState=J,u.childLanes=_f(r,P,o),a.memoizedState=Ef,Kl(r.child,u)):(Na(a),o=r.child,r=o.sibling,o=qs(o,{mode:"visible",children:u.children}),o.return=a,o.sibling=null,r!==null&&(P=a.deletions,P===null?(a.deletions=[r],a.flags|=16):P.push(r)),a.child=o,a.memoizedState=null,o)}function Af(r,a){return a=$c({mode:"visible",children:a},r.mode),a.return=r,r.child=a}function $c(r,a){return r=Fr(22,r,null,a),r.lanes=0,r}function Mf(r,a,o){return li(a,r.child,null,o),r=Af(a,a.pendingProps.children),r.flags|=2,a.memoizedState=null,r}function Pg(r,a,o){r.lanes|=a;var u=r.alternate;u!==null&&(u.lanes|=a),Fu(r.return,a,o)}function Rf(r,a,o,u,b,j){var P=r.memoizedState;P===null?r.memoizedState={isBackwards:a,rendering:null,renderingStartTime:0,last:u,tail:o,tailMode:b,treeForkCount:j}:(P.isBackwards=a,P.rendering=null,P.renderingStartTime=0,P.last=u,P.tail=o,P.tailMode=b,P.treeForkCount=j)}function qg(r,a,o){var u=a.pendingProps,b=u.revealOrder,j=u.tail;u=u.children;var P=Un.current,J=(P&2)!==0;if(J?(P=P&1|2,a.flags|=128):P&=1,I(Un,P),hr(r,a,u,o),u=Qt?Il:0,!J&&r!==null&&(r.flags&128)!==0)e:for(r=a.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&Pg(r,o,a);else if(r.tag===19)Pg(r,o,a);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===a)break e;for(;r.sibling===null;){if(r.return===null||r.return===a)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}switch(b){case"forwards":for(o=a.child,b=null;o!==null;)r=o.alternate,r!==null&&Cc(r)===null&&(b=o),o=o.sibling;o=b,o===null?(b=a.child,a.child=null):(b=o.sibling,o.sibling=null),Rf(a,!1,b,o,j,u);break;case"backwards":case"unstable_legacy-backwards":for(o=null,b=a.child,a.child=null;b!==null;){if(r=b.alternate,r!==null&&Cc(r)===null){a.child=b;break}r=b.sibling,b.sibling=o,o=b,b=r}Rf(a,!0,o,null,j,u);break;case"together":Rf(a,!1,null,null,void 0,u);break;default:a.memoizedState=null}return a.child}function Xs(r,a,o){if(r!==null&&(a.dependencies=r.dependencies),Ea|=a.lanes,(o&a.childLanes)===0)if(r!==null){if($i(r,a,o,!1),(o&a.childLanes)===0)return null}else return null;if(r!==null&&a.child!==r.child)throw Error(i(153));if(a.child!==null){for(r=a.child,o=qs(r,r.pendingProps),a.child=o,o.return=a;r.sibling!==null;)r=r.sibling,o=o.sibling=qs(r,r.pendingProps),o.return=a;o.sibling=null}return a.child}function Of(r,a){return(r.lanes&a)!==0?!0:(r=r.dependencies,!!(r!==null&&bc(r)))}function F5(r,a,o){switch(a.tag){case 3:te(a,a.stateNode.containerInfo),ya(a,Gn,r.memoizedState.cache),ti();break;case 27:case 5:he(a);break;case 4:te(a,a.stateNode.containerInfo);break;case 10:ya(a,a.type,a.memoizedProps.value);break;case 31:if(a.memoizedState!==null)return a.flags|=128,rf(a),null;break;case 13:var u=a.memoizedState;if(u!==null)return u.dehydrated!==null?(Na(a),a.flags|=128,null):(o&a.child.childLanes)!==0?Hg(r,a,o):(Na(a),r=Xs(r,a,o),r!==null?r.sibling:null);Na(a);break;case 19:var b=(r.flags&128)!==0;if(u=(o&a.childLanes)!==0,u||($i(r,a,o,!1),u=(o&a.childLanes)!==0),b){if(u)return qg(r,a,o);a.flags|=128}if(b=a.memoizedState,b!==null&&(b.rendering=null,b.tail=null,b.lastEffect=null),I(Un,Un.current),u)break;return null;case 22:return a.lanes=0,Dg(r,a,o,a.pendingProps);case 24:ya(a,Gn,r.memoizedState.cache)}return Xs(r,a,o)}function Ug(r,a,o){if(r!==null)if(r.memoizedProps!==a.pendingProps)Kn=!0;else{if(!Of(r,o)&&(a.flags&128)===0)return Kn=!1,F5(r,a,o);Kn=(r.flags&131072)!==0}else Kn=!1,Qt&&(a.flags&1048576)!==0&&jp(a,Il,a.index);switch(a.lanes=0,a.tag){case 16:e:{var u=a.pendingProps;if(r=ai(a.elementType),a.type=r,typeof r=="function")zu(r)?(u=ci(r,u),a.tag=1,a=$g(null,a,r,u,o)):(a.tag=0,a=Cf(null,a,r,u,o));else{if(r!=null){var b=r.$$typeof;if(b===M){a.tag=11,a=Mg(null,a,r,u,o);break e}else if(b===G){a.tag=14,a=Rg(null,a,r,u,o);break e}}throw a=E(r)||r,Error(i(306,a,""))}}return a;case 0:return Cf(r,a,a.type,a.pendingProps,o);case 1:return u=a.type,b=ci(u,a.pendingProps),$g(r,a,u,b,o);case 3:e:{if(te(a,a.stateNode.containerInfo),r===null)throw Error(i(387));u=a.pendingProps;var j=a.memoizedState;b=j.element,Zu(r,a),Vl(a,u,null,o);var P=a.memoizedState;if(u=P.cache,ya(a,Gn,u),u!==j.cache&&Yu(a,[Gn],o,!0),Ul(),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=Bg(r,a,u,o);break e}else if(u!==b){b=rs(Error(i(424)),a),zl(b),a=Bg(r,a,u,o);break e}else for(r=a.stateNode.containerInfo,r.nodeType===9?r=r.body:r=r.nodeName==="HTML"?r.ownerDocument.body:r,An=os(r.firstChild),ur=a,Qt=!0,ga=null,is=!0,o=Dp(a,null,u,o),a.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling;else{if(ti(),u===b){a=Xs(r,a,o);break e}hr(r,a,u,o)}a=a.child}return a;case 26:return zc(r,a),r===null?(o=eb(a.type,null,a.pendingProps,null))?a.memoizedState=o:Qt||(o=a.type,r=a.pendingProps,u=ed(W.current).createElement(o),u[qe]=a,u[Je]=r,mr(u,o,r),Nn(u),a.stateNode=u):a.memoizedState=eb(a.type,r.memoizedProps,a.pendingProps,r.memoizedState),null;case 27:return he(a),r===null&&Qt&&(u=a.stateNode=Q0(a.type,a.pendingProps,W.current),ur=a,is=!0,b=An,Ra(a.type)?(fh=b,An=os(u.firstChild)):An=b),hr(r,a,a.pendingProps.children,o),zc(r,a),r===null&&(a.flags|=4194304),a.child;case 5:return r===null&&Qt&&((b=u=An)&&(u=j2(u,a.type,a.pendingProps,is),u!==null?(a.stateNode=u,ur=a,An=os(u.firstChild),is=!1,b=!0):b=!1),b||ba(a)),he(a),b=a.type,j=a.pendingProps,P=r!==null?r.memoizedProps:null,u=j.children,lh(b,j)?u=null:P!==null&&lh(b,P)&&(a.flags|=32),a.memoizedState!==null&&(b=af(r,a,I5,null,null,o),uo._currentValue=b),zc(r,a),hr(r,a,u,o),a.child;case 6:return r===null&&Qt&&((r=o=An)&&(o=w2(o,a.pendingProps,is),o!==null?(a.stateNode=o,ur=a,An=null,r=!0):r=!1),r||ba(a)),null;case 13:return Hg(r,a,o);case 4:return te(a,a.stateNode.containerInfo),u=a.pendingProps,r===null?a.child=li(a,null,u,o):hr(r,a,u,o),a.child;case 11:return Mg(r,a,a.type,a.pendingProps,o);case 7:return hr(r,a,a.pendingProps,o),a.child;case 8:return hr(r,a,a.pendingProps.children,o),a.child;case 12:return hr(r,a,a.pendingProps.children,o),a.child;case 10:return u=a.pendingProps,ya(a,a.type,u.value),hr(r,a,u.children,o),a.child;case 9:return b=a.type._context,u=a.pendingProps.children,ri(a),b=fr(b),u=u(b),a.flags|=1,hr(r,a,u,o),a.child;case 14:return Rg(r,a,a.type,a.pendingProps,o);case 15:return Og(r,a,a.type,a.pendingProps,o);case 19:return qg(r,a,o);case 31:return V5(r,a,o);case 22:return Dg(r,a,o,a.pendingProps);case 24:return ri(a),u=fr(Gn),r===null?(b=Ku(),b===null&&(b=kn,j=Gu(),b.pooledCache=j,j.refCount++,j!==null&&(b.pooledCacheLanes|=o),b=j),a.memoizedState={parent:u,cache:b},Qu(a),ya(a,Gn,b)):((r.lanes&o)!==0&&(Zu(r,a),Vl(a,null,null,o),Ul()),b=r.memoizedState,j=a.memoizedState,b.parent!==u?(b={parent:u,cache:u},a.memoizedState=b,a.lanes===0&&(a.memoizedState=a.updateQueue.baseState=b),ya(a,Gn,u)):(u=j.cache,ya(a,Gn,u),u!==b.cache&&Yu(a,[Gn],o,!0))),hr(r,a,a.pendingProps.children,o),a.child;case 29:throw a.pendingProps}throw Error(i(156,a.tag))}function Ks(r){r.flags|=4}function Df(r,a,o,u,b){if((a=(r.mode&32)!==0)&&(a=!1),a){if(r.flags|=16777216,(b&335544128)===b)if(r.stateNode.complete)r.flags|=8192;else if(p0())r.flags|=8192;else throw ii=wc,Wu}else r.flags&=-16777217}function Vg(r,a){if(a.type!=="stylesheet"||(a.state.loading&4)!==0)r.flags&=-16777217;else if(r.flags|=16777216,!ab(a))if(p0())r.flags|=8192;else throw ii=wc,Wu}function Bc(r,a){a!==null&&(r.flags|=4),r.flags&16384&&(a=r.tag!==22?On():536870912,r.lanes|=a,Wi|=a)}function Wl(r,a){if(!Qt)switch(r.tailMode){case"hidden":a=r.tail;for(var o=null;a!==null;)a.alternate!==null&&(o=a),a=a.sibling;o===null?r.tail=null:o.sibling=null;break;case"collapsed":o=r.tail;for(var u=null;o!==null;)o.alternate!==null&&(u=o),o=o.sibling;u===null?a||r.tail===null?r.tail=null:r.tail.sibling=null:u.sibling=null}}function Mn(r){var a=r.alternate!==null&&r.alternate.child===r.child,o=0,u=0;if(a)for(var b=r.child;b!==null;)o|=b.lanes|b.childLanes,u|=b.subtreeFlags&65011712,u|=b.flags&65011712,b.return=r,b=b.sibling;else for(b=r.child;b!==null;)o|=b.lanes|b.childLanes,u|=b.subtreeFlags,u|=b.flags,b.return=r,b=b.sibling;return r.subtreeFlags|=u,r.childLanes=o,a}function Y5(r,a,o){var u=a.pendingProps;switch(Pu(a),a.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Mn(a),null;case 1:return Mn(a),null;case 3:return o=a.stateNode,u=null,r!==null&&(u=r.memoizedState.cache),a.memoizedState.cache!==u&&(a.flags|=2048),Fs(Gn),ae(),o.pendingContext&&(o.context=o.pendingContext,o.pendingContext=null),(r===null||r.child===null)&&(zi(a)?Ks(a):r===null||r.memoizedState.isDehydrated&&(a.flags&256)===0||(a.flags|=1024,Uu())),Mn(a),null;case 26:var b=a.type,j=a.memoizedState;return r===null?(Ks(a),j!==null?(Mn(a),Vg(a,j)):(Mn(a),Df(a,b,null,u,o))):j?j!==r.memoizedState?(Ks(a),Mn(a),Vg(a,j)):(Mn(a),a.flags&=-16777217):(r=r.memoizedProps,r!==u&&Ks(a),Mn(a),Df(a,b,r,u,o)),null;case 27:if(Ne(a),o=W.current,b=a.type,r!==null&&a.stateNode!=null)r.memoizedProps!==u&&Ks(a);else{if(!u){if(a.stateNode===null)throw Error(i(166));return Mn(a),null}r=S.current,zi(a)?Np(a):(r=Q0(b,u,o),a.stateNode=r,Ks(a))}return Mn(a),null;case 5:if(Ne(a),b=a.type,r!==null&&a.stateNode!=null)r.memoizedProps!==u&&Ks(a);else{if(!u){if(a.stateNode===null)throw Error(i(166));return Mn(a),null}if(j=S.current,zi(a))Np(a);else{var P=ed(W.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[qe]=a,j[Je]=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(mr(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&&Ks(a)}}return Mn(a),Df(a,a.type,r===null?null:r.memoizedProps,a.pendingProps,o),null;case 6:if(r&&a.stateNode!=null)r.memoizedProps!==u&&Ks(a);else{if(typeof u!="string"&&a.stateNode===null)throw Error(i(166));if(r=W.current,zi(a)){if(r=a.stateNode,o=a.memoizedProps,u=null,b=ur,b!==null)switch(b.tag){case 27:case 5:u=b.memoizedProps}r[qe]=a,r=!!(r.nodeValue===o||u!==null&&u.suppressHydrationWarning===!0||H0(r.nodeValue,o)),r||ba(a,!0)}else r=ed(r).createTextNode(u),r[qe]=a,a.stateNode=r}return Mn(a),null;case 31:if(o=a.memoizedState,r===null||r.memoizedState!==null){if(u=zi(a),o!==null){if(r===null){if(!u)throw Error(i(318));if(r=a.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(i(557));r[qe]=a}else ti(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;Mn(a),r=!1}else o=Uu(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=o),r=!0;if(!r)return a.flags&256?(Gr(a),a):(Gr(a),null);if((a.flags&128)!==0)throw Error(i(558))}return Mn(a),null;case 13:if(u=a.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(b=zi(a),u!==null&&u.dehydrated!==null){if(r===null){if(!b)throw Error(i(318));if(b=a.memoizedState,b=b!==null?b.dehydrated:null,!b)throw Error(i(317));b[qe]=a}else ti(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;Mn(a),b=!1}else b=Uu(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=b),b=!0;if(!b)return a.flags&256?(Gr(a),a):(Gr(a),null)}return Gr(a),(a.flags&128)!==0?(a.lanes=o,a):(o=u!==null,r=r!==null&&r.memoizedState!==null,o&&(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)),o!==r&&o&&(a.child.flags|=8192),Bc(a,a.updateQueue),Mn(a),null);case 4:return ae(),r===null&&nh(a.stateNode.containerInfo),Mn(a),null;case 10:return Fs(a.type),Mn(a),null;case 19:if(V(Un),u=a.memoizedState,u===null)return Mn(a),null;if(b=(a.flags&128)!==0,j=u.rendering,j===null)if(b)Wl(u,!1);else{if(qn!==0||r!==null&&(r.flags&128)!==0)for(r=a.child;r!==null;){if(j=Cc(r),j!==null){for(a.flags|=128,Wl(u,!1),r=j.updateQueue,a.updateQueue=r,Bc(a,r),a.subtreeFlags=0,r=o,o=a.child;o!==null;)bp(o,r),o=o.sibling;return I(Un,Un.current&1|2),Qt&&Us(a,u.treeForkCount),a.child}r=r.sibling}u.tail!==null&&dt()>Vc&&(a.flags|=128,b=!0,Wl(u,!1),a.lanes=4194304)}else{if(!b)if(r=Cc(j),r!==null){if(a.flags|=128,b=!0,r=r.updateQueue,a.updateQueue=r,Bc(a,r),Wl(u,!0),u.tail===null&&u.tailMode==="hidden"&&!j.alternate&&!Qt)return Mn(a),null}else 2*dt()-u.renderingStartTime>Vc&&o!==536870912&&(a.flags|=128,b=!0,Wl(u,!1),a.lanes=4194304);u.isBackwards?(j.sibling=a.child,a.child=j):(r=u.last,r!==null?r.sibling=j:a.child=j,u.last=j)}return u.tail!==null?(r=u.tail,u.rendering=r,u.tail=r.sibling,u.renderingStartTime=dt(),r.sibling=null,o=Un.current,I(Un,b?o&1|2:o&1),Qt&&Us(a,u.treeForkCount),r):(Mn(a),null);case 22:case 23:return Gr(a),nf(),u=a.memoizedState!==null,r!==null?r.memoizedState!==null!==u&&(a.flags|=8192):u&&(a.flags|=8192),u?(o&536870912)!==0&&(a.flags&128)===0&&(Mn(a),a.subtreeFlags&6&&(a.flags|=8192)):Mn(a),o=a.updateQueue,o!==null&&Bc(a,o.retryQueue),o=null,r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),u=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(u=a.memoizedState.cachePool.pool),u!==o&&(a.flags|=2048),r!==null&&V(si),null;case 24:return o=null,r!==null&&(o=r.memoizedState.cache),a.memoizedState.cache!==o&&(a.flags|=2048),Fs(Gn),Mn(a),null;case 25:return null;case 30:return null}throw Error(i(156,a.tag))}function G5(r,a){switch(Pu(a),a.tag){case 1:return r=a.flags,r&65536?(a.flags=r&-65537|128,a):null;case 3:return Fs(Gn),ae(),r=a.flags,(r&65536)!==0&&(r&128)===0?(a.flags=r&-65537|128,a):null;case 26:case 27:case 5:return Ne(a),null;case 31:if(a.memoizedState!==null){if(Gr(a),a.alternate===null)throw Error(i(340));ti()}return r=a.flags,r&65536?(a.flags=r&-65537|128,a):null;case 13:if(Gr(a),r=a.memoizedState,r!==null&&r.dehydrated!==null){if(a.alternate===null)throw Error(i(340));ti()}return r=a.flags,r&65536?(a.flags=r&-65537|128,a):null;case 19:return V(Un),null;case 4:return ae(),null;case 10:return Fs(a.type),null;case 22:case 23:return Gr(a),nf(),r!==null&&V(si),r=a.flags,r&65536?(a.flags=r&-65537|128,a):null;case 24:return Fs(Gn),null;case 25:return null;default:return null}}function Fg(r,a){switch(Pu(a),a.tag){case 3:Fs(Gn),ae();break;case 26:case 27:case 5:Ne(a);break;case 4:ae();break;case 31:a.memoizedState!==null&&Gr(a);break;case 13:Gr(a);break;case 19:V(Un);break;case 10:Fs(a.type);break;case 22:case 23:Gr(a),nf(),r!==null&&V(si);break;case 24:Fs(Gn)}}function Ql(r,a){try{var o=a.updateQueue,u=o!==null?o.lastEffect:null;if(u!==null){var b=u.next;o=b;do{if((o.tag&r)===r){u=void 0;var j=o.create,P=o.inst;u=j(),P.destroy=u}o=o.next}while(o!==b)}}catch(J){pn(a,a.return,J)}}function Sa(r,a,o){try{var u=a.updateQueue,b=u!==null?u.lastEffect:null;if(b!==null){var j=b.next;u=j;do{if((u.tag&r)===r){var P=u.inst,J=P.destroy;if(J!==void 0){P.destroy=void 0,b=a;var ie=o,ge=J;try{ge()}catch(Ee){pn(b,ie,Ee)}}}u=u.next}while(u!==j)}}catch(Ee){pn(a,a.return,Ee)}}function Yg(r){var a=r.updateQueue;if(a!==null){var o=r.stateNode;try{Ip(a,o)}catch(u){pn(r,r.return,u)}}}function Gg(r,a,o){o.props=ci(r.type,r.memoizedProps),o.state=r.memoizedState;try{o.componentWillUnmount()}catch(u){pn(r,a,u)}}function Zl(r,a){try{var o=r.ref;if(o!==null){switch(r.tag){case 26:case 27:case 5:var u=r.stateNode;break;case 30:u=r.stateNode;break;default:u=r.stateNode}typeof o=="function"?r.refCleanup=o(u):o.current=u}}catch(b){pn(r,a,b)}}function Cs(r,a){var o=r.ref,u=r.refCleanup;if(o!==null)if(typeof u=="function")try{u()}catch(b){pn(r,a,b)}finally{r.refCleanup=null,r=r.alternate,r!=null&&(r.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(b){pn(r,a,b)}else o.current=null}function Xg(r){var a=r.type,o=r.memoizedProps,u=r.stateNode;try{e:switch(a){case"button":case"input":case"select":case"textarea":o.autoFocus&&u.focus();break e;case"img":o.src?u.src=o.src:o.srcSet&&(u.srcset=o.srcSet)}}catch(b){pn(r,r.return,b)}}function Lf(r,a,o){try{var u=r.stateNode;x2(u,r.type,o,a),u[Je]=a}catch(b){pn(r,r.return,b)}}function Kg(r){return r.tag===5||r.tag===3||r.tag===26||r.tag===27&&Ra(r.type)||r.tag===4}function If(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||Kg(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.tag===27&&Ra(r.type)||r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function zf(r,a,o){var u=r.tag;if(u===5||u===6)r=r.stateNode,a?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(r,a):(a=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,a.appendChild(r),o=o._reactRootContainer,o!=null||a.onclick!==null||(a.onclick=Ye));else if(u!==4&&(u===27&&Ra(r.type)&&(o=r.stateNode,a=null),r=r.child,r!==null))for(zf(r,a,o),r=r.sibling;r!==null;)zf(r,a,o),r=r.sibling}function Hc(r,a,o){var u=r.tag;if(u===5||u===6)r=r.stateNode,a?o.insertBefore(r,a):o.appendChild(r);else if(u!==4&&(u===27&&Ra(r.type)&&(o=r.stateNode),r=r.child,r!==null))for(Hc(r,a,o),r=r.sibling;r!==null;)Hc(r,a,o),r=r.sibling}function Wg(r){var a=r.stateNode,o=r.memoizedProps;try{for(var u=r.type,b=a.attributes;b.length;)a.removeAttributeNode(b[0]);mr(a,u,o),a[qe]=r,a[Je]=o}catch(j){pn(r,r.return,j)}}var Ws=!1,Wn=!1,$f=!1,Qg=typeof WeakSet=="function"?WeakSet:Set,ar=null;function X5(r,a){if(r=r.containerInfo,ah=ld,r=cp(r),Au(r)){if("selectionStart"in r)var o={start:r.selectionStart,end:r.selectionEnd};else e:{o=(o=r.ownerDocument)&&o.defaultView||window;var u=o.getSelection&&o.getSelection();if(u&&u.rangeCount!==0){o=u.anchorNode;var b=u.anchorOffset,j=u.focusNode;u=u.focusOffset;try{o.nodeType,j.nodeType}catch{o=null;break e}var P=0,J=-1,ie=-1,ge=0,Ee=0,Oe=r,ve=null;t:for(;;){for(var we;Oe!==o||b!==0&&Oe.nodeType!==3||(J=P+b),Oe!==j||u!==0&&Oe.nodeType!==3||(ie=P+u),Oe.nodeType===3&&(P+=Oe.nodeValue.length),(we=Oe.firstChild)!==null;)ve=Oe,Oe=we;for(;;){if(Oe===r)break t;if(ve===o&&++ge===b&&(J=P),ve===j&&++Ee===u&&(ie=P),(we=Oe.nextSibling)!==null)break;Oe=ve,ve=Oe.parentNode}Oe=we}o=J===-1||ie===-1?null:{start:J,end:ie}}else o=null}o=o||{start:0,end:0}}else o=null;for(ih={focusedElem:r,selectionRange:o},ld=!1,ar=a;ar!==null;)if(a=ar,r=a.child,(a.subtreeFlags&1028)!==0&&r!==null)r.return=a,ar=r;else for(;ar!==null;){switch(a=ar,j=a.alternate,r=a.flags,a.tag){case 0:if((r&4)!==0&&(r=a.updateQueue,r=r!==null?r.events:null,r!==null))for(o=0;o<r.length;o++)b=r[o],b.ref.impl=b.nextImpl;break;case 11:case 15:break;case 1:if((r&1024)!==0&&j!==null){r=void 0,o=a,b=j.memoizedProps,j=j.memoizedState,u=o.stateNode;try{var tt=ci(o.type,b);r=u.getSnapshotBeforeUpdate(tt,j),u.__reactInternalSnapshotBeforeUpdate=r}catch(Ct){pn(o,o.return,Ct)}}break;case 3:if((r&1024)!==0){if(r=a.stateNode.containerInfo,o=r.nodeType,o===9)ch(r);else if(o===1)switch(r.nodeName){case"HEAD":case"HTML":case"BODY":ch(r);break;default:r.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((r&1024)!==0)throw Error(i(163))}if(r=a.sibling,r!==null){r.return=a.return,ar=r;break}ar=a.return}}function Zg(r,a,o){var u=o.flags;switch(o.tag){case 0:case 11:case 15:Zs(r,o),u&4&&Ql(5,o);break;case 1:if(Zs(r,o),u&4)if(r=o.stateNode,a===null)try{r.componentDidMount()}catch(P){pn(o,o.return,P)}else{var b=ci(o.type,a.memoizedProps);a=a.memoizedState;try{r.componentDidUpdate(b,a,r.__reactInternalSnapshotBeforeUpdate)}catch(P){pn(o,o.return,P)}}u&64&&Yg(o),u&512&&Zl(o,o.return);break;case 3:if(Zs(r,o),u&64&&(r=o.updateQueue,r!==null)){if(a=null,o.child!==null)switch(o.child.tag){case 27:case 5:a=o.child.stateNode;break;case 1:a=o.child.stateNode}try{Ip(r,a)}catch(P){pn(o,o.return,P)}}break;case 27:a===null&&u&4&&Wg(o);case 26:case 5:Zs(r,o),a===null&&u&4&&Xg(o),u&512&&Zl(o,o.return);break;case 12:Zs(r,o);break;case 31:Zs(r,o),u&4&&t0(r,o);break;case 13:Zs(r,o),u&4&&n0(r,o),u&64&&(r=o.memoizedState,r!==null&&(r=r.dehydrated,r!==null&&(o=r2.bind(null,o),N2(r,o))));break;case 22:if(u=o.memoizedState!==null||Ws,!u){a=a!==null&&a.memoizedState!==null||Wn,b=Ws;var j=Wn;Ws=u,(Wn=a)&&!j?Js(r,o,(o.subtreeFlags&8772)!==0):Zs(r,o),Ws=b,Wn=j}break;case 30:break;default:Zs(r,o)}}function Jg(r){var a=r.alternate;a!==null&&(r.alternate=null,Jg(a)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(a=r.stateNode,a!==null&&Et(a)),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}var zn=null,Ar=!1;function Qs(r,a,o){for(o=o.child;o!==null;)e0(r,a,o),o=o.sibling}function e0(r,a,o){if(gt&&typeof gt.onCommitFiberUnmount=="function")try{gt.onCommitFiberUnmount(Tt,o)}catch{}switch(o.tag){case 26:Wn||Cs(o,a),Qs(r,a,o),o.memoizedState?o.memoizedState.count--:o.stateNode&&(o=o.stateNode,o.parentNode.removeChild(o));break;case 27:Wn||Cs(o,a);var u=zn,b=Ar;Ra(o.type)&&(zn=o.stateNode,Ar=!1),Qs(r,a,o),lo(o.stateNode),zn=u,Ar=b;break;case 5:Wn||Cs(o,a);case 6:if(u=zn,b=Ar,zn=null,Qs(r,a,o),zn=u,Ar=b,zn!==null)if(Ar)try{(zn.nodeType===9?zn.body:zn.nodeName==="HTML"?zn.ownerDocument.body:zn).removeChild(o.stateNode)}catch(j){pn(o,a,j)}else try{zn.removeChild(o.stateNode)}catch(j){pn(o,a,j)}break;case 18:zn!==null&&(Ar?(r=zn,Y0(r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r,o.stateNode),sl(r)):Y0(zn,o.stateNode));break;case 4:u=zn,b=Ar,zn=o.stateNode.containerInfo,Ar=!0,Qs(r,a,o),zn=u,Ar=b;break;case 0:case 11:case 14:case 15:Sa(2,o,a),Wn||Sa(4,o,a),Qs(r,a,o);break;case 1:Wn||(Cs(o,a),u=o.stateNode,typeof u.componentWillUnmount=="function"&&Gg(o,a,u)),Qs(r,a,o);break;case 21:Qs(r,a,o);break;case 22:Wn=(u=Wn)||o.memoizedState!==null,Qs(r,a,o),Wn=u;break;default:Qs(r,a,o)}}function t0(r,a){if(a.memoizedState===null&&(r=a.alternate,r!==null&&(r=r.memoizedState,r!==null))){r=r.dehydrated;try{sl(r)}catch(o){pn(a,a.return,o)}}}function n0(r,a){if(a.memoizedState===null&&(r=a.alternate,r!==null&&(r=r.memoizedState,r!==null&&(r=r.dehydrated,r!==null))))try{sl(r)}catch(o){pn(a,a.return,o)}}function K5(r){switch(r.tag){case 31:case 13:case 19:var a=r.stateNode;return a===null&&(a=r.stateNode=new Qg),a;case 22:return r=r.stateNode,a=r._retryCache,a===null&&(a=r._retryCache=new Qg),a;default:throw Error(i(435,r.tag))}}function Pc(r,a){var o=K5(r);a.forEach(function(u){if(!o.has(u)){o.add(u);var b=s2.bind(null,r,u);u.then(b,b)}})}function Mr(r,a){var o=a.deletions;if(o!==null)for(var u=0;u<o.length;u++){var b=o[u],j=r,P=a,J=P;e:for(;J!==null;){switch(J.tag){case 27:if(Ra(J.type)){zn=J.stateNode,Ar=!1;break e}break;case 5:zn=J.stateNode,Ar=!1;break e;case 3:case 4:zn=J.stateNode.containerInfo,Ar=!0;break e}J=J.return}if(zn===null)throw Error(i(160));e0(j,P,b),zn=null,Ar=!1,j=b.alternate,j!==null&&(j.return=null),b.return=null}if(a.subtreeFlags&13886)for(a=a.child;a!==null;)r0(a,r),a=a.sibling}var ms=null;function r0(r,a){var o=r.alternate,u=r.flags;switch(r.tag){case 0:case 11:case 14:case 15:Mr(a,r),Rr(r),u&4&&(Sa(3,r,r.return),Ql(3,r),Sa(5,r,r.return));break;case 1:Mr(a,r),Rr(r),u&512&&(Wn||o===null||Cs(o,o.return)),u&64&&Ws&&(r=r.updateQueue,r!==null&&(u=r.callbacks,u!==null&&(o=r.shared.hiddenCallbacks,r.shared.hiddenCallbacks=o===null?u:o.concat(u))));break;case 26:var b=ms;if(Mr(a,r),Rr(r),u&512&&(Wn||o===null||Cs(o,o.return)),u&4){var j=o!==null?o.memoizedState:null;if(u=r.memoizedState,o===null)if(u===null)if(r.stateNode===null){e:{u=r.type,o=r.memoizedProps,b=b.ownerDocument||b;t:switch(u){case"title":j=b.getElementsByTagName("title")[0],(!j||j[ze]||j[qe]||j.namespaceURI==="http://www.w3.org/2000/svg"||j.hasAttribute("itemprop"))&&(j=b.createElement(u),b.head.insertBefore(j,b.querySelector("head > title"))),mr(j,u,o),j[qe]=r,Nn(j),u=j;break e;case"link":var P=rb("link","href",b).get(u+(o.href||""));if(P){for(var J=0;J<P.length;J++)if(j=P[J],j.getAttribute("href")===(o.href==null||o.href===""?null:o.href)&&j.getAttribute("rel")===(o.rel==null?null:o.rel)&&j.getAttribute("title")===(o.title==null?null:o.title)&&j.getAttribute("crossorigin")===(o.crossOrigin==null?null:o.crossOrigin)){P.splice(J,1);break t}}j=b.createElement(u),mr(j,u,o),b.head.appendChild(j);break;case"meta":if(P=rb("meta","content",b).get(u+(o.content||""))){for(J=0;J<P.length;J++)if(j=P[J],j.getAttribute("content")===(o.content==null?null:""+o.content)&&j.getAttribute("name")===(o.name==null?null:o.name)&&j.getAttribute("property")===(o.property==null?null:o.property)&&j.getAttribute("http-equiv")===(o.httpEquiv==null?null:o.httpEquiv)&&j.getAttribute("charset")===(o.charSet==null?null:o.charSet)){P.splice(J,1);break t}}j=b.createElement(u),mr(j,u,o),b.head.appendChild(j);break;default:throw Error(i(468,u))}j[qe]=r,Nn(j),u=j}r.stateNode=u}else sb(b,r.type,r.stateNode);else r.stateNode=nb(b,u,r.memoizedProps);else j!==u?(j===null?o.stateNode!==null&&(o=o.stateNode,o.parentNode.removeChild(o)):j.count--,u===null?sb(b,r.type,r.stateNode):nb(b,u,r.memoizedProps)):u===null&&r.stateNode!==null&&Lf(r,r.memoizedProps,o.memoizedProps)}break;case 27:Mr(a,r),Rr(r),u&512&&(Wn||o===null||Cs(o,o.return)),o!==null&&u&4&&Lf(r,r.memoizedProps,o.memoizedProps);break;case 5:if(Mr(a,r),Rr(r),u&512&&(Wn||o===null||Cs(o,o.return)),r.flags&32){b=r.stateNode;try{Cr(b,"")}catch(tt){pn(r,r.return,tt)}}u&4&&r.stateNode!=null&&(b=r.memoizedProps,Lf(r,b,o!==null?o.memoizedProps:b)),u&1024&&($f=!0);break;case 6:if(Mr(a,r),Rr(r),u&4){if(r.stateNode===null)throw Error(i(162));u=r.memoizedProps,o=r.stateNode;try{o.nodeValue=u}catch(tt){pn(r,r.return,tt)}}break;case 3:if(rd=null,b=ms,ms=td(a.containerInfo),Mr(a,r),ms=b,Rr(r),u&4&&o!==null&&o.memoizedState.isDehydrated)try{sl(a.containerInfo)}catch(tt){pn(r,r.return,tt)}$f&&($f=!1,s0(r));break;case 4:u=ms,ms=td(r.stateNode.containerInfo),Mr(a,r),Rr(r),ms=u;break;case 12:Mr(a,r),Rr(r);break;case 31:Mr(a,r),Rr(r),u&4&&(u=r.updateQueue,u!==null&&(r.updateQueue=null,Pc(r,u)));break;case 13:Mr(a,r),Rr(r),r.child.flags&8192&&r.memoizedState!==null!=(o!==null&&o.memoizedState!==null)&&(Uc=dt()),u&4&&(u=r.updateQueue,u!==null&&(r.updateQueue=null,Pc(r,u)));break;case 22:b=r.memoizedState!==null;var ie=o!==null&&o.memoizedState!==null,ge=Ws,Ee=Wn;if(Ws=ge||b,Wn=Ee||ie,Mr(a,r),Wn=Ee,Ws=ge,Rr(r),u&8192)e:for(a=r.stateNode,a._visibility=b?a._visibility&-2:a._visibility|1,b&&(o===null||ie||Ws||Wn||di(r)),o=null,a=r;;){if(a.tag===5||a.tag===26){if(o===null){ie=o=a;try{if(j=ie.stateNode,b)P=j.style,typeof P.setProperty=="function"?P.setProperty("display","none","important"):P.display="none";else{J=ie.stateNode;var Oe=ie.memoizedProps.style,ve=Oe!=null&&Oe.hasOwnProperty("display")?Oe.display:null;J.style.display=ve==null||typeof ve=="boolean"?"":(""+ve).trim()}}catch(tt){pn(ie,ie.return,tt)}}}else if(a.tag===6){if(o===null){ie=a;try{ie.stateNode.nodeValue=b?"":ie.memoizedProps}catch(tt){pn(ie,ie.return,tt)}}}else if(a.tag===18){if(o===null){ie=a;try{var we=ie.stateNode;b?G0(we,!0):G0(ie.stateNode,!1)}catch(tt){pn(ie,ie.return,tt)}}}else if((a.tag!==22&&a.tag!==23||a.memoizedState===null||a===r)&&a.child!==null){a.child.return=a,a=a.child;continue}if(a===r)break e;for(;a.sibling===null;){if(a.return===null||a.return===r)break e;o===a&&(o=null),a=a.return}o===a&&(o=null),a.sibling.return=a.return,a=a.sibling}u&4&&(u=r.updateQueue,u!==null&&(o=u.retryQueue,o!==null&&(u.retryQueue=null,Pc(r,o))));break;case 19:Mr(a,r),Rr(r),u&4&&(u=r.updateQueue,u!==null&&(r.updateQueue=null,Pc(r,u)));break;case 30:break;case 21:break;default:Mr(a,r),Rr(r)}}function Rr(r){var a=r.flags;if(a&2){try{for(var o,u=r.return;u!==null;){if(Kg(u)){o=u;break}u=u.return}if(o==null)throw Error(i(160));switch(o.tag){case 27:var b=o.stateNode,j=If(r);Hc(r,j,b);break;case 5:var P=o.stateNode;o.flags&32&&(Cr(P,""),o.flags&=-33);var J=If(r);Hc(r,J,P);break;case 3:case 4:var ie=o.stateNode.containerInfo,ge=If(r);zf(r,ge,ie);break;default:throw Error(i(161))}}catch(Ee){pn(r,r.return,Ee)}r.flags&=-3}a&4096&&(r.flags&=-4097)}function s0(r){if(r.subtreeFlags&1024)for(r=r.child;r!==null;){var a=r;s0(a),a.tag===5&&a.flags&1024&&a.stateNode.reset(),r=r.sibling}}function Zs(r,a){if(a.subtreeFlags&8772)for(a=a.child;a!==null;)Zg(r,a.alternate,a),a=a.sibling}function di(r){for(r=r.child;r!==null;){var a=r;switch(a.tag){case 0:case 11:case 14:case 15:Sa(4,a,a.return),di(a);break;case 1:Cs(a,a.return);var o=a.stateNode;typeof o.componentWillUnmount=="function"&&Gg(a,a.return,o),di(a);break;case 27:lo(a.stateNode);case 26:case 5:Cs(a,a.return),di(a);break;case 22:a.memoizedState===null&&di(a);break;case 30:di(a);break;default:di(a)}r=r.sibling}}function Js(r,a,o){for(o=o&&(a.subtreeFlags&8772)!==0,a=a.child;a!==null;){var u=a.alternate,b=r,j=a,P=j.flags;switch(j.tag){case 0:case 11:case 15:Js(b,j,o),Ql(4,j);break;case 1:if(Js(b,j,o),u=j,b=u.stateNode,typeof b.componentDidMount=="function")try{b.componentDidMount()}catch(ge){pn(u,u.return,ge)}if(u=j,b=u.updateQueue,b!==null){var J=u.stateNode;try{var ie=b.shared.hiddenCallbacks;if(ie!==null)for(b.shared.hiddenCallbacks=null,b=0;b<ie.length;b++)Lp(ie[b],J)}catch(ge){pn(u,u.return,ge)}}o&&P&64&&Yg(j),Zl(j,j.return);break;case 27:Wg(j);case 26:case 5:Js(b,j,o),o&&u===null&&P&4&&Xg(j),Zl(j,j.return);break;case 12:Js(b,j,o);break;case 31:Js(b,j,o),o&&P&4&&t0(b,j);break;case 13:Js(b,j,o),o&&P&4&&n0(b,j);break;case 22:j.memoizedState===null&&Js(b,j,o),Zl(j,j.return);break;case 30:break;default:Js(b,j,o)}a=a.sibling}}function Bf(r,a){var o=null;r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),r=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(r=a.memoizedState.cachePool.pool),r!==o&&(r!=null&&r.refCount++,o!=null&&$l(o))}function Hf(r,a){r=null,a.alternate!==null&&(r=a.alternate.memoizedState.cache),a=a.memoizedState.cache,a!==r&&(a.refCount++,r!=null&&$l(r))}function xs(r,a,o,u){if(a.subtreeFlags&10256)for(a=a.child;a!==null;)a0(r,a,o,u),a=a.sibling}function a0(r,a,o,u){var b=a.flags;switch(a.tag){case 0:case 11:case 15:xs(r,a,o,u),b&2048&&Ql(9,a);break;case 1:xs(r,a,o,u);break;case 3:xs(r,a,o,u),b&2048&&(r=null,a.alternate!==null&&(r=a.alternate.memoizedState.cache),a=a.memoizedState.cache,a!==r&&(a.refCount++,r!=null&&$l(r)));break;case 12:if(b&2048){xs(r,a,o,u),r=a.stateNode;try{var j=a.memoizedProps,P=j.id,J=j.onPostCommit;typeof J=="function"&&J(P,a.alternate===null?"mount":"update",r.passiveEffectDuration,-0)}catch(ie){pn(a,a.return,ie)}}else xs(r,a,o,u);break;case 31:xs(r,a,o,u);break;case 13:xs(r,a,o,u);break;case 23:break;case 22:j=a.stateNode,P=a.alternate,a.memoizedState!==null?j._visibility&2?xs(r,a,o,u):Jl(r,a):j._visibility&2?xs(r,a,o,u):(j._visibility|=2,Gi(r,a,o,u,(a.subtreeFlags&10256)!==0||!1)),b&2048&&Bf(P,a);break;case 24:xs(r,a,o,u),b&2048&&Hf(a.alternate,a);break;default:xs(r,a,o,u)}}function Gi(r,a,o,u,b){for(b=b&&((a.subtreeFlags&10256)!==0||!1),a=a.child;a!==null;){var j=r,P=a,J=o,ie=u,ge=P.flags;switch(P.tag){case 0:case 11:case 15:Gi(j,P,J,ie,b),Ql(8,P);break;case 23:break;case 22:var Ee=P.stateNode;P.memoizedState!==null?Ee._visibility&2?Gi(j,P,J,ie,b):Jl(j,P):(Ee._visibility|=2,Gi(j,P,J,ie,b)),b&&ge&2048&&Bf(P.alternate,P);break;case 24:Gi(j,P,J,ie,b),b&&ge&2048&&Hf(P.alternate,P);break;default:Gi(j,P,J,ie,b)}a=a.sibling}}function Jl(r,a){if(a.subtreeFlags&10256)for(a=a.child;a!==null;){var o=r,u=a,b=u.flags;switch(u.tag){case 22:Jl(o,u),b&2048&&Bf(u.alternate,u);break;case 24:Jl(o,u),b&2048&&Hf(u.alternate,u);break;default:Jl(o,u)}a=a.sibling}}var eo=8192;function Xi(r,a,o){if(r.subtreeFlags&eo)for(r=r.child;r!==null;)i0(r,a,o),r=r.sibling}function i0(r,a,o){switch(r.tag){case 26:Xi(r,a,o),r.flags&eo&&r.memoizedState!==null&&L2(o,ms,r.memoizedState,r.memoizedProps);break;case 5:Xi(r,a,o);break;case 3:case 4:var u=ms;ms=td(r.stateNode.containerInfo),Xi(r,a,o),ms=u;break;case 22:r.memoizedState===null&&(u=r.alternate,u!==null&&u.memoizedState!==null?(u=eo,eo=16777216,Xi(r,a,o),eo=u):Xi(r,a,o));break;default:Xi(r,a,o)}}function l0(r){var a=r.alternate;if(a!==null&&(r=a.child,r!==null)){a.child=null;do a=r.sibling,r.sibling=null,r=a;while(r!==null)}}function to(r){var a=r.deletions;if((r.flags&16)!==0){if(a!==null)for(var o=0;o<a.length;o++){var u=a[o];ar=u,c0(u,r)}l0(r)}if(r.subtreeFlags&10256)for(r=r.child;r!==null;)o0(r),r=r.sibling}function o0(r){switch(r.tag){case 0:case 11:case 15:to(r),r.flags&2048&&Sa(9,r,r.return);break;case 3:to(r);break;case 12:to(r);break;case 22:var a=r.stateNode;r.memoizedState!==null&&a._visibility&2&&(r.return===null||r.return.tag!==13)?(a._visibility&=-3,qc(r)):to(r);break;default:to(r)}}function qc(r){var a=r.deletions;if((r.flags&16)!==0){if(a!==null)for(var o=0;o<a.length;o++){var u=a[o];ar=u,c0(u,r)}l0(r)}for(r=r.child;r!==null;){switch(a=r,a.tag){case 0:case 11:case 15:Sa(8,a,a.return),qc(a);break;case 22:o=a.stateNode,o._visibility&2&&(o._visibility&=-3,qc(a));break;default:qc(a)}r=r.sibling}}function c0(r,a){for(;ar!==null;){var o=ar;switch(o.tag){case 0:case 11:case 15:Sa(8,o,a);break;case 23:case 22:if(o.memoizedState!==null&&o.memoizedState.cachePool!==null){var u=o.memoizedState.cachePool.pool;u!=null&&u.refCount++}break;case 24:$l(o.memoizedState.cache)}if(u=o.child,u!==null)u.return=o,ar=u;else e:for(o=r;ar!==null;){u=ar;var b=u.sibling,j=u.return;if(Jg(u),u===o){ar=null;break e}if(b!==null){b.return=j,ar=b;break e}ar=j}}}var W5={getCacheForType:function(r){var a=fr(Gn),o=a.data.get(r);return o===void 0&&(o=r(),a.data.set(r,o)),o},cacheSignal:function(){return fr(Gn).controller.signal}},Q5=typeof WeakMap=="function"?WeakMap:Map,fn=0,kn=null,Ut=null,Xt=0,xn=0,Xr=null,Ca=!1,Ki=!1,Pf=!1,ea=0,qn=0,Ea=0,ui=0,qf=0,Kr=0,Wi=0,no=null,Or=null,Uf=!1,Uc=0,d0=0,Vc=1/0,Fc=null,Ta=null,nr=0,_a=null,Qi=null,ta=0,Vf=0,Ff=null,u0=null,ro=0,Yf=null;function Wr(){return(fn&2)!==0&&Xt!==0?Xt&-Xt:R.T!==null?Zf():Ue()}function f0(){if(Kr===0)if((Xt&536870912)===0||Qt){var r=Cn;Cn<<=1,(Cn&3932160)===0&&(Cn=262144),Kr=r}else Kr=536870912;return r=Yr.current,r!==null&&(r.flags|=32),Kr}function Dr(r,a,o){(r===kn&&(xn===2||xn===9)||r.cancelPendingCommit!==null)&&(Zi(r,0),Aa(r,Xt,Kr,!1)),dn(r,o),((fn&2)===0||r!==kn)&&(r===kn&&((fn&2)===0&&(ui|=o),qn===4&&Aa(r,Xt,Kr,!1)),Es(r))}function h0(r,a,o){if((fn&6)!==0)throw Error(i(327));var u=!o&&(a&127)===0&&(a&r.expiredLanes)===0||At(r,a),b=u?e2(r,a):Xf(r,a,!0),j=u;do{if(b===0){Ki&&!u&&Aa(r,a,0,!1);break}else{if(o=r.current.alternate,j&&!Z5(o)){b=Xf(r,a,!1),j=!1;continue}if(b===2){if(j=a,r.errorRecoveryDisabledLanes&j)var P=0;else P=r.pendingLanes&-536870913,P=P!==0?P:P&536870912?536870912:0;if(P!==0){a=P;e:{var J=r;b=no;var ie=J.current.memoizedState.isDehydrated;if(ie&&(Zi(J,P).flags|=256),P=Xf(J,P,!1),P!==2){if(Pf&&!ie){J.errorRecoveryDisabledLanes|=j,ui|=j,b=4;break e}j=Or,Or=b,j!==null&&(Or===null?Or=j:Or.push.apply(Or,j))}b=P}if(j=!1,b!==2)continue}}if(b===1){Zi(r,0),Aa(r,a,0,!0);break}e:{switch(u=r,j=b,j){case 0:case 1:throw Error(i(345));case 4:if((a&4194048)!==a)break;case 6:Aa(u,a,Kr,!Ca);break e;case 2:Or=null;break;case 3:case 5:break;default:throw Error(i(329))}if((a&62914560)===a&&(b=Uc+300-dt(),10<b)){if(Aa(u,a,Kr,!Ca),vt(u,0,!0)!==0)break e;ta=a,u.timeoutHandle=V0(m0.bind(null,u,o,Or,Fc,Uf,a,Kr,ui,Wi,Ca,j,"Throttled",-0,0),b);break e}m0(u,o,Or,Fc,Uf,a,Kr,ui,Wi,Ca,j,null,-0,0)}}break}while(!0);Es(r)}function m0(r,a,o,u,b,j,P,J,ie,ge,Ee,Oe,ve,we){if(r.timeoutHandle=-1,Oe=a.subtreeFlags,Oe&8192||(Oe&16785408)===16785408){Oe={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Ye},i0(a,j,Oe);var tt=(j&62914560)===j?Uc-dt():(j&4194048)===j?d0-dt():0;if(tt=I2(Oe,tt),tt!==null){ta=j,r.cancelPendingCommit=tt(w0.bind(null,r,a,j,o,u,b,P,J,ie,Ee,Oe,null,ve,we)),Aa(r,j,P,!ge);return}}w0(r,a,j,o,u,b,P,J,ie)}function Z5(r){for(var a=r;;){var o=a.tag;if((o===0||o===11||o===15)&&a.flags&16384&&(o=a.updateQueue,o!==null&&(o=o.stores,o!==null)))for(var u=0;u<o.length;u++){var b=o[u],j=b.getSnapshot;b=b.value;try{if(!Vr(j(),b))return!1}catch{return!1}}if(o=a.child,a.subtreeFlags&16384&&o!==null)o.return=a,a=o;else{if(a===r)break;for(;a.sibling===null;){if(a.return===null||a.return===r)return!0;a=a.return}a.sibling.return=a.return,a=a.sibling}}return!0}function Aa(r,a,o,u){a&=~qf,a&=~ui,r.suspendedLanes|=a,r.pingedLanes&=~a,u&&(r.warmLanes|=a),u=r.expirationTimes;for(var b=a;0<b;){var j=31-_t(b),P=1<<j;u[j]=-1,b&=~P}o!==0&&Nt(r,o,a)}function Yc(){return(fn&6)===0?(so(0),!1):!0}function Gf(){if(Ut!==null){if(xn===0)var r=Ut.return;else r=Ut,Vs=ni=null,cf(r),qi=null,Hl=0,r=Ut;for(;r!==null;)Fg(r.alternate,r),r=r.return;Ut=null}}function Zi(r,a){var o=r.timeoutHandle;o!==-1&&(r.timeoutHandle=-1,b2(o)),o=r.cancelPendingCommit,o!==null&&(r.cancelPendingCommit=null,o()),ta=0,Gf(),kn=r,Ut=o=qs(r.current,null),Xt=a,xn=0,Xr=null,Ca=!1,Ki=At(r,a),Pf=!1,Wi=Kr=qf=ui=Ea=qn=0,Or=no=null,Uf=!1,(a&8)!==0&&(a|=a&32);var u=r.entangledLanes;if(u!==0)for(r=r.entanglements,u&=a;0<u;){var b=31-_t(u),j=1<<b;a|=r[b],u&=~j}return ea=a,hc(),o}function x0(r,a){Lt=null,R.H=Xl,a===Pi||a===jc?(a=Mp(),xn=3):a===Wu?(a=Mp(),xn=4):xn=a===Sf?8:a!==null&&typeof a=="object"&&typeof a.then=="function"?6:1,Xr=a,Ut===null&&(qn=1,Lc(r,rs(a,r.current)))}function p0(){var r=Yr.current;return r===null?!0:(Xt&4194048)===Xt?ls===null:(Xt&62914560)===Xt||(Xt&536870912)!==0?r===ls:!1}function g0(){var r=R.H;return R.H=Xl,r===null?Xl:r}function b0(){var r=R.A;return R.A=W5,r}function Gc(){qn=4,Ca||(Xt&4194048)!==Xt&&Yr.current!==null||(Ki=!0),(Ea&134217727)===0&&(ui&134217727)===0||kn===null||Aa(kn,Xt,Kr,!1)}function Xf(r,a,o){var u=fn;fn|=2;var b=g0(),j=b0();(kn!==r||Xt!==a)&&(Fc=null,Zi(r,a)),a=!1;var P=qn;e:do try{if(xn!==0&&Ut!==null){var J=Ut,ie=Xr;switch(xn){case 8:Gf(),P=6;break e;case 3:case 2:case 9:case 6:Yr.current===null&&(a=!0);var ge=xn;if(xn=0,Xr=null,Ji(r,J,ie,ge),o&&Ki){P=0;break e}break;default:ge=xn,xn=0,Xr=null,Ji(r,J,ie,ge)}}J5(),P=qn;break}catch(Ee){x0(r,Ee)}while(!0);return a&&r.shellSuspendCounter++,Vs=ni=null,fn=u,R.H=b,R.A=j,Ut===null&&(kn=null,Xt=0,hc()),P}function J5(){for(;Ut!==null;)y0(Ut)}function e2(r,a){var o=fn;fn|=2;var u=g0(),b=b0();kn!==r||Xt!==a?(Fc=null,Vc=dt()+500,Zi(r,a)):Ki=At(r,a);e:do try{if(xn!==0&&Ut!==null){a=Ut;var j=Xr;t:switch(xn){case 1:xn=0,Xr=null,Ji(r,a,j,1);break;case 2:case 9:if(_p(j)){xn=0,Xr=null,v0(a);break}a=function(){xn!==2&&xn!==9||kn!==r||(xn=7),Es(r)},j.then(a,a);break e;case 3:xn=7;break e;case 4:xn=5;break e;case 7:_p(j)?(xn=0,Xr=null,v0(a)):(xn=0,Xr=null,Ji(r,a,j,7));break;case 5:var P=null;switch(Ut.tag){case 26:P=Ut.memoizedState;case 5:case 27:var J=Ut;if(P?ab(P):J.stateNode.complete){xn=0,Xr=null;var ie=J.sibling;if(ie!==null)Ut=ie;else{var ge=J.return;ge!==null?(Ut=ge,Xc(ge)):Ut=null}break t}}xn=0,Xr=null,Ji(r,a,j,5);break;case 6:xn=0,Xr=null,Ji(r,a,j,6);break;case 8:Gf(),qn=6;break e;default:throw Error(i(462))}}t2();break}catch(Ee){x0(r,Ee)}while(!0);return Vs=ni=null,R.H=u,R.A=b,fn=o,Ut!==null?0:(kn=null,Xt=0,hc(),qn)}function t2(){for(;Ut!==null&&!_e();)y0(Ut)}function y0(r){var a=Ug(r.alternate,r,ea);r.memoizedProps=r.pendingProps,a===null?Xc(r):Ut=a}function v0(r){var a=r,o=a.alternate;switch(a.tag){case 15:case 0:a=zg(o,a,a.pendingProps,a.type,void 0,Xt);break;case 11:a=zg(o,a,a.pendingProps,a.type.render,a.ref,Xt);break;case 5:cf(a);default:Fg(o,a),a=Ut=bp(a,ea),a=Ug(o,a,ea)}r.memoizedProps=r.pendingProps,a===null?Xc(r):Ut=a}function Ji(r,a,o,u){Vs=ni=null,cf(a),qi=null,Hl=0;var b=a.return;try{if(U5(r,b,a,o,Xt)){qn=1,Lc(r,rs(o,r.current)),Ut=null;return}}catch(j){if(b!==null)throw Ut=b,j;qn=1,Lc(r,rs(o,r.current)),Ut=null;return}a.flags&32768?(Qt||u===1?r=!0:Ki||(Xt&536870912)!==0?r=!1:(Ca=r=!0,(u===2||u===9||u===3||u===6)&&(u=Yr.current,u!==null&&u.tag===13&&(u.flags|=16384))),j0(a,r)):Xc(a)}function Xc(r){var a=r;do{if((a.flags&32768)!==0){j0(a,Ca);return}r=a.return;var o=Y5(a.alternate,a,ea);if(o!==null){Ut=o;return}if(a=a.sibling,a!==null){Ut=a;return}Ut=a=r}while(a!==null);qn===0&&(qn=5)}function j0(r,a){do{var o=G5(r.alternate,r);if(o!==null){o.flags&=32767,Ut=o;return}if(o=r.return,o!==null&&(o.flags|=32768,o.subtreeFlags=0,o.deletions=null),!a&&(r=r.sibling,r!==null)){Ut=r;return}Ut=r=o}while(r!==null);qn=6,Ut=null}function w0(r,a,o,u,b,j,P,J,ie){r.cancelPendingCommit=null;do Kc();while(nr!==0);if((fn&6)!==0)throw Error(i(327));if(a!==null){if(a===r.current)throw Error(i(177));if(j=a.lanes|a.childLanes,j|=Lu,Dn(r,o,j,P,J,ie),r===kn&&(Ut=kn=null,Xt=0),Qi=a,_a=r,ta=o,Vf=j,Ff=b,u0=u,(a.subtreeFlags&10256)!==0||(a.flags&10256)!==0?(r.callbackNode=null,r.callbackPriority=0,a2(Fe,function(){return E0(),null})):(r.callbackNode=null,r.callbackPriority=0),u=(a.flags&13878)!==0,(a.subtreeFlags&13878)!==0||u){u=R.T,R.T=null,b=F.p,F.p=2,P=fn,fn|=4;try{X5(r,a,o)}finally{fn=P,F.p=b,R.T=u}}nr=1,N0(),k0(),S0()}}function N0(){if(nr===1){nr=0;var r=_a,a=Qi,o=(a.flags&13878)!==0;if((a.subtreeFlags&13878)!==0||o){o=R.T,R.T=null;var u=F.p;F.p=2;var b=fn;fn|=4;try{r0(a,r);var j=ih,P=cp(r.containerInfo),J=j.focusedElem,ie=j.selectionRange;if(P!==J&&J&&J.ownerDocument&&op(J.ownerDocument.documentElement,J)){if(ie!==null&&Au(J)){var ge=ie.start,Ee=ie.end;if(Ee===void 0&&(Ee=ge),"selectionStart"in J)J.selectionStart=ge,J.selectionEnd=Math.min(Ee,J.value.length);else{var Oe=J.ownerDocument||document,ve=Oe&&Oe.defaultView||window;if(ve.getSelection){var we=ve.getSelection(),tt=J.textContent.length,Ct=Math.min(ie.start,tt),wn=ie.end===void 0?Ct:Math.min(ie.end,tt);!we.extend&&Ct>wn&&(P=wn,wn=Ct,Ct=P);var ue=lp(J,Ct),ce=lp(J,wn);if(ue&&ce&&(we.rangeCount!==1||we.anchorNode!==ue.node||we.anchorOffset!==ue.offset||we.focusNode!==ce.node||we.focusOffset!==ce.offset)){var pe=Oe.createRange();pe.setStart(ue.node,ue.offset),we.removeAllRanges(),Ct>wn?(we.addRange(pe),we.extend(ce.node,ce.offset)):(pe.setEnd(ce.node,ce.offset),we.addRange(pe))}}}}for(Oe=[],we=J;we=we.parentNode;)we.nodeType===1&&Oe.push({element:we,left:we.scrollLeft,top:we.scrollTop});for(typeof J.focus=="function"&&J.focus(),J=0;J<Oe.length;J++){var Me=Oe[J];Me.element.scrollLeft=Me.left,Me.element.scrollTop=Me.top}}ld=!!ah,ih=ah=null}finally{fn=b,F.p=u,R.T=o}}r.current=a,nr=2}}function k0(){if(nr===2){nr=0;var r=_a,a=Qi,o=(a.flags&8772)!==0;if((a.subtreeFlags&8772)!==0||o){o=R.T,R.T=null;var u=F.p;F.p=2;var b=fn;fn|=4;try{Zg(r,a.alternate,a)}finally{fn=b,F.p=u,R.T=o}}nr=3}}function S0(){if(nr===4||nr===3){nr=0,st();var r=_a,a=Qi,o=ta,u=u0;(a.subtreeFlags&10256)!==0||(a.flags&10256)!==0?nr=5:(nr=0,Qi=_a=null,C0(r,r.pendingLanes));var b=r.pendingLanes;if(b===0&&(Ta=null),$e(o),a=a.stateNode,gt&&typeof gt.onCommitFiberRoot=="function")try{gt.onCommitFiberRoot(Tt,a,void 0,(a.current.flags&128)===128)}catch{}if(u!==null){a=R.T,b=F.p,F.p=2,R.T=null;try{for(var j=r.onRecoverableError,P=0;P<u.length;P++){var J=u[P];j(J.value,{componentStack:J.stack})}}finally{R.T=a,F.p=b}}(ta&3)!==0&&Kc(),Es(r),b=r.pendingLanes,(o&261930)!==0&&(b&42)!==0?r===Yf?ro++:(ro=0,Yf=r):ro=0,so(0)}}function C0(r,a){(r.pooledCacheLanes&=a)===0&&(a=r.pooledCache,a!=null&&(r.pooledCache=null,$l(a)))}function Kc(){return N0(),k0(),S0(),E0()}function E0(){if(nr!==5)return!1;var r=_a,a=Vf;Vf=0;var o=$e(ta),u=R.T,b=F.p;try{F.p=32>o?32:o,R.T=null,o=Ff,Ff=null;var j=_a,P=ta;if(nr=0,Qi=_a=null,ta=0,(fn&6)!==0)throw Error(i(331));var J=fn;if(fn|=4,o0(j.current),a0(j,j.current,P,o),fn=J,so(0,!1),gt&&typeof gt.onPostCommitFiberRoot=="function")try{gt.onPostCommitFiberRoot(Tt,j)}catch{}return!0}finally{F.p=b,R.T=u,C0(r,a)}}function T0(r,a,o){a=rs(o,a),a=kf(r.stateNode,a,2),r=wa(r,a,2),r!==null&&(dn(r,2),Es(r))}function pn(r,a,o){if(r.tag===3)T0(r,r,o);else for(;a!==null;){if(a.tag===3){T0(a,r,o);break}else if(a.tag===1){var u=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(Ta===null||!Ta.has(u))){r=rs(o,r),o=_g(2),u=wa(a,o,2),u!==null&&(Ag(o,u,a,r),dn(u,2),Es(u));break}}a=a.return}}function Kf(r,a,o){var u=r.pingCache;if(u===null){u=r.pingCache=new Q5;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(o)||(Pf=!0,b.add(o),r=n2.bind(null,r,a,o),a.then(r,r))}function n2(r,a,o){var u=r.pingCache;u!==null&&u.delete(a),r.pingedLanes|=r.suspendedLanes&o,r.warmLanes&=~o,kn===r&&(Xt&o)===o&&(qn===4||qn===3&&(Xt&62914560)===Xt&&300>dt()-Uc?(fn&2)===0&&Zi(r,0):qf|=o,Wi===Xt&&(Wi=0)),Es(r)}function _0(r,a){a===0&&(a=On()),r=Ja(r,a),r!==null&&(dn(r,a),Es(r))}function r2(r){var a=r.memoizedState,o=0;a!==null&&(o=a.retryLane),_0(r,o)}function s2(r,a){var o=0;switch(r.tag){case 31:case 13:var u=r.stateNode,b=r.memoizedState;b!==null&&(o=b.retryLane);break;case 19:u=r.stateNode;break;case 22:u=r.stateNode._retryCache;break;default:throw Error(i(314))}u!==null&&u.delete(a),_0(r,o)}function a2(r,a){return Rt(r,a)}var Wc=null,el=null,Wf=!1,Qc=!1,Qf=!1,Ma=0;function Es(r){r!==el&&r.next===null&&(el===null?Wc=el=r:el=el.next=r),Qc=!0,Wf||(Wf=!0,l2())}function so(r,a){if(!Qf&&Qc){Qf=!0;do for(var o=!1,u=Wc;u!==null;){if(r!==0){var b=u.pendingLanes;if(b===0)var j=0;else{var P=u.suspendedLanes,J=u.pingedLanes;j=(1<<31-_t(42|r)+1)-1,j&=b&~(P&~J),j=j&201326741?j&201326741|1:j?j|2:0}j!==0&&(o=!0,O0(u,j))}else j=Xt,j=vt(u,u===kn?j:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(j&3)===0||At(u,j)||(o=!0,O0(u,j));u=u.next}while(o);Qf=!1}}function i2(){A0()}function A0(){Qc=Wf=!1;var r=0;Ma!==0&&g2()&&(r=Ma);for(var a=dt(),o=null,u=Wc;u!==null;){var b=u.next,j=M0(u,a);j===0?(u.next=null,o===null?Wc=b:o.next=b,b===null&&(el=o)):(o=u,(r!==0||(j&3)!==0)&&(Qc=!0)),u=b}nr!==0&&nr!==5||so(r),Ma!==0&&(Ma=0)}function M0(r,a){for(var o=r.suspendedLanes,u=r.pingedLanes,b=r.expirationTimes,j=r.pendingLanes&-62914561;0<j;){var P=31-_t(j),J=1<<P,ie=b[P];ie===-1?((J&o)===0||(J&u)!==0)&&(b[P]=Dt(J,a)):ie<=a&&(r.expiredLanes|=J),j&=~J}if(a=kn,o=Xt,o=vt(r,r===a?o:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),u=r.callbackNode,o===0||r===a&&(xn===2||xn===9)||r.cancelPendingCommit!==null)return u!==null&&u!==null&&re(u),r.callbackNode=null,r.callbackPriority=0;if((o&3)===0||At(r,o)){if(a=o&-o,a===r.callbackPriority)return a;switch(u!==null&&re(u),$e(o)){case 2:case 8:o=Ae;break;case 32:o=Fe;break;case 268435456:o=xt;break;default:o=Fe}return u=R0.bind(null,r),o=Rt(o,u),r.callbackPriority=a,r.callbackNode=o,a}return u!==null&&u!==null&&re(u),r.callbackPriority=2,r.callbackNode=null,2}function R0(r,a){if(nr!==0&&nr!==5)return r.callbackNode=null,r.callbackPriority=0,null;var o=r.callbackNode;if(Kc()&&r.callbackNode!==o)return null;var u=Xt;return u=vt(r,r===kn?u:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),u===0?null:(h0(r,u,a),M0(r,dt()),r.callbackNode!=null&&r.callbackNode===o?R0.bind(null,r):null)}function O0(r,a){if(Kc())return null;h0(r,a,!0)}function l2(){y2(function(){(fn&6)!==0?Rt(ye,i2):A0()})}function Zf(){if(Ma===0){var r=Bi;r===0&&(r=Hn,Hn<<=1,(Hn&261888)===0&&(Hn=256)),Ma=r}return Ma}function D0(r){return r==null||typeof r=="symbol"||typeof r=="boolean"?null:typeof r=="function"?r:Ie(""+r)}function L0(r,a){var o=a.ownerDocument.createElement("input");return o.name=a.name,o.value=a.value,r.id&&o.setAttribute("form",r.id),a.parentNode.insertBefore(o,a),r=new FormData(r),o.parentNode.removeChild(o),r}function o2(r,a,o,u,b){if(a==="submit"&&o&&o.stateNode===b){var j=D0((b[Je]||null).action),P=u.submitter;P&&(a=(a=P[Je]||null)?D0(a.formAction):P.getAttribute("formAction"),a!==null&&(j=a,P=null));var J=new Ot("action","action",null,u,b);r.push({event:J,listeners:[{instance:null,listener:function(){if(u.defaultPrevented){if(Ma!==0){var ie=P?L0(b,P):new FormData(b);bf(o,{pending:!0,data:ie,method:b.method,action:j},null,ie)}}else typeof j=="function"&&(J.preventDefault(),ie=P?L0(b,P):new FormData(b),bf(o,{pending:!0,data:ie,method:b.method,action:j},j,ie))},currentTarget:b}]})}}for(var Jf=0;Jf<Du.length;Jf++){var eh=Du[Jf],c2=eh.toLowerCase(),d2=eh[0].toUpperCase()+eh.slice(1);hs(c2,"on"+d2)}hs(fp,"onAnimationEnd"),hs(hp,"onAnimationIteration"),hs(mp,"onAnimationStart"),hs("dblclick","onDoubleClick"),hs("focusin","onFocus"),hs("focusout","onBlur"),hs(C5,"onTransitionRun"),hs(E5,"onTransitionStart"),hs(T5,"onTransitionCancel"),hs(xp,"onTransitionEnd"),Te("onMouseEnter",["mouseout","mouseover"]),Te("onMouseLeave",["mouseout","mouseover"]),Te("onPointerEnter",["pointerout","pointerover"]),Te("onPointerLeave",["pointerout","pointerover"]),de("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),de("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),de("onBeforeInput",["compositionend","keypress","textInput","paste"]),de("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),de("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),de("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ao="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(" "),u2=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(ao));function I0(r,a){a=(a&4)!==0;for(var o=0;o<r.length;o++){var u=r[o],b=u.event;u=u.listeners;e:{var j=void 0;if(a)for(var P=u.length-1;0<=P;P--){var J=u[P],ie=J.instance,ge=J.currentTarget;if(J=J.listener,ie!==j&&b.isPropagationStopped())break e;j=J,b.currentTarget=ge;try{j(b)}catch(Ee){fc(Ee)}b.currentTarget=null,j=ie}else for(P=0;P<u.length;P++){if(J=u[P],ie=J.instance,ge=J.currentTarget,J=J.listener,ie!==j&&b.isPropagationStopped())break e;j=J,b.currentTarget=ge;try{j(b)}catch(Ee){fc(Ee)}b.currentTarget=null,j=ie}}}}function Vt(r,a){var o=a[Zt];o===void 0&&(o=a[Zt]=new Set);var u=r+"__bubble";o.has(u)||(z0(a,r,2,!1),o.add(u))}function th(r,a,o){var u=0;a&&(u|=4),z0(o,r,u,a)}var Zc="_reactListening"+Math.random().toString(36).slice(2);function nh(r){if(!r[Zc]){r[Zc]=!0,yr.forEach(function(o){o!=="selectionchange"&&(u2.has(o)||th(o,!1,r),th(o,!0,r))});var a=r.nodeType===9?r:r.ownerDocument;a===null||a[Zc]||(a[Zc]=!0,th("selectionchange",!1,a))}}function z0(r,a,o,u){switch(fb(a)){case 2:var b=B2;break;case 8:b=H2;break;default:b=gh}o=b.bind(null,a,o,r),b=void 0,!ct||a!=="touchstart"&&a!=="touchmove"&&a!=="wheel"||(b=!0),u?b!==void 0?r.addEventListener(a,o,{capture:!0,passive:b}):r.addEventListener(a,o,!0):b!==void 0?r.addEventListener(a,o,{passive:b}):r.addEventListener(a,o,!1)}function rh(r,a,o,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 J=u.stateNode.containerInfo;if(J===b)break;if(P===4)for(P=u.return;P!==null;){var ie=P.tag;if((ie===3||ie===4)&&P.stateNode.containerInfo===b)return;P=P.return}for(;J!==null;){if(P=kt(J),P===null)return;if(ie=P.tag,ie===5||ie===6||ie===26||ie===27){u=j=P;continue e}J=J.parentNode}}u=u.return}Ge(function(){var ge=j,Ee=sn(o),Oe=[];e:{var ve=pp.get(r);if(ve!==void 0){var we=Ot,tt=r;switch(r){case"keypress":if(It(o)===0)break e;case"keydown":case"keyup":we=s5;break;case"focusin":tt="focus",we=Ur;break;case"focusout":tt="blur",we=Ur;break;case"beforeblur":case"afterblur":we=Ur;break;case"click":if(o.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":we=sr;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":we=dc;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":we=l5;break;case fp:case hp:case mp:we=KN;break;case xp:we=c5;break;case"scroll":case"scrollend":we=lt;break;case"wheel":we=u5;break;case"copy":case"cut":case"paste":we=QN;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":we=Gx;break;case"toggle":case"beforetoggle":we=h5}var Ct=(a&4)!==0,wn=!Ct&&(r==="scroll"||r==="scrollend"),ue=Ct?ve!==null?ve+"Capture":null:ve;Ct=[];for(var ce=ge,pe;ce!==null;){var Me=ce;if(pe=Me.stateNode,Me=Me.tag,Me!==5&&Me!==26&&Me!==27||pe===null||ue===null||(Me=Be(ce,ue),Me!=null&&Ct.push(io(ce,Me,pe))),wn)break;ce=ce.return}0<Ct.length&&(ve=new we(ve,tt,null,o,Ee),Oe.push({event:ve,listeners:Ct}))}}if((a&7)===0){e:{if(ve=r==="mouseover"||r==="pointerover",we=r==="mouseout"||r==="pointerout",ve&&o!==it&&(tt=o.relatedTarget||o.fromElement)&&(kt(tt)||tt[Wt]))break e;if((we||ve)&&(ve=Ee.window===Ee?Ee:(ve=Ee.ownerDocument)?ve.defaultView||ve.parentWindow:window,we?(tt=o.relatedTarget||o.toElement,we=ge,tt=tt?kt(tt):null,tt!==null&&(wn=d(tt),Ct=tt.tag,tt!==wn||Ct!==5&&Ct!==27&&Ct!==6)&&(tt=null)):(we=null,tt=ge),we!==tt)){if(Ct=sr,Me="onMouseLeave",ue="onMouseEnter",ce="mouse",(r==="pointerout"||r==="pointerover")&&(Ct=Gx,Me="onPointerLeave",ue="onPointerEnter",ce="pointer"),wn=we==null?ve:_n(we),pe=tt==null?ve:_n(tt),ve=new Ct(Me,ce+"leave",we,o,Ee),ve.target=wn,ve.relatedTarget=pe,Me=null,kt(Ee)===ge&&(Ct=new Ct(ue,ce+"enter",tt,o,Ee),Ct.target=pe,Ct.relatedTarget=wn,Me=Ct),wn=Me,we&&tt)t:{for(Ct=f2,ue=we,ce=tt,pe=0,Me=ue;Me;Me=Ct(Me))pe++;Me=0;for(var bt=ce;bt;bt=Ct(bt))Me++;for(;0<pe-Me;)ue=Ct(ue),pe--;for(;0<Me-pe;)ce=Ct(ce),Me--;for(;pe--;){if(ue===ce||ce!==null&&ue===ce.alternate){Ct=ue;break t}ue=Ct(ue),ce=Ct(ce)}Ct=null}else Ct=null;we!==null&&$0(Oe,ve,we,Ct,!1),tt!==null&&wn!==null&&$0(Oe,wn,tt,Ct,!0)}}e:{if(ve=ge?_n(ge):window,we=ve.nodeName&&ve.nodeName.toLowerCase(),we==="select"||we==="input"&&ve.type==="file")var ln=tp;else if(Jx(ve))if(np)ln=N5;else{ln=j5;var ot=v5}else we=ve.nodeName,!we||we.toLowerCase()!=="input"||ve.type!=="checkbox"&&ve.type!=="radio"?ge&&Ps(ge.elementType)&&(ln=tp):ln=w5;if(ln&&(ln=ln(r,ge))){ep(Oe,ln,o,Ee);break e}ot&&ot(r,ve,ge),r==="focusout"&&ge&&ve.type==="number"&&ge.memoizedProps.value!=null&&Sr(ve,"number",ve.value)}switch(ot=ge?_n(ge):window,r){case"focusin":(Jx(ot)||ot.contentEditable==="true")&&(Mi=ot,Mu=ge,Ll=null);break;case"focusout":Ll=Mu=Mi=null;break;case"mousedown":Ru=!0;break;case"contextmenu":case"mouseup":case"dragend":Ru=!1,dp(Oe,o,Ee);break;case"selectionchange":if(S5)break;case"keydown":case"keyup":dp(Oe,o,Ee)}var zt;if(Eu)e:{switch(r){case"compositionstart":var Kt="onCompositionStart";break e;case"compositionend":Kt="onCompositionEnd";break e;case"compositionupdate":Kt="onCompositionUpdate";break e}Kt=void 0}else Ai?Qx(r,o)&&(Kt="onCompositionEnd"):r==="keydown"&&o.keyCode===229&&(Kt="onCompositionStart");Kt&&(Xx&&o.locale!=="ko"&&(Ai||Kt!=="onCompositionStart"?Kt==="onCompositionEnd"&&Ai&&(zt=Gt()):(Xe=Ee,at="value"in Xe?Xe.value:Xe.textContent,Ai=!0)),ot=Jc(ge,Kt),0<ot.length&&(Kt=new Yx(Kt,r,null,o,Ee),Oe.push({event:Kt,listeners:ot}),zt?Kt.data=zt:(zt=Zx(o),zt!==null&&(Kt.data=zt)))),(zt=x5?p5(r,o):g5(r,o))&&(Kt=Jc(ge,"onBeforeInput"),0<Kt.length&&(ot=new Yx("onBeforeInput","beforeinput",null,o,Ee),Oe.push({event:ot,listeners:Kt}),ot.data=zt)),o2(Oe,r,ge,o,Ee)}I0(Oe,a)})}function io(r,a,o){return{instance:r,listener:a,currentTarget:o}}function Jc(r,a){for(var o=a+"Capture",u=[];r!==null;){var b=r,j=b.stateNode;if(b=b.tag,b!==5&&b!==26&&b!==27||j===null||(b=Be(r,o),b!=null&&u.unshift(io(r,b,j)),b=Be(r,a),b!=null&&u.push(io(r,b,j))),r.tag===3)return u;r=r.return}return[]}function f2(r){if(r===null)return null;do r=r.return;while(r&&r.tag!==5&&r.tag!==27);return r||null}function $0(r,a,o,u,b){for(var j=a._reactName,P=[];o!==null&&o!==u;){var J=o,ie=J.alternate,ge=J.stateNode;if(J=J.tag,ie!==null&&ie===u)break;J!==5&&J!==26&&J!==27||ge===null||(ie=ge,b?(ge=Be(o,j),ge!=null&&P.unshift(io(o,ge,ie))):b||(ge=Be(o,j),ge!=null&&P.push(io(o,ge,ie)))),o=o.return}P.length!==0&&r.push({event:a,listeners:P})}var h2=/\r\n?/g,m2=/\u0000|\uFFFD/g;function B0(r){return(typeof r=="string"?r:""+r).replace(h2,`
|
|
9
|
-
`).replace(m2,"")}function H0(r,a){return a=B0(a),B0(r)===a}function jn(r,a,o,u,b,j){switch(o){case"children":typeof u=="string"?a==="body"||a==="textarea"&&u===""||Cr(r,u):(typeof u=="number"||typeof u=="bigint")&&a!=="body"&&Cr(r,""+u);break;case"className":Ns(r,"class",u);break;case"tabIndex":Ns(r,"tabindex",u);break;case"dir":case"role":case"viewBox":case"width":case"height":Ns(r,o,u);break;case"style":xa(r,u,j);break;case"data":if(a!=="object"){Ns(r,"data",u);break}case"src":case"href":if(u===""&&(a!=="a"||o!=="href")){r.removeAttribute(o);break}if(u==null||typeof u=="function"||typeof u=="symbol"||typeof u=="boolean"){r.removeAttribute(o);break}u=Ie(""+u),r.setAttribute(o,u);break;case"action":case"formAction":if(typeof u=="function"){r.setAttribute(o,"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"&&(o==="formAction"?(a!=="input"&&jn(r,a,"name",b.name,b,null),jn(r,a,"formEncType",b.formEncType,b,null),jn(r,a,"formMethod",b.formMethod,b,null),jn(r,a,"formTarget",b.formTarget,b,null)):(jn(r,a,"encType",b.encType,b,null),jn(r,a,"method",b.method,b,null),jn(r,a,"target",b.target,b,null)));if(u==null||typeof u=="symbol"||typeof u=="boolean"){r.removeAttribute(o);break}u=Ie(""+u),r.setAttribute(o,u);break;case"onClick":u!=null&&(r.onclick=Ye);break;case"onScroll":u!=null&&Vt("scroll",r);break;case"onScrollEnd":u!=null&&Vt("scrollend",r);break;case"dangerouslySetInnerHTML":if(u!=null){if(typeof u!="object"||!("__html"in u))throw Error(i(61));if(o=u.__html,o!=null){if(b.children!=null)throw Error(i(60));r.innerHTML=o}}break;case"multiple":r.multiple=u&&typeof u!="function"&&typeof u!="symbol";break;case"muted":r.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"){r.removeAttribute("xlink:href");break}o=Ie(""+u),r.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",o);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"?r.setAttribute(o,""+u):r.removeAttribute(o);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"?r.setAttribute(o,""):r.removeAttribute(o);break;case"capture":case"download":u===!0?r.setAttribute(o,""):u!==!1&&u!=null&&typeof u!="function"&&typeof u!="symbol"?r.setAttribute(o,u):r.removeAttribute(o);break;case"cols":case"rows":case"size":case"span":u!=null&&typeof u!="function"&&typeof u!="symbol"&&!isNaN(u)&&1<=u?r.setAttribute(o,u):r.removeAttribute(o);break;case"rowSpan":case"start":u==null||typeof u=="function"||typeof u=="symbol"||isNaN(u)?r.removeAttribute(o):r.setAttribute(o,u);break;case"popover":Vt("beforetoggle",r),Vt("toggle",r),Nr(r,"popover",u);break;case"xlinkActuate":xr(r,"http://www.w3.org/1999/xlink","xlink:actuate",u);break;case"xlinkArcrole":xr(r,"http://www.w3.org/1999/xlink","xlink:arcrole",u);break;case"xlinkRole":xr(r,"http://www.w3.org/1999/xlink","xlink:role",u);break;case"xlinkShow":xr(r,"http://www.w3.org/1999/xlink","xlink:show",u);break;case"xlinkTitle":xr(r,"http://www.w3.org/1999/xlink","xlink:title",u);break;case"xlinkType":xr(r,"http://www.w3.org/1999/xlink","xlink:type",u);break;case"xmlBase":xr(r,"http://www.w3.org/XML/1998/namespace","xml:base",u);break;case"xmlLang":xr(r,"http://www.w3.org/XML/1998/namespace","xml:lang",u);break;case"xmlSpace":xr(r,"http://www.w3.org/XML/1998/namespace","xml:space",u);break;case"is":Nr(r,"is",u);break;case"innerText":case"textContent":break;default:(!(2<o.length)||o[0]!=="o"&&o[0]!=="O"||o[1]!=="n"&&o[1]!=="N")&&(o=Tr.get(o)||o,Nr(r,o,u))}}function sh(r,a,o,u,b,j){switch(o){case"style":xa(r,u,j);break;case"dangerouslySetInnerHTML":if(u!=null){if(typeof u!="object"||!("__html"in u))throw Error(i(61));if(o=u.__html,o!=null){if(b.children!=null)throw Error(i(60));r.innerHTML=o}}break;case"children":typeof u=="string"?Cr(r,u):(typeof u=="number"||typeof u=="bigint")&&Cr(r,""+u);break;case"onScroll":u!=null&&Vt("scroll",r);break;case"onScrollEnd":u!=null&&Vt("scrollend",r);break;case"onClick":u!=null&&(r.onclick=Ye);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Hr.hasOwnProperty(o))e:{if(o[0]==="o"&&o[1]==="n"&&(b=o.endsWith("Capture"),a=o.slice(2,b?o.length-7:void 0),j=r[Je]||null,j=j!=null?j[o]:null,typeof j=="function"&&r.removeEventListener(a,j,b),typeof u=="function")){typeof j!="function"&&j!==null&&(o in r?r[o]=null:r.hasAttribute(o)&&r.removeAttribute(o)),r.addEventListener(a,u,b);break e}o in r?r[o]=u:u===!0?r.setAttribute(o,""):Nr(r,o,u)}}}function mr(r,a,o){switch(a){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Vt("error",r),Vt("load",r);var u=!1,b=!1,j;for(j in o)if(o.hasOwnProperty(j)){var P=o[j];if(P!=null)switch(j){case"src":u=!0;break;case"srcSet":b=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,a));default:jn(r,a,j,P,o,null)}}b&&jn(r,a,"srcSet",o.srcSet,o,null),u&&jn(r,a,"src",o.src,o,null);return;case"input":Vt("invalid",r);var J=j=P=b=null,ie=null,ge=null;for(u in o)if(o.hasOwnProperty(u)){var Ee=o[u];if(Ee!=null)switch(u){case"name":b=Ee;break;case"type":P=Ee;break;case"checked":ie=Ee;break;case"defaultChecked":ge=Ee;break;case"value":j=Ee;break;case"defaultValue":J=Ee;break;case"children":case"dangerouslySetInnerHTML":if(Ee!=null)throw Error(i(137,a));break;default:jn(r,a,u,Ee,o,null)}}fs(r,j,J,ie,ge,P,b,!1);return;case"select":Vt("invalid",r),u=P=j=null;for(b in o)if(o.hasOwnProperty(b)&&(J=o[b],J!=null))switch(b){case"value":j=J;break;case"defaultValue":P=J;break;case"multiple":u=J;default:jn(r,a,b,J,o,null)}a=j,o=P,r.multiple=!!u,a!=null?cr(r,!!u,a,!1):o!=null&&cr(r,!!u,o,!0);return;case"textarea":Vt("invalid",r),j=b=u=null;for(P in o)if(o.hasOwnProperty(P)&&(J=o[P],J!=null))switch(P){case"value":u=J;break;case"defaultValue":b=J;break;case"children":j=J;break;case"dangerouslySetInnerHTML":if(J!=null)throw Error(i(91));break;default:jn(r,a,P,J,o,null)}_i(r,u,b,j);return;case"option":for(ie in o)o.hasOwnProperty(ie)&&(u=o[ie],u!=null)&&(ie==="selected"?r.selected=u&&typeof u!="function"&&typeof u!="symbol":jn(r,a,ie,u,o,null));return;case"dialog":Vt("beforetoggle",r),Vt("toggle",r),Vt("cancel",r),Vt("close",r);break;case"iframe":case"object":Vt("load",r);break;case"video":case"audio":for(u=0;u<ao.length;u++)Vt(ao[u],r);break;case"image":Vt("error",r),Vt("load",r);break;case"details":Vt("toggle",r);break;case"embed":case"source":case"link":Vt("error",r),Vt("load",r);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(ge in o)if(o.hasOwnProperty(ge)&&(u=o[ge],u!=null))switch(ge){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,a));default:jn(r,a,ge,u,o,null)}return;default:if(Ps(a)){for(Ee in o)o.hasOwnProperty(Ee)&&(u=o[Ee],u!==void 0&&sh(r,a,Ee,u,o,void 0));return}}for(J in o)o.hasOwnProperty(J)&&(u=o[J],u!=null&&jn(r,a,J,u,o,null))}function x2(r,a,o,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,J=null,ie=null,ge=null,Ee=null;for(we in o){var Oe=o[we];if(o.hasOwnProperty(we)&&Oe!=null)switch(we){case"checked":break;case"value":break;case"defaultValue":ie=Oe;default:u.hasOwnProperty(we)||jn(r,a,we,null,u,Oe)}}for(var ve in u){var we=u[ve];if(Oe=o[ve],u.hasOwnProperty(ve)&&(we!=null||Oe!=null))switch(ve){case"type":j=we;break;case"name":b=we;break;case"checked":ge=we;break;case"defaultChecked":Ee=we;break;case"value":P=we;break;case"defaultValue":J=we;break;case"children":case"dangerouslySetInnerHTML":if(we!=null)throw Error(i(137,a));break;default:we!==Oe&&jn(r,a,ve,we,u,Oe)}}kr(r,P,J,ie,ge,Ee,j,b);return;case"select":we=P=J=ve=null;for(j in o)if(ie=o[j],o.hasOwnProperty(j)&&ie!=null)switch(j){case"value":break;case"multiple":we=ie;default:u.hasOwnProperty(j)||jn(r,a,j,null,u,ie)}for(b in u)if(j=u[b],ie=o[b],u.hasOwnProperty(b)&&(j!=null||ie!=null))switch(b){case"value":ve=j;break;case"defaultValue":J=j;break;case"multiple":P=j;default:j!==ie&&jn(r,a,b,j,u,ie)}a=J,o=P,u=we,ve!=null?cr(r,!!o,ve,!1):!!u!=!!o&&(a!=null?cr(r,!!o,a,!0):cr(r,!!o,o?[]:"",!1));return;case"textarea":we=ve=null;for(J in o)if(b=o[J],o.hasOwnProperty(J)&&b!=null&&!u.hasOwnProperty(J))switch(J){case"value":break;case"children":break;default:jn(r,a,J,null,u,b)}for(P in u)if(b=u[P],j=o[P],u.hasOwnProperty(P)&&(b!=null||j!=null))switch(P){case"value":ve=b;break;case"defaultValue":we=b;break;case"children":break;case"dangerouslySetInnerHTML":if(b!=null)throw Error(i(91));break;default:b!==j&&jn(r,a,P,b,u,j)}Wa(r,ve,we);return;case"option":for(var tt in o)ve=o[tt],o.hasOwnProperty(tt)&&ve!=null&&!u.hasOwnProperty(tt)&&(tt==="selected"?r.selected=!1:jn(r,a,tt,null,u,ve));for(ie in u)ve=u[ie],we=o[ie],u.hasOwnProperty(ie)&&ve!==we&&(ve!=null||we!=null)&&(ie==="selected"?r.selected=ve&&typeof ve!="function"&&typeof ve!="symbol":jn(r,a,ie,ve,u,we));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 Ct in o)ve=o[Ct],o.hasOwnProperty(Ct)&&ve!=null&&!u.hasOwnProperty(Ct)&&jn(r,a,Ct,null,u,ve);for(ge in u)if(ve=u[ge],we=o[ge],u.hasOwnProperty(ge)&&ve!==we&&(ve!=null||we!=null))switch(ge){case"children":case"dangerouslySetInnerHTML":if(ve!=null)throw Error(i(137,a));break;default:jn(r,a,ge,ve,u,we)}return;default:if(Ps(a)){for(var wn in o)ve=o[wn],o.hasOwnProperty(wn)&&ve!==void 0&&!u.hasOwnProperty(wn)&&sh(r,a,wn,void 0,u,ve);for(Ee in u)ve=u[Ee],we=o[Ee],!u.hasOwnProperty(Ee)||ve===we||ve===void 0&&we===void 0||sh(r,a,Ee,ve,u,we);return}}for(var ue in o)ve=o[ue],o.hasOwnProperty(ue)&&ve!=null&&!u.hasOwnProperty(ue)&&jn(r,a,ue,null,u,ve);for(Oe in u)ve=u[Oe],we=o[Oe],!u.hasOwnProperty(Oe)||ve===we||ve==null&&we==null||jn(r,a,Oe,ve,u,we)}function P0(r){switch(r){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function p2(){if(typeof performance.getEntriesByType=="function"){for(var r=0,a=0,o=performance.getEntriesByType("resource"),u=0;u<o.length;u++){var b=o[u],j=b.transferSize,P=b.initiatorType,J=b.duration;if(j&&J&&P0(P)){for(P=0,J=b.responseEnd,u+=1;u<o.length;u++){var ie=o[u],ge=ie.startTime;if(ge>J)break;var Ee=ie.transferSize,Oe=ie.initiatorType;Ee&&P0(Oe)&&(ie=ie.responseEnd,P+=Ee*(ie<J?1:(J-ge)/(ie-ge)))}if(--u,a+=8*(j+P)/(b.duration/1e3),r++,10<r)break}}if(0<r)return a/r/1e6}return navigator.connection&&(r=navigator.connection.downlink,typeof r=="number")?r:5}var ah=null,ih=null;function ed(r){return r.nodeType===9?r:r.ownerDocument}function q0(r){switch(r){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function U0(r,a){if(r===0)switch(a){case"svg":return 1;case"math":return 2;default:return 0}return r===1&&a==="foreignObject"?0:r}function lh(r,a){return r==="textarea"||r==="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 oh=null;function g2(){var r=window.event;return r&&r.type==="popstate"?r===oh?!1:(oh=r,!0):(oh=null,!1)}var V0=typeof setTimeout=="function"?setTimeout:void 0,b2=typeof clearTimeout=="function"?clearTimeout:void 0,F0=typeof Promise=="function"?Promise:void 0,y2=typeof queueMicrotask=="function"?queueMicrotask:typeof F0<"u"?function(r){return F0.resolve(null).then(r).catch(v2)}:V0;function v2(r){setTimeout(function(){throw r})}function Ra(r){return r==="head"}function Y0(r,a){var o=a,u=0;do{var b=o.nextSibling;if(r.removeChild(o),b&&b.nodeType===8)if(o=b.data,o==="/$"||o==="/&"){if(u===0){r.removeChild(b),sl(a);return}u--}else if(o==="$"||o==="$?"||o==="$~"||o==="$!"||o==="&")u++;else if(o==="html")lo(r.ownerDocument.documentElement);else if(o==="head"){o=r.ownerDocument.head,lo(o);for(var j=o.firstChild;j;){var P=j.nextSibling,J=j.nodeName;j[ze]||J==="SCRIPT"||J==="STYLE"||J==="LINK"&&j.rel.toLowerCase()==="stylesheet"||o.removeChild(j),j=P}}else o==="body"&&lo(r.ownerDocument.body);o=b}while(o);sl(a)}function G0(r,a){var o=r;r=0;do{var u=o.nextSibling;if(o.nodeType===1?a?(o._stashedDisplay=o.style.display,o.style.display="none"):(o.style.display=o._stashedDisplay||"",o.getAttribute("style")===""&&o.removeAttribute("style")):o.nodeType===3&&(a?(o._stashedText=o.nodeValue,o.nodeValue=""):o.nodeValue=o._stashedText||""),u&&u.nodeType===8)if(o=u.data,o==="/$"){if(r===0)break;r--}else o!=="$"&&o!=="$?"&&o!=="$~"&&o!=="$!"||r++;o=u}while(o)}function ch(r){var a=r.firstChild;for(a&&a.nodeType===10&&(a=a.nextSibling);a;){var o=a;switch(a=a.nextSibling,o.nodeName){case"HTML":case"HEAD":case"BODY":ch(o),Et(o);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(o.rel.toLowerCase()==="stylesheet")continue}r.removeChild(o)}}function j2(r,a,o,u){for(;r.nodeType===1;){var b=o;if(r.nodeName.toLowerCase()!==a.toLowerCase()){if(!u&&(r.nodeName!=="INPUT"||r.type!=="hidden"))break}else if(u){if(!r[ze])switch(a){case"meta":if(!r.hasAttribute("itemprop"))break;return r;case"link":if(j=r.getAttribute("rel"),j==="stylesheet"&&r.hasAttribute("data-precedence"))break;if(j!==b.rel||r.getAttribute("href")!==(b.href==null||b.href===""?null:b.href)||r.getAttribute("crossorigin")!==(b.crossOrigin==null?null:b.crossOrigin)||r.getAttribute("title")!==(b.title==null?null:b.title))break;return r;case"style":if(r.hasAttribute("data-precedence"))break;return r;case"script":if(j=r.getAttribute("src"),(j!==(b.src==null?null:b.src)||r.getAttribute("type")!==(b.type==null?null:b.type)||r.getAttribute("crossorigin")!==(b.crossOrigin==null?null:b.crossOrigin))&&j&&r.hasAttribute("async")&&!r.hasAttribute("itemprop"))break;return r;default:return r}}else if(a==="input"&&r.type==="hidden"){var j=b.name==null?null:""+b.name;if(b.type==="hidden"&&r.getAttribute("name")===j)return r}else return r;if(r=os(r.nextSibling),r===null)break}return null}function w2(r,a,o){if(a==="")return null;for(;r.nodeType!==3;)if((r.nodeType!==1||r.nodeName!=="INPUT"||r.type!=="hidden")&&!o||(r=os(r.nextSibling),r===null))return null;return r}function X0(r,a){for(;r.nodeType!==8;)if((r.nodeType!==1||r.nodeName!=="INPUT"||r.type!=="hidden")&&!a||(r=os(r.nextSibling),r===null))return null;return r}function dh(r){return r.data==="$?"||r.data==="$~"}function uh(r){return r.data==="$!"||r.data==="$?"&&r.ownerDocument.readyState!=="loading"}function N2(r,a){var o=r.ownerDocument;if(r.data==="$~")r._reactRetry=a;else if(r.data!=="$?"||o.readyState!=="loading")a();else{var u=function(){a(),o.removeEventListener("DOMContentLoaded",u)};o.addEventListener("DOMContentLoaded",u),r._reactRetry=u}}function os(r){for(;r!=null;r=r.nextSibling){var a=r.nodeType;if(a===1||a===3)break;if(a===8){if(a=r.data,a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"||a==="F!"||a==="F")break;if(a==="/$"||a==="/&")return null}}return r}var fh=null;function K0(r){r=r.nextSibling;for(var a=0;r;){if(r.nodeType===8){var o=r.data;if(o==="/$"||o==="/&"){if(a===0)return os(r.nextSibling);a--}else o!=="$"&&o!=="$!"&&o!=="$?"&&o!=="$~"&&o!=="&"||a++}r=r.nextSibling}return null}function W0(r){r=r.previousSibling;for(var a=0;r;){if(r.nodeType===8){var o=r.data;if(o==="$"||o==="$!"||o==="$?"||o==="$~"||o==="&"){if(a===0)return r;a--}else o!=="/$"&&o!=="/&"||a++}r=r.previousSibling}return null}function Q0(r,a,o){switch(a=ed(o),r){case"html":if(r=a.documentElement,!r)throw Error(i(452));return r;case"head":if(r=a.head,!r)throw Error(i(453));return r;case"body":if(r=a.body,!r)throw Error(i(454));return r;default:throw Error(i(451))}}function lo(r){for(var a=r.attributes;a.length;)r.removeAttributeNode(a[0]);Et(r)}var cs=new Map,Z0=new Set;function td(r){return typeof r.getRootNode=="function"?r.getRootNode():r.nodeType===9?r:r.ownerDocument}var na=F.d;F.d={f:k2,r:S2,D:C2,C:E2,L:T2,m:_2,X:M2,S:A2,M:R2};function k2(){var r=na.f(),a=Yc();return r||a}function S2(r){var a=yn(r);a!==null&&a.tag===5&&a.type==="form"?xg(a):na.r(r)}var tl=typeof document>"u"?null:document;function J0(r,a,o){var u=tl;if(u&&typeof a=="string"&&a){var b=Yn(a);b='link[rel="'+r+'"][href="'+b+'"]',typeof o=="string"&&(b+='[crossorigin="'+o+'"]'),Z0.has(b)||(Z0.add(b),r={rel:r,crossOrigin:o,href:a},u.querySelector(b)===null&&(a=u.createElement("link"),mr(a,"link",r),Nn(a),u.head.appendChild(a)))}}function C2(r){na.D(r),J0("dns-prefetch",r,null)}function E2(r,a){na.C(r,a),J0("preconnect",r,a)}function T2(r,a,o){na.L(r,a,o);var u=tl;if(u&&r&&a){var b='link[rel="preload"][as="'+Yn(a)+'"]';a==="image"&&o&&o.imageSrcSet?(b+='[imagesrcset="'+Yn(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(b+='[imagesizes="'+Yn(o.imageSizes)+'"]')):b+='[href="'+Yn(r)+'"]';var j=b;switch(a){case"style":j=nl(r);break;case"script":j=rl(r)}cs.has(j)||(r=p({rel:"preload",href:a==="image"&&o&&o.imageSrcSet?void 0:r,as:a},o),cs.set(j,r),u.querySelector(b)!==null||a==="style"&&u.querySelector(oo(j))||a==="script"&&u.querySelector(co(j))||(a=u.createElement("link"),mr(a,"link",r),Nn(a),u.head.appendChild(a)))}}function _2(r,a){na.m(r,a);var o=tl;if(o&&r){var u=a&&typeof a.as=="string"?a.as:"script",b='link[rel="modulepreload"][as="'+Yn(u)+'"][href="'+Yn(r)+'"]',j=b;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":j=rl(r)}if(!cs.has(j)&&(r=p({rel:"modulepreload",href:r},a),cs.set(j,r),o.querySelector(b)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector(co(j)))return}u=o.createElement("link"),mr(u,"link",r),Nn(u),o.head.appendChild(u)}}}function A2(r,a,o){na.S(r,a,o);var u=tl;if(u&&r){var b=or(u).hoistableStyles,j=nl(r);a=a||"default";var P=b.get(j);if(!P){var J={loading:0,preload:null};if(P=u.querySelector(oo(j)))J.loading=5;else{r=p({rel:"stylesheet",href:r,"data-precedence":a},o),(o=cs.get(j))&&hh(r,o);var ie=P=u.createElement("link");Nn(ie),mr(ie,"link",r),ie._p=new Promise(function(ge,Ee){ie.onload=ge,ie.onerror=Ee}),ie.addEventListener("load",function(){J.loading|=1}),ie.addEventListener("error",function(){J.loading|=2}),J.loading|=4,nd(P,a,u)}P={type:"stylesheet",instance:P,count:1,state:J},b.set(j,P)}}}function M2(r,a){na.X(r,a);var o=tl;if(o&&r){var u=or(o).hoistableScripts,b=rl(r),j=u.get(b);j||(j=o.querySelector(co(b)),j||(r=p({src:r,async:!0},a),(a=cs.get(b))&&mh(r,a),j=o.createElement("script"),Nn(j),mr(j,"link",r),o.head.appendChild(j)),j={type:"script",instance:j,count:1,state:null},u.set(b,j))}}function R2(r,a){na.M(r,a);var o=tl;if(o&&r){var u=or(o).hoistableScripts,b=rl(r),j=u.get(b);j||(j=o.querySelector(co(b)),j||(r=p({src:r,async:!0,type:"module"},a),(a=cs.get(b))&&mh(r,a),j=o.createElement("script"),Nn(j),mr(j,"link",r),o.head.appendChild(j)),j={type:"script",instance:j,count:1,state:null},u.set(b,j))}}function eb(r,a,o,u){var b=(b=W.current)?td(b):null;if(!b)throw Error(i(446));switch(r){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(a=nl(o.href),o=or(b).hoistableStyles,u=o.get(a),u||(u={type:"style",instance:null,count:0,state:null},o.set(a,u)),u):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){r=nl(o.href);var j=or(b).hoistableStyles,P=j.get(r);if(P||(b=b.ownerDocument||b,P={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},j.set(r,P),(j=b.querySelector(oo(r)))&&!j._p&&(P.instance=j,P.state.loading=5),cs.has(r)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},cs.set(r,o),j||O2(b,r,o,P.state))),a&&u===null)throw Error(i(528,""));return P}if(a&&u!==null)throw Error(i(529,""));return null;case"script":return a=o.async,o=o.src,typeof o=="string"&&a&&typeof a!="function"&&typeof a!="symbol"?(a=rl(o),o=or(b).hoistableScripts,u=o.get(a),u||(u={type:"script",instance:null,count:0,state:null},o.set(a,u)),u):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,r))}}function nl(r){return'href="'+Yn(r)+'"'}function oo(r){return'link[rel="stylesheet"]['+r+"]"}function tb(r){return p({},r,{"data-precedence":r.precedence,precedence:null})}function O2(r,a,o,u){r.querySelector('link[rel="preload"][as="style"]['+a+"]")?u.loading=1:(a=r.createElement("link"),u.preload=a,a.addEventListener("load",function(){return u.loading|=1}),a.addEventListener("error",function(){return u.loading|=2}),mr(a,"link",o),Nn(a),r.head.appendChild(a))}function rl(r){return'[src="'+Yn(r)+'"]'}function co(r){return"script[async]"+r}function nb(r,a,o){if(a.count++,a.instance===null)switch(a.type){case"style":var u=r.querySelector('style[data-href~="'+Yn(o.href)+'"]');if(u)return a.instance=u,Nn(u),u;var b=p({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return u=(r.ownerDocument||r).createElement("style"),Nn(u),mr(u,"style",b),nd(u,o.precedence,r),a.instance=u;case"stylesheet":b=nl(o.href);var j=r.querySelector(oo(b));if(j)return a.state.loading|=4,a.instance=j,Nn(j),j;u=tb(o),(b=cs.get(b))&&hh(u,b),j=(r.ownerDocument||r).createElement("link"),Nn(j);var P=j;return P._p=new Promise(function(J,ie){P.onload=J,P.onerror=ie}),mr(j,"link",u),a.state.loading|=4,nd(j,o.precedence,r),a.instance=j;case"script":return j=rl(o.src),(b=r.querySelector(co(j)))?(a.instance=b,Nn(b),b):(u=o,(b=cs.get(j))&&(u=p({},o),mh(u,b)),r=r.ownerDocument||r,b=r.createElement("script"),Nn(b),mr(b,"link",u),r.head.appendChild(b),a.instance=b);case"void":return null;default:throw Error(i(443,a.type))}else a.type==="stylesheet"&&(a.state.loading&4)===0&&(u=a.instance,a.state.loading|=4,nd(u,o.precedence,r));return a.instance}function nd(r,a,o){for(var u=o.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 J=u[P];if(J.dataset.precedence===a)j=J;else if(j!==b)break}j?j.parentNode.insertBefore(r,j.nextSibling):(a=o.nodeType===9?o.head:o,a.insertBefore(r,a.firstChild))}function hh(r,a){r.crossOrigin==null&&(r.crossOrigin=a.crossOrigin),r.referrerPolicy==null&&(r.referrerPolicy=a.referrerPolicy),r.title==null&&(r.title=a.title)}function mh(r,a){r.crossOrigin==null&&(r.crossOrigin=a.crossOrigin),r.referrerPolicy==null&&(r.referrerPolicy=a.referrerPolicy),r.integrity==null&&(r.integrity=a.integrity)}var rd=null;function rb(r,a,o){if(rd===null){var u=new Map,b=rd=new Map;b.set(o,u)}else b=rd,u=b.get(o),u||(u=new Map,b.set(o,u));if(u.has(r))return u;for(u.set(r,null),o=o.getElementsByTagName(r),b=0;b<o.length;b++){var j=o[b];if(!(j[ze]||j[qe]||r==="link"&&j.getAttribute("rel")==="stylesheet")&&j.namespaceURI!=="http://www.w3.org/2000/svg"){var P=j.getAttribute(a)||"";P=r+P;var J=u.get(P);J?J.push(j):u.set(P,[j])}}return u}function sb(r,a,o){r=r.ownerDocument||r,r.head.insertBefore(o,a==="title"?r.querySelector("head > title"):null)}function D2(r,a,o){if(o===1||a.itemProp!=null)return!1;switch(r){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"?(r=a.disabled,typeof a.precedence=="string"&&r==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 ab(r){return!(r.type==="stylesheet"&&(r.state.loading&3)===0)}function L2(r,a,o,u){if(o.type==="stylesheet"&&(typeof u.media!="string"||matchMedia(u.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var b=nl(u.href),j=a.querySelector(oo(b));if(j){a=j._p,a!==null&&typeof a=="object"&&typeof a.then=="function"&&(r.count++,r=sd.bind(r),a.then(r,r)),o.state.loading|=4,o.instance=j,Nn(j);return}j=a.ownerDocument||a,u=tb(u),(b=cs.get(b))&&hh(u,b),j=j.createElement("link"),Nn(j);var P=j;P._p=new Promise(function(J,ie){P.onload=J,P.onerror=ie}),mr(j,"link",u),o.instance=j}r.stylesheets===null&&(r.stylesheets=new Map),r.stylesheets.set(o,a),(a=o.state.preload)&&(o.state.loading&3)===0&&(r.count++,o=sd.bind(r),a.addEventListener("load",o),a.addEventListener("error",o))}}var xh=0;function I2(r,a){return r.stylesheets&&r.count===0&&id(r,r.stylesheets),0<r.count||0<r.imgCount?function(o){var u=setTimeout(function(){if(r.stylesheets&&id(r,r.stylesheets),r.unsuspend){var j=r.unsuspend;r.unsuspend=null,j()}},6e4+a);0<r.imgBytes&&xh===0&&(xh=62500*p2());var b=setTimeout(function(){if(r.waitingForImages=!1,r.count===0&&(r.stylesheets&&id(r,r.stylesheets),r.unsuspend)){var j=r.unsuspend;r.unsuspend=null,j()}},(r.imgBytes>xh?50:800)+a);return r.unsuspend=o,function(){r.unsuspend=null,clearTimeout(u),clearTimeout(b)}}:null}function sd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)id(this,this.stylesheets);else if(this.unsuspend){var r=this.unsuspend;this.unsuspend=null,r()}}}var ad=null;function id(r,a){r.stylesheets=null,r.unsuspend!==null&&(r.count++,ad=new Map,a.forEach(z2,r),ad=null,sd.call(r))}function z2(r,a){if(!(a.state.loading&4)){var o=ad.get(r);if(o)var u=o.get(null);else{o=new Map,ad.set(r,o);for(var b=r.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")&&(o.set(P.dataset.precedence,P),u=P)}u&&o.set(null,u)}b=a.instance,P=b.getAttribute("data-precedence"),j=o.get(P)||u,j===u&&o.set(null,b),o.set(P,b),this.count++,u=sd.bind(this),b.addEventListener("load",u),b.addEventListener("error",u),j?j.parentNode.insertBefore(b,j.nextSibling):(r=r.nodeType===9?r.head:r,r.insertBefore(b,r.firstChild)),a.state.loading|=4}}var uo={$$typeof:k,Provider:null,Consumer:null,_currentValue:Y,_currentValue2:Y,_threadCount:0};function $2(r,a,o,u,b,j,P,J,ie){this.tag=1,this.containerInfo=r,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=an(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=an(0),this.hiddenUpdates=an(null),this.identifierPrefix=u,this.onUncaughtError=b,this.onCaughtError=j,this.onRecoverableError=P,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=ie,this.incompleteTransitions=new Map}function ib(r,a,o,u,b,j,P,J,ie,ge,Ee,Oe){return r=new $2(r,a,o,P,ie,ge,Ee,Oe,J),a=1,j===!0&&(a|=24),j=Fr(3,null,null,a),r.current=j,j.stateNode=r,a=Gu(),a.refCount++,r.pooledCache=a,a.refCount++,j.memoizedState={element:u,isDehydrated:o,cache:a},Qu(j),r}function lb(r){return r?(r=Di,r):Di}function ob(r,a,o,u,b,j){b=lb(b),u.context===null?u.context=b:u.pendingContext=b,u=ja(a),u.payload={element:o},j=j===void 0?null:j,j!==null&&(u.callback=j),o=wa(r,u,a),o!==null&&(Dr(o,r,a),ql(o,r,a))}function cb(r,a){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var o=r.retryLane;r.retryLane=o!==0&&o<a?o:a}}function ph(r,a){cb(r,a),(r=r.alternate)&&cb(r,a)}function db(r){if(r.tag===13||r.tag===31){var a=Ja(r,67108864);a!==null&&Dr(a,r,67108864),ph(r,67108864)}}function ub(r){if(r.tag===13||r.tag===31){var a=Wr();a=le(a);var o=Ja(r,a);o!==null&&Dr(o,r,a),ph(r,a)}}var ld=!0;function B2(r,a,o,u){var b=R.T;R.T=null;var j=F.p;try{F.p=2,gh(r,a,o,u)}finally{F.p=j,R.T=b}}function H2(r,a,o,u){var b=R.T;R.T=null;var j=F.p;try{F.p=8,gh(r,a,o,u)}finally{F.p=j,R.T=b}}function gh(r,a,o,u){if(ld){var b=bh(u);if(b===null)rh(r,a,u,od,o),hb(r,u);else if(q2(b,r,a,o,u))u.stopPropagation();else if(hb(r,u),a&4&&-1<P2.indexOf(r)){for(;b!==null;){var j=yn(b);if(j!==null)switch(j.tag){case 3:if(j=j.stateNode,j.current.memoizedState.isDehydrated){var P=Re(j.pendingLanes);if(P!==0){var J=j;for(J.pendingLanes|=2,J.entangledLanes|=2;P;){var ie=1<<31-_t(P);J.entanglements[1]|=ie,P&=~ie}Es(j),(fn&6)===0&&(Vc=dt()+500,so(0))}}break;case 31:case 13:J=Ja(j,2),J!==null&&Dr(J,j,2),Yc(),ph(j,2)}if(j=bh(u),j===null&&rh(r,a,u,od,o),j===b)break;b=j}b!==null&&u.stopPropagation()}else rh(r,a,u,null,o)}}function bh(r){return r=sn(r),yh(r)}var od=null;function yh(r){if(od=null,r=kt(r),r!==null){var a=d(r);if(a===null)r=null;else{var o=a.tag;if(o===13){if(r=c(a),r!==null)return r;r=null}else if(o===31){if(r=h(a),r!==null)return r;r=null}else if(o===3){if(a.stateNode.current.memoizedState.isDehydrated)return a.tag===3?a.stateNode.containerInfo:null;r=null}else a!==r&&(r=null)}}return od=r,null}function fb(r){switch(r){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(Yt()){case ye:return 2;case Ae:return 8;case Fe:case Qe:return 32;case xt:return 268435456;default:return 32}default:return 32}}var vh=!1,Oa=null,Da=null,La=null,fo=new Map,ho=new Map,Ia=[],P2="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 hb(r,a){switch(r){case"focusin":case"focusout":Oa=null;break;case"dragenter":case"dragleave":Da=null;break;case"mouseover":case"mouseout":La=null;break;case"pointerover":case"pointerout":fo.delete(a.pointerId);break;case"gotpointercapture":case"lostpointercapture":ho.delete(a.pointerId)}}function mo(r,a,o,u,b,j){return r===null||r.nativeEvent!==j?(r={blockedOn:a,domEventName:o,eventSystemFlags:u,nativeEvent:j,targetContainers:[b]},a!==null&&(a=yn(a),a!==null&&db(a)),r):(r.eventSystemFlags|=u,a=r.targetContainers,b!==null&&a.indexOf(b)===-1&&a.push(b),r)}function q2(r,a,o,u,b){switch(a){case"focusin":return Oa=mo(Oa,r,a,o,u,b),!0;case"dragenter":return Da=mo(Da,r,a,o,u,b),!0;case"mouseover":return La=mo(La,r,a,o,u,b),!0;case"pointerover":var j=b.pointerId;return fo.set(j,mo(fo.get(j)||null,r,a,o,u,b)),!0;case"gotpointercapture":return j=b.pointerId,ho.set(j,mo(ho.get(j)||null,r,a,o,u,b)),!0}return!1}function mb(r){var a=kt(r.target);if(a!==null){var o=d(a);if(o!==null){if(a=o.tag,a===13){if(a=c(o),a!==null){r.blockedOn=a,We(r.priority,function(){ub(o)});return}}else if(a===31){if(a=h(o),a!==null){r.blockedOn=a,We(r.priority,function(){ub(o)});return}}else if(a===3&&o.stateNode.current.memoizedState.isDehydrated){r.blockedOn=o.tag===3?o.stateNode.containerInfo:null;return}}}r.blockedOn=null}function cd(r){if(r.blockedOn!==null)return!1;for(var a=r.targetContainers;0<a.length;){var o=bh(r.nativeEvent);if(o===null){o=r.nativeEvent;var u=new o.constructor(o.type,o);it=u,o.target.dispatchEvent(u),it=null}else return a=yn(o),a!==null&&db(a),r.blockedOn=o,!1;a.shift()}return!0}function xb(r,a,o){cd(r)&&o.delete(a)}function U2(){vh=!1,Oa!==null&&cd(Oa)&&(Oa=null),Da!==null&&cd(Da)&&(Da=null),La!==null&&cd(La)&&(La=null),fo.forEach(xb),ho.forEach(xb)}function dd(r,a){r.blockedOn===a&&(r.blockedOn=null,vh||(vh=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,U2)))}var ud=null;function pb(r){ud!==r&&(ud=r,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){ud===r&&(ud=null);for(var a=0;a<r.length;a+=3){var o=r[a],u=r[a+1],b=r[a+2];if(typeof u!="function"){if(yh(u||o)===null)continue;break}var j=yn(o);j!==null&&(r.splice(a,3),a-=3,bf(j,{pending:!0,data:b,method:o.method,action:u},u,b))}}))}function sl(r){function a(ie){return dd(ie,r)}Oa!==null&&dd(Oa,r),Da!==null&&dd(Da,r),La!==null&&dd(La,r),fo.forEach(a),ho.forEach(a);for(var o=0;o<Ia.length;o++){var u=Ia[o];u.blockedOn===r&&(u.blockedOn=null)}for(;0<Ia.length&&(o=Ia[0],o.blockedOn===null);)mb(o),o.blockedOn===null&&Ia.shift();if(o=(r.ownerDocument||r).$$reactFormReplay,o!=null)for(u=0;u<o.length;u+=3){var b=o[u],j=o[u+1],P=b[Je]||null;if(typeof j=="function")P||pb(o);else if(P){var J=null;if(j&&j.hasAttribute("formAction")){if(b=j,P=j[Je]||null)J=P.formAction;else if(yh(b)!==null)continue}else J=P.action;typeof J=="function"?o[u+1]=J:(o.splice(u,3),u-=3),pb(o)}}}function gb(){function r(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(o,20)}function o(){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",r),navigation.addEventListener("navigatesuccess",a),navigation.addEventListener("navigateerror",a),setTimeout(o,100),function(){u=!0,navigation.removeEventListener("navigate",r),navigation.removeEventListener("navigatesuccess",a),navigation.removeEventListener("navigateerror",a),b!==null&&(b(),b=null)}}}function jh(r){this._internalRoot=r}fd.prototype.render=jh.prototype.render=function(r){var a=this._internalRoot;if(a===null)throw Error(i(409));var o=a.current,u=Wr();ob(o,u,r,a,null,null)},fd.prototype.unmount=jh.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var a=r.containerInfo;ob(r.current,2,null,r,null,null),Yc(),a[Wt]=null}};function fd(r){this._internalRoot=r}fd.prototype.unstable_scheduleHydration=function(r){if(r){var a=Ue();r={blockedOn:null,target:r,priority:a};for(var o=0;o<Ia.length&&a!==0&&a<Ia[o].priority;o++);Ia.splice(o,0,r),o===0&&mb(r)}};var bb=n.version;if(bb!=="19.2.4")throw Error(i(527,bb,"19.2.4"));F.findDOMNode=function(r){var a=r._reactInternals;if(a===void 0)throw typeof r.render=="function"?Error(i(188)):(r=Object.keys(r).join(","),Error(i(268,r)));return r=f(a),r=r!==null?x(r):null,r=r===null?null:r.stateNode,r};var V2={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:R,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var hd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!hd.isDisabled&&hd.supportsFiber)try{Tt=hd.inject(V2),gt=hd}catch{}}return po.createRoot=function(r,a){if(!l(r))throw Error(i(299));var o=!1,u="",b=Sg,j=Cg,P=Eg;return a!=null&&(a.unstable_strictMode===!0&&(o=!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=ib(r,1,!1,null,null,o,u,null,b,j,P,gb),r[Wt]=a.current,nh(r),new jh(a)},po.hydrateRoot=function(r,a,o){if(!l(r))throw Error(i(299));var u=!1,b="",j=Sg,P=Cg,J=Eg,ie=null;return o!=null&&(o.unstable_strictMode===!0&&(u=!0),o.identifierPrefix!==void 0&&(b=o.identifierPrefix),o.onUncaughtError!==void 0&&(j=o.onUncaughtError),o.onCaughtError!==void 0&&(P=o.onCaughtError),o.onRecoverableError!==void 0&&(J=o.onRecoverableError),o.formState!==void 0&&(ie=o.formState)),a=ib(r,1,!0,a,o??null,u,b,ie,j,P,J,gb),a.context=lb(null),o=a.current,u=Wr(),u=le(u),b=ja(u),b.callback=null,wa(o,b,u),o=u,a.current.lanes=o,dn(a,o),Es(a),r[Wt]=a.current,nh(r),new fd(a)},po.version="19.2.4",po}var Tb;function ek(){if(Tb)return kh.exports;Tb=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(n){console.error(n)}}return e(),kh.exports=J2(),kh.exports}var tk=ek();const me={HOME:"home",TEAM:"team",WORK:"work",STORE:"store",BUILDER:"builder",DELIVERABLES:"deliverables",REPORTS:"reports",SETTINGS:"settings"},nk=new Set(Object.values(me)),rk={dashboard:me.HOME,overview:me.HOME,chat:me.TEAM,projects:me.WORK,tasks:me.WORK,usage:me.REPORTS,prompts:me.BUILDER,templates:me.STORE,agents:me.STORE,skills:me.STORE,teams:me.STORE,knowledge:me.DELIVERABLES,governance:me.SETTINGS};function la(e){return nk.has(e)?e:rk[e]??me.HOME}function md(){const e=window.location.hash.slice(1).split("/")[0];return la(e)}function gm(e,n){return n?`#${e}/${n}`:`#${e}`}const sk={[me.STORE]:me.BUILDER,[me.REPORTS]:me.SETTINGS},dl={[me.HOME]:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z M9 22V12h6v10",[me.WORK]:"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",[me.TEAM]:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",[me.REPORTS]:"M18 20V10 M12 20V4 M6 20v-6",[me.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",[me.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",[me.STORE]:"M6 2L3 7v13a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V7l-3-5z M3 7h18 M16 11a4 4 0 0 1-8 0",[me.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"},ak=[{key:"workspace",label:"WORKSPACE"},{key:"build",label:"BUILD"},{key:"system",label:"SYSTEM"}],ik=[{id:me.HOME,label:"Home",section:"workspace"},{id:me.TEAM,label:"Team",section:"workspace"},{id:me.DELIVERABLES,label:"Deliverables",section:"workspace"},{id:me.BUILDER,label:"Builder",section:"build"},{id:me.STORE,label:"Store",section:"build"},{id:me.REPORTS,label:"Reports",section:"system"},{id:me.SETTINGS,label:"Settings",section:"system"}],lk=[{id:me.HOME,label:"Home",group:[me.HOME]},{id:me.TEAM,label:"Team",group:[me.TEAM]},{id:me.WORK,label:"Work",group:[me.WORK]},{id:me.DELIVERABLES,label:"Deliverables",group:[me.DELIVERABLES]},{id:me.BUILDER,label:"Builder",group:[me.BUILDER,me.STORE]},{id:me.SETTINGS,label:"Settings",group:[me.SETTINGS,me.REPORTS]}],T1="/api";async function fe(e,n){const s=await fetch(`${T1}${e}`,{headers:{"Content-Type":"application/json"},credentials:"include",...n,body:n?.body?typeof n.body=="string"?n.body:JSON.stringify(n.body):void 0});if(!s.ok){let i="";try{const l=await s.json();i=l.error??l.message??""}catch{}throw new Error(i||`API error: ${s.status}`)}return s.json()}const se={agents:{list:()=>fe("/agents").then(e=>({...e,agents:e.agents.filter(n=>n.name)})),get:e=>fe(`/agents/${e}`),create:(e,n,s,i)=>fe("/agents",{method:"POST",body:JSON.stringify({name:e,roleName:n,agentRole:s,teamId:i})}),start:e=>fe(`/agents/${e}/start`,{method:"POST"}),stop:e=>fe(`/agents/${e}/stop`,{method:"POST"}),remove:(e,n)=>fe(`/agents/${e}${n?.purgeFiles?"?purgeFiles=true":""}`,{method:"DELETE"}),updateConfig:(e,n)=>fe(`/agents/${e}/config`,{method:"PATCH",body:JSON.stringify(n)}),getMemory:e=>fe(`/agents/${e}/memory`),getMemorySession:(e,n)=>fe(`/agents/${e}/memory/sessions/${encodeURIComponent(n)}`),updateDailyMemory:(e,n)=>fe(`/agents/${e}/memory/daily`,{method:"PUT",body:JSON.stringify({content:n})}),updateLongTermMemory:(e,n,s)=>fe(`/agents/${e}/memory/longterm`,{method:"PUT",body:JSON.stringify({key:n,content:s})}),getFiles:e=>fe(`/agents/${e}/files`),getFilesMap:e=>fe(`/agents/${e}/files`),updateFile:(e,n,s)=>fe(`/agents/${e}/files/${encodeURIComponent(n)}`,{method:"PUT",body:JSON.stringify({content:s})}),updateSystemPrompt:(e,n)=>fe(`/agents/${e}/system-prompt`,{method:"PUT",body:JSON.stringify({systemPrompt:n})}),roleStatus:e=>fe(`/agents/${e}/role-status`),roleDiff:(e,n="ROLE.md")=>fe(`/agents/${e}/role-diff?file=${encodeURIComponent(n)}`),roleSync:(e,n)=>fe(`/agents/${e}/role-sync`,{method:"POST",body:JSON.stringify(n?{files:n}:{})}),roleUpdates:()=>fe("/agents/role-updates"),addSkill:(e,n)=>fe(`/agents/${e}/skills`,{method:"POST",body:JSON.stringify({skillName:n})}),removeSkill:(e,n)=>fe(`/agents/${e}/skills/${encodeURIComponent(n)}`,{method:"DELETE"}),getHeartbeat:e=>fe(`/agents/${e}/heartbeat`),triggerHeartbeat:e=>fe(`/agents/${e}/heartbeat/trigger`,{method:"POST"}),getRecentActivities:e=>fe(`/agents/${e}/recent-activities`),getActivityLogs:(e,n)=>fe(`/agents/${e}/activity-logs?activityId=${encodeURIComponent(n)}`),getActivities:(e,n)=>{const s=new URLSearchParams;n?.type&&s.set("type",n.type),n?.limit&&s.set("limit",String(n.limit)),n?.before&&s.set("before",n.before);const i=s.toString();return fe(`/agents/${e}/activities${i?"?"+i:""}`)},getMindState:e=>fe(`/agents/${e}/mind`),getMailbox:(e,n)=>{const s=new URLSearchParams;n?.limit&&s.set("limit",String(n.limit)),n?.offset&&s.set("offset",String(n.offset)),n?.category&&s.set("category",n.category),n?.sourceType&&s.set("sourceType",n.sourceType),n?.status&&s.set("status",n.status);const i=s.toString();return fe(`/agents/${e}/mailbox${i?"?"+i:""}`)},getDecisions:(e,n=50)=>fe(`/agents/${e}/decisions?limit=${n}`),message:(e,n,s,i)=>fe(`/agents/${e}/message`,{method:"POST",body:JSON.stringify({text:n,images:s,sessionId:i??void 0})}),messageStream:(e,n,s,i,l,d,c,h)=>new Promise(async(m,f)=>{let x="",p;try{const g=await fetch(`${T1}/agents/${e}/message`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({text:n,stream:!0,images:d,sessionId:c??void 0,isRetry:h||void 0}),signal:l});if(!g.ok){f(new Error(`API error: ${g.status}`));return}const y=g.body?.getReader();if(!y){f(new Error("No reader"));return}const w=new TextDecoder;let N="";for(;;){const{done:T,value:C}=await y.read();if(T)break;N+=w.decode(C,{stream:!0});const _=N.split(`
|
|
10
|
-
`);N=_.pop()??"";for(const k of _){const M=k.trim();if(M.startsWith("data: "))try{const D=JSON.parse(M.slice(6));if(D.type==="text_delta"&&D.text)x+=D.text,s(D.text);else if(D.type==="thinking_delta"&&D.thinking)s?.(`<think>${D.thinking}</think>`);else if(D.type==="done")x=D.content??x,D.sessionId&&(p=D.sessionId);else if(D.type==="error"){const A=D;A.sessionId&&(p=A.sessionId);const G=new Error(A.message??A.error??"Unknown stream error");G.sessionId=A.sessionId,f(G),y.cancel().catch(()=>{});return}else D.type==="tool_call_start"&&D.toolCall?.name?i?.({tool:D.toolCall.name,phase:"start"}):D.type==="agent_tool"&&D.tool&&D.phase?D.phase==="start"?i?.({tool:D.tool,phase:"start",arguments:D.arguments}):D.phase==="end"&&i?.({tool:D.tool,phase:"end",success:D.success,arguments:D.arguments,result:D.result,error:D.error,durationMs:D.durationMs}):D.type==="tool_output"&&D.tool?i?.({tool:D.tool,phase:"output",output:D.text}):D.type==="subagent_progress"&&D.tool&&i?.({tool:D.tool,phase:"subagent_progress",subagentEvent:D.subagentEvent})}catch{}}}m({content:x,sessionId:p})}catch(g){g instanceof Error&&g.name==="AbortError"?m({content:x,sessionId:p}):f(g)}})},roles:{list:()=>fe("/roles")},teams:{list:e=>fe(`/teams?orgId=${e??"default"}`),create:(e,n)=>fe("/teams",{method:"POST",body:JSON.stringify({name:e,description:n})}),update:(e,n)=>fe(`/teams/${e}`,{method:"PATCH",body:JSON.stringify(n)}),delete:(e,n,s)=>fe(`/teams/${e}?deleteMembers=${n?"true":"false"}${s?.purgeFiles?"&purgeFiles=true":""}`,{method:"DELETE"}),addMember:(e,n,s)=>fe(`/teams/${e}/members`,{method:"POST",body:JSON.stringify({memberId:n,memberType:s})}),removeMember:(e,n)=>fe(`/teams/${e}/members/${n}`,{method:"DELETE"}),startAll:e=>fe(`/teams/${e}/start`,{method:"POST"}),stopAll:e=>fe(`/teams/${e}/stop`,{method:"POST"}),pauseAll:(e,n)=>fe(`/teams/${e}/pause`,{method:"POST",body:JSON.stringify({reason:n})}),resumeAll:e=>fe(`/teams/${e}/resume`,{method:"POST"}),status:e=>fe(`/teams/${e}/status`),getFiles:e=>fe(`/teams/${e}/files`),getFile:(e,n)=>fe(`/teams/${e}/files/${encodeURIComponent(n)}`),updateFile:(e,n,s)=>fe(`/teams/${e}/files/${encodeURIComponent(n)}`,{method:"PUT",body:JSON.stringify({content:s})}),exportTeam:e=>fe(`/teams/${e}/export`,{method:"POST"}),getFilesMap:e=>fe(`/teams/${e}/export`)},externalAgents:{list:e=>fe(`/external-agents?orgId=${e??"default"}`)},tasks:{list:e=>{const n=new URLSearchParams;e?.assignedAgentId&&n.set("assignedAgentId",e.assignedAgentId),e?.status&&n.set("status",e.status),e?.projectId&&n.set("projectId",e.projectId),e?.requirementId&&n.set("requirementId",e.requirementId),e?.priority&&n.set("priority",e.priority),e?.search&&n.set("search",e.search),e?.sortBy&&n.set("sortBy",e.sortBy),e?.sortOrder&&n.set("sortOrder",e.sortOrder),e?.page!==null&&e?.page!==void 0&&n.set("page",String(e.page)),e?.pageSize!==null&&e?.pageSize!==void 0&&n.set("pageSize",String(e.pageSize));const s=n.toString();return fe(`/tasks${s?`?${s}`:""}`)},get:e=>fe(`/tasks/${e}`),create:(e,n,s,i,l,d,c,h,m,f)=>fe("/tasks",{method:"POST",body:JSON.stringify({title:e,description:n,assignedAgentId:s,reviewerAgentId:i,priority:l,projectId:d,blockedBy:c,requirementId:h,taskType:m,scheduleConfig:f})}),update:(e,n)=>fe(`/tasks/${e}`,{method:"PUT",body:JSON.stringify(n)}),updateStatus:(e,n)=>fe(`/tasks/${e}`,{method:"PUT",body:JSON.stringify({status:n})}),assign:(e,n)=>fe(`/tasks/${e}`,{method:"PUT",body:JSON.stringify({assignedAgentId:n})}),approve:e=>fe(`/tasks/${e}/approve`,{method:"POST"}),reject:e=>fe(`/tasks/${e}/reject`,{method:"POST"}),cancel:(e,n=!1)=>fe(`/tasks/${e}/cancel`,{method:"POST",body:JSON.stringify({cascade:n})}),getDependentCount:e=>fe(`/tasks/${e}/dependents`),board:e=>{const n=new URLSearchParams;e?.projectId&&n.set("projectId",e.projectId);const s=n.toString();return fe(`/taskboard${s?`?${s}`:""}`)},listSubtasks:e=>fe(`/tasks/${e}/subtasks`),createSubtask:(e,n)=>fe(`/tasks/${e}/subtasks`,{method:"POST",body:JSON.stringify({title:n})}),completeSubtask:(e,n)=>fe(`/tasks/${e}/subtasks/${n}/complete`,{method:"POST"}),cancelSubtask:(e,n)=>fe(`/tasks/${e}/subtasks/${n}/cancel`,{method:"POST"}),deleteSubtask:(e,n)=>fe(`/tasks/${e}/subtasks/${n}`,{method:"DELETE"}),run:e=>fe(`/tasks/${e}/run`,{method:"POST"}),getLogs:(e,n)=>fe(`/tasks/${e}/logs${n!=null?`?round=${n}`:""}`),getLogsSummary:e=>fe(`/tasks/${e}/logs/summary`),accept:(e,n)=>fe(`/tasks/${e}/accept`,{method:"POST",body:JSON.stringify({reviewerAgentId:n??"human"})}),revision:(e,n,s)=>fe(`/tasks/${e}/revision`,{method:"POST",body:JSON.stringify({reason:n,reviewerAgentId:s??"human"})}),archive:e=>fe(`/tasks/${e}/archive`,{method:"POST"}),pause:e=>fe(`/tasks/${e}/pause`,{method:"POST"}),resume:e=>fe(`/tasks/${e}/resume`,{method:"POST"}),retry:e=>fe(`/tasks/${e}/retry`,{method:"POST"}),getComments:e=>fe(`/tasks/${e}/comments`),addComment:(e,n,s,i,l,d,c)=>fe(`/tasks/${e}/comments`,{method:"POST",body:JSON.stringify({content:n,authorId:l??"human",authorName:s??"User",authorType:"human",attachments:i,mentions:d,replyTo:c})}),pauseSchedule:e=>fe(`/tasks/${e}/schedule/pause`,{method:"POST"}),resumeSchedule:e=>fe(`/tasks/${e}/schedule/resume`,{method:"POST"}),runNow:e=>fe(`/tasks/${e}/schedule/run-now`,{method:"POST"}),deliverables:e=>{const n=e?`?projectId=${encodeURIComponent(e)}`:"";return fe(`/tasks/deliverables${n}`)}},files:{preview:e=>fe(`/files/preview?path=${encodeURIComponent(e)}`),reveal:e=>fe("/files/reveal",{method:"POST",body:JSON.stringify({path:e})})},requirements:{list:e=>{const n=new URLSearchParams;e?.orgId&&n.set("orgId",e.orgId),e?.status&&n.set("status",e.status),e?.source&&n.set("source",e.source),e?.projectId&&n.set("projectId",e.projectId);const s=n.toString();return fe(`/requirements${s?`?${s}`:""}`)},get:e=>fe(`/requirements/${e}`),create:e=>fe("/requirements",{method:"POST",body:JSON.stringify(e)}),update:(e,n)=>fe(`/requirements/${e}`,{method:"PUT",body:JSON.stringify(n)}),updateStatus:(e,n)=>fe(`/requirements/${e}/status`,{method:"POST",body:JSON.stringify({status:n})}),approve:e=>fe(`/requirements/${e}/approve`,{method:"POST"}),reject:(e,n)=>fe(`/requirements/${e}/reject`,{method:"POST",body:JSON.stringify({reason:n})}),cancel:e=>fe(`/requirements/${e}/cancel`,{method:"POST"}),delete:e=>fe(`/requirements/${e}`,{method:"DELETE"}),getComments:e=>fe(`/requirements/${e}/comments`),addComment:(e,n,s,i,l,d)=>fe(`/requirements/${e}/comments`,{method:"POST",body:JSON.stringify({content:n,authorId:i??"human",authorName:s??"User",authorType:"human",mentions:l,replyTo:d})})},users:{list:e=>fe(`/users?orgId=${e??"default"}`),create:(e,n,s,i,l,d)=>fe("/users",{method:"POST",body:JSON.stringify({name:e,role:n,orgId:s,email:i,password:l,teamId:d})}),remove:e=>fe(`/users/${e}`,{method:"DELETE"})},teamTemplates:{list:e=>{const n=e?`?q=${encodeURIComponent(e)}`:"";return fe(`/team-templates${n}`)},get:e=>fe(`/team-templates/${e}`)},ops:{dashboard:(e="24h")=>fe(`/ops/dashboard?period=${e}`)},agentMetrics:(e,n="24h")=>fe(`/agents/${e}/metrics?period=${n}`),usage:{summary:(e="default",n)=>{const s=new URLSearchParams({orgId:e});return n&&s.set("period",n),fe(`/usage?${s}`)},agents:(e="default")=>fe(`/usage/agents?orgId=${e}`)},health:()=>fe("/health"),system:{openPath:e=>fe("/system/open-path",{method:"POST",body:JSON.stringify({path:e})}),storage:()=>fe("/system/storage"),orphans:()=>fe("/system/storage/orphans"),purgeOrphans:e=>fe("/system/storage/orphans",{method:"DELETE",body:e?JSON.stringify({ids:e}):void 0})},settings:{getLlm:()=>fe("/settings/llm"),getAgent:()=>fe("/settings/agent"),updateAgent:e=>fe("/settings/agent",{method:"POST",body:JSON.stringify(e)})},skills:{list:()=>fe("/skills"),builtin:()=>fe("/skills/builtin"),registry:e=>fe(`/skills/registry${e?`?source=${e}`:""}`),registrySkillhub:e=>{const n=new URLSearchParams;e?.q&&n.set("q",e.q),e?.category&&n.set("category",e.category),e?.page&&n.set("page",String(e.page)),e?.limit&&n.set("limit",String(e.limit)),e?.sort&&n.set("sort",e.sort);const s=n.toString();return fe(`/skills/registry/skillhub${s?`?${s}`:""}`)},registrySkillssh:e=>fe(`/skills/registry/skillssh${e?`?q=${encodeURIComponent(e)}`:""}`),import:(e,n,s,i)=>fe("/skills/import",{method:"POST",body:JSON.stringify({name:e,sourceUrl:n,description:s,category:i})}),install:e=>fe("/skills/install",{method:"POST",body:JSON.stringify(e)}),uninstall:e=>fe(`/skills/installed/${encodeURIComponent(e)}`,{method:"DELETE"}),getFilesMap:e=>fe(`/skills/${encodeURIComponent(e)}/files`)},builder:{artifacts:{list:()=>fe("/builder/artifacts"),get:(e,n)=>fe(`/builder/artifacts/${e}s/${encodeURIComponent(n)}`),save:(e,n)=>fe("/builder/artifacts/save",{method:"POST",body:JSON.stringify({mode:e,artifact:n})}),import:(e,n,s,i)=>fe("/builder/artifacts/import",{method:"POST",body:JSON.stringify({type:e,name:n,files:s,source:i})}),install:(e,n)=>fe(`/builder/artifacts/${e}s/${encodeURIComponent(n)}/install`,{method:"POST"}),uninstall:(e,n)=>fe(`/builder/artifacts/${e}s/${encodeURIComponent(n)}/uninstall`,{method:"POST"}),delete:(e,n)=>fe(`/builder/artifacts/${e}s/${encodeURIComponent(n)}`,{method:"DELETE"}),installed:()=>fe("/builder/artifacts/installed")}},auth:{login:(e,n)=>fe("/auth/login",{method:"POST",body:JSON.stringify({email:e,password:n})}),logout:()=>fe("/auth/logout",{method:"POST"}),me:()=>fe("/auth/me"),changePassword:(e,n)=>fe("/auth/change-password",{method:"POST",body:JSON.stringify({currentPassword:e,newPassword:n})})},sessions:{listByAgent:(e,n=20)=>fe(`/agents/${e}/sessions?limit=${n}`),getMessages:(e,n=50,s)=>fe(`/sessions/${e}/messages?limit=${n}${s?`&before=${s}`:""}`),delete:e=>fe(`/sessions/${e}`,{method:"DELETE"})},channels:{getMessages:(e,n=50,s)=>fe(`/channels/${encodeURIComponent(e)}/messages?limit=${n}${s?`&before=${s}`:""}`),sendMessage:(e,n)=>fe(`/channels/${encodeURIComponent(e)}/messages`,{method:"POST",body:JSON.stringify(n)})},governance:{getSystemStatus:()=>fe("/system/status"),pauseAll:e=>fe("/system/pause-all",{method:"POST",body:JSON.stringify({reason:e})}),resumeAll:()=>fe("/system/resume-all",{method:"POST"}),emergencyStop:e=>fe("/system/emergency-stop",{method:"POST",body:JSON.stringify({reason:e})}),getAnnouncements:()=>fe("/system/announcements"),createAnnouncement:e=>fe("/system/announcements",{method:"POST",body:JSON.stringify(e)}),getPolicy:()=>fe("/governance/policy"),setPolicy:e=>fe("/governance/policy",{method:"PUT",body:JSON.stringify(e)})},approvals:{list:e=>{const n=e?`?status=${e}`:"";return fe(`/approvals${n}`)},respond:(e,n,s,i,l)=>fe(`/approvals/${e}`,{method:"POST",body:JSON.stringify({approved:n,respondedBy:s,comment:i,selectedOption:l})})},notifications:{list:(e,n,s)=>{const i=new URLSearchParams;return e&&i.set("userId",e),n&&i.set("unread","true"),s?.type&&i.set("type",s.type),s?.limit&&i.set("limit",String(s.limit)),s?.offset&&i.set("offset",String(s.offset)),fe(`/notifications?${i}`)},markRead:e=>fe(`/notifications/${e}`,{method:"POST"}),markAllRead:e=>fe("/notifications/mark-all-read",{method:"POST",body:JSON.stringify({userId:e})})},projects:{list:e=>{const n=e?`?orgId=${e}`:"";return fe(`/projects${n}`)},get:e=>fe(`/projects/${e}`),create:e=>fe("/projects",{method:"POST",body:JSON.stringify(e)}),update:(e,n)=>fe(`/projects/${e}`,{method:"PUT",body:JSON.stringify(n)}),delete:e=>fe(`/projects/${e}`,{method:"DELETE"})},knowledge:{search:(e,n,s)=>{const i=new URLSearchParams;return e&&i.set("query",e),n&&i.set("scope",n),s&&i.set("category",s),fe(`/knowledge/search?${i}`)},contribute:e=>fe("/knowledge",{method:"POST",body:JSON.stringify(e)}),flagOutdated:(e,n)=>fe(`/knowledge/${e}/flag-outdated`,{method:"POST",body:JSON.stringify({reason:n})}),verify:e=>fe(`/knowledge/${e}/verify`,{method:"POST",body:JSON.stringify({verifiedBy:"human"})}),remove:e=>fe(`/knowledge/${e}`,{method:"DELETE"})},deliverables:{search:e=>{const n=new URLSearchParams;return e?.q&&n.set("q",e.q),e?.projectId&&n.set("projectId",e.projectId),e?.agentId&&n.set("agentId",e.agentId),e?.taskId&&n.set("taskId",e.taskId),e?.type&&n.set("type",e.type),e?.status&&n.set("status",e.status),e?.artifactType&&n.set("artifactType",e.artifactType),e?.offset&&n.set("offset",String(e.offset)),e?.limit&&n.set("limit",String(e.limit)),fe(`/deliverables?${n}`)},create:e=>fe("/deliverables",{method:"POST",body:JSON.stringify(e)}),update:(e,n)=>fe(`/deliverables/${e}`,{method:"PUT",body:JSON.stringify(n)}),remove:e=>fe(`/deliverables/${e}`,{method:"DELETE"}),verify:e=>fe(`/deliverables/${e}`,{method:"PUT",body:JSON.stringify({status:"verified"})})},codeReviews:{list:(e,n=20)=>{const s=new URLSearchParams;return e&&s.set("taskId",e),s.set("limit",String(n)),fe(`/reviews?${s}`)},get:e=>fe(`/reviews/${e}`),run:e=>fe("/reviews",{method:"POST",body:JSON.stringify(e)})},reports:{list:()=>fe("/reports"),get:e=>fe(`/reports/${e}`),generate:e=>fe("/reports/generate",{method:"POST",body:JSON.stringify(e)}),approvePlan:(e,n)=>fe(`/reports/${e}/plan/approve`,{method:"POST",body:JSON.stringify(n)}),rejectPlan:(e,n)=>fe(`/reports/${e}/plan/reject`,{method:"POST",body:JSON.stringify(n)}),addFeedback:(e,n)=>fe(`/reports/${e}/feedback`,{method:"POST",body:JSON.stringify(n)}),getFeedback:e=>fe(`/reports/${e}/feedback`)},executionLogs:{get:(e,n)=>fe(`/execution-logs?sourceType=${encodeURIComponent(e)}&sourceId=${encodeURIComponent(n)}`)}};function bm(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 _1(e,n,s){return e.type==="llm_request"?null:{id:`alog_${n}_${e.seq}`,sourceType:"activity",sourceId:n,agentId:s,seq:e.seq,type:e.type,content:e.content,metadata:e.metadata,createdAt:e.createdAt}}class ok{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`,i=new WebSocket(s);this.ws=i,i.onmessage=l=>{if(this.ws===i)try{const d=JSON.parse(l.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{}},i.onclose=()=>{this.intentionalClose||(this.reconnectTimer=setTimeout(()=>this.connect(),3e3))},i.onerror=()=>{i.close()}}disconnect(){this.intentionalClose=!0,this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.ws&&(this.ws.onclose=null,this.ws.close(),this.ws=null)}on(n,s){return this.handlers.has(n)||this.handlers.set(n,new Set),this.handlers.get(n).add(s),()=>this.handlers.get(n)?.delete(s)}}const Jt=new ok;let Bo=window.__MARKUS_HUB_URL__??"https://markus.global";fe("/settings/hub").then(e=>{e.hubUrl&&(Bo=e.hubUrl);const n=localStorage.getItem("markus_hub_token");n&&fe("/settings/hub-token",{method:"POST",body:JSON.stringify({token:n})}).catch(()=>{})}).catch(()=>{});const ax="markus_hub_token",ix="markus_hub_user";function Fa(){return localStorage.getItem(ax)}function ck(){try{const e=localStorage.getItem(ix);return e?JSON.parse(e):null}catch{return null}}function A1(){localStorage.removeItem(ax),localStorage.removeItem(ix),M1(null)}function ym(e,n){localStorage.setItem(ax,e),localStorage.setItem(ix,JSON.stringify(n)),M1(e)}function M1(e){fe("/settings/hub-token",{method:"POST",body:JSON.stringify({token:e})}).catch(()=>{})}let go=null;function $a(){if(Fa())return Promise.resolve();if(go)return go;const e=`cs_${Date.now()}_${Math.random().toString(36).slice(2,10)}`;return go=new Promise((n,s)=>{const i=`${Bo}/auth/connect?session=${encodeURIComponent(e)}`,l=460,d=580,c=Math.round(window.screenX+(window.outerWidth-l)/2),h=Math.round(window.screenY+(window.outerHeight-d)/2),m=window.open(i,"markus_hub_auth",`popup=yes,width=${l},height=${d},left=${c},top=${h}`);let f=!1;const x=()=>{clearInterval(p),clearInterval(g),go=null},p=setInterval(async()=>{if(!f)try{const w=await(await fetch(`${Bo}/api/auth/connect-status?session=${encodeURIComponent(e)}`)).json();w.ready&&w.token&&w.user&&(f=!0,ym(w.token,w.user),x(),m?.close(),n())}catch{}},1500),g=setInterval(()=>{f||m?.closed&&(f=!0,x(),Fa()?n():s(new Error("Hub login cancelled")))},500)}),go}async function ds(e,n){const s=Fa(),i={"Content-Type":"application/json",...n?.headers};s&&(i.Authorization=`Bearer ${s}`);const l=await fetch(`${Bo}/api${e}`,{...n,headers:i}),d=await l.json();if(l.status===401&&s&&A1(),!l.ok)throw new Error(d.error??`Hub HTTP ${l.status}`);return d}const Zn={getUrl:()=>Bo,isAuthenticated:()=>!!Fa(),getUser:ck,logout:()=>{A1()},ensureAuth:$a,login:async(e,n)=>{const s=await ds("/auth/login",{method:"POST",body:JSON.stringify({email:e,password:n})});return ym(s.token,s.user),s},register:async(e,n,s)=>{const i=await ds("/auth/register",{method:"POST",body:JSON.stringify({username:e,email:n,password:s})});return ym(i.token,i.user),i},search:e=>{const n=new URLSearchParams;e?.type&&n.set("type",e.type),e?.q&&n.set("q",e.q),e?.category&&n.set("category",e.category),e?.sort&&n.set("sort",e.sort),e?.page&&n.set("page",String(e.page)),e?.limit&&n.set("limit",String(e.limit));const s=n.toString();return ds(`/items${s?`?${s}`:""}`)},getItem:e=>ds(`/items/${e}`),download:async e=>{await $a();try{return await ds(`/items/${e}/download`,{method:"POST"})}catch(n){if(!Fa())return await $a(),ds(`/items/${e}/download`,{method:"POST"});throw n}},publish:async e=>{await $a();try{return await ds("/items",{method:"POST",body:JSON.stringify(e)})}catch(n){if(!Fa())return await $a(),ds("/items",{method:"POST",body:JSON.stringify(e)});throw n}},publishViaProxy:async e=>{await $a();try{return await ds("/items",{method:"POST",body:JSON.stringify(e)})}catch(n){if(!Fa())return await $a(),ds("/items",{method:"POST",body:JSON.stringify(e)});throw n}},myItems:async()=>Fa()?ds("/items/mine"):{items:[]},deleteItem:async e=>(await $a(),ds(`/items/${e}`,{method:"DELETE"}))};let _b=null;const ht={setHandler(e){_b=e},navigate(e,n){n&&Object.entries(n).forEach(([s,i])=>localStorage.setItem(`markus_nav_${s}`,i)),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:e,params:n}})),_b?.(e,n)}};var lx=E1();const Ab={urgent:"bg-red-500",high:"bg-amber-500",normal:"bg-blue-500",low:"bg-gray-400"},Th={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",task_created:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",task_status_changed:"M23 4v6h-6 M1 20v-6h6 M3.51 9a9 9 0 0 1 14.85-3.36L23 10 M1 14l4.64 4.36A9 9 0 0 0 20.49 15",requirement_created:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7 M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z",requirement_decision:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",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",agent_report:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8",agent_chat_request:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",agent_escalation:"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",mention:"M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2 M12.5 7a4 4 0 1 1-8 0 4 4 0 0 1 8 0z M20 8v6 M23 11h-6",system:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"},dk={task_completed:"text-green-500",task_failed:"text-red-500",task_created:"text-blue-500",task_review:"text-purple-500",task_status_changed:"text-blue-400",requirement_created:"text-amber-500",requirement_decision:"text-green-500",approval_request:"text-amber-500",agent_alert:"text-red-500",agent_escalation:"text-red-400",agent_report:"text-blue-500",agent_chat_request:"text-brand-500",agent_notification:"text-blue-400",bounty_posted:"text-amber-500",mention:"text-brand-500",system:"text-fg-tertiary"};function Mb(e){const n=Date.now()-new Date(e).getTime(),s=Math.floor(n/6e4);if(s<1)return"now";if(s<60)return`${s}m`;const i=Math.floor(s/60);return i<24?`${i}h`:`${Math.floor(i/24)}d`}function Rb(e){const n=e.actionType;if(n==="open_chat")return"Open chat →";if(n==="navigate")return"View details →";const s=e.metadata??{};switch(e.type){case"task_completed":case"task_created":case"task_review":case"task_failed":case"task_status_changed":return s.taskId?"View task →":null;case"requirement_created":case"requirement_decision":return s.requirementId?"View requirement →":null;case"agent_chat_request":return"Open chat →";case"agent_alert":case"agent_escalation":case"agent_notification":return s.agentId?"Open chat →":null;case"approval_request":return"View approval →";default:return s.taskId?"View task →":s.requirementId?"View requirement →":s.agentId?"View agent →":null}}function uk(){try{const e=new AudioContext,n=e.currentTime,s=e.createGain();s.connect(e.destination),s.gain.setValueAtTime(.15,n),s.gain.exponentialRampToValueAtTime(.01,n+.6);const i=e.createOscillator();i.type="sine",i.frequency.setValueAtTime(880,n),i.frequency.setValueAtTime(1174.66,n+.15),i.connect(s),i.start(n),i.stop(n+.6),i.onended=()=>e.close()}catch{}}function vm({collapsed:e,userId:n}){const[s,i]=v.useState(!1),[l,d]=v.useState("approvals"),[c,h]=v.useState([]),[m,f]=v.useState([]),[x,p]=v.useState(null),[g,y]=v.useState(null),[w,N]=v.useState(""),[T,C]=v.useState(""),[_,k]=v.useState(0),M=v.useRef(null),D=v.useRef(null),[A,G]=v.useState({top:0,left:0,width:448,maxHeight:576}),X=v.useRef(null),K=v.useCallback(async()=>{try{const[O,V]=await Promise.all([se.notifications.list(n,!1),se.approvals.list()]);h(O.notifications),k(O.unreadCount??O.notifications.filter(I=>!I.read).length),f(V.approvals)}catch{}},[n]);v.useEffect(()=>{K();const O=setInterval(K,15e3),V=()=>K();return window.addEventListener("markus:notifications-changed",V),()=>{clearInterval(O),window.removeEventListener("markus:notifications-changed",V)}},[K]);const $=v.useCallback(()=>{if(!M.current)return;const O=M.current.getBoundingClientRect(),V=window.innerWidth,I=window.innerHeight,S=Math.min(448,V-16),H=Math.min(576,I-16);let W=O.right+8,ee=O.top;W+S>V-8&&(W=Math.max(8,V-S-8)),ee+H>I-8&&(ee=Math.max(8,I-H-8)),G({top:ee,left:W,width:S,maxHeight:H})},[]);v.useLayoutEffect(()=>{s&&$()},[s,$]),v.useEffect(()=>{if(s)return window.addEventListener("resize",$),()=>window.removeEventListener("resize",$)},[s,$]),v.useEffect(()=>{if(!s)return;const O=V=>{M.current?.contains(V.target)||D.current?.contains(V.target)||i(!1)};return document.addEventListener("mousedown",O),()=>document.removeEventListener("mousedown",O)},[s]);const q=new Set(m.map(O=>O.id)),U=c.filter(O=>!(O.type==="approval_request"&&O.metadata?.approvalId&&q.has(O.metadata.approvalId))),z=m.filter(O=>O.status==="pending").length,E=_+z;v.useEffect(()=>{X.current!==null&&z>X.current&&uk(),X.current=z},[z]);const L=async O=>{await se.notifications.markRead(O),h(V=>V.map(I=>I.id===O?{...I,read:!0}:I)),k(V=>Math.max(0,V-1))},R=O=>{const V=O.metadata??{},I=O.actionType,S=O.actionTarget;if(I==="open_chat"&&S)try{const H=typeof S=="string"?JSON.parse(S):S;if(H.agentId){const W={agentId:H.agentId};H.sessionId&&(W.sessionId=H.sessionId),ht.navigate(me.TEAM,W);return}}catch{}if(I==="navigate"&&S)try{const H=typeof S=="string"?JSON.parse(S):S;if(H.path&&H.path.startsWith("/work")){const W={},ee=new URLSearchParams(H.path.split("?")[1]||"");for(const[te,ae]of ee.entries())W[te]=ae;ht.navigate(me.WORK,W);return}}catch{}switch(O.type){case"approval_request":{const H=V.approvalId,ee=(H?m.find(te=>te.id===H):void 0)?.details?.taskId??V.taskId;ee?ht.navigate(me.WORK,{openTask:ee}):ht.navigate(me.WORK);break}case"task_completed":case"task_created":case"task_review":case"task_failed":case"task_status_changed":V.taskId?ht.navigate(me.WORK,{openTask:V.taskId}):ht.navigate(me.WORK);break;case"requirement_created":case"requirement_decision":V.requirementId?ht.navigate(me.WORK,{openRequirement:V.requirementId}):ht.navigate(me.WORK);break;case"agent_chat_request":{const H={};V.agentId&&(H.agentId=V.agentId),V.sessionId&&(H.sessionId=V.sessionId),ht.navigate(me.TEAM,Object.keys(H).length>0?H:void 0);break}case"agent_notification":case"agent_alert":case"agent_escalation":{if(V.agentId){const H={agentId:V.agentId};V.sessionId&&(H.sessionId=V.sessionId),ht.navigate(me.TEAM,H)}else ht.navigate(me.TEAM);break}case"bounty_posted":ht.navigate(me.SETTINGS);break;default:V.taskId?ht.navigate(me.WORK,{openTask:V.taskId}):V.requirementId?ht.navigate(me.WORK,{openRequirement:V.requirementId}):V.projectId?ht.navigate(me.WORK,{projectId:V.projectId}):V.agentId&&ht.navigate(me.TEAM,{agentId:V.agentId});break}},F=async O=>{O.read||L(O.id);const V=O.metadata??{},I=V.taskId,S=V.requirementId;if(I||S){const H=c.filter(W=>W.id!==O.id&&!W.read&&(I&&W.metadata?.taskId===I||S&&W.metadata?.requirementId===S));for(const W of H)L(W.id)}R(O)},Y=async(O,V,I,S)=>{p(O);try{const{approval:H}=await se.approvals.respond(O,V,n,I,S);f(ee=>ee.map(te=>te.id===O?H:te)),y(null),N(""),C("");const W=c.find(ee=>ee.type==="approval_request"&&ee.metadata?.approvalId===O);W&&!W.read&&(se.notifications.markRead(W.id),h(ee=>ee.map(te=>te.id===W.id?{...te,read:!0}:te))),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}catch{}p(null)},Z=async()=>{try{await se.notifications.markAllRead(n??"default"),h(O=>O.map(V=>({...V,read:!0}))),k(0)}catch{const O=U.filter(V=>!V.read);await Promise.all(O.map(V=>se.notifications.markRead(V.id))),h(V=>V.map(I=>({...I,read:!0}))),k(0)}},B=O=>{const V=O.details?.taskId,I=O.details?.agentId;V?ht.navigate(me.WORK,{openTask:V}):I?ht.navigate(me.TEAM,{agentId:I}):ht.navigate(me.WORK)};return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:M,onClick:()=>{i(!s),s||K()},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"})]}),E>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:E>99?"99+":E})]}),s&&lx.createPortal(t.jsxs("div",{ref:D,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:A.top,left:A.left,width:A.width,maxHeight:A.maxHeight},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 ${l==="approvals"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:["Approvals",z>0?` (${z})`:""]}),t.jsxs("button",{onClick:()=>d("notifications"),className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${l==="notifications"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:["Notifications",_>0?` (${_})`:""]}),t.jsx("button",{onClick:()=>i(!1),className:"px-2 py-2 text-fg-tertiary hover:text-fg-primary transition-colors shrink-0",title:"Close",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("path",{d:"M18 6L6 18"}),t.jsx("path",{d:"M6 6l12 12"})]})})]}),l==="notifications"&&_>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:Z,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:[l==="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(O=>O.status==="pending").map(O=>{const V=O.details?.command,I=V?O.description.replace(/\s*Command:.*$/,""):O.description;return t.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[t.jsxs("div",{className:"flex items-start gap-2",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:Th.approval_request})}),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 text-fg-primary font-medium",children:O.title}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Mb(O.requestedAt)})]}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:O.agentName})]})]}),t.jsx("p",{className:"text-[11px] text-fg-secondary leading-relaxed",children:I}),V&&t.jsx("pre",{className:"text-[11px] text-fg-primary bg-surface-overlay border border-border-default rounded-md px-2.5 py-2 overflow-x-auto whitespace-pre-wrap break-all font-mono leading-relaxed",children:V}),t.jsx("button",{onClick:()=>B(O),className:"text-[11px] text-brand-500 hover:text-brand-400 transition-colors",children:"View execution context →"}),O.options&&O.options.length>0?t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("div",{className:"flex flex-wrap gap-1.5",children:O.options.map(S=>t.jsx("button",{disabled:x===O.id,onClick:()=>Y(O.id,!0,void 0,S.id),className:"px-2.5 py-1.5 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors",title:S.description,children:S.label},S.id))}),O.allowFreeform&&t.jsxs("div",{className:"flex gap-1.5",children:[t.jsx("input",{type:"text",placeholder:"Type your response...",value:T,onChange:S=>C(S.target.value),onKeyDown:S=>{S.key==="Enter"&&T.trim()&&Y(O.id,!0,T.trim(),"custom")},className:"flex-1 px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),t.jsx("button",{disabled:x===O.id||!T.trim(),onClick:()=>Y(O.id,!0,T.trim(),"custom"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors",children:"Send"})]})]}):g===O.id?t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("input",{type:"text",autoFocus:!0,placeholder:"Reason for rejection (optional, Enter to submit)",value:w,onChange:S=>N(S.target.value),onKeyDown:S=>{S.key==="Enter"&&Y(O.id,!1,w||void 0,"reject"),S.key==="Escape"&&(y(null),N(""))},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-amber-500/50"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:x===O.id,onClick:()=>Y(O.id,!1,w||void 0,"reject"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium bg-red-600 text-white rounded-md hover:bg-red-700 disabled:opacity-50 transition-colors",children:"Confirm Reject"}),t.jsx("button",{onClick:()=>{y(null),N("")},className:"px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay transition-colors",children:"Cancel"})]}),O.allowFreeform&&t.jsxs("div",{className:"flex gap-1.5 mt-1",children:[t.jsx("input",{type:"text",placeholder:"Or type your response...",value:T,onChange:S=>C(S.target.value),onKeyDown:S=>{S.key==="Enter"&&T.trim()&&Y(O.id,!0,T.trim(),"custom")},className:"flex-1 px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),t.jsx("button",{disabled:x===O.id||!T.trim(),onClick:()=>Y(O.id,!0,T.trim(),"custom"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors",children:"Send"})]})]}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:x===O.id,onClick:()=>Y(O.id,!0,void 0,"approve"),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===O.id,onClick:()=>{y(O.id),N("")},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"})]}),O.allowFreeform&&t.jsxs("div",{className:"flex gap-1.5",children:[t.jsx("input",{type:"text",placeholder:"Or type your response...",value:T,onChange:S=>C(S.target.value),onKeyDown:S=>{S.key==="Enter"&&T.trim()&&Y(O.id,!0,T.trim(),"custom")},className:"flex-1 px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),t.jsx("button",{disabled:x===O.id||!T.trim(),onClick:()=>Y(O.id,!0,T.trim(),"custom"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors",children:"Send"})]})]})]},O.id)}),m.filter(O=>O.status!=="pending").slice(0,20).map(O=>t.jsxs("button",{onClick:()=>B(O),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 ${O.status==="approved"?"bg-green-500":"bg-red-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1",children:O.title}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:O.status})]}),O.responseComment&&t.jsxs("p",{className:"text-[10px] text-fg-tertiary mt-0.5 pl-3.5 truncate",children:["“",O.responseComment,"”"]})]},O.id))]})),l==="notifications"&&(U.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:U.slice(0,50).map(O=>{const V=dk[O.type]??"text-fg-tertiary";return t.jsxs("button",{onClick:()=>F(O),className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors ${O.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:V,children:t.jsx("path",{d:Th[O.type]??Th.system})})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[!O.read&&t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Ab[O.priority]??Ab.normal}`}),t.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:O.title})]}),t.jsx("p",{className:"text-[11px] text-fg-tertiary line-clamp-2 mt-0.5",children:O.body}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("span",{className:"text-[10px] text-fg-muted",children:Mb(O.createdAt)}),Rb(O)&&t.jsx("span",{className:`text-[10px] font-medium ${V}`,children:Rb(O)})]})]})]},O.id)})}))]})]}),document.body)]})}const fk="(max-width: 767px)";let _h=null;function R1(){return _h||(_h=window.matchMedia(fk)),_h}function hk(e){const n=R1();return n.addEventListener("change",e),()=>n.removeEventListener("change",e)}function mk(){return R1().matches}function xk(){return!1}function $r(){return v.useSyncExternalStore(hk,mk,xk)}function Ob({authUser:e}={}){const n=$r(),[s,i]=v.useState([]),[l,d]=v.useState([]),[c,h]=v.useState({}),[m,f]=v.useState(null),x="7d",[p,g]=v.useState([]),[y,w]=v.useState(null),N=()=>{se.agents.list().then($=>i($.agents)).catch(()=>{}),se.teams.list().then($=>d($.teams)).catch(()=>{}),se.tasks.board().then($=>h($.board)).catch(()=>{}),se.ops.dashboard(x).then(f).catch(()=>{}),se.requirements.list({source:"agent"}).then($=>{g($.requirements.filter(q=>q.status==="pending"))}).catch(()=>{}),se.system.storage().then(w).catch(()=>{})};v.useEffect(()=>{N();const $=setInterval(N,3e4),q=()=>N();return window.addEventListener("markus:data-changed",q),()=>{clearInterval($),window.removeEventListener("markus:data-changed",q)}},[x]);const T=$=>$,C={};for(const[$,q]of Object.entries(c)){const U=T(q).length;U>0&&(C[$]=U)}const _=C.pending??0,k=C.in_progress??0,M=C.completed??0;C.failed;const D=Object.values(C).reduce(($,q)=>$+q,0),A=s.filter($=>$.status==="idle"||$.status==="working").length,G=s.filter($=>$.status==="working").length,X=s.reduce(($,q)=>$+(q.mailboxDepth??0),0),K=v.useMemo(()=>{const $=new Map(s.map(q=>[q.id,q]));return l.map(q=>{const U=q.members.filter(L=>L.type==="agent").map(L=>$.get(L.id)).filter(L=>!!L),z=U.filter(L=>L.status==="working").length,E=U.filter(L=>L.status==="idle"||L.status==="working").length;return{team:q,agents:U,working:z,active:E,total:U.length}})},[l,s]);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:[n&&t.jsx(vm,{collapsed:!0,userId:e?.id}),t.jsx("h2",{className:"text-lg font-semibold",children:"Overview"})]}),t.jsx("div",{className:"flex gap-2",children:t.jsx("button",{onClick:()=>ht.navigate(me.STORE,{storeTab:"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(xd,{label:"Active Agents",value:A,total:s.length,color:"indigo",onClick:()=>ht.navigate(me.TEAM)}),t.jsx(xd,{label:"Tasks In Progress",value:k,color:"blue",onClick:()=>ht.navigate(me.WORK)}),t.jsx(xd,{label:"Pending Queue",value:_,color:"amber",onClick:()=>ht.navigate(me.WORK)}),t.jsx(xd,{label:"Completed",value:M,total:D>0?D:void 0,color:"green",onClick:()=>ht.navigate(me.WORK)})]}),D===0&&(!m||m.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:me.TEAM},{label:"Hire Agents",desc:"Browse templates: developers, researchers, writers, analysts, and more",page:me.STORE},{label:"Create a Project",desc:"Set up requirements and let agents plan, execute, and deliver",page:me.WORK}].map($=>t.jsxs("button",{onClick:()=>ht.navigate($.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:$.label}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1",children:$.desc})]},$.label))})]}),G>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:"Agent Focus"}),X>0&&t.jsxs("span",{className:"text-xs text-fg-tertiary",children:[X," total queued"]})]}),t.jsx("div",{className:"space-y-1.5",children:s.filter($=>$.status==="working").map($=>t.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-surface-elevated/30 hover:bg-surface-elevated/60 cursor-pointer transition-colors",onClick:()=>ht.navigate(me.TEAM,{agentId:$.id,profileTab:"mind"}),children:[t.jsx("div",{className:"w-5 h-5 rounded-full bg-brand-600/30 flex items-center justify-center text-[9px] font-bold text-brand-400 shrink-0",children:$.name.charAt(0)}),t.jsx("span",{className:"text-xs font-medium text-fg-primary truncate",children:$.name}),t.jsx("span",{className:"text-[10px] text-fg-tertiary truncate flex-1",children:$.currentActivity?.label??"Working..."}),($.mailboxDepth??0)>0&&t.jsxs("span",{className:"text-[9px] bg-amber-500/20 text-amber-400 rounded-full px-1.5 shrink-0",children:[$.mailboxDepth," queued"]}),t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${$.attentionState==="focused"?"bg-brand-400 animate-pulse":$.attentionState==="deciding"?"bg-amber-400 animate-pulse":"bg-green-400"}`})]},$.id))})]}),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:[D>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:()=>ht.navigate(me.WORK),children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider mb-4",children:"Task Distribution"}),t.jsx(gk,{statusCounts:C,total:D}),(C.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"}),C.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:()=>ht.navigate(me.TEAM),className:"text-[11px] text-fg-tertiary hover:text-fg-secondary",children:"View all →"})]}),K.length===0&&s.length===0?t.jsx("div",{className:"text-sm text-fg-tertiary py-4 text-center cursor-pointer",onClick:()=>ht.navigate(me.TEAM),children:"No teams yet. Create a team or hire agents to get started."}):t.jsxs("div",{className:"space-y-4",children:[K.map($=>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:()=>ht.navigate(me.TEAM),children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",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 shrink-0",children:$.team.name.charAt(0)}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-sm font-medium",children:$.team.name}),$.team.description&&t.jsx("div",{className:"text-[11px] text-fg-tertiary truncate max-w-[260px]",children:$.team.description})]}),t.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-fg-tertiary ml-auto shrink-0",children:[t.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-surface-overlay/50",children:[$.total," members"]}),$.working>0&&t.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-blue-500/15 text-blue-500",children:[$.working," working"]}),t.jsxs("span",{className:`px-1.5 py-0.5 rounded ${$.active===$.total?"bg-green-500/15 text-green-600":"bg-surface-overlay/50"}`,children:[$.active," active"]})]})]}),t.jsxs("div",{className:"flex gap-2 flex-wrap",children:[$.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:U=>{U.stopPropagation(),ht.navigate(me.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-blue-400 animate-pulse":"bg-gray-600"}`}),t.jsx("span",{className:"text-[11px] text-fg-secondary",children:q.name})]},q.id)),$.agents.length>6&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary self-center",children:["+",$.agents.length-6," more"]})]})]},$.team.id)),(()=>{const $=new Set(l.flatMap(U=>U.members.filter(z=>z.type==="agent").map(z=>z.id))),q=s.filter(U=>!$.has(U.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(U=>t.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded bg-surface-overlay/30 cursor-pointer",onClick:()=>ht.navigate(me.TEAM,{selectAgent:U.id}),children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${U.status==="idle"?"bg-green-400":U.status==="working"?"bg-blue-400 animate-pulse":"bg-gray-600"}`}),t.jsx("span",{className:"text-[11px] text-fg-secondary",children:U.name})]},U.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:[p.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:()=>ht.navigate(me.WORK),className:"text-[11px] text-fg-tertiary hover:text-fg-secondary",children:"Review →"})]}),t.jsxs("div",{className:"space-y-2",children:[p.slice(0,5).map($=>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:()=>ht.navigate(me.WORK),children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs text-fg-primary font-medium truncate",children:$.title}),t.jsxs("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:["proposed by ",$.createdBy," · ",$.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:$.source==="agent"?"Agent":"User"})]},$.id)),p.length>5&&t.jsxs("div",{className:"text-[10px] text-fg-tertiary text-center pt-1",children:["+",p.length-5," more"]})]}),t.jsxs("p",{className:"text-[10px] text-fg-tertiary mt-3",children:["Agents proposed ",p.length," requirement",p.length>1?"s":""," — review to authorize work."]})]}),m&&m.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:()=>ht.navigate(me.WORK),className:"text-[11px] text-fg-tertiary hover:text-fg-secondary",children:"View all →"})]}),t.jsx("div",{className:"space-y-1.5",children:m.taskKPI.recentActivity.slice(0,8).map($=>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:()=>ht.navigate(me.WORK,{openTask:$.taskId}),children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${jm[$.status]??"bg-gray-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1",children:$.title}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date($.updatedAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]},$.taskId))})]}),m&&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(bo,{label:"Health Score",value:m.systemHealth.overallScore,max:100,unit:"%",color:m.systemHealth.overallScore>=80?"green":m.systemHealth.overallScore>=50?"amber":"red"}),t.jsx(bo,{label:"Success Rate",value:m.taskKPI.successRate,max:100,unit:"%",color:m.taskKPI.successRate>=80?"green":"amber"}),t.jsx(bo,{label:"Active / Total",value:A,max:s.length||1,unit:`/${s.length}`,color:"brand"}),t.jsx(bo,{label:"Token Cost",value:parseFloat(m.systemHealth.totalTokenCost.toFixed(2)),max:Math.max(1,Math.ceil(m.systemHealth.totalTokenCost*2)),unit:"$",color:"brand",raw:!0}),t.jsx(bo,{label:"Working Now",value:G,max:s.length||1,unit:`/${s.length}`,color:"blue"})]}),m.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:",m.systemHealth.criticalAgents.map($=>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:()=>ht.navigate(me.TEAM,{selectAgent:$.id}),children:[$.name," (",$.score,"%)"]},$.id))]})})]}),y&&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:()=>ht.navigate(me.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:Db(y.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: ",Db(y.database.size)]}),t.jsxs("span",{children:["Agents: ",y.agents.length]})]}),t.jsx("div",{className:"mt-2 text-[10px] text-fg-tertiary",children:"Click to view details in Settings"})]})]})]})]})]})}const jm={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"},pk={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 gk({statusCounts:e,total:n}){const s=Object.entries(e).filter(([,i])=>i>0).sort(([,i],[,l])=>l-i);return t.jsxs("div",{children:[t.jsx("div",{className:"flex h-4 rounded-full overflow-hidden gap-0.5 mb-4",children:s.map(([i,l])=>t.jsx("div",{className:`${jm[i]??"bg-gray-600"} transition-all`,style:{width:`${l/n*100}%`},title:`${i}: ${l}`},i))}),t.jsx("div",{className:"flex gap-4 flex-wrap",children:s.map(([i,l])=>t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:`w-2.5 h-2.5 rounded-sm ${jm[i]??"bg-gray-600"}`}),t.jsx("span",{className:"text-xs text-fg-secondary capitalize",children:i.replace(/_/g," ")}),t.jsx("span",{className:`text-xs font-semibold ${pk[i]??"text-fg-secondary"}`,children:l})]},i))})]})}function xd({label:e,value:n,total:s,color:i,onClick:l}){const d={indigo:{text:"text-brand-400",border:"border-l-brand-500",glow:"hover:shadow-brand-500/10"},blue:{text:"text-blue-400",border:"border-l-blue-500",glow:"hover:shadow-blue-500/10"},amber:{text:"text-amber-400",border:"border-l-amber-500",glow:"hover:shadow-amber-500/10"},green:{text:"text-green-400",border:"border-l-green-500",glow:"hover:shadow-green-500/10"}},c=d[i]??d.indigo;return t.jsxs("div",{onClick:l,className:`bg-surface-secondary border border-border-default ${c.border} border-l-2 rounded-xl p-5 cursor-pointer hover:bg-surface-elevated/80 hover:shadow-lg ${c.glow} transition-all duration-200`,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:[n,s!==void 0&&t.jsxs("span",{className:"text-base font-normal text-fg-muted",children:["/",s]})]})]})}function bo({label:e,value:n,max:s,unit:i,color:l,raw:d}){const c=s>0?Math.min(n/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[l]??"bg-gray-400",x=m[l]??"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?`${i}${n}`:t.jsxs(t.Fragment,{children:[n,t.jsx("span",{className:"text-[10px] font-normal text-fg-tertiary",children:i})]})})]}),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 Db(e){if(e===0)return"0 B";const n=["B","KB","MB","GB"],s=Math.min(Math.floor(Math.log(e)/Math.log(1024)),n.length-1),i=e/Math.pow(1024,s);return`${i<10?i.toFixed(1):Math.round(i)} ${n[s]}`}function bk(e,n){const s={};return(e[e.length-1]===""?[...e,""]:e).join((s.padRight?" ":"")+","+(s.padLeft===!1?"":" ")).trim()}const yk=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,vk=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,jk={};function Lb(e,n){return(jk.jsx?vk:yk).test(e)}const wk=/[ \t\n\f\r]/g;function Nk(e){return typeof e=="object"?e.type==="text"?Ib(e.value):!1:Ib(e)}function Ib(e){return e.replace(wk,"")===""}class tc{constructor(n,s,i){this.normal=s,this.property=n,i&&(this.space=i)}}tc.prototype.normal={};tc.prototype.property={};tc.prototype.space=void 0;function O1(e,n){const s={},i={};for(const l of e)Object.assign(s,l.property),Object.assign(i,l.normal);return new tc(s,i,n)}function wm(e){return e.toLowerCase()}class Br{constructor(n,s){this.attribute=s,this.property=n}}Br.prototype.attribute="";Br.prototype.booleanish=!1;Br.prototype.boolean=!1;Br.prototype.commaOrSpaceSeparated=!1;Br.prototype.commaSeparated=!1;Br.prototype.defined=!1;Br.prototype.mustUseProperty=!1;Br.prototype.number=!1;Br.prototype.overloadedBoolean=!1;Br.prototype.property="";Br.prototype.spaceSeparated=!1;Br.prototype.space=void 0;let kk=0;const $t=Ti(),Qn=Ti(),Nm=Ti(),Pe=Ti(),Tn=Ti(),pl=Ti(),Qr=Ti();function Ti(){return 2**++kk}const km=Object.freeze(Object.defineProperty({__proto__:null,boolean:$t,booleanish:Qn,commaOrSpaceSeparated:Qr,commaSeparated:pl,number:Pe,overloadedBoolean:Nm,spaceSeparated:Tn},Symbol.toStringTag,{value:"Module"})),Ah=Object.keys(km);class ox extends Br{constructor(n,s,i,l){let d=-1;if(super(n,s),zb(this,"space",l),typeof i=="number")for(;++d<Ah.length;){const c=Ah[d];zb(this,Ah[d],(i&km[c])===km[c])}}}ox.prototype.defined=!0;function zb(e,n,s){s&&(e[n]=s)}function _l(e){const n={},s={};for(const[i,l]of Object.entries(e.properties)){const d=new ox(i,e.transform(e.attributes||{},i),l,e.space);e.mustUseProperty&&e.mustUseProperty.includes(i)&&(d.mustUseProperty=!0),n[i]=d,s[wm(i)]=i,s[wm(d.attribute)]=i}return new tc(n,s,e.space)}const D1=_l({properties:{ariaActiveDescendant:null,ariaAtomic:Qn,ariaAutoComplete:null,ariaBusy:Qn,ariaChecked:Qn,ariaColCount:Pe,ariaColIndex:Pe,ariaColSpan:Pe,ariaControls:Tn,ariaCurrent:null,ariaDescribedBy:Tn,ariaDetails:null,ariaDisabled:Qn,ariaDropEffect:Tn,ariaErrorMessage:null,ariaExpanded:Qn,ariaFlowTo:Tn,ariaGrabbed:Qn,ariaHasPopup:null,ariaHidden:Qn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Tn,ariaLevel:Pe,ariaLive:null,ariaModal:Qn,ariaMultiLine:Qn,ariaMultiSelectable:Qn,ariaOrientation:null,ariaOwns:Tn,ariaPlaceholder:null,ariaPosInSet:Pe,ariaPressed:Qn,ariaReadOnly:Qn,ariaRelevant:null,ariaRequired:Qn,ariaRoleDescription:Tn,ariaRowCount:Pe,ariaRowIndex:Pe,ariaRowSpan:Pe,ariaSelected:Qn,ariaSetSize:Pe,ariaSort:null,ariaValueMax:Pe,ariaValueMin:Pe,ariaValueNow:Pe,ariaValueText:null,role:null},transform(e,n){return n==="role"?n:"aria-"+n.slice(4).toLowerCase()}});function L1(e,n){return n in e?e[n]:n}function I1(e,n){return L1(e,n.toLowerCase())}const Sk=_l({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:pl,acceptCharset:Tn,accessKey:Tn,action:null,allow:null,allowFullScreen:$t,allowPaymentRequest:$t,allowUserMedia:$t,alt:null,as:null,async:$t,autoCapitalize:null,autoComplete:Tn,autoFocus:$t,autoPlay:$t,blocking:Tn,capture:null,charSet:null,checked:$t,cite:null,className:Tn,cols:Pe,colSpan:null,content:null,contentEditable:Qn,controls:$t,controlsList:Tn,coords:Pe|pl,crossOrigin:null,data:null,dateTime:null,decoding:null,default:$t,defer:$t,dir:null,dirName:null,disabled:$t,download:Nm,draggable:Qn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:$t,formTarget:null,headers:Tn,height:Pe,hidden:Nm,high:Pe,href:null,hrefLang:null,htmlFor:Tn,httpEquiv:Tn,id:null,imageSizes:null,imageSrcSet:null,inert:$t,inputMode:null,integrity:null,is:null,isMap:$t,itemId:null,itemProp:Tn,itemRef:Tn,itemScope:$t,itemType:Tn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:$t,low:Pe,manifest:null,max:null,maxLength:Pe,media:null,method:null,min:null,minLength:Pe,multiple:$t,muted:$t,name:null,nonce:null,noModule:$t,noValidate:$t,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:$t,optimum:Pe,pattern:null,ping:Tn,placeholder:null,playsInline:$t,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:$t,referrerPolicy:null,rel:Tn,required:$t,reversed:$t,rows:Pe,rowSpan:Pe,sandbox:Tn,scope:null,scoped:$t,seamless:$t,selected:$t,shadowRootClonable:$t,shadowRootDelegatesFocus:$t,shadowRootMode:null,shape:null,size:Pe,sizes:null,slot:null,span:Pe,spellCheck:Qn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Pe,step:null,style:null,tabIndex:Pe,target:null,title:null,translate:null,type:null,typeMustMatch:$t,useMap:null,value:Qn,width:Pe,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Tn,axis:null,background:null,bgColor:null,border:Pe,borderColor:null,bottomMargin:Pe,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:$t,declare:$t,event:null,face:null,frame:null,frameBorder:null,hSpace:Pe,leftMargin:Pe,link:null,longDesc:null,lowSrc:null,marginHeight:Pe,marginWidth:Pe,noResize:$t,noHref:$t,noShade:$t,noWrap:$t,object:null,profile:null,prompt:null,rev:null,rightMargin:Pe,rules:null,scheme:null,scrolling:Qn,standby:null,summary:null,text:null,topMargin:Pe,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Pe,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:$t,disableRemotePlayback:$t,prefix:null,property:null,results:Pe,security:null,unselectable:null},space:"html",transform:I1}),Ck=_l({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:Qr,accentHeight:Pe,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Pe,amplitude:Pe,arabicForm:null,ascent:Pe,attributeName:null,attributeType:null,azimuth:Pe,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Pe,by:null,calcMode:null,capHeight:Pe,className:Tn,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:Pe,diffuseConstant:Pe,direction:null,display:null,dur:null,divisor:Pe,dominantBaseline:null,download:$t,dx:null,dy:null,edgeMode:null,editable:null,elevation:Pe,enableBackground:null,end:null,event:null,exponent:Pe,externalResourcesRequired:null,fill:null,fillOpacity:Pe,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:pl,g2:pl,glyphName:pl,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Pe,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Pe,horizOriginX:Pe,horizOriginY:Pe,id:null,ideographic:Pe,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Pe,k:Pe,k1:Pe,k2:Pe,k3:Pe,k4:Pe,kernelMatrix:Qr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Pe,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:Pe,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:Pe,overlineThickness:Pe,paintOrder:null,panose1:null,path:null,pathLength:Pe,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Tn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Pe,pointsAtY:Pe,pointsAtZ:Pe,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Qr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Qr,rev:Qr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Qr,requiredFeatures:Qr,requiredFonts:Qr,requiredFormats:Qr,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:Pe,specularExponent:Pe,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Pe,strikethroughThickness:Pe,string:null,stroke:null,strokeDashArray:Qr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Pe,strokeOpacity:Pe,strokeWidth:null,style:null,surfaceScale:Pe,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Qr,tabIndex:Pe,tableValues:null,target:null,targetX:Pe,targetY:Pe,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Qr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Pe,underlineThickness:Pe,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Pe,values:null,vAlphabetic:Pe,vMathematical:Pe,vectorEffect:null,vHanging:Pe,vIdeographic:Pe,version:null,vertAdvY:Pe,vertOriginX:Pe,vertOriginY:Pe,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Pe,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:L1}),z1=_l({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,n){return"xlink:"+n.slice(5).toLowerCase()}}),$1=_l({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:I1}),B1=_l({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,n){return"xml:"+n.slice(3).toLowerCase()}}),Ek={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"},Tk=/[A-Z]/g,$b=/-[a-z]/g,_k=/^data[-\w.:]+$/i;function Ak(e,n){const s=wm(n);let i=n,l=Br;if(s in e.normal)return e.property[e.normal[s]];if(s.length>4&&s.slice(0,4)==="data"&&_k.test(n)){if(n.charAt(4)==="-"){const d=n.slice(5).replace($b,Rk);i="data"+d.charAt(0).toUpperCase()+d.slice(1)}else{const d=n.slice(4);if(!$b.test(d)){let c=d.replace(Tk,Mk);c.charAt(0)!=="-"&&(c="-"+c),n="data"+c}}l=ox}return new l(i,n)}function Mk(e){return"-"+e.toLowerCase()}function Rk(e){return e.charAt(1).toUpperCase()}const Ok=O1([D1,Sk,z1,$1,B1],"html"),cx=O1([D1,Ck,z1,$1,B1],"svg");function Dk(e){return e.join(" ").trim()}var al={},Mh,Bb;function Lk(){if(Bb)return Mh;Bb=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,n=/\n/g,s=/^\s*/,i=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,l=/^:\s*/,d=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,h=/^\s+|\s+$/g,m=`
|
|
11
|
-
`,f="/",x="*",p="",g="comment",y="declaration";function w(T,C){if(typeof T!="string")throw new TypeError("First argument must be a string");if(!T)return[];C=C||{};var _=1,k=1;function M(E){var L=E.match(n);L&&(_+=L.length);var R=E.lastIndexOf(m);k=~R?E.length-R:k+E.length}function D(){var E={line:_,column:k};return function(L){return L.position=new A(E),K(),L}}function A(E){this.start=E,this.end={line:_,column:k},this.source=C.source}A.prototype.content=T;function G(E){var L=new Error(C.source+":"+_+":"+k+": "+E);if(L.reason=E,L.filename=C.source,L.line=_,L.column=k,L.source=T,!C.silent)throw L}function X(E){var L=E.exec(T);if(L){var R=L[0];return M(R),T=T.slice(R.length),L}}function K(){X(s)}function $(E){var L;for(E=E||[];L=q();)L!==!1&&E.push(L);return E}function q(){var E=D();if(!(f!=T.charAt(0)||x!=T.charAt(1))){for(var L=2;p!=T.charAt(L)&&(x!=T.charAt(L)||f!=T.charAt(L+1));)++L;if(L+=2,p===T.charAt(L-1))return G("End of comment missing");var R=T.slice(2,L-2);return k+=2,M(R),T=T.slice(L),k+=2,E({type:g,comment:R})}}function U(){var E=D(),L=X(i);if(L){if(q(),!X(l))return G("property missing ':'");var R=X(d),F=E({type:y,property:N(L[0].replace(e,p)),value:R?N(R[0].replace(e,p)):p});return X(c),F}}function z(){var E=[];$(E);for(var L;L=U();)L!==!1&&(E.push(L),$(E));return E}return K(),z()}function N(T){return T?T.replace(h,p):p}return Mh=w,Mh}var Hb;function Ik(){if(Hb)return al;Hb=1;var e=al&&al.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(al,"__esModule",{value:!0}),al.default=s;const n=e(Lk());function s(i,l){let d=null;if(!i||typeof i!="string")return d;const c=(0,n.default)(i),h=typeof l=="function";return c.forEach(m=>{if(m.type!=="declaration")return;const{property:f,value:x}=m;h?l(f,x,m):x&&(d=d||{},d[f]=x)}),d}return al}var yo={},Pb;function zk(){if(Pb)return yo;Pb=1,Object.defineProperty(yo,"__esModule",{value:!0}),yo.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,s=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,l=/^-(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(l,h):f=f.replace(i,h),f.replace(n,c))};return yo.camelCase=m,yo}var vo,qb;function $k(){if(qb)return vo;qb=1;var e=vo&&vo.__importDefault||function(l){return l&&l.__esModule?l:{default:l}},n=e(Ik()),s=zk();function i(l,d){var c={};return!l||typeof l!="string"||(0,n.default)(l,function(h,m){h&&m&&(c[(0,s.camelCase)(h,d)]=m)}),c}return i.default=i,vo=i,vo}var Bk=$k();const Hk=su(Bk),H1=P1("end"),dx=P1("start");function P1(e){return n;function n(s){const i=s&&s.position&&s.position[e]||{};if(typeof i.line=="number"&&i.line>0&&typeof i.column=="number"&&i.column>0)return{line:i.line,column:i.column,offset:typeof i.offset=="number"&&i.offset>-1?i.offset:void 0}}}function Pk(e){const n=dx(e),s=H1(e);if(n&&s)return{start:n,end:s}}function Oo(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Ub(e.position):"start"in e||"end"in e?Ub(e):"line"in e||"column"in e?Sm(e):""}function Sm(e){return Vb(e&&e.line)+":"+Vb(e&&e.column)}function Ub(e){return Sm(e&&e.start)+"-"+Sm(e&&e.end)}function Vb(e){return e&&typeof e=="number"?e:1}class br extends Error{constructor(n,s,i){super(),typeof s=="string"&&(i=s,s=void 0);let l="",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 n=="string"?l=n:!d.cause&&n&&(c=!0,l=n.message,d.cause=n),!d.ruleId&&!d.source&&typeof i=="string"){const m=i.indexOf(":");m===-1?d.ruleId=i:(d.source=i.slice(0,m),d.ruleId=i.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=l,this.line=h?h.line:void 0,this.name=Oo(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}}br.prototype.file="";br.prototype.name="";br.prototype.reason="";br.prototype.message="";br.prototype.stack="";br.prototype.column=void 0;br.prototype.line=void 0;br.prototype.ancestors=void 0;br.prototype.cause=void 0;br.prototype.fatal=void 0;br.prototype.place=void 0;br.prototype.ruleId=void 0;br.prototype.source=void 0;const ux={}.hasOwnProperty,qk=new Map,Uk=/[A-Z]/g,Vk=new Set(["table","tbody","thead","tfoot","tr"]),Fk=new Set(["td","th"]),q1="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Yk(e,n){if(!n||n.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const s=n.filePath||void 0;let i;if(n.development){if(typeof n.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");i=eS(s,n.jsxDEV)}else{if(typeof n.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof n.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");i=Jk(s,n.jsx,n.jsxs)}const l={Fragment:n.Fragment,ancestors:[],components:n.components||{},create:i,elementAttributeNameCase:n.elementAttributeNameCase||"react",evaluater:n.createEvaluater?n.createEvaluater():void 0,filePath:s,ignoreInvalidStyle:n.ignoreInvalidStyle||!1,passKeys:n.passKeys!==!1,passNode:n.passNode||!1,schema:n.space==="svg"?cx:Ok,stylePropertyNameCase:n.stylePropertyNameCase||"dom",tableCellAlignToStyle:n.tableCellAlignToStyle!==!1},d=U1(l,e,void 0);return d&&typeof d!="string"?d:l.create(e,l.Fragment,{children:d||void 0},void 0)}function U1(e,n,s){if(n.type==="element")return Gk(e,n,s);if(n.type==="mdxFlowExpression"||n.type==="mdxTextExpression")return Xk(e,n);if(n.type==="mdxJsxFlowElement"||n.type==="mdxJsxTextElement")return Wk(e,n,s);if(n.type==="mdxjsEsm")return Kk(e,n);if(n.type==="root")return Qk(e,n,s);if(n.type==="text")return Zk(e,n)}function Gk(e,n,s){const i=e.schema;let l=i;n.tagName.toLowerCase()==="svg"&&i.space==="html"&&(l=cx,e.schema=l),e.ancestors.push(n);const d=F1(e,n.tagName,!1),c=tS(e,n);let h=hx(e,n);return Vk.has(n.tagName)&&(h=h.filter(function(m){return typeof m=="string"?!Nk(m):!0})),V1(e,c,d,n),fx(c,h),e.ancestors.pop(),e.schema=i,e.create(n,d,c,s)}function Xk(e,n){if(n.data&&n.data.estree&&e.evaluater){const i=n.data.estree.body[0];return i.type,e.evaluater.evaluateExpression(i.expression)}Ho(e,n.position)}function Kk(e,n){if(n.data&&n.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(n.data.estree);Ho(e,n.position)}function Wk(e,n,s){const i=e.schema;let l=i;n.name==="svg"&&i.space==="html"&&(l=cx,e.schema=l),e.ancestors.push(n);const d=n.name===null?e.Fragment:F1(e,n.name,!0),c=nS(e,n),h=hx(e,n);return V1(e,c,d,n),fx(c,h),e.ancestors.pop(),e.schema=i,e.create(n,d,c,s)}function Qk(e,n,s){const i={};return fx(i,hx(e,n)),e.create(n,e.Fragment,i,s)}function Zk(e,n){return n.value}function V1(e,n,s,i){typeof s!="string"&&s!==e.Fragment&&e.passNode&&(n.node=i)}function fx(e,n){if(n.length>0){const s=n.length>1?n:n[0];s&&(e.children=s)}}function Jk(e,n,s){return i;function i(l,d,c,h){const f=Array.isArray(c.children)?s:n;return h?f(d,c,h):f(d,c)}}function eS(e,n){return s;function s(i,l,d,c){const h=Array.isArray(d.children),m=dx(i);return n(l,d,c,h,{columnNumber:m?m.column-1:void 0,fileName:e,lineNumber:m?m.line:void 0},void 0)}}function tS(e,n){const s={};let i,l;for(l in n.properties)if(l!=="children"&&ux.call(n.properties,l)){const d=rS(e,l,n.properties[l]);if(d){const[c,h]=d;e.tableCellAlignToStyle&&c==="align"&&typeof h=="string"&&Fk.has(n.tagName)?i=h:s[c]=h}}if(i){const d=s.style||(s.style={});d[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=i}return s}function nS(e,n){const s={};for(const i of n.attributes)if(i.type==="mdxJsxExpressionAttribute")if(i.data&&i.data.estree&&e.evaluater){const d=i.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 Ho(e,n.position);else{const l=i.name;let d;if(i.value&&typeof i.value=="object")if(i.value.data&&i.value.data.estree&&e.evaluater){const h=i.value.data.estree.body[0];h.type,d=e.evaluater.evaluateExpression(h.expression)}else Ho(e,n.position);else d=i.value===null?!0:i.value;s[l]=d}return s}function hx(e,n){const s=[];let i=-1;const l=e.passKeys?new Map:qk;for(;++i<n.children.length;){const d=n.children[i];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=l.get(m)||0;c=m+"-"+f,l.set(m,f+1)}}const h=U1(e,d,c);h!==void 0&&s.push(h)}return s}function rS(e,n,s){const i=Ak(e.schema,n);if(!(s==null||typeof s=="number"&&Number.isNaN(s))){if(Array.isArray(s)&&(s=i.commaSeparated?bk(s):Dk(s)),i.property==="style"){let l=typeof s=="object"?s:sS(e,String(s));return e.stylePropertyNameCase==="css"&&(l=aS(l)),["style",l]}return[e.elementAttributeNameCase==="react"&&i.space?Ek[i.property]||i.property:i.attribute,s]}}function sS(e,n){try{return Hk(n,{reactCompat:!0})}catch(s){if(e.ignoreInvalidStyle)return{};const i=s,l=new br("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:i,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw l.file=e.filePath||void 0,l.url=q1+"#cannot-parse-style-attribute",l}}function F1(e,n,s){let i;if(!s)i={type:"Literal",value:n};else if(n.includes(".")){const l=n.split(".");let d=-1,c;for(;++d<l.length;){const h=Lb(l[d])?{type:"Identifier",name:l[d]}:{type:"Literal",value:l[d]};c=c?{type:"MemberExpression",object:c,property:h,computed:!!(d&&h.type==="Literal"),optional:!1}:h}i=c}else i=Lb(n)&&!/^[a-z]/.test(n)?{type:"Identifier",name:n}:{type:"Literal",value:n};if(i.type==="Literal"){const l=i.value;return ux.call(e.components,l)?e.components[l]:l}if(e.evaluater)return e.evaluater.evaluateExpression(i);Ho(e)}function Ho(e,n){const s=new br("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:n,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw s.file=e.filePath||void 0,s.url=q1+"#cannot-handle-mdx-estrees-without-createevaluater",s}function aS(e){const n={};let s;for(s in e)ux.call(e,s)&&(n[iS(s)]=e[s]);return n}function iS(e){let n=e.replace(Uk,lS);return n.slice(0,3)==="ms-"&&(n="-"+n),n}function lS(e){return"-"+e.toLowerCase()}const Rh={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"]},oS={};function mx(e,n){const s=oS,i=typeof s.includeImageAlt=="boolean"?s.includeImageAlt:!0,l=typeof s.includeHtml=="boolean"?s.includeHtml:!0;return Y1(e,i,l)}function Y1(e,n,s){if(cS(e)){if("value"in e)return e.type==="html"&&!s?"":e.value;if(n&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Fb(e.children,n,s)}return Array.isArray(e)?Fb(e,n,s):""}function Fb(e,n,s){const i=[];let l=-1;for(;++l<e.length;)i[l]=Y1(e[l],n,s);return i.join("")}function cS(e){return!!(e&&typeof e=="object")}const Yb=document.createElement("i");function xx(e){const n="&"+e+";";Yb.innerHTML=n;const s=Yb.textContent;return s.charCodeAt(s.length-1)===59&&e!=="semi"||s===n?!1:s}function Jr(e,n,s,i){const l=e.length;let d=0,c;if(n<0?n=-n>l?0:l+n:n=n>l?l:n,s=s>0?s:0,i.length<1e4)c=Array.from(i),c.unshift(n,s),e.splice(...c);else for(s&&e.splice(n,s);d<i.length;)c=i.slice(d,d+1e4),c.unshift(n,0),e.splice(...c),d+=1e4,n+=1e4}function us(e,n){return e.length>0?(Jr(e,e.length,0,n),e):n}const Gb={}.hasOwnProperty;function G1(e){const n={};let s=-1;for(;++s<e.length;)dS(n,e[s]);return n}function dS(e,n){let s;for(s in n){const l=(Gb.call(e,s)?e[s]:void 0)||(e[s]={}),d=n[s];let c;if(d)for(c in d){Gb.call(l,c)||(l[c]=[]);const h=d[c];uS(l[c],Array.isArray(h)?h:h?[h]:[])}}}function uS(e,n){let s=-1;const i=[];for(;++s<n.length;)(n[s].add==="after"?e:i).push(n[s]);Jr(e,0,0,i)}function X1(e,n){const s=Number.parseInt(e,n);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 vs(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const wr=Ka(/[A-Za-z]/),gr=Ka(/[\dA-Za-z]/),fS=Ka(/[#-'*+\--9=?A-Z^-~]/);function Bd(e){return e!==null&&(e<32||e===127)}const Cm=Ka(/\d/),hS=Ka(/[\dA-Fa-f]/),mS=Ka(/[!-/:-@[-`{-~]/);function St(e){return e!==null&&e<-2}function Sn(e){return e!==null&&(e<0||e===32)}function Ft(e){return e===-2||e===-1||e===32}const au=Ka(new RegExp("\\p{P}|\\p{S}","u")),wi=Ka(/\s/);function Ka(e){return n;function n(s){return s!==null&&s>-1&&e.test(String.fromCharCode(s))}}function Al(e){const n=[];let s=-1,i=0,l=0;for(;++s<e.length;){const d=e.charCodeAt(s);let c="";if(d===37&&gr(e.charCodeAt(s+1))&&gr(e.charCodeAt(s+2)))l=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),l=1):c="�"}else c=String.fromCharCode(d);c&&(n.push(e.slice(i,s),encodeURIComponent(c)),i=s+l+1,c=""),l&&(s+=l,l=0)}return n.join("")+e.slice(i)}function en(e,n,s,i){const l=i?i-1:Number.POSITIVE_INFINITY;let d=0;return c;function c(m){return Ft(m)?(e.enter(s),h(m)):n(m)}function h(m){return Ft(m)&&d++<l?(e.consume(m),h):(e.exit(s),n(m))}}const xS={tokenize:pS};function pS(e){const n=e.attempt(this.parser.constructs.contentInitial,i,l);let s;return n;function i(h){if(h===null){e.consume(h);return}return e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),en(e,n,"linePrefix")}function l(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 St(h)?(e.consume(h),e.exit("chunkText"),d):(e.consume(h),c)}}const gS={tokenize:bS},Xb={tokenize:yS};function bS(e){const n=this,s=[];let i=0,l,d,c;return h;function h(k){if(i<s.length){const M=s[i];return n.containerState=M[1],e.attempt(M[0].continuation,m,f)(k)}return f(k)}function m(k){if(i++,n.containerState._closeFlow){n.containerState._closeFlow=void 0,l&&_();const M=n.events.length;let D=M,A;for(;D--;)if(n.events[D][0]==="exit"&&n.events[D][1].type==="chunkFlow"){A=n.events[D][1].end;break}C(i);let G=M;for(;G<n.events.length;)n.events[G][1].end={...A},G++;return Jr(n.events,D+1,0,n.events.slice(M)),n.events.length=G,f(k)}return h(k)}function f(k){if(i===s.length){if(!l)return g(k);if(l.currentConstruct&&l.currentConstruct.concrete)return w(k);n.interrupt=!!(l.currentConstruct&&!l._gfmTableDynamicInterruptHack)}return n.containerState={},e.check(Xb,x,p)(k)}function x(k){return l&&_(),C(i),g(k)}function p(k){return n.parser.lazy[n.now().line]=i!==s.length,c=n.now().offset,w(k)}function g(k){return n.containerState={},e.attempt(Xb,y,w)(k)}function y(k){return i++,s.push([n.currentConstruct,n.containerState]),g(k)}function w(k){if(k===null){l&&_(),C(0),e.consume(k);return}return l=l||n.parser.flow(n.now()),e.enter("chunkFlow",{_tokenizer:l,contentType:"flow",previous:d}),N(k)}function N(k){if(k===null){T(e.exit("chunkFlow"),!0),C(0),e.consume(k);return}return St(k)?(e.consume(k),T(e.exit("chunkFlow")),i=0,n.interrupt=void 0,h):(e.consume(k),N)}function T(k,M){const D=n.sliceStream(k);if(M&&D.push(null),k.previous=d,d&&(d.next=k),d=k,l.defineSkip(k.start),l.write(D),n.parser.lazy[k.start.line]){let A=l.events.length;for(;A--;)if(l.events[A][1].start.offset<c&&(!l.events[A][1].end||l.events[A][1].end.offset>c))return;const G=n.events.length;let X=G,K,$;for(;X--;)if(n.events[X][0]==="exit"&&n.events[X][1].type==="chunkFlow"){if(K){$=n.events[X][1].end;break}K=!0}for(C(i),A=G;A<n.events.length;)n.events[A][1].end={...$},A++;Jr(n.events,X+1,0,n.events.slice(G)),n.events.length=A}}function C(k){let M=s.length;for(;M-- >k;){const D=s[M];n.containerState=D[1],D[0].exit.call(n,e)}s.length=k}function _(){l.write([null]),d=void 0,l=void 0,n.containerState._closeFlow=void 0}}function yS(e,n,s){return en(e,e.attempt(this.parser.constructs.document,n,s),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function yl(e){if(e===null||Sn(e)||wi(e))return 1;if(au(e))return 2}function iu(e,n,s){const i=[];let l=-1;for(;++l<e.length;){const d=e[l].resolveAll;d&&!i.includes(d)&&(n=d(n,s),i.push(d))}return n}const Em={name:"attention",resolveAll:vS,tokenize:jS};function vS(e,n){let s=-1,i,l,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(i=s;i--;)if(e[i][0]==="exit"&&e[i][1].type==="attentionSequence"&&e[i][1]._open&&n.sliceSerialize(e[i][1]).charCodeAt(0)===n.sliceSerialize(e[s][1]).charCodeAt(0)){if((e[i][1]._close||e[s][1]._open)&&(e[s][1].end.offset-e[s][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[s][1].end.offset-e[s][1].start.offset)%3))continue;m=e[i][1].end.offset-e[i][1].start.offset>1&&e[s][1].end.offset-e[s][1].start.offset>1?2:1;const p={...e[i][1].end},g={...e[s][1].start};Kb(p,-m),Kb(g,m),c={type:m>1?"strongSequence":"emphasisSequence",start:p,end:{...e[i][1].end}},h={type:m>1?"strongSequence":"emphasisSequence",start:{...e[s][1].start},end:g},d={type:m>1?"strongText":"emphasisText",start:{...e[i][1].end},end:{...e[s][1].start}},l={type:m>1?"strong":"emphasis",start:{...c.start},end:{...h.end}},e[i][1].end={...c.start},e[s][1].start={...h.end},f=[],e[i][1].end.offset-e[i][1].start.offset&&(f=us(f,[["enter",e[i][1],n],["exit",e[i][1],n]])),f=us(f,[["enter",l,n],["enter",c,n],["exit",c,n],["enter",d,n]]),f=us(f,iu(n.parser.constructs.insideSpan.null,e.slice(i+1,s),n)),f=us(f,[["exit",d,n],["enter",h,n],["exit",h,n],["exit",l,n]]),e[s][1].end.offset-e[s][1].start.offset?(x=2,f=us(f,[["enter",e[s][1],n],["exit",e[s][1],n]])):x=0,Jr(e,i-1,s-i+3,f),s=i+f.length-x-2;break}}for(s=-1;++s<e.length;)e[s][1].type==="attentionSequence"&&(e[s][1].type="data");return e}function jS(e,n){const s=this.parser.constructs.attentionMarkers.null,i=this.previous,l=yl(i);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=yl(m),p=!x||x===2&&l||s.includes(m),g=!l||l===2&&x||s.includes(i);return f._open=!!(d===42?p:p&&(l||!g)),f._close=!!(d===42?g:g&&(x||!p)),n(m)}}function Kb(e,n){e.column+=n,e.offset+=n,e._bufferIndex+=n}const wS={name:"autolink",tokenize:NS};function NS(e,n,s){let i=0;return l;function l(y){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),d}function d(y){return wr(y)?(e.consume(y),c):y===64?s(y):f(y)}function c(y){return y===43||y===45||y===46||gr(y)?(i=1,h(y)):f(y)}function h(y){return y===58?(e.consume(y),i=0,m):(y===43||y===45||y===46||gr(y))&&i++<32?(e.consume(y),h):(i=0,f(y))}function m(y){return y===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),n):y===null||y===32||y===60||Bd(y)?s(y):(e.consume(y),m)}function f(y){return y===64?(e.consume(y),x):fS(y)?(e.consume(y),f):s(y)}function x(y){return gr(y)?p(y):s(y)}function p(y){return y===46?(e.consume(y),i=0,x):y===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),n):g(y)}function g(y){if((y===45||gr(y))&&i++<63){const w=y===45?g:p;return e.consume(y),w}return s(y)}}const nc={partial:!0,tokenize:kS};function kS(e,n,s){return i;function i(d){return Ft(d)?en(e,l,"linePrefix")(d):l(d)}function l(d){return d===null||St(d)?n(d):s(d)}}const K1={continuation:{tokenize:CS},exit:ES,name:"blockQuote",tokenize:SS};function SS(e,n,s){const i=this;return l;function l(c){if(c===62){const h=i.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 Ft(c)?(e.enter("blockQuotePrefixWhitespace"),e.consume(c),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),n):(e.exit("blockQuotePrefix"),n(c))}}function CS(e,n,s){const i=this;return l;function l(c){return Ft(c)?en(e,d,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c):d(c)}function d(c){return e.attempt(K1,n,s)(c)}}function ES(e){e.exit("blockQuote")}const W1={name:"characterEscape",tokenize:TS};function TS(e,n,s){return i;function i(d){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(d),e.exit("escapeMarker"),l}function l(d){return mS(d)?(e.enter("characterEscapeValue"),e.consume(d),e.exit("characterEscapeValue"),e.exit("characterEscape"),n):s(d)}}const Q1={name:"characterReference",tokenize:_S};function _S(e,n,s){const i=this;let l=0,d,c;return h;function h(p){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),m}function m(p){return p===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(p),e.exit("characterReferenceMarkerNumeric"),f):(e.enter("characterReferenceValue"),d=31,c=gr,x(p))}function f(p){return p===88||p===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(p),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),d=6,c=hS,x):(e.enter("characterReferenceValue"),d=7,c=Cm,x(p))}function x(p){if(p===59&&l){const g=e.exit("characterReferenceValue");return c===gr&&!xx(i.sliceSerialize(g))?s(p):(e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),e.exit("characterReference"),n)}return c(p)&&l++<d?(e.consume(p),x):s(p)}}const Wb={partial:!0,tokenize:MS},Qb={concrete:!0,name:"codeFenced",tokenize:AS};function AS(e,n,s){const i=this,l={partial:!0,tokenize:D};let d=0,c=0,h;return m;function m(A){return f(A)}function f(A){const G=i.events[i.events.length-1];return d=G&&G[1].type==="linePrefix"?G[2].sliceSerialize(G[1],!0).length:0,h=A,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),x(A)}function x(A){return A===h?(c++,e.consume(A),x):c<3?s(A):(e.exit("codeFencedFenceSequence"),Ft(A)?en(e,p,"whitespace")(A):p(A))}function p(A){return A===null||St(A)?(e.exit("codeFencedFence"),i.interrupt?n(A):e.check(Wb,N,M)(A)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),g(A))}function g(A){return A===null||St(A)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(A)):Ft(A)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),en(e,y,"whitespace")(A)):A===96&&A===h?s(A):(e.consume(A),g)}function y(A){return A===null||St(A)?p(A):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),w(A))}function w(A){return A===null||St(A)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(A)):A===96&&A===h?s(A):(e.consume(A),w)}function N(A){return e.attempt(l,M,T)(A)}function T(A){return e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),C}function C(A){return d>0&&Ft(A)?en(e,_,"linePrefix",d+1)(A):_(A)}function _(A){return A===null||St(A)?e.check(Wb,N,M)(A):(e.enter("codeFlowValue"),k(A))}function k(A){return A===null||St(A)?(e.exit("codeFlowValue"),_(A)):(e.consume(A),k)}function M(A){return e.exit("codeFenced"),n(A)}function D(A,G,X){let K=0;return $;function $(L){return A.enter("lineEnding"),A.consume(L),A.exit("lineEnding"),q}function q(L){return A.enter("codeFencedFence"),Ft(L)?en(A,U,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):U(L)}function U(L){return L===h?(A.enter("codeFencedFenceSequence"),z(L)):X(L)}function z(L){return L===h?(K++,A.consume(L),z):K>=c?(A.exit("codeFencedFenceSequence"),Ft(L)?en(A,E,"whitespace")(L):E(L)):X(L)}function E(L){return L===null||St(L)?(A.exit("codeFencedFence"),G(L)):X(L)}}}function MS(e,n,s){const i=this;return l;function l(c){return c===null?s(c):(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),d)}function d(c){return i.parser.lazy[i.now().line]?s(c):n(c)}}const Oh={name:"codeIndented",tokenize:OS},RS={partial:!0,tokenize:DS};function OS(e,n,s){const i=this;return l;function l(f){return e.enter("codeIndented"),en(e,d,"linePrefix",5)(f)}function d(f){const x=i.events[i.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):St(f)?e.attempt(RS,c,m)(f):(e.enter("codeFlowValue"),h(f))}function h(f){return f===null||St(f)?(e.exit("codeFlowValue"),c(f)):(e.consume(f),h)}function m(f){return e.exit("codeIndented"),n(f)}}function DS(e,n,s){const i=this;return l;function l(c){return i.parser.lazy[i.now().line]?s(c):St(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),l):en(e,d,"linePrefix",5)(c)}function d(c){const h=i.events[i.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?n(c):St(c)?l(c):s(c)}}const LS={name:"codeText",previous:zS,resolve:IS,tokenize:$S};function IS(e){let n=e.length-4,s=3,i,l;if((e[s][1].type==="lineEnding"||e[s][1].type==="space")&&(e[n][1].type==="lineEnding"||e[n][1].type==="space")){for(i=s;++i<n;)if(e[i][1].type==="codeTextData"){e[s][1].type="codeTextPadding",e[n][1].type="codeTextPadding",s+=2,n-=2;break}}for(i=s-1,n++;++i<=n;)l===void 0?i!==n&&e[i][1].type!=="lineEnding"&&(l=i):(i===n||e[i][1].type==="lineEnding")&&(e[l][1].type="codeTextData",i!==l+2&&(e[l][1].end=e[i-1][1].end,e.splice(l+2,i-l-2),n-=i-l-2,i=l+2),l=void 0);return e}function zS(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function $S(e,n,s){let i=0,l,d;return c;function c(p){return e.enter("codeText"),e.enter("codeTextSequence"),h(p)}function h(p){return p===96?(e.consume(p),i++,h):(e.exit("codeTextSequence"),m(p))}function m(p){return p===null?s(p):p===32?(e.enter("space"),e.consume(p),e.exit("space"),m):p===96?(d=e.enter("codeTextSequence"),l=0,x(p)):St(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),m):(e.enter("codeTextData"),f(p))}function f(p){return p===null||p===32||p===96||St(p)?(e.exit("codeTextData"),m(p)):(e.consume(p),f)}function x(p){return p===96?(e.consume(p),l++,x):l===i?(e.exit("codeTextSequence"),e.exit("codeText"),n(p)):(d.type="codeTextData",f(p))}}class BS{constructor(n){this.left=n?[...n]:[],this.right=[]}get(n){if(n<0||n>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+n+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return n<this.left.length?this.left[n]:this.right[this.right.length-n+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(n,s){const i=s??Number.POSITIVE_INFINITY;return i<this.left.length?this.left.slice(n,i):n>this.left.length?this.right.slice(this.right.length-i+this.left.length,this.right.length-n+this.left.length).reverse():this.left.slice(n).concat(this.right.slice(this.right.length-i+this.left.length).reverse())}splice(n,s,i){const l=s||0;this.setCursor(Math.trunc(n));const d=this.right.splice(this.right.length-l,Number.POSITIVE_INFINITY);return i&&jo(this.left,i),d.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(n){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(n)}pushMany(n){this.setCursor(Number.POSITIVE_INFINITY),jo(this.left,n)}unshift(n){this.setCursor(0),this.right.push(n)}unshiftMany(n){this.setCursor(0),jo(this.right,n.reverse())}setCursor(n){if(!(n===this.left.length||n>this.left.length&&this.right.length===0||n<0&&this.left.length===0))if(n<this.left.length){const s=this.left.splice(n,Number.POSITIVE_INFINITY);jo(this.right,s.reverse())}else{const s=this.right.splice(this.left.length+this.right.length-n,Number.POSITIVE_INFINITY);jo(this.left,s.reverse())}}}function jo(e,n){let s=0;if(n.length<1e4)e.push(...n);else for(;s<n.length;)e.push(...n.slice(s,s+1e4)),s+=1e4}function Z1(e){const n={};let s=-1,i,l,d,c,h,m,f;const x=new BS(e);for(;++s<x.length;){for(;s in n;)s=n[s];if(i=x.get(s),s&&i[1].type==="chunkFlow"&&x.get(s-1)[1].type==="listItemPrefix"&&(m=i[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(i[0]==="enter")i[1].contentType&&(Object.assign(n,HS(x,s)),s=n[s],f=!0);else if(i[1]._container){for(d=s,l=void 0;d--;)if(c=x.get(d),c[1].type==="lineEnding"||c[1].type==="lineEndingBlank")c[0]==="enter"&&(l&&(x.get(l)[1].type="lineEndingBlank"),c[1].type="lineEnding",l=d);else if(!(c[1].type==="linePrefix"||c[1].type==="listItemIndent"))break;l&&(i[1].end={...x.get(l)[1].start},h=x.slice(l,s),h.unshift(i),x.splice(l,s-l+1,h))}}return Jr(e,0,Number.POSITIVE_INFINITY,x.slice(0)),!f}function HS(e,n){const s=e.get(n)[1],i=e.get(n)[2];let l=n-1;const d=[];let c=s._tokenizer;c||(c=i.parser[s.contentType](s.start),s._contentTypeTextTrailing&&(c._contentTypeTextTrailing=!0));const h=c.events,m=[],f={};let x,p,g=-1,y=s,w=0,N=0;const T=[N];for(;y;){for(;e.get(++l)[1]!==y;);d.push(l),y._tokenizer||(x=i.sliceStream(y),y.next||x.push(null),p&&c.defineSkip(y.start),y._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=!0),c.write(x),y._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=void 0)),p=y,y=y.next}for(y=s;++g<h.length;)h[g][0]==="exit"&&h[g-1][0]==="enter"&&h[g][1].type===h[g-1][1].type&&h[g][1].start.line!==h[g][1].end.line&&(N=g+1,T.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):T.pop(),g=T.length;g--;){const C=h.slice(T[g],T[g+1]),_=d.pop();m.push([_,_+C.length-1]),e.splice(_,2,C)}for(m.reverse(),g=-1;++g<m.length;)f[w+m[g][0]]=w+m[g][1],w+=m[g][1]-m[g][0]-1;return f}const PS={resolve:US,tokenize:VS},qS={partial:!0,tokenize:FS};function US(e){return Z1(e),e}function VS(e,n){let s;return i;function i(h){return e.enter("content"),s=e.enter("chunkContent",{contentType:"content"}),l(h)}function l(h){return h===null?d(h):St(h)?e.check(qS,c,d)(h):(e.consume(h),l)}function d(h){return e.exit("chunkContent"),e.exit("content"),n(h)}function c(h){return e.consume(h),e.exit("chunkContent"),s.next=e.enter("chunkContent",{contentType:"content",previous:s}),s=s.next,l}}function FS(e,n,s){const i=this;return l;function l(c){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),en(e,d,"linePrefix")}function d(c){if(c===null||St(c))return s(c);const h=i.events[i.events.length-1];return!i.parser.constructs.disable.null.includes("codeIndented")&&h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?n(c):e.interrupt(i.parser.constructs.flow,s,n)(c)}}function J1(e,n,s,i,l,d,c,h,m){const f=m||Number.POSITIVE_INFINITY;let x=0;return p;function p(C){return C===60?(e.enter(i),e.enter(l),e.enter(d),e.consume(C),e.exit(d),g):C===null||C===32||C===41||Bd(C)?s(C):(e.enter(i),e.enter(c),e.enter(h),e.enter("chunkString",{contentType:"string"}),N(C))}function g(C){return C===62?(e.enter(d),e.consume(C),e.exit(d),e.exit(l),e.exit(i),n):(e.enter(h),e.enter("chunkString",{contentType:"string"}),y(C))}function y(C){return C===62?(e.exit("chunkString"),e.exit(h),g(C)):C===null||C===60||St(C)?s(C):(e.consume(C),C===92?w:y)}function w(C){return C===60||C===62||C===92?(e.consume(C),y):y(C)}function N(C){return!x&&(C===null||C===41||Sn(C))?(e.exit("chunkString"),e.exit(h),e.exit(c),e.exit(i),n(C)):x<f&&C===40?(e.consume(C),x++,N):C===41?(e.consume(C),x--,N):C===null||C===32||C===40||Bd(C)?s(C):(e.consume(C),C===92?T:N)}function T(C){return C===40||C===41||C===92?(e.consume(C),N):N(C)}}function ej(e,n,s,i,l,d){const c=this;let h=0,m;return f;function f(y){return e.enter(i),e.enter(l),e.consume(y),e.exit(l),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(l),e.consume(y),e.exit(l),e.exit(i),n):St(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),x):(e.enter("chunkString",{contentType:"string"}),p(y))}function p(y){return y===null||y===91||y===93||St(y)||h++>999?(e.exit("chunkString"),x(y)):(e.consume(y),m||(m=!Ft(y)),y===92?g:p)}function g(y){return y===91||y===92||y===93?(e.consume(y),h++,p):p(y)}}function tj(e,n,s,i,l,d){let c;return h;function h(g){return g===34||g===39||g===40?(e.enter(i),e.enter(l),e.consume(g),e.exit(l),c=g===40?41:g,m):s(g)}function m(g){return g===c?(e.enter(l),e.consume(g),e.exit(l),e.exit(i),n):(e.enter(d),f(g))}function f(g){return g===c?(e.exit(d),m(c)):g===null?s(g):St(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),en(e,f,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),x(g))}function x(g){return g===c||g===null||St(g)?(e.exit("chunkString"),f(g)):(e.consume(g),g===92?p:x)}function p(g){return g===c||g===92?(e.consume(g),x):x(g)}}function Do(e,n){let s;return i;function i(l){return St(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),s=!0,i):Ft(l)?en(e,i,s?"linePrefix":"lineSuffix")(l):n(l)}}const YS={name:"definition",tokenize:XS},GS={partial:!0,tokenize:KS};function XS(e,n,s){const i=this;let l;return d;function d(y){return e.enter("definition"),c(y)}function c(y){return ej.call(i,e,h,s,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function h(y){return l=vs(i.sliceSerialize(i.events[i.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 Sn(y)?Do(e,f)(y):f(y)}function f(y){return J1(e,x,s,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function x(y){return e.attempt(GS,p,p)(y)}function p(y){return Ft(y)?en(e,g,"whitespace")(y):g(y)}function g(y){return y===null||St(y)?(e.exit("definition"),i.parser.defined.push(l),n(y)):s(y)}}function KS(e,n,s){return i;function i(h){return Sn(h)?Do(e,l)(h):s(h)}function l(h){return tj(e,d,s,"definitionTitle","definitionTitleMarker","definitionTitleString")(h)}function d(h){return Ft(h)?en(e,c,"whitespace")(h):c(h)}function c(h){return h===null||St(h)?n(h):s(h)}}const WS={name:"hardBreakEscape",tokenize:QS};function QS(e,n,s){return i;function i(d){return e.enter("hardBreakEscape"),e.consume(d),l}function l(d){return St(d)?(e.exit("hardBreakEscape"),n(d)):s(d)}}const ZS={name:"headingAtx",resolve:JS,tokenize:eC};function JS(e,n){let s=e.length-2,i=3,l,d;return e[i][1].type==="whitespace"&&(i+=2),s-2>i&&e[s][1].type==="whitespace"&&(s-=2),e[s][1].type==="atxHeadingSequence"&&(i===s-1||s-4>i&&e[s-2][1].type==="whitespace")&&(s-=i+1===s?2:4),s>i&&(l={type:"atxHeadingText",start:e[i][1].start,end:e[s][1].end},d={type:"chunkText",start:e[i][1].start,end:e[s][1].end,contentType:"text"},Jr(e,i,s-i+1,[["enter",l,n],["enter",d,n],["exit",d,n],["exit",l,n]])),e}function eC(e,n,s){let i=0;return l;function l(x){return e.enter("atxHeading"),d(x)}function d(x){return e.enter("atxHeadingSequence"),c(x)}function c(x){return x===35&&i++<6?(e.consume(x),c):x===null||Sn(x)?(e.exit("atxHeadingSequence"),h(x)):s(x)}function h(x){return x===35?(e.enter("atxHeadingSequence"),m(x)):x===null||St(x)?(e.exit("atxHeading"),n(x)):Ft(x)?en(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||Sn(x)?(e.exit("atxHeadingText"),h(x)):(e.consume(x),f)}}const tC=["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"],Zb=["pre","script","style","textarea"],nC={concrete:!0,name:"htmlFlow",resolveTo:aC,tokenize:iC},rC={partial:!0,tokenize:oC},sC={partial:!0,tokenize:lC};function aC(e){let n=e.length;for(;n--&&!(e[n][0]==="enter"&&e[n][1].type==="htmlFlow"););return n>1&&e[n-2][1].type==="linePrefix"&&(e[n][1].start=e[n-2][1].start,e[n+1][1].start=e[n-2][1].start,e.splice(n-2,2)),e}function iC(e,n,s){const i=this;let l,d,c,h,m;return f;function f(I){return x(I)}function x(I){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(I),p}function p(I){return I===33?(e.consume(I),g):I===47?(e.consume(I),d=!0,N):I===63?(e.consume(I),l=3,i.interrupt?n:B):wr(I)?(e.consume(I),c=String.fromCharCode(I),T):s(I)}function g(I){return I===45?(e.consume(I),l=2,y):I===91?(e.consume(I),l=5,h=0,w):wr(I)?(e.consume(I),l=4,i.interrupt?n:B):s(I)}function y(I){return I===45?(e.consume(I),i.interrupt?n:B):s(I)}function w(I){const S="CDATA[";return I===S.charCodeAt(h++)?(e.consume(I),h===S.length?i.interrupt?n:U:w):s(I)}function N(I){return wr(I)?(e.consume(I),c=String.fromCharCode(I),T):s(I)}function T(I){if(I===null||I===47||I===62||Sn(I)){const S=I===47,H=c.toLowerCase();return!S&&!d&&Zb.includes(H)?(l=1,i.interrupt?n(I):U(I)):tC.includes(c.toLowerCase())?(l=6,S?(e.consume(I),C):i.interrupt?n(I):U(I)):(l=7,i.interrupt&&!i.parser.lazy[i.now().line]?s(I):d?_(I):k(I))}return I===45||gr(I)?(e.consume(I),c+=String.fromCharCode(I),T):s(I)}function C(I){return I===62?(e.consume(I),i.interrupt?n:U):s(I)}function _(I){return Ft(I)?(e.consume(I),_):$(I)}function k(I){return I===47?(e.consume(I),$):I===58||I===95||wr(I)?(e.consume(I),M):Ft(I)?(e.consume(I),k):$(I)}function M(I){return I===45||I===46||I===58||I===95||gr(I)?(e.consume(I),M):D(I)}function D(I){return I===61?(e.consume(I),A):Ft(I)?(e.consume(I),D):k(I)}function A(I){return I===null||I===60||I===61||I===62||I===96?s(I):I===34||I===39?(e.consume(I),m=I,G):Ft(I)?(e.consume(I),A):X(I)}function G(I){return I===m?(e.consume(I),m=null,K):I===null||St(I)?s(I):(e.consume(I),G)}function X(I){return I===null||I===34||I===39||I===47||I===60||I===61||I===62||I===96||Sn(I)?D(I):(e.consume(I),X)}function K(I){return I===47||I===62||Ft(I)?k(I):s(I)}function $(I){return I===62?(e.consume(I),q):s(I)}function q(I){return I===null||St(I)?U(I):Ft(I)?(e.consume(I),q):s(I)}function U(I){return I===45&&l===2?(e.consume(I),R):I===60&&l===1?(e.consume(I),F):I===62&&l===4?(e.consume(I),O):I===63&&l===3?(e.consume(I),B):I===93&&l===5?(e.consume(I),Z):St(I)&&(l===6||l===7)?(e.exit("htmlFlowData"),e.check(rC,V,z)(I)):I===null||St(I)?(e.exit("htmlFlowData"),z(I)):(e.consume(I),U)}function z(I){return e.check(sC,E,V)(I)}function E(I){return e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),L}function L(I){return I===null||St(I)?z(I):(e.enter("htmlFlowData"),U(I))}function R(I){return I===45?(e.consume(I),B):U(I)}function F(I){return I===47?(e.consume(I),c="",Y):U(I)}function Y(I){if(I===62){const S=c.toLowerCase();return Zb.includes(S)?(e.consume(I),O):U(I)}return wr(I)&&c.length<8?(e.consume(I),c+=String.fromCharCode(I),Y):U(I)}function Z(I){return I===93?(e.consume(I),B):U(I)}function B(I){return I===62?(e.consume(I),O):I===45&&l===2?(e.consume(I),B):U(I)}function O(I){return I===null||St(I)?(e.exit("htmlFlowData"),V(I)):(e.consume(I),O)}function V(I){return e.exit("htmlFlow"),n(I)}}function lC(e,n,s){const i=this;return l;function l(c){return St(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),d):s(c)}function d(c){return i.parser.lazy[i.now().line]?s(c):n(c)}}function oC(e,n,s){return i;function i(l){return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),e.attempt(nc,n,s)}}const cC={name:"htmlText",tokenize:dC};function dC(e,n,s){const i=this;let l,d,c;return h;function h(B){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(B),m}function m(B){return B===33?(e.consume(B),f):B===47?(e.consume(B),D):B===63?(e.consume(B),k):wr(B)?(e.consume(B),X):s(B)}function f(B){return B===45?(e.consume(B),x):B===91?(e.consume(B),d=0,w):wr(B)?(e.consume(B),_):s(B)}function x(B){return B===45?(e.consume(B),y):s(B)}function p(B){return B===null?s(B):B===45?(e.consume(B),g):St(B)?(c=p,F(B)):(e.consume(B),p)}function g(B){return B===45?(e.consume(B),y):p(B)}function y(B){return B===62?R(B):B===45?g(B):p(B)}function w(B){const O="CDATA[";return B===O.charCodeAt(d++)?(e.consume(B),d===O.length?N:w):s(B)}function N(B){return B===null?s(B):B===93?(e.consume(B),T):St(B)?(c=N,F(B)):(e.consume(B),N)}function T(B){return B===93?(e.consume(B),C):N(B)}function C(B){return B===62?R(B):B===93?(e.consume(B),C):N(B)}function _(B){return B===null||B===62?R(B):St(B)?(c=_,F(B)):(e.consume(B),_)}function k(B){return B===null?s(B):B===63?(e.consume(B),M):St(B)?(c=k,F(B)):(e.consume(B),k)}function M(B){return B===62?R(B):k(B)}function D(B){return wr(B)?(e.consume(B),A):s(B)}function A(B){return B===45||gr(B)?(e.consume(B),A):G(B)}function G(B){return St(B)?(c=G,F(B)):Ft(B)?(e.consume(B),G):R(B)}function X(B){return B===45||gr(B)?(e.consume(B),X):B===47||B===62||Sn(B)?K(B):s(B)}function K(B){return B===47?(e.consume(B),R):B===58||B===95||wr(B)?(e.consume(B),$):St(B)?(c=K,F(B)):Ft(B)?(e.consume(B),K):R(B)}function $(B){return B===45||B===46||B===58||B===95||gr(B)?(e.consume(B),$):q(B)}function q(B){return B===61?(e.consume(B),U):St(B)?(c=q,F(B)):Ft(B)?(e.consume(B),q):K(B)}function U(B){return B===null||B===60||B===61||B===62||B===96?s(B):B===34||B===39?(e.consume(B),l=B,z):St(B)?(c=U,F(B)):Ft(B)?(e.consume(B),U):(e.consume(B),E)}function z(B){return B===l?(e.consume(B),l=void 0,L):B===null?s(B):St(B)?(c=z,F(B)):(e.consume(B),z)}function E(B){return B===null||B===34||B===39||B===60||B===61||B===96?s(B):B===47||B===62||Sn(B)?K(B):(e.consume(B),E)}function L(B){return B===47||B===62||Sn(B)?K(B):s(B)}function R(B){return B===62?(e.consume(B),e.exit("htmlTextData"),e.exit("htmlText"),n):s(B)}function F(B){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(B),e.exit("lineEnding"),Y}function Y(B){return Ft(B)?en(e,Z,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(B):Z(B)}function Z(B){return e.enter("htmlTextData"),c(B)}}const px={name:"labelEnd",resolveAll:mC,resolveTo:xC,tokenize:pC},uC={tokenize:gC},fC={tokenize:bC},hC={tokenize:yC};function mC(e){let n=-1;const s=[];for(;++n<e.length;){const i=e[n][1];if(s.push(e[n]),i.type==="labelImage"||i.type==="labelLink"||i.type==="labelEnd"){const l=i.type==="labelImage"?4:2;i.type="data",n+=l}}return e.length!==s.length&&Jr(e,0,e.length,s),e}function xC(e,n){let s=e.length,i=0,l,d,c,h;for(;s--;)if(l=e[s][1],d){if(l.type==="link"||l.type==="labelLink"&&l._inactive)break;e[s][0]==="enter"&&l.type==="labelLink"&&(l._inactive=!0)}else if(c){if(e[s][0]==="enter"&&(l.type==="labelImage"||l.type==="labelLink")&&!l._balanced&&(d=s,l.type!=="labelLink")){i=2;break}}else l.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+i+2][1].end},end:{...e[c-2][1].start}};return h=[["enter",m,n],["enter",f,n]],h=us(h,e.slice(d+1,d+i+3)),h=us(h,[["enter",x,n]]),h=us(h,iu(n.parser.constructs.insideSpan.null,e.slice(d+i+4,c-3),n)),h=us(h,[["exit",x,n],e[c-2],e[c-1],["exit",f,n]]),h=us(h,e.slice(c+1)),h=us(h,[["exit",m,n]]),Jr(e,d,e.length,h),e}function pC(e,n,s){const i=this;let l=i.events.length,d,c;for(;l--;)if((i.events[l][1].type==="labelImage"||i.events[l][1].type==="labelLink")&&!i.events[l][1]._balanced){d=i.events[l][1];break}return h;function h(g){return d?d._inactive?p(g):(c=i.parser.defined.includes(vs(i.sliceSerialize({start:d.end,end:i.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(g),e.exit("labelMarker"),e.exit("labelEnd"),m):s(g)}function m(g){return g===40?e.attempt(uC,x,c?x:p)(g):g===91?e.attempt(fC,x,c?f:p)(g):c?x(g):p(g)}function f(g){return e.attempt(hC,x,p)(g)}function x(g){return n(g)}function p(g){return d._balanced=!0,s(g)}}function gC(e,n,s){return i;function i(p){return e.enter("resource"),e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),l}function l(p){return Sn(p)?Do(e,d)(p):d(p)}function d(p){return p===41?x(p):J1(e,c,h,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function c(p){return Sn(p)?Do(e,m)(p):x(p)}function h(p){return s(p)}function m(p){return p===34||p===39||p===40?tj(e,f,s,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):x(p)}function f(p){return Sn(p)?Do(e,x)(p):x(p)}function x(p){return p===41?(e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),e.exit("resource"),n):s(p)}}function bC(e,n,s){const i=this;return l;function l(h){return ej.call(i,e,d,c,"reference","referenceMarker","referenceString")(h)}function d(h){return i.parser.defined.includes(vs(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?n(h):s(h)}function c(h){return s(h)}}function yC(e,n,s){return i;function i(d){return e.enter("reference"),e.enter("referenceMarker"),e.consume(d),e.exit("referenceMarker"),l}function l(d){return d===93?(e.enter("referenceMarker"),e.consume(d),e.exit("referenceMarker"),e.exit("reference"),n):s(d)}}const vC={name:"labelStartImage",resolveAll:px.resolveAll,tokenize:jC};function jC(e,n,s){const i=this;return l;function l(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 i.parser.constructs?s(h):n(h)}}const wC={name:"labelStartLink",resolveAll:px.resolveAll,tokenize:NC};function NC(e,n,s){const i=this;return l;function l(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 i.parser.constructs?s(c):n(c)}}const Dh={name:"lineEnding",tokenize:kC};function kC(e,n){return s;function s(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),en(e,n,"linePrefix")}}const Rd={name:"thematicBreak",tokenize:SC};function SC(e,n,s){let i=0,l;return d;function d(f){return e.enter("thematicBreak"),c(f)}function c(f){return l=f,h(f)}function h(f){return f===l?(e.enter("thematicBreakSequence"),m(f)):i>=3&&(f===null||St(f))?(e.exit("thematicBreak"),n(f)):s(f)}function m(f){return f===l?(e.consume(f),i++,m):(e.exit("thematicBreakSequence"),Ft(f)?en(e,h,"whitespace")(f):h(f))}}const Lr={continuation:{tokenize:_C},exit:MC,name:"list",tokenize:TC},CC={partial:!0,tokenize:RC},EC={partial:!0,tokenize:AC};function TC(e,n,s){const i=this,l=i.events[i.events.length-1];let d=l&&l[1].type==="linePrefix"?l[2].sliceSerialize(l[1],!0).length:0,c=0;return h;function h(y){const w=i.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!i.containerState.marker||y===i.containerState.marker:Cm(y)){if(i.containerState.type||(i.containerState.type=w,e.enter(w,{_container:!0})),w==="listUnordered")return e.enter("listItemPrefix"),y===42||y===45?e.check(Rd,s,f)(y):f(y);if(!i.interrupt||y===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),m(y)}return s(y)}function m(y){return Cm(y)&&++c<10?(e.consume(y),m):(!i.interrupt||c<2)&&(i.containerState.marker?y===i.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"),i.containerState.marker=i.containerState.marker||y,e.check(nc,i.interrupt?s:x,e.attempt(CC,g,p))}function x(y){return i.containerState.initialBlankLine=!0,d++,g(y)}function p(y){return Ft(y)?(e.enter("listItemPrefixWhitespace"),e.consume(y),e.exit("listItemPrefixWhitespace"),g):s(y)}function g(y){return i.containerState.size=d+i.sliceSerialize(e.exit("listItemPrefix"),!0).length,n(y)}}function _C(e,n,s){const i=this;return i.containerState._closeFlow=void 0,e.check(nc,l,d);function l(h){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,en(e,n,"listItemIndent",i.containerState.size+1)(h)}function d(h){return i.containerState.furtherBlankLines||!Ft(h)?(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,c(h)):(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,e.attempt(EC,n,c)(h))}function c(h){return i.containerState._closeFlow=!0,i.interrupt=void 0,en(e,e.attempt(Lr,n,s),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(h)}}function AC(e,n,s){const i=this;return en(e,l,"listItemIndent",i.containerState.size+1);function l(d){const c=i.events[i.events.length-1];return c&&c[1].type==="listItemIndent"&&c[2].sliceSerialize(c[1],!0).length===i.containerState.size?n(d):s(d)}}function MC(e){e.exit(this.containerState.type)}function RC(e,n,s){const i=this;return en(e,l,"listItemPrefixWhitespace",i.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function l(d){const c=i.events[i.events.length-1];return!Ft(d)&&c&&c[1].type==="listItemPrefixWhitespace"?n(d):s(d)}}const Jb={name:"setextUnderline",resolveTo:OC,tokenize:DC};function OC(e,n){let s=e.length,i,l,d;for(;s--;)if(e[s][0]==="enter"){if(e[s][1].type==="content"){i=s;break}e[s][1].type==="paragraph"&&(l=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[i][1].start},end:{...e[e.length-1][1].end}};return e[l][1].type="setextHeadingText",d?(e.splice(l,0,["enter",c,n]),e.splice(d+1,0,["exit",e[i][1],n]),e[i][1].end={...e[d][1].end}):e[i][1]=c,e.push(["exit",c,n]),e}function DC(e,n,s){const i=this;let l;return d;function d(f){let x=i.events.length,p;for(;x--;)if(i.events[x][1].type!=="lineEnding"&&i.events[x][1].type!=="linePrefix"&&i.events[x][1].type!=="content"){p=i.events[x][1].type==="paragraph";break}return!i.parser.lazy[i.now().line]&&(i.interrupt||p)?(e.enter("setextHeadingLine"),l=f,c(f)):s(f)}function c(f){return e.enter("setextHeadingLineSequence"),h(f)}function h(f){return f===l?(e.consume(f),h):(e.exit("setextHeadingLineSequence"),Ft(f)?en(e,m,"lineSuffix")(f):m(f))}function m(f){return f===null||St(f)?(e.exit("setextHeadingLine"),n(f)):s(f)}}const LC={tokenize:IC};function IC(e){const n=this,s=e.attempt(nc,i,e.attempt(this.parser.constructs.flowInitial,l,en(e,e.attempt(this.parser.constructs.flow,l,e.attempt(PS,l)),"linePrefix")));return s;function i(d){if(d===null){e.consume(d);return}return e.enter("lineEndingBlank"),e.consume(d),e.exit("lineEndingBlank"),n.currentConstruct=void 0,s}function l(d){if(d===null){e.consume(d);return}return e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),n.currentConstruct=void 0,s}}const zC={resolveAll:rj()},$C=nj("string"),BC=nj("text");function nj(e){return{resolveAll:rj(e==="text"?HC:void 0),tokenize:n};function n(s){const i=this,l=this.parser.constructs[e],d=s.attempt(l,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 p=l[x];let g=-1;if(p)for(;++g<p.length;){const y=p[g];if(!y.previous||y.previous.call(i,i.previous))return!0}return!1}}}function rj(e){return n;function n(s,i){let l=-1,d;for(;++l<=s.length;)d===void 0?s[l]&&s[l][1].type==="data"&&(d=l,l++):(!s[l]||s[l][1].type!=="data")&&(l!==d+2&&(s[d][1].end=s[l-1][1].end,s.splice(d+2,l-d-2),l=d+2),d=void 0);return e?e(s,i):s}}function HC(e,n){let s=0;for(;++s<=e.length;)if((s===e.length||e[s][1].type==="lineEnding")&&e[s-1][1].type==="data"){const i=e[s-1][1],l=n.sliceStream(i);let d=l.length,c=-1,h=0,m;for(;d--;){const f=l[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(n._contentTypeTextTrailing&&s===e.length&&(h=0),h){const f={type:s===e.length||m||h<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:d?c:i.start._bufferIndex+c,_index:i.start._index+d,line:i.end.line,column:i.end.column-h,offset:i.end.offset-h},end:{...i.end}};i.end={...f.start},i.start.offset===i.end.offset?Object.assign(i,f):(e.splice(s,0,["enter",f,n],["exit",f,n]),s+=2)}s++}return e}const PC={42:Lr,43:Lr,45:Lr,48:Lr,49:Lr,50:Lr,51:Lr,52:Lr,53:Lr,54:Lr,55:Lr,56:Lr,57:Lr,62:K1},qC={91:YS},UC={[-2]:Oh,[-1]:Oh,32:Oh},VC={35:ZS,42:Rd,45:[Jb,Rd],60:nC,61:Jb,95:Rd,96:Qb,126:Qb},FC={38:Q1,92:W1},YC={[-5]:Dh,[-4]:Dh,[-3]:Dh,33:vC,38:Q1,42:Em,60:[wS,cC],91:wC,92:[WS,W1],93:px,95:Em,96:LS},GC={null:[Em,zC]},XC={null:[42,95]},KC={null:[]},WC=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:XC,contentInitial:qC,disable:KC,document:PC,flow:VC,flowInitial:UC,insideSpan:GC,string:FC,text:YC},Symbol.toStringTag,{value:"Module"}));function QC(e,n,s){let i={_bufferIndex:-1,_index:0,line:s&&s.line||1,column:s&&s.column||1,offset:s&&s.offset||0};const l={},d=[];let c=[],h=[];const m={attempt:G(D),check:G(A),consume:_,enter:k,exit:M,interrupt:G(A,{interrupt:!0})},f={code:null,containerState:{},defineSkip:N,events:[],now:w,parser:e,previous:null,sliceSerialize:g,sliceStream:y,write:p};let x=n.tokenize.call(f,m);return n.resolveAll&&d.push(n),f;function p(q){return c=us(c,q),T(),c[c.length-1]!==null?[]:(X(n,0),f.events=iu(d,f.events,f),f.events)}function g(q,U){return JC(y(q),U)}function y(q){return ZC(c,q)}function w(){const{_bufferIndex:q,_index:U,line:z,column:E,offset:L}=i;return{_bufferIndex:q,_index:U,line:z,column:E,offset:L}}function N(q){l[q.line]=q.column,$()}function T(){let q;for(;i._index<c.length;){const U=c[i._index];if(typeof U=="string")for(q=i._index,i._bufferIndex<0&&(i._bufferIndex=0);i._index===q&&i._bufferIndex<U.length;)C(U.charCodeAt(i._bufferIndex));else C(U)}}function C(q){x=x(q)}function _(q){St(q)?(i.line++,i.column=1,i.offset+=q===-3?2:1,$()):q!==-1&&(i.column++,i.offset++),i._bufferIndex<0?i._index++:(i._bufferIndex++,i._bufferIndex===c[i._index].length&&(i._bufferIndex=-1,i._index++)),f.previous=q}function k(q,U){const z=U||{};return z.type=q,z.start=w(),f.events.push(["enter",z,f]),h.push(z),z}function M(q){const U=h.pop();return U.end=w(),f.events.push(["exit",U,f]),U}function D(q,U){X(q,U.from)}function A(q,U){U.restore()}function G(q,U){return z;function z(E,L,R){let F,Y,Z,B;return Array.isArray(E)?V(E):"tokenize"in E?V([E]):O(E);function O(W){return ee;function ee(te){const ae=te!==null&&W[te],he=te!==null&&W.null,Ne=[...Array.isArray(ae)?ae:ae?[ae]:[],...Array.isArray(he)?he:he?[he]:[]];return V(Ne)(te)}}function V(W){return F=W,Y=0,W.length===0?R:I(W[Y])}function I(W){return ee;function ee(te){return B=K(),Z=W,W.partial||(f.currentConstruct=W),W.name&&f.parser.constructs.disable.null.includes(W.name)?H():W.tokenize.call(U?Object.assign(Object.create(f),U):f,m,S,H)(te)}}function S(W){return q(Z,B),L}function H(W){return B.restore(),++Y<F.length?I(F[Y]):R}}}function X(q,U){q.resolveAll&&!d.includes(q)&&d.push(q),q.resolve&&Jr(f.events,U,f.events.length-U,q.resolve(f.events.slice(U),f)),q.resolveTo&&(f.events=q.resolveTo(f.events,f))}function K(){const q=w(),U=f.previous,z=f.currentConstruct,E=f.events.length,L=Array.from(h);return{from:E,restore:R};function R(){i=q,f.previous=U,f.currentConstruct=z,f.events.length=E,h=L,$()}}function $(){i.line in l&&i.column<2&&(i.column=l[i.line],i.offset+=l[i.line]-1)}}function ZC(e,n){const s=n.start._index,i=n.start._bufferIndex,l=n.end._index,d=n.end._bufferIndex;let c;if(s===l)c=[e[s].slice(i,d)];else{if(c=e.slice(s,l),i>-1){const h=c[0];typeof h=="string"?c[0]=h.slice(i):c.shift()}d>0&&c.push(e[l].slice(0,d))}return c}function JC(e,n){let s=-1;const i=[];let l;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=n?" ":" ";break}case-1:{if(!n&&l)continue;c=" ";break}default:c=String.fromCharCode(d)}l=d===-2,i.push(c)}return i.join("")}function eE(e){const i={constructs:G1([WC,...(e||{}).extensions||[]]),content:l(xS),defined:[],document:l(gS),flow:l(LC),lazy:{},string:l($C),text:l(BC)};return i;function l(d){return c;function c(h){return QC(i,d,h)}}}function tE(e){for(;!Z1(e););return e}const ey=/[\0\t\n\r]/g;function nE(){let e=1,n="",s=!0,i;return l;function l(d,c,h){const m=[];let f,x,p,g,y;for(d=n+(typeof d=="string"?d.toString():new TextDecoder(c||void 0).decode(d)),p=0,n="",s&&(d.charCodeAt(0)===65279&&p++,s=void 0);p<d.length;){if(ey.lastIndex=p,f=ey.exec(d),g=f&&f.index!==void 0?f.index:d.length,y=d.charCodeAt(g),!f){n=d.slice(p);break}if(y===10&&p===g&&i)m.push(-3),i=void 0;else switch(i&&(m.push(-5),i=void 0),p<g&&(m.push(d.slice(p,g)),e+=g-p),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:i=!0,e=1}p=g+1}return h&&(i&&m.push(-5),n&&m.push(n),m.push(null)),m}}const rE=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function sE(e){return e.replace(rE,aE)}function aE(e,n,s){if(n)return n;if(s.charCodeAt(0)===35){const l=s.charCodeAt(1),d=l===120||l===88;return X1(s.slice(d?2:1),d?16:10)}return xx(s)||e}const sj={}.hasOwnProperty;function iE(e,n,s){return n&&typeof n=="object"&&(s=n,n=void 0),lE(s)(tE(eE(s).document().write(nE()(e,n,!0))))}function lE(e){const n={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:d(yt),autolinkProtocol:K,autolinkEmail:K,atxHeading:d(Se),blockQuote:d(he),characterEscape:K,characterReference:K,codeFenced:d(Ne),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:d(Ne,c),codeText:d(De,c),codeTextData:K,data:K,codeFlowValue:K,definition:d(je),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:d(ke),hardBreakEscape:d(Le),hardBreakTrailing:d(Le),htmlFlow:d(nt,c),htmlFlowData:K,htmlText:d(nt,c),htmlTextData:K,image:d(rt),label:c,link:d(yt),listItem:d(re),listItemValue:g,listOrdered:d(Rt,p),listUnordered:d(Rt),paragraph:d(_e),reference:I,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:d(Se),strong:d(st),thematicBreak:d(Yt)},exit:{atxHeading:m(),atxHeadingSequence:D,autolink:m(),autolinkEmail:ae,autolinkProtocol:te,blockQuote:m(),characterEscapeValue:$,characterReferenceMarkerHexadecimal:H,characterReferenceMarkerNumeric:H,characterReferenceValue:W,characterReference:ee,codeFenced:m(T),codeFencedFence:N,codeFencedFenceInfo:y,codeFencedFenceMeta:w,codeFlowValue:$,codeIndented:m(C),codeText:m(L),codeTextData:$,data:$,definition:m(),definitionDestinationString:M,definitionLabelString:_,definitionTitleString:k,emphasis:m(),hardBreakEscape:m(U),hardBreakTrailing:m(U),htmlFlow:m(z),htmlFlowData:$,htmlText:m(E),htmlTextData:$,image:m(F),label:Z,labelText:Y,lineEnding:q,link:m(R),listItem:m(),listOrdered:m(),listUnordered:m(),paragraph:m(),referenceString:S,resourceDestinationString:B,resourceTitleString:O,resource:V,setextHeading:m(X),setextHeadingLineSequence:G,setextHeadingText:A,strong:m(),thematicBreak:m()}};aj(n,(e||{}).mdastExtensions||[]);const s={};return i;function i(ye){let Ae={type:"root",children:[]};const Fe={stack:[Ae],tokenStack:[],config:n,enter:h,exit:f,buffer:c,resume:x,data:s},Qe=[];let xt=-1;for(;++xt<ye.length;)if(ye[xt][1].type==="listOrdered"||ye[xt][1].type==="listUnordered")if(ye[xt][0]==="enter")Qe.push(xt);else{const nn=Qe.pop();xt=l(ye,nn,xt)}for(xt=-1;++xt<ye.length;){const nn=n[ye[xt][0]];sj.call(nn,ye[xt][1].type)&&nn[ye[xt][1].type].call(Object.assign({sliceSerialize:ye[xt][2].sliceSerialize},Fe),ye[xt][1])}if(Fe.tokenStack.length>0){const nn=Fe.tokenStack[Fe.tokenStack.length-1];(nn[1]||ty).call(Fe,void 0,nn[0])}for(Ae.position={start:Ba(ye.length>0?ye[0][1].start:{line:1,column:1,offset:0}),end:Ba(ye.length>0?ye[ye.length-2][1].end:{line:1,column:1,offset:0})},xt=-1;++xt<n.transforms.length;)Ae=n.transforms[xt](Ae)||Ae;return Ae}function l(ye,Ae,Fe){let Qe=Ae-1,xt=-1,nn=!1,cn,Tt,gt,Bt;for(;++Qe<=Fe;){const _t=ye[Qe];switch(_t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{_t[0]==="enter"?xt++:xt--,Bt=void 0;break}case"lineEndingBlank":{_t[0]==="enter"&&(cn&&!Bt&&!xt&&!gt&&(gt=Qe),Bt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Bt=void 0}if(!xt&&_t[0]==="enter"&&_t[1].type==="listItemPrefix"||xt===-1&&_t[0]==="exit"&&(_t[1].type==="listUnordered"||_t[1].type==="listOrdered")){if(cn){let Ht=Qe;for(Tt=void 0;Ht--;){const rn=ye[Ht];if(rn[1].type==="lineEnding"||rn[1].type==="lineEndingBlank"){if(rn[0]==="exit")continue;Tt&&(ye[Tt][1].type="lineEndingBlank",nn=!0),rn[1].type="lineEnding",Tt=Ht}else if(!(rn[1].type==="linePrefix"||rn[1].type==="blockQuotePrefix"||rn[1].type==="blockQuotePrefixWhitespace"||rn[1].type==="blockQuoteMarker"||rn[1].type==="listItemIndent"))break}gt&&(!Tt||gt<Tt)&&(cn._spread=!0),cn.end=Object.assign({},Tt?ye[Tt][1].start:_t[1].end),ye.splice(Tt||Qe,0,["exit",cn,_t[2]]),Qe++,Fe++}if(_t[1].type==="listItemPrefix"){const Ht={type:"listItem",_spread:!1,start:Object.assign({},_t[1].start),end:void 0};cn=Ht,ye.splice(Qe,0,["enter",Ht,_t[2]]),Qe++,Fe++,gt=void 0,Bt=!0}}}return ye[Ae][1]._spread=nn,Fe}function d(ye,Ae){return Fe;function Fe(Qe){h.call(this,ye(Qe),Qe),Ae&&Ae.call(this,Qe)}}function c(){this.stack.push({type:"fragment",children:[]})}function h(ye,Ae,Fe){this.stack[this.stack.length-1].children.push(ye),this.stack.push(ye),this.tokenStack.push([Ae,Fe||void 0]),ye.position={start:Ba(Ae.start),end:void 0}}function m(ye){return Ae;function Ae(Fe){ye&&ye.call(this,Fe),f.call(this,Fe)}}function f(ye,Ae){const Fe=this.stack.pop(),Qe=this.tokenStack.pop();if(Qe)Qe[0].type!==ye.type&&(Ae?Ae.call(this,ye,Qe[0]):(Qe[1]||ty).call(this,ye,Qe[0]));else throw new Error("Cannot close `"+ye.type+"` ("+Oo({start:ye.start,end:ye.end})+"): it’s not open");Fe.position.end=Ba(ye.end)}function x(){return mx(this.stack.pop())}function p(){this.data.expectingFirstListItemValue=!0}function g(ye){if(this.data.expectingFirstListItemValue){const Ae=this.stack[this.stack.length-2];Ae.start=Number.parseInt(this.sliceSerialize(ye),10),this.data.expectingFirstListItemValue=void 0}}function y(){const ye=this.resume(),Ae=this.stack[this.stack.length-1];Ae.lang=ye}function w(){const ye=this.resume(),Ae=this.stack[this.stack.length-1];Ae.meta=ye}function N(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function T(){const ye=this.resume(),Ae=this.stack[this.stack.length-1];Ae.value=ye.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function C(){const ye=this.resume(),Ae=this.stack[this.stack.length-1];Ae.value=ye.replace(/(\r?\n|\r)$/g,"")}function _(ye){const Ae=this.resume(),Fe=this.stack[this.stack.length-1];Fe.label=Ae,Fe.identifier=vs(this.sliceSerialize(ye)).toLowerCase()}function k(){const ye=this.resume(),Ae=this.stack[this.stack.length-1];Ae.title=ye}function M(){const ye=this.resume(),Ae=this.stack[this.stack.length-1];Ae.url=ye}function D(ye){const Ae=this.stack[this.stack.length-1];if(!Ae.depth){const Fe=this.sliceSerialize(ye).length;Ae.depth=Fe}}function A(){this.data.setextHeadingSlurpLineEnding=!0}function G(ye){const Ae=this.stack[this.stack.length-1];Ae.depth=this.sliceSerialize(ye).codePointAt(0)===61?1:2}function X(){this.data.setextHeadingSlurpLineEnding=void 0}function K(ye){const Fe=this.stack[this.stack.length-1].children;let Qe=Fe[Fe.length-1];(!Qe||Qe.type!=="text")&&(Qe=dt(),Qe.position={start:Ba(ye.start),end:void 0},Fe.push(Qe)),this.stack.push(Qe)}function $(ye){const Ae=this.stack.pop();Ae.value+=this.sliceSerialize(ye),Ae.position.end=Ba(ye.end)}function q(ye){const Ae=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Fe=Ae.children[Ae.children.length-1];Fe.position.end=Ba(ye.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&n.canContainEols.includes(Ae.type)&&(K.call(this,ye),$.call(this,ye))}function U(){this.data.atHardBreak=!0}function z(){const ye=this.resume(),Ae=this.stack[this.stack.length-1];Ae.value=ye}function E(){const ye=this.resume(),Ae=this.stack[this.stack.length-1];Ae.value=ye}function L(){const ye=this.resume(),Ae=this.stack[this.stack.length-1];Ae.value=ye}function R(){const ye=this.stack[this.stack.length-1];if(this.data.inReference){const Ae=this.data.referenceType||"shortcut";ye.type+="Reference",ye.referenceType=Ae,delete ye.url,delete ye.title}else delete ye.identifier,delete ye.label;this.data.referenceType=void 0}function F(){const ye=this.stack[this.stack.length-1];if(this.data.inReference){const Ae=this.data.referenceType||"shortcut";ye.type+="Reference",ye.referenceType=Ae,delete ye.url,delete ye.title}else delete ye.identifier,delete ye.label;this.data.referenceType=void 0}function Y(ye){const Ae=this.sliceSerialize(ye),Fe=this.stack[this.stack.length-2];Fe.label=sE(Ae),Fe.identifier=vs(Ae).toLowerCase()}function Z(){const ye=this.stack[this.stack.length-1],Ae=this.resume(),Fe=this.stack[this.stack.length-1];if(this.data.inReference=!0,Fe.type==="link"){const Qe=ye.children;Fe.children=Qe}else Fe.alt=Ae}function B(){const ye=this.resume(),Ae=this.stack[this.stack.length-1];Ae.url=ye}function O(){const ye=this.resume(),Ae=this.stack[this.stack.length-1];Ae.title=ye}function V(){this.data.inReference=void 0}function I(){this.data.referenceType="collapsed"}function S(ye){const Ae=this.resume(),Fe=this.stack[this.stack.length-1];Fe.label=Ae,Fe.identifier=vs(this.sliceSerialize(ye)).toLowerCase(),this.data.referenceType="full"}function H(ye){this.data.characterReferenceType=ye.type}function W(ye){const Ae=this.sliceSerialize(ye),Fe=this.data.characterReferenceType;let Qe;Fe?(Qe=X1(Ae,Fe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Qe=xx(Ae);const xt=this.stack[this.stack.length-1];xt.value+=Qe}function ee(ye){const Ae=this.stack.pop();Ae.position.end=Ba(ye.end)}function te(ye){$.call(this,ye);const Ae=this.stack[this.stack.length-1];Ae.url=this.sliceSerialize(ye)}function ae(ye){$.call(this,ye);const Ae=this.stack[this.stack.length-1];Ae.url="mailto:"+this.sliceSerialize(ye)}function he(){return{type:"blockquote",children:[]}}function Ne(){return{type:"code",lang:null,meta:null,value:""}}function De(){return{type:"inlineCode",value:""}}function je(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ke(){return{type:"emphasis",children:[]}}function Se(){return{type:"heading",depth:0,children:[]}}function Le(){return{type:"break"}}function nt(){return{type:"html",value:""}}function rt(){return{type:"image",title:null,url:"",alt:null}}function yt(){return{type:"link",title:null,url:"",children:[]}}function Rt(ye){return{type:"list",ordered:ye.type==="listOrdered",start:null,spread:ye._spread,children:[]}}function re(ye){return{type:"listItem",spread:ye._spread,checked:null,children:[]}}function _e(){return{type:"paragraph",children:[]}}function st(){return{type:"strong",children:[]}}function dt(){return{type:"text",value:""}}function Yt(){return{type:"thematicBreak"}}}function Ba(e){return{line:e.line,column:e.column,offset:e.offset}}function aj(e,n){let s=-1;for(;++s<n.length;){const i=n[s];Array.isArray(i)?aj(e,i):oE(e,i)}}function oE(e,n){let s;for(s in n)if(sj.call(n,s))switch(s){case"canContainEols":{const i=n[s];i&&e[s].push(...i);break}case"transforms":{const i=n[s];i&&e[s].push(...i);break}case"enter":case"exit":{const i=n[s];i&&Object.assign(e[s],i);break}}}function ty(e,n){throw e?new Error("Cannot close `"+e.type+"` ("+Oo({start:e.start,end:e.end})+"): a different token (`"+n.type+"`, "+Oo({start:n.start,end:n.end})+") is open"):new Error("Cannot close document, a token (`"+n.type+"`, "+Oo({start:n.start,end:n.end})+") is still open")}function cE(e){const n=this;n.parser=s;function s(i){return iE(i,{...n.data("settings"),...e,extensions:n.data("micromarkExtensions")||[],mdastExtensions:n.data("fromMarkdownExtensions")||[]})}}function dE(e,n){const s={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(n),!0)};return e.patch(n,s),e.applyData(n,s)}function uE(e,n){const s={type:"element",tagName:"br",properties:{},children:[]};return e.patch(n,s),[e.applyData(n,s),{type:"text",value:`
|
|
14
|
-
`}]}function fE(e,n){const s=n.value?n.value+`
|
|
15
|
-
`:"",i={},l=n.lang?n.lang.split(/\s+/):[];l.length>0&&(i.className=["language-"+l[0]]);let d={type:"element",tagName:"code",properties:i,children:[{type:"text",value:s}]};return n.meta&&(d.data={meta:n.meta}),e.patch(n,d),d=e.applyData(n,d),d={type:"element",tagName:"pre",properties:{},children:[d]},e.patch(n,d),d}function hE(e,n){const s={type:"element",tagName:"del",properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}function mE(e,n){const s={type:"element",tagName:"em",properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}function xE(e,n){const s=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",i=String(n.identifier).toUpperCase(),l=Al(i.toLowerCase()),d=e.footnoteOrder.indexOf(i);let c,h=e.footnoteCounts.get(i);h===void 0?(h=0,e.footnoteOrder.push(i),c=e.footnoteOrder.length):c=d+1,h+=1,e.footnoteCounts.set(i,h);const m={type:"element",tagName:"a",properties:{href:"#"+s+"fn-"+l,id:s+"fnref-"+l+(h>1?"-"+h:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(c)}]};e.patch(n,m);const f={type:"element",tagName:"sup",properties:{},children:[m]};return e.patch(n,f),e.applyData(n,f)}function pE(e,n){const s={type:"element",tagName:"h"+n.depth,properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}function gE(e,n){if(e.options.allowDangerousHtml){const s={type:"raw",value:n.value};return e.patch(n,s),e.applyData(n,s)}}function ij(e,n){const s=n.referenceType;let i="]";if(s==="collapsed"?i+="[]":s==="full"&&(i+="["+(n.label||n.identifier)+"]"),n.type==="imageReference")return[{type:"text",value:"!["+n.alt+i}];const l=e.all(n),d=l[0];d&&d.type==="text"?d.value="["+d.value:l.unshift({type:"text",value:"["});const c=l[l.length-1];return c&&c.type==="text"?c.value+=i:l.push({type:"text",value:i}),l}function bE(e,n){const s=String(n.identifier).toUpperCase(),i=e.definitionById.get(s);if(!i)return ij(e,n);const l={src:Al(i.url||""),alt:n.alt};i.title!==null&&i.title!==void 0&&(l.title=i.title);const d={type:"element",tagName:"img",properties:l,children:[]};return e.patch(n,d),e.applyData(n,d)}function yE(e,n){const s={src:Al(n.url)};n.alt!==null&&n.alt!==void 0&&(s.alt=n.alt),n.title!==null&&n.title!==void 0&&(s.title=n.title);const i={type:"element",tagName:"img",properties:s,children:[]};return e.patch(n,i),e.applyData(n,i)}function vE(e,n){const s={type:"text",value:n.value.replace(/\r?\n|\r/g," ")};e.patch(n,s);const i={type:"element",tagName:"code",properties:{},children:[s]};return e.patch(n,i),e.applyData(n,i)}function jE(e,n){const s=String(n.identifier).toUpperCase(),i=e.definitionById.get(s);if(!i)return ij(e,n);const l={href:Al(i.url||"")};i.title!==null&&i.title!==void 0&&(l.title=i.title);const d={type:"element",tagName:"a",properties:l,children:e.all(n)};return e.patch(n,d),e.applyData(n,d)}function wE(e,n){const s={href:Al(n.url)};n.title!==null&&n.title!==void 0&&(s.title=n.title);const i={type:"element",tagName:"a",properties:s,children:e.all(n)};return e.patch(n,i),e.applyData(n,i)}function NE(e,n,s){const i=e.all(n),l=s?kE(s):lj(n),d={},c=[];if(typeof n.checked=="boolean"){const x=i[0];let p;x&&x.type==="element"&&x.tagName==="p"?p=x:(p={type:"element",tagName:"p",properties:{},children:[]},i.unshift(p)),p.children.length>0&&p.children.unshift({type:"text",value:" "}),p.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:n.checked,disabled:!0},children:[]}),d.className=["task-list-item"]}let h=-1;for(;++h<i.length;){const x=i[h];(l||h!==0||x.type!=="element"||x.tagName!=="p")&&c.push({type:"text",value:`
|
|
16
|
-
`}),x.type==="element"&&x.tagName==="p"&&!l?c.push(...x.children):c.push(x)}const m=i[i.length-1];m&&(l||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(n,f),e.applyData(n,f)}function kE(e){let n=!1;if(e.type==="list"){n=e.spread||!1;const s=e.children;let i=-1;for(;!n&&++i<s.length;)n=lj(s[i])}return n}function lj(e){const n=e.spread;return n??e.children.length>1}function SE(e,n){const s={},i=e.all(n);let l=-1;for(typeof n.start=="number"&&n.start!==1&&(s.start=n.start);++l<i.length;){const c=i[l];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:n.ordered?"ol":"ul",properties:s,children:e.wrap(i,!0)};return e.patch(n,d),e.applyData(n,d)}function CE(e,n){const s={type:"element",tagName:"p",properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}function EE(e,n){const s={type:"root",children:e.wrap(e.all(n))};return e.patch(n,s),e.applyData(n,s)}function TE(e,n){const s={type:"element",tagName:"strong",properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}function _E(e,n){const s=e.all(n),i=s.shift(),l=[];if(i){const c={type:"element",tagName:"thead",properties:{},children:e.wrap([i],!0)};e.patch(n.children[0],c),l.push(c)}if(s.length>0){const c={type:"element",tagName:"tbody",properties:{},children:e.wrap(s,!0)},h=dx(n.children[1]),m=H1(n.children[n.children.length-1]);h&&m&&(c.position={start:h,end:m}),l.push(c)}const d={type:"element",tagName:"table",properties:{},children:e.wrap(l,!0)};return e.patch(n,d),e.applyData(n,d)}function AE(e,n,s){const i=s?s.children:void 0,d=(i?i.indexOf(n):1)===0?"th":"td",c=s&&s.type==="table"?s.align:void 0,h=c?c.length:n.children.length;let m=-1;const f=[];for(;++m<h;){const p=n.children[m],g={},y=c?c[m]:void 0;y&&(g.align=y);let w={type:"element",tagName:d,properties:g,children:[]};p&&(w.children=e.all(p),e.patch(p,w),w=e.applyData(p,w)),f.push(w)}const x={type:"element",tagName:"tr",properties:{},children:e.wrap(f,!0)};return e.patch(n,x),e.applyData(n,x)}function ME(e,n){const s={type:"element",tagName:"td",properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}const ny=9,ry=32;function RE(e){const n=String(e),s=/\r?\n|\r/g;let i=s.exec(n),l=0;const d=[];for(;i;)d.push(sy(n.slice(l,i.index),l>0,!0),i[0]),l=i.index+i[0].length,i=s.exec(n);return d.push(sy(n.slice(l),l>0,!1)),d.join("")}function sy(e,n,s){let i=0,l=e.length;if(n){let d=e.codePointAt(i);for(;d===ny||d===ry;)i++,d=e.codePointAt(i)}if(s){let d=e.codePointAt(l-1);for(;d===ny||d===ry;)l--,d=e.codePointAt(l-1)}return l>i?e.slice(i,l):""}function OE(e,n){const s={type:"text",value:RE(String(n.value))};return e.patch(n,s),e.applyData(n,s)}function DE(e,n){const s={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(n,s),e.applyData(n,s)}const LE={blockquote:dE,break:uE,code:fE,delete:hE,emphasis:mE,footnoteReference:xE,heading:pE,html:gE,imageReference:bE,image:yE,inlineCode:vE,linkReference:jE,link:wE,listItem:NE,list:SE,paragraph:CE,root:EE,strong:TE,table:_E,tableCell:ME,tableRow:AE,text:OE,thematicBreak:DE,toml:pd,yaml:pd,definition:pd,footnoteDefinition:pd};function pd(){}const oj=-1,lu=0,Lo=1,Hd=2,gx=3,bx=4,yx=5,vx=6,cj=7,dj=8,ay=typeof self=="object"?self:globalThis,IE=(e,n)=>{const s=(l,d)=>(e.set(d,l),l),i=l=>{if(e.has(l))return e.get(l);const[d,c]=n[l];switch(d){case lu:case oj:return s(c,l);case Lo:{const h=s([],l);for(const m of c)h.push(i(m));return h}case Hd:{const h=s({},l);for(const[m,f]of c)h[i(m)]=i(f);return h}case gx:return s(new Date(c),l);case bx:{const{source:h,flags:m}=c;return s(new RegExp(h,m),l)}case yx:{const h=s(new Map,l);for(const[m,f]of c)h.set(i(m),i(f));return h}case vx:{const h=s(new Set,l);for(const m of c)h.add(i(m));return h}case cj:{const{name:h,message:m}=c;return s(new ay[h](m),l)}case dj:return s(BigInt(c),l);case"BigInt":return s(Object(BigInt(c)),l);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 ay[d](c),l)};return i},iy=e=>IE(new Map,e)(0),il="",{toString:zE}={},{keys:$E}=Object,wo=e=>{const n=typeof e;if(n!=="object"||!e)return[lu,n];const s=zE.call(e).slice(8,-1);switch(s){case"Array":return[Lo,il];case"Object":return[Hd,il];case"Date":return[gx,il];case"RegExp":return[bx,il];case"Map":return[yx,il];case"Set":return[vx,il];case"DataView":return[Lo,s]}return s.includes("Array")?[Lo,s]:s.includes("Error")?[cj,s]:[Hd,s]},gd=([e,n])=>e===lu&&(n==="function"||n==="symbol"),BE=(e,n,s,i)=>{const l=(c,h)=>{const m=i.push(c)-1;return s.set(h,m),m},d=c=>{if(s.has(c))return s.get(c);let[h,m]=wo(c);switch(h){case lu:{let x=c;switch(m){case"bigint":h=dj,x=c.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+m);x=null;break;case"undefined":return l([oj],c)}return l([h,x],c)}case Lo:{if(m){let g=c;return m==="DataView"?g=new Uint8Array(c.buffer):m==="ArrayBuffer"&&(g=new Uint8Array(c)),l([m,[...g]],c)}const x=[],p=l([h,x],c);for(const g of c)x.push(d(g));return p}case Hd:{if(m)switch(m){case"BigInt":return l([m,c.toString()],c);case"Boolean":case"Number":case"String":return l([m,c.valueOf()],c)}if(n&&"toJSON"in c)return d(c.toJSON());const x=[],p=l([h,x],c);for(const g of $E(c))(e||!gd(wo(c[g])))&&x.push([d(g),d(c[g])]);return p}case gx:return l([h,c.toISOString()],c);case bx:{const{source:x,flags:p}=c;return l([h,{source:x,flags:p}],c)}case yx:{const x=[],p=l([h,x],c);for(const[g,y]of c)(e||!(gd(wo(g))||gd(wo(y))))&&x.push([d(g),d(y)]);return p}case vx:{const x=[],p=l([h,x],c);for(const g of c)(e||!gd(wo(g)))&&x.push(d(g));return p}}const{message:f}=c;return l([h,{name:m,message:f}],c)};return d},ly=(e,{json:n,lossy:s}={})=>{const i=[];return BE(!(n||s),!!n,new Map,i)(e),i},Pd=typeof structuredClone=="function"?(e,n)=>n&&("json"in n||"lossy"in n)?iy(ly(e,n)):structuredClone(e):(e,n)=>iy(ly(e,n));function HE(e,n){const s=[{type:"text",value:"↩"}];return n>1&&s.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(n)}]}),s}function PE(e,n){return"Back to reference "+(e+1)+(n>1?"-"+n:"")}function qE(e){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",s=e.options.footnoteBackContent||HE,i=e.options.footnoteBackLabel||PE,l=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),p=String(f.identifier).toUpperCase(),g=Al(p.toLowerCase());let y=0;const w=[],N=e.footnoteCounts.get(p);for(;N!==void 0&&++y<=N;){w.length>0&&w.push({type:"text",value:" "});let _=typeof s=="string"?s:s(m,y);typeof _=="string"&&(_={type:"text",value:_}),w.push({type:"element",tagName:"a",properties:{href:"#"+n+"fnref-"+g+(y>1?"-"+y:""),dataFootnoteBackref:"",ariaLabel:typeof i=="string"?i:i(m,y),className:["data-footnote-backref"]},children:Array.isArray(_)?_:[_]})}const T=x[x.length-1];if(T&&T.type==="element"&&T.tagName==="p"){const _=T.children[T.children.length-1];_&&_.type==="text"?_.value+=" ":T.children.push({type:"text",value:" "}),T.children.push(...w)}else x.push(...w);const C={type:"element",tagName:"li",properties:{id:n+"fn-"+g},children:e.wrap(x,!0)};e.patch(f,C),h.push(C)}if(h.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:d,properties:{...Pd(c),id:"footnote-label"},children:[{type:"text",value:l}]},{type:"text",value:`
|
|
18
|
-
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(h,!0)},{type:"text",value:`
|
|
19
|
-
`}]}}const ou=(function(e){if(e==null)return YE;if(typeof e=="function")return cu(e);if(typeof e=="object")return Array.isArray(e)?UE(e):VE(e);if(typeof e=="string")return FE(e);throw new Error("Expected function, string, or object as test")});function UE(e){const n=[];let s=-1;for(;++s<e.length;)n[s]=ou(e[s]);return cu(i);function i(...l){let d=-1;for(;++d<n.length;)if(n[d].apply(this,l))return!0;return!1}}function VE(e){const n=e;return cu(s);function s(i){const l=i;let d;for(d in e)if(l[d]!==n[d])return!1;return!0}}function FE(e){return cu(n);function n(s){return s&&s.type===e}}function cu(e){return n;function n(s,i,l){return!!(GE(s)&&e.call(this,s,typeof i=="number"?i:void 0,l||void 0))}}function YE(){return!0}function GE(e){return e!==null&&typeof e=="object"&&"type"in e}const uj=[],XE=!0,Tm=!1,KE="skip";function fj(e,n,s,i){let l;typeof n=="function"&&typeof s!="function"?(i=s,s=n):l=n;const d=ou(l),c=i?-1:1;h(e,void 0,[])();function h(m,f,x){const p=m&&typeof m=="object"?m:{};if(typeof p.type=="string"){const y=typeof p.tagName=="string"?p.tagName:typeof p.name=="string"?p.name:void 0;Object.defineProperty(g,"name",{value:"node ("+(m.type+(y?"<"+y+">":""))+")"})}return g;function g(){let y=uj,w,N,T;if((!n||d(m,f,x[x.length-1]||void 0))&&(y=WE(s(m,x)),y[0]===Tm))return y;if("children"in m&&m.children){const C=m;if(C.children&&y[0]!==KE)for(N=(i?C.children.length:-1)+c,T=x.concat(C);N>-1&&N<C.children.length;){const _=C.children[N];if(w=h(_,N,T)(),w[0]===Tm)return w;N=typeof w[1]=="number"?w[1]:N+c}}return y}}}function WE(e){return Array.isArray(e)?e:typeof e=="number"?[XE,e]:e==null?uj:[e]}function jx(e,n,s,i){let l,d,c;typeof n=="function"&&typeof s!="function"?(d=void 0,c=n,l=s):(d=n,c=s,l=i),fj(e,d,h,l);function h(m,f){const x=f[f.length-1],p=x?x.children.indexOf(m):void 0;return c(m,p,x)}}const _m={}.hasOwnProperty,QE={};function ZE(e,n){const s=n||QE,i=new Map,l=new Map,d=new Map,c={...LE,...s.handlers},h={all:f,applyData:e3,definitionById:i,footnoteById:l,footnoteCounts:d,footnoteOrder:[],handlers:c,one:m,options:s,patch:JE,wrap:n3};return jx(e,function(x){if(x.type==="definition"||x.type==="footnoteDefinition"){const p=x.type==="definition"?i:l,g=String(x.identifier).toUpperCase();p.has(g)||p.set(g,x)}}),h;function m(x,p){const g=x.type,y=h.handlers[g];if(_m.call(h.handlers,g)&&y)return y(h,x,p);if(h.options.passThrough&&h.options.passThrough.includes(g)){if("children"in x){const{children:N,...T}=x,C=Pd(T);return C.children=h.all(x),C}return Pd(x)}return(h.options.unknownHandler||t3)(h,x,p)}function f(x){const p=[];if("children"in x){const g=x.children;let y=-1;for(;++y<g.length;){const w=h.one(g[y],x);if(w){if(y&&g[y-1].type==="break"&&(!Array.isArray(w)&&w.type==="text"&&(w.value=oy(w.value)),!Array.isArray(w)&&w.type==="element")){const N=w.children[0];N&&N.type==="text"&&(N.value=oy(N.value))}Array.isArray(w)?p.push(...w):p.push(w)}}}return p}}function JE(e,n){e.position&&(n.position=Pk(e))}function e3(e,n){let s=n;if(e&&e.data){const i=e.data.hName,l=e.data.hChildren,d=e.data.hProperties;if(typeof i=="string")if(s.type==="element")s.tagName=i;else{const c="children"in s?s.children:[s];s={type:"element",tagName:i,properties:{},children:c}}s.type==="element"&&d&&Object.assign(s.properties,Pd(d)),"children"in s&&s.children&&l!==null&&l!==void 0&&(s.children=l)}return s}function t3(e,n){const s=n.data||{},i="value"in n&&!(_m.call(s,"hProperties")||_m.call(s,"hChildren"))?{type:"text",value:n.value}:{type:"element",tagName:"div",properties:{},children:e.all(n)};return e.patch(n,i),e.applyData(n,i)}function n3(e,n){const s=[];let i=-1;for(n&&s.push({type:"text",value:`
|
|
20
|
-
`});++i<e.length;)i&&s.push({type:"text",value:`
|
|
21
|
-
`}),s.push(e[i]);return n&&e.length>0&&s.push({type:"text",value:`
|
|
22
|
-
`}),s}function oy(e){let n=0,s=e.charCodeAt(n);for(;s===9||s===32;)n++,s=e.charCodeAt(n);return e.slice(n)}function cy(e,n){const s=ZE(e,n),i=s.one(e,void 0),l=qE(s),d=Array.isArray(i)?{type:"root",children:i}:i||{type:"root",children:[]};return l&&d.children.push({type:"text",value:`
|
|
23
|
-
`},l),d}function r3(e,n){return e&&"run"in e?async function(s,i){const l=cy(s,{file:i,...n});await e.run(l,i)}:function(s,i){return cy(s,{file:i,...e||n})}}function dy(e){if(e)throw e}var Lh,uy;function s3(){if(uy)return Lh;uy=1;var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,s=Object.defineProperty,i=Object.getOwnPropertyDescriptor,l=function(f){return typeof Array.isArray=="function"?Array.isArray(f):n.call(f)==="[object Array]"},d=function(f){if(!f||n.call(f)!=="[object Object]")return!1;var x=e.call(f,"constructor"),p=f.constructor&&f.constructor.prototype&&e.call(f.constructor.prototype,"isPrototypeOf");if(f.constructor&&!x&&!p)return!1;var g;for(g in f);return typeof g>"u"||e.call(f,g)},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(i)return i(f,x).value}else return;return f[x]};return Lh=function m(){var f,x,p,g,y,w,N=arguments[0],T=1,C=arguments.length,_=!1;for(typeof N=="boolean"&&(_=N,N=arguments[1]||{},T=2),(N==null||typeof N!="object"&&typeof N!="function")&&(N={});T<C;++T)if(f=arguments[T],f!=null)for(x in f)p=h(N,x),g=h(f,x),N!==g&&(_&&g&&(d(g)||(y=l(g)))?(y?(y=!1,w=p&&l(p)?p:[]):w=p&&d(p)?p:{},c(N,{name:x,newValue:m(_,w,g)})):typeof g<"u"&&c(N,{name:x,newValue:g}));return N},Lh}var a3=s3();const Ih=su(a3);function Am(e){if(typeof e!="object"||e===null)return!1;const n=Object.getPrototypeOf(e);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function i3(){const e=[],n={run:s,use:i};return n;function s(...l){let d=-1;const c=l.pop();if(typeof c!="function")throw new TypeError("Expected function as last argument, not "+c);h(null,...l);function h(m,...f){const x=e[++d];let p=-1;if(m){c(m);return}for(;++p<l.length;)(f[p]===null||f[p]===void 0)&&(f[p]=l[p]);l=f,x?l3(x,h)(...f):c(null,...f)}}function i(l){if(typeof l!="function")throw new TypeError("Expected `middelware` to be a function, not "+l);return e.push(l),n}}function l3(e,n){let s;return i;function i(...c){const h=e.length>c.length;let m;h&&c.push(l);try{m=e.apply(this,c)}catch(f){const x=f;if(h&&s)throw x;return l(x)}h||(m&&m.then&&typeof m.then=="function"?m.then(d,l):m instanceof Error?l(m):d(m))}function l(c,...h){s||(s=!0,n(c,...h))}function d(c){l(null,c)}}const Ms={basename:o3,dirname:c3,extname:d3,join:u3,sep:"/"};function o3(e,n){if(n!==void 0&&typeof n!="string")throw new TypeError('"ext" argument must be a string');rc(e);let s=0,i=-1,l=e.length,d;if(n===void 0||n.length===0||n.length>e.length){for(;l--;)if(e.codePointAt(l)===47){if(d){s=l+1;break}}else i<0&&(d=!0,i=l+1);return i<0?"":e.slice(s,i)}if(n===e)return"";let c=-1,h=n.length-1;for(;l--;)if(e.codePointAt(l)===47){if(d){s=l+1;break}}else c<0&&(d=!0,c=l+1),h>-1&&(e.codePointAt(l)===n.codePointAt(h--)?h<0&&(i=l):(h=-1,i=c));return s===i?i=c:i<0&&(i=e.length),e.slice(s,i)}function c3(e){if(rc(e),e.length===0)return".";let n=-1,s=e.length,i;for(;--s;)if(e.codePointAt(s)===47){if(i){n=s;break}}else i||(i=!0);return n<0?e.codePointAt(0)===47?"/":".":n===1&&e.codePointAt(0)===47?"//":e.slice(0,n)}function d3(e){rc(e);let n=e.length,s=-1,i=0,l=-1,d=0,c;for(;n--;){const h=e.codePointAt(n);if(h===47){if(c){i=n+1;break}continue}s<0&&(c=!0,s=n+1),h===46?l<0?l=n:d!==1&&(d=1):l>-1&&(d=-1)}return l<0||s<0||d===0||d===1&&l===s-1&&l===i+1?"":e.slice(l,s)}function u3(...e){let n=-1,s;for(;++n<e.length;)rc(e[n]),e[n]&&(s=s===void 0?e[n]:s+"/"+e[n]);return s===void 0?".":f3(s)}function f3(e){rc(e);const n=e.codePointAt(0)===47;let s=h3(e,!n);return s.length===0&&!n&&(s="."),s.length>0&&e.codePointAt(e.length-1)===47&&(s+="/"),n?"/"+s:s}function h3(e,n){let s="",i=0,l=-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(!(l===c-1||d===1))if(l!==c-1&&d===2){if(s.length<2||i!==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="",i=0):(s=s.slice(0,m),i=s.length-1-s.lastIndexOf("/")),l=c,d=0;continue}}else if(s.length>0){s="",i=0,l=c,d=0;continue}}n&&(s=s.length>0?s+"/..":"..",i=2)}else s.length>0?s+="/"+e.slice(l+1,c):s=e.slice(l+1,c),i=c-l-1;l=c,d=0}else h===46&&d>-1?d++:d=-1}return s}function rc(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const m3={cwd:x3};function x3(){return"/"}function Mm(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function p3(e){if(typeof e=="string")e=new URL(e);else if(!Mm(e)){const n=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw n.code="ERR_INVALID_ARG_TYPE",n}if(e.protocol!=="file:"){const n=new TypeError("The URL must be of scheme file");throw n.code="ERR_INVALID_URL_SCHEME",n}return g3(e)}function g3(e){if(e.hostname!==""){const i=new TypeError('File URL host must be "localhost" or empty on darwin');throw i.code="ERR_INVALID_FILE_URL_HOST",i}const n=e.pathname;let s=-1;for(;++s<n.length;)if(n.codePointAt(s)===37&&n.codePointAt(s+1)===50){const i=n.codePointAt(s+2);if(i===70||i===102){const l=new TypeError("File URL path must not include encoded / characters");throw l.code="ERR_INVALID_FILE_URL_PATH",l}}return decodeURIComponent(n)}const zh=["history","path","basename","stem","extname","dirname"];class hj{constructor(n){let s;n?Mm(n)?s={path:n}:typeof n=="string"||b3(n)?s={value:n}:s=n:s={},this.cwd="cwd"in s?"":m3.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let i=-1;for(;++i<zh.length;){const d=zh[i];d in s&&s[d]!==void 0&&s[d]!==null&&(this[d]=d==="history"?[...s[d]]:s[d])}let l;for(l in s)zh.includes(l)||(this[l]=s[l])}get basename(){return typeof this.path=="string"?Ms.basename(this.path):void 0}set basename(n){Bh(n,"basename"),$h(n,"basename"),this.path=Ms.join(this.dirname||"",n)}get dirname(){return typeof this.path=="string"?Ms.dirname(this.path):void 0}set dirname(n){fy(this.basename,"dirname"),this.path=Ms.join(n||"",this.basename)}get extname(){return typeof this.path=="string"?Ms.extname(this.path):void 0}set extname(n){if($h(n,"extname"),fy(this.dirname,"extname"),n){if(n.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(n.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Ms.join(this.dirname,this.stem+(n||""))}get path(){return this.history[this.history.length-1]}set path(n){Mm(n)&&(n=p3(n)),Bh(n,"path"),this.path!==n&&this.history.push(n)}get stem(){return typeof this.path=="string"?Ms.basename(this.path,this.extname):void 0}set stem(n){Bh(n,"stem"),$h(n,"stem"),this.path=Ms.join(this.dirname||"",n+(this.extname||""))}fail(n,s,i){const l=this.message(n,s,i);throw l.fatal=!0,l}info(n,s,i){const l=this.message(n,s,i);return l.fatal=void 0,l}message(n,s,i){const l=new br(n,s,i);return this.path&&(l.name=this.path+":"+l.name,l.file=this.path),l.fatal=!1,this.messages.push(l),l}toString(n){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(n||void 0).decode(this.value)}}function $h(e,n){if(e&&e.includes(Ms.sep))throw new Error("`"+n+"` cannot be a path: did not expect `"+Ms.sep+"`")}function Bh(e,n){if(!e)throw new Error("`"+n+"` cannot be empty")}function fy(e,n){if(!e)throw new Error("Setting `"+n+"` requires `path` to be set too")}function b3(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const y3=(function(e){const i=this.constructor.prototype,l=i[e],d=function(){return l.apply(d,arguments)};return Object.setPrototypeOf(d,i),d}),v3={}.hasOwnProperty;class wx extends y3{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=i3()}copy(){const n=new wx;let s=-1;for(;++s<this.attachers.length;){const i=this.attachers[s];n.use(...i)}return n.data(Ih(!0,{},this.namespace)),n}data(n,s){return typeof n=="string"?arguments.length===2?(qh("data",this.frozen),this.namespace[n]=s,this):v3.call(this.namespace,n)&&this.namespace[n]||void 0:n?(qh("data",this.frozen),this.namespace=n,this):this.namespace}freeze(){if(this.frozen)return this;const n=this;for(;++this.freezeIndex<this.attachers.length;){const[s,...i]=this.attachers[this.freezeIndex];if(i[0]===!1)continue;i[0]===!0&&(i[0]=void 0);const l=s.call(n,...i);typeof l=="function"&&this.transformers.use(l)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(n){this.freeze();const s=bd(n),i=this.parser||this.Parser;return Hh("parse",i),i(String(s),s)}process(n,s){const i=this;return this.freeze(),Hh("process",this.parser||this.Parser),Ph("process",this.compiler||this.Compiler),s?l(void 0,s):new Promise(l);function l(d,c){const h=bd(n),m=i.parse(h);i.run(m,h,function(x,p,g){if(x||!p||!g)return f(x);const y=p,w=i.stringify(y,g);N3(w)?g.value=w:g.result=w,f(x,g)});function f(x,p){x||!p?c(x):d?d(p):s(void 0,p)}}}processSync(n){let s=!1,i;return this.freeze(),Hh("processSync",this.parser||this.Parser),Ph("processSync",this.compiler||this.Compiler),this.process(n,l),my("processSync","process",s),i;function l(d,c){s=!0,dy(d),i=c}}run(n,s,i){hy(n),this.freeze();const l=this.transformers;return!i&&typeof s=="function"&&(i=s,s=void 0),i?d(void 0,i):new Promise(d);function d(c,h){const m=bd(s);l.run(n,m,f);function f(x,p,g){const y=p||n;x?h(x):c?c(y):i(void 0,y,g)}}}runSync(n,s){let i=!1,l;return this.run(n,s,d),my("runSync","run",i),l;function d(c,h){dy(c),l=h,i=!0}}stringify(n,s){this.freeze();const i=bd(s),l=this.compiler||this.Compiler;return Ph("stringify",l),hy(n),l(n,i)}use(n,...s){const i=this.attachers,l=this.namespace;if(qh("use",this.frozen),n!=null)if(typeof n=="function")m(n,s);else if(typeof n=="object")Array.isArray(n)?h(n):c(n);else throw new TypeError("Expected usable value, not `"+n+"`");return this;function d(f){if(typeof f=="function")m(f,[]);else if(typeof f=="object")if(Array.isArray(f)){const[x,...p]=f;m(x,p)}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&&(l.settings=Ih(!0,l.settings,f.settings))}function h(f){let x=-1;if(f!=null)if(Array.isArray(f))for(;++x<f.length;){const p=f[x];d(p)}else throw new TypeError("Expected a list of plugins, not `"+f+"`")}function m(f,x){let p=-1,g=-1;for(;++p<i.length;)if(i[p][0]===f){g=p;break}if(g===-1)i.push([f,...x]);else if(x.length>0){let[y,...w]=x;const N=i[g][1];Am(N)&&Am(y)&&(y=Ih(!0,N,y)),i[g]=[f,y,...w]}}}}const j3=new wx().freeze();function Hh(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Ph(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function qh(e,n){if(n)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function hy(e){if(!Am(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function my(e,n,s){if(!s)throw new Error("`"+e+"` finished async. Use `"+n+"` instead")}function bd(e){return w3(e)?e:new hj(e)}function w3(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function N3(e){return typeof e=="string"||k3(e)}function k3(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const S3="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",xy=[],py={allowDangerousHtml:!0},C3=/^(https?|ircs?|mailto|xmpp)$/i,E3=[{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 gy(e){const n=T3(e),s=_3(e);return A3(n.runSync(n.parse(s),s),e)}function T3(e){const n=e.rehypePlugins||xy,s=e.remarkPlugins||xy,i=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...py}:py;return j3().use(cE).use(s).use(r3,i).use(n)}function _3(e){const n=e.children||"",s=new hj;return typeof n=="string"&&(s.value=n),s}function A3(e,n){const s=n.allowedElements,i=n.allowElement,l=n.components,d=n.disallowedElements,c=n.skipHtml,h=n.unwrapDisallowed,m=n.urlTransform||M3;for(const x of E3)Object.hasOwn(n,x.from)&&(""+x.from+(x.to?"use `"+x.to+"` instead":"remove it")+S3+x.id,void 0);return jx(e,f),Yk(e,{Fragment:t.Fragment,components:l,ignoreInvalidStyle:!0,jsx:t.jsx,jsxs:t.jsxs,passKeys:!0,passNode:!0});function f(x,p,g){if(x.type==="raw"&&g&&typeof p=="number")return c?g.children.splice(p,1):g.children[p]={type:"text",value:x.value},p;if(x.type==="element"){let y;for(y in Rh)if(Object.hasOwn(Rh,y)&&Object.hasOwn(x.properties,y)){const w=x.properties[y],N=Rh[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&&i&&typeof p=="number"&&(y=!i(x,p,g)),y&&g&&typeof p=="number")return h&&x.children?g.children.splice(p,1,...x.children):g.children.splice(p,1),p}}}function M3(e){const n=e.indexOf(":"),s=e.indexOf("?"),i=e.indexOf("#"),l=e.indexOf("/");return n===-1||l!==-1&&n>l||s!==-1&&n>s||i!==-1&&n>i||C3.test(e.slice(0,n))?e:""}function by(e,n){const s=String(e);if(typeof n!="string")throw new TypeError("Expected character");let i=0,l=s.indexOf(n);for(;l!==-1;)i++,l=s.indexOf(n,l+n.length);return i}function R3(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function O3(e,n,s){const l=ou((s||{}).ignore||[]),d=D3(n);let c=-1;for(;++c<d.length;)fj(e,"text",h);function h(f,x){let p=-1,g;for(;++p<x.length;){const y=x[p],w=g?g.children:void 0;if(l(y,w?w.indexOf(y):void 0,g))return;g=y}if(g)return m(f,x)}function m(f,x){const p=x[x.length-1],g=d[c][0],y=d[c][1];let w=0;const T=p.children.indexOf(f);let C=!1,_=[];g.lastIndex=0;let k=g.exec(f.value);for(;k;){const M=k.index,D={index:k.index,input:k.input,stack:[...x,f]};let A=y(...k,D);if(typeof A=="string"&&(A=A.length>0?{type:"text",value:A}:void 0),A===!1?g.lastIndex=M+1:(w!==M&&_.push({type:"text",value:f.value.slice(w,M)}),Array.isArray(A)?_.push(...A):A&&_.push(A),w=M+k[0].length,C=!0),!g.global)break;k=g.exec(f.value)}return C?(w<f.value.length&&_.push({type:"text",value:f.value.slice(w)}),p.children.splice(T,1,..._)):_=[f],T+_.length}}function D3(e){const n=[];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 i=-1;for(;++i<s.length;){const l=s[i];n.push([L3(l[0]),I3(l[1])])}return n}function L3(e){return typeof e=="string"?new RegExp(R3(e),"g"):e}function I3(e){return typeof e=="function"?e:function(){return e}}const Uh="phrasing",Vh=["autolink","link","image","label"];function z3(){return{transforms:[V3],enter:{literalAutolink:B3,literalAutolinkEmail:Fh,literalAutolinkHttp:Fh,literalAutolinkWww:Fh},exit:{literalAutolink:U3,literalAutolinkEmail:q3,literalAutolinkHttp:H3,literalAutolinkWww:P3}}}function $3(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Uh,notInConstruct:Vh},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Uh,notInConstruct:Vh},{character:":",before:"[ps]",after:"\\/",inConstruct:Uh,notInConstruct:Vh}]}}function B3(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Fh(e){this.config.enter.autolinkProtocol.call(this,e)}function H3(e){this.config.exit.autolinkProtocol.call(this,e)}function P3(e){this.config.exit.data.call(this,e);const n=this.stack[this.stack.length-1];n.type,n.url="http://"+this.sliceSerialize(e)}function q3(e){this.config.exit.autolinkEmail.call(this,e)}function U3(e){this.exit(e)}function V3(e){O3(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,F3],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),Y3]],{ignore:["link","linkReference"]})}function F3(e,n,s,i,l){let d="";if(!mj(l)||(/^w/i.test(n)&&(s=n+s,n="",d="http://"),!G3(s)))return!1;const c=X3(s+i);if(!c[0])return!1;const h={type:"link",title:null,url:d+n+c[0],children:[{type:"text",value:n+c[0]}]};return c[1]?[h,{type:"text",value:c[1]}]:h}function Y3(e,n,s,i){return!mj(i,!0)||/[-\d_]$/.test(s)?!1:{type:"link",title:null,url:"mailto:"+n+"@"+s,children:[{type:"text",value:n+"@"+s}]}}function G3(e){const n=e.split(".");return!(n.length<2||n[n.length-1]&&(/_/.test(n[n.length-1])||!/[a-zA-Z\d]/.test(n[n.length-1]))||n[n.length-2]&&(/_/.test(n[n.length-2])||!/[a-zA-Z\d]/.test(n[n.length-2])))}function X3(e){const n=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!n)return[e,void 0];e=e.slice(0,n.index);let s=n[0],i=s.indexOf(")");const l=by(e,"(");let d=by(e,")");for(;i!==-1&&l>d;)e+=s.slice(0,i+1),s=s.slice(i+1),i=s.indexOf(")"),d++;return[e,s]}function mj(e,n){const s=e.input.charCodeAt(e.index-1);return(e.index===0||wi(s)||au(s))&&(!n||s!==47)}xj.peek=rT;function K3(){this.buffer()}function W3(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function Q3(){this.buffer()}function Z3(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function J3(e){const n=this.resume(),s=this.stack[this.stack.length-1];s.type,s.identifier=vs(this.sliceSerialize(e)).toLowerCase(),s.label=n}function eT(e){this.exit(e)}function tT(e){const n=this.resume(),s=this.stack[this.stack.length-1];s.type,s.identifier=vs(this.sliceSerialize(e)).toLowerCase(),s.label=n}function nT(e){this.exit(e)}function rT(){return"["}function xj(e,n,s,i){const l=s.createTracker(i);let d=l.move("[^");const c=s.enter("footnoteReference"),h=s.enter("reference");return d+=l.move(s.safe(s.associationId(e),{after:"]",before:d})),h(),c(),d+=l.move("]"),d}function sT(){return{enter:{gfmFootnoteCallString:K3,gfmFootnoteCall:W3,gfmFootnoteDefinitionLabelString:Q3,gfmFootnoteDefinition:Z3},exit:{gfmFootnoteCallString:J3,gfmFootnoteCall:eT,gfmFootnoteDefinitionLabelString:tT,gfmFootnoteDefinition:nT}}}function aT(e){let n=!1;return e&&e.firstLineBlank&&(n=!0),{handlers:{footnoteDefinition:s,footnoteReference:xj},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function s(i,l,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(i),{before:m,after:"]"})),x(),m+=h.move("]:"),i.children&&i.children.length>0&&(h.shift(4),m+=h.move((n?`
|
|
24
|
-
`:" ")+d.indentLines(d.containerFlow(i,h.current()),n?pj:iT))),f(),m}}function iT(e,n,s){return n===0?e:pj(e,n,s)}function pj(e,n,s){return(s?"":" ")+e}const lT=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];gj.peek=fT;function oT(){return{canContainEols:["delete"],enter:{strikethrough:dT},exit:{strikethrough:uT}}}function cT(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:lT}],handlers:{delete:gj}}}function dT(e){this.enter({type:"delete",children:[]},e)}function uT(e){this.exit(e)}function gj(e,n,s,i){const l=s.createTracker(i),d=s.enter("strikethrough");let c=l.move("~~");return c+=s.containerPhrasing(e,{...l.current(),before:c,after:"~"}),c+=l.move("~~"),d(),c}function fT(){return"~"}function hT(e){return e.length}function mT(e,n){const s=n||{},i=(s.align||[]).concat(),l=s.stringLength||hT,d=[],c=[],h=[],m=[];let f=0,x=-1;for(;++x<e.length;){const N=[],T=[];let C=-1;for(e[x].length>f&&(f=e[x].length);++C<e[x].length;){const _=xT(e[x][C]);if(s.alignDelimiters!==!1){const k=l(_);T[C]=k,(m[C]===void 0||k>m[C])&&(m[C]=k)}N.push(_)}c[x]=N,h[x]=T}let p=-1;if(typeof i=="object"&&"length"in i)for(;++p<f;)d[p]=yy(i[p]);else{const N=yy(i);for(;++p<f;)d[p]=N}p=-1;const g=[],y=[];for(;++p<f;){const N=d[p];let T="",C="";N===99?(T=":",C=":"):N===108?T=":":N===114&&(C=":");let _=s.alignDelimiters===!1?1:Math.max(1,m[p]-T.length-C.length);const k=T+"-".repeat(_)+C;s.alignDelimiters!==!1&&(_=T.length+_+C.length,_>m[p]&&(m[p]=_),y[p]=_),g[p]=k}c.splice(1,0,g),h.splice(1,0,y),x=-1;const w=[];for(;++x<c.length;){const N=c[x],T=h[x];p=-1;const C=[];for(;++p<f;){const _=N[p]||"";let k="",M="";if(s.alignDelimiters!==!1){const D=m[p]-(T[p]||0),A=d[p];A===114?k=" ".repeat(D):A===99?D%2?(k=" ".repeat(D/2+.5),M=" ".repeat(D/2-.5)):(k=" ".repeat(D/2),M=k):M=" ".repeat(D)}s.delimiterStart!==!1&&!p&&C.push("|"),s.padding!==!1&&!(s.alignDelimiters===!1&&_==="")&&(s.delimiterStart!==!1||p)&&C.push(" "),s.alignDelimiters!==!1&&C.push(k),C.push(_),s.alignDelimiters!==!1&&C.push(M),s.padding!==!1&&C.push(" "),(s.delimiterEnd!==!1||p!==f-1)&&C.push("|")}w.push(s.delimiterEnd===!1?C.join("").replace(/ +$/,""):C.join(""))}return w.join(`
|
|
25
|
-
`)}function xT(e){return e==null?"":String(e)}function yy(e){const n=typeof e=="string"?e.codePointAt(0):0;return n===67||n===99?99:n===76||n===108?108:n===82||n===114?114:0}function pT(e,n,s,i){const l=s.enter("blockquote"),d=s.createTracker(i);d.move("> "),d.shift(2);const c=s.indentLines(s.containerFlow(e,d.current()),gT);return l(),c}function gT(e,n,s){return">"+(s?"":" ")+e}function bT(e,n){return vy(e,n.inConstruct,!0)&&!vy(e,n.notInConstruct,!1)}function vy(e,n,s){if(typeof n=="string"&&(n=[n]),!n||n.length===0)return s;let i=-1;for(;++i<n.length;)if(e.includes(n[i]))return!0;return!1}function jy(e,n,s,i){let l=-1;for(;++l<s.unsafe.length;)if(s.unsafe[l].character===`
|
|
26
|
-
`&&bT(s.stack,s.unsafe[l]))return/[ \t]/.test(i.before)?"":" ";return`\\
|
|
27
|
-
`}function yT(e,n){const s=String(e);let i=s.indexOf(n),l=i,d=0,c=0;if(typeof n!="string")throw new TypeError("Expected substring");for(;i!==-1;)i===l?++d>c&&(c=d):d=1,l=i+n.length,i=s.indexOf(n,l);return c}function vT(e,n){return!!(n.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function jT(e){const n=e.options.fence||"`";if(n!=="`"&&n!=="~")throw new Error("Cannot serialize code with `"+n+"` for `options.fence`, expected `` ` `` or `~`");return n}function wT(e,n,s,i){const l=jT(s),d=e.value||"",c=l==="`"?"GraveAccent":"Tilde";if(vT(e,s)){const p=s.enter("codeIndented"),g=s.indentLines(d,NT);return p(),g}const h=s.createTracker(i),m=l.repeat(Math.max(yT(d,l)+1,3)),f=s.enter("codeFenced");let x=h.move(m);if(e.lang){const p=s.enter(`codeFencedLang${c}`);x+=h.move(s.safe(e.lang,{before:x,after:" ",encode:["`"],...h.current()})),p()}if(e.lang&&e.meta){const p=s.enter(`codeFencedMeta${c}`);x+=h.move(" "),x+=h.move(s.safe(e.meta,{before:x,after:`
|
|
28
|
-
`,encode:["`"],...h.current()})),p()}return x+=h.move(`
|
|
29
|
-
`),d&&(x+=h.move(d+`
|
|
30
|
-
`)),x+=h.move(m),f(),x}function NT(e,n,s){return(s?"":" ")+e}function Nx(e){const n=e.options.quote||'"';if(n!=='"'&&n!=="'")throw new Error("Cannot serialize title with `"+n+"` for `options.quote`, expected `\"`, or `'`");return n}function kT(e,n,s,i){const l=Nx(s),d=l==='"'?"Quote":"Apostrophe",c=s.enter("definition");let h=s.enter("label");const m=s.createTracker(i);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(" "+l),f+=m.move(s.safe(e.title,{before:f,after:l,...m.current()})),f+=m.move(l),h()),c(),f}function ST(e){const n=e.options.emphasis||"*";if(n!=="*"&&n!=="_")throw new Error("Cannot serialize emphasis with `"+n+"` for `options.emphasis`, expected `*`, or `_`");return n}function Po(e){return"&#x"+e.toString(16).toUpperCase()+";"}function qd(e,n,s){const i=yl(e),l=yl(n);return i===void 0?l===void 0?s==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:l===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:i===1?l===void 0?{inside:!1,outside:!1}:l===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:l===void 0?{inside:!1,outside:!1}:l===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}bj.peek=CT;function bj(e,n,s,i){const l=ST(s),d=s.enter("emphasis"),c=s.createTracker(i),h=c.move(l);let m=c.move(s.containerPhrasing(e,{after:l,before:h,...c.current()}));const f=m.charCodeAt(0),x=qd(i.before.charCodeAt(i.before.length-1),f,l);x.inside&&(m=Po(f)+m.slice(1));const p=m.charCodeAt(m.length-1),g=qd(i.after.charCodeAt(0),p,l);g.inside&&(m=m.slice(0,-1)+Po(p));const y=c.move(l);return d(),s.attentionEncodeSurroundingInfo={after:g.outside,before:x.outside},h+m+y}function CT(e,n,s){return s.options.emphasis||"*"}function ET(e,n){let s=!1;return jx(e,function(i){if("value"in i&&/\r?\n|\r/.test(i.value)||i.type==="break")return s=!0,Tm}),!!((!e.depth||e.depth<3)&&mx(e)&&(n.options.setext||s))}function TT(e,n,s,i){const l=Math.max(Math.min(6,e.depth||1),1),d=s.createTracker(i);if(ET(e,s)){const x=s.enter("headingSetext"),p=s.enter("phrasing"),g=s.containerPhrasing(e,{...d.current(),before:`
|
|
32
|
-
`,after:`
|
|
33
|
-
`});return p(),x(),g+`
|
|
34
|
-
`+(l===1?"=":"-").repeat(g.length-(Math.max(g.lastIndexOf("\r"),g.lastIndexOf(`
|
|
35
|
-
`))+1))}const c="#".repeat(l),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=Po(f.charCodeAt(0))+f.slice(1)),f=f?c+" "+f:c,s.options.closeAtx&&(f+=" "+c),m(),h(),f}yj.peek=_T;function yj(e){return e.value||""}function _T(){return"<"}vj.peek=AT;function vj(e,n,s,i){const l=Nx(s),d=l==='"'?"Quote":"Apostrophe",c=s.enter("image");let h=s.enter("label");const m=s.createTracker(i);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(" "+l),f+=m.move(s.safe(e.title,{before:f,after:l,...m.current()})),f+=m.move(l),h()),f+=m.move(")"),c(),f}function AT(){return"!"}jj.peek=MT;function jj(e,n,s,i){const l=e.referenceType,d=s.enter("imageReference");let c=s.enter("label");const h=s.createTracker(i);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 p=s.safe(s.associationId(e),{before:m,after:"]",...h.current()});return c(),s.stack=x,d(),l==="full"||!f||f!==p?m+=h.move(p+"]"):l==="shortcut"?m=m.slice(0,-1):m+=h.move("]"),m}function MT(){return"!"}wj.peek=RT;function wj(e,n,s){let i=e.value||"",l="`",d=-1;for(;new RegExp("(^|[^`])"+l+"([^`]|$)").test(i);)l+="`";for(/[^ \r\n]/.test(i)&&(/^[ \r\n]/.test(i)&&/[ \r\n]$/.test(i)||/^`|`$/.test(i))&&(i=" "+i+" ");++d<s.unsafe.length;){const c=s.unsafe[d],h=s.compilePattern(c);let m;if(c.atBreak)for(;m=h.exec(i);){let f=m.index;i.charCodeAt(f)===10&&i.charCodeAt(f-1)===13&&f--,i=i.slice(0,f)+" "+i.slice(m.index+1)}}return l+i+l}function RT(){return"`"}function Nj(e,n){const s=mx(e);return!!(!n.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))}kj.peek=OT;function kj(e,n,s,i){const l=Nx(s),d=l==='"'?"Quote":"Apostrophe",c=s.createTracker(i);let h,m;if(Nj(e,s)){const x=s.stack;s.stack=[],h=s.enter("autolink");let p=c.move("<");return p+=c.move(s.containerPhrasing(e,{before:p,after:">",...c.current()})),p+=c.move(">"),h(),s.stack=x,p}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(" "+l),f+=c.move(s.safe(e.title,{before:f,after:l,...c.current()})),f+=c.move(l),m()),f+=c.move(")"),h(),f}function OT(e,n,s){return Nj(e,s)?"<":"["}Sj.peek=DT;function Sj(e,n,s,i){const l=e.referenceType,d=s.enter("linkReference");let c=s.enter("label");const h=s.createTracker(i);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 p=s.safe(s.associationId(e),{before:m,after:"]",...h.current()});return c(),s.stack=x,d(),l==="full"||!f||f!==p?m+=h.move(p+"]"):l==="shortcut"?m=m.slice(0,-1):m+=h.move("]"),m}function DT(){return"["}function kx(e){const n=e.options.bullet||"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bullet`, expected `*`, `+`, or `-`");return n}function LT(e){const n=kx(e),s=e.options.bulletOther;if(!s)return n==="*"?"-":"*";if(s!=="*"&&s!=="+"&&s!=="-")throw new Error("Cannot serialize items with `"+s+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(s===n)throw new Error("Expected `bullet` (`"+n+"`) and `bulletOther` (`"+s+"`) to be different");return s}function IT(e){const n=e.options.bulletOrdered||".";if(n!=="."&&n!==")")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOrdered`, expected `.` or `)`");return n}function Cj(e){const n=e.options.rule||"*";if(n!=="*"&&n!=="-"&&n!=="_")throw new Error("Cannot serialize rules with `"+n+"` for `options.rule`, expected `*`, `-`, or `_`");return n}function zT(e,n,s,i){const l=s.enter("list"),d=s.bulletCurrent;let c=e.ordered?IT(s):kx(s);const h=e.ordered?c==="."?")":".":LT(s);let m=n&&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),Cj(s)===c&&x){let p=-1;for(;++p<e.children.length;){const g=e.children[p];if(g&&g.type==="listItem"&&g.children&&g.children[0]&&g.children[0].type==="thematicBreak"){m=!0;break}}}}m&&(c=h),s.bulletCurrent=c;const f=s.containerFlow(e,i);return s.bulletLastUsed=c,s.bulletCurrent=d,l(),f}function $T(e){const n=e.options.listItemIndent||"one";if(n!=="tab"&&n!=="one"&&n!=="mixed")throw new Error("Cannot serialize items with `"+n+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return n}function BT(e,n,s,i){const l=$T(s);let d=s.bulletCurrent||kx(s);n&&n.type==="list"&&n.ordered&&(d=(typeof n.start=="number"&&n.start>-1?n.start:1)+(s.options.incrementListMarker===!1?0:n.children.indexOf(e))+d);let c=d.length+1;(l==="tab"||l==="mixed"&&(n&&n.type==="list"&&n.spread||e.spread))&&(c=Math.ceil(c/4)*4);const h=s.createTracker(i);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(p,g,y){return g?(y?"":" ".repeat(c))+p:(y?d:d+" ".repeat(c-d.length))+p}}function HT(e,n,s,i){const l=s.enter("paragraph"),d=s.enter("phrasing"),c=s.containerPhrasing(e,i);return d(),l(),c}const PT=ou(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function qT(e,n,s,i){return(e.children.some(function(c){return PT(c)})?s.containerPhrasing:s.containerFlow).call(s,e,i)}function UT(e){const n=e.options.strong||"*";if(n!=="*"&&n!=="_")throw new Error("Cannot serialize strong with `"+n+"` for `options.strong`, expected `*`, or `_`");return n}Ej.peek=VT;function Ej(e,n,s,i){const l=UT(s),d=s.enter("strong"),c=s.createTracker(i),h=c.move(l+l);let m=c.move(s.containerPhrasing(e,{after:l,before:h,...c.current()}));const f=m.charCodeAt(0),x=qd(i.before.charCodeAt(i.before.length-1),f,l);x.inside&&(m=Po(f)+m.slice(1));const p=m.charCodeAt(m.length-1),g=qd(i.after.charCodeAt(0),p,l);g.inside&&(m=m.slice(0,-1)+Po(p));const y=c.move(l+l);return d(),s.attentionEncodeSurroundingInfo={after:g.outside,before:x.outside},h+m+y}function VT(e,n,s){return s.options.strong||"*"}function FT(e,n,s,i){return s.safe(e.value,i)}function YT(e){const n=e.options.ruleRepetition||3;if(n<3)throw new Error("Cannot serialize rules with repetition `"+n+"` for `options.ruleRepetition`, expected `3` or more");return n}function GT(e,n,s){const i=(Cj(s)+(s.options.ruleSpaces?" ":"")).repeat(YT(s));return s.options.ruleSpaces?i.slice(0,-1):i}const Tj={blockquote:pT,break:jy,code:wT,definition:kT,emphasis:bj,hardBreak:jy,heading:TT,html:yj,image:vj,imageReference:jj,inlineCode:wj,link:kj,linkReference:Sj,list:zT,listItem:BT,paragraph:HT,root:qT,strong:Ej,text:FT,thematicBreak:GT};function XT(){return{enter:{table:KT,tableData:wy,tableHeader:wy,tableRow:QT},exit:{codeText:ZT,table:WT,tableData:Yh,tableHeader:Yh,tableRow:Yh}}}function KT(e){const n=e._align;this.enter({type:"table",align:n.map(function(s){return s==="none"?null:s}),children:[]},e),this.data.inTable=!0}function WT(e){this.exit(e),this.data.inTable=void 0}function QT(e){this.enter({type:"tableRow",children:[]},e)}function Yh(e){this.exit(e)}function wy(e){this.enter({type:"tableCell",children:[]},e)}function ZT(e){let n=this.resume();this.data.inTable&&(n=n.replace(/\\([\\|])/g,JT));const s=this.stack[this.stack.length-1];s.type,s.value=n,this.exit(e)}function JT(e,n){return n==="|"?n:e}function e4(e){const n=e||{},s=n.tableCellPadding,i=n.tablePipeAlign,l=n.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:g,table:c,tableCell:m,tableRow:h}};function c(y,w,N,T){return f(x(y,N,T),y.align)}function h(y,w,N,T){const C=p(y,N,T),_=f([C]);return _.slice(0,_.indexOf(`
|
|
38
|
-
`))}function m(y,w,N,T){const C=N.enter("tableCell"),_=N.enter("phrasing"),k=N.containerPhrasing(y,{...T,before:d,after:d});return _(),C(),k}function f(y,w){return mT(y,{align:w,alignDelimiters:i,padding:s,stringLength:l})}function x(y,w,N){const T=y.children;let C=-1;const _=[],k=w.enter("table");for(;++C<T.length;)_[C]=p(T[C],w,N);return k(),_}function p(y,w,N){const T=y.children;let C=-1;const _=[],k=w.enter("tableRow");for(;++C<T.length;)_[C]=m(T[C],y,w,N);return k(),_}function g(y,w,N){let T=Tj.inlineCode(y,w,N);return N.stack.includes("tableCell")&&(T=T.replace(/\|/g,"\\$&")),T}}function t4(){return{exit:{taskListCheckValueChecked:Ny,taskListCheckValueUnchecked:Ny,paragraph:r4}}}function n4(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:s4}}}function Ny(e){const n=this.stack[this.stack.length-2];n.type,n.checked=e.type==="taskListCheckValueChecked"}function r4(e){const n=this.stack[this.stack.length-2];if(n&&n.type==="listItem"&&typeof n.checked=="boolean"){const s=this.stack[this.stack.length-1];s.type;const i=s.children[0];if(i&&i.type==="text"){const l=n.children;let d=-1,c;for(;++d<l.length;){const h=l[d];if(h.type==="paragraph"){c=h;break}}c===s&&(i.value=i.value.slice(1),i.value.length===0?s.children.shift():s.position&&i.position&&typeof i.position.start.offset=="number"&&(i.position.start.column++,i.position.start.offset++,s.position.start=Object.assign({},i.position.start)))}}this.exit(e)}function s4(e,n,s,i){const l=e.children[0],d=typeof e.checked=="boolean"&&l&&l.type==="paragraph",c="["+(e.checked?"x":" ")+"] ",h=s.createTracker(i);d&&h.move(c);let m=Tj.listItem(e,n,s,{...i,...h.current()});return d&&(m=m.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,f)),m;function f(x){return x+c}}function a4(){return[z3(),sT(),oT(),XT(),t4()]}function i4(e){return{extensions:[$3(),aT(e),cT(),e4(e),n4()]}}const l4={tokenize:h4,partial:!0},_j={tokenize:m4,partial:!0},Aj={tokenize:x4,partial:!0},Mj={tokenize:p4,partial:!0},o4={tokenize:g4,partial:!0},Rj={name:"wwwAutolink",tokenize:u4,previous:Dj},Oj={name:"protocolAutolink",tokenize:f4,previous:Lj},ua={name:"emailAutolink",tokenize:d4,previous:Ij},Is={};function c4(){return{text:Is}}let fi=48;for(;fi<123;)Is[fi]=ua,fi++,fi===58?fi=65:fi===91&&(fi=97);Is[43]=ua;Is[45]=ua;Is[46]=ua;Is[95]=ua;Is[72]=[ua,Oj];Is[104]=[ua,Oj];Is[87]=[ua,Rj];Is[119]=[ua,Rj];function d4(e,n,s){const i=this;let l,d;return c;function c(p){return!Rm(p)||!Ij.call(i,i.previous)||Sx(i.events)?s(p):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),h(p))}function h(p){return Rm(p)?(e.consume(p),h):p===64?(e.consume(p),m):s(p)}function m(p){return p===46?e.check(o4,x,f)(p):p===45||p===95||gr(p)?(d=!0,e.consume(p),m):x(p)}function f(p){return e.consume(p),l=!0,m}function x(p){return d&&l&&wr(i.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),n(p)):s(p)}}function u4(e,n,s){const i=this;return l;function l(c){return c!==87&&c!==119||!Dj.call(i,i.previous)||Sx(i.events)?s(c):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(l4,e.attempt(_j,e.attempt(Aj,d),s),s)(c))}function d(c){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),n(c)}}function f4(e,n,s){const i=this;let l="",d=!1;return c;function c(p){return(p===72||p===104)&&Lj.call(i,i.previous)&&!Sx(i.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),l+=String.fromCodePoint(p),e.consume(p),h):s(p)}function h(p){if(wr(p)&&l.length<5)return l+=String.fromCodePoint(p),e.consume(p),h;if(p===58){const g=l.toLowerCase();if(g==="http"||g==="https")return e.consume(p),m}return s(p)}function m(p){return p===47?(e.consume(p),d?f:(d=!0,m)):s(p)}function f(p){return p===null||Bd(p)||Sn(p)||wi(p)||au(p)?s(p):e.attempt(_j,e.attempt(Aj,x),s)(p)}function x(p){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),n(p)}}function h4(e,n,s){let i=0;return l;function l(c){return(c===87||c===119)&&i<3?(i++,e.consume(c),l):c===46&&i===3?(e.consume(c),d):s(c)}function d(c){return c===null?s(c):n(c)}}function m4(e,n,s){let i,l,d;return c;function c(f){return f===46||f===95?e.check(Mj,m,h)(f):f===null||Sn(f)||wi(f)||f!==45&&au(f)?m(f):(d=!0,e.consume(f),c)}function h(f){return f===95?i=!0:(l=i,i=void 0),e.consume(f),c}function m(f){return l||i||!d?s(f):n(f)}}function x4(e,n){let s=0,i=0;return l;function l(c){return c===40?(s++,e.consume(c),l):c===41&&i<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(Mj,n,d)(c):c===null||Sn(c)||wi(c)?n(c):(e.consume(c),l)}function d(c){return c===41&&i++,e.consume(c),l}}function p4(e,n,s){return i;function i(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),i):h===38?(e.consume(h),d):h===93?(e.consume(h),l):h===60||h===null||Sn(h)||wi(h)?n(h):s(h)}function l(h){return h===null||h===40||h===91||Sn(h)||wi(h)?n(h):i(h)}function d(h){return wr(h)?c(h):s(h)}function c(h){return h===59?(e.consume(h),i):wr(h)?(e.consume(h),c):s(h)}}function g4(e,n,s){return i;function i(d){return e.consume(d),l}function l(d){return gr(d)?s(d):n(d)}}function Dj(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Sn(e)}function Lj(e){return!wr(e)}function Ij(e){return!(e===47||Rm(e))}function Rm(e){return e===43||e===45||e===46||e===95||gr(e)}function Sx(e){let n=e.length,s=!1;for(;n--;){const i=e[n][1];if((i.type==="labelLink"||i.type==="labelImage")&&!i._balanced){s=!0;break}if(i._gfmAutolinkLiteralWalkedInto){s=!1;break}}return e.length>0&&!s&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),s}const b4={tokenize:C4,partial:!0};function y4(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:N4,continuation:{tokenize:k4},exit:S4}},text:{91:{name:"gfmFootnoteCall",tokenize:w4},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:v4,resolveTo:j4}}}}function v4(e,n,s){const i=this;let l=i.events.length;const d=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let c;for(;l--;){const m=i.events[l][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=vs(i.sliceSerialize({start:c.end,end:i.now()}));return f.codePointAt(0)!==94||!d.includes(f.slice(1))?s(m):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),n(m))}}function j4(e,n){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 i={type:"gfmFootnoteCall",start:Object.assign({},e[s+3][1].start),end:Object.assign({},e[e.length-1][1].end)},l={type:"gfmFootnoteCallMarker",start:Object.assign({},e[s+3][1].end),end:Object.assign({},e[s+3][1].end)};l.end.column++,l.end.offset++,l.end._bufferIndex++;const d={type:"gfmFootnoteCallString",start:Object.assign({},l.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",i,n],e[s+3],e[s+4],["enter",l,n],["exit",l,n],["enter",d,n],["enter",c,n],["exit",c,n],["exit",d,n],e[e.length-2],e[e.length-1],["exit",i,n]];return e.splice(s,e.length-s+1,...h),e}function w4(e,n,s){const i=this,l=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let d=0,c;return h;function h(p){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),m}function m(p){return p!==94?s(p):(e.enter("gfmFootnoteCallMarker"),e.consume(p),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",f)}function f(p){if(d>999||p===93&&!c||p===null||p===91||Sn(p))return s(p);if(p===93){e.exit("chunkString");const g=e.exit("gfmFootnoteCallString");return l.includes(vs(i.sliceSerialize(g)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),n):s(p)}return Sn(p)||(c=!0),d++,e.consume(p),p===92?x:f}function x(p){return p===91||p===92||p===93?(e.consume(p),d++,f):f(p)}}function N4(e,n,s){const i=this,l=i.parser.gfmFootnotes||(i.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||Sn(w))return s(w);if(w===93){e.exit("chunkString");const N=e.exit("gfmFootnoteDefinitionLabelString");return d=vs(i.sliceSerialize(N)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),g}return Sn(w)||(h=!0),c++,e.consume(w),w===92?p:x}function p(w){return w===91||w===92||w===93?(e.consume(w),c++,x):x(w)}function g(w){return w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),l.includes(d)||l.push(d),en(e,y,"gfmFootnoteDefinitionWhitespace")):s(w)}function y(w){return n(w)}}function k4(e,n,s){return e.check(nc,n,e.attempt(b4,n,s))}function S4(e){e.exit("gfmFootnoteDefinition")}function C4(e,n,s){const i=this;return en(e,l,"gfmFootnoteDefinitionIndent",5);function l(d){const c=i.events[i.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?n(d):s(d)}}function E4(e){let s=(e||{}).singleTilde;const i={name:"strikethrough",tokenize:d,resolveAll:l};return s==null&&(s=!0),{text:{126:i},insideSpan:{null:[i]},attentionMarkers:{null:[126]}};function l(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)},p={type:"strikethroughText",start:Object.assign({},c[f][1].end),end:Object.assign({},c[m][1].start)},g=[["enter",x,h],["enter",c[f][1],h],["exit",c[f][1],h],["enter",p,h]],y=h.parser.constructs.insideSpan.null;y&&Jr(g,g.length,0,iu(y,c.slice(f+1,m),h)),Jr(g,g.length,0,[["exit",p,h],["enter",c[m][1],h],["exit",c[m][1],h],["exit",x,h]]),Jr(c,f-1,m-f+3,g),m=f+g.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 p=0;return g;function g(w){return f===126&&x[x.length-1][1].type!=="characterEscape"?m(w):(c.enter("strikethroughSequenceTemporary"),y(w))}function y(w){const N=yl(f);if(w===126)return p>1?m(w):(c.consume(w),p++,y);if(p<2&&!s)return m(w);const T=c.exit("strikethroughSequenceTemporary"),C=yl(w);return T._open=!C||C===2&&!!N,T._close=!N||N===2&&!!C,h(w)}}}class T4{constructor(){this.map=[]}add(n,s,i){_4(this,n,s,i)}consume(n){if(this.map.sort(function(d,c){return d[0]-c[0]}),this.map.length===0)return;let s=this.map.length;const i=[];for(;s>0;)s-=1,i.push(n.slice(this.map[s][0]+this.map[s][1]),this.map[s][2]),n.length=this.map[s][0];i.push(n.slice()),n.length=0;let l=i.pop();for(;l;){for(const d of l)n.push(d);l=i.pop()}this.map.length=0}}function _4(e,n,s,i){let l=0;if(!(s===0&&i.length===0)){for(;l<e.map.length;){if(e.map[l][0]===n){e.map[l][1]+=s,e.map[l][2].push(...i);return}l+=1}e.map.push([n,s,i])}}function A4(e,n){let s=!1;const i=[];for(;n<e.length;){const l=e[n];if(s){if(l[0]==="enter")l[1].type==="tableContent"&&i.push(e[n+1][1].type==="tableDelimiterMarker"?"left":"none");else if(l[1].type==="tableContent"){if(e[n-1][1].type==="tableDelimiterMarker"){const d=i.length-1;i[d]=i[d]==="left"?"center":"right"}}else if(l[1].type==="tableDelimiterRow")break}else l[0]==="enter"&&l[1].type==="tableDelimiterRow"&&(s=!0);n+=1}return i}function M4(){return{flow:{null:{name:"table",tokenize:R4,resolveAll:O4}}}}function R4(e,n,s){const i=this;let l=0,d=0,c;return h;function h($){let q=i.events.length-1;for(;q>-1;){const E=i.events[q][1].type;if(E==="lineEnding"||E==="linePrefix")q--;else break}const U=q>-1?i.events[q][1].type:null,z=U==="tableHead"||U==="tableRow"?A:m;return z===A&&i.parser.lazy[i.now().line]?s($):z($)}function m($){return e.enter("tableHead"),e.enter("tableRow"),f($)}function f($){return $===124||(c=!0,d+=1),x($)}function x($){return $===null?s($):St($)?d>1?(d=0,i.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume($),e.exit("lineEnding"),y):s($):Ft($)?en(e,x,"whitespace")($):(d+=1,c&&(c=!1,l+=1),$===124?(e.enter("tableCellDivider"),e.consume($),e.exit("tableCellDivider"),c=!0,x):(e.enter("data"),p($)))}function p($){return $===null||$===124||Sn($)?(e.exit("data"),x($)):(e.consume($),$===92?g:p)}function g($){return $===92||$===124?(e.consume($),p):p($)}function y($){return i.interrupt=!1,i.parser.lazy[i.now().line]?s($):(e.enter("tableDelimiterRow"),c=!1,Ft($)?en(e,w,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)($):w($))}function w($){return $===45||$===58?T($):$===124?(c=!0,e.enter("tableCellDivider"),e.consume($),e.exit("tableCellDivider"),N):D($)}function N($){return Ft($)?en(e,T,"whitespace")($):T($)}function T($){return $===58?(d+=1,c=!0,e.enter("tableDelimiterMarker"),e.consume($),e.exit("tableDelimiterMarker"),C):$===45?(d+=1,C($)):$===null||St($)?M($):D($)}function C($){return $===45?(e.enter("tableDelimiterFiller"),_($)):D($)}function _($){return $===45?(e.consume($),_):$===58?(c=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume($),e.exit("tableDelimiterMarker"),k):(e.exit("tableDelimiterFiller"),k($))}function k($){return Ft($)?en(e,M,"whitespace")($):M($)}function M($){return $===124?w($):$===null||St($)?!c||l!==d?D($):(e.exit("tableDelimiterRow"),e.exit("tableHead"),n($)):D($)}function D($){return s($)}function A($){return e.enter("tableRow"),G($)}function G($){return $===124?(e.enter("tableCellDivider"),e.consume($),e.exit("tableCellDivider"),G):$===null||St($)?(e.exit("tableRow"),n($)):Ft($)?en(e,G,"whitespace")($):(e.enter("data"),X($))}function X($){return $===null||$===124||Sn($)?(e.exit("data"),G($)):(e.consume($),$===92?K:X)}function K($){return $===92||$===124?(e.consume($),X):X($)}}function O4(e,n){let s=-1,i=!0,l=0,d=[0,0,0,0],c=[0,0,0,0],h=!1,m=0,f,x,p;const g=new T4;for(;++s<e.length;){const y=e[s],w=y[1];y[0]==="enter"?w.type==="tableHead"?(h=!1,m!==0&&(ky(g,n,m,f,x),x=void 0,m=0),f={type:"table",start:Object.assign({},w.start),end:Object.assign({},w.end)},g.add(s,0,[["enter",f,n]])):w.type==="tableRow"||w.type==="tableDelimiterRow"?(i=!0,p=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)},g.add(s,0,[["enter",x,n]])),l=w.type==="tableDelimiterRow"?2:x?3:1):l&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")?(i=!1,c[2]===0&&(d[1]!==0&&(c[0]=c[1],p=yd(g,n,d,l,void 0,p),d=[0,0,0,0]),c[2]=s)):w.type==="tableCellDivider"&&(i?i=!1:(d[1]!==0&&(c[0]=c[1],p=yd(g,n,d,l,void 0,p)),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],p=yd(g,n,d,l,s,p)):c[1]!==0&&(p=yd(g,n,c,l,s,p)),l=0):l&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")&&(c[3]=s)}for(m!==0&&ky(g,n,m,f,x),g.consume(n.events),s=-1;++s<n.events.length;){const y=n.events[s];y[0]==="enter"&&y[1].type==="table"&&(y[1]._align=A4(n.events,s))}return e}function yd(e,n,s,i,l,d){const c=i===1?"tableHeader":i===2?"tableDelimiter":"tableData",h="tableContent";s[0]!==0&&(d.end=Object.assign({},ul(n.events,s[0])),e.add(s[0],0,[["exit",d,n]]));const m=ul(n.events,s[1]);if(d={type:c,start:Object.assign({},m),end:Object.assign({},m)},e.add(s[1],0,[["enter",d,n]]),s[2]!==0){const f=ul(n.events,s[2]),x=ul(n.events,s[3]),p={type:h,start:Object.assign({},f),end:Object.assign({},x)};if(e.add(s[2],0,[["enter",p,n]]),i!==2){const g=n.events[s[2]],y=n.events[s[3]];if(g[1].end=Object.assign({},y[1].end),g[1].type="chunkText",g[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",p,n]])}return l!==void 0&&(d.end=Object.assign({},ul(n.events,l)),e.add(l,0,[["exit",d,n]]),d=void 0),d}function ky(e,n,s,i,l){const d=[],c=ul(n.events,s);l&&(l.end=Object.assign({},c),d.push(["exit",l,n])),i.end=Object.assign({},c),d.push(["exit",i,n]),e.add(s+1,0,d)}function ul(e,n){const s=e[n],i=s[0]==="enter"?"start":"end";return s[1][i]}const D4={name:"tasklistCheck",tokenize:I4};function L4(){return{text:{91:D4}}}function I4(e,n,s){const i=this;return l;function l(m){return i.previous!==null||!i._gfmTasklistFirstContentOfListItem?s(m):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(m),e.exit("taskListCheckMarker"),d)}function d(m){return Sn(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 St(m)?n(m):Ft(m)?e.check({tokenize:z4},n,s)(m):s(m)}}function z4(e,n,s){return en(e,i,"whitespace");function i(l){return l===null?s(l):n(l)}}function $4(e){return G1([c4(),y4(),E4(e),M4(),L4()])}const B4={};function Sy(e){const n=this,s=e||B4,i=n.data(),l=i.micromarkExtensions||(i.micromarkExtensions=[]),d=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),c=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);l.push($4(s)),d.push(a4()),c.push(i4(s))}const H4=/<think>([\s\S]*?)(<\/think>|$)/g;function P4(e){const n=[];let s=e.replace(H4,(i,l)=>{const d=l.trim();return d&&n.push(d),""});return s=s.replace(/<\/think>/g,"").replace(/<think>/g,""),{thinking:n,rest:s.trim()}}const Om="#mention:";function q4(e){return e.replace(/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu,(n,s,i)=>{const l=s??i;return`[@${l}](${Om}${encodeURIComponent(l)})`})}const Gh={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:n})=>n?.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:n})=>t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500 underline break-all",children:n}),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 ir({content:e,className:n="",onMentionClick:s}){const{thinking:i,rest:l}=P4(e),d=v.useMemo(()=>s?q4(l):l,[l,s]),c=v.useMemo(()=>s?{...Gh,a:({href:h,children:m})=>{if(h?.startsWith(Om)){const f=decodeURIComponent(h.slice(Om.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})}}:Gh,[s]);return t.jsxs("div",{className:`prose prose-sm max-w-none break-words ${n}`,children:[i.length>0&&(()=>{const h=i.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:"Thinking"}),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(gy,{remarkPlugins:[Sy],components:Gh,children:h})})})]})})(),t.jsx(gy,{remarkPlugins:[Sy],components:c,children:d})]})}const Cy={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 Ni(e){const n=e.includes("__")?e.split("__").pop():e;return Cy[n]??Cy[e]??{label:n.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase()),icon:"⚙"}}function Cx(e){return e==null?"":e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function U4(e){const n=new Date(e);if(isNaN(n.getTime()))return e;const s=String(n.getMonth()+1).padStart(2,"0"),i=String(n.getDate()).padStart(2,"0"),l=String(n.getHours()).padStart(2,"0"),d=String(n.getMinutes()).padStart(2,"0"),c=String(n.getSeconds()).padStart(2,"0");return`${s}-${i} ${l}:${d}:${c}`}function Dm(e,n){return e.length<=n?e:e.slice(0,n)+"…"}function Ey(e){try{const n=JSON.parse(e);return JSON.stringify(n,null,2)}catch{return e}}function V4(e){return!e||typeof e!="object"?[]:Object.entries(e).filter(([,s])=>s!=null).map(([s,i])=>({key:s,value:typeof i=="string"?i:JSON.stringify(i,null,2)}))}function F4(e){if(e.tool!=="shell_execute"||!e.args||typeof e.args!="object")return null;const n=e.args.command;return typeof n=="string"?n:null}function Ty(e,n){const s=new Map;let i=null;for(const l of e)if(l.type==="tool_start"&&(l.content==="spawn_subagent"||l.content==="spawn_subagents"))i=l.seq,s.set(l.seq,[]);else if(l.type==="tool_end"&&(l.content==="spawn_subagent"||l.content==="spawn_subagents")){if(i!==null){const d=s.get(i);d&&s.set(l.seq,d)}i=null}else if(i!==null&&l.type.startsWith("subagent_")){const d=l.type.replace("subagent_",""),c=l.metadata;s.get(i)?.push({eventType:d,content:l.content,metadata:c})}return n.map(l=>{if(l.type!=="tool")return l;const d=l.key;if(!d)return l;const c=d.replace(/^t[se]_/,""),h=parseInt(c,10);if(isNaN(h))return l;const m=s.get(h);return!m||m.length===0?l:{...l,info:{...l.info,subagentLogs:m}}})}function qo(e){const n=new Set;for(let s=0;s<e.length;s++){const i=e[s];if(i.type==="tool"&&(i.info.status==="done"||i.info.status==="error"))for(let l=s-1;l>=0;l--){const d=e[l];if(d.type==="tool"&&d.info.status==="running"&&d.info.tool===i.info.tool&&!n.has(l)){n.add(l);break}}}return e.filter((s,i)=>!n.has(i))}function Uo(e){const n=U4(e.createdAt),s=e.createdAt,i=e.metadata;switch(e.type){case"text":return i?.isThinking?{type:"thinking",content:e.content,time:n,timestamp:s}:{type:"text",content:e.content,time:n,timestamp:s};case"status":{const l=i?.action;return l&&["chat","chat_stream","task_execution","respond_in_session"].includes(l)?null:{type:"status",content:e.content,time:n,timestamp:s}}case"error":return{type:"error",content:e.content,time:n,timestamp:s};case"tool_start":return{type:"tool",time:n,timestamp:s,key:`es_${e.seq}`,info:{tool:e.content,status:"running",args:i?.arguments}};case"tool_end":return{type:"tool",time:n,timestamp:s,key:`ee_${e.seq}`,info:{tool:e.content,status:i?.success===!1?"error":"done",args:i?.arguments,result:i?.result,error:i?.error,durationMs:i?.durationMs,subagentLogs:i?.subagentLogs}};default:return null}}function zj(e,n){if(e!=="task_create"&&e!=="create_task"||!n)return null;try{const s=JSON.parse(n);if(!s.task)return null;const i=s.task;return{taskId:i.id,title:i.title,description:i.description,assignedAgentId:i.assignedAgentId,priority:i.priority}}catch{return null}}function $j(e,n){if(e!=="requirement_propose"||!n)return null;try{const s=JSON.parse(n);if(s.status!=="success"||!s.requirement)return null;const i=s.requirement;return i.status!=="pending"?null:{requirementId:i.id,title:i.title,description:i.description,priority:i.priority}}catch{return null}}function Y4(e){const n=[];for(const s of e)if(s.phase!=="output"){if(s.phase==="start"){const i=`${s.tool}_${s.ts}`;n.push({key:i,tool:s.tool,status:"running"})}else for(let i=n.length-1;i>=0;i--)if(n[i].tool===s.tool&&n[i].status==="running"){n[i]={...n[i],status:s.success===!1?"error":"done"};break}}return n}function Bj(){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 G4(){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 _y({item:e,idx:n,total:s}){const i=Ni(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:[n>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"?"✗":""}),n<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:i.icon}),t.jsxs("span",{children:[i.label,e.status==="running"?"…":""]}),e.status==="running"&&t.jsx(Bj,{})]})]})}function X4({activities:e,isActive:n,persistent:s}){const i=Y4(e),[l,d]=v.useState(!1),[c,h]=v.useState(!1),m=v.useRef(null);if(v.useEffect(()=>(s||n||e.length>0?(d(!0),m.current&&clearTimeout(m.current)):m.current=setTimeout(()=>d(!1),800),()=>{m.current&&clearTimeout(m.current)}),[s,n,e.length]),!l)return null;const f=i.length>0,x=f&&i.every(y=>y.status!=="running"),p=n&&!f,g=n&&f&&x;if(s&&x){const y=i.filter(N=>N.status==="error").length,w=i.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:[i.slice(0,5).map(N=>t.jsx("span",{className:"text-[10px] opacity-60",title:Ni(N.tool).label,children:Ni(N.tool).icon},N.key)),i.length>5&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["+",i.length-5]})]})]}),c&&t.jsx("div",{className:"mt-2 space-y-0.5",children:i.map((N,T)=>t.jsx(_y,{item:N,idx:T,total:i.length},N.key))})]})}return t.jsxs("div",{className:"mb-2 space-y-0.5",children:[i.map((y,w)=>t.jsx(_y,{item:y,idx:w,total:i.length},y.key)),p&&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(G4,{})]}),g&&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(Bj,{}),t.jsx("span",{children:"Writing response…"})]})]})]})}function Lm({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(n=>t.jsx("span",{className:"w-1 h-1 rounded-full bg-brand-400 animate-bounce",style:{animationDelay:`${n}ms`,animationDuration:"1s"}},n))})]})}function Im({content:e,className:n}){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(ir,{content:e,className:n??"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 K4({info:e,onClose:n}){const s=Ni(e.tool),i=V4(e.args),l=e.status==="running",d=e.status!=="error";return v.useEffect(()=>{const c=h=>{h.key==="Escape"&&n()};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[n]),t.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",onClick:n,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:c=>c.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 ${l?"text-brand-500":d?"text-fg-primary":"text-red-500"}`,children:s.label}),t.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${l?"bg-brand-500/15 text-brand-500":d?"bg-green-500/15 text-green-600":"bg-red-500/15 text-red-500"}`,children:l?"Running":d?"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:Cx(e.durationMs)}),t.jsx("button",{onClick:n,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:[i.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:i.map(({key:c,value:h})=>t.jsxs("div",{children:[t.jsx("div",{className:"text-[11px] text-brand-500 font-medium mb-0.5",children:c}),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:h})]},c))})]}),!l&&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:Ey(e.result)})]}),!l&&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:Ey(String(e.error))})]}),e.subagentLogs&&e.subagentLogs.length>0&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2",children:"Sub-agent Execution"}),t.jsx("div",{className:"bg-surface-elevated/50 rounded-lg px-3 py-2 space-y-1 max-h-[50vh] overflow-y-auto",children:e.subagentLogs.map((c,h)=>{const m=c.eventType==="started"?"▶":c.eventType==="completed"?"✓":c.eventType==="error"?"✗":c.eventType==="tool_start"?"◎":c.eventType==="tool_end"?"●":c.eventType==="thinking"?"💭":"→",f=c.eventType==="error"?"text-red-500":c.eventType==="completed"?"text-green-500":c.eventType==="started"?"text-brand-500":"text-fg-tertiary";return t.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[t.jsx("span",{className:`shrink-0 ${f}`,children:m}),t.jsx("span",{className:`font-mono break-all ${f}`,children:c.content})]},h)})})]}),!i.length&&!l&&!e.result&&!e.error&&!e.subagentLogs?.length&&t.jsx("div",{className:"text-sm text-fg-tertiary italic py-4 text-center",children:"No detailed data recorded for this tool call."})]})]})]})}const Hj={urgent:"text-red-500",high:"text-amber-500",medium:"text-blue-500",low:"text-fg-tertiary"},Ay={pending:"pending",in_progress:"in_progress",completed:"completed",review:"review",blocked:"blocked",failed:"failed",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"},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 Pj({info:e}){const[n,s]=v.useState("loading");v.useEffect(()=>{let m=!1;return se.tasks.get(e.taskId).then(({task:f})=>{m||s(Ay[f.status]??"pending")}).catch(()=>{m||s("pending")}),()=>{m=!0}},[e.taskId]),v.useEffect(()=>Jt.on("task:update",m=>{const f=m.payload;f.taskId===e.taskId&&f.status&&s(Ay[f.status]??"pending")}),[e.taskId]);const i=async()=>{s("approving");try{await se.tasks.approve(e.taskId),s("in_progress")}catch{s("pending")}},l=async()=>{s("rejecting");try{await se.tasks.reject(e.taskId),s("cancelled")}catch{s("pending")}},d=n==="pending"||n==="approving"||n==="rejecting",c=My[n]??My.loading,h=()=>ht.navigate(me.WORK,{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&&n!=="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&&n!=="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:Hj[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:i,disabled:n!=="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:n==="approving"?"Approving…":"Approve"}),t.jsx("button",{onClick:l,disabled:n!=="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:n==="rejecting"?"Rejecting…":"Reject"})]})]})}const Ry={pending:"pending",in_progress:"in_progress",completed:"completed",rejected:"rejected",cancelled:"cancelled",archived:"archived"},Oy={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:""}},W4=["requirement:approved","requirement:rejected","requirement:updated","requirement:completed","requirement:cancelled","requirement:resubmitted"];function qj({info:e}){const[n,s]=v.useState("loading"),[i,l]=v.useState(""),[d,c]=v.useState(!1);v.useEffect(()=>{let p=!1;return se.requirements.get(e.requirementId).then(({requirement:g})=>{p||s(Ry[g.status]??"pending")}).catch(()=>{p||s("pending")}),()=>{p=!0}},[e.requirementId]),v.useEffect(()=>{const p=W4.map(g=>Jt.on(g,y=>{const w=y.payload;w.id===e.requirementId&&w.status&&s(Ry[w.status]??"pending")}));return()=>p.forEach(g=>g())},[e.requirementId]);const h=async()=>{s("approving");try{await se.requirements.approve(e.requirementId),s("in_progress")}catch{s("pending")}},m=async()=>{if(!d){c(!0);return}if(i.trim()){s("rejecting");try{await se.requirements.reject(e.requirementId,i.trim()),s("rejected")}catch{s("pending")}}},f=n==="pending"||n==="approving"||n==="rejecting",x=Oy[n]??Oy.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&&n!=="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&&n!=="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:Hj[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:i,onChange:p=>l(p.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:p=>p.key==="Enter"&&m(),autoFocus:!0}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:h,disabled:n!=="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:n==="approving"?"Approving…":"Approve"}),t.jsx("button",{onClick:m,disabled:n!=="pending"||d&&!i.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:n==="rejecting"?"Rejecting…":"Reject"})]})]})]})}function Q4({info:e,showTime:n,time:s,isLast:i}){const l=Ni(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,p=F4(e),g=v.useRef(null);return v.useEffect(()=>{g.current&&(g.current.scrollTop=g.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 ${i?"":"border-b border-border-default/30 pb-1.5 mb-0.5"} cursor-pointer rounded hover:bg-surface-elevated/30 transition-colors`,onClick:()=>c(!0),children:[n&&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:l.icon}),t.jsxs("span",{children:[l.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:Cx(e.durationMs)}),x&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary ml-0.5 opacity-60",children:["(",e.subagentLogs.filter(y=>y.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:"$ "}),Dm(p,120)]}),e.liveOutput&&e.status==="running"&&t.jsx("pre",{ref:g,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(K4,{info:e,onClose:()=>c(!1)}),h&&(()=>{const y=zj(e.tool,e.result);if(y)return t.jsx(Pj,{info:y});const w=$j(e.tool,e.result);return w?t.jsx(qj,{info:w}):null})()]})}function Z4({content:e,time:n,showTime:s}){const[i,l]=v.useState(!1);return t.jsxs("div",{className:"flex items-start gap-2",children:[s&&n&&t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0 w-24 text-right tabular-nums mt-2.5 hidden md:inline",children:n}),t.jsxs("div",{className:"flex-1 min-w-0 my-1 overflow-hidden",children:[t.jsxs("button",{onClick:()=>l(!i),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 ${i?"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"})})]}),i&&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(ir,{content:e,className:"text-xs text-fg-tertiary break-words"})})]})]})}const Ud=v.memo(Uj);function Uj({entry:e,showTime:n,isLast:s}){if(e.type==="tool")return t.jsx(Q4,{info:e.info,showTime:n,time:e.time,isLast:s},e.key);if(e.type==="thinking")return t.jsx(Z4,{content:e.content,time:e.time,showTime:n});if(e.type==="text")return t.jsxs("div",{className:"flex items-start gap-2 ",children:[n&&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(ir,{content:e.content,className:"text-sm text-fg-secondary break-words"})})]});if(e.type==="status"){const i=e.content==="completed"||e.content==="execution_finished",l=e.content==="started",d=e.content==="resumed",c=i?"text-green-600":l?"text-blue-600":d?"text-amber-600":"text-fg-tertiary",h=i?"bg-green-400":l?"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:[n&&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:[n&&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 Ex({entries:e,streamingText:n,isActive:s,onExpand:i,showRounds:l,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(),p=s?Date.now()-f:x-f,g=new Set(e.filter(k=>k.executionRound!=null).map(k=>k.executionRound)),y=g.size>0?Math.max(...g):void 0,w=l&&g.size>1;let N,T,C=null;if(s)if(n)N="✍",T="Writing response...",C=Dm(n.split(`
|
|
42
|
-
`).pop()??"",80);else if(c?.type==="tool_start"){const k=Ni(c.content);N=k.icon,T=`${k.label}...`;const M=c.metadata?.arguments&&typeof c.metadata.arguments=="object"?c.metadata.arguments.command:void 0;M&&(C=`$ ${Dm(M,80)}`)}else if(c?.type==="tool_end"){const k=Ni(c.content);N=k.icon,T=k.label}else N="💭",T="Thinking...";else if(m>0&&c?.type==="error")N="❌",T="Failed";else{const M=[...e].reverse().find(D=>D.type==="status")?.content??"";M==="completed"||M==="execution_finished"?(N="✅",T="Completed"):(N="●",T=`${h} tool${h!==1?"s":""} executed`)}const _=Cx(p);return t.jsx("div",{onClick:i,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:T})]}),_&&t.jsx("span",{className:"text-[10px] text-fg-tertiary tabular-nums shrink-0",children:_})]}),n?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(ir,{content:n,className:"text-xs"})}):C?t.jsx("div",{className:"mt-1 ml-5.5 text-[11px] font-mono text-fg-tertiary truncate",children:C}):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:[g.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 J4(e){const n=new Map;for(const s of e){const i=s.executionRound??1;n.has(i)||n.set(i,[]);const l=Uo(s);l&&n.get(i).push(l)}return Array.from(n.entries()).sort(([s],[i])=>s-i).map(([s,i])=>({round:s,entries:i}))}function du({entries:e,streamingText:n,isActive:s,onCollapse:i,showRounds:l,embedded:d}){const c=v.useRef(null),[h,m]=v.useState(new Set),f=J4(e),x=l&&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,n,s,d]);const p=w=>{m(N=>{const T=new Set(N);return T.has(w)?T.delete(w):T.add(w),T})},g=x?null:e.map(Uo).filter(w=>w!==null),y=g?qo(g):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:i,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),T=qo(w.entries),C=w.entries.filter(_=>_.type==="tool"&&_.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:()=>p(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:[C," tool",C!==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:T.map((_,k)=>t.jsx(Ud,{entry:_,showTime:!0,isLast:k===T.length-1},k))})]},w.round)}):y&&y.map((w,N)=>t.jsx(Ud,{entry:w,showTime:!0,isLast:N===y.length-1},N)),s&&n&&t.jsx(Im,{content:n}),s&&!n&&t.jsx(Lm,{})]})]})}function e_({agents:e,filter:n,anchorRef:s,onSelect:i,selectedIndex:l,onIndexChange:d}){const[c,h]=v.useState(null),m=v.useRef(null),f=e.filter(x=>x.name.toLowerCase().includes(n));return v.useEffect(()=>{const x=s.current;if(!x)return;const p=x.getBoundingClientRect();h({top:p.top+window.scrollY-4,left:p.left+window.scrollX+8})},[s,n]),v.useEffect(()=>{if(!m.current||!c)return;if(m.current.getBoundingClientRect().top<8){const p=s.current;if(!p)return;const g=p.getBoundingClientRect();h({top:g.bottom+window.scrollY+4,left:c.left})}},[c,s]),v.useEffect(()=>{l>=f.length&&d(Math.max(0,f.length-1))},[f.length,l,d]),v.useEffect(()=>{if(!m.current)return;m.current.querySelector('[data-selected="true"]')?.scrollIntoView({block:"nearest"})},[l]),!c||f.length===0?null:lx.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,p)=>t.jsxs("button",{"data-selected":p===l,onMouseDown:g=>{g.preventDefault(),i(x)},onMouseEnter:()=>d(p),className:`w-full text-left px-3 py-2 text-xs flex items-center gap-2 transition-colors ${p===l?"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 Vd=/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu;function n_(e){const n=[];let s;for(Vd.lastIndex=0;(s=Vd.exec(e))!==null;)n.push(s[1]??s[2]);return n}function Dy(e,n,s){const i=[],l=new RegExp(Vd.source,Vd.flags);let d=0,c,h=0;for(;(c=l.exec(e))!==null;){c.index>d&&i.push(t.jsx("span",{children:e.slice(d,c.index)},h++));const m=c[1]??c[2],f=n.find(x=>x.name.toLowerCase()===m.toLowerCase());i.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&&i.push(t.jsx("span",{children:e.slice(d)},h++)),i.length>0?i:[t.jsx("span",{children:e},0)]}function Vj({agents:e,onSubmit:n,placeholder:s,replyTo:i,onCancelReply:l}){const[d,c]=v.useState(""),[h,m]=v.useState(!1),[f,x]=v.useState(null),[p,g]=v.useState(!1),[y,w]=v.useState(""),[N,T]=v.useState([]),[C,_]=v.useState(0),k=v.useRef(null),M=v.useRef(null),D=e.filter(U=>U.name.toLowerCase().includes(y)),A=async()=>{if(d.trim()){m(!0),x(null),M.current={content:d,mentions:[...N]};try{await n(d,N,i?.id),c(""),T([]),M.current=null,l?.()}catch(U){x(String(U instanceof Error?U.message:U)||"Failed to send comment")}m(!1)}},G=async()=>{if(!M.current)return;const{content:U,mentions:z}=M.current;m(!0),x(null);try{await n(U,z),c(""),T([]),M.current=null}catch(E){x(String(E instanceof Error?E.message:E)||"Failed to send comment")}m(!1)},X=v.useCallback(U=>{c(z=>{const E=z.lastIndexOf("@"),L=t_(U.name);return E>=0?z.slice(0,E)+L+" ":z+L+" "}),N.includes(U.id)||T(z=>[...z,U.id]),g(!1),w(""),_(0),k.current?.focus()},[N]),K=U=>{c(U),x(null);const z=U.lastIndexOf("@");if(z>=0&&(z===0||U[z-1]===" ")){const L=U.slice(z+1).toLowerCase();if(e.some(F=>F.name.toLowerCase().includes(L))){w(L),g(!0),_(0);return}}g(!1)},$=U=>{if(p&&D.length>0){const z=U.key==="ArrowUp"||U.ctrlKey&&U.key==="p",E=U.key==="ArrowDown"||U.ctrlKey&&U.key==="n",L=U.key==="Enter"||U.key==="Tab",R=U.key==="Escape";if(z){U.preventDefault(),_(F=>(F-1+D.length)%D.length);return}if(E){U.preventDefault(),_(F=>(F+1)%D.length);return}if(L){U.preventDefault();const F=D[C];F&&X(F);return}if(R){U.preventDefault(),g(!1);return}}U.key==="Enter"&&!U.shiftKey&&(U.preventDefault(),A())},q=v.useCallback(()=>{setTimeout(()=>g(!1),200)},[]);return t.jsxs("div",{className:"relative",children:[p&&t.jsx(e_,{agents:e,filter:y,anchorRef:k,onSelect:X,selectedIndex:C,onIndexChange:_}),t.jsxs("div",{className:"border border-border-default rounded-lg bg-surface-elevated",children:[i&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 pt-2 pb-1 border-b border-border-default/50",children:[t.jsxs("div",{className:"flex-1 min-w-0 pl-2 border-l-2 border-brand-500/50",children:[t.jsx("span",{className:"text-[10px] font-medium text-brand-500",children:i.authorName}),t.jsx("p",{className:"text-[10px] text-fg-tertiary truncate",children:i.content})]}),t.jsx("button",{onClick:l,className:"text-fg-tertiary hover:text-fg-secondary shrink-0 p-0.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("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),N.length>0&&t.jsx("div",{className:"flex gap-1 px-2.5 pt-2 flex-wrap",children:N.map(U=>{const z=e.find(E=>E.id===U);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:["@",z?.name??U,t.jsx("button",{onClick:()=>T(E=>E.filter(L=>L!==U)),className:"hover:text-red-400",children:"×"})]},U)})}),t.jsx("textarea",{ref:k,value:d,onChange:U=>K(U.target.value),onKeyDown:$,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"}),f&&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:f}),t.jsxs("button",{onClick:G,disabled:h,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:A,disabled:!d.trim()||h,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:h?"Sending…":"Comment"})})]})]})}function Fj({title:e,message:n,confirmLabel:s="Confirm",checkboxes:i,onConfirm:l,onCancel:d}){const[c,h]=v.useState(()=>{const m={};for(const f of i??[])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:n}),i&&i.length>0&&t.jsx("div",{className:"mb-4 space-y-2",children:i.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:()=>l(i?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 uu({children:e,onClose:n,title:s,width:i="w-[440px]"}){return t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:n,children:t.jsxs("div",{className:`bg-surface-secondary border border-border-default rounded-xl p-6 ${i} shadow-2xl max-h-[90vh] overflow-y-auto`,onClick:l=>l.stopPropagation(),children:[t.jsx("h3",{className:"text-base font-semibold mb-5",children:s}),e]})})}function ia({label:e,children:n}){return t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-secondary mb-1.5 font-medium",children:e}),n]})}function r_({onClose:e,onCreate:n}){const[s,i]=v.useState(""),[l,d]=v.useState("");return t.jsx(uu,{onClose:e,title:"Create a New Team",children:t.jsxs("div",{className:"space-y-4",children:[t.jsx(ia,{label:"Team Name",children:t.jsx("input",{value:s,onChange:c=>i(c.target.value),placeholder:"e.g. Engineering, Marketing, Support",className:"input",autoFocus:!0,onKeyDown:c=>{c.key==="Enter"&&s.trim()&&n(s.trim(),l.trim()||void 0)}})}),t.jsx(ia,{label:"Description (optional)",children:t.jsx("textarea",{value:l,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:"text-xs text-fg-tertiary bg-brand-500/5 border border-brand-500/20 rounded-lg px-3 py-2",children:[t.jsx("span",{className:"text-brand-400 font-medium",children:"Tip:"})," For more advanced team creation (with roles, skills, and auto-hiring), just tell your ",t.jsx("span",{className:"text-brand-400",children:"Secretary"})," what kind of team you need."]}),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()&&n(s.trim(),l.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 s_({teamId:e,teams:n,onClose:s,onAdd:i}){const[l,d]=v.useState(""),[c,h]=v.useState("member"),[m,f]=v.useState(""),[x,p]=v.useState(""),[g,y]=v.useState(""),[w,N]=v.useState(e??""),[T,C]=v.useState(""),_=()=>{if(C(""),!l.trim()){C("Name is required");return}if(x&&x!==g){C("Passwords do not match");return}i(l.trim(),c,m||void 0,x||void 0,w||void 0)};return t.jsx(uu,{onClose:s,title:"Add Human Team Member",width:"w-[460px]",children:t.jsxs("div",{className:"space-y-4",children:[t.jsx(ia,{label:"Name *",children:t.jsx("input",{value:l,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(ia,{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(ia,{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"}),n.map(k=>t.jsx("option",{value:k.id,children:k.name},k.id))]})})]}),t.jsx(ia,{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(ia,{label:"Password",children:t.jsx("input",{value:x,onChange:k=>p(k.target.value),type:"password",placeholder:"Leave blank for no login access",className:"input"})}),x&&t.jsx("div",{className:"mt-3",children:t.jsx(ia,{label:"Confirm Password",children:t.jsx("input",{value:g,onChange:k=>y(k.target.value),type:"password",placeholder:"Repeat password",className:"input"})})})]}),T&&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:T}),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:_,className:"px-4 py-2 text-sm bg-green-700 hover:bg-green-600 rounded-lg text-white",children:"Add Member"})]})]})})}function a_({teamId:e,ungrouped:n,onClose:s,onAdd:i}){return t.jsx(uu,{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."}),n.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:n.map(l=>t.jsxs("button",{onClick:()=>i(l.id,l.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 ${l.type==="agent"?"bg-brand-600":"bg-green-600"}`,children:l.name.charAt(0)}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-sm",children:l.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[l.role," · ",l.type==="agent"?"AI":"Human"]})]}),l.status&&t.jsx("span",{className:`w-2 h-2 rounded-full ${l.status==="idle"?"bg-green-400":l.status==="working"?"bg-blue-400":"bg-gray-600"}`})]},l.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 i_({onClose:e,onConnected:n}){const[s,i]=v.useState(""),[l,d]=v.useState(""),[c,h]=v.useState(!1),[m,f]=v.useState(null),[x,p]=v.useState(null),g=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 C=await N.json().catch(()=>({}));throw new Error(C.error??`HTTP ${N.status}`)}const T=await N.json();f({externalAgentId:w,markusAgentId:T.registration?.markusAgentId,token:T.token,gatewayUrl:T.gatewayUrl})}catch(N){d(String(N))}h(!1)},y=(w,N)=>{navigator.clipboard.writeText(w),p(N),setTimeout(()=>p(null),2e3)};return t.jsx(uu,{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:()=>{n()},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(ia,{label:"Agent Name *",children:t.jsx("input",{className:"input",placeholder:"e.g. Alice",value:s,onChange:w=>i(w.target.value),autoFocus:!0})}),l&&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:l}),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:g,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 Ly=new Map;function l_(e){return e.split(" ").map(n=>n[0]).join("").toUpperCase().slice(0,2)}function o_({authUser:e,agents:n,teams:s,humans:i,tasks:l,externalAgents:d,groupChats:c,chatMode:h,selectedAgent:m,activeChannel:f,activeDmUserId:x,onSelectAgent:p,onSelectChannel:g,onSelectDm:y,onRefreshTeams:w,onRefreshAgents:N,onViewProfile:T,width:C,onResizeStart:_,hidden:k}){const M=$r(),D=e?.role==="owner"||e?.role==="admin",A=v.useMemo(()=>new Set(d.map(le=>le.markusAgentId).filter(Boolean)),[d]),[G,X]=v.useState([]),[K,$]=v.useState(new Set),[q,U]=v.useState(!1),[z,E]=v.useState(null),[L,R]=v.useState(null),[F,Y]=v.useState(!1),[Z,B]=v.useState(null),[O,V]=v.useState(null),[I,S]=v.useState(null),[H,W]=v.useState(!1),ee=v.useRef(null),[te,ae]=v.useState(null),[he,Ne]=v.useState(null),De=(le,$e="success")=>{Ne({message:le,type:$e}),setTimeout(()=>Ne(null),3e3)},[je,ke]=v.useState(!1),[Se,Le]=v.useState(!1);v.useEffect(()=>{se.governance.getSystemStatus().then(Ue=>ke(Ue.globalPaused)).catch(()=>{});const le=Jt.on("system:pause-all",()=>ke(!0)),$e=Jt.on("system:resume-all",()=>ke(!1));return()=>{le(),$e()}},[]);const nt=v.useCallback(()=>{yt({title:je?"Resume All Agents":"Pause All Agents",message:je?"All agents will resume processing events from their mailbox.":"All agents will be paused. Events will still enter the mailbox but will not be processed. In-progress tasks will be blocked.",confirmLabel:je?"Resume":"Pause",onConfirm:async()=>{Le(!0);try{je?(await se.governance.resumeAll(),ke(!1)):(await se.governance.pauseAll(),ke(!0))}catch{}Le(!1)}})},[je]),[rt,yt]=v.useState(null),Rt=(le,$e,Ue,We,Ke)=>{yt({title:le,message:$e,onConfirm:Ue,confirmLabel:We,checkboxes:Ke})},[re,_e]=v.useState(null),[st,dt]=v.useState(null),Yt=v.useRef(null),ye=v.useRef(null),[Ae,Fe]=v.useState(!1),[Qe,xt]=v.useState(null),[nn,cn]=v.useState(""),Tt=v.useCallback((le,$e=176,Ue=320)=>{const We=le.currentTarget.getBoundingClientRect(),Ke=window.innerWidth,qe=window.innerHeight,Je=8;let Wt=We.left,Zt=We.bottom+4;return Wt+$e>Ke-Je&&(Wt=Math.max(Je,Ke-$e-Je)),Zt+Ue>qe-Je&&(Zt=Math.max(Je,We.top-Ue-4)),{x:Wt,y:Zt}},[]),[gt,Bt]=v.useState(Ly),_t=v.useMemo(()=>n.map(le=>le.id).sort().join(","),[n]);v.useEffect(()=>{if(!n.length)return;let le=!1;const $e=async()=>{const We=[];if(await Promise.allSettled(n.map(async Ke=>{try{const{sessions:qe}=await se.sessions.listByAgent(Ke.id,1);if(!qe.length)return;const{messages:Je}=await se.sessions.getMessages(qe[0].id,1);if(Je.length){const Wt=Je[0],Zt=Wt.metadata?.segments;let Pt=Wt.content;if(Zt&&Zt.length>0){const be=[...Zt].reverse().find(ze=>ze.type==="text");be&&be.type==="text"&&(Pt=be.content)}const En=Pt.replace(/<think>[\s\S]*?(<\/think>|$)/g,"").replace(/<(invoke|function_calls|antml:\w+)\b[\s\S]*?(<\/\1>|$)/g,"").replace(/\n+/g," ").trim().slice(0,80);En&&We.push([Ke.id,En])}}catch{}})),!le){const Ke=new Map(We);Ly=Ke,Bt(Ke)}};$e();const Ue=setInterval($e,3e4);return()=>{le=!0,clearInterval(Ue)}},[_t]);const Ht=v.useCallback(()=>{se.teams.list().then(le=>X(le.ungrouped)).catch(()=>{})},[]);v.useEffect(()=>{Ht()},[Ht]),v.useEffect(()=>Jt.on("*",Ht),[Ht]),v.useEffect(()=>{if(!Z&&!O&&!H)return;const le=$e=>{B(null),V(null),W(!1)};return setTimeout(()=>document.addEventListener("click",le),0),()=>document.removeEventListener("click",le)},[Z,O,H]);const rn=(le,$e)=>{Rt(`Delete "${$e}"?`,"This team will be removed from the database. Check options below to also delete members and disk files.",async Ue=>{const We=Ue?.deleteMembers??!0,Ke=Ue?.purgeFiles??!1;await se.teams.delete(le,We,{purgeFiles:Ke}),w(),Ht(),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}])},bn=async(le,$e)=>{try{const We=await($e==="start"?se.teams.startAll:$e==="stop"?se.teams.stopAll:$e==="pause"?se.teams.pauseAll:se.teams.resumeAll)(le),Ke=We.success?.length??0,qe=We.failed?.length??0,Je={start:"started",stop:"stopped",pause:"paused",resume:"resumed"};qe>0?De(`${$e}: ${Ke} succeeded, ${qe} failed`,"error"):Ke>0&&De(`${Ke} agent${Ke>1?"s":""} ${Je[$e]}`,"success"),N()}catch(Ue){De(`Failed to ${$e}: ${Ue instanceof Error?Ue.message:String(Ue)}`,"error")}},Hn=async(le,$e,Ue)=>{await se.teams.update(le,{managerId:$e,managerType:Ue}),w()},Cn=async le=>{if(!nn.trim()){xt(null);return}await se.teams.update(le,{name:nn.trim()}),xt(null),w()},xe=async(le,$e)=>{$e==="offline"?await se.agents.start(le):await se.agents.stop(le),N()},Re=(le,$e)=>{Rt("Remove from team?","This member will be moved to Ungrouped.",async()=>{await se.teams.removeMember(le,$e),w(),Ht()},"Remove")},vt=(le,$e,Ue)=>{Rt(`Remove "${$e}"?`,"This agent will be removed from the database. Check the option below to also delete its workspace, memory, and other files from disk.",async We=>{{const Ke=We?.purgeFiles??!1;await se.agents.remove(le,{purgeFiles:Ke})}N(),w(),Ht(),window.dispatchEvent(new CustomEvent("markus:data-changed"))},"Remove",[{id:"purgeFiles",label:"Also delete disk files (workspace, memory, logs)",defaultChecked:!1}])},At=(le,$e,Ue)=>{ye.current={x:le.clientX,y:le.clientY},Yt.current=setTimeout(()=>{_e({agentId:$e,fromTeamId:Ue}),Fe(!0)},200)},Dt=le=>{if(!ye.current||!Yt.current)return;const $e=Math.abs(le.clientX-ye.current.x),Ue=Math.abs(le.clientY-ye.current.y);($e>5||Ue>5)&&(Ae||(clearTimeout(Yt.current),Yt.current=null))},On=async()=>{if(Yt.current&&(clearTimeout(Yt.current),Yt.current=null),ye.current=null,Ae&&re&&st){const le=st==="_ungrouped"?void 0:st;try{if(re.fromTeamId&&re.fromTeamId!==le&&await se.teams.removeMember(re.fromTeamId,re.agentId),le&&le!==re.fromTeamId){const $e=n.find(Ue=>Ue.id===re.agentId);await se.teams.addMember(le,re.agentId,"agent")}w(),N(),Ht()}catch($e){De(`Move failed: ${$e instanceof Error?$e.message:String($e)}`,"error")}}_e(null),dt(null),Fe(!1)},an=v.useMemo(()=>new Map(s.map(le=>[le.id,le])),[s]),dn=v.useMemo(()=>{const le=new Map,$e=[];for(const Ue of n)if(Ue.teamId&&an.has(Ue.teamId)){const We=le.get(Ue.teamId)??[];We.push(Ue),le.set(Ue.teamId,We)}else $e.push(Ue);return{byTeam:le,ungrouped:$e}},[n,an]);s.filter(le=>dn.byTeam.has(le.id)||le.members?.length>0).map(le=>le.id);const Dn=le=>$($e=>{const Ue=new Set($e);return Ue.has(le)?Ue.delete(le):Ue.add(le),Ue}),Nt=(le,$e)=>{const Ue=h==="direct"&&m===le.id,We=A.has(le.id),Ke=le.status==="idle"?"bg-green-500":le.status==="working"?"bg-blue-500 animate-pulse":le.status==="error"?"bg-red-500":le.status==="paused"?"bg-amber-500":"bg-gray-600",Je=($e?an.get($e):void 0)?.managerId===le.id,Wt=le.role?.toLowerCase().replace(/[-_]/g," ").trim(),Zt=le.name.toLowerCase().trim(),Pt=Wt&&Wt!==Zt,En=gt.get(le.id)||le.currentActivity?.label?.slice(0,60)||"",be=le.status==="idle"?"Online":le.status==="working"?"Working":le.status==="error"?"Error":le.status==="paused"?"Paused":"Offline";return t.jsx("div",{className:`relative mb-0.5 ${Ae&&re?.agentId===le.id?"opacity-40":""}`,onPointerDown:ze=>At(ze,le.id,$e),onPointerMove:Dt,onPointerUp:On,children:t.jsxs("button",{onClick:()=>{Ae||p(le.id)},onContextMenu:ze=>{if(!D)return;ze.preventDefault();const Et=Tt(ze);V({agentId:le.id,teamId:$e,...Et})},className:`w-full flex items-center gap-2.5 px-2 py-1.5 rounded-lg text-xs transition-colors select-none ${M?"":"touch-none"} ${Ue?"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 ${Ue?"bg-brand-600 text-white":"bg-surface-overlay text-fg-secondary"}`,children:l_(le.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:le.name}),Pt&&t.jsxs("span",{className:"text-[9px] text-fg-tertiary shrink-0 truncate max-w-[60px]",children:["(",le.role,")"]}),Je&&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"})}),We&&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:En||" "})]}),t.jsxs("span",{className:"flex items-center gap-1.5 shrink-0",children:[le.mailboxDepth!=null&&le.mailboxDepth>0&&t.jsx("span",{className:"text-[8px] text-fg-tertiary bg-surface-overlay rounded-full px-1 leading-relaxed",children:le.mailboxDepth}),t.jsx("span",{title:be,onClick:ze=>{ze.stopPropagation(),T(le.id)},className:`w-2 h-2 rounded-full cursor-pointer transition-transform duration-150 hover:scale-[2] ${Ke}`}),M&&D&&t.jsx("span",{role:"button",tabIndex:0,onClick:ze=>{if(ze.stopPropagation(),O?.agentId===le.id)V(null);else{const Et=Tt(ze);V({agentId:le.id,teamId:$e,...Et})}},className:"w-5 h-5 flex items-center justify-center text-fg-tertiary hover:text-fg-secondary rounded transition-colors",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"})]})})]})]})},le.id)},hn=(le,$e,Ue,We)=>{const Ke=K.has(le),qe=Ae&&st===le&&re?.fromTeamId!==le,Je=le!=="_ungrouped"?(lr.byTeam.get(le)??[])[0]:void 0,Wt=Je&&h==="channel"&&f===Je.channelKey,Zt=te===le;return t.jsxs("div",{"data-team-id":le,className:`mb-1 rounded-lg transition-all duration-500 ${qe?"ring-1 ring-brand-500/50 bg-brand-500/5":""} ${Zt?"ring-2 ring-brand-500 bg-brand-500/10":""}`,onPointerEnter:()=>{Ae&&dt(le)},onPointerLeave:()=>{Ae&&st===le&&dt(null)},children:[t.jsxs("div",{className:"group/teamhdr flex items-center gap-0.5",children:[t.jsxs("button",{onClick:()=>{Je?g(Je.channelKey):Dn(le)},onContextMenu:Pt=>{if(!D||!$e)return;Pt.preventDefault();const En=Tt(Pt);B({teamId:le,...En})},className:`flex-1 flex items-center gap-2 px-2 py-1.5 rounded-lg text-xs transition-colors min-w-0 ${Wt?"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 ${Wt?"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:[Qe===le?t.jsx("input",{className:"bg-transparent border-b border-brand-500 text-fg-secondary text-[11px] font-medium outline-none w-full",value:nn,onChange:Pt=>cn(Pt.target.value),onBlur:()=>Cn(le),onKeyDown:Pt=>{Pt.key==="Enter"&&Cn(le),Pt.key==="Escape"&&xt(null)},onClick:Pt=>Pt.stopPropagation(),autoFocus:!0}):t.jsx("span",{className:"truncate font-medium text-[11px] leading-tight block",children:We}),t.jsxs("div",{className:"text-[10px] text-fg-tertiary leading-tight mt-0.5",children:[Ue.length," members"]})]})]}),t.jsx("button",{onClick:()=>Dn(le),className:"w-7 h-7 flex items-center justify-center text-fg-secondary hover:text-fg-primary rounded-md hover:bg-surface-overlay transition-colors shrink-0",title:Ke?"Expand":"Collapse",children:t.jsx("svg",{className:`w-3.5 h-3.5 transition-transform duration-150 ${Ke?"":"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"})})}),D&&$e&&t.jsx("button",{onClick:Pt=>{if(Pt.stopPropagation(),Z?.teamId===le)B(null);else{const En=Tt(Pt);B({teamId:le,...En})}},className:"w-7 h-7 flex items-center justify-center text-fg-secondary hover:text-fg-primary rounded-md hover:bg-surface-overlay transition-colors shrink-0",title:"More options",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("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"})]})})]}),qe&&Ae&&t.jsx("div",{className:"text-[9px] text-brand-500 px-4 py-0.5 animate-pulse",children:"Drop here"}),!Ke&&t.jsx("div",{className:"ml-1",children:Ue.map(Pt=>Nt(Pt,le==="_ungrouped"?void 0:le))})]},le)},lr=v.useMemo(()=>{const le=new Map,$e=[];for(const Ue of c)if(Ue.teamId){const We=le.get(Ue.teamId)??[];We.push(Ue),le.set(Ue.teamId,We)}else{const We=s.find(Ke=>Ue.name.toLowerCase().includes(Ke.name.toLowerCase())||Ke.name.toLowerCase().includes(Ue.name.toLowerCase()));if(We){const Ke=le.get(We.id)??[];Ke.push(Ue),le.set(We.id,Ke)}else $e.push(Ue)}return{byTeam:le,unmatched:$e}},[c,s]);return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`bg-surface-secondary/60 border-r border-border-default flex flex-col ${C!=null?"shrink-0":"flex-1 min-w-0"}`,style:k?{display:"none"}:C!=null?{width:C}:void 0,children:[t.jsxs("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"}),t.jsx("div",{className:"ml-auto",children:t.jsx("button",{onClick:nt,disabled:Se,title:je?"Resume all agents":"Pause all agents",className:`flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-md border transition-colors ${je?"bg-green-500/10 border-green-500/30 text-green-500 hover:bg-green-500/20":"bg-amber-500/10 border-amber-500/30 text-amber-600 hover:bg-amber-500/20"} disabled:opacity-50`,children:je?t.jsxs(t.Fragment,{children:[t.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})})," Resume"]}):t.jsxs(t.Fragment,{children:[t.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"currentColor",children:[t.jsx("rect",{x:"6",y:"4",width:"4",height:"16"}),t.jsx("rect",{x:"14",y:"4",width:"4",height:"16"})]})," Pause"]})})})]}),D&&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:()=>W(!H),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 ${H?"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"})})]}),H&&t.jsxs("div",{ref:le=>{if(!le)return;const $e=le.getBoundingClientRect(),Ue=window.innerWidth,We=8;$e.right>Ue-We&&(le.style.left="auto"),$e.right>Ue-We&&(le.style.right="0"),$e.left<We&&(le.style.left="0",le.style.right="auto")},className:"absolute left-0 top-full mt-1 w-48 max-w-[calc(100vw-1rem)] bg-surface-secondary border border-border-default rounded-lg shadow-xl z-30 overflow-hidden",children:[t.jsxs("button",{onClick:()=>{W(!1),U(!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:()=>{W(!1),ht.navigate(me.STORE)},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:()=>{W(!1),Y(!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:()=>{W(!1),E({})},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:[n.length===0&&s.length===0&&t.jsx("p",{className:"text-xs text-fg-tertiary px-1 mb-2",children:"No agents yet"}),lr.unmatched.map(le=>t.jsxs("button",{onClick:()=>g(le.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===le.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===le.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:le.name}),t.jsx("div",{className:"text-[10px] text-fg-tertiary leading-tight mt-0.5",children:"Group Chat"})]}),le.memberCount!==void 0&&le.memberCount>0&&t.jsx("span",{className:"text-[9px] text-fg-tertiary shrink-0",children:le.memberCount})]},le.id)),s.map(le=>{const $e=dn.byTeam.get(le.id)??[];return $e.length===0&&(!le.members||le.members.length===0)?null:hn(le.id,le,$e,le.name)}),s.filter(le=>(dn.byTeam.get(le.id)??[]).length===0&&(!le.members||le.members.length===0)).map(le=>hn(le.id,le,[],le.name)),dn.ungrouped.length>0&&hn("_ungrouped",null,dn.ungrouped,"Other"),s.length===0&&n.length>0&&n.map(le=>Nt(le)),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"})]})})]}),i.filter(le=>le.id!==e?.id).map(le=>t.jsxs("button",{onClick:()=>y(le.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===le.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===le.id?"bg-green-600 text-white":"bg-green-500/10 text-green-600"}`,children:le.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:le.name}),t.jsx("div",{className:"text-fg-tertiary truncate text-[10px] leading-tight mt-0.5",children:le.email||le.role})]}),t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 shrink-0"})]},le.id))]})]})]}),_&&t.jsx("div",{className:"w-1 cursor-col-resize shrink-0 group relative",onMouseDown:_,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"})}),Z&&(()=>{const le=dn.byTeam.get(Z.teamId)??[],$e=le.some(qe=>qe.status==="offline"),Ue=le.some(qe=>qe.status==="idle"||qe.status==="working"),We=le.some(qe=>qe.status==="paused"),Ke=le.some(qe=>qe.status!=="offline");return t.jsxs("div",{className:"fixed bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 z-50 w-44 max-w-[calc(100vw-1rem)]",style:{left:Z.x,top:Z.y},onClick:qe=>qe.stopPropagation(),children:[t.jsxs("button",{onClick:()=>{const qe=an.get(Z.teamId);qe&&(xt(Z.teamId),cn(qe.name)),B(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"]}),$e&&t.jsxs("button",{onClick:()=>{bn(Z.teamId,"start"),B(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"]}),Ke&&t.jsxs("button",{onClick:()=>{bn(Z.teamId,"stop"),B(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"]}),Ue&&t.jsxs("button",{onClick:()=>{bn(Z.teamId,"pause"),B(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"]}),We&&t.jsxs("button",{onClick:()=>{bn(Z.teamId,"resume"),B(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:()=>{B(null),ht.navigate(me.STORE)},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:()=>{B(null),E({teamId:Z.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:()=>{B(null),R(Z.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 qe=an.get(Z.teamId);qe&&rn(Z.teamId,qe.name),B(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"]})]})})(),O&&(()=>{const le=n.find(Ke=>Ke.id===O.agentId);if(!le)return null;const Ue=(O.teamId?an.get(O.teamId):void 0)?.managerId===le.id,We=le.id===e?.id;return t.jsxs("div",{className:"fixed bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 z-50 w-44 max-w-[calc(100vw-1rem)]",style:{left:O.x,top:O.y},onClick:Ke=>Ke.stopPropagation(),children:[t.jsxs("button",{onClick:()=>{V(null),T(le.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"]}),le.status==="offline"?t.jsxs("button",{onClick:()=>{xe(le.id,"offline"),V(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:()=>{xe(le.id,le.status??"idle"),V(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"]}),O.teamId&&!Ue&&t.jsxs("button",{onClick:()=>{Hn(O.teamId,le.id,"agent"),V(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"]}),O.teamId&&t.jsxs("button",{onClick:()=>{Re(O.teamId,le.id),V(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(Ke=>Ke.id!==O.teamId).map(Ke=>t.jsx("button",{onClick:async()=>{O.teamId&&await se.teams.removeMember(O.teamId,le.id),await se.teams.addMember(Ke.id,le.id,"agent"),w(),N(),Ht(),V(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary pl-7",children:Ke.name},Ke.id))]}),t.jsx("div",{className:"border-t border-border-default/50 my-1"}),!We&&t.jsxs("button",{onClick:()=>{vt(le.id,le.name),V(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"]})]})})(),q&&t.jsx(r_,{onClose:()=>U(!1),onCreate:async(le,$e)=>{try{const{team:Ue}=await se.teams.create(le,$e);U(!1),w(),ae(Ue.id),setTimeout(()=>{document.querySelector(`[data-team-id="${Ue.id}"]`)?.scrollIntoView({behavior:"smooth",block:"center"})},300),setTimeout(()=>ae(null),3e3)}catch(Ue){alert(`Failed to create team: ${Ue instanceof Error?Ue.message:String(Ue)}`)}}}),z!==null&&t.jsx(s_,{teamId:z.teamId,teams:s,onClose:()=>E(null),onAdd:async(le,$e,Ue,We,Ke)=>{await se.users.create(le,$e,void 0,Ue,We,Ke),E(null),w()}}),L!==null&&t.jsx(a_,{teamId:L,ungrouped:G,onClose:()=>R(null),onAdd:async(le,$e)=>{await se.teams.addMember(L,le,$e),R(null),w(),Ht()}}),F&&t.jsx(i_,{onClose:()=>Y(!1),onConnected:()=>{Y(!1),N(),w()}}),rt&&t.jsx(Fj,{title:rt.title,message:rt.message,confirmLabel:rt.confirmLabel,checkboxes:rt.checkboxes,onConfirm:le=>{rt.onConfirm(le),yt(null)},onCancel:()=>yt(null)}),he&&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 ${he.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:he.message})]})}const c_=50,d_=30;function ca(e,n,s,i){const l=v.useRef(0),d=v.useRef(0),c=v.useCallback(m=>{l.current=m.touches[0].clientX,d.current=m.touches[0].clientY},[]),h=v.useCallback(m=>{const f=m.changedTouches[0].clientX-l.current,x=m.changedTouches[0].clientY-d.current,p=Math.abs(f),g=Math.abs(x);if(p<c_||Math.atan2(g,p)*(180/Math.PI)>d_)return;if(i?.scrollContainerRef?.current){const N=i.scrollContainerRef.current,T=N.scrollLeft<=1,C=N.scrollLeft+N.clientWidth>=N.scrollWidth-1;if(f>0&&!T||f<0&&!C)return}const w=e.findIndex(N=>N.id===n);f<0&&w<e.length-1?s(e[w+1].id):f>0&&w>0?s(e[w-1].id):f>0&&w===0&&i?.onSwipeOutLeft?i.onSwipeOutLeft():f<0&&w===e.length-1&&i?.onSwipeOutRight&&i.onSwipeOutRight()},[e,n,s,i]);return{onTouchStart:c,onTouchEnd:h}}const Iy=[{key:"overview",label:"Overview",icon:"▦"},{key:"mind",label:"Mind",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:"♡"}],u_={idle:"bg-green-400",working:"bg-blue-400 animate-pulse",paused:"bg-amber-400",offline:"bg-gray-500",error:"bg-red-400"};function Od(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString()}function f_({agentId:e,onBack:n,inline:s,defaultTab:i,onSwipeBack:l,highlightMailboxId:d}){const c=$r(),[h,m]=v.useState(null),[f,x]=v.useState(i??"overview"),[p,g]=v.useState(null),y=v.useMemo(()=>Iy.map(k=>({id:k.key})),[]),w=v.useMemo(()=>({onSwipeOutLeft:l}),[l]),N=ca(y,f,x,w),T=v.useRef(null);v.useEffect(()=>{const k=T.current;if(!k)return;k.querySelector('[data-active="true"]')?.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})},[f]);const C=v.useCallback(()=>{se.agents.get(e).then(m).catch(()=>{})},[e]);if(v.useEffect(()=>(x(i??"overview"),g(null),C(),se.externalAgents.list().then(M=>{const D=M.agents.find(A=>A.markusAgentId===e);g(D??null)}).catch(()=>{}),Jt.on("agent:update",M=>{M.payload.agentId===e&&C()})),[e,C]),!h)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm",children:"Loading agent..."});const _=u_[h.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:h.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:h.name}),t.jsx("span",{className:`w-2 h-2 rounded-full ${_}`}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:h.state.status}),p&&t.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-brand-500/15 text-brand-500 rounded font-medium",children:"External"}),h.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:[h.role,h.roleDescription?` — ${h.roleDescription}`:""]})]}),t.jsxs("div",{className:"flex gap-1.5 shrink-0",children:[!s&&t.jsxs("button",{onClick:()=>ht.navigate(me.TEAM,{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(h)try{const{filesMap:k}=await se.agents.getFilesMap(e),M={type:"agent",name:h.name.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"")||h.name,displayName:h.name,version:"1.0.0",description:h.roleDescription??h.role,author:"",category:"general",tags:[],agent:{roleName:h.role,agentRole:h.agentRole},dependencies:{skills:h.skills??[]}};await Zn.publishViaProxy({itemType:"agent",name:h.name,description:M.description,category:"general",config:M,files:k}),alert(`Published "${h.name}" to Markus Hub`)}catch(k){alert(`Failed to publish: ${k}`)}},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:n,className:"p-1.5 text-fg-tertiary hover:text-fg-secondary text-lg leading-none",children:"×"})]})]}),t.jsx("div",{ref:T,className:"flex gap-1 mt-3 -mb-[1px] overflow-x-auto scrollbar-hide",children:Iy.filter(k=>!p||["overview","mind"].includes(k.key)).map(k=>t.jsxs("button",{onClick:()=>x(k.key),"data-active":f===k.key,className:`px-3 py-1.5 text-xs rounded-t-lg border border-b-0 transition-colors whitespace-nowrap ${f===k.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:k.icon}),k.label]},k.key))})]}),t.jsxs("div",{className:"p-5",onTouchStart:c?N.onTouchStart:void 0,onTouchEnd:c?N.onTouchEnd:void 0,children:[f==="overview"&&t.jsx(h_,{agent:h,onUpdate:C,externalInfo:p}),f==="mind"&&t.jsx(S_,{agentId:e,highlightId:d}),f==="files"&&t.jsx(m_,{agentId:e}),f==="tools"&&t.jsx(g_,{tools:h.tools??[]}),f==="skills"&&t.jsx(b_,{agent:h}),f==="memory"&&t.jsx(y_,{agentId:e}),f==="heartbeat"&&t.jsx(v_,{agentId:e,initialData:h.heartbeat})]})]})}function h_({agent:e,onUpdate:n,externalInfo:s}){const[i,l]=v.useState(!1),[d,c]=v.useState(e.name),[h,m]=v.useState(e.agentRole),[f,x]=v.useState(e.config?.llmConfig?.modelMode??"default"),[p,g]=v.useState(e.config?.llmConfig.primary??""),[y,w]=v.useState(e.config?.llmConfig.fallback??""),[N,T]=v.useState(!1),[C,_]=v.useState({}),[k,M]=v.useState(""),[D,A]=v.useState([]),[G,X]=v.useState(null),[K,$]=v.useState(null),[q,U]=v.useState([]),[z,E]=v.useState(null),[L,R]=v.useState(null),[F,Y]=v.useState("");v.useEffect(()=>{se.settings.getLlm().then(S=>{_(S.providers),M(S.defaultProvider)}).catch(()=>{}),se.tasks.list({assignedAgentId:e.id}).then(S=>A(S.tasks.slice(0,5))).catch(()=>{}),se.usage.agents().then(S=>{const H=S.agents.find(W=>W.agentId===e.id);H&&X(H)}).catch(()=>{}),se.agents.getRecentActivities(e.id).then(S=>U(S.activities)).catch(()=>{}),se.system.storage().then(S=>{Y(S.dataDir+"/agents/"+e.id);const H=S.agents.find(W=>W.id===e.id);H&&R(H)}).catch(()=>{})},[e.id]);const Z=Object.entries(C).filter(([,S])=>S.configured).map(([S])=>S),B=e.config?.llmConfig?.modelMode??"default",O=async()=>{T(!0);try{await se.agents.updateConfig(e.id,{name:d,agentRole:h,llmConfig:{modelMode:f,primary:f==="custom"?p:k,fallback:y||void 0}}),n(),l(!1)}catch{}T(!1)},V=()=>{e.state.status==="offline"?se.agents.start(e.id).then(n):se.agents.stop(e.id).then(n)},I={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 S=[{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)"}],H=[{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(Rn,{title:"Identity",children:t.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:[t.jsx(Fn,{label:"Name",children:e.name}),t.jsx(Fn,{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(Fn,{label:"Role Template",children:e.role}),t.jsx(Fn,{label:"Markus Agent ID",mono:!0,children:e.id}),t.jsx(Fn,{label:"Organization",children:e.config?.orgId??"default"}),t.jsx(Fn,{label:"Created",children:e.config?.createdAt?new Date(e.config.createdAt).toLocaleDateString():"—"})]})}),t.jsx(Rn,{title:"Connection Status",children:t.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[t.jsx(rr,{label:"Connection",value:s.connected?"Online":"Offline",color:s.connected?"green":"gray"}),t.jsx(rr,{label:"Platform",value:"OpenClaw"}),t.jsx(rr,{label:"Active Tasks",value:String(e.state.activeTaskIds?.length??0)}),t.jsx(rr,{label:"Last Sync",value:s.lastHeartbeat?new Date(s.lastHeartbeat).toLocaleTimeString():"Never"})]})}),t.jsx(Rn,{title:"External Agent Details",children:t.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:[t.jsx(Fn,{label:"External Agent ID",mono:!0,children:s.externalAgentId}),t.jsx(Fn,{label:"Registered",children:new Date(s.registeredAt).toLocaleString()}),t.jsx(Fn,{label:"Capabilities",children:s.capabilities.length>0?s.capabilities.join(", "):"none declared"}),t.jsx(Fn,{label:"Last Heartbeat",children:s.lastHeartbeat?new Date(s.lastHeartbeat).toLocaleString():"Never"})]})}),t.jsx(Rn,{title:"Sync Context (received every sync cycle)",children:t.jsx("div",{className:"space-y-1.5",children:H.map(W=>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:W.field}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:W.desc})]},W.field))})}),t.jsx(Rn,{title:"Gateway API Endpoints",children:t.jsx("div",{className:"space-y-1.5",children:S.map(W=>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 ${W.method==="POST"?"text-amber-600":"text-green-600"}`,children:W.method}),t.jsx("span",{className:"font-mono text-[10px] text-fg-secondary shrink-0 pt-0.5",children:W.path}),t.jsx("span",{className:"text-[10px] text-fg-tertiary ml-auto",children:W.desc})]},W.path))})}),D.length>0&&t.jsx(Rn,{title:"Recent Tasks",action:t.jsx("button",{onClick:()=>ht.navigate(me.WORK),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:D.map(W=>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 ${I[W.status]??"bg-gray-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:W.title}),t.jsx("span",{className:"text-[10px] text-fg-tertiary capitalize shrink-0",children:W.status.replace(/_/g," ")})]},W.id))})})]})}return t.jsxs("div",{className:"space-y-4",children:[t.jsx(Rn,{title:"Identity",action:i?t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>l(!1),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Cancel"}),t.jsx("button",{onClick:O,disabled:N,className:"text-xs text-brand-500 hover:text-brand-500",children:N?"Saving...":"Save"})]}):t.jsx("button",{onClick:()=>{l(!0),c(e.name),m(e.agentRole),x(e.config?.llmConfig?.modelMode??"default"),g(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(Fn,{label:"Name",children:i?t.jsx("input",{className:"input-sm",value:d,onChange:S=>c(S.target.value)}):e.name}),t.jsx(Fn,{label:"Agent Role",children:i?t.jsx("div",{className:"flex gap-1.5",children:["worker","manager"].map(S=>t.jsx("button",{onClick:()=>m(S),className:`px-2 py-1 text-[10px] rounded border transition-colors capitalize ${h===S?S==="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:S},S))}):t.jsx("span",{className:e.agentRole==="manager"?"text-amber-600":"text-blue-600",children:e.agentRole==="manager"?"★ Manager":"◆ Worker"})}),t.jsx(Fn,{label:"Role Template",children:e.role}),t.jsx(Fn,{label:"Agent ID",mono:!0,children:e.id}),t.jsx(Fn,{label:"Organization",children:e.config?.orgId??"default"}),t.jsx(Fn,{label:"Created",children:e.config?.createdAt?new Date(e.config.createdAt).toLocaleDateString():"—"})]})}),t.jsxs(Rn,{title:"Runtime Status",children:[t.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[t.jsx(rr,{label:"Status",value:e.state.status,color:e.state.status==="idle"?"green":e.state.status==="working"?"blue":e.state.status==="error"?"red":"gray"}),t.jsx(rr,{label:"Tokens Today",value:String(e.state.tokensUsedToday)}),t.jsx(rr,{label:"Active Tasks",value:String(e.state.activeTaskIds?.length??0)}),t.jsx(rr,{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:D.filter(S=>e.state.activeTaskIds?.includes(S.id)).map(S=>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:S.title}),t.jsx("span",{className:"text-fg-tertiary capitalize shrink-0",children:S.status.replace(/_/g," ")})]},S.id))})]}),t.jsx("div",{className:"flex gap-2 mt-4 pt-3 border-t border-border-default/50",children:t.jsx("button",{onClick:V,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(Rn,{title:"Usage",children:t.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[t.jsx(rr,{label:"Total Tokens",value:Od(G.totalTokens)}),t.jsx(rr,{label:"Requests",value:String(G.requestCount)}),t.jsx(rr,{label:"Tool Calls",value:String(G.toolCalls)}),t.jsx(rr,{label:"Prompt Tokens",value:Od(G.promptTokens)}),t.jsx(rr,{label:"Completion Tokens",value:Od(G.completionTokens)}),t.jsx(rr,{label:"Est. Cost",value:`$${G.estimatedCost<.01?G.estimatedCost.toFixed(4):G.estimatedCost.toFixed(2)}`})]})}),L&&t.jsxs(Rn,{title:"Storage",action:t.jsx("button",{onClick:()=>{se.system.openPath(F)},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:zy(L.size)}),t.jsx("span",{className:"text-xs text-fg-tertiary font-mono truncate",children:F})]}),t.jsx("div",{className:"grid grid-cols-3 gap-3",children:L.subItems.filter(S=>S.size>0).map(S=>t.jsx(rr,{label:S.name,value:zy(S.size)},S.name))})]}),t.jsx(Rn,{title:"LLM Configuration",children:t.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:[t.jsx(Fn,{label:"Model Mode",children:i?t.jsx("div",{className:"flex gap-1.5",children:["default","custom"].map(S=>t.jsx("button",{onClick:()=>x(S),className:`px-2.5 py-1 text-[10px] rounded border transition-colors capitalize ${f===S?S==="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:S==="default"?"System Default":"Custom"},S))}):t.jsx("span",{className:`text-xs ${B==="custom"?"text-amber-600":"text-brand-500"}`,children:B==="custom"?"⚙ Custom":"◎ System Default"})}),t.jsx(Fn,{label:"Primary Model",children:i?f==="custom"?t.jsxs("select",{className:"input-sm",value:p,onChange:S=>g(S.target.value),children:[Z.map(S=>t.jsxs("option",{value:S,children:[S," (",C[S]?.model,")"]},S)),!Z.includes(p)&&p&&t.jsx("option",{value:p,children:p})]}):t.jsxs("span",{className:"text-xs text-fg-secondary italic",children:["follows system default (",k||"...",")"]}):t.jsx("span",{className:"font-mono text-xs",children:B==="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(Fn,{label:"Fallback",children:i?t.jsxs("select",{className:"input-sm",value:y,onChange:S=>w(S.target.value),children:[t.jsx("option",{value:"",children:"none"}),Z.map(S=>t.jsx("option",{value:S,children:S},S))]}):t.jsx("span",{className:"font-mono text-xs",children:e.config?.llmConfig.fallback??"none"})}),t.jsx(Fn,{label:"Max Tokens/Request",children:e.config?.llmConfig.maxTokensPerRequest??"default"}),t.jsx(Fn,{label:"Max Tokens/Day",children:e.config?.llmConfig.maxTokensPerDay??"unlimited"})]})}),D.length>0&&t.jsx(Rn,{title:"Recent Tasks",action:t.jsx("button",{onClick:()=>ht.navigate(me.WORK),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:D.map(S=>{const H=K===S.id,W=["in_progress","failed","completed","review"].includes(S.status);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>W?$(H?null:S.id):void 0,className:`w-full flex items-center gap-2.5 px-5 py-2.5 text-left transition-colors ${W?"hover:bg-surface-elevated/40 cursor-pointer":"cursor-default"}`,children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${I[S.status]??"bg-gray-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:S.title}),t.jsx("span",{className:"text-[10px] text-fg-tertiary capitalize shrink-0",children:S.status.replace(/_/g," ")}),W&&t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:H?"▲":"▼"})]}),H&&t.jsx("div",{className:"border-t border-border-default/60 bg-surface-primary/40",children:t.jsx(Yj,{taskId:S.id,isLive:S.status==="in_progress"})})]},S.id)})})}),q.filter(S=>S.type==="heartbeat").length>0&&t.jsx(Rn,{title:"Recent Heartbeats",action:t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[q.filter(S=>S.type==="heartbeat").length," runs"]}),children:t.jsx("div",{className:"divide-y divide-gray-800/50 -mx-5",children:q.filter(S=>S.type==="heartbeat").map(S=>{const H=z===S.id;return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>E(H?null:S.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:S.label}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date(S.startedAt).toLocaleString()}),t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:H?"▲":"▼"})]}),H&&t.jsx("div",{className:"border-t border-border-default/60 bg-surface-primary/40",children:t.jsx(Fd,{agentId:e.id,activityId:S.id})})]},S.id)})})}),q.filter(S=>S.type==="chat").length>0&&t.jsx(Rn,{title:"Recent A2A Communications",action:t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[q.filter(S=>S.type==="chat").length," conversations"]}),children:t.jsx("div",{className:"divide-y divide-gray-800/50 -mx-5",children:q.filter(S=>S.type==="chat").map(S=>{const H=z===S.id;return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>E(H?null:S.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:S.label}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date(S.startedAt).toLocaleString()}),t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:H?"▲":"▼"})]}),H&&t.jsx("div",{className:"border-t border-border-default/60 bg-surface-primary/40",children:t.jsx(Fd,{agentId:e.id,activityId:S.id})})]},S.id)})})})]})}function m_({agentId:e}){const[n,s]=v.useState([]),[i,l]=v.useState(!0),[d,c]=v.useState(null),[h,m]=v.useState(""),[f,x]=v.useState(!1),[p,g]=v.useState(!1),[y,w]=v.useState(null),[N,T]=v.useState(!1),[C,_]=v.useState(null),k=v.useCallback(()=>{l(!0),Promise.all([se.agents.getFiles(e),se.agents.roleStatus(e).catch(()=>null)]).then(([U,z])=>{s(U.files),w(z),U.files.length>0&&!d&&(c(U.files[0].name),m(U.files[0].content))}).catch(()=>{}).finally(()=>l(!1))},[e]);v.useEffect(()=>{k()},[k]);const M=U=>{const z=n.find(E=>E.name===U);z&&(c(U),m(z.content),g(!1),_(null))},D=async()=>{if(d){x(!0);try{await se.agents.updateFile(e,d,h),s(U=>U.map(z=>z.name===d?{...z,content:h}:z)),g(!1),d==="ROLE.md"&&await se.agents.updateSystemPrompt(e,h)}catch{}x(!1)}},A=async U=>{T(!0);try{await se.agents.roleSync(e,U?[U]:void 0),_(null),g(!1),k()}catch{}T(!1)},G=async U=>{if(C?.file===U){_(null);return}try{const z=await se.agents.roleDiff(e,U);z.agentContent!=null&&z.templateContent!=null&&_({file:U,agent:z.agentContent,template:z.templateContent})}catch{}};if(i)return t.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:"Loading files..."});const X={"ROLE.md":"System Prompt / Role Definition","HEARTBEAT.md":"Heartbeat Tasks","POLICIES.md":"Policies & Guardrails","CONTEXT.md":"Context & Instructions"},K=y?.files.filter(U=>U.status==="modified"||U.status==="added_in_template")??[],$=y?.hasTemplate&&!y.isUpToDate,q=d?K.some(U=>U.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:[K.length," file",K.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:"," ",K.map(U=>U.file).join(", ")]})]}),t.jsx("button",{onClick:()=>A(),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(Rn,{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:n.map(U=>{const z=K.some(E=>E.file===U.name);return t.jsxs("button",{onClick:()=>M(U.name),className:`px-3 py-1.5 text-xs rounded-lg border transition-colors relative ${d===U.name?"bg-brand-600/15 border-brand-500/40 text-brand-500":"border-border-default text-fg-tertiary hover:text-fg-secondary"}`,children:[U.name,z&&t.jsx("span",{className:"absolute -top-1 -right-1 w-2 h-2 bg-amber-400 rounded-full"})]},U.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:X[d]??d}),t.jsxs("div",{className:"flex gap-2 items-center",children:[q&&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:C?.file===d?"Hide Diff":"View Diff"}),t.jsx("button",{onClick:()=>A(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"})]}),p&&t.jsx("span",{className:"text-[10px] text-amber-600",children:"unsaved"}),t.jsx("button",{onClick:D,disabled:f||!p,className:`px-3 py-1 text-xs rounded-lg transition-colors ${p?"bg-brand-600 hover:bg-brand-500 text-white":"bg-surface-elevated text-fg-tertiary cursor-default"}`,children:f?"Saving...":"Save"})]})]}),C?.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:C.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:C.template})]})]}),t.jsx("textarea",{value:h,onChange:U=>{m(U.target.value),g(!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."})]}),n.length===0&&t.jsx(hl,{text:"No configuration files found for this role"})]})]})}const x_={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 p_(e){const n=new Map,s=new Set;for(const[d,c]of Object.entries(x_)){const h=e.filter(m=>c.some(f=>m.name.startsWith(f)));h.length>0&&(n.set(d,h),h.forEach(m=>s.add(m.name)))}const i=e.filter(d=>!s.has(d.name));for(const d of i){const c=d.name.indexOf("__");if(c>0){const m=`MCP: ${d.name.slice(0,c)}`;n.has(m)||n.set(m,[]),n.get(m).push(d),s.add(d.name)}}const l=e.filter(d=>!s.has(d.name));return l.length>0&&n.set("Other",l),[...n.entries()].map(([d,c])=>({category:d,tools:c}))}function g_({tools:e}){const n=p_(e);return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[e.length," tools registered"]}),n.map(s=>t.jsx(Rn,{title:s.category,children:t.jsx("div",{className:"grid grid-cols-2 gap-2",children:s.tools.map(i=>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:i.name}),t.jsx("div",{className:"text-[10px] text-fg-tertiary truncate",children:i.description})]})]},i.name))})},s.category)),e.length===0&&t.jsx("div",{className:"text-center py-12 text-fg-tertiary text-sm",children:"No tools registered"})]})}function b_({agent:e}){const n=e.proficiency??{},[s,i]=v.useState(null),[l,d]=v.useState(null),[c,h]=v.useState(!1),m=e.availableSkills??[],f=new Map;for(const N of m){const T=N.category||"custom";f.has(T)||f.set(T,[]),f.get(T).push(N)}const x=async N=>{if(s===N){i(null),d(null);return}i(N),h(!0);try{const T=await fetch(`/api/skills/${encodeURIComponent(N)}`);if(T.ok){const C=await T.json();d(C.skill)}else d(null)}catch{d(null)}h(!1)},p={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"},g=N=>{const T=n[N.name],C=T&&T.uses>0?Math.round(T.successes/T.uses*100):null,_=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 ${_?"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 ${_?"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}),T&&t.jsxs("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:[T.uses," uses · ",T.successes," successes",T.lastUsed&&` · last ${new Date(T.lastUsed).toLocaleDateString()}`]})]}),C!==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 ${C>=80?"bg-green-400":C>=50?"bg-amber-400":"bg-red-400"}`,style:{width:`${C}%`}})}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary w-8 text-right",children:[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…"}):l?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 ${p[l.category]??p.custom}`,children:l.category}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["v",l.version]}),l.author&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["by ",l.author]}),l.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))]}),l.description&&t.jsx("p",{className:"text-xs text-fg-secondary leading-relaxed",children:l.description}),l.tags&&l.tags.length>0&&t.jsx("div",{className:"flex gap-1 flex-wrap",children:l.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))}),(l.toolDetails??l.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 (",(l.toolDetails??l.tools??[]).length,")"]}),t.jsx("div",{className:"space-y-1.5",children:(l.toolDetails??l.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,T)=>{const C=y.indexOf(N[0]),_=y.indexOf(T[0]);return(C===-1?999:C)-(_===-1?999:_)});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,T])=>t.jsx(Rn,{title:t.jsxs("span",{className:"capitalize",children:[N," ",t.jsxs("span",{className:"text-fg-tertiary font-normal",children:["(",T.length,")"]})]}),children:t.jsx("div",{className:"space-y-2",children:T.map(C=>g(C))})},N)),m.length===0&&t.jsx(hl,{text:"No skills installed"})]})}function y_({agentId:e}){const[n,s]=v.useState(null),[i,l]=v.useState(!0),[d,c]=v.useState("entries"),[h,m]=v.useState(!1),[f,x]=v.useState(""),[p,g]=v.useState(!1),[y,w]=v.useState(""),[N,T]=v.useState(!1),[C,_]=v.useState(null),[k,M]=v.useState(null),[D,A]=v.useState([]),[G,X]=v.useState(!1),K=v.useCallback(()=>{l(!0),se.agents.getMemory(e).then(z=>{s(z),x(z.recentDailyLogs??""),w(z.longTermMemory??"")}).catch(()=>{}).finally(()=>l(!1))},[e]);v.useEffect(()=>{K()},[K]);const $=async()=>{T(!0),await se.agents.updateDailyMemory(e,f).catch(()=>{}),T(!1),m(!1),K()},q=async()=>{T(!0),await se.agents.updateLongTermMemory(e,"User-edited",y).catch(()=>{}),T(!1),g(!1),K()};if(i)return t.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:"Loading memory..."});if(!n)return t.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:"Failed to load memory data"});const U=[{key:"entries",label:`Recent (${n.entries.length})`},{key:"sessions",label:`Sessions (${n.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:U.map(z=>t.jsx("button",{onClick:()=>c(z.key),className:`px-3 py-1.5 text-xs rounded-lg border transition-colors ${d===z.key?"bg-brand-600/15 border-brand-500/40 text-brand-500":"border-border-default text-fg-tertiary hover:text-fg-secondary"}`,children:z.label},z.key))}),d==="entries"&&t.jsx(Rn,{title:"Recent Memory Entries",children:n.entries.length===0?t.jsx(hl,{text:"No memory entries"}):t.jsx("div",{className:"space-y-1.5 max-h-[600px] overflow-y-auto",children:n.entries.map((z,E)=>{const L=C===E;return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>_(L?null:E),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 ${z.type==="fact"?"bg-blue-500/15 text-blue-600":z.type==="task"?"bg-green-500/15 text-green-600":z.type==="note"?"bg-brand-500/15 text-brand-500":"bg-surface-overlay text-fg-secondary"}`,children:z.type}),t.jsx("span",{className:`text-fg-secondary flex-1 min-w-0 ${L?"":"line-clamp-2"}`,children:z.content}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[z.importance!=null&&t.jsxs("span",{className:`px-1 py-0.5 rounded text-[9px] font-medium ${z.importance>=7?"bg-red-500/15 text-red-500":z.importance>=4?"bg-amber-500/15 text-amber-600":"bg-surface-overlay text-fg-tertiary"}`,children:["P",z.importance]}),t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:new Date(z.timestamp).toLocaleTimeString()}),t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:L?"▲":"▼"})]})]}),L&&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:z.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: ",z.type]}),z.importance!=null&&t.jsxs("span",{children:["Importance: ",z.importance]}),t.jsx("span",{children:new Date(z.timestamp).toLocaleString()})]})]})]},E)})})}),d==="sessions"&&t.jsx(Rn,{title:"Chat Sessions",children:n.sessions.length===0?t.jsx(hl,{text:"No sessions"}):t.jsx("div",{className:"space-y-1.5 max-h-[600px] overflow-y-auto",children:n.sessions.map(z=>{const E=k===z.id,L=async()=>{if(E){M(null),A([]);return}M(z.id),X(!0);try{const R=await se.agents.getMemorySession(e,z.id);A(R.messages)}catch{A([])}X(!1)};return t.jsxs("div",{children:[t.jsxs("button",{onClick:L,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:z.id}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[z.messageCount," msgs"]}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:new Date(z.updatedAt).toLocaleDateString()}),t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:E?"▲":"▼"})]}),E&&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..."}):D.length===0?t.jsx("div",{className:"text-[10px] text-fg-tertiary py-3 text-center",children:"No messages in this session"}):(()=>{const R=new Map;for(const F of D)F.role==="tool"&&F.toolCallId&&R.set(F.toolCallId,F.content);return t.jsx("div",{className:"divide-y divide-gray-700/30",children:D.filter(F=>F.role!=="tool").map((F,Y)=>t.jsxs("div",{className:"px-3 py-2",children:[(F.role==="user"||F.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 ${F.role==="user"?"bg-blue-500/15 text-blue-600":"bg-surface-overlay text-fg-secondary"}`,children:F.role}),t.jsx("div",{className:"text-xs text-fg-secondary",children:t.jsx(ir,{content:F.content,className:"text-xs text-fg-secondary"})})]}),F.role==="assistant"&&t.jsxs("div",{className:"space-y-1",children:[F.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(ir,{content:F.content,className:"text-xs text-fg-secondary"})})]}),F.toolCalls&&F.toolCalls.length>0&&t.jsx("div",{className:"space-y-0.5",children:F.toolCalls.map(Z=>{let B;try{B=JSON.parse(Z.arguments)}catch{}const O={tool:Z.name,status:"done",args:B,result:R.get(Z.id)};return t.jsx(Uj,{entry:{type:"tool",info:O}},Z.id)})})]})]},Y))})})()})]},z.id)})})}),d==="daily"&&t.jsx(Rn,{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:z=>x(z.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"}):n.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:n.recentDailyLogs}):t.jsx(hl,{text:"No daily logs"})}),d==="longterm"&&t.jsx(Rn,{title:"Long-term Memory",action:p?t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>g(!1),className:"text-xs text-fg-tertiary",children:"Cancel"}),t.jsx("button",{onClick:q,disabled:N,className:"text-xs text-brand-500",children:N?"Saving...":"Save"})]}):t.jsx("button",{onClick:()=>g(!0),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Edit"}),children:p?t.jsx("textarea",{value:y,onChange:z=>w(z.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"}):n.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:n.longTermMemory}):t.jsx(hl,{text:"No long-term memory stored"})})]})}function v_({agentId:e,initialData:n}){const[s,i]=v.useState(n??null),[l,d]=v.useState(!n),[c,h]=v.useState([]),[m,f]=v.useState(null),[x,p]=v.useState(!1),[g,y]=v.useState(null),w=v.useCallback(()=>{se.agents.getHeartbeat(e).then(i).catch(()=>{}),se.agents.getRecentActivities(e).then(_=>{h(_.activities.filter(k=>k.type==="heartbeat"))}).catch(()=>{})},[e]);v.useEffect(()=>{d(!0),w(),d(!1)},[w]),v.useEffect(()=>Jt.on("agent:update",k=>{k.payload?.agentId===e&&w()}),[e,w]);const N=async()=>{p(!0),y(null);try{const _=await se.agents.triggerHeartbeat(e);y(_.message),setTimeout(()=>y(null),4e3),setTimeout(w,2e3)}catch(_){y(String(_).replace("Error: ",""))}p(!1)};if(l)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 T=_=>_?_<1e3?`${_}ms`:_<6e4?`${(_/1e3).toFixed(1)}s`:`${(_/6e4).toFixed(1)}m`:null,C=_=>{if(!_)return null;const k=Date.now()-new Date(_).getTime();if(k<0){const M=Math.abs(k);return M<6e4?`in ${Math.ceil(M/1e3)}s`:M<36e5?`in ${Math.ceil(M/6e4)}m`:`in ${(M/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(Rn,{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(rr,{label:"Status",value:s.running?"Running":"Stopped",color:s.running?"green":"gray"}),t.jsx(rr,{label:"Interval",value:T(s.intervalMs)??"—"}),t.jsx(rr,{label:"Last Run",value:s.lastHeartbeat?C(s.lastHeartbeat)??"—":"Never"}),t.jsx(rr,{label:"Next Run",value:s.nextRunAt?C(s.nextRunAt)??"—":s.running?"Pending":"—"})]}),g&&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:g})]}),s.lastSummary&&t.jsx(Rn,{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(ir,{content:s.lastSummary,className:"text-xs text-fg-secondary leading-relaxed"})})}),c.length>0?t.jsx(Rn,{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(_=>{const k=m===_.id;return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>f(k?null:_.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:_.label}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:[_.logCount," actions"]}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date(_.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(Fd,{agentId:e,activityId:_.id})})]},_.id)})})}):s.lastHeartbeat?null:t.jsx(Rn,{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 ~${T(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 Yj({taskId:e,isLive:n}){const[s,i]=v.useState([]),[l,d]=v.useState(""),[c,h]=v.useState(!0),[m,f]=v.useState("compact");if(v.useEffect(()=>{h(!0),d(""),se.tasks.getLogs(e).then(g=>{i(g.logs),h(!1)}).catch(()=>h(!1))},[e]),v.useEffect(()=>{if(!n)return;const g=Jt.on("task:log",w=>{const N=w.payload;if(N.taskId!==e)return;const T={id:N.id,taskId:N.taskId,agentId:N.agentId,seq:N.seq,type:N.logType,content:N.content,metadata:N.metadata,createdAt:N.createdAt};i(C=>T.id&&C.some(_=>_.id===T.id)?C:[...C,T]),T.type==="text"&&d("")}),y=Jt.on("task:log:delta",w=>{const N=w.payload;N.taskId===e&&d(T=>T+N.text)});return()=>{g(),y()}},[e,n]),c)return t.jsx("div",{className:"px-4 py-3 text-xs text-fg-tertiary",children:"Loading..."});if(s.length===0&&!l)return t.jsx("div",{className:"px-4 py-3 text-xs text-fg-tertiary",children:"No execution logs yet."});const x=s.map(g=>bm(g)),p=new Set(x.filter(g=>g.executionRound!=null).map(g=>g.executionRound)).size>1;return t.jsx("div",{className:"px-3 py-2",children:m==="compact"?t.jsx(Ex,{entries:x,streamingText:l,isActive:n,onExpand:()=>f("full"),showRounds:p}):t.jsx(du,{entries:x,streamingText:l,isActive:n,onCollapse:()=>f("compact"),showRounds:p})})}function Fd({agentId:e,activityId:n,isLive:s=!1}){const[i,l]=v.useState([]),[d,c]=v.useState(!0),[h,m]=v.useState("compact");if(v.useEffect(()=>{c(!0),se.agents.getActivityLogs(e,n).then(x=>{l(x.logs),c(!1)}).catch(()=>c(!1))},[e,n]),v.useEffect(()=>s?Jt.on("agent:activity_log",p=>{const g=p.payload;if(g.agentId!==e||g.activityId!==n)return;const y={seq:g.seq,type:g.type,content:g.content,metadata:g.metadata,createdAt:g.createdAt};l(w=>w.some(N=>N.seq===y.seq)?w:[...w,y])}):void 0,[e,n,s]),d)return t.jsx("div",{className:"px-4 py-3 text-xs text-fg-tertiary",children:"Loading..."});if(i.length===0)return t.jsx("div",{className:"px-4 py-3 text-xs text-fg-tertiary",children:"No activity logs available."});const f=i.map(x=>_1(x,n,e)).filter(x=>x!==null);return t.jsx("div",{className:"px-3 py-2",children:h==="compact"?t.jsx(Ex,{entries:f,isActive:s,onExpand:()=>m("full")}):t.jsx(du,{entries:f,isActive:s,onCollapse:()=>m("compact")})})}function Rn({title:e,action:n,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}),n]}),s]})}function Fn({label:e,mono:n,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 ${n?"font-mono text-[10px]":""}`,children:s})]})}function rr({label:e,value:n,color:s}){const i=s==="green"?"text-green-600":s==="blue"?"text-blue-500":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 ${i}`,children:n}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:e})]})}function hl({text:e}){return t.jsx("div",{className:"text-xs text-fg-tertiary py-6 text-center",children:e})}function zy(e){if(e===0)return"0 B";const n=["B","KB","MB","GB"],s=Math.min(Math.floor(Math.log(e)/Math.log(1024)),n.length-1),i=e/Math.pow(1024,s);return`${i<10?i.toFixed(1):Math.round(i)} ${n[s]}`}const $y={0:"Critical",1:"High",2:"Normal",3:"Low",4:"Background"},By={0:"text-red-400",1:"text-amber-400",2:"text-fg-secondary",3:"text-fg-tertiary",4:"text-fg-tertiary/60"},j_={pick:"bg-brand-500/20 text-brand-300",continue:"bg-gray-500/20 text-gray-300",preempt:"bg-amber-500/20 text-amber-300",merge:"bg-blue-500/20 text-blue-300",defer:"bg-purple-500/20 text-purple-300",delegate:"bg-green-500/20 text-green-300",drop:"bg-red-500/20 text-red-300"},w_={idle:"bg-green-500/20 text-green-300",focused:"bg-brand-500/20 text-brand-300",deciding:"bg-amber-500/20 text-amber-300"},Xh={system_event:"⚙",human_chat:"💬",task_comment:"💬",mention:"@",session_reply:"↩",task_status_update:"📋",a2a_message:"🔗",review_request:"👀",requirement_update:"📝",requirement_comment:"💬",daily_report:"📊",heartbeat:"♡",memory_consolidation:"🧠"},N_=[{key:"all",label:"All"},{key:"interaction",label:"Interaction"},{key:"task",label:"Task"},{key:"notification",label:"Notification"},{key:"system",label:"System"}],k_={completed:"bg-green-500",processing:"bg-blue-400 animate-pulse",deferred:"bg-purple-400",merged:"bg-cyan-400",queued:"bg-amber-400",dropped:"bg-red-500"},Hy={pending:{label:"Pending",color:"text-gray-400"},assigned:{label:"Assigned",color:"text-blue-400"},in_progress:{label:"In Progress",color:"text-brand-400"},completed:{label:"Completed",color:"text-green-400"},failed:{label:"Failed",color:"text-red-400"},cancelled:{label:"Cancelled",color:"text-gray-500"},review:{label:"Review",color:"text-amber-400"},approved:{label:"Approved",color:"text-green-500"},rejected:{label:"Rejected",color:"text-red-500"},draft:{label:"Draft",color:"text-gray-400"}};function Kh(e){const n=e.match(/Comment from .+?:\s*(.+?)(?:\n\n\*\*MANDATORY|\n\n---|\n\n\[|$)/s);if(n?.[1]){const s=n[1].trim().replace(/\n/g," ");return s.length>80?s.slice(0,80)+"…":s}}function Py(e){const n=e.payload,s=n?.summary??"",i=n?.content??"",l=e.metadata?.senderName;switch(e.sourceType){case"task_status_update":{const d=s.match(/^Task "(.+?)" status:/),c=s.match(/status:\s*(\S+)\s*→\s*(\S+)/),h=d?.[1]??s;if(c){const f=c[1],x=c[2],p=Hy[f]??{label:f},g=Hy[x]??{label:x,color:"text-fg-secondary"};return{title:h,subtitle:`${p.label} → ${g.label}`,badge:g}}const m=s.match(/^Task:\s*(.+)/);return m?{title:m[1]}:{title:h}}case"task_comment":{const d=s.match(/^Comment on task "(.+?)" from (.+?)(\s*\(\+\d+\))?$/),c=Kh(i);if(d){const h=c?`${d[2]}: ${c}`:`Comment from ${d[2]}`;return{title:d[1],subtitle:h}}return{title:s}}case"requirement_update":{const d=s.match(/^Requirement "(.+?)"\s+(.*)/);return d?{title:d[1],subtitle:d[2]}:{title:s}}case"requirement_comment":{const d=s.match(/^Comment on requirement "(.+?)" from (.+?)(\s*\(\+\d+\))?$/),c=Kh(i);if(d){const h=c?`${d[2]}: ${c}`:`Comment from ${d[2]}`;return{title:d[1],subtitle:h}}return{title:s}}case"human_chat":{const d=i.slice(0,120).replace(/\n/g," ");return{title:l?`Chat from ${l}`:"Human Chat",subtitle:d+(i.length>120?"…":"")}}case"a2a_message":{const d=i.slice(0,120).replace(/\n/g," ");return{title:l?`Message from ${l}`:"Agent Message",subtitle:d+(i.length>120?"…":"")}}case"mention":{const d=s.match(/from (.+)$/),c=Kh(i);return{title:d?`Mentioned by ${d[1]}`:"Mention",subtitle:c||void 0}}case"review_request":{const d=i.slice(0,120).replace(/\n/g," ");return{title:l?`Review request from ${l}`:"Review Request",subtitle:d+(i.length>120?"…":"")}}case"session_reply":{const d=i.slice(0,120).replace(/\n/g," ");return{title:l?`Reply in session (${l})`:"Session Reply",subtitle:d+(i.length>120?"…":"")}}case"heartbeat":return{title:"Scheduled heartbeat check-in"};case"daily_report":return{title:"Daily Report"};case"memory_consolidation":return{title:"Memory Consolidation"};case"system_event":{const d=s.match(/^\[Announcement]\s*(.+)/);return d?{title:d[1],subtitle:"System Announcement"}:{title:s||"System Event"}}default:return{title:s||e.sourceType}}}function S_({agentId:e,highlightId:n}){const[s,i]=v.useState(null),[l,d]=v.useState(null),[c,h]=v.useState(!0),[m,f]=v.useState("all"),[x,p]=v.useState("all"),[g,y]=v.useState(n??null),[w,N]=v.useState(n??null),[T,C]=v.useState(!0),_=50,k=v.useCallback(async(A=!0)=>{A&&h(!0);try{const G=m==="all"?void 0:m,X=x==="all"?void 0:x,[K,$]=await Promise.all([se.agents.getMindState(e),se.agents.getMailbox(e,{limit:_,category:G,status:X})]);i(K),d($),C(($.history?.length??0)>=_)}catch{}h(!1)},[e,m,x]),M=v.useCallback(async()=>{if(!l)return;const A=m==="all"?void 0:m,G=x==="all"?void 0:x;try{const X=await se.agents.getMailbox(e,{limit:_,offset:l.history.length,category:A,status:G});d(K=>K?{...K,history:[...K.history,...X.history]}:X),C((X.history?.length??0)>=_)}catch{}},[e,l,m,x]);v.useEffect(()=>{y(n??null),N(n??null),k()},[k,n]);const D=v.useRef(!1);return v.useEffect(()=>{if(!w||c)return;if(l?.history?.some(G=>G.id===w)){D.current=!1;const G=document.getElementById(`mbx-${w}`);if(G){setTimeout(()=>G.scrollIntoView({behavior:"smooth",block:"center"}),100);const X=setTimeout(()=>N(null),3e3);return()=>clearTimeout(X)}}else T&&!D.current&&(D.current=!0,(async()=>{let G=l?.history??[],X=T;for(;X;)try{const K=await se.agents.getMailbox(e,{limit:_,offset:G.length}),$=[...G,...K.history];G=$,X=(K.history?.length??0)>=_;const q=K.history.some(U=>U.id===w);if(d(U=>U?{...U,history:$}:K),C(X),q||!X)break}catch{break}D.current=!1})())},[w,c,l,T,e]),v.useEffect(()=>{const A=X=>{X.payload?.agentId===e&&k(!1)},G=[Jt.on("agent:mailbox",A),Jt.on("agent:decision",A),Jt.on("agent:attention",A),Jt.on("agent:focus",A),Jt.on("agent:update",A),Jt.on("agent:triage",A)];return()=>G.forEach(X=>X())},[e,k]),c&&!s?t.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:"Loading agent mind state..."}):t.jsxs("div",{className:"space-y-4",children:[t.jsxs("section",{children:[t.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[t.jsx("span",{className:`px-2.5 py-1 text-xs font-medium rounded-full ${w_[s?.attentionState??"idle"]??"bg-gray-500/20 text-gray-300"}`,children:(s?.attentionState??"idle").toUpperCase()}),s?.currentFocus?(()=>{const A=Py({id:s.currentFocus.mailboxItemId,sourceType:s.currentFocus.type,payload:{summary:s.currentFocus.label,taskId:s.currentFocus.taskId},metadata:{},queuedAt:s.currentFocus.startedAt});return t.jsxs("span",{className:"text-sm text-fg-secondary",children:[Xh[s.currentFocus.type]??"●"," ",t.jsx("span",{className:"text-fg-primary font-medium",children:A.title}),A.subtitle&&t.jsx("span",{className:"text-fg-tertiary ml-1.5 text-xs",children:A.subtitle}),t.jsxs("span",{className:"text-fg-tertiary ml-2 text-xs",children:["since ",new Date(s.currentFocus.startedAt).toLocaleTimeString()]})]})})():t.jsx("span",{className:"text-sm text-fg-tertiary",children:"Idle — waiting for new mail"}),t.jsx("button",{onClick:()=>{k()},className:"ml-auto text-xs text-fg-tertiary hover:text-fg-secondary active:text-fg-primary transition-colors",children:"↻ Refresh"})]}),(s?.queuedItems?.length??0)>0&&t.jsxs("div",{className:"mb-3",children:[t.jsxs("h4",{className:"text-xs font-medium text-amber-400 uppercase tracking-wider mb-1.5",children:["Queue (",s.queuedItems.length,")"]}),t.jsx("div",{className:"space-y-1",children:s.queuedItems.map((A,G)=>t.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded bg-amber-500/5 border border-amber-500/20 text-sm",children:[t.jsx("span",{className:"text-fg-tertiary w-4 text-right text-xs",children:G+1}),t.jsx("span",{className:"text-sm",children:Xh[A.sourceType]??"●"}),t.jsx("span",{className:`text-[10px] ${By[A.priority]??"text-fg-tertiary"}`,children:$y[A.priority]??`P${A.priority}`}),t.jsx("span",{className:"text-fg-secondary truncate flex-1 text-xs",children:A.summary}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:new Date(A.queuedAt).toLocaleTimeString()})]},A.id))})]})]}),s?.lastTriage&&t.jsxs("section",{className:"bg-surface-2 rounded-lg border border-indigo-500/20 p-3",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("span",{className:"text-sm",children:"🧠"}),t.jsx("h4",{className:"text-xs font-medium text-indigo-400 uppercase tracking-wider",children:"Triage Decision"}),t.jsx("span",{className:"text-[10px] text-fg-quaternary ml-auto",children:new Date(s.lastTriage.timestamp).toLocaleTimeString()})]}),t.jsx("p",{className:"text-xs text-fg-secondary leading-relaxed",children:s.lastTriage.reasoning}),t.jsxs("div",{className:"flex flex-wrap gap-2 mt-2 text-[10px]",children:[t.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-green-500/10 text-green-400",children:["Processing: ",s.lastTriage.processedItemId.slice(0,12),"…"]}),s.lastTriage.deferredItemIds.length>0&&t.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-400",children:["Deferred: ",s.lastTriage.deferredItemIds.length]}),s.lastTriage.droppedItemIds.length>0&&t.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-red-500/10 text-red-400",children:["Dropped: ",s.lastTriage.droppedItemIds.length]})]})]}),t.jsxs("section",{children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:"Mailbox History"}),t.jsx("div",{className:"flex gap-1 ml-auto flex-wrap",children:N_.map(A=>t.jsx("button",{onClick:()=>f(A.key),className:`px-2 py-0.5 text-[10px] rounded-md border transition-colors ${m===A.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:A.label},A.key))})]}),t.jsx("div",{className:"flex gap-1 mb-2 flex-wrap",children:[{key:"all",label:"All",dot:""},{key:"queued",label:"Queued",dot:"bg-amber-400"},{key:"processing",label:"Processing",dot:"bg-blue-400"},{key:"completed",label:"Completed",dot:"bg-green-500"},{key:"merged",label:"Merged",dot:"bg-cyan-400"},{key:"deferred",label:"Deferred",dot:"bg-purple-400"},{key:"dropped",label:"Dropped",dot:"bg-red-500"}].map(A=>t.jsxs("button",{onClick:()=>p(A.key),className:`px-2 py-0.5 text-[10px] rounded-md border transition-colors flex items-center gap-1 ${x===A.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:[A.dot&&t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${A.dot}`}),A.label]},A.key))}),(!l?.history||l.history.length===0)&&!c&&t.jsx("div",{className:"text-center text-fg-tertiary text-sm py-8",children:"No mailbox history yet"}),t.jsx("div",{className:"space-y-1",children:l?.history?.map(A=>{const G=g===A.id,X=Xh[A.sourceType]??"●",K=Py(A),$=A.metadata?.senderName,q=A.metadata?.senderRole,U=w===A.id;return t.jsxs("div",{id:`mbx-${A.id}`,className:`bg-surface-2 rounded-lg border transition-colors duration-1000 ${U?"border-brand-500 ring-1 ring-brand-500/40":"border-border-subtle"}`,children:[t.jsxs("button",{className:"w-full px-3 py-2.5 flex items-start gap-2 text-left hover:bg-surface-3/50 transition-colors rounded-lg",onClick:()=>y(G?null:A.id),children:[t.jsx("span",{className:"text-xs mt-0.5 text-fg-tertiary",children:G?"▾":"▸"}),t.jsx("span",{className:`w-2 h-2 mt-1.5 rounded-full shrink-0 ${k_[A.status]??"bg-gray-400"}`}),t.jsx("span",{className:"text-sm",children:X}),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 ${G?"":"truncate"}`,children:K.title}),K.badge&&t.jsx("span",{className:`text-[10px] font-medium shrink-0 ${K.badge.color}`,children:K.badge.label}),t.jsx("span",{className:`text-[10px] shrink-0 ${By[A.priority]??"text-fg-tertiary"}`,children:$y[A.priority]??""})]}),K.subtitle&&t.jsx("div",{className:`text-[11px] text-fg-secondary mt-0.5 ${G?"":"truncate"}`,children:K.subtitle}),t.jsxs("div",{className:"text-[10px] text-fg-tertiary mt-0.5 flex gap-2 flex-wrap",children:[t.jsx("span",{children:new Date(A.queuedAt).toLocaleString()}),A.completedAt&&t.jsxs("span",{children:["→ ",new Date(A.completedAt).toLocaleTimeString()]}),A.activity&&t.jsxs(t.Fragment,{children:[A.activity.totalTokens>0&&t.jsxs("span",{children:[Od(A.activity.totalTokens)," tokens"]}),A.activity.totalTools>0&&t.jsxs("span",{children:[A.activity.totalTools," tools"]})]})]})]}),t.jsx("span",{className:"text-[10px] text-fg-tertiary bg-surface-3 px-1.5 py-0.5 rounded shrink-0",children:A.sourceType})]}),G&&t.jsxs("div",{className:"border-t border-border-subtle px-3 py-3 space-y-3",children:[$&&t.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:["From: ",t.jsx("span",{className:"text-fg-secondary",children:$}),q&&t.jsxs("span",{className:"text-fg-tertiary",children:[" (",q,")"]})]}),A.payload?.content&&["human_chat","a2a_message","task_comment","requirement_comment","review_request","session_reply","mention"].includes(A.sourceType)&&t.jsx("div",{className:"text-xs text-fg-secondary bg-surface-primary/50 rounded-md p-2.5 whitespace-pre-wrap break-words max-h-60 overflow-y-auto",children:A.payload.content}),A.decisions&&A.decisions.length>0&&t.jsxs("div",{children:[t.jsx("h5",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider mb-1",children:"Decisions"}),t.jsx("div",{className:"space-y-1",children:A.decisions.map(z=>t.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[t.jsx("span",{className:`px-1.5 py-0.5 rounded shrink-0 ${j_[z.decisionType]??"bg-gray-500/20 text-gray-300"}`,children:z.decisionType}),t.jsx("span",{className:"text-fg-secondary flex-1",children:z.reasoning}),t.jsx("span",{className:"text-fg-tertiary shrink-0",children:new Date(z.createdAt).toLocaleTimeString()})]},z.id))})]}),A.activity?t.jsxs("div",{children:[t.jsxs("h5",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider mb-1",children:["Activity — ",A.activity.label,t.jsx("span",{className:`ml-2 inline-block px-1 py-0 rounded text-[9px] ${A.activity.success?"bg-green-500/15 text-green-400":"bg-red-500/15 text-red-400"}`,children:A.activity.success?"✓ Success":"✗ Failed"})]}),A.activity.type==="task"&&A.payload?.taskId?t.jsx(Yj,{taskId:A.payload.taskId,isLive:!A.activity.endedAt}):t.jsx(Fd,{agentId:e,activityId:A.activity.id,isLive:!A.activity.endedAt})]}):A.status==="processing"?t.jsx("div",{className:"text-xs text-fg-tertiary text-center py-2 animate-pulse",children:"Processing..."}):A.status==="completed"?t.jsx("div",{className:"text-xs text-fg-tertiary text-center py-2",children:"No activity log recorded"}):null]})]},A.id)})}),T&&(l?.history?.length??0)>0&&t.jsx("div",{className:"text-center mt-3",children:t.jsx("button",{onClick:M,className:"text-xs text-brand-400 hover:text-brand-300 transition-colors",children:"Load Earlier..."})})]})]})}const C_=[{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:"⚙"}],qy={idle:"bg-green-400",working:"bg-blue-400 animate-pulse",paused:"bg-amber-400",offline:"bg-gray-500",error:"bg-red-400"};function E_({teamId:e,onBack:n,inline:s}){const[i,l]=v.useState(null),[d,c]=v.useState("overview"),[h,m]=v.useState(""),[f,x]=v.useState(""),[p,g]=v.useState(!1),[y,w]=v.useState(!1),[N,T]=v.useState(""),[C,_]=v.useState(""),[k,M]=v.useState(!1),[D,A]=v.useState(!1),[G,X]=v.useState(""),[K,$]=v.useState(""),[q,U]=v.useState(!1),[z,E]=v.useState([]),L=v.useRef(null),R=v.useCallback(async()=>{try{const S=(await se.teams.list()).teams.find(W=>W.id===e);S&&l(S);const H=await se.teams.status(e);E(H.agents)}catch{}},[e]),F=v.useCallback(async()=>{try{const I=await se.teams.getFile(e,"ANNOUNCEMENT.md");m(I.content)}catch{m("")}try{const I=await se.teams.getFile(e,"NORMS.md");x(I.content)}catch{x("")}},[e]);v.useEffect(()=>{c("overview"),R(),F()},[e,R,F]);const Y=async(I,S)=>{M(!0);try{await se.teams.updateFile(e,I,S),I==="ANNOUNCEMENT.md"?(m(S),g(!1)):(x(S),w(!1))}catch{}M(!1)},Z=async()=>{G.trim()&&(await se.teams.update(e,{name:G.trim()}),A(!1),R())},B=async()=>{await se.teams.update(e,{description:K}),U(!1),R()};if(!i)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm",children:"Loading team..."});const O=i.members.find(I=>I.agentRole==="manager"),V=z.filter(I=>I.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:i.name}),t.jsxs("span",{className:"px-1.5 py-0.5 text-[10px] bg-brand-500/15 text-brand-500 rounded font-medium",children:[i.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:[V," online"]})]}),t.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:i.description||"No description"})]}),t.jsxs("button",{onClick:async()=>{if(i)try{const{files:I}=await se.teams.getFilesMap(i.id),S=i.members.filter(W=>W.type==="agent"),H={type:"team",name:i.name.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"")||i.name,displayName:i.name,version:"1.0.0",description:i.description??"",author:"",category:"general",tags:[],team:{members:S.map(W=>({name:W.name,roleName:W.role,role:W.agentRole??"worker",count:1,skills:[]}))}};await Zn.publishViaProxy({itemType:"team",name:i.name,description:i.description??"",category:"general",config:H,files:I}),alert(`Published "${i.name}" to Markus Hub`)}catch(I){alert(`Failed to publish: ${I}`)}},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:n,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:C_.map(I=>t.jsxs("button",{onClick:()=>c(I.key),className:`px-3 py-1.5 text-xs rounded-t-lg whitespace-nowrap transition-colors ${d===I.key?"bg-surface-primary text-fg-primary border border-border-default border-b-gray-950":"text-fg-tertiary hover:text-fg-secondary"}`,children:[I.icon," ",I.label]},I.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:O?.name??i.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:i.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:i.members.map(I=>{const S=z.find(W=>W.id===I.id),H=qy[S?.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 ${H}`}),t.jsx("span",{className:"font-medium",children:I.name}),t.jsx("span",{className:"text-fg-tertiary",children:I.role}),I.agentRole==="manager"&&t.jsx("span",{className:"text-[10px] px-1 py-0.5 bg-amber-500/15 text-amber-600 rounded",children:"Manager"})]},I.id)})})]})]}),d==="members"&&t.jsxs("div",{className:"space-y-3",children:[i.members.map(I=>{const S=z.find(W=>W.id===I.id),H=qy[S?.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:I.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:I.name}),t.jsx("span",{className:`w-2 h-2 rounded-full ${H}`}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:S?.status??"offline"}),I.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:[I.role," · ",I.type]})]})]},I.id)}),i.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"}),!p&&t.jsx("button",{onClick:()=>{T(h),g(!0)},className:"px-3 py-1 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary rounded-lg transition-colors",children:"Edit"})]}),p?t.jsxs("div",{className:"space-y-3",children:[t.jsx("textarea",{value:N,onChange:I=>T(I.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:()=>Y("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:()=>g(!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:()=>{_(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:C,onChange:I=>_(I.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:()=>Y("NORMS.md",C),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"}),D?t.jsxs("div",{className:"flex gap-2 items-center",children:[t.jsx("input",{ref:L,value:G,onChange:I=>X(I.target.value),onKeyDown:I=>I.key==="Enter"&&Z(),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:Z,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:()=>A(!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:i.name}),t.jsx("button",{onClick:()=>{X(i.name),A(!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"}),q?t.jsxs("div",{className:"space-y-2",children:[t.jsx("textarea",{value:K,onChange:I=>$(I.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:B,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:()=>U(!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:i.description||"No description"}),t.jsx("button",{onClick:()=>{$(i.description??""),U(!0)},className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Edit"})]})]})]}),t.jsx(T_,{teamId:e,teamName:i.name,onDeleted:n})]})]})]})}function T_({teamId:e,teamName:n,onDeleted:s}){const[i,l]=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"}),i?t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"text-xs text-fg-secondary",children:['Delete team "',n,'"? 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:p=>m(p.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:p=>c(p.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 se.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:()=>l(!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:()=>l(!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 fu({side:e,defaultWidth:n,minWidth:s,maxWidth:i,collapsedWidth:l=0,storageKey:d}){const[c,h]=v.useState(()=>{try{const y=localStorage.getItem(`${d}_w`);if(y)return Math.max(s,Math.min(i,parseInt(y,10)))}catch{}return n}),[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 p=v.useCallback(y=>{y.preventDefault(),x.current=!0;const w=y.clientX,N=c,T=_=>{if(!x.current)return;const k=e==="left"?_.clientX-w:w-_.clientX;h(Math.max(s,Math.min(i,N+k)))},C=()=>{x.current=!1,document.removeEventListener("mousemove",T),document.removeEventListener("mouseup",C),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",T),document.addEventListener("mouseup",C),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[c,e,s,i]),g=v.useCallback(()=>f(y=>!y),[]);return{width:m?l:c,rawWidth:c,collapsed:m,toggle:g,setCollapsed:f,onResizeStart:p}}const __={system_event:{icon:"⚙",category:"System"},human_chat:{icon:"💬",category:"Chat"},a2a_message:{icon:"🔗",category:"Chat"},task_comment:{icon:"📝",category:"Comment"},requirement_comment:{icon:"📝",category:"Comment"},mention:{icon:"@",category:"Mention"},session_reply:{icon:"↩",category:"Task"},task_status_update:{icon:"📋",category:"Task"},review_request:{icon:"👀",category:"Review"},requirement_update:{icon:"📝",category:"Notification"},daily_report:{icon:"📊",category:"System"},heartbeat:{icon:"♡",category:"System"},memory_consolidation:{icon:"🧠",category:"System"},notify_user:{icon:"🔔",category:"Notification"}},A_=new Set(["task_comment","requirement_comment","mention","notify_user"]);function Uy(e){const n={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};if(e.role!=="user"&&e.metadata?.segments&&e.metadata.segments.length>0&&(n.segments=e.metadata.segments.map((s,i)=>s.type==="tool"?{type:"tool",key:`${s.tool}_${i}`,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("⚠"))&&(n.isError=!0),e.metadata?.isStopped&&(n.isStopped=!0),e.metadata?.images?.length&&(n.images=e.metadata.images),e.metadata?.activityLog&&(n.isActivityLog=!0,n.activityType=e.metadata.activityType,n.outcome=e.metadata.outcome,n.mailboxItemId=e.metadata.mailboxItemId,n.taskId=e.metadata.taskId,n.requirementId=e.metadata.requirementId,!n.outcome&&n.text.startsWith("[ACTIVITY:"))){const s=n.text.lastIndexOf(" → ");s!==-1&&(n.outcome=n.text.slice(s+3)),n.text=n.text.replace(/^\[ACTIVITY:\s*\w+\]\s*/,"")}return n}function No(e){const n=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:n};if(e.metadata&&e.senderType==="agent"){const i=[],l=e.metadata;if(l.thinking?.length&&i.push({type:"text",content:"",thinking:l.thinking.join(`
|
|
51
|
-
|
|
52
|
-
`)}),l.toolCalls?.length)for(let d=0;d<l.toolCalls.length;d++){const c=l.toolCalls[d];i.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})}i.length>0&&(i.push({type:"text",content:e.text}),s.segments=i)}return s}function Gj(e){return e.split(" ").map(n=>n[0]).join("").toUpperCase().slice(0,2)}function M_({name:e,agentId:n,agents:s,onViewProfile:i}){const[l,d]=v.useState(!1),c=v.useRef(null),h=n?s.find(m=>m.id===n):s.find(m=>m.name===e);return v.useEffect(()=>{if(!l)return;const m=f=>{c.current&&!c.current.contains(f.target)&&d(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[l]),h?t.jsxs("span",{ref:c,className:"relative inline-block",children:[t.jsx("button",{onClick:()=>d(!l),className:"text-fg-tertiary hover:text-brand-500 cursor-pointer transition-colors",children:e}),l&&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:Gj(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),i?.(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 R_({agent:e,anchorRect:n,onClose:s,onViewProfile:i}){const l=v.useRef(null);v.useEffect(()=>{const m=f=>{l.current&&!l.current.contains(f.target)&&s()};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[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",h=v.useCallback(m=>{if(!m)return;l.current=m;const f=m.getBoundingClientRect(),x=window.innerWidth,p=window.innerHeight,g=8;f.right>x-g&&(m.style.left=`${Math.max(g,x-f.width-g)}px`),f.left<g&&(m.style.left=`${g}px`),f.bottom>p-g&&(m.style.top=`${Math.max(g,p-f.height-g)}px`)},[]);return t.jsxs("div",{ref:h,className:"fixed z-50 w-64 max-w-[calc(100vw-1rem)] bg-surface-secondary border border-border-default rounded-xl shadow-2xl p-4 space-y-3",style:{top:n.top+40,left:n.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:Gj(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(),i(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 n=String(e);if(n.includes("AbortError")||n.includes("abort"))return"";let s="";const i=n.match(/\{[\s\S]*\}/);if(i)try{const l=JSON.parse(i[0]);s=l.error?.message??l.message??""}catch{}if(!s){const l=n.lastIndexOf(": ");l>=0&&(s=n.slice(l+2).trim())}return n.includes("402")||/insufficient.?balance/i.test(n)?`⚠ AI service error: ${s||"Insufficient credits"}. Please top up the API balance or contact your administrator.`:n.includes("401")||/unauthorized|invalid.?api.?key/i.test(n)?`⚠ AI service authentication failed: ${s||"Invalid API key"}. Please check the configuration.`:n.includes("429")||/rate.?limit/i.test(n)?`⚠ Rate limit exceeded: ${s||"Too many requests"}. Please wait a moment and try again.`:n.includes("503")||/service.?unavailable/i.test(n)?`⚠ AI service unavailable: ${s||"Service temporarily down"}. Please try again later.`:`⚠ AI service error: ${s||n.slice(0,120)}`}function Fy({msg:e,onCopy:n,onRetry:s,onReply:i,isCopied:l,isLastAgentMsg:d}){const c=e.isError||e.sender==="agent"&&e.text.startsWith("⚠"),h=e.isStopped,m=d!==!1;return t.jsxs("div",{className:"flex items-center gap-0.5 mt-1",children:[t.jsxs("button",{onClick:()=>n(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"]}),m&&h&&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"]}),m&&c&&!h&&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"]}),m&&!c&&!h&&e.sender==="agent"&&s&&t.jsxs("button",{onClick:()=>s(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:"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"]}),i&&t.jsxs("button",{onClick:()=>i(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:"Reply",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:"9 17 4 12 9 7"}),t.jsx("path",{d:"M20 18v-2a4 4 0 00-4-4H4"})]}),"Reply"]})]})}function O_(e,n){if(!e)return[];const s=[];let i=0;const l=new Date().toISOString(),d=n??"";let c=!1,h="",m="";const f=()=>{const w=h.trim();w&&s.push({id:`cseg_${i}`,sourceType:"chat",sourceId:"",agentId:d,seq:i++,type:"text",content:w,createdAt:l,metadata:{isThinking:!0}}),h=""},x=()=>{const w=m.trim();w&&s.push({id:`cseg_${i}`,sourceType:"chat",sourceId:"",agentId:d,seq:i++,type:"text",content:w,createdAt:l}),m=""},p="<think>",g="</think>",y=w=>{let N=0;for(;N<w.length;)if(c){const T=w.indexOf(g,N);T===-1?(h+=w.slice(N),N=w.length):(h+=w.slice(N,T),c=!1,f(),N=T+g.length)}else{const T=w.indexOf(p,N);T===-1?(m+=w.slice(N),N=w.length):(m+=w.slice(N,T),x(),c=!0,N=T+p.length)}};for(const w of e)w.type==="tool"?(c||x(),s.push({id:`cseg_${i}`,sourceType:"chat",sourceId:"",agentId:d,seq:i++,type:"tool_start",content:w.tool,metadata:{arguments:w.args},createdAt:l}),w.status!=="running"&&s.push({id:`cseg_${i}`,sourceType:"chat",sourceId:"",agentId:d,seq:i++,type:"tool_end",content:w.tool,metadata:{arguments:w.args,result:w.result,error:w.error,durationMs:w.durationMs,success:w.status!=="error",...w.subagentLogs?.length?{subagentLogs:w.subagentLogs}:{}},createdAt:l})):(w.thinking&&(c||x(),h+=w.thinking,f()),y(w.content));return c?f():x(),s}function D_({msg:e,isStreaming:n,liveActivities:s,onViewModeChange:i}){const l=e.segments,d=e.isStopped,[c,h]=v.useState("compact"),m=v.useCallback(x=>{h(x),i?.(x)},[i]);if(l!==void 0){const x=l.some(C=>C.type==="tool"),p=O_(l,e.agentId),g=n?(()=>{const _=l.filter(k=>k.type==="text").map(k=>k.content).join("").replace(/<think>[\s\S]*?(<\/think>|$)/g,"").replace(/<(invoke|function_calls|antml:\w+)\b[\s\S]*?(<\/\1>|$)/g,"").trim();return _?_.slice(-200):void 0})():void 0,y=l.filter(C=>C.type==="text"),N=n?null:y.map(C=>C.content).join(""),T=[];if(c==="compact")for(const C of l){if(C.type!=="tool")continue;const _=zj(C.tool,C.result);if(_){T.push({key:`task-${_.taskId}`,kind:"task",info:_});continue}const k=$j(C.tool,C.result);k&&T.push({key:`req-${k.requirementId}`,kind:"req",info:k})}return t.jsxs("div",{className:"space-y-2 min-h-[1em] min-w-0 overflow-hidden",children:[(x||n)&&(c==="compact"?t.jsx(Ex,{entries:p,streamingText:g,isActive:n,onExpand:()=>m("full"),embedded:!0}):t.jsx(du,{entries:p,streamingText:g,isActive:n,onCollapse:()=>m("compact"),embedded:!0})),c==="compact"&&T.map(C=>C.kind==="task"?t.jsx(Pj,{info:C.info},C.key):t.jsx(qj,{info:C.info},C.key)),c==="compact"&&N&&t.jsx(ir,{content:N}),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:[(n||f)&&t.jsx(X4,{activities:n?s:e.activities??[],isActive:n,persistent:!n&&f}),e.text?t.jsx(ir,{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 zm=new Set;function L_(){return window.location.hash}function I_(e){return zm.add(e),()=>{zm.delete(e)}}typeof window<"u"&&window.addEventListener("hashchange",()=>zm.forEach(e=>e()));function Yy({initialAgentId:e,authUser:n}={}){const[s,i]=v.useState([]),[l,d]=v.useState([]),c=$r(),h=v.useSyncExternalStore(I_,L_),m=c&&(h.startsWith(`#${me.TEAM}/`)||h.startsWith("#chat/")),f=v.useCallback(()=>{window.location.hash=`${me.TEAM}/d`},[]);v.useEffect(()=>{if(!c)return;const Q=()=>{g.current==="profile"&&p("chat")};return window.addEventListener("popstate",Q),()=>window.removeEventListener("popstate",Q)},[c]);const[x,p]=v.useState("chat"),g=v.useRef("chat");g.current=x;const y=fu({side:"left",defaultWidth:224,minWidth:160,maxWidth:360,storageKey:"markus_chat_sidebar"}),[w,N]=v.useState(null),[T,C]=v.useState(),[_,k]=v.useState(),M=v.useCallback((Q,oe)=>{C(Q),k(oe),p("profile"),c&&history.pushState({mobileProfile:!0},"",window.location.hash)},[c]),D=[{id:"chat"},{id:"profile"}],A=v.useCallback(Q=>{Q==="profile"?M():g.current==="profile"?history.back():p("chat")},[M]),G=ca(D,x,A),X=v.useCallback((Q,oe)=>{$("direct"),U(Q),c&&f(),M(oe?.tab,oe?.highlightMailboxId),N(null)},[c,f,M]),[K,$]=v.useState(()=>e?"direct":localStorage.getItem("markus_chat_mode")??"direct"),[q,U]=v.useState(()=>e??localStorage.getItem("markus_chat_agent")??""),[z,E]=v.useState(()=>localStorage.getItem("markus_chat_channel")??"#general"),[L,R]=v.useState(""),F=v.useRef(new Map),Y=v.useRef(new Map),Z=v.useRef(new Set),B=v.useRef(""),[O,V]=v.useState([]),[I,S]=v.useState(""),[H,W]=v.useState(null),[ee,te]=v.useState(!1),[ae,he]=v.useState([]),[Ne,De]=v.useState(!1),[je,ke]=v.useState(!1),[Se,Le]=v.useState(new Set),[nt,rt]=v.useState([]),yt=v.useRef(null),Rt=v.useRef(null),re="__new_chat__",[_e,st]=v.useState([]),[dt,Yt]=v.useState(null),[ye,Ae]=v.useState(!1),[Fe,Qe]=v.useState([]),xt=v.useRef(new Map),nn=v.useRef(new Map),cn=v.useRef(null),Tt=v.useRef(null),gt=v.useRef(null),Bt=v.useRef(null),[_t,Ht]=v.useState([]),[rn,bn]=v.useState([]),[Hn,Cn]=v.useState([]),[xe,Re]=v.useState([]),[vt,At]=v.useState(null),[Dt,On]=v.useState(!1),[an,dn]=v.useState(""),[Dn,Nt]=v.useState(!1),[hn,lr]=v.useState(""),[le,$e]=v.useState(0),Ue=K==="channel"?_t.find(Q=>Q.channelKey===z)?.teamId:void 0,We=v.useRef(null),Ke=v.useRef(null),qe=v.useRef(null),Je=v.useRef(void 0),Wt=v.useRef(!1),Zt=v.useRef(!0),Pt=v.useRef(void 0);v.useEffect(()=>{if(!ye)return;const Q=oe=>{Tt.current&&!Tt.current.contains(oe.target)&&cn.current&&!cn.current.contains(oe.target)&&Ae(!1)};return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[ye]);const En=(Q,oe)=>{if(!oe||Q===oe)return`notes:${Q}`;const[Ce,Ge]=[Q,oe].sort();return`dm:${Ce}:${Ge}`},be=(Q,oe,Ce,Ge)=>Q==="channel"?`ch:${Ce}`:Q==="dm"?`dm:${Ge??""}`:oe||"_direct",ze=v.useCallback((Q,oe)=>{const Ce=oe(F.current.get(Q)??[]);F.current.set(Q,Ce),B.current===Q&&V(Ce)},[]),Et=(Q,oe)=>{const Ce=[...Y.current.get(Q)??[],oe];Y.current.set(Q,Ce),B.current===Q&&he(Ce)};v.useEffect(()=>{localStorage.setItem("markus_chat_mode",K)},[K]),v.useEffect(()=>{localStorage.setItem("markus_chat_agent",q)},[q]),v.useEffect(()=>{localStorage.setItem("markus_chat_channel",z)},[z]);const kt=v.useCallback(()=>se.agents.list().then(Q=>i(Q.agents)).catch(()=>{}),[]),yn=v.useCallback(()=>se.teams.list().then(Q=>bn(Q.teams)).catch(()=>{}),[]);v.useEffect(()=>{kt(),se.users.list().then(ct=>d(ct.users)).catch(()=>{}),se.tasks.list().then(ct=>Re(ct.tasks)).catch(()=>{}),yn(),se.externalAgents.list().then(ct=>Cn(ct.agents)).catch(()=>{}),fetch("/api/group-chats").then(ct=>ct.json()).then(ct=>Ht(ct.chats)).catch(()=>{});const Q=setInterval(kt,8e3),oe=setInterval(yn,15e3),Ce=Jt.on("agent:update",kt),Ge=Jt.on("*",yn),Be=Jt.on("chat:group_created",()=>{fetch("/api/group-chats").then(ct=>ct.json()).then(ct=>Ht(ct.chats)).catch(()=>{})}),He=()=>{kt(),yn()};return window.addEventListener("markus:data-changed",He),()=>{clearInterval(Q),clearInterval(oe),Ce(),Ge(),Be(),window.removeEventListener("markus:data-changed",He)}},[]),v.useEffect(()=>{const Q=Ge=>{const Be=Ge.detail;if(la(Be.page)===me.TEAM){if(Be.params?.agentId){if(Be.params.profileTab)X(Be.params.agentId,{tab:Be.params.profileTab});else if($("direct"),U(Be.params.agentId),Be.params.sessionId){const He=Be.params.sessionId;setTimeout(async()=>{try{const{sessions:ct}=await se.sessions.listByAgent(Be.params.agentId,20),Ze=ct.find(Xe=>Xe.id===He);Ze&&Pr(Ze)}catch{}},300)}}Be.params?.selectAgent&&X(Be.params.selectAgent),Be.params?.prefillMessage&&(S(Be.params.prefillMessage),setTimeout(()=>Rt.current?.focus(),100)),Be.params?.openHire}},oe=localStorage.getItem("markus_nav_agentId");if(oe){localStorage.removeItem("markus_nav_agentId");const Ge=localStorage.getItem("markus_nav_profileTab");Ge?(localStorage.removeItem("markus_nav_profileTab"),X(oe,{tab:Ge})):($("direct"),U(oe))}const Ce=localStorage.getItem("markus_nav_selectAgent");return Ce&&(localStorage.removeItem("markus_nav_selectAgent"),X(Ce)),window.addEventListener("markus:navigate",Q),()=>window.removeEventListener("markus:navigate",Q)},[]),v.useEffect(()=>{if(q||s.length===0)return;const Q=s.find(oe=>oe.role==="secretary");Q&&($("direct"),U(Q.id))},[s,q]);const _n=v.useRef(!1);v.useEffect(()=>{const Q=Ke.current;if(!Q)return;const oe=()=>Q.scrollHeight-Q.scrollTop-Q.clientHeight<80,Ce=()=>{_n.current=!0},Ge=()=>{_n.current&&oe()?(_n.current=!1,Zt.current=!0):_n.current&&(Zt.current=!1)};return Q.addEventListener("wheel",Ce,{passive:!0}),Q.addEventListener("touchmove",Ce,{passive:!0}),Q.addEventListener("scroll",Ge,{passive:!0}),()=>{Q.removeEventListener("wheel",Ce),Q.removeEventListener("touchmove",Ce),Q.removeEventListener("scroll",Ge)}},[]),v.useLayoutEffect(()=>{if(Wt.current){Wt.current=!1;return}Zt.current&&We.current?.scrollIntoView({behavior:"instant"})},[O,ae]),v.useEffect(()=>{x==="chat"&&requestAnimationFrame(()=>{We.current?.scrollIntoView({behavior:"instant"}),Zt.current=!0})},[x]),v.useEffect(()=>{const Q=()=>{la(window.location.hash.slice(1).split("/")[0])===me.TEAM&&g.current==="chat"&&requestAnimationFrame(()=>{We.current?.scrollIntoView({behavior:"instant"})})};return window.addEventListener("hashchange",Q),window.addEventListener("markus:navigate",Q),()=>{window.removeEventListener("hashchange",Q),window.removeEventListener("markus:navigate",Q)}},[]);const or=v.useCallback(async Q=>{const oe=`ch:${Q}`;try{const Ce=await se.channels.getMessages(Q,50),Ge=Ce.messages.map(No);F.current.set(oe,Ge),B.current===oe&&(V(Ge),De(Ce.hasMore),gt.current=Ce.messages[0]?new Date(Ce.messages[0].createdAt).toISOString():null)}catch{B.current===oe&&(V([]),De(!1))}},[]),Nn=v.useCallback(async(Q,oe)=>{Bt.current=Q;try{const Ce=await se.sessions.getMessages(Q,50),Ge=Ce.messages.map(Uy);F.current.set(oe,Ge),B.current===oe&&Bt.current===Q&&(V(Ge),De(Ce.hasMore),gt.current=Ce.messages[0]?new Date(Ce.messages[0].createdAt).toISOString():null)}catch{B.current===oe&&Bt.current===Q&&(V([]),De(!1),gt.current=null)}},[]),yr=v.useCallback(async Q=>{if(!Q)return st([]),[];try{const{sessions:oe}=await se.sessions.listByAgent(Q,10);return st(oe),oe}catch{return st([]),[]}},[]),Hr=v.useCallback(async()=>{if(je||!Ne||!gt.current)return;ke(!0);const Q=Ke.current,oe=Q?.scrollHeight??0;try{const Ce=B.current;if(K==="channel"||K==="dm"){const Ge=K==="dm"?En(n?.id??"",L):z,Be=await se.channels.getMessages(Ge,50,gt.current),He=Be.messages.map(No);Wt.current=!0,V(ct=>{const Ze=[...He,...ct];return F.current.set(Ce,Ze),Ze}),De(Be.hasMore),Be.messages[0]&&(gt.current=new Date(Be.messages[0].createdAt).toISOString())}else if(dt){const Ge=await se.sessions.getMessages(dt,50,gt.current),Be=Ge.messages.map(Uy);Wt.current=!0,V(He=>{const ct=[...Be,...He];return F.current.set(Ce,ct),ct}),De(Ge.hasMore),Ge.messages[0]&&(gt.current=new Date(Ge.messages[0].createdAt).toISOString())}}catch{}finally{ke(!1),requestAnimationFrame(()=>{if(Q){const Ce=Q.scrollHeight;Q.scrollTop+=Ce-oe}})}},[je,Ne,K,z,dt,n?.id,L]);Pt.current=Hr;const de=v.useRef(!1),Te=v.useCallback(Q=>{de.current||(de.current=!0,requestAnimationFrame(()=>{de.current=!1,Q.target.scrollTop<100&&Pt.current?.()}))},[]);v.useEffect(()=>{const Q=be(K,q,z,L),oe=B.current;B.current=Q,oe&&oe!==Q&&(xt.current.set(oe,Fe),nn.current.set(oe,dt));const Ce=F.current.get(Q),Ge=Y.current.get(Q)??[],Be=Z.current.has(Q);he(Ge),te(Be),K==="direct"&&q&&yr(q);const He=xt.current.get(Q),ct=nn.current.get(Q);if(He&&He.length>0&&Qe(He),Ae(!1),Ce!==void 0)V(Ce),De(!1),ct!==void 0&&Yt(ct),(!He||He.length===0)&&Qe([]);else if(V([]),De(!1),gt.current=null,K==="channel"||K==="dm"){const Ze=K==="dm"?En(n?.id??"",L):z;or(Ze),(!He||He.length===0)&&Qe([])}else K==="direct"&&q&&yr(q).then(Ze=>{if(B.current===Q)if(Ze.length>0){const Xe=Ze.find(un=>un.isMain),at=Xe?[Xe,...Ze.filter(un=>!un.isMain).slice(0,4)]:Ze.slice(0,5),jt=He&&He.length>0?He:at,Gt=ct!==void 0?ct:Xe?.id??jt[0].id,It=Gt&&jt.some(un=>un.id===Gt)?Gt:jt[0].id;Yt(It),Qe(jt),Nn(It,Q)}else{Yt(null),(!He||He.length===0)&&Qe([]);const Xe=(()=>{const at=(navigator.language||"").toLowerCase();return at.startsWith("zh")?"介绍一下你自己":at.startsWith("ja")?"自己紹介をしてください":at.startsWith("ko")?"자기소개를 해주세요":at.startsWith("fr")?"Présentez-vous":at.startsWith("de")?"Stell dich vor":at.startsWith("es")?"Preséntate":at.startsWith("pt")?"Apresente-se":at.startsWith("ru")?"Представьтесь":"Introduce yourself"})();setTimeout(()=>Je.current?.(Xe),150)}})},[K,q,z,L]),v.useEffect(()=>K!=="channel"?void 0:Jt.on("chat:message",oe=>{const Ce=oe.payload,Ge=Ce.channel??"";if(!Ge||Ge!==z)return;const Be=Ce.senderType??"agent",He=Ce.text??Ce.message??"",ct=Ce.senderId??Ce.agentId??"",Ze=Ce.senderName??Ce.agentId??"Agent",Xe=Ce.metadata,at={id:`ws_${Date.now()}_${ct}`,sender:Be==="human"?"user":"agent",text:He,time:new Date().toLocaleTimeString(),agentName:Be==="agent"?Ze:void 0,agentId:Be==="agent"?ct:void 0};if(Xe&&Be==="agent"){const Gt=[];if(Xe.thinking?.length&&Gt.push({type:"text",content:"",thinking:Xe.thinking.join(`
|
|
53
|
-
|
|
54
|
-
`)}),Xe.toolCalls?.length)for(let It=0;It<Xe.toolCalls.length;It++){const un=Xe.toolCalls[It];Gt.push({type:"tool",key:`${un.tool}_${It}`,tool:un.tool,status:un.status==="error"?"error":"done",args:un.arguments,result:un.result,durationMs:un.durationMs})}Gt.length>0&&(Gt.push({type:"text",content:He}),at.segments=Gt)}const jt=be("channel",q,z,L);ze(jt,Gt=>[...Gt,at])}),[K,z,q,L,ze]),v.useEffect(()=>Jt.on("chat:proactive_message",oe=>{const Ce=oe.payload,Ge=Ce.agentId??"",Be=Ce.agentName??"Agent",He=Ce.message??"";Ce.sessionId;const ct=Ce.metadata??{};if(!Ge||!He)return;const Ze=!!ct.activityLog||He.startsWith("[ACTIVITY:");if(K==="direct"&&q===Ge){const Xe={id:`proactive_${Date.now()}`,sender:"agent",text:He,time:new Date().toLocaleTimeString(),agentName:Be,agentId:Ge,...Ze?{isActivityLog:!0,activityType:ct.activityType,outcome:ct.outcome,mailboxItemId:ct.mailboxItemId,taskId:ct.taskId,requirementId:ct.requirementId}:{}},at=be("direct",Ge,z,L);ze(at,jt=>[...jt,Xe])}}),[K,q,z,L,dt,ze]),xe.find(Q=>Q.id===vt),v.useEffect(()=>{At(null)},[q]);const Ve=Q=>n_(Q),qt=()=>{qe.current?.abort(),qe.current=null;const Q=B.current;Z.current.delete(Q),Y.current.delete(Q),te(!1),he([])},vr=async(Q,oe)=>{const Ce=(Q??I).trim();if(!Ce&&nt.length===0||K==="direct"&&!q)return;if(Zt.current=!0,_n.current=!1,ee){qe.current?.abort(),qe.current=null;const Ze=B.current;Z.current.delete(Ze),Y.current.delete(Ze),ze(Ze,Xe=>{const at=[...Xe];for(let jt=at.length-1;jt>=0;jt--)if(at[jt].sender==="agent"&&!at[jt].isStopped&&!at[jt].isError){const Gt=at[jt],It=(Gt.segments??[]).map(un=>un.type==="tool"&&un.status==="running"?{...un,status:"stopped"}:un);at[jt]={...Gt,isStopped:!0,segments:It};break}return at}),te(!1),he([]),await new Promise(Xe=>setTimeout(Xe,50))}const Ge=nt.length>0?nt.map(Ze=>Ze.dataUrl):void 0,Be=be(K,q,z,L),He=H;Q||(S(""),Rt.current&&(Rt.current.style.height="auto")),rt([]),Nt(!1),W(null);const ct=K==="dm";if(Z.current.add(Be),Y.current.set(Be,[]),B.current===Be&&!ct&&(te(!0),he([])),K==="dm"){const Ze=En(n?.id??"",L),Xe=`opt_${Date.now()}`,at={id:Xe,sender:"user",text:Ce,time:new Date().toLocaleTimeString()};He&&(at.replyToId=He.id,at.replyToSender=He.sender,at.replyToText=He.text),ze(Be,jt=>[...jt,at]);try{const jt=await se.channels.sendMessage(Ze,{text:Ce,senderName:n?.name??"You",senderId:n?.id,mentions:[],orgId:"default",humanOnly:!0});ze(Be,Gt=>{const It=Gt.filter(_r=>_r.id!==Xe),un=[];return jt.userMessage&&un.push(No(jt.userMessage)),un.length>0?[...It,...un]:Gt})}catch(jt){ze(Be,Gt=>[...Gt,{id:`err_${Date.now()}`,sender:"agent",text:`Error: ${String(jt)}`,time:new Date().toLocaleTimeString(),agentName:"System",isError:!0}])}Z.current.delete(Be),B.current===Be&&te(!1)}else if(K==="channel"){const Ze=`opt_${Date.now()}`,Xe={id:Ze,sender:"user",text:Ce,time:new Date().toLocaleTimeString()};He&&(Xe.replyToId=He.id,Xe.replyToSender=He.sender,Xe.replyToText=He.text),ze(Be,at=>[...at,Xe]);try{const at=Ve(Ce),jt=at.length>0?s.find(It=>It.name.toLowerCase()===at[0].toLowerCase()):null,Gt=await se.channels.sendMessage(z,{text:Ce,senderName:n?.name??"You",mentions:at,senderId:n?.id,targetAgentId:jt?.id,orgId:"default"});ze(Be,It=>{const un=It.filter(Ln=>Ln.id!==Ze),_r=[];return Gt.userMessage&&_r.push(No(Gt.userMessage)),Gt.agentMessage&&_r.push(No(Gt.agentMessage)),_r.length>0?[...un,..._r]:It})}catch(at){const jt=Vy(at)||`Error: ${String(at)}`;ze(Be,Gt=>[...Gt,{id:`err_${Date.now()}`,sender:"agent",text:jt,time:new Date().toLocaleTimeString(),agentName:"System",isError:!0}])}Z.current.delete(Be),B.current===Be&&te(!1)}else{const Ze=`a_${Date.now()}`,Xe={id:`u_${Date.now()}`,sender:"user",text:Ce,time:new Date().toLocaleTimeString()};Ge?.length&&(Xe.images=Ge),He&&(Xe.replyToId=He.id,Xe.replyToSender=He.sender,Xe.replyToText=He.text),ze(Be,wt=>[...wt,Xe,{id:Ze,sender:"agent",text:"",time:new Date().toLocaleTimeString(),segments:[]}]);let at=!1;const jt=wt=>{ze(Be,Ot=>{const pt=[...Ot],lt=pt.findIndex(Ur=>Ur.id===Ze);if(lt<0)return Ot;const et=pt[lt].segments??[],ut=et[et.length-1],ft=ut?.type==="text"?ut.thinking??"":"";let In="",sr="",dr=wt;for(;dr.length>0;)if(at){const Ur=dr.indexOf("</think>");Ur>=0?(In+=dr.slice(0,Ur),dr=dr.slice(Ur+8),at=!1):(In+=dr,dr="")}else{const Ur=dr.indexOf("<think>");Ur>=0?(sr+=dr.slice(0,Ur),dr=dr.slice(Ur+7),at=!0):(sr+=dr,dr="")}const dc=ft+In||void 0,Su=ut?.type==="text"?[...et.slice(0,-1),{type:"text",content:ut.content+sr,thinking:dc}]:[...et,{type:"text",content:sr,thinking:dc}];return pt[lt]={...pt[lt],text:pt[lt].text+sr,segments:Su},pt})},Gt=wt=>{(wt.phase==="start"||wt.phase==="end")&&Et(Be,{...wt,phase:wt.phase,ts:Date.now()}),wt.phase==="start"?ze(Be,Ot=>{const pt=[...Ot],lt=pt.findIndex(ft=>ft.id===Ze);if(lt<0)return Ot;const et=[...pt[lt].segments??[]];let ut=!1;if(wt.arguments)for(let ft=et.length-1;ft>=0;ft--){const In=et[ft];if(In.type==="tool"&&In.tool===wt.tool&&In.status==="running"){et[ft]={...In,args:wt.arguments},ut=!0;break}}if(!ut){const ft=`${wt.tool}_${Date.now()}`;et.push({type:"tool",key:ft,tool:wt.tool,status:"running",args:wt.arguments})}return pt[lt]={...pt[lt],segments:et},pt}):wt.phase==="output"?ze(Be,Ot=>{const pt=[...Ot],lt=pt.findIndex(ut=>ut.id===Ze);if(lt<0)return Ot;const et=[...pt[lt].segments??[]];for(let ut=et.length-1;ut>=0;ut--){const ft=et[ut];if(ft.type==="tool"&&ft.tool===wt.tool&&ft.status==="running"){et[ut]={...ft,liveOutput:(ft.liveOutput??"")+(wt.output??"")};break}}return pt[lt]={...pt[lt],segments:et},pt}):wt.phase==="subagent_progress"&&wt.subagentEvent?ze(Be,Ot=>{const pt=[...Ot],lt=pt.findIndex(ut=>ut.id===Ze);if(lt<0)return Ot;const et=[...pt[lt].segments??[]];for(let ut=et.length-1;ut>=0;ut--){const ft=et[ut];if(ft.type==="tool"&&(ft.tool==="spawn_subagent"||ft.tool==="spawn_subagents")&&ft.status==="running"){et[ut]={...ft,subagentLogs:[...ft.subagentLogs??[],wt.subagentEvent]};break}}return pt[lt]={...pt[lt],segments:et},pt}):ze(Be,Ot=>{const pt=[...Ot],lt=pt.findIndex(ut=>ut.id===Ze);if(lt<0)return Ot;const et=[...pt[lt].segments??[]];for(let ut=et.length-1;ut>=0;ut--){const ft=et[ut];if(ft.type==="tool"&&ft.tool===wt.tool&&ft.status==="running"){et[ut]={...ft,status:wt.success===!1?"error":"done",args:wt.arguments,result:wt.result,error:wt.error,durationMs:wt.durationMs,liveOutput:void 0};break}}return pt[lt]={...pt[lt],segments:et},pt})},It=new AbortController;qe.current=It;try{const wt=dt===re?null:dt,Ot=await se.agents.messageStream(q,Ce,jt,Gt,It.signal,Ge,wt,oe?.isRetry);B.current===Be&&(Ot.sessionId&&(Yt(Ot.sessionId),Qe(pt=>pt.map(lt=>lt.id===re?{...lt,id:Ot.sessionId}:lt))),yr(q).then(pt=>{if(B.current===Be&&(st(pt),Ot.sessionId)){const lt=pt.find(et=>et.id===Ot.sessionId);lt&&Qe(et=>et.some(ft=>ft.id===lt.id)?et.map(ft=>ft.id===lt.id?lt:ft):[lt,...et.filter(ft=>ft.id!==re)])}}))}catch(wt){const Ot=wt?.sessionId;Ot&&K==="direct"&&B.current===Be&&(Yt(Ot),Qe(lt=>lt.map(et=>et.id===re?{...et,id:Ot}:et)),yr(q).then(lt=>{if(B.current!==Be)return;st(lt);const et=lt.find(ut=>ut.id===Ot);et&&Qe(ut=>ut.some(In=>In.id===et.id)?ut.map(In=>In.id===et.id?et:In):[et,...ut])}));const pt=Vy(wt);pt?ze(Be,lt=>{const et=[...lt],ut=et.findIndex(ft=>ft.id===Ze);if(ut>=0){const ft=et[ut].segments??[];et[ut]={...et[ut],text:pt,isError:!0,segments:[...ft,{type:"text",content:pt}]}}return et}):ze(Be,lt=>{const et=[...lt],ut=et.findIndex(ft=>ft.id===Ze);if(ut>=0){const ft=et[ut];if(!(ft.text||ft.segments&&ft.segments.length>0&&ft.segments.some(sr=>sr.type==="text"&&sr.content||sr.type==="tool")))return lt.filter(sr=>sr.id!==Ze);et[ut]={...ft,isStopped:!0}}return et})}ze(Be,wt=>{const Ot=[...wt],pt=Ot.findIndex(lt=>lt.id===Ze);if(pt>=0){const lt=(Ot[pt].segments??[]).map(et=>et.type==="tool"&&et.status==="running"?{...et,status:"stopped"}:et);Ot[pt]={...Ot[pt],segments:lt}}return Ot}),It.signal.aborted&&ze(Be,wt=>{const Ot=[...wt],pt=Ot.findIndex(lt=>lt.id===Ze);if(pt>=0){const lt=Ot[pt];if(!(lt.text||lt.segments&<.segments.length>0&<.segments.some(ut=>ut.type==="text"&&ut.content||ut.type==="tool")))return wt.filter(ut=>ut.id!==Ze);Ot[pt]={...lt,isStopped:!0}}return Ot});const _r=(F.current.get(Be)??[]).find(wt=>wt.id===Ze),Ln=dt&&dt!==re?dt:null;_r&&!_r.text&&K==="direct"&&Ln&&!It.signal.aborted&&(async(Ot,pt)=>{for(let lt=0;lt<Ot;lt++){await new Promise(et=>setTimeout(et,pt));try{const ut=(await se.sessions.getMessages(Ln,2)).messages.find(ft=>ft.role==="assistant");if(ut?.content){ze(Be,ft=>{const In=[...ft],sr=In.findIndex(dr=>dr.id===Ze);return sr>=0&&(In[sr]={...In[sr],text:ut.content,segments:[{type:"text",content:ut.content}]}),In});return}}catch{}}})(5,3e3)}qe.current=null,Z.current.delete(Be),Y.current.delete(Be),B.current===Be&&(te(!1),he([]))};Je.current=vr;const[ts,Nr]=v.useState(null),[,Ns]=v.useState(new Set),xr=v.useMemo(()=>{for(let Q=O.length-1;Q>=0;Q--)if(O[Q]?.sender==="agent"&&!O[Q]?.isActivityLog)return O[Q].id;return null},[O]),tr=v.useCallback(Q=>{const oe=Q.segments?Q.segments.filter(Ce=>Ce.type==="text").map(Ce=>Ce.content).join(`
|
|
55
|
-
`):Q.text;navigator.clipboard.writeText(oe),Nr(Q.id),setTimeout(()=>Nr(Ce=>Ce===Q.id?null:Ce),2e3)},[]),$s=v.useCallback(Q=>{const oe=B.current,Ce=F.current.get(oe)??O,Ge=Ce.findIndex(Xe=>Xe.id===Q.id);if(Ge<0)return;let Be=null;for(let Xe=Ge-1;Xe>=0;Xe--)if(Ce[Xe]?.sender==="user"){Be=Ce[Xe];break}const He=Be?.text??"";if(!He)return;if(Ge<Ce.length-1){const Xe=Ce.length-1-Ge;if(!window.confirm(`This will discard ${Xe} message${Xe>1?"s":""} after this point and re-generate. Continue?`))return}const Ze=Be&&Ge>0&&Ce[Ge-1]?.id===Be.id;ze(oe,Xe=>{const at=Xe.findIndex(jt=>jt.id===(Ze?Be.id:Q.id));return at>=0?Xe.slice(0,at):Xe}),vr(He,{isRetry:!0})},[O,ze]),Bs=v.useCallback(Q=>{W({id:Q.id,sender:Q.sender==="user"?n?.name??"You":Q.agentName??"Agent",text:Q.text.slice(0,120)}),Rt.current?.focus()},[n?.name]),Pr=async Q=>{Yt(Q.id),Ae(!1),De(!1),gt.current=null;const oe=B.current;F.current.delete(oe),V([]),Qe(Ce=>Ce.some(Ge=>Ge.id===Q.id)?Ce:[...Ce,Q]),await Nn(Q.id,oe)},ha=Q=>{if(Qe(oe=>oe.filter(Ce=>Ce.id!==Q)),dt===Q){const oe=Fe.filter(Ce=>Ce.id!==Q);oe.length>0?Pr(oe[oe.length-1]):qr()}},qr=()=>{Yt(re);const Q=B.current;F.current.delete(Q),V([]),De(!1),gt.current=null,Ae(!1),Qe(oe=>{const Ce=oe.filter(Ge=>Ge.id!==re);return[{id:re,agentId:q??"",userId:null,title:"New Chat",createdAt:new Date().toISOString(),lastMessageAt:new Date().toISOString()},...Ce]})},ma=Q=>{if(S(Q),K!=="channel"){Nt(!1);return}const oe=Q.lastIndexOf("@");if(oe>=0&&(oe===0||Q[oe-1]===" ")){const Ge=Q.slice(oe+1).toLowerCase();if(s.some(He=>He.name.toLowerCase().includes(Ge))){Nt(!0),lr(Ge),$e(0);return}}Nt(!1)},Yn=Q=>{const oe=I.lastIndexOf("@"),Ce=Q.includes(" ")?`@[${Q}]`:`@${Q}`;S(I.slice(0,oe)+Ce+" "),Nt(!1),$e(0)},kr=4*1024*1024,fs=5,Sr=v.useCallback(Q=>{const oe=Array.from(Q).filter(Ce=>Ce.type.startsWith("image/"));if(oe.length!==0)for(const Ce of oe){if(Ce.size>kr)continue;const Ge=new FileReader;Ge.onload=()=>{const Be=Ge.result;rt(He=>He.length>=fs||He.some(ct=>ct.dataUrl===Be)?He:[...He,{id:`img_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,dataUrl:Be,name:Ce.name}])},Ge.readAsDataURL(Ce)}},[]),cr=v.useCallback(Q=>{rt(oe=>oe.filter(Ce=>Ce.id!==Q))},[]),Wa=v.useCallback(Q=>{const oe=Q.clipboardData?.files;if(oe&&oe.length>0){const Ce=Array.from(oe).filter(Ge=>Ge.type.startsWith("image/"));Ce.length>0&&(Q.preventDefault(),Sr(Ce))}},[Sr]),_i=v.useCallback(Q=>{Q.preventDefault();const oe=Q.dataTransfer?.files;oe&&oe.length>0&&Sr(Array.from(oe).filter(Ce=>Ce.type.startsWith("image/")))},[Sr]),Cr=v.useCallback(Q=>{Q.preventDefault()},[]),Er=s.find(Q=>Q.id===q),Hs=n?.name??"You",xa=O[O.length-1],Ps=ee&&xa?.sender==="agent",Tr=s.filter(Q=>Q.name.toLowerCase().includes(hn)),ne=l.find(Q=>Q.id===L),Ie=L===n?.id||!L,Ye=_t.find(Q=>Q.channelKey===z),it=K==="channel"?Ye?.name??z:K==="direct"?Er?.name??"Select Agent":K==="dm"?Ie?"My Notes":ne?.name??"Direct Message":"Chat",sn=K==="channel"?Ye?`Message ${Ye.name}…`:`Message ${z}… (use @name to mention)`:K==="dm"?Ie?"Write a note to yourself…":`Message ${ne?.name??""}…`:q?"Type a message…":"Select an agent to start chatting",mn=c&&m;return t.jsxs("div",{className:"flex-1 overflow-hidden flex",children:[t.jsx(o_,{authUser:n,agents:s,teams:rn,humans:l,tasks:xe,externalAgents:Hn,groupChats:_t,chatMode:K,selectedAgent:q,activeChannel:z,activeDmUserId:L,onSelectAgent:Q=>{$("direct"),U(Q),p("chat"),c&&f()},onSelectChannel:Q=>{$("channel"),E(Q),p("chat"),c&&f()},onSelectDm:Q=>{$("dm"),R(Q),p("chat"),c&&f()},onRefreshTeams:yn,onRefreshAgents:kt,onViewProfile:X,width:c?void 0:y.width,onResizeStart:c?void 0:y.onResizeStart,hidden:c&&m}),(!c||mn)&&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=me.TEAM},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:it}),K==="direct"&&Er&&t.jsx(Gy,{agent:Er,tasks:xe,onViewProfile:X})]}),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():p("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"&&M()},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:K==="channel"?"Team":"Profile"}),t.jsx("div",{className:"flex-1"}),K==="direct"&&x!=="profile"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:qr,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:cn,onClick:()=>Ae(!ye),className:`p-1 rounded-md transition-colors shrink-0 ${ye?"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:it}),K==="direct"&&Er&&t.jsx(Gy,{agent:Er,tasks:xe,onViewProfile:X}),(K==="channel"||K==="dm")&&t.jsxs("span",{className:"text-xs text-fg-tertiary",children:[O.length," messages"]}),K==="dm"&&t.jsx("span",{className:"text-xs text-fg-tertiary ml-1",children:Ie?"· Private notepad":`· Direct message with ${ne?.name??""}`}),(K==="direct"&&q||K==="channel"&&Ue)&&t.jsxs("div",{className:"flex items-center gap-0.5 ml-4 -mb-px",children:[t.jsx("button",{onClick:()=>p("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:()=>p("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:K==="channel"?"Team":"Profile"})]}),t.jsx("div",{className:"ml-auto flex items-center gap-2",children:K==="direct"&&Er&&x!=="profile"&&t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("button",{onClick:qr,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:cn,onClick:()=>Ae(!ye),className:`p-1.5 rounded-md transition-colors ${ye?"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"})})})]})})]}),K==="direct"&&q&&x==="chat"&&Fe.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:Fe.map(Q=>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] ${Q.id===dt?"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(Q.id===re){Yt(re);const oe=B.current;F.current.delete(oe),V([])}else Pr(Q)},children:[Q.isMain&&t.jsx("span",{className:"text-[10px] opacity-50 shrink-0",children:"●"}),t.jsx("span",{className:"truncate",children:Q.id===re?"New Chat":Q.isMain?"Main":Q.title||"Conversation"}),!Q.isMain&&t.jsx("button",{onClick:oe=>{oe.stopPropagation(),ha(Q.id)},className:"opacity-0 group-hover:opacity-100 text-fg-tertiary hover:text-fg-secondary transition-opacity shrink-0",children:"✕"})]},Q.id))}),K==="direct"&&q&&ye&&t.jsxs("div",{ref:Tt,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:()=>Ae(!1),className:"text-fg-tertiary hover:text-fg-secondary text-xs",children:"✕"})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[_e.length===0&&t.jsx("div",{className:"text-xs text-fg-tertiary text-center py-6",children:"No conversations yet"}),(()=>{const Q=new Date,oe=new Date(Q.getFullYear(),Q.getMonth(),Q.getDate()).getTime(),Ce=oe-864e5,Ge=oe-7*864e5,Be=[],He=[],ct=[],Ze=[],Xe=[];for(const at of _e){const jt=new Date(at.lastMessageAt).getTime();jt>=oe?He.push(at):jt>=Ce?ct.push(at):jt>=Ge?Ze.push(at):Xe.push(at)}return He.length>0&&Be.push({label:"Today",items:He}),ct.length>0&&Be.push({label:"Yesterday",items:ct}),Ze.length>0&&Be.push({label:"Previous 7 days",items:Ze}),Xe.length>0&&Be.push({label:"Older",items:Xe}),Be.map(at=>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:at.label}),at.items.map(jt=>t.jsxs("button",{onClick:()=>{Pr(jt)},className:`w-full text-left px-3 py-2.5 rounded-lg text-xs mb-0.5 transition-colors ${jt.id===dt?"bg-brand-600/20 text-brand-500":"text-fg-secondary hover:bg-surface-elevated"}`,children:[t.jsxs("div",{className:"truncate font-medium flex items-center gap-1",children:[jt.isMain&&t.jsx("span",{className:"text-[10px] text-brand-500 opacity-60",children:"●"}),jt.isMain?"Main":jt.title||"Conversation"]}),t.jsx("div",{className:"text-fg-tertiary text-[10px] mt-0.5",children:new Date(jt.lastMessageAt).toLocaleString()})]},jt.id))]},at.label))})()]})]})]}),x==="profile"&&K==="direct"&&q&&t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsx(f_,{agentId:q,onBack:()=>p("chat"),inline:!0,defaultTab:T,highlightMailboxId:_,onSwipeBack:()=>{g.current==="profile"?history.back():p("chat")}})}),x==="profile"&&K==="channel"&&Ue&&t.jsx("div",{className:"flex-1 overflow-y-auto",onTouchStart:c?G.onTouchStart:void 0,onTouchEnd:c?G.onTouchEnd:void 0,children:t.jsx(E_,{teamId:Ue,onBack:()=>p("chat"),inline:!0})}),t.jsxs("div",{className:`flex-1 overflow-hidden flex flex-col relative ${x!=="chat"?"hidden":""}`,children:[je&&t.jsxs("div",{className:"absolute top-0 left-0 right-0 z-10 flex justify-center items-center gap-2 py-2 bg-gradient-to-b from-surface-primary/90 to-transparent pointer-events-none",children:[t.jsxs("svg",{className:"animate-spin h-3.5 w-3.5 text-brand-400",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-xs text-fg-tertiary",children:"Loading earlier messages…"})]}),t.jsxs("div",{ref:Ke,className:`flex-1 overflow-y-auto space-y-3 ${c?"p-2.5":"p-5"}`,onScroll:Te,onTouchStart:c?G.onTouchStart:void 0,onTouchEnd:c?G.onTouchEnd:void 0,children:[O.length===0&&!ee&&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:K==="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"})})}),K==="channel"&&t.jsxs("div",{children:["No messages in ",Ye?.name??z," yet."]}),K==="direct"&&!q&&t.jsx("div",{children:"Select an agent from the sidebar to start."}),K==="direct"&&q&&t.jsxs("div",{children:["Start a new conversation with ",Er?.name,"."]})]}),K==="channel"?O.map(Q=>t.jsxs("div",{id:`msg-${Q.id}`,className:"group/msg flex gap-3 transition-colors rounded-lg",children:[t.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center text-xs font-bold shrink-0 cursor-pointer ${Q.sender==="user"?"bg-brand-600 text-white":"bg-brand-500/15 text-brand-600 hover:ring-1 hover:ring-brand-500/40"}`,onClick:oe=>{if(Q.sender==="agent"&&Q.agentId){const Ce=oe.currentTarget.getBoundingClientRect();N({agentId:Q.agentId,top:Ce.top,left:Ce.right+8})}},children:Q.sender==="user"?Hs?.[0]??"Y":Q.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:Q.sender==="user"?Hs??"You":Q.agentName??"Agent"}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:Q.time})]}),Q.replyToId&&Q.replyToSender&&t.jsxs("button",{onClick:()=>{const oe=document.getElementById(`msg-${Q.replyToId}`);oe&&(oe.scrollIntoView({behavior:"smooth",block:"center"}),oe.classList.add("bg-brand-500/10"),setTimeout(()=>oe.classList.remove("bg-brand-500/10"),1500))},className:"flex items-center gap-1.5 mt-0.5 mb-1 pl-2 py-0.5 border-l-2 border-brand-500/40 text-xs text-fg-tertiary hover:text-fg-secondary transition-colors cursor-pointer",children:[t.jsx("span",{className:"font-medium text-brand-500/70",children:Q.replyToSender}),t.jsx("span",{className:"truncate max-w-[250px]",children:Q.replyToText??"..."})]}),t.jsx("div",{className:Q.isError||Q.sender==="agent"&&Q.text.startsWith("⚠")?"mt-0.5 px-3 py-2 rounded-lg border-b-2 border-red-500/60":"mt-0.5",children:Q.sender==="agent"?t.jsx(ir,{content:Q.text,className:"text-sm text-fg-secondary"}):t.jsxs("div",{className:"text-sm text-fg-secondary whitespace-pre-wrap",children:[Q.images&&Q.images.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1",children:Q.images.map((oe,Ce)=>t.jsx("img",{src:oe,alt:"",className:"max-w-[200px] max-h-[150px] rounded-lg object-cover cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>window.open(oe,"_blank")},Ce))}),Dy(Q.text,s)]})}),t.jsx("div",{className:`transition-opacity ${c?"opacity-100":"opacity-0 group-hover/msg:opacity-100"}`,children:t.jsx(Fy,{msg:Q,onCopy:tr,onRetry:$s,onReply:Bs,isCopied:ts===Q.id,isLastAgentMsg:Q.id===xr})})]})]},Q.id)):O.map((Q,oe)=>{const Ge=Ps&&oe===O.length-1&&ee,Be=!Ge||Q.isStopped;if(Q.isActivityLog){if(Q.activityType==="heartbeat"){const Ln=O[oe+1];if(Ln?.isActivityLog&&Ln.activityType==="heartbeat")return null}const He=__[Q.activityType??""],ct=He?.icon??"•",Ze=He?.category,Xe=!!(Q.taskId||Q.requirementId),at=!Xe&&!!Q.mailboxItemId,jt=Xe||at,Gt=A_.has(Q.activityType??""),It=Se.has(Q.id),un=Q.text+(Q.outcome?`
|
|
56
|
-
→ ${Q.outcome}`:""),_r=()=>{jt?Q.taskId?ht.navigate(me.WORK,{openTask:Q.taskId,...Gt?{scrollToComments:"true"}:{}}):Q.requirementId?ht.navigate(me.WORK,{openRequirement:Q.requirementId,...Gt?{scrollToComments:"true"}:{}}):Q.mailboxItemId&&q&&X(q,{tab:"mind",highlightMailboxId:Q.mailboxItemId}):Le(Ln=>{const wt=new Set(Ln);return wt.has(Q.id)?wt.delete(Q.id):wt.add(Q.id),wt})};return t.jsx("div",{id:`msg-${Q.id}`,className:`flex justify-start ${c?"max-w-[95%]":"max-w-[85%]"}`,children:t.jsxs("div",{className:"min-w-0 w-full",children:[t.jsxs("div",{className:"group/act flex items-center gap-2 py-0.5 px-2 rounded-md hover:bg-surface-elevated/30 transition-colors min-w-0 w-full overflow-hidden cursor-pointer",onClick:_r,title:jt?void 0:un,children:[t.jsx("span",{className:"text-[10px] text-fg-quaternary shrink-0 font-mono",children:Q.time}),t.jsx("span",{className:"shrink-0 text-xs",title:Q.activityType,children:ct}),Ze&&t.jsx("span",{className:"shrink-0 text-[9px] font-medium rounded py-px bg-surface-elevated text-fg-quaternary inline-flex items-center justify-center overflow-hidden",style:{width:68},children:Ze}),t.jsx("span",{className:`text-xs text-fg-tertiary truncate min-w-0 flex-1 ${jt?"group-hover/act:text-brand-500 transition-colors":""}`,children:Q.text}),Q.outcome&&!It&&t.jsxs("span",{className:"text-[10px] text-fg-quaternary shrink-0 truncate max-w-[50%]",children:["→ ",Q.outcome]})]}),It&&Q.outcome&&t.jsx("div",{className:"ml-10 mr-4 mt-1 mb-2 py-2 px-3 rounded-md bg-surface-elevated/40 text-[11px] text-fg-tertiary whitespace-pre-wrap break-words leading-relaxed max-h-[240px] overflow-y-auto",children:Q.outcome})]})},Q.id)}return t.jsx("div",{id:`msg-${Q.id}`,className:`group/msg flex transition-colors rounded-lg ${Q.sender==="user"?"justify-end":"justify-start"}`,children:t.jsxs("div",{className:[c?"max-w-[95%]":"max-w-[85%]",Q.sender==="agent"?c?"min-w-[200px]":"min-w-[280px]":""].join(" "),children:[t.jsxs("div",{className:"text-xs text-fg-tertiary mb-1",children:[Q.sender==="user"?Hs??"You":t.jsx(M_,{name:Q.agentName??(K==="direct"?Er?.name??"Agent":"Agent"),agentId:Q.agentId??(K==="direct"?Er?.id:void 0),agents:s,onViewProfile:X})," · ",Q.time]}),Q.replyToId&&Q.replyToSender&&t.jsxs("button",{onClick:()=>{const He=document.getElementById(`msg-${Q.replyToId}`);He&&(He.scrollIntoView({behavior:"smooth",block:"center"}),He.classList.add("bg-brand-500/10"),setTimeout(()=>He.classList.remove("bg-brand-500/10"),1500))},className:"flex items-center gap-1.5 mb-1 pl-2 py-0.5 border-l-2 border-brand-500/40 text-[10px] text-fg-tertiary hover:text-fg-secondary transition-colors cursor-pointer",children:[t.jsx("span",{className:"font-medium text-brand-500/70",children:Q.replyToSender}),t.jsx("span",{className:"truncate max-w-[200px]",children:Q.replyToText??"..."})]}),t.jsx("div",{className:`rounded-2xl text-sm ${c?"px-3 py-2":"px-4 py-3"} ${Q.sender==="user"?"bg-brand-600 text-white rounded-br-sm":Q.isError||Q.sender==="agent"&&Q.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"} ${Ge&&Q.sender==="agent"?"streaming-bubble":""}`,children:Q.sender==="user"?t.jsxs(t.Fragment,{children:[Q.images&&Q.images.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:Q.images.map((He,ct)=>t.jsx("img",{src:He,alt:"",className:"max-w-[200px] max-h-[150px] rounded-lg object-cover cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>window.open(He,"_blank")},ct))}),Q.text&&t.jsx("span",{className:"whitespace-pre-wrap leading-relaxed",children:Dy(Q.text,s)})]}):t.jsx(D_,{msg:Q,isStreaming:Ge,liveActivities:Ge?ae:[],onViewModeChange:He=>Ns(ct=>{const Ze=new Set(ct);return He==="full"?Ze.add(Q.id):Ze.delete(Q.id),Ze})})}),Be&&t.jsx("div",{className:`transition-opacity ${Q.isStopped||c?"opacity-100":"opacity-0 group-hover/msg:opacity-100"} ${Q.sender==="user"?"flex justify-end":""}`,children:t.jsx(Fy,{msg:Q,onCopy:tr,onRetry:$s,onReply:Bs,isCopied:ts===Q.id,isLastAgentMsg:Q.id===xr})})]})},Q.id)}),K==="channel"&&ee&&t.jsx("div",{className:"text-xs text-fg-tertiary animate-pulse ml-11",children:"Agent is thinking…"}),t.jsx("div",{ref:We})]})]}),w&&(()=>{const Q=s.find(oe=>oe.id===w.agentId);return Q?t.jsx(R_,{agent:Q,anchorRect:{top:w.top,left:w.left},onClose:()=>N(null),onViewProfile:X}):null})(),t.jsxs("div",{className:`p-4 border-t border-border-default bg-surface-secondary relative shrink-0 ${x!=="chat"?"hidden":""}`,onDrop:_i,onDragOver:Cr,children:[Dn&&Tr.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"}),Tr.map((Q,oe)=>t.jsxs("button",{onClick:()=>Yn(Q.name),onMouseEnter:()=>$e(oe),className:`w-full text-left px-4 py-2 text-sm flex items-center gap-2 transition-colors ${oe===le?"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:Q.name.slice(0,2).toUpperCase()}),t.jsx("span",{className:"flex-1 min-w-0",children:Q.name}),t.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:Q.role})]},Q.id))]}),nt.length>0&&t.jsxs("div",{className:"flex items-center gap-2 mb-2 overflow-x-auto pb-1",children:[nt.map(Q=>t.jsxs("div",{className:"relative group/img shrink-0",children:[t.jsx("img",{src:Q.dataUrl,alt:Q.name,className:"w-16 h-16 rounded-lg object-cover border border-border-default"}),t.jsx("button",{onClick:()=>cr(Q.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:"×"})]},Q.id)),nt.length<fs&&t.jsx("button",{onClick:()=>yt.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:yt,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:Q=>{Q.target.files&&Sr(Q.target.files),Q.target.value=""}}),H&&t.jsxs("div",{className:"flex items-center gap-2 mb-2 px-3 py-1.5 bg-surface-elevated rounded-lg border border-border-default/50",children:[t.jsxs("div",{className:"flex-1 min-w-0 pl-2 border-l-2 border-brand-500/50",children:[t.jsx("span",{className:"text-[11px] font-medium text-brand-500",children:H.sender}),t.jsx("p",{className:"text-[11px] text-fg-tertiary truncate",children:H.text})]}),t.jsx("button",{onClick:()=>W(null),className:"text-fg-tertiary hover:text-fg-secondary shrink-0 p-0.5",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"})]})})]}),t.jsxs("div",{className:"flex gap-2 items-end",children:[t.jsx("button",{onClick:()=>yt.current?.click(),disabled:K==="direct"&&!q,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:Rt,value:I,onChange:Q=>{ma(Q.target.value),Q.target.style.height="auto";const oe=Math.min(Q.target.scrollHeight,120);Q.target.style.height=`${oe}px`,Q.target.style.overflowY=oe>=120?"auto":"hidden"},onKeyDown:Q=>{if(Dn&&Tr.length>0){const oe=Q.key==="ArrowUp"||Q.ctrlKey&&Q.key==="p",Ce=Q.key==="ArrowDown"||Q.ctrlKey&&Q.key==="n",Ge=Q.key==="Enter"||Q.key==="Tab",Be=Q.key==="Escape";if(oe){Q.preventDefault(),$e(He=>(He-1+Tr.length)%Tr.length);return}if(Ce){Q.preventDefault(),$e(He=>(He+1)%Tr.length);return}if(Ge){Q.preventDefault();const He=Tr[le];He&&Yn(He.name);return}if(Be){Q.preventDefault(),Nt(!1);return}}Q.key==="Enter"&&!Q.shiftKey&&(Q.preventDefault(),vr())},onPaste:Wa,placeholder:sn,disabled:K==="direct"&&!q,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"}}),ee&&K!=="dm"&&t.jsx("button",{onClick:qt,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:()=>{vr()},disabled:K==="direct"&&!q||!I.trim()&&nt.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 Gy({agent:e,tasks:n,onViewProfile:s}){const[i,l]=v.useState(!1),d=v.useRef(null),c=v.useRef(null),h=e.status==="working",m=e.status==="error",f=h?n.find(w=>w.assignedAgentId===e.id&&w.status==="in_progress"):null,x=e.currentActivity;v.useEffect(()=>{if(!i)return;const w=N=>{d.current&&!d.current.contains(N.target)&&l(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[i]),v.useLayoutEffect(()=>{if(!i||!c.current)return;const w=c.current,N=w.getBoundingClientRect(),T=window.innerWidth;N.right>T-8&&(w.style.left="auto",w.style.right="0"),N.left<8&&(w.style.left="0",w.style.right="auto");const C=T-16;N.width>C&&(w.style.width=`${C}px`)},[i]);const p=m?"bg-red-400 animate-pulse":h?"bg-blue-400 animate-pulse":"bg-green-400",g=m?"error":h?"working":"idle",y=x?x.type==="heartbeat"?`Heartbeat: ${x.heartbeatName??x.label}`:x.type==="chat"?x.label:x.type==="task"?`Task: ${x.label}`:x.label:"Processing...";return t.jsxs("div",{className:"relative",ref:d,children:[t.jsxs("button",{onClick:()=>l(w=>!w),className:`flex items-center gap-1.5 px-2 py-0.5 rounded-full transition-colors ${h?"bg-blue-500/10 border border-blue-500/20 hover:bg-blue-500/20":m?"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 ${m?"text-red-500":h?"text-blue-500":"text-green-600"}`,children:g}),e.mailboxDepth!=null&&e.mailboxDepth>0&&t.jsx("span",{className:"text-[9px] bg-fg-tertiary/20 text-fg-tertiary rounded-full px-1.5",children:e.mailboxDepth})]}),i&&m&&t.jsxs("div",{ref:c,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 max-w-[calc(100vw-1rem)] 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:()=>{l(!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 →"})]}),i&&h&&t.jsxs("div",{ref:c,className:"absolute top-full left-0 mt-1.5 bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-30 w-80 max-w-[calc(100vw-1rem)] p-3 space-y-2",children:[t.jsx("p",{className:"text-[10px] text-fg-tertiary uppercase font-semibold",children:"Current Activity"}),f?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:()=>{l(!1),ht.navigate(me.WORK,{openTask:f.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:f.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 ${x?.type==="heartbeat"||x?.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:y}),t.jsx("div",{className:"text-[10px] text-fg-tertiary",children:x?.type==="heartbeat"?"Periodic check-in task":x?.type==="chat"?"Responding to conversation":"Agent is thinking or communicating"})]})]}),t.jsx("button",{onClick:()=>{l(!1),s?.(e.id,{tab:"mind"})},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 Mind →"})]})]})}const z_=[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"cyberpunk",label:"Cyberpunk"},{value:"midnight",label:"Midnight"}],Xj="markus-theme";function Xy(e){const n=document.documentElement;n.classList.remove("light","dark","cyberpunk","midnight"),e==="light"?n.classList.add("light"):e==="dark"?n.classList.add("dark"):e==="cyberpunk"?n.classList.add("cyberpunk"):e==="midnight"&&n.classList.add("midnight")}function $_(){try{const e=localStorage.getItem(Xj);if(e==="light"||e==="dark"||e==="system"||e==="cyberpunk"||e==="midnight")return e}catch{}return"system"}function B_(){const[e,n]=v.useState($_),s=v.useCallback(i=>{n(i);try{localStorage.setItem(Xj,i)}catch{}Xy(i)},[]);return v.useEffect(()=>{Xy(e)},[e]),{mode:e,setMode:s}}function Kj({theme:e,onThemeChange:n}={}){const[s,i]=v.useState(null),[l,d]=v.useState(null),[c,h]=v.useState(""),[m,f]=v.useState(!1),[x,p]=v.useState(null),[g,y]=v.useState(null),[w,N]=v.useState(null),[T,C]=v.useState(null),[_,k]=v.useState(!1),[M,D]=v.useState(null),[A,G]=v.useState(null),[X,K]=v.useState(!1),[$,q]=v.useState(null),[U,z]=v.useState({}),[E,L]=v.useState(!1),[R,F]=v.useState([]),[Y,Z]=v.useState([]),[B,O]=v.useState(null),[V,I]=v.useState(null),[S,H]=v.useState(""),[W,ee]=v.useState(null),te=v.useRef(null),ae=v.useRef(!1),[he,Ne]=v.useState(!1),[De,je]=v.useState(200),[ke,Se]=v.useState(!1),[Le,nt]=v.useState(null),[rt,yt]=v.useState(null),[Rt,re]=v.useState(!1),[_e,st]=v.useState(new Set),[dt,Yt]=v.useState(null),[ye,Ae]=v.useState(!1),Fe=()=>({"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("markus_token")??""}`}),Qe=v.useCallback(()=>{se.health().then(i).catch(()=>{}),fetch("/api/settings/llm").then(de=>de.ok?de.json():Promise.reject(de.status)).then(de=>{de&&typeof de=="object"&&"providers"in de&&(d(de),h(de.defaultProvider))}).catch(()=>{})},[]),xt=v.useCallback(()=>{fetch("/api/settings/oauth/providers").then(de=>de.ok?de.json():Promise.reject(de.status)).then(de=>F(de.providers??[])).catch(()=>{})},[]),nn=v.useCallback(()=>{fetch("/api/settings/oauth/profiles",{headers:Fe()}).then(de=>de.ok?de.json():Promise.reject(de.status)).then(de=>Z(de.profiles??[])).catch(()=>{})},[]),cn=v.useCallback(()=>{se.settings.getAgent().then(de=>{de&&typeof de.maxToolIterations=="number"&&je(de.maxToolIterations)}).catch(()=>{})},[]),Tt=v.useCallback(()=>{re(!0),se.system.storage().then(yt).catch(()=>{}).finally(()=>re(!1)),se.system.orphans().then(Yt).catch(()=>{})},[]);v.useEffect(()=>{Qe(),xt(),nn(),cn(),Tt()},[Qe,xt,nn,cn,Tt]),v.useEffect(()=>{const de=()=>Tt();return window.addEventListener("markus:data-changed",de),()=>window.removeEventListener("markus:data-changed",de)},[Tt]);const gt=v.useCallback(async()=>{K(!0),q(null),G(null),z({});try{const de=await fetch("/api/settings/env-models",{headers:Fe()});if(!de.ok){q({type:"err",text:`Detection failed (HTTP ${de.status})`});return}const Te=await de.json();if(G(Te),Te.detected.length===0)q({type:"err",text:"No model API keys found in environment variables"});else{const Ve={};for(const qt of Te.detected)Ve[qt.provider]=!0;z(Ve)}}catch{q({type:"err",text:"Failed to detect environment variables"})}finally{K(!1)}},[]),Bt=l?Object.values(l.providers).some(de=>de.configured):!1;v.useEffect(()=>{l&&!Bt&&!ae.current&&(ae.current=!0,gt())},[l,Bt,gt]);const _t=async()=>{if(!(!c||c===l?.defaultProvider)){f(!0),p(null);try{const de=await fetch("/api/settings/llm",{method:"POST",headers:Fe(),body:JSON.stringify({defaultProvider:c})}),Te=await de.json();de.ok?(d(Te),p({type:"ok",text:`Default provider updated to ${Te.defaultProvider}`})):p({type:"err",text:Te.error??"Save failed"})}catch{p({type:"err",text:"Network error"})}finally{f(!1)}}},Ht=async(de,Te)=>{N(de);try{const Ve=await fetch(`/api/settings/llm/providers/${de}/toggle`,{method:"POST",headers:Fe(),body:JSON.stringify({enabled:Te})});if(Ve.ok){const qt=await Ve.json();d(qt)}}catch{}finally{N(null)}},rn=async()=>{k(!0),D(null);try{const Te=await(await fetch("/api/settings/import/openclaw",{method:"POST",headers:Fe(),body:JSON.stringify({preview:!0})})).json();"error"in Te?D({type:"err",text:Te.error}):C(Te)}catch{D({type:"err",text:"Detection failed"})}finally{k(!1)}},bn=async()=>{k(!0),D(null);try{const Te=await(await fetch("/api/settings/import/openclaw",{method:"POST",headers:Fe(),body:JSON.stringify({preview:!1})})).json();"error"in Te?D({type:"err",text:Te.error}):(D({type:"ok",text:`Imported ${Te.appliedModels} model configs from OpenClaw`}),Qe())}catch{D({type:"err",text:"Import failed"})}finally{k(!1)}},Hn=async()=>{if(!A)return;const de=A.detected.filter(Te=>U[Te.provider]);if(de.length===0){q({type:"err",text:"Select at least one provider to apply"});return}L(!0),q(null);try{const Te=await fetch("/api/settings/env-models",{method:"POST",headers:Fe(),body:JSON.stringify({providers:de.map(qt=>({provider:qt.provider,model:qt.model,baseUrl:qt.baseUrl,enabled:!0}))})});if(!Te.ok){q({type:"err",text:`Apply failed (HTTP ${Te.status})`});return}const Ve=await Te.json();q({type:"ok",text:Ve.message}),G(null),z({}),Qe()}catch{q({type:"err",text:"Failed to apply environment configs"})}finally{L(!1)}};v.useEffect(()=>()=>{te.current&&clearInterval(te.current)},[]);const[Cn,xe]=v.useState(!1),[Re,vt]=v.useState({name:"",apiKey:"",baseUrl:"",model:"",contextWindow:128e3,maxOutputTokens:16384,costInput:1,costOutput:5}),[At,Dt]=v.useState(!1),[On,an]=v.useState(null),[dn,Dn]=v.useState(null),[Nt,hn]=v.useState({apiKey:"",baseUrl:"",model:"",contextWindow:0,maxOutputTokens:0,costInput:0,costOutput:0}),[lr,le]=v.useState(!1),[$e,Ue]=v.useState(null),[We,Ke]=v.useState(null),[qe,Je]=v.useState({id:"",name:"",contextWindow:128e3,maxOutputTokens:16384,costInput:1,costOutput:5,reasoning:!1,vision:!1}),[Wt,Zt]=v.useState(!1),Pt=async()=>{if(!(!Re.name||!Re.model)){Dt(!0),an(null);try{const de=await fetch("/api/settings/llm/providers",{method:"POST",headers:Fe(),body:JSON.stringify({name:Re.name,apiKey:Re.apiKey||void 0,baseUrl:Re.baseUrl||void 0,model:Re.model,contextWindow:Re.contextWindow||void 0,maxOutputTokens:Re.maxOutputTokens||void 0,cost:Re.costInput||Re.costOutput?{input:Re.costInput,output:Re.costOutput}:void 0})}),Te=await de.json();de.ok?(d(Te),xe(!1),vt({name:"",apiKey:"",baseUrl:"",model:"",contextWindow:128e3,maxOutputTokens:16384,costInput:1,costOutput:5}),an({type:"ok",text:`Provider ${Re.name} added`})):an({type:"err",text:Te.error??"Failed to add"})}catch{an({type:"err",text:"Network error"})}finally{Dt(!1)}}},En=(de,Te)=>{Dn(de),hn({apiKey:"",baseUrl:Te.baseUrl??"",model:Te.model,contextWindow:Te.contextWindow??0,maxOutputTokens:Te.maxOutputTokens??0,costInput:Te.cost?.input??0,costOutput:Te.cost?.output??0})},be=async de=>{le(!0);try{const Te={};Nt.apiKey&&(Te.apiKey=Nt.apiKey),Nt.baseUrl!==void 0&&(Te.baseUrl=Nt.baseUrl),Nt.model&&(Te.model=Nt.model),Nt.contextWindow&&(Te.contextWindow=Nt.contextWindow),Nt.maxOutputTokens&&(Te.maxOutputTokens=Nt.maxOutputTokens),(Nt.costInput||Nt.costOutput)&&(Te.cost={input:Nt.costInput,output:Nt.costOutput});const Ve=await fetch(`/api/settings/llm/providers/${de}`,{method:"PUT",headers:Fe(),body:JSON.stringify(Te)});if(Ve.ok){const qt=await Ve.json();d(qt),Dn(null)}}catch{}finally{le(!1)}},ze=async de=>{Ue(de);try{const Te=await fetch(`/api/settings/llm/providers/${de}`,{method:"DELETE",headers:Fe()});if(Te.ok){const Ve=await Te.json();d(Ve),h(Ve.defaultProvider)}}catch{}finally{Ue(null)}},Et=async de=>{if(!(!qe.id||!qe.name)){Zt(!0);try{const Te=await fetch(`/api/settings/llm/providers/${de}/models`,{method:"POST",headers:Fe(),body:JSON.stringify({id:qe.id,name:qe.name,contextWindow:qe.contextWindow,maxOutputTokens:qe.maxOutputTokens,cost:{input:qe.costInput,output:qe.costOutput},reasoning:qe.reasoning||void 0,inputTypes:qe.vision?["text","image"]:["text"]})});if(Te.ok){const Ve=await Te.json();d(Ve),Ke(null),Je({id:"",name:"",contextWindow:128e3,maxOutputTokens:16384,costInput:1,costOutput:5,reasoning:!1,vision:!1})}}catch{}finally{Zt(!1)}}},kt=async(de,Te)=>{try{const Ve=await fetch(`/api/settings/llm/providers/${de}/models/${encodeURIComponent(Te)}`,{method:"DELETE",headers:Fe()});if(Ve.ok){const qt=await Ve.json();d(qt)}}catch{}},yn=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"]),[_n,or]=v.useState(null),Nn=async(de,Te)=>{or(`${de}:${Te}`);try{const Ve=await fetch(`/api/settings/llm/providers/${de}/model`,{method:"POST",headers:Fe(),body:JSON.stringify({model:Te})});if(Ve.ok){const qt=await Ve.json();d(qt)}}catch{}finally{or(null)}},yr=l?.providers?Object.entries(l.providers).filter(([,de])=>de.configured&&de.enabled).map(([de])=>de):[],Hr=l&&!Bt&&!he;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(Ha,{title:"Appearance",children:t.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:t.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-center md: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 a visual style for the interface"})]}),t.jsx("div",{className:"flex flex-wrap gap-1 bg-surface-elevated rounded-lg p-0.5",children:z_.map(({value:de,label:Te})=>t.jsx("button",{onClick:()=>n?.(de),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${e===de?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary"}`,children:Te},de))})]})})}),Hr&&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:()=>Ne(!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(Wh,{step:"1",title:"From Environment Variables",description:"Automatically detected API keys from .env or system environment.",active:!!(A&&A.detected.length>0),children:[X&&t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Detecting..."}),A&&A.detected.length>0&&t.jsxs("div",{className:"space-y-2",children:[A.detected.map(de=>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:U[de.provider]??!1,onChange:Te=>z({...U,[de.provider]:Te.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:de.displayName}),t.jsx("span",{className:"text-xs text-fg-tertiary ml-2",children:de.model})]}),t.jsx("code",{className:"text-[10px] text-fg-tertiary",children:de.apiKeyPreview})]},de.provider)),t.jsx("button",{onClick:()=>{Hn()},disabled:E||Object.values(U).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:E?"Applying...":`Apply ${Object.values(U).filter(Boolean).length} Provider(s)`})]}),A&&A.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(hi,{type:$.type,text:$.text})]}),t.jsxs(Wh,{step:"2",title:"From OpenClaw Config",description:"Import model configs from an existing OpenClaw installation.",children:[T?T.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:T.summary.configPath})]}),T.summary.models&&t.jsxs("div",{className:"text-xs text-fg-secondary",children:[T.summary.models.providerCount," providers, ",T.summary.models.providers.reduce((de,Te)=>de+Te.modelCount,0)," models"]}),t.jsx("button",{onClick:()=>{bn()},disabled:_,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:_?"Importing...":"Import Model Configs"})]}):t.jsx("div",{className:"text-xs text-fg-tertiary",children:"No OpenClaw config found."}):t.jsx("button",{onClick:()=>{rn()},disabled:_,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:_?"Detecting...":"Detect OpenClaw"}),M&&t.jsx(hi,{type:M.type,text:M.text})]}),t.jsx(Wh,{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(Ha,{title:"System Status",children:s?t.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[t.jsx(Qh,{label:"Status",value:s.status==="ok"?"Healthy":s.status,color:"green"}),t.jsx(Qh,{label:"Version",value:s.version,color:"indigo"}),t.jsx(Qh,{label:"Active Agents",value:String(s.agents),color:"purple"})]}):t.jsx("div",{className:"text-sm text-fg-tertiary",children:"Loading..."})}),t.jsx(Ha,{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:[l?t.jsx("select",{value:c,onChange:de=>{h(de.target.value),p(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:yr.length>0?yr.map(de=>t.jsx("option",{value:de,children:l.providers[de]?.displayName??de},de)):t.jsx("option",{value:"",children:"No providers configured"})}):t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Loading..."}),c!==l?.defaultProvider&&t.jsx("button",{onClick:()=>{_t()},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(hi,{type:x.type,text:x.text})]})}),t.jsxs(Ha,{title:"Model Providers & Pricing",children:[t.jsx("div",{className:"space-y-3",children:l&&Object.entries(l.providers).map(([de,Te])=>t.jsxs("div",{className:`bg-surface-secondary border rounded-xl overflow-hidden transition-colors ${Te.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(g===de?null:de),children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${Te.configured&&Te.enabled?"bg-green-400":Te.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:Te.displayName??de}),de===l.defaultProvider&&t.jsx("span",{className:"text-[10px] bg-brand-500/15 text-brand-500 px-1.5 py-0.5 rounded",children:"default"}),Te.configured&&!Te.enabled&&t.jsx("span",{className:"text-[10px] bg-amber-500/15 text-amber-600 px-1.5 py-0.5 rounded",children:"disabled"}),Te.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:Te.model||"Not configured"})]})]}),t.jsxs("div",{className:"flex items-center gap-4",children:[Te.configured&&t.jsx("button",{onClick:Ve=>{Ve.stopPropagation(),Ht(de,!Te.enabled)},disabled:w===de,className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${Te.enabled?"bg-green-500":"bg-gray-600"} ${w===de?"opacity-50":""}`,title:Te.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 ${Te.enabled?"translate-x-4":"translate-x-1"}`})}),Te.contextWindow&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[(Te.contextWindow/1e3).toFixed(0),"K ctx"]}),Te.cost&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["$",Te.cost.input,"/",Te.cost.output," per 1M"]}),t.jsx("span",{className:"text-fg-tertiary text-xs",children:g===de?"▲":"▼"})]})]}),g===de&&t.jsxs("div",{className:"px-5 pb-4 border-t border-border-default pt-4 space-y-4",children:[Te.configured&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[t.jsx(Pa,{label:"Model",value:Te.model}),t.jsx(Pa,{label:"Context Window",value:Te.contextWindow?`${(Te.contextWindow/1e3).toFixed(0)}K tokens`:"N/A"}),t.jsx(Pa,{label:"Max Output",value:Te.maxOutputTokens?`${(Te.maxOutputTokens/1e3).toFixed(0)}K tokens`:"N/A"}),t.jsx(Pa,{label:"Base URL",value:Te.baseUrl??"Default"})]}),dn===de?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:Nt.apiKey,onChange:Ve=>hn({...Nt,apiKey:Ve.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:Nt.baseUrl,onChange:Ve=>hn({...Nt,baseUrl:Ve.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:Nt.model,onChange:Ve=>hn({...Nt,model:Ve.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:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"Context Window"}),t.jsx("input",{type:"number",value:Nt.contextWindow||"",onChange:Ve=>hn({...Nt,contextWindow:Number(Ve.target.value)}),placeholder:"e.g. 128000",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:"Max Output Tokens"}),t.jsx("input",{type:"number",value:Nt.maxOutputTokens||"",onChange:Ve=>hn({...Nt,maxOutputTokens:Number(Ve.target.value)}),placeholder:"e.g. 16384",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:"$/1M Input"}),t.jsx("input",{type:"number",step:"0.01",value:Nt.costInput||"",onChange:Ve=>hn({...Nt,costInput:Number(Ve.target.value)}),placeholder:"e.g. 1",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:"$/1M Output"}),t.jsx("input",{type:"number",step:"0.01",value:Nt.costOutput||"",onChange:Ve=>hn({...Nt,costOutput:Number(Ve.target.value)}),placeholder:"e.g. 5",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",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>{be(de)},disabled:lr,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:lr?"Saving...":"Save"}),t.jsx("button",{onClick:()=>Dn(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:Ve=>{Ve.stopPropagation(),En(de,Te)},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:Ve=>{Ve.stopPropagation(),confirm(`Delete provider "${Te.displayName??de}"?`)&&ze(de)},disabled:$e===de,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:$e===de?"Deleting...":"Delete"})]})]}),Te.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(Pa,{label:"Input",value:`$${Te.cost.input}`}),t.jsx(Pa,{label:"Output",value:`$${Te.cost.output}`}),Te.cost.cacheRead!=null&&t.jsx(Pa,{label:"Cache Read",value:`$${Te.cost.cacheRead}`}),Te.cost.cacheWrite!=null&&t.jsx(Pa,{label:"Cache Write",value:`$${Te.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"}),Te.configured&&We!==de&&t.jsx("button",{onClick:()=>{Ke(de),Je({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"})]}),We===de&&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:qe.id,onChange:Ve=>Je({...qe,id:Ve.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:qe.name,onChange:Ve=>Je({...qe,name:Ve.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:qe.contextWindow,onChange:Ve=>Je({...qe,contextWindow:Number(Ve.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:qe.maxOutputTokens,onChange:Ve=>Je({...qe,maxOutputTokens:Number(Ve.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:qe.costInput,onChange:Ve=>Je({...qe,costInput:Number(Ve.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:qe.costOutput,onChange:Ve=>Je({...qe,costOutput:Number(Ve.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:qe.reasoning,onChange:Ve=>Je({...qe,reasoning:Ve.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:qe.vision,onChange:Ve=>Je({...qe,vision:Ve.target.checked}),className:"rounded"}),"vision"]}),t.jsx("div",{className:"flex-1"}),t.jsx("button",{onClick:()=>{Et(de)},disabled:Wt||!qe.id||!qe.name,className:"px-2 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white rounded transition-colors",children:Wt?"Adding...":"Add"}),t.jsx("button",{onClick:()=>Ke(null),className:"px-2 py-1 text-[10px] border border-border-default text-fg-secondary hover:bg-surface-elevated rounded transition-colors",children:"Cancel"})]})]}),Te.models&&Te.models.length>0&&t.jsx("div",{className:"space-y-1.5",children:Te.models.map(Ve=>{const qt=Ve.id===Te.model,vr=_n===`${de}:${Ve.id}`,ts=!yn.has(Ve.id);return t.jsxs("div",{className:`flex items-center justify-between px-3 py-2 rounded-lg text-xs transition-colors ${qt?"bg-brand-500/15 border border-brand-500/30":Te.configured?"bg-surface-elevated/30 hover:bg-surface-elevated/60 cursor-pointer":"bg-surface-elevated/30"}`,onClick:()=>{!qt&&Te.configured&&!vr&&Nn(de,Ve.id)},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[qt&&t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-500 shrink-0"}),t.jsx("span",{className:qt?"text-brand-500 font-medium":"text-fg-secondary",children:Ve.name}),Ve.reasoning&&t.jsx("span",{className:"text-[9px] bg-amber-500/15 text-amber-600 px-1 py-0.5 rounded",children:"reasoning"}),Ve.inputTypes?.includes("image")&&t.jsx("span",{className:"text-[9px] bg-blue-500/15 text-blue-600 px-1 py-0.5 rounded",children:"vision"}),ts&&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:[(Ve.contextWindow/1e3).toFixed(0),"K ctx"]}),t.jsxs("span",{children:["$",Ve.cost.input,"/$",Ve.cost.output]}),Te.configured&&!qt&&t.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded transition-colors ${vr?"bg-brand-500/30 text-brand-400":"bg-surface-overlay text-fg-tertiary hover:bg-brand-500/20 hover:text-brand-500"}`,children:vr?"Switching...":"Use"}),qt&&t.jsx("span",{className:"text-[9px] bg-brand-500/15 text-brand-500 px-1.5 py-0.5 rounded",children:"active"}),ts&&!qt&&t.jsx("button",{onClick:Nr=>{Nr.stopPropagation(),kt(de,Ve.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"})})})]})]},Ve.id)})})]}),!Te.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.'})]})]},de))}),Cn?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:Re.name,onChange:de=>vt({...Re,name:de.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:Re.apiKey,onChange:de=>vt({...Re,apiKey:de.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:Re.baseUrl,onChange:de=>vt({...Re,baseUrl:de.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:Re.model,onChange:de=>vt({...Re,model:de.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:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"Context Window"}),t.jsx("input",{type:"number",value:Re.contextWindow,onChange:de=>vt({...Re,contextWindow:Number(de.target.value)}),placeholder:"128000",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:"Max Output Tokens"}),t.jsx("input",{type:"number",value:Re.maxOutputTokens,onChange:de=>vt({...Re,maxOutputTokens:Number(de.target.value)}),placeholder:"16384",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:"$/1M Input"}),t.jsx("input",{type:"number",step:"0.01",value:Re.costInput,onChange:de=>vt({...Re,costInput:Number(de.target.value)}),placeholder:"1",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:"$/1M Output"}),t.jsx("input",{type:"number",step:"0.01",value:Re.costOutput,onChange:de=>vt({...Re,costOutput:Number(de.target.value)}),placeholder:"5",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:()=>{Pt()},disabled:At||!Re.name||!Re.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:At?"Adding...":"Add Provider"}),t.jsx("button",{onClick:()=>{xe(!1),an(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"})]}),On&&t.jsx(hi,{type:On.type,text:On.text})]}):t.jsx("button",{onClick:()=>xe(!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(Ha,{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:()=>{gt()},disabled:X,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 ${X?"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"})}),X?"Detecting...":"Refresh Environment Variables"]}),A&&A.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:"}),A.detected.map(de=>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:U[de.provider]??!1,onChange:Te=>z({...U,[de.provider]:Te.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:de.displayName}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:["Key: ",t.jsx("code",{className:"text-fg-secondary",children:de.apiKeyPreview})," / ","Model: ",t.jsx("code",{className:"text-fg-secondary",children:de.model}),de.baseUrl&&t.jsxs(t.Fragment,{children:[" / ","URL: ",t.jsx("code",{className:"text-fg-secondary",children:de.baseUrl})]})]})]})]}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:Object.keys(de.envVars).map(Te=>t.jsx("div",{children:t.jsx("code",{children:Te})},Te))})]},de.provider)),A.timeoutMs&&t.jsxs("div",{className:"text-xs text-fg-tertiary",children:["LLM Timeout: ",t.jsxs("code",{className:"text-fg-secondary",children:[A.timeoutMs,"ms"]})," (from ",t.jsx("code",{children:"LLM_TIMEOUT_MS"}),")"]}),t.jsx("button",{onClick:()=>{Hn()},disabled:E||Object.values(U).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:E?"Applying...":`Apply ${Object.values(U).filter(Boolean).length} Provider(s) to Config`})]}),$&&t.jsx(hi,{type:$.type,text:$.text})]})}),t.jsx(Ha,{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:()=>{rn()},disabled:_,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:_?"Detecting...":"Detect OpenClaw Config"})}),T&&T.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:T.summary.configPath})]}),T.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:[T.summary.models.providerCount," model providers found:"]}),t.jsx("div",{className:"space-y-1",children:T.summary.models.providers.map(de=>t.jsxs("div",{className:"flex items-center justify-between text-xs",children:[t.jsx("span",{className:"text-fg-secondary",children:de.name}),t.jsxs("span",{className:"text-fg-tertiary",children:[de.modelCount," models ",de.baseUrl?`(${de.baseUrl})`:""]})]},de.name))})]}),T.summary.channels&&T.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: ",T.summary.channels.join(", ")]})}),t.jsx("button",{onClick:()=>{bn()},disabled:_,className:"px-4 py-2 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-lg transition-colors",children:_?"Importing...":"Import Model Configs"})]}),M&&t.jsx(hi,{type:M.type,text:M.text})]})}),t.jsx(Ha,{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:de=>{je(Number(de.target.value)),nt(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:ke,onClick:async()=>{Se(!0),nt(null);try{const de=await se.settings.updateAgent({maxToolIterations:De});je(de.maxToolIterations),nt({type:"ok",text:"Saved"})}catch{nt({type:"err",text:"Failed to save"})}Se(!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:ke?"Saving…":"Save"})]})]}),Le&&t.jsx(hi,{type:Le.type,text:Le.text})]})}),t.jsx(Ha,{title:"Data & Storage",children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 space-y-5",children:[Rt&&!rt&&t.jsx("div",{className:"text-sm text-fg-tertiary",children:"Scanning storage..."}),rt&&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:Rs(rt.totalSize)}),t.jsx("div",{className:"text-xs text-fg-tertiary font-mono mt-0.5",children:rt.dataDir})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>Tt(),disabled:Rt,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:Rt?"Scanning...":"Refresh"}),t.jsx("button",{onClick:()=>{se.system.openPath(rt.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:rt.breakdown.filter(de=>de.size>0).map(de=>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:de.name}),t.jsx("span",{className:"text-xs text-fg-tertiary ml-2",children:de.description})]}),t.jsx("span",{className:"text-sm font-medium text-fg-secondary tabular-nums shrink-0 ml-3",children:Rs(de.size)})]},de.name))})]}),rt.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 (",rt.agents.length,")"]}),t.jsx("div",{className:"space-y-1",children:rt.agents.map(de=>{const Te=_e.has(de.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:()=>st(Ve=>{const qt=new Set(Ve);return qt.has(de.id)?qt.delete(de.id):qt.add(de.id),qt}),children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:Te?"▼":"▶"}),t.jsx("button",{onClick:Ve=>{Ve.stopPropagation(),ht.navigate(me.TEAM,{agentId:de.id})},className:"text-sm text-brand-500 hover:text-brand-400 truncate",children:de.name}),t.jsx("span",{className:"text-[10px] text-fg-tertiary font-mono truncate",children:de.id})]}),t.jsx("span",{className:"text-xs font-medium text-fg-secondary tabular-nums shrink-0 ml-3",children:Rs(de.size)})]}),Te&&t.jsxs("div",{className:"px-3 pb-2 pt-0.5 space-y-0.5",children:[de.subItems.filter(Ve=>Ve.size>0).map(Ve=>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:Ve.name}),t.jsx("span",{className:"text-fg-secondary tabular-nums",children:Rs(Ve.size)})]},Ve.name)),t.jsx("div",{className:"pl-5 pt-1",children:t.jsx("button",{onClick:()=>{se.system.openPath(rt.dataDir+"/agents/"+de.id)},className:"text-[10px] text-fg-tertiary hover:text-fg-secondary underline",children:"Open folder"})})]})]},de.id)})})]}),dt&&(dt.orphanAgents.length>0||dt.orphanTeams.length>0)&&t.jsx(H_,{orphanInfo:dt,dataDir:rt.dataDir,onPurged:Tt})]})]})}),t.jsx("div",{className:"h-8"})]})]})}function Wh({step:e,title:n,description:s,active:i,children:l}){return t.jsxs("div",{className:`rounded-xl border p-4 space-y-3 transition-colors ${i?"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:n}),t.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:s})]})]}),l&&t.jsx("div",{className:"pl-9",children:l})]})}function hi({type:e,text:n}){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:n})}function Ha({title:e,children:n}){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:n})]})}function Qh({label:e,value:n,color:s}){const i=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 ${i}`,children:[t.jsx("div",{className:"text-2xl font-bold",children:n}),t.jsx("div",{className:"text-xs mt-1 opacity-70",children:e})]})}function Pa({label:e,value:n}){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:n})]})}function Rs(e){if(e===0)return"0 B";const n=["B","KB","MB","GB"],s=Math.min(Math.floor(Math.log(e)/Math.log(1024)),n.length-1),i=e/Math.pow(1024,s);return`${i<10?i.toFixed(1):Math.round(i)} ${n[s]}`}function H_({orphanInfo:e,dataDir:n,onPurged:s}){const i=[...e.orphanAgents.map(N=>({...N,kind:"agent"})),...e.orphanTeams.map(N=>({...N,kind:"team"}))],[l,d]=v.useState(new Set),[c,h]=v.useState(!1),[m,f]=v.useState(null),x=N=>d(T=>{const C=new Set(T);return C.has(N)?C.delete(N):C.add(N),C}),p=l.size===i.length&&i.length>0,g=()=>d(p?new Set:new Set(i.map(N=>N.id))),y=i.filter(N=>l.has(N.id)).reduce((N,T)=>N+T.size,0),w=async N=>{h(!0),f(null);try{const T=await se.system.purgeOrphans(N),C=T.purgedAgents.length+T.purgedTeams.length;f(`Cleaned ${C} dir${C!==1?"s":""}, freed ${Rs(T.freedBytes)}${T.failures.length?` (${T.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: ",Rs(e.totalOrphanSize)," across ",i.length," director",i.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:p,onChange:g,className:"rounded"}),"Select all"]}),l.size>0&&t.jsxs("span",{className:"text-[10px] text-fg-secondary",children:[l.size," selected (",Rs(y),")"]})]}),t.jsx("div",{className:"space-y-0.5 mb-3 max-h-52 overflow-y-auto",children:i.map(N=>t.jsxs("div",{className:`flex items-center gap-2 text-xs py-1.5 px-2 rounded transition-colors ${l.has(N.id)?"bg-amber-500/10":"bg-surface-elevated/30 hover:bg-surface-elevated/50"}`,children:[t.jsx("input",{type:"checkbox",checked:l.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:Rs(N.size)}),t.jsx("button",{onClick:()=>{se.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:[l.size>0&&t.jsx("button",{disabled:c,onClick:()=>{w([...l])},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 (${Rs(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 (${Rs(e.totalOrphanSize)})`})]}),m&&t.jsx("div",{className:"text-xs text-fg-tertiary mt-2",children:m})]})}const Yd=new Map;function mi(e,n){Yd.has(e)||Yd.set(e,n().catch(()=>{}))}function gi(e){const n=Yd.get(e);return Yd.delete(e),n}const Ir={builderArtifacts:"builder.artifacts",builderAgents:"builder.agents",builderHubMyItems:"builder.hubMyItems",builderInstalled:"builder.installed",hubAgents:"hub.agents",hubTeams:"hub.teams",hubSkills:"hub.skills"};function Wj(e){return e.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed"}function P_(e,n){const s=e.split(".").map(Number),i=n.split(".").map(Number);for(let l=0;l<Math.max(s.length,i.length);l++){const d=s[l]??0,c=i[l]??0;if(d>c)return!0;if(d<c)return!1}return!1}const Qj={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function $m({authUser:e}={}){const[n,s]=v.useState("all"),[i,l]=v.useState(""),[d,c]=v.useState([]),[h,m]=v.useState([]),[f,x]=v.useState(null),[p,g]=v.useState(!1),[y,w]=v.useState(!0),[N,T]=v.useState(new Map),C=v.useCallback(async()=>{try{const[M,D]=await Promise.all([se.builder.artifacts.list().catch(()=>({artifacts:[]})),se.builder.artifacts.installed().catch(()=>({installed:{}}))]),A=new Map;for(const G of M.artifacts){if(G.type!=="agent")continue;const X=!!D.installed[`agent/${G.name}`];A.set(G.name,{installed:X,localVersion:G.meta.version||void 0,localUpdatedAt:G.updatedAt})}T(A)}catch{}},[]),_=v.useCallback(async()=>{w(!0);try{if(n==="hub"){const M=i?Zn.search({type:"agent",q:i,limit:50}):gi(Ir.hubAgents)??Zn.search({type:"agent",limit:50}),[D]=await Promise.all([M.catch(()=>({items:[],total:0})),C()]);m(D?.items??[]),c([])}else{m([]);const M=new URLSearchParams;i&&M.set("q",i);const D=await fetch("/api/templates?"+M.toString()).then(A=>A.json()).catch(()=>({templates:[]}));c(Array.isArray(D.templates)?D.templates:[])}}catch{c([]),m([])}finally{w(!1)}},[n,i,C]);v.useEffect(()=>{_()},[_]);const k=async(M,D,A)=>{try{const G=await fetch("/api/templates/instantiate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({templateId:M,name:D,orgId:"default",teamId:A})});if(!G.ok)throw new Error(`Failed: ${G.status}`);g(!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(M=>t.jsx("button",{onClick:()=>{s(M.id),x(null)},className:`px-3 py-1 text-xs rounded-md transition-colors ${n===M.id?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:M.label},M.id))}),n==="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:i,onChange:M=>l(M.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..."}):n==="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(M=>t.jsx(q_,{item:M,localInfo:N.get(Wj(M.name)),onStatusChange:C},M.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:i?`No agents match "${i}"`:"No agents found"}),t.jsx("div",{className:"text-fg-tertiary text-sm",children:i?"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(M=>t.jsx(U_,{template:M,isSelected:f?.id===M.id,onSelect:()=>x(f?.id===M.id?null:M)},M.id))})}),f&&n==="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.jsx("div",{className:"flex items-center gap-3",children: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:()=>g(!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(M=>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:M},M)),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 ${Qj[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((M,D)=>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 ${M.priority==="high"?"bg-red-400":M.priority==="medium"?"bg-amber-400":"bg-green-400"}`}),M.title]},D))})]})]})]})}),p&&f&&t.jsx(V_,{template:f,onClose:()=>g(!1),onHire:k})]})}function q_({item:e,localInfo:n,onStatusChange:s}){const[i,l]=v.useState(!1),[d,c]=v.useState(""),h=n?.installed??!1,m=h&&e.version&&n?.localVersion&&P_(e.version,n.localVersion),f=async x=>{if(x.stopPropagation(),!i){l(!0),c("");try{const p=await Zn.download(e.id),g=p.name||e.name,y=Wj(g),w=p.itemType==="team"?"team":p.itemType==="skill"?"skill":"agent",N={type:"hub",hubItemId:e.id};if(p.files&&Object.keys(p.files).length>0)await se.builder.artifacts.import(w,y,p.files,N);else{const T={...p.config,name:g,description:e.description,source:N};await se.builder.artifacts.save(w,T)}await se.builder.artifacts.install(w,y),c(m?"Upgraded!":"Installed!"),s(),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{c("Failed")}finally{l(!1)}}};return t.jsxs("div",{className:"group relative bg-surface-secondary rounded-xl cursor-pointer transition-all duration-300 overflow-hidden hover:shadow-xl hover:shadow-brand-500/5 hover:-translate-y-0.5",children:[t.jsx("div",{className:"absolute inset-0 rounded-xl border border-border-default group-hover:border-brand-500/30 transition-colors duration-300"}),t.jsx("div",{className:"absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-green-500/40 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300"}),t.jsxs("div",{className:"relative p-5",children:[t.jsxs("div",{className:"flex items-center gap-2.5 mb-2.5",children:[t.jsx("h3",{className:"text-sm font-semibold truncate flex-1 group-hover:text-brand-400 transition-colors",children:e.name}),e.version&&t.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 bg-brand-500/15 text-brand-400 rounded-md border border-brand-500/10",children:["v",e.version]}),t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-green-500/15 text-green-500 rounded-md border border-green-500/10",children:"Hub"})]}),t.jsx("p",{className:"text-xs text-fg-tertiary line-clamp-2 mb-3",children:e.description}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-fg-tertiary",children:[t.jsxs("span",{className:"text-amber-500",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 pt-3 border-t border-border-default/50",children:[m?t.jsx("button",{onClick:x=>{f(x)},disabled:i,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:i?"Upgrading...":`Upgrade → v${e.version}`}):h?t.jsxs("span",{className:"px-3 py-1.5 text-xs bg-surface-overlay text-fg-secondary rounded-lg",children:["Installed",n?.localVersion?` (v${n.localVersion})`:""]}):t.jsx("button",{onClick:x=>{f(x)},disabled:i,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:i?"Installing...":"Install"}),d&&t.jsx("span",{className:`text-[10px] ${d==="Failed"?"text-red-500":"text-green-600"}`,children:d})]})]})]})}function U_({template:e,isSelected:n,onSelect:s}){return t.jsxs("div",{onClick:s,className:`group relative bg-surface-secondary rounded-xl cursor-pointer transition-all duration-300 overflow-hidden ${n?"ring-1 ring-brand-500/60 shadow-lg shadow-brand-500/10":"hover:shadow-xl hover:shadow-brand-500/5 hover:-translate-y-0.5"}`,children:[t.jsx("div",{className:`absolute inset-0 rounded-xl border transition-colors duration-300 ${n?"border-brand-500/50":"border-border-default group-hover:border-brand-500/30"}`}),t.jsx("div",{className:`absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-brand-500/40 to-transparent transition-opacity duration-300 ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`}),t.jsxs("div",{className:"relative p-5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"font-semibold text-fg-primary truncate group-hover:text-brand-400 transition-colors",children:e.name}),t.jsxs("span",{className:"px-2 py-0.5 rounded-md text-[10px] font-medium shrink-0 bg-brand-500/15 text-brand-400 border border-brand-500/10",children:["v",e.version]})]}),t.jsxs("div",{className:"text-[11px] 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(i=>t.jsx("span",{className:"px-2 py-0.5 text-[10px] bg-surface-elevated/80 text-fg-secondary rounded-md border border-border-default/50",children:i},i)),e.skills.length>4&&t.jsxs("span",{className:"px-2 py-0.5 text-[10px] text-fg-muted",children:["+",e.skills.length-4]})]}),t.jsxs("div",{className:"mt-3 pt-3 border-t border-border-default/50 flex items-center gap-2 text-xs",children:[t.jsx("span",{className:`inline-block px-2 py-0.5 rounded-md text-[10px] font-medium capitalize ${Qj[e.agentRole]??"bg-surface-overlay text-fg-secondary"}`,children:e.agentRole}),e.tags.length>0&&t.jsx("span",{className:"text-fg-muted text-[10px]",children:e.tags.slice(0,2).join(" · ")})]})]})]})}function V_({template:e,onClose:n,onHire:s}){const[i,l]=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(g=>g.json()).then(g=>m(g.teams??[])).catch(()=>{})},[]);const p=async()=>{if(i.trim()){x(!0);try{await s(e.id,i.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:n,children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[440px] shadow-2xl",onClick:g=>g.stopPropagation(),children:[t.jsx("div",{className:"flex items-center gap-3 mb-5",children: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:i,onChange:g=>l(g.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:g=>c(g.target.value),className:"input-field",children:[t.jsx("option",{value:"",children:"No team"}),h.map(g=>t.jsx("option",{value:g.id,children:g.name},g.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:n,className:"btn-secondary",children:"Cancel"}),t.jsx("button",{onClick:p,disabled:!i.trim()||f,className:"btn-primary",children:f?"Creating...":"Create Agent"})]})]})})}function Zj(e){return e.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed"}function F_(e,n){const s=e.split(".").map(Number),i=n.split(".").map(Number);for(let l=0;l<Math.max(s.length,i.length);l++){const d=s[l]??0,c=i[l]??0;if(d>c)return!0;if(d<c)return!1}return!1}function Bm(){const[e,n]=v.useState("all"),[s,i]=v.useState(""),[l,d]=v.useState([]),[c,h]=v.useState([]),[m,f]=v.useState(null),[x,p]=v.useState(!0),[g,y]=v.useState(!1),[w,N]=v.useState(null),[T,C]=v.useState(new Map),_=v.useCallback(async()=>{try{const[D,A]=await Promise.all([se.builder.artifacts.list().catch(()=>({artifacts:[]})),se.builder.artifacts.installed().catch(()=>({installed:{}}))]),G=new Map;for(const X of D.artifacts){if(X.type!=="team")continue;const K=!!A.installed[`team/${X.name}`];G.set(X.name,{installed:K,localVersion:X.meta.version||void 0,localUpdatedAt:X.updatedAt})}C(G)}catch{}},[]),k=v.useCallback(async()=>{p(!0);try{if(e==="hub"){const D=s?Zn.search({type:"team",q:s,limit:50}):gi(Ir.hubTeams)??Zn.search({type:"team",limit:50}),[A]=await Promise.all([D.catch(()=>({items:[],total:0})),_()]);h(A?.items??[]),d([])}else{h([]);const D=await se.teamTemplates.list(s||void 0);d(D?.templates??[])}}catch{d([]),h([])}finally{p(!1)}},[e,s,_]);v.useEffect(()=>{k()},[k]);const M=async D=>{y(!0),N(null);try{const G=(await se.teams.create(D.name,D.description)).team.id;let X,K=0;const $=[];for(const U of D.members){const z=U.count??1;for(let E=0;E<z;E++){const L=U.name??`${D.name} Agent ${E+1}`,R=z>1?`${L} ${E+1}`:L,F=U.roleName??U.templateId??"developer";try{const Y=await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({name:R,roleName:F,orgId:"default",teamId:G,agentRole:U.role??"worker",skills:U.skills??[]})});if(Y.ok){K++;const Z=await Y.json();U.role==="manager"&&!X&&(X=Z.agent?.id)}else{const Z=await Y.json().catch(()=>({error:`HTTP ${Y.status}`}));$.push(`${R}: ${Z.error??Y.statusText}`)}}catch(Y){$.push(`${R}: ${String(Y)}`)}}}X&&await se.teams.update(G,{managerId:X,managerType:"agent"}).catch(()=>{});const q=$.length>0?` (${$.length} failed: ${$[0]})`:"";N({ok:K>0,message:`Team "${D.name}" deployed with ${K} agent(s)${q}`})}catch(A){N({ok:!1,message:`Failed: ${A}`})}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(D=>t.jsx("button",{onClick:()=>{n(D.id),f(null),N(null)},className:`px-3 py-1 text-xs rounded-md transition-colors ${e===D.id?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:D.label},D.id))}),e==="all"&&t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[l.length," team",l.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:D=>i(D.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(D=>t.jsx(Y_,{item:D,localInfo:T.get(Zj(D.name)),onStatusChange:_},D.id))}):l.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:l.map(D=>t.jsx(G_,{template:D,isSelected:m?.id===D.id,onSelect:()=>f(m?.id===D.id?null:D)},D.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.jsx("div",{className:"flex items-center gap-3",children: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:()=>M(m),disabled:g,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:g?"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((D,A)=>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 ${D.role==="manager"?"bg-brand-500/20 text-brand-500":"bg-blue-500/20 text-blue-600"}`,children:D.role==="manager"?"★":A+1}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-fg-primary",children:D.name??D.roleName??D.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:D.roleName??D.templateId}),t.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] capitalize ${D.role==="manager"?"bg-brand-500/15 text-brand-500":"bg-blue-500/15 text-blue-600"}`,children:D.role??"worker"}),(D.count??1)>1&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["x",D.count]})]})]})]},A))})]}),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((D,A)=>D+(A.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(D=>t.jsx("span",{className:"px-2 py-0.5 text-[10px] bg-surface-elevated text-fg-secondary rounded-full border border-border-default",children:D},D))})]})]})]})]})]})})]})}function Y_({item:e,localInfo:n,onStatusChange:s}){const[i,l]=v.useState(!1),[d,c]=v.useState(""),h=n?.installed??!1,m=h&&e.version&&n?.localVersion&&F_(e.version,n.localVersion),f=async x=>{if(x.stopPropagation(),!i){l(!0),c("");try{const p=await Zn.download(e.id),g=p.name||e.name,y=Zj(g),w={type:"hub",hubItemId:e.id};if(p.files&&Object.keys(p.files).length>0)await se.builder.artifacts.import("team",y,p.files,w);else{const N={...p.config,name:g,description:e.description,source:w};await se.builder.artifacts.save("team",N)}await se.builder.artifacts.install("team",y),c(m?"Upgraded!":"Installed!"),s(),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{c("Failed")}finally{l(!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("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:i,className:"px-3 py-1 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:i?"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",n?.localVersion?` (v${n.localVersion})`:""]}):t.jsx("button",{onClick:x=>{f(x)},disabled:i,className:"px-3 py-1 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:i?"Installing...":"Install"}),d&&t.jsx("span",{className:`text-[10px] ${d==="Failed"?"text-red-500":"text-green-600"}`,children:d})]})]})}function G_({template:e,isSelected:n,onSelect:s}){const i=e.members.reduce((d,c)=>d+(c.count??1),0),l=e.members.some(d=>d.role==="manager");return e.category,t.jsxs("div",{onClick:s,className:`group relative bg-surface-secondary rounded-xl cursor-pointer transition-all duration-300 overflow-hidden ${n?"ring-1 ring-brand-500/60 shadow-lg shadow-brand-500/10":"hover:shadow-xl hover:shadow-brand-500/5 hover:-translate-y-0.5"}`,children:[t.jsx("div",{className:`absolute inset-0 rounded-xl border transition-colors duration-300 ${n?"border-brand-500/50":"border-border-default group-hover:border-brand-500/30"}`}),t.jsx("div",{className:`absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-brand-500/40 to-transparent transition-opacity duration-300 ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`}),t.jsxs("div",{className:"relative p-5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"font-semibold text-fg-primary truncate group-hover:text-brand-400 transition-colors",children:e.name}),t.jsxs("span",{className:"px-2 py-0.5 rounded-md text-[10px] font-medium shrink-0 bg-brand-500/15 text-brand-400 border border-brand-500/10",children:["v",e.version]})]}),t.jsxs("div",{className:"text-[11px] 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((d,c)=>t.jsxs("span",{className:`px-2 py-0.5 text-[10px] rounded-md border ${d.role==="manager"?"bg-brand-500/10 text-brand-400 border-brand-500/15":"bg-blue-500/10 text-blue-400 border-blue-500/15"}`,children:[d.name??d.roleName??d.templateId,(d.count??1)>1?` x${d.count}`:""]},c))}),t.jsxs("div",{className:"mt-3 pt-3 border-t border-border-default/50 flex items-center gap-3 text-xs",children:[t.jsxs("span",{className:"text-fg-muted",children:[i," agent",i!==1?"s":""]}),l&&t.jsx("span",{className:"text-brand-400/60",children:"has manager"}),e.tags&&e.tags.length>0&&t.jsx("span",{className:"text-fg-muted text-[10px]",children:e.tags.slice(0,3).join(" · ")})]})]})]})}function Jj(e,n){const s=e.split(".").map(Number),i=n.split(".").map(Number);for(let l=0;l<Math.max(s.length,i.length);l++){const d=s[l]??0,c=i[l]??0;if(d>c)return!0;if(d<c)return!1}return!1}const Zh={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"},X_=[{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 K_({item:e,installedSkills:n,onMsg:s,onRefresh:i}){const[l,d]=v.useState(!1),c=e.name.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed",h=n.find(p=>p.name===e.name||p.name===c),m=!!h,f=m&&e.version&&h?.version&&Jj(e.version,h.version),x=async()=>{if(!l){d(!0);try{const p=await Zn.download(e.id),g=p.name||e.name,y=g.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed",w={type:"hub",hubItemId:e.id};if(p.files&&Object.keys(p.files).length>0)await se.builder.artifacts.import("skill",y,p.files,w);else{const N={...p.config,name:g,description:e.description,source:w};await se.builder.artifacts.save("skill",N)}await se.builder.artifacts.install("skill",y),s(f?`Upgraded ${e.name}`:`Installed ${e.name}`,"success"),i(),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{s("Install failed","error")}finally{d(!1)}}};return f?t.jsx("button",{onClick:()=>{x()},disabled:l,className:"px-2.5 py-1 text-[10px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50",children:l?"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:l,className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:l?"Installing...":"Install"})}function Hm(){const e=$r(),[n,s]=v.useState("installed"),[i,l]=v.useState(null),[d,c]=v.useState(new Set),[h,m]=v.useState([]),[f,x]=v.useState(!0),[p,g]=v.useState(""),[y,w]=v.useState([]),[N,T]=v.useState(0),[C,_]=v.useState(1),[k,M]=v.useState([]),[D,A]=v.useState(""),[G,X]=v.useState("score"),[K,$]=v.useState(""),[q,U]=v.useState(!1),[z,E]=v.useState([]),[L,R]=v.useState(!1),[F,Y]=v.useState([]),[Z,B]=v.useState(""),[O,V]=v.useState(!1),[I,S]=v.useState([]),[H,W]=v.useState(!1),[ee,te]=v.useState(""),ae=(re,_e="success")=>{l({text:re,type:_e}),setTimeout(()=>l(null),_e==="error"?1e4:4e3)},he=v.useCallback(async()=>{x(!0);try{const re=await se.skills.list();m(re.skills)}catch{}x(!1)},[]),Ne=v.useCallback(async()=>{R(!0);try{const re=await se.skills.builtin();E(re.skills)}catch{}R(!1)},[]),De=v.useCallback(async re=>{U(!0);try{const _e=await se.skills.registrySkillhub({q:re?.q,category:re?.category,page:re?.page??1,limit:24,sort:re?.sort??G});w(_e.skills),T(_e.total),_e.categories?.length&&M(_e.categories)}catch{}U(!1)},[G]),je=v.useCallback(async re=>{V(!0);try{const _e=await se.skills.registrySkillssh(re);Y(_e.skills)}catch{}V(!1)},[]),ke=v.useCallback(async re=>{W(!0);try{const st=await(re?Zn.search({type:"skill",q:re,limit:50}):gi(Ir.hubSkills)??Zn.search({type:"skill",limit:50}));S(st?.items??[])}catch{}W(!1)},[]);v.useEffect(()=>{he(),Ne(),De(),je()},[]),v.useEffect(()=>{n==="markus-hub"&&ke(ee)},[n,ee,ke]);const Se=async re=>{c(_e=>new Set(_e).add(re.name));try{const _e=await se.skills.install({name:re.name,source:"skillhub",slug:re.slug,sourceUrl:re.homepage,description:re.description_zh??re.description,category:"custom",version:re.version});await he(),ae(`"${re.name}" installed (${_e.method}) → ${_e.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{ae(`Download failed for "${re.name}". You can try manually from: ${re.homepage}`,"error")}c(_e=>{const st=new Set(_e);return st.delete(re.name),st})},Le=async re=>{c(_e=>new Set(_e).add(re.name));try{const _e=await se.skills.install({name:re.name,source:"skillssh",sourceUrl:re.url,githubRepo:`${re.author}/${re.repo}`,githubSkillPath:re.name});await he(),ae(`"${re.name}" installed (${_e.method}) → ${_e.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{ae(`Download failed for "${re.name}". You can try manually from: ${re.url}`,"error")}c(_e=>{const st=new Set(_e);return st.delete(re.name),st})},nt=async re=>{c(_e=>new Set(_e).add(re.name));try{const _e=await se.skills.install({name:re.name,source:"builtin"});await he(),await Ne(),ae(`"${re.name}" installed (${_e.method}) → ${_e.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(_e){ae(`Install failed for "${re.name}": ${_e}`,"error")}c(_e=>{const st=new Set(_e);return st.delete(re.name),st})},rt=async re=>{if(confirm(`Uninstall "${re}"? This will delete the skill files from ~/.markus/skills/.`))try{await se.skills.uninstall(re),await he(),ae(`"${re}" uninstalled`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(_e){ae(`Uninstall failed: ${_e}`,"error")}},yt=h.filter(re=>{if(!p)return!0;const _e=p.toLowerCase();return re.name.toLowerCase().includes(_e)||re.description?.toLowerCase().includes(_e)}),Rt=F.filter(re=>{if(!Z)return!0;const _e=Z.toLowerCase();return re.name.toLowerCase().includes(_e)||re.repo.toLowerCase().includes(_e)});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:X_.map(re=>t.jsx("button",{onClick:()=>s(re.id),className:`px-3 py-1.5 text-xs rounded-lg transition-colors shrink-0 ${n===re.id?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:re.label},re.id))})]}),i&&t.jsx("div",{className:`mx-7 mt-2 px-3 py-1.5 text-xs rounded-lg shrink-0 ${i.type==="error"?"bg-red-500/10 text-red-500":"bg-green-500/10 text-green-600"}`,children:i.text}),n==="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:p,onChange:re=>g(re.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:[yt.length," skill",yt.length!==1?"s":""]})]}),f?t.jsx("div",{className:"text-center text-fg-tertiary py-20",children:"Loading..."}):yt.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:yt.map(re=>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:re.name}),t.jsx("span",{className:`px-1.5 py-0.5 rounded text-[9px] shrink-0 ${re.type==="builtin"?"bg-blue-500/15 text-blue-600":re.type==="filesystem"?"bg-green-500/15 text-green-600":"bg-amber-500/15 text-amber-600"}`,children:re.type==="builtin"?"built-in":re.type==="filesystem"?"local":"imported"})]}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:[re.author?`by ${re.author} · `:"",re.version?`v${re.version}`:"",re.sourcePath&&t.jsxs("span",{className:"ml-1 text-fg-tertiary",title:re.sourcePath,children:["📁 ",re.sourcePath.replace(/^.*\/\.([^/]+)\/skills\//,"~/.$1/skills/")]})]})]}),t.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium ${Zh[re.category??""]??"bg-gray-500/15 text-fg-secondary"} capitalize shrink-0 ml-2`,children:re.category??"custom"})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-2 line-clamp-2",children:re.description??"No description"}),t.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:re.tags?.slice(0,3).map(_e=>t.jsx("span",{className:"px-2 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded-full",children:_e},_e))}),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:[re.tools&&re.tools.length>0&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[re.tools.length," tool",re.tools.length!==1?"s":""]}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:"Auto-discovered by agents"})]}),re.type!=="builtin"&&t.jsx("button",{onClick:()=>{rt(re.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"})]})]},re.name))})]}),n==="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:[z.length," built-in skill",z.length!==1?"s":""," available"]}),t.jsx("button",{onClick:()=>{Ne()},className:"text-xs text-brand-500 hover:text-brand-500 transition-colors",children:"Refresh"})]}),L?t.jsx("div",{className:"text-center text-fg-tertiary py-20",children:t.jsx("div",{className:"animate-pulse",children:"Loading built-in skills..."})}):z.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:z.map(re=>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:re.name}),re.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:[re.author?`by ${re.author} · `:"","v",re.version]})]}),t.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium ${Zh[re.category??""]??"bg-gray-500/15 text-fg-secondary"} capitalize shrink-0 ml-2`,children:re.category??"custom"})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-2 line-clamp-2",children:re.description??"No description"}),t.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:re.tags.slice(0,4).map(_e=>t.jsx("span",{className:"px-2 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded-full",children:_e},_e))}),re.requiredPermissions.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:re.requiredPermissions.map(_e=>t.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-amber-500/10 text-amber-500 rounded",children:_e},_e))}),t.jsxs("div",{className:"mt-3 pt-2 border-t border-border-default flex items-center justify-between",children:[re.installed&&re.installedVersion?t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["v",re.installedVersion]}):t.jsx("span",{}),re.installed&&re.installedVersion&&Jj(re.version,re.installedVersion)?t.jsx("button",{onClick:()=>{nt(re)},disabled:d.has(re.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(re.name)?"Upgrading...":`Upgrade → v${re.version}`}):re.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:()=>{nt(re)},disabled:d.has(re.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(re.name)?"Installing...":"Install"})]})]},re.name))})]}),n==="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:D,onChange:re=>{A(re.target.value),_(1),De({q:K||void 0,category:re.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(re=>t.jsx("option",{value:re,children:re},re))]}),t.jsxs("select",{value:G,onChange:re=>{X(re.target.value),_(1),De({q:K||void 0,category:D||void 0,page:1,sort:re.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:K,onChange:re=>$(re.target.value),onKeyDown:re=>{re.key==="Enter"&&(_(1),De({q:K||void 0,category:D||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:()=>{_(1),De({q:K||void 0,category:D||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"})]}),q?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(re=>{const _e=h.some(st=>st.name===re.name||st.name===re.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:re.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:["v",re.version]})]}),t.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium shrink-0 ml-2 ${re.tags?.[0]?Zh[re.tags[0]]??"bg-brand-500/15 text-brand-500":"bg-brand-500/15 text-brand-500"}`,children:re.tags?.[0]??"SkillHub"})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-2 line-clamp-2",children:re.description_zh??re.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:[re.stars>0&&t.jsxs("span",{className:"text-[10px] text-amber-600",children:["★ ",re.stars.toLocaleString()]}),re.downloads>0&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[re.downloads>=1e4?`${(re.downloads/1e4).toFixed(1)}万`:re.downloads.toLocaleString()," 下载"]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("a",{href:re.homepage,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-brand-500 hover:text-brand-500",children:"View →"}),_e?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:()=>{Se(re)},disabled:d.has(re.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(re.name)?"...":"Install"})]})]})]},re.slug)})}),N>24&&t.jsxs("div",{className:"flex items-center justify-center gap-2 mt-6",children:[t.jsx("button",{disabled:C<=1,onClick:()=>{const re=C-1;_(re),De({q:K||void 0,category:D||void 0,page:re})},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:["第 ",C," / ",Math.ceil(N/24)," 页"]}),t.jsx("button",{disabled:C>=Math.ceil(N/24),onClick:()=>{const re=C+1;_(re),De({q:K||void 0,category:D||void 0,page:re})},className:"px-3 py-1.5 text-xs bg-surface-elevated text-fg-secondary rounded-lg hover:bg-surface-overlay disabled:opacity-30",children:"下一页 →"})]})]})]}),n==="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:Z,onChange:re=>B(re.target.value),onKeyDown:re=>{re.key==="Enter"&&Z.trim()&&je(Z)},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:()=>{Z.trim()&&je(Z)},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 →"})})]}),O?t.jsx("div",{className:"text-center text-fg-tertiary py-20",children:t.jsx("div",{className:"animate-pulse",children:"Searching skills.sh..."})}):Rt.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:Rt.map(re=>{const _e=h.some(st=>st.name===re.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:re.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:[re.author," / ",re.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:re.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:re.installs&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[re.installs," installs"]})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("a",{href:re.url,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-brand-500 hover:text-brand-500",children:"View →"}),_e?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:()=>{Le(re)},disabled:d.has(re.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(re.name)?"...":"Install"})]})]})]},`${re.author}-${re.name}`)})})]}),n==="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:re=>te(re.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"})]}),H?t.jsx("div",{className:"text-center text-fg-tertiary py-20",children:t.jsx("div",{className:"animate-pulse",children:"Loading from Hub..."})}):I.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:I.map(re=>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:re.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:["by ",re.author?.displayName??re.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:re.description}),t.jsxs("div",{className:"mt-2 text-xs text-amber-600",children:["★".repeat(Math.round(parseFloat(re.avgRating))),"☆".repeat(5-Math.round(parseFloat(re.avgRating))),t.jsxs("span",{className:"text-fg-tertiary ml-1",children:["(",re.ratingCount,") · ↓ ",re.downloadCount]})]}),t.jsx("div",{className:"mt-2 pt-2 border-t border-border-default flex items-center justify-end gap-2",children:t.jsx(K_,{item:re,installedSkills:h,onMsg:ae,onRefresh:()=>{he()}})})]},re.id))})]})]})}const Jh=[{id:"agents",label:"Agents"},{id:"teams",label:"Teams"},{id:"skills",label:"Skills"}];function W_(){const e=localStorage.getItem("markus_nav_storeTab");return e&&localStorage.removeItem("markus_nav_storeTab"),e==="agents"||e==="teams"||e==="skills"?e:"agents"}function Q_({authUser:e}){const[n,s]=v.useState(W_),i=$r(),l=ca(Jh,n,s);return v.useEffect(()=>{const d=c=>{if(c.detail.page==="store"){const m=localStorage.getItem("markus_nav_storeTab");m&&(localStorage.removeItem("markus_nav_storeTab"),(m==="agents"||m==="teams"||m==="skills")&&s(m))}};return window.addEventListener("markus:navigate",d),()=>window.removeEventListener("markus:navigate",d)},[]),i?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",children:Jh.map(d=>t.jsx("button",{onClick:()=>s(d.id),className:`flex-1 min-w-0 px-4 py-3 text-sm font-medium text-center whitespace-nowrap transition-colors border-b-2 ${n===d.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary hover:text-fg-secondary"}`,children:d.label},d.id))}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[n==="agents"&&t.jsx($m,{authUser:e}),n==="teams"&&t.jsx(Bm,{}),n==="skills"&&t.jsx(Hm,{})]})]}):t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-row",children:[t.jsxs("nav",{className:"w-48 shrink-0 border-r border-border-default bg-surface-secondary/50 flex flex-col py-4 px-2 gap-1",children:[t.jsx("div",{className:"px-3 pb-3 mb-1 border-b border-border-default/50",children:t.jsx("h2",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider",children:"Store"})}),Jh.map(d=>t.jsx("button",{onClick:()=>s(d.id),className:`flex items-center gap-2.5 px-3 py-2.5 rounded-lg text-sm font-medium transition-all ${n===d.id?"bg-brand-600/15 text-brand-400 shadow-sm shadow-brand-500/10":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated/50"}`,children:d.label},d.id))]}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[n==="agents"&&t.jsx($m,{authUser:e}),n==="teams"&&t.jsx(Bm,{}),n==="skills"&&t.jsx(Hm,{})]})]})}function Z_(e){const n=e.indexOf(".markus/builder-artifacts/");return n>=0?"~/"+e.slice(n):e}const J_=[{icon:"✦",color:"from-brand-500 to-purple-600",borderColor:"border-brand-500/30 hover:border-brand-400/50",bgColor:"bg-brand-500/10",title:"Hire an Agent",desc:"Hire from templates, create custom agents, or find specialists on Markus Hub",examples:["Hire a senior React developer","Create a custom code reviewer","Find a DevOps specialist on Hub"],prompt:"I need to hire an agent: "},{icon:"◈",color:"from-blue-500 to-blue-600",borderColor:"border-blue-500/30 hover:border-blue-400/50",bgColor:"bg-blue-500/10",title:"Build a Team",desc:"Compose an optimal team for your project or deploy a team template",examples:["A web dev team with PM, devs, and QA","A data engineering squad","A content creation team"],prompt:"I need to build a team for: "},{icon:"⬡",color:"from-green-500 to-green-600",borderColor:"border-green-500/30 hover:border-green-400/50",bgColor:"bg-green-500/10",title:"Create a Skill",desc:"Design new capabilities that agents can learn and use",examples:["A Git changelog generator","A web scraping skill","A database migration tool"],prompt:"I need a skill that: "}],Ky={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 Wy({message:e,onConfirm:n,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:i=>i.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:n,className:"px-4 py-1.5 text-xs bg-red-600 hover:bg-red-500 text-white rounded-lg transition-colors",children:"Delete"})]})]})})}function ew(){const e=$r(),[n,s]=v.useState([]),[i,l]=v.useState([]),[d,c]=v.useState(!1),[h,m]=v.useState("all"),[f,x]=v.useState(null),[p,g]=v.useState(new Map),[y,w]=v.useState(null),[N,T]=v.useState(new Map),[C,_]=v.useState(null),[k,M]=v.useState(null),D=v.useCallback(()=>{c(!0),Promise.all([(gi(Ir.builderArtifacts)??se.builder.artifacts.list()).then(z=>z?.artifacts??[]).catch(()=>[]),(gi(Ir.builderAgents)??se.agents.list()).then(z=>z?.agents??[]).catch(()=>[]),(gi(Ir.builderHubMyItems)??Zn.myItems()).then(z=>z?.items??[]).catch(()=>[]),(gi(Ir.builderInstalled)??se.builder.artifacts.installed()).then(z=>z?.installed??{}).catch(()=>({}))]).then(([z,E,L,R])=>{if(l(z),s(E),L.length>0){const Y=new Map;for(const Z of L){const B=Z.itemType==="agent"?"agent":Z.itemType==="team"?"team":"skill";for(const O of z)O.type===B&&(Z.slug===O.name||Z.name===(O.meta.displayName||O.meta.name||O.name))&&Y.set(`${O.type}/${O.name}`,{id:Z.id,name:Z.name,slug:Z.slug||O.name})}Y.size>0&&T(Z=>{const B=new Map(Z);for(const[O,V]of Y)B.set(O,V);return B})}const F=new Map;for(const Y of z){const Z=`${Y.type}/${Y.name}`,B=R[Z];B&&F.set(Z,{agentId:B.agentId,agentIds:B.agentIds,teamId:B.teamId})}g(F)}).finally(()=>c(!1))},[]);v.useEffect(()=>{D();const z=E=>{E.detail?.page===me.BUILDER&&D()};return window.addEventListener("markus:navigate",z),()=>window.removeEventListener("markus:navigate",z)},[D]);const A=z=>{const E=n.find(L=>L.role==="Secretary"||L.name==="Secretary");E?ht.navigate(me.TEAM,{agentId:E.id,prefillMessage:z}):ht.navigate(me.TEAM,{prefillMessage:z})},G=async z=>{const E=`${z.type}/${z.name}`;if(!p.has(E)){x(E);try{const L=await se.builder.artifacts.install(z.type,z.name),R={};L.agent&&typeof L.agent=="object"&&(R.agentId=L.agent.id),L.team&&typeof L.team=="object"&&(R.teamId=L.team.id),Array.isArray(L.agents)&&(R.agentIds=L.agents.map(F=>F.id)),g(F=>new Map(F).set(E,R)),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(L){console.error("Install failed:",L),alert(`Install failed: ${L}`)}finally{x(null)}}},X=async z=>{const E=`${z.type}/${z.name}`;if(p.has(E)){x(E);try{await se.builder.artifacts.uninstall(z.type,z.name),g(L=>{const R=new Map(L);return R.delete(E),R}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(L){console.error("Uninstall failed:",L),alert(`Uninstall failed: ${L}`)}finally{x(null)}}},K=async z=>{const E=`${z.type}/${z.name}`;if(!N.has(E)){x(E);try{const L=await se.builder.artifacts.get(z.type,z.name),R=z.meta.displayName||z.meta.name||z.name,F=z.meta.description||"",Y=z.meta.category||"general",Z=Array.isArray(z.meta.tags)?z.meta.tags:[],B=z.name,O=await Zn.publishViaProxy({itemType:z.type==="team"?"team":z.type==="skill"?"skill":"agent",name:R,slug:B,description:F,category:Y,tags:Z,config:z.meta,files:L.files&&Object.keys(L.files).length>0?L.files:void 0});O.id&&T(V=>{const I=new Map(V);return I.set(E,{id:O.id,name:R,slug:O.slug??B}),I})}catch(L){console.error("Share failed:",L),alert(`Share failed: ${L}`)}finally{x(null)}}},$=async()=>{if(!C)return;const{key:z}=C,E=N.get(z);if(_(null),!E)return;const L=E.id;x(z);try{await Zn.deleteItem(L),T(R=>{const F=new Map(R);return F.delete(z),F})}catch(R){console.error("Hub delete failed:",R),alert(`Failed to remove from Hub: ${R}`)}finally{x(null)}},q=async()=>{if(!y)return;const z=y,E=`${z.type}/${z.name}`;w(null),x(E);try{await se.builder.artifacts.delete(z.type,z.name),l(L=>L.filter(R=>!(R.type===z.type&&R.name===z.name))),g(L=>{const R=new Map(L);return R.delete(E),R}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(L){console.error("Delete failed:",L)}finally{x(null)}},U=h==="all"?i:i.filter(z=>z.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:"Hire agents, build teams, and create skills. Your Secretary handles the entire process — from sourcing to onboarding."})]}),t.jsx("div",{className:"grid gap-5",children:J_.map(z=>t.jsx("button",{onClick:()=>A(z.prompt),className:`group text-left w-full rounded-xl border ${z.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 ${z.bgColor} flex items-center justify-center shrink-0`,children:z.icon}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("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 ${z.color} bg-clip-text text-transparent`,children:z.title})}),t.jsx("p",{className:"text-sm text-fg-secondary leading-relaxed",children:z.desc}),t.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:z.examples.map((E,L)=>t.jsxs("span",{className:"text-[11px] text-fg-tertiary bg-surface-elevated/60 rounded-full px-3 py-1 border border-border-default cursor-pointer hover:bg-surface-elevated/80 hover:text-fg-secondary transition-colors",onClick:R=>{R.stopPropagation(),A(z.prompt+E)},children:["“",E,"”"]},L))})]}),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"})})]})},z.title))}),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:D,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(z=>t.jsx("button",{onClick:()=>m(z),className:`text-xs px-3 py-1.5 rounded-full border transition-colors ${h===z?"border-gray-600 bg-surface-elevated text-fg-primary":"border-border-default text-fg-tertiary hover:text-fg-secondary hover:border-gray-600"}`,children:z==="all"?"All":z.charAt(0).toUpperCase()+z.slice(1)+"s"},z))})]}),d&&i.length===0?t.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:"Loading artifacts..."}):U.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:U.map(z=>{const E=Ky[z.type]??Ky.agent,L=z.meta.displayName||z.meta.name||z.name,R=z.meta.description||"",F=`${z.type}/${z.name}`,Y=f===F,Z=t.jsxs("div",{className:`flex items-center gap-1.5 ${e?"flex-wrap":"shrink-0"}`,children:[p.has(F)?t.jsx("button",{onClick:()=>X(z),disabled:Y,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:Y?"Uninstalling...":"Uninstall"}):t.jsx("button",{onClick:()=>G(z),disabled:Y,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:Y?"Installing...":"Install"}),N.has(F)?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:()=>_({key:F,name:z.meta.displayName||z.meta.name||z.name}),disabled:Y,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 B=N.get(F),O=Zn.getUser();if(!B||!O)return;const V=`${Zn.getUrl()}/${encodeURIComponent(O.username)}/${encodeURIComponent(B.slug)}`;navigator.clipboard.writeText(V).then(()=>{M(F),setTimeout(()=>M(I=>I===F?null:I),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===F?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:()=>K(z),disabled:Y,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:Y?"Sharing...":"Share"}),t.jsx("button",{onClick:()=>w(z),disabled:Y,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 ${E.bg} flex items-center justify-center text-lg shrink-0`,children:E.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:L}),t.jsx("span",{className:`text-[10px] font-medium uppercase tracking-wider ${E.color}`,children:z.type})]}),R&&t.jsx("p",{className:"text-xs text-fg-tertiary line-clamp-2",children:R}),t.jsxs("div",{className:"flex items-center gap-3 mt-2 text-[10px] text-fg-tertiary min-w-0",children:[t.jsx("button",{onClick:B=>{B.stopPropagation(),se.system.openPath(z.path).catch(()=>{})},className:"hover:text-fg-secondary transition-colors truncate min-w-0",title:z.path,children:Z_(z.path)}),t.jsx("span",{className:"shrink-0",children:new Date(z.updatedAt).toLocaleDateString()})]})]}),!e&&Z]}),e&&t.jsx("div",{className:"mt-3 pt-3 border-t border-border-default/50",children:Z})]},F)})}),y&&t.jsx(Wy,{message:`Delete "${y.meta.displayName||y.meta.name||y.name}"? This cannot be undone.`,onConfirm:q,onCancel:()=>w(null)}),C&&t.jsx(Wy,{message:`Remove "${C.name}" from Markus Hub? It will no longer be available for others to download.`,onConfirm:()=>{$()},onCancel:()=>_(null)})]})})}function er(e){if(typeof e=="string"||typeof e=="number")return""+e;let n="";if(Array.isArray(e))for(let s=0,i;s<e.length;s++)(i=er(e[s]))!==""&&(n+=(n&&" ")+i);else for(let s in e)e[s]&&(n+=(n&&" ")+s);return n}var eA={value:()=>{}};function hu(){for(var e=0,n=arguments.length,s={},i;e<n;++e){if(!(i=arguments[e]+"")||i in s||/[\s.]/.test(i))throw new Error("illegal type: "+i);s[i]=[]}return new Dd(s)}function Dd(e){this._=e}function tA(e,n){return e.trim().split(/^|\s+/).map(function(s){var i="",l=s.indexOf(".");if(l>=0&&(i=s.slice(l+1),s=s.slice(0,l)),s&&!n.hasOwnProperty(s))throw new Error("unknown type: "+s);return{type:s,name:i}})}Dd.prototype=hu.prototype={constructor:Dd,on:function(e,n){var s=this._,i=tA(e+"",s),l,d=-1,c=i.length;if(arguments.length<2){for(;++d<c;)if((l=(e=i[d]).type)&&(l=nA(s[l],e.name)))return l;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++d<c;)if(l=(e=i[d]).type)s[l]=Qy(s[l],e.name,n);else if(n==null)for(l in s)s[l]=Qy(s[l],e.name,null);return this},copy:function(){var e={},n=this._;for(var s in n)e[s]=n[s].slice();return new Dd(e)},call:function(e,n){if((l=arguments.length-2)>0)for(var s=new Array(l),i=0,l,d;i<l;++i)s[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(d=this._[e],i=0,l=d.length;i<l;++i)d[i].value.apply(n,s)},apply:function(e,n,s){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var i=this._[e],l=0,d=i.length;l<d;++l)i[l].value.apply(n,s)}};function nA(e,n){for(var s=0,i=e.length,l;s<i;++s)if((l=e[s]).name===n)return l.value}function Qy(e,n,s){for(var i=0,l=e.length;i<l;++i)if(e[i].name===n){e[i]=eA,e=e.slice(0,i).concat(e.slice(i+1));break}return s!=null&&e.push({name:n,value:s}),e}var Pm="http://www.w3.org/1999/xhtml";const Zy={svg:"http://www.w3.org/2000/svg",xhtml:Pm,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function mu(e){var n=e+="",s=n.indexOf(":");return s>=0&&(n=e.slice(0,s))!=="xmlns"&&(e=e.slice(s+1)),Zy.hasOwnProperty(n)?{space:Zy[n],local:e}:e}function rA(e){return function(){var n=this.ownerDocument,s=this.namespaceURI;return s===Pm&&n.documentElement.namespaceURI===Pm?n.createElement(e):n.createElementNS(s,e)}}function sA(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function tw(e){var n=mu(e);return(n.local?sA:rA)(n)}function aA(){}function Tx(e){return e==null?aA:function(){return this.querySelector(e)}}function iA(e){typeof e!="function"&&(e=Tx(e));for(var n=this._groups,s=n.length,i=new Array(s),l=0;l<s;++l)for(var d=n[l],c=d.length,h=i[l]=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 es(i,this._parents)}function lA(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function oA(){return[]}function nw(e){return e==null?oA:function(){return this.querySelectorAll(e)}}function cA(e){return function(){return lA(e.apply(this,arguments))}}function dA(e){typeof e=="function"?e=cA(e):e=nw(e);for(var n=this._groups,s=n.length,i=[],l=[],d=0;d<s;++d)for(var c=n[d],h=c.length,m,f=0;f<h;++f)(m=c[f])&&(i.push(e.call(m,m.__data__,f,c)),l.push(m));return new es(i,l)}function rw(e){return function(){return this.matches(e)}}function sw(e){return function(n){return n.matches(e)}}var uA=Array.prototype.find;function fA(e){return function(){return uA.call(this.children,e)}}function hA(){return this.firstElementChild}function mA(e){return this.select(e==null?hA:fA(typeof e=="function"?e:sw(e)))}var xA=Array.prototype.filter;function pA(){return Array.from(this.children)}function gA(e){return function(){return xA.call(this.children,e)}}function bA(e){return this.selectAll(e==null?pA:gA(typeof e=="function"?e:sw(e)))}function yA(e){typeof e!="function"&&(e=rw(e));for(var n=this._groups,s=n.length,i=new Array(s),l=0;l<s;++l)for(var d=n[l],c=d.length,h=i[l]=[],m,f=0;f<c;++f)(m=d[f])&&e.call(m,m.__data__,f,d)&&h.push(m);return new es(i,this._parents)}function aw(e){return new Array(e.length)}function vA(){return new es(this._enter||this._groups.map(aw),this._parents)}function Gd(e,n){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=n}Gd.prototype={constructor:Gd,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,n){return this._parent.insertBefore(e,n)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function jA(e){return function(){return e}}function wA(e,n,s,i,l,d){for(var c=0,h,m=n.length,f=d.length;c<f;++c)(h=n[c])?(h.__data__=d[c],i[c]=h):s[c]=new Gd(e,d[c]);for(;c<m;++c)(h=n[c])&&(l[c]=h)}function NA(e,n,s,i,l,d,c){var h,m,f=new Map,x=n.length,p=d.length,g=new Array(x),y;for(h=0;h<x;++h)(m=n[h])&&(g[h]=y=c.call(m,m.__data__,h,n)+"",f.has(y)?l[h]=m:f.set(y,m));for(h=0;h<p;++h)y=c.call(e,d[h],h,d)+"",(m=f.get(y))?(i[h]=m,m.__data__=d[h],f.delete(y)):s[h]=new Gd(e,d[h]);for(h=0;h<x;++h)(m=n[h])&&f.get(g[h])===m&&(l[h]=m)}function kA(e){return e.__data__}function SA(e,n){if(!arguments.length)return Array.from(this,kA);var s=n?NA:wA,i=this._parents,l=this._groups;typeof e!="function"&&(e=jA(e));for(var d=l.length,c=new Array(d),h=new Array(d),m=new Array(d),f=0;f<d;++f){var x=i[f],p=l[f],g=p.length,y=CA(e.call(x,x&&x.__data__,f,i)),w=y.length,N=h[f]=new Array(w),T=c[f]=new Array(w),C=m[f]=new Array(g);s(x,p,N,T,C,y,n);for(var _=0,k=0,M,D;_<w;++_)if(M=N[_]){for(_>=k&&(k=_+1);!(D=T[k])&&++k<w;);M._next=D||null}}return c=new es(c,i),c._enter=h,c._exit=m,c}function CA(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function EA(){return new es(this._exit||this._groups.map(aw),this._parents)}function TA(e,n,s){var i=this.enter(),l=this,d=this.exit();return typeof e=="function"?(i=e(i),i&&(i=i.selection())):i=i.append(e+""),n!=null&&(l=n(l),l&&(l=l.selection())),s==null?d.remove():s(d),i&&l?i.merge(l).order():l}function _A(e){for(var n=e.selection?e.selection():e,s=this._groups,i=n._groups,l=s.length,d=i.length,c=Math.min(l,d),h=new Array(l),m=0;m<c;++m)for(var f=s[m],x=i[m],p=f.length,g=h[m]=new Array(p),y,w=0;w<p;++w)(y=f[w]||x[w])&&(g[w]=y);for(;m<l;++m)h[m]=s[m];return new es(h,this._parents)}function AA(){for(var e=this._groups,n=-1,s=e.length;++n<s;)for(var i=e[n],l=i.length-1,d=i[l],c;--l>=0;)(c=i[l])&&(d&&c.compareDocumentPosition(d)^4&&d.parentNode.insertBefore(c,d),d=c);return this}function MA(e){e||(e=RA);function n(p,g){return p&&g?e(p.__data__,g.__data__):!p-!g}for(var s=this._groups,i=s.length,l=new Array(i),d=0;d<i;++d){for(var c=s[d],h=c.length,m=l[d]=new Array(h),f,x=0;x<h;++x)(f=c[x])&&(m[x]=f);m.sort(n)}return new es(l,this._parents).order()}function RA(e,n){return e<n?-1:e>n?1:e>=n?0:NaN}function OA(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function DA(){return Array.from(this)}function LA(){for(var e=this._groups,n=0,s=e.length;n<s;++n)for(var i=e[n],l=0,d=i.length;l<d;++l){var c=i[l];if(c)return c}return null}function IA(){let e=0;for(const n of this)++e;return e}function zA(){return!this.node()}function $A(e){for(var n=this._groups,s=0,i=n.length;s<i;++s)for(var l=n[s],d=0,c=l.length,h;d<c;++d)(h=l[d])&&e.call(h,h.__data__,d,l);return this}function BA(e){return function(){this.removeAttribute(e)}}function HA(e){return function(){this.removeAttributeNS(e.space,e.local)}}function PA(e,n){return function(){this.setAttribute(e,n)}}function qA(e,n){return function(){this.setAttributeNS(e.space,e.local,n)}}function UA(e,n){return function(){var s=n.apply(this,arguments);s==null?this.removeAttribute(e):this.setAttribute(e,s)}}function VA(e,n){return function(){var s=n.apply(this,arguments);s==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,s)}}function FA(e,n){var s=mu(e);if(arguments.length<2){var i=this.node();return s.local?i.getAttributeNS(s.space,s.local):i.getAttribute(s)}return this.each((n==null?s.local?HA:BA:typeof n=="function"?s.local?VA:UA:s.local?qA:PA)(s,n))}function iw(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function YA(e){return function(){this.style.removeProperty(e)}}function GA(e,n,s){return function(){this.style.setProperty(e,n,s)}}function XA(e,n,s){return function(){var i=n.apply(this,arguments);i==null?this.style.removeProperty(e):this.style.setProperty(e,i,s)}}function KA(e,n,s){return arguments.length>1?this.each((n==null?YA:typeof n=="function"?XA:GA)(e,n,s??"")):vl(this.node(),e)}function vl(e,n){return e.style.getPropertyValue(n)||iw(e).getComputedStyle(e,null).getPropertyValue(n)}function WA(e){return function(){delete this[e]}}function QA(e,n){return function(){this[e]=n}}function ZA(e,n){return function(){var s=n.apply(this,arguments);s==null?delete this[e]:this[e]=s}}function JA(e,n){return arguments.length>1?this.each((n==null?WA:typeof n=="function"?ZA:QA)(e,n)):this.node()[e]}function lw(e){return e.trim().split(/^|\s+/)}function _x(e){return e.classList||new ow(e)}function ow(e){this._node=e,this._names=lw(e.getAttribute("class")||"")}ow.prototype={add:function(e){var n=this._names.indexOf(e);n<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var n=this._names.indexOf(e);n>=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function cw(e,n){for(var s=_x(e),i=-1,l=n.length;++i<l;)s.add(n[i])}function dw(e,n){for(var s=_x(e),i=-1,l=n.length;++i<l;)s.remove(n[i])}function eM(e){return function(){cw(this,e)}}function tM(e){return function(){dw(this,e)}}function nM(e,n){return function(){(n.apply(this,arguments)?cw:dw)(this,e)}}function rM(e,n){var s=lw(e+"");if(arguments.length<2){for(var i=_x(this.node()),l=-1,d=s.length;++l<d;)if(!i.contains(s[l]))return!1;return!0}return this.each((typeof n=="function"?nM:n?eM:tM)(s,n))}function sM(){this.textContent=""}function aM(e){return function(){this.textContent=e}}function iM(e){return function(){var n=e.apply(this,arguments);this.textContent=n??""}}function lM(e){return arguments.length?this.each(e==null?sM:(typeof e=="function"?iM:aM)(e)):this.node().textContent}function oM(){this.innerHTML=""}function cM(e){return function(){this.innerHTML=e}}function dM(e){return function(){var n=e.apply(this,arguments);this.innerHTML=n??""}}function uM(e){return arguments.length?this.each(e==null?oM:(typeof e=="function"?dM:cM)(e)):this.node().innerHTML}function fM(){this.nextSibling&&this.parentNode.appendChild(this)}function hM(){return this.each(fM)}function mM(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function xM(){return this.each(mM)}function pM(e){var n=typeof e=="function"?e:tw(e);return this.select(function(){return this.appendChild(n.apply(this,arguments))})}function gM(){return null}function bM(e,n){var s=typeof e=="function"?e:tw(e),i=n==null?gM:typeof n=="function"?n:Tx(n);return this.select(function(){return this.insertBefore(s.apply(this,arguments),i.apply(this,arguments)||null)})}function yM(){var e=this.parentNode;e&&e.removeChild(this)}function vM(){return this.each(yM)}function jM(){var e=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function wM(){var e=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function NM(e){return this.select(e?wM:jM)}function kM(e){return arguments.length?this.property("__data__",e):this.node().__data__}function SM(e){return function(n){e.call(this,n,this.__data__)}}function CM(e){return e.trim().split(/^|\s+/).map(function(n){var s="",i=n.indexOf(".");return i>=0&&(s=n.slice(i+1),n=n.slice(0,i)),{type:n,name:s}})}function EM(e){return function(){var n=this.__on;if(n){for(var s=0,i=-1,l=n.length,d;s<l;++s)d=n[s],(!e.type||d.type===e.type)&&d.name===e.name?this.removeEventListener(d.type,d.listener,d.options):n[++i]=d;++i?n.length=i:delete this.__on}}}function TM(e,n,s){return function(){var i=this.__on,l,d=SM(n);if(i){for(var c=0,h=i.length;c<h;++c)if((l=i[c]).type===e.type&&l.name===e.name){this.removeEventListener(l.type,l.listener,l.options),this.addEventListener(l.type,l.listener=d,l.options=s),l.value=n;return}}this.addEventListener(e.type,d,s),l={type:e.type,name:e.name,value:n,listener:d,options:s},i?i.push(l):this.__on=[l]}}function _M(e,n,s){var i=CM(e+""),l,d=i.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(l=0,x=h[m];l<d;++l)if((c=i[l]).type===x.type&&c.name===x.name)return x.value}return}for(h=n?TM:EM,l=0;l<d;++l)this.each(h(i[l],n,s));return this}function uw(e,n,s){var i=iw(e),l=i.CustomEvent;typeof l=="function"?l=new l(n,s):(l=i.document.createEvent("Event"),s?(l.initEvent(n,s.bubbles,s.cancelable),l.detail=s.detail):l.initEvent(n,!1,!1)),e.dispatchEvent(l)}function AM(e,n){return function(){return uw(this,e,n)}}function MM(e,n){return function(){return uw(this,e,n.apply(this,arguments))}}function RM(e,n){return this.each((typeof n=="function"?MM:AM)(e,n))}function*OM(){for(var e=this._groups,n=0,s=e.length;n<s;++n)for(var i=e[n],l=0,d=i.length,c;l<d;++l)(c=i[l])&&(yield c)}var fw=[null];function es(e,n){this._groups=e,this._parents=n}function sc(){return new es([[document.documentElement]],fw)}function DM(){return this}es.prototype=sc.prototype={constructor:es,select:iA,selectAll:dA,selectChild:mA,selectChildren:bA,filter:yA,data:SA,enter:vA,exit:EA,join:TA,merge:_A,selection:DM,order:AA,sort:MA,call:OA,nodes:DA,node:LA,size:IA,empty:zA,each:$A,attr:FA,style:KA,property:JA,classed:rM,text:lM,html:uM,raise:hM,lower:xM,append:pM,insert:bM,remove:vM,clone:NM,datum:kM,on:_M,dispatch:RM,[Symbol.iterator]:OM};function Zr(e){return typeof e=="string"?new es([[document.querySelector(e)]],[document.documentElement]):new es([[e]],fw)}function LM(e){let n;for(;n=e.sourceEvent;)e=n;return e}function ps(e,n){if(e=LM(e),n===void 0&&(n=e.currentTarget),n){var s=n.ownerSVGElement||n;if(s.createSVGPoint){var i=s.createSVGPoint();return i.x=e.clientX,i.y=e.clientY,i=i.matrixTransform(n.getScreenCTM().inverse()),[i.x,i.y]}if(n.getBoundingClientRect){var l=n.getBoundingClientRect();return[e.clientX-l.left-n.clientLeft,e.clientY-l.top-n.clientTop]}}return[e.pageX,e.pageY]}const IM={passive:!1},Vo={capture:!0,passive:!1};function em(e){e.stopImmediatePropagation()}function gl(e){e.preventDefault(),e.stopImmediatePropagation()}function hw(e){var n=e.document.documentElement,s=Zr(e).on("dragstart.drag",gl,Vo);"onselectstart"in n?s.on("selectstart.drag",gl,Vo):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function mw(e,n){var s=e.document.documentElement,i=Zr(e).on("dragstart.drag",null);n&&(i.on("click.drag",gl,Vo),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in s?i.on("selectstart.drag",null):(s.style.MozUserSelect=s.__noselect,delete s.__noselect)}const vd=e=>()=>e;function qm(e,{sourceEvent:n,subject:s,target:i,identifier:l,active:d,x:c,y:h,dx:m,dy:f,dispatch:x}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},subject:{value:s,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:l,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}})}qm.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function zM(e){return!e.ctrlKey&&!e.button}function $M(){return this.parentNode}function BM(e,n){return n??{x:e.x,y:e.y}}function HM(){return navigator.maxTouchPoints||"ontouchstart"in this}function xw(){var e=zM,n=$M,s=BM,i=HM,l={},d=hu("start","drag","end"),c=0,h,m,f,x,p=0;function g(M){M.on("mousedown.drag",y).filter(i).on("touchstart.drag",T).on("touchmove.drag",C,IM).on("touchend.drag touchcancel.drag",_).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function y(M,D){if(!(x||!e.call(this,M,D))){var A=k(this,n.call(this,M,D),M,D,"mouse");A&&(Zr(M.view).on("mousemove.drag",w,Vo).on("mouseup.drag",N,Vo),hw(M.view),em(M),f=!1,h=M.clientX,m=M.clientY,A("start",M))}}function w(M){if(gl(M),!f){var D=M.clientX-h,A=M.clientY-m;f=D*D+A*A>p}l.mouse("drag",M)}function N(M){Zr(M.view).on("mousemove.drag mouseup.drag",null),mw(M.view,f),gl(M),l.mouse("end",M)}function T(M,D){if(e.call(this,M,D)){var A=M.changedTouches,G=n.call(this,M,D),X=A.length,K,$;for(K=0;K<X;++K)($=k(this,G,M,D,A[K].identifier,A[K]))&&(em(M),$("start",M,A[K]))}}function C(M){var D=M.changedTouches,A=D.length,G,X;for(G=0;G<A;++G)(X=l[D[G].identifier])&&(gl(M),X("drag",M,D[G]))}function _(M){var D=M.changedTouches,A=D.length,G,X;for(x&&clearTimeout(x),x=setTimeout(function(){x=null},500),G=0;G<A;++G)(X=l[D[G].identifier])&&(em(M),X("end",M,D[G]))}function k(M,D,A,G,X,K){var $=d.copy(),q=ps(K||A,D),U,z,E;if((E=s.call(M,new qm("beforestart",{sourceEvent:A,target:g,identifier:X,active:c,x:q[0],y:q[1],dx:0,dy:0,dispatch:$}),G))!=null)return U=E.x-q[0]||0,z=E.y-q[1]||0,function L(R,F,Y){var Z=q,B;switch(R){case"start":l[X]=L,B=c++;break;case"end":delete l[X],--c;case"drag":q=ps(Y||F,D),B=c;break}$.call(R,M,new qm(R,{sourceEvent:F,subject:E,target:g,identifier:X,active:B,x:q[0]+U,y:q[1]+z,dx:q[0]-Z[0],dy:q[1]-Z[1],dispatch:$}),G)}}return g.filter=function(M){return arguments.length?(e=typeof M=="function"?M:vd(!!M),g):e},g.container=function(M){return arguments.length?(n=typeof M=="function"?M:vd(M),g):n},g.subject=function(M){return arguments.length?(s=typeof M=="function"?M:vd(M),g):s},g.touchable=function(M){return arguments.length?(i=typeof M=="function"?M:vd(!!M),g):i},g.on=function(){var M=d.on.apply(d,arguments);return M===d?g:M},g.clickDistance=function(M){return arguments.length?(p=(M=+M)*M,g):Math.sqrt(p)},g}function Ax(e,n,s){e.prototype=n.prototype=s,s.constructor=e}function pw(e,n){var s=Object.create(e.prototype);for(var i in n)s[i]=n[i];return s}function ac(){}var Fo=.7,Xd=1/Fo,bl="\\s*([+-]?\\d+)\\s*",Yo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ds="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",PM=/^#([0-9a-f]{3,8})$/,qM=new RegExp(`^rgb\\(${bl},${bl},${bl}\\)$`),UM=new RegExp(`^rgb\\(${Ds},${Ds},${Ds}\\)$`),VM=new RegExp(`^rgba\\(${bl},${bl},${bl},${Yo}\\)$`),FM=new RegExp(`^rgba\\(${Ds},${Ds},${Ds},${Yo}\\)$`),YM=new RegExp(`^hsl\\(${Yo},${Ds},${Ds}\\)$`),GM=new RegExp(`^hsla\\(${Yo},${Ds},${Ds},${Yo}\\)$`),Jy={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};Ax(ac,ki,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:ev,formatHex:ev,formatHex8:XM,formatHsl:KM,formatRgb:tv,toString:tv});function ev(){return this.rgb().formatHex()}function XM(){return this.rgb().formatHex8()}function KM(){return gw(this).formatHsl()}function tv(){return this.rgb().formatRgb()}function ki(e){var n,s;return e=(e+"").trim().toLowerCase(),(n=PM.exec(e))?(s=n[1].length,n=parseInt(n[1],16),s===6?nv(n):s===3?new zr(n>>8&15|n>>4&240,n>>4&15|n&240,(n&15)<<4|n&15,1):s===8?jd(n>>24&255,n>>16&255,n>>8&255,(n&255)/255):s===4?jd(n>>12&15|n>>8&240,n>>8&15|n>>4&240,n>>4&15|n&240,((n&15)<<4|n&15)/255):null):(n=qM.exec(e))?new zr(n[1],n[2],n[3],1):(n=UM.exec(e))?new zr(n[1]*255/100,n[2]*255/100,n[3]*255/100,1):(n=VM.exec(e))?jd(n[1],n[2],n[3],n[4]):(n=FM.exec(e))?jd(n[1]*255/100,n[2]*255/100,n[3]*255/100,n[4]):(n=YM.exec(e))?av(n[1],n[2]/100,n[3]/100,1):(n=GM.exec(e))?av(n[1],n[2]/100,n[3]/100,n[4]):Jy.hasOwnProperty(e)?nv(Jy[e]):e==="transparent"?new zr(NaN,NaN,NaN,0):null}function nv(e){return new zr(e>>16&255,e>>8&255,e&255,1)}function jd(e,n,s,i){return i<=0&&(e=n=s=NaN),new zr(e,n,s,i)}function WM(e){return e instanceof ac||(e=ki(e)),e?(e=e.rgb(),new zr(e.r,e.g,e.b,e.opacity)):new zr}function Um(e,n,s,i){return arguments.length===1?WM(e):new zr(e,n,s,i??1)}function zr(e,n,s,i){this.r=+e,this.g=+n,this.b=+s,this.opacity=+i}Ax(zr,Um,pw(ac,{brighter(e){return e=e==null?Xd:Math.pow(Xd,e),new zr(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Fo:Math.pow(Fo,e),new zr(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new zr(vi(this.r),vi(this.g),vi(this.b),Kd(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:rv,formatHex:rv,formatHex8:QM,formatRgb:sv,toString:sv}));function rv(){return`#${bi(this.r)}${bi(this.g)}${bi(this.b)}`}function QM(){return`#${bi(this.r)}${bi(this.g)}${bi(this.b)}${bi((isNaN(this.opacity)?1:this.opacity)*255)}`}function sv(){const e=Kd(this.opacity);return`${e===1?"rgb(":"rgba("}${vi(this.r)}, ${vi(this.g)}, ${vi(this.b)}${e===1?")":`, ${e})`}`}function Kd(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function vi(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function bi(e){return e=vi(e),(e<16?"0":"")+e.toString(16)}function av(e,n,s,i){return i<=0?e=n=s=NaN:s<=0||s>=1?e=n=NaN:n<=0&&(e=NaN),new gs(e,n,s,i)}function gw(e){if(e instanceof gs)return new gs(e.h,e.s,e.l,e.opacity);if(e instanceof ac||(e=ki(e)),!e)return new gs;if(e instanceof gs)return e;e=e.rgb();var n=e.r/255,s=e.g/255,i=e.b/255,l=Math.min(n,s,i),d=Math.max(n,s,i),c=NaN,h=d-l,m=(d+l)/2;return h?(n===d?c=(s-i)/h+(s<i)*6:s===d?c=(i-n)/h+2:c=(n-s)/h+4,h/=m<.5?d+l:2-d-l,c*=60):h=m>0&&m<1?0:c,new gs(c,h,m,e.opacity)}function ZM(e,n,s,i){return arguments.length===1?gw(e):new gs(e,n,s,i??1)}function gs(e,n,s,i){this.h=+e,this.s=+n,this.l=+s,this.opacity=+i}Ax(gs,ZM,pw(ac,{brighter(e){return e=e==null?Xd:Math.pow(Xd,e),new gs(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Fo:Math.pow(Fo,e),new gs(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,n=isNaN(e)||isNaN(this.s)?0:this.s,s=this.l,i=s+(s<.5?s:1-s)*n,l=2*s-i;return new zr(tm(e>=240?e-240:e+120,l,i),tm(e,l,i),tm(e<120?e+240:e-120,l,i),this.opacity)},clamp(){return new gs(iv(this.h),wd(this.s),wd(this.l),Kd(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=Kd(this.opacity);return`${e===1?"hsl(":"hsla("}${iv(this.h)}, ${wd(this.s)*100}%, ${wd(this.l)*100}%${e===1?")":`, ${e})`}`}}));function iv(e){return e=(e||0)%360,e<0?e+360:e}function wd(e){return Math.max(0,Math.min(1,e||0))}function tm(e,n,s){return(e<60?n+(s-n)*e/60:e<180?s:e<240?n+(s-n)*(240-e)/60:n)*255}const Mx=e=>()=>e;function JM(e,n){return function(s){return e+s*n}}function e6(e,n,s){return e=Math.pow(e,s),n=Math.pow(n,s)-e,s=1/s,function(i){return Math.pow(e+i*n,s)}}function t6(e){return(e=+e)==1?bw:function(n,s){return s-n?e6(n,s,e):Mx(isNaN(n)?s:n)}}function bw(e,n){var s=n-e;return s?JM(e,s):Mx(isNaN(e)?n:e)}const Wd=(function e(n){var s=t6(n);function i(l,d){var c=s((l=Um(l)).r,(d=Um(d)).r),h=s(l.g,d.g),m=s(l.b,d.b),f=bw(l.opacity,d.opacity);return function(x){return l.r=c(x),l.g=h(x),l.b=m(x),l.opacity=f(x),l+""}}return i.gamma=e,i})(1);function n6(e,n){n||(n=[]);var s=e?Math.min(n.length,e.length):0,i=n.slice(),l;return function(d){for(l=0;l<s;++l)i[l]=e[l]*(1-d)+n[l]*d;return i}}function r6(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function s6(e,n){var s=n?n.length:0,i=e?Math.min(s,e.length):0,l=new Array(i),d=new Array(s),c;for(c=0;c<i;++c)l[c]=Io(e[c],n[c]);for(;c<s;++c)d[c]=n[c];return function(h){for(c=0;c<i;++c)d[c]=l[c](h);return d}}function a6(e,n){var s=new Date;return e=+e,n=+n,function(i){return s.setTime(e*(1-i)+n*i),s}}function Os(e,n){return e=+e,n=+n,function(s){return e*(1-s)+n*s}}function i6(e,n){var s={},i={},l;(e===null||typeof e!="object")&&(e={}),(n===null||typeof n!="object")&&(n={});for(l in n)l in e?s[l]=Io(e[l],n[l]):i[l]=n[l];return function(d){for(l in s)i[l]=s[l](d);return i}}var Vm=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,nm=new RegExp(Vm.source,"g");function l6(e){return function(){return e}}function o6(e){return function(n){return e(n)+""}}function yw(e,n){var s=Vm.lastIndex=nm.lastIndex=0,i,l,d,c=-1,h=[],m=[];for(e=e+"",n=n+"";(i=Vm.exec(e))&&(l=nm.exec(n));)(d=l.index)>s&&(d=n.slice(s,d),h[c]?h[c]+=d:h[++c]=d),(i=i[0])===(l=l[0])?h[c]?h[c]+=l:h[++c]=l:(h[++c]=null,m.push({i:c,x:Os(i,l)})),s=nm.lastIndex;return s<n.length&&(d=n.slice(s),h[c]?h[c]+=d:h[++c]=d),h.length<2?m[0]?o6(m[0].x):l6(n):(n=m.length,function(f){for(var x=0,p;x<n;++x)h[(p=m[x]).i]=p.x(f);return h.join("")})}function Io(e,n){var s=typeof n,i;return n==null||s==="boolean"?Mx(n):(s==="number"?Os:s==="string"?(i=ki(n))?(n=i,Wd):yw:n instanceof ki?Wd:n instanceof Date?a6:r6(n)?n6:Array.isArray(n)?s6:typeof n.valueOf!="function"&&typeof n.toString!="function"||isNaN(n)?i6:Os)(e,n)}var lv=180/Math.PI,Fm={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function vw(e,n,s,i,l,d){var c,h,m;return(c=Math.sqrt(e*e+n*n))&&(e/=c,n/=c),(m=e*s+n*i)&&(s-=e*m,i-=n*m),(h=Math.sqrt(s*s+i*i))&&(s/=h,i/=h,m/=h),e*i<n*s&&(e=-e,n=-n,m=-m,c=-c),{translateX:l,translateY:d,rotate:Math.atan2(n,e)*lv,skewX:Math.atan(m)*lv,scaleX:c,scaleY:h}}var Nd;function c6(e){const n=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return n.isIdentity?Fm:vw(n.a,n.b,n.c,n.d,n.e,n.f)}function d6(e){return e==null||(Nd||(Nd=document.createElementNS("http://www.w3.org/2000/svg","g")),Nd.setAttribute("transform",e),!(e=Nd.transform.baseVal.consolidate()))?Fm:(e=e.matrix,vw(e.a,e.b,e.c,e.d,e.e,e.f))}function jw(e,n,s,i){function l(f){return f.length?f.pop()+" ":""}function d(f,x,p,g,y,w){if(f!==p||x!==g){var N=y.push("translate(",null,n,null,s);w.push({i:N-4,x:Os(f,p)},{i:N-2,x:Os(x,g)})}else(p||g)&&y.push("translate("+p+n+g+s)}function c(f,x,p,g){f!==x?(f-x>180?x+=360:x-f>180&&(f+=360),g.push({i:p.push(l(p)+"rotate(",null,i)-2,x:Os(f,x)})):x&&p.push(l(p)+"rotate("+x+i)}function h(f,x,p,g){f!==x?g.push({i:p.push(l(p)+"skewX(",null,i)-2,x:Os(f,x)}):x&&p.push(l(p)+"skewX("+x+i)}function m(f,x,p,g,y,w){if(f!==p||x!==g){var N=y.push(l(y)+"scale(",null,",",null,")");w.push({i:N-4,x:Os(f,p)},{i:N-2,x:Os(x,g)})}else(p!==1||g!==1)&&y.push(l(y)+"scale("+p+","+g+")")}return function(f,x){var p=[],g=[];return f=e(f),x=e(x),d(f.translateX,f.translateY,x.translateX,x.translateY,p,g),c(f.rotate,x.rotate,p,g),h(f.skewX,x.skewX,p,g),m(f.scaleX,f.scaleY,x.scaleX,x.scaleY,p,g),f=x=null,function(y){for(var w=-1,N=g.length,T;++w<N;)p[(T=g[w]).i]=T.x(y);return p.join("")}}}var u6=jw(c6,"px, ","px)","deg)"),f6=jw(d6,", ",")",")"),h6=1e-12;function ov(e){return((e=Math.exp(e))+1/e)/2}function m6(e){return((e=Math.exp(e))-1/e)/2}function x6(e){return((e=Math.exp(2*e))-1)/(e+1)}const Ld=(function e(n,s,i){function l(d,c){var h=d[0],m=d[1],f=d[2],x=c[0],p=c[1],g=c[2],y=x-h,w=p-m,N=y*y+w*w,T,C;if(N<h6)C=Math.log(g/f)/n,T=function(G){return[h+G*y,m+G*w,f*Math.exp(n*G*C)]};else{var _=Math.sqrt(N),k=(g*g-f*f+i*N)/(2*f*s*_),M=(g*g-f*f-i*N)/(2*g*s*_),D=Math.log(Math.sqrt(k*k+1)-k),A=Math.log(Math.sqrt(M*M+1)-M);C=(A-D)/n,T=function(G){var X=G*C,K=ov(D),$=f/(s*_)*(K*x6(n*X+D)-m6(D));return[h+$*y,m+$*w,f*K/ov(n*X+D)]}}return T.duration=C*1e3*n/Math.SQRT2,T}return l.rho=function(d){var c=Math.max(.001,+d),h=c*c,m=h*h;return e(c,h,m)},l})(Math.SQRT2,2,4);var jl=0,_o=0,ko=0,ww=1e3,Qd,Ao,Zd=0,Si=0,xu=0,Go=typeof performance=="object"&&performance.now?performance:Date,Nw=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Rx(){return Si||(Nw(p6),Si=Go.now()+xu)}function p6(){Si=0}function Jd(){this._call=this._time=this._next=null}Jd.prototype=kw.prototype={constructor:Jd,restart:function(e,n,s){if(typeof e!="function")throw new TypeError("callback is not a function");s=(s==null?Rx():+s)+(n==null?0:+n),!this._next&&Ao!==this&&(Ao?Ao._next=this:Qd=this,Ao=this),this._call=e,this._time=s,Ym()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ym())}};function kw(e,n,s){var i=new Jd;return i.restart(e,n,s),i}function g6(){Rx(),++jl;for(var e=Qd,n;e;)(n=Si-e._time)>=0&&e._call.call(void 0,n),e=e._next;--jl}function cv(){Si=(Zd=Go.now())+xu,jl=_o=0;try{g6()}finally{jl=0,y6(),Si=0}}function b6(){var e=Go.now(),n=e-Zd;n>ww&&(xu-=n,Zd=e)}function y6(){for(var e,n=Qd,s,i=1/0;n;)n._call?(i>n._time&&(i=n._time),e=n,n=n._next):(s=n._next,n._next=null,n=e?e._next=s:Qd=s);Ao=e,Ym(i)}function Ym(e){if(!jl){_o&&(_o=clearTimeout(_o));var n=e-Si;n>24?(e<1/0&&(_o=setTimeout(cv,e-Go.now()-xu)),ko&&(ko=clearInterval(ko))):(ko||(Zd=Go.now(),ko=setInterval(b6,ww)),jl=1,Nw(cv))}}function dv(e,n,s){var i=new Jd;return n=n==null?0:+n,i.restart(l=>{i.stop(),e(l+n)},n,s),i}var v6=hu("start","end","cancel","interrupt"),j6=[],Sw=0,uv=1,Gm=2,Id=3,fv=4,Xm=5,zd=6;function pu(e,n,s,i,l,d){var c=e.__transition;if(!c)e.__transition={};else if(s in c)return;w6(e,s,{name:n,index:i,group:l,on:v6,tween:j6,time:d.time,delay:d.delay,duration:d.duration,ease:d.ease,timer:null,state:Sw})}function Ox(e,n){var s=ws(e,n);if(s.state>Sw)throw new Error("too late; already scheduled");return s}function zs(e,n){var s=ws(e,n);if(s.state>Id)throw new Error("too late; already running");return s}function ws(e,n){var s=e.__transition;if(!s||!(s=s[n]))throw new Error("transition not found");return s}function w6(e,n,s){var i=e.__transition,l;i[n]=s,s.timer=kw(d,0,s.time);function d(f){s.state=uv,s.timer.restart(c,s.delay,s.time),s.delay<=f&&c(f-s.delay)}function c(f){var x,p,g,y;if(s.state!==uv)return m();for(x in i)if(y=i[x],y.name===s.name){if(y.state===Id)return dv(c);y.state===fv?(y.state=zd,y.timer.stop(),y.on.call("interrupt",e,e.__data__,y.index,y.group),delete i[x]):+x<n&&(y.state=zd,y.timer.stop(),y.on.call("cancel",e,e.__data__,y.index,y.group),delete i[x])}if(dv(function(){s.state===Id&&(s.state=fv,s.timer.restart(h,s.delay,s.time),h(f))}),s.state=Gm,s.on.call("start",e,e.__data__,s.index,s.group),s.state===Gm){for(s.state=Id,l=new Array(g=s.tween.length),x=0,p=-1;x<g;++x)(y=s.tween[x].value.call(e,e.__data__,s.index,s.group))&&(l[++p]=y);l.length=p+1}}function h(f){for(var x=f<s.duration?s.ease.call(null,f/s.duration):(s.timer.restart(m),s.state=Xm,1),p=-1,g=l.length;++p<g;)l[p].call(e,x);s.state===Xm&&(s.on.call("end",e,e.__data__,s.index,s.group),m())}function m(){s.state=zd,s.timer.stop(),delete i[n];for(var f in i)return;delete e.__transition}}function $d(e,n){var s=e.__transition,i,l,d=!0,c;if(s){n=n==null?null:n+"";for(c in s){if((i=s[c]).name!==n){d=!1;continue}l=i.state>Gm&&i.state<Xm,i.state=zd,i.timer.stop(),i.on.call(l?"interrupt":"cancel",e,e.__data__,i.index,i.group),delete s[c]}d&&delete e.__transition}}function N6(e){return this.each(function(){$d(this,e)})}function k6(e,n){var s,i;return function(){var l=zs(this,e),d=l.tween;if(d!==s){i=s=d;for(var c=0,h=i.length;c<h;++c)if(i[c].name===n){i=i.slice(),i.splice(c,1);break}}l.tween=i}}function S6(e,n,s){var i,l;if(typeof s!="function")throw new Error;return function(){var d=zs(this,e),c=d.tween;if(c!==i){l=(i=c).slice();for(var h={name:n,value:s},m=0,f=l.length;m<f;++m)if(l[m].name===n){l[m]=h;break}m===f&&l.push(h)}d.tween=l}}function C6(e,n){var s=this._id;if(e+="",arguments.length<2){for(var i=ws(this.node(),s).tween,l=0,d=i.length,c;l<d;++l)if((c=i[l]).name===e)return c.value;return null}return this.each((n==null?k6:S6)(s,e,n))}function Dx(e,n,s){var i=e._id;return e.each(function(){var l=zs(this,i);(l.value||(l.value={}))[n]=s.apply(this,arguments)}),function(l){return ws(l,i).value[n]}}function Cw(e,n){var s;return(typeof n=="number"?Os:n instanceof ki?Wd:(s=ki(n))?(n=s,Wd):yw)(e,n)}function E6(e){return function(){this.removeAttribute(e)}}function T6(e){return function(){this.removeAttributeNS(e.space,e.local)}}function _6(e,n,s){var i,l=s+"",d;return function(){var c=this.getAttribute(e);return c===l?null:c===i?d:d=n(i=c,s)}}function A6(e,n,s){var i,l=s+"",d;return function(){var c=this.getAttributeNS(e.space,e.local);return c===l?null:c===i?d:d=n(i=c,s)}}function M6(e,n,s){var i,l,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===i&&m===l?d:(l=m,d=n(i=c,h)))}}function R6(e,n,s){var i,l,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===i&&m===l?d:(l=m,d=n(i=c,h)))}}function O6(e,n){var s=mu(e),i=s==="transform"?f6:Cw;return this.attrTween(e,typeof n=="function"?(s.local?R6:M6)(s,i,Dx(this,"attr."+e,n)):n==null?(s.local?T6:E6)(s):(s.local?A6:_6)(s,i,n))}function D6(e,n){return function(s){this.setAttribute(e,n.call(this,s))}}function L6(e,n){return function(s){this.setAttributeNS(e.space,e.local,n.call(this,s))}}function I6(e,n){var s,i;function l(){var d=n.apply(this,arguments);return d!==i&&(s=(i=d)&&L6(e,d)),s}return l._value=n,l}function z6(e,n){var s,i;function l(){var d=n.apply(this,arguments);return d!==i&&(s=(i=d)&&D6(e,d)),s}return l._value=n,l}function $6(e,n){var s="attr."+e;if(arguments.length<2)return(s=this.tween(s))&&s._value;if(n==null)return this.tween(s,null);if(typeof n!="function")throw new Error;var i=mu(e);return this.tween(s,(i.local?I6:z6)(i,n))}function B6(e,n){return function(){Ox(this,e).delay=+n.apply(this,arguments)}}function H6(e,n){return n=+n,function(){Ox(this,e).delay=n}}function P6(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?B6:H6)(n,e)):ws(this.node(),n).delay}function q6(e,n){return function(){zs(this,e).duration=+n.apply(this,arguments)}}function U6(e,n){return n=+n,function(){zs(this,e).duration=n}}function V6(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?q6:U6)(n,e)):ws(this.node(),n).duration}function F6(e,n){if(typeof n!="function")throw new Error;return function(){zs(this,e).ease=n}}function Y6(e){var n=this._id;return arguments.length?this.each(F6(n,e)):ws(this.node(),n).ease}function G6(e,n){return function(){var s=n.apply(this,arguments);if(typeof s!="function")throw new Error;zs(this,e).ease=s}}function X6(e){if(typeof e!="function")throw new Error;return this.each(G6(this._id,e))}function K6(e){typeof e!="function"&&(e=rw(e));for(var n=this._groups,s=n.length,i=new Array(s),l=0;l<s;++l)for(var d=n[l],c=d.length,h=i[l]=[],m,f=0;f<c;++f)(m=d[f])&&e.call(m,m.__data__,f,d)&&h.push(m);return new da(i,this._parents,this._name,this._id)}function W6(e){if(e._id!==this._id)throw new Error;for(var n=this._groups,s=e._groups,i=n.length,l=s.length,d=Math.min(i,l),c=new Array(i),h=0;h<d;++h)for(var m=n[h],f=s[h],x=m.length,p=c[h]=new Array(x),g,y=0;y<x;++y)(g=m[y]||f[y])&&(p[y]=g);for(;h<i;++h)c[h]=n[h];return new da(c,this._parents,this._name,this._id)}function Q6(e){return(e+"").trim().split(/^|\s+/).every(function(n){var s=n.indexOf(".");return s>=0&&(n=n.slice(0,s)),!n||n==="start"})}function Z6(e,n,s){var i,l,d=Q6(n)?Ox:zs;return function(){var c=d(this,e),h=c.on;h!==i&&(l=(i=h).copy()).on(n,s),c.on=l}}function J6(e,n){var s=this._id;return arguments.length<2?ws(this.node(),s).on.on(e):this.each(Z6(s,e,n))}function eR(e){return function(){var n=this.parentNode;for(var s in this.__transition)if(+s!==e)return;n&&n.removeChild(this)}}function tR(){return this.on("end.remove",eR(this._id))}function nR(e){var n=this._name,s=this._id;typeof e!="function"&&(e=Tx(e));for(var i=this._groups,l=i.length,d=new Array(l),c=0;c<l;++c)for(var h=i[c],m=h.length,f=d[c]=new Array(m),x,p,g=0;g<m;++g)(x=h[g])&&(p=e.call(x,x.__data__,g,h))&&("__data__"in x&&(p.__data__=x.__data__),f[g]=p,pu(f[g],n,s,g,f,ws(x,s)));return new da(d,this._parents,n,s)}function rR(e){var n=this._name,s=this._id;typeof e!="function"&&(e=nw(e));for(var i=this._groups,l=i.length,d=[],c=[],h=0;h<l;++h)for(var m=i[h],f=m.length,x,p=0;p<f;++p)if(x=m[p]){for(var g=e.call(x,x.__data__,p,m),y,w=ws(x,s),N=0,T=g.length;N<T;++N)(y=g[N])&&pu(y,n,s,N,g,w);d.push(g),c.push(x)}return new da(d,c,n,s)}var sR=sc.prototype.constructor;function aR(){return new sR(this._groups,this._parents)}function iR(e,n){var s,i,l;return function(){var d=vl(this,e),c=(this.style.removeProperty(e),vl(this,e));return d===c?null:d===s&&c===i?l:l=n(s=d,i=c)}}function Ew(e){return function(){this.style.removeProperty(e)}}function lR(e,n,s){var i,l=s+"",d;return function(){var c=vl(this,e);return c===l?null:c===i?d:d=n(i=c,s)}}function oR(e,n,s){var i,l,d;return function(){var c=vl(this,e),h=s(this),m=h+"";return h==null&&(m=h=(this.style.removeProperty(e),vl(this,e))),c===m?null:c===i&&m===l?d:(l=m,d=n(i=c,h))}}function cR(e,n){var s,i,l,d="style."+n,c="end."+d,h;return function(){var m=zs(this,e),f=m.on,x=m.value[d]==null?h||(h=Ew(n)):void 0;(f!==s||l!==x)&&(i=(s=f).copy()).on(c,l=x),m.on=i}}function dR(e,n,s){var i=(e+="")=="transform"?u6:Cw;return n==null?this.styleTween(e,iR(e,i)).on("end.style."+e,Ew(e)):typeof n=="function"?this.styleTween(e,oR(e,i,Dx(this,"style."+e,n))).each(cR(this._id,e)):this.styleTween(e,lR(e,i,n),s).on("end.style."+e,null)}function uR(e,n,s){return function(i){this.style.setProperty(e,n.call(this,i),s)}}function fR(e,n,s){var i,l;function d(){var c=n.apply(this,arguments);return c!==l&&(i=(l=c)&&uR(e,c,s)),i}return d._value=n,d}function hR(e,n,s){var i="style."+(e+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(n==null)return this.tween(i,null);if(typeof n!="function")throw new Error;return this.tween(i,fR(e,n,s??""))}function mR(e){return function(){this.textContent=e}}function xR(e){return function(){var n=e(this);this.textContent=n??""}}function pR(e){return this.tween("text",typeof e=="function"?xR(Dx(this,"text",e)):mR(e==null?"":e+""))}function gR(e){return function(n){this.textContent=e.call(this,n)}}function bR(e){var n,s;function i(){var l=e.apply(this,arguments);return l!==s&&(n=(s=l)&&gR(l)),n}return i._value=e,i}function yR(e){var n="text";if(arguments.length<1)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;return this.tween(n,bR(e))}function vR(){for(var e=this._name,n=this._id,s=Tw(),i=this._groups,l=i.length,d=0;d<l;++d)for(var c=i[d],h=c.length,m,f=0;f<h;++f)if(m=c[f]){var x=ws(m,n);pu(m,e,s,f,c,{time:x.time+x.delay+x.duration,delay:0,duration:x.duration,ease:x.ease})}return new da(i,this._parents,e,s)}function jR(){var e,n,s=this,i=s._id,l=s.size();return new Promise(function(d,c){var h={value:c},m={value:function(){--l===0&&d()}};s.each(function(){var f=zs(this,i),x=f.on;x!==e&&(n=(e=x).copy(),n._.cancel.push(h),n._.interrupt.push(h),n._.end.push(m)),f.on=n}),l===0&&d()})}var wR=0;function da(e,n,s,i){this._groups=e,this._parents=n,this._name=s,this._id=i}function Tw(){return++wR}var ra=sc.prototype;da.prototype={constructor:da,select:nR,selectAll:rR,selectChild:ra.selectChild,selectChildren:ra.selectChildren,filter:K6,merge:W6,selection:aR,transition:vR,call:ra.call,nodes:ra.nodes,node:ra.node,size:ra.size,empty:ra.empty,each:ra.each,on:J6,attr:O6,attrTween:$6,style:dR,styleTween:hR,text:pR,textTween:yR,remove:tR,tween:C6,delay:P6,duration:V6,ease:Y6,easeVarying:X6,end:jR,[Symbol.iterator]:ra[Symbol.iterator]};function NR(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var kR={time:null,delay:0,duration:250,ease:NR};function SR(e,n){for(var s;!(s=e.__transition)||!(s=s[n]);)if(!(e=e.parentNode))throw new Error(`transition ${n} not found`);return s}function CR(e){var n,s;e instanceof da?(n=e._id,e=e._name):(n=Tw(),(s=kR).time=Rx(),e=e==null?null:e+"");for(var i=this._groups,l=i.length,d=0;d<l;++d)for(var c=i[d],h=c.length,m,f=0;f<h;++f)(m=c[f])&&pu(m,e,n,f,c,s||SR(m,n));return new da(i,this._parents,e,n)}sc.prototype.interrupt=N6;sc.prototype.transition=CR;const kd=e=>()=>e;function ER(e,{sourceEvent:n,target:s,transform:i,dispatch:l}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:l}})}function oa(e,n,s){this.k=e,this.x=n,this.y=s}oa.prototype={constructor:oa,scale:function(e){return e===1?this:new oa(this.k*e,this.x,this.y)},translate:function(e,n){return e===0&n===0?this:new oa(this.k,this.x+this.k*e,this.y+this.k*n)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var gu=new oa(1,0,0);_w.prototype=oa.prototype;function _w(e){for(;!e.__zoom;)if(!(e=e.parentNode))return gu;return e.__zoom}function rm(e){e.stopImmediatePropagation()}function So(e){e.preventDefault(),e.stopImmediatePropagation()}function TR(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function _R(){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 hv(){return this.__zoom||gu}function AR(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function MR(){return navigator.maxTouchPoints||"ontouchstart"in this}function RR(e,n,s){var i=e.invertX(n[0][0])-s[0][0],l=e.invertX(n[1][0])-s[1][0],d=e.invertY(n[0][1])-s[0][1],c=e.invertY(n[1][1])-s[1][1];return e.translate(l>i?(i+l)/2:Math.min(0,i)||Math.max(0,l),c>d?(d+c)/2:Math.min(0,d)||Math.max(0,c))}function Aw(){var e=TR,n=_R,s=RR,i=AR,l=MR,d=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],h=250,m=Ld,f=hu("start","zoom","end"),x,p,g,y=500,w=150,N=0,T=10;function C(E){E.property("__zoom",hv).on("wheel.zoom",X,{passive:!1}).on("mousedown.zoom",K).on("dblclick.zoom",$).filter(l).on("touchstart.zoom",q).on("touchmove.zoom",U).on("touchend.zoom touchcancel.zoom",z).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}C.transform=function(E,L,R,F){var Y=E.selection?E.selection():E;Y.property("__zoom",hv),E!==Y?D(E,L,R,F):Y.interrupt().each(function(){A(this,arguments).event(F).start().zoom(null,typeof L=="function"?L.apply(this,arguments):L).end()})},C.scaleBy=function(E,L,R,F){C.scaleTo(E,function(){var Y=this.__zoom.k,Z=typeof L=="function"?L.apply(this,arguments):L;return Y*Z},R,F)},C.scaleTo=function(E,L,R,F){C.transform(E,function(){var Y=n.apply(this,arguments),Z=this.__zoom,B=R==null?M(Y):typeof R=="function"?R.apply(this,arguments):R,O=Z.invert(B),V=typeof L=="function"?L.apply(this,arguments):L;return s(k(_(Z,V),B,O),Y,c)},R,F)},C.translateBy=function(E,L,R,F){C.transform(E,function(){return s(this.__zoom.translate(typeof L=="function"?L.apply(this,arguments):L,typeof R=="function"?R.apply(this,arguments):R),n.apply(this,arguments),c)},null,F)},C.translateTo=function(E,L,R,F,Y){C.transform(E,function(){var Z=n.apply(this,arguments),B=this.__zoom,O=F==null?M(Z):typeof F=="function"?F.apply(this,arguments):F;return s(gu.translate(O[0],O[1]).scale(B.k).translate(typeof L=="function"?-L.apply(this,arguments):-L,typeof R=="function"?-R.apply(this,arguments):-R),Z,c)},F,Y)};function _(E,L){return L=Math.max(d[0],Math.min(d[1],L)),L===E.k?E:new oa(L,E.x,E.y)}function k(E,L,R){var F=L[0]-R[0]*E.k,Y=L[1]-R[1]*E.k;return F===E.x&&Y===E.y?E:new oa(E.k,F,Y)}function M(E){return[(+E[0][0]+ +E[1][0])/2,(+E[0][1]+ +E[1][1])/2]}function D(E,L,R,F){E.on("start.zoom",function(){A(this,arguments).event(F).start()}).on("interrupt.zoom end.zoom",function(){A(this,arguments).event(F).end()}).tween("zoom",function(){var Y=this,Z=arguments,B=A(Y,Z).event(F),O=n.apply(Y,Z),V=R==null?M(O):typeof R=="function"?R.apply(Y,Z):R,I=Math.max(O[1][0]-O[0][0],O[1][1]-O[0][1]),S=Y.__zoom,H=typeof L=="function"?L.apply(Y,Z):L,W=m(S.invert(V).concat(I/S.k),H.invert(V).concat(I/H.k));return function(ee){if(ee===1)ee=H;else{var te=W(ee),ae=I/te[2];ee=new oa(ae,V[0]-te[0]*ae,V[1]-te[1]*ae)}B.zoom(null,ee)}})}function A(E,L,R){return!R&&E.__zooming||new G(E,L)}function G(E,L){this.that=E,this.args=L,this.active=0,this.sourceEvent=null,this.extent=n.apply(E,L),this.taps=0}G.prototype={event:function(E){return E&&(this.sourceEvent=E),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(E,L){return this.mouse&&E!=="mouse"&&(this.mouse[1]=L.invert(this.mouse[0])),this.touch0&&E!=="touch"&&(this.touch0[1]=L.invert(this.touch0[0])),this.touch1&&E!=="touch"&&(this.touch1[1]=L.invert(this.touch1[0])),this.that.__zoom=L,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(E){var L=Zr(this.that).datum();f.call(E,this.that,new ER(E,{sourceEvent:this.sourceEvent,target:C,transform:this.that.__zoom,dispatch:f}),L)}};function X(E,...L){if(!e.apply(this,arguments))return;var R=A(this,L).event(E),F=this.__zoom,Y=Math.max(d[0],Math.min(d[1],F.k*Math.pow(2,i.apply(this,arguments)))),Z=ps(E);if(R.wheel)(R.mouse[0][0]!==Z[0]||R.mouse[0][1]!==Z[1])&&(R.mouse[1]=F.invert(R.mouse[0]=Z)),clearTimeout(R.wheel);else{if(F.k===Y)return;R.mouse=[Z,F.invert(Z)],$d(this),R.start()}So(E),R.wheel=setTimeout(B,w),R.zoom("mouse",s(k(_(F,Y),R.mouse[0],R.mouse[1]),R.extent,c));function B(){R.wheel=null,R.end()}}function K(E,...L){if(g||!e.apply(this,arguments))return;var R=E.currentTarget,F=A(this,L,!0).event(E),Y=Zr(E.view).on("mousemove.zoom",V,!0).on("mouseup.zoom",I,!0),Z=ps(E,R),B=E.clientX,O=E.clientY;hw(E.view),rm(E),F.mouse=[Z,this.__zoom.invert(Z)],$d(this),F.start();function V(S){if(So(S),!F.moved){var H=S.clientX-B,W=S.clientY-O;F.moved=H*H+W*W>N}F.event(S).zoom("mouse",s(k(F.that.__zoom,F.mouse[0]=ps(S,R),F.mouse[1]),F.extent,c))}function I(S){Y.on("mousemove.zoom mouseup.zoom",null),mw(S.view,F.moved),So(S),F.event(S).end()}}function $(E,...L){if(e.apply(this,arguments)){var R=this.__zoom,F=ps(E.changedTouches?E.changedTouches[0]:E,this),Y=R.invert(F),Z=R.k*(E.shiftKey?.5:2),B=s(k(_(R,Z),F,Y),n.apply(this,L),c);So(E),h>0?Zr(this).transition().duration(h).call(D,B,F,E):Zr(this).call(C.transform,B,F,E)}}function q(E,...L){if(e.apply(this,arguments)){var R=E.touches,F=R.length,Y=A(this,L,E.changedTouches.length===F).event(E),Z,B,O,V;for(rm(E),B=0;B<F;++B)O=R[B],V=ps(O,this),V=[V,this.__zoom.invert(V),O.identifier],Y.touch0?!Y.touch1&&Y.touch0[2]!==V[2]&&(Y.touch1=V,Y.taps=0):(Y.touch0=V,Z=!0,Y.taps=1+!!x);x&&(x=clearTimeout(x)),Z&&(Y.taps<2&&(p=V[0],x=setTimeout(function(){x=null},y)),$d(this),Y.start())}}function U(E,...L){if(this.__zooming){var R=A(this,L).event(E),F=E.changedTouches,Y=F.length,Z,B,O,V;for(So(E),Z=0;Z<Y;++Z)B=F[Z],O=ps(B,this),R.touch0&&R.touch0[2]===B.identifier?R.touch0[0]=O:R.touch1&&R.touch1[2]===B.identifier&&(R.touch1[0]=O);if(B=R.that.__zoom,R.touch1){var I=R.touch0[0],S=R.touch0[1],H=R.touch1[0],W=R.touch1[1],ee=(ee=H[0]-I[0])*ee+(ee=H[1]-I[1])*ee,te=(te=W[0]-S[0])*te+(te=W[1]-S[1])*te;B=_(B,Math.sqrt(ee/te)),O=[(I[0]+H[0])/2,(I[1]+H[1])/2],V=[(S[0]+W[0])/2,(S[1]+W[1])/2]}else if(R.touch0)O=R.touch0[0],V=R.touch0[1];else return;R.zoom("touch",s(k(B,O,V),R.extent,c))}}function z(E,...L){if(this.__zooming){var R=A(this,L).event(E),F=E.changedTouches,Y=F.length,Z,B;for(rm(E),g&&clearTimeout(g),g=setTimeout(function(){g=null},y),Z=0;Z<Y;++Z)B=F[Z],R.touch0&&R.touch0[2]===B.identifier?delete R.touch0:R.touch1&&R.touch1[2]===B.identifier&&delete R.touch1;if(R.touch1&&!R.touch0&&(R.touch0=R.touch1,delete R.touch1),R.touch0)R.touch0[1]=this.__zoom.invert(R.touch0[0]);else if(R.end(),R.taps===2&&(B=ps(B,this),Math.hypot(p[0]-B[0],p[1]-B[1])<T)){var O=Zr(this).on("dblclick.zoom");O&&O.apply(this,arguments)}}}return C.wheelDelta=function(E){return arguments.length?(i=typeof E=="function"?E:kd(+E),C):i},C.filter=function(E){return arguments.length?(e=typeof E=="function"?E:kd(!!E),C):e},C.touchable=function(E){return arguments.length?(l=typeof E=="function"?E:kd(!!E),C):l},C.extent=function(E){return arguments.length?(n=typeof E=="function"?E:kd([[+E[0][0],+E[0][1]],[+E[1][0],+E[1][1]]]),C):n},C.scaleExtent=function(E){return arguments.length?(d[0]=+E[0],d[1]=+E[1],C):[d[0],d[1]]},C.translateExtent=function(E){return arguments.length?(c[0][0]=+E[0][0],c[1][0]=+E[1][0],c[0][1]=+E[0][1],c[1][1]=+E[1][1],C):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},C.constrain=function(E){return arguments.length?(s=E,C):s},C.duration=function(E){return arguments.length?(h=+E,C):h},C.interpolate=function(E){return arguments.length?(m=E,C):m},C.on=function(){var E=f.on.apply(f,arguments);return E===f?C:E},C.clickDistance=function(E){return arguments.length?(N=(E=+E)*E,C):Math.sqrt(N)},C.tapDistance=function(E){return arguments.length?(T=+E,C):T},C}const Ls={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:n,sourceHandle:s,targetHandle:i})=>`Couldn't create edge for ${e} handle id: "${e==="source"?s:i}", edge id: ${n}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},Xo=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Mw=["Enter"," ","Escape"],Rw={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:n,y:s})=>`Moved selected node ${e}. New position, x: ${n}, 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 wl;(function(e){e.Strict="strict",e.Loose="loose"})(wl||(wl={}));var ji;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(ji||(ji={}));var Ko;(function(e){e.Partial="partial",e.Full="full"})(Ko||(Ko={}));const Ow={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Ya;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ya||(Ya={}));var Nl;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Nl||(Nl={}));var mt;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(mt||(mt={}));const mv={[mt.Left]:mt.Right,[mt.Right]:mt.Left,[mt.Top]:mt.Bottom,[mt.Bottom]:mt.Top};function Dw(e){return e===null?null:e?"valid":"invalid"}const Lw=e=>"id"in e&&"source"in e&&"target"in e,OR=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Lx=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),ic=(e,n=[0,0])=>{const{width:s,height:i}=fa(e),l=e.origin??n,d=s*l[0],c=i*l[1];return{x:e.position.x-d,y:e.position.y-c}},DR=(e,n={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const s=e.reduce((i,l)=>{const d=typeof l=="string";let c=!n.nodeLookup&&!d?l:void 0;n.nodeLookup&&(c=d?n.nodeLookup.get(l):Lx(l)?l:n.nodeLookup.get(l.id));const h=c?eu(c,n.nodeOrigin):{x:0,y:0,x2:0,y2:0};return bu(i,h)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return yu(s)},lc=(e,n={})=>{let s={x:1/0,y:1/0,x2:-1/0,y2:-1/0},i=!1;return e.forEach(l=>{(n.filter===void 0||n.filter(l))&&(s=bu(s,eu(l)),i=!0)}),i?yu(s):{x:0,y:0,width:0,height:0}},Ix=(e,n,[s,i,l]=[0,0,1],d=!1,c=!1)=>{const h={...cc(n,[s,i,l]),width:n.width/l,height:n.height/l},m=[];for(const f of e.values()){const{measured:x,selectable:p=!0,hidden:g=!1}=f;if(c&&!p||g)continue;const y=x.width??f.width??f.initialWidth??null,w=x.height??f.height??f.initialHeight??null,N=Wo(h,Sl(f)),T=(y??0)*(w??0),C=d&&N>0;(!f.internals.handleBounds||C||N>=T||f.dragging)&&m.push(f)}return m},LR=(e,n)=>{const s=new Set;return e.forEach(i=>{s.add(i.id)}),n.filter(i=>s.has(i.source)||s.has(i.target))};function IR(e,n){const s=new Map,i=n?.nodes?new Set(n.nodes.map(l=>l.id)):null;return e.forEach(l=>{l.measured.width&&l.measured.height&&(n?.includeHiddenNodes||!l.hidden)&&(!i||i.has(l.id))&&s.set(l.id,l)}),s}async function zR({nodes:e,width:n,height:s,panZoom:i,minZoom:l,maxZoom:d},c){if(e.size===0)return Promise.resolve(!0);const h=IR(e,c),m=lc(h),f=zx(m,n,s,c?.minZoom??l,c?.maxZoom??d,c?.padding??.1);return await i.setViewport(f,{duration:c?.duration,ease:c?.ease,interpolate:c?.interpolate}),Promise.resolve(!0)}function Iw({nodeId:e,nextPosition:n,nodeLookup:s,nodeOrigin:i=[0,0],nodeExtent:l,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??i;let p=c.extent||l;if(c.extent==="parent"&&!c.expandParent)if(!h)d?.("005",Ls.error005());else{const y=h.measured.width,w=h.measured.height;y&&w&&(p=[[m,f],[m+y,f+w]])}else h&&Cl(c.extent)&&(p=[[c.extent[0][0]+m,c.extent[0][1]+f],[c.extent[1][0]+m,c.extent[1][1]+f]]);const g=Cl(p)?Ci(n,p,c.measured):n;return(c.measured.width===void 0||c.measured.height===void 0)&&d?.("015",Ls.error015()),{position:{x:g.x-m+(c.measured.width??0)*x[0],y:g.y-f+(c.measured.height??0)*x[1]},positionAbsolute:g}}async function $R({nodesToRemove:e=[],edgesToRemove:n=[],nodes:s,edges:i,onBeforeDelete:l}){const d=new Set(e.map(g=>g.id)),c=[];for(const g of s){if(g.deletable===!1)continue;const y=d.has(g.id),w=!y&&g.parentId&&c.find(N=>N.id===g.parentId);(y||w)&&c.push(g)}const h=new Set(n.map(g=>g.id)),m=i.filter(g=>g.deletable!==!1),x=LR(c,m);for(const g of m)h.has(g.id)&&!x.find(w=>w.id===g.id)&&x.push(g);if(!l)return{edges:x,nodes:c};const p=await l({nodes:c,edges:x});return typeof p=="boolean"?p?{edges:x,nodes:c}:{edges:[],nodes:[]}:p}const kl=(e,n=0,s=1)=>Math.min(Math.max(e,n),s),Ci=(e={x:0,y:0},n,s)=>({x:kl(e.x,n[0][0],n[1][0]-(s?.width??0)),y:kl(e.y,n[0][1],n[1][1]-(s?.height??0))});function zw(e,n,s){const{width:i,height:l}=fa(s),{x:d,y:c}=s.internals.positionAbsolute;return Ci(e,[[d,c],[d+i,c+l]],n)}const xv=(e,n,s)=>e<n?kl(Math.abs(e-n),1,n)/n:e>s?-kl(Math.abs(e-s),1,n)/n:0,$w=(e,n,s=15,i=40)=>{const l=xv(e.x,i,n.width-i)*s,d=xv(e.y,i,n.height-i)*s;return[l,d]},bu=(e,n)=>({x:Math.min(e.x,n.x),y:Math.min(e.y,n.y),x2:Math.max(e.x2,n.x2),y2:Math.max(e.y2,n.y2)}),Km=({x:e,y:n,width:s,height:i})=>({x:e,y:n,x2:e+s,y2:n+i}),yu=({x:e,y:n,x2:s,y2:i})=>({x:e,y:n,width:s-e,height:i-n}),Sl=(e,n=[0,0])=>{const{x:s,y:i}=Lx(e)?e.internals.positionAbsolute:ic(e,n);return{x:s,y:i,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},eu=(e,n=[0,0])=>{const{x:s,y:i}=Lx(e)?e.internals.positionAbsolute:ic(e,n);return{x:s,y:i,x2:s+(e.measured?.width??e.width??e.initialWidth??0),y2:i+(e.measured?.height??e.height??e.initialHeight??0)}},Bw=(e,n)=>yu(bu(Km(e),Km(n))),Wo=(e,n)=>{const s=Math.max(0,Math.min(e.x+e.width,n.x+n.width)-Math.max(e.x,n.x)),i=Math.max(0,Math.min(e.y+e.height,n.y+n.height)-Math.max(e.y,n.y));return Math.ceil(s*i)},pv=e=>bs(e.width)&&bs(e.height)&&bs(e.x)&&bs(e.y),bs=e=>!isNaN(e)&&isFinite(e),BR=(e,n)=>{},oc=(e,n=[1,1])=>({x:n[0]*Math.round(e.x/n[0]),y:n[1]*Math.round(e.y/n[1])}),cc=({x:e,y:n},[s,i,l],d=!1,c=[1,1])=>{const h={x:(e-s)/l,y:(n-i)/l};return d?oc(h,c):h},tu=({x:e,y:n},[s,i,l])=>({x:e*l+s,y:n*l+i});function ll(e,n){if(typeof e=="number")return Math.floor((n-n/(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(n*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 HR(e,n,s){if(typeof e=="string"||typeof e=="number"){const i=ll(e,s),l=ll(e,n);return{top:i,right:l,bottom:i,left:l,x:l*2,y:i*2}}if(typeof e=="object"){const i=ll(e.top??e.y??0,s),l=ll(e.bottom??e.y??0,s),d=ll(e.left??e.x??0,n),c=ll(e.right??e.x??0,n);return{top:i,right:c,bottom:l,left:d,x:d+c,y:i+l}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function PR(e,n,s,i,l,d){const{x:c,y:h}=tu(e,[n,s,i]),{x:m,y:f}=tu({x:e.x+e.width,y:e.y+e.height},[n,s,i]),x=l-m,p=d-f;return{left:Math.floor(c),top:Math.floor(h),right:Math.floor(x),bottom:Math.floor(p)}}const zx=(e,n,s,i,l,d)=>{const c=HR(d,n,s),h=(n-c.x)/e.width,m=(s-c.y)/e.height,f=Math.min(h,m),x=kl(f,i,l),p=e.x+e.width/2,g=e.y+e.height/2,y=n/2-p*x,w=s/2-g*x,N=PR(e,y,w,x,n,s),T={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-T.left+T.right,y:w-T.top+T.bottom,zoom:x}},Qo=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Cl(e){return e!=null&&e!=="parent"}function fa(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Hw(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Pw(e,n={width:0,height:0},s,i,l){const d={...e},c=i.get(s);if(c){const h=c.origin||l;d.x+=c.internals.positionAbsolute.x-(n.width??0)*h[0],d.y+=c.internals.positionAbsolute.y-(n.height??0)*h[1]}return d}function gv(e,n){if(e.size!==n.size)return!1;for(const s of e)if(!n.has(s))return!1;return!0}function qR(){let e,n;return{promise:new Promise((i,l)=>{e=i,n=l}),resolve:e,reject:n}}function UR(e){return{...Rw,...e||{}}}function zo(e,{snapGrid:n=[0,0],snapToGrid:s=!1,transform:i,containerBounds:l}){const{x:d,y:c}=ys(e),h=cc({x:d-(l?.left??0),y:c-(l?.top??0)},i),{x:m,y:f}=s?oc(h,n):h;return{xSnapped:m,ySnapped:f,...h}}const $x=e=>({width:e.offsetWidth,height:e.offsetHeight}),qw=e=>e?.getRootNode?.()||window?.document,VR=["INPUT","SELECT","TEXTAREA"];function Uw(e){const n=e.composedPath?.()?.[0]||e.target;return n?.nodeType!==1?!1:VR.includes(n.nodeName)||n.hasAttribute("contenteditable")||!!n.closest(".nokey")}const Vw=e=>"clientX"in e,ys=(e,n)=>{const s=Vw(e),i=s?e.clientX:e.touches?.[0].clientX,l=s?e.clientY:e.touches?.[0].clientY;return{x:i-(n?.left??0),y:l-(n?.top??0)}},bv=(e,n,s,i,l)=>{const d=n.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:l,position:c.getAttribute("data-handlepos"),x:(h.left-s.left)/i,y:(h.top-s.top)/i,...$x(c)}})};function Fw({sourceX:e,sourceY:n,targetX:s,targetY:i,sourceControlX:l,sourceControlY:d,targetControlX:c,targetControlY:h}){const m=e*.125+l*.375+c*.375+s*.125,f=n*.125+d*.375+h*.375+i*.125,x=Math.abs(m-e),p=Math.abs(f-n);return[m,f,x,p]}function Sd(e,n){return e>=0?.5*e:n*25*Math.sqrt(-e)}function yv({pos:e,x1:n,y1:s,x2:i,y2:l,c:d}){switch(e){case mt.Left:return[n-Sd(n-i,d),s];case mt.Right:return[n+Sd(i-n,d),s];case mt.Top:return[n,s-Sd(s-l,d)];case mt.Bottom:return[n,s+Sd(l-s,d)]}}function Yw({sourceX:e,sourceY:n,sourcePosition:s=mt.Bottom,targetX:i,targetY:l,targetPosition:d=mt.Top,curvature:c=.25}){const[h,m]=yv({pos:s,x1:e,y1:n,x2:i,y2:l,c}),[f,x]=yv({pos:d,x1:i,y1:l,x2:e,y2:n,c}),[p,g,y,w]=Fw({sourceX:e,sourceY:n,targetX:i,targetY:l,sourceControlX:h,sourceControlY:m,targetControlX:f,targetControlY:x});return[`M${e},${n} C${h},${m} ${f},${x} ${i},${l}`,p,g,y,w]}function Gw({sourceX:e,sourceY:n,targetX:s,targetY:i}){const l=Math.abs(s-e)/2,d=s<e?s+l:s-l,c=Math.abs(i-n)/2,h=i<n?i+c:i-c;return[d,h,l,c]}function FR({sourceNode:e,targetNode:n,selected:s=!1,zIndex:i=0,elevateOnSelect:l=!1,zIndexMode:d="basic"}){if(d==="manual")return i;const c=l&&s?i+1e3:i,h=Math.max(e.parentId||l&&e.selected?e.internals.z:0,n.parentId||l&&n.selected?n.internals.z:0);return c+h}function YR({sourceNode:e,targetNode:n,width:s,height:i,transform:l}){const d=bu(eu(e),eu(n));d.x===d.x2&&(d.x2+=1),d.y===d.y2&&(d.y2+=1);const c={x:-l[0]/l[2],y:-l[1]/l[2],width:s/l[2],height:i/l[2]};return Wo(c,yu(d))>0}const GR=({source:e,sourceHandle:n,target:s,targetHandle:i})=>`xy-edge__${e}${n||""}-${s}${i||""}`,XR=(e,n)=>n.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)),KR=(e,n,s={})=>{if(!e.source||!e.target)return n;const i=s.getEdgeId||GR;let l;return Lw(e)?l={...e}:l={...e,id:i(e)},XR(l,n)?n:(l.sourceHandle===null&&delete l.sourceHandle,l.targetHandle===null&&delete l.targetHandle,n.concat(l))};function Xw({sourceX:e,sourceY:n,targetX:s,targetY:i}){const[l,d,c,h]=Gw({sourceX:e,sourceY:n,targetX:s,targetY:i});return[`M ${e},${n}L ${s},${i}`,l,d,c,h]}const vv={[mt.Left]:{x:-1,y:0},[mt.Right]:{x:1,y:0},[mt.Top]:{x:0,y:-1},[mt.Bottom]:{x:0,y:1}},WR=({source:e,sourcePosition:n=mt.Bottom,target:s})=>n===mt.Left||n===mt.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},jv=(e,n)=>Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2));function QR({source:e,sourcePosition:n=mt.Bottom,target:s,targetPosition:i=mt.Top,center:l,offset:d,stepPosition:c}){const h=vv[n],m=vv[i],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},p=WR({source:f,sourcePosition:n,target:x}),g=p.x!==0?"x":"y",y=p[g];let w=[],N,T;const C={x:0,y:0},_={x:0,y:0},[,,k,M]=Gw({sourceX:e.x,sourceY:e.y,targetX:s.x,targetY:s.y});if(h[g]*m[g]===-1){g==="x"?(N=l.x??f.x+(x.x-f.x)*c,T=l.y??(f.y+x.y)/2):(N=l.x??(f.x+x.x)/2,T=l.y??f.y+(x.y-f.y)*c);const A=[{x:N,y:f.y},{x:N,y:x.y}],G=[{x:f.x,y:T},{x:x.x,y:T}];h[g]===y?w=g==="x"?A:G:w=g==="x"?G:A}else{const A=[{x:f.x,y:x.y}],G=[{x:x.x,y:f.y}];if(g==="x"?w=h.x===y?G:A:w=h.y===y?A:G,n===i){const U=Math.abs(e[g]-s[g]);if(U<=d){const z=Math.min(d-1,d-U);h[g]===y?C[g]=(f[g]>e[g]?-1:1)*z:_[g]=(x[g]>s[g]?-1:1)*z}}if(n!==i){const U=g==="x"?"y":"x",z=h[g]===m[U],E=f[U]>x[U],L=f[U]<x[U];(h[g]===1&&(!z&&E||z&&L)||h[g]!==1&&(!z&&L||z&&E))&&(w=g==="x"?A:G)}const X={x:f.x+C.x,y:f.y+C.y},K={x:x.x+_.x,y:x.y+_.y},$=Math.max(Math.abs(X.x-w[0].x),Math.abs(K.x-w[0].x)),q=Math.max(Math.abs(X.y-w[0].y),Math.abs(K.y-w[0].y));$>=q?(N=(X.x+K.x)/2,T=w[0].y):(N=w[0].x,T=(X.y+K.y)/2)}return[[e,{x:f.x+C.x,y:f.y+C.y},...w,{x:x.x+_.x,y:x.y+_.y},s],N,T,k,M]}function ZR(e,n,s,i){const l=Math.min(jv(e,n)/2,jv(n,s)/2,i),{x:d,y:c}=n;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+l*f},${c}Q ${d},${c} ${d},${c+l*x}`}const h=e.x<s.x?1:-1,m=e.y<s.y?-1:1;return`L ${d},${c+l*m}Q ${d},${c} ${d+l*h},${c}`}function Wm({sourceX:e,sourceY:n,sourcePosition:s=mt.Bottom,targetX:i,targetY:l,targetPosition:d=mt.Top,borderRadius:c=5,centerX:h,centerY:m,offset:f=20,stepPosition:x=.5}){const[p,g,y,w,N]=QR({source:{x:e,y:n},sourcePosition:s,target:{x:i,y:l},targetPosition:d,center:{x:h,y:m},offset:f,stepPosition:x});return[p.reduce((C,_,k)=>{let M="";return k>0&&k<p.length-1?M=ZR(p[k-1],_,p[k+1],c):M=`${k===0?"M":"L"}${_.x} ${_.y}`,C+=M,C},""),g,y,w,N]}function wv(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function JR(e){const{sourceNode:n,targetNode:s}=e;if(!wv(n)||!wv(s))return null;const i=n.internals.handleBounds||Nv(n.handles),l=s.internals.handleBounds||Nv(s.handles),d=kv(i?.source??[],e.sourceHandle),c=kv(e.connectionMode===wl.Strict?l?.target??[]:(l?.target??[]).concat(l?.source??[]),e.targetHandle);if(!d||!c)return e.onError?.("008",Ls.error008(d?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const h=d?.position||mt.Bottom,m=c?.position||mt.Top,f=Ei(n,d,h),x=Ei(s,c,m);return{sourceX:f.x,sourceY:f.y,targetX:x.x,targetY:x.y,sourcePosition:h,targetPosition:m}}function Nv(e){if(!e)return null;const n=[],s=[];for(const i of e)i.width=i.width??1,i.height=i.height??1,i.type==="source"?n.push(i):i.type==="target"&&s.push(i);return{source:n,target:s}}function Ei(e,n,s=mt.Left,i=!1){const l=(n?.x??0)+e.internals.positionAbsolute.x,d=(n?.y??0)+e.internals.positionAbsolute.y,{width:c,height:h}=n??fa(e);if(i)return{x:l+c/2,y:d+h/2};switch(n?.position??s){case mt.Top:return{x:l+c/2,y:d};case mt.Right:return{x:l+c,y:d+h/2};case mt.Bottom:return{x:l+c/2,y:d+h};case mt.Left:return{x:l,y:d+h/2}}}function kv(e,n){return e&&(n?e.find(s=>s.id===n):e[0])||null}function Qm(e,n){return e?typeof e=="string"?e:`${n?`${n}__`:""}${Object.keys(e).sort().map(i=>`${i}=${e[i]}`).join("&")}`:""}function eO(e,{id:n,defaultColor:s,defaultMarkerStart:i,defaultMarkerEnd:l}){const d=new Set;return e.reduce((c,h)=>([h.markerStart||i,h.markerEnd||l].forEach(m=>{if(m&&typeof m=="object"){const f=Qm(m,n);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 Kw=1e3,tO=10,Bx={nodeOrigin:[0,0],nodeExtent:Xo,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},nO={...Bx,checkEquality:!0};function Hx(e,n){const s={...e};for(const i in n)n[i]!==void 0&&(s[i]=n[i]);return s}function rO(e,n,s){const i=Hx(Bx,s);for(const l of e.values())if(l.parentId)qx(l,e,n,i);else{const d=ic(l,i.nodeOrigin),c=Cl(l.extent)?l.extent:i.nodeExtent,h=Ci(d,c,fa(l));l.internals.positionAbsolute=h}}function sO(e,n){if(!e.handles)return e.measured?n?.internals.handleBounds:void 0;const s=[],i=[];for(const l of e.handles){const d={id:l.id,width:l.width??1,height:l.height??1,nodeId:e.id,x:l.x,y:l.y,position:l.position,type:l.type};l.type==="source"?s.push(d):l.type==="target"&&i.push(d)}return{source:s,target:i}}function Px(e){return e==="manual"}function Zm(e,n,s,i={}){const l=Hx(nO,i),d={i:0},c=new Map(n),h=l?.elevateNodesOnSelect&&!Px(l.zIndexMode)?Kw:0;let m=e.length>0;n.clear(),s.clear();for(const f of e){let x=c.get(f.id);if(l.checkEquality&&f===x?.internals.userNode)n.set(f.id,x);else{const p=ic(f,l.nodeOrigin),g=Cl(f.extent)?f.extent:l.nodeExtent,y=Ci(p,g,fa(f));x={...l.defaults,...f,measured:{width:f.measured?.width,height:f.measured?.height},internals:{positionAbsolute:y,handleBounds:sO(f,x),z:Ww(f,h,l.zIndexMode),userNode:f}},n.set(f.id,x)}(x.measured===void 0||x.measured.width===void 0||x.measured.height===void 0)&&!x.hidden&&(m=!1),f.parentId&&qx(x,n,s,i,d)}return m}function aO(e,n){if(!e.parentId)return;const s=n.get(e.parentId);s?s.set(e.id,e):n.set(e.parentId,new Map([[e.id,e]]))}function qx(e,n,s,i,l){const{elevateNodesOnSelect:d,nodeOrigin:c,nodeExtent:h,zIndexMode:m}=Hx(Bx,i),f=e.parentId,x=n.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}aO(e,s),l&&!x.parentId&&x.internals.rootParentIndex===void 0&&m==="auto"&&(x.internals.rootParentIndex=++l.i,x.internals.z=x.internals.z+l.i*tO),l&&x.internals.rootParentIndex!==void 0&&(l.i=x.internals.rootParentIndex);const p=d&&!Px(m)?Kw:0,{x:g,y,z:w}=iO(e,x,c,h,p,m),{positionAbsolute:N}=e.internals,T=g!==N.x||y!==N.y;(T||w!==e.internals.z)&&n.set(e.id,{...e,internals:{...e.internals,positionAbsolute:T?{x:g,y}:N,z:w}})}function Ww(e,n,s){const i=bs(e.zIndex)?e.zIndex:0;return Px(s)?i:i+(e.selected?n:0)}function iO(e,n,s,i,l,d){const{x:c,y:h}=n.internals.positionAbsolute,m=fa(e),f=ic(e,s),x=Cl(e.extent)?Ci(f,e.extent,m):f;let p=Ci({x:c+x.x,y:h+x.y},i,m);e.extent==="parent"&&(p=zw(p,m,n));const g=Ww(e,l,d),y=n.internals.z??0;return{x:p.x,y:p.y,z:y>=g?y+1:g}}function Ux(e,n,s,i=[0,0]){const l=[],d=new Map;for(const c of e){const h=n.get(c.parentId);if(!h)continue;const m=d.get(c.parentId)?.expandedRect??Sl(h),f=Bw(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=fa(h),p=h.origin??i,g=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)),T=(w-x.width)*p[0],C=(N-x.height)*p[1];(g>0||y>0||T||C)&&(l.push({id:m,type:"position",position:{x:h.position.x-g+T,y:h.position.y-y+C}}),s.get(m)?.forEach(_=>{e.some(k=>k.id===_.id)||l.push({id:_.id,type:"position",position:{x:_.position.x+g,y:_.position.y+y}})})),(x.width<c.width||x.height<c.height||g||y)&&l.push({id:m,type:"dimensions",setAttributes:!0,dimensions:{width:w+(g?p[0]*g-T:0),height:N+(y?p[1]*y-C:0)}})}),l}function lO(e,n,s,i,l,d,c){const h=i?.querySelector(".xyflow__viewport");let m=!1;if(!h)return{changes:[],updatedInternals:m};const f=[],x=window.getComputedStyle(h),{m22:p}=new window.DOMMatrixReadOnly(x.transform),g=[];for(const y of e.values()){const w=n.get(y.id);if(!w)continue;if(w.hidden){n.set(w.id,{...w,internals:{...w.internals,handleBounds:void 0}}),m=!0;continue}const N=$x(y.nodeElement),T=w.measured.width!==N.width||w.measured.height!==N.height;if(!!(N.width&&N.height&&(T||!w.internals.handleBounds||y.force))){const _=y.nodeElement.getBoundingClientRect(),k=Cl(w.extent)?w.extent:d;let{positionAbsolute:M}=w.internals;w.parentId&&w.extent==="parent"?M=zw(M,N,n.get(w.parentId)):k&&(M=Ci(M,k,N));const D={...w,measured:N,internals:{...w.internals,positionAbsolute:M,handleBounds:{source:bv("source",y.nodeElement,_,p,w.id),target:bv("target",y.nodeElement,_,p,w.id)}}};n.set(w.id,D),w.parentId&&qx(D,n,s,{nodeOrigin:l,zIndexMode:c}),m=!0,T&&(f.push({id:w.id,type:"dimensions",dimensions:N}),w.expandParent&&w.parentId&&g.push({id:w.id,parentId:w.parentId,rect:Sl(D,l)}))}}if(g.length>0){const y=Ux(g,n,s,l);f.push(...y)}return{changes:f,updatedInternals:m}}async function oO({delta:e,panZoom:n,transform:s,translateExtent:i,width:l,height:d}){if(!n||!e.x&&!e.y)return Promise.resolve(!1);const c=await n.setViewportConstrained({x:s[0]+e.x,y:s[1]+e.y,zoom:s[2]},[[0,0],[l,d]],i),h=!!c&&(c.x!==s[0]||c.y!==s[1]||c.k!==s[2]);return Promise.resolve(h)}function Sv(e,n,s,i,l,d){let c=l;const h=i.get(c)||new Map;i.set(c,h.set(s,n)),c=`${l}-${e}`;const m=i.get(c)||new Map;if(i.set(c,m.set(s,n)),d){c=`${l}-${e}-${d}`;const f=i.get(c)||new Map;i.set(c,f.set(s,n))}}function Qw(e,n,s){e.clear(),n.clear();for(const i of s){const{source:l,target:d,sourceHandle:c=null,targetHandle:h=null}=i,m={edgeId:i.id,source:l,target:d,sourceHandle:c,targetHandle:h},f=`${l}-${c}--${d}-${h}`,x=`${d}-${h}--${l}-${c}`;Sv("source",m,x,e,l,c),Sv("target",m,f,e,d,h),n.set(i.id,i)}}function Zw(e,n){if(!e.parentId)return!1;const s=n.get(e.parentId);return s?s.selected?!0:Zw(s,n):!1}function Cv(e,n,s){let i=e;do{if(i?.matches?.(n))return!0;if(i===s)return!1;i=i?.parentElement}while(i);return!1}function cO(e,n,s,i){const l=new Map;for(const[d,c]of e)if((c.selected||c.id===i)&&(!c.parentId||!Zw(c,e))&&(c.draggable||n&&typeof c.draggable>"u")){const h=e.get(d);h&&l.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 l}function sm({nodeId:e,dragItems:n,nodeLookup:s,dragging:i=!0}){const l=[];for(const[c,h]of n){const m=s.get(c)?.internals.userNode;m&&l.push({...m,position:h.position,dragging:i})}if(!e)return[l[0],l];const d=s.get(e)?.internals.userNode;return[d?{...d,position:n.get(e)?.position||d.position,dragging:i}:l[0],l]}function dO({dragItems:e,snapGrid:n,x:s,y:i}){const l=e.values().next().value;if(!l)return null;const d={x:s-l.distance.x,y:i-l.distance.y},c=oc(d,n);return{x:c.x-d.x,y:c.y-d.y}}function uO({onNodeMouseDown:e,getStoreItems:n,onDragStart:s,onDrag:i,onDragStop:l}){let d={x:null,y:null},c=0,h=new Map,m=!1,f={x:0,y:0},x=null,p=!1,g=null,y=!1,w=!1,N=null;function T({noDragClassName:_,handleSelector:k,domNode:M,isSelectable:D,nodeId:A,nodeClickDistance:G=0}){g=Zr(M);function X({x:U,y:z}){const{nodeLookup:E,nodeExtent:L,snapGrid:R,snapToGrid:F,nodeOrigin:Y,onNodeDrag:Z,onSelectionDrag:B,onError:O,updateNodePositions:V}=n();d={x:U,y:z};let I=!1;const S=h.size>1,H=S&&L?Km(lc(h)):null,W=S&&F?dO({dragItems:h,snapGrid:R,x:U,y:z}):null;for(const[ee,te]of h){if(!E.has(ee))continue;let ae={x:U-te.distance.x,y:z-te.distance.y};F&&(ae=W?{x:Math.round(ae.x+W.x),y:Math.round(ae.y+W.y)}:oc(ae,R));let he=null;if(S&&L&&!te.extent&&H){const{positionAbsolute:je}=te.internals,ke=je.x-H.x+L[0][0],Se=je.x+te.measured.width-H.x2+L[1][0],Le=je.y-H.y+L[0][1],nt=je.y+te.measured.height-H.y2+L[1][1];he=[[ke,Le],[Se,nt]]}const{position:Ne,positionAbsolute:De}=Iw({nodeId:ee,nextPosition:ae,nodeLookup:E,nodeExtent:he||L,nodeOrigin:Y,onError:O});I=I||te.position.x!==Ne.x||te.position.y!==Ne.y,te.position=Ne,te.internals.positionAbsolute=De}if(w=w||I,!!I&&(V(h,!0),N&&(i||Z||!A&&B))){const[ee,te]=sm({nodeId:A,dragItems:h,nodeLookup:E});i?.(N,h,ee,te),Z?.(N,ee,te),A||B?.(N,te)}}async function K(){if(!x)return;const{transform:U,panBy:z,autoPanSpeed:E,autoPanOnNodeDrag:L}=n();if(!L){m=!1,cancelAnimationFrame(c);return}const[R,F]=$w(f,x,E);(R!==0||F!==0)&&(d.x=(d.x??0)-R/U[2],d.y=(d.y??0)-F/U[2],await z({x:R,y:F})&&X(d)),c=requestAnimationFrame(K)}function $(U){const{nodeLookup:z,multiSelectionActive:E,nodesDraggable:L,transform:R,snapGrid:F,snapToGrid:Y,selectNodesOnDrag:Z,onNodeDragStart:B,onSelectionDragStart:O,unselectNodesAndEdges:V}=n();p=!0,(!Z||!D)&&!E&&A&&(z.get(A)?.selected||V()),D&&Z&&A&&e?.(A);const I=zo(U.sourceEvent,{transform:R,snapGrid:F,snapToGrid:Y,containerBounds:x});if(d=I,h=cO(z,L,I,A),h.size>0&&(s||B||!A&&O)){const[S,H]=sm({nodeId:A,dragItems:h,nodeLookup:z});s?.(U.sourceEvent,h,S,H),B?.(U.sourceEvent,S,H),A||O?.(U.sourceEvent,H)}}const q=xw().clickDistance(G).on("start",U=>{const{domNode:z,nodeDragThreshold:E,transform:L,snapGrid:R,snapToGrid:F}=n();x=z?.getBoundingClientRect()||null,y=!1,w=!1,N=U.sourceEvent,E===0&&$(U),d=zo(U.sourceEvent,{transform:L,snapGrid:R,snapToGrid:F,containerBounds:x}),f=ys(U.sourceEvent,x)}).on("drag",U=>{const{autoPanOnNodeDrag:z,transform:E,snapGrid:L,snapToGrid:R,nodeDragThreshold:F,nodeLookup:Y}=n(),Z=zo(U.sourceEvent,{transform:E,snapGrid:L,snapToGrid:R,containerBounds:x});if(N=U.sourceEvent,(U.sourceEvent.type==="touchmove"&&U.sourceEvent.touches.length>1||A&&!Y.has(A))&&(y=!0),!y){if(!m&&z&&p&&(m=!0,K()),!p){const B=ys(U.sourceEvent,x),O=B.x-f.x,V=B.y-f.y;Math.sqrt(O*O+V*V)>F&&$(U)}(d.x!==Z.xSnapped||d.y!==Z.ySnapped)&&h&&p&&(f=ys(U.sourceEvent,x),X(Z))}}).on("end",U=>{if(!(!p||y)&&(m=!1,p=!1,cancelAnimationFrame(c),h.size>0)){const{nodeLookup:z,updateNodePositions:E,onNodeDragStop:L,onSelectionDragStop:R}=n();if(w&&(E(h,!1),w=!1),l||L||!A&&R){const[F,Y]=sm({nodeId:A,dragItems:h,nodeLookup:z,dragging:!1});l?.(U.sourceEvent,h,F,Y),L?.(U.sourceEvent,F,Y),A||R?.(U.sourceEvent,Y)}}}).filter(U=>{const z=U.target;return!U.button&&(!_||!Cv(z,`.${_}`,M))&&(!k||Cv(z,k,M))});g.call(q)}function C(){g?.on(".drag",null)}return{update:T,destroy:C}}function fO(e,n,s){const i=[],l={x:e.x-s,y:e.y-s,width:s*2,height:s*2};for(const d of n.values())Wo(l,Sl(d))>0&&i.push(d);return i}const hO=250;function mO(e,n,s,i){let l=[],d=1/0;const c=fO(e,s,n+hO);for(const h of c){const m=[...h.internals.handleBounds?.source??[],...h.internals.handleBounds?.target??[]];for(const f of m){if(i.nodeId===f.nodeId&&i.type===f.type&&i.id===f.id)continue;const{x,y:p}=Ei(h,f,f.position,!0),g=Math.sqrt(Math.pow(x-e.x,2)+Math.pow(p-e.y,2));g>n||(g<d?(l=[{...f,x,y:p}],d=g):g===d&&l.push({...f,x,y:p}))}}if(!l.length)return null;if(l.length>1){const h=i.type==="source"?"target":"source";return l.find(m=>m.type===h)??l[0]}return l[0]}function Jw(e,n,s,i,l,d=!1){const c=i.get(e);if(!c)return null;const h=l==="strict"?c.internals.handleBounds?.[n]:[...c.internals.handleBounds?.source??[],...c.internals.handleBounds?.target??[]],m=(s?h?.find(f=>f.id===s):h?.[0])??null;return m&&d?{...m,...Ei(c,m,m.position,!0)}:m}function eN(e,n){return e||(n?.classList.contains("target")?"target":n?.classList.contains("source")?"source":null)}function xO(e,n){let s=null;return n?s=!0:e&&!n&&(s=!1),s}const tN=()=>!0;function pO(e,{connectionMode:n,connectionRadius:s,handleId:i,nodeId:l,edgeUpdaterType:d,isTarget:c,domNode:h,nodeLookup:m,lib:f,autoPanOnConnect:x,flowId:p,panBy:g,cancelConnection:y,onConnectStart:w,onConnect:N,onConnectEnd:T,isValidConnection:C=tN,onReconnectEnd:_,updateConnection:k,getTransform:M,getFromHandle:D,autoPanSpeed:A,dragThreshold:G=1,handleDomNode:X}){const K=qw(e.target);let $=0,q;const{x:U,y:z}=ys(e),E=eN(d,X),L=h?.getBoundingClientRect();let R=!1;if(!L||!E)return;const F=Jw(l,E,i,m,n);if(!F)return;let Y=ys(e,L),Z=!1,B=null,O=!1,V=null;function I(){if(!x||!L)return;const[Ne,De]=$w(Y,L,A);g({x:Ne,y:De}),$=requestAnimationFrame(I)}const S={...F,nodeId:l,type:E,position:F.position},H=m.get(l);let ee={inProgress:!0,isValid:null,from:Ei(H,S,mt.Left,!0),fromHandle:S,fromPosition:S.position,fromNode:H,to:Y,toHandle:null,toPosition:mv[S.position],toNode:null,pointer:Y};function te(){R=!0,k(ee),w?.(e,{nodeId:l,handleId:i,handleType:E})}G===0&&te();function ae(Ne){if(!R){const{x:nt,y:rt}=ys(Ne),yt=nt-U,Rt=rt-z;if(!(yt*yt+Rt*Rt>G*G))return;te()}if(!D()||!S){he(Ne);return}const De=M();Y=ys(Ne,L),q=mO(cc(Y,De,!1,[1,1]),s,m,S),Z||(I(),Z=!0);const je=nN(Ne,{handle:q,connectionMode:n,fromNodeId:l,fromHandleId:i,fromType:c?"target":"source",isValidConnection:C,doc:K,lib:f,flowId:p,nodeLookup:m});V=je.handleDomNode,B=je.connection,O=xO(!!q,je.isValid);const ke=m.get(l),Se=ke?Ei(ke,S,mt.Left,!0):ee.from,Le={...ee,from:Se,isValid:O,to:je.toHandle&&O?tu({x:je.toHandle.x,y:je.toHandle.y},De):Y,toHandle:je.toHandle,toPosition:O&&je.toHandle?je.toHandle.position:mv[S.position],toNode:je.toHandle?m.get(je.toHandle.nodeId):null,pointer:Y};k(Le),ee=Le}function he(Ne){if(!("touches"in Ne&&Ne.touches.length>0)){if(R){(q||V)&&B&&O&&N?.(B);const{inProgress:De,...je}=ee,ke={...je,toPosition:ee.toHandle?ee.toPosition:null};T?.(Ne,ke),d&&_?.(Ne,ke)}y(),cancelAnimationFrame($),Z=!1,O=!1,B=null,V=null,K.removeEventListener("mousemove",ae),K.removeEventListener("mouseup",he),K.removeEventListener("touchmove",ae),K.removeEventListener("touchend",he)}}K.addEventListener("mousemove",ae),K.addEventListener("mouseup",he),K.addEventListener("touchmove",ae),K.addEventListener("touchend",he)}function nN(e,{handle:n,connectionMode:s,fromNodeId:i,fromHandleId:l,fromType:d,doc:c,lib:h,flowId:m,isValidConnection:f=tN,nodeLookup:x}){const p=d==="target",g=n?c.querySelector(`.${h}-flow__handle[data-id="${m}-${n?.nodeId}-${n?.id}-${n?.type}"]`):null,{x:y,y:w}=ys(e),N=c.elementFromPoint(y,w),T=N?.classList.contains(`${h}-flow__handle`)?N:g,C={handleDomNode:T,isValid:!1,connection:null,toHandle:null};if(T){const _=eN(void 0,T),k=T.getAttribute("data-nodeid"),M=T.getAttribute("data-handleid"),D=T.classList.contains("connectable"),A=T.classList.contains("connectableend");if(!k||!_)return C;const G={source:p?k:i,sourceHandle:p?M:l,target:p?i:k,targetHandle:p?l:M};C.connection=G;const K=D&&A&&(s===wl.Strict?p&&_==="source"||!p&&_==="target":k!==i||M!==l);C.isValid=K&&f(G),C.toHandle=Jw(k,_,M,x,s,!0)}return C}const Jm={onPointerDown:pO,isValid:nN};function gO({domNode:e,panZoom:n,getTransform:s,getViewScale:i}){const l=Zr(e);function d({translateExtent:h,width:m,height:f,zoomStep:x=1,pannable:p=!0,zoomable:g=!0,inversePan:y=!1}){const w=k=>{if(k.sourceEvent.type!=="wheel"||!n)return;const M=s(),D=k.sourceEvent.ctrlKey&&Qo()?10:1,A=-k.sourceEvent.deltaY*(k.sourceEvent.deltaMode===1?.05:k.sourceEvent.deltaMode?1:.002)*x,G=M[2]*Math.pow(2,A*D);n.scaleTo(G)};let N=[0,0];const T=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])},C=k=>{const M=s();if(k.sourceEvent.type!=="mousemove"&&k.sourceEvent.type!=="touchmove"||!n)return;const D=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY],A=[D[0]-N[0],D[1]-N[1]];N=D;const G=i()*Math.max(M[2],Math.log(M[2]))*(y?-1:1),X={x:M[0]-A[0]*G,y:M[1]-A[1]*G},K=[[0,0],[m,f]];n.setViewportConstrained({x:X.x,y:X.y,zoom:M[2]},K,h)},_=Aw().on("start",T).on("zoom",p?C:null).on("zoom.wheel",g?w:null);l.call(_,{})}function c(){l.on("zoom",null)}return{update:d,destroy:c,pointer:ps}}const vu=e=>({x:e.x,y:e.y,zoom:e.k}),am=({x:e,y:n,zoom:s})=>gu.translate(e,n).scale(s),ml=(e,n)=>e.target.closest(`.${n}`),rN=(e,n)=>n===2&&Array.isArray(e)&&e.includes(2),bO=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,im=(e,n=0,s=bO,i=()=>{})=>{const l=typeof n=="number"&&n>0;return l||i(),l?e.transition().duration(n).ease(s).on("end",i):e},sN=e=>{const n=e.ctrlKey&&Qo()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*n};function yO({zoomPanValues:e,noWheelClassName:n,d3Selection:s,d3Zoom:i,panOnScrollMode:l,panOnScrollSpeed:d,zoomOnPinch:c,onPanZoomStart:h,onPanZoom:m,onPanZoomEnd:f}){return x=>{if(ml(x,n))return x.ctrlKey&&x.preventDefault(),!1;x.preventDefault(),x.stopImmediatePropagation();const p=s.property("__zoom").k||1;if(x.ctrlKey&&c){const T=ps(x),C=sN(x),_=p*Math.pow(2,C);i.scaleTo(s,_,T,x);return}const g=x.deltaMode===1?20:1;let y=l===ji.Vertical?0:x.deltaX*g,w=l===ji.Horizontal?0:x.deltaY*g;!Qo()&&x.shiftKey&&l!==ji.Vertical&&(y=x.deltaY*g,w=0),i.translateBy(s,-(y/p)*d,-(w/p)*d,{internal:!0});const N=vu(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 vO({noWheelClassName:e,preventScrolling:n,d3ZoomHandler:s}){return function(i,l){const d=i.type==="wheel",c=!n&&d&&!i.ctrlKey,h=ml(i,e);if(i.ctrlKey&&d&&h&&i.preventDefault(),c||h)return null;i.preventDefault(),s.call(this,i,l)}}function jO({zoomPanValues:e,onDraggingChange:n,onPanZoomStart:s}){return i=>{if(i.sourceEvent?.internal)return;const l=vu(i.transform);e.mouseButton=i.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=l,i.sourceEvent?.type==="mousedown"&&n(!0),s&&s?.(i.sourceEvent,l)}}function wO({zoomPanValues:e,panOnDrag:n,onPaneContextMenu:s,onTransformChange:i,onPanZoom:l}){return d=>{e.usedRightMouseButton=!!(s&&rN(n,e.mouseButton??0)),d.sourceEvent?.sync||i([d.transform.x,d.transform.y,d.transform.k]),l&&!d.sourceEvent?.internal&&l?.(d.sourceEvent,vu(d.transform))}}function NO({zoomPanValues:e,panOnDrag:n,panOnScroll:s,onDraggingChange:i,onPanZoomEnd:l,onPaneContextMenu:d}){return c=>{if(!c.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,d&&rN(n,e.mouseButton??0)&&!e.usedRightMouseButton&&c.sourceEvent&&d(c.sourceEvent),e.usedRightMouseButton=!1,i(!1),l)){const h=vu(c.transform);e.prevViewport=h,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{l?.(c.sourceEvent,h)},s?150:0)}}}function kO({zoomActivationKeyPressed:e,zoomOnScroll:n,zoomOnPinch:s,panOnDrag:i,panOnScroll:l,zoomOnDoubleClick:d,userSelectionActive:c,noWheelClassName:h,noPanClassName:m,lib:f,connectionInProgress:x}){return p=>{const g=e||n,y=s&&p.ctrlKey,w=p.type==="wheel";if(p.button===1&&p.type==="mousedown"&&(ml(p,`${f}-flow__node`)||ml(p,`${f}-flow__edge`)))return!0;if(!i&&!g&&!l&&!d&&!s||c||x&&!w||ml(p,h)&&w||ml(p,m)&&(!w||l&&w&&!e)||!s&&p.ctrlKey&&w)return!1;if(!s&&p.type==="touchstart"&&p.touches?.length>1)return p.preventDefault(),!1;if(!g&&!l&&!y&&w||!i&&(p.type==="mousedown"||p.type==="touchstart")||Array.isArray(i)&&!i.includes(p.button)&&p.type==="mousedown")return!1;const N=Array.isArray(i)&&i.includes(p.button)||!p.button||p.button<=1;return(!p.ctrlKey||w)&&N}}function SO({domNode:e,minZoom:n,maxZoom:s,translateExtent:i,viewport:l,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(),p=Aw().scaleExtent([n,s]).translateExtent(i),g=Zr(e).call(p);_({x:l.x,y:l.y,zoom:kl(l.zoom,n,s)},[[0,0],[x.width,x.height]],i);const y=g.on("wheel.zoom"),w=g.on("dblclick.zoom");p.wheelDelta(sN);function N(q,U){return g?new Promise(z=>{p?.interpolate(U?.interpolate==="linear"?Io:Ld).transform(im(g,U?.duration,U?.ease,()=>z(!0)),q)}):Promise.resolve(!1)}function T({noWheelClassName:q,noPanClassName:U,onPaneContextMenu:z,userSelectionActive:E,panOnScroll:L,panOnDrag:R,panOnScrollMode:F,panOnScrollSpeed:Y,preventScrolling:Z,zoomOnPinch:B,zoomOnScroll:O,zoomOnDoubleClick:V,zoomActivationKeyPressed:I,lib:S,onTransformChange:H,connectionInProgress:W,paneClickDistance:ee,selectionOnDrag:te}){E&&!f.isZoomingOrPanning&&C();const ae=L&&!I&&!E;p.clickDistance(te?1/0:!bs(ee)||ee<0?0:ee);const he=ae?yO({zoomPanValues:f,noWheelClassName:q,d3Selection:g,d3Zoom:p,panOnScrollMode:F,panOnScrollSpeed:Y,zoomOnPinch:B,onPanZoomStart:c,onPanZoom:d,onPanZoomEnd:h}):vO({noWheelClassName:q,preventScrolling:Z,d3ZoomHandler:y});if(g.on("wheel.zoom",he,{passive:!1}),!E){const De=jO({zoomPanValues:f,onDraggingChange:m,onPanZoomStart:c});p.on("start",De);const je=wO({zoomPanValues:f,panOnDrag:R,onPaneContextMenu:!!z,onPanZoom:d,onTransformChange:H});p.on("zoom",je);const ke=NO({zoomPanValues:f,panOnDrag:R,panOnScroll:L,onPaneContextMenu:z,onPanZoomEnd:h,onDraggingChange:m});p.on("end",ke)}const Ne=kO({zoomActivationKeyPressed:I,panOnDrag:R,zoomOnScroll:O,panOnScroll:L,zoomOnDoubleClick:V,zoomOnPinch:B,userSelectionActive:E,noPanClassName:U,noWheelClassName:q,lib:S,connectionInProgress:W});p.filter(Ne),V?g.on("dblclick.zoom",w):g.on("dblclick.zoom",null)}function C(){p.on("zoom",null)}async function _(q,U,z){const E=am(q),L=p?.constrain()(E,U,z);return L&&await N(L),new Promise(R=>R(L))}async function k(q,U){const z=am(q);return await N(z,U),new Promise(E=>E(z))}function M(q){if(g){const U=am(q),z=g.property("__zoom");(z.k!==q.zoom||z.x!==q.x||z.y!==q.y)&&p?.transform(g,U,null,{sync:!0})}}function D(){const q=g?_w(g.node()):{x:0,y:0,k:1};return{x:q.x,y:q.y,zoom:q.k}}function A(q,U){return g?new Promise(z=>{p?.interpolate(U?.interpolate==="linear"?Io:Ld).scaleTo(im(g,U?.duration,U?.ease,()=>z(!0)),q)}):Promise.resolve(!1)}function G(q,U){return g?new Promise(z=>{p?.interpolate(U?.interpolate==="linear"?Io:Ld).scaleBy(im(g,U?.duration,U?.ease,()=>z(!0)),q)}):Promise.resolve(!1)}function X(q){p?.scaleExtent(q)}function K(q){p?.translateExtent(q)}function $(q){const U=!bs(q)||q<0?0:q;p?.clickDistance(U)}return{update:T,destroy:C,setViewport:k,setViewportConstrained:_,getViewport:D,scaleTo:A,scaleBy:G,setScaleExtent:X,setTranslateExtent:K,syncViewport:M,setClickDistance:$}}var El;(function(e){e.Line="line",e.Handle="handle"})(El||(El={}));function CO({width:e,prevWidth:n,height:s,prevHeight:i,affectsX:l,affectsY:d}){const c=e-n,h=s-i,m=[c>0?1:c<0?-1:0,h>0?1:h<0?-1:0];return c&&l&&(m[0]=m[0]*-1),h&&d&&(m[1]=m[1]*-1),m}function Ev(e){const n=e.includes("right")||e.includes("left"),s=e.includes("bottom")||e.includes("top"),i=e.includes("left"),l=e.includes("top");return{isHorizontal:n,isVertical:s,affectsX:i,affectsY:l}}function qa(e,n){return Math.max(0,n-e)}function Ua(e,n){return Math.max(0,e-n)}function Cd(e,n,s){return Math.max(0,n-e,e-s)}function Tv(e,n){return e?!n:n}function EO(e,n,s,i,l,d,c,h){let{affectsX:m,affectsY:f}=n;const{isHorizontal:x,isVertical:p}=n,g=x&&p,{xSnapped:y,ySnapped:w}=s,{minWidth:N,maxWidth:T,minHeight:C,maxHeight:_}=i,{x:k,y:M,width:D,height:A,aspectRatio:G}=e;let X=Math.floor(x?y-e.pointerX:0),K=Math.floor(p?w-e.pointerY:0);const $=D+(m?-X:X),q=A+(f?-K:K),U=-d[0]*D,z=-d[1]*A;let E=Cd($,N,T),L=Cd(q,C,_);if(c){let Y=0,Z=0;m&&X<0?Y=qa(k+X+U,c[0][0]):!m&&X>0&&(Y=Ua(k+$+U,c[1][0])),f&&K<0?Z=qa(M+K+z,c[0][1]):!f&&K>0&&(Z=Ua(M+q+z,c[1][1])),E=Math.max(E,Y),L=Math.max(L,Z)}if(h){let Y=0,Z=0;m&&X>0?Y=Ua(k+X,h[0][0]):!m&&X<0&&(Y=qa(k+$,h[1][0])),f&&K>0?Z=Ua(M+K,h[0][1]):!f&&K<0&&(Z=qa(M+q,h[1][1])),E=Math.max(E,Y),L=Math.max(L,Z)}if(l){if(x){const Y=Cd($/G,C,_)*G;if(E=Math.max(E,Y),c){let Z=0;!m&&!f||m&&!f&&g?Z=Ua(M+z+$/G,c[1][1])*G:Z=qa(M+z+(m?X:-X)/G,c[0][1])*G,E=Math.max(E,Z)}if(h){let Z=0;!m&&!f||m&&!f&&g?Z=qa(M+$/G,h[1][1])*G:Z=Ua(M+(m?X:-X)/G,h[0][1])*G,E=Math.max(E,Z)}}if(p){const Y=Cd(q*G,N,T)/G;if(L=Math.max(L,Y),c){let Z=0;!m&&!f||f&&!m&&g?Z=Ua(k+q*G+U,c[1][0])/G:Z=qa(k+(f?K:-K)*G+U,c[0][0])/G,L=Math.max(L,Z)}if(h){let Z=0;!m&&!f||f&&!m&&g?Z=qa(k+q*G,h[1][0])/G:Z=Ua(k+(f?K:-K)*G,h[0][0])/G,L=Math.max(L,Z)}}}K=K+(K<0?L:-L),X=X+(X<0?E:-E),l&&(g?$>q*G?K=(Tv(m,f)?-X:X)/G:X=(Tv(m,f)?-K:K)*G:x?(K=X/G,f=m):(X=K*G,m=f));const R=m?k+X:k,F=f?M+K:M;return{width:D+(m?-X:X),height:A+(f?-K:K),x:d[0]*X*(m?-1:1)+R,y:d[1]*K*(f?-1:1)+F}}const aN={width:0,height:0,x:0,y:0},TO={...aN,pointerX:0,pointerY:0,aspectRatio:1};function _O(e){return[[0,0],[e.measured.width,e.measured.height]]}function AO(e,n,s){const i=n.position.x+e.position.x,l=n.position.y+e.position.y,d=e.measured.width??0,c=e.measured.height??0,h=s[0]*d,m=s[1]*c;return[[i-h,l-m],[i+d-h,l+c-m]]}function MO({domNode:e,nodeId:n,getStoreItems:s,onChange:i,onEnd:l}){const d=Zr(e);let c={controlDirection:Ev("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:p,resizeDirection:g,onResizeStart:y,onResize:w,onResizeEnd:N,shouldResize:T}){let C={...aN},_={...TO};c={boundaries:x,resizeDirection:g,keepAspectRatio:p,controlDirection:Ev(f)};let k,M=null,D=[],A,G,X,K=!1;const $=xw().on("start",q=>{const{nodeLookup:U,transform:z,snapGrid:E,snapToGrid:L,nodeOrigin:R,paneDomNode:F}=s();if(k=U.get(n),!k)return;M=F?.getBoundingClientRect()??null;const{xSnapped:Y,ySnapped:Z}=zo(q.sourceEvent,{transform:z,snapGrid:E,snapToGrid:L,containerBounds:M});C={width:k.measured.width??0,height:k.measured.height??0,x:k.position.x??0,y:k.position.y??0},_={...C,pointerX:Y,pointerY:Z,aspectRatio:C.width/C.height},A=void 0,k.parentId&&(k.extent==="parent"||k.expandParent)&&(A=U.get(k.parentId),G=A&&k.extent==="parent"?_O(A):void 0),D=[],X=void 0;for(const[B,O]of U)if(O.parentId===n&&(D.push({id:B,position:{...O.position},extent:O.extent}),O.extent==="parent"||O.expandParent)){const V=AO(O,k,O.origin??R);X?X=[[Math.min(V[0][0],X[0][0]),Math.min(V[0][1],X[0][1])],[Math.max(V[1][0],X[1][0]),Math.max(V[1][1],X[1][1])]]:X=V}y?.(q,{...C})}).on("drag",q=>{const{transform:U,snapGrid:z,snapToGrid:E,nodeOrigin:L}=s(),R=zo(q.sourceEvent,{transform:U,snapGrid:z,snapToGrid:E,containerBounds:M}),F=[];if(!k)return;const{x:Y,y:Z,width:B,height:O}=C,V={},I=k.origin??L,{width:S,height:H,x:W,y:ee}=EO(_,c.controlDirection,R,c.boundaries,c.keepAspectRatio,I,G,X),te=S!==B,ae=H!==O,he=W!==Y&&te,Ne=ee!==Z&&ae;if(!he&&!Ne&&!te&&!ae)return;if((he||Ne||I[0]===1||I[1]===1)&&(V.x=he?W:C.x,V.y=Ne?ee:C.y,C.x=V.x,C.y=V.y,D.length>0)){const Se=W-Y,Le=ee-Z;for(const nt of D)nt.position={x:nt.position.x-Se+I[0]*(S-B),y:nt.position.y-Le+I[1]*(H-O)},F.push(nt)}if((te||ae)&&(V.width=te&&(!c.resizeDirection||c.resizeDirection==="horizontal")?S:C.width,V.height=ae&&(!c.resizeDirection||c.resizeDirection==="vertical")?H:C.height,C.width=V.width,C.height=V.height),A&&k.expandParent){const Se=I[0]*(V.width??0);V.x&&V.x<Se&&(C.x=Se,_.x=_.x-(V.x-Se));const Le=I[1]*(V.height??0);V.y&&V.y<Le&&(C.y=Le,_.y=_.y-(V.y-Le))}const De=CO({width:C.width,prevWidth:B,height:C.height,prevHeight:O,affectsX:c.controlDirection.affectsX,affectsY:c.controlDirection.affectsY}),je={...C,direction:De};T?.(q,je)!==!1&&(K=!0,w?.(q,je),i(V,F))}).on("end",q=>{K&&(N?.(q,{...C}),l?.({...C}),K=!1)});d.call($)}function m(){d.on(".drag",null)}return{update:h,destroy:m}}var lm={exports:{}},om={},cm={exports:{}},dm={};var _v;function RO(){if(_v)return dm;_v=1;var e=ec();function n(p,g){return p===g&&(p!==0||1/p===1/g)||p!==p&&g!==g}var s=typeof Object.is=="function"?Object.is:n,i=e.useState,l=e.useEffect,d=e.useLayoutEffect,c=e.useDebugValue;function h(p,g){var y=g(),w=i({inst:{value:y,getSnapshot:g}}),N=w[0].inst,T=w[1];return d(function(){N.value=y,N.getSnapshot=g,m(N)&&T({inst:N})},[p,y,g]),l(function(){return m(N)&&T({inst:N}),p(function(){m(N)&&T({inst:N})})},[p]),c(y),y}function m(p){var g=p.getSnapshot;p=p.value;try{var y=g();return!s(p,y)}catch{return!0}}function f(p,g){return g()}var x=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:h;return dm.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:x,dm}var Av;function OO(){return Av||(Av=1,cm.exports=RO()),cm.exports}var Mv;function DO(){if(Mv)return om;Mv=1;var e=ec(),n=OO();function s(f,x){return f===x&&(f!==0||1/f===1/x)||f!==f&&x!==x}var i=typeof Object.is=="function"?Object.is:s,l=n.useSyncExternalStore,d=e.useRef,c=e.useEffect,h=e.useMemo,m=e.useDebugValue;return om.useSyncExternalStoreWithSelector=function(f,x,p,g,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 C(A){if(!_){if(_=!0,k=A,A=g(A),y!==void 0&&N.hasValue){var G=N.value;if(y(G,A))return M=G}return M=A}if(G=M,i(k,A))return G;var X=g(A);return y!==void 0&&y(G,X)?(k=A,G):(k=A,M=X)}var _=!1,k,M,D=p===void 0?null:p;return[function(){return C(x())},D===null?void 0:function(){return C(D())}]},[x,p,g,y]);var T=l(f,w[0],w[1]);return c(function(){N.hasValue=!0,N.value=T},[T]),m(T),T},om}var Rv;function LO(){return Rv||(Rv=1,lm.exports=DO()),lm.exports}var IO=LO();const zO=su(IO),$O={},Ov=e=>{let n;const s=new Set,i=(x,p)=>{const g=typeof x=="function"?x(n):x;if(!Object.is(g,n)){const y=n;n=p??(typeof g!="object"||g===null)?g:Object.assign({},n,g),s.forEach(w=>w(n,y))}},l=()=>n,m={setState:i,getState:l,getInitialState:()=>f,subscribe:x=>(s.add(x),()=>s.delete(x)),destroy:()=>{($O?"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=n=e(i,l,m);return m},BO=e=>e?Ov(e):Ov,{useDebugValue:HO}=K2,{useSyncExternalStoreWithSelector:PO}=zO,qO=e=>e;function iN(e,n=qO,s){const i=PO(e.subscribe,e.getState,e.getServerState||e.getInitialState,n,s);return HO(i),i}const Dv=(e,n)=>{const s=BO(e),i=(l,d=n)=>iN(s,l,d);return Object.assign(i,s),i},UO=(e,n)=>e?Dv(e,n):Dv;function $n(e,n){if(Object.is(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(const[i,l]of e)if(!Object.is(l,n.get(i)))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(const i of e)if(!n.has(i))return!1;return!0}const s=Object.keys(e);if(s.length!==Object.keys(n).length)return!1;for(const i of s)if(!Object.prototype.hasOwnProperty.call(n,i)||!Object.is(e[i],n[i]))return!1;return!0}const ju=v.createContext(null),VO=ju.Provider,lN=Ls.error001();function tn(e,n){const s=v.useContext(ju);if(s===null)throw new Error(lN);return iN(s,e,n)}function Bn(){const e=v.useContext(ju);if(e===null)throw new Error(lN);return v.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Lv={display:"none"},FO={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},oN="react-flow__node-desc",cN="react-flow__edge-desc",YO="react-flow__aria-live",GO=e=>e.ariaLiveMessage,XO=e=>e.ariaLabelConfig;function KO({rfId:e}){const n=tn(GO);return t.jsx("div",{id:`${YO}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:FO,children:n})}function WO({rfId:e,disableKeyboardA11y:n}){const s=tn(XO);return t.jsxs(t.Fragment,{children:[t.jsx("div",{id:`${oN}-${e}`,style:Lv,children:n?s["node.a11yDescription.default"]:s["node.a11yDescription.keyboardDisabled"]}),t.jsx("div",{id:`${cN}-${e}`,style:Lv,children:s["edge.a11yDescription.default"]}),!n&&t.jsx(KO,{rfId:e})]})}const wu=v.forwardRef(({position:e="top-left",children:n,className:s,style:i,...l},d)=>{const c=`${e}`.split("-");return t.jsx("div",{className:er(["react-flow__panel",s,...c]),style:i,ref:d,...l,children:n})});wu.displayName="Panel";function QO({proOptions:e,position:n="bottom-right"}){return e?.hideAttribution?null:t.jsx(wu,{position:n,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:t.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const ZO=e=>{const n=[],s=[];for(const[,i]of e.nodeLookup)i.selected&&n.push(i.internals.userNode);for(const[,i]of e.edgeLookup)i.selected&&s.push(i);return{selectedNodes:n,selectedEdges:s}},Ed=e=>e.id;function JO(e,n){return $n(e.selectedNodes.map(Ed),n.selectedNodes.map(Ed))&&$n(e.selectedEdges.map(Ed),n.selectedEdges.map(Ed))}function eD({onSelectionChange:e}){const n=Bn(),{selectedNodes:s,selectedEdges:i}=tn(ZO,JO);return v.useEffect(()=>{const l={nodes:s,edges:i};e?.(l),n.getState().onSelectionChangeHandlers.forEach(d=>d(l))},[s,i,e]),null}const tD=e=>!!e.onSelectionChangeHandlers;function nD({onSelectionChange:e}){const n=tn(tD);return e||n?t.jsx(eD,{onSelectionChange:e}):null}const dN=[0,0],rD={x:0,y:0,zoom:1},sD=["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"],Iv=[...sD,"rfId"],aD=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}),zv={translateExtent:Xo,nodeOrigin:dN,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function iD(e){const{setNodes:n,setEdges:s,setMinZoom:i,setMaxZoom:l,setTranslateExtent:d,setNodeExtent:c,reset:h,setDefaultNodesAndEdges:m}=tn(aD,$n),f=Bn();v.useEffect(()=>(m(e.defaultNodes,e.defaultEdges),()=>{x.current=zv,h()}),[]);const x=v.useRef(zv);return v.useEffect(()=>{for(const p of Iv){const g=e[p],y=x.current[p];g!==y&&(typeof e[p]>"u"||(p==="nodes"?n(g):p==="edges"?s(g):p==="minZoom"?i(g):p==="maxZoom"?l(g):p==="translateExtent"?d(g):p==="nodeExtent"?c(g):p==="ariaLabelConfig"?f.setState({ariaLabelConfig:UR(g)}):p==="fitView"?f.setState({fitViewQueued:g}):p==="fitViewOptions"?f.setState({fitViewOptions:g}):f.setState({[p]:g})))}x.current=e},Iv.map(p=>e[p])),null}function $v(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function lD(e){const[n,s]=v.useState(e==="system"?null:e);return v.useEffect(()=>{if(e!=="system"){s(e);return}const i=$v(),l=()=>s(i?.matches?"dark":"light");return l(),i?.addEventListener("change",l),()=>{i?.removeEventListener("change",l)}},[e]),n!==null?n:$v()?.matches?"dark":"light"}const Bv=typeof document<"u"?document:null;function Zo(e=null,n={target:Bv,actInsideInputWithModifier:!0}){const[s,i]=v.useState(!1),l=v.useRef(!1),d=v.useRef(new Set([])),[c,h]=v.useMemo(()=>{if(e!==null){const f=(Array.isArray(e)?e:[e]).filter(p=>typeof p=="string").map(p=>p.replace("+",`
|
|
57
|
-
`).replace(`
|
|
58
|
-
|
|
59
|
-
`,`
|
|
60
|
-
+`).split(`
|
|
61
|
-
`)),x=f.reduce((p,g)=>p.concat(...g),[]);return[f,x]}return[[],[]]},[e]);return v.useEffect(()=>{const m=n?.target??Bv,f=n?.actInsideInputWithModifier??!0;if(e!==null){const x=y=>{if(l.current=y.ctrlKey||y.metaKey||y.shiftKey||y.altKey,(!l.current||l.current&&!f)&&Uw(y))return!1;const N=Pv(y.code,h);if(d.current.add(y[N]),Hv(c,d.current,!1)){const T=y.composedPath?.()?.[0]||y.target,C=T?.nodeName==="BUTTON"||T?.nodeName==="A";n.preventDefault!==!1&&(l.current||!C)&&y.preventDefault(),i(!0)}},p=y=>{const w=Pv(y.code,h);Hv(c,d.current,!0)?(i(!1),d.current.clear()):d.current.delete(y[w]),y.key==="Meta"&&d.current.clear(),l.current=!1},g=()=>{d.current.clear(),i(!1)};return m?.addEventListener("keydown",x),m?.addEventListener("keyup",p),window.addEventListener("blur",g),window.addEventListener("contextmenu",g),()=>{m?.removeEventListener("keydown",x),m?.removeEventListener("keyup",p),window.removeEventListener("blur",g),window.removeEventListener("contextmenu",g)}}},[e,i]),s}function Hv(e,n,s){return e.filter(i=>s||i.length===n.size).some(i=>i.every(l=>n.has(l)))}function Pv(e,n){return n.includes(e)?"code":"key"}const oD=()=>{const e=Bn();return v.useMemo(()=>({zoomIn:n=>{const{panZoom:s}=e.getState();return s?s.scaleBy(1.2,{duration:n?.duration}):Promise.resolve(!1)},zoomOut:n=>{const{panZoom:s}=e.getState();return s?s.scaleBy(1/1.2,{duration:n?.duration}):Promise.resolve(!1)},zoomTo:(n,s)=>{const{panZoom:i}=e.getState();return i?i.scaleTo(n,{duration:s?.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(n,s)=>{const{transform:[i,l,d],panZoom:c}=e.getState();return c?(await c.setViewport({x:n.x??i,y:n.y??l,zoom:n.zoom??d},s),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[n,s,i]=e.getState().transform;return{x:n,y:s,zoom:i}},setCenter:async(n,s,i)=>e.getState().setCenter(n,s,i),fitBounds:async(n,s)=>{const{width:i,height:l,minZoom:d,maxZoom:c,panZoom:h}=e.getState(),m=zx(n,i,l,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:(n,s={})=>{const{transform:i,snapGrid:l,snapToGrid:d,domNode:c}=e.getState();if(!c)return n;const{x:h,y:m}=c.getBoundingClientRect(),f={x:n.x-h,y:n.y-m},x=s.snapGrid??l,p=s.snapToGrid??d;return cc(f,i,p,x)},flowToScreenPosition:n=>{const{transform:s,domNode:i}=e.getState();if(!i)return n;const{x:l,y:d}=i.getBoundingClientRect(),c=tu(n,s);return{x:c.x+l,y:c.y+d}}}),[])};function uN(e,n){const s=[],i=new Map,l=[];for(const d of e)if(d.type==="add"){l.push(d);continue}else if(d.type==="remove"||d.type==="replace")i.set(d.id,[d]);else{const c=i.get(d.id);c?c.push(d):i.set(d.id,[d])}for(const d of n){const c=i.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)cD(m,h);s.push(h)}return l.length&&l.forEach(d=>{d.index!==void 0?s.splice(d.index,0,{...d.item}):s.push({...d.item})}),s}function cD(e,n){switch(e.type){case"select":{n.selected=e.selected;break}case"position":{typeof e.position<"u"&&(n.position=e.position),typeof e.dragging<"u"&&(n.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(n.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(n.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(n.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(n.resizing=e.resizing);break}}}function fN(e,n){return uN(e,n)}function hN(e,n){return uN(e,n)}function pi(e,n){return{id:e,type:"select",selected:n}}function xl(e,n=new Set,s=!1){const i=[];for(const[l,d]of e){const c=n.has(l);!(d.selected===void 0&&!c)&&d.selected!==c&&(s&&(d.selected=c),i.push(pi(d.id,c)))}return i}function qv({items:e=[],lookup:n}){const s=[],i=new Map(e.map(l=>[l.id,l]));for(const[l,d]of e.entries()){const c=n.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:l})}for(const[l]of n)i.get(l)===void 0&&s.push({id:l,type:"remove"});return s}function Uv(e){return{id:e.id,type:"remove"}}const Vv=e=>OR(e),dD=e=>Lw(e);function mN(e){return v.forwardRef(e)}const uD=typeof window<"u"?v.useLayoutEffect:v.useEffect;function Fv(e){const[n,s]=v.useState(BigInt(0)),[i]=v.useState(()=>fD(()=>s(l=>l+BigInt(1))));return uD(()=>{const l=i.get();l.length&&(e(l),i.reset())},[n]),i}function fD(e){let n=[];return{get:()=>n,reset:()=>{n=[]},push:s=>{n.push(s),e()}}}const xN=v.createContext(null);function hD({children:e}){const n=Bn(),s=v.useCallback(h=>{const{nodes:m=[],setNodes:f,hasDefaultNodes:x,onNodesChange:p,nodeLookup:g,fitViewQueued:y,onNodesChangeMiddlewareMap:w}=n.getState();let N=m;for(const C of h)N=typeof C=="function"?C(N):C;let T=qv({items:N,lookup:g});for(const C of w.values())T=C(T);x&&f(N),T.length>0?p?.(T):y&&window.requestAnimationFrame(()=>{const{fitViewQueued:C,nodes:_,setNodes:k}=n.getState();C&&k(_)})},[]),i=Fv(s),l=v.useCallback(h=>{const{edges:m=[],setEdges:f,hasDefaultEdges:x,onEdgesChange:p,edgeLookup:g}=n.getState();let y=m;for(const w of h)y=typeof w=="function"?w(y):w;x?f(y):p&&p(qv({items:y,lookup:g}))},[]),d=Fv(l),c=v.useMemo(()=>({nodeQueue:i,edgeQueue:d}),[]);return t.jsx(xN.Provider,{value:c,children:e})}function mD(){const e=v.useContext(xN);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const xD=e=>!!e.panZoom;function Vx(){const e=oD(),n=Bn(),s=mD(),i=tn(xD),l=v.useMemo(()=>{const d=p=>n.getState().nodeLookup.get(p),c=p=>{s.nodeQueue.push(p)},h=p=>{s.edgeQueue.push(p)},m=p=>{const{nodeLookup:g,nodeOrigin:y}=n.getState(),w=Vv(p)?p:g.get(p.id),N=w.parentId?Pw(w.position,w.measured,w.parentId,g,y):w.position,T={...w,position:N,width:w.measured?.width??w.width,height:w.measured?.height??w.height};return Sl(T)},f=(p,g,y={replace:!1})=>{c(w=>w.map(N=>{if(N.id===p){const T=typeof g=="function"?g(N):g;return y.replace&&Vv(T)?T:{...N,...T}}return N}))},x=(p,g,y={replace:!1})=>{h(w=>w.map(N=>{if(N.id===p){const T=typeof g=="function"?g(N):g;return y.replace&&dD(T)?T:{...N,...T}}return N}))};return{getNodes:()=>n.getState().nodes.map(p=>({...p})),getNode:p=>d(p)?.internals.userNode,getInternalNode:d,getEdges:()=>{const{edges:p=[]}=n.getState();return p.map(g=>({...g}))},getEdge:p=>n.getState().edgeLookup.get(p),setNodes:c,setEdges:h,addNodes:p=>{const g=Array.isArray(p)?p:[p];s.nodeQueue.push(y=>[...y,...g])},addEdges:p=>{const g=Array.isArray(p)?p:[p];s.edgeQueue.push(y=>[...y,...g])},toObject:()=>{const{nodes:p=[],edges:g=[],transform:y}=n.getState(),[w,N,T]=y;return{nodes:p.map(C=>({...C})),edges:g.map(C=>({...C})),viewport:{x:w,y:N,zoom:T}}},deleteElements:async({nodes:p=[],edges:g=[]})=>{const{nodes:y,edges:w,onNodesDelete:N,onEdgesDelete:T,triggerNodeChanges:C,triggerEdgeChanges:_,onDelete:k,onBeforeDelete:M}=n.getState(),{nodes:D,edges:A}=await $R({nodesToRemove:p,edgesToRemove:g,nodes:y,edges:w,onBeforeDelete:M}),G=A.length>0,X=D.length>0;if(G){const K=A.map(Uv);T?.(A),_(K)}if(X){const K=D.map(Uv);N?.(D),C(K)}return(X||G)&&k?.({nodes:D,edges:A}),{deletedNodes:D,deletedEdges:A}},getIntersectingNodes:(p,g=!0,y)=>{const w=pv(p),N=w?p:m(p),T=y!==void 0;return N?(y||n.getState().nodes).filter(C=>{const _=n.getState().nodeLookup.get(C.id);if(_&&!w&&(C.id===p.id||!_.internals.positionAbsolute))return!1;const k=Sl(T?C:_),M=Wo(k,N);return g&&M>0||M>=k.width*k.height||M>=N.width*N.height}):[]},isNodeIntersecting:(p,g,y=!0)=>{const N=pv(p)?p:m(p);if(!N)return!1;const T=Wo(N,g);return y&&T>0||T>=g.width*g.height||T>=N.width*N.height},updateNode:f,updateNodeData:(p,g,y={replace:!1})=>{f(p,w=>{const N=typeof g=="function"?g(w):g;return y.replace?{...w,data:N}:{...w,data:{...w.data,...N}}},y)},updateEdge:x,updateEdgeData:(p,g,y={replace:!1})=>{x(p,w=>{const N=typeof g=="function"?g(w):g;return y.replace?{...w,data:N}:{...w,data:{...w.data,...N}}},y)},getNodesBounds:p=>{const{nodeLookup:g,nodeOrigin:y}=n.getState();return DR(p,{nodeLookup:g,nodeOrigin:y})},getHandleConnections:({type:p,id:g,nodeId:y})=>Array.from(n.getState().connectionLookup.get(`${y}-${p}${g?`-${g}`:""}`)?.values()??[]),getNodeConnections:({type:p,handleId:g,nodeId:y})=>Array.from(n.getState().connectionLookup.get(`${y}${p?g?`-${p}-${g}`:`-${p}`:""}`)?.values()??[]),fitView:async p=>{const g=n.getState().fitViewResolver??qR();return n.setState({fitViewQueued:!0,fitViewOptions:p,fitViewResolver:g}),s.nodeQueue.push(y=>[...y]),g.promise}}},[]);return v.useMemo(()=>({...l,...e,viewportInitialized:i}),[i])}const Yv=e=>e.selected,pD=typeof window<"u"?window:void 0;function gD({deleteKeyCode:e,multiSelectionKeyCode:n}){const s=Bn(),{deleteElements:i}=Vx(),l=Zo(e,{actInsideInputWithModifier:!1}),d=Zo(n,{target:pD});v.useEffect(()=>{if(l){const{edges:c,nodes:h}=s.getState();i({nodes:h.filter(Yv),edges:c.filter(Yv)}),s.setState({nodesSelectionActive:!1})}},[l]),v.useEffect(()=>{s.setState({multiSelectionActive:d})},[d])}function bD(e){const n=Bn();v.useEffect(()=>{const s=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const i=$x(e.current);(i.height===0||i.width===0)&&n.getState().onError?.("004",Ls.error004()),n.setState({width:i.width||500,height:i.height||500})};if(e.current){s(),window.addEventListener("resize",s);const i=new ResizeObserver(()=>s());return i.observe(e.current),()=>{window.removeEventListener("resize",s),i&&e.current&&i.unobserve(e.current)}}},[])}const Nu={position:"absolute",width:"100%",height:"100%",top:0,left:0},yD=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function vD({onPaneContextMenu:e,zoomOnScroll:n=!0,zoomOnPinch:s=!0,panOnScroll:i=!1,panOnScrollSpeed:l=.5,panOnScrollMode:d=ji.Free,zoomOnDoubleClick:c=!0,panOnDrag:h=!0,defaultViewport:m,translateExtent:f,minZoom:x,maxZoom:p,zoomActivationKeyCode:g,preventScrolling:y=!0,children:w,noWheelClassName:N,noPanClassName:T,onViewportChange:C,isControlledViewport:_,paneClickDistance:k,selectionOnDrag:M}){const D=Bn(),A=v.useRef(null),{userSelectionActive:G,lib:X,connectionInProgress:K}=tn(yD,$n),$=Zo(g),q=v.useRef();bD(A);const U=v.useCallback(z=>{C?.({x:z[0],y:z[1],zoom:z[2]}),_||D.setState({transform:z})},[C,_]);return v.useEffect(()=>{if(A.current){q.current=SO({domNode:A.current,minZoom:x,maxZoom:p,translateExtent:f,viewport:m,onDraggingChange:R=>D.setState(F=>F.paneDragging===R?F:{paneDragging:R}),onPanZoomStart:(R,F)=>{const{onViewportChangeStart:Y,onMoveStart:Z}=D.getState();Z?.(R,F),Y?.(F)},onPanZoom:(R,F)=>{const{onViewportChange:Y,onMove:Z}=D.getState();Z?.(R,F),Y?.(F)},onPanZoomEnd:(R,F)=>{const{onViewportChangeEnd:Y,onMoveEnd:Z}=D.getState();Z?.(R,F),Y?.(F)}});const{x:z,y:E,zoom:L}=q.current.getViewport();return D.setState({panZoom:q.current,transform:[z,E,L],domNode:A.current.closest(".react-flow")}),()=>{q.current?.destroy()}}},[]),v.useEffect(()=>{q.current?.update({onPaneContextMenu:e,zoomOnScroll:n,zoomOnPinch:s,panOnScroll:i,panOnScrollSpeed:l,panOnScrollMode:d,zoomOnDoubleClick:c,panOnDrag:h,zoomActivationKeyPressed:$,preventScrolling:y,noPanClassName:T,userSelectionActive:G,noWheelClassName:N,lib:X,onTransformChange:U,connectionInProgress:K,selectionOnDrag:M,paneClickDistance:k})},[e,n,s,i,l,d,c,h,$,y,T,G,N,X,U,K,M,k]),t.jsx("div",{className:"react-flow__renderer",ref:A,style:Nu,children:w})}const jD=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function wD(){const{userSelectionActive:e,userSelectionRect:n}=tn(jD,$n);return e&&n?t.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:n.width,height:n.height,transform:`translate(${n.x}px, ${n.y}px)`}}):null}const um=(e,n)=>s=>{s.target===n.current&&e?.(s)},ND=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function kD({isSelecting:e,selectionKeyPressed:n,selectionMode:s=Ko.Full,panOnDrag:i,paneClickDistance:l,selectionOnDrag:d,onSelectionStart:c,onSelectionEnd:h,onPaneClick:m,onPaneContextMenu:f,onPaneScroll:x,onPaneMouseEnter:p,onPaneMouseMove:g,onPaneMouseLeave:y,children:w}){const N=Bn(),{userSelectionActive:T,elementsSelectable:C,dragging:_,connectionInProgress:k}=tn(ND,$n),M=C&&(e||T),D=v.useRef(null),A=v.useRef(),G=v.useRef(new Set),X=v.useRef(new Set),K=v.useRef(!1),$=Y=>{if(K.current||k){K.current=!1;return}m?.(Y),N.getState().resetSelectedElements(),N.setState({nodesSelectionActive:!1})},q=Y=>{if(Array.isArray(i)&&i?.includes(2)){Y.preventDefault();return}f?.(Y)},U=x?Y=>x(Y):void 0,z=Y=>{K.current&&(Y.stopPropagation(),K.current=!1)},E=Y=>{const{domNode:Z}=N.getState();if(A.current=Z?.getBoundingClientRect(),!A.current)return;const B=Y.target===D.current;if(!B&&!!Y.target.closest(".nokey")||!e||!(d&&B||n)||Y.button!==0||!Y.isPrimary)return;Y.target?.setPointerCapture?.(Y.pointerId),K.current=!1;const{x:I,y:S}=ys(Y.nativeEvent,A.current);N.setState({userSelectionRect:{width:0,height:0,startX:I,startY:S,x:I,y:S}}),B||(Y.stopPropagation(),Y.preventDefault())},L=Y=>{const{userSelectionRect:Z,transform:B,nodeLookup:O,edgeLookup:V,connectionLookup:I,triggerNodeChanges:S,triggerEdgeChanges:H,defaultEdgeOptions:W,resetSelectedElements:ee}=N.getState();if(!A.current||!Z)return;const{x:te,y:ae}=ys(Y.nativeEvent,A.current),{startX:he,startY:Ne}=Z;if(!K.current){const Le=n?0:l;if(Math.hypot(te-he,ae-Ne)<=Le)return;ee(),c?.(Y)}K.current=!0;const De={startX:he,startY:Ne,x:te<he?te:he,y:ae<Ne?ae:Ne,width:Math.abs(te-he),height:Math.abs(ae-Ne)},je=G.current,ke=X.current;G.current=new Set(Ix(O,De,B,s===Ko.Partial,!0).map(Le=>Le.id)),X.current=new Set;const Se=W?.selectable??!0;for(const Le of G.current){const nt=I.get(Le);if(nt)for(const{edgeId:rt}of nt.values()){const yt=V.get(rt);yt&&(yt.selectable??Se)&&X.current.add(rt)}}if(!gv(je,G.current)){const Le=xl(O,G.current,!0);S(Le)}if(!gv(ke,X.current)){const Le=xl(V,X.current);H(Le)}N.setState({userSelectionRect:De,userSelectionActive:!0,nodesSelectionActive:!1})},R=Y=>{Y.button===0&&(Y.target?.releasePointerCapture?.(Y.pointerId),!T&&Y.target===D.current&&N.getState().userSelectionRect&&$?.(Y),N.setState({userSelectionActive:!1,userSelectionRect:null}),K.current&&(h?.(Y),N.setState({nodesSelectionActive:G.current.size>0})))},F=i===!0||Array.isArray(i)&&i.includes(0);return t.jsxs("div",{className:er(["react-flow__pane",{draggable:F,dragging:_,selection:e}]),onClick:M?void 0:um($,D),onContextMenu:um(q,D),onWheel:um(U,D),onPointerEnter:M?void 0:p,onPointerMove:M?L:g,onPointerUp:M?R:void 0,onPointerDownCapture:M?E:void 0,onClickCapture:M?z:void 0,onPointerLeave:y,ref:D,style:Nu,children:[w,t.jsx(wD,{})]})}function ex({id:e,store:n,unselect:s=!1,nodeRef:i}){const{addSelectedNodes:l,unselectNodesAndEdges:d,multiSelectionActive:c,nodeLookup:h,onError:m}=n.getState(),f=h.get(e);if(!f){m?.("012",Ls.error012(e));return}n.setState({nodesSelectionActive:!1}),f.selected?(s||f.selected&&c)&&(d({nodes:[f],edges:[]}),requestAnimationFrame(()=>i?.current?.blur())):l([e])}function pN({nodeRef:e,disabled:n=!1,noDragClassName:s,handleSelector:i,nodeId:l,isSelectable:d,nodeClickDistance:c}){const h=Bn(),[m,f]=v.useState(!1),x=v.useRef();return v.useEffect(()=>{x.current=uO({getStoreItems:()=>h.getState(),onNodeMouseDown:p=>{ex({id:p,store:h,nodeRef:e})},onDragStart:()=>{f(!0)},onDragStop:()=>{f(!1)}})},[]),v.useEffect(()=>{if(!(n||!e.current||!x.current))return x.current.update({noDragClassName:s,handleSelector:i,domNode:e.current,isSelectable:d,nodeId:l,nodeClickDistance:c}),()=>{x.current?.destroy()}},[s,i,n,d,e,l,c]),m}const SD=e=>n=>n.selected&&(n.draggable||e&&typeof n.draggable>"u");function gN(){const e=Bn();return v.useCallback(s=>{const{nodeExtent:i,snapToGrid:l,snapGrid:d,nodesDraggable:c,onError:h,updateNodePositions:m,nodeLookup:f,nodeOrigin:x}=e.getState(),p=new Map,g=SD(c),y=l?d[0]:5,w=l?d[1]:5,N=s.direction.x*y*s.factor,T=s.direction.y*w*s.factor;for(const[,C]of f){if(!g(C))continue;let _={x:C.internals.positionAbsolute.x+N,y:C.internals.positionAbsolute.y+T};l&&(_=oc(_,d));const{position:k,positionAbsolute:M}=Iw({nodeId:C.id,nextPosition:_,nodeLookup:f,nodeExtent:i,nodeOrigin:x,onError:h});C.position=k,C.internals.positionAbsolute=M,p.set(C.id,C)}m(p)},[])}const Fx=v.createContext(null),CD=Fx.Provider;Fx.Consumer;const bN=()=>v.useContext(Fx),ED=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),TD=(e,n,s)=>i=>{const{connectionClickStartHandle:l,connectionMode:d,connection:c}=i,{fromHandle:h,toHandle:m,isValid:f}=c,x=m?.nodeId===e&&m?.id===n&&m?.type===s;return{connectingFrom:h?.nodeId===e&&h?.id===n&&h?.type===s,connectingTo:x,clickConnecting:l?.nodeId===e&&l?.id===n&&l?.type===s,isPossibleEndHandle:d===wl.Strict?h?.type!==s:e!==h?.nodeId||n!==h?.id,connectionInProcess:!!h,clickConnectionInProcess:!!l,valid:x&&f}};function _D({type:e="source",position:n=mt.Top,isValidConnection:s,isConnectable:i=!0,isConnectableStart:l=!0,isConnectableEnd:d=!0,id:c,onConnect:h,children:m,className:f,onMouseDown:x,onTouchStart:p,...g},y){const w=c||null,N=e==="target",T=Bn(),C=bN(),{connectOnClick:_,noPanClassName:k,rfId:M}=tn(ED,$n),{connectingFrom:D,connectingTo:A,clickConnecting:G,isPossibleEndHandle:X,connectionInProcess:K,clickConnectionInProcess:$,valid:q}=tn(TD(C,w,e),$n);C||T.getState().onError?.("010",Ls.error010());const U=L=>{const{defaultEdgeOptions:R,onConnect:F,hasDefaultEdges:Y}=T.getState(),Z={...R,...L};if(Y){const{edges:B,setEdges:O}=T.getState();O(KR(Z,B))}F?.(Z),h?.(Z)},z=L=>{if(!C)return;const R=Vw(L.nativeEvent);if(l&&(R&&L.button===0||!R)){const F=T.getState();Jm.onPointerDown(L.nativeEvent,{handleDomNode:L.currentTarget,autoPanOnConnect:F.autoPanOnConnect,connectionMode:F.connectionMode,connectionRadius:F.connectionRadius,domNode:F.domNode,nodeLookup:F.nodeLookup,lib:F.lib,isTarget:N,handleId:w,nodeId:C,flowId:F.rfId,panBy:F.panBy,cancelConnection:F.cancelConnection,onConnectStart:F.onConnectStart,onConnectEnd:(...Y)=>T.getState().onConnectEnd?.(...Y),updateConnection:F.updateConnection,onConnect:U,isValidConnection:s||((...Y)=>T.getState().isValidConnection?.(...Y)??!0),getTransform:()=>T.getState().transform,getFromHandle:()=>T.getState().connection.fromHandle,autoPanSpeed:F.autoPanSpeed,dragThreshold:F.connectionDragThreshold})}R?x?.(L):p?.(L)},E=L=>{const{onClickConnectStart:R,onClickConnectEnd:F,connectionClickStartHandle:Y,connectionMode:Z,isValidConnection:B,lib:O,rfId:V,nodeLookup:I,connection:S}=T.getState();if(!C||!Y&&!l)return;if(!Y){R?.(L.nativeEvent,{nodeId:C,handleId:w,handleType:e}),T.setState({connectionClickStartHandle:{nodeId:C,type:e,id:w}});return}const H=qw(L.target),W=s||B,{connection:ee,isValid:te}=Jm.isValid(L.nativeEvent,{handle:{nodeId:C,id:w,type:e},connectionMode:Z,fromNodeId:Y.nodeId,fromHandleId:Y.id||null,fromType:Y.type,isValidConnection:W,flowId:V,doc:H,lib:O,nodeLookup:I});te&&ee&&U(ee);const ae=structuredClone(S);delete ae.inProgress,ae.toPosition=ae.toHandle?ae.toHandle.position:null,F?.(L,ae),T.setState({connectionClickStartHandle:null})};return t.jsx("div",{"data-handleid":w,"data-nodeid":C,"data-handlepos":n,"data-id":`${M}-${C}-${w}-${e}`,className:er(["react-flow__handle",`react-flow__handle-${n}`,"nodrag",k,f,{source:!N,target:N,connectable:i,connectablestart:l,connectableend:d,clickconnecting:G,connectingfrom:D,connectingto:A,valid:q,connectionindicator:i&&(!K||X)&&(K||$?d:l)}]),onMouseDown:z,onTouchStart:z,onClick:_?E:void 0,ref:y,...g,children:m})}const Xa=v.memo(mN(_D));function AD({data:e,isConnectable:n,sourcePosition:s=mt.Bottom}){return t.jsxs(t.Fragment,{children:[e?.label,t.jsx(Xa,{type:"source",position:s,isConnectable:n})]})}function MD({data:e,isConnectable:n,targetPosition:s=mt.Top,sourcePosition:i=mt.Bottom}){return t.jsxs(t.Fragment,{children:[t.jsx(Xa,{type:"target",position:s,isConnectable:n}),e?.label,t.jsx(Xa,{type:"source",position:i,isConnectable:n})]})}function RD(){return null}function OD({data:e,isConnectable:n,targetPosition:s=mt.Top}){return t.jsxs(t.Fragment,{children:[t.jsx(Xa,{type:"target",position:s,isConnectable:n}),e?.label]})}const nu={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Gv={input:AD,default:MD,output:OD,group:RD};function DD(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 LD=e=>{const{width:n,height:s,x:i,y:l}=lc(e.nodeLookup,{filter:d=>!!d.selected});return{width:bs(n)?n:null,height:bs(s)?s:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${i}px,${l}px)`}};function ID({onSelectionContextMenu:e,noPanClassName:n,disableKeyboardA11y:s}){const i=Bn(),{width:l,height:d,transformString:c,userSelectionActive:h}=tn(LD,$n),m=gN(),f=v.useRef(null);v.useEffect(()=>{s||f.current?.focus({preventScroll:!0})},[s]);const x=!h&&l!==null&&d!==null;if(pN({nodeRef:f,disabled:!x}),!x)return null;const p=e?y=>{const w=i.getState().nodes.filter(N=>N.selected);e(y,w)}:void 0,g=y=>{Object.prototype.hasOwnProperty.call(nu,y.key)&&(y.preventDefault(),m({direction:nu[y.key],factor:y.shiftKey?4:1}))};return t.jsx("div",{className:er(["react-flow__nodesselection","react-flow__container",n]),style:{transform:c},children:t.jsx("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:p,tabIndex:s?void 0:-1,onKeyDown:s?void 0:g,style:{width:l,height:d}})})}const Xv=typeof window<"u"?window:void 0,zD=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function yN({children:e,onPaneClick:n,onPaneMouseEnter:s,onPaneMouseMove:i,onPaneMouseLeave:l,onPaneContextMenu:d,onPaneScroll:c,paneClickDistance:h,deleteKeyCode:m,selectionKeyCode:f,selectionOnDrag:x,selectionMode:p,onSelectionStart:g,onSelectionEnd:y,multiSelectionKeyCode:w,panActivationKeyCode:N,zoomActivationKeyCode:T,elementsSelectable:C,zoomOnScroll:_,zoomOnPinch:k,panOnScroll:M,panOnScrollSpeed:D,panOnScrollMode:A,zoomOnDoubleClick:G,panOnDrag:X,defaultViewport:K,translateExtent:$,minZoom:q,maxZoom:U,preventScrolling:z,onSelectionContextMenu:E,noWheelClassName:L,noPanClassName:R,disableKeyboardA11y:F,onViewportChange:Y,isControlledViewport:Z}){const{nodesSelectionActive:B,userSelectionActive:O}=tn(zD,$n),V=Zo(f,{target:Xv}),I=Zo(N,{target:Xv}),S=I||X,H=I||M,W=x&&S!==!0,ee=V||O||W;return gD({deleteKeyCode:m,multiSelectionKeyCode:w}),t.jsx(vD,{onPaneContextMenu:d,elementsSelectable:C,zoomOnScroll:_,zoomOnPinch:k,panOnScroll:H,panOnScrollSpeed:D,panOnScrollMode:A,zoomOnDoubleClick:G,panOnDrag:!V&&S,defaultViewport:K,translateExtent:$,minZoom:q,maxZoom:U,zoomActivationKeyCode:T,preventScrolling:z,noWheelClassName:L,noPanClassName:R,onViewportChange:Y,isControlledViewport:Z,paneClickDistance:h,selectionOnDrag:W,children:t.jsxs(kD,{onSelectionStart:g,onSelectionEnd:y,onPaneClick:n,onPaneMouseEnter:s,onPaneMouseMove:i,onPaneMouseLeave:l,onPaneContextMenu:d,onPaneScroll:c,panOnDrag:S,isSelecting:!!ee,selectionMode:p,selectionKeyPressed:V,paneClickDistance:h,selectionOnDrag:W,children:[e,B&&t.jsx(ID,{onSelectionContextMenu:E,noPanClassName:R,disableKeyboardA11y:F})]})})}yN.displayName="FlowRenderer";const $D=v.memo(yN),BD=e=>n=>e?Ix(n.nodeLookup,{x:0,y:0,width:n.width,height:n.height},n.transform,!0).map(s=>s.id):Array.from(n.nodeLookup.keys());function HD(e){return tn(v.useCallback(BD(e),[e]),$n)}const PD=e=>e.updateNodeInternals;function qD(){const e=tn(PD),[n]=v.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(s=>{const i=new Map;s.forEach(l=>{const d=l.target.getAttribute("data-id");i.set(d,{id:d,nodeElement:l.target,force:!0})}),e(i)}));return v.useEffect(()=>()=>{n?.disconnect()},[n]),n}function UD({node:e,nodeType:n,hasDimensions:s,resizeObserver:i}){const l=Bn(),d=v.useRef(null),c=v.useRef(null),h=v.useRef(e.sourcePosition),m=v.useRef(e.targetPosition),f=v.useRef(n),x=s&&!!e.internals.handleBounds;return v.useEffect(()=>{d.current&&!e.hidden&&(!x||c.current!==d.current)&&(c.current&&i?.unobserve(c.current),i?.observe(d.current),c.current=d.current)},[x,e.hidden]),v.useEffect(()=>()=>{c.current&&(i?.unobserve(c.current),c.current=null)},[]),v.useEffect(()=>{if(d.current){const p=f.current!==n,g=h.current!==e.sourcePosition,y=m.current!==e.targetPosition;(p||g||y)&&(f.current=n,h.current=e.sourcePosition,m.current=e.targetPosition,l.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:d.current,force:!0}]])))}},[e.id,n,e.sourcePosition,e.targetPosition]),d}function VD({id:e,onClick:n,onMouseEnter:s,onMouseMove:i,onMouseLeave:l,onContextMenu:d,onDoubleClick:c,nodesDraggable:h,elementsSelectable:m,nodesConnectable:f,nodesFocusable:x,resizeObserver:p,noDragClassName:g,noPanClassName:y,disableKeyboardA11y:w,rfId:N,nodeTypes:T,nodeClickDistance:C,onError:_}){const{node:k,internals:M,isParent:D}=tn(te=>{const ae=te.nodeLookup.get(e),he=te.parentLookup.has(e);return{node:ae,internals:ae.internals,isParent:he}},$n);let A=k.type||"default",G=T?.[A]||Gv[A];G===void 0&&(_?.("003",Ls.error003(A)),A="default",G=T?.default||Gv.default);const X=!!(k.draggable||h&&typeof k.draggable>"u"),K=!!(k.selectable||m&&typeof k.selectable>"u"),$=!!(k.connectable||f&&typeof k.connectable>"u"),q=!!(k.focusable||x&&typeof k.focusable>"u"),U=Bn(),z=Hw(k),E=UD({node:k,nodeType:A,hasDimensions:z,resizeObserver:p}),L=pN({nodeRef:E,disabled:k.hidden||!X,noDragClassName:g,handleSelector:k.dragHandle,nodeId:e,isSelectable:K,nodeClickDistance:C}),R=gN();if(k.hidden)return null;const F=fa(k),Y=DD(k),Z=K||X||n||s||i||l,B=s?te=>s(te,{...M.userNode}):void 0,O=i?te=>i(te,{...M.userNode}):void 0,V=l?te=>l(te,{...M.userNode}):void 0,I=d?te=>d(te,{...M.userNode}):void 0,S=c?te=>c(te,{...M.userNode}):void 0,H=te=>{const{selectNodesOnDrag:ae,nodeDragThreshold:he}=U.getState();K&&(!ae||!X||he>0)&&ex({id:e,store:U,nodeRef:E}),n&&n(te,{...M.userNode})},W=te=>{if(!(Uw(te.nativeEvent)||w)){if(Mw.includes(te.key)&&K){const ae=te.key==="Escape";ex({id:e,store:U,unselect:ae,nodeRef:E})}else if(X&&k.selected&&Object.prototype.hasOwnProperty.call(nu,te.key)){te.preventDefault();const{ariaLabelConfig:ae}=U.getState();U.setState({ariaLiveMessage:ae["node.a11yDescription.ariaLiveMessage"]({direction:te.key.replace("Arrow","").toLowerCase(),x:~~M.positionAbsolute.x,y:~~M.positionAbsolute.y})}),R({direction:nu[te.key],factor:te.shiftKey?4:1})}}},ee=()=>{if(w||!E.current?.matches(":focus-visible"))return;const{transform:te,width:ae,height:he,autoPanOnNodeFocus:Ne,setCenter:De}=U.getState();if(!Ne)return;Ix(new Map([[e,k]]),{x:0,y:0,width:ae,height:he},te,!0).length>0||De(k.position.x+F.width/2,k.position.y+F.height/2,{zoom:te[2]})};return t.jsx("div",{className:er(["react-flow__node",`react-flow__node-${A}`,{[y]:X},k.className,{selected:k.selected,selectable:K,parent:D,draggable:X,dragging:L}]),ref:E,style:{zIndex:M.z,transform:`translate(${M.positionAbsolute.x}px,${M.positionAbsolute.y}px)`,pointerEvents:Z?"all":"none",visibility:z?"visible":"hidden",...k.style,...Y},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:B,onMouseMove:O,onMouseLeave:V,onContextMenu:I,onClick:H,onDoubleClick:S,onKeyDown:q?W:void 0,tabIndex:q?0:void 0,onFocus:q?ee:void 0,role:k.ariaRole??(q?"group":void 0),"aria-roledescription":"node","aria-describedby":w?void 0:`${oN}-${N}`,"aria-label":k.ariaLabel,...k.domAttributes,children:t.jsx(CD,{value:e,children:t.jsx(G,{id:e,data:k.data,type:A,positionAbsoluteX:M.positionAbsolute.x,positionAbsoluteY:M.positionAbsolute.y,selected:k.selected??!1,selectable:K,draggable:X,deletable:k.deletable??!0,isConnectable:$,sourcePosition:k.sourcePosition,targetPosition:k.targetPosition,dragging:L,dragHandle:k.dragHandle,zIndex:M.z,parentId:k.parentId,...F})})})}var FD=v.memo(VD);const YD=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function vN(e){const{nodesDraggable:n,nodesConnectable:s,nodesFocusable:i,elementsSelectable:l,onError:d}=tn(YD,$n),c=HD(e.onlyRenderVisibleElements),h=qD();return t.jsx("div",{className:"react-flow__nodes",style:Nu,children:c.map(m=>t.jsx(FD,{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:n,nodesConnectable:s,nodesFocusable:i,elementsSelectable:l,nodeClickDistance:e.nodeClickDistance,onError:d},m))})}vN.displayName="NodeRenderer";const GD=v.memo(vN);function XD(e){return tn(v.useCallback(s=>{if(!e)return s.edges.map(l=>l.id);const i=[];if(s.width&&s.height)for(const l of s.edges){const d=s.nodeLookup.get(l.source),c=s.nodeLookup.get(l.target);d&&c&&YR({sourceNode:d,targetNode:c,width:s.width,height:s.height,transform:s.transform})&&i.push(l.id)}return i},[e]),$n)}const KD=({color:e="none",strokeWidth:n=1})=>{const s={strokeWidth:n,...e&&{stroke:e}};return t.jsx("polyline",{className:"arrow",style:s,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},WD=({color:e="none",strokeWidth:n=1})=>{const s={strokeWidth:n,...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"})},Kv={[Nl.Arrow]:KD,[Nl.ArrowClosed]:WD};function QD(e){const n=Bn();return v.useMemo(()=>Object.prototype.hasOwnProperty.call(Kv,e)?Kv[e]:(n.getState().onError?.("009",Ls.error009(e)),null),[e])}const ZD=({id:e,type:n,color:s,width:i=12.5,height:l=12.5,markerUnits:d="strokeWidth",strokeWidth:c,orient:h="auto-start-reverse"})=>{const m=QD(n);return m?t.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${i}`,markerHeight:`${l}`,viewBox:"-10 -10 20 20",markerUnits:d,orient:h,refX:"0",refY:"0",children:t.jsx(m,{color:s,strokeWidth:c})}):null},jN=({defaultColor:e,rfId:n})=>{const s=tn(d=>d.edges),i=tn(d=>d.defaultEdgeOptions),l=v.useMemo(()=>eO(s,{id:n,defaultColor:e,defaultMarkerStart:i?.markerStart,defaultMarkerEnd:i?.markerEnd}),[s,i,n,e]);return l.length?t.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:t.jsx("defs",{children:l.map(d=>t.jsx(ZD,{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};jN.displayName="MarkerDefinitions";var JD=v.memo(jN);function wN({x:e,y:n,label:s,labelStyle:i,labelShowBg:l=!0,labelBgStyle:d,labelBgPadding:c=[2,4],labelBgBorderRadius:h=2,children:m,className:f,...x}){const[p,g]=v.useState({x:1,y:0,width:0,height:0}),y=er(["react-flow__edge-textwrapper",f]),w=v.useRef(null);return v.useEffect(()=>{if(w.current){const N=w.current.getBBox();g({x:N.x,y:N.y,width:N.width,height:N.height})}},[s]),s?t.jsxs("g",{transform:`translate(${e-p.width/2} ${n-p.height/2})`,className:y,visibility:p.width?"visible":"hidden",...x,children:[l&&t.jsx("rect",{width:p.width+2*c[0],x:-c[0],y:-c[1],height:p.height+2*c[1],className:"react-flow__edge-textbg",style:d,rx:h,ry:h}),t.jsx("text",{className:"react-flow__edge-text",y:p.height/2,dy:"0.3em",ref:w,style:i,children:s}),m]}):null}wN.displayName="EdgeText";const eL=v.memo(wN);function ku({path:e,labelX:n,labelY:s,label:i,labelStyle:l,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:er(["react-flow__edge-path",x.className])}),f?t.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:f,className:"react-flow__edge-interaction"}):null,i&&bs(n)&&bs(s)?t.jsx(eL,{x:n,y:s,label:i,labelStyle:l,labelShowBg:d,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:m}):null]})}function Wv({pos:e,x1:n,y1:s,x2:i,y2:l}){return e===mt.Left||e===mt.Right?[.5*(n+i),s]:[n,.5*(s+l)]}function NN({sourceX:e,sourceY:n,sourcePosition:s=mt.Bottom,targetX:i,targetY:l,targetPosition:d=mt.Top}){const[c,h]=Wv({pos:s,x1:e,y1:n,x2:i,y2:l}),[m,f]=Wv({pos:d,x1:i,y1:l,x2:e,y2:n}),[x,p,g,y]=Fw({sourceX:e,sourceY:n,targetX:i,targetY:l,sourceControlX:c,sourceControlY:h,targetControlX:m,targetControlY:f});return[`M${e},${n} C${c},${h} ${m},${f} ${i},${l}`,x,p,g,y]}function kN(e){return v.memo(({id:n,sourceX:s,sourceY:i,targetX:l,targetY:d,sourcePosition:c,targetPosition:h,label:m,labelStyle:f,labelShowBg:x,labelBgStyle:p,labelBgPadding:g,labelBgBorderRadius:y,style:w,markerEnd:N,markerStart:T,interactionWidth:C})=>{const[_,k,M]=NN({sourceX:s,sourceY:i,sourcePosition:c,targetX:l,targetY:d,targetPosition:h}),D=e.isInternal?void 0:n;return t.jsx(ku,{id:D,path:_,labelX:k,labelY:M,label:m,labelStyle:f,labelShowBg:x,labelBgStyle:p,labelBgPadding:g,labelBgBorderRadius:y,style:w,markerEnd:N,markerStart:T,interactionWidth:C})})}const tL=kN({isInternal:!1}),SN=kN({isInternal:!0});tL.displayName="SimpleBezierEdge";SN.displayName="SimpleBezierEdgeInternal";function CN(e){return v.memo(({id:n,sourceX:s,sourceY:i,targetX:l,targetY:d,label:c,labelStyle:h,labelShowBg:m,labelBgStyle:f,labelBgPadding:x,labelBgBorderRadius:p,style:g,sourcePosition:y=mt.Bottom,targetPosition:w=mt.Top,markerEnd:N,markerStart:T,pathOptions:C,interactionWidth:_})=>{const[k,M,D]=Wm({sourceX:s,sourceY:i,sourcePosition:y,targetX:l,targetY:d,targetPosition:w,borderRadius:C?.borderRadius,offset:C?.offset,stepPosition:C?.stepPosition}),A=e.isInternal?void 0:n;return t.jsx(ku,{id:A,path:k,labelX:M,labelY:D,label:c,labelStyle:h,labelShowBg:m,labelBgStyle:f,labelBgPadding:x,labelBgBorderRadius:p,style:g,markerEnd:N,markerStart:T,interactionWidth:_})})}const EN=CN({isInternal:!1}),TN=CN({isInternal:!0});EN.displayName="SmoothStepEdge";TN.displayName="SmoothStepEdgeInternal";function _N(e){return v.memo(({id:n,...s})=>{const i=e.isInternal?void 0:n;return t.jsx(EN,{...s,id:i,pathOptions:v.useMemo(()=>({borderRadius:0,offset:s.pathOptions?.offset}),[s.pathOptions?.offset])})})}const nL=_N({isInternal:!1}),AN=_N({isInternal:!0});nL.displayName="StepEdge";AN.displayName="StepEdgeInternal";function MN(e){return v.memo(({id:n,sourceX:s,sourceY:i,targetX:l,targetY:d,label:c,labelStyle:h,labelShowBg:m,labelBgStyle:f,labelBgPadding:x,labelBgBorderRadius:p,style:g,markerEnd:y,markerStart:w,interactionWidth:N})=>{const[T,C,_]=Xw({sourceX:s,sourceY:i,targetX:l,targetY:d}),k=e.isInternal?void 0:n;return t.jsx(ku,{id:k,path:T,labelX:C,labelY:_,label:c,labelStyle:h,labelShowBg:m,labelBgStyle:f,labelBgPadding:x,labelBgBorderRadius:p,style:g,markerEnd:y,markerStart:w,interactionWidth:N})})}const rL=MN({isInternal:!1}),RN=MN({isInternal:!0});rL.displayName="StraightEdge";RN.displayName="StraightEdgeInternal";function ON(e){return v.memo(({id:n,sourceX:s,sourceY:i,targetX:l,targetY:d,sourcePosition:c=mt.Bottom,targetPosition:h=mt.Top,label:m,labelStyle:f,labelShowBg:x,labelBgStyle:p,labelBgPadding:g,labelBgBorderRadius:y,style:w,markerEnd:N,markerStart:T,pathOptions:C,interactionWidth:_})=>{const[k,M,D]=Yw({sourceX:s,sourceY:i,sourcePosition:c,targetX:l,targetY:d,targetPosition:h,curvature:C?.curvature}),A=e.isInternal?void 0:n;return t.jsx(ku,{id:A,path:k,labelX:M,labelY:D,label:m,labelStyle:f,labelShowBg:x,labelBgStyle:p,labelBgPadding:g,labelBgBorderRadius:y,style:w,markerEnd:N,markerStart:T,interactionWidth:_})})}const sL=ON({isInternal:!1}),DN=ON({isInternal:!0});sL.displayName="BezierEdge";DN.displayName="BezierEdgeInternal";const Qv={default:DN,straight:RN,step:AN,smoothstep:TN,simplebezier:SN},Zv={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},aL=(e,n,s)=>s===mt.Left?e-n:s===mt.Right?e+n:e,iL=(e,n,s)=>s===mt.Top?e-n:s===mt.Bottom?e+n:e,Jv="react-flow__edgeupdater";function e1({position:e,centerX:n,centerY:s,radius:i=10,onMouseDown:l,onMouseEnter:d,onMouseOut:c,type:h}){return t.jsx("circle",{onMouseDown:l,onMouseEnter:d,onMouseOut:c,className:er([Jv,`${Jv}-${h}`]),cx:aL(n,i,e),cy:iL(s,i,e),r:i,stroke:"transparent",fill:"transparent"})}function lL({isReconnectable:e,reconnectRadius:n,edge:s,sourceX:i,sourceY:l,targetX:d,targetY:c,sourcePosition:h,targetPosition:m,onReconnect:f,onReconnectStart:x,onReconnectEnd:p,setReconnecting:g,setUpdateHover:y}){const w=Bn(),N=(M,D)=>{if(M.button!==0)return;const{autoPanOnConnect:A,domNode:G,connectionMode:X,connectionRadius:K,lib:$,onConnectStart:q,cancelConnection:U,nodeLookup:z,rfId:E,panBy:L,updateConnection:R}=w.getState(),F=D.type==="target",Y=(O,V)=>{g(!1),p?.(O,s,D.type,V)},Z=O=>f?.(s,O),B=(O,V)=>{g(!0),x?.(M,s,D.type),q?.(O,V)};Jm.onPointerDown(M.nativeEvent,{autoPanOnConnect:A,connectionMode:X,connectionRadius:K,domNode:G,handleId:D.id,nodeId:D.nodeId,nodeLookup:z,isTarget:F,edgeUpdaterType:D.type,lib:$,flowId:E,cancelConnection:U,panBy:L,isValidConnection:(...O)=>w.getState().isValidConnection?.(...O)??!0,onConnect:Z,onConnectStart:B,onConnectEnd:(...O)=>w.getState().onConnectEnd?.(...O),onReconnectEnd:Y,updateConnection:R,getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,dragThreshold:w.getState().connectionDragThreshold,handleDomNode:M.currentTarget})},T=M=>N(M,{nodeId:s.target,id:s.targetHandle??null,type:"target"}),C=M=>N(M,{nodeId:s.source,id:s.sourceHandle??null,type:"source"}),_=()=>y(!0),k=()=>y(!1);return t.jsxs(t.Fragment,{children:[(e===!0||e==="source")&&t.jsx(e1,{position:h,centerX:i,centerY:l,radius:n,onMouseDown:T,onMouseEnter:_,onMouseOut:k,type:"source"}),(e===!0||e==="target")&&t.jsx(e1,{position:m,centerX:d,centerY:c,radius:n,onMouseDown:C,onMouseEnter:_,onMouseOut:k,type:"target"})]})}function oL({id:e,edgesFocusable:n,edgesReconnectable:s,elementsSelectable:i,onClick:l,onDoubleClick:d,onContextMenu:c,onMouseEnter:h,onMouseMove:m,onMouseLeave:f,reconnectRadius:x,onReconnect:p,onReconnectStart:g,onReconnectEnd:y,rfId:w,edgeTypes:N,noPanClassName:T,onError:C,disableKeyboardA11y:_}){let k=tn(De=>De.edgeLookup.get(e));const M=tn(De=>De.defaultEdgeOptions);k=M?{...M,...k}:k;let D=k.type||"default",A=N?.[D]||Qv[D];A===void 0&&(C?.("011",Ls.error011(D)),D="default",A=N?.default||Qv.default);const G=!!(k.focusable||n&&typeof k.focusable>"u"),X=typeof p<"u"&&(k.reconnectable||s&&typeof k.reconnectable>"u"),K=!!(k.selectable||i&&typeof k.selectable>"u"),$=v.useRef(null),[q,U]=v.useState(!1),[z,E]=v.useState(!1),L=Bn(),{zIndex:R,sourceX:F,sourceY:Y,targetX:Z,targetY:B,sourcePosition:O,targetPosition:V}=tn(v.useCallback(De=>{const je=De.nodeLookup.get(k.source),ke=De.nodeLookup.get(k.target);if(!je||!ke)return{zIndex:k.zIndex,...Zv};const Se=JR({id:e,sourceNode:je,targetNode:ke,sourceHandle:k.sourceHandle||null,targetHandle:k.targetHandle||null,connectionMode:De.connectionMode,onError:C});return{zIndex:FR({selected:k.selected,zIndex:k.zIndex,sourceNode:je,targetNode:ke,elevateOnSelect:De.elevateEdgesOnSelect,zIndexMode:De.zIndexMode}),...Se||Zv}},[k.source,k.target,k.sourceHandle,k.targetHandle,k.selected,k.zIndex]),$n),I=v.useMemo(()=>k.markerStart?`url('#${Qm(k.markerStart,w)}')`:void 0,[k.markerStart,w]),S=v.useMemo(()=>k.markerEnd?`url('#${Qm(k.markerEnd,w)}')`:void 0,[k.markerEnd,w]);if(k.hidden||F===null||Y===null||Z===null||B===null)return null;const H=De=>{const{addSelectedEdges:je,unselectNodesAndEdges:ke,multiSelectionActive:Se}=L.getState();K&&(L.setState({nodesSelectionActive:!1}),k.selected&&Se?(ke({nodes:[],edges:[k]}),$.current?.blur()):je([e])),l&&l(De,k)},W=d?De=>{d(De,{...k})}:void 0,ee=c?De=>{c(De,{...k})}:void 0,te=h?De=>{h(De,{...k})}:void 0,ae=m?De=>{m(De,{...k})}:void 0,he=f?De=>{f(De,{...k})}:void 0,Ne=De=>{if(!_&&Mw.includes(De.key)&&K){const{unselectNodesAndEdges:je,addSelectedEdges:ke}=L.getState();De.key==="Escape"?($.current?.blur(),je({edges:[k]})):ke([e])}};return t.jsx("svg",{style:{zIndex:R},children:t.jsxs("g",{className:er(["react-flow__edge",`react-flow__edge-${D}`,k.className,T,{selected:k.selected,animated:k.animated,inactive:!K&&!l,updating:q,selectable:K}]),onClick:H,onDoubleClick:W,onContextMenu:ee,onMouseEnter:te,onMouseMove:ae,onMouseLeave:he,onKeyDown:G?Ne: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?`${cN}-${w}`:void 0,ref:$,...k.domAttributes,children:[!z&&t.jsx(A,{id:e,source:k.source,target:k.target,type:k.type,selected:k.selected,animated:k.animated,selectable:K,deletable:k.deletable??!0,label:k.label,labelStyle:k.labelStyle,labelShowBg:k.labelShowBg,labelBgStyle:k.labelBgStyle,labelBgPadding:k.labelBgPadding,labelBgBorderRadius:k.labelBgBorderRadius,sourceX:F,sourceY:Y,targetX:Z,targetY:B,sourcePosition:O,targetPosition:V,data:k.data,style:k.style,sourceHandleId:k.sourceHandle,targetHandleId:k.targetHandle,markerStart:I,markerEnd:S,pathOptions:"pathOptions"in k?k.pathOptions:void 0,interactionWidth:k.interactionWidth}),X&&t.jsx(lL,{edge:k,isReconnectable:X,reconnectRadius:x,onReconnect:p,onReconnectStart:g,onReconnectEnd:y,sourceX:F,sourceY:Y,targetX:Z,targetY:B,sourcePosition:O,targetPosition:V,setUpdateHover:U,setReconnecting:E})]})})}var cL=v.memo(oL);const dL=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function LN({defaultMarkerColor:e,onlyRenderVisibleElements:n,rfId:s,edgeTypes:i,noPanClassName:l,onReconnect:d,onEdgeContextMenu:c,onEdgeMouseEnter:h,onEdgeMouseMove:m,onEdgeMouseLeave:f,onEdgeClick:x,reconnectRadius:p,onEdgeDoubleClick:g,onReconnectStart:y,onReconnectEnd:w,disableKeyboardA11y:N}){const{edgesFocusable:T,edgesReconnectable:C,elementsSelectable:_,onError:k}=tn(dL,$n),M=XD(n);return t.jsxs("div",{className:"react-flow__edges",children:[t.jsx(JD,{defaultColor:e,rfId:s}),M.map(D=>t.jsx(cL,{id:D,edgesFocusable:T,edgesReconnectable:C,elementsSelectable:_,noPanClassName:l,onReconnect:d,onContextMenu:c,onMouseEnter:h,onMouseMove:m,onMouseLeave:f,onClick:x,reconnectRadius:p,onDoubleClick:g,onReconnectStart:y,onReconnectEnd:w,rfId:s,onError:k,edgeTypes:i,disableKeyboardA11y:N},D))]})}LN.displayName="EdgeRenderer";const uL=v.memo(LN),fL=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function hL({children:e}){const n=tn(fL);return t.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:n},children:e})}function mL(e){const n=Vx(),s=v.useRef(!1);v.useEffect(()=>{!s.current&&n.viewportInitialized&&e&&(setTimeout(()=>e(n),1),s.current=!0)},[e,n.viewportInitialized])}const xL=e=>e.panZoom?.syncViewport;function pL(e){const n=tn(xL),s=Bn();return v.useEffect(()=>{e&&(n?.(e),s.setState({transform:[e.x,e.y,e.zoom]}))},[e,n]),null}function gL(e){return e.connection.inProgress?{...e.connection,to:cc(e.connection.to,e.transform)}:{...e.connection}}function bL(e){return gL}function yL(e){const n=bL();return tn(n,$n)}const vL=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function jL({containerStyle:e,style:n,type:s,component:i}){const{nodesConnectable:l,width:d,height:c,isValid:h,inProgress:m}=tn(vL,$n);return!(d&&l&&m)?null:t.jsx("svg",{style:e,width:d,height:c,className:"react-flow__connectionline react-flow__container",children:t.jsx("g",{className:er(["react-flow__connection",Dw(h)]),children:t.jsx(IN,{style:n,type:s,CustomComponent:i,isValid:h})})})}const IN=({style:e,type:n=Ya.Bezier,CustomComponent:s,isValid:i})=>{const{inProgress:l,from:d,fromNode:c,fromHandle:h,fromPosition:m,to:f,toNode:x,toHandle:p,toPosition:g,pointer:y}=yL();if(!l)return;if(s)return t.jsx(s,{connectionLineType:n,connectionLineStyle:e,fromNode:c,fromHandle:h,fromX:d.x,fromY:d.y,toX:f.x,toY:f.y,fromPosition:m,toPosition:g,connectionStatus:Dw(i),toNode:x,toHandle:p,pointer:y});let w="";const N={sourceX:d.x,sourceY:d.y,sourcePosition:m,targetX:f.x,targetY:f.y,targetPosition:g};switch(n){case Ya.Bezier:[w]=Yw(N);break;case Ya.SimpleBezier:[w]=NN(N);break;case Ya.Step:[w]=Wm({...N,borderRadius:0});break;case Ya.SmoothStep:[w]=Wm(N);break;default:[w]=Xw(N)}return t.jsx("path",{d:w,fill:"none",className:"react-flow__connection-path",style:e})};IN.displayName="ConnectionLine";const wL={};function t1(e=wL){v.useRef(e),Bn(),v.useEffect(()=>{},[e])}function NL(){Bn(),v.useRef(!1),v.useEffect(()=>{},[])}function zN({nodeTypes:e,edgeTypes:n,onInit:s,onNodeClick:i,onEdgeClick:l,onNodeDoubleClick:d,onEdgeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:m,onNodeMouseLeave:f,onNodeContextMenu:x,onSelectionContextMenu:p,onSelectionStart:g,onSelectionEnd:y,connectionLineType:w,connectionLineStyle:N,connectionLineComponent:T,connectionLineContainerStyle:C,selectionKeyCode:_,selectionOnDrag:k,selectionMode:M,multiSelectionKeyCode:D,panActivationKeyCode:A,zoomActivationKeyCode:G,deleteKeyCode:X,onlyRenderVisibleElements:K,elementsSelectable:$,defaultViewport:q,translateExtent:U,minZoom:z,maxZoom:E,preventScrolling:L,defaultMarkerColor:R,zoomOnScroll:F,zoomOnPinch:Y,panOnScroll:Z,panOnScrollSpeed:B,panOnScrollMode:O,zoomOnDoubleClick:V,panOnDrag:I,onPaneClick:S,onPaneMouseEnter:H,onPaneMouseMove:W,onPaneMouseLeave:ee,onPaneScroll:te,onPaneContextMenu:ae,paneClickDistance:he,nodeClickDistance:Ne,onEdgeContextMenu:De,onEdgeMouseEnter:je,onEdgeMouseMove:ke,onEdgeMouseLeave:Se,reconnectRadius:Le,onReconnect:nt,onReconnectStart:rt,onReconnectEnd:yt,noDragClassName:Rt,noWheelClassName:re,noPanClassName:_e,disableKeyboardA11y:st,nodeExtent:dt,rfId:Yt,viewport:ye,onViewportChange:Ae}){return t1(e),t1(n),NL(),mL(s),pL(ye),t.jsx($D,{onPaneClick:S,onPaneMouseEnter:H,onPaneMouseMove:W,onPaneMouseLeave:ee,onPaneContextMenu:ae,onPaneScroll:te,paneClickDistance:he,deleteKeyCode:X,selectionKeyCode:_,selectionOnDrag:k,selectionMode:M,onSelectionStart:g,onSelectionEnd:y,multiSelectionKeyCode:D,panActivationKeyCode:A,zoomActivationKeyCode:G,elementsSelectable:$,zoomOnScroll:F,zoomOnPinch:Y,zoomOnDoubleClick:V,panOnScroll:Z,panOnScrollSpeed:B,panOnScrollMode:O,panOnDrag:I,defaultViewport:q,translateExtent:U,minZoom:z,maxZoom:E,onSelectionContextMenu:p,preventScrolling:L,noDragClassName:Rt,noWheelClassName:re,noPanClassName:_e,disableKeyboardA11y:st,onViewportChange:Ae,isControlledViewport:!!ye,children:t.jsxs(hL,{children:[t.jsx(uL,{edgeTypes:n,onEdgeClick:l,onEdgeDoubleClick:c,onReconnect:nt,onReconnectStart:rt,onReconnectEnd:yt,onlyRenderVisibleElements:K,onEdgeContextMenu:De,onEdgeMouseEnter:je,onEdgeMouseMove:ke,onEdgeMouseLeave:Se,reconnectRadius:Le,defaultMarkerColor:R,noPanClassName:_e,disableKeyboardA11y:st,rfId:Yt}),t.jsx(jL,{style:N,type:w,component:T,containerStyle:C}),t.jsx("div",{className:"react-flow__edgelabel-renderer"}),t.jsx(GD,{nodeTypes:e,onNodeClick:i,onNodeDoubleClick:d,onNodeMouseEnter:h,onNodeMouseMove:m,onNodeMouseLeave:f,onNodeContextMenu:x,nodeClickDistance:Ne,onlyRenderVisibleElements:K,noPanClassName:_e,noDragClassName:Rt,disableKeyboardA11y:st,nodeExtent:dt,rfId:Yt}),t.jsx("div",{className:"react-flow__viewport-portal"})]})})}zN.displayName="GraphView";const kL=v.memo(zN),n1=({nodes:e,edges:n,defaultNodes:s,defaultEdges:i,width:l,height:d,fitView:c,fitViewOptions:h,minZoom:m=.5,maxZoom:f=2,nodeOrigin:x,nodeExtent:p,zIndexMode:g="basic"}={})=>{const y=new Map,w=new Map,N=new Map,T=new Map,C=i??n??[],_=s??e??[],k=x??[0,0],M=p??Xo;Qw(N,T,C);const D=Zm(_,y,w,{nodeOrigin:k,nodeExtent:M,zIndexMode:g});let A=[0,0,1];if(c&&l&&d){const G=lc(y,{filter:q=>!!((q.width||q.initialWidth)&&(q.height||q.initialHeight))}),{x:X,y:K,zoom:$}=zx(G,l,d,m,f,h?.padding??.1);A=[X,K,$]}return{rfId:"1",width:l??0,height:d??0,transform:A,nodes:_,nodesInitialized:D,nodeLookup:y,parentLookup:w,edges:C,edgeLookup:T,connectionLookup:N,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:s!==void 0,hasDefaultEdges:i!==void 0,panZoom:null,minZoom:m,maxZoom:f,translateExtent:Xo,nodeExtent:M,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:wl.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:{...Ow},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:BR,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Rw,zIndexMode:g,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},SL=({nodes:e,edges:n,defaultNodes:s,defaultEdges:i,width:l,height:d,fitView:c,fitViewOptions:h,minZoom:m,maxZoom:f,nodeOrigin:x,nodeExtent:p,zIndexMode:g})=>UO((y,w)=>{async function N(){const{nodeLookup:T,panZoom:C,fitViewOptions:_,fitViewResolver:k,width:M,height:D,minZoom:A,maxZoom:G}=w();C&&(await zR({nodes:T,width:M,height:D,panZoom:C,minZoom:A,maxZoom:G},_),k?.resolve(!0),y({fitViewResolver:null}))}return{...n1({nodes:e,edges:n,width:l,height:d,fitView:c,fitViewOptions:h,minZoom:m,maxZoom:f,nodeOrigin:x,nodeExtent:p,defaultNodes:s,defaultEdges:i,zIndexMode:g}),setNodes:T=>{const{nodeLookup:C,parentLookup:_,nodeOrigin:k,elevateNodesOnSelect:M,fitViewQueued:D,zIndexMode:A}=w(),G=Zm(T,C,_,{nodeOrigin:k,nodeExtent:p,elevateNodesOnSelect:M,checkEquality:!0,zIndexMode:A});D&&G?(N(),y({nodes:T,nodesInitialized:G,fitViewQueued:!1,fitViewOptions:void 0})):y({nodes:T,nodesInitialized:G})},setEdges:T=>{const{connectionLookup:C,edgeLookup:_}=w();Qw(C,_,T),y({edges:T})},setDefaultNodesAndEdges:(T,C)=>{if(T){const{setNodes:_}=w();_(T),y({hasDefaultNodes:!0})}if(C){const{setEdges:_}=w();_(C),y({hasDefaultEdges:!0})}},updateNodeInternals:T=>{const{triggerNodeChanges:C,nodeLookup:_,parentLookup:k,domNode:M,nodeOrigin:D,nodeExtent:A,debug:G,fitViewQueued:X,zIndexMode:K}=w(),{changes:$,updatedInternals:q}=lO(T,_,k,M,D,A,K);q&&(rO(_,k,{nodeOrigin:D,nodeExtent:A,zIndexMode:K}),X?(N(),y({fitViewQueued:!1,fitViewOptions:void 0})):y({}),$?.length>0&&(G&&console.log("React Flow: trigger node changes",$),C?.($)))},updateNodePositions:(T,C=!1)=>{const _=[];let k=[];const{nodeLookup:M,triggerNodeChanges:D,connection:A,updateConnection:G,onNodesChangeMiddlewareMap:X}=w();for(const[K,$]of T){const q=M.get(K),U=!!(q?.expandParent&&q?.parentId&&$?.position),z={id:K,type:"position",position:U?{x:Math.max(0,$.position.x),y:Math.max(0,$.position.y)}:$.position,dragging:C};if(q&&A.inProgress&&A.fromNode.id===q.id){const E=Ei(q,A.fromHandle,mt.Left,!0);G({...A,from:E})}U&&q.parentId&&_.push({id:K,parentId:q.parentId,rect:{...$.internals.positionAbsolute,width:$.measured.width??0,height:$.measured.height??0}}),k.push(z)}if(_.length>0){const{parentLookup:K,nodeOrigin:$}=w(),q=Ux(_,M,K,$);k.push(...q)}for(const K of X.values())k=K(k);D(k)},triggerNodeChanges:T=>{const{onNodesChange:C,setNodes:_,nodes:k,hasDefaultNodes:M,debug:D}=w();if(T?.length){if(M){const A=fN(T,k);_(A)}D&&console.log("React Flow: trigger node changes",T),C?.(T)}},triggerEdgeChanges:T=>{const{onEdgesChange:C,setEdges:_,edges:k,hasDefaultEdges:M,debug:D}=w();if(T?.length){if(M){const A=hN(T,k);_(A)}D&&console.log("React Flow: trigger edge changes",T),C?.(T)}},addSelectedNodes:T=>{const{multiSelectionActive:C,edgeLookup:_,nodeLookup:k,triggerNodeChanges:M,triggerEdgeChanges:D}=w();if(C){const A=T.map(G=>pi(G,!0));M(A);return}M(xl(k,new Set([...T]),!0)),D(xl(_))},addSelectedEdges:T=>{const{multiSelectionActive:C,edgeLookup:_,nodeLookup:k,triggerNodeChanges:M,triggerEdgeChanges:D}=w();if(C){const A=T.map(G=>pi(G,!0));D(A);return}D(xl(_,new Set([...T]))),M(xl(k,new Set,!0))},unselectNodesAndEdges:({nodes:T,edges:C}={})=>{const{edges:_,nodes:k,nodeLookup:M,triggerNodeChanges:D,triggerEdgeChanges:A}=w(),G=T||k,X=C||_,K=[];for(const q of G){if(!q.selected)continue;const U=M.get(q.id);U&&(U.selected=!1),K.push(pi(q.id,!1))}const $=[];for(const q of X)q.selected&&$.push(pi(q.id,!1));D(K),A($)},setMinZoom:T=>{const{panZoom:C,maxZoom:_}=w();C?.setScaleExtent([T,_]),y({minZoom:T})},setMaxZoom:T=>{const{panZoom:C,minZoom:_}=w();C?.setScaleExtent([_,T]),y({maxZoom:T})},setTranslateExtent:T=>{w().panZoom?.setTranslateExtent(T),y({translateExtent:T})},resetSelectedElements:()=>{const{edges:T,nodes:C,triggerNodeChanges:_,triggerEdgeChanges:k,elementsSelectable:M}=w();if(!M)return;const D=C.reduce((G,X)=>X.selected?[...G,pi(X.id,!1)]:G,[]),A=T.reduce((G,X)=>X.selected?[...G,pi(X.id,!1)]:G,[]);_(D),k(A)},setNodeExtent:T=>{const{nodes:C,nodeLookup:_,parentLookup:k,nodeOrigin:M,elevateNodesOnSelect:D,nodeExtent:A,zIndexMode:G}=w();T[0][0]===A[0][0]&&T[0][1]===A[0][1]&&T[1][0]===A[1][0]&&T[1][1]===A[1][1]||(Zm(C,_,k,{nodeOrigin:M,nodeExtent:T,elevateNodesOnSelect:D,checkEquality:!1,zIndexMode:G}),y({nodeExtent:T}))},panBy:T=>{const{transform:C,width:_,height:k,panZoom:M,translateExtent:D}=w();return oO({delta:T,panZoom:M,transform:C,translateExtent:D,width:_,height:k})},setCenter:async(T,C,_)=>{const{width:k,height:M,maxZoom:D,panZoom:A}=w();if(!A)return Promise.resolve(!1);const G=typeof _?.zoom<"u"?_.zoom:D;return await A.setViewport({x:k/2-T*G,y:M/2-C*G,zoom:G},{duration:_?.duration,ease:_?.ease,interpolate:_?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{y({connection:{...Ow}})},updateConnection:T=>{y({connection:T})},reset:()=>y({...n1()})}},Object.is);function CL({initialNodes:e,initialEdges:n,defaultNodes:s,defaultEdges:i,initialWidth:l,initialHeight:d,initialMinZoom:c,initialMaxZoom:h,initialFitViewOptions:m,fitView:f,nodeOrigin:x,nodeExtent:p,zIndexMode:g,children:y}){const[w]=v.useState(()=>SL({nodes:e,edges:n,defaultNodes:s,defaultEdges:i,width:l,height:d,fitView:f,minZoom:c,maxZoom:h,fitViewOptions:m,nodeOrigin:x,nodeExtent:p,zIndexMode:g}));return t.jsx(VO,{value:w,children:t.jsx(hD,{children:y})})}function EL({children:e,nodes:n,edges:s,defaultNodes:i,defaultEdges:l,width:d,height:c,fitView:h,fitViewOptions:m,minZoom:f,maxZoom:x,nodeOrigin:p,nodeExtent:g,zIndexMode:y}){return v.useContext(ju)?t.jsx(t.Fragment,{children:e}):t.jsx(CL,{initialNodes:n,initialEdges:s,defaultNodes:i,defaultEdges:l,initialWidth:d,initialHeight:c,fitView:h,initialFitViewOptions:m,initialMinZoom:f,initialMaxZoom:x,nodeOrigin:p,nodeExtent:g,zIndexMode:y,children:e})}const TL={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function _L({nodes:e,edges:n,defaultNodes:s,defaultEdges:i,className:l,nodeTypes:d,edgeTypes:c,onNodeClick:h,onEdgeClick:m,onInit:f,onMove:x,onMoveStart:p,onMoveEnd:g,onConnect:y,onConnectStart:w,onConnectEnd:N,onClickConnectStart:T,onClickConnectEnd:C,onNodeMouseEnter:_,onNodeMouseMove:k,onNodeMouseLeave:M,onNodeContextMenu:D,onNodeDoubleClick:A,onNodeDragStart:G,onNodeDrag:X,onNodeDragStop:K,onNodesDelete:$,onEdgesDelete:q,onDelete:U,onSelectionChange:z,onSelectionDragStart:E,onSelectionDrag:L,onSelectionDragStop:R,onSelectionContextMenu:F,onSelectionStart:Y,onSelectionEnd:Z,onBeforeDelete:B,connectionMode:O,connectionLineType:V=Ya.Bezier,connectionLineStyle:I,connectionLineComponent:S,connectionLineContainerStyle:H,deleteKeyCode:W="Backspace",selectionKeyCode:ee="Shift",selectionOnDrag:te=!1,selectionMode:ae=Ko.Full,panActivationKeyCode:he="Space",multiSelectionKeyCode:Ne=Qo()?"Meta":"Control",zoomActivationKeyCode:De=Qo()?"Meta":"Control",snapToGrid:je,snapGrid:ke,onlyRenderVisibleElements:Se=!1,selectNodesOnDrag:Le,nodesDraggable:nt,autoPanOnNodeFocus:rt,nodesConnectable:yt,nodesFocusable:Rt,nodeOrigin:re=dN,edgesFocusable:_e,edgesReconnectable:st,elementsSelectable:dt=!0,defaultViewport:Yt=rD,minZoom:ye=.5,maxZoom:Ae=2,translateExtent:Fe=Xo,preventScrolling:Qe=!0,nodeExtent:xt,defaultMarkerColor:nn="#b1b1b7",zoomOnScroll:cn=!0,zoomOnPinch:Tt=!0,panOnScroll:gt=!1,panOnScrollSpeed:Bt=.5,panOnScrollMode:_t=ji.Free,zoomOnDoubleClick:Ht=!0,panOnDrag:rn=!0,onPaneClick:bn,onPaneMouseEnter:Hn,onPaneMouseMove:Cn,onPaneMouseLeave:xe,onPaneScroll:Re,onPaneContextMenu:vt,paneClickDistance:At=1,nodeClickDistance:Dt=0,children:On,onReconnect:an,onReconnectStart:dn,onReconnectEnd:Dn,onEdgeContextMenu:Nt,onEdgeDoubleClick:hn,onEdgeMouseEnter:lr,onEdgeMouseMove:le,onEdgeMouseLeave:$e,reconnectRadius:Ue=10,onNodesChange:We,onEdgesChange:Ke,noDragClassName:qe="nodrag",noWheelClassName:Je="nowheel",noPanClassName:Wt="nopan",fitView:Zt,fitViewOptions:Pt,connectOnClick:En,attributionPosition:be,proOptions:ze,defaultEdgeOptions:Et,elevateNodesOnSelect:kt=!0,elevateEdgesOnSelect:yn=!1,disableKeyboardA11y:_n=!1,autoPanOnConnect:or,autoPanOnNodeDrag:Nn,autoPanSpeed:yr,connectionRadius:Hr,isValidConnection:de,onError:Te,style:Ve,id:qt,nodeDragThreshold:vr,connectionDragThreshold:ts,viewport:Nr,onViewportChange:Ns,width:xr,height:tr,colorMode:$s="light",debug:Bs,onScroll:Pr,ariaLabelConfig:ha,zIndexMode:qr="basic",...ma},Yn){const kr=qt||"1",fs=lD($s),Sr=v.useCallback(cr=>{cr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Pr?.(cr)},[Pr]);return t.jsx("div",{"data-testid":"rf__wrapper",...ma,onScroll:Sr,style:{...Ve,...TL},ref:Yn,className:er(["react-flow",l,fs]),id:qt,role:"application",children:t.jsxs(EL,{nodes:e,edges:n,width:xr,height:tr,fitView:Zt,fitViewOptions:Pt,minZoom:ye,maxZoom:Ae,nodeOrigin:re,nodeExtent:xt,zIndexMode:qr,children:[t.jsx(kL,{onInit:f,onNodeClick:h,onEdgeClick:m,onNodeMouseEnter:_,onNodeMouseMove:k,onNodeMouseLeave:M,onNodeContextMenu:D,onNodeDoubleClick:A,nodeTypes:d,edgeTypes:c,connectionLineType:V,connectionLineStyle:I,connectionLineComponent:S,connectionLineContainerStyle:H,selectionKeyCode:ee,selectionOnDrag:te,selectionMode:ae,deleteKeyCode:W,multiSelectionKeyCode:Ne,panActivationKeyCode:he,zoomActivationKeyCode:De,onlyRenderVisibleElements:Se,defaultViewport:Yt,translateExtent:Fe,minZoom:ye,maxZoom:Ae,preventScrolling:Qe,zoomOnScroll:cn,zoomOnPinch:Tt,zoomOnDoubleClick:Ht,panOnScroll:gt,panOnScrollSpeed:Bt,panOnScrollMode:_t,panOnDrag:rn,onPaneClick:bn,onPaneMouseEnter:Hn,onPaneMouseMove:Cn,onPaneMouseLeave:xe,onPaneScroll:Re,onPaneContextMenu:vt,paneClickDistance:At,nodeClickDistance:Dt,onSelectionContextMenu:F,onSelectionStart:Y,onSelectionEnd:Z,onReconnect:an,onReconnectStart:dn,onReconnectEnd:Dn,onEdgeContextMenu:Nt,onEdgeDoubleClick:hn,onEdgeMouseEnter:lr,onEdgeMouseMove:le,onEdgeMouseLeave:$e,reconnectRadius:Ue,defaultMarkerColor:nn,noDragClassName:qe,noWheelClassName:Je,noPanClassName:Wt,rfId:kr,disableKeyboardA11y:_n,nodeExtent:xt,viewport:Nr,onViewportChange:Ns}),t.jsx(iD,{nodes:e,edges:n,defaultNodes:s,defaultEdges:i,onConnect:y,onConnectStart:w,onConnectEnd:N,onClickConnectStart:T,onClickConnectEnd:C,nodesDraggable:nt,autoPanOnNodeFocus:rt,nodesConnectable:yt,nodesFocusable:Rt,edgesFocusable:_e,edgesReconnectable:st,elementsSelectable:dt,elevateNodesOnSelect:kt,elevateEdgesOnSelect:yn,minZoom:ye,maxZoom:Ae,nodeExtent:xt,onNodesChange:We,onEdgesChange:Ke,snapToGrid:je,snapGrid:ke,connectionMode:O,translateExtent:Fe,connectOnClick:En,defaultEdgeOptions:Et,fitView:Zt,fitViewOptions:Pt,onNodesDelete:$,onEdgesDelete:q,onDelete:U,onNodeDragStart:G,onNodeDrag:X,onNodeDragStop:K,onSelectionDrag:L,onSelectionDragStart:E,onSelectionDragStop:R,onMove:x,onMoveStart:p,onMoveEnd:g,noPanClassName:Wt,nodeOrigin:re,rfId:kr,autoPanOnConnect:or,autoPanOnNodeDrag:Nn,autoPanSpeed:yr,onError:Te,connectionRadius:Hr,isValidConnection:de,selectNodesOnDrag:Le,nodeDragThreshold:vr,connectionDragThreshold:ts,onBeforeDelete:B,debug:Bs,ariaLabelConfig:ha,zIndexMode:qr}),t.jsx(nD,{onSelectionChange:z}),On,t.jsx(QO,{proOptions:ze,position:be}),t.jsx(WO,{rfId:kr,disableKeyboardA11y:_n})]})})}var AL=mN(_L);function ML(e){const[n,s]=v.useState(e),i=v.useCallback(l=>s(d=>fN(l,d)),[]);return[n,s,i]}function RL(e){const[n,s]=v.useState(e),i=v.useCallback(l=>s(d=>hN(l,d)),[]);return[n,s,i]}function OL({dimensions:e,lineWidth:n,variant:s,className:i}){return t.jsx("path",{strokeWidth:n,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:er(["react-flow__background-pattern",s,i])})}function DL({radius:e,className:n}){return t.jsx("circle",{cx:e,cy:e,r:e,className:er(["react-flow__background-pattern","dots",n])})}var Ga;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Ga||(Ga={}));const LL={[Ga.Dots]:1,[Ga.Lines]:1,[Ga.Cross]:6},IL=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function $N({id:e,variant:n=Ga.Dots,gap:s=20,size:i,lineWidth:l=1,offset:d=0,color:c,bgColor:h,style:m,className:f,patternClassName:x}){const p=v.useRef(null),{transform:g,patternId:y}=tn(IL,$n),w=i||LL[n],N=n===Ga.Dots,T=n===Ga.Cross,C=Array.isArray(s)?s:[s,s],_=[C[0]*g[2]||1,C[1]*g[2]||1],k=w*g[2],M=Array.isArray(d)?d:[d,d],D=T?[k,k]:_,A=[M[0]*g[2]||1+D[0]/2,M[1]*g[2]||1+D[1]/2],G=`${y}${e||""}`;return t.jsxs("svg",{className:er(["react-flow__background",f]),style:{...m,...Nu,"--xy-background-color-props":h,"--xy-background-pattern-color-props":c},ref:p,"data-testid":"rf__background",children:[t.jsx("pattern",{id:G,x:g[0]%_[0],y:g[1]%_[1],width:_[0],height:_[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${A[0]},-${A[1]})`,children:N?t.jsx(DL,{radius:k/2,className:x}):t.jsx(OL,{dimensions:D,lineWidth:l,variant:n,className:x})}),t.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${G})`})]})}$N.displayName="Background";const zL=v.memo($N);function $L(){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 BL(){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 HL(){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 PL(){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 qL(){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 Td({children:e,className:n,...s}){return t.jsx("button",{type:"button",className:er(["react-flow__controls-button",n]),...s,children:e})}const UL=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function BN({style:e,showZoom:n=!0,showFitView:s=!0,showInteractive:i=!0,fitViewOptions:l,onZoomIn:d,onZoomOut:c,onFitView:h,onInteractiveChange:m,className:f,children:x,position:p="bottom-left",orientation:g="vertical","aria-label":y}){const w=Bn(),{isInteractive:N,minZoomReached:T,maxZoomReached:C,ariaLabelConfig:_}=tn(UL,$n),{zoomIn:k,zoomOut:M,fitView:D}=Vx(),A=()=>{k(),d?.()},G=()=>{M(),c?.()},X=()=>{D(l),h?.()},K=()=>{w.setState({nodesDraggable:!N,nodesConnectable:!N,elementsSelectable:!N}),m?.(!N)},$=g==="horizontal"?"horizontal":"vertical";return t.jsxs(wu,{className:er(["react-flow__controls",$,f]),position:p,style:e,"data-testid":"rf__controls","aria-label":y??_["controls.ariaLabel"],children:[n&&t.jsxs(t.Fragment,{children:[t.jsx(Td,{onClick:A,className:"react-flow__controls-zoomin",title:_["controls.zoomIn.ariaLabel"],"aria-label":_["controls.zoomIn.ariaLabel"],disabled:C,children:t.jsx($L,{})}),t.jsx(Td,{onClick:G,className:"react-flow__controls-zoomout",title:_["controls.zoomOut.ariaLabel"],"aria-label":_["controls.zoomOut.ariaLabel"],disabled:T,children:t.jsx(BL,{})})]}),s&&t.jsx(Td,{className:"react-flow__controls-fitview",onClick:X,title:_["controls.fitView.ariaLabel"],"aria-label":_["controls.fitView.ariaLabel"],children:t.jsx(HL,{})}),i&&t.jsx(Td,{className:"react-flow__controls-interactive",onClick:K,title:_["controls.interactive.ariaLabel"],"aria-label":_["controls.interactive.ariaLabel"],children:N?t.jsx(qL,{}):t.jsx(PL,{})}),x]})}BN.displayName="Controls";const VL=v.memo(BN);function FL({id:e,x:n,y:s,width:i,height:l,style:d,color:c,strokeColor:h,strokeWidth:m,className:f,borderRadius:x,shapeRendering:p,selected:g,onClick:y}){const{background:w,backgroundColor:N}=d||{},T=c||w||N;return t.jsx("rect",{className:er(["react-flow__minimap-node",{selected:g},f]),x:n,y:s,rx:x,ry:x,width:i,height:l,style:{fill:T,stroke:h,strokeWidth:m},shapeRendering:p,onClick:y?C=>y(C,e):void 0})}const YL=v.memo(FL),GL=e=>e.nodes.map(n=>n.id),fm=e=>e instanceof Function?e:()=>e;function XL({nodeStrokeColor:e,nodeColor:n,nodeClassName:s="",nodeBorderRadius:i=5,nodeStrokeWidth:l,nodeComponent:d=YL,onClick:c}){const h=tn(GL,$n),m=fm(n),f=fm(e),x=fm(s),p=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return t.jsx(t.Fragment,{children:h.map(g=>t.jsx(WL,{id:g,nodeColorFunc:m,nodeStrokeColorFunc:f,nodeClassNameFunc:x,nodeBorderRadius:i,nodeStrokeWidth:l,NodeComponent:d,onClick:c,shapeRendering:p},g))})}function KL({id:e,nodeColorFunc:n,nodeStrokeColorFunc:s,nodeClassNameFunc:i,nodeBorderRadius:l,nodeStrokeWidth:d,shapeRendering:c,NodeComponent:h,onClick:m}){const{node:f,x,y:p,width:g,height:y}=tn(w=>{const N=w.nodeLookup.get(e);if(!N)return{node:void 0,x:0,y:0,width:0,height:0};const T=N.internals.userNode,{x:C,y:_}=N.internals.positionAbsolute,{width:k,height:M}=fa(T);return{node:T,x:C,y:_,width:k,height:M}},$n);return!f||f.hidden||!Hw(f)?null:t.jsx(h,{x,y:p,width:g,height:y,style:f.style,selected:!!f.selected,className:i(f),color:n(f),borderRadius:l,strokeColor:s(f),strokeWidth:d,shapeRendering:c,onClick:m,id:f.id})}const WL=v.memo(KL);var QL=v.memo(XL);const ZL=200,JL=150,eI=e=>!e.hidden,tI=e=>{const n={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:n,boundingRect:e.nodeLookup.size>0?Bw(lc(e.nodeLookup,{filter:eI}),n):n,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},nI="react-flow__minimap-desc";function HN({style:e,className:n,nodeStrokeColor:s,nodeColor:i,nodeClassName:l="",nodeBorderRadius:d=5,nodeStrokeWidth:c,nodeComponent:h,bgColor:m,maskColor:f,maskStrokeColor:x,maskStrokeWidth:p,position:g="bottom-right",onClick:y,onNodeClick:w,pannable:N=!1,zoomable:T=!1,ariaLabel:C,inversePan:_,zoomStep:k=1,offsetScale:M=5}){const D=Bn(),A=v.useRef(null),{boundingRect:G,viewBB:X,rfId:K,panZoom:$,translateExtent:q,flowWidth:U,flowHeight:z,ariaLabelConfig:E}=tn(tI,$n),L=e?.width??ZL,R=e?.height??JL,F=G.width/L,Y=G.height/R,Z=Math.max(F,Y),B=Z*L,O=Z*R,V=M*Z,I=G.x-(B-G.width)/2-V,S=G.y-(O-G.height)/2-V,H=B+V*2,W=O+V*2,ee=`${nI}-${K}`,te=v.useRef(0),ae=v.useRef();te.current=Z,v.useEffect(()=>{if(A.current&&$)return ae.current=gO({domNode:A.current,panZoom:$,getTransform:()=>D.getState().transform,getViewScale:()=>te.current}),()=>{ae.current?.destroy()}},[$]),v.useEffect(()=>{ae.current?.update({translateExtent:q,width:U,height:z,inversePan:_,pannable:N,zoomStep:k,zoomable:T})},[N,T,_,k,q,U,z]);const he=y?je=>{const[ke,Se]=ae.current?.pointer(je)||[0,0];y(je,{x:ke,y:Se})}:void 0,Ne=w?v.useCallback((je,ke)=>{const Se=D.getState().nodeLookup.get(ke).internals.userNode;w(je,Se)},[]):void 0,De=C??E["minimap.ariaLabel"];return t.jsx(wu,{position:g,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 p=="number"?p*Z:void 0,"--xy-minimap-node-background-color-props":typeof i=="string"?i: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:er(["react-flow__minimap",n]),"data-testid":"rf__minimap",children:t.jsxs("svg",{width:L,height:R,viewBox:`${I} ${S} ${H} ${W}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ee,ref:A,onClick:he,children:[De&&t.jsx("title",{id:ee,children:De}),t.jsx(QL,{onClick:Ne,nodeColor:i,nodeStrokeColor:s,nodeBorderRadius:d,nodeClassName:l,nodeStrokeWidth:c,nodeComponent:h}),t.jsx("path",{className:"react-flow__minimap-mask",d:`M${I-V},${S-V}h${H+V*2}v${W+V*2}h${-H-V*2}z
|
|
62
|
-
M${X.x},${X.y}h${X.width}v${X.height}h${-X.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}HN.displayName="MiniMap";const rI=v.memo(HN),sI=e=>n=>e?`${Math.max(1/n.transform[2],1)}`:void 0,aI={[El.Line]:"right",[El.Handle]:"bottom-right"};function iI({nodeId:e,position:n,variant:s=El.Handle,className:i,style:l=void 0,children:d,color:c,minWidth:h=10,minHeight:m=10,maxWidth:f=Number.MAX_VALUE,maxHeight:x=Number.MAX_VALUE,keepAspectRatio:p=!1,resizeDirection:g,autoScale:y=!0,shouldResize:w,onResizeStart:N,onResize:T,onResizeEnd:C}){const _=bN(),k=typeof e=="string"?e:_,M=Bn(),D=v.useRef(null),A=s===El.Handle,G=tn(v.useCallback(sI(A&&y),[A,y]),$n),X=v.useRef(null),K=n??aI[s];v.useEffect(()=>{if(!(!D.current||!k))return X.current||(X.current=MO({domNode:D.current,nodeId:k,getStoreItems:()=>{const{nodeLookup:q,transform:U,snapGrid:z,snapToGrid:E,nodeOrigin:L,domNode:R}=M.getState();return{nodeLookup:q,transform:U,snapGrid:z,snapToGrid:E,nodeOrigin:L,paneDomNode:R}},onChange:(q,U)=>{const{triggerNodeChanges:z,nodeLookup:E,parentLookup:L,nodeOrigin:R}=M.getState(),F=[],Y={x:q.x,y:q.y},Z=E.get(k);if(Z&&Z.expandParent&&Z.parentId){const B=Z.origin??R,O=q.width??Z.measured.width??0,V=q.height??Z.measured.height??0,I={id:Z.id,parentId:Z.parentId,rect:{width:O,height:V,...Pw({x:q.x??Z.position.x,y:q.y??Z.position.y},{width:O,height:V},Z.parentId,E,B)}},S=Ux([I],E,L,R);F.push(...S),Y.x=q.x?Math.max(B[0]*O,q.x):void 0,Y.y=q.y?Math.max(B[1]*V,q.y):void 0}if(Y.x!==void 0&&Y.y!==void 0){const B={id:k,type:"position",position:{...Y}};F.push(B)}if(q.width!==void 0&&q.height!==void 0){const O={id:k,type:"dimensions",resizing:!0,setAttributes:g?g==="horizontal"?"width":"height":!0,dimensions:{width:q.width,height:q.height}};F.push(O)}for(const B of U){const O={...B,type:"position"};F.push(O)}z(F)},onEnd:({width:q,height:U})=>{const z={id:k,type:"dimensions",resizing:!1,dimensions:{width:q,height:U}};M.getState().triggerNodeChanges([z])}})),X.current.update({controlPosition:K,boundaries:{minWidth:h,minHeight:m,maxWidth:f,maxHeight:x},keepAspectRatio:p,resizeDirection:g,onResizeStart:N,onResize:T,onResizeEnd:C,shouldResize:w}),()=>{X.current?.destroy()}},[K,h,m,f,x,p,N,T,C,w]);const $=K.split("-");return t.jsx("div",{className:er(["react-flow__resize-control","nodrag",...$,s,i]),ref:D,style:{...l,scale:G,...c&&{[A?"backgroundColor":"borderColor"]:c}},children:d})}v.memo(iI);var gn=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports),js=gn((e,n)=>{var s=Object.defineProperty,i=(z,E,L)=>E in z?s(z,E,{enumerable:!0,configurable:!0,writable:!0,value:L}):z[E]=L,l=(z,E)=>()=>(E||z((E={exports:{}}).exports,E),E.exports),d=(z,E,L)=>i(z,typeof E!="symbol"?E+"":E,L),c=l((z,E)=>{var L="\0",R="\0",F="",Y=class{constructor(S){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"),S&&(this._isDirected=Object.hasOwn(S,"directed")?S.directed:!0,this._isMultigraph=Object.hasOwn(S,"multigraph")?S.multigraph:!1,this._isCompound=Object.hasOwn(S,"compound")?S.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[R]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(S){return this._label=S,this}graph(){return this._label}setDefaultNodeLabel(S){return this._defaultNodeLabelFn=S,typeof S!="function"&&(this._defaultNodeLabelFn=()=>S),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var S=this;return this.nodes().filter(H=>Object.keys(S._in[H]).length===0)}sinks(){var S=this;return this.nodes().filter(H=>Object.keys(S._out[H]).length===0)}setNodes(S,H){var W=arguments,ee=this;return S.forEach(function(te){W.length>1?ee.setNode(te,H):ee.setNode(te)}),this}setNode(S,H){return Object.hasOwn(this._nodes,S)?(arguments.length>1&&(this._nodes[S]=H),this):(this._nodes[S]=arguments.length>1?H:this._defaultNodeLabelFn(S),this._isCompound&&(this._parent[S]=R,this._children[S]={},this._children[R][S]=!0),this._in[S]={},this._preds[S]={},this._out[S]={},this._sucs[S]={},++this._nodeCount,this)}node(S){return this._nodes[S]}hasNode(S){return Object.hasOwn(this._nodes,S)}removeNode(S){var H=this;if(Object.hasOwn(this._nodes,S)){var W=ee=>H.removeEdge(H._edgeObjs[ee]);delete this._nodes[S],this._isCompound&&(this._removeFromParentsChildList(S),delete this._parent[S],this.children(S).forEach(function(ee){H.setParent(ee)}),delete this._children[S]),Object.keys(this._in[S]).forEach(W),delete this._in[S],delete this._preds[S],Object.keys(this._out[S]).forEach(W),delete this._out[S],delete this._sucs[S],--this._nodeCount}return this}setParent(S,H){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(H===void 0)H=R;else{H+="";for(var W=H;W!==void 0;W=this.parent(W))if(W===S)throw new Error("Setting "+H+" as parent of "+S+" would create a cycle");this.setNode(H)}return this.setNode(S),this._removeFromParentsChildList(S),this._parent[S]=H,this._children[H][S]=!0,this}_removeFromParentsChildList(S){delete this._children[this._parent[S]][S]}parent(S){if(this._isCompound){var H=this._parent[S];if(H!==R)return H}}children(S=R){if(this._isCompound){var H=this._children[S];if(H)return Object.keys(H)}else{if(S===R)return this.nodes();if(this.hasNode(S))return[]}}predecessors(S){var H=this._preds[S];if(H)return Object.keys(H)}successors(S){var H=this._sucs[S];if(H)return Object.keys(H)}neighbors(S){var H=this.predecessors(S);if(H){let ee=new Set(H);for(var W of this.successors(S))ee.add(W);return Array.from(ee.values())}}isLeaf(S){var H;return this.isDirected()?H=this.successors(S):H=this.neighbors(S),H.length===0}filterNodes(S){var H=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});H.setGraph(this.graph());var W=this;Object.entries(this._nodes).forEach(function([ae,he]){S(ae)&&H.setNode(ae,he)}),Object.values(this._edgeObjs).forEach(function(ae){H.hasNode(ae.v)&&H.hasNode(ae.w)&&H.setEdge(ae,W.edge(ae))});var ee={};function te(ae){var he=W.parent(ae);return he===void 0||H.hasNode(he)?(ee[ae]=he,he):he in ee?ee[he]:te(he)}return this._isCompound&&H.nodes().forEach(ae=>H.setParent(ae,te(ae))),H}setDefaultEdgeLabel(S){return this._defaultEdgeLabelFn=S,typeof S!="function"&&(this._defaultEdgeLabelFn=()=>S),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(S,H){var W=this,ee=arguments;return S.reduce(function(te,ae){return ee.length>1?W.setEdge(te,ae,H):W.setEdge(te,ae),ae}),this}setEdge(){var S,H,W,ee,te=!1,ae=arguments[0];typeof ae=="object"&&ae!==null&&"v"in ae?(S=ae.v,H=ae.w,W=ae.name,arguments.length===2&&(ee=arguments[1],te=!0)):(S=ae,H=arguments[1],W=arguments[3],arguments.length>2&&(ee=arguments[2],te=!0)),S=""+S,H=""+H,W!==void 0&&(W=""+W);var he=O(this._isDirected,S,H,W);if(Object.hasOwn(this._edgeLabels,he))return te&&(this._edgeLabels[he]=ee),this;if(W!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(S),this.setNode(H),this._edgeLabels[he]=te?ee:this._defaultEdgeLabelFn(S,H,W);var Ne=V(this._isDirected,S,H,W);return S=Ne.v,H=Ne.w,Object.freeze(Ne),this._edgeObjs[he]=Ne,Z(this._preds[H],S),Z(this._sucs[S],H),this._in[H][he]=Ne,this._out[S][he]=Ne,this._edgeCount++,this}edge(S,H,W){var ee=arguments.length===1?I(this._isDirected,arguments[0]):O(this._isDirected,S,H,W);return this._edgeLabels[ee]}edgeAsObj(){let S=this.edge(...arguments);return typeof S!="object"?{label:S}:S}hasEdge(S,H,W){var ee=arguments.length===1?I(this._isDirected,arguments[0]):O(this._isDirected,S,H,W);return Object.hasOwn(this._edgeLabels,ee)}removeEdge(S,H,W){var ee=arguments.length===1?I(this._isDirected,arguments[0]):O(this._isDirected,S,H,W),te=this._edgeObjs[ee];return te&&(S=te.v,H=te.w,delete this._edgeLabels[ee],delete this._edgeObjs[ee],B(this._preds[H],S),B(this._sucs[S],H),delete this._in[H][ee],delete this._out[S][ee],this._edgeCount--),this}inEdges(S,H){return this.isDirected()?this.filterEdges(this._in[S],S,H):this.nodeEdges(S,H)}outEdges(S,H){return this.isDirected()?this.filterEdges(this._out[S],S,H):this.nodeEdges(S,H)}nodeEdges(S,H){if(S in this._nodes)return this.filterEdges({...this._in[S],...this._out[S]},S,H)}filterEdges(S,H,W){if(S){var ee=Object.values(S);return W?ee.filter(function(te){return te.v===H&&te.w===W||te.v===W&&te.w===H}):ee}}};function Z(S,H){S[H]?S[H]++:S[H]=1}function B(S,H){--S[H]||delete S[H]}function O(S,H,W,ee){var te=""+H,ae=""+W;if(!S&&te>ae){var he=te;te=ae,ae=he}return te+F+ae+F+(ee===void 0?L:ee)}function V(S,H,W,ee){var te=""+H,ae=""+W;if(!S&&te>ae){var he=te;te=ae,ae=he}var Ne={v:te,w:ae};return ee&&(Ne.name=ee),Ne}function I(S,H){return O(S,H.v,H.w,H.name)}E.exports=Y}),h=l((z,E)=>{E.exports="3.0.2"}),m=l((z,E)=>{E.exports={Graph:c(),version:h()}}),f=l((z,E)=>{var L=c();E.exports={write:R,read:Z};function R(B){var O={options:{directed:B.isDirected(),multigraph:B.isMultigraph(),compound:B.isCompound()},nodes:F(B),edges:Y(B)};return B.graph()!==void 0&&(O.value=structuredClone(B.graph())),O}function F(B){return B.nodes().map(function(O){var V=B.node(O),I=B.parent(O),S={v:O};return V!==void 0&&(S.value=V),I!==void 0&&(S.parent=I),S})}function Y(B){return B.edges().map(function(O){var V=B.edge(O),I={v:O.v,w:O.w};return O.name!==void 0&&(I.name=O.name),V!==void 0&&(I.value=V),I})}function Z(B){var O=new L(B.options).setGraph(B.value);return B.nodes.forEach(function(V){O.setNode(V.v,V.value),V.parent&&O.setParent(V.v,V.parent)}),B.edges.forEach(function(V){O.setEdge({v:V.v,w:V.w,name:V.name},V.value)}),O}}),x=l((z,E)=>{E.exports=R;var L=()=>1;function R(Y,Z,B,O){return F(Y,String(Z),B||L,O||function(V){return Y.outEdges(V)})}function F(Y,Z,B,O){var V={},I=!0,S=0,H=Y.nodes(),W=function(he){var Ne=B(he);V[he.v].distance+Ne<V[he.w].distance&&(V[he.w]={distance:V[he.v].distance+Ne,predecessor:he.v},I=!0)},ee=function(){H.forEach(function(he){O(he).forEach(function(Ne){var De=Ne.v===he?Ne.v:Ne.w,je=De===Ne.v?Ne.w:Ne.v;W({v:De,w:je})})})};H.forEach(function(he){var Ne=he===Z?0:Number.POSITIVE_INFINITY;V[he]={distance:Ne}});for(var te=H.length,ae=1;ae<te&&(I=!1,S++,ee(),!!I);ae++);if(S===te-1&&(I=!1,ee(),I))throw new Error("The graph contains a negative weight cycle");return V}}),p=l((z,E)=>{E.exports=L;function L(R){var F={},Y=[],Z;function B(O){Object.hasOwn(F,O)||(F[O]=!0,Z.push(O),R.successors(O).forEach(B),R.predecessors(O).forEach(B))}return R.nodes().forEach(function(O){Z=[],B(O),Z.length&&Y.push(Z)}),Y}}),g=l((z,E)=>{var L=class{constructor(){d(this,"_arr",[]),d(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(R){return R.key})}has(R){return Object.hasOwn(this._keyIndices,R)}priority(R){var F=this._keyIndices[R];if(F!==void 0)return this._arr[F].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(R,F){var Y=this._keyIndices;if(R=String(R),!Object.hasOwn(Y,R)){var Z=this._arr,B=Z.length;return Y[R]=B,Z.push({key:R,priority:F}),this._decrease(B),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var R=this._arr.pop();return delete this._keyIndices[R.key],this._heapify(0),R.key}decrease(R,F){var Y=this._keyIndices[R];if(F>this._arr[Y].priority)throw new Error("New priority is greater than current priority. Key: "+R+" Old: "+this._arr[Y].priority+" New: "+F);this._arr[Y].priority=F,this._decrease(Y)}_heapify(R){var F=this._arr,Y=2*R,Z=Y+1,B=R;Y<F.length&&(B=F[Y].priority<F[B].priority?Y:B,Z<F.length&&(B=F[Z].priority<F[B].priority?Z:B),B!==R&&(this._swap(R,B),this._heapify(B)))}_decrease(R){for(var F=this._arr,Y=F[R].priority,Z;R!==0&&(Z=R>>1,!(F[Z].priority<Y));)this._swap(R,Z),R=Z}_swap(R,F){var Y=this._arr,Z=this._keyIndices,B=Y[R],O=Y[F];Y[R]=O,Y[F]=B,Z[O.key]=R,Z[B.key]=F}};E.exports=L}),y=l((z,E)=>{var L=g();E.exports=F;var R=()=>1;function F(Z,B,O,V){var I=function(S){return Z.outEdges(S)};return Y(Z,String(B),O||R,V||I)}function Y(Z,B,O,V){var I={},S=new L,H,W,ee=function(te){var ae=te.v!==H?te.v:te.w,he=I[ae],Ne=O(te),De=W.distance+Ne;if(Ne<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+te+" Weight: "+Ne);De<he.distance&&(he.distance=De,he.predecessor=H,S.decrease(ae,De))};for(Z.nodes().forEach(function(te){var ae=te===B?0:Number.POSITIVE_INFINITY;I[te]={distance:ae},S.add(te,ae)});S.size()>0&&(H=S.removeMin(),W=I[H],W.distance!==Number.POSITIVE_INFINITY);)V(H).forEach(ee);return I}}),w=l((z,E)=>{var L=y();E.exports=R;function R(F,Y,Z){return F.nodes().reduce(function(B,O){return B[O]=L(F,O,Y,Z),B},{})}}),N=l((z,E)=>{E.exports=L;function L(F,Y,Z){if(F[Y].predecessor!==void 0)throw new Error("Invalid source vertex");if(F[Z].predecessor===void 0&&Z!==Y)throw new Error("Invalid destination vertex");return{weight:F[Z].distance,path:R(F,Y,Z)}}function R(F,Y,Z){for(var B=[],O=Z;O!==Y;)B.push(O),O=F[O].predecessor;return B.push(Y),B.reverse()}}),T=l((z,E)=>{E.exports=L;function L(R){var F=0,Y=[],Z={},B=[];function O(V){var I=Z[V]={onStack:!0,lowlink:F,index:F++};if(Y.push(V),R.successors(V).forEach(function(W){Object.hasOwn(Z,W)?Z[W].onStack&&(I.lowlink=Math.min(I.lowlink,Z[W].index)):(O(W),I.lowlink=Math.min(I.lowlink,Z[W].lowlink))}),I.lowlink===I.index){var S=[],H;do H=Y.pop(),Z[H].onStack=!1,S.push(H);while(V!==H);B.push(S)}}return R.nodes().forEach(function(V){Object.hasOwn(Z,V)||O(V)}),B}}),C=l((z,E)=>{var L=T();E.exports=R;function R(F){return L(F).filter(function(Y){return Y.length>1||Y.length===1&&F.hasEdge(Y[0],Y[0])})}}),_=l((z,E)=>{E.exports=R;var L=()=>1;function R(Y,Z,B){return F(Y,Z||L,B||function(O){return Y.outEdges(O)})}function F(Y,Z,B){var O={},V=Y.nodes();return V.forEach(function(I){O[I]={},O[I][I]={distance:0},V.forEach(function(S){I!==S&&(O[I][S]={distance:Number.POSITIVE_INFINITY})}),B(I).forEach(function(S){var H=S.v===I?S.w:S.v,W=Z(S);O[I][H]={distance:W,predecessor:I}})}),V.forEach(function(I){var S=O[I];V.forEach(function(H){var W=O[H];V.forEach(function(ee){var te=W[I],ae=S[ee],he=W[ee],Ne=te.distance+ae.distance;Ne<he.distance&&(he.distance=Ne,he.predecessor=ae.predecessor)})})}),O}}),k=l((z,E)=>{function L(F){var Y={},Z={},B=[];function O(V){if(Object.hasOwn(Z,V))throw new R;Object.hasOwn(Y,V)||(Z[V]=!0,Y[V]=!0,F.predecessors(V).forEach(O),delete Z[V],B.push(V))}if(F.sinks().forEach(O),Object.keys(Y).length!==F.nodeCount())throw new R;return B}var R=class extends Error{constructor(){super(...arguments)}};E.exports=L,L.CycleException=R}),M=l((z,E)=>{var L=k();E.exports=R;function R(F){try{L(F)}catch(Y){if(Y instanceof L.CycleException)return!1;throw Y}return!0}}),D=l((z,E)=>{E.exports=L;function L(F,Y,Z,B,O){Array.isArray(Y)||(Y=[Y]);var V=(F.isDirected()?F.successors:F.neighbors).bind(F),I={};return Y.forEach(function(S){if(!F.hasNode(S))throw new Error("Graph does not have node: "+S);O=R(F,S,Z==="post",I,V,B,O)}),O}function R(F,Y,Z,B,O,V,I){return Object.hasOwn(B,Y)||(B[Y]=!0,Z||(I=V(I,Y)),O(Y).forEach(function(S){I=R(F,S,Z,B,O,V,I)}),Z&&(I=V(I,Y))),I}}),A=l((z,E)=>{var L=D();E.exports=R;function R(F,Y,Z){return L(F,Y,Z,function(B,O){return B.push(O),B},[])}}),G=l((z,E)=>{var L=A();E.exports=R;function R(F,Y){return L(F,Y,"post")}}),X=l((z,E)=>{var L=A();E.exports=R;function R(F,Y){return L(F,Y,"pre")}}),K=l((z,E)=>{var L=c(),R=g();E.exports=F;function F(Y,Z){var B=new L,O={},V=new R,I;function S(W){var ee=W.v===I?W.w:W.v,te=V.priority(ee);if(te!==void 0){var ae=Z(W);ae<te&&(O[ee]=I,V.decrease(ee,ae))}}if(Y.nodeCount()===0)return B;Y.nodes().forEach(function(W){V.add(W,Number.POSITIVE_INFINITY),B.setNode(W)}),V.decrease(Y.nodes()[0],0);for(var H=!1;V.size()>0;){if(I=V.removeMin(),Object.hasOwn(O,I))B.setEdge(I,O[I]);else{if(H)throw new Error("Input graph is not connected: "+Y);H=!0}Y.nodeEdges(I).forEach(S)}return B}}),$=l((z,E)=>{var L=y(),R=x();E.exports=F;function F(Z,B,O,V){return Y(Z,B,O,V||function(I){return Z.outEdges(I)})}function Y(Z,B,O,V){if(O===void 0)return L(Z,B,O,V);for(var I=!1,S=Z.nodes(),H=0;H<S.length;H++){for(var W=V(S[H]),ee=0;ee<W.length;ee++){var te=W[ee],ae=te.v===S[H]?te.v:te.w,he=ae===te.v?te.w:te.v;O({v:ae,w:he})<0&&(I=!0)}if(I)return R(Z,B,O,V)}return L(Z,B,O,V)}}),q=l((z,E)=>{E.exports={bellmanFord:x(),components:p(),dijkstra:y(),dijkstraAll:w(),extractPath:N(),findCycles:C(),floydWarshall:_(),isAcyclic:M(),postorder:G(),preorder:X(),prim:K(),shortestPaths:$(),reduce:D(),tarjan:T(),topsort:k()}}),U=m();n.exports={Graph:U.Graph,json:f(),alg:q(),version:U.version}}),lI=gn((e,n)=>{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 i(c),c}enqueue(d){let c=this._sentinel;d._prev&&d._next&&i(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,l)),h=h._prev;return"["+d.join(", ")+"]"}};function i(d){d._prev._next=d._next,d._next._prev=d._prev,delete d._next,delete d._prev}function l(d,c){if(d!=="_next"&&d!=="_prev")return c}n.exports=s}),oI=gn((e,n)=>{var s=js().Graph,i=lI();n.exports=d;var l=()=>1;function d(p,g){if(p.nodeCount()<=1)return[];let y=m(p,g||l);return c(y.graph,y.buckets,y.zeroIdx).flatMap(w=>p.outEdges(w.v,w.w))}function c(p,g,y){let w=[],N=g[g.length-1],T=g[0],C;for(;p.nodeCount();){for(;C=T.dequeue();)h(p,g,y,C);for(;C=N.dequeue();)h(p,g,y,C);if(p.nodeCount()){for(let _=g.length-2;_>0;--_)if(C=g[_].dequeue(),C){w=w.concat(h(p,g,y,C,!0));break}}}return w}function h(p,g,y,w,N){let T=N?[]:void 0;return p.inEdges(w.v).forEach(C=>{let _=p.edge(C),k=p.node(C.v);N&&T.push({v:C.v,w:C.w}),k.out-=_,f(g,y,k)}),p.outEdges(w.v).forEach(C=>{let _=p.edge(C),k=C.w,M=p.node(k);M.in-=_,f(g,y,M)}),p.removeNode(w.v),T}function m(p,g){let y=new s,w=0,N=0;p.nodes().forEach(_=>{y.setNode(_,{v:_,in:0,out:0})}),p.edges().forEach(_=>{let k=y.edge(_.v,_.w)||0,M=g(_),D=k+M;y.setEdge(_.v,_.w,D),N=Math.max(N,y.node(_.v).out+=M),w=Math.max(w,y.node(_.w).in+=M)});let T=x(N+w+3).map(()=>new i),C=w+1;return y.nodes().forEach(_=>{f(T,C,y.node(_))}),{graph:y,buckets:T,zeroIdx:C}}function f(p,g,y){y.out?y.in?p[y.out-y.in+g].enqueue(y):p[p.length-1].enqueue(y):p[0].enqueue(y)}function x(p){let g=[];for(let y=0;y<p;y++)g.push(y);return g}}),Jn=gn((e,n)=>{var s=js().Graph;n.exports={addBorderNode:g,addDummyNode:i,applyWithChunking:N,asNonCompoundGraph:d,buildLayerMatrix:f,intersectRect:m,mapValues:X,maxRank:T,normalizeRanks:x,notime:k,partition:C,pick:G,predecessorWeights:h,range:A,removeEmptyRanks:p,simplify:l,successorWeights:c,time:_,uniqueId:D,zipObject:K};function i($,q,U,z){for(var E=z;$.hasNode(E);)E=D(z);return U.dummy=q,$.setNode(E,U),E}function l($){let q=new s().setGraph($.graph());return $.nodes().forEach(U=>q.setNode(U,$.node(U))),$.edges().forEach(U=>{let z=q.edge(U.v,U.w)||{weight:0,minlen:1},E=$.edge(U);q.setEdge(U.v,U.w,{weight:z.weight+E.weight,minlen:Math.max(z.minlen,E.minlen)})}),q}function d($){let q=new s({multigraph:$.isMultigraph()}).setGraph($.graph());return $.nodes().forEach(U=>{$.children(U).length||q.setNode(U,$.node(U))}),$.edges().forEach(U=>{q.setEdge(U,$.edge(U))}),q}function c($){let q=$.nodes().map(U=>{let z={};return $.outEdges(U).forEach(E=>{z[E.w]=(z[E.w]||0)+$.edge(E).weight}),z});return K($.nodes(),q)}function h($){let q=$.nodes().map(U=>{let z={};return $.inEdges(U).forEach(E=>{z[E.v]=(z[E.v]||0)+$.edge(E).weight}),z});return K($.nodes(),q)}function m($,q){let U=$.x,z=$.y,E=q.x-U,L=q.y-z,R=$.width/2,F=$.height/2;if(!E&&!L)throw new Error("Not possible to find intersection inside of the rectangle");let Y,Z;return Math.abs(L)*R>Math.abs(E)*F?(L<0&&(F=-F),Y=F*E/L,Z=F):(E<0&&(R=-R),Y=R,Z=R*L/E),{x:U+Y,y:z+Z}}function f($){let q=A(T($)+1).map(()=>[]);return $.nodes().forEach(U=>{let z=$.node(U),E=z.rank;E!==void 0&&(q[E][z.order]=U)}),q}function x($){let q=$.nodes().map(z=>{let E=$.node(z).rank;return E===void 0?Number.MAX_VALUE:E}),U=N(Math.min,q);$.nodes().forEach(z=>{let E=$.node(z);Object.hasOwn(E,"rank")&&(E.rank-=U)})}function p($){let q=$.nodes().map(R=>$.node(R).rank).filter(R=>R!==void 0),U=N(Math.min,q),z=[];$.nodes().forEach(R=>{let F=$.node(R).rank-U;z[F]||(z[F]=[]),z[F].push(R)});let E=0,L=$.graph().nodeRankFactor;Array.from(z).forEach((R,F)=>{R===void 0&&F%L!==0?--E:R!==void 0&&E&&R.forEach(Y=>$.node(Y).rank+=E)})}function g($,q,U,z){let E={width:0,height:0};return arguments.length>=4&&(E.rank=U,E.order=z),i($,"border",E,q)}function y($,q=w){let U=[];for(let z=0;z<$.length;z+=q){let E=$.slice(z,z+q);U.push(E)}return U}var w=65535;function N($,q){if(q.length>w){let U=y(q);return $.apply(null,U.map(z=>$.apply(null,z)))}else return $.apply(null,q)}function T($){let q=$.nodes().map(U=>{let z=$.node(U).rank;return z===void 0?Number.MIN_VALUE:z});return N(Math.max,q)}function C($,q){let U={lhs:[],rhs:[]};return $.forEach(z=>{q(z)?U.lhs.push(z):U.rhs.push(z)}),U}function _($,q){let U=Date.now();try{return q()}finally{console.log($+" time: "+(Date.now()-U)+"ms")}}function k($,q){return q()}var M=0;function D($){var q=++M;return $+(""+q)}function A($,q,U=1){q==null&&(q=$,$=0);let z=L=>L<q;U<0&&(z=L=>q<L);let E=[];for(let L=$;z(L);L+=U)E.push(L);return E}function G($,q){let U={};for(let z of q)$[z]!==void 0&&(U[z]=$[z]);return U}function X($,q){let U=q;return typeof q=="string"&&(U=z=>z[q]),Object.entries($).reduce((z,[E,L])=>(z[E]=U(L,E),z),{})}function K($,q){return $.reduce((U,z,E)=>(U[z]=q[E],U),{})}}),cI=gn((e,n)=>{var s=oI(),i=Jn().uniqueId;n.exports={run:l,undo:c};function l(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,i("rev"))});function m(f){return x=>f.edge(x).weight}}function d(h){let m=[],f={},x={};function p(g){Object.hasOwn(x,g)||(x[g]=!0,f[g]=!0,h.outEdges(g).forEach(y=>{Object.hasOwn(f,y.w)?m.push(y):p(y.w)}),delete f[g])}return h.nodes().forEach(p),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)}})}}),dI=gn((e,n)=>{var s=Jn();n.exports={run:i,undo:d};function i(c){c.graph().dummyChains=[],c.edges().forEach(h=>l(c,h))}function l(c,h){let m=h.v,f=c.node(m).rank,x=h.w,p=c.node(x).rank,g=h.name,y=c.edge(h),w=y.labelRank;if(p===f+1)return;c.removeEdge(h);let N,T,C;for(C=0,++f;f<p;++C,++f)y.points=[],T={width:0,height:0,edgeLabel:y,edgeObj:h,rank:f},N=s.addDummyNode(c,"edge",T,"_d"),f===w&&(T.width=y.width,T.height=y.height,T.dummy="edge-label",T.labelpos=y.labelpos),c.setEdge(m,N,{weight:y.weight},g),C===0&&c.graph().dummyChains.push(N),m=N;c.setEdge(m,x,{weight:y.weight},g)}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)})}}),ru=gn((e,n)=>{var{applyWithChunking:s}=Jn();n.exports={longestPath:i,slack:l};function i(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(g=>g==null?Number.POSITIVE_INFINITY:h(g.w)-d.edge(g).minlen);var p=s(Math.min,x);return p===Number.POSITIVE_INFINITY&&(p=0),f.rank=p}d.sources().forEach(h)}function l(d,c){return d.node(c.w).rank-d.node(c.v).rank-d.edge(c).minlen}}),PN=gn((e,n)=>{var s=js().Graph,i=ru().slack;n.exports=l;function l(m){var f=new s({directed:!1}),x=m.nodes()[0],p=m.nodeCount();f.setNode(x,{});for(var g,y;d(f,m)<p;)g=c(f,m),y=f.hasNode(g.v)?i(m,g):-i(m,g),h(f,m,y);return f}function d(m,f){function x(p){f.nodeEdges(p).forEach(g=>{var y=g.v,w=p===y?g.w:y;!m.hasNode(w)&&!i(f,g)&&(m.setNode(w,{}),m.setEdge(p,w,{}),x(w))})}return m.nodes().forEach(x),m.nodeCount()}function c(m,f){return f.edges().reduce((x,p)=>{let g=Number.POSITIVE_INFINITY;return m.hasNode(p.v)!==m.hasNode(p.w)&&(g=i(f,p)),g<x[0]?[g,p]:x},[Number.POSITIVE_INFINITY,null])[1]}function h(m,f,x){m.nodes().forEach(p=>f.node(p).rank+=x)}}),uI=gn((e,n)=>{var s=PN(),i=ru().slack,l=ru().longestPath,d=js().alg.preorder,c=js().alg.postorder,h=Jn().simplify;n.exports=m,m.initLowLimValues=g,m.initCutValues=f,m.calcCutValue=p,m.leaveEdge=w,m.enterEdge=N,m.exchangeEdges=T;function m(M){M=h(M),l(M);var D=s(M);g(D),f(D,M);for(var A,G;A=w(D);)G=N(D,M,A),T(D,M,A,G)}function f(M,D){var A=c(M,M.nodes());A=A.slice(0,A.length-1),A.forEach(G=>x(M,D,G))}function x(M,D,A){var G=M.node(A),X=G.parent;M.edge(A,X).cutvalue=p(M,D,A)}function p(M,D,A){var G=M.node(A),X=G.parent,K=!0,$=D.edge(A,X),q=0;return $||(K=!1,$=D.edge(X,A)),q=$.weight,D.nodeEdges(A).forEach(U=>{var z=U.v===A,E=z?U.w:U.v;if(E!==X){var L=z===K,R=D.edge(U).weight;if(q+=L?R:-R,_(M,A,E)){var F=M.edge(A,E).cutvalue;q+=L?-F:F}}}),q}function g(M,D){arguments.length<2&&(D=M.nodes()[0]),y(M,{},1,D)}function y(M,D,A,G,X){var K=A,$=M.node(G);return D[G]=!0,M.neighbors(G).forEach(q=>{Object.hasOwn(D,q)||(A=y(M,D,A,q,G))}),$.low=K,$.lim=A++,X?$.parent=X:delete $.parent,A}function w(M){return M.edges().find(D=>M.edge(D).cutvalue<0)}function N(M,D,A){var G=A.v,X=A.w;D.hasEdge(G,X)||(G=A.w,X=A.v);var K=M.node(G),$=M.node(X),q=K,U=!1;K.lim>$.lim&&(q=$,U=!0);var z=D.edges().filter(E=>U===k(M,M.node(E.v),q)&&U!==k(M,M.node(E.w),q));return z.reduce((E,L)=>i(D,L)<i(D,E)?L:E)}function T(M,D,A,G){var X=A.v,K=A.w;M.removeEdge(X,K),M.setEdge(G.v,G.w,{}),g(M),f(M,D),C(M,D)}function C(M,D){var A=M.nodes().find(X=>!D.node(X).parent),G=d(M,A);G=G.slice(1),G.forEach(X=>{var K=M.node(X).parent,$=D.edge(X,K),q=!1;$||($=D.edge(K,X),q=!0),D.node(X).rank=D.node(K).rank+(q?$.minlen:-$.minlen)})}function _(M,D,A){return M.hasEdge(D,A)}function k(M,D,A){return A.low<=D.lim&&D.lim<=A.lim}}),fI=gn((e,n)=>{var s=ru(),i=s.longestPath,l=PN(),d=uI();n.exports=c;function c(x){var p=x.graph().ranker;if(p instanceof Function)return p(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=i;function m(x){i(x),l(x)}function f(x){d(x)}}),hI=gn((e,n)=>{n.exports=s;function s(d){let c=l(d);d.graph().dummyChains.forEach(h=>{let m=d.node(h),f=m.edgeObj,x=i(d,c,f.v,f.w),p=x.path,g=x.lca,y=0,w=p[y],N=!0;for(;h!==f.w;){if(m=d.node(h),N){for(;(w=p[y])!==g&&d.node(w).maxRank<m.rank;)y++;w===g&&(N=!1)}if(!N){for(;y<p.length-1&&d.node(w=p[y+1]).minRank<=m.rank;)y++;w=p[y]}d.setParent(h,w),h=d.successors(h)[0]}})}function i(d,c,h,m){let f=[],x=[],p=Math.min(c[h].low,c[m].low),g=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>p||g>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 l(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}}),mI=gn((e,n)=>{var s=Jn();n.exports={run:i,cleanup:h};function i(m){let f=s.addDummyNode(m,"root",{},"_root"),x=d(m),p=Object.values(x),g=s.applyWithChunking(Math.max,p)-1,y=2*g+1;m.graph().nestingRoot=f,m.edges().forEach(N=>m.edge(N).minlen*=y);let w=c(m)+1;m.children().forEach(N=>l(m,f,y,w,g,x,N)),m.graph().nodeRankFactor=y}function l(m,f,x,p,g,y,w){let N=m.children(w);if(!N.length){w!==f&&m.setEdge(f,w,{weight:0,minlen:x});return}let T=s.addBorderNode(m,"_bt"),C=s.addBorderNode(m,"_bb"),_=m.node(w);m.setParent(T,w),_.borderTop=T,m.setParent(C,w),_.borderBottom=C,N.forEach(k=>{l(m,f,x,p,g,y,k);let M=m.node(k),D=M.borderTop?M.borderTop:k,A=M.borderBottom?M.borderBottom:k,G=M.borderTop?p:2*p,X=D!==A?1:g-y[w]+1;m.setEdge(T,D,{weight:G,minlen:X,nestingEdge:!0}),m.setEdge(A,C,{weight:G,minlen:X,nestingEdge:!0})}),m.parent(w)||m.setEdge(f,T,{weight:0,minlen:g+y[w]})}function d(m){var f={};function x(p,g){var y=m.children(p);y&&y.length&&y.forEach(w=>x(w,g+1)),f[p]=g}return m.children().forEach(p=>x(p,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 p=m.edge(x);p.nestingEdge&&m.removeEdge(x)})}}),xI=gn((e,n)=>{var s=Jn();n.exports=i;function i(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,p=f.maxRank+1;x<p;++x)l(d,"borderLeft","_bl",h,f,x),l(d,"borderRight","_br",h,f,x)}}d.children().forEach(c)}function l(d,c,h,m,f,x){let p={width:0,height:0,rank:x,borderType:c},g=f[c][x-1],y=s.addDummyNode(d,"border",p,h);f[c][x]=y,d.setParent(y,m),g&&d.setEdge(g,y,{weight:1})}}),pI=gn((e,n)=>{n.exports={adjust:s,undo:i};function s(x){let p=x.graph().rankdir.toLowerCase();(p==="lr"||p==="rl")&&l(x)}function i(x){let p=x.graph().rankdir.toLowerCase();(p==="bt"||p==="rl")&&c(x),(p==="lr"||p==="rl")&&(m(x),l(x))}function l(x){x.nodes().forEach(p=>d(x.node(p))),x.edges().forEach(p=>d(x.edge(p)))}function d(x){let p=x.width;x.width=x.height,x.height=p}function c(x){x.nodes().forEach(p=>h(x.node(p))),x.edges().forEach(p=>{let g=x.edge(p);g.points.forEach(h),Object.hasOwn(g,"y")&&h(g)})}function h(x){x.y=-x.y}function m(x){x.nodes().forEach(p=>f(x.node(p))),x.edges().forEach(p=>{let g=x.edge(p);g.points.forEach(f),Object.hasOwn(g,"x")&&f(g)})}function f(x){let p=x.x;x.x=x.y,x.y=p}}),gI=gn((e,n)=>{var s=Jn();n.exports=i;function i(l){let d={},c=l.nodes().filter(p=>!l.children(p).length),h=c.map(p=>l.node(p).rank),m=s.applyWithChunking(Math.max,h),f=s.range(m+1).map(()=>[]);function x(p){if(d[p])return;d[p]=!0;let g=l.node(p);f[g.rank].push(p),l.successors(p).forEach(x)}return c.sort((p,g)=>l.node(p).rank-l.node(g).rank).forEach(x),f}}),bI=gn((e,n)=>{var s=Jn().zipObject;n.exports=i;function i(d,c){let h=0;for(let m=1;m<c.length;++m)h+=l(d,c[m-1],c[m]);return h}function l(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,T)=>N.pos-T.pos)),x=1;for(;x<h.length;)x<<=1;let p=2*x-1;x-=1;let g=new Array(p).fill(0),y=0;return f.forEach(w=>{let N=w.pos+x;g[N]+=w.weight;let T=0;for(;N>0;)N%2&&(T+=g[N+1]),N=N-1>>1,g[N]+=w.weight;y+=w.weight*T}),y}}),yI=gn((e,n)=>{n.exports=s;function s(i,l=[]){return l.map(d=>{let c=i.inEdges(d);if(c.length){let h=c.reduce((m,f)=>{let x=i.edge(f),p=i.node(f.v);return{sum:m.sum+x.weight*p.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}})}}),vI=gn((e,n)=>{var s=Jn();n.exports=i;function i(c,h){let m={};c.forEach((x,p)=>{let g=m[x.v]={indegree:0,in:[],out:[],vs:[x.v],i:p};x.barycenter!==void 0&&(g.barycenter=x.barycenter,g.weight=x.weight)}),h.edges().forEach(x=>{let p=m[x.v],g=m[x.w];p!==void 0&&g!==void 0&&(g.indegree++,p.out.push(m[x.w]))});let f=Object.values(m).filter(x=>!x.indegree);return l(f)}function l(c){let h=[];function m(x){return p=>{p.merged||(p.barycenter===void 0||x.barycenter===void 0||p.barycenter>=x.barycenter)&&d(x,p)}}function f(x){return p=>{p.in.push(x),--p.indegree===0&&c.push(p)}}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}}),jI=gn((e,n)=>{var s=Jn();n.exports=i;function i(c,h){let m=s.partition(c,T=>Object.hasOwn(T,"barycenter")),f=m.lhs,x=m.rhs.sort((T,C)=>C.i-T.i),p=[],g=0,y=0,w=0;f.sort(d(!!h)),w=l(p,x,w),f.forEach(T=>{w+=T.vs.length,p.push(T.vs),g+=T.barycenter*T.weight,y+=T.weight,w=l(p,x,w)});let N={vs:p.flat(!0)};return y&&(N.barycenter=g/y,N.weight=y),N}function l(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}}),wI=gn((e,n)=>{var s=yI(),i=vI(),l=jI();n.exports=d;function d(m,f,x,p){let g=m.children(f),y=m.node(f),w=y?y.borderLeft:void 0,N=y?y.borderRight:void 0,T={};w&&(g=g.filter(M=>M!==w&&M!==N));let C=s(m,g);C.forEach(M=>{if(m.children(M.v).length){let D=d(m,M.v,x,p);T[M.v]=D,Object.hasOwn(D,"barycenter")&&h(M,D)}});let _=i(C,x);c(_,T);let k=l(_,p);if(w&&(k.vs=[w,k.vs,N].flat(!0),m.predecessors(w).length)){let M=m.node(m.predecessors(w)[0]),D=m.node(m.predecessors(N)[0]);Object.hasOwn(k,"barycenter")||(k.barycenter=0,k.weight=0),k.barycenter=(k.barycenter*k.weight+M.order+D.order)/(k.weight+2),k.weight+=2}return k}function c(m,f){m.forEach(x=>{x.vs=x.vs.flatMap(p=>f[p]?f[p].vs:p)})}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)}}),NI=gn((e,n)=>{var s=js().Graph,i=Jn();n.exports=l;function l(c,h,m,f){f||(f=c.nodes());let x=d(c),p=new s({compound:!0}).setGraph({root:x}).setDefaultNodeLabel(g=>c.node(g));return f.forEach(g=>{let y=c.node(g),w=c.parent(g);(y.rank===h||y.minRank<=h&&h<=y.maxRank)&&(p.setNode(g),p.setParent(g,w||x),c[m](g).forEach(N=>{let T=N.v===g?N.w:N.v,C=p.edge(T,g),_=C!==void 0?C.weight:0;p.setEdge(T,g,{weight:c.edge(N).weight+_})}),Object.hasOwn(y,"minRank")&&p.setNode(g,{borderLeft:y.borderLeft[h],borderRight:y.borderRight[h]}))}),p}function d(c){for(var h;c.hasNode(h=i.uniqueId("_root")););return h}}),kI=gn((e,n)=>{n.exports=s;function s(i,l,d){let c={},h;d.forEach(m=>{let f=i.parent(m),x,p;for(;f;){if(x=i.parent(f),x?(p=c[x],c[x]=f):(p=h,h=f),p&&p!==f){l.setEdge(p,f);return}f=x}})}}),SI=gn((e,n)=>{var s=gI(),i=bI(),l=wI(),d=NI(),c=kI(),h=js().Graph,m=Jn();n.exports=f;function f(y,w={}){if(typeof w.customOrder=="function"){w.customOrder(y,f);return}let N=m.maxRank(y),T=x(y,m.range(1,N+1),"inEdges"),C=x(y,m.range(N-1,-1,-1),"outEdges"),_=s(y);if(g(y,_),w.disableOptimalOrderHeuristic)return;let k=Number.POSITIVE_INFINITY,M,D=w.constraints||[];for(let A=0,G=0;G<4;++A,++G){p(A%2?T:C,A%4>=2,D),_=m.buildLayerMatrix(y);let X=i(y,_);X<k?(G=0,M=Object.assign({},_),k=X):X===k&&(M=structuredClone(_))}g(y,M)}function x(y,w,N){let T=new Map,C=(_,k)=>{T.has(_)||T.set(_,[]),T.get(_).push(k)};for(let _ of y.nodes()){let k=y.node(_);if(typeof k.rank=="number"&&C(k.rank,_),typeof k.minRank=="number"&&typeof k.maxRank=="number")for(let M=k.minRank;M<=k.maxRank;M++)M!==k.rank&&C(M,_)}return w.map(function(_){return d(y,_,N,T.get(_)||[])})}function p(y,w,N){let T=new h;y.forEach(function(C){N.forEach(M=>T.setEdge(M.left,M.right));let _=C.graph().root,k=l(C,_,T,w);k.vs.forEach((M,D)=>C.node(M).order=D),c(C,T,k.vs)})}function g(y,w){Object.values(w).forEach(N=>N.forEach((T,C)=>y.node(T).order=C))}}),CI=gn((e,n)=>{var s=js().Graph,i=Jn();n.exports={positionX:N,findType1Conflicts:l,findType2Conflicts:d,addConflict:h,hasConflict:m,verticalAlignment:f,horizontalCompaction:x,alignCoordinates:y,findSmallestWidthAlignment:g,balance:w};function l(_,k){let M={};function D(A,G){let X=0,K=0,$=A.length,q=G[G.length-1];return G.forEach((U,z)=>{let E=c(_,U),L=E?_.node(E).order:$;(E||U===q)&&(G.slice(K,z+1).forEach(R=>{_.predecessors(R).forEach(F=>{let Y=_.node(F),Z=Y.order;(Z<X||L<Z)&&!(Y.dummy&&_.node(R).dummy)&&h(M,F,R)})}),K=z+1,X=L)}),G}return k.length&&k.reduce(D),M}function d(_,k){let M={};function D(G,X,K,$,q){let U;i.range(X,K).forEach(z=>{U=G[z],_.node(U).dummy&&_.predecessors(U).forEach(E=>{let L=_.node(E);L.dummy&&(L.order<$||L.order>q)&&h(M,E,U)})})}function A(G,X){let K=-1,$,q=0;return X.forEach((U,z)=>{if(_.node(U).dummy==="border"){let E=_.predecessors(U);E.length&&($=_.node(E[0]).order,D(X,q,z,K,$),q=z,K=$)}D(X,q,X.length,$,G.length)}),X}return k.length&&k.reduce(A),M}function c(_,k){if(_.node(k).dummy)return _.predecessors(k).find(M=>_.node(M).dummy)}function h(_,k,M){if(k>M){let A=k;k=M,M=A}let D=_[k];D||(_[k]=D={}),D[M]=!0}function m(_,k,M){if(k>M){let D=k;k=M,M=D}return!!_[k]&&Object.hasOwn(_[k],M)}function f(_,k,M,D){let A={},G={},X={};return k.forEach(K=>{K.forEach(($,q)=>{A[$]=$,G[$]=$,X[$]=q})}),k.forEach(K=>{let $=-1;K.forEach(q=>{let U=D(q);if(U.length){U=U.sort((E,L)=>X[E]-X[L]);let z=(U.length-1)/2;for(let E=Math.floor(z),L=Math.ceil(z);E<=L;++E){let R=U[E];G[q]===q&&$<X[R]&&!m(M,q,R)&&(G[R]=q,G[q]=A[q]=A[R],$=X[R])}}})}),{root:A,align:G}}function x(_,k,M,D,A){let G={},X=p(_,k,M,A),K=A?"borderLeft":"borderRight";function $(z,E){let L=X.nodes().slice(),R={},F=L.pop();for(;F;){if(R[F])z(F);else{R[F]=!0,L.push(F);for(let Y of E(F))L.push(Y)}F=L.pop()}}function q(z){G[z]=X.inEdges(z).reduce((E,L)=>Math.max(E,G[L.v]+X.edge(L)),0)}function U(z){let E=X.outEdges(z).reduce((R,F)=>Math.min(R,G[F.w]-X.edge(F)),Number.POSITIVE_INFINITY),L=_.node(z);E!==Number.POSITIVE_INFINITY&&L.borderType!==K&&(G[z]=Math.max(G[z],E))}return $(q,X.predecessors.bind(X)),$(U,X.successors.bind(X)),Object.keys(D).forEach(z=>G[z]=G[M[z]]),G}function p(_,k,M,D){let A=new s,G=_.graph(),X=T(G.nodesep,G.edgesep,D);return k.forEach(K=>{let $;K.forEach(q=>{let U=M[q];if(A.setNode(U),$){var z=M[$],E=A.edge(z,U);A.setEdge(z,U,Math.max(X(_,q,$),E||0))}$=q})}),A}function g(_,k){return Object.values(k).reduce((M,D)=>{let A=Number.NEGATIVE_INFINITY,G=Number.POSITIVE_INFINITY;Object.entries(D).forEach(([K,$])=>{let q=C(_,K)/2;A=Math.max($+q,A),G=Math.min($-q,G)});let X=A-G;return X<M[0]&&(M=[X,D]),M},[Number.POSITIVE_INFINITY,null])[1]}function y(_,k){let M=Object.values(k),D=i.applyWithChunking(Math.min,M),A=i.applyWithChunking(Math.max,M);["u","d"].forEach(G=>{["l","r"].forEach(X=>{let K=G+X,$=_[K];if($===k)return;let q=Object.values($),U=D-i.applyWithChunking(Math.min,q);X!=="l"&&(U=A-i.applyWithChunking(Math.max,q)),U&&(_[K]=i.mapValues($,z=>z+U))})})}function w(_,k){return i.mapValues(_.ul,(M,D)=>{if(k)return _[k.toLowerCase()][D];{let A=Object.values(_).map(G=>G[D]).sort((G,X)=>G-X);return(A[1]+A[2])/2}})}function N(_){let k=i.buildLayerMatrix(_),M=Object.assign(l(_,k),d(_,k)),D={},A;["u","d"].forEach(X=>{A=X==="u"?k:Object.values(k).reverse(),["l","r"].forEach(K=>{K==="r"&&(A=A.map(z=>Object.values(z).reverse()));let $=(X==="u"?_.predecessors:_.successors).bind(_),q=f(_,A,M,$),U=x(_,A,q.root,q.align,K==="r");K==="r"&&(U=i.mapValues(U,z=>-z)),D[X+K]=U})});let G=g(_,D);return y(D,G),w(D,_.graph().align)}function T(_,k,M){return(D,A,G)=>{let X=D.node(A),K=D.node(G),$=0,q;if($+=X.width/2,Object.hasOwn(X,"labelpos"))switch(X.labelpos.toLowerCase()){case"l":q=-X.width/2;break;case"r":q=X.width/2;break}if(q&&($+=M?q:-q),q=0,$+=(X.dummy?k:_)/2,$+=(K.dummy?k:_)/2,$+=K.width/2,Object.hasOwn(K,"labelpos"))switch(K.labelpos.toLowerCase()){case"l":q=K.width/2;break;case"r":q=-K.width/2;break}return q&&($+=M?q:-q),q=0,$}}function C(_,k){return _.node(k).width}}),EI=gn((e,n)=>{var s=Jn(),i=CI().positionX;n.exports=l;function l(c){c=s.asNonCompoundGraph(c),d(c),Object.entries(i(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(p=>{let g=p.reduce((y,w)=>{let N=c.node(w).height;return y>N?y:N},0);p.forEach(y=>{let w=c.node(y);f==="top"?w.y=x+w.height/2:f==="bottom"?w.y=x+g-w.height/2:w.y=x+g/2}),x+=g+m})}}),TI=gn((e,n)=>{var s=cI(),i=dI(),l=fI(),d=Jn().normalizeRanks,c=hI(),h=Jn().removeEmptyRanks,m=mI(),f=xI(),x=pI(),p=SI(),g=EI(),y=Jn(),w=js().Graph;n.exports=N;function N(H,W={}){let ee=W.debugTiming?y.time:y.notime;return ee("layout",()=>{let te=ee(" buildLayoutGraph",()=>$(H));return ee(" runLayout",()=>T(te,ee,W)),ee(" updateInputGraph",()=>C(H,te)),te})}function T(H,W,ee){W(" makeSpaceForEdgeLabels",()=>q(H)),W(" removeSelfEdges",()=>B(H)),W(" acyclic",()=>s.run(H)),W(" nestingGraph.run",()=>m.run(H)),W(" rank",()=>l(y.asNonCompoundGraph(H))),W(" injectEdgeLabelProxies",()=>U(H)),W(" removeEmptyRanks",()=>h(H)),W(" nestingGraph.cleanup",()=>m.cleanup(H)),W(" normalizeRanks",()=>d(H)),W(" assignRankMinMax",()=>z(H)),W(" removeEdgeLabelProxies",()=>E(H)),W(" normalize.run",()=>i.run(H)),W(" parentDummyChains",()=>c(H)),W(" addBorderSegments",()=>f(H)),W(" order",()=>p(H,ee)),W(" insertSelfEdges",()=>O(H)),W(" adjustCoordinateSystem",()=>x.adjust(H)),W(" position",()=>g(H)),W(" positionSelfEdges",()=>V(H)),W(" removeBorderNodes",()=>Z(H)),W(" normalize.undo",()=>i.undo(H)),W(" fixupEdgeLabelCoords",()=>F(H)),W(" undoCoordinateSystem",()=>x.undo(H)),W(" translateGraph",()=>L(H)),W(" assignNodeIntersects",()=>R(H)),W(" reversePoints",()=>Y(H)),W(" acyclic.undo",()=>s.undo(H))}function C(H,W){H.nodes().forEach(ee=>{let te=H.node(ee),ae=W.node(ee);te&&(te.x=ae.x,te.y=ae.y,te.order=ae.order,te.rank=ae.rank,W.children(ee).length&&(te.width=ae.width,te.height=ae.height))}),H.edges().forEach(ee=>{let te=H.edge(ee),ae=W.edge(ee);te.points=ae.points,Object.hasOwn(ae,"x")&&(te.x=ae.x,te.y=ae.y)}),H.graph().width=W.graph().width,H.graph().height=W.graph().height}var _=["nodesep","edgesep","ranksep","marginx","marginy"],k={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb",rankalign:"center"},M=["acyclicer","ranker","rankdir","align","rankalign"],D=["width","height","rank"],A={width:0,height:0},G=["minlen","weight","width","height","labeloffset"],X={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},K=["labelpos"];function $(H){let W=new w({multigraph:!0,compound:!0}),ee=S(H.graph());return W.setGraph(Object.assign({},k,I(ee,_),y.pick(ee,M))),H.nodes().forEach(te=>{let ae=S(H.node(te)),he=I(ae,D);Object.keys(A).forEach(Ne=>{he[Ne]===void 0&&(he[Ne]=A[Ne])}),W.setNode(te,he),W.setParent(te,H.parent(te))}),H.edges().forEach(te=>{let ae=S(H.edge(te));W.setEdge(te,Object.assign({},X,I(ae,G),y.pick(ae,K)))}),W}function q(H){let W=H.graph();W.ranksep/=2,H.edges().forEach(ee=>{let te=H.edge(ee);te.minlen*=2,te.labelpos.toLowerCase()!=="c"&&(W.rankdir==="TB"||W.rankdir==="BT"?te.width+=te.labeloffset:te.height+=te.labeloffset)})}function U(H){H.edges().forEach(W=>{let ee=H.edge(W);if(ee.width&&ee.height){let te=H.node(W.v),ae={rank:(H.node(W.w).rank-te.rank)/2+te.rank,e:W};y.addDummyNode(H,"edge-proxy",ae,"_ep")}})}function z(H){let W=0;H.nodes().forEach(ee=>{let te=H.node(ee);te.borderTop&&(te.minRank=H.node(te.borderTop).rank,te.maxRank=H.node(te.borderBottom).rank,W=Math.max(W,te.maxRank))}),H.graph().maxRank=W}function E(H){H.nodes().forEach(W=>{let ee=H.node(W);ee.dummy==="edge-proxy"&&(H.edge(ee.e).labelRank=ee.rank,H.removeNode(W))})}function L(H){let W=Number.POSITIVE_INFINITY,ee=0,te=Number.POSITIVE_INFINITY,ae=0,he=H.graph(),Ne=he.marginx||0,De=he.marginy||0;function je(ke){let Se=ke.x,Le=ke.y,nt=ke.width,rt=ke.height;W=Math.min(W,Se-nt/2),ee=Math.max(ee,Se+nt/2),te=Math.min(te,Le-rt/2),ae=Math.max(ae,Le+rt/2)}H.nodes().forEach(ke=>je(H.node(ke))),H.edges().forEach(ke=>{let Se=H.edge(ke);Object.hasOwn(Se,"x")&&je(Se)}),W-=Ne,te-=De,H.nodes().forEach(ke=>{let Se=H.node(ke);Se.x-=W,Se.y-=te}),H.edges().forEach(ke=>{let Se=H.edge(ke);Se.points.forEach(Le=>{Le.x-=W,Le.y-=te}),Object.hasOwn(Se,"x")&&(Se.x-=W),Object.hasOwn(Se,"y")&&(Se.y-=te)}),he.width=ee-W+Ne,he.height=ae-te+De}function R(H){H.edges().forEach(W=>{let ee=H.edge(W),te=H.node(W.v),ae=H.node(W.w),he,Ne;ee.points?(he=ee.points[0],Ne=ee.points[ee.points.length-1]):(ee.points=[],he=ae,Ne=te),ee.points.unshift(y.intersectRect(te,he)),ee.points.push(y.intersectRect(ae,Ne))})}function F(H){H.edges().forEach(W=>{let ee=H.edge(W);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 Y(H){H.edges().forEach(W=>{let ee=H.edge(W);ee.reversed&&ee.points.reverse()})}function Z(H){H.nodes().forEach(W=>{if(H.children(W).length){let ee=H.node(W),te=H.node(ee.borderTop),ae=H.node(ee.borderBottom),he=H.node(ee.borderLeft[ee.borderLeft.length-1]),Ne=H.node(ee.borderRight[ee.borderRight.length-1]);ee.width=Math.abs(Ne.x-he.x),ee.height=Math.abs(ae.y-te.y),ee.x=he.x+ee.width/2,ee.y=te.y+ee.height/2}}),H.nodes().forEach(W=>{H.node(W).dummy==="border"&&H.removeNode(W)})}function B(H){H.edges().forEach(W=>{if(W.v===W.w){var ee=H.node(W.v);ee.selfEdges||(ee.selfEdges=[]),ee.selfEdges.push({e:W,label:H.edge(W)}),H.removeEdge(W)}})}function O(H){var W=y.buildLayerMatrix(H);W.forEach(ee=>{var te=0;ee.forEach((ae,he)=>{var Ne=H.node(ae);Ne.order=he+te,(Ne.selfEdges||[]).forEach(De=>{y.addDummyNode(H,"selfedge",{width:De.label.width,height:De.label.height,rank:Ne.rank,order:he+ ++te,e:De.e,label:De.label},"_se")}),delete Ne.selfEdges})})}function V(H){H.nodes().forEach(W=>{var ee=H.node(W);if(ee.dummy==="selfedge"){var te=H.node(ee.e.v),ae=te.x+te.width/2,he=te.y,Ne=ee.x-ae,De=te.height/2;H.setEdge(ee.e,ee.label),H.removeNode(W),ee.label.points=[{x:ae+2*Ne/3,y:he-De},{x:ae+5*Ne/6,y:he-De},{x:ae+Ne,y:he},{x:ae+5*Ne/6,y:he+De},{x:ae+2*Ne/3,y:he+De}],ee.label.x=ee.x,ee.label.y=ee.y}})}function I(H,W){return y.mapValues(y.pick(H,W),Number)}function S(H){var W={};return H&&Object.entries(H).forEach(([ee,te])=>{typeof ee=="string"&&(ee=ee.toLowerCase()),W[ee]=te}),W}}),_I=gn((e,n)=>{var s=Jn(),i=js().Graph;n.exports={debugOrdering:l};function l(d){let c=s.buildLayerMatrix(d),h=new i({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((p,g)=>(h.setEdge(p,g,{style:"invis"}),g))}),h}}),AI=gn((e,n)=>{n.exports="2.0.4"}),MI=gn((e,n)=>{n.exports={graphlib:js(),layout:TI(),debug:_I(),util:{time:Jn().time,notime:Jn().notime},version:AI()}});const r1=MI();const s1={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"}},RI={critical:"bg-red-500",high:"bg-amber-500",medium:"bg-amber-500",low:"bg-blue-500"};function OI({data:e}){const{task:n,agentName:s,selected:i}=e,l=s1[n.status]??s1.pending,d=n.taskType==="scheduled"&&!!n.scheduleConfig,c=d?n.scheduleConfig.every?`Every ${n.scheduleConfig.every}`:n.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?`${l.bg} border-blue-500/40 ring-1 ring-blue-500/20`:`${l.bg} ${l.border}`} ${i?"ring-2 ring-brand-500 shadow-brand-500/25 shadow-lg":""}`,children:[t.jsx(Xa,{type:"target",position:mt.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 ${RI[n.priority]??"bg-gray-500"}`}),t.jsx("span",{className:`text-[10px] font-medium uppercase tracking-wider ${l.text}`,children:n.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:n.title}),s&&t.jsx("div",{className:"text-[10px] text-fg-tertiary truncate",children:s}),n.blockedBy&&n.blockedBy.length>0&&t.jsxs("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:[n.blockedBy.length," dep",n.blockedBy.length>1?"s":""]}),t.jsx(Xa,{type:"source",position:mt.Bottom,className:"!bg-border-default !w-2 !h-2"})]})}const a1={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"}},i1={pending:"todo",in_progress:"in_progress",completed:"done",rejected:"done",cancelled:"done",archived:"done"};function DI({data:e}){const{req:n,selected:s}=e,i=a1[n.status]??a1.pending;return t.jsxs("div",{className:`rounded-lg border-2 border-dashed px-3 py-2 min-w-[180px] max-w-[220px] shadow-lg ${i.bg} ${i.border} ${s?"ring-2 ring-brand-500 shadow-brand-500/25":""}`,children:[t.jsx(Xa,{type:"target",position:mt.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 ${i.text}`,children:n.status.replace("_"," ")})]}),t.jsx("div",{className:"text-xs font-medium text-fg-primary leading-snug line-clamp-2 mb-1",children:n.title}),n.taskIds.length>0&&t.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:[n.taskIds.length," task",n.taskIds.length>1?"s":""]}),t.jsx(Xa,{type:"source",position:mt.Bottom,className:"!bg-border-default !w-2 !h-2"})]})}const LI={task:OI,requirement:DI},II=()=>document.documentElement.classList.contains("light")||!document.documentElement.classList.contains("dark")&&window.matchMedia("(prefers-color-scheme: light)").matches,zI=e=>{const n=new MutationObserver(e);n.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]});const s=window.matchMedia("(prefers-color-scheme: light)");return s.addEventListener("change",e),()=>{n.disconnect(),s.removeEventListener("change",e)}};function $I(){return v.useSyncExternalStore(zI,II,()=>!1)}const tx=200,nx=80;function l1(e,n,s="TB"){const i=new r1.graphlib.Graph;i.setDefaultEdgeLabel(()=>({})),i.setGraph({rankdir:s,nodesep:40,ranksep:60});for(const l of e)i.setNode(l.id,{width:tx,height:nx});for(const l of n)i.setEdge(l.source,l.target);return r1.layout(i),e.map(l=>{const d=i.node(l.id);return{...l,position:{x:(d?.x??0)-tx/2,y:(d?.y??0)-nx/2}}})}function BI(e,n){const s=new Map,i=new Map;for(const c of e)i.set(c.id,c),s.set(c.id,new Set);for(const c of n)s.get(c.source)?.add(c.target),s.get(c.target)?.add(c.source);const l=new Set,d=[];for(const c of e){if(l.has(c.id))continue;const h=new Set,m=[c.id];for(;m.length>0;){const f=m.pop();if(!l.has(f)){l.add(f),h.add(f);for(const x of s.get(f)??[])l.has(x)||m.push(x)}}d.push({nodes:e.filter(f=>h.has(f.id)),edges:n.filter(f=>h.has(f.source)&&h.has(f.target))})}return d}function HI(e,n){if(e.length===0)return[];const s=BI(e,n);if(s.length===1)return l1(e,n);const i=s.map(p=>{const g=l1(p.nodes,p.edges);let y=1/0,w=-1/0,N=1/0,T=-1/0;for(const C of g)y=Math.min(y,C.position.x),w=Math.max(w,C.position.x+tx),N=Math.min(N,C.position.y),T=Math.max(T,C.position.y+nx);for(const C of g)C.position.x-=y,C.position.y-=N;return{nodes:g,w:w-y,h:T-N}});i.sort((p,g)=>g.h-p.h);const l=60,d=i.reduce((p,g)=>p+(g.w+l)*(g.h+l),0),c=Math.sqrt(d)*1.1,h=[];let m=0,f=0,x=0;for(const p of i){m>0&&m+p.w>c&&(m=0,f+=x+l,x=0);for(const g of p.nodes)h.push({...g,position:{x:g.position.x+m,y:g.position.y+f}});m+=p.w+l,x=Math.max(x,p.h)}return h}function PI(e,n,s){const i=new Set,l=[n];for(;l.length>0;){const d=l.pop();if(d===s)return!0;if(i.has(d))continue;i.add(d);const c=e.get(d);if(c?.blockedBy)for(const h of c.blockedBy)l.push(h)}return!1}const Mo=[{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","archived"]),color:{bg:"bg-green-500/10",border:"border-green-500/30",text:"text-green-600"}}],hm=new Set(Mo.map(e=>e.id)),o1=e=>e.status==="archived";function qI({tasks:e,requirements:n=[],agents:s,showArchived:i,onShowArchivedChange:l,onTaskClick:d,onReqClick:c,onDependencyChange:h,selectedTaskId:m,selectedReqId:f}){const x=$I(),[p,g]=v.useState(null),[y,w]=v.useState(null),[N,T]=v.useState(new Set(hm)),[C,_]=v.useState(i??!1),k=i??C,M=v.useCallback(je=>{const ke=typeof je=="function"?je(k):je;_(ke),l?.(ke)},[k,l]);v.useEffect(()=>{i!==void 0&&_(i)},[i]);const D=v.useMemo(()=>e.filter(je=>o1(je)).length,[e]),A=v.useMemo(()=>{const je=new Set;for(const ke of Mo)if(N.has(ke.id))for(const Se of ke.statuses)je.add(Se);return je},[N]),G=v.useMemo(()=>{const je=new Set;for(const ke of e)for(const Se of Mo)if(Se.statuses.has(ke.status)){je.add(Se.id);break}for(const ke of n){const Se=i1[ke.status];Se&&je.add(Se)}return Mo.filter(ke=>je.has(ke.id))},[e,n]),X=v.useCallback(je=>{T(ke=>{const Se=new Set(ke);return Se.has(je)?Se.delete(je):Se.add(je),Se})},[]),K=v.useCallback((je,ke="success")=>{g({msg:je,type:ke}),setTimeout(()=>g(null),2500)},[]),$=v.useMemo(()=>{const je=new Map;for(const ke of s)je.set(ke.id,ke.name);return je},[s]),q=v.useMemo(()=>{const je=new Map;for(const ke of e)je.set(ke.id,ke);return je},[e]),U=v.useMemo(()=>{const je=new Map;for(const ke of n)je.set(ke.id,ke);return je},[n]),z=x?"#94a3b8":"#6b7280",E=v.useCallback((je,ke,Se)=>({id:`${je}->${ke}`,source:je,target:ke,animated:Se==="blocked",markerEnd:{type:Nl.ArrowClosed,width:14,height:14,color:Se==="blocked"?"#ef4444":z},style:{stroke:Se==="blocked"?"#ef4444":z,strokeWidth:1.5,cursor:"pointer"}}),[z]),{initialNodes:L,initialEdges:R}=v.useMemo(()=>{const je=e.filter(_e=>A.has(_e.status)&&(k||!o1(_e))),ke=je.map(_e=>({id:_e.id,type:"task",data:{task:_e,agentName:_e.assignedAgentId?$.get(_e.assignedAgentId):void 0,selected:_e.id===m},position:{x:0,y:0}})),Se=new Set(ke.map(_e=>_e.id)),Le=new Set;for(const _e of Mo)N.has(_e.id)&&Le.add(_e.id);const nt=n.filter(_e=>{const st=i1[_e.status];return st&&Le.has(st)});for(const _e of nt){const st=`req-${_e.id}`;ke.push({id:st,type:"requirement",data:{req:_e,selected:_e.id===f},position:{x:0,y:0}}),Se.add(st)}const rt=[];for(const _e of je)if(_e.blockedBy)for(const st of _e.blockedBy)Se.has(st)&&rt.push(E(st,_e.id,_e.status));const yt=new Set,Rt=(_e,st)=>{const dt=`${_e}->${st}`;yt.has(dt)||(yt.add(dt),rt.push({id:dt,source:_e,target:st,markerEnd:{type:Nl.ArrowClosed,width:14,height:14,color:"#8b5cf6"},style:{stroke:"#8b5cf6",strokeWidth:1.5,strokeDasharray:"4 2"}}))};for(const _e of nt){const st=`req-${_e.id}`;for(const dt of _e.taskIds)Se.has(dt)&&Rt(st,dt)}for(const _e of je)if(_e.requirementId){const st=`req-${_e.requirementId}`;Se.has(st)&&Rt(st,_e.id)}return{initialNodes:HI(ke,rt),initialEdges:rt}},[e,n,$,q,E,A,N,k,m,f]),[F,Y,Z]=ML(L),[B,O,V]=RL(R),I=v.useRef(null),S=v.useRef(!1),H=v.useRef({groupFilter:N,showArchived:k});v.useEffect(()=>{const je=H.current;(je.groupFilter!==N||je.showArchived!==k)&&(S.current=!1,H.current={groupFilter:N,showArchived:k})},[N,k]),v.useEffect(()=>{Y(L),O(R),S.current||requestAnimationFrame(()=>{I.current?.fitView({padding:.2,duration:300})})},[L,R,Y,O]);const W=v.useCallback(je=>{je&&(S.current=!0)},[]),ee=v.useCallback((je,ke)=>{if(ke.id.startsWith("req-")){const Se=U.get(ke.id.slice(4));Se&&c&&c(Se)}else{const Se=q.get(ke.id);Se&&d&&d(Se)}},[q,U,d,c]),te=v.useCallback(async je=>{const{source:ke,target:Se}=je;if(!ke||!Se||ke===Se)return;const Le=q.get(Se);if(!Le)return;if(Le.blockedBy?.includes(ke)){K("Dependency already exists","error");return}if(PI(q,ke,Se)){K("Cannot add: would create a cycle","error");return}const nt=[...Le.blockedBy??[],ke];try{await se.tasks.update(Se,{blockedBy:nt}),K("Dependency added"),h?.()}catch(rt){K(`Failed: ${rt instanceof Error?rt.message:String(rt)}`,"error")}},[q,K,h]),ae=v.useCallback((je,ke)=>{w(ke)},[]),he=v.useCallback(async()=>{if(!y)return;const je=q.get(y.target);if(!je){w(null);return}const ke=(je.blockedBy??[]).filter(Se=>Se!==y.source);try{await se.tasks.update(y.target,{blockedBy:ke}),K("Dependency removed"),h?.()}catch(Se){K(`Failed: ${Se instanceof Error?Se.message:String(Se)}`,"error")}w(null)},[y,q,K,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 Ne=y?q.get(y.source):null,De=y?q.get(y.target):null;return t.jsxs("div",{className:"flex-1 min-h-0 relative",style:{height:"100%"},children:[t.jsxs(AL,{nodes:F,edges:B,onNodesChange:Z,onEdgesChange:V,onNodeClick:ee,onConnect:te,onEdgeClick:ae,onMoveEnd:W,onInit:je=>{I.current=je},nodeTypes:LI,fitView:!0,minZoom:.3,maxZoom:2,proOptions:{hideAttribution:!0},connectionLineStyle:{stroke:"#818cf8",strokeWidth:2,strokeDasharray:"6 3"},children:[t.jsx(zL,{color:x?"#cbd5e1":"#374151",gap:20,size:1}),t.jsx(VL,{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(rI,{nodeColor:je=>{const ke=je.data?.task,Se=ke?.status;return ke?.taskType==="scheduled"?"#06b6d4":Se==="completed"||Se==="accepted"?"#10b981":Se==="in_progress"?"#f59e0b":Se==="blocked"||Se==="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(je=>{const ke=N.has(je.id);return t.jsx("button",{onClick:()=>X(je.id),className:`text-[10px] px-1.5 py-0.5 rounded border transition-colors ${ke?`${je.color.bg} ${je.color.border} ${je.color.text}`:"bg-surface-elevated/50 border-border-default/50 text-fg-tertiary"}`,children:je.label},je.id)}),D>0&&t.jsxs("button",{onClick:()=>M(je=>!je),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 ",D]}),N.size<hm.size&&t.jsx("button",{onClick:()=>{T(new Set(hm)),M(!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"})]}),p&&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 ${p.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:p.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:je=>je.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:Ne?.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:he,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 qN({orgId:e,onCreated:n,onClose:s}){const[i,l]=v.useState(""),[d,c]=v.useState(""),[h,m]=v.useState(""),[f,x]=v.useState("main"),[p,g]=v.useState([]),[y,w]=v.useState([]),[N,T]=v.useState(!1),[C,_]=v.useState(""),[k,M]=v.useState(!1),D=$r();v.useEffect(()=>{se.teams.list().then(X=>w(X.teams)).catch(()=>{})},[]);const A=v.useCallback(async X=>{if(X?.preventDefault(),M(!0),!(!i.trim()||N)){T(!0),_("");try{const K=h.trim()?[{url:h.trim(),defaultBranch:f.trim()||"main"}]:[],$=await se.projects.create({name:i.trim(),description:d.trim()||void 0,repositories:K.length>0?K:void 0,teamIds:p.length>0?p:void 0,orgId:e??"default"});n($.project)}catch(K){_(K instanceof Error?K.message:"Failed to create project")}T(!1)}},[i,d,h,f,p,e,N,n]),G=k&&!i.trim();return lx.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 ${D?"w-full":"w-[520px]"}`,onClick:X=>X.stopPropagation(),onSubmit:A,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:i,onChange:X=>{l(X.target.value),_("")},onBlur:()=>M(!0),placeholder:"e.g. Mobile App, Website Redesign",className:`input ${G?"!border-red-500 focus:!ring-red-500/25":""}`,autoFocus:!D}),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:X=>c(X.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(X=>{const K=p.includes(X.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:K,onChange:()=>g($=>K?$.filter(q=>q!==X.id):[...$,X.id]),className:"accent-brand-500"}),t.jsx("span",{className:"truncate",children:X.name})]},X.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:X=>m(X.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:X=>x(X.target.value),placeholder:"main",className:"input !w-24"})]})]}),C&&t.jsx("div",{className:"text-xs text-red-400 bg-red-500/10 rounded-lg px-3 py-2",children:C}),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:!i.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 Tl(e,n,s){if(!e)return null;const i=n.find(d=>d.id===e);if(i)return i.name;const l=s.find(d=>d.id===e);return l?l.name:e==="anonymous"?"Admin":null}function UI({value:e,onSave:n,className:s,placeholder:i}){const[l,d]=v.useState(!1),[c,h]=v.useState(e),m=v.useRef(null);v.useEffect(()=>{h(e)},[e]),v.useEffect(()=>{l&&m.current?.focus()},[l]);const f=async()=>{d(!1);const x=c.trim();if(x&&x!==e)try{await n(x)}catch{h(e)}else h(e)};return l?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:i}):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:i??"Click to edit"})})}function VI({value:e,onSave:n,className:s,placeholder:i}){const[l,d]=v.useState(!1),[c,h]=v.useState(e),m=v.useRef(null);v.useEffect(()=>{h(e)},[e]),v.useEffect(()=>{l&&m.current&&(m.current.focus(),m.current.style.height="auto",m.current.style.height=m.current.scrollHeight+"px")},[l]);const f=async()=>{d(!1);const x=c.trim();if(x!==e)try{await n(x)}catch{h(e)}else h(e)};return l?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:i,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:i??"Add a description…"})})}const FI=/^\[([^\]]+?)(?:\s+by\s+([^\]]+))?\]\s*([\s\S]*)$/;function UN(e){const n=e.match(FI);return n?{timestamp:n[1].trim(),author:n[2]?.trim()??"System",content:n[3].trim()}:{timestamp:"",author:"",content:e}}function YI(e){if(!e)return"";const n=e.match(/^(\d{4})[/-](\d{2})[/-](\d{2})\s+(\d{2}):(\d{2})(?::(\d{2}))?/);if(!n)return e;const s=new Date,i=+n[1],l=+n[2]-1,d=+n[3],c=+n[4],h=+n[5],m=new Date(i,l,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`:`${i}-${String(l+1).padStart(2,"0")}-${String(d).padStart(2,"0")}`}const c1=[{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 GI(e){let n=0;for(let s=0;s<e.length;s++)n=(n<<5)-n+e.charCodeAt(s)|0;return c1[Math.abs(n)%c1.length]}function XI({note:e,compact:n}){const s=UN(e),i=GI(s.author||"System"),l=s.author?s.author.split(/[\s_-]+/).map(h=>h[0]).join("").slice(0,2).toUpperCase():"SY",d=YI(s.timestamp),c=!s.author||s.author==="System";return n?t.jsxs("div",{className:"flex gap-2.5 group",children:[t.jsx("div",{className:`w-6 h-6 rounded-full ${i.bg} flex items-center justify-center text-[9px] font-bold ${i.text} shrink-0 mt-0.5`,children:l}),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":i.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(ir,{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 ${i.bg} flex items-center justify-center text-[10px] font-bold ${i.text}`,children:l}),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 ${i.border} rounded-lg overflow-hidden`,children:[t.jsxs("div",{className:`flex items-center gap-2 px-3 py-1.5 ${i.bg} border-b ${i.border}`,children:[t.jsx("span",{className:`text-[11px] font-medium ${c?"text-fg-secondary":i.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(ir,{content:s.content,className:"text-xs text-fg-secondary"})})]})})]})}const Jo=[{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","archived"],accent:"border-t-gray-500",dropStatus:"cancelled"}],VN={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"}},Ro={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"}},KI={urgent:"border-l-red-500",high:"border-l-amber-500",medium:"border-l-blue-500",low:"border-l-gray-500"},_d={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"}},d1=["low","medium","high","urgent"],u1=["pending","in_progress","blocked","review","completed","failed","rejected","cancelled"],f1=["pending","in_progress","completed","rejected","cancelled"],h1={pending:new Set(["in_progress","blocked","rejected","cancelled"]),in_progress:new Set(["review","blocked","failed","cancelled"]),blocked:new Set(["in_progress","cancelled"]),review:new Set(["completed","in_progress","cancelled"]),completed:new Set(["archived","in_progress"]),failed:new Set(["in_progress","archived"]),rejected:new Set(["archived"]),cancelled:new Set(["archived"]),archived:new Set([])},rx={pending:new Set(["in_progress","rejected","cancelled"]),in_progress:new Set(["completed","cancelled"]),completed:new Set([]),rejected:new Set([]),cancelled:new Set([])},sx={idle:"bg-green-400",working:"bg-blue-400",error:"bg-red-400",paused:"bg-amber-400",offline:"bg-gray-600",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"},m1={idle:"text-green-500",working:"text-blue-500",error:"text-red-500",paused:"text-amber-500",offline:"text-fg-muted"};function WI({agent:e,anchorRect:n,onClose:s}){const i=v.useRef(null);v.useEffect(()=>{const c=h=>{i.current&&!i.current.contains(h.target)&&s()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]);const l=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:i,className:"fixed z-50 w-56 bg-surface-secondary border border-border-default rounded-xl shadow-2xl p-3 space-y-2",style:{top:n.top+4,left:n.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 ${l}`}),t.jsx("span",{className:"text-[10px] text-fg-secondary",children:d})]})]})]}),t.jsx("button",{onClick:()=>{s(),ht.navigate(me.TEAM,{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 $o({comment:e,agents:n,onReply:s}){const i=e.authorType==="agent"||e.authorType==="system",l=new Date(e.createdAt),d=l.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),c=l.toLocaleDateString([],{month:"short",day:"numeric"}),[h,m]=v.useState(null),[f,x]=v.useState(!1),[p,g]=v.useState([]),[y,w]=v.useState(!1),N=v.useCallback((k,M)=>{const D=n.find(A=>A.name.toLowerCase()===k.toLowerCase());if(D){const A=M.target.getBoundingClientRect();m({agent:D,top:A.bottom,left:A.left})}},[n]),T=v.useCallback(k=>{const M=n.find(D=>D.name.toLowerCase()===e.authorName.toLowerCase());if(M){const D=k.currentTarget.getBoundingClientRect();m({agent:M,top:D.bottom,left:D.left})}},[n,e.authorName]),C=v.useCallback(async()=>{if(f){x(!1);return}const k=e.activityId;if(k&&(x(!0),!(p.length>0))){w(!0);try{const{logs:M}=await se.agents.getActivityLogs(e.authorId,k),D=M.map(A=>_1(A,k,e.authorId)).filter(A=>A!==null).map(A=>({...A,ts:new Date(A.createdAt).getTime()}));g(D)}catch{}w(!1)}},[f,p.length,e]),_=v.useMemo(()=>qo(p.map(Uo).filter(k=>k!==null)),[p]);return t.jsxs("div",{className:"flex gap-2.5 group py-1",id:`comment-${e.id}`,children:[t.jsx("div",{onClick:T,className:`flex-shrink-0 w-6 h-6 rounded-full flex items-center justify-center text-[10px] mt-0.5 cursor-pointer transition-all hover:ring-1 hover:ring-brand-500/40 ${i?"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 cursor-pointer hover:underline ${i?"text-indigo-400":"text-blue-400"}`,onClick:T,children:e.authorName}),t.jsxs("span",{className:"text-fg-tertiary text-[10px]",children:[c," ",d]}),s&&t.jsx("button",{onClick:()=>s(e),className:"text-fg-tertiary hover:text-fg-secondary text-[10px] opacity-0 group-hover:opacity-100 transition-opacity ml-1",children:"Reply"}),e.activityId&&i&&t.jsx("button",{onClick:C,className:"text-fg-tertiary hover:text-brand-400 text-[10px] opacity-0 group-hover:opacity-100 transition-opacity ml-1",children:f?"Hide log":"View log"})]}),e.replyTo&&e.replyToAuthor&&t.jsxs("button",{onClick:()=>{const k=document.getElementById(`comment-${e.replyTo}`);k&&(k.scrollIntoView({behavior:"smooth",block:"center"}),k.classList.add("bg-brand-500/10"),setTimeout(()=>k.classList.remove("bg-brand-500/10"),1500))},className:"flex items-center gap-1.5 mb-1 pl-2 py-0.5 border-l-2 border-brand-500/40 text-[10px] text-fg-tertiary hover:text-fg-secondary transition-colors cursor-pointer",children:[t.jsx("span",{className:"font-medium text-brand-500/70",children:e.replyToAuthor}),t.jsx("span",{className:"truncate max-w-[200px]",children:e.replyToContent??"..."})]}),t.jsx(ir,{content:e.content,className:"text-xs text-fg-primary",onMentionClick:N}),e.attachments?.map((k,M)=>k.type==="image"?t.jsx("img",{src:k.url,alt:k.name,className:"mt-1 max-w-[200px] rounded"},M):null),f&&t.jsx("div",{className:"mt-2 border border-border-subtle rounded-lg overflow-hidden bg-surface-secondary/30",children:y?t.jsx("div",{className:"p-3 text-xs text-fg-tertiary",children:"Loading execution log..."}):_.length===0?t.jsx("div",{className:"p-3 text-xs text-fg-tertiary",children:"No execution log available."}):t.jsx(du,{entries:p,isActive:!1,onCollapse:()=>x(!1),embedded:!0})})]}),h&&t.jsx(WI,{agent:h.agent,anchorRect:{top:h.top,left:h.left},onClose:()=>m(null)})]})}function QI({task:e,agents:n,users:s,authUser:i}){const[l,d]=v.useState([]);v.useEffect(()=>{se.tasks.getComments(e.id).then(p=>d(p.comments)).catch(()=>{})},[e.id]),v.useEffect(()=>Jt.on("task:comment",g=>{g.payload?.taskId===e.id&&g.payload.comment&&d(y=>y.some(w=>w.id===g.payload.comment.id)?y:[...y,g.payload.comment])}),[e.id]);const c=v.useMemo(()=>{const p=[];for(const g of e.notes??[]){const y=UN(g);let w;if(y.timestamp){const N=y.timestamp.match(/^(\d{4})[/-](\d{2})[/-](\d{2})\s+(\d{2}):(\d{2})(?::(\d{2}))?/);w=N?new Date(+N[1],+N[2]-1,+N[3],+N[4],+N[5],+(N[6]??0)):new Date(0)}else w=new Date(0);p.push({type:"note",note:g,ts:w})}for(const g of l)p.push({type:"comment",comment:g,ts:new Date(g.createdAt)});return p.sort((g,y)=>g.ts.getTime()-y.ts.getTime()),p},[e.notes,l]),[h,m]=v.useState(null),f=async(p,g,y)=>{await se.tasks.addComment(e.id,p,i?.name,void 0,i?.id,g.length>0?g:void 0,y)},x=v.useCallback(p=>{m({id:p.id,authorName:p.authorName,content:p.content.slice(0,100)})},[]);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((p,g)=>p.type==="note"?t.jsx(XI,{note:p.note,compact:!0},`n-${g}`):t.jsx($o,{comment:p.comment,agents:n,onReply:x},`c-${p.comment.id}`))]}),t.jsx(Vj,{agents:n,onSubmit:f,replyTo:h,onCancelReply:()=>m(null)})]})}function ZI({taskId:e,isRunning:n,authUser:s,agents:i}){const[l,d]=v.useState([]),[c,h]=v.useState(new Map),[m,f]=v.useState(new Set),[x,p]=v.useState([]),[g,y]=v.useState(""),[w,N]=v.useState(n),[T,C]=v.useState(!0),[_,k]=v.useState(new Set),[M,D]=v.useState(""),[A,G]=v.useState(!1),[X,K]=v.useState([]),$=v.useRef(null),q=v.useRef(null);v.useEffect(()=>{N(n)},[n]),v.useEffect(()=>{C(!0),Promise.all([se.tasks.getLogsSummary(e).catch(()=>({rounds:[]})),se.tasks.getComments(e).catch(()=>({comments:[]}))]).then(([V,I])=>{const S=V.rounds;if(d(S),p(I.comments),S.length===0){C(!1);return}const H=S[S.length-1].round;k(new Set([H])),se.tasks.getLogs(e,H).catch(()=>({logs:[]})).then(W=>{h(new Map([[H,W.logs]])),C(!1)})})},[e]);const U=v.useCallback(V=>{c.has(V)||m.has(V)||(f(I=>new Set(I).add(V)),se.tasks.getLogs(e,V).catch(()=>({logs:[]})).then(I=>{h(S=>new Map(S).set(V,I.logs)),f(S=>{const H=new Set(S);return H.delete(V),H})}))},[e,c,m]),z=v.useCallback(V=>{k(I=>{const S=new Set(I);return S.has(V)?S.delete(V):(S.add(V),c.has(V)||U(V)),S})},[c,U]);v.useEffect(()=>{const V=Jt.on("task:log",H=>{const W=H.payload;if(W.taskId!==e)return;const ee={id:W.id,taskId:W.taskId,agentId:W.agentId,seq:W.seq,type:W.logType,content:W.content,metadata:W.metadata,executionRound:W.executionRound,createdAt:W.createdAt},te=ee.executionRound??1;d(ae=>ae.find(Ne=>Ne.round===te)?ae:[...ae,{round:te,logCount:0,toolCount:0,firstAt:ee.createdAt,lastAt:ee.createdAt,status:"running"}]),k(ae=>ae.has(te)?ae:new Set(ae).add(te)),h(ae=>{const he=ae.get(te)??[];return ee.id&&he.some(Ne=>Ne.id===ee.id)?ae:new Map(ae).set(te,[...he,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(ae=>ae.map(he=>he.round===te?{...he,status:ee.content}:he)))),ee.type==="error"&&N(!1)}),I=Jt.on("task:log:delta",H=>{const W=H.payload;W.taskId===e&&y(ee=>ee+W.text)}),S=Jt.on("task:comment",H=>{const W=H.payload;if(W.taskId!==e)return;const ee=W.comment;p(te=>te.some(ae=>ae.id===ee.id)?te:[...te,ee])});return()=>{V(),I(),S()}},[e]);const E=v.useMemo(()=>{const V=[];for(const[,I]of c)V.push(...I);return V.sort((I,S)=>I.seq-S.seq),V},[c]),L=v.useMemo(()=>E.map(V=>bm(V)),[E]),R=l.length>1,F=V=>{const I=V.target.files;if(I){for(const S of Array.from(I)){if(!S.type.startsWith("image/"))continue;const H=new FileReader;H.onload=()=>{K(W=>[...W,{type:"image",url:H.result,name:S.name}])},H.readAsDataURL(S)}V.target.value=""}},Y=async()=>{if(!(!M.trim()&&X.length===0)){G(!0);try{const V=await se.tasks.addComment(e,M,s?.name,X.length>0?X:void 0,s?.id);V.comment&&p(I=>I.some(S=>S.id===V.comment.id)?I:[...I,V.comment]),D(""),K([])}catch{}G(!1)}},Z=t.jsxs("div",{className:"border-t border-border-default px-4 py-3 sticky bottom-0 bg-surface-secondary z-10",children:[X.length>0&&t.jsx("div",{className:"flex gap-2 mb-2 flex-wrap",children:X.map((V,I)=>t.jsxs("div",{className:"relative group",children:[t.jsx("img",{src:V.url,alt:V.name,className:"w-16 h-16 object-cover rounded-lg border border-border-default"}),t.jsx("button",{onClick:()=>K(S=>S.filter((H,W)=>W!==I)),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:"×"})]},I))}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{type:"text",value:M,onChange:V=>D(V.target.value),onKeyDown:V=>{V.key==="Enter"&&!V.shiftKey&&(V.preventDefault(),Y())},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:F,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:()=>{Y()},disabled:A||!M.trim()&&X.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(T)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-xs text-fg-tertiary",children:"Loading logs…"});if(l.length===0&&!g)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.']})]})}),Z]});if(!R){const V=L.map(H=>Uo(H)).filter(H=>H!==null),I=Ty(E,qo(V)),S=[...I.map(H=>({kind:"entry",entry:H,ts:H.timestamp?new Date(H.timestamp).getTime():0})),...x.map(H=>({kind:"comment",comment:H,ts:new Date(H.createdAt).getTime()}))];return S.sort((H,W)=>H.ts-W.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:[S.map((H,W)=>H.kind==="comment"?t.jsx($o,{comment:H.comment,agents:i},`c-${H.comment.id}`):t.jsx(Ud,{entry:H.entry,showTime:!0,isLast:W===S.length-1},`e-${W}`)),w&&g&&t.jsx(Im,{content:g}),w&&!g&&I.length>0&&t.jsx(Lm,{})]}),Z]})}const B=(V,I)=>{const S=V.firstAt?new Date(V.firstAt).getTime():0,H=I?.firstAt?new Date(I.firstAt).getTime():1/0;return x.filter(W=>{const ee=new Date(W.createdAt).getTime();return ee>=S&&ee<H})},O=l.length>0?x.filter(V=>new Date(V.createdAt).getTime()<new Date(l[0].firstAt).getTime()):[];return t.jsxs("div",{className:"flex flex-col flex-1",children:[t.jsx("div",{ref:q}),t.jsxs("div",{className:"px-4 py-3 flex-1 space-y-2",children:[O.length>0&&t.jsx("div",{className:"space-y-0.5",children:O.map(V=>t.jsx($o,{comment:V,agents:i},V.id))}),l.map((V,I)=>{const S=_.has(V.round),H=V.round===l[l.length-1].round,W=c.get(V.round),ee=m.has(V.round),te=B(V,l[I+1]),ae=V.status==="completed"||V.status==="execution_finished"?"✅":V.status==="failed"?"❌":V.status==="cancelled"?"⏹":"🔄",he=V.lastAt&&V.firstAt?Math.max(0,new Date(V.lastAt).getTime()-new Date(V.firstAt).getTime()):0,Ne=he>=6e4?`${Math.floor(he/6e4)}m ${Math.floor(he%6e4/1e3)}s`:he>=1e3?`${Math.floor(he/1e3)}s`:"";return t.jsxs("div",{className:"border border-border-default/50 rounded-lg overflow-hidden",children:[t.jsxs("button",{onClick:()=>z(V.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:ae}),t.jsxs("span",{className:"text-xs text-fg-secondary font-medium",children:["Round #",V.round]}),te.length>0&&t.jsxs("span",{className:"text-[10px] text-blue-400",children:["💬 ",te.length]}),H&&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:[V.toolCount," tool",V.toolCount!==1?"s":""]}),Ne&&t.jsx("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:Ne}),t.jsx("svg",{className:`w-3 h-3 text-fg-tertiary transition-transform ${S?"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"})})]})]}),S&&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 #",V.round,"…"]}),W&&(()=>{const je=W.map(Le=>bm(Le)).map(Le=>Uo(Le)).filter(Le=>Le!==null),Se=[...Ty(W,qo(je)).map(Le=>({kind:"entry",entry:Le,ts:Le.timestamp?new Date(Le.timestamp).getTime():0})),...te.map(Le=>({kind:"comment",comment:Le,ts:new Date(Le.createdAt).getTime()}))];return Se.sort((Le,nt)=>Le.ts-nt.ts),Se.map((Le,nt)=>Le.kind==="comment"?t.jsx($o,{comment:Le.comment,agents:i},`c-${Le.comment.id}`):t.jsx(Ud,{entry:Le.entry,showTime:!0,isLast:nt===Se.length-1},`e-${nt}`))})(),H&&w&&g&&t.jsx(Im,{content:g}),H&&w&&!g&&!ee&&t.jsx(Lm,{})]})]},V.round)})]}),Z]})}function JI({filePath:e,onClose:n}){const[s,i]=v.useState(null),[l,d]=v.useState(null),[c,h]=v.useState(!0);v.useEffect(()=>{h(!0),d(null),se.files.preview(e).then(f=>i(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:n,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:n,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..."}),l&&t.jsx("div",{className:"text-sm text-red-500 text-center py-8",children:l}),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(ir,{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 ez({task:e,agents:n,projects:s,requirements:i,allTasks:l,users:d,onClose:c,onRefresh:h,authUser:m,scrollToComments:f,onScrollToCommentsDone:x}){const[p,g]=v.useState([]),[y,w]=v.useState(""),[N,T]=v.useState(!1),[C,_]=v.useState(!1),[k,M]=v.useState(null),[D,A]=v.useState(null),[G,X]=v.useState(!1),[K,$]=v.useState("details"),q=v.useRef(null),[U,z]=v.useState("none"),E=v.useCallback(xe=>{$(xe),requestAnimationFrame(()=>{q.current?.scrollTo({top:0,behavior:"instant"})})},[]),L=v.useMemo(()=>[{id:"details"},{id:"logs"},{id:"deliverables"}],[]),R=ca(L,K,E);v.useEffect(()=>{const xe=q.current;if(!xe)return;const Re=()=>{const{scrollTop:At,scrollHeight:Dt,clientHeight:On}=xe;if(!(Dt>On+50)){z("none");return}const dn=At<30,Dn=At+On>=Dt-30;z(dn?"top":Dn?"bottom":"middle")};Re(),xe.addEventListener("scroll",Re,{passive:!0});const vt=new ResizeObserver(Re);return vt.observe(xe),()=>{xe.removeEventListener("scroll",Re),vt.disconnect()}},[K]),v.useEffect(()=>{if(!f)return;$("details");const xe=setTimeout(()=>{const Re=q.current;Re&&Re.scrollTo({top:Re.scrollHeight,behavior:"smooth"}),x?.()},300);return()=>clearTimeout(xe)},[f,x]);const[F,Y]=v.useState(null),[Z,B]=v.useState(null),[O,V]=v.useState(!1),[I,S]=v.useState(e.description),[H,W]=v.useState(!1),[ee,te]=v.useState(""),[ae,he]=v.useState(1),[Ne,De]=v.useState(!1),je=$r(),ke=20,Se=v.useCallback(async()=>{try{const xe=await se.tasks.listSubtasks(e.id);g(xe.subtasks)}catch{}},[e.id]);v.useEffect(()=>{Se()},[Se]);const Le=async xe=>{if(!G){X(!0);try{await xe(),h(),await Se()}catch(Re){Y(String(Re).replace("Error: ",""))}finally{X(!1)}}},nt=xe=>Le(()=>se.tasks.update(e.id,{priority:xe})),rt=xe=>Le(()=>se.tasks.assign(e.id,xe||null)),yt=xe=>Le(()=>se.tasks.update(e.id,{projectId:xe||null})),Rt=async()=>{if(!G){X(!0);try{await se.tasks.pause(e.id),h()}finally{X(!1)}}},re=async()=>{if(!G){X(!0),Y(null),E("logs");try{await se.tasks.resume(e.id),h()}catch(xe){Y(String(xe).replace("Error: API error: 400","Server error").replace("Error: ",""))}finally{X(!1)}}},_e=async()=>{y.trim()&&(await se.tasks.createSubtask(e.id,y.trim()),w(""),T(!1),Se(),h())},st=async xe=>{xe.status==="completed"?await se.tasks.cancelSubtask(e.id,xe.id):await se.tasks.completeSubtask(e.id,xe.id),Se(),h()},dt=async xe=>{await se.tasks.deleteSubtask(e.id,xe.id),M(null),Se(),h()},Yt=async()=>{if(!G){X(!0);try{await se.tasks.updateStatus(e.id,"in_progress"),h()}finally{X(!1)}}},ye=async()=>{if(!G){X(!0),Y(null),E("logs");try{await se.tasks.retry(e.id),h()}catch(xe){Y(String(xe).replace("Error: API error: 400","Server error").replace("Error: ",""))}finally{X(!1)}}},Ae=async()=>{if(!G){X(!0),Y(null),E("logs");try{await se.tasks.runNow(e.id),h()}catch(xe){Y(String(xe).replace("Error: API error: 400","Server error").replace("Error: ","")),h()}finally{X(!1)}}},Fe=v.useRef(h);Fe.current=h,v.useEffect(()=>Jt.on("task:update",Re=>{Re.payload.taskId===e.id&&(Se(),Fe.current())}),[e.id,Se]);const Qe=p.filter(xe=>xe.status==="completed").length,xt=e.status==="in_progress",nn=e.status==="blocked",cn=e.status==="completed",Tt=e.status==="failed",gt=e.status==="rejected",Bt=e.status==="cancelled",_t=e.status==="archived",Ht=cn||Tt||gt||Bt||_t,rn=e.taskType==="scheduled"&&!!e.scheduleConfig,bn=rn&&!!e.scheduleConfig?.paused,Hn=s.find(xe=>xe.id===e.projectId),Cn=i.find(xe=>xe.id===e.requirementId);return n.find(xe=>xe.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:[je&&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 xe=Ro[e.status];return xe?t.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full font-medium whitespace-nowrap ${xe.cls}`,children:xe.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," ")})})()]})]}),!je&&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:()=>E("details"),className:`px-3 py-1.5 text-xs rounded-t-md transition-colors ${K==="details"?"bg-surface-elevated text-fg-primary font-medium":"text-fg-tertiary hover:text-fg-secondary"}`,children:"Details"}),t.jsxs("button",{onClick:()=>E("logs"),className:`px-3 py-1.5 text-xs rounded-t-md transition-colors flex items-center gap-1.5 ${K==="logs"?"bg-surface-elevated text-fg-primary font-medium":"text-fg-tertiary hover:text-fg-secondary"}`,children:["Execution Log",xt&&t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-400 animate-pulse"})]}),t.jsxs("button",{onClick:()=>E("deliverables"),className:`px-3 py-1.5 text-xs rounded-t-md transition-colors flex items-center gap-1.5 ${K==="deliverables"?"bg-surface-elevated text-fg-primary font-medium":"text-fg-tertiary hover:text-fg-secondary"}`,children:["Deliverables",(()=>{const xe=(e.deliverables??[]).filter(Re=>Re.type!=="branch"&&typeof Re.reference=="string"&&Re.reference.length>0).length;return xe>0?t.jsx("span",{className:"text-[10px] text-fg-tertiary font-normal",children:xe}):null})()]})]}),t.jsxs("div",{className:"flex-1 min-h-0 relative",children:[t.jsxs("div",{ref:q,className:"h-full overflow-y-auto",onTouchStart:R.onTouchStart,onTouchEnd:R.onTouchEnd,children:[K==="logs"&&t.jsxs("div",{className:"overflow-x-hidden min-w-0",children:[F&&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:"})," ",F]}),t.jsx(ZI,{taskId:e.id,isRunning:e.status==="in_progress",authUser:m,agents:n})]}),K==="details"&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-6 pt-4 pb-3 border-b border-border-default",children:O?t.jsxs("div",{className:"space-y-2",children:[t.jsx("textarea",{value:I,onChange:xe=>S(xe.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:()=>{V(!1),S(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:()=>{Le(()=>se.tasks.update(e.id,{description:I})),V(!1)},disabled:G,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:je&&!Ne?"line-clamp-3":"",children:t.jsx(ir,{content:e.description,className:"text-sm text-fg-secondary leading-relaxed"})}),je&&e.description.length>150&&t.jsx("button",{onClick:()=>De(!Ne),className:"text-[11px] text-brand-500 mt-1 font-medium",children:Ne?"Collapse":"Show more"})]}):t.jsx("p",{className:"text-sm text-fg-tertiary italic",children:"No description"}),t.jsx("button",{onClick:()=>{S(e.description),V(!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"})]})}),(Hn||Cn)&&t.jsxs("div",{className:"px-6 py-2.5 border-b border-border-default flex flex-wrap items-center gap-2",children:[Hn&&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"}),Hn.name]}),Cn&&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"}),Cn.title.length>40?Cn.title.slice(0,40)+"…":Cn.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(xe=>{const Re=l.find(At=>At.id===xe),vt=Re&&(Re.status==="completed"||Re.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:Re?Re.title.slice(0,30):xe.slice(-8)}),!Ht&&t.jsx("button",{onClick:async()=>{const At=(e.blockedBy??[]).filter(Dt=>Dt!==xe);await se.tasks.update(e.id,{blockedBy:At}),h()},className:"ml-0.5 text-current opacity-40 hover:opacity-100 transition-opacity",title:"Remove dependency",children:"×"})]},xe)})}):t.jsx("p",{className:"text-[11px] text-fg-tertiary mb-2",children:"No dependencies"}),!Ht&&t.jsxs("select",{value:"",onChange:async xe=>{const Re=xe.target.value;if(!Re)return;const vt=[...e.blockedBy??[],Re];await se.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…"}),l.filter(xe=>xe.id!==e.id&&!(e.blockedBy??[]).includes(xe.id)).map(xe=>t.jsx("option",{value:xe.id,children:xe.title},xe.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:xe=>{yt(xe.target.value)},disabled:G,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(xe=>t.jsx("option",{value:xe.id,children:xe.name},xe.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:xe=>Le(()=>se.tasks.update(e.id,{requirementId:xe.target.value||null})),disabled:G,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"}),i.filter(xe=>!e.projectId||xe.projectId===e.projectId).map(xe=>t.jsx("option",{value:xe.id,children:xe.title},xe.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:xe=>{rt(xe.target.value)},disabled:G,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"}),n.map(xe=>t.jsxs("option",{value:xe.id,children:[xe.name," (",xe.status,")"]},xe.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:xe=>{xe.target.value&&xe.target.value!==e.reviewerAgentId&&Le(()=>se.tasks.update(e.id,{reviewerAgentId:xe.target.value}))},disabled:G,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:n.map(xe=>t.jsx("option",{value:xe.id,children:xe.name},xe.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:xe=>{nt(xe.target.value)},disabled:G,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:Tl(e.createdBy,n,d)??e.createdBy})]}),e.updatedBy&&t.jsxs("span",{children:["Updated by ",t.jsx("span",{className:"text-fg-secondary",children:Tl(e.updatedBy,n,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 ",p.length>0&&t.jsxs("span",{className:"ml-1.5 text-fg-tertiary font-normal normal-case",children:[Qe,"/",p.length," done"]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[Qe>0&&t.jsx("button",{onClick:()=>_(xe=>!xe),className:`text-[10px] px-2 py-0.5 rounded-full border transition-colors ${C?"bg-brand-500/15 text-brand-500 border-brand-500/30":"text-fg-tertiary border-border-default hover:text-fg-secondary"}`,children:C?"Hide completed":`Show completed (${Qe})`}),t.jsx("button",{onClick:()=>T(!0),className:"text-xs text-brand-500 hover:text-brand-500 transition-colors",children:"+ Add subtask"})]})]}),(()=>{const xe=C?p:p.filter(Re=>Re.status!=="completed");return xe.length>0?t.jsx("div",{className:"space-y-1.5 mb-3",children:xe.map(Re=>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:()=>{st(Re)},className:`shrink-0 w-4 h-4 rounded border flex items-center justify-center transition-colors ${Re.status==="completed"?"bg-green-600 border-green-600 text-white":"border-gray-600 hover:border-brand-500"}`,children:Re.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 ${Re.status==="completed"?"line-through text-fg-tertiary":"text-fg-secondary"}`,children:Re.title}),t.jsx("button",{onClick:()=>M(Re),className:"shrink-0 opacity-0 group-hover:opacity-100 text-fg-tertiary hover:text-red-500 transition-all text-xs",children:"✕"})]},Re.id))}):null})(),p.length===0&&!N&&t.jsx("div",{className:"text-xs text-fg-tertiary text-center py-4",children:"No subtasks yet."}),N&&t.jsxs("div",{className:"flex gap-2 mt-2",children:[t.jsx("input",{autoFocus:!0,value:y,onChange:xe=>w(xe.target.value),onKeyDown:xe=>{xe.key==="Enter"&&_e(),xe.key==="Escape"&&(T(!1),w(""))},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:()=>{_e()},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:()=>{T(!1),w("")},className:"px-3 py-1.5 border border-border-default text-xs rounded-lg hover:bg-surface-elevated",children:"Cancel"})]}),(()=>{const xe=(e.deliverables??[]).filter(At=>At.type!=="branch"&&typeof At.reference=="string"&&At.reference.length>0);if(xe.length===0)return null;const Re={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=xe.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:["(",xe.length,")"]})]}),xe.length>3&&t.jsx("button",{onClick:()=>E("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((At,Dt)=>{const On=At.reference.split("/").pop()??At.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 ${Re[At.type]??"bg-gray-500/15 text-fg-secondary"}`,children:At.type}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("button",{onClick:()=>B(At.reference),className:"text-sm text-brand-500 hover:text-brand-500 font-medium truncate block max-w-full text-left hover:underline",title:At.reference,children:On}),At.summary&&t.jsx("p",{className:"text-[11px] text-fg-secondary mt-0.5 line-clamp-2",children:At.summary}),t.jsx("p",{className:"text-[10px] text-fg-tertiary font-mono truncate mt-0.5",children:At.reference})]})]},Dt)})})]})})(),t.jsx(QI,{task:e,agents:n,users:d,authUser:m})]})]}),K==="deliverables"&&t.jsx("div",{className:"px-6 py-4",children:(()=>{const xe=(e.deliverables??[]).filter(Dt=>Dt.type!=="branch"&&typeof Dt.reference=="string"&&Dt.reference.length>0);if(xe.length===0)return t.jsx("div",{className:"flex items-center justify-center py-12 text-xs text-fg-tertiary",children:"No deliverables yet."});const Re={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(xe.length/ke),At=xe.slice((ae-1)*ke,ae*ke);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:["(",xe.length,")"]})]}),vt>1&&t.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-fg-tertiary",children:[t.jsx("button",{disabled:ae<=1,onClick:()=>he(Dt=>Dt-1),className:"px-1.5 py-0.5 rounded bg-surface-elevated hover:bg-surface-overlay disabled:opacity-30",children:"‹"}),t.jsxs("span",{children:[ae,"/",vt]}),t.jsx("button",{disabled:ae>=vt,onClick:()=>he(Dt=>Dt+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:At.map((Dt,On)=>{const an=Dt.reference.split("/").pop()??Dt.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 ${Re[Dt.type]??"bg-gray-500/15 text-fg-secondary"}`,children:Dt.type}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("button",{onClick:()=>B(Dt.reference),className:"text-sm text-brand-500 hover:text-brand-500 font-medium truncate block max-w-full text-left hover:underline",title:Dt.reference,children:an}),Dt.summary&&t.jsx("p",{className:"text-[11px] text-fg-secondary mt-0.5 line-clamp-2",children:Dt.summary}),t.jsx("p",{className:"text-[10px] text-fg-tertiary font-mono truncate mt-0.5",children:Dt.reference})]})]},On)})})]})})()})]}),U!=="none"&&U!=="top"&&t.jsx("button",{onClick:()=>q.current?.scrollTo({top:0,behavior:"smooth"}),className:"absolute bottom-20 right-4 md:bottom-14 md:right-3 z-10 w-12 h-12 md:w-8 md:h-8 rounded-full bg-brand-500 md:bg-brand-600/90 border border-brand-400/60 shadow-xl shadow-brand-500/30 md:shadow-lg md:shadow-brand-500/20 flex items-center justify-center text-white hover:bg-brand-400 transition-colors backdrop-blur-sm",title:"Scroll to top",children:t.jsx("svg",{className:"w-6 h-6 md:w-4 md: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"})})}),U!=="none"&&U!=="bottom"&&t.jsx("button",{onClick:()=>{const xe=q.current;xe&&xe.scrollTo({top:xe.scrollHeight,behavior:"smooth"})},className:"absolute bottom-6 right-4 md:bottom-4 md:right-3 z-10 w-12 h-12 md:w-8 md:h-8 rounded-full bg-brand-500 md:bg-brand-600/90 border border-brand-400/60 shadow-xl shadow-brand-500/30 md:shadow-lg md:shadow-brand-500/20 flex items-center justify-center text-white hover:bg-brand-400 transition-colors backdrop-blur-sm",title:"Scroll to bottom",children:t.jsx("svg",{className:"w-6 h-6 md:w-4 md: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"})})})]}),rn&&e.scheduleConfig&&t.jsxs("div",{className:`mx-6 mt-3 mb-0 px-4 py-2.5 rounded-lg border text-xs ${bn?"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:bn?"text-amber-600":"text-brand-500",children:bn?"⏸ 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"}),!bn&&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 xe=new Date(e.scheduleConfig.nextRunAt).getTime()-Date.now();if(xe<=0)return"due now";const Re=Math.floor(xe/6e4);if(Re<60)return`in ${Re}m`;const vt=Math.floor(Re/60);return vt<24?`in ${vt}h ${Re%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 xe=Date.now()-new Date(e.scheduleConfig.lastRunAt).getTime(),Re=Math.floor(xe/6e4);if(Re<1)return"just now";if(Re<60)return`${Re}m ago`;const vt=Math.floor(Re/60);return vt<24?`${vt}h ${Re%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:()=>Le(()=>se.tasks.approve(e.id)),disabled:G,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:()=>Le(()=>se.tasks.reject(e.id)),disabled:G,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:()=>{Le(()=>se.tasks.accept(e.id,m?.id))},disabled:G,className:"px-3 py-1.5 text-xs bg-green-600 hover:bg-green-500 rounded-lg text-white disabled:opacity-50",children:"✓ Approve"}),H?t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("input",{type:"text",value:ee,onChange:xe=>te(xe.target.value),onKeyDown:xe=>{xe.key==="Enter"&&ee.trim()&&(Le(()=>se.tasks.revision(e.id,ee.trim(),m?.id)),W(!1),te(""))},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:()=>{Le(()=>se.tasks.revision(e.id,ee.trim()||"Revisions needed",m?.id)),W(!1),te("")},disabled:G,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:()=>{W(!1),te("")},className:"px-1.5 py-1 text-xs text-fg-secondary hover:text-fg-primary",children:"✕"})]}):t.jsx("button",{onClick:()=>W(!0),disabled:G,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"})]}),xt&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:()=>{Rt()},disabled:G,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:()=>{ye()},disabled:G,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"]})]}),nn&&t.jsx("button",{onClick:()=>{re()},disabled:G,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:G?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"]})}),Tt&&t.jsxs("button",{onClick:()=>{ye()},disabled:G,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"]}),rn&&(cn||Tt)&&t.jsx("button",{onClick:()=>{Ae()},disabled:G,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:G?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"]})}),rn&&!xt&&(bn?t.jsx("button",{onClick:()=>{Le(()=>se.tasks.resumeSchedule(e.id))},disabled:G,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:()=>{Le(()=>se.tasks.pauseSchedule(e.id))},disabled:G,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"})),(cn||Tt||gt||Bt)&&t.jsx("button",{onClick:()=>Le(()=>se.tasks.archive(e.id)),disabled:G,className:"px-3 py-1.5 text-xs bg-gray-600 hover:bg-gray-500 rounded-lg text-white disabled:opacity-50",children:"Archive"}),(cn||Tt)&&t.jsx("button",{onClick:()=>{Yt()},disabled:G,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"}),!Ht&&e.status!=="pending"&&t.jsx("button",{onClick:async()=>{const{count:xe}=await se.tasks.getDependentCount(e.id);xe>0?A({dependentCount:xe}):Le(()=>se.tasks.cancel(e.id))},disabled:G,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"})]})}),k&&t.jsx(Fj,{title:`Delete subtask "${k.title}"?`,message:"This subtask will be permanently deleted.",confirmLabel:"Delete",onConfirm:()=>{dt(k)},onCancel:()=>M(null)}),D&&t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:()=>A(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:xe=>xe.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:D.dependentCount})," dependent task",D.dependentCount>1?"s":""," that ",D.dependentCount>1?"are":"is"," currently blocked by it."]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs("button",{onClick:()=>{A(null),Le(()=>se.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:()=>{A(null),Le(()=>se.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 ",D.dependentCount," blocked task",D.dependentCount>1?"s":""]})]}),t.jsx("button",{onClick:()=>A(null),className:"w-full px-4 py-2 text-sm text-fg-tertiary hover:text-fg-secondary",children:"Keep task running"})]})]})}),Z&&t.jsx(JI,{filePath:Z,onClose:()=>B(null)})]})}function tz({project:e,tasks:n,requirements:s,agents:i,onDeleteProject:l,onUpdateProject:d,onRefresh:c}){const h=v.useMemo(()=>n.filter(X=>X.projectId===e.id),[n,e.id]),m=v.useMemo(()=>s.filter(X=>X.projectId===e.id),[s,e.id]),f=v.useMemo(()=>{const X={total:h.length,completed:0,inProgress:0,inReview:0,blocked:0,pending:0,failed:0,reqs:m.length,reqsDone:0};for(const K of h)K.status==="completed"||K.status==="accepted"?X.completed++:K.status==="in_progress"?X.inProgress++:K.status==="review"||K.status==="revision"?X.inReview++:K.status==="blocked"?X.blocked++:K.status==="failed"?X.failed++:X.pending++;for(const K of m)K.status==="completed"&&X.reqsDone++;return X},[h,m]),x=v.useMemo(()=>new Set(h.map(X=>X.assignedAgentId).filter(Boolean)),[h]),p=v.useMemo(()=>i.filter(X=>x.has(X.id)),[i,x]),[g,y]=v.useState(!1),[w,N]=v.useState(""),[T,C]=v.useState("main"),[_,k]=v.useState(!1),M=[{value:"active",label:"Active",desc:"Work is ongoing"},{value:"paused",label:"Paused",desc:"Temporarily on hold"},{value:"archived",label:"Archived",desc:"No longer active"}],D=async X=>{if(X!==e.status){k(!0);try{await d({status:X}),c()}finally{k(!1)}}},A=async()=>{const X=w.trim();if(!X)return;const K=[...e.repositories??[],{url:"",localPath:X,defaultBranch:T||"main"}];await d({repositories:K}),N(""),C("main"),y(!1),c()},G=async X=>{const K=(e.repositories??[]).filter(($,q)=>q!==X);await d({repositories:K}),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(VI,{value:e.description??"",onSave:async X=>{await d({description:X}),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:M.map(X=>t.jsxs("button",{disabled:_,onClick:()=>D(X.value),className:`flex-1 px-3 py-2 rounded-lg text-xs font-medium transition-all ${e.status===X.value?X.value==="active"?"bg-green-500/15 text-green-600 ring-1 ring-green-500/30":X.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"} ${_?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:[t.jsx("div",{children:X.label}),t.jsx("div",{className:"text-[10px] opacity-70 mt-0.5",children:X.desc})]},X.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(sa,{label:"Total",value:f.total,color:"text-fg-primary"}),t.jsx(sa,{label:"Completed",value:f.completed,color:"text-green-600"}),t.jsx(sa,{label:"In Progress",value:f.inProgress,color:"text-brand-500"}),t.jsx(sa,{label:"In Review",value:f.inReview,color:"text-brand-500"}),t.jsx(sa,{label:"Blocked",value:f.blocked,color:"text-amber-600"}),t.jsx(sa,{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(sa,{label:"Total",value:f.reqs,color:"text-fg-primary"}),t.jsx(sa,{label:"Completed",value:f.reqsDone,color:"text-green-600"}),t.jsx(sa,{label:"Active",value:f.reqs-f.reqsDone,color:"text-brand-500"})]})]}),p.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 (",p.length,")"]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:p.map(X=>{const K=h.filter(q=>q.assignedAgentId===X.id),$=K.filter(q=>!["completed","failed","cancelled","archived"].includes(q.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 ${X.status==="working"?"bg-blue-500":X.status==="idle"?"bg-green-500":"bg-gray-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary",children:X.name}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[$.length," active / ",K.length," total"]})]},X.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(!g),className:"text-[10px] text-brand-500 hover:text-brand-500",children:g?"Cancel":"+ Add"})]}),(e.repositories??[]).length===0&&!g&&t.jsx("p",{className:"text-xs text-fg-tertiary",children:"No repositories linked."}),(e.repositories??[]).map((X,K)=>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:X.url||X.localPath}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:X.defaultBranch}),t.jsx("button",{onClick:()=>G(K),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"})]})})]},K)),g&&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:X=>N(X.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:T,onChange:X=>C(X.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:A,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:l,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 sa({label:e,value:n,color:s}){return t.jsxs("div",{className:"text-center py-2",children:[t.jsx("div",{className:`text-xl font-bold ${s}`,children:n}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:e})]})}const yi={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"},archived:{label:"Archived",cls:"bg-gray-600/10 text-fg-tertiary/60"}},FN={pending:"todo",in_progress:"in_progress",completed:"done",rejected:"closed",cancelled:"closed",archived:"closed"},YN={failed:"rejected",todo:"pending",in_progress:"in_progress",review:"in_progress",done:"completed",closed:"cancelled"},nz={urgent:0,high:1,medium:2,low:3},x1={failed:0,todo:1,in_progress:2,review:3,done:4,closed:5},p1={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"},rz={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"},sz=["pending","in_progress","completed","rejected","cancelled","archived"];function az(e){for(const n of Jo)if(n.statuses.includes(e))return n.id;return"closed"}function g1(e){const n=Date.now()-new Date(e).getTime(),s=Math.floor(n/6e4);if(s<1)return"just now";if(s<60)return`${s}m ago`;const i=Math.floor(s/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function Ad({value:e,options:n,onSelect:s,allowedValues:i}){const[l,d]=v.useState(!1),c=v.useRef(null),h=v.useRef(null),m=n.find(f=>f.value===e);return v.useEffect(()=>{if(!l)return;const f=x=>{h.current&&!h.current.contains(x.target)&&c.current&&!c.current.contains(x.target)&&d(!1)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[l]),t.jsxs("div",{className:"relative",children:[t.jsx("button",{ref:c,onClick:()=>d(f=>!f),className:`text-[11px] px-2 py-0.5 rounded-full font-medium transition-colors cursor-pointer hover:ring-1 hover:ring-current/30 ${m?.cls??"bg-gray-500/15 text-fg-tertiary"}`,children:m?.label??e}),l&&t.jsx("div",{ref:h,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:n.map(f=>{const x=f.value===e,p=x||!i||i.has(f.value);return t.jsxs("button",{disabled:!p,onClick:()=>{!x&&p&&s(f.value),d(!1)},className:`w-full text-left px-3 py-1.5 text-[11px] flex items-center gap-2 transition-colors ${x?"bg-surface-elevated":p?"hover:bg-surface-elevated/60":"opacity-35 cursor-not-allowed"}`,children:[t.jsx("span",{className:`inline-block w-2 h-2 rounded-full shrink-0 ${p?f.cls.split(" ")[0]:"bg-gray-600"}`}),t.jsx("span",{className:`font-medium ${x?"text-fg-primary":p?"text-fg-secondary":"text-fg-muted"}`,children:f.label}),x&&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"})})]},f.value)})})]})}function b1({row:e,idx:n,dragIdx:s,agentMap:i,projMap:l,onTaskClick:d,onReqClick:c,onRowDragStart:h,onRowDragEnd:m,handleStatusChange:f,handlePriorityChange:x,selected:p,isMobile:g}){const y=e.data.status,w=e.data.priority,N=e.kind==="task"?i.get(e.data.assignedAgentId??""):void 0,T=l.get((e.kind==="task",e.data.projectId??"")),C=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",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"});return g?t.jsxs("div",{onClick:()=>e.kind==="task"?d(e.data):c(e.data),className:`px-3 py-2 border-b border-border-default/40 cursor-pointer transition-colors border-l-2 ${p1[e.group]??"border-l-gray-700"} ${p?"bg-brand-500/10 border-l-brand-500":"active:bg-surface-elevated/50"}`,children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[C,t.jsx("span",{className:"text-sm text-fg-primary truncate flex-1",children:e.data.title})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-1.5 flex-wrap",children:[t.jsx("div",{onClick:_=>_.stopPropagation(),children:t.jsx(Ad,{value:y,options:e.kind==="task"?u1.map(_=>({value:_,label:Ro[_]?.label??_,cls:Ro[_]?.cls??"bg-gray-500/15 text-fg-tertiary"})):f1.map(_=>({value:_,label:yi[_]?.label??_,cls:yi[_]?.cls??"bg-gray-500/15 text-fg-tertiary"})),allowedValues:e.kind==="task"?h1[y]:rx[y],onSelect:_=>{f(e,_)}})}),t.jsx("div",{onClick:_=>_.stopPropagation(),children:t.jsx(Ad,{value:w,options:d1.map(_=>({value:_,label:_d[_]?.label??_,cls:_d[_]?.cls??"bg-gray-500/15 text-fg-tertiary"})),onSelect:_=>{x(e,_)}})}),N&&t.jsxs("span",{className:"flex items-center gap-1 text-[10px]",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${sx[N.status]??"bg-gray-500"}`}),t.jsx("span",{className:`${m1[N.status]??"text-fg-secondary"}`,children:N.name})]}),T?.name&&t.jsx("span",{className:"text-[10px] text-brand-400/70 truncate max-w-[80px]",children:T.name}),t.jsx("span",{className:"text-[9px] text-fg-muted ml-auto",children:g1(e.data.updatedAt??"")})]})]}):t.jsxs("div",{draggable:!0,onDragStart:_=>h(_,n),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 ${p1[e.group]??"border-l-gray-700"} ${s===n?"opacity-40":""} ${p?"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:C}),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:_=>_.stopPropagation(),children:t.jsx(Ad,{value:y,options:e.kind==="task"?u1.map(_=>({value:_,label:Ro[_]?.label??_,cls:Ro[_]?.cls??"bg-gray-500/15 text-fg-tertiary"})):f1.map(_=>({value:_,label:yi[_]?.label??_,cls:yi[_]?.cls??"bg-gray-500/15 text-fg-tertiary"})),allowedValues:e.kind==="task"?h1[y]:rx[y],onSelect:_=>{f(e,_)}})}),t.jsx("div",{className:"w-[100px] shrink-0",onClick:_=>_.stopPropagation(),children:t.jsx(Ad,{value:w,options:d1.map(_=>({value:_,label:_d[_]?.label??_,cls:_d[_]?.cls??"bg-gray-500/15 text-fg-tertiary"})),onSelect:_=>{x(e,_)}})}),t.jsx("div",{className:"w-[120px] shrink-0 text-[11px] truncate",children:N?t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${sx[N.status]??"bg-gray-500"}`}),t.jsx("span",{className:`font-medium ${m1[N.status]??"text-fg-secondary"}`,children:N.name})]}):t.jsx("span",{className:"text-fg-muted",children:"—"})}),t.jsx("div",{className:"w-[120px] shrink-0 text-[11px] truncate",children:T?.name?t.jsx("span",{className:"text-brand-400/70",children:T.name}):t.jsx("span",{className:"text-fg-muted",children:"—"})}),t.jsx("div",{className:"w-[90px] shrink-0 text-[10px] text-fg-muted text-right",children:g1(e.data.updatedAt??"")})]})}function iz({tasks:e,requirements:n,agents:s,projects:i,onTaskClick:l,onReqClick:d,onRefresh:c,selectedTaskId:h,selectedReqId:m}){const f=$r(),[x,p]=v.useState("status"),[g,y]=v.useState(null),[w,N]=v.useState(null),T=v.useMemo(()=>{const E=[];for(const L of e){const R=az(L.status);E.push({kind:"task",data:L,group:R,groupOrder:x1[R]??5})}for(const L of n){const R=FN[L.status]??"todo";E.push({kind:"req",data:L,group:R,groupOrder:x1[R]??5})}if(x==="status")E.sort((L,R)=>{if(L.groupOrder!==R.groupOrder)return L.groupOrder-R.groupOrder;const F=new Date(L.data.updatedAt??0).getTime();return new Date(R.data.updatedAt??0).getTime()-F});else{const L=R=>nz[R.data.priority]??2;E.sort((R,F)=>{const Y=L(R),Z=L(F);return Y!==Z?Y-Z:new Date(F.data.updatedAt??0).getTime()-new Date(R.data.updatedAt??0).getTime()})}return E},[e,n,x]),C=async(E,L)=>{try{E.kind==="task"?await se.tasks.updateStatus(E.data.id,L):await se.requirements.updateStatus(E.data.id,L),c()}catch{}},_=async(E,L)=>{try{E.kind==="task"?await se.tasks.update(E.data.id,{priority:L}):await se.requirements.update(E.data.id,{priority:L}),c()}catch{}},k=(E,L)=>{y(L),E.dataTransfer.effectAllowed="move",E.dataTransfer.setData("text/plain",String(L)),E.currentTarget.style.opacity="0.4"},M=E=>{E.currentTarget.style.opacity="1",y(null),N(null)},D=(E,L)=>{E.preventDefault(),E.dataTransfer.dropEffect="move",w!==L&&N(L)},A=async(E,L)=>{if(E.preventDefault(),N(null),g==null)return;const R=T[g];if(!R||R.group===L)return;const F=Jo.find(Y=>Y.id===L);if(F){try{if(R.kind==="task"){if(R.data.status==="pending")return;await se.tasks.updateStatus(R.data.id,F.dropStatus)}else{const Y=YN[L];Y&&await se.requirements.updateStatus(R.data.id,Y)}c()}catch{}y(null)}},G=v.useMemo(()=>new Map(s.map(E=>[E.id,E])),[s]),X=v.useMemo(()=>new Map(i.map(E=>[E.id,E])),[i]),K=["todo","in_progress","review","done"],$=v.useMemo(()=>{const E={};for(const L of T)E[L.group]=(E[L.group]??0)+1;return E},[T]),{rowsByGroup:q,rowIndexMap:U}=v.useMemo(()=>{const E=new Map,L=new Map;for(let R=0;R<T.length;R++){const F=T[R];L.set(F,R);const Y=E.get(F.group)??[];Y.push(F),E.set(F.group,Y)}return{rowsByGroup:E,rowIndexMap:L}},[T]),z=v.useMemo(()=>{if(x!=="status")return null;const E=new Set(T.map(F=>F.group)),L=[],R=new Set;E.has("failed")&&(L.push("failed"),R.add("failed"));for(const F of K)L.push(F),R.add(F);for(const F of T)R.has(F.group)||(L.push(F.group),R.add(F.group));return L},[T,x]);return t.jsx("div",{className:`flex-1 min-h-0 overflow-auto bg-surface-secondary ${f?"overflow-x-hidden w-full":""}`,children:t.jsxs("div",{className:f?"w-full":"w-fit min-w-full",children:[!f&&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:T.length}),t.jsx("div",{className:"flex-1 min-w-[200px]",children:"Title"}),t.jsxs("button",{onClick:()=>p("status"),className:`w-[130px] shrink-0 text-left flex items-center gap-1 transition-colors ${x==="status"?"text-brand-500":"hover:text-fg-secondary"}`,children:["Status ",x==="status"&&t.jsx("span",{className:"text-[8px]",children:"▼"})]}),t.jsxs("button",{onClick:()=>p("priority"),className:`w-[100px] shrink-0 text-left flex items-center gap-1 transition-colors ${x==="priority"?"text-brand-500":"hover:text-fg-secondary"}`,children:["Priority ",x==="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:[x==="status"&&z?z.map(E=>{const L=Jo.find(F=>F.id===E),R=q.get(E)??[];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 ${rz[E]??""} ${w===E?"ring-1 ring-brand-500/40":""}`,onDragOver:F=>D(F,E),onDragLeave:()=>N(null),onDrop:F=>{A(F,E)},children:[t.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider",children:L?.label??E}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:$[E]??0})]}),R.map(F=>t.jsx(b1,{row:F,idx:U.get(F)??0,dragIdx:g,agentMap:G,projMap:X,onTaskClick:l,onReqClick:d,onRowDragStart:k,onRowDragEnd:M,handleStatusChange:C,handlePriorityChange:_,selected:F.kind==="task"?F.data.id===h:F.data.id===m,isMobile:f},`${F.kind}-${F.data.id}`))]},E)}):T.map((E,L)=>t.jsx(b1,{row:E,idx:L,dragIdx:g,agentMap:G,projMap:X,onTaskClick:l,onReqClick:d,onRowDragStart:k,onRowDragEnd:M,handleStatusChange:C,handlePriorityChange:_,selected:E.kind==="task"?E.data.id===h:E.data.id===m,isMobile:f},`${E.kind}-${E.data.id}`)),T.length===0&&t.jsx("div",{className:"flex items-center justify-center py-16 text-sm text-fg-tertiary",children:"No items"})]})]})})}function y1({authUser:e}){const n=$r(),s=fu({side:"right",defaultWidth:Math.round(window.innerWidth*2/3),minWidth:380,maxWidth:Math.round(window.innerWidth*.8),storageKey:"markus_projects_detail_v3"}),[i,l]=v.useState(!1),d=v.useRef(i);d.current=i;const[c,h]=v.useState([]),[m,f]=v.useState("all"),[x,p]=v.useState(null),[g,y]=v.useState({}),[w,N]=v.useState([]),[T,C]=v.useState([]),[_,k]=v.useState([]),[M,D]=v.useState(!0),[A,G]=v.useState(""),[X,K]=v.useState(!1),$=v.useCallback(()=>{dn(x??""),Cn(!0)},[x]),[q,U]=v.useState(!1),[z,E]=v.useState(!1),[L,R]=v.useState(""),[F,Y]=v.useState(""),[Z,B]=v.useState("medium"),[O,V]=v.useState(""),[I,S]=v.useState(""),[H,W]=v.useState(""),[ee,te]=v.useState(""),[ae,he]=v.useState([]),[Ne,De]=v.useState("standard"),[je,ke]=v.useState("4h"),[Se,Le]=v.useState(null),[nt,rt]=v.useState(null),[yt,Rt]=v.useState(new Set),[re,_e]=v.useState(new Set),st=v.useRef(new Set),dt=v.useRef(new Set),[Yt,ye]=v.useState(null),[Ae,Fe]=v.useState("backlog"),Qe=v.useMemo(()=>[{id:"backlog"},{id:"kanban"},{id:"dag"}],[]),xt=ca(Qe,Ae,Fe),nn=v.useRef(null),cn=v.useMemo(()=>({scrollContainerRef:nn}),[]),Tt=ca(Qe,Ae,Fe,cn),[gt,Bt]=v.useState(!1),[_t,Ht]=v.useState(!1),rn=v.useRef(null),bn=v.useRef(null),[Hn,Cn]=v.useState(!1),[xe,Re]=v.useState(""),[vt,At]=v.useState(""),[Dt,On]=v.useState("medium"),[an,dn]=v.useState(""),[Dn,Nt]=v.useState(null),[hn,lr]=v.useState(""),le=ne=>{G(ne),setTimeout(()=>G(""),3e3)},$e=c.find(ne=>ne.id===x)??null;v.useEffect(()=>{dt.current=re},[re]);const Ue=v.useCallback(async()=>{try{const{projects:ne}=await se.projects.list();h(ne)}catch{}},[]),We=v.useCallback(async()=>{const ne={};m==="project"&&x&&(ne.projectId=x);try{const{board:Ie}=await se.tasks.board(ne);y(Ie)}catch{}},[m,x]),Ke=v.useCallback(async()=>{try{const{agents:ne}=await se.agents.list();N(ne)}catch{}},[]),qe=v.useCallback(async()=>{try{const{users:ne}=await se.users.list(e?.orgId);C(ne)}catch{}},[e?.orgId]),Je=v.useCallback(async()=>{try{const{requirements:ne}=await se.requirements.list({});k(ne)}catch{}},[]),Wt=v.useCallback(async()=>{await Promise.all([Ue(),We(),Ke(),qe(),Je()]),D(!1)},[Ue,We,Ke,qe,Je]);v.useEffect(()=>{Wt()},[Wt]);const Zt=v.useCallback(ne=>{Le(Ie=>Ie?.id===ne.id?(n&&d.current&&l(!1),null):(n&&(l(!0),history.pushState({mobileDetail:me.WORK},"",window.location.hash)),ne)),rt(null)},[n]),Pt=v.useCallback(ne=>{rt(Ie=>Ie?.id===ne.id?(n&&d.current&&l(!1),null):(n&&(l(!0),history.pushState({mobileDetail:me.WORK},"",window.location.hash)),ne)),Le(null)},[n]),En=v.useCallback(()=>{Le(null),rt(null),n&&d.current&&l(!1)},[n]);v.useEffect(()=>{if(!n)return;const ne=()=>{d.current&&(l(!1),Le(null),rt(null))};return window.addEventListener("popstate",ne),()=>window.removeEventListener("popstate",ne)},[n]);const be=v.useRef(Se);be.current=Se,v.useEffect(()=>{const ne=be.current?6e4:15e3,Ie=setInterval(()=>{We(),Ke(),Je()},ne),Ye=Jt.on("task:update",Q=>{We();const oe=Q?.payload;oe?.taskId&&Le(Ce=>{if(!Ce||Ce.id!==oe.taskId)return Ce;const Ge={};return typeof oe.status=="string"&&(Ge.status=oe.status),Array.isArray(oe.deliverables)&&(Ge.deliverables=oe.deliverables),Array.isArray(oe.notes)&&(Ge.notes=oe.notes),oe.result!==void 0&&(Ge.result=oe.result),{...Ce,...Ge}})}),it=Jt.on("task:create",()=>{We()}),mn=["requirement:created","requirement:approved","requirement:rejected","requirement:updated","requirement:completed","requirement:cancelled","requirement:resubmitted"].map(Q=>Jt.on(Q,()=>{Je()}));return()=>{clearInterval(Ie),Ye(),it(),mn.forEach(Q=>Q())}},[We,Ke,Je]);const ze=v.useRef(g);ze.current=g;const Et=v.useRef(_);Et.current=_;const kt=v.useCallback(ne=>{if(!ne)return;const Ie=dt.current;Ie.size>0&&!Ie.has(ne)&&_e(Ye=>new Set([...Ye,ne]))},[]),[yn,_n]=v.useState(!1),or=v.useCallback((ne,Ie)=>{Le(ne),rt(null),Ie?.scrollToComments&&_n(!0),n&&(l(!0),history.pushState({mobileDetail:me.WORK},"",window.location.hash))},[n]),Nn=v.useCallback((ne,Ie)=>{rt(ne),Le(null),Ie?.scrollToComments&&_n(!0),n&&(l(!0),history.pushState({mobileDetail:me.WORK},"",window.location.hash))},[n]);v.useEffect(()=>{const ne=localStorage.getItem("markus_nav_openTask");if(!ne)return;const Ye=Object.values(g).flat().find(it=>it.id===ne);Ye&&(kt(Ye.projectId),or(Ye),localStorage.removeItem("markus_nav_openTask"))},[g,or,kt]),v.useEffect(()=>{const ne=window.location.hash.slice(1).split("/");if(la(ne[0])===me.WORK&&ne[1])Hr(ne[1]);else{const Ie=localStorage.getItem("markus_nav_projectId");Ie&&(localStorage.removeItem("markus_nav_projectId"),Hr(Ie))}},[]);const yr=v.useRef(la(window.location.hash.slice(1).split("/")[0]));v.useEffect(()=>{const ne=()=>{const Ye=window.location.hash.slice(1).split("/"),it=la(Ye[0]),sn=yr.current===me.WORK;yr.current=it,it===me.WORK&&(it===me.WORK&&Ye[1]?Hr(Ye[1]):sn&&de())},Ie=async Ye=>{const it=Ye.detail;if(la(it.page)===me.WORK){if(it.params?.openTask){const sn=it.params.openTask,mn=it.params.scrollToComments==="true";localStorage.removeItem("markus_nav_openTask");let Q=Object.values(ze.current).flat().find(oe=>oe.id===sn);if(!Q)try{Q=(await se.tasks.get(sn)).task}catch{}Q&&(kt(Q.projectId),or(Q,{scrollToComments:mn}))}if(it.params?.openRequirement){const sn=it.params.openRequirement,mn=it.params.scrollToComments==="true";let Q=Et.current.find(oe=>oe.id===sn);if(!Q)try{Q=(await se.requirements.get(sn)).requirement}catch{}Q&&(kt(Q.projectId),Nn(Q,{scrollToComments:mn}))}it.params?.projectId&&Hr(it.params.projectId)}};return window.addEventListener("markus:navigate",Ie),window.addEventListener("hashchange",ne),()=>{window.removeEventListener("markus:navigate",Ie),window.removeEventListener("hashchange",ne)}},[]);const Hr=ne=>{dt.current.size>0&&(st.current=new Set(dt.current)),_e(new Set),p(ne),f("project"),K(!1),history.replaceState(null,"",gm(me.WORK,ne))},de=()=>{_e(st.current),p(null),f("all"),K(!1),history.replaceState(null,"",gm(me.WORK))},Te=()=>{U(!1),le("Project created"),Ue()},Ve=async ne=>{if(confirm("Delete this project and unlink all its tasks?"))try{await se.projects.delete(ne),x===ne&&de(),le("Project deleted"),Ue(),We()}catch(Ie){le(`Error: ${Ie}`)}},qt=async()=>{if(!L||!O||!I)return;if(O===I){le("Assigned agent and reviewer must be different");return}const ne=H||void 0,Ie=ee||void 0;try{await se.tasks.create(L,F,O,I,Z,ne,ae.length>0?ae:void 0,Ie,Ne!=="standard"?Ne:void 0,Ne==="scheduled"?{every:je}:void 0),R(""),Y(""),he([]),te(""),De("standard"),ke("4h"),E(!1),We()}catch(Ye){le(`Error creating task: ${Ye}`)}},vr=()=>{We(),Se&&setTimeout(()=>{const ne={};m==="project"&&x&&(ne.projectId=x),se.tasks.board(ne).then(Ie=>{const it=Object.values(Ie.board).flat().find(sn=>sn.id===Se.id);Le(it||null)}).catch(()=>{})},150)},ts=async()=>{if(!xe.trim()){le("Please enter a title for this requirement");return}if(!vt.trim()){le("Please enter a description for this requirement");return}if(!an){le("Please select a project for this requirement");return}try{await se.requirements.create({title:xe.trim(),description:vt.trim(),priority:Dt,projectId:an}),le("Requirement created"),Re(""),At(""),Cn(!1),Je()}catch(ne){le(`Error: ${ne}`)}},Nr=async ne=>{try{await se.requirements.approve(ne),le("Requirement approved"),Je(),We()}catch(Ie){le(`Error: ${Ie}`)}},Ns=async()=>{if(Dn)try{await se.requirements.reject(Dn,hn),le("Requirement rejected"),Nt(null),lr(""),Je()}catch(ne){le(`Error: ${ne}`)}},xr=async ne=>{try{await se.requirements.cancel(ne),le("Requirement cancelled"),Je()}catch(Ie){le(`Error: ${Ie}`)}},tr=(ne,Ie)=>{rn.current=Ie,bn.current=null,ne.dataTransfer.effectAllowed="move",ne.dataTransfer.setData("text/plain",`task:${Ie.id}`),ne.currentTarget.style.opacity="0.4"},$s=(ne,Ie)=>{bn.current=Ie,rn.current=null,ne.dataTransfer.effectAllowed="move",ne.dataTransfer.setData("text/plain",`req:${Ie.id}`),ne.currentTarget.style.opacity="0.4"},Bs=ne=>{ne.currentTarget.style.opacity="1",rn.current=null,bn.current=null,ye(null)},Pr=(ne,Ie)=>{ne.preventDefault(),ne.dataTransfer.dropEffect="move",Yt!==Ie&&ye(Ie)},ha=(ne,Ie)=>{const Ye=ne.currentTarget.getBoundingClientRect(),{clientX:it,clientY:sn}=ne;(it<Ye.left||it>Ye.right||sn<Ye.top||sn>Ye.bottom)&&Yt===Ie&&ye(null)},qr=async(ne,Ie)=>{ne.preventDefault(),ye(null);const Ye=rn.current,it=bn.current;if(Ye){const sn=Jo.find(Q=>Q.id===Ie);if(!sn)return;const mn=sn.dropStatus;if(Ye.status===mn||Ye.status==="pending")return;try{await se.tasks.updateStatus(Ye.id,mn),We()}catch{}}else if(it){const sn=YN[Ie];if(!sn||it.status===sn)return;try{await se.requirements.updateStatus(it.id,sn),Je()}catch{}}},ma=ne=>{Rt(Ie=>{const Ye=new Set(Ie);return Ye.has(ne)?Ye.delete(ne):Ye.add(ne),Ye})},Yn=ne=>{_e(Ie=>{const Ye=new Set(Ie);return Ye.has(ne)?Ye.delete(ne):Ye.add(ne),Ye})},kr=ne=>ne.status==="archived",fs=(ne,Ie=!1)=>{let Ye=ne.filter(it=>gt||Ie||!kr(it));return m==="project"&&x&&(Ye=Ye.filter(it=>it.projectId===x)),re.size>0&&(Ye=Ye.filter(it=>it.projectId&&re.has(it.projectId))),yt.size>0&&(Ye=Ye.filter(it=>it.assignedAgentId&&yt.has(it.assignedAgentId))),Ye},Sr=ne=>ne.statuses.flatMap(Ie=>fs(g[Ie]??[])),cr=v.useMemo(()=>{let ne=_;return gt||(ne=ne.filter(Ie=>!kr(Ie))),m==="project"&&x&&(ne=ne.filter(Ie=>Ie.projectId===x)),re.size>0&&(ne=ne.filter(Ie=>Ie.projectId&&re.has(Ie.projectId))),yt.size>0&&(ne=ne.filter(Ie=>yt.has(Ie.createdBy))),ne},[_,gt,m,x,re,yt]),Wa=v.useCallback(ne=>cr.filter(Ie=>FN[Ie.status]===ne.id),[cr]),_i=Jo.filter(ne=>{if(ne.id==="failed"||ne.id==="closed"){const Ie=Sr(ne),Ye=Wa(ne);return Ie.length+Ye.length>0}return!0}),Cr=Object.values(g).flat().filter(ne=>kr(ne)).length+_.filter(ne=>kr(ne)).length,Er=v.useMemo(()=>{const ne=new Set(["completed","failed","cancelled","archived"]),Ie=Object.values(g).flat(),Ye=new Set;for(const it of Ie)it.assignedAgentId&&!ne.has(it.status)&&(!x||it.projectId===x)&&Ye.add(it.assignedAgentId);return[...w].sort((it,sn)=>{const mn=Ye.has(it.id)?0:1,Q=Ye.has(sn.id)?0:1;return mn-Q})},[w,g,x]),Hs=v.useMemo(()=>{const ne=new Set(["completed","failed","cancelled","archived"]),Ie=Object.values(g).flat(),Ye=new Set;for(const it of Ie)it.projectId&&!ne.has(it.status)&&Ye.add(it.projectId);return[...c].sort((it,sn)=>{const mn=Ye.has(it.id)?0:1,Q=Ye.has(sn.id)?0:1;return mn-Q})},[c,g]),xa=v.useMemo(()=>{const ne={};for(const Ie of Object.values(g))for(const Ye of Ie){const it=Ye.projectId??"__none__";ne[it]=(ne[it]??0)+1}return ne},[g]),Ps=Object.values(xa).reduce((ne,Ie)=>ne+Ie,0);if(M)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary",children:"Loading…"});const Tr=!!(Se||nt);return t.jsxs("div",{className:"flex-1 overflow-hidden flex bg-surface-secondary",children:[t.jsxs("div",{className:`${n?"flex-1 min-w-0":Tr?"shrink-0":"flex-1"} overflow-hidden flex flex-col bg-surface-secondary`,style:n?i?{display:"none"}:void 0:Tr?{width:`calc(100% - ${s.width}px - 4px)`}:void 0,children:[A&&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:A}),n?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:[$e?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:$e.name}),t.jsx("button",{onClick:()=>K(!X),className:`w-6 h-6 flex items-center justify-center rounded-md transition-colors shrink-0 ${X?"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:()=>U(!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:()=>{W(x??""),E(!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(ne=>t.jsx("button",{onClick:()=>Fe(ne),className:`px-2 py-0.5 text-[10px] font-medium transition-colors ${Ae===ne?"bg-brand-600/25 text-brand-500":"text-fg-tertiary"}`,children:ne==="backlog"?"Backlog":ne==="kanban"?"Kanban":"DAG"},ne))}),Cr>0&&t.jsx("button",{onClick:()=>Bt(ne=>!ne),className:`text-[10px] shrink-0 px-2 py-0.5 rounded-md transition-colors ${gt?"bg-surface-overlay text-fg-secondary":"text-fg-tertiary"}`,children:gt?"Hide archived":`${Cr} archived`}),t.jsx("div",{className:"flex-1"}),(re.size>0||yt.size>0||c.length>1||w.length>0)&&t.jsxs("button",{onClick:()=>Ht(!0),className:`px-2 py-1 text-[11px] rounded-md font-medium transition-colors flex items-center gap-1 ${re.size>0||yt.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",re.size+yt.size>0?` (${re.size+yt.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:[$e?t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.jsx(UI,{value:$e.name,onSave:async ne=>{await se.projects.update($e.id,{name:ne}),Ue()},className:"text-sm font-semibold text-fg-primary"}),t.jsx("button",{onClick:()=>K(!X),className:`w-6 h-6 flex items-center justify-center rounded-md transition-colors ${X?"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`}),Cr>0&&t.jsx("button",{onClick:()=>Bt(ne=>!ne),className:`text-[10px] shrink-0 px-2 py-0.5 rounded-md transition-colors ${gt?"bg-surface-overlay text-fg-secondary":"text-fg-tertiary hover:text-fg-secondary"}`,children:gt?`Hide ${Cr} archived`:`${Cr} archived`}),t.jsx("div",{className:"flex items-center border border-border-default/60 rounded-md overflow-hidden shrink-0",children:["backlog","kanban","dag"].map(ne=>t.jsx("button",{onClick:()=>Fe(ne),className:`px-2.5 py-1 text-[10px] font-medium transition-colors ${Ae===ne?"bg-brand-600/25 text-brand-500":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:ne==="backlog"?"Backlog":ne==="kanban"?"Kanban":"DAG"},ne))}),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:()=>{W(x??""),E(!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"})]}),!n&&c.length>1&&!x&&!X&&(Ps>0||_.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:()=>_e(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 ${re.size>0?"visible opacity-100":"invisible opacity-0"}`,children:"Clear"}),Hs.map(ne=>{const Ie=re.has(ne.id),Ye=xa[ne.id]??0;return t.jsxs("button",{onClick:()=>Yn(ne.id),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[11px] shrink-0 transition-all ${Ie?"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 ${Ie?"bg-brand-600 text-white":"bg-surface-overlay text-fg-secondary"}`,children:ne.name[0]?.toUpperCase()}),ne.name,Ye>0&&t.jsx("span",{className:"text-[9px] text-fg-tertiary ml-0.5",children:Ye})]},ne.id)})]}),!n&&w.length>0&&!X&&(Ps>0||_.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:()=>Rt(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 ${yt.size>0?"visible opacity-100":"invisible opacity-0"}`,children:"Clear"}),Er.map(ne=>{const Ie=yt.has(ne.id);return t.jsxs("button",{onClick:()=>ma(ne.id),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[11px] shrink-0 transition-all ${Ie?"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 ${Ie?"bg-brand-600 text-white":"bg-surface-overlay text-fg-secondary"}`,children:ne.name[0]?.toUpperCase()}),ne.name]},ne.id)})]}),X&&$e?t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsx(tz,{project:$e,tasks:Object.values(g).flat(),requirements:_,agents:w,onDeleteProject:()=>Ve($e.id),onUpdateProject:async ne=>{await se.projects.update($e.id,ne)},onRefresh:()=>{Ue()}})}):Ps===0&&cr.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"})]})}):Ae==="backlog"?t.jsx("div",{className:"flex-1 min-h-0 flex flex-col",onTouchStart:n?xt.onTouchStart:void 0,onTouchEnd:n?xt.onTouchEnd:void 0,children:t.jsx(iz,{tasks:fs(Object.values(g).flat()),requirements:cr,agents:w,projects:c,onTaskClick:ne=>Zt(ne),onReqClick:ne=>Pt(ne),onRefresh:()=>{We(),Je()},selectedTaskId:Se?.id,selectedReqId:nt?.id})}):Ae==="dag"?t.jsxs("div",{className:"flex-1 min-h-0 flex flex-col relative",onTouchStart:n?xt.onTouchStart:void 0,onTouchEnd:n?xt.onTouchEnd:void 0,children:[t.jsx(qI,{tasks:fs(Object.values(g).flat(),!0),requirements:cr,agents:w,showArchived:gt,onShowArchivedChange:Bt,onTaskClick:ne=>Zt(ne),onReqClick:ne=>Pt(ne),onDependencyChange:We,selectedTaskId:Se?.id,selectedReqId:nt?.id}),n&&t.jsx("button",{onClick:()=>Fe("kanban"),className:"absolute left-3 top-1/2 -translate-y-1/2 w-11 h-11 rounded-full bg-brand-500 border border-brand-400/60 shadow-xl shadow-brand-500/30 flex items-center justify-center text-white active:bg-brand-400 backdrop-blur-sm z-10",title:"Back to Kanban",children:t.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M12.79 5.23a.75.75 0 01-.02 1.06L8.832 10l3.938 3.71a.75.75 0 11-1.04 1.08l-4.5-4.25a.75.75 0 010-1.08l4.5-4.25a.75.75 0 011.06.02z",clipRule:"evenodd"})})})]}):t.jsx("div",{ref:nn,className:"flex-1 min-h-0 overflow-x-auto overflow-y-hidden px-4 py-5",onTouchStart:n?Tt.onTouchStart:void 0,onTouchEnd:n?Tt.onTouchEnd:void 0,children:t.jsx("div",{className:"flex gap-3 h-full",children:_i.map(ne=>{const Ie=Sr(ne),Ye=Wa(ne),it=Ie.length+Ye.length,sn=Yt===ne.id;return t.jsxs("div",{className:`w-[280px] shrink-0 rounded-xl flex flex-col h-full transition-colors ${sn?"bg-surface-elevated/60 ring-1 ring-brand-500/30":"bg-surface-secondary/50"}`,onDragOver:mn=>Pr(mn,ne.id),onDragLeave:mn=>ha(mn,ne.id),onDrop:mn=>{qr(mn,ne.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 ${ne.accent.replace("border-t-","bg-")}`}),t.jsx("span",{className:"text-xs font-semibold text-fg-secondary uppercase tracking-wider",children:ne.label})]}),t.jsx("span",{className:"text-[11px] text-fg-tertiary font-medium tabular-nums",children:it})]}),t.jsx("div",{className:"space-y-2 flex-1 min-h-0 overflow-y-auto scrollbar-thin px-2 py-2",children:(()=>{const mn=[...Ye.map(Q=>({kind:"req",data:Q,time:new Date(Q.updatedAt??Q.createdAt).getTime()})),...Ie.map(Q=>({kind:"task",data:Q,time:new Date(Q.updatedAt??Q.createdAt??0).getTime()}))];return mn.sort((Q,oe)=>oe.time-Q.time),mn.map(Q=>{if(Q.kind==="req"){const oe=Q.data,Ce=yi[oe.status]??{label:oe.status,cls:"bg-gray-500/15 text-fg-secondary"},Be=oe.source==="agent"&&oe.status==="pending",He=m==="all"&&oe.projectId?c.find(Xe=>Xe.id===oe.projectId):null,ct=Tl(oe.createdBy,w,T)??oe.createdBy.slice(0,10),Ze=nt?.id===oe.id;return t.jsxs("div",{role:"button",tabIndex:0,draggable:!0,onDragStart:Xe=>$s(Xe,oe),onDragEnd:Bs,onClick:()=>Pt(oe),onKeyDown:Xe=>Xe.key==="Enter"&&Pt(oe),className:`group rounded-lg p-2.5 border border-transparent transition-all cursor-grab active:cursor-grabbing
|
|
63
|
-
${Be?"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"}
|
|
64
|
-
${Ze?"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 ${Ce.cls}`,children:Ce.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:[He&&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:He.name,children:He.name}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:oe.priority}),t.jsxs("span",{className:"text-[10px] text-fg-quaternary",children:["by ",ct]})]}),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]})})]}),Be&&t.jsxs("div",{className:"flex items-center gap-2 mt-2 pt-2 border-t border-amber-500/15",children:[t.jsx("button",{onClick:Xe=>{Xe.stopPropagation(),Nr(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:Xe=>{Xe.stopPropagation(),Nt(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=Q.data,Ce=oe.subtasks?.length??0,Ge=VN[oe.status],Be=oe.status==="pending",He=oe.taskType==="scheduled"&&!!oe.scheduleConfig,ct=He?oe.scheduleConfig.every?`Every ${oe.scheduleConfig.every}`:oe.scheduleConfig.cron?"Cron":"Scheduled":null,Ze=m==="all"&&oe.projectId?c.find(It=>It.id===oe.projectId)?.name:null,Xe=oe.requirementId?_.find(It=>It.id===oe.requirementId)?.title:null,at=oe.createdBy?Tl(oe.createdBy,w,T)??oe.createdBy:null,jt=Se?.id===oe.id,Gt={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:!Be,onDragStart:It=>!Be&&tr(It,oe),onDragEnd:Bs,onClick:()=>Zt(oe),onKeyDown:It=>It.key==="Enter"&&Zt(oe),className:`group rounded-lg p-2.5 border border-transparent transition-all ${Be?"bg-amber-500/[0.06] border-amber-500/30 ring-1 ring-amber-500/15 cursor-pointer":He?"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"} ${jt?"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 ${Gt[oe.priority]??"bg-gray-400"}`,title:oe.priority}),He&&t.jsx("span",{className:"text-blue-500 shrink-0",title:ct??"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"})})}),He&&ct&&t.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-md bg-blue-500/10 text-blue-500 whitespace-nowrap",children:ct}),Ge&&t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded-md ml-auto shrink-0 ${Ge.cls}`,children:Ge.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}),(Ze||Xe||oe.blockedBy&&oe.blockedBy.length>0)&&t.jsxs("div",{className:"flex flex-wrap gap-1 mb-1.5",children:[Ze&&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:Ze,children:Ze}),Xe&&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:Xe,children:["# ",Xe]}),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:at&&t.jsxs("span",{className:"text-[10px] text-fg-quaternary",title:`by ${at}`,children:["by ",at]})}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[Ce>0&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["⋮ ",Ce]}),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 ${sx[w.find(It=>It.id===oe.assignedAgentId)?.status??""]??"bg-gray-500"}`}),w.find(It=>It.id===oe.assignedAgentId)?.name??oe.assignedAgentId.slice(0,8)]})]})]})]},oe.id)}})})()}),sn&&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"})})]},ne.id)})})})]}),!n&&Tr&&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}),(!n||i)&&Tr&&t.jsx("div",{className:`${n?"flex-1":"shrink-0"} overflow-hidden min-w-0 border-l border-border-default`,style:n?void 0:{width:s.width},children:Se?t.jsx(ez,{task:Se,agents:w,projects:c,requirements:_,allTasks:Object.values(g).flat(),users:T,onClose:En,onRefresh:vr,authUser:e,scrollToComments:yn,onScrollToCommentsDone:()=>_n(!1)}):nt?t.jsx(oz,{req:nt,agents:w,projects:c,allTasks:Object.values(g).flat(),users:T,onClose:En,onApprove:ne=>{Nr(ne),En()},onReject:ne=>{Nt(ne),En()},onCancel:ne=>{xr(ne),En()},onStatusChange:async(ne,Ie)=>{try{await se.requirements.updateStatus(ne,Ie),le(`Requirement status → ${Ie}`),Je(),We()}catch(Ye){le(`Error: ${Ye}`)}},scrollToComments:yn,onScrollToCommentsDone:()=>_n(!1),onRefresh:Je,authUser:e}):null}),q&&t.jsx(qN,{orgId:e?.orgId,onCreated:Te,onClose:()=>U(!1)}),z&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-3",onClick:()=>E(!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 ${n?"w-full":"w-[28rem]"}`,onClick:ne=>ne.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:H,onChange:ne=>W(ne.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(ne=>t.jsx("option",{value:ne.id,children:ne.name},ne.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:ne=>te(ne.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…"}),_.filter(ne=>ne.status==="in_progress"&&(!H||ne.projectId===H)).map(ne=>t.jsx("option",{value:ne.id,children:ne.title},ne.id))]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Title"}),t.jsx("input",{autoFocus:!n,value:L,onChange:ne=>R(ne.target.value),onKeyDown:ne=>{ne.key==="Enter"&&qt()},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:F,onChange:ne=>Y(ne.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:Z,onChange:ne=>B(ne.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:O,onChange:ne=>V(ne.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(ne=>t.jsx("option",{value:ne.id,children:ne.name},ne.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:I,onChange:ne=>S(ne.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(ne=>ne.id!==O).map(ne=>t.jsx("option",{value:ne.id,children:ne.name},ne.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:Ne,onChange:ne=>De(ne.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)"})]})]}),Ne==="scheduled"&&t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Frequency"}),t.jsxs("select",{value:je,onChange:ne=>ke(ne.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:ne=>{const Ie=ne.target.value;Ie&&!ae.includes(Ie)&&he([...ae,Ie])},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(g).flat().filter(ne=>ne.status!=="completed"&&ne.status!=="cancelled"&&!ae.includes(ne.id)).map(ne=>t.jsx("option",{value:ne.id,children:ne.title},ne.id))]}),ae.length>0&&t.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:ae.map(ne=>{const Ie=Object.values(g).flat().find(Ye=>Ye.id===ne);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:["⏳ ",Ie?Ie.title.slice(0,30):ne.slice(-8),t.jsx("button",{onClick:()=>he(ae.filter(Ye=>Ye!==ne)),className:"ml-0.5 text-amber-600/60 hover:text-amber-600",children:"×"})]},ne)})})]}),t.jsxs("div",{className:"flex justify-end gap-3 pt-1",children:[t.jsx("button",{onClick:()=>E(!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:()=>{qt()},disabled:!O||!I,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 rounded-lg text-white disabled:opacity-50",children:"Create"})]})]})}),Hn&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-3",onClick:()=>{Cn(!1),Re(""),At("")},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 ${n?"w-full":"w-[28rem]"}`,onClick:ne=>ne.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:an,onChange:ne=>dn(ne.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(ne=>t.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Title"}),t.jsx("input",{value:xe,onChange:ne=>Re(ne.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:!n,onKeyDown:ne=>{ne.key==="Enter"&&xe.trim()&&ts()}})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Description"}),t.jsx("textarea",{value:vt,onChange:ne=>At(ne.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:Dt,onChange:ne=>On(ne.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:()=>{Cn(!1),Re(""),At("")},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:()=>{ts()},disabled:!xe.trim()||!vt.trim()||!an,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"})]})]})}),Dn&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-3",onClick:()=>Nt(null),children:t.jsxs("div",{className:`bg-surface-secondary border border-border-default rounded-xl p-6 space-y-4 ${n?"w-full":"w-96"}`,onClick:ne=>ne.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:hn,onChange:ne=>lr(ne.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:!n})]}),t.jsxs("div",{className:"flex justify-end gap-3",children:[t.jsx("button",{onClick:()=>Nt(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:()=>{Ns()},className:"px-4 py-2 text-sm bg-red-600 hover:bg-red-500 rounded-lg text-white",children:"Reject"})]})]})}),_t&&t.jsxs("div",{className:"fixed inset-0 z-[60] flex flex-col justify-end",onClick:()=>Ht(!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:ne=>ne.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:[(re.size>0||yt.size>0)&&t.jsx("button",{onClick:()=>{_e(new Set),Rt(new Set)},className:"text-[11px] text-brand-500 font-medium",children:"Clear all"}),t.jsx("button",{onClick:()=>Ht(!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:Hs.map(ne=>{const Ie=re.has(ne.id),Ye=xa[ne.id]??0;return t.jsxs("button",{onClick:()=>Yn(ne.id),className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-[11px] transition-all ${Ie?"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 ${Ie?"bg-brand-600 text-white":"bg-surface-overlay text-fg-tertiary"}`,children:ne.name[0]?.toUpperCase()}),ne.name,Ye>0&&t.jsx("span",{className:"text-[9px] text-fg-tertiary",children:Ye})]},ne.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:Er.map(ne=>{const Ie=yt.has(ne.id);return t.jsxs("button",{onClick:()=>ma(ne.id),className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-[11px] transition-all ${Ie?"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 ${Ie?"bg-brand-600 text-white":"bg-surface-overlay text-fg-tertiary"}`,children:ne.name[0]?.toUpperCase()}),ne.name]},ne.id)})})]}),t.jsx("div",{className:"h-[env(safe-area-inset-bottom,0px)]"})]})]})]})}function lz({requirementId:e,agents:n,authUser:s}){const[i,l]=v.useState([]);v.useEffect(()=>{se.requirements.getComments(e).then(f=>l(f.comments)).catch(()=>{})},[e]),v.useEffect(()=>Jt.on("requirement:comment",x=>{x.payload?.requirementId===e&&x.payload.comment&&l(p=>p.some(g=>g.id===x.payload.comment.id)?p:[...p,x.payload.comment])}),[e]);const[d,c]=v.useState(null),h=async(f,x,p)=>{await se.requirements.addComment(e,f,s?.name,s?.id,x.length>0?x:void 0,p)},m=v.useCallback(f=>{c({id:f.id,authorName:f.authorName,content:f.content.slice(0,100)})},[]);return t.jsxs("div",{children:[t.jsxs("label",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2 block",children:["Comments ",i.length>0&&t.jsxs("span",{className:"font-normal",children:["(",i.length,")"]})]}),t.jsxs("div",{className:"space-y-0.5 mb-3",children:[i.length===0&&t.jsx("p",{className:"text-xs text-fg-tertiary text-center py-4",children:"No comments yet."}),i.map(f=>t.jsx($o,{comment:f,agents:n,onReply:m},f.id))]}),t.jsx(Vj,{agents:n,onSubmit:h,replyTo:d,onCancelReply:()=>c(null)})]})}function oz({req:e,agents:n,projects:s,allTasks:i,users:l,onClose:d,onApprove:c,onReject:h,onCancel:m,onStatusChange:f,onRefresh:x,authUser:p,scrollToComments:g,onScrollToCommentsDone:y}){const w=$r(),[N,T]=v.useState(!1),[C,_]=v.useState(e.description),[k,M]=v.useState(!1),D=v.useRef(null);v.useEffect(()=>{if(!g)return;const E=setTimeout(()=>{const L=D.current;L&&L.scrollTo({top:L.scrollHeight,behavior:"smooth"}),y?.()},300);return()=>clearTimeout(E)},[g,y]);const A=yi[e.status]??{label:e.status,cls:"bg-gray-500/15 text-fg-secondary"},G=e.source==="agent",X=G&&e.status==="pending",K=e.status==="pending"||e.status==="in_progress",$=e.status==="completed"||e.status==="rejected"||e.status==="cancelled"||e.status==="archived",q=e.projectId?s.find(E=>E.id===e.projectId):null,U=Tl(e.createdBy,n,l)??e.createdBy.slice(0,12),z=i.filter(E=>e.taskIds.includes(E.id));return v.useEffect(()=>{_(e.description),T(!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:[w&&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 ${A.cls}`,children:A.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})]})]}),!w&&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",{ref:D,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"}),N?t.jsxs("div",{className:"space-y-2",children:[t.jsx("textarea",{value:C,onChange:E=>_(E.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:()=>{T(!1),_(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()=>{M(!0);try{await se.requirements.update(e.id,{description:C}),T(!1),x?.()}catch{}finally{M(!1)}},disabled:k,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(ir,{content:e.description,className:"text-sm text-fg-secondary leading-relaxed"}):t.jsx("p",{className:"text-sm text-fg-tertiary italic",children:"No description"}),!$&&t.jsx("button",{onClick:()=>{_(e.description),T(!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:U}),G&&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()})]}),q&&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:q.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:Tl(e.approvedBy,n,l)??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(E=>t.jsxs("span",{className:"text-[10px] bg-surface-elevated text-fg-secondary px-2 py-0.5 rounded-full",children:["#",E]},E))}),z.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 (",z.length,")"]}),t.jsx("div",{className:"space-y-1.5",children:z.map(E=>{const L=VN[E.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 ${KI[E.priority]?.replace("border-l-","bg-")??"bg-gray-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:E.title}),L&&t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded shrink-0 ${L.cls}`,children:L.label})]},E.id)})})]}),t.jsx(lz,{requirementId:e.id,agents:n,authUser:p})]}),t.jsxs("div",{className:"flex items-center gap-2 p-5 pt-3 border-t border-border-default",children:[X&&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"})]}),!X&&f&&!$&&t.jsx("select",{value:e.status,onChange:E=>{E.target.value!==e.status&&f(e.id,E.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:sz.map(E=>{const L=yi[E],R=E===e.status||(rx[e.status]?.has(E)??!1);return t.jsx("option",{value:E,disabled:!R,children:L?.label??E},E)})}),$&&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"}),K&&!X&&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 Ts(e){return Array.isArray(e)?e.map(n=>String(n).trim()).filter(Boolean):typeof e=="string"&&e?e.split(",").map(n=>n.trim()).filter(Boolean):[]}function cz(e){return e.files&&typeof e.files=="object"&&!Array.isArray(e.files)?e.files:null}function xi({label:e,value:n}){return n?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:n})]}):null}function ol({label:e,value:n,color:s}){if(!n)return null;const i={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 ${i[s]??i.gray} capitalize inline-block`,children:n})]})}function mm({files:e}){const[n,s]=v.useState(Object.keys(e)[0]??""),i=Object.keys(e);return i.length===0?null:t.jsxs("div",{children:[t.jsxs("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:["Files (",i.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:i.map(l=>t.jsx("button",{onClick:()=>s(l),className:`px-2 py-0.5 text-[10px] rounded whitespace-nowrap transition-colors ${n===l?"bg-brand-600/30 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:l},l))}),n&&e[n]!=null&&t.jsx("pre",{className:"p-2 text-[10px] text-fg-secondary max-h-[120px] overflow-auto whitespace-pre-wrap font-mono",children:e[n]})]})]})}function dz({artifact:e,mode:n}){const s=cz(e),i=e.agent,l=e.team,d=e.dependencies,c=e.displayName??e.name;if(n==="agent"){const h=i?.roleName,m=i?.agentRole,f=i?.llmProvider,x=i?.llmModel,p=Ts(d?.env),g=Ts(d?.skills);return t.jsxs("div",{className:"space-y-3 text-sm",children:[t.jsx(xi,{label:"Name",value:c}),t.jsx(xi,{label:"Description",value:e.description}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(ol,{label:"Role Template",value:h,color:"indigo"}),t.jsx(ol,{label:"Agent Role",value:m,color:m==="manager"?"purple":"cyan"})]}),Ts(e.tags).length>0&&t.jsx("div",{className:"flex flex-wrap gap-1",children:Ts(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(ol,{label:"LLM Provider",value:f,color:"gray"}),x&&t.jsx(ol,{label:"LLM Model",value:x,color:"gray"})]}),p.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:p.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))})]}),g.length>0&&t.jsx(xi,{label:"Skills",value:g.join(", ")}),s&&t.jsx(mm,{files:s})]})}if(n==="team"){const m=l?.members??[];return t.jsxs("div",{className:"space-y-3 text-sm",children:[t.jsx(xi,{label:"Name",value:c}),t.jsx(xi,{label:"Description",value:e.description}),t.jsx("div",{className:"flex flex-wrap gap-2",children:t.jsx(ol,{label:"Category",value:e.category,color:"indigo"})}),Ts(e.tags).length>0&&t.jsx("div",{className:"flex flex-wrap gap-1",children:Ts(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(mm,{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)]})]}),Ts(f.skills).length>0&&t.jsx("div",{className:"mt-1 ml-7 flex flex-wrap gap-1",children:Ts(f.skills).map(p=>t.jsx("span",{className:"px-1 py-0.5 text-[9px] bg-green-500/10 text-green-600 rounded font-mono",children:p},p))})]},x))})]})]})}return t.jsxs("div",{className:"space-y-3 text-sm",children:[t.jsx(xi,{label:"Name",value:c}),t.jsx(xi,{label:"Description",value:e.description}),t.jsx("div",{className:"flex gap-2",children:t.jsx(ol,{label:"Category",value:e.category,color:"indigo"})}),s&&t.jsx(mm,{files:s}),Ts(e.tags).length>0&&t.jsx("div",{className:"flex flex-wrap gap-1",children:Ts(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 Co={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},v1={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"}},j1=["file","directory"],_s={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 w1(){const e=$r(),n=fu({side:"left",defaultWidth:384,minWidth:280,maxWidth:600,storageKey:"markus_deliverables_list"}),[s,i]=v.useState(!1),l=v.useRef(s);l.current=s,v.useEffect(()=>{if(!e)return;const be=()=>{l.current&&i(!1)};return window.addEventListener("popstate",be),()=>window.removeEventListener("popstate",be)},[e]);const d=100,[c,h]=v.useState([]),[m,f]=v.useState(0),[x,p]=v.useState(!1),[g,y]=v.useState([]),[w,N]=v.useState([]),[T,C]=v.useState(!0),[_,k]=v.useState(""),[M,D]=v.useState(""),[A,G]=v.useState(""),[X,K]=v.useState(""),[$,q]=v.useState(""),[U,z]=v.useState(""),[E,L]=v.useState(""),[R,F]=v.useState("date"),[Y,Z]=v.useState(null),[B,O]=v.useState(null),[V,I]=v.useState(""),[S,H]=v.useState(!1),[W,ee]=v.useState(!1),[te,ae]=v.useState(new Set),he=v.useMemo(()=>[{id:"date"},{id:"project"},{id:"agent"},{id:"type"}],[]),Ne=v.useCallback(be=>{F(be),ae(new Set)},[]),De=ca(he,R,Ne),je=v.useRef(null),[ke,Se]=v.useState("file"),[Le,nt]=v.useState(""),[rt,yt]=v.useState(""),[Rt,re]=v.useState(""),[_e,st]=v.useState(""),[dt,Yt]=v.useState(""),[ye,Ae]=v.useState(null),[Fe,Qe]=v.useState(null),[xt,nn]=v.useState(!1),[cn,Tt]=v.useState(!1),[gt,Bt]=v.useState(!1),[_t,Ht]=v.useState(!1),rn=v.useRef(null),bn=v.useRef(null),[Hn,Cn]=v.useState(""),xe=v.useRef(void 0),Re=(be,ze)=>{O({type:be,text:ze}),setTimeout(()=>O(null),3e3)},vt=async be=>{try{return await navigator.clipboard.writeText(be),!0}catch{try{const ze=document.createElement("textarea");ze.value=be,ze.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0",document.body.appendChild(ze),ze.select();const Et=document.execCommand("copy");return document.body.removeChild(ze),Et}catch{return!1}}},At=async be=>{await vt(be)?(Ht(!0),setTimeout(()=>Ht(!1),1500)):Re("error","Copy failed — try long-pressing to copy manually")},Dt=v.useMemo(()=>new Map(w.map(be=>[be.id,be])),[w]),On=v.useMemo(()=>new Map(g.map(be=>[be.id,be])),[g]);v.useEffect(()=>{se.projects.list().then(be=>y(be.projects)).catch(()=>{}),se.agents.list().then(be=>N(be.agents??[])).catch(()=>{}),se.system.storage().then(be=>Cn(be.dataDir+"/shared")).catch(()=>{})},[]),v.useEffect(()=>(xe.current=setTimeout(()=>D(_),300),()=>clearTimeout(xe.current)),[_]);const an=v.useMemo(()=>({q:M||void 0,projectId:X||void 0,agentId:$||void 0,type:A||void 0,status:U||void 0,artifactType:E||void 0}),[M,X,$,A,U,E]),dn=v.useCallback(async()=>{C(!0);try{const{results:be,total:ze}=await se.deliverables.search({...an,offset:0,limit:d});h(be),f(ze)}catch{h([]),f(0)}C(!1)},[an]),Dn=v.useCallback(async()=>{if(!(x||c.length>=m)){p(!0);try{const{results:be,total:ze}=await se.deliverables.search({...an,offset:c.length,limit:d});h(Et=>[...Et,...be]),f(ze)}catch{}p(!1)}},[an,c.length,m,x]);v.useEffect(()=>{dn()},[dn]),v.useEffect(()=>Jt.on("deliverable:created",()=>dn()),[dn]);const Nt=v.useCallback(()=>{const be=je.current;!be||T||x||c.length>=m||be.scrollHeight<=be.clientHeight+100&&Dn()},[T,x,c.length,m,Dn]);v.useEffect(()=>{const be=je.current;if(!be)return;const ze=()=>{be.scrollTop+be.clientHeight>=be.scrollHeight-100&&Dn()};return be.addEventListener("scroll",ze,{passive:!0}),()=>be.removeEventListener("scroll",ze)},[Dn]),v.useEffect(()=>{Nt()},[Nt,te]);const hn=v.useMemo(()=>{const be=new Map;for(const Et of c){let kt,yn;if(R==="project")kt=Et.projectId??"_none",yn=Et.projectId?On.get(Et.projectId)?.name??Et.projectId:"No Project";else if(R==="agent")kt=Et.agentId??"_none",yn=Et.agentId?Dt.get(Et.agentId)?.name??Et.agentId:"Unknown";else if(R==="type")kt=Et.type,yn=Et.type.charAt(0).toUpperCase()+Et.type.slice(1);else{const _n=new Date(Et.updatedAt);kt=`${_n.getFullYear()}-${String(_n.getMonth()+1).padStart(2,"0")}-${String(_n.getDate()).padStart(2,"0")}`,yn=kt}be.has(kt)||be.set(kt,{label:yn,items:[]}),be.get(kt).items.push(Et)}const ze=[...be.entries()];return R==="date"?ze.sort((Et,kt)=>kt[0].localeCompare(Et[0])):ze.sort((Et,kt)=>Et[1].label.localeCompare(kt[1].label)),ze},[c,R,On,Dt]),lr=async()=>{if(!(!Le.trim()||!rt.trim())){ee(!0);try{await se.deliverables.create({type:ke,title:Le,summary:rt,reference:Rt,projectId:_e||void 0,tags:dt.split(",").map(be=>be.trim()).filter(Boolean)}),H(!1),Re("success","Deliverable created"),dn()}catch(be){Re("error",`Error: ${be}`)}ee(!1)}},le=async be=>{I("verify");try{await se.deliverables.verify(be.id),Re("success","Verified"),Z({...be,status:"verified"}),dn()}catch(ze){Re("error",`Error: ${ze}`)}I("")},$e=async be=>{I("flag");try{await se.deliverables.update(be.id,{status:"outdated"}),Re("success","Flagged as outdated"),Z({...be,status:"outdated"}),dn()}catch(ze){Re("error",`Error: ${ze}`)}I("")},Ue=async be=>{I("remove");try{await se.deliverables.remove(be.id),Re("success","Removed"),Z(null),dn()}catch(ze){Re("error",`Error: ${ze}`)}I("")},We=()=>{ht.navigate(me.BUILDER)},Ke=async be=>{if(be.reference){if(be.type==="directory"){Tt(!0);return}nn(!0);try{const ze=await se.files.preview(be.reference);ze.type==="image"&&ze.mimeType?Qe({src:`data:${ze.mimeType};base64,${ze.content}`,name:ze.name}):Ae(ze.content)}catch{Ae(null),be.type==="file"&&Tt(!0)}nn(!1)}};v.useEffect(()=>{Ae(null),Qe(null),Tt(!1),Bt(!1),Y&&Ke(Y)},[Y?.id]),v.useEffect(()=>{if(!gt)return;const be=ze=>{bn.current&&!bn.current.contains(ze.target)&&Bt(!1)};return document.addEventListener("mousedown",be),()=>document.removeEventListener("mousedown",be)},[gt]);const qe=async(be,ze)=>{const Et=rn.current?.firstElementChild;if(!Et)return;const kt=uz(Et,be);try{await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([kt],{type:"text/html"}),"text/plain":new Blob([ze],{type:"text/plain"})})]),Re("success",be==="light"?"HTML (light) copied":"HTML (dark) copied")}catch{const yn=await vt(ze);Re(yn?"success":"error",yn?"Text copied (HTML not supported)":"Copy failed")}Bt(!1)},Je=be=>t.jsxs("div",{className:"relative group/preview",children:[t.jsxs("div",{className:"absolute -top-1 -right-1 z-10",ref:bn,children:[t.jsx("button",{onClick:()=>Bt(ze=>!ze),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"})})}),gt&&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 ze=await vt(be);Re(ze?"success":"error",ze?"Markdown source copied":"Copy failed"),Bt(!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:()=>qe("light",be),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:()=>qe("dark",be),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:rn,children:t.jsx(ir,{content:be,className:"text-fg-secondary text-sm"})})]}),Wt=v.useCallback(be=>{ae(ze=>{const Et=new Set(ze);return Et.has(be)?Et.delete(be):Et.add(be),Et})},[]),Zt=v.useCallback(()=>{te.size===hn.length?ae(new Set):ae(new Set(hn.map(([be])=>be)))},[te.size,hn]),Pt=()=>{nt(""),yt(""),re(""),Yt(""),Se("file"),g.length>0&&st(g[0].id),H(!0)},En=be=>{Z(be),e&&(i(!0),history.pushState({mobileDetail:me.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:n.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:Pt,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:_,onChange:be=>k(be.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"}),Hn&&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:Hn}),t.jsx("button",{onClick:()=>{se.system.openPath(Hn)},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(Va,{label:"All types",value:"",current:A||E||"",onClick:()=>{G(""),L("")}}),j1.map(be=>t.jsx(Va,{label:`${Co[be]?.icon??""} ${be}`,value:be,current:A,onClick:ze=>{G(ze),L("")}},be)),["agent","team","skill"].map(be=>t.jsx(Va,{label:`${_s[be].icon} ${_s[be].label}`,value:be,current:E,onClick:ze=>{L(ze),G("")}},be))]}),g.length>0&&t.jsxs("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:[t.jsx(Va,{label:"All projects",value:"",current:X,onClick:K}),g.map(be=>t.jsx(Va,{label:be.name,value:be.id,current:X,onClick:K},be.id))]}),t.jsxs("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:[t.jsx(Va,{label:"Active",value:"",current:U,onClick:z}),t.jsx(Va,{label:"Verified",value:"verified",current:U,onClick:z}),t.jsx(Va,{label:"Outdated",value:"outdated",current:U,onClick:z})]}),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(be=>t.jsx("button",{onClick:()=>{F(be),ae(new Set)},className:`px-2 py-1 rounded text-xs transition-colors ${R===be?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:bg-surface-overlay"}`,children:be.charAt(0).toUpperCase()+be.slice(1)},be)),hn.length>1&&t.jsx("button",{onClick:Zt,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===hn.length?"Expand all":"Collapse all",children:te.size===hn.length?"▶ Expand":"▼ Collapse"})]})]}),B&&t.jsx("div",{className:`mx-4 mt-2 px-3 py-1.5 text-xs rounded-lg ${B.type==="success"?"bg-green-500/15 text-green-600":"bg-red-500/15 text-red-500"}`,children:B.text}),t.jsxs("div",{ref:je,className:"flex-1 overflow-y-auto p-2 space-y-1",onTouchStart:e?De.onTouchStart:void 0,onTouchEnd:e?De.onTouchEnd:void 0,children:[T?t.jsx("div",{className:"p-4 space-y-3",children:[1,2,3].map(be=>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"})]},be))}):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:Pt,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:"+ Create first"})]}):hn.map(([be,ze])=>{const Et=te.has(be);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>Wt(be),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 ${Et?"":"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:ze.label}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:["(",ze.items.length,")"]})]}),!Et&&ze.items.map(kt=>t.jsxs("button",{onClick:()=>En(kt),className:`w-full text-left p-3 rounded-lg transition-colors ${Y?.id===kt.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:kt.title}),t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[kt.artifactType&&_s[kt.artifactType]?t.jsxs("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${_s[kt.artifactType].color}`,children:[_s[kt.artifactType].icon," ",_s[kt.artifactType].label]}):t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium uppercase ${Co[kt.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:kt.type}),t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${v1[kt.status]?.color??"bg-surface-elevated text-fg-tertiary"}`,children:kt.status}),kt.agentId&&t.jsx("span",{className:"text-[10px] text-fg-tertiary truncate",children:Dt.get(kt.agentId)?.name??"Agent"})]})]},kt.id))]},be)}),x&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-fg-tertiary",children:[t.jsx(xm,{})," ",t.jsx("span",{className:"text-[10px]",children:"Loading more..."})]}),!T&&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:n.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:Y?.title??"Details"})]}),Y?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:Y.title}),t.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[Y.status!=="verified"&&t.jsx("button",{onClick:()=>le(Y),disabled:!!V,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:V==="verify"?"Verifying...":"Verify"}),Y.status!=="outdated"&&t.jsx("button",{onClick:()=>$e(Y),disabled:!!V,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:V==="flag"?"Flagging...":"Flag Outdated"}),t.jsx("button",{onClick:()=>Ue(Y),disabled:!!V,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:V==="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 ${Co[Y.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:[Co[Y.type]?.icon??""," ",Y.type]}),t.jsx("span",{className:`px-2 py-0.5 rounded text-xs ${v1[Y.status]?.color??"bg-surface-elevated text-fg-tertiary"}`,children:Y.status}),Y.artifactType&&_s[Y.artifactType]&&t.jsxs("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${_s[Y.artifactType].color}`,children:[_s[Y.artifactType].icon," Builder ",_s[Y.artifactType].label]})]}),Y.reference&&(Y.type==="file"||Y.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:()=>{se.files.reveal(Y.reference).catch(()=>Re("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:Y.reference}),t.jsx("button",{onClick:()=>{se.files.reveal(Y.reference).catch(()=>Re("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:()=>At(Y.reference),className:`px-2 py-1 text-[10px] rounded transition-colors shrink-0 ${_t?"bg-green-500/20 text-green-600":"bg-surface-overlay/50 text-fg-secondary hover:bg-surface-overlay"}`,title:"Copy path to clipboard",children:_t?"Copied!":"Copy"})]}),Y.reference&&Y.type!=="file"&&Y.type!=="directory"&&t.jsx("div",{className:"mt-2",children:t.jsx("span",{className:"text-xs text-fg-tertiary font-mono break-all",children:Y.reference})})]}),Y.artifactType&&Y.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(dz,{artifact:Y.artifactData,mode:Y.artifactType})}),Y.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:Y.reference})]}),t.jsx("div",{className:"flex gap-2",children:t.jsx("button",{onClick:We,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"})}),Y.summary&&t.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:t.jsx(ir,{content:Y.summary,className:"text-fg-secondary text-sm"})})]}):t.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:xt?t.jsxs("div",{className:"flex items-center gap-2 text-fg-tertiary text-sm",children:[t.jsx(xm,{})," Loading preview..."]}):Fe?t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx("img",{src:Fe.src,alt:Fe.name,className:"max-w-full max-h-[60vh] rounded-lg object-contain"}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:Fe.name})]}):ye?Je(ye):cn?t.jsxs("div",{className:"space-y-3",children:[t.jsxs("p",{className:"text-sm text-fg-secondary",children:["This ",Y.type," cannot be previewed in the browser."]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:()=>{se.files.reveal(Y.reference).catch(()=>Re("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:Y.reference}),t.jsx("button",{onClick:()=>{se.files.reveal(Y.reference).catch(()=>Re("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:()=>At(Y.reference),className:`px-3 py-2 text-xs rounded-lg transition-colors shrink-0 ${_t?"bg-green-500/20 text-green-600":"bg-surface-overlay/50 text-fg-secondary hover:bg-surface-overlay"}`,children:_t?"Copied!":"Copy"})]})]}):Y.summary?Je(Y.summary):t.jsx("p",{className:"text-sm text-fg-tertiary italic",children:"No content"})}),(Y.diffStats||Y.testResults)&&t.jsxs("div",{className:"flex gap-4 flex-wrap",children:[Y.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:[Y.diffStats.filesChanged," files"]}),t.jsxs("span",{className:"text-green-600",children:["+",Y.diffStats.additions]}),t.jsxs("span",{className:"text-red-500",children:["-",Y.diffStats.deletions]})]})]}),Y.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:[Y.testResults.passed," passed"]}),t.jsxs("span",{className:"text-red-500",children:[Y.testResults.failed," failed"]}),t.jsxs("span",{className:"text-fg-secondary",children:[Y.testResults.skipped," skipped"]})]})]})]}),Y.tags.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1.5",children:Y.tags.map(be=>t.jsx("span",{className:"px-2 py-0.5 text-xs bg-surface-elevated text-fg-secondary rounded",children:be},be))}),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:[Y.taskId&&t.jsxs("button",{onClick:()=>ht.navigate(me.WORK,{openTask:Y.taskId}),className:"text-xs text-brand-500 hover:underline bg-brand-500/10 px-2.5 py-1 rounded",children:["Task: ",Y.taskId.slice(0,12),"..."]}),Y.agentId&&t.jsxs("button",{onClick:()=>ht.navigate(me.TEAM,{selectAgent:Y.agentId}),className:"text-xs text-blue-600 hover:underline bg-blue-500/10 px-2.5 py-1 rounded",children:["Agent: ",Dt.get(Y.agentId)?.name??Y.agentId.slice(0,12)]}),Y.projectId&&t.jsxs("button",{onClick:()=>ht.navigate(me.WORK,{projectId:Y.projectId}),className:"text-xs text-blue-600 hover:underline bg-blue-500/10 px-2.5 py-1 rounded",children:["Project: ",On.get(Y.projectId)?.name??Y.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(Y.createdAt).toLocaleString()})]}),t.jsxs("span",{children:["Updated: ",t.jsx("span",{className:"text-fg-secondary",children:new Date(Y.updatedAt).toLocaleString()})]}),t.jsxs("span",{children:["Accessed: ",t.jsxs("span",{className:"text-fg-secondary",children:[Y.accessCount,"x"]})]})]}),t.jsxs("div",{className:"text-fg-muted select-all",children:["ID: ",Y.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"})]})})]}),S&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:()=>!W&&H(!1),children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[36rem] space-y-4",onClick:be=>be.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:be=>Se(be.target.value),className:"w-full bg-surface-elevated border border-border-default rounded-lg px-3 py-2 text-sm text-fg-primary",children:j1.map(be=>t.jsxs("option",{value:be,children:[Co[be]?.icon??""," ",be]},be))})]}),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:Le,onChange:be=>nt(be.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:Rt,onChange:be=>re(be.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:rt,onChange:be=>yt(be.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:dt,onChange:be=>Yt(be.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:_e,onChange:be=>st(be.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"}),g.map(be=>t.jsx("option",{value:be.id,children:be.name},be.id))]})]})]}),t.jsxs("div",{className:"flex justify-end gap-3 pt-1 border-t border-border-default",children:[t.jsx("button",{onClick:()=>H(!1),disabled:W,className:"text-sm text-fg-tertiary hover:text-fg-secondary disabled:opacity-50 transition-colors py-2",children:"Cancel"}),t.jsxs("button",{onClick:lr,disabled:W||!Le.trim()||!rt.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:[W&&t.jsx(xm,{}),W?"Creating...":"Create"]})]})]})})]})}function uz(e,n){const s=e.cloneNode(!0),i=n==="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"},l={p:`margin:0 0 10px;color:${i.text};line-height:1.7;`,h1:`font-size:1.6em;font-weight:700;color:${i.heading};margin:20px 0 10px;line-height:1.3;border-bottom:1px solid ${i.border};padding-bottom:6px;`,h2:`font-size:1.35em;font-weight:700;color:${i.heading};margin:18px 0 8px;line-height:1.3;`,h3:`font-size:1.15em;font-weight:600;color:${i.heading};margin:14px 0 6px;line-height:1.3;`,h4:`font-size:1em;font-weight:600;color:${i.heading};margin:12px 0 4px;`,strong:`font-weight:600;color:${i.strong};`,em:"font-style:italic;",a:`color:${i.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:${i.text};`,blockquote:`border-left:3px solid ${i.blockquoteBorder};padding:2px 0 2px 14px;margin:10px 0;color:${i.blockquoteText};`,hr:`border:none;border-top:1px solid ${i.hrColor};margin:20px 0;`,table:"border-collapse:collapse;width:100%;margin:10px 0;",thead:`background:${i.tableHeaderBg};`,th:`border:1px solid ${i.tableBorder};padding:8px 12px;text-align:left;font-weight:600;color:${i.tableHeaderText};`,td:`border:1px solid ${i.tableBorder};padding:8px 12px;color:${i.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:${i.preBg};color:${i.preText};padding:14px;border-radius:6px;overflow-x:auto;margin:10px 0;font-size:0.88em;line-height:1.5;border:1px solid ${i.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:${i.codeBg};color:${i.codeText};padding:2px 6px;border-radius:4px;font-size:0.9em;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;`):l[h]&&c.setAttribute("style",l[h]),Array.from(c.children).forEach(d)}return s.removeAttribute("class"),Array.from(s.children).forEach(c=>d(c)),`<div style="background:${i.bg};color:${i.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 Va({label:e,value:n,current:s,onClick:i}){return t.jsx("button",{onClick:()=>i(s===n?"":n),className:`px-2 py-1 rounded text-xs whitespace-nowrap shrink-0 transition-colors ${s===n?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:bg-surface-overlay"}`,children:e})}function xm(){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 aa(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString()}function fl(e){return e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function fz(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 GN({authUser:e}){const[n,s]=v.useState("weekly"),[i,l]=v.useState(null),[d,c]=v.useState(!0),[h,m]=v.useState(""),[f,x]=v.useState(null),[p,g]=v.useState([]),[y,w]=v.useState("totalTokens"),[N,T]=v.useState(!0),[C,_]=v.useState("generate"),[k,M]=v.useState([]),[D,A]=v.useState(null),[G,X]=v.useState([]),[K,$]=v.useState(""),[q,U]=v.useState(""),z=S=>{U(S),setTimeout(()=>U(""),3e3)},E=v.useCallback(async S=>{c(!0),m("");try{const{report:H}=await se.reports.generate({period:S,scope:"org",orgId:"default"});l(H)}catch(H){m(String(H)),l(null)}c(!1)},[]),L=v.useCallback(()=>{se.usage.summary().then(S=>x(S.usage)).catch(()=>{}),se.usage.agents().then(S=>g(S.agents)).catch(()=>{})},[]),R=v.useCallback(async()=>{try{const{reports:S}=await se.reports.list();M(S)}catch{}},[]),F=v.useCallback(async S=>{A(S);try{const{feedback:H}=await se.reports.getFeedback(S.id);X(H)}catch{X([])}},[]);v.useEffect(()=>{E(n)},[n,E]),v.useEffect(()=>{L();const S=setInterval(L,3e4);return()=>clearInterval(S)},[L]),v.useEffect(()=>{C==="history"&&R()},[C,R]);const Y=v.useMemo(()=>[...p].sort((S,H)=>{const W=S[y],ee=H[y];return N?ee-W:W-ee}),[p,y,N]),Z=p.reduce((S,H)=>S+H.estimatedCost,0),B=p.reduce((S,H)=>S+H.tokensUsedToday,0),O=Math.max(1,...p.map(S=>S.totalTokens)),V=S=>{y===S?T(!N):(w(S),T(!0))},I={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 flex-col gap-3 md:flex-row md:items-center md:justify-between",children:[t.jsxs("div",{className:"flex items-center gap-4 flex-wrap",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:()=>_("generate"),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${C==="generate"?"bg-surface-overlay text-fg-primary shadow-sm":"text-fg-tertiary hover:text-fg-secondary"}`,children:"Generate"}),t.jsxs("button",{onClick:()=>_("history"),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${C==="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 flex-wrap",children:[q&&t.jsx("span",{className:"px-2.5 py-1 bg-green-500/10 text-green-600 text-xs rounded-lg",children:q}),C==="generate"&&t.jsx("div",{className:"flex gap-1 bg-surface-elevated rounded-lg p-0.5",children:["daily","weekly","monthly"].map(S=>t.jsx("button",{onClick:()=>s(S),className:`px-3 py-1.5 text-xs rounded-md transition-colors capitalize ${n===S?"bg-surface-overlay text-fg-primary shadow-sm":"text-fg-tertiary hover:text-fg-secondary"}`,children:S},S))})]})]}),C==="history"&&!D&&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(S=>t.jsxs("button",{onClick:()=>F(S),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:[S.type," Report"]}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:[new Date(S.periodStart).toLocaleDateString()," — ",new Date(S.periodEnd).toLocaleDateString()]})]}),S.plan&&t.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium shrink-0 ${S.plan.status==="approved"?"bg-green-500/10 text-green-600":S.plan.status==="rejected"?"bg-red-500/10 text-red-500":"bg-amber-500/10 text-amber-600"}`,children:S.plan.status==="pending"?"Plan pending":`Plan ${S.plan.status}`}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date(S.generatedAt).toLocaleDateString()})]},S.id))})}),C==="history"&&D&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>{A(null),X([])},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:[D.type," Report"]}),t.jsxs("span",{className:"text-xs text-fg-tertiary",children:[new Date(D.periodStart).toLocaleDateString()," — ",new Date(D.periodEnd).toLocaleDateString()]})]}),D.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(As,{label:"Completed",value:D.metrics.tasksCompleted,color:"text-green-600"}),t.jsx(As,{label:"In Progress",value:D.metrics.tasksInProgress,color:"text-brand-500"}),t.jsx(As,{label:"Created",value:D.metrics.tasksCreated,color:"text-blue-600"}),t.jsx(As,{label:"Blocked",value:D.metrics.tasksBlocked,color:"text-amber-600"}),t.jsx(As,{label:"Failed",value:D.metrics.tasksFailed,color:"text-red-500"})]})]}),D.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:D.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:fl(D.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 ${D.costSummary.trend==="decreasing"?"text-green-600":D.costSummary.trend==="increasing"?"text-red-500":"text-fg-primary"}`,children:[D.costSummary.trend==="decreasing"?"↓":D.costSummary.trend==="increasing"?"↑":"→"," ",D.costSummary.trend]}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Trend"})]})]}),D.costSummary.byAgent&&D.costSummary.byAgent.length>0&&t.jsx("div",{className:"mt-4 pt-3 border-t border-border-default/50 space-y-1.5",children:D.costSummary.byAgent.map((S,H)=>t.jsxs("div",{className:"flex items-center justify-between text-xs",children:[t.jsx("span",{className:"text-fg-secondary",children:S.agentId}),t.jsxs("span",{className:"text-fg-tertiary tabular-nums",children:[aa(S.tokens)," tokens · ",fl(S.cost)]})]},H))})]}),D.taskSummary&&t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 overflow-hidden",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Task Summary"}),t.jsxs("div",{className:"space-y-4 min-w-0",children:[D.taskSummary.completed.length>0&&t.jsx(cl,{title:`Completed (${D.taskSummary.completed.length})`,color:"emerald",items:D.taskSummary.completed.map(S=>({id:S.id,label:S.title,sub:S.agent}))}),D.taskSummary.inProgress.length>0&&t.jsx(cl,{title:`In Progress (${D.taskSummary.inProgress.length})`,color:"indigo",items:D.taskSummary.inProgress.map(S=>({id:S.id,label:S.title,sub:S.agent}))}),D.taskSummary.blocked.length>0&&t.jsx(cl,{title:`Blocked (${D.taskSummary.blocked.length})`,color:"amber",items:D.taskSummary.blocked.map(S=>({id:S.id,label:S.title,sub:S.reason||S.agent}))}),D.taskSummary.completed.length===0&&D.taskSummary.inProgress.length===0&&D.taskSummary.blocked.length===0&&t.jsx("p",{className:"text-sm text-fg-tertiary",children:"No tasks in this period."})]})]}),D.highlights&&D.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:D.highlights.map((S,H)=>t.jsx("li",{children:S},H))})]}),D.blockers&&D.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:D.blockers.map((S,H)=>t.jsx("li",{children:S},H))})]}),D.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 ${D.plan.status==="approved"?"bg-green-500/10 text-green-600":D.plan.status==="rejected"?"bg-red-500/10 text-red-500":"bg-amber-500/10 text-amber-600"}`,children:D.plan.status})]}),D.plan.status==="pending"&&t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:async()=>{try{const{report:S}=await se.reports.approvePlan(D.id,{approvedBy:e?.id??"admin"});A(S),z("Plan approved"),R()}catch(S){z(`Error: ${S}`)}},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 S=prompt("Rejection reason:");if(S)try{const{report:H}=await se.reports.rejectPlan(D.id,{rejectedBy:e?.id??"admin",reason:S});A(H),z("Plan rejected"),R()}catch(H){z(`Error: ${H}`)}},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"})]})]}),D.plan.items&&D.plan.items.length>0&&t.jsx("div",{className:"space-y-1.5",children:D.plan.items.map((S,H)=>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 ${S.priority==="high"?"bg-red-500/10 text-red-500":S.priority==="medium"?"bg-amber-500/10 text-amber-600":"bg-gray-500/10 text-fg-tertiary"}`,children:S.priority}),t.jsx("span",{children:S.title}),S.assignee&&t.jsx("span",{className:"text-[10px] text-fg-tertiary ml-auto",children:S.assignee})]},H))})]}),!D.metrics&&!D.taskSummary&&!D.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(S=>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:S.authorName}),t.jsx("span",{children:S.type}),t.jsx("span",{children:new Date(S.createdAt).toLocaleDateString()})]}),t.jsx("p",{className:"text-xs text-fg-secondary",children:S.content})]},S.id))}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{value:K,onChange:S=>$(S.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:S=>{S.key==="Enter"&&K.trim()&&se.reports.addFeedback(D.id,{author:e?.id??"admin",type:"comment",content:K.trim()}).then(({feedback:H})=>{X(W=>[...W,H]),$(""),z("Feedback added")}).catch(H=>z(`Error: ${H}`))}}),t.jsx("button",{onClick:()=>{K.trim()&&se.reports.addFeedback(D.id,{author:e?.id??"admin",type:"comment",content:K.trim()}).then(({feedback:S})=>{X(H=>[...H,S]),$(""),z("Feedback added")}).catch(S=>z(`Error: ${S}`))},disabled:!K.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"})]})]})]}),C==="generate"&&f&&t.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsx(Md,{label:"LLM Tokens (this month)",value:aa(f.llmTokens),color:"text-brand-500"}),t.jsx(Md,{label:"Tool Calls (today)",value:aa(f.toolCalls),color:"text-blue-600"}),t.jsx(Md,{label:"Messages (today)",value:aa(f.messages),color:"text-green-600"}),t.jsx(Md,{label:"Storage",value:fz(f.storageBytes),color:"text-amber-600"})]}),C==="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}):i?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[I[n]," · ",new Date(i.periodStart).toLocaleDateString()," — ",new Date(i.periodEnd).toLocaleDateString()]}),i.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(As,{label:"Completed",value:i.metrics.tasksCompleted,color:"text-green-600"}),t.jsx(As,{label:"In Progress",value:i.metrics.tasksInProgress,color:"text-brand-500"}),t.jsx(As,{label:"Created",value:i.metrics.tasksCreated,color:"text-blue-600"}),t.jsx(As,{label:"Blocked",value:i.metrics.tasksBlocked,color:"text-amber-600"}),t.jsx(As,{label:"Failed",value:i.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:fl(Z)}),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:aa(B)}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Tokens Today"})]}),i.costSummary&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:i.costSummary.totalTokens.toLocaleString()}),t.jsxs("div",{className:"text-xs text-fg-tertiary",children:["Tokens (",I[n],")"]})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:fl(i.costSummary.totalEstimatedCost)}),t.jsxs("div",{className:"text-xs text-fg-tertiary",children:["Cost (",I[n],")"]})]})]})]})]}),i.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:[i.taskSummary.completed.length>0&&t.jsx(cl,{title:`Completed (${i.taskSummary.completed.length})`,color:"emerald",items:i.taskSummary.completed.map(S=>({id:S.id,label:S.title,sub:S.agent}))}),i.taskSummary.inProgress.length>0&&t.jsx(cl,{title:`In Progress (${i.taskSummary.inProgress.length})`,color:"indigo",items:i.taskSummary.inProgress.map(S=>({id:S.id,label:S.title,sub:S.agent}))}),i.taskSummary.blocked.length>0&&t.jsx(cl,{title:`Blocked (${i.taskSummary.blocked.length})`,color:"amber",items:i.taskSummary.blocked.map(S=>({id:S.id,label:S.title,sub:S.reason||S.agent}))}),i.taskSummary.completed.length===0&&i.taskSummary.inProgress.length===0&&i.taskSummary.blocked.length===0&&t.jsx("p",{className:"text-sm text-fg-tertiary",children:"No tasks in this period."})]})]})]}):null),C==="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"})}),p.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(Eo,{label:"Total Tokens",col:"totalTokens",current:y,desc:N,onSort:V}),t.jsx(Eo,{label:"Today",col:"tokensUsedToday",current:y,desc:N,onSort:V}),t.jsx(Eo,{label:"Requests",col:"requestCount",current:y,desc:N,onSort:V}),t.jsx(Eo,{label:"Tool Calls",col:"toolCalls",current:y,desc:N,onSort:V}),t.jsx(Eo,{label:"Est. Cost",col:"estimatedCost",current:y,desc:N,onSort:V,align:"right"})]})}),t.jsx("tbody",{children:Y.map(S=>t.jsx(hz,{agent:S,maxTokens:O},S.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 (",p.length," agents)"]}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:aa(p.reduce((S,H)=>S+H.totalTokens,0))}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:aa(B)}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:p.reduce((S,H)=>S+H.requestCount,0)}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:p.reduce((S,H)=>S+H.toolCalls,0)}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-right text-fg-secondary tabular-nums",children:fl(Z)})]})})]})})]})]})})}function As({label:e,value:n,color:s}){return t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:`text-2xl font-bold ${s}`,children:n}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:e})]})}function cl({title:e,color:n,items:s}){return t.jsxs("div",{className:"min-w-0 overflow-hidden",children:[t.jsx("div",{className:`text-xs font-medium text-${n}-400 mb-1.5`,children:e}),t.jsx("div",{className:"space-y-1.5",children:s.map((i,l)=>t.jsxs("div",{className:`text-sm text-fg-secondary min-w-0 ${i.id?"cursor-pointer hover:text-fg-primary group":""}`,onClick:i.id?()=>ht.navigate(me.WORK,{openTask:i.id}):void 0,children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full bg-${n}-500 shrink-0`}),t.jsx("span",{className:`truncate min-w-0 ${i.id?"group-hover:text-brand-500 transition-colors":""}`,children:i.label})]}),i.sub&&i.sub!=="unassigned"&&t.jsx("div",{className:"text-[10px] text-fg-tertiary ml-3.5 mt-0.5 break-all line-clamp-2",children:i.sub})]},i.id??l))})]})}function Md({label:e,value:n,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:n})]})}function Eo({label:e,col:n,current:s,desc:i,onSort:l,align:d}){const c=s===n?i?"↓":"↑":"↕",h=s===n?"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:()=>l(n),children:[e,t.jsx("span",{className:`ml-1 ${h}`,children:c})]})}function hz({agent:e,maxTokens:n}){const s=n>0?Math.min(100,e.totalTokens/n*100):0,i=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:()=>ht.navigate(me.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 ${i}`}),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:aa(e.totalTokens)})]})}),t.jsx("td",{className:"px-4 py-3 text-sm text-fg-secondary tabular-nums",children:aa(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:fl(e.estimatedCost)})]})}function To({d:e,size:n=18}){return t.jsx("svg",{width:n,height:n,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 mz={active:"bg-green-500",paused:"bg-amber-500",completed:"bg-gray-500",archived:"bg-gray-600"},N1=5;function xz({currentPage:e,onNavigate:n,authUser:s,onLogout:i,collapsed:l,onToggleCollapse:d}){const[c,h]=v.useState([]),[m,f]=v.useState(!1),[x,p]=v.useState(null),[g,y]=v.useState(!1),w=v.useCallback(()=>{se.projects.list().then(_=>h(_.projects)).catch(()=>{})},[]);v.useEffect(()=>{w();const _=setInterval(w,3e4);return()=>clearInterval(_)},[w]),v.useEffect(()=>{if(e!==me.WORK){p(null);return}const k=window.location.hash.slice(1).split("/");la(k[0])===me.WORK&&k[1]&&p(k[1])},[e]);const N=async()=>{try{await se.auth.logout()}catch{}i?.()},T=m?c:c.slice(0,N1),C=c.length>N1;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 ${l?"px-2 py-3.5 justify-center":"px-4 h-14 justify-between"}`,children:l?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(vm,{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(vm,{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:`${l?"p-1.5":"p-3"} flex-1 overflow-y-auto`,children:ak.map((_,k)=>t.jsx("div",{children:t.jsxs("div",{className:"mb-3",children:[!l&&t.jsx("div",{className:"px-3 py-1.5 text-[11px] font-semibold text-fg-tertiary uppercase tracking-widest",children:_.label}),l&&k>0&&t.jsx("div",{className:"my-2 mx-1"}),ik.filter(M=>M.section===_.key&&!(_.key==="workspace"&&M.id===me.DELIVERABLES)).map(M=>{const D=e===M.id;return t.jsxs("button",{onClick:()=>n(M.id),title:l?M.label:void 0,className:`w-full flex items-center ${l?"justify-center px-2 py-2":"gap-3 px-3 py-2"} rounded-lg text-sm mb-0.5 transition-all ${D?"bg-brand-600 text-white shadow-sm shadow-brand-900/30":"text-fg-primary hover:bg-surface-overlay"}`,children:[t.jsx(To,{d:dl[M.id]??""}),!l&&M.label]},M.id)}),_.key==="workspace"&&l&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{p(null),n(me.WORK)},title:"Work",className:`w-full flex items-center justify-center px-2 py-2 rounded-lg text-sm mb-0.5 transition-all ${e===me.WORK&&!x?"bg-brand-600 text-white shadow-sm shadow-brand-900/30":e===me.WORK?"bg-brand-600/15 text-fg-primary":"text-fg-primary hover:bg-surface-overlay"}`,children:t.jsx(To,{d:dl[me.WORK]})}),t.jsx("button",{onClick:()=>n(me.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===me.DELIVERABLES?"bg-brand-600 text-white":"text-fg-primary hover:bg-surface-elevated"}`,children:t.jsx(To,{d:dl[me.DELIVERABLES]})})]}),_.key==="workspace"&&!l&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center mb-0.5",children:[t.jsxs("button",{onClick:()=>{p(null),n(me.WORK)},className:`flex-1 flex items-center gap-3 px-3 py-2 rounded-lg text-sm transition-colors ${e===me.WORK&&!x?"bg-brand-600 text-white":"text-fg-primary hover:bg-surface-elevated"}`,children:[t.jsx(To,{d:dl[me.WORK]}),"Work"]}),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"]}),T.map(M=>{const D=e===me.WORK&&x===M.id;return t.jsxs("button",{onClick:()=>{p(M.id),e!==me.WORK&&n(me.WORK),window.location.hash=gm(me.WORK,M.id).slice(1)},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 ${D?"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 ${mz[M.status]??"bg-gray-600"}`}),t.jsx("span",{className:"truncate text-xs",children:M.name})]},M.id)}),C&&!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:()=>n(me.DELIVERABLES),className:`w-full flex items-center gap-3 px-3 py-2 rounded-lg text-sm mb-0.5 transition-colors ${e===me.DELIVERABLES?"bg-brand-600 text-white":"text-fg-primary hover:bg-surface-elevated"}`,children:[t.jsx(To,{d:dl[me.DELIVERABLES]}),"Deliverables"]})]})]})},_.key))}),t.jsxs("div",{className:`${l?"p-2 flex flex-col items-center gap-2":"px-4 py-3 space-y-2"}`,children:[s&&(l?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:"⇥"})]})),!l&&t.jsxs("div",{className:"text-[10px] text-fg-muted",children:["v","0.4.19"]})]}),g&&t.jsx(qN,{orgId:s?.orgId,onCreated:()=>{y(!1),w()},onClose:()=>y(!1)})]})}function pz({currentPage:e,onNavigate:n}){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:lk.map(s=>{const i=s.group.includes(e);return t.jsxs("button",{onClick:()=>n(s.id),className:`flex-1 flex flex-col items-center justify-center gap-0.5 transition-colors ${i?"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:i?2:1.75,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:t.jsx("path",{d:dl[s.id]})}),t.jsx("span",{className:`text-[10px] leading-tight ${i?"font-semibold":""}`,children:s.label})]},s.id)})})}const k1=[{id:"builder",label:"Builder"},{id:"agents",label:"Agents"},{id:"teams",label:"Teams"},{id:"skills",label:"Skills"}];function gz({authUser:e}){const[n,s]=v.useState("builder"),i=ca(k1,n,s);return t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:i.onTouchStart,onTouchEnd:i.onTouchEnd,children:[t.jsx("div",{className:"flex border-b border-border-default bg-surface-secondary shrink-0 overflow-x-auto scrollbar-hide",children:k1.map(l=>t.jsx("button",{onClick:()=>s(l.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 ${n===l.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:l.label},l.id))}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[n==="builder"&&t.jsx(ew,{}),n==="agents"&&t.jsx($m,{authUser:e}),n==="teams"&&t.jsx(Bm,{}),n==="skills"&&t.jsx(Hm,{})]})]})}const S1=[{id:"settings",label:"Settings"},{id:"reports",label:"Reports"}];function bz({theme:e,onThemeChange:n}){const[s,i]=v.useState("settings"),l=ca(S1,s,i);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:S1.map(d=>t.jsx("button",{onClick:()=>i(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:n}),s==="reports"&&t.jsx(GN,{})]})]})}const C1=2;function yz({onComplete:e,theme:n,onThemeChange:s}){const[i,l]=v.useState(0),[d,c]=v.useState(null),[h,m]=v.useState(!1),[f,x]=v.useState({}),[p,g]=v.useState(!1),[y,w]=v.useState(null),[N,T]=v.useState(!1),[C,_]=v.useState(!1),[k,M]=v.useState(null),D=v.useRef(!1),A=()=>({"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("markus_token")??""}`});v.useEffect(()=>{fetch("/api/settings/llm").then(L=>L.ok?L.json():null).then(L=>{L?.providers&&Object.values(L.providers).some(R=>R.configured)&&_(!0)}).catch(()=>{})},[]),v.useEffect(()=>{i===C1&&!D.current&&!C&&(D.current=!0,G())},[i,C]);const G=async()=>{m(!0);try{const L=await fetch("/api/settings/env-models",{headers:A()});if(L.ok){const R=await L.json();if(c(R),R.detected.length>0){const F={};for(const Y of R.detected)F[Y.provider]=!0;x(F)}}}catch{}finally{m(!1)}},X=async()=>{if(!d)return;const L=d.detected.filter(R=>f[R.provider]);if(L.length!==0){g(!0),M(null);try{const R=await fetch("/api/settings/env-models",{method:"POST",headers:A(),body:JSON.stringify({providers:L.map(F=>({provider:F.provider,model:F.model,baseUrl:F.baseUrl,enabled:!0}))})});if(R.ok){const F=await R.json();M({type:"ok",text:F.message}),_(!0)}else M({type:"err",text:"Failed to apply"})}catch{M({type:"err",text:"Network error"})}finally{g(!1)}}},K=async()=>{T(!0);try{const R=await(await fetch("/api/settings/import/openclaw",{method:"POST",headers:A(),body:JSON.stringify({preview:!0})})).json();"error"in R||w(R)}catch{}finally{T(!1)}},$=async()=>{T(!0),M(null);try{const R=await(await fetch("/api/settings/import/openclaw",{method:"POST",headers:A(),body:JSON.stringify({preview:!1})})).json();"error"in R?M({type:"err",text:R.error}):(M({type:"ok",text:`Imported ${R.appliedModels} model configs`}),_(!0))}catch{M({type:"err",text:"Import failed"})}finally{T(!1)}},q=[{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"},{value:"cyberpunk",label:"Cyberpunk",icon:"🔮",desc:"Neon pink, dark violet"},{value:"midnight",label:"Midnight",icon:"🌊",desc:"Deep ocean, teal accents"}],U=[{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(([L,R])=>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:L}),t.jsx("div",{className:"text-fg-secondary text-xs mt-1",children:R})]},L))})]})},{title:"Choose Your Theme",subtitle:"You can change this anytime in Settings",content:t.jsx("div",{className:"grid grid-cols-3 gap-3",children:q.map(L=>t.jsxs("button",{onClick:()=>s(L.value),className:`flex flex-col items-center gap-2 rounded-xl border-2 p-5 transition-all ${n===L.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:L.icon}),t.jsx("span",{className:"text-sm font-medium text-fg-primary",children:L.label}),t.jsx("span",{className:"text-[11px] text-fg-tertiary leading-tight text-center",children:L.desc})]},L.value))})},{title:"Configure LLM",subtitle:"Agents need an LLM to think and act",content:C?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(L=>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[L.provider]??!1,onChange:R=>x({...f,[L.provider]:R.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:L.displayName}),t.jsx("span",{className:"text-xs text-fg-tertiary ml-2",children:L.model})]}),t.jsx("code",{className:"text-[10px] text-fg-tertiary",children:L.apiKeyPreview})]},L.provider)),t.jsx("button",{onClick:()=>{X()},disabled:p||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:p?"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:()=>{K()},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(([L,R])=>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:L}),t.jsx("div",{className:"text-fg-secondary text-xs",children:R})]})]},L))})}],z=()=>{i<U.length-1?l(i+1):e()},E=U[i];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:U.map((L,R)=>t.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${R<=i?"bg-brand-500":"bg-surface-elevated"}`},R))}),t.jsx("h2",{className:"text-2xl font-bold text-fg-primary",children:E.title}),t.jsx("p",{className:"text-sm text-fg-secondary mt-1 mb-6",children:E.subtitle}),E.content,t.jsxs("div",{className:"flex justify-between mt-8",children:[i>0?t.jsx("button",{onClick:()=>l(i-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:[i===C1&&!C&&t.jsx("button",{onClick:z,className:"px-4 py-2 text-sm text-fg-tertiary hover:text-fg-secondary transition-colors",children:"Skip for now"}),t.jsx("button",{onClick:z,className:"px-6 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-sm rounded-xl transition-colors",children:i===U.length-1?"Get Started":"Next"})]})]})]})})})}const vz="markus123";function jz({onLogin:e}){const[n,s]=v.useState("admin@markus.local"),[i,l]=v.useState(""),[d,c]=v.useState(""),[h,m]=v.useState(!1),f=async x=>{if(x.preventDefault(),!(!n.trim()||!i)){c(""),m(!0);try{const{user:p}=await se.auth.login(n.trim(),i);e(p,i===vz)}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:n,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:i,onChange:x=>l(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||!n||!i,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 wz({onComplete:e,isFirstTime:n}){const[s,i]=v.useState(""),[l,d]=v.useState(""),[c,h]=v.useState(""),[m,f]=v.useState(""),[x,p]=v.useState(!1),g=async y=>{if(y.preventDefault(),f(""),l.length<6){f("Password must be at least 6 characters");return}if(l!==c){f("Passwords do not match");return}p(!0);try{await se.auth.changePassword(s,l),e()}catch{f("Failed to change password. Check your current password.")}finally{p(!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:g,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:n?"Set Your Password":"Change Password"}),n&&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."})]}),!n&&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=>i(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:l,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||!l||!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…":n?"Set Password & Continue":"Change Password"})]})]})]})}const pm={};function Nz(){const[e,n]=v.useState(md),[s,i]=v.useState(()=>!localStorage.getItem("markus_onboarded")),[l,d]=v.useState(!0),c=$r(),h=B_(),m=fu({side:"left",defaultWidth:240,minWidth:180,maxWidth:400,collapsedWidth:48,storageKey:"markus_sidebar"}),[f,x]=v.useState(()=>new Set([md()])),[p,g]=v.useState("loading"),[y,w]=v.useState(!1),[N,T]=v.useState(null),[C,_]=v.useState(!1),[k,M]=v.useState(null),[D,A]=v.useState(()=>{const q=localStorage.getItem("markus_update_dismissed");return q||null}),G=v.useCallback(q=>{let U=la(q);c&&(U=sk[U]??U);const z=md(),E=window.location.hash.slice(1);E!==z?pm[z]=E:delete pm[z];const L=U!==me.WORK?pm[U]:void 0;L&&L!==U?(history.pushState(null,"","#"+U),history.pushState(null,"","#"+L)):history.pushState(null,"","#"+U),window.dispatchEvent(new HashChangeEvent("hashchange")),n(U),x(R=>R.has(U)?R:new Set([...R,U]))},[c]);v.useEffect(()=>{ht.setHandler(q=>G(q))},[G]);const X=v.useCallback(()=>{fetch("/api/settings/llm").then(q=>q.ok?q.json():null).then(q=>{if(q?.providers){const U=Object.values(q.providers).some(z=>z.configured);T(U)}}).catch(()=>{})},[]);v.useEffect(()=>{se.auth.me().then(({user:z})=>{g(z),X(),se.health().then(E=>{E.updateAvailable&&E.latestVersion&&M({latestVersion:E.latestVersion,currentVersion:E.version})}).catch(()=>{}),mi(Ir.builderArtifacts,()=>se.builder.artifacts.list()),mi(Ir.builderAgents,()=>se.agents.list()),mi(Ir.builderHubMyItems,()=>Zn.myItems()),mi(Ir.builderInstalled,()=>se.builder.artifacts.installed()),mi(Ir.hubAgents,()=>Zn.search({type:"agent",limit:50})),mi(Ir.hubTeams,()=>Zn.search({type:"team",limit:50})),mi(Ir.hubSkills,()=>Zn.search({type:"skill",limit:50}))}).catch(()=>g(null)),Jt.connect();const q=Jt.on("notification",()=>{window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}),U=()=>{const z=md();n(z),x(E=>E.has(z)?E:new Set([...E,z]))};return window.addEventListener("hashchange",U),()=>{q(),Jt.disconnect(),window.removeEventListener("hashchange",U)}},[]);const K=p!=="loading"&&p!==null?p:void 0,$=v.useMemo(()=>c?{[me.HOME]:t.jsx(Ob,{authUser:K}),[me.TEAM]:t.jsx(Yy,{authUser:K}),[me.BUILDER]:t.jsx(gz,{authUser:K}),[me.SETTINGS]:t.jsx(bz,{theme:h.mode,onThemeChange:h.setMode}),[me.WORK]:t.jsx(y1,{authUser:K}),[me.DELIVERABLES]:t.jsx(w1,{})}:{[me.HOME]:t.jsx(Ob,{}),[me.TEAM]:t.jsx(Yy,{authUser:K}),[me.SETTINGS]:t.jsx(Kj,{theme:h.mode,onThemeChange:h.setMode}),[me.STORE]:t.jsx(Q_,{authUser:K}),[me.BUILDER]:t.jsx(ew,{}),[me.WORK]:t.jsx(y1,{authUser:K}),[me.DELIVERABLES]:t.jsx(w1,{}),[me.REPORTS]:t.jsx(GN,{authUser:K})},[K?.id,h.mode,c]);return p==="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…"})}):p===null?t.jsx(jz,{onLogin:(q,U)=>{g(q),U&&w(!0)}}):y?t.jsx(wz,{onComplete:()=>w(!1),isFirstTime:!0}):s?t.jsx(yz,{theme:h.mode,onThemeChange:h.setMode,onComplete:()=>{localStorage.setItem("markus_onboarded","1"),i(!1),X()}}):t.jsxs("div",{className:`flex h-dvh bg-surface-primary text-fg-primary overflow-x-hidden ${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(xz,{currentPage:e,onNavigate:q=>{G(q),d(!1)},authUser:p,onLogout:()=>g(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&&!C&&e!==me.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:()=>{G(me.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:()=>_(!0),className:"text-amber-500 hover:text-amber-600 text-xs",children:"Dismiss"})]})]}),k&&D!==k.latestVersion&&t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-brand-500/10 border-b border-brand-500/30 text-brand-400 text-sm shrink-0",children:[t.jsxs("span",{className:c?"text-xs":"",children:["New version available: ",t.jsxs("strong",{children:["v",k.latestVersion]})," (current: v",k.currentVersion,")",!c&&t.jsxs("span",{className:"text-fg-tertiary ml-2",children:["— run ",t.jsx("code",{className:"bg-surface-overlay px-1.5 py-0.5 rounded text-xs font-mono",children:"npm i -g @markus-global/cli"})," to upgrade"]})]}),t.jsx("button",{onClick:()=>{A(k.latestVersion),localStorage.setItem("markus_update_dismissed",k.latestVersion)},className:"text-brand-400 hover:text-brand-300 text-xs shrink-0",children:"Dismiss"})]}),t.jsx("main",{className:"flex-1 overflow-hidden flex flex-col",children:Object.keys($).map(q=>f.has(q)?t.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",style:{display:q===e?"flex":"none"},children:$[q]},q):null)})]}),c&&t.jsx(pz,{currentPage:e,onNavigate:G})]})}tk.createRoot(document.getElementById("root")).render(t.jsx(v.StrictMode,{children:t.jsx(Nz,{})}));
|