tycono 0.1.83 → 0.1.84-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/api/src/create-server.ts +7 -0
- package/src/api/src/services/preferences.ts +5 -0
- package/src/web/dist/assets/index-YE1g0Mgv.js +110 -0
- package/src/web/dist/assets/{preview-app-DbMjPbJZ.js → preview-app-RTesSYsM.js} +1 -1
- package/src/web/dist/index.html +1 -1
- package/src/web/dist/assets/index-BOH9XJbW.js +0 -110
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
var fw=Object.defineProperty;var hw=(e,n,a)=>n in e?fw(e,n,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[n]=a;var j0=(e,n,a)=>hw(e,typeof n!="symbol"?n+"":n,a);(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))i(o);new MutationObserver(o=>{for(const u of o)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&i(d)}).observe(document,{childList:!0,subtree:!0});function a(o){const u={};return o.integrity&&(u.integrity=o.integrity),o.referrerPolicy&&(u.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?u.credentials="include":o.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function i(o){if(o.ep)return;o.ep=!0;const u=a(o);fetch(o.href,u)}})();function Ey(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Jf={exports:{}},vo={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var S0;function mw(){if(S0)return vo;S0=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function a(i,o,u){var d=null;if(u!==void 0&&(d=""+u),o.key!==void 0&&(d=""+o.key),"key"in o){u={};for(var f in o)f!=="key"&&(u[f]=o[f])}else u=o;return o=u.ref,{$$typeof:e,type:i,key:d,ref:o!==void 0?o:null,props:u}}return vo.Fragment=n,vo.jsx=a,vo.jsxs=a,vo}var C0;function pw(){return C0||(C0=1,Jf.exports=mw()),Jf.exports}var l=pw(),eh={exports:{}},pt={};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react.production.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var E0;function xw(){if(E0)return pt;E0=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),u=Symbol.for("react.consumer"),d=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),v=Symbol.iterator;function b(B){return B===null||typeof B!="object"?null:(B=v&&B[v]||B["@@iterator"],typeof B=="function"?B:null)}var j={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,N={};function E(B,U,T){this.props=B,this.context=U,this.refs=N,this.updater=T||j}E.prototype.isReactComponent={},E.prototype.setState=function(B,U){if(typeof B!="object"&&typeof B!="function"&&B!=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,B,U,"setState")},E.prototype.forceUpdate=function(B){this.updater.enqueueForceUpdate(this,B,"forceUpdate")};function C(){}C.prototype=E.prototype;function _(B,U,T){this.props=B,this.context=U,this.refs=N,this.updater=T||j}var R=_.prototype=new C;R.constructor=_,k(R,E.prototype),R.isPureReactComponent=!0;var L=Array.isArray;function F(){}var I={H:null,A:null,T:null,S:null},H=Object.prototype.hasOwnProperty;function X(B,U,T){var se=T.ref;return{$$typeof:e,type:B,key:U,ref:se!==void 0?se:null,props:T}}function A(B,U){return X(B.type,U,B.props)}function $(B){return typeof B=="object"&&B!==null&&B.$$typeof===e}function q(B){var U={"=":"=0",":":"=2"};return"$"+B.replace(/[=:]/g,function(T){return U[T]})}var W=/\/+/g;function ie(B,U){return typeof B=="object"&&B!==null&&B.key!=null?q(""+B.key):U.toString(36)}function P(B){switch(B.status){case"fulfilled":return B.value;case"rejected":throw B.reason;default:switch(typeof B.status=="string"?B.then(F,F):(B.status="pending",B.then(function(U){B.status==="pending"&&(B.status="fulfilled",B.value=U)},function(U){B.status==="pending"&&(B.status="rejected",B.reason=U)})),B.status){case"fulfilled":return B.value;case"rejected":throw B.reason}}throw B}function Y(B,U,T,se,ge){var pe=typeof B;(pe==="undefined"||pe==="boolean")&&(B=null);var Re=!1;if(B===null)Re=!0;else switch(pe){case"bigint":case"string":case"number":Re=!0;break;case"object":switch(B.$$typeof){case e:case n:Re=!0;break;case x:return Re=B._init,Y(Re(B._payload),U,T,se,ge)}}if(Re)return ge=ge(B),Re=se===""?"."+ie(B,0):se,L(ge)?(T="",Re!=null&&(T=Re.replace(W,"$&/")+"/"),Y(ge,U,T,"",function(ot){return ot})):ge!=null&&($(ge)&&(ge=A(ge,T+(ge.key==null||B&&B.key===ge.key?"":(""+ge.key).replace(W,"$&/")+"/")+Re)),U.push(ge)),1;Re=0;var Ie=se===""?".":se+":";if(L(B))for(var He=0;He<B.length;He++)se=B[He],pe=Ie+ie(se,He),Re+=Y(se,U,T,pe,ge);else if(He=b(B),typeof He=="function")for(B=He.call(B),He=0;!(se=B.next()).done;)se=se.value,pe=Ie+ie(se,He++),Re+=Y(se,U,T,pe,ge);else if(pe==="object"){if(typeof B.then=="function")return Y(P(B),U,T,se,ge);throw U=String(B),Error("Objects are not valid as a React child (found: "+(U==="[object Object]"?"object with keys {"+Object.keys(B).join(", ")+"}":U)+"). If you meant to render a collection of children, use an array instead.")}return Re}function oe(B,U,T){if(B==null)return B;var se=[],ge=0;return Y(B,se,"","",function(pe){return U.call(T,pe,ge++)}),se}function de(B){if(B._status===-1){var U=B._result;U=U(),U.then(function(T){(B._status===0||B._status===-1)&&(B._status=1,B._result=T)},function(T){(B._status===0||B._status===-1)&&(B._status=2,B._result=T)}),B._status===-1&&(B._status=0,B._result=U)}if(B._status===1)return B._result.default;throw B._result}var G=typeof reportError=="function"?reportError:function(B){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var U=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof B=="object"&&B!==null&&typeof B.message=="string"?String(B.message):String(B),error:B});if(!window.dispatchEvent(U))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",B);return}console.error(B)},D={map:oe,forEach:function(B,U,T){oe(B,function(){U.apply(this,arguments)},T)},count:function(B){var U=0;return oe(B,function(){U++}),U},toArray:function(B){return oe(B,function(U){return U})||[]},only:function(B){if(!$(B))throw Error("React.Children.only expected to receive a single React element child.");return B}};return pt.Activity=g,pt.Children=D,pt.Component=E,pt.Fragment=a,pt.Profiler=o,pt.PureComponent=_,pt.StrictMode=i,pt.Suspense=m,pt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=I,pt.__COMPILER_RUNTIME={__proto__:null,c:function(B){return I.H.useMemoCache(B)}},pt.cache=function(B){return function(){return B.apply(null,arguments)}},pt.cacheSignal=function(){return null},pt.cloneElement=function(B,U,T){if(B==null)throw Error("The argument must be a React element, but you passed "+B+".");var se=k({},B.props),ge=B.key;if(U!=null)for(pe in U.key!==void 0&&(ge=""+U.key),U)!H.call(U,pe)||pe==="key"||pe==="__self"||pe==="__source"||pe==="ref"&&U.ref===void 0||(se[pe]=U[pe]);var pe=arguments.length-2;if(pe===1)se.children=T;else if(1<pe){for(var Re=Array(pe),Ie=0;Ie<pe;Ie++)Re[Ie]=arguments[Ie+2];se.children=Re}return X(B.type,ge,se)},pt.createContext=function(B){return B={$$typeof:d,_currentValue:B,_currentValue2:B,_threadCount:0,Provider:null,Consumer:null},B.Provider=B,B.Consumer={$$typeof:u,_context:B},B},pt.createElement=function(B,U,T){var se,ge={},pe=null;if(U!=null)for(se in U.key!==void 0&&(pe=""+U.key),U)H.call(U,se)&&se!=="key"&&se!=="__self"&&se!=="__source"&&(ge[se]=U[se]);var Re=arguments.length-2;if(Re===1)ge.children=T;else if(1<Re){for(var Ie=Array(Re),He=0;He<Re;He++)Ie[He]=arguments[He+2];ge.children=Ie}if(B&&B.defaultProps)for(se in Re=B.defaultProps,Re)ge[se]===void 0&&(ge[se]=Re[se]);return X(B,pe,ge)},pt.createRef=function(){return{current:null}},pt.forwardRef=function(B){return{$$typeof:f,render:B}},pt.isValidElement=$,pt.lazy=function(B){return{$$typeof:x,_payload:{_status:-1,_result:B},_init:de}},pt.memo=function(B,U){return{$$typeof:h,type:B,compare:U===void 0?null:U}},pt.startTransition=function(B){var U=I.T,T={};I.T=T;try{var se=B(),ge=I.S;ge!==null&&ge(T,se),typeof se=="object"&&se!==null&&typeof se.then=="function"&&se.then(F,G)}catch(pe){G(pe)}finally{U!==null&&T.types!==null&&(U.types=T.types),I.T=U}},pt.unstable_useCacheRefresh=function(){return I.H.useCacheRefresh()},pt.use=function(B){return I.H.use(B)},pt.useActionState=function(B,U,T){return I.H.useActionState(B,U,T)},pt.useCallback=function(B,U){return I.H.useCallback(B,U)},pt.useContext=function(B){return I.H.useContext(B)},pt.useDebugValue=function(){},pt.useDeferredValue=function(B,U){return I.H.useDeferredValue(B,U)},pt.useEffect=function(B,U){return I.H.useEffect(B,U)},pt.useEffectEvent=function(B){return I.H.useEffectEvent(B)},pt.useId=function(){return I.H.useId()},pt.useImperativeHandle=function(B,U,T){return I.H.useImperativeHandle(B,U,T)},pt.useInsertionEffect=function(B,U){return I.H.useInsertionEffect(B,U)},pt.useLayoutEffect=function(B,U){return I.H.useLayoutEffect(B,U)},pt.useMemo=function(B,U){return I.H.useMemo(B,U)},pt.useOptimistic=function(B,U){return I.H.useOptimistic(B,U)},pt.useReducer=function(B,U,T){return I.H.useReducer(B,U,T)},pt.useRef=function(B){return I.H.useRef(B)},pt.useState=function(B){return I.H.useState(B)},pt.useSyncExternalStore=function(B,U,T){return I.H.useSyncExternalStore(B,U,T)},pt.useTransition=function(){return I.H.useTransition()},pt.version="19.2.4",pt}var N0;function km(){return N0||(N0=1,eh.exports=xw()),eh.exports}var w=km(),th={exports:{}},wo={},nh={exports:{}},rh={};/**
|
|
18
|
+
* @license React
|
|
19
|
+
* scheduler.production.js
|
|
20
|
+
*
|
|
21
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
22
|
+
*
|
|
23
|
+
* This source code is licensed under the MIT license found in the
|
|
24
|
+
* LICENSE file in the root directory of this source tree.
|
|
25
|
+
*/var A0;function gw(){return A0||(A0=1,(function(e){function n(Y,oe){var de=Y.length;Y.push(oe);e:for(;0<de;){var G=de-1>>>1,D=Y[G];if(0<o(D,oe))Y[G]=oe,Y[de]=D,de=G;else break e}}function a(Y){return Y.length===0?null:Y[0]}function i(Y){if(Y.length===0)return null;var oe=Y[0],de=Y.pop();if(de!==oe){Y[0]=de;e:for(var G=0,D=Y.length,B=D>>>1;G<B;){var U=2*(G+1)-1,T=Y[U],se=U+1,ge=Y[se];if(0>o(T,de))se<D&&0>o(ge,T)?(Y[G]=ge,Y[se]=de,G=se):(Y[G]=T,Y[U]=de,G=U);else if(se<D&&0>o(ge,de))Y[G]=ge,Y[se]=de,G=se;else break e}}return oe}function o(Y,oe){var de=Y.sortIndex-oe.sortIndex;return de!==0?de:Y.id-oe.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var u=performance;e.unstable_now=function(){return u.now()}}else{var d=Date,f=d.now();e.unstable_now=function(){return d.now()-f}}var m=[],h=[],x=1,g=null,v=3,b=!1,j=!1,k=!1,N=!1,E=typeof setTimeout=="function"?setTimeout:null,C=typeof clearTimeout=="function"?clearTimeout:null,_=typeof setImmediate<"u"?setImmediate:null;function R(Y){for(var oe=a(h);oe!==null;){if(oe.callback===null)i(h);else if(oe.startTime<=Y)i(h),oe.sortIndex=oe.expirationTime,n(m,oe);else break;oe=a(h)}}function L(Y){if(k=!1,R(Y),!j)if(a(m)!==null)j=!0,F||(F=!0,q());else{var oe=a(h);oe!==null&&P(L,oe.startTime-Y)}}var F=!1,I=-1,H=5,X=-1;function A(){return N?!0:!(e.unstable_now()-X<H)}function $(){if(N=!1,F){var Y=e.unstable_now();X=Y;var oe=!0;try{e:{j=!1,k&&(k=!1,C(I),I=-1),b=!0;var de=v;try{t:{for(R(Y),g=a(m);g!==null&&!(g.expirationTime>Y&&A());){var G=g.callback;if(typeof G=="function"){g.callback=null,v=g.priorityLevel;var D=G(g.expirationTime<=Y);if(Y=e.unstable_now(),typeof D=="function"){g.callback=D,R(Y),oe=!0;break t}g===a(m)&&i(m),R(Y)}else i(m);g=a(m)}if(g!==null)oe=!0;else{var B=a(h);B!==null&&P(L,B.startTime-Y),oe=!1}}break e}finally{g=null,v=de,b=!1}oe=void 0}}finally{oe?q():F=!1}}}var q;if(typeof _=="function")q=function(){_($)};else if(typeof MessageChannel<"u"){var W=new MessageChannel,ie=W.port2;W.port1.onmessage=$,q=function(){ie.postMessage(null)}}else q=function(){E($,0)};function P(Y,oe){I=E(function(){Y(e.unstable_now())},oe)}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(Y){Y.callback=null},e.unstable_forceFrameRate=function(Y){0>Y||125<Y?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):H=0<Y?Math.floor(1e3/Y):5},e.unstable_getCurrentPriorityLevel=function(){return v},e.unstable_next=function(Y){switch(v){case 1:case 2:case 3:var oe=3;break;default:oe=v}var de=v;v=oe;try{return Y()}finally{v=de}},e.unstable_requestPaint=function(){N=!0},e.unstable_runWithPriority=function(Y,oe){switch(Y){case 1:case 2:case 3:case 4:case 5:break;default:Y=3}var de=v;v=Y;try{return oe()}finally{v=de}},e.unstable_scheduleCallback=function(Y,oe,de){var G=e.unstable_now();switch(typeof de=="object"&&de!==null?(de=de.delay,de=typeof de=="number"&&0<de?G+de:G):de=G,Y){case 1:var D=-1;break;case 2:D=250;break;case 5:D=1073741823;break;case 4:D=1e4;break;default:D=5e3}return D=de+D,Y={id:x++,callback:oe,priorityLevel:Y,startTime:de,expirationTime:D,sortIndex:-1},de>G?(Y.sortIndex=de,n(h,Y),a(m)===null&&Y===a(h)&&(k?(C(I),I=-1):k=!0,P(L,de-G))):(Y.sortIndex=D,n(m,Y),j||b||(j=!0,F||(F=!0,q()))),Y},e.unstable_shouldYield=A,e.unstable_wrapCallback=function(Y){var oe=v;return function(){var de=v;v=oe;try{return Y.apply(this,arguments)}finally{v=de}}}})(rh)),rh}var D0;function yw(){return D0||(D0=1,nh.exports=gw()),nh.exports}var ah={exports:{}},tr={};/**
|
|
26
|
+
* @license React
|
|
27
|
+
* react-dom.production.js
|
|
28
|
+
*
|
|
29
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
30
|
+
*
|
|
31
|
+
* This source code is licensed under the MIT license found in the
|
|
32
|
+
* LICENSE file in the root directory of this source tree.
|
|
33
|
+
*/var T0;function bw(){if(T0)return tr;T0=1;var e=km();function n(m){var h="https://react.dev/errors/"+m;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var x=2;x<arguments.length;x++)h+="&args[]="+encodeURIComponent(arguments[x])}return"Minified React error #"+m+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(){}var i={d:{f:a,r:function(){throw Error(n(522))},D:a,C:a,L:a,m:a,X:a,S:a,M:a},p:0,findDOMNode:null},o=Symbol.for("react.portal");function u(m,h,x){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:g==null?null:""+g,children:m,containerInfo:h,implementation:x}}var d=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function f(m,h){if(m==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return tr.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,tr.createPortal=function(m,h){var x=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(n(299));return u(m,h,null,x)},tr.flushSync=function(m){var h=d.T,x=i.p;try{if(d.T=null,i.p=2,m)return m()}finally{d.T=h,i.p=x,i.d.f()}},tr.preconnect=function(m,h){typeof m=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,i.d.C(m,h))},tr.prefetchDNS=function(m){typeof m=="string"&&i.d.D(m)},tr.preinit=function(m,h){if(typeof m=="string"&&h&&typeof h.as=="string"){var x=h.as,g=f(x,h.crossOrigin),v=typeof h.integrity=="string"?h.integrity:void 0,b=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;x==="style"?i.d.S(m,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:g,integrity:v,fetchPriority:b}):x==="script"&&i.d.X(m,{crossOrigin:g,integrity:v,fetchPriority:b,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},tr.preinitModule=function(m,h){if(typeof m=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var x=f(h.as,h.crossOrigin);i.d.M(m,{crossOrigin:x,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&i.d.M(m)},tr.preload=function(m,h){if(typeof m=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var x=h.as,g=f(x,h.crossOrigin);i.d.L(m,x,{crossOrigin:g,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},tr.preloadModule=function(m,h){if(typeof m=="string")if(h){var x=f(h.as,h.crossOrigin);i.d.m(m,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:x,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else i.d.m(m)},tr.requestFormReset=function(m){i.d.r(m)},tr.unstable_batchedUpdates=function(m,h){return m(h)},tr.useFormState=function(m,h,x){return d.H.useFormState(m,h,x)},tr.useFormStatus=function(){return d.H.useHostTransitionStatus()},tr.version="19.2.4",tr}var F0;function vw(){if(F0)return ah.exports;F0=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(),ah.exports=bw(),ah.exports}/**
|
|
34
|
+
* @license React
|
|
35
|
+
* react-dom-client.production.js
|
|
36
|
+
*
|
|
37
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
38
|
+
*
|
|
39
|
+
* This source code is licensed under the MIT license found in the
|
|
40
|
+
* LICENSE file in the root directory of this source tree.
|
|
41
|
+
*/var M0;function ww(){if(M0)return wo;M0=1;var e=yw(),n=km(),a=vw();function i(t){var r="https://react.dev/errors/"+t;if(1<arguments.length){r+="?args[]="+encodeURIComponent(arguments[1]);for(var s=2;s<arguments.length;s++)r+="&args[]="+encodeURIComponent(arguments[s])}return"Minified React error #"+t+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function u(t){var r=t,s=t;if(t.alternate)for(;r.return;)r=r.return;else{t=r;do r=t,(r.flags&4098)!==0&&(s=r.return),t=r.return;while(t)}return r.tag===3?s:null}function d(t){if(t.tag===13){var r=t.memoizedState;if(r===null&&(t=t.alternate,t!==null&&(r=t.memoizedState)),r!==null)return r.dehydrated}return null}function f(t){if(t.tag===31){var r=t.memoizedState;if(r===null&&(t=t.alternate,t!==null&&(r=t.memoizedState)),r!==null)return r.dehydrated}return null}function m(t){if(u(t)!==t)throw Error(i(188))}function h(t){var r=t.alternate;if(!r){if(r=u(t),r===null)throw Error(i(188));return r!==t?null:t}for(var s=t,c=r;;){var p=s.return;if(p===null)break;var y=p.alternate;if(y===null){if(c=p.return,c!==null){s=c;continue}break}if(p.child===y.child){for(y=p.child;y;){if(y===s)return m(p),t;if(y===c)return m(p),r;y=y.sibling}throw Error(i(188))}if(s.return!==c.return)s=p,c=y;else{for(var S=!1,z=p.child;z;){if(z===s){S=!0,s=p,c=y;break}if(z===c){S=!0,c=p,s=y;break}z=z.sibling}if(!S){for(z=y.child;z;){if(z===s){S=!0,s=y,c=p;break}if(z===c){S=!0,c=y,s=p;break}z=z.sibling}if(!S)throw Error(i(189))}}if(s.alternate!==c)throw Error(i(190))}if(s.tag!==3)throw Error(i(188));return s.stateNode.current===s?t:r}function x(t){var r=t.tag;if(r===5||r===26||r===27||r===6)return t;for(t=t.child;t!==null;){if(r=x(t),r!==null)return r;t=t.sibling}return null}var g=Object.assign,v=Symbol.for("react.element"),b=Symbol.for("react.transitional.element"),j=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),N=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),C=Symbol.for("react.consumer"),_=Symbol.for("react.context"),R=Symbol.for("react.forward_ref"),L=Symbol.for("react.suspense"),F=Symbol.for("react.suspense_list"),I=Symbol.for("react.memo"),H=Symbol.for("react.lazy"),X=Symbol.for("react.activity"),A=Symbol.for("react.memo_cache_sentinel"),$=Symbol.iterator;function q(t){return t===null||typeof t!="object"?null:(t=$&&t[$]||t["@@iterator"],typeof t=="function"?t:null)}var W=Symbol.for("react.client.reference");function ie(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===W?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case k:return"Fragment";case E:return"Profiler";case N:return"StrictMode";case L:return"Suspense";case F:return"SuspenseList";case X:return"Activity"}if(typeof t=="object")switch(t.$$typeof){case j:return"Portal";case _:return t.displayName||"Context";case C:return(t._context.displayName||"Context")+".Consumer";case R:var r=t.render;return t=t.displayName,t||(t=r.displayName||r.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case I:return r=t.displayName||null,r!==null?r:ie(t.type)||"Memo";case H:r=t._payload,t=t._init;try{return ie(t(r))}catch{}}return null}var P=Array.isArray,Y=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,oe=a.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,de={pending:!1,data:null,method:null,action:null},G=[],D=-1;function B(t){return{current:t}}function U(t){0>D||(t.current=G[D],G[D]=null,D--)}function T(t,r){D++,G[D]=t.current,t.current=r}var se=B(null),ge=B(null),pe=B(null),Re=B(null);function Ie(t,r){switch(T(pe,r),T(ge,t),T(se,null),r.nodeType){case 9:case 11:t=(t=r.documentElement)&&(t=t.namespaceURI)?W1(t):0;break;default:if(t=r.tagName,r=r.namespaceURI)r=W1(r),t=V1(r,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}U(se),T(se,t)}function He(){U(se),U(ge),U(pe)}function ot(t){t.memoizedState!==null&&T(Re,t);var r=se.current,s=V1(r,t.type);r!==s&&(T(ge,t),T(se,s))}function Je(t){ge.current===t&&(U(se),U(ge)),Re.current===t&&(U(Re),xo._currentValue=de)}var tt,Ee;function Ae(t){if(tt===void 0)try{throw Error()}catch(s){var r=s.stack.trim().match(/\n( *(at )?)/);tt=r&&r[1]||"",Ee=-1<s.stack.indexOf(`
|
|
42
|
+
at`)?" (<anonymous>)":-1<s.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
43
|
+
`+tt+t+Ee}var yt=!1;function dt(t,r){if(!t||yt)return"";yt=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var c={DetermineComponentFrameRoot:function(){try{if(r){var Ce=function(){throw Error()};if(Object.defineProperty(Ce.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ce,[])}catch(fe){var ce=fe}Reflect.construct(t,[],Ce)}else{try{Ce.call()}catch(fe){ce=fe}t.call(Ce.prototype)}}else{try{throw Error()}catch(fe){ce=fe}(Ce=t())&&typeof Ce.catch=="function"&&Ce.catch(function(){})}}catch(fe){if(fe&&ce&&typeof fe.stack=="string")return[fe.stack,ce.stack]}return[null,null]}};c.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var p=Object.getOwnPropertyDescriptor(c.DetermineComponentFrameRoot,"name");p&&p.configurable&&Object.defineProperty(c.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var y=c.DetermineComponentFrameRoot(),S=y[0],z=y[1];if(S&&z){var V=S.split(`
|
|
44
|
+
`),le=z.split(`
|
|
45
|
+
`);for(p=c=0;c<V.length&&!V[c].includes("DetermineComponentFrameRoot");)c++;for(;p<le.length&&!le[p].includes("DetermineComponentFrameRoot");)p++;if(c===V.length||p===le.length)for(c=V.length-1,p=le.length-1;1<=c&&0<=p&&V[c]!==le[p];)p--;for(;1<=c&&0<=p;c--,p--)if(V[c]!==le[p]){if(c!==1||p!==1)do if(c--,p--,0>p||V[c]!==le[p]){var xe=`
|
|
46
|
+
`+V[c].replace(" at new "," at ");return t.displayName&&xe.includes("<anonymous>")&&(xe=xe.replace("<anonymous>",t.displayName)),xe}while(1<=c&&0<=p);break}}}finally{yt=!1,Error.prepareStackTrace=s}return(s=t?t.displayName||t.name:"")?Ae(s):""}function xt(t,r){switch(t.tag){case 26:case 27:case 5:return Ae(t.type);case 16:return Ae("Lazy");case 13:return t.child!==r&&r!==null?Ae("Suspense Fallback"):Ae("Suspense");case 19:return Ae("SuspenseList");case 0:case 15:return dt(t.type,!1);case 11:return dt(t.type.render,!1);case 1:return dt(t.type,!0);case 31:return Ae("Activity");default:return""}}function jt(t){try{var r="",s=null;do r+=xt(t,s),s=t,t=t.return;while(t);return r}catch(c){return`
|
|
47
|
+
Error generating stack: `+c.message+`
|
|
48
|
+
`+c.stack}}var Wt=Object.prototype.hasOwnProperty,Tt=e.unstable_scheduleCallback,Ct=e.unstable_cancelCallback,Bn=e.unstable_shouldYield,me=e.unstable_requestPaint,Se=e.unstable_now,Ne=e.unstable_getCurrentPriorityLevel,K=e.unstable_ImmediatePriority,ue=e.unstable_UserBlockingPriority,ne=e.unstable_NormalPriority,ve=e.unstable_LowPriority,we=e.unstable_IdlePriority,ze=e.log,_e=e.unstable_setDisableYieldValue,Be=null,qe=null;function at(t){if(typeof ze=="function"&&_e(t),qe&&typeof qe.setStrictMode=="function")try{qe.setStrictMode(Be,t)}catch{}}var Ke=Math.clz32?Math.clz32:Ue,bt=Math.log,Me=Math.LN2;function Ue(t){return t>>>=0,t===0?32:31-(bt(t)/Me|0)|0}var _t=256,Bt=262144,Ot=4194304;function un(t){var r=t&42;if(r!==0)return r;switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return t&261888;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function kn(t,r,s){var c=t.pendingLanes;if(c===0)return 0;var p=0,y=t.suspendedLanes,S=t.pingedLanes;t=t.warmLanes;var z=c&134217727;return z!==0?(c=z&~y,c!==0?p=un(c):(S&=z,S!==0?p=un(S):s||(s=z&~t,s!==0&&(p=un(s))))):(z=c&~y,z!==0?p=un(z):S!==0?p=un(S):s||(s=c&~t,s!==0&&(p=un(s)))),p===0?0:r!==0&&r!==p&&(r&y)===0&&(y=p&-p,s=r&-r,y>=s||y===32&&(s&4194048)!==0)?r:p}function J(t,r){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&r)===0}function Oe(t,r){switch(t){case 1:case 2:case 4:case 8:case 64:return r+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 r+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 rt(){var t=Ot;return Ot<<=1,(Ot&62914560)===0&&(Ot=4194304),t}function Kt(t){for(var r=[],s=0;31>s;s++)r.push(t);return r}function ke(t,r){t.pendingLanes|=r,r!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function kt(t,r,s,c,p,y){var S=t.pendingLanes;t.pendingLanes=s,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=s,t.entangledLanes&=s,t.errorRecoveryDisabledLanes&=s,t.shellSuspendCounter=0;var z=t.entanglements,V=t.expirationTimes,le=t.hiddenUpdates;for(s=S&~s;0<s;){var xe=31-Ke(s),Ce=1<<xe;z[xe]=0,V[xe]=-1;var ce=le[xe];if(ce!==null)for(le[xe]=null,xe=0;xe<ce.length;xe++){var fe=ce[xe];fe!==null&&(fe.lane&=-536870913)}s&=~Ce}c!==0&&jn(t,c,0),y!==0&&p===0&&t.tag!==0&&(t.suspendedLanes|=y&~(S&~r))}function jn(t,r,s){t.pendingLanes|=r,t.suspendedLanes&=~r;var c=31-Ke(r);t.entangledLanes|=r,t.entanglements[c]=t.entanglements[c]|1073741824|s&261930}function hn(t,r){var s=t.entangledLanes|=r;for(t=t.entanglements;s;){var c=31-Ke(s),p=1<<c;p&r|t[c]&r&&(t[c]|=r),s&=~p}}function te(t,r){var s=r&-r;return s=(s&42)!==0?1:$e(s),(s&(t.suspendedLanes|r))!==0?0:s}function $e(t){switch(t){case 2:t=1;break;case 8:t=4;break;case 32:t=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:t=128;break;case 268435456:t=134217728;break;default:t=0}return t}function We(t){return t&=-t,2<t?8<t?(t&134217727)!==0?32:268435456:8:2}function Pe(){var t=oe.p;return t!==0?t:(t=window.event,t===void 0?32:x0(t.type))}function Sn(t,r){var s=oe.p;try{return oe.p=t,r()}finally{oe.p=s}}var Wn=Math.random().toString(36).slice(2),yn="__reactFiber$"+Wn,mn="__reactProps$"+Wn,Or="__reactContainer$"+Wn,Ql="__reactEvents$"+Wn,Ds="__reactListeners$"+Wn,Fi="__reactHandles$"+Wn,Go="__reactResources$"+Wn,Fa="__reactMarker$"+Wn;function Ts(t){delete t[yn],delete t[mn],delete t[Ql],delete t[Ds],delete t[Fi]}function ca(t){var r=t[yn];if(r)return r;for(var s=t.parentNode;s;){if(r=s[Or]||s[yn]){if(s=r.alternate,r.child!==null||s!==null&&s.child!==null)for(t=e0(t);t!==null;){if(s=t[yn])return s;t=e0(t)}return r}t=s,s=t.parentNode}return null}function Ma(t){if(t=t[yn]||t[Or]){var r=t.tag;if(r===5||r===6||r===13||r===31||r===26||r===27||r===3)return t}return null}function Ra(t){var r=t.tag;if(r===5||r===26||r===27||r===6)return t.stateNode;throw Error(i(33))}function Vn(t){var r=t[Go];return r||(r=t[Go]={hoistableStyles:new Map,hoistableScripts:new Map}),r}function Dn(t){t[Fa]=!0}var za=new Set,Mi={};function fr(t,r){jr(t,r),jr(t+"Capture",r)}function jr(t,r){for(Mi[t]=r,t=0;t<r.length;t++)za.add(r[t])}var ol=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]*$"),Fs={},_a={};function Ko(t){return Wt.call(_a,t)?!0:Wt.call(Fs,t)?!1:ol.test(t)?_a[t]=!0:(Fs[t]=!0,!1)}function Zl(t,r,s){if(Ko(r))if(s===null)t.removeAttribute(r);else{switch(typeof s){case"undefined":case"function":case"symbol":t.removeAttribute(r);return;case"boolean":var c=r.toLowerCase().slice(0,5);if(c!=="data-"&&c!=="aria-"){t.removeAttribute(r);return}}t.setAttribute(r,""+s)}}function cl(t,r,s){if(s===null)t.removeAttribute(r);else{switch(typeof s){case"undefined":case"function":case"symbol":case"boolean":t.removeAttribute(r);return}t.setAttribute(r,""+s)}}function $r(t,r,s,c){if(c===null)t.removeAttribute(s);else{switch(typeof c){case"undefined":case"function":case"symbol":case"boolean":t.removeAttribute(s);return}t.setAttributeNS(r,s,""+c)}}function lr(t){switch(typeof t){case"bigint":case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function Po(t){var r=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function Ba(t,r,s){var c=Object.getOwnPropertyDescriptor(t.constructor.prototype,r);if(!t.hasOwnProperty(r)&&typeof c<"u"&&typeof c.get=="function"&&typeof c.set=="function"){var p=c.get,y=c.set;return Object.defineProperty(t,r,{configurable:!0,get:function(){return p.call(this)},set:function(S){s=""+S,y.call(this,S)}}),Object.defineProperty(t,r,{enumerable:c.enumerable}),{getValue:function(){return s},setValue:function(S){s=""+S},stopTracking:function(){t._valueTracker=null,delete t[r]}}}}function Lr(t){if(!t._valueTracker){var r=Po(t)?"checked":"value";t._valueTracker=Ba(t,r,""+t[r])}}function Ir(t){if(!t)return!1;var r=t._valueTracker;if(!r)return!0;var s=r.getValue(),c="";return t&&(c=Po(t)?t.checked?"true":"false":t.value),t=c,t!==s?(r.setValue(t),!0):!1}function Sr(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}var ea=/[\n"\\]/g;function Pt(t){return t.replace(ea,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function Ri(t,r,s,c,p,y,S,z){t.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?t.type=S:t.removeAttribute("type"),r!=null?S==="number"?(r===0&&t.value===""||t.value!=r)&&(t.value=""+lr(r)):t.value!==""+lr(r)&&(t.value=""+lr(r)):S!=="submit"&&S!=="reset"||t.removeAttribute("value"),r!=null?Jl(t,S,lr(r)):s!=null?Jl(t,S,lr(s)):c!=null&&t.removeAttribute("value"),p==null&&y!=null&&(t.defaultChecked=!!y),p!=null&&(t.checked=p&&typeof p!="function"&&typeof p!="symbol"),z!=null&&typeof z!="function"&&typeof z!="symbol"&&typeof z!="boolean"?t.name=""+lr(z):t.removeAttribute("name")}function Qo(t,r,s,c,p,y,S,z){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(t.type=y),r!=null||s!=null){if(!(y!=="submit"&&y!=="reset"||r!=null)){Lr(t);return}s=s!=null?""+lr(s):"",r=r!=null?""+lr(r):s,z||r===t.value||(t.value=r),t.defaultValue=r}c=c??p,c=typeof c!="function"&&typeof c!="symbol"&&!!c,t.checked=z?t.checked:!!c,t.defaultChecked=!!c,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(t.name=S),Lr(t)}function Jl(t,r,s){r==="number"&&Sr(t.ownerDocument)===t||t.defaultValue===""+s||(t.defaultValue=""+s)}function Gn(t,r,s,c){if(t=t.options,r){r={};for(var p=0;p<s.length;p++)r["$"+s[p]]=!0;for(s=0;s<t.length;s++)p=r.hasOwnProperty("$"+t[s].value),t[s].selected!==p&&(t[s].selected=p),p&&c&&(t[s].defaultSelected=!0)}else{for(s=""+lr(s),r=null,p=0;p<t.length;p++){if(t[p].value===s){t[p].selected=!0,c&&(t[p].defaultSelected=!0);return}r!==null||t[p].disabled||(r=t[p])}r!==null&&(r.selected=!0)}}function Oa(t,r,s){if(r!=null&&(r=""+lr(r),r!==t.value&&(t.value=r),s==null)){t.defaultValue!==r&&(t.defaultValue=r);return}t.defaultValue=s!=null?""+lr(s):""}function ua(t,r,s,c){if(r==null){if(c!=null){if(s!=null)throw Error(i(92));if(P(c)){if(1<c.length)throw Error(i(93));c=c[0]}s=c}s==null&&(s=""),r=s}s=lr(r),t.defaultValue=s,c=t.textContent,c===s&&c!==""&&c!==null&&(t.value=c),Lr(t)}function ul(t,r){if(r){var s=t.firstChild;if(s&&s===t.lastChild&&s.nodeType===3){s.nodeValue=r;return}}t.textContent=r}var Un=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 an(t,r,s){var c=r.indexOf("--")===0;s==null||typeof s=="boolean"||s===""?c?t.setProperty(r,""):r==="float"?t.cssFloat="":t[r]="":c?t.setProperty(r,s):typeof s!="number"||s===0||Un.has(r)?r==="float"?t.cssFloat=s:t[r]=(""+s).trim():t[r]=s+"px"}function ta(t,r,s){if(r!=null&&typeof r!="object")throw Error(i(62));if(t=t.style,s!=null){for(var c in s)!s.hasOwnProperty(c)||r!=null&&r.hasOwnProperty(c)||(c.indexOf("--")===0?t.setProperty(c,""):c==="float"?t.cssFloat="":t[c]="");for(var p in r)c=r[p],r.hasOwnProperty(p)&&s[p]!==c&&an(t,p,c)}else for(var y in r)r.hasOwnProperty(y)&&an(t,y,r[y])}function qn(t){if(t.indexOf("-")===-1)return!1;switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var da=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"]]),$a=/^[\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 zi(t){return $a.test(""+t)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":t}function hr(){}var _i=null;function fa(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var mr=null,La=null;function Ms(t){var r=Ma(t);if(r&&(t=r.stateNode)){var s=t[mn]||null;e:switch(t=r.stateNode,r.type){case"input":if(Ri(t,s.value,s.defaultValue,s.defaultValue,s.checked,s.defaultChecked,s.type,s.name),r=s.name,s.type==="radio"&&r!=null){for(s=t;s.parentNode;)s=s.parentNode;for(s=s.querySelectorAll('input[name="'+Pt(""+r)+'"][type="radio"]'),r=0;r<s.length;r++){var c=s[r];if(c!==t&&c.form===t.form){var p=c[mn]||null;if(!p)throw Error(i(90));Ri(c,p.value,p.defaultValue,p.defaultValue,p.checked,p.defaultChecked,p.type,p.name)}}for(r=0;r<s.length;r++)c=s[r],c.form===t.form&&Ir(c)}break e;case"textarea":Oa(t,s.value,s.defaultValue);break e;case"select":r=s.value,r!=null&&Gn(t,!!s.multiple,r,!1)}}}var Kn=!1;function dl(t,r,s){if(Kn)return t(r,s);Kn=!0;try{var c=t(r);return c}finally{if(Kn=!1,(mr!==null||La!==null)&&(Vc(),mr&&(r=mr,t=La,La=mr=null,Ms(r),t)))for(r=0;r<t.length;r++)Ms(t[r])}}function ha(t,r){var s=t.stateNode;if(s===null)return null;var c=s[mn]||null;if(c===null)return null;s=c[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(c=!c.disabled)||(t=t.type,c=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!c;break e;default:t=!1}if(t)return null;if(s&&typeof s!="function")throw Error(i(231,r,typeof s));return s}var na=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Rs=!1;if(na)try{var Et={};Object.defineProperty(Et,"passive",{get:function(){Rs=!0}}),window.addEventListener("test",Et,Et),window.removeEventListener("test",Et,Et)}catch{Rs=!1}var ma=null,ln=null,fl=null;function hl(){if(fl)return fl;var t,r=ln,s=r.length,c,p="value"in ma?ma.value:ma.textContent,y=p.length;for(t=0;t<s&&r[t]===p[t];t++);var S=s-t;for(c=1;c<=S&&r[s-c]===p[y-c];c++);return fl=p.slice(t,1<c?1-c:void 0)}function Bi(t){var r=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&r===13&&(t=13)):t=r,t===10&&(t=13),32<=t||t===13?t:0}function pa(){return!0}function Zo(){return!1}function Yn(t){function r(s,c,p,y,S){this._reactName=s,this._targetInst=p,this.type=c,this.nativeEvent=y,this.target=S,this.currentTarget=null;for(var z in t)t.hasOwnProperty(z)&&(s=t[z],this[z]=s?s(y):y[z]);return this.isDefaultPrevented=(y.defaultPrevented!=null?y.defaultPrevented:y.returnValue===!1)?pa:Zo,this.isPropagationStopped=Zo,this}return g(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var s=this.nativeEvent;s&&(s.preventDefault?s.preventDefault():typeof s.returnValue!="unknown"&&(s.returnValue=!1),this.isDefaultPrevented=pa)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=pa)},persist:function(){},isPersistent:pa}),r}var ir={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ml=Yn(ir),ei=g({},ir,{view:0,detail:0}),rd=Yn(ei),ti,zs,pl,ni=g({},ei,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:$i,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==pl&&(pl&&t.type==="mousemove"?(ti=t.screenX-pl.screenX,zs=t.screenY-pl.screenY):zs=ti=0,pl=t),ti)},movementY:function(t){return"movementY"in t?t.movementY:zs}}),Jo=Yn(ni),ec=g({},ni,{dataTransfer:0}),tc=Yn(ec),nc=g({},ei,{relatedTarget:0}),Hr=Yn(nc),Ia=g({},ir,{animationName:0,elapsedTime:0,pseudoElement:0}),_s=Yn(Ia),ad=g({},ir,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),rc=Yn(ad),ac=g({},ir,{data:0}),lc=Yn(ac),ic={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Jt={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"},Oi={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function sc(t){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(t):(t=Oi[t])?!!r[t]:!1}function $i(){return sc}var oc=g({},ei,{key:function(t){if(t.key){var r=ic[t.key]||t.key;if(r!=="Unidentified")return r}return t.type==="keypress"?(t=Bi(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?Jt[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:$i,charCode:function(t){return t.type==="keypress"?Bi(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Bi(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),cc=Yn(oc),uc=g({},ni,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Bs=Yn(uc),dc=g({},ei,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:$i}),M=Yn(dc),Q=g({},ir,{propertyName:0,elapsedTime:0,pseudoElement:0}),re=Yn(Q),he=g({},ni,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),je=Yn(he),Le=g({},ir,{newState:0,oldState:0}),It=Yn(Le),ft=[9,13,27,32],Ze=na&&"CompositionEvent"in window,Ge=null;na&&"documentMode"in document&&(Ge=document.documentMode);var mt=na&&"TextEvent"in window&&!Ge,Ft=na&&(!Ze||Ge&&8<Ge&&11>=Ge),xl=" ",sr=!1;function ct(t,r){switch(t){case"keyup":return ft.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function $t(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var pn=!1;function dn(t,r){switch(t){case"compositionend":return $t(r);case"keypress":return r.which!==32?null:(sr=!0,xl);case"textInput":return t=r.data,t===xl&&sr?null:t;default:return null}}function Ov(t,r){if(pn)return t==="compositionend"||!Ze&&ct(t,r)?(t=hl(),fl=ln=ma=null,pn=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return Ft&&r.locale!=="ko"?null:r.data;default:return null}}var $v={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 rp(t){var r=t&&t.nodeName&&t.nodeName.toLowerCase();return r==="input"?!!$v[t.type]:r==="textarea"}function ap(t,r,s,c){mr?La?La.push(c):La=[c]:mr=c,r=eu(r,"onChange"),0<r.length&&(s=new ml("onChange","change",null,s,c),t.push({event:s,listeners:r}))}var Os=null,$s=null;function Lv(t){I1(t,0)}function fc(t){var r=Ra(t);if(Ir(r))return t}function lp(t,r){if(t==="change")return r}var ip=!1;if(na){var ld;if(na){var id="oninput"in document;if(!id){var sp=document.createElement("div");sp.setAttribute("oninput","return;"),id=typeof sp.oninput=="function"}ld=id}else ld=!1;ip=ld&&(!document.documentMode||9<document.documentMode)}function op(){Os&&(Os.detachEvent("onpropertychange",cp),$s=Os=null)}function cp(t){if(t.propertyName==="value"&&fc($s)){var r=[];ap(r,$s,t,fa(t)),dl(Lv,r)}}function Iv(t,r,s){t==="focusin"?(op(),Os=r,$s=s,Os.attachEvent("onpropertychange",cp)):t==="focusout"&&op()}function Hv(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return fc($s)}function Uv(t,r){if(t==="click")return fc(r)}function qv(t,r){if(t==="input"||t==="change")return fc(r)}function Yv(t,r){return t===r&&(t!==0||1/t===1/r)||t!==t&&r!==r}var Cr=typeof Object.is=="function"?Object.is:Yv;function Ls(t,r){if(Cr(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;var s=Object.keys(t),c=Object.keys(r);if(s.length!==c.length)return!1;for(c=0;c<s.length;c++){var p=s[c];if(!Wt.call(r,p)||!Cr(t[p],r[p]))return!1}return!0}function up(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function dp(t,r){var s=up(t);t=0;for(var c;s;){if(s.nodeType===3){if(c=t+s.textContent.length,t<=r&&c>=r)return{node:s,offset:r-t};t=c}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=up(s)}}function fp(t,r){return t&&r?t===r?!0:t&&t.nodeType===3?!1:r&&r.nodeType===3?fp(t,r.parentNode):"contains"in t?t.contains(r):t.compareDocumentPosition?!!(t.compareDocumentPosition(r)&16):!1:!1}function hp(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var r=Sr(t.document);r instanceof t.HTMLIFrameElement;){try{var s=typeof r.contentWindow.location.href=="string"}catch{s=!1}if(s)t=r.contentWindow;else break;r=Sr(t.document)}return r}function sd(t){var r=t&&t.nodeName&&t.nodeName.toLowerCase();return r&&(r==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||r==="textarea"||t.contentEditable==="true")}var Xv=na&&"documentMode"in document&&11>=document.documentMode,Li=null,od=null,Is=null,cd=!1;function mp(t,r,s){var c=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;cd||Li==null||Li!==Sr(c)||(c=Li,"selectionStart"in c&&sd(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}),Is&&Ls(Is,c)||(Is=c,c=eu(od,"onSelect"),0<c.length&&(r=new ml("onSelect","select",null,r,s),t.push({event:r,listeners:c}),r.target=Li)))}function ri(t,r){var s={};return s[t.toLowerCase()]=r.toLowerCase(),s["Webkit"+t]="webkit"+r,s["Moz"+t]="moz"+r,s}var Ii={animationend:ri("Animation","AnimationEnd"),animationiteration:ri("Animation","AnimationIteration"),animationstart:ri("Animation","AnimationStart"),transitionrun:ri("Transition","TransitionRun"),transitionstart:ri("Transition","TransitionStart"),transitioncancel:ri("Transition","TransitionCancel"),transitionend:ri("Transition","TransitionEnd")},ud={},pp={};na&&(pp=document.createElement("div").style,"AnimationEvent"in window||(delete Ii.animationend.animation,delete Ii.animationiteration.animation,delete Ii.animationstart.animation),"TransitionEvent"in window||delete Ii.transitionend.transition);function ai(t){if(ud[t])return ud[t];if(!Ii[t])return t;var r=Ii[t],s;for(s in r)if(r.hasOwnProperty(s)&&s in pp)return ud[t]=r[s];return t}var xp=ai("animationend"),gp=ai("animationiteration"),yp=ai("animationstart"),Wv=ai("transitionrun"),Vv=ai("transitionstart"),Gv=ai("transitioncancel"),bp=ai("transitionend"),vp=new Map,dd="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(" ");dd.push("scrollEnd");function ra(t,r){vp.set(t,r),fr(r,[t])}var hc=typeof reportError=="function"?reportError:function(t){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var r=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof t=="object"&&t!==null&&typeof t.message=="string"?String(t.message):String(t),error:t});if(!window.dispatchEvent(r))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",t);return}console.error(t)},Ur=[],Hi=0,fd=0;function mc(){for(var t=Hi,r=fd=Hi=0;r<t;){var s=Ur[r];Ur[r++]=null;var c=Ur[r];Ur[r++]=null;var p=Ur[r];Ur[r++]=null;var y=Ur[r];if(Ur[r++]=null,c!==null&&p!==null){var S=c.pending;S===null?p.next=p:(p.next=S.next,S.next=p),c.pending=p}y!==0&&wp(s,p,y)}}function pc(t,r,s,c){Ur[Hi++]=t,Ur[Hi++]=r,Ur[Hi++]=s,Ur[Hi++]=c,fd|=c,t.lanes|=c,t=t.alternate,t!==null&&(t.lanes|=c)}function hd(t,r,s,c){return pc(t,r,s,c),xc(t)}function li(t,r){return pc(t,null,null,r),xc(t)}function wp(t,r,s){t.lanes|=s;var c=t.alternate;c!==null&&(c.lanes|=s);for(var p=!1,y=t.return;y!==null;)y.childLanes|=s,c=y.alternate,c!==null&&(c.childLanes|=s),y.tag===22&&(t=y.stateNode,t===null||t._visibility&1||(p=!0)),t=y,y=y.return;return t.tag===3?(y=t.stateNode,p&&r!==null&&(p=31-Ke(s),t=y.hiddenUpdates,c=t[p],c===null?t[p]=[r]:c.push(r),r.lane=s|536870912),y):null}function xc(t){if(50<oo)throw oo=0,jf=null,Error(i(185));for(var r=t.return;r!==null;)t=r,r=t.return;return t.tag===3?t.stateNode:null}var Ui={};function Kv(t,r,s,c){this.tag=t,this.key=s,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=c,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Er(t,r,s,c){return new Kv(t,r,s,c)}function md(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Ha(t,r){var s=t.alternate;return s===null?(s=Er(t.tag,r,t.key,t.mode),s.elementType=t.elementType,s.type=t.type,s.stateNode=t.stateNode,s.alternate=t,t.alternate=s):(s.pendingProps=r,s.type=t.type,s.flags=0,s.subtreeFlags=0,s.deletions=null),s.flags=t.flags&65011712,s.childLanes=t.childLanes,s.lanes=t.lanes,s.child=t.child,s.memoizedProps=t.memoizedProps,s.memoizedState=t.memoizedState,s.updateQueue=t.updateQueue,r=t.dependencies,s.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},s.sibling=t.sibling,s.index=t.index,s.ref=t.ref,s.refCleanup=t.refCleanup,s}function kp(t,r){t.flags&=65011714;var s=t.alternate;return s===null?(t.childLanes=0,t.lanes=r,t.child=null,t.subtreeFlags=0,t.memoizedProps=null,t.memoizedState=null,t.updateQueue=null,t.dependencies=null,t.stateNode=null):(t.childLanes=s.childLanes,t.lanes=s.lanes,t.child=s.child,t.subtreeFlags=0,t.deletions=null,t.memoizedProps=s.memoizedProps,t.memoizedState=s.memoizedState,t.updateQueue=s.updateQueue,t.type=s.type,r=s.dependencies,t.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),t}function gc(t,r,s,c,p,y){var S=0;if(c=t,typeof t=="function")md(t)&&(S=1);else if(typeof t=="string")S=ew(t,s,se.current)?26:t==="html"||t==="head"||t==="body"?27:5;else e:switch(t){case X:return t=Er(31,s,r,p),t.elementType=X,t.lanes=y,t;case k:return ii(s.children,p,y,r);case N:S=8,p|=24;break;case E:return t=Er(12,s,r,p|2),t.elementType=E,t.lanes=y,t;case L:return t=Er(13,s,r,p),t.elementType=L,t.lanes=y,t;case F:return t=Er(19,s,r,p),t.elementType=F,t.lanes=y,t;default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case _:S=10;break e;case C:S=9;break e;case R:S=11;break e;case I:S=14;break e;case H:S=16,c=null;break e}S=29,s=Error(i(130,t===null?"null":typeof t,"")),c=null}return r=Er(S,s,r,p),r.elementType=t,r.type=c,r.lanes=y,r}function ii(t,r,s,c){return t=Er(7,t,c,r),t.lanes=s,t}function pd(t,r,s){return t=Er(6,t,null,r),t.lanes=s,t}function jp(t){var r=Er(18,null,null,0);return r.stateNode=t,r}function xd(t,r,s){return r=Er(4,t.children!==null?t.children:[],t.key,r),r.lanes=s,r.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},r}var Sp=new WeakMap;function qr(t,r){if(typeof t=="object"&&t!==null){var s=Sp.get(t);return s!==void 0?s:(r={value:t,source:r,stack:jt(r)},Sp.set(t,r),r)}return{value:t,source:r,stack:jt(r)}}var qi=[],Yi=0,yc=null,Hs=0,Yr=[],Xr=0,gl=null,xa=1,ga="";function Ua(t,r){qi[Yi++]=Hs,qi[Yi++]=yc,yc=t,Hs=r}function Cp(t,r,s){Yr[Xr++]=xa,Yr[Xr++]=ga,Yr[Xr++]=gl,gl=t;var c=xa;t=ga;var p=32-Ke(c)-1;c&=~(1<<p),s+=1;var y=32-Ke(r)+p;if(30<y){var S=p-p%5;y=(c&(1<<S)-1).toString(32),c>>=S,p-=S,xa=1<<32-Ke(r)+p|s<<p|c,ga=y+t}else xa=1<<y|s<<p|c,ga=t}function gd(t){t.return!==null&&(Ua(t,1),Cp(t,1,0))}function yd(t){for(;t===yc;)yc=qi[--Yi],qi[Yi]=null,Hs=qi[--Yi],qi[Yi]=null;for(;t===gl;)gl=Yr[--Xr],Yr[Xr]=null,ga=Yr[--Xr],Yr[Xr]=null,xa=Yr[--Xr],Yr[Xr]=null}function Ep(t,r){Yr[Xr++]=xa,Yr[Xr++]=ga,Yr[Xr++]=gl,xa=r.id,ga=r.overflow,gl=t}var Pn=null,xn=null,Lt=!1,yl=null,Wr=!1,bd=Error(i(519));function bl(t){var r=Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Us(qr(r,t)),bd}function Np(t){var r=t.stateNode,s=t.type,c=t.memoizedProps;switch(r[yn]=t,r[mn]=c,s){case"dialog":At("cancel",r),At("close",r);break;case"iframe":case"object":case"embed":At("load",r);break;case"video":case"audio":for(s=0;s<uo.length;s++)At(uo[s],r);break;case"source":At("error",r);break;case"img":case"image":case"link":At("error",r),At("load",r);break;case"details":At("toggle",r);break;case"input":At("invalid",r),Qo(r,c.value,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name,!0);break;case"select":At("invalid",r);break;case"textarea":At("invalid",r),ua(r,c.value,c.defaultValue,c.children)}s=c.children,typeof s!="string"&&typeof s!="number"&&typeof s!="bigint"||r.textContent===""+s||c.suppressHydrationWarning===!0||Y1(r.textContent,s)?(c.popover!=null&&(At("beforetoggle",r),At("toggle",r)),c.onScroll!=null&&At("scroll",r),c.onScrollEnd!=null&&At("scrollend",r),c.onClick!=null&&(r.onclick=hr),r=!0):r=!1,r||bl(t,!0)}function Ap(t){for(Pn=t.return;Pn;)switch(Pn.tag){case 5:case 31:case 13:Wr=!1;return;case 27:case 3:Wr=!0;return;default:Pn=Pn.return}}function Xi(t){if(t!==Pn)return!1;if(!Lt)return Ap(t),Lt=!0,!1;var r=t.tag,s;if((s=r!==3&&r!==27)&&((s=r===5)&&(s=t.type,s=!(s!=="form"&&s!=="button")||$f(t.type,t.memoizedProps)),s=!s),s&&xn&&bl(t),Ap(t),r===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(i(317));xn=J1(t)}else if(r===31){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(i(317));xn=J1(t)}else r===27?(r=xn,Rl(t.type)?(t=qf,qf=null,xn=t):xn=r):xn=Pn?Gr(t.stateNode.nextSibling):null;return!0}function si(){xn=Pn=null,Lt=!1}function vd(){var t=yl;return t!==null&&(yr===null?yr=t:yr.push.apply(yr,t),yl=null),t}function Us(t){yl===null?yl=[t]:yl.push(t)}var wd=B(null),oi=null,qa=null;function vl(t,r,s){T(wd,r._currentValue),r._currentValue=s}function Ya(t){t._currentValue=wd.current,U(wd)}function kd(t,r,s){for(;t!==null;){var c=t.alternate;if((t.childLanes&r)!==r?(t.childLanes|=r,c!==null&&(c.childLanes|=r)):c!==null&&(c.childLanes&r)!==r&&(c.childLanes|=r),t===s)break;t=t.return}}function jd(t,r,s,c){var p=t.child;for(p!==null&&(p.return=t);p!==null;){var y=p.dependencies;if(y!==null){var S=p.child;y=y.firstContext;e:for(;y!==null;){var z=y;y=p;for(var V=0;V<r.length;V++)if(z.context===r[V]){y.lanes|=s,z=y.alternate,z!==null&&(z.lanes|=s),kd(y.return,s,t),c||(S=null);break e}y=z.next}}else if(p.tag===18){if(S=p.return,S===null)throw Error(i(341));S.lanes|=s,y=S.alternate,y!==null&&(y.lanes|=s),kd(S,s,t),S=null}else S=p.child;if(S!==null)S.return=p;else for(S=p;S!==null;){if(S===t){S=null;break}if(p=S.sibling,p!==null){p.return=S.return,S=p;break}S=S.return}p=S}}function Wi(t,r,s,c){t=null;for(var p=r,y=!1;p!==null;){if(!y){if((p.flags&524288)!==0)y=!0;else if((p.flags&262144)!==0)break}if(p.tag===10){var S=p.alternate;if(S===null)throw Error(i(387));if(S=S.memoizedProps,S!==null){var z=p.type;Cr(p.pendingProps.value,S.value)||(t!==null?t.push(z):t=[z])}}else if(p===Re.current){if(S=p.alternate,S===null)throw Error(i(387));S.memoizedState.memoizedState!==p.memoizedState.memoizedState&&(t!==null?t.push(xo):t=[xo])}p=p.return}t!==null&&jd(r,t,s,c),r.flags|=262144}function bc(t){for(t=t.firstContext;t!==null;){if(!Cr(t.context._currentValue,t.memoizedValue))return!0;t=t.next}return!1}function ci(t){oi=t,qa=null,t=t.dependencies,t!==null&&(t.firstContext=null)}function Qn(t){return Dp(oi,t)}function vc(t,r){return oi===null&&ci(t),Dp(t,r)}function Dp(t,r){var s=r._currentValue;if(r={context:r,memoizedValue:s,next:null},qa===null){if(t===null)throw Error(i(308));qa=r,t.dependencies={lanes:0,firstContext:r},t.flags|=524288}else qa=qa.next=r;return s}var Pv=typeof AbortController<"u"?AbortController:function(){var t=[],r=this.signal={aborted:!1,addEventListener:function(s,c){t.push(c)}};this.abort=function(){r.aborted=!0,t.forEach(function(s){return s()})}},Qv=e.unstable_scheduleCallback,Zv=e.unstable_NormalPriority,Tn={$$typeof:_,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Sd(){return{controller:new Pv,data:new Map,refCount:0}}function qs(t){t.refCount--,t.refCount===0&&Qv(Zv,function(){t.controller.abort()})}var Ys=null,Cd=0,Vi=0,Gi=null;function Jv(t,r){if(Ys===null){var s=Ys=[];Cd=0,Vi=Df(),Gi={status:"pending",value:void 0,then:function(c){s.push(c)}}}return Cd++,r.then(Tp,Tp),r}function Tp(){if(--Cd===0&&Ys!==null){Gi!==null&&(Gi.status="fulfilled");var t=Ys;Ys=null,Vi=0,Gi=null;for(var r=0;r<t.length;r++)(0,t[r])()}}function e2(t,r){var s=[],c={status:"pending",value:null,reason:null,then:function(p){s.push(p)}};return t.then(function(){c.status="fulfilled",c.value=r;for(var p=0;p<s.length;p++)(0,s[p])(r)},function(p){for(c.status="rejected",c.reason=p,p=0;p<s.length;p++)(0,s[p])(void 0)}),c}var Fp=Y.S;Y.S=function(t,r){m1=Se(),typeof r=="object"&&r!==null&&typeof r.then=="function"&&Jv(t,r),Fp!==null&&Fp(t,r)};var ui=B(null);function Ed(){var t=ui.current;return t!==null?t:sn.pooledCache}function wc(t,r){r===null?T(ui,ui.current):T(ui,r.pool)}function Mp(){var t=Ed();return t===null?null:{parent:Tn._currentValue,pool:t}}var Ki=Error(i(460)),Nd=Error(i(474)),kc=Error(i(542)),jc={then:function(){}};function Rp(t){return t=t.status,t==="fulfilled"||t==="rejected"}function zp(t,r,s){switch(s=t[s],s===void 0?t.push(r):s!==r&&(r.then(hr,hr),r=s),r.status){case"fulfilled":return r.value;case"rejected":throw t=r.reason,Bp(t),t;default:if(typeof r.status=="string")r.then(hr,hr);else{if(t=sn,t!==null&&100<t.shellSuspendCounter)throw Error(i(482));t=r,t.status="pending",t.then(function(c){if(r.status==="pending"){var p=r;p.status="fulfilled",p.value=c}},function(c){if(r.status==="pending"){var p=r;p.status="rejected",p.reason=c}})}switch(r.status){case"fulfilled":return r.value;case"rejected":throw t=r.reason,Bp(t),t}throw fi=r,Ki}}function di(t){try{var r=t._init;return r(t._payload)}catch(s){throw s!==null&&typeof s=="object"&&typeof s.then=="function"?(fi=s,Ki):s}}var fi=null;function _p(){if(fi===null)throw Error(i(459));var t=fi;return fi=null,t}function Bp(t){if(t===Ki||t===kc)throw Error(i(483))}var Pi=null,Xs=0;function Sc(t){var r=Xs;return Xs+=1,Pi===null&&(Pi=[]),zp(Pi,t,r)}function Ws(t,r){r=r.props.ref,t.ref=r!==void 0?r:null}function Cc(t,r){throw r.$$typeof===v?Error(i(525)):(t=Object.prototype.toString.call(r),Error(i(31,t==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":t)))}function Op(t){function r(ee,Z){if(t){var ae=ee.deletions;ae===null?(ee.deletions=[Z],ee.flags|=16):ae.push(Z)}}function s(ee,Z){if(!t)return null;for(;Z!==null;)r(ee,Z),Z=Z.sibling;return null}function c(ee){for(var Z=new Map;ee!==null;)ee.key!==null?Z.set(ee.key,ee):Z.set(ee.index,ee),ee=ee.sibling;return Z}function p(ee,Z){return ee=Ha(ee,Z),ee.index=0,ee.sibling=null,ee}function y(ee,Z,ae){return ee.index=ae,t?(ae=ee.alternate,ae!==null?(ae=ae.index,ae<Z?(ee.flags|=67108866,Z):ae):(ee.flags|=67108866,Z)):(ee.flags|=1048576,Z)}function S(ee){return t&&ee.alternate===null&&(ee.flags|=67108866),ee}function z(ee,Z,ae,be){return Z===null||Z.tag!==6?(Z=pd(ae,ee.mode,be),Z.return=ee,Z):(Z=p(Z,ae),Z.return=ee,Z)}function V(ee,Z,ae,be){var nt=ae.type;return nt===k?xe(ee,Z,ae.props.children,be,ae.key):Z!==null&&(Z.elementType===nt||typeof nt=="object"&&nt!==null&&nt.$$typeof===H&&di(nt)===Z.type)?(Z=p(Z,ae.props),Ws(Z,ae),Z.return=ee,Z):(Z=gc(ae.type,ae.key,ae.props,null,ee.mode,be),Ws(Z,ae),Z.return=ee,Z)}function le(ee,Z,ae,be){return Z===null||Z.tag!==4||Z.stateNode.containerInfo!==ae.containerInfo||Z.stateNode.implementation!==ae.implementation?(Z=xd(ae,ee.mode,be),Z.return=ee,Z):(Z=p(Z,ae.children||[]),Z.return=ee,Z)}function xe(ee,Z,ae,be,nt){return Z===null||Z.tag!==7?(Z=ii(ae,ee.mode,be,nt),Z.return=ee,Z):(Z=p(Z,ae),Z.return=ee,Z)}function Ce(ee,Z,ae){if(typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint")return Z=pd(""+Z,ee.mode,ae),Z.return=ee,Z;if(typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case b:return ae=gc(Z.type,Z.key,Z.props,null,ee.mode,ae),Ws(ae,Z),ae.return=ee,ae;case j:return Z=xd(Z,ee.mode,ae),Z.return=ee,Z;case H:return Z=di(Z),Ce(ee,Z,ae)}if(P(Z)||q(Z))return Z=ii(Z,ee.mode,ae,null),Z.return=ee,Z;if(typeof Z.then=="function")return Ce(ee,Sc(Z),ae);if(Z.$$typeof===_)return Ce(ee,vc(ee,Z),ae);Cc(ee,Z)}return null}function ce(ee,Z,ae,be){var nt=Z!==null?Z.key:null;if(typeof ae=="string"&&ae!==""||typeof ae=="number"||typeof ae=="bigint")return nt!==null?null:z(ee,Z,""+ae,be);if(typeof ae=="object"&&ae!==null){switch(ae.$$typeof){case b:return ae.key===nt?V(ee,Z,ae,be):null;case j:return ae.key===nt?le(ee,Z,ae,be):null;case H:return ae=di(ae),ce(ee,Z,ae,be)}if(P(ae)||q(ae))return nt!==null?null:xe(ee,Z,ae,be,null);if(typeof ae.then=="function")return ce(ee,Z,Sc(ae),be);if(ae.$$typeof===_)return ce(ee,Z,vc(ee,ae),be);Cc(ee,ae)}return null}function fe(ee,Z,ae,be,nt){if(typeof be=="string"&&be!==""||typeof be=="number"||typeof be=="bigint")return ee=ee.get(ae)||null,z(Z,ee,""+be,nt);if(typeof be=="object"&&be!==null){switch(be.$$typeof){case b:return ee=ee.get(be.key===null?ae:be.key)||null,V(Z,ee,be,nt);case j:return ee=ee.get(be.key===null?ae:be.key)||null,le(Z,ee,be,nt);case H:return be=di(be),fe(ee,Z,ae,be,nt)}if(P(be)||q(be))return ee=ee.get(ae)||null,xe(Z,ee,be,nt,null);if(typeof be.then=="function")return fe(ee,Z,ae,Sc(be),nt);if(be.$$typeof===_)return fe(ee,Z,ae,vc(Z,be),nt);Cc(Z,be)}return null}function Ye(ee,Z,ae,be){for(var nt=null,qt=null,Ve=Z,vt=Z=0,Rt=null;Ve!==null&&vt<ae.length;vt++){Ve.index>vt?(Rt=Ve,Ve=null):Rt=Ve.sibling;var Yt=ce(ee,Ve,ae[vt],be);if(Yt===null){Ve===null&&(Ve=Rt);break}t&&Ve&&Yt.alternate===null&&r(ee,Ve),Z=y(Yt,Z,vt),qt===null?nt=Yt:qt.sibling=Yt,qt=Yt,Ve=Rt}if(vt===ae.length)return s(ee,Ve),Lt&&Ua(ee,vt),nt;if(Ve===null){for(;vt<ae.length;vt++)Ve=Ce(ee,ae[vt],be),Ve!==null&&(Z=y(Ve,Z,vt),qt===null?nt=Ve:qt.sibling=Ve,qt=Ve);return Lt&&Ua(ee,vt),nt}for(Ve=c(Ve);vt<ae.length;vt++)Rt=fe(Ve,ee,vt,ae[vt],be),Rt!==null&&(t&&Rt.alternate!==null&&Ve.delete(Rt.key===null?vt:Rt.key),Z=y(Rt,Z,vt),qt===null?nt=Rt:qt.sibling=Rt,qt=Rt);return t&&Ve.forEach(function($l){return r(ee,$l)}),Lt&&Ua(ee,vt),nt}function it(ee,Z,ae,be){if(ae==null)throw Error(i(151));for(var nt=null,qt=null,Ve=Z,vt=Z=0,Rt=null,Yt=ae.next();Ve!==null&&!Yt.done;vt++,Yt=ae.next()){Ve.index>vt?(Rt=Ve,Ve=null):Rt=Ve.sibling;var $l=ce(ee,Ve,Yt.value,be);if($l===null){Ve===null&&(Ve=Rt);break}t&&Ve&&$l.alternate===null&&r(ee,Ve),Z=y($l,Z,vt),qt===null?nt=$l:qt.sibling=$l,qt=$l,Ve=Rt}if(Yt.done)return s(ee,Ve),Lt&&Ua(ee,vt),nt;if(Ve===null){for(;!Yt.done;vt++,Yt=ae.next())Yt=Ce(ee,Yt.value,be),Yt!==null&&(Z=y(Yt,Z,vt),qt===null?nt=Yt:qt.sibling=Yt,qt=Yt);return Lt&&Ua(ee,vt),nt}for(Ve=c(Ve);!Yt.done;vt++,Yt=ae.next())Yt=fe(Ve,ee,vt,Yt.value,be),Yt!==null&&(t&&Yt.alternate!==null&&Ve.delete(Yt.key===null?vt:Yt.key),Z=y(Yt,Z,vt),qt===null?nt=Yt:qt.sibling=Yt,qt=Yt);return t&&Ve.forEach(function(dw){return r(ee,dw)}),Lt&&Ua(ee,vt),nt}function nn(ee,Z,ae,be){if(typeof ae=="object"&&ae!==null&&ae.type===k&&ae.key===null&&(ae=ae.props.children),typeof ae=="object"&&ae!==null){switch(ae.$$typeof){case b:e:{for(var nt=ae.key;Z!==null;){if(Z.key===nt){if(nt=ae.type,nt===k){if(Z.tag===7){s(ee,Z.sibling),be=p(Z,ae.props.children),be.return=ee,ee=be;break e}}else if(Z.elementType===nt||typeof nt=="object"&&nt!==null&&nt.$$typeof===H&&di(nt)===Z.type){s(ee,Z.sibling),be=p(Z,ae.props),Ws(be,ae),be.return=ee,ee=be;break e}s(ee,Z);break}else r(ee,Z);Z=Z.sibling}ae.type===k?(be=ii(ae.props.children,ee.mode,be,ae.key),be.return=ee,ee=be):(be=gc(ae.type,ae.key,ae.props,null,ee.mode,be),Ws(be,ae),be.return=ee,ee=be)}return S(ee);case j:e:{for(nt=ae.key;Z!==null;){if(Z.key===nt)if(Z.tag===4&&Z.stateNode.containerInfo===ae.containerInfo&&Z.stateNode.implementation===ae.implementation){s(ee,Z.sibling),be=p(Z,ae.children||[]),be.return=ee,ee=be;break e}else{s(ee,Z);break}else r(ee,Z);Z=Z.sibling}be=xd(ae,ee.mode,be),be.return=ee,ee=be}return S(ee);case H:return ae=di(ae),nn(ee,Z,ae,be)}if(P(ae))return Ye(ee,Z,ae,be);if(q(ae)){if(nt=q(ae),typeof nt!="function")throw Error(i(150));return ae=nt.call(ae),it(ee,Z,ae,be)}if(typeof ae.then=="function")return nn(ee,Z,Sc(ae),be);if(ae.$$typeof===_)return nn(ee,Z,vc(ee,ae),be);Cc(ee,ae)}return typeof ae=="string"&&ae!==""||typeof ae=="number"||typeof ae=="bigint"?(ae=""+ae,Z!==null&&Z.tag===6?(s(ee,Z.sibling),be=p(Z,ae),be.return=ee,ee=be):(s(ee,Z),be=pd(ae,ee.mode,be),be.return=ee,ee=be),S(ee)):s(ee,Z)}return function(ee,Z,ae,be){try{Xs=0;var nt=nn(ee,Z,ae,be);return Pi=null,nt}catch(Ve){if(Ve===Ki||Ve===kc)throw Ve;var qt=Er(29,Ve,null,ee.mode);return qt.lanes=be,qt.return=ee,qt}finally{}}}var hi=Op(!0),$p=Op(!1),wl=!1;function Ad(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Dd(t,r){t=t.updateQueue,r.updateQueue===t&&(r.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function kl(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function jl(t,r,s){var c=t.updateQueue;if(c===null)return null;if(c=c.shared,(Vt&2)!==0){var p=c.pending;return p===null?r.next=r:(r.next=p.next,p.next=r),c.pending=r,r=xc(t),wp(t,null,s),r}return pc(t,c,r,s),xc(t)}function Vs(t,r,s){if(r=r.updateQueue,r!==null&&(r=r.shared,(s&4194048)!==0)){var c=r.lanes;c&=t.pendingLanes,s|=c,r.lanes=s,hn(t,s)}}function Td(t,r){var s=t.updateQueue,c=t.alternate;if(c!==null&&(c=c.updateQueue,s===c)){var p=null,y=null;if(s=s.firstBaseUpdate,s!==null){do{var S={lane:s.lane,tag:s.tag,payload:s.payload,callback:null,next:null};y===null?p=y=S:y=y.next=S,s=s.next}while(s!==null);y===null?p=y=r:y=y.next=r}else p=y=r;s={baseState:c.baseState,firstBaseUpdate:p,lastBaseUpdate:y,shared:c.shared,callbacks:c.callbacks},t.updateQueue=s;return}t=s.lastBaseUpdate,t===null?s.firstBaseUpdate=r:t.next=r,s.lastBaseUpdate=r}var Fd=!1;function Gs(){if(Fd){var t=Gi;if(t!==null)throw t}}function Ks(t,r,s,c){Fd=!1;var p=t.updateQueue;wl=!1;var y=p.firstBaseUpdate,S=p.lastBaseUpdate,z=p.shared.pending;if(z!==null){p.shared.pending=null;var V=z,le=V.next;V.next=null,S===null?y=le:S.next=le,S=V;var xe=t.alternate;xe!==null&&(xe=xe.updateQueue,z=xe.lastBaseUpdate,z!==S&&(z===null?xe.firstBaseUpdate=le:z.next=le,xe.lastBaseUpdate=V))}if(y!==null){var Ce=p.baseState;S=0,xe=le=V=null,z=y;do{var ce=z.lane&-536870913,fe=ce!==z.lane;if(fe?(Mt&ce)===ce:(c&ce)===ce){ce!==0&&ce===Vi&&(Fd=!0),xe!==null&&(xe=xe.next={lane:0,tag:z.tag,payload:z.payload,callback:null,next:null});e:{var Ye=t,it=z;ce=r;var nn=s;switch(it.tag){case 1:if(Ye=it.payload,typeof Ye=="function"){Ce=Ye.call(nn,Ce,ce);break e}Ce=Ye;break e;case 3:Ye.flags=Ye.flags&-65537|128;case 0:if(Ye=it.payload,ce=typeof Ye=="function"?Ye.call(nn,Ce,ce):Ye,ce==null)break e;Ce=g({},Ce,ce);break e;case 2:wl=!0}}ce=z.callback,ce!==null&&(t.flags|=64,fe&&(t.flags|=8192),fe=p.callbacks,fe===null?p.callbacks=[ce]:fe.push(ce))}else fe={lane:ce,tag:z.tag,payload:z.payload,callback:z.callback,next:null},xe===null?(le=xe=fe,V=Ce):xe=xe.next=fe,S|=ce;if(z=z.next,z===null){if(z=p.shared.pending,z===null)break;fe=z,z=fe.next,fe.next=null,p.lastBaseUpdate=fe,p.shared.pending=null}}while(!0);xe===null&&(V=Ce),p.baseState=V,p.firstBaseUpdate=le,p.lastBaseUpdate=xe,y===null&&(p.shared.lanes=0),Al|=S,t.lanes=S,t.memoizedState=Ce}}function Lp(t,r){if(typeof t!="function")throw Error(i(191,t));t.call(r)}function Ip(t,r){var s=t.callbacks;if(s!==null)for(t.callbacks=null,t=0;t<s.length;t++)Lp(s[t],r)}var Qi=B(null),Ec=B(0);function Hp(t,r){t=Ja,T(Ec,t),T(Qi,r),Ja=t|r.baseLanes}function Md(){T(Ec,Ja),T(Qi,Qi.current)}function Rd(){Ja=Ec.current,U(Qi),U(Ec)}var Nr=B(null),Vr=null;function Sl(t){var r=t.alternate;T(Nn,Nn.current&1),T(Nr,t),Vr===null&&(r===null||Qi.current!==null||r.memoizedState!==null)&&(Vr=t)}function zd(t){T(Nn,Nn.current),T(Nr,t),Vr===null&&(Vr=t)}function Up(t){t.tag===22?(T(Nn,Nn.current),T(Nr,t),Vr===null&&(Vr=t)):Cl()}function Cl(){T(Nn,Nn.current),T(Nr,Nr.current)}function Ar(t){U(Nr),Vr===t&&(Vr=null),U(Nn)}var Nn=B(0);function Nc(t){for(var r=t;r!==null;){if(r.tag===13){var s=r.memoizedState;if(s!==null&&(s=s.dehydrated,s===null||Hf(s)||Uf(s)))return r}else if(r.tag===19&&(r.memoizedProps.revealOrder==="forwards"||r.memoizedProps.revealOrder==="backwards"||r.memoizedProps.revealOrder==="unstable_legacy-backwards"||r.memoizedProps.revealOrder==="together")){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===t)break;for(;r.sibling===null;){if(r.return===null||r.return===t)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var Xa=0,gt=null,en=null,Fn=null,Ac=!1,Zi=!1,mi=!1,Dc=0,Ps=0,Ji=null,t2=0;function Cn(){throw Error(i(321))}function _d(t,r){if(r===null)return!1;for(var s=0;s<r.length&&s<t.length;s++)if(!Cr(t[s],r[s]))return!1;return!0}function Bd(t,r,s,c,p,y){return Xa=y,gt=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,Y.H=t===null||t.memoizedState===null?Cx:Qd,mi=!1,y=s(c,p),mi=!1,Zi&&(y=Yp(r,s,c,p)),qp(t),y}function qp(t){Y.H=Js;var r=en!==null&&en.next!==null;if(Xa=0,Fn=en=gt=null,Ac=!1,Ps=0,Ji=null,r)throw Error(i(300));t===null||Mn||(t=t.dependencies,t!==null&&bc(t)&&(Mn=!0))}function Yp(t,r,s,c){gt=t;var p=0;do{if(Zi&&(Ji=null),Ps=0,Zi=!1,25<=p)throw Error(i(301));if(p+=1,Fn=en=null,t.updateQueue!=null){var y=t.updateQueue;y.lastEffect=null,y.events=null,y.stores=null,y.memoCache!=null&&(y.memoCache.index=0)}Y.H=Ex,y=r(s,c)}while(Zi);return y}function n2(){var t=Y.H,r=t.useState()[0];return r=typeof r.then=="function"?Qs(r):r,t=t.useState()[0],(en!==null?en.memoizedState:null)!==t&&(gt.flags|=1024),r}function Od(){var t=Dc!==0;return Dc=0,t}function $d(t,r,s){r.updateQueue=t.updateQueue,r.flags&=-2053,t.lanes&=~s}function Ld(t){if(Ac){for(t=t.memoizedState;t!==null;){var r=t.queue;r!==null&&(r.pending=null),t=t.next}Ac=!1}Xa=0,Fn=en=gt=null,Zi=!1,Ps=Dc=0,Ji=null}function or(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Fn===null?gt.memoizedState=Fn=t:Fn=Fn.next=t,Fn}function An(){if(en===null){var t=gt.alternate;t=t!==null?t.memoizedState:null}else t=en.next;var r=Fn===null?gt.memoizedState:Fn.next;if(r!==null)Fn=r,en=t;else{if(t===null)throw gt.alternate===null?Error(i(467)):Error(i(310));en=t,t={memoizedState:en.memoizedState,baseState:en.baseState,baseQueue:en.baseQueue,queue:en.queue,next:null},Fn===null?gt.memoizedState=Fn=t:Fn=Fn.next=t}return Fn}function Tc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Qs(t){var r=Ps;return Ps+=1,Ji===null&&(Ji=[]),t=zp(Ji,t,r),r=gt,(Fn===null?r.memoizedState:Fn.next)===null&&(r=r.alternate,Y.H=r===null||r.memoizedState===null?Cx:Qd),t}function Fc(t){if(t!==null&&typeof t=="object"){if(typeof t.then=="function")return Qs(t);if(t.$$typeof===_)return Qn(t)}throw Error(i(438,String(t)))}function Id(t){var r=null,s=gt.updateQueue;if(s!==null&&(r=s.memoCache),r==null){var c=gt.alternate;c!==null&&(c=c.updateQueue,c!==null&&(c=c.memoCache,c!=null&&(r={data:c.data.map(function(p){return p.slice()}),index:0})))}if(r==null&&(r={data:[],index:0}),s===null&&(s=Tc(),gt.updateQueue=s),s.memoCache=r,s=r.data[r.index],s===void 0)for(s=r.data[r.index]=Array(t),c=0;c<t;c++)s[c]=A;return r.index++,s}function Wa(t,r){return typeof r=="function"?r(t):r}function Mc(t){var r=An();return Hd(r,en,t)}function Hd(t,r,s){var c=t.queue;if(c===null)throw Error(i(311));c.lastRenderedReducer=s;var p=t.baseQueue,y=c.pending;if(y!==null){if(p!==null){var S=p.next;p.next=y.next,y.next=S}r.baseQueue=p=y,c.pending=null}if(y=t.baseState,p===null)t.memoizedState=y;else{r=p.next;var z=S=null,V=null,le=r,xe=!1;do{var Ce=le.lane&-536870913;if(Ce!==le.lane?(Mt&Ce)===Ce:(Xa&Ce)===Ce){var ce=le.revertLane;if(ce===0)V!==null&&(V=V.next={lane:0,revertLane:0,gesture:null,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null}),Ce===Vi&&(xe=!0);else if((Xa&ce)===ce){le=le.next,ce===Vi&&(xe=!0);continue}else Ce={lane:0,revertLane:le.revertLane,gesture:null,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null},V===null?(z=V=Ce,S=y):V=V.next=Ce,gt.lanes|=ce,Al|=ce;Ce=le.action,mi&&s(y,Ce),y=le.hasEagerState?le.eagerState:s(y,Ce)}else ce={lane:Ce,revertLane:le.revertLane,gesture:le.gesture,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null},V===null?(z=V=ce,S=y):V=V.next=ce,gt.lanes|=Ce,Al|=Ce;le=le.next}while(le!==null&&le!==r);if(V===null?S=y:V.next=z,!Cr(y,t.memoizedState)&&(Mn=!0,xe&&(s=Gi,s!==null)))throw s;t.memoizedState=y,t.baseState=S,t.baseQueue=V,c.lastRenderedState=y}return p===null&&(c.lanes=0),[t.memoizedState,c.dispatch]}function Ud(t){var r=An(),s=r.queue;if(s===null)throw Error(i(311));s.lastRenderedReducer=t;var c=s.dispatch,p=s.pending,y=r.memoizedState;if(p!==null){s.pending=null;var S=p=p.next;do y=t(y,S.action),S=S.next;while(S!==p);Cr(y,r.memoizedState)||(Mn=!0),r.memoizedState=y,r.baseQueue===null&&(r.baseState=y),s.lastRenderedState=y}return[y,c]}function Xp(t,r,s){var c=gt,p=An(),y=Lt;if(y){if(s===void 0)throw Error(i(407));s=s()}else s=r();var S=!Cr((en||p).memoizedState,s);if(S&&(p.memoizedState=s,Mn=!0),p=p.queue,Xd(Gp.bind(null,c,p,t),[t]),p.getSnapshot!==r||S||Fn!==null&&Fn.memoizedState.tag&1){if(c.flags|=2048,es(9,{destroy:void 0},Vp.bind(null,c,p,s,r),null),sn===null)throw Error(i(349));y||(Xa&127)!==0||Wp(c,r,s)}return s}function Wp(t,r,s){t.flags|=16384,t={getSnapshot:r,value:s},r=gt.updateQueue,r===null?(r=Tc(),gt.updateQueue=r,r.stores=[t]):(s=r.stores,s===null?r.stores=[t]:s.push(t))}function Vp(t,r,s,c){r.value=s,r.getSnapshot=c,Kp(r)&&Pp(t)}function Gp(t,r,s){return s(function(){Kp(r)&&Pp(t)})}function Kp(t){var r=t.getSnapshot;t=t.value;try{var s=r();return!Cr(t,s)}catch{return!0}}function Pp(t){var r=li(t,2);r!==null&&br(r,t,2)}function qd(t){var r=or();if(typeof t=="function"){var s=t;if(t=s(),mi){at(!0);try{s()}finally{at(!1)}}}return r.memoizedState=r.baseState=t,r.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Wa,lastRenderedState:t},r}function Qp(t,r,s,c){return t.baseState=s,Hd(t,en,typeof c=="function"?c:Wa)}function r2(t,r,s,c,p){if(_c(t))throw Error(i(485));if(t=r.action,t!==null){var y={payload:p,action:t,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(S){y.listeners.push(S)}};Y.T!==null?s(!0):y.isTransition=!1,c(y),s=r.pending,s===null?(y.next=r.pending=y,Zp(r,y)):(y.next=s.next,r.pending=s.next=y)}}function Zp(t,r){var s=r.action,c=r.payload,p=t.state;if(r.isTransition){var y=Y.T,S={};Y.T=S;try{var z=s(p,c),V=Y.S;V!==null&&V(S,z),Jp(t,r,z)}catch(le){Yd(t,r,le)}finally{y!==null&&S.types!==null&&(y.types=S.types),Y.T=y}}else try{y=s(p,c),Jp(t,r,y)}catch(le){Yd(t,r,le)}}function Jp(t,r,s){s!==null&&typeof s=="object"&&typeof s.then=="function"?s.then(function(c){ex(t,r,c)},function(c){return Yd(t,r,c)}):ex(t,r,s)}function ex(t,r,s){r.status="fulfilled",r.value=s,tx(r),t.state=s,r=t.pending,r!==null&&(s=r.next,s===r?t.pending=null:(s=s.next,r.next=s,Zp(t,s)))}function Yd(t,r,s){var c=t.pending;if(t.pending=null,c!==null){c=c.next;do r.status="rejected",r.reason=s,tx(r),r=r.next;while(r!==c)}t.action=null}function tx(t){t=t.listeners;for(var r=0;r<t.length;r++)(0,t[r])()}function nx(t,r){return r}function rx(t,r){if(Lt){var s=sn.formState;if(s!==null){e:{var c=gt;if(Lt){if(xn){t:{for(var p=xn,y=Wr;p.nodeType!==8;){if(!y){p=null;break t}if(p=Gr(p.nextSibling),p===null){p=null;break t}}y=p.data,p=y==="F!"||y==="F"?p:null}if(p){xn=Gr(p.nextSibling),c=p.data==="F!";break e}}bl(c)}c=!1}c&&(r=s[0])}}return s=or(),s.memoizedState=s.baseState=r,c={pending:null,lanes:0,dispatch:null,lastRenderedReducer:nx,lastRenderedState:r},s.queue=c,s=kx.bind(null,gt,c),c.dispatch=s,c=qd(!1),y=Pd.bind(null,gt,!1,c.queue),c=or(),p={state:r,dispatch:null,action:t,pending:null},c.queue=p,s=r2.bind(null,gt,p,y,s),p.dispatch=s,c.memoizedState=t,[r,s,!1]}function ax(t){var r=An();return lx(r,en,t)}function lx(t,r,s){if(r=Hd(t,r,nx)[0],t=Mc(Wa)[0],typeof r=="object"&&r!==null&&typeof r.then=="function")try{var c=Qs(r)}catch(S){throw S===Ki?kc:S}else c=r;r=An();var p=r.queue,y=p.dispatch;return s!==r.memoizedState&&(gt.flags|=2048,es(9,{destroy:void 0},a2.bind(null,p,s),null)),[c,y,t]}function a2(t,r){t.action=r}function ix(t){var r=An(),s=en;if(s!==null)return lx(r,s,t);An(),r=r.memoizedState,s=An();var c=s.queue.dispatch;return s.memoizedState=t,[r,c,!1]}function es(t,r,s,c){return t={tag:t,create:s,deps:c,inst:r,next:null},r=gt.updateQueue,r===null&&(r=Tc(),gt.updateQueue=r),s=r.lastEffect,s===null?r.lastEffect=t.next=t:(c=s.next,s.next=t,t.next=c,r.lastEffect=t),t}function sx(){return An().memoizedState}function Rc(t,r,s,c){var p=or();gt.flags|=t,p.memoizedState=es(1|r,{destroy:void 0},s,c===void 0?null:c)}function zc(t,r,s,c){var p=An();c=c===void 0?null:c;var y=p.memoizedState.inst;en!==null&&c!==null&&_d(c,en.memoizedState.deps)?p.memoizedState=es(r,y,s,c):(gt.flags|=t,p.memoizedState=es(1|r,y,s,c))}function ox(t,r){Rc(8390656,8,t,r)}function Xd(t,r){zc(2048,8,t,r)}function l2(t){gt.flags|=4;var r=gt.updateQueue;if(r===null)r=Tc(),gt.updateQueue=r,r.events=[t];else{var s=r.events;s===null?r.events=[t]:s.push(t)}}function cx(t){var r=An().memoizedState;return l2({ref:r,nextImpl:t}),function(){if((Vt&2)!==0)throw Error(i(440));return r.impl.apply(void 0,arguments)}}function ux(t,r){return zc(4,2,t,r)}function dx(t,r){return zc(4,4,t,r)}function fx(t,r){if(typeof r=="function"){t=t();var s=r(t);return function(){typeof s=="function"?s():r(null)}}if(r!=null)return t=t(),r.current=t,function(){r.current=null}}function hx(t,r,s){s=s!=null?s.concat([t]):null,zc(4,4,fx.bind(null,r,t),s)}function Wd(){}function mx(t,r){var s=An();r=r===void 0?null:r;var c=s.memoizedState;return r!==null&&_d(r,c[1])?c[0]:(s.memoizedState=[t,r],t)}function px(t,r){var s=An();r=r===void 0?null:r;var c=s.memoizedState;if(r!==null&&_d(r,c[1]))return c[0];if(c=t(),mi){at(!0);try{t()}finally{at(!1)}}return s.memoizedState=[c,r],c}function Vd(t,r,s){return s===void 0||(Xa&1073741824)!==0&&(Mt&261930)===0?t.memoizedState=r:(t.memoizedState=s,t=x1(),gt.lanes|=t,Al|=t,s)}function xx(t,r,s,c){return Cr(s,r)?s:Qi.current!==null?(t=Vd(t,s,c),Cr(t,r)||(Mn=!0),t):(Xa&42)===0||(Xa&1073741824)!==0&&(Mt&261930)===0?(Mn=!0,t.memoizedState=s):(t=x1(),gt.lanes|=t,Al|=t,r)}function gx(t,r,s,c,p){var y=oe.p;oe.p=y!==0&&8>y?y:8;var S=Y.T,z={};Y.T=z,Pd(t,!1,r,s);try{var V=p(),le=Y.S;if(le!==null&&le(z,V),V!==null&&typeof V=="object"&&typeof V.then=="function"){var xe=e2(V,c);Zs(t,r,xe,Fr(t))}else Zs(t,r,c,Fr(t))}catch(Ce){Zs(t,r,{then:function(){},status:"rejected",reason:Ce},Fr())}finally{oe.p=y,S!==null&&z.types!==null&&(S.types=z.types),Y.T=S}}function i2(){}function Gd(t,r,s,c){if(t.tag!==5)throw Error(i(476));var p=yx(t).queue;gx(t,p,r,de,s===null?i2:function(){return bx(t),s(c)})}function yx(t){var r=t.memoizedState;if(r!==null)return r;r={memoizedState:de,baseState:de,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Wa,lastRenderedState:de},next:null};var s={};return r.next={memoizedState:s,baseState:s,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Wa,lastRenderedState:s},next:null},t.memoizedState=r,t=t.alternate,t!==null&&(t.memoizedState=r),r}function bx(t){var r=yx(t);r.next===null&&(r=t.alternate.memoizedState),Zs(t,r.next.queue,{},Fr())}function Kd(){return Qn(xo)}function vx(){return An().memoizedState}function wx(){return An().memoizedState}function s2(t){for(var r=t.return;r!==null;){switch(r.tag){case 24:case 3:var s=Fr();t=kl(s);var c=jl(r,t,s);c!==null&&(br(c,r,s),Vs(c,r,s)),r={cache:Sd()},t.payload=r;return}r=r.return}}function o2(t,r,s){var c=Fr();s={lane:c,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},_c(t)?jx(r,s):(s=hd(t,r,s,c),s!==null&&(br(s,t,c),Sx(s,r,c)))}function kx(t,r,s){var c=Fr();Zs(t,r,s,c)}function Zs(t,r,s,c){var p={lane:c,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null};if(_c(t))jx(r,p);else{var y=t.alternate;if(t.lanes===0&&(y===null||y.lanes===0)&&(y=r.lastRenderedReducer,y!==null))try{var S=r.lastRenderedState,z=y(S,s);if(p.hasEagerState=!0,p.eagerState=z,Cr(z,S))return pc(t,r,p,0),sn===null&&mc(),!1}catch{}finally{}if(s=hd(t,r,p,c),s!==null)return br(s,t,c),Sx(s,r,c),!0}return!1}function Pd(t,r,s,c){if(c={lane:2,revertLane:Df(),gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null},_c(t)){if(r)throw Error(i(479))}else r=hd(t,s,c,2),r!==null&&br(r,t,2)}function _c(t){var r=t.alternate;return t===gt||r!==null&&r===gt}function jx(t,r){Zi=Ac=!0;var s=t.pending;s===null?r.next=r:(r.next=s.next,s.next=r),t.pending=r}function Sx(t,r,s){if((s&4194048)!==0){var c=r.lanes;c&=t.pendingLanes,s|=c,r.lanes=s,hn(t,s)}}var Js={readContext:Qn,use:Fc,useCallback:Cn,useContext:Cn,useEffect:Cn,useImperativeHandle:Cn,useLayoutEffect:Cn,useInsertionEffect:Cn,useMemo:Cn,useReducer:Cn,useRef:Cn,useState:Cn,useDebugValue:Cn,useDeferredValue:Cn,useTransition:Cn,useSyncExternalStore:Cn,useId:Cn,useHostTransitionStatus:Cn,useFormState:Cn,useActionState:Cn,useOptimistic:Cn,useMemoCache:Cn,useCacheRefresh:Cn};Js.useEffectEvent=Cn;var Cx={readContext:Qn,use:Fc,useCallback:function(t,r){return or().memoizedState=[t,r===void 0?null:r],t},useContext:Qn,useEffect:ox,useImperativeHandle:function(t,r,s){s=s!=null?s.concat([t]):null,Rc(4194308,4,fx.bind(null,r,t),s)},useLayoutEffect:function(t,r){return Rc(4194308,4,t,r)},useInsertionEffect:function(t,r){Rc(4,2,t,r)},useMemo:function(t,r){var s=or();r=r===void 0?null:r;var c=t();if(mi){at(!0);try{t()}finally{at(!1)}}return s.memoizedState=[c,r],c},useReducer:function(t,r,s){var c=or();if(s!==void 0){var p=s(r);if(mi){at(!0);try{s(r)}finally{at(!1)}}}else p=r;return c.memoizedState=c.baseState=p,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:p},c.queue=t,t=t.dispatch=o2.bind(null,gt,t),[c.memoizedState,t]},useRef:function(t){var r=or();return t={current:t},r.memoizedState=t},useState:function(t){t=qd(t);var r=t.queue,s=kx.bind(null,gt,r);return r.dispatch=s,[t.memoizedState,s]},useDebugValue:Wd,useDeferredValue:function(t,r){var s=or();return Vd(s,t,r)},useTransition:function(){var t=qd(!1);return t=gx.bind(null,gt,t.queue,!0,!1),or().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,r,s){var c=gt,p=or();if(Lt){if(s===void 0)throw Error(i(407));s=s()}else{if(s=r(),sn===null)throw Error(i(349));(Mt&127)!==0||Wp(c,r,s)}p.memoizedState=s;var y={value:s,getSnapshot:r};return p.queue=y,ox(Gp.bind(null,c,y,t),[t]),c.flags|=2048,es(9,{destroy:void 0},Vp.bind(null,c,y,s,r),null),s},useId:function(){var t=or(),r=sn.identifierPrefix;if(Lt){var s=ga,c=xa;s=(c&~(1<<32-Ke(c)-1)).toString(32)+s,r="_"+r+"R_"+s,s=Dc++,0<s&&(r+="H"+s.toString(32)),r+="_"}else s=t2++,r="_"+r+"r_"+s.toString(32)+"_";return t.memoizedState=r},useHostTransitionStatus:Kd,useFormState:rx,useActionState:rx,useOptimistic:function(t){var r=or();r.memoizedState=r.baseState=t;var s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return r.queue=s,r=Pd.bind(null,gt,!0,s),s.dispatch=r,[t,r]},useMemoCache:Id,useCacheRefresh:function(){return or().memoizedState=s2.bind(null,gt)},useEffectEvent:function(t){var r=or(),s={impl:t};return r.memoizedState=s,function(){if((Vt&2)!==0)throw Error(i(440));return s.impl.apply(void 0,arguments)}}},Qd={readContext:Qn,use:Fc,useCallback:mx,useContext:Qn,useEffect:Xd,useImperativeHandle:hx,useInsertionEffect:ux,useLayoutEffect:dx,useMemo:px,useReducer:Mc,useRef:sx,useState:function(){return Mc(Wa)},useDebugValue:Wd,useDeferredValue:function(t,r){var s=An();return xx(s,en.memoizedState,t,r)},useTransition:function(){var t=Mc(Wa)[0],r=An().memoizedState;return[typeof t=="boolean"?t:Qs(t),r]},useSyncExternalStore:Xp,useId:vx,useHostTransitionStatus:Kd,useFormState:ax,useActionState:ax,useOptimistic:function(t,r){var s=An();return Qp(s,en,t,r)},useMemoCache:Id,useCacheRefresh:wx};Qd.useEffectEvent=cx;var Ex={readContext:Qn,use:Fc,useCallback:mx,useContext:Qn,useEffect:Xd,useImperativeHandle:hx,useInsertionEffect:ux,useLayoutEffect:dx,useMemo:px,useReducer:Ud,useRef:sx,useState:function(){return Ud(Wa)},useDebugValue:Wd,useDeferredValue:function(t,r){var s=An();return en===null?Vd(s,t,r):xx(s,en.memoizedState,t,r)},useTransition:function(){var t=Ud(Wa)[0],r=An().memoizedState;return[typeof t=="boolean"?t:Qs(t),r]},useSyncExternalStore:Xp,useId:vx,useHostTransitionStatus:Kd,useFormState:ix,useActionState:ix,useOptimistic:function(t,r){var s=An();return en!==null?Qp(s,en,t,r):(s.baseState=t,[t,s.queue.dispatch])},useMemoCache:Id,useCacheRefresh:wx};Ex.useEffectEvent=cx;function Zd(t,r,s,c){r=t.memoizedState,s=s(c,r),s=s==null?r:g({},r,s),t.memoizedState=s,t.lanes===0&&(t.updateQueue.baseState=s)}var Jd={enqueueSetState:function(t,r,s){t=t._reactInternals;var c=Fr(),p=kl(c);p.payload=r,s!=null&&(p.callback=s),r=jl(t,p,c),r!==null&&(br(r,t,c),Vs(r,t,c))},enqueueReplaceState:function(t,r,s){t=t._reactInternals;var c=Fr(),p=kl(c);p.tag=1,p.payload=r,s!=null&&(p.callback=s),r=jl(t,p,c),r!==null&&(br(r,t,c),Vs(r,t,c))},enqueueForceUpdate:function(t,r){t=t._reactInternals;var s=Fr(),c=kl(s);c.tag=2,r!=null&&(c.callback=r),r=jl(t,c,s),r!==null&&(br(r,t,s),Vs(r,t,s))}};function Nx(t,r,s,c,p,y,S){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(c,y,S):r.prototype&&r.prototype.isPureReactComponent?!Ls(s,c)||!Ls(p,y):!0}function Ax(t,r,s,c){t=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(s,c),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(s,c),r.state!==t&&Jd.enqueueReplaceState(r,r.state,null)}function pi(t,r){var s=r;if("ref"in r){s={};for(var c in r)c!=="ref"&&(s[c]=r[c])}if(t=t.defaultProps){s===r&&(s=g({},s));for(var p in t)s[p]===void 0&&(s[p]=t[p])}return s}function Dx(t){hc(t)}function Tx(t){console.error(t)}function Fx(t){hc(t)}function Bc(t,r){try{var s=t.onUncaughtError;s(r.value,{componentStack:r.stack})}catch(c){setTimeout(function(){throw c})}}function Mx(t,r,s){try{var c=t.onCaughtError;c(s.value,{componentStack:s.stack,errorBoundary:r.tag===1?r.stateNode:null})}catch(p){setTimeout(function(){throw p})}}function ef(t,r,s){return s=kl(s),s.tag=3,s.payload={element:null},s.callback=function(){Bc(t,r)},s}function Rx(t){return t=kl(t),t.tag=3,t}function zx(t,r,s,c){var p=s.type.getDerivedStateFromError;if(typeof p=="function"){var y=c.value;t.payload=function(){return p(y)},t.callback=function(){Mx(r,s,c)}}var S=s.stateNode;S!==null&&typeof S.componentDidCatch=="function"&&(t.callback=function(){Mx(r,s,c),typeof p!="function"&&(Dl===null?Dl=new Set([this]):Dl.add(this));var z=c.stack;this.componentDidCatch(c.value,{componentStack:z!==null?z:""})})}function c2(t,r,s,c,p){if(s.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){if(r=s.alternate,r!==null&&Wi(r,s,p,!0),s=Nr.current,s!==null){switch(s.tag){case 31:case 13:return Vr===null?Gc():s.alternate===null&&En===0&&(En=3),s.flags&=-257,s.flags|=65536,s.lanes=p,c===jc?s.flags|=16384:(r=s.updateQueue,r===null?s.updateQueue=new Set([c]):r.add(c),Ef(t,c,p)),!1;case 22:return s.flags|=65536,c===jc?s.flags|=16384:(r=s.updateQueue,r===null?(r={transitions:null,markerInstances:null,retryQueue:new Set([c])},s.updateQueue=r):(s=r.retryQueue,s===null?r.retryQueue=new Set([c]):s.add(c)),Ef(t,c,p)),!1}throw Error(i(435,s.tag))}return Ef(t,c,p),Gc(),!1}if(Lt)return r=Nr.current,r!==null?((r.flags&65536)===0&&(r.flags|=256),r.flags|=65536,r.lanes=p,c!==bd&&(t=Error(i(422),{cause:c}),Us(qr(t,s)))):(c!==bd&&(r=Error(i(423),{cause:c}),Us(qr(r,s))),t=t.current.alternate,t.flags|=65536,p&=-p,t.lanes|=p,c=qr(c,s),p=ef(t.stateNode,c,p),Td(t,p),En!==4&&(En=2)),!1;var y=Error(i(520),{cause:c});if(y=qr(y,s),so===null?so=[y]:so.push(y),En!==4&&(En=2),r===null)return!0;c=qr(c,s),s=r;do{switch(s.tag){case 3:return s.flags|=65536,t=p&-p,s.lanes|=t,t=ef(s.stateNode,c,t),Td(s,t),!1;case 1:if(r=s.type,y=s.stateNode,(s.flags&128)===0&&(typeof r.getDerivedStateFromError=="function"||y!==null&&typeof y.componentDidCatch=="function"&&(Dl===null||!Dl.has(y))))return s.flags|=65536,p&=-p,s.lanes|=p,p=Rx(p),zx(p,t,s,c),Td(s,p),!1}s=s.return}while(s!==null);return!1}var tf=Error(i(461)),Mn=!1;function Zn(t,r,s,c){r.child=t===null?$p(r,null,s,c):hi(r,t.child,s,c)}function _x(t,r,s,c,p){s=s.render;var y=r.ref;if("ref"in c){var S={};for(var z in c)z!=="ref"&&(S[z]=c[z])}else S=c;return ci(r),c=Bd(t,r,s,S,y,p),z=Od(),t!==null&&!Mn?($d(t,r,p),Va(t,r,p)):(Lt&&z&&gd(r),r.flags|=1,Zn(t,r,c,p),r.child)}function Bx(t,r,s,c,p){if(t===null){var y=s.type;return typeof y=="function"&&!md(y)&&y.defaultProps===void 0&&s.compare===null?(r.tag=15,r.type=y,Ox(t,r,y,c,p)):(t=gc(s.type,null,c,r,r.mode,p),t.ref=r.ref,t.return=r,r.child=t)}if(y=t.child,!uf(t,p)){var S=y.memoizedProps;if(s=s.compare,s=s!==null?s:Ls,s(S,c)&&t.ref===r.ref)return Va(t,r,p)}return r.flags|=1,t=Ha(y,c),t.ref=r.ref,t.return=r,r.child=t}function Ox(t,r,s,c,p){if(t!==null){var y=t.memoizedProps;if(Ls(y,c)&&t.ref===r.ref)if(Mn=!1,r.pendingProps=c=y,uf(t,p))(t.flags&131072)!==0&&(Mn=!0);else return r.lanes=t.lanes,Va(t,r,p)}return nf(t,r,s,c,p)}function $x(t,r,s,c){var p=c.children,y=t!==null?t.memoizedState:null;if(t===null&&r.stateNode===null&&(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),c.mode==="hidden"){if((r.flags&128)!==0){if(y=y!==null?y.baseLanes|s:s,t!==null){for(c=r.child=t.child,p=0;c!==null;)p=p|c.lanes|c.childLanes,c=c.sibling;c=p&~y}else c=0,r.child=null;return Lx(t,r,y,s,c)}if((s&536870912)!==0)r.memoizedState={baseLanes:0,cachePool:null},t!==null&&wc(r,y!==null?y.cachePool:null),y!==null?Hp(r,y):Md(),Up(r);else return c=r.lanes=536870912,Lx(t,r,y!==null?y.baseLanes|s:s,s,c)}else y!==null?(wc(r,y.cachePool),Hp(r,y),Cl(),r.memoizedState=null):(t!==null&&wc(r,null),Md(),Cl());return Zn(t,r,p,s),r.child}function eo(t,r){return t!==null&&t.tag===22||r.stateNode!==null||(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.sibling}function Lx(t,r,s,c,p){var y=Ed();return y=y===null?null:{parent:Tn._currentValue,pool:y},r.memoizedState={baseLanes:s,cachePool:y},t!==null&&wc(r,null),Md(),Up(r),t!==null&&Wi(t,r,c,!0),r.childLanes=p,null}function Oc(t,r){return r=Lc({mode:r.mode,children:r.children},t.mode),r.ref=t.ref,t.child=r,r.return=t,r}function Ix(t,r,s){return hi(r,t.child,null,s),t=Oc(r,r.pendingProps),t.flags|=2,Ar(r),r.memoizedState=null,t}function u2(t,r,s){var c=r.pendingProps,p=(r.flags&128)!==0;if(r.flags&=-129,t===null){if(Lt){if(c.mode==="hidden")return t=Oc(r,c),r.lanes=536870912,eo(null,t);if(zd(r),(t=xn)?(t=Z1(t,Wr),t=t!==null&&t.data==="&"?t:null,t!==null&&(r.memoizedState={dehydrated:t,treeContext:gl!==null?{id:xa,overflow:ga}:null,retryLane:536870912,hydrationErrors:null},s=jp(t),s.return=r,r.child=s,Pn=r,xn=null)):t=null,t===null)throw bl(r);return r.lanes=536870912,null}return Oc(r,c)}var y=t.memoizedState;if(y!==null){var S=y.dehydrated;if(zd(r),p)if(r.flags&256)r.flags&=-257,r=Ix(t,r,s);else if(r.memoizedState!==null)r.child=t.child,r.flags|=128,r=null;else throw Error(i(558));else if(Mn||Wi(t,r,s,!1),p=(s&t.childLanes)!==0,Mn||p){if(c=sn,c!==null&&(S=te(c,s),S!==0&&S!==y.retryLane))throw y.retryLane=S,li(t,S),br(c,t,S),tf;Gc(),r=Ix(t,r,s)}else t=y.treeContext,xn=Gr(S.nextSibling),Pn=r,Lt=!0,yl=null,Wr=!1,t!==null&&Ep(r,t),r=Oc(r,c),r.flags|=4096;return r}return t=Ha(t.child,{mode:c.mode,children:c.children}),t.ref=r.ref,r.child=t,t.return=r,t}function $c(t,r){var s=r.ref;if(s===null)t!==null&&t.ref!==null&&(r.flags|=4194816);else{if(typeof s!="function"&&typeof s!="object")throw Error(i(284));(t===null||t.ref!==s)&&(r.flags|=4194816)}}function nf(t,r,s,c,p){return ci(r),s=Bd(t,r,s,c,void 0,p),c=Od(),t!==null&&!Mn?($d(t,r,p),Va(t,r,p)):(Lt&&c&&gd(r),r.flags|=1,Zn(t,r,s,p),r.child)}function Hx(t,r,s,c,p,y){return ci(r),r.updateQueue=null,s=Yp(r,c,s,p),qp(t),c=Od(),t!==null&&!Mn?($d(t,r,y),Va(t,r,y)):(Lt&&c&&gd(r),r.flags|=1,Zn(t,r,s,y),r.child)}function Ux(t,r,s,c,p){if(ci(r),r.stateNode===null){var y=Ui,S=s.contextType;typeof S=="object"&&S!==null&&(y=Qn(S)),y=new s(c,y),r.memoizedState=y.state!==null&&y.state!==void 0?y.state:null,y.updater=Jd,r.stateNode=y,y._reactInternals=r,y=r.stateNode,y.props=c,y.state=r.memoizedState,y.refs={},Ad(r),S=s.contextType,y.context=typeof S=="object"&&S!==null?Qn(S):Ui,y.state=r.memoizedState,S=s.getDerivedStateFromProps,typeof S=="function"&&(Zd(r,s,S,c),y.state=r.memoizedState),typeof s.getDerivedStateFromProps=="function"||typeof y.getSnapshotBeforeUpdate=="function"||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(S=y.state,typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount(),S!==y.state&&Jd.enqueueReplaceState(y,y.state,null),Ks(r,c,y,p),Gs(),y.state=r.memoizedState),typeof y.componentDidMount=="function"&&(r.flags|=4194308),c=!0}else if(t===null){y=r.stateNode;var z=r.memoizedProps,V=pi(s,z);y.props=V;var le=y.context,xe=s.contextType;S=Ui,typeof xe=="object"&&xe!==null&&(S=Qn(xe));var Ce=s.getDerivedStateFromProps;xe=typeof Ce=="function"||typeof y.getSnapshotBeforeUpdate=="function",z=r.pendingProps!==z,xe||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(z||le!==S)&&Ax(r,y,c,S),wl=!1;var ce=r.memoizedState;y.state=ce,Ks(r,c,y,p),Gs(),le=r.memoizedState,z||ce!==le||wl?(typeof Ce=="function"&&(Zd(r,s,Ce,c),le=r.memoizedState),(V=wl||Nx(r,s,V,c,ce,le,S))?(xe||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount()),typeof y.componentDidMount=="function"&&(r.flags|=4194308)):(typeof y.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=c,r.memoizedState=le),y.props=c,y.state=le,y.context=S,c=V):(typeof y.componentDidMount=="function"&&(r.flags|=4194308),c=!1)}else{y=r.stateNode,Dd(t,r),S=r.memoizedProps,xe=pi(s,S),y.props=xe,Ce=r.pendingProps,ce=y.context,le=s.contextType,V=Ui,typeof le=="object"&&le!==null&&(V=Qn(le)),z=s.getDerivedStateFromProps,(le=typeof z=="function"||typeof y.getSnapshotBeforeUpdate=="function")||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(S!==Ce||ce!==V)&&Ax(r,y,c,V),wl=!1,ce=r.memoizedState,y.state=ce,Ks(r,c,y,p),Gs();var fe=r.memoizedState;S!==Ce||ce!==fe||wl||t!==null&&t.dependencies!==null&&bc(t.dependencies)?(typeof z=="function"&&(Zd(r,s,z,c),fe=r.memoizedState),(xe=wl||Nx(r,s,xe,c,ce,fe,V)||t!==null&&t.dependencies!==null&&bc(t.dependencies))?(le||typeof y.UNSAFE_componentWillUpdate!="function"&&typeof y.componentWillUpdate!="function"||(typeof y.componentWillUpdate=="function"&&y.componentWillUpdate(c,fe,V),typeof y.UNSAFE_componentWillUpdate=="function"&&y.UNSAFE_componentWillUpdate(c,fe,V)),typeof y.componentDidUpdate=="function"&&(r.flags|=4),typeof y.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof y.componentDidUpdate!="function"||S===t.memoizedProps&&ce===t.memoizedState||(r.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||S===t.memoizedProps&&ce===t.memoizedState||(r.flags|=1024),r.memoizedProps=c,r.memoizedState=fe),y.props=c,y.state=fe,y.context=V,c=xe):(typeof y.componentDidUpdate!="function"||S===t.memoizedProps&&ce===t.memoizedState||(r.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||S===t.memoizedProps&&ce===t.memoizedState||(r.flags|=1024),c=!1)}return y=c,$c(t,r),c=(r.flags&128)!==0,y||c?(y=r.stateNode,s=c&&typeof s.getDerivedStateFromError!="function"?null:y.render(),r.flags|=1,t!==null&&c?(r.child=hi(r,t.child,null,p),r.child=hi(r,null,s,p)):Zn(t,r,s,p),r.memoizedState=y.state,t=r.child):t=Va(t,r,p),t}function qx(t,r,s,c){return si(),r.flags|=256,Zn(t,r,s,c),r.child}var rf={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function af(t){return{baseLanes:t,cachePool:Mp()}}function lf(t,r,s){return t=t!==null?t.childLanes&~s:0,r&&(t|=Tr),t}function Yx(t,r,s){var c=r.pendingProps,p=!1,y=(r.flags&128)!==0,S;if((S=y)||(S=t!==null&&t.memoizedState===null?!1:(Nn.current&2)!==0),S&&(p=!0,r.flags&=-129),S=(r.flags&32)!==0,r.flags&=-33,t===null){if(Lt){if(p?Sl(r):Cl(),(t=xn)?(t=Z1(t,Wr),t=t!==null&&t.data!=="&"?t:null,t!==null&&(r.memoizedState={dehydrated:t,treeContext:gl!==null?{id:xa,overflow:ga}:null,retryLane:536870912,hydrationErrors:null},s=jp(t),s.return=r,r.child=s,Pn=r,xn=null)):t=null,t===null)throw bl(r);return Uf(t)?r.lanes=32:r.lanes=536870912,null}var z=c.children;return c=c.fallback,p?(Cl(),p=r.mode,z=Lc({mode:"hidden",children:z},p),c=ii(c,p,s,null),z.return=r,c.return=r,z.sibling=c,r.child=z,c=r.child,c.memoizedState=af(s),c.childLanes=lf(t,S,s),r.memoizedState=rf,eo(null,c)):(Sl(r),sf(r,z))}var V=t.memoizedState;if(V!==null&&(z=V.dehydrated,z!==null)){if(y)r.flags&256?(Sl(r),r.flags&=-257,r=of(t,r,s)):r.memoizedState!==null?(Cl(),r.child=t.child,r.flags|=128,r=null):(Cl(),z=c.fallback,p=r.mode,c=Lc({mode:"visible",children:c.children},p),z=ii(z,p,s,null),z.flags|=2,c.return=r,z.return=r,c.sibling=z,r.child=c,hi(r,t.child,null,s),c=r.child,c.memoizedState=af(s),c.childLanes=lf(t,S,s),r.memoizedState=rf,r=eo(null,c));else if(Sl(r),Uf(z)){if(S=z.nextSibling&&z.nextSibling.dataset,S)var le=S.dgst;S=le,c=Error(i(419)),c.stack="",c.digest=S,Us({value:c,source:null,stack:null}),r=of(t,r,s)}else if(Mn||Wi(t,r,s,!1),S=(s&t.childLanes)!==0,Mn||S){if(S=sn,S!==null&&(c=te(S,s),c!==0&&c!==V.retryLane))throw V.retryLane=c,li(t,c),br(S,t,c),tf;Hf(z)||Gc(),r=of(t,r,s)}else Hf(z)?(r.flags|=192,r.child=t.child,r=null):(t=V.treeContext,xn=Gr(z.nextSibling),Pn=r,Lt=!0,yl=null,Wr=!1,t!==null&&Ep(r,t),r=sf(r,c.children),r.flags|=4096);return r}return p?(Cl(),z=c.fallback,p=r.mode,V=t.child,le=V.sibling,c=Ha(V,{mode:"hidden",children:c.children}),c.subtreeFlags=V.subtreeFlags&65011712,le!==null?z=Ha(le,z):(z=ii(z,p,s,null),z.flags|=2),z.return=r,c.return=r,c.sibling=z,r.child=c,eo(null,c),c=r.child,z=t.child.memoizedState,z===null?z=af(s):(p=z.cachePool,p!==null?(V=Tn._currentValue,p=p.parent!==V?{parent:V,pool:V}:p):p=Mp(),z={baseLanes:z.baseLanes|s,cachePool:p}),c.memoizedState=z,c.childLanes=lf(t,S,s),r.memoizedState=rf,eo(t.child,c)):(Sl(r),s=t.child,t=s.sibling,s=Ha(s,{mode:"visible",children:c.children}),s.return=r,s.sibling=null,t!==null&&(S=r.deletions,S===null?(r.deletions=[t],r.flags|=16):S.push(t)),r.child=s,r.memoizedState=null,s)}function sf(t,r){return r=Lc({mode:"visible",children:r},t.mode),r.return=t,t.child=r}function Lc(t,r){return t=Er(22,t,null,r),t.lanes=0,t}function of(t,r,s){return hi(r,t.child,null,s),t=sf(r,r.pendingProps.children),t.flags|=2,r.memoizedState=null,t}function Xx(t,r,s){t.lanes|=r;var c=t.alternate;c!==null&&(c.lanes|=r),kd(t.return,r,s)}function cf(t,r,s,c,p,y){var S=t.memoizedState;S===null?t.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:c,tail:s,tailMode:p,treeForkCount:y}:(S.isBackwards=r,S.rendering=null,S.renderingStartTime=0,S.last=c,S.tail=s,S.tailMode=p,S.treeForkCount=y)}function Wx(t,r,s){var c=r.pendingProps,p=c.revealOrder,y=c.tail;c=c.children;var S=Nn.current,z=(S&2)!==0;if(z?(S=S&1|2,r.flags|=128):S&=1,T(Nn,S),Zn(t,r,c,s),c=Lt?Hs:0,!z&&t!==null&&(t.flags&128)!==0)e:for(t=r.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&Xx(t,s,r);else if(t.tag===19)Xx(t,s,r);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===r)break e;for(;t.sibling===null;){if(t.return===null||t.return===r)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}switch(p){case"forwards":for(s=r.child,p=null;s!==null;)t=s.alternate,t!==null&&Nc(t)===null&&(p=s),s=s.sibling;s=p,s===null?(p=r.child,r.child=null):(p=s.sibling,s.sibling=null),cf(r,!1,p,s,y,c);break;case"backwards":case"unstable_legacy-backwards":for(s=null,p=r.child,r.child=null;p!==null;){if(t=p.alternate,t!==null&&Nc(t)===null){r.child=p;break}t=p.sibling,p.sibling=s,s=p,p=t}cf(r,!0,s,null,y,c);break;case"together":cf(r,!1,null,null,void 0,c);break;default:r.memoizedState=null}return r.child}function Va(t,r,s){if(t!==null&&(r.dependencies=t.dependencies),Al|=r.lanes,(s&r.childLanes)===0)if(t!==null){if(Wi(t,r,s,!1),(s&r.childLanes)===0)return null}else return null;if(t!==null&&r.child!==t.child)throw Error(i(153));if(r.child!==null){for(t=r.child,s=Ha(t,t.pendingProps),r.child=s,s.return=r;t.sibling!==null;)t=t.sibling,s=s.sibling=Ha(t,t.pendingProps),s.return=r;s.sibling=null}return r.child}function uf(t,r){return(t.lanes&r)!==0?!0:(t=t.dependencies,!!(t!==null&&bc(t)))}function d2(t,r,s){switch(r.tag){case 3:Ie(r,r.stateNode.containerInfo),vl(r,Tn,t.memoizedState.cache),si();break;case 27:case 5:ot(r);break;case 4:Ie(r,r.stateNode.containerInfo);break;case 10:vl(r,r.type,r.memoizedProps.value);break;case 31:if(r.memoizedState!==null)return r.flags|=128,zd(r),null;break;case 13:var c=r.memoizedState;if(c!==null)return c.dehydrated!==null?(Sl(r),r.flags|=128,null):(s&r.child.childLanes)!==0?Yx(t,r,s):(Sl(r),t=Va(t,r,s),t!==null?t.sibling:null);Sl(r);break;case 19:var p=(t.flags&128)!==0;if(c=(s&r.childLanes)!==0,c||(Wi(t,r,s,!1),c=(s&r.childLanes)!==0),p){if(c)return Wx(t,r,s);r.flags|=128}if(p=r.memoizedState,p!==null&&(p.rendering=null,p.tail=null,p.lastEffect=null),T(Nn,Nn.current),c)break;return null;case 22:return r.lanes=0,$x(t,r,s,r.pendingProps);case 24:vl(r,Tn,t.memoizedState.cache)}return Va(t,r,s)}function Vx(t,r,s){if(t!==null)if(t.memoizedProps!==r.pendingProps)Mn=!0;else{if(!uf(t,s)&&(r.flags&128)===0)return Mn=!1,d2(t,r,s);Mn=(t.flags&131072)!==0}else Mn=!1,Lt&&(r.flags&1048576)!==0&&Cp(r,Hs,r.index);switch(r.lanes=0,r.tag){case 16:e:{var c=r.pendingProps;if(t=di(r.elementType),r.type=t,typeof t=="function")md(t)?(c=pi(t,c),r.tag=1,r=Ux(null,r,t,c,s)):(r.tag=0,r=nf(null,r,t,c,s));else{if(t!=null){var p=t.$$typeof;if(p===R){r.tag=11,r=_x(null,r,t,c,s);break e}else if(p===I){r.tag=14,r=Bx(null,r,t,c,s);break e}}throw r=ie(t)||t,Error(i(306,r,""))}}return r;case 0:return nf(t,r,r.type,r.pendingProps,s);case 1:return c=r.type,p=pi(c,r.pendingProps),Ux(t,r,c,p,s);case 3:e:{if(Ie(r,r.stateNode.containerInfo),t===null)throw Error(i(387));c=r.pendingProps;var y=r.memoizedState;p=y.element,Dd(t,r),Ks(r,c,null,s);var S=r.memoizedState;if(c=S.cache,vl(r,Tn,c),c!==y.cache&&jd(r,[Tn],s,!0),Gs(),c=S.element,y.isDehydrated)if(y={element:c,isDehydrated:!1,cache:S.cache},r.updateQueue.baseState=y,r.memoizedState=y,r.flags&256){r=qx(t,r,c,s);break e}else if(c!==p){p=qr(Error(i(424)),r),Us(p),r=qx(t,r,c,s);break e}else{switch(t=r.stateNode.containerInfo,t.nodeType){case 9:t=t.body;break;default:t=t.nodeName==="HTML"?t.ownerDocument.body:t}for(xn=Gr(t.firstChild),Pn=r,Lt=!0,yl=null,Wr=!0,s=$p(r,null,c,s),r.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling}else{if(si(),c===p){r=Va(t,r,s);break e}Zn(t,r,c,s)}r=r.child}return r;case 26:return $c(t,r),t===null?(s=a0(r.type,null,r.pendingProps,null))?r.memoizedState=s:Lt||(s=r.type,t=r.pendingProps,c=tu(pe.current).createElement(s),c[yn]=r,c[mn]=t,Jn(c,s,t),Dn(c),r.stateNode=c):r.memoizedState=a0(r.type,t.memoizedProps,r.pendingProps,t.memoizedState),null;case 27:return ot(r),t===null&&Lt&&(c=r.stateNode=t0(r.type,r.pendingProps,pe.current),Pn=r,Wr=!0,p=xn,Rl(r.type)?(qf=p,xn=Gr(c.firstChild)):xn=p),Zn(t,r,r.pendingProps.children,s),$c(t,r),t===null&&(r.flags|=4194304),r.child;case 5:return t===null&&Lt&&((p=c=xn)&&(c=H2(c,r.type,r.pendingProps,Wr),c!==null?(r.stateNode=c,Pn=r,xn=Gr(c.firstChild),Wr=!1,p=!0):p=!1),p||bl(r)),ot(r),p=r.type,y=r.pendingProps,S=t!==null?t.memoizedProps:null,c=y.children,$f(p,y)?c=null:S!==null&&$f(p,S)&&(r.flags|=32),r.memoizedState!==null&&(p=Bd(t,r,n2,null,null,s),xo._currentValue=p),$c(t,r),Zn(t,r,c,s),r.child;case 6:return t===null&&Lt&&((t=s=xn)&&(s=U2(s,r.pendingProps,Wr),s!==null?(r.stateNode=s,Pn=r,xn=null,t=!0):t=!1),t||bl(r)),null;case 13:return Yx(t,r,s);case 4:return Ie(r,r.stateNode.containerInfo),c=r.pendingProps,t===null?r.child=hi(r,null,c,s):Zn(t,r,c,s),r.child;case 11:return _x(t,r,r.type,r.pendingProps,s);case 7:return Zn(t,r,r.pendingProps,s),r.child;case 8:return Zn(t,r,r.pendingProps.children,s),r.child;case 12:return Zn(t,r,r.pendingProps.children,s),r.child;case 10:return c=r.pendingProps,vl(r,r.type,c.value),Zn(t,r,c.children,s),r.child;case 9:return p=r.type._context,c=r.pendingProps.children,ci(r),p=Qn(p),c=c(p),r.flags|=1,Zn(t,r,c,s),r.child;case 14:return Bx(t,r,r.type,r.pendingProps,s);case 15:return Ox(t,r,r.type,r.pendingProps,s);case 19:return Wx(t,r,s);case 31:return u2(t,r,s);case 22:return $x(t,r,s,r.pendingProps);case 24:return ci(r),c=Qn(Tn),t===null?(p=Ed(),p===null&&(p=sn,y=Sd(),p.pooledCache=y,y.refCount++,y!==null&&(p.pooledCacheLanes|=s),p=y),r.memoizedState={parent:c,cache:p},Ad(r),vl(r,Tn,p)):((t.lanes&s)!==0&&(Dd(t,r),Ks(r,null,null,s),Gs()),p=t.memoizedState,y=r.memoizedState,p.parent!==c?(p={parent:c,cache:c},r.memoizedState=p,r.lanes===0&&(r.memoizedState=r.updateQueue.baseState=p),vl(r,Tn,c)):(c=y.cache,vl(r,Tn,c),c!==p.cache&&jd(r,[Tn],s,!0))),Zn(t,r,r.pendingProps.children,s),r.child;case 29:throw r.pendingProps}throw Error(i(156,r.tag))}function Ga(t){t.flags|=4}function df(t,r,s,c,p){if((r=(t.mode&32)!==0)&&(r=!1),r){if(t.flags|=16777216,(p&335544128)===p)if(t.stateNode.complete)t.flags|=8192;else if(v1())t.flags|=8192;else throw fi=jc,Nd}else t.flags&=-16777217}function Gx(t,r){if(r.type!=="stylesheet"||(r.state.loading&4)!==0)t.flags&=-16777217;else if(t.flags|=16777216,!c0(r))if(v1())t.flags|=8192;else throw fi=jc,Nd}function Ic(t,r){r!==null&&(t.flags|=4),t.flags&16384&&(r=t.tag!==22?rt():536870912,t.lanes|=r,as|=r)}function to(t,r){if(!Lt)switch(t.tailMode){case"hidden":r=t.tail;for(var s=null;r!==null;)r.alternate!==null&&(s=r),r=r.sibling;s===null?t.tail=null:s.sibling=null;break;case"collapsed":s=t.tail;for(var c=null;s!==null;)s.alternate!==null&&(c=s),s=s.sibling;c===null?r||t.tail===null?t.tail=null:t.tail.sibling=null:c.sibling=null}}function gn(t){var r=t.alternate!==null&&t.alternate.child===t.child,s=0,c=0;if(r)for(var p=t.child;p!==null;)s|=p.lanes|p.childLanes,c|=p.subtreeFlags&65011712,c|=p.flags&65011712,p.return=t,p=p.sibling;else for(p=t.child;p!==null;)s|=p.lanes|p.childLanes,c|=p.subtreeFlags,c|=p.flags,p.return=t,p=p.sibling;return t.subtreeFlags|=c,t.childLanes=s,r}function f2(t,r,s){var c=r.pendingProps;switch(yd(r),r.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return gn(r),null;case 1:return gn(r),null;case 3:return s=r.stateNode,c=null,t!==null&&(c=t.memoizedState.cache),r.memoizedState.cache!==c&&(r.flags|=2048),Ya(Tn),He(),s.pendingContext&&(s.context=s.pendingContext,s.pendingContext=null),(t===null||t.child===null)&&(Xi(r)?Ga(r):t===null||t.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,vd())),gn(r),null;case 26:var p=r.type,y=r.memoizedState;return t===null?(Ga(r),y!==null?(gn(r),Gx(r,y)):(gn(r),df(r,p,null,c,s))):y?y!==t.memoizedState?(Ga(r),gn(r),Gx(r,y)):(gn(r),r.flags&=-16777217):(t=t.memoizedProps,t!==c&&Ga(r),gn(r),df(r,p,t,c,s)),null;case 27:if(Je(r),s=pe.current,p=r.type,t!==null&&r.stateNode!=null)t.memoizedProps!==c&&Ga(r);else{if(!c){if(r.stateNode===null)throw Error(i(166));return gn(r),null}t=se.current,Xi(r)?Np(r):(t=t0(p,c,s),r.stateNode=t,Ga(r))}return gn(r),null;case 5:if(Je(r),p=r.type,t!==null&&r.stateNode!=null)t.memoizedProps!==c&&Ga(r);else{if(!c){if(r.stateNode===null)throw Error(i(166));return gn(r),null}if(y=se.current,Xi(r))Np(r);else{var S=tu(pe.current);switch(y){case 1:y=S.createElementNS("http://www.w3.org/2000/svg",p);break;case 2:y=S.createElementNS("http://www.w3.org/1998/Math/MathML",p);break;default:switch(p){case"svg":y=S.createElementNS("http://www.w3.org/2000/svg",p);break;case"math":y=S.createElementNS("http://www.w3.org/1998/Math/MathML",p);break;case"script":y=S.createElement("div"),y.innerHTML="<script><\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof c.is=="string"?S.createElement("select",{is:c.is}):S.createElement("select"),c.multiple?y.multiple=!0:c.size&&(y.size=c.size);break;default:y=typeof c.is=="string"?S.createElement(p,{is:c.is}):S.createElement(p)}}y[yn]=r,y[mn]=c;e:for(S=r.child;S!==null;){if(S.tag===5||S.tag===6)y.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===r)break e;for(;S.sibling===null;){if(S.return===null||S.return===r)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}r.stateNode=y;e:switch(Jn(y,p,c),p){case"button":case"input":case"select":case"textarea":c=!!c.autoFocus;break e;case"img":c=!0;break e;default:c=!1}c&&Ga(r)}}return gn(r),df(r,r.type,t===null?null:t.memoizedProps,r.pendingProps,s),null;case 6:if(t&&r.stateNode!=null)t.memoizedProps!==c&&Ga(r);else{if(typeof c!="string"&&r.stateNode===null)throw Error(i(166));if(t=pe.current,Xi(r)){if(t=r.stateNode,s=r.memoizedProps,c=null,p=Pn,p!==null)switch(p.tag){case 27:case 5:c=p.memoizedProps}t[yn]=r,t=!!(t.nodeValue===s||c!==null&&c.suppressHydrationWarning===!0||Y1(t.nodeValue,s)),t||bl(r,!0)}else t=tu(t).createTextNode(c),t[yn]=r,r.stateNode=t}return gn(r),null;case 31:if(s=r.memoizedState,t===null||t.memoizedState!==null){if(c=Xi(r),s!==null){if(t===null){if(!c)throw Error(i(318));if(t=r.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(i(557));t[yn]=r}else si(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;gn(r),t=!1}else s=vd(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=s),t=!0;if(!t)return r.flags&256?(Ar(r),r):(Ar(r),null);if((r.flags&128)!==0)throw Error(i(558))}return gn(r),null;case 13:if(c=r.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(p=Xi(r),c!==null&&c.dehydrated!==null){if(t===null){if(!p)throw Error(i(318));if(p=r.memoizedState,p=p!==null?p.dehydrated:null,!p)throw Error(i(317));p[yn]=r}else si(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;gn(r),p=!1}else p=vd(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=p),p=!0;if(!p)return r.flags&256?(Ar(r),r):(Ar(r),null)}return Ar(r),(r.flags&128)!==0?(r.lanes=s,r):(s=c!==null,t=t!==null&&t.memoizedState!==null,s&&(c=r.child,p=null,c.alternate!==null&&c.alternate.memoizedState!==null&&c.alternate.memoizedState.cachePool!==null&&(p=c.alternate.memoizedState.cachePool.pool),y=null,c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(y=c.memoizedState.cachePool.pool),y!==p&&(c.flags|=2048)),s!==t&&s&&(r.child.flags|=8192),Ic(r,r.updateQueue),gn(r),null);case 4:return He(),t===null&&Rf(r.stateNode.containerInfo),gn(r),null;case 10:return Ya(r.type),gn(r),null;case 19:if(U(Nn),c=r.memoizedState,c===null)return gn(r),null;if(p=(r.flags&128)!==0,y=c.rendering,y===null)if(p)to(c,!1);else{if(En!==0||t!==null&&(t.flags&128)!==0)for(t=r.child;t!==null;){if(y=Nc(t),y!==null){for(r.flags|=128,to(c,!1),t=y.updateQueue,r.updateQueue=t,Ic(r,t),r.subtreeFlags=0,t=s,s=r.child;s!==null;)kp(s,t),s=s.sibling;return T(Nn,Nn.current&1|2),Lt&&Ua(r,c.treeForkCount),r.child}t=t.sibling}c.tail!==null&&Se()>Xc&&(r.flags|=128,p=!0,to(c,!1),r.lanes=4194304)}else{if(!p)if(t=Nc(y),t!==null){if(r.flags|=128,p=!0,t=t.updateQueue,r.updateQueue=t,Ic(r,t),to(c,!0),c.tail===null&&c.tailMode==="hidden"&&!y.alternate&&!Lt)return gn(r),null}else 2*Se()-c.renderingStartTime>Xc&&s!==536870912&&(r.flags|=128,p=!0,to(c,!1),r.lanes=4194304);c.isBackwards?(y.sibling=r.child,r.child=y):(t=c.last,t!==null?t.sibling=y:r.child=y,c.last=y)}return c.tail!==null?(t=c.tail,c.rendering=t,c.tail=t.sibling,c.renderingStartTime=Se(),t.sibling=null,s=Nn.current,T(Nn,p?s&1|2:s&1),Lt&&Ua(r,c.treeForkCount),t):(gn(r),null);case 22:case 23:return Ar(r),Rd(),c=r.memoizedState!==null,t!==null?t.memoizedState!==null!==c&&(r.flags|=8192):c&&(r.flags|=8192),c?(s&536870912)!==0&&(r.flags&128)===0&&(gn(r),r.subtreeFlags&6&&(r.flags|=8192)):gn(r),s=r.updateQueue,s!==null&&Ic(r,s.retryQueue),s=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(s=t.memoizedState.cachePool.pool),c=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(c=r.memoizedState.cachePool.pool),c!==s&&(r.flags|=2048),t!==null&&U(ui),null;case 24:return s=null,t!==null&&(s=t.memoizedState.cache),r.memoizedState.cache!==s&&(r.flags|=2048),Ya(Tn),gn(r),null;case 25:return null;case 30:return null}throw Error(i(156,r.tag))}function h2(t,r){switch(yd(r),r.tag){case 1:return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 3:return Ya(Tn),He(),t=r.flags,(t&65536)!==0&&(t&128)===0?(r.flags=t&-65537|128,r):null;case 26:case 27:case 5:return Je(r),null;case 31:if(r.memoizedState!==null){if(Ar(r),r.alternate===null)throw Error(i(340));si()}return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 13:if(Ar(r),t=r.memoizedState,t!==null&&t.dehydrated!==null){if(r.alternate===null)throw Error(i(340));si()}return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 19:return U(Nn),null;case 4:return He(),null;case 10:return Ya(r.type),null;case 22:case 23:return Ar(r),Rd(),t!==null&&U(ui),t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 24:return Ya(Tn),null;case 25:return null;default:return null}}function Kx(t,r){switch(yd(r),r.tag){case 3:Ya(Tn),He();break;case 26:case 27:case 5:Je(r);break;case 4:He();break;case 31:r.memoizedState!==null&&Ar(r);break;case 13:Ar(r);break;case 19:U(Nn);break;case 10:Ya(r.type);break;case 22:case 23:Ar(r),Rd(),t!==null&&U(ui);break;case 24:Ya(Tn)}}function no(t,r){try{var s=r.updateQueue,c=s!==null?s.lastEffect:null;if(c!==null){var p=c.next;s=p;do{if((s.tag&t)===t){c=void 0;var y=s.create,S=s.inst;c=y(),S.destroy=c}s=s.next}while(s!==p)}}catch(z){Zt(r,r.return,z)}}function El(t,r,s){try{var c=r.updateQueue,p=c!==null?c.lastEffect:null;if(p!==null){var y=p.next;c=y;do{if((c.tag&t)===t){var S=c.inst,z=S.destroy;if(z!==void 0){S.destroy=void 0,p=r;var V=s,le=z;try{le()}catch(xe){Zt(p,V,xe)}}}c=c.next}while(c!==y)}}catch(xe){Zt(r,r.return,xe)}}function Px(t){var r=t.updateQueue;if(r!==null){var s=t.stateNode;try{Ip(r,s)}catch(c){Zt(t,t.return,c)}}}function Qx(t,r,s){s.props=pi(t.type,t.memoizedProps),s.state=t.memoizedState;try{s.componentWillUnmount()}catch(c){Zt(t,r,c)}}function ro(t,r){try{var s=t.ref;if(s!==null){switch(t.tag){case 26:case 27:case 5:var c=t.stateNode;break;case 30:c=t.stateNode;break;default:c=t.stateNode}typeof s=="function"?t.refCleanup=s(c):s.current=c}}catch(p){Zt(t,r,p)}}function ya(t,r){var s=t.ref,c=t.refCleanup;if(s!==null)if(typeof c=="function")try{c()}catch(p){Zt(t,r,p)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof s=="function")try{s(null)}catch(p){Zt(t,r,p)}else s.current=null}function Zx(t){var r=t.type,s=t.memoizedProps,c=t.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":s.autoFocus&&c.focus();break e;case"img":s.src?c.src=s.src:s.srcSet&&(c.srcset=s.srcSet)}}catch(p){Zt(t,t.return,p)}}function ff(t,r,s){try{var c=t.stateNode;_2(c,t.type,s,r),c[mn]=r}catch(p){Zt(t,t.return,p)}}function Jx(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&Rl(t.type)||t.tag===4}function hf(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||Jx(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.tag===27&&Rl(t.type)||t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function mf(t,r,s){var c=t.tag;if(c===5||c===6)t=t.stateNode,r?(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s).insertBefore(t,r):(r=s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,r.appendChild(t),s=s._reactRootContainer,s!=null||r.onclick!==null||(r.onclick=hr));else if(c!==4&&(c===27&&Rl(t.type)&&(s=t.stateNode,r=null),t=t.child,t!==null))for(mf(t,r,s),t=t.sibling;t!==null;)mf(t,r,s),t=t.sibling}function Hc(t,r,s){var c=t.tag;if(c===5||c===6)t=t.stateNode,r?s.insertBefore(t,r):s.appendChild(t);else if(c!==4&&(c===27&&Rl(t.type)&&(s=t.stateNode),t=t.child,t!==null))for(Hc(t,r,s),t=t.sibling;t!==null;)Hc(t,r,s),t=t.sibling}function e1(t){var r=t.stateNode,s=t.memoizedProps;try{for(var c=t.type,p=r.attributes;p.length;)r.removeAttributeNode(p[0]);Jn(r,c,s),r[yn]=t,r[mn]=s}catch(y){Zt(t,t.return,y)}}var Ka=!1,Rn=!1,pf=!1,t1=typeof WeakSet=="function"?WeakSet:Set,Xn=null;function m2(t,r){if(t=t.containerInfo,Bf=ou,t=hp(t),sd(t)){if("selectionStart"in t)var s={start:t.selectionStart,end:t.selectionEnd};else e:{s=(s=t.ownerDocument)&&s.defaultView||window;var c=s.getSelection&&s.getSelection();if(c&&c.rangeCount!==0){s=c.anchorNode;var p=c.anchorOffset,y=c.focusNode;c=c.focusOffset;try{s.nodeType,y.nodeType}catch{s=null;break e}var S=0,z=-1,V=-1,le=0,xe=0,Ce=t,ce=null;t:for(;;){for(var fe;Ce!==s||p!==0&&Ce.nodeType!==3||(z=S+p),Ce!==y||c!==0&&Ce.nodeType!==3||(V=S+c),Ce.nodeType===3&&(S+=Ce.nodeValue.length),(fe=Ce.firstChild)!==null;)ce=Ce,Ce=fe;for(;;){if(Ce===t)break t;if(ce===s&&++le===p&&(z=S),ce===y&&++xe===c&&(V=S),(fe=Ce.nextSibling)!==null)break;Ce=ce,ce=Ce.parentNode}Ce=fe}s=z===-1||V===-1?null:{start:z,end:V}}else s=null}s=s||{start:0,end:0}}else s=null;for(Of={focusedElem:t,selectionRange:s},ou=!1,Xn=r;Xn!==null;)if(r=Xn,t=r.child,(r.subtreeFlags&1028)!==0&&t!==null)t.return=r,Xn=t;else for(;Xn!==null;){switch(r=Xn,y=r.alternate,t=r.flags,r.tag){case 0:if((t&4)!==0&&(t=r.updateQueue,t=t!==null?t.events:null,t!==null))for(s=0;s<t.length;s++)p=t[s],p.ref.impl=p.nextImpl;break;case 11:case 15:break;case 1:if((t&1024)!==0&&y!==null){t=void 0,s=r,p=y.memoizedProps,y=y.memoizedState,c=s.stateNode;try{var Ye=pi(s.type,p);t=c.getSnapshotBeforeUpdate(Ye,y),c.__reactInternalSnapshotBeforeUpdate=t}catch(it){Zt(s,s.return,it)}}break;case 3:if((t&1024)!==0){if(t=r.stateNode.containerInfo,s=t.nodeType,s===9)If(t);else if(s===1)switch(t.nodeName){case"HEAD":case"HTML":case"BODY":If(t);break;default:t.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((t&1024)!==0)throw Error(i(163))}if(t=r.sibling,t!==null){t.return=r.return,Xn=t;break}Xn=r.return}}function n1(t,r,s){var c=s.flags;switch(s.tag){case 0:case 11:case 15:Qa(t,s),c&4&&no(5,s);break;case 1:if(Qa(t,s),c&4)if(t=s.stateNode,r===null)try{t.componentDidMount()}catch(S){Zt(s,s.return,S)}else{var p=pi(s.type,r.memoizedProps);r=r.memoizedState;try{t.componentDidUpdate(p,r,t.__reactInternalSnapshotBeforeUpdate)}catch(S){Zt(s,s.return,S)}}c&64&&Px(s),c&512&&ro(s,s.return);break;case 3:if(Qa(t,s),c&64&&(t=s.updateQueue,t!==null)){if(r=null,s.child!==null)switch(s.child.tag){case 27:case 5:r=s.child.stateNode;break;case 1:r=s.child.stateNode}try{Ip(t,r)}catch(S){Zt(s,s.return,S)}}break;case 27:r===null&&c&4&&e1(s);case 26:case 5:Qa(t,s),r===null&&c&4&&Zx(s),c&512&&ro(s,s.return);break;case 12:Qa(t,s);break;case 31:Qa(t,s),c&4&&l1(t,s);break;case 13:Qa(t,s),c&4&&i1(t,s),c&64&&(t=s.memoizedState,t!==null&&(t=t.dehydrated,t!==null&&(s=j2.bind(null,s),q2(t,s))));break;case 22:if(c=s.memoizedState!==null||Ka,!c){r=r!==null&&r.memoizedState!==null||Rn,p=Ka;var y=Rn;Ka=c,(Rn=r)&&!y?Za(t,s,(s.subtreeFlags&8772)!==0):Qa(t,s),Ka=p,Rn=y}break;case 30:break;default:Qa(t,s)}}function r1(t){var r=t.alternate;r!==null&&(t.alternate=null,r1(r)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(r=t.stateNode,r!==null&&Ts(r)),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}var bn=null,pr=!1;function Pa(t,r,s){for(s=s.child;s!==null;)a1(t,r,s),s=s.sibling}function a1(t,r,s){if(qe&&typeof qe.onCommitFiberUnmount=="function")try{qe.onCommitFiberUnmount(Be,s)}catch{}switch(s.tag){case 26:Rn||ya(s,r),Pa(t,r,s),s.memoizedState?s.memoizedState.count--:s.stateNode&&(s=s.stateNode,s.parentNode.removeChild(s));break;case 27:Rn||ya(s,r);var c=bn,p=pr;Rl(s.type)&&(bn=s.stateNode,pr=!1),Pa(t,r,s),ho(s.stateNode),bn=c,pr=p;break;case 5:Rn||ya(s,r);case 6:if(c=bn,p=pr,bn=null,Pa(t,r,s),bn=c,pr=p,bn!==null)if(pr)try{(bn.nodeType===9?bn.body:bn.nodeName==="HTML"?bn.ownerDocument.body:bn).removeChild(s.stateNode)}catch(y){Zt(s,r,y)}else try{bn.removeChild(s.stateNode)}catch(y){Zt(s,r,y)}break;case 18:bn!==null&&(pr?(t=bn,P1(t.nodeType===9?t.body:t.nodeName==="HTML"?t.ownerDocument.body:t,s.stateNode),fs(t)):P1(bn,s.stateNode));break;case 4:c=bn,p=pr,bn=s.stateNode.containerInfo,pr=!0,Pa(t,r,s),bn=c,pr=p;break;case 0:case 11:case 14:case 15:El(2,s,r),Rn||El(4,s,r),Pa(t,r,s);break;case 1:Rn||(ya(s,r),c=s.stateNode,typeof c.componentWillUnmount=="function"&&Qx(s,r,c)),Pa(t,r,s);break;case 21:Pa(t,r,s);break;case 22:Rn=(c=Rn)||s.memoizedState!==null,Pa(t,r,s),Rn=c;break;default:Pa(t,r,s)}}function l1(t,r){if(r.memoizedState===null&&(t=r.alternate,t!==null&&(t=t.memoizedState,t!==null))){t=t.dehydrated;try{fs(t)}catch(s){Zt(r,r.return,s)}}}function i1(t,r){if(r.memoizedState===null&&(t=r.alternate,t!==null&&(t=t.memoizedState,t!==null&&(t=t.dehydrated,t!==null))))try{fs(t)}catch(s){Zt(r,r.return,s)}}function p2(t){switch(t.tag){case 31:case 13:case 19:var r=t.stateNode;return r===null&&(r=t.stateNode=new t1),r;case 22:return t=t.stateNode,r=t._retryCache,r===null&&(r=t._retryCache=new t1),r;default:throw Error(i(435,t.tag))}}function Uc(t,r){var s=p2(t);r.forEach(function(c){if(!s.has(c)){s.add(c);var p=S2.bind(null,t,c);c.then(p,p)}})}function xr(t,r){var s=r.deletions;if(s!==null)for(var c=0;c<s.length;c++){var p=s[c],y=t,S=r,z=S;e:for(;z!==null;){switch(z.tag){case 27:if(Rl(z.type)){bn=z.stateNode,pr=!1;break e}break;case 5:bn=z.stateNode,pr=!1;break e;case 3:case 4:bn=z.stateNode.containerInfo,pr=!0;break e}z=z.return}if(bn===null)throw Error(i(160));a1(y,S,p),bn=null,pr=!1,y=p.alternate,y!==null&&(y.return=null),p.return=null}if(r.subtreeFlags&13886)for(r=r.child;r!==null;)s1(r,t),r=r.sibling}var aa=null;function s1(t,r){var s=t.alternate,c=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:xr(r,t),gr(t),c&4&&(El(3,t,t.return),no(3,t),El(5,t,t.return));break;case 1:xr(r,t),gr(t),c&512&&(Rn||s===null||ya(s,s.return)),c&64&&Ka&&(t=t.updateQueue,t!==null&&(c=t.callbacks,c!==null&&(s=t.shared.hiddenCallbacks,t.shared.hiddenCallbacks=s===null?c:s.concat(c))));break;case 26:var p=aa;if(xr(r,t),gr(t),c&512&&(Rn||s===null||ya(s,s.return)),c&4){var y=s!==null?s.memoizedState:null;if(c=t.memoizedState,s===null)if(c===null)if(t.stateNode===null){e:{c=t.type,s=t.memoizedProps,p=p.ownerDocument||p;t:switch(c){case"title":y=p.getElementsByTagName("title")[0],(!y||y[Fa]||y[yn]||y.namespaceURI==="http://www.w3.org/2000/svg"||y.hasAttribute("itemprop"))&&(y=p.createElement(c),p.head.insertBefore(y,p.querySelector("head > title"))),Jn(y,c,s),y[yn]=t,Dn(y),c=y;break e;case"link":var S=s0("link","href",p).get(c+(s.href||""));if(S){for(var z=0;z<S.length;z++)if(y=S[z],y.getAttribute("href")===(s.href==null||s.href===""?null:s.href)&&y.getAttribute("rel")===(s.rel==null?null:s.rel)&&y.getAttribute("title")===(s.title==null?null:s.title)&&y.getAttribute("crossorigin")===(s.crossOrigin==null?null:s.crossOrigin)){S.splice(z,1);break t}}y=p.createElement(c),Jn(y,c,s),p.head.appendChild(y);break;case"meta":if(S=s0("meta","content",p).get(c+(s.content||""))){for(z=0;z<S.length;z++)if(y=S[z],y.getAttribute("content")===(s.content==null?null:""+s.content)&&y.getAttribute("name")===(s.name==null?null:s.name)&&y.getAttribute("property")===(s.property==null?null:s.property)&&y.getAttribute("http-equiv")===(s.httpEquiv==null?null:s.httpEquiv)&&y.getAttribute("charset")===(s.charSet==null?null:s.charSet)){S.splice(z,1);break t}}y=p.createElement(c),Jn(y,c,s),p.head.appendChild(y);break;default:throw Error(i(468,c))}y[yn]=t,Dn(y),c=y}t.stateNode=c}else o0(p,t.type,t.stateNode);else t.stateNode=i0(p,c,t.memoizedProps);else y!==c?(y===null?s.stateNode!==null&&(s=s.stateNode,s.parentNode.removeChild(s)):y.count--,c===null?o0(p,t.type,t.stateNode):i0(p,c,t.memoizedProps)):c===null&&t.stateNode!==null&&ff(t,t.memoizedProps,s.memoizedProps)}break;case 27:xr(r,t),gr(t),c&512&&(Rn||s===null||ya(s,s.return)),s!==null&&c&4&&ff(t,t.memoizedProps,s.memoizedProps);break;case 5:if(xr(r,t),gr(t),c&512&&(Rn||s===null||ya(s,s.return)),t.flags&32){p=t.stateNode;try{ul(p,"")}catch(Ye){Zt(t,t.return,Ye)}}c&4&&t.stateNode!=null&&(p=t.memoizedProps,ff(t,p,s!==null?s.memoizedProps:p)),c&1024&&(pf=!0);break;case 6:if(xr(r,t),gr(t),c&4){if(t.stateNode===null)throw Error(i(162));c=t.memoizedProps,s=t.stateNode;try{s.nodeValue=c}catch(Ye){Zt(t,t.return,Ye)}}break;case 3:if(au=null,p=aa,aa=nu(r.containerInfo),xr(r,t),aa=p,gr(t),c&4&&s!==null&&s.memoizedState.isDehydrated)try{fs(r.containerInfo)}catch(Ye){Zt(t,t.return,Ye)}pf&&(pf=!1,o1(t));break;case 4:c=aa,aa=nu(t.stateNode.containerInfo),xr(r,t),gr(t),aa=c;break;case 12:xr(r,t),gr(t);break;case 31:xr(r,t),gr(t),c&4&&(c=t.updateQueue,c!==null&&(t.updateQueue=null,Uc(t,c)));break;case 13:xr(r,t),gr(t),t.child.flags&8192&&t.memoizedState!==null!=(s!==null&&s.memoizedState!==null)&&(Yc=Se()),c&4&&(c=t.updateQueue,c!==null&&(t.updateQueue=null,Uc(t,c)));break;case 22:p=t.memoizedState!==null;var V=s!==null&&s.memoizedState!==null,le=Ka,xe=Rn;if(Ka=le||p,Rn=xe||V,xr(r,t),Rn=xe,Ka=le,gr(t),c&8192)e:for(r=t.stateNode,r._visibility=p?r._visibility&-2:r._visibility|1,p&&(s===null||V||Ka||Rn||xi(t)),s=null,r=t;;){if(r.tag===5||r.tag===26){if(s===null){V=s=r;try{if(y=V.stateNode,p)S=y.style,typeof S.setProperty=="function"?S.setProperty("display","none","important"):S.display="none";else{z=V.stateNode;var Ce=V.memoizedProps.style,ce=Ce!=null&&Ce.hasOwnProperty("display")?Ce.display:null;z.style.display=ce==null||typeof ce=="boolean"?"":(""+ce).trim()}}catch(Ye){Zt(V,V.return,Ye)}}}else if(r.tag===6){if(s===null){V=r;try{V.stateNode.nodeValue=p?"":V.memoizedProps}catch(Ye){Zt(V,V.return,Ye)}}}else if(r.tag===18){if(s===null){V=r;try{var fe=V.stateNode;p?Q1(fe,!0):Q1(V.stateNode,!1)}catch(Ye){Zt(V,V.return,Ye)}}}else if((r.tag!==22&&r.tag!==23||r.memoizedState===null||r===t)&&r.child!==null){r.child.return=r,r=r.child;continue}if(r===t)break e;for(;r.sibling===null;){if(r.return===null||r.return===t)break e;s===r&&(s=null),r=r.return}s===r&&(s=null),r.sibling.return=r.return,r=r.sibling}c&4&&(c=t.updateQueue,c!==null&&(s=c.retryQueue,s!==null&&(c.retryQueue=null,Uc(t,s))));break;case 19:xr(r,t),gr(t),c&4&&(c=t.updateQueue,c!==null&&(t.updateQueue=null,Uc(t,c)));break;case 30:break;case 21:break;default:xr(r,t),gr(t)}}function gr(t){var r=t.flags;if(r&2){try{for(var s,c=t.return;c!==null;){if(Jx(c)){s=c;break}c=c.return}if(s==null)throw Error(i(160));switch(s.tag){case 27:var p=s.stateNode,y=hf(t);Hc(t,y,p);break;case 5:var S=s.stateNode;s.flags&32&&(ul(S,""),s.flags&=-33);var z=hf(t);Hc(t,z,S);break;case 3:case 4:var V=s.stateNode.containerInfo,le=hf(t);mf(t,le,V);break;default:throw Error(i(161))}}catch(xe){Zt(t,t.return,xe)}t.flags&=-3}r&4096&&(t.flags&=-4097)}function o1(t){if(t.subtreeFlags&1024)for(t=t.child;t!==null;){var r=t;o1(r),r.tag===5&&r.flags&1024&&r.stateNode.reset(),t=t.sibling}}function Qa(t,r){if(r.subtreeFlags&8772)for(r=r.child;r!==null;)n1(t,r.alternate,r),r=r.sibling}function xi(t){for(t=t.child;t!==null;){var r=t;switch(r.tag){case 0:case 11:case 14:case 15:El(4,r,r.return),xi(r);break;case 1:ya(r,r.return);var s=r.stateNode;typeof s.componentWillUnmount=="function"&&Qx(r,r.return,s),xi(r);break;case 27:ho(r.stateNode);case 26:case 5:ya(r,r.return),xi(r);break;case 22:r.memoizedState===null&&xi(r);break;case 30:xi(r);break;default:xi(r)}t=t.sibling}}function Za(t,r,s){for(s=s&&(r.subtreeFlags&8772)!==0,r=r.child;r!==null;){var c=r.alternate,p=t,y=r,S=y.flags;switch(y.tag){case 0:case 11:case 15:Za(p,y,s),no(4,y);break;case 1:if(Za(p,y,s),c=y,p=c.stateNode,typeof p.componentDidMount=="function")try{p.componentDidMount()}catch(le){Zt(c,c.return,le)}if(c=y,p=c.updateQueue,p!==null){var z=c.stateNode;try{var V=p.shared.hiddenCallbacks;if(V!==null)for(p.shared.hiddenCallbacks=null,p=0;p<V.length;p++)Lp(V[p],z)}catch(le){Zt(c,c.return,le)}}s&&S&64&&Px(y),ro(y,y.return);break;case 27:e1(y);case 26:case 5:Za(p,y,s),s&&c===null&&S&4&&Zx(y),ro(y,y.return);break;case 12:Za(p,y,s);break;case 31:Za(p,y,s),s&&S&4&&l1(p,y);break;case 13:Za(p,y,s),s&&S&4&&i1(p,y);break;case 22:y.memoizedState===null&&Za(p,y,s),ro(y,y.return);break;case 30:break;default:Za(p,y,s)}r=r.sibling}}function xf(t,r){var s=null;t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(s=t.memoizedState.cachePool.pool),t=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(t=r.memoizedState.cachePool.pool),t!==s&&(t!=null&&t.refCount++,s!=null&&qs(s))}function gf(t,r){t=null,r.alternate!==null&&(t=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==t&&(r.refCount++,t!=null&&qs(t))}function la(t,r,s,c){if(r.subtreeFlags&10256)for(r=r.child;r!==null;)c1(t,r,s,c),r=r.sibling}function c1(t,r,s,c){var p=r.flags;switch(r.tag){case 0:case 11:case 15:la(t,r,s,c),p&2048&&no(9,r);break;case 1:la(t,r,s,c);break;case 3:la(t,r,s,c),p&2048&&(t=null,r.alternate!==null&&(t=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==t&&(r.refCount++,t!=null&&qs(t)));break;case 12:if(p&2048){la(t,r,s,c),t=r.stateNode;try{var y=r.memoizedProps,S=y.id,z=y.onPostCommit;typeof z=="function"&&z(S,r.alternate===null?"mount":"update",t.passiveEffectDuration,-0)}catch(V){Zt(r,r.return,V)}}else la(t,r,s,c);break;case 31:la(t,r,s,c);break;case 13:la(t,r,s,c);break;case 23:break;case 22:y=r.stateNode,S=r.alternate,r.memoizedState!==null?y._visibility&2?la(t,r,s,c):ao(t,r):y._visibility&2?la(t,r,s,c):(y._visibility|=2,ts(t,r,s,c,(r.subtreeFlags&10256)!==0||!1)),p&2048&&xf(S,r);break;case 24:la(t,r,s,c),p&2048&&gf(r.alternate,r);break;default:la(t,r,s,c)}}function ts(t,r,s,c,p){for(p=p&&((r.subtreeFlags&10256)!==0||!1),r=r.child;r!==null;){var y=t,S=r,z=s,V=c,le=S.flags;switch(S.tag){case 0:case 11:case 15:ts(y,S,z,V,p),no(8,S);break;case 23:break;case 22:var xe=S.stateNode;S.memoizedState!==null?xe._visibility&2?ts(y,S,z,V,p):ao(y,S):(xe._visibility|=2,ts(y,S,z,V,p)),p&&le&2048&&xf(S.alternate,S);break;case 24:ts(y,S,z,V,p),p&&le&2048&&gf(S.alternate,S);break;default:ts(y,S,z,V,p)}r=r.sibling}}function ao(t,r){if(r.subtreeFlags&10256)for(r=r.child;r!==null;){var s=t,c=r,p=c.flags;switch(c.tag){case 22:ao(s,c),p&2048&&xf(c.alternate,c);break;case 24:ao(s,c),p&2048&&gf(c.alternate,c);break;default:ao(s,c)}r=r.sibling}}var lo=8192;function ns(t,r,s){if(t.subtreeFlags&lo)for(t=t.child;t!==null;)u1(t,r,s),t=t.sibling}function u1(t,r,s){switch(t.tag){case 26:ns(t,r,s),t.flags&lo&&t.memoizedState!==null&&tw(s,aa,t.memoizedState,t.memoizedProps);break;case 5:ns(t,r,s);break;case 3:case 4:var c=aa;aa=nu(t.stateNode.containerInfo),ns(t,r,s),aa=c;break;case 22:t.memoizedState===null&&(c=t.alternate,c!==null&&c.memoizedState!==null?(c=lo,lo=16777216,ns(t,r,s),lo=c):ns(t,r,s));break;default:ns(t,r,s)}}function d1(t){var r=t.alternate;if(r!==null&&(t=r.child,t!==null)){r.child=null;do r=t.sibling,t.sibling=null,t=r;while(t!==null)}}function io(t){var r=t.deletions;if((t.flags&16)!==0){if(r!==null)for(var s=0;s<r.length;s++){var c=r[s];Xn=c,h1(c,t)}d1(t)}if(t.subtreeFlags&10256)for(t=t.child;t!==null;)f1(t),t=t.sibling}function f1(t){switch(t.tag){case 0:case 11:case 15:io(t),t.flags&2048&&El(9,t,t.return);break;case 3:io(t);break;case 12:io(t);break;case 22:var r=t.stateNode;t.memoizedState!==null&&r._visibility&2&&(t.return===null||t.return.tag!==13)?(r._visibility&=-3,qc(t)):io(t);break;default:io(t)}}function qc(t){var r=t.deletions;if((t.flags&16)!==0){if(r!==null)for(var s=0;s<r.length;s++){var c=r[s];Xn=c,h1(c,t)}d1(t)}for(t=t.child;t!==null;){switch(r=t,r.tag){case 0:case 11:case 15:El(8,r,r.return),qc(r);break;case 22:s=r.stateNode,s._visibility&2&&(s._visibility&=-3,qc(r));break;default:qc(r)}t=t.sibling}}function h1(t,r){for(;Xn!==null;){var s=Xn;switch(s.tag){case 0:case 11:case 15:El(8,s,r);break;case 23:case 22:if(s.memoizedState!==null&&s.memoizedState.cachePool!==null){var c=s.memoizedState.cachePool.pool;c!=null&&c.refCount++}break;case 24:qs(s.memoizedState.cache)}if(c=s.child,c!==null)c.return=s,Xn=c;else e:for(s=t;Xn!==null;){c=Xn;var p=c.sibling,y=c.return;if(r1(c),c===s){Xn=null;break e}if(p!==null){p.return=y,Xn=p;break e}Xn=y}}}var x2={getCacheForType:function(t){var r=Qn(Tn),s=r.data.get(t);return s===void 0&&(s=t(),r.data.set(t,s)),s},cacheSignal:function(){return Qn(Tn).controller.signal}},g2=typeof WeakMap=="function"?WeakMap:Map,Vt=0,sn=null,Nt=null,Mt=0,Qt=0,Dr=null,Nl=!1,rs=!1,yf=!1,Ja=0,En=0,Al=0,gi=0,bf=0,Tr=0,as=0,so=null,yr=null,vf=!1,Yc=0,m1=0,Xc=1/0,Wc=null,Dl=null,On=0,Tl=null,ls=null,el=0,wf=0,kf=null,p1=null,oo=0,jf=null;function Fr(){return(Vt&2)!==0&&Mt!==0?Mt&-Mt:Y.T!==null?Df():Pe()}function x1(){if(Tr===0)if((Mt&536870912)===0||Lt){var t=Bt;Bt<<=1,(Bt&3932160)===0&&(Bt=262144),Tr=t}else Tr=536870912;return t=Nr.current,t!==null&&(t.flags|=32),Tr}function br(t,r,s){(t===sn&&(Qt===2||Qt===9)||t.cancelPendingCommit!==null)&&(is(t,0),Fl(t,Mt,Tr,!1)),ke(t,s),((Vt&2)===0||t!==sn)&&(t===sn&&((Vt&2)===0&&(gi|=s),En===4&&Fl(t,Mt,Tr,!1)),ba(t))}function g1(t,r,s){if((Vt&6)!==0)throw Error(i(327));var c=!s&&(r&127)===0&&(r&t.expiredLanes)===0||J(t,r),p=c?v2(t,r):Cf(t,r,!0),y=c;do{if(p===0){rs&&!c&&Fl(t,r,0,!1);break}else{if(s=t.current.alternate,y&&!y2(s)){p=Cf(t,r,!1),y=!1;continue}if(p===2){if(y=r,t.errorRecoveryDisabledLanes&y)var S=0;else S=t.pendingLanes&-536870913,S=S!==0?S:S&536870912?536870912:0;if(S!==0){r=S;e:{var z=t;p=so;var V=z.current.memoizedState.isDehydrated;if(V&&(is(z,S).flags|=256),S=Cf(z,S,!1),S!==2){if(yf&&!V){z.errorRecoveryDisabledLanes|=y,gi|=y,p=4;break e}y=yr,yr=p,y!==null&&(yr===null?yr=y:yr.push.apply(yr,y))}p=S}if(y=!1,p!==2)continue}}if(p===1){is(t,0),Fl(t,r,0,!0);break}e:{switch(c=t,y=p,y){case 0:case 1:throw Error(i(345));case 4:if((r&4194048)!==r)break;case 6:Fl(c,r,Tr,!Nl);break e;case 2:yr=null;break;case 3:case 5:break;default:throw Error(i(329))}if((r&62914560)===r&&(p=Yc+300-Se(),10<p)){if(Fl(c,r,Tr,!Nl),kn(c,0,!0)!==0)break e;el=r,c.timeoutHandle=G1(y1.bind(null,c,s,yr,Wc,vf,r,Tr,gi,as,Nl,y,"Throttled",-0,0),p);break e}y1(c,s,yr,Wc,vf,r,Tr,gi,as,Nl,y,null,-0,0)}}break}while(!0);ba(t)}function y1(t,r,s,c,p,y,S,z,V,le,xe,Ce,ce,fe){if(t.timeoutHandle=-1,Ce=r.subtreeFlags,Ce&8192||(Ce&16785408)===16785408){Ce={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:hr},u1(r,y,Ce);var Ye=(y&62914560)===y?Yc-Se():(y&4194048)===y?m1-Se():0;if(Ye=nw(Ce,Ye),Ye!==null){el=y,t.cancelPendingCommit=Ye(E1.bind(null,t,r,y,s,c,p,S,z,V,xe,Ce,null,ce,fe)),Fl(t,y,S,!le);return}}E1(t,r,y,s,c,p,S,z,V)}function y2(t){for(var r=t;;){var s=r.tag;if((s===0||s===11||s===15)&&r.flags&16384&&(s=r.updateQueue,s!==null&&(s=s.stores,s!==null)))for(var c=0;c<s.length;c++){var p=s[c],y=p.getSnapshot;p=p.value;try{if(!Cr(y(),p))return!1}catch{return!1}}if(s=r.child,r.subtreeFlags&16384&&s!==null)s.return=r,r=s;else{if(r===t)break;for(;r.sibling===null;){if(r.return===null||r.return===t)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function Fl(t,r,s,c){r&=~bf,r&=~gi,t.suspendedLanes|=r,t.pingedLanes&=~r,c&&(t.warmLanes|=r),c=t.expirationTimes;for(var p=r;0<p;){var y=31-Ke(p),S=1<<y;c[y]=-1,p&=~S}s!==0&&jn(t,s,r)}function Vc(){return(Vt&6)===0?(co(0),!1):!0}function Sf(){if(Nt!==null){if(Qt===0)var t=Nt.return;else t=Nt,qa=oi=null,Ld(t),Pi=null,Xs=0,t=Nt;for(;t!==null;)Kx(t.alternate,t),t=t.return;Nt=null}}function is(t,r){var s=t.timeoutHandle;s!==-1&&(t.timeoutHandle=-1,$2(s)),s=t.cancelPendingCommit,s!==null&&(t.cancelPendingCommit=null,s()),el=0,Sf(),sn=t,Nt=s=Ha(t.current,null),Mt=r,Qt=0,Dr=null,Nl=!1,rs=J(t,r),yf=!1,as=Tr=bf=gi=Al=En=0,yr=so=null,vf=!1,(r&8)!==0&&(r|=r&32);var c=t.entangledLanes;if(c!==0)for(t=t.entanglements,c&=r;0<c;){var p=31-Ke(c),y=1<<p;r|=t[p],c&=~y}return Ja=r,mc(),s}function b1(t,r){gt=null,Y.H=Js,r===Ki||r===kc?(r=_p(),Qt=3):r===Nd?(r=_p(),Qt=4):Qt=r===tf?8:r!==null&&typeof r=="object"&&typeof r.then=="function"?6:1,Dr=r,Nt===null&&(En=1,Bc(t,qr(r,t.current)))}function v1(){var t=Nr.current;return t===null?!0:(Mt&4194048)===Mt?Vr===null:(Mt&62914560)===Mt||(Mt&536870912)!==0?t===Vr:!1}function w1(){var t=Y.H;return Y.H=Js,t===null?Js:t}function k1(){var t=Y.A;return Y.A=x2,t}function Gc(){En=4,Nl||(Mt&4194048)!==Mt&&Nr.current!==null||(rs=!0),(Al&134217727)===0&&(gi&134217727)===0||sn===null||Fl(sn,Mt,Tr,!1)}function Cf(t,r,s){var c=Vt;Vt|=2;var p=w1(),y=k1();(sn!==t||Mt!==r)&&(Wc=null,is(t,r)),r=!1;var S=En;e:do try{if(Qt!==0&&Nt!==null){var z=Nt,V=Dr;switch(Qt){case 8:Sf(),S=6;break e;case 3:case 2:case 9:case 6:Nr.current===null&&(r=!0);var le=Qt;if(Qt=0,Dr=null,ss(t,z,V,le),s&&rs){S=0;break e}break;default:le=Qt,Qt=0,Dr=null,ss(t,z,V,le)}}b2(),S=En;break}catch(xe){b1(t,xe)}while(!0);return r&&t.shellSuspendCounter++,qa=oi=null,Vt=c,Y.H=p,Y.A=y,Nt===null&&(sn=null,Mt=0,mc()),S}function b2(){for(;Nt!==null;)j1(Nt)}function v2(t,r){var s=Vt;Vt|=2;var c=w1(),p=k1();sn!==t||Mt!==r?(Wc=null,Xc=Se()+500,is(t,r)):rs=J(t,r);e:do try{if(Qt!==0&&Nt!==null){r=Nt;var y=Dr;t:switch(Qt){case 1:Qt=0,Dr=null,ss(t,r,y,1);break;case 2:case 9:if(Rp(y)){Qt=0,Dr=null,S1(r);break}r=function(){Qt!==2&&Qt!==9||sn!==t||(Qt=7),ba(t)},y.then(r,r);break e;case 3:Qt=7;break e;case 4:Qt=5;break e;case 7:Rp(y)?(Qt=0,Dr=null,S1(r)):(Qt=0,Dr=null,ss(t,r,y,7));break;case 5:var S=null;switch(Nt.tag){case 26:S=Nt.memoizedState;case 5:case 27:var z=Nt;if(S?c0(S):z.stateNode.complete){Qt=0,Dr=null;var V=z.sibling;if(V!==null)Nt=V;else{var le=z.return;le!==null?(Nt=le,Kc(le)):Nt=null}break t}}Qt=0,Dr=null,ss(t,r,y,5);break;case 6:Qt=0,Dr=null,ss(t,r,y,6);break;case 8:Sf(),En=6;break e;default:throw Error(i(462))}}w2();break}catch(xe){b1(t,xe)}while(!0);return qa=oi=null,Y.H=c,Y.A=p,Vt=s,Nt!==null?0:(sn=null,Mt=0,mc(),En)}function w2(){for(;Nt!==null&&!Bn();)j1(Nt)}function j1(t){var r=Vx(t.alternate,t,Ja);t.memoizedProps=t.pendingProps,r===null?Kc(t):Nt=r}function S1(t){var r=t,s=r.alternate;switch(r.tag){case 15:case 0:r=Hx(s,r,r.pendingProps,r.type,void 0,Mt);break;case 11:r=Hx(s,r,r.pendingProps,r.type.render,r.ref,Mt);break;case 5:Ld(r);default:Kx(s,r),r=Nt=kp(r,Ja),r=Vx(s,r,Ja)}t.memoizedProps=t.pendingProps,r===null?Kc(t):Nt=r}function ss(t,r,s,c){qa=oi=null,Ld(r),Pi=null,Xs=0;var p=r.return;try{if(c2(t,p,r,s,Mt)){En=1,Bc(t,qr(s,t.current)),Nt=null;return}}catch(y){if(p!==null)throw Nt=p,y;En=1,Bc(t,qr(s,t.current)),Nt=null;return}r.flags&32768?(Lt||c===1?t=!0:rs||(Mt&536870912)!==0?t=!1:(Nl=t=!0,(c===2||c===9||c===3||c===6)&&(c=Nr.current,c!==null&&c.tag===13&&(c.flags|=16384))),C1(r,t)):Kc(r)}function Kc(t){var r=t;do{if((r.flags&32768)!==0){C1(r,Nl);return}t=r.return;var s=f2(r.alternate,r,Ja);if(s!==null){Nt=s;return}if(r=r.sibling,r!==null){Nt=r;return}Nt=r=t}while(r!==null);En===0&&(En=5)}function C1(t,r){do{var s=h2(t.alternate,t);if(s!==null){s.flags&=32767,Nt=s;return}if(s=t.return,s!==null&&(s.flags|=32768,s.subtreeFlags=0,s.deletions=null),!r&&(t=t.sibling,t!==null)){Nt=t;return}Nt=t=s}while(t!==null);En=6,Nt=null}function E1(t,r,s,c,p,y,S,z,V){t.cancelPendingCommit=null;do Pc();while(On!==0);if((Vt&6)!==0)throw Error(i(327));if(r!==null){if(r===t.current)throw Error(i(177));if(y=r.lanes|r.childLanes,y|=fd,kt(t,s,y,S,z,V),t===sn&&(Nt=sn=null,Mt=0),ls=r,Tl=t,el=s,wf=y,kf=p,p1=c,(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?(t.callbackNode=null,t.callbackPriority=0,C2(ne,function(){return F1(),null})):(t.callbackNode=null,t.callbackPriority=0),c=(r.flags&13878)!==0,(r.subtreeFlags&13878)!==0||c){c=Y.T,Y.T=null,p=oe.p,oe.p=2,S=Vt,Vt|=4;try{m2(t,r,s)}finally{Vt=S,oe.p=p,Y.T=c}}On=1,N1(),A1(),D1()}}function N1(){if(On===1){On=0;var t=Tl,r=ls,s=(r.flags&13878)!==0;if((r.subtreeFlags&13878)!==0||s){s=Y.T,Y.T=null;var c=oe.p;oe.p=2;var p=Vt;Vt|=4;try{s1(r,t);var y=Of,S=hp(t.containerInfo),z=y.focusedElem,V=y.selectionRange;if(S!==z&&z&&z.ownerDocument&&fp(z.ownerDocument.documentElement,z)){if(V!==null&&sd(z)){var le=V.start,xe=V.end;if(xe===void 0&&(xe=le),"selectionStart"in z)z.selectionStart=le,z.selectionEnd=Math.min(xe,z.value.length);else{var Ce=z.ownerDocument||document,ce=Ce&&Ce.defaultView||window;if(ce.getSelection){var fe=ce.getSelection(),Ye=z.textContent.length,it=Math.min(V.start,Ye),nn=V.end===void 0?it:Math.min(V.end,Ye);!fe.extend&&it>nn&&(S=nn,nn=it,it=S);var ee=dp(z,it),Z=dp(z,nn);if(ee&&Z&&(fe.rangeCount!==1||fe.anchorNode!==ee.node||fe.anchorOffset!==ee.offset||fe.focusNode!==Z.node||fe.focusOffset!==Z.offset)){var ae=Ce.createRange();ae.setStart(ee.node,ee.offset),fe.removeAllRanges(),it>nn?(fe.addRange(ae),fe.extend(Z.node,Z.offset)):(ae.setEnd(Z.node,Z.offset),fe.addRange(ae))}}}}for(Ce=[],fe=z;fe=fe.parentNode;)fe.nodeType===1&&Ce.push({element:fe,left:fe.scrollLeft,top:fe.scrollTop});for(typeof z.focus=="function"&&z.focus(),z=0;z<Ce.length;z++){var be=Ce[z];be.element.scrollLeft=be.left,be.element.scrollTop=be.top}}ou=!!Bf,Of=Bf=null}finally{Vt=p,oe.p=c,Y.T=s}}t.current=r,On=2}}function A1(){if(On===2){On=0;var t=Tl,r=ls,s=(r.flags&8772)!==0;if((r.subtreeFlags&8772)!==0||s){s=Y.T,Y.T=null;var c=oe.p;oe.p=2;var p=Vt;Vt|=4;try{n1(t,r.alternate,r)}finally{Vt=p,oe.p=c,Y.T=s}}On=3}}function D1(){if(On===4||On===3){On=0,me();var t=Tl,r=ls,s=el,c=p1;(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?On=5:(On=0,ls=Tl=null,T1(t,t.pendingLanes));var p=t.pendingLanes;if(p===0&&(Dl=null),We(s),r=r.stateNode,qe&&typeof qe.onCommitFiberRoot=="function")try{qe.onCommitFiberRoot(Be,r,void 0,(r.current.flags&128)===128)}catch{}if(c!==null){r=Y.T,p=oe.p,oe.p=2,Y.T=null;try{for(var y=t.onRecoverableError,S=0;S<c.length;S++){var z=c[S];y(z.value,{componentStack:z.stack})}}finally{Y.T=r,oe.p=p}}(el&3)!==0&&Pc(),ba(t),p=t.pendingLanes,(s&261930)!==0&&(p&42)!==0?t===jf?oo++:(oo=0,jf=t):oo=0,co(0)}}function T1(t,r){(t.pooledCacheLanes&=r)===0&&(r=t.pooledCache,r!=null&&(t.pooledCache=null,qs(r)))}function Pc(){return N1(),A1(),D1(),F1()}function F1(){if(On!==5)return!1;var t=Tl,r=wf;wf=0;var s=We(el),c=Y.T,p=oe.p;try{oe.p=32>s?32:s,Y.T=null,s=kf,kf=null;var y=Tl,S=el;if(On=0,ls=Tl=null,el=0,(Vt&6)!==0)throw Error(i(331));var z=Vt;if(Vt|=4,f1(y.current),c1(y,y.current,S,s),Vt=z,co(0,!1),qe&&typeof qe.onPostCommitFiberRoot=="function")try{qe.onPostCommitFiberRoot(Be,y)}catch{}return!0}finally{oe.p=p,Y.T=c,T1(t,r)}}function M1(t,r,s){r=qr(s,r),r=ef(t.stateNode,r,2),t=jl(t,r,2),t!==null&&(ke(t,2),ba(t))}function Zt(t,r,s){if(t.tag===3)M1(t,t,s);else for(;r!==null;){if(r.tag===3){M1(r,t,s);break}else if(r.tag===1){var c=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(Dl===null||!Dl.has(c))){t=qr(s,t),s=Rx(2),c=jl(r,s,2),c!==null&&(zx(s,c,r,t),ke(c,2),ba(c));break}}r=r.return}}function Ef(t,r,s){var c=t.pingCache;if(c===null){c=t.pingCache=new g2;var p=new Set;c.set(r,p)}else p=c.get(r),p===void 0&&(p=new Set,c.set(r,p));p.has(s)||(yf=!0,p.add(s),t=k2.bind(null,t,r,s),r.then(t,t))}function k2(t,r,s){var c=t.pingCache;c!==null&&c.delete(r),t.pingedLanes|=t.suspendedLanes&s,t.warmLanes&=~s,sn===t&&(Mt&s)===s&&(En===4||En===3&&(Mt&62914560)===Mt&&300>Se()-Yc?(Vt&2)===0&&is(t,0):bf|=s,as===Mt&&(as=0)),ba(t)}function R1(t,r){r===0&&(r=rt()),t=li(t,r),t!==null&&(ke(t,r),ba(t))}function j2(t){var r=t.memoizedState,s=0;r!==null&&(s=r.retryLane),R1(t,s)}function S2(t,r){var s=0;switch(t.tag){case 31:case 13:var c=t.stateNode,p=t.memoizedState;p!==null&&(s=p.retryLane);break;case 19:c=t.stateNode;break;case 22:c=t.stateNode._retryCache;break;default:throw Error(i(314))}c!==null&&c.delete(r),R1(t,s)}function C2(t,r){return Tt(t,r)}var Qc=null,os=null,Nf=!1,Zc=!1,Af=!1,Ml=0;function ba(t){t!==os&&t.next===null&&(os===null?Qc=os=t:os=os.next=t),Zc=!0,Nf||(Nf=!0,N2())}function co(t,r){if(!Af&&Zc){Af=!0;do for(var s=!1,c=Qc;c!==null;){if(t!==0){var p=c.pendingLanes;if(p===0)var y=0;else{var S=c.suspendedLanes,z=c.pingedLanes;y=(1<<31-Ke(42|t)+1)-1,y&=p&~(S&~z),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(s=!0,O1(c,y))}else y=Mt,y=kn(c,c===sn?y:0,c.cancelPendingCommit!==null||c.timeoutHandle!==-1),(y&3)===0||J(c,y)||(s=!0,O1(c,y));c=c.next}while(s);Af=!1}}function E2(){z1()}function z1(){Zc=Nf=!1;var t=0;Ml!==0&&O2()&&(t=Ml);for(var r=Se(),s=null,c=Qc;c!==null;){var p=c.next,y=_1(c,r);y===0?(c.next=null,s===null?Qc=p:s.next=p,p===null&&(os=s)):(s=c,(t!==0||(y&3)!==0)&&(Zc=!0)),c=p}On!==0&&On!==5||co(t),Ml!==0&&(Ml=0)}function _1(t,r){for(var s=t.suspendedLanes,c=t.pingedLanes,p=t.expirationTimes,y=t.pendingLanes&-62914561;0<y;){var S=31-Ke(y),z=1<<S,V=p[S];V===-1?((z&s)===0||(z&c)!==0)&&(p[S]=Oe(z,r)):V<=r&&(t.expiredLanes|=z),y&=~z}if(r=sn,s=Mt,s=kn(t,t===r?s:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),c=t.callbackNode,s===0||t===r&&(Qt===2||Qt===9)||t.cancelPendingCommit!==null)return c!==null&&c!==null&&Ct(c),t.callbackNode=null,t.callbackPriority=0;if((s&3)===0||J(t,s)){if(r=s&-s,r===t.callbackPriority)return r;switch(c!==null&&Ct(c),We(s)){case 2:case 8:s=ue;break;case 32:s=ne;break;case 268435456:s=we;break;default:s=ne}return c=B1.bind(null,t),s=Tt(s,c),t.callbackPriority=r,t.callbackNode=s,r}return c!==null&&c!==null&&Ct(c),t.callbackPriority=2,t.callbackNode=null,2}function B1(t,r){if(On!==0&&On!==5)return t.callbackNode=null,t.callbackPriority=0,null;var s=t.callbackNode;if(Pc()&&t.callbackNode!==s)return null;var c=Mt;return c=kn(t,t===sn?c:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),c===0?null:(g1(t,c,r),_1(t,Se()),t.callbackNode!=null&&t.callbackNode===s?B1.bind(null,t):null)}function O1(t,r){if(Pc())return null;g1(t,r,!0)}function N2(){L2(function(){(Vt&6)!==0?Tt(K,E2):z1()})}function Df(){if(Ml===0){var t=Vi;t===0&&(t=_t,_t<<=1,(_t&261888)===0&&(_t=256)),Ml=t}return Ml}function $1(t){return t==null||typeof t=="symbol"||typeof t=="boolean"?null:typeof t=="function"?t:zi(""+t)}function L1(t,r){var s=r.ownerDocument.createElement("input");return s.name=r.name,s.value=r.value,t.id&&s.setAttribute("form",t.id),r.parentNode.insertBefore(s,r),t=new FormData(t),s.parentNode.removeChild(s),t}function A2(t,r,s,c,p){if(r==="submit"&&s&&s.stateNode===p){var y=$1((p[mn]||null).action),S=c.submitter;S&&(r=(r=S[mn]||null)?$1(r.formAction):S.getAttribute("formAction"),r!==null&&(y=r,S=null));var z=new ml("action","action",null,c,p);t.push({event:z,listeners:[{instance:null,listener:function(){if(c.defaultPrevented){if(Ml!==0){var V=S?L1(p,S):new FormData(p);Gd(s,{pending:!0,data:V,method:p.method,action:y},null,V)}}else typeof y=="function"&&(z.preventDefault(),V=S?L1(p,S):new FormData(p),Gd(s,{pending:!0,data:V,method:p.method,action:y},y,V))},currentTarget:p}]})}}for(var Tf=0;Tf<dd.length;Tf++){var Ff=dd[Tf],D2=Ff.toLowerCase(),T2=Ff[0].toUpperCase()+Ff.slice(1);ra(D2,"on"+T2)}ra(xp,"onAnimationEnd"),ra(gp,"onAnimationIteration"),ra(yp,"onAnimationStart"),ra("dblclick","onDoubleClick"),ra("focusin","onFocus"),ra("focusout","onBlur"),ra(Wv,"onTransitionRun"),ra(Vv,"onTransitionStart"),ra(Gv,"onTransitionCancel"),ra(bp,"onTransitionEnd"),jr("onMouseEnter",["mouseout","mouseover"]),jr("onMouseLeave",["mouseout","mouseover"]),jr("onPointerEnter",["pointerout","pointerover"]),jr("onPointerLeave",["pointerout","pointerover"]),fr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),fr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),fr("onBeforeInput",["compositionend","keypress","textInput","paste"]),fr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),fr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),fr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var uo="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(" "),F2=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(uo));function I1(t,r){r=(r&4)!==0;for(var s=0;s<t.length;s++){var c=t[s],p=c.event;c=c.listeners;e:{var y=void 0;if(r)for(var S=c.length-1;0<=S;S--){var z=c[S],V=z.instance,le=z.currentTarget;if(z=z.listener,V!==y&&p.isPropagationStopped())break e;y=z,p.currentTarget=le;try{y(p)}catch(xe){hc(xe)}p.currentTarget=null,y=V}else for(S=0;S<c.length;S++){if(z=c[S],V=z.instance,le=z.currentTarget,z=z.listener,V!==y&&p.isPropagationStopped())break e;y=z,p.currentTarget=le;try{y(p)}catch(xe){hc(xe)}p.currentTarget=null,y=V}}}}function At(t,r){var s=r[Ql];s===void 0&&(s=r[Ql]=new Set);var c=t+"__bubble";s.has(c)||(H1(r,t,2,!1),s.add(c))}function Mf(t,r,s){var c=0;r&&(c|=4),H1(s,t,c,r)}var Jc="_reactListening"+Math.random().toString(36).slice(2);function Rf(t){if(!t[Jc]){t[Jc]=!0,za.forEach(function(s){s!=="selectionchange"&&(F2.has(s)||Mf(s,!1,t),Mf(s,!0,t))});var r=t.nodeType===9?t:t.ownerDocument;r===null||r[Jc]||(r[Jc]=!0,Mf("selectionchange",!1,r))}}function H1(t,r,s,c){switch(x0(r)){case 2:var p=lw;break;case 8:p=iw;break;default:p=Gf}s=p.bind(null,r,s,t),p=void 0,!Rs||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(p=!0),c?p!==void 0?t.addEventListener(r,s,{capture:!0,passive:p}):t.addEventListener(r,s,!0):p!==void 0?t.addEventListener(r,s,{passive:p}):t.addEventListener(r,s,!1)}function zf(t,r,s,c,p){var y=c;if((r&1)===0&&(r&2)===0&&c!==null)e:for(;;){if(c===null)return;var S=c.tag;if(S===3||S===4){var z=c.stateNode.containerInfo;if(z===p)break;if(S===4)for(S=c.return;S!==null;){var V=S.tag;if((V===3||V===4)&&S.stateNode.containerInfo===p)return;S=S.return}for(;z!==null;){if(S=ca(z),S===null)return;if(V=S.tag,V===5||V===6||V===26||V===27){c=y=S;continue e}z=z.parentNode}}c=c.return}dl(function(){var le=y,xe=fa(s),Ce=[];e:{var ce=vp.get(t);if(ce!==void 0){var fe=ml,Ye=t;switch(t){case"keypress":if(Bi(s)===0)break e;case"keydown":case"keyup":fe=cc;break;case"focusin":Ye="focus",fe=Hr;break;case"focusout":Ye="blur",fe=Hr;break;case"beforeblur":case"afterblur":fe=Hr;break;case"click":if(s.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":fe=Jo;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":fe=tc;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":fe=M;break;case xp:case gp:case yp:fe=_s;break;case bp:fe=re;break;case"scroll":case"scrollend":fe=rd;break;case"wheel":fe=je;break;case"copy":case"cut":case"paste":fe=rc;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":fe=Bs;break;case"toggle":case"beforetoggle":fe=It}var it=(r&4)!==0,nn=!it&&(t==="scroll"||t==="scrollend"),ee=it?ce!==null?ce+"Capture":null:ce;it=[];for(var Z=le,ae;Z!==null;){var be=Z;if(ae=be.stateNode,be=be.tag,be!==5&&be!==26&&be!==27||ae===null||ee===null||(be=ha(Z,ee),be!=null&&it.push(fo(Z,be,ae))),nn)break;Z=Z.return}0<it.length&&(ce=new fe(ce,Ye,null,s,xe),Ce.push({event:ce,listeners:it}))}}if((r&7)===0){e:{if(ce=t==="mouseover"||t==="pointerover",fe=t==="mouseout"||t==="pointerout",ce&&s!==_i&&(Ye=s.relatedTarget||s.fromElement)&&(ca(Ye)||Ye[Or]))break e;if((fe||ce)&&(ce=xe.window===xe?xe:(ce=xe.ownerDocument)?ce.defaultView||ce.parentWindow:window,fe?(Ye=s.relatedTarget||s.toElement,fe=le,Ye=Ye?ca(Ye):null,Ye!==null&&(nn=u(Ye),it=Ye.tag,Ye!==nn||it!==5&&it!==27&&it!==6)&&(Ye=null)):(fe=null,Ye=le),fe!==Ye)){if(it=Jo,be="onMouseLeave",ee="onMouseEnter",Z="mouse",(t==="pointerout"||t==="pointerover")&&(it=Bs,be="onPointerLeave",ee="onPointerEnter",Z="pointer"),nn=fe==null?ce:Ra(fe),ae=Ye==null?ce:Ra(Ye),ce=new it(be,Z+"leave",fe,s,xe),ce.target=nn,ce.relatedTarget=ae,be=null,ca(xe)===le&&(it=new it(ee,Z+"enter",Ye,s,xe),it.target=ae,it.relatedTarget=nn,be=it),nn=be,fe&&Ye)t:{for(it=M2,ee=fe,Z=Ye,ae=0,be=ee;be;be=it(be))ae++;be=0;for(var nt=Z;nt;nt=it(nt))be++;for(;0<ae-be;)ee=it(ee),ae--;for(;0<be-ae;)Z=it(Z),be--;for(;ae--;){if(ee===Z||Z!==null&&ee===Z.alternate){it=ee;break t}ee=it(ee),Z=it(Z)}it=null}else it=null;fe!==null&&U1(Ce,ce,fe,it,!1),Ye!==null&&nn!==null&&U1(Ce,nn,Ye,it,!0)}}e:{if(ce=le?Ra(le):window,fe=ce.nodeName&&ce.nodeName.toLowerCase(),fe==="select"||fe==="input"&&ce.type==="file")var qt=lp;else if(rp(ce))if(ip)qt=qv;else{qt=Hv;var Ve=Iv}else fe=ce.nodeName,!fe||fe.toLowerCase()!=="input"||ce.type!=="checkbox"&&ce.type!=="radio"?le&&qn(le.elementType)&&(qt=lp):qt=Uv;if(qt&&(qt=qt(t,le))){ap(Ce,qt,s,xe);break e}Ve&&Ve(t,ce,le),t==="focusout"&&le&&ce.type==="number"&&le.memoizedProps.value!=null&&Jl(ce,"number",ce.value)}switch(Ve=le?Ra(le):window,t){case"focusin":(rp(Ve)||Ve.contentEditable==="true")&&(Li=Ve,od=le,Is=null);break;case"focusout":Is=od=Li=null;break;case"mousedown":cd=!0;break;case"contextmenu":case"mouseup":case"dragend":cd=!1,mp(Ce,s,xe);break;case"selectionchange":if(Xv)break;case"keydown":case"keyup":mp(Ce,s,xe)}var vt;if(Ze)e:{switch(t){case"compositionstart":var Rt="onCompositionStart";break e;case"compositionend":Rt="onCompositionEnd";break e;case"compositionupdate":Rt="onCompositionUpdate";break e}Rt=void 0}else pn?ct(t,s)&&(Rt="onCompositionEnd"):t==="keydown"&&s.keyCode===229&&(Rt="onCompositionStart");Rt&&(Ft&&s.locale!=="ko"&&(pn||Rt!=="onCompositionStart"?Rt==="onCompositionEnd"&&pn&&(vt=hl()):(ma=xe,ln="value"in ma?ma.value:ma.textContent,pn=!0)),Ve=eu(le,Rt),0<Ve.length&&(Rt=new lc(Rt,t,null,s,xe),Ce.push({event:Rt,listeners:Ve}),vt?Rt.data=vt:(vt=$t(s),vt!==null&&(Rt.data=vt)))),(vt=mt?dn(t,s):Ov(t,s))&&(Rt=eu(le,"onBeforeInput"),0<Rt.length&&(Ve=new lc("onBeforeInput","beforeinput",null,s,xe),Ce.push({event:Ve,listeners:Rt}),Ve.data=vt)),A2(Ce,t,le,s,xe)}I1(Ce,r)})}function fo(t,r,s){return{instance:t,listener:r,currentTarget:s}}function eu(t,r){for(var s=r+"Capture",c=[];t!==null;){var p=t,y=p.stateNode;if(p=p.tag,p!==5&&p!==26&&p!==27||y===null||(p=ha(t,s),p!=null&&c.unshift(fo(t,p,y)),p=ha(t,r),p!=null&&c.push(fo(t,p,y))),t.tag===3)return c;t=t.return}return[]}function M2(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5&&t.tag!==27);return t||null}function U1(t,r,s,c,p){for(var y=r._reactName,S=[];s!==null&&s!==c;){var z=s,V=z.alternate,le=z.stateNode;if(z=z.tag,V!==null&&V===c)break;z!==5&&z!==26&&z!==27||le===null||(V=le,p?(le=ha(s,y),le!=null&&S.unshift(fo(s,le,V))):p||(le=ha(s,y),le!=null&&S.push(fo(s,le,V)))),s=s.return}S.length!==0&&t.push({event:r,listeners:S})}var R2=/\r\n?/g,z2=/\u0000|\uFFFD/g;function q1(t){return(typeof t=="string"?t:""+t).replace(R2,`
|
|
49
|
+
`).replace(z2,"")}function Y1(t,r){return r=q1(r),q1(t)===r}function tn(t,r,s,c,p,y){switch(s){case"children":typeof c=="string"?r==="body"||r==="textarea"&&c===""||ul(t,c):(typeof c=="number"||typeof c=="bigint")&&r!=="body"&&ul(t,""+c);break;case"className":cl(t,"class",c);break;case"tabIndex":cl(t,"tabindex",c);break;case"dir":case"role":case"viewBox":case"width":case"height":cl(t,s,c);break;case"style":ta(t,c,y);break;case"data":if(r!=="object"){cl(t,"data",c);break}case"src":case"href":if(c===""&&(r!=="a"||s!=="href")){t.removeAttribute(s);break}if(c==null||typeof c=="function"||typeof c=="symbol"||typeof c=="boolean"){t.removeAttribute(s);break}c=zi(""+c),t.setAttribute(s,c);break;case"action":case"formAction":if(typeof c=="function"){t.setAttribute(s,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof y=="function"&&(s==="formAction"?(r!=="input"&&tn(t,r,"name",p.name,p,null),tn(t,r,"formEncType",p.formEncType,p,null),tn(t,r,"formMethod",p.formMethod,p,null),tn(t,r,"formTarget",p.formTarget,p,null)):(tn(t,r,"encType",p.encType,p,null),tn(t,r,"method",p.method,p,null),tn(t,r,"target",p.target,p,null)));if(c==null||typeof c=="symbol"||typeof c=="boolean"){t.removeAttribute(s);break}c=zi(""+c),t.setAttribute(s,c);break;case"onClick":c!=null&&(t.onclick=hr);break;case"onScroll":c!=null&&At("scroll",t);break;case"onScrollEnd":c!=null&&At("scrollend",t);break;case"dangerouslySetInnerHTML":if(c!=null){if(typeof c!="object"||!("__html"in c))throw Error(i(61));if(s=c.__html,s!=null){if(p.children!=null)throw Error(i(60));t.innerHTML=s}}break;case"multiple":t.multiple=c&&typeof c!="function"&&typeof c!="symbol";break;case"muted":t.muted=c&&typeof c!="function"&&typeof c!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(c==null||typeof c=="function"||typeof c=="boolean"||typeof c=="symbol"){t.removeAttribute("xlink:href");break}s=zi(""+c),t.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",s);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":c!=null&&typeof c!="function"&&typeof c!="symbol"?t.setAttribute(s,""+c):t.removeAttribute(s);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":c&&typeof c!="function"&&typeof c!="symbol"?t.setAttribute(s,""):t.removeAttribute(s);break;case"capture":case"download":c===!0?t.setAttribute(s,""):c!==!1&&c!=null&&typeof c!="function"&&typeof c!="symbol"?t.setAttribute(s,c):t.removeAttribute(s);break;case"cols":case"rows":case"size":case"span":c!=null&&typeof c!="function"&&typeof c!="symbol"&&!isNaN(c)&&1<=c?t.setAttribute(s,c):t.removeAttribute(s);break;case"rowSpan":case"start":c==null||typeof c=="function"||typeof c=="symbol"||isNaN(c)?t.removeAttribute(s):t.setAttribute(s,c);break;case"popover":At("beforetoggle",t),At("toggle",t),Zl(t,"popover",c);break;case"xlinkActuate":$r(t,"http://www.w3.org/1999/xlink","xlink:actuate",c);break;case"xlinkArcrole":$r(t,"http://www.w3.org/1999/xlink","xlink:arcrole",c);break;case"xlinkRole":$r(t,"http://www.w3.org/1999/xlink","xlink:role",c);break;case"xlinkShow":$r(t,"http://www.w3.org/1999/xlink","xlink:show",c);break;case"xlinkTitle":$r(t,"http://www.w3.org/1999/xlink","xlink:title",c);break;case"xlinkType":$r(t,"http://www.w3.org/1999/xlink","xlink:type",c);break;case"xmlBase":$r(t,"http://www.w3.org/XML/1998/namespace","xml:base",c);break;case"xmlLang":$r(t,"http://www.w3.org/XML/1998/namespace","xml:lang",c);break;case"xmlSpace":$r(t,"http://www.w3.org/XML/1998/namespace","xml:space",c);break;case"is":Zl(t,"is",c);break;case"innerText":case"textContent":break;default:(!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(s=da.get(s)||s,Zl(t,s,c))}}function _f(t,r,s,c,p,y){switch(s){case"style":ta(t,c,y);break;case"dangerouslySetInnerHTML":if(c!=null){if(typeof c!="object"||!("__html"in c))throw Error(i(61));if(s=c.__html,s!=null){if(p.children!=null)throw Error(i(60));t.innerHTML=s}}break;case"children":typeof c=="string"?ul(t,c):(typeof c=="number"||typeof c=="bigint")&&ul(t,""+c);break;case"onScroll":c!=null&&At("scroll",t);break;case"onScrollEnd":c!=null&&At("scrollend",t);break;case"onClick":c!=null&&(t.onclick=hr);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Mi.hasOwnProperty(s))e:{if(s[0]==="o"&&s[1]==="n"&&(p=s.endsWith("Capture"),r=s.slice(2,p?s.length-7:void 0),y=t[mn]||null,y=y!=null?y[s]:null,typeof y=="function"&&t.removeEventListener(r,y,p),typeof c=="function")){typeof y!="function"&&y!==null&&(s in t?t[s]=null:t.hasAttribute(s)&&t.removeAttribute(s)),t.addEventListener(r,c,p);break e}s in t?t[s]=c:c===!0?t.setAttribute(s,""):Zl(t,s,c)}}}function Jn(t,r,s){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":At("error",t),At("load",t);var c=!1,p=!1,y;for(y in s)if(s.hasOwnProperty(y)){var S=s[y];if(S!=null)switch(y){case"src":c=!0;break;case"srcSet":p=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,r));default:tn(t,r,y,S,s,null)}}p&&tn(t,r,"srcSet",s.srcSet,s,null),c&&tn(t,r,"src",s.src,s,null);return;case"input":At("invalid",t);var z=y=S=p=null,V=null,le=null;for(c in s)if(s.hasOwnProperty(c)){var xe=s[c];if(xe!=null)switch(c){case"name":p=xe;break;case"type":S=xe;break;case"checked":V=xe;break;case"defaultChecked":le=xe;break;case"value":y=xe;break;case"defaultValue":z=xe;break;case"children":case"dangerouslySetInnerHTML":if(xe!=null)throw Error(i(137,r));break;default:tn(t,r,c,xe,s,null)}}Qo(t,y,z,V,le,S,p,!1);return;case"select":At("invalid",t),c=S=y=null;for(p in s)if(s.hasOwnProperty(p)&&(z=s[p],z!=null))switch(p){case"value":y=z;break;case"defaultValue":S=z;break;case"multiple":c=z;default:tn(t,r,p,z,s,null)}r=y,s=S,t.multiple=!!c,r!=null?Gn(t,!!c,r,!1):s!=null&&Gn(t,!!c,s,!0);return;case"textarea":At("invalid",t),y=p=c=null;for(S in s)if(s.hasOwnProperty(S)&&(z=s[S],z!=null))switch(S){case"value":c=z;break;case"defaultValue":p=z;break;case"children":y=z;break;case"dangerouslySetInnerHTML":if(z!=null)throw Error(i(91));break;default:tn(t,r,S,z,s,null)}ua(t,c,p,y);return;case"option":for(V in s)if(s.hasOwnProperty(V)&&(c=s[V],c!=null))switch(V){case"selected":t.selected=c&&typeof c!="function"&&typeof c!="symbol";break;default:tn(t,r,V,c,s,null)}return;case"dialog":At("beforetoggle",t),At("toggle",t),At("cancel",t),At("close",t);break;case"iframe":case"object":At("load",t);break;case"video":case"audio":for(c=0;c<uo.length;c++)At(uo[c],t);break;case"image":At("error",t),At("load",t);break;case"details":At("toggle",t);break;case"embed":case"source":case"link":At("error",t),At("load",t);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(le in s)if(s.hasOwnProperty(le)&&(c=s[le],c!=null))switch(le){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,r));default:tn(t,r,le,c,s,null)}return;default:if(qn(r)){for(xe in s)s.hasOwnProperty(xe)&&(c=s[xe],c!==void 0&&_f(t,r,xe,c,s,void 0));return}}for(z in s)s.hasOwnProperty(z)&&(c=s[z],c!=null&&tn(t,r,z,c,s,null))}function _2(t,r,s,c){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var p=null,y=null,S=null,z=null,V=null,le=null,xe=null;for(fe in s){var Ce=s[fe];if(s.hasOwnProperty(fe)&&Ce!=null)switch(fe){case"checked":break;case"value":break;case"defaultValue":V=Ce;default:c.hasOwnProperty(fe)||tn(t,r,fe,null,c,Ce)}}for(var ce in c){var fe=c[ce];if(Ce=s[ce],c.hasOwnProperty(ce)&&(fe!=null||Ce!=null))switch(ce){case"type":y=fe;break;case"name":p=fe;break;case"checked":le=fe;break;case"defaultChecked":xe=fe;break;case"value":S=fe;break;case"defaultValue":z=fe;break;case"children":case"dangerouslySetInnerHTML":if(fe!=null)throw Error(i(137,r));break;default:fe!==Ce&&tn(t,r,ce,fe,c,Ce)}}Ri(t,S,z,V,le,xe,y,p);return;case"select":fe=S=z=ce=null;for(y in s)if(V=s[y],s.hasOwnProperty(y)&&V!=null)switch(y){case"value":break;case"multiple":fe=V;default:c.hasOwnProperty(y)||tn(t,r,y,null,c,V)}for(p in c)if(y=c[p],V=s[p],c.hasOwnProperty(p)&&(y!=null||V!=null))switch(p){case"value":ce=y;break;case"defaultValue":z=y;break;case"multiple":S=y;default:y!==V&&tn(t,r,p,y,c,V)}r=z,s=S,c=fe,ce!=null?Gn(t,!!s,ce,!1):!!c!=!!s&&(r!=null?Gn(t,!!s,r,!0):Gn(t,!!s,s?[]:"",!1));return;case"textarea":fe=ce=null;for(z in s)if(p=s[z],s.hasOwnProperty(z)&&p!=null&&!c.hasOwnProperty(z))switch(z){case"value":break;case"children":break;default:tn(t,r,z,null,c,p)}for(S in c)if(p=c[S],y=s[S],c.hasOwnProperty(S)&&(p!=null||y!=null))switch(S){case"value":ce=p;break;case"defaultValue":fe=p;break;case"children":break;case"dangerouslySetInnerHTML":if(p!=null)throw Error(i(91));break;default:p!==y&&tn(t,r,S,p,c,y)}Oa(t,ce,fe);return;case"option":for(var Ye in s)if(ce=s[Ye],s.hasOwnProperty(Ye)&&ce!=null&&!c.hasOwnProperty(Ye))switch(Ye){case"selected":t.selected=!1;break;default:tn(t,r,Ye,null,c,ce)}for(V in c)if(ce=c[V],fe=s[V],c.hasOwnProperty(V)&&ce!==fe&&(ce!=null||fe!=null))switch(V){case"selected":t.selected=ce&&typeof ce!="function"&&typeof ce!="symbol";break;default:tn(t,r,V,ce,c,fe)}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 it in s)ce=s[it],s.hasOwnProperty(it)&&ce!=null&&!c.hasOwnProperty(it)&&tn(t,r,it,null,c,ce);for(le in c)if(ce=c[le],fe=s[le],c.hasOwnProperty(le)&&ce!==fe&&(ce!=null||fe!=null))switch(le){case"children":case"dangerouslySetInnerHTML":if(ce!=null)throw Error(i(137,r));break;default:tn(t,r,le,ce,c,fe)}return;default:if(qn(r)){for(var nn in s)ce=s[nn],s.hasOwnProperty(nn)&&ce!==void 0&&!c.hasOwnProperty(nn)&&_f(t,r,nn,void 0,c,ce);for(xe in c)ce=c[xe],fe=s[xe],!c.hasOwnProperty(xe)||ce===fe||ce===void 0&&fe===void 0||_f(t,r,xe,ce,c,fe);return}}for(var ee in s)ce=s[ee],s.hasOwnProperty(ee)&&ce!=null&&!c.hasOwnProperty(ee)&&tn(t,r,ee,null,c,ce);for(Ce in c)ce=c[Ce],fe=s[Ce],!c.hasOwnProperty(Ce)||ce===fe||ce==null&&fe==null||tn(t,r,Ce,ce,c,fe)}function X1(t){switch(t){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function B2(){if(typeof performance.getEntriesByType=="function"){for(var t=0,r=0,s=performance.getEntriesByType("resource"),c=0;c<s.length;c++){var p=s[c],y=p.transferSize,S=p.initiatorType,z=p.duration;if(y&&z&&X1(S)){for(S=0,z=p.responseEnd,c+=1;c<s.length;c++){var V=s[c],le=V.startTime;if(le>z)break;var xe=V.transferSize,Ce=V.initiatorType;xe&&X1(Ce)&&(V=V.responseEnd,S+=xe*(V<z?1:(z-le)/(V-le)))}if(--c,r+=8*(y+S)/(p.duration/1e3),t++,10<t)break}}if(0<t)return r/t/1e6}return navigator.connection&&(t=navigator.connection.downlink,typeof t=="number")?t:5}var Bf=null,Of=null;function tu(t){return t.nodeType===9?t:t.ownerDocument}function W1(t){switch(t){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function V1(t,r){if(t===0)switch(r){case"svg":return 1;case"math":return 2;default:return 0}return t===1&&r==="foreignObject"?0:t}function $f(t,r){return t==="textarea"||t==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.children=="bigint"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var Lf=null;function O2(){var t=window.event;return t&&t.type==="popstate"?t===Lf?!1:(Lf=t,!0):(Lf=null,!1)}var G1=typeof setTimeout=="function"?setTimeout:void 0,$2=typeof clearTimeout=="function"?clearTimeout:void 0,K1=typeof Promise=="function"?Promise:void 0,L2=typeof queueMicrotask=="function"?queueMicrotask:typeof K1<"u"?function(t){return K1.resolve(null).then(t).catch(I2)}:G1;function I2(t){setTimeout(function(){throw t})}function Rl(t){return t==="head"}function P1(t,r){var s=r,c=0;do{var p=s.nextSibling;if(t.removeChild(s),p&&p.nodeType===8)if(s=p.data,s==="/$"||s==="/&"){if(c===0){t.removeChild(p),fs(r);return}c--}else if(s==="$"||s==="$?"||s==="$~"||s==="$!"||s==="&")c++;else if(s==="html")ho(t.ownerDocument.documentElement);else if(s==="head"){s=t.ownerDocument.head,ho(s);for(var y=s.firstChild;y;){var S=y.nextSibling,z=y.nodeName;y[Fa]||z==="SCRIPT"||z==="STYLE"||z==="LINK"&&y.rel.toLowerCase()==="stylesheet"||s.removeChild(y),y=S}}else s==="body"&&ho(t.ownerDocument.body);s=p}while(s);fs(r)}function Q1(t,r){var s=t;t=0;do{var c=s.nextSibling;if(s.nodeType===1?r?(s._stashedDisplay=s.style.display,s.style.display="none"):(s.style.display=s._stashedDisplay||"",s.getAttribute("style")===""&&s.removeAttribute("style")):s.nodeType===3&&(r?(s._stashedText=s.nodeValue,s.nodeValue=""):s.nodeValue=s._stashedText||""),c&&c.nodeType===8)if(s=c.data,s==="/$"){if(t===0)break;t--}else s!=="$"&&s!=="$?"&&s!=="$~"&&s!=="$!"||t++;s=c}while(s)}function If(t){var r=t.firstChild;for(r&&r.nodeType===10&&(r=r.nextSibling);r;){var s=r;switch(r=r.nextSibling,s.nodeName){case"HTML":case"HEAD":case"BODY":If(s),Ts(s);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(s.rel.toLowerCase()==="stylesheet")continue}t.removeChild(s)}}function H2(t,r,s,c){for(;t.nodeType===1;){var p=s;if(t.nodeName.toLowerCase()!==r.toLowerCase()){if(!c&&(t.nodeName!=="INPUT"||t.type!=="hidden"))break}else if(c){if(!t[Fa])switch(r){case"meta":if(!t.hasAttribute("itemprop"))break;return t;case"link":if(y=t.getAttribute("rel"),y==="stylesheet"&&t.hasAttribute("data-precedence"))break;if(y!==p.rel||t.getAttribute("href")!==(p.href==null||p.href===""?null:p.href)||t.getAttribute("crossorigin")!==(p.crossOrigin==null?null:p.crossOrigin)||t.getAttribute("title")!==(p.title==null?null:p.title))break;return t;case"style":if(t.hasAttribute("data-precedence"))break;return t;case"script":if(y=t.getAttribute("src"),(y!==(p.src==null?null:p.src)||t.getAttribute("type")!==(p.type==null?null:p.type)||t.getAttribute("crossorigin")!==(p.crossOrigin==null?null:p.crossOrigin))&&y&&t.hasAttribute("async")&&!t.hasAttribute("itemprop"))break;return t;default:return t}}else if(r==="input"&&t.type==="hidden"){var y=p.name==null?null:""+p.name;if(p.type==="hidden"&&t.getAttribute("name")===y)return t}else return t;if(t=Gr(t.nextSibling),t===null)break}return null}function U2(t,r,s){if(r==="")return null;for(;t.nodeType!==3;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!s||(t=Gr(t.nextSibling),t===null))return null;return t}function Z1(t,r){for(;t.nodeType!==8;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!r||(t=Gr(t.nextSibling),t===null))return null;return t}function Hf(t){return t.data==="$?"||t.data==="$~"}function Uf(t){return t.data==="$!"||t.data==="$?"&&t.ownerDocument.readyState!=="loading"}function q2(t,r){var s=t.ownerDocument;if(t.data==="$~")t._reactRetry=r;else if(t.data!=="$?"||s.readyState!=="loading")r();else{var c=function(){r(),s.removeEventListener("DOMContentLoaded",c)};s.addEventListener("DOMContentLoaded",c),t._reactRetry=c}}function Gr(t){for(;t!=null;t=t.nextSibling){var r=t.nodeType;if(r===1||r===3)break;if(r===8){if(r=t.data,r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"||r==="F!"||r==="F")break;if(r==="/$"||r==="/&")return null}}return t}var qf=null;function J1(t){t=t.nextSibling;for(var r=0;t;){if(t.nodeType===8){var s=t.data;if(s==="/$"||s==="/&"){if(r===0)return Gr(t.nextSibling);r--}else s!=="$"&&s!=="$!"&&s!=="$?"&&s!=="$~"&&s!=="&"||r++}t=t.nextSibling}return null}function e0(t){t=t.previousSibling;for(var r=0;t;){if(t.nodeType===8){var s=t.data;if(s==="$"||s==="$!"||s==="$?"||s==="$~"||s==="&"){if(r===0)return t;r--}else s!=="/$"&&s!=="/&"||r++}t=t.previousSibling}return null}function t0(t,r,s){switch(r=tu(s),t){case"html":if(t=r.documentElement,!t)throw Error(i(452));return t;case"head":if(t=r.head,!t)throw Error(i(453));return t;case"body":if(t=r.body,!t)throw Error(i(454));return t;default:throw Error(i(451))}}function ho(t){for(var r=t.attributes;r.length;)t.removeAttributeNode(r[0]);Ts(t)}var Kr=new Map,n0=new Set;function nu(t){return typeof t.getRootNode=="function"?t.getRootNode():t.nodeType===9?t:t.ownerDocument}var tl=oe.d;oe.d={f:Y2,r:X2,D:W2,C:V2,L:G2,m:K2,X:Q2,S:P2,M:Z2};function Y2(){var t=tl.f(),r=Vc();return t||r}function X2(t){var r=Ma(t);r!==null&&r.tag===5&&r.type==="form"?bx(r):tl.r(t)}var cs=typeof document>"u"?null:document;function r0(t,r,s){var c=cs;if(c&&typeof r=="string"&&r){var p=Pt(r);p='link[rel="'+t+'"][href="'+p+'"]',typeof s=="string"&&(p+='[crossorigin="'+s+'"]'),n0.has(p)||(n0.add(p),t={rel:t,crossOrigin:s,href:r},c.querySelector(p)===null&&(r=c.createElement("link"),Jn(r,"link",t),Dn(r),c.head.appendChild(r)))}}function W2(t){tl.D(t),r0("dns-prefetch",t,null)}function V2(t,r){tl.C(t,r),r0("preconnect",t,r)}function G2(t,r,s){tl.L(t,r,s);var c=cs;if(c&&t&&r){var p='link[rel="preload"][as="'+Pt(r)+'"]';r==="image"&&s&&s.imageSrcSet?(p+='[imagesrcset="'+Pt(s.imageSrcSet)+'"]',typeof s.imageSizes=="string"&&(p+='[imagesizes="'+Pt(s.imageSizes)+'"]')):p+='[href="'+Pt(t)+'"]';var y=p;switch(r){case"style":y=us(t);break;case"script":y=ds(t)}Kr.has(y)||(t=g({rel:"preload",href:r==="image"&&s&&s.imageSrcSet?void 0:t,as:r},s),Kr.set(y,t),c.querySelector(p)!==null||r==="style"&&c.querySelector(mo(y))||r==="script"&&c.querySelector(po(y))||(r=c.createElement("link"),Jn(r,"link",t),Dn(r),c.head.appendChild(r)))}}function K2(t,r){tl.m(t,r);var s=cs;if(s&&t){var c=r&&typeof r.as=="string"?r.as:"script",p='link[rel="modulepreload"][as="'+Pt(c)+'"][href="'+Pt(t)+'"]',y=p;switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=ds(t)}if(!Kr.has(y)&&(t=g({rel:"modulepreload",href:t},r),Kr.set(y,t),s.querySelector(p)===null)){switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(s.querySelector(po(y)))return}c=s.createElement("link"),Jn(c,"link",t),Dn(c),s.head.appendChild(c)}}}function P2(t,r,s){tl.S(t,r,s);var c=cs;if(c&&t){var p=Vn(c).hoistableStyles,y=us(t);r=r||"default";var S=p.get(y);if(!S){var z={loading:0,preload:null};if(S=c.querySelector(mo(y)))z.loading=5;else{t=g({rel:"stylesheet",href:t,"data-precedence":r},s),(s=Kr.get(y))&&Yf(t,s);var V=S=c.createElement("link");Dn(V),Jn(V,"link",t),V._p=new Promise(function(le,xe){V.onload=le,V.onerror=xe}),V.addEventListener("load",function(){z.loading|=1}),V.addEventListener("error",function(){z.loading|=2}),z.loading|=4,ru(S,r,c)}S={type:"stylesheet",instance:S,count:1,state:z},p.set(y,S)}}}function Q2(t,r){tl.X(t,r);var s=cs;if(s&&t){var c=Vn(s).hoistableScripts,p=ds(t),y=c.get(p);y||(y=s.querySelector(po(p)),y||(t=g({src:t,async:!0},r),(r=Kr.get(p))&&Xf(t,r),y=s.createElement("script"),Dn(y),Jn(y,"link",t),s.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},c.set(p,y))}}function Z2(t,r){tl.M(t,r);var s=cs;if(s&&t){var c=Vn(s).hoistableScripts,p=ds(t),y=c.get(p);y||(y=s.querySelector(po(p)),y||(t=g({src:t,async:!0,type:"module"},r),(r=Kr.get(p))&&Xf(t,r),y=s.createElement("script"),Dn(y),Jn(y,"link",t),s.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},c.set(p,y))}}function a0(t,r,s,c){var p=(p=pe.current)?nu(p):null;if(!p)throw Error(i(446));switch(t){case"meta":case"title":return null;case"style":return typeof s.precedence=="string"&&typeof s.href=="string"?(r=us(s.href),s=Vn(p).hoistableStyles,c=s.get(r),c||(c={type:"style",instance:null,count:0,state:null},s.set(r,c)),c):{type:"void",instance:null,count:0,state:null};case"link":if(s.rel==="stylesheet"&&typeof s.href=="string"&&typeof s.precedence=="string"){t=us(s.href);var y=Vn(p).hoistableStyles,S=y.get(t);if(S||(p=p.ownerDocument||p,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(t,S),(y=p.querySelector(mo(t)))&&!y._p&&(S.instance=y,S.state.loading=5),Kr.has(t)||(s={rel:"preload",as:"style",href:s.href,crossOrigin:s.crossOrigin,integrity:s.integrity,media:s.media,hrefLang:s.hrefLang,referrerPolicy:s.referrerPolicy},Kr.set(t,s),y||J2(p,t,s,S.state))),r&&c===null)throw Error(i(528,""));return S}if(r&&c!==null)throw Error(i(529,""));return null;case"script":return r=s.async,s=s.src,typeof s=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=ds(s),s=Vn(p).hoistableScripts,c=s.get(r),c||(c={type:"script",instance:null,count:0,state:null},s.set(r,c)),c):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,t))}}function us(t){return'href="'+Pt(t)+'"'}function mo(t){return'link[rel="stylesheet"]['+t+"]"}function l0(t){return g({},t,{"data-precedence":t.precedence,precedence:null})}function J2(t,r,s,c){t.querySelector('link[rel="preload"][as="style"]['+r+"]")?c.loading=1:(r=t.createElement("link"),c.preload=r,r.addEventListener("load",function(){return c.loading|=1}),r.addEventListener("error",function(){return c.loading|=2}),Jn(r,"link",s),Dn(r),t.head.appendChild(r))}function ds(t){return'[src="'+Pt(t)+'"]'}function po(t){return"script[async]"+t}function i0(t,r,s){if(r.count++,r.instance===null)switch(r.type){case"style":var c=t.querySelector('style[data-href~="'+Pt(s.href)+'"]');if(c)return r.instance=c,Dn(c),c;var p=g({},s,{"data-href":s.href,"data-precedence":s.precedence,href:null,precedence:null});return c=(t.ownerDocument||t).createElement("style"),Dn(c),Jn(c,"style",p),ru(c,s.precedence,t),r.instance=c;case"stylesheet":p=us(s.href);var y=t.querySelector(mo(p));if(y)return r.state.loading|=4,r.instance=y,Dn(y),y;c=l0(s),(p=Kr.get(p))&&Yf(c,p),y=(t.ownerDocument||t).createElement("link"),Dn(y);var S=y;return S._p=new Promise(function(z,V){S.onload=z,S.onerror=V}),Jn(y,"link",c),r.state.loading|=4,ru(y,s.precedence,t),r.instance=y;case"script":return y=ds(s.src),(p=t.querySelector(po(y)))?(r.instance=p,Dn(p),p):(c=s,(p=Kr.get(y))&&(c=g({},s),Xf(c,p)),t=t.ownerDocument||t,p=t.createElement("script"),Dn(p),Jn(p,"link",c),t.head.appendChild(p),r.instance=p);case"void":return null;default:throw Error(i(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(c=r.instance,r.state.loading|=4,ru(c,s.precedence,t));return r.instance}function ru(t,r,s){for(var c=s.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),p=c.length?c[c.length-1]:null,y=p,S=0;S<c.length;S++){var z=c[S];if(z.dataset.precedence===r)y=z;else if(y!==p)break}y?y.parentNode.insertBefore(t,y.nextSibling):(r=s.nodeType===9?s.head:s,r.insertBefore(t,r.firstChild))}function Yf(t,r){t.crossOrigin==null&&(t.crossOrigin=r.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=r.referrerPolicy),t.title==null&&(t.title=r.title)}function Xf(t,r){t.crossOrigin==null&&(t.crossOrigin=r.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=r.referrerPolicy),t.integrity==null&&(t.integrity=r.integrity)}var au=null;function s0(t,r,s){if(au===null){var c=new Map,p=au=new Map;p.set(s,c)}else p=au,c=p.get(s),c||(c=new Map,p.set(s,c));if(c.has(t))return c;for(c.set(t,null),s=s.getElementsByTagName(t),p=0;p<s.length;p++){var y=s[p];if(!(y[Fa]||y[yn]||t==="link"&&y.getAttribute("rel")==="stylesheet")&&y.namespaceURI!=="http://www.w3.org/2000/svg"){var S=y.getAttribute(r)||"";S=t+S;var z=c.get(S);z?z.push(y):c.set(S,[y])}}return c}function o0(t,r,s){t=t.ownerDocument||t,t.head.insertBefore(s,r==="title"?t.querySelector("head > title"):null)}function ew(t,r,s){if(s===1||r.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;switch(r.rel){case"stylesheet":return t=r.disabled,typeof r.precedence=="string"&&t==null;default:return!0}case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function c0(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function tw(t,r,s,c){if(s.type==="stylesheet"&&(typeof c.media!="string"||matchMedia(c.media).matches!==!1)&&(s.state.loading&4)===0){if(s.instance===null){var p=us(c.href),y=r.querySelector(mo(p));if(y){r=y._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(t.count++,t=lu.bind(t),r.then(t,t)),s.state.loading|=4,s.instance=y,Dn(y);return}y=r.ownerDocument||r,c=l0(c),(p=Kr.get(p))&&Yf(c,p),y=y.createElement("link"),Dn(y);var S=y;S._p=new Promise(function(z,V){S.onload=z,S.onerror=V}),Jn(y,"link",c),s.instance=y}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(s,r),(r=s.state.preload)&&(s.state.loading&3)===0&&(t.count++,s=lu.bind(t),r.addEventListener("load",s),r.addEventListener("error",s))}}var Wf=0;function nw(t,r){return t.stylesheets&&t.count===0&&su(t,t.stylesheets),0<t.count||0<t.imgCount?function(s){var c=setTimeout(function(){if(t.stylesheets&&su(t,t.stylesheets),t.unsuspend){var y=t.unsuspend;t.unsuspend=null,y()}},6e4+r);0<t.imgBytes&&Wf===0&&(Wf=62500*B2());var p=setTimeout(function(){if(t.waitingForImages=!1,t.count===0&&(t.stylesheets&&su(t,t.stylesheets),t.unsuspend)){var y=t.unsuspend;t.unsuspend=null,y()}},(t.imgBytes>Wf?50:800)+r);return t.unsuspend=s,function(){t.unsuspend=null,clearTimeout(c),clearTimeout(p)}}:null}function lu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)su(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var iu=null;function su(t,r){t.stylesheets=null,t.unsuspend!==null&&(t.count++,iu=new Map,r.forEach(rw,t),iu=null,lu.call(t))}function rw(t,r){if(!(r.state.loading&4)){var s=iu.get(t);if(s)var c=s.get(null);else{s=new Map,iu.set(t,s);for(var p=t.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y<p.length;y++){var S=p[y];(S.nodeName==="LINK"||S.getAttribute("media")!=="not all")&&(s.set(S.dataset.precedence,S),c=S)}c&&s.set(null,c)}p=r.instance,S=p.getAttribute("data-precedence"),y=s.get(S)||c,y===c&&s.set(null,p),s.set(S,p),this.count++,c=lu.bind(this),p.addEventListener("load",c),p.addEventListener("error",c),y?y.parentNode.insertBefore(p,y.nextSibling):(t=t.nodeType===9?t.head:t,t.insertBefore(p,t.firstChild)),r.state.loading|=4}}var xo={$$typeof:_,Provider:null,Consumer:null,_currentValue:de,_currentValue2:de,_threadCount:0};function aw(t,r,s,c,p,y,S,z,V){this.tag=1,this.containerInfo=t,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Kt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Kt(0),this.hiddenUpdates=Kt(null),this.identifierPrefix=c,this.onUncaughtError=p,this.onCaughtError=y,this.onRecoverableError=S,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=V,this.incompleteTransitions=new Map}function u0(t,r,s,c,p,y,S,z,V,le,xe,Ce){return t=new aw(t,r,s,S,V,le,xe,Ce,z),r=1,y===!0&&(r|=24),y=Er(3,null,null,r),t.current=y,y.stateNode=t,r=Sd(),r.refCount++,t.pooledCache=r,r.refCount++,y.memoizedState={element:c,isDehydrated:s,cache:r},Ad(y),t}function d0(t){return t?(t=Ui,t):Ui}function f0(t,r,s,c,p,y){p=d0(p),c.context===null?c.context=p:c.pendingContext=p,c=kl(r),c.payload={element:s},y=y===void 0?null:y,y!==null&&(c.callback=y),s=jl(t,c,r),s!==null&&(br(s,t,r),Vs(s,t,r))}function h0(t,r){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var s=t.retryLane;t.retryLane=s!==0&&s<r?s:r}}function Vf(t,r){h0(t,r),(t=t.alternate)&&h0(t,r)}function m0(t){if(t.tag===13||t.tag===31){var r=li(t,67108864);r!==null&&br(r,t,67108864),Vf(t,67108864)}}function p0(t){if(t.tag===13||t.tag===31){var r=Fr();r=$e(r);var s=li(t,r);s!==null&&br(s,t,r),Vf(t,r)}}var ou=!0;function lw(t,r,s,c){var p=Y.T;Y.T=null;var y=oe.p;try{oe.p=2,Gf(t,r,s,c)}finally{oe.p=y,Y.T=p}}function iw(t,r,s,c){var p=Y.T;Y.T=null;var y=oe.p;try{oe.p=8,Gf(t,r,s,c)}finally{oe.p=y,Y.T=p}}function Gf(t,r,s,c){if(ou){var p=Kf(c);if(p===null)zf(t,r,c,cu,s),g0(t,c);else if(ow(p,t,r,s,c))c.stopPropagation();else if(g0(t,c),r&4&&-1<sw.indexOf(t)){for(;p!==null;){var y=Ma(p);if(y!==null)switch(y.tag){case 3:if(y=y.stateNode,y.current.memoizedState.isDehydrated){var S=un(y.pendingLanes);if(S!==0){var z=y;for(z.pendingLanes|=2,z.entangledLanes|=2;S;){var V=1<<31-Ke(S);z.entanglements[1]|=V,S&=~V}ba(y),(Vt&6)===0&&(Xc=Se()+500,co(0))}}break;case 31:case 13:z=li(y,2),z!==null&&br(z,y,2),Vc(),Vf(y,2)}if(y=Kf(c),y===null&&zf(t,r,c,cu,s),y===p)break;p=y}p!==null&&c.stopPropagation()}else zf(t,r,c,null,s)}}function Kf(t){return t=fa(t),Pf(t)}var cu=null;function Pf(t){if(cu=null,t=ca(t),t!==null){var r=u(t);if(r===null)t=null;else{var s=r.tag;if(s===13){if(t=d(r),t!==null)return t;t=null}else if(s===31){if(t=f(r),t!==null)return t;t=null}else if(s===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;t=null}else r!==t&&(t=null)}}return cu=t,null}function x0(t){switch(t){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(Ne()){case K:return 2;case ue:return 8;case ne:case ve:return 32;case we:return 268435456;default:return 32}default:return 32}}var Qf=!1,zl=null,_l=null,Bl=null,go=new Map,yo=new Map,Ol=[],sw="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 g0(t,r){switch(t){case"focusin":case"focusout":zl=null;break;case"dragenter":case"dragleave":_l=null;break;case"mouseover":case"mouseout":Bl=null;break;case"pointerover":case"pointerout":go.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":yo.delete(r.pointerId)}}function bo(t,r,s,c,p,y){return t===null||t.nativeEvent!==y?(t={blockedOn:r,domEventName:s,eventSystemFlags:c,nativeEvent:y,targetContainers:[p]},r!==null&&(r=Ma(r),r!==null&&m0(r)),t):(t.eventSystemFlags|=c,r=t.targetContainers,p!==null&&r.indexOf(p)===-1&&r.push(p),t)}function ow(t,r,s,c,p){switch(r){case"focusin":return zl=bo(zl,t,r,s,c,p),!0;case"dragenter":return _l=bo(_l,t,r,s,c,p),!0;case"mouseover":return Bl=bo(Bl,t,r,s,c,p),!0;case"pointerover":var y=p.pointerId;return go.set(y,bo(go.get(y)||null,t,r,s,c,p)),!0;case"gotpointercapture":return y=p.pointerId,yo.set(y,bo(yo.get(y)||null,t,r,s,c,p)),!0}return!1}function y0(t){var r=ca(t.target);if(r!==null){var s=u(r);if(s!==null){if(r=s.tag,r===13){if(r=d(s),r!==null){t.blockedOn=r,Sn(t.priority,function(){p0(s)});return}}else if(r===31){if(r=f(s),r!==null){t.blockedOn=r,Sn(t.priority,function(){p0(s)});return}}else if(r===3&&s.stateNode.current.memoizedState.isDehydrated){t.blockedOn=s.tag===3?s.stateNode.containerInfo:null;return}}}t.blockedOn=null}function uu(t){if(t.blockedOn!==null)return!1;for(var r=t.targetContainers;0<r.length;){var s=Kf(t.nativeEvent);if(s===null){s=t.nativeEvent;var c=new s.constructor(s.type,s);_i=c,s.target.dispatchEvent(c),_i=null}else return r=Ma(s),r!==null&&m0(r),t.blockedOn=s,!1;r.shift()}return!0}function b0(t,r,s){uu(t)&&s.delete(r)}function cw(){Qf=!1,zl!==null&&uu(zl)&&(zl=null),_l!==null&&uu(_l)&&(_l=null),Bl!==null&&uu(Bl)&&(Bl=null),go.forEach(b0),yo.forEach(b0)}function du(t,r){t.blockedOn===r&&(t.blockedOn=null,Qf||(Qf=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,cw)))}var fu=null;function v0(t){fu!==t&&(fu=t,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){fu===t&&(fu=null);for(var r=0;r<t.length;r+=3){var s=t[r],c=t[r+1],p=t[r+2];if(typeof c!="function"){if(Pf(c||s)===null)continue;break}var y=Ma(s);y!==null&&(t.splice(r,3),r-=3,Gd(y,{pending:!0,data:p,method:s.method,action:c},c,p))}}))}function fs(t){function r(V){return du(V,t)}zl!==null&&du(zl,t),_l!==null&&du(_l,t),Bl!==null&&du(Bl,t),go.forEach(r),yo.forEach(r);for(var s=0;s<Ol.length;s++){var c=Ol[s];c.blockedOn===t&&(c.blockedOn=null)}for(;0<Ol.length&&(s=Ol[0],s.blockedOn===null);)y0(s),s.blockedOn===null&&Ol.shift();if(s=(t.ownerDocument||t).$$reactFormReplay,s!=null)for(c=0;c<s.length;c+=3){var p=s[c],y=s[c+1],S=p[mn]||null;if(typeof y=="function")S||v0(s);else if(S){var z=null;if(y&&y.hasAttribute("formAction")){if(p=y,S=y[mn]||null)z=S.formAction;else if(Pf(p)!==null)continue}else z=S.action;typeof z=="function"?s[c+1]=z:(s.splice(c,3),c-=3),v0(s)}}}function w0(){function t(y){y.canIntercept&&y.info==="react-transition"&&y.intercept({handler:function(){return new Promise(function(S){return p=S})},focusReset:"manual",scroll:"manual"})}function r(){p!==null&&(p(),p=null),c||setTimeout(s,20)}function s(){if(!c&&!navigation.transition){var y=navigation.currentEntry;y&&y.url!=null&&navigation.navigate(y.url,{state:y.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var c=!1,p=null;return navigation.addEventListener("navigate",t),navigation.addEventListener("navigatesuccess",r),navigation.addEventListener("navigateerror",r),setTimeout(s,100),function(){c=!0,navigation.removeEventListener("navigate",t),navigation.removeEventListener("navigatesuccess",r),navigation.removeEventListener("navigateerror",r),p!==null&&(p(),p=null)}}}function Zf(t){this._internalRoot=t}hu.prototype.render=Zf.prototype.render=function(t){var r=this._internalRoot;if(r===null)throw Error(i(409));var s=r.current,c=Fr();f0(s,c,t,r,null,null)},hu.prototype.unmount=Zf.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var r=t.containerInfo;f0(t.current,2,null,t,null,null),Vc(),r[Or]=null}};function hu(t){this._internalRoot=t}hu.prototype.unstable_scheduleHydration=function(t){if(t){var r=Pe();t={blockedOn:null,target:t,priority:r};for(var s=0;s<Ol.length&&r!==0&&r<Ol[s].priority;s++);Ol.splice(s,0,t),s===0&&y0(t)}};var k0=n.version;if(k0!=="19.2.4")throw Error(i(527,k0,"19.2.4"));oe.findDOMNode=function(t){var r=t._reactInternals;if(r===void 0)throw typeof t.render=="function"?Error(i(188)):(t=Object.keys(t).join(","),Error(i(268,t)));return t=h(r),t=t!==null?x(t):null,t=t===null?null:t.stateNode,t};var uw={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:Y,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var mu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!mu.isDisabled&&mu.supportsFiber)try{Be=mu.inject(uw),qe=mu}catch{}}return wo.createRoot=function(t,r){if(!o(t))throw Error(i(299));var s=!1,c="",p=Dx,y=Tx,S=Fx;return r!=null&&(r.unstable_strictMode===!0&&(s=!0),r.identifierPrefix!==void 0&&(c=r.identifierPrefix),r.onUncaughtError!==void 0&&(p=r.onUncaughtError),r.onCaughtError!==void 0&&(y=r.onCaughtError),r.onRecoverableError!==void 0&&(S=r.onRecoverableError)),r=u0(t,1,!1,null,null,s,c,null,p,y,S,w0),t[Or]=r.current,Rf(t),new Zf(r)},wo.hydrateRoot=function(t,r,s){if(!o(t))throw Error(i(299));var c=!1,p="",y=Dx,S=Tx,z=Fx,V=null;return s!=null&&(s.unstable_strictMode===!0&&(c=!0),s.identifierPrefix!==void 0&&(p=s.identifierPrefix),s.onUncaughtError!==void 0&&(y=s.onUncaughtError),s.onCaughtError!==void 0&&(S=s.onCaughtError),s.onRecoverableError!==void 0&&(z=s.onRecoverableError),s.formState!==void 0&&(V=s.formState)),r=u0(t,1,!0,r,s??null,c,p,V,y,S,z,w0),r.context=d0(null),s=r.current,c=Fr(),c=$e(c),p=kl(c),p.callback=null,jl(s,p,c),s=c,r.current.lanes=s,ke(r,s),ba(r),t[Or]=r.current,Rf(t),new hu(r)},wo.version="19.2.4",wo}var R0;function kw(){if(R0)return th.exports;R0=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(),th.exports=ww(),th.exports}var jw=kw();const Sw="modulepreload",Cw=function(e){return"/"+e},z0={},Ny=function(n,a,i){let o=Promise.resolve();if(a&&a.length>0){let d=function(h){return Promise.all(h.map(x=>Promise.resolve(x).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const f=document.querySelector("meta[property=csp-nonce]"),m=(f==null?void 0:f.nonce)||(f==null?void 0:f.getAttribute("nonce"));o=d(a.map(h=>{if(h=Cw(h),h in z0)return;z0[h]=!0;const x=h.endsWith(".css"),g=x?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${g}`))return;const v=document.createElement("link");if(v.rel=x?"stylesheet":Sw,x||(v.as="script"),v.crossOrigin="",v.href=h,m&&v.setAttribute("nonce",m),document.head.appendChild(v),x)return new Promise((b,j)=>{v.addEventListener("load",b),v.addEventListener("error",()=>j(new Error(`Unable to preload CSS for ${h}`)))})}))}function u(d){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=d,window.dispatchEvent(f),!f.defaultPrevented)throw d}return o.then(d=>{for(const f of d||[])f.status==="rejected"&&u(f.reason);return n().catch(u)})};class Ew extends w.Component{constructor(){super(...arguments);j0(this,"state",{hasError:!1,error:null})}static getDerivedStateFromError(a){return{hasError:!0,error:a}}render(){var a;return this.state.hasError?l.jsx("div",{className:"h-screen flex items-center justify-center bg-[var(--floor-light)]",children:l.jsxs("div",{className:"text-center max-w-md",children:[l.jsx("div",{className:"text-4xl mb-3",children:"🚨"}),l.jsx("div",{className:"text-gray-800 font-semibold mb-2",children:"Something went wrong"}),l.jsx("div",{className:"text-gray-500 text-sm mb-4",children:((a=this.state.error)==null?void 0:a.message)??"An unexpected error occurred."}),l.jsx("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 bg-gray-800 text-white rounded-lg text-sm hover:bg-gray-700",children:"Reload"})]})}):this.props.children}}const Ca="/api";async function Ut(e){const n=await fetch(`${Ca}${e}`);if(!n.ok)throw new Error(`API error: ${n.status}`);return n.json()}async function on(e,n){const a=await fetch(`${Ca}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!a.ok)throw new Error(`API error: ${a.status}`);return a.json()}async function pu(e,n){const a=await fetch(`${Ca}${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!a.ok)throw new Error(`API error: ${a.status}`);return a.json()}async function Nw(e,n){const a=await fetch(`${Ca}${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!a.ok)throw new Error(`API error: ${a.status}`);return a.json()}async function nl(e,n){const a={method:"DELETE"};n!==void 0&&(a.headers={"Content-Type":"application/json"},a.body=JSON.stringify(n));const i=await fetch(`${Ca}${e}`,a);if(!i.ok)throw new Error(`API error: ${i.status}`);return i.json()}const ye={getCompany:()=>Ut("/company"),getRoles:()=>Ut("/roles"),getRole:e=>Ut(`/roles/${e}`),getProjects:()=>Ut("/projects"),getProject:e=>Ut(`/projects/${e}`),getStandups:()=>Ut("/operations/standups"),getWaves:()=>Ut("/operations/waves"),getWaveDetail:e=>Ut(`/operations/waves/${e}`),patchWave:(e,n)=>pu(`/operations/waves/${e}`,n),getDecisions:()=>Ut("/operations/decisions"),updateDecision:(e,n)=>Nw(`/operations/decisions/${e}`,{content:n}),deleteDecision:e=>nl(`/operations/decisions/${e}`),getOrgTree:()=>Ut("/engine/org"),getSkills:()=>Ut("/skills"),exportSkills:e=>Ut(`/skills/export/${e}`),getSkillRegistry:()=>Ut("/skills/registry"),installRegistrySkill:(e,n)=>on("/skills/registry/install",{skillId:e,url:n}),createRole:e=>on("/engine/roles",e),updateRole:(e,n)=>pu(`/engine/roles/${e}`,n),deleteRole:e=>nl(`/engine/roles/${e}`),getSessions:()=>Ut("/sessions"),getSession:e=>Ut(`/sessions/${e}`),createSession:(e,n="talk")=>on("/sessions",{roleId:e,mode:n}),deleteSession:e=>nl(`/sessions/${e}`),deleteSessions:e=>nl("/sessions",{ids:e}),deleteEmptySessions:()=>nl("/sessions?empty=true"),updateSession:(e,n)=>pu(`/sessions/${e}`,n),abortSession:e=>on(`/sessions/${e}/abort`,{}),replyToSession:(e,n,a)=>on(`/sessions/${e}/reply`,{message:n,...a&&{attachments:a}}),startJob:e=>on("/jobs",e),saveWave:e=>on("/waves/save",e),getStatus:()=>Ut("/status"),detectEngine:()=>on("/setup/detect-engine",{}),validatePath:e=>on("/setup/validate-path",{path:e}),scaffold:e=>on("/setup/scaffold",e),getTeams:()=>Ut("/setup/teams"),browse:e=>on("/setup/browse",{path:e}),mkdir:(e,n)=>on("/setup/mkdir",{path:e,name:n}),connectAkb:e=>on("/setup/connect-akb",{path:e}),getRequiredTools:e=>on("/setup/required-tools",{team:e}),installTools:(e,n)=>fetch(`${Ca}/setup/install-tools`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({team:e})}).then(a=>{var f;const i=(f=a.body)==null?void 0:f.getReader();if(!i)return;const o=new TextDecoder;let u="";const d=()=>i.read().then(({done:m,value:h})=>{if(m)return;u+=o.decode(h,{stream:!0});const x=u.split(`
|
|
50
|
+
`);u=x.pop()||"";let g="";for(const v of x)if(v.startsWith("event: "))g=v.slice(7);else if(v.startsWith("data: ")&&g){try{n(g,JSON.parse(v.slice(6)))}catch{}g=""}return d()});return d()}),getKnowledge:()=>Ut("/knowledge"),getKnowledgeDoc:e=>{const n=e.split("/").map(encodeURIComponent).join("/");return Ut(`/knowledge/${n}`)},createKnowledgeDoc:e=>on("/knowledge",e),updateKnowledgeDoc:(e,n)=>{const a=e.split("/").map(encodeURIComponent).join("/");return fetch(`${Ca}/knowledge/${a}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n})}).then(i=>{if(!i.ok)throw new Error(`API error: ${i.status}`);return i.json()})},deleteKnowledgeDoc:e=>{const n=e.split("/").map(encodeURIComponent).join("/");return nl(`/knowledge/${n}`)},getPreferences:()=>Ut("/preferences"),updatePreferences:e=>pu("/preferences",e),chatInChannel:e=>on("/speech/chat",e),getSaveStatus:(e="akb")=>Ut(`/save/status?repo=${e}`),save:(e,n="akb")=>on(`/save?repo=${n}`,{message:e}),getSaveHistory:(e=20,n="akb")=>Ut(`/save/history?limit=${e}&repo=${n}`),restoreSave:(e,n,a="akb")=>on(`/save/restore?repo=${a}`,{sha:e,paths:n}),initGit:()=>on("/save/init",{}),getSyncStatus:(e="akb")=>Ut(`/save/sync-status?repo=${e}`),pull:async(e="akb")=>await(await fetch(`${Ca}/save/pull?repo=${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"})).json(),getGithubStatus:(e="akb")=>Ut(`/save/github-status?repo=${e}`),githubCreateRepo:(e,n="private",a="akb")=>on(`/save/github-create-repo?repo=${a}`,{name:e,visibility:n}),addRemote:(e,n="akb")=>on(`/save/remote?repo=${n}`,{url:e}),setCodeRoot:async e=>{const n=await fetch(`${Ca}/setup/code-root`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({codeRoot:e})}),a=await n.json();if(!n.ok)throw new Error(a.error||`API error: ${n.status}`);return a},getCodeRoot:()=>Ut("/setup/code-root"),getCostSummary:()=>Ut("/cost/summary"),getSyncRoles:()=>Ut("/sync/roles"),applySyncUpdate:e=>on("/sync/apply",e),getCompanyStats:()=>Ut("/sync/stats"),getCoins:()=>Ut("/coins"),earnCoins:(e,n,a)=>on("/coins/earn",{amount:e,reason:n,ref:a}),spendCoins:(e,n,a)=>on("/coins/spend",{amount:e,reason:n,ref:a}),migrateCoins:e=>on("/coins/migrate",{completedQuests:e}),getQuestProgress:()=>Ut("/quests/progress"),saveQuestProgress:e=>fetch(`${Ca}/quests/progress`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(n=>n.json()),getActiveSessions:()=>Ut("/active-sessions"),getActiveSession:e=>Ut(`/active-sessions/${e}`),registerActiveSession:e=>on("/active-sessions/register",e),deleteActiveSession:e=>nl(`/active-sessions/${e}`),cleanupActiveSessions:()=>on("/active-sessions/cleanup",{}),getGitStatus:()=>Ut("/git/status"),deleteWorktree:e=>nl(`/git/worktrees/${encodeURIComponent(e)}`),deleteBranch:e=>nl(`/git/branches/${encodeURIComponent(e)}`)},Aw=Object.freeze(Object.defineProperty({__proto__:null,api:ye},Symbol.toStringTag,{value:"Module"}));function Ay(e){const[n,a]=w.useState([]),[i,o]=w.useState("idle"),[u,d]=w.useState(""),[f,m]=w.useState([]),h=w.useRef(-1),x=w.useRef(null),g=w.useRef(0),v=w.useCallback(()=>{var E;if(!e)return;(E=x.current)==null||E.abort();const j=new AbortController;x.current=j,o("connecting");const k=h.current+1,N=`/api/sessions/${e}/stream?from=${k}`;fetch(N,{signal:j.signal}).then(async C=>{if(!C.ok||!C.body){o("error");return}o("streaming");const _=C.body.getReader(),R=new TextDecoder;let L="";for(;;){const{done:F,value:I}=await _.read();if(F)break;L+=R.decode(I,{stream:!0});const H=L.split(`
|
|
51
|
+
`);L=H.pop()??"";let X="";for(const A of H)if(A.startsWith("event: "))X=A.slice(7).trim();else if(A.startsWith("data: ")){try{const $=JSON.parse(A.slice(6));if(X==="activity"){const q=$;q.seq>h.current&&(h.current=q.seq),a(W=>W.some(ie=>ie.seq===q.seq)?W:[...W,q]),q.type==="text"&&d(W=>W+(q.data.text??"")),q.type==="dispatch:start"&&q.data.childJobId&&m(W=>[...W,q.data.childJobId]),q.type==="job:done"?o("done"):q.type==="job:error"&&o("error")}else if(X==="stream:end"){const q=$.reason;o(q==="done"?"done":q==="error"?"error":"done")}}catch{}X=""}}i==="streaming"&&o("done")}).catch(C=>{C.name!=="AbortError"&&(o("error"),g.current<3&&(g.current++,setTimeout(v,1e3*g.current)))})},[e]),b=w.useCallback(()=>{g.current=0,v()},[v]);return w.useEffect(()=>{if(!e){a([]),o("idle"),d(""),m([]),h.current=-1;return}return a([]),d(""),m([]),h.current=-1,g.current=0,v(),()=>{var j;(j=x.current)==null||j.abort()}},[e,v]),{events:n,status:i,textOutput:u,childJobIds:f,reconnect:b}}function Dw(e,n){const a={};return(e[e.length-1]===""?[...e,""]:e).join((a.padRight?" ":"")+","+(a.padLeft===!1?"":" ")).trim()}const Tw=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Fw=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Mw={};function _0(e,n){return(Mw.jsx?Fw:Tw).test(e)}const Rw=/[ \t\n\f\r]/g;function zw(e){return typeof e=="object"?e.type==="text"?B0(e.value):!1:B0(e)}function B0(e){return e.replace(Rw,"")===""}class Yo{constructor(n,a,i){this.normal=a,this.property=n,i&&(this.space=i)}}Yo.prototype.normal={};Yo.prototype.property={};Yo.prototype.space=void 0;function Dy(e,n){const a={},i={};for(const o of e)Object.assign(a,o.property),Object.assign(i,o.normal);return new Yo(a,i,n)}function Wh(e){return e.toLowerCase()}class kr{constructor(n,a){this.attribute=a,this.property=n}}kr.prototype.attribute="";kr.prototype.booleanish=!1;kr.prototype.boolean=!1;kr.prototype.commaOrSpaceSeparated=!1;kr.prototype.commaSeparated=!1;kr.prototype.defined=!1;kr.prototype.mustUseProperty=!1;kr.prototype.number=!1;kr.prototype.overloadedBoolean=!1;kr.prototype.property="";kr.prototype.spaceSeparated=!1;kr.prototype.space=void 0;let _w=0;const wt=Ti(),zn=Ti(),Vh=Ti(),Fe=Ti(),fn=Ti(),gs=Ti(),Mr=Ti();function Ti(){return 2**++_w}const Gh=Object.freeze(Object.defineProperty({__proto__:null,boolean:wt,booleanish:zn,commaOrSpaceSeparated:Mr,commaSeparated:gs,number:Fe,overloadedBoolean:Vh,spaceSeparated:fn},Symbol.toStringTag,{value:"Module"})),lh=Object.keys(Gh);class jm extends kr{constructor(n,a,i,o){let u=-1;if(super(n,a),O0(this,"space",o),typeof i=="number")for(;++u<lh.length;){const d=lh[u];O0(this,lh[u],(i&Gh[d])===Gh[d])}}}jm.prototype.defined=!0;function O0(e,n,a){a&&(e[n]=a)}function Ss(e){const n={},a={};for(const[i,o]of Object.entries(e.properties)){const u=new jm(i,e.transform(e.attributes||{},i),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(i)&&(u.mustUseProperty=!0),n[i]=u,a[Wh(i)]=i,a[Wh(u.attribute)]=i}return new Yo(n,a,e.space)}const Ty=Ss({properties:{ariaActiveDescendant:null,ariaAtomic:zn,ariaAutoComplete:null,ariaBusy:zn,ariaChecked:zn,ariaColCount:Fe,ariaColIndex:Fe,ariaColSpan:Fe,ariaControls:fn,ariaCurrent:null,ariaDescribedBy:fn,ariaDetails:null,ariaDisabled:zn,ariaDropEffect:fn,ariaErrorMessage:null,ariaExpanded:zn,ariaFlowTo:fn,ariaGrabbed:zn,ariaHasPopup:null,ariaHidden:zn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:fn,ariaLevel:Fe,ariaLive:null,ariaModal:zn,ariaMultiLine:zn,ariaMultiSelectable:zn,ariaOrientation:null,ariaOwns:fn,ariaPlaceholder:null,ariaPosInSet:Fe,ariaPressed:zn,ariaReadOnly:zn,ariaRelevant:null,ariaRequired:zn,ariaRoleDescription:fn,ariaRowCount:Fe,ariaRowIndex:Fe,ariaRowSpan:Fe,ariaSelected:zn,ariaSetSize:Fe,ariaSort:null,ariaValueMax:Fe,ariaValueMin:Fe,ariaValueNow:Fe,ariaValueText:null,role:null},transform(e,n){return n==="role"?n:"aria-"+n.slice(4).toLowerCase()}});function Fy(e,n){return n in e?e[n]:n}function My(e,n){return Fy(e,n.toLowerCase())}const Bw=Ss({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:gs,acceptCharset:fn,accessKey:fn,action:null,allow:null,allowFullScreen:wt,allowPaymentRequest:wt,allowUserMedia:wt,alt:null,as:null,async:wt,autoCapitalize:null,autoComplete:fn,autoFocus:wt,autoPlay:wt,blocking:fn,capture:null,charSet:null,checked:wt,cite:null,className:fn,cols:Fe,colSpan:null,content:null,contentEditable:zn,controls:wt,controlsList:fn,coords:Fe|gs,crossOrigin:null,data:null,dateTime:null,decoding:null,default:wt,defer:wt,dir:null,dirName:null,disabled:wt,download:Vh,draggable:zn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:wt,formTarget:null,headers:fn,height:Fe,hidden:Vh,high:Fe,href:null,hrefLang:null,htmlFor:fn,httpEquiv:fn,id:null,imageSizes:null,imageSrcSet:null,inert:wt,inputMode:null,integrity:null,is:null,isMap:wt,itemId:null,itemProp:fn,itemRef:fn,itemScope:wt,itemType:fn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:wt,low:Fe,manifest:null,max:null,maxLength:Fe,media:null,method:null,min:null,minLength:Fe,multiple:wt,muted:wt,name:null,nonce:null,noModule:wt,noValidate:wt,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:wt,optimum:Fe,pattern:null,ping:fn,placeholder:null,playsInline:wt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:wt,referrerPolicy:null,rel:fn,required:wt,reversed:wt,rows:Fe,rowSpan:Fe,sandbox:fn,scope:null,scoped:wt,seamless:wt,selected:wt,shadowRootClonable:wt,shadowRootDelegatesFocus:wt,shadowRootMode:null,shape:null,size:Fe,sizes:null,slot:null,span:Fe,spellCheck:zn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Fe,step:null,style:null,tabIndex:Fe,target:null,title:null,translate:null,type:null,typeMustMatch:wt,useMap:null,value:zn,width:Fe,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:fn,axis:null,background:null,bgColor:null,border:Fe,borderColor:null,bottomMargin:Fe,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:wt,declare:wt,event:null,face:null,frame:null,frameBorder:null,hSpace:Fe,leftMargin:Fe,link:null,longDesc:null,lowSrc:null,marginHeight:Fe,marginWidth:Fe,noResize:wt,noHref:wt,noShade:wt,noWrap:wt,object:null,profile:null,prompt:null,rev:null,rightMargin:Fe,rules:null,scheme:null,scrolling:zn,standby:null,summary:null,text:null,topMargin:Fe,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Fe,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:wt,disableRemotePlayback:wt,prefix:null,property:null,results:Fe,security:null,unselectable:null},space:"html",transform:My}),Ow=Ss({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:Mr,accentHeight:Fe,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Fe,amplitude:Fe,arabicForm:null,ascent:Fe,attributeName:null,attributeType:null,azimuth:Fe,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Fe,by:null,calcMode:null,capHeight:Fe,className:fn,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:Fe,diffuseConstant:Fe,direction:null,display:null,dur:null,divisor:Fe,dominantBaseline:null,download:wt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Fe,enableBackground:null,end:null,event:null,exponent:Fe,externalResourcesRequired:null,fill:null,fillOpacity:Fe,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:gs,g2:gs,glyphName:gs,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Fe,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Fe,horizOriginX:Fe,horizOriginY:Fe,id:null,ideographic:Fe,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Fe,k:Fe,k1:Fe,k2:Fe,k3:Fe,k4:Fe,kernelMatrix:Mr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Fe,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:Fe,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:Fe,overlineThickness:Fe,paintOrder:null,panose1:null,path:null,pathLength:Fe,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:fn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Fe,pointsAtY:Fe,pointsAtZ:Fe,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Mr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Mr,rev:Mr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Mr,requiredFeatures:Mr,requiredFonts:Mr,requiredFormats:Mr,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:Fe,specularExponent:Fe,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Fe,strikethroughThickness:Fe,string:null,stroke:null,strokeDashArray:Mr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Fe,strokeOpacity:Fe,strokeWidth:null,style:null,surfaceScale:Fe,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Mr,tabIndex:Fe,tableValues:null,target:null,targetX:Fe,targetY:Fe,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Mr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Fe,underlineThickness:Fe,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Fe,values:null,vAlphabetic:Fe,vMathematical:Fe,vectorEffect:null,vHanging:Fe,vIdeographic:Fe,version:null,vertAdvY:Fe,vertOriginX:Fe,vertOriginY:Fe,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Fe,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Fy}),Ry=Ss({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()}}),zy=Ss({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:My}),_y=Ss({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,n){return"xml:"+n.slice(3).toLowerCase()}}),$w={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"},Lw=/[A-Z]/g,$0=/-[a-z]/g,Iw=/^data[-\w.:]+$/i;function Hw(e,n){const a=Wh(n);let i=n,o=kr;if(a in e.normal)return e.property[e.normal[a]];if(a.length>4&&a.slice(0,4)==="data"&&Iw.test(n)){if(n.charAt(4)==="-"){const u=n.slice(5).replace($0,qw);i="data"+u.charAt(0).toUpperCase()+u.slice(1)}else{const u=n.slice(4);if(!$0.test(u)){let d=u.replace(Lw,Uw);d.charAt(0)!=="-"&&(d="-"+d),n="data"+d}}o=jm}return new o(i,n)}function Uw(e){return"-"+e.toLowerCase()}function qw(e){return e.charAt(1).toUpperCase()}const Yw=Dy([Ty,Bw,Ry,zy,_y],"html"),Sm=Dy([Ty,Ow,Ry,zy,_y],"svg");function Xw(e){return e.join(" ").trim()}var hs={},ih,L0;function Ww(){if(L0)return ih;L0=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,n=/\n/g,a=/^\s*/,i=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,u=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,d=/^[;\s]*/,f=/^\s+|\s+$/g,m=`
|
|
52
|
+
`,h="/",x="*",g="",v="comment",b="declaration";function j(N,E){if(typeof N!="string")throw new TypeError("First argument must be a string");if(!N)return[];E=E||{};var C=1,_=1;function R(ie){var P=ie.match(n);P&&(C+=P.length);var Y=ie.lastIndexOf(m);_=~Y?ie.length-Y:_+ie.length}function L(){var ie={line:C,column:_};return function(P){return P.position=new F(ie),X(),P}}function F(ie){this.start=ie,this.end={line:C,column:_},this.source=E.source}F.prototype.content=N;function I(ie){var P=new Error(E.source+":"+C+":"+_+": "+ie);if(P.reason=ie,P.filename=E.source,P.line=C,P.column=_,P.source=N,!E.silent)throw P}function H(ie){var P=ie.exec(N);if(P){var Y=P[0];return R(Y),N=N.slice(Y.length),P}}function X(){H(a)}function A(ie){var P;for(ie=ie||[];P=$();)P!==!1&&ie.push(P);return ie}function $(){var ie=L();if(!(h!=N.charAt(0)||x!=N.charAt(1))){for(var P=2;g!=N.charAt(P)&&(x!=N.charAt(P)||h!=N.charAt(P+1));)++P;if(P+=2,g===N.charAt(P-1))return I("End of comment missing");var Y=N.slice(2,P-2);return _+=2,R(Y),N=N.slice(P),_+=2,ie({type:v,comment:Y})}}function q(){var ie=L(),P=H(i);if(P){if($(),!H(o))return I("property missing ':'");var Y=H(u),oe=ie({type:b,property:k(P[0].replace(e,g)),value:Y?k(Y[0].replace(e,g)):g});return H(d),oe}}function W(){var ie=[];A(ie);for(var P;P=q();)P!==!1&&(ie.push(P),A(ie));return ie}return X(),W()}function k(N){return N?N.replace(f,g):g}return ih=j,ih}var I0;function Vw(){if(I0)return hs;I0=1;var e=hs&&hs.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(hs,"__esModule",{value:!0}),hs.default=a;const n=e(Ww());function a(i,o){let u=null;if(!i||typeof i!="string")return u;const d=(0,n.default)(i),f=typeof o=="function";return d.forEach(m=>{if(m.type!=="declaration")return;const{property:h,value:x}=m;f?o(h,x,m):x&&(u=u||{},u[h]=x)}),u}return hs}var ko={},H0;function Gw(){if(H0)return ko;H0=1,Object.defineProperty(ko,"__esModule",{value:!0}),ko.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,a=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,o=/^-(ms)-/,u=function(h){return!h||a.test(h)||e.test(h)},d=function(h,x){return x.toUpperCase()},f=function(h,x){return"".concat(x,"-")},m=function(h,x){return x===void 0&&(x={}),u(h)?h:(h=h.toLowerCase(),x.reactCompat?h=h.replace(o,f):h=h.replace(i,f),h.replace(n,d))};return ko.camelCase=m,ko}var jo,U0;function Kw(){if(U0)return jo;U0=1;var e=jo&&jo.__importDefault||function(o){return o&&o.__esModule?o:{default:o}},n=e(Vw()),a=Gw();function i(o,u){var d={};return!o||typeof o!="string"||(0,n.default)(o,function(f,m){f&&m&&(d[(0,a.camelCase)(f,u)]=m)}),d}return i.default=i,jo=i,jo}var Pw=Kw();const Qw=Ey(Pw),By=Oy("end"),Cm=Oy("start");function Oy(e){return n;function n(a){const i=a&&a.position&&a.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 Zw(e){const n=Cm(e),a=By(e);if(n&&a)return{start:n,end:a}}function _o(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?q0(e.position):"start"in e||"end"in e?q0(e):"line"in e||"column"in e?Kh(e):""}function Kh(e){return Y0(e&&e.line)+":"+Y0(e&&e.column)}function q0(e){return Kh(e&&e.start)+"-"+Kh(e&&e.end)}function Y0(e){return e&&typeof e=="number"?e:1}class ar extends Error{constructor(n,a,i){super(),typeof a=="string"&&(i=a,a=void 0);let o="",u={},d=!1;if(a&&("line"in a&&"column"in a?u={place:a}:"start"in a&&"end"in a?u={place:a}:"type"in a?u={ancestors:[a],place:a.position}:u={...a}),typeof n=="string"?o=n:!u.cause&&n&&(d=!0,o=n.message,u.cause=n),!u.ruleId&&!u.source&&typeof i=="string"){const m=i.indexOf(":");m===-1?u.ruleId=i:(u.source=i.slice(0,m),u.ruleId=i.slice(m+1))}if(!u.place&&u.ancestors&&u.ancestors){const m=u.ancestors[u.ancestors.length-1];m&&(u.place=m.position)}const f=u.place&&"start"in u.place?u.place.start:u.place;this.ancestors=u.ancestors||void 0,this.cause=u.cause||void 0,this.column=f?f.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=f?f.line:void 0,this.name=_o(u.place)||"1:1",this.place=u.place||void 0,this.reason=this.message,this.ruleId=u.ruleId||void 0,this.source=u.source||void 0,this.stack=d&&u.cause&&typeof u.cause.stack=="string"?u.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}ar.prototype.file="";ar.prototype.name="";ar.prototype.reason="";ar.prototype.message="";ar.prototype.stack="";ar.prototype.column=void 0;ar.prototype.line=void 0;ar.prototype.ancestors=void 0;ar.prototype.cause=void 0;ar.prototype.fatal=void 0;ar.prototype.place=void 0;ar.prototype.ruleId=void 0;ar.prototype.source=void 0;const Em={}.hasOwnProperty,Jw=new Map,e5=/[A-Z]/g,t5=new Set(["table","tbody","thead","tfoot","tr"]),n5=new Set(["td","th"]),$y="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function r5(e,n){if(!n||n.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const a=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=d5(a,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=u5(a,n.jsx,n.jsxs)}const o={Fragment:n.Fragment,ancestors:[],components:n.components||{},create:i,elementAttributeNameCase:n.elementAttributeNameCase||"react",evaluater:n.createEvaluater?n.createEvaluater():void 0,filePath:a,ignoreInvalidStyle:n.ignoreInvalidStyle||!1,passKeys:n.passKeys!==!1,passNode:n.passNode||!1,schema:n.space==="svg"?Sm:Yw,stylePropertyNameCase:n.stylePropertyNameCase||"dom",tableCellAlignToStyle:n.tableCellAlignToStyle!==!1},u=Ly(o,e,void 0);return u&&typeof u!="string"?u:o.create(e,o.Fragment,{children:u||void 0},void 0)}function Ly(e,n,a){if(n.type==="element")return a5(e,n,a);if(n.type==="mdxFlowExpression"||n.type==="mdxTextExpression")return l5(e,n);if(n.type==="mdxJsxFlowElement"||n.type==="mdxJsxTextElement")return s5(e,n,a);if(n.type==="mdxjsEsm")return i5(e,n);if(n.type==="root")return o5(e,n,a);if(n.type==="text")return c5(e,n)}function a5(e,n,a){const i=e.schema;let o=i;n.tagName.toLowerCase()==="svg"&&i.space==="html"&&(o=Sm,e.schema=o),e.ancestors.push(n);const u=Hy(e,n.tagName,!1),d=f5(e,n);let f=Am(e,n);return t5.has(n.tagName)&&(f=f.filter(function(m){return typeof m=="string"?!zw(m):!0})),Iy(e,d,u,n),Nm(d,f),e.ancestors.pop(),e.schema=i,e.create(n,u,d,a)}function l5(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)}Lo(e,n.position)}function i5(e,n){if(n.data&&n.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(n.data.estree);Lo(e,n.position)}function s5(e,n,a){const i=e.schema;let o=i;n.name==="svg"&&i.space==="html"&&(o=Sm,e.schema=o),e.ancestors.push(n);const u=n.name===null?e.Fragment:Hy(e,n.name,!0),d=h5(e,n),f=Am(e,n);return Iy(e,d,u,n),Nm(d,f),e.ancestors.pop(),e.schema=i,e.create(n,u,d,a)}function o5(e,n,a){const i={};return Nm(i,Am(e,n)),e.create(n,e.Fragment,i,a)}function c5(e,n){return n.value}function Iy(e,n,a,i){typeof a!="string"&&a!==e.Fragment&&e.passNode&&(n.node=i)}function Nm(e,n){if(n.length>0){const a=n.length>1?n:n[0];a&&(e.children=a)}}function u5(e,n,a){return i;function i(o,u,d,f){const h=Array.isArray(d.children)?a:n;return f?h(u,d,f):h(u,d)}}function d5(e,n){return a;function a(i,o,u,d){const f=Array.isArray(u.children),m=Cm(i);return n(o,u,d,f,{columnNumber:m?m.column-1:void 0,fileName:e,lineNumber:m?m.line:void 0},void 0)}}function f5(e,n){const a={};let i,o;for(o in n.properties)if(o!=="children"&&Em.call(n.properties,o)){const u=m5(e,o,n.properties[o]);if(u){const[d,f]=u;e.tableCellAlignToStyle&&d==="align"&&typeof f=="string"&&n5.has(n.tagName)?i=f:a[d]=f}}if(i){const u=a.style||(a.style={});u[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=i}return a}function h5(e,n){const a={};for(const i of n.attributes)if(i.type==="mdxJsxExpressionAttribute")if(i.data&&i.data.estree&&e.evaluater){const u=i.data.estree.body[0];u.type;const d=u.expression;d.type;const f=d.properties[0];f.type,Object.assign(a,e.evaluater.evaluateExpression(f.argument))}else Lo(e,n.position);else{const o=i.name;let u;if(i.value&&typeof i.value=="object")if(i.value.data&&i.value.data.estree&&e.evaluater){const f=i.value.data.estree.body[0];f.type,u=e.evaluater.evaluateExpression(f.expression)}else Lo(e,n.position);else u=i.value===null?!0:i.value;a[o]=u}return a}function Am(e,n){const a=[];let i=-1;const o=e.passKeys?new Map:Jw;for(;++i<n.children.length;){const u=n.children[i];let d;if(e.passKeys){const m=u.type==="element"?u.tagName:u.type==="mdxJsxFlowElement"||u.type==="mdxJsxTextElement"?u.name:void 0;if(m){const h=o.get(m)||0;d=m+"-"+h,o.set(m,h+1)}}const f=Ly(e,u,d);f!==void 0&&a.push(f)}return a}function m5(e,n,a){const i=Hw(e.schema,n);if(!(a==null||typeof a=="number"&&Number.isNaN(a))){if(Array.isArray(a)&&(a=i.commaSeparated?Dw(a):Xw(a)),i.property==="style"){let o=typeof a=="object"?a:p5(e,String(a));return e.stylePropertyNameCase==="css"&&(o=x5(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&i.space?$w[i.property]||i.property:i.attribute,a]}}function p5(e,n){try{return Qw(n,{reactCompat:!0})}catch(a){if(e.ignoreInvalidStyle)return{};const i=a,o=new ar("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:i,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw o.file=e.filePath||void 0,o.url=$y+"#cannot-parse-style-attribute",o}}function Hy(e,n,a){let i;if(!a)i={type:"Literal",value:n};else if(n.includes(".")){const o=n.split(".");let u=-1,d;for(;++u<o.length;){const f=_0(o[u])?{type:"Identifier",name:o[u]}:{type:"Literal",value:o[u]};d=d?{type:"MemberExpression",object:d,property:f,computed:!!(u&&f.type==="Literal"),optional:!1}:f}i=d}else i=_0(n)&&!/^[a-z]/.test(n)?{type:"Identifier",name:n}:{type:"Literal",value:n};if(i.type==="Literal"){const o=i.value;return Em.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(i);Lo(e)}function Lo(e,n){const a=new ar("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:n,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw a.file=e.filePath||void 0,a.url=$y+"#cannot-handle-mdx-estrees-without-createevaluater",a}function x5(e){const n={};let a;for(a in e)Em.call(e,a)&&(n[g5(a)]=e[a]);return n}function g5(e){let n=e.replace(e5,y5);return n.slice(0,3)==="ms-"&&(n="-"+n),n}function y5(e){return"-"+e.toLowerCase()}const sh={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"]},b5={};function Dm(e,n){const a=b5,i=typeof a.includeImageAlt=="boolean"?a.includeImageAlt:!0,o=typeof a.includeHtml=="boolean"?a.includeHtml:!0;return Uy(e,i,o)}function Uy(e,n,a){if(v5(e)){if("value"in e)return e.type==="html"&&!a?"":e.value;if(n&&"alt"in e&&e.alt)return e.alt;if("children"in e)return X0(e.children,n,a)}return Array.isArray(e)?X0(e,n,a):""}function X0(e,n,a){const i=[];let o=-1;for(;++o<e.length;)i[o]=Uy(e[o],n,a);return i.join("")}function v5(e){return!!(e&&typeof e=="object")}const W0=document.createElement("i");function Tm(e){const n="&"+e+";";W0.innerHTML=n;const a=W0.textContent;return a.charCodeAt(a.length-1)===59&&e!=="semi"||a===n?!1:a}function Br(e,n,a,i){const o=e.length;let u=0,d;if(n<0?n=-n>o?0:o+n:n=n>o?o:n,a=a>0?a:0,i.length<1e4)d=Array.from(i),d.unshift(n,a),e.splice(...d);else for(a&&e.splice(n,a);u<i.length;)d=i.slice(u,u+1e4),d.unshift(n,0),e.splice(...d),u+=1e4,n+=1e4}function Qr(e,n){return e.length>0?(Br(e,e.length,0,n),e):n}const V0={}.hasOwnProperty;function qy(e){const n={};let a=-1;for(;++a<e.length;)w5(n,e[a]);return n}function w5(e,n){let a;for(a in n){const o=(V0.call(e,a)?e[a]:void 0)||(e[a]={}),u=n[a];let d;if(u)for(d in u){V0.call(o,d)||(o[d]=[]);const f=u[d];k5(o[d],Array.isArray(f)?f:f?[f]:[])}}}function k5(e,n){let a=-1;const i=[];for(;++a<n.length;)(n[a].add==="after"?e:i).push(n[a]);Br(e,0,0,i)}function Yy(e,n){const a=Number.parseInt(e,n);return a<9||a===11||a>13&&a<32||a>126&&a<160||a>55295&&a<57344||a>64975&&a<65008||(a&65535)===65535||(a&65535)===65534||a>1114111?"�":String.fromCodePoint(a)}function oa(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const cr=Gl(/[A-Za-z]/),rr=Gl(/[\dA-Za-z]/),j5=Gl(/[#-'*+\--9=?A-Z^-~]/);function $u(e){return e!==null&&(e<32||e===127)}const Ph=Gl(/\d/),S5=Gl(/[\dA-Fa-f]/),C5=Gl(/[!-/:-@[-`{-~]/);function lt(e){return e!==null&&e<-2}function cn(e){return e!==null&&(e<0||e===32)}function Dt(e){return e===-2||e===-1||e===32}const Ku=Gl(new RegExp("\\p{P}|\\p{S}","u")),Ai=Gl(/\s/);function Gl(e){return n;function n(a){return a!==null&&a>-1&&e.test(String.fromCharCode(a))}}function Cs(e){const n=[];let a=-1,i=0,o=0;for(;++a<e.length;){const u=e.charCodeAt(a);let d="";if(u===37&&rr(e.charCodeAt(a+1))&&rr(e.charCodeAt(a+2)))o=2;else if(u<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(u))||(d=String.fromCharCode(u));else if(u>55295&&u<57344){const f=e.charCodeAt(a+1);u<56320&&f>56319&&f<57344?(d=String.fromCharCode(u,f),o=1):d="�"}else d=String.fromCharCode(u);d&&(n.push(e.slice(i,a),encodeURIComponent(d)),i=a+o+1,d=""),o&&(a+=o,o=0)}return n.join("")+e.slice(i)}function Ht(e,n,a,i){const o=i?i-1:Number.POSITIVE_INFINITY;let u=0;return d;function d(m){return Dt(m)?(e.enter(a),f(m)):n(m)}function f(m){return Dt(m)&&u++<o?(e.consume(m),f):(e.exit(a),n(m))}}const E5={tokenize:N5};function N5(e){const n=e.attempt(this.parser.constructs.contentInitial,i,o);let a;return n;function i(f){if(f===null){e.consume(f);return}return e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),Ht(e,n,"linePrefix")}function o(f){return e.enter("paragraph"),u(f)}function u(f){const m=e.enter("chunkText",{contentType:"text",previous:a});return a&&(a.next=m),a=m,d(f)}function d(f){if(f===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(f);return}return lt(f)?(e.consume(f),e.exit("chunkText"),u):(e.consume(f),d)}}const A5={tokenize:D5},G0={tokenize:T5};function D5(e){const n=this,a=[];let i=0,o,u,d;return f;function f(_){if(i<a.length){const R=a[i];return n.containerState=R[1],e.attempt(R[0].continuation,m,h)(_)}return h(_)}function m(_){if(i++,n.containerState._closeFlow){n.containerState._closeFlow=void 0,o&&C();const R=n.events.length;let L=R,F;for(;L--;)if(n.events[L][0]==="exit"&&n.events[L][1].type==="chunkFlow"){F=n.events[L][1].end;break}E(i);let I=R;for(;I<n.events.length;)n.events[I][1].end={...F},I++;return Br(n.events,L+1,0,n.events.slice(R)),n.events.length=I,h(_)}return f(_)}function h(_){if(i===a.length){if(!o)return v(_);if(o.currentConstruct&&o.currentConstruct.concrete)return j(_);n.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return n.containerState={},e.check(G0,x,g)(_)}function x(_){return o&&C(),E(i),v(_)}function g(_){return n.parser.lazy[n.now().line]=i!==a.length,d=n.now().offset,j(_)}function v(_){return n.containerState={},e.attempt(G0,b,j)(_)}function b(_){return i++,a.push([n.currentConstruct,n.containerState]),v(_)}function j(_){if(_===null){o&&C(),E(0),e.consume(_);return}return o=o||n.parser.flow(n.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:u}),k(_)}function k(_){if(_===null){N(e.exit("chunkFlow"),!0),E(0),e.consume(_);return}return lt(_)?(e.consume(_),N(e.exit("chunkFlow")),i=0,n.interrupt=void 0,f):(e.consume(_),k)}function N(_,R){const L=n.sliceStream(_);if(R&&L.push(null),_.previous=u,u&&(u.next=_),u=_,o.defineSkip(_.start),o.write(L),n.parser.lazy[_.start.line]){let F=o.events.length;for(;F--;)if(o.events[F][1].start.offset<d&&(!o.events[F][1].end||o.events[F][1].end.offset>d))return;const I=n.events.length;let H=I,X,A;for(;H--;)if(n.events[H][0]==="exit"&&n.events[H][1].type==="chunkFlow"){if(X){A=n.events[H][1].end;break}X=!0}for(E(i),F=I;F<n.events.length;)n.events[F][1].end={...A},F++;Br(n.events,H+1,0,n.events.slice(I)),n.events.length=F}}function E(_){let R=a.length;for(;R-- >_;){const L=a[R];n.containerState=L[1],L[0].exit.call(n,e)}a.length=_}function C(){o.write([null]),u=void 0,o=void 0,n.containerState._closeFlow=void 0}}function T5(e,n,a){return Ht(e,e.attempt(this.parser.constructs.document,n,a),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function bs(e){if(e===null||cn(e)||Ai(e))return 1;if(Ku(e))return 2}function Pu(e,n,a){const i=[];let o=-1;for(;++o<e.length;){const u=e[o].resolveAll;u&&!i.includes(u)&&(n=u(n,a),i.push(u))}return n}const Qh={name:"attention",resolveAll:F5,tokenize:M5};function F5(e,n){let a=-1,i,o,u,d,f,m,h,x;for(;++a<e.length;)if(e[a][0]==="enter"&&e[a][1].type==="attentionSequence"&&e[a][1]._close){for(i=a;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[a][1]).charCodeAt(0)){if((e[i][1]._close||e[a][1]._open)&&(e[a][1].end.offset-e[a][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[a][1].end.offset-e[a][1].start.offset)%3))continue;m=e[i][1].end.offset-e[i][1].start.offset>1&&e[a][1].end.offset-e[a][1].start.offset>1?2:1;const g={...e[i][1].end},v={...e[a][1].start};K0(g,-m),K0(v,m),d={type:m>1?"strongSequence":"emphasisSequence",start:g,end:{...e[i][1].end}},f={type:m>1?"strongSequence":"emphasisSequence",start:{...e[a][1].start},end:v},u={type:m>1?"strongText":"emphasisText",start:{...e[i][1].end},end:{...e[a][1].start}},o={type:m>1?"strong":"emphasis",start:{...d.start},end:{...f.end}},e[i][1].end={...d.start},e[a][1].start={...f.end},h=[],e[i][1].end.offset-e[i][1].start.offset&&(h=Qr(h,[["enter",e[i][1],n],["exit",e[i][1],n]])),h=Qr(h,[["enter",o,n],["enter",d,n],["exit",d,n],["enter",u,n]]),h=Qr(h,Pu(n.parser.constructs.insideSpan.null,e.slice(i+1,a),n)),h=Qr(h,[["exit",u,n],["enter",f,n],["exit",f,n],["exit",o,n]]),e[a][1].end.offset-e[a][1].start.offset?(x=2,h=Qr(h,[["enter",e[a][1],n],["exit",e[a][1],n]])):x=0,Br(e,i-1,a-i+3,h),a=i+h.length-x-2;break}}for(a=-1;++a<e.length;)e[a][1].type==="attentionSequence"&&(e[a][1].type="data");return e}function M5(e,n){const a=this.parser.constructs.attentionMarkers.null,i=this.previous,o=bs(i);let u;return d;function d(m){return u=m,e.enter("attentionSequence"),f(m)}function f(m){if(m===u)return e.consume(m),f;const h=e.exit("attentionSequence"),x=bs(m),g=!x||x===2&&o||a.includes(m),v=!o||o===2&&x||a.includes(i);return h._open=!!(u===42?g:g&&(o||!v)),h._close=!!(u===42?v:v&&(x||!g)),n(m)}}function K0(e,n){e.column+=n,e.offset+=n,e._bufferIndex+=n}const R5={name:"autolink",tokenize:z5};function z5(e,n,a){let i=0;return o;function o(b){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),u}function u(b){return cr(b)?(e.consume(b),d):b===64?a(b):h(b)}function d(b){return b===43||b===45||b===46||rr(b)?(i=1,f(b)):h(b)}function f(b){return b===58?(e.consume(b),i=0,m):(b===43||b===45||b===46||rr(b))&&i++<32?(e.consume(b),f):(i=0,h(b))}function m(b){return b===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.exit("autolink"),n):b===null||b===32||b===60||$u(b)?a(b):(e.consume(b),m)}function h(b){return b===64?(e.consume(b),x):j5(b)?(e.consume(b),h):a(b)}function x(b){return rr(b)?g(b):a(b)}function g(b){return b===46?(e.consume(b),i=0,x):b===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.exit("autolink"),n):v(b)}function v(b){if((b===45||rr(b))&&i++<63){const j=b===45?v:g;return e.consume(b),j}return a(b)}}const Xo={partial:!0,tokenize:_5};function _5(e,n,a){return i;function i(u){return Dt(u)?Ht(e,o,"linePrefix")(u):o(u)}function o(u){return u===null||lt(u)?n(u):a(u)}}const Xy={continuation:{tokenize:O5},exit:$5,name:"blockQuote",tokenize:B5};function B5(e,n,a){const i=this;return o;function o(d){if(d===62){const f=i.containerState;return f.open||(e.enter("blockQuote",{_container:!0}),f.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(d),e.exit("blockQuoteMarker"),u}return a(d)}function u(d){return Dt(d)?(e.enter("blockQuotePrefixWhitespace"),e.consume(d),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),n):(e.exit("blockQuotePrefix"),n(d))}}function O5(e,n,a){const i=this;return o;function o(d){return Dt(d)?Ht(e,u,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(d):u(d)}function u(d){return e.attempt(Xy,n,a)(d)}}function $5(e){e.exit("blockQuote")}const Wy={name:"characterEscape",tokenize:L5};function L5(e,n,a){return i;function i(u){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(u),e.exit("escapeMarker"),o}function o(u){return C5(u)?(e.enter("characterEscapeValue"),e.consume(u),e.exit("characterEscapeValue"),e.exit("characterEscape"),n):a(u)}}const Vy={name:"characterReference",tokenize:I5};function I5(e,n,a){const i=this;let o=0,u,d;return f;function f(g){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),m}function m(g){return g===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(g),e.exit("characterReferenceMarkerNumeric"),h):(e.enter("characterReferenceValue"),u=31,d=rr,x(g))}function h(g){return g===88||g===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(g),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),u=6,d=S5,x):(e.enter("characterReferenceValue"),u=7,d=Ph,x(g))}function x(g){if(g===59&&o){const v=e.exit("characterReferenceValue");return d===rr&&!Tm(i.sliceSerialize(v))?a(g):(e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),e.exit("characterReference"),n)}return d(g)&&o++<u?(e.consume(g),x):a(g)}}const P0={partial:!0,tokenize:U5},Q0={concrete:!0,name:"codeFenced",tokenize:H5};function H5(e,n,a){const i=this,o={partial:!0,tokenize:L};let u=0,d=0,f;return m;function m(F){return h(F)}function h(F){const I=i.events[i.events.length-1];return u=I&&I[1].type==="linePrefix"?I[2].sliceSerialize(I[1],!0).length:0,f=F,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),x(F)}function x(F){return F===f?(d++,e.consume(F),x):d<3?a(F):(e.exit("codeFencedFenceSequence"),Dt(F)?Ht(e,g,"whitespace")(F):g(F))}function g(F){return F===null||lt(F)?(e.exit("codeFencedFence"),i.interrupt?n(F):e.check(P0,k,R)(F)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),v(F))}function v(F){return F===null||lt(F)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),g(F)):Dt(F)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ht(e,b,"whitespace")(F)):F===96&&F===f?a(F):(e.consume(F),v)}function b(F){return F===null||lt(F)?g(F):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),j(F))}function j(F){return F===null||lt(F)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),g(F)):F===96&&F===f?a(F):(e.consume(F),j)}function k(F){return e.attempt(o,R,N)(F)}function N(F){return e.enter("lineEnding"),e.consume(F),e.exit("lineEnding"),E}function E(F){return u>0&&Dt(F)?Ht(e,C,"linePrefix",u+1)(F):C(F)}function C(F){return F===null||lt(F)?e.check(P0,k,R)(F):(e.enter("codeFlowValue"),_(F))}function _(F){return F===null||lt(F)?(e.exit("codeFlowValue"),C(F)):(e.consume(F),_)}function R(F){return e.exit("codeFenced"),n(F)}function L(F,I,H){let X=0;return A;function A(P){return F.enter("lineEnding"),F.consume(P),F.exit("lineEnding"),$}function $(P){return F.enter("codeFencedFence"),Dt(P)?Ht(F,q,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):q(P)}function q(P){return P===f?(F.enter("codeFencedFenceSequence"),W(P)):H(P)}function W(P){return P===f?(X++,F.consume(P),W):X>=d?(F.exit("codeFencedFenceSequence"),Dt(P)?Ht(F,ie,"whitespace")(P):ie(P)):H(P)}function ie(P){return P===null||lt(P)?(F.exit("codeFencedFence"),I(P)):H(P)}}}function U5(e,n,a){const i=this;return o;function o(d){return d===null?a(d):(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),u)}function u(d){return i.parser.lazy[i.now().line]?a(d):n(d)}}const oh={name:"codeIndented",tokenize:Y5},q5={partial:!0,tokenize:X5};function Y5(e,n,a){const i=this;return o;function o(h){return e.enter("codeIndented"),Ht(e,u,"linePrefix",5)(h)}function u(h){const x=i.events[i.events.length-1];return x&&x[1].type==="linePrefix"&&x[2].sliceSerialize(x[1],!0).length>=4?d(h):a(h)}function d(h){return h===null?m(h):lt(h)?e.attempt(q5,d,m)(h):(e.enter("codeFlowValue"),f(h))}function f(h){return h===null||lt(h)?(e.exit("codeFlowValue"),d(h)):(e.consume(h),f)}function m(h){return e.exit("codeIndented"),n(h)}}function X5(e,n,a){const i=this;return o;function o(d){return i.parser.lazy[i.now().line]?a(d):lt(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),o):Ht(e,u,"linePrefix",5)(d)}function u(d){const f=i.events[i.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?n(d):lt(d)?o(d):a(d)}}const W5={name:"codeText",previous:G5,resolve:V5,tokenize:K5};function V5(e){let n=e.length-4,a=3,i,o;if((e[a][1].type==="lineEnding"||e[a][1].type==="space")&&(e[n][1].type==="lineEnding"||e[n][1].type==="space")){for(i=a;++i<n;)if(e[i][1].type==="codeTextData"){e[a][1].type="codeTextPadding",e[n][1].type="codeTextPadding",a+=2,n-=2;break}}for(i=a-1,n++;++i<=n;)o===void 0?i!==n&&e[i][1].type!=="lineEnding"&&(o=i):(i===n||e[i][1].type==="lineEnding")&&(e[o][1].type="codeTextData",i!==o+2&&(e[o][1].end=e[i-1][1].end,e.splice(o+2,i-o-2),n-=i-o-2,i=o+2),o=void 0);return e}function G5(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function K5(e,n,a){let i=0,o,u;return d;function d(g){return e.enter("codeText"),e.enter("codeTextSequence"),f(g)}function f(g){return g===96?(e.consume(g),i++,f):(e.exit("codeTextSequence"),m(g))}function m(g){return g===null?a(g):g===32?(e.enter("space"),e.consume(g),e.exit("space"),m):g===96?(u=e.enter("codeTextSequence"),o=0,x(g)):lt(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),m):(e.enter("codeTextData"),h(g))}function h(g){return g===null||g===32||g===96||lt(g)?(e.exit("codeTextData"),m(g)):(e.consume(g),h)}function x(g){return g===96?(e.consume(g),o++,x):o===i?(e.exit("codeTextSequence"),e.exit("codeText"),n(g)):(u.type="codeTextData",h(g))}}class P5{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,a){const i=a??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,a,i){const o=a||0;this.setCursor(Math.trunc(n));const u=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return i&&So(this.left,i),u.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),So(this.left,n)}unshift(n){this.setCursor(0),this.right.push(n)}unshiftMany(n){this.setCursor(0),So(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 a=this.left.splice(n,Number.POSITIVE_INFINITY);So(this.right,a.reverse())}else{const a=this.right.splice(this.left.length+this.right.length-n,Number.POSITIVE_INFINITY);So(this.left,a.reverse())}}}function So(e,n){let a=0;if(n.length<1e4)e.push(...n);else for(;a<n.length;)e.push(...n.slice(a,a+1e4)),a+=1e4}function Gy(e){const n={};let a=-1,i,o,u,d,f,m,h;const x=new P5(e);for(;++a<x.length;){for(;a in n;)a=n[a];if(i=x.get(a),a&&i[1].type==="chunkFlow"&&x.get(a-1)[1].type==="listItemPrefix"&&(m=i[1]._tokenizer.events,u=0,u<m.length&&m[u][1].type==="lineEndingBlank"&&(u+=2),u<m.length&&m[u][1].type==="content"))for(;++u<m.length&&m[u][1].type!=="content";)m[u][1].type==="chunkText"&&(m[u][1]._isInFirstContentOfListItem=!0,u++);if(i[0]==="enter")i[1].contentType&&(Object.assign(n,Q5(x,a)),a=n[a],h=!0);else if(i[1]._container){for(u=a,o=void 0;u--;)if(d=x.get(u),d[1].type==="lineEnding"||d[1].type==="lineEndingBlank")d[0]==="enter"&&(o&&(x.get(o)[1].type="lineEndingBlank"),d[1].type="lineEnding",o=u);else if(!(d[1].type==="linePrefix"||d[1].type==="listItemIndent"))break;o&&(i[1].end={...x.get(o)[1].start},f=x.slice(o,a),f.unshift(i),x.splice(o,a-o+1,f))}}return Br(e,0,Number.POSITIVE_INFINITY,x.slice(0)),!h}function Q5(e,n){const a=e.get(n)[1],i=e.get(n)[2];let o=n-1;const u=[];let d=a._tokenizer;d||(d=i.parser[a.contentType](a.start),a._contentTypeTextTrailing&&(d._contentTypeTextTrailing=!0));const f=d.events,m=[],h={};let x,g,v=-1,b=a,j=0,k=0;const N=[k];for(;b;){for(;e.get(++o)[1]!==b;);u.push(o),b._tokenizer||(x=i.sliceStream(b),b.next||x.push(null),g&&d.defineSkip(b.start),b._isInFirstContentOfListItem&&(d._gfmTasklistFirstContentOfListItem=!0),d.write(x),b._isInFirstContentOfListItem&&(d._gfmTasklistFirstContentOfListItem=void 0)),g=b,b=b.next}for(b=a;++v<f.length;)f[v][0]==="exit"&&f[v-1][0]==="enter"&&f[v][1].type===f[v-1][1].type&&f[v][1].start.line!==f[v][1].end.line&&(k=v+1,N.push(k),b._tokenizer=void 0,b.previous=void 0,b=b.next);for(d.events=[],b?(b._tokenizer=void 0,b.previous=void 0):N.pop(),v=N.length;v--;){const E=f.slice(N[v],N[v+1]),C=u.pop();m.push([C,C+E.length-1]),e.splice(C,2,E)}for(m.reverse(),v=-1;++v<m.length;)h[j+m[v][0]]=j+m[v][1],j+=m[v][1]-m[v][0]-1;return h}const Z5={resolve:ek,tokenize:tk},J5={partial:!0,tokenize:nk};function ek(e){return Gy(e),e}function tk(e,n){let a;return i;function i(f){return e.enter("content"),a=e.enter("chunkContent",{contentType:"content"}),o(f)}function o(f){return f===null?u(f):lt(f)?e.check(J5,d,u)(f):(e.consume(f),o)}function u(f){return e.exit("chunkContent"),e.exit("content"),n(f)}function d(f){return e.consume(f),e.exit("chunkContent"),a.next=e.enter("chunkContent",{contentType:"content",previous:a}),a=a.next,o}}function nk(e,n,a){const i=this;return o;function o(d){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),Ht(e,u,"linePrefix")}function u(d){if(d===null||lt(d))return a(d);const f=i.events[i.events.length-1];return!i.parser.constructs.disable.null.includes("codeIndented")&&f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?n(d):e.interrupt(i.parser.constructs.flow,a,n)(d)}}function Ky(e,n,a,i,o,u,d,f,m){const h=m||Number.POSITIVE_INFINITY;let x=0;return g;function g(E){return E===60?(e.enter(i),e.enter(o),e.enter(u),e.consume(E),e.exit(u),v):E===null||E===32||E===41||$u(E)?a(E):(e.enter(i),e.enter(d),e.enter(f),e.enter("chunkString",{contentType:"string"}),k(E))}function v(E){return E===62?(e.enter(u),e.consume(E),e.exit(u),e.exit(o),e.exit(i),n):(e.enter(f),e.enter("chunkString",{contentType:"string"}),b(E))}function b(E){return E===62?(e.exit("chunkString"),e.exit(f),v(E)):E===null||E===60||lt(E)?a(E):(e.consume(E),E===92?j:b)}function j(E){return E===60||E===62||E===92?(e.consume(E),b):b(E)}function k(E){return!x&&(E===null||E===41||cn(E))?(e.exit("chunkString"),e.exit(f),e.exit(d),e.exit(i),n(E)):x<h&&E===40?(e.consume(E),x++,k):E===41?(e.consume(E),x--,k):E===null||E===32||E===40||$u(E)?a(E):(e.consume(E),E===92?N:k)}function N(E){return E===40||E===41||E===92?(e.consume(E),k):k(E)}}function Py(e,n,a,i,o,u){const d=this;let f=0,m;return h;function h(b){return e.enter(i),e.enter(o),e.consume(b),e.exit(o),e.enter(u),x}function x(b){return f>999||b===null||b===91||b===93&&!m||b===94&&!f&&"_hiddenFootnoteSupport"in d.parser.constructs?a(b):b===93?(e.exit(u),e.enter(o),e.consume(b),e.exit(o),e.exit(i),n):lt(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),x):(e.enter("chunkString",{contentType:"string"}),g(b))}function g(b){return b===null||b===91||b===93||lt(b)||f++>999?(e.exit("chunkString"),x(b)):(e.consume(b),m||(m=!Dt(b)),b===92?v:g)}function v(b){return b===91||b===92||b===93?(e.consume(b),f++,g):g(b)}}function Qy(e,n,a,i,o,u){let d;return f;function f(v){return v===34||v===39||v===40?(e.enter(i),e.enter(o),e.consume(v),e.exit(o),d=v===40?41:v,m):a(v)}function m(v){return v===d?(e.enter(o),e.consume(v),e.exit(o),e.exit(i),n):(e.enter(u),h(v))}function h(v){return v===d?(e.exit(u),m(d)):v===null?a(v):lt(v)?(e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),Ht(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),x(v))}function x(v){return v===d||v===null||lt(v)?(e.exit("chunkString"),h(v)):(e.consume(v),v===92?g:x)}function g(v){return v===d||v===92?(e.consume(v),x):x(v)}}function Bo(e,n){let a;return i;function i(o){return lt(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a=!0,i):Dt(o)?Ht(e,i,a?"linePrefix":"lineSuffix")(o):n(o)}}const rk={name:"definition",tokenize:lk},ak={partial:!0,tokenize:ik};function lk(e,n,a){const i=this;let o;return u;function u(b){return e.enter("definition"),d(b)}function d(b){return Py.call(i,e,f,a,"definitionLabel","definitionLabelMarker","definitionLabelString")(b)}function f(b){return o=oa(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),b===58?(e.enter("definitionMarker"),e.consume(b),e.exit("definitionMarker"),m):a(b)}function m(b){return cn(b)?Bo(e,h)(b):h(b)}function h(b){return Ky(e,x,a,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(b)}function x(b){return e.attempt(ak,g,g)(b)}function g(b){return Dt(b)?Ht(e,v,"whitespace")(b):v(b)}function v(b){return b===null||lt(b)?(e.exit("definition"),i.parser.defined.push(o),n(b)):a(b)}}function ik(e,n,a){return i;function i(f){return cn(f)?Bo(e,o)(f):a(f)}function o(f){return Qy(e,u,a,"definitionTitle","definitionTitleMarker","definitionTitleString")(f)}function u(f){return Dt(f)?Ht(e,d,"whitespace")(f):d(f)}function d(f){return f===null||lt(f)?n(f):a(f)}}const sk={name:"hardBreakEscape",tokenize:ok};function ok(e,n,a){return i;function i(u){return e.enter("hardBreakEscape"),e.consume(u),o}function o(u){return lt(u)?(e.exit("hardBreakEscape"),n(u)):a(u)}}const ck={name:"headingAtx",resolve:uk,tokenize:dk};function uk(e,n){let a=e.length-2,i=3,o,u;return e[i][1].type==="whitespace"&&(i+=2),a-2>i&&e[a][1].type==="whitespace"&&(a-=2),e[a][1].type==="atxHeadingSequence"&&(i===a-1||a-4>i&&e[a-2][1].type==="whitespace")&&(a-=i+1===a?2:4),a>i&&(o={type:"atxHeadingText",start:e[i][1].start,end:e[a][1].end},u={type:"chunkText",start:e[i][1].start,end:e[a][1].end,contentType:"text"},Br(e,i,a-i+1,[["enter",o,n],["enter",u,n],["exit",u,n],["exit",o,n]])),e}function dk(e,n,a){let i=0;return o;function o(x){return e.enter("atxHeading"),u(x)}function u(x){return e.enter("atxHeadingSequence"),d(x)}function d(x){return x===35&&i++<6?(e.consume(x),d):x===null||cn(x)?(e.exit("atxHeadingSequence"),f(x)):a(x)}function f(x){return x===35?(e.enter("atxHeadingSequence"),m(x)):x===null||lt(x)?(e.exit("atxHeading"),n(x)):Dt(x)?Ht(e,f,"whitespace")(x):(e.enter("atxHeadingText"),h(x))}function m(x){return x===35?(e.consume(x),m):(e.exit("atxHeadingSequence"),f(x))}function h(x){return x===null||x===35||cn(x)?(e.exit("atxHeadingText"),f(x)):(e.consume(x),h)}}const fk=["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"],Z0=["pre","script","style","textarea"],hk={concrete:!0,name:"htmlFlow",resolveTo:xk,tokenize:gk},mk={partial:!0,tokenize:bk},pk={partial:!0,tokenize:yk};function xk(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 gk(e,n,a){const i=this;let o,u,d,f,m;return h;function h(T){return x(T)}function x(T){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(T),g}function g(T){return T===33?(e.consume(T),v):T===47?(e.consume(T),u=!0,k):T===63?(e.consume(T),o=3,i.interrupt?n:D):cr(T)?(e.consume(T),d=String.fromCharCode(T),N):a(T)}function v(T){return T===45?(e.consume(T),o=2,b):T===91?(e.consume(T),o=5,f=0,j):cr(T)?(e.consume(T),o=4,i.interrupt?n:D):a(T)}function b(T){return T===45?(e.consume(T),i.interrupt?n:D):a(T)}function j(T){const se="CDATA[";return T===se.charCodeAt(f++)?(e.consume(T),f===se.length?i.interrupt?n:q:j):a(T)}function k(T){return cr(T)?(e.consume(T),d=String.fromCharCode(T),N):a(T)}function N(T){if(T===null||T===47||T===62||cn(T)){const se=T===47,ge=d.toLowerCase();return!se&&!u&&Z0.includes(ge)?(o=1,i.interrupt?n(T):q(T)):fk.includes(d.toLowerCase())?(o=6,se?(e.consume(T),E):i.interrupt?n(T):q(T)):(o=7,i.interrupt&&!i.parser.lazy[i.now().line]?a(T):u?C(T):_(T))}return T===45||rr(T)?(e.consume(T),d+=String.fromCharCode(T),N):a(T)}function E(T){return T===62?(e.consume(T),i.interrupt?n:q):a(T)}function C(T){return Dt(T)?(e.consume(T),C):A(T)}function _(T){return T===47?(e.consume(T),A):T===58||T===95||cr(T)?(e.consume(T),R):Dt(T)?(e.consume(T),_):A(T)}function R(T){return T===45||T===46||T===58||T===95||rr(T)?(e.consume(T),R):L(T)}function L(T){return T===61?(e.consume(T),F):Dt(T)?(e.consume(T),L):_(T)}function F(T){return T===null||T===60||T===61||T===62||T===96?a(T):T===34||T===39?(e.consume(T),m=T,I):Dt(T)?(e.consume(T),F):H(T)}function I(T){return T===m?(e.consume(T),m=null,X):T===null||lt(T)?a(T):(e.consume(T),I)}function H(T){return T===null||T===34||T===39||T===47||T===60||T===61||T===62||T===96||cn(T)?L(T):(e.consume(T),H)}function X(T){return T===47||T===62||Dt(T)?_(T):a(T)}function A(T){return T===62?(e.consume(T),$):a(T)}function $(T){return T===null||lt(T)?q(T):Dt(T)?(e.consume(T),$):a(T)}function q(T){return T===45&&o===2?(e.consume(T),Y):T===60&&o===1?(e.consume(T),oe):T===62&&o===4?(e.consume(T),B):T===63&&o===3?(e.consume(T),D):T===93&&o===5?(e.consume(T),G):lt(T)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(mk,U,W)(T)):T===null||lt(T)?(e.exit("htmlFlowData"),W(T)):(e.consume(T),q)}function W(T){return e.check(pk,ie,U)(T)}function ie(T){return e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),P}function P(T){return T===null||lt(T)?W(T):(e.enter("htmlFlowData"),q(T))}function Y(T){return T===45?(e.consume(T),D):q(T)}function oe(T){return T===47?(e.consume(T),d="",de):q(T)}function de(T){if(T===62){const se=d.toLowerCase();return Z0.includes(se)?(e.consume(T),B):q(T)}return cr(T)&&d.length<8?(e.consume(T),d+=String.fromCharCode(T),de):q(T)}function G(T){return T===93?(e.consume(T),D):q(T)}function D(T){return T===62?(e.consume(T),B):T===45&&o===2?(e.consume(T),D):q(T)}function B(T){return T===null||lt(T)?(e.exit("htmlFlowData"),U(T)):(e.consume(T),B)}function U(T){return e.exit("htmlFlow"),n(T)}}function yk(e,n,a){const i=this;return o;function o(d){return lt(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),u):a(d)}function u(d){return i.parser.lazy[i.now().line]?a(d):n(d)}}function bk(e,n,a){return i;function i(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(Xo,n,a)}}const vk={name:"htmlText",tokenize:wk};function wk(e,n,a){const i=this;let o,u,d;return f;function f(D){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(D),m}function m(D){return D===33?(e.consume(D),h):D===47?(e.consume(D),L):D===63?(e.consume(D),_):cr(D)?(e.consume(D),H):a(D)}function h(D){return D===45?(e.consume(D),x):D===91?(e.consume(D),u=0,j):cr(D)?(e.consume(D),C):a(D)}function x(D){return D===45?(e.consume(D),b):a(D)}function g(D){return D===null?a(D):D===45?(e.consume(D),v):lt(D)?(d=g,oe(D)):(e.consume(D),g)}function v(D){return D===45?(e.consume(D),b):g(D)}function b(D){return D===62?Y(D):D===45?v(D):g(D)}function j(D){const B="CDATA[";return D===B.charCodeAt(u++)?(e.consume(D),u===B.length?k:j):a(D)}function k(D){return D===null?a(D):D===93?(e.consume(D),N):lt(D)?(d=k,oe(D)):(e.consume(D),k)}function N(D){return D===93?(e.consume(D),E):k(D)}function E(D){return D===62?Y(D):D===93?(e.consume(D),E):k(D)}function C(D){return D===null||D===62?Y(D):lt(D)?(d=C,oe(D)):(e.consume(D),C)}function _(D){return D===null?a(D):D===63?(e.consume(D),R):lt(D)?(d=_,oe(D)):(e.consume(D),_)}function R(D){return D===62?Y(D):_(D)}function L(D){return cr(D)?(e.consume(D),F):a(D)}function F(D){return D===45||rr(D)?(e.consume(D),F):I(D)}function I(D){return lt(D)?(d=I,oe(D)):Dt(D)?(e.consume(D),I):Y(D)}function H(D){return D===45||rr(D)?(e.consume(D),H):D===47||D===62||cn(D)?X(D):a(D)}function X(D){return D===47?(e.consume(D),Y):D===58||D===95||cr(D)?(e.consume(D),A):lt(D)?(d=X,oe(D)):Dt(D)?(e.consume(D),X):Y(D)}function A(D){return D===45||D===46||D===58||D===95||rr(D)?(e.consume(D),A):$(D)}function $(D){return D===61?(e.consume(D),q):lt(D)?(d=$,oe(D)):Dt(D)?(e.consume(D),$):X(D)}function q(D){return D===null||D===60||D===61||D===62||D===96?a(D):D===34||D===39?(e.consume(D),o=D,W):lt(D)?(d=q,oe(D)):Dt(D)?(e.consume(D),q):(e.consume(D),ie)}function W(D){return D===o?(e.consume(D),o=void 0,P):D===null?a(D):lt(D)?(d=W,oe(D)):(e.consume(D),W)}function ie(D){return D===null||D===34||D===39||D===60||D===61||D===96?a(D):D===47||D===62||cn(D)?X(D):(e.consume(D),ie)}function P(D){return D===47||D===62||cn(D)?X(D):a(D)}function Y(D){return D===62?(e.consume(D),e.exit("htmlTextData"),e.exit("htmlText"),n):a(D)}function oe(D){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(D),e.exit("lineEnding"),de}function de(D){return Dt(D)?Ht(e,G,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):G(D)}function G(D){return e.enter("htmlTextData"),d(D)}}const Fm={name:"labelEnd",resolveAll:Ck,resolveTo:Ek,tokenize:Nk},kk={tokenize:Ak},jk={tokenize:Dk},Sk={tokenize:Tk};function Ck(e){let n=-1;const a=[];for(;++n<e.length;){const i=e[n][1];if(a.push(e[n]),i.type==="labelImage"||i.type==="labelLink"||i.type==="labelEnd"){const o=i.type==="labelImage"?4:2;i.type="data",n+=o}}return e.length!==a.length&&Br(e,0,e.length,a),e}function Ek(e,n){let a=e.length,i=0,o,u,d,f;for(;a--;)if(o=e[a][1],u){if(o.type==="link"||o.type==="labelLink"&&o._inactive)break;e[a][0]==="enter"&&o.type==="labelLink"&&(o._inactive=!0)}else if(d){if(e[a][0]==="enter"&&(o.type==="labelImage"||o.type==="labelLink")&&!o._balanced&&(u=a,o.type!=="labelLink")){i=2;break}}else o.type==="labelEnd"&&(d=a);const m={type:e[u][1].type==="labelLink"?"link":"image",start:{...e[u][1].start},end:{...e[e.length-1][1].end}},h={type:"label",start:{...e[u][1].start},end:{...e[d][1].end}},x={type:"labelText",start:{...e[u+i+2][1].end},end:{...e[d-2][1].start}};return f=[["enter",m,n],["enter",h,n]],f=Qr(f,e.slice(u+1,u+i+3)),f=Qr(f,[["enter",x,n]]),f=Qr(f,Pu(n.parser.constructs.insideSpan.null,e.slice(u+i+4,d-3),n)),f=Qr(f,[["exit",x,n],e[d-2],e[d-1],["exit",h,n]]),f=Qr(f,e.slice(d+1)),f=Qr(f,[["exit",m,n]]),Br(e,u,e.length,f),e}function Nk(e,n,a){const i=this;let o=i.events.length,u,d;for(;o--;)if((i.events[o][1].type==="labelImage"||i.events[o][1].type==="labelLink")&&!i.events[o][1]._balanced){u=i.events[o][1];break}return f;function f(v){return u?u._inactive?g(v):(d=i.parser.defined.includes(oa(i.sliceSerialize({start:u.end,end:i.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(v),e.exit("labelMarker"),e.exit("labelEnd"),m):a(v)}function m(v){return v===40?e.attempt(kk,x,d?x:g)(v):v===91?e.attempt(jk,x,d?h:g)(v):d?x(v):g(v)}function h(v){return e.attempt(Sk,x,g)(v)}function x(v){return n(v)}function g(v){return u._balanced=!0,a(v)}}function Ak(e,n,a){return i;function i(g){return e.enter("resource"),e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),o}function o(g){return cn(g)?Bo(e,u)(g):u(g)}function u(g){return g===41?x(g):Ky(e,d,f,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(g)}function d(g){return cn(g)?Bo(e,m)(g):x(g)}function f(g){return a(g)}function m(g){return g===34||g===39||g===40?Qy(e,h,a,"resourceTitle","resourceTitleMarker","resourceTitleString")(g):x(g)}function h(g){return cn(g)?Bo(e,x)(g):x(g)}function x(g){return g===41?(e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),e.exit("resource"),n):a(g)}}function Dk(e,n,a){const i=this;return o;function o(f){return Py.call(i,e,u,d,"reference","referenceMarker","referenceString")(f)}function u(f){return i.parser.defined.includes(oa(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?n(f):a(f)}function d(f){return a(f)}}function Tk(e,n,a){return i;function i(u){return e.enter("reference"),e.enter("referenceMarker"),e.consume(u),e.exit("referenceMarker"),o}function o(u){return u===93?(e.enter("referenceMarker"),e.consume(u),e.exit("referenceMarker"),e.exit("reference"),n):a(u)}}const Fk={name:"labelStartImage",resolveAll:Fm.resolveAll,tokenize:Mk};function Mk(e,n,a){const i=this;return o;function o(f){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(f),e.exit("labelImageMarker"),u}function u(f){return f===91?(e.enter("labelMarker"),e.consume(f),e.exit("labelMarker"),e.exit("labelImage"),d):a(f)}function d(f){return f===94&&"_hiddenFootnoteSupport"in i.parser.constructs?a(f):n(f)}}const Rk={name:"labelStartLink",resolveAll:Fm.resolveAll,tokenize:zk};function zk(e,n,a){const i=this;return o;function o(d){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(d),e.exit("labelMarker"),e.exit("labelLink"),u}function u(d){return d===94&&"_hiddenFootnoteSupport"in i.parser.constructs?a(d):n(d)}}const ch={name:"lineEnding",tokenize:_k};function _k(e,n){return a;function a(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),Ht(e,n,"linePrefix")}}const Ru={name:"thematicBreak",tokenize:Bk};function Bk(e,n,a){let i=0,o;return u;function u(h){return e.enter("thematicBreak"),d(h)}function d(h){return o=h,f(h)}function f(h){return h===o?(e.enter("thematicBreakSequence"),m(h)):i>=3&&(h===null||lt(h))?(e.exit("thematicBreak"),n(h)):a(h)}function m(h){return h===o?(e.consume(h),i++,m):(e.exit("thematicBreakSequence"),Dt(h)?Ht(e,f,"whitespace")(h):f(h))}}const vr={continuation:{tokenize:Ik},exit:Uk,name:"list",tokenize:Lk},Ok={partial:!0,tokenize:qk},$k={partial:!0,tokenize:Hk};function Lk(e,n,a){const i=this,o=i.events[i.events.length-1];let u=o&&o[1].type==="linePrefix"?o[2].sliceSerialize(o[1],!0).length:0,d=0;return f;function f(b){const j=i.containerState.type||(b===42||b===43||b===45?"listUnordered":"listOrdered");if(j==="listUnordered"?!i.containerState.marker||b===i.containerState.marker:Ph(b)){if(i.containerState.type||(i.containerState.type=j,e.enter(j,{_container:!0})),j==="listUnordered")return e.enter("listItemPrefix"),b===42||b===45?e.check(Ru,a,h)(b):h(b);if(!i.interrupt||b===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),m(b)}return a(b)}function m(b){return Ph(b)&&++d<10?(e.consume(b),m):(!i.interrupt||d<2)&&(i.containerState.marker?b===i.containerState.marker:b===41||b===46)?(e.exit("listItemValue"),h(b)):a(b)}function h(b){return e.enter("listItemMarker"),e.consume(b),e.exit("listItemMarker"),i.containerState.marker=i.containerState.marker||b,e.check(Xo,i.interrupt?a:x,e.attempt(Ok,v,g))}function x(b){return i.containerState.initialBlankLine=!0,u++,v(b)}function g(b){return Dt(b)?(e.enter("listItemPrefixWhitespace"),e.consume(b),e.exit("listItemPrefixWhitespace"),v):a(b)}function v(b){return i.containerState.size=u+i.sliceSerialize(e.exit("listItemPrefix"),!0).length,n(b)}}function Ik(e,n,a){const i=this;return i.containerState._closeFlow=void 0,e.check(Xo,o,u);function o(f){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,Ht(e,n,"listItemIndent",i.containerState.size+1)(f)}function u(f){return i.containerState.furtherBlankLines||!Dt(f)?(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,d(f)):(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,e.attempt($k,n,d)(f))}function d(f){return i.containerState._closeFlow=!0,i.interrupt=void 0,Ht(e,e.attempt(vr,n,a),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(f)}}function Hk(e,n,a){const i=this;return Ht(e,o,"listItemIndent",i.containerState.size+1);function o(u){const d=i.events[i.events.length-1];return d&&d[1].type==="listItemIndent"&&d[2].sliceSerialize(d[1],!0).length===i.containerState.size?n(u):a(u)}}function Uk(e){e.exit(this.containerState.type)}function qk(e,n,a){const i=this;return Ht(e,o,"listItemPrefixWhitespace",i.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(u){const d=i.events[i.events.length-1];return!Dt(u)&&d&&d[1].type==="listItemPrefixWhitespace"?n(u):a(u)}}const J0={name:"setextUnderline",resolveTo:Yk,tokenize:Xk};function Yk(e,n){let a=e.length,i,o,u;for(;a--;)if(e[a][0]==="enter"){if(e[a][1].type==="content"){i=a;break}e[a][1].type==="paragraph"&&(o=a)}else e[a][1].type==="content"&&e.splice(a,1),!u&&e[a][1].type==="definition"&&(u=a);const d={type:"setextHeading",start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[o][1].type="setextHeadingText",u?(e.splice(o,0,["enter",d,n]),e.splice(u+1,0,["exit",e[i][1],n]),e[i][1].end={...e[u][1].end}):e[i][1]=d,e.push(["exit",d,n]),e}function Xk(e,n,a){const i=this;let o;return u;function u(h){let x=i.events.length,g;for(;x--;)if(i.events[x][1].type!=="lineEnding"&&i.events[x][1].type!=="linePrefix"&&i.events[x][1].type!=="content"){g=i.events[x][1].type==="paragraph";break}return!i.parser.lazy[i.now().line]&&(i.interrupt||g)?(e.enter("setextHeadingLine"),o=h,d(h)):a(h)}function d(h){return e.enter("setextHeadingLineSequence"),f(h)}function f(h){return h===o?(e.consume(h),f):(e.exit("setextHeadingLineSequence"),Dt(h)?Ht(e,m,"lineSuffix")(h):m(h))}function m(h){return h===null||lt(h)?(e.exit("setextHeadingLine"),n(h)):a(h)}}const Wk={tokenize:Vk};function Vk(e){const n=this,a=e.attempt(Xo,i,e.attempt(this.parser.constructs.flowInitial,o,Ht(e,e.attempt(this.parser.constructs.flow,o,e.attempt(Z5,o)),"linePrefix")));return a;function i(u){if(u===null){e.consume(u);return}return e.enter("lineEndingBlank"),e.consume(u),e.exit("lineEndingBlank"),n.currentConstruct=void 0,a}function o(u){if(u===null){e.consume(u);return}return e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),n.currentConstruct=void 0,a}}const Gk={resolveAll:Jy()},Kk=Zy("string"),Pk=Zy("text");function Zy(e){return{resolveAll:Jy(e==="text"?Qk:void 0),tokenize:n};function n(a){const i=this,o=this.parser.constructs[e],u=a.attempt(o,d,f);return d;function d(x){return h(x)?u(x):f(x)}function f(x){if(x===null){a.consume(x);return}return a.enter("data"),a.consume(x),m}function m(x){return h(x)?(a.exit("data"),u(x)):(a.consume(x),m)}function h(x){if(x===null)return!0;const g=o[x];let v=-1;if(g)for(;++v<g.length;){const b=g[v];if(!b.previous||b.previous.call(i,i.previous))return!0}return!1}}}function Jy(e){return n;function n(a,i){let o=-1,u;for(;++o<=a.length;)u===void 0?a[o]&&a[o][1].type==="data"&&(u=o,o++):(!a[o]||a[o][1].type!=="data")&&(o!==u+2&&(a[u][1].end=a[o-1][1].end,a.splice(u+2,o-u-2),o=u+2),u=void 0);return e?e(a,i):a}}function Qk(e,n){let a=0;for(;++a<=e.length;)if((a===e.length||e[a][1].type==="lineEnding")&&e[a-1][1].type==="data"){const i=e[a-1][1],o=n.sliceStream(i);let u=o.length,d=-1,f=0,m;for(;u--;){const h=o[u];if(typeof h=="string"){for(d=h.length;h.charCodeAt(d-1)===32;)f++,d--;if(d)break;d=-1}else if(h===-2)m=!0,f++;else if(h!==-1){u++;break}}if(n._contentTypeTextTrailing&&a===e.length&&(f=0),f){const h={type:a===e.length||m||f<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:u?d:i.start._bufferIndex+d,_index:i.start._index+u,line:i.end.line,column:i.end.column-f,offset:i.end.offset-f},end:{...i.end}};i.end={...h.start},i.start.offset===i.end.offset?Object.assign(i,h):(e.splice(a,0,["enter",h,n],["exit",h,n]),a+=2)}a++}return e}const Zk={42:vr,43:vr,45:vr,48:vr,49:vr,50:vr,51:vr,52:vr,53:vr,54:vr,55:vr,56:vr,57:vr,62:Xy},Jk={91:rk},e3={[-2]:oh,[-1]:oh,32:oh},t3={35:ck,42:Ru,45:[J0,Ru],60:hk,61:J0,95:Ru,96:Q0,126:Q0},n3={38:Vy,92:Wy},r3={[-5]:ch,[-4]:ch,[-3]:ch,33:Fk,38:Vy,42:Qh,60:[R5,vk],91:Rk,92:[sk,Wy],93:Fm,95:Qh,96:W5},a3={null:[Qh,Gk]},l3={null:[42,95]},i3={null:[]},s3=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:l3,contentInitial:Jk,disable:i3,document:Zk,flow:t3,flowInitial:e3,insideSpan:a3,string:n3,text:r3},Symbol.toStringTag,{value:"Module"}));function o3(e,n,a){let i={_bufferIndex:-1,_index:0,line:a&&a.line||1,column:a&&a.column||1,offset:a&&a.offset||0};const o={},u=[];let d=[],f=[];const m={attempt:I(L),check:I(F),consume:C,enter:_,exit:R,interrupt:I(F,{interrupt:!0})},h={code:null,containerState:{},defineSkip:k,events:[],now:j,parser:e,previous:null,sliceSerialize:v,sliceStream:b,write:g};let x=n.tokenize.call(h,m);return n.resolveAll&&u.push(n),h;function g($){return d=Qr(d,$),N(),d[d.length-1]!==null?[]:(H(n,0),h.events=Pu(u,h.events,h),h.events)}function v($,q){return u3(b($),q)}function b($){return c3(d,$)}function j(){const{_bufferIndex:$,_index:q,line:W,column:ie,offset:P}=i;return{_bufferIndex:$,_index:q,line:W,column:ie,offset:P}}function k($){o[$.line]=$.column,A()}function N(){let $;for(;i._index<d.length;){const q=d[i._index];if(typeof q=="string")for($=i._index,i._bufferIndex<0&&(i._bufferIndex=0);i._index===$&&i._bufferIndex<q.length;)E(q.charCodeAt(i._bufferIndex));else E(q)}}function E($){x=x($)}function C($){lt($)?(i.line++,i.column=1,i.offset+=$===-3?2:1,A()):$!==-1&&(i.column++,i.offset++),i._bufferIndex<0?i._index++:(i._bufferIndex++,i._bufferIndex===d[i._index].length&&(i._bufferIndex=-1,i._index++)),h.previous=$}function _($,q){const W=q||{};return W.type=$,W.start=j(),h.events.push(["enter",W,h]),f.push(W),W}function R($){const q=f.pop();return q.end=j(),h.events.push(["exit",q,h]),q}function L($,q){H($,q.from)}function F($,q){q.restore()}function I($,q){return W;function W(ie,P,Y){let oe,de,G,D;return Array.isArray(ie)?U(ie):"tokenize"in ie?U([ie]):B(ie);function B(pe){return Re;function Re(Ie){const He=Ie!==null&&pe[Ie],ot=Ie!==null&&pe.null,Je=[...Array.isArray(He)?He:He?[He]:[],...Array.isArray(ot)?ot:ot?[ot]:[]];return U(Je)(Ie)}}function U(pe){return oe=pe,de=0,pe.length===0?Y:T(pe[de])}function T(pe){return Re;function Re(Ie){return D=X(),G=pe,pe.partial||(h.currentConstruct=pe),pe.name&&h.parser.constructs.disable.null.includes(pe.name)?ge():pe.tokenize.call(q?Object.assign(Object.create(h),q):h,m,se,ge)(Ie)}}function se(pe){return $(G,D),P}function ge(pe){return D.restore(),++de<oe.length?T(oe[de]):Y}}}function H($,q){$.resolveAll&&!u.includes($)&&u.push($),$.resolve&&Br(h.events,q,h.events.length-q,$.resolve(h.events.slice(q),h)),$.resolveTo&&(h.events=$.resolveTo(h.events,h))}function X(){const $=j(),q=h.previous,W=h.currentConstruct,ie=h.events.length,P=Array.from(f);return{from:ie,restore:Y};function Y(){i=$,h.previous=q,h.currentConstruct=W,h.events.length=ie,f=P,A()}}function A(){i.line in o&&i.column<2&&(i.column=o[i.line],i.offset+=o[i.line]-1)}}function c3(e,n){const a=n.start._index,i=n.start._bufferIndex,o=n.end._index,u=n.end._bufferIndex;let d;if(a===o)d=[e[a].slice(i,u)];else{if(d=e.slice(a,o),i>-1){const f=d[0];typeof f=="string"?d[0]=f.slice(i):d.shift()}u>0&&d.push(e[o].slice(0,u))}return d}function u3(e,n){let a=-1;const i=[];let o;for(;++a<e.length;){const u=e[a];let d;if(typeof u=="string")d=u;else switch(u){case-5:{d="\r";break}case-4:{d=`
|
|
53
|
+
`;break}case-3:{d=`\r
|
|
54
|
+
`;break}case-2:{d=n?" ":" ";break}case-1:{if(!n&&o)continue;d=" ";break}default:d=String.fromCharCode(u)}o=u===-2,i.push(d)}return i.join("")}function d3(e){const i={constructs:qy([s3,...(e||{}).extensions||[]]),content:o(E5),defined:[],document:o(A5),flow:o(Wk),lazy:{},string:o(Kk),text:o(Pk)};return i;function o(u){return d;function d(f){return o3(i,u,f)}}}function f3(e){for(;!Gy(e););return e}const eg=/[\0\t\n\r]/g;function h3(){let e=1,n="",a=!0,i;return o;function o(u,d,f){const m=[];let h,x,g,v,b;for(u=n+(typeof u=="string"?u.toString():new TextDecoder(d||void 0).decode(u)),g=0,n="",a&&(u.charCodeAt(0)===65279&&g++,a=void 0);g<u.length;){if(eg.lastIndex=g,h=eg.exec(u),v=h&&h.index!==void 0?h.index:u.length,b=u.charCodeAt(v),!h){n=u.slice(g);break}if(b===10&&g===v&&i)m.push(-3),i=void 0;else switch(i&&(m.push(-5),i=void 0),g<v&&(m.push(u.slice(g,v)),e+=v-g),b){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}g=v+1}return f&&(i&&m.push(-5),n&&m.push(n),m.push(null)),m}}const m3=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function p3(e){return e.replace(m3,x3)}function x3(e,n,a){if(n)return n;if(a.charCodeAt(0)===35){const o=a.charCodeAt(1),u=o===120||o===88;return Yy(a.slice(u?2:1),u?16:10)}return Tm(a)||e}const eb={}.hasOwnProperty;function g3(e,n,a){return n&&typeof n=="object"&&(a=n,n=void 0),y3(a)(f3(d3(a).document().write(h3()(e,n,!0))))}function y3(e){const n={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:u(Wt),autolinkProtocol:X,autolinkEmail:X,atxHeading:u(yt),blockQuote:u(ot),characterEscape:X,characterReference:X,codeFenced:u(Je),codeFencedFenceInfo:d,codeFencedFenceMeta:d,codeIndented:u(Je,d),codeText:u(tt,d),codeTextData:X,data:X,codeFlowValue:X,definition:u(Ee),definitionDestinationString:d,definitionLabelString:d,definitionTitleString:d,emphasis:u(Ae),hardBreakEscape:u(dt),hardBreakTrailing:u(dt),htmlFlow:u(xt,d),htmlFlowData:X,htmlText:u(xt,d),htmlTextData:X,image:u(jt),label:d,link:u(Wt),listItem:u(Ct),listItemValue:v,listOrdered:u(Tt,g),listUnordered:u(Tt),paragraph:u(Bn),reference:T,referenceString:d,resourceDestinationString:d,resourceTitleString:d,setextHeading:u(yt),strong:u(me),thematicBreak:u(Ne)},exit:{atxHeading:m(),atxHeadingSequence:L,autolink:m(),autolinkEmail:He,autolinkProtocol:Ie,blockQuote:m(),characterEscapeValue:A,characterReferenceMarkerHexadecimal:ge,characterReferenceMarkerNumeric:ge,characterReferenceValue:pe,characterReference:Re,codeFenced:m(N),codeFencedFence:k,codeFencedFenceInfo:b,codeFencedFenceMeta:j,codeFlowValue:A,codeIndented:m(E),codeText:m(P),codeTextData:A,data:A,definition:m(),definitionDestinationString:R,definitionLabelString:C,definitionTitleString:_,emphasis:m(),hardBreakEscape:m(q),hardBreakTrailing:m(q),htmlFlow:m(W),htmlFlowData:A,htmlText:m(ie),htmlTextData:A,image:m(oe),label:G,labelText:de,lineEnding:$,link:m(Y),listItem:m(),listOrdered:m(),listUnordered:m(),paragraph:m(),referenceString:se,resourceDestinationString:D,resourceTitleString:B,resource:U,setextHeading:m(H),setextHeadingLineSequence:I,setextHeadingText:F,strong:m(),thematicBreak:m()}};tb(n,(e||{}).mdastExtensions||[]);const a={};return i;function i(K){let ue={type:"root",children:[]};const ne={stack:[ue],tokenStack:[],config:n,enter:f,exit:h,buffer:d,resume:x,data:a},ve=[];let we=-1;for(;++we<K.length;)if(K[we][1].type==="listOrdered"||K[we][1].type==="listUnordered")if(K[we][0]==="enter")ve.push(we);else{const ze=ve.pop();we=o(K,ze,we)}for(we=-1;++we<K.length;){const ze=n[K[we][0]];eb.call(ze,K[we][1].type)&&ze[K[we][1].type].call(Object.assign({sliceSerialize:K[we][2].sliceSerialize},ne),K[we][1])}if(ne.tokenStack.length>0){const ze=ne.tokenStack[ne.tokenStack.length-1];(ze[1]||tg).call(ne,void 0,ze[0])}for(ue.position={start:Ll(K.length>0?K[0][1].start:{line:1,column:1,offset:0}),end:Ll(K.length>0?K[K.length-2][1].end:{line:1,column:1,offset:0})},we=-1;++we<n.transforms.length;)ue=n.transforms[we](ue)||ue;return ue}function o(K,ue,ne){let ve=ue-1,we=-1,ze=!1,_e,Be,qe,at;for(;++ve<=ne;){const Ke=K[ve];switch(Ke[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Ke[0]==="enter"?we++:we--,at=void 0;break}case"lineEndingBlank":{Ke[0]==="enter"&&(_e&&!at&&!we&&!qe&&(qe=ve),at=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:at=void 0}if(!we&&Ke[0]==="enter"&&Ke[1].type==="listItemPrefix"||we===-1&&Ke[0]==="exit"&&(Ke[1].type==="listUnordered"||Ke[1].type==="listOrdered")){if(_e){let bt=ve;for(Be=void 0;bt--;){const Me=K[bt];if(Me[1].type==="lineEnding"||Me[1].type==="lineEndingBlank"){if(Me[0]==="exit")continue;Be&&(K[Be][1].type="lineEndingBlank",ze=!0),Me[1].type="lineEnding",Be=bt}else if(!(Me[1].type==="linePrefix"||Me[1].type==="blockQuotePrefix"||Me[1].type==="blockQuotePrefixWhitespace"||Me[1].type==="blockQuoteMarker"||Me[1].type==="listItemIndent"))break}qe&&(!Be||qe<Be)&&(_e._spread=!0),_e.end=Object.assign({},Be?K[Be][1].start:Ke[1].end),K.splice(Be||ve,0,["exit",_e,Ke[2]]),ve++,ne++}if(Ke[1].type==="listItemPrefix"){const bt={type:"listItem",_spread:!1,start:Object.assign({},Ke[1].start),end:void 0};_e=bt,K.splice(ve,0,["enter",bt,Ke[2]]),ve++,ne++,qe=void 0,at=!0}}}return K[ue][1]._spread=ze,ne}function u(K,ue){return ne;function ne(ve){f.call(this,K(ve),ve),ue&&ue.call(this,ve)}}function d(){this.stack.push({type:"fragment",children:[]})}function f(K,ue,ne){this.stack[this.stack.length-1].children.push(K),this.stack.push(K),this.tokenStack.push([ue,ne||void 0]),K.position={start:Ll(ue.start),end:void 0}}function m(K){return ue;function ue(ne){K&&K.call(this,ne),h.call(this,ne)}}function h(K,ue){const ne=this.stack.pop(),ve=this.tokenStack.pop();if(ve)ve[0].type!==K.type&&(ue?ue.call(this,K,ve[0]):(ve[1]||tg).call(this,K,ve[0]));else throw new Error("Cannot close `"+K.type+"` ("+_o({start:K.start,end:K.end})+"): it’s not open");ne.position.end=Ll(K.end)}function x(){return Dm(this.stack.pop())}function g(){this.data.expectingFirstListItemValue=!0}function v(K){if(this.data.expectingFirstListItemValue){const ue=this.stack[this.stack.length-2];ue.start=Number.parseInt(this.sliceSerialize(K),10),this.data.expectingFirstListItemValue=void 0}}function b(){const K=this.resume(),ue=this.stack[this.stack.length-1];ue.lang=K}function j(){const K=this.resume(),ue=this.stack[this.stack.length-1];ue.meta=K}function k(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function N(){const K=this.resume(),ue=this.stack[this.stack.length-1];ue.value=K.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function E(){const K=this.resume(),ue=this.stack[this.stack.length-1];ue.value=K.replace(/(\r?\n|\r)$/g,"")}function C(K){const ue=this.resume(),ne=this.stack[this.stack.length-1];ne.label=ue,ne.identifier=oa(this.sliceSerialize(K)).toLowerCase()}function _(){const K=this.resume(),ue=this.stack[this.stack.length-1];ue.title=K}function R(){const K=this.resume(),ue=this.stack[this.stack.length-1];ue.url=K}function L(K){const ue=this.stack[this.stack.length-1];if(!ue.depth){const ne=this.sliceSerialize(K).length;ue.depth=ne}}function F(){this.data.setextHeadingSlurpLineEnding=!0}function I(K){const ue=this.stack[this.stack.length-1];ue.depth=this.sliceSerialize(K).codePointAt(0)===61?1:2}function H(){this.data.setextHeadingSlurpLineEnding=void 0}function X(K){const ne=this.stack[this.stack.length-1].children;let ve=ne[ne.length-1];(!ve||ve.type!=="text")&&(ve=Se(),ve.position={start:Ll(K.start),end:void 0},ne.push(ve)),this.stack.push(ve)}function A(K){const ue=this.stack.pop();ue.value+=this.sliceSerialize(K),ue.position.end=Ll(K.end)}function $(K){const ue=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ne=ue.children[ue.children.length-1];ne.position.end=Ll(K.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&n.canContainEols.includes(ue.type)&&(X.call(this,K),A.call(this,K))}function q(){this.data.atHardBreak=!0}function W(){const K=this.resume(),ue=this.stack[this.stack.length-1];ue.value=K}function ie(){const K=this.resume(),ue=this.stack[this.stack.length-1];ue.value=K}function P(){const K=this.resume(),ue=this.stack[this.stack.length-1];ue.value=K}function Y(){const K=this.stack[this.stack.length-1];if(this.data.inReference){const ue=this.data.referenceType||"shortcut";K.type+="Reference",K.referenceType=ue,delete K.url,delete K.title}else delete K.identifier,delete K.label;this.data.referenceType=void 0}function oe(){const K=this.stack[this.stack.length-1];if(this.data.inReference){const ue=this.data.referenceType||"shortcut";K.type+="Reference",K.referenceType=ue,delete K.url,delete K.title}else delete K.identifier,delete K.label;this.data.referenceType=void 0}function de(K){const ue=this.sliceSerialize(K),ne=this.stack[this.stack.length-2];ne.label=p3(ue),ne.identifier=oa(ue).toLowerCase()}function G(){const K=this.stack[this.stack.length-1],ue=this.resume(),ne=this.stack[this.stack.length-1];if(this.data.inReference=!0,ne.type==="link"){const ve=K.children;ne.children=ve}else ne.alt=ue}function D(){const K=this.resume(),ue=this.stack[this.stack.length-1];ue.url=K}function B(){const K=this.resume(),ue=this.stack[this.stack.length-1];ue.title=K}function U(){this.data.inReference=void 0}function T(){this.data.referenceType="collapsed"}function se(K){const ue=this.resume(),ne=this.stack[this.stack.length-1];ne.label=ue,ne.identifier=oa(this.sliceSerialize(K)).toLowerCase(),this.data.referenceType="full"}function ge(K){this.data.characterReferenceType=K.type}function pe(K){const ue=this.sliceSerialize(K),ne=this.data.characterReferenceType;let ve;ne?(ve=Yy(ue,ne==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ve=Tm(ue);const we=this.stack[this.stack.length-1];we.value+=ve}function Re(K){const ue=this.stack.pop();ue.position.end=Ll(K.end)}function Ie(K){A.call(this,K);const ue=this.stack[this.stack.length-1];ue.url=this.sliceSerialize(K)}function He(K){A.call(this,K);const ue=this.stack[this.stack.length-1];ue.url="mailto:"+this.sliceSerialize(K)}function ot(){return{type:"blockquote",children:[]}}function Je(){return{type:"code",lang:null,meta:null,value:""}}function tt(){return{type:"inlineCode",value:""}}function Ee(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Ae(){return{type:"emphasis",children:[]}}function yt(){return{type:"heading",depth:0,children:[]}}function dt(){return{type:"break"}}function xt(){return{type:"html",value:""}}function jt(){return{type:"image",title:null,url:"",alt:null}}function Wt(){return{type:"link",title:null,url:"",children:[]}}function Tt(K){return{type:"list",ordered:K.type==="listOrdered",start:null,spread:K._spread,children:[]}}function Ct(K){return{type:"listItem",spread:K._spread,checked:null,children:[]}}function Bn(){return{type:"paragraph",children:[]}}function me(){return{type:"strong",children:[]}}function Se(){return{type:"text",value:""}}function Ne(){return{type:"thematicBreak"}}}function Ll(e){return{line:e.line,column:e.column,offset:e.offset}}function tb(e,n){let a=-1;for(;++a<n.length;){const i=n[a];Array.isArray(i)?tb(e,i):b3(e,i)}}function b3(e,n){let a;for(a in n)if(eb.call(n,a))switch(a){case"canContainEols":{const i=n[a];i&&e[a].push(...i);break}case"transforms":{const i=n[a];i&&e[a].push(...i);break}case"enter":case"exit":{const i=n[a];i&&Object.assign(e[a],i);break}}}function tg(e,n){throw e?new Error("Cannot close `"+e.type+"` ("+_o({start:e.start,end:e.end})+"): a different token (`"+n.type+"`, "+_o({start:n.start,end:n.end})+") is open"):new Error("Cannot close document, a token (`"+n.type+"`, "+_o({start:n.start,end:n.end})+") is still open")}function v3(e){const n=this;n.parser=a;function a(i){return g3(i,{...n.data("settings"),...e,extensions:n.data("micromarkExtensions")||[],mdastExtensions:n.data("fromMarkdownExtensions")||[]})}}function w3(e,n){const a={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(n),!0)};return e.patch(n,a),e.applyData(n,a)}function k3(e,n){const a={type:"element",tagName:"br",properties:{},children:[]};return e.patch(n,a),[e.applyData(n,a),{type:"text",value:`
|
|
55
|
+
`}]}function j3(e,n){const a=n.value?n.value+`
|
|
56
|
+
`:"",i={},o=n.lang?n.lang.split(/\s+/):[];o.length>0&&(i.className=["language-"+o[0]]);let u={type:"element",tagName:"code",properties:i,children:[{type:"text",value:a}]};return n.meta&&(u.data={meta:n.meta}),e.patch(n,u),u=e.applyData(n,u),u={type:"element",tagName:"pre",properties:{},children:[u]},e.patch(n,u),u}function S3(e,n){const a={type:"element",tagName:"del",properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}function C3(e,n){const a={type:"element",tagName:"em",properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}function E3(e,n){const a=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",i=String(n.identifier).toUpperCase(),o=Cs(i.toLowerCase()),u=e.footnoteOrder.indexOf(i);let d,f=e.footnoteCounts.get(i);f===void 0?(f=0,e.footnoteOrder.push(i),d=e.footnoteOrder.length):d=u+1,f+=1,e.footnoteCounts.set(i,f);const m={type:"element",tagName:"a",properties:{href:"#"+a+"fn-"+o,id:a+"fnref-"+o+(f>1?"-"+f:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(d)}]};e.patch(n,m);const h={type:"element",tagName:"sup",properties:{},children:[m]};return e.patch(n,h),e.applyData(n,h)}function N3(e,n){const a={type:"element",tagName:"h"+n.depth,properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}function A3(e,n){if(e.options.allowDangerousHtml){const a={type:"raw",value:n.value};return e.patch(n,a),e.applyData(n,a)}}function nb(e,n){const a=n.referenceType;let i="]";if(a==="collapsed"?i+="[]":a==="full"&&(i+="["+(n.label||n.identifier)+"]"),n.type==="imageReference")return[{type:"text",value:"!["+n.alt+i}];const o=e.all(n),u=o[0];u&&u.type==="text"?u.value="["+u.value:o.unshift({type:"text",value:"["});const d=o[o.length-1];return d&&d.type==="text"?d.value+=i:o.push({type:"text",value:i}),o}function D3(e,n){const a=String(n.identifier).toUpperCase(),i=e.definitionById.get(a);if(!i)return nb(e,n);const o={src:Cs(i.url||""),alt:n.alt};i.title!==null&&i.title!==void 0&&(o.title=i.title);const u={type:"element",tagName:"img",properties:o,children:[]};return e.patch(n,u),e.applyData(n,u)}function T3(e,n){const a={src:Cs(n.url)};n.alt!==null&&n.alt!==void 0&&(a.alt=n.alt),n.title!==null&&n.title!==void 0&&(a.title=n.title);const i={type:"element",tagName:"img",properties:a,children:[]};return e.patch(n,i),e.applyData(n,i)}function F3(e,n){const a={type:"text",value:n.value.replace(/\r?\n|\r/g," ")};e.patch(n,a);const i={type:"element",tagName:"code",properties:{},children:[a]};return e.patch(n,i),e.applyData(n,i)}function M3(e,n){const a=String(n.identifier).toUpperCase(),i=e.definitionById.get(a);if(!i)return nb(e,n);const o={href:Cs(i.url||"")};i.title!==null&&i.title!==void 0&&(o.title=i.title);const u={type:"element",tagName:"a",properties:o,children:e.all(n)};return e.patch(n,u),e.applyData(n,u)}function R3(e,n){const a={href:Cs(n.url)};n.title!==null&&n.title!==void 0&&(a.title=n.title);const i={type:"element",tagName:"a",properties:a,children:e.all(n)};return e.patch(n,i),e.applyData(n,i)}function z3(e,n,a){const i=e.all(n),o=a?_3(a):rb(n),u={},d=[];if(typeof n.checked=="boolean"){const x=i[0];let g;x&&x.type==="element"&&x.tagName==="p"?g=x:(g={type:"element",tagName:"p",properties:{},children:[]},i.unshift(g)),g.children.length>0&&g.children.unshift({type:"text",value:" "}),g.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:n.checked,disabled:!0},children:[]}),u.className=["task-list-item"]}let f=-1;for(;++f<i.length;){const x=i[f];(o||f!==0||x.type!=="element"||x.tagName!=="p")&&d.push({type:"text",value:`
|
|
57
|
+
`}),x.type==="element"&&x.tagName==="p"&&!o?d.push(...x.children):d.push(x)}const m=i[i.length-1];m&&(o||m.type!=="element"||m.tagName!=="p")&&d.push({type:"text",value:`
|
|
58
|
+
`});const h={type:"element",tagName:"li",properties:u,children:d};return e.patch(n,h),e.applyData(n,h)}function _3(e){let n=!1;if(e.type==="list"){n=e.spread||!1;const a=e.children;let i=-1;for(;!n&&++i<a.length;)n=rb(a[i])}return n}function rb(e){const n=e.spread;return n??e.children.length>1}function B3(e,n){const a={},i=e.all(n);let o=-1;for(typeof n.start=="number"&&n.start!==1&&(a.start=n.start);++o<i.length;){const d=i[o];if(d.type==="element"&&d.tagName==="li"&&d.properties&&Array.isArray(d.properties.className)&&d.properties.className.includes("task-list-item")){a.className=["contains-task-list"];break}}const u={type:"element",tagName:n.ordered?"ol":"ul",properties:a,children:e.wrap(i,!0)};return e.patch(n,u),e.applyData(n,u)}function O3(e,n){const a={type:"element",tagName:"p",properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}function $3(e,n){const a={type:"root",children:e.wrap(e.all(n))};return e.patch(n,a),e.applyData(n,a)}function L3(e,n){const a={type:"element",tagName:"strong",properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}function I3(e,n){const a=e.all(n),i=a.shift(),o=[];if(i){const d={type:"element",tagName:"thead",properties:{},children:e.wrap([i],!0)};e.patch(n.children[0],d),o.push(d)}if(a.length>0){const d={type:"element",tagName:"tbody",properties:{},children:e.wrap(a,!0)},f=Cm(n.children[1]),m=By(n.children[n.children.length-1]);f&&m&&(d.position={start:f,end:m}),o.push(d)}const u={type:"element",tagName:"table",properties:{},children:e.wrap(o,!0)};return e.patch(n,u),e.applyData(n,u)}function H3(e,n,a){const i=a?a.children:void 0,u=(i?i.indexOf(n):1)===0?"th":"td",d=a&&a.type==="table"?a.align:void 0,f=d?d.length:n.children.length;let m=-1;const h=[];for(;++m<f;){const g=n.children[m],v={},b=d?d[m]:void 0;b&&(v.align=b);let j={type:"element",tagName:u,properties:v,children:[]};g&&(j.children=e.all(g),e.patch(g,j),j=e.applyData(g,j)),h.push(j)}const x={type:"element",tagName:"tr",properties:{},children:e.wrap(h,!0)};return e.patch(n,x),e.applyData(n,x)}function U3(e,n){const a={type:"element",tagName:"td",properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}const ng=9,rg=32;function q3(e){const n=String(e),a=/\r?\n|\r/g;let i=a.exec(n),o=0;const u=[];for(;i;)u.push(ag(n.slice(o,i.index),o>0,!0),i[0]),o=i.index+i[0].length,i=a.exec(n);return u.push(ag(n.slice(o),o>0,!1)),u.join("")}function ag(e,n,a){let i=0,o=e.length;if(n){let u=e.codePointAt(i);for(;u===ng||u===rg;)i++,u=e.codePointAt(i)}if(a){let u=e.codePointAt(o-1);for(;u===ng||u===rg;)o--,u=e.codePointAt(o-1)}return o>i?e.slice(i,o):""}function Y3(e,n){const a={type:"text",value:q3(String(n.value))};return e.patch(n,a),e.applyData(n,a)}function X3(e,n){const a={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(n,a),e.applyData(n,a)}const W3={blockquote:w3,break:k3,code:j3,delete:S3,emphasis:C3,footnoteReference:E3,heading:N3,html:A3,imageReference:D3,image:T3,inlineCode:F3,linkReference:M3,link:R3,listItem:z3,list:B3,paragraph:O3,root:$3,strong:L3,table:I3,tableCell:U3,tableRow:H3,text:Y3,thematicBreak:X3,toml:xu,yaml:xu,definition:xu,footnoteDefinition:xu};function xu(){}const ab=-1,Qu=0,Oo=1,Lu=2,Mm=3,Rm=4,zm=5,_m=6,lb=7,ib=8,lg=typeof self=="object"?self:globalThis,V3=(e,n)=>{const a=(o,u)=>(e.set(u,o),o),i=o=>{if(e.has(o))return e.get(o);const[u,d]=n[o];switch(u){case Qu:case ab:return a(d,o);case Oo:{const f=a([],o);for(const m of d)f.push(i(m));return f}case Lu:{const f=a({},o);for(const[m,h]of d)f[i(m)]=i(h);return f}case Mm:return a(new Date(d),o);case Rm:{const{source:f,flags:m}=d;return a(new RegExp(f,m),o)}case zm:{const f=a(new Map,o);for(const[m,h]of d)f.set(i(m),i(h));return f}case _m:{const f=a(new Set,o);for(const m of d)f.add(i(m));return f}case lb:{const{name:f,message:m}=d;return a(new lg[f](m),o)}case ib:return a(BigInt(d),o);case"BigInt":return a(Object(BigInt(d)),o);case"ArrayBuffer":return a(new Uint8Array(d).buffer,d);case"DataView":{const{buffer:f}=new Uint8Array(d);return a(new DataView(f),d)}}return a(new lg[u](d),o)};return i},ig=e=>V3(new Map,e)(0),ms="",{toString:G3}={},{keys:K3}=Object,Co=e=>{const n=typeof e;if(n!=="object"||!e)return[Qu,n];const a=G3.call(e).slice(8,-1);switch(a){case"Array":return[Oo,ms];case"Object":return[Lu,ms];case"Date":return[Mm,ms];case"RegExp":return[Rm,ms];case"Map":return[zm,ms];case"Set":return[_m,ms];case"DataView":return[Oo,a]}return a.includes("Array")?[Oo,a]:a.includes("Error")?[lb,a]:[Lu,a]},gu=([e,n])=>e===Qu&&(n==="function"||n==="symbol"),P3=(e,n,a,i)=>{const o=(d,f)=>{const m=i.push(d)-1;return a.set(f,m),m},u=d=>{if(a.has(d))return a.get(d);let[f,m]=Co(d);switch(f){case Qu:{let x=d;switch(m){case"bigint":f=ib,x=d.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+m);x=null;break;case"undefined":return o([ab],d)}return o([f,x],d)}case Oo:{if(m){let v=d;return m==="DataView"?v=new Uint8Array(d.buffer):m==="ArrayBuffer"&&(v=new Uint8Array(d)),o([m,[...v]],d)}const x=[],g=o([f,x],d);for(const v of d)x.push(u(v));return g}case Lu:{if(m)switch(m){case"BigInt":return o([m,d.toString()],d);case"Boolean":case"Number":case"String":return o([m,d.valueOf()],d)}if(n&&"toJSON"in d)return u(d.toJSON());const x=[],g=o([f,x],d);for(const v of K3(d))(e||!gu(Co(d[v])))&&x.push([u(v),u(d[v])]);return g}case Mm:return o([f,d.toISOString()],d);case Rm:{const{source:x,flags:g}=d;return o([f,{source:x,flags:g}],d)}case zm:{const x=[],g=o([f,x],d);for(const[v,b]of d)(e||!(gu(Co(v))||gu(Co(b))))&&x.push([u(v),u(b)]);return g}case _m:{const x=[],g=o([f,x],d);for(const v of d)(e||!gu(Co(v)))&&x.push(u(v));return g}}const{message:h}=d;return o([f,{name:m,message:h}],d)};return u},sg=(e,{json:n,lossy:a}={})=>{const i=[];return P3(!(n||a),!!n,new Map,i)(e),i},Iu=typeof structuredClone=="function"?(e,n)=>n&&("json"in n||"lossy"in n)?ig(sg(e,n)):structuredClone(e):(e,n)=>ig(sg(e,n));function Q3(e,n){const a=[{type:"text",value:"↩"}];return n>1&&a.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(n)}]}),a}function Z3(e,n){return"Back to reference "+(e+1)+(n>1?"-"+n:"")}function J3(e){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",a=e.options.footnoteBackContent||Q3,i=e.options.footnoteBackLabel||Z3,o=e.options.footnoteLabel||"Footnotes",u=e.options.footnoteLabelTagName||"h2",d=e.options.footnoteLabelProperties||{className:["sr-only"]},f=[];let m=-1;for(;++m<e.footnoteOrder.length;){const h=e.footnoteById.get(e.footnoteOrder[m]);if(!h)continue;const x=e.all(h),g=String(h.identifier).toUpperCase(),v=Cs(g.toLowerCase());let b=0;const j=[],k=e.footnoteCounts.get(g);for(;k!==void 0&&++b<=k;){j.length>0&&j.push({type:"text",value:" "});let C=typeof a=="string"?a:a(m,b);typeof C=="string"&&(C={type:"text",value:C}),j.push({type:"element",tagName:"a",properties:{href:"#"+n+"fnref-"+v+(b>1?"-"+b:""),dataFootnoteBackref:"",ariaLabel:typeof i=="string"?i:i(m,b),className:["data-footnote-backref"]},children:Array.isArray(C)?C:[C]})}const N=x[x.length-1];if(N&&N.type==="element"&&N.tagName==="p"){const C=N.children[N.children.length-1];C&&C.type==="text"?C.value+=" ":N.children.push({type:"text",value:" "}),N.children.push(...j)}else x.push(...j);const E={type:"element",tagName:"li",properties:{id:n+"fn-"+v},children:e.wrap(x,!0)};e.patch(h,E),f.push(E)}if(f.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:u,properties:{...Iu(d),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:`
|
|
59
|
+
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(f,!0)},{type:"text",value:`
|
|
60
|
+
`}]}}const Zu=(function(e){if(e==null)return r4;if(typeof e=="function")return Ju(e);if(typeof e=="object")return Array.isArray(e)?e4(e):t4(e);if(typeof e=="string")return n4(e);throw new Error("Expected function, string, or object as test")});function e4(e){const n=[];let a=-1;for(;++a<e.length;)n[a]=Zu(e[a]);return Ju(i);function i(...o){let u=-1;for(;++u<n.length;)if(n[u].apply(this,o))return!0;return!1}}function t4(e){const n=e;return Ju(a);function a(i){const o=i;let u;for(u in e)if(o[u]!==n[u])return!1;return!0}}function n4(e){return Ju(n);function n(a){return a&&a.type===e}}function Ju(e){return n;function n(a,i,o){return!!(a4(a)&&e.call(this,a,typeof i=="number"?i:void 0,o||void 0))}}function r4(){return!0}function a4(e){return e!==null&&typeof e=="object"&&"type"in e}const sb=[],l4=!0,Zh=!1,i4="skip";function ob(e,n,a,i){let o;typeof n=="function"&&typeof a!="function"?(i=a,a=n):o=n;const u=Zu(o),d=i?-1:1;f(e,void 0,[])();function f(m,h,x){const g=m&&typeof m=="object"?m:{};if(typeof g.type=="string"){const b=typeof g.tagName=="string"?g.tagName:typeof g.name=="string"?g.name:void 0;Object.defineProperty(v,"name",{value:"node ("+(m.type+(b?"<"+b+">":""))+")"})}return v;function v(){let b=sb,j,k,N;if((!n||u(m,h,x[x.length-1]||void 0))&&(b=s4(a(m,x)),b[0]===Zh))return b;if("children"in m&&m.children){const E=m;if(E.children&&b[0]!==i4)for(k=(i?E.children.length:-1)+d,N=x.concat(E);k>-1&&k<E.children.length;){const C=E.children[k];if(j=f(C,k,N)(),j[0]===Zh)return j;k=typeof j[1]=="number"?j[1]:k+d}}return b}}}function s4(e){return Array.isArray(e)?e:typeof e=="number"?[l4,e]:e==null?sb:[e]}function Bm(e,n,a,i){let o,u,d;typeof n=="function"&&typeof a!="function"?(u=void 0,d=n,o=a):(u=n,d=a,o=i),ob(e,u,f,o);function f(m,h){const x=h[h.length-1],g=x?x.children.indexOf(m):void 0;return d(m,g,x)}}const Jh={}.hasOwnProperty,o4={};function c4(e,n){const a=n||o4,i=new Map,o=new Map,u=new Map,d={...W3,...a.handlers},f={all:h,applyData:d4,definitionById:i,footnoteById:o,footnoteCounts:u,footnoteOrder:[],handlers:d,one:m,options:a,patch:u4,wrap:h4};return Bm(e,function(x){if(x.type==="definition"||x.type==="footnoteDefinition"){const g=x.type==="definition"?i:o,v=String(x.identifier).toUpperCase();g.has(v)||g.set(v,x)}}),f;function m(x,g){const v=x.type,b=f.handlers[v];if(Jh.call(f.handlers,v)&&b)return b(f,x,g);if(f.options.passThrough&&f.options.passThrough.includes(v)){if("children"in x){const{children:k,...N}=x,E=Iu(N);return E.children=f.all(x),E}return Iu(x)}return(f.options.unknownHandler||f4)(f,x,g)}function h(x){const g=[];if("children"in x){const v=x.children;let b=-1;for(;++b<v.length;){const j=f.one(v[b],x);if(j){if(b&&v[b-1].type==="break"&&(!Array.isArray(j)&&j.type==="text"&&(j.value=og(j.value)),!Array.isArray(j)&&j.type==="element")){const k=j.children[0];k&&k.type==="text"&&(k.value=og(k.value))}Array.isArray(j)?g.push(...j):g.push(j)}}}return g}}function u4(e,n){e.position&&(n.position=Zw(e))}function d4(e,n){let a=n;if(e&&e.data){const i=e.data.hName,o=e.data.hChildren,u=e.data.hProperties;if(typeof i=="string")if(a.type==="element")a.tagName=i;else{const d="children"in a?a.children:[a];a={type:"element",tagName:i,properties:{},children:d}}a.type==="element"&&u&&Object.assign(a.properties,Iu(u)),"children"in a&&a.children&&o!==null&&o!==void 0&&(a.children=o)}return a}function f4(e,n){const a=n.data||{},i="value"in n&&!(Jh.call(a,"hProperties")||Jh.call(a,"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 h4(e,n){const a=[];let i=-1;for(n&&a.push({type:"text",value:`
|
|
61
|
+
`});++i<e.length;)i&&a.push({type:"text",value:`
|
|
62
|
+
`}),a.push(e[i]);return n&&e.length>0&&a.push({type:"text",value:`
|
|
63
|
+
`}),a}function og(e){let n=0,a=e.charCodeAt(n);for(;a===9||a===32;)n++,a=e.charCodeAt(n);return e.slice(n)}function cg(e,n){const a=c4(e,n),i=a.one(e,void 0),o=J3(a),u=Array.isArray(i)?{type:"root",children:i}:i||{type:"root",children:[]};return o&&u.children.push({type:"text",value:`
|
|
64
|
+
`},o),u}function m4(e,n){return e&&"run"in e?async function(a,i){const o=cg(a,{file:i,...n});await e.run(o,i)}:function(a,i){return cg(a,{file:i,...e||n})}}function ug(e){if(e)throw e}var uh,dg;function p4(){if(dg)return uh;dg=1;var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,a=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=function(h){return typeof Array.isArray=="function"?Array.isArray(h):n.call(h)==="[object Array]"},u=function(h){if(!h||n.call(h)!=="[object Object]")return!1;var x=e.call(h,"constructor"),g=h.constructor&&h.constructor.prototype&&e.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!x&&!g)return!1;var v;for(v in h);return typeof v>"u"||e.call(h,v)},d=function(h,x){a&&x.name==="__proto__"?a(h,x.name,{enumerable:!0,configurable:!0,value:x.newValue,writable:!0}):h[x.name]=x.newValue},f=function(h,x){if(x==="__proto__")if(e.call(h,x)){if(i)return i(h,x).value}else return;return h[x]};return uh=function m(){var h,x,g,v,b,j,k=arguments[0],N=1,E=arguments.length,C=!1;for(typeof k=="boolean"&&(C=k,k=arguments[1]||{},N=2),(k==null||typeof k!="object"&&typeof k!="function")&&(k={});N<E;++N)if(h=arguments[N],h!=null)for(x in h)g=f(k,x),v=f(h,x),k!==v&&(C&&v&&(u(v)||(b=o(v)))?(b?(b=!1,j=g&&o(g)?g:[]):j=g&&u(g)?g:{},d(k,{name:x,newValue:m(C,j,v)})):typeof v<"u"&&d(k,{name:x,newValue:v}));return k},uh}var x4=p4();const dh=Ey(x4);function em(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 g4(){const e=[],n={run:a,use:i};return n;function a(...o){let u=-1;const d=o.pop();if(typeof d!="function")throw new TypeError("Expected function as last argument, not "+d);f(null,...o);function f(m,...h){const x=e[++u];let g=-1;if(m){d(m);return}for(;++g<o.length;)(h[g]===null||h[g]===void 0)&&(h[g]=o[g]);o=h,x?y4(x,f)(...h):d(null,...h)}}function i(o){if(typeof o!="function")throw new TypeError("Expected `middelware` to be a function, not "+o);return e.push(o),n}}function y4(e,n){let a;return i;function i(...d){const f=e.length>d.length;let m;f&&d.push(o);try{m=e.apply(this,d)}catch(h){const x=h;if(f&&a)throw x;return o(x)}f||(m&&m.then&&typeof m.then=="function"?m.then(u,o):m instanceof Error?o(m):u(m))}function o(d,...f){a||(a=!0,n(d,...f))}function u(d){o(null,d)}}const ja={basename:b4,dirname:v4,extname:w4,join:k4,sep:"/"};function b4(e,n){if(n!==void 0&&typeof n!="string")throw new TypeError('"ext" argument must be a string');Wo(e);let a=0,i=-1,o=e.length,u;if(n===void 0||n.length===0||n.length>e.length){for(;o--;)if(e.codePointAt(o)===47){if(u){a=o+1;break}}else i<0&&(u=!0,i=o+1);return i<0?"":e.slice(a,i)}if(n===e)return"";let d=-1,f=n.length-1;for(;o--;)if(e.codePointAt(o)===47){if(u){a=o+1;break}}else d<0&&(u=!0,d=o+1),f>-1&&(e.codePointAt(o)===n.codePointAt(f--)?f<0&&(i=o):(f=-1,i=d));return a===i?i=d:i<0&&(i=e.length),e.slice(a,i)}function v4(e){if(Wo(e),e.length===0)return".";let n=-1,a=e.length,i;for(;--a;)if(e.codePointAt(a)===47){if(i){n=a;break}}else i||(i=!0);return n<0?e.codePointAt(0)===47?"/":".":n===1&&e.codePointAt(0)===47?"//":e.slice(0,n)}function w4(e){Wo(e);let n=e.length,a=-1,i=0,o=-1,u=0,d;for(;n--;){const f=e.codePointAt(n);if(f===47){if(d){i=n+1;break}continue}a<0&&(d=!0,a=n+1),f===46?o<0?o=n:u!==1&&(u=1):o>-1&&(u=-1)}return o<0||a<0||u===0||u===1&&o===a-1&&o===i+1?"":e.slice(o,a)}function k4(...e){let n=-1,a;for(;++n<e.length;)Wo(e[n]),e[n]&&(a=a===void 0?e[n]:a+"/"+e[n]);return a===void 0?".":j4(a)}function j4(e){Wo(e);const n=e.codePointAt(0)===47;let a=S4(e,!n);return a.length===0&&!n&&(a="."),a.length>0&&e.codePointAt(e.length-1)===47&&(a+="/"),n?"/"+a:a}function S4(e,n){let a="",i=0,o=-1,u=0,d=-1,f,m;for(;++d<=e.length;){if(d<e.length)f=e.codePointAt(d);else{if(f===47)break;f=47}if(f===47){if(!(o===d-1||u===1))if(o!==d-1&&u===2){if(a.length<2||i!==2||a.codePointAt(a.length-1)!==46||a.codePointAt(a.length-2)!==46){if(a.length>2){if(m=a.lastIndexOf("/"),m!==a.length-1){m<0?(a="",i=0):(a=a.slice(0,m),i=a.length-1-a.lastIndexOf("/")),o=d,u=0;continue}}else if(a.length>0){a="",i=0,o=d,u=0;continue}}n&&(a=a.length>0?a+"/..":"..",i=2)}else a.length>0?a+="/"+e.slice(o+1,d):a=e.slice(o+1,d),i=d-o-1;o=d,u=0}else f===46&&u>-1?u++:u=-1}return a}function Wo(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const C4={cwd:E4};function E4(){return"/"}function tm(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function N4(e){if(typeof e=="string")e=new URL(e);else if(!tm(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 A4(e)}function A4(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 a=-1;for(;++a<n.length;)if(n.codePointAt(a)===37&&n.codePointAt(a+1)===50){const i=n.codePointAt(a+2);if(i===70||i===102){const o=new TypeError("File URL path must not include encoded / characters");throw o.code="ERR_INVALID_FILE_URL_PATH",o}}return decodeURIComponent(n)}const fh=["history","path","basename","stem","extname","dirname"];class cb{constructor(n){let a;n?tm(n)?a={path:n}:typeof n=="string"||D4(n)?a={value:n}:a=n:a={},this.cwd="cwd"in a?"":C4.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let i=-1;for(;++i<fh.length;){const u=fh[i];u in a&&a[u]!==void 0&&a[u]!==null&&(this[u]=u==="history"?[...a[u]]:a[u])}let o;for(o in a)fh.includes(o)||(this[o]=a[o])}get basename(){return typeof this.path=="string"?ja.basename(this.path):void 0}set basename(n){mh(n,"basename"),hh(n,"basename"),this.path=ja.join(this.dirname||"",n)}get dirname(){return typeof this.path=="string"?ja.dirname(this.path):void 0}set dirname(n){fg(this.basename,"dirname"),this.path=ja.join(n||"",this.basename)}get extname(){return typeof this.path=="string"?ja.extname(this.path):void 0}set extname(n){if(hh(n,"extname"),fg(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=ja.join(this.dirname,this.stem+(n||""))}get path(){return this.history[this.history.length-1]}set path(n){tm(n)&&(n=N4(n)),mh(n,"path"),this.path!==n&&this.history.push(n)}get stem(){return typeof this.path=="string"?ja.basename(this.path,this.extname):void 0}set stem(n){mh(n,"stem"),hh(n,"stem"),this.path=ja.join(this.dirname||"",n+(this.extname||""))}fail(n,a,i){const o=this.message(n,a,i);throw o.fatal=!0,o}info(n,a,i){const o=this.message(n,a,i);return o.fatal=void 0,o}message(n,a,i){const o=new ar(n,a,i);return this.path&&(o.name=this.path+":"+o.name,o.file=this.path),o.fatal=!1,this.messages.push(o),o}toString(n){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(n||void 0).decode(this.value)}}function hh(e,n){if(e&&e.includes(ja.sep))throw new Error("`"+n+"` cannot be a path: did not expect `"+ja.sep+"`")}function mh(e,n){if(!e)throw new Error("`"+n+"` cannot be empty")}function fg(e,n){if(!e)throw new Error("Setting `"+n+"` requires `path` to be set too")}function D4(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const T4=(function(e){const i=this.constructor.prototype,o=i[e],u=function(){return o.apply(u,arguments)};return Object.setPrototypeOf(u,i),u}),F4={}.hasOwnProperty;class Om extends T4{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=g4()}copy(){const n=new Om;let a=-1;for(;++a<this.attachers.length;){const i=this.attachers[a];n.use(...i)}return n.data(dh(!0,{},this.namespace)),n}data(n,a){return typeof n=="string"?arguments.length===2?(gh("data",this.frozen),this.namespace[n]=a,this):F4.call(this.namespace,n)&&this.namespace[n]||void 0:n?(gh("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[a,...i]=this.attachers[this.freezeIndex];if(i[0]===!1)continue;i[0]===!0&&(i[0]=void 0);const o=a.call(n,...i);typeof o=="function"&&this.transformers.use(o)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(n){this.freeze();const a=yu(n),i=this.parser||this.Parser;return ph("parse",i),i(String(a),a)}process(n,a){const i=this;return this.freeze(),ph("process",this.parser||this.Parser),xh("process",this.compiler||this.Compiler),a?o(void 0,a):new Promise(o);function o(u,d){const f=yu(n),m=i.parse(f);i.run(m,f,function(x,g,v){if(x||!g||!v)return h(x);const b=g,j=i.stringify(b,v);z4(j)?v.value=j:v.result=j,h(x,v)});function h(x,g){x||!g?d(x):u?u(g):a(void 0,g)}}}processSync(n){let a=!1,i;return this.freeze(),ph("processSync",this.parser||this.Parser),xh("processSync",this.compiler||this.Compiler),this.process(n,o),mg("processSync","process",a),i;function o(u,d){a=!0,ug(u),i=d}}run(n,a,i){hg(n),this.freeze();const o=this.transformers;return!i&&typeof a=="function"&&(i=a,a=void 0),i?u(void 0,i):new Promise(u);function u(d,f){const m=yu(a);o.run(n,m,h);function h(x,g,v){const b=g||n;x?f(x):d?d(b):i(void 0,b,v)}}}runSync(n,a){let i=!1,o;return this.run(n,a,u),mg("runSync","run",i),o;function u(d,f){ug(d),o=f,i=!0}}stringify(n,a){this.freeze();const i=yu(a),o=this.compiler||this.Compiler;return xh("stringify",o),hg(n),o(n,i)}use(n,...a){const i=this.attachers,o=this.namespace;if(gh("use",this.frozen),n!=null)if(typeof n=="function")m(n,a);else if(typeof n=="object")Array.isArray(n)?f(n):d(n);else throw new TypeError("Expected usable value, not `"+n+"`");return this;function u(h){if(typeof h=="function")m(h,[]);else if(typeof h=="object")if(Array.isArray(h)){const[x,...g]=h;m(x,g)}else d(h);else throw new TypeError("Expected usable value, not `"+h+"`")}function d(h){if(!("plugins"in h)&&!("settings"in h))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");f(h.plugins),h.settings&&(o.settings=dh(!0,o.settings,h.settings))}function f(h){let x=-1;if(h!=null)if(Array.isArray(h))for(;++x<h.length;){const g=h[x];u(g)}else throw new TypeError("Expected a list of plugins, not `"+h+"`")}function m(h,x){let g=-1,v=-1;for(;++g<i.length;)if(i[g][0]===h){v=g;break}if(v===-1)i.push([h,...x]);else if(x.length>0){let[b,...j]=x;const k=i[v][1];em(k)&&em(b)&&(b=dh(!0,k,b)),i[v]=[h,b,...j]}}}}const M4=new Om().freeze();function ph(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function xh(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function gh(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 hg(e){if(!em(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function mg(e,n,a){if(!a)throw new Error("`"+e+"` finished async. Use `"+n+"` instead")}function yu(e){return R4(e)?e:new cb(e)}function R4(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function z4(e){return typeof e=="string"||_4(e)}function _4(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const B4="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",pg=[],xg={allowDangerousHtml:!0},O4=/^(https?|ircs?|mailto|xmpp)$/i,$4=[{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 $m(e){const n=L4(e),a=I4(e);return H4(n.runSync(n.parse(a),a),e)}function L4(e){const n=e.rehypePlugins||pg,a=e.remarkPlugins||pg,i=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...xg}:xg;return M4().use(v3).use(a).use(m4,i).use(n)}function I4(e){const n=e.children||"",a=new cb;return typeof n=="string"&&(a.value=n),a}function H4(e,n){const a=n.allowedElements,i=n.allowElement,o=n.components,u=n.disallowedElements,d=n.skipHtml,f=n.unwrapDisallowed,m=n.urlTransform||U4;for(const x of $4)Object.hasOwn(n,x.from)&&(""+x.from+(x.to?"use `"+x.to+"` instead":"remove it")+B4+x.id,void 0);return Bm(e,h),r5(e,{Fragment:l.Fragment,components:o,ignoreInvalidStyle:!0,jsx:l.jsx,jsxs:l.jsxs,passKeys:!0,passNode:!0});function h(x,g,v){if(x.type==="raw"&&v&&typeof g=="number")return d?v.children.splice(g,1):v.children[g]={type:"text",value:x.value},g;if(x.type==="element"){let b;for(b in sh)if(Object.hasOwn(sh,b)&&Object.hasOwn(x.properties,b)){const j=x.properties[b],k=sh[b];(k===null||k.includes(x.tagName))&&(x.properties[b]=m(String(j||""),b,x))}}if(x.type==="element"){let b=a?!a.includes(x.tagName):u?u.includes(x.tagName):!1;if(!b&&i&&typeof g=="number"&&(b=!i(x,g,v)),b&&v&&typeof g=="number")return f&&x.children?v.children.splice(g,1,...x.children):v.children.splice(g,1),g}}}function U4(e){const n=e.indexOf(":"),a=e.indexOf("?"),i=e.indexOf("#"),o=e.indexOf("/");return n===-1||o!==-1&&n>o||a!==-1&&n>a||i!==-1&&n>i||O4.test(e.slice(0,n))?e:""}function gg(e,n){const a=String(e);if(typeof n!="string")throw new TypeError("Expected character");let i=0,o=a.indexOf(n);for(;o!==-1;)i++,o=a.indexOf(n,o+n.length);return i}function q4(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function Y4(e,n,a){const o=Zu((a||{}).ignore||[]),u=X4(n);let d=-1;for(;++d<u.length;)ob(e,"text",f);function f(h,x){let g=-1,v;for(;++g<x.length;){const b=x[g],j=v?v.children:void 0;if(o(b,j?j.indexOf(b):void 0,v))return;v=b}if(v)return m(h,x)}function m(h,x){const g=x[x.length-1],v=u[d][0],b=u[d][1];let j=0;const N=g.children.indexOf(h);let E=!1,C=[];v.lastIndex=0;let _=v.exec(h.value);for(;_;){const R=_.index,L={index:_.index,input:_.input,stack:[...x,h]};let F=b(..._,L);if(typeof F=="string"&&(F=F.length>0?{type:"text",value:F}:void 0),F===!1?v.lastIndex=R+1:(j!==R&&C.push({type:"text",value:h.value.slice(j,R)}),Array.isArray(F)?C.push(...F):F&&C.push(F),j=R+_[0].length,E=!0),!v.global)break;_=v.exec(h.value)}return E?(j<h.value.length&&C.push({type:"text",value:h.value.slice(j)}),g.children.splice(N,1,...C)):C=[h],N+C.length}}function X4(e){const n=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const a=!e[0]||Array.isArray(e[0])?e:[e];let i=-1;for(;++i<a.length;){const o=a[i];n.push([W4(o[0]),V4(o[1])])}return n}function W4(e){return typeof e=="string"?new RegExp(q4(e),"g"):e}function V4(e){return typeof e=="function"?e:function(){return e}}const yh="phrasing",bh=["autolink","link","image","label"];function G4(){return{transforms:[tj],enter:{literalAutolink:P4,literalAutolinkEmail:vh,literalAutolinkHttp:vh,literalAutolinkWww:vh},exit:{literalAutolink:ej,literalAutolinkEmail:J4,literalAutolinkHttp:Q4,literalAutolinkWww:Z4}}}function K4(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:yh,notInConstruct:bh},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:yh,notInConstruct:bh},{character:":",before:"[ps]",after:"\\/",inConstruct:yh,notInConstruct:bh}]}}function P4(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function vh(e){this.config.enter.autolinkProtocol.call(this,e)}function Q4(e){this.config.exit.autolinkProtocol.call(this,e)}function Z4(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 J4(e){this.config.exit.autolinkEmail.call(this,e)}function ej(e){this.exit(e)}function tj(e){Y4(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,nj],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),rj]],{ignore:["link","linkReference"]})}function nj(e,n,a,i,o){let u="";if(!ub(o)||(/^w/i.test(n)&&(a=n+a,n="",u="http://"),!aj(a)))return!1;const d=lj(a+i);if(!d[0])return!1;const f={type:"link",title:null,url:u+n+d[0],children:[{type:"text",value:n+d[0]}]};return d[1]?[f,{type:"text",value:d[1]}]:f}function rj(e,n,a,i){return!ub(i,!0)||/[-\d_]$/.test(a)?!1:{type:"link",title:null,url:"mailto:"+n+"@"+a,children:[{type:"text",value:n+"@"+a}]}}function aj(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 lj(e){const n=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!n)return[e,void 0];e=e.slice(0,n.index);let a=n[0],i=a.indexOf(")");const o=gg(e,"(");let u=gg(e,")");for(;i!==-1&&o>u;)e+=a.slice(0,i+1),a=a.slice(i+1),i=a.indexOf(")"),u++;return[e,a]}function ub(e,n){const a=e.input.charCodeAt(e.index-1);return(e.index===0||Ai(a)||Ku(a))&&(!n||a!==47)}db.peek=mj;function ij(){this.buffer()}function sj(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function oj(){this.buffer()}function cj(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function uj(e){const n=this.resume(),a=this.stack[this.stack.length-1];a.type,a.identifier=oa(this.sliceSerialize(e)).toLowerCase(),a.label=n}function dj(e){this.exit(e)}function fj(e){const n=this.resume(),a=this.stack[this.stack.length-1];a.type,a.identifier=oa(this.sliceSerialize(e)).toLowerCase(),a.label=n}function hj(e){this.exit(e)}function mj(){return"["}function db(e,n,a,i){const o=a.createTracker(i);let u=o.move("[^");const d=a.enter("footnoteReference"),f=a.enter("reference");return u+=o.move(a.safe(a.associationId(e),{after:"]",before:u})),f(),d(),u+=o.move("]"),u}function pj(){return{enter:{gfmFootnoteCallString:ij,gfmFootnoteCall:sj,gfmFootnoteDefinitionLabelString:oj,gfmFootnoteDefinition:cj},exit:{gfmFootnoteCallString:uj,gfmFootnoteCall:dj,gfmFootnoteDefinitionLabelString:fj,gfmFootnoteDefinition:hj}}}function xj(e){let n=!1;return e&&e.firstLineBlank&&(n=!0),{handlers:{footnoteDefinition:a,footnoteReference:db},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function a(i,o,u,d){const f=u.createTracker(d);let m=f.move("[^");const h=u.enter("footnoteDefinition"),x=u.enter("label");return m+=f.move(u.safe(u.associationId(i),{before:m,after:"]"})),x(),m+=f.move("]:"),i.children&&i.children.length>0&&(f.shift(4),m+=f.move((n?`
|
|
65
|
+
`:" ")+u.indentLines(u.containerFlow(i,f.current()),n?fb:gj))),h(),m}}function gj(e,n,a){return n===0?e:fb(e,n,a)}function fb(e,n,a){return(a?"":" ")+e}const yj=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];hb.peek=jj;function bj(){return{canContainEols:["delete"],enter:{strikethrough:wj},exit:{strikethrough:kj}}}function vj(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:yj}],handlers:{delete:hb}}}function wj(e){this.enter({type:"delete",children:[]},e)}function kj(e){this.exit(e)}function hb(e,n,a,i){const o=a.createTracker(i),u=a.enter("strikethrough");let d=o.move("~~");return d+=a.containerPhrasing(e,{...o.current(),before:d,after:"~"}),d+=o.move("~~"),u(),d}function jj(){return"~"}function Sj(e){return e.length}function Cj(e,n){const a=n||{},i=(a.align||[]).concat(),o=a.stringLength||Sj,u=[],d=[],f=[],m=[];let h=0,x=-1;for(;++x<e.length;){const k=[],N=[];let E=-1;for(e[x].length>h&&(h=e[x].length);++E<e[x].length;){const C=Ej(e[x][E]);if(a.alignDelimiters!==!1){const _=o(C);N[E]=_,(m[E]===void 0||_>m[E])&&(m[E]=_)}k.push(C)}d[x]=k,f[x]=N}let g=-1;if(typeof i=="object"&&"length"in i)for(;++g<h;)u[g]=yg(i[g]);else{const k=yg(i);for(;++g<h;)u[g]=k}g=-1;const v=[],b=[];for(;++g<h;){const k=u[g];let N="",E="";k===99?(N=":",E=":"):k===108?N=":":k===114&&(E=":");let C=a.alignDelimiters===!1?1:Math.max(1,m[g]-N.length-E.length);const _=N+"-".repeat(C)+E;a.alignDelimiters!==!1&&(C=N.length+C+E.length,C>m[g]&&(m[g]=C),b[g]=C),v[g]=_}d.splice(1,0,v),f.splice(1,0,b),x=-1;const j=[];for(;++x<d.length;){const k=d[x],N=f[x];g=-1;const E=[];for(;++g<h;){const C=k[g]||"";let _="",R="";if(a.alignDelimiters!==!1){const L=m[g]-(N[g]||0),F=u[g];F===114?_=" ".repeat(L):F===99?L%2?(_=" ".repeat(L/2+.5),R=" ".repeat(L/2-.5)):(_=" ".repeat(L/2),R=_):R=" ".repeat(L)}a.delimiterStart!==!1&&!g&&E.push("|"),a.padding!==!1&&!(a.alignDelimiters===!1&&C==="")&&(a.delimiterStart!==!1||g)&&E.push(" "),a.alignDelimiters!==!1&&E.push(_),E.push(C),a.alignDelimiters!==!1&&E.push(R),a.padding!==!1&&E.push(" "),(a.delimiterEnd!==!1||g!==h-1)&&E.push("|")}j.push(a.delimiterEnd===!1?E.join("").replace(/ +$/,""):E.join(""))}return j.join(`
|
|
66
|
+
`)}function Ej(e){return e==null?"":String(e)}function yg(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 Nj(e,n,a,i){const o=a.enter("blockquote"),u=a.createTracker(i);u.move("> "),u.shift(2);const d=a.indentLines(a.containerFlow(e,u.current()),Aj);return o(),d}function Aj(e,n,a){return">"+(a?"":" ")+e}function Dj(e,n){return bg(e,n.inConstruct,!0)&&!bg(e,n.notInConstruct,!1)}function bg(e,n,a){if(typeof n=="string"&&(n=[n]),!n||n.length===0)return a;let i=-1;for(;++i<n.length;)if(e.includes(n[i]))return!0;return!1}function vg(e,n,a,i){let o=-1;for(;++o<a.unsafe.length;)if(a.unsafe[o].character===`
|
|
67
|
+
`&&Dj(a.stack,a.unsafe[o]))return/[ \t]/.test(i.before)?"":" ";return`\\
|
|
68
|
+
`}function Tj(e,n){const a=String(e);let i=a.indexOf(n),o=i,u=0,d=0;if(typeof n!="string")throw new TypeError("Expected substring");for(;i!==-1;)i===o?++u>d&&(d=u):u=1,o=i+n.length,i=a.indexOf(n,o);return d}function Fj(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 Mj(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 Rj(e,n,a,i){const o=Mj(a),u=e.value||"",d=o==="`"?"GraveAccent":"Tilde";if(Fj(e,a)){const g=a.enter("codeIndented"),v=a.indentLines(u,zj);return g(),v}const f=a.createTracker(i),m=o.repeat(Math.max(Tj(u,o)+1,3)),h=a.enter("codeFenced");let x=f.move(m);if(e.lang){const g=a.enter(`codeFencedLang${d}`);x+=f.move(a.safe(e.lang,{before:x,after:" ",encode:["`"],...f.current()})),g()}if(e.lang&&e.meta){const g=a.enter(`codeFencedMeta${d}`);x+=f.move(" "),x+=f.move(a.safe(e.meta,{before:x,after:`
|
|
69
|
+
`,encode:["`"],...f.current()})),g()}return x+=f.move(`
|
|
70
|
+
`),u&&(x+=f.move(u+`
|
|
71
|
+
`)),x+=f.move(m),h(),x}function zj(e,n,a){return(a?"":" ")+e}function Lm(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 _j(e,n,a,i){const o=Lm(a),u=o==='"'?"Quote":"Apostrophe",d=a.enter("definition");let f=a.enter("label");const m=a.createTracker(i);let h=m.move("[");return h+=m.move(a.safe(a.associationId(e),{before:h,after:"]",...m.current()})),h+=m.move("]: "),f(),!e.url||/[\0- \u007F]/.test(e.url)?(f=a.enter("destinationLiteral"),h+=m.move("<"),h+=m.move(a.safe(e.url,{before:h,after:">",...m.current()})),h+=m.move(">")):(f=a.enter("destinationRaw"),h+=m.move(a.safe(e.url,{before:h,after:e.title?" ":`
|
|
72
|
+
`,...m.current()}))),f(),e.title&&(f=a.enter(`title${u}`),h+=m.move(" "+o),h+=m.move(a.safe(e.title,{before:h,after:o,...m.current()})),h+=m.move(o),f()),d(),h}function Bj(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 Io(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Hu(e,n,a){const i=bs(e),o=bs(n);return i===void 0?o===void 0?a==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:o===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:i===1?o===void 0?{inside:!1,outside:!1}:o===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:o===void 0?{inside:!1,outside:!1}:o===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}mb.peek=Oj;function mb(e,n,a,i){const o=Bj(a),u=a.enter("emphasis"),d=a.createTracker(i),f=d.move(o);let m=d.move(a.containerPhrasing(e,{after:o,before:f,...d.current()}));const h=m.charCodeAt(0),x=Hu(i.before.charCodeAt(i.before.length-1),h,o);x.inside&&(m=Io(h)+m.slice(1));const g=m.charCodeAt(m.length-1),v=Hu(i.after.charCodeAt(0),g,o);v.inside&&(m=m.slice(0,-1)+Io(g));const b=d.move(o);return u(),a.attentionEncodeSurroundingInfo={after:v.outside,before:x.outside},f+m+b}function Oj(e,n,a){return a.options.emphasis||"*"}function $j(e,n){let a=!1;return Bm(e,function(i){if("value"in i&&/\r?\n|\r/.test(i.value)||i.type==="break")return a=!0,Zh}),!!((!e.depth||e.depth<3)&&Dm(e)&&(n.options.setext||a))}function Lj(e,n,a,i){const o=Math.max(Math.min(6,e.depth||1),1),u=a.createTracker(i);if($j(e,a)){const x=a.enter("headingSetext"),g=a.enter("phrasing"),v=a.containerPhrasing(e,{...u.current(),before:`
|
|
73
|
+
`,after:`
|
|
74
|
+
`});return g(),x(),v+`
|
|
75
|
+
`+(o===1?"=":"-").repeat(v.length-(Math.max(v.lastIndexOf("\r"),v.lastIndexOf(`
|
|
76
|
+
`))+1))}const d="#".repeat(o),f=a.enter("headingAtx"),m=a.enter("phrasing");u.move(d+" ");let h=a.containerPhrasing(e,{before:"# ",after:`
|
|
77
|
+
`,...u.current()});return/^[\t ]/.test(h)&&(h=Io(h.charCodeAt(0))+h.slice(1)),h=h?d+" "+h:d,a.options.closeAtx&&(h+=" "+d),m(),f(),h}pb.peek=Ij;function pb(e){return e.value||""}function Ij(){return"<"}xb.peek=Hj;function xb(e,n,a,i){const o=Lm(a),u=o==='"'?"Quote":"Apostrophe",d=a.enter("image");let f=a.enter("label");const m=a.createTracker(i);let h=m.move("![");return h+=m.move(a.safe(e.alt,{before:h,after:"]",...m.current()})),h+=m.move("]("),f(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(f=a.enter("destinationLiteral"),h+=m.move("<"),h+=m.move(a.safe(e.url,{before:h,after:">",...m.current()})),h+=m.move(">")):(f=a.enter("destinationRaw"),h+=m.move(a.safe(e.url,{before:h,after:e.title?" ":")",...m.current()}))),f(),e.title&&(f=a.enter(`title${u}`),h+=m.move(" "+o),h+=m.move(a.safe(e.title,{before:h,after:o,...m.current()})),h+=m.move(o),f()),h+=m.move(")"),d(),h}function Hj(){return"!"}gb.peek=Uj;function gb(e,n,a,i){const o=e.referenceType,u=a.enter("imageReference");let d=a.enter("label");const f=a.createTracker(i);let m=f.move("![");const h=a.safe(e.alt,{before:m,after:"]",...f.current()});m+=f.move(h+"]["),d();const x=a.stack;a.stack=[],d=a.enter("reference");const g=a.safe(a.associationId(e),{before:m,after:"]",...f.current()});return d(),a.stack=x,u(),o==="full"||!h||h!==g?m+=f.move(g+"]"):o==="shortcut"?m=m.slice(0,-1):m+=f.move("]"),m}function Uj(){return"!"}yb.peek=qj;function yb(e,n,a){let i=e.value||"",o="`",u=-1;for(;new RegExp("(^|[^`])"+o+"([^`]|$)").test(i);)o+="`";for(/[^ \r\n]/.test(i)&&(/^[ \r\n]/.test(i)&&/[ \r\n]$/.test(i)||/^`|`$/.test(i))&&(i=" "+i+" ");++u<a.unsafe.length;){const d=a.unsafe[u],f=a.compilePattern(d);let m;if(d.atBreak)for(;m=f.exec(i);){let h=m.index;i.charCodeAt(h)===10&&i.charCodeAt(h-1)===13&&h--,i=i.slice(0,h)+" "+i.slice(m.index+1)}}return o+i+o}function qj(){return"`"}function bb(e,n){const a=Dm(e);return!!(!n.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(a===e.url||"mailto:"+a===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}vb.peek=Yj;function vb(e,n,a,i){const o=Lm(a),u=o==='"'?"Quote":"Apostrophe",d=a.createTracker(i);let f,m;if(bb(e,a)){const x=a.stack;a.stack=[],f=a.enter("autolink");let g=d.move("<");return g+=d.move(a.containerPhrasing(e,{before:g,after:">",...d.current()})),g+=d.move(">"),f(),a.stack=x,g}f=a.enter("link"),m=a.enter("label");let h=d.move("[");return h+=d.move(a.containerPhrasing(e,{before:h,after:"](",...d.current()})),h+=d.move("]("),m(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(m=a.enter("destinationLiteral"),h+=d.move("<"),h+=d.move(a.safe(e.url,{before:h,after:">",...d.current()})),h+=d.move(">")):(m=a.enter("destinationRaw"),h+=d.move(a.safe(e.url,{before:h,after:e.title?" ":")",...d.current()}))),m(),e.title&&(m=a.enter(`title${u}`),h+=d.move(" "+o),h+=d.move(a.safe(e.title,{before:h,after:o,...d.current()})),h+=d.move(o),m()),h+=d.move(")"),f(),h}function Yj(e,n,a){return bb(e,a)?"<":"["}wb.peek=Xj;function wb(e,n,a,i){const o=e.referenceType,u=a.enter("linkReference");let d=a.enter("label");const f=a.createTracker(i);let m=f.move("[");const h=a.containerPhrasing(e,{before:m,after:"]",...f.current()});m+=f.move(h+"]["),d();const x=a.stack;a.stack=[],d=a.enter("reference");const g=a.safe(a.associationId(e),{before:m,after:"]",...f.current()});return d(),a.stack=x,u(),o==="full"||!h||h!==g?m+=f.move(g+"]"):o==="shortcut"?m=m.slice(0,-1):m+=f.move("]"),m}function Xj(){return"["}function Im(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 Wj(e){const n=Im(e),a=e.options.bulletOther;if(!a)return n==="*"?"-":"*";if(a!=="*"&&a!=="+"&&a!=="-")throw new Error("Cannot serialize items with `"+a+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(a===n)throw new Error("Expected `bullet` (`"+n+"`) and `bulletOther` (`"+a+"`) to be different");return a}function Vj(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 kb(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 Gj(e,n,a,i){const o=a.enter("list"),u=a.bulletCurrent;let d=e.ordered?Vj(a):Im(a);const f=e.ordered?d==="."?")":".":Wj(a);let m=n&&a.bulletLastUsed?d===a.bulletLastUsed:!1;if(!e.ordered){const x=e.children?e.children[0]:void 0;if((d==="*"||d==="-")&&x&&(!x.children||!x.children[0])&&a.stack[a.stack.length-1]==="list"&&a.stack[a.stack.length-2]==="listItem"&&a.stack[a.stack.length-3]==="list"&&a.stack[a.stack.length-4]==="listItem"&&a.indexStack[a.indexStack.length-1]===0&&a.indexStack[a.indexStack.length-2]===0&&a.indexStack[a.indexStack.length-3]===0&&(m=!0),kb(a)===d&&x){let g=-1;for(;++g<e.children.length;){const v=e.children[g];if(v&&v.type==="listItem"&&v.children&&v.children[0]&&v.children[0].type==="thematicBreak"){m=!0;break}}}}m&&(d=f),a.bulletCurrent=d;const h=a.containerFlow(e,i);return a.bulletLastUsed=d,a.bulletCurrent=u,o(),h}function Kj(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 Pj(e,n,a,i){const o=Kj(a);let u=a.bulletCurrent||Im(a);n&&n.type==="list"&&n.ordered&&(u=(typeof n.start=="number"&&n.start>-1?n.start:1)+(a.options.incrementListMarker===!1?0:n.children.indexOf(e))+u);let d=u.length+1;(o==="tab"||o==="mixed"&&(n&&n.type==="list"&&n.spread||e.spread))&&(d=Math.ceil(d/4)*4);const f=a.createTracker(i);f.move(u+" ".repeat(d-u.length)),f.shift(d);const m=a.enter("listItem"),h=a.indentLines(a.containerFlow(e,f.current()),x);return m(),h;function x(g,v,b){return v?(b?"":" ".repeat(d))+g:(b?u:u+" ".repeat(d-u.length))+g}}function Qj(e,n,a,i){const o=a.enter("paragraph"),u=a.enter("phrasing"),d=a.containerPhrasing(e,i);return u(),o(),d}const Zj=Zu(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Jj(e,n,a,i){return(e.children.some(function(d){return Zj(d)})?a.containerPhrasing:a.containerFlow).call(a,e,i)}function eS(e){const n=e.options.strong||"*";if(n!=="*"&&n!=="_")throw new Error("Cannot serialize strong with `"+n+"` for `options.strong`, expected `*`, or `_`");return n}jb.peek=tS;function jb(e,n,a,i){const o=eS(a),u=a.enter("strong"),d=a.createTracker(i),f=d.move(o+o);let m=d.move(a.containerPhrasing(e,{after:o,before:f,...d.current()}));const h=m.charCodeAt(0),x=Hu(i.before.charCodeAt(i.before.length-1),h,o);x.inside&&(m=Io(h)+m.slice(1));const g=m.charCodeAt(m.length-1),v=Hu(i.after.charCodeAt(0),g,o);v.inside&&(m=m.slice(0,-1)+Io(g));const b=d.move(o+o);return u(),a.attentionEncodeSurroundingInfo={after:v.outside,before:x.outside},f+m+b}function tS(e,n,a){return a.options.strong||"*"}function nS(e,n,a,i){return a.safe(e.value,i)}function rS(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 aS(e,n,a){const i=(kb(a)+(a.options.ruleSpaces?" ":"")).repeat(rS(a));return a.options.ruleSpaces?i.slice(0,-1):i}const Sb={blockquote:Nj,break:vg,code:Rj,definition:_j,emphasis:mb,hardBreak:vg,heading:Lj,html:pb,image:xb,imageReference:gb,inlineCode:yb,link:vb,linkReference:wb,list:Gj,listItem:Pj,paragraph:Qj,root:Jj,strong:jb,text:nS,thematicBreak:aS};function lS(){return{enter:{table:iS,tableData:wg,tableHeader:wg,tableRow:oS},exit:{codeText:cS,table:sS,tableData:wh,tableHeader:wh,tableRow:wh}}}function iS(e){const n=e._align;this.enter({type:"table",align:n.map(function(a){return a==="none"?null:a}),children:[]},e),this.data.inTable=!0}function sS(e){this.exit(e),this.data.inTable=void 0}function oS(e){this.enter({type:"tableRow",children:[]},e)}function wh(e){this.exit(e)}function wg(e){this.enter({type:"tableCell",children:[]},e)}function cS(e){let n=this.resume();this.data.inTable&&(n=n.replace(/\\([\\|])/g,uS));const a=this.stack[this.stack.length-1];a.type,a.value=n,this.exit(e)}function uS(e,n){return n==="|"?n:e}function dS(e){const n=e||{},a=n.tableCellPadding,i=n.tablePipeAlign,o=n.stringLength,u=a?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
78
|
+
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:v,table:d,tableCell:m,tableRow:f}};function d(b,j,k,N){return h(x(b,k,N),b.align)}function f(b,j,k,N){const E=g(b,k,N),C=h([E]);return C.slice(0,C.indexOf(`
|
|
79
|
+
`))}function m(b,j,k,N){const E=k.enter("tableCell"),C=k.enter("phrasing"),_=k.containerPhrasing(b,{...N,before:u,after:u});return C(),E(),_}function h(b,j){return Cj(b,{align:j,alignDelimiters:i,padding:a,stringLength:o})}function x(b,j,k){const N=b.children;let E=-1;const C=[],_=j.enter("table");for(;++E<N.length;)C[E]=g(N[E],j,k);return _(),C}function g(b,j,k){const N=b.children;let E=-1;const C=[],_=j.enter("tableRow");for(;++E<N.length;)C[E]=m(N[E],b,j,k);return _(),C}function v(b,j,k){let N=Sb.inlineCode(b,j,k);return k.stack.includes("tableCell")&&(N=N.replace(/\|/g,"\\$&")),N}}function fS(){return{exit:{taskListCheckValueChecked:kg,taskListCheckValueUnchecked:kg,paragraph:mS}}}function hS(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:pS}}}function kg(e){const n=this.stack[this.stack.length-2];n.type,n.checked=e.type==="taskListCheckValueChecked"}function mS(e){const n=this.stack[this.stack.length-2];if(n&&n.type==="listItem"&&typeof n.checked=="boolean"){const a=this.stack[this.stack.length-1];a.type;const i=a.children[0];if(i&&i.type==="text"){const o=n.children;let u=-1,d;for(;++u<o.length;){const f=o[u];if(f.type==="paragraph"){d=f;break}}d===a&&(i.value=i.value.slice(1),i.value.length===0?a.children.shift():a.position&&i.position&&typeof i.position.start.offset=="number"&&(i.position.start.column++,i.position.start.offset++,a.position.start=Object.assign({},i.position.start)))}}this.exit(e)}function pS(e,n,a,i){const o=e.children[0],u=typeof e.checked=="boolean"&&o&&o.type==="paragraph",d="["+(e.checked?"x":" ")+"] ",f=a.createTracker(i);u&&f.move(d);let m=Sb.listItem(e,n,a,{...i,...f.current()});return u&&(m=m.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,h)),m;function h(x){return x+d}}function xS(){return[G4(),pj(),bj(),lS(),fS()]}function gS(e){return{extensions:[K4(),xj(e),vj(),dS(e),hS()]}}const yS={tokenize:SS,partial:!0},Cb={tokenize:CS,partial:!0},Eb={tokenize:ES,partial:!0},Nb={tokenize:NS,partial:!0},bS={tokenize:AS,partial:!0},Ab={name:"wwwAutolink",tokenize:kS,previous:Tb},Db={name:"protocolAutolink",tokenize:jS,previous:Fb},sl={name:"emailAutolink",tokenize:wS,previous:Mb},Da={};function vS(){return{text:Da}}let yi=48;for(;yi<123;)Da[yi]=sl,yi++,yi===58?yi=65:yi===91&&(yi=97);Da[43]=sl;Da[45]=sl;Da[46]=sl;Da[95]=sl;Da[72]=[sl,Db];Da[104]=[sl,Db];Da[87]=[sl,Ab];Da[119]=[sl,Ab];function wS(e,n,a){const i=this;let o,u;return d;function d(g){return!nm(g)||!Mb.call(i,i.previous)||Hm(i.events)?a(g):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),f(g))}function f(g){return nm(g)?(e.consume(g),f):g===64?(e.consume(g),m):a(g)}function m(g){return g===46?e.check(bS,x,h)(g):g===45||g===95||rr(g)?(u=!0,e.consume(g),m):x(g)}function h(g){return e.consume(g),o=!0,m}function x(g){return u&&o&&cr(i.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),n(g)):a(g)}}function kS(e,n,a){const i=this;return o;function o(d){return d!==87&&d!==119||!Tb.call(i,i.previous)||Hm(i.events)?a(d):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(yS,e.attempt(Cb,e.attempt(Eb,u),a),a)(d))}function u(d){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),n(d)}}function jS(e,n,a){const i=this;let o="",u=!1;return d;function d(g){return(g===72||g===104)&&Fb.call(i,i.previous)&&!Hm(i.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(g),e.consume(g),f):a(g)}function f(g){if(cr(g)&&o.length<5)return o+=String.fromCodePoint(g),e.consume(g),f;if(g===58){const v=o.toLowerCase();if(v==="http"||v==="https")return e.consume(g),m}return a(g)}function m(g){return g===47?(e.consume(g),u?h:(u=!0,m)):a(g)}function h(g){return g===null||$u(g)||cn(g)||Ai(g)||Ku(g)?a(g):e.attempt(Cb,e.attempt(Eb,x),a)(g)}function x(g){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),n(g)}}function SS(e,n,a){let i=0;return o;function o(d){return(d===87||d===119)&&i<3?(i++,e.consume(d),o):d===46&&i===3?(e.consume(d),u):a(d)}function u(d){return d===null?a(d):n(d)}}function CS(e,n,a){let i,o,u;return d;function d(h){return h===46||h===95?e.check(Nb,m,f)(h):h===null||cn(h)||Ai(h)||h!==45&&Ku(h)?m(h):(u=!0,e.consume(h),d)}function f(h){return h===95?i=!0:(o=i,i=void 0),e.consume(h),d}function m(h){return o||i||!u?a(h):n(h)}}function ES(e,n){let a=0,i=0;return o;function o(d){return d===40?(a++,e.consume(d),o):d===41&&i<a?u(d):d===33||d===34||d===38||d===39||d===41||d===42||d===44||d===46||d===58||d===59||d===60||d===63||d===93||d===95||d===126?e.check(Nb,n,u)(d):d===null||cn(d)||Ai(d)?n(d):(e.consume(d),o)}function u(d){return d===41&&i++,e.consume(d),o}}function NS(e,n,a){return i;function i(f){return f===33||f===34||f===39||f===41||f===42||f===44||f===46||f===58||f===59||f===63||f===95||f===126?(e.consume(f),i):f===38?(e.consume(f),u):f===93?(e.consume(f),o):f===60||f===null||cn(f)||Ai(f)?n(f):a(f)}function o(f){return f===null||f===40||f===91||cn(f)||Ai(f)?n(f):i(f)}function u(f){return cr(f)?d(f):a(f)}function d(f){return f===59?(e.consume(f),i):cr(f)?(e.consume(f),d):a(f)}}function AS(e,n,a){return i;function i(u){return e.consume(u),o}function o(u){return rr(u)?a(u):n(u)}}function Tb(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||cn(e)}function Fb(e){return!cr(e)}function Mb(e){return!(e===47||nm(e))}function nm(e){return e===43||e===45||e===46||e===95||rr(e)}function Hm(e){let n=e.length,a=!1;for(;n--;){const i=e[n][1];if((i.type==="labelLink"||i.type==="labelImage")&&!i._balanced){a=!0;break}if(i._gfmAutolinkLiteralWalkedInto){a=!1;break}}return e.length>0&&!a&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),a}const DS={tokenize:OS,partial:!0};function TS(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:zS,continuation:{tokenize:_S},exit:BS}},text:{91:{name:"gfmFootnoteCall",tokenize:RS},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:FS,resolveTo:MS}}}}function FS(e,n,a){const i=this;let o=i.events.length;const u=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let d;for(;o--;){const m=i.events[o][1];if(m.type==="labelImage"){d=m;break}if(m.type==="gfmFootnoteCall"||m.type==="labelLink"||m.type==="label"||m.type==="image"||m.type==="link")break}return f;function f(m){if(!d||!d._balanced)return a(m);const h=oa(i.sliceSerialize({start:d.end,end:i.now()}));return h.codePointAt(0)!==94||!u.includes(h.slice(1))?a(m):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),n(m))}}function MS(e,n){let a=e.length;for(;a--;)if(e[a][1].type==="labelImage"&&e[a][0]==="enter"){e[a][1];break}e[a+1][1].type="data",e[a+3][1].type="gfmFootnoteCallLabelMarker";const i={type:"gfmFootnoteCall",start:Object.assign({},e[a+3][1].start),end:Object.assign({},e[e.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},e[a+3][1].end),end:Object.assign({},e[a+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const u={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},e[e.length-1][1].start)},d={type:"chunkString",contentType:"string",start:Object.assign({},u.start),end:Object.assign({},u.end)},f=[e[a+1],e[a+2],["enter",i,n],e[a+3],e[a+4],["enter",o,n],["exit",o,n],["enter",u,n],["enter",d,n],["exit",d,n],["exit",u,n],e[e.length-2],e[e.length-1],["exit",i,n]];return e.splice(a,e.length-a+1,...f),e}function RS(e,n,a){const i=this,o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let u=0,d;return f;function f(g){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),m}function m(g){return g!==94?a(g):(e.enter("gfmFootnoteCallMarker"),e.consume(g),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(g){if(u>999||g===93&&!d||g===null||g===91||cn(g))return a(g);if(g===93){e.exit("chunkString");const v=e.exit("gfmFootnoteCallString");return o.includes(oa(i.sliceSerialize(v)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),n):a(g)}return cn(g)||(d=!0),u++,e.consume(g),g===92?x:h}function x(g){return g===91||g===92||g===93?(e.consume(g),u++,h):h(g)}}function zS(e,n,a){const i=this,o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let u,d=0,f;return m;function m(j){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(j),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(j){return j===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(j),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",x):a(j)}function x(j){if(d>999||j===93&&!f||j===null||j===91||cn(j))return a(j);if(j===93){e.exit("chunkString");const k=e.exit("gfmFootnoteDefinitionLabelString");return u=oa(i.sliceSerialize(k)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(j),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),v}return cn(j)||(f=!0),d++,e.consume(j),j===92?g:x}function g(j){return j===91||j===92||j===93?(e.consume(j),d++,x):x(j)}function v(j){return j===58?(e.enter("definitionMarker"),e.consume(j),e.exit("definitionMarker"),o.includes(u)||o.push(u),Ht(e,b,"gfmFootnoteDefinitionWhitespace")):a(j)}function b(j){return n(j)}}function _S(e,n,a){return e.check(Xo,n,e.attempt(DS,n,a))}function BS(e){e.exit("gfmFootnoteDefinition")}function OS(e,n,a){const i=this;return Ht(e,o,"gfmFootnoteDefinitionIndent",5);function o(u){const d=i.events[i.events.length-1];return d&&d[1].type==="gfmFootnoteDefinitionIndent"&&d[2].sliceSerialize(d[1],!0).length===4?n(u):a(u)}}function $S(e){let a=(e||{}).singleTilde;const i={name:"strikethrough",tokenize:u,resolveAll:o};return a==null&&(a=!0),{text:{126:i},insideSpan:{null:[i]},attentionMarkers:{null:[126]}};function o(d,f){let m=-1;for(;++m<d.length;)if(d[m][0]==="enter"&&d[m][1].type==="strikethroughSequenceTemporary"&&d[m][1]._close){let h=m;for(;h--;)if(d[h][0]==="exit"&&d[h][1].type==="strikethroughSequenceTemporary"&&d[h][1]._open&&d[m][1].end.offset-d[m][1].start.offset===d[h][1].end.offset-d[h][1].start.offset){d[m][1].type="strikethroughSequence",d[h][1].type="strikethroughSequence";const x={type:"strikethrough",start:Object.assign({},d[h][1].start),end:Object.assign({},d[m][1].end)},g={type:"strikethroughText",start:Object.assign({},d[h][1].end),end:Object.assign({},d[m][1].start)},v=[["enter",x,f],["enter",d[h][1],f],["exit",d[h][1],f],["enter",g,f]],b=f.parser.constructs.insideSpan.null;b&&Br(v,v.length,0,Pu(b,d.slice(h+1,m),f)),Br(v,v.length,0,[["exit",g,f],["enter",d[m][1],f],["exit",d[m][1],f],["exit",x,f]]),Br(d,h-1,m-h+3,v),m=h+v.length-2;break}}for(m=-1;++m<d.length;)d[m][1].type==="strikethroughSequenceTemporary"&&(d[m][1].type="data");return d}function u(d,f,m){const h=this.previous,x=this.events;let g=0;return v;function v(j){return h===126&&x[x.length-1][1].type!=="characterEscape"?m(j):(d.enter("strikethroughSequenceTemporary"),b(j))}function b(j){const k=bs(h);if(j===126)return g>1?m(j):(d.consume(j),g++,b);if(g<2&&!a)return m(j);const N=d.exit("strikethroughSequenceTemporary"),E=bs(j);return N._open=!E||E===2&&!!k,N._close=!k||k===2&&!!E,f(j)}}}class LS{constructor(){this.map=[]}add(n,a,i){IS(this,n,a,i)}consume(n){if(this.map.sort(function(u,d){return u[0]-d[0]}),this.map.length===0)return;let a=this.map.length;const i=[];for(;a>0;)a-=1,i.push(n.slice(this.map[a][0]+this.map[a][1]),this.map[a][2]),n.length=this.map[a][0];i.push(n.slice()),n.length=0;let o=i.pop();for(;o;){for(const u of o)n.push(u);o=i.pop()}this.map.length=0}}function IS(e,n,a,i){let o=0;if(!(a===0&&i.length===0)){for(;o<e.map.length;){if(e.map[o][0]===n){e.map[o][1]+=a,e.map[o][2].push(...i);return}o+=1}e.map.push([n,a,i])}}function HS(e,n){let a=!1;const i=[];for(;n<e.length;){const o=e[n];if(a){if(o[0]==="enter")o[1].type==="tableContent"&&i.push(e[n+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(e[n-1][1].type==="tableDelimiterMarker"){const u=i.length-1;i[u]=i[u]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(a=!0);n+=1}return i}function US(){return{flow:{null:{name:"table",tokenize:qS,resolveAll:YS}}}}function qS(e,n,a){const i=this;let o=0,u=0,d;return f;function f(A){let $=i.events.length-1;for(;$>-1;){const ie=i.events[$][1].type;if(ie==="lineEnding"||ie==="linePrefix")$--;else break}const q=$>-1?i.events[$][1].type:null,W=q==="tableHead"||q==="tableRow"?F:m;return W===F&&i.parser.lazy[i.now().line]?a(A):W(A)}function m(A){return e.enter("tableHead"),e.enter("tableRow"),h(A)}function h(A){return A===124||(d=!0,u+=1),x(A)}function x(A){return A===null?a(A):lt(A)?u>1?(u=0,i.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),b):a(A):Dt(A)?Ht(e,x,"whitespace")(A):(u+=1,d&&(d=!1,o+=1),A===124?(e.enter("tableCellDivider"),e.consume(A),e.exit("tableCellDivider"),d=!0,x):(e.enter("data"),g(A)))}function g(A){return A===null||A===124||cn(A)?(e.exit("data"),x(A)):(e.consume(A),A===92?v:g)}function v(A){return A===92||A===124?(e.consume(A),g):g(A)}function b(A){return i.interrupt=!1,i.parser.lazy[i.now().line]?a(A):(e.enter("tableDelimiterRow"),d=!1,Dt(A)?Ht(e,j,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):j(A))}function j(A){return A===45||A===58?N(A):A===124?(d=!0,e.enter("tableCellDivider"),e.consume(A),e.exit("tableCellDivider"),k):L(A)}function k(A){return Dt(A)?Ht(e,N,"whitespace")(A):N(A)}function N(A){return A===58?(u+=1,d=!0,e.enter("tableDelimiterMarker"),e.consume(A),e.exit("tableDelimiterMarker"),E):A===45?(u+=1,E(A)):A===null||lt(A)?R(A):L(A)}function E(A){return A===45?(e.enter("tableDelimiterFiller"),C(A)):L(A)}function C(A){return A===45?(e.consume(A),C):A===58?(d=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(A),e.exit("tableDelimiterMarker"),_):(e.exit("tableDelimiterFiller"),_(A))}function _(A){return Dt(A)?Ht(e,R,"whitespace")(A):R(A)}function R(A){return A===124?j(A):A===null||lt(A)?!d||o!==u?L(A):(e.exit("tableDelimiterRow"),e.exit("tableHead"),n(A)):L(A)}function L(A){return a(A)}function F(A){return e.enter("tableRow"),I(A)}function I(A){return A===124?(e.enter("tableCellDivider"),e.consume(A),e.exit("tableCellDivider"),I):A===null||lt(A)?(e.exit("tableRow"),n(A)):Dt(A)?Ht(e,I,"whitespace")(A):(e.enter("data"),H(A))}function H(A){return A===null||A===124||cn(A)?(e.exit("data"),I(A)):(e.consume(A),A===92?X:H)}function X(A){return A===92||A===124?(e.consume(A),H):H(A)}}function YS(e,n){let a=-1,i=!0,o=0,u=[0,0,0,0],d=[0,0,0,0],f=!1,m=0,h,x,g;const v=new LS;for(;++a<e.length;){const b=e[a],j=b[1];b[0]==="enter"?j.type==="tableHead"?(f=!1,m!==0&&(jg(v,n,m,h,x),x=void 0,m=0),h={type:"table",start:Object.assign({},j.start),end:Object.assign({},j.end)},v.add(a,0,[["enter",h,n]])):j.type==="tableRow"||j.type==="tableDelimiterRow"?(i=!0,g=void 0,u=[0,0,0,0],d=[0,a+1,0,0],f&&(f=!1,x={type:"tableBody",start:Object.assign({},j.start),end:Object.assign({},j.end)},v.add(a,0,[["enter",x,n]])),o=j.type==="tableDelimiterRow"?2:x?3:1):o&&(j.type==="data"||j.type==="tableDelimiterMarker"||j.type==="tableDelimiterFiller")?(i=!1,d[2]===0&&(u[1]!==0&&(d[0]=d[1],g=bu(v,n,u,o,void 0,g),u=[0,0,0,0]),d[2]=a)):j.type==="tableCellDivider"&&(i?i=!1:(u[1]!==0&&(d[0]=d[1],g=bu(v,n,u,o,void 0,g)),u=d,d=[u[1],a,0,0])):j.type==="tableHead"?(f=!0,m=a):j.type==="tableRow"||j.type==="tableDelimiterRow"?(m=a,u[1]!==0?(d[0]=d[1],g=bu(v,n,u,o,a,g)):d[1]!==0&&(g=bu(v,n,d,o,a,g)),o=0):o&&(j.type==="data"||j.type==="tableDelimiterMarker"||j.type==="tableDelimiterFiller")&&(d[3]=a)}for(m!==0&&jg(v,n,m,h,x),v.consume(n.events),a=-1;++a<n.events.length;){const b=n.events[a];b[0]==="enter"&&b[1].type==="table"&&(b[1]._align=HS(n.events,a))}return e}function bu(e,n,a,i,o,u){const d=i===1?"tableHeader":i===2?"tableDelimiter":"tableData",f="tableContent";a[0]!==0&&(u.end=Object.assign({},ps(n.events,a[0])),e.add(a[0],0,[["exit",u,n]]));const m=ps(n.events,a[1]);if(u={type:d,start:Object.assign({},m),end:Object.assign({},m)},e.add(a[1],0,[["enter",u,n]]),a[2]!==0){const h=ps(n.events,a[2]),x=ps(n.events,a[3]),g={type:f,start:Object.assign({},h),end:Object.assign({},x)};if(e.add(a[2],0,[["enter",g,n]]),i!==2){const v=n.events[a[2]],b=n.events[a[3]];if(v[1].end=Object.assign({},b[1].end),v[1].type="chunkText",v[1].contentType="text",a[3]>a[2]+1){const j=a[2]+1,k=a[3]-a[2]-1;e.add(j,k,[])}}e.add(a[3]+1,0,[["exit",g,n]])}return o!==void 0&&(u.end=Object.assign({},ps(n.events,o)),e.add(o,0,[["exit",u,n]]),u=void 0),u}function jg(e,n,a,i,o){const u=[],d=ps(n.events,a);o&&(o.end=Object.assign({},d),u.push(["exit",o,n])),i.end=Object.assign({},d),u.push(["exit",i,n]),e.add(a+1,0,u)}function ps(e,n){const a=e[n],i=a[0]==="enter"?"start":"end";return a[1][i]}const XS={name:"tasklistCheck",tokenize:VS};function WS(){return{text:{91:XS}}}function VS(e,n,a){const i=this;return o;function o(m){return i.previous!==null||!i._gfmTasklistFirstContentOfListItem?a(m):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(m),e.exit("taskListCheckMarker"),u)}function u(m){return cn(m)?(e.enter("taskListCheckValueUnchecked"),e.consume(m),e.exit("taskListCheckValueUnchecked"),d):m===88||m===120?(e.enter("taskListCheckValueChecked"),e.consume(m),e.exit("taskListCheckValueChecked"),d):a(m)}function d(m){return m===93?(e.enter("taskListCheckMarker"),e.consume(m),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),f):a(m)}function f(m){return lt(m)?n(m):Dt(m)?e.check({tokenize:GS},n,a)(m):a(m)}}function GS(e,n,a){return Ht(e,i,"whitespace");function i(o){return o===null?a(o):n(o)}}function KS(e){return qy([vS(),TS(),$S(e),US(),WS()])}const PS={};function Um(e){const n=this,a=e||PS,i=n.data(),o=i.micromarkExtensions||(i.micromarkExtensions=[]),u=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),d=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);o.push(KS(a)),u.push(xS()),d.push(gS(a))}function Es({content:e,className:n=""}){return l.jsx("div",{className:`office-markdown ${n}`,children:l.jsx($m,{remarkPlugins:[Um],components:{code:QS,table:({children:a})=>l.jsx("div",{className:"overflow-x-auto my-2",children:l.jsx("table",{className:"office-table",children:a})})},children:e})})}function QS({className:e,children:n,...a}){const i=/language-(\w+)/.exec(e??"");return i||typeof n=="string"&&n.includes(`
|
|
80
|
+
`)?l.jsx(ZS,{language:i==null?void 0:i[1],children:n}):l.jsx("code",{className:"bg-gray-100 text-gray-700 px-1 py-0.5 rounded text-[0.9em] font-mono",...a,children:n})}function ZS({children:e,language:n}){const[a,i]=w.useState(!1),o=String(e).replace(/\n$/,""),u=()=>{navigator.clipboard.writeText(o),i(!0),setTimeout(()=>i(!1),1500)};return l.jsxs("div",{className:"office-code-block group relative my-2",children:[n&&l.jsx("div",{className:"text-[10px] text-gray-400 px-3 pt-1.5",children:n}),l.jsx("button",{onClick:u,className:"absolute top-1.5 right-2 text-[10px] text-gray-400 hover:text-gray-600 opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:a?"Copied!":"Copy"}),l.jsx("pre",{className:"overflow-x-auto p-3 text-xs leading-relaxed",children:l.jsx("code",{children:o})})]})}const Sg={$skin:"skinColor",$hair:"hairColor",$shirt:"shirtColor",$pants:"pantsColor",$shoes:"shoeColor"},JS=/^(darken|lighten)\((\$\w+),\s*(\d+)\)$/;function eC(e,n){const a=parseInt(e.replace("#",""),16),i=Math.max(0,(a>>16&255)-n),o=Math.max(0,(a>>8&255)-n),u=Math.max(0,(a&255)-n);return`#${(i<<16|o<<8|u).toString(16).padStart(6,"0")}`}function tC(e,n){const a=parseInt(e.replace("#",""),16),i=Math.min(255,(a>>16&255)+n),o=Math.min(255,(a>>8&255)+n),u=Math.min(255,(a&255)+n);return`#${(i<<16|o<<8|u).toString(16).padStart(6,"0")}`}function Rb(e,n){const a=Sg[e];if(a&&n)return n[a];const i=JS.exec(e);if(i){const[,o,u,d]=i,f=Sg[u],m=f&&n?n[f]:u,h=parseInt(d,10);return o==="darken"?eC(m,h):tC(m,h)}return e}function rm(e,n=12){return e.map(a=>({...a,x:n-a.x-a.w}))}function nC(e,n){return n==="down"?e.down:n==="up"&&e.up?e.up:n==="left"&&e.left?e.left:n==="right"&&e.right?e.right:n==="right"&&e.left?{name:e.left.name,pixels:rm(e.left.pixels)}:n==="left"&&e.right?{name:e.right.name,pixels:rm(e.right.pixels)}:e.down}function rC(e,n){return am(e,"hair",n,1)}function am(e,n,a,i){const o=e.layers.findIndex(d=>d.name===n),u=[...e.layers];if(o>=0)u[o]={...a,name:n};else{const d=i??u.length;u.splice(d,0,{...a,name:n})}return{...e,layers:u}}const qm=new Map,Ym=new Map;function zb(e,n){qm.set(e,n)}function ed(e,n){Ym.set(e,n)}function lm(e){return qm.get(e)}function W8(e){return Ym.get(e)}function V8(){return Array.from(qm.keys())}function G8(){return Array.from(Ym.keys())}function aC(e,n,a,i,o=2){e.clearRect(0,0,n.width*o,n.height*o);for(const u of n.layers)_b(e,u.pixels,o,a,i)}function Xl(e,n,a,i,o){for(const u of n){const d=Rb(u.c,o);u.a!==void 0&&u.a!==1&&(e.globalAlpha=u.a),e.fillStyle=d,e.fillRect(a+u.x,i+u.y,u.w,u.h),u.a!==void 0&&u.a!==1&&(e.globalAlpha=1)}}function K8(e,n){const a=n.scale;e.clearRect(0,0,n.canvasWidth,n.canvasHeight),_b(e,n.pixels,a,0)}function _b(e,n,a,i,o){for(const u of n){const d=Rb(u.c,o);u.a!==void 0&&u.a!==1&&(e.globalAlpha=u.a),e.fillStyle=d,e.fillRect(u.x*a,(u.y+i)*a,u.w*a,u.h*a),u.a!==void 0&&u.a!==1&&(e.globalAlpha=1)}}const Uu=new Map;function Kl(e,n,a){if("down"in a&&!("pixels"in a)){const o=a;Uu.set(e,{id:e,name:n,layer:{...o.down,name:"hair"},directions:{down:{...o.down,name:"hair"},up:o.up?{...o.up,name:"hair"}:void 0,left:o.left?{...o.left,name:"hair"}:void 0,right:o.right?{...o.right,name:"hair"}:void 0}})}else{const o=a;Uu.set(e,{id:e,name:n,layer:{...o,name:"hair"}})}}function lC(e){return Uu.get(e)}function Bb(){return Array.from(Uu.values())}Kl("short","Short",{down:{name:"hair",pixels:[{x:1,y:0,w:10,h:2,c:"$hair"},{x:0,y:1,w:2,h:2,c:"$hair"},{x:10,y:1,w:2,h:2,c:"$hair"},{x:2,y:0,w:8,h:1,c:"lighten($hair, 25)",a:.3}]},up:{name:"hair",pixels:[{x:1,y:0,w:10,h:3,c:"$hair"},{x:0,y:1,w:2,h:2,c:"$hair"},{x:10,y:1,w:2,h:2,c:"$hair"}]},left:{name:"hair",pixels:[{x:1,y:0,w:9,h:2,c:"$hair"},{x:0,y:1,w:2,h:2,c:"$hair"},{x:2,y:0,w:6,h:1,c:"lighten($hair, 25)",a:.3}]}});Kl("messy","Messy",{down:{name:"hair",pixels:[{x:1,y:0,w:10,h:3,c:"$hair"},{x:0,y:1,w:2,h:3,c:"$hair"},{x:10,y:0,w:2,h:4,c:"$hair"},{x:3,y:-1,w:3,h:2,c:"$hair"},{x:7,y:-1,w:2,h:2,c:"lighten($hair, 20)"},{x:2,y:0,w:4,h:1,c:"lighten($hair, 30)",a:.3}]},up:{name:"hair",pixels:[{x:1,y:0,w:10,h:4,c:"$hair"},{x:0,y:1,w:2,h:3,c:"$hair"},{x:10,y:0,w:2,h:4,c:"$hair"},{x:3,y:-1,w:3,h:2,c:"$hair"},{x:7,y:-1,w:2,h:2,c:"$hair"}]},left:{name:"hair",pixels:[{x:1,y:0,w:9,h:3,c:"$hair"},{x:0,y:1,w:2,h:3,c:"$hair"},{x:3,y:-1,w:3,h:2,c:"$hair"},{x:2,y:0,w:4,h:1,c:"lighten($hair, 30)",a:.3}]}});Kl("bun","Bun",{down:{name:"hair",pixels:[{x:1,y:0,w:10,h:2,c:"$hair"},{x:0,y:1,w:2,h:2,c:"$hair"},{x:10,y:1,w:2,h:2,c:"$hair"},{x:4,y:-2,w:4,h:3,c:"$hair"},{x:5,y:-2,w:2,h:1,c:"lighten($hair, 30)",a:.4}]},up:{name:"hair",pixels:[{x:1,y:0,w:10,h:3,c:"$hair"},{x:0,y:1,w:2,h:2,c:"$hair"},{x:10,y:1,w:2,h:2,c:"$hair"},{x:4,y:-2,w:4,h:3,c:"$hair"},{x:5,y:-2,w:2,h:1,c:"lighten($hair, 30)",a:.4}]},left:{name:"hair",pixels:[{x:1,y:0,w:9,h:2,c:"$hair"},{x:0,y:1,w:2,h:2,c:"$hair"},{x:4,y:-2,w:4,h:3,c:"$hair"},{x:5,y:-2,w:2,h:1,c:"lighten($hair, 30)",a:.4}]}});Kl("long","Long",{down:{name:"hair",pixels:[{x:0,y:0,w:12,h:3,c:"$hair"},{x:-1,y:1,w:2,h:7,c:"$hair"},{x:11,y:1,w:2,h:7,c:"$hair"},{x:-1,y:6,w:2,h:3,c:"darken($hair, 15)",a:.5},{x:11,y:6,w:2,h:3,c:"darken($hair, 15)",a:.5},{x:2,y:0,w:8,h:1,c:"lighten($hair, 25)",a:.3}]},up:{name:"hair",pixels:[{x:0,y:0,w:12,h:3,c:"$hair"},{x:-1,y:1,w:2,h:7,c:"$hair"},{x:11,y:1,w:2,h:7,c:"$hair"},{x:1,y:2,w:10,h:6,c:"$hair"},{x:2,y:6,w:8,h:2,c:"darken($hair, 10)",a:.3}]},left:{name:"hair",pixels:[{x:0,y:0,w:10,h:3,c:"$hair"},{x:-1,y:1,w:2,h:7,c:"$hair"},{x:-1,y:6,w:2,h:3,c:"darken($hair, 15)",a:.5},{x:2,y:0,w:6,h:1,c:"lighten($hair, 25)",a:.3}]}});Kl("mohawk","Mohawk",{down:{name:"hair",pixels:[{x:4,y:-2,w:4,h:4,c:"$hair"},{x:5,y:-3,w:2,h:2,c:"lighten($hair, 20)"},{x:1,y:1,w:3,h:2,c:"$hair"},{x:8,y:1,w:3,h:2,c:"$hair"}]},up:{name:"hair",pixels:[{x:4,y:-2,w:4,h:4,c:"$hair"},{x:5,y:-3,w:2,h:2,c:"lighten($hair, 20)"},{x:1,y:1,w:3,h:2,c:"$hair"},{x:8,y:1,w:3,h:2,c:"$hair"}]},left:{name:"hair",pixels:[{x:4,y:-2,w:3,h:4,c:"$hair"},{x:5,y:-3,w:2,h:2,c:"lighten($hair, 20)"},{x:1,y:1,w:3,h:2,c:"$hair"}]}});Kl("slicked","Slicked Back",{down:{name:"hair",pixels:[{x:1,y:0,w:10,h:2,c:"$hair"},{x:0,y:1,w:2,h:2,c:"$hair"},{x:10,y:1,w:2,h:2,c:"$hair"},{x:2,y:0,w:8,h:1,c:"lighten($hair, 15)",a:.4},{x:3,y:1,w:6,h:1,c:"lighten($hair, 10)",a:.2}]},up:{name:"hair",pixels:[{x:1,y:0,w:10,h:3,c:"$hair"},{x:0,y:1,w:2,h:2,c:"$hair"},{x:10,y:1,w:2,h:2,c:"$hair"},{x:2,y:0,w:8,h:1,c:"lighten($hair, 15)",a:.4}]},left:{name:"hair",pixels:[{x:1,y:0,w:9,h:2,c:"$hair"},{x:0,y:1,w:2,h:2,c:"$hair"},{x:2,y:0,w:6,h:1,c:"lighten($hair, 15)",a:.4}]}});Kl("bob","Bob Cut",{down:{name:"hair",pixels:[{x:0,y:0,w:12,h:3,c:"$hair"},{x:-1,y:1,w:2,h:5,c:"$hair"},{x:11,y:1,w:2,h:5,c:"$hair"},{x:-1,y:5,w:2,h:1,c:"darken($hair, 15)",a:.4},{x:11,y:5,w:2,h:1,c:"darken($hair, 15)",a:.4},{x:2,y:0,w:8,h:1,c:"lighten($hair, 25)",a:.3}]},up:{name:"hair",pixels:[{x:0,y:0,w:12,h:3,c:"$hair"},{x:-1,y:1,w:2,h:5,c:"$hair"},{x:11,y:1,w:2,h:5,c:"$hair"},{x:1,y:2,w:10,h:4,c:"$hair"},{x:2,y:5,w:8,h:1,c:"darken($hair, 10)",a:.3}]},left:{name:"hair",pixels:[{x:0,y:0,w:10,h:3,c:"$hair"},{x:-1,y:1,w:2,h:5,c:"$hair"},{x:-1,y:5,w:2,h:1,c:"darken($hair, 15)",a:.4},{x:2,y:0,w:6,h:1,c:"lighten($hair, 25)",a:.3}]}});Kl("curly","Curly",{down:{name:"hair",pixels:[{x:0,y:0,w:12,h:4,c:"$hair"},{x:-1,y:1,w:2,h:5,c:"$hair"},{x:11,y:1,w:2,h:5,c:"$hair"},{x:2,y:0,w:2,h:1,c:"lighten($hair, 25)",a:.4},{x:6,y:0,w:2,h:1,c:"lighten($hair, 25)",a:.4},{x:4,y:2,w:2,h:1,c:"lighten($hair, 15)",a:.3},{x:8,y:2,w:2,h:1,c:"lighten($hair, 15)",a:.3}]},up:{name:"hair",pixels:[{x:0,y:0,w:12,h:4,c:"$hair"},{x:-1,y:1,w:2,h:5,c:"$hair"},{x:11,y:1,w:2,h:5,c:"$hair"},{x:1,y:2,w:10,h:4,c:"$hair"},{x:3,y:1,w:2,h:1,c:"lighten($hair, 15)",a:.3},{x:7,y:1,w:2,h:1,c:"lighten($hair, 15)",a:.3}]},left:{name:"hair",pixels:[{x:0,y:0,w:10,h:4,c:"$hair"},{x:-1,y:1,w:2,h:5,c:"$hair"},{x:2,y:0,w:2,h:1,c:"lighten($hair, 25)",a:.4},{x:5,y:0,w:2,h:1,c:"lighten($hair, 25)",a:.4},{x:3,y:2,w:2,h:1,c:"lighten($hair, 15)",a:.3}]}});const iC={short:1,messy:1,bun:2,long:2,mohawk:3,slicked:3,bob:4,curly:4},sC={short:0,messy:0,bun:10,long:10,mohawk:25,slicked:25,bob:50,curly:50};function Ob(e){return iC[e]??1}function $b(e,n){return n>=Ob(e)}function oC(e){return sC[e]??0}const qu=new Map;function Ta(e,n,a){if("down"in a&&!("pixels"in a)){const o=a;qu.set(e,{id:e,name:n,layer:{...o.down,name:"torso"},directions:{down:{...o.down,name:"torso"},up:o.up?{...o.up,name:"torso"}:void 0,left:o.left?{...o.left,name:"torso"}:void 0,right:o.right?{...o.right,name:"torso"}:void 0}})}else{const o=a;qu.set(e,{id:e,name:n,layer:{...o,name:"torso"}})}}function cC(e){return qu.get(e)}function Lb(){return Array.from(qu.values())}Ta("tshirt","T-Shirt",{down:{name:"torso",pixels:[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:2,y:10,w:8,h:1,c:"lighten($shirt, 18)",a:.3},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:10,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},up:{name:"torso",pixels:[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:10,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:5,y:10,w:2,h:3,c:"darken($shirt, 10)",a:.15},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},left:{name:"torso",pixels:[{x:1,y:10,w:9,h:6,c:"$shirt"},{x:2,y:10,w:7,h:1,c:"lighten($shirt, 18)",a:.3},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:-1,y:11,w:3,h:5,c:"$shirt"},{x:-1,y:15,w:3,h:1,c:"$skin"}]}});Ta("suit","Suit",{down:{name:"torso",pixels:[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:2,y:10,w:8,h:1,c:"lighten($shirt, 12)",a:.3},{x:1,y:10,w:1,h:5,c:"darken($shirt, 30)",a:.3},{x:10,y:10,w:1,h:5,c:"darken($shirt, 30)",a:.3},{x:2,y:10,w:3,h:3,c:"darken($shirt, 20)",a:.3},{x:7,y:10,w:3,h:3,c:"darken($shirt, 20)",a:.3},{x:5,y:10,w:2,h:5,c:"#E8E8E8",a:.5},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:11,w:2,h:1,c:"darken($shirt, 20)",a:.2},{x:11,y:11,w:2,h:1,c:"darken($shirt, 20)",a:.2},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},up:{name:"torso",pixels:[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:1,y:10,w:1,h:5,c:"darken($shirt, 30)",a:.3},{x:10,y:10,w:1,h:5,c:"darken($shirt, 30)",a:.3},{x:5,y:12,w:2,h:4,c:"darken($shirt, 10)",a:.15},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},left:{name:"torso",pixels:[{x:1,y:10,w:9,h:6,c:"$shirt"},{x:1,y:10,w:1,h:5,c:"darken($shirt, 30)",a:.3},{x:2,y:10,w:3,h:3,c:"darken($shirt, 20)",a:.3},{x:-1,y:11,w:3,h:5,c:"$shirt"},{x:-1,y:11,w:3,h:1,c:"darken($shirt, 20)",a:.2},{x:-1,y:15,w:3,h:1,c:"$skin"}]}});Ta("hoodie","Hoodie",{down:{name:"torso",pixels:[{x:0,y:10,w:12,h:6,c:"$shirt"},{x:1,y:10,w:10,h:1,c:"lighten($shirt, 15)",a:.25},{x:0,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.3},{x:11,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.3},{x:2,y:8,w:8,h:2,c:"$shirt",a:.4},{x:3,y:13,w:6,h:2,c:"darken($shirt, 15)",a:.2},{x:5,y:10,w:1,h:2,c:"#DDD",a:.3},{x:6,y:10,w:1,h:2,c:"#DDD",a:.3},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},up:{name:"torso",pixels:[{x:0,y:10,w:12,h:6,c:"$shirt"},{x:0,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.3},{x:11,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.3},{x:2,y:7,w:8,h:3,c:"$shirt",a:.5},{x:3,y:7,w:6,h:1,c:"darken($shirt, 10)",a:.3},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},left:{name:"torso",pixels:[{x:0,y:10,w:10,h:6,c:"$shirt"},{x:1,y:10,w:8,h:1,c:"lighten($shirt, 15)",a:.25},{x:0,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.3},{x:2,y:8,w:6,h:2,c:"$shirt",a:.4},{x:-1,y:11,w:3,h:5,c:"$shirt"},{x:-1,y:15,w:3,h:1,c:"$skin"}]}});Ta("vest","Vest",{down:{name:"torso",pixels:[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:2,y:10,w:8,h:1,c:"lighten($shirt, 18)",a:.3},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:10,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:5,y:10,w:2,h:2,c:"$skin",a:.6},{x:-1,y:11,w:2,h:5,c:"$skin"},{x:11,y:11,w:2,h:5,c:"$skin"},{x:-1,y:15,w:2,h:1,c:"darken($skin, 10)"},{x:11,y:15,w:2,h:1,c:"darken($skin, 10)"}]},up:{name:"torso",pixels:[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:10,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:-1,y:11,w:2,h:5,c:"$skin"},{x:11,y:11,w:2,h:5,c:"$skin"},{x:-1,y:15,w:2,h:1,c:"darken($skin, 10)"},{x:11,y:15,w:2,h:1,c:"darken($skin, 10)"}]},left:{name:"torso",pixels:[{x:1,y:10,w:9,h:6,c:"$shirt"},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:-1,y:11,w:3,h:5,c:"$skin"},{x:-1,y:15,w:3,h:1,c:"darken($skin, 10)"}]}});Ta("tank","Tank Top",{down:{name:"torso",pixels:[{x:2,y:10,w:8,h:6,c:"$shirt"},{x:3,y:10,w:6,h:1,c:"lighten($shirt, 18)",a:.3},{x:2,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:9,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:0,y:10,w:2,h:2,c:"$skin"},{x:10,y:10,w:2,h:2,c:"$skin"},{x:-1,y:11,w:2,h:5,c:"$skin"},{x:11,y:11,w:2,h:5,c:"$skin"},{x:-1,y:15,w:2,h:1,c:"darken($skin, 10)"},{x:11,y:15,w:2,h:1,c:"darken($skin, 10)"}]},up:{name:"torso",pixels:[{x:2,y:10,w:8,h:6,c:"$shirt"},{x:2,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:9,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:0,y:10,w:2,h:2,c:"$skin"},{x:10,y:10,w:2,h:2,c:"$skin"},{x:-1,y:11,w:2,h:5,c:"$skin"},{x:11,y:11,w:2,h:5,c:"$skin"},{x:-1,y:15,w:2,h:1,c:"darken($skin, 10)"},{x:11,y:15,w:2,h:1,c:"darken($skin, 10)"}]},left:{name:"torso",pixels:[{x:2,y:10,w:7,h:6,c:"$shirt"},{x:2,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:0,y:10,w:2,h:2,c:"$skin"},{x:-1,y:11,w:3,h:5,c:"$skin"},{x:-1,y:15,w:3,h:1,c:"darken($skin, 10)"}]}});Ta("polo","Polo",{down:{name:"torso",pixels:[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:2,y:10,w:8,h:1,c:"lighten($shirt, 18)",a:.3},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:10,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:3,y:9,w:6,h:2,c:"lighten($shirt, 25)",a:.5},{x:5,y:9,w:2,h:1,c:"$skin",a:.4},{x:5,y:10,w:2,h:3,c:"darken($shirt, 15)",a:.15},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},up:{name:"torso",pixels:[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:10,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:3,y:9,w:6,h:1,c:"lighten($shirt, 25)",a:.5},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},left:{name:"torso",pixels:[{x:1,y:10,w:9,h:6,c:"$shirt"},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:3,y:9,w:4,h:2,c:"lighten($shirt, 25)",a:.5},{x:-1,y:11,w:3,h:5,c:"$shirt"},{x:-1,y:15,w:3,h:1,c:"$skin"}]}});Ta("labcoat","Lab Coat",{down:{name:"torso",pixels:[{x:4,y:10,w:4,h:5,c:"$shirt"},{x:0,y:10,w:4,h:7,c:"#F0F0F0"},{x:8,y:10,w:4,h:7,c:"#F0F0F0"},{x:1,y:10,w:10,h:1,c:"#FAFAFA"},{x:0,y:10,w:1,h:7,c:"#DDD",a:.5},{x:11,y:10,w:1,h:7,c:"#DDD",a:.5},{x:1,y:13,w:2,h:2,c:"#E0E0E0",a:.4},{x:9,y:13,w:2,h:2,c:"#E0E0E0",a:.4},{x:-1,y:11,w:2,h:5,c:"#F0F0F0"},{x:11,y:11,w:2,h:5,c:"#F0F0F0"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},up:{name:"torso",pixels:[{x:0,y:10,w:12,h:7,c:"#F0F0F0"},{x:0,y:10,w:1,h:7,c:"#DDD",a:.5},{x:11,y:10,w:1,h:7,c:"#DDD",a:.5},{x:5,y:11,w:2,h:5,c:"#E8E8E8",a:.3},{x:-1,y:11,w:2,h:5,c:"#F0F0F0"},{x:11,y:11,w:2,h:5,c:"#F0F0F0"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},left:{name:"torso",pixels:[{x:3,y:10,w:3,h:5,c:"$shirt"},{x:0,y:10,w:3,h:7,c:"#F0F0F0"},{x:6,y:10,w:4,h:7,c:"#F0F0F0"},{x:1,y:10,w:8,h:1,c:"#FAFAFA"},{x:0,y:10,w:1,h:7,c:"#DDD",a:.5},{x:1,y:13,w:2,h:2,c:"#E0E0E0",a:.4},{x:-1,y:11,w:3,h:5,c:"#F0F0F0"},{x:-1,y:15,w:3,h:1,c:"$skin"}]}});Ta("overalls","Overalls",{down:{name:"torso",pixels:[{x:1,y:10,w:10,h:3,c:"$shirt"},{x:2,y:10,w:8,h:1,c:"lighten($shirt, 18)",a:.3},{x:3,y:11,w:6,h:5,c:"#3D6B99"},{x:3,y:10,w:2,h:1,c:"#3D6B99"},{x:7,y:10,w:2,h:1,c:"#3D6B99"},{x:3,y:11,w:1,h:1,c:"#FFD700",a:.6},{x:8,y:11,w:1,h:1,c:"#FFD700",a:.6},{x:1,y:13,w:2,h:3,c:"#3D6B99"},{x:9,y:13,w:2,h:3,c:"#3D6B99"},{x:5,y:13,w:2,h:2,c:"#345E87",a:.4},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},up:{name:"torso",pixels:[{x:1,y:10,w:10,h:3,c:"$shirt"},{x:3,y:10,w:2,h:1,c:"#3D6B99"},{x:7,y:10,w:2,h:1,c:"#3D6B99"},{x:1,y:13,w:10,h:3,c:"#3D6B99"},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},left:{name:"torso",pixels:[{x:1,y:10,w:9,h:3,c:"$shirt"},{x:3,y:11,w:5,h:5,c:"#3D6B99"},{x:3,y:10,w:2,h:1,c:"#3D6B99"},{x:3,y:11,w:1,h:1,c:"#FFD700",a:.6},{x:1,y:13,w:2,h:3,c:"#3D6B99"},{x:-1,y:11,w:3,h:5,c:"$shirt"},{x:-1,y:15,w:3,h:1,c:"$skin"}]}});Ta("turtleneck","Turtleneck",{down:{name:"torso",pixels:[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:10,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:3,y:8,w:6,h:2,c:"$shirt"},{x:4,y:8,w:4,h:1,c:"lighten($shirt, 12)",a:.3},{x:3,y:9,w:1,h:1,c:"darken($shirt, 15)",a:.2},{x:8,y:9,w:1,h:1,c:"darken($shirt, 15)",a:.2},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},up:{name:"torso",pixels:[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:10,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:3,y:8,w:6,h:2,c:"$shirt"},{x:4,y:8,w:4,h:1,c:"lighten($shirt, 12)",a:.3},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},left:{name:"torso",pixels:[{x:1,y:10,w:9,h:6,c:"$shirt"},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:3,y:8,w:4,h:2,c:"$shirt"},{x:3,y:8,w:3,h:1,c:"lighten($shirt, 12)",a:.3},{x:-1,y:11,w:3,h:5,c:"$shirt"},{x:-1,y:15,w:3,h:1,c:"$skin"}]}});Ta("robe","Robe",{down:{name:"torso",pixels:[{x:0,y:10,w:12,h:7,c:"$shirt"},{x:0,y:10,w:1,h:6,c:"darken($shirt, 25)",a:.3},{x:11,y:10,w:1,h:6,c:"darken($shirt, 25)",a:.3},{x:3,y:10,w:3,h:4,c:"lighten($shirt, 15)",a:.25},{x:6,y:10,w:3,h:4,c:"darken($shirt, 10)",a:.2},{x:1,y:14,w:10,h:1,c:"darken($shirt, 35)"},{x:2,y:14,w:8,h:1,c:"darken($shirt, 25)",a:.4},{x:-2,y:11,w:3,h:5,c:"$shirt"},{x:11,y:11,w:3,h:5,c:"$shirt"},{x:-2,y:15,w:3,h:1,c:"darken($shirt, 15)",a:.3},{x:11,y:15,w:3,h:1,c:"darken($shirt, 15)",a:.3},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},up:{name:"torso",pixels:[{x:0,y:10,w:12,h:7,c:"$shirt"},{x:0,y:10,w:1,h:6,c:"darken($shirt, 25)",a:.3},{x:11,y:10,w:1,h:6,c:"darken($shirt, 25)",a:.3},{x:1,y:14,w:10,h:1,c:"darken($shirt, 35)"},{x:-2,y:11,w:3,h:5,c:"$shirt"},{x:11,y:11,w:3,h:5,c:"$shirt"},{x:-2,y:15,w:3,h:1,c:"darken($shirt, 15)",a:.3},{x:11,y:15,w:3,h:1,c:"darken($shirt, 15)",a:.3},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},left:{name:"torso",pixels:[{x:0,y:10,w:10,h:7,c:"$shirt"},{x:0,y:10,w:1,h:6,c:"darken($shirt, 25)",a:.3},{x:1,y:14,w:8,h:1,c:"darken($shirt, 35)"},{x:-2,y:11,w:4,h:5,c:"$shirt"},{x:-2,y:15,w:4,h:1,c:"darken($shirt, 15)",a:.3},{x:-1,y:15,w:2,h:1,c:"$skin"}]}});const uC={tshirt:1,polo:1,hoodie:2,vest:2,suit:3,tank:3,overalls:4,turtleneck:4,labcoat:5,robe:5},dC={tshirt:0,polo:0,hoodie:10,vest:10,suit:25,tank:15,overalls:50,turtleneck:50,labcoat:75,robe:75};function Ib(e){return uC[e]??1}function Hb(e,n){return n>=Ib(e)}function fC(e){return dC[e]??0}const Ho=new Map;function Gt(e,n,a){if("down"in a&&!("pixels"in a)){const o=a;Ho.set(e,{id:e,name:n,layer:{...o.down,name:"accessory"},directions:{down:{...o.down,name:"accessory"},up:o.up?{...o.up,name:"accessory"}:void 0,left:o.left?{...o.left,name:"accessory"}:void 0,right:o.right?{...o.right,name:"accessory"}:void 0}})}else{const o=a;Ho.set(e,{id:e,name:n,layer:{...o,name:"accessory"}})}}function hC(e){return Ho.get(e)}function mC(e,n){const a=Ho.get(e);if(!a)return;if(a.directions)return nC(a.directions,n);if(n==="down")return a.layer;const i=a.layer.pixels.filter(u=>u.y<2);if(i.length===0)return;const o=n==="right"?1:n==="left"?-1:0;return{name:a.layer.name,pixels:o?i.map(u=>({...u,x:u.x+o})):i}}function Ub(){return Array.from(Ho.values())}Gt("none","None",{name:"accessory",pixels:[]});Gt("glasses","Glasses",{down:{name:"accessory",pixels:[{x:2,y:4,w:3,h:2,c:"#2A3A50",a:.5},{x:7,y:4,w:3,h:2,c:"#2A3A50",a:.5},{x:5,y:4,w:2,h:1,c:"#2A3A50",a:.3}]},up:{name:"accessory",pixels:[{x:0,y:3,w:2,h:1,c:"#2A3A50",a:.4},{x:10,y:3,w:2,h:1,c:"#2A3A50",a:.4}]},left:{name:"accessory",pixels:[{x:2,y:4,w:3,h:2,c:"#2A3A50",a:.5},{x:5,y:4,w:6,h:1,c:"#2A3A50",a:.3}]}});Gt("round-glasses","Round Glasses",{down:{name:"accessory",pixels:[{x:2,y:3,w:3,h:3,c:"#8B7355",a:.4},{x:7,y:3,w:3,h:3,c:"#8B7355",a:.4},{x:3,y:4,w:1,h:1,c:"#B0E0FF",a:.15},{x:8,y:4,w:1,h:1,c:"#B0E0FF",a:.15},{x:5,y:4,w:2,h:1,c:"#8B7355",a:.3}]},up:{name:"accessory",pixels:[{x:0,y:3,w:2,h:1,c:"#8B7355",a:.3},{x:10,y:3,w:2,h:1,c:"#8B7355",a:.3}]},left:{name:"accessory",pixels:[{x:2,y:3,w:3,h:3,c:"#8B7355",a:.4},{x:3,y:4,w:1,h:1,c:"#B0E0FF",a:.15},{x:5,y:4,w:6,h:1,c:"#8B7355",a:.25}]}});Gt("sunglasses","Sunglasses",{down:{name:"accessory",pixels:[{x:2,y:4,w:3,h:2,c:"#1A1A2E",a:.7},{x:7,y:4,w:3,h:2,c:"#1A1A2E",a:.7},{x:5,y:4,w:2,h:1,c:"#1A1A2E",a:.4},{x:3,y:4,w:1,h:1,c:"#334",a:.3},{x:8,y:4,w:1,h:1,c:"#334",a:.3}]},up:{name:"accessory",pixels:[{x:0,y:3,w:2,h:1,c:"#1A1A2E",a:.4},{x:10,y:3,w:2,h:1,c:"#1A1A2E",a:.4}]},left:{name:"accessory",pixels:[{x:2,y:4,w:3,h:2,c:"#1A1A2E",a:.7},{x:3,y:4,w:1,h:1,c:"#334",a:.3},{x:5,y:4,w:6,h:1,c:"#1A1A2E",a:.35}]}});Gt("headphones","Headphones",{down:{name:"accessory",pixels:[{x:0,y:0,w:12,h:1,c:"#333",a:.7},{x:-1,y:1,w:2,h:5,c:"#444"},{x:11,y:1,w:2,h:5,c:"#444"},{x:-1,y:2,w:2,h:3,c:"#555",a:.3},{x:11,y:2,w:2,h:3,c:"#555",a:.3}]},up:{name:"accessory",pixels:[{x:0,y:0,w:12,h:1,c:"#333",a:.7},{x:-1,y:1,w:2,h:5,c:"#444"},{x:11,y:1,w:2,h:5,c:"#444"},{x:-1,y:2,w:2,h:3,c:"#555",a:.3},{x:11,y:2,w:2,h:3,c:"#555",a:.3}]},left:{name:"accessory",pixels:[{x:1,y:0,w:10,h:1,c:"#333",a:.7},{x:-1,y:1,w:3,h:5,c:"#444"},{x:-1,y:2,w:3,h:3,c:"#555",a:.3}]}});Gt("beret","Beret",{down:{name:"accessory",pixels:[{x:2,y:-1,w:8,h:2,c:"#E91E63"},{x:1,y:0,w:2,h:1,c:"#E91E63",a:.6},{x:4,y:-1,w:4,h:1,c:"#F06292",a:.3}]},up:{name:"accessory",pixels:[{x:2,y:-1,w:8,h:2,c:"#E91E63"},{x:9,y:0,w:2,h:1,c:"#E91E63",a:.6}]},left:{name:"accessory",pixels:[{x:0,y:-1,w:8,h:2,c:"#E91E63"},{x:2,y:-1,w:4,h:1,c:"#F06292",a:.3}]}});Gt("cap","Cap",{down:{name:"accessory",pixels:[{x:1,y:-1,w:10,h:2,c:"#1565C0"},{x:0,y:1,w:12,h:1,c:"#0D47A1"},{x:3,y:-1,w:6,h:1,c:"#1E88E5",a:.3}]},up:{name:"accessory",pixels:[{x:1,y:-1,w:10,h:2,c:"#1565C0"},{x:3,y:-1,w:6,h:1,c:"#1E88E5",a:.3},{x:5,y:1,w:2,h:1,c:"#0D47A1",a:.5}]},left:{name:"accessory",pixels:[{x:0,y:-1,w:9,h:2,c:"#1565C0"},{x:-2,y:1,w:6,h:1,c:"#0D47A1"},{x:2,y:-1,w:5,h:1,c:"#1E88E5",a:.3}]}});Gt("badge","Badge",{down:{name:"accessory",pixels:[{x:5,y:8,w:2,h:3,c:"#2196F3",a:.4},{x:4,y:11,w:4,h:3,c:"#FFF",a:.5},{x:5,y:12,w:2,h:1,c:"#333",a:.3}]},up:{name:"accessory",pixels:[]},left:{name:"accessory",pixels:[{x:3,y:8,w:1,h:3,c:"#2196F3",a:.4},{x:2,y:11,w:3,h:3,c:"#FFF",a:.5}]}});Gt("lapels","Lapels",{down:{name:"accessory",pixels:[{x:1,y:10,w:3,h:2,c:"#1A1A2E",a:.4},{x:8,y:10,w:3,h:2,c:"#1A1A2E",a:.4}]},up:{name:"accessory",pixels:[]},left:{name:"accessory",pixels:[{x:1,y:10,w:3,h:2,c:"#1A1A2E",a:.4}]}});Gt("blush","Blush",{down:{name:"accessory",pixels:[{x:2,y:6,w:1,h:1,c:"#FFCDD2",a:.3},{x:9,y:6,w:1,h:1,c:"#FFCDD2",a:.3}]},up:{name:"accessory",pixels:[]},left:{name:"accessory",pixels:[{x:2,y:6,w:1,h:1,c:"#FFCDD2",a:.3}]}});Gt("scarf","Scarf",{down:{name:"accessory",pixels:[{x:2,y:9,w:8,h:2,c:"#E53935",a:.6},{x:3,y:9,w:6,h:1,c:"#EF5350",a:.3},{x:3,y:11,w:2,h:3,c:"#E53935",a:.5}]},up:{name:"accessory",pixels:[{x:2,y:9,w:8,h:2,c:"#E53935",a:.6},{x:3,y:9,w:6,h:1,c:"#EF5350",a:.3}]},left:{name:"accessory",pixels:[{x:1,y:9,w:8,h:2,c:"#E53935",a:.6},{x:2,y:9,w:5,h:1,c:"#EF5350",a:.3},{x:1,y:11,w:2,h:3,c:"#E53935",a:.5}]}});Gt("tie","Tie",{down:{name:"accessory",pixels:[{x:5,y:9,w:2,h:1,c:"#B71C1C"},{x:5,y:10,w:2,h:4,c:"#D32F2F"},{x:5,y:10,w:1,h:4,c:"#E53935",a:.3},{x:5,y:14,w:2,h:1,c:"#B71C1C",a:.8}]},up:{name:"accessory",pixels:[]},left:{name:"accessory",pixels:[{x:4,y:9,w:2,h:1,c:"#B71C1C"},{x:4,y:10,w:2,h:4,c:"#D32F2F"},{x:4,y:14,w:2,h:1,c:"#B71C1C",a:.8}]}});Gt("bowtie","Bowtie",{down:{name:"accessory",pixels:[{x:3,y:9,w:2,h:1,c:"#D32F2F"},{x:7,y:9,w:2,h:1,c:"#D32F2F"},{x:5,y:9,w:2,h:1,c:"#B71C1C"},{x:4,y:9,w:1,h:1,c:"#E53935",a:.3},{x:7,y:9,w:1,h:1,c:"#E53935",a:.3}]},up:{name:"accessory",pixels:[]},left:{name:"accessory",pixels:[{x:3,y:9,w:3,h:1,c:"#D32F2F"},{x:4,y:9,w:1,h:1,c:"#B71C1C"}]}});Gt("cat-ears","Cat Ears",{down:{name:"accessory",pixels:[{x:1,y:-3,w:2,h:1,c:"#555"},{x:0,y:-2,w:3,h:1,c:"#555"},{x:0,y:-1,w:3,h:1,c:"#555"},{x:1,y:-2,w:1,h:1,c:"#FFB0C0",a:.6},{x:9,y:-3,w:2,h:1,c:"#555"},{x:9,y:-2,w:3,h:1,c:"#555"},{x:9,y:-1,w:3,h:1,c:"#555"},{x:10,y:-2,w:1,h:1,c:"#FFB0C0",a:.6}]},up:{name:"accessory",pixels:[{x:1,y:-3,w:2,h:1,c:"#555"},{x:0,y:-2,w:3,h:1,c:"#555"},{x:0,y:-1,w:3,h:1,c:"#555"},{x:9,y:-3,w:2,h:1,c:"#555"},{x:9,y:-2,w:3,h:1,c:"#555"},{x:9,y:-1,w:3,h:1,c:"#555"}]},left:{name:"accessory",pixels:[{x:2,y:-3,w:2,h:1,c:"#555"},{x:1,y:-2,w:3,h:1,c:"#555"},{x:1,y:-1,w:3,h:1,c:"#555"},{x:2,y:-2,w:1,h:1,c:"#FFB0C0",a:.6}]}});Gt("bear-ears","Bear Ears",{down:{name:"accessory",pixels:[{x:0,y:-2,w:3,h:2,c:"#8B6914"},{x:1,y:-1,w:1,h:1,c:"#C4A24A",a:.5},{x:9,y:-2,w:3,h:2,c:"#8B6914"},{x:10,y:-1,w:1,h:1,c:"#C4A24A",a:.5}]},up:{name:"accessory",pixels:[{x:0,y:-2,w:3,h:2,c:"#8B6914"},{x:9,y:-2,w:3,h:2,c:"#8B6914"}]},left:{name:"accessory",pixels:[{x:1,y:-2,w:3,h:2,c:"#8B6914"},{x:2,y:-1,w:1,h:1,c:"#C4A24A",a:.5}]}});Gt("bunny-ears","Bunny Ears",{down:{name:"accessory",pixels:[{x:2,y:-5,w:2,h:4,c:"#F5F5F5"},{x:2,y:-4,w:1,h:2,c:"#FFB0C0",a:.5},{x:8,y:-5,w:2,h:4,c:"#F5F5F5"},{x:9,y:-4,w:1,h:2,c:"#FFB0C0",a:.5},{x:9,y:-6,w:2,h:1,c:"#F5F5F5"}]},up:{name:"accessory",pixels:[{x:2,y:-5,w:2,h:4,c:"#F5F5F5"},{x:8,y:-5,w:2,h:4,c:"#F5F5F5"},{x:9,y:-6,w:2,h:1,c:"#F5F5F5"}]},left:{name:"accessory",pixels:[{x:3,y:-5,w:2,h:4,c:"#F5F5F5"},{x:3,y:-4,w:1,h:2,c:"#FFB0C0",a:.5},{x:4,y:-6,w:2,h:1,c:"#F5F5F5"}]}});Gt("dog-nose","Dog Nose",{down:{name:"accessory",pixels:[{x:4,y:5,w:4,h:3,c:"#D2B48C",a:.5},{x:5,y:5,w:2,h:1,c:"#222"},{x:6,y:7,w:1,h:1,c:"#FF6B8A",a:.7}]},up:{name:"accessory",pixels:[]},left:{name:"accessory",pixels:[{x:0,y:5,w:4,h:2,c:"#D2B48C",a:.5},{x:0,y:5,w:2,h:1,c:"#222"},{x:1,y:7,w:1,h:1,c:"#FF6B8A",a:.7}]}});Gt("fox-mask","Fox Mask",{down:{name:"accessory",pixels:[{x:0,y:-3,w:2,h:1,c:"#E65100"},{x:-1,y:-2,w:3,h:1,c:"#E65100"},{x:0,y:-1,w:3,h:1,c:"#E65100"},{x:10,y:-3,w:2,h:1,c:"#E65100"},{x:10,y:-2,w:3,h:1,c:"#E65100"},{x:9,y:-1,w:3,h:1,c:"#E65100"},{x:0,y:-2,w:1,h:1,c:"#FFF",a:.4},{x:11,y:-2,w:1,h:1,c:"#FFF",a:.4},{x:1,y:5,w:2,h:2,c:"#FFF",a:.25},{x:9,y:5,w:2,h:2,c:"#FFF",a:.25},{x:5,y:6,w:2,h:1,c:"#222",a:.6}]},up:{name:"accessory",pixels:[{x:0,y:-3,w:2,h:1,c:"#E65100"},{x:-1,y:-2,w:3,h:1,c:"#E65100"},{x:0,y:-1,w:3,h:1,c:"#E65100"},{x:10,y:-3,w:2,h:1,c:"#E65100"},{x:10,y:-2,w:3,h:1,c:"#E65100"},{x:9,y:-1,w:3,h:1,c:"#E65100"}]},left:{name:"accessory",pixels:[{x:1,y:-3,w:2,h:1,c:"#E65100"},{x:0,y:-2,w:3,h:1,c:"#E65100"},{x:1,y:-1,w:3,h:1,c:"#E65100"},{x:1,y:-2,w:1,h:1,c:"#FFF",a:.4},{x:1,y:5,w:2,h:2,c:"#FFF",a:.25},{x:1,y:6,w:2,h:1,c:"#222",a:.6}]}});Gt("crown","Crown",{down:{name:"accessory",pixels:[{x:2,y:-1,w:8,h:2,c:"#FFD700"},{x:3,y:-3,w:2,h:2,c:"#FFD700"},{x:5,y:-2,w:2,h:1,c:"#FFD700"},{x:7,y:-3,w:2,h:2,c:"#FFD700"},{x:4,y:-2,w:1,h:1,c:"#E53935",a:.8},{x:6,y:-1,w:1,h:1,c:"#42A5F5",a:.8},{x:8,y:-2,w:1,h:1,c:"#66BB6A",a:.8},{x:3,y:-1,w:6,h:1,c:"#FFF",a:.15}]},up:{name:"accessory",pixels:[{x:2,y:-1,w:8,h:2,c:"#FFD700"},{x:3,y:-3,w:2,h:2,c:"#FFD700"},{x:5,y:-2,w:2,h:1,c:"#FFD700"},{x:7,y:-3,w:2,h:2,c:"#FFD700"},{x:3,y:-1,w:6,h:1,c:"#FFF",a:.15}]},left:{name:"accessory",pixels:[{x:1,y:-1,w:7,h:2,c:"#FFD700"},{x:2,y:-3,w:2,h:2,c:"#FFD700"},{x:5,y:-2,w:2,h:1,c:"#FFD700"},{x:3,y:-2,w:1,h:1,c:"#E53935",a:.8},{x:5,y:-1,w:1,h:1,c:"#42A5F5",a:.8},{x:2,y:-1,w:5,h:1,c:"#FFF",a:.15}]}});Gt("halo","Halo",{down:{name:"accessory",pixels:[{x:2,y:-3,w:8,h:1,c:"#FFE082",a:.7},{x:1,y:-2,w:1,h:1,c:"#FFE082",a:.5},{x:10,y:-2,w:1,h:1,c:"#FFE082",a:.5},{x:3,y:-4,w:6,h:1,c:"#FFF9C4",a:.4},{x:3,y:-3,w:6,h:1,c:"#FFF",a:.15}]},up:{name:"accessory",pixels:[{x:2,y:-3,w:8,h:1,c:"#FFE082",a:.7},{x:1,y:-2,w:1,h:1,c:"#FFE082",a:.5},{x:10,y:-2,w:1,h:1,c:"#FFE082",a:.5},{x:3,y:-4,w:6,h:1,c:"#FFF9C4",a:.4},{x:3,y:-3,w:6,h:1,c:"#FFF",a:.15}]},left:{name:"accessory",pixels:[{x:1,y:-3,w:7,h:1,c:"#FFE082",a:.7},{x:0,y:-2,w:1,h:1,c:"#FFE082",a:.5},{x:8,y:-2,w:1,h:1,c:"#FFE082",a:.5},{x:2,y:-4,w:5,h:1,c:"#FFF9C4",a:.4},{x:2,y:-3,w:5,h:1,c:"#FFF",a:.15}]}});Gt("horns","Horns",{down:{name:"accessory",pixels:[{x:1,y:-1,w:2,h:2,c:"#8B0000"},{x:0,y:-3,w:2,h:2,c:"#A00"},{x:0,y:-4,w:1,h:1,c:"#C62828"},{x:9,y:-1,w:2,h:2,c:"#8B0000"},{x:10,y:-3,w:2,h:2,c:"#A00"},{x:11,y:-4,w:1,h:1,c:"#C62828"}]},up:{name:"accessory",pixels:[{x:1,y:-1,w:2,h:2,c:"#8B0000"},{x:0,y:-3,w:2,h:2,c:"#A00"},{x:0,y:-4,w:1,h:1,c:"#C62828"},{x:9,y:-1,w:2,h:2,c:"#8B0000"},{x:10,y:-3,w:2,h:2,c:"#A00"},{x:11,y:-4,w:1,h:1,c:"#C62828"}]},left:{name:"accessory",pixels:[{x:2,y:-1,w:2,h:2,c:"#8B0000"},{x:1,y:-3,w:2,h:2,c:"#A00"},{x:1,y:-4,w:1,h:1,c:"#C62828"}]}});Gt("mask","Mask",{down:{name:"accessory",pixels:[{x:1,y:3,w:10,h:3,c:"#1A1A2E",a:.75},{x:3,y:4,w:2,h:1,c:"#000",a:0},{x:7,y:4,w:2,h:1,c:"#000",a:0},{x:1,y:3,w:10,h:1,c:"#FFD700",a:.3},{x:1,y:5,w:10,h:1,c:"#FFD700",a:.2}]},up:{name:"accessory",pixels:[{x:0,y:4,w:12,h:1,c:"#1A1A2E",a:.3}]},left:{name:"accessory",pixels:[{x:1,y:3,w:6,h:3,c:"#1A1A2E",a:.75},{x:2,y:4,w:2,h:1,c:"#000",a:0},{x:1,y:3,w:6,h:1,c:"#FFD700",a:.3},{x:1,y:5,w:6,h:1,c:"#FFD700",a:.2}]}});Gt("bandana","Bandana",{down:{name:"accessory",pixels:[{x:0,y:1,w:12,h:2,c:"#E53935"},{x:1,y:1,w:10,h:1,c:"#EF5350",a:.3}]},up:{name:"accessory",pixels:[{x:0,y:1,w:12,h:2,c:"#E53935"},{x:1,y:1,w:10,h:1,c:"#EF5350",a:.3},{x:11,y:2,w:2,h:2,c:"#E53935",a:.7},{x:12,y:3,w:1,h:1,c:"#C62828",a:.5}]},left:{name:"accessory",pixels:[{x:0,y:1,w:10,h:2,c:"#E53935"},{x:1,y:1,w:8,h:1,c:"#EF5350",a:.3}]}});Gt("eyepatch","Eye Patch",{down:{name:"accessory",pixels:[{x:0,y:3,w:12,h:1,c:"#222",a:.5},{x:2,y:3,w:3,h:3,c:"#1A1A1A"},{x:3,y:4,w:1,h:1,c:"#333",a:.3}]},up:{name:"accessory",pixels:[{x:0,y:3,w:12,h:1,c:"#222",a:.5}]},left:{name:"accessory",pixels:[{x:0,y:3,w:10,h:1,c:"#222",a:.5},{x:1,y:3,w:3,h:3,c:"#1A1A1A"},{x:2,y:4,w:1,h:1,c:"#333",a:.3}]}});Gt("cat-face","Cat Face",{down:{name:"accessory",pixels:[{x:1,y:1,w:10,h:8,c:"#555"},{x:2,y:0,w:8,h:1,c:"#555"},{x:0,y:-2,w:3,h:2,c:"#555"},{x:1,y:-3,w:2,h:1,c:"#555"},{x:9,y:-2,w:3,h:2,c:"#555"},{x:9,y:-3,w:2,h:1,c:"#555"},{x:1,y:-1,w:1,h:1,c:"#FFB0C0",a:.7},{x:10,y:-1,w:1,h:1,c:"#FFB0C0",a:.7},{x:2,y:3,w:3,h:3,c:"#222"},{x:7,y:3,w:3,h:3,c:"#222"},{x:3,y:3,w:1,h:2,c:"#4FC3F7",a:.8},{x:8,y:3,w:1,h:2,c:"#4FC3F7",a:.8},{x:3,y:4,w:1,h:1,c:"#111"},{x:8,y:4,w:1,h:1,c:"#111"},{x:5,y:5,w:2,h:1,c:"#FFB0C0"},{x:4,y:6,w:1,h:1,c:"#444",a:.6},{x:7,y:6,w:1,h:1,c:"#444",a:.6},{x:0,y:5,w:2,h:1,c:"#888",a:.4},{x:10,y:5,w:2,h:1,c:"#888",a:.4},{x:0,y:6,w:2,h:1,c:"#888",a:.3},{x:10,y:6,w:2,h:1,c:"#888",a:.3}]},up:{name:"accessory",pixels:[{x:1,y:1,w:10,h:8,c:"#555"},{x:2,y:0,w:8,h:1,c:"#555"},{x:0,y:-2,w:3,h:2,c:"#555"},{x:1,y:-3,w:2,h:1,c:"#555"},{x:9,y:-2,w:3,h:2,c:"#555"},{x:9,y:-3,w:2,h:1,c:"#555"},{x:5,y:1,w:2,h:5,c:"#4A4A4A",a:.3},{x:9,y:8,w:2,h:2,c:"#555"},{x:10,y:7,w:1,h:1,c:"#555"}]},left:{name:"accessory",pixels:[{x:1,y:1,w:9,h:8,c:"#555"},{x:2,y:0,w:7,h:1,c:"#555"},{x:2,y:-2,w:3,h:2,c:"#555"},{x:3,y:-3,w:2,h:1,c:"#555"},{x:3,y:-1,w:1,h:1,c:"#FFB0C0",a:.7},{x:2,y:3,w:3,h:3,c:"#222"},{x:3,y:3,w:1,h:2,c:"#4FC3F7",a:.8},{x:3,y:4,w:1,h:1,c:"#111"},{x:0,y:5,w:3,h:2,c:"#555"},{x:0,y:5,w:2,h:1,c:"#FFB0C0"},{x:-1,y:5,w:2,h:1,c:"#888",a:.4},{x:-1,y:6,w:2,h:1,c:"#888",a:.3}]}});Gt("bear-face","Bear Face",{down:{name:"accessory",pixels:[{x:1,y:0,w:10,h:9,c:"#8B6914"},{x:2,y:-1,w:8,h:1,c:"#8B6914"},{x:0,y:-1,w:3,h:3,c:"#8B6914"},{x:9,y:-1,w:3,h:3,c:"#8B6914"},{x:1,y:0,w:1,h:1,c:"#C4A24A",a:.6},{x:10,y:0,w:1,h:1,c:"#C4A24A",a:.6},{x:3,y:5,w:6,h:4,c:"#C4A24A",a:.7},{x:3,y:3,w:2,h:2,c:"#111"},{x:7,y:3,w:2,h:2,c:"#111"},{x:3,y:3,w:1,h:1,c:"#FFF",a:.3},{x:7,y:3,w:1,h:1,c:"#FFF",a:.3},{x:5,y:5,w:2,h:1,c:"#222"},{x:5,y:7,w:2,h:1,c:"#6B4F10",a:.5}]},up:{name:"accessory",pixels:[{x:1,y:0,w:10,h:9,c:"#8B6914"},{x:2,y:-1,w:8,h:1,c:"#8B6914"},{x:0,y:-1,w:3,h:3,c:"#8B6914"},{x:9,y:-1,w:3,h:3,c:"#8B6914"},{x:1,y:0,w:1,h:1,c:"#C4A24A",a:.6},{x:10,y:0,w:1,h:1,c:"#C4A24A",a:.6},{x:5,y:1,w:2,h:5,c:"#7A5B10",a:.3}]},left:{name:"accessory",pixels:[{x:1,y:0,w:9,h:9,c:"#8B6914"},{x:2,y:-1,w:7,h:1,c:"#8B6914"},{x:0,y:-1,w:3,h:3,c:"#8B6914"},{x:0,y:0,w:1,h:1,c:"#C4A24A",a:.6},{x:0,y:4,w:3,h:4,c:"#C4A24A",a:.7},{x:3,y:3,w:2,h:2,c:"#111"},{x:3,y:3,w:1,h:1,c:"#FFF",a:.3},{x:1,y:5,w:2,h:1,c:"#222"}]}});Gt("panda-face","Panda Face",{down:{name:"accessory",pixels:[{x:1,y:0,w:10,h:9,c:"#F5F5F5"},{x:2,y:-1,w:8,h:1,c:"#F5F5F5"},{x:0,y:-2,w:3,h:3,c:"#222"},{x:9,y:-2,w:3,h:3,c:"#222"},{x:2,y:2,w:3,h:4,c:"#222"},{x:7,y:2,w:3,h:4,c:"#222"},{x:3,y:3,w:1,h:2,c:"#FFF"},{x:8,y:3,w:1,h:2,c:"#FFF"},{x:3,y:4,w:1,h:1,c:"#111"},{x:8,y:4,w:1,h:1,c:"#111"},{x:5,y:6,w:2,h:1,c:"#222"},{x:5,y:7,w:1,h:1,c:"#CCC",a:.4},{x:6,y:7,w:1,h:1,c:"#CCC",a:.4}]},up:{name:"accessory",pixels:[{x:1,y:0,w:10,h:9,c:"#F5F5F5"},{x:2,y:-1,w:8,h:1,c:"#F5F5F5"},{x:0,y:-2,w:3,h:3,c:"#222"},{x:9,y:-2,w:3,h:3,c:"#222"},{x:5,y:1,w:2,h:5,c:"#EEE",a:.3}]},left:{name:"accessory",pixels:[{x:1,y:0,w:9,h:9,c:"#F5F5F5"},{x:2,y:-1,w:7,h:1,c:"#F5F5F5"},{x:0,y:-2,w:3,h:3,c:"#222"},{x:2,y:2,w:3,h:4,c:"#222"},{x:3,y:3,w:1,h:2,c:"#FFF"},{x:3,y:4,w:1,h:1,c:"#111"},{x:0,y:5,w:3,h:2,c:"#F5F5F5"},{x:1,y:6,w:1,h:1,c:"#222"}]}});Gt("frog-face","Frog Face",{down:{name:"accessory",pixels:[{x:1,y:1,w:10,h:8,c:"#4CAF50"},{x:2,y:0,w:8,h:1,c:"#4CAF50"},{x:1,y:-2,w:4,h:3,c:"#4CAF50"},{x:7,y:-2,w:4,h:3,c:"#4CAF50"},{x:2,y:-1,w:2,h:2,c:"#FFF"},{x:8,y:-1,w:2,h:2,c:"#FFF"},{x:3,y:0,w:1,h:1,c:"#111"},{x:9,y:0,w:1,h:1,c:"#111"},{x:3,y:5,w:6,h:3,c:"#81C784",a:.5},{x:2,y:7,w:8,h:1,c:"#388E3C",a:.6},{x:4,y:4,w:1,h:1,c:"#388E3C",a:.5},{x:7,y:4,w:1,h:1,c:"#388E3C",a:.5},{x:1,y:5,w:2,h:1,c:"#FF8A80",a:.25},{x:9,y:5,w:2,h:1,c:"#FF8A80",a:.25}]},up:{name:"accessory",pixels:[{x:1,y:1,w:10,h:8,c:"#4CAF50"},{x:2,y:0,w:8,h:1,c:"#4CAF50"},{x:1,y:-2,w:4,h:2,c:"#4CAF50"},{x:7,y:-2,w:4,h:2,c:"#4CAF50"},{x:5,y:2,w:2,h:4,c:"#388E3C",a:.2}]},left:{name:"accessory",pixels:[{x:1,y:1,w:9,h:8,c:"#4CAF50"},{x:2,y:0,w:7,h:1,c:"#4CAF50"},{x:0,y:-2,w:4,h:3,c:"#4CAF50"},{x:1,y:-1,w:2,h:2,c:"#FFF"},{x:2,y:0,w:1,h:1,c:"#111"},{x:0,y:5,w:3,h:3,c:"#81C784",a:.5},{x:0,y:7,w:8,h:1,c:"#388E3C",a:.6},{x:1,y:5,w:1,h:1,c:"#FF8A80",a:.25}]}});Gt("rabbit-face","Rabbit Face",{down:{name:"accessory",pixels:[{x:1,y:1,w:10,h:8,c:"#F5F5F5"},{x:2,y:0,w:8,h:1,c:"#F5F5F5"},{x:2,y:-6,w:3,h:6,c:"#F5F5F5"},{x:7,y:-6,w:3,h:6,c:"#F5F5F5"},{x:3,y:-5,w:1,h:4,c:"#FFB0C0",a:.6},{x:8,y:-5,w:1,h:4,c:"#FFB0C0",a:.6},{x:2,y:3,w:3,h:3,c:"#E57373",a:.7},{x:7,y:3,w:3,h:3,c:"#E57373",a:.7},{x:3,y:3,w:1,h:1,c:"#FFF",a:.4},{x:8,y:3,w:1,h:1,c:"#FFF",a:.4},{x:5,y:5,w:2,h:1,c:"#FFB0C0"},{x:5,y:6,w:1,h:1,c:"#DDD",a:.4},{x:6,y:6,w:1,h:1,c:"#DDD",a:.4},{x:0,y:4,w:2,h:3,c:"#F5F5F5",a:.6},{x:10,y:4,w:2,h:3,c:"#F5F5F5",a:.6}]},up:{name:"accessory",pixels:[{x:1,y:1,w:10,h:8,c:"#F5F5F5"},{x:2,y:0,w:8,h:1,c:"#F5F5F5"},{x:2,y:-6,w:3,h:6,c:"#F5F5F5"},{x:7,y:-6,w:3,h:6,c:"#F5F5F5"},{x:3,y:-5,w:1,h:4,c:"#FFB0C0",a:.6},{x:8,y:-5,w:1,h:4,c:"#FFB0C0",a:.6},{x:5,y:8,w:3,h:2,c:"#FFF"}]},left:{name:"accessory",pixels:[{x:1,y:1,w:9,h:8,c:"#F5F5F5"},{x:2,y:0,w:7,h:1,c:"#F5F5F5"},{x:3,y:-6,w:3,h:6,c:"#F5F5F5"},{x:4,y:-5,w:1,h:4,c:"#FFB0C0",a:.6},{x:2,y:3,w:3,h:3,c:"#E57373",a:.7},{x:3,y:3,w:1,h:1,c:"#FFF",a:.4},{x:0,y:4,w:3,h:3,c:"#F5F5F5"},{x:1,y:5,w:1,h:1,c:"#FFB0C0"},{x:0,y:4,w:2,h:3,c:"#F5F5F5",a:.6}]}});Gt("dog-face","Dog Face",{down:{name:"accessory",pixels:[{x:1,y:0,w:10,h:9,c:"#D2A25C"},{x:2,y:-1,w:8,h:1,c:"#D2A25C"},{x:-1,y:1,w:3,h:6,c:"#A67B3D"},{x:10,y:1,w:3,h:6,c:"#A67B3D"},{x:3,y:5,w:6,h:4,c:"#F5E6D0",a:.8},{x:3,y:2,w:2,h:3,c:"#3E2723"},{x:7,y:2,w:2,h:3,c:"#3E2723"},{x:3,y:2,w:1,h:1,c:"#FFF",a:.4},{x:7,y:2,w:1,h:1,c:"#FFF",a:.4},{x:5,y:5,w:2,h:2,c:"#222"},{x:5,y:7,w:2,h:2,c:"#FF6B8A",a:.8},{x:5,y:7,w:1,h:1,c:"#FF8A9E",a:.4}]},up:{name:"accessory",pixels:[{x:1,y:0,w:10,h:9,c:"#D2A25C"},{x:2,y:-1,w:8,h:1,c:"#D2A25C"},{x:-1,y:1,w:3,h:6,c:"#A67B3D"},{x:10,y:1,w:3,h:6,c:"#A67B3D"},{x:5,y:0,w:2,h:6,c:"#B8883C",a:.3},{x:2,y:8,w:8,h:1,c:"#A67B3D",a:.5}]},left:{name:"accessory",pixels:[{x:1,y:0,w:9,h:9,c:"#D2A25C"},{x:2,y:-1,w:7,h:1,c:"#D2A25C"},{x:-1,y:1,w:3,h:6,c:"#A67B3D"},{x:-1,y:4,w:3,h:4,c:"#D2A25C"},{x:-1,y:5,w:2,h:3,c:"#F5E6D0",a:.8},{x:3,y:2,w:2,h:3,c:"#3E2723"},{x:3,y:2,w:1,h:1,c:"#FFF",a:.4},{x:0,y:5,w:2,h:1,c:"#222"},{x:0,y:7,w:2,h:1,c:"#FF6B8A",a:.7}]}});const pC={none:1,glasses:1,beret:1,cap:1,badge:1,blush:1,lapels:1,"round-glasses":2,headphones:2,scarf:3,tie:3,bowtie:3,sunglasses:4,bandana:4,eyepatch:4,crown:5,halo:5,horns:5,mask:5,"cat-ears":6,"bear-ears":6,"bunny-ears":6,"dog-nose":6,"fox-mask":6,"cat-face":7,"bear-face":7,"panda-face":7,"frog-face":8,"rabbit-face":8,"dog-face":8,"star-glasses":9};function qb(e){return pC[e]??1}function Yb(e,n){return n>=qb(e)}const xC={none:0,glasses:0,beret:0,cap:0,badge:0,blush:0,lapels:0,"round-glasses":10,headphones:15,scarf:25,tie:25,bowtie:25,sunglasses:50,bandana:50,eyepatch:50,crown:100,halo:100,horns:75,mask:75,"cat-ears":100,"bear-ears":100,"bunny-ears":100,"dog-nose":75,"fox-mask":100,"cat-face":150,"bear-face":150,"panda-face":150,"frog-face":200,"rabbit-face":200,"dog-face":200,"star-glasses":300};function gC(e){return xC[e]??0}Gt("star-glasses","Star Glasses",{down:{name:"accessory",pixels:[{x:1,y:3,w:4,h:3,c:"#FF4081",a:.6},{x:2,y:2,w:2,h:1,c:"#FF4081",a:.6},{x:2,y:6,w:2,h:1,c:"#FF4081",a:.6},{x:7,y:3,w:4,h:3,c:"#FF4081",a:.6},{x:8,y:2,w:2,h:1,c:"#FF4081",a:.6},{x:8,y:6,w:2,h:1,c:"#FF4081",a:.6},{x:5,y:4,w:2,h:1,c:"#FF4081",a:.4}]},up:{name:"accessory",pixels:[{x:0,y:3,w:2,h:1,c:"#FF4081",a:.3},{x:10,y:3,w:2,h:1,c:"#FF4081",a:.3}]},left:{name:"accessory",pixels:[{x:1,y:3,w:4,h:3,c:"#FF4081",a:.6},{x:2,y:2,w:2,h:1,c:"#FF4081",a:.6},{x:2,y:6,w:2,h:1,c:"#FF4081",a:.6},{x:5,y:4,w:6,h:1,c:"#FF4081",a:.3}]}});function Eo({r:e,g:n,b:a}){return`#${(e<<16|n<<8|a).toString(16).padStart(6,"0")}`}function zu(e,n){const a=e.r-n.r,i=e.g-n.g,o=e.b-n.b;return a*a+i*i+o*o}function yC(e,n){const a=[];a.push(e[Math.floor(Math.random()*e.length)]);for(let i=1;i<n;i++){const o=e.map(f=>{let m=1/0;for(const h of a)m=Math.min(m,zu(f,h));return m}),u=o.reduce((f,m)=>f+m,0);let d=Math.random()*u;for(let f=0;f<e.length;f++)if(d-=o[f],d<=0){a.push(e[f]);break}a.length<=i&&a.push(e[Math.floor(Math.random()*e.length)])}return a}function bC(e,n,a=20){if(e.length===0)return[];const i=yC(e,n);for(let u=0;u<a;u++){const d=Array.from({length:n},()=>[]);for(const m of e){let h=1/0,x=0;for(let g=0;g<n;g++){const v=zu(m,i[g]);v<h&&(h=v,x=g)}d[x].push(m)}let f=!0;for(let m=0;m<n;m++){if(d[m].length===0)continue;const h={r:0,g:0,b:0};for(const v of d[m])h.r+=v.r,h.g+=v.g,h.b+=v.b;const x=d[m].length,g={r:Math.round(h.r/x),g:Math.round(h.g/x),b:Math.round(h.b/x)};zu(g,i[m])>1&&(f=!1),i[m]=g}if(f)break}const o=new Array(n).fill(0);for(const u of e){let d=1/0,f=0;for(let m=0;m<n;m++){const h=zu(u,i[m]);h<d&&(d=h,f=m)}o[f]++}return i.map((u,d)=>({c:u,count:o[d]})).sort((u,d)=>d.count-u.count).map(u=>u.c)}function vC(e,n=1e4){const a=document.createElement("canvas"),i=e instanceof HTMLImageElement?e.naturalWidth:e.width,o=e instanceof HTMLImageElement?e.naturalHeight:e.height;a.width=i,a.height=o;const u=a.getContext("2d");u.drawImage(e,0,0);const d=u.getImageData(0,0,i,o).data,f=i*o,m=Math.max(1,Math.floor(f/n)),h=[];for(let x=0;x<f;x+=m){const g=x*4;d[g+3]<128||h.push({r:d[g],g:d[g+1],b:d[g+2]})}return h}function Cg(e){return .299*e.r+.587*e.g+.114*e.b}function Eg(e){const n=Math.max(e.r,e.g,e.b),a=Math.min(e.r,e.g,e.b);return n===0?0:(n-a)/n*255}function wC(e,n=8){const a=vC(e),i=bC(a,n);if(i.length<5)return{skinColor:"#F5CBA7",hairColor:"#2C1810",shirtColor:"#1565C0",pantsColor:"#37474F",shoeColor:"#212121"};const o=[...i].sort((g,v)=>Cg(v)-Cg(g)),u=[...i].sort((g,v)=>Eg(v)-Eg(g)),d=o[0],f=o[o.length-1],m=u[0],h=o[o.length-2],x=o[o.length-1];return{skinColor:Eo(d),hairColor:Eo(f),shirtColor:Eo(m),pantsColor:Eo(h),shoeColor:Eo(x)}}const kC=[{x:1,y:19,w:10,h:2,c:"#100A06",a:.15},{x:2,y:15,w:3,h:4,c:"$pants"},{x:7,y:15,w:3,h:4,c:"$pants"},{x:2,y:19,w:3,h:2,c:"$shoes"},{x:7,y:19,w:3,h:2,c:"$shoes"},{x:2,y:19,w:3,h:1,c:"lighten($shoes, 20)",a:.4},{x:7,y:19,w:3,h:1,c:"lighten($shoes, 20)",a:.4}],jC=[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:2,y:10,w:8,h:1,c:"lighten($shirt, 18)",a:.3},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:10,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:4,y:10,w:4,h:2,c:"darken($shirt, 25)",a:.2},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}],SC=[{x:4,y:8,w:4,h:3,c:"$skin"},{x:1,y:1,w:10,h:8,c:"$skin"},{x:3,y:4,w:2,h:2,c:"#1A1A2E"},{x:7,y:4,w:2,h:2,c:"#1A1A2E"},{x:3,y:4,w:1,h:1,c:"#FFF",a:.35},{x:7,y:4,w:1,h:1,c:"#FFF",a:.35},{x:5,y:7,w:2,h:1,c:"darken($skin, 25)",a:.4},{x:0,y:4,w:1,h:1,c:"$skin"},{x:11,y:4,w:1,h:1,c:"$skin"}],CC=[{x:1,y:0,w:10,h:3,c:"$hair"},{x:0,y:1,w:2,h:3,c:"$hair"},{x:10,y:1,w:2,h:3,c:"$hair"},{x:2,y:0,w:8,h:1,c:"lighten($hair, 25)",a:.3},{x:2,y:2,w:8,h:1,c:"darken($hair, 20)",a:.2}];function EC(){return{width:12,height:22,layers:[{name:"lower",pixels:kC},{name:"torso",pixels:jC},{name:"head",pixels:SC},{name:"hair",pixels:CC},{name:"accessory",pixels:[]}]}}const NC=["cto","cbo","pm","engineer","designer","qa","data-analyst","default"];for(const e of NC)zb(`mini:${e}`,EC());const AC=[{x:1,y:10,w:10,h:8,c:"$shirt"},{x:2,y:10,w:8,h:1,c:"lighten($shirt, 18)",a:.3},{x:1,y:10,w:1,h:7,c:"darken($shirt, 25)",a:.25},{x:10,y:10,w:1,h:7,c:"darken($shirt, 25)",a:.25},{x:4,y:10,w:4,h:2,c:"darken($shirt, 25)",a:.2},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"}],DC=[{x:4,y:8,w:4,h:3,c:"$skin"},{x:1,y:1,w:10,h:8,c:"$skin"},{x:3,y:4,w:2,h:2,c:"#1A1A2E"},{x:7,y:4,w:2,h:2,c:"#1A1A2E"},{x:3,y:4,w:1,h:1,c:"#FFF",a:.35},{x:7,y:4,w:1,h:1,c:"#FFF",a:.35},{x:5,y:7,w:2,h:1,c:"darken($skin, 25)",a:.4},{x:0,y:4,w:1,h:1,c:"$skin"},{x:11,y:4,w:1,h:1,c:"$skin"}],TC=[{x:1,y:0,w:10,h:3,c:"$hair"},{x:0,y:1,w:2,h:3,c:"$hair"},{x:10,y:1,w:2,h:3,c:"$hair"},{x:2,y:0,w:8,h:1,c:"lighten($hair, 25)",a:.3},{x:2,y:2,w:8,h:1,c:"darken($hair, 20)",a:.2}];function FC(){return{width:12,height:22,layers:[{name:"torso",pixels:AC},{name:"head",pixels:DC},{name:"hair",pixels:TC},{name:"accessory",pixels:[]}]}}zb("mini-seated:default",FC());const MC={canvasWidth:160,canvasHeight:80,scale:2,pixels:[{x:0,y:0,w:80,h:40,c:"#1e2030"},{x:10,y:2,w:10,h:6,c:"#78889c"},{x:10,y:2,w:10,h:1,c:"#8899ad"},{x:24,y:0,w:10,h:6,c:"#78889c"},{x:24,y:0,w:10,h:1,c:"#8899ad"},{x:38,y:2,w:10,h:6,c:"#78889c"},{x:38,y:2,w:10,h:1,c:"#8899ad"},{x:54,y:2,w:10,h:6,c:"#78889c"},{x:54,y:2,w:10,h:1,c:"#8899ad"},{x:11,y:7,w:2,h:2,c:"#2a2a2a"},{x:17,y:7,w:2,h:2,c:"#2a2a2a"},{x:25,y:5,w:2,h:2,c:"#2a2a2a"},{x:31,y:5,w:2,h:2,c:"#2a2a2a"},{x:39,y:7,w:2,h:2,c:"#2a2a2a"},{x:45,y:7,w:2,h:2,c:"#2a2a2a"},{x:55,y:7,w:2,h:2,c:"#2a2a2a"},{x:61,y:7,w:2,h:2,c:"#2a2a2a"},{x:8,y:8,w:64,h:24,c:"#6b5b4b"},{x:4,y:10,w:72,h:20,c:"#7d6d5d"},{x:2,y:12,w:76,h:16,c:"#7d6d5d"},{x:2,y:12,w:76,h:2,c:"#8b7b6b"},{x:2,y:26,w:76,h:2,c:"#4b3b2b"},{x:2,y:28,w:76,h:3,c:"#4b3b2b"},{x:4,y:28,w:72,h:1,c:"#5b4b3b"},{x:6,y:30,w:3,h:2,c:"#3a2a1a"},{x:71,y:30,w:3,h:2,c:"#3a2a1a"},{x:18,y:14,w:44,h:12,c:"#6b5b4b",a:.5},{x:28,y:14,w:14,h:8,c:"#1a1a2e"},{x:29,y:15,w:12,h:6,c:"#1565C0",a:.5},{x:30,y:16,w:8,h:1,c:"#60A5FA",a:.45},{x:30,y:18,w:5,h:1,c:"#60A5FA",a:.3},{x:58,y:16,w:5,h:5,c:"#795548"},{x:59,y:17,w:3,h:3,c:"#A67C52"},{x:63,y:18,w:2,h:2,c:"#795548"},{x:10,y:16,w:10,h:8,c:"#FFEE58",a:.7},{x:11,y:17,w:8,h:1,c:"#9E9E9E",a:.5},{x:11,y:19,w:8,h:1,c:"#9E9E9E",a:.5},{x:11,y:21,w:6,h:1,c:"#9E9E9E",a:.5},{x:10,y:32,w:10,h:6,c:"#78889c"},{x:10,y:32,w:10,h:1,c:"#8899ad"},{x:24,y:34,w:10,h:6,c:"#78889c"},{x:24,y:34,w:10,h:1,c:"#8899ad"},{x:38,y:32,w:10,h:6,c:"#78889c"},{x:38,y:32,w:10,h:1,c:"#8899ad"},{x:54,y:32,w:10,h:6,c:"#78889c"},{x:54,y:32,w:10,h:1,c:"#8899ad"},{x:11,y:37,w:2,h:2,c:"#2a2a2a"},{x:17,y:37,w:2,h:2,c:"#2a2a2a"},{x:25,y:39,w:2,h:2,c:"#2a2a2a"},{x:31,y:39,w:2,h:2,c:"#2a2a2a"},{x:39,y:37,w:2,h:2,c:"#2a2a2a"},{x:45,y:37,w:2,h:2,c:"#2a2a2a"},{x:55,y:37,w:2,h:2,c:"#2a2a2a"},{x:61,y:37,w:2,h:2,c:"#2a2a2a"}]},RC={canvasWidth:128,canvasHeight:96,scale:2,pixels:[{x:0,y:0,w:64,h:48,c:"#4b3b2b"},{x:3,y:3,w:58,h:42,c:"#8B7355"},{x:4,y:4,w:10,h:10,c:"#A0845C",a:.5},{x:20,y:8,w:8,h:8,c:"#A0845C",a:.4},{x:40,y:6,w:12,h:6,c:"#A0845C",a:.3},{x:8,y:30,w:14,h:10,c:"#A0845C",a:.25},{x:44,y:32,w:10,h:8,c:"#A0845C",a:.3},{x:6,y:8,w:18,h:12,c:"#FFEE58"},{x:5,y:7,w:3,h:3,c:"#EF5350"},{x:6,y:7,w:2,h:2,c:"#C62828"},{x:8,y:10,w:14,h:1,c:"#9E9E9E"},{x:8,y:12,w:12,h:1,c:"#9E9E9E"},{x:8,y:14,w:10,h:1,c:"#9E9E9E"},{x:28,y:6,w:16,h:14,c:"#B3E5FC"},{x:35,y:5,w:3,h:3,c:"#42A5F5"},{x:36,y:5,w:2,h:2,c:"#1565C0"},{x:30,y:9,w:12,h:1,c:"#9E9E9E"},{x:30,y:11,w:10,h:1,c:"#9E9E9E"},{x:30,y:13,w:11,h:1,c:"#9E9E9E"},{x:8,y:24,w:16,h:14,c:"#C8E6C9"},{x:15,y:23,w:3,h:3,c:"#66BB6A"},{x:16,y:23,w:2,h:2,c:"#388E3C"},{x:10,y:27,w:12,h:1,c:"#9E9E9E"},{x:10,y:29,w:8,h:1,c:"#9E9E9E"},{x:10,y:31,w:10,h:1,c:"#9E9E9E"},{x:28,y:24,w:28,h:16,c:"#FFCDD2"},{x:43,y:23,w:3,h:3,c:"#EF5350"},{x:44,y:23,w:2,h:2,c:"#B71C1C"},{x:32,y:27,w:24,h:1,c:"#9E9E9E"},{x:32,y:29,w:20,h:1,c:"#9E9E9E"},{x:32,y:31,w:22,h:1,c:"#9E9E9E"},{x:32,y:33,w:15,h:1,c:"#9E9E9E"},{x:0,y:0,w:64,h:3,c:"#5a4a3a"},{x:0,y:45,w:64,h:3,c:"#3a2a1a"}]},zC={canvasWidth:128,canvasHeight:96,scale:2,pixels:[{x:2,y:0,w:60,h:48,c:"#3b1f0a"},{x:4,y:2,w:56,h:44,c:"#5a3310"},{x:4,y:13,w:56,h:2,c:"#2d1508"},{x:4,y:27,w:56,h:2,c:"#2d1508"},{x:4,y:41,w:56,h:2,c:"#2d1508"},{x:5,y:3,w:4,h:10,c:"#2563EB"},{x:5,y:3,w:4,h:2,c:"#1D4ED8"},{x:10,y:4,w:3,h:9,c:"#DC2626"},{x:10,y:4,w:3,h:2,c:"#B91C1C"},{x:14,y:3,w:5,h:10,c:"#16A34A"},{x:14,y:3,w:5,h:2,c:"#15803D"},{x:20,y:4,w:3,h:9,c:"#9333EA"},{x:20,y:4,w:3,h:2,c:"#7E22CE"},{x:24,y:3,w:4,h:10,c:"#D97706"},{x:24,y:3,w:4,h:2,c:"#B45309"},{x:29,y:4,w:3,h:9,c:"#0891B2"},{x:29,y:4,w:3,h:2,c:"#0E7490"},{x:33,y:3,w:5,h:10,c:"#BE123C"},{x:33,y:3,w:5,h:2,c:"#9F1239"},{x:39,y:4,w:4,h:9,c:"#4F46E5"},{x:39,y:4,w:4,h:2,c:"#3730A3"},{x:44,y:3,w:3,h:10,c:"#065F46"},{x:44,y:3,w:3,h:2,c:"#064E3B"},{x:48,y:4,w:4,h:9,c:"#92400E"},{x:48,y:4,w:4,h:2,c:"#78350F"},{x:53,y:3,w:5,h:10,c:"#1E3A5F"},{x:53,y:3,w:5,h:2,c:"#1e3060"},{x:6,y:6,w:2,h:1,c:"#BFDBFE",a:.7},{x:11,y:7,w:1,h:1,c:"#FCA5A5",a:.7},{x:16,y:6,w:3,h:1,c:"#BBF7D0",a:.7},{x:21,y:7,w:1,h:1,c:"#D8B4FE",a:.7},{x:25,y:6,w:2,h:1,c:"#FDE68A",a:.7},{x:5,y:16,w:5,h:11,c:"#0F766E"},{x:5,y:16,w:5,h:2,c:"#0D6056"},{x:11,y:17,w:3,h:10,c:"#C2410C"},{x:11,y:17,w:3,h:2,c:"#9A3412"},{x:15,y:16,w:4,h:11,c:"#7C3AED"},{x:15,y:16,w:4,h:2,c:"#6D28D9"},{x:20,y:17,w:3,h:10,c:"#1D4ED8"},{x:20,y:17,w:3,h:2,c:"#1E40AF"},{x:24,y:16,w:5,h:11,c:"#166534"},{x:24,y:16,w:5,h:2,c:"#14532D"},{x:30,y:17,w:4,h:10,c:"#991B1B"},{x:30,y:17,w:4,h:2,c:"#7F1D1D"},{x:35,y:16,w:3,h:11,c:"#854D0E"},{x:35,y:16,w:3,h:2,c:"#713F12"},{x:39,y:17,w:4,h:10,c:"#1E40AF"},{x:39,y:17,w:4,h:2,c:"#1E3A8A"},{x:44,y:16,w:5,h:11,c:"#065F46"},{x:44,y:16,w:5,h:2,c:"#064E3B"},{x:50,y:17,w:3,h:10,c:"#831843"},{x:50,y:17,w:3,h:2,c:"#6B21A8"},{x:54,y:16,w:5,h:11,c:"#374151"},{x:54,y:16,w:5,h:2,c:"#1F2937"},{x:5,y:30,w:4,h:11,c:"#0E7490"},{x:5,y:30,w:4,h:2,c:"#0C6B7E"},{x:10,y:31,w:3,h:10,c:"#B45309"},{x:10,y:31,w:3,h:2,c:"#92400E"},{x:14,y:30,w:5,h:11,c:"#6D28D9"},{x:14,y:30,w:5,h:2,c:"#5B21B6"},{x:20,y:30,w:7,h:8,c:"#1e293b"},{x:22,y:32,w:3,h:3,c:"#3b82f6",a:.9},{x:22,y:32,w:1,h:3,c:"#60a5fa",a:.6},{x:28,y:31,w:4,h:10,c:"#DC2626"},{x:28,y:31,w:4,h:2,c:"#B91C1C"},{x:33,y:30,w:3,h:11,c:"#065F46"},{x:33,y:30,w:3,h:2,c:"#064E3B"},{x:37,y:31,w:4,h:10,c:"#1D4ED8"},{x:37,y:31,w:4,h:2,c:"#1E40AF"},{x:42,y:35,w:6,h:6,c:"#92400E"},{x:43,y:30,w:4,h:6,c:"#16a34a",a:.8},{x:43,y:29,w:2,h:3,c:"#15803d",a:.7},{x:45,y:28,w:2,h:4,c:"#16a34a",a:.6},{x:49,y:30,w:3,h:11,c:"#7C3AED"},{x:49,y:30,w:3,h:2,c:"#6D28D9"},{x:53,y:31,w:5,h:10,c:"#B45309"},{x:53,y:31,w:5,h:2,c:"#92400E"},{x:2,y:46,w:60,h:2,c:"#1a0a03"},{x:2,y:0,w:60,h:2,c:"#4a2510"},{x:2,y:0,w:2,h:48,c:"#2d1508"},{x:60,y:0,w:2,h:48,c:"#2d1508"}]},_C={canvasWidth:96,canvasHeight:120,scale:2,pixels:[{x:2,y:0,w:44,h:60,c:"#546E7A"},{x:2,y:0,w:44,h:3,c:"#78909C"},{x:2,y:57,w:44,h:3,c:"#37474F"},{x:2,y:0,w:2,h:60,c:"#455A64"},{x:44,y:0,w:2,h:60,c:"#37474F"},{x:5,y:4,w:38,h:3,c:"#FFD54F",a:.5},{x:6,y:1,w:2,h:4,c:"#FFFDE7"},{x:10,y:0,w:2,h:5,c:"#FFF9C4"},{x:14,y:1,w:2,h:3,c:"#FFFDE7"},{x:18,y:0,w:2,h:4,c:"#FFF8E1"},{x:5,y:5,w:38,h:16,c:"#607D8B"},{x:5,y:5,w:38,h:2,c:"#78909C"},{x:15,y:12,w:18,h:4,c:"#37474F"},{x:22,y:11,w:4,h:6,c:"#455A64"},{x:23,y:13,w:2,h:2,c:"#B0BEC5"},{x:7,y:14,w:8,h:5,c:"#B0BEC5"},{x:8,y:15,w:6,h:1,c:"#607D8B"},{x:8,y:17,w:5,h:1,c:"#607D8B"},{x:5,y:23,w:38,h:16,c:"#607D8B"},{x:5,y:23,w:38,h:2,c:"#78909C"},{x:15,y:30,w:18,h:4,c:"#37474F"},{x:22,y:29,w:4,h:6,c:"#455A64"},{x:23,y:31,w:2,h:2,c:"#B0BEC5"},{x:7,y:32,w:8,h:5,c:"#B0BEC5"},{x:8,y:33,w:6,h:1,c:"#607D8B"},{x:8,y:35,w:4,h:1,c:"#607D8B"},{x:5,y:41,w:38,h:16,c:"#607D8B"},{x:5,y:41,w:38,h:2,c:"#78909C"},{x:15,y:48,w:18,h:4,c:"#37474F"},{x:22,y:47,w:4,h:6,c:"#455A64"},{x:23,y:49,w:2,h:2,c:"#B0BEC5"},{x:7,y:50,w:8,h:5,c:"#B0BEC5"},{x:8,y:51,w:6,h:1,c:"#607D8B"},{x:8,y:53,w:3,h:1,c:"#607D8B"}]};ed("meeting",MC);ed("bulletin",RC);ed("decision",_C);ed("knowledge",zC);const kh=16,jh=24,BC=60,OC={cbo:0,cto:8,pm:15,engineer:22,designer:5,qa:12};function Xb(e,n){if(!e)return e;let a=e;if(n!=null&&n.hairStyle){const i=lC(n.hairStyle);i&&(a=rC(a,i.layer))}if(n!=null&&n.outfitStyle){const i=cC(n.outfitStyle);i&&(a=am(a,"torso",i.layer,1))}if(n!=null&&n.accessory&&n.accessory!=="none"){const i=hC(n.accessory);i&&(a=am(a,"accessory",i.layer))}return a}function Vl({roleId:e,className:n,appearance:a,scale:i}){const o=w.useRef(null),u=w.useRef(0),d=w.useRef(0),f=w.useRef(a);f.current=a;const m=i??4,h=kh*m,x=jh*m,g=w.useMemo(()=>{const v=lm(`mini:${e}`)??lm("mini:default");return Xb(v,a)},[e,a==null?void 0:a.hairStyle,a==null?void 0:a.outfitStyle,a==null?void 0:a.accessory]);return w.useEffect(()=>{const v=o.current;if(!v)return;const b=v.getContext("2d");if(!b)return;const j=OC[e]??0,k=()=>{d.current++;const N=f.current;if(!N||!g){u.current=requestAnimationFrame(k);return}const C=(d.current+j)%BC<30?1:0;b.clearRect(0,0,kh,jh),b.save(),b.translate(2,1),aC(b,g,C,N,1),b.restore(),u.current=requestAnimationFrame(k)};return u.current=requestAnimationFrame(k),()=>cancelAnimationFrame(u.current)},[e,g]),l.jsx("canvas",{ref:o,width:kh,height:jh,className:n,style:{imageRendering:"pixelated",display:"block",width:h,height:x}})}const $C="https://api.tycono.ai",Xm=$C;async function No(e){const n=await fetch(`${Xm}${e}`);if(!n.ok)throw new Error(`Cloud API error: ${n.status}`);return n.json()}async function bi(e,n){const a=await fetch(`${Xm}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!a.ok)throw new Error(`Cloud API error: ${a.status}`);return a.json()}const wr={health:()=>No("/api/health"),getMyName:e=>No(`/api/auth/my-name?instance_id=${encodeURIComponent(e)}`),getCharacters:e=>{const n=new URLSearchParams;e!=null&&e.sort&&n.set("sort",e.sort),e!=null&&e.instanceId&&n.set("instance_id",e.instanceId);const a=n.toString();return No(`/api/store/characters${a?`?${a}`:""}`)},getCharacter:e=>No(`/api/store/characters/${e}`),getCharacterVersion:e=>No(`/api/store/characters/${e}/version`),voteCharacter:(e,n,a)=>bi(`/api/store/characters/${e}/vote`,{instanceId:n,vote:a}),trackInstall:e=>bi(`/api/store/characters/${e}/install`,{}),syncCheck:e=>bi("/api/sync/check",{roles:e}),syncPull:e=>bi("/api/sync/pull",{sourceId:e}),publishCharacter:e=>bi("/api/store/publish",e),deleteCharacter:(e,n)=>{const a=n?`?publisher_id=${encodeURIComponent(n)}`:"";return fetch(`${Xm}/api/store/characters/${e}${a}`,{method:"DELETE"}).then(i=>i.json())},uploadTelemetry:e=>bi("/api/telemetry",e),syncStats:e=>bi("/api/stats/sync",e)},LC={cto:"🏗️",cbo:"📊",pm:"📋",engineer:"⚙️",designer:"🎨",qa:"🔍"},Sh={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"},IC={cto:"Chief Technology Officer",cbo:"Chief Business Officer",pm:"Product Manager",engineer:"Software Engineer",designer:"UI/UX Designer",qa:"QA Engineer"},HC=500,Ng=360,Ag=700,UC=e=>`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`;function Dg({role:e,allRoles:n,recentActivity:a,onClose:i,onFireRole:o,terminalWidth:u=0,activeJobId:d,activeSessionId:f,activeTask:m,isWorking:h,jobStartedAt:x,onStopJob:g,sessions:v,streamingSessionId:b,onCreateSessionSilent:j,onSendMessage:k,onFocusTerminal:N,onCustomize:E,onUpdateRole:C,appearance:_,relationships:R,roleLevel:L,onMaximize:F}){var Ke,bt;const[I,H]=w.useState(HC),[X,A]=w.useState(!1),$=w.useRef(0),q=w.useRef(0),[W,ie]=w.useState(!1),[P,Y]=w.useState(!1),[oe,de]=w.useState(!1),[G,D]=w.useState(!1),[B,U]=w.useState("talk"),[T,se]=w.useState(!1),[ge,pe]=w.useState(""),[Re,Ie]=w.useState(!1),He=w.useRef(null),[ot,Je]=w.useState(!1),[tt,Ee]=w.useState(""),[Ae,yt]=w.useState(!1),{events:dt,status:xt}=Ay(f??null),[jt,Wt]=w.useState(0);w.useEffect(()=>{if(!h||!x){Wt(0);return}const Me=new Date(x).getTime(),Ue=()=>Wt(Math.floor((Date.now()-Me)/1e3));Ue();const _t=setInterval(Ue,1e3);return()=>clearInterval(_t)},[h,x]);const Tt=u>0,Ct=Tt?u:0,Bn=Tt?Math.max(Ng,window.innerWidth-u-100):Ag,me=Math.min(I,Bn),Se=w.useCallback(Me=>{Me.preventDefault(),$.current=Me.clientX,q.current=me,A(!0);const Ue=F,_t=()=>{A(!1),document.removeEventListener("mousemove",Bt),document.removeEventListener("mouseup",_t)},Bt=Ot=>{const un=$.current-Ot.clientX,kn=q.current+un;if(kn>=window.innerWidth*.6&&Ue){_t(),Ue();return}const J=Math.min(Ag,Math.max(Ng,kn));H(J)};document.addEventListener("mousemove",Bt),document.addEventListener("mouseup",_t)},[me,F]),Ne=w.useRef(null),K=e?v.find(Me=>Me.roleId===e.id):null,ue=Me=>{if(!e)return;const Ue=h?"talk":B;K?(k(K.id,Me,Ue),N(e.id)):(Ne.current={content:Me,mode:Ue},j(e.id))};w.useEffect(()=>{if(K&&Ne.current){const{content:Me,mode:Ue}=Ne.current;Ne.current=null,k(K.id,Me,Ue),e&&N(e.id)}},[K==null?void 0:K.id]);const ne=(()=>{if(!dt.length)return null;const Me=[];let Ue=0,_t=0,Bt=0;for(const Ot of dt)if(Ot.type==="thinking")Ue++;else if(Ot.type==="text")_t++;else if(Ot.type==="tool:start"){const un=String(Ot.data.name??"");Me.includes(un)||Me.push(un)}else Ot.type==="dispatch:start"&&Bt++;return{tools:Me,thinkCount:Ue,textCount:_t,dispatchCount:Bt,total:dt.length}})(),ve=m||(()=>{if(!K)return null;const Me=K.messages;for(let Ue=Me.length-1;Ue>=0;Ue--)if(Me[Ue].from==="ceo")return Me[Ue].content;return null})(),we=(()=>{if(!K)return null;const Me=K.messages;for(let Ue=Me.length-1;Ue>=0;Ue--)if(Me[Ue].from==="role"&&Me[Ue].content)return Me[Ue].content;return null})();if(!e)return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"dimmer fixed top-0 left-0 bottom-0 bg-black/30 z-40 open",style:{right:Ct},onClick:i}),l.jsx("div",{className:"side-panel open fixed top-0 h-full z-50 flex items-center justify-center border-l-[3px]",style:{right:Ct,width:me,background:"var(--terminal-bg)",borderLeftColor:"var(--pixel-border)"},children:l.jsx("div",{className:"text-sm",style:{color:"var(--terminal-text-muted)"},children:"Loading role..."})})]});const ze=Sh[e.id]??"#666",_e=LC[e.id]??"👤",Be=n.filter(Me=>Me.reportsTo===e.id),qe=K&&b===K.id,at=e.name||IC[e.id]||e.id;return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"dimmer fixed top-0 left-0 bottom-0 bg-black/30 z-40 open",style:{right:Ct},onClick:i}),l.jsxs("div",{className:`side-panel open fixed top-0 h-full z-50 flex flex-col border-l-[3px] shadow-[-4px_0_20px_rgba(0,0,0,0.4)] ${X?"resizing":""}`,style:{borderLeftColor:ze,right:Ct,width:me,background:"var(--terminal-bg)"},children:[l.jsx("div",{className:`absolute top-0 -left-[5px] w-[10px] h-full cursor-col-resize z-[60] transition-colors ${X?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:Se}),l.jsxs("div",{className:"relative shrink-0 overflow-hidden",style:{background:`linear-gradient(135deg, ${ze}ee, ${ze}99)`},children:[l.jsx("div",{className:"absolute inset-0 opacity-[0.06]",style:{backgroundImage:"repeating-linear-gradient(45deg, transparent, transparent 8px, white 8px, white 9px)"}}),l.jsxs("div",{className:"absolute top-3 right-3 flex items-center gap-1.5 z-10",children:[E&&l.jsx("button",{onClick:()=>E(e.id),className:"w-7 h-7 rounded-full bg-black/20 text-white flex items-center justify-center text-sm hover:bg-black/30 cursor-pointer backdrop-blur-sm",title:"Customize",children:"🎨"}),F&&l.jsx("button",{onClick:F,className:"w-7 h-7 rounded-full bg-black/20 text-white flex items-center justify-center text-sm hover:bg-black/30 cursor-pointer backdrop-blur-sm",title:"Maximize (Pro View)",children:"⤢"}),l.jsx("button",{onClick:i,className:"w-7 h-7 rounded-full bg-black/20 text-white flex items-center justify-center text-lg hover:bg-black/30 cursor-pointer backdrop-blur-sm",children:"×"})]}),l.jsxs("div",{className:"relative flex items-end gap-4 px-4 pt-4 pb-3",children:[l.jsx("div",{className:"shrink-0 relative",style:{marginBottom:-2},children:l.jsx("div",{className:"rounded-lg p-1",style:{background:"rgba(0,0,0,0.2)"},children:l.jsx(Vl,{roleId:e.id,appearance:_,scale:8})})}),l.jsxs("div",{className:"flex-1 min-w-0 text-white pb-1",children:[l.jsxs("div",{className:"text-lg font-bold flex items-center gap-2",style:{fontFamily:"var(--pixel-font)"},children:[_e," ",e.id.toUpperCase(),h&&l.jsx("span",{className:"text-[9px] font-semibold px-2 py-0.5 rounded-full animate-pulse",style:{background:"rgba(251,191,36,0.25)",color:"#fde68a"},children:"WORKING"})]}),T?l.jsxs("form",{className:"flex items-center gap-1.5 mt-0.5",onSubmit:async Me=>{Me.preventDefault();const Ue=ge.trim();if(!Ue||Ue===at||!C){se(!1);return}Ie(!0);try{await C(e.id,{name:Ue})}catch{}Ie(!1),se(!1)},children:[l.jsx("input",{ref:He,value:ge,onChange:Me=>pe(Me.target.value),onKeyDown:Me=>{Me.key==="Escape"&&se(!1)},disabled:Re,autoFocus:!0,className:"bg-white/20 text-white text-xs rounded px-1.5 py-0.5 outline-none focus:bg-white/30 w-full",style:{fontFamily:"inherit"}}),l.jsx("button",{type:"submit",disabled:Re,className:"text-white/80 hover:text-white text-[10px] cursor-pointer shrink-0",children:"✓"}),l.jsx("button",{type:"button",onClick:()=>se(!1),className:"text-white/60 hover:text-white text-[10px] cursor-pointer shrink-0",children:"✕"})]}):l.jsxs("div",{className:"text-xs opacity-75 mt-0.5 group/name flex items-center gap-1 cursor-pointer hover:opacity-100 transition-opacity",onClick:()=>{C&&(pe(at),se(!0))},title:C?"Click to edit name":void 0,children:[at,C&&l.jsx("span",{className:"opacity-0 group-hover/name:opacity-60 text-[10px]",children:"✎"})]})]})]}),l.jsxs("div",{className:"relative flex items-center gap-3 px-4 py-2 text-[10px] font-bold text-white/80",style:{background:"rgba(0,0,0,0.2)",fontFamily:"var(--pixel-font)"},children:[l.jsxs("span",{children:["Lv.",L??1]}),l.jsx("span",{style:{color:"rgba(255,255,255,0.3)"},children:"|"}),l.jsxs("span",{className:"flex items-center gap-1.5",children:[l.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:h?"var(--idle-amber)":"var(--active-green)"}}),h?"Working":"Idle"]}),l.jsx("span",{style:{color:"rgba(255,255,255,0.3)"},children:"|"}),l.jsx("span",{children:e.level}),e.reportsTo&&l.jsxs(l.Fragment,{children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.3)"},children:"|"}),l.jsxs("span",{className:"opacity-60",children:["→"," ",e.reportsTo]})]})]})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto flex flex-col min-h-0",children:[h&&l.jsxs("div",{className:"px-4 py-3 shrink-0",style:{borderBottom:"1px solid var(--terminal-border)",background:"var(--hud-bg-alt)"},children:[l.jsxs("div",{className:"flex items-center justify-between mb-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:"w-2 h-2 rounded-full animate-pulse",style:{background:"var(--idle-amber)"}}),l.jsxs("span",{className:"text-xs font-semibold",style:{color:"var(--idle-amber)"},children:["Working",jt>0?` · ${UC(jt)}`:""]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{onClick:()=>N(e.id),className:"text-[10px] cursor-pointer hover:underline",style:{color:"var(--terminal-text-muted)"},children:"Open chat ↗"}),d&&g&&l.jsx("button",{onClick:()=>g(d),className:"text-[10px] px-2 py-0.5 rounded cursor-pointer font-semibold transition-colors",style:{background:"rgba(239,68,68,0.15)",color:"#ef4444"},children:"Stop"})]})]}),ve&&l.jsx("div",{className:"text-xs truncate",style:{color:"var(--terminal-text-secondary)"},children:ve})]}),h&&d&&ne&&l.jsxs("div",{className:"px-4 py-2.5 shrink-0",style:{borderBottom:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[l.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider",style:{color:"var(--terminal-text-secondary)"},children:"Activity"}),l.jsx("button",{onClick:()=>N(e.id),className:"text-[10px] cursor-pointer hover:underline",style:{color:"var(--terminal-text-muted)"},children:"View details ↗"})]}),l.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[ne.thinkCount>0&&l.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px]",style:{background:"rgba(168,85,247,0.15)",color:"#c084fc"},children:[l.jsx("span",{className:"w-1.5 h-1.5 rounded-full",style:{background:"#a855f7"}}),"thinking ×",ne.thinkCount]}),ne.tools.map(Me=>l.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px]",style:{background:"rgba(59,130,246,0.15)",color:"#60a5fa"},children:Me},Me)),ne.dispatchCount>0&&l.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[10px]",style:{background:"rgba(249,115,22,0.15)",color:"#fb923c"},children:["dispatch ×",ne.dispatchCount]}),ne.textCount>0&&l.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[10px]",style:{background:"rgba(34,197,94,0.15)",color:"#4ade80"},children:["output ×",ne.textCount]}),(xt==="streaming"||xt==="connecting")&&l.jsx("span",{className:"inline-block w-1.5 h-3 animate-pulse rounded-sm",style:{background:"var(--active-green)"}})]}),l.jsxs("div",{className:"text-[10px] mt-1",style:{color:"var(--terminal-text-muted)"},children:[ne.total," events"]})]}),h&&we&&l.jsxs("div",{className:"px-4 py-2.5 shrink-0",style:{borderBottom:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[l.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider",style:{color:"var(--terminal-text-secondary)"},children:"Last Message"}),l.jsx("button",{onClick:()=>N(e.id),className:"text-[10px] cursor-pointer hover:underline",style:{color:"var(--terminal-text-muted)"},children:"Open chat ↗"})]}),l.jsxs("div",{className:"rounded-lg p-2.5 text-xs leading-relaxed line-clamp-3 overflow-hidden",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text-secondary)"},children:[we.slice(0,200),we.length>200&&"..."]})]}),h&&l.jsx("div",{className:"px-4 py-2.5 shrink-0",style:{borderBottom:"1px solid var(--terminal-border)"},children:l.jsx(Tg,{onSend:ue,disabled:!!qe,placeholder:"Ask something...",color:ze})}),!h&&l.jsxs("div",{className:"px-4 pt-4 pb-2",children:[l.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider mb-2",style:{color:"var(--terminal-text-secondary)"},children:"Latest"}),l.jsx(YC,{icon:_e,roleId:e.id,roleName:at,color:ze,text:a})]}),!h&&l.jsx("div",{className:"px-4 py-3",style:{borderBottom:"1px solid var(--terminal-border)"},children:l.jsxs("div",{className:"rounded-xl overflow-hidden",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)"},children:[we&&l.jsxs("div",{className:"px-3 pt-2.5 pb-2 cursor-pointer transition-colors",style:{borderBottom:"1px solid var(--terminal-border)"},onClick:()=>N(e.id),children:[l.jsxs("div",{className:"flex items-center justify-between mb-1",children:[l.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--terminal-text-muted)"},children:"Last response"}),l.jsx("span",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:"View ↗"})]}),l.jsxs("div",{className:"text-xs leading-relaxed line-clamp-2 overflow-hidden",style:{color:"var(--terminal-text-secondary)"},children:[we.slice(0,150),we.length>150&&"..."]})]}),l.jsx("div",{className:"p-2",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("div",{className:"flex rounded-lg overflow-hidden shrink-0",style:{border:"1px solid var(--pixel-border)"},children:[l.jsx("button",{onClick:()=>U("talk"),className:"px-2 py-1 text-[10px] font-semibold cursor-pointer transition-colors",style:{background:B==="talk"?"var(--accent)":"transparent",color:B==="talk"?"#fff":"var(--terminal-text-secondary)"},children:"Talk"}),l.jsx("button",{onClick:()=>U("do"),className:"px-2 py-1 text-[10px] font-semibold cursor-pointer transition-colors",style:{background:B==="do"?"var(--idle-amber)":"transparent",color:B==="do"?"#fff":"var(--terminal-text-secondary)"},children:"Do"})]}),l.jsx(Tg,{onSend:ue,disabled:!!qe,placeholder:B==="talk"?"Ask something...":"Give a directive...",color:ze})]})})]})}),l.jsxs("div",{className:"px-4 py-2 space-y-1",children:[l.jsxs(vu,{title:`Profile${e.persona?"":" (empty)"}`,open:W,onToggle:()=>ie(Me=>!Me),children:[ot?l.jsxs("div",{className:"space-y-2",children:[l.jsx("textarea",{value:tt,onChange:Me=>Ee(Me.target.value),onKeyDown:Me=>{Me.key==="Escape"&&Je(!1)},disabled:Ae,autoFocus:!0,rows:5,placeholder:"Describe this role's personality and communication style. How do they talk? Are they sarcastic? Cheerful? Blunt?",className:"w-full text-xs leading-relaxed rounded-lg p-3 outline-none resize-y",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--active-green)",color:"var(--terminal-text)",fontFamily:"inherit",minHeight:"80px"}}),l.jsxs("div",{className:"flex gap-1.5 justify-end",children:[l.jsx("button",{onClick:()=>Je(!1),disabled:Ae,className:"text-[10px] px-2 py-0.5 rounded cursor-pointer",style:{color:"var(--terminal-text-muted)",border:"1px solid var(--terminal-border)"},children:"Cancel"}),l.jsx("button",{onClick:async()=>{if(C){yt(!0);try{await C(e.id,{persona:tt.trim()})}catch{}yt(!1),Je(!1)}},disabled:Ae,className:"text-[10px] px-2 py-0.5 rounded cursor-pointer font-semibold",style:{background:"var(--active-green)",color:"#000"},children:Ae?"Saving...":"Save"})]})]}):l.jsxs("div",{className:"text-xs leading-relaxed rounded-lg p-3 group/persona cursor-pointer hover:opacity-90 transition-opacity",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text-secondary)"},onClick:()=>{C&&(Ee(e.persona||""),Je(!0))},title:C?"Click to edit persona":void 0,children:[e.persona||l.jsx("span",{style:{color:"var(--terminal-text-muted)"},children:"No persona set. Click to add one."}),C&&l.jsx("span",{className:"opacity-0 group-hover/persona:opacity-60 text-[10px] ml-1",children:"✎"})]}),l.jsxs("div",{className:"space-y-0 mt-2",children:[l.jsx(Ch,{label:"Level",value:e.level}),l.jsx(Ch,{label:"Reports to",value:e.reportsTo}),l.jsx(Ch,{label:"Status",value:e.status})]}),Be.length>0&&l.jsxs("div",{className:"mt-3",children:[l.jsx("div",{className:"text-[11px] font-semibold mb-1",style:{color:"var(--terminal-text-muted)"},children:"Direct Reports"}),l.jsx("div",{className:"space-y-1",children:Be.map(Me=>l.jsxs("div",{className:"flex items-center gap-2 p-1.5 rounded-lg",style:{background:"var(--hud-bg-alt)"},children:[l.jsx("div",{className:"w-6 h-6 rounded flex items-center justify-center text-white text-[10px] font-bold",style:{background:Sh[Me.id]??"#666"},children:Me.id.slice(0,2).toUpperCase()}),l.jsx("div",{className:"text-xs",style:{color:"var(--terminal-text)"},children:Me.name})]},Me.id))})]})]}),e.authority&&l.jsxs(vu,{title:"Authority",open:P,onToggle:()=>Y(Me=>!Me),children:[((Ke=e.authority.autonomous)==null?void 0:Ke.length)>0&&l.jsxs("div",{className:"mb-2",children:[l.jsx("div",{className:"text-xs font-semibold mb-1",style:{color:"var(--active-green)"},children:"Autonomous"}),e.authority.autonomous.map((Me,Ue)=>l.jsxs("div",{className:"text-xs pl-3 py-0.5",style:{color:"var(--terminal-text-secondary)"},children:["- ",Me]},Ue))]}),((bt=e.authority.needsApproval)==null?void 0:bt.length)>0&&l.jsxs("div",{children:[l.jsx("div",{className:"text-xs font-semibold mb-1",style:{color:"var(--idle-amber)"},children:"Needs Approval"}),e.authority.needsApproval.map((Me,Ue)=>l.jsxs("div",{className:"text-xs pl-3 py-0.5",style:{color:"var(--terminal-text-secondary)"},children:["- ",Me]},Ue))]})]}),e&&R&&(()=>{const Me=R.filter(Ue=>Ue.roleA===e.id||Ue.roleB===e.id).filter(Ue=>Ue.familiarity>0).sort((Ue,_t)=>_t.familiarity-Ue.familiarity);return Me.length===0?null:l.jsx(vu,{title:`Relationships (${Me.length})`,open:oe,onToggle:()=>de(Ue=>!Ue),children:l.jsx("div",{className:"space-y-1.5",children:Me.map((Ue,_t)=>{const Bt=Ue.roleA===e.id?Ue.roleB:Ue.roleA,Ot=n.find(J=>J.id===Bt),un=Ue.familiarity>=80?"Best Partner":Ue.familiarity>=50?"Friend":Ue.familiarity>=20?"Colleague":"Acquaintance",kn=Ue.familiarity>=80?"#4CAF50":Ue.familiarity>=50?"#2196F3":Ue.familiarity>=20?"#FF9800":"#9E9E9E";return l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-xs w-20 truncate",style:{color:Sh[Bt]??"var(--terminal-text-secondary)"},children:(Ot==null?void 0:Ot.name)??Bt}),l.jsx("div",{className:"flex-1 h-1.5 rounded-full bg-white/10",children:l.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Ue.familiarity}%`,background:kn}})}),l.jsx("span",{className:"text-[10px] w-16 text-right",style:{color:"var(--terminal-text-muted)"},children:un})]},_t)})})})})(),e.journal&&l.jsx(vu,{title:`Journal (${(e.journal.match(/### /g)??[]).length})`,open:G,onToggle:()=>D(Me=>!Me),children:l.jsxs("div",{className:"text-xs leading-relaxed rounded-lg p-3 max-h-[300px] overflow-y-auto",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text-secondary)"},children:[l.jsx(Es,{content:e.journal.slice(0,3e3)}),e.journal.length>3e3&&l.jsx("div",{className:"italic mt-2",style:{color:"var(--terminal-text-muted)"},children:"... (truncated)"})]})})]}),l.jsx(qC,{role:e,appearance:_}),o&&l.jsx("div",{className:"px-4 pb-4 mt-auto shrink-0",children:l.jsx("button",{onClick:()=>{o(e.id,e.name),i()},className:"w-full p-2 text-center text-xs font-medium border-2 border-dashed rounded-lg cursor-pointer transition-colors",style:{borderColor:"rgba(239,68,68,0.3)",color:"rgba(239,68,68,0.5)"},children:"Fire Role"})})]})]})]})}function qC({role:e,appearance:n}){const[a,i]=w.useState("idle"),[o,u]=w.useState(""),[d,f]=w.useState(!1),[m,h]=w.useState(null),[x,g]=w.useState(!1),[v,b]=w.useState(!1),[j,k]=w.useState(null);w.useEffect(()=>{wr.getCharacterVersion(e.id).then(C=>h((C==null?void 0:C.version)??null)).catch(()=>h(null)),ye.getPreferences().then(C=>k(C.instanceId??null)).catch(()=>{})},[e.id]);const N=async()=>{var C,_;if(!d){f(!0);return}i("publishing");try{let R=null;try{R=await ye.exportSkills(e.id)}catch{}const L={roleId:e.id,persona:e.persona??"",authority:e.authority??{autonomous:[],needsApproval:[]},level:e.level,tagline:((C=(e.persona??"").split(/[.\n]/)[0])==null?void 0:C.trim().slice(0,80))||e.name,chatStyle:"Professional and focused",skills:R??[],resume:{summary:((_=e.persona)==null?void 0:_.split(`
|
|
81
|
+
`)[0])??"",strengths:[],specialties:[],experience:""},author:{id:"tycono",name:"Tycono"},tags:[e.level,e.id],price:"free",installs:0,rating:0,featured:!1,randomActive:!0,randomPersonality:""};n&&(L.appearance=n);let F="1.0.0";try{const I=await wr.getCharacterVersion(e.id);if(I!=null&&I.version){const H=I.version.split(".").map(Number);H[2]=(H[2]??0)+1,F=H.join(".")}}catch{}await wr.publishCharacter({id:e.id,name:e.name||e.id,version:F,data:L,publisherId:j??void 0}),i("done"),u(`Published v${F}`),h(F),f(!1)}catch(R){i("error"),u(R instanceof Error?R.message:"Failed"),f(!1)}},E=async()=>{b(!0);try{await wr.deleteCharacter(e.id,j??void 0),h(null),i("idle"),u(""),g(!1)}catch{u("Delete failed")}b(!1)};return l.jsx("div",{className:"px-4 pb-2 shrink-0",children:l.jsx("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid var(--terminal-border)"},children:l.jsxs("div",{className:"px-3 py-2.5 flex items-center justify-between gap-2",style:{background:"var(--hud-bg-alt)"},children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx("a",{href:"https://tycono.ai/store.html",target:"_blank",rel:"noopener noreferrer",className:"text-[11px] font-bold uppercase tracking-wider shrink-0 hover:underline cursor-pointer",style:{color:"var(--terminal-text-secondary)",fontFamily:"var(--pixel-font)",textDecoration:"none"},onClick:C=>C.stopPropagation(),children:"Job Board ↗"}),m&&l.jsxs("span",{className:"text-[9px] px-1.5 py-0.5 rounded shrink-0",style:{background:"rgba(34,197,94,0.1)",color:"rgba(34,197,94,0.6)",border:"1px solid rgba(34,197,94,0.2)"},children:["v",m]})]}),l.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[a==="done"?l.jsx(l.Fragment,{children:l.jsx("span",{className:"text-[10px] font-semibold",style:{color:"var(--active-green)"},children:o})}):a==="error"?l.jsx("span",{className:"text-[10px] font-semibold",style:{color:"#ef4444"},children:o}):l.jsx("button",{onClick:N,disabled:a==="publishing",className:"text-[10px] px-2.5 py-1 rounded font-semibold cursor-pointer transition-colors disabled:opacity-50",style:{background:d?"rgba(59,130,246,0.3)":"rgba(59,130,246,0.15)",color:"#60a5fa",border:d?"1px solid rgba(59,130,246,0.5)":"1px solid transparent"},children:a==="publishing"?"Publishing...":d?"Confirm?":m?"Update":"Publish"}),m&&!x&&l.jsx("button",{onClick:()=>g(!0),className:"text-[10px] px-1.5 py-1 rounded cursor-pointer transition-colors",style:{color:"rgba(239,68,68,0.4)"},title:"Remove from store",children:"✕"}),x&&l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("button",{onClick:E,disabled:v,className:"text-[10px] px-2 py-1 rounded font-semibold cursor-pointer disabled:opacity-50",style:{background:"rgba(239,68,68,0.2)",color:"#ef4444",border:"1px solid rgba(239,68,68,0.3)"},children:v?"...":"Delete"}),l.jsx("button",{onClick:()=>g(!1),className:"text-[10px] px-1.5 py-1 rounded cursor-pointer",style:{color:"var(--terminal-text-muted)"},children:"No"})]})]})]})})})}function YC({icon:e,roleId:n,roleName:a,color:i,text:o}){const u=!!o;return l.jsx("div",{className:"relative",children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsxs("div",{className:"shrink-0",children:[l.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center text-xl shadow-sm",style:{background:`${i}18`,border:`2px solid ${i}44`},children:e}),l.jsx("div",{className:"text-[9px] font-bold text-center mt-0.5 uppercase tracking-wide",style:{color:i},children:n})]}),l.jsx("div",{className:"flex-1 min-w-0",children:l.jsxs("div",{className:"relative",children:[l.jsx("div",{className:"absolute top-3 -left-2 w-0 h-0",style:{borderTop:"6px solid transparent",borderBottom:"6px solid transparent",borderRight:`8px solid ${i}12`}}),l.jsxs("div",{className:"rounded-xl rounded-tl-sm p-4 border",style:{background:`${i}08`,borderColor:`${i}22`},children:[l.jsx("div",{className:"text-[10px] font-semibold mb-1.5 uppercase tracking-wider",style:{color:i},children:a}),u?l.jsx("div",{className:"text-sm leading-relaxed",style:{color:"var(--terminal-text)"},children:l.jsx(Es,{content:o})}):l.jsx("div",{className:"text-sm italic",style:{color:"var(--terminal-text-muted)"},children:"No recent activity."})]})]})})]})})}function vu({title:e,open:n,onToggle:a,children:i}){return l.jsxs("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid var(--terminal-border)"},children:[l.jsxs("button",{onClick:a,className:"w-full px-3 py-2.5 flex items-center justify-between cursor-pointer transition-colors group",style:{background:"var(--hud-bg-alt)"},children:[l.jsx("span",{className:"text-[11px] font-bold uppercase tracking-wider",style:{color:"var(--terminal-text-secondary)",fontFamily:"var(--pixel-font)"},children:e}),l.jsx("span",{className:"text-[10px] transition-transform",style:{color:"var(--terminal-text-muted)",transform:n?"rotate(0deg)":"rotate(-90deg)"},children:"▼"})]}),n&&l.jsx("div",{className:"px-3 pb-3 pt-2",style:{borderTop:"1px solid var(--terminal-border)"},children:i})]})}function Tg({onSend:e,disabled:n,placeholder:a,color:i}){const[o,u]=w.useState(""),d=w.useRef(!1),f=()=>{const m=o.trim();!m||n||(e(m),u(""))};return l.jsxs("div",{className:"flex items-center gap-1.5 flex-1",children:[l.jsx("input",{type:"text",value:o,onChange:m=>u(m.target.value),onKeyDown:m=>{m.key==="Enter"&&!d.current&&(m.preventDefault(),f())},onCompositionStart:()=>{d.current=!0},onCompositionEnd:()=>{d.current=!1},placeholder:n?"Waiting...":a,disabled:n,className:"flex-1 rounded-lg px-2.5 py-1.5 text-xs focus:outline-none disabled:opacity-40",style:{background:"var(--hud-bg)",border:"1px solid var(--pixel-border)",color:"var(--terminal-text)"}}),l.jsx("button",{onClick:f,disabled:n||!o.trim(),className:"w-7 h-7 rounded-lg flex items-center justify-center shrink-0 cursor-pointer text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",style:{background:n||!o.trim()?"#666":i},children:l.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M22 2L11 13"}),l.jsx("path",{d:"M22 2L15 22L11 13L2 9L22 2Z"})]})})]})}function Ch({label:e,value:n}){return l.jsxs("div",{className:"flex justify-between py-1.5 text-xs",style:{borderBottom:"1px solid var(--terminal-border)"},children:[l.jsx("span",{style:{color:"var(--terminal-text-muted)"},children:e}),l.jsx("span",{className:"font-semibold",style:{color:"var(--terminal-text)"},children:n})]})}function XC(e,n){var a,i=1;e==null&&(e=0),n==null&&(n=0);function o(){var u,d=a.length,f,m=0,h=0;for(u=0;u<d;++u)f=a[u],m+=f.x,h+=f.y;for(m=(m/d-e)*i,h=(h/d-n)*i,u=0;u<d;++u)f=a[u],f.x-=m,f.y-=h}return o.initialize=function(u){a=u},o.x=function(u){return arguments.length?(e=+u,o):e},o.y=function(u){return arguments.length?(n=+u,o):n},o.strength=function(u){return arguments.length?(i=+u,o):i},o}function WC(e){const n=+this._x.call(null,e),a=+this._y.call(null,e);return Wb(this.cover(n,a),n,a,e)}function Wb(e,n,a,i){if(isNaN(n)||isNaN(a))return e;var o,u=e._root,d={data:i},f=e._x0,m=e._y0,h=e._x1,x=e._y1,g,v,b,j,k,N,E,C;if(!u)return e._root=d,e;for(;u.length;)if((k=n>=(g=(f+h)/2))?f=g:h=g,(N=a>=(v=(m+x)/2))?m=v:x=v,o=u,!(u=u[E=N<<1|k]))return o[E]=d,e;if(b=+e._x.call(null,u.data),j=+e._y.call(null,u.data),n===b&&a===j)return d.next=u,o?o[E]=d:e._root=d,e;do o=o?o[E]=new Array(4):e._root=new Array(4),(k=n>=(g=(f+h)/2))?f=g:h=g,(N=a>=(v=(m+x)/2))?m=v:x=v;while((E=N<<1|k)===(C=(j>=v)<<1|b>=g));return o[C]=u,o[E]=d,e}function VC(e){var n,a,i=e.length,o,u,d=new Array(i),f=new Array(i),m=1/0,h=1/0,x=-1/0,g=-1/0;for(a=0;a<i;++a)isNaN(o=+this._x.call(null,n=e[a]))||isNaN(u=+this._y.call(null,n))||(d[a]=o,f[a]=u,o<m&&(m=o),o>x&&(x=o),u<h&&(h=u),u>g&&(g=u));if(m>x||h>g)return this;for(this.cover(m,h).cover(x,g),a=0;a<i;++a)Wb(this,d[a],f[a],e[a]);return this}function GC(e,n){if(isNaN(e=+e)||isNaN(n=+n))return this;var a=this._x0,i=this._y0,o=this._x1,u=this._y1;if(isNaN(a))o=(a=Math.floor(e))+1,u=(i=Math.floor(n))+1;else{for(var d=o-a||1,f=this._root,m,h;a>e||e>=o||i>n||n>=u;)switch(h=(n<i)<<1|e<a,m=new Array(4),m[h]=f,f=m,d*=2,h){case 0:o=a+d,u=i+d;break;case 1:a=o-d,u=i+d;break;case 2:o=a+d,i=u-d;break;case 3:a=o-d,i=u-d;break}this._root&&this._root.length&&(this._root=f)}return this._x0=a,this._y0=i,this._x1=o,this._y1=u,this}function KC(){var e=[];return this.visit(function(n){if(!n.length)do e.push(n.data);while(n=n.next)}),e}function PC(e){return arguments.length?this.cover(+e[0][0],+e[0][1]).cover(+e[1][0],+e[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function ur(e,n,a,i,o){this.node=e,this.x0=n,this.y0=a,this.x1=i,this.y1=o}function QC(e,n,a){var i,o=this._x0,u=this._y0,d,f,m,h,x=this._x1,g=this._y1,v=[],b=this._root,j,k;for(b&&v.push(new ur(b,o,u,x,g)),a==null?a=1/0:(o=e-a,u=n-a,x=e+a,g=n+a,a*=a);j=v.pop();)if(!(!(b=j.node)||(d=j.x0)>x||(f=j.y0)>g||(m=j.x1)<o||(h=j.y1)<u))if(b.length){var N=(d+m)/2,E=(f+h)/2;v.push(new ur(b[3],N,E,m,h),new ur(b[2],d,E,N,h),new ur(b[1],N,f,m,E),new ur(b[0],d,f,N,E)),(k=(n>=E)<<1|e>=N)&&(j=v[v.length-1],v[v.length-1]=v[v.length-1-k],v[v.length-1-k]=j)}else{var C=e-+this._x.call(null,b.data),_=n-+this._y.call(null,b.data),R=C*C+_*_;if(R<a){var L=Math.sqrt(a=R);o=e-L,u=n-L,x=e+L,g=n+L,i=b.data}}return i}function ZC(e){if(isNaN(x=+this._x.call(null,e))||isNaN(g=+this._y.call(null,e)))return this;var n,a=this._root,i,o,u,d=this._x0,f=this._y0,m=this._x1,h=this._y1,x,g,v,b,j,k,N,E;if(!a)return this;if(a.length)for(;;){if((j=x>=(v=(d+m)/2))?d=v:m=v,(k=g>=(b=(f+h)/2))?f=b:h=b,n=a,!(a=a[N=k<<1|j]))return this;if(!a.length)break;(n[N+1&3]||n[N+2&3]||n[N+3&3])&&(i=n,E=N)}for(;a.data!==e;)if(o=a,!(a=a.next))return this;return(u=a.next)&&delete a.next,o?(u?o.next=u:delete o.next,this):n?(u?n[N]=u:delete n[N],(a=n[0]||n[1]||n[2]||n[3])&&a===(n[3]||n[2]||n[1]||n[0])&&!a.length&&(i?i[E]=a:this._root=a),this):(this._root=u,this)}function JC(e){for(var n=0,a=e.length;n<a;++n)this.remove(e[n]);return this}function eE(){return this._root}function tE(){var e=0;return this.visit(function(n){if(!n.length)do++e;while(n=n.next)}),e}function nE(e){var n=[],a,i=this._root,o,u,d,f,m;for(i&&n.push(new ur(i,this._x0,this._y0,this._x1,this._y1));a=n.pop();)if(!e(i=a.node,u=a.x0,d=a.y0,f=a.x1,m=a.y1)&&i.length){var h=(u+f)/2,x=(d+m)/2;(o=i[3])&&n.push(new ur(o,h,x,f,m)),(o=i[2])&&n.push(new ur(o,u,x,h,m)),(o=i[1])&&n.push(new ur(o,h,d,f,x)),(o=i[0])&&n.push(new ur(o,u,d,h,x))}return this}function rE(e){var n=[],a=[],i;for(this._root&&n.push(new ur(this._root,this._x0,this._y0,this._x1,this._y1));i=n.pop();){var o=i.node;if(o.length){var u,d=i.x0,f=i.y0,m=i.x1,h=i.y1,x=(d+m)/2,g=(f+h)/2;(u=o[0])&&n.push(new ur(u,d,f,x,g)),(u=o[1])&&n.push(new ur(u,x,f,m,g)),(u=o[2])&&n.push(new ur(u,d,g,x,h)),(u=o[3])&&n.push(new ur(u,x,g,m,h))}a.push(i)}for(;i=a.pop();)e(i.node,i.x0,i.y0,i.x1,i.y1);return this}function aE(e){return e[0]}function lE(e){return arguments.length?(this._x=e,this):this._x}function iE(e){return e[1]}function sE(e){return arguments.length?(this._y=e,this):this._y}function Wm(e,n,a){var i=new Vm(n??aE,a??iE,NaN,NaN,NaN,NaN);return e==null?i:i.addAll(e)}function Vm(e,n,a,i,o,u){this._x=e,this._y=n,this._x0=a,this._y0=i,this._x1=o,this._y1=u,this._root=void 0}function Fg(e){for(var n={data:e.data},a=n;e=e.next;)a=a.next={data:e.data};return n}var dr=Wm.prototype=Vm.prototype;dr.copy=function(){var e=new Vm(this._x,this._y,this._x0,this._y0,this._x1,this._y1),n=this._root,a,i;if(!n)return e;if(!n.length)return e._root=Fg(n),e;for(a=[{source:n,target:e._root=new Array(4)}];n=a.pop();)for(var o=0;o<4;++o)(i=n.source[o])&&(i.length?a.push({source:i,target:n.target[o]=new Array(4)}):n.target[o]=Fg(i));return e};dr.add=WC;dr.addAll=VC;dr.cover=GC;dr.data=KC;dr.extent=PC;dr.find=QC;dr.remove=ZC;dr.removeAll=JC;dr.root=eE;dr.size=tE;dr.visit=nE;dr.visitAfter=rE;dr.x=lE;dr.y=sE;function Ci(e){return function(){return e}}function Wl(e){return(e()-.5)*1e-6}function oE(e){return e.x+e.vx}function cE(e){return e.y+e.vy}function uE(e){var n,a,i,o=1,u=1;typeof e!="function"&&(e=Ci(e==null?1:+e));function d(){for(var h,x=n.length,g,v,b,j,k,N,E=0;E<u;++E)for(g=Wm(n,oE,cE).visitAfter(f),h=0;h<x;++h)v=n[h],k=a[v.index],N=k*k,b=v.x+v.vx,j=v.y+v.vy,g.visit(C);function C(_,R,L,F,I){var H=_.data,X=_.r,A=k+X;if(H){if(H.index>v.index){var $=b-H.x-H.vx,q=j-H.y-H.vy,W=$*$+q*q;W<A*A&&($===0&&($=Wl(i),W+=$*$),q===0&&(q=Wl(i),W+=q*q),W=(A-(W=Math.sqrt(W)))/W*o,v.vx+=($*=W)*(A=(X*=X)/(N+X)),v.vy+=(q*=W)*A,H.vx-=$*(A=1-A),H.vy-=q*A)}return}return R>b+A||F<b-A||L>j+A||I<j-A}}function f(h){if(h.data)return h.r=a[h.data.index];for(var x=h.r=0;x<4;++x)h[x]&&h[x].r>h.r&&(h.r=h[x].r)}function m(){if(n){var h,x=n.length,g;for(a=new Array(x),h=0;h<x;++h)g=n[h],a[g.index]=+e(g,h,n)}}return d.initialize=function(h,x){n=h,i=x,m()},d.iterations=function(h){return arguments.length?(u=+h,d):u},d.strength=function(h){return arguments.length?(o=+h,d):o},d.radius=function(h){return arguments.length?(e=typeof h=="function"?h:Ci(+h),m(),d):e},d}function dE(e){return e.index}function Mg(e,n){var a=e.get(n);if(!a)throw new Error("node not found: "+n);return a}function fE(e){var n=dE,a=g,i,o=Ci(30),u,d,f,m,h,x=1;e==null&&(e=[]);function g(N){return 1/Math.min(f[N.source.index],f[N.target.index])}function v(N){for(var E=0,C=e.length;E<x;++E)for(var _=0,R,L,F,I,H,X,A;_<C;++_)R=e[_],L=R.source,F=R.target,I=F.x+F.vx-L.x-L.vx||Wl(h),H=F.y+F.vy-L.y-L.vy||Wl(h),X=Math.sqrt(I*I+H*H),X=(X-u[_])/X*N*i[_],I*=X,H*=X,F.vx-=I*(A=m[_]),F.vy-=H*A,L.vx+=I*(A=1-A),L.vy+=H*A}function b(){if(d){var N,E=d.length,C=e.length,_=new Map(d.map((L,F)=>[n(L,F,d),L])),R;for(N=0,f=new Array(E);N<C;++N)R=e[N],R.index=N,typeof R.source!="object"&&(R.source=Mg(_,R.source)),typeof R.target!="object"&&(R.target=Mg(_,R.target)),f[R.source.index]=(f[R.source.index]||0)+1,f[R.target.index]=(f[R.target.index]||0)+1;for(N=0,m=new Array(C);N<C;++N)R=e[N],m[N]=f[R.source.index]/(f[R.source.index]+f[R.target.index]);i=new Array(C),j(),u=new Array(C),k()}}function j(){if(d)for(var N=0,E=e.length;N<E;++N)i[N]=+a(e[N],N,e)}function k(){if(d)for(var N=0,E=e.length;N<E;++N)u[N]=+o(e[N],N,e)}return v.initialize=function(N,E){d=N,h=E,b()},v.links=function(N){return arguments.length?(e=N,b(),v):e},v.id=function(N){return arguments.length?(n=N,v):n},v.iterations=function(N){return arguments.length?(x=+N,v):x},v.strength=function(N){return arguments.length?(a=typeof N=="function"?N:Ci(+N),j(),v):a},v.distance=function(N){return arguments.length?(o=typeof N=="function"?N:Ci(+N),k(),v):o},v}var hE={value:()=>{}};function Vb(){for(var e=0,n=arguments.length,a={},i;e<n;++e){if(!(i=arguments[e]+"")||i in a||/[\s.]/.test(i))throw new Error("illegal type: "+i);a[i]=[]}return new _u(a)}function _u(e){this._=e}function mE(e,n){return e.trim().split(/^|\s+/).map(function(a){var i="",o=a.indexOf(".");if(o>=0&&(i=a.slice(o+1),a=a.slice(0,o)),a&&!n.hasOwnProperty(a))throw new Error("unknown type: "+a);return{type:a,name:i}})}_u.prototype=Vb.prototype={constructor:_u,on:function(e,n){var a=this._,i=mE(e+"",a),o,u=-1,d=i.length;if(arguments.length<2){for(;++u<d;)if((o=(e=i[u]).type)&&(o=pE(a[o],e.name)))return o;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++u<d;)if(o=(e=i[u]).type)a[o]=Rg(a[o],e.name,n);else if(n==null)for(o in a)a[o]=Rg(a[o],e.name,null);return this},copy:function(){var e={},n=this._;for(var a in n)e[a]=n[a].slice();return new _u(e)},call:function(e,n){if((o=arguments.length-2)>0)for(var a=new Array(o),i=0,o,u;i<o;++i)a[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(u=this._[e],i=0,o=u.length;i<o;++i)u[i].value.apply(n,a)},apply:function(e,n,a){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var i=this._[e],o=0,u=i.length;o<u;++o)i[o].value.apply(n,a)}};function pE(e,n){for(var a=0,i=e.length,o;a<i;++a)if((o=e[a]).name===n)return o.value}function Rg(e,n,a){for(var i=0,o=e.length;i<o;++i)if(e[i].name===n){e[i]=hE,e=e.slice(0,i).concat(e.slice(i+1));break}return a!=null&&e.push({name:n,value:a}),e}var vs=0,Mo=0,Ao=0,Gb=1e3,Yu,Ro,Xu=0,Di=0,td=0,Uo=typeof performance=="object"&&performance.now?performance:Date,Kb=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Pb(){return Di||(Kb(xE),Di=Uo.now()+td)}function xE(){Di=0}function im(){this._call=this._time=this._next=null}im.prototype=Qb.prototype={constructor:im,restart:function(e,n,a){if(typeof e!="function")throw new TypeError("callback is not a function");a=(a==null?Pb():+a)+(n==null?0:+n),!this._next&&Ro!==this&&(Ro?Ro._next=this:Yu=this,Ro=this),this._call=e,this._time=a,sm()},stop:function(){this._call&&(this._call=null,this._time=1/0,sm())}};function Qb(e,n,a){var i=new im;return i.restart(e,n,a),i}function gE(){Pb(),++vs;for(var e=Yu,n;e;)(n=Di-e._time)>=0&&e._call.call(void 0,n),e=e._next;--vs}function zg(){Di=(Xu=Uo.now())+td,vs=Mo=0;try{gE()}finally{vs=0,bE(),Di=0}}function yE(){var e=Uo.now(),n=e-Xu;n>Gb&&(td-=n,Xu=e)}function bE(){for(var e,n=Yu,a,i=1/0;n;)n._call?(i>n._time&&(i=n._time),e=n,n=n._next):(a=n._next,n._next=null,n=e?e._next=a:Yu=a);Ro=e,sm(i)}function sm(e){if(!vs){Mo&&(Mo=clearTimeout(Mo));var n=e-Di;n>24?(e<1/0&&(Mo=setTimeout(zg,e-Uo.now()-td)),Ao&&(Ao=clearInterval(Ao))):(Ao||(Xu=Uo.now(),Ao=setInterval(yE,Gb)),vs=1,Kb(zg))}}const vE=1664525,wE=1013904223,_g=4294967296;function kE(){let e=1;return()=>(e=(vE*e+wE)%_g)/_g}function jE(e){return e.x}function SE(e){return e.y}var CE=10,EE=Math.PI*(3-Math.sqrt(5));function NE(e){var n,a=1,i=.001,o=1-Math.pow(i,1/300),u=0,d=.6,f=new Map,m=Qb(g),h=Vb("tick","end"),x=kE();e==null&&(e=[]);function g(){v(),h.call("tick",n),a<i&&(m.stop(),h.call("end",n))}function v(k){var N,E=e.length,C;k===void 0&&(k=1);for(var _=0;_<k;++_)for(a+=(u-a)*o,f.forEach(function(R){R(a)}),N=0;N<E;++N)C=e[N],C.fx==null?C.x+=C.vx*=d:(C.x=C.fx,C.vx=0),C.fy==null?C.y+=C.vy*=d:(C.y=C.fy,C.vy=0);return n}function b(){for(var k=0,N=e.length,E;k<N;++k){if(E=e[k],E.index=k,E.fx!=null&&(E.x=E.fx),E.fy!=null&&(E.y=E.fy),isNaN(E.x)||isNaN(E.y)){var C=CE*Math.sqrt(.5+k),_=k*EE;E.x=C*Math.cos(_),E.y=C*Math.sin(_)}(isNaN(E.vx)||isNaN(E.vy))&&(E.vx=E.vy=0)}}function j(k){return k.initialize&&k.initialize(e,x),k}return b(),n={tick:v,restart:function(){return m.restart(g),n},stop:function(){return m.stop(),n},nodes:function(k){return arguments.length?(e=k,b(),f.forEach(j),n):e},alpha:function(k){return arguments.length?(a=+k,n):a},alphaMin:function(k){return arguments.length?(i=+k,n):i},alphaDecay:function(k){return arguments.length?(o=+k,n):+o},alphaTarget:function(k){return arguments.length?(u=+k,n):u},velocityDecay:function(k){return arguments.length?(d=1-k,n):1-d},randomSource:function(k){return arguments.length?(x=k,f.forEach(j),n):x},force:function(k,N){return arguments.length>1?(N==null?f.delete(k):f.set(k,j(N)),n):f.get(k)},find:function(k,N,E){var C=0,_=e.length,R,L,F,I,H;for(E==null?E=1/0:E*=E,C=0;C<_;++C)I=e[C],R=k-I.x,L=N-I.y,F=R*R+L*L,F<E&&(H=I,E=F);return H},on:function(k,N){return arguments.length>1?(h.on(k,N),n):h.on(k)}}}function AE(){var e,n,a,i,o=Ci(-30),u,d=1,f=1/0,m=.81;function h(b){var j,k=e.length,N=Wm(e,jE,SE).visitAfter(g);for(i=b,j=0;j<k;++j)n=e[j],N.visit(v)}function x(){if(e){var b,j=e.length,k;for(u=new Array(j),b=0;b<j;++b)k=e[b],u[k.index]=+o(k,b,e)}}function g(b){var j=0,k,N,E=0,C,_,R;if(b.length){for(C=_=R=0;R<4;++R)(k=b[R])&&(N=Math.abs(k.value))&&(j+=k.value,E+=N,C+=N*k.x,_+=N*k.y);b.x=C/E,b.y=_/E}else{k=b,k.x=k.data.x,k.y=k.data.y;do j+=u[k.data.index];while(k=k.next)}b.value=j}function v(b,j,k,N){if(!b.value)return!0;var E=b.x-n.x,C=b.y-n.y,_=N-j,R=E*E+C*C;if(_*_/m<R)return R<f&&(E===0&&(E=Wl(a),R+=E*E),C===0&&(C=Wl(a),R+=C*C),R<d&&(R=Math.sqrt(d*R)),n.vx+=E*b.value*i/R,n.vy+=C*b.value*i/R),!0;if(b.length||R>=f)return;(b.data!==n||b.next)&&(E===0&&(E=Wl(a),R+=E*E),C===0&&(C=Wl(a),R+=C*C),R<d&&(R=Math.sqrt(d*R)));do b.data!==n&&(_=u[b.data.index]*i/R,n.vx+=E*_,n.vy+=C*_);while(b=b.next)}return h.initialize=function(b,j){e=b,a=j,x()},h.strength=function(b){return arguments.length?(o=typeof b=="function"?b:Ci(+b),x(),h):o},h.distanceMin=function(b){return arguments.length?(d=b*b,h):Math.sqrt(d)},h.distanceMax=function(b){return arguments.length?(f=b*b,h):Math.sqrt(f)},h.theta=function(b){return arguments.length?(m=b*b,h):Math.sqrt(m)},h}function ll(e){return Array.isArray?Array.isArray(e):ev(e)==="[object Array]"}function DE(e){if(typeof e=="string")return e;let n=e+"";return n=="0"&&1/e==-1/0?"-0":n}function TE(e){return e==null?"":DE(e)}function Ea(e){return typeof e=="string"}function Zb(e){return typeof e=="number"}function FE(e){return e===!0||e===!1||ME(e)&&ev(e)=="[object Boolean]"}function Jb(e){return typeof e=="object"}function ME(e){return Jb(e)&&e!==null}function zr(e){return e!=null}function Eh(e){return!e.trim().length}function ev(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const RE="Incorrect 'index' type",zE=e=>`Invalid value for key ${e}`,_E=e=>`Pattern length exceeds max of ${e}.`,BE=e=>`Missing ${e} property in key`,OE=e=>`Property 'weight' in key '${e}' must be a positive integer`,Bg=Object.prototype.hasOwnProperty;class $E{constructor(n){this._keys=[],this._keyMap={};let a=0;n.forEach(i=>{let o=tv(i);this._keys.push(o),this._keyMap[o.id]=o,a+=o.weight}),this._keys.forEach(i=>{i.weight/=a})}get(n){return this._keyMap[n]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function tv(e){let n=null,a=null,i=null,o=1,u=null;if(Ea(e)||ll(e))i=e,n=Og(e),a=om(e);else{if(!Bg.call(e,"name"))throw new Error(BE("name"));const d=e.name;if(i=d,Bg.call(e,"weight")&&(o=e.weight,o<=0))throw new Error(OE(d));n=Og(d),a=om(d),u=e.getFn}return{path:n,id:a,weight:o,src:i,getFn:u}}function Og(e){return ll(e)?e:e.split(".")}function om(e){return ll(e)?e.join("."):e}function LE(e,n){let a=[],i=!1;const o=(u,d,f)=>{if(zr(u))if(!d[f])a.push(u);else{let m=d[f];const h=u[m];if(!zr(h))return;if(f===d.length-1&&(Ea(h)||Zb(h)||FE(h)))a.push(TE(h));else if(ll(h)){i=!0;for(let x=0,g=h.length;x<g;x+=1)o(h[x],d,f+1)}else d.length&&o(h,d,f+1)}};return o(e,Ea(n)?n.split("."):n,0),i?a:a[0]}const IE={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},HE={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,n)=>e.score===n.score?e.idx<n.idx?-1:1:e.score<n.score?-1:1},UE={location:0,threshold:.6,distance:100},qE={useExtendedSearch:!1,getFn:LE,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var ht={...HE,...IE,...UE,...qE};const YE=/[^ ]+/g;function XE(e=1,n=3){const a=new Map,i=Math.pow(10,n);return{get(o){const u=o.match(YE).length;if(a.has(u))return a.get(u);const d=1/Math.pow(u,.5*e),f=parseFloat(Math.round(d*i)/i);return a.set(u,f),f},clear(){a.clear()}}}class Gm{constructor({getFn:n=ht.getFn,fieldNormWeight:a=ht.fieldNormWeight}={}){this.norm=XE(a,3),this.getFn=n,this.isCreated=!1,this.setIndexRecords()}setSources(n=[]){this.docs=n}setIndexRecords(n=[]){this.records=n}setKeys(n=[]){this.keys=n,this._keysMap={},n.forEach((a,i)=>{this._keysMap[a.id]=i})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,Ea(this.docs[0])?this.docs.forEach((n,a)=>{this._addString(n,a)}):this.docs.forEach((n,a)=>{this._addObject(n,a)}),this.norm.clear())}add(n){const a=this.size();Ea(n)?this._addString(n,a):this._addObject(n,a)}removeAt(n){this.records.splice(n,1);for(let a=n,i=this.size();a<i;a+=1)this.records[a].i-=1}getValueForItemAtKeyId(n,a){return n[this._keysMap[a]]}size(){return this.records.length}_addString(n,a){if(!zr(n)||Eh(n))return;let i={v:n,i:a,n:this.norm.get(n)};this.records.push(i)}_addObject(n,a){let i={i:a,$:{}};this.keys.forEach((o,u)=>{let d=o.getFn?o.getFn(n):this.getFn(n,o.path);if(zr(d)){if(ll(d)){let f=[];const m=[{nestedArrIndex:-1,value:d}];for(;m.length;){const{nestedArrIndex:h,value:x}=m.pop();if(zr(x))if(Ea(x)&&!Eh(x)){let g={v:x,i:h,n:this.norm.get(x)};f.push(g)}else ll(x)&&x.forEach((g,v)=>{m.push({nestedArrIndex:v,value:g})})}i.$[u]=f}else if(Ea(d)&&!Eh(d)){let f={v:d,n:this.norm.get(d)};i.$[u]=f}}}),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function nv(e,n,{getFn:a=ht.getFn,fieldNormWeight:i=ht.fieldNormWeight}={}){const o=new Gm({getFn:a,fieldNormWeight:i});return o.setKeys(e.map(tv)),o.setSources(n),o.create(),o}function WE(e,{getFn:n=ht.getFn,fieldNormWeight:a=ht.fieldNormWeight}={}){const{keys:i,records:o}=e,u=new Gm({getFn:n,fieldNormWeight:a});return u.setKeys(i),u.setIndexRecords(o),u}function wu(e,{errors:n=0,currentLocation:a=0,expectedLocation:i=0,distance:o=ht.distance,ignoreLocation:u=ht.ignoreLocation}={}){const d=n/e.length;if(u)return d;const f=Math.abs(i-a);return o?d+f/o:f?1:d}function VE(e=[],n=ht.minMatchCharLength){let a=[],i=-1,o=-1,u=0;for(let d=e.length;u<d;u+=1){let f=e[u];f&&i===-1?i=u:!f&&i!==-1&&(o=u-1,o-i+1>=n&&a.push([i,o]),i=-1)}return e[u-1]&&u-i>=n&&a.push([i,u-1]),a}const Si=32;function GE(e,n,a,{location:i=ht.location,distance:o=ht.distance,threshold:u=ht.threshold,findAllMatches:d=ht.findAllMatches,minMatchCharLength:f=ht.minMatchCharLength,includeMatches:m=ht.includeMatches,ignoreLocation:h=ht.ignoreLocation}={}){if(n.length>Si)throw new Error(_E(Si));const x=n.length,g=e.length,v=Math.max(0,Math.min(i,g));let b=u,j=v;const k=f>1||m,N=k?Array(g):[];let E;for(;(E=e.indexOf(n,j))>-1;){let I=wu(n,{currentLocation:E,expectedLocation:v,distance:o,ignoreLocation:h});if(b=Math.min(I,b),j=E+x,k){let H=0;for(;H<x;)N[E+H]=1,H+=1}}j=-1;let C=[],_=1,R=x+g;const L=1<<x-1;for(let I=0;I<x;I+=1){let H=0,X=R;for(;H<X;)wu(n,{errors:I,currentLocation:v+X,expectedLocation:v,distance:o,ignoreLocation:h})<=b?H=X:R=X,X=Math.floor((R-H)/2+H);R=X;let A=Math.max(1,v-X+1),$=d?g:Math.min(v+X,g)+x,q=Array($+2);q[$+1]=(1<<I)-1;for(let ie=$;ie>=A;ie-=1){let P=ie-1,Y=a[e.charAt(P)];if(k&&(N[P]=+!!Y),q[ie]=(q[ie+1]<<1|1)&Y,I&&(q[ie]|=(C[ie+1]|C[ie])<<1|1|C[ie+1]),q[ie]&L&&(_=wu(n,{errors:I,currentLocation:P,expectedLocation:v,distance:o,ignoreLocation:h}),_<=b)){if(b=_,j=P,j<=v)break;A=Math.max(1,2*v-j)}}if(wu(n,{errors:I+1,currentLocation:v,expectedLocation:v,distance:o,ignoreLocation:h})>b)break;C=q}const F={isMatch:j>=0,score:Math.max(.001,_)};if(k){const I=VE(N,f);I.length?m&&(F.indices=I):F.isMatch=!1}return F}function KE(e){let n={};for(let a=0,i=e.length;a<i;a+=1){const o=e.charAt(a);n[o]=(n[o]||0)|1<<i-a-1}return n}const Wu=String.prototype.normalize?(e=>e.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(e=>e);class rv{constructor(n,{location:a=ht.location,threshold:i=ht.threshold,distance:o=ht.distance,includeMatches:u=ht.includeMatches,findAllMatches:d=ht.findAllMatches,minMatchCharLength:f=ht.minMatchCharLength,isCaseSensitive:m=ht.isCaseSensitive,ignoreDiacritics:h=ht.ignoreDiacritics,ignoreLocation:x=ht.ignoreLocation}={}){if(this.options={location:a,threshold:i,distance:o,includeMatches:u,findAllMatches:d,minMatchCharLength:f,isCaseSensitive:m,ignoreDiacritics:h,ignoreLocation:x},n=m?n:n.toLowerCase(),n=h?Wu(n):n,this.pattern=n,this.chunks=[],!this.pattern.length)return;const g=(b,j)=>{this.chunks.push({pattern:b,alphabet:KE(b),startIndex:j})},v=this.pattern.length;if(v>Si){let b=0;const j=v%Si,k=v-j;for(;b<k;)g(this.pattern.substr(b,Si),b),b+=Si;if(j){const N=v-Si;g(this.pattern.substr(N),N)}}else g(this.pattern,0)}searchIn(n){const{isCaseSensitive:a,ignoreDiacritics:i,includeMatches:o}=this.options;if(n=a?n:n.toLowerCase(),n=i?Wu(n):n,this.pattern===n){let k={isMatch:!0,score:0};return o&&(k.indices=[[0,n.length-1]]),k}const{location:u,distance:d,threshold:f,findAllMatches:m,minMatchCharLength:h,ignoreLocation:x}=this.options;let g=[],v=0,b=!1;this.chunks.forEach(({pattern:k,alphabet:N,startIndex:E})=>{const{isMatch:C,score:_,indices:R}=GE(n,k,N,{location:u+E,distance:d,threshold:f,findAllMatches:m,minMatchCharLength:h,includeMatches:o,ignoreLocation:x});C&&(b=!0),v+=_,C&&R&&(g=[...g,...R])});let j={isMatch:b,score:b?v/this.chunks.length:1};return b&&o&&(j.indices=g),j}}class Pl{constructor(n){this.pattern=n}static isMultiMatch(n){return $g(n,this.multiRegex)}static isSingleMatch(n){return $g(n,this.singleRegex)}search(){}}function $g(e,n){const a=e.match(n);return a?a[1]:null}class PE extends Pl{constructor(n){super(n)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(n){const a=n===this.pattern;return{isMatch:a,score:a?0:1,indices:[0,this.pattern.length-1]}}}class QE extends Pl{constructor(n){super(n)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(n){const i=n.indexOf(this.pattern)===-1;return{isMatch:i,score:i?0:1,indices:[0,n.length-1]}}}class ZE extends Pl{constructor(n){super(n)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(n){const a=n.startsWith(this.pattern);return{isMatch:a,score:a?0:1,indices:[0,this.pattern.length-1]}}}class JE extends Pl{constructor(n){super(n)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(n){const a=!n.startsWith(this.pattern);return{isMatch:a,score:a?0:1,indices:[0,n.length-1]}}}class eN extends Pl{constructor(n){super(n)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(n){const a=n.endsWith(this.pattern);return{isMatch:a,score:a?0:1,indices:[n.length-this.pattern.length,n.length-1]}}}class tN extends Pl{constructor(n){super(n)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(n){const a=!n.endsWith(this.pattern);return{isMatch:a,score:a?0:1,indices:[0,n.length-1]}}}class av extends Pl{constructor(n,{location:a=ht.location,threshold:i=ht.threshold,distance:o=ht.distance,includeMatches:u=ht.includeMatches,findAllMatches:d=ht.findAllMatches,minMatchCharLength:f=ht.minMatchCharLength,isCaseSensitive:m=ht.isCaseSensitive,ignoreDiacritics:h=ht.ignoreDiacritics,ignoreLocation:x=ht.ignoreLocation}={}){super(n),this._bitapSearch=new rv(n,{location:a,threshold:i,distance:o,includeMatches:u,findAllMatches:d,minMatchCharLength:f,isCaseSensitive:m,ignoreDiacritics:h,ignoreLocation:x})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(n){return this._bitapSearch.searchIn(n)}}class lv extends Pl{constructor(n){super(n)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(n){let a=0,i;const o=[],u=this.pattern.length;for(;(i=n.indexOf(this.pattern,a))>-1;)a=i+u,o.push([i,a-1]);const d=!!o.length;return{isMatch:d,score:d?0:1,indices:o}}}const cm=[PE,lv,ZE,JE,tN,eN,QE,av],Lg=cm.length,nN=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,rN="|";function aN(e,n={}){return e.split(rN).map(a=>{let i=a.trim().split(nN).filter(u=>u&&!!u.trim()),o=[];for(let u=0,d=i.length;u<d;u+=1){const f=i[u];let m=!1,h=-1;for(;!m&&++h<Lg;){const x=cm[h];let g=x.isMultiMatch(f);g&&(o.push(new x(g,n)),m=!0)}if(!m)for(h=-1;++h<Lg;){const x=cm[h];let g=x.isSingleMatch(f);if(g){o.push(new x(g,n));break}}}return o})}const lN=new Set([av.type,lv.type]);class iN{constructor(n,{isCaseSensitive:a=ht.isCaseSensitive,ignoreDiacritics:i=ht.ignoreDiacritics,includeMatches:o=ht.includeMatches,minMatchCharLength:u=ht.minMatchCharLength,ignoreLocation:d=ht.ignoreLocation,findAllMatches:f=ht.findAllMatches,location:m=ht.location,threshold:h=ht.threshold,distance:x=ht.distance}={}){this.query=null,this.options={isCaseSensitive:a,ignoreDiacritics:i,includeMatches:o,minMatchCharLength:u,findAllMatches:f,ignoreLocation:d,location:m,threshold:h,distance:x},n=a?n:n.toLowerCase(),n=i?Wu(n):n,this.pattern=n,this.query=aN(this.pattern,this.options)}static condition(n,a){return a.useExtendedSearch}searchIn(n){const a=this.query;if(!a)return{isMatch:!1,score:1};const{includeMatches:i,isCaseSensitive:o,ignoreDiacritics:u}=this.options;n=o?n:n.toLowerCase(),n=u?Wu(n):n;let d=0,f=[],m=0;for(let h=0,x=a.length;h<x;h+=1){const g=a[h];f.length=0,d=0;for(let v=0,b=g.length;v<b;v+=1){const j=g[v],{isMatch:k,indices:N,score:E}=j.search(n);if(k){if(d+=1,m+=E,i){const C=j.constructor.type;lN.has(C)?f=[...f,...N]:f.push(N)}}else{m=0,d=0,f.length=0;break}}if(d){let v={isMatch:!0,score:m/d};return i&&(v.indices=f),v}}return{isMatch:!1,score:1}}}const um=[];function sN(...e){um.push(...e)}function dm(e,n){for(let a=0,i=um.length;a<i;a+=1){let o=um[a];if(o.condition(e,n))return new o(e,n)}return new rv(e,n)}const Vu={AND:"$and",OR:"$or"},fm={PATH:"$path",PATTERN:"$val"},hm=e=>!!(e[Vu.AND]||e[Vu.OR]),oN=e=>!!e[fm.PATH],cN=e=>!ll(e)&&Jb(e)&&!hm(e),Ig=e=>({[Vu.AND]:Object.keys(e).map(n=>({[n]:e[n]}))});function iv(e,n,{auto:a=!0}={}){const i=o=>{let u=Object.keys(o);const d=oN(o);if(!d&&u.length>1&&!hm(o))return i(Ig(o));if(cN(o)){const m=d?o[fm.PATH]:u[0],h=d?o[fm.PATTERN]:o[m];if(!Ea(h))throw new Error(zE(m));const x={keyId:om(m),pattern:h};return a&&(x.searcher=dm(h,n)),x}let f={children:[],operator:u[0]};return u.forEach(m=>{const h=o[m];ll(h)&&h.forEach(x=>{f.children.push(i(x))})}),f};return hm(e)||(e=Ig(e)),i(e)}function uN(e,{ignoreFieldNorm:n=ht.ignoreFieldNorm}){e.forEach(a=>{let i=1;a.matches.forEach(({key:o,norm:u,score:d})=>{const f=o?o.weight:null;i*=Math.pow(d===0&&f?Number.EPSILON:d,(f||1)*(n?1:u))}),a.score=i})}function dN(e,n){const a=e.matches;n.matches=[],zr(a)&&a.forEach(i=>{if(!zr(i.indices)||!i.indices.length)return;const{indices:o,value:u}=i;let d={indices:o,value:u};i.key&&(d.key=i.key.src),i.idx>-1&&(d.refIndex=i.idx),n.matches.push(d)})}function fN(e,n){n.score=e.score}function hN(e,n,{includeMatches:a=ht.includeMatches,includeScore:i=ht.includeScore}={}){const o=[];return a&&o.push(dN),i&&o.push(fN),e.map(u=>{const{idx:d}=u,f={item:n[d],refIndex:d};return o.length&&o.forEach(m=>{m(u,f)}),f})}class Ns{constructor(n,a={},i){this.options={...ht,...a},this.options.useExtendedSearch,this._keyStore=new $E(this.options.keys),this.setCollection(n,i)}setCollection(n,a){if(this._docs=n,a&&!(a instanceof Gm))throw new Error(RE);this._myIndex=a||nv(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(n){zr(n)&&(this._docs.push(n),this._myIndex.add(n))}remove(n=()=>!1){const a=[];for(let i=0,o=this._docs.length;i<o;i+=1){const u=this._docs[i];n(u,i)&&(this.removeAt(i),i-=1,o-=1,a.push(u))}return a}removeAt(n){this._docs.splice(n,1),this._myIndex.removeAt(n)}getIndex(){return this._myIndex}search(n,{limit:a=-1}={}){const{includeMatches:i,includeScore:o,shouldSort:u,sortFn:d,ignoreFieldNorm:f}=this.options;let m=Ea(n)?Ea(this._docs[0])?this._searchStringList(n):this._searchObjectList(n):this._searchLogical(n);return uN(m,{ignoreFieldNorm:f}),u&&m.sort(d),Zb(a)&&a>-1&&(m=m.slice(0,a)),hN(m,this._docs,{includeMatches:i,includeScore:o})}_searchStringList(n){const a=dm(n,this.options),{records:i}=this._myIndex,o=[];return i.forEach(({v:u,i:d,n:f})=>{if(!zr(u))return;const{isMatch:m,score:h,indices:x}=a.searchIn(u);m&&o.push({item:u,idx:d,matches:[{score:h,value:u,norm:f,indices:x}]})}),o}_searchLogical(n){const a=iv(n,this.options),i=(f,m,h)=>{if(!f.children){const{keyId:g,searcher:v}=f,b=this._findMatches({key:this._keyStore.get(g),value:this._myIndex.getValueForItemAtKeyId(m,g),searcher:v});return b&&b.length?[{idx:h,item:m,matches:b}]:[]}const x=[];for(let g=0,v=f.children.length;g<v;g+=1){const b=f.children[g],j=i(b,m,h);if(j.length)x.push(...j);else if(f.operator===Vu.AND)return[]}return x},o=this._myIndex.records,u={},d=[];return o.forEach(({$:f,i:m})=>{if(zr(f)){let h=i(a,f,m);h.length&&(u[m]||(u[m]={idx:m,item:f,matches:[]},d.push(u[m])),h.forEach(({matches:x})=>{u[m].matches.push(...x)}))}}),d}_searchObjectList(n){const a=dm(n,this.options),{keys:i,records:o}=this._myIndex,u=[];return o.forEach(({$:d,i:f})=>{if(!zr(d))return;let m=[];i.forEach((h,x)=>{m.push(...this._findMatches({key:h,value:d[x],searcher:a}))}),m.length&&u.push({idx:f,item:d,matches:m})}),u}_findMatches({key:n,value:a,searcher:i}){if(!zr(a))return[];let o=[];if(ll(a))a.forEach(({v:u,i:d,n:f})=>{if(!zr(u))return;const{isMatch:m,score:h,indices:x}=i.searchIn(u);m&&o.push({score:h,key:n,value:u,idx:d,norm:f,indices:x})});else{const{v:u,n:d}=a,{isMatch:f,score:m,indices:h}=i.searchIn(u);f&&o.push({score:m,key:n,value:u,norm:d,indices:h})}return o}}Ns.version="7.1.0";Ns.createIndex=nv;Ns.parseIndex=WE;Ns.config=ht;Ns.parseQuery=iv;sN(iN);const ia={tech:{bg:"rgba(59,130,246,0.15)",border:"#3b82f6",text:"#60a5fa"},market:{bg:"rgba(245,158,11,0.15)",border:"#f59e0b",text:"#fbbf24"},strategy:{bg:"rgba(139,92,246,0.15)",border:"#8b5cf6",text:"#a78bfa"},financial:{bg:"rgba(34,197,94,0.15)",border:"#22c55e",text:"#4ade80"},process:{bg:"rgba(236,72,153,0.15)",border:"#ec4899",text:"#f472b6"},competitor:{bg:"rgba(239,68,68,0.15)",border:"#ef4444",text:"#f87171"},domain:{bg:"rgba(14,165,233,0.15)",border:"#0ea5e9",text:"#38bdf8"},general:{bg:"rgba(148,163,184,0.12)",border:"#64748b",text:"#94a3b8"}};function mN(e){return ia[e]??ia.general}function pN(e){return e>1600?"macro":e<800?"micro":"standard"}function xN(e){const n=new Map;for(const i of e){const o=i.category||"general";n.has(o)||n.set(o,[]),n.get(o).push(i)}const a=[];for(const[i,o]of n){let u=0,d=0;for(const m of o)u+=m.x??0,d+=m.y??0;const f=o.length;a.push({domain:i,count:f,centerX:u/f,centerY:d/f,nodes:o})}return a}function gN(e,n=60){if(!e)return"";const a=e.match(/^[^.!?]+[.!?]/),i=a?a[0]:e;return i.length>n?i.slice(0,n-2)+"..":i}function yN(e,n,a){const i=[...new Set(a.map(m=>m.category||"general"))],o=new Map,u=e/2,d=n/2,f=Math.min(e,n)*.3;return i.forEach((m,h)=>{const x=2*Math.PI*h/i.length-Math.PI/2;o.set(m,{x:u+f*Math.cos(x),y:d+f*Math.sin(x)})}),o}function bN(e,n=.12){let a;function i(o){for(const u of a){const d=e.get(u.category)||e.get("general");d&&u.x!==void 0&&u.y!==void 0&&(u.vx=(u.vx||0)+(d.x-u.x)*o*n,u.vy=(u.vy||0)+(d.y-u.y)*o*n)}}return i.initialize=function(o){a=o},i}function vN(e){return e.map(n=>{let a=0;for(const o of n.nodes){const u=(o.x??0)-n.centerX,d=(o.y??0)-n.centerY,f=Math.sqrt(u*u+d*d);f>a&&(a=f)}const i=Math.max(40,n.count*8);return{...n,radius:a+i}})}function wN(e,n,a,i){if(!e)return a;const o=new Set([e]),u=new Set;let d=new Set([e]);for(let f=0;f<i;f++){const m=new Set;for(const h of d)if(!u.has(h)){u.add(h);for(const x of n){const g=typeof x.source=="string"?x.source:x.source.id,v=typeof x.target=="string"?x.target:x.target.id;g===h&&!o.has(v)&&(o.add(v),m.add(v)),v===h&&!o.has(g)&&(o.add(g),m.add(g))}}d=m}return o}function kN({docs:e,onNodeClick:n,selectedDocId:a,matchedIds:i,localGraphMode:o,onLocalModeChange:u}){var de;const d=w.useRef(null),f=w.useRef(null),[m,h]=w.useState({width:600,height:400}),[x,g]=w.useState({nodes:[],links:[]}),[v,b]=w.useState(null),[j,k]=w.useState(null),[N,E]=w.useState({x:0,y:0}),[C,_]=w.useState({x:0,y:0,w:600,h:400}),R=w.useRef(!1),L=w.useRef({x:0,y:0,vx:0,vy:0}),F=w.useRef(null),I=w.useRef(null),H=w.useMemo(()=>pN(C.w),[C.w]),X=w.useMemo(()=>xN(x.nodes),[x.nodes]),A=w.useMemo(()=>vN(X),[X]),$=w.useMemo(()=>{if(o==="global"||!a)return null;const G=new Set(x.nodes.map(B=>B.id)),D=o==="1-hop"?1:2;return wN(a,x.links,G,D)},[o,a,x.nodes,x.links]);w.useEffect(()=>{const G=d.current;if(!G)return;const D=new ResizeObserver(B=>{const{width:U,height:T}=B[0].contentRect;U>0&&T>0&&(h({width:U,height:T}),_(se=>({...se,w:U,h:T})))});return D.observe(G),()=>D.disconnect()},[]),w.useEffect(()=>{if(e.length===0)return;const G=new Set(e.map(Ae=>Ae.id)),D=e.map(Ae=>({id:Ae.id,title:Ae.title,category:Ae.category,akb_type:Ae.akb_type,tldr:Ae.tldr,tags:Ae.tags})),B=(Ae,yt)=>{if(!yt.startsWith(".")&&!yt.startsWith("/"))return yt;const dt=Ae.split("/");dt.pop();const xt=yt.split("/");for(const jt of xt)jt===".."?dt.pop():jt!=="."&&jt!==""&&dt.push(jt);return dt.join("/")},U=[];for(const Ae of e)for(const yt of Ae.links){const dt=B(Ae.id,yt.href);G.has(dt)&&dt!==Ae.id&&(U.some(xt=>xt.source===Ae.id&&xt.target===dt||xt.source===dt&&xt.target===Ae.id)||U.push({source:Ae.id,target:dt,label:yt.text}))}const{width:T,height:se}=m,ge=D.length,pe=ge>100?-600:ge>50?-500:-400,Re=ge>100?180:ge>50?160:140,Ie=ge>100?60:50,He=Math.max(T,ge*12),ot=Math.max(se,ge*10),Je=yN(He,ot,D),tt=NE(D).force("link",fE(U).id(Ae=>Ae.id).distance(Re)).force("charge",AE().strength(pe)).force("center",XC(He/2,ot/2)).force("collide",uE(Ie)).force("cluster",bN(Je,.15));I.current=tt,tt.on("tick",()=>{g({nodes:[...D],links:[...U]})}),tt.alpha(1).restart();const Ee=ge>100?300:150;for(let Ae=0;Ae<Ee;Ae++)tt.tick();if(tt.stop(),g({nodes:[...D],links:[...U]}),D.length>0){let Ae=1/0,yt=1/0,dt=-1/0,xt=-1/0;for(const Wt of D){const Tt=Wt.x??0,Ct=Wt.y??0;Tt<Ae&&(Ae=Tt),Ct<yt&&(yt=Ct),Tt>dt&&(dt=Tt),Ct>xt&&(xt=Ct)}const jt=100;_({x:Ae-jt,y:yt-jt,w:Math.max(T,dt-Ae+jt*2),h:Math.max(se,xt-yt+jt*2)})}return()=>{tt.stop()}},[e,m]);const q=G=>{if(typeof G=="string"){const D=x.nodes.find(B=>B.id===G);return{x:(D==null?void 0:D.x)??0,y:(D==null?void 0:D.y)??0}}return{x:G.x??0,y:G.y??0}},W=w.useCallback(G=>{G.preventDefault();const D=G.deltaY>0?1.1:.9;_(B=>{const U=Math.max(200,Math.min(m.width*3,B.w*D)),T=Math.max(150,Math.min(m.height*3,B.h*D)),se=(U-B.w)/2,ge=(T-B.h)/2;return{x:B.x-se,y:B.y-ge,w:U,h:T}})},[m]),ie=w.useCallback(G=>{G.button===0&&(R.current=!0,L.current={x:G.clientX,y:G.clientY,vx:C.x,vy:C.y})},[C]),P=w.useCallback(G=>{var D;if(F.current){const B=f.current;if(!B)return;const U=B.getBoundingClientRect(),T=C.w/U.width,se=C.h/U.height,ge=C.x+(G.clientX-U.left)*T,pe=C.y+(G.clientY-U.top)*se;F.current.fx=ge,F.current.fy=pe,(D=I.current)==null||D.alpha(.3).restart();return}if(R.current){const B=(G.clientX-L.current.x)*(C.w/m.width),U=(G.clientY-L.current.y)*(C.h/m.height);_(T=>({...T,x:L.current.vx-B,y:L.current.vy-U}))}},[C,m]),Y=w.useCallback(()=>{R.current=!1,F.current&&(F.current.fx=null,F.current.fy=null,F.current=null)},[]),oe=w.useCallback((G,D)=>{var B;G.stopPropagation(),F.current=D,(B=I.current)==null||B.alpha(.3).restart()},[]);return l.jsxs("div",{ref:d,className:"relative flex-1 overflow-hidden",style:{background:"#1e1e2e"},children:[l.jsxs("svg",{ref:f,width:m.width,height:m.height,viewBox:`${C.x} ${C.y} ${C.w} ${C.h}`,style:{display:"block",cursor:R.current?"grabbing":"grab"},onWheel:W,onMouseDown:ie,onMouseMove:P,onMouseUp:Y,onMouseLeave:Y,children:[l.jsx("defs",{children:l.jsx("pattern",{id:"grid",width:"20",height:"20",patternUnits:"userSpaceOnUse",children:l.jsx("circle",{cx:"0",cy:"0",r:"0.5",fill:"rgba(255,255,255,0.06)"})})}),l.jsx("rect",{x:C.x-100,y:C.y-100,width:C.w+200,height:C.h+200,fill:"url(#grid)",pointerEvents:"none"}),H==="macro"&&l.jsx("g",{className:"macro-clusters",style:{transition:"opacity 0.3s ease"},children:X.map(G=>{const D=ia[G.domain]??ia.general,B=Math.max(40,Math.sqrt(G.count)*25),T=i===null||G.nodes.some(se=>i.has(se.id))?1:.4;return l.jsxs("g",{transform:`translate(${G.centerX}, ${G.centerY})`,style:{cursor:"pointer",opacity:T,transition:"opacity 0.3s ease"},onMouseEnter:se=>{var pe;const ge=(pe=d.current)==null?void 0:pe.getBoundingClientRect();ge&&E({x:se.clientX-ge.left,y:se.clientY-ge.top}),b({id:`cluster-${G.domain}`,title:`${G.domain} (${G.count})`,category:G.domain,akb_type:"hub"})},onMouseLeave:()=>b(null),children:[l.jsx("circle",{r:B,fill:D.bg,stroke:D.border,strokeWidth:3,opacity:.8}),l.jsx("text",{textAnchor:"middle",dominantBaseline:"middle",fill:D.text,fontSize:16,fontFamily:"monospace",fontWeight:"bold",style:{pointerEvents:"none"},children:G.domain}),l.jsxs("text",{y:20,textAnchor:"middle",dominantBaseline:"middle",fill:D.text,fontSize:12,fontFamily:"monospace",opacity:.8,style:{pointerEvents:"none"},children:["(",G.count,")"]})]},G.domain)})}),H!=="macro"&&l.jsxs(l.Fragment,{children:[H==="standard"&&A.map(G=>{const D=ia[G.domain]??ia.general;if(G.count<2)return null;const B=i===null||G.nodes.some(T=>i.has(T.id)),U=B?.08:.04;return l.jsxs("g",{children:[l.jsx("circle",{cx:G.centerX,cy:G.centerY,r:G.radius,fill:D.bg,stroke:D.border,strokeWidth:1,strokeDasharray:"6 4",opacity:U,style:{transition:"opacity 0.3s ease"},pointerEvents:"none"}),l.jsxs("text",{x:G.centerX,y:G.centerY-G.radius-8,textAnchor:"middle",fill:D.text,fontSize:12,fontFamily:"monospace",fontWeight:"600",opacity:B?.85:.5,style:{pointerEvents:"none",transition:"opacity 0.3s ease"},children:[G.domain," (",G.count,")"]})]},`cluster-bg-${G.domain}`)}),x.links.map((G,D)=>{const B=q(G.source),U=q(G.target),T=j===D,se=(B.x+U.x)/2,ge=(B.y+U.y)/2,pe=typeof G.source=="string"?G.source:G.source.id,Re=typeof G.target=="string"?G.target:G.target.id,He=$===null||$.has(pe)&&$.has(Re)?1:.4;return l.jsxs("g",{style:{opacity:He,transition:"opacity 0.3s ease"},children:[l.jsx("line",{x1:B.x,y1:B.y,x2:U.x,y2:U.y,stroke:"transparent",strokeWidth:12,style:{cursor:"default"},onMouseEnter:()=>k(D),onMouseLeave:()=>k(null)}),l.jsx("line",{x1:B.x,y1:B.y,x2:U.x,y2:U.y,stroke:T?"rgba(148,163,184,0.7)":"rgba(148,163,184,0.6)",strokeWidth:T?2:1.5,strokeDasharray:"4 3",pointerEvents:"none"}),T&&G.label&&l.jsx("text",{x:se,y:ge-6,textAnchor:"middle",fill:"#e2e8f0",fontSize:9,fontFamily:"monospace",style:{pointerEvents:"none"},children:l.jsx("tspan",{style:{filter:"drop-shadow(0 0 2px rgba(0,0,0,0.8))"},children:G.label.length>30?G.label.slice(0,28)+"..":G.label})})]},D)}),x.nodes.map(G=>{const D=ia[G.category]??ia.general,B=G.akb_type==="hub",U=B?24:16,T=H==="micro"?U*1.5:U,se=(v==null?void 0:v.id)===G.id,ge=a===G.id,pe=se?1.1:ge?1.05:1,Re=i===null||i.has(G.id),Ie=$===null||$.has(G.id),He=Re&&Ie?1:.35,ot=H==="micro"?gN(G.tldr,50):"",Je=H==="micro"&&G.tags?G.tags.slice(0,3):[];return l.jsxs("g",{transform:`translate(${G.x??0}, ${G.y??0}) scale(${pe})`,style:{cursor:"pointer",transition:"transform 0.2s ease, opacity 0.3s ease",opacity:He},onClick:tt=>{tt.stopPropagation();const Ee=e.find(Ae=>Ae.id===G.id);Ee&&n(Ee)},onMouseDown:tt=>oe(tt,G),onMouseEnter:tt=>{var Ae;b(G);const Ee=(Ae=d.current)==null?void 0:Ae.getBoundingClientRect();Ee&&E({x:tt.clientX-Ee.left,y:tt.clientY-Ee.top})},onMouseLeave:()=>b(null),children:[ge&&l.jsx("rect",{x:-T/2-4,y:-T/2-4,width:T+8,height:T+8,fill:"none",stroke:"#22c55e",strokeWidth:2,rx:B?5:2,opacity:.6}),l.jsx("rect",{x:-T/2,y:-T/2,width:T,height:T,fill:D.border,rx:B?4:2,opacity:se?1:.9}),l.jsx("rect",{x:-T/2+3,y:-T/2+3,width:Math.max(0,T-6),height:Math.max(0,T-6),fill:D.bg,rx:B?3:1}),l.jsx("text",{y:T/2+14,textAnchor:"middle",fill:ge?"#e2e8f0":"#94a3b8",fontSize:H==="micro"?10:11,fontFamily:"monospace",fontWeight:ge?"bold":"normal",style:{pointerEvents:"none"},children:G.title.length>24?G.title.slice(0,22)+"..":G.title}),H==="micro"&&ot&&l.jsx("text",{y:T/2+28,textAnchor:"middle",fill:"#94a3b8",fontSize:8,fontFamily:"system-ui, sans-serif",opacity:.7,style:{pointerEvents:"none"},children:ot}),H==="micro"&&Je.length>0&&l.jsx("g",{transform:`translate(0, ${T/2+(ot?42:28)})`,children:Je.map((tt,Ee)=>{const Ae=tt.length*5+8;let dt=-Je.reduce((xt,jt)=>xt+jt.length*5+10,0)/2;for(let xt=0;xt<Ee;xt++)dt+=Je[xt].length*5+10;return l.jsxs("g",{transform:`translate(${dt+Ae/2}, 0)`,children:[l.jsx("rect",{x:-Ae/2,y:-6,width:Ae,height:12,fill:D.bg,stroke:D.border,strokeWidth:.5,rx:3}),l.jsx("text",{textAnchor:"middle",dominantBaseline:"middle",fill:D.text,fontSize:7,fontFamily:"monospace",style:{pointerEvents:"none"},children:tt})]},tt)})})]},G.id)})]})]}),v&&!F.current&&l.jsxs("div",{className:"absolute z-10 pointer-events-none p-2.5 rounded text-xs max-w-[240px]",style:{left:Math.min(N.x+16,m.width-250),top:Math.max(N.y-30,8),background:"var(--hud-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)",boxShadow:"0 4px 12px rgba(0,0,0,0.4)"},children:[l.jsx("div",{className:"font-bold mb-1",children:v.title}),l.jsxs("div",{className:"text-[10px] opacity-60 mb-1",children:[v.akb_type.toUpperCase()," / ",v.category]}),v.id.startsWith("cluster-")?l.jsx("div",{className:"text-[10px] text-green-400",children:"Zoom in to see documents"}):l.jsxs(l.Fragment,{children:[((de=e.find(G=>G.id===v.id))==null?void 0:de.tldr)&&l.jsx("div",{className:"text-[10px] opacity-80 mb-1",children:e.find(G=>G.id===v.id).tldr}),l.jsx("div",{className:"text-[10px] text-green-400",children:"Click to open | Drag to move"})]})]}),l.jsxs("div",{className:"absolute bottom-3 left-3 px-2 py-1 rounded text-[10px] font-mono",style:{background:"var(--hud-bg)",border:"1px solid var(--terminal-border)",color:H==="macro"?"#f59e0b":H==="micro"?"#22c55e":"#94a3b8",transition:"color 0.3s ease"},children:[H==="macro"&&"📍 Overview",H==="standard"&&"📍 Standard",H==="micro"&&"📍 Detail"]}),l.jsx("div",{className:"absolute bottom-3 right-3 flex gap-1 rounded overflow-hidden",style:{background:"var(--hud-bg)",border:"1px solid var(--terminal-border)"},children:["global","1-hop","2-hop"].map(G=>{const D=o===G,B=G!=="global"&&!a,U=G==="global"?"🌐 All":G==="1-hop"?"1-hop":"2-hop";return l.jsx("button",{onClick:()=>!B&&u(G),disabled:B,className:"px-2 py-1 text-[10px] font-medium cursor-pointer transition-all",style:{background:D?"rgba(22,163,106,0.3)":"transparent",color:B?"var(--terminal-text-muted)":D?"#4ade80":"var(--terminal-text-secondary)",opacity:B?.4:1,cursor:B?"not-allowed":"pointer"},title:B?"Select a node first":`Show ${G==="global"?"all nodes":`nodes within ${G}`}`,children:U},G)})}),e.length===0&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-xs",style:{color:"var(--terminal-text-muted)"},children:"No knowledge documents found"})]})}function jN(e){const n=[],a=new Map;return[...e].sort((o,u)=>o.id.localeCompare(u.id)).forEach(o=>{const u=o.id.split("/");let d=n,f="";for(let m=0;m<u.length-1;m++)if(f=f?`${f}/${u[m]}`:u[m],a.has(f))d=a.get(f).children;else{const h={type:"folder",name:u[m],path:f,children:[]};a.set(f,h),d.push(h),d=h.children}d.push({type:"file",name:u[u.length-1],path:o.id,doc:o})}),n}function SN({docs:e,onDocumentClick:n,selectedDocId:a,matchedIds:i}){const[o,u]=w.useState(new Set(["knowledge","projects","architecture","operations","company"])),[d,f]=w.useState(null),[m,h]=w.useState([]),[x,g]=w.useState(-1),v=w.useMemo(()=>jN(e),[e]),b=L=>{u(F=>{const I=new Set(F);return I.has(L)?I.delete(L):I.add(L),I})},j=L=>{f(L),n(L);const F=m.slice(0,x+1);F.push(L),F.length>10&&F.shift(),h(F),g(F.length-1)},k=()=>{f(null),n(null)},N=()=>{if(x>0){const L=x-1;g(L),f(m[L]),n(m[L])}},E=()=>{if(x<m.length-1){const L=x+1;g(L),f(m[L]),n(m[L])}},C=L=>{const F=m.indexOf(L);F!==-1&&(g(F),f(L),n(L))},_=L=>{L==="hub"&&k()},R=d?e.find(L=>L.id===d):null;return l.jsxs("div",{className:"flex-1 overflow-hidden flex animate-fadeIn",children:[l.jsxs("div",{className:"shrink-0 overflow-y-auto p-3",style:{width:220,background:"var(--hud-bg-alt)",borderRight:"1px solid var(--terminal-border)"},children:[l.jsx("div",{className:"text-[10px] font-bold uppercase mb-2",style:{color:"var(--terminal-text-muted)"},children:"📂 Explorer"}),v.map(L=>l.jsx(sv,{node:L,level:0,expandedFolders:o,selectedDocId:a,viewingDocId:d,onToggleFolder:b,onFileClick:j,matchedIds:i},L.path))]}),l.jsx("div",{className:"flex-1 overflow-y-auto",children:R?l.jsx(EN,{doc:R,onClose:k,onBreadcrumbClick:_,history:m,historyIndex:x,onHistoryBack:N,onHistoryForward:E,onHistoryJump:C,allDocs:e}):l.jsx("div",{className:"flex items-center justify-center h-full text-xs",style:{color:"var(--terminal-text-muted)"},children:l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"text-2xl mb-2",children:"📄"}),l.jsx("div",{children:"Select a document to view"})]})})})]})}function sv({node:e,level:n,expandedFolders:a,selectedDocId:i,viewingDocId:o,onToggleFolder:u,onFileClick:d,matchedIds:f}){var b,j,k;const m=a.has(e.path),h=e.type==="file"&&e.path===i,x=e.type==="file"&&e.path===o,g=((b=e.doc)==null?void 0:b.akb_type)==="hub",v=e.type==="folder"||f===null||f.has(e.path);if(e.type==="folder"){const N=f===null||(((j=e.children)==null?void 0:j.some(E=>{if(E.type==="file")return f.has(E.path);const C=_=>{var R;return _.type==="file"?f.has(_.path):((R=_.children)==null?void 0:R.some(C))??!1};return C(E)}))??!1);return l.jsxs("div",{style:{opacity:N?1:.5,transition:"opacity 0.2s ease"},children:[l.jsxs("div",{className:"flex items-center gap-1 py-0.5 px-1 rounded cursor-pointer hover:bg-white/5",style:{paddingLeft:n*12+4},onClick:()=>u(e.path),children:[l.jsx("span",{className:"text-[10px]",children:m?"📂":"📁"}),l.jsx("span",{className:"text-[11px]",style:{color:"var(--terminal-text)"},children:e.name})]}),m&&((k=e.children)==null?void 0:k.map(E=>l.jsx(sv,{node:E,level:n+1,expandedFolders:a,selectedDocId:i,viewingDocId:o,onToggleFolder:u,onFileClick:d,matchedIds:f},E.path)))]})}return l.jsxs("div",{className:`flex items-center gap-1 py-0.5 px-1 rounded cursor-pointer transition-colors ${x?"bg-green-500/20":h?"bg-white/10":"hover:bg-white/5"}`,style:{paddingLeft:n*12+4,opacity:v?1:.45,transition:"opacity 0.2s ease"},onClick:()=>d(e.path),children:[l.jsx("span",{className:"text-[10px]",children:g?"📘":"📄"}),l.jsx("span",{className:`text-[11px] truncate ${g?"font-semibold":""}`,style:{color:g?"#16a34a":"var(--terminal-text)"},children:e.name})]})}function CN(e){const n=e.split(`
|
|
82
|
+
`),a=[],i=new Map;for(const o of n){const u=o.match(/^(#{2,3})\s+(.+)$/);if(!u)continue;const d=u[1].length,f=u[2].trim();let m=f.toLowerCase().replace(/[^a-z0-9가-힣\s-]/g,"").replace(/\s+/g,"-").slice(0,50);const h=i.get(m)||0;i.set(m,h+1);const x=h>0?`${m}-${h}`:m;a.push({id:x,text:f,level:d})}return a}function EN({doc:e,onClose:n,onBreadcrumbClick:a,history:i,historyIndex:o,onHistoryBack:u,onHistoryForward:d,onHistoryJump:f,allDocs:m}){const[h,x]=w.useState(null),[g,v]=w.useState(!1),[b,j]=w.useState(null),k=w.useRef(null),[N,E]=w.useState(null);w.useEffect(()=>{if("content"in e&&e.content){x(e);return}v(!0),j(null),ye.getKnowledgeDoc(e.id).then(x).catch(A=>j(A instanceof Error?A.message:"Failed to load")).finally(()=>v(!1))},[e]);const C=w.useMemo(()=>!h||e.format==="html"?[]:CN(h.content),[h,e.format]),_=A=>{if(!k.current)return;const $=k.current.querySelectorAll("h2, h3");for(const q of $){const ie=(q.textContent||"").toLowerCase().replace(/[^a-z0-9가-힣\s-]/g,"").replace(/\s+/g,"-").slice(0,50);if(A.startsWith(ie)){q.scrollIntoView({behavior:"smooth",block:"start"}),E(A);break}}},R=mN(e.category),L=e.akb_type==="hub",F=C.length>0&&!g&&!b,I=i.slice(0,o).reverse().filter(A=>A!==e.id).slice(0,3).map(A=>m.find($=>$.id===A)).filter(A=>A!==void 0),H=o>0,X=o<i.length-1;return l.jsxs("div",{className:"h-full flex flex-col",children:[l.jsxs("div",{className:"shrink-0 p-4",style:{borderBottom:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[l.jsx("button",{onClick:u,disabled:!H,className:"text-xs font-semibold cursor-pointer hover:opacity-70 disabled:opacity-30 disabled:cursor-not-allowed",style:{color:"var(--active-green)"},title:"Back",children:"←"}),l.jsx("button",{onClick:d,disabled:!X,className:"text-xs font-semibold cursor-pointer hover:opacity-70 disabled:opacity-30 disabled:cursor-not-allowed",style:{color:"var(--active-green)"},title:"Forward",children:"→"}),l.jsx("div",{className:"flex-1 flex items-center gap-1 overflow-x-auto",children:I.map(A=>l.jsxs("button",{onClick:()=>f(A.id),className:"px-2 py-0.5 rounded text-[9px] hover:opacity-70 cursor-pointer whitespace-nowrap",style:{background:"var(--hud-bg)",color:"var(--terminal-text-secondary)"},title:A.title,children:["📄 ",A.title.length>15?A.title.slice(0,15)+"...":A.title]},A.id))})]}),l.jsxs("div",{className:"flex items-center gap-1 mb-2 text-[10px]",style:{color:"var(--terminal-text-muted)"},children:[l.jsx("button",{onClick:()=>a("hub"),className:"hover:underline cursor-pointer",style:{color:"var(--active-green)"},children:"Knowledge Hub"}),l.jsx("span",{children:"›"}),l.jsx("span",{style:{color:R.text},children:e.category}),l.jsx("span",{children:"›"}),l.jsx("span",{style:{color:"var(--terminal-text)"},children:e.title})]}),l.jsx("div",{className:"flex items-center gap-2 mb-2",children:l.jsxs("button",{onClick:n,className:"text-xs font-semibold cursor-pointer hover:opacity-70",style:{color:"var(--active-green)"},children:["←"," Back"]})}),l.jsxs("div",{className:"flex items-start gap-2 mb-2",children:[l.jsx("span",{className:"text-lg",children:L?"📘":e.format==="html"?"🌐":"📄"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-sm font-bold mb-1",style:{color:"var(--terminal-text)"},children:e.title}),l.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[l.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:e.status==="active"?"#16a34a":e.status==="draft"?"#f59e0b":"#94a3b8"},title:e.status}),l.jsx("span",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:e.id})]}),e.tags.length>0&&l.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:e.tags.map(A=>l.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-medium",style:{background:R.bg,color:R.text,border:`1px solid ${R.border}`},children:A},A))})]})]}),e.tldr&&l.jsx("div",{className:"text-[11px] italic leading-relaxed p-2 rounded",style:{background:"var(--hud-bg)",color:"var(--terminal-text-secondary)"},children:e.tldr})]}),l.jsxs("div",{className:"flex-1 overflow-hidden flex",children:[l.jsxs("div",{ref:k,className:"flex-1 overflow-y-auto p-4",children:[g&&l.jsx("div",{className:"text-xs",style:{color:"var(--terminal-text-muted)"},children:"Loading..."}),b&&l.jsx("div",{className:"text-xs p-2 rounded",style:{background:"rgba(239,68,68,0.15)",color:"#f87171"},children:b}),h&&l.jsx(Es,{content:h.content})]}),F&&l.jsxs("div",{className:"shrink-0 overflow-y-auto p-3",style:{width:180,background:"var(--hud-bg-alt)",borderLeft:"1px solid var(--terminal-border)"},children:[l.jsx("div",{className:"text-[10px] font-bold uppercase mb-2",style:{color:"var(--terminal-text-muted)"},children:"Contents"}),l.jsx("div",{className:"space-y-1",children:C.map(A=>l.jsx("button",{onClick:()=>_(A.id),className:"block w-full text-left text-[10px] py-1 px-2 rounded cursor-pointer hover:bg-white/5 transition-colors",style:{paddingLeft:(A.level-2)*8+8,color:N===A.id?"#4ade80":"var(--terminal-text-secondary)",fontWeight:N===A.id?"bold":"normal"},children:A.text.length>30?A.text.slice(0,28)+"..":A.text},A.id))})]})]})]})}const NN=500,Hg=360,AN=700;function Vo(e,n,a){const i=n??NN,[o,u]=w.useState(i),[d,f]=w.useState(!1),m=w.useRef(0),h=w.useRef(0),x=w.useRef(a);x.current=a;const g=e>0,v=g?e:0,b=Math.max(AN,i),j=g?Math.max(Hg,window.innerWidth-e-100):b,k=Math.min(o,j),N=w.useCallback(E=>{E.preventDefault(),m.current=E.clientX,h.current=k,f(!0);const C=()=>{f(!1),document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",C)},_=R=>{const L=m.current-R.clientX,F=h.current+L;if(F>=window.innerWidth*.6&&x.current){C(),x.current();return}const I=Math.min(b,Math.max(Hg,F));u(I)};document.addEventListener("mousemove",_),document.addEventListener("mouseup",C)},[k]);return{panelRight:v,panelWidth:k,isResizing:d,handleResizeStart:N}}function Ug({docs:e,onClose:n,onRefresh:a,terminalWidth:i=0,initialDocId:o,onMaximize:u}){const[d,f]=w.useState(()=>{const A=localStorage.getItem("kb-view-mode");return A==="graph"||A==="tree"||A==="list"?A:"graph"}),[m,h]=w.useState(null),[x,g]=w.useState("global"),[v,b]=w.useState(""),[j,k]=w.useState(()=>new Set(Object.keys(ia)));w.useEffect(()=>{localStorage.setItem("kb-view-mode",d)},[d]);const N=w.useMemo(()=>new Ns(e,{keys:["title","tldr","tags"],threshold:.3,includeScore:!0}),[e]),E=w.useMemo(()=>{let A=new Set(e.map($=>$.id));if(v.trim()){const $=N.search(v);A=new Set($.map(q=>q.item.id))}return A=new Set(Array.from(A).filter($=>{const q=e.find(W=>W.id===$);return q&&j.has(q.category)})),A.size===e.length?null:A},[e,v,N,j]),C=w.useMemo(()=>E===null?e:e.filter(A=>E.has(A.id)),[e,E]),_=A=>{k($=>{const q=new Set($);return q.has(A)?q.delete(A):q.add(A),q})},{panelRight:R,panelWidth:L,isResizing:F,handleResizeStart:I}=Vo(i,void 0,u),H=A=>{h(A.id)},X=m?e.find(A=>A.id===m):null;return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"dimmer fixed top-0 left-0 bottom-0 bg-black/30 z-40 open",style:{right:R},onClick:n}),l.jsxs("div",{className:`side-panel open fixed top-0 h-full z-50 flex flex-col border-l-[3px] shadow-[-4px_0_20px_rgba(0,0,0,0.4)] ${F?"resizing":""}`,style:{right:R,width:L,background:"var(--terminal-bg)",borderLeftColor:"#16a34a"},children:[l.jsx("div",{className:`absolute top-0 -left-[5px] w-[10px] h-full cursor-col-resize z-[60] transition-colors ${F?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:I}),l.jsxs("div",{className:"p-5 text-white relative",style:{background:"#16a34a"},children:[l.jsxs("div",{className:"absolute top-3 right-3 flex items-center gap-1",children:[u&&l.jsx("button",{onClick:u,className:"w-7 h-7 rounded-full bg-white/20 text-white flex items-center justify-center text-sm hover:bg-white/30 cursor-pointer",title:"Maximize (Pro View)",children:"⤢"}),l.jsx("button",{onClick:n,className:"w-7 h-7 rounded-full bg-white/20 text-white flex items-center justify-center text-lg hover:bg-white/30 cursor-pointer",children:"×"})]}),l.jsxs("div",{className:"text-lg font-bold",children:["📚"," Knowledge Base"]}),l.jsxs("div",{className:"text-xs opacity-80 mt-0.5",children:[e.length," documents"]})]}),l.jsxs("div",{className:"flex gap-1 p-2",style:{borderBottom:"1px solid var(--terminal-border)"},children:[l.jsx(Nh,{icon:"🕸️",label:"Graph",active:d==="graph",onClick:()=>f("graph")}),l.jsx(Nh,{icon:"🌲",label:"Tree",active:d==="tree",onClick:()=>{f("tree"),h(null)}}),l.jsx(Nh,{icon:"📋",label:"List",active:d==="list",onClick:()=>{f("list"),h(null)}})]}),l.jsxs("div",{className:"p-3 space-y-2",style:{borderBottom:"1px solid var(--terminal-border)",background:"var(--hud-bg-alt)"},children:[l.jsxs("div",{className:"relative",children:[l.jsx("span",{className:"absolute left-2 top-1/2 -translate-y-1/2 text-sm",children:"🔍"}),l.jsx("input",{type:"text",value:v,onChange:A=>b(A.target.value),placeholder:"Search docs...",className:"w-full pl-8 pr-3 py-1.5 text-xs rounded focus:outline-none transition-colors",style:{background:"var(--hud-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)"}}),v&&l.jsx("button",{onClick:()=>b(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs hover:opacity-70",style:{color:"var(--terminal-text-muted)"},children:"✕"})]}),l.jsx("div",{className:"flex flex-wrap gap-1.5",children:Object.entries(ia).map(([A,$])=>{const q=j.has(A);return l.jsx("button",{onClick:()=>_(A),className:"px-2 py-1 text-[10px] font-medium rounded cursor-pointer transition-all",style:{background:q?$.bg:"transparent",color:q?$.text:"var(--terminal-text-muted)",border:`1px solid ${q?$.border:"var(--terminal-border)"}`,opacity:q?1:.5},children:A},A)})}),l.jsx("div",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:C.length===e.length?`${e.length} documents`:`${C.length} of ${e.length} documents`})]}),d==="graph"&&l.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col animate-fadeIn",children:[l.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[l.jsx(kN,{docs:e,onNodeClick:H,selectedDocId:m,matchedIds:E,localGraphMode:x,onLocalModeChange:g}),X&&l.jsxs("div",{className:"shrink-0 overflow-y-auto p-3",style:{width:200,background:"var(--hud-bg-alt)",borderLeft:"1px solid var(--terminal-border)"},children:[l.jsx("div",{className:"text-[10px] font-bold uppercase mb-1",style:{color:"var(--terminal-text-muted)"},children:"Selected"}),l.jsx("div",{className:"text-xs font-bold mb-1",style:{color:"var(--terminal-text)"},children:X.title}),l.jsx("div",{className:"w-2 h-2 rounded-full mb-2",style:{background:X.status==="active"?"#16a34a":X.status==="draft"?"#f59e0b":"#94a3b8"}}),X.tldr&&l.jsx("div",{className:"text-[10px] mb-2 leading-relaxed",style:{color:"var(--terminal-text-secondary)"},children:X.tldr}),X.links.length>0&&l.jsxs("div",{className:"mb-2",children:[l.jsx("div",{className:"text-[9px] font-bold mb-1",style:{color:"var(--terminal-text-muted)"},children:"Links"}),X.links.slice(0,5).map((A,$)=>l.jsxs("div",{className:"text-[9px] mb-0.5 truncate",style:{color:"var(--terminal-text-secondary)"},children:["🔗"," ",A.text]},$))]})]})]}),l.jsx("div",{className:"shrink-0 p-2",style:{borderTop:"1px solid var(--terminal-border)"},children:l.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(ia).map(([A,$])=>l.jsxs("div",{className:"flex items-center gap-1 text-[9px]",children:[l.jsx("div",{className:"w-2 h-2",style:{background:$.border}}),l.jsx("span",{style:{color:"var(--terminal-text-muted)"},children:A})]},A))})})]}),d==="tree"&&l.jsx(SN,{docs:e,onDocumentClick:A=>h(A),selectedDocId:m,matchedIds:E}),d==="list"&&l.jsx(DN,{icon:"📋",title:"List View",message:"Coming soon in KB-002",description:"Table format with sortable columns and quick scanning"})]})]})}function Nh({icon:e,label:n,active:a,onClick:i}){return l.jsxs("button",{onClick:i,className:"flex-1 flex items-center justify-center gap-1.5 px-3 py-2 text-xs font-medium rounded cursor-pointer transition-all",style:{background:a?"rgba(22,163,106,0.2)":"transparent",color:a?"#4ade80":"var(--terminal-text-muted)",border:a?"1px solid rgba(22,163,106,0.4)":"1px solid transparent"},children:[l.jsx("span",{className:"text-sm",children:e}),l.jsx("span",{children:n})]})}function DN({icon:e,title:n,message:a,description:i}){return l.jsx("div",{className:"flex-1 flex items-center justify-center p-8 animate-fadeIn",children:l.jsxs("div",{className:"text-center max-w-md",children:[l.jsx("div",{className:"text-6xl mb-4",children:e}),l.jsx("div",{className:"text-lg font-bold mb-2",style:{color:"var(--terminal-text)"},children:n}),l.jsx("div",{className:"text-sm mb-3",style:{color:"#4ade80"},children:a}),l.jsx("div",{className:"text-xs leading-relaxed",style:{color:"var(--terminal-text-muted)"},children:i})]})})}function qg({waves:e,decisions:n,mode:a,onClose:i,onOpenWaveCenter:o,onUpdateDecision:u,onDeleteDecision:d,terminalWidth:f=0,onMaximize:m}){const[h,x]=w.useState("decisions"),{panelRight:g,panelWidth:v,isResizing:b,handleResizeStart:j}=Vo(f,void 0,m);return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"dimmer fixed top-0 left-0 bottom-0 bg-black/30 z-40 open",style:{right:g},onClick:i}),l.jsxs("div",{className:`side-panel open fixed top-0 h-full z-50 flex flex-col border-l-[3px] shadow-[-4px_0_20px_rgba(0,0,0,0.4)] ${b?"resizing":""}`,style:{right:g,width:v,background:"var(--terminal-bg)",borderLeftColor:"var(--desk-wood)"},children:[l.jsx("div",{className:`absolute top-0 -left-[5px] w-[10px] h-full cursor-col-resize z-[60] transition-colors ${b?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:j}),l.jsxs("div",{className:"p-5 bg-[var(--desk-wood)] text-white relative",children:[l.jsxs("div",{className:"absolute top-3 right-3 flex items-center gap-1",children:[m&&l.jsx("button",{onClick:m,className:"w-7 h-7 rounded-full bg-white/20 text-white flex items-center justify-center text-sm hover:bg-white/30 cursor-pointer",title:"Maximize (Pro View)",children:"⤢"}),l.jsx("button",{onClick:i,className:"w-7 h-7 rounded-full bg-white/20 text-white flex items-center justify-center text-lg hover:bg-white/30 cursor-pointer",children:"×"})]}),l.jsxs("div",{className:"text-lg font-bold",children:["📋"," Decisions"]})]}),l.jsxs("div",{className:"flex",style:{borderBottom:"1px solid var(--terminal-border)"},children:[l.jsx(Ah,{label:`Decisions (${n.length})`,active:h==="decisions",onClick:()=>x("decisions")}),o?l.jsx(Ah,{label:"Waves →",active:!1,onClick:o}):l.jsx(Ah,{label:`Waves (${e.length})`,active:h==="waves",onClick:()=>x("waves")})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[h==="decisions"&&(n.length>0?n.map(k=>l.jsx(TN,{decision:k,onSave:u,onDelete:d},k.id)):l.jsx("div",{className:"text-center py-10 text-sm",style:{color:"var(--terminal-text-muted)"},children:"No decisions yet"})),h==="waves"&&e.map((k,N)=>l.jsx(FN,{title:`Wave ${k.id}`,subtitle:k.startedAt,content:k.directive},N))]})]})]})}function TN({decision:e,onSave:n,onDelete:a}){const[i,o]=w.useState(!1),[u,d]=w.useState(!1),[f,m]=w.useState(e.content),[h,x]=w.useState(!1),g=ov(e.content).slice(0,160),v=e.content.length>100,b=w.useCallback(async()=>{if(!n||f===e.content){d(!1);return}x(!0);try{await n(e.id,f),d(!1)}finally{x(!1)}},[n,f,e.id,e.content]),j=w.useCallback(async()=>{if(a){x(!0);try{await a(e.id)}finally{x(!1)}}},[a,e.id]);return l.jsxs("div",{className:"mb-3 rounded-lg overflow-hidden",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"p-3 cursor-pointer hover:bg-white/5",onClick:()=>{u||o(!i)},children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"font-medium text-sm",style:{color:"var(--terminal-text)"},children:["#",e.id," ",e.title]}),l.jsxs("div",{className:"flex items-center gap-1.5 shrink-0 ml-2",children:[i&&!u&&n&&l.jsx("button",{onClick:k=>{k.stopPropagation(),m(e.content),d(!0)},className:"text-[10px] px-2 py-0.5 rounded hover:bg-white/10 transition-colors",style:{color:"var(--terminal-text-muted)",border:"1px solid var(--terminal-border)"},children:"Edit"}),l.jsx("span",{className:"text-xs",style:{color:"var(--terminal-text-muted)"},children:i?"▲":"▼"})]})]}),e.date&&l.jsx("div",{className:"text-xs mt-0.5",style:{color:"var(--terminal-text-muted)"},children:e.date})]}),i&&u?l.jsxs("div",{className:"px-3 pb-3 pt-2",style:{borderTop:"1px solid var(--terminal-border)"},children:[l.jsx("textarea",{value:f,onChange:k=>m(k.target.value),className:"w-full rounded-lg p-3 text-xs leading-relaxed resize-none font-mono terminal-scrollbar focus:outline-none",style:{background:"var(--terminal-inline-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)",minHeight:200},rows:12}),l.jsxs("div",{className:"flex items-center justify-between mt-2",children:[l.jsx("div",{children:a&&l.jsx("button",{onClick:j,disabled:h,className:"text-[10px] px-2 py-1 rounded hover:bg-red-900/30 transition-colors disabled:opacity-40",style:{color:"#EF4444",border:"1px solid #EF444440"},children:"Delete"})}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:()=>d(!1),disabled:h,className:"text-[10px] px-3 py-1 rounded hover:bg-white/5 transition-colors disabled:opacity-40",style:{color:"var(--terminal-text-muted)",border:"1px solid var(--terminal-border)"},children:"Cancel"}),l.jsx("button",{onClick:b,disabled:h||f===e.content,className:"text-[10px] px-3 py-1 rounded font-semibold transition-colors disabled:opacity-40",style:{background:"var(--desk-wood)",color:"#fff"},children:h?"Saving...":"Save"})]})]})]}):i?l.jsx("div",{className:"px-3 pb-3 text-xs leading-relaxed pt-2",style:{borderTop:"1px solid var(--terminal-border)",color:"var(--terminal-text-secondary)"},children:l.jsx(Es,{content:e.content})}):null,!i&&v&&l.jsx("div",{className:"px-3 pb-2 text-xs line-clamp-2 leading-relaxed",style:{color:"var(--terminal-text-muted)"},children:g})]})}function Ah({label:e,active:n,onClick:a}){return l.jsx("button",{onClick:a,className:"px-4 py-2.5 text-sm font-medium cursor-pointer",style:{color:n?"var(--accent)":"var(--terminal-text-muted)",borderBottom:n?"2px solid var(--accent)":"2px solid transparent"},children:e})}function ov(e){return e.replace(/^#{1,6}\s+/gm,"").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\*([^*]+)\*/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/```[\s\S]*?```/g,"").replace(/^\s*[-*+]\s+/gm,"• ").replace(/^\s*\d+\.\s+/gm,"").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/^>\s+/gm,"").replace(/^---+$/gm,"").replace(/\|[^|]*\|/g,"").replace(/\n{2,}/g," · ").replace(/\n/g," ").trim()}function FN({title:e,subtitle:n,content:a}){const[i,o]=w.useState(!1),u=a.length>100,d=ov(a).slice(0,160);return l.jsxs("div",{className:"mb-3 rounded-lg overflow-hidden",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"p-3 cursor-pointer hover:bg-white/5",onClick:()=>o(!i),children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("div",{className:"font-medium text-sm",style:{color:"var(--terminal-text)"},children:e}),l.jsx("span",{className:"text-xs shrink-0 ml-2",style:{color:"var(--terminal-text-muted)"},children:i?"▲":"▼"})]}),n&&l.jsx("div",{className:"text-xs mt-0.5",style:{color:"var(--terminal-text-muted)"},children:n})]}),i&&l.jsx("div",{className:"px-3 pb-3 text-xs leading-relaxed pt-2",style:{borderTop:"1px solid var(--terminal-border)",color:"var(--terminal-text-secondary)"},children:l.jsx(Es,{content:a})}),!i&&u&&l.jsx("div",{className:"px-3 pb-2 text-xs line-clamp-2 leading-relaxed",style:{color:"var(--terminal-text-muted)"},children:d})]})}const ws=[{id:"ch1-q1",chapter:1,title:"Hire your first employee",description:'Every company starts with its first hire. Click the HIRE button to open the recruitment panel. Choose a role name (e.g. "PM"), set a level, and bring them on board. Each role becomes an AI agent that works for your company.',type:"main",trigger:{type:"role_hired"},rewards:{coins:1e3},hint:{target:"hire-btn",message:"Click HIRE to recruit your first team member"}},{id:"ch1-q2",chapter:1,title:"Open the Terminal",description:"The Terminal is your command center — where you talk to your team. Click TERMINAL in the bottom bar to open it. You'll see a chat-like interface where you can select any role and give them instructions.",type:"main",trigger:{type:"terminal_opened"},rewards:{coins:500},hint:{target:"terminal-btn",message:"Click TERMINAL to open your command center"}},{id:"ch1-q3",chapter:1,title:"Talk to your team",description:`Use "Talk" mode to have a conversation with your team. Talk mode is for quick questions, brainstorming, and discussions — the AI role will respond with advice but won't modify any files. Select a role tab and type your message.`,type:"main",trigger:{type:"talk_mode_used"},rewards:{coins:1e3},hint:{target:"terminal-btn",message:"Open the terminal, select Talk mode, and chat"}},{id:"ch2-q1",chapter:2,title:"Create a project",description:"Projects organize your company's work. Click the Meeting Room in the office view to create one. Give it a name, description, and the system will scaffold a project folder with PRD, tasks, and design docs that your AI team will use.",type:"main",trigger:{type:"project_created"},rewards:{coins:1500},hint:{target:"meeting-room",message:"Click the Meeting Room to create a project"}},{id:"ch2-q2",chapter:2,title:"Give your first order",description:'Use "Do" mode to assign real work. Unlike Talk mode, Do mode lets roles execute tasks — they can read/write files, create documents, and run commands. Switch to Do mode in the terminal and give your team member a task.',type:"main",trigger:{type:"do_mode_used"},rewards:{badge:"first-launch",coins:2e3},hint:{target:"terminal-btn",message:"Open the terminal, switch to Do mode, and assign a task"}},{id:"ch3-q1",chapter:3,title:"Create a chat channel",description:'Chat channels let multiple roles discuss topics together — like Slack for your AI team. Click the "+" button next to channel tabs in the terminal to create a new channel. Add members and set a topic for focused collaboration.',type:"main",trigger:{type:"chat_channel_created"},rewards:{coins:1500},hint:{target:"terminal-btn",message:'Open the terminal and click "+" to create a chat channel'}},{id:"ch3-q2",chapter:3,title:"Dispatch a CEO Wave",description:"CEO Wave broadcasts a directive to your entire C-Level team at once. It's like an all-hands announcement — each C-Level role receives the wave and can delegate to their reports. Use it for company-wide initiatives, pivots, or big decisions.",type:"main",trigger:{type:"wave_dispatched"},rewards:{badge:"team-builder",coins:3e3},hint:{target:"wave-btn",message:"Click CEO WAVE to broadcast to your team"}},{id:"ch4-q1",chapter:4,title:"Hire a CTO",description:"C-Level roles are special — they can delegate work to their reports and make autonomous decisions. A CTO manages your technical team (Engineers, QA). Hire one with the C-Level tier to unlock the org hierarchy.",type:"main",trigger:{type:"role_hired",condition:{roleId:"cto"}},rewards:{coins:2e3},hint:{target:"hire-btn",message:"Hire a CTO to lead your tech team"}},{id:"ch4-q2",chapter:4,title:"Hire an Engineer",description:'Engineers are the builders. They read architecture docs, write code, and ship features. Set their "Reports To" to CTO so the org hierarchy works — when you wave, the CTO can delegate tasks down to engineers automatically.',type:"main",trigger:{type:"role_hired",condition:{roleId:"engineer"}},rewards:{coins:2500},hint:{target:"hire-btn",message:"Hire an Engineer to start building"}},{id:"ch4-q3",chapter:4,title:"Define a persona",description:"Each role has a persona — their personality, expertise, and communication style. Click a role in the office to open their panel, then edit their persona. A well-defined persona makes the AI role more consistent and specialized.",type:"main",trigger:{type:"persona_updated"},rewards:{coins:2e3},hint:{target:"terminal-btn",message:"Click a role in the office, then edit their persona"}},{id:"ch5-q1",chapter:5,title:"Explore the Knowledge Base",description:"The Knowledge Hub stores your company's documents — architecture decisions, domain knowledge, meeting notes. Your AI team reads these docs for context when working. Click the Knowledge bookshelf in the office to browse.",type:"main",trigger:{type:"knowledge_visited"},rewards:{coins:2e3},hint:{target:"knowledge-hub",message:"Click the Knowledge Hub to explore your docs"}},{id:"ch5-q2",chapter:5,title:"Check the Bulletin Board",description:"The Bulletin Board shows your company's daily standups and wave execution logs. Every time a role completes work, they post a standup. Waves show the full chain of delegation. It's your company's activity feed.",type:"main",trigger:{type:"bulletin_visited"},rewards:{badge:"scholar",coins:2e3},hint:{target:"bulletin-board",message:"Click the Bulletin Board for company updates"}},{id:"ch6-q1",chapter:6,title:"Visit the Character Store",description:"The Store has community-created characters with unique pixel art designs. Browse characters shared by other Tycono users, preview their look, and import them into your team. Open HIRE and switch to the Store tab.",type:"main",trigger:{type:"store_visited"},rewards:{coins:3e3},hint:{target:"hire-btn",message:"Open HIRE and check out the Store tab"}},{id:"ch6-q2",chapter:6,title:"Customize a character",description:"Every role has a pixel art character you can customize — change hair, skin, outfit, and accessories. Click a role in the office view to open their panel, then click the character sprite to enter the customization editor.",type:"main",trigger:{type:"accessory_changed"},rewards:{badge:"explorer",coins:5e3},hint:{target:"hire-btn",message:"Click a team member to customize their look"}},{id:"ch6-q3",chapter:6,title:"Change the office theme",description:"Your office supports multiple visual themes — each changes the color palette, mood, and atmosphere. Click the theme icon in the bottom bar to browse available themes and pick the one that matches your company's vibe.",type:"main",trigger:{type:"theme_changed"},rewards:{badge:"stylist",coins:2e3},hint:{target:"theme-btn",message:"Click the Theme button to change your office look"}},{id:"ch7-q1",chapter:7,title:"Decorate your office",description:"Enter Edit mode to rearrange your office layout. You can drag furniture, place decorations, and create different room zones. Click the EDIT button, then drag items to place them. Click DONE when finished.",type:"main",trigger:{type:"furniture_placed"},rewards:{coins:2e3},hint:{target:"edit-btn",message:"Click EDIT to enter furniture layout mode"}},{id:"ch7-q2",chapter:7,title:"Buy premium furniture",description:"Spend coins earned from quests and achievements to buy premium furniture. Enter Edit mode and browse the furniture shop — each item has a coin price. Premium items add unique visual flair to your office.",type:"main",trigger:{type:"furniture_purchased"},rewards:{badge:"interior-designer",coins:3e3},hint:{target:"edit-btn",message:"Enter EDIT mode and buy furniture with coins"}},{id:"ch8-q1",chapter:8,title:"Review company stats",description:"The Stats panel shows your company's performance metrics — token usage per role, activity levels, role leaderboard, and growth over time. Click the Stats facility in the office to see how your team is performing.",type:"main",trigger:{type:"stats_visited"},rewards:{coins:2e3},hint:{target:"stats-btn",message:"Click Stats to see your company metrics"}},{id:"ch8-q2",chapter:8,title:"Save your progress",description:"Tycono uses git to track all changes your AI team makes. Press Cmd+S (or click the save indicator) to commit your company's current state. Each save creates a git commit — you can view history and even restore previous states.",type:"main",trigger:{type:"save_committed"},rewards:{coins:2e3},hint:{target:"save-btn",message:"Press Cmd+S or click Save to commit changes"}},{id:"ch8-q3",chapter:8,title:"Open Settings",description:"The Settings panel lets you configure your company — adjust API keys, execution engine preferences, and other system options. Click the gear icon in the bottom bar to access it.",type:"main",trigger:{type:"settings_visited"},rewards:{coins:2e3},hint:{target:"settings-btn",message:"Click the Settings gear to configure your company"}},{id:"ch9-q1",chapter:9,title:"Hire a Designer",description:"A Designer handles UI/UX work — wireframes, mockups, and visual design decisions. They complement your Engineer by focusing on the user experience side. Hire one to round out your product team.",type:"main",trigger:{type:"role_hired",condition:{roleId:"designer"}},rewards:{coins:2500},hint:{target:"hire-btn",message:"Hire a Designer for your creative team"}},{id:"ch9-q2",chapter:9,title:"Hire a QA Engineer",description:"QA Engineers test your product, find bugs, and ensure quality. They review code changes, write test plans, and validate that features work as expected. Essential for any serious product team.",type:"main",trigger:{type:"role_hired",condition:{roleId:"qa"}},rewards:{coins:3e3},hint:{target:"hire-btn",message:"Hire a QA Engineer for quality assurance"}},{id:"ch9-q3",chapter:9,title:"Build a 5-person team",description:"Growing your team unlocks the full potential of delegation. With 5+ members, your C-Level roles can distribute work across specialized team members, creating a real organizational hierarchy.",type:"main",trigger:{type:"role_hired",condition:{minRoles:5}},rewards:{badge:"growing-company",coins:5e3},hint:{target:"hire-btn",message:"Keep hiring until you have 5+ team members"}},{id:"ch10-q1",chapter:10,title:"Build a 7-person team",description:"A full-size team with diverse roles means your company can handle any challenge. CEO at the top, C-Levels managing domains, and specialists executing. You've built a real AI-powered organization.",type:"main",trigger:{type:"role_hired",condition:{minRoles:7}},rewards:{badge:"tycoon-master",coins:1e4},hint:{target:"hire-btn",message:"Keep hiring until you have 7+ team members"}}],mm=[{num:1,title:"Getting Started",questIds:["ch1-q1","ch1-q2","ch1-q3"]},{num:2,title:"First Project",questIds:["ch2-q1","ch2-q2"]},{num:3,title:"Team Communication",questIds:["ch3-q1","ch3-q2"]},{num:4,title:"Building the Team",questIds:["ch4-q1","ch4-q2","ch4-q3"]},{num:5,title:"Knowledge & Docs",questIds:["ch5-q1","ch5-q2"]},{num:6,title:"Customization",questIds:["ch6-q1","ch6-q2","ch6-q3"]},{num:7,title:"Office Design",questIds:["ch7-q1","ch7-q2"]},{num:8,title:"Operations",questIds:["ch8-q1","ch8-q2","ch8-q3"]},{num:9,title:"Scaling Up",questIds:["ch9-q1","ch9-q2","ch9-q3"]},{num:10,title:"Tycoon Master",questIds:["ch10-q1"]}],MN={completedQuests:[],activeChapter:1,sideQuestsCompleted:[]};function Yg(){return{...MN}}function pm(e,n){return n.completedQuests.includes(e.id)?"completed":"active"}function cv(e){return ws.filter(n=>pm(n,e)==="active")}function RN(e){const n=cv(e);return n.find(i=>i.chapter===e.activeChapter)??n[0]??null}function zN(e,n){const a=ws.find(o=>o.id===n);return a?e.completedQuests.includes(n)?{progress:e,quest:null}:{progress:{...e,completedQuests:[...e.completedQuests,n],firstCompletedAt:e.firstCompletedAt??new Date().toISOString()},quest:a}:{progress:e,quest:null}}function Xg(e){let n=1;for(const a of mm)if(a.questIds.every(i=>e.completedQuests.includes(i))){const i=mm.find(o=>o.num===a.num+1);i&&(n=i.num)}return n!==e.activeChapter?{...e,activeChapter:n}:e}function _N(e){const n=ws.filter(i=>i.type==="main").length;return{completed:e.completedQuests.filter(i=>{var o;return((o=ws.find(u=>u.id===i))==null?void 0:o.type)==="main"}).length,total:n}}function BN(e,n){if(e.trigger.type!==n.type)return!1;if(e.trigger.condition&&n.condition){for(const[a,i]of Object.entries(e.trigger.condition))if(a==="minRoles"){if(n.condition.roleCount<i)return!1}else if(n.condition[a]!==i)return!1}return!0}function ON({progress:e,onQuestAction:n,onClose:a,terminalWidth:i=0}){const{completed:o,total:u}=_N(e),d=u>0?Math.round(o/u*100):0,{panelRight:f,panelWidth:m,isResizing:h,handleResizeStart:x}=Vo(i);return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"dimmer fixed top-0 left-0 bottom-0 bg-black/30 z-40 open",style:{right:f},onClick:a}),l.jsxs("div",{className:`side-panel open fixed top-0 h-full z-50 flex flex-col border-l-[3px] shadow-[-4px_0_20px_rgba(0,0,0,0.4)] ${h?"resizing":""}`,style:{right:f,width:m,background:"var(--terminal-bg)",borderLeftColor:"var(--desk-wood)"},children:[l.jsx("div",{className:`absolute top-0 -left-[5px] w-[10px] h-full cursor-col-resize z-[60] transition-colors ${h?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:x}),l.jsxs("div",{className:"p-5 text-white relative",style:{background:"linear-gradient(135deg, #8B5E3C, #6B4226)"},children:[l.jsx("button",{onClick:a,className:"absolute top-3 right-3 w-7 h-7 rounded-full bg-white/20 text-white flex items-center justify-center text-lg hover:bg-white/30 cursor-pointer",children:"×"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-xl",children:"🐾"}),l.jsxs("div",{children:[l.jsx("div",{className:"text-lg font-bold",children:"Pupu's Quest Board"}),l.jsxs("div",{className:"text-xs opacity-70 mt-0.5",children:[o,"/",u," quests completed · ",d,"%"]})]})]}),l.jsx("div",{className:"mt-3",children:l.jsx("div",{className:"h-2 rounded-full overflow-hidden bg-white/15",children:l.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${d}%`,background:"#F4D03F"}})})})]}),l.jsx("div",{className:"flex-1 overflow-y-auto p-5 flex flex-col gap-3",children:mm.map(g=>{const v=ws.filter(k=>g.questIds.includes(k.id)),b=v.every(k=>e.completedQuests.includes(k.id)),j=v.some(k=>pm(k,e)==="active");return l.jsxs("div",{className:"rounded-lg",style:{background:j?"var(--hud-bg-alt)":"transparent",border:j?"1px solid var(--accent)":"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",children:[l.jsx("span",{className:"text-sm",children:b?"✅":"🟡"}),l.jsxs("span",{className:"text-sm font-medium",style:{color:j?"var(--accent)":"var(--terminal-text)"},children:["Chapter ",g.num,": ",g.title]})]}),l.jsx("div",{className:"px-3 pb-2 flex flex-col gap-1.5",children:v.map(k=>{const N=pm(k,e);return l.jsxs("div",{className:"flex items-start gap-2 pl-2",children:[l.jsx("span",{className:"text-xs mt-0.5 shrink-0",children:N==="completed"?"☑":"☐"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-xs",style:{color:N==="completed"?"var(--terminal-text-muted)":"var(--terminal-text)",textDecoration:N==="completed"?"line-through":"none"},children:k.title}),N==="active"&&k.hint&&n&&l.jsx("button",{onClick:()=>n(k.id),className:"shrink-0 text-[10px] px-2 py-0.5 rounded cursor-pointer hover:brightness-125 transition-all",style:{background:"var(--accent)",color:"#000",fontWeight:600},children:"GO →"})]}),N==="active"&&l.jsx("div",{className:"text-[10px] mt-1 leading-relaxed",style:{color:"var(--terminal-text-secondary)"},children:k.description}),N==="active"&&k.hint&&l.jsxs("div",{className:"text-[10px] mt-0.5",style:{color:"var(--accent)"},children:["💡 ",k.hint.message]})]})]},k.id)})})]},g.num)})})]})]})}function $N({projectId:e,onClose:n,terminalWidth:a=0}){const[i,o]=w.useState(null),{panelRight:u,panelWidth:d,isResizing:f,handleResizeStart:m}=Vo(a);if(w.useEffect(()=>{ye.getProject(e).then(o).catch(console.error)},[e]),!i)return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"dimmer fixed top-0 left-0 bottom-0 bg-black/30 z-40 open",style:{right:u},onClick:n}),l.jsx("div",{className:"side-panel open fixed top-0 h-full z-50 flex items-center justify-center border-l-[3px] border-[var(--meeting-blue)]",style:{right:u,width:d,background:"var(--terminal-bg)"},children:l.jsx("div",{className:"text-sm",style:{color:"var(--terminal-text-muted)"},children:"Loading project..."})})]});const h=i.tasks.filter(v=>v.status==="done").length,x=i.tasks.length,g=x>0?Math.round(h/x*100):0;return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"dimmer fixed top-0 left-0 bottom-0 bg-black/30 z-40 open",style:{right:u},onClick:n}),l.jsxs("div",{className:`side-panel open fixed top-0 h-full z-50 flex flex-col border-l-[3px] border-[var(--meeting-blue)] shadow-[-4px_0_20px_rgba(0,0,0,0.4)] ${f?"resizing":""}`,style:{right:u,width:d,background:"var(--terminal-bg)"},children:[l.jsx("div",{className:`absolute top-0 -left-[5px] w-[10px] h-full cursor-col-resize z-[60] transition-colors ${f?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:m}),l.jsxs("div",{className:"p-5 bg-[var(--meeting-blue)] text-white relative",children:[l.jsx("div",{className:"text-sm opacity-70",children:"Meeting Room"}),l.jsx("button",{onClick:n,className:"absolute top-3 right-3 z-10 w-7 h-7 rounded-full bg-white/20 text-white flex items-center justify-center text-lg hover:bg-white/30 cursor-pointer",children:"×"}),l.jsx("div",{className:"text-xl font-bold mt-1",children:i.name}),l.jsxs("div",{className:"flex items-center gap-3 mt-3 text-sm",children:[l.jsxs("span",{children:["Tasks: ",x]}),l.jsxs("span",{children:["Done: ",h]}),l.jsxs("span",{children:["Progress: ",g,"%"]})]}),l.jsx("div",{className:"mt-2 h-1.5 bg-white/20 rounded-full overflow-hidden",children:l.jsx("div",{className:"h-full bg-white rounded-full transition-all",style:{width:`${g}%`}})})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[i.prd&&l.jsxs("div",{className:"mb-5",children:[l.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider mb-2",style:{color:"var(--terminal-text-muted)"},children:"PRD"}),l.jsx("div",{className:"rounded-lg p-4 text-xs leading-relaxed max-h-60 overflow-y-auto",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text-secondary)"},children:l.jsx(Es,{content:i.prd})})]}),l.jsxs("div",{children:[l.jsxs("div",{className:"text-[11px] font-bold uppercase tracking-wider mb-2",style:{color:"var(--terminal-text-muted)"},children:["Tasks (",x,")"]}),l.jsx("div",{className:"space-y-2",children:i.tasks.map(v=>l.jsxs("div",{className:"rounded-lg p-3",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm font-medium",style:{color:"var(--terminal-text)"},children:v.title}),l.jsx(LN,{status:v.status})]}),l.jsx("div",{className:"text-xs mt-1",style:{color:"var(--terminal-text-muted)"},children:v.role}),v.description&&l.jsx("div",{className:"text-xs mt-1.5 line-clamp-2",style:{color:"var(--terminal-text-secondary)"},children:v.description})]},v.id))})]})]})]})]})}function LN({status:e}){const n={done:{bg:"rgba(34,197,94,0.15)",color:"#4ade80"},"in-progress":{bg:"rgba(59,130,246,0.15)",color:"#60a5fa"},todo:{bg:"rgba(148,163,184,0.15)",color:"var(--terminal-text-muted)"}},a=n[e]??n.todo;return l.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full",style:{background:a.bg,color:a.color},children:e})}const IN={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"};function HN({roleId:e,roleName:n,mode:a="assign",onClose:i,onExecutionStart:o}){const[u,d]=w.useState(""),f=w.useRef(null);w.useEffect(()=>{var g;(g=f.current)==null||g.focus()},[]);const m=()=>{u.trim()&&(o(e,u.trim()),i())},h=g=>{g.key==="Enter"&&(g.metaKey||g.ctrlKey)&&m(),g.key==="Escape"&&i()},x=IN[e]??"#666";return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:i}),l.jsxs("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[520px] z-[61] bg-[var(--wall)] rounded-2xl shadow-2xl overflow-hidden",children:[l.jsxs("div",{className:"p-5 text-white",style:{background:`linear-gradient(135deg, ${x}, ${x}cc)`},children:[l.jsx("div",{className:"text-lg font-bold",children:a==="ask"?"Ask":"Assign Task"}),l.jsx("div",{className:"text-sm opacity-80 mt-0.5",children:a==="ask"?`to ${n}`:`to ${n} (${e})`})]}),l.jsxs("div",{className:"p-5",children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Task Description"}),l.jsx("textarea",{ref:f,value:u,onChange:g=>d(g.target.value),onKeyDown:h,placeholder:a==="ask"?"What would you like to ask?":"Describe the task...",className:"w-full h-32 p-3 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 placeholder-white/25 resize-none focus:outline-none focus:border-white/25 transition-colors"}),l.jsx("div",{className:"text-[10px] text-white/30 mt-1",children:"Cmd+Enter to submit"})]}),l.jsxs("div",{className:"flex justify-end gap-3 px-5 pb-5",children:[l.jsx("button",{onClick:i,className:"px-4 py-2 text-sm rounded-lg border border-white/15 text-white/60 hover:bg-white/5 cursor-pointer",children:"Cancel"}),l.jsx("button",{onClick:m,disabled:!u.trim(),className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:x},children:a==="ask"?"Ask":"Assign"})]})]})]})}const Wg={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"};function Km({event:e,isThinkingCollapsed:n,onToggleThinking:a,onNavigateToJob:i,onOpenKnowledgeDoc:o,compact:u}){var f;const d=Wg[e.roleId]??"#888";switch(e.type){case"text":{const m=e.data.text??"",h=u?m.slice(0,300):m;return/[#*|`\[\]_~>-]/.test(h)?l.jsx("div",{className:"text-green-300/90 leading-relaxed event-markdown",children:l.jsx($m,{remarkPlugins:[Um],children:h})}):l.jsx("div",{className:"text-green-300/90 whitespace-pre-wrap leading-relaxed",children:h})}case"thinking":{const m=e.data.text??"";return l.jsxs("div",{className:"group",children:[l.jsxs("button",{onClick:a,className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-[10px] cursor-pointer flex items-center gap-1 select-text",children:[l.jsx("span",{children:n?"▶":"▼"}),l.jsx("span",{className:"italic",children:"thinking..."})]}),!n&&l.jsxs("div",{className:`ml-3 text-[var(--terminal-text-muted)] italic whitespace-pre-wrap opacity-60 text-[11px] overflow-hidden ${u?"max-h-[60px]":"max-h-[120px]"}`,children:[m.slice(0,u?200:500),m.length>(u?200:500)?"...":""]})]})}case"tool:start":{const m=String(e.data.name??""),h=e.data.input,x=typeof(h==null?void 0:h.command)=="string"?h.command.slice(0,80):"",g=typeof(h==null?void 0:h.file_path)=="string"?String(h.file_path):typeof(h==null?void 0:h.path)=="string"?String(h.path):"",v=g?g.split("/").pop()??"":"",b=/^(write_file|Write|edit_file|Edit)$/i.test(m),j=(f=g.match(/(?:^|\/)knowledge\/(.+\.md)$/))==null?void 0:f[1],k=b&&j&&o;return l.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[l.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] ${k?"text-green-400/80 bg-green-400/10":"text-blue-400/80 bg-blue-400/10"}`,children:k?b&&m.toLowerCase().includes("edit")?"Edit":"Write":m}),k?l.jsx("button",{onClick:()=>o(j),className:"text-[10px] text-green-400 hover:text-green-300 underline underline-offset-2 cursor-pointer truncate",style:{maxWidth:u?200:400},children:v}):l.jsxs(l.Fragment,{children:[x&&l.jsx("span",{className:`text-[var(--terminal-text-muted)] text-[10px] truncate ${u?"max-w-[200px]":"max-w-[400px]"}`,children:x}),v&&l.jsx("span",{className:`text-[var(--terminal-text-muted)] text-[10px] truncate ${u?"max-w-[200px]":"max-w-[400px]"}`,children:v})]})]})}case"dispatch:start":{const m=e.data.targetRoleId??e.data.roleId??"",h=e.data.task??"",x=e.data.childJobId,g=Wg[m]??"#888";return l.jsx("div",{className:"my-1 p-2 rounded-lg border cursor-pointer hover:opacity-90 transition-opacity",style:{borderColor:`${g}44`,background:`${g}11`},onClick:()=>x&&(i==null?void 0:i(x)),children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("span",{style:{color:g},className:"font-bold text-[11px]",children:["→"," ",m.toUpperCase()]}),l.jsx("span",{className:"text-[var(--terminal-text-secondary)] text-[10px] truncate flex-1",children:h.slice(0,u?60:100)}),x&&i&&l.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-white/10 text-[var(--terminal-text-muted)]",children:["View ","→"]})]})})}case"dispatch:done":return l.jsx("div",{className:"text-[var(--terminal-text-muted)] text-[10px] pl-3 border-l-2 border-[var(--terminal-border)] my-0.5",children:"Dispatch completed"});case"turn:complete":return l.jsx("div",{className:"border-t border-[var(--terminal-border)] my-2 relative",children:l.jsxs("span",{className:"absolute -top-2 left-2 bg-[var(--terminal-bg)] px-2 text-[9px] text-[var(--terminal-text-muted)]",children:["Turn ",e.data.turn]})});case"stderr":return l.jsxs("div",{className:"text-red-400/80 text-[11px]",children:["⚠"," ",e.data.message]});case"job:start":return l.jsxs("div",{className:"text-[var(--terminal-text-muted)] text-[10px] pb-1",children:[l.jsx("span",{style:{color:d},className:"font-bold",children:e.roleId.toUpperCase()})," ","started: ",(e.data.task??"").slice(0,u?50:80)]});case"job:done":{const m=e.data.turns??0,h=e.data.toolCalls??0;return l.jsx("div",{className:"mt-2 p-2 rounded-lg bg-green-900/20 border border-green-800/30",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"w-2 h-2 rounded-full bg-green-400"}),l.jsx("span",{className:"text-green-300 font-bold text-[11px]",children:"Complete"}),l.jsxs("span",{className:"text-[var(--terminal-text-muted)] text-[10px]",children:[m," turns · ",h," tools"]})]})})}case"job:error":return l.jsx("div",{className:"mt-2 p-2 rounded-lg bg-red-900/20 border border-red-800/30",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"w-2 h-2 rounded-full bg-red-400"}),l.jsx("span",{className:"text-red-300 font-bold text-[11px]",children:"Error"}),l.jsx("span",{className:"text-red-200/70 text-[10px]",children:e.data.message})]})});case"job:awaiting_input":{const m=e.data.question??"";return l.jsxs("div",{className:"mt-2 p-2 rounded-lg border",style:{background:"#F59E0B11",borderColor:"#F59E0B33"},children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:"#F59E0B",animation:"wave-pulse 1.5s ease-in-out infinite"}}),l.jsx("span",{className:"font-bold text-[11px]",style:{color:"#F59E0B"},children:"Awaiting Reply"})]}),m&&l.jsx("div",{className:"mt-1 text-[11px] text-[var(--terminal-text)] whitespace-pre-wrap",children:m})]})}case"job:reply":return l.jsx("div",{className:"mt-1 p-2 rounded-lg bg-blue-900/20 border border-blue-800/30",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-blue-300 font-bold text-[11px]",children:"CEO replied:"}),l.jsx("span",{className:"text-blue-200/80 text-[11px]",children:e.data.response??""})]})});case"import:scan":case"import:process":case"import:created":return l.jsxs("div",{className:"text-cyan-300/70 text-[11px]",children:["[",e.type,"] ",JSON.stringify(e.data)]});default:return null}}function UN({sessionId:e,title:n,color:a,variant:i,style:o,onClose:u,onMinimize:d,onDone:f,onNavigateToJob:m,onOpenKnowledgeDoc:h}){const{events:x,status:g,textOutput:v,childJobIds:b}=Ay(e),[j,k]=w.useState(0),[N,E]=w.useState(new Set),C=w.useRef(null),_=w.useRef(Date.now()),R=w.useRef(!1);w.useEffect(()=>{const $=setInterval(()=>{k(Math.floor((Date.now()-_.current)/1e3))},1e3);return()=>clearInterval($)},[]),w.useEffect(()=>{C.current&&(C.current.scrollTop=C.current.scrollHeight)},[x]),w.useEffect(()=>{(g==="done"||g==="error")&&!R.current&&(R.current=!0,f==null||f())},[g,f]);const L=$=>{E(q=>{const W=new Set(q);return W.has($)?W.delete($):W.add($),W})},F={idle:"Waiting",connecting:"Connecting...",streaming:"Working",done:"Complete",error:"Error"}[g],I={idle:"#888",connecting:"#888",streaming:a,done:"#2E7D32",error:"#C62828"}[g],H=$=>`${Math.floor($/60)}:${String($%60).padStart(2,"0")}`,X=g==="done"||g==="error",A=l.jsxs("div",{className:i==="modal"?"fixed top-[5%] left-1/2 -translate-x-1/2 w-[720px] max-w-[95vw] h-[85vh] z-[61] bg-[var(--terminal-bg)] rounded-2xl shadow-2xl overflow-hidden flex flex-col":"bg-[var(--terminal-bg)] rounded-xl border border-[var(--terminal-border)] overflow-hidden flex flex-col max-h-[400px]",style:o,children:[l.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-[var(--terminal-border)] shrink-0",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-3 h-3 rounded-full animate-pulse",style:{background:I}}),l.jsx("div",{children:l.jsx("span",{className:"text-[var(--terminal-text)] font-bold text-sm",children:n})})]}),l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs font-mono",children:H(j)}),l.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full font-semibold",style:{background:`${I}22`,color:I},children:F}),d&&i==="modal"&&l.jsx("button",{onClick:d,title:"Minimize",className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text)] text-sm cursor-pointer px-1",children:"–"}),X&&l.jsx("button",{onClick:u,className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text)] text-lg cursor-pointer",children:"×"})]})]}),l.jsxs("div",{ref:C,className:"flex-1 overflow-y-auto p-4 space-y-1 text-xs font-mono",children:[x.length===0&&g==="connecting"&&l.jsx("div",{className:"text-[var(--terminal-text-muted)]",children:"Connecting to activity stream..."}),x.map($=>l.jsx(Km,{event:$,isThinkingCollapsed:N.has($.seq),onToggleThinking:()=>L($.seq),onNavigateToJob:m,onOpenKnowledgeDoc:h},$.seq)),g==="streaming"&&l.jsx("span",{className:"inline-block w-2 h-4 bg-green-400 animate-pulse ml-0.5"})]}),l.jsxs("div",{className:"px-5 py-3 border-t border-[var(--terminal-border)] flex items-center justify-between shrink-0",children:[l.jsxs("div",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:[x.length>0&&`${x.length} events`,v.length>0&&` · ${v.length} chars`,b.length>0&&` · ${b.length} dispatches`]}),X&&l.jsx("button",{onClick:u,className:"px-4 py-1.5 text-xs text-white rounded-lg font-semibold cursor-pointer",style:{background:a},children:"Close"})]})]});return i==="modal"?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:X?u:void 0}),A]}):A}const qN={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function YN({orgNodes:e,rootId:n,activeRoles:a,onToggleRole:i}){const o=e[n];if(!o)return null;const u=!!a&&!!i,f=o.children.map(b=>e[b]).filter(Boolean),m=new Map,h=[];for(const b of f){const j=[];for(const k of b.children){const N=e[k];N&&(j.push(N),h.push(N))}m.set(b.id,j)}const x=b=>!a||a.has(b),g=u?f.filter(b=>a.has(b.id)).length+h.filter(b=>a.has(b.id)).length:f.length+h.length,v=f.length+h.length;return l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider",children:u?"Select Target Roles":"Propagation Preview"}),u&&l.jsxs("span",{className:"text-[10px] text-white/50",children:[g,"/",v," selected"]})]}),l.jsxs("div",{className:"bg-white/5 border border-white/10 rounded-lg p-4",children:[l.jsx("div",{className:"flex justify-center mb-2",children:l.jsx("span",{className:"px-3 py-1 text-[10px] font-bold rounded border-2 border-white/20 bg-white/5 text-white/30 uppercase",children:"CEO"})}),f.length>0&&l.jsx("div",{className:"flex justify-center mb-1",children:l.jsx("div",{className:"w-px h-3 bg-white/15"})}),f.length>1&&l.jsx("div",{className:"flex justify-center mb-1",children:l.jsx("div",{className:"h-px bg-white/15",style:{width:`${Math.min(f.length*80,320)}px`}})}),l.jsx("div",{className:"flex justify-center gap-3 mb-2 flex-wrap",children:f.map(b=>{const j=x(b.id),k=qN[b.id]??"#888";return l.jsx(XN,{node:b,active:j,color:k,interactive:u,onToggle:i,subRoles:m.get(b.id)??[],activeRoles:a},b.id)})}),h.length>0&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"flex justify-center mb-1",children:l.jsx("div",{className:"w-px h-2 bg-white/10"})}),l.jsx("div",{className:"flex justify-center gap-2 flex-wrap",children:h.map(b=>{var C;const j=x(b.id),k=(C=f.find(_=>_.children.includes(b.id)))==null?void 0:C.id,N=k?x(k):!0,E=u&&N;return l.jsx("span",{className:`px-2 py-0.5 text-[9px] font-semibold rounded border uppercase transition-all ${E?"cursor-pointer select-none":u?"cursor-not-allowed":""} ${j&&N?"border-white/15 text-white/40":"border-white/5 text-white/15 opacity-50"}`,onClick:E?()=>i(b.id,!j):void 0,title:u?N?j?"Click to exclude":"Click to include":`Enable ${k==null?void 0:k.toUpperCase()} first`:void 0,children:b.id},b.id)})}),l.jsx("div",{className:"text-center text-[8px] text-white/30 mt-1",children:"via re-dispatch"})]})]}),l.jsx("div",{className:"text-[10px] text-gray-400 mt-1.5",children:u?`${g} role${g!==1?"s":""} will receive this wave`:`${v} role${v!==1?"s":""} will receive this wave`})]})}function XN({node:e,active:n,color:a,interactive:i,onToggle:o,subRoles:u,activeRoles:d}){const f=w.useCallback(m=>{if(!(!i||!o)){if(n){o(e.id,!1);for(const h of u)d!=null&&d.has(h.id)&&o(h.id,!1)}else if(o(e.id,!0),m.shiftKey)for(const h of u)d!=null&&d.has(h.id)||o(h.id,!0)}},[i,o,n,e.id,u,d]);return l.jsxs("div",{className:"flex flex-col items-center",children:[l.jsx("span",{className:`px-2.5 py-1 text-[10px] font-bold rounded border-2 uppercase transition-all ${i?"cursor-pointer select-none hover:scale-105":""}`,style:{borderColor:n?a:`${a}44`,color:n?a:`${a}44`,background:n?`${a}22`:"transparent",opacity:n?1:.4},onClick:f,title:i?n?"Click to exclude (disables subordinates)":"Click to include / Shift+click to include with all subordinates":void 0,children:e.id}),l.jsx("span",{className:"text-[8px] text-white/30 mt-0.5",children:i?n?"active":"off":"direct"})]})}function WN({cLevelRoles:e,orgNodes:n,rootId:a,onClose:i,onDispatch:o}){const[u,d]=w.useState(""),f=w.useRef(null),[m,h]=w.useState(()=>{const k=new Set,N=n[a];if(N)for(const E of N.children){k.add(E);const C=n[E];if(C)for(const _ of C.children)k.add(_)}return k});w.useEffect(()=>{var k;(k=f.current)==null||k.focus()},[]);const x=w.useCallback((k,N)=>{h(E=>{const C=new Set(E);return N?C.add(k):C.delete(k),C})},[]),g=e.filter(k=>m.has(k.id)).length,v=()=>{if(!u.trim()||g===0)return;const k=n[a];let N=0;if(k)for(const _ of k.children){N++;const R=n[_];R&&(N+=R.children.length)}const C=m.size>=N?void 0:Array.from(m);o(u.trim(),C),i()},b=k=>{k.key==="Enter"&&(k.metaKey||k.ctrlKey)&&v(),k.key==="Escape"&&i()},j=a&&Object.keys(n).length>0;return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:i}),l.jsxs("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[560px] z-[61] bg-[var(--wall)] rounded-2xl shadow-2xl overflow-hidden",children:[l.jsxs("div",{className:"p-5 text-white",style:{background:"linear-gradient(135deg, #B71C1C, #D32F2F)"},children:[l.jsx("div",{className:"text-lg font-bold",children:"CEO Wave"}),l.jsx("div",{className:"text-sm opacity-80 mt-0.5",children:j?"Select target roles and broadcast a directive":"Broadcast a directive to all C-Level reports"})]}),l.jsxs("div",{className:"p-5 space-y-4",children:[j&&l.jsx(YN,{orgNodes:n,rootId:a,activeRoles:m,onToggleRole:x}),!j&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Dispatching to"}),l.jsx("div",{className:"flex gap-2 flex-wrap",children:e.length>0?e.map(k=>l.jsxs("span",{className:"px-3 py-1.5 text-xs font-semibold rounded-lg border-2 border-red-200 bg-red-50 text-red-800",children:[k.id.toUpperCase()," · ",k.name]},k.id)):l.jsx("span",{className:"text-xs text-gray-400 italic",children:"No C-Level roles found"})}),l.jsx("div",{className:"text-[10px] text-gray-400 mt-1",children:"Each C-Level receives the directive and delegates to their reports"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Directive"}),l.jsx("textarea",{ref:f,value:u,onChange:k=>d(k.target.value),onKeyDown:b,placeholder:"e.g. Report current status across all departments",className:"w-full h-28 p-3 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 placeholder-white/25 resize-none focus:outline-none focus:border-white/25 transition-colors"}),l.jsx("div",{className:"text-[10px] text-gray-400 mt-1",children:"Cmd+Enter to dispatch"})]})]}),l.jsxs("div",{className:"flex justify-end gap-3 px-5 pb-5",children:[l.jsx("button",{onClick:i,className:"px-4 py-2 text-sm rounded-lg border border-white/15 text-white/60 hover:bg-white/5 cursor-pointer",children:"Cancel"}),l.jsxs("button",{onClick:v,disabled:!u.trim()||g===0,className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#B71C1C"},children:["Dispatch to ",g," Role",g!==1?"s":""]})]})]})]})}function VN(){const e=w.useRef(null),n=w.useRef(0),a=w.useCallback((o,u,d)=>{e.current&&e.current.abort();const f=new AbortController;e.current=f,n.current=0;const h=`/api/waves/${o}/stream?from=0`;fetch(h,{signal:f.signal}).then(async x=>{if(!x.ok||!x.body){console.error(`[WaveStream] Failed to connect: ${x.status}`);return}console.log(`[WaveStream] Connected to wave=${o}`);const g=x.body.getReader(),v=new TextDecoder;let b="",j="",k=Date.now();const N=6e4,E=setInterval(()=>{Date.now()-k>N&&(console.warn("[WaveStream] Stale connection — no data for 60s"),f.abort(),clearInterval(E))},1e4);try{for(;;){const{done:C,value:_}=await g.read();if(C)break;k=Date.now(),b+=v.decode(_,{stream:!0});const R=b.split(`
|
|
83
|
+
`);b=R.pop()??"";for(const L of R)if(L.startsWith("event: "))j=L.slice(7).trim();else if(L.startsWith("data: ")){try{const F=JSON.parse(L.slice(6));GN(j,F,u,d)}catch{}j=""}}}finally{clearInterval(E)}}).catch(x=>{x.name!=="AbortError"&&console.error("[WaveStream] Connection error:",x)})},[]),i=w.useCallback(()=>{e.current&&(e.current.abort(),e.current=null)},[]);return{connectWaveStream:a,disconnectWaveStream:i}}function GN(e,n,a,i){switch(e){case"wave:event":KN(n,a);break;case"wave:role-attached":PN(n,a,i);break;case"wave:role-detached":QN(n,a);break;case"wave:done":ZN(a);break}}function KN(e,n){const{event:a,sessionId:i}=e,{roleId:o}=a;n(u=>{const d=new Map(u),f=d.get(o);if(!f||f.events.some(h=>h.seq===a.seq&&h.roleId===a.roleId))return u;const m={...f,sessionId:i||f.sessionId,events:[...f.events,a]};return a.type==="job:start"?(m.status="running",m.streamStatus="streaming"):a.type==="job:done"?(m.status="done",m.streamStatus="done"):a.type==="job:error"?(m.status="error",m.streamStatus="error"):a.type==="job:awaiting_input"?(m.status="awaiting_input",m.streamStatus="done"):a.type==="job:reply"&&(m.status="running",m.streamStatus="streaming"),d.set(o,m),d})}function PN(e,n,a){const{sessionId:i,roleId:o}=e;n(u=>{const d=new Map(u),f=d.get(o);if(f)d.set(o,{...f,sessionId:i,status:"running",streamStatus:"streaming"});else{const m=a[o];d.set(o,{sessionId:i,roleId:o,roleName:(m==null?void 0:m.name)??o,children:(m==null?void 0:m.children)??[],status:"running",events:[],streamStatus:"streaming"})}return d})}function QN(e,n){const{roleId:a,reason:i}=e,o=i==="error"?"error":"done";n(u=>{const d=new Map(u),f=d.get(a);return!f||f.status==="done"||f.status==="error"?u:(d.set(a,{...f,status:o,streamStatus:o==="error"?"error":"done"}),d)})}function ZN(e){e(n=>{const a=new Map(n);let i=!1;for(const[o,u]of a)u.status==="waiting"&&(a.set(o,{...u,status:"not-dispatched"}),i=!0);return i?a:n})}function uv(e,n,a,i){const[o,u]=w.useState(new Map),[d,f]=w.useState(null),[m,h]=w.useState(new Set),x=w.useRef(new Map),g=w.useRef(o);g.current=o;const v=w.useRef(!1),{connectWaveStream:b,disconnectWaveStream:j}=VN(),k=w.useCallback(()=>{if(!a||Object.keys(n).length===0)return null;const H=new Map,X=new Set,A=q=>{const W=n[q];W&&(X.add(q),H.set(q,{sessionId:"",roleId:q,roleName:W.name,children:W.children,status:"waiting",events:[],streamStatus:"idle"}),W.children.forEach(A))},$=n[a];return $&&(H.set(a,{sessionId:"",roleId:a,roleName:"CEO",children:$.children,status:"not-dispatched",events:[],streamStatus:"idle"}),$.children.forEach(A)),{initial:H,allRoles:X}},[n,a]);w.useEffect(()=>{if(v.current)if(e.length>0)v.current=!1;else return;const H=k();if(!H)return;const{initial:X,allRoles:A}=H;for(const $ of e){const q=X.get($.roleId);q&&(q.sessionId=$.sessionId,q.status="running",q.streamStatus="connecting")}u(X),h($=>{if($.size===0){const q=new Set(A);return q.delete(a),q}return $}),e.length>0&&f($=>$??e[0].roleId)},[e,n,a,k]);const N=w.useCallback(H=>{h(X=>{const A=new Set(X);return A.has(H)?A.delete(H):A.add(H),A})},[]),E=w.useCallback(H=>{for(const[,X]of x.current)X.controller.abort();x.current.clear(),v.current=!0,u(H);for(const[X,A]of H)if(X!==a&&A.events.length>0){f(X);break}},[a]),C=w.useCallback((H,X)=>{const A=x.current.get(H);if(A&&!A.controller.signal.aborted){console.log(`[WaveTree] connectStream SKIP (already connected) → role=${X} session=${H}`);return}A&&A.controller.abort(),console.log(`[WaveTree] connectStream → role=${X} session=${H}`),u(ie=>{const P=new Map(ie),Y=P.get(X);return Y&&P.set(X,{...Y,sessionId:H,status:"running",streamStatus:"connecting",events:[]}),P});const $=new AbortController,q={controller:$,lastSeq:-1};x.current.set(H,q);const W=`/api/sessions/${H}/stream?from=0`;fetch(W,{signal:$.signal}).then(async ie=>{if(!ie.ok||!ie.body){u(G=>{const D=new Map(G),B=D.get(X);return B&&D.set(X,{...B,streamStatus:"error"}),D});return}console.log(`[WaveTree SSE] connected → role=${X} status=${ie.status}`),u(G=>{const D=new Map(G),B=D.get(X);return B&&D.set(X,{...B,streamStatus:"streaming",status:"running"}),D});const P=ie.body.getReader(),Y=new TextDecoder;let oe="",de="";for(;;){const{done:G,value:D}=await P.read();if(G)break;oe+=Y.decode(D,{stream:!0});const B=oe.split(`
|
|
84
|
+
`);oe=B.pop()??"";for(const U of B)if(U.startsWith("event: "))de=U.slice(7).trim();else if(U.startsWith("data: ")){try{const T=JSON.parse(U.slice(6));if(console.log(`[WaveTree SSE] role=${X} event=${de} type=${(T==null?void 0:T.type)??"?"} seq=${(T==null?void 0:T.seq)??"?"}`),de==="activity"){const se=T;se.seq>q.lastSeq&&(q.lastSeq=se.seq),u(ge=>{const pe=new Map(ge),Re=pe.get(X);if(!Re||Re.events.some(He=>He.seq===se.seq))return ge;const Ie={...Re,events:[...Re.events,se]};if(se.type==="dispatch:start"&&se.data.childJobId){const He=se.data.targetRoleId??se.data.roleId,ot=se.data.childSessionId;if(console.log(`[WaveTree] dispatch:start → target=${He} childSession=${ot??"none"} from=${X}`),He&&ot){const Je=pe.get(He);Je&&(pe.set(He,{...Je,sessionId:ot,status:"running",streamStatus:"connecting"}),setTimeout(()=>C(ot,He),0))}}return se.type==="job:done"?(Ie.status="done",Ie.streamStatus="done"):se.type==="job:error"?(Ie.status="error",Ie.streamStatus="error"):se.type==="job:awaiting_input"?(Ie.status="awaiting_input",Ie.streamStatus="done"):se.type==="job:reply"&&(Ie.status="running",Ie.streamStatus="streaming"),pe.set(X,Ie),pe})}else if(de==="stream:end"){const se=T.reason;se!=="replied"&&u(ge=>{const pe=new Map(ge),Re=pe.get(X);if(!Re)return ge;const Ie=se==="error"?"error":se==="awaiting_input"?"awaiting_input":"done";return pe.set(X,{...Re,status:Re.status==="running"?Ie:Re.status,streamStatus:Ie==="error"?"error":"done"}),pe})}}catch{}de=""}}}).catch(ie=>{ie.name!=="AbortError"&&u(P=>{const Y=new Map(P),oe=Y.get(X);return oe&&Y.set(X,{...oe,streamStatus:"error"}),Y})})},[]),_=w.useRef(new Set),R=w.useRef(!1);w.useEffect(()=>{if(e.length===0)return;if(i)return R.current=!0,b(i,u,n),()=>{j(),R.current=!1};R.current=!1;const H=new Set;for(const X of e)H.add(X.sessionId),C(X.sessionId,X.roleId);return _.current=H,()=>{for(const X of _.current){const A=x.current.get(X);A&&(A.controller.abort(),x.current.delete(X))}_.current.clear()}},[e,C,i,b,j,n]);const L=(()=>{let H=0,X=0,A=0,$=0;for(const[q,W]of o)q!==a&&($++,W.status==="done"?H++:W.status==="running"?X++:W.status==="awaiting_input"&&A++);return{done:H,total:$,running:X,awaitingInput:A}})(),F=L.total>0&&L.running===0&&L.awaitingInput===0&&Array.from(o.values()).every(H=>H.status!=="running"&&H.status!=="awaiting_input"&&H.streamStatus!=="streaming"&&H.streamStatus!=="connecting");w.useEffect(()=>{F&&u(H=>{const X=new Map(H);let A=!1;for(const[$,q]of X)q.status==="waiting"&&(X.set($,{...q,status:"not-dispatched"}),A=!0);return A?X:H})},[F]);const I=w.useCallback(()=>{for(const[,X]of x.current)X.controller.abort();x.current.clear(),v.current=!1;const H=k();if(H){u(H.initial);const X=new Set(H.allRoles);X.delete(a),h(X)}f(a)},[k,a]);return{nodes:o,selectedRoleId:d,selectNode:f,checkedRoles:m,toggleCheck:N,setCheckedRoles:h,progress:L,allDone:F,connectStream:C,injectStaticNodes:E,reset:I}}const Vg={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"},Sa=130,Pr=44,Gg=80;function JN(e,n){if(!e.get(n))return{layout:[],width:300,height:200};const i=[],o=[],u=[{id:n,depth:0,parentId:null}],d=new Set;for(;u.length>0;){const{id:x,depth:g,parentId:v}=u.shift();if(d.has(x))continue;for(d.add(x);o.length<=g;)o.push([]);o[g].push(x),i.push({roleId:x,x:0,y:g*Gg+20,parentId:v});const b=e.get(x);if(b)for(const j of b.children)e.has(j)&&!d.has(j)&&u.push({id:j,depth:g+1,parentId:x})}const f=Math.max(...o.map(x=>x.length))*(Sa+16),m=Math.max(f,280);for(const x of o){const g=x.length*(Sa+16)-16,v=(m-g)/2;x.forEach((b,j)=>{const k=i.find(N=>N.roleId===b);k&&(k.x=v+j*(Sa+16))})}const h=o.length*Gg+40;return{layout:i,width:m,height:h}}function dv({nodes:e,rootId:n,selectedRoleId:a,onSelectNode:i,checkedRoles:o,onToggleCheck:u,eligibleRoles:d}){const{layout:f,width:m,height:h}=JN(e,n),x=!!u,g=b=>{const j=f.find(k=>k.roleId===b);return j?{cx:j.x+Sa/2,cy:j.y+Pr/2}:{cx:0,cy:0}},v=b=>{switch(b.status){case"running":return Vg[b.roleId]??"#FBBF24";case"awaiting_input":return"#F59E0B";case"done":return"#2E7D32";case"error":return"#C62828";case"not-dispatched":return"#666";default:return"#888"}};return l.jsxs("svg",{viewBox:`0 0 ${m} ${h}`,width:Math.max(m,280),height:h,className:"block",style:{minWidth:m},children:[l.jsx("defs",{children:l.jsxs("filter",{id:"glow",children:[l.jsx("feGaussianBlur",{stdDeviation:"2",result:"blur"}),l.jsxs("feMerge",{children:[l.jsx("feMergeNode",{in:"blur"}),l.jsx("feMergeNode",{in:"SourceGraphic"})]})]})}),f.filter(b=>b.parentId).map(b=>{const j=g(b.parentId),k=g(b.roleId),N=e.get(b.roleId),E=e.get(b.parentId);let C="rgba(180,200,240,0.15)",_="4 4",R="";return(N==null?void 0:N.status)==="done"||(E==null?void 0:E.status)==="done"?(C="#2E7D3266",_=""):(N==null?void 0:N.status)==="awaiting_input"?(C="#F59E0B",_="6 4",R="wave-edge-flow"):(N==null?void 0:N.status)==="running"&&(C=Vg[b.roleId]??"#FBBF24",_="6 4",R="wave-edge-flow"),l.jsx("line",{x1:j.cx,y1:j.cy+Pr/2-4,x2:k.cx,y2:k.cy-Pr/2+4,stroke:C,strokeWidth:1.5,strokeDasharray:_,className:R},`${b.parentId}-${b.roleId}`)}),f.map(b=>{const j=e.get(b.roleId);if(!j)return null;const k=v(j),N=a===b.roleId,E=b.roleId===n,C=(o==null?void 0:o.has(b.roleId))??!1,_=E?N?.7:.5:j.status==="not-dispatched"&&!C?.35:1;return l.jsxs("g",{transform:`translate(${b.x}, ${b.y})`,style:{cursor:"pointer",opacity:_},onClick:()=>i(b.roleId),children:[l.jsx("rect",{x:0,y:0,width:Sa,height:Pr,rx:8,ry:8,fill:"var(--terminal-bg-deeper, #181825)",stroke:N?"#fff":C?"#EF5350":k,strokeWidth:N||C?2:1.5,strokeDasharray:j.status==="not-dispatched"&&!C?"4 3":""}),l.jsx("circle",{cx:14,cy:Pr/2,r:4,fill:k,filter:j.status==="running"||j.status==="awaiting_input"?"url(#glow)":void 0,children:(j.status==="running"||j.status==="awaiting_input")&&l.jsx("animate",{attributeName:"opacity",values:"1;0.4;1",dur:"1.5s",repeatCount:"indefinite"})}),l.jsx("text",{x:26,y:Pr/2-4,fill:"var(--terminal-text, #fff)",fontSize:10,fontWeight:700,fontFamily:"var(--pixel-font)",children:j.roleId.toUpperCase()}),l.jsx("text",{x:26,y:Pr/2+10,fill:"var(--terminal-text-muted, #888)",fontSize:8,fontFamily:"var(--pixel-font)",children:j.status==="running"?"Working...":j.status==="awaiting_input"?"Awaiting Reply":j.status==="done"?"Complete":j.status==="error"?"Error":j.status==="waiting"?"Waiting":""}),j.status==="done"&&!x&&l.jsx("text",{x:Sa-18,y:Pr/2+4,fontSize:14,fill:"#2E7D32",children:"✓"}),j.status==="error"&&!x&&l.jsx("text",{x:Sa-18,y:Pr/2+4,fontSize:14,fill:"#C62828",children:"✗"}),x&&!E&&(()=>{const R=!d||d.has(b.roleId);return l.jsxs("g",{onClick:L=>{L.stopPropagation(),R&&(u==null||u(b.roleId))},style:{cursor:R?"pointer":"default",opacity:R?1:.2},children:[l.jsx("rect",{x:Sa-24,y:Pr/2-10,width:20,height:20,fill:"transparent"}),l.jsx("rect",{x:Sa-20,y:Pr/2-6,width:12,height:12,rx:2,ry:2,fill:C?"#EF5350":"transparent",stroke:C?"#EF5350":"#666",strokeWidth:1.5}),C&&l.jsx("text",{x:Sa-18,y:Pr/2+4,fontSize:10,fontWeight:700,fill:"#fff",children:"✓"})]})})()]},b.roleId)})]})}const e6={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function t6({directive:e,rootJobs:n,orgNodes:a,rootRoleId:i,waveId:o,onClose:u,onMinimize:d,onDone:f,onOpenKnowledgeDoc:m,onSave:h}){const{nodes:x,selectedRoleId:g,selectNode:v,progress:b,allDone:j,connectStream:k}=uv(n,a,i,o),[N,E]=w.useState(0),[C,_]=w.useState(new Set),[R,L]=w.useState(""),[F,I]=w.useState(!1),[H,X]=w.useState(!1),A=w.useRef(null),$=w.useRef(Date.now()),q=w.useRef(!1),W=w.useCallback(async()=>{if(h){X(!0);try{const U=n.map(T=>T.jobId).filter(T=>!!T);await h(U)}catch(U){console.error("Save failed:",U)}finally{X(!1),u()}}},[h,n,u]),ie=w.useCallback(async()=>{if(!g||!R.trim())return;const U=x.get(g);if(!(!(U!=null&&U.sessionId)||U.status!=="awaiting_input"&&U.status!=="done")){I(!0);try{await ye.replyToSession(U.sessionId,R.trim()),L(""),k(U.sessionId,g)}catch(T){console.error("Reply failed:",T)}finally{I(!1)}}},[g,R,x,k]),P=w.useCallback(async U=>{const T=x.get(U);if(T!=null&&T.sessionId)try{await ye.abortSession(T.sessionId)}catch(se){console.error("Abort failed:",se)}},[x]),Y=w.useCallback(async()=>{for(const[,U]of x)if((U.status==="running"||U.status==="awaiting_input")&&U.sessionId)try{await ye.abortSession(U.sessionId)}catch{}},[x]);w.useEffect(()=>{const U=setInterval(()=>{E(Math.floor((Date.now()-$.current)/1e3))},1e3);return()=>clearInterval(U)},[]);const oe=w.useRef(!1);w.useEffect(()=>{const U=A.current;if(!U)return;const T=()=>{const se=U.scrollHeight-U.scrollTop-U.clientHeight<60;oe.current=!se};return U.addEventListener("scroll",T),()=>U.removeEventListener("scroll",T)},[]),w.useEffect(()=>{oe.current=!1,A.current&&(A.current.scrollTop=A.current.scrollHeight)},[g]),w.useEffect(()=>{A.current&&!oe.current&&(A.current.scrollTop=A.current.scrollHeight)},[x]),w.useEffect(()=>{j&&!q.current&&(q.current=!0,f==null||f()),!j&&q.current&&(q.current=!1)},[j,f]);const de=U=>`${Math.floor(U/60)}:${String(U%60).padStart(2,"0")}`,G=g?x.get(g):null,D=g?e6[g]??"#888":"#888",B=U=>{_(T=>{const se=new Set(T);return se.has(U)?se.delete(U):se.add(U),se})};return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm pointer-events-none"}),l.jsxs("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[960px] max-w-[95vw] h-[85vh] z-[61] bg-[var(--terminal-bg)] rounded-2xl shadow-2xl overflow-hidden flex flex-col",children:[l.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-[var(--terminal-border)] shrink-0",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-3 h-3 rounded-full",style:{background:j?"#2E7D32":"#B71C1C",animation:j?void 0:"wave-pulse 2s ease-in-out infinite"}}),l.jsx("div",{children:l.jsx("span",{className:"text-[var(--terminal-text)] font-bold text-sm",children:j?"WAVE COMPLETE":"WAVE COMMAND CENTER"})})]}),l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs font-mono",children:de(N)}),b.awaitingInput>0&&l.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full font-semibold",style:{background:"#F59E0B22",color:"#F59E0B"},children:[b.awaitingInput," awaiting reply"]}),l.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full font-semibold",style:{background:j?"#2E7D3222":"#B71C1C22",color:j?"#2E7D32":"#B71C1C"},children:[b.done,"/",b.total," done"]}),!j&&(b.running>0||b.awaitingInput>0)&&l.jsx("button",{onClick:Y,className:"text-xs px-2 py-0.5 rounded font-semibold cursor-pointer",style:{background:"#C6282822",color:"#C62828",border:"1px solid #C6282844"},title:"Stop all running jobs",children:"Stop All"}),l.jsx("button",{onClick:d,title:"Minimize",className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text)] text-sm cursor-pointer px-1",children:"–"}),l.jsx("button",{onClick:u,className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text)] text-lg cursor-pointer",title:j?"Dismiss wave":"Close (jobs keep running)",children:"×"})]})]}),l.jsx("div",{className:"px-5 py-2 border-b border-[var(--terminal-border)] shrink-0",children:l.jsxs("span",{className:"text-[var(--terminal-text-secondary)] text-xs italic",children:["“",e,"”"]})}),l.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[l.jsxs("div",{className:"shrink-0 border-b border-[var(--terminal-border)] flex flex-col",children:[l.jsxs("div",{className:"flex items-center gap-3 px-4 py-1.5",children:[l.jsx("span",{className:"text-[10px] font-bold text-[var(--terminal-text-secondary)] uppercase tracking-wider",children:"Org Propagation"}),l.jsx("div",{className:"flex gap-x-3 ml-auto",children:[{label:"running",color:"#FBBF24",dot:!0},{label:"awaiting",color:"#F59E0B",dot:!0},{label:"done",color:"#2E7D32",dot:!1},{label:"waiting",color:"#888",dot:!1},{label:"error",color:"#C62828",dot:!1}].map(U=>l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:U.color,animation:U.dot?"wave-pulse 1.5s ease-in-out infinite":void 0}}),l.jsx("span",{className:"text-[8px] text-[var(--terminal-text-muted)]",children:U.label})]},U.label))})]}),l.jsx("div",{className:"overflow-x-auto overflow-y-auto px-3 pb-2",style:{maxHeight:"35vh"},children:l.jsx(dv,{nodes:x,rootId:i,selectedRoleId:g,onSelectNode:v})})]}),l.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[G&&l.jsxs("div",{className:"px-4 py-2 border-b border-[var(--terminal-border)] shrink-0 flex items-center gap-2",children:[l.jsx("div",{className:"w-2 h-2 rounded-full",style:{background:D}}),l.jsx("span",{className:"text-[var(--terminal-text)] font-bold text-xs",children:G.roleId.toUpperCase()}),l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs",children:G.roleName}),l.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full font-semibold",style:{background:G.status==="awaiting_input"?"#F59E0B22":`${D}22`,color:G.status==="awaiting_input"?"#F59E0B":D},children:G.status==="running"?"Working":G.status==="done"?"Complete":G.status==="error"?"Error":G.status==="waiting"?"Waiting":G.status==="awaiting_input"?"Awaiting Reply":"Not dispatched"}),(G.status==="running"||G.status==="awaiting_input")&&G.sessionId&&l.jsx("button",{onClick:()=>P(G.roleId),className:"text-[10px] px-2 py-0.5 rounded font-semibold cursor-pointer ml-1",style:{background:"#C6282822",color:"#C62828",border:"1px solid #C6282844"},title:"Force stop this job",children:"Stop"})]}),l.jsxs("div",{ref:A,className:"flex-1 min-h-0 overflow-y-auto p-4 space-y-1 text-xs font-mono select-text",children:[G&&G.events.length===0&&l.jsx("div",{className:"text-[var(--terminal-text-muted)]",children:G.status==="waiting"?"Waiting for dispatch...":G.status==="running"?"Connecting to activity stream...":G.status==="not-dispatched"?"This role was not dispatched in this wave.":""}),G==null?void 0:G.events.map(U=>l.jsx(Km,{event:U,isThinkingCollapsed:C.has(U.seq),onToggleThinking:()=>B(U.seq),onNavigateToJob:T=>{const se=G==null?void 0:G.events.find(pe=>pe.type==="dispatch:start"&&pe.data.childJobId===T),ge=se==null?void 0:se.data.targetRoleId;ge&&x.has(ge)&&v(ge)},onOpenKnowledgeDoc:m},U.seq)),(G==null?void 0:G.status)==="running"&&l.jsx("span",{className:"inline-block w-2 h-4 bg-green-400 animate-pulse ml-0.5"})]}),(G==null?void 0:G.status)==="awaiting_input"&&l.jsxs("div",{className:"px-4 py-3 border-t border-[var(--terminal-border)] shrink-0",style:{background:"#F59E0B0A"},children:[l.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[l.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:"#F59E0B",animation:"wave-pulse 1.5s ease-in-out infinite"}}),l.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"#F59E0B"},children:[G.roleName," is waiting for your response"]})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{type:"text",value:R,onChange:U=>L(U.target.value),onKeyDown:U=>{U.key==="Enter"&&!U.shiftKey&&(U.preventDefault(),ie())},placeholder:"Type your response...",disabled:F,className:"flex-1 px-3 py-1.5 text-xs rounded border bg-[var(--terminal-bg)] text-[var(--terminal-text)] border-[var(--terminal-border)] outline-none focus:border-[#F59E0B]",autoFocus:!0}),l.jsx("button",{onClick:ie,disabled:F||!R.trim(),className:"px-4 py-1.5 text-xs rounded font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#F59E0B",color:"#000"},children:F?"...":"Reply"})]})]}),(G==null?void 0:G.status)==="done"&&G.sessionId&&l.jsxs("div",{className:"px-4 py-3 border-t border-[var(--terminal-border)] shrink-0",style:{background:"#1565C00A"},children:[l.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[l.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"#64B5F6"},children:["Follow-up to ",G.roleName]}),l.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:"Send a follow-up directive"})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{type:"text",value:R,onChange:U=>L(U.target.value),onKeyDown:U=>{U.key==="Enter"&&!U.shiftKey&&(U.preventDefault(),ie())},placeholder:"e.g., 좋아 KB-3 진행해, Engineer에게 시켜...",disabled:F,className:"flex-1 px-3 py-1.5 text-xs rounded border bg-[var(--terminal-bg)] text-[var(--terminal-text)] border-[var(--terminal-border)] outline-none focus:border-[#64B5F6]"}),l.jsx("button",{onClick:ie,disabled:F||!R.trim(),className:"px-4 py-1.5 text-xs rounded font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#1565C0",color:"#fff"},children:F?"...":"Send"})]})]}),!G&&l.jsx("div",{className:"flex-1 flex items-center justify-center text-[var(--terminal-text-muted)] text-xs",children:"Click a node in the org tree to view activity"}),l.jsxs("div",{className:"px-4 py-2 border-t border-[var(--terminal-border)] flex items-center justify-between shrink-0",children:[l.jsx("div",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:G&&G.events.length>0&&`${G.events.length} events`}),j&&l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{onClick:u,className:"px-4 py-1.5 text-xs rounded-lg font-semibold cursor-pointer",style:{background:"rgba(255,255,255,0.08)",color:"var(--terminal-text-muted)"},children:"Dismiss"}),h&&l.jsx("button",{onClick:W,disabled:H,className:"px-4 py-1.5 text-xs text-white rounded-lg font-semibold cursor-pointer disabled:opacity-50",style:{background:"#2E7D32"},children:H?"Saving...":"Save Wave"})]})]})]})]})]})]})}const n6={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function Kg({orgNodes:e,rootRoleId:n,cLevelRoles:a,pastWaves:i,activeWaves:o,onDispatch:u,onClose:d,onDone:f,onSave:m,onOpenKnowledgeDoc:h,onRefreshWaves:x,terminalWidth:g=0,onMaximize:v,inline:b=!1,onOpenSaveModal:j}){const[k,N]=w.useState(""),[E,C]=w.useState(null),[_,R]=w.useState(!1),[L,F]=w.useState(o.length>0?0:-1),[I,H]=w.useState(!1),X=w.useRef(null),A=L>=0?o[L]??null:null,$=w.useMemo(()=>[],[]),q=(A==null?void 0:A.rootJobs)??$,W=uv(q,e,n,(A==null?void 0:A.id)??null);w.useEffect(()=>{if(E){const te=r6(e,n,E.roles);W.injectStaticNodes(te);for(const $e of E.roles??[])if($e.status==="running"&&$e.jobId){const We=te.get($e.roleId);We!=null&&We.sessionId&&setTimeout(()=>W.connectStream(We.sessionId,$e.roleId),100)}}},[E,e,n]),w.useEffect(()=>{!W.selectedRoleId&&n&&W.selectNode(n)},[n]);const ie=w.useRef(o.length);w.useEffect(()=>{const te=o.length>ie.current;ie.current=o.length,te?(F(0),C(null),H(!1)):o.length>0&&L<0&&!I&&(F(0),C(null))},[o.length,L,I]);const[P,Y]=w.useState(null),oe=w.useMemo(()=>{if(!P)return null;const te=P.modified.length+P.untracked.length;return{branch:P.branch,dirty:te>0,count:te}},[P]),de=w.useCallback(()=>{ye.getSaveStatus("code").then(te=>{Y({dirty:te.modified.length+te.untracked.length>0,modified:te.modified,untracked:te.untracked,lastCommit:te.lastCommit,branch:te.branch})}).catch(()=>{})},[]);w.useEffect(()=>{de()},[de]);const[G,D]=w.useState(0);w.useEffect(()=>{if(!A)return;const te=setInterval(()=>{D(Math.floor((Date.now()-A.startedAt)/1e3))},1e3);return()=>clearInterval(te)},[A]);const[B,U]=w.useState(""),[T,se]=w.useState(!1),[ge,pe]=w.useState([]),[Re,Ie]=w.useState(!1),[He,ot]=w.useState(null),Je=w.useRef(null);w.useEffect(()=>{if(He){const te=setTimeout(()=>ot(null),3e3);return()=>clearTimeout(te)}},[He]);const tt=w.useCallback(async te=>["image/png","image/jpeg","image/gif","image/webp"].includes(te.type)?te.size>5*1024*1024?(ot(`Too large: ${(te.size/1024/1024).toFixed(1)}MB. Max 5MB.`),null):new Promise(We=>{const Pe=new FileReader;Pe.onload=()=>{const Sn=Pe.result.split(",")[1];We({type:"image",data:Sn,name:te.name,mediaType:te.type})},Pe.onerror=()=>{ot("Failed to read file"),We(null)},Pe.readAsDataURL(te)}):(ot(`Unsupported: ${te.type}. Use PNG, JPG, GIF, or WebP.`),null),[]),Ee=w.useCallback(async te=>{const $e=[];for(const We of Array.from(te)){const Pe=await tt(We);Pe&&$e.push(Pe)}$e.length>0&&pe(We=>[...We,...$e])},[tt]),Ae=w.useCallback(te=>{te.preventDefault(),te.stopPropagation(),Ie(!0)},[]),yt=w.useCallback(te=>{te.preventDefault(),te.stopPropagation(),Ie(!1)},[]),dt=w.useCallback(te=>{te.preventDefault(),te.stopPropagation(),Ie(!1),te.dataTransfer.files.length>0&&Ee(te.dataTransfer.files)},[Ee]),xt=w.useCallback(te=>{const $e=[];for(let We=0;We<te.clipboardData.items.length;We++){const Pe=te.clipboardData.items[We];if(Pe.type.startsWith("image/")){const Sn=Pe.getAsFile();Sn&&$e.push(Sn)}}$e.length>0&&(te.preventDefault(),Ee($e))},[Ee]),[jt,Wt]=w.useState(320),Tt=w.useRef(!1),Ct=w.useRef(0),Bn=w.useRef(0),me=w.useCallback(te=>{te.preventDefault(),Tt.current=!0,Ct.current=te.clientX,Bn.current=jt;const $e=Pe=>{if(!Tt.current)return;const Sn=Ct.current-Pe.clientX;Wt(Math.max(200,Math.min(500,Bn.current+Sn)))},We=()=>{Tt.current=!1,window.removeEventListener("mousemove",$e),window.removeEventListener("mouseup",We)};window.addEventListener("mousemove",$e),window.addEventListener("mouseup",We)},[jt]),[Se,Ne]=w.useState(new Set),K=w.useRef(null),ue=w.useRef(!1);w.useEffect(()=>{const te=K.current;if(!te)return;const $e=()=>{const We=te.scrollHeight-te.scrollTop-te.clientHeight<60;ue.current=!We};return te.addEventListener("scroll",$e),()=>te.removeEventListener("scroll",$e)},[]),w.useEffect(()=>{!ue.current&&K.current&&(K.current.scrollTop=K.current.scrollHeight)},[W.nodes,W.selectedRoleId]);const ne=W.selectedRoleId?W.nodes.get(W.selectedRoleId)??null:null,ve=ne?n6[ne.roleId]??"#888":"#888",we=W.progress.running>0||W.progress.awaitingInput>0,ze=W.selectedRoleId===n,_e=!!E&&!A,Be=(A==null?void 0:A.directive)??(E==null?void 0:E.directive)??"",qe=w.useCallback(te=>{const $e=new Set,We=[te];for(;We.length>0;){const Pe=We.shift();if($e.has(Pe))continue;$e.add(Pe);const Sn=e[Pe];Sn&&We.push(...Sn.children)}return $e},[e]),at=w.useMemo(()=>{if(!W.selectedRoleId)return new Set;const te=qe(W.selectedRoleId);return te.delete(n),te},[W.selectedRoleId,qe,n]),Ke=w.useRef(null);w.useEffect(()=>{if(W.selectedRoleId===Ke.current||(Ke.current=W.selectedRoleId,!W.selectedRoleId))return;const te=qe(W.selectedRoleId);te.delete(n),W.setCheckedRoles(te)},[W.selectedRoleId,qe,n]);const bt=W.checkedRoles.size,Me=()=>{if(!k.trim()&&ge.length===0||bt===0)return;const $e=Array.from(W.nodes.keys()).filter(Pe=>Pe!==n).every(Pe=>W.checkedRoles.has(Pe)),We=ge.length>0?ge:void 0;u(k.trim(),$e?void 0:Array.from(W.checkedRoles),We),N(""),pe([])},Ue=te=>{te.key==="Enter"&&(te.metaKey||te.ctrlKey)&&(te.preventDefault(),Me()),te.key==="Escape"&&d()},_t=w.useCallback(async()=>{if(!W.selectedRoleId||!B.trim()&&ge.length===0)return;const te=W.nodes.get(W.selectedRoleId);if(!te)return;const $e=ge.length>0?ge:void 0;se(!0);try{if(te.status==="awaiting_input"&&te.sessionId){const We=await ye.replyToSession(te.sessionId,B.trim(),$e);U(""),pe([]),W.connectStream(We.sessionId||te.sessionId,W.selectedRoleId)}else{const We=(A==null?void 0:A.id)??(E==null?void 0:E.waveId)??(E==null?void 0:E.id),Pe=await ye.startJob({type:"assign",roleId:W.selectedRoleId,task:B.trim(),...We&&{waveId:We},...$e&&{attachments:$e}});U(""),pe([]),Pe.sessionId&&W.connectStream(Pe.sessionId,W.selectedRoleId)}}catch(We){console.error("Reply failed:",We)}finally{se(!1)}},[W,B,ge,A,E]),Bt=w.useCallback(async te=>{const $e=W.nodes.get(te);if($e!=null&&$e.sessionId)try{await ye.abortSession($e.sessionId)}catch{}},[W.nodes]),Ot=w.useCallback(async()=>{for(const[,te]of W.nodes)if((te.status==="running"||te.status==="awaiting_input")&&te.sessionId)try{await ye.abortSession(te.sessionId)}catch{}},[W.nodes]),un=w.useCallback(async te=>{R(!0),C(null),F(-1);try{const $e=await ye.getWaveDetail(te);$e.replay&&C($e.replay)}catch($e){console.error("Failed to load wave:",$e)}finally{R(!1)}},[]),kn=w.useRef(!1);w.useEffect(()=>{W.allDone&&!kn.current&&A&&(kn.current=!0,de(),f==null||f())},[W.allDone,A,f,de]);const J=w.useCallback(async()=>{if(!m||!A)return;const te=A.rootJobs.map($e=>$e.jobId).filter($e=>!!$e);await m(A.directive,te,{waveId:A.id,sessionIds:A.sessionIds})},[m,A]),Oe=te=>{Ne($e=>{const We=new Set($e);return We.has(te)?We.delete(te):We.add(te),We})},rt=te=>{const $e=Math.floor(te/60),We=te%60;return`${$e}:${We.toString().padStart(2,"0")}`},{panelRight:Kt,panelWidth:ke,isResizing:kt,handleResizeStart:jn}=Vo(g,700,v),hn=l.jsxs(l.Fragment,{children:[!b&&l.jsxs("div",{className:"shrink-0 px-4 py-3",style:{background:"linear-gradient(180deg, #B71C1C 0%, #7f1d1d 100%)"},children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("span",{className:"text-white font-bold text-lg tracking-wide",style:{fontFamily:"var(--pixel-font)"},children:"Wave Center"}),we&&l.jsxs("span",{className:"text-white/60 text-xs",children:[W.progress.running," running"]}),l.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[v&&l.jsx("button",{onClick:v,className:"text-white/50 hover:text-white text-xs cursor-pointer",children:"Maximize"}),l.jsx("button",{onClick:d,className:"text-white/50 hover:text-white text-xl leading-none cursor-pointer px-2",children:"✕"})]})]}),l.jsx("div",{className:"text-white/60 text-xs mt-0.5",children:A?`${o.length} active wave${o.length!==1?"s":""}`:_e?"Reviewing past wave":"Broadcast directives to your organization"})]}),l.jsxs("div",{className:"flex-1 flex min-h-0",children:[l.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[(A||_e)&&l.jsxs("div",{className:"px-4 py-2 border-b flex items-center gap-3 shrink-0",style:{borderColor:"var(--terminal-border)"},children:[l.jsx("div",{className:"w-3 h-3 rounded-full shrink-0",style:{background:we?"#FBBF24":W.allDone||_e?"#2E7D32":"#B71C1C",animation:we?"wave-pulse 2s ease-in-out infinite":void 0}}),l.jsxs("span",{className:"text-[var(--terminal-text-secondary)] text-xs italic flex-1 min-w-0 truncate",children:["“",Be,"”"]}),A&&l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs font-mono shrink-0",children:rt(G)}),_e&&l.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-semibold shrink-0",style:{background:we?"#FBBF2422":"#2E7D3222",color:we?"#FBBF24":"#2E7D32"},children:we?"LIVE":"REPLAY"}),_e&&(E==null?void 0:E.startedAt)&&l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-[10px] shrink-0",children:new Date(E.startedAt).toLocaleString()}),W.progress.awaitingInput>0&&l.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-semibold shrink-0",style:{background:"#F59E0B22",color:"#F59E0B"},children:[W.progress.awaitingInput," awaiting"]}),l.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-semibold shrink-0",style:{background:W.allDone||_e&&!we?"#2E7D3222":"#B71C1C22",color:W.allDone||_e&&!we?"#2E7D32":"#B71C1C"},children:[W.progress.done,"/",W.progress.total]}),we&&l.jsx("button",{onClick:Ot,className:"text-[10px] px-2 py-0.5 rounded font-semibold cursor-pointer shrink-0",style:{background:"#C6282822",color:"#C62828",border:"1px solid #C6282844"},children:"Stop All"})]}),l.jsxs("div",{className:"shrink-0 border-b flex flex-col",style:{borderColor:"var(--terminal-border)"},children:[l.jsxs("div",{className:"flex items-center gap-3 px-4 py-1.5",children:[l.jsx("span",{className:"text-[10px] font-bold text-[var(--terminal-text-secondary)] uppercase tracking-wider",children:A||_e?"Org Propagation":"Select Target Roles"}),l.jsxs("span",{className:"ml-auto text-[10px] text-[var(--terminal-text-muted)]",children:[W.checkedRoles.size,"/",W.progress.total," selected"]}),(A||_e)&&l.jsx("div",{className:"flex gap-x-3",children:[{label:"running",color:"#FBBF24",dot:!0},{label:"awaiting",color:"#F59E0B",dot:!0},{label:"done",color:"#2E7D32",dot:!1},{label:"waiting",color:"#888",dot:!1},{label:"error",color:"#C62828",dot:!1}].map(te=>l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:te.color,animation:te.dot?"wave-pulse 1.5s ease-in-out infinite":void 0}}),l.jsx("span",{className:"text-[8px] text-[var(--terminal-text-muted)]",children:te.label})]},te.label))})]}),l.jsx("div",{className:"overflow-x-auto overflow-y-auto px-3 pb-2",style:{maxHeight:"30vh"},children:l.jsx(dv,{nodes:W.nodes,rootId:n,selectedRoleId:W.selectedRoleId,onSelectNode:W.selectNode,checkedRoles:W.checkedRoles,onToggleCheck:W.toggleCheck,eligibleRoles:at})})]}),_?l.jsx("div",{className:"flex-1 flex items-center justify-center text-[var(--terminal-text-muted)] text-sm",children:"Loading wave data..."}):ze?l.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[l.jsxs("div",{className:"px-4 py-2 border-b shrink-0 flex items-center gap-2",style:{borderColor:"var(--terminal-border)"},children:[l.jsx("div",{className:"w-2 h-2 rounded-full",style:{background:"#B71C1C"}}),l.jsx("span",{className:"text-[var(--terminal-text)] font-bold text-xs",children:"CEO"}),l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs",children:"Directive Control"}),l.jsxs("span",{className:"ml-auto text-[10px] text-[var(--terminal-text-muted)]",children:[bt," target role",bt!==1?"s":""," selected"]})]}),l.jsxs("div",{ref:K,className:"flex-1 min-h-0 overflow-y-auto p-4 space-y-2 text-xs font-mono select-text",children:[Be&&l.jsxs("div",{className:"flex items-start gap-2 pb-3 border-b",style:{borderColor:"var(--terminal-border)"},children:[l.jsx("span",{className:"text-[10px] font-bold px-1.5 py-0.5 rounded shrink-0",style:{background:"#B71C1C33",color:"#EF5350"},children:"CEO"}),l.jsxs("div",{children:[l.jsx("span",{className:"text-[var(--terminal-text-secondary)] whitespace-pre-wrap",children:Be}),A&&l.jsxs("div",{className:"text-[9px] text-[var(--terminal-text-muted)] mt-1",children:["dispatched ",rt(G)," ago to ",A.rootJobs.length," role",A.rootJobs.length!==1?"s":""]})]})]}),!Be&&!A&&l.jsx("div",{className:"text-[var(--terminal-text-muted)] text-center py-8",children:"Select target roles using checkboxes, then dispatch a directive below."})]}),l.jsxs("div",{className:"px-4 py-3 border-t shrink-0",style:{borderColor:"var(--terminal-border)",background:"var(--hud-bg-alt)"},children:[ge.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:ge.map((te,$e)=>l.jsxs("div",{className:"relative group w-14 h-14 rounded-lg overflow-hidden border border-[var(--terminal-border)] bg-[var(--terminal-inline-bg)]",children:[l.jsx("img",{src:`data:${te.mediaType};base64,${te.data}`,alt:te.name,className:"w-full h-full object-cover"}),l.jsx("button",{onClick:()=>pe(We=>We.filter((Pe,Sn)=>Sn!==$e)),className:"absolute top-0.5 right-0.5 w-4 h-4 rounded-full bg-black/70 text-white text-[9px] flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:"x"}),l.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-black/60 text-[7px] text-white truncate px-1",children:te.name})]},$e))}),He&&l.jsx("div",{className:"text-[10px] text-red-400 mb-1",children:He}),l.jsxs("div",{className:"flex gap-2 items-end",children:[l.jsx("button",{onClick:()=>{var te;return(te=Je.current)==null?void 0:te.click()},className:"w-8 h-8 rounded-lg bg-[var(--terminal-inline-bg)] border border-[var(--terminal-border)] text-[var(--terminal-text-muted)] flex items-center justify-center shrink-0 cursor-pointer hover:text-[var(--terminal-text-secondary)] transition-colors",title:"Attach image",children:l.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})})}),l.jsx("textarea",{ref:X,value:k,onChange:te=>N(te.target.value),onKeyDown:Ue,onPaste:xt,placeholder:"e.g. Report current status across all departments",rows:2,className:"flex-1 px-3 py-2 text-sm rounded-lg border bg-[var(--terminal-bg)] text-[var(--terminal-text)] outline-none resize-none",style:{borderColor:"var(--terminal-border)"}}),l.jsxs("button",{onClick:Me,disabled:!k.trim()&&ge.length===0||bt===0,className:"px-4 py-2 text-xs font-bold rounded-lg cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed shrink-0",style:{background:k.trim()&&bt>0?"#B71C1C":"#333",color:"#fff",minWidth:140},children:["Dispatch to ",bt," Role",bt!==1?"s":""]})]}),l.jsx("div",{className:"text-[9px] text-[var(--terminal-text-muted)] mt-1",children:"Cmd+Enter to dispatch"})]})]}):l.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[ne&&l.jsxs("div",{className:"px-4 py-2 border-b shrink-0 flex items-center gap-2",style:{borderColor:"var(--terminal-border)"},children:[l.jsx("div",{className:"w-2 h-2 rounded-full",style:{background:ve}}),l.jsx("span",{className:"text-[var(--terminal-text)] font-bold text-xs",children:ne.roleId.toUpperCase()}),l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs",children:ne.roleName}),l.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full font-semibold",style:{background:ne.status==="awaiting_input"?"#F59E0B22":ne.status==="running"?"#FBBF2422":`${ve}22`,color:ne.status==="awaiting_input"?"#F59E0B":ne.status==="running"?"#FBBF24":ve},children:ne.status==="running"?"Working...":ne.status==="done"?"Complete":ne.status==="error"?"Error":ne.status==="waiting"?"Waiting":ne.status==="awaiting_input"?"Awaiting Reply":"Not dispatched"}),l.jsxs("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:[ne.events.length," events"]}),(ne.status==="running"||ne.status==="awaiting_input")&&ne.sessionId&&l.jsx("button",{onClick:()=>Bt(ne.roleId),className:"text-[10px] px-2 py-0.5 rounded font-semibold cursor-pointer ml-1",style:{background:"#C6282822",color:"#C62828",border:"1px solid #C6282844"},children:"Stop"})]}),l.jsx("input",{ref:Je,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,onChange:te=>{var $e;($e=te.target.files)!=null&&$e.length&&Ee(te.target.files),te.target.value=""},className:"hidden"}),l.jsxs("div",{ref:K,className:`flex-1 min-h-0 overflow-y-auto p-4 space-y-1 text-xs font-mono select-text transition-colors ${Re?"bg-amber-500/5 ring-1 ring-inset ring-amber-500/30":""}`,onDragOver:Ae,onDragLeave:yt,onDrop:dt,children:[ne&&Be&&ne.status!=="waiting"&&ne.status!=="not-dispatched"&&l.jsxs("div",{className:"flex items-start gap-2 mb-3 pb-2 border-b",style:{borderColor:"var(--terminal-border)"},children:[l.jsx("span",{className:"text-[10px] font-bold px-1.5 py-0.5 rounded shrink-0",style:{background:"#B71C1C33",color:"#EF5350"},children:"CEO"}),l.jsx("span",{className:"text-[var(--terminal-text-secondary)] whitespace-pre-wrap",children:Be})]}),ne&&ne.events.length===0&&l.jsx("div",{className:"text-[var(--terminal-text-muted)]",children:ne.status==="waiting"?"Waiting for dispatch...":ne.status==="running"?"Connecting to activity stream...":ne.status==="not-dispatched"?"This role was not dispatched. Send a follow-up to activate.":""}),ne==null?void 0:ne.events.map((te,$e)=>{const We=ne.events,Pe=te.type==="job:start"&&$e>0,Sn=We[$e+1];if((te.type==="job:done"||te.type==="job:error"||te.type==="job:awaiting_input")&&(Sn==null?void 0:Sn.type)==="job:start")return null;if(Pe){const yn=te.data.task??"",mn=yn.match(/\[CEO Follow-up\]\n([\s\S]+)$/),Or=mn?mn[1].trim():yn;return l.jsx(w.Fragment,{children:l.jsxs("div",{className:"flex items-start gap-2 my-3 pt-2 pb-2 border-t border-b",style:{borderColor:"var(--terminal-border)"},children:[l.jsx("span",{className:"text-[10px] font-bold px-1.5 py-0.5 rounded shrink-0",style:{background:"#B71C1C33",color:"#EF5350"},children:"CEO"}),l.jsx("span",{className:"text-[var(--terminal-text-secondary)] whitespace-pre-wrap",children:Or})]})},`followup-${te.seq}`)}return l.jsx(Km,{event:te,isThinkingCollapsed:Se.has(te.seq),onToggleThinking:()=>Oe(te.seq),onNavigateToJob:yn=>{for(const[,mn]of W.nodes)if(mn.events.some(Or=>Or.data.childJobId===yn)){W.selectNode(mn.roleId);return}},onOpenKnowledgeDoc:h},te.seq)}),(ne==null?void 0:ne.status)==="running"&&l.jsx("span",{className:"inline-block w-2 h-4 bg-green-400 animate-pulse ml-0.5"}),!ne&&l.jsx("div",{className:"flex-1 flex items-center justify-center text-[var(--terminal-text-muted)] text-xs h-full",children:"Click a node in the org tree to view activity"})]}),((ne==null?void 0:ne.status)==="awaiting_input"||(ne==null?void 0:ne.status)==="done"||(ne==null?void 0:ne.status)==="not-dispatched")&&(ge.length>0||He||Re)&&l.jsxs("div",{className:"px-4 pt-2 border-t shrink-0",style:{borderColor:"var(--terminal-border)"},children:[He&&l.jsx("div",{className:"text-[10px] text-red-400 mb-1",children:He}),Re&&l.jsx("div",{className:"text-[11px] text-amber-400 text-center mb-1",children:"Drop image here"}),ge.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2 mb-1",children:ge.map((te,$e)=>l.jsxs("div",{className:"relative group w-14 h-14 rounded-lg overflow-hidden border border-[var(--terminal-border)] bg-[var(--terminal-inline-bg)]",children:[l.jsx("img",{src:`data:${te.mediaType};base64,${te.data}`,alt:te.name,className:"w-full h-full object-cover"}),l.jsx("button",{onClick:()=>pe(We=>We.filter((Pe,Sn)=>Sn!==$e)),className:"absolute top-0.5 right-0.5 w-4 h-4 rounded-full bg-black/70 text-white text-[9px] flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:"x"}),l.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-black/60 text-[7px] text-white truncate px-1",children:te.name})]},$e))})]}),(ne==null?void 0:ne.status)==="awaiting_input"&&l.jsxs("div",{className:"px-4 py-3 border-t shrink-0",style:{borderColor:"var(--terminal-border)",background:"#F59E0B0A"},children:[l.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[l.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:"#F59E0B",animation:"wave-pulse 1.5s ease-in-out infinite"}}),l.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"#F59E0B"},children:[ne.roleName," is waiting for your response"]})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:()=>{var te;return(te=Je.current)==null?void 0:te.click()},disabled:T,className:"w-7 h-7 rounded bg-[var(--terminal-inline-bg)] border border-[var(--terminal-border)] text-[var(--terminal-text-muted)] flex items-center justify-center shrink-0 cursor-pointer hover:text-[var(--terminal-text-secondary)] disabled:opacity-30 transition-colors",title:"Attach image",children:l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})})}),l.jsx("input",{type:"text",value:B,onChange:te=>U(te.target.value),onKeyDown:te=>{te.key==="Enter"&&!te.shiftKey&&(te.preventDefault(),_t())},onPaste:xt,placeholder:"Type your response...",disabled:T,className:"flex-1 px-3 py-1.5 text-xs rounded border bg-[var(--terminal-bg)] text-[var(--terminal-text)] outline-none",style:{borderColor:"var(--terminal-border)"},autoFocus:!0}),l.jsx("button",{onClick:_t,disabled:T||!B.trim()&&ge.length===0,className:"px-4 py-1.5 text-xs rounded font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#F59E0B",color:"#000"},children:T?"...":"Reply"})]})]}),ne&&(ne.status==="done"||ne.status==="not-dispatched")&&l.jsxs("div",{className:"px-4 py-3 border-t shrink-0",style:{borderColor:"var(--terminal-border)",background:"#1565C00A"},children:[l.jsx("div",{className:"flex items-center gap-2 mb-2",children:l.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"#64B5F6"},children:["Follow-up to ",ne.roleName]})}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:()=>{var te;return(te=Je.current)==null?void 0:te.click()},disabled:T,className:"w-7 h-7 rounded bg-[var(--terminal-inline-bg)] border border-[var(--terminal-border)] text-[var(--terminal-text-muted)] flex items-center justify-center shrink-0 cursor-pointer hover:text-[var(--terminal-text-secondary)] disabled:opacity-30 transition-colors",title:"Attach image",children:l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})})}),l.jsx("input",{type:"text",value:B,onChange:te=>U(te.target.value),onKeyDown:te=>{te.key==="Enter"&&!te.shiftKey&&(te.preventDefault(),_t())},onPaste:xt,placeholder:"Send a follow-up directive...",disabled:T,className:"flex-1 px-3 py-1.5 text-xs rounded border bg-[var(--terminal-bg)] text-[var(--terminal-text)] outline-none",style:{borderColor:"var(--terminal-border)"}}),l.jsx("button",{onClick:_t,disabled:T||!B.trim()&&ge.length===0,className:"px-4 py-1.5 text-xs rounded font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#1565C0",color:"#fff"},children:T?"...":"Send"})]})]}),W.allDone&&A&&m&&l.jsx("div",{className:"px-4 py-2 border-t shrink-0 flex justify-end",style:{borderColor:"var(--terminal-border)"},children:l.jsx("button",{onClick:J,className:"px-4 py-1.5 text-xs rounded font-semibold cursor-pointer",style:{background:"#1565C022",color:"#64B5F6",border:"1px solid #1565C044"},children:"Save Wave"})})]})]}),l.jsxs("div",{className:"shrink-0 border-l flex flex-col relative",style:{width:jt,borderColor:"var(--terminal-border)",background:"var(--hud-bg-alt)"},children:[l.jsx("div",{className:"absolute top-0 bottom-0 w-1.5 cursor-col-resize hover:bg-[var(--accent)] z-10",style:{left:-2},onMouseDown:me}),l.jsx("div",{className:"p-3 pb-0",children:l.jsx("button",{onClick:()=>{C(null),F(-1),H(!0),W.reset()},className:"w-full px-3 py-1.5 text-[11px] font-bold rounded-lg cursor-pointer transition-colors",style:{background:!E&&L<0?"#B71C1C":"var(--terminal-inline-bg)",color:!E&&L<0?"#fff":"var(--terminal-text-secondary)",border:"1px solid",borderColor:!E&&L<0?"#B71C1C":"var(--terminal-border)"},children:"+ New Wave"})}),o.length>0&&l.jsxs("div",{className:"p-3",children:[l.jsx("div",{className:"text-[10px] font-bold text-[var(--terminal-text-muted)] uppercase tracking-wider mb-2",children:"Active"}),l.jsx("div",{className:"flex flex-col gap-1.5",children:o.map((te,$e)=>l.jsxs("button",{onClick:()=>{F($e),C(null),H(!1)},className:"text-left p-2 rounded-lg cursor-pointer transition-colors",style:{background:L===$e&&!E?"var(--terminal-bg)":"transparent",border:L===$e&&!E?"1px solid var(--accent)":"1px solid transparent"},children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("span",{className:"w-2 h-2 rounded-full bg-red-500 shrink-0 animate-pulse"}),l.jsxs("span",{className:"text-[11px] text-[var(--terminal-text)] truncate font-medium",children:[te.directive.slice(0,40),te.directive.length>40?"...":""]})]}),l.jsxs("div",{className:"text-[9px] text-[var(--terminal-text-muted)] mt-0.5 pl-3.5",children:[te.rootJobs.length," role",te.rootJobs.length!==1?"s":""]})]},te.id))})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-3",children:[l.jsxs("div",{className:"text-[10px] font-bold text-[var(--terminal-text-muted)] uppercase tracking-wider mb-2",children:["Past Waves (",i.length,")"]}),i.length===0&&l.jsx("div",{className:"text-[10px] text-[var(--terminal-text-muted)] italic",children:"No past waves yet"}),l.jsx("div",{className:"flex flex-col gap-1.5",children:i.map(te=>l.jsx(a6,{wave:te,active:(E==null?void 0:E.id)===te.id,onLoad:()=>un(te.id)},te.id))})]}),oe&&l.jsxs("button",{onClick:j,disabled:!j,className:"px-3 py-2.5 border-t shrink-0 flex items-center gap-1.5 w-full text-left hover:bg-white/5 transition-colors cursor-pointer disabled:cursor-default",style:{borderColor:"var(--terminal-border)"},children:[l.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:oe.dirty?"var(--idle-amber)":"#2E7D32"}}),l.jsx("span",{className:"text-[10px] font-mono text-[var(--terminal-text-muted)] truncate",children:oe.branch}),oe.dirty&&l.jsxs("span",{className:"text-[9px] ml-auto shrink-0",style:{color:"var(--idle-amber)"},children:[oe.count," unsaved"]}),!oe.dirty&&l.jsx("span",{className:"text-[9px] text-green-400 ml-auto shrink-0",children:"clean"})]})]})]})]});return b?l.jsx("div",{className:"flex flex-col h-full w-full",style:{background:"var(--terminal-bg)"},children:hn}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"dimmer fixed top-0 left-0 bottom-0 bg-black/30 z-40 open",style:{right:Kt},onClick:d}),l.jsxs("div",{className:"fixed top-0 bottom-0 z-50 flex flex-col",style:{right:Kt,width:ke,background:"var(--terminal-bg)",borderLeft:"1px solid var(--terminal-border)",transition:kt?"none":"width 0.2s ease"},children:[l.jsx("div",{className:"absolute top-0 bottom-0 w-1 cursor-col-resize hover:bg-[var(--accent)] z-50",style:{left:0},onMouseDown:jn}),hn]})]})}function r6(e,n,a){const i=new Map,o=d=>{const f=e[d];!f||i.has(d)||(i.set(d,{sessionId:"",roleId:d,roleName:f.name,children:f.children,status:"not-dispatched",events:[],streamStatus:"idle"}),f.children.forEach(o))},u=e[n];u&&(i.set(n,{sessionId:"",roleId:n,roleName:"CEO",children:u.children,status:"not-dispatched",events:[],streamStatus:"idle"}),u.children.forEach(o));for(const d of a){const f=i.get(d.roleId);if(f){const m=d.status==="running";i.set(d.roleId,{...f,sessionId:d.sessionId??d.jobId??"",status:d.status||"done",events:d.events,streamStatus:m?"connecting":"done"})}for(const m of d.childJobs){const h=i.get(m.roleId);h&&i.set(m.roleId,{...h,sessionId:m.jobId??"",status:m.status||"done",events:m.events,streamStatus:"done"})}}return i}function a6({wave:e,active:n,onLoad:a}){const i=e.id.match(/^(\d{4})(\d{2})(\d{2})-(\d{2})(\d{2})/),o=i?`${i[1]}-${i[2]}-${i[3]} ${i[4]}:${i[5]}`:e.id;return l.jsx("div",{className:"rounded-lg cursor-pointer transition-colors hover:bg-[var(--terminal-bg)]",style:{border:n?"1px solid var(--accent)":"1px solid var(--terminal-border)",background:n?"var(--terminal-bg)":void 0},onClick:a,children:l.jsxs("div",{className:"p-2",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[e.hasRunning?l.jsx("span",{className:"w-1.5 h-1.5 rounded-full animate-pulse shrink-0",style:{background:"#4CAF50"}}):l.jsx("span",{className:"text-[10px]",children:"▶"}),l.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:o}),e.hasRunning?l.jsx("span",{className:"text-[9px] ml-auto animate-pulse",style:{color:"#4CAF50"},children:"running"}):e.commit?l.jsx("span",{className:"text-[9px] text-green-400 ml-auto font-mono",title:`Committed: ${e.commit.sha}`,children:e.commit.sha.slice(0,7)}):e.rolesCount?l.jsx("span",{className:"text-[9px] ml-auto",style:{color:"var(--idle-amber)"},title:"No commit recorded",children:"uncommitted"}):null]}),l.jsx("div",{className:"text-[10px] text-[var(--terminal-text-secondary)] mt-0.5 line-clamp-2 leading-relaxed",children:e.directive.slice(0,80)}),e.rolesCount?l.jsxs("div",{className:"text-[9px] text-[var(--terminal-text-muted)] mt-0.5",children:[e.rolesCount," role",e.rolesCount!==1?"s":""]}):null]})})}const l6={cto:{skinColor:"#F5CBA7",hairColor:"#2C1810",shirtColor:"#1565C0",pantsColor:"#37474F",shoeColor:"#212121",hairStyle:"short",outfitStyle:"tshirt",accessory:"glasses"},cbo:{skinColor:"#FDEBD0",hairColor:"#1A0A00",shirtColor:"#E65100",pantsColor:"#37474F",shoeColor:"#1A1A1A",hairStyle:"slicked",outfitStyle:"suit",accessory:"lapels"},pm:{skinColor:"#FDEBD0",hairColor:"#6D4C41",shirtColor:"#2E7D32",pantsColor:"#37474F",shoeColor:"#212121",hairStyle:"bun",outfitStyle:"tshirt",accessory:"blush"},engineer:{skinColor:"#F5CBA7",hairColor:"#1A1A1A",shirtColor:"#4A148C",pantsColor:"#37474F",shoeColor:"#7B1FA2",hairStyle:"messy",outfitStyle:"hoodie",accessory:"headphones"},designer:{skinColor:"#FDEBD0",hairColor:"#AD1457",shirtColor:"#AD1457",pantsColor:"#37474F",shoeColor:"#212121",hairStyle:"bob",outfitStyle:"tshirt",accessory:"beret"},qa:{skinColor:"#F5CBA7",hairColor:"#4E342E",shirtColor:"#00695C",pantsColor:"#37474F",shoeColor:"#212121",hairStyle:"short",outfitStyle:"tshirt",accessory:"badge"},"data-analyst":{skinColor:"#F5CBA7",hairColor:"#3E2723",shirtColor:"#0277BD",pantsColor:"#37474F",shoeColor:"#212121",hairStyle:"curly",outfitStyle:"vest",accessory:"none"}};function Pm(e){return l6[e]??{skinColor:"#B0BEC5",hairColor:"#78909C",shirtColor:"#607D8B",pantsColor:"#455A64",shoeColor:"#37474F"}}const fv=["#FDEBD0","#F5CBA7","#D4A07A","#C68642","#8D5524","#5C3A1E","#F3D1C7","#E8BEAC","#B07D62","#704214"],hv=["#1A0A00","#2C1810","#4E342E","#6D4C41","#8D6E63","#D4A574","#F5E6CA","#FFD700","#B71C1C","#AD1457","#4A148C","#1A237E","#004D40","#1A1A1A","#78909C","#E0E0E0"],mv=["#1565C0","#E65100","#2E7D32","#4A148C","#AD1457","#00695C","#D32F2F","#F57F17","#1B5E20","#283593","#4E342E","#37474F","#880E4F","#00838F","#6A1B9A","#FF6F00"],pv=["#37474F","#1A237E","#3E2723","#263238","#1B5E20","#455A64","#212121","#4E342E","#0D47A1","#311B92"],xv=["#212121","#1A1A1A","#37474F","#4E342E","#7B1FA2","#D32F2F","#1565C0","#F57F17","#2E7D32","#FFFFFF"],il={default:{name:"MIDNIGHT",icon:"🌃",vars:{"--floor-light":"#0d1117","--floor-dark":"#0a0e14","--hud-bg":"#0d1117","--hud-bg-alt":"#161b22","--pixel-border":"#30363d","--terminal-bg":"#0d1117","--terminal-border":"#21262d","--terminal-border-hover":"#388bfd","--terminal-text":"#e6edf3","--terminal-text-secondary":"#8b949e","--terminal-text-muted":"#484f58","--accent":"#388bfd","--active-green":"#3fb950","--idle-amber":"#d29922"}},light:{name:"DAYLIGHT",icon:"☀️",vars:{"--floor-light":"#f6f8fa","--floor-dark":"#eaeef2","--hud-bg":"#f0f3f6","--hud-bg-alt":"#e4e8ec","--pixel-border":"#c0c8d0","--terminal-bg":"#ffffff","--terminal-border":"#d0d7de","--terminal-border-hover":"#0969da","--terminal-text":"#1f2328","--terminal-text-secondary":"#484f58","--terminal-text-muted":"#6e7781","--accent":"#0969da","--active-green":"#1a7f37","--idle-amber":"#9a6700","--bar-bg":"#24292f","--bar-text":"#e6edf3","--bar-border":"#444c56","--terminal-bg-deeper":"#e8ecf0"}},retro:{name:"RETRO",icon:"🎮",vars:{"--floor-light":"#1a1410","--floor-dark":"#140f0a","--hud-bg":"#1a1410","--hud-bg-alt":"#2a2018","--pixel-border":"#5c4a32","--terminal-bg":"#1a1410","--terminal-border":"#3a2e20","--terminal-border-hover":"#d4a44e","--terminal-text":"#e8d5b0","--terminal-text-secondary":"#a08860","--terminal-text-muted":"#6b5840","--accent":"#d4a44e","--active-green":"#8bba4a","--idle-amber":"#e8a030"}},cyberpunk:{name:"NEON",icon:"🌌",vars:{"--floor-light":"#0a0014","--floor-dark":"#06000e","--hud-bg":"#0a0014","--hud-bg-alt":"#14002a","--pixel-border":"#4a1a80","--terminal-bg":"#0a0014","--terminal-border":"#2a0a50","--terminal-border-hover":"#e040fb","--terminal-text":"#e0d0ff","--terminal-text-secondary":"#9070c0","--terminal-text-muted":"#5a3a80","--accent":"#e040fb","--active-green":"#00ff88","--idle-amber":"#ffab00"}},forest:{name:"FOREST",icon:"🌲",vars:{"--floor-light":"#0a1410","--floor-dark":"#060e0a","--hud-bg":"#0a1410","--hud-bg-alt":"#142a1e","--pixel-border":"#2a5a3a","--terminal-bg":"#0a1410","--terminal-border":"#1a3a26","--terminal-border-hover":"#4ade80","--terminal-text":"#d0f0d8","--terminal-text-secondary":"#70a880","--terminal-text-muted":"#3a6848","--accent":"#4ade80","--active-green":"#86efac","--idle-amber":"#fcd34d"}},ocean:{name:"OCEAN",icon:"🌊",vars:{"--floor-light":"#0a1420","--floor-dark":"#060e18","--hud-bg":"#0a1420","--hud-bg-alt":"#142a40","--pixel-border":"#1e4a6a","--terminal-bg":"#0a1420","--terminal-border":"#163050","--terminal-border-hover":"#38bdf8","--terminal-text":"#d0e8f8","--terminal-text-secondary":"#6090b0","--terminal-text-muted":"#305070","--accent":"#38bdf8","--active-green":"#34d399","--idle-amber":"#fbbf24"}}};function i6({color:e,selected:n,onClick:a}){return l.jsx("button",{onClick:a,className:"customize-swatch",style:{background:e,outline:n?"2px solid #fff":"2px solid transparent",boxShadow:n?`0 0 0 1px ${e}, 0 0 6px ${e}88`:"none"}})}function Do({label:e,presets:n,value:a,onChange:i}){return l.jsxs("div",{className:"customize-row",children:[l.jsxs("div",{className:"customize-row-header",children:[l.jsx("span",{className:"customize-row-label",children:e}),l.jsx("div",{className:"customize-row-current",style:{background:a}})]}),l.jsx("div",{className:"customize-swatches",children:n.map(o=>l.jsx(i6,{color:o,selected:o===a,onClick:()=>i(o)},o))})]})}function Dh({label:e,items:n,value:a,onChange:i,lockInfo:o}){return l.jsxs("div",{className:"customize-row",children:[l.jsx("div",{className:"customize-row-header",children:l.jsx("span",{className:"customize-row-label",children:e})}),l.jsx("div",{className:"customize-swatches",style:{gap:4},children:n.map(u=>{const d=o?o.getLockLevel(u.id):1,f=o!=null&&o.getCost?o.getCost(u.id):0,m=u.id===a,h=o?d>o.roleLevel&&!m:!1,x=f>0&&(o==null?void 0:o.purchased)&&!o.purchased.has(u.id)&&!m,g=(o==null?void 0:o.coinBalance)!==void 0?o.coinBalance>=f:!0,v=h||!1,b=o?m&&d>o.roleLevel:!1;return l.jsxs("button",{onClick:()=>{if(!v){if(x&&!h){g&&(o!=null&&o.onPurchase)&&o.onPurchase(u.id,f);return}i(u.id===a?void 0:u.id)}},className:"customize-swatch",style:{width:"auto",height:"auto",padding:v||x?"2px 6px 12px 6px":"2px 6px",fontSize:9,fontFamily:"var(--font-pixel, monospace)",background:m?"rgba(255,255,255,0.15)":v?"rgba(255,255,255,0.02)":x?"rgba(255,200,0,0.04)":"rgba(255,255,255,0.04)",outline:m?b?"2px solid #F59E0B":"2px solid #fff":x&&!v?"2px solid rgba(255,200,0,0.3)":"2px solid transparent",color:v?"rgba(255,255,255,0.25)":x?"rgba(255,255,255,0.45)":m?"#fff":"rgba(255,255,255,0.5)",borderRadius:4,cursor:v?"not-allowed":x?g?"pointer":"not-allowed":"pointer",opacity:v?.35:1,position:"relative"},children:[u.name,v&&l.jsxs("span",{style:{position:"absolute",bottom:1,left:"50%",transform:"translateX(-50%)",fontSize:8,color:"rgba(255,255,255,0.5)",whiteSpace:"nowrap"},children:["🔒"," Lv.",d]}),!v&&x&&l.jsxs("span",{style:{position:"absolute",bottom:1,left:"50%",transform:"translateX(-50%)",fontSize:8,color:g?"#FFD700":"#F87171",whiteSpace:"nowrap"},children:["🪙"," ",f]}),b&&l.jsxs("span",{style:{position:"absolute",bottom:-8,left:"50%",transform:"translateX(-50%)",fontSize:7,color:"#F59E0B",whiteSpace:"nowrap"},children:["⚠"," Lv.",d]})]},u.id)})})]})}function Th({label:e,active:n,onClick:a}){return l.jsx("button",{onClick:a,style:{flex:1,padding:"6px 0",fontSize:10,fontFamily:"var(--font-pixel, monospace)",fontWeight:"bold",letterSpacing:1,background:n?"rgba(255,255,255,0.08)":"transparent",color:n?"#fff":"rgba(255,255,255,0.35)",border:"none",borderBottom:n?"2px solid #3B82F6":"2px solid transparent",cursor:"pointer",transition:"all 0.15s"},children:e})}function Il(e){return e[Math.floor(Math.random()*e.length)]}function xs(e){var o,u,d;const n=Bb().filter(f=>!e||$b(f.id,e)),a=Lb().filter(f=>!e||Hb(f.id,e)),i=Ub().filter(f=>!e||Yb(f.id,e));return{skinColor:Il(fv),hairColor:Il(hv),shirtColor:Il(mv),pantsColor:Il(pv),shoeColor:Il(xv),hairStyle:(o=Il(n))==null?void 0:o.id,outfitStyle:(u=Il(a))==null?void 0:u.id,accessory:(d=Il(i))==null?void 0:d.id}}function gv({roleId:e,appearance:n,onChange:a,onRandomize:i,onReset:o,label:u,roleLevel:d,coinBalance:f,purchased:m,onPurchase:h}){const[x,g]=w.useState("look"),v=w.useCallback((F,I)=>{a({...n,[F]:I})},[n,a]),b=w.useRef(null),j=w.useCallback(F=>{var X;const I=(X=F.target.files)==null?void 0:X[0];if(!I)return;const H=new Image;H.onload=()=>{const A=wC(H);a({...A,hairStyle:n.hairStyle,outfitStyle:n.outfitStyle,accessory:n.accessory}),URL.revokeObjectURL(H.src)},H.src=URL.createObjectURL(I),F.target.value=""},[n.hairStyle,n.outfitStyle,n.accessory,a]),k=Bb(),N=Lb(),E=Ub(),C=d!==void 0?k.filter(F=>$b(F.id,d)).length:k.length,_=d!==void 0?N.filter(F=>Hb(F.id,d)).length:N.length,R=d!==void 0?E.filter(F=>Yb(F.id,d)).length:E.length,L=(F,I)=>d!==void 0?{roleLevel:d,getLockLevel:F,getCost:I,purchased:m,onPurchase:h,coinBalance:f}:void 0;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"customize-preview",children:[l.jsx("div",{className:"customize-preview-bg",children:l.jsx(Vl,{roleId:e,appearance:n,scale:12})}),u&&l.jsx("div",{className:"customize-preview-name",children:u}),l.jsxs("div",{className:"customize-preview-actions",children:[l.jsx("button",{className:"customize-btn customize-btn--random",onClick:i,children:"RANDOM"}),l.jsx("button",{className:"customize-btn customize-btn--reset",onClick:o,children:"RESET"}),l.jsx("button",{className:"customize-btn",onClick:()=>{var F;return(F=b.current)==null?void 0:F.click()},style:{fontSize:9,opacity:.7},children:"PHOTO"}),l.jsx("input",{ref:b,type:"file",accept:"image/*",onChange:j,style:{display:"none"}})]})]}),l.jsxs("div",{className:"customize-colors",children:[l.jsxs("div",{style:{display:"flex",borderBottom:"1px solid rgba(255,255,255,0.06)",marginBottom:4},children:[l.jsx(Th,{label:"LOOK",active:x==="look",onClick:()=>g("look")}),l.jsx(Th,{label:"OUTFIT",active:x==="outfit",onClick:()=>g("outfit")}),l.jsx(Th,{label:"ACCESSORY",active:x==="accessory",onClick:()=>g("accessory")})]}),x==="look"&&l.jsxs(l.Fragment,{children:[l.jsx(Do,{label:"SKIN",presets:fv,value:n.skinColor,onChange:F=>v("skinColor",F)}),l.jsx(Do,{label:"HAIR COLOR",presets:hv,value:n.hairColor,onChange:F=>v("hairColor",F)}),d!==void 0&&l.jsxs("div",{style:{padding:"4px 8px",marginBottom:4,background:"rgba(255,255,255,0.04)",borderRadius:4,fontSize:9,fontFamily:"var(--font-pixel, monospace)",color:"rgba(255,255,255,0.5)",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[l.jsxs("span",{children:["Lv.",d]}),l.jsxs("span",{children:[C,"/",k.length," unlocked"]})]}),l.jsx(Dh,{label:"HAIR STYLE",items:k,value:n.hairStyle,onChange:F=>v("hairStyle",F),lockInfo:L(Ob,oC)})]}),x==="outfit"&&l.jsxs(l.Fragment,{children:[d!==void 0&&l.jsxs("div",{style:{padding:"4px 8px",marginBottom:4,background:"rgba(255,255,255,0.04)",borderRadius:4,fontSize:9,fontFamily:"var(--font-pixel, monospace)",color:"rgba(255,255,255,0.5)",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[l.jsxs("span",{children:["Lv.",d]}),l.jsxs("span",{children:[_,"/",N.length," unlocked"]})]}),l.jsx(Dh,{label:"STYLE",items:N,value:n.outfitStyle,onChange:F=>v("outfitStyle",F),lockInfo:L(Ib,fC)}),l.jsx(Do,{label:"TOP",presets:mv,value:n.shirtColor,onChange:F=>v("shirtColor",F)}),l.jsx(Do,{label:"PANTS",presets:pv,value:n.pantsColor,onChange:F=>v("pantsColor",F)}),l.jsx(Do,{label:"SHOES",presets:xv,value:n.shoeColor,onChange:F=>v("shoeColor",F)})]}),x==="accessory"&&l.jsxs(l.Fragment,{children:[d!==void 0&&l.jsxs("div",{style:{padding:"4px 8px",marginBottom:4,background:"rgba(255,255,255,0.04)",borderRadius:4,fontSize:9,fontFamily:"var(--font-pixel, monospace)",color:"rgba(255,255,255,0.5)",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[l.jsxs("span",{children:["Lv.",d]}),l.jsxs("span",{children:[R,"/",E.length," unlocked"]})]}),l.jsx(Dh,{label:"ACCESSORY",items:E,value:n.accessory,onChange:F=>v("accessory",F),lockInfo:L(qb,gC)}),l.jsx("div",{style:{marginTop:12,padding:"8px 10px",background:"rgba(255,255,255,0.03)",borderRadius:6,border:"1px dashed rgba(255,255,255,0.08)",color:"rgba(255,255,255,0.25)",fontSize:9,fontFamily:"var(--font-pixel, monospace)",textAlign:"center"},children:d!==void 0&&d<10?"Level up to unlock more accessories":"More accessories coming soon"})]})]})]})}const s6=[{value:"c-level",label:"C-Level"},{value:"member",label:"Member"}];function xm(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,24)}function Fh(e){switch(e){case"c-level":return{authority:{autonomous:["Strategic decisions within domain","Task delegation to reports"],needsApproval:["Budget over $5K","External commitments"]},knowledge:{reads:["company/","operations/","projects/"],writes:["operations/","knowledge/"]},reports:{daily:"standup",weekly:"summary"}};default:return{authority:{autonomous:["Implementation within assigned tasks"],needsApproval:["Design changes","New dependencies"]},knowledge:{reads:["projects/"],writes:[]},reports:{daily:"standup",weekly:""}}}}const o6={cto:{name:"CTO",id:"cto",level:"c-level"},cbo:{name:"CBO",id:"cbo",level:"c-level"},pm:{name:"PM",id:"pm",level:"member"},engineer:{name:"Engineer",id:"engineer",level:"member"},designer:{name:"Designer",id:"designer",level:"member"},qa:{name:"QA Engineer",id:"qa",level:"member"}};let ql=null;async function c6(){if(ql)return ql;try{const a=await ye.getPreferences();if(a.instanceId)return ql=a.instanceId,localStorage.setItem("tycono_instance_id",ql),ql}catch{}const e="tycono_instance_id";let n=localStorage.getItem(e);return n||(n=crypto.randomUUID(),localStorage.setItem(e,n)),ql=n,n}const To=4;function u6(e,n,a){const i=e.trim();if(!i||i.startsWith("#"))return null;const o=i.split(",").map(g=>g.trim()),u=o[0];if(!u)return null;const d=xm(u),m=(o[1]||"member").toLowerCase()==="c-level"?"c-level":"member",h=o[2]||"ceo";let x;return n.has(d)?x="ID already exists":a.has(d)&&(x="Duplicate ID in batch"),a.add(d),{name:u,id:d,level:m,reportsTo:h,error:x}}function d6({existingRoles:e,onClose:n,onHire:a,onStoreVisit:i,questHint:o}){const[u,d]=w.useState("single"),[f,m]=w.useState([]),[h,x]=w.useState(!1),[g,v]=w.useState("popular"),[b,j]=w.useState(""),[k,N]=w.useState(null),[E,C]=w.useState(!1),[_,R]=w.useState(""),[L,F]=w.useState("browse"),[I,H]=w.useState(""),[X,A]=w.useState(""),[$,q]=w.useState("ceo"),[W,ie]=w.useState(null),[P,Y]=w.useState(1),[oe,de]=w.useState(""),[G,D]=w.useState(""),[B,U]=w.useState(!1),[T,se]=w.useState("member"),[ge,pe]=w.useState(()=>{const J=e.find(Oe=>Oe.level==="c-level");return(J==null?void 0:J.id)??"ceo"}),[Re,Ie]=w.useState(""),[He,ot]=w.useState(xs),[Je,tt]=w.useState(!1),[Ee,Ae]=w.useState(""),[yt,dt]=w.useState([]),[xt,jt]=w.useState(new Set),[Wt,Tt]=w.useState(""),[Ct,Bn]=w.useState("input"),[me,Se]=w.useState({done:0,total:0}),Ne=w.useRef(null),K=w.useRef(null),ue=w.useRef(null);w.useEffect(()=>{ye.getSkills().then(J=>dt(J.filter(Oe=>Oe.installed))).catch(()=>{}),c6().then(J=>ie(J)).catch(()=>{})},[]),w.useEffect(()=>{var J,Oe,rt;u==="single"?(P===1&&((J=Ne.current)==null||J.focus()),P===2&&((Oe=K.current)==null||Oe.focus())):u==="bulk"&&Ct==="input"&&((rt=ue.current)==null||rt.focus())},[P,u,Ct]),w.useEffect(()=>{u==="store"&&L==="browse"&&f.length===0&&ne()},[u,L]);const ne=async()=>{x(!0);try{const J=await wr.getCharacters({sort:g,instanceId:W??void 0});m(J.characters)}catch{R("Failed to load job board")}x(!1)};w.useEffect(()=>{u==="store"&&L==="browse"&&ne()},[g,W]);const ve=w.useMemo(()=>{if(!b.trim())return f;const J=b.toLowerCase();return f.filter(Oe=>Oe.name.toLowerCase().includes(J)||Oe.id.toLowerCase().includes(J)||(Oe.tagline??"").toLowerCase().includes(J))},[f,b]),we=w.useMemo(()=>new Set(e.map(J=>J.id)),[e]),ze=w.useMemo(()=>{const J=Wt.split(`
|
|
85
|
+
`),Oe=new Set;return J.map(rt=>u6(rt,we,Oe)).filter(rt=>rt!==null)},[Wt,we]),_e=ze.length>0&&ze.every(J=>!J.error),Be=J=>{de(J),B||D(xm(J))},qe=oe.trim().length>0&&G.trim().length>0&&!e.some(J=>J.id===G),at=Re.trim().length>0,Ke=async()=>{tt(!0),Ae("");const J=Fh(T);try{await a({id:G,name:oe.trim(),level:T,reportsTo:ge,persona:Re.trim(),...J,skills:xt.size>0?[...xt]:void 0},He),n()}catch(Oe){Ae(Oe instanceof Error?Oe.message:"Failed to create role"),tt(!1)}},bt=J=>J===1?qe:J===2?at:!0,Me=async()=>{tt(!0),Ae(""),Se({done:0,total:ze.length});try{for(let J=0;J<ze.length;J++){const Oe=ze[J],rt=Fh(Oe.level),Kt=xs(),ke=`${Oe.name}. A ${Oe.level} role reporting to ${Oe.reportsTo}.`;await a({id:Oe.id,name:Oe.name,level:Oe.level,reportsTo:Oe.reportsTo,persona:ke,...rt},Kt),Se({done:J+1,total:ze.length})}n()}catch(J){Ae(J instanceof Error?J.message:"Failed to create roles"),tt(!1)}},Ue=async J=>{C(!0),R("");try{const Oe=await wr.getCharacter(J);N(Oe),H(Oe.name||""),A(xm(Oe.name||J)),F("review")}catch{R("Failed to load character details")}finally{C(!1)}},_t=async(J,Oe)=>{if(!W)return;const rt=f.find(ke=>ke.id===J);if(!rt)return;const Kt=rt.my_vote===Oe?0:Oe;try{const ke=await wr.voteCharacter(J,W,Kt);m(kt=>kt.map(jn=>jn.id===J?{...jn,upvotes:ke.upvotes,downvotes:ke.downvotes,vote_score:ke.upvotes-ke.downvotes,my_vote:Kt===0?null:Kt}:jn))}catch{}},Bt=async()=>{if(!k)return;tt(!0),Ae("");const J=k,Oe=J.level==="c-level"?"c-level":"member",rt=Fh(Oe),Kt=J.skills!=null&&typeof J.skills=="object"&&!Array.isArray(J.skills)&&"primary"in J.skills;try{await a({id:X,name:I.trim(),level:Oe,reportsTo:$,persona:J.persona||`${I}. Imported from Job Board.`,authority:J.authority||rt.authority,knowledge:rt.knowledge,reports:rt.reports,source:{id:`tycono/${J.id}`,sync:"manual",forked_at:"1.0.0",upstream_version:"1.0.0"},skillContent:Kt?J.skills:void 0},J.appearance?J.appearance:xs()),wr.trackInstall(J.id).catch(()=>{}),n()}catch(ke){Ae(ke instanceof Error?ke.message:"Failed to hire"),tt(!1)}},Ot=async J=>{if(W)try{await wr.deleteCharacter(J,W),m(Oe=>Oe.filter(rt=>rt.id!==J))}catch{}},un=J=>{J.key==="Escape"&&n(),J.key==="Enter"&&(J.metaKey||J.ctrlKey)&&(u==="single"?P<To&&bt(P)?Y(P+1):P===To&&Ke():u==="bulk"?Ct==="input"&&_e?Bn("review"):Ct==="review"&&Me():u==="store"&&L==="review"&&Bt())},kn=e.some(J=>J.id===G)&&G.length>0;return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:n}),l.jsxs("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[560px] max-h-[90vh] z-[61] bg-[var(--wall)] rounded-2xl shadow-2xl overflow-hidden flex flex-col",onKeyDown:un,children:[l.jsxs("div",{className:"p-5 text-white",style:{background:"linear-gradient(135deg, #2E7D32, #43A047)"},children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("div",{className:"text-lg font-bold",children:"Hire New Role"}),l.jsxs("div",{className:"flex bg-black/20 rounded-lg p-0.5",children:[l.jsx("button",{onClick:()=>{d("single"),Ae("")},className:`px-3 py-1 text-xs font-semibold rounded-md cursor-pointer transition-colors ${u==="single"?"bg-white/20 text-white":"text-white/50 hover:text-white/70"}`,children:"Single"}),l.jsx("button",{onClick:()=>{d("bulk"),Ae("")},className:`px-3 py-1 text-xs font-semibold rounded-md cursor-pointer transition-colors ${u==="bulk"?"bg-white/20 text-white":"text-white/50 hover:text-white/70"}`,children:"Bulk"}),l.jsx("button",{onClick:()=>{d("store"),Ae(""),i==null||i()},className:`px-3 py-1 text-xs font-semibold rounded-md cursor-pointer transition-colors ${u==="store"?"bg-white/20 text-white":"text-white/50 hover:text-white/70"}`,children:"Job Board"})]})]}),o&&l.jsxs("div",{className:"mt-2 px-3 py-1.5 rounded-lg text-xs flex items-center gap-2",style:{background:"rgba(0,0,0,0.2)"},children:[l.jsx("span",{children:"🐾"}),l.jsx("span",{className:"opacity-90",children:o.message}),o.roleId&&u==="single"&&P===1&&!oe&&l.jsx("button",{className:"ml-auto px-2 py-0.5 rounded text-[10px] font-semibold cursor-pointer hover:brightness-125",style:{background:"rgba(255,255,255,0.15)",color:"#fff"},onClick:()=>{const J=o6[o.roleId];J&&(de(J.name),D(J.id),U(!0),se(J.level))},children:"Auto-fill →"})]}),l.jsxs("div",{className:"text-sm opacity-80 mt-0.5 flex items-center gap-2",children:[l.jsx("span",{children:u==="single"?`Step ${P} of ${To}`:u==="bulk"?Ct==="input"?"Enter roles, one per line":`Review ${ze.length} roles`:L==="browse"?`${f.length} roles available`:"Review & customize"}),u==="store"&&L==="browse"&&l.jsx("a",{href:"https://tycono.ai/jobs",target:"_blank",rel:"noopener noreferrer",className:"text-[10px] opacity-60 hover:opacity-100 transition-opacity",onClick:J=>J.stopPropagation(),children:"Open in browser ↗"})]})]}),u==="single"&&l.jsx("div",{className:"flex gap-1 px-5 pt-4",children:Array.from({length:To},(J,Oe)=>Oe+1).map(J=>l.jsx("div",{className:"flex-1 h-1 rounded-full transition-colors",style:{background:J<=P?"#2E7D32":"rgba(255,255,255,0.1)"}},J))}),l.jsx("div",{className:"p-5 min-h-[240px] overflow-y-auto flex-1",children:u==="store"?l.jsxs(l.Fragment,{children:[L==="browse"&&l.jsxs("div",{className:"space-y-3",children:[W?l.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 rounded-lg bg-green-900/10 border border-green-800/20 text-[10px]",children:[l.jsxs("span",{className:"text-green-400/70",children:["Signed in · ",l.jsxs("span",{className:"font-mono text-white/40",children:[W.slice(0,8),"..."]})]}),l.jsx("button",{onClick:()=>{ql=null,localStorage.removeItem("tycono_instance_id"),ie(null)},className:"text-white/30 hover:text-white/60 cursor-pointer",children:"Sign out"})]}):l.jsx(f6,{onLogin:J=>{ql=J,localStorage.setItem("tycono_instance_id",J),ie(J)}}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{placeholder:"Paste ID (tycono:engineer)",className:"flex-1 p-2 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 placeholder-white/25 focus:outline-none focus:border-accent/40 transition-colors font-mono",onKeyDown:J=>{if(J.key==="Enter"){const rt=J.target.value.trim().replace(/^tycono:/,"");rt&&(Ue(rt),J.target.value="")}}}),l.jsx("button",{onClick:()=>{const J=document.querySelector('[placeholder="Paste ID (tycono:engineer)"]');if(J){const rt=J.value.trim().replace(/^tycono:/,"");rt&&(Ue(rt),J.value="")}},disabled:E,className:"px-3 py-2 rounded-lg bg-accent/10 border border-accent/25 text-accent text-xs font-medium hover:bg-accent/20 transition-colors shrink-0 cursor-pointer disabled:opacity-50",children:E?"Loading...":"Fetch"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:"flex-1 h-px bg-white/10"}),l.jsx("span",{className:"text-[10px] text-white/30",children:"or browse"}),l.jsx("div",{className:"flex-1 h-px bg-white/10"})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{value:b,onChange:J=>j(J.target.value),placeholder:"Search roles...",className:"flex-1 p-2 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 placeholder-white/25 focus:outline-none focus:border-white/25 transition-colors",autoFocus:!0}),l.jsxs("select",{value:g,onChange:J=>v(J.target.value),className:"px-2 py-2 rounded-lg border border-white/10 bg-white/5 text-xs text-white/70 focus:outline-none cursor-pointer",children:[l.jsx("option",{value:"popular",className:"bg-[var(--wall)]",children:"Popular"}),l.jsx("option",{value:"installs",className:"bg-[var(--wall)]",children:"Most Hired"}),l.jsx("option",{value:"newest",className:"bg-[var(--wall)]",children:"Newest"}),l.jsx("option",{value:"name",className:"bg-[var(--wall)]",children:"A-Z"})]})]}),h?l.jsx("div",{className:"text-center py-8 text-sm text-white/40",children:"Loading store..."}):_?l.jsxs("div",{className:"text-center py-8",children:[l.jsx("div",{className:"text-xs text-red-400 mb-2",children:_}),l.jsx("button",{onClick:ne,className:"text-xs text-green-400 hover:underline cursor-pointer",children:"Retry"})]}):ve.length===0?l.jsx("div",{className:"text-center py-8 text-sm text-white/40",children:b?"No matches found":"No characters in store yet"}):l.jsx("div",{className:"space-y-2 max-h-[380px] overflow-y-auto pr-1",children:ve.map(J=>l.jsx(h6,{char:J,isHired:we.has(J.id),onSelect:()=>Ue(J.id),onVote:Oe=>_t(J.id,Oe),onDelete:()=>Ot(J.id),fetching:E,token:W},J.id))})]}),L==="review"&&k&&l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"bg-white/5 rounded-xl p-4 border border-white/10",children:[l.jsxs("div",{className:"flex gap-4",children:[k.appearance&&l.jsx("div",{className:"flex-shrink-0 rounded-lg overflow-hidden",style:{background:"#0d1117",padding:8},children:l.jsx(Vl,{roleId:"store-preview",appearance:k.appearance,scale:4})}),l.jsxs("div",{className:"flex-1 space-y-2.5",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-[10px] text-white/30 uppercase tracking-wider mb-0.5",children:"Name"}),l.jsx("input",{value:I,onChange:J=>H(J.target.value),className:"w-full p-2 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 focus:outline-none focus:border-white/25 transition-colors"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-[10px] text-white/30 uppercase tracking-wider mb-0.5",children:"Role ID"}),l.jsx("input",{value:X,onChange:J=>A(J.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),className:"w-full p-2 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 font-mono focus:outline-none focus:border-white/25 transition-colors"}),e.some(J=>J.id===X)&&X.length>0&&l.jsx("div",{className:"text-xs text-red-500 mt-1",children:"ID already exists"})]}),l.jsxs("div",{className:"flex gap-3",children:[l.jsxs("div",{className:"flex-1",children:[l.jsx("label",{className:"block text-[10px] text-white/30 uppercase tracking-wider mb-0.5",children:"Level"}),l.jsx("div",{className:"text-sm text-white/70 p-2 rounded-lg bg-white/5 border border-white/10",children:k.level==="c-level"?"C-Level":"Member"})]}),l.jsxs("div",{className:"flex-1",children:[l.jsx("label",{className:"block text-[10px] text-white/30 uppercase tracking-wider mb-0.5",children:"Reports To"}),l.jsxs("select",{value:$,onChange:J=>q(J.target.value),className:"w-full p-2 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 focus:outline-none focus:border-white/25 transition-colors",children:[l.jsx("option",{value:"ceo",className:"bg-[var(--wall)] text-white",children:"CEO"}),e.map(J=>l.jsxs("option",{value:J.id,className:"bg-[var(--wall)] text-white",children:[J.name," (",J.id,")"]},J.id))]})]})]})]})]}),k.persona&&l.jsxs("div",{className:"pt-3 mt-3 border-t border-white/10",children:[l.jsx("div",{className:"text-[10px] text-white/30 uppercase tracking-wider mb-1",children:"Persona"}),l.jsx("div",{className:"text-xs text-white/60 leading-relaxed line-clamp-3",children:k.persona})]}),k.skills&&l.jsxs("div",{className:"pt-3 mt-3 border-t border-white/10",children:[l.jsx("div",{className:"text-[10px] text-white/30 uppercase tracking-wider mb-1",children:"Skills"}),l.jsx("div",{className:"flex flex-wrap gap-1.5",children:(()=>{var Kt,ke;const J=k.skills;if(J&&typeof J=="object"&&!Array.isArray(J)&&"primary"in J){const kt=[];return(ke=(Kt=J.primary)==null?void 0:Kt.frontmatter)!=null&&ke.name&&kt.push(J.primary.frontmatter.name),J.shared&&J.shared.forEach(jn=>{var hn;return kt.push(((hn=jn.frontmatter)==null?void 0:hn.name)||jn.id)}),kt.map(jn=>l.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-mono bg-green-900/20 border border-green-800/30 text-green-400",children:jn},jn))}return(Array.isArray(J)?J:[]).map((kt,jn)=>l.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-mono bg-green-900/20 border border-green-800/30 text-green-400",children:typeof kt=="string"?kt:kt.name},jn))})()})]})]}),Ee&&l.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:Ee})]})]}):u==="single"?l.jsxs(l.Fragment,{children:[P===1&&l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-1",children:"Role Name"}),l.jsx("input",{ref:Ne,value:oe,onChange:J=>Be(J.target.value),placeholder:"e.g. Data Analyst",className:"w-full p-2.5 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 placeholder-white/25 focus:outline-none focus:border-white/25 transition-colors"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-1",children:"Role ID (slug)"}),l.jsx("input",{value:G,onChange:J=>{D(J.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),U(!0)},className:`w-full p-2.5 rounded-lg border bg-white/5 text-sm text-white/90 font-mono focus:outline-none transition-colors ${kn?"border-red-400":"border-white/10 focus:border-white/25"}`}),kn&&l.jsx("div",{className:"text-xs text-red-500 mt-1",children:"ID already exists"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-1",children:"Level"}),l.jsx("div",{className:"flex gap-2",children:s6.map(J=>l.jsx("button",{onClick:()=>{if(se(J.value),J.value==="c-level")pe("ceo");else{const Oe=e.find(rt=>rt.level==="c-level");pe((Oe==null?void 0:Oe.id)??"ceo")}},className:`flex-1 p-2 text-xs font-semibold rounded-lg border cursor-pointer transition-colors ${T===J.value?"border-green-600 bg-green-900/30 text-green-400":"border-white/10 text-white/50 hover:border-white/20"}`,children:J.label},J.value))})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-1",children:"Reports To"}),T==="c-level"?l.jsx("div",{className:"w-full p-2.5 rounded-lg border border-white/10 bg-white/5 text-sm text-white/40",children:"CEO (automatic)"}):l.jsx("select",{value:ge,onChange:J=>pe(J.target.value),className:"w-full p-2.5 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 focus:outline-none focus:border-white/25 transition-colors",children:e.filter(J=>J.level==="c-level").map(J=>l.jsxs("option",{value:J.id,className:"bg-[var(--wall)] text-white",children:[J.name," (",J.id,")"]},J.id))})]})]}),P===2&&l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Persona"}),l.jsx("textarea",{ref:K,value:Re,onChange:J=>Ie(J.target.value),placeholder:"Describe this role's personality, expertise, and working style...",className:"w-full h-32 p-3 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 placeholder-white/25 resize-none focus:outline-none focus:border-white/25 transition-colors"}),l.jsx("div",{className:"text-[10px] text-gray-400 mt-1",children:"This defines how the AI agent will behave in this role"})]}),yt.length>0&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Skills"}),l.jsx("div",{className:"space-y-1.5 max-h-[120px] overflow-y-auto",children:yt.map(J=>l.jsxs("label",{className:"flex items-center gap-2 p-2 rounded-lg border border-white/10 bg-white/5 cursor-pointer hover:border-white/20 transition-colors",children:[l.jsx("input",{type:"checkbox",checked:xt.has(J.id),onChange:()=>jt(Oe=>{const rt=new Set(Oe);return rt.has(J.id)?rt.delete(J.id):rt.add(J.id),rt}),className:"accent-green-600"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-xs font-semibold text-white/80",children:J.name}),l.jsx("div",{className:"text-[10px] text-white/40 truncate",children:J.description})]})]},J.id))})]})]}),P===3&&l.jsx("div",{className:"customize-body",style:{padding:0},children:l.jsx(gv,{roleId:"default",appearance:He,onChange:ot,onRandomize:()=>ot(xs()),onReset:()=>ot(xs()),label:l.jsxs("span",{children:[G||"new-role"," — ",oe||"New Role"]})})}),P===4&&l.jsxs("div",{className:"space-y-3",children:[l.jsx("div",{className:"text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Review"}),l.jsxs("div",{className:"bg-white/5 rounded-xl p-4 border border-white/10",children:[l.jsxs("div",{className:"flex gap-4",children:[l.jsx("div",{className:"flex-shrink-0 rounded-lg overflow-hidden",style:{background:"#0d1117",padding:8},children:l.jsx(Vl,{roleId:"default",appearance:He,scale:4})}),l.jsxs("div",{className:"flex-1 space-y-2.5",children:[l.jsx(Fo,{label:"Name",value:oe}),l.jsx(Fo,{label:"ID",value:G,mono:!0}),l.jsx(Fo,{label:"Level",value:T}),l.jsx(Fo,{label:"Reports To",value:ge}),xt.size>0&&l.jsx(Fo,{label:"Skills",value:[...xt].join(", ")})]})]}),l.jsxs("div",{className:"pt-3 mt-3 border-t border-white/10",children:[l.jsx("div",{className:"text-[10px] text-white/30 uppercase tracking-wider mb-1",children:"Persona"}),l.jsx("div",{className:"text-xs text-white/60 leading-relaxed",children:Re})]})]}),Ee&&l.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:Ee})]})]}):l.jsxs(l.Fragment,{children:[Ct==="input"&&l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Roles (one per line)"}),l.jsx("textarea",{ref:ue,value:Wt,onChange:J=>Tt(J.target.value),placeholder:`Name, Level, ReportsTo
|
|
86
|
+
e.g.
|
|
87
|
+
Data Analyst
|
|
88
|
+
DevOps Engineer, member, cto
|
|
89
|
+
VP Marketing, c-level, ceo`,className:"w-full h-40 p-3 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 placeholder-white/25 resize-none focus:outline-none focus:border-white/25 transition-colors font-mono"}),l.jsx("div",{className:"text-[10px] text-gray-400 mt-1",children:"Format: Name, Level (member/c-level), ReportsTo. Level and ReportsTo are optional."})]}),ze.length>0&&l.jsxs("div",{children:[l.jsxs("div",{className:"text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:["Preview (",ze.length," role",ze.length!==1?"s":"",")"]}),l.jsx("div",{className:"bg-white/5 rounded-lg border border-white/10 overflow-hidden",children:l.jsxs("table",{className:"w-full text-xs",children:[l.jsx("thead",{children:l.jsxs("tr",{className:"border-b border-white/10",children:[l.jsx("th",{className:"text-left p-2 text-white/40 font-semibold",children:"Name"}),l.jsx("th",{className:"text-left p-2 text-white/40 font-semibold",children:"ID"}),l.jsx("th",{className:"text-left p-2 text-white/40 font-semibold",children:"Level"}),l.jsx("th",{className:"text-left p-2 text-white/40 font-semibold",children:"Reports To"})]})}),l.jsx("tbody",{children:ze.map((J,Oe)=>l.jsxs("tr",{className:`border-b border-white/5 ${J.error?"bg-red-900/10":""}`,children:[l.jsx("td",{className:"p-2 text-white/80",children:J.name}),l.jsx("td",{className:"p-2 text-white/60 font-mono",children:J.id}),l.jsx("td",{className:"p-2 text-white/60",children:J.level}),l.jsx("td",{className:"p-2 text-white/60",children:J.reportsTo}),J.error&&l.jsx("td",{className:"p-2 text-red-400 text-[10px]",children:J.error})]},Oe))})]})})]})]}),Ct==="review"&&l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:["Confirm Bulk Hire — ",ze.length," roles"]}),l.jsx("div",{className:"bg-white/5 rounded-lg border border-white/10 overflow-hidden max-h-[300px] overflow-y-auto",children:l.jsxs("table",{className:"w-full text-xs",children:[l.jsx("thead",{className:"sticky top-0 bg-[var(--wall)]",children:l.jsxs("tr",{className:"border-b border-white/10",children:[l.jsx("th",{className:"text-left p-2 text-white/40 font-semibold",children:"#"}),l.jsx("th",{className:"text-left p-2 text-white/40 font-semibold",children:"Name"}),l.jsx("th",{className:"text-left p-2 text-white/40 font-semibold",children:"ID"}),l.jsx("th",{className:"text-left p-2 text-white/40 font-semibold",children:"Level"}),l.jsx("th",{className:"text-left p-2 text-white/40 font-semibold",children:"Reports To"})]})}),l.jsx("tbody",{children:ze.map((J,Oe)=>l.jsxs("tr",{className:"border-b border-white/5",children:[l.jsx("td",{className:"p-2 text-white/30",children:Oe+1}),l.jsx("td",{className:"p-2 text-white/80",children:J.name}),l.jsx("td",{className:"p-2 text-white/60 font-mono",children:J.id}),l.jsx("td",{className:"p-2 text-white/60",children:J.level}),l.jsx("td",{className:"p-2 text-white/60",children:J.reportsTo})]},Oe))})]})}),Je&&me.total>0&&l.jsxs("div",{children:[l.jsxs("div",{className:"flex justify-between text-[10px] text-white/40 mb-1",children:[l.jsx("span",{children:"Hiring..."}),l.jsxs("span",{children:[me.done,"/",me.total]})]}),l.jsx("div",{className:"h-1.5 bg-white/10 rounded-full overflow-hidden",children:l.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${me.done/me.total*100}%`,background:"#2E7D32"}})})]}),l.jsx("div",{className:"text-[10px] text-white/30",children:"Each role will get a random appearance and auto-generated persona. You can customize them later."}),Ee&&l.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:Ee})]})]})}),l.jsxs("div",{className:"flex justify-between px-5 pb-5",children:[l.jsxs("div",{children:[u==="single"&&P>1&&l.jsx("button",{onClick:()=>Y(P-1),className:"px-4 py-2 text-sm rounded-lg border border-white/15 text-white/60 hover:bg-white/5 cursor-pointer",children:"Back"}),u==="bulk"&&Ct==="review"&&l.jsx("button",{onClick:()=>Bn("input"),disabled:Je,className:"px-4 py-2 text-sm rounded-lg border border-white/15 text-white/60 hover:bg-white/5 cursor-pointer disabled:opacity-40",children:"Back"}),u==="store"&&L==="review"&&l.jsx("button",{onClick:()=>{F("browse"),N(null),Ae("")},disabled:Je,className:"px-4 py-2 text-sm rounded-lg border border-white/15 text-white/60 hover:bg-white/5 cursor-pointer disabled:opacity-40",children:"Back"})]}),l.jsxs("div",{className:"flex gap-3",children:[l.jsx("button",{onClick:n,className:"px-4 py-2 text-sm rounded-lg border border-white/15 text-white/60 hover:bg-white/5 cursor-pointer",children:"Cancel"}),u==="single"?P<To?l.jsx("button",{onClick:()=>Y(P+1),disabled:!bt(P),className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#2E7D32"},children:"Next"}):l.jsx("button",{onClick:Ke,disabled:Je,className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#2E7D32"},children:Je?"Hiring...":"HIRE"}):u==="bulk"?Ct==="input"?l.jsxs("button",{onClick:()=>Bn("review"),disabled:!_e,className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#2E7D32"},children:["Review (",ze.length,")"]}):l.jsx("button",{onClick:Me,disabled:Je,className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#2E7D32"},children:Je?`Hiring ${me.done}/${me.total}...`:`HIRE ALL (${ze.length})`}):L==="review"?l.jsx("button",{onClick:Bt,disabled:Je||!I.trim()||!X.trim()||e.some(J=>J.id===X),className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#2E7D32"},children:Je?"Hiring...":"HIRE"}):null]})]})]})]})}function f6({onLogin:e}){const[n,a]=w.useState(""),[i,o]=w.useState(!1),[u,d]=w.useState(""),f=()=>{const m=n.trim();if(m){if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(m)){d("Invalid token format");return}e(m)}};return l.jsxs("div",{className:"rounded-lg border border-white/10 bg-white/[0.03] p-3 space-y-2",children:[l.jsx("div",{className:"text-[11px] text-white/50",children:"Sign in to vote, publish, and manage your characters."}),i?l.jsxs("div",{className:"space-y-1.5",children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{value:n,onChange:m=>{a(m.target.value),d("")},onKeyDown:m=>{m.key==="Enter"&&f()},placeholder:"Paste your token here...",className:"flex-1 px-2 py-1.5 rounded-lg border border-white/10 bg-white/5 text-xs text-white/90 font-mono placeholder-white/20 focus:outline-none focus:border-amber-800/40",autoFocus:!0}),l.jsx("button",{onClick:f,disabled:!n.trim(),className:"px-3 py-1.5 text-[11px] font-semibold rounded-lg cursor-pointer text-green-400 bg-green-900/20 border border-green-800/30 hover:bg-green-900/40 disabled:opacity-30 transition-colors",children:"Sign in"})]}),u&&l.jsx("div",{className:"text-[10px] text-red-400",children:u}),l.jsx("button",{onClick:o.bind(null,!1),className:"text-[10px] text-white/30 hover:text-white/50 cursor-pointer",children:"Cancel"})]}):l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:o.bind(null,!0),className:"px-3 py-1.5 text-[11px] font-semibold rounded-lg cursor-pointer text-amber-400 bg-amber-900/20 border border-amber-800/30 hover:bg-amber-900/40 transition-colors",children:"Paste Token"}),l.jsx("span",{className:"text-[10px] text-white/20 self-center",children:"from Settings → Token"})]})]})}function h6({char:e,isHired:n,onSelect:a,onVote:i,onDelete:o,fetching:u,token:d}){const[f,m]=w.useState(!1),h=d&&e.publisher_id===d,x=!!d;return l.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-xl border border-white/10 bg-white/[0.03] hover:bg-white/[0.06] transition-colors group",children:[l.jsxs("div",{className:"flex flex-col items-center gap-0.5 shrink-0 w-8",children:[l.jsx("button",{onClick:g=>{g.stopPropagation(),i(1)},disabled:!x,className:`text-[14px] leading-none transition-colors ${x?"cursor-pointer":"cursor-not-allowed opacity-30"} ${e.my_vote===1?"text-green-400":"text-white/20 hover:text-green-400/60"}`,title:x?"Upvote":"Sign in to vote",children:"▲"}),l.jsx("span",{className:`text-[11px] font-bold tabular-nums ${(e.vote_score??0)>0?"text-green-400/80":(e.vote_score??0)<0?"text-red-400/80":"text-white/30"}`,children:e.vote_score??0}),l.jsx("button",{onClick:g=>{g.stopPropagation(),i(-1)},disabled:!x,className:`text-[14px] leading-none transition-colors ${x?"cursor-pointer":"cursor-not-allowed opacity-30"} ${e.my_vote===-1?"text-red-400":"text-white/20 hover:text-red-400/60"}`,title:x?"Downvote":"Sign in to vote",children:"▼"})]}),l.jsxs("div",{className:"flex-1 min-w-0 cursor-pointer",onClick:a,children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm font-semibold text-white/90 truncate",children:e.name}),l.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded font-semibold uppercase ${e.level==="c-level"?"bg-amber-900/30 text-amber-400 border border-amber-800/30":"bg-white/5 text-white/40 border border-white/10"}`,children:e.level}),n&&l.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-green-900/20 text-green-400/60 border border-green-800/20",children:"Hired"})]}),e.tagline&&l.jsx("div",{className:"text-[11px] text-white/40 truncate mt-0.5",children:e.tagline}),l.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[l.jsxs("span",{className:"text-[10px] text-white/25",children:[e.installs??0," installs"]}),l.jsxs("span",{className:"text-[10px] text-white/25",children:["v",e.version]}),l.jsx("span",{className:"text-[10px] text-white/25 font-mono",children:e.id})]})]}),l.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[l.jsx("button",{onClick:a,disabled:u,className:"px-3 py-1.5 text-[11px] font-semibold rounded-lg cursor-pointer transition-colors disabled:opacity-40 text-green-400 bg-green-900/20 border border-green-800/30 hover:bg-green-900/40",children:"Hire"}),h&&(f?l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("button",{onClick:g=>{g.stopPropagation(),o(),m(!1)},className:"px-2 py-1.5 text-[10px] font-semibold rounded cursor-pointer text-red-400 bg-red-900/30 border border-red-800/40 hover:bg-red-900/50",children:"Confirm"}),l.jsx("button",{onClick:g=>{g.stopPropagation(),m(!1)},className:"px-2 py-1.5 text-[10px] rounded cursor-pointer text-white/40 hover:text-white/60",children:"No"})]}):l.jsx("button",{onClick:g=>{g.stopPropagation(),m(!0)},className:"w-7 h-7 rounded-lg flex items-center justify-center cursor-pointer text-white/15 hover:text-red-400/60 hover:bg-red-900/10 transition-colors opacity-0 group-hover:opacity-100",title:"Delete from store",children:l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M3 6h18M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6M8 6V4a2 2 0 012-2h4a2 2 0 012 2v2"})})}))]})]})}function Fo({label:e,value:n,mono:a}){return l.jsxs("div",{className:"flex justify-between text-sm",children:[l.jsx("span",{className:"text-white/40",children:e}),l.jsx("span",{className:`font-semibold text-white/80 ${a?"font-mono":""}`,children:n})]})}function m6({roleId:e,roleName:n,onClose:a,onConfirm:i}){const[o,u]=w.useState(!1),d=async()=>{u(!0);try{await i(e)}finally{u(!1)}};return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:a}),l.jsxs("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[480px] z-[61] bg-[var(--wall)] rounded-2xl shadow-2xl overflow-hidden",children:[l.jsxs("div",{className:"p-5 text-white",style:{background:"linear-gradient(135deg, #B71C1C, #D32F2F)"},children:[l.jsx("div",{className:"text-lg font-bold",children:"Fire Role"}),l.jsxs("div",{className:"text-sm opacity-80 mt-0.5",children:["Remove ",n," (",e,")"]})]}),l.jsxs("div",{className:"p-5",children:[l.jsxs("div",{className:"p-4 rounded-lg border-2 border-red-300 bg-red-50 mb-4",children:[l.jsx("div",{className:"text-sm font-bold text-red-800 mb-1",children:"Warning"}),l.jsxs("div",{className:"text-xs text-red-700 leading-relaxed",children:["This will permanently delete the role directory including",l.jsx("strong",{children:" role.yaml"}),", ",l.jsx("strong",{children:"profile.md"}),", ",l.jsx("strong",{children:"SKILL.md"}),", and all journal entries. This action cannot be undone."]})]}),l.jsxs("div",{className:"text-sm text-gray-600",children:["Are you sure you want to fire ",l.jsx("strong",{children:n}),"?"]})]}),l.jsxs("div",{className:"flex justify-end gap-3 px-5 pb-5",children:[l.jsx("button",{onClick:a,className:"px-4 py-2 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 cursor-pointer",children:"Cancel"}),l.jsx("button",{onClick:d,disabled:o,className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#B71C1C"},children:o?"Removing...":"Confirm Fire"})]})]})]})}const p6={cto:"🏗️",cbo:"📊",pm:"📋",engineer:"⚙️",designer:"🎨",qa:"🔍"};function x6({roleId:e,title:n,roleColor:a,active:i,isWave:o,isWaveStreaming:u,onClick:d,onClose:f,"data-session-id":m}){const h=o?"#F59E0B":a;return l.jsxs("button",{onClick:d,"data-session-id":m,className:`flex items-center gap-1.5 px-3 py-1.5 text-[11px] rounded-t-lg shrink-0 cursor-pointer transition-colors max-w-[180px] group ${i?"bg-[var(--terminal-bg)] text-[var(--terminal-text)]":"bg-[var(--terminal-inline-bg)] text-[var(--terminal-text-secondary)] hover:text-[var(--terminal-text)] hover:bg-[var(--terminal-surface)]"}`,style:i?{borderTop:`2px solid ${h}`}:void 0,children:[o&&u&&l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse shrink-0"}),l.jsx("span",{className:"text-xs",children:p6[e]??"👤"}),l.jsx("span",{className:`truncate ${o?"text-amber-400/90":""}`,children:n}),l.jsx("span",{onClick:f,className:"ml-auto text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-sm leading-none",children:"×"})]})}function g6({content:e,streaming:n}){let a=e;return n&&(e.match(/```/g)??[]).length%2!==0&&(a+="\n```"),l.jsx("div",{className:"terminal-markdown",children:l.jsx($m,{remarkPlugins:[Um],components:{code:y6,table:({children:i})=>l.jsx("div",{className:"overflow-x-auto my-2",children:l.jsx("table",{className:"terminal-table",children:i})})},children:a})})}function y6({className:e,children:n,...a}){const i=/language-(\w+)/.exec(e??"");return i||typeof n=="string"&&n.includes(`
|
|
90
|
+
`)?l.jsx(b6,{language:i==null?void 0:i[1],children:n}):l.jsx("code",{className:"terminal-inline-code",...a,children:n})}function b6({children:e,language:n}){const[a,i]=w.useState(!1),o=String(e).replace(/\n$/,""),u=()=>{navigator.clipboard.writeText(o),i(!0),setTimeout(()=>i(!1),1500)};return l.jsxs("div",{className:"terminal-code-block group relative my-2",children:[n&&l.jsx("div",{className:"text-[10px] text-[var(--terminal-text-muted)] px-3 pt-1.5",children:n}),l.jsx("button",{onClick:u,className:"absolute top-1.5 right-2 text-[10px] text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:a?"Copied!":"Copy"}),l.jsx("pre",{className:"overflow-x-auto p-3 text-xs leading-relaxed",children:l.jsx("code",{children:o})})]})}const v6={cto:"🏗️",cbo:"📊",pm:"📋",engineer:"⚙️",designer:"🎨",qa:"🔍"};function w6({attachments:e}){const[n,a]=w.useState(null);return e.length===0?null:l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:e.map((i,o)=>l.jsxs("button",{onClick:()=>a(o),className:"relative w-20 h-20 rounded-lg overflow-hidden border border-[var(--terminal-border)] bg-[var(--terminal-inline-bg)] cursor-pointer hover:border-[var(--terminal-border-hover)] transition-colors",children:[l.jsx("img",{src:`data:${i.mediaType};base64,${i.data}`,alt:i.name,className:"w-full h-full object-cover"}),l.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-black/60 text-[8px] text-white truncate px-1 py-0.5",children:i.name})]},o))}),n!==null&&l.jsx("div",{className:"fixed inset-0 z-[100] bg-black/80 flex items-center justify-center",onClick:()=>a(null),children:l.jsxs("div",{className:"relative max-w-[90vw] max-h-[90vh]",children:[l.jsx("img",{src:`data:${e[n].mediaType};base64,${e[n].data}`,alt:e[n].name,className:"max-w-full max-h-[90vh] object-contain rounded-lg"}),l.jsx("button",{onClick:()=>a(null),className:"absolute top-2 right-2 w-8 h-8 rounded-full bg-black/70 text-white flex items-center justify-center cursor-pointer hover:bg-black/90",children:"x"}),l.jsx("div",{className:"absolute bottom-2 left-1/2 -translate-x-1/2 bg-black/70 text-white text-sm px-3 py-1 rounded",children:e[n].name})]})})]})}function Mh(e,n){return n?n.file_path?String(n.file_path).replace(/^.*\/(?=[^/]+\/)/,""):n.path?String(n.path).replace(/^.*\/(?=[^/]+\/)/,""):n.pattern?String(n.pattern):n.command?String(n.command).slice(0,60):n.query?String(n.query).slice(0,60):n.url?String(n.url).slice(0,60):"":""}function k6(e){const n=[];let a="";for(const i of e)if(i.type==="thinking")i.text&&(a=i.text),n.length===0||n[n.length-1].type!=="thinking"?n.push({type:"thinking",text:i.text}):n[n.length-1].text=i.text;else if(i.type==="tool")n.push({type:"tool",toolName:i.toolName,toolSummary:Mh(i.toolName??"",i.toolInput),toolInput:i.toolInput});else if(i.type==="dispatch")n.push({type:"dispatch",roleId:i.roleId,task:i.task});else if(i.type==="dispatch:progress"){const o=n.length>0?n[n.length-1]:null;(o==null?void 0:o.type)==="dispatch:progress"&&o.roleId===i.roleId?i.progressType==="tool"?(o.toolName=i.toolName,o.toolSummary=Mh(i.toolName??"",i.toolInput),o.progressType="tool"):i.progressType==="thinking"?(o.text=i.text,o.progressType="thinking"):i.progressType==="text"?(o.text=i.text,o.progressType="text"):(i.progressType==="done"||i.progressType==="error")&&(o.progressType=i.progressType):n.push({type:"dispatch:progress",roleId:i.roleId,progressType:i.progressType,text:i.text,toolName:i.toolName,toolSummary:i.toolName?Mh(i.toolName,i.toolInput):void 0})}if(a){const i=n.filter(o=>o.type==="thinking");i.length>0&&(i[i.length-1].text=a)}return n}function j6({event:e,isStreaming:n}){var o,u,d;const[a,i]=w.useState(!1);switch(e.type){case"thinking":return l.jsxs("div",{className:"stream-event-thinking",children:[l.jsxs("div",{className:"stream-event-thinking-header",onClick:()=>i(!a),children:[l.jsx("span",{className:"stream-event-thinking-icon"}),l.jsxs("span",{className:"stream-event-thinking-label",children:["thinking",n?"...":""]}),e.text&&!n&&l.jsx("span",{className:"stream-event-thinking-toggle",children:a?"▾":"▸"})]}),(n||a)&&e.text&&l.jsx("div",{className:"stream-event-thinking-content",children:e.text.slice(-500)})]});case"tool":return l.jsxs("div",{className:"stream-event-tool",children:[l.jsx("span",{className:"stream-event-tool-badge",children:e.toolName}),e.toolSummary&&l.jsx("span",{className:"stream-event-tool-path",children:e.toolSummary}),e.toolInput&&l.jsx("span",{className:"stream-event-tool-toggle",onClick:()=>i(!a),children:a?"▾":"▸"}),a&&e.toolInput&&l.jsx("div",{className:"stream-event-tool-detail",children:JSON.stringify(e.toolInput,null,1).slice(0,300)})]});case"dispatch":return l.jsxs("div",{className:"stream-event-dispatch",children:[l.jsxs("span",{className:"stream-event-dispatch-badge",children:["→"," ",(o=e.roleId)==null?void 0:o.toUpperCase()]}),l.jsx("span",{className:"stream-event-dispatch-task",children:(u=e.task)==null?void 0:u.slice(0,80)})]});case"dispatch:progress":return l.jsxs("div",{className:"stream-event-dispatch-progress",children:[l.jsx("span",{className:"stream-event-dispatch-progress-role",children:(d=e.roleId)==null?void 0:d.toUpperCase()}),e.progressType==="thinking"&&l.jsxs("span",{className:"stream-event-dispatch-progress-status",children:["thinking",n?"...":""]}),e.progressType==="tool"&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"stream-event-tool-badge",children:e.toolName}),e.toolSummary&&l.jsx("span",{className:"stream-event-tool-path",children:e.toolSummary})]}),e.progressType==="text"&&e.text&&l.jsx("span",{className:"stream-event-dispatch-progress-status",children:"responding..."}),e.progressType==="done"&&l.jsx("span",{className:"stream-event-dispatch-progress-done",children:"done"}),e.progressType==="error"&&l.jsx("span",{className:"stream-event-dispatch-progress-error",children:"error"})]});default:return null}}function S6({events:e,isStreaming:n}){const[a,i]=w.useState(!1);if(e.length===0)return null;const o=k6(e);if(o.length===0)return null;const u=e.filter(v=>v.type==="thinking").length,d=e.filter(v=>v.type==="tool"),f=e.filter(v=>v.type==="dispatch"||v.type==="dispatch:progress"),m=e.filter(v=>v.type==="turn").reduce((v,b)=>Math.max(v,b.turn??0),0),h=[];if(u>0&&h.push("thinking"),d.length>0){const v=[...new Set(d.map(b=>b.toolName))];v.length<=3?h.push(v.join(", ")):h.push(`${d.length} tool calls`)}f.length>0&&h.push(`${f.length} dispatch`),m>1&&h.push(`${m} turns`);const x=h.join(" · "),g=!a;return l.jsxs("div",{className:"stream-activity-log",children:[l.jsxs("div",{className:"stream-activity-header",onClick:()=>i(!a),children:[n&&l.jsx("span",{className:"stream-activity-pulse"}),l.jsxs("span",{className:"stream-activity-summary",children:[a?"▸":"▾"," ",x,n?"...":""]})]}),g&&l.jsx("div",{className:"stream-activity-events",children:o.map((v,b)=>l.jsx(j6,{event:v,isStreaming:n&&b===o.length-1},b))})]})}function C6(e){return e.map(n=>({type:n.type==="tool:start"?"tool":n.type==="dispatch:start"?"dispatch":n.type,timestamp:new Date(n.ts).getTime(),text:n.data.text,toolName:n.data.name,toolInput:n.data.input,roleId:n.data.roleId,task:n.data.task}))}function E6({message:e,roleId:n,roleColor:a}){const i=e.from==="ceo",o=e.type==="system",u=e.status==="streaming";if(o)return l.jsx("div",{className:"flex justify-center my-2",children:l.jsx("div",{className:"text-[10px] text-[var(--terminal-text-muted)] bg-[var(--terminal-inline-bg)] px-3 py-1 rounded-full",children:e.content})});if(i)return l.jsx("div",{className:"flex justify-end mb-3",children:l.jsxs("div",{className:"max-w-[85%]",children:[l.jsx("div",{className:"text-[10px] text-[var(--terminal-text-muted)] text-right mb-1",children:"CEO"}),e.attachments&&e.attachments.length>0&&l.jsx("div",{className:"flex justify-end mb-1",children:l.jsx(w6,{attachments:e.attachments})}),l.jsxs("div",{className:"bg-[var(--terminal-surface-light)] rounded-xl rounded-tr-sm px-4 py-2.5 text-sm text-[var(--terminal-text)] leading-relaxed",children:[e.type==="directive"&&l.jsx("span",{className:"text-amber-400 text-[10px] font-bold mr-1.5",children:"DO"}),e.content]})]})});const d=e.streamEvents??(e.events?C6(e.events):void 0),f=((d==null?void 0:d.length)??0)>0,m=!!e.thinking,h=m&&!e.content&&u&&!f;return l.jsxs("div",{className:"flex gap-2.5 mb-3",children:[l.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center text-sm shrink-0 mt-5",style:{background:`${a}33`},children:v6[n]??"👤"}),l.jsxs("div",{className:"max-w-[85%] min-w-0",children:[l.jsx("div",{className:"text-[10px] text-[var(--terminal-text-muted)] mb-1",children:n.toUpperCase()}),f&&l.jsx(S6,{events:d,isStreaming:u}),m&&!f&&l.jsxs("details",{open:h,className:"mb-1",children:[l.jsxs("summary",{className:"text-[10px] text-purple-400/70 cursor-pointer select-none flex items-center gap-1",children:[h&&l.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-purple-400 animate-pulse"}),"thinking",h?"...":` (${e.thinking.length} chars)`]}),l.jsx("div",{className:"text-[11px] text-[var(--terminal-text-muted)] leading-relaxed mt-1 pl-2 border-l border-purple-400/20 max-h-32 overflow-y-auto",children:e.thinking.slice(-500)})]}),l.jsxs("div",{className:"rounded-xl rounded-tl-sm px-4 py-2.5 text-sm text-[var(--terminal-text)] leading-relaxed",style:{borderLeft:`3px solid ${a}`,background:"var(--terminal-surface)"},children:[e.content?l.jsx(g6,{content:e.content,streaming:u}):u&&!m?l.jsxs("span",{className:"typing-dots",children:[l.jsx("span",{className:"typing-dot"}),l.jsx("span",{className:"typing-dot"}),l.jsx("span",{className:"typing-dot"})]}):u&&m?l.jsxs("span",{className:"typing-dots",children:[l.jsx("span",{className:"typing-dot"}),l.jsx("span",{className:"typing-dot"}),l.jsx("span",{className:"typing-dot"})]}):null,u&&e.content&&l.jsx("span",{className:"inline-block w-1.5 h-3.5 bg-[var(--terminal-text-secondary)] animate-pulse ml-0.5 align-middle"})]}),e.status==="error"&&l.jsx("div",{className:"text-[10px] text-red-400 mt-1",children:"Error occurred"}),e.status==="done"&&(e.turns||e.tokens)&&l.jsxs("div",{className:"text-[9px] text-[var(--terminal-text-muted)] mt-1 flex gap-2",children:[e.turns&&l.jsxs("span",{children:[e.turns," turns"]}),e.tokens&&l.jsxs("span",{children:[(e.tokens.input+e.tokens.output).toLocaleString()," tokens"]}),e.readOnly&&l.jsx("span",{className:"text-blue-400/60",children:"read-only"})]}),e.knowledgeDebt&&e.knowledgeDebt.length>0&&l.jsxs("div",{className:"mt-1.5 px-3 py-2 rounded-lg text-[10px]",style:{background:"#FFA72615",border:"1px solid #FFA72630"},children:[l.jsxs("div",{className:"font-bold mb-1",style:{color:"#FFA726"},children:["Knowledge Debt (",e.knowledgeDebt.length,")"]}),e.knowledgeDebt.map((x,g)=>l.jsxs("div",{className:"flex gap-1.5 mb-0.5",style:{color:"var(--terminal-text-muted)"},children:[l.jsx("span",{style:{color:"#FFA726"},children:x.type==="orphan"?"⚠":x.type==="no-hub"?"📁":"🔗"}),l.jsxs("span",{children:[x.message,x.file?` (${x.file})`:""]})]},g))]})]})]})}function yv({messages:e,roleId:n,roleColor:a}){var o;const i=w.useRef(null);return w.useEffect(()=>{var u;(u=i.current)==null||u.scrollIntoView({behavior:"smooth"})},[e,(o=e[e.length-1])==null?void 0:o.content]),e.length===0?l.jsxs("div",{className:"flex-1 flex items-center justify-center text-[var(--terminal-text-muted)] text-sm",children:["Start a conversation with ",n.toUpperCase()]}):l.jsxs("div",{className:"flex-1 overflow-y-auto p-4 terminal-scrollbar",children:[e.map(u=>l.jsx(E6,{message:u,roleId:n,roleColor:a},u.id)),l.jsx("div",{ref:i})]})}const N6=5*1024*1024,A6=["image/png","image/jpeg","image/gif","image/webp"];function Qm({mode:e,onModeChange:n,onSend:a,disabled:i,disabledReason:o,onStop:u}){const[d,f]=w.useState(""),[m,h]=w.useState([]),[x,g]=w.useState(!1),[v,b]=w.useState(null),j=w.useRef(null),k=w.useRef(null),N=w.useRef(!1);w.useEffect(()=>{const $=j.current;$&&($.style.height="0",$.style.height=Math.min($.scrollHeight,120)+"px")},[d]),w.useEffect(()=>{if(v){const $=setTimeout(()=>b(null),3e3);return()=>clearTimeout($)}},[v]);const E=w.useCallback(async $=>A6.includes($.type)?$.size>N6?(b(`File too large: ${($.size/1024/1024).toFixed(1)}MB. Max 5MB.`),null):new Promise(q=>{const W=new FileReader;W.onload=()=>{const P=W.result.split(",")[1];q({type:"image",data:P,name:$.name,mediaType:$.type})},W.onerror=()=>{b("Failed to read file"),q(null)},W.readAsDataURL($)}):(b(`Unsupported format: ${$.type}. Use PNG, JPG, GIF, or WebP.`),null),[]),C=w.useCallback(async $=>{const q=Array.from($),W=[];for(const ie of q){const P=await E(ie);P&&W.push(P)}W.length>0&&h(ie=>[...ie,...W])},[E]),_=w.useCallback($=>{$.preventDefault(),$.stopPropagation(),g(!0)},[]),R=w.useCallback($=>{$.preventDefault(),$.stopPropagation(),g(!1)},[]),L=w.useCallback($=>{$.preventDefault(),$.stopPropagation(),g(!1);const q=$.dataTransfer.files;q.length>0&&C(q)},[C]),F=w.useCallback($=>{const q=$.clipboardData.items,W=[];for(let ie=0;ie<q.length;ie++){const P=q[ie];if(P.type.startsWith("image/")){const Y=P.getAsFile();Y&&W.push(Y)}}W.length>0&&($.preventDefault(),C(W))},[C]),I=w.useCallback($=>{const q=$.target.files;q&&q.length>0&&C(q),$.target.value=""},[C]),H=w.useCallback($=>{h(q=>q.filter((W,ie)=>ie!==$))},[]),X=()=>{const $=d.trim();!$&&m.length===0||i||(a($,m.length>0?m:void 0),f(""),h([]))},A=$=>{if($.key==="Enter"&&!$.shiftKey){if(N.current)return;$.preventDefault(),X()}};return l.jsxs("div",{className:`border-t border-[var(--terminal-border)] p-3 shrink-0 transition-colors ${x?"bg-[var(--terminal-surface-light)] border-amber-500/50":""}`,onDragOver:_,onDragLeave:R,onDrop:L,children:[v&&l.jsx("div",{className:"text-[10px] text-red-400 mb-2 text-center",children:v}),o&&l.jsx("div",{className:"text-[10px] text-amber-400/70 mb-2 text-center",children:o}),m.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:m.map(($,q)=>l.jsxs("div",{className:"relative group w-16 h-16 rounded-lg overflow-hidden border border-[var(--terminal-border)] bg-[var(--terminal-inline-bg)]",children:[l.jsx("img",{src:`data:${$.mediaType};base64,${$.data}`,alt:$.name,className:"w-full h-full object-cover"}),l.jsx("button",{onClick:()=>H(q),className:"absolute top-0.5 right-0.5 w-4 h-4 rounded-full bg-black/70 text-white text-xs flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:"x"}),l.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-black/60 text-[8px] text-white truncate px-1 py-0.5",children:$.name})]},q))}),x&&l.jsx("div",{className:"text-[11px] text-amber-400 text-center mb-2",children:"Drop image here"}),l.jsxs("div",{className:"flex items-end gap-2",children:[l.jsxs("div",{className:"flex rounded-lg overflow-hidden border border-[var(--terminal-border)] shrink-0",children:[l.jsx("button",{onClick:()=>n("talk"),className:`px-2.5 py-1.5 text-[11px] font-semibold cursor-pointer transition-colors ${e==="talk"?"bg-[var(--desk-wood)] text-white":"bg-[var(--terminal-inline-bg)] text-[var(--terminal-text-secondary)] hover:text-[var(--terminal-text)]"}`,children:"Talk"}),l.jsx("button",{onClick:()=>n("do"),className:`px-2.5 py-1.5 text-[11px] font-semibold cursor-pointer transition-colors ${e==="do"?"bg-amber-700 text-white":"bg-[var(--terminal-inline-bg)] text-[var(--terminal-text-secondary)] hover:text-[var(--terminal-text)]"}`,children:"Do"})]}),l.jsx("button",{onClick:()=>{var $;return($=k.current)==null?void 0:$.click()},disabled:i,className:"w-8 h-8 rounded-lg bg-[var(--terminal-inline-bg)] border border-[var(--terminal-border)] text-[var(--terminal-text-muted)] flex items-center justify-center shrink-0 cursor-pointer hover:bg-[var(--terminal-surface-light)] hover:text-[var(--terminal-text-secondary)] disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:"Attach image (PNG, JPG, GIF, WebP)",children:l.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})})}),l.jsx("input",{ref:k,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,onChange:I,className:"hidden"}),l.jsx("textarea",{ref:j,value:d,onChange:$=>f($.target.value),onKeyDown:A,onCompositionStart:()=>{N.current=!0},onCompositionEnd:()=>{N.current=!1},onPaste:F,placeholder:i?"Waiting...":e==="talk"?"Ask something...":"Give a directive...",disabled:i,rows:1,className:"flex-1 bg-[var(--terminal-inline-bg)] border border-[var(--terminal-border)] rounded-lg px-3 py-2 text-sm text-[var(--terminal-text)] placeholder:text-[var(--terminal-text-muted)] resize-none focus:outline-none focus:border-[var(--terminal-border-hover)] disabled:opacity-40 terminal-scrollbar"}),i&&u&&l.jsx("button",{onClick:u,className:"w-8 h-8 rounded-lg bg-red-900/40 text-red-400 flex items-center justify-center shrink-0 cursor-pointer hover:bg-red-900/60 hover:text-red-300 transition-colors",title:"Stop",children:l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:l.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})})}),l.jsx("button",{onClick:X,disabled:i||!d.trim()&&m.length===0,className:"w-8 h-8 rounded-lg bg-[var(--terminal-surface-light)] text-[var(--terminal-text-secondary)] flex items-center justify-center shrink-0 cursor-pointer hover:bg-[var(--desk-wood)] hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:l.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M22 2L11 13"}),l.jsx("path",{d:"M22 2L15 22L11 13L2 9L22 2Z"})]})})]})]})}const D6={ceo:"#FFB300",cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"},bv={ceo:"CEO (You)",cto:"CTO",cbo:"CBO",pm:"PM",engineer:"Engineer",designer:"Designer",qa:"QA","data-analyst":"Data Analyst"};function Pg(e){return new Date(e).toLocaleTimeString("ko-KR",{hour:"2-digit",minute:"2-digit"})}function T6({msg:e}){const n=D6[e.roleId]??"#888",a=bv[e.roleId]??e.roleId;if(e.type==="dispatch"){const i=e.text.includes("WAVE"),o=e.text.includes("completed")||e.text.includes("완료"),u=i?"📡":o?"✓":"→",d=o?"text-green-400/70":"text-[var(--terminal-text-muted)]";return l.jsxs("div",{className:"flex items-start gap-2 px-3 py-1 hover:bg-white/[0.02]",children:[l.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)] shrink-0 w-10 text-right mt-0.5",children:Pg(e.ts)}),l.jsx("span",{className:"text-[10px] shrink-0 mt-0.5",children:u}),l.jsx("span",{className:`text-[11px] ${d}`,children:e.text})]})}return l.jsxs("div",{className:"flex items-start gap-2 px-3 py-1.5 hover:bg-white/[0.02]",children:[l.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)] shrink-0 w-10 text-right mt-0.5",children:Pg(e.ts)}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"text-[11px] font-semibold mr-1.5",style:{color:n},children:a}),l.jsx("span",{className:"text-xs text-[var(--terminal-text-secondary)]",children:e.text})]})]})}function F6({channel:e,allRoles:n,onUpdateMembers:a,onUpdateTopic:i,onSendMessage:o}){const u=w.useRef(null),d=w.useRef(null),[f,m]=w.useState("");w.useEffect(()=>{var _;const E=d.current;if(!E)return;E.scrollHeight-E.scrollTop-E.clientHeight<80&&((_=u.current)==null||_.scrollIntoView({behavior:"smooth"}))},[e.messages.length]);const[h,x]=w.useState(!1),[g,v]=w.useState(!1),[b,j]=w.useState(""),k=o&&e.id!=="general",N=()=>{!f.trim()||!o||(o(e.id,f.trim()),m(""),setTimeout(()=>{var E;return(E=u.current)==null?void 0:E.scrollIntoView({behavior:"smooth"})},50))};return l.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[l.jsxs("div",{ref:d,className:"flex-1 overflow-y-auto terminal-scrollbar py-2 min-h-0",children:[l.jsxs("div",{className:"px-3 py-2 mb-2 border-b border-[var(--terminal-border)] flex items-center gap-2",children:[l.jsx("span",{className:"text-sm font-semibold text-[var(--terminal-text)]",children:e.name}),e.members.length>0&&l.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:e.members.map(E=>bv[E]??E).join(", ")}),e.members.length===0&&l.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:e.isDefault?"system logs":"no members"}),!e.isDefault&&n&&a&&l.jsx("button",{className:"ml-auto text-[10px] px-2 py-0.5 rounded bg-white/5 hover:bg-white/10 text-[var(--terminal-text-muted)]",onClick:()=>x(!h),children:h?"Done":"Invite"})]}),!e.isDefault&&i&&l.jsx("div",{className:"px-3 pb-2 mb-1",children:g?l.jsx("input",{autoFocus:!0,value:b,onChange:E=>j(E.target.value),onKeyDown:E=>{E.key==="Enter"&&(i(e.id,b.trim()),v(!1)),E.key==="Escape"&&v(!1)},onBlur:()=>{i(e.id,b.trim()),v(!1)},placeholder:"Set a topic for this channel...",className:"w-full bg-transparent text-[10px] text-[var(--terminal-text-muted)] outline-none border-b border-[var(--terminal-border)] pb-0.5"}):l.jsx("button",{onClick:()=>{j(e.topic??""),v(!0)},className:"text-[10px] text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] cursor-pointer italic",children:e.topic||"Click to set channel topic..."})}),h&&!e.isDefault&&n&&a&&l.jsx("div",{className:"px-3 pb-2 mb-2 border-b border-[var(--terminal-border)]",children:l.jsx("div",{className:"flex flex-wrap gap-1",children:n.map(E=>{const C=e.members.includes(E.id);return l.jsxs("button",{className:`text-[10px] px-2 py-1 rounded ${C?"bg-white/15 text-[var(--terminal-text)]":"bg-white/5 text-[var(--terminal-text-muted)]"}`,onClick:()=>{const _=C?e.members.filter(R=>R!==E.id):[...e.members,E.id];a(e.id,_)},children:[C?"✓ ":"",E.name]},E.id)})})}),e.messages.length===0&&l.jsx("div",{className:"flex-1 flex flex-col items-center justify-center text-[var(--terminal-text-muted)] text-xs gap-1 py-8",children:l.jsx("span",{children:e.isDefault?"No dispatch events yet":"No messages yet — invite roles to start chatting"})}),e.messages.map(E=>l.jsx(T6,{msg:E},E.id)),l.jsx("div",{ref:u})]}),k&&l.jsx("div",{className:"shrink-0 px-3 py-2 border-t border-[var(--terminal-border)]",children:l.jsxs("div",{className:"flex gap-2 items-center",children:[l.jsx("span",{className:"text-[10px] font-semibold shrink-0",style:{color:"#FFB300"},children:"CEO"}),l.jsx("input",{type:"text",value:f,onChange:E=>m(E.target.value),onKeyDown:E=>{E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),N())},placeholder:"Say something...",className:"flex-1 px-2 py-1 text-xs rounded border bg-transparent text-[var(--terminal-text)] border-[var(--terminal-border)] outline-none focus:border-[#FFB300]/50"})]})})]})}const Rh={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"},M6=400,R6=800;function Qg({sessions:e,activeSessionId:n,roles:a,streamingSessionId:i,width:o,onWidthChange:u,onSwitchSession:d,onCloseSession:f,onCreateSession:m,onClearEmpty:h,onCloseAll:x,onSendMessage:g,onModeChange:v,onStopSession:b,onCloseTerminal:j,onMaximize:k,chatChannels:N,activeChatChannelId:E,onSwitchChatChannel:C,onCreateChatChannel:_,onDeleteChatChannel:R,onUpdateChatMembers:L,onUpdateChatTopic:F,onSendChatMessage:I,unreadChannels:H}){const[X,A]=w.useState(!1),[$,q]=w.useState(!1),[W,ie]=w.useState(!1),[P,Y]=w.useState(""),oe=E!=null,de=N==null?void 0:N.find(Ee=>Ee.id===E),[G,D]=w.useState(!1),[B,U]=w.useState(!1),[T,se]=w.useState(!1),ge=w.useRef(0),pe=w.useRef(0),Re=w.useRef(null),Ie=e.find(Ee=>Ee.id===n),He=i===n,ot=e.filter(Ee=>Ee.messages.length===0).length,Je=w.useCallback(()=>{const Ee=Re.current;Ee&&(U(Ee.scrollLeft>0),se(Ee.scrollLeft+Ee.clientWidth<Ee.scrollWidth-1))},[]);w.useEffect(()=>{if(!n||!Re.current)return;const Ee=Re.current.querySelector(`[data-session-id="${n}"]`);Ee&&Ee.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"}),Je()},[n,e.length,Je]),w.useEffect(()=>{const Ee=Re.current;if(!Ee)return;Je(),Ee.addEventListener("scroll",Je);const Ae=new ResizeObserver(Je);return Ae.observe(Ee),()=>{Ee.removeEventListener("scroll",Je),Ae.disconnect()}},[Je]);const tt=w.useCallback(Ee=>{Ee.preventDefault(),ge.current=Ee.clientX,pe.current=o,D(!0);const Ae=k,yt=()=>{D(!1),document.removeEventListener("mousemove",dt),document.removeEventListener("mouseup",yt)},dt=xt=>{const jt=ge.current-xt.clientX,Wt=pe.current+jt;if(Wt>=window.innerWidth*.6&&Ae){yt(),Ae();return}const Tt=Math.min(R6,Math.max(M6,Wt));u==null||u(Tt)};document.addEventListener("mousemove",dt),document.addEventListener("mouseup",yt)},[o,u,k]);return l.jsxs("div",{className:"shrink-0 bg-[var(--terminal-bg)] border-l border-[var(--terminal-border)] flex flex-col h-full relative",style:{width:o},children:[u&&l.jsx("div",{className:`terminal-resize-handle absolute top-0 left-0 w-1 h-full cursor-col-resize z-10 transition-colors ${G?"bg-[var(--terminal-border-hover)]":"bg-transparent"}`,onMouseDown:tt}),l.jsxs("div",{className:"flex items-center bg-[var(--terminal-bg-deeper)] border-b border-[var(--terminal-border)] shrink-0",children:[l.jsxs("div",{className:"relative flex-1 min-w-0",children:[B&&l.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-6 bg-gradient-to-r from-[var(--terminal-bg-deeper)] to-transparent z-10 pointer-events-none"}),l.jsxs("div",{ref:Re,className:"flex items-center overflow-x-auto terminal-tab-scroll gap-px px-1 py-1",children:[N==null?void 0:N.map(Ee=>l.jsxs("button",{onClick:()=>{C==null||C(Ee.id)},className:`flex items-center gap-1 px-2.5 py-1.5 text-[11px] rounded-t-lg shrink-0 cursor-pointer transition-colors group ${E===Ee.id?"bg-[var(--terminal-bg)] text-[var(--terminal-text)]":"bg-[var(--terminal-inline-bg)] text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] hover:bg-[var(--terminal-surface)]"}`,style:E===Ee.id?{borderTop:"2px solid #4CAF50"}:void 0,children:[l.jsx("span",{className:"text-[10px]",children:"💬"}),l.jsx("span",{className:"truncate",children:Ee.name}),(H==null?void 0:H.has(Ee.id))&&E!==Ee.id&&l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-400 shrink-0"}),!Ee.isDefault&&l.jsx("span",{onClick:Ae=>{Ae.stopPropagation(),R==null||R(Ee.id)},className:"ml-1 text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-sm leading-none opacity-0 group-hover:opacity-100",children:"×"})]},Ee.id)),N&&N.length>0&&e.length>0&&l.jsx("div",{className:"w-px h-4 bg-[var(--terminal-border)] shrink-0 mx-1"}),e.map(Ee=>l.jsx(x6,{roleId:Ee.roleId,title:Ee.title,roleColor:Rh[Ee.roleId]??"#666",active:!oe&&Ee.id===n,isWave:Ee.source==="wave",isWaveStreaming:Ee.source==="wave"&&Ee.status==="active",onClick:()=>{C==null||C(null),d(Ee.id)},onClose:Ae=>{Ae.stopPropagation(),f(Ee.id)},"data-session-id":Ee.id},Ee.id))]}),T&&l.jsx("div",{className:"absolute right-0 top-0 bottom-0 w-6 bg-gradient-to-l from-[var(--terminal-bg-deeper)] to-transparent z-10 pointer-events-none"})]}),l.jsxs("div",{className:"relative shrink-0",children:[l.jsx("button",{onClick:()=>{A(!X),q(!1)},className:"w-7 h-7 flex items-center justify-center text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-lg cursor-pointer",children:"+"}),X&&l.jsxs("div",{className:"absolute top-full right-0 mt-1 bg-[var(--terminal-surface)] border border-[var(--terminal-border)] rounded-lg shadow-xl z-50 py-1 min-w-[200px]",children:[_&&l.jsxs(l.Fragment,{children:[W?l.jsxs("div",{className:"px-3 py-2 flex items-center gap-1",children:[l.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:"#"}),l.jsx("input",{autoFocus:!0,value:P,onChange:Ee=>Y(Ee.target.value),onKeyDown:Ee=>{Ee.key==="Enter"&&P.trim()&&(_(P.trim(),[]),Y(""),ie(!1),A(!1)),Ee.key==="Escape"&&(ie(!1),Y(""))},placeholder:"channel name",className:"flex-1 bg-transparent text-xs text-[var(--terminal-text)] outline-none border-b border-[var(--terminal-border)]"})]}):l.jsxs("button",{onClick:()=>ie(!0),className:"w-full text-left px-3 py-2 text-xs text-[var(--terminal-text-secondary)] hover:bg-[var(--terminal-surface-light)] cursor-pointer flex items-center gap-2",children:[l.jsx("span",{className:"text-[10px]",children:"💬"}),"New Channel"]}),l.jsx("div",{className:"border-b border-[var(--terminal-border)] my-1"})]}),a.map(Ee=>l.jsxs("button",{onClick:()=>{m(Ee.id),C==null||C(null),A(!1)},className:"w-full text-left px-3 py-2 text-xs text-[var(--terminal-text-secondary)] hover:bg-[var(--terminal-surface-light)] cursor-pointer flex items-center gap-2",children:[l.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:Rh[Ee.id]??"#666"}}),Ee.id.toUpperCase()," — ",Ee.name]},Ee.id))]})]}),l.jsxs("div",{className:"relative shrink-0",children:[l.jsx("button",{onClick:()=>{q(!$),A(!1)},className:"w-7 h-7 flex items-center justify-center text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-xs cursor-pointer tracking-tight",title:"Manage sessions",children:"···"}),$&&l.jsxs("div",{className:"absolute top-full right-0 mt-1 bg-[var(--terminal-surface)] border border-[var(--terminal-border)] rounded-lg shadow-xl z-50 py-1 min-w-[200px]",children:[l.jsxs("div",{className:"px-3 py-1.5 text-[10px] text-[var(--terminal-text-muted)] border-b border-[var(--terminal-border)]",children:[e.length," session",e.length!==1?"s":""]}),ot>0&&h&&l.jsxs("button",{onClick:()=>{h(),q(!1)},className:"w-full text-left px-3 py-2 text-xs text-[var(--terminal-text-secondary)] hover:bg-[var(--terminal-surface-light)] cursor-pointer",children:["Clear empty sessions (",ot,")"]}),e.length>0&&x&&l.jsx("button",{onClick:()=>{x(),q(!1)},className:"w-full text-left px-3 py-2 text-xs text-[#E57373] hover:bg-[var(--terminal-surface-light)] cursor-pointer",children:"Close all sessions"}),e.length===0&&l.jsx("div",{className:"px-3 py-2 text-xs text-[var(--terminal-text-muted)]",children:"No sessions"})]})]}),k&&l.jsx("button",{onClick:k,className:"w-7 h-7 flex items-center justify-center text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-sm cursor-pointer shrink-0",title:"Maximize (Pro View)",children:"⤢"}),l.jsx("button",{onClick:j,className:"px-2 py-1 text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-sm cursor-pointer shrink-0",children:"×"})]}),oe&&de?l.jsx(F6,{channel:de,allRoles:a,onUpdateMembers:L,onUpdateTopic:F,onSendMessage:I}):Ie?l.jsxs(l.Fragment,{children:[l.jsx(yv,{messages:Ie.messages,roleId:Ie.roleId,roleColor:Rh[Ie.roleId]??"#666"}),l.jsx(Qm,{mode:Ie.mode,onModeChange:Ee=>v(Ie.id,Ee),onSend:(Ee,Ae)=>g(Ie.id,Ee,Ie.mode,Ae),disabled:He,disabledReason:He?`${Ie.roleId.toUpperCase()} is responding...`:void 0,onStop:He&&b?()=>b(Ie.id):void 0})]}):l.jsx("div",{className:"flex-1 flex items-center justify-center text-[var(--terminal-text-muted)] text-sm",children:"No active session. Click [+] to start."})]})}function z6(){const e=w.useRef(null),n=w.useCallback(()=>{var i;(i=e.current)==null||i.abort(),e.current=null},[]);return{sendMessage:w.useCallback((i,o,u,d,f)=>{n();const m=new AbortController;return e.current=m,fetch(`/api/exec/session/${i}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:o,mode:u,attachments:f}),signal:m.signal}).then(async h=>{var N,E,C,_,R;if(!h.ok||!h.body){d.onError("Failed to connect");return}const x=h.body.getReader(),g=new TextDecoder;let v="",b=Date.now();const j=6e4,k=setInterval(()=>{Date.now()-b>j&&(clearInterval(k),m.abort(),d.onError("Connection stale — no data received for 60s"))},1e4);try{for(;;){const{done:L,value:F}=await x.read();if(L)break;b=Date.now(),v+=g.decode(F,{stream:!0});const I=v.split(`
|
|
91
|
+
`);v=I.pop()??"";let H="";for(let X=0;X<I.length;X++){const A=I[X];if(A.startsWith("event: ")){H=A.slice(7).trim();continue}if(A.startsWith("data: ")){let $;try{$=JSON.parse(A.slice(6))}catch{H="";continue}switch(H){case"thinking":$.text&&((N=d.onThinking)==null||N.call(d,$.text));break;case"output":$.text&&d.onText($.text);break;case"tool":(E=d.onToolUse)==null||E.call(d,$.name,$.input);break;case"dispatch":(C=d.onDispatch)==null||C.call(d,$.roleId,$.task);break;case"dispatch:progress":(_=d.onDispatchProgress)==null||_.call(d,$.roleId,$.type,$);break;case"turn":(R=d.onTurn)==null||R.call(d,$.turn);break;case"done":d.onDone($);break;case"error":d.onError($.message??"Unknown error");break;default:$.text&&d.onText($.text);break}H=""}}}}finally{clearInterval(k)}}).catch(h=>{h.name!=="AbortError"&&d.onError(h.message)}),{abort:n}},[n]),abort:n}}const vv="tycono-appearances",gm="tycono-theme";function Zg(){try{const e=localStorage.getItem(vv);return e?JSON.parse(e):{}}catch{return{}}}function zh(e){localStorage.setItem(vv,JSON.stringify(e))}function Jg(){try{const e=localStorage.getItem(gm);if(e&&e in il)return e}catch{}return"default"}const wv=new Set;for(const e of Object.values(il))for(const n of Object.keys(e.vars))wv.add(n);function _6(e){var i;const n=(i=il[e])==null?void 0:i.vars;if(!n)return;const a=document.documentElement;for(const o of wv)o in n||a.style.removeProperty(o);for(const[o,u]of Object.entries(n))a.style.setProperty(o,u)}const _h={mode:"auto",intervalSec:18,dailyBudgetUsd:1},ym="tycono-speech-settings",Bh="tycono-language";function B6(){try{const e=localStorage.getItem(ym);return e?{..._h,...JSON.parse(e)}:_h}catch{return _h}}function O6(){const[e,n]=w.useState(Zg),[a,i]=w.useState(Jg),[o,u]=w.useState(B6),[d,f]=w.useState(()=>{try{return localStorage.getItem(Bh)??"auto"}catch{return"auto"}}),[m,h]=w.useState(new Set),x=w.useRef(!1);w.useEffect(()=>{x.current||(x.current=!0,ye.getPreferences().then(C=>{const _=Object.keys(C.appearances??{}).length>0||C.theme!=="default";if(C.speech&&(u(R=>({...R,...C.speech})),localStorage.setItem(ym,JSON.stringify(C.speech))),C.language&&(f(C.language),localStorage.setItem(Bh,C.language)),C.purchasedItems&&h(new Set(C.purchasedItems)),_){const R=C.appearances;n(R),zh(R),C.theme&&C.theme in il&&(i(C.theme),localStorage.setItem(gm,C.theme))}else{const R=Zg(),L=Jg();(Object.keys(R).length>0||L!=="default")&&ye.updatePreferences({appearances:R,theme:L}).catch(()=>{})}}).catch(()=>{}))},[]),w.useEffect(()=>{_6(a)},[a]);const g=w.useCallback(C=>e[C]??Pm(C),[e]),v=w.useCallback((C,_)=>{n(R=>{const L={...R,[C]:_};return zh(L),ye.updatePreferences({appearances:L}).catch(()=>{}),L})},[]),b=w.useCallback(C=>{n(_=>{const R={..._};return delete R[C],zh(R),ye.updatePreferences({appearances:R}).catch(()=>{}),R})},[]),j=w.useCallback(C=>{i(C),localStorage.setItem(gm,C),ye.updatePreferences({theme:C}).catch(()=>{})},[]),k=w.useCallback(C=>{u(_=>{const R={..._,...C};return localStorage.setItem(ym,JSON.stringify(R)),ye.updatePreferences({speech:R}).catch(()=>{}),R})},[]),N=w.useCallback(C=>{f(C),localStorage.setItem(Bh,C),ye.updatePreferences({language:C}).catch(()=>{})},[]),E=w.useCallback(C=>{h(_=>{const R=new Set(_);return R.add(C),ye.updatePreferences({purchasedItems:Array.from(R)}).catch(()=>{}),R})},[]);return{appearances:e,getAppearance:g,setAppearance:v,resetAppearance:b,theme:a,setTheme:j,speechSettings:o,setSpeechSettings:k,language:d,setLanguage:N,purchasedItems:m,addPurchasedItem:E}}const $6=3e4,L6=3e5;function I6(){var $;const[e,n]=w.useState("akb"),[a,i]=w.useState(null),[o,u]=w.useState("synced"),[d,f]=w.useState([]),[m,h]=w.useState(null),[x,g]=w.useState(!1),v=w.useRef(null),b=w.useRef(null),j=w.useRef(e);j.current=e;const k=w.useCallback(async()=>{try{const q=await ye.getSaveStatus(j.current);i(q),q.noGit?u("no-git"):u(W=>W==="saving"?W:q.dirty?"dirty":"synced")}catch{u("error")}},[]),N=w.useCallback(async()=>{try{const q=await ye.getSyncStatus(j.current);h({ahead:q.ahead,behind:q.behind,branch:q.branch,hasRemote:q.hasRemote})}catch{}},[]),E=w.useCallback(()=>{v.current&&clearInterval(v.current),k(),v.current=setInterval(k,$6),b.current&&clearInterval(b.current),N(),b.current=setInterval(N,L6)},[k,N]);w.useEffect(()=>()=>{v.current&&clearInterval(v.current),b.current&&clearInterval(b.current)},[]);const C=w.useCallback(q=>{n(q),j.current=q,i(null),h(null),f([]),setTimeout(()=>{k(),N()},0)},[k,N]),_=w.useCallback(async q=>{u("saving");try{const W=await ye.save(q,j.current);return await k(),W}catch(W){throw u("error"),W}},[k]),R=w.useCallback(async()=>{try{const q=await ye.getSaveHistory(20,j.current);f(q)}catch{}},[]),L=w.useCallback(async q=>{u("saving");try{await ye.restoreSave(q,void 0,j.current),await k()}catch(W){throw u("error"),W}},[k]),F=w.useCallback(async()=>{g(!0);try{const q=await ye.pull(j.current);return await k(),await N(),q}catch(q){throw q}finally{g(!1)}},[k,N]),I=w.useCallback(async()=>{try{await ye.initGit(),await k()}catch{u("error")}},[k]),H=a?a.modified.length+a.untracked.length:0,X=(($=a==null?void 0:a.lastCommit)==null?void 0:$.date)??null,A=w.useCallback(async()=>{E()},[E]);return{state:o,dirtyCount:H,lastSaved:X,status:a,save:_,history:d,loadHistory:R,restore:L,refresh:A,initGit:I,repo:e,setRepo:C,syncInfo:m,fetchSyncStatus:N,pull:F,pulling:x}}const ey={cto:["Need to reduce this architecture tech debt...","Don't over-engineer. Keep it minimal.","Performance profiling results are a bit concerning.","Should do a system design review.","If I just strip one abstraction layer, it should work.","Let me check the monitoring dashboard.","Need to go through the code review queue.","It's about time to clean up these module dependencies."],cbo:["Heard the competitor launched a new feature... need to analyze.","Should compile this month's revenue metrics.","It's time to update the market trend report.","Maybe I should benchmark the pricing strategy.","Need to recalculate the ROI.","Let me check the competitor's GitHub star trends.","Thinking about launch timing...","Should re-examine the positioning strategy."],pm:["Is this feature really what users want?","Need to clean up the backlog...","MVP scope keeps expanding.","Analyzing user feedback...","Might need to re-prioritize.","Watch out for scope creep.","Will the roadmap timeline hold...","Should double-check the task dependencies."],engineer:["I want to refactor this code...","Test coverage seems a bit low.","Working code first, perfect code later.","Waiting for PR review...","What could be causing this bug...","Is the build broken?","Need to fix that one type error.","Maybe I should run npm audit."],designer:["This UI flow feels a bit awkward...","Usability first, pretty later.","Need to organize the design system components.","Let me make two quick options and compare.","Should run through the accessibility checklist.","Maybe I should prototype this interaction.","Let me revisit the color palette...","The spacing feels a bit cramped."],qa:['"Works" and "correct" are two different things.',"Organizing edge case scenarios...","Should run the regression test suite.","This part could be converted to automated tests.","Need to go through the pre-release checklist.","Reproducible bug reports are key.","Should run cross-browser tests.","Need to check for performance regressions."],"data-analyst":["Checking the data pipeline status...","Interesting outlier detection pattern.","Need to update the dashboard metrics.","Correlation isn't causation though...","Seems like there is room for SQL query optimization.","It's time for a data quality check."]},ty={cto:["Should I assign more work to the team...","It's time to clean up the architecture debt.","Need to re-examine the tech roadmap.","It's quiet... am I missing something?"],cbo:["It's time to update the market analysis...","Should be preparing the revenue report, but no directives.","Let me check on competitor movements.","It's quiet on the business side..."],pm:["Backlog is pretty quiet... nothing to plan?","It's been a while since we scheduled a sprint.","User feedback must be piling up...","No PRD to write... that's unusual."],engineer:["Nothing to do today... maybe some code reviews.","Task queue is empty. Guess I'll refactor.","Am I missing something?","Should clean up the commit log."],designer:["No design requests coming in. Should I improve something on my own?","Maybe run a UI audit...","Should organize my portfolio.","Let me tidy up the component library."],qa:["No builds to test. Let me improve the automation scripts.","It's quiet... no bugs, or just haven't found them?","Let me review the existing test scenarios.","Should update the test coverage report."],"data-analyst":["No analysis requests coming in...","Maybe I should clean up the data warehouse.","Should verify the past reports."]},H6=[{id:"sup-check-1",relation:"superior-subordinate",minFamiliarity:0,topic:"progress",turns:[{speaker:"A",text:"How's the progress?"},{speaker:"B",text:"Going well. Should be done soon."},{speaker:"A",text:"Good, let me know when it's done."}]},{id:"sup-check-2",relation:"superior-subordinate",minFamiliarity:20,topic:"progress",turns:[{speaker:"A",text:"What are you working on today?"},{speaker:"B",text:"Finishing up what I was doing yesterday."}]},{id:"sub-report-1",relation:"superior-subordinate",minFamiliarity:10,topic:"report",turns:[{speaker:"B",text:"Done with that task from earlier."},{speaker:"A",text:"Nice work. Can you share the results?"},{speaker:"B",text:"Sure, I've updated the docs."}]},{id:"peer-tech-1",relation:"peer",minFamiliarity:20,topic:"tech",turns:[{speaker:"A",text:"What do you think about this design?"},{speaker:"B",text:"I think we could go simpler."},{speaker:"A",text:"Really? Want to look at it together?"}]},{id:"peer-tech-2",relation:"peer",minFamiliarity:30,topic:"tech",turns:[{speaker:"A",text:"Have you used this library before?"},{speaker:"B",text:"Yeah, used it in the last project. It was decent."}]},{id:"close-feedback-1",relation:"peer",minFamiliarity:60,topic:"feedback",turns:[{speaker:"A",text:"Can I be honest with you?"},{speaker:"B",text:"Of course, go ahead."},{speaker:"A",text:"This one feels a bit off. Let's revisit."},{speaker:"B",text:"...Alright. Thanks for the feedback."}]},{id:"clevel-sync-1",relation:"c-level",minFamiliarity:10,topic:"strategy",turns:[{speaker:"A",text:"We need to sync the roadmap with the business timeline."},{speaker:"B",text:"Agreed. I'll have it organized and shared by tomorrow."}]},{id:"clevel-sync-2",relation:"c-level",minFamiliarity:30,topic:"strategy",turns:[{speaker:"A",text:"I have some competitor intel to share."},{speaker:"B",text:"Great, I have a tech update too."},{speaker:"A",text:"Let's sync up when you're free."}]},{id:"casual-coffee",relation:"any",minFamiliarity:30,topic:"casual",turns:[{speaker:"A",text:"Want to grab a coffee?"},{speaker:"B",text:"Sure. Feels like it's going to be a long day."}]},{id:"casual-overtime",relation:"any",minFamiliarity:25,topic:"casual",turns:[{speaker:"A",text:"Working late again..."},{speaker:"B",text:"We're in this together. Hang in there."}]},{id:"casual-lunch",relation:"any",minFamiliarity:35,topic:"casual",turns:[{speaker:"A",text:"What should we get for lunch?"},{speaker:"B",text:"Anything. Feel like we eat the same thing every day."}]},{id:"casual-weekend",relation:"any",minFamiliarity:40,topic:"casual",turns:[{speaker:"A",text:"What did you do this weekend?"},{speaker:"B",text:"Just rested. Was too tired."}]},{id:"bestie-1",relation:"any",minFamiliarity:80,topic:"trust",turns:[{speaker:"A",text:"I'm a bit unsure about this direction..."},{speaker:"B",text:"What's bothering you? Be honest."},{speaker:"A",text:"Thanks. It's nice having someone I can talk to."}]}],U6=18e3,ny=6e3,q6=2500,Y6=30*6e4,kv="tycono:relationships";function X6(){try{const e=localStorage.getItem(kv);return e?JSON.parse(e):[]}catch{return[]}}function W6(e){localStorage.setItem(kv,JSON.stringify(e))}function ku(e,n,a){const[i,o]=n<a?[n,a]:[a,n];let u=e.find(d=>d.roleA===i&&d.roleB===o);return u||(u={roleA:i,roleB:o,dispatches:0,wavesTogether:0,conversations:0,familiarity:0,lastInteraction:new Date().toISOString()},e.push(u)),u}function ju(e){return Math.min(100,e.dispatches*5+e.wavesTogether*10+e.conversations*2)}function Su(e){return e[Math.floor(Math.random()*e.length)]}function V6(e,n,a){const i=a.find(f=>f.id===e),o=a.find(f=>f.id===n);if(!i||!o)return null;const u=i.level==="c-level",d=o.level==="c-level";return u&&d?"c-level":i.reportsTo===n||o.reportsTo===e?"superior-subordinate":(i.reportsTo===o.reportsTo,"peer")}function G6(e,n){return e.relation==="any"?!0:e.relation===n}function K6({roles:e,roleStatuses:n,activeExecs:a,getStandupSpeech:i}){const[o,u]=w.useState(new Map),[d,f]=w.useState(X6),m=w.useRef({}),h=w.useRef(null),x=w.useRef(e),g=w.useRef(n),v=w.useRef(a),b=w.useRef(i),j=w.useRef(d);x.current=e,g.current=n,v.current=a,b.current=i,j.current=d,w.useEffect(()=>{const R=Date.now();for(const[L,F]of Object.entries(n))F==="working"&&(m.current[L]=R)},[n]),w.useEffect(()=>{W6(d)},[d]);const k=w.useCallback(R=>{const L=g.current[R],F=v.current.find($=>$.roleId===R);if(L==="working"&&(F!=null&&F.task))return null;const I=b.current(R);if(I&&Math.random()<.3)return{text:I,type:"work",ts:Date.now()};const H=Date.now(),X=m.current[R]??0;if(H-X>Y6&&Math.random()<.5){const $=ty[R]??ty.engineer;return{text:Su($),type:"guilt",ts:H}}const A=ey[R]??ey.engineer;return{text:Su(A),type:"personality",ts:H}},[]),N=w.useCallback(R=>{if(h.current)return!1;const L=R.filter(oe=>g.current[oe.id]!=="working");if(L.length<2)return!1;const F=[...L].sort(()=>Math.random()-.5),I=F[0],H=F[1],X=V6(I.id,H.id,R);if(!X)return!1;const A=ku(j.current,I.id,H.id),$=ju(A),q=H6.filter(oe=>G6(oe,X)&&$>=oe.minFamiliarity);if(q.length===0)return!1;const W=Su(q);let ie=I.id,P=H.id;W.relation==="superior-subordinate"&&(H.reportsTo===I.id||I.level==="c-level"?(ie=I.id,P=H.id):(ie=H.id,P=I.id)),h.current={templateId:W.id,roleA:ie,roleB:P,turnIdx:0,timer:null};const Y=oe=>{if(!h.current||oe>=W.turns.length){h.current=null,f(B=>{const U=[...B],T=ku(U,ie,P);return T.conversations++,T.familiarity=ju(T),T.lastInteraction=new Date().toISOString(),U}),setTimeout(()=>{u(B=>{const U=new Map(B);return U.delete(ie),U.delete(P),U})},ny);return}const de=W.turns[oe],G=de.speaker==="A"?ie:P,D=de.speaker==="A"?P:ie;u(B=>{const U=new Map(B);if(U.set(G,{text:de.text,type:"social",partnerId:D,ts:Date.now()}),oe>0){const T=W.turns[oe-1].speaker==="A"?ie:P;T!==G&&U.delete(T)}return U}),h.current.turnIdx=oe,h.current.timer=setTimeout(()=>Y(oe+1),q6)};return Y(0),!0},[]);w.useEffect(()=>{const R=setInterval(()=>{const L=x.current;if(L.length===0||h.current||Math.random()<.35&&N(L))return;const F=L.filter(X=>g.current[X.id]!=="working");if(F.length===0)return;const I=Su(F),H=k(I.id);H&&(u(X=>{const A=new Map(X);return A.set(I.id,H),A}),setTimeout(()=>{u(X=>{const A=new Map(X),$=A.get(I.id);return $&&$.ts===H.ts&&A.delete(I.id),A})},ny))},U6);return()=>{var L;clearInterval(R),(L=h.current)!=null&&L.timer&&clearTimeout(h.current.timer)}},[k,N]);const E=w.useCallback(R=>{const L=o.get(R);return(L==null?void 0:L.text)??""},[o]),C=w.useCallback((R,L)=>{f(F=>{const I=[...F],H=ku(I,R,L);return H.dispatches++,H.familiarity=ju(H),H.lastInteraction=new Date().toISOString(),I})},[]),_=w.useCallback(R=>{R.length<2||f(L=>{const F=[...L];for(let I=0;I<R.length;I++)for(let H=I+1;H<R.length;H++){const X=ku(F,R[I],R[H]);X.wavesTogether++,X.familiarity=ju(X),X.lastInteraction=new Date().toISOString()}return F})},[]);return{speeches:o,getSpeech:E,relationships:d,notifyDispatch:C,notifyWave:_}}const jv="tycono:office-chat";let P6=0;function Q6(){return`chat-${Date.now()}-${++P6}`}function Oh(){return[{id:"general",name:"#general",members:[],isDefault:!0,messages:[],topic:"Company-wide announcements and general discussion"},{id:"watercooler",name:"#watercooler",members:[],isDefault:!0,messages:[],topic:"No managers allowed. Vent, gossip, joke around. Talk freely about work frustrations, complain about directives you disagree with, share hot takes."}]}function Z6(){try{const e=localStorage.getItem(jv);if(e){const n=JSON.parse(e);if(n.find(i=>i.id==="office")&&!n.find(i=>i.id==="general")){const i=n.filter(o=>o.id!=="office");return[...Oh(),...i]}const a=Oh();for(const i of a)n.find(o=>o.id===i.id)||n.unshift(i);return n}}catch{}return Oh()}function J6(e){const n=e.map(a=>({...a,messages:a.messages.slice(-200)}));localStorage.setItem(jv,JSON.stringify(n))}function eA(){const[e,n]=w.useState(Z6),[a,i]=w.useState(null),[o,u]=w.useState(new Set);w.useEffect(()=>{J6(e)},[e]);const d=w.useCallback(b=>{i(b),b&&u(j=>{const k=new Set(j);return k.delete(b),k})},[]),f=w.useCallback(b=>{const j={...b,id:Q6()};n(k=>{const N=k.map(E=>E.id==="general"?b.type==="dispatch"?{...E,messages:[...E.messages,j].slice(-200)}:E:b.channelId?E.id===b.channelId?{...E,messages:[...E.messages,j].slice(-200)}:E:E.members.length>0&&E.members.includes(b.roleId)?{...E,messages:[...E.messages,j].slice(-200)}:E);return u(E=>{const C=new Set(E);for(const _ of N){const R=k.find(L=>L.id===_.id);R&&_.messages.length>R.messages.length&&C.add(_.id)}return C}),N})},[]),m=w.useCallback((b,j,k)=>{const N=`ch-${Date.now()}`,E={id:N,name:b.startsWith("#")?b:`#${b}`,members:j,isDefault:!1,messages:[],topic:k};n(C=>[...C,E]),i(N)},[]),h=w.useCallback(b=>{n(j=>j.filter(k=>k.id!==b||k.isDefault)),i(j=>j===b?"general":j)},[]),x=w.useCallback((b,j)=>{n(k=>k.map(N=>N.id===b&&!N.isDefault?{...N,members:j}:N))},[]),g=w.useCallback((b,j)=>{n(k=>k.map(N=>N.id===b&&!N.isDefault?{...N,topic:j||void 0}:N))},[]),v=w.useCallback(b=>{n(j=>j.map(k=>{if(k.id==="watercooler"){const N=b.filter(E=>E.level!=="c-level").map(E=>E.id);if(k.members.length!==N.length||!N.every(E=>k.members.includes(E)))return{...k,members:N}}return k}))},[]);return{channels:e,activeChannelId:a,setActiveChannelId:d,pushMessage:f,createChannel:m,deleteChannel:h,updateMembers:x,updateTopic:g,unreadChannels:o,syncDefaultMembers:v}}const tA=45e3,ry=5e3,nA=4,rA=20;function aA({roles:e,roleStatuses:n,activeExecs:a,channels:i,relationships:o,pushMessage:u,speechSettings:d,engineType:f,hasApiKey:m}){const x=((d==null?void 0:d.mode)==="auto"?f==="claude-cli"||f==="local"?"llm":"template":(d==null?void 0:d.mode)??"template")==="llm"&&(m!==!1||f==="claude-cli"),g=((d==null?void 0:d.intervalSec)??tA/1e3)*1e3,v=w.useRef(e),b=w.useRef(n),j=w.useRef(a),k=w.useRef(i),N=w.useRef(o),E=w.useRef(u),C=w.useRef(0),_=w.useRef(!1);v.current=e,b.current=n,j.current=a,k.current=i,N.current=o,E.current=u;const R=w.useCallback(async(I,H)=>{if(_.current)return!1;_.current=!0;try{if(!v.current.find(Y=>Y.id===I))return!1;const A=H.messages.slice(-rA).map(Y=>({roleId:Y.roleId,text:Y.text,ts:Y.ts})),$=v.current.filter(Y=>H.members.includes(Y.id)),q=N.current.filter(Y=>Y.roleA===I||Y.roleB===I).map(Y=>({partnerId:Y.roleA===I?Y.roleB:Y.roleA,familiarity:Y.familiarity})),W=j.current.find(Y=>Y.roleId===I),ie=W?{currentTask:W.task,taskProgress:null}:{currentTask:null,taskProgress:null},P=await ye.chatInChannel({channelId:H.name.replace("#",""),channelTopic:H.topic,roleId:I,history:A,members:$.map(Y=>({id:Y.id,name:Y.name,level:Y.level})),relationships:q,workContext:ie});return P.message?(E.current({ts:Date.now(),roleId:I,text:P.message,type:"chat",channelId:H.id}),!0):!1}catch{return!1}finally{_.current=!1}},[]),L=w.useCallback(async(I,H)=>{if(C.current>=nA){C.current=0;return}const X=I.members.filter(W=>W!==H&&b.current[W]!=="working");if(X.length===0){C.current=0;return}const A=X[Math.floor(Math.random()*X.length)];if(Math.random()>.7){C.current=0;return}const $=C.current*2e3,q=Math.random()*5e3;setTimeout(async()=>{C.current++;const W=k.current.find(P=>P.id===I.id);if(!W)return;if(await R(A,W)){const P=.6-C.current*.1;Math.random()<P?L(W,A):C.current=0}else C.current=0},ry+$+q)},[R]);return w.useEffect(()=>{if(!x)return;const I=setInterval(async()=>{const H=v.current;if(H.length===0||_.current)return;const X=H.filter(ie=>b.current[ie.id]!=="working");if(X.length===0)return;const A=X[Math.floor(Math.random()*X.length)],$=k.current.filter(ie=>ie.members.length===0?!0:ie.members.includes(A.id));if($.length===0)return;const q=$[Math.floor(Math.random()*$.length)];C.current=0,await R(A.id,q)&&L(q,A.id)},g);return()=>clearInterval(I)},[x,g,R,L]),{triggerCeoReaction:w.useCallback(I=>{if(!x)return;const H=k.current.find(X=>X.id===I);H&&(C.current=0,setTimeout(()=>{L(H,"ceo")},ry))},[x,L])}}const Sv=[[1,8],[3,5],[8,1],[5,3]],lA=[[1,4],[2,3],[4,1],[3,2]];function Cu(e){const n=e===1||e===3?-1:0,a=Sv[e],i=e<2?[0,1]:[1,0],o=n;return[{x:1,y:17,w:10,h:2,c:"#100A06",a:.18},{x:a[0],y:13,w:3,h:4,c:"$pants"},{x:a[1],y:13,w:3,h:4,c:"$pants"},{x:a[0]+1,y:13,w:1,h:3,c:"darken($pants, 25)",a:.2},{x:a[1]+1,y:13,w:1,h:3,c:"darken($pants, 25)",a:.2},{x:a[0],y:16,w:3,h:2,c:"$shoes"},{x:a[1],y:16,w:3,h:2,c:"$shoes"},{x:a[0],y:16,w:3,h:1,c:"lighten($shoes, 25)",a:.4},{x:a[1],y:16,w:3,h:1,c:"lighten($shoes, 25)",a:.4},{x:1,y:o+8,w:10,h:6,c:"$shirt"},{x:2,y:o+8,w:8,h:1,c:"lighten($shirt, 20)",a:.35},{x:1,y:o+8,w:1,h:5,c:"darken($shirt, 30)",a:.2},{x:10,y:o+8,w:1,h:5,c:"darken($shirt, 30)",a:.2},{x:-1,y:o+9+i[0],w:3,h:4-i[0],c:"$shirt"},{x:10,y:o+9+i[1],w:3,h:4-i[1],c:"$shirt"},{x:-1,y:o+12,w:2,h:1,c:"$skin"},{x:11,y:o+12,w:2,h:1,c:"$skin"},{x:4,y:o+6,w:4,h:3,c:"$skin"},{x:1,y:o+0,w:10,h:7,c:"$skin"},{x:3,y:o+3,w:2,h:2,c:"#1A1A2E"},{x:7,y:o+3,w:2,h:2,c:"#1A1A2E"},{x:3,y:o+3,w:1,h:1,c:"#FFF",a:.4},{x:7,y:o+3,w:1,h:1,c:"#FFF",a:.4},{x:5,y:o+6,w:2,h:1,c:"darken($skin, 25)",a:.35},{x:0,y:o+3,w:1,h:1,c:"$skin"},{x:11,y:o+3,w:1,h:1,c:"$skin"},{x:1,y:o+0,w:10,h:3,c:"$hair"},{x:0,y:o+1,w:2,h:3,c:"$hair"},{x:10,y:o+1,w:2,h:3,c:"$hair"},{x:2,y:o+0,w:8,h:1,c:"lighten($hair, 25)",a:.3}]}function Eu(e){const n=e===1||e===3?-1:0,a=Sv[e],i=e<2?[0,1]:[1,0],o=n;return[{x:1,y:17,w:10,h:2,c:"#100A06",a:.18},{x:a[0],y:13,w:3,h:4,c:"$pants"},{x:a[1],y:13,w:3,h:4,c:"$pants"},{x:a[0],y:16,w:3,h:2,c:"$shoes"},{x:a[1],y:16,w:3,h:2,c:"$shoes"},{x:1,y:o+8,w:10,h:6,c:"$shirt"},{x:2,y:o+8,w:8,h:1,c:"lighten($shirt, 20)",a:.2},{x:5,y:o+10,w:2,h:3,c:"darken($shirt, 30)",a:.12},{x:-1,y:o+9+i[0],w:3,h:4-i[0],c:"$shirt"},{x:10,y:o+9+i[1],w:3,h:4-i[1],c:"$shirt"},{x:4,y:o+6,w:4,h:3,c:"$skin"},{x:1,y:o+0,w:10,h:7,c:"$skin"},{x:1,y:o+0,w:10,h:6,c:"$hair"},{x:0,y:o+1,w:2,h:5,c:"$hair"},{x:10,y:o+1,w:2,h:5,c:"$hair"},{x:2,y:o+0,w:8,h:1,c:"lighten($hair, 25)",a:.3},{x:0,y:o+4,w:1,h:1,c:"$skin",a:.6},{x:11,y:o+4,w:1,h:1,c:"$skin",a:.6}]}function Hl(e,n){const a=e===1||e===3?-1:0,i=lA[e],o=a,u=e%2===0?1:0;return n?[{x:1,y:17,w:10,h:2,c:"#100A06",a:.18},{x:i[0],y:13,w:3,h:4,c:"$pants"},{x:i[1],y:13,w:3,h:4,c:"$pants"},{x:i[0],y:16,w:3,h:2,c:"$shoes"},{x:i[1],y:16,w:3,h:2,c:"$shoes"},{x:2,y:o+8,w:8,h:6,c:"$shirt"},{x:2,y:o+8,w:8,h:1,c:"lighten($shirt, 20)",a:.2},{x:8,y:o+9+u,w:3,h:4-u,c:"$shirt"},{x:9,y:o+12,w:2,h:1,c:"$skin"},{x:4,y:o+6,w:4,h:3,c:"$skin"},{x:2,y:o+0,w:8,h:7,c:"$skin"},{x:7,y:o+3,w:2,h:2,c:"#1A1A2E"},{x:7,y:o+3,w:1,h:1,c:"#FFF",a:.3},{x:9,y:o+4,w:1,h:1,c:"darken($skin, 25)",a:.3},{x:2,y:o+0,w:8,h:3,c:"$hair"},{x:1,y:o+1,w:2,h:4,c:"$hair"},{x:9,y:o+1,w:2,h:3,c:"$hair"},{x:3,y:o+0,w:6,h:1,c:"lighten($hair, 25)",a:.25}]:[{x:1,y:17,w:10,h:2,c:"#100A06",a:.18},{x:i[0],y:13,w:3,h:4,c:"$pants"},{x:i[1],y:13,w:3,h:4,c:"$pants"},{x:i[0],y:16,w:3,h:2,c:"$shoes"},{x:i[1],y:16,w:3,h:2,c:"$shoes"},{x:2,y:o+8,w:8,h:6,c:"$shirt"},{x:2,y:o+8,w:8,h:1,c:"lighten($shirt, 20)",a:.2},{x:0,y:o+9+u,w:3,h:4-u,c:"$shirt"},{x:-1,y:o+12,w:2,h:1,c:"$skin"},{x:4,y:o+6,w:4,h:3,c:"$skin"},{x:2,y:o+0,w:8,h:7,c:"$skin"},{x:3,y:o+3,w:2,h:2,c:"#1A1A2E"},{x:3,y:o+3,w:1,h:1,c:"#FFF",a:.3},{x:1,y:o+4,w:1,h:1,c:"darken($skin, 25)",a:.3},{x:2,y:o+0,w:8,h:3,c:"$hair"},{x:1,y:o+1,w:2,h:3,c:"$hair"},{x:9,y:o+1,w:2,h:4,c:"$hair"},{x:3,y:o+0,w:6,h:1,c:"lighten($hair, 25)",a:.25}]}const ay={down:[Cu(0),Cu(1),Cu(2),Cu(3)],up:[Eu(0),Eu(1),Eu(2),Eu(3)],right:[Hl(0,!0),Hl(1,!0),Hl(2,!0),Hl(3,!0)],left:[Hl(0,!1),Hl(1,!1),Hl(2,!1),Hl(3,!1)]},Te="#FAFAF7",Hn="#FFFFFF",De="#EDE8E2",et="#DDD6CC",qo="#1A1A2E",nd="#2A2A2A",Zm="#FFB0B0",ly=[{x:2,y:0,w:1,h:1,c:De},{x:3,y:0,w:1,h:1,c:Te},{x:4,y:0,w:1,h:1,c:Hn},{x:5,y:0,w:1,h:1,c:Te},{x:6,y:0,w:1,h:1,c:De},{x:1,y:1,w:1,h:1,c:et},{x:2,y:1,w:1,h:1,c:Te},{x:3,y:1,w:1,h:1,c:Hn},{x:4,y:1,w:1,h:1,c:Te},{x:5,y:1,w:1,h:1,c:Hn},{x:6,y:1,w:1,h:1,c:Te},{x:7,y:1,w:1,h:1,c:et},{x:0,y:2,w:1,h:1,c:et},{x:1,y:2,w:1,h:1,c:De},{x:2,y:2,w:1,h:1,c:Te},{x:3,y:2,w:1,h:1,c:Te},{x:4,y:2,w:1,h:1,c:Hn},{x:5,y:2,w:1,h:1,c:Te},{x:6,y:2,w:1,h:1,c:Te},{x:7,y:2,w:1,h:1,c:De},{x:8,y:2,w:1,h:1,c:et},{x:1,y:3,w:1,h:1,c:De},{x:2,y:3,w:1,h:1,c:Te},{x:3,y:3,w:1,h:1,c:qo},{x:4,y:3,w:1,h:1,c:Te},{x:5,y:3,w:1,h:1,c:qo},{x:6,y:3,w:1,h:1,c:Te},{x:7,y:3,w:1,h:1,c:De},{x:2,y:4,w:1,h:1,c:De},{x:3,y:4,w:1,h:1,c:Te},{x:4,y:4,w:1,h:1,c:nd},{x:5,y:4,w:1,h:1,c:Te},{x:6,y:4,w:1,h:1,c:De},{x:3,y:5,w:1,h:1,c:et},{x:4,y:5,w:1,h:1,c:De},{x:5,y:5,w:1,h:1,c:et},{x:2,y:6,w:1,h:1,c:De},{x:3,y:6,w:1,h:1,c:Te},{x:4,y:6,w:1,h:1,c:Hn},{x:5,y:6,w:1,h:1,c:Te},{x:6,y:6,w:1,h:1,c:De},{x:2,y:7,w:1,h:1,c:et},{x:3,y:7,w:1,h:1,c:De},{x:4,y:7,w:1,h:1,c:Te},{x:5,y:7,w:1,h:1,c:De},{x:6,y:7,w:1,h:1,c:et}],iA=[{x:3,y:8,w:1,h:1,c:De},{x:5,y:8,w:1,h:1,c:De},{x:3,y:9,w:1,h:1,c:et},{x:5,y:9,w:1,h:1,c:et}],sA=[{x:2,y:8,w:1,h:1,c:De},{x:6,y:8,w:1,h:1,c:De},{x:2,y:9,w:1,h:1,c:et},{x:6,y:9,w:1,h:1,c:et}],iy=[{x:2,y:0,w:1,h:1,c:De},{x:3,y:0,w:1,h:1,c:Te},{x:4,y:0,w:1,h:1,c:Hn},{x:5,y:0,w:1,h:1,c:Te},{x:6,y:0,w:1,h:1,c:De},{x:1,y:1,w:1,h:1,c:et},{x:2,y:1,w:1,h:1,c:De},{x:3,y:1,w:1,h:1,c:Te},{x:4,y:1,w:1,h:1,c:Hn},{x:5,y:1,w:1,h:1,c:Te},{x:6,y:1,w:1,h:1,c:De},{x:7,y:1,w:1,h:1,c:et},{x:0,y:2,w:1,h:1,c:et},{x:1,y:2,w:1,h:1,c:De},{x:2,y:2,w:1,h:1,c:Te},{x:3,y:2,w:1,h:1,c:Te},{x:4,y:2,w:1,h:1,c:Te},{x:5,y:2,w:1,h:1,c:Te},{x:6,y:2,w:1,h:1,c:Te},{x:7,y:2,w:1,h:1,c:De},{x:8,y:2,w:1,h:1,c:et},{x:1,y:3,w:1,h:1,c:et},{x:2,y:3,w:1,h:1,c:De},{x:3,y:3,w:1,h:1,c:Te},{x:4,y:3,w:1,h:1,c:Te},{x:5,y:3,w:1,h:1,c:Te},{x:6,y:3,w:1,h:1,c:De},{x:7,y:3,w:1,h:1,c:et},{x:2,y:4,w:1,h:1,c:et},{x:3,y:4,w:1,h:1,c:De},{x:4,y:4,w:1,h:1,c:Te},{x:5,y:4,w:1,h:1,c:De},{x:6,y:4,w:1,h:1,c:et},{x:3,y:5,w:1,h:1,c:et},{x:4,y:5,w:1,h:1,c:De},{x:5,y:5,w:1,h:1,c:et},{x:2,y:6,w:1,h:1,c:De},{x:3,y:6,w:1,h:1,c:Te},{x:4,y:6,w:1,h:1,c:Te},{x:5,y:6,w:1,h:1,c:Te},{x:6,y:6,w:1,h:1,c:De},{x:2,y:7,w:1,h:1,c:et},{x:3,y:7,w:1,h:1,c:De},{x:4,y:7,w:1,h:1,c:Te},{x:5,y:7,w:1,h:1,c:De},{x:6,y:7,w:1,h:1,c:et},{x:4,y:5,w:1,h:1,c:Te},{x:4,y:4,w:1,h:1,c:Hn}],oA=[{x:3,y:8,w:1,h:1,c:De},{x:5,y:8,w:1,h:1,c:De},{x:3,y:9,w:1,h:1,c:et},{x:5,y:9,w:1,h:1,c:et}],cA=[{x:2,y:8,w:1,h:1,c:De},{x:6,y:8,w:1,h:1,c:De},{x:2,y:9,w:1,h:1,c:et},{x:6,y:9,w:1,h:1,c:et}],bm=[{x:8,y:0,w:1,h:1,c:De},{x:9,y:0,w:1,h:1,c:Te},{x:10,y:0,w:1,h:1,c:Hn},{x:11,y:0,w:1,h:1,c:Te},{x:7,y:1,w:1,h:1,c:et},{x:8,y:1,w:1,h:1,c:Te},{x:9,y:1,w:1,h:1,c:Hn},{x:10,y:1,w:1,h:1,c:Te},{x:11,y:1,w:1,h:1,c:Te},{x:12,y:1,w:1,h:1,c:De},{x:0,y:2,w:1,h:1,c:Hn},{x:1,y:2,w:1,h:1,c:Te},{x:3,y:2,w:1,h:1,c:De},{x:4,y:2,w:1,h:1,c:Te},{x:5,y:2,w:1,h:1,c:Te},{x:6,y:2,w:1,h:1,c:Te},{x:7,y:2,w:1,h:1,c:De},{x:8,y:2,w:1,h:1,c:Te},{x:9,y:2,w:1,h:1,c:Te},{x:10,y:2,w:1,h:1,c:Te},{x:11,y:2,w:1,h:1,c:Te},{x:12,y:2,w:1,h:1,c:De},{x:0,y:3,w:1,h:1,c:De},{x:1,y:3,w:1,h:1,c:et},{x:3,y:3,w:1,h:1,c:et},{x:4,y:3,w:1,h:1,c:De},{x:5,y:3,w:1,h:1,c:Te},{x:6,y:3,w:1,h:1,c:De},{x:7,y:3,w:1,h:1,c:et},{x:8,y:3,w:1,h:1,c:Te},{x:9,y:3,w:1,h:1,c:qo},{x:10,y:3,w:1,h:1,c:Te},{x:11,y:3,w:1,h:1,c:De},{x:3,y:4,w:1,h:1,c:et},{x:4,y:4,w:1,h:1,c:De},{x:5,y:4,w:1,h:1,c:Te},{x:6,y:4,w:1,h:1,c:De},{x:8,y:4,w:1,h:1,c:De},{x:9,y:4,w:1,h:1,c:Te},{x:10,y:4,w:1,h:1,c:nd}],Cv=[{x:4,y:5,w:1,h:1,c:De},{x:6,y:5,w:1,h:1,c:De},{x:8,y:5,w:1,h:1,c:De},{x:10,y:5,w:1,h:1,c:De},{x:4,y:6,w:1,h:1,c:et},{x:6,y:6,w:1,h:1,c:et},{x:8,y:6,w:1,h:1,c:et},{x:10,y:6,w:1,h:1,c:et}],Ev=[{x:3,y:5,w:1,h:1,c:De},{x:5,y:5,w:1,h:1,c:De},{x:9,y:5,w:1,h:1,c:De},{x:11,y:5,w:1,h:1,c:De},{x:3,y:6,w:1,h:1,c:et},{x:5,y:6,w:1,h:1,c:et},{x:9,y:6,w:1,h:1,c:et},{x:11,y:6,w:1,h:1,c:et}];function Jm(e,n=13){return e.map(a=>({...a,x:n-1-a.x}))}const sy=Jm(bm),uA=Jm(Cv),dA=Jm(Ev),fA={down:[[...ly,...iA],[...ly,...sA]],up:[[...iy,...oA],[...iy,...cA]],right:[[...bm,...Cv],[...bm,...Ev]],left:[[...sy,...uA],[...sy,...dA]]},hA=[{x:4,y:5,w:1,h:1,c:Zm}],_n="#FFD4D4",Zr="#FFCCD5",mA=[{x:2,y:0,w:1,h:1,c:et},{x:3,y:0,w:1,h:1,c:De},{x:4,y:0,w:1,h:1,c:Te},{x:5,y:0,w:1,h:1,c:Hn},{x:6,y:0,w:1,h:1,c:De},{x:7,y:0,w:1,h:1,c:et},{x:1,y:1,w:1,h:1,c:et},{x:2,y:1,w:1,h:1,c:De},{x:3,y:1,w:1,h:1,c:Te},{x:4,y:1,w:1,h:1,c:Hn},{x:5,y:1,w:1,h:1,c:Te},{x:6,y:1,w:1,h:1,c:Hn},{x:7,y:1,w:1,h:1,c:De},{x:8,y:1,w:1,h:1,c:et},{x:1,y:2,w:1,h:1,c:De},{x:2,y:2,w:1,h:1,c:Te},{x:3,y:2,w:1,h:1,c:qo},{x:4,y:2,w:1,h:1,c:Te},{x:5,y:2,w:1,h:1,c:Te},{x:6,y:2,w:1,h:1,c:qo},{x:7,y:2,w:1,h:1,c:Te},{x:8,y:2,w:1,h:1,c:De},{x:2,y:3,w:1,h:1,c:De},{x:3,y:3,w:1,h:1,c:Te},{x:4,y:3,w:1,h:1,c:nd},{x:5,y:3,w:1,h:1,c:Zm},{x:6,y:3,w:1,h:1,c:Te},{x:7,y:3,w:1,h:1,c:De},{x:2,y:4,w:1,h:1,c:et},{x:3,y:4,w:1,h:1,c:De},{x:4,y:4,w:1,h:1,c:Te},{x:5,y:4,w:1,h:1,c:Te},{x:6,y:4,w:1,h:1,c:De},{x:7,y:4,w:1,h:1,c:et},{x:0,y:5,w:1,h:1,c:De},{x:1,y:5,w:1,h:1,c:Zr},{x:2,y:5,w:1,h:1,c:Te},{x:3,y:5,w:1,h:1,c:_n},{x:4,y:5,w:1,h:1,c:_n},{x:5,y:5,w:1,h:1,c:_n},{x:6,y:5,w:1,h:1,c:_n},{x:7,y:5,w:1,h:1,c:Te},{x:8,y:5,w:1,h:1,c:Zr},{x:9,y:5,w:1,h:1,c:De},{x:1,y:6,w:1,h:1,c:De},{x:2,y:6,w:1,h:1,c:Te},{x:3,y:6,w:1,h:1,c:_n},{x:4,y:6,w:1,h:1,c:Zr},{x:5,y:6,w:1,h:1,c:Zr},{x:6,y:6,w:1,h:1,c:_n},{x:7,y:6,w:1,h:1,c:Te},{x:8,y:6,w:1,h:1,c:De},{x:2,y:7,w:1,h:1,c:Te},{x:3,y:7,w:1,h:1,c:_n},{x:4,y:7,w:1,h:1,c:_n},{x:5,y:7,w:1,h:1,c:_n},{x:6,y:7,w:1,h:1,c:_n},{x:7,y:7,w:1,h:1,c:Te},{x:0,y:8,w:1,h:1,c:De},{x:1,y:8,w:1,h:1,c:Zr},{x:2,y:8,w:1,h:1,c:et},{x:3,y:8,w:1,h:1,c:De},{x:4,y:8,w:1,h:1,c:Te},{x:5,y:8,w:1,h:1,c:Te},{x:6,y:8,w:1,h:1,c:De},{x:7,y:8,w:1,h:1,c:et},{x:8,y:8,w:1,h:1,c:Zr},{x:9,y:8,w:1,h:1,c:De},{x:4,y:9,w:1,h:1,c:Te},{x:5,y:9,w:1,h:1,c:Hn}],pA=[{x:2,y:0,w:1,h:1,c:et},{x:3,y:0,w:1,h:1,c:De},{x:4,y:0,w:1,h:1,c:Te},{x:5,y:0,w:1,h:1,c:Hn},{x:6,y:0,w:1,h:1,c:De},{x:7,y:0,w:1,h:1,c:et},{x:1,y:1,w:1,h:1,c:et},{x:2,y:1,w:1,h:1,c:De},{x:3,y:1,w:1,h:1,c:Te},{x:4,y:1,w:1,h:1,c:Hn},{x:5,y:1,w:1,h:1,c:Te},{x:6,y:1,w:1,h:1,c:Hn},{x:7,y:1,w:1,h:1,c:De},{x:8,y:1,w:1,h:1,c:et},{x:1,y:2,w:1,h:1,c:De},{x:2,y:2,w:1,h:1,c:Te},{x:3,y:2,w:1,h:1,c:De},{x:4,y:2,w:1,h:1,c:Te},{x:5,y:2,w:1,h:1,c:Te},{x:6,y:2,w:1,h:1,c:De},{x:7,y:2,w:1,h:1,c:Te},{x:8,y:2,w:1,h:1,c:De},{x:2,y:3,w:1,h:1,c:De},{x:3,y:3,w:1,h:1,c:Te},{x:4,y:3,w:1,h:1,c:nd},{x:5,y:3,w:1,h:1,c:Zm},{x:6,y:3,w:1,h:1,c:Te},{x:7,y:3,w:1,h:1,c:De},{x:2,y:4,w:1,h:1,c:et},{x:3,y:4,w:1,h:1,c:De},{x:4,y:4,w:1,h:1,c:Te},{x:5,y:4,w:1,h:1,c:Te},{x:6,y:4,w:1,h:1,c:De},{x:7,y:4,w:1,h:1,c:et},{x:0,y:5,w:1,h:1,c:De},{x:1,y:5,w:1,h:1,c:Zr},{x:2,y:5,w:1,h:1,c:Te},{x:3,y:5,w:1,h:1,c:_n},{x:4,y:5,w:1,h:1,c:_n},{x:5,y:5,w:1,h:1,c:_n},{x:6,y:5,w:1,h:1,c:_n},{x:7,y:5,w:1,h:1,c:Te},{x:8,y:5,w:1,h:1,c:Zr},{x:9,y:5,w:1,h:1,c:De},{x:1,y:6,w:1,h:1,c:De},{x:2,y:6,w:1,h:1,c:Te},{x:3,y:6,w:1,h:1,c:_n},{x:4,y:6,w:1,h:1,c:Zr},{x:5,y:6,w:1,h:1,c:Zr},{x:6,y:6,w:1,h:1,c:_n},{x:7,y:6,w:1,h:1,c:Te},{x:8,y:6,w:1,h:1,c:De},{x:2,y:7,w:1,h:1,c:Te},{x:3,y:7,w:1,h:1,c:_n},{x:4,y:7,w:1,h:1,c:_n},{x:5,y:7,w:1,h:1,c:_n},{x:6,y:7,w:1,h:1,c:_n},{x:7,y:7,w:1,h:1,c:Te},{x:0,y:8,w:1,h:1,c:De},{x:1,y:8,w:1,h:1,c:Zr},{x:2,y:8,w:1,h:1,c:et},{x:3,y:8,w:1,h:1,c:De},{x:4,y:8,w:1,h:1,c:Te},{x:5,y:8,w:1,h:1,c:Te},{x:6,y:8,w:1,h:1,c:De},{x:7,y:8,w:1,h:1,c:et},{x:8,y:8,w:1,h:1,c:Zr},{x:9,y:8,w:1,h:1,c:De},{x:5,y:9,w:1,h:1,c:Te},{x:6,y:9,w:1,h:1,c:Hn}],xA=[{x:1,y:9,w:7,h:1,c:"#100A06",a:.12}],gA=[{x:2,y:6,w:9,h:1,c:"#100A06",a:.12}],yA=[{x:1,y:10,w:8,h:1,c:"#100A06",a:.12}],ut=4,rn=28,In=2,zt=4,St=4,al=[{wallColor:"#C8B898",baseboardColor:"#6A5840",floorType:"wood"},{wallColor:"#A8B8C8",baseboardColor:"#586878",floorType:"dark"},{wallColor:"#A8C8B0",baseboardColor:"#4A6A50",floorType:"carpet"},{wallColor:"#C8C0A8",baseboardColor:"#7A6A50",floorType:"tile"}];function ep(e,n,a){const u=e.fy+Math.max(10,Math.floor(e.fh*.18)),d=Math.min(n,a),f=Math.ceil(n/d),m=[],h=d*28,x=e.fx+Math.max(8,Math.floor((e.fw-h)/2));for(let g=0;g<f&&m.length<n;g++){const v=Math.min(d,n-g*d);for(let b=0;b<v;b++)m.push({dx:x+b*28,dy:u+g*28,room:e.id})}return m}function bA(e){const i=al[0],o={id:"main",wx:ut+St,wy:ut,ww:160-2*(ut+St),wh:rn,fx:ut+St,fy:ut+rn+In,fw:160-2*(ut+St),fh:120-ut-rn-In-ut,...i},u=ep(o,Math.min(e,6),3),d=[{id:"s-window-l",type:"window",room:"main",zone:"wall",offsetX:10,offsetY:6,windowW:16,windowH:14},{id:"s-window-r",type:"window",room:"main",zone:"wall",anchorX:"right",offsetX:-26,offsetY:6,windowW:16,windowH:14},{id:"s-clock",type:"clock",room:"main",zone:"wall",offsetX:Math.floor((160-2*(ut+St))/2),offsetY:10}],f=[{id:"s-plant-l",type:"plant",room:"main",zone:"floor",offsetX:4,offsetY:4},{id:"s-plant-r",type:"plant",room:"main",zone:"floor",anchorX:"right",offsetX:-8,offsetY:4}];return{preset:"S",canvasW:160,canvasH:120,rooms:{main:o},desks:u,doors:{},adjacency:{main:[]},corridorY:{main:o.fy+o.fh-12},waypoints:{main:[{x:o.fx+10,y:o.fy+o.fh-14},{x:o.fx+o.fw/2,y:o.fy+o.fh-14},{x:o.fx+o.fw-10,y:o.fy+o.fh-14}]},wallDecorations:d,furniture:f}}function vA(e){const o={id:"exec",wx:ut+St,wy:ut,ww:144-ut-St-zt/2,wh:rn,fx:ut+St,fy:ut+rn+In,fw:144-ut-St-zt/2,fh:66,...al[0]},u={id:"work",wx:144+zt/2+St,wy:ut,ww:144-zt/2-St-ut,wh:rn,fx:144+zt/2+St,fy:ut+rn+In,fw:144-zt/2-St-ut,fh:66,...al[1]},d={id:"meet",wx:ut+St,wy:ut+rn+In+66+zt,ww:144-ut-St-zt/2,wh:rn,fx:ut+St,fy:ut+rn+In+66+zt+rn+In,fw:144-ut-St-zt/2,fh:70,...al[2]},f={id:"comm",wx:144+zt/2+St,wy:ut+rn+In+66+zt,ww:144-zt/2-St-ut,wh:rn,fx:144+zt/2+St,fy:ut+rn+In+66+zt+rn+In,fw:144-zt/2-St-ut,fh:70,...al[3]},m={exec:o,work:u,meet:d,comm:f},h=[];let x=e;const g=[[o,Math.min(3,x)],[u,0]];g[1][1]=Math.min(3,x-g[0][1]);const v=[[d,0],[f,0]];let b=x-g[0][1]-g[1][1];b>0&&(v[0][1]=Math.min(2,b),b-=v[0][1]),b>0&&(v[1][1]=Math.min(2,b));for(const[F,I]of[...g,...v])I>0&&h.push(...ep(F,I,3));const j=ut+rn+In+66,k=144-zt/2,N={exec_work:{id:"exec_work",type:"v",doorY:ut+rn+In+20+12,xA:k-2,xB:u.fx+2},meet_comm:{id:"meet_comm",type:"v",doorY:ut+rn+In+66+zt+rn+In+20+12,xA:k-2,xB:f.fx+2},exec_meet:{id:"exec_meet",type:"h",doorX:ut+St+40+14,yA:j-2,yB:d.fy+2},work_comm:{id:"work_comm",type:"h",doorX:144+zt/2+St+40+14,yA:j-2,yB:f.fy+2}},E={exec:[{room:"work",door:"exec_work",side:"A"},{room:"meet",door:"exec_meet",side:"A"}],work:[{room:"exec",door:"exec_work",side:"B"},{room:"comm",door:"work_comm",side:"A"}],meet:[{room:"exec",door:"exec_meet",side:"B"},{room:"comm",door:"meet_comm",side:"A"}],comm:[{room:"work",door:"work_comm",side:"B"},{room:"meet",door:"meet_comm",side:"B"}]},C={exec:o.fy+52,work:u.fy+48,meet:d.fy+56,comm:f.fy+54},_={exec:[{x:o.fx+6,y:o.fy+52},{x:o.fx+60,y:o.fy+54},{x:o.fx+112,y:o.fy+50},{x:o.fx+50,y:o.fy+52}],work:[{x:u.fx+14,y:u.fy+48},{x:u.fx+44,y:u.fy+48},{x:u.fx+70,y:u.fy+48},{x:u.fx+100,y:u.fy+48}],meet:[{x:d.fx+60,y:d.fy+56},{x:d.fx+30,y:d.fy+54},{x:d.fx+110,y:d.fy+50},{x:d.fx+80,y:d.fy+56}],comm:[{x:f.fx+96,y:f.fy+8},{x:f.fx+60,y:f.fy+54},{x:f.fx+40,y:f.fy+54},{x:f.fx+20,y:f.fy+54}]},R=[{id:"exec-window-1",type:"window",room:"exec",zone:"wall",offsetX:10,offsetY:6,windowW:16,windowH:14},{id:"exec-picture-1",type:"picture",room:"exec",zone:"wall",offsetX:34,offsetY:8,pictureColor:"#1565C0",facility:{id:"theme",label:"THEME",icon:"🎨",color:"#42A5F5",hitW:12,hitH:10}},{id:"exec-picture-2",type:"picture",room:"exec",zone:"wall",offsetX:48,offsetY:8,pictureColor:"#E65100"},{id:"exec-clock",type:"clock",room:"exec",zone:"wall",offsetX:64,offsetY:10,facility:{id:"settings",label:"SETTINGS",icon:"⚙",color:"#78909C",hitW:10,hitH:10}},{id:"exec-shelf",type:"shelf",room:"exec",zone:"wall",offsetX:78,offsetY:14,facility:{id:"stats",label:"STATS",icon:"📊",color:"#7E57C2",hitW:16,hitH:8}},{id:"exec-window-2",type:"window",room:"exec",zone:"wall",offsetX:104,offsetY:6,windowW:16,windowH:14},{id:"work-whiteboard",type:"whiteboard",room:"work",zone:"wall",offsetX:6,offsetY:4},{id:"work-window-1",type:"window",room:"work",zone:"wall",offsetX:50,offsetY:6,windowW:16,windowH:14},{id:"work-window-2",type:"window",room:"work",zone:"wall",offsetX:92,offsetY:6,windowW:16,windowH:14},{id:"meet-bulletin",type:"bulletin-board",room:"meet",zone:"wall",offsetX:6,offsetY:4,facility:{id:"bulletin",label:"BULLETIN",icon:"📋",color:"#F59E0B",hitW:22,hitH:16}},{id:"meet-picture",type:"picture",room:"meet",zone:"wall",offsetX:28,offsetY:8,pictureColor:"#10B981"},{id:"meet-window",type:"window",room:"meet",zone:"wall",offsetX:80,offsetY:6,windowW:16,windowH:14},{id:"meet-shelf",type:"shelf",room:"meet",zone:"wall",offsetX:102,offsetY:18},{id:"comm-screen",type:"screen",room:"comm",zone:"wall",offsetX:6,offsetY:6,facility:{id:"decisions",label:"DECISIONS",icon:"📜",color:"#EF4444",hitW:16,hitH:12}},{id:"comm-picture",type:"picture",room:"comm",zone:"wall",offsetX:28,offsetY:8,pictureColor:"#d4956a"},{id:"comm-window",type:"window",room:"comm",zone:"wall",offsetX:76,offsetY:6,windowW:16,windowH:14},{id:"comm-clock",type:"clock",room:"comm",zone:"wall",offsetX:98,offsetY:10},{id:"comm-shelf",type:"shelf",room:"comm",zone:"wall",offsetX:108,offsetY:18}],L=[{id:"exec-bookshelf",type:"bookshelf",room:"exec",zone:"floor",offsetX:2,offsetY:4},{id:"exec-plant-r",type:"plant",room:"exec",zone:"floor",anchorX:"right",offsetX:-10,offsetY:4},{id:"exec-plant-c",type:"plant",room:"exec",zone:"floor",offsetX:Math.floor(o.fw/2),offsetY:4},{id:"work-plant-1",type:"plant",room:"work",zone:"floor",offsetX:36,offsetY:4},{id:"work-plant-2",type:"plant",room:"work",zone:"floor",offsetX:80,offsetY:4},{id:"meet-plant",type:"plant",room:"meet",zone:"floor",anchorX:"right",offsetX:-12,offsetY:4},{id:"meet-table",type:"meeting-table",room:"meet",zone:"floor",offsetX:10,offsetY:42,facility:{id:"meeting",label:"MEETING",icon:"🏢",color:"#3B82F6",hitW:44,hitH:40}},{id:"comm-coffee-machine",type:"coffee-machine",room:"comm",zone:"floor",anchorX:"right",offsetX:-30,offsetY:4,condition:"no-desks"},{id:"comm-plant-1",type:"plant",room:"comm",zone:"floor",offsetX:38,offsetY:4,condition:"no-desks"},{id:"comm-bookshelf",type:"bookshelf",room:"comm",zone:"floor",anchorX:"right",offsetX:-26,offsetY:16,accent:"#10B981",condition:"no-desks",facility:{id:"knowledge",label:"KNOWLEDGE",icon:"📚",color:"#10B981",hitW:26,hitH:24}},{id:"comm-sofa",type:"sofa",room:"comm",zone:"floor",offsetX:44,offsetY:30,condition:"no-desks"},{id:"comm-coffee-table",type:"coffee-table",room:"comm",zone:"floor",offsetX:50,offsetY:50,condition:"no-desks"},{id:"comm-plant-2",type:"plant",room:"comm",zone:"floor",offsetX:38,offsetY:50,condition:"no-desks"}];return{preset:"M",canvasW:288,canvasH:208,rooms:m,desks:h,doors:N,adjacency:E,corridorY:C,waypoints:_,wallDecorations:R,furniture:L}}function wA(e){const d={id:"exec",wx:ut+St,wy:ut,ww:180-ut-St-zt/2,wh:rn,fx:ut+St,fy:ut+rn+In,fw:180-ut-St-zt/2,fh:82,...al[0]},f={id:"work",wx:180+zt/2+St,wy:ut,ww:180-zt/2-St-ut,wh:rn,fx:180+zt/2+St,fy:ut+rn+In,fw:180-zt/2-St-ut,fh:82,...al[1]},m=ut+rn+In+82,h={id:"meet",wx:ut+St,wy:m+zt,ww:180-ut-St-zt/2,wh:rn,fx:ut+St,fy:m+zt+rn+In,fw:180-ut-St-zt/2,fh:86,...al[2]},x={id:"comm",wx:180+zt/2+St,wy:m+zt,ww:180-zt/2-St-ut,wh:rn,fx:180+zt/2+St,fy:m+zt+rn+In,fw:180-zt/2-St-ut,fh:86,...al[3]},g={exec:d,work:f,meet:h,comm:x},v=[];let b=e;const j=[[d,Math.min(5,b)],[f,0]];j[1][1]=Math.min(5,b-j[0][1]);const k=[[h,0],[x,0]];let N=b-j[0][1]-j[1][1];N>0&&(k[0][1]=Math.min(3,N),N-=k[0][1]),N>0&&(k[1][1]=Math.min(3,N));for(const[H,X]of[...j,...k])X>0&&v.push(...ep(H,X,4));const E=180-zt/2,C={exec_work:{id:"exec_work",type:"v",doorY:d.fy+82/2,xA:E-2,xB:f.fx+2},meet_comm:{id:"meet_comm",type:"v",doorY:h.fy+86/2,xA:E-2,xB:x.fx+2},exec_meet:{id:"exec_meet",type:"h",doorX:d.fx+54,yA:m-2,yB:h.fy+2},work_comm:{id:"work_comm",type:"h",doorX:f.fx+54,yA:m-2,yB:x.fy+2}},_={exec:[{room:"work",door:"exec_work",side:"A"},{room:"meet",door:"exec_meet",side:"A"}],work:[{room:"exec",door:"exec_work",side:"B"},{room:"comm",door:"work_comm",side:"A"}],meet:[{room:"exec",door:"exec_meet",side:"B"},{room:"comm",door:"meet_comm",side:"A"}],comm:[{room:"work",door:"work_comm",side:"B"},{room:"meet",door:"meet_comm",side:"B"}]},R={exec:d.fy+82-12,work:f.fy+82-12,meet:h.fy+86-12,comm:x.fy+86-12},L={exec:[{x:d.fx+10,y:R.exec},{x:d.fx+d.fw/2,y:R.exec},{x:d.fx+d.fw-10,y:R.exec}],work:[{x:f.fx+10,y:R.work},{x:f.fx+f.fw/2,y:R.work},{x:f.fx+f.fw-10,y:R.work}],meet:[{x:h.fx+10,y:R.meet},{x:h.fx+h.fw/2,y:R.meet},{x:h.fx+h.fw-10,y:R.meet}],comm:[{x:x.fx+10,y:R.comm},{x:x.fx+x.fw/2,y:R.comm},{x:x.fx+x.fw-10,y:R.comm}]},F=[{id:"exec-window-1",type:"window",room:"exec",zone:"wall",offsetX:10,offsetY:6,windowW:16,windowH:14},{id:"exec-picture-1",type:"picture",room:"exec",zone:"wall",offsetX:34,offsetY:8,pictureColor:"#1565C0",facility:{id:"theme",label:"THEME",icon:"🎨",color:"#42A5F5",hitW:12,hitH:10}},{id:"exec-picture-2",type:"picture",room:"exec",zone:"wall",offsetX:48,offsetY:8,pictureColor:"#E65100"},{id:"exec-clock",type:"clock",room:"exec",zone:"wall",offsetX:64,offsetY:10,facility:{id:"settings",label:"SETTINGS",icon:"⚙",color:"#78909C",hitW:10,hitH:10}},{id:"exec-shelf",type:"shelf",room:"exec",zone:"wall",offsetX:78,offsetY:14,facility:{id:"stats",label:"STATS",icon:"📊",color:"#7E57C2",hitW:16,hitH:8}},{id:"exec-window-2",type:"window",room:"exec",zone:"wall",offsetX:104,offsetY:6,windowW:16,windowH:14},{id:"work-whiteboard",type:"whiteboard",room:"work",zone:"wall",offsetX:6,offsetY:4},{id:"work-window-1",type:"window",room:"work",zone:"wall",offsetX:50,offsetY:6,windowW:16,windowH:14},{id:"work-window-2",type:"window",room:"work",zone:"wall",offsetX:92,offsetY:6,windowW:16,windowH:14},{id:"meet-bulletin",type:"bulletin-board",room:"meet",zone:"wall",offsetX:6,offsetY:4,facility:{id:"bulletin",label:"BULLETIN",icon:"📋",color:"#F59E0B",hitW:22,hitH:16}},{id:"meet-picture",type:"picture",room:"meet",zone:"wall",offsetX:28,offsetY:8,pictureColor:"#10B981"},{id:"meet-window",type:"window",room:"meet",zone:"wall",offsetX:80,offsetY:6,windowW:16,windowH:14},{id:"meet-shelf",type:"shelf",room:"meet",zone:"wall",offsetX:102,offsetY:18},{id:"comm-screen",type:"screen",room:"comm",zone:"wall",offsetX:6,offsetY:6,facility:{id:"decisions",label:"DECISIONS",icon:"📜",color:"#EF4444",hitW:16,hitH:12}},{id:"comm-picture",type:"picture",room:"comm",zone:"wall",offsetX:28,offsetY:8,pictureColor:"#d4956a"},{id:"comm-window",type:"window",room:"comm",zone:"wall",offsetX:76,offsetY:6,windowW:16,windowH:14},{id:"comm-clock",type:"clock",room:"comm",zone:"wall",offsetX:98,offsetY:10},{id:"comm-shelf",type:"shelf",room:"comm",zone:"wall",offsetX:108,offsetY:18}],I=[{id:"exec-bookshelf",type:"bookshelf",room:"exec",zone:"floor",offsetX:2,offsetY:4},{id:"exec-plant-r",type:"plant",room:"exec",zone:"floor",anchorX:"right",offsetX:-10,offsetY:4},{id:"exec-plant-c",type:"plant",room:"exec",zone:"floor",offsetX:Math.floor(d.fw/2),offsetY:4},{id:"work-plant-1",type:"plant",room:"work",zone:"floor",offsetX:36,offsetY:4},{id:"work-plant-2",type:"plant",room:"work",zone:"floor",offsetX:80,offsetY:4},{id:"meet-plant",type:"plant",room:"meet",zone:"floor",anchorX:"right",offsetX:-12,offsetY:4},{id:"meet-table",type:"meeting-table",room:"meet",zone:"floor",offsetX:10,offsetY:42,facility:{id:"meeting",label:"MEETING",icon:"🏢",color:"#3B82F6",hitW:44,hitH:40}},{id:"comm-coffee-machine",type:"coffee-machine",room:"comm",zone:"floor",anchorX:"right",offsetX:-30,offsetY:4,condition:"no-desks"},{id:"comm-plant-1",type:"plant",room:"comm",zone:"floor",offsetX:38,offsetY:4,condition:"no-desks"},{id:"comm-bookshelf",type:"bookshelf",room:"comm",zone:"floor",anchorX:"right",offsetX:-26,offsetY:16,accent:"#10B981",condition:"no-desks",facility:{id:"knowledge",label:"KNOWLEDGE",icon:"📚",color:"#10B981",hitW:26,hitH:24}},{id:"comm-sofa",type:"sofa",room:"comm",zone:"floor",offsetX:44,offsetY:30,condition:"no-desks"},{id:"comm-coffee-table",type:"coffee-table",room:"comm",zone:"floor",offsetX:50,offsetY:50,condition:"no-desks"},{id:"comm-plant-2",type:"plant",room:"comm",zone:"floor",offsetX:38,offsetY:50,condition:"no-desks"}];return{preset:"L",canvasW:360,canvasH:260,rooms:g,desks:v,doors:C,adjacency:_,corridorY:R,waypoints:L,wallDecorations:F,furniture:I}}const kA=2;function Nv(e,n,a){return a||(n?n==="L"&&e<=12-kA?"M":n==="M"&&e>12?"L":n:e<=12?"M":"L")}function Av(e,n){switch(n??Nv(e)){case"S":return bA(e);case"M":return vA(e);case"L":return wA(e)}}function jA(e,n){if(!n||Object.keys(n).length===0)return e;const a=i=>i.map(o=>{const u=n[o.id];return u?{...o,offsetX:u.offsetX,offsetY:u.offsetY}:o});return{...e,wallDecorations:a(e.wallDecorations),furniture:a(e.furniture)}}function SA(e,n){if(n)for(const[a,i]of Object.entries(n))e[a]&&(e[a]={...e[a],dx:i.dx,dy:i.dy})}function oy(e,n){if(!n||n.length===0)return e;const a=new Set(n);return{...e,wallDecorations:e.wallDecorations.filter(i=>!a.has(i.id)),furniture:e.furniture.filter(i=>!a.has(i.id))}}function CA(e,n){if(!n||n.length===0)return e;const a=[],i=[];for(const o of n)o.zone==="wall"?a.push(o):i.push(o);return{...e,wallDecorations:[...e.wallDecorations,...a],furniture:[...e.furniture,...i]}}let zo;function EA(e){zo=e}function O(e,n,a,i,o,u){e=Math.round(e),n=Math.round(n),!(u!==void 0&&u<.01)&&(u!==void 0&&u!==1&&(zo.globalAlpha=u),zo.fillStyle=o,zo.fillRect(e,n,a,i),u!==void 0&&u!==1&&(zo.globalAlpha=1))}function st(e,n,a,i){O(e,n,1,1,a,i)}let Bu=1;function As(e){Bu=e}function Na(){return Bu=Bu*16807%2147483647,(Bu&65535)/65535}function Dv(e){const n=parseInt(e.slice(1,3),16)/255,a=parseInt(e.slice(3,5),16)/255,i=parseInt(e.slice(5,7),16)/255,o=Math.max(n,a,i),u=Math.min(n,a,i);let d=0,f=0;const m=(o+u)/2;if(o!==u){const h=o-u;f=m>.5?h/(2-o-u):h/(o+u),o===n?d=((a-i)/h+(a<i?6:0))/6:o===a?d=((i-n)/h+2)/6:d=((n-a)/h+4)/6}return[d*360,f*100,m*100]}function Tv(e,n,a){e=(e%360+360)%360,n=Math.max(0,Math.min(100,n))/100,a=Math.max(0,Math.min(100,a))/100;const i=n*Math.min(a,1-a),o=d=>{const f=(d+e/30)%12;return a-i*Math.max(-1,Math.min(f-3,9-f,1))},u=d=>Math.round(d*255).toString(16).padStart(2,"0");return"#"+u(o(0))+u(o(8))+u(o(4))}function Aa(e,n=1){const[a,i,o]=Dv(e);return Tv(a+15*n,Math.min(100,i+8),o-12*n)}function vn(e,n=1){const[a,i,o]=Dv(e);return Tv(a-10*n,i-3,o+10*n)}const Ln={hi:"#D4AA5C",base:"#B08040",sh:"#7A5038",deep:"#4E3028"},_r={hi:"#8A6848",base:"#604832",sh:"#3A2E24",deep:"#2A1E18"},va={hi:"#5A6A80",base:"#485868",sh:"#364858",deep:"#283848"},Jr="#100A06";function NA(e,n,a=14,i=12){O(e,n,a,i,"#4A3828"),O(e+1,n+1,a-2,i-2,"#5A4838"),O(e+2,n+2,a-4,i-4,"#4A7098"),O(e+2,n+2,a-4,Math.floor((i-4)/2),"#6A90B8",.35);const o=Math.floor(a/2);O(e+o,n+1,1,i-2,"#4A3828"),O(e+1,n+Math.floor(i/2),a-2,1,"#4A3828",.5),st(e+3,n+3,"#8AB8E8",.35),st(e+o+2,n+3,"#8AB8E8",.25),O(e-1,n+i,a+2,2,"#5A4838"),O(e-1,n+i,a+2,1,vn("#5A4838",.5),.35)}function AA(e,n,a){O(e,n,10,8,"#3A2818"),O(e+1,n+1,8,6,a),O(e+2,n+2,4,3,vn(a,1.2),.3),st(e+3,n+2,vn(a,2),.25)}function DA(e,n){O(e,n,7,7,"#3A2818"),O(e+1,n+1,5,5,"#F0EDE5"),st(e+3,n+1,"#AAA"),st(e+3,n+5,"#AAA"),st(e+1,n+3,"#AAA"),st(e+5,n+3,"#AAA"),st(e+3,n+3,"#222"),O(e+3,n+1,1,2,"#333"),st(e+4,n+3,"#D32F2F")}function TA(e,n){O(e,n,26,16,"#586878"),O(e+1,n+1,24,13,"#ECEFF1"),O(e+1,n+1,24,1,"#F5F5F5",.4),O(e+3,n+3,14,1,"#1565C0",.6),O(e+3,n+5,18,1,"#333",.2),O(e+3,n+7,12,1,"#D32F2F",.35),O(e+3,n+9,16,1,"#333",.15),O(e+1,n+14,24,2,"#708898"),O(e+3,n+14,3,1,"#D32F2F"),O(e+7,n+14,3,1,"#1565C0"),O(e+11,n+14,3,1,"#2E7D32")}function FA(e,n){O(e,n,22,16,"#6A5030"),O(e+1,n+1,20,14,"#C4A66A"),As(88);for(let a=0;a<14;a++)for(let i=0;i<20;i++)Na()>.5&&st(e+1+i,n+1+a,Na()>.5?"#B89858":"#D4B87A",.18);O(e+2,n+2,5,4,"#FFF176"),O(e+8,n+2,5,4,"#90CAF9"),O(e+14,n+3,5,4,"#CE93D8"),O(e+3,n+8,7,4,"#C8E6C9"),O(e+11,n+8,8,4,"#F8BBD0"),st(e+4,n+2,"#E53935"),st(e+10,n+2,"#1E88E5"),st(e+16,n+3,"#FF9800")}function MA(e,n){O(e,n,20,3,"#5A4030"),O(e,n,20,1,vn("#5A4030",.5),.35),O(e,n+2,20,1,Aa("#5A4030",.5),.3),O(e+2,n-4,3,4,"#E53935"),O(e+2,n-4,3,1,vn("#E53935",1),.3),O(e+6,n-3,2,3,"#1E88E5"),O(e+9,n-5,4,5,"#43A047"),O(e+14,n-3,3,3,"#FFD54F"),st(e+15,n-3,"#FFF176",.4)}function RA(e,n){O(e,n,16,12,"#1E1E28"),O(e+1,n+1,14,9,"#0C1420"),O(e+2,n+2,12,1,"#EF4444",.6),st(e+2,n+4,"#4CAF50"),O(e+4,n+4,7,1,"#8b949e",.4),st(e+2,n+6,"#FF9800"),O(e+4,n+6,5,1,"#8b949e",.3),st(e+2,n+8,"#42A5F5"),O(e+4,n+8,8,1,"#8b949e",.25),O(e+7,n+10,2,2,"#1E1E28"),O(e+5,n+11,6,1,"#586878")}function zA(e,n,a){O(e+2,n+20,22,2,Jr,.15),O(e,n,22,20,_r.deep),O(e+1,n+1,20,18,_r.base),O(e,n,22,1,_r.hi,.35),O(e,n,1,20,_r.hi,.2);for(const u of[6,12])O(e+1,n+u,20,2,_r.sh),O(e+1,n+u,20,1,_r.hi,.2);const i=["#E53935","#1E88E5","#43A047","#8E24AA","#FB8C00","#00897B","#5C6BC0"];let o=e+2;for(let u=0;u<5;u++){const d=2+u%2;O(o,n+1,d,5,i[u]),O(o,n+1,d,1,vn(i[u],1),.35),o+=d+1}o=e+2;for(let u=0;u<4;u++)O(o,n+7,4,5,i[u+3]),O(o,n+7,4,1,vn(i[u+3],1),.25),o+=5;O(e+2,n+14,4,4,"#FFD54F"),O(e+8,n+14,7,4,"#90CAF9"),a&&O(e,n-1,22,1,a,.7)}function _A(e,n){O(e+2,n+11,6,2,Jr,.1),O(e+2,n+8,6,4,"#8B5E3C"),O(e+1,n+7,8,2,Aa("#A06E48",.3)),O(e+2,n+7,6,1,vn("#A06E48",.5),.4),O(e+1,n+3,3,4,"#2E7D32"),O(e+5,n+2,3,4,"#2E7D32"),O(e+2,n+1,4,4,"#43A047"),O(e+3,n+0,3,3,"#66BB6A"),st(e+4,n,"#81C784"),st(e+3,n+1,"#A5D6A7",.4)}function BA(e,n){wi(e+4,n-4,"down"),wi(e+16,n-4,"down"),wi(e+28,n-4,"down"),O(e+3,n+24,34,3,Jr,.15),O(e,n+2,36,18,Ln.deep),O(e+1,n+3,34,16,Ln.base),O(e+1,n+3,34,1,Ln.hi,.35);for(let a=0;a<14;a+=3)O(e+1,n+4+a,34,1,Aa(Ln.base,.2),.08);O(e,n+20,36,4,Ln.deep),O(e+1,n+21,34,2,Ln.sh),O(e+6,n+7,10,6,"#1A1A24"),O(e+7,n+8,8,4,"#0C1420"),O(e+8,n+9,4,1,"#2A6898",.4),O(e+20,n+8,6,4,"#F0F0F0"),O(e+15,n+7,3,3,"#ECEFF1"),st(e+16,n+8,"#795548"),wi(e+4,n+24,"up"),wi(e+16,n+24,"up"),wi(e+28,n+24,"up")}function OA(e,n){O(e+2,n+16,36,3,Jr,.15),O(e,n,36,5,"#5D4037"),O(e+1,n+1,34,3,"#6D4C41"),O(e+1,n+1,34,1,vn("#6D4C41",.5),.3),O(e,n+5,36,8,"#5D4037"),O(e+2,n+6,15,6,"#6D4C41"),O(e+3,n+6,13,1,vn("#6D4C41",.5),.35),O(e+19,n+6,15,6,"#6D4C41"),O(e+20,n+6,13,1,vn("#6D4C41",.5),.35),O(e+17,n+6,2,6,"#5D4037"),O(e,n+13,36,3,Aa("#5D4037",1)),O(e-2,n+2,3,12,"#5D4037"),O(e+35,n+2,3,12,"#5D4037"),O(e+4,n+7,6,4,"#FF8A65"),O(e+5,n+7,4,1,vn("#FF8A65",1),.35)}function $A(e,n){O(e+2,n+10,22,2,Jr,.12),O(e,n,22,8,_r.deep),O(e+1,n+1,20,6,_r.base),O(e+1,n+1,20,1,_r.hi,.3),O(e,n+8,22,2,_r.sh),O(e+3,n+2,6,4,"#F0F0F0"),O(e+13,n+3,3,3,"#ECEFF1"),st(e+14,n+4,"#795548")}function LA(e,n){O(e+1,n+14,10,2,Jr,.12),O(e,n,10,14,"#546E7A"),O(e,n,10,1,vn("#546E7A",1),.35),O(e+1,n+1,8,3,"#78909C"),O(e+1,n+5,8,4,"#37474F"),st(e+2,n+6,"#EF5350"),st(e+4,n+6,"#66BB6A"),O(e+2,n+11,4,2,"#ECEFF1")}function IA(e,n){O(e+2,n+18,28,3,Jr,.12),O(e,n,28,18,"#37474F"),O(e+1,n+1,26,15,"#0D47A1"),O(e+2,n+2,24,13,"#1565C0"),O(e+2,n+2,24,4,"#1976D2",.4),O(e+2,n+12,24,3,"#F9A825",.35),O(e+4,n+8,2,5,"#2E7D32"),O(e+6,n+9,2,4,"#43A047"),O(e+20,n+7,2,6,"#2E7D32"),O(e+22,n+8,2,5,"#388E3C"),O(e+9,n+5,4,2,"#FF8A65"),st(e+12,n+5,"#FF5722"),O(e+16,n+8,3,2,"#FFD54F"),st(e+15,n+8,"#FFC107"),st(e+13,n+3,"#90CAF9",.5),st(e+14,n+4,"#BBDEFB",.35),st(e+8,n+3,"#BBDEFB",.3),O(e,n+16,28,2,"#455A64"),O(e+1,n+16,26,1,vn("#455A64",.5),.3)}function HA(e,n){O(e,n,24,10,"#1A1A2E"),O(e+2,n+1,20,8,"#E040FB",.15),O(e+3,n+2,4,6,"#E040FB",.7),O(e+4,n+3,2,4,"#1A1A2E"),O(e+8,n+2,1,6,"#00E5FF",.7),O(e+8,n+2,4,1,"#00E5FF",.7),O(e+8,n+4,4,1,"#00E5FF",.7),O(e+11,n+2,1,3,"#00E5FF",.7),O(e+13,n+2,1,6,"#E040FB",.7),O(e+13,n+2,4,1,"#E040FB",.7),O(e+13,n+4,3,1,"#E040FB",.7),O(e+13,n+7,4,1,"#E040FB",.7),O(e+18,n+2,1,6,"#00E5FF",.7),O(e+21,n+2,1,6,"#00E5FF",.7),O(e+19,n+3,1,2,"#00E5FF",.5),O(e+20,n+5,1,2,"#00E5FF",.5)}function UA(e,n){O(e+2,n+28,16,3,Jr,.15),O(e,n,16,28,"#1A237E"),O(e+1,n+1,14,3,"#283593"),O(e+2,n+4,12,10,"#0D1117"),O(e+3,n+5,10,8,"#1B5E20"),O(e+5,n+6,2,2,"#4CAF50"),O(e+9,n+8,2,2,"#FF5722"),O(e+7,n+10,3,1,"#FFD54F"),st(e+6,n+7,"#81C784"),O(e+1,n+14,14,6,"#1A237E"),O(e+2,n+15,4,4,"#212121"),st(e+4,n+16,"#F44336"),st(e+9,n+16,"#F44336"),st(e+11,n+16,"#2196F3"),st(e+10,n+18,"#FFEB3B"),O(e,n+20,16,8,"#0D47A1"),O(e+1,n+21,14,6,"#1565C0"),O(e,n+4,1,14,"#FF4081",.4),O(e+15,n+4,1,14,"#FF4081",.4)}function qA(e,n){O(e+2,n+24,20,3,Jr,.15),O(e,n,20,24,"#4E342E"),O(e+1,n+1,18,22,"#5D4037"),O(e+2,n+1,16,4,"#FF6F00"),O(e+3,n+2,14,2,"#FF8F00",.6),O(e+2,n+5,16,10,"#1A1A2E"),O(e+3,n+6,14,8,"#212121"),O(e+4,n+7,4,4,"#333"),O(e+5,n+8,2,2,"#E53935"),O(e+10,n+7,4,4,"#333"),O(e+11,n+8,2,2,"#1E88E5"),O(e+3,n+16,14,6,"#3E2723");for(let a=0;a<7;a++)O(e+4+a*2,n+17,1,4,"#5D4037",.5);O(e+1,n+5,18,1,"#FFD54F",.5),O(e+1,n+15,18,1,"#FFD54F",.5)}function YA(e,n){O(e+2,n+22,22,2,Jr,.12),O(e,n,22,22,_r.deep),O(e+1,n+1,20,20,"#37474F"),O(e+2,n+2,18,18,"#546E7A",.3),O(e+1,n+10,20,1,_r.base),O(e+1,n+10,20,1,_r.hi,.2),O(e+4,n+3,4,5,"#FFD54F"),O(e+5,n+4,2,3,"#FFC107"),O(e+4,n+7,4,1,"#FFA000"),st(e+5,n+3,"#FFF176",.5),O(e+13,n+4,4,4,"#B0BEC5"),O(e+14,n+3,2,1,"#CFD8DC"),st(e+14,n+5,"#ECEFF1",.6),O(e+5,n+12,3,3,"#A1887F"),O(e+6,n+11,1,1,"#D7CCC8"),O(e+12,n+12,6,4,"#5D4037"),O(e+13,n+13,4,2,"#FFD54F",.6),O(e+2,n+2,2,18,"#fff",.08)}function XA(e,n){O(e+2,n+16,26,3,Jr,.18),O(e,n,26,10,Ln.deep),O(e+1,n+1,24,8,Ln.base),O(e+1,n+2,24,1,Ln.hi,.2),O(e+1,n+4,24,1,Aa(Ln.base,.2),.1),O(e+1,n+6,24,1,Ln.hi,.15),O(e+1,n+1,24,1,Ln.hi,.4),O(e+1,n+1,1,8,Ln.hi,.2),O(e,n+10,26,5,Ln.deep),O(e+1,n+11,24,3,Ln.sh),O(e+1,n+10,24,1,Aa(Ln.base,1.5),.4),O(e+1,n+14,24,1,Ln.base,.15),O(e+2,n+12,10,1,Ln.deep,.4),O(e+14,n+12,10,1,Ln.deep,.4),st(e+7,n+11,"#C8D0D8",.6),st(e+19,n+11,"#C8D0D8",.6),O(e+6,n-5,14,7,"#1E1E28"),O(e+7,n-4,12,5,"#0C1420"),O(e+8,n-3,5,1,"#2A6898",.6),O(e+8,n-2,8,1,"#1A3858",.4),O(e+8,n-1,3,1,"#2A6898",.35),st(e+7,n-4,"#4A98D8",.25),st(e+12,n+1,"#4CAF50",.4),O(e+12,n+2,2,3,"#586878"),O(e+10,n+4,6,1,"#8898A8"),O(e+6,n+4,12,4,"#222228"),O(e+6,n+4,12,1,"#333338",.4);for(let a=0;a<5;a++)st(e+7+a*2,n+5,"#444",.6),st(e+7+a*2,n+6,"#3A3A3E",.4);O(e+20,n+5,3,4,"#333338"),O(e+20,n+5,3,1,"#444448"),O(e+1,n+3,4,4,"#F0EDE8"),O(e+1,n+3,4,1,"#F8F6F2"),st(e+2,n+5,"#6D4C41")}function wi(e,n,a){O(e+1,n+9,10,2,Jr,.1),st(e+5,n+9,"#1E1E22"),st(e+1,n+10,"#1A1A1E"),st(e+9,n+10,"#1A1A1E"),st(e+3,n+11,"#1A1A1E"),st(e+7,n+11,"#1A1A1E"),O(e+1,n+2,8,6,va.base),O(e+2,n+3,6,4,va.hi,.35),O(e+2,n+3,6,1,vn(va.hi,.5),.25),O(e+1,n+7,8,1,va.deep),a==="up"?(O(e,n+7,10,3,va.deep),O(e+1,n+8,8,1,va.sh)):(O(e,n-1,10,3,va.deep),O(e+1,n,8,1,va.sh)),O(e,n+3,1,4,va.sh),O(e+9,n+3,1,4,va.sh)}const Fv={bookshelf:(e,n,a)=>zA(e,n,a.accent),plant:(e,n)=>_A(e,n),"meeting-table":(e,n)=>BA(e,n),sofa:(e,n)=>OA(e,n),"coffee-table":(e,n)=>$A(e,n),"coffee-machine":(e,n)=>LA(e,n),window:(e,n,a)=>NA(e,n,a.windowW??16,a.windowH??14),picture:(e,n,a)=>AA(e,n,a.pictureColor??"#1565C0"),clock:(e,n)=>DA(e,n),whiteboard:(e,n)=>TA(e,n),"bulletin-board":(e,n)=>FA(e,n),shelf:(e,n)=>MA(e,n),screen:(e,n)=>RA(e,n),aquarium:(e,n)=>IA(e,n),"neon-sign":(e,n)=>HA(e,n),arcade:(e,n)=>UA(e,n),jukebox:(e,n)=>qA(e,n),"trophy-case":(e,n)=>YA(e,n)};function ks(e,n){const a=e.zone==="wall"?n.wx:n.fx,i=e.zone==="wall"?n.wy:n.fy;return{x:e.anchorX==="right"?(e.zone==="wall"?n.wx+n.ww:n.fx+n.fw)+e.offsetX:a+e.offsetX,y:i+e.offsetY}}function WA(e){for(const n of e.wallDecorations){const a=e.rooms[n.room];if(!a)continue;const{x:i,y:o}=ks(n,a),u=Fv[n.type];u&&u(i,o,n)}}function VA(e,n,a){for(const i of e.furniture){const o=e.rooms[i.room];if(!o||i.condition==="no-desks"&&a.has(i.room))continue;const{x:u,y:d}=ks(i,o),f=Fv[i.type];f&&n.push({y:d,draw:()=>f(u,d,i)})}}function ki(e){const n=[],a=[...e.wallDecorations,...e.furniture];for(const i of a){if(!i.facility)continue;const o=e.rooms[i.room];if(!o)continue;const{x:u,y:d}=ks(i,o);n.push({id:i.facility.id,label:i.facility.label,icon:i.facility.icon,color:i.facility.color,dx:u,dy:d,pw:i.facility.hitW,ph:i.facility.hitH})}return n}const GA={bookshelf:{w:22,h:20},plant:{w:10,h:12},"meeting-table":{w:36,h:28},sofa:{w:38,h:16},"coffee-table":{w:22,h:10},"coffee-machine":{w:10,h:14},window:{w:16,h:14},picture:{w:10,h:8},clock:{w:7,h:7},whiteboard:{w:26,h:16},"bulletin-board":{w:22,h:16},shelf:{w:20,h:8},screen:{w:16,h:12},aquarium:{w:28,h:18},"neon-sign":{w:24,h:10},arcade:{w:16,h:28},jukebox:{w:20,h:24},"trophy-case":{w:22,h:22}};function vm(e){return GA[e]??{w:16,h:16}}function $h(e,n,a,i){for(let o=e.furniture.length-1;o>=0;o--){const u=e.furniture[o],d=e.rooms[u.room];if(!d||u.condition==="no-desks"&&i.has(u.room))continue;const{x:f,y:m}=ks(u,d),h=vm(u.type);if(n>=f&&n<=f+h.w&&a>=m&&a<=m+h.h)return u.id}for(let o=e.wallDecorations.length-1;o>=0;o--){const u=e.wallDecorations[o],d=e.rooms[u.room];if(!d)continue;const{x:f,y:m}=ks(u,d),h=vm(u.type);if(n>=f&&n<=f+h.w&&a>=m&&a<=m+h.h)return u.id}return null}function cy(e,n,a,i,o){const d=[...n.wallDecorations,...n.furniture].find(g=>g.id===a);if(!d||d.condition==="no-desks"&&o.has(d.room))return;const f=n.rooms[d.room];if(!f)return;const{x:m,y:h}=ks(d,f),x=vm(d.type);e.save(),e.fillStyle=i,e.globalAlpha=.2,e.fillRect(m-1,h-1,x.w+2,x.h+2),e.globalAlpha=.9,e.strokeStyle=i,e.lineWidth=1,e.strokeRect(m-.5,h-.5,x.w+1,x.h+1),e.restore()}function uy(e,n,a,i){e.save(),e.fillStyle=i,e.globalAlpha=.2,e.fillRect(n-1,a-1,28,42),e.globalAlpha=.9,e.strokeStyle=i,e.lineWidth=1,e.strokeRect(n-.5,a-.5,27,41),e.restore()}function dy(e,n,a){for(const[i,o]of Object.entries(e))if(n>=o.dx&&n<=o.dx+26&&a>=o.dy&&a<=o.dy+40)return i;return null}const fy=[{type:"plant",zone:"floor",label:"Plant",icon:"🪴",price:0},{type:"clock",zone:"wall",label:"Clock",icon:"🕐",price:0},{type:"bookshelf",zone:"floor",label:"Bookshelf",icon:"📚",price:500},{type:"picture",zone:"wall",label:"Picture",icon:"🖼️",price:500},{type:"shelf",zone:"wall",label:"Shelf",icon:"📦",price:800},{type:"window",zone:"wall",label:"Window",icon:"🪟",price:1e3},{type:"sofa",zone:"floor",label:"Sofa",icon:"🛋️",price:1500},{type:"coffee-table",zone:"floor",label:"Coffee Table",icon:"☕",price:1500},{type:"coffee-machine",zone:"floor",label:"Coffee Machine",icon:"☕",price:2e3},{type:"meeting-table",zone:"floor",label:"Meeting Table",icon:"🪑",price:3e3},{type:"whiteboard",zone:"wall",label:"Whiteboard",icon:"📋",price:3e3},{type:"screen",zone:"wall",label:"Screen",icon:"🖥️",price:5e3},{type:"aquarium",zone:"floor",label:"Aquarium",icon:"🐠",price:5e3},{type:"neon-sign",zone:"wall",label:"Neon Sign",icon:"💡",price:3e3},{type:"arcade",zone:"floor",label:"Arcade",icon:"🕹️",price:8e3},{type:"jukebox",zone:"floor",label:"Jukebox",icon:"🎵",price:6e3},{type:"trophy-case",zone:"floor",label:"Trophy Case",icon:"🏆",price:7e3}],Nu=16,KA=4,vi=4,Ou=2,Xt=4,Yl=4;let Qe=Av(7);const Gu={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"},hy={ceo:{en:["Boss?","What's up?","Time for a meeting?","Got any ideas?","How's everyone doing?"],ko:["대표님?","무슨 일이신가요?","회의 시간이신가요?","좋은 아이디어 있으시면 말씀해주세요.","다들 잘하고 있나요?"],ja:["社長?","何かありますか?","会議の時間ですか?","良いアイデアがあれば教えてください。","みんな元気ですか?"]},cto:{en:["Need anything?","Tech question?","Reviewing architecture.","Deploy in a moment.","Want me to look at the code?"],ko:["뭐 필요하신 거 있으세요?","기술 관련 질문이신가요?","아키텍처 리뷰 중이에요.","배포는 조금만 기다려주세요.","코드 봐드릴까요?"],ja:["何かお手伝いしましょうか?","技術的な質問ですか?","アーキテクチャレビュー中です。","デプロイはもう少しお待ちください。","コード見ましょうか?"]},cbo:{en:["Business question?","Reviewing revenue model.","Want to see market research?","Analyzing competitors.","Can I help?"],ko:["비즈니스 관련 얘기신가요?","수익 모델 검토 중이에요.","시장 조사 결과 보실래요?","경쟁사 분석 중입니다.","뭔가 도와드릴까요?"],ja:["ビジネスの話ですか?","収益モデルを検討中です。","市場調査の結果を見ますか?","競合分析中です。","何かお手伝いしましょうか?"]},pm:{en:["Curious about progress?","Updating the roadmap.","Assigning tasks.","Need to re-prioritize?","Preparing sprint review."],ko:["프로젝트 진행 상황 궁금하신가요?","로드맵 업데이트 중이에요.","태스크 할당 중입니다.","우선순위 조정이 필요할까요?","스프린트 리뷰 준비 중이에요."],ja:["進捗が気になりますか?","ロードマップを更新中です。","タスクを割り当て中です。","優先順位の調整が必要ですか?","スプリントレビューの準備中です。"]},engineer:{en:["Working on it!","Fixing a bug.","Need a code review?","Writing tests.","Pushing a PR."],ko:["일하고 있어요!","버그 수정 중입니다.","코드 리뷰 필요하신가요?","테스트 작성 중이에요.","PR 올리고 있어요."],ja:["作業中です!","バグ修正中です。","コードレビュー必要ですか?","テスト書いてます。","PR出してます。"]},designer:{en:["Got design feedback?","Working on mockups.","Thinking about UI improvements.","Picking colors...","Want to see the prototype?"],ko:["디자인 피드백 있으신가요?","목업 작업 중이에요.","UI 개선안 생각 중입니다.","컬러 팔레트 고민 중이에요.","프로토타입 보여드릴까요?"],ja:["デザインのフィードバックありますか?","モックアップ作業中です。","UI改善案を考えています。","カラーパレットを検討中です。","プロトタイプ見せましょうか?"]},qa:{en:["Testing in progress.","Found a bug!","Writing test cases.","Running regression tests.","Quality check in progress."],ko:["테스트 중이에요.","버그 발견했어요!","테스트 케이스 작성 중입니다.","회귀 테스트 진행 중이에요.","품질 체크 중입니다."],ja:["テスト中です。","バグ見つけました!","テストケース作成中です。","回帰テスト実行中です。","品質チェック中です。"]},"data-analyst":{en:["Analyzing data.","Preparing a report.","Want to check the dashboard?","Tracking metrics.","Found an insight!"],ko:["데이터 분석 중이에요.","리포트 준비 중입니다.","대시보드 확인해보실래요?","지표 추적 중이에요.","인사이트 발견했어요!"],ja:["データ分析中です。","レポート準備中です。","ダッシュボード確認しますか?","指標追跡中です。","インサイト発見しました!"]},default:{en:["Hello!","How can I help?","Working hard.","Have a great day!"],ko:["안녕하세요!","무엇을 도와드릴까요?","열심히 일하고 있어요.","좋은 하루 되세요!"],ja:["こんにちは!","何かお手伝いしましょうか?","頑張って仕事してます。","良い一日を!"]}};function PA(e,n){const a=hy[e]||hy.default;return a[n]||a.en||a.default||[]}let ka=ki(Qe);function Mv(e){return{x:e.dx,y:e.dy,w:e.pw,h:e.ph}}function Rv(e){return{cx:e.dx+e.pw/2,botY:e.dy+e.ph}}let wn={};function QA(e){const n={};for(let a=0;a<e.length&&a<Qe.desks.length;a++)n[e[a]]=Qe.desks[a];return n}let Xe,er=null,ji=null,rl=!1,sa=null,Rr=null,zv=0,nr=null,$n=null,Ul=null,wa=null,Lh=900;function ZA(e,n){const{wx:a,wy:i,ww:o,wh:u,wallColor:d,baseboardColor:f}=e,m=Aa(d,.5),h=vn(d,.5),x=[];if(n){const g=n.x-a,v=n.w;g>0&&x.push({sx:a,sw:g}),g+v<o&&x.push({sx:n.x+v,sw:o-g-v})}else x.push({sx:a,sw:o});for(const g of x){O(g.sx,i,g.sw,u,d);for(let v=0;v<u;v+=4)O(g.sx,i+v,g.sw,1,h,.08),O(g.sx,i+v+2,g.sw,1,m,.05);As(Math.round(g.sx*7+i*13));for(let v=0;v<g.sw;v+=3)Na()>.4&&O(g.sx+v,i,1,u,h,.04);O(g.sx,i,g.sw,2,h,.3),O(g.sx,i,g.sw,1,vn(d,1),.2),O(g.sx,i+u-2,g.sw,2,m,.3),O(g.sx,i+u,g.sw,Ou,f),O(g.sx,i+u,g.sw,1,vn(f,.5),.4)}n&&(O(n.x-1,i,1,u+Ou,"#4A3828"),O(n.x+n.w,i,1,u+Ou,"#4A3828"),O(n.x,i,n.w,1,"#0A0808",.12)),O(e.fx,e.fy,e.fw,3,"#0A0808",.12),O(e.fx,e.fy+3,e.fw,2,"#0A0808",.06)}function JA(e){const n="#504038",a=Aa(n,.5),i=vn(n,.5),o=e.wx-Yl,u=e.wy,d=e.wh+Ou+e.fh;O(o,u,Yl,d,n),O(o,u,1,d,i,.3),O(o+Yl-1,u,1,d,a,.4);for(let m=0;m<d;m+=6)O(o+1,u+m,Yl-2,1,i,.06);const f=e.wx+e.ww;O(f,u,Yl,d,n),O(f,u,1,d,i,.2),O(f+Yl-1,u,1,d,a,.3)}function Ih(e){const{fx:n,fy:a,fw:i,fh:o}=e,u="#B08040",d="#C89848",f="#8A6030",m="#6A4820";O(n,a,i,o,u),As(42);for(let h=0;h<o;h+=5){const x=Math.floor(h/5)%2*10;for(let g=-10;g<i+10;g+=20){const v=n+g+x,b=Math.max(n,v),j=Math.min(v+19,n+i)-b;if(j<=0)continue;const k=Na()>.5?d:u;O(b,a+h,j,4,k,.25),O(b,a+h,j,1,d,.3),O(b,a+h+4,j,1,m,.35),v>=n&&v<n+i&&O(v,a+h,1,4,m,.2),O(b,a+h+2,j,1,f,.1)}}O(n,a,i,2,"#0A0808",.08),O(n,a,2,o,"#0A0808",.06)}function my(e){const{fx:n,fy:a,fw:i,fh:o}=e,u="#1C2A38",d="#101820";As(99),O(n,a,i,o,u);for(let f=0;f<o;f+=Nu)for(let m=0;m<i;m+=Nu){const h=Math.min(Nu,i-m),x=Math.min(Nu,o-f);Na()>.5&&O(n+m,a+f,h,x,vn(u,.2),.15),O(n+m+2,a+f+2,h-4,x-4,vn(u,.3),.08),O(n+m,a+f,h,1,d,.5),O(n+m,a+f,1,x,d,.5),O(n+m+1,a+f+1,1,x-1,vn(u,.4),.1),Na()>.85&&st(n+m+4+Math.floor(Na()*8),a+f+4+Math.floor(Na()*8),"#3A6A9A",.08)}}function e8(e){const{fx:n,fy:a,fw:i,fh:o}=e,u="#387848",d="#4A9058",f="#285E38";O(n,a,i,o,u),As(77);for(let h=0;h<o;h+=2)for(let x=0;x<i;x+=2)Na()>.5&&st(n+x,a+h,d,.1),Na()>.8&&st(n+x+1,a+h+1,f,.12);const m=5;O(n+m,a+m,i-m*2,1,d,.45),O(n+m,a+o-m-1,i-m*2,1,f,.45),O(n+m,a+m,1,o-m*2,d,.35),O(n+i-m-1,a+m,1,o-m*2,f,.35)}function t8(e){const{fx:n,fy:a,fw:i,fh:o}=e,u="#D8C490",d="#B09060",f="#907848";As(55);for(let m=0;m<o;m+=8)for(let h=0;h<i;h+=8){const x=Math.min(8,i-h),g=Math.min(8,o-m),v=(h/8+m/8)%2===0?d:u;O(n+h,a+m,x,g,v),O(n+h+1,a+m+1,x-2,1,vn(v,.4),.2),O(n+h+1,a+m+1,1,g-2,vn(v,.4),.15),O(n+h+x-2,a+m+2,1,g-3,Aa(v,.4),.15),O(n+h+2,a+m+g-2,x-3,1,Aa(v,.4),.15),O(n+h,a+m,x,1,f,.3),O(n+h,a+m,1,g,f,.3)}}function n8(){const{canvasW:e,canvasH:n,rooms:a,doors:i}=Qe,o="#2A1E14",u="#3A2E24";if(O(0,0,e,vi,o),O(0,n-vi,e,vi,o),O(0,0,vi,n,o),O(e-vi,0,vi,n,o),O(0,0,e,1,u,.3),O(0,0,1,n,u,.2),!a.exec||!a.work||!a.meet||!a.comm)return;const d=a.exec,f=a.meet,m=e/2,h=m-Xt/2,x=d.fy+d.fh,g=i.exec_work,v=i.meet_comm,b=i.exec_meet,j=i.work_comm,k=24,N=28,E=((g==null?void 0:g.doorY)??d.fy+20)-k/2,C=((b==null?void 0:b.doorX)??vi+Yl+54)-N/2,_=((j==null?void 0:j.doorX)??m+Xt/2+Yl+54)-N/2,R=((v==null?void 0:v.doorY)??f.fy+20)-k/2;O(0,x,C,Xt,o),O(C+N,x,h-C-N,Xt,o),O(h+Xt,x,_-h-Xt,Xt,o),O(_+N,x,e-_-N,Xt,o),O(0,x,C,1,u,.3),O(C+N,x,h-C-N,1,u,.3),O(h+Xt,x,_-h-Xt,1,u,.3),O(_+N,x,e-_-N,1,u,.3),O(h,0,Xt,E,o),O(h,E+k,Xt,x-E-k,o),O(h,x+Xt,Xt,R-x-Xt,o),O(h,R+k,Xt,n-R-k,o),O(h,0,1,E,u,.2),O(h,E+k,1,x-E-k,u,.2),O(h,x+Xt,1,R-x-Xt,u,.2),O(h,R+k,1,n-R-k,u,.2),O(h,E,Xt,k,"#C4A070"),O(h+Xt/2,E,Xt/2,k,"#3A4858"),O(h,R,Xt,k,"#7AA880"),O(h+Xt/2,R,Xt/2,k,"#C8B890");const L="#4A3828";O(h,E-1,Xt,1,L),O(h,E+k,Xt,1,L),O(C-1,x,1,Xt,L),O(C+N,x,1,Xt,L),O(_-1,x,1,Xt,L),O(_+N,x,1,Xt,L),O(h,R-1,Xt,1,L),O(h,R+k,Xt,1,L)}const py=new Map;function r8(e,n="right"){const a=`${e.hairStyle??""}|${e.outfitStyle??""}|${e.accessory??""}|${n}`;let i=py.get(a);if(!i){const o=lm("mini-seated:default"),u=Xb(o,e);let d=u?u.layers.flatMap(f=>f.pixels):[];n==="left"&&d.length>0&&(d=rm(d,12)),i=d,py.set(a,i)}return i}function a8(e,n,a,i="right"){Xl(Xe,r8(a,i),e,n,a)}function l8(e,n,a,i,o,u="right"){wi(e+8,n+20,"up"),o||a8(e+8,n+0+i,a,u),XA(e,n+14)}function i8(e,n,a,i,o){const u=i in ay?i:"down",d=o%4,f=ay[u][d];Xl(Xe,f,e,n,a);const m=d===1||d===3?-1:0;if(a.accessory&&a.accessory!=="none"){const h=mC(a.accessory,u);h&&h.pixels.length>0&&Xl(Xe,h.pixels,e,n+m,a)}Xe.globalAlpha=1}let $o=[],Ei=!1,js=0;function s8(){const e=Object.keys(Qe.rooms),n=e[Math.floor(Math.random()*e.length)],a=Qe.rooms[n];return{x:a.fx+a.fw/2,y:a.fy+a.fh/2,dir:"down",walkFrame:0,walkTimer:0,path:[],room:n,state:"walking",stateTimer:0,tongueTimer:0,idleTime:0}}function o8(e){if(e.stateTimer--,Ei){js++,e.dir="down",e.walkFrame=0,e.tongueTimer++,e.idleTime=0;return}else js=0;if(e.state==="idle"){if(e.tongueTimer++,e.idleTime++,e.stateTimer<=0){e.state="walking",e.tongueTimer=0;const n=Object.keys(Qe.rooms);if(Math.random()<.35&&n.length>1){const a=n.filter(d=>d!==e.room),i=a[Math.floor(Math.random()*a.length)],o=tp(e,i),u=Qe.waypoints[i];if(u&&u.length>0){const d=u[Math.floor(Math.random()*u.length)],f=o[o.length-1]??{x:e.x,y:e.y},m=Ni(f.x,f.y,d.x,d.y,i);e.path=[...o,...m]}else e.path=o}else{const a=Qe.waypoints[e.room];if(a&&a.length>0){const i=a[Math.floor(Math.random()*a.length)];e.path=Ni(e.x,e.y,i.x,i.y,e.room)}}e.walkTimer=0}}else if(e.state==="walking"){if(e.idleTime=0,e.path.length===0){e.state="idle",e.dir="down",e.stateTimer=120+Math.floor(Math.random()*240);return}const n=e.path[0],a=n.x-e.x,i=n.y-e.y,o=Math.sqrt(a*a+i*i);if(o<1.5){e.x=n.x,e.y=n.y,e.path.shift();for(const[u,d]of Object.entries(Qe.rooms))if(e.x>=d.fx&&e.x<=d.fx+d.fw&&e.y>=d.fy&&e.y<=d.fy+d.fh){e.room=u;break}}else e.x+=a/o*.15,e.y+=i/o*.15,Math.abs(a)>Math.abs(i)?e.dir=a>0?"right":"left":e.dir=i>0?"down":"up",e.walkTimer++,e.walkFrame=Math.floor(e.walkTimer/15)%2}}function c8(e){const n=Math.round(e.x),a=Math.round(e.y);if(Ei&&js>90){const d=Math.floor(js/12)%2===0?mA:pA;Xl(Xe,yA,n,a),Xl(Xe,d,n,a);return}const i=e.state==="walking"?e.walkFrame:0,o=fA[e.dir][i],u=e.dir==="left"||e.dir==="right";Xl(Xe,u?gA:xA,n,a),Xl(Xe,o,n,a),e.state==="idle"&&e.dir==="down"&&e.tongueTimer%80<50&&Xl(Xe,hA,n,a)}function u8(e){const n={};let a=0;for(const i of e){const o=wn[i];o&&(n[i]={state:"sitting",homeX:o.dx+8,homeY:o.dy+34,homeRoom:o.room,x:o.dx+8,y:o.dy+34,path:[],room:o.room,dir:"down",walkFrame:0,walkTimer:0,bobY:0,bobOff:a*17,stateTimer:1200+Math.floor(Math.random()*1800),sittingTime:0,lookDir:"right",isStretching:!1,stretchTimer:0},a++)}return n}function Ni(e,n,a,i,o){const u=Qe.corridorY[o]??n,d=[];return n<u-4&&d.push({x:e,y:u}),Math.abs(e-a)>4&&d.push({x:a,y:u}),d.push({x:a,y:i}),d}function Hh(e,n,a,i){const o=Qe.adjacency[a];if(!o)return[];const u=o.find(x=>x.room===i);if(!u)return[];const d=Qe.doors[u.door];if(!d)return[];const f=[],m=Qe.corridorY[a]??n,h=Qe.corridorY[i]??n;if(Math.abs(n-m)>4&&f.push({x:e,y:m}),d.type==="v"){const x=u.side==="A"?d.xA:d.xB,g=u.side==="A"?d.xB:d.xA;f.push({x,y:m}),f.push({x,y:d.doorY}),f.push({x:g,y:d.doorY}),f.push({x:g,y:h})}else{const x=u.side==="A"?d.yA:d.yB,g=u.side==="A"?d.yB:d.yA;f.push({x:d.doorX,y:m}),f.push({x:d.doorX,y:x}),f.push({x:d.doorX,y:g}),f.push({x:d.doorX,y:h})}return f}function tp(e,n){const a=Qe.adjacency[e.room];if(!a)return[];if(!a.find(o=>o.room===n)){for(const o of a){const u=Qe.adjacency[o.room];if(u!=null&&u.find(d=>d.room===n)){const d=Hh(e.x,e.y,e.room,o.room),f=d[d.length-1],m=Hh((f==null?void 0:f.x)??e.x,(f==null?void 0:f.y)??e.y,o.room,n);return[...d,...m]}}return[]}return Hh(e.x,e.y,e.room,n)}function d8(e){if(e.room!==e.homeRoom){const n=tp({...e},e.homeRoom),a=n[n.length-1],i=Ni((a==null?void 0:a.x)??e.x,(a==null?void 0:a.y)??e.y,e.homeX,e.homeY,e.homeRoom);return[...n,...i]}return Ni(e.x,e.y,e.homeX,e.homeY,e.room)}function f8(e,n){if(Lh--,Lh<=0){const a=Object.entries(e).filter(([,i])=>i.state==="sitting"&&!i.isStretching);if(a.length>0){const[,i]=a[Math.floor(Math.random()*a.length)];i.isStretching=!0,i.stretchTimer=120}Lh=900}for(const[a,i]of Object.entries(e))if(i.stateTimer--,i.isStretching&&i.stretchTimer>0&&(i.stretchTimer--,i.stretchTimer<=0&&(i.isStretching=!1)),i.state==="sitting"){if(i.sittingTime++,er===a){i.sittingTime=0,i.bobY=-3;const u=wn[a];if(u){const d=u.dx+13;i.lookDir=zv<d?"left":"right"}}else i.bobY=(n+i.bobOff)%60<30?1:0,i.lookDir="right";if(i.stateTimer<=0){i.state="walking",i.x=i.homeX,i.y=i.homeY,i.room=i.homeRoom;const u=Object.keys(Qe.rooms);if(Math.random()<.15&&u.length>1){const d=u.filter(x=>x!==i.room),f=d[Math.floor(Math.random()*d.length)],m=tp(i,f),h=Qe.waypoints[f];if(h&&h.length>0){const x=h[Math.floor(Math.random()*h.length)],g=m[m.length-1]??{x:i.x,y:i.y},v=Ni(g.x,g.y,x.x,x.y,f);i.path=[...m,...v]}else i.path=m;i.walkTimer=0}else{const d=Qe.waypoints[i.room];if(d&&d.length>0){const f=d[Math.floor(Math.random()*d.length)];i.path=Ni(i.x,i.y,f.x,f.y,i.room)}i.walkTimer=0}}}else if(i.state==="walking"||i.state==="returning"){if(i.sittingTime=0,er===a){i.dir="down",i.walkFrame=0;continue}if(i.path.length===0){i.state==="returning"?(i.state="sitting",i.room=i.homeRoom,i.stateTimer=1200+Math.floor(Math.random()*1800)):(i.state="idle",i.dir="down",i.stateTimer=180+Math.floor(Math.random()*360));continue}const u=i.path[0],d=u.x-i.x,f=u.y-i.y,m=Math.sqrt(d*d+f*f);if(m<1.5){i.x=u.x,i.y=u.y,i.path.shift();for(const[h,x]of Object.entries(Qe.rooms))if(i.x>=x.fx&&i.x<=x.fx+x.fw&&i.y>=x.fy&&i.y<=x.fy+x.fh){i.room=h;break}}else i.x+=d/m*.2,i.y+=f/m*.2,Math.abs(d)>Math.abs(f)?i.dir=d>0?"right":"left":i.dir=f>0?"down":"up",i.walkTimer++,i.walkFrame=Math.floor(i.walkTimer/12)%4}else if(i.state==="idle"){if(er===a){i.dir="down";continue}if(i.stateTimer<=0)if(Math.random()<.15){i.state="walking";const o=Qe.waypoints[i.room];if(o&&o.length>0){const u=o[Math.floor(Math.random()*o.length)];i.path=Ni(i.x,i.y,u.x,u.y,i.room)}i.walkTimer=0}else i.state="returning",i.path=d8(i),i.walkTimer=0}}function h8(e,n,a,i){const{canvasW:o,canvasH:u,rooms:d}=Qe;Xe.clearRect(0,0,o,u),O(0,0,o,u,"#2A1E14");const f={wood:Ih,dark:my,carpet:e8,tile:t8};for(const b of Object.values(d))(f[b.floorType]??Ih)(b);const m=Object.keys(d);if(m.length>=4){const b=d.exec,j=d.meet,{doors:k}=Qe;if(b&&j&&k.exec_meet&&k.work_comm){const E=(k.exec_meet.doorX??0)-14,C=(k.work_comm.doorX??0)-28/2,_=b.fy+b.fh,R=j.fy;Ih({fx:E,fy:_,fw:28,fh:R-_}),my({fx:C,fy:_,fw:28,fh:R-_})}}const h={};if(m.length>=4){const{doors:b}=Qe,j=28,k=b.exec_meet,N=b.work_comm;k!=null&&k.doorX&&(h.meet={x:k.doorX-j/2,w:j}),N!=null&&N.doorX&&(h.comm={x:N.doorX-j/2,w:j})}for(const b of Object.values(d))ZA(b,h[b.id]),JA(b);n8(),WA(Qe);const x=[],g=new Set(Object.values(wn).map(b=>b.room));VA(Qe,x,g);for(const[b,j]of Object.entries(wn)){const k=e[b];if(!k)continue;const N=k.state==="sitting",E=n(b),C=a[b]==="working",_=k.isStretching&&k.stretchTimer>0?Math.sin(k.stretchTimer*.15)*1:0;x.push({y:j.dy+14,draw:()=>{const R=N?k.bobY+_:0;if(l8(j.dx,j.dy,E,R,!N,k.lookDir),N&&C){const L=Gu[b]??"#388bfd";O(j.dx+7,j.dy+14-4,12,5,L,.15),st(j.dx+12,j.dy+14+1,"#4CAF50",.8)}}})}for(const[b,j]of Object.entries(e))if(j.state!=="sitting"){const k=n(b);x.push({y:j.y+14,draw:()=>i8(Math.round(j.x),Math.round(j.y),k,j.dir,j.walkFrame)})}i&&x.push({y:i.y+10,draw:()=>c8(i)}),x.sort((b,j)=>b.y-j.y);for(const b of x)b.draw();for(const b of ka){const j=ji===b.id,k=Rv(b);if(Xe.save(),Xe.globalAlpha=j?.9:.5,Xe.fillStyle=b.color,Xe.fillRect(k.cx-1,k.botY-2,3,3),j){const N=Mv(b);Xe.globalAlpha=.3,Xe.strokeStyle=b.color,Xe.lineWidth=1,Xe.strokeRect(N.x-1,N.y-1,N.w+2,N.h+2)}Xe.restore()}if(rl){const b=new Set(Object.values(wn).map(j=>j.room));if(sa&&sa!==Rr)if(sa.startsWith("desk:")){const j=sa.slice(5),k=wn[j];k&&uy(Xe,k.dx,k.dy,"#FBBF24")}else cy(Xe,Qe,sa,"#FBBF24",b);if(Rr)if(Rr.startsWith("desk:")){const j=Rr.slice(5),k=wn[j];k&&uy(Xe,k.dx,k.dy,"#3B82F6")}else cy(Xe,Qe,Rr,"#3B82F6",b)}if(er){const b=wn[er],j=e[er];if(b&&j){Xe.save(),Xe.globalAlpha=.25,Xe.fillStyle=Gu[er]??"#fff",j.state==="sitting"?Xe.fillRect(b.dx-1,b.dy+6,28,30):Xe.fillRect(Math.round(j.x)-1,Math.round(j.y)-1,14,24),Xe.globalAlpha=.95,Xe.fillStyle="#FBBF24",Xe.font="bold 8px monospace",Xe.textAlign="center";const k=j.state==="sitting"?b.dx+13:Math.round(j.x)+6,N=j.state==="sitting"?b.dy-1:Math.round(j.y)-5;Xe.fillText("!",k,N),Xe.restore()}}const v=3600;for(const[,b]of Object.entries(e))if(b.state==="sitting"&&b.sittingTime>v&&!b.isStretching){const j=Object.values(wn).find(R=>R.dx+8===b.homeX&&R.dy+34===b.homeY);if(!j)continue;const k=j.dx+13,N=j.dy,E=Math.floor(b.sittingTime/40)%3;Xe.save(),Xe.font="5px monospace",Xe.textAlign="center";const C=[.7,.5,.3],_=[{x:3,y:-2-E},{x:6,y:-5-(E+1)%3},{x:4,y:-8-(E+2)%3}];for(let R=0;R<3;R++)Xe.globalAlpha=C[R],Xe.fillStyle="#93C5FD",Xe.font=`${4+R}px monospace`,Xe.fillText("z",k+_[R].x,N+_[R].y);Xe.restore()}$o=$o.filter(b=>b.life>0);for(const b of $o)b.x+=b.vx,b.y+=b.vy,b.life--,Xe.save(),Xe.globalAlpha=Math.min(1,b.life/(b.maxLife*.3)),Xe.fillStyle=b.color??"#FF6B8A",Xe.font="8px serif",Xe.fillText(b.char,Math.round(b.x),Math.round(b.y)),Xe.restore();if(Ei&&i&&js<=90){const b=Math.round(i.x),j=Math.round(i.y);Xe.save(),Xe.globalAlpha=.9,Xe.fillStyle="#FBBF24",Xe.font="bold 5px monospace",Xe.textAlign="center",Xe.fillText("!",b+4,j-2),Xe.restore()}if(i&&!Ei&&i.state==="idle"&&i.idleTime>600){const b=Math.round(i.x),j=Math.round(i.y),k=Math.floor(i.idleTime/40)%3;Xe.save();const N=[{x:3,y:-2-k},{x:5,y:-5-(k+1)%3},{x:4,y:-8-(k+2)%3}];for(let E=0;E<3;E++)Xe.globalAlpha=[.7,.5,.3][E],Xe.fillStyle="#93C5FD",Xe.font=`${3+E}px monospace`,Xe.textAlign="center",Xe.fillText("z",b+N[E].x,j+N[E].y);Xe.restore()}if(Ei&&i&&js<=90){const b=Math.round(i.x),j=Math.round(i.y),k=Math.floor(Date.now()/150)%2===0?-1:1;i.dir==="down"&&(Xe.fillStyle="#FAFAF7",Xe.fillRect(b+4+k,j-1,2,2))}}function m8(e,n){for(let a=0;a<4;a++)$o.push({x:e+(Math.random()-.5)*8,y:n,vx:(Math.random()-.5)*.3,vy:-.3-Math.random()*.2,life:60+Math.floor(Math.random()*30),maxLife:80,char:a%2===0?"♥":"♡",color:"#FF6B8A"})}function p8(e,n){for(let a=0;a<3;a++)$o.push({x:e+(Math.random()-.5)*8,y:n,vx:(Math.random()-.5)*.3,vy:-.3-Math.random()*.2,life:60+Math.floor(Math.random()*30),maxLife:80,char:"💧",color:"#64B5F6"})}function x8({roles:e,projects:n,roleStatuses:a,activeExecs:i,onRoleClick:o,onProjectClick:u,onBulletinClick:d,onDecisionsClick:f,onKnowledgeClick:m,onSettingsClick:h,onThemeClick:x,onStatsClick:g,getRoleSpeech:v,getAppearance:b,onHireClick:j,onMascotClick:k,roleLevels:N,coinBalance:E=0,onCoinsSpent:C,onFurniturePlaced:_,purchasedPreset:R,language:L="en"}){const F=w.useRef(null),I=w.useRef(null),H=w.useRef(null),X=w.useRef({}),A=w.useRef(null),$=w.useRef(0),q=w.useRef(KA),[W,ie]=w.useState(!1),[P,Y]=w.useState(null),[oe,de]=w.useState(null),G=w.useRef({}),D=w.useRef({}),B=w.useRef([]),U=w.useRef([]);w.useEffect(()=>{rl=W},[W]),w.useEffect(()=>{Ul=P,wa=oe},[P,oe]);const[T,se]=w.useState(!1);w.useEffect(()=>{ye.getPreferences().then(me=>{const Se=me.furnitureOverrides;Se&&Object.keys(Se).length>0&&(G.current=Se);const Ne=me.deskOverrides;Ne&&Object.keys(Ne).length>0&&(D.current=Ne);const K=me.removedFurniture;K&&K.length>0&&(B.current=K);const ue=me.addedFurniture;ue&&ue.length>0&&(U.current=ue),se(!0)}).catch(()=>{se(!0)})},[]);const ge=w.useRef({roleStatuses:a,activeExecs:i,getRoleSpeech:v,getAppearance:b});ge.current={roleStatuses:a,activeExecs:i,getRoleSpeech:v,getAppearance:b};const pe=w.useRef({}),Re=w.useMemo(()=>e.map(me=>me.id),[e]),Ie=w.useRef(Qe);w.useEffect(()=>{if(!T)return;const me=Re.length,Se=Nv(me,Ie.current.preset,R),Ne=Ie.current.preset!==Se;let K=Av(me,Se);B.current.length>0&&(K=oy(K,B.current)),U.current.length>0&&(K=CA(K,U.current)),Object.keys(G.current).length>0&&(K=jA(K,G.current)),Qe=K,Ie.current=K,wn=QA(Re),Object.keys(D.current).length>0&&SA(wn,D.current),ka=ki(K),X.current=u8(Re),A.current=s8();const ue=F.current;ue&&(ue.width=K.canvasW,ue.height=K.canvasH,Ne&&(ue.style.opacity="0",ue.style.transition="opacity 0.3s",setTimeout(()=>{ue.style.opacity="1"},50))),ot()},[Re,R,T]);const He=w.useCallback(me=>{var Se,Ne;return((Ne=(Se=ge.current).getAppearance)==null?void 0:Ne.call(Se,me))??Pm(me)},[]),ot=w.useCallback(()=>{const me=I.current,Se=F.current;if(!me||!Se)return;const Ne=me.parentElement;if(!Ne)return;const K=Ne.clientWidth,ue=Ne.clientHeight;if(K===0||ue===0)return;const{canvasW:ne,canvasH:ve}=Qe;let we=Math.min(K/ne,ue/ve);we=Math.round(we*2)/2,we=Math.max(2,Math.min(we,5)),q.current=we,Se.style.width=ne*we+"px",Se.style.height=ve*we+"px",me.style.width=ne*we+"px",me.style.height=ve*we+"px"},[]);w.useEffect(()=>{var ve;const me=F.current;if(!me)return;const Se=me.getContext("2d");if(!Se)return;Xe=Se,EA(Se),ot();const Ne=new ResizeObserver(()=>ot()),K=(ve=I.current)==null?void 0:ve.parentElement;K&&Ne.observe(K);let ue;const ne=()=>{$.current++,f8(X.current,$.current),A.current&&o8(A.current),h8(X.current,He,ge.current.roleStatuses,A.current),Je(),ue=requestAnimationFrame(ne)};return ue=requestAnimationFrame(ne),()=>{cancelAnimationFrame(ue),Ne.disconnect()}},[He,ot]),w.useEffect(()=>{var ne;const me=H.current;if(!me)return;me.innerHTML="";const Se={};for(const ve of e)Se[ve.id]=ve.name;for(const ve of Re){const we=Gu[ve]??"#8b949e",ze=Se[ve],_e=ze&&ze.toLowerCase()!==ve.toLowerCase()?`${ve.toUpperCase()} · ${ze}`:ve.toUpperCase(),Be=document.createElement("div");Be.className="td-nametag",Be.dataset.role=ve;const qe=document.createElement("span");qe.className="td-dot",qe.style.background=we,Be.appendChild(qe),Be.appendChild(document.createTextNode(_e));const at=((ne=N==null?void 0:N[ve])==null?void 0:ne.level)??1;if(at>1){const bt=document.createElement("span");bt.className="td-lvl",bt.textContent=`Lv.${at}`,Be.appendChild(bt)}me.appendChild(Be);const Ke=document.createElement("div");Ke.className="td-bubble",Ke.dataset.role=ve,Ke.dataset.type="bubble",me.appendChild(Ke)}const Ne={meeting:()=>{const ve=n[0];ve?u(ve.id):d()},bulletin:d,decisions:f,knowledge:m,settings:h,theme:x,stats:g};for(const ve of ka){const we=document.createElement("div");we.className="td-facility-label",we.dataset.facility=ve.id,ve.id==="meeting"&&(we.dataset.questTarget="meeting-room"),ve.id==="knowledge"&&(we.dataset.questTarget="knowledge-hub"),ve.id==="bulletin"&&(we.dataset.questTarget="bulletin-board"),ve.id==="stats"&&(we.dataset.questTarget="stats-btn"),ve.id==="settings"&&(we.dataset.questTarget="settings-btn"),ve.id==="theme"&&(we.dataset.questTarget="theme-btn"),we.textContent=`${ve.icon} ${ve.label}`,we.style.borderColor=`${ve.color}44`;const ze=Ne[ve.id];ze&&we.addEventListener("click",ze),we.addEventListener("mouseenter",()=>{ji=ve.id}),we.addEventListener("mouseleave",()=>{ji=null}),me.appendChild(we)}const K=document.createElement("div");K.className="td-nametag td-nametag-mascot",K.dataset.role="mascot";const ue=document.createElement("span");ue.className="td-dot",ue.style.background="#ffd700",K.appendChild(ue),K.appendChild(document.createTextNode("Pupu")),K.addEventListener("click",()=>k==null?void 0:k()),me.appendChild(K)},[Re,e,n,u,d,f,m,h,x,g,k,N]);const Je=w.useCallback(()=>{var ze;const me=H.current;if(!me)return;const Se=q.current,Ne=X.current,{getRoleSpeech:K,roleStatuses:ue,activeExecs:ne}=ge.current;for(const _e of Object.keys(Ne)){const Be=Ne[_e],qe=wn[_e];if(!qe)continue;let at,Ke,bt;Be.state==="sitting"?(at=qe.dx+13,bt=qe.dy+2,Ke=qe.dy+37):(at=Math.round(Be.x)+6,bt=Math.round(Be.y)-2,Ke=Math.round(Be.y)+18);const Me=at/Qe.canvasW*100,Ue=me.querySelector(`.td-nametag[data-role="${_e}"]`);if(Ue){Ue.style.left=Me+"%",Ue.style.top=Ke*Se+2+"px";const Bt=Ue.querySelector(".td-dot");if(Bt){const Ot=ue[_e]==="working";Bt.style.background=Ot?"#FBBF24":Gu[_e]??"#8b949e",Ot?Bt.style.animation="td-pulse 1s ease-in-out infinite":Bt.style.animation=""}}const _t=me.querySelector(`.td-bubble[data-role="${_e}"]`);if(_t){const Bt=Date.now(),Ot=ue[_e]==="working",un=(ze=ne.find(Kt=>Kt.roleId===_e))==null?void 0:ze.task,kn=K(_e);let J="";const Oe=pe.current[_e];if(Oe){if(Oe.speechDismissTime&&Bt>=Oe.speechDismissTime&&(Oe.currentSpeech=null,Oe.speechDismissTime=null),Oe.hoverStartTime&&!Oe.currentSpeech){const Kt=Bt-Oe.hoverStartTime,ke=!Oe.lastSpeechTime||Bt-Oe.lastSpeechTime>=5e3;if(Kt>=2e3&&ke){const kt=PA(_e,L),jn=kt[Math.floor(Math.random()*kt.length)];Oe.currentSpeech=jn,Oe.lastSpeechTime=Bt,Oe.speechDismissTime=Bt+3e3}}J=Oe.currentSpeech||""}const rt=Ot&&un?un.slice(0,60):J?J.slice(0,60):kn?kn.slice(0,60):"";rt&&Be.state==="sitting"?(_t.style.display="",_t.style.left=Me+"%",_t.style.top=(bt-10)*Se+"px",_t.textContent=rt):_t.style.display="none"}}const ve=me.querySelector(".td-nametag-mascot"),we=A.current;if(ve&&we){const _e=we.dir==="left"||we.dir==="right",Be=Math.round(we.x)+(_e?6:4),qe=Math.round(we.y)+(_e?7:10);ve.style.left=Be/Qe.canvasW*100+"%",ve.style.top=qe*Se+2+"px"}for(const _e of ka){const Be=me.querySelector(`.td-facility-label[data-facility="${_e.id}"]`);if(Be){const qe=Rv(_e);Be.style.left=qe.cx/Qe.canvasW*100+"%",Be.style.top=qe.botY*Se-4+"px",Be.classList.toggle("td-facility-label--hover",ji===_e.id)}}},[]),tt=w.useCallback(me=>{const Se=F.current;if(!Se)return null;const Ne=Se.getBoundingClientRect(),K=q.current,ue=(me.clientX-Ne.left)/K,ne=(me.clientY-Ne.top)/K,ve=X.current;for(const[ze,_e]of Object.entries(wn)){if(!ve[ze])continue;const Be=ve[ze];if(Be.state==="sitting"){if(ue>=_e.dx&&ue<=_e.dx+26&&ne>=_e.dy&&ne<=_e.dy+40)return{type:"role",id:ze}}else if(ue>=Be.x-2&&ue<=Be.x+14&&ne>=Be.y-2&&ne<=Be.y+20)return{type:"role",id:ze}}const we=A.current;if(we){const ze=we.dir==="left"||we.dir==="right",_e=ze?13:9,Be=ze?7:10;if(ue>=we.x&&ue<=we.x+_e&&ne>=we.y&&ne<=we.y+Be)return{type:"mascot",id:"mascot"}}for(const ze of ka){const _e=Mv(ze);if(ue>=_e.x&&ue<=_e.x+_e.w&&ne>=_e.y&&ne<=_e.y+_e.h)return{type:"facility",id:ze.id}}return null},[]),Ee=w.useCallback(me=>{const Se=F.current;if(!Se)return{mx:0,my:0};const Ne=Se.getBoundingClientRect(),K=q.current;return{mx:(me.clientX-Ne.left)/K,my:(me.clientY-Ne.top)/K}},[]),Ae=w.useCallback(me=>{ye.updatePreferences(me).catch(()=>{})},[]),yt=w.useCallback(me=>{const Se=U.current.some(K=>K.id===me),Ne={};if(Se){const K=U.current.filter(ue=>ue.id!==me);U.current=K,Ne.addedFurniture=K}else{const K=[...B.current,me];B.current=K,Ne.removedFurniture=K}Qe=oy(Qe,[me]),ka=ki(Qe),Rr=null,sa=null,Ae(Ne)},[Ae]),dt=w.useCallback((me,Se)=>{if(!Ul||!wa)return;const Ne=fy.find(Be=>Be.type===Ul),K=(Ne==null?void 0:Ne.price)??0;if(K>0&&E<K)return;let ue=null;for(const[Be,qe]of Object.entries(Qe.rooms)){const at=wa==="wall"?qe.wx:qe.fx,Ke=wa==="wall"?qe.wy:qe.fy,bt=wa==="wall"?qe.ww:qe.fw,Me=wa==="wall"?qe.wh:qe.fh;if(me>=at&&me<=at+bt&&Se>=Ke&&Se<=Ke+Me){ue=Be;break}}if(!ue)return;const ne=Qe.rooms[ue],ve=wa==="wall"?ne.wx:ne.fx,we=wa==="wall"?ne.wy:ne.fy,ze={id:`user-${Ul}-${Date.now()}`,type:Ul,room:ue,zone:wa,offsetX:Math.round(me-ve),offsetY:Math.round(Se-we)},_e=[...U.current,ze];if(U.current=_e,wa==="wall"?Qe.wallDecorations.push(ze):Qe.furniture.push(ze),ka=ki(Qe),Ae({addedFurniture:_e}),_==null||_(Ul,K),K>0){const Be=ze.type;Ny(async()=>{const{api:qe}=await Promise.resolve().then(()=>Aw);return{api:qe}},void 0).then(({api:qe})=>{qe.spendCoins(K,`furniture: ${Be}`,ze.id).then(at=>C==null?void 0:C(at.balance)).catch(()=>{})})}Y(null),de(null)},[Ae,E,C,_]),xt=w.useCallback(me=>{const Se=F.current;if(rl&&nr){const{mx:ve,my:we}=Ee(me),_e=[...Qe.furniture,...Qe.wallDecorations].find(at=>at.id===nr.defId);if(!_e)return;const Be=ve-nr.startMx,qe=we-nr.startMy;_e.offsetX=Math.round(nr.origOffX+Be),_e.offsetY=Math.round(nr.origOffY+qe),ka=ki(Qe),Se&&(Se.style.cursor="grabbing");return}if(rl&&$n){const{mx:ve,my:we}=Ee(me),ze=wn[$n.roleId];if(!ze)return;ze.dx=Math.round($n.origDx+(ve-$n.startMx)),ze.dy=Math.round($n.origDy+(we-$n.startMy));const _e=X.current[$n.roleId];_e&&(_e.homeX=ze.dx+8,_e.homeY=ze.dy+34),Se&&(Se.style.cursor="grabbing");return}if(rl){const{mx:ve,my:we}=Ee(me);if(Ul){Se&&(Se.style.cursor="crosshair");return}const ze=new Set(Object.values(wn).map(Be=>Be.room)),_e=$h(Qe,ve,we,ze);if(_e)sa=_e;else{const Be=dy(wn,ve,we);sa=Be?`desk:${Be}`:null}er=null,ji=null,Se&&(Se.style.cursor=sa?"grab":"default");return}const Ne=tt(me),K=er;er=(Ne==null?void 0:Ne.type)==="role"?Ne.id:null,ji=(Ne==null?void 0:Ne.type)==="facility"?Ne.id:null,Ei=(Ne==null?void 0:Ne.type)==="mascot",sa=null,Se&&(Se.style.cursor=Ne?"pointer":"default");const{mx:ue}=Ee(me);zv=ue;const ne=Date.now();if(er&&er!==K){pe.current[er]||(pe.current[er]={hoverStartTime:null,lastSpeechTime:null,currentSpeech:null,speechDismissTime:null});const ve=pe.current[er];ve.hoverStartTime=ne}else if(!er&&K){const ve=pe.current[K];ve&&(ve.hoverStartTime=null)}},[tt,Ee]),jt=w.useCallback(me=>{if(!rl)return;const{mx:Se,my:Ne}=Ee(me);if(Ul){dt(Se,Ne),me.preventDefault();return}const K=new Set(Object.values(wn).map(ve=>ve.room)),ue=$h(Qe,Se,Ne,K);if(ue){const we=[...Qe.furniture,...Qe.wallDecorations].find(ze=>ze.id===ue);we&&(Rr=ue,nr={defId:ue,startMx:Se,startMy:Ne,origOffX:we.offsetX,origOffY:we.offsetY},me.preventDefault());return}const ne=dy(wn,Se,Ne);if(ne){const ve=wn[ne];Rr=`desk:${ne}`,$n={roleId:ne,startMx:Se,startMy:Ne,origDx:ve.dx,origDy:ve.dy},me.preventDefault();return}Rr=null},[Ee,dt]),Wt=w.useCallback(me=>{if(nr){const Ne=[...Qe.furniture,...Qe.wallDecorations].find(K=>K.id===nr.defId);if(Ne){const K={...G.current,[Ne.id]:{offsetX:Ne.offsetX,offsetY:Ne.offsetY}};G.current=K,Ae({furnitureOverrides:K}),ka=ki(Qe)}nr=null,F.current&&(F.current.style.cursor="grab");return}if($n){const Se=wn[$n.roleId];if(Se){const Ne={...D.current,[$n.roleId]:{dx:Se.dx,dy:Se.dy}};D.current=Ne,Ae({deskOverrides:Ne})}$n=null,F.current&&(F.current.style.cursor="grab")}},[Ae]),Tt=w.useCallback(me=>{if(!rl)return;me.preventDefault();const{mx:Se,my:Ne}=Ee(me),K=new Set(Object.values(wn).map(ne=>ne.room)),ue=$h(Qe,Se,Ne,K);ue&&yt(ue)},[Ee,yt]);w.useEffect(()=>{const me=Se=>{!rl||!Rr||(Se.key==="Delete"||Se.key==="Backspace")&&(Rr.startsWith("desk:")||yt(Rr))};return window.addEventListener("keydown",me),()=>window.removeEventListener("keydown",me)},[yt]);const Ct=w.useCallback(()=>{if(nr){const Se=[...Qe.furniture,...Qe.wallDecorations].find(Ne=>Ne.id===nr.defId);Se&&(Se.offsetX=nr.origOffX,Se.offsetY=nr.origOffY,ka=ki(Qe)),nr=null}if($n){const me=wn[$n.roleId];me&&(me.dx=$n.origDx,me.dy=$n.origDy);const Se=X.current[$n.roleId];Se&&(Se.homeX=me.dx+8,Se.homeY=me.dy+34),$n=null}er=null,ji=null,Ei=!1,sa=null,F.current&&(F.current.style.cursor="default")},[]),Bn=w.useCallback(me=>{if(rl)return;const Se=tt(me);if(Se){if(Se.type==="role"){const Ne=X.current[Se.id],K=wn[Se.id];if(Ne&&K){const ue=Ne.state==="sitting"?K.dx+13:Math.round(Ne.x)+6,ne=Ne.state==="sitting"?K.dy+2:Math.round(Ne.y)-2;p8(ue,ne)}o(Se.id);return}if(Se.type==="mascot"){const Ne=A.current;Ne&&m8(Math.round(Ne.x)+4,Math.round(Ne.y)-2),k==null||k();return}switch(Se.id){case"meeting":{const Ne=n[0];Ne?u(Ne.id):d();break}case"bulletin":d();break;case"decisions":f();break;case"knowledge":m();break;case"settings":h==null||h();break;case"theme":x==null||x();break;case"stats":g==null||g();break}}},[tt,o,u,d,f,m,h,x,g]);return l.jsxs("div",{className:`td-scene${W?" td-scene--editing":""}`,children:[l.jsxs("div",{ref:I,className:"td-wrap",children:[l.jsx("canvas",{ref:F,width:Qe.canvasW,height:Qe.canvasH,className:"td-canvas",onClick:Bn,onMouseDown:jt,onMouseUp:Wt,onMouseMove:xt,onMouseLeave:Ct,onContextMenu:Tt}),l.jsx("div",{ref:H,className:"td-overlay"})]}),W&&l.jsxs("div",{className:"td-edit-banner",children:[l.jsx("span",{className:"td-edit-banner__icon",children:"✎"})," EDIT MODE — Click DONE when finished"]}),l.jsxs("button",{className:`td-edit-btn${W?" td-edit-btn--active":""}`,"data-quest-target":"edit-btn",onClick:()=>{ie(me=>{const Se=!me;return Se||(Y(null),de(null)),Se}),Rr=null,nr=null,$n=null},title:W?"Exit Edit Mode":"Edit Furniture Layout",children:[l.jsx("span",{className:"td-edit-btn__icon",children:W?"✓":"✎"}),l.jsx("span",{className:"td-edit-btn__label",children:W?"DONE":"EDIT"})]}),W&&l.jsx("div",{className:"td-palette",children:fy.map(me=>{const Se=me.price===0||E>=me.price,Ne=me.price===0?"Free":`${me.price>=1e3?`${(me.price/1e3).toFixed(me.price%1e3===0?0:1)}K`:me.price}`;return l.jsxs("button",{className:`td-palette__item${P===me.type?" td-palette__item--active":""}${Se?"":" td-palette__item--locked"}`,onClick:()=>{Se&&(P===me.type?(Y(null),de(null)):(Y(me.type),de(me.zone)))},title:`${me.label} — ${Ne}`,style:Se?void 0:{opacity:.4,cursor:"not-allowed"},children:[l.jsx("span",{children:me.icon}),l.jsx("span",{className:"td-palette__price",style:{fontSize:"7px",color:me.price===0?"#4CAF50":Se?"#FFD54F":"#EF5350"},children:Ne})]},me.type)})}),j&&l.jsxs("button",{className:"td-hire-btn","data-quest-target":"hire-btn",onClick:j,title:"Hire New Role",children:[l.jsx("span",{className:"td-hire-btn__icon",children:"+"}),l.jsx("span",{className:"td-hire-btn__label",children:"HIRE"})]})]})}function g8({role:e,appearance:n,onSave:a,onReset:i,onClose:o,theme:u,onThemeChange:d,onUpdateName:f,initialTab:m,characterOnly:h,speechSettings:x,onSpeechSettingsChange:g,language:v,onLanguageChange:b,roleLevel:j,coinBalance:k,purchased:N,onPurchase:E}){var ie;const[C,_]=w.useState(m??"character"),[R,L]=w.useState({...n}),[F,I]=w.useState(e.name),[H,X]=w.useState(!1),A=w.useCallback(()=>L(xs(j)),[j]),$=w.useCallback(()=>{const P=Pm(e.id);L({...P}),i()},[e.id,i]),q=w.useCallback(async()=>{a(R);const P=F.trim();if(f&&P&&P!==e.name){X(!0);try{await f(e.id,P)}catch{}X(!1)}o()},[R,a,o,F,e.name,e.id,f]),W=l.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6},children:[l.jsxs("span",{children:[e.id.toUpperCase()," –"]}),f?l.jsx("input",{value:F,onChange:P=>I(P.target.value),disabled:H,className:"customize-name-input",style:{background:"rgba(255,255,255,0.08)",border:"1px solid rgba(255,255,255,0.15)",borderRadius:4,color:"inherit",font:"inherit",padding:"2px 6px",flex:1,minWidth:0}}):l.jsx("span",{children:e.name})]});return l.jsx("div",{className:"customize-overlay",onClick:o,children:l.jsxs("div",{className:"customize-modal",onClick:P=>P.stopPropagation(),children:[l.jsxs("div",{className:"customize-header",children:[l.jsxs("div",{className:"customize-tabs",children:[l.jsx("button",{className:`customize-tab ${C==="character"?"active":""}`,onClick:()=>_("character"),children:"CHARACTER"}),!h&&l.jsxs(l.Fragment,{children:[l.jsx("button",{className:`customize-tab ${C==="office"?"active":""}`,onClick:()=>_("office"),children:"OFFICE THEME"}),l.jsx("button",{className:`customize-tab ${C==="settings"?"active":""}`,onClick:()=>_("settings"),children:"SETTINGS"})]})]}),l.jsx("button",{className:"customize-close",onClick:o,children:"X"})]}),C==="character"?l.jsx("div",{className:"customize-body",children:l.jsx(gv,{roleId:e.id,appearance:R,onChange:L,onRandomize:A,onReset:$,label:W,roleLevel:j,coinBalance:k,purchased:N,onPurchase:E})}):C==="office"?l.jsx("div",{className:"customize-body",children:l.jsx("div",{className:"customize-themes",children:Object.entries(il).map(([P,Y])=>l.jsxs("button",{className:`customize-theme-card ${u===P?"active":""}`,onClick:()=>d(P),children:[l.jsxs("div",{className:"customize-theme-preview",style:{background:Y.vars["--floor-light"],borderColor:Y.vars["--pixel-border"]},children:[l.jsx("div",{style:{background:Y.vars["--hud-bg"],height:8,borderBottom:`2px solid ${Y.vars["--pixel-border"]}`}}),l.jsxs("div",{className:"flex-1 flex items-center justify-center gap-1 p-1",children:[l.jsx("div",{style:{width:10,height:14,background:Y.vars["--accent"],borderRadius:1}}),l.jsx("div",{style:{width:10,height:14,background:Y.vars["--active-green"],borderRadius:1}}),l.jsx("div",{style:{width:10,height:14,background:Y.vars["--idle-amber"],borderRadius:1}})]}),l.jsx("div",{style:{background:Y.vars["--hud-bg"],height:6,borderTop:`2px solid ${Y.vars["--pixel-border"]}`}})]}),l.jsxs("div",{className:"customize-theme-name",children:[Y.icon," ",Y.name]})]},P))})}):l.jsx("div",{className:"customize-body",children:l.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:20,padding:"8px 0"},children:[l.jsxs("div",{children:[l.jsx("div",{style:{fontSize:11,fontWeight:600,marginBottom:8,color:"var(--terminal-text)"},children:"AMBIENT SPEECH MODE"}),l.jsx("div",{style:{display:"flex",gap:6},children:["template","llm","auto"].map(P=>l.jsxs("button",{onClick:()=>g==null?void 0:g({mode:P}),style:{flex:1,padding:"8px 12px",fontSize:11,border:`2px solid ${(x==null?void 0:x.mode)===P?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(x==null?void 0:x.mode)===P?"rgba(255,255,255,0.08)":"transparent",color:(x==null?void 0:x.mode)===P?"var(--terminal-text)":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",textAlign:"center"},children:[l.jsx("div",{style:{fontWeight:600,marginBottom:2},children:P==="template"?"TEMPLATE":P==="llm"?"AI":"AUTO"}),l.jsx("div",{style:{fontSize:9,opacity:.7},children:P==="template"?"Static pool ($0)":P==="llm"?"LLM generated":"Detect engine"})]},P))}),l.jsx("div",{style:{fontSize:9,color:"var(--terminal-text-muted)",marginTop:4},children:"Auto: CLI Max = AI, BYOK = Template"})]}),l.jsxs("div",{children:[l.jsxs("div",{style:{fontSize:11,fontWeight:600,marginBottom:8,color:"var(--terminal-text)"},children:["SPEECH INTERVAL: ",(x==null?void 0:x.intervalSec)??18,"s"]}),l.jsx("input",{type:"range",min:5,max:120,step:5,value:(x==null?void 0:x.intervalSec)??18,onChange:P=>g==null?void 0:g({intervalSec:Number(P.target.value)}),style:{width:"100%",accentColor:"var(--accent)"}}),l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:9,color:"var(--terminal-text-muted)"},children:[l.jsx("span",{children:"5s (frequent)"}),l.jsx("span",{children:"120s (rare)"})]})]}),(x==null?void 0:x.mode)!=="template"&&l.jsxs("div",{children:[l.jsxs("div",{style:{fontSize:11,fontWeight:600,marginBottom:8,color:"var(--terminal-text)"},children:["DAILY LLM BUDGET: $",((ie=x==null?void 0:x.dailyBudgetUsd)==null?void 0:ie.toFixed(2))??"1.00"]}),l.jsx("input",{type:"range",min:0,max:5,step:.25,value:(x==null?void 0:x.dailyBudgetUsd)??1,onChange:P=>g==null?void 0:g({dailyBudgetUsd:Number(P.target.value)}),style:{width:"100%",accentColor:"var(--accent)"}}),l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:9,color:"var(--terminal-text-muted)"},children:[l.jsx("span",{children:"$0 (unlimited)"}),l.jsx("span",{children:"$5.00/day"})]})]}),l.jsxs("div",{children:[l.jsx("div",{style:{fontSize:11,fontWeight:600,marginBottom:8,color:"var(--terminal-text)"},children:"LANGUAGE"}),l.jsx("div",{style:{display:"flex",gap:6},children:[{key:"auto",label:"Auto"},{key:"en",label:"English"},{key:"ko",label:"한국어"},{key:"ja",label:"日本語"}].map(({key:P,label:Y})=>l.jsx("button",{onClick:()=>b==null?void 0:b(P),style:{flex:1,padding:"8px 12px",fontSize:11,border:`2px solid ${(v??"auto")===P?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(v??"auto")===P?"rgba(255,255,255,0.08)":"transparent",color:(v??"auto")===P?"var(--terminal-text)":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",textAlign:"center",fontWeight:600},children:Y},P))}),l.jsx("div",{style:{fontSize:9,color:"var(--terminal-text-muted)",marginTop:4},children:"Sets language for AI responses and speech bubbles"})]})]})}),C==="character"&&l.jsxs("div",{className:"customize-footer",children:[l.jsx("button",{className:"customize-btn customize-btn--cancel",onClick:o,children:"CANCEL"}),l.jsx("button",{className:"customize-btn customize-btn--save",onClick:q,children:"SAVE"})]})]})})}function xy(e){if(e.length===0)return"";const n={};for(const{file:f}of e){const m=f.split("/"),h=m[0]==="."?m[1]??"root":m[0];(n[h]??(n[h]=[])).push(f)}const a={roles:"roles",projects:"projects",operations:"operations",knowledge:"knowledge",architecture:"architecture",company:"company",".tycono":"config",".claude":"skills"},i=[];for(const[f,m]of Object.entries(n)){const h=a[f]??f;if(m.length===1){const x=m[0].split("/").pop()??m[0];i.push(`${h}/${x}`)}else i.push(`${h} (${m.length} files)`)}const o=e.some(f=>f.status==="A"),u=e.some(f=>f.status==="M");return`${o&&!u?"add":"update"}: ${i.join(", ")}`}function gy(e){const n=Date.now()-new Date(e).getTime(),a=Math.floor(n/6e4);if(a<1)return"just now";if(a<60)return`${a}m ago`;const i=Math.floor(a/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function y8({onInitGit:e,onDelegate:n,delegateRoleName:a}){const[i,o]=w.useState(!1),[u,d]=w.useState(null),f=async()=>{o(!0),d(null);try{await e(),d({ok:!0,message:"Git repository initialized!"})}catch(h){const x=h instanceof Error?h.message:"Failed";x.includes("not installed")||x.includes("noGitBinary")?d({ok:!1,message:"git is not installed on this system"}):d({ok:!1,message:x})}finally{o(!1)}},m=u&&!u.ok&&u.message.includes("not installed");return l.jsxs("div",{className:"p-3 space-y-2",style:{background:"rgba(211,47,47,0.05)",border:"1px solid var(--pixel-border)"},children:[l.jsx("div",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"var(--terminal-text-muted)"},children:"No Git Repository"}),!u&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"text-[10px]",style:{color:"var(--terminal-text-secondary)"},children:"This project has no git repository. Initialize one to start saving."}),l.jsxs("div",{className:"flex gap-2 flex-wrap",children:[l.jsx("button",{onClick:f,disabled:i,className:"text-[10px] font-bold px-3 py-1.5 cursor-pointer disabled:opacity-50",style:{background:"var(--accent)",color:"#fff",border:"none"},children:i?"INITIALIZING...":"GIT INIT"}),n&&l.jsxs("button",{onClick:n,className:"text-[10px] font-bold px-3 py-1.5 cursor-pointer",style:{background:"var(--terminal-bg)",color:"var(--idle-amber)",border:"1px solid var(--idle-amber)"},children:["🤖"," ",(a==null?void 0:a.toUpperCase())??"AI"," FIX"]})]})]}),u&&u.ok&&l.jsx("div",{className:"text-[10px] p-1.5",style:{background:"rgba(59,185,80,0.1)",border:"1px solid var(--active-green)",color:"var(--active-green)"},children:u.message}),m&&l.jsxs("div",{className:"space-y-2",children:[l.jsx("div",{className:"text-[10px]",style:{color:"#EF5350"},children:"git is not installed on this system."}),l.jsxs("div",{className:"text-[10px] space-y-1",style:{color:"var(--terminal-text-muted)"},children:[l.jsxs("div",{children:[l.jsx("b",{children:"macOS:"})," xcode-select --install"]}),l.jsxs("div",{children:[l.jsx("b",{children:"Ubuntu/Debian:"})," sudo apt install git"]}),l.jsxs("div",{children:[l.jsx("b",{children:"Windows:"})," ",l.jsx("a",{href:"https://git-scm.com/downloads",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)",textDecoration:"underline"},children:"git-scm.com/downloads"})]})]}),l.jsxs("div",{className:"flex gap-2 flex-wrap",children:[l.jsx("button",{onClick:()=>{d(null)},className:"text-[10px] font-bold px-3 py-1 cursor-pointer",style:{background:"var(--accent)",color:"#fff",border:"none"},children:"RETRY"}),n&&l.jsxs("button",{onClick:n,className:"text-[10px] font-bold px-3 py-1 cursor-pointer",style:{background:"var(--terminal-bg)",color:"var(--idle-amber)",border:"1px solid var(--idle-amber)"},children:["🤖"," ",(a==null?void 0:a.toUpperCase())??"AI"," FIX"]})]})]}),u&&!u.ok&&!m&&l.jsx("div",{className:"text-[10px] p-1.5",style:{background:"rgba(211,47,47,0.1)",border:"1px solid #D32F2F",color:"#EF5350"},children:u.message})]})}function b8({repo:e,onConnected:n,onDelegate:a,delegateRoleName:i}){const[o,u]=w.useState("idle"),[d,f]=w.useState(null),[m,h]=w.useState(""),[x,g]=w.useState("private"),[v,b]=w.useState(""),[j,k]=w.useState(null),[N,E]=w.useState(!1),C=async()=>{u("checking"),k(null);try{const F=await ye.getGithubStatus(e);f(F),F.hasRemote?n():F.ghInstalled&&F.authenticated?u("ready"):u("idle")}catch{u("idle")}},_=async()=>{if(m.trim()){E(!0),k(null);try{const F=await ye.githubCreateRepo(m.trim(),x,e);k(F),F.ok&&setTimeout(n,1500)}catch(F){k({ok:!1,message:F instanceof Error?F.message:"Failed"})}finally{E(!1)}}},R=async()=>{if(v.trim()){E(!0),k(null);try{const F=await ye.addRemote(v.trim(),e);k(F),F.ok&&setTimeout(n,1500)}catch(F){k({ok:!1,message:F instanceof Error?F.message:"Failed"})}finally{E(!1)}}},L=a?l.jsxs("button",{onClick:a,className:"text-[10px] font-bold px-3 py-1.5 cursor-pointer",style:{background:"var(--terminal-bg)",color:"var(--idle-amber)",border:"1px solid var(--idle-amber)"},title:`Ask ${i??"AI"} to set up GitHub remote`,children:["🤖"," ",(i==null?void 0:i.toUpperCase())??"AI"," FIX"]}):null;return l.jsxs("div",{className:"p-3 space-y-2",style:{background:"rgba(100,100,255,0.05)",border:"1px solid var(--pixel-border)"},children:[l.jsx("div",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"var(--terminal-text-muted)"},children:"No Remote — Local Only"}),o==="idle"&&!d&&l.jsxs("div",{className:"flex gap-2 flex-wrap",children:[l.jsx("button",{onClick:C,className:"text-[10px] font-bold px-3 py-1.5 cursor-pointer",style:{background:"var(--accent)",color:"#fff",border:"none"},children:"CONNECT GITHUB"}),l.jsx("button",{onClick:()=>u("manual"),className:"text-[10px] font-bold px-3 py-1.5 cursor-pointer",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},children:"ADD REMOTE URL"}),L]}),o==="checking"&&l.jsx("div",{className:"text-[10px]",style:{color:"var(--terminal-text-secondary)"},children:"Checking GitHub CLI..."}),o==="idle"&&d&&!d.ghInstalled&&l.jsxs("div",{className:"space-y-2",children:[l.jsx("div",{className:"text-[10px]",style:{color:"var(--idle-amber)"},children:"GitHub CLI (gh) not installed."}),l.jsxs("div",{className:"text-[10px] space-y-0.5",style:{color:"var(--terminal-text-muted)"},children:[l.jsxs("div",{children:["Install:"," ",l.jsx("a",{href:"https://cli.github.com",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)",textDecoration:"underline"},children:"cli.github.com"})]}),l.jsx("div",{style:{fontFamily:"var(--pixel-font)"},children:"brew install gh && gh auth login"})]}),l.jsxs("div",{className:"flex gap-2 flex-wrap",children:[l.jsx("button",{onClick:C,className:"text-[10px] font-bold px-3 py-1 cursor-pointer",style:{background:"var(--accent)",color:"#fff",border:"none"},children:"RETRY"}),l.jsx("button",{onClick:()=>u("manual"),className:"text-[10px] font-bold px-3 py-1 cursor-pointer",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},children:"ADD URL MANUALLY"}),L]})]}),o==="idle"&&d&&d.ghInstalled&&!d.authenticated&&l.jsxs("div",{className:"space-y-2",children:[l.jsx("div",{className:"text-[10px]",style:{color:"var(--idle-amber)"},children:"GitHub CLI installed but not logged in."}),l.jsx("div",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)",fontFamily:"var(--pixel-font)"},children:"Run in terminal: gh auth login"}),l.jsxs("div",{className:"flex gap-2 flex-wrap",children:[l.jsx("button",{onClick:C,className:"text-[10px] font-bold px-3 py-1 cursor-pointer",style:{background:"var(--accent)",color:"#fff",border:"none"},children:"RETRY"}),l.jsx("button",{onClick:()=>u("manual"),className:"text-[10px] font-bold px-3 py-1 cursor-pointer",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},children:"ADD REMOTE URL"}),L]})]}),o==="ready"&&d&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"text-[10px]",style:{color:"var(--active-green)"},children:["Logged in as ",d.username||"GitHub user"]}),l.jsxs("div",{className:"flex gap-2 items-center",children:[l.jsx("input",{type:"text",value:m,onChange:F=>h(F.target.value),placeholder:"repository-name",className:"flex-1 px-2 py-1.5 text-[11px] outline-none",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)",fontFamily:"var(--pixel-font)"}}),l.jsxs("select",{value:x,onChange:F=>g(F.target.value),className:"px-2 py-1.5 text-[10px] outline-none cursor-pointer",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)",fontFamily:"var(--pixel-font)"},children:[l.jsx("option",{value:"private",children:"Private"}),l.jsx("option",{value:"public",children:"Public"})]})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:_,disabled:N||!m.trim(),className:"text-[10px] font-bold px-3 py-1.5 cursor-pointer disabled:opacity-50",style:{background:"var(--accent)",color:"#fff",border:"none"},children:N?"CREATING...":"CREATE & PUSH"}),l.jsx("button",{onClick:()=>u("manual"),className:"text-[10px] px-2 py-1 cursor-pointer",style:{background:"transparent",color:"var(--terminal-text-muted)",border:"1px solid var(--terminal-border)"},children:"USE URL INSTEAD"})]})]}),o==="manual"&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:[l.jsx("a",{href:"https://github.com/new",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)",textDecoration:"underline"},children:"Create a new repo on GitHub"})," ","then paste the URL below:"]}),l.jsx("input",{type:"text",value:v,onChange:F=>b(F.target.value),placeholder:"https://github.com/username/repo-name.git",className:"w-full px-2 py-1.5 text-[11px] outline-none",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)",fontFamily:"var(--pixel-font)"}}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:R,disabled:N||!v.trim(),className:"text-[10px] font-bold px-3 py-1.5 cursor-pointer disabled:opacity-50",style:{background:"var(--accent)",color:"#fff",border:"none"},children:N?"ADDING...":"ADD REMOTE & PUSH"}),l.jsx("button",{onClick:()=>{u("idle"),f(null)},className:"text-[10px] px-2 py-1 cursor-pointer",style:{background:"transparent",color:"var(--terminal-text-muted)",border:"1px solid var(--terminal-border)"},children:"BACK"})]})]}),j&&l.jsx("div",{className:"text-[10px] p-1.5",style:{background:j.ok?"rgba(59,185,80,0.1)":"rgba(211,47,47,0.1)",border:`1px solid ${j.ok?"var(--active-green)":"#D32F2F"}`,color:j.ok?"var(--active-green)":"#EF5350"},children:j.message})]})}function v8({status:e,history:n,onClose:a,onSave:i,onLoadHistory:o,onRestore:u,saving:d,onDelegate:f,delegateRoleName:m,repo:h,onRepoChange:x,syncInfo:g,onPull:v,pulling:b,onRefresh:j,onInitGit:k}){const[N,E]=w.useState("save"),[C,_]=w.useState(""),[R,L]=w.useState(null),[F,I]=w.useState(!1),[H,X]=w.useState(null),[A,$]=w.useState(null),q=w.useRef(null);w.useEffect(()=>{N==="history"&&o()},[N,o]),w.useEffect(()=>{var D;(D=q.current)==null||D.focus()},[]);const W=[...((e==null?void 0:e.modified)??[]).map(D=>({status:"M",file:D})),...((e==null?void 0:e.untracked)??[]).map(D=>({status:"A",file:D}))],ie=w.useRef(!1);w.useEffect(()=>{!ie.current&&W.length>0&&!C&&(_(xy(W)),ie.current=!0)},[W.length]),w.useEffect(()=>{ie.current=!1,_(""),$(null),X(null),L(null)},[h]);const P=w.useCallback(()=>{_(xy(W))},[W]),Y=async()=>{L(null),X(null);try{const D=await i(C||void 0);X(D),_("")}catch(D){L(D instanceof Error?D.message:"Save failed")}},oe=async()=>{$(null),L(null);try{const D=await v();$(D)}catch(D){L(D instanceof Error?D.message:"Pull failed")}},de=async D=>{if(confirm(`Restore from commit ${D.slice(0,7)}? This creates a new commit with those files.`)){I(!0);try{await u(D),I(!1)}catch(B){L(B instanceof Error?B.message:"Restore failed"),I(!1)}}};w.useEffect(()=>{const D=B=>{B.key==="Escape"&&a()};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[a]);const G=D=>{D.key==="Enter"&&(D.metaKey||D.ctrlKey)&&Y()};return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:a}),l.jsxs("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[520px] max-h-[80vh] z-[61] overflow-hidden flex flex-col",style:{background:"var(--hud-bg)",border:"3px solid var(--pixel-border)",fontFamily:"var(--pixel-font)",color:"var(--terminal-text)"},onKeyDown:G,children:[l.jsxs("div",{className:"px-5 py-3 flex items-center justify-between shrink-0",style:{borderBottom:"2px solid var(--pixel-border)"},children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("span",{className:"text-lg font-black tracking-tight",children:"SAVE COMPANY"}),l.jsx("span",{className:"text-[10px]",style:{color:"var(--terminal-text-secondary)"},children:(e==null?void 0:e.branch)??""})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[g&&g.hasRemote&&(g.behind>0||g.ahead>0)&&l.jsxs("span",{className:"text-[10px] font-bold",style:{color:g.behind>0?"var(--idle-amber)":"var(--active-green)"},children:[g.behind>0&&`↓${g.behind}`,g.behind>0&&g.ahead>0&&" ",g.ahead>0&&`↑${g.ahead}`]}),l.jsx("button",{onClick:a,className:"text-[var(--terminal-text-secondary)] hover:text-[var(--terminal-text)] cursor-pointer text-lg",children:"×"})]})]}),l.jsx("div",{className:"flex shrink-0",style:{borderBottom:"2px solid var(--pixel-border)"},children:["akb","code"].map(D=>l.jsx("button",{onClick:()=>x(D),className:"flex-1 py-1.5 text-[10px] font-bold uppercase tracking-wider cursor-pointer",style:{background:h===D?"var(--hud-bg-alt)":"transparent",color:h===D?"var(--terminal-text)":"var(--terminal-text-muted)",borderBottom:h===D?"2px solid var(--accent)":"2px solid transparent"},children:D==="akb"?"AKB":"CODE"},D))}),l.jsx("div",{className:"flex shrink-0",style:{borderBottom:"2px solid var(--pixel-border)"},children:["save","history"].map(D=>l.jsx("button",{onClick:()=>E(D),className:"flex-1 py-2 text-[11px] font-bold uppercase tracking-wider cursor-pointer",style:{background:N===D?"var(--hud-bg-alt)":"transparent",color:N===D?"var(--terminal-text)":"var(--terminal-text-muted)",borderBottom:N===D?"2px solid var(--accent)":"2px solid transparent"},children:D==="save"?"SAVE":"HISTORY"},D))}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-5 space-y-4",children:[N==="save"&&l.jsxs(l.Fragment,{children:[(e==null?void 0:e.noGit)&&l.jsx(y8,{onInitGit:async()=>{await(k==null?void 0:k()),j==null||j()},onDelegate:f?()=>{f(`Git is not initialized or not installed for this project. Please check if git is installed (run "git --version"). If git is available, initialize the repository with "git init" and make an initial commit. If git is not installed, provide clear instructions for the user's OS to install it.`)}:void 0,delegateRoleName:m}),g&&g.hasRemote&&g.behind>0&&l.jsxs("div",{className:"flex items-center justify-between p-2",style:{background:"rgba(255,180,0,0.08)",border:"1px solid var(--idle-amber)"},children:[l.jsxs("span",{className:"text-[11px]",style:{color:"var(--idle-amber)"},children:[g.behind," commit",g.behind>1?"s":""," behind remote"]}),l.jsx("button",{onClick:oe,disabled:b,className:"text-[10px] font-bold px-3 py-1 cursor-pointer",style:{background:"var(--idle-amber)",color:"#000",border:"none",opacity:b?.5:1},children:b?"PULLING...":"↓ PULL"})]}),A&&l.jsx("div",{className:"text-[11px] p-2",style:{background:A.status==="ok"||A.status==="up-to-date"?"rgba(59,185,80,0.1)":"rgba(211,47,47,0.1)",border:`1px solid ${A.status==="ok"||A.status==="up-to-date"?"var(--active-green)":"#D32F2F"}`,color:A.status==="ok"||A.status==="up-to-date"?"var(--active-green)":"#EF5350"},children:A.message}),l.jsx("div",{className:"text-[11px]",style:{color:"var(--terminal-text-secondary)"},children:W.length>0?l.jsxs("span",{style:{color:"var(--idle-amber)"},children:["* ",W.length," unsaved change",W.length>1?"s":""]}):l.jsx("span",{style:{color:"var(--active-green)"},children:"All changes saved"})}),W.length>0&&l.jsxs("div",{children:[l.jsx("div",{className:"text-[10px] font-bold uppercase tracking-wider mb-2",style:{color:"var(--terminal-text-muted)"},children:"Changed Files"}),l.jsx("div",{className:"text-[11px] max-h-[160px] overflow-y-auto p-2 space-y-0.5",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)"},children:W.map(({status:D,file:B})=>l.jsxs("div",{className:"flex gap-2",children:[l.jsx("span",{style:{color:D==="A"?"var(--active-green)":"var(--idle-amber)",width:"14px"},children:D}),l.jsx("span",{style:{color:"var(--terminal-text-secondary)"},children:B})]},B))})]}),W.length>0&&l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsx("div",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"var(--terminal-text-muted)"},children:"Save Message"}),l.jsxs("button",{onClick:P,className:"text-[9px] px-1.5 py-0.5 cursor-pointer",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)",color:"var(--accent)",fontFamily:"var(--pixel-font)"},title:"Auto-generate message from changes",children:["✨"," AUTO"]})]}),l.jsx("input",{ref:q,type:"text",value:C,onChange:D=>_(D.target.value),placeholder:"Auto-generated — edit if needed",className:"w-full px-3 py-2 text-[12px] outline-none",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)",fontFamily:"var(--pixel-font)"}})]}),W.length>0&&l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:Y,disabled:d,className:"flex-1 py-2.5 text-[12px] font-black uppercase tracking-wider cursor-pointer disabled:opacity-50",style:{background:"var(--accent)",color:"#fff",border:"2px solid var(--accent)"},children:d?"SAVING...":e!=null&&e.hasRemote?"SAVE & PUSH":"SAVE"}),f&&l.jsxs("button",{onClick:()=>{const D=W.map(B=>`${B.status} ${B.file}`).join(`
|
|
92
|
+
`);f(D)},disabled:d,className:"py-2.5 px-4 text-[11px] font-bold uppercase tracking-wider cursor-pointer disabled:opacity-50",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"2px solid var(--pixel-border)"},title:`Delegate to ${m??"AI role"} — they'll review, commit, push & merge`,children:["🤖"," ",(m==null?void 0:m.toUpperCase())??"DELEGATE"]})]}),e&&!e.hasRemote&&!e.noGit&&l.jsx(b8,{repo:h,onConnected:()=>j==null?void 0:j(),onDelegate:f?()=>{f(`Set up a GitHub remote for the ${h==="akb"?"AKB":"Code"} repository and push all commits. If gh CLI is available, use "gh repo create". Otherwise, guide through manual setup. Current repo path can be found in config.`)}:void 0,delegateRoleName:m}),H&&l.jsxs("div",{className:"text-[11px] p-2",style:{background:"rgba(59,185,80,0.1)",border:"1px solid var(--active-green)",color:"var(--active-green)"},children:["Saved! ",H.filesChanged," file",H.filesChanged>1?"s":""," committed",H.pushed?" & pushed":"",H.pushError?` (push error: ${H.pushError})`:""]}),R&&l.jsx("div",{className:"text-[11px] p-2",style:{background:"rgba(211,47,47,0.1)",border:"1px solid #D32F2F",color:"#EF5350"},children:R}),(e==null?void 0:e.lastCommit)&&l.jsxs("div",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:["Last save: ",e.lastCommit.message," (",gy(e.lastCommit.date),")"]})]}),N==="history"&&l.jsxs(l.Fragment,{children:[n.length===0&&l.jsx("div",{className:"text-[11px] text-center py-8",style:{color:"var(--terminal-text-muted)"},children:"No save history"}),l.jsx("div",{className:"space-y-1",children:n.map(D=>l.jsxs("div",{className:"flex items-center justify-between py-2 px-3 group",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-[11px] font-mono",style:{color:"var(--accent)"},children:D.shortSha}),l.jsx("span",{className:"text-[11px] truncate",style:{color:"var(--terminal-text)"},children:D.message})]}),l.jsx("div",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:gy(D.date)})]}),l.jsx("button",{onClick:()=>de(D.sha),disabled:F,className:"text-[10px] font-bold px-2 py-1 opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)",color:"var(--idle-amber)"},children:"LOAD"})]},D.sha))})]})]})]})]})}function w8({onClose:e}){const[n,a]=w.useState(null),[i,o]=w.useState(!0),[u,d]=w.useState(null),[,f]=w.useState(!1);return w.useEffect(()=>{Promise.all([ye.getCompanyStats(),ye.getPreferences()]).then(async([m,h])=>{a(m);const x=h;if(x.instanceId)try{await wr.syncStats({instanceId:x.instanceId,roleCount:m.company.roleCount,totalTokens:m.company.totalTokens,rolesData:m.roles.map(g=>({roleId:g.roleId,name:g.name,tokens:g.totalTokens}))}),f(!0)}catch{}}).catch(m=>d(m.message)).finally(()=>o(!1))},[]),i?l.jsx("div",{style:{padding:24,color:"rgba(255,255,255,0.6)"},children:"Loading stats..."}):u||!n?l.jsxs("div",{style:{padding:24,color:"#ff6b6b"},children:[u||"Failed to load stats",l.jsx("button",{onClick:e,style:{marginLeft:12,color:"rgba(255,255,255,0.6)",background:"none",border:"none",cursor:"pointer"},children:"Close"})]}):l.jsxs("div",{style:{padding:20,color:"rgba(255,255,255,0.9)",maxHeight:"100%",overflowY:"auto"},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:20},children:[l.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:600},children:"Company Stats"}),l.jsx("button",{onClick:e,style:{background:"none",border:"none",color:"rgba(255,255,255,0.5)",cursor:"pointer",fontSize:18},children:"×"})]}),l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10,marginBottom:20},children:[l.jsx(Au,{label:"Roles",value:String(n.company.roleCount)}),l.jsx(Au,{label:"Avg Level",value:`Lv.${n.company.avgLevel}`}),l.jsx(Au,{label:"Total Tokens",value:n.company.formattedTokens}),l.jsx(Au,{label:"Total Cost",value:`$${n.company.totalCostUsd.toFixed(2)}`})]}),l.jsx("h4",{style:{margin:"0 0 12px",fontSize:13,fontWeight:600,color:"rgba(255,255,255,0.6)",textTransform:"uppercase",letterSpacing:1},children:"Role Leaderboard"}),l.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[n.roles.map((m,h)=>l.jsx(k8,{role:m,rank:h+1},m.roleId)),n.roles.length===0&&l.jsx("div",{style:{color:"rgba(255,255,255,0.4)",fontSize:13,padding:"8px 0"},children:"No role activity yet. Assign tasks to start leveling up!"})]}),Object.keys(n.byModel).length>0&&l.jsxs(l.Fragment,{children:[l.jsx("h4",{style:{margin:"20px 0 12px",fontSize:13,fontWeight:600,color:"rgba(255,255,255,0.6)",textTransform:"uppercase",letterSpacing:1},children:"Model Usage"}),l.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:Object.entries(n.byModel).map(([m,h])=>l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 10px",background:"rgba(255,255,255,0.03)",borderRadius:6,fontSize:12},children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.7)"},children:j8(m)}),l.jsxs("span",{style:{color:"rgba(255,255,255,0.5)"},children:["$",h.costUsd.toFixed(2)]})]},m))})]})]})}function Au({label:e,value:n}){return l.jsxs("div",{style:{padding:"12px 14px",background:"rgba(255,255,255,0.04)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)"},children:[l.jsx("div",{style:{fontSize:11,color:"rgba(255,255,255,0.45)",marginBottom:4},children:e}),l.jsx("div",{style:{fontSize:18,fontWeight:600},children:n})]})}function k8({role:e,rank:n}){const a=["🥇","🥈","🥉"],i=n<=3?a[n-1]:`#${n}`;return l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",background:"rgba(255,255,255,0.03)",borderRadius:8},children:[l.jsx("span",{style:{fontSize:14,width:28,textAlign:"center",flexShrink:0},children:i}),l.jsxs("div",{style:{flex:1,minWidth:0},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:4},children:[l.jsx("span",{style:{fontSize:13,fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),l.jsxs("span",{style:{fontSize:12,color:yy(e.level),fontWeight:600,flexShrink:0,marginLeft:8},children:["Lv.",e.level]})]}),l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[l.jsx("div",{style:{flex:1,height:4,background:"rgba(255,255,255,0.08)",borderRadius:2,overflow:"hidden"},children:l.jsx("div",{style:{width:`${e.progress*100}%`,height:"100%",background:yy(e.level),borderRadius:2,transition:"width 0.3s ease"}})}),l.jsx("span",{style:{fontSize:10,color:"rgba(255,255,255,0.4)",flexShrink:0},children:e.formattedTokens})]})]})]})}function yy(e){return e>=20?"#FFD700":e>=10?"#C0A0FF":e>=5?"#4FC3F7":e>=3?"#81C784":"rgba(255,255,255,0.4)"}function j8(e){return e.includes("opus")?"Opus":e.includes("sonnet")?"Sonnet":e.includes("haiku")?"Haiku":e.split("-").slice(0,2).join(" ")}function S8({onClose:e,onSyncComplete:n}){const[a,i]=w.useState([]),[o,u]=w.useState([]),[d,f]=w.useState(!0),[m,h]=w.useState(null),[x,g]=w.useState(new Set),[v,b]=w.useState(null),[j,k]=w.useState(null),N=w.useCallback(async()=>{f(!0),b(null);try{const{roles:C}=await ye.getSyncRoles();i(C);const _=C.filter(R=>R.source.sync!=="off");if(_.length===0){u([]),k(null);return}try{const R=await wr.syncCheck(_.map(F=>({roleId:F.roleId,sourceId:F.source.id,currentVersion:F.source.upstream_version??F.source.forked_at??"0.0.0"})));k(!0);const L=[];for(const F of R.updates){if(!F.hasUpdate)continue;const I=_.find(q=>q.roleId===F.roleId);if(!I)continue;const{character:H}=await wr.syncPull(F.sourceId),X=[];I.persona.trim()!==H.persona.trim()&&X.push({field:"persona",local:I.persona.slice(0,120)+(I.persona.length>120?"...":""),upstream:H.persona.slice(0,120)+(H.persona.length>120?"...":"")});const A=JSON.stringify(I.authority),$=JSON.stringify(H.authority);A!==$&&X.push({field:"authority",local:`${I.authority.autonomous.length} autonomous, ${I.authority.needsApproval.length} approval`,upstream:`${H.authority.autonomous.length} autonomous, ${H.authority.needsApproval.length} approval`}),X.length>0&&L.push({roleId:F.roleId,roleName:I.name,sourceId:F.sourceId,currentVersion:F.currentVersion,latestVersion:F.latestVersion,fields:X})}u(L)}catch{k(!1),u([])}}catch(C){b(C instanceof Error?C.message:"Failed to check for updates")}finally{f(!1)}},[]);w.useEffect(()=>{N()},[N]);const E=async C=>{h(C.roleId);try{const{character:_,version:R}=await wr.syncPull(C.sourceId);await ye.applySyncUpdate({roleId:C.roleId,changes:{persona:_.persona,authority:_.authority},upstreamVersion:R}),g(L=>new Set(L).add(C.roleId)),n==null||n()}catch(_){b(_ instanceof Error?_.message:"Failed to apply update")}finally{h(null)}};return l.jsxs("div",{style:{padding:20,color:"rgba(255,255,255,0.9)",maxHeight:"100%",overflowY:"auto"},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[l.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:600},children:"Role Sync"}),l.jsxs("div",{style:{display:"flex",gap:8},children:[l.jsx("button",{onClick:N,disabled:d,style:{background:"rgba(255,255,255,0.08)",border:"1px solid rgba(255,255,255,0.1)",color:"rgba(255,255,255,0.7)",borderRadius:6,padding:"4px 10px",fontSize:12,cursor:d?"wait":"pointer"},children:d?"Checking...":"Refresh"}),l.jsx("button",{onClick:e,style:{background:"none",border:"none",color:"rgba(255,255,255,0.5)",cursor:"pointer",fontSize:18},children:"×"})]})]}),j===!1&&l.jsx("div",{style:{padding:"8px 12px",background:"rgba(255,180,0,0.1)",borderRadius:6,color:"#FFB74D",fontSize:12,marginBottom:12},children:"Cloud API unreachable. Sync requires connection to api.tycono.ai."}),v&&l.jsx("div",{style:{padding:"8px 12px",background:"rgba(255,100,100,0.1)",borderRadius:6,color:"#ff6b6b",fontSize:12,marginBottom:12},children:v}),l.jsxs("div",{style:{padding:"10px 14px",background:"rgba(255,255,255,0.04)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)",marginBottom:16,fontSize:13},children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:"Tracked roles: "}),l.jsx("span",{style:{fontWeight:500},children:a.length}),l.jsx("span",{style:{color:"rgba(255,255,255,0.3)",margin:"0 8px"},children:"·"}),l.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:"Updates available: "}),l.jsx("span",{style:{fontWeight:500,color:o.length>0?"#4FC3F7":"rgba(255,255,255,0.7)"},children:o.filter(C=>!x.has(C.roleId)).length}),j===!0&&l.jsxs(l.Fragment,{children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.3)",margin:"0 8px"},children:"·"}),l.jsx("span",{style:{fontSize:11,color:"#81C784"},children:"Cloud connected"})]})]}),o.length===0&&!d&&l.jsx("div",{style:{color:"rgba(255,255,255,0.4)",fontSize:13,padding:"20px 0",textAlign:"center"},children:a.length===0?"No roles with source tracking. Hire from the Store to enable sync.":"All roles are up to date!"}),o.map(C=>l.jsxs("div",{style:{marginBottom:12,padding:14,background:"rgba(255,255,255,0.03)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)"},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:10},children:[l.jsxs("div",{children:[l.jsx("div",{style:{fontSize:14,fontWeight:500},children:C.roleName}),l.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.4)"},children:[C.sourceId," · v",C.currentVersion," → v",C.latestVersion]})]}),x.has(C.roleId)?l.jsx("span",{style:{fontSize:12,color:"#81C784"},children:"Applied ✓"}):l.jsx("button",{onClick:()=>E(C),disabled:m===C.roleId,style:{background:"#1565C0",border:"none",color:"white",borderRadius:6,padding:"5px 12px",fontSize:12,cursor:m===C.roleId?"wait":"pointer",opacity:m===C.roleId?.6:1},children:m===C.roleId?"Applying...":"Apply Update"})]}),C.fields.map(_=>l.jsxs("div",{style:{marginBottom:6,fontSize:12},children:[l.jsx("div",{style:{color:"rgba(255,255,255,0.5)",marginBottom:2,textTransform:"uppercase",fontSize:10,letterSpacing:.5},children:_.field}),l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:6},children:[l.jsxs("div",{style:{padding:"4px 8px",background:"rgba(255,100,100,0.08)",borderRadius:4,color:"rgba(255,255,255,0.6)"},children:[l.jsx("span",{style:{fontSize:9,color:"rgba(255,255,255,0.3)"},children:"LOCAL"}),l.jsx("br",{}),_.local]}),l.jsxs("div",{style:{padding:"4px 8px",background:"rgba(100,255,100,0.08)",borderRadius:4,color:"rgba(255,255,255,0.6)"},children:[l.jsx("span",{style:{fontSize:9,color:"rgba(255,255,255,0.3)"},children:"UPSTREAM"}),l.jsx("br",{}),_.upstream]})]})]},_.field))]},C.roleId)),a.length>0&&l.jsxs("div",{style:{marginTop:16,fontSize:11,color:"rgba(255,255,255,0.3)",lineHeight:1.5},children:["Roles hired from the Store are tracked automatically. Set ",l.jsx("code",{style:{background:"rgba(255,255,255,0.06)",padding:"1px 4px",borderRadius:3},children:"sync: off"})," in role.yaml to stop tracking."]})]})}function C8({onClose:e}){const[n,a]=w.useState(null),[i,o]=w.useState(!0),[u,d]=w.useState(null),[f,m]=w.useState(null),h=w.useCallback(async()=>{o(!0),d(null);try{const C=await ye.getGitStatus();a(C)}catch(C){d(C instanceof Error?C.message:"Failed to load git status")}finally{o(!1)}},[]);w.useEffect(()=>{h()},[h]);const x=async C=>{m(C.path);try{await ye.deleteWorktree(C.path),await h()}catch(_){d(_ instanceof Error?_.message:"Failed to remove worktree")}finally{m(null)}},g=async C=>{m(C);try{await ye.deleteBranch(C),await h()}catch(_){d(_ instanceof Error?_.message:"Failed to delete branch")}finally{m(null)}};if(i&&!n)return l.jsx("div",{style:{padding:24,color:"rgba(255,255,255,0.6)"},children:"Loading git status..."});if(u&&!n)return l.jsxs("div",{style:{padding:24,color:"#ff6b6b"},children:[u,l.jsx("button",{onClick:e,style:{marginLeft:12,color:"rgba(255,255,255,0.6)",background:"none",border:"none",cursor:"pointer"},children:"Close"})]});if(!n)return null;const v=n.worktrees.filter(C=>C.status==="active"),b=n.worktrees.filter(C=>C.status==="pending-merge"),j=n.worktrees.filter(C=>C.status==="stale");function k(C){const _=C.split("/");if(_.length>1){const R=_[_.length-1],L=["cto","cbo","pm","engineer","designer","qa","data-analyst"];for(const F of L)if(R.toLowerCase().includes(F))return F}return null}function N(C,_=40){return C.length<=_?C:"..."+C.slice(C.length-_+3)}function E(C){const _=Date.now()-new Date(C).getTime(),R=Math.floor(_/6e4);if(R<1)return"just now";if(R<60)return`${R}m ago`;const L=Math.floor(R/60);return L<24?`${L}h ago`:`${Math.floor(L/24)}d ago`}return l.jsxs("div",{style:{padding:20,color:"rgba(255,255,255,0.9)",maxHeight:"100%",overflowY:"auto"},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[l.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:600},children:"GIT STATUS"}),l.jsxs("div",{style:{display:"flex",gap:8},children:[l.jsx("button",{onClick:h,disabled:i,style:{background:"rgba(255,255,255,0.08)",border:"1px solid rgba(255,255,255,0.1)",color:"rgba(255,255,255,0.7)",borderRadius:6,padding:"4px 10px",fontSize:12,cursor:i?"wait":"pointer"},children:i?"Checking...":"Refresh"}),l.jsx("button",{onClick:e,style:{background:"none",border:"none",color:"rgba(255,255,255,0.5)",cursor:"pointer",fontSize:18},children:"×"})]})]}),u&&l.jsx("div",{style:{padding:"8px 12px",background:"rgba(255,100,100,0.1)",borderRadius:6,color:"#ff6b6b",fontSize:12,marginBottom:12},children:u}),l.jsxs("div",{style:{padding:"10px 14px",background:"rgba(255,255,255,0.04)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)",marginBottom:16,fontSize:13},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[l.jsxs("div",{children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:"Branch: "}),l.jsx("span",{style:{fontWeight:500},children:n.currentBranch})]}),l.jsx("div",{children:n.unsavedCount>0&&l.jsxs("span",{style:{color:"#FFB74D",fontSize:12},children:[n.unsavedCount," unsaved"]})})]}),n.lastCommit&&l.jsxs("div",{style:{marginTop:6,fontSize:11,color:"rgba(255,255,255,0.4)"},children:["Last commit: ",n.lastCommit.message.slice(0,60),n.lastCommit.message.length>60?"...":""," · ",E(n.lastCommit.date)]})]}),v.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Du,{label:"Active Worktrees",count:v.length}),v.map(C=>l.jsx(Uh,{wt:C,roleFromBranch:C.roleId||k(C.branch),truncatePath:N,timeAgo:E,removing:f===C.path,onRemove:()=>x(C),statusColor:"#4FC3F7",statusIcon:"📂"},C.path))]}),b.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Du,{label:"Pending Merge",count:b.length}),b.map(C=>l.jsx(Uh,{wt:C,roleFromBranch:C.roleId||k(C.branch),truncatePath:N,timeAgo:E,removing:f===C.path,onRemove:()=>x(C),statusColor:"#FFB74D",statusIcon:"⚠️"},C.path))]}),j.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Du,{label:"Stale",count:j.length}),j.map(C=>l.jsx(Uh,{wt:C,roleFromBranch:C.roleId||k(C.branch),truncatePath:N,timeAgo:E,removing:f===C.path,onRemove:()=>x(C),statusColor:"#ff6b6b",statusIcon:"🔴"},C.path))]}),n.staleBranches.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Du,{label:"Unmerged Branches",count:n.staleBranches.length}),n.staleBranches.map(C=>l.jsxs("div",{style:{marginBottom:8,padding:"10px 14px",background:"rgba(255,255,255,0.03)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[l.jsxs("div",{style:{fontSize:13},children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.5)",marginRight:6},children:"⚠️"}),l.jsx("span",{style:{fontWeight:500},children:C})]}),l.jsx("button",{onClick:()=>g(C),disabled:f===C,style:{background:"rgba(255,100,100,0.15)",border:"1px solid rgba(255,100,100,0.2)",color:"#ff6b6b",borderRadius:4,padding:"3px 8px",fontSize:10,cursor:f===C?"wait":"pointer",opacity:f===C?.6:1,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:f===C?"...":"DELETE"})]},C))]}),v.length===0&&b.length===0&&j.length===0&&n.staleBranches.length===0&&l.jsxs("div",{style:{color:"rgba(255,255,255,0.4)",fontSize:13,padding:"20px 0",textAlign:"center"},children:["✓"," All clean. No active worktrees or stale branches."]}),n.lastMerge&&l.jsxs("div",{style:{marginTop:16,fontSize:11,color:"rgba(255,255,255,0.3)",lineHeight:1.5},children:["Last merge: ",l.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:n.lastMerge.branch})," · ",n.lastMerge.roleId," · ",E(n.lastMerge.mergedAt)]})]})}function Du({label:e,count:n}){return l.jsxs("h4",{style:{margin:"16px 0 8px",fontSize:11,fontWeight:600,color:"rgba(255,255,255,0.5)",textTransform:"uppercase",letterSpacing:1},children:[e," (",n,")"]})}function Uh({wt:e,roleFromBranch:n,truncatePath:a,timeAgo:i,removing:o,onRemove:u,statusColor:d,statusIcon:f}){return l.jsx("div",{style:{marginBottom:8,padding:"10px 14px",background:"rgba(255,255,255,0.03)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)"},children:l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[l.jsxs("div",{style:{flex:1,minWidth:0},children:[l.jsxs("div",{style:{fontSize:13,fontWeight:500,marginBottom:2},children:[l.jsx("span",{style:{marginRight:6},children:f}),e.branch,n&&l.jsx("span",{style:{marginLeft:8,fontSize:10,padding:"1px 6px",background:"rgba(255,255,255,0.08)",borderRadius:3,color:"rgba(255,255,255,0.6)",textTransform:"uppercase"},children:n})]}),e.task&&l.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.5)",marginBottom:2},children:['"',e.task.slice(0,50),e.task.length>50?"...":"",'"']}),l.jsxs("div",{style:{fontSize:10,color:"rgba(255,255,255,0.35)"},children:[a(e.path)," · ",e.filesChanged," file",e.filesChanged!==1?"s":""," changed"," · ",i(e.createdAt)]}),e.conflictFiles&&e.conflictFiles.length>0&&l.jsxs("div",{style:{fontSize:10,color:"#ff6b6b",marginTop:4},children:["⛔"," CONFLICT: ",e.conflictFiles.join(", ")]})]}),l.jsx("button",{onClick:u,disabled:o,style:{background:"rgba(255,100,100,0.15)",border:"1px solid rgba(255,100,100,0.2)",color:d,borderRadius:4,padding:"3px 8px",fontSize:10,cursor:o?"wait":"pointer",opacity:o?.6:1,fontWeight:600,textTransform:"uppercase",letterSpacing:.5,flexShrink:0,marginLeft:8},children:o?"...":"REMOVE"})]})})}function E8({onClose:e}){const[n,a]=w.useState(null),[i,o]=w.useState(!0),[u,d]=w.useState(null),[f,m]=w.useState(null),h=w.useCallback(async()=>{o(!0),d(null);try{const k=await ye.getActiveSessions();a(k)}catch(k){d(k instanceof Error?k.message:"Failed to load sessions")}finally{o(!1)}},[]);w.useEffect(()=>{h();const k=setInterval(h,1e4);return()=>clearInterval(k)},[h]);const x=async k=>{m(k);try{await ye.deleteActiveSession(k),await h()}catch(N){d(N instanceof Error?N.message:"Failed to remove session")}finally{m(null)}},g=async()=>{try{await ye.cleanupActiveSessions(),await h()}catch(k){d(k instanceof Error?k.message:"Failed to cleanup sessions")}};if(i&&!n)return l.jsx("div",{style:{padding:24,color:"rgba(255,255,255,0.6)"},children:"Loading sessions..."});if(u&&!n)return l.jsxs("div",{style:{padding:24,color:"#ff6b6b"},children:[u,l.jsx("button",{onClick:e,style:{marginLeft:12,color:"rgba(255,255,255,0.6)",background:"none",border:"none",cursor:"pointer"},children:"Close"})]});if(!n)return null;const v=n.sessions.filter(k=>k.status==="active"),b=n.sessions.filter(k=>k.status==="idle"),j=n.sessions.filter(k=>k.status==="dead");return l.jsxs("div",{style:{padding:20,color:"rgba(255,255,255,0.9)",maxHeight:"100%",overflowY:"auto"},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[l.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:600},children:"ACTIVE SESSIONS"}),l.jsxs("div",{style:{display:"flex",gap:8},children:[j.length>0&&l.jsx("button",{onClick:g,style:{background:"rgba(255,180,100,0.15)",border:"1px solid rgba(255,180,100,0.2)",color:"#FFB74D",borderRadius:6,padding:"4px 10px",fontSize:12,cursor:"pointer"},children:"Cleanup Dead"}),l.jsx("button",{onClick:h,disabled:i,style:{background:"rgba(255,255,255,0.08)",border:"1px solid rgba(255,255,255,0.1)",color:"rgba(255,255,255,0.7)",borderRadius:6,padding:"4px 10px",fontSize:12,cursor:i?"wait":"pointer"},children:i?"Checking...":"Refresh"}),l.jsx("button",{onClick:e,style:{background:"none",border:"none",color:"rgba(255,255,255,0.5)",cursor:"pointer",fontSize:18},children:"×"})]})]}),u&&l.jsx("div",{style:{padding:"8px 12px",background:"rgba(255,100,100,0.1)",borderRadius:6,color:"#ff6b6b",fontSize:12,marginBottom:12},children:u}),l.jsxs("div",{style:{padding:"10px 14px",background:"rgba(255,255,255,0.04)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)",marginBottom:16,fontSize:13,display:"flex",justifyContent:"space-between"},children:[l.jsxs("div",{children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:"Sessions: "}),l.jsx("span",{style:{fontWeight:500},children:n.summary.active})]}),l.jsxs("div",{children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:"Ports in use: "}),l.jsx("span",{style:{fontWeight:500},children:n.summary.totalPorts})]})]}),v.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(qh,{label:"Active",count:v.length}),v.map(k=>l.jsx(Yh,{session:k,removing:f===k.sessionId,onRemove:()=>x(k.sessionId),statusColor:"#4FC3F7"},k.sessionId))]}),b.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(qh,{label:"Idle",count:b.length}),b.map(k=>l.jsx(Yh,{session:k,removing:f===k.sessionId,onRemove:()=>x(k.sessionId),statusColor:"#FFB74D"},k.sessionId))]}),j.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(qh,{label:"Dead",count:j.length}),j.map(k=>l.jsx(Yh,{session:k,removing:f===k.sessionId,onRemove:()=>x(k.sessionId),statusColor:"#ff6b6b"},k.sessionId))]}),n.sessions.length===0&&l.jsx("div",{style:{color:"rgba(255,255,255,0.4)",fontSize:13,padding:"20px 0",textAlign:"center"},children:"No active sessions. Sessions appear when jobs run with port allocation."})]})}function qh({label:e,count:n}){return l.jsxs("h4",{style:{margin:"16px 0 8px",fontSize:11,fontWeight:600,color:"rgba(255,255,255,0.5)",textTransform:"uppercase",letterSpacing:1},children:[e," (",n,")"]})}function N8(e){const n=Date.now()-new Date(e).getTime(),a=Math.floor(n/6e4);if(a<1)return"just now";if(a<60)return`${a}m ago`;const i=Math.floor(a/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function Yh({session:e,removing:n,onRemove:a,statusColor:i}){const{ports:o}=e;return l.jsx("div",{style:{marginBottom:8,padding:"10px 14px",background:"rgba(255,255,255,0.03)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)"},children:l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[l.jsxs("div",{style:{flex:1,minWidth:0},children:[l.jsxs("div",{style:{fontSize:13,fontWeight:500,marginBottom:2},children:[l.jsx("span",{style:{display:"inline-block",width:8,height:8,borderRadius:"50%",backgroundColor:i,marginRight:8,verticalAlign:"middle"}}),l.jsx("span",{style:{textTransform:"uppercase"},children:e.roleName||e.roleId}),e.jobStatus&&l.jsx("span",{style:{marginLeft:8,fontSize:10,padding:"1px 6px",background:"rgba(255,255,255,0.08)",borderRadius:3,color:"rgba(255,255,255,0.6)"},children:e.jobStatus})]}),e.task&&l.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.5)",marginBottom:4},children:['"',e.task.slice(0,60),e.task.length>60?"...":"",'"']}),l.jsxs("div",{style:{fontSize:11,display:"flex",gap:8,marginBottom:2},children:[l.jsxs("span",{style:{color:"#81C784"},children:["API:",o.api||"?"]}),l.jsxs("span",{style:{color:"#64B5F6"},children:["Vite:",o.vite||"?"]}),o.hmr&&l.jsxs("span",{style:{color:"#FFB74D"},children:["HMR:",o.hmr]})]}),l.jsxs("div",{style:{fontSize:10,color:"rgba(255,255,255,0.35)"},children:[e.sessionId.slice(0,12),"...",e.worktreePath&&l.jsxs(l.Fragment,{children:[" · ",A8(e.worktreePath)]}),e.pid&&l.jsxs(l.Fragment,{children:[" · ","PID:",e.pid]})," · ",N8(e.startedAt)]})]}),l.jsx("button",{onClick:a,disabled:n,style:{background:"rgba(255,100,100,0.15)",border:"1px solid rgba(255,100,100,0.2)",color:"#ff6b6b",borderRadius:4,padding:"3px 8px",fontSize:10,cursor:n?"wait":"pointer",opacity:n?.6:1,fontWeight:600,textTransform:"uppercase",letterSpacing:.5,flexShrink:0,marginLeft:8},children:n?"...":"STOP"})]})})}function A8(e,n=35){return e.length<=n?e:"..."+e.slice(e.length-n+3)}function D8({onClose:e,speechSettings:n,onSpeechSettingsChange:a,language:i,onLanguageChange:o,onOpenSync:u,onOpenGitStatus:d,onOpenSessions:f,onOpenStats:m}){var oe;const[h,x]=w.useState(null),[g,v]=w.useState(null),[b,j]=w.useState(!1),[k,N]=w.useState(!1),[E,C]=w.useState(!1),[_,R]=w.useState(null),[L,F]=w.useState(""),[I,H]=w.useState(!1),[X,A]=w.useState(!1),[$,q]=w.useState(null),[W,ie]=w.useState(!1);w.useEffect(()=>{ye.getPreferences().then(async de=>{const G=de;if(x(G.instanceId??null),G.instanceId)try{const{name:D}=await wr.getMyName(G.instanceId);v(D)}catch{}}).catch(()=>{}),ye.getCodeRoot().then(({codeRoot:de})=>{R(de),de&&F(de)}).catch(()=>{})},[]);const P=async()=>{C(!0);try{const G=await(await fetch("/api/preferences/regenerate-token",{method:"POST"})).json();G.ok&&(x(G.newInstanceId),N(!1))}catch{}C(!1)},Y=()=>{h&&navigator.clipboard.writeText(h).then(()=>{j(!0),setTimeout(()=>j(!1),2e3)})};return l.jsx("div",{className:"customize-overlay",onClick:e,children:l.jsxs("div",{className:"customize-modal",onClick:de=>de.stopPropagation(),style:{maxWidth:480},children:[l.jsxs("div",{className:"customize-header",children:[l.jsx("div",{style:{fontSize:12,fontWeight:700,letterSpacing:1,color:"var(--terminal-text)"},children:"SETTINGS"}),l.jsx("button",{className:"customize-close",onClick:e,children:"X"})]}),l.jsx("div",{className:"customize-body",style:{padding:"12px 20px 20px"},children:l.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:20},children:[l.jsxs("div",{children:[l.jsx("div",{style:{fontSize:11,fontWeight:600,marginBottom:8,color:"var(--terminal-text)"},children:"AMBIENT SPEECH MODE"}),l.jsx("div",{style:{display:"flex",gap:6},children:["template","llm","auto"].map(de=>l.jsxs("button",{onClick:()=>a==null?void 0:a({mode:de}),style:{flex:1,padding:"8px 12px",fontSize:11,border:`2px solid ${(n==null?void 0:n.mode)===de?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(n==null?void 0:n.mode)===de?"rgba(255,255,255,0.08)":"transparent",color:(n==null?void 0:n.mode)===de?"var(--terminal-text)":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",textAlign:"center"},children:[l.jsx("div",{style:{fontWeight:600,marginBottom:2},children:de==="template"?"TEMPLATE":de==="llm"?"AI":"AUTO"}),l.jsx("div",{style:{fontSize:9,opacity:.7},children:de==="template"?"Static pool ($0)":de==="llm"?"LLM generated":"Detect engine"})]},de))}),l.jsx("div",{style:{fontSize:9,color:"var(--terminal-text-muted)",marginTop:4},children:"Auto: CLI Max = AI, BYOK = Template"})]}),l.jsxs("div",{children:[l.jsxs("div",{style:{fontSize:11,fontWeight:600,marginBottom:8,color:"var(--terminal-text)"},children:["SPEECH INTERVAL: ",(n==null?void 0:n.intervalSec)??18,"s"]}),l.jsx("input",{type:"range",min:5,max:120,step:5,value:(n==null?void 0:n.intervalSec)??18,onChange:de=>a==null?void 0:a({intervalSec:Number(de.target.value)}),style:{width:"100%",accentColor:"var(--accent)"}}),l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:9,color:"var(--terminal-text-muted)"},children:[l.jsx("span",{children:"5s (frequent)"}),l.jsx("span",{children:"120s (rare)"})]})]}),(n==null?void 0:n.mode)!=="template"&&l.jsxs("div",{children:[l.jsxs("div",{style:{fontSize:11,fontWeight:600,marginBottom:8,color:"var(--terminal-text)"},children:["DAILY LLM BUDGET: $",((oe=n==null?void 0:n.dailyBudgetUsd)==null?void 0:oe.toFixed(2))??"1.00"]}),l.jsx("input",{type:"range",min:0,max:5,step:.25,value:(n==null?void 0:n.dailyBudgetUsd)??1,onChange:de=>a==null?void 0:a({dailyBudgetUsd:Number(de.target.value)}),style:{width:"100%",accentColor:"var(--accent)"}}),l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:9,color:"var(--terminal-text-muted)"},children:[l.jsx("span",{children:"$0 (unlimited)"}),l.jsx("span",{children:"$5.00/day"})]})]}),l.jsxs("div",{children:[l.jsx("div",{style:{fontSize:11,fontWeight:600,marginBottom:8,color:"var(--terminal-text)"},children:"LANGUAGE"}),l.jsx("div",{style:{display:"flex",gap:6},children:[{key:"auto",label:"Auto"},{key:"en",label:"English"},{key:"ko",label:"한국어"},{key:"ja",label:"日本語"}].map(({key:de,label:G})=>l.jsx("button",{onClick:()=>o==null?void 0:o(de),style:{flex:1,padding:"8px 12px",fontSize:11,border:`2px solid ${(i??"auto")===de?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(i??"auto")===de?"rgba(255,255,255,0.08)":"transparent",color:(i??"auto")===de?"var(--terminal-text)":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",textAlign:"center",fontWeight:600},children:G},de))}),l.jsx("div",{style:{fontSize:9,color:"var(--terminal-text-muted)",marginTop:4},children:"Sets language for AI responses and speech bubbles"})]}),l.jsxs("div",{children:[l.jsx("div",{style:{fontSize:11,fontWeight:600,marginBottom:8,color:"var(--terminal-text)"},children:"CODE REPOSITORY"}),I?l.jsxs("div",{children:[l.jsxs("div",{style:{display:"flex",gap:6},children:[l.jsx("input",{type:"text",value:L,onChange:de=>{F(de.target.value),q(null)},placeholder:"/path/to/code/repo",style:{flex:1,padding:"8px 10px",fontSize:11,background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.15)",borderRadius:6,color:"var(--terminal-text)",fontFamily:"monospace",outline:"none"},autoFocus:!0}),l.jsx("button",{onClick:async()=>{if(L.trim()){A(!0),q(null);try{const de=await ye.setCodeRoot(L.trim());R(de.codeRoot),F(de.codeRoot),H(!1),ie(!0),setTimeout(()=>ie(!1),3e3)}catch(de){q(de instanceof Error?de.message:"Failed to set code root")}finally{A(!1)}}},disabled:X||!L.trim(),style:{padding:"8px 12px",fontSize:10,fontWeight:600,background:"var(--accent)",border:"none",color:"#fff",borderRadius:6,cursor:"pointer",opacity:X||!L.trim()?.5:1},children:X?"...":"Save"}),l.jsx("button",{onClick:()=>{H(!1),F(_||""),q(null)},style:{padding:"8px 10px",fontSize:10,background:"transparent",border:"1px solid rgba(255,255,255,0.1)",color:"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer"},children:"Cancel"})]}),$&&l.jsx("div",{style:{fontSize:9,color:"#ff6b6b",marginTop:4},children:$})]}):l.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[l.jsx("code",{style:{flex:1,padding:"8px 10px",fontSize:10,background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:6,color:_?"var(--terminal-text)":"var(--terminal-text-muted)",fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:_||"Not configured"}),l.jsx("button",{onClick:()=>{H(!0),q(null),ie(!1)},style:{padding:"8px 12px",fontSize:10,fontWeight:600,border:"2px solid rgba(255,255,255,0.1)",background:"transparent",color:"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer"},children:"Change"})]}),W&&l.jsx("div",{style:{fontSize:9,color:"#4ade80",marginTop:4},children:"Code repository updated!"}),l.jsx("div",{style:{fontSize:9,color:"var(--terminal-text-muted)",marginTop:4},children:"Path to your code repository (separate from AKB). If not set, auto-created as ../[company]-code/ when AI starts working."})]}),h&&l.jsxs("div",{children:[l.jsx("div",{style:{fontSize:11,fontWeight:600,marginBottom:8,color:"var(--terminal-text)"},children:"STORE TOKEN"}),l.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[l.jsx("code",{style:{flex:1,padding:"8px 10px",fontSize:10,background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:6,color:"var(--terminal-text-muted)",fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h}),l.jsx("button",{onClick:Y,style:{padding:"8px 12px",fontSize:10,fontWeight:600,border:"2px solid rgba(255,255,255,0.1)",background:"transparent",color:b?"#4ade80":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",whiteSpace:"nowrap"},children:b?"Copied!":"Copy"})]}),l.jsx("div",{style:{fontSize:9,color:"var(--terminal-text-muted)",marginTop:4},children:"Use this token to sign in on the web Store. Keep it secret — anyone with this token can act as you."}),l.jsx("div",{style:{marginTop:6},children:k?l.jsxs("div",{style:{background:"rgba(255,50,50,0.08)",border:"1px solid rgba(255,50,50,0.2)",borderRadius:6,padding:"8px 10px"},children:[l.jsx("div",{style:{fontSize:9,color:"rgba(255,100,100,0.8)",marginBottom:6},children:"This will invalidate your current token. Published characters will lose ownership. No migration."}),l.jsxs("div",{style:{display:"flex",gap:6},children:[l.jsx("button",{onClick:P,disabled:E,style:{padding:"4px 12px",fontSize:9,fontWeight:700,border:"1px solid rgba(255,50,50,0.4)",background:"rgba(255,50,50,0.15)",color:"#ff6464",borderRadius:4,cursor:"pointer"},children:E?"...":"Confirm Regenerate"}),l.jsx("button",{onClick:()=>N(!1),style:{padding:"4px 12px",fontSize:9,border:"none",background:"transparent",color:"var(--terminal-text-muted)",cursor:"pointer"},children:"Cancel"})]})]}):l.jsx("button",{onClick:()=>N(!0),style:{padding:"4px 10px",fontSize:9,fontWeight:600,border:"1px solid rgba(255,100,100,0.2)",background:"transparent",color:"rgba(255,100,100,0.6)",borderRadius:4,cursor:"pointer"},children:"Regenerate Token"})})]}),l.jsxs("div",{style:{borderTop:"1px solid rgba(255,255,255,0.08)",paddingTop:16,display:"flex",gap:8},children:[u&&l.jsx("button",{onClick:()=>{e(),u()},className:"theme-btn",style:{flex:1,padding:"8px 12px",fontSize:10},children:"🔄 ROLE SYNC"}),d&&l.jsx("button",{onClick:()=>{e(),d()},className:"theme-btn",style:{flex:1,padding:"8px 12px",fontSize:10},children:"📂 GIT STATUS"}),f&&l.jsx("button",{onClick:()=>{e(),f()},className:"theme-btn",style:{flex:1,padding:"8px 12px",fontSize:10},children:"🖥 SESSIONS"}),m&&l.jsx("button",{onClick:()=>{e(),m()},className:"theme-btn",style:{flex:1,padding:"8px 12px",fontSize:10},children:"📊 COMPANY STATS"}),l.jsx("button",{onClick:()=>window.open("https://tycono.ai/store.html","_blank"),className:"theme-btn",style:{flex:1,padding:"8px 12px",fontSize:10},children:"🌐 WEB STORE"})]}),g&&l.jsx("div",{style:{textAlign:"center",marginTop:-8},children:l.jsx("a",{href:`https://tycono.ai/profile.html?u=${encodeURIComponent(g)}`,target:"_blank",rel:"noopener noreferrer",style:{fontSize:10,color:"var(--terminal-text-muted)",textDecoration:"none"},onMouseEnter:de=>de.currentTarget.style.color="var(--accent)",onMouseLeave:de=>de.currentTarget.style.color="var(--terminal-text-muted)",children:"View public profile →"})})]})})]})})}function T8({theme:e,onThemeChange:n,onClose:a}){const i=w.useRef(null);return w.useEffect(()=>{const o=u=>{i.current&&!i.current.contains(u.target)&&a()};return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[a]),l.jsx("div",{ref:i,className:"theme-dropup",children:Object.entries(il).map(([o,u])=>l.jsxs("button",{className:`theme-dropup__item${e===o?" theme-dropup__item--active":""}`,onClick:()=>{n(o),a()},title:u.name,children:[l.jsxs("span",{className:"theme-dropup__swatch",style:{background:u.vars["--hud-bg"],borderColor:u.vars["--pixel-border"]},children:[l.jsx("span",{style:{background:u.vars["--accent"],width:5,height:5,borderRadius:1}}),l.jsx("span",{style:{background:u.vars["--active-green"],width:5,height:5,borderRadius:1}}),l.jsx("span",{style:{background:u.vars["--idle-amber"],width:5,height:5,borderRadius:1}})]}),l.jsx("span",{className:"theme-dropup__name",children:u.icon})]},o))})}const ys={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function F8({roles:e,roleStatuses:n,activeExecs:a,sessions:i,knowledgeDocs:o,roleLevels:u,companyName:d,getAppearance:f,waveCenterWaves:m,renderProfile:h,channel:x,onChannelChange:g,onClose:v,children:b}){const[j,k]=w.useState(!1),N=m.filter(I=>I.rootJobs.some(H=>{const X=n[H.roleId];return X==="working"||X==="thinking"})),E=[...e].sort((I,H)=>I.level==="c-level"&&H.level!=="c-level"?-1:I.level!=="c-level"&&H.level==="c-level"?1:I.name.localeCompare(H.name)),C=e.filter(I=>n[I.id]==="working").length,_=i.filter(I=>I.status==="active").length,R=x.type==="role"?e.find(I=>I.id===x.roleId):null,L=x.type==="dashboard"?"Dashboard":x.type==="terminal"?"Chats":x.type==="wave"?"Wave Center":x.type==="knowledge"?"Knowledge Base":x.type==="operations"?"Operations":x.type==="role"?(R==null?void 0:R.name)??x.roleId:"Dashboard",F=x.type==="terminal"?`${_} active sessions`:x.type==="wave"?`${N.length} running`:x.type==="knowledge"?`${o.length} documents`:x.type==="role"?(R==null?void 0:R.level)==="c-level"?"C-Level":"Team member":`${C} working · ${e.length} total`;return l.jsxs("div",{className:"fixed inset-0 z-[60] flex",style:{background:"var(--terminal-bg, #1C1612)"},children:[l.jsxs("div",{className:"flex flex-col shrink-0 overflow-y-auto",style:{width:240,borderRight:"1px solid var(--terminal-border, #2E261F)",background:"var(--terminal-surface, #1a1510)"},children:[l.jsxs("div",{className:"px-4 py-3 flex items-center gap-2 shrink-0",style:{borderBottom:"1px solid var(--terminal-border, #2E261F)"},children:[l.jsx("span",{className:"text-[11px] font-bold tracking-wider flex-1",style:{color:"var(--terminal-text, #fff5eb)",fontFamily:"var(--pixel-font)"},children:d}),C>0&&l.jsxs("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full animate-pulse",style:{background:"#4CAF5020",color:"#4CAF50"},children:[C," live"]})]}),N.length>0&&l.jsxs("button",{className:"mx-3 mt-3 px-3 py-2.5 rounded-lg text-left transition-all hover:opacity-90",style:{background:x.type==="wave"?"#EF444420":"#EF444410",border:"1px solid #EF444430"},onClick:()=>g({type:"wave"}),children:[l.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[l.jsxs("span",{className:"text-[10px] font-bold truncate flex-1",style:{color:"#EF4444"},children:["⚡"," ",N[0].directive.slice(0,28)]}),l.jsx("span",{className:"text-[7px] px-1.5 py-0.5 rounded font-bold shrink-0",style:{background:"#EF4444",color:"#fff"},children:"LIVE"})]}),l.jsxs("div",{className:"text-[9px]",style:{color:"var(--terminal-text-muted)"},children:[N[0].rootJobs.filter(I=>{const H=n[I.roleId];return H==="working"||H==="thinking"}).length,"/",N[0].rootJobs.length," roles working"]})]}),l.jsxs("div",{className:"mx-3 mt-3 grid grid-cols-2 gap-1.5",children:[l.jsx(Tu,{icon:"💬",label:"Chats",badge:_||void 0,active:x.type==="terminal",onClick:()=>g({type:"terminal"})}),l.jsx(Tu,{icon:"⚡",label:"Waves",live:N.length>0,active:x.type==="wave",onClick:()=>g({type:"wave"})}),l.jsx(Tu,{icon:"📋",label:"Decisions",active:x.type==="operations",onClick:()=>g({type:"operations"})}),l.jsx(Tu,{icon:"📚",label:"Knowledge",badge:o.length||void 0,active:x.type==="knowledge",onClick:()=>g({type:"knowledge"})})]}),l.jsxs("div",{className:"mt-4",children:[l.jsx("div",{className:"px-4 py-1 text-[9px] font-bold tracking-widest",style:{color:"var(--terminal-text-muted)"},children:"TEAM"}),E.map(I=>{var W;const H=n[I.id],X=a.find(ie=>ie.roleId===I.id),A=ys[I.id]??"#666",$=(W=u[I.id])==null?void 0:W.level,q=x.type==="role"&&x.roleId===I.id;return l.jsxs("button",{onClick:()=>g({type:"role",roleId:I.id}),className:"flex items-center gap-2.5 w-full px-4 py-1.5 text-left hover:opacity-80 transition-all",style:{background:q?`${A}18`:"transparent",borderLeft:q?`2px solid ${A}`:"2px solid transparent"},children:[l.jsxs("div",{className:"relative shrink-0",style:{width:22,height:22},children:[l.jsx(Vl,{roleId:I.id,appearance:f(I.id),scale:1.3}),l.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 w-2 h-2 rounded-full",style:{background:H==="working"?"#4CAF50":H==="idle"?"#FFC107":"#9E9E9E",border:"1.5px solid var(--terminal-surface, #1a1510)"}})]}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"text-[11px] truncate",style:{color:"var(--terminal-text, #fff5eb)"},children:[I.name,$!=null&&l.jsxs("span",{className:"ml-1 opacity-40 text-[8px]",children:["Lv.",$]})]}),X?l.jsx("div",{className:"text-[9px] truncate",style:{color:A},children:X.task.slice(0,28)}):l.jsx("div",{className:"text-[9px]",style:{color:"var(--terminal-text-muted, #887766)"},children:I.level==="c-level"?I.id.toUpperCase():I.id})]}),H==="working"&&l.jsx("span",{className:"w-1.5 h-1.5 rounded-full animate-pulse shrink-0",style:{background:A}})]},I.id)})]}),l.jsx("div",{className:"flex-1"}),a.length>0&&l.jsxs("div",{className:"shrink-0 px-3 pb-2",style:{borderTop:"1px solid var(--terminal-border, #2E261F)"},children:[l.jsxs("div",{className:"px-1 py-1.5 text-[8px] font-bold tracking-widest",style:{color:"var(--terminal-text-muted)"},children:["ACTIVE JOBS (",a.length,")"]}),l.jsx("div",{className:"space-y-0.5 max-h-[140px] overflow-y-auto",children:a.map(I=>{const H=e.find($=>$.id===I.roleId),X=ys[I.roleId]??"#666",A=x.type==="role"&&x.roleId===I.roleId;return l.jsxs("button",{onClick:()=>g({type:"role",roleId:I.roleId}),className:"flex items-center gap-2 w-full px-2 py-1.5 rounded text-left hover:opacity-80 transition-all",style:{background:A?`${X}18`:"transparent"},children:[l.jsx("span",{className:"w-1.5 h-1.5 rounded-full animate-pulse shrink-0",style:{background:X}}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"text-[10px] truncate",style:{color:"var(--terminal-text, #fff5eb)"},children:(H==null?void 0:H.name)??I.roleId}),l.jsx("div",{className:"text-[8px] truncate",style:{color:"var(--terminal-text-muted)"},children:I.task.slice(0,40)})]})]},I.jobId??I.roleId)})})]}),l.jsx("div",{className:"px-3 py-3 shrink-0",style:{borderTop:"1px solid var(--terminal-border, #2E261F)"},children:l.jsxs("button",{onClick:v,className:"flex items-center gap-2 w-full px-3 py-2.5 rounded-lg hover:opacity-80 transition-opacity",style:{background:"var(--terminal-border, #2E261F)",color:"var(--terminal-text, #fff5eb)"},children:[l.jsx("span",{className:"text-[12px]",children:"🏢"}),l.jsx("span",{className:"text-[11px] font-medium",children:"Office"})]})})]}),l.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[l.jsxs("div",{className:"px-5 py-3 flex items-center gap-3 shrink-0",style:{borderBottom:"1px solid var(--terminal-border, #2E261F)"},children:[x.type==="role"&&R&&l.jsxs("button",{onClick:()=>k(I=>!I),className:"relative shrink-0 rounded-lg overflow-hidden hover:opacity-80 transition-opacity cursor-pointer",style:{width:28,height:28,background:`${ys[R.id]??"#666"}30`},title:"View profile",children:[l.jsx(Vl,{roleId:R.id,appearance:f(R.id),scale:1.5}),l.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 w-2.5 h-2.5 rounded-full",style:{background:n[R.id]==="working"?"#4CAF50":n[R.id]==="idle"?"#FFC107":"#9E9E9E",border:"2px solid var(--terminal-bg, #1C1612)"}})]}),l.jsx("span",{className:"text-[15px] font-semibold",style:{color:"var(--terminal-text, #fff5eb)"},children:L}),l.jsx("span",{className:"text-[10px]",style:{color:"var(--terminal-text-muted, #887766)"},children:F}),l.jsx("span",{className:"flex-1"}),x.type==="role"&&l.jsx("button",{onClick:()=>k(I=>!I),className:"text-[10px] px-2 py-1 rounded hover:opacity-80 transition-opacity",style:{color:j?"var(--terminal-text)":"var(--terminal-text-muted)",border:"1px solid var(--terminal-border)",background:j?"var(--terminal-border)":"transparent"},children:"Profile"}),x.type!=="dashboard"&&l.jsx("button",{onClick:()=>g({type:"dashboard"}),className:"text-[10px] px-2 py-1 rounded hover:opacity-80 transition-opacity",style:{color:"var(--terminal-text-muted)",border:"1px solid var(--terminal-border)"},children:"Dashboard"})]}),l.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[l.jsx("div",{className:"flex-1 overflow-hidden relative pro-panel-inline",children:b}),j&&x.type==="role"&&h&&l.jsx("div",{className:"shrink-0 overflow-hidden pro-panel-inline",style:{width:420,borderLeft:"1px solid var(--terminal-border, #2E261F)"},children:h(()=>k(!1))})]})]})]})}function M8({role:e,messages:n,isStreaming:a,mode:i,onModeChange:o,onSend:u,isWave:d}){const f=ys[e.id]??"#666";return l.jsxs("div",{className:"flex flex-col h-full",children:[l.jsx(yv,{messages:n,roleId:e.id,roleColor:f}),d?l.jsxs("div",{className:"shrink-0 px-4 py-2 border-t flex items-center gap-2",style:{borderColor:"var(--terminal-border)",background:"var(--terminal-bg-deeper)"},children:[l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 shrink-0",style:{animation:"pulse 2s infinite"}}),l.jsx("span",{className:"text-[11px] text-amber-400/80",children:"Wave execution · read-only"})]}):l.jsx(Qm,{mode:i,onModeChange:o,onSend:(m,h)=>u(m,i,h),disabled:a,disabledReason:a?`${e.id.toUpperCase()} is responding...`:void 0})]})}function R8({role:e,onSend:n,getAppearance:a,onOpenProfile:i}){const[o,u]=w.useState("talk"),d=ys[e.id]??"#666";return l.jsxs("div",{className:"flex flex-col h-full",children:[l.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4",children:[l.jsx("button",{onClick:i,className:"cursor-pointer hover:opacity-80 transition-opacity",children:l.jsx("div",{className:"rounded-lg p-1",style:{background:`${d}20`},children:l.jsx(Vl,{roleId:e.id,appearance:a(e.id),scale:5})})}),l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"text-sm font-semibold",style:{color:"var(--terminal-text)"},children:e.name}),l.jsxs("div",{className:"text-xs mt-0.5",style:{color:"var(--terminal-text-muted)"},children:[e.level==="c-level"?e.id.toUpperCase():e.id," · Start a conversation"]})]})]}),l.jsx(Qm,{mode:o,onModeChange:u,onSend:f=>n(f,o),disabled:!1})]})}function Tu({icon:e,label:n,active:a,badge:i,live:o,onClick:u}){return l.jsxs("button",{onClick:u,className:"flex flex-col items-center gap-1 py-3 rounded-lg transition-all hover:opacity-90",style:{background:a?"var(--desk-wood, #5C3D2E)":"var(--terminal-border, #2E261F)",border:a?"1px solid var(--desk-wood, #5C3D2E)":"1px solid transparent"},children:[l.jsxs("div",{className:"relative",children:[l.jsx("span",{className:"text-[16px]",children:e}),o&&l.jsx("span",{className:"absolute -top-1 -right-2 w-2 h-2 rounded-full animate-pulse",style:{background:"#EF4444"}}),i!==void 0&&i>0&&!o&&l.jsx("span",{className:"absolute -top-1.5 -right-3 text-[7px] px-1 py-0.5 rounded-full font-bold leading-none",style:{background:"var(--desk-wood, #5C3D2E)",color:"#fff",minWidth:14,textAlign:"center"},children:i})]}),l.jsx("span",{className:"text-[10px] font-semibold",style:{color:a?"#fff":"var(--terminal-text, #fff5eb)"},children:n})]})}function z8({roles:e,roleStatuses:n,activeExecs:a,waves:i,knowledgeDocs:o,roleLevels:u,getAppearance:d,onRoleClick:f,onWaveClick:m,onKnowledgeClick:h}){const x=e.filter(g=>n[g.id]==="working");return l.jsx("div",{className:"h-full overflow-y-auto px-6 py-5",children:l.jsxs("div",{className:"space-y-5 max-w-4xl",children:[l.jsxs("div",{className:"flex gap-3",children:[l.jsx(by,{label:"New Wave",icon:"⚡",color:"#EF4444",onClick:m}),l.jsx(by,{label:"Knowledge",icon:"📚",color:"#0D9488",onClick:h})]}),x.length>0&&l.jsx(Fu,{title:"Currently Working",count:x.length,children:a.map(g=>{const v=e.find(j=>j.id===g.roleId),b=ys[g.roleId]??"#666";return l.jsxs("button",{onClick:()=>f(g.roleId),className:"flex items-center gap-3 px-4 py-2.5 rounded hover:opacity-80 w-full text-left",style:{background:`${b}10`},children:[l.jsx("div",{className:"shrink-0",style:{width:24,height:24},children:l.jsx(Vl,{roleId:g.roleId,appearance:d(g.roleId),scale:1.2})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"text-[12px] font-medium",style:{color:b},children:v==null?void 0:v.name}),l.jsx("span",{className:"text-[11px] ml-2 truncate",style:{color:"var(--terminal-text-muted)"},children:g.task.slice(0,60)})]}),l.jsx("span",{className:"text-[10px] animate-pulse",style:{color:b},children:"●"})]},g.roleId)})}),l.jsx(Fu,{title:"Team",count:e.length,children:l.jsx("div",{className:"grid grid-cols-3 gap-1 px-2",children:e.map(g=>{var j;const v=n[g.id]??"offline",b=(j=u[g.id])==null?void 0:j.level;return l.jsxs("button",{onClick:()=>f(g.id),className:"flex items-center gap-2 px-3 py-2 rounded hover:opacity-80 text-left",children:[l.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:v==="working"?"#4CAF50":v==="idle"?"#FFC107":"#9E9E9E"}}),l.jsx("span",{className:"text-[11px] truncate",style:{color:"var(--terminal-text)"},children:g.name}),b!=null&&l.jsxs("span",{className:"text-[9px] opacity-40",children:["Lv.",b]})]},g.id)})})}),i.length>0&&l.jsx(Fu,{title:"Recent Waves",count:i.length,children:i.slice(0,5).map(g=>{var v;return l.jsxs("div",{className:"px-4 py-2 text-[11px]",style:{color:"var(--terminal-text-muted)"},children:[l.jsxs("span",{style:{color:"var(--terminal-text)"},children:["Wave ",g.id]})," — ",(v=g.directive)==null?void 0:v.slice(0,80)]},g.id)})}),l.jsx(Fu,{title:"Knowledge Base",count:o.length,children:l.jsxs("button",{onClick:h,className:"px-4 py-3 text-[11px] hover:opacity-80",style:{color:"var(--terminal-text-muted)"},children:[o.length," documents · Click to explore ","→"]})})]})})}function by({label:e,icon:n,color:a,onClick:i}){return l.jsxs("button",{onClick:i,className:"flex items-center gap-2 px-5 py-3 rounded-lg hover:opacity-80 transition-opacity",style:{background:`${a}15`,border:`1px solid ${a}30`},children:[l.jsx("span",{className:"text-sm",children:n}),l.jsx("span",{className:"text-[12px] font-medium",style:{color:a},children:e})]})}function Fu({title:e,count:n,children:a}){return l.jsxs("div",{className:"rounded-lg overflow-hidden",style:{background:"var(--terminal-surface, #241E19)",border:"1px solid var(--terminal-border, #2E261F)"},children:[l.jsxs("div",{className:"px-4 py-2.5 flex items-center gap-2",style:{borderBottom:"1px solid var(--terminal-border, #2E261F)"},children:[l.jsx("span",{className:"text-[10px] font-bold tracking-wider",style:{color:"var(--terminal-text-muted)"},children:e.toUpperCase()}),n!==void 0&&l.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full",style:{background:"var(--terminal-border)",color:"var(--terminal-text-muted)"},children:n})]}),l.jsx("div",{className:"py-1",children:a})]})}const wm=5e4;function _v(e){return e<wm?1:Math.max(1,Math.floor(Math.sqrt(e/wm)))}function vy(e){return wm*e*e}function _8(e){const n=_v(e),a=vy(n),i=vy(n+1);return Math.min(1,(e-a)/(i-a))}function Xh(e){const n={};for(const[a,i]of Object.entries(e)){const o=i.inputTokens+i.outputTokens;n[a]={level:_v(o),totalTokens:o,progress:_8(o)}}return n}const B8=[{id:"first-employee",name:"First Employee",icon:"🏆",description:"Hired your first role",check:e=>e.roleCount>=1},{id:"full-team",name:"Full Team",icon:"👥",description:"Hired 5+ roles",check:e=>e.roleCount>=5},{id:"token-10k",name:"Getting Started",icon:"📊",description:"Used 10K tokens total",check:e=>e.totalTokens>=1e4},{id:"token-100k",name:"Power User",icon:"💪",description:"Used 100K tokens total",check:e=>e.totalTokens>=1e5},{id:"token-millionaire",name:"Token Millionaire",icon:"🎖",description:"Used 1M tokens total",check:e=>e.totalTokens>=1e6},{id:"token-mogul",name:"Token Mogul",icon:"💎",description:"Used 10M tokens total",check:e=>e.totalTokens>=1e7},{id:"first-promotion",name:"First Promotion",icon:"⭐",description:"Any role reached Lv.3",check:e=>e.roles.some(n=>n.level>=3)},{id:"senior-staff",name:"Senior Staff",icon:"🌟",description:"Any role reached Lv.5",check:e=>e.roles.some(n=>n.level>=5)},{id:"master-class",name:"Master Class",icon:"👑",description:"Any role reached Lv.10",check:e=>e.roles.some(n=>n.level>=10)},{id:"full-house",name:"Full House",icon:"🏠",description:"All roles Lv.5+",check:e=>e.roleCount>=3&&e.roles.every(n=>n.level>=5)},{id:"first-launch",name:"First Launch",icon:"🚀",description:"Completed Chapter 2 — gave your first order",check:e=>{var n;return((n=e.completedQuests)==null?void 0:n.includes("ch2-q2"))??!1}},{id:"team-builder",name:"Team Builder",icon:"🏗️",description:"Completed Chapter 4 — dispatched your first wave",check:e=>{var n;return((n=e.completedQuests)==null?void 0:n.includes("ch4-q2"))??!1}},{id:"explorer",name:"Explorer",icon:"🔍",description:"Completed Chapter 5 — customized a character",check:e=>{var n;return((n=e.completedQuests)==null?void 0:n.includes("ch5-q2"))??!1}},{id:"interior-designer",name:"Interior Designer",icon:"🎨",description:"Completed Chapter 7 — bought premium furniture",check:e=>{var n;return((n=e.completedQuests)==null?void 0:n.includes("ch7-q2"))??!1}},{id:"tycoon-master",name:"Tycoon Master",icon:"🎯",description:"Completed all 10 chapters",check:e=>{var n;return((n=e.completedQuests)==null?void 0:n.includes("ch10-q3"))??!1}}];function wy(e){return B8.filter(n=>n.check(e))}const ky={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function O8({importJob:e,onImportDone:n}){var oc,cc,uc,Bs,dc;const[a,i]=w.useState([]),[o,u]=w.useState([]),[d,f]=w.useState([]),[m,h]=w.useState([]),[x,g]=w.useState([]),[v,b]=w.useState([]),[j,k]=w.useState("TYCONO"),[N,E]=w.useState(!0),[C,_]=w.useState(null),[R,L]=w.useState({type:"none"}),[F,I]=w.useState(null),[H,X]=w.useState(null),[A,$]=w.useState([]),[q,W]=w.useState(!1),[ie,P]=w.useState(!1),[Y,oe]=w.useState([]),[de,G]=w.useState([]),[D,B]=w.useState(0),[U,T]=w.useState(!1),[se,ge]=w.useState({}),[pe,Re]=w.useState("ceo"),[Ie,He]=w.useState(null),[ot,Je]=w.useState(!1),[tt,Ee]=w.useState(!1),[Ae,yt]=w.useState({}),dt=w.useRef({}),[xt,jt]=w.useState(!1),[Wt,Tt]=w.useState(null),[Ct,Bn]=w.useState({}),[me,Se]=w.useState([]),Ne=w.useMemo(()=>{const M={};for(const Q of me)M[Q.roleId]=Q;return M},[me]),[K,ue]=w.useState([]),[ne,ve]=w.useState(0),[we,ze]=w.useState(Yg()),_e=w.useRef(Yg()),Be=w.useRef(!1),qe=w.useRef(-1),[at,Ke]=w.useState(null),bt=w.useRef(null),[Me,Ue]=w.useState(void 0),[_t,Bt]=w.useState(!1);w.useEffect(()=>{ye.getStatus().then(M=>{Ue(M.engine),Bt(!!M.hasApiKey)}).catch(()=>{})},[]);const{getAppearance:Ot,setAppearance:un,resetAppearance:kn,theme:J,setTheme:Oe,speechSettings:rt,setSpeechSettings:Kt,language:ke,setLanguage:kt,purchasedItems:jn,addPurchasedItem:hn}=O6(),[te,$e]=w.useState(null),[,We]=w.useState("character"),Pe=I6(),[Sn,Wn]=w.useState(!1),[yn,mn]=w.useState(!1),[Or,Ql]=w.useState(!1),[Ds,Fi]=w.useState(!1),[Go,Fa]=w.useState(!1),[Ts,ca]=w.useState(!1),[Ma,Ra]=w.useState(!1),[Vn,Dn]=w.useState(null);w.useEffect(()=>{Pe.refresh()},[]),w.useEffect(()=>{const M=Q=>{(Q.metaKey||Q.ctrlKey)&&Q.key==="s"&&(Q.preventDefault(),Wn(!0))};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[]),w.useEffect(()=>{if(!Ds)return;let M=!1;const Q=async()=>{try{const he=await ye.getGitStatus();M||Dn(he)}catch{}};Q();const re=setInterval(Q,1e4);return()=>{M=!0,clearInterval(re)}},[Ds]);const[za,Mi]=w.useState(null),[fr,jr]=w.useState(null),[ol,Fs]=w.useState([]),[_a,Ko]=w.useState(!1),Zl=w.useRef(!1),cl=w.useRef(null);let $r=w.useRef(0);const lr=w.useRef(new Set),Po=w.useRef(Date.now()),Ba=(M,Q,re)=>{const he={id:$r.current++,type:M,text:Q,detail:re};Fs(je=>[...je,he])};w.useEffect(()=>{var M;_a&&((M=cl.current)==null||M.scrollIntoView({behavior:"smooth"}))},[ol,_a]),w.useEffect(()=>{e&&(Zl.current||(Zl.current=!0,jr("Scanning knowledge sources..."),Fs([{id:0,type:"scan",text:"Starting knowledge import..."}]),$r.current=1,fetch("/api/setup/import-knowledge",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paths:e.paths,companyRoot:e.companyRoot})}).then(async M=>{var je;const Q=(je=M.body)==null?void 0:je.getReader();if(!Q)return;const re=new TextDecoder;let he="";for(;;){const{done:Le,value:It}=await Q.read();if(Le)break;he+=re.decode(It,{stream:!0});const ft=he.split(`
|
|
93
|
+
`);he=ft.pop()||"";let Ze="";for(const Ge of ft)if(Ge.startsWith("event: "))Ze=Ge.slice(7).trim();else if(Ge.startsWith("data: ")&&Ze){try{const mt=JSON.parse(Ge.slice(6));switch(Ze){case"scanning":jr(`Scanning: ${mt.path} (${mt.fileCount} files)`),Ba("scan",`Found ${mt.fileCount} files`,mt.path);break;case"processing":Mi({index:mt.index,total:mt.total}),jr(`Importing knowledge... (${mt.index}/${mt.total})`),Ba("process",`Processing: ${mt.file}`,`${mt.index} / ${mt.total}`);break;case"created":Ba("created",mt.title,mt.summary);break;case"skipped":Ba("process",`Skipped: ${mt.file}`,mt.reason);break;case"done":jr(null),Mi(null),Ba("done",`Import complete! ${mt.created} created, ${mt.skipped} skipped.`),Et(`Knowledge import complete! ${mt.created} documents imported.`,"#2E7D32"),n==null||n();break;case"error":jr(null),Mi(null),Ba("error",mt.message),Et(`Import failed: ${mt.message}`,"#B71C1C"),n==null||n();break}}catch{}Ze=""}}}).catch(M=>{jr(null),Ba("error",M.message),Et(`Import error: ${M.message}`,"#B71C1C"),n==null||n()})))},[e]);const[Lr,Ir]=w.useState("iso"),Sr=w.useRef("iso"),[ea,Pt]=w.useState({type:"dashboard"}),[Ri,Qo]=w.useState(typeof window<"u"?window.innerWidth:1200);w.useEffect(()=>{const M=()=>Qo(window.innerWidth);return window.addEventListener("resize",M),()=>window.removeEventListener("resize",M)},[]);const Jl=Ri<1024,[Gn,Oa]=w.useState(!1),[ua,ul]=w.useState(560),[Un,an]=w.useState([]),[ta,qn]=w.useState(null),[da,$a]=w.useState(null),{sendMessage:zi}=z6(),hr=w.useRef(new Map);w.useEffect(()=>{Promise.all([ye.getCompany().then(M=>{k(M.name),i(M.roles)}),ye.getOrgTree().then(M=>{ge(M.nodes),Re(M.root)}).catch(()=>{}),ye.getCostSummary().then(M=>fl(Xh(M.byRole))).catch(()=>{})]).catch(M=>_(`Failed to load: ${M.message}`)).finally(()=>E(!1)),ye.getProjects().then(u).catch(()=>{}),ye.getStandups().then(f).catch(()=>{}),ye.getWaves().then(h).catch(()=>{}),ye.getDecisions().then(g).catch(()=>{}),ye.getKnowledge().then(b).catch(()=>{}),ye.getQuestProgress().then(M=>{const Q=Xg(M);Q.activeChapter!==M.activeChapter&&ye.saveQuestProgress(Q).catch(()=>{}),ze(Q),_e.current=Q,Be.current=!0,ye.getCoins().then(re=>{var he;re.totalEarned===0?ye.migrateCoins(((he=Q.completedQuests)==null?void 0:he.length)??0).then(je=>ve(je.balance)).catch(()=>{}):ve(re.balance)}).catch(()=>{})}).catch(()=>{Be.current=!0})},[]),w.useEffect(()=>{if(qe.current===-1){qe.current=o.length;return}o.length>qe.current&&ln({type:"project_created"}),qe.current=o.length},[o.length]);const _i=w.useRef(!1);w.useEffect(()=>{if(!(!Be.current||a.length===0||_i.current)){_i.current=!0;for(const M of a)ln({type:"role_hired",condition:{roleId:M.id,roleCount:a.length}})}},[a.length]),w.useEffect(()=>{ye.getSessions().then(M=>{const Q=M.filter(he=>he.source!=="wave");if(Q.length>0){const he=Q.map(Le=>({...Le,messages:[]}));an(he);const je=he.find(Le=>Le.status==="active")??he[0];qn(je.id),dl()}const re=M.filter(he=>he.source==="wave").map(he=>he.id);re.length>0&&ye.deleteSessions(re).catch(()=>{})}).catch(M=>{console.error("Failed to load sessions",M)})},[]),w.useEffect(()=>{const M=()=>{fetch("/api/exec/status").then(re=>re.json()).then(re=>{Bn(re.statuses??{}),Se(re.activeExecutions??[])}).catch(()=>{})};M();const Q=setInterval(M,3e3);return()=>clearInterval(Q)},[]);const fa=w.useMemo(()=>{const M={...Ct};if(da){const Q=Un.find(re=>re.id===da);Q&&(M[Q.roleId]="working")}return M},[Ct,da,Un]);w.useEffect(()=>{R.type==="role"?ye.getRole(R.roleId).then(I).catch(console.error):I(null)},[R]);const mr=()=>L({type:"none"}),La=async(M,Q)=>{const re=await ye.updateDecision(M,Q);g(he=>he.map(je=>je.id===M?re:je))},Ms=async M=>{await ye.deleteDecision(M),g(Q=>Q.filter(re=>re.id!==M))},Kn=M=>{L(M),Oa(!1),P(!1)},dl=()=>{Oa(!0),L({type:"none"}),P(!1)},ha=()=>{Sr.current="iso",Pt({type:"wave"}),Ir("pro"),P(!0),Oa(!1),L({type:"none"})},na=async(M,Q)=>{const re=a.find(je=>je.id===M),he=(H==null?void 0:H.mode)==="ask";X(null);try{const je=await ye.startJob({type:"assign",roleId:M,task:Q,readOnly:he}),Le=je.jobId,It=je.sessionId??`job-${Le}`,ft=ky[M]??"#666",Ze=`${M.toUpperCase()} · ${(re==null?void 0:re.name)??M}`;T(!1),$([{sessionId:It,jobId:Le,title:Ze,color:ft}]),ln({type:"task_executed",condition:{roleId:M}}),Jt.pushMessage({ts:Date.now(),roleId:"ceo",text:`[CEO → ${(re==null?void 0:re.name)??M}] ${he?"Ask":"Assign"}: ${Q}`,type:"dispatch",targetRoleId:M})}catch(je){Et(`Failed to start job: ${je instanceof Error?je.message:"unknown"}`,"#C62828")}},Rs=w.useRef(0),Et=(M,Q)=>{const re=++Rs.current;ue(he=>[...he,{id:re,message:M,color:Q}]),setTimeout(()=>ue(he=>he.filter(je=>je.id!==re)),4e3)},ma=M=>{bt.current&&clearTimeout(bt.current),Ke(M),bt.current=setTimeout(()=>Ke(null),8e3)},ln=M=>{if(!Be.current)return;let Q=_e.current;const re=cv(Q);let he=0;const je=[];for(const It of re){if(!BN(It,M))continue;const{progress:ft,quest:Ze}=zN(Q,It.id);Ze&&(Q=ft,he+=Ze.rewards.coins??0,je.push(Ze.title))}if(je.length===0)return;Q=Xg(Q),_e.current=Q,ze(Q);const Le=he>0?` 💰 +${he.toLocaleString()}`:"";je.length===1?Et(`📋 Quest complete: ${je[0]}${Le}`,"#7C3AED"):Et(`📋 ${je.length} quests complete!${Le}`,"#7C3AED"),Ke(null),ye.saveQuestProgress(Q).catch(()=>{}),he>0&&ye.earnCoins(he,`quests: ${je.length}`,je.join(",")).then(It=>ve(It.balance)).catch(()=>{})};w.useEffect(()=>{if(!at)return;const M=document.querySelector(`[data-quest-target="${at}"]`);if(!M)return;M.classList.add("quest-spotlight");const Q=()=>{M.classList.remove("quest-spotlight"),Ke(null),bt.current&&clearTimeout(bt.current)};return M.addEventListener("click",Q,{once:!0}),()=>{M.classList.remove("quest-spotlight"),M.removeEventListener("click",Q)}},[at]);const fl=M=>{var re,he;const Q=dt.current;for(const[je,Le]of Object.entries(M)){const It=((re=Q[je])==null?void 0:re.level)??0;if(It>0&&Le.level>It){const ft=((he=a.find(Ze=>Ze.id===je))==null?void 0:he.name)??je.toUpperCase();Et(`${ft} leveled up to Lv.${Le.level}!`,"#7C3AED")}}dt.current=M,yt(M)};w.useEffect(()=>{const M={roles:Object.entries(Ae).map(([je,Le])=>({id:je,level:Le.level,totalTokens:Le.totalTokens})),totalTokens:Object.values(Ae).reduce((je,Le)=>je+Le.totalTokens,0),roleCount:a.length,completedQuests:we.completedQuests},Q=wy(M),re=new Set(Q.map(je=>je.id));if(Date.now()-Po.current>5e3){const je=lr.current;for(const Le of Q)je.has(Le.id)||Et(`${Le.icon} Badge earned: ${Le.name}!`,"#D4A017")}lr.current=re},[Ae,a.length,we.completedQuests]);const hl=w.useMemo(()=>RN(we),[we]),Bi=()=>{var Q;const M=A[A.length-1];M&&(Et(`${M.title} completed`,M.color),Jt.pushMessage({ts:Date.now(),roleId:((Q=M.title.split(" · ")[0])==null?void 0:Q.toLowerCase())??"unknown",text:`[${M.title}] Job completed`,type:"dispatch"})),ye.getStandups().then(f).catch(console.error),ye.getCompany().then(re=>i(re.roles)).catch(console.error),ye.getCostSummary().then(re=>fl(Xh(re.byRole))).catch(()=>{})},pa=w.useRef(new Map),Zo=M=>{if(pa.current.has(M))return;const Q=new AbortController;pa.current.set(M,Q),$a(re=>re??M),fetch(`/api/sessions/${M}/stream?from=0`,{signal:Q.signal}).then(async re=>{var It,ft;if(!re.ok||!re.body)return;const he=re.body.getReader(),je=new TextDecoder;let Le="";for(;;){const{done:Ze,value:Ge}=await he.read();if(Ze)break;Le+=je.decode(Ge,{stream:!0});const mt=Le.split(`
|
|
94
|
+
`);Le=mt.pop()??"";let Ft="";for(const xl of mt)if(xl.startsWith("event: "))Ft=xl.slice(7).trim();else if(xl.startsWith("data: ")){try{const sr=JSON.parse(xl.slice(6));Ft==="stream:end"?(an(ct=>ct.map($t=>{if($t.id!==M)return $t;const pn=$t.messages.map(dn=>dn.status==="streaming"?{...dn,status:"done"}:dn);return{...$t,messages:pn}})),$a(ct=>ct===M?null:ct),pa.current.delete(M)):Ft==="activity"&&(sr.type==="text"&&((It=sr.data)!=null&&It.text)?an(ct=>ct.map($t=>{if($t.id!==M)return $t;const pn=[...$t.messages],dn=pn[pn.length-1];return(dn==null?void 0:dn.from)==="role"&&dn.status==="streaming"&&(pn[pn.length-1]={...dn,content:dn.content+sr.data.text}),{...$t,messages:pn}})):sr.type==="thinking"&&((ft=sr.data)!=null&&ft.text)?an(ct=>ct.map($t=>{if($t.id!==M)return $t;const pn=[...$t.messages],dn=pn[pn.length-1];return(dn==null?void 0:dn.from)==="role"&&dn.status==="streaming"&&(pn[pn.length-1]={...dn,thinking:(dn.thinking??"")+sr.data.text}),{...$t,messages:pn}})):(sr.type==="job:done"||sr.type==="job:error")&&(an(ct=>ct.map($t=>{if($t.id!==M)return $t;const pn=$t.messages.map(dn=>dn.status==="streaming"?{...dn,status:sr.type==="job:done"?"done":"error"}:dn);return{...$t,messages:pn}})),$a(ct=>ct===M?null:ct),pa.current.delete(M)))}catch{}Ft=""}}}).catch(()=>{pa.current.delete(M),$a(re=>re===M?null:re)})},Yn=async(M,Q,re)=>{W(!1);try{const he=await ye.startJob({type:"wave",directive:M,targetRoles:Q,...re&&{attachments:re}});ln({type:"wave_dispatched"});const je=he.jobIds??(he.jobId?[he.jobId]:[]),Le=pe&&se[pe]?se[pe].children.map(ct=>a.find($t=>$t.id===ct)).filter(ct=>!!ct):a.filter(ct=>ct.level==="c-level"),It=Q?Le.filter(ct=>Q.includes(ct.id)):Le,ft=he.waveId??`wave-${Date.now()}`,Ze=he.sessionIds??[],Ge=je.map((ct,$t)=>{var pn,dn;return{jobId:ct,roleId:((pn=It[$t])==null?void 0:pn.id)??`role-${$t}`,roleName:((dn=It[$t])==null?void 0:dn.name)??`C-Level ${$t+1}`,sessionId:Ze[$t]??`wave-${ct}`}});Jt.pushMessage({ts:Date.now(),roleId:"ceo",text:`[CEO WAVE] "${M}" → ${Ge.map(ct=>ct.roleName).join(", ")}`,type:"dispatch"});const mt={id:ft,directive:M,rootJobs:Ge,startedAt:Date.now(),sessionIds:Ze};oe(ct=>[mt,...ct]),ha();const Ft=new Date().toISOString(),sr=(Ze.length>0?Ge.map((ct,$t)=>({id:Ze[$t]??`wave-${ct.jobId}`,roleId:ct.roleId,title:`WAVE: ${ct.roleName}`,mode:"do",source:"wave",jobId:ct.jobId,messages:[{id:`msg-wave-${ct.jobId}-ceo`,from:"ceo",content:M,type:"directive",status:"done",timestamp:Ft}],status:"active",createdAt:Ft,updatedAt:Ft})):Ge.map(ct=>({id:`wave-${ct.jobId}`,roleId:ct.roleId,title:`WAVE: ${ct.roleName}`,mode:"do",source:"wave",jobId:ct.jobId,messages:[{id:`msg-wave-${ct.jobId}-ceo`,from:"ceo",content:M,type:"directive",status:"done",timestamp:Ft}],status:"active",createdAt:Ft,updatedAt:Ft}))).map((ct,$t)=>({...ct,messages:[...ct.messages,{id:`msg-wave-${Ge[$t].jobId}-role`,from:"role",content:"",type:"conversation",status:"streaming",timestamp:Ft,jobId:Ge[$t].jobId}]}));an(ct=>[...sr,...ct]);for(const ct of sr)Zo(ct.id)}catch(he){Et(`Failed to start wave: ${he instanceof Error?he.message:"unknown"}`,"#C62828")}},ir=()=>{ye.getWaves().then(h).catch(console.error),ye.getStandups().then(f).catch(console.error)},ml=()=>{ye.getCompany().then(M=>i(M.roles)).catch(console.error),ye.getOrgTree().then(M=>{ge(M.nodes),Re(M.root)}).catch(console.error),ye.getCostSummary().then(M=>fl(Xh(M.byRole))).catch(()=>{})},ei=async(M,Q)=>{await ye.createRole(M),un(M.id,Q),ml(),Et(`${M.name} hired!`,"#2E7D32"),ln({type:"role_hired",condition:{roleId:M.id,roleCount:a.length+1}})},rd=async M=>{var Q;await ye.deleteRole(M),ml(),an(re=>re.filter(he=>he.roleId!==M)),ta&&((Q=Un.find(re=>re.id===ta))==null?void 0:Q.roleId)===M&&qn(null),Tt(null),Et(`${M.toUpperCase()} removed`,"#B71C1C")},ti=async(M,Q)=>{await ye.updateRole(M,Q),ml(),R.type==="role"&&R.roleId===M&&ye.getRole(M).then(I).catch(console.error),Q.name&&Et(`${M.toUpperCase()} renamed to "${Q.name}"`,"#1565C0"),Q.persona!==void 0&&(Et(`${M.toUpperCase()} persona updated`,"#2E7D32"),ln({type:"persona_updated"}))},zs=M=>{dl(),ln({type:"terminal_opened"})},pl=async M=>{try{const Q=await ye.createSession(M,"talk");an(re=>[Q,...re]),qn(Q.id),dl()}catch(Q){console.error("Failed to create session",Q),Et(`Failed to create session: ${Q instanceof Error?Q.message:"API unreachable"}`,"#B71C1C")}},ni=async M=>{try{const Q=await ye.createSession(M,"talk");an(re=>[Q,...re]),qn(Q.id)}catch(Q){console.error("Failed to create session",Q),Et(`Failed to create session: ${Q instanceof Error?Q.message:"API unreachable"}`,"#B71C1C")}},Jo=async M=>{const Q=Ne[M],re=(Q==null?void 0:Q.jobId)??(Q==null?void 0:Q.id);if(re&&fa[M]==="working"){const je=a.find(Ge=>Ge.id===M),Le=ky[M]??"#666",It=`${M.toUpperCase()} · ${(je==null?void 0:je.name)??M}`,ft=Un.find(Ge=>Ge.roleId===M&&Ge.status==="active"),Ze=(ft==null?void 0:ft.id)??`job-${re}`;$([{sessionId:Ze,jobId:re,title:It,color:Le}]),T(!1);return}const he=Un.find(je=>je.roleId===M);if(he)qn(he.id),Jt.setActiveChannelId(null);else try{const je=await ye.createSession(M,"talk");an(Le=>[je,...Le]),qn(je.id),Jt.setActiveChannelId(null)}catch(je){console.error("Failed to create session",je)}dl()},ec=async M=>{const Q=Un.find(re=>re.id===M);if((Q==null?void 0:Q.source)==="wave"){if(Q.jobId){const re=hr.current.get(Q.jobId);re&&(re.abort(),hr.current.delete(Q.jobId))}an(re=>{var je;const he=re.filter(Le=>Le.id!==M);return ta===M&&qn(((je=he[0])==null?void 0:je.id)??null),he});return}try{await ye.deleteSession(M),an(re=>{var je;const he=re.filter(Le=>Le.id!==M);return ta===M&&qn(((je=he[0])==null?void 0:je.id)??null),he})}catch(re){console.error("Failed to delete session",re),Et(`Failed to close session: ${re instanceof Error?re.message:"API error"}`,"#B71C1C")}},tc=async()=>{try{const{ids:M}=await ye.deleteEmptySessions();if(M.length===0)return;an(Q=>{var he;const re=Q.filter(je=>!M.includes(je.id));return ta&&M.includes(ta)&&qn(((he=re[0])==null?void 0:he.id)??null),re}),Et(`Cleared ${M.length} empty session${M.length!==1?"s":""}`,"#2E7D32")}catch(M){Et(`Failed to clear empty sessions: ${M instanceof Error?M.message:"API error"}`,"#B71C1C")}},nc=async()=>{if(!confirm("Close all sessions? This cannot be undone."))return;const M=Un.filter(Q=>Q.source!=="wave").map(Q=>Q.id);for(const Q of Un)if(Q.source==="wave"&&Q.jobId){const re=hr.current.get(Q.jobId);re&&(re.abort(),hr.current.delete(Q.jobId))}try{M.length>0&&await ye.deleteSessions(M),an([]),qn(null),Et("All sessions closed","#2E7D32")}catch(Q){Et(`Failed to close sessions: ${Q instanceof Error?Q.message:"API error"}`,"#B71C1C")}},Hr=(M,Q)=>{an(re=>re.map(he=>{if(he.id!==M)return he;const je=[...he.messages],Le=je[je.length-1];if(Le&&Le.from==="role"&&Le.status==="streaming"){const It=[...Le.streamEvents??[],Q];je[je.length-1]={...Le,streamEvents:It}}return{...he,messages:je}}))},Ia=(M,Q,re,he)=>{const je={id:`msg-${Date.now()}-ceo`,from:"ceo",content:Q,type:re==="do"?"directive":"conversation",status:"done",timestamp:new Date().toISOString(),attachments:he},Le={id:`msg-${Date.now()+1}-role`,from:"role",content:"",type:"conversation",status:"streaming",timestamp:new Date().toISOString(),streamEvents:[]};an(ft=>ft.map(Ze=>Ze.id===M?{...Ze,messages:[...Ze.messages,je,Le],updatedAt:new Date().toISOString()}:Ze));const It=Un.find(ft=>ft.id===M);re==="talk"?ln({type:"talk_mode_used"}):re==="do"&&(ln({type:"do_mode_used"}),It&&ln({type:"task_executed",condition:{roleId:It.roleId}})),$a(M),zi(M,Q,re,{onThinking:ft=>{an(Ze=>Ze.map(Ge=>{if(Ge.id!==M)return Ge;const mt=[...Ge.messages],Ft=mt[mt.length-1];return Ft&&Ft.from==="role"&&Ft.status==="streaming"&&(mt[mt.length-1]={...Ft,thinking:(Ft.thinking??"")+ft}),{...Ge,messages:mt}})),Hr(M,{type:"thinking",timestamp:Date.now(),text:ft})},onText:ft=>{an(Ze=>Ze.map(Ge=>{if(Ge.id!==M)return Ge;const mt=[...Ge.messages],Ft=mt[mt.length-1];return Ft&&Ft.from==="role"&&Ft.status==="streaming"&&(mt[mt.length-1]={...Ft,content:Ft.content+ft}),{...Ge,messages:mt}}))},onToolUse:(ft,Ze)=>{Hr(M,{type:"tool",timestamp:Date.now(),toolName:ft,toolInput:Ze})},onDispatch:(ft,Ze)=>{Hr(M,{type:"dispatch",timestamp:Date.now(),roleId:ft,task:Ze})},onDispatchProgress:(ft,Ze,Ge)=>{var mt;Ze==="tool"?Hr(M,{type:"dispatch:progress",timestamp:Date.now(),roleId:ft,progressType:"tool",toolName:Ge.name,toolInput:Ge.input}):Ze==="thinking"?Hr(M,{type:"dispatch:progress",timestamp:Date.now(),roleId:ft,progressType:"thinking",text:Ge.text}):Ze==="text"?Hr(M,{type:"dispatch:progress",timestamp:Date.now(),roleId:ft,progressType:"text",text:(mt=Ge.text)==null?void 0:mt.slice(-200)}):(Ze==="done"||Ze==="error")&&Hr(M,{type:"dispatch:progress",timestamp:Date.now(),roleId:ft,progressType:Ze})},onTurn:ft=>{Hr(M,{type:"turn",timestamp:Date.now(),turn:ft})},onDone:()=>{an(ft=>ft.map(Ze=>{if(Ze.id!==M)return Ze;const Ge=Ze.messages.map(Ft=>Ft.status==="streaming"?{...Ft,status:"done"}:Ft),mt=Ze.messages.length<=2?Q.slice(0,40).replace(/\n/g," "):Ze.title;return{...Ze,messages:Ge,title:mt}})),$a(null)},onError:ft=>{an(Ze=>Ze.map(Ge=>{if(Ge.id!==M)return Ge;const mt=Ge.messages.map(Ft=>Ft.status==="streaming"?{...Ft,status:"error",content:Ft.content||ft}:Ft);return{...Ge,messages:mt}})),$a(null)}},he)},_s=(M,Q)=>{an(re=>re.map(he=>he.id===M?{...he,mode:Q}:he)),ye.updateSession(M,{mode:Q}).catch(console.error)},ad=new Date().toISOString().slice(0,10),rc=o[0],ac={cto:"Chief Technology Officer",cbo:"Chief Business Officer",pm:"Product Manager",engineer:"Software Engineer",designer:"UI/UX Designer",qa:"QA Engineer"},lc=M=>{const Q=ac[M];if(!Q)return"";for(const re of d){const he=re.content,je=he.indexOf(`## ${Q}`);if(je===-1)continue;const Le=he.indexOf(`
|
|
95
|
+
## `,je+10),ft=(Le===-1?he.slice(je):he.slice(je,Le)).split(`
|
|
96
|
+
`).filter(Ze=>Ze.trim().length>0);for(const Ze of ft){const Ge=Ze.replace(/^#+\s*/,"").replace(/\*\*/g,"").replace(/^[-*]\s+/,"").trim();if(!(Ge.startsWith("|")||Ge.startsWith("{")||Ge.startsWith("[")||Ge.startsWith("```")||Ge.startsWith("---")||Ge.includes("Journal")||Ge.includes("(c-level)")||Ge.includes("(team-lead)")||Ge.includes("(member)")||/^(CEO |작업 결과|생성\/수정|APPROVAL|비고|상황 보고|태스크$)/.test(Ge))&&Ge.length>15&&Ge.length<120)return Ge}}return""},ic=M=>{const Q=ac[M];if(!Q)return"";for(const re of d){const he=re.content,je=he.indexOf(`## ${Q}`);if(je===-1)continue;const Le=he.indexOf(`
|
|
97
|
+
## `,je+10),ft=(Le===-1?he.slice(je):he.slice(je,Le)).replace(/^## .+\n/,"").trim();if(ft)return ft.slice(0,1500)}return""},Jt=eA();w.useEffect(()=>{a.length>0&&Jt.syncDefaultMembers(a)},[a]);const Oi=K6({roles:a,roleStatuses:Ct,activeExecs:me,getStandupSpeech:lc}),sc=aA({roles:a,roleStatuses:Ct,activeExecs:me,channels:Jt.channels,relationships:Oi.relationships,pushMessage:Jt.pushMessage,speechSettings:rt,engineType:Me,hasApiKey:_t}),$i=w.useCallback((M,Q)=>{Jt.pushMessage({ts:Date.now(),roleId:"ceo",text:Q,type:"chat",channelId:M}),sc.triggerCeoReaction(M)},[Jt,sc]);return N?l.jsxs("div",{className:"h-screen flex flex-col bg-[var(--floor-light)]",style:{fontFamily:"var(--pixel-font)"},children:[(fr||ol.length>0)&&l.jsxs("div",{className:"shrink-0 z-[44]",children:[l.jsxs("div",{className:"flex items-center gap-3 px-5 py-2 text-xs cursor-pointer select-none",style:{background:"var(--accent)",color:"#fff",fontFamily:"var(--pixel-font)"},onClick:()=>Ko(M=>!M),children:[fr?l.jsx("div",{className:"w-3 h-3 border-2 border-white/40 border-t-white rounded-full animate-spin shrink-0"}):l.jsx("span",{className:"shrink-0",children:"✅"}),l.jsx("span",{className:"flex-1",children:fr||"Knowledge import finished"}),za&&l.jsx("div",{className:"w-24 h-1.5 rounded-full overflow-hidden shrink-0",style:{background:"rgba(255,255,255,0.3)"},children:l.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${za.index/za.total*100}%`,background:"#fff"}})}),l.jsx("span",{className:"text-[10px] opacity-70 shrink-0",children:_a?"▲":"▼"})]}),_a&&l.jsxs("div",{className:"overflow-y-auto text-xs",style:{background:"var(--terminal-bg)",borderBottom:"2px solid var(--accent)",maxHeight:240,fontFamily:"var(--pixel-font)"},children:[ol.map(M=>l.jsxs("div",{className:"flex items-start gap-2 px-5 py-1.5",style:{borderBottom:"1px solid var(--terminal-border)"},children:[l.jsxs("span",{className:"shrink-0 mt-0.5",style:{width:14,textAlign:"center"},children:[M.type==="scan"&&"🔍",M.type==="process"&&"⚙️",M.type==="created"&&"✅",M.type==="done"&&"🎉",M.type==="error"&&"❌"]}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{style:{color:M.type==="error"?"#EF4444":M.type==="done"?"var(--active-green)":"var(--terminal-text)"},children:M.text}),M.detail&&l.jsx("div",{className:"text-[10px] truncate",style:{color:"var(--terminal-text-muted)"},children:M.detail})]})]},M.id)),l.jsx("div",{ref:cl})]})]}),l.jsx("div",{className:"flex-1 flex items-center justify-center",children:l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"text-4xl mb-3",children:"🏢"}),l.jsx("div",{className:"text-gray-600 font-semibold text-xs",children:"LOADING OFFICE..."})]})})]}):C?l.jsx("div",{className:"h-screen flex items-center justify-center bg-[var(--floor-light)]",children:l.jsxs("div",{className:"text-center max-w-md",style:{fontFamily:"var(--pixel-font)"},children:[l.jsx("div",{className:"text-4xl mb-3",children:"⚠️"}),l.jsx("div",{className:"text-gray-800 font-semibold mb-2 text-xs",children:"CONNECTION ERROR"}),l.jsx("div",{className:"text-gray-500 text-xs mb-4",children:C}),l.jsx("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 bg-gray-800 text-white text-xs font-bold cursor-pointer border-2 border-gray-600",style:{fontFamily:"var(--pixel-font)"},children:"RETRY"})]})}):l.jsxs("div",{className:"flex flex-col",style:{height:"100dvh",fontFamily:"var(--pixel-font)"},children:[l.jsxs("div",{className:"flex items-center justify-between px-5 py-2 text-white text-sm shrink-0 z-[45]",style:{background:"var(--bar-bg, var(--hud-bg))",borderBottom:"3px solid var(--bar-border, var(--pixel-border))"},children:[l.jsxs("div",{className:"font-black text-[13px] tracking-tight",style:{color:"var(--idle-amber)",textShadow:"2px 2px 0 rgba(0,0,0,0.5)"},children:["🏢"," ",l.jsx("span",{style:{color:"var(--bar-text, var(--terminal-text))"},children:j})]}),l.jsxs("div",{className:"flex gap-4 text-[11px] items-center",style:{color:"var(--bar-text, var(--terminal-text-secondary))"},children:[(()=>{const M=ne>=1e6?`${(ne/1e6).toFixed(1)}M`:ne>=1e3?`${(ne/1e3).toFixed(1)}K`:String(ne),Q=me.length,re=a.length>0?Math.round(Q/a.length*100):0;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"hidden md:flex items-center gap-1",children:["💰",l.jsx("strong",{className:"text-[var(--active-green)]",children:M})]}),l.jsxs("div",{className:"hidden md:flex items-center gap-1",children:["⚡",l.jsx("div",{className:"w-[50px] h-2 bg-[#111] overflow-hidden",style:{border:"2px solid var(--pixel-border)"},children:l.jsx("div",{className:"h-full",style:{width:`${re}%`,background:"linear-gradient(90deg,#3b82f6,#60A5FA)"}})}),l.jsx("strong",{style:{color:"var(--bar-text, var(--terminal-text))"},children:re})]})]})})(),l.jsxs("span",{className:"hidden sm:inline",children:["Roles: ",l.jsx("strong",{style:{color:"var(--bar-text, var(--terminal-text))"},children:a.length})]}),l.jsxs("span",{className:"hidden sm:inline",children:["Projects: ",l.jsx("strong",{style:{color:"var(--bar-text, var(--terminal-text))"},children:o.length})]}),me.length>0&&l.jsxs("span",{className:"text-amber-400",children:["Working: ",l.jsx("strong",{children:me.length})]}),(()=>{const M={roles:Object.entries(Ae).map(([re,he])=>({id:re,level:he.level,totalTokens:he.totalTokens})),totalTokens:Object.values(Ae).reduce((re,he)=>re+he.totalTokens,0),roleCount:a.length},Q=wy(M);return Q.length>0?l.jsx("div",{className:"hidden sm:flex",style:{gap:2,alignItems:"center",marginLeft:8,paddingLeft:8,borderLeft:"1px solid rgba(255,255,255,0.1)"},children:Q.map(re=>l.jsx("span",{title:`${re.name}: ${re.description}`,style:{fontSize:12,cursor:"default"},children:re.icon},re.id))}):null})(),l.jsx("span",{className:"px-1.5 py-0.5",style:{background:"var(--bar-border, var(--hud-bg-alt))",border:"1px solid var(--bar-border, var(--pixel-border))",color:"var(--bar-text, var(--terminal-text))"},children:ad})]})]}),(fr||ol.length>0)&&l.jsxs("div",{className:"shrink-0 z-[44]",children:[l.jsxs("div",{className:"flex items-center gap-3 px-5 py-2 text-xs cursor-pointer select-none",style:{background:"var(--accent)",color:"#fff",fontFamily:"var(--pixel-font)"},onClick:()=>Ko(M=>!M),children:[fr?l.jsx("div",{className:"w-3 h-3 border-2 border-white/40 border-t-white rounded-full animate-spin shrink-0"}):l.jsx("span",{className:"shrink-0",children:"✅"}),l.jsx("span",{className:"flex-1",children:fr||"Knowledge import finished"}),za&&l.jsx("div",{className:"w-24 h-1.5 rounded-full overflow-hidden shrink-0",style:{background:"rgba(255,255,255,0.3)"},children:l.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${za.index/za.total*100}%`,background:"#fff"}})}),l.jsx("span",{className:"text-[10px] opacity-70 shrink-0",children:_a?"▲":"▼"})]}),_a&&l.jsxs("div",{className:"overflow-y-auto text-xs",style:{background:"var(--terminal-bg)",borderBottom:"2px solid var(--accent)",maxHeight:240,fontFamily:"var(--pixel-font)"},children:[ol.map(M=>l.jsxs("div",{className:"flex items-start gap-2 px-5 py-1.5",style:{borderBottom:"1px solid var(--terminal-border)"},children:[l.jsxs("span",{className:"shrink-0 mt-0.5",style:{width:14,textAlign:"center"},children:[M.type==="scan"&&"🔍",M.type==="process"&&"⚙️",M.type==="created"&&"✅",M.type==="done"&&"🎉",M.type==="error"&&"❌"]}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{style:{color:M.type==="error"?"#EF4444":M.type==="done"?"var(--active-green)":"var(--terminal-text)"},children:M.text}),M.detail&&l.jsx("div",{className:"text-[10px] truncate",style:{color:"var(--terminal-text-muted)"},children:M.detail})]})]},M.id)),l.jsx("div",{ref:cl}),ol.length===0&&l.jsx("div",{className:"px-5 py-4 text-center",style:{color:"var(--terminal-text-muted)"},children:"Waiting for events..."})]})]}),l.jsxs("div",{className:"flex-1 overflow-hidden flex relative",children:[l.jsx("div",{className:"flex-1 overflow-y-auto relative floor-grid",style:{background:"var(--floor-light)"},children:l.jsx(x8,{roles:a,projects:o,waves:m,standups:d,decisions:x,roleStatuses:fa,activeExecs:me,onRoleClick:M=>Kn({type:"role",roleId:M}),onProjectClick:M=>Kn({type:"project",projectId:M}),onBulletinClick:()=>{Kn({type:"bulletin"}),ln({type:"bulletin_visited"})},onDecisionsClick:()=>Kn({type:"decisions"}),onKnowledgeClick:()=>{Kn({type:"knowledge"}),ln({type:"knowledge_visited"})},onSettingsClick:()=>{ca(!0),ln({type:"settings_visited"})},onThemeClick:()=>Ra(M=>!M),onStatsClick:()=>{mn(!0),ln({type:"stats_visited"})},knowledgeDocsCount:v.length,getRoleSpeech:Oi.getSpeech,getAppearance:Ot,onHireClick:()=>jt(!0),onMascotClick:()=>Kn({type:"quest"}),roleLevels:Ae,language:ke,coinBalance:ne,onCoinsSpent:M=>ve(M),onFurniturePlaced:(M,Q)=>{ln({type:"furniture_placed"}),Q>0&&ln({type:"furniture_purchased"})}})}),Gn&&l.jsx("div",{className:Jl?"absolute inset-0 z-50":"contents",children:l.jsx(Qg,{sessions:Un,activeSessionId:ta,roles:a,streamingSessionId:da,width:Jl?Ri:ua,onWidthChange:Jl?void 0:ul,onSwitchSession:qn,onCloseSession:ec,onCreateSession:pl,onClearEmpty:tc,onCloseAll:nc,onSendMessage:Ia,onModeChange:_s,onStopSession:M=>ye.abortSession(M).catch(()=>{}),onCloseTerminal:()=>Oa(!1),onMaximize:()=>{Sr.current="iso",Pt({type:"terminal"}),Ir("pro")},chatChannels:Jt.channels,activeChatChannelId:Jt.activeChannelId,onSwitchChatChannel:Jt.setActiveChannelId,onCreateChatChannel:(...M)=>{const Q=Jt.createChannel(...M);return ln({type:"chat_channel_created"}),Q},onDeleteChatChannel:Jt.deleteChannel,onUpdateChatMembers:Jt.updateMembers,onUpdateChatTopic:Jt.updateTopic,onSendChatMessage:$i,unreadChannels:Jt.unreadChannels})})]}),l.jsxs("div",{className:"flex items-center justify-between px-5 py-2 text-[10px] shrink-0 z-[45]",style:{background:"var(--bar-bg, var(--hud-bg))",color:"var(--bar-text, var(--terminal-text-secondary))",borderTop:"3px solid var(--bar-border, var(--pixel-border))"},children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{onClick:()=>Ir("iso"),className:`view-toggle-btn ${Lr==="iso"?"active":""}`,children:"OFFICE"}),l.jsx("button",{onClick:()=>{Sr.current="iso",Ir("pro")},className:`view-toggle-btn ${Lr==="pro"?"active":""}`,children:"PRO"}),l.jsx("span",{className:"mx-1",children:"|"}),l.jsxs("div",{style:{position:"relative"},children:[l.jsxs("button",{className:`theme-btn${Ma?" active":""}`,"data-quest-target":"theme-btn",onClick:()=>Ra(M=>!M),title:"Office Theme",children:[((oc=il[J])==null?void 0:oc.icon)??"","▾"]}),Ma&&l.jsx(T8,{theme:J,onThemeChange:M=>{Oe(M),ln({type:"theme_changed"})},onClose:()=>Ra(!1)})]}),l.jsx("button",{className:"theme-btn","data-quest-target":"settings-btn",onClick:()=>ca(!0),title:"Settings",children:"⚙"}),l.jsx("span",{className:"mx-1",children:"|"}),l.jsxs("button",{"data-quest-target":"save-btn",onClick:()=>{Pe.state==="no-git"||Pe.state==="dirty"?Wn(!0):Fi(!0)},title:Pe.state==="dirty"?`${Pe.dirtyCount} unsaved — click to save`:"Git Status",style:{background:"none",border:"none",cursor:"pointer",fontSize:10,fontFamily:"var(--pixel-font)",color:"var(--bar-text, var(--terminal-text-muted))",display:"flex",alignItems:"center",gap:4},children:[l.jsx("span",{style:{display:"inline-block",width:6,height:6,borderRadius:"50%",background:Pe.state==="no-git"?"var(--terminal-text-muted)":Pe.state==="saving"||Pe.state==="dirty"?"var(--idle-amber)":Pe.state==="error"?"#EF5350":"var(--active-green)",animation:Pe.state==="saving"?"pulse 1s infinite":void 0}}),l.jsx("span",{style:{color:Pe.state==="dirty"?"var(--idle-amber)":"var(--bar-text, var(--terminal-text-muted))"},children:Pe.state==="no-git"?"No git":Pe.state==="saving"?"Saving...":Pe.state==="dirty"?`${Pe.dirtyCount} unsaved`:"Saved"}),Vn&&(Vn.worktrees.length>0||Vn.staleBranches.length>0)&&l.jsxs("span",{style:{color:Vn.worktrees.some(M=>M.status==="stale")?"#ff6b6b":Vn.worktrees.some(M=>M.status==="pending-merge")?"#FFB74D":"#4FC3F7"},children:["·"," ","📂"," ",Vn.worktrees.length," worktree",Vn.worktrees.length!==1?"s":"",Vn.staleBranches.length>0&&` · ⚠ ${Vn.staleBranches.length} branch${Vn.staleBranches.length!==1?"es":""}`]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[Y.length>0&&!ie&&l.jsx("button",{onClick:()=>ha(),className:`px-3 py-1 font-black text-white cursor-pointer ${tt?"":"animate-pulse"}`,style:{background:tt?"#2E7D32":"#B71C1C",border:`2px solid ${tt?"#1b5e2088":"#7f121288"}`,fontFamily:"var(--pixel-font)",borderRadius:4},children:tt?"WAVE DONE":`WAVE (${Y.length})`}),Ie&&ot&&Y.length===0&&l.jsx("button",{onClick:()=>Je(!1),className:`px-3 py-1 font-black text-white cursor-pointer ${tt?"":"animate-pulse"}`,style:{background:tt?"#2E7D32":"#B71C1C",border:`2px solid ${tt?"#1b5e2088":"#7f121288"}`,fontFamily:"var(--pixel-font)",borderRadius:4},children:tt?"WAVE DONE":"WAVE"}),A.length>0&&U&&l.jsxs("button",{onClick:()=>T(!1),className:"px-3 py-1 font-black text-white cursor-pointer animate-pulse",style:{background:A[A.length-1].color,border:`2px solid ${A[A.length-1].color}88`,fontFamily:"var(--pixel-font)",borderRadius:4},children:[A[A.length-1].title.slice(0,20),A[A.length-1].title.length>20?"..":""]}),l.jsxs("button",{onClick:()=>ha(),className:"wave-btn px-3 py-1 font-black text-white cursor-pointer","data-quest-target":"wave-btn",style:{background:"#B71C1C",border:"2px solid #7f1212",fontFamily:"var(--pixel-font)"},children:["🔴"," CEO WAVE"]}),l.jsx("button",{onClick:()=>Gn?Oa(!1):zs(),className:"px-3 py-1 font-black cursor-pointer","data-quest-target":"terminal-btn",style:{background:Gn?"var(--terminal-bg)":"var(--hud-bg-alt)",color:"var(--terminal-text)",border:`2px solid ${Gn?"var(--terminal-border-hover)":"var(--pixel-border)"}`,fontFamily:"var(--pixel-font)"},children:"TERMINAL"})]})]}),Lr!=="pro"&&R.type==="role"&&F&&(()=>{var Q,re;const M=Ne[F.id];return l.jsx(Dg,{role:F,allRoles:a,recentActivity:ic(F.id),onClose:mr,onFireRole:(he,je)=>{Tt({roleId:he,roleName:je}),mr()},terminalWidth:Gn?ua:0,activeJobId:M==null?void 0:M.id,activeSessionId:(Q=A.find(he=>he.jobId===(M==null?void 0:M.jobId)))==null?void 0:Q.sessionId,activeTask:M==null?void 0:M.task,isWorking:fa[F.id]==="working",jobStartedAt:M==null?void 0:M.startedAt,onStopJob:he=>{const je=A.find(Le=>Le.jobId===he);je&&ye.abortSession(je.sessionId)},sessions:Un,streamingSessionId:da,onCreateSessionSilent:ni,onSendMessage:Ia,onFocusTerminal:Jo,onCustomize:he=>{const je=a.find(Le=>Le.id===he);je&&(We("character"),$e(je))},onUpdateRole:ti,appearance:Ot(F.id),relationships:Oi.relationships,roleLevel:(re=Ae[F.id])==null?void 0:re.level,onMaximize:()=>{Sr.current="iso",Pt({type:"role",roleId:F.id}),Ir("pro")}})})(),Lr!=="pro"&&R.type==="project"&&rc&&l.jsx($N,{projectId:rc.id,onClose:mr,terminalWidth:Gn?ua:0}),Lr!=="pro"&&(R.type==="bulletin"||R.type==="decisions")&&l.jsx(qg,{standups:d,waves:m,decisions:x,mode:R.type==="bulletin"?"bulletin":"decisions",onClose:mr,onOpenWaveCenter:()=>ha(),onUpdateDecision:La,onDeleteDecision:Ms,terminalWidth:Gn?ua:0,onMaximize:()=>{Sr.current="iso",Pt({type:"operations"}),Ir("pro")}}),Lr!=="pro"&&R.type==="quest"&&l.jsx(ON,{progress:we,onClose:mr,terminalWidth:Gn?ua:0,onQuestAction:M=>{var re;mr();const Q=ws.find(he=>he.id===M);(re=Q==null?void 0:Q.hint)!=null&&re.target&&ma(Q.hint.target)}}),Lr!=="pro"&&R.type==="knowledge"&&l.jsx(Ug,{docs:v,onClose:mr,onRefresh:()=>ye.getKnowledge().then(b).catch(()=>{}),terminalWidth:Gn?ua:0,initialDocId:R.docId,onMaximize:()=>{Sr.current="iso",Pt({type:"knowledge"}),Ir("pro")}}),Lr==="pro"&&l.jsxs(F8,{roles:a,roleStatuses:fa,activeExecs:me,waves:m,knowledgeDocs:v,sessions:Un,roleLevels:Ae,companyName:j,getAppearance:Ot,waveCenterWaves:Y,renderProfile:ea.type==="role"&&F?M=>{var re,he;const Q=Ne[F.id];return l.jsx(Dg,{role:F,allRoles:a,recentActivity:ic(F.id),onClose:M,onFireRole:(je,Le)=>{Tt({roleId:je,roleName:Le})},terminalWidth:0,activeJobId:Q==null?void 0:Q.id,activeSessionId:(re=A.find(je=>je.jobId===(Q==null?void 0:Q.jobId)))==null?void 0:re.sessionId,activeTask:Q==null?void 0:Q.task,isWorking:fa[F.id]==="working",jobStartedAt:Q==null?void 0:Q.startedAt,onStopJob:je=>{const Le=A.find(It=>It.jobId===je);Le&&ye.abortSession(Le.sessionId)},sessions:Un,streamingSessionId:da,onCreateSessionSilent:ni,onSendMessage:Ia,onFocusTerminal:()=>{},onCustomize:je=>{const Le=a.find(It=>It.id===je);Le&&(We("character"),$e(Le))},onUpdateRole:ti,appearance:Ot(F.id),relationships:Oi.relationships,roleLevel:(he=Ae[F.id])==null?void 0:he.level})}:void 0,channel:ea,onChannelChange:M=>{Pt(M),M.type==="role"?Kn({type:"role",roleId:M.roleId}):M.type==="knowledge"?Kn({type:"knowledge"}):M.type==="operations"?Kn({type:"bulletin"}):M.type==="wave"?P(!0):M.type==="terminal"?Oa(!0):(L({type:"none"}),P(!1))},onClose:()=>{Ir(Sr.current),L({type:"none"}),P(!1)},children:[ea.type==="dashboard"&&l.jsx(z8,{roles:a,roleStatuses:fa,activeExecs:me,waves:m,knowledgeDocs:v,roleLevels:Ae,getAppearance:Ot,onRoleClick:M=>Pt({type:"role",roleId:M}),onWaveClick:()=>Pt({type:"wave"}),onKnowledgeClick:()=>Pt({type:"knowledge"})}),ea.type==="terminal"&&l.jsx(Qg,{sessions:Un,activeSessionId:ta,roles:a,streamingSessionId:da,width:typeof window<"u"?window.innerWidth-240:1e3,onSwitchSession:qn,onCloseSession:ec,onCreateSession:pl,onClearEmpty:tc,onCloseAll:nc,onSendMessage:Ia,onModeChange:_s,onStopSession:M=>ye.abortSession(M).catch(()=>{}),onCloseTerminal:()=>Pt({type:"dashboard"}),chatChannels:Jt.channels,activeChatChannelId:Jt.activeChannelId,onSwitchChatChannel:Jt.setActiveChannelId,onCreateChatChannel:(...M)=>{const Q=Jt.createChannel(...M);return ln({type:"chat_channel_created"}),Q},onDeleteChatChannel:Jt.deleteChannel,onUpdateChatMembers:Jt.updateMembers,onUpdateChatTopic:Jt.updateTopic,onSendChatMessage:$i,unreadChannels:Jt.unreadChannels}),ea.type==="wave"&&l.jsx(Kg,{orgNodes:se,rootRoleId:pe,cLevelRoles:pe&&se[pe]?se[pe].children.map(M=>a.find(Q=>Q.id===M)).filter(M=>!!M):a.filter(M=>M.level==="c-level"),pastWaves:m,activeWaves:Y,onDispatch:(M,Q)=>Yn(M,Q),onClose:()=>Pt({type:"dashboard"}),onDone:()=>{ir(),Ee(!0),Et("Wave complete","#2E7D32")},onSave:async(M,Q,re)=>{try{await ye.saveWave({directive:M,jobIds:Q,waveId:re==null?void 0:re.waveId,sessionIds:re==null?void 0:re.sessionIds}),ir(),Et("Wave saved","#2E7D32")}catch(he){Et(`Save failed: ${he instanceof Error?he.message:"unknown"}`,"#C62828")}},onOpenKnowledgeDoc:M=>{Pt({type:"knowledge"}),Kn({type:"knowledge",docId:M}),ye.getKnowledge().then(b).catch(()=>{})},onRefreshWaves:()=>ye.getWaves().then(h).catch(()=>{}),terminalWidth:0,inline:!0,onOpenSaveModal:()=>Wn(!0)}),ea.type==="knowledge"&&l.jsx(Ug,{docs:v,onClose:()=>Pt({type:"dashboard"}),onRefresh:()=>ye.getKnowledge().then(b).catch(()=>{}),terminalWidth:0}),ea.type==="operations"&&l.jsx(qg,{standups:d,waves:m,decisions:x,mode:"bulletin",onClose:()=>Pt({type:"dashboard"}),onOpenWaveCenter:()=>Pt({type:"wave"}),onUpdateDecision:La,onDeleteDecision:Ms,terminalWidth:0}),ea.type==="role"&&(()=>{const M=ea.roleId,Q=a.find(he=>he.id===M);if(!Q)return null;const re=Un.find(he=>he.roleId===M);return re?l.jsx(M8,{role:Q,messages:re.messages,isStreaming:da===re.id,mode:re.mode,onModeChange:he=>_s(re.id,he),onSend:(he,je,Le)=>Ia(re.id,he,je,Le),isWave:re.source==="wave"}):l.jsx(R8,{role:Q,getAppearance:Ot,onSend:async(he,je)=>{try{const Le=await ye.createSession(M,"talk");an(It=>[Le,...It]),qn(Le.id),Ia(Le.id,he,je)}catch(Le){Et(`Failed to create session: ${Le instanceof Error?Le.message:"API unreachable"}`,"#B71C1C")}}})})()]}),H&&l.jsx(HN,{roleId:H.roleId,roleName:H.roleName,mode:H.mode,onClose:()=>X(null),onExecutionStart:na}),Ie&&!ot&&l.jsx(t6,{directive:Ie.directive,rootJobs:Ie.rootJobs,orgNodes:se,rootRoleId:pe,onClose:()=>{He(null),Je(!1),Ee(!1)},onMinimize:()=>Je(!0),onDone:()=>{ir(),Ee(!0),Et("Wave complete","#2E7D32")},onSave:async M=>{try{await ye.saveWave({directive:Ie.directive,jobIds:M}),ir(),Et("Wave saved to bulletin","#2E7D32")}catch(Q){Et(`Save failed: ${Q instanceof Error?Q.message:"unknown"}`,"#C62828")}},onOpenKnowledgeDoc:M=>{He(null),Je(!1),Ee(!1),Kn({type:"knowledge",docId:M}),ye.getKnowledge().then(b).catch(()=>{})}}),ie&&l.jsx(Kg,{orgNodes:se,rootRoleId:pe,cLevelRoles:pe&&se[pe]?se[pe].children.map(M=>a.find(Q=>Q.id===M)).filter(M=>!!M):a.filter(M=>M.level==="c-level"),pastWaves:m,activeWaves:Y,onDispatch:(M,Q)=>Yn(M,Q),onClose:()=>P(!1),onMaximize:()=>{Sr.current="iso",Pt({type:"wave"}),Ir("pro")},onDone:()=>{ir(),Ee(!0),Et("Wave complete","#2E7D32")},onSave:async(M,Q,re)=>{try{await ye.saveWave({directive:M,jobIds:Q,waveId:re==null?void 0:re.waveId,sessionIds:re==null?void 0:re.sessionIds}),ir(),Et("Wave saved","#2E7D32")}catch(he){Et(`Save failed: ${he instanceof Error?he.message:"unknown"}`,"#C62828")}},onOpenKnowledgeDoc:M=>{P(!1),Kn({type:"knowledge",docId:M}),ye.getKnowledge().then(b).catch(()=>{})},onRefreshWaves:()=>ye.getWaves().then(h).catch(()=>{}),terminalWidth:Gn?ua:0,onOpenSaveModal:()=>Wn(!0)}),A.length>0&&!U&&(()=>{var re;const M=A[A.length-1],Q=de.length>1;return l.jsxs(l.Fragment,{children:[Q&&A.length===1&&l.jsx("div",{className:"fixed top-[5%] left-1/2 -translate-x-1/2 w-[720px] max-w-[95vw] z-[63] flex gap-1 px-2 pt-2",children:de.map((he,je)=>l.jsx("button",{onClick:()=>{B(je),$([{sessionId:he.sessionId,jobId:he.jobId??"",title:`CEO WAVE · ${he.roleId.toUpperCase()}`,color:"#B71C1C"}])},className:"px-3 py-1.5 text-xs font-bold rounded-t-lg cursor-pointer transition-colors",style:{background:D===je?"#B71C1C":"var(--terminal-bg)",color:D===je?"#fff":"var(--terminal-text-secondary)",border:`1px solid ${D===je?"#B71C1C":"var(--terminal-border)"}`,borderBottom:"none"},children:he.roleId.toUpperCase()},he.sessionId))}),l.jsx(UN,{sessionId:M.sessionId,title:A.length>1?M.title:Q?`CEO WAVE · ${((re=de[D])==null?void 0:re.roleName)??""}`:M.title,color:M.color,variant:"modal",style:Q&&A.length===1?{marginTop:28}:void 0,onClose:()=>{const he=Un.filter(je=>je.source==="wave").map(je=>je.id);he.length>0&&(an(je=>je.filter(Le=>Le.source!=="wave")),ye.deleteSessions(he).catch(()=>{})),$([]),G([]),B(0),T(!1)},onMinimize:()=>T(!0),onDone:()=>{Bi(),ir()},onNavigateToJob:()=>{},onOpenKnowledgeDoc:he=>{$([]),G([]),B(0),T(!1),Kn({type:"knowledge",docId:he}),ye.getKnowledge().then(b).catch(()=>{})}},M.sessionId)]})})(),A.length>1&&l.jsx("div",{className:"fixed top-[5%] left-1/2 -translate-x-1/2 w-[720px] max-w-[95vw] z-[62] pointer-events-none",children:l.jsx("div",{className:"pointer-events-auto",children:l.jsxs("button",{onClick:()=>$(M=>M.slice(0,-1)),className:"mt-2 ml-2 px-3 py-1 text-xs font-bold text-[var(--terminal-text)] bg-[var(--terminal-bg)] border border-[var(--terminal-border)] rounded-lg cursor-pointer hover:bg-[var(--terminal-inline-bg)]",children:["←"," Back to ",(cc=A[A.length-2])==null?void 0:cc.title]})})}),q&&l.jsx(WN,{cLevelRoles:pe&&se[pe]?se[pe].children.map(M=>a.find(Q=>Q.id===M)).filter(M=>!!M):a.filter(M=>M.level==="c-level"),orgNodes:se,rootId:pe,onClose:()=>W(!1),onDispatch:(M,Q)=>Yn(M,Q)}),xt&&l.jsx(d6,{existingRoles:a,onClose:()=>jt(!1),onHire:ei,onStoreVisit:()=>ln({type:"store_visited"}),questHint:((uc=hl==null?void 0:hl.hint)==null?void 0:uc.target)==="hire-btn"?{message:hl.description,roleId:((Bs=hl.trigger.condition)==null?void 0:Bs.roleId)??void 0}:void 0}),Wt&&l.jsx(m6,{roleId:Wt.roleId,roleName:Wt.roleName,onClose:()=>Tt(null),onConfirm:rd}),te&&l.jsx(g8,{role:te,appearance:Ot(te.id),onSave:M=>{un(te.id,M),ln({type:"accessory_changed"})},onReset:()=>kn(te.id),onClose:()=>{$e(null),We("character")},theme:J,onThemeChange:M=>{Oe(M),ln({type:"theme_changed"})},onUpdateName:async(M,Q)=>{await ti(M,{name:Q})},initialTab:"character",characterOnly:!0,speechSettings:rt,onSpeechSettingsChange:Kt,language:ke,onLanguageChange:kt,roleLevel:(dc=Ae[te.id])==null?void 0:dc.level,coinBalance:ne,purchased:jn,onPurchase:(M,Q)=>{ye.spendCoins(Q,`Purchased ${M}`,M).then(re=>{ve(re.balance),hn(M)}).catch(()=>{})}}),Sn&&(()=>{const M=a.find(Q=>Q.id==="cto")??a.find(Q=>Q.level==="c-level")??a[0];return l.jsx(v8,{status:Pe.status,history:Pe.history,onClose:()=>Wn(!1),onSave:async Q=>{const re=await Pe.save(Q);return re!=null&&re.ok&&ln({type:"save_committed"}),re},onLoadHistory:Pe.loadHistory,onRestore:Pe.restore,saving:Pe.state==="saving",repo:Pe.repo,onRepoChange:Pe.setRepo,syncInfo:Pe.syncInfo,onPull:Pe.pull,pulling:Pe.pulling,onRefresh:Pe.refresh,onInitGit:Pe.initGit,delegateRoleName:(M==null?void 0:M.name)??(M==null?void 0:M.id),onDelegate:M?async Q=>{Wn(!1);try{const re=await ye.createSession(M.id,"do");an(je=>[re,...je]),qn(re.id),dl();const he=`Review the following unsaved changes, write a proper commit message, save (git add + commit), and push. If the current branch is not the main branch, create a PR and merge it.
|
|
98
|
+
|
|
99
|
+
Changed files:
|
|
100
|
+
${Q}`;Ia(re.id,he,"do")}catch(re){Et(`Failed to delegate: ${re instanceof Error?re.message:"error"}`,"#B71C1C")}}:void 0})})(),yn&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>mn(!1),children:l.jsx("div",{style:{width:420,maxHeight:"80vh",background:"var(--terminal-bg)",border:"2px solid var(--pixel-border)",borderRadius:8},onClick:M=>M.stopPropagation(),children:l.jsx(w8,{onClose:()=>mn(!1)})})}),Or&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>Ql(!1),children:l.jsx("div",{style:{width:480,maxHeight:"80vh",background:"var(--terminal-bg)",border:"2px solid var(--pixel-border)",borderRadius:8,overflowY:"auto"},onClick:M=>M.stopPropagation(),children:l.jsx(S8,{onClose:()=>Ql(!1),onSyncComplete:()=>{}})})}),Ts&&l.jsx(D8,{onClose:()=>ca(!1),speechSettings:rt,onSpeechSettingsChange:Kt,language:ke,onLanguageChange:kt,onOpenSync:()=>Ql(!0),onOpenGitStatus:()=>Fi(!0),onOpenSessions:()=>Fa(!0),onOpenStats:()=>mn(!0)}),Ds&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>Fi(!1),children:l.jsx("div",{style:{width:520,maxHeight:"80vh",background:"var(--terminal-bg)",border:"2px solid var(--pixel-border)",borderRadius:8,overflowY:"auto"},onClick:M=>M.stopPropagation(),children:l.jsx(C8,{onClose:()=>Fi(!1)})})}),Go&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>Fa(!1),children:l.jsx("div",{style:{width:520,maxHeight:"80vh",background:"var(--terminal-bg)",border:"2px solid var(--pixel-border)",borderRadius:8,overflowY:"auto"},onClick:M=>M.stopPropagation(),children:l.jsx(E8,{onClose:()=>Fa(!1)})})}),l.jsx("div",{className:"fixed top-16 right-4 z-[70] flex flex-col gap-2",children:K.map(M=>l.jsxs("div",{className:"toast-enter flex items-center gap-2 px-4 py-2.5 shadow-lg text-white text-xs font-black",style:{background:M.color,border:"2px solid rgba(0,0,0,0.3)",fontFamily:"var(--pixel-font)"},children:[l.jsx("div",{className:"w-2 h-2 bg-white/60"}),M.message]},M.id))})]})}function Mu({onSelect:e,onClose:n}){const[a,i]=w.useState(null),[o,u]=w.useState(!0),[d,f]=w.useState(""),[m,h]=w.useState(!1),[x,g]=w.useState(!1),v=w.useRef(null),b=w.useCallback(async k=>{u(!0);try{const N=await ye.browse(k);i(N)}catch{}finally{u(!1)}},[]);w.useEffect(()=>{b()},[b]),w.useEffect(()=>{var k;m&&((k=v.current)==null||k.focus())},[m]);const j=async()=>{if(!(!a||!d.trim())){g(!0);try{const k=await ye.mkdir(a.current,d.trim());k.ok&&(f(""),h(!1),await b(k.path))}catch{}finally{g(!1)}}};return o&&!a?l.jsx("div",{className:"mt-3 rounded-lg p-4 text-xs text-center",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text-muted)"},children:"Loading..."}):a?l.jsxs("div",{className:"mt-3 rounded-lg overflow-hidden text-xs",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)",maxHeight:260,overflowY:"auto"},children:[l.jsxs("div",{className:"px-3 py-2 flex items-center gap-2 sticky top-0 z-10",style:{background:"var(--terminal-surface)",borderBottom:"1px solid var(--terminal-border)"},children:[l.jsx("span",{style:{color:"var(--terminal-text-secondary)",fontFamily:"var(--pixel-font)"},className:"truncate flex-1",children:a.current}),l.jsx("button",{onClick:()=>{h(!m),f("")},className:"px-2 py-1 rounded text-[10px] font-medium shrink-0 cursor-pointer",style:{background:"var(--terminal-bg)",color:"var(--terminal-text-muted)",border:"1px solid var(--terminal-border)"},title:"New folder",children:"+ Folder"}),l.jsx("button",{onClick:()=>e(a.current),className:"px-2 py-1 rounded text-[10px] font-medium shrink-0 cursor-pointer",style:{background:"var(--active-green)",color:"#fff"},children:"Select"}),l.jsx("button",{onClick:n,className:"opacity-50 hover:opacity-100 shrink-0 cursor-pointer",style:{color:"var(--terminal-text)"},children:"✕"})]}),m&&l.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",style:{borderBottom:"1px solid var(--terminal-border)",background:"var(--hud-bg-alt)"},children:[l.jsx("input",{ref:v,className:"flex-1 px-2 py-1 rounded text-xs",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)",outline:"none"},placeholder:"folder name",value:d,onChange:k=>f(k.target.value),onKeyDown:k=>{k.key==="Enter"&&j(),k.key==="Escape"&&h(!1)}}),l.jsx("button",{onClick:j,disabled:x||!d.trim(),className:"px-2 py-1 rounded text-[10px] font-medium shrink-0 cursor-pointer",style:{background:"var(--accent)",color:"#fff",opacity:x||!d.trim()?.5:1},children:x?"...":"Create"})]}),a.parent&&l.jsxs("div",{className:"px-3 py-1.5 cursor-pointer flex items-center gap-2 hover:bg-[var(--terminal-surface-light)]",style:{color:"var(--terminal-text-secondary)"},onClick:()=>b(a.parent),children:[l.jsx("span",{children:"⬆️"}),l.jsx("span",{children:".."})]}),a.dirs.map(k=>l.jsxs("div",{className:"px-3 py-1.5 cursor-pointer flex items-center gap-2 hover:bg-[var(--terminal-surface-light)]",style:{color:"var(--terminal-text)"},onClick:()=>b(k.path),children:[l.jsx("span",{children:"📁"}),l.jsx("span",{children:k.name})]},k.path)),a.dirs.length===0&&!m&&l.jsx("div",{className:"px-3 py-3 text-center",style:{color:"var(--terminal-text-muted)"},children:"No subdirectories"})]}):null}const $8={engine:"AI Engine",company:"Company",workspace:"Workspace",team:"Team",create:"Create"};function jy(e){return e==="existing-akb"?["engine","workspace","create"]:["engine","company","workspace","team","create"]}function L8({onComplete:e}){const[n,a]=w.useState(0),[i,o]=w.useState(null),[u,d]=w.useState("none"),[f,m]=w.useState(""),[h,x]=w.useState(!0),[g,v]=w.useState(""),[b,j]=w.useState(""),[k,N]=w.useState("en"),E=w.useRef(null),[C,_]=w.useState("new"),[R,L]=w.useState(""),[F,I]=w.useState(""),[H,X]=w.useState(!1),[A,$]=w.useState(!1),[q,W]=w.useState(!1),[ie,P]=w.useState(""),[Y,oe]=w.useState(!1),[de,G]=w.useState(!1),[D,B]=w.useState([]),[U,T]=w.useState(""),[se,ge]=w.useState(!1),[pe,Re]=w.useState(""),[Ie,He]=w.useState(null),[ot,Je]=w.useState(!1),[tt,Ee]=w.useState(!1),[Ae,yt]=w.useState([]),[dt,xt]=w.useState("startup"),[jt,Wt]=w.useState(!1),[Tt,Ct]=w.useState(!1),[Bn,me]=w.useState(null),[Se,Ne]=w.useState([]),[K,ue]=w.useState(""),[ne,ve]=w.useState(!1),[we,ze]=w.useState(!1),[_e,Be]=w.useState([]),qe=w.useMemo(()=>jy(C),[C]),at=qe[n]??"engine";w.useEffect(()=>{ye.detectEngine().then(ke=>{o(ke),d(ke.recommended),x(!1)}).catch(()=>x(!1)),ye.getTeams().then(yt).catch(()=>{}),ye.getStatus().then(ke=>{I(ke.companyRoot||"")}).catch(()=>{})},[]),w.useEffect(()=>{var ke;at==="company"&&((ke=E.current)==null||ke.focus())},[at]),w.useEffect(()=>{if(H||!F)return;const ke=g.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");L(ke?`${F}/${ke}`:F)},[g,F,H]);const Ke=()=>{switch(at){case"engine":return u!=="none"||f.length>10;case"company":return g.trim().length>0;case"workspace":return C==="existing-akb"?Ie===!0:!0;case"team":return!0;case"create":return!Tt;default:return!1}},bt=()=>{n<qe.length-1&&Ke()&&a(n+1),at==="create"&&!jt&&!ne&&(C==="existing-akb"?kn():un())},Me=()=>{n>0&&a(n-1)},Ue=w.useRef(C);w.useEffect(()=>{if(Ue.current===C)return;Ue.current=C;const kt=jy(C).indexOf("workspace");kt>=0&&a(kt)},[C]);const _t=async()=>{if(pe.trim()){Je(!0);try{const ke=await ye.validatePath(pe.trim());He(ke.valid&&ke.hasClaudeMd===!0)}catch{He(!1)}finally{Je(!1)}}},Bt=()=>{const ke=U.trim();ke&&!D.includes(ke)&&(B([...D,ke]),T(""))},Ot=async ke=>{ze(!0),Be([]);try{const{tools:kt}=await ye.getRequiredTools(ke);if(kt.filter(hn=>!hn.installed).length===0){ze(!1);return}await ye.installTools(ke,(hn,te)=>{const $e=te.tool||"";hn==="checking"?Be(We=>[...We,{event:hn,tool:$e,detail:"checking..."}]):hn==="installing"?Be(We=>[...We,{event:hn,tool:$e,detail:"installing..."}]):hn==="installed"?Be(We=>[...We,{event:hn,tool:$e,detail:"installed"}]):hn==="skipped"?Be(We=>[...We,{event:hn,tool:$e,detail:te.reason||"skipped"}]):hn==="error"&&Be(We=>[...We,{event:hn,tool:$e,detail:te.error||"failed"}])})}catch{}finally{ze(!1)}},un=async()=>{Wt(!0),me(null);try{const ke={companyName:g.trim(),description:b.trim()||"An AI-powered organization",team:dt,knowledgePaths:D.length>0?D:void 0,language:k!=="auto"?k:void 0,location:R.trim()||void 0,codeRoot:ie.trim()||void 0};(u==="direct-api"||f)&&(ke.apiKey=f||void 0);const kt=await ye.scaffold(ke);Ne(kt.created),ue(kt.projectRoot),Ct(!0),Wt(!1),dt!=="custom"&&Ot(dt)}catch(ke){me(ke instanceof Error?ke.message:"Scaffold failed"),Wt(!1)}},kn=async()=>{ve(!0),me(null);try{const ke=await ye.connectAkb(pe.trim());ke.ok?(Ct(!0),Ne([`Connected to: ${ke.companyRoot}`])):me(ke.error||"Failed to connect")}catch(ke){me(ke instanceof Error?ke.message:"Connect failed")}finally{ve(!1)}},J=()=>{D.length>0?e({paths:D,companyRoot:""}):e()},Oe=ke=>{ke.key==="Enter"&&Ke()&&(ke.preventDefault(),bt())},rt=`w-full px-3 py-2 rounded text-sm outline-none transition-colors
|
|
101
|
+
bg-[var(--terminal-bg)] text-[var(--terminal-text)]
|
|
102
|
+
border border-[var(--terminal-border)]
|
|
103
|
+
focus:border-[var(--terminal-border-hover)]
|
|
104
|
+
placeholder:text-[var(--terminal-text-muted)]`,Kt=ke=>`p-4 rounded-lg border-2 cursor-pointer transition-all text-[var(--terminal-text)] ${ke?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--terminal-border)] bg-[var(--hud-bg-alt)] hover:border-[var(--accent)]/50"}`;return l.jsx("div",{className:"h-full flex items-center justify-center",style:{background:"var(--floor-dark)"},onKeyDown:Oe,children:l.jsxs("div",{className:"w-full max-w-xl rounded-xl shadow-2xl overflow-hidden",style:{background:"var(--hud-bg)",border:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"px-6 py-5",style:{background:"var(--terminal-bg)",borderBottom:"1px solid var(--terminal-border)"},children:[l.jsx("div",{className:"text-lg font-bold",style:{color:"var(--terminal-text)",fontFamily:"var(--pixel-font)"},children:"tycono"}),l.jsx("div",{className:"text-xs mt-1",style:{color:"var(--terminal-text-secondary)"},children:"Build an AI company. Watch them work."}),l.jsx("div",{className:"flex gap-1.5 mt-4",children:qe.map((ke,kt)=>l.jsxs("div",{className:"flex-1",children:[l.jsx("div",{className:"h-1 rounded-full transition-colors",style:{background:kt<=n?"var(--accent)":"var(--terminal-surface-light)"}}),l.jsx("div",{className:"text-[9px] mt-1 truncate",style:{color:kt===n?"var(--terminal-text)":"var(--terminal-text-muted)"},children:$8[ke]})]},ke))})]}),l.jsxs("div",{className:"px-6 py-5 min-h-[280px] max-h-[480px] overflow-y-auto",children:[at==="engine"&&l.jsxs("div",{className:"space-y-4",children:[l.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"AI Engine Setup"}),h?l.jsx("div",{className:"text-sm",style:{color:"var(--terminal-text-secondary)"},children:"Detecting AI engine..."}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:Kt(u==="claude-cli"),onClick:()=>(i==null?void 0:i.claudeCli)&&d("claude-cli"),style:{opacity:i!=null&&i.claudeCli?1:.4},children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-lg",children:i!=null&&i.claudeCli?"✅":"❌"}),l.jsxs("div",{children:[l.jsx("div",{className:"font-medium text-sm",children:"Claude Code CLI"}),l.jsx("div",{className:"text-xs opacity-70",children:i!=null&&i.claudeCli?"Detected! Recommended — zero config needed.":"Not installed. Get it at claude.ai/download"})]})]})}),l.jsxs("div",{className:Kt(u==="direct-api"),onClick:()=>d("direct-api"),children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-lg",children:i!=null&&i.apiKey?"✅":"🔑"}),l.jsxs("div",{className:"flex-1",children:[l.jsx("div",{className:"font-medium text-sm",children:"Anthropic API Key (BYOK)"}),l.jsx("div",{className:"text-xs opacity-70",children:i!=null&&i.apiKey?"API key found in environment.":"Enter your ANTHROPIC_API_KEY"})]})]}),u==="direct-api"&&!(i!=null&&i.apiKey)&&l.jsx("input",{type:"password",className:`${rt} mt-3`,placeholder:"sk-ant-...",value:f,onChange:ke=>m(ke.target.value),autoFocus:!0})]})]})]}),at==="company"&&l.jsxs("div",{className:"space-y-4",children:[l.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"Company"}),l.jsxs("div",{children:[l.jsx("label",{className:"text-xs font-medium block mb-1",style:{color:"var(--terminal-text-secondary)"},children:"Company Name *"}),l.jsx("input",{ref:E,className:rt,placeholder:"e.g. Acme Corp",value:g,onChange:ke=>v(ke.target.value)})]}),l.jsxs("div",{children:[l.jsx("label",{className:"text-xs font-medium block mb-1",style:{color:"var(--terminal-text-secondary)"},children:"Description"}),l.jsx("textarea",{className:`${rt} resize-none`,rows:3,placeholder:"What does your AI company do?",value:b,onChange:ke=>j(ke.target.value)})]}),l.jsxs("div",{children:[l.jsx("label",{className:"text-xs font-medium block mb-1",style:{color:"var(--terminal-text-secondary)"},children:"AI Response Language"}),l.jsxs("select",{className:rt,value:k,onChange:ke=>N(ke.target.value),children:[l.jsx("option",{value:"en",children:"English"}),l.jsx("option",{value:"ko",children:"한국어"}),l.jsx("option",{value:"ja",children:"日本語"})]})]})]}),at==="workspace"&&l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"Workspace"}),l.jsx(np,{text:`"New Company" creates a fresh workspace with roles, knowledge base, and project structure.
|
|
105
|
+
|
|
106
|
+
"Connect Existing" links to an existing Tycono workspace you've set up before.`})]}),l.jsxs("div",{className:"flex rounded-lg overflow-hidden",style:{border:"1px solid var(--terminal-border)"},children:[l.jsx("button",{className:"flex-1 px-3 py-2 text-xs font-medium transition-colors",style:{background:C==="new"?"var(--accent)":"var(--hud-bg-alt)",color:C==="new"?"#fff":"var(--terminal-text-muted)"},onClick:()=>_("new"),children:"New Company"}),l.jsx("button",{className:"flex-1 px-3 py-2 text-xs font-medium transition-colors",style:{background:C==="existing-akb"?"var(--accent)":"var(--hud-bg-alt)",color:C==="existing-akb"?"#fff":"var(--terminal-text-muted)",borderLeft:"1px solid var(--terminal-border)"},onClick:()=>_("existing-akb"),children:"Connect Existing"})]}),C==="new"?l.jsxs("div",{className:"space-y-3",children:[l.jsxs(Sy,{icon:"📁",title:"Company Location",hint:"Where your AI company files will be created.",help:"Roles, knowledge, decisions, and project files are stored here. This is your AI company's home directory. Auto-generated from your company name — change it if needed.",children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{className:`${rt} flex-1`,placeholder:"/path/to/your-company",value:R,onChange:ke=>{L(ke.target.value),X(!0)}}),l.jsx("button",{onClick:()=>$(!A),className:"px-3 py-2 rounded text-xs font-medium transition-colors shrink-0 cursor-pointer hover:brightness-125",style:{background:"var(--terminal-surface)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},title:"Browse folders",children:"📁"})]}),A&&l.jsx(Mu,{onSelect:ke=>{L(ke),X(!0),$(!1)},onClose:()=>$(!1)})]}),l.jsxs(Cy,{icon:"💻",title:"Code Repository",hint:"Connect a separate code repo.",help:`Link your existing code repo so AI roles can read and write code there.
|
|
107
|
+
|
|
108
|
+
Skip this if you don't have a codebase yet — you can connect one later from Settings.`,tag:"optional",open:q,onToggle:()=>W(!q),children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{className:`${rt} flex-1`,placeholder:"/path/to/code/repo",value:ie,onChange:ke=>P(ke.target.value)}),l.jsx("button",{onClick:()=>oe(!Y),className:"px-3 py-2 rounded text-xs font-medium transition-colors shrink-0 cursor-pointer hover:brightness-125",style:{background:"var(--terminal-surface)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},title:"Browse folders",children:"📁"})]}),Y&&l.jsx(Mu,{onSelect:ke=>{P(ke),oe(!1)},onClose:()=>oe(!1)})]}),l.jsxs(Cy,{icon:"📚",title:"Knowledge Import",hint:"Import existing documents into knowledge base.",help:`Point to folders with docs (.md, .txt, etc.) — AI will read, summarize, and organize them into a searchable knowledge base.
|
|
109
|
+
|
|
110
|
+
Skip this to start with an empty knowledge base. You can import documents anytime from the office.`,tag:"optional",open:de,onToggle:()=>G(!de),children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{className:`${rt} flex-1`,placeholder:"/path/to/docs",value:U,onChange:ke=>T(ke.target.value),onKeyDown:ke=>{ke.key==="Enter"&&(ke.preventDefault(),Bt())}}),l.jsx("button",{onClick:()=>ge(!se),className:"px-3 py-2 rounded text-xs font-medium transition-colors shrink-0 cursor-pointer hover:brightness-125",style:{background:"var(--terminal-surface)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},title:"Browse folders",children:"📁"}),l.jsx("button",{onClick:Bt,disabled:!U.trim(),className:"px-3 py-2 rounded text-xs font-medium shrink-0",style:{background:"var(--accent)",color:"#fff",opacity:U.trim()?1:.5},children:"Add"})]}),se&&l.jsx(Mu,{onSelect:ke=>{D.includes(ke)||B([...D,ke]),ge(!1)},onClose:()=>ge(!1)}),D.length>0&&l.jsx("div",{className:"space-y-1 mt-2",children:D.map((ke,kt)=>l.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded text-xs",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},children:[l.jsx("span",{className:"flex-1 truncate",style:{fontFamily:"var(--pixel-font)"},children:ke}),l.jsx("button",{onClick:()=>B(D.filter((jn,hn)=>hn!==kt)),className:"opacity-50 hover:opacity-100",children:"✕"})]},kt))})]})]}):l.jsx("div",{className:"space-y-3",children:l.jsxs(Sy,{icon:"🔗",title:"AKB Path",hint:"Directory with existing CLAUDE.md and AKB structure.",help:"Connect to a directory that was previously set up with Tycono. It must contain a CLAUDE.md file. All existing roles, knowledge, and settings will be loaded.",children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{className:`${rt} flex-1`,placeholder:"/path/to/your/akb",value:pe,onChange:ke=>{Re(ke.target.value),He(null)},autoFocus:!0}),l.jsx("button",{onClick:()=>Ee(!tt),className:"px-3 py-2 rounded text-xs font-medium transition-colors shrink-0 cursor-pointer hover:brightness-125",style:{background:"var(--terminal-surface)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},title:"Browse folders",children:"📁"}),l.jsx("button",{onClick:_t,disabled:ot||!pe.trim(),className:"px-3 py-2 rounded text-xs font-medium transition-colors shrink-0",style:{background:"var(--accent)",color:"#fff",opacity:ot||!pe.trim()?.5:1},children:ot?"...":"Verify"})]}),Ie===!0&&l.jsxs("div",{className:"text-xs mt-2",style:{color:"var(--active-green)"},children:["✅"," Valid AKB found"]}),Ie===!1&&l.jsxs("div",{className:"text-xs mt-2",style:{color:"#EF4444"},children:["❌"," No valid AKB (CLAUDE.md required)"]}),tt&&l.jsx(Mu,{onSelect:ke=>{Re(ke),He(null),Ee(!1)},onClose:()=>Ee(!1)})]})})]}),at==="team"&&l.jsxs("div",{className:"space-y-4",children:[l.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"Team Template"}),l.jsx("p",{className:"text-xs",style:{color:"var(--terminal-text-secondary)"},children:"Choose a starting team. You can add or remove roles later."}),Ae.map(ke=>l.jsxs("div",{className:Kt(dt===ke.id),onClick:()=>xt(ke.id),children:[l.jsx("div",{className:"font-medium text-sm capitalize",children:ke.id}),l.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:ke.roles.map(kt=>l.jsx("span",{className:"px-2 py-0.5 rounded text-[10px]",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},children:kt.id.toUpperCase()},kt.id))})]},ke.id)),l.jsxs("div",{className:Kt(dt==="custom"),onClick:()=>xt("custom"),children:[l.jsx("div",{className:"font-medium text-sm",children:"Custom"}),l.jsx("div",{className:"text-xs opacity-70 mt-1",children:"Start with no pre-built roles. Hire them from the office."})]})]}),at==="create"&&l.jsxs("div",{className:"space-y-4",children:[l.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:Tt?C==="existing-akb"?"AKB Connected!":"Company Created!":"Review & Create"}),!Tt&&!jt&&!ne&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"rounded-lg p-4 space-y-2 text-xs",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)",fontFamily:"var(--pixel-font)"},children:C==="existing-akb"?l.jsxs(l.Fragment,{children:[l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Mode:"})," Connect Existing AKB"]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Path:"})," ",pe]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Engine:"})," ",u==="claude-cli"?"Claude Code CLI":"Direct API"]})]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Company:"})," ",g]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Location:"})," ",R||"(default)"]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Engine:"})," ",u==="claude-cli"?"Claude Code CLI":"Direct API"]}),ie.trim()&&l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Code Repo:"})," ",ie]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Knowledge:"})," ",D.length>0?`Import ${D.length} source(s)`:"Fresh (empty)"]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Team:"})," ",dt]}),D.length>0&&l.jsx("div",{className:"text-[10px] mt-1",style:{color:"var(--idle-amber)"},children:"Knowledge import will run in the background after entering the office."})]})}),Bn&&l.jsx("div",{className:"text-xs p-3 rounded",style:{background:"rgba(220,38,38,0.15)",color:"#f87171"},children:Bn})]}),(jt||ne)&&l.jsxs("div",{className:"flex flex-col items-center py-8 gap-3",children:[l.jsx("div",{className:"w-8 h-8 border-2 rounded-full animate-spin",style:{borderColor:"var(--terminal-border)",borderTopColor:"var(--accent)"}}),l.jsx("div",{className:"text-sm",style:{color:"var(--terminal-text-secondary)"},children:ne?"Connecting to AKB...":"Scaffolding your company..."})]}),Tt&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"text-center py-4 text-4xl",children:"🏢"}),K&&l.jsxs("div",{className:"rounded-lg p-3 text-xs",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)",fontFamily:"var(--pixel-font)"},children:[l.jsx("span",{className:"opacity-50",children:"Location:"})," ",K]}),l.jsx("div",{className:"rounded-lg p-4 text-xs max-h-40 overflow-y-auto",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)",fontFamily:"var(--pixel-font)"},children:Se.map((ke,kt)=>l.jsxs("div",{className:"py-0.5",children:[l.jsx("span",{style:{color:"var(--active-green)"},children:"✓"})," ",ke]},kt))}),(we||_e.length>0)&&l.jsxs("div",{className:"rounded-lg p-4 text-xs space-y-1",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)",fontFamily:"var(--pixel-font)"},children:[l.jsx("div",{className:"font-medium mb-2",style:{color:"var(--terminal-text-secondary)"},children:we?"Installing skill tools...":"Skill tools"}),_e.map((ke,kt)=>l.jsxs("div",{className:"py-0.5 flex items-center gap-2",children:[l.jsx("span",{style:{color:ke.event==="installed"||ke.event==="skipped"?"var(--active-green)":ke.event==="error"?"#f87171":"var(--terminal-text-muted)"},children:ke.event==="installed"||ke.event==="skipped"?"✓":ke.event==="error"?"✗":"…"}),l.jsx("span",{children:ke.tool}),l.jsx("span",{style:{color:"var(--terminal-text-muted)"},children:ke.detail})]},kt)),we&&l.jsxs("div",{className:"flex items-center gap-2 mt-1",style:{color:"var(--terminal-text-muted)"},children:[l.jsx("div",{className:"w-3 h-3 border border-current rounded-full animate-spin",style:{borderTopColor:"var(--accent)"}}),l.jsx("span",{children:"Please wait..."})]})]}),D.length>0&&l.jsx("div",{className:"text-xs p-3 rounded",style:{background:"var(--accent)",color:"#fff",opacity:.9},children:"Knowledge import will start in the background after entering the office."})]})]})]}),l.jsxs("div",{className:"px-6 py-4 flex justify-between items-center",style:{borderTop:"1px solid var(--terminal-border)"},children:[l.jsx("div",{children:n>0&&!Tt&&l.jsx("button",{onClick:Me,className:"px-4 py-2 rounded text-sm transition-colors",style:{color:"var(--terminal-text-secondary)",border:"1px solid var(--terminal-border)"},children:"Back"})}),l.jsxs("div",{className:"text-xs",style:{color:"var(--terminal-text-muted)"},children:[n+1," / ",qe.length]}),l.jsx("div",{children:Tt?l.jsx("button",{onClick:J,disabled:we,className:"px-5 py-2 rounded text-sm font-medium transition-colors",style:{background:"var(--active-green)",color:"#fff",opacity:we?.5:1},children:we?"Setting up tools...":"Enter Office"}):l.jsx("button",{onClick:bt,disabled:!Ke()||jt||ne,className:"px-5 py-2 rounded text-sm font-medium transition-colors",style:{background:Ke()?"var(--accent)":"var(--terminal-border)",color:"#fff",opacity:Ke()&&!jt&&!ne?1:.5},children:at==="create"?jt||ne?ne?"Connecting...":"Creating...":C==="existing-akb"?"Connect AKB":"Create Company":"Next"})})]})]})})}function np({text:e}){const[n,a]=w.useState(!1),[i,o]=w.useState({top:0,left:0}),u=w.useRef(null),d=()=>{if(u.current){const f=u.current.getBoundingClientRect();o({top:f.bottom+6,left:f.left})}a(!0)};return l.jsxs("span",{className:"inline-flex",ref:u,children:[l.jsx("span",{className:"w-4 h-4 rounded-full text-[9px] font-bold flex items-center justify-center cursor-help shrink-0 select-none",style:{background:"var(--terminal-surface)",color:"var(--terminal-text-muted)",border:"1px solid var(--terminal-border)"},onMouseEnter:d,onMouseLeave:()=>a(!1),onClick:f=>{f.stopPropagation(),n?a(!1):d()},children:"?"}),n&&l.jsxs("div",{className:"fixed z-[9999] px-3 py-2 rounded-lg text-[11px] leading-relaxed whitespace-pre-line w-60 shadow-lg pointer-events-none",style:{top:i.top,left:Math.min(i.left,window.innerWidth-260),background:"var(--terminal-bg)",color:"var(--terminal-text-secondary)",border:"1px solid var(--terminal-border)"},children:[l.jsx("div",{className:"absolute bottom-full w-0 h-0",style:{left:8,borderLeft:"5px solid transparent",borderRight:"5px solid transparent",borderBottom:"5px solid var(--terminal-border)"}}),e]})]})}function Sy({icon:e,title:n,hint:a,help:i,children:o}){return l.jsxs("div",{className:"rounded-lg p-3 space-y-2",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm",children:e}),l.jsx("span",{className:"text-xs font-medium",style:{color:"var(--terminal-text)"},children:n}),i&&l.jsx(np,{text:i})]}),l.jsx("div",{className:"text-[10px] mt-0.5 ml-6",style:{color:"var(--terminal-text-muted)"},children:a})]}),o]})}function Cy({icon:e,title:n,hint:a,help:i,tag:o,open:u,onToggle:d,children:f}){return l.jsxs("div",{className:"rounded-lg",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"p-3 cursor-pointer flex items-center gap-2 hover:bg-[var(--terminal-surface-light)] transition-colors",onClick:d,children:[l.jsx("span",{className:"text-sm",children:e}),l.jsx("span",{className:"text-xs font-medium flex-1",style:{color:"var(--terminal-text)"},children:n}),i&&l.jsx(np,{text:i}),o&&l.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded",style:{background:"var(--terminal-surface)",color:"var(--terminal-text-muted)"},children:o}),l.jsx("span",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:u?"▲":"▼"})]}),!u&&l.jsx("div",{className:"px-3 pb-2 -mt-1",children:l.jsx("div",{className:"text-[10px] ml-6",style:{color:"var(--terminal-text-muted)"},children:a})}),u&&l.jsx("div",{className:"px-3 pb-3 space-y-2",children:f})]})}function I8(){const[e,n]=w.useState(null),[a,i]=w.useState(!0),[o,u]=w.useState(null),d=w.useCallback(async()=>{i(!0),u(null);try{const f=await ye.getStatus();n(f)}catch(f){u(f instanceof Error?f.message:"Failed to fetch status")}finally{i(!1)}},[]);return w.useEffect(()=>{d()},[d]),{initialized:(e==null?void 0:e.initialized)??!1,companyName:(e==null?void 0:e.companyName)??null,engine:(e==null?void 0:e.engine)??"none",companyRoot:(e==null?void 0:e.companyRoot)??"",loading:a,error:o,refetch:d}}const H8=w.lazy(()=>Ny(()=>import("./preview-app-RTesSYsM.js"),[]));function Bv(){return l.jsx("div",{className:"h-full flex items-center justify-center",style:{background:"var(--floor-dark)"},children:l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"w-10 h-10 mx-auto border-2 rounded-full animate-spin",style:{borderColor:"var(--terminal-border)",borderTopColor:"var(--accent)"}}),l.jsx("div",{className:"mt-4 text-sm",style:{color:"var(--terminal-text-secondary)",fontFamily:"var(--pixel-font)"},children:"Loading..."})]})})}function U8(){var e;try{const n=localStorage.getItem("tycono-theme"),a=n&&n in il?n:"default",i=(e=il[a])==null?void 0:e.vars;if(!i)return;const o=document.documentElement;for(const[u,d]of Object.entries(i))o.style.setProperty(u,d)}catch{}}function q8(){const{initialized:e,loading:n,refetch:a}=I8(),[i,o]=w.useState(null);w.useEffect(()=>{U8()},[]);const u=d=>{d&&o(d),a()};return n?l.jsx(Bv,{}):e?l.jsx(O8,{importJob:i,onImportDone:()=>o(null)}):l.jsx(L8,{onComplete:u})}function Y8(){const e=new URLSearchParams(window.location.search).has("sprite-preview");return l.jsx(Ew,{children:e?l.jsx(w.Suspense,{fallback:l.jsx(Bv,{}),children:l.jsx(H8,{})}):l.jsx(q8,{})})}jw.createRoot(document.getElementById("root")).render(l.jsx(w.StrictMode,{children:l.jsx(Y8,{})}));export{hv as H,pv as P,xv as S,G8 as a,mv as b,fv as c,lm as d,aC as e,W8 as f,V8 as g,K8 as h,l as j,w as r};
|