tycono 0.1.72 → 0.1.73

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,109 +0,0 @@
1
- var hw=Object.defineProperty;var mw=(e,n,a)=>n in e?hw(e,n,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[n]=a;var C0=(e,n,a)=>mw(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 Dg(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Qf={exports:{}},mo={};/**
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 N0;function pw(){if(N0)return mo;N0=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 h in o)h!=="key"&&(u[h]=o[h])}else u=o;return o=u.ref,{$$typeof:e,type:i,key:d,ref:o!==void 0?o:null,props:u}}return mo.Fragment=n,mo.jsx=a,mo.jsxs=a,mo}var E0;function xw(){return E0||(E0=1,Qf.exports=pw()),Qf.exports}var l=xw(),Pf={exports:{}},ut={};/**
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 A0;function yw(){if(A0)return ut;A0=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"),h=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),y=Symbol.for("react.activity"),v=Symbol.iterator;function b(F){return F===null||typeof F!="object"?null:(F=v&&F[v]||F["@@iterator"],typeof F=="function"?F:null)}var j={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,N={};function S(F,W,A){this.props=F,this.context=W,this.refs=N,this.updater=A||j}S.prototype.isReactComponent={},S.prototype.setState=function(F,W){if(typeof F!="object"&&typeof F!="function"&&F!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,F,W,"setState")},S.prototype.forceUpdate=function(F){this.updater.enqueueForceUpdate(this,F,"forceUpdate")};function E(){}E.prototype=S.prototype;function _(F,W,A){this.props=F,this.context=W,this.refs=N,this.updater=A||j}var R=_.prototype=new E;R.constructor=_,k(R,S.prototype),R.isPureReactComponent=!0;var I=Array.isArray;function B(){}var $={H:null,A:null,T:null,S:null},q=Object.prototype.hasOwnProperty;function G(F,W,A){var Q=A.ref;return{$$typeof:e,type:F,key:W,ref:Q!==void 0?Q:null,props:A}}function T(F,W){return G(F.type,W,F.props)}function H(F){return typeof F=="object"&&F!==null&&F.$$typeof===e}function L(F){var W={"=":"=0",":":"=2"};return"$"+F.replace(/[=:]/g,function(A){return W[A]})}var J=/\/+/g;function ce(F,W){return typeof F=="object"&&F!==null&&F.key!=null?L(""+F.key):W.toString(36)}function re(F){switch(F.status){case"fulfilled":return F.value;case"rejected":throw F.reason;default:switch(typeof F.status=="string"?F.then(B,B):(F.status="pending",F.then(function(W){F.status==="pending"&&(F.status="fulfilled",F.value=W)},function(W){F.status==="pending"&&(F.status="rejected",F.reason=W)})),F.status){case"fulfilled":return F.value;case"rejected":throw F.reason}}throw F}function X(F,W,A,Q,ie){var he=typeof F;(he==="undefined"||he==="boolean")&&(F=null);var Ne=!1;if(F===null)Ne=!0;else switch(he){case"bigint":case"string":case"number":Ne=!0;break;case"object":switch(F.$$typeof){case e:case n:Ne=!0;break;case x:return Ne=F._init,X(Ne(F._payload),W,A,Q,ie)}}if(Ne)return ie=ie(F),Ne=Q===""?"."+ce(F,0):Q,I(ie)?(A="",Ne!=null&&(A=Ne.replace(J,"$&/")+"/"),X(ie,W,A,"",function(_e){return _e})):ie!=null&&(H(ie)&&(ie=T(ie,A+(ie.key==null||F&&F.key===ie.key?"":(""+ie.key).replace(J,"$&/")+"/")+Ne)),W.push(ie)),1;Ne=0;var Ie=Q===""?".":Q+":";if(I(F))for(var de=0;de<F.length;de++)Q=F[de],he=Ie+ce(Q,de),Ne+=X(Q,W,A,he,ie);else if(de=b(F),typeof de=="function")for(F=de.call(F),de=0;!(Q=F.next()).done;)Q=Q.value,he=Ie+ce(Q,de++),Ne+=X(Q,W,A,he,ie);else if(he==="object"){if(typeof F.then=="function")return X(re(F),W,A,Q,ie);throw W=String(F),Error("Objects are not valid as a React child (found: "+(W==="[object Object]"?"object with keys {"+Object.keys(F).join(", ")+"}":W)+"). If you meant to render a collection of children, use an array instead.")}return Ne}function le(F,W,A){if(F==null)return F;var Q=[],ie=0;return X(F,Q,"","",function(he){return W.call(A,he,ie++)}),Q}function ee(F){if(F._status===-1){var W=F._result;W=W(),W.then(function(A){(F._status===0||F._status===-1)&&(F._status=1,F._result=A)},function(A){(F._status===0||F._status===-1)&&(F._status=2,F._result=A)}),F._status===-1&&(F._status=0,F._result=W)}if(F._status===1)return F._result.default;throw F._result}var Z=typeof reportError=="function"?reportError:function(F){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var W=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof F=="object"&&F!==null&&typeof F.message=="string"?String(F.message):String(F),error:F});if(!window.dispatchEvent(W))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",F);return}console.error(F)},D={map:le,forEach:function(F,W,A){le(F,function(){W.apply(this,arguments)},A)},count:function(F){var W=0;return le(F,function(){W++}),W},toArray:function(F){return le(F,function(W){return W})||[]},only:function(F){if(!H(F))throw Error("React.Children.only expected to receive a single React element child.");return F}};return ut.Activity=y,ut.Children=D,ut.Component=S,ut.Fragment=a,ut.Profiler=o,ut.PureComponent=_,ut.StrictMode=i,ut.Suspense=m,ut.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=$,ut.__COMPILER_RUNTIME={__proto__:null,c:function(F){return $.H.useMemoCache(F)}},ut.cache=function(F){return function(){return F.apply(null,arguments)}},ut.cacheSignal=function(){return null},ut.cloneElement=function(F,W,A){if(F==null)throw Error("The argument must be a React element, but you passed "+F+".");var Q=k({},F.props),ie=F.key;if(W!=null)for(he in W.key!==void 0&&(ie=""+W.key),W)!q.call(W,he)||he==="key"||he==="__self"||he==="__source"||he==="ref"&&W.ref===void 0||(Q[he]=W[he]);var he=arguments.length-2;if(he===1)Q.children=A;else if(1<he){for(var Ne=Array(he),Ie=0;Ie<he;Ie++)Ne[Ie]=arguments[Ie+2];Q.children=Ne}return G(F.type,ie,Q)},ut.createContext=function(F){return F={$$typeof:d,_currentValue:F,_currentValue2:F,_threadCount:0,Provider:null,Consumer:null},F.Provider=F,F.Consumer={$$typeof:u,_context:F},F},ut.createElement=function(F,W,A){var Q,ie={},he=null;if(W!=null)for(Q in W.key!==void 0&&(he=""+W.key),W)q.call(W,Q)&&Q!=="key"&&Q!=="__self"&&Q!=="__source"&&(ie[Q]=W[Q]);var Ne=arguments.length-2;if(Ne===1)ie.children=A;else if(1<Ne){for(var Ie=Array(Ne),de=0;de<Ne;de++)Ie[de]=arguments[de+2];ie.children=Ie}if(F&&F.defaultProps)for(Q in Ne=F.defaultProps,Ne)ie[Q]===void 0&&(ie[Q]=Ne[Q]);return G(F,he,ie)},ut.createRef=function(){return{current:null}},ut.forwardRef=function(F){return{$$typeof:h,render:F}},ut.isValidElement=H,ut.lazy=function(F){return{$$typeof:x,_payload:{_status:-1,_result:F},_init:ee}},ut.memo=function(F,W){return{$$typeof:f,type:F,compare:W===void 0?null:W}},ut.startTransition=function(F){var W=$.T,A={};$.T=A;try{var Q=F(),ie=$.S;ie!==null&&ie(A,Q),typeof Q=="object"&&Q!==null&&typeof Q.then=="function"&&Q.then(B,Z)}catch(he){Z(he)}finally{W!==null&&A.types!==null&&(W.types=A.types),$.T=W}},ut.unstable_useCacheRefresh=function(){return $.H.useCacheRefresh()},ut.use=function(F){return $.H.use(F)},ut.useActionState=function(F,W,A){return $.H.useActionState(F,W,A)},ut.useCallback=function(F,W){return $.H.useCallback(F,W)},ut.useContext=function(F){return $.H.useContext(F)},ut.useDebugValue=function(){},ut.useDeferredValue=function(F,W){return $.H.useDeferredValue(F,W)},ut.useEffect=function(F,W){return $.H.useEffect(F,W)},ut.useEffectEvent=function(F){return $.H.useEffectEvent(F)},ut.useId=function(){return $.H.useId()},ut.useImperativeHandle=function(F,W,A){return $.H.useImperativeHandle(F,W,A)},ut.useInsertionEffect=function(F,W){return $.H.useInsertionEffect(F,W)},ut.useLayoutEffect=function(F,W){return $.H.useLayoutEffect(F,W)},ut.useMemo=function(F,W){return $.H.useMemo(F,W)},ut.useOptimistic=function(F,W){return $.H.useOptimistic(F,W)},ut.useReducer=function(F,W,A){return $.H.useReducer(F,W,A)},ut.useRef=function(F){return $.H.useRef(F)},ut.useState=function(F){return $.H.useState(F)},ut.useSyncExternalStore=function(F,W,A){return $.H.useSyncExternalStore(F,W,A)},ut.useTransition=function(){return $.H.useTransition()},ut.version="19.2.4",ut}var D0;function bm(){return D0||(D0=1,Pf.exports=yw()),Pf.exports}var w=bm(),Zf={exports:{}},po={},Jf={exports:{}},eh={};/**
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 T0;function gw(){return T0||(T0=1,(function(e){function n(X,le){var ee=X.length;X.push(le);e:for(;0<ee;){var Z=ee-1>>>1,D=X[Z];if(0<o(D,le))X[Z]=le,X[ee]=D,ee=Z;else break e}}function a(X){return X.length===0?null:X[0]}function i(X){if(X.length===0)return null;var le=X[0],ee=X.pop();if(ee!==le){X[0]=ee;e:for(var Z=0,D=X.length,F=D>>>1;Z<F;){var W=2*(Z+1)-1,A=X[W],Q=W+1,ie=X[Q];if(0>o(A,ee))Q<D&&0>o(ie,A)?(X[Z]=ie,X[Q]=ee,Z=Q):(X[Z]=A,X[W]=ee,Z=W);else if(Q<D&&0>o(ie,ee))X[Z]=ie,X[Q]=ee,Z=Q;else break e}}return le}function o(X,le){var ee=X.sortIndex-le.sortIndex;return ee!==0?ee:X.id-le.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,h=d.now();e.unstable_now=function(){return d.now()-h}}var m=[],f=[],x=1,y=null,v=3,b=!1,j=!1,k=!1,N=!1,S=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,_=typeof setImmediate<"u"?setImmediate:null;function R(X){for(var le=a(f);le!==null;){if(le.callback===null)i(f);else if(le.startTime<=X)i(f),le.sortIndex=le.expirationTime,n(m,le);else break;le=a(f)}}function I(X){if(k=!1,R(X),!j)if(a(m)!==null)j=!0,B||(B=!0,L());else{var le=a(f);le!==null&&re(I,le.startTime-X)}}var B=!1,$=-1,q=5,G=-1;function T(){return N?!0:!(e.unstable_now()-G<q)}function H(){if(N=!1,B){var X=e.unstable_now();G=X;var le=!0;try{e:{j=!1,k&&(k=!1,E($),$=-1),b=!0;var ee=v;try{t:{for(R(X),y=a(m);y!==null&&!(y.expirationTime>X&&T());){var Z=y.callback;if(typeof Z=="function"){y.callback=null,v=y.priorityLevel;var D=Z(y.expirationTime<=X);if(X=e.unstable_now(),typeof D=="function"){y.callback=D,R(X),le=!0;break t}y===a(m)&&i(m),R(X)}else i(m);y=a(m)}if(y!==null)le=!0;else{var F=a(f);F!==null&&re(I,F.startTime-X),le=!1}}break e}finally{y=null,v=ee,b=!1}le=void 0}}finally{le?L():B=!1}}}var L;if(typeof _=="function")L=function(){_(H)};else if(typeof MessageChannel<"u"){var J=new MessageChannel,ce=J.port2;J.port1.onmessage=H,L=function(){ce.postMessage(null)}}else L=function(){S(H,0)};function re(X,le){$=S(function(){X(e.unstable_now())},le)}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(X){X.callback=null},e.unstable_forceFrameRate=function(X){0>X||125<X?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):q=0<X?Math.floor(1e3/X):5},e.unstable_getCurrentPriorityLevel=function(){return v},e.unstable_next=function(X){switch(v){case 1:case 2:case 3:var le=3;break;default:le=v}var ee=v;v=le;try{return X()}finally{v=ee}},e.unstable_requestPaint=function(){N=!0},e.unstable_runWithPriority=function(X,le){switch(X){case 1:case 2:case 3:case 4:case 5:break;default:X=3}var ee=v;v=X;try{return le()}finally{v=ee}},e.unstable_scheduleCallback=function(X,le,ee){var Z=e.unstable_now();switch(typeof ee=="object"&&ee!==null?(ee=ee.delay,ee=typeof ee=="number"&&0<ee?Z+ee:Z):ee=Z,X){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=ee+D,X={id:x++,callback:le,priorityLevel:X,startTime:ee,expirationTime:D,sortIndex:-1},ee>Z?(X.sortIndex=ee,n(f,X),a(m)===null&&X===a(f)&&(k?(E($),$=-1):k=!0,re(I,ee-Z))):(X.sortIndex=D,n(m,X),j||b||(j=!0,B||(B=!0,L()))),X},e.unstable_shouldYield=T,e.unstable_wrapCallback=function(X){var le=v;return function(){var ee=v;v=le;try{return X.apply(this,arguments)}finally{v=ee}}}})(eh)),eh}var F0;function bw(){return F0||(F0=1,Jf.exports=gw()),Jf.exports}var th={exports:{}},Kn={};/**
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 M0;function vw(){if(M0)return Kn;M0=1;var e=bm();function n(m){var f="https://react.dev/errors/"+m;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var x=2;x<arguments.length;x++)f+="&args[]="+encodeURIComponent(arguments[x])}return"Minified React error #"+m+"; visit "+f+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function 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,f,x){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:y==null?null:""+y,children:m,containerInfo:f,implementation:x}}var d=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(m,f){if(m==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return Kn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,Kn.createPortal=function(m,f){var x=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)throw Error(n(299));return u(m,f,null,x)},Kn.flushSync=function(m){var f=d.T,x=i.p;try{if(d.T=null,i.p=2,m)return m()}finally{d.T=f,i.p=x,i.d.f()}},Kn.preconnect=function(m,f){typeof m=="string"&&(f?(f=f.crossOrigin,f=typeof f=="string"?f==="use-credentials"?f:"":void 0):f=null,i.d.C(m,f))},Kn.prefetchDNS=function(m){typeof m=="string"&&i.d.D(m)},Kn.preinit=function(m,f){if(typeof m=="string"&&f&&typeof f.as=="string"){var x=f.as,y=h(x,f.crossOrigin),v=typeof f.integrity=="string"?f.integrity:void 0,b=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;x==="style"?i.d.S(m,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:y,integrity:v,fetchPriority:b}):x==="script"&&i.d.X(m,{crossOrigin:y,integrity:v,fetchPriority:b,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},Kn.preinitModule=function(m,f){if(typeof m=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var x=h(f.as,f.crossOrigin);i.d.M(m,{crossOrigin:x,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0})}}else f==null&&i.d.M(m)},Kn.preload=function(m,f){if(typeof m=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var x=f.as,y=h(x,f.crossOrigin);i.d.L(m,x,{crossOrigin:y,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0,type:typeof f.type=="string"?f.type:void 0,fetchPriority:typeof f.fetchPriority=="string"?f.fetchPriority:void 0,referrerPolicy:typeof f.referrerPolicy=="string"?f.referrerPolicy:void 0,imageSrcSet:typeof f.imageSrcSet=="string"?f.imageSrcSet:void 0,imageSizes:typeof f.imageSizes=="string"?f.imageSizes:void 0,media:typeof f.media=="string"?f.media:void 0})}},Kn.preloadModule=function(m,f){if(typeof m=="string")if(f){var x=h(f.as,f.crossOrigin);i.d.m(m,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:x,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else i.d.m(m)},Kn.requestFormReset=function(m){i.d.r(m)},Kn.unstable_batchedUpdates=function(m,f){return m(f)},Kn.useFormState=function(m,f,x){return d.H.useFormState(m,f,x)},Kn.useFormStatus=function(){return d.H.useHostTransitionStatus()},Kn.version="19.2.4",Kn}var R0;function ww(){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=vw(),th.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 z0;function kw(){if(z0)return po;z0=1;var e=bw(),n=bm(),a=ww();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 h(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 f(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 g=p.alternate;if(g===null){if(c=p.return,c!==null){s=c;continue}break}if(p.child===g.child){for(g=p.child;g;){if(g===s)return m(p),t;if(g===c)return m(p),r;g=g.sibling}throw Error(i(188))}if(s.return!==c.return)s=p,c=g;else{for(var C=!1,z=p.child;z;){if(z===s){C=!0,s=p,c=g;break}if(z===c){C=!0,c=p,s=g;break}z=z.sibling}if(!C){for(z=g.child;z;){if(z===s){C=!0,s=g,c=p;break}if(z===c){C=!0,c=g,s=p;break}z=z.sibling}if(!C)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 y=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"),S=Symbol.for("react.profiler"),E=Symbol.for("react.consumer"),_=Symbol.for("react.context"),R=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),B=Symbol.for("react.suspense_list"),$=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),G=Symbol.for("react.activity"),T=Symbol.for("react.memo_cache_sentinel"),H=Symbol.iterator;function L(t){return t===null||typeof t!="object"?null:(t=H&&t[H]||t["@@iterator"],typeof t=="function"?t:null)}var J=Symbol.for("react.client.reference");function ce(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===J?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case k:return"Fragment";case S:return"Profiler";case N:return"StrictMode";case I:return"Suspense";case B:return"SuspenseList";case G:return"Activity"}if(typeof t=="object")switch(t.$$typeof){case j:return"Portal";case _:return t.displayName||"Context";case E: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 $:return r=t.displayName||null,r!==null?r:ce(t.type)||"Memo";case q:r=t._payload,t=t._init;try{return ce(t(r))}catch{}}return null}var re=Array.isArray,X=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,le=a.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ee={pending:!1,data:null,method:null,action:null},Z=[],D=-1;function F(t){return{current:t}}function W(t){0>D||(t.current=Z[D],Z[D]=null,D--)}function A(t,r){D++,Z[D]=t.current,t.current=r}var Q=F(null),ie=F(null),he=F(null),Ne=F(null);function Ie(t,r){switch(A(he,r),A(ie,t),A(Q,null),r.nodeType){case 9:case 11:t=(t=r.documentElement)&&(t=t.namespaceURI)?G1(t):0;break;default:if(t=r.tagName,r=r.namespaceURI)r=G1(r),t=K1(r,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}W(Q),A(Q,t)}function de(){W(Q),W(ie),W(he)}function _e(t){t.memoizedState!==null&&A(Ne,t);var r=Q.current,s=K1(r,t.type);r!==s&&(A(ie,t),A(Q,s))}function Ye(t){ie.current===t&&(W(Q),W(ie)),Ne.current===t&&(W(Ne),co._currentValue=ee)}var ge,Je;function Fe(t){if(ge===void 0)try{throw Error()}catch(s){var r=s.stack.trim().match(/\n( *(at )?)/);ge=r&&r[1]||"",Je=-1<s.stack.indexOf(`
42
- at`)?" (<anonymous>)":-1<s.stack.indexOf("@")?"@unknown:0:0":""}return`
43
- `+ge+t+Je}var ct=!1;function Ke(t,r){if(!t||ct)return"";ct=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var c={DetermineComponentFrameRoot:function(){try{if(r){var ke=function(){throw Error()};if(Object.defineProperty(ke.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ke,[])}catch(fe){var ue=fe}Reflect.construct(t,[],ke)}else{try{ke.call()}catch(fe){ue=fe}t.call(ke.prototype)}}else{try{throw Error()}catch(fe){ue=fe}(ke=t())&&typeof ke.catch=="function"&&ke.catch(function(){})}}catch(fe){if(fe&&ue&&typeof fe.stack=="string")return[fe.stack,ue.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 g=c.DetermineComponentFrameRoot(),C=g[0],z=g[1];if(C&&z){var Y=C.split(`
44
- `),oe=z.split(`
45
- `);for(p=c=0;c<Y.length&&!Y[c].includes("DetermineComponentFrameRoot");)c++;for(;p<oe.length&&!oe[p].includes("DetermineComponentFrameRoot");)p++;if(c===Y.length||p===oe.length)for(c=Y.length-1,p=oe.length-1;1<=c&&0<=p&&Y[c]!==oe[p];)p--;for(;1<=c&&0<=p;c--,p--)if(Y[c]!==oe[p]){if(c!==1||p!==1)do if(c--,p--,0>p||Y[c]!==oe[p]){var pe=`
46
- `+Y[c].replace(" at new "," at ");return t.displayName&&pe.includes("<anonymous>")&&(pe=pe.replace("<anonymous>",t.displayName)),pe}while(1<=c&&0<=p);break}}}finally{ct=!1,Error.prepareStackTrace=s}return(s=t?t.displayName||t.name:"")?Fe(s):""}function ot(t,r){switch(t.tag){case 26:case 27:case 5:return Fe(t.type);case 16:return Fe("Lazy");case 13:return t.child!==r&&r!==null?Fe("Suspense Fallback"):Fe("Suspense");case 19:return Fe("SuspenseList");case 0:case 15:return Ke(t.type,!1);case 11:return Ke(t.type.render,!1);case 1:return Ke(t.type,!0);case 31:return Fe("Activity");default:return""}}function xt(t){try{var r="",s=null;do r+=ot(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,bt=e.unstable_scheduleCallback,dt=e.unstable_cancelCallback,gn=e.unstable_shouldYield,ft=e.unstable_requestPaint,Wt=e.unstable_now,we=e.unstable_getCurrentPriorityLevel,U=e.unstable_ImmediatePriority,ae=e.unstable_UserBlockingPriority,me=e.unstable_NormalPriority,Ce=e.unstable_LowPriority,De=e.unstable_IdlePriority,Se=e.log,Be=e.unstable_setDisableYieldValue,$e=null,Re=null;function ze(t){if(typeof Se=="function"&&Be(t),Re&&typeof Re.setStrictMode=="function")try{Re.setStrictMode($e,t)}catch{}}var Oe=Math.clz32?Math.clz32:Le,kt=Math.log,Me=Math.LN2;function Le(t){return t>>>=0,t===0?32:31-(kt(t)/Me|0)|0}var Vt=256,Jt=262144,jt=4194304;function Bt(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 bn(t,r,s){var c=t.pendingLanes;if(c===0)return 0;var p=0,g=t.suspendedLanes,C=t.pingedLanes;t=t.warmLanes;var z=c&134217727;return z!==0?(c=z&~g,c!==0?p=Bt(c):(C&=z,C!==0?p=Bt(C):s||(s=z&~t,s!==0&&(p=Bt(s))))):(z=c&~g,z!==0?p=Bt(z):C!==0?p=Bt(C):s||(s=c&~t,s!==0&&(p=Bt(s)))),p===0?0:r!==0&&r!==p&&(r&g)===0&&(g=p&-p,s=r&-r,g>=s||g===32&&(s&4194048)!==0)?r:p}function P(t,r){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&r)===0}function qe(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 et(){var t=jt;return jt<<=1,(jt&62914560)===0&&(jt=4194304),t}function St(t){for(var r=[],s=0;31>s;s++)r.push(t);return r}function ve(t,r){t.pendingLanes|=r,r!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function yt(t,r,s,c,p,g){var C=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,Y=t.expirationTimes,oe=t.hiddenUpdates;for(s=C&~s;0<s;){var pe=31-Oe(s),ke=1<<pe;z[pe]=0,Y[pe]=-1;var ue=oe[pe];if(ue!==null)for(oe[pe]=null,pe=0;pe<ue.length;pe++){var fe=ue[pe];fe!==null&&(fe.lane&=-536870913)}s&=~ke}c!==0&&sn(t,c,0),g!==0&&p===0&&t.tag!==0&&(t.suspendedLanes|=g&~(C&~r))}function sn(t,r,s){t.pendingLanes|=r,t.suspendedLanes&=~r;var c=31-Oe(r);t.entangledLanes|=r,t.entanglements[c]=t.entanglements[c]|1073741824|s&261930}function en(t,r){var s=t.entangledLanes|=r;for(t=t.entanglements;s;){var c=31-Oe(s),p=1<<c;p&r|t[c]&r&&(t[c]|=r),s&=~p}}function Mr(t,r){var s=r&-r;return s=(s&42)!==0?1:vt(s),(s&(t.suspendedLanes|r))!==0?0:s}function vt(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 Jn(t){return t&=-t,2<t?8<t?(t&134217727)!==0?32:268435456:8:2}function tl(){var t=le.p;return t!==0?t:(t=window.event,t===void 0?32:g0(t.type))}function qo(t,r){var s=le.p;try{return le.p=t,r()}finally{le.p=s}}var yr=Math.random().toString(36).slice(2),Fn="__reactFiber$"+yr,Ln="__reactProps$"+yr,oa="__reactContainer$"+yr,nl="__reactEvents$"+yr,Ju="__reactListeners$"+yr,Ss="__reactHandles$"+yr,Yo="__reactResources$"+yr,Da="__reactMarker$"+yr;function Ci(t){delete t[Fn],delete t[Ln],delete t[nl],delete t[Ju],delete t[Ss]}function ca(t){var r=t[Fn];if(r)return r;for(var s=t.parentNode;s;){if(r=s[oa]||s[Fn]){if(s=r.alternate,r.child!==null||s!==null&&s.child!==null)for(t=n0(t);t!==null;){if(s=t[Fn])return s;t=n0(t)}return r}t=s,s=t.parentNode}return null}function Hn(t){if(t=t[Fn]||t[oa]){var r=t.tag;if(r===5||r===6||r===13||r===31||r===26||r===27||r===3)return t}return null}function Hl(t){var r=t.tag;if(r===5||r===26||r===27||r===6)return t.stateNode;throw Error(i(33))}function gr(t){var r=t[Yo];return r||(r=t[Yo]={hoistableStyles:new Map,hoistableScripts:new Map}),r}function pn(t){t[Da]=!0}var Ta=new Set,Fa={};function lr(t,r){Ma(t,r),Ma(t+"Capture",r)}function Ma(t,r){for(Fa[t]=r,t=0;t<r.length;t++)Ta.add(r[t])}var rl=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]*$"),Cs={},Ns={};function Es(t){return wt.call(Ns,t)?!0:wt.call(Cs,t)?!1:rl.test(t)?Ns[t]=!0:(Cs[t]=!0,!1)}function Ul(t,r,s){if(Es(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 ql(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 Gr(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 jn(t){switch(typeof t){case"bigint":case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function vn(t){var r=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function Kr(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,g=c.set;return Object.defineProperty(t,r,{configurable:!0,get:function(){return p.call(this)},set:function(C){s=""+C,g.call(this,C)}}),Object.defineProperty(t,r,{enumerable:c.enumerable}),{getValue:function(){return s},setValue:function(C){s=""+C},stopTracking:function(){t._valueTracker=null,delete t[r]}}}}function Qr(t){if(!t._valueTracker){var r=vn(t)?"checked":"value";t._valueTracker=Kr(t,r,""+t[r])}}function Rr(t){if(!t)return!1;var r=t._valueTracker;if(!r)return!0;var s=r.getValue(),c="";return t&&(c=vn(t)?t.checked?"true":"false":t.value),t=c,t!==s?(r.setValue(t),!0):!1}function Sn(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 Xo=/[\n"\\]/g;function ir(t){return t.replace(Xo,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function Yl(t,r,s,c,p,g,C,z){t.name="",C!=null&&typeof C!="function"&&typeof C!="symbol"&&typeof C!="boolean"?t.type=C:t.removeAttribute("type"),r!=null?C==="number"?(r===0&&t.value===""||t.value!=r)&&(t.value=""+jn(r)):t.value!==""+jn(r)&&(t.value=""+jn(r)):C!=="submit"&&C!=="reset"||t.removeAttribute("value"),r!=null?ua(t,C,jn(r)):s!=null?ua(t,C,jn(s)):c!=null&&t.removeAttribute("value"),p==null&&g!=null&&(t.defaultChecked=!!g),p!=null&&(t.checked=p&&typeof p!="function"&&typeof p!="symbol"),z!=null&&typeof z!="function"&&typeof z!="symbol"&&typeof z!="boolean"?t.name=""+jn(z):t.removeAttribute("name")}function er(t,r,s,c,p,g,C,z){if(g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"&&(t.type=g),r!=null||s!=null){if(!(g!=="submit"&&g!=="reset"||r!=null)){Qr(t);return}s=s!=null?""+jn(s):"",r=r!=null?""+jn(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,C!=null&&typeof C!="function"&&typeof C!="symbol"&&typeof C!="boolean"&&(t.name=C),Qr(t)}function ua(t,r,s){r==="number"&&Sn(t.ownerDocument)===t||t.defaultValue===""+s||(t.defaultValue=""+s)}function sr(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=""+jn(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 Wo(t,r,s){if(r!=null&&(r=""+jn(r),r!==t.value&&(t.value=r),s==null)){t.defaultValue!==r&&(t.defaultValue=r);return}t.defaultValue=s!=null?""+jn(s):""}function Mn(t,r,s,c){if(r==null){if(c!=null){if(s!=null)throw Error(i(92));if(re(c)){if(1<c.length)throw Error(i(93));c=c[0]}s=c}s==null&&(s=""),r=s}s=jn(r),t.defaultValue=s,c=t.textContent,c===s&&c!==""&&c!==null&&(t.value=c),Qr(t)}function on(t,r){if(r){var s=t.firstChild;if(s&&s===t.lastChild&&s.nodeType===3){s.nodeValue=r;return}}t.textContent=r}var da=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 Un(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||da.has(r)?r==="float"?t.cssFloat=s:t[r]=(""+s).trim():t[r]=s+"px"}function Pr(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&&Un(t,p,c)}else for(var g in r)r.hasOwnProperty(g)&&Un(t,g,r[g])}function Xl(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 ed=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"]]),Ni=/^[\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 Wl(t){return Ni.test(""+t)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":t}function $n(){}var Zr=null;function hn(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var br=null,Jr=null;function Vo(t){var r=Hn(t);if(r&&(t=r.stateNode)){var s=t[Ln]||null;e:switch(t=r.stateNode,r.type){case"input":if(Yl(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="'+ir(""+r)+'"][type="radio"]'),r=0;r<s.length;r++){var c=s[r];if(c!==t&&c.form===t.form){var p=c[Ln]||null;if(!p)throw Error(i(90));Yl(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&&Rr(c)}break e;case"textarea":Wo(t,s.value,s.defaultValue);break e;case"select":r=s.value,r!=null&&sr(t,!!s.multiple,r,!1)}}}var As=!1;function Mt(t,r,s){if(As)return t(r,s);As=!0;try{var c=t(r);return c}finally{if(As=!1,(br!==null||Jr!==null)&&(Lc(),br&&(r=br,t=Jr,Jr=br=null,Vo(r),t)))for(r=0;r<t.length;r++)Vo(t[r])}}function Vl(t,r){var s=t.stateNode;if(s===null)return null;var c=s[Ln]||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 zt=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Gl=!1;if(zt)try{var ea={};Object.defineProperty(ea,"passive",{get:function(){Gl=!0}}),window.addEventListener("test",ea,ea),window.removeEventListener("test",ea,ea)}catch{Gl=!1}var fa=null,Kl=null,zr=null;function Ei(){if(zr)return zr;var t,r=Kl,s=r.length,c,p="value"in fa?fa.value:fa.textContent,g=p.length;for(t=0;t<s&&r[t]===p[t];t++);var C=s-t;for(c=1;c<=C&&r[s-c]===p[g-c];c++);return zr=p.slice(t,1<c?1-c:void 0)}function Ai(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 Di(){return!0}function Ti(){return!1}function Gn(t){function r(s,c,p,g,C){this._reactName=s,this._targetInst=p,this.type=c,this.nativeEvent=g,this.target=C,this.currentTarget=null;for(var z in t)t.hasOwnProperty(z)&&(s=t[z],this[z]=s?s(g):g[z]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?Di:Ti,this.isPropagationStopped=Ti,this}return y(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=Di)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=Di)},persist:function(){},isPersistent:Di}),r}var ha={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},al=Gn(ha),Ql=y({},ha,{view:0,detail:0}),Go=Gn(Ql),Fi,Mi,or,_r=y({},Ql,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:M,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!==or&&(or&&t.type==="mousemove"?(Fi=t.screenX-or.screenX,Mi=t.screenY-or.screenY):Mi=Fi=0,or=t),Fi)},movementY:function(t){return"movementY"in t?t.movementY:Mi}}),Ri=Gn(_r),td=y({},_r,{dataTransfer:0}),ma=Gn(td),Ko=y({},Ql,{relatedTarget:0}),Ds=Gn(Ko),Qo=y({},ha,{animationName:0,elapsedTime:0,pseudoElement:0}),Gt=Gn(Qo),ll=y({},ha,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),Po=Gn(ll),Zo=y({},ha,{data:0}),Ts=Gn(Zo),Jo={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},ec={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"},tc={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function nc(t){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(t):(t=tc[t])?!!r[t]:!1}function M(){return nc}var K=y({},Ql,{key:function(t){if(t.key){var r=Jo[t.key]||t.key;if(r!=="Unidentified")return r}return t.type==="keypress"?(t=Ai(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?ec[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:M,charCode:function(t){return t.type==="keypress"?Ai(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Ai(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),ne=Gn(K),xe=y({},_r,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),je=Gn(xe),Xe=y({},Ql,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:M}),Ut=Gn(Xe),lt=y({},ha,{propertyName:0,elapsedTime:0,pseudoElement:0}),Pe=Gn(lt),at=y({},_r,{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}),it=Gn(at),an=y({},ha,{newState:0,oldState:0}),qt=Gn(an),ta=[9,13,27,32],zi=zt&&"CompositionEvent"in window,il=null;zt&&"documentMode"in document&&(il=document.documentMode);var Bv=zt&&"TextEvent"in window&&!il,ep=zt&&(!zi||il&&8<il&&11>=il),tp=" ",np=!1;function rp(t,r){switch(t){case"keyup":return ta.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ap(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var _i=!1;function Ov(t,r){switch(t){case"compositionend":return ap(r);case"keypress":return r.which!==32?null:(np=!0,tp);case"textInput":return t=r.data,t===tp&&np?null:t;default:return null}}function Lv(t,r){if(_i)return t==="compositionend"||!zi&&rp(t,r)?(t=Ei(),zr=Kl=fa=null,_i=!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 ep&&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 lp(t){var r=t&&t.nodeName&&t.nodeName.toLowerCase();return r==="input"?!!$v[t.type]:r==="textarea"}function ip(t,r,s,c){br?Jr?Jr.push(c):Jr=[c]:br=c,r=Xc(r,"onChange"),0<r.length&&(s=new al("onChange","change",null,s,c),t.push({event:s,listeners:r}))}var Fs=null,Ms=null;function Iv(t){U1(t,0)}function rc(t){var r=Hl(t);if(Rr(r))return t}function sp(t,r){if(t==="change")return r}var op=!1;if(zt){var nd;if(zt){var rd="oninput"in document;if(!rd){var cp=document.createElement("div");cp.setAttribute("oninput","return;"),rd=typeof cp.oninput=="function"}nd=rd}else nd=!1;op=nd&&(!document.documentMode||9<document.documentMode)}function up(){Fs&&(Fs.detachEvent("onpropertychange",dp),Ms=Fs=null)}function dp(t){if(t.propertyName==="value"&&rc(Ms)){var r=[];ip(r,Ms,t,hn(t)),Mt(Iv,r)}}function Hv(t,r,s){t==="focusin"?(up(),Fs=r,Ms=s,Fs.attachEvent("onpropertychange",dp)):t==="focusout"&&up()}function Uv(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return rc(Ms)}function qv(t,r){if(t==="click")return rc(r)}function Yv(t,r){if(t==="input"||t==="change")return rc(r)}function Xv(t,r){return t===r&&(t!==0||1/t===1/r)||t!==t&&r!==r}var vr=typeof Object.is=="function"?Object.is:Xv;function Rs(t,r){if(vr(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)||!vr(t[p],r[p]))return!1}return!0}function fp(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function hp(t,r){var s=fp(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=fp(s)}}function mp(t,r){return t&&r?t===r?!0:t&&t.nodeType===3?!1:r&&r.nodeType===3?mp(t,r.parentNode):"contains"in t?t.contains(r):t.compareDocumentPosition?!!(t.compareDocumentPosition(r)&16):!1:!1}function pp(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var r=Sn(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=Sn(t.document)}return r}function ad(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 Wv=zt&&"documentMode"in document&&11>=document.documentMode,Bi=null,ld=null,zs=null,id=!1;function xp(t,r,s){var c=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;id||Bi==null||Bi!==Sn(c)||(c=Bi,"selectionStart"in c&&ad(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}),zs&&Rs(zs,c)||(zs=c,c=Xc(ld,"onSelect"),0<c.length&&(r=new al("onSelect","select",null,r,s),t.push({event:r,listeners:c}),r.target=Bi)))}function Pl(t,r){var s={};return s[t.toLowerCase()]=r.toLowerCase(),s["Webkit"+t]="webkit"+r,s["Moz"+t]="moz"+r,s}var Oi={animationend:Pl("Animation","AnimationEnd"),animationiteration:Pl("Animation","AnimationIteration"),animationstart:Pl("Animation","AnimationStart"),transitionrun:Pl("Transition","TransitionRun"),transitionstart:Pl("Transition","TransitionStart"),transitioncancel:Pl("Transition","TransitionCancel"),transitionend:Pl("Transition","TransitionEnd")},sd={},yp={};zt&&(yp=document.createElement("div").style,"AnimationEvent"in window||(delete Oi.animationend.animation,delete Oi.animationiteration.animation,delete Oi.animationstart.animation),"TransitionEvent"in window||delete Oi.transitionend.transition);function Zl(t){if(sd[t])return sd[t];if(!Oi[t])return t;var r=Oi[t],s;for(s in r)if(r.hasOwnProperty(s)&&s in yp)return sd[t]=r[s];return t}var gp=Zl("animationend"),bp=Zl("animationiteration"),vp=Zl("animationstart"),Vv=Zl("transitionrun"),Gv=Zl("transitionstart"),Kv=Zl("transitioncancel"),wp=Zl("transitionend"),kp=new Map,od="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(" ");od.push("scrollEnd");function na(t,r){kp.set(t,r),lr(r,[t])}var ac=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)},Br=[],Li=0,cd=0;function lc(){for(var t=Li,r=cd=Li=0;r<t;){var s=Br[r];Br[r++]=null;var c=Br[r];Br[r++]=null;var p=Br[r];Br[r++]=null;var g=Br[r];if(Br[r++]=null,c!==null&&p!==null){var C=c.pending;C===null?p.next=p:(p.next=C.next,C.next=p),c.pending=p}g!==0&&jp(s,p,g)}}function ic(t,r,s,c){Br[Li++]=t,Br[Li++]=r,Br[Li++]=s,Br[Li++]=c,cd|=c,t.lanes|=c,t=t.alternate,t!==null&&(t.lanes|=c)}function ud(t,r,s,c){return ic(t,r,s,c),sc(t)}function Jl(t,r){return ic(t,null,null,r),sc(t)}function jp(t,r,s){t.lanes|=s;var c=t.alternate;c!==null&&(c.lanes|=s);for(var p=!1,g=t.return;g!==null;)g.childLanes|=s,c=g.alternate,c!==null&&(c.childLanes|=s),g.tag===22&&(t=g.stateNode,t===null||t._visibility&1||(p=!0)),t=g,g=g.return;return t.tag===3?(g=t.stateNode,p&&r!==null&&(p=31-Oe(s),t=g.hiddenUpdates,c=t[p],c===null?t[p]=[r]:c.push(r),r.lane=s|536870912),g):null}function sc(t){if(50<no)throw no=0,vf=null,Error(i(185));for(var r=t.return;r!==null;)t=r,r=t.return;return t.tag===3?t.stateNode:null}var $i={};function Qv(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 wr(t,r,s,c){return new Qv(t,r,s,c)}function dd(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Ra(t,r){var s=t.alternate;return s===null?(s=wr(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 Sp(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 oc(t,r,s,c,p,g){var C=0;if(c=t,typeof t=="function")dd(t)&&(C=1);else if(typeof t=="string")C=tw(t,s,Q.current)?26:t==="html"||t==="head"||t==="body"?27:5;else e:switch(t){case G:return t=wr(31,s,r,p),t.elementType=G,t.lanes=g,t;case k:return ei(s.children,p,g,r);case N:C=8,p|=24;break;case S:return t=wr(12,s,r,p|2),t.elementType=S,t.lanes=g,t;case I:return t=wr(13,s,r,p),t.elementType=I,t.lanes=g,t;case B:return t=wr(19,s,r,p),t.elementType=B,t.lanes=g,t;default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case _:C=10;break e;case E:C=9;break e;case R:C=11;break e;case $:C=14;break e;case q:C=16,c=null;break e}C=29,s=Error(i(130,t===null?"null":typeof t,"")),c=null}return r=wr(C,s,r,p),r.elementType=t,r.type=c,r.lanes=g,r}function ei(t,r,s,c){return t=wr(7,t,c,r),t.lanes=s,t}function fd(t,r,s){return t=wr(6,t,null,r),t.lanes=s,t}function Cp(t){var r=wr(18,null,null,0);return r.stateNode=t,r}function hd(t,r,s){return r=wr(4,t.children!==null?t.children:[],t.key,r),r.lanes=s,r.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},r}var Np=new WeakMap;function Or(t,r){if(typeof t=="object"&&t!==null){var s=Np.get(t);return s!==void 0?s:(r={value:t,source:r,stack:xt(r)},Np.set(t,r),r)}return{value:t,source:r,stack:xt(r)}}var Ii=[],Hi=0,cc=null,_s=0,Lr=[],$r=0,sl=null,pa=1,xa="";function za(t,r){Ii[Hi++]=_s,Ii[Hi++]=cc,cc=t,_s=r}function Ep(t,r,s){Lr[$r++]=pa,Lr[$r++]=xa,Lr[$r++]=sl,sl=t;var c=pa;t=xa;var p=32-Oe(c)-1;c&=~(1<<p),s+=1;var g=32-Oe(r)+p;if(30<g){var C=p-p%5;g=(c&(1<<C)-1).toString(32),c>>=C,p-=C,pa=1<<32-Oe(r)+p|s<<p|c,xa=g+t}else pa=1<<g|s<<p|c,xa=t}function md(t){t.return!==null&&(za(t,1),Ep(t,1,0))}function pd(t){for(;t===cc;)cc=Ii[--Hi],Ii[Hi]=null,_s=Ii[--Hi],Ii[Hi]=null;for(;t===sl;)sl=Lr[--$r],Lr[$r]=null,xa=Lr[--$r],Lr[$r]=null,pa=Lr[--$r],Lr[$r]=null}function Ap(t,r){Lr[$r++]=pa,Lr[$r++]=xa,Lr[$r++]=sl,pa=r.id,xa=r.overflow,sl=t}var qn=null,cn=null,Ft=!1,ol=null,Ir=!1,xd=Error(i(519));function cl(t){var r=Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Bs(Or(r,t)),xd}function Dp(t){var r=t.stateNode,s=t.type,c=t.memoizedProps;switch(r[Fn]=t,r[Ln]=c,s){case"dialog":Nt("cancel",r),Nt("close",r);break;case"iframe":case"object":case"embed":Nt("load",r);break;case"video":case"audio":for(s=0;s<ao.length;s++)Nt(ao[s],r);break;case"source":Nt("error",r);break;case"img":case"image":case"link":Nt("error",r),Nt("load",r);break;case"details":Nt("toggle",r);break;case"input":Nt("invalid",r),er(r,c.value,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name,!0);break;case"select":Nt("invalid",r);break;case"textarea":Nt("invalid",r),Mn(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||W1(r.textContent,s)?(c.popover!=null&&(Nt("beforetoggle",r),Nt("toggle",r)),c.onScroll!=null&&Nt("scroll",r),c.onScrollEnd!=null&&Nt("scrollend",r),c.onClick!=null&&(r.onclick=$n),r=!0):r=!1,r||cl(t,!0)}function Tp(t){for(qn=t.return;qn;)switch(qn.tag){case 5:case 31:case 13:Ir=!1;return;case 27:case 3:Ir=!0;return;default:qn=qn.return}}function Ui(t){if(t!==qn)return!1;if(!Ft)return Tp(t),Ft=!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&&cn&&cl(t),Tp(t),r===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(i(317));cn=t0(t)}else if(r===31){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(i(317));cn=t0(t)}else r===27?(r=cn,jl(t.type)?(t=If,If=null,cn=t):cn=r):cn=qn?Ur(t.stateNode.nextSibling):null;return!0}function ti(){cn=qn=null,Ft=!1}function yd(){var t=ol;return t!==null&&(fr===null?fr=t:fr.push.apply(fr,t),ol=null),t}function Bs(t){ol===null?ol=[t]:ol.push(t)}var gd=F(null),ni=null,_a=null;function ul(t,r,s){A(gd,r._currentValue),r._currentValue=s}function Ba(t){t._currentValue=gd.current,W(gd)}function bd(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 vd(t,r,s,c){var p=t.child;for(p!==null&&(p.return=t);p!==null;){var g=p.dependencies;if(g!==null){var C=p.child;g=g.firstContext;e:for(;g!==null;){var z=g;g=p;for(var Y=0;Y<r.length;Y++)if(z.context===r[Y]){g.lanes|=s,z=g.alternate,z!==null&&(z.lanes|=s),bd(g.return,s,t),c||(C=null);break e}g=z.next}}else if(p.tag===18){if(C=p.return,C===null)throw Error(i(341));C.lanes|=s,g=C.alternate,g!==null&&(g.lanes|=s),bd(C,s,t),C=null}else C=p.child;if(C!==null)C.return=p;else for(C=p;C!==null;){if(C===t){C=null;break}if(p=C.sibling,p!==null){p.return=C.return,C=p;break}C=C.return}p=C}}function qi(t,r,s,c){t=null;for(var p=r,g=!1;p!==null;){if(!g){if((p.flags&524288)!==0)g=!0;else if((p.flags&262144)!==0)break}if(p.tag===10){var C=p.alternate;if(C===null)throw Error(i(387));if(C=C.memoizedProps,C!==null){var z=p.type;vr(p.pendingProps.value,C.value)||(t!==null?t.push(z):t=[z])}}else if(p===Ne.current){if(C=p.alternate,C===null)throw Error(i(387));C.memoizedState.memoizedState!==p.memoizedState.memoizedState&&(t!==null?t.push(co):t=[co])}p=p.return}t!==null&&vd(r,t,s,c),r.flags|=262144}function uc(t){for(t=t.firstContext;t!==null;){if(!vr(t.context._currentValue,t.memoizedValue))return!0;t=t.next}return!1}function ri(t){ni=t,_a=null,t=t.dependencies,t!==null&&(t.firstContext=null)}function Yn(t){return Fp(ni,t)}function dc(t,r){return ni===null&&ri(t),Fp(t,r)}function Fp(t,r){var s=r._currentValue;if(r={context:r,memoizedValue:s,next:null},_a===null){if(t===null)throw Error(i(308));_a=r,t.dependencies={lanes:0,firstContext:r},t.flags|=524288}else _a=_a.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()})}},Zv=e.unstable_scheduleCallback,Jv=e.unstable_NormalPriority,Cn={$$typeof:_,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function wd(){return{controller:new Pv,data:new Map,refCount:0}}function Os(t){t.refCount--,t.refCount===0&&Zv(Jv,function(){t.controller.abort()})}var Ls=null,kd=0,Yi=0,Xi=null;function e2(t,r){if(Ls===null){var s=Ls=[];kd=0,Yi=Nf(),Xi={status:"pending",value:void 0,then:function(c){s.push(c)}}}return kd++,r.then(Mp,Mp),r}function Mp(){if(--kd===0&&Ls!==null){Xi!==null&&(Xi.status="fulfilled");var t=Ls;Ls=null,Yi=0,Xi=null;for(var r=0;r<t.length;r++)(0,t[r])()}}function t2(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 Rp=X.S;X.S=function(t,r){x1=Wt(),typeof r=="object"&&r!==null&&typeof r.then=="function"&&e2(t,r),Rp!==null&&Rp(t,r)};var ai=F(null);function jd(){var t=ai.current;return t!==null?t:tn.pooledCache}function fc(t,r){r===null?A(ai,ai.current):A(ai,r.pool)}function zp(){var t=jd();return t===null?null:{parent:Cn._currentValue,pool:t}}var Wi=Error(i(460)),Sd=Error(i(474)),hc=Error(i(542)),mc={then:function(){}};function _p(t){return t=t.status,t==="fulfilled"||t==="rejected"}function Bp(t,r,s){switch(s=t[s],s===void 0?t.push(r):s!==r&&(r.then($n,$n),r=s),r.status){case"fulfilled":return r.value;case"rejected":throw t=r.reason,Lp(t),t;default:if(typeof r.status=="string")r.then($n,$n);else{if(t=tn,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,Lp(t),t}throw ii=r,Wi}}function li(t){try{var r=t._init;return r(t._payload)}catch(s){throw s!==null&&typeof s=="object"&&typeof s.then=="function"?(ii=s,Wi):s}}var ii=null;function Op(){if(ii===null)throw Error(i(459));var t=ii;return ii=null,t}function Lp(t){if(t===Wi||t===hc)throw Error(i(483))}var Vi=null,$s=0;function pc(t){var r=$s;return $s+=1,Vi===null&&(Vi=[]),Bp(Vi,t,r)}function Is(t,r){r=r.props.ref,t.ref=r!==void 0?r:null}function xc(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 $p(t){function r(te,V){if(t){var se=te.deletions;se===null?(te.deletions=[V],te.flags|=16):se.push(V)}}function s(te,V){if(!t)return null;for(;V!==null;)r(te,V),V=V.sibling;return null}function c(te){for(var V=new Map;te!==null;)te.key!==null?V.set(te.key,te):V.set(te.index,te),te=te.sibling;return V}function p(te,V){return te=Ra(te,V),te.index=0,te.sibling=null,te}function g(te,V,se){return te.index=se,t?(se=te.alternate,se!==null?(se=se.index,se<V?(te.flags|=67108866,V):se):(te.flags|=67108866,V)):(te.flags|=1048576,V)}function C(te){return t&&te.alternate===null&&(te.flags|=67108866),te}function z(te,V,se,be){return V===null||V.tag!==6?(V=fd(se,te.mode,be),V.return=te,V):(V=p(V,se),V.return=te,V)}function Y(te,V,se,be){var Qe=se.type;return Qe===k?pe(te,V,se.props.children,be,se.key):V!==null&&(V.elementType===Qe||typeof Qe=="object"&&Qe!==null&&Qe.$$typeof===q&&li(Qe)===V.type)?(V=p(V,se.props),Is(V,se),V.return=te,V):(V=oc(se.type,se.key,se.props,null,te.mode,be),Is(V,se),V.return=te,V)}function oe(te,V,se,be){return V===null||V.tag!==4||V.stateNode.containerInfo!==se.containerInfo||V.stateNode.implementation!==se.implementation?(V=hd(se,te.mode,be),V.return=te,V):(V=p(V,se.children||[]),V.return=te,V)}function pe(te,V,se,be,Qe){return V===null||V.tag!==7?(V=ei(se,te.mode,be,Qe),V.return=te,V):(V=p(V,se),V.return=te,V)}function ke(te,V,se){if(typeof V=="string"&&V!==""||typeof V=="number"||typeof V=="bigint")return V=fd(""+V,te.mode,se),V.return=te,V;if(typeof V=="object"&&V!==null){switch(V.$$typeof){case b:return se=oc(V.type,V.key,V.props,null,te.mode,se),Is(se,V),se.return=te,se;case j:return V=hd(V,te.mode,se),V.return=te,V;case q:return V=li(V),ke(te,V,se)}if(re(V)||L(V))return V=ei(V,te.mode,se,null),V.return=te,V;if(typeof V.then=="function")return ke(te,pc(V),se);if(V.$$typeof===_)return ke(te,dc(te,V),se);xc(te,V)}return null}function ue(te,V,se,be){var Qe=V!==null?V.key:null;if(typeof se=="string"&&se!==""||typeof se=="number"||typeof se=="bigint")return Qe!==null?null:z(te,V,""+se,be);if(typeof se=="object"&&se!==null){switch(se.$$typeof){case b:return se.key===Qe?Y(te,V,se,be):null;case j:return se.key===Qe?oe(te,V,se,be):null;case q:return se=li(se),ue(te,V,se,be)}if(re(se)||L(se))return Qe!==null?null:pe(te,V,se,be,null);if(typeof se.then=="function")return ue(te,V,pc(se),be);if(se.$$typeof===_)return ue(te,V,dc(te,se),be);xc(te,se)}return null}function fe(te,V,se,be,Qe){if(typeof be=="string"&&be!==""||typeof be=="number"||typeof be=="bigint")return te=te.get(se)||null,z(V,te,""+be,Qe);if(typeof be=="object"&&be!==null){switch(be.$$typeof){case b:return te=te.get(be.key===null?se:be.key)||null,Y(V,te,be,Qe);case j:return te=te.get(be.key===null?se:be.key)||null,oe(V,te,be,Qe);case q:return be=li(be),fe(te,V,se,be,Qe)}if(re(be)||L(be))return te=te.get(se)||null,pe(V,te,be,Qe,null);if(typeof be.then=="function")return fe(te,V,se,pc(be),Qe);if(be.$$typeof===_)return fe(te,V,se,dc(V,be),Qe);xc(V,be)}return null}function He(te,V,se,be){for(var Qe=null,Ot=null,We=V,mt=V=0,Dt=null;We!==null&&mt<se.length;mt++){We.index>mt?(Dt=We,We=null):Dt=We.sibling;var Lt=ue(te,We,se[mt],be);if(Lt===null){We===null&&(We=Dt);break}t&&We&&Lt.alternate===null&&r(te,We),V=g(Lt,V,mt),Ot===null?Qe=Lt:Ot.sibling=Lt,Ot=Lt,We=Dt}if(mt===se.length)return s(te,We),Ft&&za(te,mt),Qe;if(We===null){for(;mt<se.length;mt++)We=ke(te,se[mt],be),We!==null&&(V=g(We,V,mt),Ot===null?Qe=We:Ot.sibling=We,Ot=We);return Ft&&za(te,mt),Qe}for(We=c(We);mt<se.length;mt++)Dt=fe(We,te,mt,se[mt],be),Dt!==null&&(t&&Dt.alternate!==null&&We.delete(Dt.key===null?mt:Dt.key),V=g(Dt,V,mt),Ot===null?Qe=Dt:Ot.sibling=Dt,Ot=Dt);return t&&We.forEach(function(Al){return r(te,Al)}),Ft&&za(te,mt),Qe}function tt(te,V,se,be){if(se==null)throw Error(i(151));for(var Qe=null,Ot=null,We=V,mt=V=0,Dt=null,Lt=se.next();We!==null&&!Lt.done;mt++,Lt=se.next()){We.index>mt?(Dt=We,We=null):Dt=We.sibling;var Al=ue(te,We,Lt.value,be);if(Al===null){We===null&&(We=Dt);break}t&&We&&Al.alternate===null&&r(te,We),V=g(Al,V,mt),Ot===null?Qe=Al:Ot.sibling=Al,Ot=Al,We=Dt}if(Lt.done)return s(te,We),Ft&&za(te,mt),Qe;if(We===null){for(;!Lt.done;mt++,Lt=se.next())Lt=ke(te,Lt.value,be),Lt!==null&&(V=g(Lt,V,mt),Ot===null?Qe=Lt:Ot.sibling=Lt,Ot=Lt);return Ft&&za(te,mt),Qe}for(We=c(We);!Lt.done;mt++,Lt=se.next())Lt=fe(We,te,mt,Lt.value,be),Lt!==null&&(t&&Lt.alternate!==null&&We.delete(Lt.key===null?mt:Lt.key),V=g(Lt,V,mt),Ot===null?Qe=Lt:Ot.sibling=Lt,Ot=Lt);return t&&We.forEach(function(fw){return r(te,fw)}),Ft&&za(te,mt),Qe}function Pt(te,V,se,be){if(typeof se=="object"&&se!==null&&se.type===k&&se.key===null&&(se=se.props.children),typeof se=="object"&&se!==null){switch(se.$$typeof){case b:e:{for(var Qe=se.key;V!==null;){if(V.key===Qe){if(Qe=se.type,Qe===k){if(V.tag===7){s(te,V.sibling),be=p(V,se.props.children),be.return=te,te=be;break e}}else if(V.elementType===Qe||typeof Qe=="object"&&Qe!==null&&Qe.$$typeof===q&&li(Qe)===V.type){s(te,V.sibling),be=p(V,se.props),Is(be,se),be.return=te,te=be;break e}s(te,V);break}else r(te,V);V=V.sibling}se.type===k?(be=ei(se.props.children,te.mode,be,se.key),be.return=te,te=be):(be=oc(se.type,se.key,se.props,null,te.mode,be),Is(be,se),be.return=te,te=be)}return C(te);case j:e:{for(Qe=se.key;V!==null;){if(V.key===Qe)if(V.tag===4&&V.stateNode.containerInfo===se.containerInfo&&V.stateNode.implementation===se.implementation){s(te,V.sibling),be=p(V,se.children||[]),be.return=te,te=be;break e}else{s(te,V);break}else r(te,V);V=V.sibling}be=hd(se,te.mode,be),be.return=te,te=be}return C(te);case q:return se=li(se),Pt(te,V,se,be)}if(re(se))return He(te,V,se,be);if(L(se)){if(Qe=L(se),typeof Qe!="function")throw Error(i(150));return se=Qe.call(se),tt(te,V,se,be)}if(typeof se.then=="function")return Pt(te,V,pc(se),be);if(se.$$typeof===_)return Pt(te,V,dc(te,se),be);xc(te,se)}return typeof se=="string"&&se!==""||typeof se=="number"||typeof se=="bigint"?(se=""+se,V!==null&&V.tag===6?(s(te,V.sibling),be=p(V,se),be.return=te,te=be):(s(te,V),be=fd(se,te.mode,be),be.return=te,te=be),C(te)):s(te,V)}return function(te,V,se,be){try{$s=0;var Qe=Pt(te,V,se,be);return Vi=null,Qe}catch(We){if(We===Wi||We===hc)throw We;var Ot=wr(29,We,null,te.mode);return Ot.lanes=be,Ot.return=te,Ot}finally{}}}var si=$p(!0),Ip=$p(!1),dl=!1;function Cd(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Nd(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 fl(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function hl(t,r,s){var c=t.updateQueue;if(c===null)return null;if(c=c.shared,(It&2)!==0){var p=c.pending;return p===null?r.next=r:(r.next=p.next,p.next=r),c.pending=r,r=sc(t),jp(t,null,s),r}return ic(t,c,r,s),sc(t)}function Hs(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,en(t,s)}}function Ed(t,r){var s=t.updateQueue,c=t.alternate;if(c!==null&&(c=c.updateQueue,s===c)){var p=null,g=null;if(s=s.firstBaseUpdate,s!==null){do{var C={lane:s.lane,tag:s.tag,payload:s.payload,callback:null,next:null};g===null?p=g=C:g=g.next=C,s=s.next}while(s!==null);g===null?p=g=r:g=g.next=r}else p=g=r;s={baseState:c.baseState,firstBaseUpdate:p,lastBaseUpdate:g,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 Ad=!1;function Us(){if(Ad){var t=Xi;if(t!==null)throw t}}function qs(t,r,s,c){Ad=!1;var p=t.updateQueue;dl=!1;var g=p.firstBaseUpdate,C=p.lastBaseUpdate,z=p.shared.pending;if(z!==null){p.shared.pending=null;var Y=z,oe=Y.next;Y.next=null,C===null?g=oe:C.next=oe,C=Y;var pe=t.alternate;pe!==null&&(pe=pe.updateQueue,z=pe.lastBaseUpdate,z!==C&&(z===null?pe.firstBaseUpdate=oe:z.next=oe,pe.lastBaseUpdate=Y))}if(g!==null){var ke=p.baseState;C=0,pe=oe=Y=null,z=g;do{var ue=z.lane&-536870913,fe=ue!==z.lane;if(fe?(At&ue)===ue:(c&ue)===ue){ue!==0&&ue===Yi&&(Ad=!0),pe!==null&&(pe=pe.next={lane:0,tag:z.tag,payload:z.payload,callback:null,next:null});e:{var He=t,tt=z;ue=r;var Pt=s;switch(tt.tag){case 1:if(He=tt.payload,typeof He=="function"){ke=He.call(Pt,ke,ue);break e}ke=He;break e;case 3:He.flags=He.flags&-65537|128;case 0:if(He=tt.payload,ue=typeof He=="function"?He.call(Pt,ke,ue):He,ue==null)break e;ke=y({},ke,ue);break e;case 2:dl=!0}}ue=z.callback,ue!==null&&(t.flags|=64,fe&&(t.flags|=8192),fe=p.callbacks,fe===null?p.callbacks=[ue]:fe.push(ue))}else fe={lane:ue,tag:z.tag,payload:z.payload,callback:z.callback,next:null},pe===null?(oe=pe=fe,Y=ke):pe=pe.next=fe,C|=ue;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);pe===null&&(Y=ke),p.baseState=Y,p.firstBaseUpdate=oe,p.lastBaseUpdate=pe,g===null&&(p.shared.lanes=0),gl|=C,t.lanes=C,t.memoizedState=ke}}function Hp(t,r){if(typeof t!="function")throw Error(i(191,t));t.call(r)}function Up(t,r){var s=t.callbacks;if(s!==null)for(t.callbacks=null,t=0;t<s.length;t++)Hp(s[t],r)}var Gi=F(null),yc=F(0);function qp(t,r){t=Xa,A(yc,t),A(Gi,r),Xa=t|r.baseLanes}function Dd(){A(yc,Xa),A(Gi,Gi.current)}function Td(){Xa=yc.current,W(Gi),W(yc)}var kr=F(null),Hr=null;function ml(t){var r=t.alternate;A(wn,wn.current&1),A(kr,t),Hr===null&&(r===null||Gi.current!==null||r.memoizedState!==null)&&(Hr=t)}function Fd(t){A(wn,wn.current),A(kr,t),Hr===null&&(Hr=t)}function Yp(t){t.tag===22?(A(wn,wn.current),A(kr,t),Hr===null&&(Hr=t)):pl()}function pl(){A(wn,wn.current),A(kr,kr.current)}function jr(t){W(kr),Hr===t&&(Hr=null),W(wn)}var wn=F(0);function gc(t){for(var r=t;r!==null;){if(r.tag===13){var s=r.memoizedState;if(s!==null&&(s=s.dehydrated,s===null||Lf(s)||$f(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 Oa=0,ht=null,Kt=null,Nn=null,bc=!1,Ki=!1,oi=!1,vc=0,Ys=0,Qi=null,n2=0;function xn(){throw Error(i(321))}function Md(t,r){if(r===null)return!1;for(var s=0;s<r.length&&s<t.length;s++)if(!vr(t[s],r[s]))return!1;return!0}function Rd(t,r,s,c,p,g){return Oa=g,ht=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,X.H=t===null||t.memoizedState===null?Ex:Gd,oi=!1,g=s(c,p),oi=!1,Ki&&(g=Wp(r,s,c,p)),Xp(t),g}function Xp(t){X.H=Vs;var r=Kt!==null&&Kt.next!==null;if(Oa=0,Nn=Kt=ht=null,bc=!1,Ys=0,Qi=null,r)throw Error(i(300));t===null||En||(t=t.dependencies,t!==null&&uc(t)&&(En=!0))}function Wp(t,r,s,c){ht=t;var p=0;do{if(Ki&&(Qi=null),Ys=0,Ki=!1,25<=p)throw Error(i(301));if(p+=1,Nn=Kt=null,t.updateQueue!=null){var g=t.updateQueue;g.lastEffect=null,g.events=null,g.stores=null,g.memoCache!=null&&(g.memoCache.index=0)}X.H=Ax,g=r(s,c)}while(Ki);return g}function r2(){var t=X.H,r=t.useState()[0];return r=typeof r.then=="function"?Xs(r):r,t=t.useState()[0],(Kt!==null?Kt.memoizedState:null)!==t&&(ht.flags|=1024),r}function zd(){var t=vc!==0;return vc=0,t}function _d(t,r,s){r.updateQueue=t.updateQueue,r.flags&=-2053,t.lanes&=~s}function Bd(t){if(bc){for(t=t.memoizedState;t!==null;){var r=t.queue;r!==null&&(r.pending=null),t=t.next}bc=!1}Oa=0,Nn=Kt=ht=null,Ki=!1,Ys=vc=0,Qi=null}function tr(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Nn===null?ht.memoizedState=Nn=t:Nn=Nn.next=t,Nn}function kn(){if(Kt===null){var t=ht.alternate;t=t!==null?t.memoizedState:null}else t=Kt.next;var r=Nn===null?ht.memoizedState:Nn.next;if(r!==null)Nn=r,Kt=t;else{if(t===null)throw ht.alternate===null?Error(i(467)):Error(i(310));Kt=t,t={memoizedState:Kt.memoizedState,baseState:Kt.baseState,baseQueue:Kt.baseQueue,queue:Kt.queue,next:null},Nn===null?ht.memoizedState=Nn=t:Nn=Nn.next=t}return Nn}function wc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Xs(t){var r=Ys;return Ys+=1,Qi===null&&(Qi=[]),t=Bp(Qi,t,r),r=ht,(Nn===null?r.memoizedState:Nn.next)===null&&(r=r.alternate,X.H=r===null||r.memoizedState===null?Ex:Gd),t}function kc(t){if(t!==null&&typeof t=="object"){if(typeof t.then=="function")return Xs(t);if(t.$$typeof===_)return Yn(t)}throw Error(i(438,String(t)))}function Od(t){var r=null,s=ht.updateQueue;if(s!==null&&(r=s.memoCache),r==null){var c=ht.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=wc(),ht.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]=T;return r.index++,s}function La(t,r){return typeof r=="function"?r(t):r}function jc(t){var r=kn();return Ld(r,Kt,t)}function Ld(t,r,s){var c=t.queue;if(c===null)throw Error(i(311));c.lastRenderedReducer=s;var p=t.baseQueue,g=c.pending;if(g!==null){if(p!==null){var C=p.next;p.next=g.next,g.next=C}r.baseQueue=p=g,c.pending=null}if(g=t.baseState,p===null)t.memoizedState=g;else{r=p.next;var z=C=null,Y=null,oe=r,pe=!1;do{var ke=oe.lane&-536870913;if(ke!==oe.lane?(At&ke)===ke:(Oa&ke)===ke){var ue=oe.revertLane;if(ue===0)Y!==null&&(Y=Y.next={lane:0,revertLane:0,gesture:null,action:oe.action,hasEagerState:oe.hasEagerState,eagerState:oe.eagerState,next:null}),ke===Yi&&(pe=!0);else if((Oa&ue)===ue){oe=oe.next,ue===Yi&&(pe=!0);continue}else ke={lane:0,revertLane:oe.revertLane,gesture:null,action:oe.action,hasEagerState:oe.hasEagerState,eagerState:oe.eagerState,next:null},Y===null?(z=Y=ke,C=g):Y=Y.next=ke,ht.lanes|=ue,gl|=ue;ke=oe.action,oi&&s(g,ke),g=oe.hasEagerState?oe.eagerState:s(g,ke)}else ue={lane:ke,revertLane:oe.revertLane,gesture:oe.gesture,action:oe.action,hasEagerState:oe.hasEagerState,eagerState:oe.eagerState,next:null},Y===null?(z=Y=ue,C=g):Y=Y.next=ue,ht.lanes|=ke,gl|=ke;oe=oe.next}while(oe!==null&&oe!==r);if(Y===null?C=g:Y.next=z,!vr(g,t.memoizedState)&&(En=!0,pe&&(s=Xi,s!==null)))throw s;t.memoizedState=g,t.baseState=C,t.baseQueue=Y,c.lastRenderedState=g}return p===null&&(c.lanes=0),[t.memoizedState,c.dispatch]}function $d(t){var r=kn(),s=r.queue;if(s===null)throw Error(i(311));s.lastRenderedReducer=t;var c=s.dispatch,p=s.pending,g=r.memoizedState;if(p!==null){s.pending=null;var C=p=p.next;do g=t(g,C.action),C=C.next;while(C!==p);vr(g,r.memoizedState)||(En=!0),r.memoizedState=g,r.baseQueue===null&&(r.baseState=g),s.lastRenderedState=g}return[g,c]}function Vp(t,r,s){var c=ht,p=kn(),g=Ft;if(g){if(s===void 0)throw Error(i(407));s=s()}else s=r();var C=!vr((Kt||p).memoizedState,s);if(C&&(p.memoizedState=s,En=!0),p=p.queue,Ud(Qp.bind(null,c,p,t),[t]),p.getSnapshot!==r||C||Nn!==null&&Nn.memoizedState.tag&1){if(c.flags|=2048,Pi(9,{destroy:void 0},Kp.bind(null,c,p,s,r),null),tn===null)throw Error(i(349));g||(Oa&127)!==0||Gp(c,r,s)}return s}function Gp(t,r,s){t.flags|=16384,t={getSnapshot:r,value:s},r=ht.updateQueue,r===null?(r=wc(),ht.updateQueue=r,r.stores=[t]):(s=r.stores,s===null?r.stores=[t]:s.push(t))}function Kp(t,r,s,c){r.value=s,r.getSnapshot=c,Pp(r)&&Zp(t)}function Qp(t,r,s){return s(function(){Pp(r)&&Zp(t)})}function Pp(t){var r=t.getSnapshot;t=t.value;try{var s=r();return!vr(t,s)}catch{return!0}}function Zp(t){var r=Jl(t,2);r!==null&&hr(r,t,2)}function Id(t){var r=tr();if(typeof t=="function"){var s=t;if(t=s(),oi){ze(!0);try{s()}finally{ze(!1)}}}return r.memoizedState=r.baseState=t,r.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:La,lastRenderedState:t},r}function Jp(t,r,s,c){return t.baseState=s,Ld(t,Kt,typeof c=="function"?c:La)}function a2(t,r,s,c,p){if(Nc(t))throw Error(i(485));if(t=r.action,t!==null){var g={payload:p,action:t,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(C){g.listeners.push(C)}};X.T!==null?s(!0):g.isTransition=!1,c(g),s=r.pending,s===null?(g.next=r.pending=g,ex(r,g)):(g.next=s.next,r.pending=s.next=g)}}function ex(t,r){var s=r.action,c=r.payload,p=t.state;if(r.isTransition){var g=X.T,C={};X.T=C;try{var z=s(p,c),Y=X.S;Y!==null&&Y(C,z),tx(t,r,z)}catch(oe){Hd(t,r,oe)}finally{g!==null&&C.types!==null&&(g.types=C.types),X.T=g}}else try{g=s(p,c),tx(t,r,g)}catch(oe){Hd(t,r,oe)}}function tx(t,r,s){s!==null&&typeof s=="object"&&typeof s.then=="function"?s.then(function(c){nx(t,r,c)},function(c){return Hd(t,r,c)}):nx(t,r,s)}function nx(t,r,s){r.status="fulfilled",r.value=s,rx(r),t.state=s,r=t.pending,r!==null&&(s=r.next,s===r?t.pending=null:(s=s.next,r.next=s,ex(t,s)))}function Hd(t,r,s){var c=t.pending;if(t.pending=null,c!==null){c=c.next;do r.status="rejected",r.reason=s,rx(r),r=r.next;while(r!==c)}t.action=null}function rx(t){t=t.listeners;for(var r=0;r<t.length;r++)(0,t[r])()}function ax(t,r){return r}function lx(t,r){if(Ft){var s=tn.formState;if(s!==null){e:{var c=ht;if(Ft){if(cn){t:{for(var p=cn,g=Ir;p.nodeType!==8;){if(!g){p=null;break t}if(p=Ur(p.nextSibling),p===null){p=null;break t}}g=p.data,p=g==="F!"||g==="F"?p:null}if(p){cn=Ur(p.nextSibling),c=p.data==="F!";break e}}cl(c)}c=!1}c&&(r=s[0])}}return s=tr(),s.memoizedState=s.baseState=r,c={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ax,lastRenderedState:r},s.queue=c,s=Sx.bind(null,ht,c),c.dispatch=s,c=Id(!1),g=Vd.bind(null,ht,!1,c.queue),c=tr(),p={state:r,dispatch:null,action:t,pending:null},c.queue=p,s=a2.bind(null,ht,p,g,s),p.dispatch=s,c.memoizedState=t,[r,s,!1]}function ix(t){var r=kn();return sx(r,Kt,t)}function sx(t,r,s){if(r=Ld(t,r,ax)[0],t=jc(La)[0],typeof r=="object"&&r!==null&&typeof r.then=="function")try{var c=Xs(r)}catch(C){throw C===Wi?hc:C}else c=r;r=kn();var p=r.queue,g=p.dispatch;return s!==r.memoizedState&&(ht.flags|=2048,Pi(9,{destroy:void 0},l2.bind(null,p,s),null)),[c,g,t]}function l2(t,r){t.action=r}function ox(t){var r=kn(),s=Kt;if(s!==null)return sx(r,s,t);kn(),r=r.memoizedState,s=kn();var c=s.queue.dispatch;return s.memoizedState=t,[r,c,!1]}function Pi(t,r,s,c){return t={tag:t,create:s,deps:c,inst:r,next:null},r=ht.updateQueue,r===null&&(r=wc(),ht.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 cx(){return kn().memoizedState}function Sc(t,r,s,c){var p=tr();ht.flags|=t,p.memoizedState=Pi(1|r,{destroy:void 0},s,c===void 0?null:c)}function Cc(t,r,s,c){var p=kn();c=c===void 0?null:c;var g=p.memoizedState.inst;Kt!==null&&c!==null&&Md(c,Kt.memoizedState.deps)?p.memoizedState=Pi(r,g,s,c):(ht.flags|=t,p.memoizedState=Pi(1|r,g,s,c))}function ux(t,r){Sc(8390656,8,t,r)}function Ud(t,r){Cc(2048,8,t,r)}function i2(t){ht.flags|=4;var r=ht.updateQueue;if(r===null)r=wc(),ht.updateQueue=r,r.events=[t];else{var s=r.events;s===null?r.events=[t]:s.push(t)}}function dx(t){var r=kn().memoizedState;return i2({ref:r,nextImpl:t}),function(){if((It&2)!==0)throw Error(i(440));return r.impl.apply(void 0,arguments)}}function fx(t,r){return Cc(4,2,t,r)}function hx(t,r){return Cc(4,4,t,r)}function mx(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 px(t,r,s){s=s!=null?s.concat([t]):null,Cc(4,4,mx.bind(null,r,t),s)}function qd(){}function xx(t,r){var s=kn();r=r===void 0?null:r;var c=s.memoizedState;return r!==null&&Md(r,c[1])?c[0]:(s.memoizedState=[t,r],t)}function yx(t,r){var s=kn();r=r===void 0?null:r;var c=s.memoizedState;if(r!==null&&Md(r,c[1]))return c[0];if(c=t(),oi){ze(!0);try{t()}finally{ze(!1)}}return s.memoizedState=[c,r],c}function Yd(t,r,s){return s===void 0||(Oa&1073741824)!==0&&(At&261930)===0?t.memoizedState=r:(t.memoizedState=s,t=g1(),ht.lanes|=t,gl|=t,s)}function gx(t,r,s,c){return vr(s,r)?s:Gi.current!==null?(t=Yd(t,s,c),vr(t,r)||(En=!0),t):(Oa&42)===0||(Oa&1073741824)!==0&&(At&261930)===0?(En=!0,t.memoizedState=s):(t=g1(),ht.lanes|=t,gl|=t,r)}function bx(t,r,s,c,p){var g=le.p;le.p=g!==0&&8>g?g:8;var C=X.T,z={};X.T=z,Vd(t,!1,r,s);try{var Y=p(),oe=X.S;if(oe!==null&&oe(z,Y),Y!==null&&typeof Y=="object"&&typeof Y.then=="function"){var pe=t2(Y,c);Ws(t,r,pe,Nr(t))}else Ws(t,r,c,Nr(t))}catch(ke){Ws(t,r,{then:function(){},status:"rejected",reason:ke},Nr())}finally{le.p=g,C!==null&&z.types!==null&&(C.types=z.types),X.T=C}}function s2(){}function Xd(t,r,s,c){if(t.tag!==5)throw Error(i(476));var p=vx(t).queue;bx(t,p,r,ee,s===null?s2:function(){return wx(t),s(c)})}function vx(t){var r=t.memoizedState;if(r!==null)return r;r={memoizedState:ee,baseState:ee,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:La,lastRenderedState:ee},next:null};var s={};return r.next={memoizedState:s,baseState:s,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:La,lastRenderedState:s},next:null},t.memoizedState=r,t=t.alternate,t!==null&&(t.memoizedState=r),r}function wx(t){var r=vx(t);r.next===null&&(r=t.alternate.memoizedState),Ws(t,r.next.queue,{},Nr())}function Wd(){return Yn(co)}function kx(){return kn().memoizedState}function jx(){return kn().memoizedState}function o2(t){for(var r=t.return;r!==null;){switch(r.tag){case 24:case 3:var s=Nr();t=fl(s);var c=hl(r,t,s);c!==null&&(hr(c,r,s),Hs(c,r,s)),r={cache:wd()},t.payload=r;return}r=r.return}}function c2(t,r,s){var c=Nr();s={lane:c,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},Nc(t)?Cx(r,s):(s=ud(t,r,s,c),s!==null&&(hr(s,t,c),Nx(s,r,c)))}function Sx(t,r,s){var c=Nr();Ws(t,r,s,c)}function Ws(t,r,s,c){var p={lane:c,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null};if(Nc(t))Cx(r,p);else{var g=t.alternate;if(t.lanes===0&&(g===null||g.lanes===0)&&(g=r.lastRenderedReducer,g!==null))try{var C=r.lastRenderedState,z=g(C,s);if(p.hasEagerState=!0,p.eagerState=z,vr(z,C))return ic(t,r,p,0),tn===null&&lc(),!1}catch{}finally{}if(s=ud(t,r,p,c),s!==null)return hr(s,t,c),Nx(s,r,c),!0}return!1}function Vd(t,r,s,c){if(c={lane:2,revertLane:Nf(),gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null},Nc(t)){if(r)throw Error(i(479))}else r=ud(t,s,c,2),r!==null&&hr(r,t,2)}function Nc(t){var r=t.alternate;return t===ht||r!==null&&r===ht}function Cx(t,r){Ki=bc=!0;var s=t.pending;s===null?r.next=r:(r.next=s.next,s.next=r),t.pending=r}function Nx(t,r,s){if((s&4194048)!==0){var c=r.lanes;c&=t.pendingLanes,s|=c,r.lanes=s,en(t,s)}}var Vs={readContext:Yn,use:kc,useCallback:xn,useContext:xn,useEffect:xn,useImperativeHandle:xn,useLayoutEffect:xn,useInsertionEffect:xn,useMemo:xn,useReducer:xn,useRef:xn,useState:xn,useDebugValue:xn,useDeferredValue:xn,useTransition:xn,useSyncExternalStore:xn,useId:xn,useHostTransitionStatus:xn,useFormState:xn,useActionState:xn,useOptimistic:xn,useMemoCache:xn,useCacheRefresh:xn};Vs.useEffectEvent=xn;var Ex={readContext:Yn,use:kc,useCallback:function(t,r){return tr().memoizedState=[t,r===void 0?null:r],t},useContext:Yn,useEffect:ux,useImperativeHandle:function(t,r,s){s=s!=null?s.concat([t]):null,Sc(4194308,4,mx.bind(null,r,t),s)},useLayoutEffect:function(t,r){return Sc(4194308,4,t,r)},useInsertionEffect:function(t,r){Sc(4,2,t,r)},useMemo:function(t,r){var s=tr();r=r===void 0?null:r;var c=t();if(oi){ze(!0);try{t()}finally{ze(!1)}}return s.memoizedState=[c,r],c},useReducer:function(t,r,s){var c=tr();if(s!==void 0){var p=s(r);if(oi){ze(!0);try{s(r)}finally{ze(!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=c2.bind(null,ht,t),[c.memoizedState,t]},useRef:function(t){var r=tr();return t={current:t},r.memoizedState=t},useState:function(t){t=Id(t);var r=t.queue,s=Sx.bind(null,ht,r);return r.dispatch=s,[t.memoizedState,s]},useDebugValue:qd,useDeferredValue:function(t,r){var s=tr();return Yd(s,t,r)},useTransition:function(){var t=Id(!1);return t=bx.bind(null,ht,t.queue,!0,!1),tr().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,r,s){var c=ht,p=tr();if(Ft){if(s===void 0)throw Error(i(407));s=s()}else{if(s=r(),tn===null)throw Error(i(349));(At&127)!==0||Gp(c,r,s)}p.memoizedState=s;var g={value:s,getSnapshot:r};return p.queue=g,ux(Qp.bind(null,c,g,t),[t]),c.flags|=2048,Pi(9,{destroy:void 0},Kp.bind(null,c,g,s,r),null),s},useId:function(){var t=tr(),r=tn.identifierPrefix;if(Ft){var s=xa,c=pa;s=(c&~(1<<32-Oe(c)-1)).toString(32)+s,r="_"+r+"R_"+s,s=vc++,0<s&&(r+="H"+s.toString(32)),r+="_"}else s=n2++,r="_"+r+"r_"+s.toString(32)+"_";return t.memoizedState=r},useHostTransitionStatus:Wd,useFormState:lx,useActionState:lx,useOptimistic:function(t){var r=tr();r.memoizedState=r.baseState=t;var s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return r.queue=s,r=Vd.bind(null,ht,!0,s),s.dispatch=r,[t,r]},useMemoCache:Od,useCacheRefresh:function(){return tr().memoizedState=o2.bind(null,ht)},useEffectEvent:function(t){var r=tr(),s={impl:t};return r.memoizedState=s,function(){if((It&2)!==0)throw Error(i(440));return s.impl.apply(void 0,arguments)}}},Gd={readContext:Yn,use:kc,useCallback:xx,useContext:Yn,useEffect:Ud,useImperativeHandle:px,useInsertionEffect:fx,useLayoutEffect:hx,useMemo:yx,useReducer:jc,useRef:cx,useState:function(){return jc(La)},useDebugValue:qd,useDeferredValue:function(t,r){var s=kn();return gx(s,Kt.memoizedState,t,r)},useTransition:function(){var t=jc(La)[0],r=kn().memoizedState;return[typeof t=="boolean"?t:Xs(t),r]},useSyncExternalStore:Vp,useId:kx,useHostTransitionStatus:Wd,useFormState:ix,useActionState:ix,useOptimistic:function(t,r){var s=kn();return Jp(s,Kt,t,r)},useMemoCache:Od,useCacheRefresh:jx};Gd.useEffectEvent=dx;var Ax={readContext:Yn,use:kc,useCallback:xx,useContext:Yn,useEffect:Ud,useImperativeHandle:px,useInsertionEffect:fx,useLayoutEffect:hx,useMemo:yx,useReducer:$d,useRef:cx,useState:function(){return $d(La)},useDebugValue:qd,useDeferredValue:function(t,r){var s=kn();return Kt===null?Yd(s,t,r):gx(s,Kt.memoizedState,t,r)},useTransition:function(){var t=$d(La)[0],r=kn().memoizedState;return[typeof t=="boolean"?t:Xs(t),r]},useSyncExternalStore:Vp,useId:kx,useHostTransitionStatus:Wd,useFormState:ox,useActionState:ox,useOptimistic:function(t,r){var s=kn();return Kt!==null?Jp(s,Kt,t,r):(s.baseState=t,[t,s.queue.dispatch])},useMemoCache:Od,useCacheRefresh:jx};Ax.useEffectEvent=dx;function Kd(t,r,s,c){r=t.memoizedState,s=s(c,r),s=s==null?r:y({},r,s),t.memoizedState=s,t.lanes===0&&(t.updateQueue.baseState=s)}var Qd={enqueueSetState:function(t,r,s){t=t._reactInternals;var c=Nr(),p=fl(c);p.payload=r,s!=null&&(p.callback=s),r=hl(t,p,c),r!==null&&(hr(r,t,c),Hs(r,t,c))},enqueueReplaceState:function(t,r,s){t=t._reactInternals;var c=Nr(),p=fl(c);p.tag=1,p.payload=r,s!=null&&(p.callback=s),r=hl(t,p,c),r!==null&&(hr(r,t,c),Hs(r,t,c))},enqueueForceUpdate:function(t,r){t=t._reactInternals;var s=Nr(),c=fl(s);c.tag=2,r!=null&&(c.callback=r),r=hl(t,c,s),r!==null&&(hr(r,t,s),Hs(r,t,s))}};function Dx(t,r,s,c,p,g,C){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(c,g,C):r.prototype&&r.prototype.isPureReactComponent?!Rs(s,c)||!Rs(p,g):!0}function Tx(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&&Qd.enqueueReplaceState(r,r.state,null)}function ci(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=y({},s));for(var p in t)s[p]===void 0&&(s[p]=t[p])}return s}function Fx(t){ac(t)}function Mx(t){console.error(t)}function Rx(t){ac(t)}function Ec(t,r){try{var s=t.onUncaughtError;s(r.value,{componentStack:r.stack})}catch(c){setTimeout(function(){throw c})}}function zx(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 Pd(t,r,s){return s=fl(s),s.tag=3,s.payload={element:null},s.callback=function(){Ec(t,r)},s}function _x(t){return t=fl(t),t.tag=3,t}function Bx(t,r,s,c){var p=s.type.getDerivedStateFromError;if(typeof p=="function"){var g=c.value;t.payload=function(){return p(g)},t.callback=function(){zx(r,s,c)}}var C=s.stateNode;C!==null&&typeof C.componentDidCatch=="function"&&(t.callback=function(){zx(r,s,c),typeof p!="function"&&(bl===null?bl=new Set([this]):bl.add(this));var z=c.stack;this.componentDidCatch(c.value,{componentStack:z!==null?z:""})})}function u2(t,r,s,c,p){if(s.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){if(r=s.alternate,r!==null&&qi(r,s,p,!0),s=kr.current,s!==null){switch(s.tag){case 31:case 13:return Hr===null?$c():s.alternate===null&&yn===0&&(yn=3),s.flags&=-257,s.flags|=65536,s.lanes=p,c===mc?s.flags|=16384:(r=s.updateQueue,r===null?s.updateQueue=new Set([c]):r.add(c),jf(t,c,p)),!1;case 22:return s.flags|=65536,c===mc?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)),jf(t,c,p)),!1}throw Error(i(435,s.tag))}return jf(t,c,p),$c(),!1}if(Ft)return r=kr.current,r!==null?((r.flags&65536)===0&&(r.flags|=256),r.flags|=65536,r.lanes=p,c!==xd&&(t=Error(i(422),{cause:c}),Bs(Or(t,s)))):(c!==xd&&(r=Error(i(423),{cause:c}),Bs(Or(r,s))),t=t.current.alternate,t.flags|=65536,p&=-p,t.lanes|=p,c=Or(c,s),p=Pd(t.stateNode,c,p),Ed(t,p),yn!==4&&(yn=2)),!1;var g=Error(i(520),{cause:c});if(g=Or(g,s),to===null?to=[g]:to.push(g),yn!==4&&(yn=2),r===null)return!0;c=Or(c,s),s=r;do{switch(s.tag){case 3:return s.flags|=65536,t=p&-p,s.lanes|=t,t=Pd(s.stateNode,c,t),Ed(s,t),!1;case 1:if(r=s.type,g=s.stateNode,(s.flags&128)===0&&(typeof r.getDerivedStateFromError=="function"||g!==null&&typeof g.componentDidCatch=="function"&&(bl===null||!bl.has(g))))return s.flags|=65536,p&=-p,s.lanes|=p,p=_x(p),Bx(p,t,s,c),Ed(s,p),!1}s=s.return}while(s!==null);return!1}var Zd=Error(i(461)),En=!1;function Xn(t,r,s,c){r.child=t===null?Ip(r,null,s,c):si(r,t.child,s,c)}function Ox(t,r,s,c,p){s=s.render;var g=r.ref;if("ref"in c){var C={};for(var z in c)z!=="ref"&&(C[z]=c[z])}else C=c;return ri(r),c=Rd(t,r,s,C,g,p),z=zd(),t!==null&&!En?(_d(t,r,p),$a(t,r,p)):(Ft&&z&&md(r),r.flags|=1,Xn(t,r,c,p),r.child)}function Lx(t,r,s,c,p){if(t===null){var g=s.type;return typeof g=="function"&&!dd(g)&&g.defaultProps===void 0&&s.compare===null?(r.tag=15,r.type=g,$x(t,r,g,c,p)):(t=oc(s.type,null,c,r,r.mode,p),t.ref=r.ref,t.return=r,r.child=t)}if(g=t.child,!sf(t,p)){var C=g.memoizedProps;if(s=s.compare,s=s!==null?s:Rs,s(C,c)&&t.ref===r.ref)return $a(t,r,p)}return r.flags|=1,t=Ra(g,c),t.ref=r.ref,t.return=r,r.child=t}function $x(t,r,s,c,p){if(t!==null){var g=t.memoizedProps;if(Rs(g,c)&&t.ref===r.ref)if(En=!1,r.pendingProps=c=g,sf(t,p))(t.flags&131072)!==0&&(En=!0);else return r.lanes=t.lanes,$a(t,r,p)}return Jd(t,r,s,c,p)}function Ix(t,r,s,c){var p=c.children,g=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(g=g!==null?g.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&~g}else c=0,r.child=null;return Hx(t,r,g,s,c)}if((s&536870912)!==0)r.memoizedState={baseLanes:0,cachePool:null},t!==null&&fc(r,g!==null?g.cachePool:null),g!==null?qp(r,g):Dd(),Yp(r);else return c=r.lanes=536870912,Hx(t,r,g!==null?g.baseLanes|s:s,s,c)}else g!==null?(fc(r,g.cachePool),qp(r,g),pl(),r.memoizedState=null):(t!==null&&fc(r,null),Dd(),pl());return Xn(t,r,p,s),r.child}function Gs(t,r){return t!==null&&t.tag===22||r.stateNode!==null||(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.sibling}function Hx(t,r,s,c,p){var g=jd();return g=g===null?null:{parent:Cn._currentValue,pool:g},r.memoizedState={baseLanes:s,cachePool:g},t!==null&&fc(r,null),Dd(),Yp(r),t!==null&&qi(t,r,c,!0),r.childLanes=p,null}function Ac(t,r){return r=Tc({mode:r.mode,children:r.children},t.mode),r.ref=t.ref,t.child=r,r.return=t,r}function Ux(t,r,s){return si(r,t.child,null,s),t=Ac(r,r.pendingProps),t.flags|=2,jr(r),r.memoizedState=null,t}function d2(t,r,s){var c=r.pendingProps,p=(r.flags&128)!==0;if(r.flags&=-129,t===null){if(Ft){if(c.mode==="hidden")return t=Ac(r,c),r.lanes=536870912,Gs(null,t);if(Fd(r),(t=cn)?(t=e0(t,Ir),t=t!==null&&t.data==="&"?t:null,t!==null&&(r.memoizedState={dehydrated:t,treeContext:sl!==null?{id:pa,overflow:xa}:null,retryLane:536870912,hydrationErrors:null},s=Cp(t),s.return=r,r.child=s,qn=r,cn=null)):t=null,t===null)throw cl(r);return r.lanes=536870912,null}return Ac(r,c)}var g=t.memoizedState;if(g!==null){var C=g.dehydrated;if(Fd(r),p)if(r.flags&256)r.flags&=-257,r=Ux(t,r,s);else if(r.memoizedState!==null)r.child=t.child,r.flags|=128,r=null;else throw Error(i(558));else if(En||qi(t,r,s,!1),p=(s&t.childLanes)!==0,En||p){if(c=tn,c!==null&&(C=Mr(c,s),C!==0&&C!==g.retryLane))throw g.retryLane=C,Jl(t,C),hr(c,t,C),Zd;$c(),r=Ux(t,r,s)}else t=g.treeContext,cn=Ur(C.nextSibling),qn=r,Ft=!0,ol=null,Ir=!1,t!==null&&Ap(r,t),r=Ac(r,c),r.flags|=4096;return r}return t=Ra(t.child,{mode:c.mode,children:c.children}),t.ref=r.ref,r.child=t,t.return=r,t}function Dc(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 Jd(t,r,s,c,p){return ri(r),s=Rd(t,r,s,c,void 0,p),c=zd(),t!==null&&!En?(_d(t,r,p),$a(t,r,p)):(Ft&&c&&md(r),r.flags|=1,Xn(t,r,s,p),r.child)}function qx(t,r,s,c,p,g){return ri(r),r.updateQueue=null,s=Wp(r,c,s,p),Xp(t),c=zd(),t!==null&&!En?(_d(t,r,g),$a(t,r,g)):(Ft&&c&&md(r),r.flags|=1,Xn(t,r,s,g),r.child)}function Yx(t,r,s,c,p){if(ri(r),r.stateNode===null){var g=$i,C=s.contextType;typeof C=="object"&&C!==null&&(g=Yn(C)),g=new s(c,g),r.memoizedState=g.state!==null&&g.state!==void 0?g.state:null,g.updater=Qd,r.stateNode=g,g._reactInternals=r,g=r.stateNode,g.props=c,g.state=r.memoizedState,g.refs={},Cd(r),C=s.contextType,g.context=typeof C=="object"&&C!==null?Yn(C):$i,g.state=r.memoizedState,C=s.getDerivedStateFromProps,typeof C=="function"&&(Kd(r,s,C,c),g.state=r.memoizedState),typeof s.getDerivedStateFromProps=="function"||typeof g.getSnapshotBeforeUpdate=="function"||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(C=g.state,typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount(),C!==g.state&&Qd.enqueueReplaceState(g,g.state,null),qs(r,c,g,p),Us(),g.state=r.memoizedState),typeof g.componentDidMount=="function"&&(r.flags|=4194308),c=!0}else if(t===null){g=r.stateNode;var z=r.memoizedProps,Y=ci(s,z);g.props=Y;var oe=g.context,pe=s.contextType;C=$i,typeof pe=="object"&&pe!==null&&(C=Yn(pe));var ke=s.getDerivedStateFromProps;pe=typeof ke=="function"||typeof g.getSnapshotBeforeUpdate=="function",z=r.pendingProps!==z,pe||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(z||oe!==C)&&Tx(r,g,c,C),dl=!1;var ue=r.memoizedState;g.state=ue,qs(r,c,g,p),Us(),oe=r.memoizedState,z||ue!==oe||dl?(typeof ke=="function"&&(Kd(r,s,ke,c),oe=r.memoizedState),(Y=dl||Dx(r,s,Y,c,ue,oe,C))?(pe||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount()),typeof g.componentDidMount=="function"&&(r.flags|=4194308)):(typeof g.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=c,r.memoizedState=oe),g.props=c,g.state=oe,g.context=C,c=Y):(typeof g.componentDidMount=="function"&&(r.flags|=4194308),c=!1)}else{g=r.stateNode,Nd(t,r),C=r.memoizedProps,pe=ci(s,C),g.props=pe,ke=r.pendingProps,ue=g.context,oe=s.contextType,Y=$i,typeof oe=="object"&&oe!==null&&(Y=Yn(oe)),z=s.getDerivedStateFromProps,(oe=typeof z=="function"||typeof g.getSnapshotBeforeUpdate=="function")||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(C!==ke||ue!==Y)&&Tx(r,g,c,Y),dl=!1,ue=r.memoizedState,g.state=ue,qs(r,c,g,p),Us();var fe=r.memoizedState;C!==ke||ue!==fe||dl||t!==null&&t.dependencies!==null&&uc(t.dependencies)?(typeof z=="function"&&(Kd(r,s,z,c),fe=r.memoizedState),(pe=dl||Dx(r,s,pe,c,ue,fe,Y)||t!==null&&t.dependencies!==null&&uc(t.dependencies))?(oe||typeof g.UNSAFE_componentWillUpdate!="function"&&typeof g.componentWillUpdate!="function"||(typeof g.componentWillUpdate=="function"&&g.componentWillUpdate(c,fe,Y),typeof g.UNSAFE_componentWillUpdate=="function"&&g.UNSAFE_componentWillUpdate(c,fe,Y)),typeof g.componentDidUpdate=="function"&&(r.flags|=4),typeof g.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof g.componentDidUpdate!="function"||C===t.memoizedProps&&ue===t.memoizedState||(r.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||C===t.memoizedProps&&ue===t.memoizedState||(r.flags|=1024),r.memoizedProps=c,r.memoizedState=fe),g.props=c,g.state=fe,g.context=Y,c=pe):(typeof g.componentDidUpdate!="function"||C===t.memoizedProps&&ue===t.memoizedState||(r.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||C===t.memoizedProps&&ue===t.memoizedState||(r.flags|=1024),c=!1)}return g=c,Dc(t,r),c=(r.flags&128)!==0,g||c?(g=r.stateNode,s=c&&typeof s.getDerivedStateFromError!="function"?null:g.render(),r.flags|=1,t!==null&&c?(r.child=si(r,t.child,null,p),r.child=si(r,null,s,p)):Xn(t,r,s,p),r.memoizedState=g.state,t=r.child):t=$a(t,r,p),t}function Xx(t,r,s,c){return ti(),r.flags|=256,Xn(t,r,s,c),r.child}var ef={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function tf(t){return{baseLanes:t,cachePool:zp()}}function nf(t,r,s){return t=t!==null?t.childLanes&~s:0,r&&(t|=Cr),t}function Wx(t,r,s){var c=r.pendingProps,p=!1,g=(r.flags&128)!==0,C;if((C=g)||(C=t!==null&&t.memoizedState===null?!1:(wn.current&2)!==0),C&&(p=!0,r.flags&=-129),C=(r.flags&32)!==0,r.flags&=-33,t===null){if(Ft){if(p?ml(r):pl(),(t=cn)?(t=e0(t,Ir),t=t!==null&&t.data!=="&"?t:null,t!==null&&(r.memoizedState={dehydrated:t,treeContext:sl!==null?{id:pa,overflow:xa}:null,retryLane:536870912,hydrationErrors:null},s=Cp(t),s.return=r,r.child=s,qn=r,cn=null)):t=null,t===null)throw cl(r);return $f(t)?r.lanes=32:r.lanes=536870912,null}var z=c.children;return c=c.fallback,p?(pl(),p=r.mode,z=Tc({mode:"hidden",children:z},p),c=ei(c,p,s,null),z.return=r,c.return=r,z.sibling=c,r.child=z,c=r.child,c.memoizedState=tf(s),c.childLanes=nf(t,C,s),r.memoizedState=ef,Gs(null,c)):(ml(r),rf(r,z))}var Y=t.memoizedState;if(Y!==null&&(z=Y.dehydrated,z!==null)){if(g)r.flags&256?(ml(r),r.flags&=-257,r=af(t,r,s)):r.memoizedState!==null?(pl(),r.child=t.child,r.flags|=128,r=null):(pl(),z=c.fallback,p=r.mode,c=Tc({mode:"visible",children:c.children},p),z=ei(z,p,s,null),z.flags|=2,c.return=r,z.return=r,c.sibling=z,r.child=c,si(r,t.child,null,s),c=r.child,c.memoizedState=tf(s),c.childLanes=nf(t,C,s),r.memoizedState=ef,r=Gs(null,c));else if(ml(r),$f(z)){if(C=z.nextSibling&&z.nextSibling.dataset,C)var oe=C.dgst;C=oe,c=Error(i(419)),c.stack="",c.digest=C,Bs({value:c,source:null,stack:null}),r=af(t,r,s)}else if(En||qi(t,r,s,!1),C=(s&t.childLanes)!==0,En||C){if(C=tn,C!==null&&(c=Mr(C,s),c!==0&&c!==Y.retryLane))throw Y.retryLane=c,Jl(t,c),hr(C,t,c),Zd;Lf(z)||$c(),r=af(t,r,s)}else Lf(z)?(r.flags|=192,r.child=t.child,r=null):(t=Y.treeContext,cn=Ur(z.nextSibling),qn=r,Ft=!0,ol=null,Ir=!1,t!==null&&Ap(r,t),r=rf(r,c.children),r.flags|=4096);return r}return p?(pl(),z=c.fallback,p=r.mode,Y=t.child,oe=Y.sibling,c=Ra(Y,{mode:"hidden",children:c.children}),c.subtreeFlags=Y.subtreeFlags&65011712,oe!==null?z=Ra(oe,z):(z=ei(z,p,s,null),z.flags|=2),z.return=r,c.return=r,c.sibling=z,r.child=c,Gs(null,c),c=r.child,z=t.child.memoizedState,z===null?z=tf(s):(p=z.cachePool,p!==null?(Y=Cn._currentValue,p=p.parent!==Y?{parent:Y,pool:Y}:p):p=zp(),z={baseLanes:z.baseLanes|s,cachePool:p}),c.memoizedState=z,c.childLanes=nf(t,C,s),r.memoizedState=ef,Gs(t.child,c)):(ml(r),s=t.child,t=s.sibling,s=Ra(s,{mode:"visible",children:c.children}),s.return=r,s.sibling=null,t!==null&&(C=r.deletions,C===null?(r.deletions=[t],r.flags|=16):C.push(t)),r.child=s,r.memoizedState=null,s)}function rf(t,r){return r=Tc({mode:"visible",children:r},t.mode),r.return=t,t.child=r}function Tc(t,r){return t=wr(22,t,null,r),t.lanes=0,t}function af(t,r,s){return si(r,t.child,null,s),t=rf(r,r.pendingProps.children),t.flags|=2,r.memoizedState=null,t}function Vx(t,r,s){t.lanes|=r;var c=t.alternate;c!==null&&(c.lanes|=r),bd(t.return,r,s)}function lf(t,r,s,c,p,g){var C=t.memoizedState;C===null?t.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:c,tail:s,tailMode:p,treeForkCount:g}:(C.isBackwards=r,C.rendering=null,C.renderingStartTime=0,C.last=c,C.tail=s,C.tailMode=p,C.treeForkCount=g)}function Gx(t,r,s){var c=r.pendingProps,p=c.revealOrder,g=c.tail;c=c.children;var C=wn.current,z=(C&2)!==0;if(z?(C=C&1|2,r.flags|=128):C&=1,A(wn,C),Xn(t,r,c,s),c=Ft?_s:0,!z&&t!==null&&(t.flags&128)!==0)e:for(t=r.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&Vx(t,s,r);else if(t.tag===19)Vx(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&&gc(t)===null&&(p=s),s=s.sibling;s=p,s===null?(p=r.child,r.child=null):(p=s.sibling,s.sibling=null),lf(r,!1,p,s,g,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&&gc(t)===null){r.child=p;break}t=p.sibling,p.sibling=s,s=p,p=t}lf(r,!0,s,null,g,c);break;case"together":lf(r,!1,null,null,void 0,c);break;default:r.memoizedState=null}return r.child}function $a(t,r,s){if(t!==null&&(r.dependencies=t.dependencies),gl|=r.lanes,(s&r.childLanes)===0)if(t!==null){if(qi(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=Ra(t,t.pendingProps),r.child=s,s.return=r;t.sibling!==null;)t=t.sibling,s=s.sibling=Ra(t,t.pendingProps),s.return=r;s.sibling=null}return r.child}function sf(t,r){return(t.lanes&r)!==0?!0:(t=t.dependencies,!!(t!==null&&uc(t)))}function f2(t,r,s){switch(r.tag){case 3:Ie(r,r.stateNode.containerInfo),ul(r,Cn,t.memoizedState.cache),ti();break;case 27:case 5:_e(r);break;case 4:Ie(r,r.stateNode.containerInfo);break;case 10:ul(r,r.type,r.memoizedProps.value);break;case 31:if(r.memoizedState!==null)return r.flags|=128,Fd(r),null;break;case 13:var c=r.memoizedState;if(c!==null)return c.dehydrated!==null?(ml(r),r.flags|=128,null):(s&r.child.childLanes)!==0?Wx(t,r,s):(ml(r),t=$a(t,r,s),t!==null?t.sibling:null);ml(r);break;case 19:var p=(t.flags&128)!==0;if(c=(s&r.childLanes)!==0,c||(qi(t,r,s,!1),c=(s&r.childLanes)!==0),p){if(c)return Gx(t,r,s);r.flags|=128}if(p=r.memoizedState,p!==null&&(p.rendering=null,p.tail=null,p.lastEffect=null),A(wn,wn.current),c)break;return null;case 22:return r.lanes=0,Ix(t,r,s,r.pendingProps);case 24:ul(r,Cn,t.memoizedState.cache)}return $a(t,r,s)}function Kx(t,r,s){if(t!==null)if(t.memoizedProps!==r.pendingProps)En=!0;else{if(!sf(t,s)&&(r.flags&128)===0)return En=!1,f2(t,r,s);En=(t.flags&131072)!==0}else En=!1,Ft&&(r.flags&1048576)!==0&&Ep(r,_s,r.index);switch(r.lanes=0,r.tag){case 16:e:{var c=r.pendingProps;if(t=li(r.elementType),r.type=t,typeof t=="function")dd(t)?(c=ci(t,c),r.tag=1,r=Yx(null,r,t,c,s)):(r.tag=0,r=Jd(null,r,t,c,s));else{if(t!=null){var p=t.$$typeof;if(p===R){r.tag=11,r=Ox(null,r,t,c,s);break e}else if(p===$){r.tag=14,r=Lx(null,r,t,c,s);break e}}throw r=ce(t)||t,Error(i(306,r,""))}}return r;case 0:return Jd(t,r,r.type,r.pendingProps,s);case 1:return c=r.type,p=ci(c,r.pendingProps),Yx(t,r,c,p,s);case 3:e:{if(Ie(r,r.stateNode.containerInfo),t===null)throw Error(i(387));c=r.pendingProps;var g=r.memoizedState;p=g.element,Nd(t,r),qs(r,c,null,s);var C=r.memoizedState;if(c=C.cache,ul(r,Cn,c),c!==g.cache&&vd(r,[Cn],s,!0),Us(),c=C.element,g.isDehydrated)if(g={element:c,isDehydrated:!1,cache:C.cache},r.updateQueue.baseState=g,r.memoizedState=g,r.flags&256){r=Xx(t,r,c,s);break e}else if(c!==p){p=Or(Error(i(424)),r),Bs(p),r=Xx(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(cn=Ur(t.firstChild),qn=r,Ft=!0,ol=null,Ir=!0,s=Ip(r,null,c,s),r.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling}else{if(ti(),c===p){r=$a(t,r,s);break e}Xn(t,r,c,s)}r=r.child}return r;case 26:return Dc(t,r),t===null?(s=i0(r.type,null,r.pendingProps,null))?r.memoizedState=s:Ft||(s=r.type,t=r.pendingProps,c=Wc(he.current).createElement(s),c[Fn]=r,c[Ln]=t,Wn(c,s,t),pn(c),r.stateNode=c):r.memoizedState=i0(r.type,t.memoizedProps,r.pendingProps,t.memoizedState),null;case 27:return _e(r),t===null&&Ft&&(c=r.stateNode=r0(r.type,r.pendingProps,he.current),qn=r,Ir=!0,p=cn,jl(r.type)?(If=p,cn=Ur(c.firstChild)):cn=p),Xn(t,r,r.pendingProps.children,s),Dc(t,r),t===null&&(r.flags|=4194304),r.child;case 5:return t===null&&Ft&&((p=c=cn)&&(c=U2(c,r.type,r.pendingProps,Ir),c!==null?(r.stateNode=c,qn=r,cn=Ur(c.firstChild),Ir=!1,p=!0):p=!1),p||cl(r)),_e(r),p=r.type,g=r.pendingProps,C=t!==null?t.memoizedProps:null,c=g.children,_f(p,g)?c=null:C!==null&&_f(p,C)&&(r.flags|=32),r.memoizedState!==null&&(p=Rd(t,r,r2,null,null,s),co._currentValue=p),Dc(t,r),Xn(t,r,c,s),r.child;case 6:return t===null&&Ft&&((t=s=cn)&&(s=q2(s,r.pendingProps,Ir),s!==null?(r.stateNode=s,qn=r,cn=null,t=!0):t=!1),t||cl(r)),null;case 13:return Wx(t,r,s);case 4:return Ie(r,r.stateNode.containerInfo),c=r.pendingProps,t===null?r.child=si(r,null,c,s):Xn(t,r,c,s),r.child;case 11:return Ox(t,r,r.type,r.pendingProps,s);case 7:return Xn(t,r,r.pendingProps,s),r.child;case 8:return Xn(t,r,r.pendingProps.children,s),r.child;case 12:return Xn(t,r,r.pendingProps.children,s),r.child;case 10:return c=r.pendingProps,ul(r,r.type,c.value),Xn(t,r,c.children,s),r.child;case 9:return p=r.type._context,c=r.pendingProps.children,ri(r),p=Yn(p),c=c(p),r.flags|=1,Xn(t,r,c,s),r.child;case 14:return Lx(t,r,r.type,r.pendingProps,s);case 15:return $x(t,r,r.type,r.pendingProps,s);case 19:return Gx(t,r,s);case 31:return d2(t,r,s);case 22:return Ix(t,r,s,r.pendingProps);case 24:return ri(r),c=Yn(Cn),t===null?(p=jd(),p===null&&(p=tn,g=wd(),p.pooledCache=g,g.refCount++,g!==null&&(p.pooledCacheLanes|=s),p=g),r.memoizedState={parent:c,cache:p},Cd(r),ul(r,Cn,p)):((t.lanes&s)!==0&&(Nd(t,r),qs(r,null,null,s),Us()),p=t.memoizedState,g=r.memoizedState,p.parent!==c?(p={parent:c,cache:c},r.memoizedState=p,r.lanes===0&&(r.memoizedState=r.updateQueue.baseState=p),ul(r,Cn,c)):(c=g.cache,ul(r,Cn,c),c!==p.cache&&vd(r,[Cn],s,!0))),Xn(t,r,r.pendingProps.children,s),r.child;case 29:throw r.pendingProps}throw Error(i(156,r.tag))}function Ia(t){t.flags|=4}function of(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(k1())t.flags|=8192;else throw ii=mc,Sd}else t.flags&=-16777217}function Qx(t,r){if(r.type!=="stylesheet"||(r.state.loading&4)!==0)t.flags&=-16777217;else if(t.flags|=16777216,!d0(r))if(k1())t.flags|=8192;else throw ii=mc,Sd}function Fc(t,r){r!==null&&(t.flags|=4),t.flags&16384&&(r=t.tag!==22?et():536870912,t.lanes|=r,ts|=r)}function Ks(t,r){if(!Ft)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 un(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 h2(t,r,s){var c=r.pendingProps;switch(pd(r),r.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return un(r),null;case 1:return un(r),null;case 3:return s=r.stateNode,c=null,t!==null&&(c=t.memoizedState.cache),r.memoizedState.cache!==c&&(r.flags|=2048),Ba(Cn),de(),s.pendingContext&&(s.context=s.pendingContext,s.pendingContext=null),(t===null||t.child===null)&&(Ui(r)?Ia(r):t===null||t.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,yd())),un(r),null;case 26:var p=r.type,g=r.memoizedState;return t===null?(Ia(r),g!==null?(un(r),Qx(r,g)):(un(r),of(r,p,null,c,s))):g?g!==t.memoizedState?(Ia(r),un(r),Qx(r,g)):(un(r),r.flags&=-16777217):(t=t.memoizedProps,t!==c&&Ia(r),un(r),of(r,p,t,c,s)),null;case 27:if(Ye(r),s=he.current,p=r.type,t!==null&&r.stateNode!=null)t.memoizedProps!==c&&Ia(r);else{if(!c){if(r.stateNode===null)throw Error(i(166));return un(r),null}t=Q.current,Ui(r)?Dp(r):(t=r0(p,c,s),r.stateNode=t,Ia(r))}return un(r),null;case 5:if(Ye(r),p=r.type,t!==null&&r.stateNode!=null)t.memoizedProps!==c&&Ia(r);else{if(!c){if(r.stateNode===null)throw Error(i(166));return un(r),null}if(g=Q.current,Ui(r))Dp(r);else{var C=Wc(he.current);switch(g){case 1:g=C.createElementNS("http://www.w3.org/2000/svg",p);break;case 2:g=C.createElementNS("http://www.w3.org/1998/Math/MathML",p);break;default:switch(p){case"svg":g=C.createElementNS("http://www.w3.org/2000/svg",p);break;case"math":g=C.createElementNS("http://www.w3.org/1998/Math/MathML",p);break;case"script":g=C.createElement("div"),g.innerHTML="<script><\/script>",g=g.removeChild(g.firstChild);break;case"select":g=typeof c.is=="string"?C.createElement("select",{is:c.is}):C.createElement("select"),c.multiple?g.multiple=!0:c.size&&(g.size=c.size);break;default:g=typeof c.is=="string"?C.createElement(p,{is:c.is}):C.createElement(p)}}g[Fn]=r,g[Ln]=c;e:for(C=r.child;C!==null;){if(C.tag===5||C.tag===6)g.appendChild(C.stateNode);else if(C.tag!==4&&C.tag!==27&&C.child!==null){C.child.return=C,C=C.child;continue}if(C===r)break e;for(;C.sibling===null;){if(C.return===null||C.return===r)break e;C=C.return}C.sibling.return=C.return,C=C.sibling}r.stateNode=g;e:switch(Wn(g,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&&Ia(r)}}return un(r),of(r,r.type,t===null?null:t.memoizedProps,r.pendingProps,s),null;case 6:if(t&&r.stateNode!=null)t.memoizedProps!==c&&Ia(r);else{if(typeof c!="string"&&r.stateNode===null)throw Error(i(166));if(t=he.current,Ui(r)){if(t=r.stateNode,s=r.memoizedProps,c=null,p=qn,p!==null)switch(p.tag){case 27:case 5:c=p.memoizedProps}t[Fn]=r,t=!!(t.nodeValue===s||c!==null&&c.suppressHydrationWarning===!0||W1(t.nodeValue,s)),t||cl(r,!0)}else t=Wc(t).createTextNode(c),t[Fn]=r,r.stateNode=t}return un(r),null;case 31:if(s=r.memoizedState,t===null||t.memoizedState!==null){if(c=Ui(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[Fn]=r}else ti(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;un(r),t=!1}else s=yd(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=s),t=!0;if(!t)return r.flags&256?(jr(r),r):(jr(r),null);if((r.flags&128)!==0)throw Error(i(558))}return un(r),null;case 13:if(c=r.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(p=Ui(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[Fn]=r}else ti(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;un(r),p=!1}else p=yd(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=p),p=!0;if(!p)return r.flags&256?(jr(r),r):(jr(r),null)}return jr(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),g=null,c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(g=c.memoizedState.cachePool.pool),g!==p&&(c.flags|=2048)),s!==t&&s&&(r.child.flags|=8192),Fc(r,r.updateQueue),un(r),null);case 4:return de(),t===null&&Tf(r.stateNode.containerInfo),un(r),null;case 10:return Ba(r.type),un(r),null;case 19:if(W(wn),c=r.memoizedState,c===null)return un(r),null;if(p=(r.flags&128)!==0,g=c.rendering,g===null)if(p)Ks(c,!1);else{if(yn!==0||t!==null&&(t.flags&128)!==0)for(t=r.child;t!==null;){if(g=gc(t),g!==null){for(r.flags|=128,Ks(c,!1),t=g.updateQueue,r.updateQueue=t,Fc(r,t),r.subtreeFlags=0,t=s,s=r.child;s!==null;)Sp(s,t),s=s.sibling;return A(wn,wn.current&1|2),Ft&&za(r,c.treeForkCount),r.child}t=t.sibling}c.tail!==null&&Wt()>Bc&&(r.flags|=128,p=!0,Ks(c,!1),r.lanes=4194304)}else{if(!p)if(t=gc(g),t!==null){if(r.flags|=128,p=!0,t=t.updateQueue,r.updateQueue=t,Fc(r,t),Ks(c,!0),c.tail===null&&c.tailMode==="hidden"&&!g.alternate&&!Ft)return un(r),null}else 2*Wt()-c.renderingStartTime>Bc&&s!==536870912&&(r.flags|=128,p=!0,Ks(c,!1),r.lanes=4194304);c.isBackwards?(g.sibling=r.child,r.child=g):(t=c.last,t!==null?t.sibling=g:r.child=g,c.last=g)}return c.tail!==null?(t=c.tail,c.rendering=t,c.tail=t.sibling,c.renderingStartTime=Wt(),t.sibling=null,s=wn.current,A(wn,p?s&1|2:s&1),Ft&&za(r,c.treeForkCount),t):(un(r),null);case 22:case 23:return jr(r),Td(),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&&(un(r),r.subtreeFlags&6&&(r.flags|=8192)):un(r),s=r.updateQueue,s!==null&&Fc(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&&W(ai),null;case 24:return s=null,t!==null&&(s=t.memoizedState.cache),r.memoizedState.cache!==s&&(r.flags|=2048),Ba(Cn),un(r),null;case 25:return null;case 30:return null}throw Error(i(156,r.tag))}function m2(t,r){switch(pd(r),r.tag){case 1:return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 3:return Ba(Cn),de(),t=r.flags,(t&65536)!==0&&(t&128)===0?(r.flags=t&-65537|128,r):null;case 26:case 27:case 5:return Ye(r),null;case 31:if(r.memoizedState!==null){if(jr(r),r.alternate===null)throw Error(i(340));ti()}return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 13:if(jr(r),t=r.memoizedState,t!==null&&t.dehydrated!==null){if(r.alternate===null)throw Error(i(340));ti()}return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 19:return W(wn),null;case 4:return de(),null;case 10:return Ba(r.type),null;case 22:case 23:return jr(r),Td(),t!==null&&W(ai),t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 24:return Ba(Cn),null;case 25:return null;default:return null}}function Px(t,r){switch(pd(r),r.tag){case 3:Ba(Cn),de();break;case 26:case 27:case 5:Ye(r);break;case 4:de();break;case 31:r.memoizedState!==null&&jr(r);break;case 13:jr(r);break;case 19:W(wn);break;case 10:Ba(r.type);break;case 22:case 23:jr(r),Td(),t!==null&&W(ai);break;case 24:Ba(Cn)}}function Qs(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 g=s.create,C=s.inst;c=g(),C.destroy=c}s=s.next}while(s!==p)}}catch(z){Xt(r,r.return,z)}}function xl(t,r,s){try{var c=r.updateQueue,p=c!==null?c.lastEffect:null;if(p!==null){var g=p.next;c=g;do{if((c.tag&t)===t){var C=c.inst,z=C.destroy;if(z!==void 0){C.destroy=void 0,p=r;var Y=s,oe=z;try{oe()}catch(pe){Xt(p,Y,pe)}}}c=c.next}while(c!==g)}}catch(pe){Xt(r,r.return,pe)}}function Zx(t){var r=t.updateQueue;if(r!==null){var s=t.stateNode;try{Up(r,s)}catch(c){Xt(t,t.return,c)}}}function Jx(t,r,s){s.props=ci(t.type,t.memoizedProps),s.state=t.memoizedState;try{s.componentWillUnmount()}catch(c){Xt(t,r,c)}}function Ps(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){Xt(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){Xt(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){Xt(t,r,p)}else s.current=null}function e1(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){Xt(t,t.return,p)}}function cf(t,r,s){try{var c=t.stateNode;B2(c,t.type,s,r),c[Ln]=r}catch(p){Xt(t,t.return,p)}}function t1(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&jl(t.type)||t.tag===4}function uf(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||t1(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&&jl(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 df(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=$n));else if(c!==4&&(c===27&&jl(t.type)&&(s=t.stateNode,r=null),t=t.child,t!==null))for(df(t,r,s),t=t.sibling;t!==null;)df(t,r,s),t=t.sibling}function Mc(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&&jl(t.type)&&(s=t.stateNode),t=t.child,t!==null))for(Mc(t,r,s),t=t.sibling;t!==null;)Mc(t,r,s),t=t.sibling}function n1(t){var r=t.stateNode,s=t.memoizedProps;try{for(var c=t.type,p=r.attributes;p.length;)r.removeAttributeNode(p[0]);Wn(r,c,s),r[Fn]=t,r[Ln]=s}catch(g){Xt(t,t.return,g)}}var Ha=!1,An=!1,ff=!1,r1=typeof WeakSet=="function"?WeakSet:Set,In=null;function p2(t,r){if(t=t.containerInfo,Rf=Jc,t=pp(t),ad(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,g=c.focusNode;c=c.focusOffset;try{s.nodeType,g.nodeType}catch{s=null;break e}var C=0,z=-1,Y=-1,oe=0,pe=0,ke=t,ue=null;t:for(;;){for(var fe;ke!==s||p!==0&&ke.nodeType!==3||(z=C+p),ke!==g||c!==0&&ke.nodeType!==3||(Y=C+c),ke.nodeType===3&&(C+=ke.nodeValue.length),(fe=ke.firstChild)!==null;)ue=ke,ke=fe;for(;;){if(ke===t)break t;if(ue===s&&++oe===p&&(z=C),ue===g&&++pe===c&&(Y=C),(fe=ke.nextSibling)!==null)break;ke=ue,ue=ke.parentNode}ke=fe}s=z===-1||Y===-1?null:{start:z,end:Y}}else s=null}s=s||{start:0,end:0}}else s=null;for(zf={focusedElem:t,selectionRange:s},Jc=!1,In=r;In!==null;)if(r=In,t=r.child,(r.subtreeFlags&1028)!==0&&t!==null)t.return=r,In=t;else for(;In!==null;){switch(r=In,g=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&&g!==null){t=void 0,s=r,p=g.memoizedProps,g=g.memoizedState,c=s.stateNode;try{var He=ci(s.type,p);t=c.getSnapshotBeforeUpdate(He,g),c.__reactInternalSnapshotBeforeUpdate=t}catch(tt){Xt(s,s.return,tt)}}break;case 3:if((t&1024)!==0){if(t=r.stateNode.containerInfo,s=t.nodeType,s===9)Of(t);else if(s===1)switch(t.nodeName){case"HEAD":case"HTML":case"BODY":Of(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,In=t;break}In=r.return}}function a1(t,r,s){var c=s.flags;switch(s.tag){case 0:case 11:case 15:qa(t,s),c&4&&Qs(5,s);break;case 1:if(qa(t,s),c&4)if(t=s.stateNode,r===null)try{t.componentDidMount()}catch(C){Xt(s,s.return,C)}else{var p=ci(s.type,r.memoizedProps);r=r.memoizedState;try{t.componentDidUpdate(p,r,t.__reactInternalSnapshotBeforeUpdate)}catch(C){Xt(s,s.return,C)}}c&64&&Zx(s),c&512&&Ps(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{Up(t,r)}catch(C){Xt(s,s.return,C)}}break;case 27:r===null&&c&4&&n1(s);case 26:case 5:qa(t,s),r===null&&c&4&&e1(s),c&512&&Ps(s,s.return);break;case 12:qa(t,s);break;case 31:qa(t,s),c&4&&s1(t,s);break;case 13:qa(t,s),c&4&&o1(t,s),c&64&&(t=s.memoizedState,t!==null&&(t=t.dehydrated,t!==null&&(s=S2.bind(null,s),Y2(t,s))));break;case 22:if(c=s.memoizedState!==null||Ha,!c){r=r!==null&&r.memoizedState!==null||An,p=Ha;var g=An;Ha=c,(An=r)&&!g?Ya(t,s,(s.subtreeFlags&8772)!==0):qa(t,s),Ha=p,An=g}break;case 30:break;default:qa(t,s)}}function l1(t){var r=t.alternate;r!==null&&(t.alternate=null,l1(r)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(r=t.stateNode,r!==null&&Ci(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 dn=null,cr=!1;function Ua(t,r,s){for(s=s.child;s!==null;)i1(t,r,s),s=s.sibling}function i1(t,r,s){if(Re&&typeof Re.onCommitFiberUnmount=="function")try{Re.onCommitFiberUnmount($e,s)}catch{}switch(s.tag){case 26:An||ya(s,r),Ua(t,r,s),s.memoizedState?s.memoizedState.count--:s.stateNode&&(s=s.stateNode,s.parentNode.removeChild(s));break;case 27:An||ya(s,r);var c=dn,p=cr;jl(s.type)&&(dn=s.stateNode,cr=!1),Ua(t,r,s),io(s.stateNode),dn=c,cr=p;break;case 5:An||ya(s,r);case 6:if(c=dn,p=cr,dn=null,Ua(t,r,s),dn=c,cr=p,dn!==null)if(cr)try{(dn.nodeType===9?dn.body:dn.nodeName==="HTML"?dn.ownerDocument.body:dn).removeChild(s.stateNode)}catch(g){Xt(s,r,g)}else try{dn.removeChild(s.stateNode)}catch(g){Xt(s,r,g)}break;case 18:dn!==null&&(cr?(t=dn,Z1(t.nodeType===9?t.body:t.nodeName==="HTML"?t.ownerDocument.body:t,s.stateNode),cs(t)):Z1(dn,s.stateNode));break;case 4:c=dn,p=cr,dn=s.stateNode.containerInfo,cr=!0,Ua(t,r,s),dn=c,cr=p;break;case 0:case 11:case 14:case 15:xl(2,s,r),An||xl(4,s,r),Ua(t,r,s);break;case 1:An||(ya(s,r),c=s.stateNode,typeof c.componentWillUnmount=="function"&&Jx(s,r,c)),Ua(t,r,s);break;case 21:Ua(t,r,s);break;case 22:An=(c=An)||s.memoizedState!==null,Ua(t,r,s),An=c;break;default:Ua(t,r,s)}}function s1(t,r){if(r.memoizedState===null&&(t=r.alternate,t!==null&&(t=t.memoizedState,t!==null))){t=t.dehydrated;try{cs(t)}catch(s){Xt(r,r.return,s)}}}function o1(t,r){if(r.memoizedState===null&&(t=r.alternate,t!==null&&(t=t.memoizedState,t!==null&&(t=t.dehydrated,t!==null))))try{cs(t)}catch(s){Xt(r,r.return,s)}}function x2(t){switch(t.tag){case 31:case 13:case 19:var r=t.stateNode;return r===null&&(r=t.stateNode=new r1),r;case 22:return t=t.stateNode,r=t._retryCache,r===null&&(r=t._retryCache=new r1),r;default:throw Error(i(435,t.tag))}}function Rc(t,r){var s=x2(t);r.forEach(function(c){if(!s.has(c)){s.add(c);var p=C2.bind(null,t,c);c.then(p,p)}})}function ur(t,r){var s=r.deletions;if(s!==null)for(var c=0;c<s.length;c++){var p=s[c],g=t,C=r,z=C;e:for(;z!==null;){switch(z.tag){case 27:if(jl(z.type)){dn=z.stateNode,cr=!1;break e}break;case 5:dn=z.stateNode,cr=!1;break e;case 3:case 4:dn=z.stateNode.containerInfo,cr=!0;break e}z=z.return}if(dn===null)throw Error(i(160));i1(g,C,p),dn=null,cr=!1,g=p.alternate,g!==null&&(g.return=null),p.return=null}if(r.subtreeFlags&13886)for(r=r.child;r!==null;)c1(r,t),r=r.sibling}var ra=null;function c1(t,r){var s=t.alternate,c=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:ur(r,t),dr(t),c&4&&(xl(3,t,t.return),Qs(3,t),xl(5,t,t.return));break;case 1:ur(r,t),dr(t),c&512&&(An||s===null||ya(s,s.return)),c&64&&Ha&&(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=ra;if(ur(r,t),dr(t),c&512&&(An||s===null||ya(s,s.return)),c&4){var g=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":g=p.getElementsByTagName("title")[0],(!g||g[Da]||g[Fn]||g.namespaceURI==="http://www.w3.org/2000/svg"||g.hasAttribute("itemprop"))&&(g=p.createElement(c),p.head.insertBefore(g,p.querySelector("head > title"))),Wn(g,c,s),g[Fn]=t,pn(g),c=g;break e;case"link":var C=c0("link","href",p).get(c+(s.href||""));if(C){for(var z=0;z<C.length;z++)if(g=C[z],g.getAttribute("href")===(s.href==null||s.href===""?null:s.href)&&g.getAttribute("rel")===(s.rel==null?null:s.rel)&&g.getAttribute("title")===(s.title==null?null:s.title)&&g.getAttribute("crossorigin")===(s.crossOrigin==null?null:s.crossOrigin)){C.splice(z,1);break t}}g=p.createElement(c),Wn(g,c,s),p.head.appendChild(g);break;case"meta":if(C=c0("meta","content",p).get(c+(s.content||""))){for(z=0;z<C.length;z++)if(g=C[z],g.getAttribute("content")===(s.content==null?null:""+s.content)&&g.getAttribute("name")===(s.name==null?null:s.name)&&g.getAttribute("property")===(s.property==null?null:s.property)&&g.getAttribute("http-equiv")===(s.httpEquiv==null?null:s.httpEquiv)&&g.getAttribute("charset")===(s.charSet==null?null:s.charSet)){C.splice(z,1);break t}}g=p.createElement(c),Wn(g,c,s),p.head.appendChild(g);break;default:throw Error(i(468,c))}g[Fn]=t,pn(g),c=g}t.stateNode=c}else u0(p,t.type,t.stateNode);else t.stateNode=o0(p,c,t.memoizedProps);else g!==c?(g===null?s.stateNode!==null&&(s=s.stateNode,s.parentNode.removeChild(s)):g.count--,c===null?u0(p,t.type,t.stateNode):o0(p,c,t.memoizedProps)):c===null&&t.stateNode!==null&&cf(t,t.memoizedProps,s.memoizedProps)}break;case 27:ur(r,t),dr(t),c&512&&(An||s===null||ya(s,s.return)),s!==null&&c&4&&cf(t,t.memoizedProps,s.memoizedProps);break;case 5:if(ur(r,t),dr(t),c&512&&(An||s===null||ya(s,s.return)),t.flags&32){p=t.stateNode;try{on(p,"")}catch(He){Xt(t,t.return,He)}}c&4&&t.stateNode!=null&&(p=t.memoizedProps,cf(t,p,s!==null?s.memoizedProps:p)),c&1024&&(ff=!0);break;case 6:if(ur(r,t),dr(t),c&4){if(t.stateNode===null)throw Error(i(162));c=t.memoizedProps,s=t.stateNode;try{s.nodeValue=c}catch(He){Xt(t,t.return,He)}}break;case 3:if(Kc=null,p=ra,ra=Vc(r.containerInfo),ur(r,t),ra=p,dr(t),c&4&&s!==null&&s.memoizedState.isDehydrated)try{cs(r.containerInfo)}catch(He){Xt(t,t.return,He)}ff&&(ff=!1,u1(t));break;case 4:c=ra,ra=Vc(t.stateNode.containerInfo),ur(r,t),dr(t),ra=c;break;case 12:ur(r,t),dr(t);break;case 31:ur(r,t),dr(t),c&4&&(c=t.updateQueue,c!==null&&(t.updateQueue=null,Rc(t,c)));break;case 13:ur(r,t),dr(t),t.child.flags&8192&&t.memoizedState!==null!=(s!==null&&s.memoizedState!==null)&&(_c=Wt()),c&4&&(c=t.updateQueue,c!==null&&(t.updateQueue=null,Rc(t,c)));break;case 22:p=t.memoizedState!==null;var Y=s!==null&&s.memoizedState!==null,oe=Ha,pe=An;if(Ha=oe||p,An=pe||Y,ur(r,t),An=pe,Ha=oe,dr(t),c&8192)e:for(r=t.stateNode,r._visibility=p?r._visibility&-2:r._visibility|1,p&&(s===null||Y||Ha||An||ui(t)),s=null,r=t;;){if(r.tag===5||r.tag===26){if(s===null){Y=s=r;try{if(g=Y.stateNode,p)C=g.style,typeof C.setProperty=="function"?C.setProperty("display","none","important"):C.display="none";else{z=Y.stateNode;var ke=Y.memoizedProps.style,ue=ke!=null&&ke.hasOwnProperty("display")?ke.display:null;z.style.display=ue==null||typeof ue=="boolean"?"":(""+ue).trim()}}catch(He){Xt(Y,Y.return,He)}}}else if(r.tag===6){if(s===null){Y=r;try{Y.stateNode.nodeValue=p?"":Y.memoizedProps}catch(He){Xt(Y,Y.return,He)}}}else if(r.tag===18){if(s===null){Y=r;try{var fe=Y.stateNode;p?J1(fe,!0):J1(Y.stateNode,!1)}catch(He){Xt(Y,Y.return,He)}}}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,Rc(t,s))));break;case 19:ur(r,t),dr(t),c&4&&(c=t.updateQueue,c!==null&&(t.updateQueue=null,Rc(t,c)));break;case 30:break;case 21:break;default:ur(r,t),dr(t)}}function dr(t){var r=t.flags;if(r&2){try{for(var s,c=t.return;c!==null;){if(t1(c)){s=c;break}c=c.return}if(s==null)throw Error(i(160));switch(s.tag){case 27:var p=s.stateNode,g=uf(t);Mc(t,g,p);break;case 5:var C=s.stateNode;s.flags&32&&(on(C,""),s.flags&=-33);var z=uf(t);Mc(t,z,C);break;case 3:case 4:var Y=s.stateNode.containerInfo,oe=uf(t);df(t,oe,Y);break;default:throw Error(i(161))}}catch(pe){Xt(t,t.return,pe)}t.flags&=-3}r&4096&&(t.flags&=-4097)}function u1(t){if(t.subtreeFlags&1024)for(t=t.child;t!==null;){var r=t;u1(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;)a1(t,r.alternate,r),r=r.sibling}function ui(t){for(t=t.child;t!==null;){var r=t;switch(r.tag){case 0:case 11:case 14:case 15:xl(4,r,r.return),ui(r);break;case 1:ya(r,r.return);var s=r.stateNode;typeof s.componentWillUnmount=="function"&&Jx(r,r.return,s),ui(r);break;case 27:io(r.stateNode);case 26:case 5:ya(r,r.return),ui(r);break;case 22:r.memoizedState===null&&ui(r);break;case 30:ui(r);break;default:ui(r)}t=t.sibling}}function Ya(t,r,s){for(s=s&&(r.subtreeFlags&8772)!==0,r=r.child;r!==null;){var c=r.alternate,p=t,g=r,C=g.flags;switch(g.tag){case 0:case 11:case 15:Ya(p,g,s),Qs(4,g);break;case 1:if(Ya(p,g,s),c=g,p=c.stateNode,typeof p.componentDidMount=="function")try{p.componentDidMount()}catch(oe){Xt(c,c.return,oe)}if(c=g,p=c.updateQueue,p!==null){var z=c.stateNode;try{var Y=p.shared.hiddenCallbacks;if(Y!==null)for(p.shared.hiddenCallbacks=null,p=0;p<Y.length;p++)Hp(Y[p],z)}catch(oe){Xt(c,c.return,oe)}}s&&C&64&&Zx(g),Ps(g,g.return);break;case 27:n1(g);case 26:case 5:Ya(p,g,s),s&&c===null&&C&4&&e1(g),Ps(g,g.return);break;case 12:Ya(p,g,s);break;case 31:Ya(p,g,s),s&&C&4&&s1(p,g);break;case 13:Ya(p,g,s),s&&C&4&&o1(p,g);break;case 22:g.memoizedState===null&&Ya(p,g,s),Ps(g,g.return);break;case 30:break;default:Ya(p,g,s)}r=r.sibling}}function hf(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&&Os(s))}function mf(t,r){t=null,r.alternate!==null&&(t=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==t&&(r.refCount++,t!=null&&Os(t))}function aa(t,r,s,c){if(r.subtreeFlags&10256)for(r=r.child;r!==null;)d1(t,r,s,c),r=r.sibling}function d1(t,r,s,c){var p=r.flags;switch(r.tag){case 0:case 11:case 15:aa(t,r,s,c),p&2048&&Qs(9,r);break;case 1:aa(t,r,s,c);break;case 3:aa(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&&Os(t)));break;case 12:if(p&2048){aa(t,r,s,c),t=r.stateNode;try{var g=r.memoizedProps,C=g.id,z=g.onPostCommit;typeof z=="function"&&z(C,r.alternate===null?"mount":"update",t.passiveEffectDuration,-0)}catch(Y){Xt(r,r.return,Y)}}else aa(t,r,s,c);break;case 31:aa(t,r,s,c);break;case 13:aa(t,r,s,c);break;case 23:break;case 22:g=r.stateNode,C=r.alternate,r.memoizedState!==null?g._visibility&2?aa(t,r,s,c):Zs(t,r):g._visibility&2?aa(t,r,s,c):(g._visibility|=2,Zi(t,r,s,c,(r.subtreeFlags&10256)!==0||!1)),p&2048&&hf(C,r);break;case 24:aa(t,r,s,c),p&2048&&mf(r.alternate,r);break;default:aa(t,r,s,c)}}function Zi(t,r,s,c,p){for(p=p&&((r.subtreeFlags&10256)!==0||!1),r=r.child;r!==null;){var g=t,C=r,z=s,Y=c,oe=C.flags;switch(C.tag){case 0:case 11:case 15:Zi(g,C,z,Y,p),Qs(8,C);break;case 23:break;case 22:var pe=C.stateNode;C.memoizedState!==null?pe._visibility&2?Zi(g,C,z,Y,p):Zs(g,C):(pe._visibility|=2,Zi(g,C,z,Y,p)),p&&oe&2048&&hf(C.alternate,C);break;case 24:Zi(g,C,z,Y,p),p&&oe&2048&&mf(C.alternate,C);break;default:Zi(g,C,z,Y,p)}r=r.sibling}}function Zs(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:Zs(s,c),p&2048&&hf(c.alternate,c);break;case 24:Zs(s,c),p&2048&&mf(c.alternate,c);break;default:Zs(s,c)}r=r.sibling}}var Js=8192;function Ji(t,r,s){if(t.subtreeFlags&Js)for(t=t.child;t!==null;)f1(t,r,s),t=t.sibling}function f1(t,r,s){switch(t.tag){case 26:Ji(t,r,s),t.flags&Js&&t.memoizedState!==null&&nw(s,ra,t.memoizedState,t.memoizedProps);break;case 5:Ji(t,r,s);break;case 3:case 4:var c=ra;ra=Vc(t.stateNode.containerInfo),Ji(t,r,s),ra=c;break;case 22:t.memoizedState===null&&(c=t.alternate,c!==null&&c.memoizedState!==null?(c=Js,Js=16777216,Ji(t,r,s),Js=c):Ji(t,r,s));break;default:Ji(t,r,s)}}function h1(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 eo(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];In=c,p1(c,t)}h1(t)}if(t.subtreeFlags&10256)for(t=t.child;t!==null;)m1(t),t=t.sibling}function m1(t){switch(t.tag){case 0:case 11:case 15:eo(t),t.flags&2048&&xl(9,t,t.return);break;case 3:eo(t);break;case 12:eo(t);break;case 22:var r=t.stateNode;t.memoizedState!==null&&r._visibility&2&&(t.return===null||t.return.tag!==13)?(r._visibility&=-3,zc(t)):eo(t);break;default:eo(t)}}function zc(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];In=c,p1(c,t)}h1(t)}for(t=t.child;t!==null;){switch(r=t,r.tag){case 0:case 11:case 15:xl(8,r,r.return),zc(r);break;case 22:s=r.stateNode,s._visibility&2&&(s._visibility&=-3,zc(r));break;default:zc(r)}t=t.sibling}}function p1(t,r){for(;In!==null;){var s=In;switch(s.tag){case 0:case 11:case 15:xl(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:Os(s.memoizedState.cache)}if(c=s.child,c!==null)c.return=s,In=c;else e:for(s=t;In!==null;){c=In;var p=c.sibling,g=c.return;if(l1(c),c===s){In=null;break e}if(p!==null){p.return=g,In=p;break e}In=g}}}var y2={getCacheForType:function(t){var r=Yn(Cn),s=r.data.get(t);return s===void 0&&(s=t(),r.data.set(t,s)),s},cacheSignal:function(){return Yn(Cn).controller.signal}},g2=typeof WeakMap=="function"?WeakMap:Map,It=0,tn=null,Ct=null,At=0,Yt=0,Sr=null,yl=!1,es=!1,pf=!1,Xa=0,yn=0,gl=0,di=0,xf=0,Cr=0,ts=0,to=null,fr=null,yf=!1,_c=0,x1=0,Bc=1/0,Oc=null,bl=null,Rn=0,vl=null,ns=null,Wa=0,gf=0,bf=null,y1=null,no=0,vf=null;function Nr(){return(It&2)!==0&&At!==0?At&-At:X.T!==null?Nf():tl()}function g1(){if(Cr===0)if((At&536870912)===0||Ft){var t=Jt;Jt<<=1,(Jt&3932160)===0&&(Jt=262144),Cr=t}else Cr=536870912;return t=kr.current,t!==null&&(t.flags|=32),Cr}function hr(t,r,s){(t===tn&&(Yt===2||Yt===9)||t.cancelPendingCommit!==null)&&(rs(t,0),wl(t,At,Cr,!1)),ve(t,s),((It&2)===0||t!==tn)&&(t===tn&&((It&2)===0&&(di|=s),yn===4&&wl(t,At,Cr,!1)),ga(t))}function b1(t,r,s){if((It&6)!==0)throw Error(i(327));var c=!s&&(r&127)===0&&(r&t.expiredLanes)===0||P(t,r),p=c?w2(t,r):kf(t,r,!0),g=c;do{if(p===0){es&&!c&&wl(t,r,0,!1);break}else{if(s=t.current.alternate,g&&!b2(s)){p=kf(t,r,!1),g=!1;continue}if(p===2){if(g=r,t.errorRecoveryDisabledLanes&g)var C=0;else C=t.pendingLanes&-536870913,C=C!==0?C:C&536870912?536870912:0;if(C!==0){r=C;e:{var z=t;p=to;var Y=z.current.memoizedState.isDehydrated;if(Y&&(rs(z,C).flags|=256),C=kf(z,C,!1),C!==2){if(pf&&!Y){z.errorRecoveryDisabledLanes|=g,di|=g,p=4;break e}g=fr,fr=p,g!==null&&(fr===null?fr=g:fr.push.apply(fr,g))}p=C}if(g=!1,p!==2)continue}}if(p===1){rs(t,0),wl(t,r,0,!0);break}e:{switch(c=t,g=p,g){case 0:case 1:throw Error(i(345));case 4:if((r&4194048)!==r)break;case 6:wl(c,r,Cr,!yl);break e;case 2:fr=null;break;case 3:case 5:break;default:throw Error(i(329))}if((r&62914560)===r&&(p=_c+300-Wt(),10<p)){if(wl(c,r,Cr,!yl),bn(c,0,!0)!==0)break e;Wa=r,c.timeoutHandle=Q1(v1.bind(null,c,s,fr,Oc,yf,r,Cr,di,ts,yl,g,"Throttled",-0,0),p);break e}v1(c,s,fr,Oc,yf,r,Cr,di,ts,yl,g,null,-0,0)}}break}while(!0);ga(t)}function v1(t,r,s,c,p,g,C,z,Y,oe,pe,ke,ue,fe){if(t.timeoutHandle=-1,ke=r.subtreeFlags,ke&8192||(ke&16785408)===16785408){ke={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:$n},f1(r,g,ke);var He=(g&62914560)===g?_c-Wt():(g&4194048)===g?x1-Wt():0;if(He=rw(ke,He),He!==null){Wa=g,t.cancelPendingCommit=He(A1.bind(null,t,r,g,s,c,p,C,z,Y,pe,ke,null,ue,fe)),wl(t,g,C,!oe);return}}A1(t,r,g,s,c,p,C,z,Y)}function b2(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],g=p.getSnapshot;p=p.value;try{if(!vr(g(),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 wl(t,r,s,c){r&=~xf,r&=~di,t.suspendedLanes|=r,t.pingedLanes&=~r,c&&(t.warmLanes|=r),c=t.expirationTimes;for(var p=r;0<p;){var g=31-Oe(p),C=1<<g;c[g]=-1,p&=~C}s!==0&&sn(t,s,r)}function Lc(){return(It&6)===0?(ro(0),!1):!0}function wf(){if(Ct!==null){if(Yt===0)var t=Ct.return;else t=Ct,_a=ni=null,Bd(t),Vi=null,$s=0,t=Ct;for(;t!==null;)Px(t.alternate,t),t=t.return;Ct=null}}function rs(t,r){var s=t.timeoutHandle;s!==-1&&(t.timeoutHandle=-1,$2(s)),s=t.cancelPendingCommit,s!==null&&(t.cancelPendingCommit=null,s()),Wa=0,wf(),tn=t,Ct=s=Ra(t.current,null),At=r,Yt=0,Sr=null,yl=!1,es=P(t,r),pf=!1,ts=Cr=xf=di=gl=yn=0,fr=to=null,yf=!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-Oe(c),g=1<<p;r|=t[p],c&=~g}return Xa=r,lc(),s}function w1(t,r){ht=null,X.H=Vs,r===Wi||r===hc?(r=Op(),Yt=3):r===Sd?(r=Op(),Yt=4):Yt=r===Zd?8:r!==null&&typeof r=="object"&&typeof r.then=="function"?6:1,Sr=r,Ct===null&&(yn=1,Ec(t,Or(r,t.current)))}function k1(){var t=kr.current;return t===null?!0:(At&4194048)===At?Hr===null:(At&62914560)===At||(At&536870912)!==0?t===Hr:!1}function j1(){var t=X.H;return X.H=Vs,t===null?Vs:t}function S1(){var t=X.A;return X.A=y2,t}function $c(){yn=4,yl||(At&4194048)!==At&&kr.current!==null||(es=!0),(gl&134217727)===0&&(di&134217727)===0||tn===null||wl(tn,At,Cr,!1)}function kf(t,r,s){var c=It;It|=2;var p=j1(),g=S1();(tn!==t||At!==r)&&(Oc=null,rs(t,r)),r=!1;var C=yn;e:do try{if(Yt!==0&&Ct!==null){var z=Ct,Y=Sr;switch(Yt){case 8:wf(),C=6;break e;case 3:case 2:case 9:case 6:kr.current===null&&(r=!0);var oe=Yt;if(Yt=0,Sr=null,as(t,z,Y,oe),s&&es){C=0;break e}break;default:oe=Yt,Yt=0,Sr=null,as(t,z,Y,oe)}}v2(),C=yn;break}catch(pe){w1(t,pe)}while(!0);return r&&t.shellSuspendCounter++,_a=ni=null,It=c,X.H=p,X.A=g,Ct===null&&(tn=null,At=0,lc()),C}function v2(){for(;Ct!==null;)C1(Ct)}function w2(t,r){var s=It;It|=2;var c=j1(),p=S1();tn!==t||At!==r?(Oc=null,Bc=Wt()+500,rs(t,r)):es=P(t,r);e:do try{if(Yt!==0&&Ct!==null){r=Ct;var g=Sr;t:switch(Yt){case 1:Yt=0,Sr=null,as(t,r,g,1);break;case 2:case 9:if(_p(g)){Yt=0,Sr=null,N1(r);break}r=function(){Yt!==2&&Yt!==9||tn!==t||(Yt=7),ga(t)},g.then(r,r);break e;case 3:Yt=7;break e;case 4:Yt=5;break e;case 7:_p(g)?(Yt=0,Sr=null,N1(r)):(Yt=0,Sr=null,as(t,r,g,7));break;case 5:var C=null;switch(Ct.tag){case 26:C=Ct.memoizedState;case 5:case 27:var z=Ct;if(C?d0(C):z.stateNode.complete){Yt=0,Sr=null;var Y=z.sibling;if(Y!==null)Ct=Y;else{var oe=z.return;oe!==null?(Ct=oe,Ic(oe)):Ct=null}break t}}Yt=0,Sr=null,as(t,r,g,5);break;case 6:Yt=0,Sr=null,as(t,r,g,6);break;case 8:wf(),yn=6;break e;default:throw Error(i(462))}}k2();break}catch(pe){w1(t,pe)}while(!0);return _a=ni=null,X.H=c,X.A=p,It=s,Ct!==null?0:(tn=null,At=0,lc(),yn)}function k2(){for(;Ct!==null&&!gn();)C1(Ct)}function C1(t){var r=Kx(t.alternate,t,Xa);t.memoizedProps=t.pendingProps,r===null?Ic(t):Ct=r}function N1(t){var r=t,s=r.alternate;switch(r.tag){case 15:case 0:r=qx(s,r,r.pendingProps,r.type,void 0,At);break;case 11:r=qx(s,r,r.pendingProps,r.type.render,r.ref,At);break;case 5:Bd(r);default:Px(s,r),r=Ct=Sp(r,Xa),r=Kx(s,r,Xa)}t.memoizedProps=t.pendingProps,r===null?Ic(t):Ct=r}function as(t,r,s,c){_a=ni=null,Bd(r),Vi=null,$s=0;var p=r.return;try{if(u2(t,p,r,s,At)){yn=1,Ec(t,Or(s,t.current)),Ct=null;return}}catch(g){if(p!==null)throw Ct=p,g;yn=1,Ec(t,Or(s,t.current)),Ct=null;return}r.flags&32768?(Ft||c===1?t=!0:es||(At&536870912)!==0?t=!1:(yl=t=!0,(c===2||c===9||c===3||c===6)&&(c=kr.current,c!==null&&c.tag===13&&(c.flags|=16384))),E1(r,t)):Ic(r)}function Ic(t){var r=t;do{if((r.flags&32768)!==0){E1(r,yl);return}t=r.return;var s=h2(r.alternate,r,Xa);if(s!==null){Ct=s;return}if(r=r.sibling,r!==null){Ct=r;return}Ct=r=t}while(r!==null);yn===0&&(yn=5)}function E1(t,r){do{var s=m2(t.alternate,t);if(s!==null){s.flags&=32767,Ct=s;return}if(s=t.return,s!==null&&(s.flags|=32768,s.subtreeFlags=0,s.deletions=null),!r&&(t=t.sibling,t!==null)){Ct=t;return}Ct=t=s}while(t!==null);yn=6,Ct=null}function A1(t,r,s,c,p,g,C,z,Y){t.cancelPendingCommit=null;do Hc();while(Rn!==0);if((It&6)!==0)throw Error(i(327));if(r!==null){if(r===t.current)throw Error(i(177));if(g=r.lanes|r.childLanes,g|=cd,yt(t,s,g,C,z,Y),t===tn&&(Ct=tn=null,At=0),ns=r,vl=t,Wa=s,gf=g,bf=p,y1=c,(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?(t.callbackNode=null,t.callbackPriority=0,N2(me,function(){return R1(),null})):(t.callbackNode=null,t.callbackPriority=0),c=(r.flags&13878)!==0,(r.subtreeFlags&13878)!==0||c){c=X.T,X.T=null,p=le.p,le.p=2,C=It,It|=4;try{p2(t,r,s)}finally{It=C,le.p=p,X.T=c}}Rn=1,D1(),T1(),F1()}}function D1(){if(Rn===1){Rn=0;var t=vl,r=ns,s=(r.flags&13878)!==0;if((r.subtreeFlags&13878)!==0||s){s=X.T,X.T=null;var c=le.p;le.p=2;var p=It;It|=4;try{c1(r,t);var g=zf,C=pp(t.containerInfo),z=g.focusedElem,Y=g.selectionRange;if(C!==z&&z&&z.ownerDocument&&mp(z.ownerDocument.documentElement,z)){if(Y!==null&&ad(z)){var oe=Y.start,pe=Y.end;if(pe===void 0&&(pe=oe),"selectionStart"in z)z.selectionStart=oe,z.selectionEnd=Math.min(pe,z.value.length);else{var ke=z.ownerDocument||document,ue=ke&&ke.defaultView||window;if(ue.getSelection){var fe=ue.getSelection(),He=z.textContent.length,tt=Math.min(Y.start,He),Pt=Y.end===void 0?tt:Math.min(Y.end,He);!fe.extend&&tt>Pt&&(C=Pt,Pt=tt,tt=C);var te=hp(z,tt),V=hp(z,Pt);if(te&&V&&(fe.rangeCount!==1||fe.anchorNode!==te.node||fe.anchorOffset!==te.offset||fe.focusNode!==V.node||fe.focusOffset!==V.offset)){var se=ke.createRange();se.setStart(te.node,te.offset),fe.removeAllRanges(),tt>Pt?(fe.addRange(se),fe.extend(V.node,V.offset)):(se.setEnd(V.node,V.offset),fe.addRange(se))}}}}for(ke=[],fe=z;fe=fe.parentNode;)fe.nodeType===1&&ke.push({element:fe,left:fe.scrollLeft,top:fe.scrollTop});for(typeof z.focus=="function"&&z.focus(),z=0;z<ke.length;z++){var be=ke[z];be.element.scrollLeft=be.left,be.element.scrollTop=be.top}}Jc=!!Rf,zf=Rf=null}finally{It=p,le.p=c,X.T=s}}t.current=r,Rn=2}}function T1(){if(Rn===2){Rn=0;var t=vl,r=ns,s=(r.flags&8772)!==0;if((r.subtreeFlags&8772)!==0||s){s=X.T,X.T=null;var c=le.p;le.p=2;var p=It;It|=4;try{a1(t,r.alternate,r)}finally{It=p,le.p=c,X.T=s}}Rn=3}}function F1(){if(Rn===4||Rn===3){Rn=0,ft();var t=vl,r=ns,s=Wa,c=y1;(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?Rn=5:(Rn=0,ns=vl=null,M1(t,t.pendingLanes));var p=t.pendingLanes;if(p===0&&(bl=null),Jn(s),r=r.stateNode,Re&&typeof Re.onCommitFiberRoot=="function")try{Re.onCommitFiberRoot($e,r,void 0,(r.current.flags&128)===128)}catch{}if(c!==null){r=X.T,p=le.p,le.p=2,X.T=null;try{for(var g=t.onRecoverableError,C=0;C<c.length;C++){var z=c[C];g(z.value,{componentStack:z.stack})}}finally{X.T=r,le.p=p}}(Wa&3)!==0&&Hc(),ga(t),p=t.pendingLanes,(s&261930)!==0&&(p&42)!==0?t===vf?no++:(no=0,vf=t):no=0,ro(0)}}function M1(t,r){(t.pooledCacheLanes&=r)===0&&(r=t.pooledCache,r!=null&&(t.pooledCache=null,Os(r)))}function Hc(){return D1(),T1(),F1(),R1()}function R1(){if(Rn!==5)return!1;var t=vl,r=gf;gf=0;var s=Jn(Wa),c=X.T,p=le.p;try{le.p=32>s?32:s,X.T=null,s=bf,bf=null;var g=vl,C=Wa;if(Rn=0,ns=vl=null,Wa=0,(It&6)!==0)throw Error(i(331));var z=It;if(It|=4,m1(g.current),d1(g,g.current,C,s),It=z,ro(0,!1),Re&&typeof Re.onPostCommitFiberRoot=="function")try{Re.onPostCommitFiberRoot($e,g)}catch{}return!0}finally{le.p=p,X.T=c,M1(t,r)}}function z1(t,r,s){r=Or(s,r),r=Pd(t.stateNode,r,2),t=hl(t,r,2),t!==null&&(ve(t,2),ga(t))}function Xt(t,r,s){if(t.tag===3)z1(t,t,s);else for(;r!==null;){if(r.tag===3){z1(r,t,s);break}else if(r.tag===1){var c=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(bl===null||!bl.has(c))){t=Or(s,t),s=_x(2),c=hl(r,s,2),c!==null&&(Bx(s,c,r,t),ve(c,2),ga(c));break}}r=r.return}}function jf(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)||(pf=!0,p.add(s),t=j2.bind(null,t,r,s),r.then(t,t))}function j2(t,r,s){var c=t.pingCache;c!==null&&c.delete(r),t.pingedLanes|=t.suspendedLanes&s,t.warmLanes&=~s,tn===t&&(At&s)===s&&(yn===4||yn===3&&(At&62914560)===At&&300>Wt()-_c?(It&2)===0&&rs(t,0):xf|=s,ts===At&&(ts=0)),ga(t)}function _1(t,r){r===0&&(r=et()),t=Jl(t,r),t!==null&&(ve(t,r),ga(t))}function S2(t){var r=t.memoizedState,s=0;r!==null&&(s=r.retryLane),_1(t,s)}function C2(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),_1(t,s)}function N2(t,r){return bt(t,r)}var Uc=null,ls=null,Sf=!1,qc=!1,Cf=!1,kl=0;function ga(t){t!==ls&&t.next===null&&(ls===null?Uc=ls=t:ls=ls.next=t),qc=!0,Sf||(Sf=!0,A2())}function ro(t,r){if(!Cf&&qc){Cf=!0;do for(var s=!1,c=Uc;c!==null;){if(t!==0){var p=c.pendingLanes;if(p===0)var g=0;else{var C=c.suspendedLanes,z=c.pingedLanes;g=(1<<31-Oe(42|t)+1)-1,g&=p&~(C&~z),g=g&201326741?g&201326741|1:g?g|2:0}g!==0&&(s=!0,$1(c,g))}else g=At,g=bn(c,c===tn?g:0,c.cancelPendingCommit!==null||c.timeoutHandle!==-1),(g&3)===0||P(c,g)||(s=!0,$1(c,g));c=c.next}while(s);Cf=!1}}function E2(){B1()}function B1(){qc=Sf=!1;var t=0;kl!==0&&L2()&&(t=kl);for(var r=Wt(),s=null,c=Uc;c!==null;){var p=c.next,g=O1(c,r);g===0?(c.next=null,s===null?Uc=p:s.next=p,p===null&&(ls=s)):(s=c,(t!==0||(g&3)!==0)&&(qc=!0)),c=p}Rn!==0&&Rn!==5||ro(t),kl!==0&&(kl=0)}function O1(t,r){for(var s=t.suspendedLanes,c=t.pingedLanes,p=t.expirationTimes,g=t.pendingLanes&-62914561;0<g;){var C=31-Oe(g),z=1<<C,Y=p[C];Y===-1?((z&s)===0||(z&c)!==0)&&(p[C]=qe(z,r)):Y<=r&&(t.expiredLanes|=z),g&=~z}if(r=tn,s=At,s=bn(t,t===r?s:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),c=t.callbackNode,s===0||t===r&&(Yt===2||Yt===9)||t.cancelPendingCommit!==null)return c!==null&&c!==null&&dt(c),t.callbackNode=null,t.callbackPriority=0;if((s&3)===0||P(t,s)){if(r=s&-s,r===t.callbackPriority)return r;switch(c!==null&&dt(c),Jn(s)){case 2:case 8:s=ae;break;case 32:s=me;break;case 268435456:s=De;break;default:s=me}return c=L1.bind(null,t),s=bt(s,c),t.callbackPriority=r,t.callbackNode=s,r}return c!==null&&c!==null&&dt(c),t.callbackPriority=2,t.callbackNode=null,2}function L1(t,r){if(Rn!==0&&Rn!==5)return t.callbackNode=null,t.callbackPriority=0,null;var s=t.callbackNode;if(Hc()&&t.callbackNode!==s)return null;var c=At;return c=bn(t,t===tn?c:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),c===0?null:(b1(t,c,r),O1(t,Wt()),t.callbackNode!=null&&t.callbackNode===s?L1.bind(null,t):null)}function $1(t,r){if(Hc())return null;b1(t,r,!0)}function A2(){I2(function(){(It&6)!==0?bt(U,E2):B1()})}function Nf(){if(kl===0){var t=Yi;t===0&&(t=Vt,Vt<<=1,(Vt&261888)===0&&(Vt=256)),kl=t}return kl}function I1(t){return t==null||typeof t=="symbol"||typeof t=="boolean"?null:typeof t=="function"?t:Wl(""+t)}function H1(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 D2(t,r,s,c,p){if(r==="submit"&&s&&s.stateNode===p){var g=I1((p[Ln]||null).action),C=c.submitter;C&&(r=(r=C[Ln]||null)?I1(r.formAction):C.getAttribute("formAction"),r!==null&&(g=r,C=null));var z=new al("action","action",null,c,p);t.push({event:z,listeners:[{instance:null,listener:function(){if(c.defaultPrevented){if(kl!==0){var Y=C?H1(p,C):new FormData(p);Xd(s,{pending:!0,data:Y,method:p.method,action:g},null,Y)}}else typeof g=="function"&&(z.preventDefault(),Y=C?H1(p,C):new FormData(p),Xd(s,{pending:!0,data:Y,method:p.method,action:g},g,Y))},currentTarget:p}]})}}for(var Ef=0;Ef<od.length;Ef++){var Af=od[Ef],T2=Af.toLowerCase(),F2=Af[0].toUpperCase()+Af.slice(1);na(T2,"on"+F2)}na(gp,"onAnimationEnd"),na(bp,"onAnimationIteration"),na(vp,"onAnimationStart"),na("dblclick","onDoubleClick"),na("focusin","onFocus"),na("focusout","onBlur"),na(Vv,"onTransitionRun"),na(Gv,"onTransitionStart"),na(Kv,"onTransitionCancel"),na(wp,"onTransitionEnd"),Ma("onMouseEnter",["mouseout","mouseover"]),Ma("onMouseLeave",["mouseout","mouseover"]),Ma("onPointerEnter",["pointerout","pointerover"]),Ma("onPointerLeave",["pointerout","pointerover"]),lr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),lr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),lr("onBeforeInput",["compositionend","keypress","textInput","paste"]),lr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),lr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),lr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ao="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),M2=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(ao));function U1(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 g=void 0;if(r)for(var C=c.length-1;0<=C;C--){var z=c[C],Y=z.instance,oe=z.currentTarget;if(z=z.listener,Y!==g&&p.isPropagationStopped())break e;g=z,p.currentTarget=oe;try{g(p)}catch(pe){ac(pe)}p.currentTarget=null,g=Y}else for(C=0;C<c.length;C++){if(z=c[C],Y=z.instance,oe=z.currentTarget,z=z.listener,Y!==g&&p.isPropagationStopped())break e;g=z,p.currentTarget=oe;try{g(p)}catch(pe){ac(pe)}p.currentTarget=null,g=Y}}}}function Nt(t,r){var s=r[nl];s===void 0&&(s=r[nl]=new Set);var c=t+"__bubble";s.has(c)||(q1(r,t,2,!1),s.add(c))}function Df(t,r,s){var c=0;r&&(c|=4),q1(s,t,c,r)}var Yc="_reactListening"+Math.random().toString(36).slice(2);function Tf(t){if(!t[Yc]){t[Yc]=!0,Ta.forEach(function(s){s!=="selectionchange"&&(M2.has(s)||Df(s,!1,t),Df(s,!0,t))});var r=t.nodeType===9?t:t.ownerDocument;r===null||r[Yc]||(r[Yc]=!0,Df("selectionchange",!1,r))}}function q1(t,r,s,c){switch(g0(r)){case 2:var p=iw;break;case 8:p=sw;break;default:p=Xf}s=p.bind(null,r,s,t),p=void 0,!Gl||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 Ff(t,r,s,c,p){var g=c;if((r&1)===0&&(r&2)===0&&c!==null)e:for(;;){if(c===null)return;var C=c.tag;if(C===3||C===4){var z=c.stateNode.containerInfo;if(z===p)break;if(C===4)for(C=c.return;C!==null;){var Y=C.tag;if((Y===3||Y===4)&&C.stateNode.containerInfo===p)return;C=C.return}for(;z!==null;){if(C=ca(z),C===null)return;if(Y=C.tag,Y===5||Y===6||Y===26||Y===27){c=g=C;continue e}z=z.parentNode}}c=c.return}Mt(function(){var oe=g,pe=hn(s),ke=[];e:{var ue=kp.get(t);if(ue!==void 0){var fe=al,He=t;switch(t){case"keypress":if(Ai(s)===0)break e;case"keydown":case"keyup":fe=ne;break;case"focusin":He="focus",fe=Ds;break;case"focusout":He="blur",fe=Ds;break;case"beforeblur":case"afterblur":fe=Ds;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=Ri;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":fe=ma;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":fe=Ut;break;case gp:case bp:case vp:fe=Gt;break;case wp:fe=Pe;break;case"scroll":case"scrollend":fe=Go;break;case"wheel":fe=it;break;case"copy":case"cut":case"paste":fe=Po;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":fe=je;break;case"toggle":case"beforetoggle":fe=qt}var tt=(r&4)!==0,Pt=!tt&&(t==="scroll"||t==="scrollend"),te=tt?ue!==null?ue+"Capture":null:ue;tt=[];for(var V=oe,se;V!==null;){var be=V;if(se=be.stateNode,be=be.tag,be!==5&&be!==26&&be!==27||se===null||te===null||(be=Vl(V,te),be!=null&&tt.push(lo(V,be,se))),Pt)break;V=V.return}0<tt.length&&(ue=new fe(ue,He,null,s,pe),ke.push({event:ue,listeners:tt}))}}if((r&7)===0){e:{if(ue=t==="mouseover"||t==="pointerover",fe=t==="mouseout"||t==="pointerout",ue&&s!==Zr&&(He=s.relatedTarget||s.fromElement)&&(ca(He)||He[oa]))break e;if((fe||ue)&&(ue=pe.window===pe?pe:(ue=pe.ownerDocument)?ue.defaultView||ue.parentWindow:window,fe?(He=s.relatedTarget||s.toElement,fe=oe,He=He?ca(He):null,He!==null&&(Pt=u(He),tt=He.tag,He!==Pt||tt!==5&&tt!==27&&tt!==6)&&(He=null)):(fe=null,He=oe),fe!==He)){if(tt=Ri,be="onMouseLeave",te="onMouseEnter",V="mouse",(t==="pointerout"||t==="pointerover")&&(tt=je,be="onPointerLeave",te="onPointerEnter",V="pointer"),Pt=fe==null?ue:Hl(fe),se=He==null?ue:Hl(He),ue=new tt(be,V+"leave",fe,s,pe),ue.target=Pt,ue.relatedTarget=se,be=null,ca(pe)===oe&&(tt=new tt(te,V+"enter",He,s,pe),tt.target=se,tt.relatedTarget=Pt,be=tt),Pt=be,fe&&He)t:{for(tt=R2,te=fe,V=He,se=0,be=te;be;be=tt(be))se++;be=0;for(var Qe=V;Qe;Qe=tt(Qe))be++;for(;0<se-be;)te=tt(te),se--;for(;0<be-se;)V=tt(V),be--;for(;se--;){if(te===V||V!==null&&te===V.alternate){tt=te;break t}te=tt(te),V=tt(V)}tt=null}else tt=null;fe!==null&&Y1(ke,ue,fe,tt,!1),He!==null&&Pt!==null&&Y1(ke,Pt,He,tt,!0)}}e:{if(ue=oe?Hl(oe):window,fe=ue.nodeName&&ue.nodeName.toLowerCase(),fe==="select"||fe==="input"&&ue.type==="file")var Ot=sp;else if(lp(ue))if(op)Ot=Yv;else{Ot=Uv;var We=Hv}else fe=ue.nodeName,!fe||fe.toLowerCase()!=="input"||ue.type!=="checkbox"&&ue.type!=="radio"?oe&&Xl(oe.elementType)&&(Ot=sp):Ot=qv;if(Ot&&(Ot=Ot(t,oe))){ip(ke,Ot,s,pe);break e}We&&We(t,ue,oe),t==="focusout"&&oe&&ue.type==="number"&&oe.memoizedProps.value!=null&&ua(ue,"number",ue.value)}switch(We=oe?Hl(oe):window,t){case"focusin":(lp(We)||We.contentEditable==="true")&&(Bi=We,ld=oe,zs=null);break;case"focusout":zs=ld=Bi=null;break;case"mousedown":id=!0;break;case"contextmenu":case"mouseup":case"dragend":id=!1,xp(ke,s,pe);break;case"selectionchange":if(Wv)break;case"keydown":case"keyup":xp(ke,s,pe)}var mt;if(zi)e:{switch(t){case"compositionstart":var Dt="onCompositionStart";break e;case"compositionend":Dt="onCompositionEnd";break e;case"compositionupdate":Dt="onCompositionUpdate";break e}Dt=void 0}else _i?rp(t,s)&&(Dt="onCompositionEnd"):t==="keydown"&&s.keyCode===229&&(Dt="onCompositionStart");Dt&&(ep&&s.locale!=="ko"&&(_i||Dt!=="onCompositionStart"?Dt==="onCompositionEnd"&&_i&&(mt=Ei()):(fa=pe,Kl="value"in fa?fa.value:fa.textContent,_i=!0)),We=Xc(oe,Dt),0<We.length&&(Dt=new Ts(Dt,t,null,s,pe),ke.push({event:Dt,listeners:We}),mt?Dt.data=mt:(mt=ap(s),mt!==null&&(Dt.data=mt)))),(mt=Bv?Ov(t,s):Lv(t,s))&&(Dt=Xc(oe,"onBeforeInput"),0<Dt.length&&(We=new Ts("onBeforeInput","beforeinput",null,s,pe),ke.push({event:We,listeners:Dt}),We.data=mt)),D2(ke,t,oe,s,pe)}U1(ke,r)})}function lo(t,r,s){return{instance:t,listener:r,currentTarget:s}}function Xc(t,r){for(var s=r+"Capture",c=[];t!==null;){var p=t,g=p.stateNode;if(p=p.tag,p!==5&&p!==26&&p!==27||g===null||(p=Vl(t,s),p!=null&&c.unshift(lo(t,p,g)),p=Vl(t,r),p!=null&&c.push(lo(t,p,g))),t.tag===3)return c;t=t.return}return[]}function R2(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5&&t.tag!==27);return t||null}function Y1(t,r,s,c,p){for(var g=r._reactName,C=[];s!==null&&s!==c;){var z=s,Y=z.alternate,oe=z.stateNode;if(z=z.tag,Y!==null&&Y===c)break;z!==5&&z!==26&&z!==27||oe===null||(Y=oe,p?(oe=Vl(s,g),oe!=null&&C.unshift(lo(s,oe,Y))):p||(oe=Vl(s,g),oe!=null&&C.push(lo(s,oe,Y)))),s=s.return}C.length!==0&&t.push({event:r,listeners:C})}var z2=/\r\n?/g,_2=/\u0000|\uFFFD/g;function X1(t){return(typeof t=="string"?t:""+t).replace(z2,`
49
- `).replace(_2,"")}function W1(t,r){return r=X1(r),X1(t)===r}function Qt(t,r,s,c,p,g){switch(s){case"children":typeof c=="string"?r==="body"||r==="textarea"&&c===""||on(t,c):(typeof c=="number"||typeof c=="bigint")&&r!=="body"&&on(t,""+c);break;case"className":ql(t,"class",c);break;case"tabIndex":ql(t,"tabindex",c);break;case"dir":case"role":case"viewBox":case"width":case"height":ql(t,s,c);break;case"style":Pr(t,c,g);break;case"data":if(r!=="object"){ql(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=Wl(""+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 g=="function"&&(s==="formAction"?(r!=="input"&&Qt(t,r,"name",p.name,p,null),Qt(t,r,"formEncType",p.formEncType,p,null),Qt(t,r,"formMethod",p.formMethod,p,null),Qt(t,r,"formTarget",p.formTarget,p,null)):(Qt(t,r,"encType",p.encType,p,null),Qt(t,r,"method",p.method,p,null),Qt(t,r,"target",p.target,p,null)));if(c==null||typeof c=="symbol"||typeof c=="boolean"){t.removeAttribute(s);break}c=Wl(""+c),t.setAttribute(s,c);break;case"onClick":c!=null&&(t.onclick=$n);break;case"onScroll":c!=null&&Nt("scroll",t);break;case"onScrollEnd":c!=null&&Nt("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=Wl(""+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":Nt("beforetoggle",t),Nt("toggle",t),Ul(t,"popover",c);break;case"xlinkActuate":Gr(t,"http://www.w3.org/1999/xlink","xlink:actuate",c);break;case"xlinkArcrole":Gr(t,"http://www.w3.org/1999/xlink","xlink:arcrole",c);break;case"xlinkRole":Gr(t,"http://www.w3.org/1999/xlink","xlink:role",c);break;case"xlinkShow":Gr(t,"http://www.w3.org/1999/xlink","xlink:show",c);break;case"xlinkTitle":Gr(t,"http://www.w3.org/1999/xlink","xlink:title",c);break;case"xlinkType":Gr(t,"http://www.w3.org/1999/xlink","xlink:type",c);break;case"xmlBase":Gr(t,"http://www.w3.org/XML/1998/namespace","xml:base",c);break;case"xmlLang":Gr(t,"http://www.w3.org/XML/1998/namespace","xml:lang",c);break;case"xmlSpace":Gr(t,"http://www.w3.org/XML/1998/namespace","xml:space",c);break;case"is":Ul(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=ed.get(s)||s,Ul(t,s,c))}}function Mf(t,r,s,c,p,g){switch(s){case"style":Pr(t,c,g);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"?on(t,c):(typeof c=="number"||typeof c=="bigint")&&on(t,""+c);break;case"onScroll":c!=null&&Nt("scroll",t);break;case"onScrollEnd":c!=null&&Nt("scrollend",t);break;case"onClick":c!=null&&(t.onclick=$n);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Fa.hasOwnProperty(s))e:{if(s[0]==="o"&&s[1]==="n"&&(p=s.endsWith("Capture"),r=s.slice(2,p?s.length-7:void 0),g=t[Ln]||null,g=g!=null?g[s]:null,typeof g=="function"&&t.removeEventListener(r,g,p),typeof c=="function")){typeof g!="function"&&g!==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,""):Ul(t,s,c)}}}function Wn(t,r,s){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Nt("error",t),Nt("load",t);var c=!1,p=!1,g;for(g in s)if(s.hasOwnProperty(g)){var C=s[g];if(C!=null)switch(g){case"src":c=!0;break;case"srcSet":p=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,r));default:Qt(t,r,g,C,s,null)}}p&&Qt(t,r,"srcSet",s.srcSet,s,null),c&&Qt(t,r,"src",s.src,s,null);return;case"input":Nt("invalid",t);var z=g=C=p=null,Y=null,oe=null;for(c in s)if(s.hasOwnProperty(c)){var pe=s[c];if(pe!=null)switch(c){case"name":p=pe;break;case"type":C=pe;break;case"checked":Y=pe;break;case"defaultChecked":oe=pe;break;case"value":g=pe;break;case"defaultValue":z=pe;break;case"children":case"dangerouslySetInnerHTML":if(pe!=null)throw Error(i(137,r));break;default:Qt(t,r,c,pe,s,null)}}er(t,g,z,Y,oe,C,p,!1);return;case"select":Nt("invalid",t),c=C=g=null;for(p in s)if(s.hasOwnProperty(p)&&(z=s[p],z!=null))switch(p){case"value":g=z;break;case"defaultValue":C=z;break;case"multiple":c=z;default:Qt(t,r,p,z,s,null)}r=g,s=C,t.multiple=!!c,r!=null?sr(t,!!c,r,!1):s!=null&&sr(t,!!c,s,!0);return;case"textarea":Nt("invalid",t),g=p=c=null;for(C in s)if(s.hasOwnProperty(C)&&(z=s[C],z!=null))switch(C){case"value":c=z;break;case"defaultValue":p=z;break;case"children":g=z;break;case"dangerouslySetInnerHTML":if(z!=null)throw Error(i(91));break;default:Qt(t,r,C,z,s,null)}Mn(t,c,p,g);return;case"option":for(Y in s)if(s.hasOwnProperty(Y)&&(c=s[Y],c!=null))switch(Y){case"selected":t.selected=c&&typeof c!="function"&&typeof c!="symbol";break;default:Qt(t,r,Y,c,s,null)}return;case"dialog":Nt("beforetoggle",t),Nt("toggle",t),Nt("cancel",t),Nt("close",t);break;case"iframe":case"object":Nt("load",t);break;case"video":case"audio":for(c=0;c<ao.length;c++)Nt(ao[c],t);break;case"image":Nt("error",t),Nt("load",t);break;case"details":Nt("toggle",t);break;case"embed":case"source":case"link":Nt("error",t),Nt("load",t);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(oe in s)if(s.hasOwnProperty(oe)&&(c=s[oe],c!=null))switch(oe){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,r));default:Qt(t,r,oe,c,s,null)}return;default:if(Xl(r)){for(pe in s)s.hasOwnProperty(pe)&&(c=s[pe],c!==void 0&&Mf(t,r,pe,c,s,void 0));return}}for(z in s)s.hasOwnProperty(z)&&(c=s[z],c!=null&&Qt(t,r,z,c,s,null))}function B2(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,g=null,C=null,z=null,Y=null,oe=null,pe=null;for(fe in s){var ke=s[fe];if(s.hasOwnProperty(fe)&&ke!=null)switch(fe){case"checked":break;case"value":break;case"defaultValue":Y=ke;default:c.hasOwnProperty(fe)||Qt(t,r,fe,null,c,ke)}}for(var ue in c){var fe=c[ue];if(ke=s[ue],c.hasOwnProperty(ue)&&(fe!=null||ke!=null))switch(ue){case"type":g=fe;break;case"name":p=fe;break;case"checked":oe=fe;break;case"defaultChecked":pe=fe;break;case"value":C=fe;break;case"defaultValue":z=fe;break;case"children":case"dangerouslySetInnerHTML":if(fe!=null)throw Error(i(137,r));break;default:fe!==ke&&Qt(t,r,ue,fe,c,ke)}}Yl(t,C,z,Y,oe,pe,g,p);return;case"select":fe=C=z=ue=null;for(g in s)if(Y=s[g],s.hasOwnProperty(g)&&Y!=null)switch(g){case"value":break;case"multiple":fe=Y;default:c.hasOwnProperty(g)||Qt(t,r,g,null,c,Y)}for(p in c)if(g=c[p],Y=s[p],c.hasOwnProperty(p)&&(g!=null||Y!=null))switch(p){case"value":ue=g;break;case"defaultValue":z=g;break;case"multiple":C=g;default:g!==Y&&Qt(t,r,p,g,c,Y)}r=z,s=C,c=fe,ue!=null?sr(t,!!s,ue,!1):!!c!=!!s&&(r!=null?sr(t,!!s,r,!0):sr(t,!!s,s?[]:"",!1));return;case"textarea":fe=ue=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:Qt(t,r,z,null,c,p)}for(C in c)if(p=c[C],g=s[C],c.hasOwnProperty(C)&&(p!=null||g!=null))switch(C){case"value":ue=p;break;case"defaultValue":fe=p;break;case"children":break;case"dangerouslySetInnerHTML":if(p!=null)throw Error(i(91));break;default:p!==g&&Qt(t,r,C,p,c,g)}Wo(t,ue,fe);return;case"option":for(var He in s)if(ue=s[He],s.hasOwnProperty(He)&&ue!=null&&!c.hasOwnProperty(He))switch(He){case"selected":t.selected=!1;break;default:Qt(t,r,He,null,c,ue)}for(Y in c)if(ue=c[Y],fe=s[Y],c.hasOwnProperty(Y)&&ue!==fe&&(ue!=null||fe!=null))switch(Y){case"selected":t.selected=ue&&typeof ue!="function"&&typeof ue!="symbol";break;default:Qt(t,r,Y,ue,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 tt in s)ue=s[tt],s.hasOwnProperty(tt)&&ue!=null&&!c.hasOwnProperty(tt)&&Qt(t,r,tt,null,c,ue);for(oe in c)if(ue=c[oe],fe=s[oe],c.hasOwnProperty(oe)&&ue!==fe&&(ue!=null||fe!=null))switch(oe){case"children":case"dangerouslySetInnerHTML":if(ue!=null)throw Error(i(137,r));break;default:Qt(t,r,oe,ue,c,fe)}return;default:if(Xl(r)){for(var Pt in s)ue=s[Pt],s.hasOwnProperty(Pt)&&ue!==void 0&&!c.hasOwnProperty(Pt)&&Mf(t,r,Pt,void 0,c,ue);for(pe in c)ue=c[pe],fe=s[pe],!c.hasOwnProperty(pe)||ue===fe||ue===void 0&&fe===void 0||Mf(t,r,pe,ue,c,fe);return}}for(var te in s)ue=s[te],s.hasOwnProperty(te)&&ue!=null&&!c.hasOwnProperty(te)&&Qt(t,r,te,null,c,ue);for(ke in c)ue=c[ke],fe=s[ke],!c.hasOwnProperty(ke)||ue===fe||ue==null&&fe==null||Qt(t,r,ke,ue,c,fe)}function V1(t){switch(t){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function O2(){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],g=p.transferSize,C=p.initiatorType,z=p.duration;if(g&&z&&V1(C)){for(C=0,z=p.responseEnd,c+=1;c<s.length;c++){var Y=s[c],oe=Y.startTime;if(oe>z)break;var pe=Y.transferSize,ke=Y.initiatorType;pe&&V1(ke)&&(Y=Y.responseEnd,C+=pe*(Y<z?1:(z-oe)/(Y-oe)))}if(--c,r+=8*(g+C)/(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 Rf=null,zf=null;function Wc(t){return t.nodeType===9?t:t.ownerDocument}function G1(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 K1(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 Bf=null;function L2(){var t=window.event;return t&&t.type==="popstate"?t===Bf?!1:(Bf=t,!0):(Bf=null,!1)}var Q1=typeof setTimeout=="function"?setTimeout:void 0,$2=typeof clearTimeout=="function"?clearTimeout:void 0,P1=typeof Promise=="function"?Promise:void 0,I2=typeof queueMicrotask=="function"?queueMicrotask:typeof P1<"u"?function(t){return P1.resolve(null).then(t).catch(H2)}:Q1;function H2(t){setTimeout(function(){throw t})}function jl(t){return t==="head"}function Z1(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),cs(r);return}c--}else if(s==="$"||s==="$?"||s==="$~"||s==="$!"||s==="&")c++;else if(s==="html")io(t.ownerDocument.documentElement);else if(s==="head"){s=t.ownerDocument.head,io(s);for(var g=s.firstChild;g;){var C=g.nextSibling,z=g.nodeName;g[Da]||z==="SCRIPT"||z==="STYLE"||z==="LINK"&&g.rel.toLowerCase()==="stylesheet"||s.removeChild(g),g=C}}else s==="body"&&io(t.ownerDocument.body);s=p}while(s);cs(r)}function J1(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 Of(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":Of(s),Ci(s);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(s.rel.toLowerCase()==="stylesheet")continue}t.removeChild(s)}}function U2(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[Da])switch(r){case"meta":if(!t.hasAttribute("itemprop"))break;return t;case"link":if(g=t.getAttribute("rel"),g==="stylesheet"&&t.hasAttribute("data-precedence"))break;if(g!==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(g=t.getAttribute("src"),(g!==(p.src==null?null:p.src)||t.getAttribute("type")!==(p.type==null?null:p.type)||t.getAttribute("crossorigin")!==(p.crossOrigin==null?null:p.crossOrigin))&&g&&t.hasAttribute("async")&&!t.hasAttribute("itemprop"))break;return t;default:return t}}else if(r==="input"&&t.type==="hidden"){var g=p.name==null?null:""+p.name;if(p.type==="hidden"&&t.getAttribute("name")===g)return t}else return t;if(t=Ur(t.nextSibling),t===null)break}return null}function q2(t,r,s){if(r==="")return null;for(;t.nodeType!==3;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!s||(t=Ur(t.nextSibling),t===null))return null;return t}function e0(t,r){for(;t.nodeType!==8;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!r||(t=Ur(t.nextSibling),t===null))return null;return t}function Lf(t){return t.data==="$?"||t.data==="$~"}function $f(t){return t.data==="$!"||t.data==="$?"&&t.ownerDocument.readyState!=="loading"}function Y2(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 Ur(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 If=null;function t0(t){t=t.nextSibling;for(var r=0;t;){if(t.nodeType===8){var s=t.data;if(s==="/$"||s==="/&"){if(r===0)return Ur(t.nextSibling);r--}else s!=="$"&&s!=="$!"&&s!=="$?"&&s!=="$~"&&s!=="&"||r++}t=t.nextSibling}return null}function n0(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 r0(t,r,s){switch(r=Wc(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 io(t){for(var r=t.attributes;r.length;)t.removeAttributeNode(r[0]);Ci(t)}var qr=new Map,a0=new Set;function Vc(t){return typeof t.getRootNode=="function"?t.getRootNode():t.nodeType===9?t:t.ownerDocument}var Va=le.d;le.d={f:X2,r:W2,D:V2,C:G2,L:K2,m:Q2,X:Z2,S:P2,M:J2};function X2(){var t=Va.f(),r=Lc();return t||r}function W2(t){var r=Hn(t);r!==null&&r.tag===5&&r.type==="form"?wx(r):Va.r(t)}var is=typeof document>"u"?null:document;function l0(t,r,s){var c=is;if(c&&typeof r=="string"&&r){var p=ir(r);p='link[rel="'+t+'"][href="'+p+'"]',typeof s=="string"&&(p+='[crossorigin="'+s+'"]'),a0.has(p)||(a0.add(p),t={rel:t,crossOrigin:s,href:r},c.querySelector(p)===null&&(r=c.createElement("link"),Wn(r,"link",t),pn(r),c.head.appendChild(r)))}}function V2(t){Va.D(t),l0("dns-prefetch",t,null)}function G2(t,r){Va.C(t,r),l0("preconnect",t,r)}function K2(t,r,s){Va.L(t,r,s);var c=is;if(c&&t&&r){var p='link[rel="preload"][as="'+ir(r)+'"]';r==="image"&&s&&s.imageSrcSet?(p+='[imagesrcset="'+ir(s.imageSrcSet)+'"]',typeof s.imageSizes=="string"&&(p+='[imagesizes="'+ir(s.imageSizes)+'"]')):p+='[href="'+ir(t)+'"]';var g=p;switch(r){case"style":g=ss(t);break;case"script":g=os(t)}qr.has(g)||(t=y({rel:"preload",href:r==="image"&&s&&s.imageSrcSet?void 0:t,as:r},s),qr.set(g,t),c.querySelector(p)!==null||r==="style"&&c.querySelector(so(g))||r==="script"&&c.querySelector(oo(g))||(r=c.createElement("link"),Wn(r,"link",t),pn(r),c.head.appendChild(r)))}}function Q2(t,r){Va.m(t,r);var s=is;if(s&&t){var c=r&&typeof r.as=="string"?r.as:"script",p='link[rel="modulepreload"][as="'+ir(c)+'"][href="'+ir(t)+'"]',g=p;switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":g=os(t)}if(!qr.has(g)&&(t=y({rel:"modulepreload",href:t},r),qr.set(g,t),s.querySelector(p)===null)){switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(s.querySelector(oo(g)))return}c=s.createElement("link"),Wn(c,"link",t),pn(c),s.head.appendChild(c)}}}function P2(t,r,s){Va.S(t,r,s);var c=is;if(c&&t){var p=gr(c).hoistableStyles,g=ss(t);r=r||"default";var C=p.get(g);if(!C){var z={loading:0,preload:null};if(C=c.querySelector(so(g)))z.loading=5;else{t=y({rel:"stylesheet",href:t,"data-precedence":r},s),(s=qr.get(g))&&Hf(t,s);var Y=C=c.createElement("link");pn(Y),Wn(Y,"link",t),Y._p=new Promise(function(oe,pe){Y.onload=oe,Y.onerror=pe}),Y.addEventListener("load",function(){z.loading|=1}),Y.addEventListener("error",function(){z.loading|=2}),z.loading|=4,Gc(C,r,c)}C={type:"stylesheet",instance:C,count:1,state:z},p.set(g,C)}}}function Z2(t,r){Va.X(t,r);var s=is;if(s&&t){var c=gr(s).hoistableScripts,p=os(t),g=c.get(p);g||(g=s.querySelector(oo(p)),g||(t=y({src:t,async:!0},r),(r=qr.get(p))&&Uf(t,r),g=s.createElement("script"),pn(g),Wn(g,"link",t),s.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},c.set(p,g))}}function J2(t,r){Va.M(t,r);var s=is;if(s&&t){var c=gr(s).hoistableScripts,p=os(t),g=c.get(p);g||(g=s.querySelector(oo(p)),g||(t=y({src:t,async:!0,type:"module"},r),(r=qr.get(p))&&Uf(t,r),g=s.createElement("script"),pn(g),Wn(g,"link",t),s.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},c.set(p,g))}}function i0(t,r,s,c){var p=(p=he.current)?Vc(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=ss(s.href),s=gr(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=ss(s.href);var g=gr(p).hoistableStyles,C=g.get(t);if(C||(p=p.ownerDocument||p,C={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},g.set(t,C),(g=p.querySelector(so(t)))&&!g._p&&(C.instance=g,C.state.loading=5),qr.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},qr.set(t,s),g||ew(p,t,s,C.state))),r&&c===null)throw Error(i(528,""));return C}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=os(s),s=gr(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 ss(t){return'href="'+ir(t)+'"'}function so(t){return'link[rel="stylesheet"]['+t+"]"}function s0(t){return y({},t,{"data-precedence":t.precedence,precedence:null})}function ew(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}),Wn(r,"link",s),pn(r),t.head.appendChild(r))}function os(t){return'[src="'+ir(t)+'"]'}function oo(t){return"script[async]"+t}function o0(t,r,s){if(r.count++,r.instance===null)switch(r.type){case"style":var c=t.querySelector('style[data-href~="'+ir(s.href)+'"]');if(c)return r.instance=c,pn(c),c;var p=y({},s,{"data-href":s.href,"data-precedence":s.precedence,href:null,precedence:null});return c=(t.ownerDocument||t).createElement("style"),pn(c),Wn(c,"style",p),Gc(c,s.precedence,t),r.instance=c;case"stylesheet":p=ss(s.href);var g=t.querySelector(so(p));if(g)return r.state.loading|=4,r.instance=g,pn(g),g;c=s0(s),(p=qr.get(p))&&Hf(c,p),g=(t.ownerDocument||t).createElement("link"),pn(g);var C=g;return C._p=new Promise(function(z,Y){C.onload=z,C.onerror=Y}),Wn(g,"link",c),r.state.loading|=4,Gc(g,s.precedence,t),r.instance=g;case"script":return g=os(s.src),(p=t.querySelector(oo(g)))?(r.instance=p,pn(p),p):(c=s,(p=qr.get(g))&&(c=y({},s),Uf(c,p)),t=t.ownerDocument||t,p=t.createElement("script"),pn(p),Wn(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,Gc(c,s.precedence,t));return r.instance}function Gc(t,r,s){for(var c=s.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),p=c.length?c[c.length-1]:null,g=p,C=0;C<c.length;C++){var z=c[C];if(z.dataset.precedence===r)g=z;else if(g!==p)break}g?g.parentNode.insertBefore(t,g.nextSibling):(r=s.nodeType===9?s.head:s,r.insertBefore(t,r.firstChild))}function Hf(t,r){t.crossOrigin==null&&(t.crossOrigin=r.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=r.referrerPolicy),t.title==null&&(t.title=r.title)}function Uf(t,r){t.crossOrigin==null&&(t.crossOrigin=r.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=r.referrerPolicy),t.integrity==null&&(t.integrity=r.integrity)}var Kc=null;function c0(t,r,s){if(Kc===null){var c=new Map,p=Kc=new Map;p.set(s,c)}else p=Kc,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 g=s[p];if(!(g[Da]||g[Fn]||t==="link"&&g.getAttribute("rel")==="stylesheet")&&g.namespaceURI!=="http://www.w3.org/2000/svg"){var C=g.getAttribute(r)||"";C=t+C;var z=c.get(C);z?z.push(g):c.set(C,[g])}}return c}function u0(t,r,s){t=t.ownerDocument||t,t.head.insertBefore(s,r==="title"?t.querySelector("head > title"):null)}function tw(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 d0(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function nw(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=ss(c.href),g=r.querySelector(so(p));if(g){r=g._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(t.count++,t=Qc.bind(t),r.then(t,t)),s.state.loading|=4,s.instance=g,pn(g);return}g=r.ownerDocument||r,c=s0(c),(p=qr.get(p))&&Hf(c,p),g=g.createElement("link"),pn(g);var C=g;C._p=new Promise(function(z,Y){C.onload=z,C.onerror=Y}),Wn(g,"link",c),s.instance=g}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(s,r),(r=s.state.preload)&&(s.state.loading&3)===0&&(t.count++,s=Qc.bind(t),r.addEventListener("load",s),r.addEventListener("error",s))}}var qf=0;function rw(t,r){return t.stylesheets&&t.count===0&&Zc(t,t.stylesheets),0<t.count||0<t.imgCount?function(s){var c=setTimeout(function(){if(t.stylesheets&&Zc(t,t.stylesheets),t.unsuspend){var g=t.unsuspend;t.unsuspend=null,g()}},6e4+r);0<t.imgBytes&&qf===0&&(qf=62500*O2());var p=setTimeout(function(){if(t.waitingForImages=!1,t.count===0&&(t.stylesheets&&Zc(t,t.stylesheets),t.unsuspend)){var g=t.unsuspend;t.unsuspend=null,g()}},(t.imgBytes>qf?50:800)+r);return t.unsuspend=s,function(){t.unsuspend=null,clearTimeout(c),clearTimeout(p)}}:null}function Qc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Zc(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var Pc=null;function Zc(t,r){t.stylesheets=null,t.unsuspend!==null&&(t.count++,Pc=new Map,r.forEach(aw,t),Pc=null,Qc.call(t))}function aw(t,r){if(!(r.state.loading&4)){var s=Pc.get(t);if(s)var c=s.get(null);else{s=new Map,Pc.set(t,s);for(var p=t.querySelectorAll("link[data-precedence],style[data-precedence]"),g=0;g<p.length;g++){var C=p[g];(C.nodeName==="LINK"||C.getAttribute("media")!=="not all")&&(s.set(C.dataset.precedence,C),c=C)}c&&s.set(null,c)}p=r.instance,C=p.getAttribute("data-precedence"),g=s.get(C)||c,g===c&&s.set(null,p),s.set(C,p),this.count++,c=Qc.bind(this),p.addEventListener("load",c),p.addEventListener("error",c),g?g.parentNode.insertBefore(p,g.nextSibling):(t=t.nodeType===9?t.head:t,t.insertBefore(p,t.firstChild)),r.state.loading|=4}}var co={$$typeof:_,Provider:null,Consumer:null,_currentValue:ee,_currentValue2:ee,_threadCount:0};function lw(t,r,s,c,p,g,C,z,Y){this.tag=1,this.containerInfo=t,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=St(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=St(0),this.hiddenUpdates=St(null),this.identifierPrefix=c,this.onUncaughtError=p,this.onCaughtError=g,this.onRecoverableError=C,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Y,this.incompleteTransitions=new Map}function f0(t,r,s,c,p,g,C,z,Y,oe,pe,ke){return t=new lw(t,r,s,C,Y,oe,pe,ke,z),r=1,g===!0&&(r|=24),g=wr(3,null,null,r),t.current=g,g.stateNode=t,r=wd(),r.refCount++,t.pooledCache=r,r.refCount++,g.memoizedState={element:c,isDehydrated:s,cache:r},Cd(g),t}function h0(t){return t?(t=$i,t):$i}function m0(t,r,s,c,p,g){p=h0(p),c.context===null?c.context=p:c.pendingContext=p,c=fl(r),c.payload={element:s},g=g===void 0?null:g,g!==null&&(c.callback=g),s=hl(t,c,r),s!==null&&(hr(s,t,r),Hs(s,t,r))}function p0(t,r){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var s=t.retryLane;t.retryLane=s!==0&&s<r?s:r}}function Yf(t,r){p0(t,r),(t=t.alternate)&&p0(t,r)}function x0(t){if(t.tag===13||t.tag===31){var r=Jl(t,67108864);r!==null&&hr(r,t,67108864),Yf(t,67108864)}}function y0(t){if(t.tag===13||t.tag===31){var r=Nr();r=vt(r);var s=Jl(t,r);s!==null&&hr(s,t,r),Yf(t,r)}}var Jc=!0;function iw(t,r,s,c){var p=X.T;X.T=null;var g=le.p;try{le.p=2,Xf(t,r,s,c)}finally{le.p=g,X.T=p}}function sw(t,r,s,c){var p=X.T;X.T=null;var g=le.p;try{le.p=8,Xf(t,r,s,c)}finally{le.p=g,X.T=p}}function Xf(t,r,s,c){if(Jc){var p=Wf(c);if(p===null)Ff(t,r,c,eu,s),b0(t,c);else if(cw(p,t,r,s,c))c.stopPropagation();else if(b0(t,c),r&4&&-1<ow.indexOf(t)){for(;p!==null;){var g=Hn(p);if(g!==null)switch(g.tag){case 3:if(g=g.stateNode,g.current.memoizedState.isDehydrated){var C=Bt(g.pendingLanes);if(C!==0){var z=g;for(z.pendingLanes|=2,z.entangledLanes|=2;C;){var Y=1<<31-Oe(C);z.entanglements[1]|=Y,C&=~Y}ga(g),(It&6)===0&&(Bc=Wt()+500,ro(0))}}break;case 31:case 13:z=Jl(g,2),z!==null&&hr(z,g,2),Lc(),Yf(g,2)}if(g=Wf(c),g===null&&Ff(t,r,c,eu,s),g===p)break;p=g}p!==null&&c.stopPropagation()}else Ff(t,r,c,null,s)}}function Wf(t){return t=hn(t),Vf(t)}var eu=null;function Vf(t){if(eu=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=h(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 eu=t,null}function g0(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(we()){case U:return 2;case ae:return 8;case me:case Ce:return 32;case De:return 268435456;default:return 32}default:return 32}}var Gf=!1,Sl=null,Cl=null,Nl=null,uo=new Map,fo=new Map,El=[],ow="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 b0(t,r){switch(t){case"focusin":case"focusout":Sl=null;break;case"dragenter":case"dragleave":Cl=null;break;case"mouseover":case"mouseout":Nl=null;break;case"pointerover":case"pointerout":uo.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":fo.delete(r.pointerId)}}function ho(t,r,s,c,p,g){return t===null||t.nativeEvent!==g?(t={blockedOn:r,domEventName:s,eventSystemFlags:c,nativeEvent:g,targetContainers:[p]},r!==null&&(r=Hn(r),r!==null&&x0(r)),t):(t.eventSystemFlags|=c,r=t.targetContainers,p!==null&&r.indexOf(p)===-1&&r.push(p),t)}function cw(t,r,s,c,p){switch(r){case"focusin":return Sl=ho(Sl,t,r,s,c,p),!0;case"dragenter":return Cl=ho(Cl,t,r,s,c,p),!0;case"mouseover":return Nl=ho(Nl,t,r,s,c,p),!0;case"pointerover":var g=p.pointerId;return uo.set(g,ho(uo.get(g)||null,t,r,s,c,p)),!0;case"gotpointercapture":return g=p.pointerId,fo.set(g,ho(fo.get(g)||null,t,r,s,c,p)),!0}return!1}function v0(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,qo(t.priority,function(){y0(s)});return}}else if(r===31){if(r=h(s),r!==null){t.blockedOn=r,qo(t.priority,function(){y0(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 tu(t){if(t.blockedOn!==null)return!1;for(var r=t.targetContainers;0<r.length;){var s=Wf(t.nativeEvent);if(s===null){s=t.nativeEvent;var c=new s.constructor(s.type,s);Zr=c,s.target.dispatchEvent(c),Zr=null}else return r=Hn(s),r!==null&&x0(r),t.blockedOn=s,!1;r.shift()}return!0}function w0(t,r,s){tu(t)&&s.delete(r)}function uw(){Gf=!1,Sl!==null&&tu(Sl)&&(Sl=null),Cl!==null&&tu(Cl)&&(Cl=null),Nl!==null&&tu(Nl)&&(Nl=null),uo.forEach(w0),fo.forEach(w0)}function nu(t,r){t.blockedOn===r&&(t.blockedOn=null,Gf||(Gf=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,uw)))}var ru=null;function k0(t){ru!==t&&(ru=t,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){ru===t&&(ru=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(Vf(c||s)===null)continue;break}var g=Hn(s);g!==null&&(t.splice(r,3),r-=3,Xd(g,{pending:!0,data:p,method:s.method,action:c},c,p))}}))}function cs(t){function r(Y){return nu(Y,t)}Sl!==null&&nu(Sl,t),Cl!==null&&nu(Cl,t),Nl!==null&&nu(Nl,t),uo.forEach(r),fo.forEach(r);for(var s=0;s<El.length;s++){var c=El[s];c.blockedOn===t&&(c.blockedOn=null)}for(;0<El.length&&(s=El[0],s.blockedOn===null);)v0(s),s.blockedOn===null&&El.shift();if(s=(t.ownerDocument||t).$$reactFormReplay,s!=null)for(c=0;c<s.length;c+=3){var p=s[c],g=s[c+1],C=p[Ln]||null;if(typeof g=="function")C||k0(s);else if(C){var z=null;if(g&&g.hasAttribute("formAction")){if(p=g,C=g[Ln]||null)z=C.formAction;else if(Vf(p)!==null)continue}else z=C.action;typeof z=="function"?s[c+1]=z:(s.splice(c,3),c-=3),k0(s)}}}function j0(){function t(g){g.canIntercept&&g.info==="react-transition"&&g.intercept({handler:function(){return new Promise(function(C){return p=C})},focusReset:"manual",scroll:"manual"})}function r(){p!==null&&(p(),p=null),c||setTimeout(s,20)}function s(){if(!c&&!navigation.transition){var g=navigation.currentEntry;g&&g.url!=null&&navigation.navigate(g.url,{state:g.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 Kf(t){this._internalRoot=t}au.prototype.render=Kf.prototype.render=function(t){var r=this._internalRoot;if(r===null)throw Error(i(409));var s=r.current,c=Nr();m0(s,c,t,r,null,null)},au.prototype.unmount=Kf.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var r=t.containerInfo;m0(t.current,2,null,t,null,null),Lc(),r[oa]=null}};function au(t){this._internalRoot=t}au.prototype.unstable_scheduleHydration=function(t){if(t){var r=tl();t={blockedOn:null,target:t,priority:r};for(var s=0;s<El.length&&r!==0&&r<El[s].priority;s++);El.splice(s,0,t),s===0&&v0(t)}};var S0=n.version;if(S0!=="19.2.4")throw Error(i(527,S0,"19.2.4"));le.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=f(r),t=t!==null?x(t):null,t=t===null?null:t.stateNode,t};var dw={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:X,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var lu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!lu.isDisabled&&lu.supportsFiber)try{$e=lu.inject(dw),Re=lu}catch{}}return po.createRoot=function(t,r){if(!o(t))throw Error(i(299));var s=!1,c="",p=Fx,g=Mx,C=Rx;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&&(g=r.onCaughtError),r.onRecoverableError!==void 0&&(C=r.onRecoverableError)),r=f0(t,1,!1,null,null,s,c,null,p,g,C,j0),t[oa]=r.current,Tf(t),new Kf(r)},po.hydrateRoot=function(t,r,s){if(!o(t))throw Error(i(299));var c=!1,p="",g=Fx,C=Mx,z=Rx,Y=null;return s!=null&&(s.unstable_strictMode===!0&&(c=!0),s.identifierPrefix!==void 0&&(p=s.identifierPrefix),s.onUncaughtError!==void 0&&(g=s.onUncaughtError),s.onCaughtError!==void 0&&(C=s.onCaughtError),s.onRecoverableError!==void 0&&(z=s.onRecoverableError),s.formState!==void 0&&(Y=s.formState)),r=f0(t,1,!0,r,s??null,c,p,Y,g,C,z,j0),r.context=h0(null),s=r.current,c=Nr(),c=vt(c),p=fl(c),p.callback=null,hl(s,p,c),s=c,r.current.lanes=s,ve(r,s),ga(r),t[oa]=r.current,Tf(t),new au(r)},po.version="19.2.4",po}var _0;function jw(){if(_0)return Zf.exports;_0=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(),Zf.exports=kw(),Zf.exports}var Sw=jw();const Cw="modulepreload",Nw=function(e){return"/"+e},B0={},Tg=function(n,a,i){let o=Promise.resolve();if(a&&a.length>0){let d=function(f){return Promise.all(f.map(x=>Promise.resolve(x).then(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),m=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));o=d(a.map(f=>{if(f=Nw(f),f in B0)return;B0[f]=!0;const x=f.endsWith(".css"),y=x?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${y}`))return;const v=document.createElement("link");if(v.rel=x?"stylesheet":Cw,x||(v.as="script"),v.crossOrigin="",v.href=f,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 ${f}`)))})}))}function u(d){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=d,window.dispatchEvent(h),!h.defaultPrevented)throw d}return o.then(d=>{for(const h of d||[])h.status==="rejected"&&u(h.reason);return n().catch(u)})};class Ew extends w.Component{constructor(){super(...arguments);C0(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 Ka="/api";async function _t(e){const n=await fetch(`${Ka}${e}`);if(!n.ok)throw new Error(`API error: ${n.status}`);return n.json()}async function nn(e,n){const a=await fetch(`${Ka}${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 iu(e,n){const a=await fetch(`${Ka}${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 Dl(e,n){const a={method:"DELETE"};n!==void 0&&(a.headers={"Content-Type":"application/json"},a.body=JSON.stringify(n));const i=await fetch(`${Ka}${e}`,a);if(!i.ok)throw new Error(`API error: ${i.status}`);return i.json()}const ye={getCompany:()=>_t("/company"),getRoles:()=>_t("/roles"),getRole:e=>_t(`/roles/${e}`),getProjects:()=>_t("/projects"),getProject:e=>_t(`/projects/${e}`),getStandups:()=>_t("/operations/standups"),getWaves:()=>_t("/operations/waves"),getWaveDetail:e=>_t(`/operations/waves/${e}`),patchWave:(e,n)=>iu(`/operations/waves/${e}`,n),getDecisions:()=>_t("/operations/decisions"),getOrgTree:()=>_t("/engine/org"),getSkills:()=>_t("/skills"),exportSkills:e=>_t(`/skills/export/${e}`),getSkillRegistry:()=>_t("/skills/registry"),installRegistrySkill:(e,n)=>nn("/skills/registry/install",{skillId:e,url:n}),createRole:e=>nn("/engine/roles",e),updateRole:(e,n)=>iu(`/engine/roles/${e}`,n),deleteRole:e=>Dl(`/engine/roles/${e}`),getSessions:()=>_t("/sessions"),getSession:e=>_t(`/sessions/${e}`),createSession:(e,n="talk")=>nn("/sessions",{roleId:e,mode:n}),deleteSession:e=>Dl(`/sessions/${e}`),deleteSessions:e=>Dl("/sessions",{ids:e}),deleteEmptySessions:()=>Dl("/sessions?empty=true"),updateSession:(e,n)=>iu(`/sessions/${e}`,n),abortSession:e=>nn(`/sessions/${e}/abort`,{}),replyToSession:(e,n)=>nn(`/sessions/${e}/reply`,{message:n}),startJob:e=>nn("/jobs",e),saveWave:e=>nn("/waves/save",e),getStatus:()=>_t("/status"),detectEngine:()=>nn("/setup/detect-engine",{}),validatePath:e=>nn("/setup/validate-path",{path:e}),scaffold:e=>nn("/setup/scaffold",e),getTeams:()=>_t("/setup/teams"),browse:e=>nn("/setup/browse",{path:e}),mkdir:(e,n)=>nn("/setup/mkdir",{path:e,name:n}),connectAkb:e=>nn("/setup/connect-akb",{path:e}),getRequiredTools:e=>nn("/setup/required-tools",{team:e}),installTools:(e,n)=>fetch(`${Ka}/setup/install-tools`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({team:e})}).then(a=>{var h;const i=(h=a.body)==null?void 0:h.getReader();if(!i)return;const o=new TextDecoder;let u="";const d=()=>i.read().then(({done:m,value:f})=>{if(m)return;u+=o.decode(f,{stream:!0});const x=u.split(`
50
- `);u=x.pop()||"";let y="";for(const v of x)if(v.startsWith("event: "))y=v.slice(7);else if(v.startsWith("data: ")&&y){try{n(y,JSON.parse(v.slice(6)))}catch{}y=""}return d()});return d()}),getKnowledge:()=>_t("/knowledge"),getKnowledgeDoc:e=>{const n=e.split("/").map(encodeURIComponent).join("/");return _t(`/knowledge/${n}`)},createKnowledgeDoc:e=>nn("/knowledge",e),updateKnowledgeDoc:(e,n)=>{const a=e.split("/").map(encodeURIComponent).join("/");return fetch(`${Ka}/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 Dl(`/knowledge/${n}`)},getPreferences:()=>_t("/preferences"),updatePreferences:e=>iu("/preferences",e),chatInChannel:e=>nn("/speech/chat",e),getSaveStatus:(e="akb")=>_t(`/save/status?repo=${e}`),save:(e,n="akb")=>nn(`/save?repo=${n}`,{message:e}),getSaveHistory:(e=20,n="akb")=>_t(`/save/history?limit=${e}&repo=${n}`),restoreSave:(e,n,a="akb")=>nn(`/save/restore?repo=${a}`,{sha:e,paths:n}),initGit:()=>nn("/save/init",{}),getSyncStatus:(e="akb")=>_t(`/save/sync-status?repo=${e}`),pull:async(e="akb")=>await(await fetch(`${Ka}/save/pull?repo=${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"})).json(),getGithubStatus:(e="akb")=>_t(`/save/github-status?repo=${e}`),githubCreateRepo:(e,n="private",a="akb")=>nn(`/save/github-create-repo?repo=${a}`,{name:e,visibility:n}),addRemote:(e,n="akb")=>nn(`/save/remote?repo=${n}`,{url:e}),setCodeRoot:async e=>{const n=await fetch(`${Ka}/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:()=>_t("/setup/code-root"),getCostSummary:()=>_t("/cost/summary"),getSyncRoles:()=>_t("/sync/roles"),applySyncUpdate:e=>nn("/sync/apply",e),getCompanyStats:()=>_t("/sync/stats"),getCoins:()=>_t("/coins"),earnCoins:(e,n,a)=>nn("/coins/earn",{amount:e,reason:n,ref:a}),spendCoins:(e,n,a)=>nn("/coins/spend",{amount:e,reason:n,ref:a}),migrateCoins:e=>nn("/coins/migrate",{completedQuests:e}),getQuestProgress:()=>_t("/quests/progress"),saveQuestProgress:e=>fetch(`${Ka}/quests/progress`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(n=>n.json()),getActiveSessions:()=>_t("/active-sessions"),getActiveSession:e=>_t(`/active-sessions/${e}`),registerActiveSession:e=>nn("/active-sessions/register",e),deleteActiveSession:e=>Dl(`/active-sessions/${e}`),cleanupActiveSessions:()=>nn("/active-sessions/cleanup",{}),getGitStatus:()=>_t("/git/status"),deleteWorktree:e=>Dl(`/git/worktrees/${encodeURIComponent(e)}`),deleteBranch:e=>Dl(`/git/branches/${encodeURIComponent(e)}`)},Aw=Object.freeze(Object.defineProperty({__proto__:null,api:ye},Symbol.toStringTag,{value:"Module"}));function Fg(e){const[n,a]=w.useState([]),[i,o]=w.useState("idle"),[u,d]=w.useState(""),[h,m]=w.useState([]),f=w.useRef(-1),x=w.useRef(null),y=w.useRef(0),v=w.useCallback(()=>{var S;if(!e)return;(S=x.current)==null||S.abort();const j=new AbortController;x.current=j,o("connecting");const k=f.current+1,N=`/api/sessions/${e}/stream?from=${k}`;fetch(N,{signal:j.signal}).then(async E=>{if(!E.ok||!E.body){o("error");return}o("streaming");const _=E.body.getReader(),R=new TextDecoder;let I="";for(;;){const{done:B,value:$}=await _.read();if(B)break;I+=R.decode($,{stream:!0});const q=I.split(`
51
- `);I=q.pop()??"";let G="";for(const T of q)if(T.startsWith("event: "))G=T.slice(7).trim();else if(T.startsWith("data: ")){try{const H=JSON.parse(T.slice(6));if(G==="activity"){const L=H;L.seq>f.current&&(f.current=L.seq),a(J=>J.some(ce=>ce.seq===L.seq)?J:[...J,L]),L.type==="text"&&d(J=>J+(L.data.text??"")),L.type==="dispatch:start"&&L.data.childJobId&&m(J=>[...J,L.data.childJobId]),L.type==="job:done"?o("done"):L.type==="job:error"&&o("error")}else if(G==="stream:end"){const L=H.reason;o(L==="done"?"done":L==="error"?"error":"done")}}catch{}G=""}}i==="streaming"&&o("done")}).catch(E=>{E.name!=="AbortError"&&(o("error"),y.current<3&&(y.current++,setTimeout(v,1e3*y.current)))})},[e]),b=w.useCallback(()=>{y.current=0,v()},[v]);return w.useEffect(()=>{if(!e){a([]),o("idle"),d(""),m([]),f.current=-1;return}return a([]),d(""),m([]),f.current=-1,y.current=0,v(),()=>{var j;(j=x.current)==null||j.abort()}},[e,v]),{events:n,status:i,textOutput:u,childJobIds:h,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 O0(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"?L0(e.value):!1:L0(e)}function L0(e){return e.replace(Rw,"")===""}class Lo{constructor(n,a,i){this.normal=a,this.property=n,i&&(this.space=i)}}Lo.prototype.normal={};Lo.prototype.property={};Lo.prototype.space=void 0;function Mg(e,n){const a={},i={};for(const o of e)Object.assign(a,o.property),Object.assign(i,o.normal);return new Lo(a,i,n)}function qh(e){return e.toLowerCase()}class xr{constructor(n,a){this.attribute=a,this.property=n}}xr.prototype.attribute="";xr.prototype.booleanish=!1;xr.prototype.boolean=!1;xr.prototype.commaOrSpaceSeparated=!1;xr.prototype.commaSeparated=!1;xr.prototype.defined=!1;xr.prototype.mustUseProperty=!1;xr.prototype.number=!1;xr.prototype.overloadedBoolean=!1;xr.prototype.property="";xr.prototype.spaceSeparated=!1;xr.prototype.space=void 0;let _w=0;const pt=Si(),Dn=Si(),Yh=Si(),Te=Si(),ln=Si(),ms=Si(),Er=Si();function Si(){return 2**++_w}const Xh=Object.freeze(Object.defineProperty({__proto__:null,boolean:pt,booleanish:Dn,commaOrSpaceSeparated:Er,commaSeparated:ms,number:Te,overloadedBoolean:Yh,spaceSeparated:ln},Symbol.toStringTag,{value:"Module"})),nh=Object.keys(Xh);class vm extends xr{constructor(n,a,i,o){let u=-1;if(super(n,a),$0(this,"space",o),typeof i=="number")for(;++u<nh.length;){const d=nh[u];$0(this,nh[u],(i&Xh[d])===Xh[d])}}}vm.prototype.defined=!0;function $0(e,n,a){a&&(e[n]=a)}function vs(e){const n={},a={};for(const[i,o]of Object.entries(e.properties)){const u=new vm(i,e.transform(e.attributes||{},i),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(i)&&(u.mustUseProperty=!0),n[i]=u,a[qh(i)]=i,a[qh(u.attribute)]=i}return new Lo(n,a,e.space)}const Rg=vs({properties:{ariaActiveDescendant:null,ariaAtomic:Dn,ariaAutoComplete:null,ariaBusy:Dn,ariaChecked:Dn,ariaColCount:Te,ariaColIndex:Te,ariaColSpan:Te,ariaControls:ln,ariaCurrent:null,ariaDescribedBy:ln,ariaDetails:null,ariaDisabled:Dn,ariaDropEffect:ln,ariaErrorMessage:null,ariaExpanded:Dn,ariaFlowTo:ln,ariaGrabbed:Dn,ariaHasPopup:null,ariaHidden:Dn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ln,ariaLevel:Te,ariaLive:null,ariaModal:Dn,ariaMultiLine:Dn,ariaMultiSelectable:Dn,ariaOrientation:null,ariaOwns:ln,ariaPlaceholder:null,ariaPosInSet:Te,ariaPressed:Dn,ariaReadOnly:Dn,ariaRelevant:null,ariaRequired:Dn,ariaRoleDescription:ln,ariaRowCount:Te,ariaRowIndex:Te,ariaRowSpan:Te,ariaSelected:Dn,ariaSetSize:Te,ariaSort:null,ariaValueMax:Te,ariaValueMin:Te,ariaValueNow:Te,ariaValueText:null,role:null},transform(e,n){return n==="role"?n:"aria-"+n.slice(4).toLowerCase()}});function zg(e,n){return n in e?e[n]:n}function _g(e,n){return zg(e,n.toLowerCase())}const Bw=vs({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:ms,acceptCharset:ln,accessKey:ln,action:null,allow:null,allowFullScreen:pt,allowPaymentRequest:pt,allowUserMedia:pt,alt:null,as:null,async:pt,autoCapitalize:null,autoComplete:ln,autoFocus:pt,autoPlay:pt,blocking:ln,capture:null,charSet:null,checked:pt,cite:null,className:ln,cols:Te,colSpan:null,content:null,contentEditable:Dn,controls:pt,controlsList:ln,coords:Te|ms,crossOrigin:null,data:null,dateTime:null,decoding:null,default:pt,defer:pt,dir:null,dirName:null,disabled:pt,download:Yh,draggable:Dn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:pt,formTarget:null,headers:ln,height:Te,hidden:Yh,high:Te,href:null,hrefLang:null,htmlFor:ln,httpEquiv:ln,id:null,imageSizes:null,imageSrcSet:null,inert:pt,inputMode:null,integrity:null,is:null,isMap:pt,itemId:null,itemProp:ln,itemRef:ln,itemScope:pt,itemType:ln,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:pt,low:Te,manifest:null,max:null,maxLength:Te,media:null,method:null,min:null,minLength:Te,multiple:pt,muted:pt,name:null,nonce:null,noModule:pt,noValidate:pt,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:pt,optimum:Te,pattern:null,ping:ln,placeholder:null,playsInline:pt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:pt,referrerPolicy:null,rel:ln,required:pt,reversed:pt,rows:Te,rowSpan:Te,sandbox:ln,scope:null,scoped:pt,seamless:pt,selected:pt,shadowRootClonable:pt,shadowRootDelegatesFocus:pt,shadowRootMode:null,shape:null,size:Te,sizes:null,slot:null,span:Te,spellCheck:Dn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Te,step:null,style:null,tabIndex:Te,target:null,title:null,translate:null,type:null,typeMustMatch:pt,useMap:null,value:Dn,width:Te,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ln,axis:null,background:null,bgColor:null,border:Te,borderColor:null,bottomMargin:Te,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:pt,declare:pt,event:null,face:null,frame:null,frameBorder:null,hSpace:Te,leftMargin:Te,link:null,longDesc:null,lowSrc:null,marginHeight:Te,marginWidth:Te,noResize:pt,noHref:pt,noShade:pt,noWrap:pt,object:null,profile:null,prompt:null,rev:null,rightMargin:Te,rules:null,scheme:null,scrolling:Dn,standby:null,summary:null,text:null,topMargin:Te,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Te,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:pt,disableRemotePlayback:pt,prefix:null,property:null,results:Te,security:null,unselectable:null},space:"html",transform:_g}),Ow=vs({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:Er,accentHeight:Te,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Te,amplitude:Te,arabicForm:null,ascent:Te,attributeName:null,attributeType:null,azimuth:Te,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Te,by:null,calcMode:null,capHeight:Te,className:ln,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:Te,diffuseConstant:Te,direction:null,display:null,dur:null,divisor:Te,dominantBaseline:null,download:pt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Te,enableBackground:null,end:null,event:null,exponent:Te,externalResourcesRequired:null,fill:null,fillOpacity:Te,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:ms,g2:ms,glyphName:ms,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Te,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Te,horizOriginX:Te,horizOriginY:Te,id:null,ideographic:Te,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Te,k:Te,k1:Te,k2:Te,k3:Te,k4:Te,kernelMatrix:Er,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Te,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:Te,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:Te,overlineThickness:Te,paintOrder:null,panose1:null,path:null,pathLength:Te,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ln,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Te,pointsAtY:Te,pointsAtZ:Te,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Er,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Er,rev:Er,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Er,requiredFeatures:Er,requiredFonts:Er,requiredFormats:Er,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:Te,specularExponent:Te,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Te,strikethroughThickness:Te,string:null,stroke:null,strokeDashArray:Er,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Te,strokeOpacity:Te,strokeWidth:null,style:null,surfaceScale:Te,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Er,tabIndex:Te,tableValues:null,target:null,targetX:Te,targetY:Te,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Er,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Te,underlineThickness:Te,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Te,values:null,vAlphabetic:Te,vMathematical:Te,vectorEffect:null,vHanging:Te,vIdeographic:Te,version:null,vertAdvY:Te,vertOriginX:Te,vertOriginY:Te,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Te,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:zg}),Bg=vs({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()}}),Og=vs({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:_g}),Lg=vs({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,n){return"xml:"+n.slice(3).toLowerCase()}}),Lw={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"},$w=/[A-Z]/g,I0=/-[a-z]/g,Iw=/^data[-\w.:]+$/i;function Hw(e,n){const a=qh(n);let i=n,o=xr;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(I0,qw);i="data"+u.charAt(0).toUpperCase()+u.slice(1)}else{const u=n.slice(4);if(!I0.test(u)){let d=u.replace($w,Uw);d.charAt(0)!=="-"&&(d="-"+d),n="data"+d}}o=vm}return new o(i,n)}function Uw(e){return"-"+e.toLowerCase()}function qw(e){return e.charAt(1).toUpperCase()}const Yw=Mg([Rg,Bw,Bg,Og,Lg],"html"),wm=Mg([Rg,Ow,Bg,Og,Lg],"svg");function Xw(e){return e.join(" ").trim()}var us={},rh,H0;function Ww(){if(H0)return rh;H0=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,n=/\n/g,a=/^\s*/,i=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,u=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,d=/^[;\s]*/,h=/^\s+|\s+$/g,m=`
52
- `,f="/",x="*",y="",v="comment",b="declaration";function j(N,S){if(typeof N!="string")throw new TypeError("First argument must be a string");if(!N)return[];S=S||{};var E=1,_=1;function R(ce){var re=ce.match(n);re&&(E+=re.length);var X=ce.lastIndexOf(m);_=~X?ce.length-X:_+ce.length}function I(){var ce={line:E,column:_};return function(re){return re.position=new B(ce),G(),re}}function B(ce){this.start=ce,this.end={line:E,column:_},this.source=S.source}B.prototype.content=N;function $(ce){var re=new Error(S.source+":"+E+":"+_+": "+ce);if(re.reason=ce,re.filename=S.source,re.line=E,re.column=_,re.source=N,!S.silent)throw re}function q(ce){var re=ce.exec(N);if(re){var X=re[0];return R(X),N=N.slice(X.length),re}}function G(){q(a)}function T(ce){var re;for(ce=ce||[];re=H();)re!==!1&&ce.push(re);return ce}function H(){var ce=I();if(!(f!=N.charAt(0)||x!=N.charAt(1))){for(var re=2;y!=N.charAt(re)&&(x!=N.charAt(re)||f!=N.charAt(re+1));)++re;if(re+=2,y===N.charAt(re-1))return $("End of comment missing");var X=N.slice(2,re-2);return _+=2,R(X),N=N.slice(re),_+=2,ce({type:v,comment:X})}}function L(){var ce=I(),re=q(i);if(re){if(H(),!q(o))return $("property missing ':'");var X=q(u),le=ce({type:b,property:k(re[0].replace(e,y)),value:X?k(X[0].replace(e,y)):y});return q(d),le}}function J(){var ce=[];T(ce);for(var re;re=L();)re!==!1&&(ce.push(re),T(ce));return ce}return G(),J()}function k(N){return N?N.replace(h,y):y}return rh=j,rh}var U0;function Vw(){if(U0)return us;U0=1;var e=us&&us.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(us,"__esModule",{value:!0}),us.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),h=typeof o=="function";return d.forEach(m=>{if(m.type!=="declaration")return;const{property:f,value:x}=m;h?o(f,x,m):x&&(u=u||{},u[f]=x)}),u}return us}var xo={},q0;function Gw(){if(q0)return xo;q0=1,Object.defineProperty(xo,"__esModule",{value:!0}),xo.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,a=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,o=/^-(ms)-/,u=function(f){return!f||a.test(f)||e.test(f)},d=function(f,x){return x.toUpperCase()},h=function(f,x){return"".concat(x,"-")},m=function(f,x){return x===void 0&&(x={}),u(f)?f:(f=f.toLowerCase(),x.reactCompat?f=f.replace(o,h):f=f.replace(i,h),f.replace(n,d))};return xo.camelCase=m,xo}var yo,Y0;function Kw(){if(Y0)return yo;Y0=1;var e=yo&&yo.__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(h,m){h&&m&&(d[(0,a.camelCase)(h,u)]=m)}),d}return i.default=i,yo=i,yo}var Qw=Kw();const Pw=Dg(Qw),$g=Ig("end"),km=Ig("start");function Ig(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=km(e),a=$g(e);if(n&&a)return{start:n,end:a}}function Do(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?X0(e.position):"start"in e||"end"in e?X0(e):"line"in e||"column"in e?Wh(e):""}function Wh(e){return W0(e&&e.line)+":"+W0(e&&e.column)}function X0(e){return Wh(e&&e.start)+"-"+Wh(e&&e.end)}function W0(e){return e&&typeof e=="number"?e:1}class Zn 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 h=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=h?h.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=h?h.line:void 0,this.name=Do(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}}Zn.prototype.file="";Zn.prototype.name="";Zn.prototype.reason="";Zn.prototype.message="";Zn.prototype.stack="";Zn.prototype.column=void 0;Zn.prototype.line=void 0;Zn.prototype.ancestors=void 0;Zn.prototype.cause=void 0;Zn.prototype.fatal=void 0;Zn.prototype.place=void 0;Zn.prototype.ruleId=void 0;Zn.prototype.source=void 0;const jm={}.hasOwnProperty,Jw=new Map,e5=/[A-Z]/g,t5=new Set(["table","tbody","thead","tfoot","tr"]),n5=new Set(["td","th"]),Hg="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"?wm:Yw,stylePropertyNameCase:n.stylePropertyNameCase||"dom",tableCellAlignToStyle:n.tableCellAlignToStyle!==!1},u=Ug(o,e,void 0);return u&&typeof u!="string"?u:o.create(e,o.Fragment,{children:u||void 0},void 0)}function Ug(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=wm,e.schema=o),e.ancestors.push(n);const u=Yg(e,n.tagName,!1),d=f5(e,n);let h=Cm(e,n);return t5.has(n.tagName)&&(h=h.filter(function(m){return typeof m=="string"?!zw(m):!0})),qg(e,d,u,n),Sm(d,h),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)}Mo(e,n.position)}function i5(e,n){if(n.data&&n.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(n.data.estree);Mo(e,n.position)}function s5(e,n,a){const i=e.schema;let o=i;n.name==="svg"&&i.space==="html"&&(o=wm,e.schema=o),e.ancestors.push(n);const u=n.name===null?e.Fragment:Yg(e,n.name,!0),d=h5(e,n),h=Cm(e,n);return qg(e,d,u,n),Sm(d,h),e.ancestors.pop(),e.schema=i,e.create(n,u,d,a)}function o5(e,n,a){const i={};return Sm(i,Cm(e,n)),e.create(n,e.Fragment,i,a)}function c5(e,n){return n.value}function qg(e,n,a,i){typeof a!="string"&&a!==e.Fragment&&e.passNode&&(n.node=i)}function Sm(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,h){const f=Array.isArray(d.children)?a:n;return h?f(u,d,h):f(u,d)}}function d5(e,n){return a;function a(i,o,u,d){const h=Array.isArray(u.children),m=km(i);return n(o,u,d,h,{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"&&jm.call(n.properties,o)){const u=m5(e,o,n.properties[o]);if(u){const[d,h]=u;e.tableCellAlignToStyle&&d==="align"&&typeof h=="string"&&n5.has(n.tagName)?i=h:a[d]=h}}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 h=d.properties[0];h.type,Object.assign(a,e.evaluater.evaluateExpression(h.argument))}else Mo(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 h=i.value.data.estree.body[0];h.type,u=e.evaluater.evaluateExpression(h.expression)}else Mo(e,n.position);else u=i.value===null?!0:i.value;a[o]=u}return a}function Cm(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 f=o.get(m)||0;d=m+"-"+f,o.set(m,f+1)}}const h=Ug(e,u,d);h!==void 0&&a.push(h)}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?Lw[i.property]||i.property:i.attribute,a]}}function p5(e,n){try{return Pw(n,{reactCompat:!0})}catch(a){if(e.ignoreInvalidStyle)return{};const i=a,o=new Zn("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=Hg+"#cannot-parse-style-attribute",o}}function Yg(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 h=O0(o[u])?{type:"Identifier",name:o[u]}:{type:"Literal",value:o[u]};d=d?{type:"MemberExpression",object:d,property:h,computed:!!(u&&h.type==="Literal"),optional:!1}:h}i=d}else i=O0(n)&&!/^[a-z]/.test(n)?{type:"Identifier",name:n}:{type:"Literal",value:n};if(i.type==="Literal"){const o=i.value;return jm.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(i);Mo(e)}function Mo(e,n){const a=new Zn("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=Hg+"#cannot-handle-mdx-estrees-without-createevaluater",a}function x5(e){const n={};let a;for(a in e)jm.call(e,a)&&(n[y5(a)]=e[a]);return n}function y5(e){let n=e.replace(e5,g5);return n.slice(0,3)==="ms-"&&(n="-"+n),n}function g5(e){return"-"+e.toLowerCase()}const ah={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 Nm(e,n){const a=b5,i=typeof a.includeImageAlt=="boolean"?a.includeImageAlt:!0,o=typeof a.includeHtml=="boolean"?a.includeHtml:!0;return Xg(e,i,o)}function Xg(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 V0(e.children,n,a)}return Array.isArray(e)?V0(e,n,a):""}function V0(e,n,a){const i=[];let o=-1;for(;++o<e.length;)i[o]=Xg(e[o],n,a);return i.join("")}function v5(e){return!!(e&&typeof e=="object")}const G0=document.createElement("i");function Em(e){const n="&"+e+";";G0.innerHTML=n;const a=G0.textContent;return a.charCodeAt(a.length-1)===59&&e!=="semi"||a===n?!1:a}function Fr(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 Xr(e,n){return e.length>0?(Fr(e,e.length,0,n),e):n}const K0={}.hasOwnProperty;function Wg(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=(K0.call(e,a)?e[a]:void 0)||(e[a]={}),u=n[a];let d;if(u)for(d in u){K0.call(o,d)||(o[d]=[]);const h=u[d];k5(o[d],Array.isArray(h)?h:h?[h]:[])}}}function k5(e,n){let a=-1;const i=[];for(;++a<n.length;)(n[a].add==="after"?e:i).push(n[a]);Fr(e,0,0,i)}function Vg(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 sa(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const nr=Ll(/[A-Za-z]/),Pn=Ll(/[\dA-Za-z]/),j5=Ll(/[#-'*+\--9=?A-Z^-~]/);function Mu(e){return e!==null&&(e<32||e===127)}const Vh=Ll(/\d/),S5=Ll(/[\dA-Fa-f]/),C5=Ll(/[!-/:-@[-`{-~]/);function Ze(e){return e!==null&&e<-2}function rn(e){return e!==null&&(e<0||e===32)}function Et(e){return e===-2||e===-1||e===32}const Yu=Ll(new RegExp("\\p{P}|\\p{S}","u")),ki=Ll(/\s/);function Ll(e){return n;function n(a){return a!==null&&a>-1&&e.test(String.fromCharCode(a))}}function ws(e){const n=[];let a=-1,i=0,o=0;for(;++a<e.length;){const u=e.charCodeAt(a);let d="";if(u===37&&Pn(e.charCodeAt(a+1))&&Pn(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 h=e.charCodeAt(a+1);u<56320&&h>56319&&h<57344?(d=String.fromCharCode(u,h),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 Rt(e,n,a,i){const o=i?i-1:Number.POSITIVE_INFINITY;let u=0;return d;function d(m){return Et(m)?(e.enter(a),h(m)):n(m)}function h(m){return Et(m)&&u++<o?(e.consume(m),h):(e.exit(a),n(m))}}const N5={tokenize:E5};function E5(e){const n=e.attempt(this.parser.constructs.contentInitial,i,o);let a;return n;function i(h){if(h===null){e.consume(h);return}return e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),Rt(e,n,"linePrefix")}function o(h){return e.enter("paragraph"),u(h)}function u(h){const m=e.enter("chunkText",{contentType:"text",previous:a});return a&&(a.next=m),a=m,d(h)}function d(h){if(h===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(h);return}return Ze(h)?(e.consume(h),e.exit("chunkText"),u):(e.consume(h),d)}}const A5={tokenize:D5},Q0={tokenize:T5};function D5(e){const n=this,a=[];let i=0,o,u,d;return h;function h(_){if(i<a.length){const R=a[i];return n.containerState=R[1],e.attempt(R[0].continuation,m,f)(_)}return f(_)}function m(_){if(i++,n.containerState._closeFlow){n.containerState._closeFlow=void 0,o&&E();const R=n.events.length;let I=R,B;for(;I--;)if(n.events[I][0]==="exit"&&n.events[I][1].type==="chunkFlow"){B=n.events[I][1].end;break}S(i);let $=R;for(;$<n.events.length;)n.events[$][1].end={...B},$++;return Fr(n.events,I+1,0,n.events.slice(R)),n.events.length=$,f(_)}return h(_)}function f(_){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(Q0,x,y)(_)}function x(_){return o&&E(),S(i),v(_)}function y(_){return n.parser.lazy[n.now().line]=i!==a.length,d=n.now().offset,j(_)}function v(_){return n.containerState={},e.attempt(Q0,b,j)(_)}function b(_){return i++,a.push([n.currentConstruct,n.containerState]),v(_)}function j(_){if(_===null){o&&E(),S(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),S(0),e.consume(_);return}return Ze(_)?(e.consume(_),N(e.exit("chunkFlow")),i=0,n.interrupt=void 0,h):(e.consume(_),k)}function N(_,R){const I=n.sliceStream(_);if(R&&I.push(null),_.previous=u,u&&(u.next=_),u=_,o.defineSkip(_.start),o.write(I),n.parser.lazy[_.start.line]){let B=o.events.length;for(;B--;)if(o.events[B][1].start.offset<d&&(!o.events[B][1].end||o.events[B][1].end.offset>d))return;const $=n.events.length;let q=$,G,T;for(;q--;)if(n.events[q][0]==="exit"&&n.events[q][1].type==="chunkFlow"){if(G){T=n.events[q][1].end;break}G=!0}for(S(i),B=$;B<n.events.length;)n.events[B][1].end={...T},B++;Fr(n.events,q+1,0,n.events.slice($)),n.events.length=B}}function S(_){let R=a.length;for(;R-- >_;){const I=a[R];n.containerState=I[1],I[0].exit.call(n,e)}a.length=_}function E(){o.write([null]),u=void 0,o=void 0,n.containerState._closeFlow=void 0}}function T5(e,n,a){return Rt(e,e.attempt(this.parser.constructs.document,n,a),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function ps(e){if(e===null||rn(e)||ki(e))return 1;if(Yu(e))return 2}function Xu(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 Gh={name:"attention",resolveAll:F5,tokenize:M5};function F5(e,n){let a=-1,i,o,u,d,h,m,f,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 y={...e[i][1].end},v={...e[a][1].start};P0(y,-m),P0(v,m),d={type:m>1?"strongSequence":"emphasisSequence",start:y,end:{...e[i][1].end}},h={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:{...h.end}},e[i][1].end={...d.start},e[a][1].start={...h.end},f=[],e[i][1].end.offset-e[i][1].start.offset&&(f=Xr(f,[["enter",e[i][1],n],["exit",e[i][1],n]])),f=Xr(f,[["enter",o,n],["enter",d,n],["exit",d,n],["enter",u,n]]),f=Xr(f,Xu(n.parser.constructs.insideSpan.null,e.slice(i+1,a),n)),f=Xr(f,[["exit",u,n],["enter",h,n],["exit",h,n],["exit",o,n]]),e[a][1].end.offset-e[a][1].start.offset?(x=2,f=Xr(f,[["enter",e[a][1],n],["exit",e[a][1],n]])):x=0,Fr(e,i-1,a-i+3,f),a=i+f.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=ps(i);let u;return d;function d(m){return u=m,e.enter("attentionSequence"),h(m)}function h(m){if(m===u)return e.consume(m),h;const f=e.exit("attentionSequence"),x=ps(m),y=!x||x===2&&o||a.includes(m),v=!o||o===2&&x||a.includes(i);return f._open=!!(u===42?y:y&&(o||!v)),f._close=!!(u===42?v:v&&(x||!y)),n(m)}}function P0(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 nr(b)?(e.consume(b),d):b===64?a(b):f(b)}function d(b){return b===43||b===45||b===46||Pn(b)?(i=1,h(b)):f(b)}function h(b){return b===58?(e.consume(b),i=0,m):(b===43||b===45||b===46||Pn(b))&&i++<32?(e.consume(b),h):(i=0,f(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||Mu(b)?a(b):(e.consume(b),m)}function f(b){return b===64?(e.consume(b),x):j5(b)?(e.consume(b),f):a(b)}function x(b){return Pn(b)?y(b):a(b)}function y(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||Pn(b))&&i++<63){const j=b===45?v:y;return e.consume(b),j}return a(b)}}const $o={partial:!0,tokenize:_5};function _5(e,n,a){return i;function i(u){return Et(u)?Rt(e,o,"linePrefix")(u):o(u)}function o(u){return u===null||Ze(u)?n(u):a(u)}}const Gg={continuation:{tokenize:O5},exit:L5,name:"blockQuote",tokenize:B5};function B5(e,n,a){const i=this;return o;function o(d){if(d===62){const h=i.containerState;return h.open||(e.enter("blockQuote",{_container:!0}),h.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(d),e.exit("blockQuoteMarker"),u}return a(d)}function u(d){return Et(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 Et(d)?Rt(e,u,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(d):u(d)}function u(d){return e.attempt(Gg,n,a)(d)}}function L5(e){e.exit("blockQuote")}const Kg={name:"characterEscape",tokenize:$5};function $5(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 Qg={name:"characterReference",tokenize:I5};function I5(e,n,a){const i=this;let o=0,u,d;return h;function h(y){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(y),e.exit("characterReferenceMarker"),m}function m(y){return y===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(y),e.exit("characterReferenceMarkerNumeric"),f):(e.enter("characterReferenceValue"),u=31,d=Pn,x(y))}function f(y){return y===88||y===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(y),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),u=6,d=S5,x):(e.enter("characterReferenceValue"),u=7,d=Vh,x(y))}function x(y){if(y===59&&o){const v=e.exit("characterReferenceValue");return d===Pn&&!Em(i.sliceSerialize(v))?a(y):(e.enter("characterReferenceMarker"),e.consume(y),e.exit("characterReferenceMarker"),e.exit("characterReference"),n)}return d(y)&&o++<u?(e.consume(y),x):a(y)}}const Z0={partial:!0,tokenize:U5},J0={concrete:!0,name:"codeFenced",tokenize:H5};function H5(e,n,a){const i=this,o={partial:!0,tokenize:I};let u=0,d=0,h;return m;function m(B){return f(B)}function f(B){const $=i.events[i.events.length-1];return u=$&&$[1].type==="linePrefix"?$[2].sliceSerialize($[1],!0).length:0,h=B,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),x(B)}function x(B){return B===h?(d++,e.consume(B),x):d<3?a(B):(e.exit("codeFencedFenceSequence"),Et(B)?Rt(e,y,"whitespace")(B):y(B))}function y(B){return B===null||Ze(B)?(e.exit("codeFencedFence"),i.interrupt?n(B):e.check(Z0,k,R)(B)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),v(B))}function v(B){return B===null||Ze(B)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),y(B)):Et(B)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Rt(e,b,"whitespace")(B)):B===96&&B===h?a(B):(e.consume(B),v)}function b(B){return B===null||Ze(B)?y(B):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),j(B))}function j(B){return B===null||Ze(B)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),y(B)):B===96&&B===h?a(B):(e.consume(B),j)}function k(B){return e.attempt(o,R,N)(B)}function N(B){return e.enter("lineEnding"),e.consume(B),e.exit("lineEnding"),S}function S(B){return u>0&&Et(B)?Rt(e,E,"linePrefix",u+1)(B):E(B)}function E(B){return B===null||Ze(B)?e.check(Z0,k,R)(B):(e.enter("codeFlowValue"),_(B))}function _(B){return B===null||Ze(B)?(e.exit("codeFlowValue"),E(B)):(e.consume(B),_)}function R(B){return e.exit("codeFenced"),n(B)}function I(B,$,q){let G=0;return T;function T(re){return B.enter("lineEnding"),B.consume(re),B.exit("lineEnding"),H}function H(re){return B.enter("codeFencedFence"),Et(re)?Rt(B,L,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(re):L(re)}function L(re){return re===h?(B.enter("codeFencedFenceSequence"),J(re)):q(re)}function J(re){return re===h?(G++,B.consume(re),J):G>=d?(B.exit("codeFencedFenceSequence"),Et(re)?Rt(B,ce,"whitespace")(re):ce(re)):q(re)}function ce(re){return re===null||Ze(re)?(B.exit("codeFencedFence"),$(re)):q(re)}}}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 lh={name:"codeIndented",tokenize:Y5},q5={partial:!0,tokenize:X5};function Y5(e,n,a){const i=this;return o;function o(f){return e.enter("codeIndented"),Rt(e,u,"linePrefix",5)(f)}function u(f){const x=i.events[i.events.length-1];return x&&x[1].type==="linePrefix"&&x[2].sliceSerialize(x[1],!0).length>=4?d(f):a(f)}function d(f){return f===null?m(f):Ze(f)?e.attempt(q5,d,m)(f):(e.enter("codeFlowValue"),h(f))}function h(f){return f===null||Ze(f)?(e.exit("codeFlowValue"),d(f)):(e.consume(f),h)}function m(f){return e.exit("codeIndented"),n(f)}}function X5(e,n,a){const i=this;return o;function o(d){return i.parser.lazy[i.now().line]?a(d):Ze(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),o):Rt(e,u,"linePrefix",5)(d)}function u(d){const h=i.events[i.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?n(d):Ze(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(y){return e.enter("codeText"),e.enter("codeTextSequence"),h(y)}function h(y){return y===96?(e.consume(y),i++,h):(e.exit("codeTextSequence"),m(y))}function m(y){return y===null?a(y):y===32?(e.enter("space"),e.consume(y),e.exit("space"),m):y===96?(u=e.enter("codeTextSequence"),o=0,x(y)):Ze(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),m):(e.enter("codeTextData"),f(y))}function f(y){return y===null||y===32||y===96||Ze(y)?(e.exit("codeTextData"),m(y)):(e.consume(y),f)}function x(y){return y===96?(e.consume(y),o++,x):o===i?(e.exit("codeTextSequence"),e.exit("codeText"),n(y)):(u.type="codeTextData",f(y))}}class Q5{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&&go(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),go(this.left,n)}unshift(n){this.setCursor(0),this.right.push(n)}unshiftMany(n){this.setCursor(0),go(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);go(this.right,a.reverse())}else{const a=this.right.splice(this.left.length+this.right.length-n,Number.POSITIVE_INFINITY);go(this.left,a.reverse())}}}function go(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 Pg(e){const n={};let a=-1,i,o,u,d,h,m,f;const x=new Q5(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,P5(x,a)),a=n[a],f=!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},h=x.slice(o,a),h.unshift(i),x.splice(o,a-o+1,h))}}return Fr(e,0,Number.POSITIVE_INFINITY,x.slice(0)),!f}function P5(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 h=d.events,m=[],f={};let x,y,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),y&&d.defineSkip(b.start),b._isInFirstContentOfListItem&&(d._gfmTasklistFirstContentOfListItem=!0),d.write(x),b._isInFirstContentOfListItem&&(d._gfmTasklistFirstContentOfListItem=void 0)),y=b,b=b.next}for(b=a;++v<h.length;)h[v][0]==="exit"&&h[v-1][0]==="enter"&&h[v][1].type===h[v-1][1].type&&h[v][1].start.line!==h[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 S=h.slice(N[v],N[v+1]),E=u.pop();m.push([E,E+S.length-1]),e.splice(E,2,S)}for(m.reverse(),v=-1;++v<m.length;)f[j+m[v][0]]=j+m[v][1],j+=m[v][1]-m[v][0]-1;return f}const Z5={resolve:ek,tokenize:tk},J5={partial:!0,tokenize:nk};function ek(e){return Pg(e),e}function tk(e,n){let a;return i;function i(h){return e.enter("content"),a=e.enter("chunkContent",{contentType:"content"}),o(h)}function o(h){return h===null?u(h):Ze(h)?e.check(J5,d,u)(h):(e.consume(h),o)}function u(h){return e.exit("chunkContent"),e.exit("content"),n(h)}function d(h){return e.consume(h),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"),Rt(e,u,"linePrefix")}function u(d){if(d===null||Ze(d))return a(d);const h=i.events[i.events.length-1];return!i.parser.constructs.disable.null.includes("codeIndented")&&h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?n(d):e.interrupt(i.parser.constructs.flow,a,n)(d)}}function Zg(e,n,a,i,o,u,d,h,m){const f=m||Number.POSITIVE_INFINITY;let x=0;return y;function y(S){return S===60?(e.enter(i),e.enter(o),e.enter(u),e.consume(S),e.exit(u),v):S===null||S===32||S===41||Mu(S)?a(S):(e.enter(i),e.enter(d),e.enter(h),e.enter("chunkString",{contentType:"string"}),k(S))}function v(S){return S===62?(e.enter(u),e.consume(S),e.exit(u),e.exit(o),e.exit(i),n):(e.enter(h),e.enter("chunkString",{contentType:"string"}),b(S))}function b(S){return S===62?(e.exit("chunkString"),e.exit(h),v(S)):S===null||S===60||Ze(S)?a(S):(e.consume(S),S===92?j:b)}function j(S){return S===60||S===62||S===92?(e.consume(S),b):b(S)}function k(S){return!x&&(S===null||S===41||rn(S))?(e.exit("chunkString"),e.exit(h),e.exit(d),e.exit(i),n(S)):x<f&&S===40?(e.consume(S),x++,k):S===41?(e.consume(S),x--,k):S===null||S===32||S===40||Mu(S)?a(S):(e.consume(S),S===92?N:k)}function N(S){return S===40||S===41||S===92?(e.consume(S),k):k(S)}}function Jg(e,n,a,i,o,u){const d=this;let h=0,m;return f;function f(b){return e.enter(i),e.enter(o),e.consume(b),e.exit(o),e.enter(u),x}function x(b){return h>999||b===null||b===91||b===93&&!m||b===94&&!h&&"_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):Ze(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),x):(e.enter("chunkString",{contentType:"string"}),y(b))}function y(b){return b===null||b===91||b===93||Ze(b)||h++>999?(e.exit("chunkString"),x(b)):(e.consume(b),m||(m=!Et(b)),b===92?v:y)}function v(b){return b===91||b===92||b===93?(e.consume(b),h++,y):y(b)}}function eb(e,n,a,i,o,u){let d;return h;function h(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),f(v))}function f(v){return v===d?(e.exit(u),m(d)):v===null?a(v):Ze(v)?(e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),Rt(e,f,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),x(v))}function x(v){return v===d||v===null||Ze(v)?(e.exit("chunkString"),f(v)):(e.consume(v),v===92?y:x)}function y(v){return v===d||v===92?(e.consume(v),x):x(v)}}function To(e,n){let a;return i;function i(o){return Ze(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a=!0,i):Et(o)?Rt(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 Jg.call(i,e,h,a,"definitionLabel","definitionLabelMarker","definitionLabelString")(b)}function h(b){return o=sa(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 rn(b)?To(e,f)(b):f(b)}function f(b){return Zg(e,x,a,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(b)}function x(b){return e.attempt(ak,y,y)(b)}function y(b){return Et(b)?Rt(e,v,"whitespace")(b):v(b)}function v(b){return b===null||Ze(b)?(e.exit("definition"),i.parser.defined.push(o),n(b)):a(b)}}function ik(e,n,a){return i;function i(h){return rn(h)?To(e,o)(h):a(h)}function o(h){return eb(e,u,a,"definitionTitle","definitionTitleMarker","definitionTitleString")(h)}function u(h){return Et(h)?Rt(e,d,"whitespace")(h):d(h)}function d(h){return h===null||Ze(h)?n(h):a(h)}}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 Ze(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"},Fr(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||rn(x)?(e.exit("atxHeadingSequence"),h(x)):a(x)}function h(x){return x===35?(e.enter("atxHeadingSequence"),m(x)):x===null||Ze(x)?(e.exit("atxHeading"),n(x)):Et(x)?Rt(e,h,"whitespace")(x):(e.enter("atxHeadingText"),f(x))}function m(x){return x===35?(e.consume(x),m):(e.exit("atxHeadingSequence"),h(x))}function f(x){return x===null||x===35||rn(x)?(e.exit("atxHeadingText"),h(x)):(e.consume(x),f)}}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"],ey=["pre","script","style","textarea"],hk={concrete:!0,name:"htmlFlow",resolveTo:xk,tokenize:yk},mk={partial:!0,tokenize:bk},pk={partial:!0,tokenize:gk};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 yk(e,n,a){const i=this;let o,u,d,h,m;return f;function f(A){return x(A)}function x(A){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(A),y}function y(A){return A===33?(e.consume(A),v):A===47?(e.consume(A),u=!0,k):A===63?(e.consume(A),o=3,i.interrupt?n:D):nr(A)?(e.consume(A),d=String.fromCharCode(A),N):a(A)}function v(A){return A===45?(e.consume(A),o=2,b):A===91?(e.consume(A),o=5,h=0,j):nr(A)?(e.consume(A),o=4,i.interrupt?n:D):a(A)}function b(A){return A===45?(e.consume(A),i.interrupt?n:D):a(A)}function j(A){const Q="CDATA[";return A===Q.charCodeAt(h++)?(e.consume(A),h===Q.length?i.interrupt?n:L:j):a(A)}function k(A){return nr(A)?(e.consume(A),d=String.fromCharCode(A),N):a(A)}function N(A){if(A===null||A===47||A===62||rn(A)){const Q=A===47,ie=d.toLowerCase();return!Q&&!u&&ey.includes(ie)?(o=1,i.interrupt?n(A):L(A)):fk.includes(d.toLowerCase())?(o=6,Q?(e.consume(A),S):i.interrupt?n(A):L(A)):(o=7,i.interrupt&&!i.parser.lazy[i.now().line]?a(A):u?E(A):_(A))}return A===45||Pn(A)?(e.consume(A),d+=String.fromCharCode(A),N):a(A)}function S(A){return A===62?(e.consume(A),i.interrupt?n:L):a(A)}function E(A){return Et(A)?(e.consume(A),E):T(A)}function _(A){return A===47?(e.consume(A),T):A===58||A===95||nr(A)?(e.consume(A),R):Et(A)?(e.consume(A),_):T(A)}function R(A){return A===45||A===46||A===58||A===95||Pn(A)?(e.consume(A),R):I(A)}function I(A){return A===61?(e.consume(A),B):Et(A)?(e.consume(A),I):_(A)}function B(A){return A===null||A===60||A===61||A===62||A===96?a(A):A===34||A===39?(e.consume(A),m=A,$):Et(A)?(e.consume(A),B):q(A)}function $(A){return A===m?(e.consume(A),m=null,G):A===null||Ze(A)?a(A):(e.consume(A),$)}function q(A){return A===null||A===34||A===39||A===47||A===60||A===61||A===62||A===96||rn(A)?I(A):(e.consume(A),q)}function G(A){return A===47||A===62||Et(A)?_(A):a(A)}function T(A){return A===62?(e.consume(A),H):a(A)}function H(A){return A===null||Ze(A)?L(A):Et(A)?(e.consume(A),H):a(A)}function L(A){return A===45&&o===2?(e.consume(A),X):A===60&&o===1?(e.consume(A),le):A===62&&o===4?(e.consume(A),F):A===63&&o===3?(e.consume(A),D):A===93&&o===5?(e.consume(A),Z):Ze(A)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(mk,W,J)(A)):A===null||Ze(A)?(e.exit("htmlFlowData"),J(A)):(e.consume(A),L)}function J(A){return e.check(pk,ce,W)(A)}function ce(A){return e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),re}function re(A){return A===null||Ze(A)?J(A):(e.enter("htmlFlowData"),L(A))}function X(A){return A===45?(e.consume(A),D):L(A)}function le(A){return A===47?(e.consume(A),d="",ee):L(A)}function ee(A){if(A===62){const Q=d.toLowerCase();return ey.includes(Q)?(e.consume(A),F):L(A)}return nr(A)&&d.length<8?(e.consume(A),d+=String.fromCharCode(A),ee):L(A)}function Z(A){return A===93?(e.consume(A),D):L(A)}function D(A){return A===62?(e.consume(A),F):A===45&&o===2?(e.consume(A),D):L(A)}function F(A){return A===null||Ze(A)?(e.exit("htmlFlowData"),W(A)):(e.consume(A),F)}function W(A){return e.exit("htmlFlow"),n(A)}}function gk(e,n,a){const i=this;return o;function o(d){return Ze(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($o,n,a)}}const vk={name:"htmlText",tokenize:wk};function wk(e,n,a){const i=this;let o,u,d;return h;function h(D){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(D),m}function m(D){return D===33?(e.consume(D),f):D===47?(e.consume(D),I):D===63?(e.consume(D),_):nr(D)?(e.consume(D),q):a(D)}function f(D){return D===45?(e.consume(D),x):D===91?(e.consume(D),u=0,j):nr(D)?(e.consume(D),E):a(D)}function x(D){return D===45?(e.consume(D),b):a(D)}function y(D){return D===null?a(D):D===45?(e.consume(D),v):Ze(D)?(d=y,le(D)):(e.consume(D),y)}function v(D){return D===45?(e.consume(D),b):y(D)}function b(D){return D===62?X(D):D===45?v(D):y(D)}function j(D){const F="CDATA[";return D===F.charCodeAt(u++)?(e.consume(D),u===F.length?k:j):a(D)}function k(D){return D===null?a(D):D===93?(e.consume(D),N):Ze(D)?(d=k,le(D)):(e.consume(D),k)}function N(D){return D===93?(e.consume(D),S):k(D)}function S(D){return D===62?X(D):D===93?(e.consume(D),S):k(D)}function E(D){return D===null||D===62?X(D):Ze(D)?(d=E,le(D)):(e.consume(D),E)}function _(D){return D===null?a(D):D===63?(e.consume(D),R):Ze(D)?(d=_,le(D)):(e.consume(D),_)}function R(D){return D===62?X(D):_(D)}function I(D){return nr(D)?(e.consume(D),B):a(D)}function B(D){return D===45||Pn(D)?(e.consume(D),B):$(D)}function $(D){return Ze(D)?(d=$,le(D)):Et(D)?(e.consume(D),$):X(D)}function q(D){return D===45||Pn(D)?(e.consume(D),q):D===47||D===62||rn(D)?G(D):a(D)}function G(D){return D===47?(e.consume(D),X):D===58||D===95||nr(D)?(e.consume(D),T):Ze(D)?(d=G,le(D)):Et(D)?(e.consume(D),G):X(D)}function T(D){return D===45||D===46||D===58||D===95||Pn(D)?(e.consume(D),T):H(D)}function H(D){return D===61?(e.consume(D),L):Ze(D)?(d=H,le(D)):Et(D)?(e.consume(D),H):G(D)}function L(D){return D===null||D===60||D===61||D===62||D===96?a(D):D===34||D===39?(e.consume(D),o=D,J):Ze(D)?(d=L,le(D)):Et(D)?(e.consume(D),L):(e.consume(D),ce)}function J(D){return D===o?(e.consume(D),o=void 0,re):D===null?a(D):Ze(D)?(d=J,le(D)):(e.consume(D),J)}function ce(D){return D===null||D===34||D===39||D===60||D===61||D===96?a(D):D===47||D===62||rn(D)?G(D):(e.consume(D),ce)}function re(D){return D===47||D===62||rn(D)?G(D):a(D)}function X(D){return D===62?(e.consume(D),e.exit("htmlTextData"),e.exit("htmlText"),n):a(D)}function le(D){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(D),e.exit("lineEnding"),ee}function ee(D){return Et(D)?Rt(e,Z,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):Z(D)}function Z(D){return e.enter("htmlTextData"),d(D)}}const Am={name:"labelEnd",resolveAll:Ck,resolveTo:Nk,tokenize:Ek},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&&Fr(e,0,e.length,a),e}function Nk(e,n){let a=e.length,i=0,o,u,d,h;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}},f={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 h=[["enter",m,n],["enter",f,n]],h=Xr(h,e.slice(u+1,u+i+3)),h=Xr(h,[["enter",x,n]]),h=Xr(h,Xu(n.parser.constructs.insideSpan.null,e.slice(u+i+4,d-3),n)),h=Xr(h,[["exit",x,n],e[d-2],e[d-1],["exit",f,n]]),h=Xr(h,e.slice(d+1)),h=Xr(h,[["exit",m,n]]),Fr(e,u,e.length,h),e}function Ek(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 h;function h(v){return u?u._inactive?y(v):(d=i.parser.defined.includes(sa(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:y)(v):v===91?e.attempt(jk,x,d?f:y)(v):d?x(v):y(v)}function f(v){return e.attempt(Sk,x,y)(v)}function x(v){return n(v)}function y(v){return u._balanced=!0,a(v)}}function Ak(e,n,a){return i;function i(y){return e.enter("resource"),e.enter("resourceMarker"),e.consume(y),e.exit("resourceMarker"),o}function o(y){return rn(y)?To(e,u)(y):u(y)}function u(y){return y===41?x(y):Zg(e,d,h,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(y)}function d(y){return rn(y)?To(e,m)(y):x(y)}function h(y){return a(y)}function m(y){return y===34||y===39||y===40?eb(e,f,a,"resourceTitle","resourceTitleMarker","resourceTitleString")(y):x(y)}function f(y){return rn(y)?To(e,x)(y):x(y)}function x(y){return y===41?(e.enter("resourceMarker"),e.consume(y),e.exit("resourceMarker"),e.exit("resource"),n):a(y)}}function Dk(e,n,a){const i=this;return o;function o(h){return Jg.call(i,e,u,d,"reference","referenceMarker","referenceString")(h)}function u(h){return i.parser.defined.includes(sa(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?n(h):a(h)}function d(h){return a(h)}}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:Am.resolveAll,tokenize:Mk};function Mk(e,n,a){const i=this;return o;function o(h){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(h),e.exit("labelImageMarker"),u}function u(h){return h===91?(e.enter("labelMarker"),e.consume(h),e.exit("labelMarker"),e.exit("labelImage"),d):a(h)}function d(h){return h===94&&"_hiddenFootnoteSupport"in i.parser.constructs?a(h):n(h)}}const Rk={name:"labelStartLink",resolveAll:Am.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 ih={name:"lineEnding",tokenize:_k};function _k(e,n){return a;function a(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),Rt(e,n,"linePrefix")}}const Nu={name:"thematicBreak",tokenize:Bk};function Bk(e,n,a){let i=0,o;return u;function u(f){return e.enter("thematicBreak"),d(f)}function d(f){return o=f,h(f)}function h(f){return f===o?(e.enter("thematicBreakSequence"),m(f)):i>=3&&(f===null||Ze(f))?(e.exit("thematicBreak"),n(f)):a(f)}function m(f){return f===o?(e.consume(f),i++,m):(e.exit("thematicBreakSequence"),Et(f)?Rt(e,h,"whitespace")(f):h(f))}}const mr={continuation:{tokenize:Ik},exit:Uk,name:"list",tokenize:$k},Ok={partial:!0,tokenize:qk},Lk={partial:!0,tokenize:Hk};function $k(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 h;function h(b){const j=i.containerState.type||(b===42||b===43||b===45?"listUnordered":"listOrdered");if(j==="listUnordered"?!i.containerState.marker||b===i.containerState.marker:Vh(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(Nu,a,f)(b):f(b);if(!i.interrupt||b===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),m(b)}return a(b)}function m(b){return Vh(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"),f(b)):a(b)}function f(b){return e.enter("listItemMarker"),e.consume(b),e.exit("listItemMarker"),i.containerState.marker=i.containerState.marker||b,e.check($o,i.interrupt?a:x,e.attempt(Ok,v,y))}function x(b){return i.containerState.initialBlankLine=!0,u++,v(b)}function y(b){return Et(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($o,o,u);function o(h){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,Rt(e,n,"listItemIndent",i.containerState.size+1)(h)}function u(h){return i.containerState.furtherBlankLines||!Et(h)?(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,d(h)):(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,e.attempt(Lk,n,d)(h))}function d(h){return i.containerState._closeFlow=!0,i.interrupt=void 0,Rt(e,e.attempt(mr,n,a),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(h)}}function Hk(e,n,a){const i=this;return Rt(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 Rt(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!Et(u)&&d&&d[1].type==="listItemPrefixWhitespace"?n(u):a(u)}}const ty={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(f){let x=i.events.length,y;for(;x--;)if(i.events[x][1].type!=="lineEnding"&&i.events[x][1].type!=="linePrefix"&&i.events[x][1].type!=="content"){y=i.events[x][1].type==="paragraph";break}return!i.parser.lazy[i.now().line]&&(i.interrupt||y)?(e.enter("setextHeadingLine"),o=f,d(f)):a(f)}function d(f){return e.enter("setextHeadingLineSequence"),h(f)}function h(f){return f===o?(e.consume(f),h):(e.exit("setextHeadingLineSequence"),Et(f)?Rt(e,m,"lineSuffix")(f):m(f))}function m(f){return f===null||Ze(f)?(e.exit("setextHeadingLine"),n(f)):a(f)}}const Wk={tokenize:Vk};function Vk(e){const n=this,a=e.attempt($o,i,e.attempt(this.parser.constructs.flowInitial,o,Rt(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:nb()},Kk=tb("string"),Qk=tb("text");function tb(e){return{resolveAll:nb(e==="text"?Pk:void 0),tokenize:n};function n(a){const i=this,o=this.parser.constructs[e],u=a.attempt(o,d,h);return d;function d(x){return f(x)?u(x):h(x)}function h(x){if(x===null){a.consume(x);return}return a.enter("data"),a.consume(x),m}function m(x){return f(x)?(a.exit("data"),u(x)):(a.consume(x),m)}function f(x){if(x===null)return!0;const y=o[x];let v=-1;if(y)for(;++v<y.length;){const b=y[v];if(!b.previous||b.previous.call(i,i.previous))return!0}return!1}}}function nb(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 Pk(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,h=0,m;for(;u--;){const f=o[u];if(typeof f=="string"){for(d=f.length;f.charCodeAt(d-1)===32;)h++,d--;if(d)break;d=-1}else if(f===-2)m=!0,h++;else if(f!==-1){u++;break}}if(n._contentTypeTextTrailing&&a===e.length&&(h=0),h){const f={type:a===e.length||m||h<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:u?d:i.start._bufferIndex+d,_index:i.start._index+u,line:i.end.line,column:i.end.column-h,offset:i.end.offset-h},end:{...i.end}};i.end={...f.start},i.start.offset===i.end.offset?Object.assign(i,f):(e.splice(a,0,["enter",f,n],["exit",f,n]),a+=2)}a++}return e}const Zk={42:mr,43:mr,45:mr,48:mr,49:mr,50:mr,51:mr,52:mr,53:mr,54:mr,55:mr,56:mr,57:mr,62:Gg},Jk={91:rk},e3={[-2]:lh,[-1]:lh,32:lh},t3={35:ck,42:Nu,45:[ty,Nu],60:hk,61:ty,95:Nu,96:J0,126:J0},n3={38:Qg,92:Kg},r3={[-5]:ih,[-4]:ih,[-3]:ih,33:Fk,38:Qg,42:Gh,60:[R5,vk],91:Rk,92:[sk,Kg],93:Am,95:Gh,96:W5},a3={null:[Gh,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=[],h=[];const m={attempt:$(I),check:$(B),consume:E,enter:_,exit:R,interrupt:$(B,{interrupt:!0})},f={code:null,containerState:{},defineSkip:k,events:[],now:j,parser:e,previous:null,sliceSerialize:v,sliceStream:b,write:y};let x=n.tokenize.call(f,m);return n.resolveAll&&u.push(n),f;function y(H){return d=Xr(d,H),N(),d[d.length-1]!==null?[]:(q(n,0),f.events=Xu(u,f.events,f),f.events)}function v(H,L){return u3(b(H),L)}function b(H){return c3(d,H)}function j(){const{_bufferIndex:H,_index:L,line:J,column:ce,offset:re}=i;return{_bufferIndex:H,_index:L,line:J,column:ce,offset:re}}function k(H){o[H.line]=H.column,T()}function N(){let H;for(;i._index<d.length;){const L=d[i._index];if(typeof L=="string")for(H=i._index,i._bufferIndex<0&&(i._bufferIndex=0);i._index===H&&i._bufferIndex<L.length;)S(L.charCodeAt(i._bufferIndex));else S(L)}}function S(H){x=x(H)}function E(H){Ze(H)?(i.line++,i.column=1,i.offset+=H===-3?2:1,T()):H!==-1&&(i.column++,i.offset++),i._bufferIndex<0?i._index++:(i._bufferIndex++,i._bufferIndex===d[i._index].length&&(i._bufferIndex=-1,i._index++)),f.previous=H}function _(H,L){const J=L||{};return J.type=H,J.start=j(),f.events.push(["enter",J,f]),h.push(J),J}function R(H){const L=h.pop();return L.end=j(),f.events.push(["exit",L,f]),L}function I(H,L){q(H,L.from)}function B(H,L){L.restore()}function $(H,L){return J;function J(ce,re,X){let le,ee,Z,D;return Array.isArray(ce)?W(ce):"tokenize"in ce?W([ce]):F(ce);function F(he){return Ne;function Ne(Ie){const de=Ie!==null&&he[Ie],_e=Ie!==null&&he.null,Ye=[...Array.isArray(de)?de:de?[de]:[],...Array.isArray(_e)?_e:_e?[_e]:[]];return W(Ye)(Ie)}}function W(he){return le=he,ee=0,he.length===0?X:A(he[ee])}function A(he){return Ne;function Ne(Ie){return D=G(),Z=he,he.partial||(f.currentConstruct=he),he.name&&f.parser.constructs.disable.null.includes(he.name)?ie():he.tokenize.call(L?Object.assign(Object.create(f),L):f,m,Q,ie)(Ie)}}function Q(he){return H(Z,D),re}function ie(he){return D.restore(),++ee<le.length?A(le[ee]):X}}}function q(H,L){H.resolveAll&&!u.includes(H)&&u.push(H),H.resolve&&Fr(f.events,L,f.events.length-L,H.resolve(f.events.slice(L),f)),H.resolveTo&&(f.events=H.resolveTo(f.events,f))}function G(){const H=j(),L=f.previous,J=f.currentConstruct,ce=f.events.length,re=Array.from(h);return{from:ce,restore:X};function X(){i=H,f.previous=L,f.currentConstruct=J,f.events.length=ce,h=re,T()}}function T(){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 h=d[0];typeof h=="string"?d[0]=h.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:Wg([s3,...(e||{}).extensions||[]]),content:o(N5),defined:[],document:o(A5),flow:o(Wk),lazy:{},string:o(Kk),text:o(Qk)};return i;function o(u){return d;function d(h){return o3(i,u,h)}}}function f3(e){for(;!Pg(e););return e}const ny=/[\0\t\n\r]/g;function h3(){let e=1,n="",a=!0,i;return o;function o(u,d,h){const m=[];let f,x,y,v,b;for(u=n+(typeof u=="string"?u.toString():new TextDecoder(d||void 0).decode(u)),y=0,n="",a&&(u.charCodeAt(0)===65279&&y++,a=void 0);y<u.length;){if(ny.lastIndex=y,f=ny.exec(u),v=f&&f.index!==void 0?f.index:u.length,b=u.charCodeAt(v),!f){n=u.slice(y);break}if(b===10&&y===v&&i)m.push(-3),i=void 0;else switch(i&&(m.push(-5),i=void 0),y<v&&(m.push(u.slice(y,v)),e+=v-y),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}y=v+1}return h&&(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 Vg(a.slice(u?2:1),u?16:10)}return Em(a)||e}const rb={}.hasOwnProperty;function y3(e,n,a){return n&&typeof n=="object"&&(a=n,n=void 0),g3(a)(f3(d3(a).document().write(h3()(e,n,!0))))}function g3(e){const n={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:u(wt),autolinkProtocol:G,autolinkEmail:G,atxHeading:u(ct),blockQuote:u(_e),characterEscape:G,characterReference:G,codeFenced:u(Ye),codeFencedFenceInfo:d,codeFencedFenceMeta:d,codeIndented:u(Ye,d),codeText:u(ge,d),codeTextData:G,data:G,codeFlowValue:G,definition:u(Je),definitionDestinationString:d,definitionLabelString:d,definitionTitleString:d,emphasis:u(Fe),hardBreakEscape:u(Ke),hardBreakTrailing:u(Ke),htmlFlow:u(ot,d),htmlFlowData:G,htmlText:u(ot,d),htmlTextData:G,image:u(xt),label:d,link:u(wt),listItem:u(dt),listItemValue:v,listOrdered:u(bt,y),listUnordered:u(bt),paragraph:u(gn),reference:A,referenceString:d,resourceDestinationString:d,resourceTitleString:d,setextHeading:u(ct),strong:u(ft),thematicBreak:u(we)},exit:{atxHeading:m(),atxHeadingSequence:I,autolink:m(),autolinkEmail:de,autolinkProtocol:Ie,blockQuote:m(),characterEscapeValue:T,characterReferenceMarkerHexadecimal:ie,characterReferenceMarkerNumeric:ie,characterReferenceValue:he,characterReference:Ne,codeFenced:m(N),codeFencedFence:k,codeFencedFenceInfo:b,codeFencedFenceMeta:j,codeFlowValue:T,codeIndented:m(S),codeText:m(re),codeTextData:T,data:T,definition:m(),definitionDestinationString:R,definitionLabelString:E,definitionTitleString:_,emphasis:m(),hardBreakEscape:m(L),hardBreakTrailing:m(L),htmlFlow:m(J),htmlFlowData:T,htmlText:m(ce),htmlTextData:T,image:m(le),label:Z,labelText:ee,lineEnding:H,link:m(X),listItem:m(),listOrdered:m(),listUnordered:m(),paragraph:m(),referenceString:Q,resourceDestinationString:D,resourceTitleString:F,resource:W,setextHeading:m(q),setextHeadingLineSequence:$,setextHeadingText:B,strong:m(),thematicBreak:m()}};ab(n,(e||{}).mdastExtensions||[]);const a={};return i;function i(U){let ae={type:"root",children:[]};const me={stack:[ae],tokenStack:[],config:n,enter:h,exit:f,buffer:d,resume:x,data:a},Ce=[];let De=-1;for(;++De<U.length;)if(U[De][1].type==="listOrdered"||U[De][1].type==="listUnordered")if(U[De][0]==="enter")Ce.push(De);else{const Se=Ce.pop();De=o(U,Se,De)}for(De=-1;++De<U.length;){const Se=n[U[De][0]];rb.call(Se,U[De][1].type)&&Se[U[De][1].type].call(Object.assign({sliceSerialize:U[De][2].sliceSerialize},me),U[De][1])}if(me.tokenStack.length>0){const Se=me.tokenStack[me.tokenStack.length-1];(Se[1]||ry).call(me,void 0,Se[0])}for(ae.position={start:Tl(U.length>0?U[0][1].start:{line:1,column:1,offset:0}),end:Tl(U.length>0?U[U.length-2][1].end:{line:1,column:1,offset:0})},De=-1;++De<n.transforms.length;)ae=n.transforms[De](ae)||ae;return ae}function o(U,ae,me){let Ce=ae-1,De=-1,Se=!1,Be,$e,Re,ze;for(;++Ce<=me;){const Oe=U[Ce];switch(Oe[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Oe[0]==="enter"?De++:De--,ze=void 0;break}case"lineEndingBlank":{Oe[0]==="enter"&&(Be&&!ze&&!De&&!Re&&(Re=Ce),ze=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:ze=void 0}if(!De&&Oe[0]==="enter"&&Oe[1].type==="listItemPrefix"||De===-1&&Oe[0]==="exit"&&(Oe[1].type==="listUnordered"||Oe[1].type==="listOrdered")){if(Be){let kt=Ce;for($e=void 0;kt--;){const Me=U[kt];if(Me[1].type==="lineEnding"||Me[1].type==="lineEndingBlank"){if(Me[0]==="exit")continue;$e&&(U[$e][1].type="lineEndingBlank",Se=!0),Me[1].type="lineEnding",$e=kt}else if(!(Me[1].type==="linePrefix"||Me[1].type==="blockQuotePrefix"||Me[1].type==="blockQuotePrefixWhitespace"||Me[1].type==="blockQuoteMarker"||Me[1].type==="listItemIndent"))break}Re&&(!$e||Re<$e)&&(Be._spread=!0),Be.end=Object.assign({},$e?U[$e][1].start:Oe[1].end),U.splice($e||Ce,0,["exit",Be,Oe[2]]),Ce++,me++}if(Oe[1].type==="listItemPrefix"){const kt={type:"listItem",_spread:!1,start:Object.assign({},Oe[1].start),end:void 0};Be=kt,U.splice(Ce,0,["enter",kt,Oe[2]]),Ce++,me++,Re=void 0,ze=!0}}}return U[ae][1]._spread=Se,me}function u(U,ae){return me;function me(Ce){h.call(this,U(Ce),Ce),ae&&ae.call(this,Ce)}}function d(){this.stack.push({type:"fragment",children:[]})}function h(U,ae,me){this.stack[this.stack.length-1].children.push(U),this.stack.push(U),this.tokenStack.push([ae,me||void 0]),U.position={start:Tl(ae.start),end:void 0}}function m(U){return ae;function ae(me){U&&U.call(this,me),f.call(this,me)}}function f(U,ae){const me=this.stack.pop(),Ce=this.tokenStack.pop();if(Ce)Ce[0].type!==U.type&&(ae?ae.call(this,U,Ce[0]):(Ce[1]||ry).call(this,U,Ce[0]));else throw new Error("Cannot close `"+U.type+"` ("+Do({start:U.start,end:U.end})+"): it’s not open");me.position.end=Tl(U.end)}function x(){return Nm(this.stack.pop())}function y(){this.data.expectingFirstListItemValue=!0}function v(U){if(this.data.expectingFirstListItemValue){const ae=this.stack[this.stack.length-2];ae.start=Number.parseInt(this.sliceSerialize(U),10),this.data.expectingFirstListItemValue=void 0}}function b(){const U=this.resume(),ae=this.stack[this.stack.length-1];ae.lang=U}function j(){const U=this.resume(),ae=this.stack[this.stack.length-1];ae.meta=U}function k(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function N(){const U=this.resume(),ae=this.stack[this.stack.length-1];ae.value=U.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function S(){const U=this.resume(),ae=this.stack[this.stack.length-1];ae.value=U.replace(/(\r?\n|\r)$/g,"")}function E(U){const ae=this.resume(),me=this.stack[this.stack.length-1];me.label=ae,me.identifier=sa(this.sliceSerialize(U)).toLowerCase()}function _(){const U=this.resume(),ae=this.stack[this.stack.length-1];ae.title=U}function R(){const U=this.resume(),ae=this.stack[this.stack.length-1];ae.url=U}function I(U){const ae=this.stack[this.stack.length-1];if(!ae.depth){const me=this.sliceSerialize(U).length;ae.depth=me}}function B(){this.data.setextHeadingSlurpLineEnding=!0}function $(U){const ae=this.stack[this.stack.length-1];ae.depth=this.sliceSerialize(U).codePointAt(0)===61?1:2}function q(){this.data.setextHeadingSlurpLineEnding=void 0}function G(U){const me=this.stack[this.stack.length-1].children;let Ce=me[me.length-1];(!Ce||Ce.type!=="text")&&(Ce=Wt(),Ce.position={start:Tl(U.start),end:void 0},me.push(Ce)),this.stack.push(Ce)}function T(U){const ae=this.stack.pop();ae.value+=this.sliceSerialize(U),ae.position.end=Tl(U.end)}function H(U){const ae=this.stack[this.stack.length-1];if(this.data.atHardBreak){const me=ae.children[ae.children.length-1];me.position.end=Tl(U.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&n.canContainEols.includes(ae.type)&&(G.call(this,U),T.call(this,U))}function L(){this.data.atHardBreak=!0}function J(){const U=this.resume(),ae=this.stack[this.stack.length-1];ae.value=U}function ce(){const U=this.resume(),ae=this.stack[this.stack.length-1];ae.value=U}function re(){const U=this.resume(),ae=this.stack[this.stack.length-1];ae.value=U}function X(){const U=this.stack[this.stack.length-1];if(this.data.inReference){const ae=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=ae,delete U.url,delete U.title}else delete U.identifier,delete U.label;this.data.referenceType=void 0}function le(){const U=this.stack[this.stack.length-1];if(this.data.inReference){const ae=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=ae,delete U.url,delete U.title}else delete U.identifier,delete U.label;this.data.referenceType=void 0}function ee(U){const ae=this.sliceSerialize(U),me=this.stack[this.stack.length-2];me.label=p3(ae),me.identifier=sa(ae).toLowerCase()}function Z(){const U=this.stack[this.stack.length-1],ae=this.resume(),me=this.stack[this.stack.length-1];if(this.data.inReference=!0,me.type==="link"){const Ce=U.children;me.children=Ce}else me.alt=ae}function D(){const U=this.resume(),ae=this.stack[this.stack.length-1];ae.url=U}function F(){const U=this.resume(),ae=this.stack[this.stack.length-1];ae.title=U}function W(){this.data.inReference=void 0}function A(){this.data.referenceType="collapsed"}function Q(U){const ae=this.resume(),me=this.stack[this.stack.length-1];me.label=ae,me.identifier=sa(this.sliceSerialize(U)).toLowerCase(),this.data.referenceType="full"}function ie(U){this.data.characterReferenceType=U.type}function he(U){const ae=this.sliceSerialize(U),me=this.data.characterReferenceType;let Ce;me?(Ce=Vg(ae,me==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ce=Em(ae);const De=this.stack[this.stack.length-1];De.value+=Ce}function Ne(U){const ae=this.stack.pop();ae.position.end=Tl(U.end)}function Ie(U){T.call(this,U);const ae=this.stack[this.stack.length-1];ae.url=this.sliceSerialize(U)}function de(U){T.call(this,U);const ae=this.stack[this.stack.length-1];ae.url="mailto:"+this.sliceSerialize(U)}function _e(){return{type:"blockquote",children:[]}}function Ye(){return{type:"code",lang:null,meta:null,value:""}}function ge(){return{type:"inlineCode",value:""}}function Je(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Fe(){return{type:"emphasis",children:[]}}function ct(){return{type:"heading",depth:0,children:[]}}function Ke(){return{type:"break"}}function ot(){return{type:"html",value:""}}function xt(){return{type:"image",title:null,url:"",alt:null}}function wt(){return{type:"link",title:null,url:"",children:[]}}function bt(U){return{type:"list",ordered:U.type==="listOrdered",start:null,spread:U._spread,children:[]}}function dt(U){return{type:"listItem",spread:U._spread,checked:null,children:[]}}function gn(){return{type:"paragraph",children:[]}}function ft(){return{type:"strong",children:[]}}function Wt(){return{type:"text",value:""}}function we(){return{type:"thematicBreak"}}}function Tl(e){return{line:e.line,column:e.column,offset:e.offset}}function ab(e,n){let a=-1;for(;++a<n.length;){const i=n[a];Array.isArray(i)?ab(e,i):b3(e,i)}}function b3(e,n){let a;for(a in n)if(rb.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 ry(e,n){throw e?new Error("Cannot close `"+e.type+"` ("+Do({start:e.start,end:e.end})+"): a different token (`"+n.type+"`, "+Do({start:n.start,end:n.end})+") is open"):new Error("Cannot close document, a token (`"+n.type+"`, "+Do({start:n.start,end:n.end})+") is still open")}function v3(e){const n=this;n.parser=a;function a(i){return y3(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 N3(e,n){const a=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",i=String(n.identifier).toUpperCase(),o=ws(i.toLowerCase()),u=e.footnoteOrder.indexOf(i);let d,h=e.footnoteCounts.get(i);h===void 0?(h=0,e.footnoteOrder.push(i),d=e.footnoteOrder.length):d=u+1,h+=1,e.footnoteCounts.set(i,h);const m={type:"element",tagName:"a",properties:{href:"#"+a+"fn-"+o,id:a+"fnref-"+o+(h>1?"-"+h:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(d)}]};e.patch(n,m);const f={type:"element",tagName:"sup",properties:{},children:[m]};return e.patch(n,f),e.applyData(n,f)}function E3(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 lb(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 lb(e,n);const o={src:ws(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:ws(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 lb(e,n);const o={href:ws(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:ws(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):ib(n),u={},d=[];if(typeof n.checked=="boolean"){const x=i[0];let y;x&&x.type==="element"&&x.tagName==="p"?y=x:(y={type:"element",tagName:"p",properties:{},children:[]},i.unshift(y)),y.children.length>0&&y.children.unshift({type:"text",value:" "}),y.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:n.checked,disabled:!0},children:[]}),u.className=["task-list-item"]}let h=-1;for(;++h<i.length;){const x=i[h];(o||h!==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 f={type:"element",tagName:"li",properties:u,children:d};return e.patch(n,f),e.applyData(n,f)}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=ib(a[i])}return n}function ib(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 L3(e,n){const a={type:"root",children:e.wrap(e.all(n))};return e.patch(n,a),e.applyData(n,a)}function $3(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)},h=km(n.children[1]),m=$g(n.children[n.children.length-1]);h&&m&&(d.position={start:h,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,h=d?d.length:n.children.length;let m=-1;const f=[];for(;++m<h;){const y=n.children[m],v={},b=d?d[m]:void 0;b&&(v.align=b);let j={type:"element",tagName:u,properties:v,children:[]};y&&(j.children=e.all(y),e.patch(y,j),j=e.applyData(y,j)),f.push(j)}const x={type:"element",tagName:"tr",properties:{},children:e.wrap(f,!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 ay=9,ly=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(iy(n.slice(o,i.index),o>0,!0),i[0]),o=i.index+i[0].length,i=a.exec(n);return u.push(iy(n.slice(o),o>0,!1)),u.join("")}function iy(e,n,a){let i=0,o=e.length;if(n){let u=e.codePointAt(i);for(;u===ay||u===ly;)i++,u=e.codePointAt(i)}if(a){let u=e.codePointAt(o-1);for(;u===ay||u===ly;)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:N3,heading:E3,html:A3,imageReference:D3,image:T3,inlineCode:F3,linkReference:M3,link:R3,listItem:z3,list:B3,paragraph:O3,root:L3,strong:$3,table:I3,tableCell:U3,tableRow:H3,text:Y3,thematicBreak:X3,toml:su,yaml:su,definition:su,footnoteDefinition:su};function su(){}const sb=-1,Wu=0,Fo=1,Ru=2,Dm=3,Tm=4,Fm=5,Mm=6,ob=7,cb=8,sy=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 Wu:case sb:return a(d,o);case Fo:{const h=a([],o);for(const m of d)h.push(i(m));return h}case Ru:{const h=a({},o);for(const[m,f]of d)h[i(m)]=i(f);return h}case Dm:return a(new Date(d),o);case Tm:{const{source:h,flags:m}=d;return a(new RegExp(h,m),o)}case Fm:{const h=a(new Map,o);for(const[m,f]of d)h.set(i(m),i(f));return h}case Mm:{const h=a(new Set,o);for(const m of d)h.add(i(m));return h}case ob:{const{name:h,message:m}=d;return a(new sy[h](m),o)}case cb: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:h}=new Uint8Array(d);return a(new DataView(h),d)}}return a(new sy[u](d),o)};return i},oy=e=>V3(new Map,e)(0),ds="",{toString:G3}={},{keys:K3}=Object,bo=e=>{const n=typeof e;if(n!=="object"||!e)return[Wu,n];const a=G3.call(e).slice(8,-1);switch(a){case"Array":return[Fo,ds];case"Object":return[Ru,ds];case"Date":return[Dm,ds];case"RegExp":return[Tm,ds];case"Map":return[Fm,ds];case"Set":return[Mm,ds];case"DataView":return[Fo,a]}return a.includes("Array")?[Fo,a]:a.includes("Error")?[ob,a]:[Ru,a]},ou=([e,n])=>e===Wu&&(n==="function"||n==="symbol"),Q3=(e,n,a,i)=>{const o=(d,h)=>{const m=i.push(d)-1;return a.set(h,m),m},u=d=>{if(a.has(d))return a.get(d);let[h,m]=bo(d);switch(h){case Wu:{let x=d;switch(m){case"bigint":h=cb,x=d.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+m);x=null;break;case"undefined":return o([sb],d)}return o([h,x],d)}case Fo:{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=[],y=o([h,x],d);for(const v of d)x.push(u(v));return y}case Ru:{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=[],y=o([h,x],d);for(const v of K3(d))(e||!ou(bo(d[v])))&&x.push([u(v),u(d[v])]);return y}case Dm:return o([h,d.toISOString()],d);case Tm:{const{source:x,flags:y}=d;return o([h,{source:x,flags:y}],d)}case Fm:{const x=[],y=o([h,x],d);for(const[v,b]of d)(e||!(ou(bo(v))||ou(bo(b))))&&x.push([u(v),u(b)]);return y}case Mm:{const x=[],y=o([h,x],d);for(const v of d)(e||!ou(bo(v)))&&x.push(u(v));return y}}const{message:f}=d;return o([h,{name:m,message:f}],d)};return u},cy=(e,{json:n,lossy:a}={})=>{const i=[];return Q3(!(n||a),!!n,new Map,i)(e),i},zu=typeof structuredClone=="function"?(e,n)=>n&&("json"in n||"lossy"in n)?oy(cy(e,n)):structuredClone(e):(e,n)=>oy(cy(e,n));function P3(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||P3,i=e.options.footnoteBackLabel||Z3,o=e.options.footnoteLabel||"Footnotes",u=e.options.footnoteLabelTagName||"h2",d=e.options.footnoteLabelProperties||{className:["sr-only"]},h=[];let m=-1;for(;++m<e.footnoteOrder.length;){const f=e.footnoteById.get(e.footnoteOrder[m]);if(!f)continue;const x=e.all(f),y=String(f.identifier).toUpperCase(),v=ws(y.toLowerCase());let b=0;const j=[],k=e.footnoteCounts.get(y);for(;k!==void 0&&++b<=k;){j.length>0&&j.push({type:"text",value:" "});let E=typeof a=="string"?a:a(m,b);typeof E=="string"&&(E={type:"text",value:E}),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(E)?E:[E]})}const N=x[x.length-1];if(N&&N.type==="element"&&N.tagName==="p"){const E=N.children[N.children.length-1];E&&E.type==="text"?E.value+=" ":N.children.push({type:"text",value:" "}),N.children.push(...j)}else x.push(...j);const S={type:"element",tagName:"li",properties:{id:n+"fn-"+v},children:e.wrap(x,!0)};e.patch(f,S),h.push(S)}if(h.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:u,properties:{...zu(d),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:`
59
- `},{type:"element",tagName:"ol",properties:{},children:e.wrap(h,!0)},{type:"text",value:`
60
- `}]}}const Vu=(function(e){if(e==null)return rj;if(typeof e=="function")return Gu(e);if(typeof e=="object")return Array.isArray(e)?ej(e):tj(e);if(typeof e=="string")return nj(e);throw new Error("Expected function, string, or object as test")});function ej(e){const n=[];let a=-1;for(;++a<e.length;)n[a]=Vu(e[a]);return Gu(i);function i(...o){let u=-1;for(;++u<n.length;)if(n[u].apply(this,o))return!0;return!1}}function tj(e){const n=e;return Gu(a);function a(i){const o=i;let u;for(u in e)if(o[u]!==n[u])return!1;return!0}}function nj(e){return Gu(n);function n(a){return a&&a.type===e}}function Gu(e){return n;function n(a,i,o){return!!(aj(a)&&e.call(this,a,typeof i=="number"?i:void 0,o||void 0))}}function rj(){return!0}function aj(e){return e!==null&&typeof e=="object"&&"type"in e}const ub=[],lj=!0,Kh=!1,ij="skip";function db(e,n,a,i){let o;typeof n=="function"&&typeof a!="function"?(i=a,a=n):o=n;const u=Vu(o),d=i?-1:1;h(e,void 0,[])();function h(m,f,x){const y=m&&typeof m=="object"?m:{};if(typeof y.type=="string"){const b=typeof y.tagName=="string"?y.tagName:typeof y.name=="string"?y.name:void 0;Object.defineProperty(v,"name",{value:"node ("+(m.type+(b?"<"+b+">":""))+")"})}return v;function v(){let b=ub,j,k,N;if((!n||u(m,f,x[x.length-1]||void 0))&&(b=sj(a(m,x)),b[0]===Kh))return b;if("children"in m&&m.children){const S=m;if(S.children&&b[0]!==ij)for(k=(i?S.children.length:-1)+d,N=x.concat(S);k>-1&&k<S.children.length;){const E=S.children[k];if(j=h(E,k,N)(),j[0]===Kh)return j;k=typeof j[1]=="number"?j[1]:k+d}}return b}}}function sj(e){return Array.isArray(e)?e:typeof e=="number"?[lj,e]:e==null?ub:[e]}function Rm(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),db(e,u,h,o);function h(m,f){const x=f[f.length-1],y=x?x.children.indexOf(m):void 0;return d(m,y,x)}}const Qh={}.hasOwnProperty,oj={};function cj(e,n){const a=n||oj,i=new Map,o=new Map,u=new Map,d={...W3,...a.handlers},h={all:f,applyData:dj,definitionById:i,footnoteById:o,footnoteCounts:u,footnoteOrder:[],handlers:d,one:m,options:a,patch:uj,wrap:hj};return Rm(e,function(x){if(x.type==="definition"||x.type==="footnoteDefinition"){const y=x.type==="definition"?i:o,v=String(x.identifier).toUpperCase();y.has(v)||y.set(v,x)}}),h;function m(x,y){const v=x.type,b=h.handlers[v];if(Qh.call(h.handlers,v)&&b)return b(h,x,y);if(h.options.passThrough&&h.options.passThrough.includes(v)){if("children"in x){const{children:k,...N}=x,S=zu(N);return S.children=h.all(x),S}return zu(x)}return(h.options.unknownHandler||fj)(h,x,y)}function f(x){const y=[];if("children"in x){const v=x.children;let b=-1;for(;++b<v.length;){const j=h.one(v[b],x);if(j){if(b&&v[b-1].type==="break"&&(!Array.isArray(j)&&j.type==="text"&&(j.value=uy(j.value)),!Array.isArray(j)&&j.type==="element")){const k=j.children[0];k&&k.type==="text"&&(k.value=uy(k.value))}Array.isArray(j)?y.push(...j):y.push(j)}}}return y}}function uj(e,n){e.position&&(n.position=Zw(e))}function dj(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,zu(u)),"children"in a&&a.children&&o!==null&&o!==void 0&&(a.children=o)}return a}function fj(e,n){const a=n.data||{},i="value"in n&&!(Qh.call(a,"hProperties")||Qh.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 hj(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 uy(e){let n=0,a=e.charCodeAt(n);for(;a===9||a===32;)n++,a=e.charCodeAt(n);return e.slice(n)}function dy(e,n){const a=cj(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 mj(e,n){return e&&"run"in e?async function(a,i){const o=dy(a,{file:i,...n});await e.run(o,i)}:function(a,i){return dy(a,{file:i,...e||n})}}function fy(e){if(e)throw e}var sh,hy;function pj(){if(hy)return sh;hy=1;var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,a=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=function(f){return typeof Array.isArray=="function"?Array.isArray(f):n.call(f)==="[object Array]"},u=function(f){if(!f||n.call(f)!=="[object Object]")return!1;var x=e.call(f,"constructor"),y=f.constructor&&f.constructor.prototype&&e.call(f.constructor.prototype,"isPrototypeOf");if(f.constructor&&!x&&!y)return!1;var v;for(v in f);return typeof v>"u"||e.call(f,v)},d=function(f,x){a&&x.name==="__proto__"?a(f,x.name,{enumerable:!0,configurable:!0,value:x.newValue,writable:!0}):f[x.name]=x.newValue},h=function(f,x){if(x==="__proto__")if(e.call(f,x)){if(i)return i(f,x).value}else return;return f[x]};return sh=function m(){var f,x,y,v,b,j,k=arguments[0],N=1,S=arguments.length,E=!1;for(typeof k=="boolean"&&(E=k,k=arguments[1]||{},N=2),(k==null||typeof k!="object"&&typeof k!="function")&&(k={});N<S;++N)if(f=arguments[N],f!=null)for(x in f)y=h(k,x),v=h(f,x),k!==v&&(E&&v&&(u(v)||(b=o(v)))?(b?(b=!1,j=y&&o(y)?y:[]):j=y&&u(y)?y:{},d(k,{name:x,newValue:m(E,j,v)})):typeof v<"u"&&d(k,{name:x,newValue:v}));return k},sh}var xj=pj();const oh=Dg(xj);function Ph(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 yj(){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);h(null,...o);function h(m,...f){const x=e[++u];let y=-1;if(m){d(m);return}for(;++y<o.length;)(f[y]===null||f[y]===void 0)&&(f[y]=o[y]);o=f,x?gj(x,h)(...f):d(null,...f)}}function i(o){if(typeof o!="function")throw new TypeError("Expected `middelware` to be a function, not "+o);return e.push(o),n}}function gj(e,n){let a;return i;function i(...d){const h=e.length>d.length;let m;h&&d.push(o);try{m=e.apply(this,d)}catch(f){const x=f;if(h&&a)throw x;return o(x)}h||(m&&m.then&&typeof m.then=="function"?m.then(u,o):m instanceof Error?o(m):u(m))}function o(d,...h){a||(a=!0,n(d,...h))}function u(d){o(null,d)}}const ka={basename:bj,dirname:vj,extname:wj,join:kj,sep:"/"};function bj(e,n){if(n!==void 0&&typeof n!="string")throw new TypeError('"ext" argument must be a string');Io(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,h=n.length-1;for(;o--;)if(e.codePointAt(o)===47){if(u){a=o+1;break}}else d<0&&(u=!0,d=o+1),h>-1&&(e.codePointAt(o)===n.codePointAt(h--)?h<0&&(i=o):(h=-1,i=d));return a===i?i=d:i<0&&(i=e.length),e.slice(a,i)}function vj(e){if(Io(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 wj(e){Io(e);let n=e.length,a=-1,i=0,o=-1,u=0,d;for(;n--;){const h=e.codePointAt(n);if(h===47){if(d){i=n+1;break}continue}a<0&&(d=!0,a=n+1),h===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 kj(...e){let n=-1,a;for(;++n<e.length;)Io(e[n]),e[n]&&(a=a===void 0?e[n]:a+"/"+e[n]);return a===void 0?".":jj(a)}function jj(e){Io(e);const n=e.codePointAt(0)===47;let a=Sj(e,!n);return a.length===0&&!n&&(a="."),a.length>0&&e.codePointAt(e.length-1)===47&&(a+="/"),n?"/"+a:a}function Sj(e,n){let a="",i=0,o=-1,u=0,d=-1,h,m;for(;++d<=e.length;){if(d<e.length)h=e.codePointAt(d);else{if(h===47)break;h=47}if(h===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 h===46&&u>-1?u++:u=-1}return a}function Io(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const Cj={cwd:Nj};function Nj(){return"/"}function Zh(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function Ej(e){if(typeof e=="string")e=new URL(e);else if(!Zh(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 Aj(e)}function Aj(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 ch=["history","path","basename","stem","extname","dirname"];class fb{constructor(n){let a;n?Zh(n)?a={path:n}:typeof n=="string"||Dj(n)?a={value:n}:a=n:a={},this.cwd="cwd"in a?"":Cj.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let i=-1;for(;++i<ch.length;){const u=ch[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)ch.includes(o)||(this[o]=a[o])}get basename(){return typeof this.path=="string"?ka.basename(this.path):void 0}set basename(n){dh(n,"basename"),uh(n,"basename"),this.path=ka.join(this.dirname||"",n)}get dirname(){return typeof this.path=="string"?ka.dirname(this.path):void 0}set dirname(n){my(this.basename,"dirname"),this.path=ka.join(n||"",this.basename)}get extname(){return typeof this.path=="string"?ka.extname(this.path):void 0}set extname(n){if(uh(n,"extname"),my(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=ka.join(this.dirname,this.stem+(n||""))}get path(){return this.history[this.history.length-1]}set path(n){Zh(n)&&(n=Ej(n)),dh(n,"path"),this.path!==n&&this.history.push(n)}get stem(){return typeof this.path=="string"?ka.basename(this.path,this.extname):void 0}set stem(n){dh(n,"stem"),uh(n,"stem"),this.path=ka.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 Zn(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 uh(e,n){if(e&&e.includes(ka.sep))throw new Error("`"+n+"` cannot be a path: did not expect `"+ka.sep+"`")}function dh(e,n){if(!e)throw new Error("`"+n+"` cannot be empty")}function my(e,n){if(!e)throw new Error("Setting `"+n+"` requires `path` to be set too")}function Dj(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const Tj=(function(e){const i=this.constructor.prototype,o=i[e],u=function(){return o.apply(u,arguments)};return Object.setPrototypeOf(u,i),u}),Fj={}.hasOwnProperty;class zm extends Tj{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=yj()}copy(){const n=new zm;let a=-1;for(;++a<this.attachers.length;){const i=this.attachers[a];n.use(...i)}return n.data(oh(!0,{},this.namespace)),n}data(n,a){return typeof n=="string"?arguments.length===2?(mh("data",this.frozen),this.namespace[n]=a,this):Fj.call(this.namespace,n)&&this.namespace[n]||void 0:n?(mh("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=cu(n),i=this.parser||this.Parser;return fh("parse",i),i(String(a),a)}process(n,a){const i=this;return this.freeze(),fh("process",this.parser||this.Parser),hh("process",this.compiler||this.Compiler),a?o(void 0,a):new Promise(o);function o(u,d){const h=cu(n),m=i.parse(h);i.run(m,h,function(x,y,v){if(x||!y||!v)return f(x);const b=y,j=i.stringify(b,v);zj(j)?v.value=j:v.result=j,f(x,v)});function f(x,y){x||!y?d(x):u?u(y):a(void 0,y)}}}processSync(n){let a=!1,i;return this.freeze(),fh("processSync",this.parser||this.Parser),hh("processSync",this.compiler||this.Compiler),this.process(n,o),xy("processSync","process",a),i;function o(u,d){a=!0,fy(u),i=d}}run(n,a,i){py(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,h){const m=cu(a);o.run(n,m,f);function f(x,y,v){const b=y||n;x?h(x):d?d(b):i(void 0,b,v)}}}runSync(n,a){let i=!1,o;return this.run(n,a,u),xy("runSync","run",i),o;function u(d,h){fy(d),o=h,i=!0}}stringify(n,a){this.freeze();const i=cu(a),o=this.compiler||this.Compiler;return hh("stringify",o),py(n),o(n,i)}use(n,...a){const i=this.attachers,o=this.namespace;if(mh("use",this.frozen),n!=null)if(typeof n=="function")m(n,a);else if(typeof n=="object")Array.isArray(n)?h(n):d(n);else throw new TypeError("Expected usable value, not `"+n+"`");return this;function u(f){if(typeof f=="function")m(f,[]);else if(typeof f=="object")if(Array.isArray(f)){const[x,...y]=f;m(x,y)}else d(f);else throw new TypeError("Expected usable value, not `"+f+"`")}function d(f){if(!("plugins"in f)&&!("settings"in f))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");h(f.plugins),f.settings&&(o.settings=oh(!0,o.settings,f.settings))}function h(f){let x=-1;if(f!=null)if(Array.isArray(f))for(;++x<f.length;){const y=f[x];u(y)}else throw new TypeError("Expected a list of plugins, not `"+f+"`")}function m(f,x){let y=-1,v=-1;for(;++y<i.length;)if(i[y][0]===f){v=y;break}if(v===-1)i.push([f,...x]);else if(x.length>0){let[b,...j]=x;const k=i[v][1];Ph(k)&&Ph(b)&&(b=oh(!0,k,b)),i[v]=[f,b,...j]}}}}const Mj=new zm().freeze();function fh(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function hh(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function mh(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 py(e){if(!Ph(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function xy(e,n,a){if(!a)throw new Error("`"+e+"` finished async. Use `"+n+"` instead")}function cu(e){return Rj(e)?e:new fb(e)}function Rj(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function zj(e){return typeof e=="string"||_j(e)}function _j(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const Bj="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",yy=[],gy={allowDangerousHtml:!0},Oj=/^(https?|ircs?|mailto|xmpp)$/i,Lj=[{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=$j(e),a=Ij(e);return Hj(n.runSync(n.parse(a),a),e)}function $j(e){const n=e.rehypePlugins||yy,a=e.remarkPlugins||yy,i=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...gy}:gy;return Mj().use(v3).use(a).use(mj,i).use(n)}function Ij(e){const n=e.children||"",a=new fb;return typeof n=="string"&&(a.value=n),a}function Hj(e,n){const a=n.allowedElements,i=n.allowElement,o=n.components,u=n.disallowedElements,d=n.skipHtml,h=n.unwrapDisallowed,m=n.urlTransform||Uj;for(const x of Lj)Object.hasOwn(n,x.from)&&(""+x.from+(x.to?"use `"+x.to+"` instead":"remove it")+Bj+x.id,void 0);return Rm(e,f),r5(e,{Fragment:l.Fragment,components:o,ignoreInvalidStyle:!0,jsx:l.jsx,jsxs:l.jsxs,passKeys:!0,passNode:!0});function f(x,y,v){if(x.type==="raw"&&v&&typeof y=="number")return d?v.children.splice(y,1):v.children[y]={type:"text",value:x.value},y;if(x.type==="element"){let b;for(b in ah)if(Object.hasOwn(ah,b)&&Object.hasOwn(x.properties,b)){const j=x.properties[b],k=ah[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 y=="number"&&(b=!i(x,y,v)),b&&v&&typeof y=="number")return h&&x.children?v.children.splice(y,1,...x.children):v.children.splice(y,1),y}}}function Uj(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||Oj.test(e.slice(0,n))?e:""}function by(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 qj(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function Yj(e,n,a){const o=Vu((a||{}).ignore||[]),u=Xj(n);let d=-1;for(;++d<u.length;)db(e,"text",h);function h(f,x){let y=-1,v;for(;++y<x.length;){const b=x[y],j=v?v.children:void 0;if(o(b,j?j.indexOf(b):void 0,v))return;v=b}if(v)return m(f,x)}function m(f,x){const y=x[x.length-1],v=u[d][0],b=u[d][1];let j=0;const N=y.children.indexOf(f);let S=!1,E=[];v.lastIndex=0;let _=v.exec(f.value);for(;_;){const R=_.index,I={index:_.index,input:_.input,stack:[...x,f]};let B=b(..._,I);if(typeof B=="string"&&(B=B.length>0?{type:"text",value:B}:void 0),B===!1?v.lastIndex=R+1:(j!==R&&E.push({type:"text",value:f.value.slice(j,R)}),Array.isArray(B)?E.push(...B):B&&E.push(B),j=R+_[0].length,S=!0),!v.global)break;_=v.exec(f.value)}return S?(j<f.value.length&&E.push({type:"text",value:f.value.slice(j)}),y.children.splice(N,1,...E)):E=[f],N+E.length}}function Xj(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([Wj(o[0]),Vj(o[1])])}return n}function Wj(e){return typeof e=="string"?new RegExp(qj(e),"g"):e}function Vj(e){return typeof e=="function"?e:function(){return e}}const ph="phrasing",xh=["autolink","link","image","label"];function Gj(){return{transforms:[t4],enter:{literalAutolink:Qj,literalAutolinkEmail:yh,literalAutolinkHttp:yh,literalAutolinkWww:yh},exit:{literalAutolink:e4,literalAutolinkEmail:Jj,literalAutolinkHttp:Pj,literalAutolinkWww:Zj}}}function Kj(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:ph,notInConstruct:xh},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:ph,notInConstruct:xh},{character:":",before:"[ps]",after:"\\/",inConstruct:ph,notInConstruct:xh}]}}function Qj(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function yh(e){this.config.enter.autolinkProtocol.call(this,e)}function Pj(e){this.config.exit.autolinkProtocol.call(this,e)}function Zj(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 Jj(e){this.config.exit.autolinkEmail.call(this,e)}function e4(e){this.exit(e)}function t4(e){Yj(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,n4],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),r4]],{ignore:["link","linkReference"]})}function n4(e,n,a,i,o){let u="";if(!hb(o)||(/^w/i.test(n)&&(a=n+a,n="",u="http://"),!a4(a)))return!1;const d=l4(a+i);if(!d[0])return!1;const h={type:"link",title:null,url:u+n+d[0],children:[{type:"text",value:n+d[0]}]};return d[1]?[h,{type:"text",value:d[1]}]:h}function r4(e,n,a,i){return!hb(i,!0)||/[-\d_]$/.test(a)?!1:{type:"link",title:null,url:"mailto:"+n+"@"+a,children:[{type:"text",value:n+"@"+a}]}}function a4(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 l4(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=by(e,"(");let u=by(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 hb(e,n){const a=e.input.charCodeAt(e.index-1);return(e.index===0||ki(a)||Yu(a))&&(!n||a!==47)}mb.peek=m4;function i4(){this.buffer()}function s4(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function o4(){this.buffer()}function c4(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function u4(e){const n=this.resume(),a=this.stack[this.stack.length-1];a.type,a.identifier=sa(this.sliceSerialize(e)).toLowerCase(),a.label=n}function d4(e){this.exit(e)}function f4(e){const n=this.resume(),a=this.stack[this.stack.length-1];a.type,a.identifier=sa(this.sliceSerialize(e)).toLowerCase(),a.label=n}function h4(e){this.exit(e)}function m4(){return"["}function mb(e,n,a,i){const o=a.createTracker(i);let u=o.move("[^");const d=a.enter("footnoteReference"),h=a.enter("reference");return u+=o.move(a.safe(a.associationId(e),{after:"]",before:u})),h(),d(),u+=o.move("]"),u}function p4(){return{enter:{gfmFootnoteCallString:i4,gfmFootnoteCall:s4,gfmFootnoteDefinitionLabelString:o4,gfmFootnoteDefinition:c4},exit:{gfmFootnoteCallString:u4,gfmFootnoteCall:d4,gfmFootnoteDefinitionLabelString:f4,gfmFootnoteDefinition:h4}}}function x4(e){let n=!1;return e&&e.firstLineBlank&&(n=!0),{handlers:{footnoteDefinition:a,footnoteReference:mb},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function a(i,o,u,d){const h=u.createTracker(d);let m=h.move("[^");const f=u.enter("footnoteDefinition"),x=u.enter("label");return m+=h.move(u.safe(u.associationId(i),{before:m,after:"]"})),x(),m+=h.move("]:"),i.children&&i.children.length>0&&(h.shift(4),m+=h.move((n?`
65
- `:" ")+u.indentLines(u.containerFlow(i,h.current()),n?pb:y4))),f(),m}}function y4(e,n,a){return n===0?e:pb(e,n,a)}function pb(e,n,a){return(a?"":" ")+e}const g4=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];xb.peek=j4;function b4(){return{canContainEols:["delete"],enter:{strikethrough:w4},exit:{strikethrough:k4}}}function v4(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:g4}],handlers:{delete:xb}}}function w4(e){this.enter({type:"delete",children:[]},e)}function k4(e){this.exit(e)}function xb(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 j4(){return"~"}function S4(e){return e.length}function C4(e,n){const a=n||{},i=(a.align||[]).concat(),o=a.stringLength||S4,u=[],d=[],h=[],m=[];let f=0,x=-1;for(;++x<e.length;){const k=[],N=[];let S=-1;for(e[x].length>f&&(f=e[x].length);++S<e[x].length;){const E=N4(e[x][S]);if(a.alignDelimiters!==!1){const _=o(E);N[S]=_,(m[S]===void 0||_>m[S])&&(m[S]=_)}k.push(E)}d[x]=k,h[x]=N}let y=-1;if(typeof i=="object"&&"length"in i)for(;++y<f;)u[y]=vy(i[y]);else{const k=vy(i);for(;++y<f;)u[y]=k}y=-1;const v=[],b=[];for(;++y<f;){const k=u[y];let N="",S="";k===99?(N=":",S=":"):k===108?N=":":k===114&&(S=":");let E=a.alignDelimiters===!1?1:Math.max(1,m[y]-N.length-S.length);const _=N+"-".repeat(E)+S;a.alignDelimiters!==!1&&(E=N.length+E+S.length,E>m[y]&&(m[y]=E),b[y]=E),v[y]=_}d.splice(1,0,v),h.splice(1,0,b),x=-1;const j=[];for(;++x<d.length;){const k=d[x],N=h[x];y=-1;const S=[];for(;++y<f;){const E=k[y]||"";let _="",R="";if(a.alignDelimiters!==!1){const I=m[y]-(N[y]||0),B=u[y];B===114?_=" ".repeat(I):B===99?I%2?(_=" ".repeat(I/2+.5),R=" ".repeat(I/2-.5)):(_=" ".repeat(I/2),R=_):R=" ".repeat(I)}a.delimiterStart!==!1&&!y&&S.push("|"),a.padding!==!1&&!(a.alignDelimiters===!1&&E==="")&&(a.delimiterStart!==!1||y)&&S.push(" "),a.alignDelimiters!==!1&&S.push(_),S.push(E),a.alignDelimiters!==!1&&S.push(R),a.padding!==!1&&S.push(" "),(a.delimiterEnd!==!1||y!==f-1)&&S.push("|")}j.push(a.delimiterEnd===!1?S.join("").replace(/ +$/,""):S.join(""))}return j.join(`
66
- `)}function N4(e){return e==null?"":String(e)}function vy(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 E4(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()),A4);return o(),d}function A4(e,n,a){return">"+(a?"":" ")+e}function D4(e,n){return wy(e,n.inConstruct,!0)&&!wy(e,n.notInConstruct,!1)}function wy(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 ky(e,n,a,i){let o=-1;for(;++o<a.unsafe.length;)if(a.unsafe[o].character===`
67
- `&&D4(a.stack,a.unsafe[o]))return/[ \t]/.test(i.before)?"":" ";return`\\
68
- `}function T4(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 F4(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 M4(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 R4(e,n,a,i){const o=M4(a),u=e.value||"",d=o==="`"?"GraveAccent":"Tilde";if(F4(e,a)){const y=a.enter("codeIndented"),v=a.indentLines(u,z4);return y(),v}const h=a.createTracker(i),m=o.repeat(Math.max(T4(u,o)+1,3)),f=a.enter("codeFenced");let x=h.move(m);if(e.lang){const y=a.enter(`codeFencedLang${d}`);x+=h.move(a.safe(e.lang,{before:x,after:" ",encode:["`"],...h.current()})),y()}if(e.lang&&e.meta){const y=a.enter(`codeFencedMeta${d}`);x+=h.move(" "),x+=h.move(a.safe(e.meta,{before:x,after:`
69
- `,encode:["`"],...h.current()})),y()}return x+=h.move(`
70
- `),u&&(x+=h.move(u+`
71
- `)),x+=h.move(m),f(),x}function z4(e,n,a){return(a?"":" ")+e}function Bm(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 _4(e,n,a,i){const o=Bm(a),u=o==='"'?"Quote":"Apostrophe",d=a.enter("definition");let h=a.enter("label");const m=a.createTracker(i);let f=m.move("[");return f+=m.move(a.safe(a.associationId(e),{before:f,after:"]",...m.current()})),f+=m.move("]: "),h(),!e.url||/[\0- \u007F]/.test(e.url)?(h=a.enter("destinationLiteral"),f+=m.move("<"),f+=m.move(a.safe(e.url,{before:f,after:">",...m.current()})),f+=m.move(">")):(h=a.enter("destinationRaw"),f+=m.move(a.safe(e.url,{before:f,after:e.title?" ":`
72
- `,...m.current()}))),h(),e.title&&(h=a.enter(`title${u}`),f+=m.move(" "+o),f+=m.move(a.safe(e.title,{before:f,after:o,...m.current()})),f+=m.move(o),h()),d(),f}function B4(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 Ro(e){return"&#x"+e.toString(16).toUpperCase()+";"}function _u(e,n,a){const i=ps(e),o=ps(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}}yb.peek=O4;function yb(e,n,a,i){const o=B4(a),u=a.enter("emphasis"),d=a.createTracker(i),h=d.move(o);let m=d.move(a.containerPhrasing(e,{after:o,before:h,...d.current()}));const f=m.charCodeAt(0),x=_u(i.before.charCodeAt(i.before.length-1),f,o);x.inside&&(m=Ro(f)+m.slice(1));const y=m.charCodeAt(m.length-1),v=_u(i.after.charCodeAt(0),y,o);v.inside&&(m=m.slice(0,-1)+Ro(y));const b=d.move(o);return u(),a.attentionEncodeSurroundingInfo={after:v.outside,before:x.outside},h+m+b}function O4(e,n,a){return a.options.emphasis||"*"}function L4(e,n){let a=!1;return Rm(e,function(i){if("value"in i&&/\r?\n|\r/.test(i.value)||i.type==="break")return a=!0,Kh}),!!((!e.depth||e.depth<3)&&Nm(e)&&(n.options.setext||a))}function $4(e,n,a,i){const o=Math.max(Math.min(6,e.depth||1),1),u=a.createTracker(i);if(L4(e,a)){const x=a.enter("headingSetext"),y=a.enter("phrasing"),v=a.containerPhrasing(e,{...u.current(),before:`
73
- `,after:`
74
- `});return y(),x(),v+`
75
- `+(o===1?"=":"-").repeat(v.length-(Math.max(v.lastIndexOf("\r"),v.lastIndexOf(`
76
- `))+1))}const d="#".repeat(o),h=a.enter("headingAtx"),m=a.enter("phrasing");u.move(d+" ");let f=a.containerPhrasing(e,{before:"# ",after:`
77
- `,...u.current()});return/^[\t ]/.test(f)&&(f=Ro(f.charCodeAt(0))+f.slice(1)),f=f?d+" "+f:d,a.options.closeAtx&&(f+=" "+d),m(),h(),f}gb.peek=I4;function gb(e){return e.value||""}function I4(){return"<"}bb.peek=H4;function bb(e,n,a,i){const o=Bm(a),u=o==='"'?"Quote":"Apostrophe",d=a.enter("image");let h=a.enter("label");const m=a.createTracker(i);let f=m.move("![");return f+=m.move(a.safe(e.alt,{before:f,after:"]",...m.current()})),f+=m.move("]("),h(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(h=a.enter("destinationLiteral"),f+=m.move("<"),f+=m.move(a.safe(e.url,{before:f,after:">",...m.current()})),f+=m.move(">")):(h=a.enter("destinationRaw"),f+=m.move(a.safe(e.url,{before:f,after:e.title?" ":")",...m.current()}))),h(),e.title&&(h=a.enter(`title${u}`),f+=m.move(" "+o),f+=m.move(a.safe(e.title,{before:f,after:o,...m.current()})),f+=m.move(o),h()),f+=m.move(")"),d(),f}function H4(){return"!"}vb.peek=U4;function vb(e,n,a,i){const o=e.referenceType,u=a.enter("imageReference");let d=a.enter("label");const h=a.createTracker(i);let m=h.move("![");const f=a.safe(e.alt,{before:m,after:"]",...h.current()});m+=h.move(f+"]["),d();const x=a.stack;a.stack=[],d=a.enter("reference");const y=a.safe(a.associationId(e),{before:m,after:"]",...h.current()});return d(),a.stack=x,u(),o==="full"||!f||f!==y?m+=h.move(y+"]"):o==="shortcut"?m=m.slice(0,-1):m+=h.move("]"),m}function U4(){return"!"}wb.peek=q4;function wb(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],h=a.compilePattern(d);let m;if(d.atBreak)for(;m=h.exec(i);){let f=m.index;i.charCodeAt(f)===10&&i.charCodeAt(f-1)===13&&f--,i=i.slice(0,f)+" "+i.slice(m.index+1)}}return o+i+o}function q4(){return"`"}function kb(e,n){const a=Nm(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))}jb.peek=Y4;function jb(e,n,a,i){const o=Bm(a),u=o==='"'?"Quote":"Apostrophe",d=a.createTracker(i);let h,m;if(kb(e,a)){const x=a.stack;a.stack=[],h=a.enter("autolink");let y=d.move("<");return y+=d.move(a.containerPhrasing(e,{before:y,after:">",...d.current()})),y+=d.move(">"),h(),a.stack=x,y}h=a.enter("link"),m=a.enter("label");let f=d.move("[");return f+=d.move(a.containerPhrasing(e,{before:f,after:"](",...d.current()})),f+=d.move("]("),m(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(m=a.enter("destinationLiteral"),f+=d.move("<"),f+=d.move(a.safe(e.url,{before:f,after:">",...d.current()})),f+=d.move(">")):(m=a.enter("destinationRaw"),f+=d.move(a.safe(e.url,{before:f,after:e.title?" ":")",...d.current()}))),m(),e.title&&(m=a.enter(`title${u}`),f+=d.move(" "+o),f+=d.move(a.safe(e.title,{before:f,after:o,...d.current()})),f+=d.move(o),m()),f+=d.move(")"),h(),f}function Y4(e,n,a){return kb(e,a)?"<":"["}Sb.peek=X4;function Sb(e,n,a,i){const o=e.referenceType,u=a.enter("linkReference");let d=a.enter("label");const h=a.createTracker(i);let m=h.move("[");const f=a.containerPhrasing(e,{before:m,after:"]",...h.current()});m+=h.move(f+"]["),d();const x=a.stack;a.stack=[],d=a.enter("reference");const y=a.safe(a.associationId(e),{before:m,after:"]",...h.current()});return d(),a.stack=x,u(),o==="full"||!f||f!==y?m+=h.move(y+"]"):o==="shortcut"?m=m.slice(0,-1):m+=h.move("]"),m}function X4(){return"["}function Om(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 W4(e){const n=Om(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 V4(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 Cb(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 G4(e,n,a,i){const o=a.enter("list"),u=a.bulletCurrent;let d=e.ordered?V4(a):Om(a);const h=e.ordered?d==="."?")":".":W4(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),Cb(a)===d&&x){let y=-1;for(;++y<e.children.length;){const v=e.children[y];if(v&&v.type==="listItem"&&v.children&&v.children[0]&&v.children[0].type==="thematicBreak"){m=!0;break}}}}m&&(d=h),a.bulletCurrent=d;const f=a.containerFlow(e,i);return a.bulletLastUsed=d,a.bulletCurrent=u,o(),f}function K4(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 Q4(e,n,a,i){const o=K4(a);let u=a.bulletCurrent||Om(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 h=a.createTracker(i);h.move(u+" ".repeat(d-u.length)),h.shift(d);const m=a.enter("listItem"),f=a.indentLines(a.containerFlow(e,h.current()),x);return m(),f;function x(y,v,b){return v?(b?"":" ".repeat(d))+y:(b?u:u+" ".repeat(d-u.length))+y}}function P4(e,n,a,i){const o=a.enter("paragraph"),u=a.enter("phrasing"),d=a.containerPhrasing(e,i);return u(),o(),d}const Z4=Vu(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function J4(e,n,a,i){return(e.children.some(function(d){return Z4(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}Nb.peek=tS;function Nb(e,n,a,i){const o=eS(a),u=a.enter("strong"),d=a.createTracker(i),h=d.move(o+o);let m=d.move(a.containerPhrasing(e,{after:o,before:h,...d.current()}));const f=m.charCodeAt(0),x=_u(i.before.charCodeAt(i.before.length-1),f,o);x.inside&&(m=Ro(f)+m.slice(1));const y=m.charCodeAt(m.length-1),v=_u(i.after.charCodeAt(0),y,o);v.inside&&(m=m.slice(0,-1)+Ro(y));const b=d.move(o+o);return u(),a.attentionEncodeSurroundingInfo={after:v.outside,before:x.outside},h+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=(Cb(a)+(a.options.ruleSpaces?" ":"")).repeat(rS(a));return a.options.ruleSpaces?i.slice(0,-1):i}const Eb={blockquote:E4,break:ky,code:R4,definition:_4,emphasis:yb,hardBreak:ky,heading:$4,html:gb,image:bb,imageReference:vb,inlineCode:wb,link:jb,linkReference:Sb,list:G4,listItem:Q4,paragraph:P4,root:J4,strong:Nb,text:nS,thematicBreak:aS};function lS(){return{enter:{table:iS,tableData:jy,tableHeader:jy,tableRow:oS},exit:{codeText:cS,table:sS,tableData:gh,tableHeader:gh,tableRow:gh}}}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 gh(e){this.exit(e)}function jy(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:h}};function d(b,j,k,N){return f(x(b,k,N),b.align)}function h(b,j,k,N){const S=y(b,k,N),E=f([S]);return E.slice(0,E.indexOf(`
79
- `))}function m(b,j,k,N){const S=k.enter("tableCell"),E=k.enter("phrasing"),_=k.containerPhrasing(b,{...N,before:u,after:u});return E(),S(),_}function f(b,j){return C4(b,{align:j,alignDelimiters:i,padding:a,stringLength:o})}function x(b,j,k){const N=b.children;let S=-1;const E=[],_=j.enter("table");for(;++S<N.length;)E[S]=y(N[S],j,k);return _(),E}function y(b,j,k){const N=b.children;let S=-1;const E=[],_=j.enter("tableRow");for(;++S<N.length;)E[S]=m(N[S],b,j,k);return _(),E}function v(b,j,k){let N=Eb.inlineCode(b,j,k);return k.stack.includes("tableCell")&&(N=N.replace(/\|/g,"\\$&")),N}}function fS(){return{exit:{taskListCheckValueChecked:Sy,taskListCheckValueUnchecked:Sy,paragraph:mS}}}function hS(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:pS}}}function Sy(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 h=o[u];if(h.type==="paragraph"){d=h;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":" ")+"] ",h=a.createTracker(i);u&&h.move(d);let m=Eb.listItem(e,n,a,{...i,...h.current()});return u&&(m=m.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,f)),m;function f(x){return x+d}}function xS(){return[Gj(),p4(),b4(),lS(),fS()]}function yS(e){return{extensions:[Kj(),x4(e),v4(),dS(e),hS()]}}const gS={tokenize:SS,partial:!0},Ab={tokenize:CS,partial:!0},Db={tokenize:NS,partial:!0},Tb={tokenize:ES,partial:!0},bS={tokenize:AS,partial:!0},Fb={name:"wwwAutolink",tokenize:kS,previous:Rb},Mb={name:"protocolAutolink",tokenize:jS,previous:zb},el={name:"emailAutolink",tokenize:wS,previous:_b},Ea={};function vS(){return{text:Ea}}let fi=48;for(;fi<123;)Ea[fi]=el,fi++,fi===58?fi=65:fi===91&&(fi=97);Ea[43]=el;Ea[45]=el;Ea[46]=el;Ea[95]=el;Ea[72]=[el,Mb];Ea[104]=[el,Mb];Ea[87]=[el,Fb];Ea[119]=[el,Fb];function wS(e,n,a){const i=this;let o,u;return d;function d(y){return!Jh(y)||!_b.call(i,i.previous)||Lm(i.events)?a(y):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),h(y))}function h(y){return Jh(y)?(e.consume(y),h):y===64?(e.consume(y),m):a(y)}function m(y){return y===46?e.check(bS,x,f)(y):y===45||y===95||Pn(y)?(u=!0,e.consume(y),m):x(y)}function f(y){return e.consume(y),o=!0,m}function x(y){return u&&o&&nr(i.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),n(y)):a(y)}}function kS(e,n,a){const i=this;return o;function o(d){return d!==87&&d!==119||!Rb.call(i,i.previous)||Lm(i.events)?a(d):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(gS,e.attempt(Ab,e.attempt(Db,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(y){return(y===72||y===104)&&zb.call(i,i.previous)&&!Lm(i.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(y),e.consume(y),h):a(y)}function h(y){if(nr(y)&&o.length<5)return o+=String.fromCodePoint(y),e.consume(y),h;if(y===58){const v=o.toLowerCase();if(v==="http"||v==="https")return e.consume(y),m}return a(y)}function m(y){return y===47?(e.consume(y),u?f:(u=!0,m)):a(y)}function f(y){return y===null||Mu(y)||rn(y)||ki(y)||Yu(y)?a(y):e.attempt(Ab,e.attempt(Db,x),a)(y)}function x(y){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),n(y)}}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(f){return f===46||f===95?e.check(Tb,m,h)(f):f===null||rn(f)||ki(f)||f!==45&&Yu(f)?m(f):(u=!0,e.consume(f),d)}function h(f){return f===95?i=!0:(o=i,i=void 0),e.consume(f),d}function m(f){return o||i||!u?a(f):n(f)}}function NS(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(Tb,n,u)(d):d===null||rn(d)||ki(d)?n(d):(e.consume(d),o)}function u(d){return d===41&&i++,e.consume(d),o}}function ES(e,n,a){return i;function i(h){return h===33||h===34||h===39||h===41||h===42||h===44||h===46||h===58||h===59||h===63||h===95||h===126?(e.consume(h),i):h===38?(e.consume(h),u):h===93?(e.consume(h),o):h===60||h===null||rn(h)||ki(h)?n(h):a(h)}function o(h){return h===null||h===40||h===91||rn(h)||ki(h)?n(h):i(h)}function u(h){return nr(h)?d(h):a(h)}function d(h){return h===59?(e.consume(h),i):nr(h)?(e.consume(h),d):a(h)}}function AS(e,n,a){return i;function i(u){return e.consume(u),o}function o(u){return Pn(u)?a(u):n(u)}}function Rb(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||rn(e)}function zb(e){return!nr(e)}function _b(e){return!(e===47||Jh(e))}function Jh(e){return e===43||e===45||e===46||e===95||Pn(e)}function Lm(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 h;function h(m){if(!d||!d._balanced)return a(m);const f=sa(i.sliceSerialize({start:d.end,end:i.now()}));return f.codePointAt(0)!==94||!u.includes(f.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)},h=[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,...h),e}function RS(e,n,a){const i=this,o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let u=0,d;return h;function h(y){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(y),e.exit("gfmFootnoteCallLabelMarker"),m}function m(y){return y!==94?a(y):(e.enter("gfmFootnoteCallMarker"),e.consume(y),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",f)}function f(y){if(u>999||y===93&&!d||y===null||y===91||rn(y))return a(y);if(y===93){e.exit("chunkString");const v=e.exit("gfmFootnoteCallString");return o.includes(sa(i.sliceSerialize(v)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(y),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),n):a(y)}return rn(y)||(d=!0),u++,e.consume(y),y===92?x:f}function x(y){return y===91||y===92||y===93?(e.consume(y),u++,f):f(y)}}function zS(e,n,a){const i=this,o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let u,d=0,h;return m;function m(j){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(j),e.exit("gfmFootnoteDefinitionLabelMarker"),f}function f(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&&!h||j===null||j===91||rn(j))return a(j);if(j===93){e.exit("chunkString");const k=e.exit("gfmFootnoteDefinitionLabelString");return u=sa(i.sliceSerialize(k)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(j),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),v}return rn(j)||(h=!0),d++,e.consume(j),j===92?y:x}function y(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),Rt(e,b,"gfmFootnoteDefinitionWhitespace")):a(j)}function b(j){return n(j)}}function _S(e,n,a){return e.check($o,n,e.attempt(DS,n,a))}function BS(e){e.exit("gfmFootnoteDefinition")}function OS(e,n,a){const i=this;return Rt(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 LS(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,h){let m=-1;for(;++m<d.length;)if(d[m][0]==="enter"&&d[m][1].type==="strikethroughSequenceTemporary"&&d[m][1]._close){let f=m;for(;f--;)if(d[f][0]==="exit"&&d[f][1].type==="strikethroughSequenceTemporary"&&d[f][1]._open&&d[m][1].end.offset-d[m][1].start.offset===d[f][1].end.offset-d[f][1].start.offset){d[m][1].type="strikethroughSequence",d[f][1].type="strikethroughSequence";const x={type:"strikethrough",start:Object.assign({},d[f][1].start),end:Object.assign({},d[m][1].end)},y={type:"strikethroughText",start:Object.assign({},d[f][1].end),end:Object.assign({},d[m][1].start)},v=[["enter",x,h],["enter",d[f][1],h],["exit",d[f][1],h],["enter",y,h]],b=h.parser.constructs.insideSpan.null;b&&Fr(v,v.length,0,Xu(b,d.slice(f+1,m),h)),Fr(v,v.length,0,[["exit",y,h],["enter",d[m][1],h],["exit",d[m][1],h],["exit",x,h]]),Fr(d,f-1,m-f+3,v),m=f+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,h,m){const f=this.previous,x=this.events;let y=0;return v;function v(j){return f===126&&x[x.length-1][1].type!=="characterEscape"?m(j):(d.enter("strikethroughSequenceTemporary"),b(j))}function b(j){const k=ps(f);if(j===126)return y>1?m(j):(d.consume(j),y++,b);if(y<2&&!a)return m(j);const N=d.exit("strikethroughSequenceTemporary"),S=ps(j);return N._open=!S||S===2&&!!k,N._close=!k||k===2&&!!S,h(j)}}}class $S{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 h;function h(T){let H=i.events.length-1;for(;H>-1;){const ce=i.events[H][1].type;if(ce==="lineEnding"||ce==="linePrefix")H--;else break}const L=H>-1?i.events[H][1].type:null,J=L==="tableHead"||L==="tableRow"?B:m;return J===B&&i.parser.lazy[i.now().line]?a(T):J(T)}function m(T){return e.enter("tableHead"),e.enter("tableRow"),f(T)}function f(T){return T===124||(d=!0,u+=1),x(T)}function x(T){return T===null?a(T):Ze(T)?u>1?(u=0,i.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),b):a(T):Et(T)?Rt(e,x,"whitespace")(T):(u+=1,d&&(d=!1,o+=1),T===124?(e.enter("tableCellDivider"),e.consume(T),e.exit("tableCellDivider"),d=!0,x):(e.enter("data"),y(T)))}function y(T){return T===null||T===124||rn(T)?(e.exit("data"),x(T)):(e.consume(T),T===92?v:y)}function v(T){return T===92||T===124?(e.consume(T),y):y(T)}function b(T){return i.interrupt=!1,i.parser.lazy[i.now().line]?a(T):(e.enter("tableDelimiterRow"),d=!1,Et(T)?Rt(e,j,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(T):j(T))}function j(T){return T===45||T===58?N(T):T===124?(d=!0,e.enter("tableCellDivider"),e.consume(T),e.exit("tableCellDivider"),k):I(T)}function k(T){return Et(T)?Rt(e,N,"whitespace")(T):N(T)}function N(T){return T===58?(u+=1,d=!0,e.enter("tableDelimiterMarker"),e.consume(T),e.exit("tableDelimiterMarker"),S):T===45?(u+=1,S(T)):T===null||Ze(T)?R(T):I(T)}function S(T){return T===45?(e.enter("tableDelimiterFiller"),E(T)):I(T)}function E(T){return T===45?(e.consume(T),E):T===58?(d=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(T),e.exit("tableDelimiterMarker"),_):(e.exit("tableDelimiterFiller"),_(T))}function _(T){return Et(T)?Rt(e,R,"whitespace")(T):R(T)}function R(T){return T===124?j(T):T===null||Ze(T)?!d||o!==u?I(T):(e.exit("tableDelimiterRow"),e.exit("tableHead"),n(T)):I(T)}function I(T){return a(T)}function B(T){return e.enter("tableRow"),$(T)}function $(T){return T===124?(e.enter("tableCellDivider"),e.consume(T),e.exit("tableCellDivider"),$):T===null||Ze(T)?(e.exit("tableRow"),n(T)):Et(T)?Rt(e,$,"whitespace")(T):(e.enter("data"),q(T))}function q(T){return T===null||T===124||rn(T)?(e.exit("data"),$(T)):(e.consume(T),T===92?G:q)}function G(T){return T===92||T===124?(e.consume(T),q):q(T)}}function YS(e,n){let a=-1,i=!0,o=0,u=[0,0,0,0],d=[0,0,0,0],h=!1,m=0,f,x,y;const v=new $S;for(;++a<e.length;){const b=e[a],j=b[1];b[0]==="enter"?j.type==="tableHead"?(h=!1,m!==0&&(Cy(v,n,m,f,x),x=void 0,m=0),f={type:"table",start:Object.assign({},j.start),end:Object.assign({},j.end)},v.add(a,0,[["enter",f,n]])):j.type==="tableRow"||j.type==="tableDelimiterRow"?(i=!0,y=void 0,u=[0,0,0,0],d=[0,a+1,0,0],h&&(h=!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],y=uu(v,n,u,o,void 0,y),u=[0,0,0,0]),d[2]=a)):j.type==="tableCellDivider"&&(i?i=!1:(u[1]!==0&&(d[0]=d[1],y=uu(v,n,u,o,void 0,y)),u=d,d=[u[1],a,0,0])):j.type==="tableHead"?(h=!0,m=a):j.type==="tableRow"||j.type==="tableDelimiterRow"?(m=a,u[1]!==0?(d[0]=d[1],y=uu(v,n,u,o,a,y)):d[1]!==0&&(y=uu(v,n,d,o,a,y)),o=0):o&&(j.type==="data"||j.type==="tableDelimiterMarker"||j.type==="tableDelimiterFiller")&&(d[3]=a)}for(m!==0&&Cy(v,n,m,f,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 uu(e,n,a,i,o,u){const d=i===1?"tableHeader":i===2?"tableDelimiter":"tableData",h="tableContent";a[0]!==0&&(u.end=Object.assign({},fs(n.events,a[0])),e.add(a[0],0,[["exit",u,n]]));const m=fs(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 f=fs(n.events,a[2]),x=fs(n.events,a[3]),y={type:h,start:Object.assign({},f),end:Object.assign({},x)};if(e.add(a[2],0,[["enter",y,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",y,n]])}return o!==void 0&&(u.end=Object.assign({},fs(n.events,o)),e.add(o,0,[["exit",u,n]]),u=void 0),u}function Cy(e,n,a,i,o){const u=[],d=fs(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 fs(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 rn(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"),h):a(m)}function h(m){return Ze(m)?n(m):Et(m)?e.check({tokenize:GS},n,a)(m):a(m)}}function GS(e,n,a){return Rt(e,i,"whitespace");function i(o){return o===null?a(o):n(o)}}function KS(e){return Wg([vS(),TS(),LS(e),US(),WS()])}const QS={};function $m(e){const n=this,a=e||QS,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(yS(a))}function Ho({content:e,className:n=""}){return l.jsx("div",{className:`office-markdown ${n}`,children:l.jsx(_m,{remarkPlugins:[$m],components:{code:PS,table:({children:a})=>l.jsx("div",{className:"overflow-x-auto my-2",children:l.jsx("table",{className:"office-table",children:a})})},children:e})})}function PS({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 Ny={$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 Bb(e,n){const a=Ny[e];if(a&&n)return n[a];const i=JS.exec(e);if(i){const[,o,u,d]=i,h=Ny[u],m=h&&n?n[h]:u,f=parseInt(d,10);return o==="darken"?eC(m,f):tC(m,f)}return e}function em(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:em(e.left.pixels)}:n==="left"&&e.right?{name:e.right.name,pixels:em(e.right.pixels)}:e.down}function rC(e,n){return tm(e,"hair",n,1)}function tm(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 Im=new Map,Hm=new Map;function Ob(e,n){Im.set(e,n)}function Ku(e,n){Hm.set(e,n)}function nm(e){return Im.get(e)}function aC(e){return Hm.get(e)}function z8(){return Array.from(Im.keys())}function _8(){return Array.from(Hm.keys())}function lC(e,n,a,i,o=2){e.clearRect(0,0,n.width*o,n.height*o);for(const u of n.layers)Lb(e,u.pixels,o,a,i)}function Bl(e,n,a,i,o){for(const u of n){const d=Bb(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 iC(e,n){const a=n.scale;e.clearRect(0,0,n.canvasWidth,n.canvasHeight),Lb(e,n.pixels,a,0)}function Lb(e,n,a,i,o){for(const u of n){const d=Bb(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 Bu=new Map;function $l(e,n,a){if("down"in a&&!("pixels"in a)){const o=a;Bu.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;Bu.set(e,{id:e,name:n,layer:{...o,name:"hair"}})}}function sC(e){return Bu.get(e)}function $b(){return Array.from(Bu.values())}$l("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}]}});$l("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}]}});$l("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}]}});$l("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}]}});$l("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"}]}});$l("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}]}});$l("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}]}});$l("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 Ou=new Map;function Aa(e,n,a){if("down"in a&&!("pixels"in a)){const o=a;Ou.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;Ou.set(e,{id:e,name:n,layer:{...o,name:"torso"}})}}function oC(e){return Ou.get(e)}function Ib(){return Array.from(Ou.values())}Aa("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"}]}});Aa("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"}]}});Aa("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"}]}});Aa("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)"}]}});Aa("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)"}]}});Aa("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"}]}});Aa("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"}]}});Aa("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"}]}});Aa("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"}]}});Aa("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 zo=new Map;function Ht(e,n,a){if("down"in a&&!("pixels"in a)){const o=a;zo.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;zo.set(e,{id:e,name:n,layer:{...o,name:"accessory"}})}}function cC(e){return zo.get(e)}function uC(e,n){const a=zo.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 Hb(){return Array.from(zo.values())}Ht("none","None",{name:"accessory",pixels:[]});Ht("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}]}});Ht("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}]}});Ht("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}]}});Ht("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}]}});Ht("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}]}});Ht("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}]}});Ht("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}]}});Ht("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}]}});Ht("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}]}});Ht("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}]}});Ht("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}]}});Ht("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"}]}});Ht("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}]}});Ht("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}]}});Ht("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"}]}});Ht("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}]}});Ht("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}]}});Ht("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}]}});Ht("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}]}});Ht("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"}]}});Ht("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}]}});Ht("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}]}});Ht("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}]}});Ht("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}]}});Ht("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"}]}});Ht("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"}]}});Ht("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}]}});Ht("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}]}});Ht("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 dC={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 Ub(e){return dC[e]??1}function qb(e,n){return n>=Ub(e)}Ht("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 vo({r:e,g:n,b:a}){return`#${(e<<16|n<<8|a).toString(16).padStart(6,"0")}`}function Eu(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 fC(e,n){const a=[];a.push(e[Math.floor(Math.random()*e.length)]);for(let i=1;i<n;i++){const o=e.map(h=>{let m=1/0;for(const f of a)m=Math.min(m,Eu(h,f));return m}),u=o.reduce((h,m)=>h+m,0);let d=Math.random()*u;for(let h=0;h<e.length;h++)if(d-=o[h],d<=0){a.push(e[h]);break}a.length<=i&&a.push(e[Math.floor(Math.random()*e.length)])}return a}function hC(e,n,a=20){if(e.length===0)return[];const i=fC(e,n);for(let u=0;u<a;u++){const d=Array.from({length:n},()=>[]);for(const m of e){let f=1/0,x=0;for(let y=0;y<n;y++){const v=Eu(m,i[y]);v<f&&(f=v,x=y)}d[x].push(m)}let h=!0;for(let m=0;m<n;m++){if(d[m].length===0)continue;const f={r:0,g:0,b:0};for(const v of d[m])f.r+=v.r,f.g+=v.g,f.b+=v.b;const x=d[m].length,y={r:Math.round(f.r/x),g:Math.round(f.g/x),b:Math.round(f.b/x)};Eu(y,i[m])>1&&(h=!1),i[m]=y}if(h)break}const o=new Array(n).fill(0);for(const u of e){let d=1/0,h=0;for(let m=0;m<n;m++){const f=Eu(u,i[m]);f<d&&(d=f,h=m)}o[h]++}return i.map((u,d)=>({c:u,count:o[d]})).sort((u,d)=>d.count-u.count).map(u=>u.c)}function mC(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,h=i*o,m=Math.max(1,Math.floor(h/n)),f=[];for(let x=0;x<h;x+=m){const y=x*4;d[y+3]<128||f.push({r:d[y],g:d[y+1],b:d[y+2]})}return f}function Ey(e){return .299*e.r+.587*e.g+.114*e.b}function Ay(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 pC(e,n=8){const a=mC(e),i=hC(a,n);if(i.length<5)return{skinColor:"#F5CBA7",hairColor:"#2C1810",shirtColor:"#1565C0",pantsColor:"#37474F",shoeColor:"#212121"};const o=[...i].sort((y,v)=>Ey(v)-Ey(y)),u=[...i].sort((y,v)=>Ay(v)-Ay(y)),d=o[0],h=o[o.length-1],m=u[0],f=o[o.length-2],x=o[o.length-1];return{skinColor:vo(d),hairColor:vo(h),shirtColor:vo(m),pantsColor:vo(f),shoeColor:vo(x)}}const xC=[{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}],yC=[{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"}],gC=[{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"}],bC=[{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 vC(){return{width:12,height:22,layers:[{name:"lower",pixels:xC},{name:"torso",pixels:yC},{name:"head",pixels:gC},{name:"hair",pixels:bC},{name:"accessory",pixels:[]}]}}const wC=["cto","cbo","pm","engineer","designer","qa","data-analyst","default"];for(const e of wC)Ob(`mini:${e}`,vC());const kC=[{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"}],jC=[{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"}],SC=[{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 CC(){return{width:12,height:22,layers:[{name:"torso",pixels:kC},{name:"head",pixels:jC},{name:"hair",pixels:SC},{name:"accessory",pixels:[]}]}}Ob("mini-seated:default",CC());const NC={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"}]},EC={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"}]},AC={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"}]},DC={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"}]};Ku("meeting",NC);Ku("bulletin",EC);Ku("decision",DC);Ku("knowledge",AC);const bh=16,vh=24,TC=60,FC={cbo:0,cto:8,pm:15,engineer:22,designer:5,qa:12};function Yb(e,n){if(!e)return e;let a=e;if(n!=null&&n.hairStyle){const i=sC(n.hairStyle);i&&(a=rC(a,i.layer))}if(n!=null&&n.outfitStyle){const i=oC(n.outfitStyle);i&&(a=tm(a,"torso",i.layer,1))}if(n!=null&&n.accessory&&n.accessory!=="none"){const i=cC(n.accessory);i&&(a=tm(a,"accessory",i.layer))}return a}function Pa({roleId:e,className:n,appearance:a,scale:i}){const o=w.useRef(null),u=w.useRef(0),d=w.useRef(0),h=w.useRef(a);h.current=a;const m=i??4,f=bh*m,x=vh*m,y=w.useMemo(()=>{const v=nm(`mini:${e}`)??nm("mini:default");return Yb(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=FC[e]??0,k=()=>{d.current++;const N=h.current;if(!N||!y){u.current=requestAnimationFrame(k);return}const E=(d.current+j)%TC<30?1:0;b.clearRect(0,0,bh,vh),b.save(),b.translate(2,1),lC(b,y,E,N,1),b.restore(),u.current=requestAnimationFrame(k)};return u.current=requestAnimationFrame(k),()=>cancelAnimationFrame(u.current)},[e,y]),l.jsx("canvas",{ref:o,width:bh,height:vh,className:n,style:{imageRendering:"pixelated",display:"block",width:f,height:x}})}const MC="https://api.tycono.ai",Um=MC;async function wo(e){const n=await fetch(`${Um}${e}`);if(!n.ok)throw new Error(`Cloud API error: ${n.status}`);return n.json()}async function hi(e,n){const a=await fetch(`${Um}${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 pr={health:()=>wo("/api/health"),getMyName:e=>wo(`/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 wo(`/api/store/characters${a?`?${a}`:""}`)},getCharacter:e=>wo(`/api/store/characters/${e}`),getCharacterVersion:e=>wo(`/api/store/characters/${e}/version`),voteCharacter:(e,n,a)=>hi(`/api/store/characters/${e}/vote`,{instanceId:n,vote:a}),trackInstall:e=>hi(`/api/store/characters/${e}/install`,{}),syncCheck:e=>hi("/api/sync/check",{roles:e}),syncPull:e=>hi("/api/sync/pull",{sourceId:e}),publishCharacter:e=>hi("/api/store/publish",e),deleteCharacter:(e,n)=>{const a=n?`?publisher_id=${encodeURIComponent(n)}`:"";return fetch(`${Um}/api/store/characters/${e}${a}`,{method:"DELETE"}).then(i=>i.json())},uploadTelemetry:e=>hi("/api/telemetry",e),syncStats:e=>hi("/api/stats/sync",e)},RC={cto:"🏗️",cbo:"📊",pm:"📋",engineer:"⚙️",designer:"🎨",qa:"🔍"},wh={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"},zC={cto:"Chief Technology Officer",cbo:"Chief Business Officer",pm:"Product Manager",engineer:"Software Engineer",designer:"UI/UX Designer",qa:"QA Engineer"},_C=500,Dy=360,Ty=700,BC=e=>`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`;function Fy({role:e,allRoles:n,recentActivity:a,onClose:i,onFireRole:o,terminalWidth:u=0,activeJobId:d,activeSessionId:h,activeTask:m,isWorking:f,jobStartedAt:x,onStopJob:y,sessions:v,streamingSessionId:b,onCreateSessionSilent:j,onSendMessage:k,onFocusTerminal:N,onCustomize:S,onUpdateRole:E,appearance:_,relationships:R,roleLevel:I,onMaximize:B}){var Oe,kt;const[$,q]=w.useState(_C),[G,T]=w.useState(!1),H=w.useRef(0),L=w.useRef(0),[J,ce]=w.useState(!1),[re,X]=w.useState(!1),[le,ee]=w.useState(!1),[Z,D]=w.useState(!1),[F,W]=w.useState("talk"),[A,Q]=w.useState(!1),[ie,he]=w.useState(""),[Ne,Ie]=w.useState(!1),de=w.useRef(null),[_e,Ye]=w.useState(!1),[ge,Je]=w.useState(""),[Fe,ct]=w.useState(!1),{events:Ke,status:ot}=Fg(h??null),[xt,wt]=w.useState(0);w.useEffect(()=>{if(!f||!x){wt(0);return}const Me=new Date(x).getTime(),Le=()=>wt(Math.floor((Date.now()-Me)/1e3));Le();const Vt=setInterval(Le,1e3);return()=>clearInterval(Vt)},[f,x]);const bt=u>0,dt=bt?u:0,gn=bt?Math.max(Dy,window.innerWidth-u-100):Ty,ft=Math.min($,gn),Wt=w.useCallback(Me=>{Me.preventDefault(),H.current=Me.clientX,L.current=ft,T(!0);const Le=B,Vt=()=>{T(!1),document.removeEventListener("mousemove",Jt),document.removeEventListener("mouseup",Vt)},Jt=jt=>{const Bt=H.current-jt.clientX,bn=L.current+Bt;if(bn>=window.innerWidth*.6&&Le){Vt(),Le();return}const P=Math.min(Ty,Math.max(Dy,bn));q(P)};document.addEventListener("mousemove",Jt),document.addEventListener("mouseup",Vt)},[ft,B]),we=w.useRef(null),U=e?v.find(Me=>Me.roleId===e.id):null,ae=Me=>{if(!e)return;const Le=f?"talk":F;U?(k(U.id,Me,Le),N(e.id)):(we.current={content:Me,mode:Le},j(e.id))};w.useEffect(()=>{if(U&&we.current){const{content:Me,mode:Le}=we.current;we.current=null,k(U.id,Me,Le),e&&N(e.id)}},[U==null?void 0:U.id]);const me=(()=>{if(!Ke.length)return null;const Me=[];let Le=0,Vt=0,Jt=0;for(const jt of Ke)if(jt.type==="thinking")Le++;else if(jt.type==="text")Vt++;else if(jt.type==="tool:start"){const Bt=String(jt.data.name??"");Me.includes(Bt)||Me.push(Bt)}else jt.type==="dispatch:start"&&Jt++;return{tools:Me,thinkCount:Le,textCount:Vt,dispatchCount:Jt,total:Ke.length}})(),Ce=m||(()=>{if(!U)return null;const Me=U.messages;for(let Le=Me.length-1;Le>=0;Le--)if(Me[Le].from==="ceo")return Me[Le].content;return null})(),De=(()=>{if(!U)return null;const Me=U.messages;for(let Le=Me.length-1;Le>=0;Le--)if(Me[Le].from==="role"&&Me[Le].content)return Me[Le].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:dt},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:dt,width:ft,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 Se=wh[e.id]??"#666",Be=RC[e.id]??"👤",$e=n.filter(Me=>Me.reportsTo===e.id),Re=U&&b===U.id,ze=e.name||zC[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:dt},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)] ${G?"resizing":""}`,style:{borderLeftColor:Se,right:dt,width:ft,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 ${G?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:Wt}),l.jsxs("div",{className:"relative shrink-0 overflow-hidden",style:{background:`linear-gradient(135deg, ${Se}ee, ${Se}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:[S&&l.jsx("button",{onClick:()=>S(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:"🎨"}),B&&l.jsx("button",{onClick:B,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(Pa,{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:[Be," ",e.id.toUpperCase(),f&&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"})]}),A?l.jsxs("form",{className:"flex items-center gap-1.5 mt-0.5",onSubmit:async Me=>{Me.preventDefault();const Le=ie.trim();if(!Le||Le===ze||!E){Q(!1);return}Ie(!0);try{await E(e.id,{name:Le})}catch{}Ie(!1),Q(!1)},children:[l.jsx("input",{ref:de,value:ie,onChange:Me=>he(Me.target.value),onKeyDown:Me=>{Me.key==="Escape"&&Q(!1)},disabled:Ne,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:Ne,className:"text-white/80 hover:text-white text-[10px] cursor-pointer shrink-0",children:"✓"}),l.jsx("button",{type:"button",onClick:()=>Q(!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:()=>{E&&(he(ze),Q(!0))},title:E?"Click to edit name":void 0,children:[ze,E&&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.",I??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:f?"var(--idle-amber)":"var(--active-green)"}}),f?"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:[f&&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",xt>0?` · ${BC(xt)}`:""]})]}),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&&y&&l.jsx("button",{onClick:()=>y(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"})]})]}),Ce&&l.jsx("div",{className:"text-xs truncate",style:{color:"var(--terminal-text-secondary)"},children:Ce})]}),f&&d&&me&&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:[me.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 ×",me.thinkCount]}),me.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)),me.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 ×",me.dispatchCount]}),me.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 ×",me.textCount]}),(ot==="streaming"||ot==="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:[me.total," events"]})]}),f&&De&&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:[De.slice(0,200),De.length>200&&"..."]})]}),f&&l.jsx("div",{className:"px-4 py-2.5 shrink-0",style:{borderBottom:"1px solid var(--terminal-border)"},children:l.jsx(My,{onSend:ae,disabled:!!Re,placeholder:"Ask something...",color:Se})}),!f&&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(LC,{icon:Be,roleId:e.id,roleName:ze,color:Se,text:a})]}),!f&&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:[De&&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:[De.slice(0,150),De.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:()=>W("talk"),className:"px-2 py-1 text-[10px] font-semibold cursor-pointer transition-colors",style:{background:F==="talk"?"var(--accent)":"transparent",color:F==="talk"?"#fff":"var(--terminal-text-secondary)"},children:"Talk"}),l.jsx("button",{onClick:()=>W("do"),className:"px-2 py-1 text-[10px] font-semibold cursor-pointer transition-colors",style:{background:F==="do"?"var(--idle-amber)":"transparent",color:F==="do"?"#fff":"var(--terminal-text-secondary)"},children:"Do"})]}),l.jsx(My,{onSend:ae,disabled:!!Re,placeholder:F==="talk"?"Ask something...":"Give a directive...",color:Se})]})})]})}),l.jsxs("div",{className:"px-4 py-2 space-y-1",children:[l.jsxs(du,{title:`Profile${e.persona?"":" (empty)"}`,open:J,onToggle:()=>ce(Me=>!Me),children:[_e?l.jsxs("div",{className:"space-y-2",children:[l.jsx("textarea",{value:ge,onChange:Me=>Je(Me.target.value),onKeyDown:Me=>{Me.key==="Escape"&&Ye(!1)},disabled:Fe,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:()=>Ye(!1),disabled:Fe,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(E){ct(!0);try{await E(e.id,{persona:ge.trim()})}catch{}ct(!1),Ye(!1)}},disabled:Fe,className:"text-[10px] px-2 py-0.5 rounded cursor-pointer font-semibold",style:{background:"var(--active-green)",color:"#000"},children:Fe?"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:()=>{E&&(Je(e.persona||""),Ye(!0))},title:E?"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."}),E&&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(kh,{label:"Level",value:e.level}),l.jsx(kh,{label:"Reports to",value:e.reportsTo}),l.jsx(kh,{label:"Status",value:e.status})]}),$e.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:$e.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:wh[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(du,{title:"Authority",open:re,onToggle:()=>X(Me=>!Me),children:[((Oe=e.authority.autonomous)==null?void 0:Oe.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,Le)=>l.jsxs("div",{className:"text-xs pl-3 py-0.5",style:{color:"var(--terminal-text-secondary)"},children:["- ",Me]},Le))]}),((kt=e.authority.needsApproval)==null?void 0:kt.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,Le)=>l.jsxs("div",{className:"text-xs pl-3 py-0.5",style:{color:"var(--terminal-text-secondary)"},children:["- ",Me]},Le))]})]}),e&&R&&(()=>{const Me=R.filter(Le=>Le.roleA===e.id||Le.roleB===e.id).filter(Le=>Le.familiarity>0).sort((Le,Vt)=>Vt.familiarity-Le.familiarity);return Me.length===0?null:l.jsx(du,{title:`Relationships (${Me.length})`,open:le,onToggle:()=>ee(Le=>!Le),children:l.jsx("div",{className:"space-y-1.5",children:Me.map((Le,Vt)=>{const Jt=Le.roleA===e.id?Le.roleB:Le.roleA,jt=n.find(P=>P.id===Jt),Bt=Le.familiarity>=80?"Best Partner":Le.familiarity>=50?"Friend":Le.familiarity>=20?"Colleague":"Acquaintance",bn=Le.familiarity>=80?"#4CAF50":Le.familiarity>=50?"#2196F3":Le.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:wh[Jt]??"var(--terminal-text-secondary)"},children:(jt==null?void 0:jt.name)??Jt}),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:`${Le.familiarity}%`,background:bn}})}),l.jsx("span",{className:"text-[10px] w-16 text-right",style:{color:"var(--terminal-text-muted)"},children:Bt})]},Vt)})})})})(),e.journal&&l.jsx(du,{title:`Journal (${(e.journal.match(/### /g)??[]).length})`,open:Z,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(Ho,{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(OC,{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 OC({role:e,appearance:n}){const[a,i]=w.useState("idle"),[o,u]=w.useState(""),[d,h]=w.useState(!1),[m,f]=w.useState(null),[x,y]=w.useState(!1),[v,b]=w.useState(!1),[j,k]=w.useState(null);w.useEffect(()=>{pr.getCharacterVersion(e.id).then(E=>f((E==null?void 0:E.version)??null)).catch(()=>f(null)),ye.getPreferences().then(E=>k(E.instanceId??null)).catch(()=>{})},[e.id]);const N=async()=>{var E,_;if(!d){h(!0);return}i("publishing");try{let R=null;try{R=await ye.exportSkills(e.id)}catch{}const I={roleId:e.id,persona:e.persona??"",authority:e.authority??{autonomous:[],needsApproval:[]},level:e.level,tagline:((E=(e.persona??"").split(/[.\n]/)[0])==null?void 0:E.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&&(I.appearance=n);let B="1.0.0";try{const $=await pr.getCharacterVersion(e.id);if($!=null&&$.version){const q=$.version.split(".").map(Number);q[2]=(q[2]??0)+1,B=q.join(".")}}catch{}await pr.publishCharacter({id:e.id,name:e.name||e.id,version:B,data:I,publisherId:j??void 0}),i("done"),u(`Published v${B}`),f(B),h(!1)}catch(R){i("error"),u(R instanceof Error?R.message:"Failed"),h(!1)}},S=async()=>{b(!0);try{await pr.deleteCharacter(e.id,j??void 0),f(null),i("idle"),u(""),y(!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("span",{className:"text-[11px] font-bold uppercase tracking-wider shrink-0",style:{color:"var(--terminal-text-secondary)",fontFamily:"var(--pixel-font)"},children:"Cloud Store"}),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.jsxs(l.Fragment,{children:[l.jsx("a",{href:"https://tycono.ai/store.html",target:"_blank",rel:"noopener noreferrer",className:"text-[10px] hover:underline",style:{color:"var(--terminal-text-muted)"},onClick:E=>E.stopPropagation(),children:"View on Store ↗"}),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:()=>y(!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:S,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:()=>y(!1),className:"text-[10px] px-1.5 py-1 rounded cursor-pointer",style:{color:"var(--terminal-text-muted)"},children:"No"})]})]})]})})})}function LC({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(Ho,{content:o})}):l.jsx("div",{className:"text-sm italic",style:{color:"var(--terminal-text-muted)"},children:"No recent activity."})]})]})})]})})}function du({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 My({onSend:e,disabled:n,placeholder:a,color:i}){const[o,u]=w.useState(""),d=w.useRef(!1),h=()=>{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(),h())},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:h,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 kh({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 $C(e,n){var a,i=1;e==null&&(e=0),n==null&&(n=0);function o(){var u,d=a.length,h,m=0,f=0;for(u=0;u<d;++u)h=a[u],m+=h.x,f+=h.y;for(m=(m/d-e)*i,f=(f/d-n)*i,u=0;u<d;++u)h=a[u],h.x-=m,h.y-=f}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 IC(e){const n=+this._x.call(null,e),a=+this._y.call(null,e);return Xb(this.cover(n,a),n,a,e)}function Xb(e,n,a,i){if(isNaN(n)||isNaN(a))return e;var o,u=e._root,d={data:i},h=e._x0,m=e._y0,f=e._x1,x=e._y1,y,v,b,j,k,N,S,E;if(!u)return e._root=d,e;for(;u.length;)if((k=n>=(y=(h+f)/2))?h=y:f=y,(N=a>=(v=(m+x)/2))?m=v:x=v,o=u,!(u=u[S=N<<1|k]))return o[S]=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[S]=d:e._root=d,e;do o=o?o[S]=new Array(4):e._root=new Array(4),(k=n>=(y=(h+f)/2))?h=y:f=y,(N=a>=(v=(m+x)/2))?m=v:x=v;while((S=N<<1|k)===(E=(j>=v)<<1|b>=y));return o[E]=u,o[S]=d,e}function HC(e){var n,a,i=e.length,o,u,d=new Array(i),h=new Array(i),m=1/0,f=1/0,x=-1/0,y=-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,h[a]=u,o<m&&(m=o),o>x&&(x=o),u<f&&(f=u),u>y&&(y=u));if(m>x||f>y)return this;for(this.cover(m,f).cover(x,y),a=0;a<i;++a)Xb(this,d[a],h[a],e[a]);return this}function UC(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,h=this._root,m,f;a>e||e>=o||i>n||n>=u;)switch(f=(n<i)<<1|e<a,m=new Array(4),m[f]=h,h=m,d*=2,f){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=h)}return this._x0=a,this._y0=i,this._x1=o,this._y1=u,this}function qC(){var e=[];return this.visit(function(n){if(!n.length)do e.push(n.data);while(n=n.next)}),e}function YC(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 rr(e,n,a,i,o){this.node=e,this.x0=n,this.y0=a,this.x1=i,this.y1=o}function XC(e,n,a){var i,o=this._x0,u=this._y0,d,h,m,f,x=this._x1,y=this._y1,v=[],b=this._root,j,k;for(b&&v.push(new rr(b,o,u,x,y)),a==null?a=1/0:(o=e-a,u=n-a,x=e+a,y=n+a,a*=a);j=v.pop();)if(!(!(b=j.node)||(d=j.x0)>x||(h=j.y0)>y||(m=j.x1)<o||(f=j.y1)<u))if(b.length){var N=(d+m)/2,S=(h+f)/2;v.push(new rr(b[3],N,S,m,f),new rr(b[2],d,S,N,f),new rr(b[1],N,h,m,S),new rr(b[0],d,h,N,S)),(k=(n>=S)<<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 E=e-+this._x.call(null,b.data),_=n-+this._y.call(null,b.data),R=E*E+_*_;if(R<a){var I=Math.sqrt(a=R);o=e-I,u=n-I,x=e+I,y=n+I,i=b.data}}return i}function WC(e){if(isNaN(x=+this._x.call(null,e))||isNaN(y=+this._y.call(null,e)))return this;var n,a=this._root,i,o,u,d=this._x0,h=this._y0,m=this._x1,f=this._y1,x,y,v,b,j,k,N,S;if(!a)return this;if(a.length)for(;;){if((j=x>=(v=(d+m)/2))?d=v:m=v,(k=y>=(b=(h+f)/2))?h=b:f=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,S=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[S]=a:this._root=a),this):(this._root=u,this)}function VC(e){for(var n=0,a=e.length;n<a;++n)this.remove(e[n]);return this}function GC(){return this._root}function KC(){var e=0;return this.visit(function(n){if(!n.length)do++e;while(n=n.next)}),e}function QC(e){var n=[],a,i=this._root,o,u,d,h,m;for(i&&n.push(new rr(i,this._x0,this._y0,this._x1,this._y1));a=n.pop();)if(!e(i=a.node,u=a.x0,d=a.y0,h=a.x1,m=a.y1)&&i.length){var f=(u+h)/2,x=(d+m)/2;(o=i[3])&&n.push(new rr(o,f,x,h,m)),(o=i[2])&&n.push(new rr(o,u,x,f,m)),(o=i[1])&&n.push(new rr(o,f,d,h,x)),(o=i[0])&&n.push(new rr(o,u,d,f,x))}return this}function PC(e){var n=[],a=[],i;for(this._root&&n.push(new rr(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,h=i.y0,m=i.x1,f=i.y1,x=(d+m)/2,y=(h+f)/2;(u=o[0])&&n.push(new rr(u,d,h,x,y)),(u=o[1])&&n.push(new rr(u,x,h,m,y)),(u=o[2])&&n.push(new rr(u,d,y,x,f)),(u=o[3])&&n.push(new rr(u,x,y,m,f))}a.push(i)}for(;i=a.pop();)e(i.node,i.x0,i.y0,i.x1,i.y1);return this}function ZC(e){return e[0]}function JC(e){return arguments.length?(this._x=e,this):this._x}function eN(e){return e[1]}function tN(e){return arguments.length?(this._y=e,this):this._y}function qm(e,n,a){var i=new Ym(n??ZC,a??eN,NaN,NaN,NaN,NaN);return e==null?i:i.addAll(e)}function Ym(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 Ry(e){for(var n={data:e.data},a=n;e=e.next;)a=a.next={data:e.data};return n}var ar=qm.prototype=Ym.prototype;ar.copy=function(){var e=new Ym(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=Ry(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]=Ry(i));return e};ar.add=IC;ar.addAll=HC;ar.cover=UC;ar.data=qC;ar.extent=YC;ar.find=XC;ar.remove=WC;ar.removeAll=VC;ar.root=GC;ar.size=KC;ar.visit=QC;ar.visitAfter=PC;ar.x=JC;ar.y=tN;function bi(e){return function(){return e}}function Ol(e){return(e()-.5)*1e-6}function nN(e){return e.x+e.vx}function rN(e){return e.y+e.vy}function aN(e){var n,a,i,o=1,u=1;typeof e!="function"&&(e=bi(e==null?1:+e));function d(){for(var f,x=n.length,y,v,b,j,k,N,S=0;S<u;++S)for(y=qm(n,nN,rN).visitAfter(h),f=0;f<x;++f)v=n[f],k=a[v.index],N=k*k,b=v.x+v.vx,j=v.y+v.vy,y.visit(E);function E(_,R,I,B,$){var q=_.data,G=_.r,T=k+G;if(q){if(q.index>v.index){var H=b-q.x-q.vx,L=j-q.y-q.vy,J=H*H+L*L;J<T*T&&(H===0&&(H=Ol(i),J+=H*H),L===0&&(L=Ol(i),J+=L*L),J=(T-(J=Math.sqrt(J)))/J*o,v.vx+=(H*=J)*(T=(G*=G)/(N+G)),v.vy+=(L*=J)*T,q.vx-=H*(T=1-T),q.vy-=L*T)}return}return R>b+T||B<b-T||I>j+T||$<j-T}}function h(f){if(f.data)return f.r=a[f.data.index];for(var x=f.r=0;x<4;++x)f[x]&&f[x].r>f.r&&(f.r=f[x].r)}function m(){if(n){var f,x=n.length,y;for(a=new Array(x),f=0;f<x;++f)y=n[f],a[y.index]=+e(y,f,n)}}return d.initialize=function(f,x){n=f,i=x,m()},d.iterations=function(f){return arguments.length?(u=+f,d):u},d.strength=function(f){return arguments.length?(o=+f,d):o},d.radius=function(f){return arguments.length?(e=typeof f=="function"?f:bi(+f),m(),d):e},d}function lN(e){return e.index}function zy(e,n){var a=e.get(n);if(!a)throw new Error("node not found: "+n);return a}function iN(e){var n=lN,a=y,i,o=bi(30),u,d,h,m,f,x=1;e==null&&(e=[]);function y(N){return 1/Math.min(h[N.source.index],h[N.target.index])}function v(N){for(var S=0,E=e.length;S<x;++S)for(var _=0,R,I,B,$,q,G,T;_<E;++_)R=e[_],I=R.source,B=R.target,$=B.x+B.vx-I.x-I.vx||Ol(f),q=B.y+B.vy-I.y-I.vy||Ol(f),G=Math.sqrt($*$+q*q),G=(G-u[_])/G*N*i[_],$*=G,q*=G,B.vx-=$*(T=m[_]),B.vy-=q*T,I.vx+=$*(T=1-T),I.vy+=q*T}function b(){if(d){var N,S=d.length,E=e.length,_=new Map(d.map((I,B)=>[n(I,B,d),I])),R;for(N=0,h=new Array(S);N<E;++N)R=e[N],R.index=N,typeof R.source!="object"&&(R.source=zy(_,R.source)),typeof R.target!="object"&&(R.target=zy(_,R.target)),h[R.source.index]=(h[R.source.index]||0)+1,h[R.target.index]=(h[R.target.index]||0)+1;for(N=0,m=new Array(E);N<E;++N)R=e[N],m[N]=h[R.source.index]/(h[R.source.index]+h[R.target.index]);i=new Array(E),j(),u=new Array(E),k()}}function j(){if(d)for(var N=0,S=e.length;N<S;++N)i[N]=+a(e[N],N,e)}function k(){if(d)for(var N=0,S=e.length;N<S;++N)u[N]=+o(e[N],N,e)}return v.initialize=function(N,S){d=N,f=S,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:bi(+N),j(),v):a},v.distance=function(N){return arguments.length?(o=typeof N=="function"?N:bi(+N),k(),v):o},v}var sN={value:()=>{}};function Wb(){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 Au(a)}function Au(e){this._=e}function oN(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}})}Au.prototype=Wb.prototype={constructor:Au,on:function(e,n){var a=this._,i=oN(e+"",a),o,u=-1,d=i.length;if(arguments.length<2){for(;++u<d;)if((o=(e=i[u]).type)&&(o=cN(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]=_y(a[o],e.name,n);else if(n==null)for(o in a)a[o]=_y(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 Au(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 cN(e,n){for(var a=0,i=e.length,o;a<i;++a)if((o=e[a]).name===n)return o.value}function _y(e,n,a){for(var i=0,o=e.length;i<o;++i)if(e[i].name===n){e[i]=sN,e=e.slice(0,i).concat(e.slice(i+1));break}return a!=null&&e.push({name:n,value:a}),e}var xs=0,No=0,ko=0,Vb=1e3,Lu,Eo,$u=0,ji=0,Qu=0,_o=typeof performance=="object"&&performance.now?performance:Date,Gb=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Kb(){return ji||(Gb(uN),ji=_o.now()+Qu)}function uN(){ji=0}function rm(){this._call=this._time=this._next=null}rm.prototype=Qb.prototype={constructor:rm,restart:function(e,n,a){if(typeof e!="function")throw new TypeError("callback is not a function");a=(a==null?Kb():+a)+(n==null?0:+n),!this._next&&Eo!==this&&(Eo?Eo._next=this:Lu=this,Eo=this),this._call=e,this._time=a,am()},stop:function(){this._call&&(this._call=null,this._time=1/0,am())}};function Qb(e,n,a){var i=new rm;return i.restart(e,n,a),i}function dN(){Kb(),++xs;for(var e=Lu,n;e;)(n=ji-e._time)>=0&&e._call.call(void 0,n),e=e._next;--xs}function By(){ji=($u=_o.now())+Qu,xs=No=0;try{dN()}finally{xs=0,hN(),ji=0}}function fN(){var e=_o.now(),n=e-$u;n>Vb&&(Qu-=n,$u=e)}function hN(){for(var e,n=Lu,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:Lu=a);Eo=e,am(i)}function am(e){if(!xs){No&&(No=clearTimeout(No));var n=e-ji;n>24?(e<1/0&&(No=setTimeout(By,e-_o.now()-Qu)),ko&&(ko=clearInterval(ko))):(ko||($u=_o.now(),ko=setInterval(fN,Vb)),xs=1,Gb(By))}}const mN=1664525,pN=1013904223,Oy=4294967296;function xN(){let e=1;return()=>(e=(mN*e+pN)%Oy)/Oy}function yN(e){return e.x}function gN(e){return e.y}var bN=10,vN=Math.PI*(3-Math.sqrt(5));function wN(e){var n,a=1,i=.001,o=1-Math.pow(i,1/300),u=0,d=.6,h=new Map,m=Qb(y),f=Wb("tick","end"),x=xN();e==null&&(e=[]);function y(){v(),f.call("tick",n),a<i&&(m.stop(),f.call("end",n))}function v(k){var N,S=e.length,E;k===void 0&&(k=1);for(var _=0;_<k;++_)for(a+=(u-a)*o,h.forEach(function(R){R(a)}),N=0;N<S;++N)E=e[N],E.fx==null?E.x+=E.vx*=d:(E.x=E.fx,E.vx=0),E.fy==null?E.y+=E.vy*=d:(E.y=E.fy,E.vy=0);return n}function b(){for(var k=0,N=e.length,S;k<N;++k){if(S=e[k],S.index=k,S.fx!=null&&(S.x=S.fx),S.fy!=null&&(S.y=S.fy),isNaN(S.x)||isNaN(S.y)){var E=bN*Math.sqrt(.5+k),_=k*vN;S.x=E*Math.cos(_),S.y=E*Math.sin(_)}(isNaN(S.vx)||isNaN(S.vy))&&(S.vx=S.vy=0)}}function j(k){return k.initialize&&k.initialize(e,x),k}return b(),n={tick:v,restart:function(){return m.restart(y),n},stop:function(){return m.stop(),n},nodes:function(k){return arguments.length?(e=k,b(),h.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,h.forEach(j),n):x},force:function(k,N){return arguments.length>1?(N==null?h.delete(k):h.set(k,j(N)),n):h.get(k)},find:function(k,N,S){var E=0,_=e.length,R,I,B,$,q;for(S==null?S=1/0:S*=S,E=0;E<_;++E)$=e[E],R=k-$.x,I=N-$.y,B=R*R+I*I,B<S&&(q=$,S=B);return q},on:function(k,N){return arguments.length>1?(f.on(k,N),n):f.on(k)}}}function kN(){var e,n,a,i,o=bi(-30),u,d=1,h=1/0,m=.81;function f(b){var j,k=e.length,N=qm(e,yN,gN).visitAfter(y);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 y(b){var j=0,k,N,S=0,E,_,R;if(b.length){for(E=_=R=0;R<4;++R)(k=b[R])&&(N=Math.abs(k.value))&&(j+=k.value,S+=N,E+=N*k.x,_+=N*k.y);b.x=E/S,b.y=_/S}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 S=b.x-n.x,E=b.y-n.y,_=N-j,R=S*S+E*E;if(_*_/m<R)return R<h&&(S===0&&(S=Ol(a),R+=S*S),E===0&&(E=Ol(a),R+=E*E),R<d&&(R=Math.sqrt(d*R)),n.vx+=S*b.value*i/R,n.vy+=E*b.value*i/R),!0;if(b.length||R>=h)return;(b.data!==n||b.next)&&(S===0&&(S=Ol(a),R+=S*S),E===0&&(E=Ol(a),R+=E*E),R<d&&(R=Math.sqrt(d*R)));do b.data!==n&&(_=u[b.data.index]*i/R,n.vx+=S*_,n.vy+=E*_);while(b=b.next)}return f.initialize=function(b,j){e=b,a=j,x()},f.strength=function(b){return arguments.length?(o=typeof b=="function"?b:bi(+b),x(),f):o},f.distanceMin=function(b){return arguments.length?(d=b*b,f):Math.sqrt(d)},f.distanceMax=function(b){return arguments.length?(h=b*b,f):Math.sqrt(h)},f.theta=function(b){return arguments.length?(m=b*b,f):Math.sqrt(m)},f}function Za(e){return Array.isArray?Array.isArray(e):Jb(e)==="[object Array]"}function jN(e){if(typeof e=="string")return e;let n=e+"";return n=="0"&&1/e==-1/0?"-0":n}function SN(e){return e==null?"":jN(e)}function Sa(e){return typeof e=="string"}function Pb(e){return typeof e=="number"}function CN(e){return e===!0||e===!1||NN(e)&&Jb(e)=="[object Boolean]"}function Zb(e){return typeof e=="object"}function NN(e){return Zb(e)&&e!==null}function Dr(e){return e!=null}function jh(e){return!e.trim().length}function Jb(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const EN="Incorrect 'index' type",AN=e=>`Invalid value for key ${e}`,DN=e=>`Pattern length exceeds max of ${e}.`,TN=e=>`Missing ${e} property in key`,FN=e=>`Property 'weight' in key '${e}' must be a positive integer`,Ly=Object.prototype.hasOwnProperty;class MN{constructor(n){this._keys=[],this._keyMap={};let a=0;n.forEach(i=>{let o=ev(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 ev(e){let n=null,a=null,i=null,o=1,u=null;if(Sa(e)||Za(e))i=e,n=$y(e),a=lm(e);else{if(!Ly.call(e,"name"))throw new Error(TN("name"));const d=e.name;if(i=d,Ly.call(e,"weight")&&(o=e.weight,o<=0))throw new Error(FN(d));n=$y(d),a=lm(d),u=e.getFn}return{path:n,id:a,weight:o,src:i,getFn:u}}function $y(e){return Za(e)?e:e.split(".")}function lm(e){return Za(e)?e.join("."):e}function RN(e,n){let a=[],i=!1;const o=(u,d,h)=>{if(Dr(u))if(!d[h])a.push(u);else{let m=d[h];const f=u[m];if(!Dr(f))return;if(h===d.length-1&&(Sa(f)||Pb(f)||CN(f)))a.push(SN(f));else if(Za(f)){i=!0;for(let x=0,y=f.length;x<y;x+=1)o(f[x],d,h+1)}else d.length&&o(f,d,h+1)}};return o(e,Sa(n)?n.split("."):n,0),i?a:a[0]}const zN={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},_N={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},BN={location:0,threshold:.6,distance:100},ON={useExtendedSearch:!1,getFn:RN,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var st={..._N,...zN,...BN,...ON};const LN=/[^ ]+/g;function $N(e=1,n=3){const a=new Map,i=Math.pow(10,n);return{get(o){const u=o.match(LN).length;if(a.has(u))return a.get(u);const d=1/Math.pow(u,.5*e),h=parseFloat(Math.round(d*i)/i);return a.set(u,h),h},clear(){a.clear()}}}class Xm{constructor({getFn:n=st.getFn,fieldNormWeight:a=st.fieldNormWeight}={}){this.norm=$N(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,Sa(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();Sa(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(!Dr(n)||jh(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(Dr(d)){if(Za(d)){let h=[];const m=[{nestedArrIndex:-1,value:d}];for(;m.length;){const{nestedArrIndex:f,value:x}=m.pop();if(Dr(x))if(Sa(x)&&!jh(x)){let y={v:x,i:f,n:this.norm.get(x)};h.push(y)}else Za(x)&&x.forEach((y,v)=>{m.push({nestedArrIndex:v,value:y})})}i.$[u]=h}else if(Sa(d)&&!jh(d)){let h={v:d,n:this.norm.get(d)};i.$[u]=h}}}),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function tv(e,n,{getFn:a=st.getFn,fieldNormWeight:i=st.fieldNormWeight}={}){const o=new Xm({getFn:a,fieldNormWeight:i});return o.setKeys(e.map(ev)),o.setSources(n),o.create(),o}function IN(e,{getFn:n=st.getFn,fieldNormWeight:a=st.fieldNormWeight}={}){const{keys:i,records:o}=e,u=new Xm({getFn:n,fieldNormWeight:a});return u.setKeys(i),u.setIndexRecords(o),u}function fu(e,{errors:n=0,currentLocation:a=0,expectedLocation:i=0,distance:o=st.distance,ignoreLocation:u=st.ignoreLocation}={}){const d=n/e.length;if(u)return d;const h=Math.abs(i-a);return o?d+h/o:h?1:d}function HN(e=[],n=st.minMatchCharLength){let a=[],i=-1,o=-1,u=0;for(let d=e.length;u<d;u+=1){let h=e[u];h&&i===-1?i=u:!h&&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 gi=32;function UN(e,n,a,{location:i=st.location,distance:o=st.distance,threshold:u=st.threshold,findAllMatches:d=st.findAllMatches,minMatchCharLength:h=st.minMatchCharLength,includeMatches:m=st.includeMatches,ignoreLocation:f=st.ignoreLocation}={}){if(n.length>gi)throw new Error(DN(gi));const x=n.length,y=e.length,v=Math.max(0,Math.min(i,y));let b=u,j=v;const k=h>1||m,N=k?Array(y):[];let S;for(;(S=e.indexOf(n,j))>-1;){let $=fu(n,{currentLocation:S,expectedLocation:v,distance:o,ignoreLocation:f});if(b=Math.min($,b),j=S+x,k){let q=0;for(;q<x;)N[S+q]=1,q+=1}}j=-1;let E=[],_=1,R=x+y;const I=1<<x-1;for(let $=0;$<x;$+=1){let q=0,G=R;for(;q<G;)fu(n,{errors:$,currentLocation:v+G,expectedLocation:v,distance:o,ignoreLocation:f})<=b?q=G:R=G,G=Math.floor((R-q)/2+q);R=G;let T=Math.max(1,v-G+1),H=d?y:Math.min(v+G,y)+x,L=Array(H+2);L[H+1]=(1<<$)-1;for(let ce=H;ce>=T;ce-=1){let re=ce-1,X=a[e.charAt(re)];if(k&&(N[re]=+!!X),L[ce]=(L[ce+1]<<1|1)&X,$&&(L[ce]|=(E[ce+1]|E[ce])<<1|1|E[ce+1]),L[ce]&I&&(_=fu(n,{errors:$,currentLocation:re,expectedLocation:v,distance:o,ignoreLocation:f}),_<=b)){if(b=_,j=re,j<=v)break;T=Math.max(1,2*v-j)}}if(fu(n,{errors:$+1,currentLocation:v,expectedLocation:v,distance:o,ignoreLocation:f})>b)break;E=L}const B={isMatch:j>=0,score:Math.max(.001,_)};if(k){const $=HN(N,h);$.length?m&&(B.indices=$):B.isMatch=!1}return B}function qN(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 Iu=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 nv{constructor(n,{location:a=st.location,threshold:i=st.threshold,distance:o=st.distance,includeMatches:u=st.includeMatches,findAllMatches:d=st.findAllMatches,minMatchCharLength:h=st.minMatchCharLength,isCaseSensitive:m=st.isCaseSensitive,ignoreDiacritics:f=st.ignoreDiacritics,ignoreLocation:x=st.ignoreLocation}={}){if(this.options={location:a,threshold:i,distance:o,includeMatches:u,findAllMatches:d,minMatchCharLength:h,isCaseSensitive:m,ignoreDiacritics:f,ignoreLocation:x},n=m?n:n.toLowerCase(),n=f?Iu(n):n,this.pattern=n,this.chunks=[],!this.pattern.length)return;const y=(b,j)=>{this.chunks.push({pattern:b,alphabet:qN(b),startIndex:j})},v=this.pattern.length;if(v>gi){let b=0;const j=v%gi,k=v-j;for(;b<k;)y(this.pattern.substr(b,gi),b),b+=gi;if(j){const N=v-gi;y(this.pattern.substr(N),N)}}else y(this.pattern,0)}searchIn(n){const{isCaseSensitive:a,ignoreDiacritics:i,includeMatches:o}=this.options;if(n=a?n:n.toLowerCase(),n=i?Iu(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:h,findAllMatches:m,minMatchCharLength:f,ignoreLocation:x}=this.options;let y=[],v=0,b=!1;this.chunks.forEach(({pattern:k,alphabet:N,startIndex:S})=>{const{isMatch:E,score:_,indices:R}=UN(n,k,N,{location:u+S,distance:d,threshold:h,findAllMatches:m,minMatchCharLength:f,includeMatches:o,ignoreLocation:x});E&&(b=!0),v+=_,E&&R&&(y=[...y,...R])});let j={isMatch:b,score:b?v/this.chunks.length:1};return b&&o&&(j.indices=y),j}}class Il{constructor(n){this.pattern=n}static isMultiMatch(n){return Iy(n,this.multiRegex)}static isSingleMatch(n){return Iy(n,this.singleRegex)}search(){}}function Iy(e,n){const a=e.match(n);return a?a[1]:null}class YN extends Il{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 XN extends Il{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 WN extends Il{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 VN extends Il{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 GN extends Il{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 KN extends Il{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 rv extends Il{constructor(n,{location:a=st.location,threshold:i=st.threshold,distance:o=st.distance,includeMatches:u=st.includeMatches,findAllMatches:d=st.findAllMatches,minMatchCharLength:h=st.minMatchCharLength,isCaseSensitive:m=st.isCaseSensitive,ignoreDiacritics:f=st.ignoreDiacritics,ignoreLocation:x=st.ignoreLocation}={}){super(n),this._bitapSearch=new nv(n,{location:a,threshold:i,distance:o,includeMatches:u,findAllMatches:d,minMatchCharLength:h,isCaseSensitive:m,ignoreDiacritics:f,ignoreLocation:x})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(n){return this._bitapSearch.searchIn(n)}}class av extends Il{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 im=[YN,av,WN,VN,KN,GN,XN,rv],Hy=im.length,QN=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,PN="|";function ZN(e,n={}){return e.split(PN).map(a=>{let i=a.trim().split(QN).filter(u=>u&&!!u.trim()),o=[];for(let u=0,d=i.length;u<d;u+=1){const h=i[u];let m=!1,f=-1;for(;!m&&++f<Hy;){const x=im[f];let y=x.isMultiMatch(h);y&&(o.push(new x(y,n)),m=!0)}if(!m)for(f=-1;++f<Hy;){const x=im[f];let y=x.isSingleMatch(h);if(y){o.push(new x(y,n));break}}}return o})}const JN=new Set([rv.type,av.type]);class eE{constructor(n,{isCaseSensitive:a=st.isCaseSensitive,ignoreDiacritics:i=st.ignoreDiacritics,includeMatches:o=st.includeMatches,minMatchCharLength:u=st.minMatchCharLength,ignoreLocation:d=st.ignoreLocation,findAllMatches:h=st.findAllMatches,location:m=st.location,threshold:f=st.threshold,distance:x=st.distance}={}){this.query=null,this.options={isCaseSensitive:a,ignoreDiacritics:i,includeMatches:o,minMatchCharLength:u,findAllMatches:h,ignoreLocation:d,location:m,threshold:f,distance:x},n=a?n:n.toLowerCase(),n=i?Iu(n):n,this.pattern=n,this.query=ZN(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?Iu(n):n;let d=0,h=[],m=0;for(let f=0,x=a.length;f<x;f+=1){const y=a[f];h.length=0,d=0;for(let v=0,b=y.length;v<b;v+=1){const j=y[v],{isMatch:k,indices:N,score:S}=j.search(n);if(k){if(d+=1,m+=S,i){const E=j.constructor.type;JN.has(E)?h=[...h,...N]:h.push(N)}}else{m=0,d=0,h.length=0;break}}if(d){let v={isMatch:!0,score:m/d};return i&&(v.indices=h),v}}return{isMatch:!1,score:1}}}const sm=[];function tE(...e){sm.push(...e)}function om(e,n){for(let a=0,i=sm.length;a<i;a+=1){let o=sm[a];if(o.condition(e,n))return new o(e,n)}return new nv(e,n)}const Hu={AND:"$and",OR:"$or"},cm={PATH:"$path",PATTERN:"$val"},um=e=>!!(e[Hu.AND]||e[Hu.OR]),nE=e=>!!e[cm.PATH],rE=e=>!Za(e)&&Zb(e)&&!um(e),Uy=e=>({[Hu.AND]:Object.keys(e).map(n=>({[n]:e[n]}))});function lv(e,n,{auto:a=!0}={}){const i=o=>{let u=Object.keys(o);const d=nE(o);if(!d&&u.length>1&&!um(o))return i(Uy(o));if(rE(o)){const m=d?o[cm.PATH]:u[0],f=d?o[cm.PATTERN]:o[m];if(!Sa(f))throw new Error(AN(m));const x={keyId:lm(m),pattern:f};return a&&(x.searcher=om(f,n)),x}let h={children:[],operator:u[0]};return u.forEach(m=>{const f=o[m];Za(f)&&f.forEach(x=>{h.children.push(i(x))})}),h};return um(e)||(e=Uy(e)),i(e)}function aE(e,{ignoreFieldNorm:n=st.ignoreFieldNorm}){e.forEach(a=>{let i=1;a.matches.forEach(({key:o,norm:u,score:d})=>{const h=o?o.weight:null;i*=Math.pow(d===0&&h?Number.EPSILON:d,(h||1)*(n?1:u))}),a.score=i})}function lE(e,n){const a=e.matches;n.matches=[],Dr(a)&&a.forEach(i=>{if(!Dr(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 iE(e,n){n.score=e.score}function sE(e,n,{includeMatches:a=st.includeMatches,includeScore:i=st.includeScore}={}){const o=[];return a&&o.push(lE),i&&o.push(iE),e.map(u=>{const{idx:d}=u,h={item:n[d],refIndex:d};return o.length&&o.forEach(m=>{m(u,h)}),h})}class ks{constructor(n,a={},i){this.options={...st,...a},this.options.useExtendedSearch,this._keyStore=new MN(this.options.keys),this.setCollection(n,i)}setCollection(n,a){if(this._docs=n,a&&!(a instanceof Xm))throw new Error(EN);this._myIndex=a||tv(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(n){Dr(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:h}=this.options;let m=Sa(n)?Sa(this._docs[0])?this._searchStringList(n):this._searchObjectList(n):this._searchLogical(n);return aE(m,{ignoreFieldNorm:h}),u&&m.sort(d),Pb(a)&&a>-1&&(m=m.slice(0,a)),sE(m,this._docs,{includeMatches:i,includeScore:o})}_searchStringList(n){const a=om(n,this.options),{records:i}=this._myIndex,o=[];return i.forEach(({v:u,i:d,n:h})=>{if(!Dr(u))return;const{isMatch:m,score:f,indices:x}=a.searchIn(u);m&&o.push({item:u,idx:d,matches:[{score:f,value:u,norm:h,indices:x}]})}),o}_searchLogical(n){const a=lv(n,this.options),i=(h,m,f)=>{if(!h.children){const{keyId:y,searcher:v}=h,b=this._findMatches({key:this._keyStore.get(y),value:this._myIndex.getValueForItemAtKeyId(m,y),searcher:v});return b&&b.length?[{idx:f,item:m,matches:b}]:[]}const x=[];for(let y=0,v=h.children.length;y<v;y+=1){const b=h.children[y],j=i(b,m,f);if(j.length)x.push(...j);else if(h.operator===Hu.AND)return[]}return x},o=this._myIndex.records,u={},d=[];return o.forEach(({$:h,i:m})=>{if(Dr(h)){let f=i(a,h,m);f.length&&(u[m]||(u[m]={idx:m,item:h,matches:[]},d.push(u[m])),f.forEach(({matches:x})=>{u[m].matches.push(...x)}))}}),d}_searchObjectList(n){const a=om(n,this.options),{keys:i,records:o}=this._myIndex,u=[];return o.forEach(({$:d,i:h})=>{if(!Dr(d))return;let m=[];i.forEach((f,x)=>{m.push(...this._findMatches({key:f,value:d[x],searcher:a}))}),m.length&&u.push({idx:h,item:d,matches:m})}),u}_findMatches({key:n,value:a,searcher:i}){if(!Dr(a))return[];let o=[];if(Za(a))a.forEach(({v:u,i:d,n:h})=>{if(!Dr(u))return;const{isMatch:m,score:f,indices:x}=i.searchIn(u);m&&o.push({score:f,key:n,value:u,idx:d,norm:h,indices:x})});else{const{v:u,n:d}=a,{isMatch:h,score:m,indices:f}=i.searchIn(u);h&&o.push({score:m,key:n,value:u,norm:d,indices:f})}return o}}ks.version="7.1.0";ks.createIndex=tv;ks.parseIndex=IN;ks.config=st;ks.parseQuery=lv;tE(eE);const la={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 oE(e){return la[e]??la.general}function cE(e){return e>1600?"macro":e<800?"micro":"standard"}function uE(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 h=o.length;a.push({domain:i,count:h,centerX:u/h,centerY:d/h,nodes:o})}return a}function dE(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 fE(e,n,a){const i=[...new Set(a.map(m=>m.category||"general"))],o=new Map,u=e/2,d=n/2,h=Math.min(e,n)*.3;return i.forEach((m,f)=>{const x=2*Math.PI*f/i.length-Math.PI/2;o.set(m,{x:u+h*Math.cos(x),y:d+h*Math.sin(x)})}),o}function hE(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 mE(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,h=Math.sqrt(u*u+d*d);h>a&&(a=h)}const i=Math.max(40,n.count*8);return{...n,radius:a+i}})}function pE(e,n,a,i){if(!e)return a;const o=new Set([e]),u=new Set;let d=new Set([e]);for(let h=0;h<i;h++){const m=new Set;for(const f of d)if(!u.has(f)){u.add(f);for(const x of n){const y=typeof x.source=="string"?x.source:x.source.id,v=typeof x.target=="string"?x.target:x.target.id;y===f&&!o.has(v)&&(o.add(v),m.add(v)),v===f&&!o.has(y)&&(o.add(y),m.add(y))}}d=m}return o}function xE({docs:e,onNodeClick:n,selectedDocId:a,matchedIds:i,localGraphMode:o,onLocalModeChange:u}){var ee;const d=w.useRef(null),h=w.useRef(null),[m,f]=w.useState({width:600,height:400}),[x,y]=w.useState({nodes:[],links:[]}),[v,b]=w.useState(null),[j,k]=w.useState(null),[N,S]=w.useState({x:0,y:0}),[E,_]=w.useState({x:0,y:0,w:600,h:400}),R=w.useRef(!1),I=w.useRef({x:0,y:0,vx:0,vy:0}),B=w.useRef(null),$=w.useRef(null),q=w.useMemo(()=>cE(E.w),[E.w]),G=w.useMemo(()=>uE(x.nodes),[x.nodes]),T=w.useMemo(()=>mE(G),[G]),H=w.useMemo(()=>{if(o==="global"||!a)return null;const Z=new Set(x.nodes.map(F=>F.id)),D=o==="1-hop"?1:2;return pE(a,x.links,Z,D)},[o,a,x.nodes,x.links]);w.useEffect(()=>{const Z=d.current;if(!Z)return;const D=new ResizeObserver(F=>{const{width:W,height:A}=F[0].contentRect;W>0&&A>0&&(f({width:W,height:A}),_(Q=>({...Q,w:W,h:A})))});return D.observe(Z),()=>D.disconnect()},[]),w.useEffect(()=>{if(e.length===0)return;const Z=new Set(e.map(Fe=>Fe.id)),D=e.map(Fe=>({id:Fe.id,title:Fe.title,category:Fe.category,akb_type:Fe.akb_type,tldr:Fe.tldr,tags:Fe.tags})),F=(Fe,ct)=>{if(!ct.startsWith(".")&&!ct.startsWith("/"))return ct;const Ke=Fe.split("/");Ke.pop();const ot=ct.split("/");for(const xt of ot)xt===".."?Ke.pop():xt!=="."&&xt!==""&&Ke.push(xt);return Ke.join("/")},W=[];for(const Fe of e)for(const ct of Fe.links){const Ke=F(Fe.id,ct.href);Z.has(Ke)&&Ke!==Fe.id&&(W.some(ot=>ot.source===Fe.id&&ot.target===Ke||ot.source===Ke&&ot.target===Fe.id)||W.push({source:Fe.id,target:Ke,label:ct.text}))}const{width:A,height:Q}=m,ie=D.length,he=ie>100?-600:ie>50?-500:-400,Ne=ie>100?180:ie>50?160:140,Ie=ie>100?60:50,de=Math.max(A,ie*12),_e=Math.max(Q,ie*10),Ye=fE(de,_e,D),ge=wN(D).force("link",iN(W).id(Fe=>Fe.id).distance(Ne)).force("charge",kN().strength(he)).force("center",$C(de/2,_e/2)).force("collide",aN(Ie)).force("cluster",hE(Ye,.15));$.current=ge,ge.on("tick",()=>{y({nodes:[...D],links:[...W]})}),ge.alpha(1).restart();const Je=ie>100?300:150;for(let Fe=0;Fe<Je;Fe++)ge.tick();if(ge.stop(),y({nodes:[...D],links:[...W]}),D.length>0){let Fe=1/0,ct=1/0,Ke=-1/0,ot=-1/0;for(const wt of D){const bt=wt.x??0,dt=wt.y??0;bt<Fe&&(Fe=bt),dt<ct&&(ct=dt),bt>Ke&&(Ke=bt),dt>ot&&(ot=dt)}const xt=100;_({x:Fe-xt,y:ct-xt,w:Math.max(A,Ke-Fe+xt*2),h:Math.max(Q,ot-ct+xt*2)})}return()=>{ge.stop()}},[e,m]);const L=Z=>{if(typeof Z=="string"){const D=x.nodes.find(F=>F.id===Z);return{x:(D==null?void 0:D.x)??0,y:(D==null?void 0:D.y)??0}}return{x:Z.x??0,y:Z.y??0}},J=w.useCallback(Z=>{Z.preventDefault();const D=Z.deltaY>0?1.1:.9;_(F=>{const W=Math.max(200,Math.min(m.width*3,F.w*D)),A=Math.max(150,Math.min(m.height*3,F.h*D)),Q=(W-F.w)/2,ie=(A-F.h)/2;return{x:F.x-Q,y:F.y-ie,w:W,h:A}})},[m]),ce=w.useCallback(Z=>{Z.button===0&&(R.current=!0,I.current={x:Z.clientX,y:Z.clientY,vx:E.x,vy:E.y})},[E]),re=w.useCallback(Z=>{var D;if(B.current){const F=h.current;if(!F)return;const W=F.getBoundingClientRect(),A=E.w/W.width,Q=E.h/W.height,ie=E.x+(Z.clientX-W.left)*A,he=E.y+(Z.clientY-W.top)*Q;B.current.fx=ie,B.current.fy=he,(D=$.current)==null||D.alpha(.3).restart();return}if(R.current){const F=(Z.clientX-I.current.x)*(E.w/m.width),W=(Z.clientY-I.current.y)*(E.h/m.height);_(A=>({...A,x:I.current.vx-F,y:I.current.vy-W}))}},[E,m]),X=w.useCallback(()=>{R.current=!1,B.current&&(B.current.fx=null,B.current.fy=null,B.current=null)},[]),le=w.useCallback((Z,D)=>{var F;Z.stopPropagation(),B.current=D,(F=$.current)==null||F.alpha(.3).restart()},[]);return l.jsxs("div",{ref:d,className:"relative flex-1 overflow-hidden",style:{background:"#1e1e2e"},children:[l.jsxs("svg",{ref:h,width:m.width,height:m.height,viewBox:`${E.x} ${E.y} ${E.w} ${E.h}`,style:{display:"block",cursor:R.current?"grabbing":"grab"},onWheel:J,onMouseDown:ce,onMouseMove:re,onMouseUp:X,onMouseLeave:X,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:E.x-100,y:E.y-100,width:E.w+200,height:E.h+200,fill:"url(#grid)",pointerEvents:"none"}),q==="macro"&&l.jsx("g",{className:"macro-clusters",style:{transition:"opacity 0.3s ease"},children:G.map(Z=>{const D=la[Z.domain]??la.general,F=Math.max(40,Math.sqrt(Z.count)*25),A=i===null||Z.nodes.some(Q=>i.has(Q.id))?1:.2;return l.jsxs("g",{transform:`translate(${Z.centerX}, ${Z.centerY})`,style:{cursor:"pointer",opacity:A,transition:"opacity 0.3s ease"},onMouseEnter:Q=>{var he;const ie=(he=d.current)==null?void 0:he.getBoundingClientRect();ie&&S({x:Q.clientX-ie.left,y:Q.clientY-ie.top}),b({id:`cluster-${Z.domain}`,title:`${Z.domain} (${Z.count})`,category:Z.domain,akb_type:"hub"})},onMouseLeave:()=>b(null),children:[l.jsx("circle",{r:F,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:Z.domain}),l.jsxs("text",{y:20,textAnchor:"middle",dominantBaseline:"middle",fill:D.text,fontSize:12,fontFamily:"monospace",opacity:.8,style:{pointerEvents:"none"},children:["(",Z.count,")"]})]},Z.domain)})}),q!=="macro"&&l.jsxs(l.Fragment,{children:[q==="standard"&&T.map(Z=>{const D=la[Z.domain]??la.general;if(Z.count<2)return null;const F=i===null||Z.nodes.some(A=>i.has(A.id)),W=F?.08:.02;return l.jsxs("g",{children:[l.jsx("circle",{cx:Z.centerX,cy:Z.centerY,r:Z.radius,fill:D.bg,stroke:D.border,strokeWidth:1,strokeDasharray:"6 4",opacity:W,style:{transition:"opacity 0.3s ease"},pointerEvents:"none"}),l.jsxs("text",{x:Z.centerX,y:Z.centerY-Z.radius-8,textAnchor:"middle",fill:D.text,fontSize:10,fontFamily:"monospace",fontWeight:"600",opacity:F?.6:.2,style:{pointerEvents:"none",transition:"opacity 0.3s ease"},children:[Z.domain," (",Z.count,")"]})]},`cluster-bg-${Z.domain}`)}),x.links.map((Z,D)=>{const F=L(Z.source),W=L(Z.target),A=j===D,Q=(F.x+W.x)/2,ie=(F.y+W.y)/2,he=typeof Z.source=="string"?Z.source:Z.source.id,Ne=typeof Z.target=="string"?Z.target:Z.target.id,de=H===null||H.has(he)&&H.has(Ne)?1:.1;return l.jsxs("g",{style:{opacity:de,transition:"opacity 0.3s ease"},children:[l.jsx("line",{x1:F.x,y1:F.y,x2:W.x,y2:W.y,stroke:"transparent",strokeWidth:12,style:{cursor:"default"},onMouseEnter:()=>k(D),onMouseLeave:()=>k(null)}),l.jsx("line",{x1:F.x,y1:F.y,x2:W.x,y2:W.y,stroke:A?"rgba(148,163,184,0.7)":"rgba(148,163,184,0.3)",strokeWidth:A?2:1.5,strokeDasharray:"4 3",pointerEvents:"none"}),A&&Z.label&&l.jsx("text",{x:Q,y:ie-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:Z.label.length>30?Z.label.slice(0,28)+"..":Z.label})})]},D)}),x.nodes.map(Z=>{const D=la[Z.category]??la.general,F=Z.akb_type==="hub",W=F?24:16,A=q==="micro"?W*1.5:W,Q=(v==null?void 0:v.id)===Z.id,ie=a===Z.id,he=Q?1.1:ie?1.05:1,Ne=i===null||i.has(Z.id),Ie=H===null||H.has(Z.id),de=Ne&&Ie?1:.15,_e=q==="micro"?dE(Z.tldr,50):"",Ye=q==="micro"&&Z.tags?Z.tags.slice(0,3):[];return l.jsxs("g",{transform:`translate(${Z.x??0}, ${Z.y??0}) scale(${he})`,style:{cursor:"pointer",transition:"transform 0.2s ease, opacity 0.3s ease",opacity:de},onClick:ge=>{ge.stopPropagation();const Je=e.find(Fe=>Fe.id===Z.id);Je&&n(Je)},onMouseDown:ge=>le(ge,Z),onMouseEnter:ge=>{var Fe;b(Z);const Je=(Fe=d.current)==null?void 0:Fe.getBoundingClientRect();Je&&S({x:ge.clientX-Je.left,y:ge.clientY-Je.top})},onMouseLeave:()=>b(null),children:[ie&&l.jsx("rect",{x:-A/2-4,y:-A/2-4,width:A+8,height:A+8,fill:"none",stroke:"#22c55e",strokeWidth:2,rx:F?5:2,opacity:.6}),l.jsx("rect",{x:-A/2,y:-A/2,width:A,height:A,fill:D.border,rx:F?4:2,opacity:Q?1:.9}),l.jsx("rect",{x:-A/2+3,y:-A/2+3,width:Math.max(0,A-6),height:Math.max(0,A-6),fill:D.bg,rx:F?3:1}),l.jsx("text",{y:A/2+14,textAnchor:"middle",fill:ie?"#e2e8f0":"#94a3b8",fontSize:q==="micro"?10:11,fontFamily:"monospace",fontWeight:ie?"bold":"normal",style:{pointerEvents:"none"},children:Z.title.length>24?Z.title.slice(0,22)+"..":Z.title}),q==="micro"&&_e&&l.jsx("text",{y:A/2+28,textAnchor:"middle",fill:"#94a3b8",fontSize:8,fontFamily:"system-ui, sans-serif",opacity:.7,style:{pointerEvents:"none"},children:_e}),q==="micro"&&Ye.length>0&&l.jsx("g",{transform:`translate(0, ${A/2+(_e?42:28)})`,children:Ye.map((ge,Je)=>{const Fe=ge.length*5+8;let Ke=-Ye.reduce((ot,xt)=>ot+xt.length*5+10,0)/2;for(let ot=0;ot<Je;ot++)Ke+=Ye[ot].length*5+10;return l.jsxs("g",{transform:`translate(${Ke+Fe/2}, 0)`,children:[l.jsx("rect",{x:-Fe/2,y:-6,width:Fe,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:ge})]},ge)})})]},Z.id)})]})]}),v&&!B.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:[((ee=e.find(Z=>Z.id===v.id))==null?void 0:ee.tldr)&&l.jsx("div",{className:"text-[10px] opacity-80 mb-1",children:e.find(Z=>Z.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:q==="macro"?"#f59e0b":q==="micro"?"#22c55e":"#94a3b8",transition:"color 0.3s ease"},children:[q==="macro"&&"📍 Overview",q==="standard"&&"📍 Standard",q==="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(Z=>{const D=o===Z,F=Z!=="global"&&!a,W=Z==="global"?"🌐 All":Z==="1-hop"?"1-hop":"2-hop";return l.jsx("button",{onClick:()=>!F&&u(Z),disabled:F,className:"px-2 py-1 text-[10px] font-medium cursor-pointer transition-all",style:{background:D?"rgba(22,163,106,0.3)":"transparent",color:F?"var(--terminal-text-muted)":D?"#4ade80":"var(--terminal-text-secondary)",opacity:F?.4:1,cursor:F?"not-allowed":"pointer"},title:F?"Select a node first":`Show ${Z==="global"?"all nodes":`nodes within ${Z}`}`,children:W},Z)})}),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 yE(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,h="";for(let m=0;m<u.length-1;m++)if(h=h?`${h}/${u[m]}`:u[m],a.has(h))d=a.get(h).children;else{const f={type:"folder",name:u[m],path:h,children:[]};a.set(h,f),d.push(f),d=f.children}d.push({type:"file",name:u[u.length-1],path:o.id,doc:o})}),n}function gE({docs:e,onDocumentClick:n,selectedDocId:a,matchedIds:i}){const[o,u]=w.useState(new Set(["knowledge","projects","architecture","operations","company"])),[d,h]=w.useState(null),m=w.useMemo(()=>yE(e),[e]),f=b=>{u(j=>{const k=new Set(j);return k.has(b)?k.delete(b):k.add(b),k})},x=b=>{h(b),n(b)},y=()=>{h(null),n(null)},v=d?e.find(b=>b.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"}),m.map(b=>l.jsx(iv,{node:b,level:0,expandedFolders:o,selectedDocId:a,viewingDocId:d,onToggleFolder:f,onFileClick:x,matchedIds:i},b.path))]}),l.jsx("div",{className:"flex-1 overflow-y-auto",children:v?l.jsx(vE,{doc:v,onClose:y}):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 iv({node:e,level:n,expandedFolders:a,selectedDocId:i,viewingDocId:o,onToggleFolder:u,onFileClick:d,matchedIds:h}){var b,j,k;const m=a.has(e.path),f=e.type==="file"&&e.path===i,x=e.type==="file"&&e.path===o,y=((b=e.doc)==null?void 0:b.akb_type)==="hub",v=e.type==="folder"||h===null||h.has(e.path);if(e.type==="folder"){const N=h===null||(((j=e.children)==null?void 0:j.some(S=>{if(S.type==="file")return h.has(S.path);const E=_=>{var R;return _.type==="file"?h.has(_.path):((R=_.children)==null?void 0:R.some(E))??!1};return E(S)}))??!1);return l.jsxs("div",{style:{opacity:N?1:.3,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(S=>l.jsx(iv,{node:S,level:n+1,expandedFolders:a,selectedDocId:i,viewingDocId:o,onToggleFolder:u,onFileClick:d,matchedIds:h},S.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":f?"bg-white/10":"hover:bg-white/5"}`,style:{paddingLeft:n*12+4,opacity:v?1:.2,transition:"opacity 0.2s ease"},onClick:()=>d(e.path),children:[l.jsx("span",{className:"text-[10px]",children:y?"📘":"📄"}),l.jsx("span",{className:`text-[11px] truncate ${y?"font-semibold":""}`,style:{color:y?"#16a34a":"var(--terminal-text)"},children:e.name})]})}function bE(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,h=u[2].trim();let m=h.toLowerCase().replace(/[^a-z0-9가-힣\s-]/g,"").replace(/\s+/g,"-").slice(0,50);const f=i.get(m)||0;i.set(m,f+1);const x=f>0?`${m}-${f}`:m;a.push({id:x,text:h,level:d})}return a}function vE({doc:e,onClose:n}){const[a,i]=w.useState(null),[o,u]=w.useState(!1),[d,h]=w.useState(null),m=w.useRef(null),[f,x]=w.useState(null);w.useEffect(()=>{if("content"in e&&e.content){i(e);return}u(!0),h(null),ye.getKnowledgeDoc(e.id).then(i).catch(N=>h(N instanceof Error?N.message:"Failed to load")).finally(()=>u(!1))},[e]);const y=w.useMemo(()=>!a||e.format==="html"?[]:bE(a.content),[a,e.format]),v=N=>{if(!m.current)return;const S=m.current.querySelectorAll("h2, h3");for(const E of S){const R=(E.textContent||"").toLowerCase().replace(/[^a-z0-9가-힣\s-]/g,"").replace(/\s+/g,"-").slice(0,50);if(N.startsWith(R)){E.scrollIntoView({behavior:"smooth",block:"start"}),x(N);break}}},b=oE(e.category),j=e.akb_type==="hub",k=y.length>0&&!o&&!d;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.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:j?"📘":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(N=>l.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-medium",style:{background:b.bg,color:b.text,border:`1px solid ${b.border}`},children:N},N))})]})]}),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:m,className:"flex-1 overflow-y-auto p-4",children:[o&&l.jsx("div",{className:"text-xs",style:{color:"var(--terminal-text-muted)"},children:"Loading..."}),d&&l.jsx("div",{className:"text-xs p-2 rounded",style:{background:"rgba(239,68,68,0.15)",color:"#f87171"},children:d}),a&&l.jsx(Ho,{content:a.content})]}),k&&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:y.map(N=>l.jsx("button",{onClick:()=>v(N.id),className:"block w-full text-left text-[10px] py-1 px-2 rounded cursor-pointer hover:bg-white/5 transition-colors",style:{paddingLeft:(N.level-2)*8+8,color:f===N.id?"#4ade80":"var(--terminal-text-secondary)",fontWeight:f===N.id?"bold":"normal"},children:N.text.length>30?N.text.slice(0,28)+"..":N.text},N.id))})]})]})]})}const wE=500,qy=360,kE=700;function Uo(e,n,a){const i=n??wE,[o,u]=w.useState(i),[d,h]=w.useState(!1),m=w.useRef(0),f=w.useRef(0),x=w.useRef(a);x.current=a;const y=e>0,v=y?e:0,b=Math.max(kE,i),j=y?Math.max(qy,window.innerWidth-e-100):b,k=Math.min(o,j),N=w.useCallback(S=>{S.preventDefault(),m.current=S.clientX,f.current=k,h(!0);const E=()=>{h(!1),document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",E)},_=R=>{const I=m.current-R.clientX,B=f.current+I;if(B>=window.innerWidth*.6&&x.current){E(),x.current();return}const $=Math.min(b,Math.max(qy,B));u($)};document.addEventListener("mousemove",_),document.addEventListener("mouseup",E)},[k]);return{panelRight:v,panelWidth:k,isResizing:d,handleResizeStart:N}}function Yy({docs:e,onClose:n,onRefresh:a,terminalWidth:i=0,initialDocId:o,onMaximize:u}){const[d,h]=w.useState(()=>{const T=localStorage.getItem("kb-view-mode");return T==="graph"||T==="tree"||T==="list"?T:"graph"}),[m,f]=w.useState(null),[x,y]=w.useState("global"),[v,b]=w.useState(""),[j,k]=w.useState(()=>new Set(Object.keys(la)));w.useEffect(()=>{localStorage.setItem("kb-view-mode",d)},[d]);const N=w.useMemo(()=>new ks(e,{keys:["title","tldr","tags"],threshold:.3,includeScore:!0}),[e]),S=w.useMemo(()=>{let T=new Set(e.map(H=>H.id));if(v.trim()){const H=N.search(v);T=new Set(H.map(L=>L.item.id))}return T=new Set(Array.from(T).filter(H=>{const L=e.find(J=>J.id===H);return L&&j.has(L.category)})),T.size===e.length?null:T},[e,v,N,j]),E=w.useMemo(()=>S===null?e:e.filter(T=>S.has(T.id)),[e,S]),_=T=>{k(H=>{const L=new Set(H);return L.has(T)?L.delete(T):L.add(T),L})},{panelRight:R,panelWidth:I,isResizing:B,handleResizeStart:$}=Uo(i,void 0,u),q=T=>{f(T.id)},G=m?e.find(T=>T.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)] ${B?"resizing":""}`,style:{right:R,width:I,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 ${B?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:$}),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(Sh,{icon:"🕸️",label:"Graph",active:d==="graph",onClick:()=>h("graph")}),l.jsx(Sh,{icon:"🌲",label:"Tree",active:d==="tree",onClick:()=>{h("tree"),f(null)}}),l.jsx(Sh,{icon:"📋",label:"List",active:d==="list",onClick:()=>{h("list"),f(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:T=>b(T.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(la).map(([T,H])=>{const L=j.has(T);return l.jsx("button",{onClick:()=>_(T),className:"px-2 py-1 text-[10px] font-medium rounded cursor-pointer transition-all",style:{background:L?H.bg:"transparent",color:L?H.text:"var(--terminal-text-muted)",border:`1px solid ${L?H.border:"var(--terminal-border)"}`,opacity:L?1:.5},children:T},T)})}),l.jsx("div",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:E.length===e.length?`${e.length} documents`:`${E.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(xE,{docs:e,onNodeClick:q,selectedDocId:m,matchedIds:S,localGraphMode:x,onLocalModeChange:y}),G&&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:G.title}),l.jsx("div",{className:"w-2 h-2 rounded-full mb-2",style:{background:G.status==="active"?"#16a34a":G.status==="draft"?"#f59e0b":"#94a3b8"}}),G.tldr&&l.jsx("div",{className:"text-[10px] mb-2 leading-relaxed",style:{color:"var(--terminal-text-secondary)"},children:G.tldr}),G.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"}),G.links.slice(0,5).map((T,H)=>l.jsxs("div",{className:"text-[9px] mb-0.5 truncate",style:{color:"var(--terminal-text-secondary)"},children:["🔗"," ",T.text]},H))]})]})]}),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(la).map(([T,H])=>l.jsxs("div",{className:"flex items-center gap-1 text-[9px]",children:[l.jsx("div",{className:"w-2 h-2",style:{background:H.border}}),l.jsx("span",{style:{color:"var(--terminal-text-muted)"},children:T})]},T))})})]}),d==="tree"&&l.jsx(gE,{docs:e,onDocumentClick:T=>f(T),selectedDocId:m,matchedIds:S}),d==="list"&&l.jsx(jE,{icon:"📋",title:"List View",message:"Coming soon in KB-002",description:"Table format with sortable columns and quick scanning"})]})]})}function Sh({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 jE({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 Xy({standups:e,waves:n,decisions:a,mode:i,onClose:o,onOpenWaveCenter:u,terminalWidth:d=0,onMaximize:h}){const[m,f]=w.useState(i==="decisions"?"decisions":"standups"),{panelRight:x,panelWidth:y,isResizing:v,handleResizeStart:b}=Uo(d,void 0,h);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:x},onClick:o}),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)] ${v?"resizing":""}`,style:{right:x,width:y,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 ${v?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:b}),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:[h&&l.jsx("button",{onClick:h,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:o,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.jsx("div",{className:"text-lg font-bold",children:i==="bulletin"?"📌 Bulletin Board":"📜 Decision Log"})]}),l.jsx("div",{className:"flex",style:{borderBottom:"1px solid var(--terminal-border)"},children:i==="bulletin"?l.jsxs(l.Fragment,{children:[l.jsx(hu,{label:`Standups (${e.length})`,active:m==="standups",onClick:()=>f("standups")}),u?l.jsx(hu,{label:"Waves →",active:!1,onClick:u}):l.jsx(hu,{label:`Waves (${n.length})`,active:m==="waves",onClick:()=>f("waves")})]}):l.jsx(hu,{label:`Decisions (${a.length})`,active:m==="decisions",onClick:()=>f("decisions")})}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[m==="standups"&&e.map((j,k)=>l.jsx(Ch,{title:`Standup ${j.date}`,content:j.content},k)),m==="waves"&&n.map((j,k)=>l.jsx(Ch,{title:`Wave ${j.id}`,subtitle:j.startedAt,content:j.directive},k)),m==="decisions"&&a.map((j,k)=>l.jsx(Ch,{title:`#${j.id} ${j.title}`,subtitle:j.date,content:j.content},k))]})]})]})}function hu({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 SE(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 Ch({title:e,subtitle:n,content:a}){const[i,o]=w.useState(!1),u=a.length>100,d=SE(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(Ho,{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 ys=[{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"}}],Uu=[{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"]}],CE={completedQuests:[],activeChapter:1,sideQuestsCompleted:[]};function Wy(){return{...CE}}function dm(e,n){return n.completedQuests.includes(e.id)?"completed":"active"}function sv(e){const n=Uu.find(a=>a.num===e.activeChapter);return n?ys.filter(a=>n.questIds.includes(a.id)&&dm(a,e)==="active"):[]}function NE(e){return sv(e)[0]??null}function EE(e,n){const a=ys.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 Vy(e){let n=1;for(const a of Uu)if(a.questIds.every(i=>e.completedQuests.includes(i))){const i=Uu.find(o=>o.num===a.num+1);i&&(n=i.num)}return n!==e.activeChapter?{...e,activeChapter:n}:e}function AE(e){const n=ys.filter(i=>i.type==="main").length;return{completed:e.completedQuests.filter(i=>{var o;return((o=ys.find(u=>u.id===i))==null?void 0:o.type)==="main"}).length,total:n}}function DE(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 TE({progress:e,onQuestAction:n,onClose:a,terminalWidth:i=0}){const{completed:o,total:u}=AE(e),d=u>0?Math.round(o/u*100):0,{panelRight:h,panelWidth:m,isResizing:f,handleResizeStart:x}=Uo(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:h},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)] ${f?"resizing":""}`,style:{right:h,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 ${f?"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:Uu.map(y=>{const v=ys.filter(k=>y.questIds.includes(k.id)),b=v.every(k=>e.completedQuests.includes(k.id)),j=v.some(k=>dm(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 ",y.num,": ",y.title]})]}),l.jsx("div",{className:"px-3 pb-2 flex flex-col gap-1.5",children:v.map(k=>{const N=dm(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)})})]},y.num)})})]})]})}function FE({projectId:e,onClose:n,terminalWidth:a=0}){const[i,o]=w.useState(null),{panelRight:u,panelWidth:d,isResizing:h,handleResizeStart:m}=Uo(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 f=i.tasks.filter(v=>v.status==="done").length,x=i.tasks.length,y=x>0?Math.round(f/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)] ${h?"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 ${h?"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: ",f]}),l.jsxs("span",{children:["Progress: ",y,"%"]})]}),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:`${y}%`}})})]}),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(Ho,{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(ME,{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 ME({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 RE={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"};function zE({roleId:e,roleName:n,mode:a="assign",onClose:i,onExecutionStart:o}){const[u,d]=w.useState(""),h=w.useRef(null);w.useEffect(()=>{var y;(y=h.current)==null||y.focus()},[]);const m=()=>{u.trim()&&(o(e,u.trim()),i())},f=y=>{y.key==="Enter"&&(y.metaKey||y.ctrlKey)&&m(),y.key==="Escape"&&i()},x=RE[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:h,value:u,onChange:y=>d(y.target.value),onKeyDown:f,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 Gy={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"};function Pu({event:e,isThinkingCollapsed:n,onToggleThinking:a,onNavigateToJob:i,onOpenKnowledgeDoc:o,compact:u}){var h;const d=Gy[e.roleId]??"#888";switch(e.type){case"text":{const m=e.data.text??"",f=u?m.slice(0,300):m;return/[#*|`\[\]_~>-]/.test(f)?l.jsx("div",{className:"text-green-300/90 leading-relaxed event-markdown",children:l.jsx(_m,{remarkPlugins:[$m],children:f})}):l.jsx("div",{className:"text-green-300/90 whitespace-pre-wrap leading-relaxed",children:f})}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??""),f=e.data.input,x=typeof(f==null?void 0:f.command)=="string"?f.command.slice(0,80):"",y=typeof(f==null?void 0:f.file_path)=="string"?String(f.file_path):typeof(f==null?void 0:f.path)=="string"?String(f.path):"",v=y?y.split("/").pop()??"":"",b=/^(write_file|Write|edit_file|Edit)$/i.test(m),j=(h=y.match(/(?:^|\/)knowledge\/(.+\.md)$/))==null?void 0:h[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??"",f=e.data.task??"",x=e.data.childJobId,y=Gy[m]??"#888";return l.jsx("div",{className:"my-1 p-2 rounded-lg border cursor-pointer hover:opacity-90 transition-opacity",style:{borderColor:`${y}44`,background:`${y}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:y},className:"font-bold text-[11px]",children:["→"," ",m.toUpperCase()]}),l.jsx("span",{className:"text-[var(--terminal-text-secondary)] text-[10px] truncate flex-1",children:f.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,f=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 · ",f," 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 _E({sessionId:e,title:n,color:a,variant:i,style:o,onClose:u,onMinimize:d,onDone:h,onNavigateToJob:m,onOpenKnowledgeDoc:f}){const{events:x,status:y,textOutput:v,childJobIds:b}=Fg(e),[j,k]=w.useState(0),[N,S]=w.useState(new Set),E=w.useRef(null),_=w.useRef(Date.now()),R=w.useRef(!1);w.useEffect(()=>{const H=setInterval(()=>{k(Math.floor((Date.now()-_.current)/1e3))},1e3);return()=>clearInterval(H)},[]),w.useEffect(()=>{E.current&&(E.current.scrollTop=E.current.scrollHeight)},[x]),w.useEffect(()=>{(y==="done"||y==="error")&&!R.current&&(R.current=!0,h==null||h())},[y,h]);const I=H=>{S(L=>{const J=new Set(L);return J.has(H)?J.delete(H):J.add(H),J})},B={idle:"Waiting",connecting:"Connecting...",streaming:"Working",done:"Complete",error:"Error"}[y],$={idle:"#888",connecting:"#888",streaming:a,done:"#2E7D32",error:"#C62828"}[y],q=H=>`${Math.floor(H/60)}:${String(H%60).padStart(2,"0")}`,G=y==="done"||y==="error",T=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:$}}),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:q(j)}),l.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full font-semibold",style:{background:`${$}22`,color:$},children:B}),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:"–"}),G&&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:E,className:"flex-1 overflow-y-auto p-4 space-y-1 text-xs font-mono",children:[x.length===0&&y==="connecting"&&l.jsx("div",{className:"text-[var(--terminal-text-muted)]",children:"Connecting to activity stream..."}),x.map(H=>l.jsx(Pu,{event:H,isThinkingCollapsed:N.has(H.seq),onToggleThinking:()=>I(H.seq),onNavigateToJob:m,onOpenKnowledgeDoc:f},H.seq)),y==="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`]}),G&&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:G?u:void 0}),T]}):T}const BE={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function ov({orgNodes:e,rootId:n,activeRoles:a,onToggleRole:i}){const o=e[n];if(!o)return null;const u=!!a&&!!i,h=o.children.map(b=>e[b]).filter(Boolean),m=new Map,f=[];for(const b of h){const j=[];for(const k of b.children){const N=e[k];N&&(j.push(N),f.push(N))}m.set(b.id,j)}const x=b=>!a||a.has(b),y=u?h.filter(b=>a.has(b.id)).length+f.filter(b=>a.has(b.id)).length:h.length+f.length,v=h.length+f.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:[y,"/",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"})}),h.length>0&&l.jsx("div",{className:"flex justify-center mb-1",children:l.jsx("div",{className:"w-px h-3 bg-white/15"})}),h.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(h.length*80,320)}px`}})}),l.jsx("div",{className:"flex justify-center gap-3 mb-2 flex-wrap",children:h.map(b=>{const j=x(b.id),k=BE[b.id]??"#888";return l.jsx(OE,{node:b,active:j,color:k,interactive:u,onToggle:i,subRoles:m.get(b.id)??[],activeRoles:a},b.id)})}),f.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:f.map(b=>{var E;const j=x(b.id),k=(E=h.find(_=>_.children.includes(b.id)))==null?void 0:E.id,N=k?x(k):!0,S=u&&N;return l.jsx("span",{className:`px-2 py-0.5 text-[9px] font-semibold rounded border uppercase transition-all ${S?"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:S?()=>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?`${y} role${y!==1?"s":""} will receive this wave`:`${v} role${v!==1?"s":""} will receive this wave`})]})}function OE({node:e,active:n,color:a,interactive:i,onToggle:o,subRoles:u,activeRoles:d}){const h=w.useCallback(m=>{if(!(!i||!o)){if(n){o(e.id,!1);for(const f of u)d!=null&&d.has(f.id)&&o(f.id,!1)}else if(o(e.id,!0),m.shiftKey)for(const f of u)d!=null&&d.has(f.id)||o(f.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:h,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 LE({cLevelRoles:e,orgNodes:n,rootId:a,onClose:i,onDispatch:o}){const[u,d]=w.useState(""),h=w.useRef(null),[m,f]=w.useState(()=>{const k=new Set,N=n[a];if(N)for(const S of N.children){k.add(S);const E=n[S];if(E)for(const _ of E.children)k.add(_)}return k});w.useEffect(()=>{var k;(k=h.current)==null||k.focus()},[]);const x=w.useCallback((k,N)=>{f(S=>{const E=new Set(S);return N?E.add(k):E.delete(k),E})},[]),y=e.filter(k=>m.has(k.id)).length,v=()=>{if(!u.trim()||y===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 E=m.size>=N?void 0:Array.from(m);o(u.trim(),E),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(ov,{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:h,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()||y===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 ",y," Role",y!==1?"s":""]})]})]})]})}function cv(e,n,a){const[i,o]=w.useState(new Map),[u,d]=w.useState(null),[h,m]=w.useState(new Set),f=w.useRef(new Map),x=w.useRef(i);x.current=i;const y=w.useCallback(()=>{if(!a||Object.keys(n).length===0)return null;const S=new Map,E=new Set,_=I=>{const B=n[I];B&&(E.add(I),S.set(I,{sessionId:"",roleId:I,roleName:B.name,children:B.children,status:"waiting",events:[],streamStatus:"idle"}),B.children.forEach(_))},R=n[a];return R&&(S.set(a,{sessionId:"",roleId:a,roleName:"CEO",children:R.children,status:"not-dispatched",events:[],streamStatus:"idle"}),R.children.forEach(_)),{initial:S,allRoles:E}},[n,a]);w.useEffect(()=>{const S=y();if(!S)return;const{initial:E,allRoles:_}=S;for(const R of e){const I=E.get(R.roleId);I&&(I.sessionId=R.sessionId,I.status="running",I.streamStatus="connecting")}o(E),m(R=>{if(R.size===0){const I=new Set(_);return I.delete(a),I}return R}),e.length>0&&!u&&d(e[0].roleId)},[e,n,a,y,u]);const v=w.useCallback(S=>{m(E=>{const _=new Set(E);return _.has(S)?_.delete(S):_.add(S),_})},[]),b=w.useCallback(S=>{for(const[,E]of f.current)E.controller.abort();f.current.clear(),o(S);for(const[E,_]of S)if(E!==a&&_.events.length>0){d(E);break}},[a]),j=w.useCallback((S,E)=>{console.log(`[WaveTree] connectStream → role=${E} session=${S}`);const _=f.current.get(S);_&&_.controller.abort(),o($=>{const q=new Map($),G=q.get(E);return G&&q.set(E,{...G,sessionId:S,status:"running",streamStatus:"connecting",events:[]}),q});const R=new AbortController,I={controller:R,lastSeq:-1};f.current.set(S,I);const B=`/api/sessions/${S}/stream?from=0`;fetch(B,{signal:R.signal}).then(async $=>{if(!$.ok||!$.body){o(H=>{const L=new Map(H),J=L.get(E);return J&&L.set(E,{...J,streamStatus:"error"}),L});return}o(H=>{const L=new Map(H),J=L.get(E);return J&&L.set(E,{...J,streamStatus:"streaming",status:"running"}),L});const q=$.body.getReader(),G=new TextDecoder;let T="";for(;;){const{done:H,value:L}=await q.read();if(H)break;T+=G.decode(L,{stream:!0});const J=T.split(`
83
- `);T=J.pop()??"";let ce="";for(const re of J)if(re.startsWith("event: "))ce=re.slice(7).trim();else if(re.startsWith("data: ")){try{const X=JSON.parse(re.slice(6));if(ce==="activity"){const le=X;le.seq>I.lastSeq&&(I.lastSeq=le.seq),o(ee=>{const Z=new Map(ee),D=Z.get(E);if(!D||D.events.some(W=>W.seq===le.seq))return ee;const F={...D,events:[...D.events,le]};if(le.type==="dispatch:start"&&le.data.childJobId){const W=le.data.targetRoleId??le.data.roleId,A=le.data.childSessionId;if(console.log(`[WaveTree] dispatch:start → target=${W} childSession=${A??"none"} from=${E}`),W&&A){const Q=Z.get(W);Q&&(Z.set(W,{...Q,sessionId:A,status:"running",streamStatus:"connecting"}),setTimeout(()=>j(A,W),0))}}return le.type==="job:done"?(F.status="done",F.streamStatus="done"):le.type==="job:error"?(F.status="error",F.streamStatus="error"):le.type==="job:awaiting_input"?(F.status="awaiting_input",F.streamStatus="done"):le.type==="job:reply"&&(F.status="running",F.streamStatus="streaming"),Z.set(E,F),Z})}else if(ce==="stream:end"){const le=X.reason;le!=="replied"&&o(ee=>{const Z=new Map(ee),D=Z.get(E);if(!D)return ee;const F=le==="error"?"error":le==="awaiting_input"?"awaiting_input":"done";return Z.set(E,{...D,status:D.status==="running"?F:D.status,streamStatus:F==="error"?"error":"done"}),Z})}}catch{}ce=""}}}).catch($=>{$.name!=="AbortError"&&o(q=>{const G=new Map(q),T=G.get(E);return T&&G.set(E,{...T,streamStatus:"error"}),G})})},[]);w.useEffect(()=>{if(e.length!==0){for(const S of e)j(S.sessionId,S.roleId);return()=>{for(const[,S]of f.current)S.controller.abort();f.current.clear()}}},[e,j]);const k=(()=>{let S=0,E=0,_=0,R=0;for(const[I,B]of i)I!==a&&(R++,B.status==="done"?S++:B.status==="running"?E++:B.status==="awaiting_input"&&_++);return{done:S,total:R,running:E,awaitingInput:_}})(),N=k.total>0&&k.running===0&&k.awaitingInput===0&&Array.from(i.values()).every(S=>S.status!=="running"&&S.status!=="awaiting_input"&&S.streamStatus!=="streaming"&&S.streamStatus!=="connecting");return w.useEffect(()=>{N&&o(S=>{const E=new Map(S);let _=!1;for(const[R,I]of E)I.status==="waiting"&&(E.set(R,{...I,status:"not-dispatched"}),_=!0);return _?E:S})},[N]),{nodes:i,selectedRoleId:u,selectNode:d,checkedRoles:h,toggleCheck:v,setCheckedRoles:m,progress:k,allDone:N,connectStream:j,injectStaticNodes:b}}const Ky={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"},ja=130,Yr=44,Qy=80;function $E(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:y,parentId:v}=u.shift();if(d.has(x))continue;for(d.add(x);o.length<=y;)o.push([]);o[y].push(x),i.push({roleId:x,x:0,y:y*Qy+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:y+1,parentId:x})}const h=Math.max(...o.map(x=>x.length))*(ja+16),m=Math.max(h,280);for(const x of o){const y=x.length*(ja+16)-16,v=(m-y)/2;x.forEach((b,j)=>{const k=i.find(N=>N.roleId===b);k&&(k.x=v+j*(ja+16))})}const f=o.length*Qy+40;return{layout:i,width:m,height:f}}function Wm({nodes:e,rootId:n,selectedRoleId:a,onSelectNode:i,checkedRoles:o,onToggleCheck:u}){const{layout:d,width:h,height:m}=$E(e,n),f=!!u,x=v=>{const b=d.find(j=>j.roleId===v);return b?{cx:b.x+ja/2,cy:b.y+Yr/2}:{cx:0,cy:0}},y=v=>{switch(v.status){case"running":return Ky[v.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 ${h} ${m}`,width:Math.max(h,280),height:m,className:"block",style:{minWidth:h},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"})]})]})}),d.filter(v=>v.parentId).map(v=>{const b=x(v.parentId),j=x(v.roleId),k=e.get(v.roleId),N=e.get(v.parentId);let S="rgba(180,200,240,0.15)",E="4 4",_="";return(k==null?void 0:k.status)==="done"||(N==null?void 0:N.status)==="done"?(S="#2E7D3266",E=""):(k==null?void 0:k.status)==="awaiting_input"?(S="#F59E0B",E="6 4",_="wave-edge-flow"):(k==null?void 0:k.status)==="running"&&(S=Ky[v.roleId]??"#FBBF24",E="6 4",_="wave-edge-flow"),l.jsx("line",{x1:b.cx,y1:b.cy+Yr/2-4,x2:j.cx,y2:j.cy-Yr/2+4,stroke:S,strokeWidth:1.5,strokeDasharray:E,className:_},`${v.parentId}-${v.roleId}`)}),d.map(v=>{const b=e.get(v.roleId);if(!b)return null;const j=y(b),k=a===v.roleId,N=v.roleId===n,S=(o==null?void 0:o.has(v.roleId))??!1,E=N?.4:b.status==="not-dispatched"&&!S?.35:1;return l.jsxs("g",{transform:`translate(${v.x}, ${v.y})`,style:{cursor:N?"default":"pointer",opacity:E},onClick:()=>!N&&i(v.roleId),children:[l.jsx("rect",{x:0,y:0,width:ja,height:Yr,rx:8,ry:8,fill:"var(--terminal-bg-deeper, #181825)",stroke:k?"#fff":S?"#EF5350":j,strokeWidth:k||S?2:1.5,strokeDasharray:b.status==="not-dispatched"&&!S?"4 3":""}),l.jsx("circle",{cx:14,cy:Yr/2,r:4,fill:j,filter:b.status==="running"||b.status==="awaiting_input"?"url(#glow)":void 0,children:(b.status==="running"||b.status==="awaiting_input")&&l.jsx("animate",{attributeName:"opacity",values:"1;0.4;1",dur:"1.5s",repeatCount:"indefinite"})}),l.jsx("text",{x:26,y:Yr/2-4,fill:"var(--terminal-text, #fff)",fontSize:10,fontWeight:700,fontFamily:"var(--pixel-font)",children:b.roleId.toUpperCase()}),l.jsx("text",{x:26,y:Yr/2+10,fill:"var(--terminal-text-muted, #888)",fontSize:8,fontFamily:"var(--pixel-font)",children:b.status==="running"?"Working...":b.status==="awaiting_input"?"Awaiting Reply":b.status==="done"?"Complete":b.status==="error"?"Error":b.status==="waiting"?"Waiting":""}),b.status==="done"&&!f&&l.jsx("text",{x:ja-18,y:Yr/2+4,fontSize:14,fill:"#2E7D32",children:"✓"}),b.status==="error"&&!f&&l.jsx("text",{x:ja-18,y:Yr/2+4,fontSize:14,fill:"#C62828",children:"✗"}),f&&!N&&l.jsxs("g",{onClick:_=>{_.stopPropagation(),u==null||u(v.roleId)},style:{cursor:"pointer"},children:[l.jsx("rect",{x:ja-24,y:Yr/2-10,width:20,height:20,fill:"transparent"}),l.jsx("rect",{x:ja-20,y:Yr/2-6,width:12,height:12,rx:2,ry:2,fill:S?"#EF5350":"transparent",stroke:S?"#EF5350":"#666",strokeWidth:1.5}),S&&l.jsx("text",{x:ja-18,y:Yr/2+4,fontSize:10,fontWeight:700,fill:"#fff",children:"✓"})]})]},v.roleId)})]})}const IE={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function HE({directive:e,rootJobs:n,orgNodes:a,rootRoleId:i,onClose:o,onMinimize:u,onDone:d,onOpenKnowledgeDoc:h,onSave:m}){const{nodes:f,selectedRoleId:x,selectNode:y,progress:v,allDone:b,connectStream:j}=cv(n,a,i),[k,N]=w.useState(0),[S,E]=w.useState(new Set),[_,R]=w.useState(""),[I,B]=w.useState(!1),[$,q]=w.useState(!1),G=w.useRef(null),T=w.useRef(Date.now()),H=w.useRef(!1),L=w.useCallback(async()=>{if(m){q(!0);try{const F=n.map(W=>W.jobId).filter(W=>!!W);await m(F)}catch(F){console.error("Save failed:",F)}finally{q(!1),o()}}},[m,n,o]),J=w.useCallback(async()=>{if(!x||!_.trim())return;const F=f.get(x);if(!(!(F!=null&&F.sessionId)||F.status!=="awaiting_input"&&F.status!=="done")){B(!0);try{await ye.replyToSession(F.sessionId,_.trim()),R(""),j(F.sessionId,x)}catch(W){console.error("Reply failed:",W)}finally{B(!1)}}},[x,_,f,j]),ce=w.useCallback(async F=>{const W=f.get(F);if(W!=null&&W.sessionId)try{await ye.abortSession(W.sessionId)}catch(A){console.error("Abort failed:",A)}},[f]),re=w.useCallback(async()=>{for(const[,F]of f)if((F.status==="running"||F.status==="awaiting_input")&&F.sessionId)try{await ye.abortSession(F.sessionId)}catch{}},[f]);w.useEffect(()=>{const F=setInterval(()=>{N(Math.floor((Date.now()-T.current)/1e3))},1e3);return()=>clearInterval(F)},[]);const X=w.useRef(!1);w.useEffect(()=>{const F=G.current;if(!F)return;const W=()=>{const A=F.scrollHeight-F.scrollTop-F.clientHeight<60;X.current=!A};return F.addEventListener("scroll",W),()=>F.removeEventListener("scroll",W)},[]),w.useEffect(()=>{X.current=!1,G.current&&(G.current.scrollTop=G.current.scrollHeight)},[x]),w.useEffect(()=>{G.current&&!X.current&&(G.current.scrollTop=G.current.scrollHeight)},[f]),w.useEffect(()=>{b&&!H.current&&(H.current=!0,d==null||d()),!b&&H.current&&(H.current=!1)},[b,d]);const le=F=>`${Math.floor(F/60)}:${String(F%60).padStart(2,"0")}`,ee=x?f.get(x):null,Z=x?IE[x]??"#888":"#888",D=F=>{E(W=>{const A=new Set(W);return A.has(F)?A.delete(F):A.add(F),A})};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:b?"#2E7D32":"#B71C1C",animation:b?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:b?"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:le(k)}),v.awaitingInput>0&&l.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full font-semibold",style:{background:"#F59E0B22",color:"#F59E0B"},children:[v.awaitingInput," awaiting reply"]}),l.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full font-semibold",style:{background:b?"#2E7D3222":"#B71C1C22",color:b?"#2E7D32":"#B71C1C"},children:[v.done,"/",v.total," done"]}),!b&&(v.running>0||v.awaitingInput>0)&&l.jsx("button",{onClick:re,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:u,title:"Minimize",className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text)] text-sm cursor-pointer px-1",children:"–"}),l.jsx("button",{onClick:o,className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text)] text-lg cursor-pointer",title:b?"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(F=>l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:F.color,animation:F.dot?"wave-pulse 1.5s ease-in-out infinite":void 0}}),l.jsx("span",{className:"text-[8px] text-[var(--terminal-text-muted)]",children:F.label})]},F.label))})]}),l.jsx("div",{className:"overflow-x-auto overflow-y-auto px-3 pb-2",style:{maxHeight:"35vh"},children:l.jsx(Wm,{nodes:f,rootId:i,selectedRoleId:x,onSelectNode:y})})]}),l.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[ee&&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:Z}}),l.jsx("span",{className:"text-[var(--terminal-text)] font-bold text-xs",children:ee.roleId.toUpperCase()}),l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs",children:ee.roleName}),l.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full font-semibold",style:{background:ee.status==="awaiting_input"?"#F59E0B22":`${Z}22`,color:ee.status==="awaiting_input"?"#F59E0B":Z},children:ee.status==="running"?"Working":ee.status==="done"?"Complete":ee.status==="error"?"Error":ee.status==="waiting"?"Waiting":ee.status==="awaiting_input"?"Awaiting Reply":"Not dispatched"}),(ee.status==="running"||ee.status==="awaiting_input")&&ee.sessionId&&l.jsx("button",{onClick:()=>ce(ee.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:G,className:"flex-1 min-h-0 overflow-y-auto p-4 space-y-1 text-xs font-mono select-text",children:[ee&&ee.events.length===0&&l.jsx("div",{className:"text-[var(--terminal-text-muted)]",children:ee.status==="waiting"?"Waiting for dispatch...":ee.status==="running"?"Connecting to activity stream...":ee.status==="not-dispatched"?"This role was not dispatched in this wave.":""}),ee==null?void 0:ee.events.map(F=>l.jsx(Pu,{event:F,isThinkingCollapsed:S.has(F.seq),onToggleThinking:()=>D(F.seq),onNavigateToJob:W=>{const A=ee==null?void 0:ee.events.find(ie=>ie.type==="dispatch:start"&&ie.data.childJobId===W),Q=A==null?void 0:A.data.targetRoleId;Q&&f.has(Q)&&y(Q)},onOpenKnowledgeDoc:h},F.seq)),(ee==null?void 0:ee.status)==="running"&&l.jsx("span",{className:"inline-block w-2 h-4 bg-green-400 animate-pulse ml-0.5"})]}),(ee==null?void 0:ee.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:[ee.roleName," is waiting for your response"]})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{type:"text",value:_,onChange:F=>R(F.target.value),onKeyDown:F=>{F.key==="Enter"&&!F.shiftKey&&(F.preventDefault(),J())},placeholder:"Type your response...",disabled:I,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:J,disabled:I||!_.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:I?"...":"Reply"})]})]}),(ee==null?void 0:ee.status)==="done"&&ee.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 ",ee.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:_,onChange:F=>R(F.target.value),onKeyDown:F=>{F.key==="Enter"&&!F.shiftKey&&(F.preventDefault(),J())},placeholder:"e.g., 좋아 KB-3 진행해, Engineer에게 시켜...",disabled:I,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:J,disabled:I||!_.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:I?"...":"Send"})]})]}),!ee&&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:ee&&ee.events.length>0&&`${ee.events.length} events`}),b&&l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{onClick:o,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"}),m&&l.jsx("button",{onClick:L,disabled:$,className:"px-4 py-1.5 text-xs text-white rounded-lg font-semibold cursor-pointer disabled:opacity-50",style:{background:"#2E7D32"},children:$?"Saving...":"Save Wave"})]})]})]})]})]})]})}const uv={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function Py({orgNodes:e,rootRoleId:n,cLevelRoles:a,pastWaves:i,activeWaves:o,onDispatch:u,onClose:d,onDone:h,onSave:m,onOpenKnowledgeDoc:f,onRefreshWaves:x,terminalWidth:y=0,onMaximize:v}){const[b,j]=w.useState(o.length>0?"monitor":"dispatch"),[k,N]=w.useState(0),[S,E]=w.useState(""),_=w.useRef(null),[R,I]=w.useState(null),[B,$]=w.useState(!1),[q,G]=w.useState(null);w.useEffect(()=>{const A=()=>ye.getSaveStatus("code").then(ie=>{G({dirty:ie.dirty,count:ie.modified.length+ie.untracked.length,branch:ie.branch})}).catch(()=>{});A();const Q=setInterval(A,3e4);return()=>clearInterval(Q)},[]);const[T,H]=w.useState(()=>{const A=new Set,Q=e[n];if(Q)for(const ie of Q.children){A.add(ie);const he=e[ie];if(he)for(const Ne of he.children)A.add(Ne)}return A}),{panelRight:L,panelWidth:J,isResizing:ce,handleResizeStart:re}=Uo(y,720,v);w.useEffect(()=>{o.length>0&&b==="dispatch"&&(j("monitor"),N(0))},[o.length,b]),w.useEffect(()=>{b==="dispatch"&&setTimeout(()=>{var A;return(A=_.current)==null?void 0:A.focus()},100)},[b]);const X=w.useCallback((A,Q)=>{H(ie=>{const he=new Set(ie);return Q?he.add(A):he.delete(A),he})},[]),le=a.filter(A=>T.has(A.id)).length,ee=()=>{if(!S.trim()||le===0)return;const A=e[n];let Q=0;if(A)for(const Ne of A.children){Q++;const Ie=e[Ne];Ie&&(Q+=Ie.children.length)}const he=T.size>=Q?void 0:Array.from(T);u(S.trim(),he),E("")},Z=A=>{A.key==="Enter"&&(A.metaKey||A.ctrlKey)&&ee(),A.key==="Escape"&&b==="dispatch"&&d()},D=w.useCallback(async A=>{$(!0),I(null),N(-1),j("monitor");try{const Q=await ye.getWaveDetail(A);Q.replay&&I(Q.replay)}catch(Q){console.error("Failed to load wave:",Q)}finally{$(!1)}},[]),F=k>=0?o[k]??null:null,W=!!n&&Object.keys(e).length>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:L},onClick:d}),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)] ${ce?"resizing":""}`,style:{right:L,width:J,background:"var(--terminal-bg)",borderLeftColor:"#B71C1C"},children:[l.jsx("div",{className:`absolute top-0 -left-[5px] w-[10px] h-full cursor-col-resize z-[60] transition-colors ${ce?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:re}),l.jsxs("div",{className:"px-5 py-3 text-white relative shrink-0",style:{background:"linear-gradient(135deg, #B71C1C, #D32F2F)"},children:[l.jsxs("div",{className:"absolute top-3 right-3 flex items-center gap-1",children:[v&&l.jsx("button",{onClick:v,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:d,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.jsx("div",{className:"text-lg font-bold",children:"Wave Center"}),l.jsx("div",{className:"text-xs opacity-70 mt-0.5",children:o.length>0?`${o.length} active wave${o.length!==1?"s":""}`:"Broadcast directives to your organization"})]}),l.jsxs("div",{className:"flex shrink-0",style:{borderBottom:"1px solid var(--terminal-border)"},children:[l.jsx("button",{onClick:()=>j("dispatch"),className:"px-4 py-2 text-xs font-semibold cursor-pointer transition-colors",style:{color:b==="dispatch"?"#D32F2F":"var(--terminal-text-muted)",borderBottom:b==="dispatch"?"2px solid #D32F2F":"2px solid transparent"},children:"New Wave"}),l.jsxs("button",{onClick:()=>j("monitor"),className:"px-4 py-2 text-xs font-semibold cursor-pointer transition-colors flex items-center gap-1.5",style:{color:b==="monitor"?"#D32F2F":"var(--terminal-text-muted)",borderBottom:b==="monitor"?"2px solid #D32F2F":"2px solid transparent"},children:["Monitor",o.length>0&&l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-500 animate-pulse"})]}),l.jsxs("button",{onClick:()=>j("monitor"),className:"px-4 py-2 text-xs font-semibold cursor-pointer transition-colors ml-auto",style:{color:"var(--terminal-text-muted)"},children:["History (",i.length,")"]})]}),l.jsxs("div",{className:"flex-1 flex min-h-0",children:[l.jsx("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:b==="dispatch"?l.jsx(UE,{orgNodes:e,rootId:n,hasOrgData:W,cLevelRoles:a,activeRoles:T,onToggleRole:X,directive:S,onDirectiveChange:E,onSubmit:ee,onKeyDown:Z,activeCLevelCount:le,inputRef:_}):l.jsxs(l.Fragment,{children:[o.map(A=>l.jsx("div",{className:"flex-1 flex flex-col min-h-0",style:{display:(F==null?void 0:F.id)===A.id&&!R?"flex":"none"},children:l.jsx(qE,{wave:A,orgNodes:e,rootRoleId:n,onDone:h,onSave:m,onOpenKnowledgeDoc:f})},A.id)),R?l.jsx(XE,{replay:R,orgNodes:e,rootRoleId:n,onOpenKnowledgeDoc:f,onRefreshWaves:x}):B?l.jsx("div",{className:"flex-1 flex items-center justify-center text-[var(--terminal-text-muted)] text-sm",children:"Loading wave data..."}):F?null:l.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-[var(--terminal-text-muted)] gap-3 p-8",children:[l.jsx("span",{className:"text-3xl",children:"🌊"}),l.jsx("div",{className:"text-sm",children:"No active waves"}),l.jsx("div",{className:"text-[10px]",children:"Select a past wave from the list, or start a new one"}),l.jsx("button",{onClick:()=>j("dispatch"),className:"px-4 py-2 text-xs font-semibold rounded-lg cursor-pointer",style:{background:"#B71C1C",color:"#fff"},children:"Start New Wave"})]})]})}),l.jsxs("div",{className:"w-[220px] shrink-0 border-l flex flex-col",style:{borderColor:"var(--terminal-border)",background:"var(--hud-bg-alt)"},children:[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((A,Q)=>l.jsxs("button",{onClick:()=>{j("monitor"),N(Q),I(null)},className:"text-left p-2 rounded-lg cursor-pointer transition-colors",style:{background:b==="monitor"&&k===Q?"var(--terminal-bg)":"transparent",border:b==="monitor"&&k===Q?"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:[A.directive.slice(0,40),A.directive.length>40?"...":""]})]}),l.jsxs("div",{className:"text-[9px] text-[var(--terminal-text-muted)] mt-0.5 pl-3.5",children:[A.rootJobs.length," role",A.rootJobs.length!==1?"s":""]})]},A.id))})]}),q&&l.jsx("div",{className:"px-3 py-2 border-b",style:{borderColor:"var(--terminal-border)"},children:l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:q.dirty?"var(--idle-amber)":"#2E7D32"}}),l.jsx("span",{className:"text-[10px] font-mono text-[var(--terminal-text-muted)] truncate",children:q.branch}),q.dirty&&l.jsxs("span",{className:"text-[9px] ml-auto shrink-0",style:{color:"var(--idle-amber)"},children:[q.count," uncommitted"]}),!q.dirty&&l.jsx("span",{className:"text-[9px] text-green-400 ml-auto shrink-0",children:"clean"})]})}),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(A=>l.jsx(WE,{wave:A,active:(R==null?void 0:R.id)===A.id,onLoad:()=>D(A.id)},A.id))})]})]})]})]})]})}function UE({orgNodes:e,rootId:n,hasOrgData:a,cLevelRoles:i,activeRoles:o,onToggleRole:u,directive:d,onDirectiveChange:h,onSubmit:m,onKeyDown:f,activeCLevelCount:x,inputRef:y}){return l.jsxs("div",{className:"flex-1 overflow-y-auto p-5 space-y-4",children:[a&&l.jsx(ov,{orgNodes:e,rootId:n,activeRoles:o,onToggleRole:u}),!a&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--terminal-text-secondary)] uppercase tracking-wider mb-2",children:"Dispatching to"}),l.jsx("div",{className:"flex gap-2 flex-wrap",children:i.length>0?i.map(v=>l.jsxs("span",{className:"px-3 py-1.5 text-xs font-semibold rounded-lg",style:{background:"#B71C1C22",color:"#E57373",border:"1px solid #B71C1C44"},children:[v.id.toUpperCase()," · ",v.name]},v.id)):l.jsx("span",{className:"text-xs text-[var(--terminal-text-muted)] italic",children:"No C-Level roles found"})})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--terminal-text-secondary)] uppercase tracking-wider mb-2",children:"Directive"}),l.jsx("textarea",{ref:y,value:d,onChange:v=>h(v.target.value),onKeyDown:f,placeholder:"e.g. Report current status across all departments",className:"w-full h-28 p-3 rounded-lg border text-sm resize-none focus:outline-none transition-colors",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)"}}),l.jsxs("div",{className:"flex items-center justify-between mt-2",children:[l.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:"Cmd+Enter to dispatch"}),l.jsxs("button",{onClick:m,disabled:!d.trim()||x===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 ",x," Role",x!==1?"s":""]})]})]})]})}function qE({wave:e,orgNodes:n,rootRoleId:a,onDone:i,onSave:o,onOpenKnowledgeDoc:u}){var Ne,Ie;const{nodes:d,selectedRoleId:h,selectNode:m,progress:f,allDone:x,connectStream:y}=cv(e.rootJobs,n,a),[v,b]=w.useState(0),[j,k]=w.useState(new Set),[N,S]=w.useState(""),[E,_]=w.useState(!1),[R,I]=w.useState(null),[B,$]=w.useState(""),[q,G]=w.useState(!1),[T,H]=w.useState(null),[L,J]=w.useState(!1),ce=w.useRef(null),re=w.useRef(null),X=w.useRef(!1),le=w.useCallback(async()=>{if(!h||!N.trim())return;const de=d.get(h);if(!(!(de!=null&&de.sessionId)||de.status!=="awaiting_input"&&de.status!=="done")){_(!0);try{await ye.replyToSession(de.sessionId,N.trim()),S(""),y(de.sessionId,h)}catch(_e){console.error("Reply failed:",_e)}finally{_(!1)}}},[h,N,d,y]),ee=w.useCallback(async de=>{const _e=d.get(de);if(_e!=null&&_e.sessionId)try{await ye.abortSession(_e.sessionId)}catch{}},[d]),Z=w.useCallback(async()=>{for(const[,de]of d)if((de.status==="running"||de.status==="awaiting_input")&&de.sessionId)try{await ye.abortSession(de.sessionId)}catch{}},[d]);w.useEffect(()=>{const de=setInterval(()=>{b(Math.floor((Date.now()-e.startedAt)/1e3))},1e3);return()=>clearInterval(de)},[e.startedAt]);const D=w.useRef(!1);w.useEffect(()=>{const de=re.current;if(!de)return;const _e=()=>{const Ye=de.scrollHeight-de.scrollTop-de.clientHeight<60;D.current=!Ye};return de.addEventListener("scroll",_e),()=>de.removeEventListener("scroll",_e)},[]),w.useEffect(()=>{D.current=!1,re.current&&(re.current.scrollTop=re.current.scrollHeight)},[h]),w.useEffect(()=>{re.current&&!D.current&&(re.current.scrollTop=re.current.scrollHeight)},[d]);const F=w.useCallback(()=>{ye.getSaveStatus("code").then(de=>{if(I(de),!B){const _e=e.directive.slice(0,60).replace(/\n/g," ");$(`wave: ${_e}`)}}).catch(()=>{})},[e.directive,B]),W=w.useCallback(async()=>{if(B.trim()){G(!0),H(null);try{const de=await ye.save(B.trim(),"code");H({ok:!0,sha:de.commitSha}),ce.current&&de.commitSha&&ye.patchWave(ce.current,{commitSha:de.commitSha,commitMessage:B.trim()}).catch(()=>{}),F()}catch(de){H({ok:!1,error:de instanceof Error?de.message:"Commit failed"})}finally{G(!1)}}},[B,F]);w.useEffect(()=>{if(x&&!X.current){if(X.current=!0,i==null||i(),o){const de=e.rootJobs.map(_e=>_e.jobId).filter(_e=>!!_e);o(e.directive,de,{waveId:e.id,sessionIds:e.sessionIds}).then(()=>{ye.getWaves().then(_e=>{_e.length>0&&(ce.current=_e[0].id)}).catch(()=>{})}).catch(()=>{})}F()}!x&&X.current&&(X.current=!1)},[x,i,o,e,F]);const A=de=>`${Math.floor(de/60)}:${String(de%60).padStart(2,"0")}`,Q=h?d.get(h):null,ie=h?uv[h]??"#888":"#888",he=de=>{k(_e=>{const Ye=new Set(_e);return Ye.has(de)?Ye.delete(de):Ye.add(de),Ye})};return l.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[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:x?"#2E7D32":"#B71C1C",animation:x?void 0:"wave-pulse 2s ease-in-out infinite"}}),l.jsxs("span",{className:"text-[var(--terminal-text-secondary)] text-xs italic flex-1 min-w-0 truncate",children:["“",e.directive,"”"]}),l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs font-mono shrink-0",children:A(v)}),f.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:[f.awaitingInput," awaiting"]}),l.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-semibold shrink-0",style:{background:x?"#2E7D3222":"#B71C1C22",color:x?"#2E7D32":"#B71C1C"},children:[f.done,"/",f.total]}),!x&&(f.running>0||f.awaitingInput>0)&&l.jsx("button",{onClick:Z,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:"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(de=>l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:de.color,animation:de.dot?"wave-pulse 1.5s ease-in-out infinite":void 0}}),l.jsx("span",{className:"text-[8px] text-[var(--terminal-text-muted)]",children:de.label})]},de.label))})]}),l.jsx("div",{className:"overflow-x-auto overflow-y-auto px-3 pb-2",style:{maxHeight:"30vh"},children:l.jsx(Wm,{nodes:d,rootId:a,selectedRoleId:h,onSelectNode:m})})]}),l.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[Q&&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:ie}}),l.jsx("span",{className:"text-[var(--terminal-text)] font-bold text-xs",children:Q.roleId.toUpperCase()}),l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs",children:Q.roleName}),l.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full font-semibold",style:{background:Q.status==="awaiting_input"?"#F59E0B22":`${ie}22`,color:Q.status==="awaiting_input"?"#F59E0B":ie},children:Q.status==="running"?"Working":Q.status==="done"?"Complete":Q.status==="error"?"Error":Q.status==="waiting"?"Waiting":Q.status==="awaiting_input"?"Awaiting Reply":"Not dispatched"}),(Q.status==="running"||Q.status==="awaiting_input")&&Q.sessionId&&l.jsx("button",{onClick:()=>ee(Q.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.jsxs("div",{ref:re,className:"flex-1 min-h-0 overflow-y-auto p-4 space-y-1 text-xs font-mono select-text",children:[Q&&Q.status!=="waiting"&&Q.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:e.directive})]}),Q&&Q.events.length===0&&l.jsx("div",{className:"text-[var(--terminal-text-muted)]",children:Q.status==="waiting"?"Waiting for dispatch...":Q.status==="running"?"Connecting to activity stream...":Q.status==="not-dispatched"?"This role was not dispatched in this wave.":""}),Q==null?void 0:Q.events.map(de=>l.jsx(Pu,{event:de,isThinkingCollapsed:j.has(de.seq),onToggleThinking:()=>he(de.seq),onNavigateToJob:_e=>{for(const[,Ye]of d)if(Ye.events.some(ge=>ge.data.childJobId===_e)){m(Ye.roleId);return}},onOpenKnowledgeDoc:u},de.seq)),(Q==null?void 0:Q.status)==="running"&&l.jsx("span",{className:"inline-block w-2 h-4 bg-green-400 animate-pulse ml-0.5"}),!Q&&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"})]}),(Q==null?void 0:Q.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:[Q.roleName," is waiting for your response"]})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{type:"text",value:N,onChange:de=>S(de.target.value),onKeyDown:de=>{de.key==="Enter"&&!de.shiftKey&&(de.preventDefault(),le())},placeholder:"Type your response...",disabled:E,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:le,disabled:E||!N.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:E?"...":"Reply"})]})]}),(Q==null?void 0:Q.status)==="done"&&Q.sessionId&&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 ",Q.roleName]})}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{type:"text",value:N,onChange:de=>S(de.target.value),onKeyDown:de=>{de.key==="Enter"&&!de.shiftKey&&(de.preventDefault(),le())},placeholder:"Send a follow-up directive...",disabled:E,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:le,disabled:E||!N.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:E?"...":"Send"})]})]}),l.jsxs("div",{className:"px-4 py-2 border-t flex items-center justify-between shrink-0",style:{borderColor:"var(--terminal-border)"},children:[l.jsx("div",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:Q&&Q.events.length>0&&`${Q.events.length} events`}),x&&R&&l.jsxs("div",{className:"flex items-center gap-2",children:[R.dirty&&l.jsxs("button",{onClick:()=>J(de=>!de),className:"px-3 py-1.5 text-[10px] font-bold cursor-pointer rounded",style:{background:L?"var(--idle-amber)":"var(--terminal-bg)",color:L?"#000":"var(--idle-amber)",border:"1px solid var(--idle-amber)"},children:[R.modified.length+R.untracked.length," changes"]}),!R.dirty&&(T==null?void 0:T.ok)&&l.jsxs("span",{className:"text-[10px] text-green-400 font-mono",children:["committed ",(Ne=T.sha)==null?void 0:Ne.slice(0,7)]}),!R.dirty&&!T&&l.jsx("span",{className:"text-[10px] text-green-400",children:"no uncommitted changes"})]})]}),x&&L&&(R==null?void 0:R.dirty)&&l.jsx("div",{className:"border-t overflow-y-auto",style:{borderColor:"var(--terminal-border)",background:"var(--hud-bg-alt)",maxHeight:"40vh"},children:l.jsxs("div",{className:"px-4 py-3 space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("span",{className:"text-[10px] font-bold text-[var(--terminal-text-secondary)] uppercase tracking-wider",children:["Code Changes (",R.branch,")"]}),l.jsx("button",{onClick:()=>F(),className:"text-[9px] text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text)] cursor-pointer",children:"refresh"})]}),l.jsxs("div",{className:"max-h-[120px] overflow-y-auto space-y-0.5",children:[R.modified.map(de=>l.jsxs("div",{className:"text-[10px] font-mono text-[var(--terminal-text)] flex items-center gap-1.5",children:[l.jsx("span",{className:"text-yellow-500",children:"M"}),l.jsx("span",{className:"truncate",children:de})]},de)),R.untracked.map(de=>l.jsxs("div",{className:"text-[10px] font-mono text-[var(--terminal-text)] flex items-center gap-1.5",children:[l.jsx("span",{className:"text-green-400",children:"+"}),l.jsx("span",{className:"truncate",children:de})]},de))]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{value:B,onChange:de=>$(de.target.value),onKeyDown:de=>{de.key==="Enter"&&W()},placeholder:"Commit message...",disabled:q,className:"flex-1 px-2 py-1.5 text-xs rounded border bg-[var(--terminal-bg)] text-[var(--terminal-text)] outline-none font-mono",style:{borderColor:"var(--terminal-border)"}}),l.jsx("button",{onClick:W,disabled:q||!B.trim(),className:"px-4 py-1.5 text-xs rounded font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#2E7D32",color:"#fff"},children:q?"...":"Commit"})]}),(T==null?void 0:T.error)&&l.jsx("div",{className:"text-[10px] text-red-400",children:T.error}),(T==null?void 0:T.ok)&&l.jsxs("div",{className:"text-[10px] text-green-400 font-mono",children:["Committed: ",(Ie=T.sha)==null?void 0:Ie.slice(0,7)]})]})})]})]})}function YE(e,n,a){const i=new Map,o=d=>{const h=e[d];!h||i.has(d)||(i.set(d,{sessionId:"",roleId:d,roleName:h.name,children:h.children,status:"not-dispatched",events:[],streamStatus:"idle"}),h.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 h=i.get(d.roleId);h&&i.set(d.roleId,{...h,sessionId:d.jobId??"",status:d.status||"done",events:d.events,streamStatus:"done"});for(const m of d.childJobs){const f=i.get(m.roleId);f&&i.set(m.roleId,{...f,sessionId:m.jobId??"",status:m.status||"done",events:m.events,streamStatus:"done"})}}return i}function XE({replay:e,orgNodes:n,rootRoleId:a,onOpenKnowledgeDoc:i,onRefreshWaves:o}){var W,A,Q;const u=w.useMemo(()=>YE(n,a,e.roles),[n,a,e]),[d,h]=w.useState(u),[m,f]=w.useState(((W=e.roles[0])==null?void 0:W.roleId)??null),[x,y]=w.useState(new Set),v=w.useRef(null),b=w.useRef(new Map);w.useEffect(()=>{h(u)},[u]);const[j,k]=w.useState(null),[N,S]=w.useState(`wave: ${e.directive.slice(0,60).replace(/\n/g," ")}`),[E,_]=w.useState(!1),[R,I]=w.useState(null),[B,$]=w.useState(!1),[q,G]=w.useState(""),[T,H]=w.useState(!1),L=m?d.get(m):null,J=m?uv[m]??"#888":"#888";w.useEffect(()=>{v.current&&(v.current.scrollTop=0)},[m]);const ce=w.useCallback(()=>{ye.getSaveStatus("code").then(k).catch(()=>{})},[]);w.useEffect(()=>{ce()},[ce]);const re=w.useCallback(async()=>{if(N.trim()){_(!0),I(null);try{const ie=await ye.save(N.trim(),"code");I({ok:!0,sha:ie.commitSha}),ie.commitSha&&ye.patchWave(e.id,{commitSha:ie.commitSha,commitMessage:N.trim()}).then(()=>{o==null||o()}).catch(()=>{}),ce()}catch(ie){I({ok:!1,error:ie instanceof Error?ie.message:"Commit failed"})}finally{_(!1)}}},[N,ce,e.id,o]),X=w.useCallback((ie,he)=>{const Ne=b.current.get(ie);Ne&&Ne.abort();const Ie=new AbortController;b.current.set(ie,Ie),h(de=>{const _e=new Map(de),Ye=_e.get(he);return Ye&&_e.set(he,{...Ye,sessionId:ie,status:"running",streamStatus:"streaming",events:[]}),_e}),fetch(`/api/sessions/${ie}/stream?from=0`,{signal:Ie.signal}).then(async de=>{if(!de.ok||!de.body)return;const _e=de.body.getReader(),Ye=new TextDecoder;let ge="";for(;;){const{done:Je,value:Fe}=await _e.read();if(Je)break;ge+=Ye.decode(Fe,{stream:!0});const ct=ge.split(`
84
- `);ge=ct.pop()??"";let Ke="";for(const ot of ct)if(ot.startsWith("event: "))Ke=ot.slice(7).trim();else if(ot.startsWith("data: ")){try{const xt=JSON.parse(ot.slice(6));if(Ke==="activity"){const wt=xt;h(bt=>{const dt=new Map(bt),gn=dt.get(he);if(!gn||gn.events.some(Wt=>Wt.seq===wt.seq))return bt;const ft={...gn,events:[...gn.events,wt]};return wt.type==="job:done"?(ft.status="done",ft.streamStatus="done"):wt.type==="job:error"?(ft.status="error",ft.streamStatus="error"):wt.type==="job:awaiting_input"&&(ft.status="awaiting_input",ft.streamStatus="done"),dt.set(he,ft),dt})}else Ke==="stream:end"&&h(wt=>{const bt=new Map(wt),dt=bt.get(he);return!dt||dt.status!=="running"?wt:(bt.set(he,{...dt,status:"done",streamStatus:"done"}),bt)})}catch{}Ke=""}}}).catch(de=>{de.name!=="AbortError"&&h(_e=>{const Ye=new Map(_e),ge=Ye.get(he);return ge&&Ye.set(he,{...ge,status:"error",streamStatus:"error"}),Ye})})},[]);w.useEffect(()=>()=>{for(const[,ie]of b.current)ie.abort();b.current.clear()},[]);const le=w.useCallback(async()=>{if(!(!m||!q.trim()||!d.get(m))){H(!0);try{const he=await ye.startJob({type:"assign",roleId:m,task:q.trim()});G("");const Ne=he.sessionId;Ne&&X(Ne,m)}catch(he){console.error("Follow-up failed:",he)}finally{H(!1)}}},[m,q,d,X]),ee=ie=>{y(he=>{const Ne=new Set(he);return Ne.has(ie)?Ne.delete(ie):Ne.add(ie),Ne})},Z=e.startedAt?new Date(e.startedAt).toLocaleString():"",D=Array.from(d.values()).some(ie=>ie.status==="running"||ie.status==="awaiting_input"),F=w.useMemo(()=>{let ie=0,he=0;for(const[Ne,Ie]of d)Ne!==a&&(he++,Ie.status==="done"&&ie++);return{done:ie,total:he}},[d,a]);return l.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[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:D?"#FBBF24":"#2E7D32",animation:D?"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:["“",e.directive,"”"]}),l.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-semibold shrink-0",style:{background:D?"#FBBF2422":"#2E7D3222",color:D?"#FBBF24":"#2E7D32"},children:D?"LIVE":"REPLAY"}),l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-[10px] shrink-0",children:Z}),l.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-semibold shrink-0",style:{background:"#2E7D3222",color:"#2E7D32"},children:[F.done,"/",F.total]})]}),l.jsxs("div",{className:"shrink-0 border-b flex flex-col",style:{borderColor:"var(--terminal-border)"},children:[l.jsx("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:"overflow-x-auto overflow-y-auto px-3 pb-2",style:{maxHeight:"30vh"},children:l.jsx(Wm,{nodes:d,rootId:a,selectedRoleId:m,onSelectNode:f})})]}),l.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[L&&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:J}}),l.jsx("span",{className:"text-[var(--terminal-text)] font-bold text-xs",children:L.roleId.toUpperCase()}),l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs",children:L.roleName}),l.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full font-semibold",style:{background:L.status==="running"?"#FBBF2422":L.status==="awaiting_input"?"#F59E0B22":`${J}22`,color:L.status==="running"?"#FBBF24":L.status==="awaiting_input"?"#F59E0B":J},children:L.status==="done"?"Complete":L.status==="error"?"Error":L.status==="running"?"Working...":L.status==="awaiting_input"?"Awaiting Reply":L.status}),l.jsxs("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:[L.events.length," events"]})]}),l.jsxs("div",{ref:v,className:"flex-1 min-h-0 overflow-y-auto p-4 space-y-1 text-xs font-mono select-text",children:[L&&L.events.length===0&&l.jsx("div",{className:"text-[var(--terminal-text-muted)]",children:L.status==="not-dispatched"?"This role was not dispatched in this wave.":"No events recorded for this role."}),L==null?void 0:L.events.map(ie=>l.jsx(Pu,{event:ie,isThinkingCollapsed:x.has(ie.seq),onToggleThinking:()=>ee(ie.seq),onNavigateToJob:he=>{for(const[,Ne]of d)if(Ne.events.some(Ie=>Ie.data.childJobId===he)){f(Ne.roleId);return}},onOpenKnowledgeDoc:i},ie.seq)),(L==null?void 0:L.status)==="running"&&l.jsx("span",{className:"inline-block w-2 h-4 bg-green-400 animate-pulse ml-0.5"}),!L&&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"})]}),L&&(L.status==="done"||L.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 ",L.roleName]})}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{type:"text",value:q,onChange:ie=>G(ie.target.value),onKeyDown:ie=>{ie.key==="Enter"&&!ie.shiftKey&&(ie.preventDefault(),le())},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:le,disabled:T||!q.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:T?"...":"Send"})]})]}),l.jsxs("div",{className:"px-4 py-2 border-t flex items-center justify-between shrink-0",style:{borderColor:"var(--terminal-border)"},children:[l.jsx("div",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:L&&L.events.length>0&&`${L.events.length} events`}),j&&l.jsxs("div",{className:"flex items-center gap-2",children:[j.dirty&&l.jsxs("button",{onClick:()=>$(ie=>!ie),className:"px-3 py-1.5 text-[10px] font-bold cursor-pointer rounded",style:{background:B?"var(--idle-amber)":"var(--terminal-bg)",color:B?"#000":"var(--idle-amber)",border:"1px solid var(--idle-amber)"},children:[j.modified.length+j.untracked.length," changes"]}),!j.dirty&&(R==null?void 0:R.ok)&&l.jsxs("span",{className:"text-[10px] text-green-400 font-mono",children:["committed ",(A=R.sha)==null?void 0:A.slice(0,7)]}),!j.dirty&&!R&&l.jsx("span",{className:"text-[10px] text-green-400",children:"no uncommitted changes"})]})]}),B&&(j==null?void 0:j.dirty)&&l.jsx("div",{className:"border-t overflow-y-auto",style:{borderColor:"var(--terminal-border)",background:"var(--hud-bg-alt)",maxHeight:"40vh"},children:l.jsxs("div",{className:"px-4 py-3 space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("span",{className:"text-[10px] font-bold text-[var(--terminal-text-secondary)] uppercase tracking-wider",children:["Code Changes (",j.branch,")"]}),l.jsx("button",{onClick:ce,className:"text-[9px] text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text)] cursor-pointer",children:"refresh"})]}),l.jsxs("div",{className:"max-h-[120px] overflow-y-auto space-y-0.5",children:[j.modified.map(ie=>l.jsxs("div",{className:"text-[10px] font-mono text-[var(--terminal-text)] flex items-center gap-1.5",children:[l.jsx("span",{className:"text-yellow-500",children:"M"}),l.jsx("span",{className:"truncate",children:ie})]},ie)),j.untracked.map(ie=>l.jsxs("div",{className:"text-[10px] font-mono text-[var(--terminal-text)] flex items-center gap-1.5",children:[l.jsx("span",{className:"text-green-400",children:"+"}),l.jsx("span",{className:"truncate",children:ie})]},ie))]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{value:N,onChange:ie=>S(ie.target.value),onKeyDown:ie=>{ie.key==="Enter"&&re()},placeholder:"Commit message...",disabled:E,className:"flex-1 px-2 py-1.5 text-xs rounded border bg-[var(--terminal-bg)] text-[var(--terminal-text)] outline-none font-mono",style:{borderColor:"var(--terminal-border)"}}),l.jsx("button",{onClick:re,disabled:E||!N.trim(),className:"px-4 py-1.5 text-xs rounded font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#2E7D32",color:"#fff"},children:E?"...":"Commit"})]}),(R==null?void 0:R.error)&&l.jsx("div",{className:"text-[10px] text-red-400",children:R.error}),(R==null?void 0:R.ok)&&l.jsxs("div",{className:"text-[10px] text-green-400 font-mono",children:["Committed: ",(Q=R.sha)==null?void 0:Q.slice(0,7)]})]})})]})]})}function WE({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:[l.jsx("span",{className:"text-[10px]",children:"▶"}),l.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:o}),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 VE={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 Vm(e){return VE[e]??{skinColor:"#B0BEC5",hairColor:"#78909C",shirtColor:"#607D8B",pantsColor:"#455A64",shoeColor:"#37474F"}}const dv=["#FDEBD0","#F5CBA7","#D4A07A","#C68642","#8D5524","#5C3A1E","#F3D1C7","#E8BEAC","#B07D62","#704214"],fv=["#1A0A00","#2C1810","#4E342E","#6D4C41","#8D6E63","#D4A574","#F5E6CA","#FFD700","#B71C1C","#AD1457","#4A148C","#1A237E","#004D40","#1A1A1A","#78909C","#E0E0E0"],hv=["#1565C0","#E65100","#2E7D32","#4A148C","#AD1457","#00695C","#D32F2F","#F57F17","#1B5E20","#283593","#4E342E","#37474F","#880E4F","#00838F","#6A1B9A","#FF6F00"],mv=["#37474F","#1A237E","#3E2723","#263238","#1B5E20","#455A64","#212121","#4E342E","#0D47A1","#311B92"],pv=["#212121","#1A1A1A","#37474F","#4E342E","#7B1FA2","#D32F2F","#1565C0","#F57F17","#2E7D32","#FFFFFF"],Ja={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 GE({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 jo({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(GE,{color:o,selected:o===a,onClick:()=>i(o)},o))})]})}function Nh({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,h=u.id===a,m=o?d>o.roleLevel&&!h:!1,f=o?h&&d>o.roleLevel:!1;return l.jsxs("button",{onClick:()=>{m||i(u.id===a?void 0:u.id)},className:"customize-swatch",style:{width:"auto",height:"auto",padding:m?"2px 6px 10px 6px":"2px 6px",fontSize:9,fontFamily:"var(--font-pixel, monospace)",background:h?"rgba(255,255,255,0.15)":m?"rgba(255,255,255,0.02)":"rgba(255,255,255,0.04)",outline:h?f?"2px solid #F59E0B":"2px solid #fff":"2px solid transparent",color:m?"rgba(255,255,255,0.25)":h?"#fff":"rgba(255,255,255,0.5)",borderRadius:4,cursor:m?"not-allowed":"pointer",opacity:m?.35:1,position:"relative"},children:[u.name,m&&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]}),f&&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 Eh({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 Fl(e){return e[Math.floor(Math.random()*e.length)]}function hs(e){var o,u,d;const n=$b(),a=Ib(),i=Hb().filter(h=>!e||qb(h.id,e));return{skinColor:Fl(dv),hairColor:Fl(fv),shirtColor:Fl(hv),pantsColor:Fl(mv),shoeColor:Fl(pv),hairStyle:(o=Fl(n))==null?void 0:o.id,outfitStyle:(u=Fl(a))==null?void 0:u.id,accessory:(d=Fl(i))==null?void 0:d.id}}function xv({roleId:e,appearance:n,onChange:a,onRandomize:i,onReset:o,label:u,roleLevel:d}){const[h,m]=w.useState("look"),f=w.useCallback((N,S)=>{a({...n,[N]:S})},[n,a]),x=w.useRef(null),y=w.useCallback(N=>{var _;const S=(_=N.target.files)==null?void 0:_[0];if(!S)return;const E=new Image;E.onload=()=>{const R=pC(E);a({...R,hairStyle:n.hairStyle,outfitStyle:n.outfitStyle,accessory:n.accessory}),URL.revokeObjectURL(E.src)},E.src=URL.createObjectURL(S),N.target.value=""},[n.hairStyle,n.outfitStyle,n.accessory,a]),v=$b(),b=Ib(),j=Hb(),k=d!==void 0?j.filter(N=>qb(N.id,d)).length:j.length;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"customize-preview",children:[l.jsx("div",{className:"customize-preview-bg",children:l.jsx(Pa,{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 N;return(N=x.current)==null?void 0:N.click()},style:{fontSize:9,opacity:.7},children:"PHOTO"}),l.jsx("input",{ref:x,type:"file",accept:"image/*",onChange:y,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(Eh,{label:"LOOK",active:h==="look",onClick:()=>m("look")}),l.jsx(Eh,{label:"OUTFIT",active:h==="outfit",onClick:()=>m("outfit")}),l.jsx(Eh,{label:"ACCESSORY",active:h==="accessory",onClick:()=>m("accessory")})]}),h==="look"&&l.jsxs(l.Fragment,{children:[l.jsx(jo,{label:"SKIN",presets:dv,value:n.skinColor,onChange:N=>f("skinColor",N)}),l.jsx(jo,{label:"HAIR COLOR",presets:fv,value:n.hairColor,onChange:N=>f("hairColor",N)}),l.jsx(Nh,{label:"HAIR STYLE",items:v,value:n.hairStyle,onChange:N=>f("hairStyle",N)})]}),h==="outfit"&&l.jsxs(l.Fragment,{children:[l.jsx(Nh,{label:"STYLE",items:b,value:n.outfitStyle,onChange:N=>f("outfitStyle",N)}),l.jsx(jo,{label:"TOP",presets:hv,value:n.shirtColor,onChange:N=>f("shirtColor",N)}),l.jsx(jo,{label:"PANTS",presets:mv,value:n.pantsColor,onChange:N=>f("pantsColor",N)}),l.jsx(jo,{label:"SHOES",presets:pv,value:n.shoeColor,onChange:N=>f("shoeColor",N)})]}),h==="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:[k,"/",j.length," unlocked"]})]}),l.jsx(Nh,{label:"ACCESSORY",items:j,value:n.accessory,onChange:N=>f("accessory",N),lockInfo:d!==void 0?{roleLevel:d,getLockLevel:Ub}:void 0}),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 KE=[{value:"c-level",label:"C-Level"},{value:"member",label:"Member"}];function fm(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,24)}function Ah(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 QE={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 zl=null;async function PE(){if(zl)return zl;try{const a=await ye.getPreferences();if(a.instanceId)return zl=a.instanceId,localStorage.setItem("tycono_instance_id",zl),zl}catch{}const e="tycono_instance_id";let n=localStorage.getItem(e);return n||(n=crypto.randomUUID(),localStorage.setItem(e,n)),zl=n,n}const So=4;function ZE(e,n,a){const i=e.trim();if(!i||i.startsWith("#"))return null;const o=i.split(",").map(y=>y.trim()),u=o[0];if(!u)return null;const d=fm(u),m=(o[1]||"member").toLowerCase()==="c-level"?"c-level":"member",f=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:f,error:x}}function JE({existingRoles:e,onClose:n,onHire:a,onStoreVisit:i,questHint:o}){const[u,d]=w.useState("single"),[h,m]=w.useState([]),[f,x]=w.useState(!1),[y,v]=w.useState("popular"),[b,j]=w.useState(""),[k,N]=w.useState(null),[S,E]=w.useState(!1),[_,R]=w.useState(""),[I,B]=w.useState("browse"),[$,q]=w.useState(""),[G,T]=w.useState(""),[H,L]=w.useState("ceo"),[J,ce]=w.useState(null),[re,X]=w.useState(1),[le,ee]=w.useState(""),[Z,D]=w.useState(""),[F,W]=w.useState(!1),[A,Q]=w.useState("member"),[ie,he]=w.useState(()=>{const P=e.find(qe=>qe.level==="c-level");return(P==null?void 0:P.id)??"ceo"}),[Ne,Ie]=w.useState(""),[de,_e]=w.useState(hs),[Ye,ge]=w.useState(!1),[Je,Fe]=w.useState(""),[ct,Ke]=w.useState([]),[ot,xt]=w.useState(new Set),[wt,bt]=w.useState(""),[dt,gn]=w.useState("input"),[ft,Wt]=w.useState({done:0,total:0}),we=w.useRef(null),U=w.useRef(null),ae=w.useRef(null);w.useEffect(()=>{ye.getSkills().then(P=>Ke(P.filter(qe=>qe.installed))).catch(()=>{}),PE().then(P=>ce(P)).catch(()=>{})},[]),w.useEffect(()=>{var P,qe,et;u==="single"?(re===1&&((P=we.current)==null||P.focus()),re===2&&((qe=U.current)==null||qe.focus())):u==="bulk"&&dt==="input"&&((et=ae.current)==null||et.focus())},[re,u,dt]),w.useEffect(()=>{u==="store"&&I==="browse"&&h.length===0&&me()},[u,I]);const me=async()=>{x(!0);try{const P=await pr.getCharacters({sort:y,instanceId:J??void 0});m(P.characters)}catch{R("Failed to load job board")}x(!1)};w.useEffect(()=>{u==="store"&&I==="browse"&&me()},[y,J]);const Ce=w.useMemo(()=>{if(!b.trim())return h;const P=b.toLowerCase();return h.filter(qe=>qe.name.toLowerCase().includes(P)||qe.id.toLowerCase().includes(P)||(qe.tagline??"").toLowerCase().includes(P))},[h,b]),De=w.useMemo(()=>new Set(e.map(P=>P.id)),[e]),Se=w.useMemo(()=>{const P=wt.split(`
85
- `),qe=new Set;return P.map(et=>ZE(et,De,qe)).filter(et=>et!==null)},[wt,De]),Be=Se.length>0&&Se.every(P=>!P.error),$e=P=>{ee(P),F||D(fm(P))},Re=le.trim().length>0&&Z.trim().length>0&&!e.some(P=>P.id===Z),ze=Ne.trim().length>0,Oe=async()=>{ge(!0),Fe("");const P=Ah(A);try{await a({id:Z,name:le.trim(),level:A,reportsTo:ie,persona:Ne.trim(),...P,skills:ot.size>0?[...ot]:void 0},de),n()}catch(qe){Fe(qe instanceof Error?qe.message:"Failed to create role"),ge(!1)}},kt=P=>P===1?Re:P===2?ze:!0,Me=async()=>{ge(!0),Fe(""),Wt({done:0,total:Se.length});try{for(let P=0;P<Se.length;P++){const qe=Se[P],et=Ah(qe.level),St=hs(),ve=`${qe.name}. A ${qe.level} role reporting to ${qe.reportsTo}.`;await a({id:qe.id,name:qe.name,level:qe.level,reportsTo:qe.reportsTo,persona:ve,...et},St),Wt({done:P+1,total:Se.length})}n()}catch(P){Fe(P instanceof Error?P.message:"Failed to create roles"),ge(!1)}},Le=async P=>{E(!0),R("");try{const qe=await pr.getCharacter(P);N(qe),q(qe.name||""),T(fm(qe.name||P)),B("review")}catch{R("Failed to load character details")}finally{E(!1)}},Vt=async(P,qe)=>{if(!J)return;const et=h.find(ve=>ve.id===P);if(!et)return;const St=et.my_vote===qe?0:qe;try{const ve=await pr.voteCharacter(P,J,St);m(yt=>yt.map(sn=>sn.id===P?{...sn,upvotes:ve.upvotes,downvotes:ve.downvotes,vote_score:ve.upvotes-ve.downvotes,my_vote:St===0?null:St}:sn))}catch{}},Jt=async()=>{if(!k)return;ge(!0),Fe("");const P=k,qe=P.level==="c-level"?"c-level":"member",et=Ah(qe),St=P.skills!=null&&typeof P.skills=="object"&&!Array.isArray(P.skills)&&"primary"in P.skills;try{await a({id:G,name:$.trim(),level:qe,reportsTo:H,persona:P.persona||`${$}. Imported from Job Board.`,authority:P.authority||et.authority,knowledge:et.knowledge,reports:et.reports,source:{id:`tycono/${P.id}`,sync:"manual",forked_at:"1.0.0",upstream_version:"1.0.0"},skillContent:St?P.skills:void 0},P.appearance?P.appearance:hs()),pr.trackInstall(P.id).catch(()=>{}),n()}catch(ve){Fe(ve instanceof Error?ve.message:"Failed to hire"),ge(!1)}},jt=async P=>{if(J)try{await pr.deleteCharacter(P,J),m(qe=>qe.filter(et=>et.id!==P))}catch{}},Bt=P=>{P.key==="Escape"&&n(),P.key==="Enter"&&(P.metaKey||P.ctrlKey)&&(u==="single"?re<So&&kt(re)?X(re+1):re===So&&Oe():u==="bulk"?dt==="input"&&Be?gn("review"):dt==="review"&&Me():u==="store"&&I==="review"&&Jt())},bn=e.some(P=>P.id===Z)&&Z.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:Bt,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"),Fe("")},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"),Fe("")},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"),Fe(""),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"&&re===1&&!le&&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 P=QE[o.roleId];P&&(ee(P.name),D(P.id),W(!0),Q(P.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 ${re} of ${So}`:u==="bulk"?dt==="input"?"Enter roles, one per line":`Review ${Se.length} roles`:I==="browse"?`${h.length} roles available`:"Review & customize"}),u==="store"&&I==="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:P=>P.stopPropagation(),children:"Open in browser ↗"})]})]}),u==="single"&&l.jsx("div",{className:"flex gap-1 px-5 pt-4",children:Array.from({length:So},(P,qe)=>qe+1).map(P=>l.jsx("div",{className:"flex-1 h-1 rounded-full transition-colors",style:{background:P<=re?"#2E7D32":"rgba(255,255,255,0.1)"}},P))}),l.jsx("div",{className:"p-5 min-h-[240px] overflow-y-auto flex-1",children:u==="store"?l.jsxs(l.Fragment,{children:[I==="browse"&&l.jsxs("div",{className:"space-y-3",children:[J?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:[J.slice(0,8),"..."]})]}),l.jsx("button",{onClick:()=>{zl=null,localStorage.removeItem("tycono_instance_id"),ce(null)},className:"text-white/30 hover:text-white/60 cursor-pointer",children:"Sign out"})]}):l.jsx(e6,{onLogin:P=>{zl=P,localStorage.setItem("tycono_instance_id",P),ce(P)}}),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:P=>{if(P.key==="Enter"){const et=P.target.value.trim().replace(/^tycono:/,"");et&&(Le(et),P.target.value="")}}}),l.jsx("button",{onClick:()=>{const P=document.querySelector('[placeholder="Paste ID (tycono:engineer)"]');if(P){const et=P.value.trim().replace(/^tycono:/,"");et&&(Le(et),P.value="")}},disabled:S,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:S?"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:P=>j(P.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:y,onChange:P=>v(P.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"})]})]}),f?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:me,className:"text-xs text-green-400 hover:underline cursor-pointer",children:"Retry"})]}):Ce.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:Ce.map(P=>l.jsx(t6,{char:P,isHired:De.has(P.id),onSelect:()=>Le(P.id),onVote:qe=>Vt(P.id,qe),onDelete:()=>jt(P.id),fetching:S,token:J},P.id))})]}),I==="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(Pa,{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:$,onChange:P=>q(P.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:G,onChange:P=>T(P.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(P=>P.id===G)&&G.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:H,onChange:P=>L(P.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(P=>l.jsxs("option",{value:P.id,className:"bg-[var(--wall)] text-white",children:[P.name," (",P.id,")"]},P.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 St,ve;const P=k.skills;if(P&&typeof P=="object"&&!Array.isArray(P)&&"primary"in P){const yt=[];return(ve=(St=P.primary)==null?void 0:St.frontmatter)!=null&&ve.name&&yt.push(P.primary.frontmatter.name),P.shared&&P.shared.forEach(sn=>{var en;return yt.push(((en=sn.frontmatter)==null?void 0:en.name)||sn.id)}),yt.map(sn=>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:sn},sn))}return(Array.isArray(P)?P:[]).map((yt,sn)=>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 yt=="string"?yt:yt.name},sn))})()})]})]}),Je&&l.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:Je})]})]}):u==="single"?l.jsxs(l.Fragment,{children:[re===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:we,value:le,onChange:P=>$e(P.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:Z,onChange:P=>{D(P.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),W(!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 ${bn?"border-red-400":"border-white/10 focus:border-white/25"}`}),bn&&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:KE.map(P=>l.jsx("button",{onClick:()=>{if(Q(P.value),P.value==="c-level")he("ceo");else{const qe=e.find(et=>et.level==="c-level");he((qe==null?void 0:qe.id)??"ceo")}},className:`flex-1 p-2 text-xs font-semibold rounded-lg border cursor-pointer transition-colors ${A===P.value?"border-green-600 bg-green-900/30 text-green-400":"border-white/10 text-white/50 hover:border-white/20"}`,children:P.label},P.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"}),A==="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:ie,onChange:P=>he(P.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(P=>P.level==="c-level").map(P=>l.jsxs("option",{value:P.id,className:"bg-[var(--wall)] text-white",children:[P.name," (",P.id,")"]},P.id))})]})]}),re===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:U,value:Ne,onChange:P=>Ie(P.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"})]}),ct.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:ct.map(P=>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:ot.has(P.id),onChange:()=>xt(qe=>{const et=new Set(qe);return et.has(P.id)?et.delete(P.id):et.add(P.id),et}),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:P.name}),l.jsx("div",{className:"text-[10px] text-white/40 truncate",children:P.description})]})]},P.id))})]})]}),re===3&&l.jsx("div",{className:"customize-body",style:{padding:0},children:l.jsx(xv,{roleId:"default",appearance:de,onChange:_e,onRandomize:()=>_e(hs()),onReset:()=>_e(hs()),label:l.jsxs("span",{children:[Z||"new-role"," — ",le||"New Role"]})})}),re===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(Pa,{roleId:"default",appearance:de,scale:4})}),l.jsxs("div",{className:"flex-1 space-y-2.5",children:[l.jsx(Co,{label:"Name",value:le}),l.jsx(Co,{label:"ID",value:Z,mono:!0}),l.jsx(Co,{label:"Level",value:A}),l.jsx(Co,{label:"Reports To",value:ie}),ot.size>0&&l.jsx(Co,{label:"Skills",value:[...ot].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:Ne})]})]}),Je&&l.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:Je})]})]}):l.jsxs(l.Fragment,{children:[dt==="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:ae,value:wt,onChange:P=>bt(P.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."})]}),Se.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 (",Se.length," role",Se.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:Se.map((P,qe)=>l.jsxs("tr",{className:`border-b border-white/5 ${P.error?"bg-red-900/10":""}`,children:[l.jsx("td",{className:"p-2 text-white/80",children:P.name}),l.jsx("td",{className:"p-2 text-white/60 font-mono",children:P.id}),l.jsx("td",{className:"p-2 text-white/60",children:P.level}),l.jsx("td",{className:"p-2 text-white/60",children:P.reportsTo}),P.error&&l.jsx("td",{className:"p-2 text-red-400 text-[10px]",children:P.error})]},qe))})]})})]})]}),dt==="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 — ",Se.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:Se.map((P,qe)=>l.jsxs("tr",{className:"border-b border-white/5",children:[l.jsx("td",{className:"p-2 text-white/30",children:qe+1}),l.jsx("td",{className:"p-2 text-white/80",children:P.name}),l.jsx("td",{className:"p-2 text-white/60 font-mono",children:P.id}),l.jsx("td",{className:"p-2 text-white/60",children:P.level}),l.jsx("td",{className:"p-2 text-white/60",children:P.reportsTo})]},qe))})]})}),Ye&&ft.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:[ft.done,"/",ft.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:`${ft.done/ft.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."}),Je&&l.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:Je})]})]})}),l.jsxs("div",{className:"flex justify-between px-5 pb-5",children:[l.jsxs("div",{children:[u==="single"&&re>1&&l.jsx("button",{onClick:()=>X(re-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"&&dt==="review"&&l.jsx("button",{onClick:()=>gn("input"),disabled:Ye,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"&&I==="review"&&l.jsx("button",{onClick:()=>{B("browse"),N(null),Fe("")},disabled:Ye,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"?re<So?l.jsx("button",{onClick:()=>X(re+1),disabled:!kt(re),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:Oe,disabled:Ye,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:Ye?"Hiring...":"HIRE"}):u==="bulk"?dt==="input"?l.jsxs("button",{onClick:()=>gn("review"),disabled:!Be,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 (",Se.length,")"]}):l.jsx("button",{onClick:Me,disabled:Ye,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:Ye?`Hiring ${ft.done}/${ft.total}...`:`HIRE ALL (${Se.length})`}):I==="review"?l.jsx("button",{onClick:Jt,disabled:Ye||!$.trim()||!G.trim()||e.some(P=>P.id===G),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:Ye?"Hiring...":"HIRE"}):null]})]})]})]})}function e6({onLogin:e}){const[n,a]=w.useState(""),[i,o]=w.useState(!1),[u,d]=w.useState(""),h=()=>{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"&&h()},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:h,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 t6({char:e,isHired:n,onSelect:a,onVote:i,onDelete:o,fetching:u,token:d}){const[h,m]=w.useState(!1),f=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:y=>{y.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:y=>{y.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"}),f&&(h?l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("button",{onClick:y=>{y.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:y=>{y.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:y=>{y.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 Co({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 n6({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 r6={cto:"🏗️",cbo:"📊",pm:"📋",engineer:"⚙️",designer:"🎨",qa:"🔍"};function a6({roleId:e,title:n,roleColor:a,active:i,isWave:o,isWaveStreaming:u,onClick:d,onClose:h,"data-session-id":m}){const f=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 ${f}`}: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:r6[e]??"👤"}),l.jsx("span",{className:`truncate ${o?"text-amber-400/90":""}`,children:n}),l.jsx("span",{onClick:h,className:"ml-auto text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-sm leading-none",children:"×"})]})}function l6({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:[$m],components:{code:i6,table:({children:i})=>l.jsx("div",{className:"overflow-x-auto my-2",children:l.jsx("table",{className:"terminal-table",children:i})})},children:a})})}function i6({className:e,children:n,...a}){const i=/language-(\w+)/.exec(e??"");return i||typeof n=="string"&&n.includes(`
90
- `)?l.jsx(s6,{language:i==null?void 0:i[1],children:n}):l.jsx("code",{className:"terminal-inline-code",...a,children:n})}function s6({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 o6={cto:"🏗️",cbo:"📊",pm:"📋",engineer:"⚙️",designer:"🎨",qa:"🔍"};function c6({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 Dh(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 u6(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:Dh(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=Dh(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?Dh(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 d6({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 f6({events:e,isStreaming:n}){const[a,i]=w.useState(!1);if(e.length===0)return null;const o=u6(e);if(o.length===0)return null;const u=e.filter(v=>v.type==="thinking").length,d=e.filter(v=>v.type==="tool"),h=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),f=[];if(u>0&&f.push("thinking"),d.length>0){const v=[...new Set(d.map(b=>b.toolName))];v.length<=3?f.push(v.join(", ")):f.push(`${d.length} tool calls`)}h.length>0&&f.push(`${h.length} dispatch`),m>1&&f.push(`${m} turns`);const x=f.join(" · "),y=!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?"...":""]})]}),y&&l.jsx("div",{className:"stream-activity-events",children:o.map((v,b)=>l.jsx(d6,{event:v,isStreaming:n&&b===o.length-1},b))})]})}function h6(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 m6({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(c6,{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?h6(e.events):void 0),h=((d==null?void 0:d.length)??0)>0,m=!!e.thinking,f=m&&!e.content&&u&&!h;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:o6[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()}),h&&l.jsx(f6,{events:d,isStreaming:u}),m&&!h&&l.jsxs("details",{open:f,className:"mb-1",children:[l.jsxs("summary",{className:"text-[10px] text-purple-400/70 cursor-pointer select-none flex items-center gap-1",children:[f&&l.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-purple-400 animate-pulse"}),"thinking",f?"...":` (${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(l6,{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,y)=>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})`:""]})]},y))]})]})]})}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(m6,{message:u,roleId:n,roleColor:a},u.id)),l.jsx("div",{ref:i})]})}const p6=5*1024*1024,x6=["image/png","image/jpeg","image/gif","image/webp"];function Gm({mode:e,onModeChange:n,onSend:a,disabled:i,disabledReason:o}){const[u,d]=w.useState(""),[h,m]=w.useState([]),[f,x]=w.useState(!1),[y,v]=w.useState(null),b=w.useRef(null),j=w.useRef(null),k=w.useRef(!1);w.useEffect(()=>{const T=b.current;T&&(T.style.height="0",T.style.height=Math.min(T.scrollHeight,120)+"px")},[u]),w.useEffect(()=>{if(y){const T=setTimeout(()=>v(null),3e3);return()=>clearTimeout(T)}},[y]);const N=w.useCallback(async T=>x6.includes(T.type)?T.size>p6?(v(`File too large: ${(T.size/1024/1024).toFixed(1)}MB. Max 5MB.`),null):new Promise(H=>{const L=new FileReader;L.onload=()=>{const ce=L.result.split(",")[1];H({type:"image",data:ce,name:T.name,mediaType:T.type})},L.onerror=()=>{v("Failed to read file"),H(null)},L.readAsDataURL(T)}):(v(`Unsupported format: ${T.type}. Use PNG, JPG, GIF, or WebP.`),null),[]),S=w.useCallback(async T=>{const H=Array.from(T),L=[];for(const J of H){const ce=await N(J);ce&&L.push(ce)}L.length>0&&m(J=>[...J,...L])},[N]),E=w.useCallback(T=>{T.preventDefault(),T.stopPropagation(),x(!0)},[]),_=w.useCallback(T=>{T.preventDefault(),T.stopPropagation(),x(!1)},[]),R=w.useCallback(T=>{T.preventDefault(),T.stopPropagation(),x(!1);const H=T.dataTransfer.files;H.length>0&&S(H)},[S]),I=w.useCallback(T=>{const H=T.clipboardData.items,L=[];for(let J=0;J<H.length;J++){const ce=H[J];if(ce.type.startsWith("image/")){const re=ce.getAsFile();re&&L.push(re)}}L.length>0&&(T.preventDefault(),S(L))},[S]),B=w.useCallback(T=>{const H=T.target.files;H&&H.length>0&&S(H),T.target.value=""},[S]),$=w.useCallback(T=>{m(H=>H.filter((L,J)=>J!==T))},[]),q=()=>{const T=u.trim();!T&&h.length===0||i||(a(T,h.length>0?h:void 0),d(""),m([]))},G=T=>{if(T.key==="Enter"&&!T.shiftKey){if(k.current)return;T.preventDefault(),q()}};return l.jsxs("div",{className:`border-t border-[var(--terminal-border)] p-3 shrink-0 transition-colors ${f?"bg-[var(--terminal-surface-light)] border-amber-500/50":""}`,onDragOver:E,onDragLeave:_,onDrop:R,children:[y&&l.jsx("div",{className:"text-[10px] text-red-400 mb-2 text-center",children:y}),o&&l.jsx("div",{className:"text-[10px] text-amber-400/70 mb-2 text-center",children:o}),h.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:h.map((T,H)=>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:${T.mediaType};base64,${T.data}`,alt:T.name,className:"w-full h-full object-cover"}),l.jsx("button",{onClick:()=>$(H),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:T.name})]},H))}),f&&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 T;return(T=j.current)==null?void 0:T.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:j,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,onChange:B,className:"hidden"}),l.jsx("textarea",{ref:b,value:u,onChange:T=>d(T.target.value),onKeyDown:G,onCompositionStart:()=>{k.current=!0},onCompositionEnd:()=>{k.current=!1},onPaste:I,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"}),l.jsx("button",{onClick:q,disabled:i||!u.trim()&&h.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 y6={ceo:"#FFB300",cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"},gv={ceo:"CEO (You)",cto:"CTO",cbo:"CBO",pm:"PM",engineer:"Engineer",designer:"Designer",qa:"QA","data-analyst":"Data Analyst"};function Zy(e){return new Date(e).toLocaleTimeString("ko-KR",{hour:"2-digit",minute:"2-digit"})}function g6({msg:e}){const n=y6[e.roleId]??"#888",a=gv[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:Zy(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:Zy(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 b6({channel:e,allRoles:n,onUpdateMembers:a,onUpdateTopic:i,onSendMessage:o}){const u=w.useRef(null),d=w.useRef(null),[h,m]=w.useState("");w.useEffect(()=>{var _;const S=d.current;if(!S)return;S.scrollHeight-S.scrollTop-S.clientHeight<80&&((_=u.current)==null||_.scrollIntoView({behavior:"smooth"}))},[e.messages.length]);const[f,x]=w.useState(!1),[y,v]=w.useState(!1),[b,j]=w.useState(""),k=o&&e.id!=="general",N=()=>{!h.trim()||!o||(o(e.id,h.trim()),m(""),setTimeout(()=>{var S;return(S=u.current)==null?void 0:S.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(S=>gv[S]??S).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(!f),children:f?"Done":"Invite"})]}),!e.isDefault&&i&&l.jsx("div",{className:"px-3 pb-2 mb-1",children:y?l.jsx("input",{autoFocus:!0,value:b,onChange:S=>j(S.target.value),onKeyDown:S=>{S.key==="Enter"&&(i(e.id,b.trim()),v(!1)),S.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..."})}),f&&!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(S=>{const E=e.members.includes(S.id);return l.jsxs("button",{className:`text-[10px] px-2 py-1 rounded ${E?"bg-white/15 text-[var(--terminal-text)]":"bg-white/5 text-[var(--terminal-text-muted)]"}`,onClick:()=>{const _=E?e.members.filter(R=>R!==S.id):[...e.members,S.id];a(e.id,_)},children:[E?"✓ ":"",S.name]},S.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(S=>l.jsx(g6,{msg:S},S.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:h,onChange:S=>m(S.target.value),onKeyDown:S=>{S.key==="Enter"&&!S.shiftKey&&(S.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 Th={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"},v6=400,w6=800;function Jy({sessions:e,activeSessionId:n,roles:a,streamingSessionId:i,width:o,onWidthChange:u,onSwitchSession:d,onCloseSession:h,onCreateSession:m,onClearEmpty:f,onCloseAll:x,onSendMessage:y,onModeChange:v,onCloseTerminal:b,onMaximize:j,chatChannels:k,activeChatChannelId:N,onSwitchChatChannel:S,onCreateChatChannel:E,onDeleteChatChannel:_,onUpdateChatMembers:R,onUpdateChatTopic:I,onSendChatMessage:B,unreadChannels:$}){const[q,G]=w.useState(!1),[T,H]=w.useState(!1),[L,J]=w.useState(!1),[ce,re]=w.useState(""),X=N!=null,le=k==null?void 0:k.find(ge=>ge.id===N),[ee,Z]=w.useState(!1),[D,F]=w.useState(!1),[W,A]=w.useState(!1),Q=w.useRef(0),ie=w.useRef(0),he=w.useRef(null),Ne=e.find(ge=>ge.id===n),Ie=i===n,de=e.filter(ge=>ge.messages.length===0).length,_e=w.useCallback(()=>{const ge=he.current;ge&&(F(ge.scrollLeft>0),A(ge.scrollLeft+ge.clientWidth<ge.scrollWidth-1))},[]);w.useEffect(()=>{if(!n||!he.current)return;const ge=he.current.querySelector(`[data-session-id="${n}"]`);ge&&ge.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"}),_e()},[n,e.length,_e]),w.useEffect(()=>{const ge=he.current;if(!ge)return;_e(),ge.addEventListener("scroll",_e);const Je=new ResizeObserver(_e);return Je.observe(ge),()=>{ge.removeEventListener("scroll",_e),Je.disconnect()}},[_e]);const Ye=w.useCallback(ge=>{ge.preventDefault(),Q.current=ge.clientX,ie.current=o,Z(!0);const Je=j,Fe=()=>{Z(!1),document.removeEventListener("mousemove",ct),document.removeEventListener("mouseup",Fe)},ct=Ke=>{const ot=Q.current-Ke.clientX,xt=ie.current+ot;if(xt>=window.innerWidth*.6&&Je){Fe(),Je();return}const wt=Math.min(w6,Math.max(v6,xt));u==null||u(wt)};document.addEventListener("mousemove",ct),document.addEventListener("mouseup",Fe)},[o,u,j]);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 ${ee?"bg-[var(--terminal-border-hover)]":"bg-transparent"}`,onMouseDown:Ye}),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:[D&&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:he,className:"flex items-center overflow-x-auto terminal-tab-scroll gap-px px-1 py-1",children:[k==null?void 0:k.map(ge=>l.jsxs("button",{onClick:()=>{S==null||S(ge.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 ${N===ge.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:N===ge.id?{borderTop:"2px solid #4CAF50"}:void 0,children:[l.jsx("span",{className:"text-[10px]",children:"💬"}),l.jsx("span",{className:"truncate",children:ge.name}),($==null?void 0:$.has(ge.id))&&N!==ge.id&&l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-400 shrink-0"}),!ge.isDefault&&l.jsx("span",{onClick:Je=>{Je.stopPropagation(),_==null||_(ge.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:"×"})]},ge.id)),k&&k.length>0&&e.length>0&&l.jsx("div",{className:"w-px h-4 bg-[var(--terminal-border)] shrink-0 mx-1"}),e.map(ge=>l.jsx(a6,{roleId:ge.roleId,title:ge.title,roleColor:Th[ge.roleId]??"#666",active:!X&&ge.id===n,isWave:ge.source==="wave",isWaveStreaming:ge.source==="wave"&&ge.status==="active",onClick:()=>{S==null||S(null),d(ge.id)},onClose:Je=>{Je.stopPropagation(),h(ge.id)},"data-session-id":ge.id},ge.id))]}),W&&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:()=>{G(!q),H(!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:"+"}),q&&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:[E&&l.jsxs(l.Fragment,{children:[L?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:ce,onChange:ge=>re(ge.target.value),onKeyDown:ge=>{ge.key==="Enter"&&ce.trim()&&(E(ce.trim(),[]),re(""),J(!1),G(!1)),ge.key==="Escape"&&(J(!1),re(""))},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:()=>J(!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(ge=>l.jsxs("button",{onClick:()=>{m(ge.id),S==null||S(null),G(!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:Th[ge.id]??"#666"}}),ge.id.toUpperCase()," — ",ge.name]},ge.id))]})]}),l.jsxs("div",{className:"relative shrink-0",children:[l.jsx("button",{onClick:()=>{H(!T),G(!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:"···"}),T&&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":""]}),de>0&&f&&l.jsxs("button",{onClick:()=>{f(),H(!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 (",de,")"]}),e.length>0&&x&&l.jsx("button",{onClick:()=>{x(),H(!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"})]})]}),j&&l.jsx("button",{onClick:j,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:b,className:"px-2 py-1 text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-sm cursor-pointer shrink-0",children:"×"})]}),X&&le?l.jsx(b6,{channel:le,allRoles:a,onUpdateMembers:R,onUpdateTopic:I,onSendMessage:B}):Ne?l.jsxs(l.Fragment,{children:[l.jsx(yv,{messages:Ne.messages,roleId:Ne.roleId,roleColor:Th[Ne.roleId]??"#666"}),Ne.source==="wave"?l.jsxs("div",{className:"shrink-0 px-4 py-2 border-t border-[var(--terminal-border)] bg-[var(--terminal-bg-deeper)] flex items-center gap-2",children:[l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 shrink-0",style:Ne.status==="active"?{animation:"pulse 2s infinite"}:void 0}),l.jsx("span",{className:"text-[11px] text-amber-400/80",children:"Wave execution · read-only"}),l.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)] ml-auto",children:"Interact via Wave Command Center"})]}):l.jsx(Gm,{mode:Ne.mode,onModeChange:ge=>v(Ne.id,ge),onSend:(ge,Je)=>y(Ne.id,ge,Ne.mode,Je),disabled:Ie,disabledReason:Ie?`${Ne.roleId.toUpperCase()} is responding...`: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 k6(){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,h)=>{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:h}),signal:m.signal}).then(async f=>{var N,S,E,_,R;if(!f.ok||!f.body){d.onError("Failed to connect");return}const x=f.body.getReader(),y=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:I,value:B}=await x.read();if(I)break;b=Date.now(),v+=y.decode(B,{stream:!0});const $=v.split(`
91
- `);v=$.pop()??"";let q="";for(let G=0;G<$.length;G++){const T=$[G];if(T.startsWith("event: ")){q=T.slice(7).trim();continue}if(T.startsWith("data: ")){let H;try{H=JSON.parse(T.slice(6))}catch{q="";continue}switch(q){case"thinking":H.text&&((N=d.onThinking)==null||N.call(d,H.text));break;case"output":H.text&&d.onText(H.text);break;case"tool":(S=d.onToolUse)==null||S.call(d,H.name,H.input);break;case"dispatch":(E=d.onDispatch)==null||E.call(d,H.roleId,H.task);break;case"dispatch:progress":(_=d.onDispatchProgress)==null||_.call(d,H.roleId,H.type,H);break;case"turn":(R=d.onTurn)==null||R.call(d,H.turn);break;case"done":d.onDone(H);break;case"error":d.onError(H.message??"Unknown error");break;default:H.text&&d.onText(H.text);break}q=""}}}}finally{clearInterval(k)}}).catch(f=>{f.name!=="AbortError"&&d.onError(f.message)}),{abort:n}},[n]),abort:n}}const bv="tycono-appearances",hm="tycono-theme";function eg(){try{const e=localStorage.getItem(bv);return e?JSON.parse(e):{}}catch{return{}}}function Fh(e){localStorage.setItem(bv,JSON.stringify(e))}function tg(){try{const e=localStorage.getItem(hm);if(e&&e in Ja)return e}catch{}return"default"}const vv=new Set;for(const e of Object.values(Ja))for(const n of Object.keys(e.vars))vv.add(n);function j6(e){var i;const n=(i=Ja[e])==null?void 0:i.vars;if(!n)return;const a=document.documentElement;for(const o of vv)o in n||a.style.removeProperty(o);for(const[o,u]of Object.entries(n))a.style.setProperty(o,u)}const Mh={mode:"auto",intervalSec:18,dailyBudgetUsd:1},mm="tycono-speech-settings",Rh="tycono-language";function S6(){try{const e=localStorage.getItem(mm);return e?{...Mh,...JSON.parse(e)}:Mh}catch{return Mh}}function C6(){const[e,n]=w.useState(eg),[a,i]=w.useState(tg),[o,u]=w.useState(S6),[d,h]=w.useState(()=>{try{return localStorage.getItem(Rh)??"auto"}catch{return"auto"}}),m=w.useRef(!1);w.useEffect(()=>{m.current||(m.current=!0,ye.getPreferences().then(k=>{const N=Object.keys(k.appearances??{}).length>0||k.theme!=="default";if(k.speech&&(u(S=>({...S,...k.speech})),localStorage.setItem(mm,JSON.stringify(k.speech))),k.language&&(h(k.language),localStorage.setItem(Rh,k.language)),N){const S=k.appearances;n(S),Fh(S),k.theme&&k.theme in Ja&&(i(k.theme),localStorage.setItem(hm,k.theme))}else{const S=eg(),E=tg();(Object.keys(S).length>0||E!=="default")&&ye.updatePreferences({appearances:S,theme:E}).catch(()=>{})}}).catch(()=>{}))},[]),w.useEffect(()=>{j6(a)},[a]);const f=w.useCallback(k=>e[k]??Vm(k),[e]),x=w.useCallback((k,N)=>{n(S=>{const E={...S,[k]:N};return Fh(E),ye.updatePreferences({appearances:E}).catch(()=>{}),E})},[]),y=w.useCallback(k=>{n(N=>{const S={...N};return delete S[k],Fh(S),ye.updatePreferences({appearances:S}).catch(()=>{}),S})},[]),v=w.useCallback(k=>{i(k),localStorage.setItem(hm,k),ye.updatePreferences({theme:k}).catch(()=>{})},[]),b=w.useCallback(k=>{u(N=>{const S={...N,...k};return localStorage.setItem(mm,JSON.stringify(S)),ye.updatePreferences({speech:S}).catch(()=>{}),S})},[]),j=w.useCallback(k=>{h(k),localStorage.setItem(Rh,k),ye.updatePreferences({language:k}).catch(()=>{})},[]);return{appearances:e,getAppearance:f,setAppearance:x,resetAppearance:y,theme:a,setTheme:v,speechSettings:o,setSpeechSettings:b,language:d,setLanguage:j}}const N6=3e4,E6=3e5;function A6(){var H;const[e,n]=w.useState("akb"),[a,i]=w.useState(null),[o,u]=w.useState("synced"),[d,h]=w.useState([]),[m,f]=w.useState(null),[x,y]=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 L=await ye.getSaveStatus(j.current);i(L),L.noGit?u("no-git"):u(J=>J==="saving"?J:L.dirty?"dirty":"synced")}catch{u("error")}},[]),N=w.useCallback(async()=>{try{const L=await ye.getSyncStatus(j.current);f({ahead:L.ahead,behind:L.behind,branch:L.branch,hasRemote:L.hasRemote})}catch{}},[]),S=w.useCallback(()=>{v.current&&clearInterval(v.current),k(),v.current=setInterval(k,N6),b.current&&clearInterval(b.current),N(),b.current=setInterval(N,E6)},[k,N]);w.useEffect(()=>()=>{v.current&&clearInterval(v.current),b.current&&clearInterval(b.current)},[]);const E=w.useCallback(L=>{n(L),j.current=L,i(null),f(null),h([]),setTimeout(()=>{k(),N()},0)},[k,N]),_=w.useCallback(async L=>{u("saving");try{const J=await ye.save(L,j.current);return await k(),J}catch(J){throw u("error"),J}},[k]),R=w.useCallback(async()=>{try{const L=await ye.getSaveHistory(20,j.current);h(L)}catch{}},[]),I=w.useCallback(async L=>{u("saving");try{await ye.restoreSave(L,void 0,j.current),await k()}catch(J){throw u("error"),J}},[k]),B=w.useCallback(async()=>{y(!0);try{const L=await ye.pull(j.current);return await k(),await N(),L}catch(L){throw L}finally{y(!1)}},[k,N]),$=w.useCallback(async()=>{try{await ye.initGit(),await k()}catch{u("error")}},[k]),q=a?a.modified.length+a.untracked.length:0,G=((H=a==null?void 0:a.lastCommit)==null?void 0:H.date)??null,T=w.useCallback(async()=>{S()},[S]);return{state:o,dirtyCount:q,lastSaved:G,status:a,save:_,history:d,loadHistory:R,restore:I,refresh:T,initGit:$,repo:e,setRepo:E,syncInfo:m,fetchSyncStatus:N,pull:B,pulling:x}}const ng={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."]},rg={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."]},D6=[{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."}]}],T6=18e3,ag=6e3,F6=2500,M6=30*6e4,wv="tycono:relationships";function R6(){try{const e=localStorage.getItem(wv);return e?JSON.parse(e):[]}catch{return[]}}function z6(e){localStorage.setItem(wv,JSON.stringify(e))}function mu(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 pu(e){return Math.min(100,e.dispatches*5+e.wavesTogether*10+e.conversations*2)}function xu(e){return e[Math.floor(Math.random()*e.length)]}function _6(e,n,a){const i=a.find(h=>h.id===e),o=a.find(h=>h.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 B6(e,n){return e.relation==="any"?!0:e.relation===n}function O6({roles:e,roleStatuses:n,activeExecs:a,getStandupSpeech:i}){const[o,u]=w.useState(new Map),[d,h]=w.useState(R6),m=w.useRef({}),f=w.useRef(null),x=w.useRef(e),y=w.useRef(n),v=w.useRef(a),b=w.useRef(i),j=w.useRef(d);x.current=e,y.current=n,v.current=a,b.current=i,j.current=d,w.useEffect(()=>{const R=Date.now();for(const[I,B]of Object.entries(n))B==="working"&&(m.current[I]=R)},[n]),w.useEffect(()=>{z6(d)},[d]);const k=w.useCallback(R=>{const I=y.current[R],B=v.current.find(H=>H.roleId===R);if(I==="working"&&(B!=null&&B.task))return null;const $=b.current(R);if($&&Math.random()<.3)return{text:$,type:"work",ts:Date.now()};const q=Date.now(),G=m.current[R]??0;if(q-G>M6&&Math.random()<.5){const H=rg[R]??rg.engineer;return{text:xu(H),type:"guilt",ts:q}}const T=ng[R]??ng.engineer;return{text:xu(T),type:"personality",ts:q}},[]),N=w.useCallback(R=>{if(f.current)return!1;const I=R.filter(le=>y.current[le.id]!=="working");if(I.length<2)return!1;const B=[...I].sort(()=>Math.random()-.5),$=B[0],q=B[1],G=_6($.id,q.id,R);if(!G)return!1;const T=mu(j.current,$.id,q.id),H=pu(T),L=D6.filter(le=>B6(le,G)&&H>=le.minFamiliarity);if(L.length===0)return!1;const J=xu(L);let ce=$.id,re=q.id;J.relation==="superior-subordinate"&&(q.reportsTo===$.id||$.level==="c-level"?(ce=$.id,re=q.id):(ce=q.id,re=$.id)),f.current={templateId:J.id,roleA:ce,roleB:re,turnIdx:0,timer:null};const X=le=>{if(!f.current||le>=J.turns.length){f.current=null,h(F=>{const W=[...F],A=mu(W,ce,re);return A.conversations++,A.familiarity=pu(A),A.lastInteraction=new Date().toISOString(),W}),setTimeout(()=>{u(F=>{const W=new Map(F);return W.delete(ce),W.delete(re),W})},ag);return}const ee=J.turns[le],Z=ee.speaker==="A"?ce:re,D=ee.speaker==="A"?re:ce;u(F=>{const W=new Map(F);if(W.set(Z,{text:ee.text,type:"social",partnerId:D,ts:Date.now()}),le>0){const A=J.turns[le-1].speaker==="A"?ce:re;A!==Z&&W.delete(A)}return W}),f.current.turnIdx=le,f.current.timer=setTimeout(()=>X(le+1),F6)};return X(0),!0},[]);w.useEffect(()=>{const R=setInterval(()=>{const I=x.current;if(I.length===0||f.current||Math.random()<.35&&N(I))return;const B=I.filter(G=>y.current[G.id]!=="working");if(B.length===0)return;const $=xu(B),q=k($.id);q&&(u(G=>{const T=new Map(G);return T.set($.id,q),T}),setTimeout(()=>{u(G=>{const T=new Map(G),H=T.get($.id);return H&&H.ts===q.ts&&T.delete($.id),T})},ag))},T6);return()=>{var I;clearInterval(R),(I=f.current)!=null&&I.timer&&clearTimeout(f.current.timer)}},[k,N]);const S=w.useCallback(R=>{const I=o.get(R);return(I==null?void 0:I.text)??""},[o]),E=w.useCallback((R,I)=>{h(B=>{const $=[...B],q=mu($,R,I);return q.dispatches++,q.familiarity=pu(q),q.lastInteraction=new Date().toISOString(),$})},[]),_=w.useCallback(R=>{R.length<2||h(I=>{const B=[...I];for(let $=0;$<R.length;$++)for(let q=$+1;q<R.length;q++){const G=mu(B,R[$],R[q]);G.wavesTogether++,G.familiarity=pu(G),G.lastInteraction=new Date().toISOString()}return B})},[]);return{speeches:o,getSpeech:S,relationships:d,notifyDispatch:E,notifyWave:_}}const kv="tycono:office-chat";let L6=0;function $6(){return`chat-${Date.now()}-${++L6}`}function zh(){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 I6(){try{const e=localStorage.getItem(kv);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[...zh(),...i]}const a=zh();for(const i of a)n.find(o=>o.id===i.id)||n.unshift(i);return n}}catch{}return zh()}function H6(e){const n=e.map(a=>({...a,messages:a.messages.slice(-200)}));localStorage.setItem(kv,JSON.stringify(n))}function U6(){const[e,n]=w.useState(I6),[a,i]=w.useState(null),[o,u]=w.useState(new Set);w.useEffect(()=>{H6(e)},[e]);const d=w.useCallback(b=>{i(b),b&&u(j=>{const k=new Set(j);return k.delete(b),k})},[]),h=w.useCallback(b=>{const j={...b,id:$6()};n(k=>{const N=k.map(S=>S.id==="general"?b.type==="dispatch"?{...S,messages:[...S.messages,j].slice(-200)}:S:b.channelId?S.id===b.channelId?{...S,messages:[...S.messages,j].slice(-200)}:S:S.members.length>0&&S.members.includes(b.roleId)?{...S,messages:[...S.messages,j].slice(-200)}:S);return u(S=>{const E=new Set(S);for(const _ of N){const R=k.find(I=>I.id===_.id);R&&_.messages.length>R.messages.length&&E.add(_.id)}return E}),N})},[]),m=w.useCallback((b,j,k)=>{const N=`ch-${Date.now()}`,S={id:N,name:b.startsWith("#")?b:`#${b}`,members:j,isDefault:!1,messages:[],topic:k};n(E=>[...E,S]),i(N)},[]),f=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))},[]),y=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(S=>S.level!=="c-level").map(S=>S.id);if(k.members.length!==N.length||!N.every(S=>k.members.includes(S)))return{...k,members:N}}return k}))},[]);return{channels:e,activeChannelId:a,setActiveChannelId:d,pushMessage:h,createChannel:m,deleteChannel:f,updateMembers:x,updateTopic:y,unreadChannels:o,syncDefaultMembers:v}}const q6=45e3,lg=5e3,Y6=4,X6=20;function W6({roles:e,roleStatuses:n,activeExecs:a,channels:i,relationships:o,pushMessage:u,speechSettings:d,engineType:h,hasApiKey:m}){const x=((d==null?void 0:d.mode)==="auto"?h==="claude-cli"||h==="local"?"llm":"template":(d==null?void 0:d.mode)??"template")==="llm"&&(m!==!1||h==="claude-cli"),y=((d==null?void 0:d.intervalSec)??q6/1e3)*1e3,v=w.useRef(e),b=w.useRef(n),j=w.useRef(a),k=w.useRef(i),N=w.useRef(o),S=w.useRef(u),E=w.useRef(0),_=w.useRef(!1);v.current=e,b.current=n,j.current=a,k.current=i,N.current=o,S.current=u;const R=w.useCallback(async($,q)=>{if(_.current)return!1;_.current=!0;try{if(!v.current.find(X=>X.id===$))return!1;const T=q.messages.slice(-X6).map(X=>({roleId:X.roleId,text:X.text,ts:X.ts})),H=v.current.filter(X=>q.members.includes(X.id)),L=N.current.filter(X=>X.roleA===$||X.roleB===$).map(X=>({partnerId:X.roleA===$?X.roleB:X.roleA,familiarity:X.familiarity})),J=j.current.find(X=>X.roleId===$),ce=J?{currentTask:J.task,taskProgress:null}:{currentTask:null,taskProgress:null},re=await ye.chatInChannel({channelId:q.name.replace("#",""),channelTopic:q.topic,roleId:$,history:T,members:H.map(X=>({id:X.id,name:X.name,level:X.level})),relationships:L,workContext:ce});return re.message?(S.current({ts:Date.now(),roleId:$,text:re.message,type:"chat",channelId:q.id}),!0):!1}catch{return!1}finally{_.current=!1}},[]),I=w.useCallback(async($,q)=>{if(E.current>=Y6){E.current=0;return}const G=$.members.filter(J=>J!==q&&b.current[J]!=="working");if(G.length===0){E.current=0;return}const T=G[Math.floor(Math.random()*G.length)];if(Math.random()>.7){E.current=0;return}const H=E.current*2e3,L=Math.random()*5e3;setTimeout(async()=>{E.current++;const J=k.current.find(re=>re.id===$.id);if(!J)return;if(await R(T,J)){const re=.6-E.current*.1;Math.random()<re?I(J,T):E.current=0}else E.current=0},lg+H+L)},[R]);return w.useEffect(()=>{if(!x)return;const $=setInterval(async()=>{const q=v.current;if(q.length===0||_.current)return;const G=q.filter(ce=>b.current[ce.id]!=="working");if(G.length===0)return;const T=G[Math.floor(Math.random()*G.length)],H=k.current.filter(ce=>ce.members.length===0?!0:ce.members.includes(T.id));if(H.length===0)return;const L=H[Math.floor(Math.random()*H.length)];E.current=0,await R(T.id,L)&&I(L,T.id)},y);return()=>clearInterval($)},[x,y,R,I]),{triggerCeoReaction:w.useCallback($=>{if(!x)return;const q=k.current.find(G=>G.id===$);q&&(E.current=0,setTimeout(()=>{I(q,"ceo")},lg))},[x,I])}}function yu({type:e,className:n}){const a=w.useRef(null),i=aC(e);return w.useEffect(()=>{const o=a.current;if(!o||!i)return;const u=o.getContext("2d");u&&iC(u,i)},[e,i]),i?l.jsx("canvas",{ref:a,width:i.canvasWidth,height:i.canvasHeight,className:n,style:{imageRendering:"pixelated",display:"block"}}):null}const jv=[[1,8],[3,5],[8,1],[5,3]],V6=[[1,4],[2,3],[4,1],[3,2]];function gu(e){const n=e===1||e===3?-1:0,a=jv[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 bu(e){const n=e===1||e===3?-1:0,a=jv[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 Ml(e,n){const a=e===1||e===3?-1:0,i=V6[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 ig={down:[gu(0),gu(1),gu(2),gu(3)],up:[bu(0),bu(1),bu(2),bu(3)],right:[Ml(0,!0),Ml(1,!0),Ml(2,!0),Ml(3,!0)],left:[Ml(0,!1),Ml(1,!1),Ml(2,!1),Ml(3,!1)]},Ae="#FAFAF7",On="#FFFFFF",Ee="#EDE8E2",Ge="#DDD6CC",Bo="#1A1A2E",Zu="#2A2A2A",Km="#FFB0B0",sg=[{x:2,y:0,w:1,h:1,c:Ee},{x:3,y:0,w:1,h:1,c:Ae},{x:4,y:0,w:1,h:1,c:On},{x:5,y:0,w:1,h:1,c:Ae},{x:6,y:0,w:1,h:1,c:Ee},{x:1,y:1,w:1,h:1,c:Ge},{x:2,y:1,w:1,h:1,c:Ae},{x:3,y:1,w:1,h:1,c:On},{x:4,y:1,w:1,h:1,c:Ae},{x:5,y:1,w:1,h:1,c:On},{x:6,y:1,w:1,h:1,c:Ae},{x:7,y:1,w:1,h:1,c:Ge},{x:0,y:2,w:1,h:1,c:Ge},{x:1,y:2,w:1,h:1,c:Ee},{x:2,y:2,w:1,h:1,c:Ae},{x:3,y:2,w:1,h:1,c:Ae},{x:4,y:2,w:1,h:1,c:On},{x:5,y:2,w:1,h:1,c:Ae},{x:6,y:2,w:1,h:1,c:Ae},{x:7,y:2,w:1,h:1,c:Ee},{x:8,y:2,w:1,h:1,c:Ge},{x:1,y:3,w:1,h:1,c:Ee},{x:2,y:3,w:1,h:1,c:Ae},{x:3,y:3,w:1,h:1,c:Bo},{x:4,y:3,w:1,h:1,c:Ae},{x:5,y:3,w:1,h:1,c:Bo},{x:6,y:3,w:1,h:1,c:Ae},{x:7,y:3,w:1,h:1,c:Ee},{x:2,y:4,w:1,h:1,c:Ee},{x:3,y:4,w:1,h:1,c:Ae},{x:4,y:4,w:1,h:1,c:Zu},{x:5,y:4,w:1,h:1,c:Ae},{x:6,y:4,w:1,h:1,c:Ee},{x:3,y:5,w:1,h:1,c:Ge},{x:4,y:5,w:1,h:1,c:Ee},{x:5,y:5,w:1,h:1,c:Ge},{x:2,y:6,w:1,h:1,c:Ee},{x:3,y:6,w:1,h:1,c:Ae},{x:4,y:6,w:1,h:1,c:On},{x:5,y:6,w:1,h:1,c:Ae},{x:6,y:6,w:1,h:1,c:Ee},{x:2,y:7,w:1,h:1,c:Ge},{x:3,y:7,w:1,h:1,c:Ee},{x:4,y:7,w:1,h:1,c:Ae},{x:5,y:7,w:1,h:1,c:Ee},{x:6,y:7,w:1,h:1,c:Ge}],G6=[{x:3,y:8,w:1,h:1,c:Ee},{x:5,y:8,w:1,h:1,c:Ee},{x:3,y:9,w:1,h:1,c:Ge},{x:5,y:9,w:1,h:1,c:Ge}],K6=[{x:2,y:8,w:1,h:1,c:Ee},{x:6,y:8,w:1,h:1,c:Ee},{x:2,y:9,w:1,h:1,c:Ge},{x:6,y:9,w:1,h:1,c:Ge}],og=[{x:2,y:0,w:1,h:1,c:Ee},{x:3,y:0,w:1,h:1,c:Ae},{x:4,y:0,w:1,h:1,c:On},{x:5,y:0,w:1,h:1,c:Ae},{x:6,y:0,w:1,h:1,c:Ee},{x:1,y:1,w:1,h:1,c:Ge},{x:2,y:1,w:1,h:1,c:Ee},{x:3,y:1,w:1,h:1,c:Ae},{x:4,y:1,w:1,h:1,c:On},{x:5,y:1,w:1,h:1,c:Ae},{x:6,y:1,w:1,h:1,c:Ee},{x:7,y:1,w:1,h:1,c:Ge},{x:0,y:2,w:1,h:1,c:Ge},{x:1,y:2,w:1,h:1,c:Ee},{x:2,y:2,w:1,h:1,c:Ae},{x:3,y:2,w:1,h:1,c:Ae},{x:4,y:2,w:1,h:1,c:Ae},{x:5,y:2,w:1,h:1,c:Ae},{x:6,y:2,w:1,h:1,c:Ae},{x:7,y:2,w:1,h:1,c:Ee},{x:8,y:2,w:1,h:1,c:Ge},{x:1,y:3,w:1,h:1,c:Ge},{x:2,y:3,w:1,h:1,c:Ee},{x:3,y:3,w:1,h:1,c:Ae},{x:4,y:3,w:1,h:1,c:Ae},{x:5,y:3,w:1,h:1,c:Ae},{x:6,y:3,w:1,h:1,c:Ee},{x:7,y:3,w:1,h:1,c:Ge},{x:2,y:4,w:1,h:1,c:Ge},{x:3,y:4,w:1,h:1,c:Ee},{x:4,y:4,w:1,h:1,c:Ae},{x:5,y:4,w:1,h:1,c:Ee},{x:6,y:4,w:1,h:1,c:Ge},{x:3,y:5,w:1,h:1,c:Ge},{x:4,y:5,w:1,h:1,c:Ee},{x:5,y:5,w:1,h:1,c:Ge},{x:2,y:6,w:1,h:1,c:Ee},{x:3,y:6,w:1,h:1,c:Ae},{x:4,y:6,w:1,h:1,c:Ae},{x:5,y:6,w:1,h:1,c:Ae},{x:6,y:6,w:1,h:1,c:Ee},{x:2,y:7,w:1,h:1,c:Ge},{x:3,y:7,w:1,h:1,c:Ee},{x:4,y:7,w:1,h:1,c:Ae},{x:5,y:7,w:1,h:1,c:Ee},{x:6,y:7,w:1,h:1,c:Ge},{x:4,y:5,w:1,h:1,c:Ae},{x:4,y:4,w:1,h:1,c:On}],Q6=[{x:3,y:8,w:1,h:1,c:Ee},{x:5,y:8,w:1,h:1,c:Ee},{x:3,y:9,w:1,h:1,c:Ge},{x:5,y:9,w:1,h:1,c:Ge}],P6=[{x:2,y:8,w:1,h:1,c:Ee},{x:6,y:8,w:1,h:1,c:Ee},{x:2,y:9,w:1,h:1,c:Ge},{x:6,y:9,w:1,h:1,c:Ge}],pm=[{x:8,y:0,w:1,h:1,c:Ee},{x:9,y:0,w:1,h:1,c:Ae},{x:10,y:0,w:1,h:1,c:On},{x:11,y:0,w:1,h:1,c:Ae},{x:7,y:1,w:1,h:1,c:Ge},{x:8,y:1,w:1,h:1,c:Ae},{x:9,y:1,w:1,h:1,c:On},{x:10,y:1,w:1,h:1,c:Ae},{x:11,y:1,w:1,h:1,c:Ae},{x:12,y:1,w:1,h:1,c:Ee},{x:0,y:2,w:1,h:1,c:On},{x:1,y:2,w:1,h:1,c:Ae},{x:3,y:2,w:1,h:1,c:Ee},{x:4,y:2,w:1,h:1,c:Ae},{x:5,y:2,w:1,h:1,c:Ae},{x:6,y:2,w:1,h:1,c:Ae},{x:7,y:2,w:1,h:1,c:Ee},{x:8,y:2,w:1,h:1,c:Ae},{x:9,y:2,w:1,h:1,c:Ae},{x:10,y:2,w:1,h:1,c:Ae},{x:11,y:2,w:1,h:1,c:Ae},{x:12,y:2,w:1,h:1,c:Ee},{x:0,y:3,w:1,h:1,c:Ee},{x:1,y:3,w:1,h:1,c:Ge},{x:3,y:3,w:1,h:1,c:Ge},{x:4,y:3,w:1,h:1,c:Ee},{x:5,y:3,w:1,h:1,c:Ae},{x:6,y:3,w:1,h:1,c:Ee},{x:7,y:3,w:1,h:1,c:Ge},{x:8,y:3,w:1,h:1,c:Ae},{x:9,y:3,w:1,h:1,c:Bo},{x:10,y:3,w:1,h:1,c:Ae},{x:11,y:3,w:1,h:1,c:Ee},{x:3,y:4,w:1,h:1,c:Ge},{x:4,y:4,w:1,h:1,c:Ee},{x:5,y:4,w:1,h:1,c:Ae},{x:6,y:4,w:1,h:1,c:Ee},{x:8,y:4,w:1,h:1,c:Ee},{x:9,y:4,w:1,h:1,c:Ae},{x:10,y:4,w:1,h:1,c:Zu}],Sv=[{x:4,y:5,w:1,h:1,c:Ee},{x:6,y:5,w:1,h:1,c:Ee},{x:8,y:5,w:1,h:1,c:Ee},{x:10,y:5,w:1,h:1,c:Ee},{x:4,y:6,w:1,h:1,c:Ge},{x:6,y:6,w:1,h:1,c:Ge},{x:8,y:6,w:1,h:1,c:Ge},{x:10,y:6,w:1,h:1,c:Ge}],Cv=[{x:3,y:5,w:1,h:1,c:Ee},{x:5,y:5,w:1,h:1,c:Ee},{x:9,y:5,w:1,h:1,c:Ee},{x:11,y:5,w:1,h:1,c:Ee},{x:3,y:6,w:1,h:1,c:Ge},{x:5,y:6,w:1,h:1,c:Ge},{x:9,y:6,w:1,h:1,c:Ge},{x:11,y:6,w:1,h:1,c:Ge}];function Qm(e,n=13){return e.map(a=>({...a,x:n-1-a.x}))}const cg=Qm(pm),Z6=Qm(Sv),J6=Qm(Cv),eA={down:[[...sg,...G6],[...sg,...K6]],up:[[...og,...Q6],[...og,...P6]],right:[[...pm,...Sv],[...pm,...Cv]],left:[[...cg,...Z6],[...cg,...J6]]},tA=[{x:4,y:5,w:1,h:1,c:Km}],Tn="#FFD4D4",Wr="#FFCCD5",nA=[{x:2,y:0,w:1,h:1,c:Ge},{x:3,y:0,w:1,h:1,c:Ee},{x:4,y:0,w:1,h:1,c:Ae},{x:5,y:0,w:1,h:1,c:On},{x:6,y:0,w:1,h:1,c:Ee},{x:7,y:0,w:1,h:1,c:Ge},{x:1,y:1,w:1,h:1,c:Ge},{x:2,y:1,w:1,h:1,c:Ee},{x:3,y:1,w:1,h:1,c:Ae},{x:4,y:1,w:1,h:1,c:On},{x:5,y:1,w:1,h:1,c:Ae},{x:6,y:1,w:1,h:1,c:On},{x:7,y:1,w:1,h:1,c:Ee},{x:8,y:1,w:1,h:1,c:Ge},{x:1,y:2,w:1,h:1,c:Ee},{x:2,y:2,w:1,h:1,c:Ae},{x:3,y:2,w:1,h:1,c:Bo},{x:4,y:2,w:1,h:1,c:Ae},{x:5,y:2,w:1,h:1,c:Ae},{x:6,y:2,w:1,h:1,c:Bo},{x:7,y:2,w:1,h:1,c:Ae},{x:8,y:2,w:1,h:1,c:Ee},{x:2,y:3,w:1,h:1,c:Ee},{x:3,y:3,w:1,h:1,c:Ae},{x:4,y:3,w:1,h:1,c:Zu},{x:5,y:3,w:1,h:1,c:Km},{x:6,y:3,w:1,h:1,c:Ae},{x:7,y:3,w:1,h:1,c:Ee},{x:2,y:4,w:1,h:1,c:Ge},{x:3,y:4,w:1,h:1,c:Ee},{x:4,y:4,w:1,h:1,c:Ae},{x:5,y:4,w:1,h:1,c:Ae},{x:6,y:4,w:1,h:1,c:Ee},{x:7,y:4,w:1,h:1,c:Ge},{x:0,y:5,w:1,h:1,c:Ee},{x:1,y:5,w:1,h:1,c:Wr},{x:2,y:5,w:1,h:1,c:Ae},{x:3,y:5,w:1,h:1,c:Tn},{x:4,y:5,w:1,h:1,c:Tn},{x:5,y:5,w:1,h:1,c:Tn},{x:6,y:5,w:1,h:1,c:Tn},{x:7,y:5,w:1,h:1,c:Ae},{x:8,y:5,w:1,h:1,c:Wr},{x:9,y:5,w:1,h:1,c:Ee},{x:1,y:6,w:1,h:1,c:Ee},{x:2,y:6,w:1,h:1,c:Ae},{x:3,y:6,w:1,h:1,c:Tn},{x:4,y:6,w:1,h:1,c:Wr},{x:5,y:6,w:1,h:1,c:Wr},{x:6,y:6,w:1,h:1,c:Tn},{x:7,y:6,w:1,h:1,c:Ae},{x:8,y:6,w:1,h:1,c:Ee},{x:2,y:7,w:1,h:1,c:Ae},{x:3,y:7,w:1,h:1,c:Tn},{x:4,y:7,w:1,h:1,c:Tn},{x:5,y:7,w:1,h:1,c:Tn},{x:6,y:7,w:1,h:1,c:Tn},{x:7,y:7,w:1,h:1,c:Ae},{x:0,y:8,w:1,h:1,c:Ee},{x:1,y:8,w:1,h:1,c:Wr},{x:2,y:8,w:1,h:1,c:Ge},{x:3,y:8,w:1,h:1,c:Ee},{x:4,y:8,w:1,h:1,c:Ae},{x:5,y:8,w:1,h:1,c:Ae},{x:6,y:8,w:1,h:1,c:Ee},{x:7,y:8,w:1,h:1,c:Ge},{x:8,y:8,w:1,h:1,c:Wr},{x:9,y:8,w:1,h:1,c:Ee},{x:4,y:9,w:1,h:1,c:Ae},{x:5,y:9,w:1,h:1,c:On}],rA=[{x:2,y:0,w:1,h:1,c:Ge},{x:3,y:0,w:1,h:1,c:Ee},{x:4,y:0,w:1,h:1,c:Ae},{x:5,y:0,w:1,h:1,c:On},{x:6,y:0,w:1,h:1,c:Ee},{x:7,y:0,w:1,h:1,c:Ge},{x:1,y:1,w:1,h:1,c:Ge},{x:2,y:1,w:1,h:1,c:Ee},{x:3,y:1,w:1,h:1,c:Ae},{x:4,y:1,w:1,h:1,c:On},{x:5,y:1,w:1,h:1,c:Ae},{x:6,y:1,w:1,h:1,c:On},{x:7,y:1,w:1,h:1,c:Ee},{x:8,y:1,w:1,h:1,c:Ge},{x:1,y:2,w:1,h:1,c:Ee},{x:2,y:2,w:1,h:1,c:Ae},{x:3,y:2,w:1,h:1,c:Ee},{x:4,y:2,w:1,h:1,c:Ae},{x:5,y:2,w:1,h:1,c:Ae},{x:6,y:2,w:1,h:1,c:Ee},{x:7,y:2,w:1,h:1,c:Ae},{x:8,y:2,w:1,h:1,c:Ee},{x:2,y:3,w:1,h:1,c:Ee},{x:3,y:3,w:1,h:1,c:Ae},{x:4,y:3,w:1,h:1,c:Zu},{x:5,y:3,w:1,h:1,c:Km},{x:6,y:3,w:1,h:1,c:Ae},{x:7,y:3,w:1,h:1,c:Ee},{x:2,y:4,w:1,h:1,c:Ge},{x:3,y:4,w:1,h:1,c:Ee},{x:4,y:4,w:1,h:1,c:Ae},{x:5,y:4,w:1,h:1,c:Ae},{x:6,y:4,w:1,h:1,c:Ee},{x:7,y:4,w:1,h:1,c:Ge},{x:0,y:5,w:1,h:1,c:Ee},{x:1,y:5,w:1,h:1,c:Wr},{x:2,y:5,w:1,h:1,c:Ae},{x:3,y:5,w:1,h:1,c:Tn},{x:4,y:5,w:1,h:1,c:Tn},{x:5,y:5,w:1,h:1,c:Tn},{x:6,y:5,w:1,h:1,c:Tn},{x:7,y:5,w:1,h:1,c:Ae},{x:8,y:5,w:1,h:1,c:Wr},{x:9,y:5,w:1,h:1,c:Ee},{x:1,y:6,w:1,h:1,c:Ee},{x:2,y:6,w:1,h:1,c:Ae},{x:3,y:6,w:1,h:1,c:Tn},{x:4,y:6,w:1,h:1,c:Wr},{x:5,y:6,w:1,h:1,c:Wr},{x:6,y:6,w:1,h:1,c:Tn},{x:7,y:6,w:1,h:1,c:Ae},{x:8,y:6,w:1,h:1,c:Ee},{x:2,y:7,w:1,h:1,c:Ae},{x:3,y:7,w:1,h:1,c:Tn},{x:4,y:7,w:1,h:1,c:Tn},{x:5,y:7,w:1,h:1,c:Tn},{x:6,y:7,w:1,h:1,c:Tn},{x:7,y:7,w:1,h:1,c:Ae},{x:0,y:8,w:1,h:1,c:Ee},{x:1,y:8,w:1,h:1,c:Wr},{x:2,y:8,w:1,h:1,c:Ge},{x:3,y:8,w:1,h:1,c:Ee},{x:4,y:8,w:1,h:1,c:Ae},{x:5,y:8,w:1,h:1,c:Ae},{x:6,y:8,w:1,h:1,c:Ee},{x:7,y:8,w:1,h:1,c:Ge},{x:8,y:8,w:1,h:1,c:Wr},{x:9,y:8,w:1,h:1,c:Ee},{x:5,y:9,w:1,h:1,c:Ae},{x:6,y:9,w:1,h:1,c:On}],aA=[{x:1,y:9,w:7,h:1,c:"#100A06",a:.12}],lA=[{x:2,y:6,w:9,h:1,c:"#100A06",a:.12}],iA=[{x:1,y:10,w:8,h:1,c:"#100A06",a:.12}],rt=4,Zt=28,Bn=2,Tt=4,gt=4,Qa=[{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 Pm(e,n,a){const u=e.fy+Math.max(10,Math.floor(e.fh*.18)),d=Math.min(n,a),h=Math.ceil(n/d),m=[],f=d*28,x=e.fx+Math.max(8,Math.floor((e.fw-f)/2));for(let y=0;y<h&&m.length<n;y++){const v=Math.min(d,n-y*d);for(let b=0;b<v;b++)m.push({dx:x+b*28,dy:u+y*28,room:e.id})}return m}function sA(e){const i=Qa[0],o={id:"main",wx:rt+gt,wy:rt,ww:160-2*(rt+gt),wh:Zt,fx:rt+gt,fy:rt+Zt+Bn,fw:160-2*(rt+gt),fh:120-rt-Zt-Bn-rt,...i},u=Pm(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*(rt+gt))/2),offsetY:10}],h=[{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:h}}function oA(e){const o={id:"exec",wx:rt+gt,wy:rt,ww:144-rt-gt-Tt/2,wh:Zt,fx:rt+gt,fy:rt+Zt+Bn,fw:144-rt-gt-Tt/2,fh:66,...Qa[0]},u={id:"work",wx:144+Tt/2+gt,wy:rt,ww:144-Tt/2-gt-rt,wh:Zt,fx:144+Tt/2+gt,fy:rt+Zt+Bn,fw:144-Tt/2-gt-rt,fh:66,...Qa[1]},d={id:"meet",wx:rt+gt,wy:rt+Zt+Bn+66+Tt,ww:144-rt-gt-Tt/2,wh:Zt,fx:rt+gt,fy:rt+Zt+Bn+66+Tt+Zt+Bn,fw:144-rt-gt-Tt/2,fh:70,...Qa[2]},h={id:"comm",wx:144+Tt/2+gt,wy:rt+Zt+Bn+66+Tt,ww:144-Tt/2-gt-rt,wh:Zt,fx:144+Tt/2+gt,fy:rt+Zt+Bn+66+Tt+Zt+Bn,fw:144-Tt/2-gt-rt,fh:70,...Qa[3]},m={exec:o,work:u,meet:d,comm:h},f=[];let x=e;const y=[[o,Math.min(3,x)],[u,0]];y[1][1]=Math.min(3,x-y[0][1]);const v=[[d,0],[h,0]];let b=x-y[0][1]-y[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[B,$]of[...y,...v])$>0&&f.push(...Pm(B,$,3));const j=rt+Zt+Bn+66,k=144-Tt/2,N={exec_work:{id:"exec_work",type:"v",doorY:rt+Zt+Bn+20+12,xA:k-2,xB:u.fx+2},meet_comm:{id:"meet_comm",type:"v",doorY:rt+Zt+Bn+66+Tt+Zt+Bn+20+12,xA:k-2,xB:h.fx+2},exec_meet:{id:"exec_meet",type:"h",doorX:rt+gt+40+14,yA:j-2,yB:d.fy+2},work_comm:{id:"work_comm",type:"h",doorX:144+Tt/2+gt+40+14,yA:j-2,yB:h.fy+2}},S={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"}]},E={exec:o.fy+52,work:u.fy+48,meet:d.fy+56,comm:h.fy+42},_={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:h.fx+96,y:h.fy+8},{x:h.fx+60,y:h.fy+42},{x:h.fx+40,y:h.fy+42},{x:h.fx+20,y:h.fy+42}]},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}],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(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:f,doors:N,adjacency:S,corridorY:E,waypoints:_,wallDecorations:R,furniture:I}}function cA(e){const d={id:"exec",wx:rt+gt,wy:rt,ww:180-rt-gt-Tt/2,wh:Zt,fx:rt+gt,fy:rt+Zt+Bn,fw:180-rt-gt-Tt/2,fh:82,...Qa[0]},h={id:"work",wx:180+Tt/2+gt,wy:rt,ww:180-Tt/2-gt-rt,wh:Zt,fx:180+Tt/2+gt,fy:rt+Zt+Bn,fw:180-Tt/2-gt-rt,fh:82,...Qa[1]},m=rt+Zt+Bn+82,f={id:"meet",wx:rt+gt,wy:m+Tt,ww:180-rt-gt-Tt/2,wh:Zt,fx:rt+gt,fy:m+Tt+Zt+Bn,fw:180-rt-gt-Tt/2,fh:86,...Qa[2]},x={id:"comm",wx:180+Tt/2+gt,wy:m+Tt,ww:180-Tt/2-gt-rt,wh:Zt,fx:180+Tt/2+gt,fy:m+Tt+Zt+Bn,fw:180-Tt/2-gt-rt,fh:86,...Qa[3]},y={exec:d,work:h,meet:f,comm:x},v=[];let b=e;const j=[[d,Math.min(5,b)],[h,0]];j[1][1]=Math.min(5,b-j[0][1]);const k=[[f,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[q,G]of[...j,...k])G>0&&v.push(...Pm(q,G,4));const S=180-Tt/2,E={exec_work:{id:"exec_work",type:"v",doorY:d.fy+82/2,xA:S-2,xB:h.fx+2},meet_comm:{id:"meet_comm",type:"v",doorY:f.fy+86/2,xA:S-2,xB:x.fx+2},exec_meet:{id:"exec_meet",type:"h",doorX:d.fx+54,yA:m-2,yB:f.fy+2},work_comm:{id:"work_comm",type:"h",doorX:h.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:h.fy+82-12,meet:f.fy+86-12,comm:x.fy+86-12},I={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:h.fx+10,y:R.work},{x:h.fx+h.fw/2,y:R.work},{x:h.fx+h.fw-10,y:R.work}],meet:[{x:f.fx+10,y:R.meet},{x:f.fx+f.fw/2,y:R.meet},{x:f.fx+f.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}]},B=[{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}],$=[{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:y,desks:v,doors:E,adjacency:_,corridorY:R,waypoints:I,wallDecorations:B,furniture:$}}const uA=2;function Nv(e,n,a){return a||(n?n==="L"&&e<=12-uA?"M":n==="M"&&e>12?"L":n:e<=12?"M":"L")}function Ev(e,n){switch(n??Nv(e)){case"S":return sA(e);case"M":return oA(e);case"L":return cA(e)}}function dA(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 fA(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 ug(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 hA(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 Ao;function mA(e){Ao=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&&(Ao.globalAlpha=u),Ao.fillStyle=o,Ao.fillRect(e,n,a,i),u!==void 0&&u!==1&&(Ao.globalAlpha=1))}function nt(e,n,a,i){O(e,n,1,1,a,i)}let Du=1;function js(e){Du=e}function Ca(){return Du=Du*16807%2147483647,(Du&65535)/65535}function Av(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,h=0;const m=(o+u)/2;if(o!==u){const f=o-u;h=m>.5?f/(2-o-u):f/(o+u),o===n?d=((a-i)/f+(a<i?6:0))/6:o===a?d=((i-n)/f+2)/6:d=((n-a)/f+4)/6}return[d*360,h*100,m*100]}function Dv(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 h=(d+e/30)%12;return a-i*Math.max(-1,Math.min(h-3,9-h,1))},u=d=>Math.round(d*255).toString(16).padStart(2,"0");return"#"+u(o(0))+u(o(8))+u(o(4))}function Na(e,n=1){const[a,i,o]=Av(e);return Dv(a+15*n,Math.min(100,i+8),o-12*n)}function fn(e,n=1){const[a,i,o]=Av(e);return Dv(a-10*n,i-3,o+10*n)}const _n={hi:"#D4AA5C",base:"#B08040",sh:"#7A5038",deep:"#4E3028"},Tr={hi:"#8A6848",base:"#604832",sh:"#3A2E24",deep:"#2A1E18"},ba={hi:"#5A6A80",base:"#485868",sh:"#364858",deep:"#283848"},Vr="#100A06";function pA(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),nt(e+3,n+3,"#8AB8E8",.35),nt(e+o+2,n+3,"#8AB8E8",.25),O(e-1,n+i,a+2,2,"#5A4838"),O(e-1,n+i,a+2,1,fn("#5A4838",.5),.35)}function xA(e,n,a){O(e,n,10,8,"#3A2818"),O(e+1,n+1,8,6,a),O(e+2,n+2,4,3,fn(a,1.2),.3),nt(e+3,n+2,fn(a,2),.25)}function yA(e,n){O(e,n,7,7,"#3A2818"),O(e+1,n+1,5,5,"#F0EDE5"),nt(e+3,n+1,"#AAA"),nt(e+3,n+5,"#AAA"),nt(e+1,n+3,"#AAA"),nt(e+5,n+3,"#AAA"),nt(e+3,n+3,"#222"),O(e+3,n+1,1,2,"#333"),nt(e+4,n+3,"#D32F2F")}function gA(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 bA(e,n){O(e,n,22,16,"#6A5030"),O(e+1,n+1,20,14,"#C4A66A"),js(88);for(let a=0;a<14;a++)for(let i=0;i<20;i++)Ca()>.5&&nt(e+1+i,n+1+a,Ca()>.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"),nt(e+4,n+2,"#E53935"),nt(e+10,n+2,"#1E88E5"),nt(e+16,n+3,"#FF9800")}function vA(e,n){O(e,n,20,3,"#5A4030"),O(e,n,20,1,fn("#5A4030",.5),.35),O(e,n+2,20,1,Na("#5A4030",.5),.3),O(e+2,n-4,3,4,"#E53935"),O(e+2,n-4,3,1,fn("#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"),nt(e+15,n-3,"#FFF176",.4)}function wA(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),nt(e+2,n+4,"#4CAF50"),O(e+4,n+4,7,1,"#8b949e",.4),nt(e+2,n+6,"#FF9800"),O(e+4,n+6,5,1,"#8b949e",.3),nt(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 kA(e,n,a){O(e+2,n+20,22,2,Vr,.15),O(e,n,22,20,Tr.deep),O(e+1,n+1,20,18,Tr.base),O(e,n,22,1,Tr.hi,.35),O(e,n,1,20,Tr.hi,.2);for(const u of[6,12])O(e+1,n+u,20,2,Tr.sh),O(e+1,n+u,20,1,Tr.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,fn(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,fn(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 jA(e,n){O(e+2,n+11,6,2,Vr,.1),O(e+2,n+8,6,4,"#8B5E3C"),O(e+1,n+7,8,2,Na("#A06E48",.3)),O(e+2,n+7,6,1,fn("#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"),nt(e+4,n,"#81C784"),nt(e+3,n+1,"#A5D6A7",.4)}function SA(e,n){pi(e+4,n-4,"down"),pi(e+16,n-4,"down"),pi(e+28,n-4,"down"),O(e+3,n+24,34,3,Vr,.15),O(e,n+2,36,18,_n.deep),O(e+1,n+3,34,16,_n.base),O(e+1,n+3,34,1,_n.hi,.35);for(let a=0;a<14;a+=3)O(e+1,n+4+a,34,1,Na(_n.base,.2),.08);O(e,n+20,36,4,_n.deep),O(e+1,n+21,34,2,_n.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"),nt(e+16,n+8,"#795548"),pi(e+4,n+24,"up"),pi(e+16,n+24,"up"),pi(e+28,n+24,"up")}function CA(e,n){O(e+2,n+16,36,3,Vr,.15),O(e,n,36,5,"#5D4037"),O(e+1,n+1,34,3,"#6D4C41"),O(e+1,n+1,34,1,fn("#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,fn("#6D4C41",.5),.35),O(e+19,n+6,15,6,"#6D4C41"),O(e+20,n+6,13,1,fn("#6D4C41",.5),.35),O(e+17,n+6,2,6,"#5D4037"),O(e,n+13,36,3,Na("#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,fn("#FF8A65",1),.35)}function NA(e,n){O(e+2,n+10,22,2,Vr,.12),O(e,n,22,8,Tr.deep),O(e+1,n+1,20,6,Tr.base),O(e+1,n+1,20,1,Tr.hi,.3),O(e,n+8,22,2,Tr.sh),O(e+3,n+2,6,4,"#F0F0F0"),O(e+13,n+3,3,3,"#ECEFF1"),nt(e+14,n+4,"#795548")}function EA(e,n){O(e+1,n+14,10,2,Vr,.12),O(e,n,10,14,"#546E7A"),O(e,n,10,1,fn("#546E7A",1),.35),O(e+1,n+1,8,3,"#78909C"),O(e+1,n+5,8,4,"#37474F"),nt(e+2,n+6,"#EF5350"),nt(e+4,n+6,"#66BB6A"),O(e+2,n+11,4,2,"#ECEFF1")}function AA(e,n){O(e+2,n+18,28,3,Vr,.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"),nt(e+12,n+5,"#FF5722"),O(e+16,n+8,3,2,"#FFD54F"),nt(e+15,n+8,"#FFC107"),nt(e+13,n+3,"#90CAF9",.5),nt(e+14,n+4,"#BBDEFB",.35),nt(e+8,n+3,"#BBDEFB",.3),O(e,n+16,28,2,"#455A64"),O(e+1,n+16,26,1,fn("#455A64",.5),.3)}function DA(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 TA(e,n){O(e+2,n+28,16,3,Vr,.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"),nt(e+6,n+7,"#81C784"),O(e+1,n+14,14,6,"#1A237E"),O(e+2,n+15,4,4,"#212121"),nt(e+4,n+16,"#F44336"),nt(e+9,n+16,"#F44336"),nt(e+11,n+16,"#2196F3"),nt(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 FA(e,n){O(e+2,n+24,20,3,Vr,.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 MA(e,n){O(e+2,n+22,22,2,Vr,.12),O(e,n,22,22,Tr.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,Tr.base),O(e+1,n+10,20,1,Tr.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"),nt(e+5,n+3,"#FFF176",.5),O(e+13,n+4,4,4,"#B0BEC5"),O(e+14,n+3,2,1,"#CFD8DC"),nt(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 RA(e,n){O(e+2,n+16,26,3,Vr,.18),O(e,n,26,10,_n.deep),O(e+1,n+1,24,8,_n.base),O(e+1,n+2,24,1,_n.hi,.2),O(e+1,n+4,24,1,Na(_n.base,.2),.1),O(e+1,n+6,24,1,_n.hi,.15),O(e+1,n+1,24,1,_n.hi,.4),O(e+1,n+1,1,8,_n.hi,.2),O(e,n+10,26,5,_n.deep),O(e+1,n+11,24,3,_n.sh),O(e+1,n+10,24,1,Na(_n.base,1.5),.4),O(e+1,n+14,24,1,_n.base,.15),O(e+2,n+12,10,1,_n.deep,.4),O(e+14,n+12,10,1,_n.deep,.4),nt(e+7,n+11,"#C8D0D8",.6),nt(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),nt(e+7,n-4,"#4A98D8",.25),nt(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++)nt(e+7+a*2,n+5,"#444",.6),nt(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"),nt(e+2,n+5,"#6D4C41")}function pi(e,n,a){O(e+1,n+9,10,2,Vr,.1),nt(e+5,n+9,"#1E1E22"),nt(e+1,n+10,"#1A1A1E"),nt(e+9,n+10,"#1A1A1E"),nt(e+3,n+11,"#1A1A1E"),nt(e+7,n+11,"#1A1A1E"),O(e+1,n+2,8,6,ba.base),O(e+2,n+3,6,4,ba.hi,.35),O(e+2,n+3,6,1,fn(ba.hi,.5),.25),O(e+1,n+7,8,1,ba.deep),a==="up"?(O(e,n+7,10,3,ba.deep),O(e+1,n+8,8,1,ba.sh)):(O(e,n-1,10,3,ba.deep),O(e+1,n,8,1,ba.sh)),O(e,n+3,1,4,ba.sh),O(e+9,n+3,1,4,ba.sh)}const Tv={bookshelf:(e,n,a)=>kA(e,n,a.accent),plant:(e,n)=>jA(e,n),"meeting-table":(e,n)=>SA(e,n),sofa:(e,n)=>CA(e,n),"coffee-table":(e,n)=>NA(e,n),"coffee-machine":(e,n)=>EA(e,n),window:(e,n,a)=>pA(e,n,a.windowW??16,a.windowH??14),picture:(e,n,a)=>xA(e,n,a.pictureColor??"#1565C0"),clock:(e,n)=>yA(e,n),whiteboard:(e,n)=>gA(e,n),"bulletin-board":(e,n)=>bA(e,n),shelf:(e,n)=>vA(e,n),screen:(e,n)=>wA(e,n),aquarium:(e,n)=>AA(e,n),"neon-sign":(e,n)=>DA(e,n),arcade:(e,n)=>TA(e,n),jukebox:(e,n)=>FA(e,n),"trophy-case":(e,n)=>MA(e,n)};function gs(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 zA(e){for(const n of e.wallDecorations){const a=e.rooms[n.room];if(!a)continue;const{x:i,y:o}=gs(n,a),u=Tv[n.type];u&&u(i,o,n)}}function _A(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}=gs(i,o),h=Tv[i.type];h&&n.push({y:d,draw:()=>h(u,d,i)})}}function xi(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}=gs(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 BA={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 xm(e){return BA[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:h,y:m}=gs(u,d),f=xm(u.type);if(n>=h&&n<=h+f.w&&a>=m&&a<=m+f.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:h,y:m}=gs(u,d),f=xm(u.type);if(n>=h&&n<=h+f.w&&a>=m&&a<=m+f.h)return u.id}return null}function dg(e,n,a,i,o){const d=[...n.wallDecorations,...n.furniture].find(y=>y.id===a);if(!d||d.condition==="no-desks"&&o.has(d.room))return;const h=n.rooms[d.room];if(!h)return;const{x:m,y:f}=gs(d,h),x=xm(d.type);e.save(),e.fillStyle=i,e.globalAlpha=.2,e.fillRect(m-1,f-1,x.w+2,x.h+2),e.globalAlpha=.9,e.strokeStyle=i,e.lineWidth=1,e.strokeRect(m-.5,f-.5,x.w+1,x.h+1),e.restore()}function fg(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 hg(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 mg=[{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}],vu=16,OA=4,mi=4,Tu=2,$t=4,_l=4;let Ve=Ev(7);const qu={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"},pg={ceo:["대표님?","무슨 일이신가요?","회의 시간이신가요?","좋은 아이디어 있으시면 말씀해주세요.","다들 잘하고 있나요?"],cto:["뭐 필요하신 거 있으세요?","기술 관련 질문이신가요?","아키텍처 리뷰 중이에요.","배포는 조금만 기다려주세요.","코드 봐드릴까요?"],cbo:["비즈니스 관련 얘기신가요?","수익 모델 검토 중이에요.","시장 조사 결과 보실래요?","경쟁사 분석 중입니다.","뭔가 도와드릴까요?"],pm:["프로젝트 진행 상황 궁금하신가요?","로드맵 업데이트 중이에요.","태스크 할당 중입니다.","우선순위 조정이 필요할까요?","스프린트 리뷰 준비 중이에요."],engineer:["일하고 있어요!","버그 수정 중입니다.","코드 리뷰 필요하신가요?","테스트 작성 중이에요.","PR 올리고 있어요."],designer:["디자인 피드백 있으신가요?","목업 작업 중이에요.","UI 개선안 생각 중입니다.","컬러 팔레트 고민 중이에요.","프로토타입 보여드릴까요?"],qa:["테스트 중이에요.","버그 발견했어요!","테스트 케이스 작성 중입니다.","회귀 테스트 진행 중이에요.","품질 체크 중입니다."],"data-analyst":["데이터 분석 중이에요.","리포트 준비 중입니다.","대시보드 확인해보실래요?","지표 추적 중이에요.","인사이트 발견했어요!"],default:["안녕하세요!","무엇을 도와드릴까요?","열심히 일하고 있어요.","좋은 하루 되세요!"]};let wa=xi(Ve);function Fv(e){return{x:e.dx,y:e.dy,w:e.pw,h:e.ph}}function Mv(e){return{cx:e.dx+e.pw/2,botY:e.dy+e.ph}}let mn={};function LA(e){const n={};for(let a=0;a<e.length&&a<Ve.desks.length;a++)n[e[a]]=Ve.desks[a];return n}let Ue,Vn=null,yi=null,Ga=!1,ia=null,Ar=null,Rv=0,Qn=null,zn=null,Rl=null,va=null,Bh=900;function $A(e,n){const{wx:a,wy:i,ww:o,wh:u,wallColor:d,baseboardColor:h}=e,m=Na(d,.5),f=fn(d,.5),x=[];if(n){const y=n.x-a,v=n.w;y>0&&x.push({sx:a,sw:y}),y+v<o&&x.push({sx:n.x+v,sw:o-y-v})}else x.push({sx:a,sw:o});for(const y of x){O(y.sx,i,y.sw,u,d);for(let v=0;v<u;v+=4)O(y.sx,i+v,y.sw,1,f,.08),O(y.sx,i+v+2,y.sw,1,m,.05);js(Math.round(y.sx*7+i*13));for(let v=0;v<y.sw;v+=3)Ca()>.4&&O(y.sx+v,i,1,u,f,.04);O(y.sx,i,y.sw,2,f,.3),O(y.sx,i,y.sw,1,fn(d,1),.2),O(y.sx,i+u-2,y.sw,2,m,.3),O(y.sx,i+u,y.sw,Tu,h),O(y.sx,i+u,y.sw,1,fn(h,.5),.4)}n&&(O(n.x-1,i,1,u+Tu,"#4A3828"),O(n.x+n.w,i,1,u+Tu,"#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 IA(e){const n="#504038",a=Na(n,.5),i=fn(n,.5),o=e.wx-_l,u=e.wy,d=e.wh+Tu+e.fh;O(o,u,_l,d,n),O(o,u,1,d,i,.3),O(o+_l-1,u,1,d,a,.4);for(let m=0;m<d;m+=6)O(o+1,u+m,_l-2,1,i,.06);const h=e.wx+e.ww;O(h,u,_l,d,n),O(h,u,1,d,i,.2),O(h+_l-1,u,1,d,a,.3)}function Oh(e){const{fx:n,fy:a,fw:i,fh:o}=e,u="#B08040",d="#C89848",h="#8A6030",m="#6A4820";O(n,a,i,o,u),js(42);for(let f=0;f<o;f+=5){const x=Math.floor(f/5)%2*10;for(let y=-10;y<i+10;y+=20){const v=n+y+x,b=Math.max(n,v),j=Math.min(v+19,n+i)-b;if(j<=0)continue;const k=Ca()>.5?d:u;O(b,a+f,j,4,k,.25),O(b,a+f,j,1,d,.3),O(b,a+f+4,j,1,m,.35),v>=n&&v<n+i&&O(v,a+f,1,4,m,.2),O(b,a+f+2,j,1,h,.1)}}O(n,a,i,2,"#0A0808",.08),O(n,a,2,o,"#0A0808",.06)}function xg(e){const{fx:n,fy:a,fw:i,fh:o}=e,u="#1C2A38",d="#101820";js(99),O(n,a,i,o,u);for(let h=0;h<o;h+=vu)for(let m=0;m<i;m+=vu){const f=Math.min(vu,i-m),x=Math.min(vu,o-h);Ca()>.5&&O(n+m,a+h,f,x,fn(u,.2),.15),O(n+m+2,a+h+2,f-4,x-4,fn(u,.3),.08),O(n+m,a+h,f,1,d,.5),O(n+m,a+h,1,x,d,.5),O(n+m+1,a+h+1,1,x-1,fn(u,.4),.1),Ca()>.85&&nt(n+m+4+Math.floor(Ca()*8),a+h+4+Math.floor(Ca()*8),"#3A6A9A",.08)}}function HA(e){const{fx:n,fy:a,fw:i,fh:o}=e,u="#387848",d="#4A9058",h="#285E38";O(n,a,i,o,u),js(77);for(let f=0;f<o;f+=2)for(let x=0;x<i;x+=2)Ca()>.5&&nt(n+x,a+f,d,.1),Ca()>.8&&nt(n+x+1,a+f+1,h,.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,h,.45),O(n+m,a+m,1,o-m*2,d,.35),O(n+i-m-1,a+m,1,o-m*2,h,.35)}function UA(e){const{fx:n,fy:a,fw:i,fh:o}=e,u="#D8C490",d="#B09060",h="#907848";js(55);for(let m=0;m<o;m+=8)for(let f=0;f<i;f+=8){const x=Math.min(8,i-f),y=Math.min(8,o-m),v=(f/8+m/8)%2===0?d:u;O(n+f,a+m,x,y,v),O(n+f+1,a+m+1,x-2,1,fn(v,.4),.2),O(n+f+1,a+m+1,1,y-2,fn(v,.4),.15),O(n+f+x-2,a+m+2,1,y-3,Na(v,.4),.15),O(n+f+2,a+m+y-2,x-3,1,Na(v,.4),.15),O(n+f,a+m,x,1,h,.3),O(n+f,a+m,1,y,h,.3)}}function qA(){const{canvasW:e,canvasH:n,rooms:a,doors:i}=Ve,o="#2A1E14",u="#3A2E24";if(O(0,0,e,mi,o),O(0,n-mi,e,mi,o),O(0,0,mi,n,o),O(e-mi,0,mi,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,h=a.meet,m=e/2,f=m-$t/2,x=d.fy+d.fh,y=i.exec_work,v=i.meet_comm,b=i.exec_meet,j=i.work_comm,k=24,N=28,S=((y==null?void 0:y.doorY)??d.fy+20)-k/2,E=((b==null?void 0:b.doorX)??mi+_l+54)-N/2,_=((j==null?void 0:j.doorX)??m+$t/2+_l+54)-N/2,R=((v==null?void 0:v.doorY)??h.fy+20)-k/2;O(0,x,E,$t,o),O(E+N,x,f-E-N,$t,o),O(f+$t,x,_-f-$t,$t,o),O(_+N,x,e-_-N,$t,o),O(0,x,E,1,u,.3),O(E+N,x,f-E-N,1,u,.3),O(f+$t,x,_-f-$t,1,u,.3),O(_+N,x,e-_-N,1,u,.3),O(f,0,$t,S,o),O(f,S+k,$t,x-S-k,o),O(f,x+$t,$t,R-x-$t,o),O(f,R+k,$t,n-R-k,o),O(f,0,1,S,u,.2),O(f,S+k,1,x-S-k,u,.2),O(f,x+$t,1,R-x-$t,u,.2),O(f,R+k,1,n-R-k,u,.2),O(f,S,$t,k,"#C4A070"),O(f+$t/2,S,$t/2,k,"#3A4858"),O(f,R,$t,k,"#7AA880"),O(f+$t/2,R,$t/2,k,"#C8B890");const I="#4A3828";O(f,S-1,$t,1,I),O(f,S+k,$t,1,I),O(E-1,x,1,$t,I),O(E+N,x,1,$t,I),O(_-1,x,1,$t,I),O(_+N,x,1,$t,I),O(f,R-1,$t,1,I),O(f,R+k,$t,1,I)}const yg=new Map;function YA(e,n="right"){const a=`${e.hairStyle??""}|${e.outfitStyle??""}|${e.accessory??""}|${n}`;let i=yg.get(a);if(!i){const o=nm("mini-seated:default"),u=Yb(o,e);let d=u?u.layers.flatMap(h=>h.pixels):[];n==="left"&&d.length>0&&(d=em(d,12)),i=d,yg.set(a,i)}return i}function XA(e,n,a,i="right"){Bl(Ue,YA(a,i),e,n,a)}function WA(e,n,a,i,o,u="right"){pi(e+8,n+20,"up"),o||XA(e+8,n+0+i,a,u),RA(e,n+14)}function VA(e,n,a,i,o){const u=i in ig?i:"down",d=o%4,h=ig[u][d];Bl(Ue,h,e,n,a);const m=d===1||d===3?-1:0;if(a.accessory&&a.accessory!=="none"){const f=uC(a.accessory,u);f&&f.pixels.length>0&&Bl(Ue,f.pixels,e,n+m,a)}Ue.globalAlpha=1}let Fu=[],vi=!1,bs=0;function GA(){const e=Object.keys(Ve.rooms),n=e[Math.floor(Math.random()*e.length)],a=Ve.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 KA(e){if(e.stateTimer--,vi){bs++,e.dir="down",e.walkFrame=0,e.tongueTimer++,e.idleTime=0;return}else bs=0;if(e.state==="idle"){if(e.tongueTimer++,e.idleTime++,e.stateTimer<=0){e.state="walking",e.tongueTimer=0;const n=Object.keys(Ve.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=Zm(e,i),u=Ve.waypoints[i];if(u&&u.length>0){const d=u[Math.floor(Math.random()*u.length)],h=o[o.length-1]??{x:e.x,y:e.y},m=wi(h.x,h.y,d.x,d.y,i);e.path=[...o,...m]}else e.path=o}else{const a=Ve.waypoints[e.room];if(a&&a.length>0){const i=a[Math.floor(Math.random()*a.length)];e.path=wi(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(Ve.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 QA(e){const n=Math.round(e.x),a=Math.round(e.y);if(vi&&bs>90){const d=Math.floor(bs/12)%2===0?nA:rA;Bl(Ue,iA,n,a),Bl(Ue,d,n,a);return}const i=e.state==="walking"?e.walkFrame:0,o=eA[e.dir][i],u=e.dir==="left"||e.dir==="right";Bl(Ue,u?lA:aA,n,a),Bl(Ue,o,n,a),e.state==="idle"&&e.dir==="down"&&e.tongueTimer%80<50&&Bl(Ue,tA,n,a)}function PA(e){const n={};let a=0;for(const i of e){const o=mn[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 wi(e,n,a,i,o){const u=Ve.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 Lh(e,n,a,i){const o=Ve.adjacency[a];if(!o)return[];const u=o.find(x=>x.room===i);if(!u)return[];const d=Ve.doors[u.door];if(!d)return[];const h=[],m=Ve.corridorY[a]??n,f=Ve.corridorY[i]??n;if(Math.abs(n-m)>4&&h.push({x:e,y:m}),d.type==="v"){const x=u.side==="A"?d.xA:d.xB,y=u.side==="A"?d.xB:d.xA;h.push({x,y:m}),h.push({x,y:d.doorY}),h.push({x:y,y:d.doorY}),h.push({x:y,y:f})}else{const x=u.side==="A"?d.yA:d.yB,y=u.side==="A"?d.yB:d.yA;h.push({x:d.doorX,y:m}),h.push({x:d.doorX,y:x}),h.push({x:d.doorX,y}),h.push({x:d.doorX,y:f})}return h}function Zm(e,n){const a=Ve.adjacency[e.room];if(!a)return[];if(!a.find(o=>o.room===n)){for(const o of a){const u=Ve.adjacency[o.room];if(u!=null&&u.find(d=>d.room===n)){const d=Lh(e.x,e.y,e.room,o.room),h=d[d.length-1],m=Lh((h==null?void 0:h.x)??e.x,(h==null?void 0:h.y)??e.y,o.room,n);return[...d,...m]}}return[]}return Lh(e.x,e.y,e.room,n)}function ZA(e){if(e.room!==e.homeRoom){const n=Zm({...e},e.homeRoom),a=n[n.length-1],i=wi((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 wi(e.x,e.y,e.homeX,e.homeY,e.room)}function JA(e,n){if(Bh--,Bh<=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}Bh=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++,Vn===a){i.sittingTime=0,i.bobY=-3;const u=mn[a];if(u){const d=u.dx+13;i.lookDir=Rv<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(Ve.rooms);if(Math.random()<.15&&u.length>1){const d=u.filter(x=>x!==i.room),h=d[Math.floor(Math.random()*d.length)],m=Zm(i,h),f=Ve.waypoints[h];if(f&&f.length>0){const x=f[Math.floor(Math.random()*f.length)],y=m[m.length-1]??{x:i.x,y:i.y},v=wi(y.x,y.y,x.x,x.y,h);i.path=[...m,...v]}else i.path=m;i.walkTimer=0}else{const d=Ve.waypoints[i.room];if(d&&d.length>0){const h=d[Math.floor(Math.random()*d.length)];i.path=wi(i.x,i.y,h.x,h.y,i.room)}i.walkTimer=0}}}else if(i.state==="walking"||i.state==="returning"){if(i.sittingTime=0,Vn===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,h=u.y-i.y,m=Math.sqrt(d*d+h*h);if(m<1.5){i.x=u.x,i.y=u.y,i.path.shift();for(const[f,x]of Object.entries(Ve.rooms))if(i.x>=x.fx&&i.x<=x.fx+x.fw&&i.y>=x.fy&&i.y<=x.fy+x.fh){i.room=f;break}}else i.x+=d/m*.2,i.y+=h/m*.2,Math.abs(d)>Math.abs(h)?i.dir=d>0?"right":"left":i.dir=h>0?"down":"up",i.walkTimer++,i.walkFrame=Math.floor(i.walkTimer/12)%4}else if(i.state==="idle"){if(Vn===a){i.dir="down";continue}if(i.stateTimer<=0)if(Math.random()<.15){i.state="walking";const o=Ve.waypoints[i.room];if(o&&o.length>0){const u=o[Math.floor(Math.random()*o.length)];i.path=wi(i.x,i.y,u.x,u.y,i.room)}i.walkTimer=0}else i.state="returning",i.path=ZA(i),i.walkTimer=0}}function e8(e,n,a,i){const{canvasW:o,canvasH:u,rooms:d}=Ve;Ue.clearRect(0,0,o,u),O(0,0,o,u,"#2A1E14");const h={wood:Oh,dark:xg,carpet:HA,tile:UA};for(const b of Object.values(d))(h[b.floorType]??Oh)(b);const m=Object.keys(d);if(m.length>=4){const b=d.exec,j=d.meet,{doors:k}=Ve;if(b&&j&&k.exec_meet&&k.work_comm){const S=(k.exec_meet.doorX??0)-14,E=(k.work_comm.doorX??0)-28/2,_=b.fy+b.fh,R=j.fy;Oh({fx:S,fy:_,fw:28,fh:R-_}),xg({fx:E,fy:_,fw:28,fh:R-_})}}const f={};if(m.length>=4){const{doors:b}=Ve,j=28,k=b.exec_meet,N=b.work_comm;k!=null&&k.doorX&&(f.meet={x:k.doorX-j/2,w:j}),N!=null&&N.doorX&&(f.comm={x:N.doorX-j/2,w:j})}for(const b of Object.values(d))$A(b,f[b.id]),IA(b);qA(),zA(Ve);const x=[],y=new Set(Object.values(mn).map(b=>b.room));_A(Ve,x,y);for(const[b,j]of Object.entries(mn)){const k=e[b];if(!k)continue;const N=k.state==="sitting",S=n(b),E=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(WA(j.dx,j.dy,S,R,!N,k.lookDir),N&&E){const I=qu[b]??"#388bfd";O(j.dx+7,j.dy+14-4,12,5,I,.15),nt(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:()=>VA(Math.round(j.x),Math.round(j.y),k,j.dir,j.walkFrame)})}i&&x.push({y:i.y+10,draw:()=>QA(i)}),x.sort((b,j)=>b.y-j.y);for(const b of x)b.draw();for(const b of wa){const j=yi===b.id,k=Mv(b);if(Ue.save(),Ue.globalAlpha=j?.9:.5,Ue.fillStyle=b.color,Ue.fillRect(k.cx-1,k.botY-2,3,3),j){const N=Fv(b);Ue.globalAlpha=.3,Ue.strokeStyle=b.color,Ue.lineWidth=1,Ue.strokeRect(N.x-1,N.y-1,N.w+2,N.h+2)}Ue.restore()}if(Ga){const b=new Set(Object.values(mn).map(j=>j.room));if(ia&&ia!==Ar)if(ia.startsWith("desk:")){const j=ia.slice(5),k=mn[j];k&&fg(Ue,k.dx,k.dy,"#FBBF24")}else dg(Ue,Ve,ia,"#FBBF24",b);if(Ar)if(Ar.startsWith("desk:")){const j=Ar.slice(5),k=mn[j];k&&fg(Ue,k.dx,k.dy,"#3B82F6")}else dg(Ue,Ve,Ar,"#3B82F6",b)}if(Vn){const b=mn[Vn],j=e[Vn];if(b&&j){Ue.save(),Ue.globalAlpha=.25,Ue.fillStyle=qu[Vn]??"#fff",j.state==="sitting"?Ue.fillRect(b.dx-1,b.dy+6,28,30):Ue.fillRect(Math.round(j.x)-1,Math.round(j.y)-1,14,24),Ue.globalAlpha=.95,Ue.fillStyle="#FBBF24",Ue.font="bold 8px monospace",Ue.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;Ue.fillText("!",k,N),Ue.restore()}}const v=3600;for(const[,b]of Object.entries(e))if(b.state==="sitting"&&b.sittingTime>v&&!b.isStretching){const j=Object.values(mn).find(R=>R.dx+8===b.homeX&&R.dy+34===b.homeY);if(!j)continue;const k=j.dx+13,N=j.dy,S=Math.floor(b.sittingTime/40)%3;Ue.save(),Ue.font="5px monospace",Ue.textAlign="center";const E=[.7,.5,.3],_=[{x:3,y:-2-S},{x:6,y:-5-(S+1)%3},{x:4,y:-8-(S+2)%3}];for(let R=0;R<3;R++)Ue.globalAlpha=E[R],Ue.fillStyle="#93C5FD",Ue.font=`${4+R}px monospace`,Ue.fillText("z",k+_[R].x,N+_[R].y);Ue.restore()}Fu=Fu.filter(b=>b.life>0);for(const b of Fu)b.x+=b.vx,b.y+=b.vy,b.life--,Ue.save(),Ue.globalAlpha=Math.min(1,b.life/(b.maxLife*.3)),Ue.fillStyle=b.color??"#FF6B8A",Ue.font="8px serif",Ue.fillText(b.char,Math.round(b.x),Math.round(b.y)),Ue.restore();if(vi&&i&&bs<=90){const b=Math.round(i.x),j=Math.round(i.y);Ue.save(),Ue.globalAlpha=.9,Ue.fillStyle="#FBBF24",Ue.font="bold 5px monospace",Ue.textAlign="center",Ue.fillText("!",b+4,j-2),Ue.restore()}if(i&&!vi&&i.state==="idle"&&i.idleTime>600){const b=Math.round(i.x),j=Math.round(i.y),k=Math.floor(i.idleTime/40)%3;Ue.save();const N=[{x:3,y:-2-k},{x:5,y:-5-(k+1)%3},{x:4,y:-8-(k+2)%3}];for(let S=0;S<3;S++)Ue.globalAlpha=[.7,.5,.3][S],Ue.fillStyle="#93C5FD",Ue.font=`${3+S}px monospace`,Ue.textAlign="center",Ue.fillText("z",b+N[S].x,j+N[S].y);Ue.restore()}if(vi&&i&&bs<=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"&&(Ue.fillStyle="#FAFAF7",Ue.fillRect(b+4+k,j-1,2,2))}}function gg(e,n){for(let a=0;a<4;a++)Fu.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 t8({roles:e,projects:n,roleStatuses:a,activeExecs:i,onRoleClick:o,onProjectClick:u,onBulletinClick:d,onDecisionsClick:h,onKnowledgeClick:m,onSettingsClick:f,onThemeClick:x,onStatsClick:y,getRoleSpeech:v,getAppearance:b,onHireClick:j,onMascotClick:k,roleLevels:N,coinBalance:S=0,onCoinsSpent:E,onFurniturePlaced:_,purchasedPreset:R,onExpansionPurchased:I}){const B=w.useRef(null),$=w.useRef(null),q=w.useRef(null),G=w.useRef({}),T=w.useRef(null),H=w.useRef(0),L=w.useRef(OA),[J,ce]=w.useState(!1),[re,X]=w.useState("furniture"),[le,ee]=w.useState(null),[Z,D]=w.useState(null),F=w.useRef({}),W=w.useRef({}),A=w.useRef([]),Q=w.useRef([]);w.useEffect(()=>{Ga=J},[J]),w.useEffect(()=>{Rl=le,va=Z},[le,Z]);const[ie,he]=w.useState(!1);w.useEffect(()=>{ye.getPreferences().then(we=>{const U=we.furnitureOverrides;U&&Object.keys(U).length>0&&(F.current=U);const ae=we.deskOverrides;ae&&Object.keys(ae).length>0&&(W.current=ae);const me=we.removedFurniture;me&&me.length>0&&(A.current=me);const Ce=we.addedFurniture;Ce&&Ce.length>0&&(Q.current=Ce),he(!0)}).catch(()=>{he(!0)})},[]);const Ne=w.useRef({roleStatuses:a,activeExecs:i,getRoleSpeech:v,getAppearance:b});Ne.current={roleStatuses:a,activeExecs:i,getRoleSpeech:v,getAppearance:b};const Ie=w.useRef({}),de=w.useMemo(()=>e.map(we=>we.id),[e]),_e=w.useRef(Ve);w.useEffect(()=>{if(!ie)return;const we=de.length,U=Nv(we,_e.current.preset,R),ae=_e.current.preset!==U;let me=Ev(we,U);A.current.length>0&&(me=ug(me,A.current)),Q.current.length>0&&(me=hA(me,Q.current)),Object.keys(F.current).length>0&&(me=dA(me,F.current)),Ve=me,_e.current=me,mn=LA(de),Object.keys(W.current).length>0&&fA(mn,W.current),wa=xi(me),G.current=PA(de),T.current=GA();const Ce=B.current;Ce&&(Ce.width=me.canvasW,Ce.height=me.canvasH,ae&&(Ce.style.opacity="0",Ce.style.transition="opacity 0.3s",setTimeout(()=>{Ce.style.opacity="1"},50))),ge()},[de,R,ie]);const Ye=w.useCallback(we=>{var U,ae;return((ae=(U=Ne.current).getAppearance)==null?void 0:ae.call(U,we))??Vm(we)},[]),ge=w.useCallback(()=>{const we=$.current,U=B.current;if(!we||!U)return;const ae=we.parentElement;if(!ae)return;const me=ae.clientWidth,Ce=ae.clientHeight;if(me===0||Ce===0)return;const{canvasW:De,canvasH:Se}=Ve;let Be=Math.floor(Math.min(me/De,Ce/Se));Be=Math.max(2,Math.min(Be,5)),L.current=Be,U.style.width=De*Be+"px",U.style.height=Se*Be+"px",we.style.width=De*Be+"px",we.style.height=Se*Be+"px"},[]);w.useEffect(()=>{var Se;const we=B.current;if(!we)return;const U=we.getContext("2d");if(!U)return;Ue=U,mA(U),ge();const ae=new ResizeObserver(()=>ge()),me=(Se=$.current)==null?void 0:Se.parentElement;me&&ae.observe(me);let Ce;const De=()=>{H.current++,JA(G.current,H.current),T.current&&KA(T.current),e8(G.current,Ye,Ne.current.roleStatuses,T.current),Je(),Ce=requestAnimationFrame(De)};return Ce=requestAnimationFrame(De),()=>{cancelAnimationFrame(Ce),ae.disconnect()}},[Ye,ge]),w.useEffect(()=>{var De;const we=q.current;if(!we)return;we.innerHTML="";const U={};for(const Se of e)U[Se.id]=Se.name;for(const Se of de){const Be=qu[Se]??"#8b949e",$e=U[Se],Re=$e&&$e.toLowerCase()!==Se.toLowerCase()?`${Se.toUpperCase()} · ${$e}`:Se.toUpperCase(),ze=document.createElement("div");ze.className="td-nametag",ze.dataset.role=Se;const Oe=document.createElement("span");Oe.className="td-dot",Oe.style.background=Be,ze.appendChild(Oe),ze.appendChild(document.createTextNode(Re));const kt=((De=N==null?void 0:N[Se])==null?void 0:De.level)??1;if(kt>1){const Le=document.createElement("span");Le.className="td-lvl",Le.textContent=`Lv.${kt}`,ze.appendChild(Le)}we.appendChild(ze);const Me=document.createElement("div");Me.className="td-bubble",Me.dataset.role=Se,Me.dataset.type="bubble",we.appendChild(Me)}const ae={meeting:()=>{const Se=n[0];Se?u(Se.id):d()},bulletin:d,decisions:h,knowledge:m,settings:f,theme:x,stats:y};for(const Se of wa){const Be=document.createElement("div");Be.className="td-facility-label",Be.dataset.facility=Se.id,Se.id==="meeting"&&(Be.dataset.questTarget="meeting-room"),Se.id==="knowledge"&&(Be.dataset.questTarget="knowledge-hub"),Se.id==="bulletin"&&(Be.dataset.questTarget="bulletin-board"),Se.id==="stats"&&(Be.dataset.questTarget="stats-btn"),Se.id==="settings"&&(Be.dataset.questTarget="settings-btn"),Se.id==="theme"&&(Be.dataset.questTarget="theme-btn"),Be.textContent=`${Se.icon} ${Se.label}`,Be.style.borderColor=`${Se.color}44`;const $e=ae[Se.id];$e&&Be.addEventListener("click",$e),Be.addEventListener("mouseenter",()=>{yi=Se.id}),Be.addEventListener("mouseleave",()=>{yi=null}),we.appendChild(Be)}const me=document.createElement("div");me.className="td-nametag td-nametag-mascot",me.dataset.role="mascot";const Ce=document.createElement("span");Ce.className="td-dot",Ce.style.background="#ffd700",me.appendChild(Ce),me.appendChild(document.createTextNode("Pupu")),me.addEventListener("click",()=>k==null?void 0:k()),we.appendChild(me)},[de,e,n,u,d,h,m,f,x,y,k,N]);const Je=w.useCallback(()=>{var $e;const we=q.current;if(!we)return;const U=L.current,ae=G.current,{getRoleSpeech:me,roleStatuses:Ce,activeExecs:De}=Ne.current;for(const Re of Object.keys(ae)){const ze=ae[Re],Oe=mn[Re];if(!Oe)continue;let kt,Me,Le;ze.state==="sitting"?(kt=Oe.dx+13,Le=Oe.dy+2,Me=Oe.dy+37):(kt=Math.round(ze.x)+6,Le=Math.round(ze.y)-2,Me=Math.round(ze.y)+18);const Vt=kt/Ve.canvasW*100,Jt=we.querySelector(`.td-nametag[data-role="${Re}"]`);if(Jt){Jt.style.left=Vt+"%",Jt.style.top=Me*U+2+"px";const Bt=Jt.querySelector(".td-dot");if(Bt){const bn=Ce[Re]==="working";Bt.style.background=bn?"#FBBF24":qu[Re]??"#8b949e",bn?Bt.style.animation="td-pulse 1s ease-in-out infinite":Bt.style.animation=""}}const jt=we.querySelector(`.td-bubble[data-role="${Re}"]`);if(jt){const Bt=Date.now(),bn=Ce[Re]==="working",P=($e=De.find(yt=>yt.roleId===Re))==null?void 0:$e.task,qe=me(Re);let et="";const St=Ie.current[Re];if(St){if(St.speechDismissTime&&Bt>=St.speechDismissTime&&(St.currentSpeech=null,St.speechDismissTime=null),St.hoverStartTime&&!St.currentSpeech){const yt=Bt-St.hoverStartTime,sn=!St.lastSpeechTime||Bt-St.lastSpeechTime>=5e3;if(yt>=2e3&&sn){const en=pg[Re]||pg.default,Mr=en[Math.floor(Math.random()*en.length)];St.currentSpeech=Mr,St.lastSpeechTime=Bt,St.speechDismissTime=Bt+3e3}}et=St.currentSpeech||""}const ve=bn&&P?P.slice(0,60):et?et.slice(0,60):qe?qe.slice(0,60):"";ve&&ze.state==="sitting"?(jt.style.display="",jt.style.left=Vt+"%",jt.style.top=(Le-10)*U+"px",jt.textContent=ve):jt.style.display="none"}}const Se=we.querySelector(".td-nametag-mascot"),Be=T.current;if(Se&&Be){const Re=Be.dir==="left"||Be.dir==="right",ze=Math.round(Be.x)+(Re?6:4),Oe=Math.round(Be.y)+(Re?7:10);Se.style.left=ze/Ve.canvasW*100+"%",Se.style.top=Oe*U+2+"px"}for(const Re of wa){const ze=we.querySelector(`.td-facility-label[data-facility="${Re.id}"]`);if(ze){const Oe=Mv(Re);ze.style.left=Oe.cx/Ve.canvasW*100+"%",ze.style.top=Oe.botY*U-4+"px",ze.classList.toggle("td-facility-label--hover",yi===Re.id)}}},[]),Fe=w.useCallback(we=>{const U=B.current;if(!U)return null;const ae=U.getBoundingClientRect(),me=L.current,Ce=(we.clientX-ae.left)/me,De=(we.clientY-ae.top)/me,Se=G.current;for(const[$e,Re]of Object.entries(mn)){if(!Se[$e])continue;const ze=Se[$e];if(ze.state==="sitting"){if(Ce>=Re.dx&&Ce<=Re.dx+26&&De>=Re.dy&&De<=Re.dy+40)return{type:"role",id:$e}}else if(Ce>=ze.x-2&&Ce<=ze.x+14&&De>=ze.y-2&&De<=ze.y+20)return{type:"role",id:$e}}const Be=T.current;if(Be){const $e=Be.dir==="left"||Be.dir==="right",Re=$e?13:9,ze=$e?7:10;if(Ce>=Be.x&&Ce<=Be.x+Re&&De>=Be.y&&De<=Be.y+ze)return{type:"mascot",id:"mascot"}}for(const $e of wa){const Re=Fv($e);if(Ce>=Re.x&&Ce<=Re.x+Re.w&&De>=Re.y&&De<=Re.y+Re.h)return{type:"facility",id:$e.id}}return null},[]),ct=w.useCallback(we=>{const U=B.current;if(!U)return{mx:0,my:0};const ae=U.getBoundingClientRect(),me=L.current;return{mx:(we.clientX-ae.left)/me,my:(we.clientY-ae.top)/me}},[]),Ke=w.useCallback(we=>{ye.updatePreferences(we).catch(()=>{})},[]),ot=w.useCallback(we=>{const U=[...A.current,we];A.current=U,Ve=ug(Ve,[we]),wa=xi(Ve),Ar=null,ia=null,Ke({removedFurniture:U})},[Ke]),xt=w.useCallback((we,U)=>{if(!Rl||!va)return;const ae=mg.find(ze=>ze.type===Rl),me=(ae==null?void 0:ae.price)??0;if(me>0&&S<me)return;let Ce=null;for(const[ze,Oe]of Object.entries(Ve.rooms)){const kt=va==="wall"?Oe.wx:Oe.fx,Me=va==="wall"?Oe.wy:Oe.fy,Le=va==="wall"?Oe.ww:Oe.fw,Vt=va==="wall"?Oe.wh:Oe.fh;if(we>=kt&&we<=kt+Le&&U>=Me&&U<=Me+Vt){Ce=ze;break}}if(!Ce)return;const De=Ve.rooms[Ce],Se=va==="wall"?De.wx:De.fx,Be=va==="wall"?De.wy:De.fy,$e={id:`user-${Rl}-${Date.now()}`,type:Rl,room:Ce,zone:va,offsetX:Math.round(we-Se),offsetY:Math.round(U-Be)},Re=[...Q.current,$e];if(Q.current=Re,va==="wall"?Ve.wallDecorations.push($e):Ve.furniture.push($e),wa=xi(Ve),Ke({addedFurniture:Re}),_==null||_(Rl,me),me>0){const ze=$e.type;Tg(async()=>{const{api:Oe}=await Promise.resolve().then(()=>Aw);return{api:Oe}},void 0).then(({api:Oe})=>{Oe.spendCoins(me,`furniture: ${ze}`,$e.id).then(kt=>E==null?void 0:E(kt.balance)).catch(()=>{})})}ee(null),D(null)},[Ke,S,E,_]),wt=w.useCallback(we=>{const U=B.current;if(Ga&&Qn){const{mx:Se,my:Be}=ct(we),Re=[...Ve.furniture,...Ve.wallDecorations].find(kt=>kt.id===Qn.defId);if(!Re)return;const ze=Se-Qn.startMx,Oe=Be-Qn.startMy;Re.offsetX=Math.round(Qn.origOffX+ze),Re.offsetY=Math.round(Qn.origOffY+Oe),wa=xi(Ve),U&&(U.style.cursor="grabbing");return}if(Ga&&zn){const{mx:Se,my:Be}=ct(we),$e=mn[zn.roleId];if(!$e)return;$e.dx=Math.round(zn.origDx+(Se-zn.startMx)),$e.dy=Math.round(zn.origDy+(Be-zn.startMy));const Re=G.current[zn.roleId];Re&&(Re.homeX=$e.dx+8,Re.homeY=$e.dy+34),U&&(U.style.cursor="grabbing");return}if(Ga){const{mx:Se,my:Be}=ct(we);if(Rl){U&&(U.style.cursor="crosshair");return}const $e=new Set(Object.values(mn).map(ze=>ze.room)),Re=_h(Ve,Se,Be,$e);if(Re)ia=Re;else{const ze=hg(mn,Se,Be);ia=ze?`desk:${ze}`:null}Vn=null,yi=null,U&&(U.style.cursor=ia?"grab":"default");return}const ae=Fe(we),me=Vn;Vn=(ae==null?void 0:ae.type)==="role"?ae.id:null,yi=(ae==null?void 0:ae.type)==="facility"?ae.id:null,vi=(ae==null?void 0:ae.type)==="mascot",ia=null,U&&(U.style.cursor=ae?"pointer":"default");const{mx:Ce}=ct(we);Rv=Ce;const De=Date.now();if(Vn&&Vn!==me){Ie.current[Vn]||(Ie.current[Vn]={hoverStartTime:null,lastSpeechTime:null,currentSpeech:null,speechDismissTime:null});const Se=Ie.current[Vn];Se.hoverStartTime=De}else if(!Vn&&me){const Se=Ie.current[me];Se&&(Se.hoverStartTime=null)}},[Fe,ct]),bt=w.useCallback(we=>{if(!Ga)return;const{mx:U,my:ae}=ct(we);if(Rl){xt(U,ae),we.preventDefault();return}const me=new Set(Object.values(mn).map(Se=>Se.room)),Ce=_h(Ve,U,ae,me);if(Ce){const Be=[...Ve.furniture,...Ve.wallDecorations].find($e=>$e.id===Ce);Be&&(Ar=Ce,Qn={defId:Ce,startMx:U,startMy:ae,origOffX:Be.offsetX,origOffY:Be.offsetY},we.preventDefault());return}const De=hg(mn,U,ae);if(De){const Se=mn[De];Ar=`desk:${De}`,zn={roleId:De,startMx:U,startMy:ae,origDx:Se.dx,origDy:Se.dy},we.preventDefault();return}Ar=null},[ct,xt]),dt=w.useCallback(we=>{if(Qn){const ae=[...Ve.furniture,...Ve.wallDecorations].find(me=>me.id===Qn.defId);if(ae){const me={...F.current,[ae.id]:{offsetX:ae.offsetX,offsetY:ae.offsetY}};F.current=me,Ke({furnitureOverrides:me}),wa=xi(Ve)}Qn=null,B.current&&(B.current.style.cursor="grab");return}if(zn){const U=mn[zn.roleId];if(U){const ae={...W.current,[zn.roleId]:{dx:U.dx,dy:U.dy}};W.current=ae,Ke({deskOverrides:ae})}zn=null,B.current&&(B.current.style.cursor="grab")}},[Ke]),gn=w.useCallback(we=>{if(!Ga)return;we.preventDefault();const{mx:U,my:ae}=ct(we),me=new Set(Object.values(mn).map(De=>De.room)),Ce=_h(Ve,U,ae,me);Ce&&ot(Ce)},[ct,ot]);w.useEffect(()=>{const we=U=>{!Ga||!Ar||(U.key==="Delete"||U.key==="Backspace")&&(Ar.startsWith("desk:")||ot(Ar))};return window.addEventListener("keydown",we),()=>window.removeEventListener("keydown",we)},[ot]);const ft=w.useCallback(()=>{if(Qn){const U=[...Ve.furniture,...Ve.wallDecorations].find(ae=>ae.id===Qn.defId);U&&(U.offsetX=Qn.origOffX,U.offsetY=Qn.origOffY,wa=xi(Ve)),Qn=null}if(zn){const we=mn[zn.roleId];we&&(we.dx=zn.origDx,we.dy=zn.origDy);const U=G.current[zn.roleId];U&&(U.homeX=we.dx+8,U.homeY=we.dy+34),zn=null}Vn=null,yi=null,vi=!1,ia=null,B.current&&(B.current.style.cursor="default")},[]),Wt=w.useCallback(we=>{if(Ga)return;const U=Fe(we);if(U){if(U.type==="role"){const ae=G.current[U.id],me=mn[U.id];if(ae&&me){const Ce=ae.state==="sitting"?me.dx+13:Math.round(ae.x)+6,De=ae.state==="sitting"?me.dy+2:Math.round(ae.y)-2;gg(Ce,De)}o(U.id);return}if(U.type==="mascot"){const ae=T.current;ae&&gg(Math.round(ae.x)+4,Math.round(ae.y)-2),k==null||k();return}switch(U.id){case"meeting":{const ae=n[0];ae?u(ae.id):d();break}case"bulletin":d();break;case"decisions":h();break;case"knowledge":m();break;case"settings":f==null||f();break;case"theme":x==null||x();break;case"stats":y==null||y();break}}},[Fe,o,u,d,h,m,f,x,y]);return w.useCallback(async()=>{if(!((S??0)<15e3||!window.confirm("Upgrade to Large Office for 15,000 coins?")))try{const U=await ye.spendCoins(15e3,"office-expansion: preset-L","expansion-preset-L");U.ok&&(E==null||E(U.balance),I==null||I("L"))}catch{}},[S,E,I]),l.jsxs("div",{className:`td-scene${J?" td-scene--editing":""}`,children:[l.jsxs("div",{ref:$,className:"td-wrap",children:[l.jsx("canvas",{ref:B,width:Ve.canvasW,height:Ve.canvasH,className:"td-canvas",onClick:Wt,onMouseDown:bt,onMouseUp:dt,onMouseMove:wt,onMouseLeave:ft,onContextMenu:gn}),l.jsx("div",{ref:q,className:"td-overlay"})]}),J&&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${J?" td-edit-btn--active":""}`,"data-quest-target":"edit-btn",onClick:()=>{ce(we=>{const U=!we;return U||(ee(null),D(null)),U}),Ar=null,Qn=null,zn=null},title:J?"Exit Edit Mode":"Edit Furniture Layout",children:[l.jsx("span",{className:"td-edit-btn__icon",children:J?"✓":"✎"}),l.jsx("span",{className:"td-edit-btn__label",children:J?"DONE":"EDIT"})]}),J&&l.jsx("div",{className:"td-palette",children:mg.map(we=>{const U=we.price===0||S>=we.price,ae=we.price===0?"Free":`${we.price>=1e3?`${(we.price/1e3).toFixed(we.price%1e3===0?0:1)}K`:we.price}`;return l.jsxs("button",{className:`td-palette__item${le===we.type?" td-palette__item--active":""}${U?"":" td-palette__item--locked"}`,onClick:()=>{U&&(le===we.type?(ee(null),D(null)):(ee(we.type),D(we.zone)))},title:`${we.label} — ${ae}`,style:U?void 0:{opacity:.4,cursor:"not-allowed"},children:[l.jsx("span",{children:we.icon}),l.jsx("span",{className:"td-palette__price",style:{fontSize:"7px",color:we.price===0?"#4CAF50":U?"#FFD54F":"#EF5350"},children:ae})]},we.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 n8({role:e,appearance:n,onSave:a,onReset:i,onClose:o,theme:u,onThemeChange:d,onUpdateName:h,initialTab:m,characterOnly:f,speechSettings:x,onSpeechSettingsChange:y,language:v,onLanguageChange:b,roleLevel:j}){var H;const[k,N]=w.useState(m??"character"),[S,E]=w.useState({...n}),[_,R]=w.useState(e.name),[I,B]=w.useState(!1),$=w.useCallback(()=>E(hs(j)),[j]),q=w.useCallback(()=>{const L=Vm(e.id);E({...L}),i()},[e.id,i]),G=w.useCallback(async()=>{a(S);const L=_.trim();if(h&&L&&L!==e.name){B(!0);try{await h(e.id,L)}catch{}B(!1)}o()},[S,a,o,_,e.name,e.id,h]),T=l.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6},children:[l.jsxs("span",{children:[e.id.toUpperCase()," –"]}),h?l.jsx("input",{value:_,onChange:L=>R(L.target.value),disabled:I,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:L=>L.stopPropagation(),children:[l.jsxs("div",{className:"customize-header",children:[l.jsxs("div",{className:"customize-tabs",children:[l.jsx("button",{className:`customize-tab ${k==="character"?"active":""}`,onClick:()=>N("character"),children:"CHARACTER"}),!f&&l.jsxs(l.Fragment,{children:[l.jsx("button",{className:`customize-tab ${k==="office"?"active":""}`,onClick:()=>N("office"),children:"OFFICE THEME"}),l.jsx("button",{className:`customize-tab ${k==="settings"?"active":""}`,onClick:()=>N("settings"),children:"SETTINGS"})]})]}),l.jsx("button",{className:"customize-close",onClick:o,children:"X"})]}),k==="character"?l.jsx("div",{className:"customize-body",children:l.jsx(xv,{roleId:e.id,appearance:S,onChange:E,onRandomize:$,onReset:q,label:T,roleLevel:j})}):k==="office"?l.jsx("div",{className:"customize-body",children:l.jsx("div",{className:"customize-themes",children:Object.entries(Ja).map(([L,J])=>l.jsxs("button",{className:`customize-theme-card ${u===L?"active":""}`,onClick:()=>d(L),children:[l.jsxs("div",{className:"customize-theme-preview",style:{background:J.vars["--floor-light"],borderColor:J.vars["--pixel-border"]},children:[l.jsx("div",{style:{background:J.vars["--hud-bg"],height:8,borderBottom:`2px solid ${J.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:J.vars["--accent"],borderRadius:1}}),l.jsx("div",{style:{width:10,height:14,background:J.vars["--active-green"],borderRadius:1}}),l.jsx("div",{style:{width:10,height:14,background:J.vars["--idle-amber"],borderRadius:1}})]}),l.jsx("div",{style:{background:J.vars["--hud-bg"],height:6,borderTop:`2px solid ${J.vars["--pixel-border"]}`}})]}),l.jsxs("div",{className:"customize-theme-name",children:[J.icon," ",J.name]})]},L))})}):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(L=>l.jsxs("button",{onClick:()=>y==null?void 0:y({mode:L}),style:{flex:1,padding:"8px 12px",fontSize:11,border:`2px solid ${(x==null?void 0:x.mode)===L?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(x==null?void 0:x.mode)===L?"rgba(255,255,255,0.08)":"transparent",color:(x==null?void 0:x.mode)===L?"var(--terminal-text)":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",textAlign:"center"},children:[l.jsx("div",{style:{fontWeight:600,marginBottom:2},children:L==="template"?"TEMPLATE":L==="llm"?"AI":"AUTO"}),l.jsx("div",{style:{fontSize:9,opacity:.7},children:L==="template"?"Static pool ($0)":L==="llm"?"LLM generated":"Detect engine"})]},L))}),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:L=>y==null?void 0:y({intervalSec:Number(L.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: $",((H=x==null?void 0:x.dailyBudgetUsd)==null?void 0:H.toFixed(2))??"1.00"]}),l.jsx("input",{type:"range",min:0,max:5,step:.25,value:(x==null?void 0:x.dailyBudgetUsd)??1,onChange:L=>y==null?void 0:y({dailyBudgetUsd:Number(L.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:L,label:J})=>l.jsx("button",{onClick:()=>b==null?void 0:b(L),style:{flex:1,padding:"8px 12px",fontSize:11,border:`2px solid ${(v??"auto")===L?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(v??"auto")===L?"rgba(255,255,255,0.08)":"transparent",color:(v??"auto")===L?"var(--terminal-text)":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",textAlign:"center",fontWeight:600},children:J},L))}),l.jsx("div",{style:{fontSize:9,color:"var(--terminal-text-muted)",marginTop:4},children:"Sets language for AI responses and speech bubbles"})]})]})}),k==="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:G,children:"SAVE"})]})]})})}function bg(e){if(e.length===0)return"";const n={};for(const{file:h}of e){const m=h.split("/"),f=m[0]==="."?m[1]??"root":m[0];(n[f]??(n[f]=[])).push(h)}const a={roles:"roles",projects:"projects",operations:"operations",knowledge:"knowledge",architecture:"architecture",company:"company",".tycono":"config",".claude":"skills"},i=[];for(const[h,m]of Object.entries(n)){const f=a[h]??h;if(m.length===1){const x=m[0].split("/").pop()??m[0];i.push(`${f}/${x}`)}else i.push(`${f} (${m.length} files)`)}const o=e.some(h=>h.status==="A"),u=e.some(h=>h.status==="M");return`${o&&!u?"add":"update"}: ${i.join(", ")}`}function vg(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 r8({onInitGit:e,onDelegate:n,delegateRoleName:a}){const[i,o]=w.useState(!1),[u,d]=w.useState(null),h=async()=>{o(!0),d(null);try{await e(),d({ok:!0,message:"Git repository initialized!"})}catch(f){const x=f instanceof Error?f.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:h,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 a8({repo:e,onConnected:n,onDelegate:a,delegateRoleName:i}){const[o,u]=w.useState("idle"),[d,h]=w.useState(null),[m,f]=w.useState(""),[x,y]=w.useState("private"),[v,b]=w.useState(""),[j,k]=w.useState(null),[N,S]=w.useState(!1),E=async()=>{u("checking"),k(null);try{const B=await ye.getGithubStatus(e);h(B),B.hasRemote?n():B.ghInstalled&&B.authenticated?u("ready"):u("idle")}catch{u("idle")}},_=async()=>{if(m.trim()){S(!0),k(null);try{const B=await ye.githubCreateRepo(m.trim(),x,e);k(B),B.ok&&setTimeout(n,1500)}catch(B){k({ok:!1,message:B instanceof Error?B.message:"Failed"})}finally{S(!1)}}},R=async()=>{if(v.trim()){S(!0),k(null);try{const B=await ye.addRemote(v.trim(),e);k(B),B.ok&&setTimeout(n,1500)}catch(B){k({ok:!1,message:B instanceof Error?B.message:"Failed"})}finally{S(!1)}}},I=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:E,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"}),I]}),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:E,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"}),I]})]}),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:E,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"}),I]})]}),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:B=>f(B.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:B=>y(B.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:B=>b(B.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"),h(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 l8({status:e,history:n,onClose:a,onSave:i,onLoadHistory:o,onRestore:u,saving:d,onDelegate:h,delegateRoleName:m,repo:f,onRepoChange:x,syncInfo:y,onPull:v,pulling:b,onRefresh:j,onInitGit:k}){const[N,S]=w.useState("save"),[E,_]=w.useState(""),[R,I]=w.useState(null),[B,$]=w.useState(!1),[q,G]=w.useState(null),[T,H]=w.useState(null),L=w.useRef(null);w.useEffect(()=>{N==="history"&&o()},[N,o]),w.useEffect(()=>{var D;(D=L.current)==null||D.focus()},[]);const J=[...((e==null?void 0:e.modified)??[]).map(D=>({status:"M",file:D})),...((e==null?void 0:e.untracked)??[]).map(D=>({status:"A",file:D}))],ce=w.useRef(!1);w.useEffect(()=>{!ce.current&&J.length>0&&!E&&(_(bg(J)),ce.current=!0)},[J.length]),w.useEffect(()=>{ce.current=!1,_(""),H(null),G(null),I(null)},[f]);const re=w.useCallback(()=>{_(bg(J))},[J]),X=async()=>{I(null),G(null);try{const D=await i(E||void 0);G(D),_("")}catch(D){I(D instanceof Error?D.message:"Save failed")}},le=async()=>{H(null),I(null);try{const D=await v();H(D)}catch(D){I(D instanceof Error?D.message:"Pull failed")}},ee=async D=>{if(confirm(`Restore from commit ${D.slice(0,7)}? This creates a new commit with those files.`)){$(!0);try{await u(D),$(!1)}catch(F){I(F instanceof Error?F.message:"Restore failed"),$(!1)}}};w.useEffect(()=>{const D=F=>{F.key==="Escape"&&a()};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[a]);const Z=D=>{D.key==="Enter"&&(D.metaKey||D.ctrlKey)&&X()};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:Z,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 GAME"}),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:[y&&y.hasRemote&&(y.behind>0||y.ahead>0)&&l.jsxs("span",{className:"text-[10px] font-bold",style:{color:y.behind>0?"var(--idle-amber)":"var(--active-green)"},children:[y.behind>0&&`↓${y.behind}`,y.behind>0&&y.ahead>0&&" ",y.ahead>0&&`↑${y.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:f===D?"var(--hud-bg-alt)":"transparent",color:f===D?"var(--terminal-text)":"var(--terminal-text-muted)",borderBottom:f===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:()=>S(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(r8,{onInitGit:async()=>{await(k==null?void 0:k()),j==null||j()},onDelegate:h?()=>{h(`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}),y&&y.hasRemote&&y.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:[y.behind," commit",y.behind>1?"s":""," behind remote"]}),l.jsx("button",{onClick:le,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"})]}),T&&l.jsx("div",{className:"text-[11px] p-2",style:{background:T.status==="ok"||T.status==="up-to-date"?"rgba(59,185,80,0.1)":"rgba(211,47,47,0.1)",border:`1px solid ${T.status==="ok"||T.status==="up-to-date"?"var(--active-green)":"#D32F2F"}`,color:T.status==="ok"||T.status==="up-to-date"?"var(--active-green)":"#EF5350"},children:T.message}),l.jsx("div",{className:"text-[11px]",style:{color:"var(--terminal-text-secondary)"},children:J.length>0?l.jsxs("span",{style:{color:"var(--idle-amber)"},children:["* ",J.length," unsaved change",J.length>1?"s":""]}):l.jsx("span",{style:{color:"var(--active-green)"},children:"All changes saved"})}),J.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:J.map(({status:D,file:F})=>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:F})]},F))})]}),J.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:re,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:L,type:"text",value:E,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)"}})]}),J.length>0&&l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:X,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"}),h&&l.jsxs("button",{onClick:()=>{const D=J.map(F=>`${F.status} ${F.file}`).join(`
92
- `);h(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(a8,{repo:f,onConnected:()=>j==null?void 0:j(),onDelegate:h?()=>{h(`Set up a GitHub remote for the ${f==="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}),q&&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! ",q.filesChanged," file",q.filesChanged>1?"s":""," committed",q.pushed?" & pushed":"",q.pushError?` (push error: ${q.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," (",vg(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:vg(D.date)})]}),l.jsx("button",{onClick:()=>ee(D.sha),disabled:B,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 i8({onClose:e}){const[n,a]=w.useState(null),[i,o]=w.useState(!0),[u,d]=w.useState(null),[,h]=w.useState(!1);return w.useEffect(()=>{Promise.all([ye.getCompanyStats(),ye.getPreferences()]).then(async([m,f])=>{a(m);const x=f;if(x.instanceId)try{await pr.syncStats({instanceId:x.instanceId,roleCount:m.company.roleCount,totalTokens:m.company.totalTokens,rolesData:m.roles.map(y=>({roleId:y.roleId,name:y.name,tokens:y.totalTokens}))}),h(!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(wu,{label:"Roles",value:String(n.company.roleCount)}),l.jsx(wu,{label:"Avg Level",value:`Lv.${n.company.avgLevel}`}),l.jsx(wu,{label:"Total Tokens",value:n.company.formattedTokens}),l.jsx(wu,{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,f)=>l.jsx(s8,{role:m,rank:f+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,f])=>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:o8(m)}),l.jsxs("span",{style:{color:"rgba(255,255,255,0.5)"},children:["$",f.costUsd.toFixed(2)]})]},m))})]})]})}function wu({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 s8({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:wg(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:wg(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 wg(e){return e>=20?"#FFD700":e>=10?"#C0A0FF":e>=5?"#4FC3F7":e>=3?"#81C784":"rgba(255,255,255,0.4)"}function o8(e){return e.includes("opus")?"Opus":e.includes("sonnet")?"Sonnet":e.includes("haiku")?"Haiku":e.split("-").slice(0,2).join(" ")}function c8({onClose:e,onSyncComplete:n}){const[a,i]=w.useState([]),[o,u]=w.useState([]),[d,h]=w.useState(!0),[m,f]=w.useState(null),[x,y]=w.useState(new Set),[v,b]=w.useState(null),[j,k]=w.useState(null),N=w.useCallback(async()=>{h(!0),b(null);try{const{roles:E}=await ye.getSyncRoles();i(E);const _=E.filter(R=>R.source.sync!=="off");if(_.length===0){u([]),k(null);return}try{const R=await pr.syncCheck(_.map(B=>({roleId:B.roleId,sourceId:B.source.id,currentVersion:B.source.upstream_version??B.source.forked_at??"0.0.0"})));k(!0);const I=[];for(const B of R.updates){if(!B.hasUpdate)continue;const $=_.find(L=>L.roleId===B.roleId);if(!$)continue;const{character:q}=await pr.syncPull(B.sourceId),G=[];$.persona.trim()!==q.persona.trim()&&G.push({field:"persona",local:$.persona.slice(0,120)+($.persona.length>120?"...":""),upstream:q.persona.slice(0,120)+(q.persona.length>120?"...":"")});const T=JSON.stringify($.authority),H=JSON.stringify(q.authority);T!==H&&G.push({field:"authority",local:`${$.authority.autonomous.length} autonomous, ${$.authority.needsApproval.length} approval`,upstream:`${q.authority.autonomous.length} autonomous, ${q.authority.needsApproval.length} approval`}),G.length>0&&I.push({roleId:B.roleId,roleName:$.name,sourceId:B.sourceId,currentVersion:B.currentVersion,latestVersion:B.latestVersion,fields:G})}u(I)}catch{k(!1),u([])}}catch(E){b(E instanceof Error?E.message:"Failed to check for updates")}finally{h(!1)}},[]);w.useEffect(()=>{N()},[N]);const S=async E=>{f(E.roleId);try{const{character:_,version:R}=await pr.syncPull(E.sourceId);await ye.applySyncUpdate({roleId:E.roleId,changes:{persona:_.persona,authority:_.authority},upstreamVersion:R}),y(I=>new Set(I).add(E.roleId)),n==null||n()}catch(_){b(_ instanceof Error?_.message:"Failed to apply update")}finally{f(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(E=>!x.has(E.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(E=>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:E.roleName}),l.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.4)"},children:[E.sourceId," · v",E.currentVersion," → v",E.latestVersion]})]}),x.has(E.roleId)?l.jsx("span",{style:{fontSize:12,color:"#81C784"},children:"Applied ✓"}):l.jsx("button",{onClick:()=>S(E),disabled:m===E.roleId,style:{background:"#1565C0",border:"none",color:"white",borderRadius:6,padding:"5px 12px",fontSize:12,cursor:m===E.roleId?"wait":"pointer",opacity:m===E.roleId?.6:1},children:m===E.roleId?"Applying...":"Apply Update"})]}),E.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))]},E.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 u8({onClose:e}){const[n,a]=w.useState(null),[i,o]=w.useState(!0),[u,d]=w.useState(null),[h,m]=w.useState(null),f=w.useCallback(async()=>{o(!0),d(null);try{const E=await ye.getGitStatus();a(E)}catch(E){d(E instanceof Error?E.message:"Failed to load git status")}finally{o(!1)}},[]);w.useEffect(()=>{f()},[f]);const x=async E=>{m(E.path);try{await ye.deleteWorktree(E.path),await f()}catch(_){d(_ instanceof Error?_.message:"Failed to remove worktree")}finally{m(null)}},y=async E=>{m(E);try{await ye.deleteBranch(E),await f()}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(E=>E.status==="active"),b=n.worktrees.filter(E=>E.status==="pending-merge"),j=n.worktrees.filter(E=>E.status==="stale");function k(E){const _=E.split("/");if(_.length>1){const R=_[_.length-1],I=["cto","cbo","pm","engineer","designer","qa","data-analyst"];for(const B of I)if(R.toLowerCase().includes(B))return B}return null}function N(E,_=40){return E.length<=_?E:"..."+E.slice(E.length-_+3)}function S(E){const _=Date.now()-new Date(E).getTime(),R=Math.floor(_/6e4);if(R<1)return"just now";if(R<60)return`${R}m ago`;const I=Math.floor(R/60);return I<24?`${I}h ago`:`${Math.floor(I/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:f,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?"...":""," · ",S(n.lastCommit.date)]})]}),v.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(ku,{label:"Active Worktrees",count:v.length}),v.map(E=>l.jsx($h,{wt:E,roleFromBranch:E.roleId||k(E.branch),truncatePath:N,timeAgo:S,removing:h===E.path,onRemove:()=>x(E),statusColor:"#4FC3F7",statusIcon:"📂"},E.path))]}),b.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(ku,{label:"Pending Merge",count:b.length}),b.map(E=>l.jsx($h,{wt:E,roleFromBranch:E.roleId||k(E.branch),truncatePath:N,timeAgo:S,removing:h===E.path,onRemove:()=>x(E),statusColor:"#FFB74D",statusIcon:"⚠️"},E.path))]}),j.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(ku,{label:"Stale",count:j.length}),j.map(E=>l.jsx($h,{wt:E,roleFromBranch:E.roleId||k(E.branch),truncatePath:N,timeAgo:S,removing:h===E.path,onRemove:()=>x(E),statusColor:"#ff6b6b",statusIcon:"🔴"},E.path))]}),n.staleBranches.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(ku,{label:"Unmerged Branches",count:n.staleBranches.length}),n.staleBranches.map(E=>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:E})]}),l.jsx("button",{onClick:()=>y(E),disabled:h===E,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:h===E?"wait":"pointer",opacity:h===E?.6:1,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:h===E?"...":"DELETE"})]},E))]}),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," · ",S(n.lastMerge.mergedAt)]})]})}function ku({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 $h({wt:e,roleFromBranch:n,truncatePath:a,timeAgo:i,removing:o,onRemove:u,statusColor:d,statusIcon:h}){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:h}),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 d8({onClose:e}){const[n,a]=w.useState(null),[i,o]=w.useState(!0),[u,d]=w.useState(null),[h,m]=w.useState(null),f=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(()=>{f();const k=setInterval(f,1e4);return()=>clearInterval(k)},[f]);const x=async k=>{m(k);try{await ye.deleteActiveSession(k),await f()}catch(N){d(N instanceof Error?N.message:"Failed to remove session")}finally{m(null)}},y=async()=>{try{await ye.cleanupActiveSessions(),await f()}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:y,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:f,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(Ih,{label:"Active",count:v.length}),v.map(k=>l.jsx(Hh,{session:k,removing:h===k.sessionId,onRemove:()=>x(k.sessionId),statusColor:"#4FC3F7"},k.sessionId))]}),b.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Ih,{label:"Idle",count:b.length}),b.map(k=>l.jsx(Hh,{session:k,removing:h===k.sessionId,onRemove:()=>x(k.sessionId),statusColor:"#FFB74D"},k.sessionId))]}),j.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Ih,{label:"Dead",count:j.length}),j.map(k=>l.jsx(Hh,{session:k,removing:h===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 Ih({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 f8(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 Hh({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:[" · ",h8(e.worktreePath)]}),e.pid&&l.jsxs(l.Fragment,{children:[" · ","PID:",e.pid]})," · ",f8(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 h8(e,n=35){return e.length<=n?e:"..."+e.slice(e.length-n+3)}function m8({onClose:e,speechSettings:n,onSpeechSettingsChange:a,language:i,onLanguageChange:o,onOpenSync:u,onOpenGitStatus:d,onOpenSessions:h,onOpenStats:m}){var le;const[f,x]=w.useState(null),[y,v]=w.useState(null),[b,j]=w.useState(!1),[k,N]=w.useState(!1),[S,E]=w.useState(!1),[_,R]=w.useState(null),[I,B]=w.useState(""),[$,q]=w.useState(!1),[G,T]=w.useState(!1),[H,L]=w.useState(null),[J,ce]=w.useState(!1);w.useEffect(()=>{ye.getPreferences().then(async ee=>{const Z=ee;if(x(Z.instanceId??null),Z.instanceId)try{const{name:D}=await pr.getMyName(Z.instanceId);v(D)}catch{}}).catch(()=>{}),ye.getCodeRoot().then(({codeRoot:ee})=>{R(ee),ee&&B(ee)}).catch(()=>{})},[]);const re=async()=>{E(!0);try{const Z=await(await fetch("/api/preferences/regenerate-token",{method:"POST"})).json();Z.ok&&(x(Z.newInstanceId),N(!1))}catch{}E(!1)},X=()=>{f&&navigator.clipboard.writeText(f).then(()=>{j(!0),setTimeout(()=>j(!1),2e3)})};return l.jsx("div",{className:"customize-overlay",onClick:e,children:l.jsxs("div",{className:"customize-modal",onClick:ee=>ee.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(ee=>l.jsxs("button",{onClick:()=>a==null?void 0:a({mode:ee}),style:{flex:1,padding:"8px 12px",fontSize:11,border:`2px solid ${(n==null?void 0:n.mode)===ee?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(n==null?void 0:n.mode)===ee?"rgba(255,255,255,0.08)":"transparent",color:(n==null?void 0:n.mode)===ee?"var(--terminal-text)":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",textAlign:"center"},children:[l.jsx("div",{style:{fontWeight:600,marginBottom:2},children:ee==="template"?"TEMPLATE":ee==="llm"?"AI":"AUTO"}),l.jsx("div",{style:{fontSize:9,opacity:.7},children:ee==="template"?"Static pool ($0)":ee==="llm"?"LLM generated":"Detect engine"})]},ee))}),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:ee=>a==null?void 0:a({intervalSec:Number(ee.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: $",((le=n==null?void 0:n.dailyBudgetUsd)==null?void 0:le.toFixed(2))??"1.00"]}),l.jsx("input",{type:"range",min:0,max:5,step:.25,value:(n==null?void 0:n.dailyBudgetUsd)??1,onChange:ee=>a==null?void 0:a({dailyBudgetUsd:Number(ee.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:ee,label:Z})=>l.jsx("button",{onClick:()=>o==null?void 0:o(ee),style:{flex:1,padding:"8px 12px",fontSize:11,border:`2px solid ${(i??"auto")===ee?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(i??"auto")===ee?"rgba(255,255,255,0.08)":"transparent",color:(i??"auto")===ee?"var(--terminal-text)":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",textAlign:"center",fontWeight:600},children:Z},ee))}),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"}),$?l.jsxs("div",{children:[l.jsxs("div",{style:{display:"flex",gap:6},children:[l.jsx("input",{type:"text",value:I,onChange:ee=>{B(ee.target.value),L(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(I.trim()){T(!0),L(null);try{const ee=await ye.setCodeRoot(I.trim());R(ee.codeRoot),B(ee.codeRoot),q(!1),ce(!0),setTimeout(()=>ce(!1),3e3)}catch(ee){L(ee instanceof Error?ee.message:"Failed to set code root")}finally{T(!1)}}},disabled:G||!I.trim(),style:{padding:"8px 12px",fontSize:10,fontWeight:600,background:"var(--accent)",border:"none",color:"#fff",borderRadius:6,cursor:"pointer",opacity:G||!I.trim()?.5:1},children:G?"...":"Save"}),l.jsx("button",{onClick:()=>{q(!1),B(_||""),L(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"})]}),H&&l.jsx("div",{style:{fontSize:9,color:"#ff6b6b",marginTop:4},children:H})]}):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:()=>{q(!0),L(null),ce(!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"})]}),J&&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)"})]}),f&&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:f}),l.jsx("button",{onClick:X,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:re,disabled:S,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:S?"...":"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"}),h&&l.jsx("button",{onClick:()=>{e(),h()},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"})]}),y&&l.jsx("div",{style:{textAlign:"center",marginTop:-8},children:l.jsx("a",{href:`https://tycono.ai/profile.html?u=${encodeURIComponent(y)}`,target:"_blank",rel:"noopener noreferrer",style:{fontSize:10,color:"var(--terminal-text-muted)",textDecoration:"none"},onMouseEnter:ee=>ee.currentTarget.style.color="var(--accent)",onMouseLeave:ee=>ee.currentTarget.style.color="var(--terminal-text-muted)",children:"View public profile →"})})]})})]})})}function p8({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(Ja).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 Oo={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function x8({roles:e,roleStatuses:n,activeExecs:a,sessions:i,knowledgeDocs:o,roleLevels:u,companyName:d,getAppearance:h,waveCenterWaves:m,renderProfile:f,channel:x,onChannelChange:y,onClose:v,children:b}){const[j,k]=w.useState(!1),N=m.filter($=>$.rootJobs.some(q=>{const G=n[q.roleId];return G==="working"||G==="thinking"})),S=[...e].sort(($,q)=>$.level==="c-level"&&q.level!=="c-level"?-1:$.level!=="c-level"&&q.level==="c-level"?1:$.name.localeCompare(q.name)),E=e.filter($=>n[$.id]==="working").length,_=i.filter($=>$.status==="active").length,R=x.type==="role"?e.find($=>$.id===x.roleId):null,I=x.type==="dashboard"?"Dashboard":x.type==="terminal"?"Terminal":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",B=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":`${E} 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}),E>0&&l.jsxs("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full animate-pulse",style:{background:"#4CAF5020",color:"#4CAF50"},children:[E," 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:()=>y({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($=>{const q=n[$.roleId];return q==="working"||q==="thinking"}).length,"/",N[0].rootJobs.length," roles working"]})]}),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:"CHANNELS"}),l.jsx(ju,{icon:"#",label:"general",active:x.type==="terminal",badge:_>0?_:void 0,onClick:()=>y({type:"terminal"})}),l.jsx(ju,{icon:"⚡",label:"wave-log",active:x.type==="wave",live:N.length>0,onClick:()=>y({type:"wave"})}),l.jsx(ju,{icon:"#",label:"decisions",active:x.type==="operations",onClick:()=>y({type:"operations"})}),l.jsx(ju,{icon:"📚",label:"knowledge",active:x.type==="knowledge",onClick:()=>y({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"}),S.map($=>{var J;const q=n[$.id],G=a.find(ce=>ce.roleId===$.id),T=Oo[$.id]??"#666",H=(J=u[$.id])==null?void 0:J.level,L=x.type==="role"&&x.roleId===$.id;return l.jsxs("button",{onClick:()=>y({type:"role",roleId:$.id}),className:"flex items-center gap-2.5 w-full px-4 py-1.5 text-left hover:opacity-80 transition-all",style:{background:L?`${T}18`:"transparent",borderLeft:L?`2px solid ${T}`:"2px solid transparent"},children:[l.jsxs("div",{className:"relative shrink-0",style:{width:22,height:22},children:[l.jsx(Pa,{roleId:$.id,appearance:h($.id),scale:1.3}),l.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 w-2 h-2 rounded-full",style:{background:q==="working"?"#4CAF50":q==="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:[$.name,H!=null&&l.jsxs("span",{className:"ml-1 opacity-40 text-[8px]",children:["Lv.",H]})]}),G?l.jsx("div",{className:"text-[9px] truncate",style:{color:T},children:G.task.slice(0,28)}):l.jsx("div",{className:"text-[9px]",style:{color:"var(--terminal-text-muted, #887766)"},children:$.level==="c-level"?$.id.toUpperCase():$.id})]}),q==="working"&&l.jsx("span",{className:"w-1.5 h-1.5 rounded-full animate-pulse shrink-0",style:{background:T}})]},$.id)})]}),l.jsx("div",{className:"flex-1"}),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($=>!$),className:"relative shrink-0 rounded-lg overflow-hidden hover:opacity-80 transition-opacity cursor-pointer",style:{width:28,height:28,background:`${Oo[R.id]??"#666"}30`},title:"View profile",children:[l.jsx(Pa,{roleId:R.id,appearance:h(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:I}),l.jsx("span",{className:"text-[10px]",style:{color:"var(--terminal-text-muted, #887766)"},children:B}),l.jsx("span",{className:"flex-1"}),x.type==="role"&&l.jsx("button",{onClick:()=>k($=>!$),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:()=>y({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"&&f&&l.jsx("div",{className:"shrink-0 overflow-hidden pro-panel-inline",style:{width:420,borderLeft:"1px solid var(--terminal-border, #2E261F)"},children:f(()=>k(!1))})]})]})]})}function y8({role:e,messages:n,isStreaming:a,mode:i,onModeChange:o,onSend:u,isWave:d}){const h=Oo[e.id]??"#666";return l.jsxs("div",{className:"flex flex-col h-full",children:[l.jsx(yv,{messages:n,roleId:e.id,roleColor:h}),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(Gm,{mode:i,onModeChange:o,onSend:(m,f)=>u(m,i,f),disabled:a,disabledReason:a?`${e.id.toUpperCase()} is responding...`:void 0})]})}function g8({role:e,onSend:n,getAppearance:a,onOpenProfile:i}){const[o,u]=w.useState("talk"),d=Oo[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(Pa,{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(Gm,{mode:o,onModeChange:u,onSend:h=>n(h,o),disabled:!1})]})}function ju({icon:e,label:n,active:a,badge:i,live:o,onClick:u}){return l.jsxs("button",{onClick:u,className:"flex items-center gap-2.5 w-full px-4 py-1.5 text-left hover:opacity-80 transition-all",style:{background:a?"var(--terminal-border, #2E261F)":"transparent"},children:[l.jsx("span",{className:"text-[11px] w-4 text-center",style:{color:a?"var(--terminal-text)":"var(--terminal-text-muted)"},children:e}),l.jsx("span",{className:"text-[11px] flex-1",style:{color:a?"var(--terminal-text, #fff5eb)":"var(--terminal-text-muted, #887766)",fontWeight:a?600:400},children:n}),o&&l.jsx("span",{className:"text-[7px] px-1 py-0.5 rounded font-bold",style:{background:"#EF444420",color:"#EF4444"},children:"live"}),i!==void 0&&i>0&&!o&&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:i})]})}function b8({roles:e,roleStatuses:n,activeExecs:a,waves:i,knowledgeDocs:o,roleLevels:u,getAppearance:d,onRoleClick:h,onWaveClick:m,onKnowledgeClick:f}){const x=e.filter(y=>n[y.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(kg,{label:"New Wave",icon:"⚡",color:"#EF4444",onClick:m}),l.jsx(kg,{label:"Knowledge",icon:"📚",color:"#0D9488",onClick:f})]}),x.length>0&&l.jsx(Su,{title:"Currently Working",count:x.length,children:a.map(y=>{const v=e.find(j=>j.id===y.roleId),b=Oo[y.roleId]??"#666";return l.jsxs("button",{onClick:()=>h(y.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(Pa,{roleId:y.roleId,appearance:d(y.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:y.task.slice(0,60)})]}),l.jsx("span",{className:"text-[10px] animate-pulse",style:{color:b},children:"●"})]},y.roleId)})}),l.jsx(Su,{title:"Team",count:e.length,children:l.jsx("div",{className:"grid grid-cols-3 gap-1 px-2",children:e.map(y=>{var j;const v=n[y.id]??"offline",b=(j=u[y.id])==null?void 0:j.level;return l.jsxs("button",{onClick:()=>h(y.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:y.name}),b!=null&&l.jsxs("span",{className:"text-[9px] opacity-40",children:["Lv.",b]})]},y.id)})})}),i.length>0&&l.jsx(Su,{title:"Recent Waves",count:i.length,children:i.slice(0,5).map(y=>{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 ",y.id]})," — ",(v=y.directive)==null?void 0:v.slice(0,80)]},y.id)})}),l.jsx(Su,{title:"Knowledge Base",count:o.length,children:l.jsxs("button",{onClick:f,className:"px-4 py-3 text-[11px] hover:opacity-80",style:{color:"var(--terminal-text-muted)"},children:[o.length," documents · Click to explore ","→"]})})]})})}function kg({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 Su({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 ym=5e4;function zv(e){return e<ym?1:Math.max(1,Math.floor(Math.sqrt(e/ym)))}function jg(e){return ym*e*e}function v8(e){const n=zv(e),a=jg(n),i=jg(n+1);return Math.min(1,(e-a)/(i-a))}function Uh(e){const n={};for(const[a,i]of Object.entries(e)){const o=i.inputTokens+i.outputTokens;n[a]={level:zv(o),totalTokens:o,progress:v8(o)}}return n}const w8=[{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 Sg(e){return w8.filter(n=>n.check(e))}const k8={cto:"🏗️",cbo:"📊",pm:"📋",engineer:"⚙️",designer:"🎨",qa:"🔍","data-analyst":"📊"},gm={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"},j8={cto:"아키텍처",cbo:"시장 분석",pm:"PRD 작성",engineer:"코딩",designer:"시안 제작",qa:"품질 검증"};function S8(e){let n=0;for(let i=0;i<e.length;i++)n=e.charCodeAt(i)+((n<<5)-n);return`hsl(${(n%360+360)%360}, 50%, 40%)`}function C8({importJob:e,onImportDone:n}){var Ts,Jo,ec,tc,nc;const[a,i]=w.useState([]),[o,u]=w.useState([]),[d,h]=w.useState([]),[m,f]=w.useState([]),[x,y]=w.useState([]),[v,b]=w.useState([]),[j,k]=w.useState("TYCONO"),[N,S]=w.useState(!0),[E,_]=w.useState(null),[R,I]=w.useState({type:"none"}),[B,$]=w.useState(null),[q,G]=w.useState(null),[T,H]=w.useState([]),[L,J]=w.useState(!1),[ce,re]=w.useState(!1),[X,le]=w.useState([]),[ee,Z]=w.useState([]),[D,F]=w.useState(0),[W,A]=w.useState(!1),[Q,ie]=w.useState({}),[he,Ne]=w.useState("ceo"),[Ie,de]=w.useState(null),[_e,Ye]=w.useState(!1),[ge,Je]=w.useState(!1),[Fe,ct]=w.useState({}),Ke=w.useRef({}),[ot,xt]=w.useState(!1),[wt,bt]=w.useState(null),[dt,gn]=w.useState({}),[ft,Wt]=w.useState([]),we=w.useMemo(()=>{const M={};for(const K of ft)M[K.roleId]=K;return M},[ft]),[U,ae]=w.useState([]),[me,Ce]=w.useState(0),[De,Se]=w.useState(Wy()),Be=w.useRef(Wy()),$e=w.useRef(!1),Re=w.useRef(-1),[ze,Oe]=w.useState(null),kt=w.useRef(null),[Me,Le]=w.useState(void 0),[Vt,Jt]=w.useState(!1);w.useEffect(()=>{ye.getStatus().then(M=>{Le(M.engine),Jt(!!M.hasApiKey)}).catch(()=>{})},[]);const{getAppearance:jt,setAppearance:Bt,resetAppearance:bn,theme:P,setTheme:qe,speechSettings:et,setSpeechSettings:St,language:ve,setLanguage:yt}=C6(),[sn,en]=w.useState(null),[,Mr]=w.useState("character"),vt=A6(),[Jn,tl]=w.useState(!1),[qo,yr]=w.useState(!1),[Fn,Ln]=w.useState(!1),[oa,nl]=w.useState(!1),[Ju,Ss]=w.useState(!1),[Yo,Da]=w.useState(!1),[Ci,ca]=w.useState(!1),[Hn,Hl]=w.useState(null);w.useEffect(()=>{vt.refresh()},[]),w.useEffect(()=>{const M=K=>{(K.metaKey||K.ctrlKey)&&K.key==="s"&&(K.preventDefault(),tl(!0))};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[]),w.useEffect(()=>{if(!oa)return;let M=!1;const K=async()=>{try{const xe=await ye.getGitStatus();M||Hl(xe)}catch{}};K();const ne=setInterval(K,1e4);return()=>{M=!0,clearInterval(ne)}},[oa]);const[gr,pn]=w.useState(null),[Ta,Fa]=w.useState(null),[lr,Ma]=w.useState([]),[rl,Cs]=w.useState(!1),Ns=w.useRef(!1),Es=w.useRef(null);let Ul=w.useRef(0);const ql=w.useRef(new Set),Gr=w.useRef(Date.now()),jn=(M,K,ne)=>{const xe={id:Ul.current++,type:M,text:K,detail:ne};Ma(je=>[...je,xe])};w.useEffect(()=>{var M;rl&&((M=Es.current)==null||M.scrollIntoView({behavior:"smooth"}))},[lr,rl]),w.useEffect(()=>{e&&(Ns.current||(Ns.current=!0,Fa("Scanning knowledge sources..."),Ma([{id:0,type:"scan",text:"Starting knowledge import..."}]),Ul.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 K=(je=M.body)==null?void 0:je.getReader();if(!K)return;const ne=new TextDecoder;let xe="";for(;;){const{done:Xe,value:Ut}=await K.read();if(Xe)break;xe+=ne.decode(Ut,{stream:!0});const lt=xe.split(`
93
- `);xe=lt.pop()||"";let Pe="";for(const at of lt)if(at.startsWith("event: "))Pe=at.slice(7).trim();else if(at.startsWith("data: ")&&Pe){try{const it=JSON.parse(at.slice(6));switch(Pe){case"scanning":Fa(`Scanning: ${it.path} (${it.fileCount} files)`),jn("scan",`Found ${it.fileCount} files`,it.path);break;case"processing":pn({index:it.index,total:it.total}),Fa(`Importing knowledge... (${it.index}/${it.total})`),jn("process",`Processing: ${it.file}`,`${it.index} / ${it.total}`);break;case"created":jn("created",it.title,it.summary);break;case"skipped":jn("process",`Skipped: ${it.file}`,it.reason);break;case"done":Fa(null),pn(null),jn("done",`Import complete! ${it.created} created, ${it.skipped} skipped.`),Mt(`Knowledge import complete! ${it.created} documents imported.`,"#2E7D32"),n==null||n();break;case"error":Fa(null),pn(null),jn("error",it.message),Mt(`Import failed: ${it.message}`,"#B71C1C"),n==null||n();break}}catch{}Pe=""}}}).catch(M=>{Fa(null),jn("error",M.message),Mt(`Import error: ${M.message}`,"#B71C1C"),n==null||n()})))},[e]);const[vn,Kr]=w.useState("iso"),Qr=w.useRef("iso"),[Rr,Sn]=w.useState({type:"dashboard"}),[Xo,ir]=w.useState(typeof window<"u"?window.innerWidth:1200);w.useEffect(()=>{const M=()=>ir(window.innerWidth);return window.addEventListener("resize",M),()=>window.removeEventListener("resize",M)},[]);const Yl=Xo<1024,[er,ua]=w.useState(!1),[sr,Wo]=w.useState(560),[Mn,on]=w.useState([]),[da,Un]=w.useState(null),[Pr,Xl]=w.useState(null),{sendMessage:ed}=k6(),Ni=w.useRef(new Map);w.useEffect(()=>{Promise.all([ye.getCompany().then(M=>{k(M.name),i(M.roles)}),ye.getOrgTree().then(M=>{ie(M.nodes),Ne(M.root)}).catch(()=>{}),ye.getCostSummary().then(M=>Gl(Uh(M.byRole))).catch(()=>{})]).catch(M=>_(`Failed to load: ${M.message}`)).finally(()=>S(!1)),ye.getProjects().then(u).catch(()=>{}),ye.getStandups().then(h).catch(()=>{}),ye.getWaves().then(f).catch(()=>{}),ye.getDecisions().then(y).catch(()=>{}),ye.getKnowledge().then(b).catch(()=>{}),ye.getQuestProgress().then(M=>{const K=Vy(M);K.activeChapter!==M.activeChapter&&ye.saveQuestProgress(K).catch(()=>{}),Se(K),Be.current=K,$e.current=!0,ye.getCoins().then(ne=>{var xe;ne.totalEarned===0?ye.migrateCoins(((xe=K.completedQuests)==null?void 0:xe.length)??0).then(je=>Ce(je.balance)).catch(()=>{}):Ce(ne.balance)}).catch(()=>{})}).catch(()=>{$e.current=!0})},[]),w.useEffect(()=>{if(Re.current===-1){Re.current=o.length;return}o.length>Re.current&&zt({type:"project_created"}),Re.current=o.length},[o.length]);const Wl=w.useRef(!1);w.useEffect(()=>{if(!(!$e.current||a.length===0||Wl.current)){Wl.current=!0;for(const M of a)zt({type:"role_hired",condition:{roleId:M.id,roleCount:a.length}})}},[a.length]),w.useEffect(()=>{ye.getSessions().then(M=>{if(M.length>0){const K=M.map(xe=>({...xe,messages:[]}));on(K);const ne=K.find(xe=>xe.status==="active")??K[0];Un(ne.id),br()}}).catch(M=>{console.error("Failed to load sessions",M)})},[]),w.useEffect(()=>{const M=()=>{fetch("/api/exec/status").then(ne=>ne.json()).then(ne=>{gn(ne.statuses??{}),Wt(ne.activeExecutions??[])}).catch(()=>{})};M();const K=setInterval(M,3e3);return()=>clearInterval(K)},[]);const $n=w.useMemo(()=>{const M={...dt};if(Pr){const K=Mn.find(ne=>ne.id===Pr);K&&(M[K.roleId]="working")}return M},[dt,Pr,Mn]);w.useEffect(()=>{R.type==="role"?ye.getRole(R.roleId).then($).catch(console.error):$(null)},[R]);const Zr=()=>I({type:"none"}),hn=M=>{I(M),ua(!1),re(!1)},br=()=>{ua(!0),I({type:"none"}),re(!1)},Jr=()=>{re(!0),ua(!1),I({type:"none"})},Vo=async(M,K)=>{const ne=a.find(je=>je.id===M),xe=(q==null?void 0:q.mode)==="ask";G(null);try{const je=await ye.startJob({type:"assign",roleId:M,task:K,readOnly:xe}),Xe=je.jobId,Ut=je.sessionId??`job-${Xe}`,lt=gm[M]??"#666",Pe=`${M.toUpperCase()} · ${(ne==null?void 0:ne.name)??M}`;A(!1),H([{sessionId:Ut,jobId:Xe,title:Pe,color:lt}]),zt({type:"task_executed",condition:{roleId:M}}),Gt.pushMessage({ts:Date.now(),roleId:"ceo",text:`[CEO → ${(ne==null?void 0:ne.name)??M}] ${xe?"Ask":"Assign"}: ${K}`,type:"dispatch",targetRoleId:M})}catch(je){Mt(`Failed to start job: ${je instanceof Error?je.message:"unknown"}`,"#C62828")}},As=w.useRef(0),Mt=(M,K)=>{const ne=++As.current;ae(xe=>[...xe,{id:ne,message:M,color:K}]),setTimeout(()=>ae(xe=>xe.filter(je=>je.id!==ne)),4e3)},Vl=M=>{kt.current&&clearTimeout(kt.current),Oe(M),kt.current=setTimeout(()=>Oe(null),8e3)},zt=M=>{if(!$e.current)return;let K=Be.current;const ne=sv(K);let xe=0;const je=[];for(const Ut of ne){if(!DE(Ut,M))continue;const{progress:lt,quest:Pe}=EE(K,Ut.id);Pe&&(K=lt,xe+=Pe.rewards.coins??0,je.push(Pe.title))}if(je.length===0)return;K=Vy(K),Be.current=K,Se(K);const Xe=xe>0?` 💰 +${xe.toLocaleString()}`:"";je.length===1?Mt(`📋 Quest complete: ${je[0]}${Xe}`,"#7C3AED"):Mt(`📋 ${je.length} quests complete!${Xe}`,"#7C3AED"),Oe(null),ye.saveQuestProgress(K).catch(()=>{}),xe>0&&ye.earnCoins(xe,`quests: ${je.length}`,je.join(",")).then(Ut=>Ce(Ut.balance)).catch(()=>{})};w.useEffect(()=>{if(!ze)return;const M=document.querySelector(`[data-quest-target="${ze}"]`);if(!M)return;M.classList.add("quest-spotlight");const K=()=>{M.classList.remove("quest-spotlight"),Oe(null),kt.current&&clearTimeout(kt.current)};return M.addEventListener("click",K,{once:!0}),()=>{M.classList.remove("quest-spotlight"),M.removeEventListener("click",K)}},[ze]);const Gl=M=>{var ne,xe;const K=Ke.current;for(const[je,Xe]of Object.entries(M)){const Ut=((ne=K[je])==null?void 0:ne.level)??0;if(Ut>0&&Xe.level>Ut){const lt=((xe=a.find(Pe=>Pe.id===je))==null?void 0:xe.name)??je.toUpperCase();Mt(`${lt} leveled up to Lv.${Xe.level}!`,"#7C3AED")}}Ke.current=M,ct(M)};w.useEffect(()=>{const M={roles:Object.entries(Fe).map(([je,Xe])=>({id:je,level:Xe.level,totalTokens:Xe.totalTokens})),totalTokens:Object.values(Fe).reduce((je,Xe)=>je+Xe.totalTokens,0),roleCount:a.length,completedQuests:De.completedQuests},K=Sg(M),ne=new Set(K.map(je=>je.id));if(Date.now()-Gr.current>5e3){const je=ql.current;for(const Xe of K)je.has(Xe.id)||Mt(`${Xe.icon} Badge earned: ${Xe.name}!`,"#D4A017")}ql.current=ne},[Fe,a.length,De.completedQuests]);const ea=w.useMemo(()=>NE(De),[De]),fa=()=>{var K;const M=T[T.length-1];M&&(Mt(`${M.title} completed`,M.color),Gt.pushMessage({ts:Date.now(),roleId:((K=M.title.split(" · ")[0])==null?void 0:K.toLowerCase())??"unknown",text:`[${M.title}] Job completed`,type:"dispatch"})),ye.getStandups().then(h).catch(console.error),ye.getCompany().then(ne=>i(ne.roles)).catch(console.error),ye.getCostSummary().then(ne=>Gl(Uh(ne.byRole))).catch(()=>{})},Kl=async(M,K)=>{J(!1);try{const ne=await ye.startJob({type:"wave",directive:M,targetRoles:K});zt({type:"wave_dispatched"});const xe=ne.jobIds??(ne.jobId?[ne.jobId]:[]),je=he&&Q[he]?Q[he].children.map(qt=>a.find(ta=>ta.id===qt)).filter(qt=>!!qt):a.filter(qt=>qt.level==="c-level"),Xe=K?je.filter(qt=>K.includes(qt.id)):je,Ut=ne.waveId??`wave-${Date.now()}`,lt=ne.sessionIds??[],Pe=xe.map((qt,ta)=>{var zi,il;return{jobId:qt,roleId:((zi=Xe[ta])==null?void 0:zi.id)??`role-${ta}`,roleName:((il=Xe[ta])==null?void 0:il.name)??`C-Level ${ta+1}`,sessionId:lt[ta]??`wave-${qt}`}});Gt.pushMessage({ts:Date.now(),roleId:"ceo",text:`[CEO WAVE] "${M}" → ${Pe.map(qt=>qt.roleName).join(", ")}`,type:"dispatch"});const at={id:Ut,directive:M,rootJobs:Pe,startedAt:Date.now(),sessionIds:lt};le(qt=>[at,...qt]),Jr();const it=new Date().toISOString(),an=lt.length>0?Pe.map((qt,ta)=>({id:lt[ta]??`wave-${qt.jobId}`,roleId:qt.roleId,title:`WAVE: ${qt.roleName}`,mode:"do",source:"wave",jobId:qt.jobId,messages:[{id:`msg-wave-${qt.jobId}-ceo`,from:"ceo",content:M,type:"directive",status:"done",timestamp:it}],status:"active",createdAt:it,updatedAt:it})):Pe.map(qt=>({id:`wave-${qt.jobId}`,roleId:qt.roleId,title:`WAVE: ${qt.roleName}`,mode:"do",source:"wave",jobId:qt.jobId,messages:[{id:`msg-wave-${qt.jobId}-ceo`,from:"ceo",content:M,type:"directive",status:"done",timestamp:it}],status:"active",createdAt:it,updatedAt:it}));on(qt=>[...an,...qt]),an.length>0&&(Un(an[0].id),br())}catch(ne){Mt(`Failed to start wave: ${ne instanceof Error?ne.message:"unknown"}`,"#C62828")}},zr=()=>{ye.getWaves().then(f).catch(console.error),ye.getStandups().then(h).catch(console.error)},Ei=()=>{ye.getCompany().then(M=>i(M.roles)).catch(console.error),ye.getOrgTree().then(M=>{ie(M.nodes),Ne(M.root)}).catch(console.error),ye.getCostSummary().then(M=>Gl(Uh(M.byRole))).catch(()=>{})},Ai=async(M,K)=>{await ye.createRole(M),Bt(M.id,K),Ei(),Mt(`${M.name} hired!`,"#2E7D32"),zt({type:"role_hired",condition:{roleId:M.id,roleCount:a.length+1}})},Di=async M=>{var K;await ye.deleteRole(M),Ei(),on(ne=>ne.filter(xe=>xe.roleId!==M)),da&&((K=Mn.find(ne=>ne.id===da))==null?void 0:K.roleId)===M&&Un(null),bt(null),Mt(`${M.toUpperCase()} removed`,"#B71C1C")},Ti=async(M,K)=>{await ye.updateRole(M,K),Ei(),R.type==="role"&&R.roleId===M&&ye.getRole(M).then($).catch(console.error),K.name&&Mt(`${M.toUpperCase()} renamed to "${K.name}"`,"#1565C0"),K.persona!==void 0&&(Mt(`${M.toUpperCase()} persona updated`,"#2E7D32"),zt({type:"persona_updated"}))},Gn=M=>{br(),zt({type:"terminal_opened"})},ha=async M=>{try{const K=await ye.createSession(M,"talk");on(ne=>[K,...ne]),Un(K.id),br()}catch(K){console.error("Failed to create session",K),Mt(`Failed to create session: ${K instanceof Error?K.message:"API unreachable"}`,"#B71C1C")}},al=async M=>{try{const K=await ye.createSession(M,"talk");on(ne=>[K,...ne]),Un(K.id)}catch(K){console.error("Failed to create session",K),Mt(`Failed to create session: ${K instanceof Error?K.message:"API unreachable"}`,"#B71C1C")}},Ql=async M=>{const K=we[M],ne=(K==null?void 0:K.jobId)??(K==null?void 0:K.id);if(ne&&$n[M]==="working"){const je=a.find(at=>at.id===M),Xe=gm[M]??"#666",Ut=`${M.toUpperCase()} · ${(je==null?void 0:je.name)??M}`,lt=Mn.find(at=>at.roleId===M&&at.status==="active"),Pe=(lt==null?void 0:lt.id)??`job-${ne}`;H([{sessionId:Pe,jobId:ne,title:Ut,color:Xe}]),A(!1);return}const xe=Mn.find(je=>je.roleId===M);if(xe)Un(xe.id),Gt.setActiveChannelId(null);else try{const je=await ye.createSession(M,"talk");on(Xe=>[je,...Xe]),Un(je.id),Gt.setActiveChannelId(null)}catch(je){console.error("Failed to create session",je)}br()},Go=async M=>{const K=Mn.find(ne=>ne.id===M);if((K==null?void 0:K.source)==="wave"){if(K.jobId){const ne=Ni.current.get(K.jobId);ne&&(ne.abort(),Ni.current.delete(K.jobId))}on(ne=>{var je;const xe=ne.filter(Xe=>Xe.id!==M);return da===M&&Un(((je=xe[0])==null?void 0:je.id)??null),xe});return}try{await ye.deleteSession(M),on(ne=>{var je;const xe=ne.filter(Xe=>Xe.id!==M);return da===M&&Un(((je=xe[0])==null?void 0:je.id)??null),xe})}catch(ne){console.error("Failed to delete session",ne),Mt(`Failed to close session: ${ne instanceof Error?ne.message:"API error"}`,"#B71C1C")}},Fi=async()=>{try{const{ids:M}=await ye.deleteEmptySessions();if(M.length===0)return;on(K=>{var xe;const ne=K.filter(je=>!M.includes(je.id));return da&&M.includes(da)&&Un(((xe=ne[0])==null?void 0:xe.id)??null),ne}),Mt(`Cleared ${M.length} empty session${M.length!==1?"s":""}`,"#2E7D32")}catch(M){Mt(`Failed to clear empty sessions: ${M instanceof Error?M.message:"API error"}`,"#B71C1C")}},Mi=async()=>{if(!confirm("Close all sessions? This cannot be undone."))return;const M=Mn.filter(K=>K.source!=="wave").map(K=>K.id);for(const K of Mn)if(K.source==="wave"&&K.jobId){const ne=Ni.current.get(K.jobId);ne&&(ne.abort(),Ni.current.delete(K.jobId))}try{M.length>0&&await ye.deleteSessions(M),on([]),Un(null),Mt("All sessions closed","#2E7D32")}catch(K){Mt(`Failed to close sessions: ${K instanceof Error?K.message:"API error"}`,"#B71C1C")}},or=(M,K)=>{on(ne=>ne.map(xe=>{if(xe.id!==M)return xe;const je=[...xe.messages],Xe=je[je.length-1];if(Xe&&Xe.from==="role"&&Xe.status==="streaming"){const Ut=[...Xe.streamEvents??[],K];je[je.length-1]={...Xe,streamEvents:Ut}}return{...xe,messages:je}}))},_r=(M,K,ne,xe)=>{const je={id:`msg-${Date.now()}-ceo`,from:"ceo",content:K,type:ne==="do"?"directive":"conversation",status:"done",timestamp:new Date().toISOString(),attachments:xe},Xe={id:`msg-${Date.now()+1}-role`,from:"role",content:"",type:"conversation",status:"streaming",timestamp:new Date().toISOString(),streamEvents:[]};on(lt=>lt.map(Pe=>Pe.id===M?{...Pe,messages:[...Pe.messages,je,Xe],updatedAt:new Date().toISOString()}:Pe));const Ut=Mn.find(lt=>lt.id===M);ne==="talk"?zt({type:"talk_mode_used"}):ne==="do"&&(zt({type:"do_mode_used"}),Ut&&zt({type:"task_executed",condition:{roleId:Ut.roleId}})),Xl(M),ed(M,K,ne,{onThinking:lt=>{on(Pe=>Pe.map(at=>{if(at.id!==M)return at;const it=[...at.messages],an=it[it.length-1];return an&&an.from==="role"&&an.status==="streaming"&&(it[it.length-1]={...an,thinking:(an.thinking??"")+lt}),{...at,messages:it}})),or(M,{type:"thinking",timestamp:Date.now(),text:lt})},onText:lt=>{on(Pe=>Pe.map(at=>{if(at.id!==M)return at;const it=[...at.messages],an=it[it.length-1];return an&&an.from==="role"&&an.status==="streaming"&&(it[it.length-1]={...an,content:an.content+lt}),{...at,messages:it}}))},onToolUse:(lt,Pe)=>{or(M,{type:"tool",timestamp:Date.now(),toolName:lt,toolInput:Pe})},onDispatch:(lt,Pe)=>{or(M,{type:"dispatch",timestamp:Date.now(),roleId:lt,task:Pe})},onDispatchProgress:(lt,Pe,at)=>{var it;Pe==="tool"?or(M,{type:"dispatch:progress",timestamp:Date.now(),roleId:lt,progressType:"tool",toolName:at.name,toolInput:at.input}):Pe==="thinking"?or(M,{type:"dispatch:progress",timestamp:Date.now(),roleId:lt,progressType:"thinking",text:at.text}):Pe==="text"?or(M,{type:"dispatch:progress",timestamp:Date.now(),roleId:lt,progressType:"text",text:(it=at.text)==null?void 0:it.slice(-200)}):(Pe==="done"||Pe==="error")&&or(M,{type:"dispatch:progress",timestamp:Date.now(),roleId:lt,progressType:Pe})},onTurn:lt=>{or(M,{type:"turn",timestamp:Date.now(),turn:lt})},onDone:()=>{on(lt=>lt.map(Pe=>{if(Pe.id!==M)return Pe;const at=Pe.messages.map(an=>an.status==="streaming"?{...an,status:"done"}:an),it=Pe.messages.length<=2?K.slice(0,40).replace(/\n/g," "):Pe.title;return{...Pe,messages:at,title:it}})),Xl(null)},onError:lt=>{on(Pe=>Pe.map(at=>{if(at.id!==M)return at;const it=at.messages.map(an=>an.status==="streaming"?{...an,status:"error",content:an.content||lt}:an);return{...at,messages:it}})),Xl(null)}},xe)},Ri=(M,K)=>{on(ne=>ne.map(xe=>xe.id===M?{...xe,mode:K}:xe)),ye.updateSession(M,{mode:K}).catch(console.error)},td=new Date().toISOString().slice(0,10),ma=o[0],Ko={cto:"Chief Technology Officer",cbo:"Chief Business Officer",pm:"Product Manager",engineer:"Software Engineer",designer:"UI/UX Designer",qa:"QA Engineer"},Ds=M=>{const K=Ko[M];if(!K)return"";for(const ne of d){const xe=ne.content,je=xe.indexOf(`## ${K}`);if(je===-1)continue;const Xe=xe.indexOf(`
94
- ## `,je+10),lt=(Xe===-1?xe.slice(je):xe.slice(je,Xe)).split(`
95
- `).filter(Pe=>Pe.trim().length>0);for(const Pe of lt){const at=Pe.replace(/^#+\s*/,"").replace(/\*\*/g,"").replace(/^[-*]\s+/,"").trim();if(!(at.startsWith("|")||at.startsWith("{")||at.startsWith("[")||at.startsWith("```")||at.startsWith("---")||at.includes("Journal")||at.includes("(c-level)")||at.includes("(team-lead)")||at.includes("(member)")||/^(CEO |작업 결과|생성\/수정|APPROVAL|비고|상황 보고|태스크$)/.test(at))&&at.length>15&&at.length<120)return at}}return""},Qo=M=>{const K=Ko[M];if(!K)return"";for(const ne of d){const xe=ne.content,je=xe.indexOf(`## ${K}`);if(je===-1)continue;const Xe=xe.indexOf(`
96
- ## `,je+10),lt=(Xe===-1?xe.slice(je):xe.slice(je,Xe)).replace(/^## .+\n/,"").trim();if(lt)return lt.slice(0,1500)}return""},Gt=U6();w.useEffect(()=>{a.length>0&&Gt.syncDefaultMembers(a)},[a]);const ll=O6({roles:a,roleStatuses:dt,activeExecs:ft,getStandupSpeech:Ds}),Po=W6({roles:a,roleStatuses:dt,activeExecs:ft,channels:Gt.channels,relationships:ll.relationships,pushMessage:Gt.pushMessage,speechSettings:et,engineType:Me,hasApiKey:Vt}),Zo=w.useCallback((M,K)=>{Gt.pushMessage({ts:Date.now(),roleId:"ceo",text:K,type:"chat",channelId:M}),Po.triggerCeoReaction(M)},[Gt,Po]);return N?l.jsxs("div",{className:"h-screen flex flex-col bg-[var(--floor-light)]",style:{fontFamily:"var(--pixel-font)"},children:[(Ta||lr.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:()=>Cs(M=>!M),children:[Ta?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:Ta||"Knowledge import finished"}),gr&&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:`${gr.index/gr.total*100}%`,background:"#fff"}})}),l.jsx("span",{className:"text-[10px] opacity-70 shrink-0",children:rl?"▲":"▼"})]}),rl&&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:[lr.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:Es})]})]}),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..."})]})})]}):E?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:E}),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=me>=1e6?`${(me/1e6).toFixed(1)}M`:me>=1e3?`${(me/1e3).toFixed(1)}K`:String(me),K=ft.length,ne=a.length>0?Math.round(K/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:`${ne}%`,background:"linear-gradient(90deg,#3b82f6,#60A5FA)"}})}),l.jsx("strong",{style:{color:"var(--bar-text, var(--terminal-text))"},children:ne})]})]})})(),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})]}),ft.length>0&&l.jsxs("span",{className:"text-amber-400",children:["Working: ",l.jsx("strong",{children:ft.length})]}),(()=>{const M={roles:Object.entries(Fe).map(([ne,xe])=>({id:ne,level:xe.level,totalTokens:xe.totalTokens})),totalTokens:Object.values(Fe).reduce((ne,xe)=>ne+xe.totalTokens,0),roleCount:a.length},K=Sg(M);return K.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:K.map(ne=>l.jsx("span",{title:`${ne.name}: ${ne.description}`,style:{fontSize:12,cursor:"default"},children:ne.icon},ne.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:td})]})]}),(Ta||lr.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:()=>Cs(M=>!M),children:[Ta?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:Ta||"Knowledge import finished"}),gr&&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:`${gr.index/gr.total*100}%`,background:"#fff"}})}),l.jsx("span",{className:"text-[10px] opacity-70 shrink-0",children:rl?"▲":"▼"})]}),rl&&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:[lr.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:Es}),lr.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:vn==="iso"?l.jsx(t8,{roles:a,projects:o,waves:m,standups:d,decisions:x,roleStatuses:$n,activeExecs:ft,onRoleClick:M=>hn({type:"role",roleId:M}),onProjectClick:M=>hn({type:"project",projectId:M}),onBulletinClick:()=>{hn({type:"bulletin"}),zt({type:"bulletin_visited"})},onDecisionsClick:()=>hn({type:"decisions"}),onKnowledgeClick:()=>{hn({type:"knowledge"}),zt({type:"knowledge_visited"})},onSettingsClick:()=>{Da(!0),zt({type:"settings_visited"})},onThemeClick:()=>ca(M=>!M),onStatsClick:()=>{yr(!0),zt({type:"stats_visited"})},knowledgeDocsCount:v.length,getRoleSpeech:ll.getSpeech,getAppearance:jt,onHireClick:()=>xt(!0),onMascotClick:()=>hn({type:"quest"}),roleLevels:Fe,coinBalance:me,onCoinsSpent:M=>Ce(M),onFurniturePlaced:(M,K)=>{zt({type:"furniture_placed"}),K>0&&zt({type:"furniture_purchased"})}}):l.jsxs("div",{className:`${er?"max-w-full":"max-w-[1100px]"} mx-auto h-full p-4 flex flex-col gap-3 relative z-[1]`,children:[(()=>{const M=a.filter(ne=>ne.level==="c-level"),K=a.filter(ne=>ne.level!=="c-level");return l.jsxs(l.Fragment,{children:[M.length>0&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"pixel-section-label",children:"LEADERSHIP"}),l.jsx("div",{className:`grid gap-2 ${M.length===1?"grid-cols-1":"grid-cols-2"}`,children:M.map(ne=>{var xe,je;return l.jsx(Cg,{role:ne,speech:ll.getSpeech(ne.id),onClick:()=>hn({type:"role",roleId:ne.id}),liveStatus:$n[ne.id],activeTask:(xe=we[ne.id])==null?void 0:xe.task,featured:!0,appearance:jt(ne.id),xpLevel:(je=Fe[ne.id])==null?void 0:je.level},ne.id)})})]}),l.jsx("div",{className:"pixel-section-label",children:"TEAM"}),l.jsxs("div",{className:`grid gap-2 ${er?"grid-cols-3":"grid-cols-4"}`,children:[K.map(ne=>{var xe,je;return l.jsx(Cg,{role:ne,speech:ll.getSpeech(ne.id),onClick:()=>hn({type:"role",roleId:ne.id}),liveStatus:$n[ne.id],activeTask:(xe=we[ne.id])==null?void 0:xe.task,appearance:jt(ne.id),xpLevel:(je=Fe[ne.id])==null?void 0:je.level},ne.id)}),l.jsx("div",{className:"pixel-card pixel-card--hire",onClick:()=>xt(!0),children:l.jsxs("div",{className:"pixel-card--hire-inner",children:[l.jsx("span",{className:"pixel-card--hire-icon",children:"+"}),l.jsx("span",{className:"pixel-card--hire-label",children:"HIRE NEW ROLE"})]})})]})]})})(),l.jsx("div",{className:"pixel-section-label mt-1",children:"OFFICE"}),l.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[l.jsxs("div",{className:"facility-card-compact",onClick:ma?()=>hn({type:"project",projectId:ma.id}):void 0,style:ma?void 0:{borderStyle:"dashed",opacity:.5},children:[l.jsxs("div",{className:"fcc-hdr",style:{background:"#3B82F6"},children:["🏢"," MEETING ROOM"]}),l.jsx("div",{className:"fcc-canvas",children:l.jsx(yu,{type:"meeting"})}),l.jsxs("div",{className:"fcc-body",children:[l.jsx("div",{className:"fcc-desc",children:"Projects, PRDs, and task boards"}),ma?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"fcc-title",children:['"',ma.name,'"']}),l.jsxs("div",{className:"fcc-meta",children:["Status: ",l.jsx("strong",{style:{color:"var(--active-green)"},children:ma.status})]})]}):l.jsx("div",{className:"fcc-meta",style:{fontStyle:"italic"},children:"No active projects"})]})]}),l.jsxs("div",{className:"facility-card-compact",onClick:()=>hn({type:"bulletin"}),children:[l.jsxs("div",{className:"fcc-hdr",style:{background:"#64748b"},children:["📋"," BULLETIN"]}),l.jsx("div",{className:"fcc-canvas",children:l.jsx(yu,{type:"bulletin"})}),l.jsxs("div",{className:"fcc-body",children:[l.jsx("div",{className:"fcc-desc",children:"Waves and daily standups"}),m.slice(0,1).map(M=>l.jsxs("div",{className:"fcc-item",children:["Wave ",M.id]},M.id)),d.slice(0,1).map(M=>l.jsxs("div",{className:"fcc-item",children:["Standup ",M.date]},M.date)),m.length===0&&d.length===0&&l.jsx("div",{className:"fcc-meta",style:{fontStyle:"italic"},children:"No entries yet"})]})]}),l.jsxs("div",{className:"facility-card-compact",onClick:()=>hn({type:"decisions"}),children:[l.jsxs("div",{className:"fcc-hdr",style:{background:"#EF4444"},children:["📜"," DECISIONS"]}),l.jsx("div",{className:"fcc-canvas",children:l.jsx(yu,{type:"decision"})}),l.jsxs("div",{className:"fcc-body",children:[l.jsx("div",{className:"fcc-desc",children:"CEO strategic decision log"}),l.jsxs("div",{className:"fcc-title",children:[x.length," decisions"]}),x.slice(0,2).map(M=>l.jsxs("div",{className:"fcc-item",children:["#",M.id," ",M.title]},M.id))]})]}),l.jsxs("div",{className:"facility-card-compact",onClick:()=>hn({type:"knowledge"}),children:[l.jsxs("div",{className:"fcc-hdr",style:{background:"#0D9488"},children:["📚"," KNOWLEDGE"]}),l.jsx("div",{className:"fcc-canvas",children:l.jsx(yu,{type:"knowledge"})}),l.jsxs("div",{className:"fcc-body",children:[l.jsx("div",{className:"fcc-desc",children:"Research, analysis, and references"}),l.jsxs("div",{className:"fcc-title",children:[v.length," docs"]}),v.slice(0,2).map(M=>l.jsx("div",{className:"fcc-item",children:M.title},M.id))]})]})]})]})}),er&&l.jsx("div",{className:Yl?"absolute inset-0 z-50":"contents",children:l.jsx(Jy,{sessions:Mn,activeSessionId:da,roles:a,streamingSessionId:Pr,width:Yl?Xo:sr,onWidthChange:Yl?void 0:Wo,onSwitchSession:Un,onCloseSession:Go,onCreateSession:ha,onClearEmpty:Fi,onCloseAll:Mi,onSendMessage:_r,onModeChange:Ri,onCloseTerminal:()=>ua(!1),onMaximize:()=>{Qr.current=vn==="pro"?"iso":vn,Sn({type:"terminal"}),Kr("pro")},chatChannels:Gt.channels,activeChatChannelId:Gt.activeChannelId,onSwitchChatChannel:Gt.setActiveChannelId,onCreateChatChannel:(...M)=>{const K=Gt.createChannel(...M);return zt({type:"chat_channel_created"}),K},onDeleteChatChannel:Gt.deleteChannel,onUpdateChatMembers:Gt.updateMembers,onUpdateChatTopic:Gt.updateTopic,onSendChatMessage:Zo,unreadChannels:Gt.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:()=>Kr("card"),className:`view-toggle-btn ${vn==="card"?"active":""}`,children:"CARD"}),l.jsx("button",{onClick:()=>Kr("iso"),className:`view-toggle-btn ${vn==="iso"?"active":""}`,children:"OFFICE"}),l.jsx("button",{onClick:()=>{Qr.current=vn==="pro"?"iso":vn,Kr("pro")},className:`view-toggle-btn ${vn==="pro"?"active":""}`,children:"PRO"}),l.jsx("span",{className:"mx-1",children:"|"}),l.jsxs("div",{style:{position:"relative"},children:[l.jsxs("button",{className:`theme-btn${Ci?" active":""}`,"data-quest-target":"theme-btn",onClick:()=>ca(M=>!M),title:"Office Theme",children:[((Ts=Ja[P])==null?void 0:Ts.icon)??"","▾"]}),Ci&&l.jsx(p8,{theme:P,onThemeChange:M=>{qe(M),zt({type:"theme_changed"})},onClose:()=>ca(!1)})]}),l.jsx("button",{className:"theme-btn","data-quest-target":"settings-btn",onClick:()=>Da(!0),title:"Settings",children:"⚙"}),l.jsx("span",{className:"mx-1",children:"|"}),l.jsxs("button",{"data-quest-target":"save-btn",onClick:()=>{vt.state==="no-git"||vt.state==="dirty"?tl(!0):nl(!0)},title:vt.state==="dirty"?`${vt.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:vt.state==="no-git"?"var(--terminal-text-muted)":vt.state==="saving"||vt.state==="dirty"?"var(--idle-amber)":vt.state==="error"?"#EF5350":"var(--active-green)",animation:vt.state==="saving"?"pulse 1s infinite":void 0}}),l.jsx("span",{style:{color:vt.state==="dirty"?"var(--idle-amber)":"var(--bar-text, var(--terminal-text-muted))"},children:vt.state==="no-git"?"No git":vt.state==="saving"?"Saving...":vt.state==="dirty"?`${vt.dirtyCount} unsaved`:"Saved"}),Hn&&(Hn.worktrees.length>0||Hn.staleBranches.length>0)&&l.jsxs("span",{style:{color:Hn.worktrees.some(M=>M.status==="stale")?"#ff6b6b":Hn.worktrees.some(M=>M.status==="pending-merge")?"#FFB74D":"#4FC3F7"},children:["·"," ","📂"," ",Hn.worktrees.length," worktree",Hn.worktrees.length!==1?"s":"",Hn.staleBranches.length>0&&` · ⚠ ${Hn.staleBranches.length} branch${Hn.staleBranches.length!==1?"es":""}`]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[X.length>0&&!ce&&l.jsx("button",{onClick:()=>Jr(),className:`px-3 py-1 font-black text-white cursor-pointer ${ge?"":"animate-pulse"}`,style:{background:ge?"#2E7D32":"#B71C1C",border:`2px solid ${ge?"#1b5e2088":"#7f121288"}`,fontFamily:"var(--pixel-font)",borderRadius:4},children:ge?"WAVE DONE":`WAVE (${X.length})`}),Ie&&_e&&X.length===0&&l.jsx("button",{onClick:()=>Ye(!1),className:`px-3 py-1 font-black text-white cursor-pointer ${ge?"":"animate-pulse"}`,style:{background:ge?"#2E7D32":"#B71C1C",border:`2px solid ${ge?"#1b5e2088":"#7f121288"}`,fontFamily:"var(--pixel-font)",borderRadius:4},children:ge?"WAVE DONE":"WAVE"}),T.length>0&&W&&l.jsxs("button",{onClick:()=>A(!1),className:"px-3 py-1 font-black text-white cursor-pointer animate-pulse",style:{background:T[T.length-1].color,border:`2px solid ${T[T.length-1].color}88`,fontFamily:"var(--pixel-font)",borderRadius:4},children:[T[T.length-1].title.slice(0,20),T[T.length-1].title.length>20?"..":""]}),l.jsxs("button",{onClick:()=>Jr(),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:()=>er?ua(!1):Gn(),className:"px-3 py-1 font-black cursor-pointer","data-quest-target":"terminal-btn",style:{background:er?"var(--terminal-bg)":"var(--hud-bg-alt)",color:"var(--terminal-text)",border:`2px solid ${er?"var(--terminal-border-hover)":"var(--pixel-border)"}`,fontFamily:"var(--pixel-font)"},children:"TERMINAL"})]})]}),vn!=="pro"&&R.type==="role"&&B&&(()=>{var K,ne;const M=we[B.id];return l.jsx(Fy,{role:B,allRoles:a,recentActivity:Qo(B.id),onClose:Zr,onFireRole:(xe,je)=>{bt({roleId:xe,roleName:je}),Zr()},terminalWidth:er?sr:0,activeJobId:M==null?void 0:M.id,activeSessionId:(K=T.find(xe=>xe.jobId===(M==null?void 0:M.jobId)))==null?void 0:K.sessionId,activeTask:M==null?void 0:M.task,isWorking:$n[B.id]==="working",jobStartedAt:M==null?void 0:M.startedAt,onStopJob:xe=>{const je=T.find(Xe=>Xe.jobId===xe);je&&ye.abortSession(je.sessionId)},sessions:Mn,streamingSessionId:Pr,onCreateSessionSilent:al,onSendMessage:_r,onFocusTerminal:Ql,onCustomize:xe=>{const je=a.find(Xe=>Xe.id===xe);je&&(Mr("character"),en(je))},onUpdateRole:Ti,appearance:jt(B.id),relationships:ll.relationships,roleLevel:(ne=Fe[B.id])==null?void 0:ne.level,onMaximize:()=>{Qr.current=vn,Sn({type:"role",roleId:B.id}),Kr("pro")}})})(),vn!=="pro"&&R.type==="project"&&ma&&l.jsx(FE,{projectId:ma.id,onClose:Zr,terminalWidth:er?sr:0}),vn!=="pro"&&(R.type==="bulletin"||R.type==="decisions")&&l.jsx(Xy,{standups:d,waves:m,decisions:x,mode:R.type==="bulletin"?"bulletin":"decisions",onClose:Zr,onOpenWaveCenter:()=>Jr(),terminalWidth:er?sr:0,onMaximize:()=>{Qr.current=vn,Sn({type:"operations"}),Kr("pro")}}),vn!=="pro"&&R.type==="quest"&&l.jsx(TE,{progress:De,onClose:Zr,terminalWidth:er?sr:0,onQuestAction:M=>{var ne;Zr();const K=ys.find(xe=>xe.id===M);(ne=K==null?void 0:K.hint)!=null&&ne.target&&Vl(K.hint.target)}}),vn!=="pro"&&R.type==="knowledge"&&l.jsx(Yy,{docs:v,onClose:Zr,onRefresh:()=>ye.getKnowledge().then(b).catch(()=>{}),terminalWidth:er?sr:0,initialDocId:R.docId,onMaximize:()=>{Qr.current=vn,Sn({type:"knowledge"}),Kr("pro")}}),vn==="pro"&&l.jsxs(x8,{roles:a,roleStatuses:$n,activeExecs:ft,waves:m,knowledgeDocs:v,sessions:Mn,roleLevels:Fe,companyName:j,getAppearance:jt,waveCenterWaves:X,renderProfile:Rr.type==="role"&&B?M=>{var ne,xe;const K=we[B.id];return l.jsx(Fy,{role:B,allRoles:a,recentActivity:Qo(B.id),onClose:M,onFireRole:(je,Xe)=>{bt({roleId:je,roleName:Xe})},terminalWidth:0,activeJobId:K==null?void 0:K.id,activeSessionId:(ne=T.find(je=>je.jobId===(K==null?void 0:K.jobId)))==null?void 0:ne.sessionId,activeTask:K==null?void 0:K.task,isWorking:$n[B.id]==="working",jobStartedAt:K==null?void 0:K.startedAt,onStopJob:je=>{const Xe=T.find(Ut=>Ut.jobId===je);Xe&&ye.abortSession(Xe.sessionId)},sessions:Mn,streamingSessionId:Pr,onCreateSessionSilent:al,onSendMessage:_r,onFocusTerminal:()=>{},onCustomize:je=>{const Xe=a.find(Ut=>Ut.id===je);Xe&&(Mr("character"),en(Xe))},onUpdateRole:Ti,appearance:jt(B.id),relationships:ll.relationships,roleLevel:(xe=Fe[B.id])==null?void 0:xe.level})}:void 0,channel:Rr,onChannelChange:M=>{Sn(M),M.type==="role"?hn({type:"role",roleId:M.roleId}):M.type==="knowledge"?hn({type:"knowledge"}):M.type==="operations"?hn({type:"bulletin"}):M.type==="wave"?re(!0):M.type==="terminal"?ua(!0):(I({type:"none"}),re(!1))},onClose:()=>{Kr(Qr.current),I({type:"none"}),re(!1)},children:[Rr.type==="dashboard"&&l.jsx(b8,{roles:a,roleStatuses:$n,activeExecs:ft,waves:m,knowledgeDocs:v,roleLevels:Fe,getAppearance:jt,onRoleClick:M=>Sn({type:"role",roleId:M}),onWaveClick:()=>Sn({type:"wave"}),onKnowledgeClick:()=>Sn({type:"knowledge"})}),Rr.type==="terminal"&&l.jsx(Jy,{sessions:Mn,activeSessionId:da,roles:a,streamingSessionId:Pr,width:typeof window<"u"?window.innerWidth-240:1e3,onSwitchSession:Un,onCloseSession:Go,onCreateSession:ha,onClearEmpty:Fi,onCloseAll:Mi,onSendMessage:_r,onModeChange:Ri,onCloseTerminal:()=>Sn({type:"dashboard"}),chatChannels:Gt.channels,activeChatChannelId:Gt.activeChannelId,onSwitchChatChannel:Gt.setActiveChannelId,onCreateChatChannel:(...M)=>{const K=Gt.createChannel(...M);return zt({type:"chat_channel_created"}),K},onDeleteChatChannel:Gt.deleteChannel,onUpdateChatMembers:Gt.updateMembers,onUpdateChatTopic:Gt.updateTopic,onSendChatMessage:Zo,unreadChannels:Gt.unreadChannels}),Rr.type==="wave"&&l.jsx(Py,{orgNodes:Q,rootRoleId:he,cLevelRoles:he&&Q[he]?Q[he].children.map(M=>a.find(K=>K.id===M)).filter(M=>!!M):a.filter(M=>M.level==="c-level"),pastWaves:m,activeWaves:X,onDispatch:(M,K)=>Kl(M,K),onClose:()=>Sn({type:"dashboard"}),onDone:()=>{zr(),Je(!0),Mt("Wave complete","#2E7D32")},onSave:async(M,K,ne)=>{try{await ye.saveWave({directive:M,jobIds:K,waveId:ne==null?void 0:ne.waveId,sessionIds:ne==null?void 0:ne.sessionIds}),zr(),Mt("Wave saved","#2E7D32")}catch(xe){Mt(`Save failed: ${xe instanceof Error?xe.message:"unknown"}`,"#C62828")}},onOpenKnowledgeDoc:M=>{Sn({type:"knowledge"}),hn({type:"knowledge",docId:M}),ye.getKnowledge().then(b).catch(()=>{})},onRefreshWaves:()=>ye.getWaves().then(f).catch(()=>{}),terminalWidth:0}),Rr.type==="knowledge"&&l.jsx(Yy,{docs:v,onClose:()=>Sn({type:"dashboard"}),onRefresh:()=>ye.getKnowledge().then(b).catch(()=>{}),terminalWidth:0}),Rr.type==="operations"&&l.jsx(Xy,{standups:d,waves:m,decisions:x,mode:"bulletin",onClose:()=>Sn({type:"dashboard"}),onOpenWaveCenter:()=>Sn({type:"wave"}),terminalWidth:0}),Rr.type==="role"&&(()=>{const M=Rr.roleId,K=a.find(xe=>xe.id===M);if(!K)return null;const ne=Mn.find(xe=>xe.roleId===M);return ne?l.jsx(y8,{role:K,messages:ne.messages,isStreaming:Pr===ne.id,mode:ne.mode,onModeChange:xe=>Ri(ne.id,xe),onSend:(xe,je,Xe)=>_r(ne.id,xe,je,Xe),isWave:ne.source==="wave"}):l.jsx(g8,{role:K,getAppearance:jt,onSend:(xe,je)=>{al(M),setTimeout(()=>{const Xe=Mn.find(Ut=>Ut.roleId===M);Xe&&_r(Xe.id,xe,je)},100)}})})()]}),q&&l.jsx(zE,{roleId:q.roleId,roleName:q.roleName,mode:q.mode,onClose:()=>G(null),onExecutionStart:Vo}),Ie&&!_e&&l.jsx(HE,{directive:Ie.directive,rootJobs:Ie.rootJobs,orgNodes:Q,rootRoleId:he,onClose:()=>{de(null),Ye(!1),Je(!1)},onMinimize:()=>Ye(!0),onDone:()=>{zr(),Je(!0),Mt("Wave complete","#2E7D32")},onSave:async M=>{try{await ye.saveWave({directive:Ie.directive,jobIds:M}),zr(),Mt("Wave saved to bulletin","#2E7D32")}catch(K){Mt(`Save failed: ${K instanceof Error?K.message:"unknown"}`,"#C62828")}},onOpenKnowledgeDoc:M=>{de(null),Ye(!1),Je(!1),hn({type:"knowledge",docId:M}),ye.getKnowledge().then(b).catch(()=>{})}}),ce&&l.jsx(Py,{orgNodes:Q,rootRoleId:he,cLevelRoles:he&&Q[he]?Q[he].children.map(M=>a.find(K=>K.id===M)).filter(M=>!!M):a.filter(M=>M.level==="c-level"),pastWaves:m,activeWaves:X,onDispatch:(M,K)=>Kl(M,K),onClose:()=>re(!1),onMaximize:()=>{Qr.current=vn,Sn({type:"wave"}),Kr("pro")},onDone:()=>{zr(),Je(!0),Mt("Wave complete","#2E7D32")},onSave:async(M,K,ne)=>{try{await ye.saveWave({directive:M,jobIds:K,waveId:ne==null?void 0:ne.waveId,sessionIds:ne==null?void 0:ne.sessionIds}),zr(),Mt("Wave saved","#2E7D32")}catch(xe){Mt(`Save failed: ${xe instanceof Error?xe.message:"unknown"}`,"#C62828")}},onOpenKnowledgeDoc:M=>{re(!1),hn({type:"knowledge",docId:M}),ye.getKnowledge().then(b).catch(()=>{})},onRefreshWaves:()=>ye.getWaves().then(f).catch(()=>{}),terminalWidth:er?sr:0}),T.length>0&&!W&&(()=>{var ne;const M=T[T.length-1],K=ee.length>1;return l.jsxs(l.Fragment,{children:[K&&T.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:ee.map((xe,je)=>l.jsx("button",{onClick:()=>{F(je),H([{sessionId:xe.sessionId,jobId:xe.jobId??"",title:`CEO WAVE · ${xe.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:xe.roleId.toUpperCase()},xe.sessionId))}),l.jsx(_E,{sessionId:M.sessionId,title:T.length>1?M.title:K?`CEO WAVE · ${((ne=ee[D])==null?void 0:ne.roleName)??""}`:M.title,color:M.color,variant:"modal",style:K&&T.length===1?{marginTop:28}:void 0,onClose:()=>{H([]),Z([]),F(0),A(!1)},onMinimize:()=>A(!0),onDone:()=>{fa(),zr()},onNavigateToJob:()=>{},onOpenKnowledgeDoc:xe=>{H([]),Z([]),F(0),A(!1),hn({type:"knowledge",docId:xe}),ye.getKnowledge().then(b).catch(()=>{})}},M.sessionId)]})})(),T.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:()=>H(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 ",(Jo=T[T.length-2])==null?void 0:Jo.title]})})}),L&&l.jsx(LE,{cLevelRoles:he&&Q[he]?Q[he].children.map(M=>a.find(K=>K.id===M)).filter(M=>!!M):a.filter(M=>M.level==="c-level"),orgNodes:Q,rootId:he,onClose:()=>J(!1),onDispatch:(M,K)=>Kl(M,K)}),ot&&l.jsx(JE,{existingRoles:a,onClose:()=>xt(!1),onHire:Ai,onStoreVisit:()=>zt({type:"store_visited"}),questHint:((ec=ea==null?void 0:ea.hint)==null?void 0:ec.target)==="hire-btn"?{message:ea.description,roleId:((tc=ea.trigger.condition)==null?void 0:tc.roleId)??void 0}:void 0}),wt&&l.jsx(n6,{roleId:wt.roleId,roleName:wt.roleName,onClose:()=>bt(null),onConfirm:Di}),sn&&l.jsx(n8,{role:sn,appearance:jt(sn.id),onSave:M=>{Bt(sn.id,M),zt({type:"accessory_changed"})},onReset:()=>bn(sn.id),onClose:()=>{en(null),Mr("character")},theme:P,onThemeChange:M=>{qe(M),zt({type:"theme_changed"})},onUpdateName:async(M,K)=>{await Ti(M,{name:K})},initialTab:"character",characterOnly:!0,speechSettings:et,onSpeechSettingsChange:St,language:ve,onLanguageChange:yt,roleLevel:(nc=Fe[sn.id])==null?void 0:nc.level}),Jn&&(()=>{const M=a.find(K=>K.id==="cto")??a.find(K=>K.level==="c-level")??a[0];return l.jsx(l8,{status:vt.status,history:vt.history,onClose:()=>tl(!1),onSave:async K=>{const ne=await vt.save(K);return ne!=null&&ne.ok&&zt({type:"save_committed"}),ne},onLoadHistory:vt.loadHistory,onRestore:vt.restore,saving:vt.state==="saving",repo:vt.repo,onRepoChange:vt.setRepo,syncInfo:vt.syncInfo,onPull:vt.pull,pulling:vt.pulling,onRefresh:vt.refresh,onInitGit:vt.initGit,delegateRoleName:(M==null?void 0:M.name)??(M==null?void 0:M.id),onDelegate:M?async K=>{tl(!1);try{const ne=await ye.createSession(M.id,"do");on(je=>[ne,...je]),Un(ne.id),br();const xe=`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.
97
-
98
- Changed files:
99
- ${K}`;_r(ne.id,xe,"do")}catch(ne){Mt(`Failed to delegate: ${ne instanceof Error?ne.message:"error"}`,"#B71C1C")}}:void 0})})(),qo&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>yr(!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(i8,{onClose:()=>yr(!1)})})}),Fn&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>Ln(!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(c8,{onClose:()=>Ln(!1),onSyncComplete:()=>{}})})}),Yo&&l.jsx(m8,{onClose:()=>Da(!1),speechSettings:et,onSpeechSettingsChange:St,language:ve,onLanguageChange:yt,onOpenSync:()=>Ln(!0),onOpenGitStatus:()=>nl(!0),onOpenSessions:()=>Ss(!0),onOpenStats:()=>yr(!0)}),oa&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>nl(!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(u8,{onClose:()=>nl(!1)})})}),Ju&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>Ss(!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(d8,{onClose:()=>Ss(!1)})})}),l.jsx("div",{className:"fixed top-16 right-4 z-[70] flex flex-col gap-2",children:U.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 Cg({role:e,speech:n,onClick:a,liveStatus:i,activeTask:o,featured:u,appearance:d,xpLevel:h}){const m=gm[e.id]??S8(e.id),f=h??1,x=j8[e.id]??e.name,y=i==="working",v=y&&o?o:n||x;return l.jsxs("div",{className:`pixel-card ${y?"working":""} ${u?"pixel-card--featured":""}`,onClick:a,children:[l.jsxs("div",{className:"pixel-card-hdr",style:{background:m},children:[l.jsxs("span",{children:[e.id.toUpperCase()," ","·"," ",e.name.toUpperCase()]}),l.jsxs("span",{className:"lvl",children:["Lv.",f]})]}),l.jsxs("div",{className:"pixel-card-body",children:[l.jsx("div",{className:"pixel-desk"}),l.jsx(Pa,{roleId:e.id,appearance:d}),l.jsx("div",{className:"pixel-status-dot",style:{background:y?"var(--idle-amber)":"var(--active-green)"}})]}),l.jsxs("div",{className:"pixel-card-task",children:[l.jsx("span",{className:"pixel-card-task-icon",children:y?"🛠️":k8[e.id]??"👤"}),l.jsx("span",{className:"pixel-card-task-text",children:v||x})]})]})}function Cu({onSelect:e,onClose:n}){const[a,i]=w.useState(null),[o,u]=w.useState(!0),[d,h]=w.useState(""),[m,f]=w.useState(!1),[x,y]=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())){y(!0);try{const k=await ye.mkdir(a.current,d.trim());k.ok&&(h(""),f(!1),await b(k.path))}catch{}finally{y(!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:()=>{f(!m),h("")},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=>h(k.target.value),onKeyDown:k=>{k.key==="Enter"&&j(),k.key==="Escape"&&f(!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 N8={engine:"AI Engine",company:"Company",workspace:"Workspace",team:"Team",create:"Create"};function Ng(e){return e==="existing-akb"?["engine","workspace","create"]:["engine","company","workspace","team","create"]}function E8({onComplete:e}){const[n,a]=w.useState(0),[i,o]=w.useState(null),[u,d]=w.useState("none"),[h,m]=w.useState(""),[f,x]=w.useState(!0),[y,v]=w.useState(""),[b,j]=w.useState(""),[k,N]=w.useState("en"),S=w.useRef(null),[E,_]=w.useState("new"),[R,I]=w.useState(""),[B,$]=w.useState(""),[q,G]=w.useState(!1),[T,H]=w.useState(!1),[L,J]=w.useState(!1),[ce,re]=w.useState(""),[X,le]=w.useState(!1),[ee,Z]=w.useState(!1),[D,F]=w.useState([]),[W,A]=w.useState(""),[Q,ie]=w.useState(!1),[he,Ne]=w.useState(""),[Ie,de]=w.useState(null),[_e,Ye]=w.useState(!1),[ge,Je]=w.useState(!1),[Fe,ct]=w.useState([]),[Ke,ot]=w.useState("startup"),[xt,wt]=w.useState(!1),[bt,dt]=w.useState(!1),[gn,ft]=w.useState(null),[Wt,we]=w.useState([]),[U,ae]=w.useState(""),[me,Ce]=w.useState(!1),[De,Se]=w.useState(!1),[Be,$e]=w.useState([]),Re=w.useMemo(()=>Ng(E),[E]),ze=Re[n]??"engine";w.useEffect(()=>{ye.detectEngine().then(ve=>{o(ve),d(ve.recommended),x(!1)}).catch(()=>x(!1)),ye.getTeams().then(ct).catch(()=>{}),ye.getStatus().then(ve=>{$(ve.companyRoot||"")}).catch(()=>{})},[]),w.useEffect(()=>{var ve;ze==="company"&&((ve=S.current)==null||ve.focus())},[ze]),w.useEffect(()=>{if(q||!B)return;const ve=y.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");I(ve?`${B}/${ve}`:B)},[y,B,q]);const Oe=()=>{switch(ze){case"engine":return u!=="none"||h.length>10;case"company":return y.trim().length>0;case"workspace":return E==="existing-akb"?Ie===!0:!0;case"team":return!0;case"create":return!bt;default:return!1}},kt=()=>{n<Re.length-1&&Oe()&&a(n+1),ze==="create"&&!xt&&!me&&(E==="existing-akb"?bn():Bt())},Me=()=>{n>0&&a(n-1)},Le=w.useRef(E);w.useEffect(()=>{if(Le.current===E)return;Le.current=E;const yt=Ng(E).indexOf("workspace");yt>=0&&a(yt)},[E]);const Vt=async()=>{if(he.trim()){Ye(!0);try{const ve=await ye.validatePath(he.trim());de(ve.valid&&ve.hasClaudeMd===!0)}catch{de(!1)}finally{Ye(!1)}}},Jt=()=>{const ve=W.trim();ve&&!D.includes(ve)&&(F([...D,ve]),A(""))},jt=async ve=>{Se(!0),$e([]);try{const{tools:yt}=await ye.getRequiredTools(ve);if(yt.filter(en=>!en.installed).length===0){Se(!1);return}await ye.installTools(ve,(en,Mr)=>{const vt=Mr.tool||"";en==="checking"?$e(Jn=>[...Jn,{event:en,tool:vt,detail:"checking..."}]):en==="installing"?$e(Jn=>[...Jn,{event:en,tool:vt,detail:"installing..."}]):en==="installed"?$e(Jn=>[...Jn,{event:en,tool:vt,detail:"installed"}]):en==="skipped"?$e(Jn=>[...Jn,{event:en,tool:vt,detail:Mr.reason||"skipped"}]):en==="error"&&$e(Jn=>[...Jn,{event:en,tool:vt,detail:Mr.error||"failed"}])})}catch{}finally{Se(!1)}},Bt=async()=>{wt(!0),ft(null);try{const ve={companyName:y.trim(),description:b.trim()||"An AI-powered organization",team:Ke,knowledgePaths:D.length>0?D:void 0,language:k!=="auto"?k:void 0,location:R.trim()||void 0,codeRoot:ce.trim()||void 0};(u==="direct-api"||h)&&(ve.apiKey=h||void 0);const yt=await ye.scaffold(ve);we(yt.created),ae(yt.projectRoot),dt(!0),wt(!1),Ke!=="custom"&&jt(Ke)}catch(ve){ft(ve instanceof Error?ve.message:"Scaffold failed"),wt(!1)}},bn=async()=>{Ce(!0),ft(null);try{const ve=await ye.connectAkb(he.trim());ve.ok?(dt(!0),we([`Connected to: ${ve.companyRoot}`])):ft(ve.error||"Failed to connect")}catch(ve){ft(ve instanceof Error?ve.message:"Connect failed")}finally{Ce(!1)}},P=()=>{D.length>0?e({paths:D,companyRoot:""}):e()},qe=ve=>{ve.key==="Enter"&&Oe()&&(ve.preventDefault(),kt())},et=`w-full px-3 py-2 rounded text-sm outline-none transition-colors
100
- bg-[var(--terminal-bg)] text-[var(--terminal-text)]
101
- border border-[var(--terminal-border)]
102
- focus:border-[var(--terminal-border-hover)]
103
- placeholder:text-[var(--terminal-text-muted)]`,St=ve=>`p-4 rounded-lg border-2 cursor-pointer transition-all text-[var(--terminal-text)] ${ve?"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:qe,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:Re.map((ve,yt)=>l.jsxs("div",{className:"flex-1",children:[l.jsx("div",{className:"h-1 rounded-full transition-colors",style:{background:yt<=n?"var(--accent)":"var(--terminal-surface-light)"}}),l.jsx("div",{className:"text-[9px] mt-1 truncate",style:{color:yt===n?"var(--terminal-text)":"var(--terminal-text-muted)"},children:N8[ve]})]},ve))})]}),l.jsxs("div",{className:"px-6 py-5 min-h-[280px] max-h-[480px] overflow-y-auto",children:[ze==="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"}),f?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:St(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:St(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:`${et} mt-3`,placeholder:"sk-ant-...",value:h,onChange:ve=>m(ve.target.value),autoFocus:!0})]})]})]}),ze==="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:S,className:et,placeholder:"e.g. Acme Corp",value:y,onChange:ve=>v(ve.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:`${et} resize-none`,rows:3,placeholder:"What does your AI company do?",value:b,onChange:ve=>j(ve.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:et,value:k,onChange:ve=>N(ve.target.value),children:[l.jsx("option",{value:"en",children:"English"}),l.jsx("option",{value:"ko",children:"한국어"}),l.jsx("option",{value:"ja",children:"日本語"})]})]})]}),ze==="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(Jm,{text:`"New Company" creates a fresh workspace with roles, knowledge base, and project structure.
104
-
105
- "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:E==="new"?"var(--accent)":"var(--hud-bg-alt)",color:E==="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:E==="existing-akb"?"var(--accent)":"var(--hud-bg-alt)",color:E==="existing-akb"?"#fff":"var(--terminal-text-muted)",borderLeft:"1px solid var(--terminal-border)"},onClick:()=>_("existing-akb"),children:"Connect Existing"})]}),E==="new"?l.jsxs("div",{className:"space-y-3",children:[l.jsxs(Eg,{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:`${et} flex-1`,placeholder:"/path/to/your-company",value:R,onChange:ve=>{I(ve.target.value),G(!0)}}),l.jsx("button",{onClick:()=>H(!T),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:"📁"})]}),T&&l.jsx(Cu,{onSelect:ve=>{I(ve),G(!0),H(!1)},onClose:()=>H(!1)})]}),l.jsxs(Ag,{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.
106
-
107
- Skip this if you don't have a codebase yet — you can connect one later from Settings.`,tag:"optional",open:L,onToggle:()=>J(!L),children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{className:`${et} flex-1`,placeholder:"/path/to/code/repo",value:ce,onChange:ve=>re(ve.target.value)}),l.jsx("button",{onClick:()=>le(!X),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:"📁"})]}),X&&l.jsx(Cu,{onSelect:ve=>{re(ve),le(!1)},onClose:()=>le(!1)})]}),l.jsxs(Ag,{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.
108
-
109
- Skip this to start with an empty knowledge base. You can import documents anytime from the office.`,tag:"optional",open:ee,onToggle:()=>Z(!ee),children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{className:`${et} flex-1`,placeholder:"/path/to/docs",value:W,onChange:ve=>A(ve.target.value),onKeyDown:ve=>{ve.key==="Enter"&&(ve.preventDefault(),Jt())}}),l.jsx("button",{onClick:()=>ie(!Q),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:Jt,disabled:!W.trim(),className:"px-3 py-2 rounded text-xs font-medium shrink-0",style:{background:"var(--accent)",color:"#fff",opacity:W.trim()?1:.5},children:"Add"})]}),Q&&l.jsx(Cu,{onSelect:ve=>{D.includes(ve)||F([...D,ve]),ie(!1)},onClose:()=>ie(!1)}),D.length>0&&l.jsx("div",{className:"space-y-1 mt-2",children:D.map((ve,yt)=>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:ve}),l.jsx("button",{onClick:()=>F(D.filter((sn,en)=>en!==yt)),className:"opacity-50 hover:opacity-100",children:"✕"})]},yt))})]})]}):l.jsx("div",{className:"space-y-3",children:l.jsxs(Eg,{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:`${et} flex-1`,placeholder:"/path/to/your/akb",value:he,onChange:ve=>{Ne(ve.target.value),de(null)},autoFocus:!0}),l.jsx("button",{onClick:()=>Je(!ge),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:Vt,disabled:_e||!he.trim(),className:"px-3 py-2 rounded text-xs font-medium transition-colors shrink-0",style:{background:"var(--accent)",color:"#fff",opacity:_e||!he.trim()?.5:1},children:_e?"...":"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)"]}),ge&&l.jsx(Cu,{onSelect:ve=>{Ne(ve),de(null),Je(!1)},onClose:()=>Je(!1)})]})})]}),ze==="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."}),Fe.map(ve=>l.jsxs("div",{className:St(Ke===ve.id),onClick:()=>ot(ve.id),children:[l.jsx("div",{className:"font-medium text-sm capitalize",children:ve.id}),l.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:ve.roles.map(yt=>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:yt.name},yt.id))})]},ve.id)),l.jsxs("div",{className:St(Ke==="custom"),onClick:()=>ot("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."})]})]}),ze==="create"&&l.jsxs("div",{className:"space-y-4",children:[l.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:bt?E==="existing-akb"?"AKB Connected!":"Company Created!":"Review & Create"}),!bt&&!xt&&!me&&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:E==="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:"})," ",he]}),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:"})," ",y]}),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"]}),ce.trim()&&l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Code Repo:"})," ",ce]}),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:"})," ",Ke]}),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."})]})}),gn&&l.jsx("div",{className:"text-xs p-3 rounded",style:{background:"rgba(220,38,38,0.15)",color:"#f87171"},children:gn})]}),(xt||me)&&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:me?"Connecting to AKB...":"Scaffolding your company..."})]}),bt&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"text-center py-4 text-4xl",children:"🏢"}),U&&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:"})," ",U]}),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:Wt.map((ve,yt)=>l.jsxs("div",{className:"py-0.5",children:[l.jsx("span",{style:{color:"var(--active-green)"},children:"✓"})," ",ve]},yt))}),(De||Be.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:De?"Installing skill tools...":"Skill tools"}),Be.map((ve,yt)=>l.jsxs("div",{className:"py-0.5 flex items-center gap-2",children:[l.jsx("span",{style:{color:ve.event==="installed"||ve.event==="skipped"?"var(--active-green)":ve.event==="error"?"#f87171":"var(--terminal-text-muted)"},children:ve.event==="installed"||ve.event==="skipped"?"✓":ve.event==="error"?"✗":"…"}),l.jsx("span",{children:ve.tool}),l.jsx("span",{style:{color:"var(--terminal-text-muted)"},children:ve.detail})]},yt)),De&&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&&!bt&&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," / ",Re.length]}),l.jsx("div",{children:bt?l.jsx("button",{onClick:P,disabled:De,className:"px-5 py-2 rounded text-sm font-medium transition-colors",style:{background:"var(--active-green)",color:"#fff",opacity:De?.5:1},children:De?"Setting up tools...":"Enter Office"}):l.jsx("button",{onClick:kt,disabled:!Oe()||xt||me,className:"px-5 py-2 rounded text-sm font-medium transition-colors",style:{background:Oe()?"var(--accent)":"var(--terminal-border)",color:"#fff",opacity:Oe()&&!xt&&!me?1:.5},children:ze==="create"?xt||me?me?"Connecting...":"Creating...":E==="existing-akb"?"Connect AKB":"Create Company":"Next"})})]})]})})}function Jm({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 h=u.current.getBoundingClientRect();o({top:h.bottom+6,left:h.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:h=>{h.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 Eg({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(Jm,{text:i})]}),l.jsx("div",{className:"text-[10px] mt-0.5 ml-6",style:{color:"var(--terminal-text-muted)"},children:a})]}),o]})}function Ag({icon:e,title:n,hint:a,help:i,tag:o,open:u,onToggle:d,children:h}){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(Jm,{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:h})]})}function A8(){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 h=await ye.getStatus();n(h)}catch(h){u(h instanceof Error?h.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 D8=w.lazy(()=>Tg(()=>import("./preview-app-DeGAcwV0.js"),[]));function _v(){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 T8(){var e;try{const n=localStorage.getItem("tycono-theme"),a=n&&n in Ja?n:"default",i=(e=Ja[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 F8(){const{initialized:e,loading:n,refetch:a}=A8(),[i,o]=w.useState(null);w.useEffect(()=>{T8()},[]);const u=d=>{d&&o(d),a()};return n?l.jsx(_v,{}):e?l.jsx(C8,{importJob:i,onImportDone:()=>o(null)}):l.jsx(E8,{onComplete:u})}function M8(){const e=new URLSearchParams(window.location.search).has("sprite-preview");return l.jsx(Ew,{children:e?l.jsx(w.Suspense,{fallback:l.jsx(_v,{}),children:l.jsx(D8,{})}):l.jsx(F8,{})})}Sw.createRoot(document.getElementById("root")).render(l.jsx(w.StrictMode,{children:l.jsx(M8,{})}));export{fv as H,mv as P,pv as S,_8 as a,hv as b,dv as c,nm as d,lC as e,aC as f,z8 as g,iC as h,l as j,w as r};