tide-commander 1.40.2 → 1.40.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/assets/{BossLogsModal-CaDrNfm1.js → BossLogsModal-CehuxNwV.js} +1 -1
  2. package/dist/assets/{BossSpawnModal-DLJInoVf.js → BossSpawnModal-Cohl0WaH.js} +1 -1
  3. package/dist/assets/{ControlsModal-Cnnhwfr_.js → ControlsModal-CAVkg9mM.js} +1 -1
  4. package/dist/assets/{DockerLogsModal-D4CbWK3-.js → DockerLogsModal-BXv9Hzg-.js} +1 -1
  5. package/dist/assets/{EmbeddedEditor-36YBGNE2.js → EmbeddedEditor-CTlTVKdD.js} +1 -1
  6. package/dist/assets/{GmailOAuthSetup-DI5j7wkF.js → GmailOAuthSetup-B1zQWbRR.js} +1 -1
  7. package/dist/assets/{GoogleOAuthSetup-Bsj02mND.js → GoogleOAuthSetup-CmayoZ-D.js} +1 -1
  8. package/dist/assets/{IframeModal-BJ4oeDBn.js → IframeModal-DlS7y7PK.js} +1 -1
  9. package/dist/assets/{IntegrationsPanel-DLmIJEUy.js → IntegrationsPanel-BPKoNwZm.js} +2 -2
  10. package/dist/assets/{LogViewerModal-D7CXMmZf.js → LogViewerModal-Bx9IDiFM.js} +1 -1
  11. package/dist/assets/{MonitoringModal-PnEKvezF.js → MonitoringModal-DzqEa0fQ.js} +1 -1
  12. package/dist/assets/{PM2LogsModal-EB_Au0iK.js → PM2LogsModal-DZXPRV5-.js} +1 -1
  13. package/dist/assets/{RestoreArchivedAreaModal-C-X90Qxe.js → RestoreArchivedAreaModal-BajWqtWn.js} +1 -1
  14. package/dist/assets/{SaveSnapshotModal-D6XAjL2T.js → SaveSnapshotModal-LqaLezB-.js} +1 -1
  15. package/dist/assets/{Scene2DCanvas-DlVguRVM.js → Scene2DCanvas-DWDmyh_y.js} +1 -1
  16. package/dist/assets/{SceneManager-OOaJ_z8v.js → SceneManager-BgkqWsDb.js} +1 -1
  17. package/dist/assets/{SkillsPanel-D5wo2MHh.js → SkillsPanel-CO-Zt0Tq.js} +1 -1
  18. package/dist/assets/{SnapshotManager-BLjpctX_.js → SnapshotManager-D4Uzw6Tp.js} +1 -1
  19. package/dist/assets/{SpawnModal-DQ4uUm1y.js → SpawnModal-BdCgTKpM.js} +1 -1
  20. package/dist/assets/{SubordinateAssignmentModal-BDUDt6WC.js → SubordinateAssignmentModal-BoaofULj.js} +1 -1
  21. package/dist/assets/{SupervisorPanel-BZaBI9BA.js → SupervisorPanel-D8Cp77my.js} +1 -1
  22. package/dist/assets/{TriggerManagerPanel-DuBiclsE.js → TriggerManagerPanel-CFf3Tud5.js} +1 -1
  23. package/dist/assets/{WorkflowEditorPanel-D49yDqth.js → WorkflowEditorPanel-EtzhBZWw.js} +1 -1
  24. package/dist/assets/{index-DZ3f9mNd.js → index-2YWd58Wh.js} +1 -1
  25. package/dist/assets/{index-DJdXbeWz.js → index-BKRKKMPQ.js} +3 -3
  26. package/dist/assets/{index-BwkNteiZ.js → index-BgTRovwT.js} +1 -1
  27. package/dist/assets/{index-mQmnkGdF.js → index-BiJ_hIit.js} +1 -1
  28. package/dist/assets/{index-Bxjd0N-j.js → index-CDAtstMx.js} +1 -1
  29. package/dist/assets/{index-BxbFh16W.js → index-DBpmD8r7.js} +2 -2
  30. package/dist/assets/{index-BiGvhrCO.js → index-DByGRjfY.js} +1 -1
  31. package/dist/assets/index-VO6fNr63.js +1 -0
  32. package/dist/assets/main-BFSqr5mR.css +1 -0
  33. package/dist/assets/main-BSyGZK2z.js +152 -0
  34. package/dist/assets/{web-DAqM9uoZ.js → web-1BwWjkKM.js} +1 -1
  35. package/dist/assets/{web-DQ10iSod.js → web-BXQj42md.js} +1 -1
  36. package/dist/index.html +2 -2
  37. package/dist/locales/en/config.json +1 -0
  38. package/dist/src/packages/server/claude/backend.js +9 -0
  39. package/dist/src/packages/server/claude/runner/process-lifecycle.js +79 -7
  40. package/dist/src/packages/server/claude/runner/recovery-store.js +73 -10
  41. package/dist/src/packages/server/claude/runner/restart-policy.js +9 -0
  42. package/dist/src/packages/server/claude/runner/stdout-pipeline.js +28 -4
  43. package/dist/src/packages/server/claude/runner/tmux-helper.js +264 -0
  44. package/dist/src/packages/server/claude/runner/watchdog.js +27 -0
  45. package/dist/src/packages/server/claude/runner.js +84 -9
  46. package/dist/src/packages/server/cli.js +17 -1
  47. package/dist/src/packages/server/data/builtin-skills/boss-instructions.js +2 -2
  48. package/dist/src/packages/server/data/index.js +6 -0
  49. package/dist/src/packages/server/opencode/backend.js +1 -0
  50. package/dist/src/packages/server/opencode/index.js +1 -0
  51. package/dist/src/packages/server/routes/agents.js +29 -1
  52. package/dist/src/packages/server/services/system-prompt-service.js +38 -0
  53. package/dist/src/packages/server/websocket/handlers/boss-response-handler.js +5 -1
  54. package/dist/src/packages/server/websocket/listeners/runtime-listeners.js +19 -1
  55. package/package.json +1 -1
  56. package/dist/assets/index-BSl18-4e.js +0 -1
  57. package/dist/assets/main-CUx2B9bn.css +0 -1
  58. package/dist/assets/main-DULfVodw.js +0 -152
@@ -1,152 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browser-ponyfill-DZOWXZ4K.js","assets/vendor-react--Eh9ivFN.js","assets/index-BxbFh16W.js","assets/modulepreload-polyfill-B5Qt9EMX.js","assets/vendor-three-Chj50gSY.js","assets/web-DAqM9uoZ.js","assets/SceneManager-OOaJ_z8v.js","assets/prism-cpp-CK2Ly5dS.js","assets/prism-java-CK6tws4L.js","assets/prism-csharp-ByDDDiWW.js","assets/prism-ruby-CQBUuZIF.js","assets/prism-php-Dt9698bA.js","assets/prism-scss-CeN16CFC.js","assets/prism-perl-UZfqnD51.js","assets/prism-haskell-Ce8aBmia.js","assets/prism-elixir-df27OMMQ.js","assets/xterm-6GBZ9nXN.css","assets/SpawnModal-DQ4uUm1y.js","assets/BossSpawnModal-DLJInoVf.js","assets/SubordinateAssignmentModal-BDUDt6WC.js","assets/index-BSl18-4e.js","assets/index-Bykeknjl.css","assets/index-mQmnkGdF.js","assets/index-BwkNteiZ.js","assets/index-DJdXbeWz.js","assets/SupervisorPanel-BZaBI9BA.js","assets/index-Bxjd0N-j.js","assets/ControlsModal-Cnnhwfr_.js","assets/SkillsPanel-D5wo2MHh.js","assets/SnapshotManager-BLjpctX_.js","assets/RestoreArchivedAreaModal-C-X90Qxe.js","assets/IntegrationsPanel-DLmIJEUy.js","assets/MonitoringModal-PnEKvezF.js","assets/WorkflowEditorPanel-D49yDqth.js","assets/TriggerManagerPanel-DuBiclsE.js","assets/index-DZ3f9mNd.js","assets/index-CprCD9du.css","assets/PM2LogsModal-EB_Au0iK.js","assets/LogViewerModal-D7CXMmZf.js","assets/DockerLogsModal-D4CbWK3-.js","assets/BossLogsModal-CaDrNfm1.js","assets/Scene2DCanvas-DlVguRVM.js","assets/Scene2DCanvas-DwXbvB-b.css","assets/index-BiGvhrCO.js","assets/index-BZyCMBzi.css","assets/IframeModal-BJ4oeDBn.js","assets/IframeModal-DJkCGwT6.css","assets/SaveSnapshotModal-D6XAjL2T.js"])))=>i.map(i=>d[i]);
2
- var _E=Object.defineProperty;var EE=(t,e,n)=>e in t?_E(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Xe=(t,e,n)=>EE(t,typeof e!="symbol"?e+"":e,n);import"./modulepreload-polyfill-B5Qt9EMX.js";import{r as Nx,g as Xu,a as tj,c as Z0}from"./vendor-react--Eh9ivFN.js";import{T as ME,a as Lb,b as nj,L as sj,c as Cu,F as up,M as cr,V as aj,C as Hr,d as lr,S as Br,e as DE,P as RE,D as Ib,f as dp,g as wo,I as OE,Q as rj,h as LE,O as ij,i as IE,j as PE,B as Au,k as BE,l as oj,N as FE,m as zE,n as $E,o as Pb,p as lj,R as Bb,q as UE,r as HE,s as WE,t as Jf,u as qE,v as Tx,w as cj,x as Fl,y as VE,z as uj,A as YE,E as Il,G as GE,H as KE,J as QE,K as XE,U as xg,W as dj,X as JE,Y as ZE,Z as eM,_ as tM,$ as nM,a0 as sM,a1 as fj,a2 as aM,a3 as ek,a4 as tk,a5 as nk,a6 as sk,a7 as Fb,a8 as rM,a9 as iM,aa as oM,ab as lM,ac as cM,ad as uM,ae as dM,af as fM,ag as pM,ah as hM,ai as mM,aj as gM}from"./vendor-three-Chj50gSY.js";function bM(t,e){for(var n=0;n<e.length;n++){const s=e[n];if(typeof s!="string"&&!Array.isArray(s)){for(const a in s)if(a!=="default"&&!(a in t)){const r=Object.getOwnPropertyDescriptor(s,a);r&&Object.defineProperty(t,a,r.get?r:{enumerable:!0,get:()=>s[a]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var yg={exports:{}},Jc={};/**
3
- * @license React
4
- * react-jsx-runtime.production.js
5
- *
6
- * Copyright (c) Meta Platforms, Inc. and affiliates.
7
- *
8
- * This source code is licensed under the MIT license found in the
9
- * LICENSE file in the root directory of this source tree.
10
- */var ak;function xM(){if(ak)return Jc;ak=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(s,a,r){var i=null;if(r!==void 0&&(i=""+r),a.key!==void 0&&(i=""+a.key),"key"in a){r={};for(var c in a)c!=="key"&&(r[c]=a[c])}else r=a;return a=r.ref,{$$typeof:t,type:s,key:i,ref:a!==void 0?a:null,props:r}}return Jc.Fragment=e,Jc.jsx=n,Jc.jsxs=n,Jc}var rk;function yM(){return rk||(rk=1,yg.exports=xM()),yg.exports}var o=yM(),x=Nx();const Se=Xu(x),pj=bM({__proto__:null,default:Se},[x]);var vg={exports:{}},Zc={},wg={exports:{}},kg={};/**
11
- * @license React
12
- * scheduler.production.js
13
- *
14
- * Copyright (c) Meta Platforms, Inc. and affiliates.
15
- *
16
- * This source code is licensed under the MIT license found in the
17
- * LICENSE file in the root directory of this source tree.
18
- */var ik;function vM(){return ik||(ik=1,(function(t){function e(F,H){var V=F.length;F.push(H);e:for(;0<V;){var G=V-1>>>1,B=F[G];if(0<a(B,H))F[G]=H,F[V]=B,V=G;else break e}}function n(F){return F.length===0?null:F[0]}function s(F){if(F.length===0)return null;var H=F[0],V=F.pop();if(V!==H){F[0]=V;e:for(var G=0,B=F.length,K=B>>>1;G<K;){var se=2*(G+1)-1,q=F[se],be=se+1,Ce=F[be];if(0>a(q,V))be<B&&0>a(Ce,q)?(F[G]=Ce,F[be]=V,G=be):(F[G]=q,F[se]=V,G=se);else if(be<B&&0>a(Ce,V))F[G]=Ce,F[be]=V,G=be;else break e}}return H}function a(F,H){var V=F.sortIndex-H.sortIndex;return V!==0?V:F.id-H.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var r=performance;t.unstable_now=function(){return r.now()}}else{var i=Date,c=i.now();t.unstable_now=function(){return i.now()-c}}var d=[],f=[],h=1,m=null,b=3,y=!1,w=!1,C=!1,N=!1,k=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;function T(F){for(var H=n(f);H!==null;){if(H.callback===null)s(f);else if(H.startTime<=F)s(f),H.sortIndex=H.expirationTime,e(d,H);else break;H=n(f)}}function D(F){if(C=!1,T(F),!w)if(n(d)!==null)w=!0,E||(E=!0,z());else{var H=n(f);H!==null&&L(D,H.startTime-F)}}var E=!1,I=-1,O=5,_=-1;function M(){return N?!0:!(t.unstable_now()-_<O)}function R(){if(N=!1,E){var F=t.unstable_now();_=F;var H=!0;try{e:{w=!1,C&&(C=!1,j(I),I=-1),y=!0;var V=b;try{t:{for(T(F),m=n(d);m!==null&&!(m.expirationTime>F&&M());){var G=m.callback;if(typeof G=="function"){m.callback=null,b=m.priorityLevel;var B=G(m.expirationTime<=F);if(F=t.unstable_now(),typeof B=="function"){m.callback=B,T(F),H=!0;break t}m===n(d)&&s(d),T(F)}else s(d);m=n(d)}if(m!==null)H=!0;else{var K=n(f);K!==null&&L(D,K.startTime-F),H=!1}}break e}finally{m=null,b=V,y=!1}H=void 0}}finally{H?z():E=!1}}}var z;if(typeof S=="function")z=function(){S(R)};else if(typeof MessageChannel<"u"){var $=new MessageChannel,W=$.port2;$.port1.onmessage=R,z=function(){W.postMessage(null)}}else z=function(){k(R,0)};function L(F,H){I=k(function(){F(t.unstable_now())},H)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(F){F.callback=null},t.unstable_forceFrameRate=function(F){0>F||125<F?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):O=0<F?Math.floor(1e3/F):5},t.unstable_getCurrentPriorityLevel=function(){return b},t.unstable_next=function(F){switch(b){case 1:case 2:case 3:var H=3;break;default:H=b}var V=b;b=H;try{return F()}finally{b=V}},t.unstable_requestPaint=function(){N=!0},t.unstable_runWithPriority=function(F,H){switch(F){case 1:case 2:case 3:case 4:case 5:break;default:F=3}var V=b;b=F;try{return H()}finally{b=V}},t.unstable_scheduleCallback=function(F,H,V){var G=t.unstable_now();switch(typeof V=="object"&&V!==null?(V=V.delay,V=typeof V=="number"&&0<V?G+V:G):V=G,F){case 1:var B=-1;break;case 2:B=250;break;case 5:B=1073741823;break;case 4:B=1e4;break;default:B=5e3}return B=V+B,F={id:h++,callback:H,priorityLevel:F,startTime:V,expirationTime:B,sortIndex:-1},V>G?(F.sortIndex=V,e(f,F),n(d)===null&&F===n(f)&&(C?(j(I),I=-1):C=!0,L(D,V-G))):(F.sortIndex=B,e(d,F),w||y||(w=!0,E||(E=!0,z()))),F},t.unstable_shouldYield=M,t.unstable_wrapCallback=function(F){var H=b;return function(){var V=b;b=H;try{return F.apply(this,arguments)}finally{b=V}}}})(kg)),kg}var ok;function wM(){return ok||(ok=1,wg.exports=vM()),wg.exports}/**
19
- * @license React
20
- * react-dom-client.production.js
21
- *
22
- * Copyright (c) Meta Platforms, Inc. and affiliates.
23
- *
24
- * This source code is licensed under the MIT license found in the
25
- * LICENSE file in the root directory of this source tree.
26
- */var lk;function kM(){if(lk)return Zc;lk=1;var t=wM(),e=Nx(),n=tj();function s(l){var u="https://react.dev/errors/"+l;if(1<arguments.length){u+="?args[]="+encodeURIComponent(arguments[1]);for(var p=2;p<arguments.length;p++)u+="&args[]="+encodeURIComponent(arguments[p])}return"Minified React error #"+l+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(l){return!(!l||l.nodeType!==1&&l.nodeType!==9&&l.nodeType!==11)}function r(l){var u=l,p=l;if(l.alternate)for(;u.return;)u=u.return;else{l=u;do u=l,(u.flags&4098)!==0&&(p=u.return),l=u.return;while(l)}return u.tag===3?p:null}function i(l){if(l.tag===13){var u=l.memoizedState;if(u===null&&(l=l.alternate,l!==null&&(u=l.memoizedState)),u!==null)return u.dehydrated}return null}function c(l){if(l.tag===31){var u=l.memoizedState;if(u===null&&(l=l.alternate,l!==null&&(u=l.memoizedState)),u!==null)return u.dehydrated}return null}function d(l){if(r(l)!==l)throw Error(s(188))}function f(l){var u=l.alternate;if(!u){if(u=r(l),u===null)throw Error(s(188));return u!==l?null:l}for(var p=l,g=u;;){var v=p.return;if(v===null)break;var A=v.alternate;if(A===null){if(g=v.return,g!==null){p=g;continue}break}if(v.child===A.child){for(A=v.child;A;){if(A===p)return d(v),l;if(A===g)return d(v),u;A=A.sibling}throw Error(s(188))}if(p.return!==g.return)p=v,g=A;else{for(var P=!1,Y=v.child;Y;){if(Y===p){P=!0,p=v,g=A;break}if(Y===g){P=!0,g=v,p=A;break}Y=Y.sibling}if(!P){for(Y=A.child;Y;){if(Y===p){P=!0,p=A,g=v;break}if(Y===g){P=!0,g=A,p=v;break}Y=Y.sibling}if(!P)throw Error(s(189))}}if(p.alternate!==g)throw Error(s(190))}if(p.tag!==3)throw Error(s(188));return p.stateNode.current===p?l:u}function h(l){var u=l.tag;if(u===5||u===26||u===27||u===6)return l;for(l=l.child;l!==null;){if(u=h(l),u!==null)return u;l=l.sibling}return null}var m=Object.assign,b=Symbol.for("react.element"),y=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),N=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),j=Symbol.for("react.consumer"),S=Symbol.for("react.context"),T=Symbol.for("react.forward_ref"),D=Symbol.for("react.suspense"),E=Symbol.for("react.suspense_list"),I=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),_=Symbol.for("react.activity"),M=Symbol.for("react.memo_cache_sentinel"),R=Symbol.iterator;function z(l){return l===null||typeof l!="object"?null:(l=R&&l[R]||l["@@iterator"],typeof l=="function"?l:null)}var $=Symbol.for("react.client.reference");function W(l){if(l==null)return null;if(typeof l=="function")return l.$$typeof===$?null:l.displayName||l.name||null;if(typeof l=="string")return l;switch(l){case C:return"Fragment";case k:return"Profiler";case N:return"StrictMode";case D:return"Suspense";case E:return"SuspenseList";case _:return"Activity"}if(typeof l=="object")switch(l.$$typeof){case w:return"Portal";case S:return l.displayName||"Context";case j:return(l._context.displayName||"Context")+".Consumer";case T:var u=l.render;return l=l.displayName,l||(l=u.displayName||u.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case I:return u=l.displayName||null,u!==null?u:W(l.type)||"Memo";case O:u=l._payload,l=l._init;try{return W(l(u))}catch{}}return null}var L=Array.isArray,F=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,H=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V={pending:!1,data:null,method:null,action:null},G=[],B=-1;function K(l){return{current:l}}function se(l){0>B||(l.current=G[B],G[B]=null,B--)}function q(l,u){B++,G[B]=l.current,l.current=u}var be=K(null),Ce=K(null),Z=K(null),ie=K(null);function me(l,u){switch(q(Z,u),q(Ce,l),q(be,null),u.nodeType){case 9:case 11:l=(l=u.documentElement)&&(l=l.namespaceURI)?k0(l):0;break;default:if(l=u.tagName,u=u.namespaceURI)u=k0(u),l=S0(u,l);else switch(l){case"svg":l=1;break;case"math":l=2;break;default:l=0}}se(be),q(be,l)}function Ee(){se(be),se(Ce),se(Z)}function Te(l){l.memoizedState!==null&&q(ie,l);var u=be.current,p=S0(u,l.type);u!==p&&(q(Ce,l),q(be,p))}function Ve(l){Ce.current===l&&(se(be),se(Ce)),ie.current===l&&(se(ie),Gc._currentValue=V)}var We,ee;function ne(l){if(We===void 0)try{throw Error()}catch(p){var u=p.stack.trim().match(/\n( *(at )?)/);We=u&&u[1]||"",ee=-1<p.stack.indexOf(`
27
- at`)?" (<anonymous>)":-1<p.stack.indexOf("@")?"@unknown:0:0":""}return`
28
- `+We+l+ee}var Ne=!1;function ze(l,u){if(!l||Ne)return"";Ne=!0;var p=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var g={DetermineComponentFrameRoot:function(){try{if(u){var Qe=function(){throw Error()};if(Object.defineProperty(Qe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Qe,[])}catch(Ue){var Ie=Ue}Reflect.construct(l,[],Qe)}else{try{Qe.call()}catch(Ue){Ie=Ue}l.call(Qe.prototype)}}else{try{throw Error()}catch(Ue){Ie=Ue}(Qe=l())&&typeof Qe.catch=="function"&&Qe.catch(function(){})}}catch(Ue){if(Ue&&Ie&&typeof Ue.stack=="string")return[Ue.stack,Ie.stack]}return[null,null]}};g.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var v=Object.getOwnPropertyDescriptor(g.DetermineComponentFrameRoot,"name");v&&v.configurable&&Object.defineProperty(g.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var A=g.DetermineComponentFrameRoot(),P=A[0],Y=A[1];if(P&&Y){var re=P.split(`
29
- `),De=Y.split(`
30
- `);for(v=g=0;g<re.length&&!re[g].includes("DetermineComponentFrameRoot");)g++;for(;v<De.length&&!De[v].includes("DetermineComponentFrameRoot");)v++;if(g===re.length||v===De.length)for(g=re.length-1,v=De.length-1;1<=g&&0<=v&&re[g]!==De[v];)v--;for(;1<=g&&0<=v;g--,v--)if(re[g]!==De[v]){if(g!==1||v!==1)do if(g--,v--,0>v||re[g]!==De[v]){var qe=`
31
- `+re[g].replace(" at new "," at ");return l.displayName&&qe.includes("<anonymous>")&&(qe=qe.replace("<anonymous>",l.displayName)),qe}while(1<=g&&0<=v);break}}}finally{Ne=!1,Error.prepareStackTrace=p}return(p=l?l.displayName||l.name:"")?ne(p):""}function st(l,u){switch(l.tag){case 26:case 27:case 5:return ne(l.type);case 16:return ne("Lazy");case 13:return l.child!==u&&u!==null?ne("Suspense Fallback"):ne("Suspense");case 19:return ne("SuspenseList");case 0:case 15:return ze(l.type,!1);case 11:return ze(l.type.render,!1);case 1:return ze(l.type,!0);case 31:return ne("Activity");default:return""}}function pe(l){try{var u="",p=null;do u+=st(l,p),p=l,l=l.return;while(l);return u}catch(g){return`
32
- Error generating stack: `+g.message+`
33
- `+g.stack}}var Be=Object.prototype.hasOwnProperty,oe=t.unstable_scheduleCallback,de=t.unstable_cancelCallback,He=t.unstable_shouldYield,et=t.unstable_requestPaint,ct=t.unstable_now,fe=t.unstable_getCurrentPriorityLevel,X=t.unstable_ImmediatePriority,ae=t.unstable_UserBlockingPriority,ke=t.unstable_NormalPriority,J=t.unstable_LowPriority,he=t.unstable_IdlePriority,Oe=t.log,$e=t.unstable_setDisableYieldValue,xe=null,Pe=null;function te(l){if(typeof Oe=="function"&&$e(l),Pe&&typeof Pe.setStrictMode=="function")try{Pe.setStrictMode(xe,l)}catch{}}var ge=Math.clz32?Math.clz32:Ke,ve=Math.log,Fe=Math.LN2;function Ke(l){return l>>>=0,l===0?32:31-(ve(l)/Fe|0)|0}var at=256,ft=262144,wt=4194304;function it(l){var u=l&42;if(u!==0)return u;switch(l&-l){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 l&261888;case 262144:case 524288:case 1048576:case 2097152:return l&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return l&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return l}}function gt(l,u,p){var g=l.pendingLanes;if(g===0)return 0;var v=0,A=l.suspendedLanes,P=l.pingedLanes;l=l.warmLanes;var Y=g&134217727;return Y!==0?(g=Y&~A,g!==0?v=it(g):(P&=Y,P!==0?v=it(P):p||(p=Y&~l,p!==0&&(v=it(p))))):(Y=g&~A,Y!==0?v=it(Y):P!==0?v=it(P):p||(p=g&~l,p!==0&&(v=it(p)))),v===0?0:u!==0&&u!==v&&(u&A)===0&&(A=v&-v,p=u&-u,A>=p||A===32&&(p&4194048)!==0)?u:v}function ht(l,u){return(l.pendingLanes&~(l.suspendedLanes&~l.pingedLanes)&u)===0}function Gt(l,u){switch(l){case 1:case 2:case 4:case 8:case 64:return u+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 u+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 tn(){var l=wt;return wt<<=1,(wt&62914560)===0&&(wt=4194304),l}function Ae(l){for(var u=[],p=0;31>p;p++)u.push(l);return u}function Le(l,u){l.pendingLanes|=u,u!==268435456&&(l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0)}function Ye(l,u,p,g,v,A){var P=l.pendingLanes;l.pendingLanes=p,l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0,l.expiredLanes&=p,l.entangledLanes&=p,l.errorRecoveryDisabledLanes&=p,l.shellSuspendCounter=0;var Y=l.entanglements,re=l.expirationTimes,De=l.hiddenUpdates;for(p=P&~p;0<p;){var qe=31-ge(p),Qe=1<<qe;Y[qe]=0,re[qe]=-1;var Ie=De[qe];if(Ie!==null)for(De[qe]=null,qe=0;qe<Ie.length;qe++){var Ue=Ie[qe];Ue!==null&&(Ue.lane&=-536870913)}p&=~Qe}g!==0&&Ze(l,g,0),A!==0&&v===0&&l.tag!==0&&(l.suspendedLanes|=A&~(P&~u))}function Ze(l,u,p){l.pendingLanes|=u,l.suspendedLanes&=~u;var g=31-ge(u);l.entangledLanes|=u,l.entanglements[g]=l.entanglements[g]|1073741824|p&261930}function Ot(l,u){var p=l.entangledLanes|=u;for(l=l.entanglements;p;){var g=31-ge(p),v=1<<g;v&u|l[g]&u&&(l[g]|=u),p&=~v}}function Ft(l,u){var p=u&-u;return p=(p&42)!==0?1:Lt(p),(p&(l.suspendedLanes|u))!==0?0:p}function Lt(l){switch(l){case 2:l=1;break;case 8:l=4;break;case 32:l=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:l=128;break;case 268435456:l=134217728;break;default:l=0}return l}function Vt(l){return l&=-l,2<l?8<l?(l&134217727)!==0?32:268435456:8:2}function ln(){var l=H.p;return l!==0?l:(l=window.event,l===void 0?32:V0(l.type))}function bt(l,u){var p=H.p;try{return H.p=l,u()}finally{H.p=p}}var rt=Math.random().toString(36).slice(2),xt="__reactFiber$"+rt,$t="__reactProps$"+rt,En="__reactContainer$"+rt,nn="__reactEvents$"+rt,Un="__reactListeners$"+rt,Os="__reactHandles$"+rt,ps="__reactResources$"+rt,ks="__reactMarker$"+rt;function Qn(l){delete l[xt],delete l[$t],delete l[nn],delete l[Un],delete l[Os]}function Ss(l){var u=l[xt];if(u)return u;for(var p=l.parentNode;p;){if(u=p[En]||p[xt]){if(p=u.alternate,u.child!==null||p!==null&&p.child!==null)for(l=E0(l);l!==null;){if(p=l[xt])return p;l=E0(l)}return u}l=p,p=l.parentNode}return null}function Fn(l){if(l=l[xt]||l[En]){var u=l.tag;if(u===5||u===6||u===13||u===31||u===26||u===27||u===3)return l}return null}function Ls(l){var u=l.tag;if(u===5||u===26||u===27||u===6)return l.stateNode;throw Error(s(33))}function Is(l){var u=l[ps];return u||(u=l[ps]={hoistableStyles:new Map,hoistableScripts:new Map}),u}function wn(l){l[ks]=!0}var Po=new Set,Bo={};function Ps(l,u){Ua(l,u),Ua(l+"Capture",u)}function Ua(l,u){for(Bo[l]=u,l=0;l<u.length;l++)Po.add(u[l])}var Bi=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]*$"),Fi={},Bs={};function lc(l){return Be.call(Bs,l)?!0:Be.call(Fi,l)?!1:Bi.test(l)?Bs[l]=!0:(Fi[l]=!0,!1)}function Ma(l,u,p){if(lc(u))if(p===null)l.removeAttribute(u);else{switch(typeof p){case"undefined":case"function":case"symbol":l.removeAttribute(u);return;case"boolean":var g=u.toLowerCase().slice(0,5);if(g!=="data-"&&g!=="aria-"){l.removeAttribute(u);return}}l.setAttribute(u,""+p)}}function Ts(l,u,p){if(p===null)l.removeAttribute(u);else{switch(typeof p){case"undefined":case"function":case"symbol":case"boolean":l.removeAttribute(u);return}l.setAttribute(u,""+p)}}function hs(l,u,p,g){if(g===null)l.removeAttribute(p);else{switch(typeof g){case"undefined":case"function":case"symbol":case"boolean":l.removeAttribute(p);return}l.setAttributeNS(u,p,""+g)}}function Mn(l){switch(typeof l){case"bigint":case"boolean":case"number":case"string":case"undefined":return l;case"object":return l;default:return""}}function zi(l){var u=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(u==="checkbox"||u==="radio")}function je(l,u,p){var g=Object.getOwnPropertyDescriptor(l.constructor.prototype,u);if(!l.hasOwnProperty(u)&&typeof g<"u"&&typeof g.get=="function"&&typeof g.set=="function"){var v=g.get,A=g.set;return Object.defineProperty(l,u,{configurable:!0,get:function(){return v.call(this)},set:function(P){p=""+P,A.call(this,P)}}),Object.defineProperty(l,u,{enumerable:g.enumerable}),{getValue:function(){return p},setValue:function(P){p=""+P},stopTracking:function(){l._valueTracker=null,delete l[u]}}}}function Je(l){if(!l._valueTracker){var u=zi(l)?"checked":"value";l._valueTracker=je(l,u,""+l[u])}}function Ct(l){if(!l)return!1;var u=l._valueTracker;if(!u)return!0;var p=u.getValue(),g="";return l&&(g=zi(l)?l.checked?"true":"false":l.value),l=g,l!==p?(u.setValue(l),!0):!1}function ot(l){if(l=l||(typeof document<"u"?document:void 0),typeof l>"u")return null;try{return l.activeElement||l.body}catch{return l.body}}var jn=/[\n"\\]/g;function Mt(l){return l.replace(jn,function(u){return"\\"+u.charCodeAt(0).toString(16)+" "})}function At(l,u,p,g,v,A,P,Y){l.name="",P!=null&&typeof P!="function"&&typeof P!="symbol"&&typeof P!="boolean"?l.type=P:l.removeAttribute("type"),u!=null?P==="number"?(u===0&&l.value===""||l.value!=u)&&(l.value=""+Mn(u)):l.value!==""+Mn(u)&&(l.value=""+Mn(u)):P!=="submit"&&P!=="reset"||l.removeAttribute("value"),u!=null?ms(l,P,Mn(u)):p!=null?ms(l,P,Mn(p)):g!=null&&l.removeAttribute("value"),v==null&&A!=null&&(l.defaultChecked=!!A),v!=null&&(l.checked=v&&typeof v!="function"&&typeof v!="symbol"),Y!=null&&typeof Y!="function"&&typeof Y!="symbol"&&typeof Y!="boolean"?l.name=""+Mn(Y):l.removeAttribute("name")}function kn(l,u,p,g,v,A,P,Y){if(A!=null&&typeof A!="function"&&typeof A!="symbol"&&typeof A!="boolean"&&(l.type=A),u!=null||p!=null){if(!(A!=="submit"&&A!=="reset"||u!=null)){Je(l);return}p=p!=null?""+Mn(p):"",u=u!=null?""+Mn(u):p,Y||u===l.value||(l.value=u),l.defaultValue=u}g=g??v,g=typeof g!="function"&&typeof g!="symbol"&&!!g,l.checked=Y?l.checked:!!g,l.defaultChecked=!!g,P!=null&&typeof P!="function"&&typeof P!="symbol"&&typeof P!="boolean"&&(l.name=P),Je(l)}function ms(l,u,p){u==="number"&&ot(l.ownerDocument)===l||l.defaultValue===""+p||(l.defaultValue=""+p)}function Dn(l,u,p,g){if(l=l.options,u){u={};for(var v=0;v<p.length;v++)u["$"+p[v]]=!0;for(p=0;p<l.length;p++)v=u.hasOwnProperty("$"+l[p].value),l[p].selected!==v&&(l[p].selected=v),v&&g&&(l[p].defaultSelected=!0)}else{for(p=""+Mn(p),u=null,v=0;v<l.length;v++){if(l[v].value===p){l[v].selected=!0,g&&(l[v].defaultSelected=!0);return}u!==null||l[v].disabled||(u=l[v])}u!==null&&(u.selected=!0)}}function Fs(l,u,p){if(u!=null&&(u=""+Mn(u),u!==l.value&&(l.value=u),p==null)){l.defaultValue!==u&&(l.defaultValue=u);return}l.defaultValue=p!=null?""+Mn(p):""}function Qr(l,u,p,g){if(u==null){if(g!=null){if(p!=null)throw Error(s(92));if(L(g)){if(1<g.length)throw Error(s(93));g=g[0]}p=g}p==null&&(p=""),u=p}p=Mn(u),l.defaultValue=p,g=l.textContent,g===p&&g!==""&&g!==null&&(l.value=g),Je(l)}function pa(l,u){if(u){var p=l.firstChild;if(p&&p===l.lastChild&&p.nodeType===3){p.nodeValue=u;return}}l.textContent=u}var mh=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 ha(l,u,p){var g=u.indexOf("--")===0;p==null||typeof p=="boolean"||p===""?g?l.setProperty(u,""):u==="float"?l.cssFloat="":l[u]="":g?l.setProperty(u,p):typeof p!="number"||p===0||mh.has(u)?u==="float"?l.cssFloat=p:l[u]=(""+p).trim():l[u]=p+"px"}function $i(l,u,p){if(u!=null&&typeof u!="object")throw Error(s(62));if(l=l.style,p!=null){for(var g in p)!p.hasOwnProperty(g)||u!=null&&u.hasOwnProperty(g)||(g.indexOf("--")===0?l.setProperty(g,""):g==="float"?l.cssFloat="":l[g]="");for(var v in u)g=u[v],u.hasOwnProperty(v)&&p[v]!==g&&ha(l,v,g)}else for(var A in u)u.hasOwnProperty(A)&&ha(l,A,u[A])}function gr(l){if(l.indexOf("-")===-1)return!1;switch(l){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 Ui=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"]]),cc=/^[\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 Fo(l){return cc.test(""+l)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":l}function It(){}var Hn=null;function uc(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var Xr=null,Jr=null;function ts(l){var u=Fn(l);if(u&&(l=u.stateNode)){var p=l[$t]||null;e:switch(l=u.stateNode,u.type){case"input":if(At(l,p.value,p.defaultValue,p.defaultValue,p.checked,p.defaultChecked,p.type,p.name),u=p.name,p.type==="radio"&&u!=null){for(p=l;p.parentNode;)p=p.parentNode;for(p=p.querySelectorAll('input[name="'+Mt(""+u)+'"][type="radio"]'),u=0;u<p.length;u++){var g=p[u];if(g!==l&&g.form===l.form){var v=g[$t]||null;if(!v)throw Error(s(90));At(g,v.value,v.defaultValue,v.defaultValue,v.checked,v.defaultChecked,v.type,v.name)}}for(u=0;u<p.length;u++)g=p[u],g.form===l.form&&Ct(g)}break e;case"textarea":Fs(l,p.value,p.defaultValue);break e;case"select":u=p.value,u!=null&&Dn(l,!!p.multiple,u,!1)}}}var zo=!1;function cd(l,u,p){if(zo)return l(u,p);zo=!0;try{var g=l(u);return g}finally{if(zo=!1,(Xr!==null||Jr!==null)&&(tf(),Xr&&(u=Xr,l=Jr,Jr=Xr=null,ts(u),l)))for(u=0;u<l.length;u++)ts(l[u])}}function Ha(l,u){var p=l.stateNode;if(p===null)return null;var g=p[$t]||null;if(g===null)return null;p=g[u];e:switch(u){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(g=!g.disabled)||(l=l.type,g=!(l==="button"||l==="input"||l==="select"||l==="textarea")),l=!g;break e;default:l=!1}if(l)return null;if(p&&typeof p!="function")throw Error(s(231,u,typeof p));return p}var zs=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Hi=!1;if(zs)try{var br={};Object.defineProperty(br,"passive",{get:function(){Hi=!0}}),window.addEventListener("test",br,br),window.removeEventListener("test",br,br)}catch{Hi=!1}var ma=null,$o=null,Uo=null;function ud(){if(Uo)return Uo;var l,u=$o,p=u.length,g,v="value"in ma?ma.value:ma.textContent,A=v.length;for(l=0;l<p&&u[l]===v[l];l++);var P=p-l;for(g=1;g<=P&&u[p-g]===v[A-g];g++);return Uo=v.slice(l,1<g?1-g:void 0)}function Wi(l){var u=l.keyCode;return"charCode"in l?(l=l.charCode,l===0&&u===13&&(l=13)):l=u,l===10&&(l=13),32<=l||l===13?l:0}function qi(){return!0}function Wa(){return!1}function Wn(l){function u(p,g,v,A,P){this._reactName=p,this._targetInst=v,this.type=g,this.nativeEvent=A,this.target=P,this.currentTarget=null;for(var Y in l)l.hasOwnProperty(Y)&&(p=l[Y],this[Y]=p?p(A):A[Y]);return this.isDefaultPrevented=(A.defaultPrevented!=null?A.defaultPrevented:A.returnValue===!1)?qi:Wa,this.isPropagationStopped=Wa,this}return m(u.prototype,{preventDefault:function(){this.defaultPrevented=!0;var p=this.nativeEvent;p&&(p.preventDefault?p.preventDefault():typeof p.returnValue!="unknown"&&(p.returnValue=!1),this.isDefaultPrevented=qi)},stopPropagation:function(){var p=this.nativeEvent;p&&(p.stopPropagation?p.stopPropagation():typeof p.cancelBubble!="unknown"&&(p.cancelBubble=!0),this.isPropagationStopped=qi)},persist:function(){},isPersistent:qi}),u}var xr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(l){return l.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ln=Wn(xr),Vi=m({},xr,{view:0,detail:0}),dd=Wn(Vi),Ho,Wo,Zr,qo=m({},Vi,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Go,button:0,buttons:0,relatedTarget:function(l){return l.relatedTarget===void 0?l.fromElement===l.srcElement?l.toElement:l.fromElement:l.relatedTarget},movementX:function(l){return"movementX"in l?l.movementX:(l!==Zr&&(Zr&&l.type==="mousemove"?(Ho=l.screenX-Zr.screenX,Wo=l.screenY-Zr.screenY):Wo=Ho=0,Zr=l),Ho)},movementY:function(l){return"movementY"in l?l.movementY:Wo}}),fd=Wn(qo),gh=m({},qo,{dataTransfer:0}),Vo=Wn(gh),pd=m({},Vi,{relatedTarget:0}),ei=Wn(pd),dc=m({},xr,{animationName:0,elapsedTime:0,pseudoElement:0}),fc=Wn(dc),Yi=m({},xr,{clipboardData:function(l){return"clipboardData"in l?l.clipboardData:window.clipboardData}}),pc=Wn(Yi),Yo=m({},xr,{data:0}),hd=Wn(Yo),bh={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},xh={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"},yh={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function vh(l){var u=this.nativeEvent;return u.getModifierState?u.getModifierState(l):(l=yh[l])?!!u[l]:!1}function Go(){return vh}var wh=m({},Vi,{key:function(l){if(l.key){var u=bh[l.key]||l.key;if(u!=="Unidentified")return u}return l.type==="keypress"?(l=Wi(l),l===13?"Enter":String.fromCharCode(l)):l.type==="keydown"||l.type==="keyup"?xh[l.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Go,charCode:function(l){return l.type==="keypress"?Wi(l):0},keyCode:function(l){return l.type==="keydown"||l.type==="keyup"?l.keyCode:0},which:function(l){return l.type==="keypress"?Wi(l):l.type==="keydown"||l.type==="keyup"?l.keyCode:0}}),kh=Wn(wh),md=m({},qo,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),qa=Wn(md),gd=m({},Vi,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Go}),bd=Wn(gd),Gi=m({},xr,{propertyName:0,elapsedTime:0,pseudoElement:0}),hc=Wn(Gi),Sh=m({},qo,{deltaX:function(l){return"deltaX"in l?l.deltaX:"wheelDeltaX"in l?-l.wheelDeltaX:0},deltaY:function(l){return"deltaY"in l?l.deltaY:"wheelDeltaY"in l?-l.wheelDeltaY:"wheelDelta"in l?-l.wheelDelta:0},deltaZ:0,deltaMode:0}),Ch=Wn(Sh),Ah=m({},xr,{newState:0,oldState:0}),jh=Wn(Ah),xd=[9,13,27,32],Ko=zs&&"CompositionEvent"in window,ti=null;zs&&"documentMode"in document&&(ti=document.documentMode);var yd=zs&&"TextEvent"in window&&!ti,mc=zs&&(!Ko||ti&&8<ti&&11>=ti),Q=" ",ue=!1;function ce(l,u){switch(l){case"keyup":return xd.indexOf(u.keyCode)!==-1;case"keydown":return u.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Me(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var nt=!1;function ut(l,u){switch(l){case"compositionend":return Me(u);case"keypress":return u.which!==32?null:(ue=!0,Q);case"textInput":return l=u.data,l===Q&&ue?null:l;default:return null}}function Nt(l,u){if(nt)return l==="compositionend"||!Ko&&ce(l,u)?(l=ud(),Uo=$o=ma=null,nt=!1,l):null;switch(l){case"paste":return null;case"keypress":if(!(u.ctrlKey||u.altKey||u.metaKey)||u.ctrlKey&&u.altKey){if(u.char&&1<u.char.length)return u.char;if(u.which)return String.fromCharCode(u.which)}return null;case"compositionend":return mc&&u.locale!=="ko"?null:u.data;default:return null}}var _t={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 sn(l){var u=l&&l.nodeName&&l.nodeName.toLowerCase();return u==="input"?!!_t[l.type]:u==="textarea"}function gn(l,u,p,g){Xr?Jr?Jr.push(g):Jr=[g]:Xr=g,u=cf(u,"onChange"),0<u.length&&(p=new Ln("onChange","change",null,p,g),l.push({event:p,listeners:u}))}var qn=null,Va=null;function Qo(l){g0(l,0)}function Ki(l){var u=Ls(l);if(Ct(u))return l}function gc(l,u){if(l==="change")return u}var Xo=!1;if(zs){var Jo;if(zs){var bc="oninput"in document;if(!bc){var vd=document.createElement("div");vd.setAttribute("oninput","return;"),bc=typeof vd.oninput=="function"}Jo=bc}else Jo=!1;Xo=Jo&&(!document.documentMode||9<document.documentMode)}function By(){qn&&(qn.detachEvent("onpropertychange",Fy),Va=qn=null)}function Fy(l){if(l.propertyName==="value"&&Ki(Va)){var u=[];gn(u,Va,l,uc(l)),cd(Qo,u)}}function s_(l,u,p){l==="focusin"?(By(),qn=u,Va=p,qn.attachEvent("onpropertychange",Fy)):l==="focusout"&&By()}function a_(l){if(l==="selectionchange"||l==="keyup"||l==="keydown")return Ki(Va)}function r_(l,u){if(l==="click")return Ki(u)}function i_(l,u){if(l==="input"||l==="change")return Ki(u)}function o_(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}var Js=typeof Object.is=="function"?Object.is:o_;function xc(l,u){if(Js(l,u))return!0;if(typeof l!="object"||l===null||typeof u!="object"||u===null)return!1;var p=Object.keys(l),g=Object.keys(u);if(p.length!==g.length)return!1;for(g=0;g<p.length;g++){var v=p[g];if(!Be.call(u,v)||!Js(l[v],u[v]))return!1}return!0}function zy(l){for(;l&&l.firstChild;)l=l.firstChild;return l}function $y(l,u){var p=zy(l);l=0;for(var g;p;){if(p.nodeType===3){if(g=l+p.textContent.length,l<=u&&g>=u)return{node:p,offset:u-l};l=g}e:{for(;p;){if(p.nextSibling){p=p.nextSibling;break e}p=p.parentNode}p=void 0}p=zy(p)}}function Uy(l,u){return l&&u?l===u?!0:l&&l.nodeType===3?!1:u&&u.nodeType===3?Uy(l,u.parentNode):"contains"in l?l.contains(u):l.compareDocumentPosition?!!(l.compareDocumentPosition(u)&16):!1:!1}function Hy(l){l=l!=null&&l.ownerDocument!=null&&l.ownerDocument.defaultView!=null?l.ownerDocument.defaultView:window;for(var u=ot(l.document);u instanceof l.HTMLIFrameElement;){try{var p=typeof u.contentWindow.location.href=="string"}catch{p=!1}if(p)l=u.contentWindow;else break;u=ot(l.document)}return u}function Nh(l){var u=l&&l.nodeName&&l.nodeName.toLowerCase();return u&&(u==="input"&&(l.type==="text"||l.type==="search"||l.type==="tel"||l.type==="url"||l.type==="password")||u==="textarea"||l.contentEditable==="true")}var l_=zs&&"documentMode"in document&&11>=document.documentMode,Zo=null,Th=null,yc=null,_h=!1;function Wy(l,u,p){var g=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;_h||Zo==null||Zo!==ot(g)||(g=Zo,"selectionStart"in g&&Nh(g)?g={start:g.selectionStart,end:g.selectionEnd}:(g=(g.ownerDocument&&g.ownerDocument.defaultView||window).getSelection(),g={anchorNode:g.anchorNode,anchorOffset:g.anchorOffset,focusNode:g.focusNode,focusOffset:g.focusOffset}),yc&&xc(yc,g)||(yc=g,g=cf(Th,"onSelect"),0<g.length&&(u=new Ln("onSelect","select",null,u,p),l.push({event:u,listeners:g}),u.target=Zo)))}function Qi(l,u){var p={};return p[l.toLowerCase()]=u.toLowerCase(),p["Webkit"+l]="webkit"+u,p["Moz"+l]="moz"+u,p}var el={animationend:Qi("Animation","AnimationEnd"),animationiteration:Qi("Animation","AnimationIteration"),animationstart:Qi("Animation","AnimationStart"),transitionrun:Qi("Transition","TransitionRun"),transitionstart:Qi("Transition","TransitionStart"),transitioncancel:Qi("Transition","TransitionCancel"),transitionend:Qi("Transition","TransitionEnd")},Eh={},qy={};zs&&(qy=document.createElement("div").style,"AnimationEvent"in window||(delete el.animationend.animation,delete el.animationiteration.animation,delete el.animationstart.animation),"TransitionEvent"in window||delete el.transitionend.transition);function Xi(l){if(Eh[l])return Eh[l];if(!el[l])return l;var u=el[l],p;for(p in u)if(u.hasOwnProperty(p)&&p in qy)return Eh[l]=u[p];return l}var Vy=Xi("animationend"),Yy=Xi("animationiteration"),Gy=Xi("animationstart"),c_=Xi("transitionrun"),u_=Xi("transitionstart"),d_=Xi("transitioncancel"),Ky=Xi("transitionend"),Qy=new Map,Mh="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(" ");Mh.push("scrollEnd");function Da(l,u){Qy.set(l,u),Ps(u,[l])}var wd=typeof reportError=="function"?reportError:function(l){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var u=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof l=="object"&&l!==null&&typeof l.message=="string"?String(l.message):String(l),error:l});if(!window.dispatchEvent(u))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",l);return}console.error(l)},ga=[],tl=0,Dh=0;function kd(){for(var l=tl,u=Dh=tl=0;u<l;){var p=ga[u];ga[u++]=null;var g=ga[u];ga[u++]=null;var v=ga[u];ga[u++]=null;var A=ga[u];if(ga[u++]=null,g!==null&&v!==null){var P=g.pending;P===null?v.next=v:(v.next=P.next,P.next=v),g.pending=v}A!==0&&Xy(p,v,A)}}function Sd(l,u,p,g){ga[tl++]=l,ga[tl++]=u,ga[tl++]=p,ga[tl++]=g,Dh|=g,l.lanes|=g,l=l.alternate,l!==null&&(l.lanes|=g)}function Rh(l,u,p,g){return Sd(l,u,p,g),Cd(l)}function Ji(l,u){return Sd(l,null,null,u),Cd(l)}function Xy(l,u,p){l.lanes|=p;var g=l.alternate;g!==null&&(g.lanes|=p);for(var v=!1,A=l.return;A!==null;)A.childLanes|=p,g=A.alternate,g!==null&&(g.childLanes|=p),A.tag===22&&(l=A.stateNode,l===null||l._visibility&1||(v=!0)),l=A,A=A.return;return l.tag===3?(A=l.stateNode,v&&u!==null&&(v=31-ge(p),l=A.hiddenUpdates,g=l[v],g===null?l[v]=[u]:g.push(u),u.lane=p|536870912),A):null}function Cd(l){if(50<$c)throw $c=0,Um=null,Error(s(185));for(var u=l.return;u!==null;)l=u,u=l.return;return l.tag===3?l.stateNode:null}var nl={};function f_(l,u,p,g){this.tag=l,this.key=p,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=u,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=g,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Zs(l,u,p,g){return new f_(l,u,p,g)}function Oh(l){return l=l.prototype,!(!l||!l.isReactComponent)}function yr(l,u){var p=l.alternate;return p===null?(p=Zs(l.tag,u,l.key,l.mode),p.elementType=l.elementType,p.type=l.type,p.stateNode=l.stateNode,p.alternate=l,l.alternate=p):(p.pendingProps=u,p.type=l.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=l.flags&65011712,p.childLanes=l.childLanes,p.lanes=l.lanes,p.child=l.child,p.memoizedProps=l.memoizedProps,p.memoizedState=l.memoizedState,p.updateQueue=l.updateQueue,u=l.dependencies,p.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext},p.sibling=l.sibling,p.index=l.index,p.ref=l.ref,p.refCleanup=l.refCleanup,p}function Jy(l,u){l.flags&=65011714;var p=l.alternate;return p===null?(l.childLanes=0,l.lanes=u,l.child=null,l.subtreeFlags=0,l.memoizedProps=null,l.memoizedState=null,l.updateQueue=null,l.dependencies=null,l.stateNode=null):(l.childLanes=p.childLanes,l.lanes=p.lanes,l.child=p.child,l.subtreeFlags=0,l.deletions=null,l.memoizedProps=p.memoizedProps,l.memoizedState=p.memoizedState,l.updateQueue=p.updateQueue,l.type=p.type,u=p.dependencies,l.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext}),l}function Ad(l,u,p,g,v,A){var P=0;if(g=l,typeof l=="function")Oh(l)&&(P=1);else if(typeof l=="string")P=bE(l,p,be.current)?26:l==="html"||l==="head"||l==="body"?27:5;else e:switch(l){case _:return l=Zs(31,p,u,v),l.elementType=_,l.lanes=A,l;case C:return Zi(p.children,v,A,u);case N:P=8,v|=24;break;case k:return l=Zs(12,p,u,v|2),l.elementType=k,l.lanes=A,l;case D:return l=Zs(13,p,u,v),l.elementType=D,l.lanes=A,l;case E:return l=Zs(19,p,u,v),l.elementType=E,l.lanes=A,l;default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case S:P=10;break e;case j:P=9;break e;case T:P=11;break e;case I:P=14;break e;case O:P=16,g=null;break e}P=29,p=Error(s(130,l===null?"null":typeof l,"")),g=null}return u=Zs(P,p,u,v),u.elementType=l,u.type=g,u.lanes=A,u}function Zi(l,u,p,g){return l=Zs(7,l,g,u),l.lanes=p,l}function Lh(l,u,p){return l=Zs(6,l,null,u),l.lanes=p,l}function Zy(l){var u=Zs(18,null,null,0);return u.stateNode=l,u}function Ih(l,u,p){return u=Zs(4,l.children!==null?l.children:[],l.key,u),u.lanes=p,u.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},u}var ev=new WeakMap;function ba(l,u){if(typeof l=="object"&&l!==null){var p=ev.get(l);return p!==void 0?p:(u={value:l,source:u,stack:pe(u)},ev.set(l,u),u)}return{value:l,source:u,stack:pe(u)}}var sl=[],al=0,jd=null,vc=0,xa=[],ya=0,ni=null,Ya=1,Ga="";function vr(l,u){sl[al++]=vc,sl[al++]=jd,jd=l,vc=u}function tv(l,u,p){xa[ya++]=Ya,xa[ya++]=Ga,xa[ya++]=ni,ni=l;var g=Ya;l=Ga;var v=32-ge(g)-1;g&=~(1<<v),p+=1;var A=32-ge(u)+v;if(30<A){var P=v-v%5;A=(g&(1<<P)-1).toString(32),g>>=P,v-=P,Ya=1<<32-ge(u)+v|p<<v|g,Ga=A+l}else Ya=1<<A|p<<v|g,Ga=l}function Ph(l){l.return!==null&&(vr(l,1),tv(l,1,0))}function Bh(l){for(;l===jd;)jd=sl[--al],sl[al]=null,vc=sl[--al],sl[al]=null;for(;l===ni;)ni=xa[--ya],xa[ya]=null,Ga=xa[--ya],xa[ya]=null,Ya=xa[--ya],xa[ya]=null}function nv(l,u){xa[ya++]=Ya,xa[ya++]=Ga,xa[ya++]=ni,Ya=u.id,Ga=u.overflow,ni=l}var gs=null,In=null,cn=!1,si=null,va=!1,Fh=Error(s(519));function ai(l){var u=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw wc(ba(u,l)),Fh}function sv(l){var u=l.stateNode,p=l.type,g=l.memoizedProps;switch(u[xt]=l,u[$t]=g,p){case"dialog":Qt("cancel",u),Qt("close",u);break;case"iframe":case"object":case"embed":Qt("load",u);break;case"video":case"audio":for(p=0;p<Hc.length;p++)Qt(Hc[p],u);break;case"source":Qt("error",u);break;case"img":case"image":case"link":Qt("error",u),Qt("load",u);break;case"details":Qt("toggle",u);break;case"input":Qt("invalid",u),kn(u,g.value,g.defaultValue,g.checked,g.defaultChecked,g.type,g.name,!0);break;case"select":Qt("invalid",u);break;case"textarea":Qt("invalid",u),Qr(u,g.value,g.defaultValue,g.children)}p=g.children,typeof p!="string"&&typeof p!="number"&&typeof p!="bigint"||u.textContent===""+p||g.suppressHydrationWarning===!0||v0(u.textContent,p)?(g.popover!=null&&(Qt("beforetoggle",u),Qt("toggle",u)),g.onScroll!=null&&Qt("scroll",u),g.onScrollEnd!=null&&Qt("scrollend",u),g.onClick!=null&&(u.onclick=It),u=!0):u=!1,u||ai(l,!0)}function av(l){for(gs=l.return;gs;)switch(gs.tag){case 5:case 31:case 13:va=!1;return;case 27:case 3:va=!0;return;default:gs=gs.return}}function rl(l){if(l!==gs)return!1;if(!cn)return av(l),cn=!0,!1;var u=l.tag,p;if((p=u!==3&&u!==27)&&((p=u===5)&&(p=l.type,p=!(p!=="form"&&p!=="button")||sg(l.type,l.memoizedProps)),p=!p),p&&In&&ai(l),av(l),u===13){if(l=l.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(s(317));In=_0(l)}else if(u===31){if(l=l.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(s(317));In=_0(l)}else u===27?(u=In,xi(l.type)?(l=lg,lg=null,In=l):In=u):In=gs?ka(l.stateNode.nextSibling):null;return!0}function eo(){In=gs=null,cn=!1}function zh(){var l=si;return l!==null&&(Ws===null?Ws=l:Ws.push.apply(Ws,l),si=null),l}function wc(l){si===null?si=[l]:si.push(l)}var $h=K(null),to=null,wr=null;function ri(l,u,p){q($h,u._currentValue),u._currentValue=p}function kr(l){l._currentValue=$h.current,se($h)}function Uh(l,u,p){for(;l!==null;){var g=l.alternate;if((l.childLanes&u)!==u?(l.childLanes|=u,g!==null&&(g.childLanes|=u)):g!==null&&(g.childLanes&u)!==u&&(g.childLanes|=u),l===p)break;l=l.return}}function Hh(l,u,p,g){var v=l.child;for(v!==null&&(v.return=l);v!==null;){var A=v.dependencies;if(A!==null){var P=v.child;A=A.firstContext;e:for(;A!==null;){var Y=A;A=v;for(var re=0;re<u.length;re++)if(Y.context===u[re]){A.lanes|=p,Y=A.alternate,Y!==null&&(Y.lanes|=p),Uh(A.return,p,l),g||(P=null);break e}A=Y.next}}else if(v.tag===18){if(P=v.return,P===null)throw Error(s(341));P.lanes|=p,A=P.alternate,A!==null&&(A.lanes|=p),Uh(P,p,l),P=null}else P=v.child;if(P!==null)P.return=v;else for(P=v;P!==null;){if(P===l){P=null;break}if(v=P.sibling,v!==null){v.return=P.return,P=v;break}P=P.return}v=P}}function il(l,u,p,g){l=null;for(var v=u,A=!1;v!==null;){if(!A){if((v.flags&524288)!==0)A=!0;else if((v.flags&262144)!==0)break}if(v.tag===10){var P=v.alternate;if(P===null)throw Error(s(387));if(P=P.memoizedProps,P!==null){var Y=v.type;Js(v.pendingProps.value,P.value)||(l!==null?l.push(Y):l=[Y])}}else if(v===ie.current){if(P=v.alternate,P===null)throw Error(s(387));P.memoizedState.memoizedState!==v.memoizedState.memoizedState&&(l!==null?l.push(Gc):l=[Gc])}v=v.return}l!==null&&Hh(u,l,p,g),u.flags|=262144}function Nd(l){for(l=l.firstContext;l!==null;){if(!Js(l.context._currentValue,l.memoizedValue))return!0;l=l.next}return!1}function no(l){to=l,wr=null,l=l.dependencies,l!==null&&(l.firstContext=null)}function bs(l){return rv(to,l)}function Td(l,u){return to===null&&no(l),rv(l,u)}function rv(l,u){var p=u._currentValue;if(u={context:u,memoizedValue:p,next:null},wr===null){if(l===null)throw Error(s(308));wr=u,l.dependencies={lanes:0,firstContext:u},l.flags|=524288}else wr=wr.next=u;return p}var p_=typeof AbortController<"u"?AbortController:function(){var l=[],u=this.signal={aborted:!1,addEventListener:function(p,g){l.push(g)}};this.abort=function(){u.aborted=!0,l.forEach(function(p){return p()})}},h_=t.unstable_scheduleCallback,m_=t.unstable_NormalPriority,ns={$$typeof:S,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Wh(){return{controller:new p_,data:new Map,refCount:0}}function kc(l){l.refCount--,l.refCount===0&&h_(m_,function(){l.controller.abort()})}var Sc=null,qh=0,ol=0,ll=null;function g_(l,u){if(Sc===null){var p=Sc=[];qh=0,ol=Gm(),ll={status:"pending",value:void 0,then:function(g){p.push(g)}}}return qh++,u.then(iv,iv),u}function iv(){if(--qh===0&&Sc!==null){ll!==null&&(ll.status="fulfilled");var l=Sc;Sc=null,ol=0,ll=null;for(var u=0;u<l.length;u++)(0,l[u])()}}function b_(l,u){var p=[],g={status:"pending",value:null,reason:null,then:function(v){p.push(v)}};return l.then(function(){g.status="fulfilled",g.value=u;for(var v=0;v<p.length;v++)(0,p[v])(u)},function(v){for(g.status="rejected",g.reason=v,v=0;v<p.length;v++)(0,p[v])(void 0)}),g}var ov=F.S;F.S=function(l,u){Ww=ct(),typeof u=="object"&&u!==null&&typeof u.then=="function"&&g_(l,u),ov!==null&&ov(l,u)};var so=K(null);function Vh(){var l=so.current;return l!==null?l:Nn.pooledCache}function _d(l,u){u===null?q(so,so.current):q(so,u.pool)}function lv(){var l=Vh();return l===null?null:{parent:ns._currentValue,pool:l}}var cl=Error(s(460)),Yh=Error(s(474)),Ed=Error(s(542)),Md={then:function(){}};function cv(l){return l=l.status,l==="fulfilled"||l==="rejected"}function uv(l,u,p){switch(p=l[p],p===void 0?l.push(u):p!==u&&(u.then(It,It),u=p),u.status){case"fulfilled":return u.value;case"rejected":throw l=u.reason,fv(l),l;default:if(typeof u.status=="string")u.then(It,It);else{if(l=Nn,l!==null&&100<l.shellSuspendCounter)throw Error(s(482));l=u,l.status="pending",l.then(function(g){if(u.status==="pending"){var v=u;v.status="fulfilled",v.value=g}},function(g){if(u.status==="pending"){var v=u;v.status="rejected",v.reason=g}})}switch(u.status){case"fulfilled":return u.value;case"rejected":throw l=u.reason,fv(l),l}throw ro=u,cl}}function ao(l){try{var u=l._init;return u(l._payload)}catch(p){throw p!==null&&typeof p=="object"&&typeof p.then=="function"?(ro=p,cl):p}}var ro=null;function dv(){if(ro===null)throw Error(s(459));var l=ro;return ro=null,l}function fv(l){if(l===cl||l===Ed)throw Error(s(483))}var ul=null,Cc=0;function Dd(l){var u=Cc;return Cc+=1,ul===null&&(ul=[]),uv(ul,l,u)}function Ac(l,u){u=u.props.ref,l.ref=u!==void 0?u:null}function Rd(l,u){throw u.$$typeof===b?Error(s(525)):(l=Object.prototype.toString.call(u),Error(s(31,l==="[object Object]"?"object with keys {"+Object.keys(u).join(", ")+"}":l)))}function pv(l){function u(we,le){if(l){var _e=we.deletions;_e===null?(we.deletions=[le],we.flags|=16):_e.push(le)}}function p(we,le){if(!l)return null;for(;le!==null;)u(we,le),le=le.sibling;return null}function g(we){for(var le=new Map;we!==null;)we.key!==null?le.set(we.key,we):le.set(we.index,we),we=we.sibling;return le}function v(we,le){return we=yr(we,le),we.index=0,we.sibling=null,we}function A(we,le,_e){return we.index=_e,l?(_e=we.alternate,_e!==null?(_e=_e.index,_e<le?(we.flags|=67108866,le):_e):(we.flags|=67108866,le)):(we.flags|=1048576,le)}function P(we){return l&&we.alternate===null&&(we.flags|=67108866),we}function Y(we,le,_e,Ge){return le===null||le.tag!==6?(le=Lh(_e,we.mode,Ge),le.return=we,le):(le=v(le,_e),le.return=we,le)}function re(we,le,_e,Ge){var Tt=_e.type;return Tt===C?qe(we,le,_e.props.children,Ge,_e.key):le!==null&&(le.elementType===Tt||typeof Tt=="object"&&Tt!==null&&Tt.$$typeof===O&&ao(Tt)===le.type)?(le=v(le,_e.props),Ac(le,_e),le.return=we,le):(le=Ad(_e.type,_e.key,_e.props,null,we.mode,Ge),Ac(le,_e),le.return=we,le)}function De(we,le,_e,Ge){return le===null||le.tag!==4||le.stateNode.containerInfo!==_e.containerInfo||le.stateNode.implementation!==_e.implementation?(le=Ih(_e,we.mode,Ge),le.return=we,le):(le=v(le,_e.children||[]),le.return=we,le)}function qe(we,le,_e,Ge,Tt){return le===null||le.tag!==7?(le=Zi(_e,we.mode,Ge,Tt),le.return=we,le):(le=v(le,_e),le.return=we,le)}function Qe(we,le,_e){if(typeof le=="string"&&le!==""||typeof le=="number"||typeof le=="bigint")return le=Lh(""+le,we.mode,_e),le.return=we,le;if(typeof le=="object"&&le!==null){switch(le.$$typeof){case y:return _e=Ad(le.type,le.key,le.props,null,we.mode,_e),Ac(_e,le),_e.return=we,_e;case w:return le=Ih(le,we.mode,_e),le.return=we,le;case O:return le=ao(le),Qe(we,le,_e)}if(L(le)||z(le))return le=Zi(le,we.mode,_e,null),le.return=we,le;if(typeof le.then=="function")return Qe(we,Dd(le),_e);if(le.$$typeof===S)return Qe(we,Td(we,le),_e);Rd(we,le)}return null}function Ie(we,le,_e,Ge){var Tt=le!==null?le.key:null;if(typeof _e=="string"&&_e!==""||typeof _e=="number"||typeof _e=="bigint")return Tt!==null?null:Y(we,le,""+_e,Ge);if(typeof _e=="object"&&_e!==null){switch(_e.$$typeof){case y:return _e.key===Tt?re(we,le,_e,Ge):null;case w:return _e.key===Tt?De(we,le,_e,Ge):null;case O:return _e=ao(_e),Ie(we,le,_e,Ge)}if(L(_e)||z(_e))return Tt!==null?null:qe(we,le,_e,Ge,null);if(typeof _e.then=="function")return Ie(we,le,Dd(_e),Ge);if(_e.$$typeof===S)return Ie(we,le,Td(we,_e),Ge);Rd(we,_e)}return null}function Ue(we,le,_e,Ge,Tt){if(typeof Ge=="string"&&Ge!==""||typeof Ge=="number"||typeof Ge=="bigint")return we=we.get(_e)||null,Y(le,we,""+Ge,Tt);if(typeof Ge=="object"&&Ge!==null){switch(Ge.$$typeof){case y:return we=we.get(Ge.key===null?_e:Ge.key)||null,re(le,we,Ge,Tt);case w:return we=we.get(Ge.key===null?_e:Ge.key)||null,De(le,we,Ge,Tt);case O:return Ge=ao(Ge),Ue(we,le,_e,Ge,Tt)}if(L(Ge)||z(Ge))return we=we.get(_e)||null,qe(le,we,Ge,Tt,null);if(typeof Ge.then=="function")return Ue(we,le,_e,Dd(Ge),Tt);if(Ge.$$typeof===S)return Ue(we,le,_e,Td(le,Ge),Tt);Rd(le,Ge)}return null}function yt(we,le,_e,Ge){for(var Tt=null,fn=null,kt=le,Ht=le=0,rn=null;kt!==null&&Ht<_e.length;Ht++){kt.index>Ht?(rn=kt,kt=null):rn=kt.sibling;var pn=Ie(we,kt,_e[Ht],Ge);if(pn===null){kt===null&&(kt=rn);break}l&&kt&&pn.alternate===null&&u(we,kt),le=A(pn,le,Ht),fn===null?Tt=pn:fn.sibling=pn,fn=pn,kt=rn}if(Ht===_e.length)return p(we,kt),cn&&vr(we,Ht),Tt;if(kt===null){for(;Ht<_e.length;Ht++)kt=Qe(we,_e[Ht],Ge),kt!==null&&(le=A(kt,le,Ht),fn===null?Tt=kt:fn.sibling=kt,fn=kt);return cn&&vr(we,Ht),Tt}for(kt=g(kt);Ht<_e.length;Ht++)rn=Ue(kt,we,Ht,_e[Ht],Ge),rn!==null&&(l&&rn.alternate!==null&&kt.delete(rn.key===null?Ht:rn.key),le=A(rn,le,Ht),fn===null?Tt=rn:fn.sibling=rn,fn=rn);return l&&kt.forEach(function(Si){return u(we,Si)}),cn&&vr(we,Ht),Tt}function Dt(we,le,_e,Ge){if(_e==null)throw Error(s(151));for(var Tt=null,fn=null,kt=le,Ht=le=0,rn=null,pn=_e.next();kt!==null&&!pn.done;Ht++,pn=_e.next()){kt.index>Ht?(rn=kt,kt=null):rn=kt.sibling;var Si=Ie(we,kt,pn.value,Ge);if(Si===null){kt===null&&(kt=rn);break}l&&kt&&Si.alternate===null&&u(we,kt),le=A(Si,le,Ht),fn===null?Tt=Si:fn.sibling=Si,fn=Si,kt=rn}if(pn.done)return p(we,kt),cn&&vr(we,Ht),Tt;if(kt===null){for(;!pn.done;Ht++,pn=_e.next())pn=Qe(we,pn.value,Ge),pn!==null&&(le=A(pn,le,Ht),fn===null?Tt=pn:fn.sibling=pn,fn=pn);return cn&&vr(we,Ht),Tt}for(kt=g(kt);!pn.done;Ht++,pn=_e.next())pn=Ue(kt,we,Ht,pn.value,Ge),pn!==null&&(l&&pn.alternate!==null&&kt.delete(pn.key===null?Ht:pn.key),le=A(pn,le,Ht),fn===null?Tt=pn:fn.sibling=pn,fn=pn);return l&&kt.forEach(function(TE){return u(we,TE)}),cn&&vr(we,Ht),Tt}function An(we,le,_e,Ge){if(typeof _e=="object"&&_e!==null&&_e.type===C&&_e.key===null&&(_e=_e.props.children),typeof _e=="object"&&_e!==null){switch(_e.$$typeof){case y:e:{for(var Tt=_e.key;le!==null;){if(le.key===Tt){if(Tt=_e.type,Tt===C){if(le.tag===7){p(we,le.sibling),Ge=v(le,_e.props.children),Ge.return=we,we=Ge;break e}}else if(le.elementType===Tt||typeof Tt=="object"&&Tt!==null&&Tt.$$typeof===O&&ao(Tt)===le.type){p(we,le.sibling),Ge=v(le,_e.props),Ac(Ge,_e),Ge.return=we,we=Ge;break e}p(we,le);break}else u(we,le);le=le.sibling}_e.type===C?(Ge=Zi(_e.props.children,we.mode,Ge,_e.key),Ge.return=we,we=Ge):(Ge=Ad(_e.type,_e.key,_e.props,null,we.mode,Ge),Ac(Ge,_e),Ge.return=we,we=Ge)}return P(we);case w:e:{for(Tt=_e.key;le!==null;){if(le.key===Tt)if(le.tag===4&&le.stateNode.containerInfo===_e.containerInfo&&le.stateNode.implementation===_e.implementation){p(we,le.sibling),Ge=v(le,_e.children||[]),Ge.return=we,we=Ge;break e}else{p(we,le);break}else u(we,le);le=le.sibling}Ge=Ih(_e,we.mode,Ge),Ge.return=we,we=Ge}return P(we);case O:return _e=ao(_e),An(we,le,_e,Ge)}if(L(_e))return yt(we,le,_e,Ge);if(z(_e)){if(Tt=z(_e),typeof Tt!="function")throw Error(s(150));return _e=Tt.call(_e),Dt(we,le,_e,Ge)}if(typeof _e.then=="function")return An(we,le,Dd(_e),Ge);if(_e.$$typeof===S)return An(we,le,Td(we,_e),Ge);Rd(we,_e)}return typeof _e=="string"&&_e!==""||typeof _e=="number"||typeof _e=="bigint"?(_e=""+_e,le!==null&&le.tag===6?(p(we,le.sibling),Ge=v(le,_e),Ge.return=we,we=Ge):(p(we,le),Ge=Lh(_e,we.mode,Ge),Ge.return=we,we=Ge),P(we)):p(we,le)}return function(we,le,_e,Ge){try{Cc=0;var Tt=An(we,le,_e,Ge);return ul=null,Tt}catch(kt){if(kt===cl||kt===Ed)throw kt;var fn=Zs(29,kt,null,we.mode);return fn.lanes=Ge,fn.return=we,fn}finally{}}}var io=pv(!0),hv=pv(!1),ii=!1;function Gh(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Kh(l,u){l=l.updateQueue,u.updateQueue===l&&(u.updateQueue={baseState:l.baseState,firstBaseUpdate:l.firstBaseUpdate,lastBaseUpdate:l.lastBaseUpdate,shared:l.shared,callbacks:null})}function oi(l){return{lane:l,tag:0,payload:null,callback:null,next:null}}function li(l,u,p){var g=l.updateQueue;if(g===null)return null;if(g=g.shared,(hn&2)!==0){var v=g.pending;return v===null?u.next=u:(u.next=v.next,v.next=u),g.pending=u,u=Cd(l),Xy(l,null,p),u}return Sd(l,g,u,p),Cd(l)}function jc(l,u,p){if(u=u.updateQueue,u!==null&&(u=u.shared,(p&4194048)!==0)){var g=u.lanes;g&=l.pendingLanes,p|=g,u.lanes=p,Ot(l,p)}}function Qh(l,u){var p=l.updateQueue,g=l.alternate;if(g!==null&&(g=g.updateQueue,p===g)){var v=null,A=null;if(p=p.firstBaseUpdate,p!==null){do{var P={lane:p.lane,tag:p.tag,payload:p.payload,callback:null,next:null};A===null?v=A=P:A=A.next=P,p=p.next}while(p!==null);A===null?v=A=u:A=A.next=u}else v=A=u;p={baseState:g.baseState,firstBaseUpdate:v,lastBaseUpdate:A,shared:g.shared,callbacks:g.callbacks},l.updateQueue=p;return}l=p.lastBaseUpdate,l===null?p.firstBaseUpdate=u:l.next=u,p.lastBaseUpdate=u}var Xh=!1;function Nc(){if(Xh){var l=ll;if(l!==null)throw l}}function Tc(l,u,p,g){Xh=!1;var v=l.updateQueue;ii=!1;var A=v.firstBaseUpdate,P=v.lastBaseUpdate,Y=v.shared.pending;if(Y!==null){v.shared.pending=null;var re=Y,De=re.next;re.next=null,P===null?A=De:P.next=De,P=re;var qe=l.alternate;qe!==null&&(qe=qe.updateQueue,Y=qe.lastBaseUpdate,Y!==P&&(Y===null?qe.firstBaseUpdate=De:Y.next=De,qe.lastBaseUpdate=re))}if(A!==null){var Qe=v.baseState;P=0,qe=De=re=null,Y=A;do{var Ie=Y.lane&-536870913,Ue=Ie!==Y.lane;if(Ue?(an&Ie)===Ie:(g&Ie)===Ie){Ie!==0&&Ie===ol&&(Xh=!0),qe!==null&&(qe=qe.next={lane:0,tag:Y.tag,payload:Y.payload,callback:null,next:null});e:{var yt=l,Dt=Y;Ie=u;var An=p;switch(Dt.tag){case 1:if(yt=Dt.payload,typeof yt=="function"){Qe=yt.call(An,Qe,Ie);break e}Qe=yt;break e;case 3:yt.flags=yt.flags&-65537|128;case 0:if(yt=Dt.payload,Ie=typeof yt=="function"?yt.call(An,Qe,Ie):yt,Ie==null)break e;Qe=m({},Qe,Ie);break e;case 2:ii=!0}}Ie=Y.callback,Ie!==null&&(l.flags|=64,Ue&&(l.flags|=8192),Ue=v.callbacks,Ue===null?v.callbacks=[Ie]:Ue.push(Ie))}else Ue={lane:Ie,tag:Y.tag,payload:Y.payload,callback:Y.callback,next:null},qe===null?(De=qe=Ue,re=Qe):qe=qe.next=Ue,P|=Ie;if(Y=Y.next,Y===null){if(Y=v.shared.pending,Y===null)break;Ue=Y,Y=Ue.next,Ue.next=null,v.lastBaseUpdate=Ue,v.shared.pending=null}}while(!0);qe===null&&(re=Qe),v.baseState=re,v.firstBaseUpdate=De,v.lastBaseUpdate=qe,A===null&&(v.shared.lanes=0),pi|=P,l.lanes=P,l.memoizedState=Qe}}function mv(l,u){if(typeof l!="function")throw Error(s(191,l));l.call(u)}function gv(l,u){var p=l.callbacks;if(p!==null)for(l.callbacks=null,l=0;l<p.length;l++)mv(p[l],u)}var dl=K(null),Od=K(0);function bv(l,u){l=Mr,q(Od,l),q(dl,u),Mr=l|u.baseLanes}function Jh(){q(Od,Mr),q(dl,dl.current)}function Zh(){Mr=Od.current,se(dl),se(Od)}var ea=K(null),wa=null;function ci(l){var u=l.alternate;q(Xn,Xn.current&1),q(ea,l),wa===null&&(u===null||dl.current!==null||u.memoizedState!==null)&&(wa=l)}function em(l){q(Xn,Xn.current),q(ea,l),wa===null&&(wa=l)}function xv(l){l.tag===22?(q(Xn,Xn.current),q(ea,l),wa===null&&(wa=l)):ui()}function ui(){q(Xn,Xn.current),q(ea,ea.current)}function ta(l){se(ea),wa===l&&(wa=null),se(Xn)}var Xn=K(0);function Ld(l){for(var u=l;u!==null;){if(u.tag===13){var p=u.memoizedState;if(p!==null&&(p=p.dehydrated,p===null||ig(p)||og(p)))return u}else if(u.tag===19&&(u.memoizedProps.revealOrder==="forwards"||u.memoizedProps.revealOrder==="backwards"||u.memoizedProps.revealOrder==="unstable_legacy-backwards"||u.memoizedProps.revealOrder==="together")){if((u.flags&128)!==0)return u}else if(u.child!==null){u.child.return=u,u=u.child;continue}if(u===l)break;for(;u.sibling===null;){if(u.return===null||u.return===l)return null;u=u.return}u.sibling.return=u.return,u=u.sibling}return null}var Sr=0,Ut=null,Sn=null,ss=null,Id=!1,fl=!1,oo=!1,Pd=0,_c=0,pl=null,x_=0;function Vn(){throw Error(s(321))}function tm(l,u){if(u===null)return!1;for(var p=0;p<u.length&&p<l.length;p++)if(!Js(l[p],u[p]))return!1;return!0}function nm(l,u,p,g,v,A){return Sr=A,Ut=u,u.memoizedState=null,u.updateQueue=null,u.lanes=0,F.H=l===null||l.memoizedState===null?tw:bm,oo=!1,A=p(g,v),oo=!1,fl&&(A=vv(u,p,g,v)),yv(l),A}function yv(l){F.H=Dc;var u=Sn!==null&&Sn.next!==null;if(Sr=0,ss=Sn=Ut=null,Id=!1,_c=0,pl=null,u)throw Error(s(300));l===null||as||(l=l.dependencies,l!==null&&Nd(l)&&(as=!0))}function vv(l,u,p,g){Ut=l;var v=0;do{if(fl&&(pl=null),_c=0,fl=!1,25<=v)throw Error(s(301));if(v+=1,ss=Sn=null,l.updateQueue!=null){var A=l.updateQueue;A.lastEffect=null,A.events=null,A.stores=null,A.memoCache!=null&&(A.memoCache.index=0)}F.H=nw,A=u(p,g)}while(fl);return A}function y_(){var l=F.H,u=l.useState()[0];return u=typeof u.then=="function"?Ec(u):u,l=l.useState()[0],(Sn!==null?Sn.memoizedState:null)!==l&&(Ut.flags|=1024),u}function sm(){var l=Pd!==0;return Pd=0,l}function am(l,u,p){u.updateQueue=l.updateQueue,u.flags&=-2053,l.lanes&=~p}function rm(l){if(Id){for(l=l.memoizedState;l!==null;){var u=l.queue;u!==null&&(u.pending=null),l=l.next}Id=!1}Sr=0,ss=Sn=Ut=null,fl=!1,_c=Pd=0,pl=null}function _s(){var l={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ss===null?Ut.memoizedState=ss=l:ss=ss.next=l,ss}function Jn(){if(Sn===null){var l=Ut.alternate;l=l!==null?l.memoizedState:null}else l=Sn.next;var u=ss===null?Ut.memoizedState:ss.next;if(u!==null)ss=u,Sn=l;else{if(l===null)throw Ut.alternate===null?Error(s(467)):Error(s(310));Sn=l,l={memoizedState:Sn.memoizedState,baseState:Sn.baseState,baseQueue:Sn.baseQueue,queue:Sn.queue,next:null},ss===null?Ut.memoizedState=ss=l:ss=ss.next=l}return ss}function Bd(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ec(l){var u=_c;return _c+=1,pl===null&&(pl=[]),l=uv(pl,l,u),u=Ut,(ss===null?u.memoizedState:ss.next)===null&&(u=u.alternate,F.H=u===null||u.memoizedState===null?tw:bm),l}function Fd(l){if(l!==null&&typeof l=="object"){if(typeof l.then=="function")return Ec(l);if(l.$$typeof===S)return bs(l)}throw Error(s(438,String(l)))}function im(l){var u=null,p=Ut.updateQueue;if(p!==null&&(u=p.memoCache),u==null){var g=Ut.alternate;g!==null&&(g=g.updateQueue,g!==null&&(g=g.memoCache,g!=null&&(u={data:g.data.map(function(v){return v.slice()}),index:0})))}if(u==null&&(u={data:[],index:0}),p===null&&(p=Bd(),Ut.updateQueue=p),p.memoCache=u,p=u.data[u.index],p===void 0)for(p=u.data[u.index]=Array(l),g=0;g<l;g++)p[g]=M;return u.index++,p}function Cr(l,u){return typeof u=="function"?u(l):u}function zd(l){var u=Jn();return om(u,Sn,l)}function om(l,u,p){var g=l.queue;if(g===null)throw Error(s(311));g.lastRenderedReducer=p;var v=l.baseQueue,A=g.pending;if(A!==null){if(v!==null){var P=v.next;v.next=A.next,A.next=P}u.baseQueue=v=A,g.pending=null}if(A=l.baseState,v===null)l.memoizedState=A;else{u=v.next;var Y=P=null,re=null,De=u,qe=!1;do{var Qe=De.lane&-536870913;if(Qe!==De.lane?(an&Qe)===Qe:(Sr&Qe)===Qe){var Ie=De.revertLane;if(Ie===0)re!==null&&(re=re.next={lane:0,revertLane:0,gesture:null,action:De.action,hasEagerState:De.hasEagerState,eagerState:De.eagerState,next:null}),Qe===ol&&(qe=!0);else if((Sr&Ie)===Ie){De=De.next,Ie===ol&&(qe=!0);continue}else Qe={lane:0,revertLane:De.revertLane,gesture:null,action:De.action,hasEagerState:De.hasEagerState,eagerState:De.eagerState,next:null},re===null?(Y=re=Qe,P=A):re=re.next=Qe,Ut.lanes|=Ie,pi|=Ie;Qe=De.action,oo&&p(A,Qe),A=De.hasEagerState?De.eagerState:p(A,Qe)}else Ie={lane:Qe,revertLane:De.revertLane,gesture:De.gesture,action:De.action,hasEagerState:De.hasEagerState,eagerState:De.eagerState,next:null},re===null?(Y=re=Ie,P=A):re=re.next=Ie,Ut.lanes|=Qe,pi|=Qe;De=De.next}while(De!==null&&De!==u);if(re===null?P=A:re.next=Y,!Js(A,l.memoizedState)&&(as=!0,qe&&(p=ll,p!==null)))throw p;l.memoizedState=A,l.baseState=P,l.baseQueue=re,g.lastRenderedState=A}return v===null&&(g.lanes=0),[l.memoizedState,g.dispatch]}function lm(l){var u=Jn(),p=u.queue;if(p===null)throw Error(s(311));p.lastRenderedReducer=l;var g=p.dispatch,v=p.pending,A=u.memoizedState;if(v!==null){p.pending=null;var P=v=v.next;do A=l(A,P.action),P=P.next;while(P!==v);Js(A,u.memoizedState)||(as=!0),u.memoizedState=A,u.baseQueue===null&&(u.baseState=A),p.lastRenderedState=A}return[A,g]}function wv(l,u,p){var g=Ut,v=Jn(),A=cn;if(A){if(p===void 0)throw Error(s(407));p=p()}else p=u();var P=!Js((Sn||v).memoizedState,p);if(P&&(v.memoizedState=p,as=!0),v=v.queue,dm(Cv.bind(null,g,v,l),[l]),v.getSnapshot!==u||P||ss!==null&&ss.memoizedState.tag&1){if(g.flags|=2048,hl(9,{destroy:void 0},Sv.bind(null,g,v,p,u),null),Nn===null)throw Error(s(349));A||(Sr&127)!==0||kv(g,u,p)}return p}function kv(l,u,p){l.flags|=16384,l={getSnapshot:u,value:p},u=Ut.updateQueue,u===null?(u=Bd(),Ut.updateQueue=u,u.stores=[l]):(p=u.stores,p===null?u.stores=[l]:p.push(l))}function Sv(l,u,p,g){u.value=p,u.getSnapshot=g,Av(u)&&jv(l)}function Cv(l,u,p){return p(function(){Av(u)&&jv(l)})}function Av(l){var u=l.getSnapshot;l=l.value;try{var p=u();return!Js(l,p)}catch{return!0}}function jv(l){var u=Ji(l,2);u!==null&&qs(u,l,2)}function cm(l){var u=_s();if(typeof l=="function"){var p=l;if(l=p(),oo){te(!0);try{p()}finally{te(!1)}}}return u.memoizedState=u.baseState=l,u.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Cr,lastRenderedState:l},u}function Nv(l,u,p,g){return l.baseState=p,om(l,Sn,typeof g=="function"?g:Cr)}function v_(l,u,p,g,v){if(Hd(l))throw Error(s(485));if(l=u.action,l!==null){var A={payload:v,action:l,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(P){A.listeners.push(P)}};F.T!==null?p(!0):A.isTransition=!1,g(A),p=u.pending,p===null?(A.next=u.pending=A,Tv(u,A)):(A.next=p.next,u.pending=p.next=A)}}function Tv(l,u){var p=u.action,g=u.payload,v=l.state;if(u.isTransition){var A=F.T,P={};F.T=P;try{var Y=p(v,g),re=F.S;re!==null&&re(P,Y),_v(l,u,Y)}catch(De){um(l,u,De)}finally{A!==null&&P.types!==null&&(A.types=P.types),F.T=A}}else try{A=p(v,g),_v(l,u,A)}catch(De){um(l,u,De)}}function _v(l,u,p){p!==null&&typeof p=="object"&&typeof p.then=="function"?p.then(function(g){Ev(l,u,g)},function(g){return um(l,u,g)}):Ev(l,u,p)}function Ev(l,u,p){u.status="fulfilled",u.value=p,Mv(u),l.state=p,u=l.pending,u!==null&&(p=u.next,p===u?l.pending=null:(p=p.next,u.next=p,Tv(l,p)))}function um(l,u,p){var g=l.pending;if(l.pending=null,g!==null){g=g.next;do u.status="rejected",u.reason=p,Mv(u),u=u.next;while(u!==g)}l.action=null}function Mv(l){l=l.listeners;for(var u=0;u<l.length;u++)(0,l[u])()}function Dv(l,u){return u}function Rv(l,u){if(cn){var p=Nn.formState;if(p!==null){e:{var g=Ut;if(cn){if(In){t:{for(var v=In,A=va;v.nodeType!==8;){if(!A){v=null;break t}if(v=ka(v.nextSibling),v===null){v=null;break t}}A=v.data,v=A==="F!"||A==="F"?v:null}if(v){In=ka(v.nextSibling),g=v.data==="F!";break e}}ai(g)}g=!1}g&&(u=p[0])}}return p=_s(),p.memoizedState=p.baseState=u,g={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Dv,lastRenderedState:u},p.queue=g,p=Jv.bind(null,Ut,g),g.dispatch=p,g=cm(!1),A=gm.bind(null,Ut,!1,g.queue),g=_s(),v={state:u,dispatch:null,action:l,pending:null},g.queue=v,p=v_.bind(null,Ut,v,A,p),v.dispatch=p,g.memoizedState=l,[u,p,!1]}function Ov(l){var u=Jn();return Lv(u,Sn,l)}function Lv(l,u,p){if(u=om(l,u,Dv)[0],l=zd(Cr)[0],typeof u=="object"&&u!==null&&typeof u.then=="function")try{var g=Ec(u)}catch(P){throw P===cl?Ed:P}else g=u;u=Jn();var v=u.queue,A=v.dispatch;return p!==u.memoizedState&&(Ut.flags|=2048,hl(9,{destroy:void 0},w_.bind(null,v,p),null)),[g,A,l]}function w_(l,u){l.action=u}function Iv(l){var u=Jn(),p=Sn;if(p!==null)return Lv(u,p,l);Jn(),u=u.memoizedState,p=Jn();var g=p.queue.dispatch;return p.memoizedState=l,[u,g,!1]}function hl(l,u,p,g){return l={tag:l,create:p,deps:g,inst:u,next:null},u=Ut.updateQueue,u===null&&(u=Bd(),Ut.updateQueue=u),p=u.lastEffect,p===null?u.lastEffect=l.next=l:(g=p.next,p.next=l,l.next=g,u.lastEffect=l),l}function Pv(){return Jn().memoizedState}function $d(l,u,p,g){var v=_s();Ut.flags|=l,v.memoizedState=hl(1|u,{destroy:void 0},p,g===void 0?null:g)}function Ud(l,u,p,g){var v=Jn();g=g===void 0?null:g;var A=v.memoizedState.inst;Sn!==null&&g!==null&&tm(g,Sn.memoizedState.deps)?v.memoizedState=hl(u,A,p,g):(Ut.flags|=l,v.memoizedState=hl(1|u,A,p,g))}function Bv(l,u){$d(8390656,8,l,u)}function dm(l,u){Ud(2048,8,l,u)}function k_(l){Ut.flags|=4;var u=Ut.updateQueue;if(u===null)u=Bd(),Ut.updateQueue=u,u.events=[l];else{var p=u.events;p===null?u.events=[l]:p.push(l)}}function Fv(l){var u=Jn().memoizedState;return k_({ref:u,nextImpl:l}),function(){if((hn&2)!==0)throw Error(s(440));return u.impl.apply(void 0,arguments)}}function zv(l,u){return Ud(4,2,l,u)}function $v(l,u){return Ud(4,4,l,u)}function Uv(l,u){if(typeof u=="function"){l=l();var p=u(l);return function(){typeof p=="function"?p():u(null)}}if(u!=null)return l=l(),u.current=l,function(){u.current=null}}function Hv(l,u,p){p=p!=null?p.concat([l]):null,Ud(4,4,Uv.bind(null,u,l),p)}function fm(){}function Wv(l,u){var p=Jn();u=u===void 0?null:u;var g=p.memoizedState;return u!==null&&tm(u,g[1])?g[0]:(p.memoizedState=[l,u],l)}function qv(l,u){var p=Jn();u=u===void 0?null:u;var g=p.memoizedState;if(u!==null&&tm(u,g[1]))return g[0];if(g=l(),oo){te(!0);try{l()}finally{te(!1)}}return p.memoizedState=[g,u],g}function pm(l,u,p){return p===void 0||(Sr&1073741824)!==0&&(an&261930)===0?l.memoizedState=u:(l.memoizedState=p,l=Vw(),Ut.lanes|=l,pi|=l,p)}function Vv(l,u,p,g){return Js(p,u)?p:dl.current!==null?(l=pm(l,p,g),Js(l,u)||(as=!0),l):(Sr&42)===0||(Sr&1073741824)!==0&&(an&261930)===0?(as=!0,l.memoizedState=p):(l=Vw(),Ut.lanes|=l,pi|=l,u)}function Yv(l,u,p,g,v){var A=H.p;H.p=A!==0&&8>A?A:8;var P=F.T,Y={};F.T=Y,gm(l,!1,u,p);try{var re=v(),De=F.S;if(De!==null&&De(Y,re),re!==null&&typeof re=="object"&&typeof re.then=="function"){var qe=b_(re,g);Mc(l,u,qe,aa(l))}else Mc(l,u,g,aa(l))}catch(Qe){Mc(l,u,{then:function(){},status:"rejected",reason:Qe},aa())}finally{H.p=A,P!==null&&Y.types!==null&&(P.types=Y.types),F.T=P}}function S_(){}function hm(l,u,p,g){if(l.tag!==5)throw Error(s(476));var v=Gv(l).queue;Yv(l,v,u,V,p===null?S_:function(){return Kv(l),p(g)})}function Gv(l){var u=l.memoizedState;if(u!==null)return u;u={memoizedState:V,baseState:V,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Cr,lastRenderedState:V},next:null};var p={};return u.next={memoizedState:p,baseState:p,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Cr,lastRenderedState:p},next:null},l.memoizedState=u,l=l.alternate,l!==null&&(l.memoizedState=u),u}function Kv(l){var u=Gv(l);u.next===null&&(u=l.alternate.memoizedState),Mc(l,u.next.queue,{},aa())}function mm(){return bs(Gc)}function Qv(){return Jn().memoizedState}function Xv(){return Jn().memoizedState}function C_(l){for(var u=l.return;u!==null;){switch(u.tag){case 24:case 3:var p=aa();l=oi(p);var g=li(u,l,p);g!==null&&(qs(g,u,p),jc(g,u,p)),u={cache:Wh()},l.payload=u;return}u=u.return}}function A_(l,u,p){var g=aa();p={lane:g,revertLane:0,gesture:null,action:p,hasEagerState:!1,eagerState:null,next:null},Hd(l)?Zv(u,p):(p=Rh(l,u,p,g),p!==null&&(qs(p,l,g),ew(p,u,g)))}function Jv(l,u,p){var g=aa();Mc(l,u,p,g)}function Mc(l,u,p,g){var v={lane:g,revertLane:0,gesture:null,action:p,hasEagerState:!1,eagerState:null,next:null};if(Hd(l))Zv(u,v);else{var A=l.alternate;if(l.lanes===0&&(A===null||A.lanes===0)&&(A=u.lastRenderedReducer,A!==null))try{var P=u.lastRenderedState,Y=A(P,p);if(v.hasEagerState=!0,v.eagerState=Y,Js(Y,P))return Sd(l,u,v,0),Nn===null&&kd(),!1}catch{}finally{}if(p=Rh(l,u,v,g),p!==null)return qs(p,l,g),ew(p,u,g),!0}return!1}function gm(l,u,p,g){if(g={lane:2,revertLane:Gm(),gesture:null,action:g,hasEagerState:!1,eagerState:null,next:null},Hd(l)){if(u)throw Error(s(479))}else u=Rh(l,p,g,2),u!==null&&qs(u,l,2)}function Hd(l){var u=l.alternate;return l===Ut||u!==null&&u===Ut}function Zv(l,u){fl=Id=!0;var p=l.pending;p===null?u.next=u:(u.next=p.next,p.next=u),l.pending=u}function ew(l,u,p){if((p&4194048)!==0){var g=u.lanes;g&=l.pendingLanes,p|=g,u.lanes=p,Ot(l,p)}}var Dc={readContext:bs,use:Fd,useCallback:Vn,useContext:Vn,useEffect:Vn,useImperativeHandle:Vn,useLayoutEffect:Vn,useInsertionEffect:Vn,useMemo:Vn,useReducer:Vn,useRef:Vn,useState:Vn,useDebugValue:Vn,useDeferredValue:Vn,useTransition:Vn,useSyncExternalStore:Vn,useId:Vn,useHostTransitionStatus:Vn,useFormState:Vn,useActionState:Vn,useOptimistic:Vn,useMemoCache:Vn,useCacheRefresh:Vn};Dc.useEffectEvent=Vn;var tw={readContext:bs,use:Fd,useCallback:function(l,u){return _s().memoizedState=[l,u===void 0?null:u],l},useContext:bs,useEffect:Bv,useImperativeHandle:function(l,u,p){p=p!=null?p.concat([l]):null,$d(4194308,4,Uv.bind(null,u,l),p)},useLayoutEffect:function(l,u){return $d(4194308,4,l,u)},useInsertionEffect:function(l,u){$d(4,2,l,u)},useMemo:function(l,u){var p=_s();u=u===void 0?null:u;var g=l();if(oo){te(!0);try{l()}finally{te(!1)}}return p.memoizedState=[g,u],g},useReducer:function(l,u,p){var g=_s();if(p!==void 0){var v=p(u);if(oo){te(!0);try{p(u)}finally{te(!1)}}}else v=u;return g.memoizedState=g.baseState=v,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:v},g.queue=l,l=l.dispatch=A_.bind(null,Ut,l),[g.memoizedState,l]},useRef:function(l){var u=_s();return l={current:l},u.memoizedState=l},useState:function(l){l=cm(l);var u=l.queue,p=Jv.bind(null,Ut,u);return u.dispatch=p,[l.memoizedState,p]},useDebugValue:fm,useDeferredValue:function(l,u){var p=_s();return pm(p,l,u)},useTransition:function(){var l=cm(!1);return l=Yv.bind(null,Ut,l.queue,!0,!1),_s().memoizedState=l,[!1,l]},useSyncExternalStore:function(l,u,p){var g=Ut,v=_s();if(cn){if(p===void 0)throw Error(s(407));p=p()}else{if(p=u(),Nn===null)throw Error(s(349));(an&127)!==0||kv(g,u,p)}v.memoizedState=p;var A={value:p,getSnapshot:u};return v.queue=A,Bv(Cv.bind(null,g,A,l),[l]),g.flags|=2048,hl(9,{destroy:void 0},Sv.bind(null,g,A,p,u),null),p},useId:function(){var l=_s(),u=Nn.identifierPrefix;if(cn){var p=Ga,g=Ya;p=(g&~(1<<32-ge(g)-1)).toString(32)+p,u="_"+u+"R_"+p,p=Pd++,0<p&&(u+="H"+p.toString(32)),u+="_"}else p=x_++,u="_"+u+"r_"+p.toString(32)+"_";return l.memoizedState=u},useHostTransitionStatus:mm,useFormState:Rv,useActionState:Rv,useOptimistic:function(l){var u=_s();u.memoizedState=u.baseState=l;var p={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return u.queue=p,u=gm.bind(null,Ut,!0,p),p.dispatch=u,[l,u]},useMemoCache:im,useCacheRefresh:function(){return _s().memoizedState=C_.bind(null,Ut)},useEffectEvent:function(l){var u=_s(),p={impl:l};return u.memoizedState=p,function(){if((hn&2)!==0)throw Error(s(440));return p.impl.apply(void 0,arguments)}}},bm={readContext:bs,use:Fd,useCallback:Wv,useContext:bs,useEffect:dm,useImperativeHandle:Hv,useInsertionEffect:zv,useLayoutEffect:$v,useMemo:qv,useReducer:zd,useRef:Pv,useState:function(){return zd(Cr)},useDebugValue:fm,useDeferredValue:function(l,u){var p=Jn();return Vv(p,Sn.memoizedState,l,u)},useTransition:function(){var l=zd(Cr)[0],u=Jn().memoizedState;return[typeof l=="boolean"?l:Ec(l),u]},useSyncExternalStore:wv,useId:Qv,useHostTransitionStatus:mm,useFormState:Ov,useActionState:Ov,useOptimistic:function(l,u){var p=Jn();return Nv(p,Sn,l,u)},useMemoCache:im,useCacheRefresh:Xv};bm.useEffectEvent=Fv;var nw={readContext:bs,use:Fd,useCallback:Wv,useContext:bs,useEffect:dm,useImperativeHandle:Hv,useInsertionEffect:zv,useLayoutEffect:$v,useMemo:qv,useReducer:lm,useRef:Pv,useState:function(){return lm(Cr)},useDebugValue:fm,useDeferredValue:function(l,u){var p=Jn();return Sn===null?pm(p,l,u):Vv(p,Sn.memoizedState,l,u)},useTransition:function(){var l=lm(Cr)[0],u=Jn().memoizedState;return[typeof l=="boolean"?l:Ec(l),u]},useSyncExternalStore:wv,useId:Qv,useHostTransitionStatus:mm,useFormState:Iv,useActionState:Iv,useOptimistic:function(l,u){var p=Jn();return Sn!==null?Nv(p,Sn,l,u):(p.baseState=l,[l,p.queue.dispatch])},useMemoCache:im,useCacheRefresh:Xv};nw.useEffectEvent=Fv;function xm(l,u,p,g){u=l.memoizedState,p=p(g,u),p=p==null?u:m({},u,p),l.memoizedState=p,l.lanes===0&&(l.updateQueue.baseState=p)}var ym={enqueueSetState:function(l,u,p){l=l._reactInternals;var g=aa(),v=oi(g);v.payload=u,p!=null&&(v.callback=p),u=li(l,v,g),u!==null&&(qs(u,l,g),jc(u,l,g))},enqueueReplaceState:function(l,u,p){l=l._reactInternals;var g=aa(),v=oi(g);v.tag=1,v.payload=u,p!=null&&(v.callback=p),u=li(l,v,g),u!==null&&(qs(u,l,g),jc(u,l,g))},enqueueForceUpdate:function(l,u){l=l._reactInternals;var p=aa(),g=oi(p);g.tag=2,u!=null&&(g.callback=u),u=li(l,g,p),u!==null&&(qs(u,l,p),jc(u,l,p))}};function sw(l,u,p,g,v,A,P){return l=l.stateNode,typeof l.shouldComponentUpdate=="function"?l.shouldComponentUpdate(g,A,P):u.prototype&&u.prototype.isPureReactComponent?!xc(p,g)||!xc(v,A):!0}function aw(l,u,p,g){l=u.state,typeof u.componentWillReceiveProps=="function"&&u.componentWillReceiveProps(p,g),typeof u.UNSAFE_componentWillReceiveProps=="function"&&u.UNSAFE_componentWillReceiveProps(p,g),u.state!==l&&ym.enqueueReplaceState(u,u.state,null)}function lo(l,u){var p=u;if("ref"in u){p={};for(var g in u)g!=="ref"&&(p[g]=u[g])}if(l=l.defaultProps){p===u&&(p=m({},p));for(var v in l)p[v]===void 0&&(p[v]=l[v])}return p}function rw(l){wd(l)}function iw(l){console.error(l)}function ow(l){wd(l)}function Wd(l,u){try{var p=l.onUncaughtError;p(u.value,{componentStack:u.stack})}catch(g){setTimeout(function(){throw g})}}function lw(l,u,p){try{var g=l.onCaughtError;g(p.value,{componentStack:p.stack,errorBoundary:u.tag===1?u.stateNode:null})}catch(v){setTimeout(function(){throw v})}}function vm(l,u,p){return p=oi(p),p.tag=3,p.payload={element:null},p.callback=function(){Wd(l,u)},p}function cw(l){return l=oi(l),l.tag=3,l}function uw(l,u,p,g){var v=p.type.getDerivedStateFromError;if(typeof v=="function"){var A=g.value;l.payload=function(){return v(A)},l.callback=function(){lw(u,p,g)}}var P=p.stateNode;P!==null&&typeof P.componentDidCatch=="function"&&(l.callback=function(){lw(u,p,g),typeof v!="function"&&(hi===null?hi=new Set([this]):hi.add(this));var Y=g.stack;this.componentDidCatch(g.value,{componentStack:Y!==null?Y:""})})}function j_(l,u,p,g,v){if(p.flags|=32768,g!==null&&typeof g=="object"&&typeof g.then=="function"){if(u=p.alternate,u!==null&&il(u,p,v,!0),p=ea.current,p!==null){switch(p.tag){case 31:case 13:return wa===null?nf():p.alternate===null&&Yn===0&&(Yn=3),p.flags&=-257,p.flags|=65536,p.lanes=v,g===Md?p.flags|=16384:(u=p.updateQueue,u===null?p.updateQueue=new Set([g]):u.add(g),qm(l,g,v)),!1;case 22:return p.flags|=65536,g===Md?p.flags|=16384:(u=p.updateQueue,u===null?(u={transitions:null,markerInstances:null,retryQueue:new Set([g])},p.updateQueue=u):(p=u.retryQueue,p===null?u.retryQueue=new Set([g]):p.add(g)),qm(l,g,v)),!1}throw Error(s(435,p.tag))}return qm(l,g,v),nf(),!1}if(cn)return u=ea.current,u!==null?((u.flags&65536)===0&&(u.flags|=256),u.flags|=65536,u.lanes=v,g!==Fh&&(l=Error(s(422),{cause:g}),wc(ba(l,p)))):(g!==Fh&&(u=Error(s(423),{cause:g}),wc(ba(u,p))),l=l.current.alternate,l.flags|=65536,v&=-v,l.lanes|=v,g=ba(g,p),v=vm(l.stateNode,g,v),Qh(l,v),Yn!==4&&(Yn=2)),!1;var A=Error(s(520),{cause:g});if(A=ba(A,p),zc===null?zc=[A]:zc.push(A),Yn!==4&&(Yn=2),u===null)return!0;g=ba(g,p),p=u;do{switch(p.tag){case 3:return p.flags|=65536,l=v&-v,p.lanes|=l,l=vm(p.stateNode,g,l),Qh(p,l),!1;case 1:if(u=p.type,A=p.stateNode,(p.flags&128)===0&&(typeof u.getDerivedStateFromError=="function"||A!==null&&typeof A.componentDidCatch=="function"&&(hi===null||!hi.has(A))))return p.flags|=65536,v&=-v,p.lanes|=v,v=cw(v),uw(v,l,p,g),Qh(p,v),!1}p=p.return}while(p!==null);return!1}var wm=Error(s(461)),as=!1;function xs(l,u,p,g){u.child=l===null?hv(u,null,p,g):io(u,l.child,p,g)}function dw(l,u,p,g,v){p=p.render;var A=u.ref;if("ref"in g){var P={};for(var Y in g)Y!=="ref"&&(P[Y]=g[Y])}else P=g;return no(u),g=nm(l,u,p,P,A,v),Y=sm(),l!==null&&!as?(am(l,u,v),Ar(l,u,v)):(cn&&Y&&Ph(u),u.flags|=1,xs(l,u,g,v),u.child)}function fw(l,u,p,g,v){if(l===null){var A=p.type;return typeof A=="function"&&!Oh(A)&&A.defaultProps===void 0&&p.compare===null?(u.tag=15,u.type=A,pw(l,u,A,g,v)):(l=Ad(p.type,null,g,u,u.mode,v),l.ref=u.ref,l.return=u,u.child=l)}if(A=l.child,!_m(l,v)){var P=A.memoizedProps;if(p=p.compare,p=p!==null?p:xc,p(P,g)&&l.ref===u.ref)return Ar(l,u,v)}return u.flags|=1,l=yr(A,g),l.ref=u.ref,l.return=u,u.child=l}function pw(l,u,p,g,v){if(l!==null){var A=l.memoizedProps;if(xc(A,g)&&l.ref===u.ref)if(as=!1,u.pendingProps=g=A,_m(l,v))(l.flags&131072)!==0&&(as=!0);else return u.lanes=l.lanes,Ar(l,u,v)}return km(l,u,p,g,v)}function hw(l,u,p,g){var v=g.children,A=l!==null?l.memoizedState:null;if(l===null&&u.stateNode===null&&(u.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),g.mode==="hidden"){if((u.flags&128)!==0){if(A=A!==null?A.baseLanes|p:p,l!==null){for(g=u.child=l.child,v=0;g!==null;)v=v|g.lanes|g.childLanes,g=g.sibling;g=v&~A}else g=0,u.child=null;return mw(l,u,A,p,g)}if((p&536870912)!==0)u.memoizedState={baseLanes:0,cachePool:null},l!==null&&_d(u,A!==null?A.cachePool:null),A!==null?bv(u,A):Jh(),xv(u);else return g=u.lanes=536870912,mw(l,u,A!==null?A.baseLanes|p:p,p,g)}else A!==null?(_d(u,A.cachePool),bv(u,A),ui(),u.memoizedState=null):(l!==null&&_d(u,null),Jh(),ui());return xs(l,u,v,p),u.child}function Rc(l,u){return l!==null&&l.tag===22||u.stateNode!==null||(u.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),u.sibling}function mw(l,u,p,g,v){var A=Vh();return A=A===null?null:{parent:ns._currentValue,pool:A},u.memoizedState={baseLanes:p,cachePool:A},l!==null&&_d(u,null),Jh(),xv(u),l!==null&&il(l,u,g,!0),u.childLanes=v,null}function qd(l,u){return u=Yd({mode:u.mode,children:u.children},l.mode),u.ref=l.ref,l.child=u,u.return=l,u}function gw(l,u,p){return io(u,l.child,null,p),l=qd(u,u.pendingProps),l.flags|=2,ta(u),u.memoizedState=null,l}function N_(l,u,p){var g=u.pendingProps,v=(u.flags&128)!==0;if(u.flags&=-129,l===null){if(cn){if(g.mode==="hidden")return l=qd(u,g),u.lanes=536870912,Rc(null,l);if(em(u),(l=In)?(l=T0(l,va),l=l!==null&&l.data==="&"?l:null,l!==null&&(u.memoizedState={dehydrated:l,treeContext:ni!==null?{id:Ya,overflow:Ga}:null,retryLane:536870912,hydrationErrors:null},p=Zy(l),p.return=u,u.child=p,gs=u,In=null)):l=null,l===null)throw ai(u);return u.lanes=536870912,null}return qd(u,g)}var A=l.memoizedState;if(A!==null){var P=A.dehydrated;if(em(u),v)if(u.flags&256)u.flags&=-257,u=gw(l,u,p);else if(u.memoizedState!==null)u.child=l.child,u.flags|=128,u=null;else throw Error(s(558));else if(as||il(l,u,p,!1),v=(p&l.childLanes)!==0,as||v){if(g=Nn,g!==null&&(P=Ft(g,p),P!==0&&P!==A.retryLane))throw A.retryLane=P,Ji(l,P),qs(g,l,P),wm;nf(),u=gw(l,u,p)}else l=A.treeContext,In=ka(P.nextSibling),gs=u,cn=!0,si=null,va=!1,l!==null&&nv(u,l),u=qd(u,g),u.flags|=4096;return u}return l=yr(l.child,{mode:g.mode,children:g.children}),l.ref=u.ref,u.child=l,l.return=u,l}function Vd(l,u){var p=u.ref;if(p===null)l!==null&&l.ref!==null&&(u.flags|=4194816);else{if(typeof p!="function"&&typeof p!="object")throw Error(s(284));(l===null||l.ref!==p)&&(u.flags|=4194816)}}function km(l,u,p,g,v){return no(u),p=nm(l,u,p,g,void 0,v),g=sm(),l!==null&&!as?(am(l,u,v),Ar(l,u,v)):(cn&&g&&Ph(u),u.flags|=1,xs(l,u,p,v),u.child)}function bw(l,u,p,g,v,A){return no(u),u.updateQueue=null,p=vv(u,g,p,v),yv(l),g=sm(),l!==null&&!as?(am(l,u,A),Ar(l,u,A)):(cn&&g&&Ph(u),u.flags|=1,xs(l,u,p,A),u.child)}function xw(l,u,p,g,v){if(no(u),u.stateNode===null){var A=nl,P=p.contextType;typeof P=="object"&&P!==null&&(A=bs(P)),A=new p(g,A),u.memoizedState=A.state!==null&&A.state!==void 0?A.state:null,A.updater=ym,u.stateNode=A,A._reactInternals=u,A=u.stateNode,A.props=g,A.state=u.memoizedState,A.refs={},Gh(u),P=p.contextType,A.context=typeof P=="object"&&P!==null?bs(P):nl,A.state=u.memoizedState,P=p.getDerivedStateFromProps,typeof P=="function"&&(xm(u,p,P,g),A.state=u.memoizedState),typeof p.getDerivedStateFromProps=="function"||typeof A.getSnapshotBeforeUpdate=="function"||typeof A.UNSAFE_componentWillMount!="function"&&typeof A.componentWillMount!="function"||(P=A.state,typeof A.componentWillMount=="function"&&A.componentWillMount(),typeof A.UNSAFE_componentWillMount=="function"&&A.UNSAFE_componentWillMount(),P!==A.state&&ym.enqueueReplaceState(A,A.state,null),Tc(u,g,A,v),Nc(),A.state=u.memoizedState),typeof A.componentDidMount=="function"&&(u.flags|=4194308),g=!0}else if(l===null){A=u.stateNode;var Y=u.memoizedProps,re=lo(p,Y);A.props=re;var De=A.context,qe=p.contextType;P=nl,typeof qe=="object"&&qe!==null&&(P=bs(qe));var Qe=p.getDerivedStateFromProps;qe=typeof Qe=="function"||typeof A.getSnapshotBeforeUpdate=="function",Y=u.pendingProps!==Y,qe||typeof A.UNSAFE_componentWillReceiveProps!="function"&&typeof A.componentWillReceiveProps!="function"||(Y||De!==P)&&aw(u,A,g,P),ii=!1;var Ie=u.memoizedState;A.state=Ie,Tc(u,g,A,v),Nc(),De=u.memoizedState,Y||Ie!==De||ii?(typeof Qe=="function"&&(xm(u,p,Qe,g),De=u.memoizedState),(re=ii||sw(u,p,re,g,Ie,De,P))?(qe||typeof A.UNSAFE_componentWillMount!="function"&&typeof A.componentWillMount!="function"||(typeof A.componentWillMount=="function"&&A.componentWillMount(),typeof A.UNSAFE_componentWillMount=="function"&&A.UNSAFE_componentWillMount()),typeof A.componentDidMount=="function"&&(u.flags|=4194308)):(typeof A.componentDidMount=="function"&&(u.flags|=4194308),u.memoizedProps=g,u.memoizedState=De),A.props=g,A.state=De,A.context=P,g=re):(typeof A.componentDidMount=="function"&&(u.flags|=4194308),g=!1)}else{A=u.stateNode,Kh(l,u),P=u.memoizedProps,qe=lo(p,P),A.props=qe,Qe=u.pendingProps,Ie=A.context,De=p.contextType,re=nl,typeof De=="object"&&De!==null&&(re=bs(De)),Y=p.getDerivedStateFromProps,(De=typeof Y=="function"||typeof A.getSnapshotBeforeUpdate=="function")||typeof A.UNSAFE_componentWillReceiveProps!="function"&&typeof A.componentWillReceiveProps!="function"||(P!==Qe||Ie!==re)&&aw(u,A,g,re),ii=!1,Ie=u.memoizedState,A.state=Ie,Tc(u,g,A,v),Nc();var Ue=u.memoizedState;P!==Qe||Ie!==Ue||ii||l!==null&&l.dependencies!==null&&Nd(l.dependencies)?(typeof Y=="function"&&(xm(u,p,Y,g),Ue=u.memoizedState),(qe=ii||sw(u,p,qe,g,Ie,Ue,re)||l!==null&&l.dependencies!==null&&Nd(l.dependencies))?(De||typeof A.UNSAFE_componentWillUpdate!="function"&&typeof A.componentWillUpdate!="function"||(typeof A.componentWillUpdate=="function"&&A.componentWillUpdate(g,Ue,re),typeof A.UNSAFE_componentWillUpdate=="function"&&A.UNSAFE_componentWillUpdate(g,Ue,re)),typeof A.componentDidUpdate=="function"&&(u.flags|=4),typeof A.getSnapshotBeforeUpdate=="function"&&(u.flags|=1024)):(typeof A.componentDidUpdate!="function"||P===l.memoizedProps&&Ie===l.memoizedState||(u.flags|=4),typeof A.getSnapshotBeforeUpdate!="function"||P===l.memoizedProps&&Ie===l.memoizedState||(u.flags|=1024),u.memoizedProps=g,u.memoizedState=Ue),A.props=g,A.state=Ue,A.context=re,g=qe):(typeof A.componentDidUpdate!="function"||P===l.memoizedProps&&Ie===l.memoizedState||(u.flags|=4),typeof A.getSnapshotBeforeUpdate!="function"||P===l.memoizedProps&&Ie===l.memoizedState||(u.flags|=1024),g=!1)}return A=g,Vd(l,u),g=(u.flags&128)!==0,A||g?(A=u.stateNode,p=g&&typeof p.getDerivedStateFromError!="function"?null:A.render(),u.flags|=1,l!==null&&g?(u.child=io(u,l.child,null,v),u.child=io(u,null,p,v)):xs(l,u,p,v),u.memoizedState=A.state,l=u.child):l=Ar(l,u,v),l}function yw(l,u,p,g){return eo(),u.flags|=256,xs(l,u,p,g),u.child}var Sm={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Cm(l){return{baseLanes:l,cachePool:lv()}}function Am(l,u,p){return l=l!==null?l.childLanes&~p:0,u&&(l|=sa),l}function vw(l,u,p){var g=u.pendingProps,v=!1,A=(u.flags&128)!==0,P;if((P=A)||(P=l!==null&&l.memoizedState===null?!1:(Xn.current&2)!==0),P&&(v=!0,u.flags&=-129),P=(u.flags&32)!==0,u.flags&=-33,l===null){if(cn){if(v?ci(u):ui(),(l=In)?(l=T0(l,va),l=l!==null&&l.data!=="&"?l:null,l!==null&&(u.memoizedState={dehydrated:l,treeContext:ni!==null?{id:Ya,overflow:Ga}:null,retryLane:536870912,hydrationErrors:null},p=Zy(l),p.return=u,u.child=p,gs=u,In=null)):l=null,l===null)throw ai(u);return og(l)?u.lanes=32:u.lanes=536870912,null}var Y=g.children;return g=g.fallback,v?(ui(),v=u.mode,Y=Yd({mode:"hidden",children:Y},v),g=Zi(g,v,p,null),Y.return=u,g.return=u,Y.sibling=g,u.child=Y,g=u.child,g.memoizedState=Cm(p),g.childLanes=Am(l,P,p),u.memoizedState=Sm,Rc(null,g)):(ci(u),jm(u,Y))}var re=l.memoizedState;if(re!==null&&(Y=re.dehydrated,Y!==null)){if(A)u.flags&256?(ci(u),u.flags&=-257,u=Nm(l,u,p)):u.memoizedState!==null?(ui(),u.child=l.child,u.flags|=128,u=null):(ui(),Y=g.fallback,v=u.mode,g=Yd({mode:"visible",children:g.children},v),Y=Zi(Y,v,p,null),Y.flags|=2,g.return=u,Y.return=u,g.sibling=Y,u.child=g,io(u,l.child,null,p),g=u.child,g.memoizedState=Cm(p),g.childLanes=Am(l,P,p),u.memoizedState=Sm,u=Rc(null,g));else if(ci(u),og(Y)){if(P=Y.nextSibling&&Y.nextSibling.dataset,P)var De=P.dgst;P=De,g=Error(s(419)),g.stack="",g.digest=P,wc({value:g,source:null,stack:null}),u=Nm(l,u,p)}else if(as||il(l,u,p,!1),P=(p&l.childLanes)!==0,as||P){if(P=Nn,P!==null&&(g=Ft(P,p),g!==0&&g!==re.retryLane))throw re.retryLane=g,Ji(l,g),qs(P,l,g),wm;ig(Y)||nf(),u=Nm(l,u,p)}else ig(Y)?(u.flags|=192,u.child=l.child,u=null):(l=re.treeContext,In=ka(Y.nextSibling),gs=u,cn=!0,si=null,va=!1,l!==null&&nv(u,l),u=jm(u,g.children),u.flags|=4096);return u}return v?(ui(),Y=g.fallback,v=u.mode,re=l.child,De=re.sibling,g=yr(re,{mode:"hidden",children:g.children}),g.subtreeFlags=re.subtreeFlags&65011712,De!==null?Y=yr(De,Y):(Y=Zi(Y,v,p,null),Y.flags|=2),Y.return=u,g.return=u,g.sibling=Y,u.child=g,Rc(null,g),g=u.child,Y=l.child.memoizedState,Y===null?Y=Cm(p):(v=Y.cachePool,v!==null?(re=ns._currentValue,v=v.parent!==re?{parent:re,pool:re}:v):v=lv(),Y={baseLanes:Y.baseLanes|p,cachePool:v}),g.memoizedState=Y,g.childLanes=Am(l,P,p),u.memoizedState=Sm,Rc(l.child,g)):(ci(u),p=l.child,l=p.sibling,p=yr(p,{mode:"visible",children:g.children}),p.return=u,p.sibling=null,l!==null&&(P=u.deletions,P===null?(u.deletions=[l],u.flags|=16):P.push(l)),u.child=p,u.memoizedState=null,p)}function jm(l,u){return u=Yd({mode:"visible",children:u},l.mode),u.return=l,l.child=u}function Yd(l,u){return l=Zs(22,l,null,u),l.lanes=0,l}function Nm(l,u,p){return io(u,l.child,null,p),l=jm(u,u.pendingProps.children),l.flags|=2,u.memoizedState=null,l}function ww(l,u,p){l.lanes|=u;var g=l.alternate;g!==null&&(g.lanes|=u),Uh(l.return,u,p)}function Tm(l,u,p,g,v,A){var P=l.memoizedState;P===null?l.memoizedState={isBackwards:u,rendering:null,renderingStartTime:0,last:g,tail:p,tailMode:v,treeForkCount:A}:(P.isBackwards=u,P.rendering=null,P.renderingStartTime=0,P.last=g,P.tail=p,P.tailMode=v,P.treeForkCount=A)}function kw(l,u,p){var g=u.pendingProps,v=g.revealOrder,A=g.tail;g=g.children;var P=Xn.current,Y=(P&2)!==0;if(Y?(P=P&1|2,u.flags|=128):P&=1,q(Xn,P),xs(l,u,g,p),g=cn?vc:0,!Y&&l!==null&&(l.flags&128)!==0)e:for(l=u.child;l!==null;){if(l.tag===13)l.memoizedState!==null&&ww(l,p,u);else if(l.tag===19)ww(l,p,u);else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===u)break e;for(;l.sibling===null;){if(l.return===null||l.return===u)break e;l=l.return}l.sibling.return=l.return,l=l.sibling}switch(v){case"forwards":for(p=u.child,v=null;p!==null;)l=p.alternate,l!==null&&Ld(l)===null&&(v=p),p=p.sibling;p=v,p===null?(v=u.child,u.child=null):(v=p.sibling,p.sibling=null),Tm(u,!1,v,p,A,g);break;case"backwards":case"unstable_legacy-backwards":for(p=null,v=u.child,u.child=null;v!==null;){if(l=v.alternate,l!==null&&Ld(l)===null){u.child=v;break}l=v.sibling,v.sibling=p,p=v,v=l}Tm(u,!0,p,null,A,g);break;case"together":Tm(u,!1,null,null,void 0,g);break;default:u.memoizedState=null}return u.child}function Ar(l,u,p){if(l!==null&&(u.dependencies=l.dependencies),pi|=u.lanes,(p&u.childLanes)===0)if(l!==null){if(il(l,u,p,!1),(p&u.childLanes)===0)return null}else return null;if(l!==null&&u.child!==l.child)throw Error(s(153));if(u.child!==null){for(l=u.child,p=yr(l,l.pendingProps),u.child=p,p.return=u;l.sibling!==null;)l=l.sibling,p=p.sibling=yr(l,l.pendingProps),p.return=u;p.sibling=null}return u.child}function _m(l,u){return(l.lanes&u)!==0?!0:(l=l.dependencies,!!(l!==null&&Nd(l)))}function T_(l,u,p){switch(u.tag){case 3:me(u,u.stateNode.containerInfo),ri(u,ns,l.memoizedState.cache),eo();break;case 27:case 5:Te(u);break;case 4:me(u,u.stateNode.containerInfo);break;case 10:ri(u,u.type,u.memoizedProps.value);break;case 31:if(u.memoizedState!==null)return u.flags|=128,em(u),null;break;case 13:var g=u.memoizedState;if(g!==null)return g.dehydrated!==null?(ci(u),u.flags|=128,null):(p&u.child.childLanes)!==0?vw(l,u,p):(ci(u),l=Ar(l,u,p),l!==null?l.sibling:null);ci(u);break;case 19:var v=(l.flags&128)!==0;if(g=(p&u.childLanes)!==0,g||(il(l,u,p,!1),g=(p&u.childLanes)!==0),v){if(g)return kw(l,u,p);u.flags|=128}if(v=u.memoizedState,v!==null&&(v.rendering=null,v.tail=null,v.lastEffect=null),q(Xn,Xn.current),g)break;return null;case 22:return u.lanes=0,hw(l,u,p,u.pendingProps);case 24:ri(u,ns,l.memoizedState.cache)}return Ar(l,u,p)}function Sw(l,u,p){if(l!==null)if(l.memoizedProps!==u.pendingProps)as=!0;else{if(!_m(l,p)&&(u.flags&128)===0)return as=!1,T_(l,u,p);as=(l.flags&131072)!==0}else as=!1,cn&&(u.flags&1048576)!==0&&tv(u,vc,u.index);switch(u.lanes=0,u.tag){case 16:e:{var g=u.pendingProps;if(l=ao(u.elementType),u.type=l,typeof l=="function")Oh(l)?(g=lo(l,g),u.tag=1,u=xw(null,u,l,g,p)):(u.tag=0,u=km(null,u,l,g,p));else{if(l!=null){var v=l.$$typeof;if(v===T){u.tag=11,u=dw(null,u,l,g,p);break e}else if(v===I){u.tag=14,u=fw(null,u,l,g,p);break e}}throw u=W(l)||l,Error(s(306,u,""))}}return u;case 0:return km(l,u,u.type,u.pendingProps,p);case 1:return g=u.type,v=lo(g,u.pendingProps),xw(l,u,g,v,p);case 3:e:{if(me(u,u.stateNode.containerInfo),l===null)throw Error(s(387));g=u.pendingProps;var A=u.memoizedState;v=A.element,Kh(l,u),Tc(u,g,null,p);var P=u.memoizedState;if(g=P.cache,ri(u,ns,g),g!==A.cache&&Hh(u,[ns],p,!0),Nc(),g=P.element,A.isDehydrated)if(A={element:g,isDehydrated:!1,cache:P.cache},u.updateQueue.baseState=A,u.memoizedState=A,u.flags&256){u=yw(l,u,g,p);break e}else if(g!==v){v=ba(Error(s(424)),u),wc(v),u=yw(l,u,g,p);break e}else{switch(l=u.stateNode.containerInfo,l.nodeType){case 9:l=l.body;break;default:l=l.nodeName==="HTML"?l.ownerDocument.body:l}for(In=ka(l.firstChild),gs=u,cn=!0,si=null,va=!0,p=hv(u,null,g,p),u.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling}else{if(eo(),g===v){u=Ar(l,u,p);break e}xs(l,u,g,p)}u=u.child}return u;case 26:return Vd(l,u),l===null?(p=O0(u.type,null,u.pendingProps,null))?u.memoizedState=p:cn||(p=u.type,l=u.pendingProps,g=uf(Z.current).createElement(p),g[xt]=u,g[$t]=l,ys(g,p,l),wn(g),u.stateNode=g):u.memoizedState=O0(u.type,l.memoizedProps,u.pendingProps,l.memoizedState),null;case 27:return Te(u),l===null&&cn&&(g=u.stateNode=M0(u.type,u.pendingProps,Z.current),gs=u,va=!0,v=In,xi(u.type)?(lg=v,In=ka(g.firstChild)):In=v),xs(l,u,u.pendingProps.children,p),Vd(l,u),l===null&&(u.flags|=4194304),u.child;case 5:return l===null&&cn&&((v=g=In)&&(g=aE(g,u.type,u.pendingProps,va),g!==null?(u.stateNode=g,gs=u,In=ka(g.firstChild),va=!1,v=!0):v=!1),v||ai(u)),Te(u),v=u.type,A=u.pendingProps,P=l!==null?l.memoizedProps:null,g=A.children,sg(v,A)?g=null:P!==null&&sg(v,P)&&(u.flags|=32),u.memoizedState!==null&&(v=nm(l,u,y_,null,null,p),Gc._currentValue=v),Vd(l,u),xs(l,u,g,p),u.child;case 6:return l===null&&cn&&((l=p=In)&&(p=rE(p,u.pendingProps,va),p!==null?(u.stateNode=p,gs=u,In=null,l=!0):l=!1),l||ai(u)),null;case 13:return vw(l,u,p);case 4:return me(u,u.stateNode.containerInfo),g=u.pendingProps,l===null?u.child=io(u,null,g,p):xs(l,u,g,p),u.child;case 11:return dw(l,u,u.type,u.pendingProps,p);case 7:return xs(l,u,u.pendingProps,p),u.child;case 8:return xs(l,u,u.pendingProps.children,p),u.child;case 12:return xs(l,u,u.pendingProps.children,p),u.child;case 10:return g=u.pendingProps,ri(u,u.type,g.value),xs(l,u,g.children,p),u.child;case 9:return v=u.type._context,g=u.pendingProps.children,no(u),v=bs(v),g=g(v),u.flags|=1,xs(l,u,g,p),u.child;case 14:return fw(l,u,u.type,u.pendingProps,p);case 15:return pw(l,u,u.type,u.pendingProps,p);case 19:return kw(l,u,p);case 31:return N_(l,u,p);case 22:return hw(l,u,p,u.pendingProps);case 24:return no(u),g=bs(ns),l===null?(v=Vh(),v===null&&(v=Nn,A=Wh(),v.pooledCache=A,A.refCount++,A!==null&&(v.pooledCacheLanes|=p),v=A),u.memoizedState={parent:g,cache:v},Gh(u),ri(u,ns,v)):((l.lanes&p)!==0&&(Kh(l,u),Tc(u,null,null,p),Nc()),v=l.memoizedState,A=u.memoizedState,v.parent!==g?(v={parent:g,cache:g},u.memoizedState=v,u.lanes===0&&(u.memoizedState=u.updateQueue.baseState=v),ri(u,ns,g)):(g=A.cache,ri(u,ns,g),g!==v.cache&&Hh(u,[ns],p,!0))),xs(l,u,u.pendingProps.children,p),u.child;case 29:throw u.pendingProps}throw Error(s(156,u.tag))}function jr(l){l.flags|=4}function Em(l,u,p,g,v){if((u=(l.mode&32)!==0)&&(u=!1),u){if(l.flags|=16777216,(v&335544128)===v)if(l.stateNode.complete)l.flags|=8192;else if(Qw())l.flags|=8192;else throw ro=Md,Yh}else l.flags&=-16777217}function Cw(l,u){if(u.type!=="stylesheet"||(u.state.loading&4)!==0)l.flags&=-16777217;else if(l.flags|=16777216,!F0(u))if(Qw())l.flags|=8192;else throw ro=Md,Yh}function Gd(l,u){u!==null&&(l.flags|=4),l.flags&16384&&(u=l.tag!==22?tn():536870912,l.lanes|=u,xl|=u)}function Oc(l,u){if(!cn)switch(l.tailMode){case"hidden":u=l.tail;for(var p=null;u!==null;)u.alternate!==null&&(p=u),u=u.sibling;p===null?l.tail=null:p.sibling=null;break;case"collapsed":p=l.tail;for(var g=null;p!==null;)p.alternate!==null&&(g=p),p=p.sibling;g===null?u||l.tail===null?l.tail=null:l.tail.sibling=null:g.sibling=null}}function Pn(l){var u=l.alternate!==null&&l.alternate.child===l.child,p=0,g=0;if(u)for(var v=l.child;v!==null;)p|=v.lanes|v.childLanes,g|=v.subtreeFlags&65011712,g|=v.flags&65011712,v.return=l,v=v.sibling;else for(v=l.child;v!==null;)p|=v.lanes|v.childLanes,g|=v.subtreeFlags,g|=v.flags,v.return=l,v=v.sibling;return l.subtreeFlags|=g,l.childLanes=p,u}function __(l,u,p){var g=u.pendingProps;switch(Bh(u),u.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Pn(u),null;case 1:return Pn(u),null;case 3:return p=u.stateNode,g=null,l!==null&&(g=l.memoizedState.cache),u.memoizedState.cache!==g&&(u.flags|=2048),kr(ns),Ee(),p.pendingContext&&(p.context=p.pendingContext,p.pendingContext=null),(l===null||l.child===null)&&(rl(u)?jr(u):l===null||l.memoizedState.isDehydrated&&(u.flags&256)===0||(u.flags|=1024,zh())),Pn(u),null;case 26:var v=u.type,A=u.memoizedState;return l===null?(jr(u),A!==null?(Pn(u),Cw(u,A)):(Pn(u),Em(u,v,null,g,p))):A?A!==l.memoizedState?(jr(u),Pn(u),Cw(u,A)):(Pn(u),u.flags&=-16777217):(l=l.memoizedProps,l!==g&&jr(u),Pn(u),Em(u,v,l,g,p)),null;case 27:if(Ve(u),p=Z.current,v=u.type,l!==null&&u.stateNode!=null)l.memoizedProps!==g&&jr(u);else{if(!g){if(u.stateNode===null)throw Error(s(166));return Pn(u),null}l=be.current,rl(u)?sv(u):(l=M0(v,g,p),u.stateNode=l,jr(u))}return Pn(u),null;case 5:if(Ve(u),v=u.type,l!==null&&u.stateNode!=null)l.memoizedProps!==g&&jr(u);else{if(!g){if(u.stateNode===null)throw Error(s(166));return Pn(u),null}if(A=be.current,rl(u))sv(u);else{var P=uf(Z.current);switch(A){case 1:A=P.createElementNS("http://www.w3.org/2000/svg",v);break;case 2:A=P.createElementNS("http://www.w3.org/1998/Math/MathML",v);break;default:switch(v){case"svg":A=P.createElementNS("http://www.w3.org/2000/svg",v);break;case"math":A=P.createElementNS("http://www.w3.org/1998/Math/MathML",v);break;case"script":A=P.createElement("div"),A.innerHTML="<script><\/script>",A=A.removeChild(A.firstChild);break;case"select":A=typeof g.is=="string"?P.createElement("select",{is:g.is}):P.createElement("select"),g.multiple?A.multiple=!0:g.size&&(A.size=g.size);break;default:A=typeof g.is=="string"?P.createElement(v,{is:g.is}):P.createElement(v)}}A[xt]=u,A[$t]=g;e:for(P=u.child;P!==null;){if(P.tag===5||P.tag===6)A.appendChild(P.stateNode);else if(P.tag!==4&&P.tag!==27&&P.child!==null){P.child.return=P,P=P.child;continue}if(P===u)break e;for(;P.sibling===null;){if(P.return===null||P.return===u)break e;P=P.return}P.sibling.return=P.return,P=P.sibling}u.stateNode=A;e:switch(ys(A,v,g),v){case"button":case"input":case"select":case"textarea":g=!!g.autoFocus;break e;case"img":g=!0;break e;default:g=!1}g&&jr(u)}}return Pn(u),Em(u,u.type,l===null?null:l.memoizedProps,u.pendingProps,p),null;case 6:if(l&&u.stateNode!=null)l.memoizedProps!==g&&jr(u);else{if(typeof g!="string"&&u.stateNode===null)throw Error(s(166));if(l=Z.current,rl(u)){if(l=u.stateNode,p=u.memoizedProps,g=null,v=gs,v!==null)switch(v.tag){case 27:case 5:g=v.memoizedProps}l[xt]=u,l=!!(l.nodeValue===p||g!==null&&g.suppressHydrationWarning===!0||v0(l.nodeValue,p)),l||ai(u,!0)}else l=uf(l).createTextNode(g),l[xt]=u,u.stateNode=l}return Pn(u),null;case 31:if(p=u.memoizedState,l===null||l.memoizedState!==null){if(g=rl(u),p!==null){if(l===null){if(!g)throw Error(s(318));if(l=u.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(s(557));l[xt]=u}else eo(),(u.flags&128)===0&&(u.memoizedState=null),u.flags|=4;Pn(u),l=!1}else p=zh(),l!==null&&l.memoizedState!==null&&(l.memoizedState.hydrationErrors=p),l=!0;if(!l)return u.flags&256?(ta(u),u):(ta(u),null);if((u.flags&128)!==0)throw Error(s(558))}return Pn(u),null;case 13:if(g=u.memoizedState,l===null||l.memoizedState!==null&&l.memoizedState.dehydrated!==null){if(v=rl(u),g!==null&&g.dehydrated!==null){if(l===null){if(!v)throw Error(s(318));if(v=u.memoizedState,v=v!==null?v.dehydrated:null,!v)throw Error(s(317));v[xt]=u}else eo(),(u.flags&128)===0&&(u.memoizedState=null),u.flags|=4;Pn(u),v=!1}else v=zh(),l!==null&&l.memoizedState!==null&&(l.memoizedState.hydrationErrors=v),v=!0;if(!v)return u.flags&256?(ta(u),u):(ta(u),null)}return ta(u),(u.flags&128)!==0?(u.lanes=p,u):(p=g!==null,l=l!==null&&l.memoizedState!==null,p&&(g=u.child,v=null,g.alternate!==null&&g.alternate.memoizedState!==null&&g.alternate.memoizedState.cachePool!==null&&(v=g.alternate.memoizedState.cachePool.pool),A=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(A=g.memoizedState.cachePool.pool),A!==v&&(g.flags|=2048)),p!==l&&p&&(u.child.flags|=8192),Gd(u,u.updateQueue),Pn(u),null);case 4:return Ee(),l===null&&Jm(u.stateNode.containerInfo),Pn(u),null;case 10:return kr(u.type),Pn(u),null;case 19:if(se(Xn),g=u.memoizedState,g===null)return Pn(u),null;if(v=(u.flags&128)!==0,A=g.rendering,A===null)if(v)Oc(g,!1);else{if(Yn!==0||l!==null&&(l.flags&128)!==0)for(l=u.child;l!==null;){if(A=Ld(l),A!==null){for(u.flags|=128,Oc(g,!1),l=A.updateQueue,u.updateQueue=l,Gd(u,l),u.subtreeFlags=0,l=p,p=u.child;p!==null;)Jy(p,l),p=p.sibling;return q(Xn,Xn.current&1|2),cn&&vr(u,g.treeForkCount),u.child}l=l.sibling}g.tail!==null&&ct()>Zd&&(u.flags|=128,v=!0,Oc(g,!1),u.lanes=4194304)}else{if(!v)if(l=Ld(A),l!==null){if(u.flags|=128,v=!0,l=l.updateQueue,u.updateQueue=l,Gd(u,l),Oc(g,!0),g.tail===null&&g.tailMode==="hidden"&&!A.alternate&&!cn)return Pn(u),null}else 2*ct()-g.renderingStartTime>Zd&&p!==536870912&&(u.flags|=128,v=!0,Oc(g,!1),u.lanes=4194304);g.isBackwards?(A.sibling=u.child,u.child=A):(l=g.last,l!==null?l.sibling=A:u.child=A,g.last=A)}return g.tail!==null?(l=g.tail,g.rendering=l,g.tail=l.sibling,g.renderingStartTime=ct(),l.sibling=null,p=Xn.current,q(Xn,v?p&1|2:p&1),cn&&vr(u,g.treeForkCount),l):(Pn(u),null);case 22:case 23:return ta(u),Zh(),g=u.memoizedState!==null,l!==null?l.memoizedState!==null!==g&&(u.flags|=8192):g&&(u.flags|=8192),g?(p&536870912)!==0&&(u.flags&128)===0&&(Pn(u),u.subtreeFlags&6&&(u.flags|=8192)):Pn(u),p=u.updateQueue,p!==null&&Gd(u,p.retryQueue),p=null,l!==null&&l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(p=l.memoizedState.cachePool.pool),g=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(g=u.memoizedState.cachePool.pool),g!==p&&(u.flags|=2048),l!==null&&se(so),null;case 24:return p=null,l!==null&&(p=l.memoizedState.cache),u.memoizedState.cache!==p&&(u.flags|=2048),kr(ns),Pn(u),null;case 25:return null;case 30:return null}throw Error(s(156,u.tag))}function E_(l,u){switch(Bh(u),u.tag){case 1:return l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 3:return kr(ns),Ee(),l=u.flags,(l&65536)!==0&&(l&128)===0?(u.flags=l&-65537|128,u):null;case 26:case 27:case 5:return Ve(u),null;case 31:if(u.memoizedState!==null){if(ta(u),u.alternate===null)throw Error(s(340));eo()}return l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 13:if(ta(u),l=u.memoizedState,l!==null&&l.dehydrated!==null){if(u.alternate===null)throw Error(s(340));eo()}return l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 19:return se(Xn),null;case 4:return Ee(),null;case 10:return kr(u.type),null;case 22:case 23:return ta(u),Zh(),l!==null&&se(so),l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 24:return kr(ns),null;case 25:return null;default:return null}}function Aw(l,u){switch(Bh(u),u.tag){case 3:kr(ns),Ee();break;case 26:case 27:case 5:Ve(u);break;case 4:Ee();break;case 31:u.memoizedState!==null&&ta(u);break;case 13:ta(u);break;case 19:se(Xn);break;case 10:kr(u.type);break;case 22:case 23:ta(u),Zh(),l!==null&&se(so);break;case 24:kr(ns)}}function Lc(l,u){try{var p=u.updateQueue,g=p!==null?p.lastEffect:null;if(g!==null){var v=g.next;p=v;do{if((p.tag&l)===l){g=void 0;var A=p.create,P=p.inst;g=A(),P.destroy=g}p=p.next}while(p!==v)}}catch(Y){xn(u,u.return,Y)}}function di(l,u,p){try{var g=u.updateQueue,v=g!==null?g.lastEffect:null;if(v!==null){var A=v.next;g=A;do{if((g.tag&l)===l){var P=g.inst,Y=P.destroy;if(Y!==void 0){P.destroy=void 0,v=u;var re=p,De=Y;try{De()}catch(qe){xn(v,re,qe)}}}g=g.next}while(g!==A)}}catch(qe){xn(u,u.return,qe)}}function jw(l){var u=l.updateQueue;if(u!==null){var p=l.stateNode;try{gv(u,p)}catch(g){xn(l,l.return,g)}}}function Nw(l,u,p){p.props=lo(l.type,l.memoizedProps),p.state=l.memoizedState;try{p.componentWillUnmount()}catch(g){xn(l,u,g)}}function Ic(l,u){try{var p=l.ref;if(p!==null){switch(l.tag){case 26:case 27:case 5:var g=l.stateNode;break;case 30:g=l.stateNode;break;default:g=l.stateNode}typeof p=="function"?l.refCleanup=p(g):p.current=g}}catch(v){xn(l,u,v)}}function Ka(l,u){var p=l.ref,g=l.refCleanup;if(p!==null)if(typeof g=="function")try{g()}catch(v){xn(l,u,v)}finally{l.refCleanup=null,l=l.alternate,l!=null&&(l.refCleanup=null)}else if(typeof p=="function")try{p(null)}catch(v){xn(l,u,v)}else p.current=null}function Tw(l){var u=l.type,p=l.memoizedProps,g=l.stateNode;try{e:switch(u){case"button":case"input":case"select":case"textarea":p.autoFocus&&g.focus();break e;case"img":p.src?g.src=p.src:p.srcSet&&(g.srcset=p.srcSet)}}catch(v){xn(l,l.return,v)}}function Mm(l,u,p){try{var g=l.stateNode;J_(g,l.type,p,u),g[$t]=u}catch(v){xn(l,l.return,v)}}function _w(l){return l.tag===5||l.tag===3||l.tag===26||l.tag===27&&xi(l.type)||l.tag===4}function Dm(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||_w(l.return))return null;l=l.return}for(l.sibling.return=l.return,l=l.sibling;l.tag!==5&&l.tag!==6&&l.tag!==18;){if(l.tag===27&&xi(l.type)||l.flags&2||l.child===null||l.tag===4)continue e;l.child.return=l,l=l.child}if(!(l.flags&2))return l.stateNode}}function Rm(l,u,p){var g=l.tag;if(g===5||g===6)l=l.stateNode,u?(p.nodeType===9?p.body:p.nodeName==="HTML"?p.ownerDocument.body:p).insertBefore(l,u):(u=p.nodeType===9?p.body:p.nodeName==="HTML"?p.ownerDocument.body:p,u.appendChild(l),p=p._reactRootContainer,p!=null||u.onclick!==null||(u.onclick=It));else if(g!==4&&(g===27&&xi(l.type)&&(p=l.stateNode,u=null),l=l.child,l!==null))for(Rm(l,u,p),l=l.sibling;l!==null;)Rm(l,u,p),l=l.sibling}function Kd(l,u,p){var g=l.tag;if(g===5||g===6)l=l.stateNode,u?p.insertBefore(l,u):p.appendChild(l);else if(g!==4&&(g===27&&xi(l.type)&&(p=l.stateNode),l=l.child,l!==null))for(Kd(l,u,p),l=l.sibling;l!==null;)Kd(l,u,p),l=l.sibling}function Ew(l){var u=l.stateNode,p=l.memoizedProps;try{for(var g=l.type,v=u.attributes;v.length;)u.removeAttributeNode(v[0]);ys(u,g,p),u[xt]=l,u[$t]=p}catch(A){xn(l,l.return,A)}}var Nr=!1,rs=!1,Om=!1,Mw=typeof WeakSet=="function"?WeakSet:Set,ds=null;function M_(l,u){if(l=l.containerInfo,tg=bf,l=Hy(l),Nh(l)){if("selectionStart"in l)var p={start:l.selectionStart,end:l.selectionEnd};else e:{p=(p=l.ownerDocument)&&p.defaultView||window;var g=p.getSelection&&p.getSelection();if(g&&g.rangeCount!==0){p=g.anchorNode;var v=g.anchorOffset,A=g.focusNode;g=g.focusOffset;try{p.nodeType,A.nodeType}catch{p=null;break e}var P=0,Y=-1,re=-1,De=0,qe=0,Qe=l,Ie=null;t:for(;;){for(var Ue;Qe!==p||v!==0&&Qe.nodeType!==3||(Y=P+v),Qe!==A||g!==0&&Qe.nodeType!==3||(re=P+g),Qe.nodeType===3&&(P+=Qe.nodeValue.length),(Ue=Qe.firstChild)!==null;)Ie=Qe,Qe=Ue;for(;;){if(Qe===l)break t;if(Ie===p&&++De===v&&(Y=P),Ie===A&&++qe===g&&(re=P),(Ue=Qe.nextSibling)!==null)break;Qe=Ie,Ie=Qe.parentNode}Qe=Ue}p=Y===-1||re===-1?null:{start:Y,end:re}}else p=null}p=p||{start:0,end:0}}else p=null;for(ng={focusedElem:l,selectionRange:p},bf=!1,ds=u;ds!==null;)if(u=ds,l=u.child,(u.subtreeFlags&1028)!==0&&l!==null)l.return=u,ds=l;else for(;ds!==null;){switch(u=ds,A=u.alternate,l=u.flags,u.tag){case 0:if((l&4)!==0&&(l=u.updateQueue,l=l!==null?l.events:null,l!==null))for(p=0;p<l.length;p++)v=l[p],v.ref.impl=v.nextImpl;break;case 11:case 15:break;case 1:if((l&1024)!==0&&A!==null){l=void 0,p=u,v=A.memoizedProps,A=A.memoizedState,g=p.stateNode;try{var yt=lo(p.type,v);l=g.getSnapshotBeforeUpdate(yt,A),g.__reactInternalSnapshotBeforeUpdate=l}catch(Dt){xn(p,p.return,Dt)}}break;case 3:if((l&1024)!==0){if(l=u.stateNode.containerInfo,p=l.nodeType,p===9)rg(l);else if(p===1)switch(l.nodeName){case"HEAD":case"HTML":case"BODY":rg(l);break;default:l.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((l&1024)!==0)throw Error(s(163))}if(l=u.sibling,l!==null){l.return=u.return,ds=l;break}ds=u.return}}function Dw(l,u,p){var g=p.flags;switch(p.tag){case 0:case 11:case 15:_r(l,p),g&4&&Lc(5,p);break;case 1:if(_r(l,p),g&4)if(l=p.stateNode,u===null)try{l.componentDidMount()}catch(P){xn(p,p.return,P)}else{var v=lo(p.type,u.memoizedProps);u=u.memoizedState;try{l.componentDidUpdate(v,u,l.__reactInternalSnapshotBeforeUpdate)}catch(P){xn(p,p.return,P)}}g&64&&jw(p),g&512&&Ic(p,p.return);break;case 3:if(_r(l,p),g&64&&(l=p.updateQueue,l!==null)){if(u=null,p.child!==null)switch(p.child.tag){case 27:case 5:u=p.child.stateNode;break;case 1:u=p.child.stateNode}try{gv(l,u)}catch(P){xn(p,p.return,P)}}break;case 27:u===null&&g&4&&Ew(p);case 26:case 5:_r(l,p),u===null&&g&4&&Tw(p),g&512&&Ic(p,p.return);break;case 12:_r(l,p);break;case 31:_r(l,p),g&4&&Lw(l,p);break;case 13:_r(l,p),g&4&&Iw(l,p),g&64&&(l=p.memoizedState,l!==null&&(l=l.dehydrated,l!==null&&(p=z_.bind(null,p),iE(l,p))));break;case 22:if(g=p.memoizedState!==null||Nr,!g){u=u!==null&&u.memoizedState!==null||rs,v=Nr;var A=rs;Nr=g,(rs=u)&&!A?Er(l,p,(p.subtreeFlags&8772)!==0):_r(l,p),Nr=v,rs=A}break;case 30:break;default:_r(l,p)}}function Rw(l){var u=l.alternate;u!==null&&(l.alternate=null,Rw(u)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(u=l.stateNode,u!==null&&Qn(u)),l.stateNode=null,l.return=null,l.dependencies=null,l.memoizedProps=null,l.memoizedState=null,l.pendingProps=null,l.stateNode=null,l.updateQueue=null}var zn=null,$s=!1;function Tr(l,u,p){for(p=p.child;p!==null;)Ow(l,u,p),p=p.sibling}function Ow(l,u,p){if(Pe&&typeof Pe.onCommitFiberUnmount=="function")try{Pe.onCommitFiberUnmount(xe,p)}catch{}switch(p.tag){case 26:rs||Ka(p,u),Tr(l,u,p),p.memoizedState?p.memoizedState.count--:p.stateNode&&(p=p.stateNode,p.parentNode.removeChild(p));break;case 27:rs||Ka(p,u);var g=zn,v=$s;xi(p.type)&&(zn=p.stateNode,$s=!1),Tr(l,u,p),qc(p.stateNode),zn=g,$s=v;break;case 5:rs||Ka(p,u);case 6:if(g=zn,v=$s,zn=null,Tr(l,u,p),zn=g,$s=v,zn!==null)if($s)try{(zn.nodeType===9?zn.body:zn.nodeName==="HTML"?zn.ownerDocument.body:zn).removeChild(p.stateNode)}catch(A){xn(p,u,A)}else try{zn.removeChild(p.stateNode)}catch(A){xn(p,u,A)}break;case 18:zn!==null&&($s?(l=zn,j0(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,p.stateNode),jl(l)):j0(zn,p.stateNode));break;case 4:g=zn,v=$s,zn=p.stateNode.containerInfo,$s=!0,Tr(l,u,p),zn=g,$s=v;break;case 0:case 11:case 14:case 15:di(2,p,u),rs||di(4,p,u),Tr(l,u,p);break;case 1:rs||(Ka(p,u),g=p.stateNode,typeof g.componentWillUnmount=="function"&&Nw(p,u,g)),Tr(l,u,p);break;case 21:Tr(l,u,p);break;case 22:rs=(g=rs)||p.memoizedState!==null,Tr(l,u,p),rs=g;break;default:Tr(l,u,p)}}function Lw(l,u){if(u.memoizedState===null&&(l=u.alternate,l!==null&&(l=l.memoizedState,l!==null))){l=l.dehydrated;try{jl(l)}catch(p){xn(u,u.return,p)}}}function Iw(l,u){if(u.memoizedState===null&&(l=u.alternate,l!==null&&(l=l.memoizedState,l!==null&&(l=l.dehydrated,l!==null))))try{jl(l)}catch(p){xn(u,u.return,p)}}function D_(l){switch(l.tag){case 31:case 13:case 19:var u=l.stateNode;return u===null&&(u=l.stateNode=new Mw),u;case 22:return l=l.stateNode,u=l._retryCache,u===null&&(u=l._retryCache=new Mw),u;default:throw Error(s(435,l.tag))}}function Qd(l,u){var p=D_(l);u.forEach(function(g){if(!p.has(g)){p.add(g);var v=$_.bind(null,l,g);g.then(v,v)}})}function Us(l,u){var p=u.deletions;if(p!==null)for(var g=0;g<p.length;g++){var v=p[g],A=l,P=u,Y=P;e:for(;Y!==null;){switch(Y.tag){case 27:if(xi(Y.type)){zn=Y.stateNode,$s=!1;break e}break;case 5:zn=Y.stateNode,$s=!1;break e;case 3:case 4:zn=Y.stateNode.containerInfo,$s=!0;break e}Y=Y.return}if(zn===null)throw Error(s(160));Ow(A,P,v),zn=null,$s=!1,A=v.alternate,A!==null&&(A.return=null),v.return=null}if(u.subtreeFlags&13886)for(u=u.child;u!==null;)Pw(u,l),u=u.sibling}var Ra=null;function Pw(l,u){var p=l.alternate,g=l.flags;switch(l.tag){case 0:case 11:case 14:case 15:Us(u,l),Hs(l),g&4&&(di(3,l,l.return),Lc(3,l),di(5,l,l.return));break;case 1:Us(u,l),Hs(l),g&512&&(rs||p===null||Ka(p,p.return)),g&64&&Nr&&(l=l.updateQueue,l!==null&&(g=l.callbacks,g!==null&&(p=l.shared.hiddenCallbacks,l.shared.hiddenCallbacks=p===null?g:p.concat(g))));break;case 26:var v=Ra;if(Us(u,l),Hs(l),g&512&&(rs||p===null||Ka(p,p.return)),g&4){var A=p!==null?p.memoizedState:null;if(g=l.memoizedState,p===null)if(g===null)if(l.stateNode===null){e:{g=l.type,p=l.memoizedProps,v=v.ownerDocument||v;t:switch(g){case"title":A=v.getElementsByTagName("title")[0],(!A||A[ks]||A[xt]||A.namespaceURI==="http://www.w3.org/2000/svg"||A.hasAttribute("itemprop"))&&(A=v.createElement(g),v.head.insertBefore(A,v.querySelector("head > title"))),ys(A,g,p),A[xt]=l,wn(A),g=A;break e;case"link":var P=P0("link","href",v).get(g+(p.href||""));if(P){for(var Y=0;Y<P.length;Y++)if(A=P[Y],A.getAttribute("href")===(p.href==null||p.href===""?null:p.href)&&A.getAttribute("rel")===(p.rel==null?null:p.rel)&&A.getAttribute("title")===(p.title==null?null:p.title)&&A.getAttribute("crossorigin")===(p.crossOrigin==null?null:p.crossOrigin)){P.splice(Y,1);break t}}A=v.createElement(g),ys(A,g,p),v.head.appendChild(A);break;case"meta":if(P=P0("meta","content",v).get(g+(p.content||""))){for(Y=0;Y<P.length;Y++)if(A=P[Y],A.getAttribute("content")===(p.content==null?null:""+p.content)&&A.getAttribute("name")===(p.name==null?null:p.name)&&A.getAttribute("property")===(p.property==null?null:p.property)&&A.getAttribute("http-equiv")===(p.httpEquiv==null?null:p.httpEquiv)&&A.getAttribute("charset")===(p.charSet==null?null:p.charSet)){P.splice(Y,1);break t}}A=v.createElement(g),ys(A,g,p),v.head.appendChild(A);break;default:throw Error(s(468,g))}A[xt]=l,wn(A),g=A}l.stateNode=g}else B0(v,l.type,l.stateNode);else l.stateNode=I0(v,g,l.memoizedProps);else A!==g?(A===null?p.stateNode!==null&&(p=p.stateNode,p.parentNode.removeChild(p)):A.count--,g===null?B0(v,l.type,l.stateNode):I0(v,g,l.memoizedProps)):g===null&&l.stateNode!==null&&Mm(l,l.memoizedProps,p.memoizedProps)}break;case 27:Us(u,l),Hs(l),g&512&&(rs||p===null||Ka(p,p.return)),p!==null&&g&4&&Mm(l,l.memoizedProps,p.memoizedProps);break;case 5:if(Us(u,l),Hs(l),g&512&&(rs||p===null||Ka(p,p.return)),l.flags&32){v=l.stateNode;try{pa(v,"")}catch(yt){xn(l,l.return,yt)}}g&4&&l.stateNode!=null&&(v=l.memoizedProps,Mm(l,v,p!==null?p.memoizedProps:v)),g&1024&&(Om=!0);break;case 6:if(Us(u,l),Hs(l),g&4){if(l.stateNode===null)throw Error(s(162));g=l.memoizedProps,p=l.stateNode;try{p.nodeValue=g}catch(yt){xn(l,l.return,yt)}}break;case 3:if(pf=null,v=Ra,Ra=df(u.containerInfo),Us(u,l),Ra=v,Hs(l),g&4&&p!==null&&p.memoizedState.isDehydrated)try{jl(u.containerInfo)}catch(yt){xn(l,l.return,yt)}Om&&(Om=!1,Bw(l));break;case 4:g=Ra,Ra=df(l.stateNode.containerInfo),Us(u,l),Hs(l),Ra=g;break;case 12:Us(u,l),Hs(l);break;case 31:Us(u,l),Hs(l),g&4&&(g=l.updateQueue,g!==null&&(l.updateQueue=null,Qd(l,g)));break;case 13:Us(u,l),Hs(l),l.child.flags&8192&&l.memoizedState!==null!=(p!==null&&p.memoizedState!==null)&&(Jd=ct()),g&4&&(g=l.updateQueue,g!==null&&(l.updateQueue=null,Qd(l,g)));break;case 22:v=l.memoizedState!==null;var re=p!==null&&p.memoizedState!==null,De=Nr,qe=rs;if(Nr=De||v,rs=qe||re,Us(u,l),rs=qe,Nr=De,Hs(l),g&8192)e:for(u=l.stateNode,u._visibility=v?u._visibility&-2:u._visibility|1,v&&(p===null||re||Nr||rs||co(l)),p=null,u=l;;){if(u.tag===5||u.tag===26){if(p===null){re=p=u;try{if(A=re.stateNode,v)P=A.style,typeof P.setProperty=="function"?P.setProperty("display","none","important"):P.display="none";else{Y=re.stateNode;var Qe=re.memoizedProps.style,Ie=Qe!=null&&Qe.hasOwnProperty("display")?Qe.display:null;Y.style.display=Ie==null||typeof Ie=="boolean"?"":(""+Ie).trim()}}catch(yt){xn(re,re.return,yt)}}}else if(u.tag===6){if(p===null){re=u;try{re.stateNode.nodeValue=v?"":re.memoizedProps}catch(yt){xn(re,re.return,yt)}}}else if(u.tag===18){if(p===null){re=u;try{var Ue=re.stateNode;v?N0(Ue,!0):N0(re.stateNode,!1)}catch(yt){xn(re,re.return,yt)}}}else if((u.tag!==22&&u.tag!==23||u.memoizedState===null||u===l)&&u.child!==null){u.child.return=u,u=u.child;continue}if(u===l)break e;for(;u.sibling===null;){if(u.return===null||u.return===l)break e;p===u&&(p=null),u=u.return}p===u&&(p=null),u.sibling.return=u.return,u=u.sibling}g&4&&(g=l.updateQueue,g!==null&&(p=g.retryQueue,p!==null&&(g.retryQueue=null,Qd(l,p))));break;case 19:Us(u,l),Hs(l),g&4&&(g=l.updateQueue,g!==null&&(l.updateQueue=null,Qd(l,g)));break;case 30:break;case 21:break;default:Us(u,l),Hs(l)}}function Hs(l){var u=l.flags;if(u&2){try{for(var p,g=l.return;g!==null;){if(_w(g)){p=g;break}g=g.return}if(p==null)throw Error(s(160));switch(p.tag){case 27:var v=p.stateNode,A=Dm(l);Kd(l,A,v);break;case 5:var P=p.stateNode;p.flags&32&&(pa(P,""),p.flags&=-33);var Y=Dm(l);Kd(l,Y,P);break;case 3:case 4:var re=p.stateNode.containerInfo,De=Dm(l);Rm(l,De,re);break;default:throw Error(s(161))}}catch(qe){xn(l,l.return,qe)}l.flags&=-3}u&4096&&(l.flags&=-4097)}function Bw(l){if(l.subtreeFlags&1024)for(l=l.child;l!==null;){var u=l;Bw(u),u.tag===5&&u.flags&1024&&u.stateNode.reset(),l=l.sibling}}function _r(l,u){if(u.subtreeFlags&8772)for(u=u.child;u!==null;)Dw(l,u.alternate,u),u=u.sibling}function co(l){for(l=l.child;l!==null;){var u=l;switch(u.tag){case 0:case 11:case 14:case 15:di(4,u,u.return),co(u);break;case 1:Ka(u,u.return);var p=u.stateNode;typeof p.componentWillUnmount=="function"&&Nw(u,u.return,p),co(u);break;case 27:qc(u.stateNode);case 26:case 5:Ka(u,u.return),co(u);break;case 22:u.memoizedState===null&&co(u);break;case 30:co(u);break;default:co(u)}l=l.sibling}}function Er(l,u,p){for(p=p&&(u.subtreeFlags&8772)!==0,u=u.child;u!==null;){var g=u.alternate,v=l,A=u,P=A.flags;switch(A.tag){case 0:case 11:case 15:Er(v,A,p),Lc(4,A);break;case 1:if(Er(v,A,p),g=A,v=g.stateNode,typeof v.componentDidMount=="function")try{v.componentDidMount()}catch(De){xn(g,g.return,De)}if(g=A,v=g.updateQueue,v!==null){var Y=g.stateNode;try{var re=v.shared.hiddenCallbacks;if(re!==null)for(v.shared.hiddenCallbacks=null,v=0;v<re.length;v++)mv(re[v],Y)}catch(De){xn(g,g.return,De)}}p&&P&64&&jw(A),Ic(A,A.return);break;case 27:Ew(A);case 26:case 5:Er(v,A,p),p&&g===null&&P&4&&Tw(A),Ic(A,A.return);break;case 12:Er(v,A,p);break;case 31:Er(v,A,p),p&&P&4&&Lw(v,A);break;case 13:Er(v,A,p),p&&P&4&&Iw(v,A);break;case 22:A.memoizedState===null&&Er(v,A,p),Ic(A,A.return);break;case 30:break;default:Er(v,A,p)}u=u.sibling}}function Lm(l,u){var p=null;l!==null&&l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(p=l.memoizedState.cachePool.pool),l=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(l=u.memoizedState.cachePool.pool),l!==p&&(l!=null&&l.refCount++,p!=null&&kc(p))}function Im(l,u){l=null,u.alternate!==null&&(l=u.alternate.memoizedState.cache),u=u.memoizedState.cache,u!==l&&(u.refCount++,l!=null&&kc(l))}function Oa(l,u,p,g){if(u.subtreeFlags&10256)for(u=u.child;u!==null;)Fw(l,u,p,g),u=u.sibling}function Fw(l,u,p,g){var v=u.flags;switch(u.tag){case 0:case 11:case 15:Oa(l,u,p,g),v&2048&&Lc(9,u);break;case 1:Oa(l,u,p,g);break;case 3:Oa(l,u,p,g),v&2048&&(l=null,u.alternate!==null&&(l=u.alternate.memoizedState.cache),u=u.memoizedState.cache,u!==l&&(u.refCount++,l!=null&&kc(l)));break;case 12:if(v&2048){Oa(l,u,p,g),l=u.stateNode;try{var A=u.memoizedProps,P=A.id,Y=A.onPostCommit;typeof Y=="function"&&Y(P,u.alternate===null?"mount":"update",l.passiveEffectDuration,-0)}catch(re){xn(u,u.return,re)}}else Oa(l,u,p,g);break;case 31:Oa(l,u,p,g);break;case 13:Oa(l,u,p,g);break;case 23:break;case 22:A=u.stateNode,P=u.alternate,u.memoizedState!==null?A._visibility&2?Oa(l,u,p,g):Pc(l,u):A._visibility&2?Oa(l,u,p,g):(A._visibility|=2,ml(l,u,p,g,(u.subtreeFlags&10256)!==0||!1)),v&2048&&Lm(P,u);break;case 24:Oa(l,u,p,g),v&2048&&Im(u.alternate,u);break;default:Oa(l,u,p,g)}}function ml(l,u,p,g,v){for(v=v&&((u.subtreeFlags&10256)!==0||!1),u=u.child;u!==null;){var A=l,P=u,Y=p,re=g,De=P.flags;switch(P.tag){case 0:case 11:case 15:ml(A,P,Y,re,v),Lc(8,P);break;case 23:break;case 22:var qe=P.stateNode;P.memoizedState!==null?qe._visibility&2?ml(A,P,Y,re,v):Pc(A,P):(qe._visibility|=2,ml(A,P,Y,re,v)),v&&De&2048&&Lm(P.alternate,P);break;case 24:ml(A,P,Y,re,v),v&&De&2048&&Im(P.alternate,P);break;default:ml(A,P,Y,re,v)}u=u.sibling}}function Pc(l,u){if(u.subtreeFlags&10256)for(u=u.child;u!==null;){var p=l,g=u,v=g.flags;switch(g.tag){case 22:Pc(p,g),v&2048&&Lm(g.alternate,g);break;case 24:Pc(p,g),v&2048&&Im(g.alternate,g);break;default:Pc(p,g)}u=u.sibling}}var Bc=8192;function gl(l,u,p){if(l.subtreeFlags&Bc)for(l=l.child;l!==null;)zw(l,u,p),l=l.sibling}function zw(l,u,p){switch(l.tag){case 26:gl(l,u,p),l.flags&Bc&&l.memoizedState!==null&&xE(p,Ra,l.memoizedState,l.memoizedProps);break;case 5:gl(l,u,p);break;case 3:case 4:var g=Ra;Ra=df(l.stateNode.containerInfo),gl(l,u,p),Ra=g;break;case 22:l.memoizedState===null&&(g=l.alternate,g!==null&&g.memoizedState!==null?(g=Bc,Bc=16777216,gl(l,u,p),Bc=g):gl(l,u,p));break;default:gl(l,u,p)}}function $w(l){var u=l.alternate;if(u!==null&&(l=u.child,l!==null)){u.child=null;do u=l.sibling,l.sibling=null,l=u;while(l!==null)}}function Fc(l){var u=l.deletions;if((l.flags&16)!==0){if(u!==null)for(var p=0;p<u.length;p++){var g=u[p];ds=g,Hw(g,l)}$w(l)}if(l.subtreeFlags&10256)for(l=l.child;l!==null;)Uw(l),l=l.sibling}function Uw(l){switch(l.tag){case 0:case 11:case 15:Fc(l),l.flags&2048&&di(9,l,l.return);break;case 3:Fc(l);break;case 12:Fc(l);break;case 22:var u=l.stateNode;l.memoizedState!==null&&u._visibility&2&&(l.return===null||l.return.tag!==13)?(u._visibility&=-3,Xd(l)):Fc(l);break;default:Fc(l)}}function Xd(l){var u=l.deletions;if((l.flags&16)!==0){if(u!==null)for(var p=0;p<u.length;p++){var g=u[p];ds=g,Hw(g,l)}$w(l)}for(l=l.child;l!==null;){switch(u=l,u.tag){case 0:case 11:case 15:di(8,u,u.return),Xd(u);break;case 22:p=u.stateNode,p._visibility&2&&(p._visibility&=-3,Xd(u));break;default:Xd(u)}l=l.sibling}}function Hw(l,u){for(;ds!==null;){var p=ds;switch(p.tag){case 0:case 11:case 15:di(8,p,u);break;case 23:case 22:if(p.memoizedState!==null&&p.memoizedState.cachePool!==null){var g=p.memoizedState.cachePool.pool;g!=null&&g.refCount++}break;case 24:kc(p.memoizedState.cache)}if(g=p.child,g!==null)g.return=p,ds=g;else e:for(p=l;ds!==null;){g=ds;var v=g.sibling,A=g.return;if(Rw(g),g===p){ds=null;break e}if(v!==null){v.return=A,ds=v;break e}ds=A}}}var R_={getCacheForType:function(l){var u=bs(ns),p=u.data.get(l);return p===void 0&&(p=l(),u.data.set(l,p)),p},cacheSignal:function(){return bs(ns).controller.signal}},O_=typeof WeakMap=="function"?WeakMap:Map,hn=0,Nn=null,Kt=null,an=0,bn=0,na=null,fi=!1,bl=!1,Pm=!1,Mr=0,Yn=0,pi=0,uo=0,Bm=0,sa=0,xl=0,zc=null,Ws=null,Fm=!1,Jd=0,Ww=0,Zd=1/0,ef=null,hi=null,ls=0,mi=null,yl=null,Dr=0,zm=0,$m=null,qw=null,$c=0,Um=null;function aa(){return(hn&2)!==0&&an!==0?an&-an:F.T!==null?Gm():ln()}function Vw(){if(sa===0)if((an&536870912)===0||cn){var l=ft;ft<<=1,(ft&3932160)===0&&(ft=262144),sa=l}else sa=536870912;return l=ea.current,l!==null&&(l.flags|=32),sa}function qs(l,u,p){(l===Nn&&(bn===2||bn===9)||l.cancelPendingCommit!==null)&&(vl(l,0),gi(l,an,sa,!1)),Le(l,p),((hn&2)===0||l!==Nn)&&(l===Nn&&((hn&2)===0&&(uo|=p),Yn===4&&gi(l,an,sa,!1)),Qa(l))}function Yw(l,u,p){if((hn&6)!==0)throw Error(s(327));var g=!p&&(u&127)===0&&(u&l.expiredLanes)===0||ht(l,u),v=g?P_(l,u):Wm(l,u,!0),A=g;do{if(v===0){bl&&!g&&gi(l,u,0,!1);break}else{if(p=l.current.alternate,A&&!L_(p)){v=Wm(l,u,!1),A=!1;continue}if(v===2){if(A=u,l.errorRecoveryDisabledLanes&A)var P=0;else P=l.pendingLanes&-536870913,P=P!==0?P:P&536870912?536870912:0;if(P!==0){u=P;e:{var Y=l;v=zc;var re=Y.current.memoizedState.isDehydrated;if(re&&(vl(Y,P).flags|=256),P=Wm(Y,P,!1),P!==2){if(Pm&&!re){Y.errorRecoveryDisabledLanes|=A,uo|=A,v=4;break e}A=Ws,Ws=v,A!==null&&(Ws===null?Ws=A:Ws.push.apply(Ws,A))}v=P}if(A=!1,v!==2)continue}}if(v===1){vl(l,0),gi(l,u,0,!0);break}e:{switch(g=l,A=v,A){case 0:case 1:throw Error(s(345));case 4:if((u&4194048)!==u)break;case 6:gi(g,u,sa,!fi);break e;case 2:Ws=null;break;case 3:case 5:break;default:throw Error(s(329))}if((u&62914560)===u&&(v=Jd+300-ct(),10<v)){if(gi(g,u,sa,!fi),gt(g,0,!0)!==0)break e;Dr=u,g.timeoutHandle=C0(Gw.bind(null,g,p,Ws,ef,Fm,u,sa,uo,xl,fi,A,"Throttled",-0,0),v);break e}Gw(g,p,Ws,ef,Fm,u,sa,uo,xl,fi,A,null,-0,0)}}break}while(!0);Qa(l)}function Gw(l,u,p,g,v,A,P,Y,re,De,qe,Qe,Ie,Ue){if(l.timeoutHandle=-1,Qe=u.subtreeFlags,Qe&8192||(Qe&16785408)===16785408){Qe={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:It},zw(u,A,Qe);var yt=(A&62914560)===A?Jd-ct():(A&4194048)===A?Ww-ct():0;if(yt=yE(Qe,yt),yt!==null){Dr=A,l.cancelPendingCommit=yt(n0.bind(null,l,u,A,p,g,v,P,Y,re,qe,Qe,null,Ie,Ue)),gi(l,A,P,!De);return}}n0(l,u,A,p,g,v,P,Y,re)}function L_(l){for(var u=l;;){var p=u.tag;if((p===0||p===11||p===15)&&u.flags&16384&&(p=u.updateQueue,p!==null&&(p=p.stores,p!==null)))for(var g=0;g<p.length;g++){var v=p[g],A=v.getSnapshot;v=v.value;try{if(!Js(A(),v))return!1}catch{return!1}}if(p=u.child,u.subtreeFlags&16384&&p!==null)p.return=u,u=p;else{if(u===l)break;for(;u.sibling===null;){if(u.return===null||u.return===l)return!0;u=u.return}u.sibling.return=u.return,u=u.sibling}}return!0}function gi(l,u,p,g){u&=~Bm,u&=~uo,l.suspendedLanes|=u,l.pingedLanes&=~u,g&&(l.warmLanes|=u),g=l.expirationTimes;for(var v=u;0<v;){var A=31-ge(v),P=1<<A;g[A]=-1,v&=~P}p!==0&&Ze(l,p,u)}function tf(){return(hn&6)===0?(Uc(0),!1):!0}function Hm(){if(Kt!==null){if(bn===0)var l=Kt.return;else l=Kt,wr=to=null,rm(l),ul=null,Cc=0,l=Kt;for(;l!==null;)Aw(l.alternate,l),l=l.return;Kt=null}}function vl(l,u){var p=l.timeoutHandle;p!==-1&&(l.timeoutHandle=-1,tE(p)),p=l.cancelPendingCommit,p!==null&&(l.cancelPendingCommit=null,p()),Dr=0,Hm(),Nn=l,Kt=p=yr(l.current,null),an=u,bn=0,na=null,fi=!1,bl=ht(l,u),Pm=!1,xl=sa=Bm=uo=pi=Yn=0,Ws=zc=null,Fm=!1,(u&8)!==0&&(u|=u&32);var g=l.entangledLanes;if(g!==0)for(l=l.entanglements,g&=u;0<g;){var v=31-ge(g),A=1<<v;u|=l[v],g&=~A}return Mr=u,kd(),p}function Kw(l,u){Ut=null,F.H=Dc,u===cl||u===Ed?(u=dv(),bn=3):u===Yh?(u=dv(),bn=4):bn=u===wm?8:u!==null&&typeof u=="object"&&typeof u.then=="function"?6:1,na=u,Kt===null&&(Yn=1,Wd(l,ba(u,l.current)))}function Qw(){var l=ea.current;return l===null?!0:(an&4194048)===an?wa===null:(an&62914560)===an||(an&536870912)!==0?l===wa:!1}function Xw(){var l=F.H;return F.H=Dc,l===null?Dc:l}function Jw(){var l=F.A;return F.A=R_,l}function nf(){Yn=4,fi||(an&4194048)!==an&&ea.current!==null||(bl=!0),(pi&134217727)===0&&(uo&134217727)===0||Nn===null||gi(Nn,an,sa,!1)}function Wm(l,u,p){var g=hn;hn|=2;var v=Xw(),A=Jw();(Nn!==l||an!==u)&&(ef=null,vl(l,u)),u=!1;var P=Yn;e:do try{if(bn!==0&&Kt!==null){var Y=Kt,re=na;switch(bn){case 8:Hm(),P=6;break e;case 3:case 2:case 9:case 6:ea.current===null&&(u=!0);var De=bn;if(bn=0,na=null,wl(l,Y,re,De),p&&bl){P=0;break e}break;default:De=bn,bn=0,na=null,wl(l,Y,re,De)}}I_(),P=Yn;break}catch(qe){Kw(l,qe)}while(!0);return u&&l.shellSuspendCounter++,wr=to=null,hn=g,F.H=v,F.A=A,Kt===null&&(Nn=null,an=0,kd()),P}function I_(){for(;Kt!==null;)Zw(Kt)}function P_(l,u){var p=hn;hn|=2;var g=Xw(),v=Jw();Nn!==l||an!==u?(ef=null,Zd=ct()+500,vl(l,u)):bl=ht(l,u);e:do try{if(bn!==0&&Kt!==null){u=Kt;var A=na;t:switch(bn){case 1:bn=0,na=null,wl(l,u,A,1);break;case 2:case 9:if(cv(A)){bn=0,na=null,e0(u);break}u=function(){bn!==2&&bn!==9||Nn!==l||(bn=7),Qa(l)},A.then(u,u);break e;case 3:bn=7;break e;case 4:bn=5;break e;case 7:cv(A)?(bn=0,na=null,e0(u)):(bn=0,na=null,wl(l,u,A,7));break;case 5:var P=null;switch(Kt.tag){case 26:P=Kt.memoizedState;case 5:case 27:var Y=Kt;if(P?F0(P):Y.stateNode.complete){bn=0,na=null;var re=Y.sibling;if(re!==null)Kt=re;else{var De=Y.return;De!==null?(Kt=De,sf(De)):Kt=null}break t}}bn=0,na=null,wl(l,u,A,5);break;case 6:bn=0,na=null,wl(l,u,A,6);break;case 8:Hm(),Yn=6;break e;default:throw Error(s(462))}}B_();break}catch(qe){Kw(l,qe)}while(!0);return wr=to=null,F.H=g,F.A=v,hn=p,Kt!==null?0:(Nn=null,an=0,kd(),Yn)}function B_(){for(;Kt!==null&&!He();)Zw(Kt)}function Zw(l){var u=Sw(l.alternate,l,Mr);l.memoizedProps=l.pendingProps,u===null?sf(l):Kt=u}function e0(l){var u=l,p=u.alternate;switch(u.tag){case 15:case 0:u=bw(p,u,u.pendingProps,u.type,void 0,an);break;case 11:u=bw(p,u,u.pendingProps,u.type.render,u.ref,an);break;case 5:rm(u);default:Aw(p,u),u=Kt=Jy(u,Mr),u=Sw(p,u,Mr)}l.memoizedProps=l.pendingProps,u===null?sf(l):Kt=u}function wl(l,u,p,g){wr=to=null,rm(u),ul=null,Cc=0;var v=u.return;try{if(j_(l,v,u,p,an)){Yn=1,Wd(l,ba(p,l.current)),Kt=null;return}}catch(A){if(v!==null)throw Kt=v,A;Yn=1,Wd(l,ba(p,l.current)),Kt=null;return}u.flags&32768?(cn||g===1?l=!0:bl||(an&536870912)!==0?l=!1:(fi=l=!0,(g===2||g===9||g===3||g===6)&&(g=ea.current,g!==null&&g.tag===13&&(g.flags|=16384))),t0(u,l)):sf(u)}function sf(l){var u=l;do{if((u.flags&32768)!==0){t0(u,fi);return}l=u.return;var p=__(u.alternate,u,Mr);if(p!==null){Kt=p;return}if(u=u.sibling,u!==null){Kt=u;return}Kt=u=l}while(u!==null);Yn===0&&(Yn=5)}function t0(l,u){do{var p=E_(l.alternate,l);if(p!==null){p.flags&=32767,Kt=p;return}if(p=l.return,p!==null&&(p.flags|=32768,p.subtreeFlags=0,p.deletions=null),!u&&(l=l.sibling,l!==null)){Kt=l;return}Kt=l=p}while(l!==null);Yn=6,Kt=null}function n0(l,u,p,g,v,A,P,Y,re){l.cancelPendingCommit=null;do af();while(ls!==0);if((hn&6)!==0)throw Error(s(327));if(u!==null){if(u===l.current)throw Error(s(177));if(A=u.lanes|u.childLanes,A|=Dh,Ye(l,p,A,P,Y,re),l===Nn&&(Kt=Nn=null,an=0),yl=u,mi=l,Dr=p,zm=A,$m=v,qw=g,(u.subtreeFlags&10256)!==0||(u.flags&10256)!==0?(l.callbackNode=null,l.callbackPriority=0,U_(ke,function(){return o0(),null})):(l.callbackNode=null,l.callbackPriority=0),g=(u.flags&13878)!==0,(u.subtreeFlags&13878)!==0||g){g=F.T,F.T=null,v=H.p,H.p=2,P=hn,hn|=4;try{M_(l,u,p)}finally{hn=P,H.p=v,F.T=g}}ls=1,s0(),a0(),r0()}}function s0(){if(ls===1){ls=0;var l=mi,u=yl,p=(u.flags&13878)!==0;if((u.subtreeFlags&13878)!==0||p){p=F.T,F.T=null;var g=H.p;H.p=2;var v=hn;hn|=4;try{Pw(u,l);var A=ng,P=Hy(l.containerInfo),Y=A.focusedElem,re=A.selectionRange;if(P!==Y&&Y&&Y.ownerDocument&&Uy(Y.ownerDocument.documentElement,Y)){if(re!==null&&Nh(Y)){var De=re.start,qe=re.end;if(qe===void 0&&(qe=De),"selectionStart"in Y)Y.selectionStart=De,Y.selectionEnd=Math.min(qe,Y.value.length);else{var Qe=Y.ownerDocument||document,Ie=Qe&&Qe.defaultView||window;if(Ie.getSelection){var Ue=Ie.getSelection(),yt=Y.textContent.length,Dt=Math.min(re.start,yt),An=re.end===void 0?Dt:Math.min(re.end,yt);!Ue.extend&&Dt>An&&(P=An,An=Dt,Dt=P);var we=$y(Y,Dt),le=$y(Y,An);if(we&&le&&(Ue.rangeCount!==1||Ue.anchorNode!==we.node||Ue.anchorOffset!==we.offset||Ue.focusNode!==le.node||Ue.focusOffset!==le.offset)){var _e=Qe.createRange();_e.setStart(we.node,we.offset),Ue.removeAllRanges(),Dt>An?(Ue.addRange(_e),Ue.extend(le.node,le.offset)):(_e.setEnd(le.node,le.offset),Ue.addRange(_e))}}}}for(Qe=[],Ue=Y;Ue=Ue.parentNode;)Ue.nodeType===1&&Qe.push({element:Ue,left:Ue.scrollLeft,top:Ue.scrollTop});for(typeof Y.focus=="function"&&Y.focus(),Y=0;Y<Qe.length;Y++){var Ge=Qe[Y];Ge.element.scrollLeft=Ge.left,Ge.element.scrollTop=Ge.top}}bf=!!tg,ng=tg=null}finally{hn=v,H.p=g,F.T=p}}l.current=u,ls=2}}function a0(){if(ls===2){ls=0;var l=mi,u=yl,p=(u.flags&8772)!==0;if((u.subtreeFlags&8772)!==0||p){p=F.T,F.T=null;var g=H.p;H.p=2;var v=hn;hn|=4;try{Dw(l,u.alternate,u)}finally{hn=v,H.p=g,F.T=p}}ls=3}}function r0(){if(ls===4||ls===3){ls=0,et();var l=mi,u=yl,p=Dr,g=qw;(u.subtreeFlags&10256)!==0||(u.flags&10256)!==0?ls=5:(ls=0,yl=mi=null,i0(l,l.pendingLanes));var v=l.pendingLanes;if(v===0&&(hi=null),Vt(p),u=u.stateNode,Pe&&typeof Pe.onCommitFiberRoot=="function")try{Pe.onCommitFiberRoot(xe,u,void 0,(u.current.flags&128)===128)}catch{}if(g!==null){u=F.T,v=H.p,H.p=2,F.T=null;try{for(var A=l.onRecoverableError,P=0;P<g.length;P++){var Y=g[P];A(Y.value,{componentStack:Y.stack})}}finally{F.T=u,H.p=v}}(Dr&3)!==0&&af(),Qa(l),v=l.pendingLanes,(p&261930)!==0&&(v&42)!==0?l===Um?$c++:($c=0,Um=l):$c=0,Uc(0)}}function i0(l,u){(l.pooledCacheLanes&=u)===0&&(u=l.pooledCache,u!=null&&(l.pooledCache=null,kc(u)))}function af(){return s0(),a0(),r0(),o0()}function o0(){if(ls!==5)return!1;var l=mi,u=zm;zm=0;var p=Vt(Dr),g=F.T,v=H.p;try{H.p=32>p?32:p,F.T=null,p=$m,$m=null;var A=mi,P=Dr;if(ls=0,yl=mi=null,Dr=0,(hn&6)!==0)throw Error(s(331));var Y=hn;if(hn|=4,Uw(A.current),Fw(A,A.current,P,p),hn=Y,Uc(0,!1),Pe&&typeof Pe.onPostCommitFiberRoot=="function")try{Pe.onPostCommitFiberRoot(xe,A)}catch{}return!0}finally{H.p=v,F.T=g,i0(l,u)}}function l0(l,u,p){u=ba(p,u),u=vm(l.stateNode,u,2),l=li(l,u,2),l!==null&&(Le(l,2),Qa(l))}function xn(l,u,p){if(l.tag===3)l0(l,l,p);else for(;u!==null;){if(u.tag===3){l0(u,l,p);break}else if(u.tag===1){var g=u.stateNode;if(typeof u.type.getDerivedStateFromError=="function"||typeof g.componentDidCatch=="function"&&(hi===null||!hi.has(g))){l=ba(p,l),p=cw(2),g=li(u,p,2),g!==null&&(uw(p,g,u,l),Le(g,2),Qa(g));break}}u=u.return}}function qm(l,u,p){var g=l.pingCache;if(g===null){g=l.pingCache=new O_;var v=new Set;g.set(u,v)}else v=g.get(u),v===void 0&&(v=new Set,g.set(u,v));v.has(p)||(Pm=!0,v.add(p),l=F_.bind(null,l,u,p),u.then(l,l))}function F_(l,u,p){var g=l.pingCache;g!==null&&g.delete(u),l.pingedLanes|=l.suspendedLanes&p,l.warmLanes&=~p,Nn===l&&(an&p)===p&&(Yn===4||Yn===3&&(an&62914560)===an&&300>ct()-Jd?(hn&2)===0&&vl(l,0):Bm|=p,xl===an&&(xl=0)),Qa(l)}function c0(l,u){u===0&&(u=tn()),l=Ji(l,u),l!==null&&(Le(l,u),Qa(l))}function z_(l){var u=l.memoizedState,p=0;u!==null&&(p=u.retryLane),c0(l,p)}function $_(l,u){var p=0;switch(l.tag){case 31:case 13:var g=l.stateNode,v=l.memoizedState;v!==null&&(p=v.retryLane);break;case 19:g=l.stateNode;break;case 22:g=l.stateNode._retryCache;break;default:throw Error(s(314))}g!==null&&g.delete(u),c0(l,p)}function U_(l,u){return oe(l,u)}var rf=null,kl=null,Vm=!1,of=!1,Ym=!1,bi=0;function Qa(l){l!==kl&&l.next===null&&(kl===null?rf=kl=l:kl=kl.next=l),of=!0,Vm||(Vm=!0,W_())}function Uc(l,u){if(!Ym&&of){Ym=!0;do for(var p=!1,g=rf;g!==null;){if(l!==0){var v=g.pendingLanes;if(v===0)var A=0;else{var P=g.suspendedLanes,Y=g.pingedLanes;A=(1<<31-ge(42|l)+1)-1,A&=v&~(P&~Y),A=A&201326741?A&201326741|1:A?A|2:0}A!==0&&(p=!0,p0(g,A))}else A=an,A=gt(g,g===Nn?A:0,g.cancelPendingCommit!==null||g.timeoutHandle!==-1),(A&3)===0||ht(g,A)||(p=!0,p0(g,A));g=g.next}while(p);Ym=!1}}function H_(){u0()}function u0(){of=Vm=!1;var l=0;bi!==0&&eE()&&(l=bi);for(var u=ct(),p=null,g=rf;g!==null;){var v=g.next,A=d0(g,u);A===0?(g.next=null,p===null?rf=v:p.next=v,v===null&&(kl=p)):(p=g,(l!==0||(A&3)!==0)&&(of=!0)),g=v}ls!==0&&ls!==5||Uc(l),bi!==0&&(bi=0)}function d0(l,u){for(var p=l.suspendedLanes,g=l.pingedLanes,v=l.expirationTimes,A=l.pendingLanes&-62914561;0<A;){var P=31-ge(A),Y=1<<P,re=v[P];re===-1?((Y&p)===0||(Y&g)!==0)&&(v[P]=Gt(Y,u)):re<=u&&(l.expiredLanes|=Y),A&=~Y}if(u=Nn,p=an,p=gt(l,l===u?p:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),g=l.callbackNode,p===0||l===u&&(bn===2||bn===9)||l.cancelPendingCommit!==null)return g!==null&&g!==null&&de(g),l.callbackNode=null,l.callbackPriority=0;if((p&3)===0||ht(l,p)){if(u=p&-p,u===l.callbackPriority)return u;switch(g!==null&&de(g),Vt(p)){case 2:case 8:p=ae;break;case 32:p=ke;break;case 268435456:p=he;break;default:p=ke}return g=f0.bind(null,l),p=oe(p,g),l.callbackPriority=u,l.callbackNode=p,u}return g!==null&&g!==null&&de(g),l.callbackPriority=2,l.callbackNode=null,2}function f0(l,u){if(ls!==0&&ls!==5)return l.callbackNode=null,l.callbackPriority=0,null;var p=l.callbackNode;if(af()&&l.callbackNode!==p)return null;var g=an;return g=gt(l,l===Nn?g:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),g===0?null:(Yw(l,g,u),d0(l,ct()),l.callbackNode!=null&&l.callbackNode===p?f0.bind(null,l):null)}function p0(l,u){if(af())return null;Yw(l,u,!0)}function W_(){nE(function(){(hn&6)!==0?oe(X,H_):u0()})}function Gm(){if(bi===0){var l=ol;l===0&&(l=at,at<<=1,(at&261888)===0&&(at=256)),bi=l}return bi}function h0(l){return l==null||typeof l=="symbol"||typeof l=="boolean"?null:typeof l=="function"?l:Fo(""+l)}function m0(l,u){var p=u.ownerDocument.createElement("input");return p.name=u.name,p.value=u.value,l.id&&p.setAttribute("form",l.id),u.parentNode.insertBefore(p,u),l=new FormData(l),p.parentNode.removeChild(p),l}function q_(l,u,p,g,v){if(u==="submit"&&p&&p.stateNode===v){var A=h0((v[$t]||null).action),P=g.submitter;P&&(u=(u=P[$t]||null)?h0(u.formAction):P.getAttribute("formAction"),u!==null&&(A=u,P=null));var Y=new Ln("action","action",null,g,v);l.push({event:Y,listeners:[{instance:null,listener:function(){if(g.defaultPrevented){if(bi!==0){var re=P?m0(v,P):new FormData(v);hm(p,{pending:!0,data:re,method:v.method,action:A},null,re)}}else typeof A=="function"&&(Y.preventDefault(),re=P?m0(v,P):new FormData(v),hm(p,{pending:!0,data:re,method:v.method,action:A},A,re))},currentTarget:v}]})}}for(var Km=0;Km<Mh.length;Km++){var Qm=Mh[Km],V_=Qm.toLowerCase(),Y_=Qm[0].toUpperCase()+Qm.slice(1);Da(V_,"on"+Y_)}Da(Vy,"onAnimationEnd"),Da(Yy,"onAnimationIteration"),Da(Gy,"onAnimationStart"),Da("dblclick","onDoubleClick"),Da("focusin","onFocus"),Da("focusout","onBlur"),Da(c_,"onTransitionRun"),Da(u_,"onTransitionStart"),Da(d_,"onTransitionCancel"),Da(Ky,"onTransitionEnd"),Ua("onMouseEnter",["mouseout","mouseover"]),Ua("onMouseLeave",["mouseout","mouseover"]),Ua("onPointerEnter",["pointerout","pointerover"]),Ua("onPointerLeave",["pointerout","pointerover"]),Ps("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Ps("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Ps("onBeforeInput",["compositionend","keypress","textInput","paste"]),Ps("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Ps("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Ps("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Hc="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(" "),G_=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Hc));function g0(l,u){u=(u&4)!==0;for(var p=0;p<l.length;p++){var g=l[p],v=g.event;g=g.listeners;e:{var A=void 0;if(u)for(var P=g.length-1;0<=P;P--){var Y=g[P],re=Y.instance,De=Y.currentTarget;if(Y=Y.listener,re!==A&&v.isPropagationStopped())break e;A=Y,v.currentTarget=De;try{A(v)}catch(qe){wd(qe)}v.currentTarget=null,A=re}else for(P=0;P<g.length;P++){if(Y=g[P],re=Y.instance,De=Y.currentTarget,Y=Y.listener,re!==A&&v.isPropagationStopped())break e;A=Y,v.currentTarget=De;try{A(v)}catch(qe){wd(qe)}v.currentTarget=null,A=re}}}}function Qt(l,u){var p=u[nn];p===void 0&&(p=u[nn]=new Set);var g=l+"__bubble";p.has(g)||(b0(u,l,2,!1),p.add(g))}function Xm(l,u,p){var g=0;u&&(g|=4),b0(p,l,g,u)}var lf="_reactListening"+Math.random().toString(36).slice(2);function Jm(l){if(!l[lf]){l[lf]=!0,Po.forEach(function(p){p!=="selectionchange"&&(G_.has(p)||Xm(p,!1,l),Xm(p,!0,l))});var u=l.nodeType===9?l:l.ownerDocument;u===null||u[lf]||(u[lf]=!0,Xm("selectionchange",!1,u))}}function b0(l,u,p,g){switch(V0(u)){case 2:var v=kE;break;case 8:v=SE;break;default:v=pg}p=v.bind(null,u,p,l),v=void 0,!Hi||u!=="touchstart"&&u!=="touchmove"&&u!=="wheel"||(v=!0),g?v!==void 0?l.addEventListener(u,p,{capture:!0,passive:v}):l.addEventListener(u,p,!0):v!==void 0?l.addEventListener(u,p,{passive:v}):l.addEventListener(u,p,!1)}function Zm(l,u,p,g,v){var A=g;if((u&1)===0&&(u&2)===0&&g!==null)e:for(;;){if(g===null)return;var P=g.tag;if(P===3||P===4){var Y=g.stateNode.containerInfo;if(Y===v)break;if(P===4)for(P=g.return;P!==null;){var re=P.tag;if((re===3||re===4)&&P.stateNode.containerInfo===v)return;P=P.return}for(;Y!==null;){if(P=Ss(Y),P===null)return;if(re=P.tag,re===5||re===6||re===26||re===27){g=A=P;continue e}Y=Y.parentNode}}g=g.return}cd(function(){var De=A,qe=uc(p),Qe=[];e:{var Ie=Qy.get(l);if(Ie!==void 0){var Ue=Ln,yt=l;switch(l){case"keypress":if(Wi(p)===0)break e;case"keydown":case"keyup":Ue=kh;break;case"focusin":yt="focus",Ue=ei;break;case"focusout":yt="blur",Ue=ei;break;case"beforeblur":case"afterblur":Ue=ei;break;case"click":if(p.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ue=fd;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ue=Vo;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ue=bd;break;case Vy:case Yy:case Gy:Ue=fc;break;case Ky:Ue=hc;break;case"scroll":case"scrollend":Ue=dd;break;case"wheel":Ue=Ch;break;case"copy":case"cut":case"paste":Ue=pc;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ue=qa;break;case"toggle":case"beforetoggle":Ue=jh}var Dt=(u&4)!==0,An=!Dt&&(l==="scroll"||l==="scrollend"),we=Dt?Ie!==null?Ie+"Capture":null:Ie;Dt=[];for(var le=De,_e;le!==null;){var Ge=le;if(_e=Ge.stateNode,Ge=Ge.tag,Ge!==5&&Ge!==26&&Ge!==27||_e===null||we===null||(Ge=Ha(le,we),Ge!=null&&Dt.push(Wc(le,Ge,_e))),An)break;le=le.return}0<Dt.length&&(Ie=new Ue(Ie,yt,null,p,qe),Qe.push({event:Ie,listeners:Dt}))}}if((u&7)===0){e:{if(Ie=l==="mouseover"||l==="pointerover",Ue=l==="mouseout"||l==="pointerout",Ie&&p!==Hn&&(yt=p.relatedTarget||p.fromElement)&&(Ss(yt)||yt[En]))break e;if((Ue||Ie)&&(Ie=qe.window===qe?qe:(Ie=qe.ownerDocument)?Ie.defaultView||Ie.parentWindow:window,Ue?(yt=p.relatedTarget||p.toElement,Ue=De,yt=yt?Ss(yt):null,yt!==null&&(An=r(yt),Dt=yt.tag,yt!==An||Dt!==5&&Dt!==27&&Dt!==6)&&(yt=null)):(Ue=null,yt=De),Ue!==yt)){if(Dt=fd,Ge="onMouseLeave",we="onMouseEnter",le="mouse",(l==="pointerout"||l==="pointerover")&&(Dt=qa,Ge="onPointerLeave",we="onPointerEnter",le="pointer"),An=Ue==null?Ie:Ls(Ue),_e=yt==null?Ie:Ls(yt),Ie=new Dt(Ge,le+"leave",Ue,p,qe),Ie.target=An,Ie.relatedTarget=_e,Ge=null,Ss(qe)===De&&(Dt=new Dt(we,le+"enter",yt,p,qe),Dt.target=_e,Dt.relatedTarget=An,Ge=Dt),An=Ge,Ue&&yt)t:{for(Dt=K_,we=Ue,le=yt,_e=0,Ge=we;Ge;Ge=Dt(Ge))_e++;Ge=0;for(var Tt=le;Tt;Tt=Dt(Tt))Ge++;for(;0<_e-Ge;)we=Dt(we),_e--;for(;0<Ge-_e;)le=Dt(le),Ge--;for(;_e--;){if(we===le||le!==null&&we===le.alternate){Dt=we;break t}we=Dt(we),le=Dt(le)}Dt=null}else Dt=null;Ue!==null&&x0(Qe,Ie,Ue,Dt,!1),yt!==null&&An!==null&&x0(Qe,An,yt,Dt,!0)}}e:{if(Ie=De?Ls(De):window,Ue=Ie.nodeName&&Ie.nodeName.toLowerCase(),Ue==="select"||Ue==="input"&&Ie.type==="file")var fn=gc;else if(sn(Ie))if(Xo)fn=i_;else{fn=a_;var kt=s_}else Ue=Ie.nodeName,!Ue||Ue.toLowerCase()!=="input"||Ie.type!=="checkbox"&&Ie.type!=="radio"?De&&gr(De.elementType)&&(fn=gc):fn=r_;if(fn&&(fn=fn(l,De))){gn(Qe,fn,p,qe);break e}kt&&kt(l,Ie,De),l==="focusout"&&De&&Ie.type==="number"&&De.memoizedProps.value!=null&&ms(Ie,"number",Ie.value)}switch(kt=De?Ls(De):window,l){case"focusin":(sn(kt)||kt.contentEditable==="true")&&(Zo=kt,Th=De,yc=null);break;case"focusout":yc=Th=Zo=null;break;case"mousedown":_h=!0;break;case"contextmenu":case"mouseup":case"dragend":_h=!1,Wy(Qe,p,qe);break;case"selectionchange":if(l_)break;case"keydown":case"keyup":Wy(Qe,p,qe)}var Ht;if(Ko)e:{switch(l){case"compositionstart":var rn="onCompositionStart";break e;case"compositionend":rn="onCompositionEnd";break e;case"compositionupdate":rn="onCompositionUpdate";break e}rn=void 0}else nt?ce(l,p)&&(rn="onCompositionEnd"):l==="keydown"&&p.keyCode===229&&(rn="onCompositionStart");rn&&(mc&&p.locale!=="ko"&&(nt||rn!=="onCompositionStart"?rn==="onCompositionEnd"&&nt&&(Ht=ud()):(ma=qe,$o="value"in ma?ma.value:ma.textContent,nt=!0)),kt=cf(De,rn),0<kt.length&&(rn=new hd(rn,l,null,p,qe),Qe.push({event:rn,listeners:kt}),Ht?rn.data=Ht:(Ht=Me(p),Ht!==null&&(rn.data=Ht)))),(Ht=yd?ut(l,p):Nt(l,p))&&(rn=cf(De,"onBeforeInput"),0<rn.length&&(kt=new hd("onBeforeInput","beforeinput",null,p,qe),Qe.push({event:kt,listeners:rn}),kt.data=Ht)),q_(Qe,l,De,p,qe)}g0(Qe,u)})}function Wc(l,u,p){return{instance:l,listener:u,currentTarget:p}}function cf(l,u){for(var p=u+"Capture",g=[];l!==null;){var v=l,A=v.stateNode;if(v=v.tag,v!==5&&v!==26&&v!==27||A===null||(v=Ha(l,p),v!=null&&g.unshift(Wc(l,v,A)),v=Ha(l,u),v!=null&&g.push(Wc(l,v,A))),l.tag===3)return g;l=l.return}return[]}function K_(l){if(l===null)return null;do l=l.return;while(l&&l.tag!==5&&l.tag!==27);return l||null}function x0(l,u,p,g,v){for(var A=u._reactName,P=[];p!==null&&p!==g;){var Y=p,re=Y.alternate,De=Y.stateNode;if(Y=Y.tag,re!==null&&re===g)break;Y!==5&&Y!==26&&Y!==27||De===null||(re=De,v?(De=Ha(p,A),De!=null&&P.unshift(Wc(p,De,re))):v||(De=Ha(p,A),De!=null&&P.push(Wc(p,De,re)))),p=p.return}P.length!==0&&l.push({event:u,listeners:P})}var Q_=/\r\n?/g,X_=/\u0000|\uFFFD/g;function y0(l){return(typeof l=="string"?l:""+l).replace(Q_,`
34
- `).replace(X_,"")}function v0(l,u){return u=y0(u),y0(l)===u}function Cn(l,u,p,g,v,A){switch(p){case"children":typeof g=="string"?u==="body"||u==="textarea"&&g===""||pa(l,g):(typeof g=="number"||typeof g=="bigint")&&u!=="body"&&pa(l,""+g);break;case"className":Ts(l,"class",g);break;case"tabIndex":Ts(l,"tabindex",g);break;case"dir":case"role":case"viewBox":case"width":case"height":Ts(l,p,g);break;case"style":$i(l,g,A);break;case"data":if(u!=="object"){Ts(l,"data",g);break}case"src":case"href":if(g===""&&(u!=="a"||p!=="href")){l.removeAttribute(p);break}if(g==null||typeof g=="function"||typeof g=="symbol"||typeof g=="boolean"){l.removeAttribute(p);break}g=Fo(""+g),l.setAttribute(p,g);break;case"action":case"formAction":if(typeof g=="function"){l.setAttribute(p,"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 A=="function"&&(p==="formAction"?(u!=="input"&&Cn(l,u,"name",v.name,v,null),Cn(l,u,"formEncType",v.formEncType,v,null),Cn(l,u,"formMethod",v.formMethod,v,null),Cn(l,u,"formTarget",v.formTarget,v,null)):(Cn(l,u,"encType",v.encType,v,null),Cn(l,u,"method",v.method,v,null),Cn(l,u,"target",v.target,v,null)));if(g==null||typeof g=="symbol"||typeof g=="boolean"){l.removeAttribute(p);break}g=Fo(""+g),l.setAttribute(p,g);break;case"onClick":g!=null&&(l.onclick=It);break;case"onScroll":g!=null&&Qt("scroll",l);break;case"onScrollEnd":g!=null&&Qt("scrollend",l);break;case"dangerouslySetInnerHTML":if(g!=null){if(typeof g!="object"||!("__html"in g))throw Error(s(61));if(p=g.__html,p!=null){if(v.children!=null)throw Error(s(60));l.innerHTML=p}}break;case"multiple":l.multiple=g&&typeof g!="function"&&typeof g!="symbol";break;case"muted":l.muted=g&&typeof g!="function"&&typeof g!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(g==null||typeof g=="function"||typeof g=="boolean"||typeof g=="symbol"){l.removeAttribute("xlink:href");break}p=Fo(""+g),l.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",p);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":g!=null&&typeof g!="function"&&typeof g!="symbol"?l.setAttribute(p,""+g):l.removeAttribute(p);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":g&&typeof g!="function"&&typeof g!="symbol"?l.setAttribute(p,""):l.removeAttribute(p);break;case"capture":case"download":g===!0?l.setAttribute(p,""):g!==!1&&g!=null&&typeof g!="function"&&typeof g!="symbol"?l.setAttribute(p,g):l.removeAttribute(p);break;case"cols":case"rows":case"size":case"span":g!=null&&typeof g!="function"&&typeof g!="symbol"&&!isNaN(g)&&1<=g?l.setAttribute(p,g):l.removeAttribute(p);break;case"rowSpan":case"start":g==null||typeof g=="function"||typeof g=="symbol"||isNaN(g)?l.removeAttribute(p):l.setAttribute(p,g);break;case"popover":Qt("beforetoggle",l),Qt("toggle",l),Ma(l,"popover",g);break;case"xlinkActuate":hs(l,"http://www.w3.org/1999/xlink","xlink:actuate",g);break;case"xlinkArcrole":hs(l,"http://www.w3.org/1999/xlink","xlink:arcrole",g);break;case"xlinkRole":hs(l,"http://www.w3.org/1999/xlink","xlink:role",g);break;case"xlinkShow":hs(l,"http://www.w3.org/1999/xlink","xlink:show",g);break;case"xlinkTitle":hs(l,"http://www.w3.org/1999/xlink","xlink:title",g);break;case"xlinkType":hs(l,"http://www.w3.org/1999/xlink","xlink:type",g);break;case"xmlBase":hs(l,"http://www.w3.org/XML/1998/namespace","xml:base",g);break;case"xmlLang":hs(l,"http://www.w3.org/XML/1998/namespace","xml:lang",g);break;case"xmlSpace":hs(l,"http://www.w3.org/XML/1998/namespace","xml:space",g);break;case"is":Ma(l,"is",g);break;case"innerText":case"textContent":break;default:(!(2<p.length)||p[0]!=="o"&&p[0]!=="O"||p[1]!=="n"&&p[1]!=="N")&&(p=Ui.get(p)||p,Ma(l,p,g))}}function eg(l,u,p,g,v,A){switch(p){case"style":$i(l,g,A);break;case"dangerouslySetInnerHTML":if(g!=null){if(typeof g!="object"||!("__html"in g))throw Error(s(61));if(p=g.__html,p!=null){if(v.children!=null)throw Error(s(60));l.innerHTML=p}}break;case"children":typeof g=="string"?pa(l,g):(typeof g=="number"||typeof g=="bigint")&&pa(l,""+g);break;case"onScroll":g!=null&&Qt("scroll",l);break;case"onScrollEnd":g!=null&&Qt("scrollend",l);break;case"onClick":g!=null&&(l.onclick=It);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Bo.hasOwnProperty(p))e:{if(p[0]==="o"&&p[1]==="n"&&(v=p.endsWith("Capture"),u=p.slice(2,v?p.length-7:void 0),A=l[$t]||null,A=A!=null?A[p]:null,typeof A=="function"&&l.removeEventListener(u,A,v),typeof g=="function")){typeof A!="function"&&A!==null&&(p in l?l[p]=null:l.hasAttribute(p)&&l.removeAttribute(p)),l.addEventListener(u,g,v);break e}p in l?l[p]=g:g===!0?l.setAttribute(p,""):Ma(l,p,g)}}}function ys(l,u,p){switch(u){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Qt("error",l),Qt("load",l);var g=!1,v=!1,A;for(A in p)if(p.hasOwnProperty(A)){var P=p[A];if(P!=null)switch(A){case"src":g=!0;break;case"srcSet":v=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,u));default:Cn(l,u,A,P,p,null)}}v&&Cn(l,u,"srcSet",p.srcSet,p,null),g&&Cn(l,u,"src",p.src,p,null);return;case"input":Qt("invalid",l);var Y=A=P=v=null,re=null,De=null;for(g in p)if(p.hasOwnProperty(g)){var qe=p[g];if(qe!=null)switch(g){case"name":v=qe;break;case"type":P=qe;break;case"checked":re=qe;break;case"defaultChecked":De=qe;break;case"value":A=qe;break;case"defaultValue":Y=qe;break;case"children":case"dangerouslySetInnerHTML":if(qe!=null)throw Error(s(137,u));break;default:Cn(l,u,g,qe,p,null)}}kn(l,A,Y,re,De,P,v,!1);return;case"select":Qt("invalid",l),g=P=A=null;for(v in p)if(p.hasOwnProperty(v)&&(Y=p[v],Y!=null))switch(v){case"value":A=Y;break;case"defaultValue":P=Y;break;case"multiple":g=Y;default:Cn(l,u,v,Y,p,null)}u=A,p=P,l.multiple=!!g,u!=null?Dn(l,!!g,u,!1):p!=null&&Dn(l,!!g,p,!0);return;case"textarea":Qt("invalid",l),A=v=g=null;for(P in p)if(p.hasOwnProperty(P)&&(Y=p[P],Y!=null))switch(P){case"value":g=Y;break;case"defaultValue":v=Y;break;case"children":A=Y;break;case"dangerouslySetInnerHTML":if(Y!=null)throw Error(s(91));break;default:Cn(l,u,P,Y,p,null)}Qr(l,g,v,A);return;case"option":for(re in p)if(p.hasOwnProperty(re)&&(g=p[re],g!=null))switch(re){case"selected":l.selected=g&&typeof g!="function"&&typeof g!="symbol";break;default:Cn(l,u,re,g,p,null)}return;case"dialog":Qt("beforetoggle",l),Qt("toggle",l),Qt("cancel",l),Qt("close",l);break;case"iframe":case"object":Qt("load",l);break;case"video":case"audio":for(g=0;g<Hc.length;g++)Qt(Hc[g],l);break;case"image":Qt("error",l),Qt("load",l);break;case"details":Qt("toggle",l);break;case"embed":case"source":case"link":Qt("error",l),Qt("load",l);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(De in p)if(p.hasOwnProperty(De)&&(g=p[De],g!=null))switch(De){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,u));default:Cn(l,u,De,g,p,null)}return;default:if(gr(u)){for(qe in p)p.hasOwnProperty(qe)&&(g=p[qe],g!==void 0&&eg(l,u,qe,g,p,void 0));return}}for(Y in p)p.hasOwnProperty(Y)&&(g=p[Y],g!=null&&Cn(l,u,Y,g,p,null))}function J_(l,u,p,g){switch(u){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var v=null,A=null,P=null,Y=null,re=null,De=null,qe=null;for(Ue in p){var Qe=p[Ue];if(p.hasOwnProperty(Ue)&&Qe!=null)switch(Ue){case"checked":break;case"value":break;case"defaultValue":re=Qe;default:g.hasOwnProperty(Ue)||Cn(l,u,Ue,null,g,Qe)}}for(var Ie in g){var Ue=g[Ie];if(Qe=p[Ie],g.hasOwnProperty(Ie)&&(Ue!=null||Qe!=null))switch(Ie){case"type":A=Ue;break;case"name":v=Ue;break;case"checked":De=Ue;break;case"defaultChecked":qe=Ue;break;case"value":P=Ue;break;case"defaultValue":Y=Ue;break;case"children":case"dangerouslySetInnerHTML":if(Ue!=null)throw Error(s(137,u));break;default:Ue!==Qe&&Cn(l,u,Ie,Ue,g,Qe)}}At(l,P,Y,re,De,qe,A,v);return;case"select":Ue=P=Y=Ie=null;for(A in p)if(re=p[A],p.hasOwnProperty(A)&&re!=null)switch(A){case"value":break;case"multiple":Ue=re;default:g.hasOwnProperty(A)||Cn(l,u,A,null,g,re)}for(v in g)if(A=g[v],re=p[v],g.hasOwnProperty(v)&&(A!=null||re!=null))switch(v){case"value":Ie=A;break;case"defaultValue":Y=A;break;case"multiple":P=A;default:A!==re&&Cn(l,u,v,A,g,re)}u=Y,p=P,g=Ue,Ie!=null?Dn(l,!!p,Ie,!1):!!g!=!!p&&(u!=null?Dn(l,!!p,u,!0):Dn(l,!!p,p?[]:"",!1));return;case"textarea":Ue=Ie=null;for(Y in p)if(v=p[Y],p.hasOwnProperty(Y)&&v!=null&&!g.hasOwnProperty(Y))switch(Y){case"value":break;case"children":break;default:Cn(l,u,Y,null,g,v)}for(P in g)if(v=g[P],A=p[P],g.hasOwnProperty(P)&&(v!=null||A!=null))switch(P){case"value":Ie=v;break;case"defaultValue":Ue=v;break;case"children":break;case"dangerouslySetInnerHTML":if(v!=null)throw Error(s(91));break;default:v!==A&&Cn(l,u,P,v,g,A)}Fs(l,Ie,Ue);return;case"option":for(var yt in p)if(Ie=p[yt],p.hasOwnProperty(yt)&&Ie!=null&&!g.hasOwnProperty(yt))switch(yt){case"selected":l.selected=!1;break;default:Cn(l,u,yt,null,g,Ie)}for(re in g)if(Ie=g[re],Ue=p[re],g.hasOwnProperty(re)&&Ie!==Ue&&(Ie!=null||Ue!=null))switch(re){case"selected":l.selected=Ie&&typeof Ie!="function"&&typeof Ie!="symbol";break;default:Cn(l,u,re,Ie,g,Ue)}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 Dt in p)Ie=p[Dt],p.hasOwnProperty(Dt)&&Ie!=null&&!g.hasOwnProperty(Dt)&&Cn(l,u,Dt,null,g,Ie);for(De in g)if(Ie=g[De],Ue=p[De],g.hasOwnProperty(De)&&Ie!==Ue&&(Ie!=null||Ue!=null))switch(De){case"children":case"dangerouslySetInnerHTML":if(Ie!=null)throw Error(s(137,u));break;default:Cn(l,u,De,Ie,g,Ue)}return;default:if(gr(u)){for(var An in p)Ie=p[An],p.hasOwnProperty(An)&&Ie!==void 0&&!g.hasOwnProperty(An)&&eg(l,u,An,void 0,g,Ie);for(qe in g)Ie=g[qe],Ue=p[qe],!g.hasOwnProperty(qe)||Ie===Ue||Ie===void 0&&Ue===void 0||eg(l,u,qe,Ie,g,Ue);return}}for(var we in p)Ie=p[we],p.hasOwnProperty(we)&&Ie!=null&&!g.hasOwnProperty(we)&&Cn(l,u,we,null,g,Ie);for(Qe in g)Ie=g[Qe],Ue=p[Qe],!g.hasOwnProperty(Qe)||Ie===Ue||Ie==null&&Ue==null||Cn(l,u,Qe,Ie,g,Ue)}function w0(l){switch(l){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Z_(){if(typeof performance.getEntriesByType=="function"){for(var l=0,u=0,p=performance.getEntriesByType("resource"),g=0;g<p.length;g++){var v=p[g],A=v.transferSize,P=v.initiatorType,Y=v.duration;if(A&&Y&&w0(P)){for(P=0,Y=v.responseEnd,g+=1;g<p.length;g++){var re=p[g],De=re.startTime;if(De>Y)break;var qe=re.transferSize,Qe=re.initiatorType;qe&&w0(Qe)&&(re=re.responseEnd,P+=qe*(re<Y?1:(Y-De)/(re-De)))}if(--g,u+=8*(A+P)/(v.duration/1e3),l++,10<l)break}}if(0<l)return u/l/1e6}return navigator.connection&&(l=navigator.connection.downlink,typeof l=="number")?l:5}var tg=null,ng=null;function uf(l){return l.nodeType===9?l:l.ownerDocument}function k0(l){switch(l){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function S0(l,u){if(l===0)switch(u){case"svg":return 1;case"math":return 2;default:return 0}return l===1&&u==="foreignObject"?0:l}function sg(l,u){return l==="textarea"||l==="noscript"||typeof u.children=="string"||typeof u.children=="number"||typeof u.children=="bigint"||typeof u.dangerouslySetInnerHTML=="object"&&u.dangerouslySetInnerHTML!==null&&u.dangerouslySetInnerHTML.__html!=null}var ag=null;function eE(){var l=window.event;return l&&l.type==="popstate"?l===ag?!1:(ag=l,!0):(ag=null,!1)}var C0=typeof setTimeout=="function"?setTimeout:void 0,tE=typeof clearTimeout=="function"?clearTimeout:void 0,A0=typeof Promise=="function"?Promise:void 0,nE=typeof queueMicrotask=="function"?queueMicrotask:typeof A0<"u"?function(l){return A0.resolve(null).then(l).catch(sE)}:C0;function sE(l){setTimeout(function(){throw l})}function xi(l){return l==="head"}function j0(l,u){var p=u,g=0;do{var v=p.nextSibling;if(l.removeChild(p),v&&v.nodeType===8)if(p=v.data,p==="/$"||p==="/&"){if(g===0){l.removeChild(v),jl(u);return}g--}else if(p==="$"||p==="$?"||p==="$~"||p==="$!"||p==="&")g++;else if(p==="html")qc(l.ownerDocument.documentElement);else if(p==="head"){p=l.ownerDocument.head,qc(p);for(var A=p.firstChild;A;){var P=A.nextSibling,Y=A.nodeName;A[ks]||Y==="SCRIPT"||Y==="STYLE"||Y==="LINK"&&A.rel.toLowerCase()==="stylesheet"||p.removeChild(A),A=P}}else p==="body"&&qc(l.ownerDocument.body);p=v}while(p);jl(u)}function N0(l,u){var p=l;l=0;do{var g=p.nextSibling;if(p.nodeType===1?u?(p._stashedDisplay=p.style.display,p.style.display="none"):(p.style.display=p._stashedDisplay||"",p.getAttribute("style")===""&&p.removeAttribute("style")):p.nodeType===3&&(u?(p._stashedText=p.nodeValue,p.nodeValue=""):p.nodeValue=p._stashedText||""),g&&g.nodeType===8)if(p=g.data,p==="/$"){if(l===0)break;l--}else p!=="$"&&p!=="$?"&&p!=="$~"&&p!=="$!"||l++;p=g}while(p)}function rg(l){var u=l.firstChild;for(u&&u.nodeType===10&&(u=u.nextSibling);u;){var p=u;switch(u=u.nextSibling,p.nodeName){case"HTML":case"HEAD":case"BODY":rg(p),Qn(p);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(p.rel.toLowerCase()==="stylesheet")continue}l.removeChild(p)}}function aE(l,u,p,g){for(;l.nodeType===1;){var v=p;if(l.nodeName.toLowerCase()!==u.toLowerCase()){if(!g&&(l.nodeName!=="INPUT"||l.type!=="hidden"))break}else if(g){if(!l[ks])switch(u){case"meta":if(!l.hasAttribute("itemprop"))break;return l;case"link":if(A=l.getAttribute("rel"),A==="stylesheet"&&l.hasAttribute("data-precedence"))break;if(A!==v.rel||l.getAttribute("href")!==(v.href==null||v.href===""?null:v.href)||l.getAttribute("crossorigin")!==(v.crossOrigin==null?null:v.crossOrigin)||l.getAttribute("title")!==(v.title==null?null:v.title))break;return l;case"style":if(l.hasAttribute("data-precedence"))break;return l;case"script":if(A=l.getAttribute("src"),(A!==(v.src==null?null:v.src)||l.getAttribute("type")!==(v.type==null?null:v.type)||l.getAttribute("crossorigin")!==(v.crossOrigin==null?null:v.crossOrigin))&&A&&l.hasAttribute("async")&&!l.hasAttribute("itemprop"))break;return l;default:return l}}else if(u==="input"&&l.type==="hidden"){var A=v.name==null?null:""+v.name;if(v.type==="hidden"&&l.getAttribute("name")===A)return l}else return l;if(l=ka(l.nextSibling),l===null)break}return null}function rE(l,u,p){if(u==="")return null;for(;l.nodeType!==3;)if((l.nodeType!==1||l.nodeName!=="INPUT"||l.type!=="hidden")&&!p||(l=ka(l.nextSibling),l===null))return null;return l}function T0(l,u){for(;l.nodeType!==8;)if((l.nodeType!==1||l.nodeName!=="INPUT"||l.type!=="hidden")&&!u||(l=ka(l.nextSibling),l===null))return null;return l}function ig(l){return l.data==="$?"||l.data==="$~"}function og(l){return l.data==="$!"||l.data==="$?"&&l.ownerDocument.readyState!=="loading"}function iE(l,u){var p=l.ownerDocument;if(l.data==="$~")l._reactRetry=u;else if(l.data!=="$?"||p.readyState!=="loading")u();else{var g=function(){u(),p.removeEventListener("DOMContentLoaded",g)};p.addEventListener("DOMContentLoaded",g),l._reactRetry=g}}function ka(l){for(;l!=null;l=l.nextSibling){var u=l.nodeType;if(u===1||u===3)break;if(u===8){if(u=l.data,u==="$"||u==="$!"||u==="$?"||u==="$~"||u==="&"||u==="F!"||u==="F")break;if(u==="/$"||u==="/&")return null}}return l}var lg=null;function _0(l){l=l.nextSibling;for(var u=0;l;){if(l.nodeType===8){var p=l.data;if(p==="/$"||p==="/&"){if(u===0)return ka(l.nextSibling);u--}else p!=="$"&&p!=="$!"&&p!=="$?"&&p!=="$~"&&p!=="&"||u++}l=l.nextSibling}return null}function E0(l){l=l.previousSibling;for(var u=0;l;){if(l.nodeType===8){var p=l.data;if(p==="$"||p==="$!"||p==="$?"||p==="$~"||p==="&"){if(u===0)return l;u--}else p!=="/$"&&p!=="/&"||u++}l=l.previousSibling}return null}function M0(l,u,p){switch(u=uf(p),l){case"html":if(l=u.documentElement,!l)throw Error(s(452));return l;case"head":if(l=u.head,!l)throw Error(s(453));return l;case"body":if(l=u.body,!l)throw Error(s(454));return l;default:throw Error(s(451))}}function qc(l){for(var u=l.attributes;u.length;)l.removeAttributeNode(u[0]);Qn(l)}var Sa=new Map,D0=new Set;function df(l){return typeof l.getRootNode=="function"?l.getRootNode():l.nodeType===9?l:l.ownerDocument}var Rr=H.d;H.d={f:oE,r:lE,D:cE,C:uE,L:dE,m:fE,X:hE,S:pE,M:mE};function oE(){var l=Rr.f(),u=tf();return l||u}function lE(l){var u=Fn(l);u!==null&&u.tag===5&&u.type==="form"?Kv(u):Rr.r(l)}var Sl=typeof document>"u"?null:document;function R0(l,u,p){var g=Sl;if(g&&typeof u=="string"&&u){var v=Mt(u);v='link[rel="'+l+'"][href="'+v+'"]',typeof p=="string"&&(v+='[crossorigin="'+p+'"]'),D0.has(v)||(D0.add(v),l={rel:l,crossOrigin:p,href:u},g.querySelector(v)===null&&(u=g.createElement("link"),ys(u,"link",l),wn(u),g.head.appendChild(u)))}}function cE(l){Rr.D(l),R0("dns-prefetch",l,null)}function uE(l,u){Rr.C(l,u),R0("preconnect",l,u)}function dE(l,u,p){Rr.L(l,u,p);var g=Sl;if(g&&l&&u){var v='link[rel="preload"][as="'+Mt(u)+'"]';u==="image"&&p&&p.imageSrcSet?(v+='[imagesrcset="'+Mt(p.imageSrcSet)+'"]',typeof p.imageSizes=="string"&&(v+='[imagesizes="'+Mt(p.imageSizes)+'"]')):v+='[href="'+Mt(l)+'"]';var A=v;switch(u){case"style":A=Cl(l);break;case"script":A=Al(l)}Sa.has(A)||(l=m({rel:"preload",href:u==="image"&&p&&p.imageSrcSet?void 0:l,as:u},p),Sa.set(A,l),g.querySelector(v)!==null||u==="style"&&g.querySelector(Vc(A))||u==="script"&&g.querySelector(Yc(A))||(u=g.createElement("link"),ys(u,"link",l),wn(u),g.head.appendChild(u)))}}function fE(l,u){Rr.m(l,u);var p=Sl;if(p&&l){var g=u&&typeof u.as=="string"?u.as:"script",v='link[rel="modulepreload"][as="'+Mt(g)+'"][href="'+Mt(l)+'"]',A=v;switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":A=Al(l)}if(!Sa.has(A)&&(l=m({rel:"modulepreload",href:l},u),Sa.set(A,l),p.querySelector(v)===null)){switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(p.querySelector(Yc(A)))return}g=p.createElement("link"),ys(g,"link",l),wn(g),p.head.appendChild(g)}}}function pE(l,u,p){Rr.S(l,u,p);var g=Sl;if(g&&l){var v=Is(g).hoistableStyles,A=Cl(l);u=u||"default";var P=v.get(A);if(!P){var Y={loading:0,preload:null};if(P=g.querySelector(Vc(A)))Y.loading=5;else{l=m({rel:"stylesheet",href:l,"data-precedence":u},p),(p=Sa.get(A))&&cg(l,p);var re=P=g.createElement("link");wn(re),ys(re,"link",l),re._p=new Promise(function(De,qe){re.onload=De,re.onerror=qe}),re.addEventListener("load",function(){Y.loading|=1}),re.addEventListener("error",function(){Y.loading|=2}),Y.loading|=4,ff(P,u,g)}P={type:"stylesheet",instance:P,count:1,state:Y},v.set(A,P)}}}function hE(l,u){Rr.X(l,u);var p=Sl;if(p&&l){var g=Is(p).hoistableScripts,v=Al(l),A=g.get(v);A||(A=p.querySelector(Yc(v)),A||(l=m({src:l,async:!0},u),(u=Sa.get(v))&&ug(l,u),A=p.createElement("script"),wn(A),ys(A,"link",l),p.head.appendChild(A)),A={type:"script",instance:A,count:1,state:null},g.set(v,A))}}function mE(l,u){Rr.M(l,u);var p=Sl;if(p&&l){var g=Is(p).hoistableScripts,v=Al(l),A=g.get(v);A||(A=p.querySelector(Yc(v)),A||(l=m({src:l,async:!0,type:"module"},u),(u=Sa.get(v))&&ug(l,u),A=p.createElement("script"),wn(A),ys(A,"link",l),p.head.appendChild(A)),A={type:"script",instance:A,count:1,state:null},g.set(v,A))}}function O0(l,u,p,g){var v=(v=Z.current)?df(v):null;if(!v)throw Error(s(446));switch(l){case"meta":case"title":return null;case"style":return typeof p.precedence=="string"&&typeof p.href=="string"?(u=Cl(p.href),p=Is(v).hoistableStyles,g=p.get(u),g||(g={type:"style",instance:null,count:0,state:null},p.set(u,g)),g):{type:"void",instance:null,count:0,state:null};case"link":if(p.rel==="stylesheet"&&typeof p.href=="string"&&typeof p.precedence=="string"){l=Cl(p.href);var A=Is(v).hoistableStyles,P=A.get(l);if(P||(v=v.ownerDocument||v,P={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},A.set(l,P),(A=v.querySelector(Vc(l)))&&!A._p&&(P.instance=A,P.state.loading=5),Sa.has(l)||(p={rel:"preload",as:"style",href:p.href,crossOrigin:p.crossOrigin,integrity:p.integrity,media:p.media,hrefLang:p.hrefLang,referrerPolicy:p.referrerPolicy},Sa.set(l,p),A||gE(v,l,p,P.state))),u&&g===null)throw Error(s(528,""));return P}if(u&&g!==null)throw Error(s(529,""));return null;case"script":return u=p.async,p=p.src,typeof p=="string"&&u&&typeof u!="function"&&typeof u!="symbol"?(u=Al(p),p=Is(v).hoistableScripts,g=p.get(u),g||(g={type:"script",instance:null,count:0,state:null},p.set(u,g)),g):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,l))}}function Cl(l){return'href="'+Mt(l)+'"'}function Vc(l){return'link[rel="stylesheet"]['+l+"]"}function L0(l){return m({},l,{"data-precedence":l.precedence,precedence:null})}function gE(l,u,p,g){l.querySelector('link[rel="preload"][as="style"]['+u+"]")?g.loading=1:(u=l.createElement("link"),g.preload=u,u.addEventListener("load",function(){return g.loading|=1}),u.addEventListener("error",function(){return g.loading|=2}),ys(u,"link",p),wn(u),l.head.appendChild(u))}function Al(l){return'[src="'+Mt(l)+'"]'}function Yc(l){return"script[async]"+l}function I0(l,u,p){if(u.count++,u.instance===null)switch(u.type){case"style":var g=l.querySelector('style[data-href~="'+Mt(p.href)+'"]');if(g)return u.instance=g,wn(g),g;var v=m({},p,{"data-href":p.href,"data-precedence":p.precedence,href:null,precedence:null});return g=(l.ownerDocument||l).createElement("style"),wn(g),ys(g,"style",v),ff(g,p.precedence,l),u.instance=g;case"stylesheet":v=Cl(p.href);var A=l.querySelector(Vc(v));if(A)return u.state.loading|=4,u.instance=A,wn(A),A;g=L0(p),(v=Sa.get(v))&&cg(g,v),A=(l.ownerDocument||l).createElement("link"),wn(A);var P=A;return P._p=new Promise(function(Y,re){P.onload=Y,P.onerror=re}),ys(A,"link",g),u.state.loading|=4,ff(A,p.precedence,l),u.instance=A;case"script":return A=Al(p.src),(v=l.querySelector(Yc(A)))?(u.instance=v,wn(v),v):(g=p,(v=Sa.get(A))&&(g=m({},p),ug(g,v)),l=l.ownerDocument||l,v=l.createElement("script"),wn(v),ys(v,"link",g),l.head.appendChild(v),u.instance=v);case"void":return null;default:throw Error(s(443,u.type))}else u.type==="stylesheet"&&(u.state.loading&4)===0&&(g=u.instance,u.state.loading|=4,ff(g,p.precedence,l));return u.instance}function ff(l,u,p){for(var g=p.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),v=g.length?g[g.length-1]:null,A=v,P=0;P<g.length;P++){var Y=g[P];if(Y.dataset.precedence===u)A=Y;else if(A!==v)break}A?A.parentNode.insertBefore(l,A.nextSibling):(u=p.nodeType===9?p.head:p,u.insertBefore(l,u.firstChild))}function cg(l,u){l.crossOrigin==null&&(l.crossOrigin=u.crossOrigin),l.referrerPolicy==null&&(l.referrerPolicy=u.referrerPolicy),l.title==null&&(l.title=u.title)}function ug(l,u){l.crossOrigin==null&&(l.crossOrigin=u.crossOrigin),l.referrerPolicy==null&&(l.referrerPolicy=u.referrerPolicy),l.integrity==null&&(l.integrity=u.integrity)}var pf=null;function P0(l,u,p){if(pf===null){var g=new Map,v=pf=new Map;v.set(p,g)}else v=pf,g=v.get(p),g||(g=new Map,v.set(p,g));if(g.has(l))return g;for(g.set(l,null),p=p.getElementsByTagName(l),v=0;v<p.length;v++){var A=p[v];if(!(A[ks]||A[xt]||l==="link"&&A.getAttribute("rel")==="stylesheet")&&A.namespaceURI!=="http://www.w3.org/2000/svg"){var P=A.getAttribute(u)||"";P=l+P;var Y=g.get(P);Y?Y.push(A):g.set(P,[A])}}return g}function B0(l,u,p){l=l.ownerDocument||l,l.head.insertBefore(p,u==="title"?l.querySelector("head > title"):null)}function bE(l,u,p){if(p===1||u.itemProp!=null)return!1;switch(l){case"meta":case"title":return!0;case"style":if(typeof u.precedence!="string"||typeof u.href!="string"||u.href==="")break;return!0;case"link":if(typeof u.rel!="string"||typeof u.href!="string"||u.href===""||u.onLoad||u.onError)break;switch(u.rel){case"stylesheet":return l=u.disabled,typeof u.precedence=="string"&&l==null;default:return!0}case"script":if(u.async&&typeof u.async!="function"&&typeof u.async!="symbol"&&!u.onLoad&&!u.onError&&u.src&&typeof u.src=="string")return!0}return!1}function F0(l){return!(l.type==="stylesheet"&&(l.state.loading&3)===0)}function xE(l,u,p,g){if(p.type==="stylesheet"&&(typeof g.media!="string"||matchMedia(g.media).matches!==!1)&&(p.state.loading&4)===0){if(p.instance===null){var v=Cl(g.href),A=u.querySelector(Vc(v));if(A){u=A._p,u!==null&&typeof u=="object"&&typeof u.then=="function"&&(l.count++,l=hf.bind(l),u.then(l,l)),p.state.loading|=4,p.instance=A,wn(A);return}A=u.ownerDocument||u,g=L0(g),(v=Sa.get(v))&&cg(g,v),A=A.createElement("link"),wn(A);var P=A;P._p=new Promise(function(Y,re){P.onload=Y,P.onerror=re}),ys(A,"link",g),p.instance=A}l.stylesheets===null&&(l.stylesheets=new Map),l.stylesheets.set(p,u),(u=p.state.preload)&&(p.state.loading&3)===0&&(l.count++,p=hf.bind(l),u.addEventListener("load",p),u.addEventListener("error",p))}}var dg=0;function yE(l,u){return l.stylesheets&&l.count===0&&gf(l,l.stylesheets),0<l.count||0<l.imgCount?function(p){var g=setTimeout(function(){if(l.stylesheets&&gf(l,l.stylesheets),l.unsuspend){var A=l.unsuspend;l.unsuspend=null,A()}},6e4+u);0<l.imgBytes&&dg===0&&(dg=62500*Z_());var v=setTimeout(function(){if(l.waitingForImages=!1,l.count===0&&(l.stylesheets&&gf(l,l.stylesheets),l.unsuspend)){var A=l.unsuspend;l.unsuspend=null,A()}},(l.imgBytes>dg?50:800)+u);return l.unsuspend=p,function(){l.unsuspend=null,clearTimeout(g),clearTimeout(v)}}:null}function hf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)gf(this,this.stylesheets);else if(this.unsuspend){var l=this.unsuspend;this.unsuspend=null,l()}}}var mf=null;function gf(l,u){l.stylesheets=null,l.unsuspend!==null&&(l.count++,mf=new Map,u.forEach(vE,l),mf=null,hf.call(l))}function vE(l,u){if(!(u.state.loading&4)){var p=mf.get(l);if(p)var g=p.get(null);else{p=new Map,mf.set(l,p);for(var v=l.querySelectorAll("link[data-precedence],style[data-precedence]"),A=0;A<v.length;A++){var P=v[A];(P.nodeName==="LINK"||P.getAttribute("media")!=="not all")&&(p.set(P.dataset.precedence,P),g=P)}g&&p.set(null,g)}v=u.instance,P=v.getAttribute("data-precedence"),A=p.get(P)||g,A===g&&p.set(null,v),p.set(P,v),this.count++,g=hf.bind(this),v.addEventListener("load",g),v.addEventListener("error",g),A?A.parentNode.insertBefore(v,A.nextSibling):(l=l.nodeType===9?l.head:l,l.insertBefore(v,l.firstChild)),u.state.loading|=4}}var Gc={$$typeof:S,Provider:null,Consumer:null,_currentValue:V,_currentValue2:V,_threadCount:0};function wE(l,u,p,g,v,A,P,Y,re){this.tag=1,this.containerInfo=l,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=Ae(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ae(0),this.hiddenUpdates=Ae(null),this.identifierPrefix=g,this.onUncaughtError=v,this.onCaughtError=A,this.onRecoverableError=P,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=re,this.incompleteTransitions=new Map}function z0(l,u,p,g,v,A,P,Y,re,De,qe,Qe){return l=new wE(l,u,p,P,re,De,qe,Qe,Y),u=1,A===!0&&(u|=24),A=Zs(3,null,null,u),l.current=A,A.stateNode=l,u=Wh(),u.refCount++,l.pooledCache=u,u.refCount++,A.memoizedState={element:g,isDehydrated:p,cache:u},Gh(A),l}function $0(l){return l?(l=nl,l):nl}function U0(l,u,p,g,v,A){v=$0(v),g.context===null?g.context=v:g.pendingContext=v,g=oi(u),g.payload={element:p},A=A===void 0?null:A,A!==null&&(g.callback=A),p=li(l,g,u),p!==null&&(qs(p,l,u),jc(p,l,u))}function H0(l,u){if(l=l.memoizedState,l!==null&&l.dehydrated!==null){var p=l.retryLane;l.retryLane=p!==0&&p<u?p:u}}function fg(l,u){H0(l,u),(l=l.alternate)&&H0(l,u)}function W0(l){if(l.tag===13||l.tag===31){var u=Ji(l,67108864);u!==null&&qs(u,l,67108864),fg(l,67108864)}}function q0(l){if(l.tag===13||l.tag===31){var u=aa();u=Lt(u);var p=Ji(l,u);p!==null&&qs(p,l,u),fg(l,u)}}var bf=!0;function kE(l,u,p,g){var v=F.T;F.T=null;var A=H.p;try{H.p=2,pg(l,u,p,g)}finally{H.p=A,F.T=v}}function SE(l,u,p,g){var v=F.T;F.T=null;var A=H.p;try{H.p=8,pg(l,u,p,g)}finally{H.p=A,F.T=v}}function pg(l,u,p,g){if(bf){var v=hg(g);if(v===null)Zm(l,u,g,xf,p),Y0(l,g);else if(AE(v,l,u,p,g))g.stopPropagation();else if(Y0(l,g),u&4&&-1<CE.indexOf(l)){for(;v!==null;){var A=Fn(v);if(A!==null)switch(A.tag){case 3:if(A=A.stateNode,A.current.memoizedState.isDehydrated){var P=it(A.pendingLanes);if(P!==0){var Y=A;for(Y.pendingLanes|=2,Y.entangledLanes|=2;P;){var re=1<<31-ge(P);Y.entanglements[1]|=re,P&=~re}Qa(A),(hn&6)===0&&(Zd=ct()+500,Uc(0))}}break;case 31:case 13:Y=Ji(A,2),Y!==null&&qs(Y,A,2),tf(),fg(A,2)}if(A=hg(g),A===null&&Zm(l,u,g,xf,p),A===v)break;v=A}v!==null&&g.stopPropagation()}else Zm(l,u,g,null,p)}}function hg(l){return l=uc(l),mg(l)}var xf=null;function mg(l){if(xf=null,l=Ss(l),l!==null){var u=r(l);if(u===null)l=null;else{var p=u.tag;if(p===13){if(l=i(u),l!==null)return l;l=null}else if(p===31){if(l=c(u),l!==null)return l;l=null}else if(p===3){if(u.stateNode.current.memoizedState.isDehydrated)return u.tag===3?u.stateNode.containerInfo:null;l=null}else u!==l&&(l=null)}}return xf=l,null}function V0(l){switch(l){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(fe()){case X:return 2;case ae:return 8;case ke:case J:return 32;case he:return 268435456;default:return 32}default:return 32}}var gg=!1,yi=null,vi=null,wi=null,Kc=new Map,Qc=new Map,ki=[],CE="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 Y0(l,u){switch(l){case"focusin":case"focusout":yi=null;break;case"dragenter":case"dragleave":vi=null;break;case"mouseover":case"mouseout":wi=null;break;case"pointerover":case"pointerout":Kc.delete(u.pointerId);break;case"gotpointercapture":case"lostpointercapture":Qc.delete(u.pointerId)}}function Xc(l,u,p,g,v,A){return l===null||l.nativeEvent!==A?(l={blockedOn:u,domEventName:p,eventSystemFlags:g,nativeEvent:A,targetContainers:[v]},u!==null&&(u=Fn(u),u!==null&&W0(u)),l):(l.eventSystemFlags|=g,u=l.targetContainers,v!==null&&u.indexOf(v)===-1&&u.push(v),l)}function AE(l,u,p,g,v){switch(u){case"focusin":return yi=Xc(yi,l,u,p,g,v),!0;case"dragenter":return vi=Xc(vi,l,u,p,g,v),!0;case"mouseover":return wi=Xc(wi,l,u,p,g,v),!0;case"pointerover":var A=v.pointerId;return Kc.set(A,Xc(Kc.get(A)||null,l,u,p,g,v)),!0;case"gotpointercapture":return A=v.pointerId,Qc.set(A,Xc(Qc.get(A)||null,l,u,p,g,v)),!0}return!1}function G0(l){var u=Ss(l.target);if(u!==null){var p=r(u);if(p!==null){if(u=p.tag,u===13){if(u=i(p),u!==null){l.blockedOn=u,bt(l.priority,function(){q0(p)});return}}else if(u===31){if(u=c(p),u!==null){l.blockedOn=u,bt(l.priority,function(){q0(p)});return}}else if(u===3&&p.stateNode.current.memoizedState.isDehydrated){l.blockedOn=p.tag===3?p.stateNode.containerInfo:null;return}}}l.blockedOn=null}function yf(l){if(l.blockedOn!==null)return!1;for(var u=l.targetContainers;0<u.length;){var p=hg(l.nativeEvent);if(p===null){p=l.nativeEvent;var g=new p.constructor(p.type,p);Hn=g,p.target.dispatchEvent(g),Hn=null}else return u=Fn(p),u!==null&&W0(u),l.blockedOn=p,!1;u.shift()}return!0}function K0(l,u,p){yf(l)&&p.delete(u)}function jE(){gg=!1,yi!==null&&yf(yi)&&(yi=null),vi!==null&&yf(vi)&&(vi=null),wi!==null&&yf(wi)&&(wi=null),Kc.forEach(K0),Qc.forEach(K0)}function vf(l,u){l.blockedOn===u&&(l.blockedOn=null,gg||(gg=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,jE)))}var wf=null;function Q0(l){wf!==l&&(wf=l,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){wf===l&&(wf=null);for(var u=0;u<l.length;u+=3){var p=l[u],g=l[u+1],v=l[u+2];if(typeof g!="function"){if(mg(g||p)===null)continue;break}var A=Fn(p);A!==null&&(l.splice(u,3),u-=3,hm(A,{pending:!0,data:v,method:p.method,action:g},g,v))}}))}function jl(l){function u(re){return vf(re,l)}yi!==null&&vf(yi,l),vi!==null&&vf(vi,l),wi!==null&&vf(wi,l),Kc.forEach(u),Qc.forEach(u);for(var p=0;p<ki.length;p++){var g=ki[p];g.blockedOn===l&&(g.blockedOn=null)}for(;0<ki.length&&(p=ki[0],p.blockedOn===null);)G0(p),p.blockedOn===null&&ki.shift();if(p=(l.ownerDocument||l).$$reactFormReplay,p!=null)for(g=0;g<p.length;g+=3){var v=p[g],A=p[g+1],P=v[$t]||null;if(typeof A=="function")P||Q0(p);else if(P){var Y=null;if(A&&A.hasAttribute("formAction")){if(v=A,P=A[$t]||null)Y=P.formAction;else if(mg(v)!==null)continue}else Y=P.action;typeof Y=="function"?p[g+1]=Y:(p.splice(g,3),g-=3),Q0(p)}}}function X0(){function l(A){A.canIntercept&&A.info==="react-transition"&&A.intercept({handler:function(){return new Promise(function(P){return v=P})},focusReset:"manual",scroll:"manual"})}function u(){v!==null&&(v(),v=null),g||setTimeout(p,20)}function p(){if(!g&&!navigation.transition){var A=navigation.currentEntry;A&&A.url!=null&&navigation.navigate(A.url,{state:A.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var g=!1,v=null;return navigation.addEventListener("navigate",l),navigation.addEventListener("navigatesuccess",u),navigation.addEventListener("navigateerror",u),setTimeout(p,100),function(){g=!0,navigation.removeEventListener("navigate",l),navigation.removeEventListener("navigatesuccess",u),navigation.removeEventListener("navigateerror",u),v!==null&&(v(),v=null)}}}function bg(l){this._internalRoot=l}kf.prototype.render=bg.prototype.render=function(l){var u=this._internalRoot;if(u===null)throw Error(s(409));var p=u.current,g=aa();U0(p,g,l,u,null,null)},kf.prototype.unmount=bg.prototype.unmount=function(){var l=this._internalRoot;if(l!==null){this._internalRoot=null;var u=l.containerInfo;U0(l.current,2,null,l,null,null),tf(),u[En]=null}};function kf(l){this._internalRoot=l}kf.prototype.unstable_scheduleHydration=function(l){if(l){var u=ln();l={blockedOn:null,target:l,priority:u};for(var p=0;p<ki.length&&u!==0&&u<ki[p].priority;p++);ki.splice(p,0,l),p===0&&G0(l)}};var J0=e.version;if(J0!=="19.2.4")throw Error(s(527,J0,"19.2.4"));H.findDOMNode=function(l){var u=l._reactInternals;if(u===void 0)throw typeof l.render=="function"?Error(s(188)):(l=Object.keys(l).join(","),Error(s(268,l)));return l=f(u),l=l!==null?h(l):null,l=l===null?null:l.stateNode,l};var NE={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:F,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Sf=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Sf.isDisabled&&Sf.supportsFiber)try{xe=Sf.inject(NE),Pe=Sf}catch{}}return Zc.createRoot=function(l,u){if(!a(l))throw Error(s(299));var p=!1,g="",v=rw,A=iw,P=ow;return u!=null&&(u.unstable_strictMode===!0&&(p=!0),u.identifierPrefix!==void 0&&(g=u.identifierPrefix),u.onUncaughtError!==void 0&&(v=u.onUncaughtError),u.onCaughtError!==void 0&&(A=u.onCaughtError),u.onRecoverableError!==void 0&&(P=u.onRecoverableError)),u=z0(l,1,!1,null,null,p,g,null,v,A,P,X0),l[En]=u.current,Jm(l),new bg(u)},Zc.hydrateRoot=function(l,u,p){if(!a(l))throw Error(s(299));var g=!1,v="",A=rw,P=iw,Y=ow,re=null;return p!=null&&(p.unstable_strictMode===!0&&(g=!0),p.identifierPrefix!==void 0&&(v=p.identifierPrefix),p.onUncaughtError!==void 0&&(A=p.onUncaughtError),p.onCaughtError!==void 0&&(P=p.onCaughtError),p.onRecoverableError!==void 0&&(Y=p.onRecoverableError),p.formState!==void 0&&(re=p.formState)),u=z0(l,1,!0,u,p??null,g,v,re,A,P,Y,X0),u.context=$0(null),p=u.current,g=aa(),g=Lt(g),v=oi(g),v.callback=null,li(p,v,g),p=g,u.current.lanes=p,Le(u,p),Qa(u),l[En]=u.current,Jm(l),new kf(u)},Zc.version="19.2.4",Zc}var ck;function SM(){if(ck)return vg.exports;ck=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),vg.exports=kM(),vg.exports}var CM=SM();const zt=t=>typeof t=="string",eu=()=>{let t,e;const n=new Promise((s,a)=>{t=s,e=a});return n.resolve=t,n.reject=e,n},uk=t=>t==null?"":String(t),AM=(t,e,n)=>{t.forEach(s=>{e[s]&&(n[s]=e[s])})},jM=/###/g,dk=t=>t&&t.includes("###")?t.replace(jM,"."):t,fk=t=>!t||zt(t),ju=(t,e,n)=>{const s=zt(e)?e.split("."):e;let a=0;for(;a<s.length-1;){if(fk(t))return{};const r=dk(s[a]);!t[r]&&n&&(t[r]=new n),Object.prototype.hasOwnProperty.call(t,r)?t=t[r]:t={},++a}return fk(t)?{}:{obj:t,k:dk(s[a])}},pk=(t,e,n)=>{const{obj:s,k:a}=ju(t,e,Object);if(s!==void 0||e.length===1){s[a]=n;return}let r=e[e.length-1],i=e.slice(0,e.length-1),c=ju(t,i,Object);for(;c.obj===void 0&&i.length;)r=`${i[i.length-1]}.${r}`,i=i.slice(0,i.length-1),c=ju(t,i,Object),c!=null&&c.obj&&typeof c.obj[`${c.k}.${r}`]<"u"&&(c.obj=void 0);c.obj[`${c.k}.${r}`]=n},NM=(t,e,n,s)=>{const{obj:a,k:r}=ju(t,e,Object);a[r]=a[r]||[],a[r].push(n)},fp=(t,e)=>{const{obj:n,k:s}=ju(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,s))return n[s]},TM=(t,e,n)=>{const s=fp(t,n);return s!==void 0?s:fp(e,n)},hj=(t,e,n)=>{for(const s in e)s!=="__proto__"&&s!=="constructor"&&(s in t?zt(t[s])||t[s]instanceof String||zt(e[s])||e[s]instanceof String?n&&(t[s]=e[s]):hj(t[s],e[s],n):t[s]=e[s]);return t},fo=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),_M={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"},EM=t=>zt(t)?t.replace(/[&<>"'\/]/g,e=>_M[e]):t;class MM{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const n=this.regExpMap.get(e);if(n!==void 0)return n;const s=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,s),this.regExpQueue.push(e),s}}const DM=[" ",",","?","!",";"],RM=new MM(20),OM=(t,e,n)=>{e=e||"",n=n||"";const s=DM.filter(i=>!e.includes(i)&&!n.includes(i));if(s.length===0)return!0;const a=RM.getRegExp(`(${s.map(i=>i==="?"?"\\?":i).join("|")})`);let r=!a.test(t);if(!r){const i=t.indexOf(n);i>0&&!a.test(t.substring(0,i))&&(r=!0)}return r},zb=(t,e,n=".")=>{if(!t)return;if(t[e])return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;const s=e.split(n);let a=t;for(let r=0;r<s.length;){if(!a||typeof a!="object")return;let i,c="";for(let d=r;d<s.length;++d)if(d!==r&&(c+=n),c+=s[d],i=a[c],i!==void 0){if(["string","number","boolean"].includes(typeof i)&&d<s.length-1)continue;r+=d-r+1;break}a=i}return a},Fu=t=>t==null?void 0:t.replace(/_/g,"-"),LM={type:"logger",log(t){this.output("log",t)},warn(t){this.output("warn",t)},error(t){this.output("error",t)},output(t,e){var n,s;(s=(n=console==null?void 0:console[t])==null?void 0:n.apply)==null||s.call(n,console,e)}};class pp{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||LM,this.options=n,this.debug=n.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,n,s,a){return a&&!this.debug?null:(zt(e[0])&&(e[0]=`${s}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new pp(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new pp(this.logger,e)}}var nr=new pp;class Vp{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(s=>{this.observers[s]||(this.observers[s]=new Map);const a=this.observers[s].get(n)||0;this.observers[s].set(n,a+1)}),this}off(e,n){if(this.observers[e]){if(!n){delete this.observers[e];return}this.observers[e].delete(n)}}once(e,n){const s=(...a)=>{n(...a),this.off(e,s)};return this.on(e,s),this}emit(e,...n){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([a,r])=>{for(let i=0;i<r;i++)a(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([a,r])=>{for(let i=0;i<r;i++)a(e,...n)})}}class hk extends Vp{constructor(e,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.includes(e)||this.options.ns.push(e)}removeNamespaces(e){const n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,s,a={}){var f,h;const r=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator,i=a.ignoreJSONStructure!==void 0?a.ignoreJSONStructure:this.options.ignoreJSONStructure;let c;e.includes(".")?c=e.split("."):(c=[e,n],s&&(Array.isArray(s)?c.push(...s):zt(s)&&r?c.push(...s.split(r)):c.push(s)));const d=fp(this.data,c);return!d&&!n&&!s&&e.includes(".")&&(e=c[0],n=c[1],s=c.slice(2).join(".")),d||!i||!zt(s)?d:zb((h=(f=this.data)==null?void 0:f[e])==null?void 0:h[n],s,r)}addResource(e,n,s,a,r={silent:!1}){const i=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator;let c=[e,n];s&&(c=c.concat(i?s.split(i):s)),e.includes(".")&&(c=e.split("."),a=n,n=c[1]),this.addNamespaces(n),pk(this.data,c,a),r.silent||this.emit("added",e,n,s,a)}addResources(e,n,s,a={silent:!1}){for(const r in s)(zt(s[r])||Array.isArray(s[r]))&&this.addResource(e,n,r,s[r],{silent:!0});a.silent||this.emit("added",e,n,s)}addResourceBundle(e,n,s,a,r,i={silent:!1,skipCopy:!1}){let c=[e,n];e.includes(".")&&(c=e.split("."),a=s,s=n,n=c[1]),this.addNamespaces(n);let d=fp(this.data,c)||{};i.skipCopy||(s=JSON.parse(JSON.stringify(s))),a?hj(d,s,r):d={...d,...s},pk(this.data,c,d),i.silent||this.emit("added",e,n,s)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return this.getResource(e,n)!==void 0}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(a=>n[a]&&Object.keys(n[a]).length>0)}toJSON(){return this.data}}var mj={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,s,a){return t.forEach(r=>{var i;e=((i=this.processors[r])==null?void 0:i.process(e,n,s,a))??e}),e}};const gj=Symbol("i18next/PATH_KEY");function IM(){const t=[],e=Object.create(null);let n;return e.get=(s,a)=>{var r;return(r=n==null?void 0:n.revoke)==null||r.call(n),a===gj?t:(t.push(a),n=Proxy.revocable(s,e),n.proxy)},Proxy.revocable(Object.create(null),e).proxy}function $l(t,e){const{[gj]:n}=t(IM()),s=(e==null?void 0:e.keySeparator)??".",a=(e==null?void 0:e.nsSeparator)??":";if(n.length>1&&a){const r=e==null?void 0:e.ns,i=Array.isArray(r)?r:null;if(i&&i.length>1&&i.slice(1).includes(n[0]))return`${n[0]}${a}${n.slice(1).join(s)}`}return n.join(s)}const Sg=t=>!zt(t)&&typeof t!="boolean"&&typeof t!="number";class hp extends Vp{constructor(e,n={}){super(),AM(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=nr.create("translator"),this.checkedLoadedFor={}}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){const s={...n};if(e==null)return!1;const a=this.resolve(e,s);if((a==null?void 0:a.res)===void 0)return!1;const r=Sg(a.res);return!(s.returnObjects===!1&&r)}extractFromKey(e,n){let s=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;s===void 0&&(s=":");const a=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let r=n.ns||this.options.defaultNS||[];const i=s&&e.includes(s),c=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!OM(e,s,a);if(i&&!c){const d=e.match(this.interpolator.nestingRegexp);if(d&&d.length>0)return{key:e,namespaces:zt(r)?[r]:r};const f=e.split(s);(s!==a||s===a&&this.options.ns.includes(f[0]))&&(r=f.shift()),e=f.join(a)}return{key:e,namespaces:zt(r)?[r]:r}}translate(e,n,s){let a=typeof n=="object"?{...n}:n;if(typeof a!="object"&&this.options.overloadTranslationOptionHandler&&(a=this.options.overloadTranslationOptionHandler(arguments)),typeof a=="object"&&(a={...a}),a||(a={}),e==null)return"";typeof e=="function"&&(e=$l(e,{...this.options,...a})),Array.isArray(e)||(e=[String(e)]),e=e.map($=>typeof $=="function"?$l($,{...this.options,...a}):String($));const r=a.returnDetails!==void 0?a.returnDetails:this.options.returnDetails,i=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator,{key:c,namespaces:d}=this.extractFromKey(e[e.length-1],a),f=d[d.length-1];let h=a.nsSeparator!==void 0?a.nsSeparator:this.options.nsSeparator;h===void 0&&(h=":");const m=a.lng||this.language,b=a.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if((m==null?void 0:m.toLowerCase())==="cimode")return b?r?{res:`${f}${h}${c}`,usedKey:c,exactUsedKey:c,usedLng:m,usedNS:f,usedParams:this.getUsedParamsDetails(a)}:`${f}${h}${c}`:r?{res:c,usedKey:c,exactUsedKey:c,usedLng:m,usedNS:f,usedParams:this.getUsedParamsDetails(a)}:c;const y=this.resolve(e,a);let w=y==null?void 0:y.res;const C=(y==null?void 0:y.usedKey)||c,N=(y==null?void 0:y.exactUsedKey)||c,k=["[object Number]","[object Function]","[object RegExp]"],j=a.joinArrays!==void 0?a.joinArrays:this.options.joinArrays,S=!this.i18nFormat||this.i18nFormat.handleAsObject,T=a.count!==void 0&&!zt(a.count),D=hp.hasDefaultValue(a),E=T?this.pluralResolver.getSuffix(m,a.count,a):"",I=a.ordinal&&T?this.pluralResolver.getSuffix(m,a.count,{ordinal:!1}):"",O=T&&!a.ordinal&&a.count===0,_=O&&a[`defaultValue${this.options.pluralSeparator}zero`]||a[`defaultValue${E}`]||a[`defaultValue${I}`]||a.defaultValue;let M=w;S&&!w&&D&&(M=_);const R=Sg(M),z=Object.prototype.toString.apply(M);if(S&&M&&R&&!k.includes(z)&&!(zt(j)&&Array.isArray(M))){if(!a.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const $=this.options.returnedObjectHandler?this.options.returnedObjectHandler(C,M,{...a,ns:d}):`key '${c} (${this.language})' returned an object instead of string.`;return r?(y.res=$,y.usedParams=this.getUsedParamsDetails(a),y):$}if(i){const $=Array.isArray(M),W=$?[]:{},L=$?N:C;for(const F in M)if(Object.prototype.hasOwnProperty.call(M,F)){const H=`${L}${i}${F}`;D&&!w?W[F]=this.translate(H,{...a,defaultValue:Sg(_)?_[F]:void 0,joinArrays:!1,ns:d}):W[F]=this.translate(H,{...a,joinArrays:!1,ns:d}),W[F]===H&&(W[F]=M[F])}w=W}}else if(S&&zt(j)&&Array.isArray(w))w=w.join(j),w&&(w=this.extendTranslation(w,e,a,s));else{let $=!1,W=!1;!this.isValidLookup(w)&&D&&($=!0,w=_),this.isValidLookup(w)||(W=!0,w=c);const F=(a.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&W?void 0:w,H=D&&_!==w&&this.options.updateMissing;if(W||$||H){if(this.logger.log(H?"updateKey":"missingKey",m,f,c,H?_:w),i){const K=this.resolve(c,{...a,keySeparator:!1});K&&K.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let V=[];const G=this.languageUtils.getFallbackCodes(this.options.fallbackLng,a.lng||this.language);if(this.options.saveMissingTo==="fallback"&&G&&G[0])for(let K=0;K<G.length;K++)V.push(G[K]);else this.options.saveMissingTo==="all"?V=this.languageUtils.toResolveHierarchy(a.lng||this.language):V.push(a.lng||this.language);const B=(K,se,q)=>{var Ce;const be=D&&q!==w?q:F;this.options.missingKeyHandler?this.options.missingKeyHandler(K,f,se,be,H,a):(Ce=this.backendConnector)!=null&&Ce.saveMissing&&this.backendConnector.saveMissing(K,f,se,be,H,a),this.emit("missingKey",K,f,se,w)};this.options.saveMissing&&(this.options.saveMissingPlurals&&T?V.forEach(K=>{const se=this.pluralResolver.getSuffixes(K,a);O&&a[`defaultValue${this.options.pluralSeparator}zero`]&&!se.includes(`${this.options.pluralSeparator}zero`)&&se.push(`${this.options.pluralSeparator}zero`),se.forEach(q=>{B([K],c+q,a[`defaultValue${q}`]||_)})}):B(V,c,_))}w=this.extendTranslation(w,e,a,y,s),W&&w===c&&this.options.appendNamespaceToMissingKey&&(w=`${f}${h}${c}`),(W||$)&&this.options.parseMissingKeyHandler&&(w=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${f}${h}${c}`:c,$?w:void 0,a))}return r?(y.res=w,y.usedParams=this.getUsedParamsDetails(a),y):w}extendTranslation(e,n,s,a,r){var d,f;if((d=this.i18nFormat)!=null&&d.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...s},s.lng||this.language||a.usedLng,a.usedNS,a.usedKey,{resolved:a});else if(!s.skipInterpolation){s.interpolation&&this.interpolator.init({...s,interpolation:{...this.options.interpolation,...s.interpolation}});const h=zt(e)&&(((f=s==null?void 0:s.interpolation)==null?void 0:f.skipOnVariables)!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let m;if(h){const y=e.match(this.interpolator.nestingRegexp);m=y&&y.length}let b=s.replace&&!zt(s.replace)?s.replace:s;if(this.options.interpolation.defaultVariables&&(b={...this.options.interpolation.defaultVariables,...b}),e=this.interpolator.interpolate(e,b,s.lng||this.language||a.usedLng,s),h){const y=e.match(this.interpolator.nestingRegexp),w=y&&y.length;m<w&&(s.nest=!1)}!s.lng&&a&&a.res&&(s.lng=this.language||a.usedLng),s.nest!==!1&&(e=this.interpolator.nest(e,(...y)=>(r==null?void 0:r[0])===y[0]&&!s.context?(this.logger.warn(`It seems you are nesting recursively key: ${y[0]} in key: ${n[0]}`),null):this.translate(...y,n),s)),s.interpolation&&this.interpolator.reset()}const i=s.postProcess||this.options.postProcess,c=zt(i)?[i]:i;return e!=null&&(c!=null&&c.length)&&s.applyPostProcessor!==!1&&(e=mj.handle(c,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...a,usedParams:this.getUsedParamsDetails(s)},...s}:s,this)),e}resolve(e,n={}){let s,a,r,i,c;return zt(e)&&(e=[e]),Array.isArray(e)&&(e=e.map(d=>typeof d=="function"?$l(d,{...this.options,...n}):d)),e.forEach(d=>{if(this.isValidLookup(s))return;const f=this.extractFromKey(d,n),h=f.key;a=h;let m=f.namespaces;this.options.fallbackNS&&(m=m.concat(this.options.fallbackNS));const b=n.count!==void 0&&!zt(n.count),y=b&&!n.ordinal&&n.count===0,w=n.context!==void 0&&(zt(n.context)||typeof n.context=="number")&&n.context!=="",C=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);m.forEach(N=>{var k,j;this.isValidLookup(s)||(c=N,!this.checkedLoadedFor[`${C[0]}-${N}`]&&((k=this.utils)!=null&&k.hasLoadedNamespace)&&!((j=this.utils)!=null&&j.hasLoadedNamespace(c))&&(this.checkedLoadedFor[`${C[0]}-${N}`]=!0,this.logger.warn(`key "${a}" for languages "${C.join(", ")}" won't get resolved as namespace "${c}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),C.forEach(S=>{var E;if(this.isValidLookup(s))return;i=S;const T=[h];if((E=this.i18nFormat)!=null&&E.addLookupKeys)this.i18nFormat.addLookupKeys(T,h,S,N,n);else{let I;b&&(I=this.pluralResolver.getSuffix(S,n.count,n));const O=`${this.options.pluralSeparator}zero`,_=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(b&&(n.ordinal&&I.startsWith(_)&&T.push(h+I.replace(_,this.options.pluralSeparator)),T.push(h+I),y&&T.push(h+O)),w){const M=`${h}${this.options.contextSeparator||"_"}${n.context}`;T.push(M),b&&(n.ordinal&&I.startsWith(_)&&T.push(M+I.replace(_,this.options.pluralSeparator)),T.push(M+I),y&&T.push(M+O))}}let D;for(;D=T.pop();)this.isValidLookup(s)||(r=D,s=this.getResource(S,N,D,n))}))})}),{res:s,usedKey:a,exactUsedKey:r,usedLng:i,usedNS:c}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,s,a={}){var r;return(r=this.i18nFormat)!=null&&r.getResource?this.i18nFormat.getResource(e,n,s,a):this.resourceStore.getResource(e,n,s,a)}getUsedParamsDetails(e={}){const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],s=e.replace&&!zt(e.replace);let a=s?e.replace:e;if(s&&typeof e.count<"u"&&(a.count=e.count),this.options.interpolation.defaultVariables&&(a={...this.options.interpolation.defaultVariables,...a}),!s){a={...a};for(const r of n)delete a[r]}return a}static hasDefaultValue(e){const n="defaultValue";for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)&&s.startsWith(n)&&e[s]!==void 0)return!0;return!1}}class mk{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=nr.create("languageUtils")}getScriptPartFromCode(e){if(e=Fu(e),!e||!e.includes("-"))return null;const n=e.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(e){if(e=Fu(e),!e||!e.includes("-"))return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(zt(e)&&e.includes("-")){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.includes(e)}getBestMatchFromCodes(e){if(!e)return null;let n;return e.forEach(s=>{if(n)return;const a=this.formatLanguageCode(s);(!this.options.supportedLngs||this.isSupportedCode(a))&&(n=a)}),!n&&this.options.supportedLngs&&e.forEach(s=>{if(n)return;const a=this.getScriptPartFromCode(s);if(this.isSupportedCode(a))return n=a;const r=this.getLanguagePartFromCode(s);if(this.isSupportedCode(r))return n=r;n=this.options.supportedLngs.find(i=>i===r?!0:!i.includes("-")&&!r.includes("-")?!1:!!(i.includes("-")&&!r.includes("-")&&i.slice(0,i.indexOf("-"))===r||i.startsWith(r)&&r.length>1))}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),zt(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let s=e[n];return s||(s=e[this.getScriptPartFromCode(n)]),s||(s=e[this.formatLanguageCode(n)]),s||(s=e[this.getLanguagePartFromCode(n)]),s||(s=e.default),s||[]}toResolveHierarchy(e,n){const s=this.getFallbackCodes((n===!1?[]:n)||this.options.fallbackLng||[],e),a=[],r=i=>{i&&(this.isSupportedCode(i)?a.push(i):this.logger.warn(`rejecting language code not found in supportedLngs: ${i}`))};return zt(e)&&(e.includes("-")||e.includes("_"))?(this.options.load!=="languageOnly"&&r(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&r(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&r(this.getLanguagePartFromCode(e))):zt(e)&&r(this.formatLanguageCode(e)),s.forEach(i=>{a.includes(i)||r(this.formatLanguageCode(i))}),a}}const gk={zero:0,one:1,two:2,few:3,many:4,other:5},bk={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class PM{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=nr.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const s=Fu(e==="dev"?"en":e),a=n.ordinal?"ordinal":"cardinal",r=JSON.stringify({cleanedCode:s,type:a});if(r in this.pluralRulesCache)return this.pluralRulesCache[r];let i;try{i=new Intl.PluralRules(s,{type:a})}catch{if(typeof Intl>"u")return this.logger.error("No Intl support, please use an Intl polyfill!"),bk;if(!e.match(/-|_/))return bk;const d=this.languageUtils.getLanguagePartFromCode(e);i=this.getRule(d,n)}return this.pluralRulesCache[r]=i,i}needsPlural(e,n={}){let s=this.getRule(e,n);return s||(s=this.getRule("dev",n)),(s==null?void 0:s.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(e,n,s={}){return this.getSuffixes(e,s).map(a=>`${n}${a}`)}getSuffixes(e,n={}){let s=this.getRule(e,n);return s||(s=this.getRule("dev",n)),s?s.resolvedOptions().pluralCategories.sort((a,r)=>gk[a]-gk[r]).map(a=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${a}`):[]}getSuffix(e,n,s={}){const a=this.getRule(e,s);return a?`${this.options.prepend}${s.ordinal?`ordinal${this.options.prepend}`:""}${a.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,s))}}const xk=(t,e,n,s=".",a=!0)=>{let r=TM(t,e,n);return!r&&a&&zt(n)&&(r=zb(t,n,s),r===void 0&&(r=zb(e,n,s))),r},Cg=t=>t.replace(/\$/g,"$$$$");class yk{constructor(e={}){var n;this.logger=nr.create("interpolator"),this.options=e,this.format=((n=e==null?void 0:e.interpolation)==null?void 0:n.format)||(s=>s),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:n,escapeValue:s,useRawValueToEscape:a,prefix:r,prefixEscaped:i,suffix:c,suffixEscaped:d,formatSeparator:f,unescapeSuffix:h,unescapePrefix:m,nestingPrefix:b,nestingPrefixEscaped:y,nestingSuffix:w,nestingSuffixEscaped:C,nestingOptionsSeparator:N,maxReplaces:k,alwaysFormat:j}=e.interpolation;this.escape=n!==void 0?n:EM,this.escapeValue=s!==void 0?s:!0,this.useRawValueToEscape=a!==void 0?a:!1,this.prefix=r?fo(r):i||"{{",this.suffix=c?fo(c):d||"}}",this.formatSeparator=f||",",this.unescapePrefix=h?"":m||"-",this.unescapeSuffix=this.unescapePrefix?"":h||"",this.nestingPrefix=b?fo(b):y||fo("$t("),this.nestingSuffix=w?fo(w):C||fo(")"),this.nestingOptionsSeparator=N||",",this.maxReplaces=k||1e3,this.alwaysFormat=j!==void 0?j:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(n,s)=>(n==null?void 0:n.source)===s?(n.lastIndex=0,n):new RegExp(s,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,n,s,a){var y;let r,i,c;const d=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},f=w=>{if(!w.includes(this.formatSeparator)){const j=xk(n,d,w,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(j,void 0,s,{...a,...n,interpolationkey:w}):j}const C=w.split(this.formatSeparator),N=C.shift().trim(),k=C.join(this.formatSeparator).trim();return this.format(xk(n,d,N,this.options.keySeparator,this.options.ignoreJSONStructure),k,s,{...a,...n,interpolationkey:N})};this.resetRegExp();const h=(a==null?void 0:a.missingInterpolationHandler)||this.options.missingInterpolationHandler,m=((y=a==null?void 0:a.interpolation)==null?void 0:y.skipOnVariables)!==void 0?a.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:w=>Cg(w)},{regex:this.regexp,safeValue:w=>this.escapeValue?Cg(this.escape(w)):Cg(w)}].forEach(w=>{for(c=0;r=w.regex.exec(e);){const C=r[1].trim();if(i=f(C),i===void 0)if(typeof h=="function"){const k=h(e,r,a);i=zt(k)?k:""}else if(a&&Object.prototype.hasOwnProperty.call(a,C))i="";else if(m){i=r[0];continue}else this.logger.warn(`missed to pass in variable ${C} for interpolating ${e}`),i="";else!zt(i)&&!this.useRawValueToEscape&&(i=uk(i));const N=w.safeValue(i);if(e=e.replace(r[0],N),m?(w.regex.lastIndex+=i.length,w.regex.lastIndex-=r[0].length):w.regex.lastIndex=0,c++,c>=this.maxReplaces)break}}),e}nest(e,n,s={}){let a,r,i;const c=(d,f)=>{const h=this.nestingOptionsSeparator;if(!d.includes(h))return d;const m=d.split(new RegExp(`${fo(h)}[ ]*{`));let b=`{${m[1]}`;d=m[0],b=this.interpolate(b,i);const y=b.match(/'/g),w=b.match(/"/g);(((y==null?void 0:y.length)??0)%2===0&&!w||((w==null?void 0:w.length)??0)%2!==0)&&(b=b.replace(/'/g,'"'));try{i=JSON.parse(b),f&&(i={...f,...i})}catch(C){return this.logger.warn(`failed parsing options string in nesting for key ${d}`,C),`${d}${h}${b}`}return i.defaultValue&&i.defaultValue.includes(this.prefix)&&delete i.defaultValue,d};for(;a=this.nestingRegexp.exec(e);){let d=[];i={...s},i=i.replace&&!zt(i.replace)?i.replace:i,i.applyPostProcessor=!1,delete i.defaultValue;const f=/{.*}/.test(a[1])?a[1].lastIndexOf("}")+1:a[1].indexOf(this.formatSeparator);if(f!==-1&&(d=a[1].slice(f).split(this.formatSeparator).map(h=>h.trim()).filter(Boolean),a[1]=a[1].slice(0,f)),r=n(c.call(this,a[1].trim(),i),i),r&&a[0]===e&&!zt(r))return r;zt(r)||(r=uk(r)),r||(this.logger.warn(`missed to resolve ${a[1]} for nesting ${e}`),r=""),d.length&&(r=d.reduce((h,m)=>this.format(h,m,s.lng,{...s,interpolationkey:a[1].trim()}),r.trim())),e=e.replace(a[0],r),this.regexp.lastIndex=0}return e}}const BM=t=>{let e=t.toLowerCase().trim();const n={};if(t.includes("(")){const s=t.split("(");e=s[0].toLowerCase().trim();const a=s[1].slice(0,-1);e==="currency"&&!a.includes(":")?n.currency||(n.currency=a.trim()):e==="relativetime"&&!a.includes(":")?n.range||(n.range=a.trim()):a.split(";").forEach(i=>{if(i){const[c,...d]=i.split(":"),f=d.join(":").trim().replace(/^'+|'+$/g,""),h=c.trim();n[h]||(n[h]=f),f==="false"&&(n[h]=!1),f==="true"&&(n[h]=!0),isNaN(f)||(n[h]=parseInt(f,10))}})}return{formatName:e,formatOptions:n}},vk=t=>{const e={};return(n,s,a)=>{let r=a;a&&a.interpolationkey&&a.formatParams&&a.formatParams[a.interpolationkey]&&a[a.interpolationkey]&&(r={...r,[a.interpolationkey]:void 0});const i=s+JSON.stringify(r);let c=e[i];return c||(c=t(Fu(s),a),e[i]=c),c(n)}},FM=t=>(e,n,s)=>t(Fu(n),s)(e);class zM{constructor(e={}){this.logger=nr.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const s=n.cacheInBuiltFormats?vk:FM;this.formats={number:s((a,r)=>{const i=new Intl.NumberFormat(a,{...r});return c=>i.format(c)}),currency:s((a,r)=>{const i=new Intl.NumberFormat(a,{...r,style:"currency"});return c=>i.format(c)}),datetime:s((a,r)=>{const i=new Intl.DateTimeFormat(a,{...r});return c=>i.format(c)}),relativetime:s((a,r)=>{const i=new Intl.RelativeTimeFormat(a,{...r});return c=>i.format(c,r.range||"day")}),list:s((a,r)=>{const i=new Intl.ListFormat(a,{...r});return c=>i.format(c)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=vk(n)}format(e,n,s,a={}){if(!n||e==null)return e;const r=n.split(this.formatSeparator);if(r.length>1&&r[0].indexOf("(")>1&&!r[0].includes(")")&&r.find(c=>c.includes(")"))){const c=r.findIndex(d=>d.includes(")"));r[0]=[r[0],...r.splice(1,c)].join(this.formatSeparator)}return r.reduce((c,d)=>{var m;const{formatName:f,formatOptions:h}=BM(d);if(this.formats[f]){let b=c;try{const y=((m=a==null?void 0:a.formatParams)==null?void 0:m[a.interpolationkey])||{},w=y.locale||y.lng||a.locale||a.lng||s;b=this.formats[f](c,w,{...h,...a,...y})}catch(y){this.logger.warn(y)}return b}else this.logger.warn(`there was no format function for ${f}`);return c},e)}}const $M=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class UM extends Vp{constructor(e,n,s,a={}){var r,i;super(),this.backend=e,this.store=n,this.services=s,this.languageUtils=s.languageUtils,this.options=a,this.logger=nr.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=a.maxParallelReads||10,this.readingCalls=0,this.maxRetries=a.maxRetries>=0?a.maxRetries:5,this.retryTimeout=a.retryTimeout>=1?a.retryTimeout:350,this.state={},this.queue=[],(i=(r=this.backend)==null?void 0:r.init)==null||i.call(r,s,a.backend,a)}queueLoad(e,n,s,a){const r={},i={},c={},d={};return e.forEach(f=>{let h=!0;n.forEach(m=>{const b=`${f}|${m}`;!s.reload&&this.store.hasResourceBundle(f,m)?this.state[b]=2:this.state[b]<0||(this.state[b]===1?i[b]===void 0&&(i[b]=!0):(this.state[b]=1,h=!1,i[b]===void 0&&(i[b]=!0),r[b]===void 0&&(r[b]=!0),d[m]===void 0&&(d[m]=!0)))}),h||(c[f]=!0)}),(Object.keys(r).length||Object.keys(i).length)&&this.queue.push({pending:i,pendingCount:Object.keys(i).length,loaded:{},errors:[],callback:a}),{toLoad:Object.keys(r),pending:Object.keys(i),toLoadLanguages:Object.keys(c),toLoadNamespaces:Object.keys(d)}}loaded(e,n,s){const a=e.split("|"),r=a[0],i=a[1];n&&this.emit("failedLoading",r,i,n),!n&&s&&this.store.addResourceBundle(r,i,s,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&s&&(this.state[e]=0);const c={};this.queue.forEach(d=>{NM(d.loaded,[r],i),$M(d,e),n&&d.errors.push(n),d.pendingCount===0&&!d.done&&(Object.keys(d.loaded).forEach(f=>{c[f]||(c[f]={});const h=d.loaded[f];h.length&&h.forEach(m=>{c[f][m]===void 0&&(c[f][m]=!0)})}),d.done=!0,d.errors.length?d.callback(d.errors):d.callback())}),this.emit("loaded",c),this.queue=this.queue.filter(d=>!d.done)}read(e,n,s,a=0,r=this.retryTimeout,i){if(!e.length)return i(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:s,tried:a,wait:r,callback:i});return}this.readingCalls++;const c=(f,h)=>{if(this.readingCalls--,this.waitingReads.length>0){const m=this.waitingReads.shift();this.read(m.lng,m.ns,m.fcName,m.tried,m.wait,m.callback)}if(f&&h&&a<this.maxRetries){setTimeout(()=>{this.read(e,n,s,a+1,r*2,i)},r);return}i(f,h)},d=this.backend[s].bind(this.backend);if(d.length===2){try{const f=d(e,n);f&&typeof f.then=="function"?f.then(h=>c(null,h)).catch(c):c(null,f)}catch(f){c(f)}return}return d(e,n,c)}prepareLoading(e,n,s={},a){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),a&&a();zt(e)&&(e=this.languageUtils.toResolveHierarchy(e)),zt(n)&&(n=[n]);const r=this.queueLoad(e,n,s,a);if(!r.toLoad.length)return r.pending.length||a(),null;r.toLoad.forEach(i=>{this.loadOne(i)})}load(e,n,s){this.prepareLoading(e,n,{},s)}reload(e,n,s){this.prepareLoading(e,n,{reload:!0},s)}loadOne(e,n=""){const s=e.split("|"),a=s[0],r=s[1];this.read(a,r,"read",void 0,void 0,(i,c)=>{i&&this.logger.warn(`${n}loading namespace ${r} for language ${a} failed`,i),!i&&c&&this.logger.log(`${n}loaded namespace ${r} for language ${a}`,c),this.loaded(e,i,c)})}saveMissing(e,n,s,a,r,i={},c=()=>{}){var d,f,h,m,b;if((f=(d=this.services)==null?void 0:d.utils)!=null&&f.hasLoadedNamespace&&!((m=(h=this.services)==null?void 0:h.utils)!=null&&m.hasLoadedNamespace(n))){this.logger.warn(`did not save key "${s}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(s==null||s==="")){if((b=this.backend)!=null&&b.create){const y={...i,isUpdate:r},w=this.backend.create.bind(this.backend);if(w.length<6)try{let C;w.length===5?C=w(e,n,s,a,y):C=w(e,n,s,a),C&&typeof C.then=="function"?C.then(N=>c(null,N)).catch(c):c(null,C)}catch(C){c(C)}else w(e,n,s,a,c,y)}!e||!e[0]||this.store.addResource(e[0],n,s,a)}}}const Ag=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let e={};if(typeof t[1]=="object"&&(e=t[1]),zt(t[1])&&(e.defaultValue=t[1]),zt(t[2])&&(e.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const n=t[3]||t[2];Object.keys(n).forEach(s=>{e[s]=n[s]})}return e},interpolation:{escapeValue:!0,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),wk=t=>(zt(t.ns)&&(t.ns=[t.ns]),zt(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),zt(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs&&!t.supportedLngs.includes("cimode")&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),t),Cf=()=>{},HM=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class Nu extends Vp{constructor(e={},n){if(super(),this.options=wk(e),this.services={},this.logger=nr,this.modules={external:[]},HM(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(e={},n){this.isInitializing=!0,typeof e=="function"&&(n=e,e={}),e.defaultNS==null&&e.ns&&(zt(e.ns)?e.defaultNS=e.ns:e.ns.includes("translation")||(e.defaultNS=e.ns[0]));const s=Ag();this.options={...s,...this.options,...wk(e)},this.options.interpolation={...s.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator),typeof this.options.overloadTranslationOptionHandler!="function"&&(this.options.overloadTranslationOptionHandler=s.overloadTranslationOptionHandler);const a=f=>f?typeof f=="function"?new f:f:null;if(!this.options.isClone){this.modules.logger?nr.init(a(this.modules.logger),this.options):nr.init(null,this.options);let f;this.modules.formatter?f=this.modules.formatter:f=zM;const h=new mk(this.options);this.store=new hk(this.options.resources,this.options);const m=this.services;m.logger=nr,m.resourceStore=this.store,m.languageUtils=h,m.pluralResolver=new PM(h,{prepend:this.options.pluralSeparator}),f&&(m.formatter=a(f),m.formatter.init&&m.formatter.init(m,this.options),this.options.interpolation.format=m.formatter.format.bind(m.formatter)),m.interpolator=new yk(this.options),m.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},m.backendConnector=new UM(a(this.modules.backend),m.resourceStore,m,this.options),m.backendConnector.on("*",(b,...y)=>{this.emit(b,...y)}),this.modules.languageDetector&&(m.languageDetector=a(this.modules.languageDetector),m.languageDetector.init&&m.languageDetector.init(m,this.options.detection,this.options)),this.modules.i18nFormat&&(m.i18nFormat=a(this.modules.i18nFormat),m.i18nFormat.init&&m.i18nFormat.init(this)),this.translator=new hp(this.services,this.options),this.translator.on("*",(b,...y)=>{this.emit(b,...y)}),this.modules.external.forEach(b=>{b.init&&b.init(this)})}if(this.format=this.options.interpolation.format,n||(n=Cf),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const f=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);f.length>0&&f[0]!=="dev"&&(this.options.lng=f[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(f=>{this[f]=(...h)=>this.store[f](...h)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(f=>{this[f]=(...h)=>(this.store[f](...h),this)});const c=eu(),d=()=>{const f=(h,m)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),c.resolve(m),n(h,m)};if(this.languages&&!this.isInitialized)return f(null,this.t.bind(this));this.changeLanguage(this.options.lng,f)};return this.options.resources||!this.options.initAsync?d():setTimeout(d,0),c}loadResources(e,n=Cf){var r,i;let s=n;const a=zt(e)?e:this.language;if(typeof e=="function"&&(s=e),!this.options.resources||this.options.partialBundledLanguages){if((a==null?void 0:a.toLowerCase())==="cimode"&&(!this.options.preload||this.options.preload.length===0))return s();const c=[],d=f=>{if(!f||f==="cimode")return;this.services.languageUtils.toResolveHierarchy(f).forEach(m=>{m!=="cimode"&&(c.includes(m)||c.push(m))})};a?d(a):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(h=>d(h)),(i=(r=this.options.preload)==null?void 0:r.forEach)==null||i.call(r,f=>d(f)),this.services.backendConnector.load(c,this.options.ns,f=>{!f&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),s(f)})}else s(null)}reloadResources(e,n,s){const a=eu();return typeof e=="function"&&(s=e,e=void 0),typeof n=="function"&&(s=n,n=void 0),e||(e=this.languages),n||(n=this.options.ns),s||(s=Cf),this.services.backendConnector.reload(e,n,r=>{a.resolve(),s(r)}),a}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&mj.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!["cimode","dev"].includes(e)){for(let n=0;n<this.languages.length;n++){const s=this.languages[n];if(!["cimode","dev"].includes(s)&&this.store.hasLanguageSomeTranslations(s)){this.resolvedLanguage=s;break}}!this.resolvedLanguage&&!this.languages.includes(e)&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,n){this.isLanguageChangingTo=e;const s=eu();this.emit("languageChanging",e);const a=c=>{this.language=c,this.languages=this.services.languageUtils.toResolveHierarchy(c),this.resolvedLanguage=void 0,this.setResolvedLanguage(c)},r=(c,d)=>{d?this.isLanguageChangingTo===e&&(a(d),this.translator.changeLanguage(d),this.isLanguageChangingTo=void 0,this.emit("languageChanged",d),this.logger.log("languageChanged",d)):this.isLanguageChangingTo=void 0,s.resolve((...f)=>this.t(...f)),n&&n(c,(...f)=>this.t(...f))},i=c=>{var h,m;!e&&!c&&this.services.languageDetector&&(c=[]);const d=zt(c)?c:c&&c[0],f=this.store.hasLanguageSomeTranslations(d)?d:this.services.languageUtils.getBestMatchFromCodes(zt(c)?[c]:c);f&&(this.language||a(f),this.translator.language||this.translator.changeLanguage(f),(m=(h=this.services.languageDetector)==null?void 0:h.cacheUserLanguage)==null||m.call(h,f)),this.loadResources(f,b=>{r(b,f)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?i(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(i):this.services.languageDetector.detect(i):i(e),s}getFixedT(e,n,s){const a=(r,i,...c)=>{let d;typeof i!="object"?d=this.options.overloadTranslationOptionHandler([r,i].concat(c)):d={...i},d.lng=d.lng||a.lng,d.lngs=d.lngs||a.lngs,d.ns=d.ns||a.ns,d.keyPrefix!==""&&(d.keyPrefix=d.keyPrefix||s||a.keyPrefix);const f={...this.options,...d};typeof d.keyPrefix=="function"&&(d.keyPrefix=$l(d.keyPrefix,f));const h=this.options.keySeparator||".";let m;return d.keyPrefix&&Array.isArray(r)?m=r.map(b=>(typeof b=="function"&&(b=$l(b,f)),`${d.keyPrefix}${h}${b}`)):(typeof r=="function"&&(r=$l(r,f)),m=d.keyPrefix?`${d.keyPrefix}${h}${r}`:r),this.t(m,d)};return zt(e)?a.lng=e:a.lngs=e,a.ns=n,a.keyPrefix=s,a}t(...e){var n;return(n=this.translator)==null?void 0:n.translate(...e)}exists(...e){var n;return(n=this.translator)==null?void 0:n.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const s=n.lng||this.resolvedLanguage||this.languages[0],a=this.options?this.options.fallbackLng:!1,r=this.languages[this.languages.length-1];if(s.toLowerCase()==="cimode")return!0;const i=(c,d)=>{const f=this.services.backendConnector.state[`${c}|${d}`];return f===-1||f===0||f===2};if(n.precheck){const c=n.precheck(this,i);if(c!==void 0)return c}return!!(this.hasResourceBundle(s,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||i(s,e)&&(!a||i(r,e)))}loadNamespaces(e,n){const s=eu();return this.options.ns?(zt(e)&&(e=[e]),e.forEach(a=>{this.options.ns.includes(a)||this.options.ns.push(a)}),this.loadResources(a=>{s.resolve(),n&&n(a)}),s):(n&&n(),Promise.resolve())}loadLanguages(e,n){const s=eu();zt(e)&&(e=[e]);const a=this.options.preload||[],r=e.filter(i=>!a.includes(i)&&this.services.languageUtils.isSupportedCode(i));return r.length?(this.options.preload=a.concat(r),this.loadResources(i=>{s.resolve(),n&&n(i)}),s):(n&&n(),Promise.resolve())}dir(e){var a,r;if(e||(e=this.resolvedLanguage||(((a=this.languages)==null?void 0:a.length)>0?this.languages[0]:this.language)),!e)return"rtl";try{const i=new Intl.Locale(e);if(i&&i.getTextInfo){const c=i.getTextInfo();if(c&&c.direction)return c.direction}}catch{}const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],s=((r=this.services)==null?void 0:r.languageUtils)||new mk(Ag());return e.toLowerCase().indexOf("-latn")>1?"ltr":n.includes(s.getLanguagePartFromCode(e))||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},n){const s=new Nu(e,n);return s.createInstance=Nu.createInstance,s}cloneInstance(e={},n=Cf){const s=e.forkResourceStore;s&&delete e.forkResourceStore;const a={...this.options,...e,isClone:!0},r=new Nu(a);if((e.debug!==void 0||e.prefix!==void 0)&&(r.logger=r.logger.clone(e)),["store","services","language"].forEach(c=>{r[c]=this[c]}),r.services={...this.services},r.services.utils={hasLoadedNamespace:r.hasLoadedNamespace.bind(r)},s){const c=Object.keys(this.store.data).reduce((d,f)=>(d[f]={...this.store.data[f]},d[f]=Object.keys(d[f]).reduce((h,m)=>(h[m]={...d[f][m]},h),d[f]),d),{});r.store=new hk(c,a),r.services.resourceStore=r.store}if(e.interpolation){const d={...Ag().interpolation,...this.options.interpolation,...e.interpolation},f={...a,interpolation:d};r.services.interpolator=new yk(f)}return r.translator=new hp(r.services,a),r.translator.on("*",(c,...d)=>{r.emit(c,...d)}),r.init(a,n),r.translator.options=a,r.translator.backendConnector.services.utils={hasLoadedNamespace:r.hasLoadedNamespace.bind(r)},r}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const On=Nu.createInstance();On.createInstance;On.dir;On.init;On.loadResources;On.reloadResources;On.use;On.changeLanguage;On.getFixedT;On.t;On.exists;On.setDefaultNamespace;On.hasLoadedNamespace;On.loadNamespaces;On.loadLanguages;const WM=(t,e,n,s)=>{var r,i,c,d;const a=[n,{code:e,...s||{}}];if((i=(r=t==null?void 0:t.services)==null?void 0:r.logger)!=null&&i.forward)return t.services.logger.forward(a,"warn","react-i18next::",!0);No(a[0])&&(a[0]=`react-i18next:: ${a[0]}`),(d=(c=t==null?void 0:t.services)==null?void 0:c.logger)!=null&&d.warn?t.services.logger.warn(...a):console!=null&&console.warn&&console.warn(...a)},kk={},$b=(t,e,n,s)=>{No(n)&&kk[n]||(No(n)&&(kk[n]=new Date),WM(t,e,n,s))},bj=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},Ub=(t,e,n)=>{t.loadNamespaces(e,bj(t,n))},Sk=(t,e,n,s)=>{if(No(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return Ub(t,n,s);n.forEach(a=>{t.options.ns.indexOf(a)<0&&t.options.ns.push(a)}),t.loadLanguages(e,bj(t,s))},qM=(t,e,n={})=>!e.languages||!e.languages.length?($b(e,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:e.languages}),!0):e.hasLoadedNamespace(t,{lng:n.lng,precheck:(s,a)=>{if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&s.services.backendConnector.backend&&s.isLanguageChangingTo&&!a(s.isLanguageChangingTo,t))return!1}}),No=t=>typeof t=="string",VM=t=>typeof t=="object"&&t!==null,YM=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,GM={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},KM=t=>GM[t],QM=t=>t.replace(YM,KM);let Hb={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:QM,transDefaultProps:void 0};const XM=(t={})=>{Hb={...Hb,...t}},JM=()=>Hb;let xj;const ZM=t=>{xj=t},eD=()=>xj,tD={type:"3rdParty",init(t){XM(t.options.react),ZM(t)}},nD=x.createContext();class sD{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var jg={exports:{}},Ng={};/**
35
- * @license React
36
- * use-sync-external-store-shim.production.js
37
- *
38
- * Copyright (c) Meta Platforms, Inc. and affiliates.
39
- *
40
- * This source code is licensed under the MIT license found in the
41
- * LICENSE file in the root directory of this source tree.
42
- */var Ck;function aD(){if(Ck)return Ng;Ck=1;var t=Nx();function e(m,b){return m===b&&(m!==0||1/m===1/b)||m!==m&&b!==b}var n=typeof Object.is=="function"?Object.is:e,s=t.useState,a=t.useEffect,r=t.useLayoutEffect,i=t.useDebugValue;function c(m,b){var y=b(),w=s({inst:{value:y,getSnapshot:b}}),C=w[0].inst,N=w[1];return r(function(){C.value=y,C.getSnapshot=b,d(C)&&N({inst:C})},[m,y,b]),a(function(){return d(C)&&N({inst:C}),m(function(){d(C)&&N({inst:C})})},[m]),i(y),y}function d(m){var b=m.getSnapshot;m=m.value;try{var y=b();return!n(m,y)}catch{return!0}}function f(m,b){return b()}var h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:c;return Ng.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:h,Ng}var Ak;function rD(){return Ak||(Ak=1,jg.exports=aD()),jg.exports}var iD=rD();const oD=(t,e)=>{if(No(e))return e;if(VM(e)&&No(e.defaultValue))return e.defaultValue;if(typeof t=="function")return"";if(Array.isArray(t)){const n=t[t.length-1];return typeof n=="function"?"":n}return t},lD={t:oD,ready:!1},cD=()=>()=>{},dt=(t,e={})=>{var _,M,R;const{i18n:n}=e,{i18n:s,defaultNS:a}=x.useContext(nD)||{},r=n||s||eD();r&&!r.reportNamespaces&&(r.reportNamespaces=new sD),r||$b(r,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const i=x.useMemo(()=>{var z;return{...JM(),...(z=r==null?void 0:r.options)==null?void 0:z.react,...e}},[r,e]),{useSuspense:c,keyPrefix:d}=i,f=t||a||((_=r==null?void 0:r.options)==null?void 0:_.defaultNS),h=No(f)?[f]:f||["translation"],m=x.useMemo(()=>h,h);(R=(M=r==null?void 0:r.reportNamespaces)==null?void 0:M.addUsedNamespaces)==null||R.call(M,m);const b=x.useRef(0),y=x.useCallback(z=>{if(!r)return cD;const{bindI18n:$,bindI18nStore:W}=i,L=()=>{b.current+=1,z()};return $&&r.on($,L),W&&r.store.on(W,L),()=>{$&&$.split(" ").forEach(F=>r.off(F,L)),W&&W.split(" ").forEach(F=>r.store.off(F,L))}},[r,i]),w=x.useRef(),C=x.useCallback(()=>{if(!r)return lD;const z=!!(r.isInitialized||r.initializedStoreOnce)&&m.every(V=>qM(V,r,i)),$=e.lng||r.language,W=b.current,L=w.current;if(L&&L.ready===z&&L.lng===$&&L.keyPrefix===d&&L.revision===W)return L;const H={t:r.getFixedT($,i.nsMode==="fallback"?m:m[0],d),ready:z,lng:$,keyPrefix:d,revision:W};return w.current=H,H},[r,m,d,i,e.lng]),[N,k]=x.useState(0),{t:j,ready:S}=iD.useSyncExternalStore(y,C,C);x.useEffect(()=>{if(r&&!S&&!c){const z=()=>k($=>$+1);e.lng?Sk(r,e.lng,m,z):Ub(r,m,z)}},[r,e.lng,m,S,c,N]);const T=r||{},D=x.useRef(null),E=x.useRef(),I=z=>{const $=Object.getOwnPropertyDescriptors(z);$.__original&&delete $.__original;const W=Object.create(Object.getPrototypeOf(z),$);if(!Object.prototype.hasOwnProperty.call(W,"__original"))try{Object.defineProperty(W,"__original",{value:z,writable:!1,enumerable:!1,configurable:!1})}catch{}return W},O=x.useMemo(()=>{const z=T,$=z==null?void 0:z.language;let W=z;z&&(D.current&&D.current.__original===z?E.current!==$?(W=I(z),D.current=W,E.current=$):W=D.current:(W=I(z),D.current=W,E.current=$));const L=!S&&!c?(...H)=>($b(r,"USE_T_BEFORE_READY","useTranslation: t was called before ready. When using useSuspense: false, make sure to check the ready flag before using t."),j(...H)):j,F=[L,W,S];return F.t=L,F.i18n=W,F.ready=S,F},[j,T,S,T.resolvedLanguage,T.language,T.languages]);if(r&&c&&!S)throw new Promise(z=>{const $=()=>z();e.lng?Sk(r,e.lng,m,$):Ub(r,m,$)});return O};function Wb(t){"@babel/helpers - typeof";return Wb=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Wb(t)}function yj(){return typeof XMLHttpRequest=="function"||(typeof XMLHttpRequest>"u"?"undefined":Wb(XMLHttpRequest))==="object"}function uD(t){return!!t&&typeof t.then=="function"}function dD(t){return uD(t)?t:Promise.resolve(t)}var fD=/\{\{(.+?)\}\}/g;function jk(t,e){return t.replace(fD,function(n,s){var a=e[s.trim()];return a??n})}const pD="modulepreload",hD=function(t){return"/"+t},Nk={},vt=function(e,n,s){let a=Promise.resolve();if(n&&n.length>0){let i=function(f){return Promise.all(f.map(h=>Promise.resolve(h).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));a=i(n.map(f=>{if(f=hD(f),f in Nk)return;Nk[f]=!0;const h=f.endsWith(".css"),m=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${m}`))return;const b=document.createElement("link");if(b.rel=h?"stylesheet":pD,h||(b.as="script"),b.crossOrigin="",b.href=f,d&&b.setAttribute("nonce",d),document.head.appendChild(b),h)return new Promise((y,w)=>{b.addEventListener("load",y),b.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${f}`)))})}))}function r(i){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=i,window.dispatchEvent(c),!c.defaultPrevented)throw i}return a.then(i=>{for(const c of i||[])c.status==="rejected"&&r(c.reason);return e().catch(r)})};function Tk(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),n.push.apply(n,s)}return n}function _k(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Tk(Object(n),!0).forEach(function(s){mD(t,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Tk(Object(n)).forEach(function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(n,s))})}return t}function mD(t,e,n){return(e=gD(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function gD(t){var e=bD(t,"string");return To(e)=="symbol"?e:e+""}function bD(t,e){if(To(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var s=n.call(t,e);if(To(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function To(t){"@babel/helpers - typeof";return To=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},To(t)}var Di=typeof fetch=="function"?fetch:void 0;typeof global<"u"&&global.fetch?Di=global.fetch:typeof window<"u"&&window.fetch&&(Di=window.fetch);var zu;yj()&&(typeof global<"u"&&global.XMLHttpRequest?zu=global.XMLHttpRequest:typeof window<"u"&&window.XMLHttpRequest&&(zu=window.XMLHttpRequest));var mp;typeof ActiveXObject=="function"&&(typeof global<"u"&&global.ActiveXObject?mp=global.ActiveXObject:typeof window<"u"&&window.ActiveXObject&&(mp=window.ActiveXObject));typeof Di!="function"&&(Di=void 0);if(!Di&&!zu&&!mp)try{vt(()=>import("./browser-ponyfill-DZOWXZ4K.js").then(t=>t.b),__vite__mapDeps([0,1])).then(function(t){Di=t.default}).catch(function(){})}catch{}var qb=function(e,n){if(n&&To(n)==="object"){var s="";for(var a in n)s+="&"+encodeURIComponent(a)+"="+encodeURIComponent(n[a]);if(!s)return e;e=e+(e.indexOf("?")!==-1?"&":"?")+s.slice(1)}return e},Ek=function(e,n,s,a){var r=function(d){if(!d.ok)return s(d.statusText||"Error",{status:d.status});d.text().then(function(f){s(null,{status:d.status,data:f})}).catch(s)};if(a){var i=a(e,n);if(i instanceof Promise){i.then(r).catch(s);return}}typeof fetch=="function"?fetch(e,n).then(r).catch(s):Di(e,n).then(r).catch(s)},Mk=!1,xD=function(e,n,s,a){e.queryStringParams&&(n=qb(n,e.queryStringParams));var r=_k({},typeof e.customHeaders=="function"?e.customHeaders():e.customHeaders);typeof window>"u"&&typeof global<"u"&&typeof global.process<"u"&&global.process.versions&&global.process.versions.node&&(r["User-Agent"]="i18next-http-backend (node/".concat(global.process.version,"; ").concat(global.process.platform," ").concat(global.process.arch,")")),s&&(r["Content-Type"]="application/json");var i=typeof e.requestOptions=="function"?e.requestOptions(s):e.requestOptions,c=_k({method:s?"POST":"GET",body:s?e.stringify(s):void 0,headers:r},Mk?{}:i),d=typeof e.alternateFetch=="function"&&e.alternateFetch.length>=1?e.alternateFetch:void 0;try{Ek(n,c,a,d)}catch(f){if(!i||Object.keys(i).length===0||!f.message||f.message.indexOf("not implemented")<0)return a(f);try{Object.keys(i).forEach(function(h){delete c[h]}),Ek(n,c,a,d),Mk=!0}catch(h){a(h)}}},yD=function(e,n,s,a){s&&To(s)==="object"&&(s=qb("",s).slice(1)),e.queryStringParams&&(n=qb(n,e.queryStringParams));try{var r=zu?new zu:new mp("MSXML2.XMLHTTP.3.0");r.open(s?"POST":"GET",n,1),e.crossDomain||r.setRequestHeader("X-Requested-With","XMLHttpRequest"),r.withCredentials=!!e.withCredentials,s&&r.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),r.overrideMimeType&&r.overrideMimeType("application/json");var i=e.customHeaders;if(i=typeof i=="function"?i():i,i)for(var c in i)r.setRequestHeader(c,i[c]);r.onreadystatechange=function(){r.readyState>3&&a(r.status>=400?r.statusText:null,{status:r.status,data:r.responseText})},r.send(s)}catch(d){console&&console.log(d)}},vD=function(e,n,s,a){if(typeof s=="function"&&(a=s,s=void 0),a=a||function(){},Di&&n.indexOf("file:")!==0)return xD(e,n,s,a);if(yj()||typeof ActiveXObject=="function")return yD(e,n,s,a);a(new Error("No fetch and no xhr implementation found!"))};function Vl(t){"@babel/helpers - typeof";return Vl=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Vl(t)}function Dk(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),n.push.apply(n,s)}return n}function Tg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Dk(Object(n),!0).forEach(function(s){vj(t,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Dk(Object(n)).forEach(function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(n,s))})}return t}function wD(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function kD(t,e){for(var n=0;n<e.length;n++){var s=e[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,wj(s.key),s)}}function SD(t,e,n){return e&&kD(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function vj(t,e,n){return(e=wj(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function wj(t){var e=CD(t,"string");return Vl(e)=="symbol"?e:e+""}function CD(t,e){if(Vl(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var s=n.call(t,e);if(Vl(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}var AD=function(){return{loadPath:"/locales/{{lng}}/{{ns}}.json",addPath:"/locales/add/{{lng}}/{{ns}}",parse:function(n){return JSON.parse(n)},stringify:JSON.stringify,parsePayload:function(n,s,a){return vj({},s,a||"")},parseLoadPayload:function(n,s){},request:vD,reloadInterval:typeof window<"u"?!1:3600*1e3,customHeaders:{},queryStringParams:{},crossDomain:!1,withCredentials:!1,overrideMimeType:!1,requestOptions:{mode:"cors",credentials:"same-origin",cache:"default"}}},kj=(function(){function t(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};wD(this,t),this.services=e,this.options=n,this.allOptions=s,this.type="backend",this.init(e,n,s)}return SD(t,[{key:"init",value:function(n){var s=this,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this.services=n,this.options=Tg(Tg(Tg({},AD()),this.options||{}),a),this.allOptions=r,this.services&&this.options.reloadInterval){var i=setInterval(function(){return s.reload()},this.options.reloadInterval);Vl(i)==="object"&&typeof i.unref=="function"&&i.unref()}}},{key:"readMulti",value:function(n,s,a){this._readAny(n,n,s,s,a)}},{key:"read",value:function(n,s,a){this._readAny([n],n,[s],s,a)}},{key:"_readAny",value:function(n,s,a,r,i){var c=this,d=this.options.loadPath;typeof this.options.loadPath=="function"&&(d=this.options.loadPath(n,a)),d=dD(d),d.then(function(f){if(!f)return i(null,{});var h=jk(f,{lng:n.join("+"),ns:a.join("+")});c.loadUrl(h,i,s,r)})}},{key:"loadUrl",value:function(n,s,a,r){var i=this,c=typeof a=="string"?[a]:a,d=typeof r=="string"?[r]:r,f=this.options.parseLoadPayload(c,d);this.options.request(this.options,n,f,function(h,m){if(m&&(m.status>=500&&m.status<600||!m.status))return s("failed loading "+n+"; status code: "+m.status,!0);if(m&&m.status>=400&&m.status<500)return s("failed loading "+n+"; status code: "+m.status,!1);if(!m&&h&&h.message){var b=h.message.toLowerCase(),y=["failed","fetch","network","load"].find(function(N){return b.indexOf(N)>-1});if(y)return s("failed loading "+n+": "+h.message,!0)}if(h)return s(h,!1);var w,C;try{typeof m.data=="string"?w=i.options.parse(m.data,a,r):w=m.data}catch{C="failed parsing "+n+" to json"}if(C)return s(C,!1);s(null,w)})}},{key:"create",value:function(n,s,a,r,i){var c=this;if(this.options.addPath){typeof n=="string"&&(n=[n]);var d=this.options.parsePayload(s,a,r),f=0,h=[],m=[];n.forEach(function(b){var y=c.options.addPath;typeof c.options.addPath=="function"&&(y=c.options.addPath(b,s));var w=jk(y,{lng:b,ns:s});c.options.request(c.options,w,d,function(C,N){f+=1,h.push(C),m.push(N),f===n.length&&typeof i=="function"&&i(h,m)})})}}},{key:"reload",value:function(){var n=this,s=this.services,a=s.backendConnector,r=s.languageUtils,i=s.logger,c=a.language;if(!(c&&c.toLowerCase()==="cimode")){var d=[],f=function(m){var b=r.toResolveHierarchy(m);b.forEach(function(y){d.indexOf(y)<0&&d.push(y)})};f(c),this.allOptions.preload&&this.allOptions.preload.forEach(function(h){return f(h)}),d.forEach(function(h){n.allOptions.ns.forEach(function(m){a.read(h,m,"read",null,null,function(b,y){b&&i.warn("loading namespace ".concat(m," for language ").concat(h," failed"),b),!b&&y&&i.log("loaded namespace ".concat(m," for language ").concat(h),y),a.loaded("".concat(h,"|").concat(m),b,y)})})})}}}])})();kj.type="backend";const{slice:jD,forEach:ND}=[];function TD(t){return ND.call(jD.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function _D(t){return typeof t!="string"?!1:[/<\s*script.*?>/i,/<\s*\/\s*script\s*>/i,/<\s*img.*?on\w+\s*=/i,/<\s*\w+\s*on\w+\s*=.*?>/i,/javascript\s*:/i,/vbscript\s*:/i,/expression\s*\(/i,/eval\s*\(/i,/alert\s*\(/i,/document\.cookie/i,/document\.write\s*\(/i,/window\.location/i,/innerHTML/i].some(n=>n.test(t))}const Rk=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,ED=function(t,e){const s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:"/"},a=encodeURIComponent(e);let r=`${t}=${a}`;if(s.maxAge>0){const i=s.maxAge-0;if(Number.isNaN(i))throw new Error("maxAge should be a Number");r+=`; Max-Age=${Math.floor(i)}`}if(s.domain){if(!Rk.test(s.domain))throw new TypeError("option domain is invalid");r+=`; Domain=${s.domain}`}if(s.path){if(!Rk.test(s.path))throw new TypeError("option path is invalid");r+=`; Path=${s.path}`}if(s.expires){if(typeof s.expires.toUTCString!="function")throw new TypeError("option expires is invalid");r+=`; Expires=${s.expires.toUTCString()}`}if(s.httpOnly&&(r+="; HttpOnly"),s.secure&&(r+="; Secure"),s.sameSite)switch(typeof s.sameSite=="string"?s.sameSite.toLowerCase():s.sameSite){case!0:r+="; SameSite=Strict";break;case"lax":r+="; SameSite=Lax";break;case"strict":r+="; SameSite=Strict";break;case"none":r+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return s.partitioned&&(r+="; Partitioned"),r},Ok={create(t,e,n,s){let a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};n&&(a.expires=new Date,a.expires.setTime(a.expires.getTime()+n*60*1e3)),s&&(a.domain=s),document.cookie=ED(t,e,a)},read(t){const e=`${t}=`,n=document.cookie.split(";");for(let s=0;s<n.length;s++){let a=n[s];for(;a.charAt(0)===" ";)a=a.substring(1,a.length);if(a.indexOf(e)===0)return a.substring(e.length,a.length)}return null},remove(t,e){this.create(t,"",-1,e)}};var MD={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return Ok.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:s,cookieDomain:a,cookieOptions:r}=e;n&&typeof document<"u"&&Ok.create(n,t,s,a,r)}},DD={name:"querystring",lookup(t){var s;let{lookupQuerystring:e}=t,n;if(typeof window<"u"){let{search:a}=window.location;!window.location.search&&((s=window.location.hash)==null?void 0:s.indexOf("?"))>-1&&(a=window.location.hash.substring(window.location.hash.indexOf("?")));const i=a.substring(1).split("&");for(let c=0;c<i.length;c++){const d=i[c].indexOf("=");d>0&&i[c].substring(0,d)===e&&(n=i[c].substring(d+1))}}return n}},RD={name:"hash",lookup(t){var a;let{lookupHash:e,lookupFromHashIndex:n}=t,s;if(typeof window<"u"){const{hash:r}=window.location;if(r&&r.length>2){const i=r.substring(1);if(e){const c=i.split("&");for(let d=0;d<c.length;d++){const f=c[d].indexOf("=");f>0&&c[d].substring(0,f)===e&&(s=c[d].substring(f+1))}}if(s)return s;if(!s&&n>-1){const c=r.match(/\/([a-zA-Z-]*)/g);return Array.isArray(c)?(a=c[typeof n=="number"?n:0])==null?void 0:a.replace("/",""):void 0}}}return s}};let Nl=null;const Lk=()=>{if(Nl!==null)return Nl;try{if(Nl=typeof window<"u"&&window.localStorage!==null,!Nl)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Nl=!1}return Nl};var OD={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&Lk())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&Lk()&&window.localStorage.setItem(n,t)}};let Tl=null;const Ik=()=>{if(Tl!==null)return Tl;try{if(Tl=typeof window<"u"&&window.sessionStorage!==null,!Tl)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Tl=!1}return Tl};var LD={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&Ik())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&Ik()&&window.sessionStorage.setItem(n,t)}},ID={name:"navigator",lookup(t){const e=[];if(typeof navigator<"u"){const{languages:n,userLanguage:s,language:a}=navigator;if(n)for(let r=0;r<n.length;r++)e.push(n[r]);s&&e.push(s),a&&e.push(a)}return e.length>0?e:void 0}},PD={name:"htmlTag",lookup(t){let{htmlTag:e}=t,n;const s=e||(typeof document<"u"?document.documentElement:null);return s&&typeof s.getAttribute=="function"&&(n=s.getAttribute("lang")),n}},BD={name:"path",lookup(t){var a;let{lookupFromPathIndex:e}=t;if(typeof window>"u")return;const n=window.location.pathname.match(/\/([a-zA-Z-]*)/g);return Array.isArray(n)?(a=n[typeof e=="number"?e:0])==null?void 0:a.replace("/",""):void 0}},FD={name:"subdomain",lookup(t){var a,r;let{lookupFromSubdomainIndex:e}=t;const n=typeof e=="number"?e+1:1,s=typeof window<"u"&&((r=(a=window.location)==null?void 0:a.hostname)==null?void 0:r.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i));if(s)return s[n]}};let Sj=!1;try{document.cookie,Sj=!0}catch{}const Cj=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];Sj||Cj.splice(1,1);const zD=()=>({order:Cj,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class Aj{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.type="languageDetector",this.detectors={},this.init(e,n)}init(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{languageUtils:{}},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=e,this.options=TD(n,this.options||{},zD()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=a=>a.replace("-","_")),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=s,this.addDetector(MD),this.addDetector(DD),this.addDetector(OD),this.addDetector(LD),this.addDetector(ID),this.addDetector(PD),this.addDetector(BD),this.addDetector(FD),this.addDetector(RD)}addDetector(e){return this.detectors[e.name]=e,this}detect(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.options.order,n=[];return e.forEach(s=>{if(this.detectors[s]){let a=this.detectors[s].lookup(this.options);a&&typeof a=="string"&&(a=[a]),a&&(n=n.concat(a))}}),n=n.filter(s=>s!=null&&!_D(s)).map(s=>this.options.convertDetectedLanguage(s)),this.services&&this.services.languageUtils&&this.services.languageUtils.getBestMatchFromCodes?n:n.length>0?n[0]:null}cacheUserLanguage(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.options.caches;n&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(e)>-1||n.forEach(s=>{this.detectors[s]&&this.detectors[s].cacheUserLanguage(e,this.options)}))}}Aj.type="languageDetector";const gp={idle:"#4aff9e",working:"#4a9eff",waiting:"#ff9e4a",waiting_permission:"#ffcc00",error:"#ff4a4a",offline:"#888888",orphaned:"#ff9e4a",default:"#888888"},Vb={running:"#4aff9e",stopped:"#888888",error:"#ff4a4a",unknown:"#ffaa00",starting:"#4a9eff",stopping:"#ffaa00"},$D={on_track:"#4aff9e",stalled:"#ff9e4a",blocked:"#ff4a4a",completed:"#4a9eff",idle:"#888888"},Cq=["#4a9eff","#4aff9e","#ff9e4a","#ff4a9e","#9e4aff","#ff4a4a","#4affff","#ffff4a","#4ad7ff","#00e6a8","#ff6b4a","#ff66cc","#b84aff","#ff4a7a","#00d9ff","#e6ff4a","#1a3a6e","#1a5e3a","#6e3a1a","#6e1a4a","#4a1a6e","#6e1a1a","#1a5e5e","#5e5e1a","#1a4a6e","#145a47","#6e2c1a","#6e1a5e","#3b1a6e","#6e1a33","#14566e","#4f5e1a"],Af={recent:"#50fa7b",short:"#f1fa8c",medium:"#ffb86c",long:"#ff5555"};function _x(t){const n=Math.floor((Date.now()-t)/1e3)/60;return n<1?Af.recent:n<5?Af.short:n<30?Af.medium:Af.long}function Ex(t){return gp[t]??gp.default}let Zf=null;function jj(){if(!Zf)try{Zf=globalThis.__i18n}catch{}return Zf}function UD(t){Zf=t}function HD(t){return t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?(t/1e3).toFixed(1)+"K":t.toString()}function WD(t){return t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?(t/1e3).toFixed(1)+"K":t.toString()}function qD(t){var a;const e=jj(),n=(a=e==null?void 0:e.t)==null?void 0:a.bind(e),s=Math.floor((Date.now()-t)/1e3);return s<60?n?n("common:time.seconds",{count:s}):`${s}s`:s<3600?n?n("common:time.minutes",{count:Math.floor(s/60)}):`${Math.floor(s/60)}m`:s<86400?n?n("common:time.hours",{count:Math.floor(s/3600)}):`${Math.floor(s/3600)}h`:n?n("common:time.days",{count:Math.floor(s/86400)}):`${Math.floor(s/86400)}d`}function Mx(t){var f;const e=jj(),n=(f=e==null?void 0:e.t)==null?void 0:f.bind(e),s=Math.floor((Date.now()-t)/1e3);if(s<5)return n?n("common:time.justNow"):"just now";if(s<60)return n?n("common:time.secondsAgo",{count:s}):`${s}s ago`;const a=Math.floor(s/60);if(a<60){const h=s%60;return h>0?n?n("common:time.minutesSecondsAgo",{minutes:a,seconds:h}):`${a}m ${h}s ago`:n?n("common:time.minutesAgo",{count:a}):`${a}m ago`}const r=Math.floor(a/60),i=a%60;if(r<24)return i>0?n?n("common:time.hoursMinutesAgo",{hours:r,minutes:i}):`${r}h ${i}m ago`:n?n("common:time.hoursAgo",{count:r}):`${r}h ago`;const c=Math.floor(r/24),d=r%24;return d>0?n?n("common:time.daysHoursAgo",{days:c,hours:d}):`${c}d ${d}h ago`:n?n("common:time.daysAgo",{count:c}):`${c}d ago`}function Tu(t,e){return t?e?t.replace(/\s*\(?\s*~?\$[\d,.]+\s*\)?/g,"").replace(/\s*cost[:\s]+~?\$[\d,.]+/gi,"").replace(/\s*price[:\s]+~?\$[\d,.]+/gi,"").replace(/\s*\(~?\$[\d,.]+\s*(?:USD|cost|spent)?\)/gi,"").replace(/\s*-\s*~?\$[\d,.]+\s*$/g,"").replace(/[^\S\n]+/g," ").trim():t:""}On.use(kj).use(Aj).use(tD).init({fallbackLng:"en",ns:["common","tools","config","errors","notifications","dashboard","terminal"],defaultNS:"common",backend:{loadPath:"/locales/{{lng}}/{{ns}}.json"},detection:{order:["localStorage","navigator"],lookupLocalStorage:"tide-commander-language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!0}}).then(()=>{UD(On)});const pt={CONFIG:"tide-commander-config",SHOW_FPS:"tide-show-fps",SETTINGS:"tide-settings",SHORTCUTS:"tide-shortcuts",MOUSE_CONTROLS:"tide-mouse-controls",BACKEND_URL:"tide-backend-url",AUTH_TOKEN:"tide-auth-token",SCENE_VIEW_MODE:"tide-scene-view-mode",CAMERA_STATE:"tide-camera-state",CAMERA_STATE_2D:"tide-camera-state-2d",VIEW_MODE:"guake-view-mode",ADVANCED_VIEW:"guake-advanced-view",TERMINAL_HEIGHT:"guake-terminal-height",TERMINAL_FULLSCREEN:"guake-terminal-fullscreen",INPUT_TEXT_PREFIX:"guake-input-",PASTED_TEXTS_PREFIX:"guake-pasted-",COMMANDER_TAB:"commander-active-tab",COMMANDER_FILTERS:"commander-filters",LAST_CWD:"tide-last-cwd",GLOBAL_SUPERVISOR_COLLAPSED:"tide-global-supervisor-collapsed",TOOLS_COLLAPSED:"tide-tool-history-collapsed",FILES_COLLAPSED:"tide-file-history-collapsed",MOBILE_VIEW:"tide-mobile-view",TREE_PANEL_WIDTH:"tide-tree-panel-width",MOBILE_TREE_PANEL_HEIGHT:"tide-mobile-tree-panel-height",AGENT_ORDER:"tide-agent-order",AOP_CONFIG:"tide-aop-config",AOP_OPEN:"tide-aop-open",MOBILE_OVERVIEW_HEIGHT:"tide-mobile-overview-height",GIT_PANEL_OPEN:"guake-git-panel-open",GIT_PANEL_MODE:"guake-git-panel-mode",GIT_PANEL_VIEW_MODE:"guake-git-view-mode",GIT_PANEL_FOLDER_IDX:"guake-git-folder-idx",BUILDINGS_PANEL_OPEN:"guake-buildings-panel-open",WORKFLOW_PANEL_OPEN:"guake-workflow-panel-open",SIDE_PANEL_WIDTH:"guake-side-panel-width",UNSEEN_AGENTS:"tide-unseen-agents",PENDING_MESSAGES:"tide-pending-messages"},Yb="tide-backend-url-change";function Na(t,e){try{const n=localStorage.getItem(t);return n===null?e:JSON.parse(n)}catch{return e}}function Fa(t,e=""){try{return localStorage.getItem(t)??e}catch{return e}}function Ni(t,e=!1){try{const n=localStorage.getItem(t);return n===null?e:n==="true"}catch{return e}}function Dx(t,e){try{const n=localStorage.getItem(t);if(n===null)return e;const s=Number(n);return isNaN(s)?e:s}catch{return e}}function La(t,e){try{localStorage.setItem(t,JSON.stringify(e))}catch(n){console.error(`Failed to save to localStorage: ${t}`,n)}}function Wr(t,e){try{localStorage.setItem(t,e)}catch(n){console.error(`Failed to save to localStorage: ${t}`,n)}}function Ti(t,e){try{localStorage.setItem(t,String(e))}catch(n){console.error(`Failed to save to localStorage: ${t}`,n)}}function Rx(t,e){try{localStorage.setItem(t,String(e))}catch(n){console.error(`Failed to save to localStorage: ${t}`,n)}}function Pk(t){try{localStorage.removeItem(t)}catch(e){console.error(`Failed to remove from localStorage: ${t}`,e)}}function Ea(){const t=Ox();return t?t.replace(/\/$/,""):`${window.location.protocol}//${window.location.host}`}function Ii(){return Fa(pt.AUTH_TOKEN,"")}function Ox(){return Fa(pt.BACKEND_URL,"")}function VD(t){const e=t.trim();Wr(pt.BACKEND_URL,e),typeof window<"u"&&window.dispatchEvent(new CustomEvent(Yb,{detail:e}))}function YD(t){if(typeof window>"u")return()=>{};const e=s=>{t(s.detail)},n=s=>{s.key===pt.BACKEND_URL&&t(s.newValue??"")};return window.addEventListener(Yb,e),window.addEventListener("storage",n),()=>{window.removeEventListener(Yb,e),window.removeEventListener("storage",n)}}function Rt(t){return`${Ea()}${t}`}async function Bt(t,e){const n=Ii(),s=new Headers(e==null?void 0:e.headers);return n&&s.set("X-Auth-Token",n),fetch(t,{...e,headers:s,cache:"no-store"})}function Gb(t){const e=Ii();if(!e)return t;try{const n=!t.startsWith("http://")&&!t.startsWith("https://"),s=n?"http://dummy":void 0,a=new URL(t,s);return a.searchParams.set("token",e),n?a.pathname+a.search:a.toString()}catch{const n=t.includes("?")?"&":"?";return`${t}${n}token=${encodeURIComponent(e)}`}}function cs(t=!1,e){const[n,s]=x.useState(t),[a,r]=x.useState(e),i=x.useCallback(f=>{f!==void 0&&r(f),s(!0)},[]),c=x.useCallback(()=>{s(!1)},[]),d=x.useCallback(()=>{s(f=>!f)},[]);return{isOpen:n,data:a,open:i,close:c,toggle:d,setData:r}}function GD(){const[t,e]=x.useState(null),n=x.useCallback(a=>{e(a)},[]),s=x.useCallback(()=>{e(null)},[]);return{isOpen:t!==null,id:t,open:n,close:s}}function KD(){const[t,e]=x.useState(!1),[n,s]=x.useState({x:0,y:0}),[a,r]=x.useState({x:0,z:0}),[i,c]=x.useState({type:"ground"}),d=x.useCallback((h,m,b)=>{s(h),r(m),c(b),e(!0)},[]),f=x.useCallback(()=>{e(!1)},[]);return{isOpen:t,screenPosition:n,worldPosition:a,target:i,open:d,close:f}}const ca=[],QD=new Set;function bp(){QD.forEach(t=>t())}function XD(t,e){const n=ca.findIndex(s=>s.id===t);return n!==-1&&ca.splice(n,1),ca.push({id:t,close:e}),bp(),()=>{const s=ca.findIndex(a=>a.id===t);s!==-1&&(ca.splice(s,1),bp())}}function ep(){return ca.length===0?!1:(ca.pop().close(),bp(),!0)}function JD(t){const e=ca.findIndex(n=>n.id===t);return e===-1?!1:e<ca.length-1}function ZD(...t){const e=new Set(t);for(;ca.length>0;){const n=ca[ca.length-1];if(e.has(n.id))break;ca.pop().close()}bp()}function Xt(t,e,n){const s=x.useRef(n);s.current=n,x.useEffect(()=>e?XD(t,()=>s.current()):void 0,[t,e])}const $u=5,_g={0:0,1:4,2:8,3:14,4:25,5:50};let _u=null,Bk=!1;async function eR(){if(Bk)return _u;Bk=!0;try{const t=await vt(()=>import("./index-BxbFh16W.js"),__vite__mapDeps([2,3,1,4]));_u={Haptics:t.Haptics,ImpactStyle:t.ImpactStyle}}catch{}return _u}eR();function xp(t){const e=Math.round(t),n=e<=0?0:e>=$u?$u:e;if(n!==0){if(_u){const{Haptics:s,ImpactStyle:a}=_u;if(n<=2&&typeof s.selectionChanged=="function"){s.selectionChanged().catch(()=>{navigator.vibrate&&navigator.vibrate(_g[n])});return}const i={3:"Light",4:"Medium",5:"Heavy"}[n];if(i&&a[i]){s.impact({style:a[i]}).catch(()=>{navigator.vibrate&&navigator.vibrate(_g[n])});return}}navigator.vibrate&&navigator.vibrate(_g[n])}}function Fk(t,e){const{threshold:n=80,maxVerticalMovement:s=50,enabled:a=!0,onSwipeLeft:r,onSwipeRight:i,onSwipeMove:c,onSwipeCancel:d,vibrationIntensity:f=1}=e,h=x.useRef({startX:0,startY:0,startTime:0,isTracking:!1,hasMovedEnough:!1}),m=x.useCallback(C=>{if(C.touches.length!==1)return;const N=C.touches[0];h.current={startX:N.clientX,startY:N.clientY,startTime:Date.now(),isTracking:!0,hasMovedEnough:!1}},[]),b=x.useCallback(C=>{if(!h.current.isTracking||C.touches.length!==1)return;const N=C.touches[0],k=N.clientX-h.current.startX;if(Math.abs(N.clientY-h.current.startY)>s){h.current.isTracking=!1,h.current.hasMovedEnough&&(d==null||d());return}const T=window.innerWidth*.4,D=Math.max(-1,Math.min(1,k/T));Math.abs(k)>=12&&(h.current.hasMovedEnough=!0,c==null||c(D))},[s,c,d]),y=x.useCallback(C=>{const N=h.current.isTracking,k=h.current.hasMovedEnough;if(!N)return;const j=C.changedTouches[0],S=j.clientX-h.current.startX,T=Math.abs(j.clientY-h.current.startY),D=Date.now()-h.current.startTime;h.current.isTracking=!1,h.current.hasMovedEnough=!1,Math.abs(S)>=n&&T<=s&&D<500?(xp(f),S>0?i==null||i():r==null||r()):k&&(d==null||d())},[n,s,f,r,i,d]),w=x.useCallback(()=>{const C=h.current.hasMovedEnough;h.current.isTracking=!1,h.current.hasMovedEnough=!1,C&&(d==null||d())},[d]);x.useEffect(()=>{const C=t.current;if(!(!C||!a||!(window.innerWidth<=768&&"ontouchstart"in window)))return C.addEventListener("touchstart",m,{passive:!0}),C.addEventListener("touchmove",b,{passive:!0}),C.addEventListener("touchend",y,{passive:!0}),C.addEventListener("touchcancel",w,{passive:!0}),()=>{C.removeEventListener("touchstart",m),C.removeEventListener("touchmove",b),C.removeEventListener("touchend",y),C.removeEventListener("touchcancel",w)}},[t,a,m,b,y,w])}const zk=8,tR=.93,$k=.4;function nR(t){const{gestureRef:e,agentListRef:n,enabled:s,onSelect:a}=t,[r,i]=x.useState(!1),[c,d]=x.useState(null),f=x.useRef(!1),h=x.useRef(null),m=x.useRef(a);m.current=a;const b=x.useCallback(()=>{if(f.current)return;f.current=!0,i(!0);const N=n.current;if(N){const k=Math.round(N.clientHeight/2);N.style.paddingTop=`${k}px`,N.style.paddingBottom=`${k}px`}},[n]),y=x.useCallback(()=>{f.current=!1,h.current=null,i(!1),d(null);const N=n.current;N&&(N.style.paddingTop="",N.style.paddingBottom="")},[n]),w=x.useCallback(N=>{const k=n.current;if(!k)return;k.scrollTop+=N;const j=k.getBoundingClientRect(),S=j.top+j.height/2,T=j.left+j.width/2,D=document.elementFromPoint(T,S);let E=null;if(D){const I=D.closest("[data-agent-id]");I&&k.contains(I)&&(E=I.dataset.agentId)}if(E!==h.current&&(h.current=E,d(E),E)){const I=U.getState().settings.vibrationIntensity??1;xp(I)}},[n]),C=x.useCallback(()=>{const N=h.current;if(N){const k=U.getState().settings.vibrationIntensity??1,j=k<=0?0:Math.min(k+1,$u);xp(j),m.current(N)}y()},[y]);return x.useEffect(()=>{const N=e.current;if(!N||!s)return;const k=N.style.touchAction;N.style.touchAction="none";let j=!1,S=!1,T=0,D=0,E=0,I=0,O=0,_=0,M=0,R=0;const z=()=>{M&&(cancelAnimationFrame(M),M=0)},$=()=>{if(Math.abs(_)<$k){_=0;return}N.scrollTop+=_,_*=tR,M=requestAnimationFrame($)},W=V=>{if(z(),V.touches.length>=2){V.preventDefault(),j=!1,S=!1,R=(V.touches[0].clientY+V.touches[1].clientY)/2,b(),w(0);return}j=!0,S=!1,T=V.touches[0].clientX,D=V.touches[0].clientY,E=N.scrollTop,I=D,O=performance.now(),_=0},L=V=>{if(V.touches.length>=2){if(V.preventDefault(),(S||j)&&(S=!1,j=!1),!f.current){R=(V.touches[0].clientY+V.touches[1].clientY)/2,b(),w(0);return}const K=(V.touches[0].clientY+V.touches[1].clientY)/2,se=R-K;R=K,w(se);return}if(f.current&&V.touches.length===1){V.preventDefault();const K=V.touches[0].clientY,se=R-K;R=K,w(se);return}if(!j&&!S)return;const G=V.touches[0].clientX,B=V.touches[0].clientY;if(j&&!S){const K=Math.abs(G-T),se=Math.abs(B-D);if(K<zk&&se<zk)return;if(se>=K)S=!0,j=!1,V.preventDefault();else{j=!1;return}}if(S){V.preventDefault();const K=performance.now(),se=K-O;N.scrollTop=E+(D-B),se>0&&(_=(I-B)/se*16),I=B,O=K}},F=V=>{if(f.current&&V.touches.length===0){C();return}f.current||(S||j)&&V.touches.length===0&&(S&&Math.abs(_)>$k&&(M=requestAnimationFrame($)),S=!1,j=!1)},H=()=>{S=!1,j=!1,z(),f.current&&y()};return N.addEventListener("touchstart",W,{passive:!1}),N.addEventListener("touchmove",L,{passive:!1}),N.addEventListener("touchend",F,{passive:!0}),N.addEventListener("touchcancel",H,{passive:!0}),()=>{N.removeEventListener("touchstart",W),N.removeEventListener("touchmove",L),N.removeEventListener("touchend",F),N.removeEventListener("touchcancel",H),N.style.touchAction=k,z();const V=n.current;V&&(V.style.paddingTop="",V.style.paddingBottom="")}},[e,n,s,b,y,w,C]),{isActive:r,hoveredAgentId:c}}const sR={width:400,height:300,copyStyleSheets:!0,keepOnTop:"focus"};function aR(){return"documentPictureInPicture"in window}function rR(t,e){for(const r of t.styleSheets)try{if(r.cssRules){const i=e.createElement("style");for(const c of r.cssRules)i.appendChild(e.createTextNode(c.cssText));e.head.appendChild(i)}}catch{if(r.href){const i=e.createElement("link");i.rel="stylesheet",i.href=r.href,e.head.appendChild(i)}}const n=t.documentElement.style.cssText;n&&(e.documentElement.style.cssText=n);const s=getComputedStyle(t.documentElement),a=[];for(let r=0;r<s.length;r++){const i=s[r];i.startsWith("--")&&a.push(`${i}: ${s.getPropertyValue(i)}`)}if(a.length>0){const r=e.createElement("style");r.textContent=`:root { ${a.join("; ")} }`,e.head.appendChild(r)}}function iR(){const[t,e]=x.useState(!1),[n,s]=x.useState(null),[a,r]=x.useState(null),i=x.useRef(null),c=aR(),d=x.useCallback(()=>{if(i.current){const m=i.current.__cleanupFns;m&&m.forEach(b=>b()),i.current.close(),i.current=null}s(null),r(null),e(!1)},[]),f=x.useCallback(async m=>{if(!c)return console.warn("Document Picture-in-Picture is not supported in this browser"),!1;i.current&&d();const b={...sR,...m};try{const w=await window.documentPictureInPicture.requestWindow({width:b.width,height:b.height,disallowReturnToOpener:!0});i.current=w,b.copyStyleSheets&&rR(document,w.document);const C=w.document.createElement("div");C.id="pip-root",C.style.width="100%",C.style.height="100%",w.document.body.appendChild(C),w.document.body.style.margin="0",w.document.body.style.padding="0",w.document.body.style.overflow="hidden",w.addEventListener("pagehide",()=>{i.current=null,s(null),r(null),e(!1)});const N=[];if(b.keepOnTop&&b.keepOnTop!=="none"){const k=b.keepOnTop==="raise",j=()=>{i.current&&!i.current.closed&&setTimeout(()=>{i.current&&!i.current.closed&&(i.current.focus(),k&&setTimeout(()=>window.focus(),10))},50)},S=()=>{document.visibilityState==="visible"&&i.current&&!i.current.closed&&setTimeout(()=>{i.current&&!i.current.closed&&(i.current.focus(),k&&setTimeout(()=>window.focus(),10))},100)};window.addEventListener("focus",j),document.addEventListener("visibilitychange",S),N.push(()=>window.removeEventListener("focus",j),()=>document.removeEventListener("visibilitychange",S))}return w.__cleanupFns=N,s(w),r(C),e(!0),!0}catch(y){return console.error("Failed to open Picture-in-Picture window:",y),!1}},[c,d]),h=x.useCallback(async m=>{t?d():await f(m)},[t,f,d]);return x.useEffect(()=>()=>{i.current&&i.current.close()},[]),x.useMemo(()=>({isOpen:t,pipWindow:n,pipContainer:a,isSupported:c,open:f,close:d,toggle:h}),[t,n,a,c,f,d,h])}function tu(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}class oR{constructor(){Xe(this,"messages",new Map);Xe(this,"logs",[]);Xe(this,"maxMessagesPerAgent",200);Xe(this,"maxLogs",500);Xe(this,"enabled",!0);Xe(this,"listeners",new Set);Xe(this,"logListeners",new Set)}setEnabled(e){this.enabled=e,this.notifyListeners("all")}isEnabled(){return this.enabled}captureSent(e,n){try{const s=JSON.parse(n);console.log(`[AgentDebugger] SENT - agent: ${e.slice(0,4)}, type: ${s.type}, size: ${n.length}B`),this.addMessage(e,{id:tu(),agentId:e,direction:"sent",type:s.type||"unknown",payload:s.payload||s,timestamp:Date.now(),size:n.length,raw:n})}catch(s){console.error("[AgentDebugger] Failed to parse SENT message:",String(s).slice(0,80)),this.addMessage(e,{id:tu(),agentId:e,direction:"sent",type:"parse_error",payload:{error:String(s)},timestamp:Date.now(),size:n.length,raw:n})}}captureReceived(e,n){try{const s=JSON.parse(n);console.log(`[AgentDebugger] RECEIVED - agent: ${e.slice(0,4)}, type: ${s.type}, size: ${n.length}B`),this.addMessage(e,{id:tu(),agentId:e,direction:"received",type:s.type||"unknown",payload:s.payload||s,timestamp:Date.now(),size:n.length,raw:n})}catch(s){console.error("[AgentDebugger] Failed to parse RECEIVED message:",String(s).slice(0,80)),this.addMessage(e,{id:tu(),agentId:e,direction:"received",type:"parse_error",payload:{error:String(s)},timestamp:Date.now(),size:n.length,raw:n})}}addMessage(e,n){let s=this.messages.get(e);s||(s=[],this.messages.set(e,s)),s.push(n),console.log(`[AgentDebugger] Added message for ${e}, total: ${s.length}, type: ${n.type}, direction: ${n.direction}`),s.length>this.maxMessagesPerAgent&&s.shift(),this.notifyListeners(e)}getMessages(e){return this.messages.get(e)||[]}getStats(e){const n=this.getMessages(e),s=n.filter(i=>i.direction==="sent").length,a=n.filter(i=>i.direction==="received").length,r=[...new Set(n.map(i=>i.type))];return{total:n.length,sent:s,received:a,messageTypes:r}}clearMessages(e){this.messages.delete(e),this.notifyListeners(e)}clearAllMessages(){this.messages.clear(),this.notifyListeners("all")}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notifyListeners(e){this.listeners.forEach(n=>n(e))}getAgentIds(){return Array.from(this.messages.keys())}log(e,n,s,a){const r={id:tu(),level:e,message:n,data:s,timestamp:Date.now(),source:a};this.logs.push(r),this.logs.length>this.maxLogs&&this.logs.shift(),this.notifyLogListeners()}debug(e,n,s){this.log("debug",e,n,s)}info(e,n,s){this.log("info",e,n,s)}warn(e,n,s){this.log("warn",e,n,s)}error(e,n,s){this.log("error",e,n,s)}getLogs(){return this.logs}clearLogs(){this.logs=[],this.notifyLogListeners()}subscribeLogs(e){return this.logListeners.add(e),()=>this.logListeners.delete(e)}notifyLogListeners(){this.logListeners.forEach(e=>e())}}const vs=new oR,Uu={debug:(t,e,n)=>vs.debug(t,e,n),info:(t,e,n)=>vs.info(t,e,n),warn:(t,e,n)=>vs.warn(t,e,n),error:(t,e,n)=>vs.error(t,e,n)};/*! Capacitor: https://capacitorjs.com/ - MIT License */var Yl;(function(t){t.Unimplemented="UNIMPLEMENTED",t.Unavailable="UNAVAILABLE"})(Yl||(Yl={}));class Eg extends Error{constructor(e,n,s){super(e),this.message=e,this.code=n,this.data=s}}const lR=t=>{var e,n;return t!=null&&t.androidBridge?"android":!((n=(e=t==null?void 0:t.webkit)===null||e===void 0?void 0:e.messageHandlers)===null||n===void 0)&&n.bridge?"ios":"web"},cR=t=>{const e=t.CapacitorCustomPlatform||null,n=t.Capacitor||{},s=n.Plugins=n.Plugins||{},a=()=>e!==null?e.name:lR(t),r=()=>a()!=="web",i=m=>{const b=f.get(m);return!!(b!=null&&b.platforms.has(a())||c(m))},c=m=>{var b;return(b=n.PluginHeaders)===null||b===void 0?void 0:b.find(y=>y.name===m)},d=m=>t.console.error(m),f=new Map,h=(m,b={})=>{const y=f.get(m);if(y)return console.warn(`Capacitor plugin "${m}" already registered. Cannot register plugins twice.`),y.proxy;const w=a(),C=c(m);let N;const k=async()=>(!N&&w in b?N=typeof b[w]=="function"?N=await b[w]():N=b[w]:e!==null&&!N&&"web"in b&&(N=typeof b.web=="function"?N=await b.web():N=b.web),N),j=(O,_)=>{var M,R;if(C){const z=C==null?void 0:C.methods.find($=>_===$.name);if(z)return z.rtype==="promise"?$=>n.nativePromise(m,_.toString(),$):($,W)=>n.nativeCallback(m,_.toString(),$,W);if(O)return(M=O[_])===null||M===void 0?void 0:M.bind(O)}else{if(O)return(R=O[_])===null||R===void 0?void 0:R.bind(O);throw new Eg(`"${m}" plugin is not implemented on ${w}`,Yl.Unimplemented)}},S=O=>{let _;const M=(...R)=>{const z=k().then($=>{const W=j($,O);if(W){const L=W(...R);return _=L==null?void 0:L.remove,L}else throw new Eg(`"${m}.${O}()" is not implemented on ${w}`,Yl.Unimplemented)});return O==="addListener"&&(z.remove=async()=>_()),z};return M.toString=()=>`${O.toString()}() { [capacitor code] }`,Object.defineProperty(M,"name",{value:O,writable:!1,configurable:!1}),M},T=S("addListener"),D=S("removeListener"),E=(O,_)=>{const M=T({eventName:O},_),R=async()=>{const $=await M;D({eventName:O,callbackId:$},_)},z=new Promise($=>M.then(()=>$({remove:R})));return z.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await R()},z},I=new Proxy({},{get(O,_){switch(_){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return C?E:T;case"removeListener":return D;default:return S(_)}}});return s[m]=I,f.set(m,{name:m,proxy:I,platforms:new Set([...Object.keys(b),...C?[w]:[]])}),I};return n.convertFileSrc||(n.convertFileSrc=m=>m),n.getPlatform=a,n.handleError=d,n.isNativePlatform=r,n.isPluginAvailable=i,n.registerPlugin=h,n.Exception=Eg,n.DEBUG=!!n.DEBUG,n.isLoggingEnabled=!!n.isLoggingEnabled,n},uR=t=>t.Capacitor=cR(t),yp=uR(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),Ju=yp.registerPlugin;class Lx{constructor(){this.listeners={},this.retainedEventArguments={},this.windowListeners={}}addListener(e,n){let s=!1;this.listeners[e]||(this.listeners[e]=[],s=!0),this.listeners[e].push(n);const r=this.windowListeners[e];r&&!r.registered&&this.addWindowListener(r),s&&this.sendRetainedArgumentsForEvent(e);const i=async()=>this.removeListener(e,n);return Promise.resolve({remove:i})}async removeAllListeners(){this.listeners={};for(const e in this.windowListeners)this.removeWindowListener(this.windowListeners[e]);this.windowListeners={}}notifyListeners(e,n,s){const a=this.listeners[e];if(!a){if(s){let r=this.retainedEventArguments[e];r||(r=[]),r.push(n),this.retainedEventArguments[e]=r}return}a.forEach(r=>r(n))}hasListeners(e){var n;return!!(!((n=this.listeners[e])===null||n===void 0)&&n.length)}registerWindowListener(e,n){this.windowListeners[n]={registered:!1,windowEventName:e,pluginEventName:n,handler:s=>{this.notifyListeners(n,s)}}}unimplemented(e="not implemented"){return new yp.Exception(e,Yl.Unimplemented)}unavailable(e="not available"){return new yp.Exception(e,Yl.Unavailable)}async removeListener(e,n){const s=this.listeners[e];if(!s)return;const a=s.indexOf(n);this.listeners[e].splice(a,1),this.listeners[e].length||this.removeWindowListener(this.windowListeners[e])}addWindowListener(e){window.addEventListener(e.windowEventName,e.handler),e.registered=!0}removeWindowListener(e){e&&(window.removeEventListener(e.windowEventName,e.handler),e.registered=!1)}sendRetainedArgumentsForEvent(e){const n=this.retainedEventArguments[e];n&&(delete this.retainedEventArguments[e],n.forEach(s=>{this.notifyListeners(e,s)}))}}const Uk=t=>encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),Hk=t=>t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);class dR extends Lx{async getCookies(){const e=document.cookie,n={};return e.split(";").forEach(s=>{if(s.length<=0)return;let[a,r]=s.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");a=Hk(a).trim(),r=Hk(r).trim(),n[a]=r}),n}async setCookie(e){try{const n=Uk(e.key),s=Uk(e.value),a=e.expires?`; expires=${e.expires.replace("expires=","")}`:"",r=(e.path||"/").replace("path=",""),i=e.url!=null&&e.url.length>0?`domain=${e.url}`:"";document.cookie=`${n}=${s||""}${a}; path=${r}; ${i};`}catch(n){return Promise.reject(n)}}async deleteCookie(e){try{document.cookie=`${e.key}=; Max-Age=0`}catch(n){return Promise.reject(n)}}async clearCookies(){try{const e=document.cookie.split(";")||[];for(const n of e)document.cookie=n.replace(/^ +/,"").replace(/=.*/,`=;expires=${new Date().toUTCString()};path=/`)}catch(e){return Promise.reject(e)}}async clearAllCookies(){try{await this.clearCookies()}catch(e){return Promise.reject(e)}}}Ju("CapacitorCookies",{web:()=>new dR});const fR=async t=>new Promise((e,n)=>{const s=new FileReader;s.onload=()=>{const a=s.result;e(a.indexOf(",")>=0?a.split(",")[1]:a)},s.onerror=a=>n(a),s.readAsDataURL(t)}),pR=(t={})=>{const e=Object.keys(t);return Object.keys(t).map(a=>a.toLocaleLowerCase()).reduce((a,r,i)=>(a[r]=t[e[i]],a),{})},hR=(t,e=!0)=>t?Object.entries(t).reduce((s,a)=>{const[r,i]=a;let c,d;return Array.isArray(i)?(d="",i.forEach(f=>{c=e?encodeURIComponent(f):f,d+=`${r}=${c}&`}),d.slice(0,-1)):(c=e?encodeURIComponent(i):i,d=`${r}=${c}`),`${s}&${d}`},"").substr(1):null,mR=(t,e={})=>{const n=Object.assign({method:t.method||"GET",headers:t.headers},e),a=pR(t.headers)["content-type"]||"";if(typeof t.data=="string")n.body=t.data;else if(a.includes("application/x-www-form-urlencoded")){const r=new URLSearchParams;for(const[i,c]of Object.entries(t.data||{}))r.set(i,c);n.body=r.toString()}else if(a.includes("multipart/form-data")||t.data instanceof FormData){const r=new FormData;if(t.data instanceof FormData)t.data.forEach((c,d)=>{r.append(d,c)});else for(const c of Object.keys(t.data))r.append(c,t.data[c]);n.body=r;const i=new Headers(n.headers);i.delete("content-type"),n.headers=i}else(a.includes("application/json")||typeof t.data=="object")&&(n.body=JSON.stringify(t.data));return n};class gR extends Lx{async request(e){const n=mR(e,e.webFetchExtra),s=hR(e.params,e.shouldEncodeUrlParams),a=s?`${e.url}?${s}`:e.url,r=await fetch(a,n),i=r.headers.get("content-type")||"";let{responseType:c="text"}=r.ok?e:{};i.includes("application/json")&&(c="json");let d,f;switch(c){case"arraybuffer":case"blob":f=await r.blob(),d=await fR(f);break;case"json":d=await r.json();break;case"document":case"text":default:d=await r.text()}const h={};return r.headers.forEach((m,b)=>{h[b]=m}),{data:d,headers:h,status:r.status,url:r.url}}async get(e){return this.request(Object.assign(Object.assign({},e),{method:"GET"}))}async post(e){return this.request(Object.assign(Object.assign({},e),{method:"POST"}))}async put(e){return this.request(Object.assign(Object.assign({},e),{method:"PUT"}))}async patch(e){return this.request(Object.assign(Object.assign({},e),{method:"PATCH"}))}async delete(e){return this.request(Object.assign(Object.assign({},e),{method:"DELETE"}))}}const Aq=Ju("CapacitorHttp",{web:()=>new gR});var Wk;(function(t){t.Dark="DARK",t.Light="LIGHT",t.Default="DEFAULT"})(Wk||(Wk={}));var qk;(function(t){t.StatusBar="StatusBar",t.NavigationBar="NavigationBar"})(qk||(qk={}));class bR extends Lx{async setStyle(){this.unavailable("not available for web")}async setAnimation(){this.unavailable("not available for web")}async show(){this.unavailable("not available for web")}async hide(){this.unavailable("not available for web")}}Ju("SystemBars",{web:()=>new bR});var Vk;(function(t){t[t.Sunday=1]="Sunday",t[t.Monday=2]="Monday",t[t.Tuesday=3]="Tuesday",t[t.Wednesday=4]="Wednesday",t[t.Thursday=5]="Thursday",t[t.Friday=6]="Friday",t[t.Saturday=7]="Saturday"})(Vk||(Vk={}));const Ix=Ju("LocalNotifications",{web:()=>vt(()=>import("./web-DAqM9uoZ.js"),__vite__mapDeps([5,3,1,4])).then(t=>new t.LocalNotificationsWeb)}),xR=Ju("ServerConfig");let yR=100;const vR="agent_alerts",Kb="tide-notification-tap";function wR(){return typeof window<"u"&&window.innerWidth<=768&&"ontouchstart"in window}function Nj(t){if(wR()){U.openTerminalOnMobile(t);return}if(document.querySelector(".commander-overlay")){U.requestCommanderExpand(t);return}U.selectAgent(t),U.setTerminalOpen(!0)}function Zu(){try{return yp.isNativePlatform()}catch{return!1}}async function kR(){if(Zu())try{const t=await Ix.requestPermissions();return console.log("[Notifications] Permission result:",t.display),t.display==="granted"}catch(t){return console.error("[Notifications] Failed to request permissions:",t),!1}else return"Notification"in window?await Notification.requestPermission()==="granted":!1}async function SR(t){const{title:e,body:n,icon:s,data:a}=t;if(Zu())try{const r=yR++;console.log("[Notifications] Scheduling native notification id="+r,e),await Ix.schedule({notifications:[{id:r,title:e,body:n,extra:a,channelId:vR,smallIcon:"ic_launcher",autoCancel:!0}]}),console.log("[Notifications] Notification scheduled successfully")}catch(r){console.error("[Notifications] Failed to schedule notification:",r)}else if("Notification"in window&&Notification.permission==="granted"){const r=new Notification(e,{body:n,icon:s,data:a});r.onclick=()=>{window.focus(),a&&window.dispatchEvent(new CustomEvent(Kb,{detail:a}))}}}let Mg=!1;async function CR(t){const e=[];if(Mg)return()=>{};if(Mg=!0,t){const n=s=>{const a=s;a.detail&&t(a.detail)};window.addEventListener(Kb,n),e.push(()=>window.removeEventListener(Kb,n))}if(Zu())try{const n=await Ix.addListener("localNotificationActionPerformed",s=>{t&&s.notification.extra&&t(s.notification.extra)});e.push(()=>n.remove())}catch(n){console.error("[Notifications] Failed to add tap listener:",n)}return()=>{e.forEach(n=>n()),Mg=!1}}function AR(t,e){Zu()&&xR.syncConfig({url:t,token:e}).catch(n=>{console.warn("[Notifications] Failed to sync config to native service:",n)})}window.__tideWsState||(window.__tideWsState={ws:null,isConnecting:!1,reconnectAttempts:0,reconnectTimeout:null});const Yp=()=>window.__tideWsState.ws,Yk=t=>{window.__tideWsState.ws=t},jR=()=>window.__tideWsState.isConnecting,nu=t=>{window.__tideWsState.isConnecting=t},Qb=()=>window.__tideWsState.reconnectAttempts,Xb=t=>{window.__tideWsState.reconnectAttempts=t},Tj=()=>window.__tideWsState.reconnectTimeout,_j=t=>{window.__tideWsState.reconnectTimeout=t},Gk=10,Px="tide_ws_has_connected";function Kk(){return sessionStorage.getItem(Px)==="true"}function NR(t){sessionStorage.setItem(Px,"true")}function TR(){sessionStorage.removeItem(Px)}let Ej=null;const _R=t=>{Ej=t},Qk=()=>Ej,Re={onToast:null,onAgentCreated:null,onAgentUpdated:null,onAgentDeleted:null,onAgentsSync:null,onAreasSync:null,onSpawnError:null,onSpawnSuccess:null,onToolUse:null,onDirectoryNotFound:null,onDelegation:null,onCustomClassesSync:null,onReconnect:null,onAgentNotification:null,onBuildingUpdated:null,onSubagentStarted:null,onSubagentCompleted:null};function Mj(t){t.onToast&&(Re.onToast=t.onToast),t.onAgentCreated&&(Re.onAgentCreated=t.onAgentCreated),t.onAgentUpdated&&(Re.onAgentUpdated=t.onAgentUpdated),t.onAgentDeleted&&(Re.onAgentDeleted=t.onAgentDeleted),t.onAgentsSync&&(Re.onAgentsSync=t.onAgentsSync),t.onAreasSync&&(Re.onAreasSync=t.onAreasSync),t.onSpawnError&&(Re.onSpawnError=t.onSpawnError),t.onSpawnSuccess&&(Re.onSpawnSuccess=t.onSpawnSuccess),t.onToolUse&&(Re.onToolUse=t.onToolUse),t.onDirectoryNotFound&&(Re.onDirectoryNotFound=t.onDirectoryNotFound),t.onDelegation&&(Re.onDelegation=t.onDelegation),t.onCustomClassesSync&&(Re.onCustomClassesSync=t.onCustomClassesSync),t.onReconnect&&(Re.onReconnect=t.onReconnect),t.onAgentNotification&&(Re.onAgentNotification=t.onAgentNotification),t.onBuildingUpdated&&(Re.onBuildingUpdated=t.onBuildingUpdated),t.onSubagentStarted&&(Re.onSubagentStarted=t.onSubagentStarted),t.onSubagentCompleted&&(Re.onSubagentCompleted=t.onSubagentCompleted)}function ER(){Re.onToast=null,Re.onAgentCreated=null,Re.onAgentUpdated=null,Re.onAgentDeleted=null,Re.onAgentsSync=null,Re.onAreasSync=null,Re.onSpawnError=null,Re.onSpawnSuccess=null,Re.onToolUse=null,Re.onDirectoryNotFound=null,Re.onDelegation=null,Re.onCustomClassesSync=null,Re.onReconnect=null,Re.onAgentNotification=null,Re.onSubagentStarted=null,Re.onSubagentCompleted=null}function MR(){Re.onAgentCreated=null,Re.onAgentUpdated=null,Re.onAgentDeleted=null,Re.onAgentsSync=null,Re.onAreasSync=null,Re.onToolUse=null,Re.onDelegation=null,Re.onCustomClassesSync=null,Re.onBuildingUpdated=null,Re.onSubagentStarted=null,Re.onSubagentCompleted=null}const jf=new Map,DR=new Map,Jb={start(t){},end(t){},async measure(t,e){this.start(t);try{return await e()}finally{this.end(t)}},measureSync(t,e){this.start(t);try{return e()}finally{this.end(t)}},getMetrics(t){const e={},n=t?jf.has(t)?[[t,jf.get(t)]]:[]:Array.from(jf.entries());for(const[s,a]of n){const r=[...a.samples].sort((f,h)=>f-h),i=Math.floor(r.length*.5),c=Math.floor(r.length*.95),d=Math.floor(r.length*.99);e[s]={count:a.count,avgMs:a.totalMs/a.count,minMs:a.minMs,maxMs:a.maxMs,lastMs:a.lastMs,p50Ms:r[i]||0,p95Ms:r[c]||0,p99Ms:r[d]||0}}return e},clear(){jf.clear(),DR.clear()},report(){}};class RR{constructor(){Xe(this,"frames",[]);Xe(this,"lastFrameTime",0);Xe(this,"frameCount",0);Xe(this,"fps",0);Xe(this,"minFps",1/0);Xe(this,"maxFps",0);Xe(this,"fpsHistory",[]);Xe(this,"maxHistorySize",60)}tick(e=200){const n=performance.now();if(this.lastFrameTime>0){const s=n-this.lastFrameTime;s<e&&(this.frames.push(s),this.frames.length>60&&this.frames.shift())}this.lastFrameTime=n,this.frameCount++}update(){if(this.frames.length===0)return;const e=this.frames.reduce((n,s)=>n+s,0)/this.frames.length;this.fps=1e3/e,this.minFps=Math.min(this.minFps,this.fps),this.maxFps=Math.max(this.maxFps,this.fps),this.fpsHistory.push(this.fps),this.fpsHistory.length>this.maxHistorySize&&this.fpsHistory.shift()}getFPS(){return Math.round(this.fps)}getStats(){const e=this.fpsHistory.length>0?this.fpsHistory.reduce((n,s)=>n+s,0)/this.fpsHistory.length:this.fps;return{current:Math.round(this.fps),min:Math.round(this.minFps===1/0?0:this.minFps),max:Math.round(this.maxFps),avg:Math.round(e)}}reset(){this.frames=[],this.lastFrameTime=0,this.frameCount=0,this.fps=0,this.minFps=1/0,this.maxFps=0,this.fpsHistory=[]}}const Nf=new RR;class OR{constructor(){Xe(this,"snapshots",[]);Xe(this,"maxSnapshots",120);Xe(this,"intervalId",null);Xe(this,"leakThresholdMB",50);Xe(this,"baselineUsedMB",0)}getUsage(){const e=performance.memory;return e?{usedMB:Math.round(e.usedJSHeapSize/1024/1024),totalMB:Math.round(e.totalJSHeapSize/1024/1024),limitMB:Math.round(e.jsHeapSizeLimit/1024/1024)}:null}log(){const e=this.getUsage();e&&console.log(`[Memory] Used: ${e.usedMB}MB / ${e.totalMB}MB (limit: ${e.limitMB}MB)`)}startMonitoring(e=1e3){if(this.intervalId)return;const n=this.getUsage();n&&(this.baselineUsedMB=n.usedMB),this.intervalId=setInterval(()=>{this.takeSnapshot()},e),console.log("[Memory] Monitoring started. Use memory.report() to see analysis.")}stopMonitoring(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null,console.log("[Memory] Monitoring stopped."))}takeSnapshot(){const e=this.getUsage();if(!e)return;const n={timestamp:Date.now(),heapUsedMB:e.usedMB,heapTotalMB:e.totalMB,heapLimitMB:e.limitMB};this.snapshots.push(n),this.snapshots.length>this.maxSnapshots&&this.snapshots.shift();const s=e.usedMB-this.baselineUsedMB;s>this.leakThresholdMB&&console.warn(`[Memory] Warning: Heap grew by ${s}MB since monitoring started (baseline: ${this.baselineUsedMB}MB, current: ${e.usedMB}MB)`)}getGrowthRate(){if(this.snapshots.length<10)return null;const e=this.snapshots[0],n=this.snapshots[this.snapshots.length-1],s=(n.timestamp-e.timestamp)/1e3/60;return s<.1?null:(n.heapUsedMB-e.heapUsedMB)/s}report(){const e=this.getUsage();if(!e){console.log("[Memory] Memory API not available (Chrome only)");return}console.group("%c[Memory Report]","color: #ff6600; font-weight: bold"),console.log(`Current: ${e.usedMB}MB / ${e.totalMB}MB (limit: ${e.limitMB}MB)`),console.log(`Baseline: ${this.baselineUsedMB}MB`),console.log(`Growth: ${e.usedMB-this.baselineUsedMB}MB since monitoring started`);const n=this.getGrowthRate();if(n!==null&&(console.log(`Growth Rate: ${n.toFixed(2)}MB/min`),n>5&&console.warn("POTENTIAL MEMORY LEAK: Growth rate exceeds 5MB/min")),this.snapshots.length>1){const s=Math.min(...this.snapshots.map(r=>r.heapUsedMB)),a=Math.max(...this.snapshots.map(r=>r.heapUsedMB));console.log(`Range: ${s}MB - ${a}MB (${a-s}MB variance)`)}console.groupEnd()}getThreeJsInfo(e){var n;return(n=e==null?void 0:e.info)!=null&&n.memory?{geometries:e.info.memory.geometries,textures:e.info.memory.textures}:null}reset(){this.snapshots=[];const e=this.getUsage();e&&(this.baselineUsedMB=e.usedMB),console.log("[Memory] Reset. New baseline:",this.baselineUsedMB,"MB")}}const su=new OR;function yu(t,e,n,s,a,r){}function Dj(t,e){x.useRef(0),x.useEffect(()=>{},[t,5e3,!0])}if(typeof window<"u"){setInterval(()=>{try{performance.clearMarks(),performance.clearMeasures(),performance.clearResourceTimings()}catch{}},6e4);try{performance.setResourceTimingBufferSize(0)}catch{}}const Zb=pt.PENDING_MESSAGES,LR=300*1e3;function Rj(){try{const t=localStorage.getItem(Zb);if(!t)return[];const e=JSON.parse(t),n=Date.now();return e.filter(s=>n-s.queuedAt<LR)}catch{return[]}}function Oj(t){try{t.length===0?localStorage.removeItem(Zb):localStorage.setItem(Zb,JSON.stringify(t))}catch{}}function Tf(t){const e=Rj();e.push({message:t,queuedAt:Date.now()}),Oj(e)}function IR(){var s;const t=Rj();if(t.length===0)return 0;let e=0;const n=[];for(const a of t)PR(a.message)?e++:n.push(a);if(Oj(n),e>0){const a=e===1?"queued message":"queued messages";(s=Re.onToast)==null||s.call(Re,"success","Messages Sent",`${e} ${a} delivered after reconnecting.`)}return e}function Bx(t){if(t.payload&&typeof t.payload=="object"){const e=t.payload;if(e.agentId)return e.agentId;if(e.parentAgentId)return e.parentAgentId;if(e.bossId)return e.bossId;if(e.id)return e.id}return null}function PR(t){const e=Yp();if(!e||e.readyState!==WebSocket.OPEN)return!1;try{const n=JSON.stringify(t),s=Bx(t);return console.log("[AgentDebugger] SENT - type:",t.type,"agentId:",s,"payload:",t.payload),s&&vs.captureSent(s,n),e.send(n),!0}catch{return!1}}function Fx(t){var n,s,a,r,i,c,d,f,h,m;const e=Yp();if(!e)return(n=Qk())==null||n(),t.type==="send_command"?(Tf(t),(s=Re.onToast)==null||s.call(Re,"warning","Message Queued","Connection lost. Your message will be sent when reconnected.")):(a=Re.onToast)==null||a.call(Re,"error","Not Connected","Connecting to server... Please try again in a moment."),!1;if(e.readyState!==WebSocket.OPEN)return e.readyState===WebSocket.CONNECTING?t.type==="send_command"?(Tf(t),(r=Re.onToast)==null||r.call(Re,"warning","Message Queued","Still connecting. Your message will be sent automatically.")):(i=Re.onToast)==null||i.call(Re,"warning","Connecting...","WebSocket is still connecting. Please wait a moment and try again."):(e.readyState===WebSocket.CLOSED||e.readyState===WebSocket.CLOSING)&&((c=Qk())==null||c(),t.type==="send_command"?(Tf(t),(d=Re.onToast)==null||d.call(Re,"warning","Message Queued","Connection lost. Your message will be sent when reconnected.")):(f=Re.onToast)==null||f.call(Re,"warning","Reconnecting...","Connection lost. Reconnecting to server...")),!1;try{const b=JSON.stringify(t),y=Bx(t);return console.log("[AgentDebugger] SENT - type:",t.type,"agentId:",y,"payload:",t.payload),y&&vs.captureSent(y,b),e.send(b),!0}catch(b){return t.type==="send_command"?(Tf(t),(h=Re.onToast)==null||h.call(Re,"warning","Message Queued","Send failed. Your message will be retried when reconnected.")):(m=Re.onToast)==null||m.call(Re,"error","Send Failed",`Failed to send message: ${b}`),!1}}const vu=new Set,BR=5e3;function Xk(t){if(!t.isDetached||!t.sessionId){vu.delete(t.id);return}vu.has(t.id)||(vu.add(t.id),Fx({type:"reattach_agent",payload:{agentId:t.id}}),setTimeout(()=>{vu.delete(t.id)},BR))}function FR(t){var e,n,s,a,r,i,c,d,f,h,m,b,y,w,C,N,k,j,S,T,D,E,I,O;switch(Jb.start(`ws:${t.type}`),t.type){case"agents_update":{const _=t.payload,M=_.filter(R=>R.class==="boss"||R.isBoss);M.length>0&&console.log("[WS agents_update] Boss agents received:",M.map(R=>({id:R.id,name:R.name,subordinateIds:R.subordinateIds}))),U.setAgents(_),(e=Re.onAgentsSync)==null||e.call(Re,_),U.loadToolHistory();for(const R of _)Xk(R);break}case"agent_created":{const _=t.payload;console.log("[WebSocket] Agent created:",_),U.addAgent(_);const M=(n=window.__spawnModalAreaContext)==null?void 0:n.areaId;M&&(U.assignAgentToArea(_.id,M),window.__spawnModalAreaContext=null),U.selectAgent(_.id),(s=Re.onAgentCreated)==null||s.call(Re,_),(a=Re.onSpawnSuccess)==null||a.call(Re),window.__spawnModalSuccess&&(console.log("[WebSocket] Calling __spawnModalSuccess"),window.__spawnModalSuccess()),(r=Re.onToast)==null||r.call(Re,"success","Agent Deployed",`${_.name} is ready for commands`);break}case"agent_updated":{const _=t.payload,R=U.getState().agents.get(_.id),z=(R==null?void 0:R.status)!==_.status;console.log(`[Tide] Agent updated: ${_.name} (${_.id}) status=${_.status} (was ${R==null?void 0:R.status})${z?" ⚡ STATUS CHANGED":""}`),z&&console.log(`[Tide] 🔔 Status change for ${_.name}: ${R==null?void 0:R.status} → ${_.status}`),z&&(R==null?void 0:R.status)==="working"&&_.status==="idle"&&U.triggerHistoryRefresh(_.id);const $=R?R.position.x!==_.position.x||R.position.z!==_.position.z:!1;U.updateAgent(_),Xk(_),(i=Re.onAgentUpdated)==null||i.call(Re,_,$);break}case"agent_deleted":{const{id:_}=t.payload;vu.delete(_),U.removeAgent(_),(c=Re.onAgentDeleted)==null||c.call(Re,_);break}case"activity":{const _=t.payload;U.addActivity(_);break}case"event":{const _=t.payload;if(Uu.debug(`Event: ${_.type}`,{agentId:_.agentId,toolName:_.toolName},"ws:event"),_.type==="tool_start"&&_.toolName&&((d=Re.onToolUse)==null||d.call(Re,_.agentId,_.toolName,_.toolInput),U.addToolExecution(_.agentId,_.toolName,_.toolInput),_.toolInput)){const M=_.toolInput.file_path||_.toolInput.path;M&&(_.toolName==="Write"?U.addFileChange(_.agentId,"created",M):_.toolName==="Edit"?U.addFileChange(_.agentId,"modified",M):_.toolName==="Read"&&U.addFileChange(_.agentId,"read",M))}break}case"output":{const _=t.payload;Uu.debug(`Output: "${_.text.slice(0,80)}..."`,{agentId:_.agentId,isStreaming:_.isStreaming,length:_.text.length,hasSkillUpdate:!!_.skillUpdate,uuid:_.uuid,toolName:_.toolName},"ws:output"),U.addOutput(_.agentId,{text:_.text,isStreaming:_.isStreaming,timestamp:_.timestamp,isDelegation:_.isDelegation,skillUpdate:_.skillUpdate,subagentName:_.subagentName,uuid:_.uuid,toolName:_.toolName,toolInput:_.toolInput,toolOutput:_.toolOutput});break}case"context_stats":{const{agentId:_,stats:M}=t.payload;console.log(`[Tide] Received context stats for agent ${_}: ${M.usedPercent}% used`),U.updateAgentContextStats(_,M);break}case"context_update":{const{agentId:_,contextUsed:M,contextLimit:R}=t.payload;U.updateAgentContext(_,M,R);break}case"error":{const _=t.payload;console.error("[WebSocket] Error from server:",_.message),(f=Re.onToast)==null||f.call(Re,"error","Error",_.message),(h=Re.onSpawnError)==null||h.call(Re),window.__spawnModalError&&(console.log("[WebSocket] Calling __spawnModalError"),window.__spawnModalError());break}case"directory_not_found":{const{path:_}=t.payload;console.log("[WebSocket] Directory not found:",_),(m=Re.onDirectoryNotFound)==null||m.call(Re,_),window.__spawnModalDirNotFound&&(console.log("[WebSocket] Calling __spawnModalDirNotFound"),window.__spawnModalDirNotFound(_));break}case"command_started":{const{agentId:_,command:M}=t.payload,R=M.trim();if(R==="/context"||R==="/cost"||R==="/compact")break;U.addUserPromptToOutput(_,M);break}case"session_updated":{const{agentId:_}=t.payload;U.loadToolHistory(),U.triggerHistoryRefresh(_);const M=U.getState().agents.get(_);M&&U.updateAgent({...M});break}case"supervisor_report":{const _=t.payload;U.setSupervisorReport(_);break}case"narrative_update":{const{agentId:_,narrative:M}=t.payload;U.addNarrative(_,M);break}case"supervisor_status":{const _=t.payload;U.setSupervisorStatus(_);break}case"agent_supervisor_history":{const _=t.payload;U.setAgentSupervisorHistory(_);break}case"agent_analysis":{const{agentId:_,analysis:M}=t.payload;U.addAgentAnalysis(_,M);break}case"areas_update":{const _=t.payload;U.setAreasFromServer(_),(b=Re.onAreasSync)==null||b.call(Re);break}case"buildings_update":{const _=t.payload;U.setBuildingsFromServer(_);break}case"building_created":{const _=t.payload;U.addBuilding(_);break}case"building_updated":{const _=t.payload;U.updateBuildingFromServer(_),(y=Re.onBuildingUpdated)==null||y.call(Re,_);break}case"building_deleted":{const{id:_}=t.payload;U.removeBuildingFromServer(_);break}case"building_logs":{const{buildingId:_,logs:M}=t.payload;U.addBuildingLogs(_,M);break}case"pm2_logs_chunk":{const{buildingId:_,chunk:M}=t.payload;U.appendStreamingLogChunk(_,M);break}case"pm2_logs_streaming":{const{buildingId:_,streaming:M}=t.payload;U.setStreamingStatus(_,M);break}case"docker_logs_chunk":{const{buildingId:_,chunk:M}=t.payload;U.appendStreamingLogChunk(_,M);break}case"docker_logs_streaming":{const{buildingId:_,streaming:M}=t.payload;U.setStreamingStatus(_,M);break}case"docker_containers_list":{const{containers:_,composeProjects:M}=t.payload;console.log(`[WebSocket] Received ${_.length} containers, ${M.length} compose projects`),U.setDockerContainersList(_,M);break}case"boss_building_logs_chunk":{const{bossBuildingId:_,subordinateBuildingId:M,subordinateBuildingName:R,chunk:z,isError:$}=t.payload;U.appendBossStreamingLogChunk(_,M,R,z,$);break}case"boss_building_subordinates_updated":{const{bossBuildingId:_,subordinateBuildingIds:M}=t.payload;U.updateBuilding(_,{subordinateBuildingIds:M});break}case"permission_request":{const _=t.payload;U.addPermissionRequest(_);break}case"permission_resolved":{const{requestId:_,approved:M}=t.payload;U.resolvePermissionRequest(_,M);break}case"delegation_decision":{const _=t.payload;U.handleDelegationDecision(_),_.status==="sent"&&((w=Re.onToast)==null||w.call(Re,"info","Task Delegated",`Delegated to ${_.selectedAgentName}: ${_.reasoning.slice(0,80)}...`),_.bossId&&_.selectedAgentId&&((C=Re.onDelegation)==null||C.call(Re,_.bossId,_.selectedAgentId)));break}case"boss_subordinates_updated":{const{bossId:_,subordinateIds:M}=t.payload;U.updateBossSubordinates(_,M);break}case"delegation_history":{const{bossId:_,decisions:M}=t.payload;U.setDelegationHistory(_,M);break}case"boss_spawned_agent":{const{agent:_,bossPosition:M}=t.payload;console.log("[WebSocket] Boss spawned agent:",_.name,"- walking to boss at",M),U.addAgent(_),(N=Re.onAgentCreated)==null||N.call(Re,_),Fx({type:"move_agent",payload:{agentId:_.id,position:M}}),(k=Re.onToast)==null||k.call(Re,"success","Agent Deployed",`${_.name} spawned by boss, walking to position`);break}case"agent_task_started":{const{bossId:_,subordinateId:M,subordinateName:R,taskDescription:z}=t.payload;console.log(`[WebSocket] Agent ${R} started task for boss ${_}: ${z.slice(0,50)}...`),U.handleAgentTaskStarted(_,M,R,z);break}case"agent_task_output":{const{bossId:_,subordinateId:M,output:R,isStreaming:z,timestamp:$,subagentName:W,toolName:L,toolInput:F,toolOutput:H}=t.payload;U.handleAgentTaskOutput(_,M,{text:R,isStreaming:z||!1,timestamp:$||Date.now(),subagentName:W,toolName:L,toolInput:F,toolOutput:H});break}case"agent_task_completed":{const{bossId:_,subordinateId:M,success:R}=t.payload;console.log(`[WebSocket] Agent task completed for boss ${_}, subordinate ${M}, success: ${R}`),U.handleAgentTaskCompleted(_,M,R);break}case"skills_update":{const _=t.payload;U.setSkillsFromServer(_);break}case"skill_created":{const _=t.payload;U.addSkillFromServer(_),console.log(`[WebSocket] Skill created: ${_.name}`);break}case"skill_updated":{const _=t.payload;U.updateSkillFromServer(_),console.log(`[WebSocket] Skill updated: ${_.name}`);break}case"skill_deleted":{const{id:_}=t.payload;U.removeSkillFromServer(_),console.log(`[WebSocket] Skill deleted: ${_}`);break}case"agent_skills":{const{agentId:_,skills:M}=t.payload;console.log(`[WebSocket] Agent ${_} has ${M.length} skills`);break}case"custom_agent_classes_update":{const _=t.payload;U.setCustomAgentClassesFromServer(_),console.log(`[WebSocket] Received ${_.length} custom agent classes`);const M=new Map;for(const R of _)M.set(R.id,R);(j=Re.onCustomClassesSync)==null||j.call(Re,M);break}case"custom_agent_class_created":{const _=t.payload;U.addCustomAgentClassFromServer(_),console.log(`[WebSocket] Custom agent class created: ${_.name}`),(S=Re.onCustomClassesSync)==null||S.call(Re,U.getState().customAgentClasses);break}case"custom_agent_class_updated":{const _=t.payload;U.updateCustomAgentClassFromServer(_),console.log(`[WebSocket] Custom agent class updated: ${_.name}`),(T=Re.onCustomClassesSync)==null||T.call(Re,U.getState().customAgentClasses);break}case"custom_agent_class_deleted":{const{id:_}=t.payload;U.removeCustomAgentClassFromServer(_),console.log(`[WebSocket] Custom agent class deleted: ${_}`),(D=Re.onCustomClassesSync)==null||D.call(Re,U.getState().customAgentClasses);break}case"global_usage":{const _=t.payload;console.log("[WebSocket] Global usage update:",_),U.setGlobalUsage(_);break}case"agent_notification":{const _=t.payload;console.log(`[WebSocket] Agent notification from ${_.agentName}: ${_.title}`),(E=Re.onAgentNotification)==null||E.call(Re,_);break}case"focus_agent":{const{agentId:_,openTerminal:M}=t.payload;if(!U.getState().agents.get(_)){console.warn(`[WebSocket] focus_agent ignored - agent not found: ${_}`);break}U.selectAgent(_),M&&U.setTerminalOpen(!0);const z=[0,80,220,500,1e3];for(const $ of z)window.setTimeout(()=>{window.focus()},$);break}case"exec_task_started":{const{taskId:_,agentId:M,agentName:R,command:z,cwd:$}=t.payload;console.log(`[WebSocket] Exec task started: ${_} for agent ${R}: ${z.slice(0,50)}...`),U.handleExecTaskStarted(_,M,R,z,$);break}case"exec_task_output":{const{taskId:_,agentId:M,output:R,isError:z}=t.payload;U.handleExecTaskOutput(_,M,R,z);break}case"exec_task_completed":{const{taskId:_,agentId:M,exitCode:R,success:z}=t.payload;console.log(`[WebSocket] Exec task completed: ${_} for agent ${M}, success: ${z}`),U.handleExecTaskCompleted(_,M,R,z);break}case"subagent_started":{const _=t.payload;console.log(`[WebSocket] Subagent started: ${_.name} (${_.id}) for agent ${_.parentAgentId}`),U.addSubagent(_),(I=Re.onSubagentStarted)==null||I.call(Re,_);break}case"subagent_output":{const{subagentId:_,parentAgentId:M,text:R,timestamp:z}=t.payload,$=R.indexOf(":");if($>0){const W=R.slice(0,$).trim(),L=R.slice($+1).trim();U.addSubagentActivity(_,M,{toolName:W,description:L,timestamp:z})}else R.startsWith("Using ")&&U.addSubagentActivity(_,M,{toolName:R.slice(6).trim(),description:"",timestamp:z});break}case"subagent_completed":{const{subagentId:_,parentAgentId:M,success:R,resultPreview:z,subagentName:$,durationMs:W,tokensUsed:L,toolUseCount:F}=t.payload;console.log(`[WebSocket] Subagent completed: ${_} for agent ${M}, success: ${R}`),(W||L||F)&&U.updateSubagentStats(_,M,{durationMs:W||0,tokensUsed:L||0,toolUseCount:F||0}),U.completeSubagent(_,M,R),(O=Re.onSubagentCompleted)==null||O.call(Re,_);const H=U.getSubagent(_)||U.getSubagentByToolUseId(_),V=$||(H==null?void 0:H.name)||_,G=R?"✅":"❌",B=W?` (${(W/1e3).toFixed(0)}s · ${((L||0)/1e3).toFixed(1)}K tokens · ${F||0} tools)`:"";U.addOutput(M,{text:`${G} Subagent ${V} ${R?"completed":"failed"}${B}`,isStreaming:!1,timestamp:Date.now(),subagentName:V,toolOutput:z});break}case"subagent_stream":{const{toolUseId:_,parentAgentId:M,entries:R}=t.payload;U.addSubagentStreamEntries(_,M,R);break}case"secrets_update":{const _=t.payload;U.setSecretsFromServer(_),console.log(`[WebSocket] Received ${_.length} secrets`);break}case"secret_created":{const _=t.payload;U.addSecretFromServer(_),console.log(`[WebSocket] Secret created: ${_.name}`);break}case"secret_updated":{const _=t.payload;U.updateSecretFromServer(_),console.log(`[WebSocket] Secret updated: ${_.name}`);break}case"secret_deleted":{const{id:_}=t.payload;U.removeSecretFromServer(_),console.log(`[WebSocket] Secret deleted: ${_}`);break}case"database_connection_result":{const{buildingId:_,connectionId:M,success:R,error:z,serverVersion:$}=t.payload;U.setConnectionStatus(_,M,{connected:R,error:z,serverVersion:$}),console.log(`[WebSocket] Database connection ${R?"succeeded":"failed"}: ${M}`);break}case"databases_list":{const{buildingId:_,connectionId:M,databases:R}=t.payload;U.setDatabases(_,M,R),console.log(`[WebSocket] Received ${R.length} databases for ${M}`);break}case"tables_list":{const{buildingId:_,connectionId:M,database:R,tables:z}=t.payload;U.setTables(_,M,R,z),console.log(`[WebSocket] Received ${z.length} tables for ${R}`);break}case"table_schema":{const{buildingId:_,connectionId:M,database:R,table:z,columns:$,indexes:W,foreignKeys:L}=t.payload;U.setTableSchema(_,M,R,z,{columns:$,indexes:W||[],foreignKeys:L||[]}),console.log(`[WebSocket] Received schema for ${z}`);break}case"query_result":{const{buildingId:_,result:M}=t.payload;U.setQueryResult(_,M),console.log(`[WebSocket] Query ${M.status}: ${M.rowCount??M.affectedRows??0} rows in ${M.duration}ms`);break}case"silent_query_result":{const{buildingId:_,query:M,requestId:R,success:z,affectedRows:$,error:W}=t.payload;U.setSilentQueryResult(_,{query:M,requestId:R,success:z,affectedRows:$,error:W}),console.log(`[WebSocket] Silent query ${z?"succeeded":"failed"}: ${$??0} affected rows`);break}case"query_history_update":{const{buildingId:_,history:M}=t.payload;U.setQueryHistory(_,M),console.log(`[WebSocket] Received ${M.length} query history entries for ${_}`);break}}Jb.end(`ws:${t.type}`)}_R(()=>Hu());let Jk=!1;function Lj(){const t=Yp();t&&t.readyState===WebSocket.OPEN&&t.close(1e3,"Page unloading");const e=Tj();e&&clearTimeout(e),window.__tideWsState&&(window.__tideWsState.ws=null,window.__tideWsState.reconnectTimeout=null,window.__tideWsState.isConnecting=!1,window.__tideWsState.reconnectAttempts=0),TR()}function zR(){Jk||(window.addEventListener("beforeunload",Lj),Jk=!0)}function Ij(){Lj(),U.setConnected(!1),U.stopStatusPolling()}function $R(){Ij(),Xb(0),setTimeout(()=>Hu(),100)}function Hu(){zR();const t=Tj();t&&(clearTimeout(t),_j(null));const e=Yp();if(jR()||e&&e.readyState===WebSocket.CONNECTING)return;if(e&&e.readyState===WebSocket.OPEN){Kk()&&Re.onReconnect&&Re.onReconnect();return}Xb(Qb()+1),nu(!0);const n=Ox(),s=Ii(),a=6200;let r;if(n){const c=n.replace(/^https:\/\//,"wss://").replace(/^http:\/\//,"ws://");r=c.endsWith("/ws")?c:`${c.replace(/\/$/,"")}/ws`}else r=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`;let i=null;try{s?i=new WebSocket(r,[`auth-${s}`]):i=new WebSocket(r)}catch{nu(!1),Zk();return}Yk(i),i.onopen=()=>{var d,f,h;const c=Kk();nu(!1),Xb(0),NR(),U.setConnected(!0),U.startStatusPolling(),U.clearAllPermissions(),c?((d=Re.onToast)==null||d.call(Re,"success","Reconnected","Connection restored - refreshing data..."),(f=Re.onReconnect)==null||f.call(Re)):(h=Re.onToast)==null||h.call(Re,"success","Connected","Connected to Tide Commander server"),AR(n,s),IR()},i.onmessage=c=>{try{const d=JSON.parse(c.data),f=Bx(d);console.log("[AgentDebugger] RECEIVED - type:",d.type,"agentId:",f,"payload:",d.payload),f&&vs.captureReceived(f,c.data),FR(d)}catch(d){const f=c.data.substring(0,200);console.error("[WS] Failed to parse message:",d),console.error("[WS] Raw data (first 200 chars):",f),console.error("[WS] Full data length:",c.data.length),c.data.length<5e3&&console.error("[WS] Full malformed message:",c.data)}},i.onclose=()=>{var d,f;nu(!1),Yk(null),U.setConnected(!1),U.stopStatusPolling();const c=Qb();c<Gk?((d=Re.onToast)==null||d.call(Re,"warning","Disconnected",`Connection lost. Reconnecting... (attempt ${c+1}/${Gk})`),Zk()):(f=Re.onToast)==null||f.call(Re,"error","Connection Failed",`Could not connect to server. Please check if the backend is running on port ${a}.`)},i.onerror=()=>{nu(!1)},U.setSendMessage(Fx)}function Zk(){const t=Qb(),e=Math.min(1e3*Math.pow(2,t-1),3e4);_j(setTimeout(Hu,e))}function UR(t,e){const n={position:t,target:e};La(pt.CAMERA_STATE,n)}function HR(){return Na(pt.CAMERA_STATE,null)}function jq(t,e,n){const s={posX:t,posZ:e,zoom:n};La(pt.CAMERA_STATE_2D,s)}function Nq(){return Na(pt.CAMERA_STATE_2D,null)}function sc(){return{Authorization:`Bearer ${Ii()}`,"Content-Type":"application/json"}}async function WR(){const t=await fetch(`${Ea()}/api/workspaces`,{headers:sc()});if(!t.ok)throw new Error(`Failed to fetch workspaces: ${t.statusText}`);return t.json()}async function qR(t,e){const n=await fetch(`${Ea()}/api/workspaces`,{method:"POST",headers:sc(),body:JSON.stringify({name:t,areaIds:e})});if(!n.ok)throw new Error(`Failed to create workspace: ${n.statusText}`);return n.json()}async function eS(t,e){const n=await fetch(`${Ea()}/api/workspaces/${t}`,{method:"PUT",headers:sc(),body:JSON.stringify(e)});if(!n.ok)throw new Error(`Failed to update workspace: ${n.statusText}`);return n.json()}async function VR(t){const e=await fetch(`${Ea()}/api/workspaces/${t}`,{method:"DELETE",headers:sc()});if(!e.ok)throw new Error(`Failed to delete workspace: ${e.statusText}`)}async function YR(){const t=await fetch(`${Ea()}/api/workspaces/active`,{headers:sc()});if(!t.ok)throw new Error(`Failed to get active workspace: ${t.statusText}`);return(await t.json()).activeWorkspaceId??null}async function tS(t){const e=await fetch(`${Ea()}/api/workspaces/active`,{method:"PUT",headers:sc(),body:JSON.stringify({workspaceId:t})});if(!e.ok)throw new Error(`Failed to set active workspace: ${e.statusText}`)}const Wu=new Set;let sr=null,xo=[],Pj=!1;const ex=new Set;function Dg(t){Pj=t,ex.forEach(e=>e(t))}const Bj="tide-commander-active-workspace";function nS(){return typeof window>"u"?null:localStorage.getItem(Bj)||null}function Rg(t){typeof window>"u"||localStorage.setItem(Bj,t||"")}function au(){Wu.forEach(t=>t())}function GR(){return sr}function zx(t){return sr?t?sr.areaIds.includes(t):!1:!0}function Tq(t){return sr?sr.areaIds.includes(t):!0}function Fj(){const[,t]=x.useState(0);return x.useEffect(()=>{const e=()=>t(n=>n+1);return Wu.add(e),()=>{Wu.delete(e)}},[]),[sr,xo]}function KR(t){return Wu.add(t),()=>{Wu.delete(t)}}function QR(){const[t,e]=x.useState(Pj);return x.useEffect(()=>{const n=s=>e(s);return ex.add(n),()=>{ex.delete(n)}},[]),t}const Og=new Map,XR=Se.memo(function(){const{t:e}=dt("common"),n=ur(),[s,a]=x.useState([]),[r,i]=x.useState(()=>nS()),[c,d]=x.useState(!1),[f,h]=x.useState(!1),[m,b]=x.useState(!0),[y,w]=x.useState(null),[C,N]=x.useState(""),[k,j]=x.useState([]),[S,T]=x.useState(!1),D=x.useRef(null);x.useEffect(()=>{let L=!1;return(async()=>{try{const F=nS(),[H,V]=await Promise.all([WR(),YR()]);if(L)return;const G=F&&H.some(B=>B.id===F)?F:V&&H.some(B=>B.id===V)?V:null;a(H),xo=H,i(G),Rg(G),sr=H.find(B=>B.id===G)??null,au()}catch(F){console.error("workspace error:",F)}finally{L||b(!1)}})(),()=>{L=!0}},[]),x.useEffect(()=>{if(!c&&!f)return;const L=F=>{D.current&&!D.current.contains(F.target)&&(d(!1),h(!1))};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[c,f]);const E=x.useMemo(()=>s.find(L=>L.id===r)??null,[s,r]),I=x.useCallback(async L=>{Dg(!0);const F=Date.now();if(r){const B=HR();B&&(Og.set(r,B),eS(r,{cameraState:B}).then(K=>{a(se=>{const q=se.map(be=>be.id===r?K:be);return xo=q,q})}).catch(K=>console.error("workspace error:",K)))}i(L),Rg(L),d(!1);const H=L?s.find(B=>B.id===L)??null:null;if(sr=H,xo=s,au(),L){const K=(H==null?void 0:H.cameraState)??Og.get(L);K&&(UR(K.position,K.target),Og.set(L,K))}tS(L).catch(B=>console.error("workspace error:",B));const V=Date.now()-F,G=400;V<G?setTimeout(()=>Dg(!1),G-V):Dg(!1)},[r,s]),O=x.useMemo(()=>Array.from(n.values()).filter(L=>!L.archived),[n]),_=x.useCallback(async()=>{if(C.trim())try{const L=await qR(C.trim(),k),F=[...s,L];a(F),xo=F,au(),N(""),j([]),T(!1)}catch(L){console.error("workspace error:",L)}},[C,k,s]),M=x.useCallback(async()=>{if(!(!y||!C.trim()))try{const L=await eS(y,{name:C.trim(),areaIds:k}),F=s.map(H=>H.id===y?L:H);a(F),xo=F,y===r&&(sr=L),au(),w(null),N(""),j([])}catch(L){console.error("workspace error:",L)}},[y,C,k,s,r]),R=x.useCallback(async L=>{try{await VR(L);const F=s.filter(H=>H.id!==L);a(F),xo=F,r===L&&(i(null),Rg(null),sr=null,await tS(null).catch(H=>console.error("workspace error:",H))),au()}catch(F){console.error("workspace error:",F)}},[s,r]),z=x.useCallback(L=>{w(L.id),N(L.name),j([...L.areaIds]),T(!1)},[]),$=x.useCallback(()=>{w(null),N(""),j([]),T(!0)},[]),W=x.useCallback(L=>{j(F=>F.includes(L)?F.filter(H=>H!==L):[...F,L])},[]);return m?null:o.jsxs("div",{className:"workspace-switcher",ref:D,children:[o.jsxs("button",{className:"workspace-switcher-trigger",onClick:()=>{d(!c),h(!1)},title:"Workspaces",children:[o.jsx("span",{className:"workspace-switcher-icon",children:"📂"}),o.jsx("span",{className:"workspace-switcher-label",children:E?E.name:e("agentBar.allWorkspaces",{defaultValue:"All"})}),o.jsx("span",{className:"workspace-switcher-arrow",children:c?"▲":"▼"})]}),c&&!f&&o.jsxs("div",{className:"workspace-switcher-dropdown",children:[o.jsx("button",{className:`workspace-switcher-option ${r?"":"active"}`,onClick:()=>I(null),children:e("agentBar.allWorkspaces",{defaultValue:"All"})}),s.map(L=>o.jsxs("button",{className:`workspace-switcher-option ${L.id===r?"active":""}`,onClick:()=>I(L.id),children:[L.name,o.jsx("span",{className:"workspace-switcher-option-count",children:L.areaIds.length})]},L.id)),o.jsx("div",{className:"workspace-switcher-divider"}),o.jsxs("button",{className:"workspace-switcher-option workspace-switcher-manage",onClick:()=>h(!0),children:["⚙ ",e("agentBar.manageWorkspaces",{defaultValue:"Manage"})]})]}),f&&o.jsxs("div",{className:"workspace-switcher-dropdown workspace-switcher-manager",children:[o.jsxs("div",{className:"workspace-switcher-manager-header",children:[o.jsx("span",{children:e("agentBar.workspaces",{defaultValue:"Workspaces"})}),o.jsx("button",{className:"workspace-switcher-close",onClick:()=>h(!1),children:"×"})]}),o.jsx("div",{className:"workspace-switcher-manager-list",children:s.map(L=>o.jsx("div",{className:"workspace-switcher-manager-item",children:y===L.id?o.jsxs("div",{className:"workspace-switcher-editor",children:[o.jsx("input",{type:"text",value:C,onChange:F=>N(F.target.value),className:"workspace-switcher-input",placeholder:"Workspace name",autoFocus:!0,onKeyDown:F=>{F.key==="Enter"&&M(),F.key==="Escape"&&w(null)}}),o.jsxs("div",{className:"workspace-switcher-area-list",children:[O.map(F=>o.jsxs("label",{className:"workspace-switcher-area-check",children:[o.jsx("input",{type:"checkbox",checked:k.includes(F.id),onChange:()=>W(F.id)}),o.jsx("span",{style:{color:F.color},children:F.name})]},F.id)),O.length===0&&o.jsx("span",{className:"workspace-switcher-empty",children:"No areas"})]}),o.jsxs("div",{className:"workspace-switcher-editor-actions",children:[o.jsx("button",{className:"workspace-switcher-btn-save",onClick:M,children:"Save"}),o.jsx("button",{className:"workspace-switcher-btn-cancel",onClick:()=>w(null),children:"Cancel"})]})]}):o.jsxs("div",{className:"workspace-switcher-manager-row",children:[o.jsx("span",{className:"workspace-switcher-manager-name",children:L.name}),o.jsxs("span",{className:"workspace-switcher-manager-count",children:[L.areaIds.length," areas"]}),o.jsx("button",{className:"workspace-switcher-btn-edit",onClick:()=>z(L),title:"Edit",children:"✏"}),o.jsx("button",{className:"workspace-switcher-btn-delete",onClick:()=>R(L.id),title:"Delete",children:"🗑"})]})},L.id))}),S?o.jsxs("div",{className:"workspace-switcher-editor workspace-switcher-create-form",children:[o.jsx("input",{type:"text",value:C,onChange:L=>N(L.target.value),className:"workspace-switcher-input",placeholder:"New workspace name",autoFocus:!0,onKeyDown:L=>{L.key==="Enter"&&_(),L.key==="Escape"&&T(!1)}}),o.jsxs("div",{className:"workspace-switcher-area-list",children:[O.map(L=>o.jsxs("label",{className:"workspace-switcher-area-check",children:[o.jsx("input",{type:"checkbox",checked:k.includes(L.id),onChange:()=>W(L.id)}),o.jsx("span",{style:{color:L.color},children:L.name})]},L.id)),O.length===0&&o.jsx("span",{className:"workspace-switcher-empty",children:"No areas"})]}),o.jsxs("div",{className:"workspace-switcher-editor-actions",children:[o.jsx("button",{className:"workspace-switcher-btn-save",onClick:_,children:"Create"}),o.jsx("button",{className:"workspace-switcher-btn-cancel",onClick:()=>T(!1),children:"Cancel"})]})]}):o.jsxs("button",{className:"workspace-switcher-option workspace-switcher-add",onClick:$,children:["+ ",e("agentBar.newWorkspace",{defaultValue:"New Workspace"})]})]})]})}),vp="tide_webgl_active";typeof window<"u"&&(window.__tidePersistedScene===void 0&&(window.__tidePersistedScene=null),window.__tidePersistedCanvas===void 0&&(window.__tidePersistedCanvas=null),window.__tideWsConnected===void 0&&(window.__tideWsConnected=!1),window.__tideIsPageUnloading===void 0&&(window.__tideIsPageUnloading=!1));function Gp(){return typeof window<"u"?window.__tidePersistedScene??null:null}function zj(){return typeof window<"u"?window.__tidePersistedCanvas??null:null}function JR(){return typeof window<"u"?window.__tideWsConnected??!1:!1}function qu(t){typeof window<"u"&&(window.__tidePersistedScene=t)}function Eu(t){typeof window<"u"&&(window.__tidePersistedCanvas=t)}function $j(t){typeof window<"u"&&(window.__tideWsConnected=t)}function ZR(t){typeof window<"u"&&(window.__tideIsPageUnloading=t)}function eO(){sessionStorage.setItem(vp,"true")}function _f(t){ZR(!0),sessionStorage.removeItem(vp),Ij(),ER(),window.__tideScene&&(window.__tideScene=null);const e=Gp();e?(console.log("[App] Calling persistedScene.dispose()"),e.dispose(),qu(null)):console.log("[App] No persistedScene to dispose"),Eu(null),$j(!1);const n=document.getElementById("battlefield");n&&n.remove();const s=document.getElementById("app");s&&(s.innerHTML="")}function tO(){var a,r;if(window.__tideAppInitialized)return;if(window.__tideAppInitialized=!0,sessionStorage.getItem(vp)==="true"&&console.log("[App] Detected unclean shutdown from previous session - forcing cleanup"),window.__tideScene){console.log("[App] Cleaning up stale __tideScene reference");try{(r=(a=window.__tideScene).dispose)==null||r.call(a)}catch{}window.__tideScene=null}const e=Gp();if(e){console.log("[App] Cleaning up stale persistedScene");try{e.dispose()}catch{}qu(null)}const n=document.getElementById("battlefield"),s=zj();n&&n!==s&&n.remove(),sessionStorage.removeItem(vp)}function nO(){typeof window>"u"||(tO(),window.addEventListener("pageshow",t=>{t.persisted&&(console.log("[App] Page restored from bfcache - cleaning up"),_f(),window.location.reload())}),window.onunload=()=>_f(),window.onbeforeunload=t=>{_f()},window.addEventListener("pagehide",t=>{_f(`pagehide (persisted=${t.persisted})`)}))}nO();const sS={showTrees:!0,showBushes:!0,showHouse:!0,showLamps:!0,showGrass:!0,showClouds:!0,fogDensity:1,floorStyle:"metal",brightness:1,skyColor:null,battlefieldSize:50},aS={saturation:2,roughness:.5,metalness:-1,emissiveBoost:0,envMapIntensity:1,wireframe:!1,colorMode:"normal"},rS={idleAnimation:"sit",workingAnimation:"sprint"},sO=0;function Uj(){const t={characterScale:2,scale2d:.7,scale3d:.7,show2DTaskLabels:!0,gridVisible:!1,timeMode:"day",terrain:sS,modelStyle:aS,animations:rS,fpsLimit:sO},e=Na(pt.CONFIG,null);if(e){const n=e.indicatorScale;return{characterScale:e.characterScale??t.characterScale,scale2d:e.scale2d??n??t.scale2d,scale3d:e.scale3d??n??t.scale3d,show2DTaskLabels:e.show2DTaskLabels??t.show2DTaskLabels,gridVisible:e.gridVisible??t.gridVisible,timeMode:e.timeMode??t.timeMode,terrain:{...sS,...e.terrain},modelStyle:{...aS,...e.modelStyle},animations:{...rS,...e.animations},fpsLimit:e.fpsLimit??t.fpsLimit}}return t}function aO(t){La(pt.CONFIG,t)}function rO(){return typeof window>"u"?!0:window.matchMedia("(max-width: 768px)").matches}typeof window<"u"&&!window.__tideHmrRefreshListeners&&(window.__tideHmrRefreshListeners=new Set);function Hj(){console.log("[Tide HMR] Manual scene refresh triggered");const t=Gp();if(t){try{t.dispose()}catch(n){console.warn("[Tide HMR] Error disposing scene:",n)}qu(null)}Eu(null),window.__tideScene&&(window.__tideScene=null);const e=document.getElementById("battlefield");if(e){const n=e.getContext("webgl2")||e.getContext("webgl");if(n){const s=n.getExtension("WEBGL_lose_context");s&&s.loseContext()}}window.__tideHmrPendingSceneChanges=!1,window.location.reload()}typeof window<"u"&&(window.__tideHmrSceneRefresh=Hj);function iO({canvasRef:t,selectionBoxRef:e,viewMode:n,sceneMountKey:s=0,showToast:a,showAgentNotification:r,toolboxModal:i,contextMenu:c,setHoveredAgentPopup:d,setBuildingPopup:f,getBuildingPopup:h,openBuildingModal:m,openPM2LogsModal:b,openBossLogsModal:y,openDatabasePanel:w,onSceneLoadingChange:C}){const N=x.useRef(null),k=x.useRef(null),j=x.useRef(null),S=x.useRef(null),T=x.useRef(null);return x.useEffect(()=>{if(n!=="3d"){C==null||C(!1);return}if(!t.current||!e.current)return;let D=!1;C==null||C(!0);const E=Gp(),O=zj()===t.current;function _(){var R,z,$,W,L,F,H,V;(R=N.current)==null||R.setOnToast(a),(z=N.current)==null||z.setOnBuildingClick((G,B)=>{U.selectBuilding(G);const K=U.getState().buildings.get(G);(K==null?void 0:K.type)==="folder"&&K.folderPath?U.openFileExplorer(K.folderPath):(K==null?void 0:K.type)==="server"||(K==null?void 0:K.type)==="boss"||(K==null?void 0:K.type)==="database"?(k.current&&clearTimeout(k.current),k.current=setTimeout(()=>{f({buildingId:G,screenPos:B,fromClick:!0}),k.current=null},150)):m(G)}),($=N.current)==null||$.setOnContextMenu((G,B,K)=>{c.open(G,B,K)}),(W=N.current)==null||W.setOnAgentHover(()=>{}),(L=N.current)==null||L.setOnBuildingHover((G,B)=>{const K=h();if(G&&B){const se=U.getState().buildings.get(G);((se==null?void 0:se.type)==="server"||(se==null?void 0:se.type)==="boss"||(se==null?void 0:se.type)==="database")&&!(K!=null&&K.fromClick)&&f({buildingId:G,screenPos:B,fromClick:!1})}else K!=null&&K.fromClick||f(null)}),(F=N.current)==null||F.setOnGroundClick(()=>{f(null)}),(H=N.current)==null||H.setOnAreaDoubleClick(G=>{U.selectArea(G),i.open()}),(V=N.current)==null||V.setOnBuildingDoubleClick(G=>{var K;k.current&&(clearTimeout(k.current),k.current=null),f(null);const B=U.getState().buildings.get(G);(B==null?void 0:B.type)==="server"&&((K=B.pm2)!=null&&K.enabled)?b==null||b(G):(B==null?void 0:B.type)==="boss"?y==null||y(G):(B==null?void 0:B.type)==="database"?w==null||w(G):(B==null?void 0:B.type)==="folder"&&B.folderPath?U.openFileExplorer(B.folderPath):m(G)})}if(E)try{N.current=E,O?(console.log("[Tide] Reusing existing scene (StrictMode remount)"),E.ensureRenderLoopRunning()):(console.log("[Tide] Reattaching persisted scene to new canvas"),E.reattach(t.current,e.current),Eu(t.current));const R=U.getState();E.syncAreas(),E.syncBuildings(),R.agents.size>0&&(console.log("[Tide] Re-syncing agents from store after remount:",R.agents.size),E.syncAgents(Array.from(R.agents.values()))),_()}catch(R){console.error("[Tide] Failed to reattach persisted 3D scene:",R),C==null||C(!1)}finally{S.current=requestAnimationFrame(()=>{T.current=requestAnimationFrame(()=>{C==null||C(!1),T.current=null}),S.current=null})}else{const R=t.current,z=e.current,$=async()=>{if(D){console.log("[Tide] Effect cleaned up before scene init, skipping"),C==null||C(!1);return}if(!R.isConnected||!z.isConnected){console.warn("[Tide] Canvas disconnected before initialization"),C==null||C(!1);return}(!R.clientWidth||!R.clientHeight)&&(console.log("[Tide] Canvas has no CSS dimensions, using window fallback"),R.style.width="100%",R.style.height="100%",R.offsetHeight),(!R.clientWidth||!R.clientHeight)&&(R.width=window.innerWidth,R.height=window.innerHeight),eO();try{const{SceneManager:W}=await vt(async()=>{const{SceneManager:H}=await import("./SceneManager-OOaJ_z8v.js");return{SceneManager:H}},__vite__mapDeps([6,4,3,1]));if(D){C==null||C(!1);return}const L=new W(R,z);N.current=L,qu(L),Eu(R);const F=Uj();L.setCharacterScale(F.characterScale),L.setScale3D(F.scale3d),L.setTimeMode(F.timeMode),L.setTerrainConfig(F.terrain),L.setFloorStyle(F.terrain.floorStyle,!0),L.setGridVisible(F.gridVisible),L.setAgentModelStyle(F.modelStyle),L.setIdleAnimation(F.animations.idleAnimation),L.setWorkingAnimation(F.animations.workingAnimation),L.setFpsLimit(F.fpsLimit),L.syncAreas(),L.syncBuildings(),L.loadCharacterModels().then(()=>{console.log("[Tide] Character models ready");const H=U.getState();H.customAgentClasses.size>0&&(console.log("[Tide] Applying custom classes from store:",H.customAgentClasses.size),L.setCustomAgentClasses(H.customAgentClasses)),H.agents.size>0&&(console.log("[Tide] Syncing agents from store:",H.agents.size),L.syncAgents(Array.from(H.agents.values()))),L.upgradeAgentModels()}).catch(H=>{console.warn("[Tide] Some models failed to load, using fallback:",H)}).finally(()=>{C==null||C(!1)}),_()}catch(W){console.error("[Tide] Failed to initialize 3D scene:",W),C==null||C(!1)}};j.current=requestAnimationFrame(()=>void $())}Mj({onAgentCreated:R=>{var z,$,W;(z=N.current)==null||z.addAgent(R),($=N.current)==null||$.refreshSelectionVisuals(),(W=window.__spawnModalSuccess)==null||W.call(window)},onAgentUpdated:(R,z)=>{var W;const $=U.getState().agents.get(R.id)||R;(W=N.current)==null||W.updateAgent($,z)},onAgentDeleted:R=>{var z;(z=N.current)==null||z.removeAgent(R)},onAgentsSync:R=>{var $;const z=Array.from(U.getState().agents.values());($=N.current)==null||$.syncAgents(z)},onAreasSync:()=>{var z,$;(z=N.current)==null||z.syncAreas();const R=Array.from(U.getState().agents.values());($=N.current)==null||$.syncAgents(R)},onSpawnError:()=>{var R;(R=window.__spawnModalError)==null||R.call(window)},onSpawnSuccess:()=>{var R;(R=window.__spawnModalSuccess)==null||R.call(window)},onDirectoryNotFound:R=>{var z;(z=window.__spawnModalDirNotFound)==null||z.call(window,R)},onToolUse:(R,z,$)=>{var W;(W=N.current)==null||W.showToolBubble(R,z,$)},onDelegation:(R,z)=>{var $;($=N.current)==null||$.showDelegationEffect(R,z)},onCustomClassesSync:R=>{var z,$;(z=N.current)==null||z.setCustomAgentClasses(R),($=N.current)==null||$.upgradeAgentModels()},onBuildingUpdated:R=>{var z;(z=N.current)==null||z.updateBuilding(R)},onSubagentStarted:R=>{var z;(z=N.current)==null||z.addSubagentEffect(R.id,R.parentAgentId,R.name,R.subagentType)},onSubagentCompleted:R=>{var W;const z=U.getSubagent(R)||U.getSubagentByToolUseId(R),$=(z==null?void 0:z.id)||R;(W=N.current)==null||W.completeSubagentEffect($),setTimeout(()=>{var L;(L=N.current)==null||L.removeSubagentEffect($)},3e4)}});const M=KR(()=>{if(N.current){N.current.syncAreas(),N.current.syncBuildings();const R=Array.from(U.getState().agents.values());N.current.syncAgents(R)}});return()=>{M(),D=!0,j.current!==null&&(cancelAnimationFrame(j.current),j.current=null),S.current!==null&&(cancelAnimationFrame(S.current),S.current=null),T.current!==null&&(cancelAnimationFrame(T.current),T.current=null),U.getState().viewMode!=="3d"&&rO()&&N.current&&(console.log("[Tide] 3D canvas unmounted - disposing scene to free memory"),MR(),N.current.dispose(),N.current=null,qu(null),Eu(null))}},[n,s]),N}function oO({showToast:t,showAgentNotification:e}){x.useEffect(()=>{Mj({onToast:t,onReconnect:()=>{U.triggerReconnect()},onAgentNotification:a=>{e(a)}}),JR()||(Hu(),$j(!0)),kR();let n;CR(a=>{a.type==="agent_notification"&&typeof a.agentId=="string"&&Nj(a.agentId)}).then(a=>{n=a});const s=()=>{console.log("[Tide] App resumed from background, reconnecting..."),setTimeout(()=>Hu(),100)};return window.addEventListener("tideAppResume",s),()=>{window.removeEventListener("tideAppResume",s),n==null||n()}},[t,e])}function lO(t){x.useEffect(()=>{let e="",n="",s=new Map;const a=r=>{var d;let i=!1;const c=new Map;for(const[f,h]of r){const b=`${h.position.x.toFixed(2)},${h.position.z.toFixed(2)},${h.status},${h.class},${h.isBoss},${((d=h.subordinateIds)==null?void 0:d.length)??0}`.split("").reduce((y,w)=>(y<<5)-y+w.charCodeAt(0),0);c.set(f,b),s.get(f)!==b&&(i=!0)}return c.size!==s.size&&(i=!0),{newVersion:c,changed:i}};return U.subscribe(()=>{var b;const r=U.getState(),i=Array.from(r.selectedAgentIds).sort().join(","),c=Array.from(r.selectedBuildingIds).sort().join(","),d=i!==e,f=c!==n,{newVersion:h,changed:m}=a(r.agents);(d||f||m)&&(e=i,n=c,s=h,(b=t.current)==null||b.refreshSelectionVisuals())})},[t])}function cO(t){x.useEffect(()=>{var s;(s=t.current)==null||s.syncAreas();let e=0,n=0;return U.subscribe(()=>{var c,d;const r=U.getState().areas;if(r.size!==e){e=r.size,n=Date.now(),(c=t.current)==null||c.syncAreas();return}let i=0;for(const[f,h]of r){let m=f.charCodeAt(0);m+=(h.width??0)+(h.height??0)+(h.radius??0),m+=Math.floor(h.center.x*100)+Math.floor(h.center.z*100),m+=(h.zIndex??0)*1e3;for(let b=0;b<h.name.length;b++)m+=h.name.charCodeAt(b);for(let b=0;b<h.color.length;b++)m+=h.color.charCodeAt(b);if(h.directoryGitCounts)for(const b of h.directoryGitCounts)m+=(b+1)*7;if(h.logo){m+=Math.floor((h.logo.opacity??.8)*1e3),m+=Math.floor(h.logo.width*100)+Math.floor(h.logo.height*100);for(let b=0;b<h.logo.position.length;b++)m+=h.logo.position.charCodeAt(b);if(h.logo.filename)for(let b=0;b<h.logo.filename.length;b++)m+=h.logo.filename.charCodeAt(b)}i^=m|0}i!==n&&(n=i,(d=t.current)==null||d.syncAreas())})},[t])}function uO(t){x.useEffect(()=>{var s;(s=t.current)==null||s.syncBuildings();let e=0,n=0;return U.subscribe(()=>{var c,d;const r=U.getState().buildings;if(r.size!==e){e=r.size,n=Date.now(),(c=t.current)==null||c.syncBuildings();return}let i=0;for(const[f,h]of r){i^=h.position.x*1e3+h.position.z|0,i^=(h.scale||1)*1e4|0;const m=`${h.style||""}${h.name}${h.status}${h.gitChangesCount||0}`;for(let b=0;b<m.length;b++)i=(i<<5)-i+m.charCodeAt(b)|0}i!==n&&(n=i,(d=t.current)==null||d.syncBuildings())})},[t])}function dO(t,e){x.useEffect(()=>{var n;(n=t.current)==null||n.highlightArea(e)},[t,e])}function fO(t,e){x.useEffect(()=>{var n;(n=t.current)==null||n.setPowerSaving(e)},[t,e])}function Pt(t,e,n,s,a={},r="global"){return{id:t,name:e,description:n,key:s,modifiers:a,enabled:!0,context:r}}const Lg=[Pt("toggle-commander","Toggle Commander","Open/close Commander View","k",{ctrl:!0}),Pt("toggle-commander-tab","Toggle Commander (Tab)","Open/close Commander View with Tab","Tab",{}),Pt("spawn-agent","Spawn Agent","Open new agent spawn modal","n",{alt:!0}),Pt("select-agent-1","Select Agent 1","Select first agent","1",{ctrl:!0}),Pt("select-agent-2","Select Agent 2","Select second agent","2",{ctrl:!0}),Pt("select-agent-3","Select Agent 3","Select third agent","3",{ctrl:!0}),Pt("select-agent-4","Select Agent 4","Select fourth agent","4",{ctrl:!0}),Pt("select-agent-5","Select Agent 5","Select fifth agent","5",{ctrl:!0}),Pt("select-agent-6","Select Agent 6","Select sixth agent","6",{ctrl:!0}),Pt("select-agent-7","Select Agent 7","Select seventh agent","7",{ctrl:!0}),Pt("select-agent-8","Select Agent 8","Select eighth agent","8",{ctrl:!0}),Pt("select-agent-9","Select Agent 9","Select ninth agent","9",{ctrl:!0}),Pt("delete-selected","Delete Selected","Remove selected agents","Delete",{}),Pt("delete-selected-backspace","Delete Selected (Backspace)","Remove selected agents","Backspace",{}),Pt("deselect-all","Deselect All","Clear agent selection","Escape",{}),Pt("open-terminal","Open Terminal","Open terminal for selected agent","Space",{}),Pt("dashboard-selector-toggle","Dashboard Selector","Enable dashboard card selector",",",{}),Pt("dashboard-vim-left","Dashboard Left","Move dashboard selector left","h",{}),Pt("dashboard-vim-down","Dashboard Down","Move dashboard selector down","j",{}),Pt("dashboard-vim-up","Dashboard Up","Move dashboard selector up","k",{}),Pt("dashboard-vim-right","Dashboard Right","Move dashboard selector right","l",{}),Pt("next-agent","Next Agent","Select next agent on battlefield","l",{alt:!0}),Pt("prev-agent","Previous Agent","Select previous agent on battlefield","h",{alt:!0}),Pt("next-working-agent","Next Working Agent","Select next working agent on battlefield","l",{alt:!0,shift:!0}),Pt("prev-working-agent","Previous Working Agent","Select previous working agent on battlefield","h",{alt:!0,shift:!0}),Pt("next-message","Next Message","Navigate to next message in terminal","j",{alt:!0}),Pt("prev-message","Previous Message","Navigate to previous message in terminal","k",{alt:!0}),Pt("page-down-messages","Page Down Messages","Jump down 10 messages in terminal","d",{alt:!0,shift:!0}),Pt("page-up-messages","Page Up Messages","Jump up 10 messages in terminal","u",{alt:!0}),Pt("next-agent-terminal","Next Agent (Terminal)","Switch to next agent in terminal","l",{alt:!0}),Pt("prev-agent-terminal","Previous Agent (Terminal)","Switch to previous agent in terminal","h",{alt:!0}),Pt("activate-message","Activate Message","Click on interactive element in selected message","Space",{}),Pt("toggle-file-explorer","Toggle File Explorer","Open/close file explorer","e",{alt:!0}),Pt("file-explorer-close-tab","Close File Tab","Close active file tab in explorer","w",{alt:!0}),Pt("toggle-spotlight","Toggle Spotlight","Open/close global search","p",{alt:!0}),Pt("open-database","Open Database","Open last used database query builder","d",{alt:!0}),Pt("toggle-2d-view","Cycle View Mode","Cycle between 3D, 2D, and Dashboard views","2",{alt:!0}),Pt("clear-context","Clear Context","Clear context of the selected agent","c",{alt:!0,shift:!0}),Pt("commander-close","Close Commander","Close Commander View","Escape",{},"commander"),Pt("commander-vim-left","Navigate Left","Move focus left (Vim H)","h",{alt:!0},"commander"),Pt("commander-vim-down","Navigate Down","Move focus down (Vim J)","j",{alt:!0},"commander"),Pt("commander-vim-up","Navigate Up","Move focus up (Vim K)","k",{alt:!0},"commander"),Pt("commander-vim-right","Navigate Right","Move focus right (Vim L)","l",{alt:!0},"commander"),Pt("commander-expand","Expand/Collapse","Toggle agent expansion","o",{alt:!0},"commander"),Pt("commander-new-agent","New Agent","Open spawn form in commander","n",{alt:!0},"commander"),Pt("commander-next-tab","Next Tab","Switch to next area tab","Tab",{},"commander"),Pt("commander-prev-tab","Previous Tab","Switch to previous area tab","Tab",{shift:!0},"commander"),Pt("toolbox-close","Close Toolbox","Close Settings panel","Escape",{},"toolbox")];function Tn(t,e){if(!e||!e.enabled)return!1;const{ctrl:n,alt:s,shift:a}=e.modifiers,r=n?t.ctrlKey||t.metaKey:!t.ctrlKey&&!t.metaKey,i=s?t.altKey:!t.altKey,c=a?t.shiftKey:!t.shiftKey;let d;if(n?d=(t.ctrlKey||t.metaKey)&&i&&c:d=r&&i&&c,!d)return!1;const f=e.key;if(f.length===1&&/^[a-zA-Z]$/.test(f)){const m=`Key${f.toUpperCase()}`;return t.code===m}if(f.length===1&&/^[0-9]$/.test(f)){const m=`Digit${f}`;return t.code===m}return f==="Space"||f===" "?t.code==="Space":t.key===f}function _q(t){const e=[];if(t.modifiers.ctrl){const s=navigator.platform.toUpperCase().indexOf("MAC")>=0;e.push(s?"⌘":"Ctrl")}if(t.modifiers.alt){const s=navigator.platform.toUpperCase().indexOf("MAC")>=0;e.push(s?"⌥":"Alt")}t.modifiers.shift&&e.push("Shift"),t.modifiers.meta&&e.push("⌘");let n=t.key;return n===" "?n="Space":n.length===1&&(n=n.toUpperCase()),e.push(n),e.join("+")}function Eq(t,e,n,s){return t.filter(a=>{if(a.id===n||!a.enabled||s&&a.context!=="global"&&a.context!==s)return!1;const r=h=>h===" "||h==="Space"?"Space":h.length===1?h.toLowerCase():h,i=r(a.key),c=r(e.key);if(i!==c)return!1;const d=a.modifiers,f=e.modifiers;return(d.ctrl||!1)===(f.ctrl||!1)&&(d.alt||!1)===(f.alt||!1)&&(d.shift||!1)===(f.shift||!1)&&(d.meta||!1)===(f.meta||!1)})}function pO({sceneRef:t,spawnModal:e,commanderModal:n,explorerModal:s,spotlightModal:a,deleteConfirmModal:r,onRequestBuildingDelete:i,onOpenDatabasePanel:c,onCloseDatabasePanel:d,databasePanelOpen:f}){x.useEffect(()=>{const h=m=>{var R,z,$,W;const b=U.getShortcuts(),y=m.target,w=y.tagName==="INPUT"||y.tagName==="TEXTAREA"||y.getAttribute("contenteditable")==="true"||!!y.closest(".cm-editor"),C=b.find(L=>L.id==="deselect-all");if(Tn(m,C)){if(y.closest(".guake-bottom-terminal-embed"))return;if(ep()){m.preventDefault();return}const L=U.getState();if(L.activeTool==="rectangle"||L.activeTool==="circle"){(R=t.current)==null||R.setDrawingTool(null),typeof window<"u"&&window.__tideScene2D_setDrawingTool&&window.__tideScene2D_setDrawingTool(null);return}e.isOpen?e.close():L.terminalOpen?(U.setTerminalOpen(!1),document.activeElement instanceof HTMLElement&&document.activeElement.blur()):(U.deselectAll(),(z=t.current)==null||z.refreshSelectionVisuals())}for(let L=1;L<=9;L++){const F=b.find(H=>H.id===`select-agent-${L}`);if(Tn(m,F)){m.preventDefault();const H=U.getState(),V=L-1,G=Array.from(H.agents.keys());V<G.length&&(U.selectAgent(G[V]),($=t.current)==null||$.refreshSelectionVisuals());return}}const N=b.find(L=>L.id==="spawn-agent");if(Tn(m,N)){m.preventDefault(),e.open();return}const k=b.find(L=>L.id==="toggle-commander-tab");if(Tn(m,k)&&!w){m.preventDefault(),n.toggle();return}const j=b.find(L=>L.id==="toggle-commander");if(Tn(m,j)){m.preventDefault(),n.toggle();return}const S=b.find(L=>L.id==="toggle-file-explorer");if(Tn(m,S)){m.preventDefault();const L=U.getState();if(s.isOpen||L.explorerFolderPath!==null||L.explorerAreaId!==null)s.close(),U.closeFileExplorer();else{const H=U.getLastExplorerState();if((H==null?void 0:H.type)==="folder")U.openFileExplorer(H.path);else if((H==null?void 0:H.type)==="area")if(L.areas.has(H.areaId))s.open(H.areaId);else{const V=Array.from(L.areas.values()).filter(G=>G.directories&&G.directories.length>0);V.length>0&&s.open(V[0].id)}else{const V=Array.from(L.areas.values()).filter(G=>G.directories&&G.directories.length>0);V.length>0&&s.open(V[0].id)}}return}if(m.altKey&&!m.ctrlKey&&!m.shiftKey&&!m.metaKey&&m.code==="KeyD"){if(m.preventDefault(),m.stopPropagation(),f){d();return}const L=localStorage.getItem("tide-commander-last-database-building"),F=U.getState();if(L){const H=F.buildings.get(L);if((H==null?void 0:H.type)==="database"){c(L);return}}for(const[H,V]of F.buildings)if(V.type==="database"){c(H);return}return}const T=b.find(L=>L.id==="toggle-spotlight");if(Tn(m,T)||m.altKey&&!m.ctrlKey&&!m.metaKey&&m.code==="KeyP"){console.log("[useKeyboardShortcuts] Spotlight shortcut matched!",{spotlightShortcut:T,altKey:m.altKey,code:m.code}),m.preventDefault(),a.toggle();return}const D=b.find(L=>L.id==="toggle-2d-view");if(Tn(m,D)){m.preventDefault();const L=U.getState().viewMode,F=L==="3d"?"2d":L==="2d"?"dashboard":"3d";U.setViewMode(F);return}const E=b.find(L=>L.id==="clear-context");if(Tn(m,E)){m.preventDefault();const L=U.getState(),F=L.selectedAgentIds.size===1?Array.from(L.selectedAgentIds)[0]:null;F&&U.clearContext(F);return}const I=b.find(L=>L.id==="next-working-agent"),O=b.find(L=>L.id==="prev-working-agent");if((Tn(m,I)||Tn(m,O))&&!w){const L=U.getState();if(L.terminalOpen)return;const F=Array.from(L.agents.values());let H=F.filter(K=>L.agentsWithUnseenOutput.has(K.id));if(H.length===0&&(H=F.filter(K=>K.status==="working")),H.length===0)return;m.preventDefault();const V=L.selectedAgentIds.size===1?Array.from(L.selectedAgentIds)[0]:null,G=V?H.findIndex(K=>K.id===V):-1;let B;Tn(m,I)?B=G===-1?0:(G+1)%H.length:B=G===-1?H.length-1:(G-1+H.length)%H.length,U.selectAgent(H[B].id),(W=t.current)==null||W.refreshSelectionVisuals();return}const _=b.find(L=>L.id==="delete-selected"),M=b.find(L=>L.id==="delete-selected-backspace");if((Tn(m,_)||Tn(m,M))&&!w){const L=U.getState();if(L.selectedAgentIds.size>0){m.preventDefault(),r.open();return}if(L.selectedBuildingIds.size>0){m.preventDefault(),i();return}return}};return document.addEventListener("keydown",h,!0),()=>document.removeEventListener("keydown",h,!0)},[t,e,n,s,a,r,i,c,d,f])}function hO(){const[t,e]=x.useState(!1);return window.__tideSetBackNavModal=e,x.useEffect(()=>{if(window.__tideBackNavSetup){window.location.hash.includes("app")||(window.location.hash="#app");return}window.__tideBackNavSetup=!0,window.location.hash.includes("app")||(window.location.hash="#app");const s=()=>window.innerWidth<=768;let a=0;const r=()=>{var c;Date.now()-a<200||window.location.hash.includes("app")||(window.location.hash="#app",s()&&(ep()||(c=window.__tideSetBackNavModal)==null||c.call(window,!0)))},i=()=>{var c;window.location.hash.includes("app")||(window.location.hash="#app"),window.location.hash==="#app"&&setTimeout(()=>{window.location.hash==="#app"&&!window.location.hash.includes("app2")&&(window.history.pushState(null,"","#app2"),window.history.pushState(null,"","#app"))},50),s()?ep()?a=Date.now():(c=window.__tideSetBackNavModal)==null||c.call(window,!0):(ep(),a=Date.now())};window.history.pushState(null,"","#app1"),window.history.pushState(null,"","#app2"),window.history.pushState(null,"","#app"),window.addEventListener("hashchange",r),window.addEventListener("popstate",i)},[]),{showBackNavModal:t,setShowBackNavModal:e,handleLeave:()=>{e(!1);const s=window.__tideHistoryDepth??2;window.history.go(-(s+1))}}}const Ig="agent-order-change";function mO(t){const e=x.useMemo(()=>new Set(t.map(d=>d.id)),[t]),[n,s]=x.useState(()=>Na(pt.AGENT_ORDER,[]));x.useEffect(()=>{const d=f=>{s(f.detail)};return window.addEventListener(Ig,d),()=>{window.removeEventListener(Ig,d)}},[]);const a=x.useMemo(()=>{const d=n.filter(b=>e.has(b)),f=t.filter(b=>!d.includes(b.id)).map(b=>b.id),h=[...d,...f],m=new Map(t.map(b=>[b.id,b]));return h.map(b=>m.get(b)).filter(b=>b!==void 0)},[t,n,e]),r=x.useCallback(d=>{s(d),La(pt.AGENT_ORDER,d),window.dispatchEvent(new CustomEvent(Ig,{detail:d}))},[]),i=x.useCallback((d,f)=>{const h=a.map(b=>b.id),[m]=h.splice(d,1);h.splice(f,0,m),r(h)},[a,r]),c=x.useCallback(()=>{s([]),La(pt.AGENT_ORDER,[])},[]);return x.useEffect(()=>{if(e.size===0)return;const d=n.filter(f=>e.has(f));d.length!==n.length&&r(d)},[e,n,r]),{orderedAgents:a,moveAgent:i,resetOrder:c}}function Ta(t){const e=x.useRef(null),n=x.useCallback(a=>{e.current=a.target,a.target===a.currentTarget&&a.stopPropagation()},[]),s=x.useCallback(a=>{a.target===a.currentTarget&&e.current===a.currentTarget&&(a.stopPropagation(),t()),e.current=null},[t]);return{handleMouseDown:n,handleClick:s}}const gO=3e4;function bO(){const t=x.useRef(null);x.useEffect(()=>{const e=async()=>{var i,c;const n=U.getState(),s=new Map,a=new Map;for(const[d,f]of n.buildings){const h=f.folderPath||f.cwd;h&&(a.has(h)||a.set(h,[]),a.get(h).push(d))}for(const[d,f]of a)try{const h=await Bt(Rt(`/api/files/git-status?path=${encodeURIComponent(d)}`));if(!h.ok)continue;const b=((i=(await h.json()).files)==null?void 0:i.length)||0;s.set(d,b);for(const y of f){const w=U.getState().buildings.get(y);w&&w.gitChangesCount!==b&&U.updateBuildingLocal(y,{gitChangesCount:b})}}catch{}const r=new Map;for(const[d,f]of n.areas)f.archived||!f.directories||f.directories.forEach((h,m)=>{h&&(r.has(h)||r.set(h,[]),r.get(h).push({areaId:d,dirIndex:m}))});if(r.size!==0)for(const[d,f]of r)try{let h;if(s.has(d))h=s.get(d);else{const b=await Bt(Rt(`/api/files/git-status?path=${encodeURIComponent(d)}`));if(!b.ok)continue;h=((c=(await b.json()).files)==null?void 0:c.length)||0,s.set(d,h)}const m=new Map;for(const b of f)m.has(b.areaId)||m.set(b.areaId,[]),m.get(b.areaId).push({dirIndex:b.dirIndex,count:h});for(const[b,y]of m){const w=U.getState().areas.get(b);if(!w)continue;const C=w.directoryGitCounts?[...w.directoryGitCounts]:new Array(w.directories.length).fill(0);let N=!1;for(const{dirIndex:k,count:j}of y)C[k]!==j&&(C[k]=j,N=!0);N&&U.updateAreaLocal(b,{directoryGitCounts:C})}}catch{}};return e(),t.current=setInterval(e,gO),()=>{t.current&&(clearInterval(t.current),t.current=null)}},[])}const Pg={historyLimit:500,hideCost:!0,showFPS:!1,powerSaving:!1,customAgentNames:[],experimental2DView:!1,experimentalVoiceAssistant:!1,experimentalTTS:!1,experimentalEchoPrompt:!1,externalEditorCommand:"",vibrationIntensity:1,tabTitle:""},iS=90,Bg=["simple","chat","advanced"],oS=55,lS=20,cS=95,xO=200,yO=12e4,vO=5,la=new Map;function wO(t){const e=la.get(t);e&&(la.delete(t),la.set(t,e))}function kO(){for(;la.size>vO;){const t=la.keys().next().value;if(t!==void 0)la.delete(t);else break}}function Wj(t){la.delete(t)}function SO(t){return t.trim().replace(/\r\n/g,`
43
- `)}function tx(t,e){return`${t}:${SO(e)}`}function uS(t,e,n,s){if(t.uuid&&e.has(t.uuid))return!1;const a=t.isUserPrompt?"user":"assistant",r=tx(a,t.text),i=t.timestamp||0,c=n.get(r);return c!==void 0&&Math.abs(i-c)<=yO?!1:i>s}function qj({selectedAgentId:t,hasSessionId:e,reconnectCount:n,historyRefreshTrigger:s,lastPrompts:a,outputScrollRef:r}){const[i,c]=x.useState([]),[d,f]=x.useState(!1),[h,m]=x.useState(!1),[b,y]=x.useState(0),[w,C]=x.useState(!1),[N,k]=x.useState(!1),[j,S]=x.useState(0),T=x.useRef(!0),D=x.useRef(0),E=x.useRef(0),I=x.useRef(!1),O=x.useRef(!1),_=x.useRef(null),M=x.useRef(!1),R=x.useRef(null),z=x.useRef(null);x.useEffect(()=>(T.current=!0,()=>{T.current=!1}),[]),x.useEffect(()=>{if(!t||!e){c([]),E.current=0,k(!1),O.current=!1,S(0),f(!1),m(!1),y(Z=>Z+1),M.current=!1,R.current=null;return}const V=`${t}:${n}:${s}`;if(R.current===V)return;const G=_.current!==null&&_.current!==t,B=n>0,K=G||B,se=!G&&!M.current&&e;_.current=t,M.current=e,R.current=V;let q;if(B){const Z=U.getOutputs(t);Z.length>0&&(q=Z.map(ie=>({...ie})))}z.current&&(clearTimeout(z.current),z.current=null),B&&la.delete(t),D.current+=1;const be=D.current;m(!0);const Ce=la.get(t);Ce?(wO(t),c(Ce.messages),E.current=Ce.messages.length,k(Ce.hasMore),O.current=Ce.hasMore,S(Ce.totalCount)):(c([]),E.current=0,k(!1),O.current=!1,S(0)),se||(z.current=setTimeout(()=>{f(!0)},150)),Bt(Rt(`/api/agents/${t}/history?limit=${iS}&offset=0`)).then(Z=>{if(!Z.ok)throw new Error(`HTTP ${Z.status}: ${Z.statusText}`);return Z.json()}).then(Z=>{if(be!==D.current)return;const ie=Array.isArray(Z.messages)?Z.messages:[],me=Array.isArray(Z.subagents)?Z.subagents:[];c(ie),E.current=ie.length;const Ee=Z.hasMore||!1;if(k(Ee),O.current=Ee,S(Z.totalCount||0),me.length>0&&U.hydrateSubagentsFromHistory(t,me),la.set(t,{messages:ie,hasMore:Ee,totalCount:Z.totalCount||0}),kO(),q&&q.length>0){const Te=ie.length>0?Math.max(...ie.map(ne=>ne.timestamp?new Date(ne.timestamp).getTime():0)):0,Ve=new Set(ie.map(ne=>ne.uuid).filter(ne=>typeof ne=="string"&&ne.length>0)),We=new Map;for(const ne of ie){if(ne.type!=="user"&&ne.type!=="assistant")continue;const Ne=tx(ne.type,ne.content),ze=ne.timestamp?new Date(ne.timestamp).getTime():0,st=We.get(Ne)??0;ze>st&&We.set(Ne,ze)}const ee=q.filter(ne=>uS(ne,Ve,We,Te));U.clearOutputs(t);for(const ne of ee)U.addOutput(t,ne)}else if(ie.length>0){const Te=Math.max(...ie.map(Ne=>Ne.timestamp?new Date(Ne.timestamp).getTime():0)),Ve=new Set(ie.map(Ne=>Ne.uuid).filter(Ne=>typeof Ne=="string"&&Ne.length>0)),We=new Map;for(const Ne of ie){if(Ne.type!=="user"&&Ne.type!=="assistant")continue;const ze=tx(Ne.type,Ne.content),st=Ne.timestamp?new Date(Ne.timestamp).getTime():0,pe=We.get(ze)??0;st>pe&&We.set(ze,st)}const ee=U.getOutputs(t),ne=ee.filter(Ne=>{const ze=uS(Ne,Ve,We,Te);return ze||console.warn(`[HISTORY-DEDUP] Removing live output: uuid=${Ne.uuid||"none"} ts=${Ne.timestamp} lastHistTs=${Te} text="${Ne.text.slice(0,80)}"`),ze});if(ee.length!==ne.length){console.warn(`[HISTORY-DEDUP] Cleared ${ee.length-ne.length}/${ee.length} overlapping outputs for agent ${t}`),U.clearOutputs(t);for(const Ne of ne)U.addOutput(t,Ne)}}if(!a.get(t)){for(let Te=ie.length-1;Te>=0;Te--)if(ie[Te].type==="user"){U.setLastPrompt(t,ie[Te].content);break}}}).catch(Z=>{if(console.error("Failed to load history:",Z),c([]),E.current=0,k(!1),O.current=!1,S(0),K&&q&&q.length>0){U.clearOutputs(t);for(const ie of q)U.addOutput(t,ie)}}).finally(()=>{T.current&&be===D.current&&(z.current&&(clearTimeout(z.current),z.current=null),f(!1),m(!1),y(Z=>Z+1))})},[t,e,n,s]);const $=x.useCallback(async()=>{if(!t||I.current||!O.current)return;const V=r.current;if(!V){console.warn("loadMoreHistory: outputScrollRef not connected");return}const G=V.scrollHeight-V.scrollTop;I.current=!0,C(!0);const B=E.current;try{const se=await(await Bt(Rt(`/api/agents/${t}/history?limit=${iS}&offset=${B}`))).json(),q=Array.isArray(se.subagents)?se.subagents:[];if(q.length>0&&U.hydrateSubagentsFromHistory(t,q),se.messages&&se.messages.length>0){if(!T.current)return;c(Ce=>{const Z=[...se.messages,...Ce];return E.current=Z.length,Z});const be=se.hasMore||!1;O.current=be,k(be),requestAnimationFrame(()=>{requestAnimationFrame(()=>{T.current&&(r.current&&(r.current.scrollTop=r.current.scrollHeight-G),I.current=!1,C(!1))})})}else{if(!T.current)return;I.current=!1,C(!1)}}catch(K){if(console.error("Failed to load more history:",K),!T.current)return;I.current=!1,C(!1)}},[t,r]),W=x.useCallback(V=>{if(!r.current||V.current)return;const{scrollTop:G}=r.current;!I.current&&O.current&&G<xO&&$()},[$,r]),L=x.useCallback(()=>{c([]),E.current=0,t&&la.delete(t)},[t]),F=x.useRef(!1),H=x.useCallback(async()=>{var V,G;if(!(!t||!O.current)&&!(I.current||F.current)){F.current=!0,I.current=!0,C(!0);try{const K=await(await Bt(Rt(`/api/agents/${t}/history?limit=100000&offset=0`))).json();if(!T.current)return;const se=Array.isArray(K.subagents)?K.subagents:[];se.length>0&&U.hydrateSubagentsFromHistory(t,se),K.messages&&K.messages.length>0&&(c(K.messages),E.current=K.messages.length),O.current=!1,k(!1),S(K.totalCount||((V=K.messages)==null?void 0:V.length)||0),la.set(t,{messages:K.messages||[],hasMore:!1,totalCount:K.totalCount||((G=K.messages)==null?void 0:G.length)||0})}catch(B){console.error("Failed to load all history:",B)}finally{T.current&&(I.current=!1,F.current=!1,C(!1))}}},[t]);return{history:i,loadingHistory:d,fetchingHistory:h,historyLoadVersion:b,loadingMore:w,hasMore:N,totalCount:j,isMountedRef:T,loadMoreHistory:$,loadAllHistory:H,allLoaded:!N,handleScroll:W,clearHistory:L,hasCachedHistory:x.useCallback(V=>la.has(V),[])}}function ru(...t){}function CO(t){return(t.tokensUsed??0)===0&&(t.contextUsed??0)===0&&!t.contextStats&&!t.sessionId&&!t.currentTask&&!t.lastAssignedTask}function dS(t,e){var r,i;if(!t||CO(e))return e;const n=((r=t.contextStats)==null?void 0:r.lastUpdated)??0,s=((i=e.contextStats)==null?void 0:i.lastUpdated)??0;return n>0&&n>s?{...e,contextUsed:t.contextUsed,contextLimit:t.contextLimit,contextStats:t.contextStats}:e}function AO(t,e,n,s,a){return{setAgents(r){const i=new Map,c=t().agents;for(const f of r){const h=c.get(f.id);i.set(f.id,dS(h,f)),(f.class==="boss"||f.isBoss)&&ru("[Store.setAgents] Boss agent:",f.name,"subordinateIds:",f.subordinateIds)}const d=r.find(f=>f.status==="working");e(f=>{f.agents=i,d&&f.selectedAgentIds.size===0&&(f.selectedAgentIds=new Set([d.id]),f.terminalOpen=!0)}),n()},addAgent(r){e(i=>{const c=new Map(i.agents);c.set(r.id,r),i.agents=c}),n()},updateAgent(r){var h;const c=t().agents.get(r.id),d=(c==null?void 0:c.status)!==r.status;d&&ru(`[Store] Agent ${r.name} status update: ${c==null?void 0:c.status} → ${r.status}`);let f=!1;e(m=>{const b=new Map(m.agents);b.set(r.id,dS(c,r)),m.agents=b,d&&(c==null?void 0:c.status)==="working"&&r.status==="idle"&&(m.terminalOpen&&m.selectedAgentIds.has(r.id)||(m.agentsWithUnseenOutput=new Set(m.agentsWithUnseenOutput),m.agentsWithUnseenOutput.add(r.id),ru(`[Store] Agent ${r.name} completed work - marked as unseen`),f=!0))}),f&&a&&a(),n(),d&&ru(`[Store] Agent ${r.name} status now in store: ${(h=t().agents.get(r.id))==null?void 0:h.status}`)},updateAgentContextStats(r,i){const d=t().agents.get(r);d&&(e(f=>{const h=new Map(f.agents);h.set(r,{...d,contextStats:i,contextUsed:i.totalTokens,contextLimit:i.contextWindow}),f.agents=h}),n())},updateAgentContext(r,i,c){const f=t().agents.get(r);if(f){const h=Math.max(1,c||2e5),m=Math.max(0,Math.min(100,Number((i/h*100).toFixed(1))));e(b=>{const y=new Map(b.agents),w=f.contextStats?{...f.contextStats,totalTokens:i,contextWindow:h,usedPercent:m,lastUpdated:Date.now()}:void 0;y.set(r,{...f,contextUsed:i,contextLimit:h,contextStats:w}),b.agents=y}),n()}},removeAgent(r){const i=t().agentsWithUnseenOutput.has(r);e(c=>{const d=new Map(c.agents);d.delete(r),c.agents=d;const f=new Set(c.selectedAgentIds);f.delete(r),c.selectedAgentIds=f,c.agentOutputs.delete(r),c.lastPrompts.delete(r),c.agentsWithUnseenOutput.has(r)&&(c.agentsWithUnseenOutput=new Set(c.agentsWithUnseenOutput),c.agentsWithUnseenOutput.delete(r)),c.delegationHistories.delete(r),c.lastDelegationReceived.delete(r),c.agentTaskProgress.delete(r),c.supervisor.narratives.delete(r),c.supervisor.agentHistories.delete(r),c.supervisor.historyFetchedForAgents.delete(r),c.subagents.delete(r)}),Wj(r),i&&a&&a(),n()},selectAgent(r){let i=!1;e(c=>{c.selectedAgentIds=new Set(r?[r]:[]),r&&(c.lastSelectedAgentId=r,c.agentsWithUnseenOutput.has(r)&&(c.agentsWithUnseenOutput=new Set(c.agentsWithUnseenOutput),c.agentsWithUnseenOutput.delete(r),i=!0)),c.currentSnapshot=null}),i&&a&&a(),n()},addToSelection(r){let i=!1;e(c=>{const d=new Set(c.selectedAgentIds);d.has(r)?d.delete(r):(d.add(r),c.agentsWithUnseenOutput.has(r)&&(c.agentsWithUnseenOutput=new Set(c.agentsWithUnseenOutput),c.agentsWithUnseenOutput.delete(r),i=!0)),c.selectedAgentIds=d}),i&&a&&a(),n()},selectMultiple(r){e(i=>{i.selectedAgentIds=new Set(r)}),n()},deselectAll(){e(r=>{r.selectedAgentIds=new Set}),n()},spawnAgent(r,i,c,d,f,h,m,b,y,w,C,N,k,j,S){ru("[Store] spawnAgent called with:",{name:r,agentClass:i,cwd:c,position:d,sessionId:f,useChrome:h,permissionMode:m,initialSkillIds:b,provider:y,codexConfig:w,codexModel:C,model:N,effort:j,opencodeModel:S,customInstructions:k?`${k.length} chars`:void 0});const T=d?{x:d.x,y:0,z:d.z}:void 0,D={type:"spawn_agent",payload:{name:r,class:i,cwd:c,position:T,sessionId:f,useChrome:h,permissionMode:m,initialSkillIds:b,provider:y,codexConfig:w,codexModel:C,opencodeModel:S,model:N,effort:j,customInstructions:k}},E=s();if(!E){console.error("[Store] sendMessage is not defined! WebSocket may not be connected");return}E(D)},createDirectoryAndSpawn(r,i,c){var d;(d=s())==null||d({type:"create_directory",payload:{path:r,name:i,class:c}})},sendCommand(r,i){var c;e(d=>{d.lastPrompts.set(r,{text:i,timestamp:Date.now()})}),n(),(c=s())==null||c({type:"send_command",payload:{agentId:r,command:i}})},refreshAgentContext(r){var i;(i=s())==null||i({type:"request_context_stats",payload:{agentId:r}})},moveAgentLocal(r,i){const d=t().agents.get(r);d&&(e(f=>{const h={...d,position:i},m=new Map(f.agents);m.set(r,h),f.agents=m}),n())},moveAgent(r,i){var f;const d=t().agents.get(r);d&&(e(h=>{const m={...d,position:i},b=new Map(h.agents);b.set(r,m),h.agents=b}),n()),(f=s())==null||f({type:"move_agent",payload:{agentId:r,position:i}})},killAgent(r){var i;(i=s())==null||i({type:"kill_agent",payload:{agentId:r}})},stopAgent(r){var i;(i=s())==null||i({type:"stop_agent",payload:{agentId:r}})},clearContext(r){var i;(i=s())==null||i({type:"clear_context",payload:{agentId:r}}),e(c=>{const d=c.agents.get(r);if(d){const y={...d,status:"idle",currentTask:void 0,taskLabel:void 0,currentTool:void 0,lastAssignedTask:void 0,lastAssignedTaskTime:void 0,sessionId:void 0,tokensUsed:0,contextUsed:0,contextStats:void 0},w=new Map(c.agents);w.set(r,y),c.agents=w}const f=new Map(c.agentOutputs);f.delete(r),c.agentOutputs=f;const h=new Map(c.lastPrompts);h.delete(r),c.lastPrompts=h;const m=new Map(c.subagents);let b=!1;for(const[y,w]of m)w.parentAgentId===r&&(m.delete(y),b=!0);b&&(c.subagents=m)}),n()},collapseContext(r){var i;(i=s())==null||i({type:"collapse_context",payload:{agentId:r}})},removeAgentFromServer(r){var i;(i=s())==null||i({type:"remove_agent",payload:{agentId:r}})},renameAgent(r,i){var f;const d=t().agents.get(r);d&&(e(h=>{const m={...d,name:i},b=new Map(h.agents);b.set(r,m),h.agents=b}),n()),(f=s())==null||f({type:"rename_agent",payload:{agentId:r,name:i}})},updateAgentProperties(r,i){var f;const d=t().agents.get(r);d&&(e(h=>{const m={...d};i.class!==void 0&&(m.class=i.class),i.permissionMode!==void 0&&(m.permissionMode=i.permissionMode),i.model!==void 0&&(m.model=i.model),i.effort!==void 0&&(m.effort=i.effort),i.provider!==void 0&&(m.provider=i.provider),i.codexConfig!==void 0&&(m.codexConfig=i.codexConfig),i.codexModel!==void 0&&(m.codexModel=i.codexModel),i.opencodeModel!==void 0&&(m.opencodeModel=i.opencodeModel),i.useChrome!==void 0&&(m.useChrome=i.useChrome),i.cwd!==void 0&&(m.cwd=i.cwd);const b=new Map(h.agents);b.set(r,m),h.agents=b}),n()),(f=s())==null||f({type:"update_agent_properties",payload:{agentId:r,updates:i}})},getTotalTokens(){let r=0;for(const i of t().agents.values())r+=i.tokensUsed;return r},getSelectedAgents(){const r=t(),i=[];for(const c of r.selectedAgentIds){const d=r.agents.get(c);d&&i.push(d)}return i},addActivity(r){e(i=>{i.activities.unshift(r),i.activities.length>100&&i.activities.pop()}),n()},addToolExecution(r,i,c){const f=t().agents.get(r);e(h=>{h.toolExecutions.unshift({agentId:r,agentName:(f==null?void 0:f.name)||"Unknown",toolName:i,toolInput:c,timestamp:Date.now()}),h.toolExecutions.length>200&&h.toolExecutions.pop()}),n()},addFileChange(r,i,c){const f=t().agents.get(r);e(h=>{h.fileChanges.unshift({agentId:r,agentName:(f==null?void 0:f.name)||"Unknown",action:i,filePath:c,timestamp:Date.now()}),h.fileChanges.length>200&&h.fileChanges.pop()}),n()},async loadToolHistory(){try{const i=await(await Bt(Rt("/api/agents/tool-history?limit=100"))).json();e(c=>{i.toolExecutions&&(c.toolExecutions=i.toolExecutions),i.fileChanges&&(c.fileChanges=i.fileChanges)}),n()}catch(r){console.error("[Store] Failed to load tool history:",r)}}}}const fS=200;function pS(t){return t.length<=fS?t:t.slice(-fS)}function jO(t,e,n,s){return{addOutput(a,r){const i=s();e(c=>{const d=c.agentOutputs.get(a)||[];if(r.uuid&&d.some(b=>b.uuid===r.uuid))return;const f=pS([...d,r]);Uu.info(`Store: ${d.length} -> ${f.length}`,{agentId:a,text:r.text.slice(0,60),isStreaming:r.isStreaming,listeners:i},"store:addOutput");const h=new Map(c.agentOutputs);h.set(a,f),c.agentOutputs=h}),n()},clearOutputs(a){e(r=>{const i=new Map(r.agentOutputs);i.delete(a),r.agentOutputs=i}),n()},getOutputs(a){return t().agentOutputs.get(a)||[]},addUserPromptToOutput(a,r){this.addOutput(a,{text:r,isStreaming:!1,timestamp:Date.now(),isUserPrompt:!0})},getLastPrompt(a){return t().lastPrompts.get(a)},setLastPrompt(a,r){e(i=>{i.lastPrompts.set(a,{text:r,timestamp:Date.now()})}),n()},preserveOutputs(){const a=t(),r=new Map;for(const[i,c]of a.agentOutputs)r.set(i,c.map(d=>({...d})));return r},mergeOutputsWithHistory(a,r,i){let c=[...r,...i];return c.sort((d,f)=>d.timestamp-f.timestamp),c=pS(c),e(d=>{const f=new Map(d.agentOutputs);f.set(a,c),d.agentOutputs=f}),n(),c}}}function NO(t,e,n,s){return{setSupervisorReport(a){e(r=>{r.supervisor.lastReport=a,r.supervisor.lastReportTime=a.timestamp;const i=new Map(r.supervisor.agentHistories);for(const c of a.agentSummaries){const d=i.get(c.agentId)||[],f={id:`${a.id}-${c.agentId}`,timestamp:a.timestamp,reportId:a.id,analysis:c};if(!d.some(h=>h.reportId===a.id)){const h=[f,...d];h.length>50&&h.pop(),i.set(c.agentId,h)}}r.supervisor.agentHistories=i,r.supervisor.generatingReport=!1}),n()},addNarrative(a,r){e(i=>{const c=i.supervisor.narratives.get(a)||[];c.unshift(r),c.length>50&&c.pop();const d=new Map(i.supervisor.narratives);d.set(a,c),i.supervisor.narratives=d}),n()},getNarratives(a){return t().supervisor.narratives.get(a)||[]},setSupervisorStatus(a){e(r=>{r.supervisor.enabled=a.enabled,a.autoReportOnComplete!==void 0&&(r.supervisor.autoReportOnComplete=a.autoReportOnComplete),r.supervisor.lastReportTime=a.lastReportTime,r.supervisor.nextReportTime=a.nextReportTime}),n()},setSupervisorConfig(a){var r;(r=s())==null||r({type:"set_supervisor_config",payload:a})},requestSupervisorReport(){var a;e(r=>{r.supervisor.generatingReport=!0}),n(),(a=s())==null||a({type:"request_supervisor_report",payload:{}})},requestAgentSupervisorHistory(a){var r;e(i=>{i.supervisor.loadingHistoryForAgent=a}),n(),(r=s())==null||r({type:"request_agent_supervisor_history",payload:{agentId:a}})},setAgentSupervisorHistory(a){e(r=>{const i=new Map(r.supervisor.agentHistories);i.set(a.agentId,a.entries),r.supervisor.agentHistories=i,r.supervisor.historyFetchedForAgents.add(a.agentId),r.supervisor.loadingHistoryForAgent===a.agentId&&(r.supervisor.loadingHistoryForAgent=null)}),n()},getAgentSupervisorHistory(a){return t().supervisor.agentHistories.get(a)||[]},addAgentAnalysis(a,r){e(i=>{const c=new Map(i.supervisor.agentHistories),d=c.get(a)||[],f={id:`single-${Date.now()}-${a}`,timestamp:Date.now(),reportId:`single-${Date.now()}`,analysis:r};if(!d.some(m=>Math.abs(m.timestamp-f.timestamp)<5e3&&m.analysis.statusDescription===r.statusDescription)){const m=[f,...d];m.length>50&&m.pop(),c.set(a,m),i.supervisor.agentHistories=c}}),n()},isLoadingHistoryForAgent(a){return t().supervisor.loadingHistoryForAgent===a},hasHistoryBeenFetched(a){return t().supervisor.historyFetchedForAgents.has(a)},setGlobalUsage(a){console.log("[Supervisor] setGlobalUsage called with:",a),e(r=>{r.supervisor.globalUsage=a,r.supervisor.refreshingUsage=!1}),n()},requestGlobalUsage(){console.log("[Supervisor] requestGlobalUsage called"),e(r=>{r.supervisor.refreshingUsage=!0}),n();const a=s();console.log("[Supervisor] sendMessage function:",a?"available":"null"),a?(console.log("[Supervisor] Sending request_global_usage message"),a({type:"request_global_usage",payload:{}})):console.warn("[Supervisor] Cannot send request_global_usage - no sendMessage function")},getGlobalUsage(){return t().supervisor.globalUsage}}}function TO(t,e,n,s){const a=()=>{var c;const i=Array.from(t().areas.values());(c=s())==null||c({type:"sync_areas",payload:i})},r=()=>{e(i=>{i.areas=new Map(i.areas)})};return{setActiveTool(i){e(c=>{c.activeTool=i,i!=="select"&&(c.selectedAreaId=null)}),n()},selectArea(i){e(c=>{c.selectedAreaId=i}),n()},addArea(i){if(i.zIndex===void 0||i.zIndex===null){const c=Array.from(t().areas.values()),d=c.length===0?-1:Math.max(...c.map(f=>f.zIndex??0));i.zIndex=d+1}e(c=>{c.areas.set(i.id,i)}),r(),a(),n()},updateArea(i,c){t().areas.get(i)&&(e(h=>{Object.assign(h.areas.get(i),c)}),r(),a(),n())},updateAreaLocal(i,c){t().areas.get(i)&&(e(h=>{Object.assign(h.areas.get(i),c)}),r(),n())},deleteArea(i){e(c=>{c.areas.delete(i),c.selectedAreaId===i&&(c.selectedAreaId=null)}),r(),a(),n()},assignAgentToArea(i,c){const f=t().areas.get(c);f&&!f.assignedAgentIds.includes(i)&&(e(h=>{for(const m of h.areas.values()){const b=m.assignedAgentIds.indexOf(i);b!==-1&&m.assignedAgentIds.splice(b,1)}h.areas.get(c).assignedAgentIds.push(i)}),r(),a(),n())},unassignAgentFromArea(i,c){const f=t().areas.get(c);if(f){const h=f.assignedAgentIds.indexOf(i);h!==-1&&(e(m=>{m.areas.get(c).assignedAgentIds.splice(h,1)}),r(),a(),n())}},addDirectoryToArea(i,c){const f=t().areas.get(i);f&&!f.directories.includes(c)&&(e(h=>{h.areas.get(i).directories.push(c)}),r(),a(),n())},removeDirectoryFromArea(i,c){const f=t().areas.get(i);if(f){const h=f.directories.indexOf(c);h!==-1&&(e(m=>{m.areas.get(i).directories.splice(h,1)}),r(),a(),n())}},getAreaDirectories(i){const c=t().areas.get(i);return(c==null?void 0:c.directories)||[]},isPositionInArea(i,c){if(c.type==="rectangle"&&c.width&&c.height){const d=c.width/2,f=c.height/2;return i.x>=c.center.x-d&&i.x<=c.center.x+d&&i.z>=c.center.z-f&&i.z<=c.center.z+f}else if(c.type==="circle"&&c.radius){const d=i.x-c.center.x,f=i.z-c.center.z;return d*d+f*f<=c.radius*c.radius}return!1},getAreaForAgent(i){const c=t(),d=c.agents.get(i);if(!d)return null;for(const f of c.areas.values())if(this.isPositionInArea({x:d.position.x,z:d.position.z},f))return f;return null},setAreasFromServer(i){e(c=>{const d=new Map;for(let f=0;f<i.length;f++){const h=i[f];if(!h.center||typeof h.center.x!="number"||typeof h.center.z!="number"||!h.type){console.error(`[Areas] Skipping malformed area "${(h==null?void 0:h.id)??(h==null?void 0:h.name)??"unknown"}": missing center or type`);continue}h.directories||(h.directories=[]),(h.zIndex===void 0||h.zIndex===null)&&(h.zIndex=f),h.archived===void 0&&(h.archived=!1),d.set(h.id,h)}c.areas=d}),n()},getAreasInZOrder(){return Array.from(t().areas.values()).sort((c,d)=>(c.zIndex??0)-(d.zIndex??0))},getNextZIndex(){const i=Array.from(t().areas.values());return i.length===0?0:Math.max(...i.map(d=>d.zIndex??0))+1},bringAreaToFront(i){const c=t(),d=c.areas.get(i);if(!d)return;const f=Array.from(c.areas.values()),h=f.length===0?-1:Math.max(...f.map(w=>w.zIndex??0)),m=h+1,b=d.zIndex??0,y=f.filter(w=>(w.zIndex??0)===h);b===h&&y.length===1||(e(w=>{w.areas.get(i).zIndex=m}),r(),a(),n())},sendAreaToBack(i){const c=t(),d=c.areas.get(i);if(!d)return;const f=Array.from(c.areas.values()),h=Math.min(...f.map(y=>y.zIndex??0)),m=d.zIndex??0,b=f.filter(y=>(y.zIndex??0)===h);m===h&&b.length===1||(e(y=>{for(const w of y.areas.values())w.id!==i&&(w.zIndex=(w.zIndex??0)+1);y.areas.get(i).zIndex=0}),r(),a(),n())},setAreaZIndex(i,c){t().areas.get(i)&&(e(h=>{h.areas.get(i).zIndex=c}),r(),a(),n())},archiveArea(i,c){const f=t().areas.get(i);if(!(!f||f.archived)){if(c)for(const h of f.assignedAgentIds)c(h);e(h=>{const m=h.areas.get(i);m.archived=!0,m.archivedAt=Date.now(),m.originalCenter={...m.center},h.selectedAreaId===i&&(h.selectedAreaId=null)}),r(),a(),n()}},restoreArchivedArea(i,c){const d=t(),f=d.areas.get(i);if(!f||!f.archived)return;const h=f.center,m=c||f.originalCenter||f.center,b=m.x-h.x,y=m.z-h.z,w=Array.from(d.areas.values()),N=(w.length===0?-1:Math.max(...w.map(k=>k.zIndex??0)))+1;e(k=>{const j=k.areas.get(i);if(j.archived=!1,j.archivedAt=void 0,j.center=m,j.zIndex=N,b!==0||y!==0)for(const S of j.assignedAgentIds){const T=k.agents.get(S);T&&(T.position={x:T.position.x+b,y:T.position.y,z:T.position.z+y})}}),r(),a(),n()},getArchivedAreas(){return Array.from(t().areas.values()).filter(i=>i.archived===!0)},getVisibleAreas(){return Array.from(t().areas.values()).filter(i=>!i.archived)},isAgentInArchivedArea(i){const c=t();for(const d of c.areas.values())if(d.archived&&d.assignedAgentIds.includes(i))return!0;return!1}}}const Vj="tide:bottom-pm2-log-retention",Fg=5e3,_O=[1e3,2500,5e3,1e4,null];function Yj(){if(typeof window>"u")return Fg;try{const t=window.localStorage.getItem(Vj);if(!t)return Fg;if(t==="unlimited")return null;const e=Number(t);if(Number.isFinite(e)&&e>0)return Math.floor(e)}catch{}return Fg}function EO(t){if(!(typeof window>"u"))try{window.localStorage.setItem(Vj,t===null?"unlimited":String(t))}catch{}}function Gj(t,e){if(!t||e===null)return t;const n=t.split(`
44
- `);return n.length<=e?t:n.slice(-e).join(`
45
- `)}function MO(t,e,n,s){const a=()=>{var c;const i=Array.from(t().buildings.values());(c=s())==null||c({type:"sync_buildings",payload:i})},r={selectBuilding(i){e(c=>{c.selectedBuildingIds.clear(),i&&c.selectedBuildingIds.add(i)}),n()},selectMultipleBuildings(i){e(c=>{c.selectedBuildingIds.clear();for(const d of i)c.selectedBuildingIds.add(d)}),n()},toggleBuildingSelection(i){e(c=>{c.selectedBuildingIds.has(i)?c.selectedBuildingIds.delete(i):c.selectedBuildingIds.add(i)}),n()},isBuildingSelected(i){return t().selectedBuildingIds.has(i)},getSelectedBuildingIds(){return Array.from(t().selectedBuildingIds)},deleteSelectedBuildings(){var c,d,f;const i=t();for(const h of i.selectedBuildingIds){const m=i.buildings.get(h);((c=m==null?void 0:m.pm2)!=null&&c.enabled||(d=m==null?void 0:m.docker)!=null&&d.enabled)&&((f=s())==null||f({type:"building_command",payload:{buildingId:h,command:"delete"}}))}e(h=>{const m=new Map(h.buildings);for(const b of h.selectedBuildingIds)m.delete(b);h.buildings=m,h.selectedBuildingIds.clear()}),a(),n()},addBuilding(i){e(c=>{const d=new Map(c.buildings);d.set(i.id,i),c.buildings=d}),a(),n()},updateBuilding(i,c){const f=t().buildings.get(i);f&&(e(h=>{const m=new Map(h.buildings);m.set(i,{...f,...c}),h.buildings=m}),a(),n())},updateBuildingLocal(i,c){const f=t().buildings.get(i);f&&(e(h=>{const m=new Map(h.buildings);m.set(i,{...f,...c}),h.buildings=m}),n())},deleteBuilding(i){var f,h,m;const d=t().buildings.get(i);((f=d==null?void 0:d.pm2)!=null&&f.enabled||(h=d==null?void 0:d.docker)!=null&&h.enabled)&&((m=s())==null||m({type:"building_command",payload:{buildingId:i,command:"delete"}})),e(b=>{const y=new Map(b.buildings);y.delete(i),b.buildings=y,b.selectedBuildingIds.delete(i)}),a(),n()},moveBuilding(i,c){const f=t().buildings.get(i);f&&(e(h=>{const m=new Map(h.buildings);m.set(i,{...f,position:c}),h.buildings=m}),a(),n())},updateBuildingPosition(i,c){r.moveBuilding(i,c)},createBuilding(i){const c={...i,id:`building_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,status:"stopped",createdAt:Date.now()};r.addBuilding(c)},sendBuildingCommand(i,c){var d;(d=s())==null||d({type:"building_command",payload:{buildingId:i,command:c}})},addBuildingLogs(i,c){e(d=>{const h=[...d.buildingLogs.get(i)||[],c];h.length>500&&h.splice(0,h.length-500);const m=new Map(d.buildingLogs);m.set(i,h),d.buildingLogs=m}),n()},getBuildingLogs(i){return t().buildingLogs.get(i)||[]},clearBuildingLogs(i){e(c=>{const d=new Map(c.buildingLogs);d.delete(i),c.buildingLogs=d}),n()},setBuildingsFromServer(i){e(c=>{const d=new Map;for(const f of i)d.set(f.id,f);c.buildings=d}),n()},updateBuildingFromServer(i){e(c=>{const d=new Map(c.buildings);d.set(i.id,i),c.buildings=d}),n()},removeBuildingFromServer(i){e(c=>{const d=new Map(c.buildings);d.delete(i),c.buildings=d,c.selectedBuildingIds.delete(i)}),n()},startLogStreaming(i,c=100){var f,h,m;const d=t().buildings.get(i);e(b=>{const y=new Map(b.streamingBuildingLogs);y.set(i,""),b.streamingBuildingLogs=y}),(f=d==null?void 0:d.docker)!=null&&f.enabled?(h=s())==null||h({type:"docker_logs_start",payload:{buildingId:i,lines:c}}):(m=s())==null||m({type:"pm2_logs_start",payload:{buildingId:i,lines:c}})},stopLogStreaming(i){var d,f,h;const c=t().buildings.get(i);(d=c==null?void 0:c.docker)!=null&&d.enabled?(f=s())==null||f({type:"docker_logs_stop",payload:{buildingId:i}}):(h=s())==null||h({type:"pm2_logs_stop",payload:{buildingId:i}})},appendStreamingLogChunk(i,c){e(d=>{const f=d.streamingBuildingLogs.get(i)||"",h=Yj(),m=Gj(f+c,h),b=new Map(d.streamingBuildingLogs);b.set(i,m),d.streamingBuildingLogs=b}),n()},setStreamingStatus(i,c){e(d=>{const f=new Set(d.streamingBuildingIds);c?f.add(i):f.delete(i),d.streamingBuildingIds=f}),n()},getStreamingLogs(i){return t().streamingBuildingLogs.get(i)||""},clearStreamingLogs(i){e(c=>{const d=new Map(c.streamingBuildingLogs);d.delete(i),c.streamingBuildingLogs=d}),n()},isLogStreaming(i){return t().streamingBuildingIds.has(i)},sendBossBuildingCommand(i,c){var d;(d=s())==null||d({type:"boss_building_command",payload:{buildingId:i,command:c}})},assignBuildingsToBoSS(i,c){var h;const f=t().buildings.get(i);f&&(e(m=>{const b=new Map(m.buildings);b.set(i,{...f,subordinateBuildingIds:c}),m.buildings=b}),a(),n()),(h=s())==null||h({type:"assign_buildings",payload:{bossBuildingId:i,subordinateBuildingIds:c}})},startBossLogStreaming(i,c=50){var d;e(f=>{const h=new Map(f.bossStreamingLogs);h.set(i,[]),f.bossStreamingLogs=h}),(d=s())==null||d({type:"boss_building_logs_start",payload:{buildingId:i,lines:c}})},stopBossLogStreaming(i){var c;(c=s())==null||c({type:"boss_building_logs_stop",payload:{buildingId:i}})},appendBossStreamingLogChunk(i,c,d,f,h){e(m=>{const b=m.bossStreamingLogs.get(i)||[],y={subordinateId:c,subordinateName:d,chunk:f,timestamp:Date.now(),isError:h},w=[...b,y];w.length>1e3&&w.splice(0,w.length-1e3);const C=new Map(m.bossStreamingLogs);C.set(i,w),m.bossStreamingLogs=C}),n()},getBossStreamingLogs(i){return t().bossStreamingLogs.get(i)||[]},clearBossStreamingLogs(i){e(c=>{const d=new Map(c.bossStreamingLogs);d.delete(i),c.bossStreamingLogs=d}),n()},requestDockerContainersList(){var i;(i=s())==null||i({type:"docker_list_containers",payload:{}})},setDockerContainersList(i,c){e(d=>{d.dockerContainersList=i,d.dockerComposeProjectsList=c}),n()},getDockerContainersList(){return t().dockerContainersList},getDockerComposeProjectsList(){return t().dockerComposeProjectsList}};return r}function DO(t,e,n,s){return{addPermissionRequest(a){e(r=>{const i=new Map(r.permissionRequests);i.set(a.id,a),r.permissionRequests=i}),n()},resolvePermissionRequest(a,r){const c=t().permissionRequests.get(a);c&&(e(d=>{const f=new Map(d.permissionRequests);f.set(a,{...c,status:r?"approved":"denied"}),d.permissionRequests=f}),n(),setTimeout(()=>{e(d=>{const f=new Map(d.permissionRequests);f.delete(a),d.permissionRequests=f}),n()},2e3))},respondToPermissionRequest(a,r,i,c){var d;(d=s())==null||d({type:"permission_response",payload:{requestId:a,approved:r,reason:i,remember:c}})},getPendingPermissionsForAgent(a){return Array.from(t().permissionRequests.values()).filter(r=>r.agentId===a&&r.status==="pending")},clearAllPermissions(){e(a=>{a.permissionRequests=new Map}),n()}}}function RO(t,e,n,s){return{spawnBossAgent(a,r,i,c,d,f,h,m,b,y,w,C,N){var j;const k=c?{x:c.x,y:0,z:c.z}:void 0;(j=s())==null||j({type:"spawn_boss_agent",payload:{name:a,class:r,cwd:i,position:k,subordinateIds:d,useChrome:f,permissionMode:h,provider:m,codexConfig:b,codexModel:y,model:w,customInstructions:C,initialSkillIds:N}})},assignSubordinates(a,r){var i;(i=s())==null||i({type:"assign_subordinates",payload:{bossId:a,subordinateIds:r}})},removeSubordinate(a,r){var i;(i=s())==null||i({type:"remove_subordinate",payload:{bossId:a,subordinateId:r}})},sendBossCommand(a,r){var i;e(c=>{c.pendingDelegation={bossId:a,command:r}}),n(),(i=s())==null||i({type:"send_boss_command",payload:{bossId:a,command:r}})},requestDelegationHistory(a){var r;(r=s())==null||r({type:"request_delegation_history",payload:{bossId:a}})},handleDelegationDecision(a){e(r=>{var f;const i=new Map(r.delegationHistories),c=i.get(a.bossId)||[],d=c.findIndex(h=>h.id===a.id);if(d!==-1?c[d]=a:(c.unshift(a),c.length>100&&c.pop()),i.set(a.bossId,c),r.delegationHistories=i,a.status==="sent"&&a.selectedAgentId){const h=r.agents.get(a.bossId),m=new Map(r.lastDelegationReceived);m.set(a.selectedAgentId,{bossName:(h==null?void 0:h.name)||"Boss",taskCommand:a.userCommand,timestamp:Date.now()}),r.lastDelegationReceived=m}((f=r.pendingDelegation)==null?void 0:f.bossId)===a.bossId&&a.status!=="pending"&&(r.pendingDelegation=null)}),n()},setDelegationHistory(a,r){e(i=>{const c=new Map(i.delegationHistories);c.set(a,r),i.delegationHistories=c}),n()},getDelegationHistory(a){return t().delegationHistories.get(a)||[]},getLastDelegationReceived(a){return t().lastDelegationReceived.get(a)||null},clearLastDelegationReceived(a){t().lastDelegationReceived.has(a)&&(e(i=>{const c=new Map(i.lastDelegationReceived);c.delete(a),i.lastDelegationReceived=c}),n())},updateBossSubordinates(a,r){const c=t().agents.get(a);c&&(e(d=>{const f={...c,subordinateIds:r},h=new Map(d.agents);h.set(a,f),d.agents=h}),n())},getSubordinates(a){const r=t(),i=r.agents.get(a),c=(i==null?void 0:i.isBoss)===!0||(i==null?void 0:i.class)==="boss";return!i||!c||!i.subordinateIds?[]:i.subordinateIds.map(d=>r.agents.get(d)).filter(d=>d!==void 0)},isBossAgent(a){const r=t().agents.get(a);return(r==null?void 0:r.isBoss)===!0||(r==null?void 0:r.class)==="boss"},getBossForAgent(a){const r=t(),i=r.agents.get(a);return i!=null&&i.bossId&&r.agents.get(i.bossId)||null},getAvailableSubordinates(){return Array.from(t().agents.values()).filter(a=>a.class!=="boss")},handleAgentTaskStarted(a,r,i,c){e(d=>{const f=new Map(d.agentTaskProgress);let h=f.get(a);h||(h=new Map,f.set(a,h)),h.set(r,{agentId:r,agentName:i,taskDescription:c,status:"working",output:[],startedAt:Date.now()}),d.agentTaskProgress=f}),n()},handleAgentTaskOutput(a,r,i){e(c=>{const d=c.agentTaskProgress.get(a);if(!d)return;const f=d.get(r);if(!f)return;const h=200;let m=[...f.output,i];m.length>h&&(m=m.slice(-h));const b=new Map(c.agentTaskProgress),y=new Map(d);y.set(r,{...f,output:m}),b.set(a,y),c.agentTaskProgress=b}),n()},handleAgentTaskCompleted(a,r,i){e(c=>{const d=c.agentTaskProgress.get(a);if(!d)return;const f=d.get(r);if(!f)return;const h=f.output.length>20?f.output.slice(-20):f.output,m=new Map(c.agentTaskProgress),b=new Map(d);b.set(r,{...f,status:i?"completed":"failed",completedAt:Date.now(),output:h}),m.set(a,b),c.agentTaskProgress=m}),n()},getAgentTaskProgress(a){return t().agentTaskProgress.get(a)||new Map},clearAgentTaskProgress(a,r){e(i=>{if(r){const c=i.agentTaskProgress.get(a);if(c){const d=new Map(i.agentTaskProgress),f=new Map(c);f.delete(r),d.set(a,f),i.agentTaskProgress=d}}else{const c=new Map(i.agentTaskProgress);c.delete(a),i.agentTaskProgress=c}}),n()},clearAllSubordinatesContext(a){const i=t().agents.get(a),c=(i==null?void 0:i.isBoss)===!0||(i==null?void 0:i.class)==="boss";if(console.log("[Store] clearAllSubordinatesContext called:",{bossId:a,bossName:i==null?void 0:i.name,isBoss:c,subordinateIds:i==null?void 0:i.subordinateIds}),!i||!c||!i.subordinateIds||i.subordinateIds.length===0){console.log("[Store] clearAllSubordinatesContext: No boss or subordinates found, returning early");return}const d=s();console.log("[Store] clearAllSubordinatesContext: sendMessage available:",!!d);for(const f of i.subordinateIds)console.log("[Store] clearAllSubordinatesContext: Sending clear_context for subordinate:",f),d==null||d({type:"clear_context",payload:{agentId:f}});e(f=>{const h=new Map(f.agentOutputs);for(const m of i.subordinateIds||[])h.delete(m);f.agentOutputs=h}),n(),console.log("[Store] clearAllSubordinatesContext: Completed")}}}function OO(t,e,n,s){return{setSkillsFromServer(a){e(r=>{const i=new Map;for(const c of a)i.set(c.id,c);r.skills=i}),n()},addSkillFromServer(a){e(r=>{const i=new Map(r.skills);i.set(a.id,a),r.skills=i}),n()},updateSkillFromServer(a){e(r=>{const i=new Map(r.skills);i.set(a.id,a),r.skills=i}),n()},removeSkillFromServer(a){e(r=>{const i=new Map(r.skills);i.delete(a),r.skills=i}),n()},getSkill(a){return t().skills.get(a)},getAllSkills(){return Array.from(t().skills.values())},getSkillsForAgent(a){const r=t(),i=r.agents.get(a);return i?Array.from(r.skills.values()).filter(c=>c.enabled?!!(c.assignedAgentIds.includes(a)||c.assignedAgentClasses.includes(i.class)):!1):[]},createSkill(a){var r;(r=s())==null||r({type:"create_skill",payload:a})},updateSkill(a,r){var i;(i=s())==null||i({type:"update_skill",payload:{id:a,updates:r}})},deleteSkill(a){var r;(r=s())==null||r({type:"delete_skill",payload:{id:a}})},assignSkillToAgent(a,r){var i;(i=s())==null||i({type:"assign_skill",payload:{skillId:a,agentId:r}})},unassignSkillFromAgent(a,r){var i;(i=s())==null||i({type:"unassign_skill",payload:{skillId:a,agentId:r}})},requestAgentSkills(a){var r;(r=s())==null||r({type:"request_agent_skills",payload:{agentId:a}})},setCustomAgentClassesFromServer(a){e(r=>{const i=new Map;for(const c of a)i.set(c.id,c);r.customAgentClasses=i}),n()},addCustomAgentClassFromServer(a){e(r=>{const i=new Map(r.customAgentClasses);i.set(a.id,a),r.customAgentClasses=i}),n()},updateCustomAgentClassFromServer(a){e(r=>{const i=new Map(r.customAgentClasses);i.set(a.id,a),r.customAgentClasses=i}),n()},removeCustomAgentClassFromServer(a){e(r=>{const i=new Map(r.customAgentClasses);i.delete(a),r.customAgentClasses=i}),n()},getCustomAgentClass(a){return t().customAgentClasses.get(a)},getAllCustomAgentClasses(){return Array.from(t().customAgentClasses.values())},createCustomAgentClass(a){var r;(r=s())==null||r({type:"create_custom_agent_class",payload:a})},updateCustomAgentClass(a,r){var i;(i=s())==null||i({type:"update_custom_agent_class",payload:{id:a,updates:r}})},deleteCustomAgentClass(a){var r;(r=s())==null||r({type:"delete_custom_agent_class",payload:{id:a}})}}}function LO(t,e,n){return{handleExecTaskStarted(s,a,r,i,c){e(d=>{const f={taskId:s,agentId:a,agentName:r,command:i,cwd:c,status:"running",output:[],startedAt:Date.now()};d.execTasks||(d.execTasks=new Map),d.execTasks.set(s,f)}),n()},handleExecTaskOutput(s,a,r,i){e(c=>{var m;const d=(m=c.execTasks)==null?void 0:m.get(s);if(!d)return;const f=r.split(`
46
- `),h=[...d.output];for(const b of f)b.length>0&&h.push(i?`[stderr] ${b}`:b);h.length>500&&h.splice(0,h.length-500),c.execTasks.set(s,{...d,output:h})}),n()},handleExecTaskCompleted(s,a,r,i){e(c=>{var f;const d=(f=c.execTasks)==null?void 0:f.get(s);d&&(d.status=i?"completed":"failed",d.exitCode=r,d.completedAt=Date.now())}),n()},async stopExecTask(s){try{return(await fetch(`/api/exec/tasks/${s}`,{method:"DELETE"})).ok?(e(r=>{var c;const i=(c=r.execTasks)==null?void 0:c.get(s);i&&i.status==="running"&&(i.status="failed",i.exitCode=-15,i.completedAt=Date.now(),i.output.push("[Task stopped by user]"))}),n(),!0):!1}catch(a){return console.error("Failed to stop exec task:",a),!1}},getExecTasks(s){const a=t();return a.execTasks?Array.from(a.execTasks.values()).filter(r=>r.agentId===s):[]},getAllExecTasks(){const s=t();return s.execTasks?Array.from(s.execTasks.values()):[]},getExecTask(s){var r;return(r=t().execTasks)==null?void 0:r.get(s)},clearCompletedExecTasks(s){e(a=>{if(a.execTasks)for(const[r,i]of a.execTasks.entries())i.agentId===s&&i.status!=="running"&&a.execTasks.delete(r)}),n()},clearAllExecTasks(s){e(a=>{if(a.execTasks)for(const[r,i]of a.execTasks.entries())i.agentId===s&&a.execTasks.delete(r)}),n()},removeExecTask(s){e(a=>{a.execTasks&&a.execTasks.delete(s)}),n()}}}function IO(t,e,n,s){return{setSecretsFromServer(a){e(r=>{const i=new Map;for(const c of a)i.set(c.id,c);r.secrets=i}),n()},addSecretFromServer(a){e(r=>{const i=new Map(r.secrets);i.set(a.id,a),r.secrets=i}),n()},updateSecretFromServer(a){e(r=>{const i=new Map(r.secrets);i.set(a.id,a),r.secrets=i}),n()},removeSecretFromServer(a){e(r=>{const i=new Map(r.secrets);i.delete(a),r.secrets=i}),n()},getSecret(a){return t().secrets.get(a)},getSecretByKey(a){return Array.from(t().secrets.values()).find(r=>r.key===a)},getAllSecrets(){return Array.from(t().secrets.values())},createSecret(a){var r;(r=s())==null||r({type:"create_secret",payload:a})},updateSecret(a,r){var i;(i=s())==null||i({type:"update_secret",payload:{id:a,updates:r}})},deleteSecret(a){var r;(r=s())==null||r({type:"delete_secret",payload:{id:a}})}}}function hS(){return{connectionStatus:new Map,databases:new Map,tables:new Map,tableSchemas:new Map,queryResults:[],queryHistory:[],executingQuery:!1,activeConnectionId:null,activeDatabase:null,lastSilentQueryResult:null}}function PO(t,e,n,s){const a=i=>{t().databaseState.has(i)||e(d=>{const f=new Map(d.databaseState);f.set(i,hS()),d.databaseState=f})};return{testDatabaseConnection(i,c){var d;(d=s())==null||d({type:"test_database_connection",payload:{buildingId:i,connectionId:c}})},setConnectionStatus(i,c,d){a(i),e(f=>{const h=f.databaseState.get(i);if(h){const m=new Map(h.connectionStatus);m.set(c,d);const b={...h,connectionStatus:m},y=new Map(f.databaseState);y.set(i,b),f.databaseState=y}}),n()},listDatabases(i,c){var d;(d=s())==null||d({type:"list_databases",payload:{buildingId:i,connectionId:c}})},setDatabases(i,c,d){a(i),e(f=>{const h=f.databaseState.get(i);if(h){const m=new Map(h.databases);m.set(c,d);const b={...h,databases:m},y=new Map(f.databaseState);y.set(i,b),f.databaseState=y}}),n()},listTables(i,c,d){var f;(f=s())==null||f({type:"list_tables",payload:{buildingId:i,connectionId:c,database:d}})},setTables(i,c,d,f){a(i);const h=`${c}:${d}`;e(m=>{const b=m.databaseState.get(i);if(b){const y=new Map(b.tables);y.set(h,f);const w={...b,tables:y},C=new Map(m.databaseState);C.set(i,w),m.databaseState=C}}),n()},getTableSchema(i,c,d,f){var h;(h=s())==null||h({type:"get_table_schema",payload:{buildingId:i,connectionId:c,database:d,table:f}})},setTableSchema(i,c,d,f,h){a(i);const m=`${c}:${d}:${f}`;e(b=>{const y=b.databaseState.get(i);if(y){const w=new Map(y.tableSchemas);w.set(m,h);const C={...y,tableSchemas:w},N=new Map(b.databaseState);N.set(i,C),b.databaseState=N}}),n()},executeQuery(i,c,d,f,h=1e3){var m;a(i),e(b=>{const y=b.databaseState.get(i);if(y){const w={...y,executingQuery:!0},C=new Map(b.databaseState);C.set(i,w),b.databaseState=C}}),n(),(m=s())==null||m({type:"execute_query",payload:{buildingId:i,connectionId:c,database:d,query:f,limit:h}})},executeSilentQuery(i,c,d,f,h){var m;(m=s())==null||m({type:"execute_query",payload:{buildingId:i,connectionId:c,database:d,query:f,limit:0,silent:!0,requestId:h}})},setSilentQueryResult(i,c){a(i),e(d=>{const f=d.databaseState.get(i);if(f){const h={...f,lastSilentQueryResult:{...c,timestamp:Date.now()}},m=new Map(d.databaseState);m.set(i,h),d.databaseState=m}}),n()},setQueryResult(i,c){a(i),e(d=>{const f=d.databaseState.get(i);if(f){const h=[c,...f.queryResults].slice(0,20),m={...f,queryResults:h,executingQuery:!1},b=new Map(d.databaseState);b.set(i,m),d.databaseState=b}}),n()},setExecutingQuery(i,c){a(i),e(d=>{const f=d.databaseState.get(i);if(f){const h={...f,executingQuery:c},m=new Map(d.databaseState);m.set(i,h),d.databaseState=m}}),n()},requestQueryHistory(i,c=100){var d;(d=s())==null||d({type:"request_query_history",payload:{buildingId:i,limit:c}})},setQueryHistory(i,c){a(i),e(d=>{const f=d.databaseState.get(i);if(f){const h={...f,queryHistory:c},m=new Map(d.databaseState);m.set(i,h),d.databaseState=m}}),n()},toggleQueryFavorite(i,c){var d;(d=s())==null||d({type:"toggle_query_favorite",payload:{buildingId:i,queryId:c}})},deleteQueryFromHistory(i,c){var d;(d=s())==null||d({type:"delete_query_history",payload:{buildingId:i,queryId:c}})},clearQueryHistory(i){var c;(c=s())==null||c({type:"clear_query_history",payload:{buildingId:i}})},setActiveConnection(i,c){a(i),e(d=>{const f=d.databaseState.get(i);if(f){const h={...f,activeConnectionId:c,activeDatabase:null},m=new Map(d.databaseState);m.set(i,h),d.databaseState=m}}),n()},setActiveDatabase(i,c){a(i),e(d=>{const f=d.databaseState.get(i);if(f){const h={...f,activeDatabase:c},m=new Map(d.databaseState);m.set(i,h),d.databaseState=m}}),n()},getDatabaseState(i){return t().databaseState.get(i)||hS()},clearDatabaseState(i){e(c=>{const d=new Map(c.databaseState);d.delete(i),c.databaseState=d}),n()}}}function BO(t,e,n){return{async fetchSnapshots(){e(s=>{s.snapshotsLoading=!0,s.snapshotsError=null}),n();try{const s=await Bt(Rt("/api/snapshots"));if(!s.ok)throw new Error(`Failed to fetch snapshots: ${s.statusText}`);const a=await s.json(),r=Array.isArray(a)?a:a.snapshots||[];this.setSnapshots(r)}catch(s){const a=s instanceof Error?s.message:"Failed to fetch snapshots";this.setError(a),console.error("Snapshot fetch error:",s)}finally{e(s=>{s.snapshotsLoading=!1}),n()}},setSnapshots(s){e(a=>{const r=new Map;s.forEach(i=>{r.set(i.id,i)}),a.snapshots=r}),n()},async createSnapshot(s,a,r,i,c,d){e(f=>{f.snapshotsLoading=!0,f.snapshotsError=null}),n();try{const f={agentId:s,agentName:a,title:r,description:i,outputs:c||[],files:d||[]},h=await Bt(Rt("/api/snapshots"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)});if(!h.ok)throw new Error(`Failed to create snapshot: ${h.statusText}`);const m=await h.json();return await this.fetchSnapshots(),m}catch(f){const h=f instanceof Error?f.message:"Failed to create snapshot";throw this.setError(h),console.error("Snapshot creation error:",f),f}finally{e(f=>{f.snapshotsLoading=!1}),n()}},async loadSnapshot(s){e(a=>{a.snapshotsLoading=!0,a.snapshotsError=null}),n();try{const a=await Bt(Rt(`/api/snapshots/${s}`));if(!a.ok)throw new Error(`Failed to load snapshot: ${a.statusText}`);const r=await a.json();this.setCurrentSnapshot(r)}catch(a){const r=a instanceof Error?a.message:"Failed to load snapshot";this.setError(r),console.error("Snapshot load error:",a)}finally{e(a=>{a.snapshotsLoading=!1}),n()}},setCurrentSnapshot(s){e(a=>{a.currentSnapshot=s}),n()},async deleteSnapshot(s){var a;e(r=>{r.snapshotsLoading=!0,r.snapshotsError=null}),n();try{const r=await Bt(Rt(`/api/snapshots/${s}`),{method:"DELETE"});if(!r.ok)throw new Error(`Failed to delete snapshot: ${r.statusText}`);await this.fetchSnapshots(),((a=t().currentSnapshot)==null?void 0:a.id)===s&&this.setCurrentSnapshot(null)}catch(r){const i=r instanceof Error?r.message:"Failed to delete snapshot";throw this.setError(i),console.error("Snapshot deletion error:",r),r}finally{e(r=>{r.snapshotsLoading=!1}),n()}},async restoreFiles(s,a){e(r=>{r.snapshotsLoading=!0,r.snapshotsError=null}),n();try{const r=a?{filePaths:a}:{},i=await Bt(Rt(`/api/snapshots/${s}/restore`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!i.ok)throw new Error(`Failed to restore files: ${i.statusText}`)}catch(r){const i=r instanceof Error?r.message:"Failed to restore files";throw this.setError(i),console.error("File restoration error:",r),r}finally{e(r=>{r.snapshotsLoading=!1}),n()}},setLoading(s){e(a=>{a.snapshotsLoading=s}),n()},setError(s){e(a=>{a.snapshotsError=s}),n()},clearError(){this.setError(null)},reset(){e(s=>{s.snapshots=new Map,s.currentSnapshot=null,s.snapshotsLoading=!1,s.snapshotsError=null}),n()}}}const FO=3e4,zg=new Map;function Ef(t,e,n){let s=t.get(e);if(!s){for(const[,a]of t)if(a.toolUseId===e&&a.parentAgentId===n){s=a;break}}return s}function mS(t,e,n){const s=zg.get(t);s&&clearTimeout(s),zg.set(t,setTimeout(()=>{zg.delete(t),e(a=>{const r=a.subagents.get(t);if(r&&(r.status==="completed"||r.status==="failed")){const i=new Map(a.subagents);i.delete(t),a.subagents=i}}),n()},FO))}function zO(t,e,n){return{addSubagent(s){e(a=>{const r=new Map(a.subagents);r.set(s.id,s),a.subagents=r}),n(),console.log(`[Subagent] Added: ${s.name} (${s.id}) for agent ${s.parentAgentId}`)},completeSubagent(s,a,r){e(i=>{const c=Ef(i.subagents,s,a);if(c){const d=new Map(i.subagents);d.set(c.id,{...c,status:r?"completed":"failed",completedAt:Date.now()}),i.subagents=d,console.log(`[Subagent] Completed: ${c.name} (${c.id}) success=${r}`),mS(c.id,e,n)}}),n()},addSubagentActivity(s,a,r){e(i=>{const c=Ef(i.subagents,s,a);if(c){const d=[...c.activities||[],r].slice(-50),f=new Map(i.subagents);f.set(c.id,{...c,activities:d}),i.subagents=f}}),n()},updateSubagentStats(s,a,r){e(i=>{const c=Ef(i.subagents,s,a);if(c){const d=new Map(i.subagents);d.set(c.id,{...c,stats:r}),i.subagents=d}}),n()},getSubagentsForAgent(s){const a=t();return Array.from(a.subagents.values()).filter(r=>r.parentAgentId===s)},getSubagent(s){return t().subagents.get(s)},removeSubagent(s){e(a=>{const r=new Map(a.subagents);r.delete(s),a.subagents=r}),n()},addSubagentStreamEntries(s,a,r){e(i=>{const c=Ef(i.subagents,s,a);if(c){const f=[...c.streamEntries||[],...r].slice(-200),h=new Map(i.subagents);h.set(c.id,{...c,streamEntries:f}),i.subagents=h,(c.status==="completed"||c.status==="failed")&&mS(c.id,e,n)}}),n()},getSubagentByToolUseId(s){const a=t();for(const[,r]of a.subagents)if(r.toolUseId===s)return r},hydrateSubagentsFromHistory(s,a){!a||a.length===0||(e(r=>{const i=new Map(r.subagents);for(const c of a){let d=!1;for(const[,m]of i)if(m.toolUseId===c.toolUseId&&m.parentAgentId===s){d=!0;break}if(d)continue;const f=`hist_${c.toolUseId}`,h={id:f,parentAgentId:s,toolUseId:c.toolUseId,name:c.name||"Subagent",description:c.description||"",subagentType:c.subagentType||"general-purpose",model:c.model,status:"completed",startedAt:c.startedAt||0,completedAt:c.completedAt,streamEntries:c.streamEntries.slice(-200),stats:c.stats};i.set(f,h)}r.subagents=i}),n())}}}const $O={workflowDefinitions:new Map,workflowInstances:new Map,selectedWorkflowId:null,workflowDetailOpen:!1,workflowDetailLevel:{level:"overview"},workflowChatMessages:[],workflowChatScope:{level:"workflow"},workflowChatLoading:!1};function UO(t,e,n,s){const a=()=>{const i=t();return{workflowDefinitions:i.workflowDefinitions??new Map,workflowInstances:i.workflowInstances??new Map,selectedWorkflowId:i.selectedWorkflowId??null,workflowDetailOpen:i.workflowDetailOpen??!1,workflowDetailLevel:i.workflowDetailLevel??{level:"overview"},workflowChatMessages:i.workflowChatMessages??[],workflowChatScope:i.workflowChatScope??{level:"workflow"},workflowChatLoading:i.workflowChatLoading??!1}};return{setWorkflowDefinitionsFromServer(i){e(c=>{const d=new Map;for(const f of i)d.set(f.id,f);c.workflowDefinitions=d}),n()},addWorkflowDefinitionFromServer(i){e(c=>{const d=c,f=new Map(d.workflowDefinitions??new Map);f.set(i.id,i),d.workflowDefinitions=f}),n()},updateWorkflowDefinitionFromServer(i){e(c=>{const d=c,f=new Map(d.workflowDefinitions??new Map);f.set(i.id,i),d.workflowDefinitions=f}),n()},removeWorkflowDefinitionFromServer(i){e(c=>{const d=c,f=new Map(d.workflowDefinitions??new Map);f.delete(i),d.workflowDefinitions=f,d.selectedWorkflowId===i&&(d.selectedWorkflowId=null,d.workflowDetailOpen=!1)}),n()},createWorkflowDefinition(i){var c;(c=s())==null||c({type:"create_workflow_def",payload:i})},updateWorkflowDefinition(i,c){var d;(d=s())==null||d({type:"update_workflow_def",payload:{id:i,updates:c}})},deleteWorkflowDefinition(i){var c;(c=s())==null||c({type:"delete_workflow_def",payload:{id:i}})},moveWorkflow(i,c){var d;e(f=>{const h=f,m=new Map(h.workflowDefinitions??new Map),b=m.get(i);b&&(m.set(i,{...b,position:c}),h.workflowDefinitions=m)}),(d=s())==null||d({type:"update_workflow_def",payload:{id:i,updates:{position:c}}}),n()},setWorkflowInstancesFromServer(i){e(c=>{const d=c,f=new Map;for(const h of i)f.set(h.id,h);d.workflowInstances=f}),n()},updateWorkflowInstanceFromServer(i){e(c=>{const d=c,f=new Map(d.workflowInstances??new Map);f.set(i.id,i),d.workflowInstances=f}),n()},removeWorkflowInstanceFromServer(i){e(c=>{const d=c,f=new Map(d.workflowInstances??new Map);f.delete(i),d.workflowInstances=f}),n()},startWorkflow(i,c){var d;(d=s())==null||d({type:"start_workflow",payload:{workflowDefId:i,initialVariables:c}})},pauseWorkflow(i){var c;(c=s())==null||c({type:"pause_workflow",payload:{instanceId:i}})},resumeWorkflow(i){var c;(c=s())==null||c({type:"resume_workflow",payload:{instanceId:i}})},cancelWorkflow(i){var c;(c=s())==null||c({type:"cancel_workflow",payload:{instanceId:i}})},manualTransition(i,c){var d;(d=s())==null||d({type:"manual_transition",payload:{instanceId:i,transitionId:c}})},selectWorkflow(i){e(c=>{c.selectedWorkflowId=i}),n()},openWorkflowDetail(i){e(c=>{const d=c;d.selectedWorkflowId=i,d.workflowDetailOpen=!0,d.workflowDetailLevel={level:"overview"},d.workflowChatMessages=[],d.workflowChatScope={level:"workflow"}}),n()},closeWorkflowDetail(){e(i=>{const c=i;c.workflowDetailOpen=!1,c.workflowDetailLevel={level:"overview"},c.workflowChatMessages=[]}),n()},navigateToExecution(i){e(c=>{const d=c;d.workflowDetailLevel={level:"execution",instanceId:i},d.workflowChatScope={level:"instance",instanceId:i}}),n()},navigateToStep(i,c){e(d=>{const f=d;f.workflowDetailLevel={level:"step",instanceId:i,stepId:c},f.workflowChatScope={level:"step",instanceId:i,stepId:c}}),n()},navigateBack(){const c=a().workflowDetailLevel;e(d=>{const f=d;c.level==="step"?(f.workflowDetailLevel={level:"execution",instanceId:c.instanceId},f.workflowChatScope={level:"instance",instanceId:c.instanceId}):c.level==="execution"&&(f.workflowDetailLevel={level:"overview"},f.workflowChatScope={level:"workflow"})}),n()},getWorkflowModelStatus(i){const c=a(),d=Array.from(c.workflowInstances.values()).filter(m=>m.workflowDefId===i);if(d.length===0)return"idle";if(d.some(m=>m.status==="failed"))return"error";if(d.some(m=>m.status==="running"||m.status==="paused"))return"running";const f=Date.now()-300*1e3;return d.filter(m=>m.status==="completed"&&m.completedAt&&m.completedAt>f).length>0?"completed":"idle"},addWorkflowChatMessage(i){e(c=>{const d=c;d.workflowChatMessages=[...d.workflowChatMessages??[],i]}),n()},setWorkflowChatScope(i){e(c=>{c.workflowChatScope=i}),n()},setWorkflowChatLoading(i){e(c=>{c.workflowChatLoading=i}),n()},clearWorkflowChat(){e(i=>{const c=i;c.workflowChatMessages=[]}),n()},getWorkflowDefinition(i){return a().workflowDefinitions.get(i)},getWorkflowInstances(i){return Array.from(a().workflowInstances.values()).filter(c=>c.workflowDefId===i)},getAllWorkflowDefinitions(){return Array.from(a().workflowDefinitions.values())}}}const $g={panSpeed:1,orbitSpeed:1,zoomSpeed:1,smoothing:.3,invertPanX:!1,invertPanY:!1,invertOrbitX:!1,invertOrbitY:!1},Mf={enabled:!0,pinchToZoom:!0,twoFingerPan:!0,shiftTwoFingerOrbit:!0,sensitivity:{zoom:1,pan:1,orbit:1}};function po(t,e,n,s,a,r,i){return{id:t,name:e,description:n,button:s,modifiers:a,action:r,enabled:!0,sensitivity:i}}const Ug=[po("left-click-select","Select/Click","Select agents, click on buildings/areas","left",{},"primary-action"),po("left-drag-selection","Selection Box","Drag to select multiple agents","left",{},"selection-box"),po("right-click-context","Context Menu / Move","Show context menu or move selected agents","right",{},"context-menu"),po("alt-right-drag-pan","Camera Pan","Pan camera with Alt+Right-drag","right",{alt:!0},"camera-pan",1),po("middle-drag-orbit","Camera Orbit","Orbit camera with middle-drag","middle",{},"camera-orbit",1),po("shift-middle-drag-pan","Camera Pan (Alt)","Alternative pan with Shift+Middle-drag","middle",{shift:!0},"camera-pan",1),po("wheel-zoom","Zoom","Zoom camera with scroll wheel","middle",{},"camera-zoom",1)],Mq={0:"left",1:"middle",2:"right",3:"back",4:"forward"},HO={left:"Left Click",right:"Right Click",middle:"Middle Click",back:"Back Button",forward:"Forward Button"};function Dq(t,e){const n=[];if(t.modifiers.ctrl){const s=typeof navigator<"u"&&navigator.platform.toUpperCase().includes("MAC");n.push(s?"⌘":"Ctrl")}if(t.modifiers.alt){const s=typeof navigator<"u"&&navigator.platform.toUpperCase().includes("MAC");n.push(s?"⌥":"Alt")}return t.modifiers.shift&&n.push("Shift"),n.push(e?e(t.button):HO[t.button]),n.join("+")}function Rq(t,e){const n=e.ctrl?t.ctrlKey||t.metaKey:!t.ctrlKey&&!t.metaKey,s=e.alt?t.altKey:!t.altKey,a=e.shift?t.shiftKey:!t.shiftKey;return n&&s&&a}function Oq(t,e,n){return t.filter(s=>{if(s.id===n||!s.enabled||s.button!==e.button)return!1;const a=s.modifiers,r=e.modifiers;return(a.ctrl||!1)===(r.ctrl||!1)&&(a.alt||!1)===(r.alt||!1)&&(a.shift||!1)===(r.shift||!1)})}function Qs(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}function $a(t,e){if(t===e)return!0;if(t.size!==e.size)return!1;for(const[n,s]of t)if(e.get(n)!==s)return!1;return!0}function $x(t,e){if(t===e)return!0;if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;return!0}function jt(t,e=Object.is){const[n,s]=x.useState(()=>t(U.getState())),a=x.useRef(n);return x.useEffect(()=>{a.current=n},[n]),x.useEffect(()=>{const r=()=>{const i=t(U.getState());e(a.current,i)||(a.current=i,s(i))};return r(),U.subscribe(r)},[t,e]),n}function Rs(){const[,t]=x.useState({});return x.useEffect(()=>U.subscribe(()=>t({})),[]),U.getState()}function ed(){return jt(x.useCallback(t=>t.agents,[]),$a)}function Kj(){return jt(x.useCallback(t=>t.agents.size,[]))}function Kp(){const t=ed(),e=x.useRef([]),n=Array.from(t.values());return Qs(e.current,n)||(e.current=n),e.current}function Qj(t){return jt(x.useCallback(e=>t?e.agents.get(t):void 0,[t]))}function Ux(){return jt(x.useCallback(t=>t.selectedAgentIds,[]),$x)}function WO(){return jt(x.useCallback(t=>t.lastSelectedAgentId,[]))}function Xj(t){const e=x.useRef([]),n=x.useRef(0),s=jt(x.useCallback(a=>t&&a.agentOutputs.get(t)||e.current,[t]),Qs);return s.length!==n.current&&(Uu.info(`Selector: ${n.current} -> ${s.length}`,{agentId:t,lastText:s.length>0?s[s.length-1].text.slice(0,40):null},"useAgentOutputs"),n.current=s.length),s}function Jj(t){return jt(x.useCallback(e=>t?e.lastPrompts.get(t):void 0,[t]))}function Hx(){return jt(x.useCallback(t=>t.lastPrompts,[]),$a)}function Zj(){return jt(x.useCallback(t=>t.isConnected,[]))}function ur(){return jt(x.useCallback(t=>t.areas,[]),$a)}function qO(){return jt(x.useCallback(t=>t.activeTool,[]))}function VO(){return jt(x.useCallback(t=>t.selectedAreaId,[]))}function Wx(){return jt(x.useCallback(t=>t.buildings,[]),$a)}function YO(){return jt(x.useCallback(t=>t.selectedBuildingIds,[]),$x)}function GO(){return jt(x.useCallback(t=>t.supervisor,[]))}function Lq(){return jt(x.useCallback(t=>t.supervisor.lastReport,[]))}function KO(){return jt(x.useCallback(t=>t.supervisor.generatingReport,[]))}function QO(){return jt(x.useCallback(t=>t.permissionRequests,[]),$a)}function Vr(){return jt(x.useCallback(t=>t.settings,[]))}function e1(){return jt(x.useCallback(t=>t.settings.hideCost,[]))}function Iq(){return jt(x.useCallback(t=>t.settings.customAgentNames,[]),Qs)}function Pq(){return jt(x.useCallback(t=>t.shortcuts,[]),Qs)}function Bq(){return jt(x.useCallback(t=>t.mouseControls,[]))}function Fq(){return jt(x.useCallback(t=>t.mouseControls.trackpad,[]))}function t1(){return jt(x.useCallback(t=>t.terminalOpen,[]))}function n1(){return jt(x.useCallback(t=>t.mobileView,[]))}function qx(){return jt(x.useCallback(t=>t.fileViewerPath,[]))}function XO(){return jt(x.useCallback(t=>t.fileViewerEditData,[]))}function JO(){return jt(x.useCallback(t=>t.fileViewerSearchRoot,[]))}function ZO(){return jt(x.useCallback(t=>t.explorerFolderPath,[]))}function Vx(){return jt(x.useCallback(t=>t.contextModalAgentId,[]))}function zq(){return jt(x.useCallback(t=>t.commanderExpandRequest,[]))}function Yx(){return jt(x.useCallback(t=>t.toolExecutions,[]),Qs)}function s1(){return jt(x.useCallback(t=>t.fileChanges,[]),Qs)}function a1(){return jt(x.useCallback(t=>t.skills,[]),$a)}function eL(){const t=a1(),e=x.useRef([]),n=Array.from(t.values());return Qs(e.current,n)||(e.current=n),e.current}function $q(t){return jt(x.useCallback(e=>t?e.skills.get(t):void 0,[t]))}function tL(t){const e=x.useRef([]),n=ed(),s=a1();if(!t)return e.current;const a=n.get(t);return a?Array.from(s.values()).filter(i=>i.enabled?!!(i.assignedAgentIds.includes(t)||i.assignedAgentClasses.includes(a.class)):!1):e.current}function nL(){return jt(x.useCallback(t=>t.customAgentClasses,[]),$a)}function dr(){const t=nL(),e=x.useRef([]),n=Array.from(t.values());return Qs(e.current,n)||(e.current=n),e.current}function r1(t){return jt(x.useCallback(e=>t?e.customAgentClasses.get(t):void 0,[t]))}function i1(){return jt(x.useCallback(t=>t.reconnectCount,[]))}function o1(){return jt(x.useCallback(t=>t.historyRefreshTrigger,[]))}function Uq(){return jt(x.useCallback(t=>t.supervisor.globalUsage,[]))}function Hq(){return jt(x.useCallback(t=>t.supervisor.refreshingUsage,[]))}function sL(t){const e=x.useRef(new Map);return jt(x.useCallback(n=>t&&n.agentTaskProgress.get(t)||e.current,[t]),$a)}function aL(t){return jt(x.useCallback(e=>!t||!e.execTasks?[]:Array.from(e.execTasks.values()).filter(n=>n.agentId===t),[t]),Qs)}function rL(){return jt(x.useCallback(t=>t.secrets,[]),$a)}function Wq(){const t=rL(),e=x.useRef([]),n=Array.from(t.values());return Qs(e.current,n)||(e.current=n),e.current}const iL={connectionStatus:new Map,databases:new Map,tables:new Map,tableSchemas:new Map,queryResults:[],queryHistory:[],executingQuery:!1,activeConnectionId:null,activeDatabase:null,lastSilentQueryResult:null};function Gx(t){return jt(x.useCallback(e=>(t?e.databaseState.get(t):void 0)??iL,[t]))}function oL(t){return jt(x.useCallback(e=>{if(!t)return[];const n=e.databaseState.get(t);return(n==null?void 0:n.queryResults)??[]},[t]),Qs)}function qq(t){return jt(x.useCallback(e=>{if(!t)return[];const n=e.databaseState.get(t);return(n==null?void 0:n.queryHistory)??[]},[t]),Qs)}function lL(t){return jt(x.useCallback(e=>{if(!t)return!1;const n=e.databaseState.get(t);return(n==null?void 0:n.executingQuery)??!1},[t]))}function Vq(){return jt(t=>t.dockerContainersList,Qs)}function cL(){return jt(t=>t.currentSnapshot)}function uL(){return jt(t=>t.snapshotsLoading)}function dL(){return jt(t=>t.snapshotsError)}function fL(){return jt(t=>t.subagents,$a)}function pL(t){return jt(x.useCallback(e=>t?Array.from(e.subagents.values()).filter(n=>n.parentAgentId===t):[],[t]),Qs)}function hL(t){const e=x.useRef(new Map);return jt(x.useCallback(n=>{if(!t)return e.current;const s=new Map;for(const[a,r]of n.subagents)r.parentAgentId===t&&s.set(a,r);return s.size===0?e.current:s},[t]),$a)}function l1(){return jt(t=>t.viewMode)}function mL(){return jt(x.useCallback(t=>t.overviewPanelOpen,[]))}function c1(){return jt(x.useCallback(t=>t.agentsWithUnseenOutput,[]),$x)}class gS{constructor(){Xe(this,"state");Xe(this,"listeners",new Set);Xe(this,"sendMessage",null);Xe(this,"agentActions");Xe(this,"outputActions");Xe(this,"supervisorActions");Xe(this,"areaActions");Xe(this,"buildingActions");Xe(this,"permissionActions");Xe(this,"delegationActions");Xe(this,"skillActions");Xe(this,"execTaskActions");Xe(this,"secretActions");Xe(this,"databaseActions");Xe(this,"snapshotActions");Xe(this,"subagentActions");Xe(this,"workflowActions");Xe(this,"statusPollInterval",null);this.state={agents:new Map,selectedAgentIds:new Set,lastSelectedAgentId:null,activities:[],isConnected:!1,areas:new Map,activeTool:null,selectedAreaId:null,buildings:new Map,selectedBuildingIds:new Set,buildingLogs:new Map,streamingBuildingLogs:new Map,streamingBuildingIds:new Set,bossStreamingLogs:new Map,agentOutputs:new Map,lastPrompts:new Map,toolExecutions:[],fileChanges:[],terminalOpen:!1,terminalResizing:!1,mobileView:this.loadMobileView(),settings:this.loadSettings(),shortcuts:this.loadShortcuts(),mouseControls:this.loadMouseControls(),fileViewerPath:null,fileViewerSearchRoot:null,fileViewerEditData:null,explorerFolderPath:null,explorerAreaId:null,contextModalAgentId:null,supervisor:{enabled:!0,autoReportOnComplete:!1,lastReport:null,narratives:new Map,lastReportTime:null,nextReportTime:null,agentHistories:new Map,loadingHistoryForAgent:null,historyFetchedForAgents:new Set,generatingReport:!1,globalUsage:null,refreshingUsage:!1},permissionRequests:new Map,delegationHistories:new Map,pendingDelegation:null,lastDelegationReceived:new Map,agentTaskProgress:new Map,skills:new Map,customAgentClasses:new Map,reconnectCount:0,historyRefreshTrigger:0,execTasks:new Map,secrets:new Map,databaseState:new Map,dockerContainersList:[],dockerComposeProjectsList:[],snapshots:new Map,currentSnapshot:null,snapshotsLoading:!1,snapshotsError:null,lastSelectionViaSwipe:!1,lastSelectionViaDirectClickAt:null,subagents:new Map,viewMode:(()=>{const i=Fa(pt.SCENE_VIEW_MODE,"3d");return i==="2d"||i==="3d"||i==="dashboard"?i:"3d"})(),overviewPanelOpen:Ni(pt.AOP_OPEN,!1),agentsWithUnseenOutput:this.loadUnseenAgents(),commanderExpandRequest:null,latestNotificationAgentId:null,...$O};const e=()=>this.state,n=i=>{i(this.state)},s=()=>this.notify(),a=()=>this.sendMessage,r=()=>this.listeners.size;this.agentActions=AO(e,n,s,a,()=>this.saveUnseenAgents()),this.outputActions=jO(e,n,s,r),this.supervisorActions=NO(e,n,s,a),this.areaActions=TO(e,n,s,a),this.buildingActions=MO(e,n,s,a),this.permissionActions=DO(e,n,s,a),this.delegationActions=RO(e,n,s,a),this.skillActions=OO(e,n,s,a),this.execTaskActions=LO(e,n,s),this.secretActions=IO(e,n,s,a),this.databaseActions=PO(e,n,s,a),this.snapshotActions=BO(e,n,s),this.subagentActions=zO(e,n,s),this.workflowActions=UO(e,n,s,a)}loadSettings(){const e=Na(pt.SETTINGS,null);if(e){const n={...Pg,...e},s=Number(n.vibrationIntensity);return n.vibrationIntensity=Number.isFinite(s)?Math.max(0,Math.min($u,Math.round(s))):Pg.vibrationIntensity,n}return{...Pg}}loadShortcuts(){const e=Na(pt.SHORTCUTS,null);return e?Lg.map(s=>{const a=e.find(r=>r.id===s.id);return a?{...s,...a}:s}):[...Lg]}loadMouseControls(){var n;const e=Na(pt.MOUSE_CONTROLS,null);return e?{bindings:Ug.map(a=>{var i;const r=(i=e.bindings)==null?void 0:i.find(c=>c.id===a.id);return r?{...a,...r}:a}),sensitivity:{...$g,...e.sensitivity},trackpad:{...Mf,...e.trackpad,sensitivity:{...Mf.sensitivity,...(n=e.trackpad)==null?void 0:n.sensitivity}}}:{bindings:[...Ug],sensitivity:{...$g},trackpad:{...Mf}}}loadMobileView(){const e=Fa(pt.MOBILE_VIEW,"");return e==="terminal"||e==="3d"?e:typeof window<"u"&&window.innerWidth<=768&&"ontouchstart"in window?"3d":"terminal"}loadUnseenAgents(){const e=Na(pt.UNSEEN_AGENTS,[]);return new Set(e)}saveUnseenAgents(){const e=Array.from(this.state.agentsWithUnseenOutput);La(pt.UNSEEN_AGENTS,e)}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notify(){this.listeners.forEach(e=>e())}getState(){return this.state}setSendMessage(e){this.sendMessage=e}setConnected(e){this.state.isConnected=e,this.notify()}triggerReconnect(){this.state.reconnectCount++,this.notify()}triggerHistoryRefresh(e){Wj(e),this.state.selectedAgentIds.has(e)&&(this.state.historyRefreshTrigger++,this.notify())}toggleTerminal(e){e&&!this.state.selectedAgentIds.has(e)&&(this.state.selectedAgentIds=new Set([e])),this.state.terminalOpen=!this.state.terminalOpen,this.notify()}setTerminalOpen(e){if(this.state.terminalOpen=e,e){if(this.state.mobileView="terminal",this.state.selectedAgentIds.size===0&&this.state.agents.size>0&&!this.state.currentSnapshot){const s=Array.from(this.state.agents.keys())[0];this.state.selectedAgentIds=new Set([s])}let n=!1;for(const s of this.state.selectedAgentIds)this.state.agentsWithUnseenOutput.has(s)&&(n||(this.state.agentsWithUnseenOutput=new Set(this.state.agentsWithUnseenOutput),n=!0),this.state.agentsWithUnseenOutput.delete(s));n&&this.saveUnseenAgents()}else window.innerWidth<=768&&(this.state.mobileView="3d");this.notify()}setOverviewPanelOpen(e){this.state.overviewPanelOpen=e,Ti(pt.AOP_OPEN,e),this.notify()}setMobileView(e){if(this.state.mobileView=e,Wr(pt.MOBILE_VIEW,e),e==="terminal"&&this.state.selectedAgentIds.size===0&&this.state.agents.size>0&&!this.state.currentSnapshot){const n=Array.from(this.state.agents.keys())[0];this.state.selectedAgentIds=new Set([n]),this.state.terminalOpen=!0}this.notify()}setViewMode(e){this.state.viewMode=e,Wr(pt.SCENE_VIEW_MODE,e),this.state.settings.experimental2DView=e==="2d",this.notify()}openTerminalOnMobile(e){ZD("terminal"),this.state.selectedAgentIds=new Set([e]),this.state.terminalOpen=!0,this.state.mobileView="terminal",this.state.agentsWithUnseenOutput.has(e)&&(this.state.agentsWithUnseenOutput=new Set(this.state.agentsWithUnseenOutput),this.state.agentsWithUnseenOutput.delete(e),this.saveUnseenAgents()),this.notify()}clearUnseenForAgent(e){this.state.agentsWithUnseenOutput.has(e)&&(this.state.agentsWithUnseenOutput=new Set(this.state.agentsWithUnseenOutput),this.state.agentsWithUnseenOutput.delete(e),this.saveUnseenAgents(),this.notify())}setTerminalResizing(e){this.state.terminalResizing=e,this.notify()}setLastSelectionViaSwipe(e){this.state.lastSelectionViaSwipe=e}consumeSwipeSelectionFlag(){const e=this.state.lastSelectionViaSwipe;return this.state.lastSelectionViaSwipe=!1,e}setLastSelectionViaDirectClick(e){this.state.lastSelectionViaDirectClickAt=e?Date.now():null}consumeDirectClickSelectionFlag(){const e=this.state.lastSelectionViaDirectClickAt;return this.state.lastSelectionViaDirectClickAt=null,e===null?!1:Date.now()-e<=1500}setFileViewerPath(e,n,s){this.state.fileViewerPath=e,this.state.fileViewerEditData=n||null,this.state.fileViewerSearchRoot=s||null,this.notify()}clearFileViewerPath(){this.state.fileViewerPath=null,this.state.fileViewerEditData=null,this.state.fileViewerSearchRoot=null,this.notify()}requestCommanderExpand(e){this.state.commanderExpandRequest=e,this.notify()}clearCommanderExpandRequest(){this.state.commanderExpandRequest=null,this.notify()}setLatestNotificationAgentId(e){this.state.latestNotificationAgentId=e,this.notify()}getLastExplorerState(){try{const e=localStorage.getItem("file-explorer-last-opened");return e?JSON.parse(e):null}catch{return null}}setExplorerFolderPath(e){this.state.explorerFolderPath=e,this.notify()}openFileExplorer(e){this.state.explorerFolderPath=e,this.state.explorerAreaId=null,this.notify()}closeFileExplorer(){this.state.explorerFolderPath=null,this.state.explorerAreaId=null,this.notify()}openFileExplorerForArea(e){this.state.explorerFolderPath=null,this.state.explorerAreaId=e,this.notify()}openFileExplorerForAreaFolder(e,n){this.state.explorerAreaId=e,this.state.explorerFolderPath=n,this.notify()}setContextModalAgentId(e){this.state.contextModalAgentId=e,this.notify()}closeContextModal(){this.state.contextModalAgentId=null,this.notify()}updateSettings(e){const n={...e};if(n.vibrationIntensity!==void 0){const s=Number(n.vibrationIntensity);n.vibrationIntensity=Number.isFinite(s)?Math.max(0,Math.min($u,Math.round(s))):this.state.settings.vibrationIntensity}this.state.settings={...this.state.settings,...n},La(pt.SETTINGS,this.state.settings),this.notify()}getSettings(){return this.state.settings}getShortcuts(){return this.state.shortcuts}getShortcut(e){return this.state.shortcuts.find(n=>n.id===e)}updateShortcut(e,n){const s=this.state.shortcuts.findIndex(a=>a.id===e);s!==-1&&(this.state.shortcuts=[...this.state.shortcuts.slice(0,s),{...this.state.shortcuts[s],...n},...this.state.shortcuts.slice(s+1)],this.saveShortcuts(),this.notify())}resetShortcuts(){this.state.shortcuts=[...Lg],this.saveShortcuts(),this.notify()}saveShortcuts(){La(pt.SHORTCUTS,this.state.shortcuts)}getMouseControls(){return this.state.mouseControls}getMouseBinding(e){return this.state.mouseControls.bindings.find(n=>n.id===e)}updateMouseBinding(e,n){const s=this.state.mouseControls.bindings.findIndex(a=>a.id===e);s!==-1&&(this.state.mouseControls.bindings=[...this.state.mouseControls.bindings.slice(0,s),{...this.state.mouseControls.bindings[s],...n},...this.state.mouseControls.bindings.slice(s+1)],this.saveMouseControls(),this.notify())}updateCameraSensitivity(e){this.state.mouseControls.sensitivity={...this.state.mouseControls.sensitivity,...e},this.saveMouseControls(),this.notify()}resetMouseControls(){this.state.mouseControls={bindings:[...Ug],sensitivity:{...$g},trackpad:{...Mf}},this.saveMouseControls(),this.notify()}getTrackpadConfig(){return this.state.mouseControls.trackpad}updateTrackpadConfig(e){this.state.mouseControls.trackpad={...this.state.mouseControls.trackpad,...e,sensitivity:{...this.state.mouseControls.trackpad.sensitivity,...e.sensitivity||{}}},this.saveMouseControls(),this.notify()}saveMouseControls(){La(pt.MOUSE_CONTROLS,this.state.mouseControls)}startStatusPolling(){}stopStatusPolling(){this.statusPollInterval&&(clearInterval(this.statusPollInterval),this.statusPollInterval=null)}setAgents(...e){return this.agentActions.setAgents(...e)}addAgent(...e){return this.agentActions.addAgent(...e)}updateAgent(...e){return this.agentActions.updateAgent(...e)}updateAgentContextStats(...e){return this.agentActions.updateAgentContextStats(...e)}updateAgentContext(...e){return this.agentActions.updateAgentContext(...e)}removeAgent(...e){return this.agentActions.removeAgent(...e)}selectAgent(...e){return this.agentActions.selectAgent(...e)}addToSelection(...e){return this.agentActions.addToSelection(...e)}selectMultiple(...e){return this.agentActions.selectMultiple(...e)}deselectAll(...e){return this.agentActions.deselectAll(...e)}spawnAgent(...e){return this.agentActions.spawnAgent(...e)}createDirectoryAndSpawn(...e){return this.agentActions.createDirectoryAndSpawn(...e)}sendCommand(...e){return this.agentActions.sendCommand(...e)}refreshAgentContext(...e){return this.agentActions.refreshAgentContext(...e)}moveAgentLocal(...e){return this.agentActions.moveAgentLocal(...e)}moveAgent(...e){return this.agentActions.moveAgent(...e)}killAgent(...e){return this.agentActions.killAgent(...e)}stopAgent(...e){return this.agentActions.stopAgent(...e)}clearContext(...e){return this.agentActions.clearContext(...e)}collapseContext(...e){return this.agentActions.collapseContext(...e)}removeAgentFromServer(...e){return this.agentActions.removeAgentFromServer(...e)}renameAgent(...e){return this.agentActions.renameAgent(...e)}updateAgentProperties(...e){return this.agentActions.updateAgentProperties(...e)}getTotalTokens(){return this.agentActions.getTotalTokens()}getSelectedAgents(){return this.agentActions.getSelectedAgents()}addActivity(...e){return this.agentActions.addActivity(...e)}addToolExecution(...e){return this.agentActions.addToolExecution(...e)}addFileChange(...e){return this.agentActions.addFileChange(...e)}loadToolHistory(){return this.agentActions.loadToolHistory()}addOutput(...e){return this.outputActions.addOutput(...e)}clearOutputs(...e){return this.outputActions.clearOutputs(...e)}getOutputs(...e){return this.outputActions.getOutputs(...e)}addUserPromptToOutput(...e){return this.outputActions.addUserPromptToOutput(...e)}getLastPrompt(...e){return this.outputActions.getLastPrompt(...e)}setLastPrompt(...e){return this.outputActions.setLastPrompt(...e)}preserveOutputs(){return this.outputActions.preserveOutputs()}mergeOutputsWithHistory(...e){return this.outputActions.mergeOutputsWithHistory(...e)}setSupervisorReport(...e){return this.supervisorActions.setSupervisorReport(...e)}addNarrative(...e){return this.supervisorActions.addNarrative(...e)}getNarratives(...e){return this.supervisorActions.getNarratives(...e)}setSupervisorStatus(...e){return this.supervisorActions.setSupervisorStatus(...e)}setSupervisorConfig(...e){return this.supervisorActions.setSupervisorConfig(...e)}requestSupervisorReport(){return this.supervisorActions.requestSupervisorReport()}requestAgentSupervisorHistory(...e){return this.supervisorActions.requestAgentSupervisorHistory(...e)}setAgentSupervisorHistory(...e){return this.supervisorActions.setAgentSupervisorHistory(...e)}getAgentSupervisorHistory(...e){return this.supervisorActions.getAgentSupervisorHistory(...e)}addAgentAnalysis(...e){return this.supervisorActions.addAgentAnalysis(...e)}isLoadingHistoryForAgent(...e){return this.supervisorActions.isLoadingHistoryForAgent(...e)}hasHistoryBeenFetched(...e){return this.supervisorActions.hasHistoryBeenFetched(...e)}setGlobalUsage(...e){return this.supervisorActions.setGlobalUsage(...e)}requestGlobalUsage(){return this.supervisorActions.requestGlobalUsage()}getGlobalUsage(){return this.supervisorActions.getGlobalUsage()}setActiveTool(...e){return this.areaActions.setActiveTool(...e)}selectArea(...e){return this.areaActions.selectArea(...e)}addArea(...e){return this.areaActions.addArea(...e)}updateArea(...e){return this.areaActions.updateArea(...e)}updateAreaLocal(...e){return this.areaActions.updateAreaLocal(...e)}deleteArea(...e){return this.areaActions.deleteArea(...e)}assignAgentToArea(...e){return this.areaActions.assignAgentToArea(...e)}unassignAgentFromArea(...e){return this.areaActions.unassignAgentFromArea(...e)}addDirectoryToArea(...e){return this.areaActions.addDirectoryToArea(...e)}removeDirectoryFromArea(...e){return this.areaActions.removeDirectoryFromArea(...e)}getAreaDirectories(...e){return this.areaActions.getAreaDirectories(...e)}isPositionInArea(...e){return this.areaActions.isPositionInArea(...e)}getAreaForAgent(...e){return this.areaActions.getAreaForAgent(...e)}setAreasFromServer(...e){return this.areaActions.setAreasFromServer(...e)}getAreasInZOrder(...e){return this.areaActions.getAreasInZOrder(...e)}getNextZIndex(...e){return this.areaActions.getNextZIndex(...e)}bringAreaToFront(...e){return this.areaActions.bringAreaToFront(...e)}sendAreaToBack(...e){return this.areaActions.sendAreaToBack(...e)}setAreaZIndex(...e){return this.areaActions.setAreaZIndex(...e)}archiveArea(...e){return this.areaActions.archiveArea(...e)}restoreArchivedArea(...e){return this.areaActions.restoreArchivedArea(...e)}getArchivedAreas(...e){return this.areaActions.getArchivedAreas(...e)}getVisibleAreas(...e){return this.areaActions.getVisibleAreas(...e)}isAgentInArchivedArea(...e){return this.areaActions.isAgentInArchivedArea(...e)}selectBuilding(...e){return this.buildingActions.selectBuilding(...e)}selectMultipleBuildings(...e){return this.buildingActions.selectMultipleBuildings(...e)}toggleBuildingSelection(...e){return this.buildingActions.toggleBuildingSelection(...e)}isBuildingSelected(...e){return this.buildingActions.isBuildingSelected(...e)}getSelectedBuildingIds(){return this.buildingActions.getSelectedBuildingIds()}deleteSelectedBuildings(){return this.buildingActions.deleteSelectedBuildings()}addBuilding(...e){return this.buildingActions.addBuilding(...e)}updateBuilding(...e){return this.buildingActions.updateBuilding(...e)}updateBuildingLocal(...e){return this.buildingActions.updateBuildingLocal(...e)}deleteBuilding(...e){return this.buildingActions.deleteBuilding(...e)}moveBuilding(...e){return this.buildingActions.moveBuilding(...e)}updateBuildingPosition(...e){return this.buildingActions.updateBuildingPosition(...e)}createBuilding(...e){return this.buildingActions.createBuilding(...e)}sendBuildingCommand(...e){return this.buildingActions.sendBuildingCommand(...e)}addBuildingLogs(...e){return this.buildingActions.addBuildingLogs(...e)}getBuildingLogs(...e){return this.buildingActions.getBuildingLogs(...e)}clearBuildingLogs(...e){return this.buildingActions.clearBuildingLogs(...e)}setBuildingsFromServer(...e){return this.buildingActions.setBuildingsFromServer(...e)}updateBuildingFromServer(...e){return this.buildingActions.updateBuildingFromServer(...e)}removeBuildingFromServer(...e){return this.buildingActions.removeBuildingFromServer(...e)}startLogStreaming(...e){return this.buildingActions.startLogStreaming(...e)}stopLogStreaming(...e){return this.buildingActions.stopLogStreaming(...e)}appendStreamingLogChunk(...e){return this.buildingActions.appendStreamingLogChunk(...e)}setStreamingStatus(...e){return this.buildingActions.setStreamingStatus(...e)}getStreamingLogs(...e){return this.buildingActions.getStreamingLogs(...e)}clearStreamingLogs(...e){return this.buildingActions.clearStreamingLogs(...e)}isLogStreaming(...e){return this.buildingActions.isLogStreaming(...e)}sendBossBuildingCommand(...e){return this.buildingActions.sendBossBuildingCommand(...e)}assignBuildingsToBoSS(...e){return this.buildingActions.assignBuildingsToBoSS(...e)}startBossLogStreaming(...e){return this.buildingActions.startBossLogStreaming(...e)}stopBossLogStreaming(...e){return this.buildingActions.stopBossLogStreaming(...e)}appendBossStreamingLogChunk(...e){return this.buildingActions.appendBossStreamingLogChunk(...e)}getBossStreamingLogs(...e){return this.buildingActions.getBossStreamingLogs(...e)}clearBossStreamingLogs(...e){return this.buildingActions.clearBossStreamingLogs(...e)}requestDockerContainersList(){return this.buildingActions.requestDockerContainersList()}setDockerContainersList(...e){return this.buildingActions.setDockerContainersList(...e)}getDockerContainersList(){return this.buildingActions.getDockerContainersList()}getDockerComposeProjectsList(){return this.buildingActions.getDockerComposeProjectsList()}setWorkflowDefinitionsFromServer(...e){return this.workflowActions.setWorkflowDefinitionsFromServer(...e)}addWorkflowDefinitionFromServer(...e){return this.workflowActions.addWorkflowDefinitionFromServer(...e)}updateWorkflowDefinitionFromServer(...e){return this.workflowActions.updateWorkflowDefinitionFromServer(...e)}removeWorkflowDefinitionFromServer(...e){return this.workflowActions.removeWorkflowDefinitionFromServer(...e)}createWorkflowDefinition(...e){return this.workflowActions.createWorkflowDefinition(...e)}updateWorkflowDefinition(...e){return this.workflowActions.updateWorkflowDefinition(...e)}deleteWorkflowDefinition(...e){return this.workflowActions.deleteWorkflowDefinition(...e)}moveWorkflow(...e){return this.workflowActions.moveWorkflow(...e)}setWorkflowInstancesFromServer(...e){return this.workflowActions.setWorkflowInstancesFromServer(...e)}updateWorkflowInstanceFromServer(...e){return this.workflowActions.updateWorkflowInstanceFromServer(...e)}removeWorkflowInstanceFromServer(...e){return this.workflowActions.removeWorkflowInstanceFromServer(...e)}startWorkflow(...e){return this.workflowActions.startWorkflow(...e)}pauseWorkflow(...e){return this.workflowActions.pauseWorkflow(...e)}resumeWorkflow(...e){return this.workflowActions.resumeWorkflow(...e)}cancelWorkflow(...e){return this.workflowActions.cancelWorkflow(...e)}manualTransition(...e){return this.workflowActions.manualTransition(...e)}selectWorkflow(...e){return this.workflowActions.selectWorkflow(...e)}openWorkflowDetail(...e){return this.workflowActions.openWorkflowDetail(...e)}closeWorkflowDetail(){return this.workflowActions.closeWorkflowDetail()}navigateToExecution(...e){return this.workflowActions.navigateToExecution(...e)}navigateToStep(...e){return this.workflowActions.navigateToStep(...e)}navigateBack(){return this.workflowActions.navigateBack()}getWorkflowModelStatus(...e){return this.workflowActions.getWorkflowModelStatus(...e)}addWorkflowChatMessage(...e){return this.workflowActions.addWorkflowChatMessage(...e)}setWorkflowChatScope(...e){return this.workflowActions.setWorkflowChatScope(...e)}setWorkflowChatLoading(...e){return this.workflowActions.setWorkflowChatLoading(...e)}clearWorkflowChat(){return this.workflowActions.clearWorkflowChat()}getWorkflowDefinition(...e){return this.workflowActions.getWorkflowDefinition(...e)}getWorkflowInstances(...e){return this.workflowActions.getWorkflowInstances(...e)}getAllWorkflowDefinitions(){return this.workflowActions.getAllWorkflowDefinitions()}addPermissionRequest(...e){return this.permissionActions.addPermissionRequest(...e)}resolvePermissionRequest(...e){return this.permissionActions.resolvePermissionRequest(...e)}respondToPermissionRequest(...e){return this.permissionActions.respondToPermissionRequest(...e)}getPendingPermissionsForAgent(...e){return this.permissionActions.getPendingPermissionsForAgent(...e)}clearAllPermissions(...e){return this.permissionActions.clearAllPermissions(...e)}spawnBossAgent(...e){return this.delegationActions.spawnBossAgent(...e)}assignSubordinates(...e){return this.delegationActions.assignSubordinates(...e)}removeSubordinate(...e){return this.delegationActions.removeSubordinate(...e)}sendBossCommand(...e){return this.delegationActions.sendBossCommand(...e)}requestDelegationHistory(...e){return this.delegationActions.requestDelegationHistory(...e)}handleDelegationDecision(...e){return this.delegationActions.handleDelegationDecision(...e)}setDelegationHistory(...e){return this.delegationActions.setDelegationHistory(...e)}getDelegationHistory(...e){return this.delegationActions.getDelegationHistory(...e)}getLastDelegationReceived(...e){return this.delegationActions.getLastDelegationReceived(...e)}clearLastDelegationReceived(...e){return this.delegationActions.clearLastDelegationReceived(...e)}updateBossSubordinates(...e){return this.delegationActions.updateBossSubordinates(...e)}getSubordinates(...e){return this.delegationActions.getSubordinates(...e)}isBossAgent(...e){return this.delegationActions.isBossAgent(...e)}getBossForAgent(...e){return this.delegationActions.getBossForAgent(...e)}getAvailableSubordinates(){return this.delegationActions.getAvailableSubordinates()}handleAgentTaskStarted(...e){return this.delegationActions.handleAgentTaskStarted(...e)}handleAgentTaskOutput(...e){return this.delegationActions.handleAgentTaskOutput(...e)}handleAgentTaskCompleted(...e){return this.delegationActions.handleAgentTaskCompleted(...e)}getAgentTaskProgress(...e){return this.delegationActions.getAgentTaskProgress(...e)}clearAgentTaskProgress(...e){return this.delegationActions.clearAgentTaskProgress(...e)}clearAllSubordinatesContext(...e){return this.delegationActions.clearAllSubordinatesContext(...e)}setSkillsFromServer(...e){return this.skillActions.setSkillsFromServer(...e)}addSkillFromServer(...e){return this.skillActions.addSkillFromServer(...e)}updateSkillFromServer(...e){return this.skillActions.updateSkillFromServer(...e)}removeSkillFromServer(...e){return this.skillActions.removeSkillFromServer(...e)}getSkill(...e){return this.skillActions.getSkill(...e)}getAllSkills(){return this.skillActions.getAllSkills()}getSkillsForAgent(...e){return this.skillActions.getSkillsForAgent(...e)}createSkill(...e){return this.skillActions.createSkill(...e)}updateSkill(...e){return this.skillActions.updateSkill(...e)}deleteSkill(...e){return this.skillActions.deleteSkill(...e)}assignSkillToAgent(...e){return this.skillActions.assignSkillToAgent(...e)}unassignSkillFromAgent(...e){return this.skillActions.unassignSkillFromAgent(...e)}requestAgentSkills(...e){return this.skillActions.requestAgentSkills(...e)}setCustomAgentClassesFromServer(...e){return this.skillActions.setCustomAgentClassesFromServer(...e)}addCustomAgentClassFromServer(...e){return this.skillActions.addCustomAgentClassFromServer(...e)}updateCustomAgentClassFromServer(...e){return this.skillActions.updateCustomAgentClassFromServer(...e)}removeCustomAgentClassFromServer(...e){return this.skillActions.removeCustomAgentClassFromServer(...e)}getCustomAgentClass(...e){return this.skillActions.getCustomAgentClass(...e)}getAllCustomAgentClasses(){return this.skillActions.getAllCustomAgentClasses()}createCustomAgentClass(...e){return this.skillActions.createCustomAgentClass(...e)}updateCustomAgentClass(...e){return this.skillActions.updateCustomAgentClass(...e)}deleteCustomAgentClass(...e){return this.skillActions.deleteCustomAgentClass(...e)}handleExecTaskStarted(...e){return this.execTaskActions.handleExecTaskStarted(...e)}handleExecTaskOutput(...e){return this.execTaskActions.handleExecTaskOutput(...e)}handleExecTaskCompleted(...e){return this.execTaskActions.handleExecTaskCompleted(...e)}stopExecTask(...e){return this.execTaskActions.stopExecTask(...e)}getExecTasks(...e){return this.execTaskActions.getExecTasks(...e)}getAllExecTasks(){return this.execTaskActions.getAllExecTasks()}getExecTask(...e){return this.execTaskActions.getExecTask(...e)}clearCompletedExecTasks(...e){return this.execTaskActions.clearCompletedExecTasks(...e)}clearAllExecTasks(...e){return this.execTaskActions.clearAllExecTasks(...e)}removeExecTask(...e){return this.execTaskActions.removeExecTask(...e)}setSecretsFromServer(...e){return this.secretActions.setSecretsFromServer(...e)}addSecretFromServer(...e){return this.secretActions.addSecretFromServer(...e)}updateSecretFromServer(...e){return this.secretActions.updateSecretFromServer(...e)}removeSecretFromServer(...e){return this.secretActions.removeSecretFromServer(...e)}getSecret(...e){return this.secretActions.getSecret(...e)}getSecretByKey(...e){return this.secretActions.getSecretByKey(...e)}getAllSecrets(){return this.secretActions.getAllSecrets()}createSecret(...e){return this.secretActions.createSecret(...e)}updateSecret(...e){return this.secretActions.updateSecret(...e)}deleteSecret(...e){return this.secretActions.deleteSecret(...e)}testDatabaseConnection(...e){return this.databaseActions.testDatabaseConnection(...e)}setConnectionStatus(...e){return this.databaseActions.setConnectionStatus(...e)}listDatabases(...e){return this.databaseActions.listDatabases(...e)}setDatabases(...e){return this.databaseActions.setDatabases(...e)}listTables(...e){return this.databaseActions.listTables(...e)}setTables(...e){return this.databaseActions.setTables(...e)}getTableSchema(...e){return this.databaseActions.getTableSchema(...e)}setTableSchema(...e){return this.databaseActions.setTableSchema(...e)}executeQuery(...e){return this.databaseActions.executeQuery(...e)}executeSilentQuery(...e){return this.databaseActions.executeSilentQuery(...e)}setSilentQueryResult(...e){return this.databaseActions.setSilentQueryResult(...e)}setQueryResult(...e){return this.databaseActions.setQueryResult(...e)}setExecutingQuery(...e){return this.databaseActions.setExecutingQuery(...e)}requestQueryHistory(...e){return this.databaseActions.requestQueryHistory(...e)}setQueryHistory(...e){return this.databaseActions.setQueryHistory(...e)}toggleQueryFavorite(...e){return this.databaseActions.toggleQueryFavorite(...e)}deleteQueryFromHistory(...e){return this.databaseActions.deleteQueryFromHistory(...e)}clearQueryHistory(...e){return this.databaseActions.clearQueryHistory(...e)}setActiveConnection(...e){return this.databaseActions.setActiveConnection(...e)}setActiveDatabase(...e){return this.databaseActions.setActiveDatabase(...e)}getDatabaseState(...e){return this.databaseActions.getDatabaseState(...e)}clearDatabaseState(...e){return this.databaseActions.clearDatabaseState(...e)}fetchSnapshots(...e){return this.snapshotActions.fetchSnapshots(...e)}setSnapshots(...e){return this.snapshotActions.setSnapshots(...e)}createSnapshot(...e){return this.snapshotActions.createSnapshot(...e)}loadSnapshot(...e){return this.snapshotActions.loadSnapshot(...e)}setCurrentSnapshot(...e){return this.snapshotActions.setCurrentSnapshot(...e)}deleteSnapshot(...e){return this.snapshotActions.deleteSnapshot(...e)}restoreFiles(...e){return this.snapshotActions.restoreFiles(...e)}setLoading(...e){return this.snapshotActions.setLoading(...e)}setError(...e){return this.snapshotActions.setError(...e)}clearError(...e){return this.snapshotActions.clearError(...e)}reset(...e){return this.snapshotActions.reset(...e)}addSubagent(...e){return this.subagentActions.addSubagent(...e)}completeSubagent(...e){return this.subagentActions.completeSubagent(...e)}getSubagentsForAgent(...e){return this.subagentActions.getSubagentsForAgent(...e)}getSubagent(...e){return this.subagentActions.getSubagent(...e)}removeSubagent(...e){return this.subagentActions.removeSubagent(...e)}getSubagentByToolUseId(...e){return this.subagentActions.getSubagentByToolUseId(...e)}addSubagentActivity(...e){return this.subagentActions.addSubagentActivity(...e)}updateSubagentStats(...e){return this.subagentActions.updateSubagentStats(...e)}addSubagentStreamEntries(...e){return this.subagentActions.addSubagentStreamEntries(...e)}hydrateSubagentsFromHistory(...e){return this.subagentActions.hydrateSubagentsFromHistory(...e)}}const bS=1;function gL(){return typeof window<"u"?(window.__tideStore&&window.__tideStoreVersion===bS||(window.__tideStore=new gS,window.__tideStoreVersion=bS),window.__tideStore):new gS}const U=gL(),u1=x.createContext(null),bL={error:"❌",success:"✅",warning:"⚠️",info:"ℹ️"};let xL=0;function yL({children:t}){const[e,n]=x.useState(null),s=x.useRef([]),a=x.useRef(null),r=x.useCallback(()=>{if(s.current.length>0&&!e){const d=s.current.shift();n(d)}},[e]);x.useEffect(()=>{e||r()},[e,r]),x.useEffect(()=>{if(e&&e.duration>0)return a.current=window.setTimeout(()=>{n(null)},e.duration),()=>{a.current&&clearTimeout(a.current)}},[e]);const i=x.useCallback((d,f,h,m=5e3)=>{const y={id:++xL,type:d,title:f,message:h,duration:m};if(s.current.push(y),!e){const w=s.current.shift();n(w)}},[e]),c=x.useCallback(()=>{a.current&&clearTimeout(a.current),n(null)},[]);return o.jsxs(u1.Provider,{value:{showToast:i},children:[t,o.jsx("div",{id:"toast-container",children:e&&o.jsxs("div",{className:`toast ${e.type}`,children:[o.jsx("span",{className:"toast-icon",children:bL[e.type]}),o.jsxs("div",{className:"toast-content",children:[o.jsx("div",{className:"toast-title",children:e.title}),o.jsx("div",{className:"toast-message",children:e.message})]}),o.jsx("button",{className:"toast-close",onClick:c,children:"×"})]},e.id)})]})}function d1(){const t=x.useContext(u1);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const _o={scout:{icon:"🔍",color:"#4a9eff",description:"Codebase exploration, file discovery"},builder:{icon:"🔨",color:"#ff9e4a",description:"Feature implementation, writing code"},debugger:{icon:"🐛",color:"#ff4a4a",description:"Bug hunting, fixing issues"},architect:{icon:"📐",color:"#9e4aff",description:"Planning, design decisions"},warrior:{icon:"⚔️",color:"#ff4a9e",description:"Aggressive refactoring, migrations"},support:{icon:"💚",color:"#4aff9e",description:"Documentation, tests, cleanup"},boss:{icon:"👑",color:"#ffd700",description:"Team leader, delegates tasks to subordinates"}},Qp=_o,Mu={bypass:{label:"Permissionless",description:"Skip all permission prompts (less safe, faster)"},interactive:{label:"Interactive",description:"Ask for approval before sensitive operations"}},Df={"gpt-5.4":{label:"GPT-5.4",description:"Latest frontier model with advanced reasoning and coding",icon:"🌟"},"gpt-5.3-codex":{label:"GPT-5.3 Codex",description:"Latest frontier agentic coding model",icon:"⚙️"},"gpt-5.2-codex":{label:"GPT-5.2 Codex",description:"Frontier agentic coding model",icon:"🧠"},"gpt-5.1-codex-max":{label:"GPT-5.1 Codex Max",description:"Codex-optimized flagship for deep and fast reasoning",icon:"🚀"},"gpt-5.1-codex-mini":{label:"GPT-5.1 Codex Mini",description:"Optimized for codex, cheaper and faster",icon:"⚡"},"gpt-5.2":{label:"GPT-5.2",description:"General frontier model with strong reasoning and coding",icon:"🧩"}},Rf={sonnet:{label:"Sonnet",description:"Balanced performance and cost (recommended)",icon:"⚡"},opus:{label:"Opus",description:"Most capable, higher cost",icon:"🧠"},haiku:{label:"Haiku",description:"Fast and economical",icon:"🚀"}},Hg={low:{label:"Low",description:"Minimal reasoning, fastest responses",icon:"🏃"},medium:{label:"Medium",description:"Balanced reasoning effort",icon:"⚖️"},high:{label:"High",description:"Deep reasoning for complex tasks (default)",icon:"🔬"},max:{label:"Max",description:"Maximum reasoning, most thorough",icon:"🧠"}},nx="<<<BOSS_CONTEXT_START>>>",xS="<<<BOSS_CONTEXT_END>>>",vL={server:{icon:"🖥️",color:"#4aff9e",description:"Service with start/stop commands and logs"},link:{icon:"🔗",color:"#4a9eff",description:"Quick links to URLs"},database:{icon:"🗄️",color:"#ff9e4a",description:"Database connection and queries"},docker:{icon:"🐳",color:"#4ac1ff",description:"Docker container management"},monitor:{icon:"📊",color:"#ff4a9e",description:"System metrics and monitoring"},folder:{icon:"📁",color:"#ffd700",description:"Folder shortcut - opens file explorer on click"},boss:{icon:"👑",color:"#ffd700",description:"Boss building - manages multiple buildings with unified controls"},terminal:{icon:"💻",color:"#a855f7",description:"Interactive web terminal via ttyd"}},Yq={"server-rack":{label:"Server Rack",description:"Classic server rack with blinking LEDs"},tower:{label:"Control Tower",description:"Tall tower with rotating antenna"},dome:{label:"Data Dome",description:"Futuristic dome with energy ring"},pyramid:{label:"Power Pyramid",description:"Egyptian-style pyramid with glowing core"},desktop:{label:"Desktop PC",description:"Retro computer with monitor and keyboard"},"filing-cabinet":{label:"Filing Cabinet",description:"Office cabinet with sliding drawers"},satellite:{label:"Satellite Dish",description:"Communication dish with rotating receiver"},crystal:{label:"Data Crystal",description:"Floating crystal with energy particles"},factory:{label:"Mini Factory",description:"Industrial building with smoking chimney"},"command-center":{label:"Command Center",description:"Grand central hub for boss buildings with holographic rings"}},Gq={"":{label:"Auto-detect",description:"Let PM2 detect the interpreter"},node:{label:"Node.js",description:"JavaScript/TypeScript runtime"},bun:{label:"Bun",description:"Bun JavaScript runtime"},python3:{label:"Python 3",description:"Python 3 interpreter"},python:{label:"Python 2",description:"Python 2 interpreter (legacy)"},java:{label:"Java",description:"Java runtime (use with -jar args)"},php:{label:"PHP",description:"PHP interpreter"},bash:{label:"Bash",description:"Bash shell script"},none:{label:"None (Binary)",description:"Direct execution (compiled binaries)"}},Kq={no:{label:"No",description:"Do not automatically restart"},always:{label:"Always",description:"Always restart when stopped"},"unless-stopped":{label:"Unless Stopped",description:"Restart unless manually stopped"},"on-failure":{label:"On Failure",description:"Restart only on failure"}},Qq={always:{label:"Always",description:"Always pull the image"},missing:{label:"If Missing",description:"Pull only if image not present"},never:{label:"Never",description:"Never pull, use local only"}},wL={mysql:{label:"MySQL",icon:"🐬",defaultPort:3306},postgresql:{label:"PostgreSQL",icon:"🐘",defaultPort:5432},oracle:{label:"Oracle",icon:"🔶",defaultPort:1521},sqlite:{label:"SQLite",icon:"🪶",defaultPort:0},mssql:{label:"SQL Server",icon:"🔷",defaultPort:1433}},f1=x.createContext(null);function p1(t){const e=_o[t];if(e)return e.icon;const s=U.getState().customAgentClasses.get(t);return s?s.icon:"🤖"}function kL(t){const e=_o[t];if(e)return e.color;const s=U.getState().customAgentClasses.get(t);return s?s.color:"#888888"}const SL=3,yS=80;function CL({notification:t,onDismiss:e,onClick:n}){const s=x.useRef({startX:0,startY:0,locked:!1}),[a,r]=x.useState(0),[i,c]=x.useState(!1),d=x.useRef(!1),f="ontouchstart"in window||navigator.maxTouchPoints>0,h=p1(t.agentClass),m=kL(t.agentClass),b=x.useCallback(T=>{s.current={startX:T.touches[0].clientX,startY:T.touches[0].clientY,locked:!1},d.current=!1},[]),y=x.useCallback(T=>{const D=T.touches[0].clientX-s.current.startX,E=T.touches[0].clientY-s.current.startY;!s.current.locked&&(Math.abs(D)<10&&Math.abs(E)<10||(s.current.locked=!0,Math.abs(E)>Math.abs(D)))||D<0&&(d.current=!0,r(D))},[]),w=x.useCallback(()=>{a<-yS?(c(!0),xp(2),setTimeout(()=>e(t.id),200)):r(0),setTimeout(()=>{d.current=!1},50)},[a,e,t.id]),C=x.useCallback(()=>{d.current||n(t)},[n,t]),N=Math.min(Math.abs(a)/(yS*1.5),1),k=i?0:1-N*.6,j=i?"-120%":`${a}px`,S=d.current&&!i?"none":"transform 0.2s ease-out, opacity 0.2s ease-out";return o.jsxs("div",{className:`agent-notification${i?" is-dismissing":""}`,onClick:f?void 0:C,onTouchStart:b,onTouchMove:y,onTouchEnd:w,style:{"--agent-color":m,transform:`translateX(${j})`,opacity:k,transition:S},children:[o.jsxs("div",{className:"agent-notification-content",children:[o.jsxs("div",{className:"agent-notification-header",children:[o.jsx("span",{className:"agent-notification-icon",children:h}),o.jsx("span",{className:"agent-notification-name",children:t.agentName}),o.jsx("span",{className:"agent-notification-separator",children:"·"}),o.jsx("span",{className:"agent-notification-title",children:t.title})]}),o.jsx("div",{className:"agent-notification-message",children:t.message})]}),o.jsx("button",{className:"agent-notification-close",onClick:T=>{T.stopPropagation(),e(t.id)},children:"×"})]})}function AL({children:t}){const{t:e}=dt(["notifications"]),[n,s]=x.useState([]),a=x.useRef(new Map);x.useEffect(()=>()=>{a.current.forEach(d=>clearTimeout(d))},[]);const r=x.useCallback(d=>{s(h=>h.filter(m=>m.id!==d));const f=a.current.get(d);f&&(clearTimeout(f),a.current.delete(d))},[]),i=x.useCallback(d=>{U.setLatestNotificationAgentId(d.agentId),s(h=>{const m=[...h,d];if(m.length>SL){const b=m.shift();if(b){const y=a.current.get(b.id);y&&(clearTimeout(y),a.current.delete(b.id))}}return m});const f=window.setTimeout(()=>{r(d.id)},8e3);if(a.current.set(d.id,f),!Zu()){const h=p1(d.agentClass);SR({title:`${h} ${d.agentName}: ${d.title}`,body:d.message,data:{type:"agent_notification",agentId:d.agentId,notificationId:d.id}})}},[r]),c=x.useCallback(d=>{Nj(d.agentId),r(d.id)},[r]);return o.jsxs(f1.Provider,{value:{showAgentNotification:i},children:[t,o.jsx("div",{id:"agent-notification-container",children:n.map(d=>o.jsx(CL,{notification:d,onDismiss:r,onClick:c},d.id))})]})}function jL(){const t=x.useContext(f1);if(!t)throw new Error("useAgentNotification must be used within AgentNotificationProvider");return t}const NL={scout:{icon:"🔍",color:4890367,description:"Explores and searches codebase"},builder:{icon:"🔨",color:16752202,description:"Creates and builds features"},debugger:{icon:"🐛",color:16730698,description:"Finds and fixes bugs"},architect:{icon:"📐",color:10373887,description:"Plans and designs systems"},warrior:{icon:"⚔️",color:16730782,description:"Tackles tough problems"},support:{icon:"💚",color:4915102,description:"Helps and assists others"},boss:{icon:"👑",color:16766720,description:"Manages and delegates to subordinates"}},TL=["Alex","Sam","Jordan","Taylor","Casey","Morgan","Riley","Quinn","Avery","Blake","Cameron","Drew","Emery","Finley","Harper","Jamie","Kai","Logan","Max","Nico","Parker","Reese","Sage","Sky"],Xq=TL,_L={scout:"character-male-a.glb",builder:"character-male-b.glb",debugger:"character-female-a.glb",architect:"character-male-c.glb",warrior:"character-female-b.glb",support:"character-female-c.glb",boss:"character-male-c.glb"},Jq=[{id:"scout",model:"character-male-a.glb",name:"Explorer",gender:"Male"},{id:"builder",model:"character-male-b.glb",name:"Crafter",gender:"Male"},{id:"architect",model:"character-male-c.glb",name:"Planner",gender:"Male"},{id:"debugger",model:"character-female-a.glb",name:"Analyst",gender:"Female"},{id:"warrior",model:"character-female-b.glb",name:"Fighter",gender:"Female"},{id:"support",model:"character-female-c.glb",name:"Healer",gender:"Female"}],Zq=[{file:"character-male-a.glb",name:"Male A (Explorer)",gender:"Male"},{file:"character-male-b.glb",name:"Male B (Crafter)",gender:"Male"},{file:"character-male-c.glb",name:"Male C (Planner)",gender:"Male"},{file:"character-male-d.glb",name:"Male D",gender:"Male"},{file:"character-male-e.glb",name:"Male E",gender:"Male"},{file:"character-male-f.glb",name:"Male F",gender:"Male"},{file:"character-female-a.glb",name:"Female A (Analyst)",gender:"Female"},{file:"character-female-b.glb",name:"Female B (Fighter)",gender:"Female"},{file:"character-female-c.glb",name:"Female C (Healer)",gender:"Female"},{file:"character-female-d.glb",name:"Female D",gender:"Female"},{file:"character-female-e.glb",name:"Female E",gender:"Female"},{file:"character-female-f.glb",name:"Female F",gender:"Female"}],eV=3,tV=5,nV=1e3,sV=50,aV=1.2;function EL(t){return typeof t=="string"?t:"#"+t.toString(16).padStart(6,"0")}function fr(t,e){const n=NL[t];if(n)return{icon:n.icon,color:EL(n.color),description:n.description};const s=e.find(a=>a.id===t);return s?{icon:s.icon,color:s.color,description:s.description}:{icon:"🤖",color:"#888888"}}const ML=2e5,DL=258400;function iu(t){return Math.max(0,Math.min(100,t))}function vS(t){const e=t.provider==="codex"||t.provider==="opencode"?DL:ML,n=Math.max(1,Math.round(t.contextLimit||e)),s=Math.max(0,Math.min(Math.round(t.contextUsed||0),n)),a=iu(Number((s/n*100).toFixed(1))),r=t.contextStats;if(!r)return{totalTokens:s,contextWindow:n,usedPercent:a,freePercent:iu(Number((100-a).toFixed(1)))};const i=Math.max(1,Math.round(r.contextWindow||n)),c=Math.max(0,Math.min(Math.round(r.totalTokens||0),i)),d=iu(Number((r.usedPercent??c/i*100).toFixed(1)));return n!==i||s!==c?{totalTokens:s,contextWindow:n,usedPercent:a,freePercent:iu(Number((100-a).toFixed(1)))}:{totalTokens:c,contextWindow:i,usedPercent:d,freePercent:iu(Number((100-d).toFixed(1)))}}function RL(t){const e=Math.floor((Date.now()-t)/1e3);if(e<60)return`${e}s`;const n=Math.floor(e/60);if(n<60)return`${n}m`;const s=Math.floor(n/60);return s<24?`${s}h`:`${Math.floor(s/24)}d`}function wp(t){const e=Math.floor((Date.now()-t)/1e3);if(e<60)return"just now";const n=Math.floor(e/60);if(n<60)return`${n}m ago`;const s=Math.floor(n/60);return s<24?`${s}h ago`:`${Math.floor(s/24)}d ago`}function Xp(t){if(t.contextStats){const n=vS(t);return{remainingPercent:n.freePercent,usedPercent:n.usedPercent,hasData:!0,totalTokens:n.totalTokens,contextWindow:n.contextWindow,freeTokens:n.contextWindow-n.totalTokens}}const e=vS(t);return{remainingPercent:e.freePercent,usedPercent:e.usedPercent,hasData:!1,totalTokens:e.totalTokens,contextWindow:e.contextWindow,freeTokens:e.contextWindow-e.totalTokens}}function h1(t){return t<20?"#c85858":t<50?"#c89858":"#6a9a78"}const wS={working:0,waiting_permission:1,waiting:2,error:3,orphaned:4,idle:5,offline:6};function OL(t){return[...t].sort((e,n)=>{const s=wS[e.status]??5,a=wS[n.status]??5;return s!==a?s-a:(n.lastActivity||0)-(e.lastActivity||0)})}function LL(t,e){const n=new Map;for(const s of t){const a=e(s.id),r=(a==null?void 0:a.id)||null;n.has(r)||n.set(r,[]),n.get(r).push(s)}return n}function IL(t,e){return[...t].sort((n,s)=>{if(n===null)return 1;if(s===null)return-1;const a=n?e(n):void 0,r=s?e(s):void 0;return((a==null?void 0:a.name)||"").localeCompare((r==null?void 0:r.name)||"")})}function kS(t,e){if(e===ME)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),t;if(e===Lb||e===nj){let n=t.getIndex();if(n===null){const i=[],c=t.getAttribute("position");if(c!==void 0){for(let d=0;d<c.count;d++)i.push(d);t.setIndex(i),n=t.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),t}const s=n.count-2,a=[];if(e===Lb)for(let i=1;i<=s;i++)a.push(n.getX(0)),a.push(n.getX(i)),a.push(n.getX(i+1));else for(let i=0;i<s;i++)i%2===0?(a.push(n.getX(i)),a.push(n.getX(i+1)),a.push(n.getX(i+2))):(a.push(n.getX(i+2)),a.push(n.getX(i+1)),a.push(n.getX(i)));a.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=t.clone();return r.setIndex(a),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),t}class PL extends sj{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(n){return new UL(n)}),this.register(function(n){return new HL(n)}),this.register(function(n){return new JL(n)}),this.register(function(n){return new ZL(n)}),this.register(function(n){return new e2(n)}),this.register(function(n){return new qL(n)}),this.register(function(n){return new VL(n)}),this.register(function(n){return new YL(n)}),this.register(function(n){return new GL(n)}),this.register(function(n){return new $L(n)}),this.register(function(n){return new KL(n)}),this.register(function(n){return new WL(n)}),this.register(function(n){return new XL(n)}),this.register(function(n){return new QL(n)}),this.register(function(n){return new FL(n)}),this.register(function(n){return new t2(n)}),this.register(function(n){return new n2(n)})}load(e,n,s,a){const r=this;let i;if(this.resourcePath!=="")i=this.resourcePath;else if(this.path!==""){const f=Cu.extractUrlBase(e);i=Cu.resolveURL(f,this.path)}else i=Cu.extractUrlBase(e);this.manager.itemStart(e);const c=function(f){a?a(f):console.error(f),r.manager.itemError(e),r.manager.itemEnd(e)},d=new up(this.manager);d.setPath(this.path),d.setResponseType("arraybuffer"),d.setRequestHeader(this.requestHeader),d.setWithCredentials(this.withCredentials),d.load(e,function(f){try{r.parse(f,i,function(h){n(h),r.manager.itemEnd(e)},c)}catch(h){c(h)}},s,c)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,n,s,a){let r;const i={},c={},d=new TextDecoder;if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(d.decode(new Uint8Array(e,0,4))===m1){try{i[Jt.KHR_BINARY_GLTF]=new s2(e)}catch(m){a&&a(m);return}r=JSON.parse(i[Jt.KHR_BINARY_GLTF].content)}else r=JSON.parse(d.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){a&&a(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const f=new g2(r,{path:n||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});f.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const m=this.pluginCallbacks[h](f);m.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),c[m.name]=m,i[m.name]=!0}if(r.extensionsUsed)for(let h=0;h<r.extensionsUsed.length;++h){const m=r.extensionsUsed[h],b=r.extensionsRequired||[];switch(m){case Jt.KHR_MATERIALS_UNLIT:i[m]=new zL;break;case Jt.KHR_DRACO_MESH_COMPRESSION:i[m]=new a2(r,this.dracoLoader);break;case Jt.KHR_TEXTURE_TRANSFORM:i[m]=new r2;break;case Jt.KHR_MESH_QUANTIZATION:i[m]=new i2;break;default:b.indexOf(m)>=0&&c[m]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+m+'".')}}f.setExtensions(i),f.setPlugins(c),f.parse(s,a)}parseAsync(e,n){const s=this;return new Promise(function(a,r){s.parse(e,n,a,r)})}}function BL(){let t={};return{get:function(e){return t[e]},add:function(e,n){t[e]=n},remove:function(e){delete t[e]},removeAll:function(){t={}}}}const Jt={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class FL{constructor(e){this.parser=e,this.name=Jt.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,n=this.parser.json.nodes||[];for(let s=0,a=n.length;s<a;s++){const r=n[s];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const n=this.parser,s="light:"+e;let a=n.cache.get(s);if(a)return a;const r=n.json,d=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let f;const h=new Hr(16777215);d.color!==void 0&&h.setRGB(d.color[0],d.color[1],d.color[2],lr);const m=d.range!==void 0?d.range:0;switch(d.type){case"directional":f=new Ib(h),f.target.position.set(0,0,-1),f.add(f.target);break;case"point":f=new RE(h),f.distance=m;break;case"spot":f=new DE(h),f.distance=m,d.spot=d.spot||{},d.spot.innerConeAngle=d.spot.innerConeAngle!==void 0?d.spot.innerConeAngle:0,d.spot.outerConeAngle=d.spot.outerConeAngle!==void 0?d.spot.outerConeAngle:Math.PI/4,f.angle=d.spot.outerConeAngle,f.penumbra=1-d.spot.innerConeAngle/d.spot.outerConeAngle,f.target.position.set(0,0,-1),f.add(f.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+d.type)}return f.position.set(0,0,0),f.decay=2,Ir(f,d),d.intensity!==void 0&&(f.intensity=d.intensity),f.name=n.createUniqueName(d.name||"light_"+e),a=Promise.resolve(f),n.cache.add(s,a),a}getDependency(e,n){if(e==="light")return this._loadLight(n)}createNodeAttachment(e){const n=this,s=this.parser,r=s.json.nodes[e],c=(r.extensions&&r.extensions[this.name]||{}).light;return c===void 0?null:this._loadLight(c).then(function(d){return s._getNodeRef(n.cache,c,d)})}}class zL{constructor(){this.name=Jt.KHR_MATERIALS_UNLIT}getMaterialType(){return Fl}extendParams(e,n,s){const a=[];e.color=new Hr(1,1,1),e.opacity=1;const r=n.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const i=r.baseColorFactor;e.color.setRGB(i[0],i[1],i[2],lr),e.opacity=i[3]}r.baseColorTexture!==void 0&&a.push(s.assignTexture(e,"map",r.baseColorTexture,Br))}return Promise.all(a)}}class $L{constructor(e){this.parser=e,this.name=Jt.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,n){const a=this.parser.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=a.extensions[this.name].emissiveStrength;return r!==void 0&&(n.emissiveIntensity=r),Promise.resolve()}}class UL{constructor(e){this.parser=e,this.name=Jt.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:cr}extendMaterialParams(e,n){const s=this.parser,a=s.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],i=a.extensions[this.name];if(i.clearcoatFactor!==void 0&&(n.clearcoat=i.clearcoatFactor),i.clearcoatTexture!==void 0&&r.push(s.assignTexture(n,"clearcoatMap",i.clearcoatTexture)),i.clearcoatRoughnessFactor!==void 0&&(n.clearcoatRoughness=i.clearcoatRoughnessFactor),i.clearcoatRoughnessTexture!==void 0&&r.push(s.assignTexture(n,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),i.clearcoatNormalTexture!==void 0&&(r.push(s.assignTexture(n,"clearcoatNormalMap",i.clearcoatNormalTexture)),i.clearcoatNormalTexture.scale!==void 0)){const c=i.clearcoatNormalTexture.scale;n.clearcoatNormalScale=new aj(c,c)}return Promise.all(r)}}class HL{constructor(e){this.parser=e,this.name=Jt.KHR_MATERIALS_DISPERSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:cr}extendMaterialParams(e,n){const a=this.parser.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=a.extensions[this.name];return n.dispersion=r.dispersion!==void 0?r.dispersion:0,Promise.resolve()}}class WL{constructor(e){this.parser=e,this.name=Jt.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:cr}extendMaterialParams(e,n){const s=this.parser,a=s.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],i=a.extensions[this.name];return i.iridescenceFactor!==void 0&&(n.iridescence=i.iridescenceFactor),i.iridescenceTexture!==void 0&&r.push(s.assignTexture(n,"iridescenceMap",i.iridescenceTexture)),i.iridescenceIor!==void 0&&(n.iridescenceIOR=i.iridescenceIor),n.iridescenceThicknessRange===void 0&&(n.iridescenceThicknessRange=[100,400]),i.iridescenceThicknessMinimum!==void 0&&(n.iridescenceThicknessRange[0]=i.iridescenceThicknessMinimum),i.iridescenceThicknessMaximum!==void 0&&(n.iridescenceThicknessRange[1]=i.iridescenceThicknessMaximum),i.iridescenceThicknessTexture!==void 0&&r.push(s.assignTexture(n,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(r)}}class qL{constructor(e){this.parser=e,this.name=Jt.KHR_MATERIALS_SHEEN}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:cr}extendMaterialParams(e,n){const s=this.parser,a=s.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[];n.sheenColor=new Hr(0,0,0),n.sheenRoughness=0,n.sheen=1;const i=a.extensions[this.name];if(i.sheenColorFactor!==void 0){const c=i.sheenColorFactor;n.sheenColor.setRGB(c[0],c[1],c[2],lr)}return i.sheenRoughnessFactor!==void 0&&(n.sheenRoughness=i.sheenRoughnessFactor),i.sheenColorTexture!==void 0&&r.push(s.assignTexture(n,"sheenColorMap",i.sheenColorTexture,Br)),i.sheenRoughnessTexture!==void 0&&r.push(s.assignTexture(n,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(r)}}class VL{constructor(e){this.parser=e,this.name=Jt.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:cr}extendMaterialParams(e,n){const s=this.parser,a=s.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],i=a.extensions[this.name];return i.transmissionFactor!==void 0&&(n.transmission=i.transmissionFactor),i.transmissionTexture!==void 0&&r.push(s.assignTexture(n,"transmissionMap",i.transmissionTexture)),Promise.all(r)}}class YL{constructor(e){this.parser=e,this.name=Jt.KHR_MATERIALS_VOLUME}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:cr}extendMaterialParams(e,n){const s=this.parser,a=s.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],i=a.extensions[this.name];n.thickness=i.thicknessFactor!==void 0?i.thicknessFactor:0,i.thicknessTexture!==void 0&&r.push(s.assignTexture(n,"thicknessMap",i.thicknessTexture)),n.attenuationDistance=i.attenuationDistance||1/0;const c=i.attenuationColor||[1,1,1];return n.attenuationColor=new Hr().setRGB(c[0],c[1],c[2],lr),Promise.all(r)}}class GL{constructor(e){this.parser=e,this.name=Jt.KHR_MATERIALS_IOR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:cr}extendMaterialParams(e,n){const a=this.parser.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=a.extensions[this.name];return n.ior=r.ior!==void 0?r.ior:1.5,Promise.resolve()}}class KL{constructor(e){this.parser=e,this.name=Jt.KHR_MATERIALS_SPECULAR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:cr}extendMaterialParams(e,n){const s=this.parser,a=s.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],i=a.extensions[this.name];n.specularIntensity=i.specularFactor!==void 0?i.specularFactor:1,i.specularTexture!==void 0&&r.push(s.assignTexture(n,"specularIntensityMap",i.specularTexture));const c=i.specularColorFactor||[1,1,1];return n.specularColor=new Hr().setRGB(c[0],c[1],c[2],lr),i.specularColorTexture!==void 0&&r.push(s.assignTexture(n,"specularColorMap",i.specularColorTexture,Br)),Promise.all(r)}}class QL{constructor(e){this.parser=e,this.name=Jt.EXT_MATERIALS_BUMP}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:cr}extendMaterialParams(e,n){const s=this.parser,a=s.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],i=a.extensions[this.name];return n.bumpScale=i.bumpFactor!==void 0?i.bumpFactor:1,i.bumpTexture!==void 0&&r.push(s.assignTexture(n,"bumpMap",i.bumpTexture)),Promise.all(r)}}class XL{constructor(e){this.parser=e,this.name=Jt.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:cr}extendMaterialParams(e,n){const s=this.parser,a=s.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],i=a.extensions[this.name];return i.anisotropyStrength!==void 0&&(n.anisotropy=i.anisotropyStrength),i.anisotropyRotation!==void 0&&(n.anisotropyRotation=i.anisotropyRotation),i.anisotropyTexture!==void 0&&r.push(s.assignTexture(n,"anisotropyMap",i.anisotropyTexture)),Promise.all(r)}}class JL{constructor(e){this.parser=e,this.name=Jt.KHR_TEXTURE_BASISU}loadTexture(e){const n=this.parser,s=n.json,a=s.textures[e];if(!a.extensions||!a.extensions[this.name])return null;const r=a.extensions[this.name],i=n.options.ktx2Loader;if(!i){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return n.loadTextureImage(e,r.source,i)}}class ZL{constructor(e){this.parser=e,this.name=Jt.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const n=this.name,s=this.parser,a=s.json,r=a.textures[e];if(!r.extensions||!r.extensions[n])return null;const i=r.extensions[n],c=a.images[i.source];let d=s.textureLoader;if(c.uri){const f=s.options.manager.getHandler(c.uri);f!==null&&(d=f)}return this.detectSupport().then(function(f){if(f)return s.loadTextureImage(e,i.source,d);if(a.extensionsRequired&&a.extensionsRequired.indexOf(n)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const n=new Image;n.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",n.onload=n.onerror=function(){e(n.height===1)}})),this.isSupported}}class e2{constructor(e){this.parser=e,this.name=Jt.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const n=this.name,s=this.parser,a=s.json,r=a.textures[e];if(!r.extensions||!r.extensions[n])return null;const i=r.extensions[n],c=a.images[i.source];let d=s.textureLoader;if(c.uri){const f=s.options.manager.getHandler(c.uri);f!==null&&(d=f)}return this.detectSupport().then(function(f){if(f)return s.loadTextureImage(e,i.source,d);if(a.extensionsRequired&&a.extensionsRequired.indexOf(n)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return s.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const n=new Image;n.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",n.onload=n.onerror=function(){e(n.height===1)}})),this.isSupported}}class t2{constructor(e){this.name=Jt.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const n=this.parser.json,s=n.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const a=s.extensions[this.name],r=this.parser.getDependency("buffer",a.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(c){const d=a.byteOffset||0,f=a.byteLength||0,h=a.count,m=a.byteStride,b=new Uint8Array(c,d,f);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(h,m,b,a.mode,a.filter).then(function(y){return y.buffer}):i.ready.then(function(){const y=new ArrayBuffer(h*m);return i.decodeGltfBuffer(new Uint8Array(y),h,m,b,a.mode,a.filter),y})})}else return null}}class n2{constructor(e){this.name=Jt.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const n=this.parser.json,s=n.nodes[e];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const a=n.meshes[s.mesh];for(const f of a.primitives)if(f.mode!==Ca.TRIANGLES&&f.mode!==Ca.TRIANGLE_STRIP&&f.mode!==Ca.TRIANGLE_FAN&&f.mode!==void 0)return null;const i=s.extensions[this.name].attributes,c=[],d={};for(const f in i)c.push(this.parser.getDependency("accessor",i[f]).then(h=>(d[f]=h,d[f])));return c.length<1?null:(c.push(this.parser.createNodeMesh(e)),Promise.all(c).then(f=>{const h=f.pop(),m=h.isGroup?h.children:[h],b=f[0].count,y=[];for(const w of m){const C=new dp,N=new wo,k=new rj,j=new wo(1,1,1),S=new OE(w.geometry,w.material,b);for(let T=0;T<b;T++)d.TRANSLATION&&N.fromBufferAttribute(d.TRANSLATION,T),d.ROTATION&&k.fromBufferAttribute(d.ROTATION,T),d.SCALE&&j.fromBufferAttribute(d.SCALE,T),S.setMatrixAt(T,C.compose(N,k,j));for(const T in d)if(T==="_COLOR_0"){const D=d[T];S.instanceColor=new LE(D.array,D.itemSize,D.normalized)}else T!=="TRANSLATION"&&T!=="ROTATION"&&T!=="SCALE"&&w.geometry.setAttribute(T,d[T]);ij.prototype.copy.call(S,w),this.parser.assignFinalMaterial(S),y.push(S)}return h.isGroup?(h.clear(),h.add(...y),h):y[0]}))}}const m1="glTF",ou=12,SS={JSON:1313821514,BIN:5130562};class s2{constructor(e){this.name=Jt.KHR_BINARY_GLTF,this.content=null,this.body=null;const n=new DataView(e,0,ou),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(e.slice(0,4))),version:n.getUint32(4,!0),length:n.getUint32(8,!0)},this.header.magic!==m1)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const a=this.header.length-ou,r=new DataView(e,ou);let i=0;for(;i<a;){const c=r.getUint32(i,!0);i+=4;const d=r.getUint32(i,!0);if(i+=4,d===SS.JSON){const f=new Uint8Array(e,ou+i,c);this.content=s.decode(f)}else if(d===SS.BIN){const f=ou+i;this.body=e.slice(f,f+c)}i+=c}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class a2{constructor(e,n){if(!n)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Jt.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=n,this.dracoLoader.preload()}decodePrimitive(e,n){const s=this.json,a=this.dracoLoader,r=e.extensions[this.name].bufferView,i=e.extensions[this.name].attributes,c={},d={},f={};for(const h in i){const m=sx[h]||h.toLowerCase();c[m]=i[h]}for(const h in e.attributes){const m=sx[h]||h.toLowerCase();if(i[h]!==void 0){const b=s.accessors[e.attributes[h]],y=Ul[b.componentType];f[m]=y.name,d[m]=b.normalized===!0}}return n.getDependency("bufferView",r).then(function(h){return new Promise(function(m,b){a.decodeDracoFile(h,function(y){for(const w in y.attributes){const C=y.attributes[w],N=d[w];N!==void 0&&(C.normalized=N)}m(y)},c,f,lr,b)})})}}class r2{constructor(){this.name=Jt.KHR_TEXTURE_TRANSFORM}extendTexture(e,n){return(n.texCoord===void 0||n.texCoord===e.channel)&&n.offset===void 0&&n.rotation===void 0&&n.scale===void 0||(e=e.clone(),n.texCoord!==void 0&&(e.channel=n.texCoord),n.offset!==void 0&&e.offset.fromArray(n.offset),n.rotation!==void 0&&(e.rotation=n.rotation),n.scale!==void 0&&e.repeat.fromArray(n.scale),e.needsUpdate=!0),e}}class i2{constructor(){this.name=Jt.KHR_MESH_QUANTIZATION}}class g1 extends iM{constructor(e,n,s,a){super(e,n,s,a)}copySampleValue_(e){const n=this.resultBuffer,s=this.sampleValues,a=this.valueSize,r=e*a*3+a;for(let i=0;i!==a;i++)n[i]=s[r+i];return n}interpolate_(e,n,s,a){const r=this.resultBuffer,i=this.sampleValues,c=this.valueSize,d=c*2,f=c*3,h=a-n,m=(s-n)/h,b=m*m,y=b*m,w=e*f,C=w-f,N=-2*y+3*b,k=y-b,j=1-N,S=k-b+m;for(let T=0;T!==c;T++){const D=i[C+T+c],E=i[C+T+d]*h,I=i[w+T+c],O=i[w+T]*h;r[T]=j*D+S*E+N*I+k*O}return r}}const o2=new rj;class l2 extends g1{interpolate_(e,n,s,a){const r=super.interpolate_(e,n,s,a);return o2.fromArray(r).normalize().toArray(r),r}}const Ca={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Ul={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},CS={9728:lj,9729:Pb,9984:$E,9985:zE,9986:FE,9987:oj},AS={33071:HE,33648:UE,10497:Bb},Wg={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},sx={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Ci={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},c2={CUBICSPLINE:void 0,LINEAR:fj,STEP:sM},qg={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function u2(t){return t.DefaultMaterial===void 0&&(t.DefaultMaterial=new Tx({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:rM})),t.DefaultMaterial}function ho(t,e,n){for(const s in n.extensions)t[s]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[s]=n.extensions[s])}function Ir(t,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(t.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function d2(t,e,n){let s=!1,a=!1,r=!1;for(let f=0,h=e.length;f<h;f++){const m=e[f];if(m.POSITION!==void 0&&(s=!0),m.NORMAL!==void 0&&(a=!0),m.COLOR_0!==void 0&&(r=!0),s&&a&&r)break}if(!s&&!a&&!r)return Promise.resolve(t);const i=[],c=[],d=[];for(let f=0,h=e.length;f<h;f++){const m=e[f];if(s){const b=m.POSITION!==void 0?n.getDependency("accessor",m.POSITION):t.attributes.position;i.push(b)}if(a){const b=m.NORMAL!==void 0?n.getDependency("accessor",m.NORMAL):t.attributes.normal;c.push(b)}if(r){const b=m.COLOR_0!==void 0?n.getDependency("accessor",m.COLOR_0):t.attributes.color;d.push(b)}}return Promise.all([Promise.all(i),Promise.all(c),Promise.all(d)]).then(function(f){const h=f[0],m=f[1],b=f[2];return s&&(t.morphAttributes.position=h),a&&(t.morphAttributes.normal=m),r&&(t.morphAttributes.color=b),t.morphTargetsRelative=!0,t})}function f2(t,e){if(t.updateMorphTargets(),e.weights!==void 0)for(let n=0,s=e.weights.length;n<s;n++)t.morphTargetInfluences[n]=e.weights[n];if(e.extras&&Array.isArray(e.extras.targetNames)){const n=e.extras.targetNames;if(t.morphTargetInfluences.length===n.length){t.morphTargetDictionary={};for(let s=0,a=n.length;s<a;s++)t.morphTargetDictionary[n[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function p2(t){let e;const n=t.extensions&&t.extensions[Jt.KHR_DRACO_MESH_COMPRESSION];if(n?e="draco:"+n.bufferView+":"+n.indices+":"+Vg(n.attributes):e=t.indices+":"+Vg(t.attributes)+":"+t.mode,t.targets!==void 0)for(let s=0,a=t.targets.length;s<a;s++)e+=":"+Vg(t.targets[s]);return e}function Vg(t){let e="";const n=Object.keys(t).sort();for(let s=0,a=n.length;s<a;s++)e+=n[s]+":"+t[n[s]]+";";return e}function ax(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function h2(t){return t.search(/\.jpe?g($|\?)/i)>0||t.search(/^data\:image\/jpeg/)===0?"image/jpeg":t.search(/\.webp($|\?)/i)>0||t.search(/^data\:image\/webp/)===0?"image/webp":t.search(/\.ktx2($|\?)/i)>0||t.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const m2=new dp;class g2{constructor(e={},n={}){this.json=e,this.extensions={},this.plugins={},this.options=n,this.cache=new BL,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,a=-1,r=!1,i=-1;if(typeof navigator<"u"){const c=navigator.userAgent;s=/^((?!chrome|android).)*safari/i.test(c)===!0;const d=c.match(/Version\/(\d+)/);a=s&&d?parseInt(d[1],10):-1,r=c.indexOf("Firefox")>-1,i=r?c.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||s&&a<17||r&&i<98?this.textureLoader=new IE(this.options.manager):this.textureLoader=new PE(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new up(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,n){const s=this,a=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(i){return i._markDefs&&i._markDefs()}),Promise.all(this._invokeAll(function(i){return i.beforeRoot&&i.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(i){const c={scene:i[0][a.scene||0],scenes:i[0],animations:i[1],cameras:i[2],asset:a.asset,parser:s,userData:{}};return ho(r,c,a),Ir(c,a),Promise.all(s._invokeAll(function(d){return d.afterRoot&&d.afterRoot(c)})).then(function(){for(const d of c.scenes)d.updateMatrixWorld();e(c)})}).catch(n)}_markDefs(){const e=this.json.nodes||[],n=this.json.skins||[],s=this.json.meshes||[];for(let a=0,r=n.length;a<r;a++){const i=n[a].joints;for(let c=0,d=i.length;c<d;c++)e[i[c]].isBone=!0}for(let a=0,r=e.length;a<r;a++){const i=e[a];i.mesh!==void 0&&(this._addNodeRef(this.meshCache,i.mesh),i.skin!==void 0&&(s[i.mesh].isSkinnedMesh=!0)),i.camera!==void 0&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(e,n){n!==void 0&&(e.refs[n]===void 0&&(e.refs[n]=e.uses[n]=0),e.refs[n]++)}_getNodeRef(e,n,s){if(e.refs[n]<=1)return s;const a=s.clone(),r=(i,c)=>{const d=this.associations.get(i);d!=null&&this.associations.set(c,d);for(const[f,h]of i.children.entries())r(h,c.children[f])};return r(s,a),a.name+="_instance_"+e.uses[n]++,a}_invokeOne(e){const n=Object.values(this.plugins);n.push(this);for(let s=0;s<n.length;s++){const a=e(n[s]);if(a)return a}return null}_invokeAll(e){const n=Object.values(this.plugins);n.unshift(this);const s=[];for(let a=0;a<n.length;a++){const r=e(n[a]);r&&s.push(r)}return s}getDependency(e,n){const s=e+":"+n;let a=this.cache.get(s);if(!a){switch(e){case"scene":a=this.loadScene(n);break;case"node":a=this._invokeOne(function(r){return r.loadNode&&r.loadNode(n)});break;case"mesh":a=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(n)});break;case"accessor":a=this.loadAccessor(n);break;case"bufferView":a=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(n)});break;case"buffer":a=this.loadBuffer(n);break;case"material":a=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(n)});break;case"texture":a=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(n)});break;case"skin":a=this.loadSkin(n);break;case"animation":a=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(n)});break;case"camera":a=this.loadCamera(n);break;default:if(a=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,n)}),!a)throw new Error("Unknown type: "+e);break}this.cache.add(s,a)}return a}getDependencies(e){let n=this.cache.get(e);if(!n){const s=this,a=this.json[e+(e==="mesh"?"es":"s")]||[];n=Promise.all(a.map(function(r,i){return s.getDependency(e,i)})),this.cache.add(e,n)}return n}loadBuffer(e){const n=this.json.buffers[e],s=this.fileLoader;if(n.type&&n.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+n.type+" buffer type is not supported.");if(n.uri===void 0&&e===0)return Promise.resolve(this.extensions[Jt.KHR_BINARY_GLTF].body);const a=this.options;return new Promise(function(r,i){s.load(Cu.resolveURL(n.uri,a.path),r,void 0,function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+n.uri+'".'))})})}loadBufferView(e){const n=this.json.bufferViews[e];return this.getDependency("buffer",n.buffer).then(function(s){const a=n.byteLength||0,r=n.byteOffset||0;return s.slice(r,r+a)})}loadAccessor(e){const n=this,s=this.json,a=this.json.accessors[e];if(a.bufferView===void 0&&a.sparse===void 0){const i=Wg[a.type],c=Ul[a.componentType],d=a.normalized===!0,f=new c(a.count*i);return Promise.resolve(new Au(f,i,d))}const r=[];return a.bufferView!==void 0?r.push(this.getDependency("bufferView",a.bufferView)):r.push(null),a.sparse!==void 0&&(r.push(this.getDependency("bufferView",a.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",a.sparse.values.bufferView))),Promise.all(r).then(function(i){const c=i[0],d=Wg[a.type],f=Ul[a.componentType],h=f.BYTES_PER_ELEMENT,m=h*d,b=a.byteOffset||0,y=a.bufferView!==void 0?s.bufferViews[a.bufferView].byteStride:void 0,w=a.normalized===!0;let C,N;if(y&&y!==m){const k=Math.floor(b/y),j="InterleavedBuffer:"+a.bufferView+":"+a.componentType+":"+k+":"+a.count;let S=n.cache.get(j);S||(C=new f(c,k*y,a.count*y/h),S=new BE(C,y/h),n.cache.add(j,S)),N=new aM(S,d,b%y/h,w)}else c===null?C=new f(a.count*d):C=new f(c,b,a.count*d),N=new Au(C,d,w);if(a.sparse!==void 0){const k=Wg.SCALAR,j=Ul[a.sparse.indices.componentType],S=a.sparse.indices.byteOffset||0,T=a.sparse.values.byteOffset||0,D=new j(i[1],S,a.sparse.count*k),E=new f(i[2],T,a.sparse.count*d);c!==null&&(N=new Au(N.array.slice(),N.itemSize,N.normalized)),N.normalized=!1;for(let I=0,O=D.length;I<O;I++){const _=D[I];if(N.setX(_,E[I*d]),d>=2&&N.setY(_,E[I*d+1]),d>=3&&N.setZ(_,E[I*d+2]),d>=4&&N.setW(_,E[I*d+3]),d>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}N.normalized=w}return N})}loadTexture(e){const n=this.json,s=this.options,r=n.textures[e].source,i=n.images[r];let c=this.textureLoader;if(i.uri){const d=s.manager.getHandler(i.uri);d!==null&&(c=d)}return this.loadTextureImage(e,r,c)}loadTextureImage(e,n,s){const a=this,r=this.json,i=r.textures[e],c=r.images[n],d=(c.uri||c.bufferView)+":"+i.sampler;if(this.textureCache[d])return this.textureCache[d];const f=this.loadImageSource(n,s).then(function(h){h.flipY=!1,h.name=i.name||c.name||"",h.name===""&&typeof c.uri=="string"&&c.uri.startsWith("data:image/")===!1&&(h.name=c.uri);const b=(r.samplers||{})[i.sampler]||{};return h.magFilter=CS[b.magFilter]||Pb,h.minFilter=CS[b.minFilter]||oj,h.wrapS=AS[b.wrapS]||Bb,h.wrapT=AS[b.wrapT]||Bb,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==lj&&h.minFilter!==Pb,a.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[d]=f,f}loadImageSource(e,n){const s=this,a=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(m=>m.clone());const i=a.images[e],c=self.URL||self.webkitURL;let d=i.uri||"",f=!1;if(i.bufferView!==void 0)d=s.getDependency("bufferView",i.bufferView).then(function(m){f=!0;const b=new Blob([m],{type:i.mimeType});return d=c.createObjectURL(b),d});else if(i.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(d).then(function(m){return new Promise(function(b,y){let w=b;n.isImageBitmapLoader===!0&&(w=function(C){const N=new ek(C);N.needsUpdate=!0,b(N)}),n.load(Cu.resolveURL(m,r.path),w,void 0,y)})}).then(function(m){return f===!0&&c.revokeObjectURL(d),Ir(m,i),m.userData.mimeType=i.mimeType||h2(i.uri),m}).catch(function(m){throw console.error("THREE.GLTFLoader: Couldn't load texture",d),m});return this.sourceCache[e]=h,h}assignTexture(e,n,s,a){const r=this;return this.getDependency("texture",s.index).then(function(i){if(!i)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(i=i.clone(),i.channel=s.texCoord),r.extensions[Jt.KHR_TEXTURE_TRANSFORM]){const c=s.extensions!==void 0?s.extensions[Jt.KHR_TEXTURE_TRANSFORM]:void 0;if(c){const d=r.associations.get(i);i=r.extensions[Jt.KHR_TEXTURE_TRANSFORM].extendTexture(i,c),r.associations.set(i,d)}}return a!==void 0&&(i.colorSpace=a),e[n]=i,i})}assignFinalMaterial(e){const n=e.geometry;let s=e.material;const a=n.attributes.tangent===void 0,r=n.attributes.color!==void 0,i=n.attributes.normal===void 0;if(e.isPoints){const c="PointsMaterial:"+s.uuid;let d=this.cache.get(c);d||(d=new WE,Jf.prototype.copy.call(d,s),d.color.copy(s.color),d.map=s.map,d.sizeAttenuation=!1,this.cache.add(c,d)),s=d}else if(e.isLine){const c="LineBasicMaterial:"+s.uuid;let d=this.cache.get(c);d||(d=new qE,Jf.prototype.copy.call(d,s),d.color.copy(s.color),d.map=s.map,this.cache.add(c,d)),s=d}if(a||r||i){let c="ClonedMaterial:"+s.uuid+":";a&&(c+="derivative-tangents:"),r&&(c+="vertex-colors:"),i&&(c+="flat-shading:");let d=this.cache.get(c);d||(d=s.clone(),r&&(d.vertexColors=!0),i&&(d.flatShading=!0),a&&(d.normalScale&&(d.normalScale.y*=-1),d.clearcoatNormalScale&&(d.clearcoatNormalScale.y*=-1)),this.cache.add(c,d),this.associations.set(d,this.associations.get(s))),s=d}e.material=s}getMaterialType(){return Tx}loadMaterial(e){const n=this,s=this.json,a=this.extensions,r=s.materials[e];let i;const c={},d=r.extensions||{},f=[];if(d[Jt.KHR_MATERIALS_UNLIT]){const m=a[Jt.KHR_MATERIALS_UNLIT];i=m.getMaterialType(),f.push(m.extendParams(c,r,n))}else{const m=r.pbrMetallicRoughness||{};if(c.color=new Hr(1,1,1),c.opacity=1,Array.isArray(m.baseColorFactor)){const b=m.baseColorFactor;c.color.setRGB(b[0],b[1],b[2],lr),c.opacity=b[3]}m.baseColorTexture!==void 0&&f.push(n.assignTexture(c,"map",m.baseColorTexture,Br)),c.metalness=m.metallicFactor!==void 0?m.metallicFactor:1,c.roughness=m.roughnessFactor!==void 0?m.roughnessFactor:1,m.metallicRoughnessTexture!==void 0&&(f.push(n.assignTexture(c,"metalnessMap",m.metallicRoughnessTexture)),f.push(n.assignTexture(c,"roughnessMap",m.metallicRoughnessTexture))),i=this._invokeOne(function(b){return b.getMaterialType&&b.getMaterialType(e)}),f.push(Promise.all(this._invokeAll(function(b){return b.extendMaterialParams&&b.extendMaterialParams(e,c)})))}r.doubleSided===!0&&(c.side=cj);const h=r.alphaMode||qg.OPAQUE;if(h===qg.BLEND?(c.transparent=!0,c.depthWrite=!1):(c.transparent=!1,h===qg.MASK&&(c.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&i!==Fl&&(f.push(n.assignTexture(c,"normalMap",r.normalTexture)),c.normalScale=new aj(1,1),r.normalTexture.scale!==void 0)){const m=r.normalTexture.scale;c.normalScale.set(m,m)}if(r.occlusionTexture!==void 0&&i!==Fl&&(f.push(n.assignTexture(c,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(c.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&i!==Fl){const m=r.emissiveFactor;c.emissive=new Hr().setRGB(m[0],m[1],m[2],lr)}return r.emissiveTexture!==void 0&&i!==Fl&&f.push(n.assignTexture(c,"emissiveMap",r.emissiveTexture,Br)),Promise.all(f).then(function(){const m=new i(c);return r.name&&(m.name=r.name),Ir(m,r),n.associations.set(m,{materials:e}),r.extensions&&ho(a,m,r),m})}createUniqueName(e){const n=VE.sanitizeNodeName(e||"");return n in this.nodeNamesUsed?n+"_"+ ++this.nodeNamesUsed[n]:(this.nodeNamesUsed[n]=0,n)}loadGeometries(e){const n=this,s=this.extensions,a=this.primitiveCache;function r(c){return s[Jt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(c,n).then(function(d){return jS(d,c,n)})}const i=[];for(let c=0,d=e.length;c<d;c++){const f=e[c],h=p2(f),m=a[h];if(m)i.push(m.promise);else{let b;f.extensions&&f.extensions[Jt.KHR_DRACO_MESH_COMPRESSION]?b=r(f):b=jS(new uj,f,n),a[h]={primitive:f,promise:b},i.push(b)}}return Promise.all(i)}loadMesh(e){const n=this,s=this.json,a=this.extensions,r=s.meshes[e],i=r.primitives,c=[];for(let d=0,f=i.length;d<f;d++){const h=i[d].material===void 0?u2(this.cache):this.getDependency("material",i[d].material);c.push(h)}return c.push(n.loadGeometries(i)),Promise.all(c).then(function(d){const f=d.slice(0,d.length-1),h=d[d.length-1],m=[];for(let y=0,w=h.length;y<w;y++){const C=h[y],N=i[y];let k;const j=f[y];if(N.mode===Ca.TRIANGLES||N.mode===Ca.TRIANGLE_STRIP||N.mode===Ca.TRIANGLE_FAN||N.mode===void 0)k=r.isSkinnedMesh===!0?new YE(C,j):new Il(C,j),k.isSkinnedMesh===!0&&k.normalizeSkinWeights(),N.mode===Ca.TRIANGLE_STRIP?k.geometry=kS(k.geometry,nj):N.mode===Ca.TRIANGLE_FAN&&(k.geometry=kS(k.geometry,Lb));else if(N.mode===Ca.LINES)k=new GE(C,j);else if(N.mode===Ca.LINE_STRIP)k=new KE(C,j);else if(N.mode===Ca.LINE_LOOP)k=new QE(C,j);else if(N.mode===Ca.POINTS)k=new XE(C,j);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+N.mode);Object.keys(k.geometry.morphAttributes).length>0&&f2(k,r),k.name=n.createUniqueName(r.name||"mesh_"+e),Ir(k,r),N.extensions&&ho(a,k,N),n.assignFinalMaterial(k),m.push(k)}for(let y=0,w=m.length;y<w;y++)n.associations.set(m[y],{meshes:e,primitives:y});if(m.length===1)return r.extensions&&ho(a,m[0],r),m[0];const b=new xg;r.extensions&&ho(a,b,r),n.associations.set(b,{meshes:e});for(let y=0,w=m.length;y<w;y++)b.add(m[y]);return b})}loadCamera(e){let n;const s=this.json.cameras[e],a=s[s.type];if(!a){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?n=new dj(JE.radToDeg(a.yfov),a.aspectRatio||1,a.znear||1,a.zfar||2e6):s.type==="orthographic"&&(n=new ZE(-a.xmag,a.xmag,a.ymag,-a.ymag,a.znear,a.zfar)),s.name&&(n.name=this.createUniqueName(s.name)),Ir(n,s),Promise.resolve(n)}loadSkin(e){const n=this.json.skins[e],s=[];for(let a=0,r=n.joints.length;a<r;a++)s.push(this._loadNodeShallow(n.joints[a]));return n.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",n.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(a){const r=a.pop(),i=a,c=[],d=[];for(let f=0,h=i.length;f<h;f++){const m=i[f];if(m){c.push(m);const b=new dp;r!==null&&b.fromArray(r.array,f*16),d.push(b)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',n.joints[f])}return new eM(c,d)})}loadAnimation(e){const n=this.json,s=this,a=n.animations[e],r=a.name?a.name:"animation_"+e,i=[],c=[],d=[],f=[],h=[];for(let m=0,b=a.channels.length;m<b;m++){const y=a.channels[m],w=a.samplers[y.sampler],C=y.target,N=C.node,k=a.parameters!==void 0?a.parameters[w.input]:w.input,j=a.parameters!==void 0?a.parameters[w.output]:w.output;C.node!==void 0&&(i.push(this.getDependency("node",N)),c.push(this.getDependency("accessor",k)),d.push(this.getDependency("accessor",j)),f.push(w),h.push(C))}return Promise.all([Promise.all(i),Promise.all(c),Promise.all(d),Promise.all(f),Promise.all(h)]).then(function(m){const b=m[0],y=m[1],w=m[2],C=m[3],N=m[4],k=[];for(let j=0,S=b.length;j<S;j++){const T=b[j],D=y[j],E=w[j],I=C[j],O=N[j];if(T===void 0)continue;T.updateMatrix&&T.updateMatrix();const _=s._createAnimationTracks(T,D,E,I,O);if(_)for(let M=0;M<_.length;M++)k.push(_[M])}return new tM(r,void 0,k)})}createNodeMesh(e){const n=this.json,s=this,a=n.nodes[e];return a.mesh===void 0?null:s.getDependency("mesh",a.mesh).then(function(r){const i=s._getNodeRef(s.meshCache,a.mesh,r);return a.weights!==void 0&&i.traverse(function(c){if(c.isMesh)for(let d=0,f=a.weights.length;d<f;d++)c.morphTargetInfluences[d]=a.weights[d]}),i})}loadNode(e){const n=this.json,s=this,a=n.nodes[e],r=s._loadNodeShallow(e),i=[],c=a.children||[];for(let f=0,h=c.length;f<h;f++)i.push(s.getDependency("node",c[f]));const d=a.skin===void 0?Promise.resolve(null):s.getDependency("skin",a.skin);return Promise.all([r,Promise.all(i),d]).then(function(f){const h=f[0],m=f[1],b=f[2];b!==null&&h.traverse(function(y){y.isSkinnedMesh&&y.bind(b,m2)});for(let y=0,w=m.length;y<w;y++)h.add(m[y]);return h})}_loadNodeShallow(e){const n=this.json,s=this.extensions,a=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=n.nodes[e],i=r.name?a.createUniqueName(r.name):"",c=[],d=a._invokeOne(function(f){return f.createNodeMesh&&f.createNodeMesh(e)});return d&&c.push(d),r.camera!==void 0&&c.push(a.getDependency("camera",r.camera).then(function(f){return a._getNodeRef(a.cameraCache,r.camera,f)})),a._invokeAll(function(f){return f.createNodeAttachment&&f.createNodeAttachment(e)}).forEach(function(f){c.push(f)}),this.nodeCache[e]=Promise.all(c).then(function(f){let h;if(r.isBone===!0?h=new nM:f.length>1?h=new xg:f.length===1?h=f[0]:h=new ij,h!==f[0])for(let m=0,b=f.length;m<b;m++)h.add(f[m]);if(r.name&&(h.userData.name=r.name,h.name=i),Ir(h,r),r.extensions&&ho(s,h,r),r.matrix!==void 0){const m=new dp;m.fromArray(r.matrix),h.applyMatrix4(m)}else r.translation!==void 0&&h.position.fromArray(r.translation),r.rotation!==void 0&&h.quaternion.fromArray(r.rotation),r.scale!==void 0&&h.scale.fromArray(r.scale);return a.associations.has(h)||a.associations.set(h,{}),a.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const n=this.extensions,s=this.json.scenes[e],a=this,r=new xg;s.name&&(r.name=a.createUniqueName(s.name)),Ir(r,s),s.extensions&&ho(n,r,s);const i=s.nodes||[],c=[];for(let d=0,f=i.length;d<f;d++)c.push(a.getDependency("node",i[d]));return Promise.all(c).then(function(d){for(let h=0,m=d.length;h<m;h++)r.add(d[h]);const f=h=>{const m=new Map;for(const[b,y]of a.associations)(b instanceof Jf||b instanceof ek)&&m.set(b,y);return h.traverse(b=>{const y=a.associations.get(b);y!=null&&m.set(b,y)}),m};return a.associations=f(r),r})}_createAnimationTracks(e,n,s,a,r){const i=[],c=e.name?e.name:e.uuid,d=[];Ci[r.path]===Ci.weights?e.traverse(function(b){b.morphTargetInfluences&&d.push(b.name?b.name:b.uuid)}):d.push(c);let f;switch(Ci[r.path]){case Ci.weights:f=nk;break;case Ci.rotation:f=sk;break;case Ci.position:case Ci.scale:f=tk;break;default:switch(s.itemSize){case 1:f=nk;break;case 2:case 3:default:f=tk;break}break}const h=a.interpolation!==void 0?c2[a.interpolation]:fj,m=this._getArrayFromAccessor(s);for(let b=0,y=d.length;b<y;b++){const w=new f(d[b]+"."+Ci[r.path],n.array,m,h);a.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(w),i.push(w)}return i}_getArrayFromAccessor(e){let n=e.array;if(e.normalized){const s=ax(n.constructor),a=new Float32Array(n.length);for(let r=0,i=n.length;r<i;r++)a[r]=n[r]*s;n=a}return n}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(s){const a=this instanceof sk?l2:g1;return new a(this.times,this.values,this.getValueSize()/3,s)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function b2(t,e,n){const s=e.attributes,a=new oM;if(s.POSITION!==void 0){const c=n.json.accessors[s.POSITION],d=c.min,f=c.max;if(d!==void 0&&f!==void 0){if(a.set(new wo(d[0],d[1],d[2]),new wo(f[0],f[1],f[2])),c.normalized){const h=ax(Ul[c.componentType]);a.min.multiplyScalar(h),a.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=e.targets;if(r!==void 0){const c=new wo,d=new wo;for(let f=0,h=r.length;f<h;f++){const m=r[f];if(m.POSITION!==void 0){const b=n.json.accessors[m.POSITION],y=b.min,w=b.max;if(y!==void 0&&w!==void 0){if(d.setX(Math.max(Math.abs(y[0]),Math.abs(w[0]))),d.setY(Math.max(Math.abs(y[1]),Math.abs(w[1]))),d.setZ(Math.max(Math.abs(y[2]),Math.abs(w[2]))),b.normalized){const C=ax(Ul[b.componentType]);d.multiplyScalar(C)}c.max(d)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}a.expandByVector(c)}t.boundingBox=a;const i=new lM;a.getCenter(i.center),i.radius=a.min.distanceTo(a.max)/2,t.boundingSphere=i}function jS(t,e,n){const s=e.attributes,a=[];function r(i,c){return n.getDependency("accessor",i).then(function(d){t.setAttribute(c,d)})}for(const i in s){const c=sx[i]||i.toLowerCase();c in t.attributes||a.push(r(s[i],c))}if(e.indices!==void 0&&!t.index){const i=n.getDependency("accessor",e.indices).then(function(c){t.setIndex(c)});a.push(i)}return Fb.workingColorSpace!==lr&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Fb.workingColorSpace}" not supported.`),Ir(t,e),b2(t,e,n),Promise.all(a).then(function(){return e.targets!==void 0?d2(t,e.targets,n):t})}const Yg=new WeakMap;class x2 extends sj{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,n,s,a){const r=new up(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,i=>{this.parse(i,n,a)},s,a)}parse(e,n,s=()=>{}){this.decodeDracoFile(e,n,null,null,Br,s).catch(s)}decodeDracoFile(e,n,s,a,r=lr,i=()=>{}){const c={attributeIDs:s||this.defaultAttributeIDs,attributeTypes:a||this.defaultAttributeTypes,useUniqueIDs:!!s,vertexColorSpace:r};return this.decodeGeometry(e,c).then(n).catch(i)}decodeGeometry(e,n){const s=JSON.stringify(n);if(Yg.has(e)){const d=Yg.get(e);if(d.key===s)return d.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let a;const r=this.workerNextTaskID++,i=e.byteLength,c=this._getWorker(r,i).then(d=>(a=d,new Promise((f,h)=>{a._callbacks[r]={resolve:f,reject:h},a.postMessage({type:"decode",id:r,taskConfig:n,buffer:e},[e])}))).then(d=>this._createGeometry(d.geometry));return c.catch(()=>!0).then(()=>{a&&r&&this._releaseTask(a,r)}),Yg.set(e,{key:s,promise:c}),c}_createGeometry(e){const n=new uj;e.index&&n.setIndex(new Au(e.index.array,1));for(let s=0;s<e.attributes.length;s++){const a=e.attributes[s],r=a.name,i=a.array,c=a.itemSize,d=new Au(i,c);r==="color"&&(this._assignVertexColorSpace(d,a.vertexColorSpace),d.normalized=!(i instanceof Float32Array)),n.setAttribute(r,d)}return n}_assignVertexColorSpace(e,n){if(n!==Br)return;const s=new Hr;for(let a=0,r=e.count;a<r;a++)s.fromBufferAttribute(e,a),Fb.toWorkingColorSpace(s,Br),e.setXYZ(a,s.r,s.g,s.b)}_loadLibrary(e,n){const s=new up(this.manager);return s.setPath(this.decoderPath),s.setResponseType(n),s.setWithCredentials(this.withCredentials),new Promise((a,r)=>{s.load(e,a,void 0,r)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",n=[];return e?n.push(this._loadLibrary("draco_decoder.js","text")):(n.push(this._loadLibrary("draco_wasm_wrapper.js","text")),n.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(n).then(s=>{const a=s[0];e||(this.decoderConfig.wasmBinary=s[1]);const r=y2.toString(),i=["/* draco decoder */",a,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join(`
47
- `);this.workerSourceURL=URL.createObjectURL(new Blob([i]))}),this.decoderPending}_getWorker(e,n){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const a=new Worker(this.workerSourceURL);a._callbacks={},a._taskCosts={},a._taskLoad=0,a.postMessage({type:"init",decoderConfig:this.decoderConfig}),a.onmessage=function(r){const i=r.data;switch(i.type){case"decode":a._callbacks[i.id].resolve(i);break;case"error":a._callbacks[i.id].reject(i);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+i.type+'"')}},this.workerPool.push(a)}else this.workerPool.sort(function(a,r){return a._taskLoad>r._taskLoad?-1:1});const s=this.workerPool[this.workerPool.length-1];return s._taskCosts[e]=n,s._taskLoad+=n,s})}_releaseTask(e,n){e._taskLoad-=e._taskCosts[n],delete e._callbacks[n],delete e._taskCosts[n]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function y2(){let t,e;onmessage=function(i){const c=i.data;switch(c.type){case"init":t=c.decoderConfig,e=new Promise(function(h){t.onModuleLoaded=function(m){h({draco:m})},DracoDecoderModule(t)});break;case"decode":const d=c.buffer,f=c.taskConfig;e.then(h=>{const m=h.draco,b=new m.Decoder;try{const y=n(m,b,new Int8Array(d),f),w=y.attributes.map(C=>C.array.buffer);y.index&&w.push(y.index.array.buffer),self.postMessage({type:"decode",id:c.id,geometry:y},w)}catch(y){console.error(y),self.postMessage({type:"error",id:c.id,error:y.message})}finally{m.destroy(b)}});break}};function n(i,c,d,f){const h=f.attributeIDs,m=f.attributeTypes;let b,y;const w=c.GetEncodedGeometryType(d);if(w===i.TRIANGULAR_MESH)b=new i.Mesh,y=c.DecodeArrayToMesh(d,d.byteLength,b);else if(w===i.POINT_CLOUD)b=new i.PointCloud,y=c.DecodeArrayToPointCloud(d,d.byteLength,b);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!y.ok()||b.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+y.error_msg());const C={index:null,attributes:[]};for(const N in h){const k=self[m[N]];let j,S;if(f.useUniqueIDs)S=h[N],j=c.GetAttributeByUniqueId(b,S);else{if(S=c.GetAttributeId(b,i[h[N]]),S===-1)continue;j=c.GetAttribute(b,S)}const T=a(i,c,b,N,k,j);N==="color"&&(T.vertexColorSpace=f.vertexColorSpace),C.attributes.push(T)}return w===i.TRIANGULAR_MESH&&(C.index=s(i,c,b)),i.destroy(b),C}function s(i,c,d){const h=d.num_faces()*3,m=h*4,b=i._malloc(m);c.GetTrianglesUInt32Array(d,m,b);const y=new Uint32Array(i.HEAPF32.buffer,b,h).slice();return i._free(b),{array:y,itemSize:1}}function a(i,c,d,f,h,m){const b=m.num_components(),w=d.num_points()*b,C=w*h.BYTES_PER_ELEMENT,N=r(i,h),k=i._malloc(C);c.GetAttributeDataArrayForAllPoints(d,m,N,C,k);const j=new h(i.HEAPF32.buffer,k,w).slice();return i._free(k),{name:f,array:j,itemSize:b}}function r(i,c){switch(c){case Float32Array:return i.DT_FLOAT32;case Int8Array:return i.DT_INT8;case Int16Array:return i.DT_INT16;case Int32Array:return i.DT_INT32;case Uint8Array:return i.DT_UINT8;case Uint16Array:return i.DT_UINT16;case Uint32Array:return i.DT_UINT32}}}var v2=(function(){var t="b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuikqbeeedddillviebeoweuec:q;iekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbol79IV9Rbrq:P8Yqdbk;3sezu8Jjjjjbcj;eb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Radz1jjjbhwcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhDcbhqinaqae9pmeaDaeaq9RaqaDfae6Egkcsfgocl4cifcd4hxdndndndnaoc9WGgmTmbcbhPcehsawcjdfhzalhHinaraH9Rax6midnaraHaxfgl9RcK6mbczhoinawcj;cbfaogifgoc9WfhOdndndndndnaHaic9WfgAco4fRbbaAci4coG4ciGPlbedibkaO9cb83ibaOcwf9cb83ibxikaOalRblalRbbgAco4gCaCciSgCE86bbaocGfalclfaCfgORbbaAcl4ciGgCaCciSgCE86bbaocVfaOaCfgORbbaAcd4ciGgCaCciSgCE86bbaoc7faOaCfgORbbaAciGgAaAciSgAE86bbaoctfaOaAfgARbbalRbegOco4gCaCciSgCE86bbaoc91faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc4faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc93faAaCfgARbbaOciGgOaOciSgOE86bbaoc94faAaOfgARbbalRbdgOco4gCaCciSgCE86bbaoc95faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc96faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc97faAaCfgARbbaOciGgOaOciSgOE86bbaoc98faAaOfgORbbalRbiglco4gAaAciSgAE86bbaoc99faOaAfgORbbalcl4ciGgAaAciSgAE86bbaoc9:faOaAfgORbbalcd4ciGgAaAciSgAE86bbaocufaOaAfgoRbbalciGglalciSglE86bbaoalfhlxdkaOalRbwalRbbgAcl4gCaCcsSgCE86bbaocGfalcwfaCfgORbbaAcsGgAaAcsSgAE86bbaocVfaOaAfgORbbalRbegAcl4gCaCcsSgCE86bbaoc7faOaCfgORbbaAcsGgAaAcsSgAE86bbaoctfaOaAfgORbbalRbdgAcl4gCaCcsSgCE86bbaoc91faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc4faOaAfgORbbalRbigAcl4gCaCcsSgCE86bbaoc93faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc94faOaAfgORbbalRblgAcl4gCaCcsSgCE86bbaoc95faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc96faOaAfgORbbalRbvgAcl4gCaCcsSgCE86bbaoc97faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc98faOaAfgORbbalRbogAcl4gCaCcsSgCE86bbaoc99faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc9:faOaAfgORbbalRbrglcl4gAaAcsSgAE86bbaocufaOaAfgoRbbalcsGglalcsSglE86bbaoalfhlxekaOal8Pbb83bbaOcwfalcwf8Pbb83bbalczfhlkdnaiam9pmbaiczfhoaral9RcL0mekkaiam6mialTmidnakTmbawaPfRbbhOcbhoazhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkkazcefhzaPcefgPad6hsalhHaPad9hmexvkkcbhlasceGmdxikalaxad2fhCdnakTmbcbhHcehsawcjdfhminaral9Rax6mialTmdalaxfhlawaHfRbbhOcbhoamhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkamcefhmaHcefgHad6hsaHad9hmbkaChlxikcbhocehsinaral9Rax6mdalTmealaxfhlaocefgoad6hsadao9hmbkaChlxdkcbhlasceGTmekc9:hoxikabaqad2fawcjdfakad2z1jjjb8Aawawcjdfakcufad2fadz1jjjb8Aakaqfhqalmbkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;ebf8Kjjjjbaok;yzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:jjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk;siliui99iue99dnaeTmbcbhiabhlindndnJ;Zl81Zalcof8UebgvciV:Y:vgoal8Ueb:YNgrJb;:FSNJbbbZJbbb:;arJbbbb9GEMgw:lJbbb9p9DTmbaw:OhDxekcjjjj94hDkalclf8Uebhqalcdf8UebhkabavcefciGaiVcetfaD87ebdndnaoak:YNgwJb;:FSNJbbbZJbbb:;awJbbbb9GEMgx:lJbbb9p9DTmbax:Ohkxekcjjjj94hkkabavcdfciGaiVcetfak87ebdndnaoaq:YNgoJb;:FSNJbbbZJbbb:;aoJbbbb9GEMgx:lJbbb9p9DTmbax:Ohqxekcjjjj94hqkabavcufciGaiVcetfaq87ebdndnJbbjZararN:tawawN:taoaoN:tgrJbbbbarJbbbb9GE:rJb;:FSNJbbbZMgr:lJbbb9p9DTmbar:Ohqxekcjjjj94hqkabavciGaiVcetfaq87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2geTmbinababydbgdcwtcw91:Yadce91cjjj;8ifcjjj98G::NUdbabclfhbaecufgembkkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaiczfhiaeczfheadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkkkebcjwklz9Kbb",e="b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuikqbbebeedddilve9Weeeviebeoweuec:q;Aekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbwl79IV9RbDq;t9tqlbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk;h8JlHud97euo978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Rad;8qbbcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhwcbhDinaDae9pmeawaeaD9RaDawfae6Egqcsfgoc9WGgkci2hxakcethmaocl4cifcd4hPabaDad2fhscbhzdnincehHalhOcbhAdninaraO9RaP6miavcj;cbfaAak2fhCaOaPfhlcbhidnakc;ab6mbaral9Rc;Gb6mbcbhoinaCaofhidndndndndnaOaoco4fRbbgXciGPlbedibkaipxbbbbbbbbbbbbbbbbpklbxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklbalczfhlkdndndndndnaXcd4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklzxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklzalczfhlkdndndndndnaXcl4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklaxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklaalczfhlkdndndndndnaXco4Plbedibkaipxbbbbbbbbbbbbbbbbpkl8WxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalclfaYpQbfaXc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalcwfaYpQbfaXc:q:yjjbfRbbfhlxekaialpbbbpkl8Walczfhlkaoc;abfhiaocjefak0meaihoaral9Rc;Fb0mbkkdndnaiak9pmbaici4hoinaral9RcK6mdaCaifhXdndndndndnaOaico4fRbbaocoG4ciGPlbedibkaXpxbbbbbbbbbbbbbbbbpklbxikaXalpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaXalpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaXalpbbbpklbalczfhlkaocdfhoaiczfgiak6mbkkalTmbaAci6hHalhOaAcefgohAaoclSmdxekkcbhlaHceGmdkdnakTmbavcjdfazfhiavazfpbdbhYcbhXinaiavcj;cbfaXfgopblbgLcep9TaLpxeeeeeeeeeeeeeeeegQp9op9Hp9rgLaoakfpblbg8Acep9Ta8AaQp9op9Hp9rg8ApmbzeHdOiAlCvXoQrLgEaoamfpblbg3cep9Ta3aQp9op9Hp9rg3aoaxfpblbg5cep9Ta5aQp9op9Hp9rg5pmbzeHdOiAlCvXoQrLg8EpmbezHdiOAlvCXorQLgQaQpmbedibedibedibediaYp9UgYp9AdbbaiadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaEa8EpmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwKDYq8AkEx3m5P8Es8FgLa3a5pmwKDYq8AkEx3m5P8Es8Fg8ApmbezHdiOAlvCXorQLgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfhiaXczfgXak6mbkkazclfgzad6mbkasavcjdfaqad2;8qbbavavcjdfaqcufad2fad;8qbbaqaDfhDc9:hoalmexikkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;kbf8Kjjjjbaokwbz:bjjjbk;uzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:EPliuo97eue978Jjjjjbca9Rhidndnadcl9hmbdnaec98GglTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalae9pmeaiaeciGgvcdtgdVcbczad9R;8kbaiabalcdtfglad;8qbbdnavTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkalaiad;8qbbskdnaec98GgxTmbcbhvabhdinadczfglalpbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oawaopmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgvax6mbkkaxae9pmbaiaeciGgvcitgdfcbcaad9R;8kbaiabaxcitfglad;8qbbdnavTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oawaopmbezHdiOAlvCXorQLp9qpklbkalaiad;8qbbkk;4wllue97euv978Jjjjjbc8W9Rhidnaec98GglTmbcbhvabhoinaiaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklbaopxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblbpEb:T:j83ibaocwfarp5eaipblbpEe:T:j83ibawaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblbpEd:T:j83ibaocKfakp5eaipblbpEi:T:j83ibaocafhoavclfgval6mbkkdnalae9pmbaiaeciGgvcitgofcbcaao9R;8kbaiabalcitfgwao;8qbbdnavTmbaiaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklaaipxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblapEb:T:j83ibaiarp5eaipblapEe:T:j83iwaiaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblapEd:T:j83izaiakp5eaipblapEi:T:j83iKkawaiao;8qbbkk:Pddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbhdabheinaeaepbbbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepkbbaeczfheadclfgdav6mbkkdnaval9pmbaialciGgdcdtgeVcbc;abae9R;8kbaiabavcdtfgvae;8qbbdnadTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepklbkavaiae;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz9Tbb",n=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),s=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!="object")return{supported:!1};var a=WebAssembly.validate(n)?e:t,r,i=WebAssembly.instantiate(c(a),{}).then(function(k){r=k.instance,r.exports.__wasm_call_ctors()});function c(k){for(var j=new Uint8Array(k.length),S=0;S<k.length;++S){var T=k.charCodeAt(S);j[S]=T>96?T-97:T>64?T-39:T+4}for(var D=0,S=0;S<k.length;++S)j[D++]=j[S]<60?s[j[S]]:(j[S]-60)*64+j[++S];return j.buffer.slice(0,D)}function d(k,j,S,T,D,E){var I=r.exports.sbrk,O=S+3&-4,_=I(O*T),M=I(D.length),R=new Uint8Array(r.exports.memory.buffer);R.set(D,M);var z=k(_,S,T,M,D.length);if(z==0&&E&&E(_,O,T),j.set(R.subarray(_,_+S*T)),I(_-I(0)),z!=0)throw new Error("Malformed buffer data: "+z)}var f={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},h={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},m=[],b=0;function y(k){var j={object:new Worker(k),pending:0,requests:{}};return j.object.onmessage=function(S){var T=S.data;j.pending-=T.count,j.requests[T.id][T.action](T.value),delete j.requests[T.id]},j}function w(k){for(var j="var instance; var ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(c(a))+"]), {}).then(function(result) { instance = result.instance; instance.exports.__wasm_call_ctors(); });self.onmessage = workerProcess;"+d.toString()+N.toString(),S=new Blob([j],{type:"text/javascript"}),T=URL.createObjectURL(S),D=0;D<k;++D)m[D]=y(T);URL.revokeObjectURL(T)}function C(k,j,S,T,D){for(var E=m[0],I=1;I<m.length;++I)m[I].pending<E.pending&&(E=m[I]);return new Promise(function(O,_){var M=new Uint8Array(S),R=b++;E.pending+=k,E.requests[R]={resolve:O,reject:_},E.object.postMessage({id:R,count:k,size:j,source:M,mode:T,filter:D},[M.buffer])})}function N(k){i.then(function(){var j=k.data;try{var S=new Uint8Array(j.count*j.size);d(r.exports[j.mode],S,j.count,j.size,j.source,r.exports[j.filter]),self.postMessage({id:j.id,count:j.count,action:"resolve",value:S},[S.buffer])}catch(T){self.postMessage({id:j.id,count:j.count,action:"reject",value:T})}})}return{ready:i,supported:!0,useWorkers:function(k){w(k)},decodeVertexBuffer:function(k,j,S,T,D){d(r.exports.meshopt_decodeVertexBuffer,k,j,S,T,r.exports[f[D]])},decodeIndexBuffer:function(k,j,S,T){d(r.exports.meshopt_decodeIndexBuffer,k,j,S,T)},decodeIndexSequence:function(k,j,S,T){d(r.exports.meshopt_decodeIndexSequence,k,j,S,T)},decodeGltfBuffer:function(k,j,S,T,D,E){d(r.exports[h[D]],k,j,S,T,r.exports[f[E]])},decodeGltfBufferAsync:function(k,j,S,T,D){return m.length>0?C(k,j,S,h[T],f[D]):i.then(function(){var E=new Uint8Array(k*j);return d(r.exports[h[T]],E,k,j,S,r.exports[f[D]]),E})}}})();const w2={idle:"idle",working:"walk",waiting:"sit",waiting_permission:"idle",error:"emote-no",offline:"static",orphaned:"idle"},NS={idle:4915102,working:4890367,waiting:16752202,waiting_permission:16763904,error:16730698,offline:8947848,orphaned:16752202};function b1({agentClass:t,modelFile:e,customModelFile:n,customModelUrl:s,modelScale:a=1,modelOffset:r,idleAnimation:i,status:c="idle",width:d=150,height:f=200}){const h=x.useRef(null),m=x.useRef(null),b=x.useRef(null),y=x.useRef(null),w=x.useRef(null),C=x.useRef(null),N=x.useRef(new Map),k=x.useRef(null),j=x.useRef(null),S=x.useRef(0),T=x.useRef(new cM),[D,E]=x.useState(!1),[I,O]=x.useState(!1),_=x.useRef(!1),M=x.useRef(0),R=x.useRef(new wo),z=x.useRef(!1),$=x.useRef({x:0,y:0}),W=x.useRef({x:0,y:0});x.useEffect(()=>{const F=h.current;if(!F)return;O(!1);const H=new uM;H.background=new Hr(1710628),b.current=H;const V=new dj(45,d/f,.1,100);V.position.set(0,1.2,1.4),V.lookAt(0,.4,0),y.current=V;let G;try{G=new dM({antialias:!0,alpha:!0})}catch{console.warn("[ModelPreview] WebGL context creation failed — too many active contexts"),O(!0);return}G.setSize(d,f),G.setPixelRatio(Math.min(window.devicePixelRatio,2)),G.setClearColor(1710628,1),F.appendChild(G.domElement),m.current=G;const B=new fM(16777215,1);H.add(B);const K=new Ib(16777215,1.5);K.position.set(2,3,2),H.add(K);const se=new Ib(4890367,.6);se.position.set(-2,1,-1),H.add(se);const q=new pM(1,32),be=new Tx({color:2763322,roughness:.8}),Ce=new Il(q,be);Ce.rotation.x=-Math.PI/2,Ce.position.y=0,H.add(Ce);const Z=new hM(.35,.42,32),ie=new Fl({color:NS.idle,side:cj,transparent:!0,opacity:.8}),me=new Il(Z,ie);me.rotation.x=-Math.PI/2,me.position.y=.01,H.add(me),j.current=me,E(!0);const Ee=ne=>{z.current=!0,$.current={x:ne.clientX,y:ne.clientY},F.style.cursor="grabbing"},Te=ne=>{if(!z.current||!w.current)return;const Ne=ne.clientX-$.current.x,ze=ne.clientY-$.current.y;W.current.y+=Ne*.01,W.current.x+=ze*.01,W.current.x=Math.max(-Math.PI/4,Math.min(Math.PI/4,W.current.x)),w.current.rotation.y=W.current.y,w.current.rotation.x=W.current.x,$.current={x:ne.clientX,y:ne.clientY}},Ve=()=>{z.current=!1,F.style.cursor="grab"},We=()=>{z.current=!1,F.style.cursor="grab"};F.addEventListener("mousedown",Ee),window.addEventListener("mousemove",Te),window.addEventListener("mouseup",Ve),F.addEventListener("mouseleave",We),F.style.cursor="grab";const ee=()=>{S.current=requestAnimationFrame(ee);const ne=T.current.getDelta();if(C.current)C.current.update(ne);else if(w.current&&!_.current){M.current+=ne;const Ne=M.current,pe=Math.sin(Ne*1.5)*.02,de=Math.sin(Ne*.8)*.01;w.current.position.set(R.current.x+de,R.current.y+pe,R.current.z)}m.current&&b.current&&y.current&&m.current.render(b.current,y.current)};return ee(),()=>{if(cancelAnimationFrame(S.current),F.removeEventListener("mousedown",Ee),window.removeEventListener("mousemove",Te),window.removeEventListener("mouseup",Ve),F.removeEventListener("mouseleave",We),w.current&&b.current&&(b.current.remove(w.current),w.current.traverse(ne=>{var Ne,ze;ne instanceof Il&&((Ne=ne.geometry)==null||Ne.dispose(),Array.isArray(ne.material)?ne.material.forEach(st=>{st.map&&st.map.dispose(),st.dispose()}):ne.material&&(ne.material.map&&((ze=ne.material.map)==null||ze.dispose()),ne.material.dispose()))}),w.current=null),j.current&&b.current&&(b.current.remove(j.current),j.current.geometry.dispose(),j.current.material.dispose(),j.current=null),b.current&&(b.current.traverse(ne=>{var Ne;ne instanceof Il&&((Ne=ne.geometry)==null||Ne.dispose(),ne.material instanceof Jf&&ne.material.dispose())}),b.current.clear()),C.current=null,k.current=null,N.current.clear(),m.current){try{const Ne=m.current.getContext().getExtension("WEBGL_lose_context");Ne&&Ne.loseContext()}catch{}m.current.dispose(),F.contains(m.current.domElement)&&F.removeChild(m.current.domElement),m.current=null}b.current=null,y.current=null,E(!1)}},[d,f]),x.useEffect(()=>{if(!D||!b.current)return;const F=new PL,H=new x2;H.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.7/"),F.setDRACOLoader(H),F.setMeshoptDecoder(v2);let V=null;const G=B=>{w.current&&b.current&&(b.current.remove(w.current),w.current=null,C.current=null,k.current=null);const K=B.scene;K.scale.setScalar(a);const se=(r==null?void 0:r.x)??0,q=(r==null?void 0:r.y)??0,be=(r==null?void 0:r.z)??0;if(K.position.set(se,be,q),K.visible=!0,W.current={x:0,y:0},K.rotation.set(0,0,0),K.traverse(Ce=>{if(Ce instanceof Il&&(Ce.castShadow=!0,Ce.receiveShadow=!0,Ce.material)){const Z=Ce.material;Z.map&&(Z.map.colorSpace=Br)}}),b.current)if(b.current.add(K),w.current=K,R.current.copy(K.position),B.animations.length>0){_.current=!0;const Ce=new mM(K);C.current=Ce,N.current.clear();for(const Z of B.animations)N.current.set(Z.name.toLowerCase(),Z);if(i!==""){const Z=i?N.current.get(i.toLowerCase())||B.animations[0]:N.current.get("idle")||B.animations[0];if(Z){const ie=Ce.clipAction(Z);ie.reset().play(),k.current=ie}}}else _.current=!1,C.current=null,N.current.clear()};if(n)V=URL.createObjectURL(n),console.log("[ModelPreview] Loading custom model from file:",n.name,"blob URL:",V),F.load(V,B=>{console.log("[ModelPreview] Successfully loaded custom model file, animations:",B.animations.length),G(B)},void 0,B=>{console.error("[ModelPreview] Failed to load custom model file:",B)});else if(s){const B=Gb(s);console.log("[ModelPreview] Loading custom model from URL:",s),F.load(B,K=>{console.log("[ModelPreview] Successfully loaded custom model URL, animations:",K.animations.length),G(K)},void 0,K=>{console.error("[ModelPreview] Failed to load custom model URL:",s,K)})}else{const B=e||(t?_L[t]:void 0)||"character-male-a.glb";F.load(`/assets/characters/${B}`,G,void 0,K=>{console.error("[ModelPreview] Failed to load model:",B,K)})}return()=>{V&&URL.revokeObjectURL(V),H.dispose()}},[t,e,n,s,a,r,D]);const L=F=>{if(!C.current)return;const H=w2[F],V=N.current.get(H);if(!V){const B=N.current.get("idle");if(B){const K=C.current.clipAction(B);K.reset().play(),k.current=K}return}const G=C.current.clipAction(V);F==="working"?G.timeScale=1.5:F==="error"&&(G.setLoop(gM,1),G.clampWhenFinished=!0),k.current&&k.current!==G?(k.current.fadeOut(.3),G.reset().fadeIn(.3).play()):G.reset().play(),k.current=G};return x.useEffect(()=>{if(D){if(j.current){const F=j.current.material;F.color.setHex(NS[c]),c==="working"?F.opacity=.6+Math.sin(Date.now()*.005)*.4:F.opacity=.8}L(c)}},[c,D]),x.useEffect(()=>{if(!D||!C.current||c!=="idle")return;if(i===""){k.current&&(k.current.stop(),k.current=null);return}const F=i?i.toLowerCase():"idle",H=N.current.get(F);if(H){const V=C.current.clipAction(H);k.current&&k.current!==V?(k.current.fadeOut(.3),V.reset().fadeIn(.3).play()):V.reset().play(),k.current=V}else k.current&&(k.current.stop(),k.current=null)},[i,D,c]),I?o.jsx("div",{className:"model-preview",style:{width:d,height:f,borderRadius:8,overflow:"hidden",background:"#1a1a24",display:"flex",alignItems:"center",justifyContent:"center",color:"#666",fontSize:12,textAlign:"center",padding:8},children:"3D preview unavailable"}):o.jsx("div",{ref:h,className:"model-preview",style:{width:d,height:f,borderRadius:8,overflow:"hidden",background:"#1a1a24"}})}function k2({value:t,onChange:e,onSubmit:n,placeholder:s="/path/to/folder",className:a="",directoriesOnly:r=!0,autoFocus:i=!1,hasError:c=!1,disabled:d=!1}){const[f,h]=x.useState([]),[m,b]=x.useState(-1),[y,w]=x.useState(!1),[C,N]=x.useState(!1),k=x.useRef(null),j=x.useRef(null),S=x.useRef(null),T=x.useCallback(async R=>{if(!R){h([]);return}N(!0);try{const z=new URLSearchParams({path:R,dirs:r?"true":"false",limit:"15"}),$=await Bt(Rt(`/api/files/autocomplete?${z}`));if($.ok){const W=await $.json();h(W.suggestions||[]),b(-1)}}catch(z){console.error("Failed to fetch path suggestions:",z)}finally{N(!1)}},[r]);x.useEffect(()=>(S.current&&clearTimeout(S.current),t&&y?S.current=setTimeout(()=>{T(t)},150):h([]),()=>{S.current&&clearTimeout(S.current)}),[t,y,T]);const D=R=>{e(R.target.value),w(!0)},E=x.useCallback(R=>{var $;const z=R.isDirectory?R.path+"/":R.path;e(z),w(R.isDirectory),b(-1),($=k.current)==null||$.focus(),R.isDirectory&&T(z)},[e,T]),I=R=>{if(!y||f.length===0){R.key==="Enter"&&n&&(R.preventDefault(),n()),R.key==="Escape"&&w(!1);return}switch(R.key){case"ArrowDown":R.preventDefault(),b(z=>z<f.length-1?z+1:z);break;case"ArrowUp":R.preventDefault(),b(z=>z>0?z-1:-1);break;case"Tab":if(R.preventDefault(),f.length>0){const z=m>=0?m:0;E(f[z])}break;case"Enter":R.preventDefault(),m>=0&&f[m]?E(f[m]):n&&(w(!1),n());break;case"Escape":R.preventDefault(),w(!1),b(-1);break}},O=()=>{w(!0),t&&T(t)},_=()=>{setTimeout(()=>{w(!1),b(-1)},200)};x.useEffect(()=>{if(m>=0&&j.current){const z=j.current.querySelectorAll(".folder-input-suggestion")[m];z&&z.scrollIntoView({block:"nearest"})}},[m]);const M=["folder-input",a,c?"error":""].filter(Boolean).join(" ");return o.jsxs("div",{className:"folder-input-container",children:[o.jsx("input",{ref:k,type:"text",className:M,value:t,onChange:D,onKeyDown:I,onFocus:O,onBlur:_,placeholder:s,autoFocus:i,disabled:d,autoComplete:"off",spellCheck:!1}),y&&(f.length>0||C)&&o.jsx("div",{ref:j,className:"folder-input-suggestions",children:C&&f.length===0?o.jsx("div",{className:"folder-input-loading",children:"Loading..."}):f.map((R,z)=>o.jsxs("div",{className:`folder-input-suggestion ${z===m?"selected":""}`,onClick:()=>E(R),onMouseEnter:()=>b(z),children:[o.jsx("span",{className:"folder-input-suggestion-icon",children:R.isDirectory?"📁":"📄"}),o.jsx("span",{className:"folder-input-suggestion-name",children:R.name}),R.isDirectory&&o.jsx("span",{className:"folder-input-suggestion-hint",children:"/"})]},R.path))})]})}function x1({agent:t,isOpen:e,onClose:n}){const{t:s}=dt(["terminal","common","tools"]),a=eL(),r=dr(),[i,c]=x.useState(t.name),[d,f]=x.useState(t.class),[h,m]=x.useState(t.permissionMode),[b,y]=x.useState(t.provider||"claude"),[w,C]=x.useState(t.codexConfig||{fullAuto:!0,sandbox:"workspace-write",approvalMode:"on-request",search:!1}),[N,k]=x.useState(t.model||"sonnet"),[j,S]=x.useState(t.effort),[T,D]=x.useState(t.codexModel||"gpt-5.3-codex"),[E,I]=x.useState(t.opencodeModel||"minimax/MiniMax-M1-80k"),[O,_]=x.useState(t.useChrome||!1),[M,R]=x.useState(t.cwd),[z,$]=x.useState(new Set),[W,L]=x.useState(""),[F,H]=x.useState(!1),[V,G]=x.useState("");x.useMemo(()=>a.filter(ee=>ee.enabled&&(ee.assignedAgentIds.includes(t.id)||ee.assignedAgentClasses.includes(t.class))),[a,t.id,t.class]),x.useEffect(()=>{const ee=a.filter(ne=>ne.assignedAgentIds.includes(t.id)).map(ne=>ne.id);$(new Set(ee))},[a,t.id]),x.useEffect(()=>{if(e){c(t.name),f(t.class),m(t.permissionMode),y(t.provider||"claude"),C(t.codexConfig||{fullAuto:!0,sandbox:"workspace-write",approvalMode:"on-request",search:!1}),k(t.model||"sonnet"),S(t.effort),D(t.codexModel||"gpt-5.3-codex"),I(t.opencodeModel||"minimax/MiniMax-M1-80k"),_(t.useChrome||!1),R(t.cwd);const ee=a.filter(ne=>ne.assignedAgentIds.includes(t.id)).map(ne=>ne.id);$(new Set(ee))}},[e,t,a]);const B=x.useMemo(()=>a.filter(ee=>ee.enabled),[a]),K=x.useMemo(()=>{if(!W.trim())return B;const ee=W.toLowerCase();return B.filter(ne=>ne.name.toLowerCase().includes(ee)||ne.description.toLowerCase().includes(ee)||ne.slug.toLowerCase().includes(ee))},[B,W]),se=x.useMemo(()=>B.filter(ee=>ee.assignedAgentClasses.includes(d)),[B,d]),q=x.useCallback(ee=>{$(ne=>{const Ne=new Set(ne);return Ne.has(ee)?Ne.delete(ee):Ne.add(ee),Ne})},[]),be=x.useMemo(()=>{const ee=r.find(ne=>ne.id===d);if(ee!=null&&ee.model)return ee.model},[r,d]),Ce=x.useMemo(()=>{const ee=r.find(ne=>ne.id===d);if(ee!=null&&ee.customModelPath)return Rt(`/api/custom-models/${ee.id}`)},[r,d]),Z=x.useMemo(()=>{const ee=r.find(ne=>ne.id===d);return ee==null?void 0:ee.modelScale},[r,d]),ie=x.useMemo(()=>r.find(ee=>ee.id===d),[r,d]);x.useEffect(()=>{ie&&(G(ie.instructions||""),H(!1))},[ie==null?void 0:ie.id]);const me=x.useMemo(()=>r.find(ne=>ne.id===d)?"scout":d,[r,d]),Ee=x.useMemo(()=>{const ee=i.trim();if(ee&&ee!==t.name||d!==t.class||h!==t.permissionMode||b!==(t.provider||"claude")||b==="claude"&&N!==(t.model||"sonnet")||b==="claude"&&j!==(t.effort||void 0)||b==="codex"&&T!==(t.codexModel||"gpt-5.3-codex")||b==="codex"&&JSON.stringify(w||{})!==JSON.stringify(t.codexConfig||{})||b==="opencode"&&E!==(t.opencodeModel||"minimax/MiniMax-M1-80k")||O!==(t.useChrome||!1)||M!==t.cwd)return!0;const ne=a.filter(ze=>ze.assignedAgentIds.includes(t.id)).map(ze=>ze.id).sort().join(","),Ne=Array.from(z).sort().join(",");return ne!==Ne},[i,d,h,b,N,j,T,w,E,O,M,z,t,a]),Te=()=>{const ee=i.trim(),ne={};ee&&ee!==t.name&&U.renameAgent(t.id,ee),d!==t.class&&(ne.class=d),h!==t.permissionMode&&(ne.permissionMode=h),b!==(t.provider||"claude")&&(ne.provider=b),b==="codex"&&JSON.stringify(w||{})!==JSON.stringify(t.codexConfig||{})&&(ne.codexConfig=w),b==="codex"&&T!==(t.codexModel||"gpt-5.3-codex")&&(ne.codexModel=T),b==="opencode"&&E!==(t.opencodeModel||"minimax/MiniMax-M1-80k")&&(ne.opencodeModel=E),b==="claude"&&N!==(t.model||"sonnet")&&(ne.model=N),b==="claude"&&j!==(t.effort||void 0)&&(ne.effort=j),O!==(t.useChrome||!1)&&(ne.useChrome=O),M!==t.cwd&&(ne.cwd=M);const Ne=a.filter(st=>st.assignedAgentIds.includes(t.id)).map(st=>st.id).sort().join(","),ze=Array.from(z).sort().join(",");Ne!==ze&&(ne.skillIds=Array.from(z)),Object.keys(ne).length>0&&U.updateAgentProperties(t.id,ne),n()},{handleMouseDown:Ve,handleClick:We}=Ta(n);return e?o.jsx("div",{className:"modal-overlay visible",onMouseDown:Ve,onClick:We,children:o.jsxs("div",{className:"modal agent-edit-modal",children:[o.jsxs("div",{className:"modal-header",children:[s("terminal:spawn.editAgentTitle"),": ",i.trim()||t.name]}),o.jsxs("div",{className:"modal-body spawn-modal-body",children:[o.jsxs("div",{className:"spawn-top-section",children:[o.jsx("div",{className:"spawn-preview-compact",children:o.jsx(b1,{agentClass:me,modelFile:be,customModelUrl:Ce,modelScale:Z,width:100,height:120})}),o.jsxs("div",{className:"spawn-class-section",children:[o.jsx("div",{className:"spawn-class-label",children:s("terminal:spawn.agentClass")}),o.jsxs("div",{className:"class-selector-inline",children:[r.map(ee=>o.jsxs("button",{className:`class-chip ${d===ee.id?"selected":""}`,onClick:()=>f(ee.id),title:ee.description,children:[o.jsx("span",{className:"class-chip-icon",children:ee.icon}),o.jsx("span",{className:"class-chip-name",children:ee.name})]},ee.id)),Object.entries(_o).filter(([ee])=>ee!=="boss").map(([ee,ne])=>o.jsxs("button",{className:`class-chip ${d===ee?"selected":""}`,onClick:()=>f(ee),title:ne.description,children:[o.jsx("span",{className:"class-chip-icon",children:ne.icon}),o.jsx("span",{className:"class-chip-name",children:ee.charAt(0).toUpperCase()+ee.slice(1)})]},ee))]})]})]}),ie&&o.jsxs("div",{className:"custom-class-notice",children:[o.jsxs("div",{className:"custom-class-notice-header",onClick:()=>H(!F),style:{cursor:"pointer"},children:[o.jsx("span",{children:"📋"}),o.jsx("span",{children:ie.instructions?s("terminal:spawn.hasCustomInstructions"):"Add custom instructions"}),o.jsx("span",{style:{marginLeft:"auto",fontSize:11,opacity:.6},children:F?"▲":"▼"})]}),!F&&ie.instructions&&o.jsx("div",{className:"custom-class-notice-info",children:s("terminal:spawn.instructionsInjected",{count:ie.instructions.length})}),F&&o.jsxs("div",{className:"custom-class-instructions-editor",children:[o.jsx("textarea",{value:V,onChange:ee=>G(ee.target.value),placeholder:"CLAUDE.md instructions for this agent class...",rows:6,style:{width:"100%",resize:"vertical",fontFamily:"monospace",fontSize:12,background:"rgba(0,0,0,0.3)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:4,color:"var(--text-primary)",padding:"6px 8px",outline:"none"}}),o.jsxs("div",{style:{display:"flex",gap:6,marginTop:4,justifyContent:"flex-end"},children:[o.jsx("button",{onClick:()=>{U.updateCustomAgentClass(ie.id,{instructions:V}),H(!1)},style:{padding:"2px 10px",borderRadius:4,fontSize:11,cursor:"pointer",background:"rgba(0,200,200,0.2)",color:"var(--accent-cyan)",border:"1px solid rgba(0,200,200,0.3)"},children:"Save"}),o.jsx("button",{onClick:()=>{G(ie.instructions||""),H(!1)},style:{padding:"2px 10px",borderRadius:4,fontSize:11,cursor:"pointer",background:"transparent",color:"var(--text-secondary)",border:"1px solid rgba(255,255,255,0.1)"},children:"Cancel"})]}),o.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:4},children:"These instructions are injected as system prompt for all agents of this class."})]})]}),o.jsxs("div",{className:"spawn-form-section",children:[o.jsx("div",{className:"spawn-form-row",children:o.jsxs("div",{className:"spawn-field",children:[o.jsx("label",{className:"spawn-label",children:s("common:labels.name")}),o.jsx("input",{type:"text",className:"spawn-input",value:i,onChange:ee=>c(ee.target.value),placeholder:s("terminal:spawn.agentNamePlaceholder")})]})}),o.jsxs("div",{className:"spawn-form-row",children:[o.jsxs("div",{className:"spawn-field",children:[o.jsx("label",{className:"spawn-label",children:s("common:labels.runtime")}),o.jsxs("div",{className:"spawn-select-row",children:[o.jsxs("button",{className:`spawn-select-btn ${b==="claude"?"selected":""}`,onClick:()=>y("claude"),children:[o.jsx("span",{children:"🧠"}),o.jsx("span",{children:"Claude"})]}),o.jsxs("button",{className:`spawn-select-btn ${b==="codex"?"selected":""}`,onClick:()=>y("codex"),children:[o.jsx("span",{children:"⚙️"}),o.jsx("span",{children:"Codex"})]}),o.jsxs("button",{className:`spawn-select-btn spawn-select-btn--opencode ${b==="opencode"?"selected":""}`,onClick:()=>y("opencode"),children:[o.jsx("span",{children:"🟢"}),o.jsx("span",{children:"OpenCode"})]})]})]}),o.jsxs("div",{className:"spawn-field",children:[o.jsx("label",{className:"spawn-label",children:s("common:labels.permissions")}),o.jsx("div",{className:"spawn-select-row",children:Object.keys(Mu).map(ee=>o.jsxs("button",{className:`spawn-select-btn ${h===ee?"selected":""}`,onClick:()=>m(ee),title:Mu[ee].description,children:[o.jsx("span",{children:ee==="bypass"?"⚡":"🔐"}),o.jsx("span",{children:Mu[ee].label})]},ee))})]})]}),o.jsxs("div",{className:"spawn-form-row",children:[o.jsxs("div",{className:"spawn-field",children:[o.jsx("label",{className:"spawn-label",children:s("common:labels.model")}),b==="claude"?o.jsx("div",{className:"spawn-select-row",children:Object.keys(Rf).map(ee=>o.jsxs("button",{className:`spawn-select-btn ${N===ee?"selected":""}`,onClick:()=>k(ee),title:Rf[ee].description,children:[o.jsx("span",{children:Rf[ee].icon}),o.jsx("span",{children:Rf[ee].label})]},ee))}):b==="codex"?o.jsx("div",{className:"spawn-select-row spawn-select-row--codex-models",children:Object.keys(Df).map(ee=>o.jsxs("button",{className:`spawn-select-btn ${T===ee?"selected":""}`,onClick:()=>D(ee),title:Df[ee].description,children:[o.jsx("span",{children:Df[ee].icon}),o.jsx("span",{children:Df[ee].label})]},ee))}):b==="opencode"?o.jsx("input",{type:"text",className:"spawn-input",value:E,onChange:ee=>I(ee.target.value),placeholder:"provider/model (e.g., minimax/MiniMax-M1-80k)"}):o.jsx("div",{className:"spawn-inline-hint",children:s("terminal:spawn.codex.configuration")})]}),b==="claude"&&o.jsxs("div",{className:"spawn-field",children:[o.jsx("label",{className:"spawn-label",children:"Effort"}),o.jsxs("div",{className:"spawn-select-row spawn-select-row--effort",children:[o.jsx("button",{className:`spawn-select-btn spawn-select-btn--compact ${j===void 0?"selected":""}`,onClick:()=>S(void 0),title:"Use default effort level",children:o.jsx("span",{children:"Default"})}),Object.keys(Hg).map(ee=>o.jsx("button",{className:`spawn-select-btn spawn-select-btn--compact ${j===ee?"selected":""}`,onClick:()=>S(ee),title:Hg[ee].description,children:o.jsx("span",{children:Hg[ee].label})},ee))]})]})]}),b==="codex"&&o.jsx("div",{className:"spawn-form-row",children:o.jsxs("div",{className:"spawn-field",children:[o.jsx("label",{className:"spawn-label",children:s("terminal:spawn.codex.config")}),o.jsxs("div",{className:"spawn-options-row",style:{display:"flex",flexDirection:"column",gap:8},children:[o.jsxs("label",{className:"spawn-checkbox",children:[o.jsx("input",{type:"checkbox",checked:w.fullAuto!==!1,onChange:ee=>C(ne=>({...ne,fullAuto:ee.target.checked}))}),o.jsx("span",{children:s("terminal:spawn.codex.useFullAuto")})]}),o.jsxs("label",{className:"spawn-checkbox",children:[o.jsx("input",{type:"checkbox",checked:!!w.search,onChange:ee=>C(ne=>({...ne,search:ee.target.checked}))}),o.jsx("span",{children:s("terminal:spawn.codex.enableSearch")})]}),w.fullAuto===!1&&o.jsxs(o.Fragment,{children:[o.jsxs("select",{className:"spawn-input",value:w.sandbox||"workspace-write",onChange:ee=>C(ne=>({...ne,sandbox:ee.target.value})),children:[o.jsx("option",{value:"read-only",children:s("terminal:spawn.codex.sandboxReadOnly")}),o.jsx("option",{value:"workspace-write",children:s("terminal:spawn.codex.sandboxWorkspaceWrite")}),o.jsx("option",{value:"danger-full-access",children:s("terminal:spawn.codex.sandboxDangerFullAccess")})]}),o.jsxs("select",{className:"spawn-input",value:w.approvalMode||"on-request",onChange:ee=>C(ne=>({...ne,approvalMode:ee.target.value})),children:[o.jsx("option",{value:"untrusted",children:s("terminal:spawn.codex.approvalsUntrusted")}),o.jsx("option",{value:"on-failure",children:s("terminal:spawn.codex.approvalsOnFailure")}),o.jsx("option",{value:"on-request",children:s("terminal:spawn.codex.approvalsOnRequest")}),o.jsx("option",{value:"never",children:s("terminal:spawn.codex.approvalsNever")})]})]}),o.jsx("input",{type:"text",className:"spawn-input",placeholder:s("terminal:spawn.codex.profileOptional"),value:w.profile||"",onChange:ee=>C(ne=>({...ne,profile:ee.target.value||void 0}))})]})]})}),b==="claude"&&(N!==(t.model||"sonnet")||j!==(t.effort||void 0))&&o.jsx("div",{className:"model-change-notice",children:s("terminal:spawn.contextPreserved")}),o.jsx("div",{className:"spawn-form-row spawn-options-row",children:o.jsxs("label",{className:"spawn-checkbox",children:[o.jsx("input",{type:"checkbox",checked:O,onChange:ee=>_(ee.target.checked),disabled:b!=="claude"}),o.jsx("span",{children:s("terminal:spawn.chromeBrowser")})]})}),o.jsx("div",{className:"spawn-form-row",children:o.jsxs("div",{className:"spawn-field",children:[o.jsx("label",{className:"spawn-label",children:s("terminal:spawn.workingDir")}),o.jsx(k2,{value:M,onChange:R,placeholder:s("terminal:spawn.workingDirPlaceholder"),className:"spawn-input",directoriesOnly:!0})]})}),M!==t.cwd&&o.jsx("div",{className:"model-change-notice warning",children:s("terminal:spawn.newSessionWarning")}),o.jsxs("div",{className:"spawn-skills-section",children:[o.jsxs("label",{className:"spawn-label",children:[s("terminal:spawn.skills")," ",o.jsxs("span",{className:"spawn-label-hint",children:["(",s("terminal:spawn.clickToToggle"),")"]})]}),B.length>6&&o.jsx("input",{type:"text",className:"spawn-input skill-search-input",placeholder:s("terminal:spawn.filterSkills"),value:W,onChange:ee=>L(ee.target.value)}),o.jsx("div",{className:"skills-chips-compact",children:B.length===0?o.jsx("div",{className:"skills-empty",children:s("terminal:spawn.noEnabledSkills")}):K.length===0?o.jsx("div",{className:"skills-empty",children:s("terminal:spawn.noSkillsMatch",{query:W})}):K.map(ee=>{const ne=se.includes(ee),ze=z.has(ee.id)||ne;return o.jsxs("button",{className:`skill-chip ${ze?"selected":""} ${ne?"class-based":""}`,onClick:()=>!ne&&q(ee.id),title:ne?s("terminal:spawn.assignedViaClass"):ee.name,children:[ze&&o.jsx("span",{className:"skill-check",children:"✓"}),o.jsx("span",{className:"skill-chip-name",children:ee.name}),ee.builtin&&o.jsx("span",{className:"skill-chip-badge builtin",children:"TC"}),ne&&o.jsx("span",{className:"skill-chip-badge",children:"class"})]},ee.id)})})]})]})]}),o.jsxs("div",{className:"modal-footer",children:[o.jsx("button",{className:"btn btn-secondary",onClick:n,children:s("common:buttons.cancel")}),o.jsx("button",{className:"btn btn-primary",onClick:Te,disabled:!Ee,children:s("common:buttons2.saveChanges")})]})]})}):null}const S2=Object.freeze(Object.defineProperty({__proto__:null,AgentEditModal:x1},Symbol.toStringTag,{value:"Module"}));var ac=tj();const C2=Xu(ac);function pr({children:t}){return typeof document>"u"?null:ac.createPortal(t,document.body)}function lu(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString()}function TS(t){return`${t.toFixed(1)}%`}function A2(t){return t>=80?"#ff4a4a":t>=60?"#ff9e4a":t>=40?"#ffd700":"#4aff9e"}const j2={systemPrompt:"#4a9eff",systemTools:"#9e4aff",messages:"#4aff9e",freeSpace:"rgba(255,255,255,0.1)",autocompactBuffer:"#ff9e4a"},N2={systemPrompt:"terminal:context.systemPrompt",systemTools:"terminal:context.systemTools",messages:"terminal:context.messagesCategory",freeSpace:"terminal:context.freeSpace",autocompactBuffer:"terminal:context.autocompactBuffer"},T2={systemPrompt:"terminal:context.systemPromptDesc",systemTools:"terminal:context.systemToolsDesc",messages:"terminal:context.messagesDesc",freeSpace:"terminal:context.freeSpaceDesc",autocompactBuffer:"terminal:context.autocompactBufferDesc"};function y1({agent:t,isOpen:e,onClose:n,onRefresh:s}){const{t:a}=dt(["terminal","common"]),r=t.contextStats,[i,c]=x.useState(!1),d=()=>{s&&!i&&(c(!0),s(),setTimeout(()=>c(!1),3e3))},f=["systemPrompt","systemTools","messages","autocompactBuffer","freeSpace"],h=x.useMemo(()=>r?f.map(w=>({key:w,...r.categories[w],label:a(N2[w]),description:a(T2[w]),color:j2[w]})):[],[r]),m=x.useMemo(()=>h.filter(w=>w.key!=="freeSpace"),[h]),{handleMouseDown:b,handleClick:y}=Ta(n);return e?o.jsx(pr,{children:o.jsx("div",{className:"modal-overlay visible",onMouseDown:b,onClick:y,children:o.jsxs("div",{className:"modal context-view-modal",style:{maxWidth:"520px"},children:[o.jsxs("div",{className:"modal-header",style:{display:"flex",alignItems:"center",gap:"12px"},children:[o.jsx("span",{style:{flex:1},children:a("terminal:context.contextWindow",{name:t.name})}),s&&o.jsxs("button",{className:"btn btn-primary",onClick:d,disabled:i||t.status!=="idle",style:{padding:"6px 12px",fontSize:"12px",display:"flex",alignItems:"center",gap:"6px"},title:t.status!=="idle"?a("terminal:context.agentMustBeIdle"):a("terminal:context.fetchContextStats"),children:[o.jsx("span",{style:{display:"inline-block",animation:i?"spin 1s linear infinite":"none"},children:i?"⟳":"↻"}),a(i?"common:status.loading":"common:buttons.refresh")]})]}),o.jsx("div",{className:"modal-body",style:{padding:"16px"},children:r?o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px",padding:"8px 12px",background:"var(--bg-secondary)",borderRadius:"6px"},children:[o.jsxs("div",{children:[o.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:a("terminal:context.model")}),o.jsx("div",{style:{fontSize:"13px",fontWeight:500},children:r.model})]}),o.jsxs("div",{style:{textAlign:"right"},children:[o.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:a("terminal:context.contextWindowLabel")}),o.jsx("div",{style:{fontSize:"13px",fontWeight:500},children:lu(r.contextWindow)})]})]}),o.jsxs("div",{style:{marginBottom:"24px"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"8px",fontSize:"13px"},children:[o.jsx("span",{children:a("terminal:context.contextUsage")}),o.jsxs("span",{style:{color:A2(r.usedPercent)},children:[lu(r.totalTokens)," / ",lu(r.contextWindow)," (",r.usedPercent,"%)"]})]}),o.jsx("div",{style:{height:"28px",background:"var(--bg-tertiary)",borderRadius:"6px",overflow:"hidden",display:"flex"},children:m.map(w=>w.percent>0&&o.jsx("div",{style:{width:`${w.percent}%`,background:w.color,height:"100%",minWidth:w.percent>.5?"2px":"0",transition:"width 0.3s ease"},title:`${w.label}: ${lu(w.tokens)} (${TS(w.percent)})`},w.key))})]}),o.jsxs("div",{style:{marginBottom:"16px"},children:[o.jsx("div",{style:{fontSize:"12px",color:"var(--text-secondary)",marginBottom:"8px",textTransform:"uppercase",letterSpacing:"0.5px"},children:a("terminal:context.tokenBreakdown")}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:h.map(w=>o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 12px",background:w.key==="freeSpace"?"transparent":"var(--bg-secondary)",borderRadius:"6px",borderLeft:w.key==="freeSpace"?"3px dashed rgba(255,255,255,0.2)":`3px solid ${w.color}`,opacity:w.key==="freeSpace"?.7:1},children:[o.jsx("div",{style:{width:"12px",height:"12px",borderRadius:"3px",background:w.color,flexShrink:0,border:w.key==="freeSpace"?"1px dashed rgba(255,255,255,0.3)":"none"}}),o.jsxs("div",{style:{flex:1},children:[o.jsx("div",{style:{fontSize:"13px",fontWeight:500},children:w.label}),o.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:w.description})]}),o.jsxs("div",{style:{textAlign:"right"},children:[o.jsx("div",{style:{fontSize:"13px",fontWeight:500},children:lu(w.tokens)}),o.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:TS(w.percent)})]})]},w.key))})]}),o.jsx("div",{style:{fontSize:"11px",color:"var(--text-muted)",textAlign:"center"},children:a("terminal:context.lastUpdated",{time:new Date(r.lastUpdated).toLocaleTimeString()})})]}):o.jsxs("div",{style:{textAlign:"center",color:"var(--text-secondary)",padding:"32px"},children:[o.jsx("div",{style:{fontSize:"48px",marginBottom:"16px",opacity:.5},children:"📊"}),o.jsx("div",{style:{fontSize:"14px",marginBottom:"8px"},children:a("terminal:context.noContextData")}),o.jsx("div",{style:{fontSize:"12px",marginBottom:"20px",opacity:.7},children:a("terminal:context.clickRefresh")}),s&&o.jsxs("button",{className:"btn btn-primary",onClick:d,disabled:i||t.status!=="idle",style:{padding:"10px 24px",fontSize:"14px",display:"inline-flex",alignItems:"center",gap:"8px"},children:[o.jsx("span",{style:{display:"inline-block",animation:i?"spin 1s linear infinite":"none"},children:i?"⟳":"↻"}),a(i?"terminal:context.fetchingStats":"terminal:context.fetchContextStats")]}),t.status!=="idle"&&o.jsx("div",{style:{fontSize:"11px",color:"var(--text-muted)",marginTop:"12px"},children:a("terminal:context.agentMustBeIdle")})]})}),o.jsx("div",{className:"modal-footer",style:{display:"flex",justifyContent:"flex-end",padding:"12px 16px",borderTop:"1px solid var(--border-color)"},children:o.jsx("button",{className:"btn btn-secondary",onClick:n,children:a("common:buttons.close")})})]})})}):null}const _2=x.memo(function({tokensUsed:e,createdAt:n}){const{t:s}=dt(["common"]);return o.jsxs("div",{className:"unit-stats",children:[o.jsxs("div",{className:"unit-stat",children:[o.jsx("div",{className:"unit-stat-label",children:s("labels.tokens")}),o.jsx("div",{className:"unit-stat-value",children:WD(e)})]}),o.jsxs("div",{className:"unit-stat",children:[o.jsx("div",{className:"unit-stat-label",children:s("labels.uptime")}),o.jsx("div",{className:"unit-stat-value",children:qD(n)})]})]})}),v1=x.memo(function({contextInfo:e,onClick:n}){const{t:s}=dt(["common"]),{remainingPercent:a,hasData:r}=e;return o.jsxs("div",{className:"unit-context unit-context-clickable",onClick:n,title:s(r?"unitPanel.remainingContext":"unitPanel.notRetrievedYet"),style:{cursor:"pointer"},children:[o.jsxs("div",{className:"unit-stat-label",style:{display:"flex",alignItems:"center",gap:"4px"},children:[o.jsx("span",{children:s("unitPanel.remainingContext")}),r?o.jsx("span",{style:{fontSize:"10px",opacity:.6},children:"📊"}):o.jsx("span",{style:{fontSize:"9px",color:"#ff9e4a",opacity:.8},title:s("unitPanel.notRetrievedYet"),children:"⚠️"})]}),r?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"unit-context-bar",children:o.jsx("div",{className:"unit-context-fill",style:{width:`${a}%`,background:h1(a)}})}),o.jsxs("span",{className:"unit-context-value",children:[Math.round(a),"%"]})]}):o.jsx("div",{style:{fontSize:"11px",color:"var(--text-muted)",fontStyle:"italic"},children:s("unitPanel.notRetrievedYet")})]})}),E2=x.memo(function({lastActivity:e}){const{t:n}=dt(["common"]);return o.jsxs("div",{className:"unit-idle-timer",title:n("unitPanel.timeSinceActivity"),style:{color:_x(e)},children:["⏱ ",Mx(e)]})}),M2=x.memo(function({task:e}){const{t:n}=dt(["common"]);return o.jsxs("div",{className:"unit-task",children:[o.jsx("div",{className:"unit-stat-label",children:n("labels.task")}),o.jsx("div",{className:"unit-task-text",children:e})]})}),D2=x.memo(function({cwd:e}){const{t:n}=dt(["common"]);return o.jsxs("div",{className:"unit-cwd",children:[o.jsx("div",{className:"unit-stat-label",children:n("labels.cwd")}),o.jsx("div",{className:"unit-cwd-path",title:e,children:e})]})}),R2=x.memo(function({text:e,maxLength:n=150}){const{t:s}=dt(["common"]);return o.jsxs("div",{className:"unit-last-prompt",children:[o.jsx("div",{className:"unit-stat-label",children:s("unitPanel.lastPrompt")}),o.jsx("div",{className:"unit-last-prompt-text",children:e.length>n?e.slice(0,n)+"...":e})]})}),O2=x.memo(function({text:e,maxLength:n=200}){const{t:s}=dt(["common"]);return o.jsxs("div",{className:"unit-last-message",children:[o.jsx("div",{className:"unit-stat-label",children:s("unitPanel.lastResponse")}),o.jsx("div",{className:"unit-last-message-text",children:e.length>n?e.slice(0,n)+"...":e})]})});function L2({agent:t,onFocusAgent:e,onKillAgent:n,onCallSubordinates:s,onOpenAreaExplorer:a}){var Ee,Te;const{t:r}=dt(["common"]),i=Rs(),c=dr(),{showToast:d}=d1(),f=i.agents.get(t.id)||t,h=fr(f.class,c),m=c.find(Ve=>Ve.id===f.class),b=m==null?void 0:m.model,y=m!=null&&m.customModelPath?Rt(`/api/custom-models/${m.id}`):void 0,w=m==null?void 0:m.modelScale,[C,N]=x.useState(!1),[k,j]=x.useState(f.name),S=x.useRef(null),[,T]=x.useState(0),[D,E]=x.useState(!0),[I,O]=x.useState(!1),[_,M]=x.useState([]),[R,z]=x.useState(null),[$,W]=x.useState(!1),[L,F]=x.useState(!1),H=U.getAgentSupervisorHistory(f.id),V=U.isLoadingHistoryForAgent(f.id);x.useEffect(()=>{!U.hasHistoryBeenFetched(f.id)&&!V&&U.requestAgentSupervisorHistory(f.id)},[f.id,V]),x.useEffect(()=>{j(f.name)},[f.name]),x.useEffect(()=>{C&&S.current&&(S.current.focus(),S.current.select())},[C]),x.useEffect(()=>{if(f.status==="idle"){const Ve=setInterval(()=>{T(We=>We+1)},15e3);return()=>clearInterval(Ve)}},[f.status]),x.useEffect(()=>{f.permissionMode==="interactive"&&Bt(Rt("/api/remembered-patterns")).then(Ve=>Ve.json()).then(M).catch(Ve=>console.error("Failed to fetch remembered patterns:",Ve))},[f.permissionMode]);const G=x.useMemo(()=>Xp(f),[f.contextStats,f.contextUsed,f.contextLimit]),B=U.getAreaForAgent(f.id),K=i.agentOutputs.get(f.id)||[],se=K.length>0?K[K.length-1]:null,q=i.lastPrompts.get(f.id),be=async(Ve,We)=>{try{(await Bt(Rt(`/api/remembered-patterns/${Ve}/${encodeURIComponent(We)}`),{method:"DELETE"})).ok&&M(ne=>ne.filter(Ne=>!(Ne.tool===Ve&&Ne.pattern===We)))}catch(ee){console.error("Failed to remove pattern:",ee)}},Ce=async()=>{if(confirm(r("confirm.clearPatterns")))try{(await Bt(Rt("/api/remembered-patterns"),{method:"DELETE"})).ok&&M([])}catch(Ve){console.error("Failed to clear patterns:",Ve)}},Z=()=>{confirm(r("confirm.terminateAgent"))&&n(f.id)},ie=()=>{const Ve=k.trim();Ve&&Ve!==f.name?U.renameAgent(f.id,Ve):j(f.name),N(!1)},me=Ve=>{Ve.key==="Enter"?ie():Ve.key==="Escape"&&(j(f.name),N(!1))};return o.jsxs("div",{className:"unit-panel",children:[o.jsx("div",{className:"unit-model-preview",children:o.jsx(b1,{agentClass:f.class,modelFile:b,customModelUrl:y,modelScale:w,status:f.status,width:80,height:80})}),o.jsxs("div",{className:"unit-panel-header",children:[o.jsx("div",{className:"unit-class-icon",style:{background:`${h.color}20`},children:h.icon}),o.jsxs("div",{className:"unit-header-info",children:[C?o.jsx("input",{ref:S,type:"text",className:"unit-name-input",value:k,onChange:Ve=>j(Ve.target.value),onBlur:ie,onKeyDown:me}):o.jsx("div",{className:"unit-name unit-name-editable",onClick:()=>N(!0),title:r("unitPanel.clickToRename"),children:f.name}),o.jsxs("div",{className:"unit-status",children:[o.jsx("span",{style:{color:gp[f.status]||gp.default},children:f.status}),o.jsxs("span",{children:[" • ",f.class," • ",f.provider]})]}),f.status==="idle"&&f.lastActivity>0&&o.jsx(E2,{lastActivity:f.lastActivity})]}),o.jsxs("div",{className:"unit-header-actions",children:[o.jsx("button",{className:"unit-action-icon",onClick:()=>e(f.id),title:r("unitPanel.focusOnAgent"),children:"🎯"}),o.jsx("button",{className:"unit-action-icon",onClick:()=>W(!0),title:r("unitPanel.editProperties"),children:"✏️"}),(f.isBoss||f.class==="boss")&&f.subordinateIds&&f.subordinateIds.length>0&&o.jsx("button",{className:"unit-action-icon",onClick:()=>s==null?void 0:s(f.id),title:r("unitPanel.callSubordinates"),children:"📢"}),o.jsx("button",{className:"unit-action-icon",onClick:()=>z("collapse"),title:r("unitPanel.collapseContext"),disabled:f.status!=="idle",children:"📦"}),o.jsx("button",{className:"unit-action-icon warning",onClick:()=>z("clear"),title:r("unitPanel.clearContext"),children:"🧹"}),o.jsx("button",{className:"unit-action-icon danger",onClick:Z,title:r("unitPanel.killAgent"),children:"☠️"})]})]}),B&&o.jsxs("div",{className:"unit-area",children:[o.jsx("span",{className:"unit-area-dot",style:{background:B.color}}),o.jsx("span",{className:"unit-area-name",children:B.name})]}),q&&o.jsx(R2,{text:q.text}),se&&o.jsx(O2,{text:se.text}),o.jsx(_2,{tokensUsed:f.tokensUsed,createdAt:f.createdAt}),o.jsx(v1,{contextInfo:G,onClick:()=>F(!0)}),f.taskLabel&&o.jsxs("div",{className:"unit-task-label",children:[o.jsx("div",{className:"unit-stat-label",children:"📋 Task"}),o.jsx("div",{className:"unit-task-label-value",children:f.taskLabel})]}),f.currentTask&&o.jsx(M2,{task:f.currentTask}),o.jsx(D2,{cwd:f.cwd}),o.jsx(I2,{currentAgentId:f.id}),o.jsxs("div",{className:"unit-permission-mode",children:[o.jsx("div",{className:"unit-stat-label",children:r("unitPanel.permissions")}),o.jsxs("div",{className:"unit-permission-mode-value",title:(Ee=Mu[f.permissionMode])==null?void 0:Ee.description,children:[o.jsx("span",{className:"unit-permission-mode-icon",children:f.permissionMode==="bypass"?"⚡":"🔐"}),o.jsx("span",{className:"unit-permission-mode-label",children:((Te=Mu[f.permissionMode])==null?void 0:Te.label)||f.permissionMode})]})]}),f.permissionMode==="interactive"&&o.jsx(P2,{patterns:_,showPatterns:I,onToggle:()=>O(!I),onRemovePattern:be,onClearAll:Ce}),f.sessionId?o.jsxs("div",{className:"unit-resume-cmd",children:[o.jsx("div",{className:"unit-stat-label",children:r("unitPanel.resumeSession")}),o.jsxs("div",{className:"unit-resume-cmd-text",title:r("unitPanel.clickToCopy"),onClick:async()=>{const Ve=f.provider==="codex"?`codex resume ${f.sessionId}`:f.provider==="opencode"?`opencode resume ${f.sessionId}`:`claude --resume ${f.sessionId}`;try{await navigator.clipboard.writeText(Ve),d("success",r("toast.copied"),r("toast.resumeCommandCopied"),2e3)}catch{d("error",r("toast.errorTitle"),r("toast.failedToCopy"),3e3)}},children:[f.provider==="codex"?"codex resume":f.provider==="opencode"?"opencode resume":"claude --resume"," ",f.sessionId]})]}):o.jsxs("div",{className:"unit-resume-cmd",children:[o.jsx("div",{className:"unit-stat-label",children:r("unitPanel.session")}),o.jsx("div",{className:"unit-new-session-indicator",children:r("unitPanel.newSession")})]}),o.jsxs("div",{className:"unit-supervisor-history",children:[o.jsxs("div",{className:"unit-supervisor-history-header",onClick:()=>E(!D),children:[o.jsx("div",{className:"unit-stat-label",children:r("unitPanel.supervisorHistory")}),o.jsxs("span",{className:"unit-supervisor-history-toggle",children:[H.length>0&&o.jsx("span",{className:"unit-supervisor-history-count",children:H.length}),D?"▼":"▶"]})]}),D&&o.jsx("div",{className:"unit-supervisor-history-list",children:V?o.jsx("div",{className:"unit-supervisor-history-loading",children:r("status.loading")}):H.length===0?o.jsx("div",{className:"unit-supervisor-history-empty",children:r("unitPanel.noSupervisorReports")}):H.slice(0,10).map((Ve,We)=>o.jsx(w1,{entry:Ve,defaultExpanded:We===0},Ve.id))})]}),(f.isBoss||f.class==="boss")&&o.jsx(F2,{agent:f}),f.bossId&&o.jsx($2,{agentId:f.id,bossId:f.bossId}),f.class!=="boss"&&!f.isBoss&&!f.bossId&&o.jsx(U2,{agentId:f.id}),R&&o.jsx(B2,{action:R,agentName:f.name,onClose:()=>z(null),onConfirm:()=>{R==="collapse"?U.collapseContext(f.id):U.clearContext(f.id),z(null)}}),o.jsx(x1,{agent:f,isOpen:$,onClose:()=>W(!1)}),o.jsx(y1,{agent:f,isOpen:L,onClose:()=>F(!1),onRefresh:()=>{U.refreshAgentContext(f.id)}})]})}const I2=x.memo(function({currentAgentId:e}){const{t:n}=dt(["common"]),s=Rs(),a=dr(),[r,i]=x.useState(!1),c=x.useMemo(()=>[...Array.from(s.agents.values()).filter(f=>f.id!==e)].sort((f,h)=>(h.lastActivity||0)-(f.lastActivity||0)),[s.agents,e]);return c.length===0?null:o.jsxs("div",{className:"unit-other-agents",children:[o.jsxs("div",{className:"unit-other-agents-header",onClick:()=>i(!r),children:[o.jsxs("div",{className:"unit-stat-label",children:[n("unitPanel.otherAgents")," (",c.length,")"]}),o.jsx("span",{className:"unit-other-agents-toggle",children:r?"▶":"▼"})]}),!r&&o.jsx("div",{className:"unit-other-agents-list",children:c.map(d=>{const f=fr(d.class,a);return o.jsxs("div",{className:`unit-other-agent-item ${d.status}`,onClick:()=>{U.selectAgent(d.id),U.setTerminalOpen(!0)},children:[o.jsx("span",{className:"unit-other-agent-icon",style:{background:`${f.color}20`},children:f.icon}),o.jsxs("div",{className:"unit-other-agent-info",children:[o.jsx("span",{className:"unit-other-agent-name",children:d.name}),d.taskLabel&&o.jsx("span",{className:"unit-other-agent-task",children:d.taskLabel})]}),o.jsx("div",{className:`agent-status-dot ${d.status}`})]},d.id)})})]})}),P2=x.memo(function({patterns:e,showPatterns:n,onToggle:s,onRemovePattern:a,onClearAll:r}){const{t:i}=dt(["common"]);return o.jsxs("div",{className:"unit-remembered-patterns",children:[o.jsxs("div",{className:"unit-remembered-patterns-header",onClick:s,children:[o.jsx("div",{className:"unit-stat-label",children:i("unitPanel.allowedPatterns")}),o.jsxs("span",{className:"unit-remembered-patterns-toggle",children:[e.length>0&&o.jsx("span",{className:"unit-remembered-patterns-count",children:e.length}),n?"▼":"▶"]})]}),n&&o.jsx("div",{className:"unit-remembered-patterns-list",children:e.length===0?o.jsx("div",{className:"unit-remembered-patterns-empty",children:i("unitPanel.noPatterns")}):o.jsxs(o.Fragment,{children:[e.map((c,d)=>o.jsxs("div",{className:"unit-remembered-pattern-item",children:[o.jsx("span",{className:"unit-pattern-tool",children:c.tool}),o.jsx("span",{className:"unit-pattern-desc",title:c.pattern,children:c.description}),o.jsx("button",{className:"unit-pattern-remove",onClick:()=>a(c.tool,c.pattern),title:i("unitPanel.removePattern"),children:"×"})]},d)),o.jsx("button",{className:"unit-patterns-clear-all",onClick:r,children:i("buttons.clearAll")})]})})]})}),B2=x.memo(function({action:e,agentName:n,onClose:s,onConfirm:a}){const{t:r}=dt(["common"]),{handleMouseDown:i,handleClick:c}=Ta(s);return o.jsx("div",{className:"modal-overlay visible",onMouseDown:i,onClick:c,children:o.jsxs("div",{className:"modal confirm-modal",children:[o.jsx("div",{className:"modal-header",children:r(e==="collapse"?"unitPanel.collapseContextTitle":"unitPanel.clearContextTitle")}),o.jsx("div",{className:"modal-body confirm-modal-body",children:e==="collapse"?o.jsxs(o.Fragment,{children:[o.jsx("p",{dangerouslySetInnerHTML:{__html:r("unitPanel.collapseContextMsg",{name:n})}}),o.jsx("p",{className:"confirm-modal-note",children:r("unitPanel.collapseContextNote")})]}):o.jsxs(o.Fragment,{children:[o.jsx("p",{dangerouslySetInnerHTML:{__html:r("unitPanel.clearContextMsg",{name:n})}}),o.jsx("p",{className:"confirm-modal-note",children:r("unitPanel.clearContextNote")})]})}),o.jsxs("div",{className:"modal-footer",children:[o.jsx("button",{className:"btn btn-secondary",onClick:s,children:r("buttons.cancel")}),o.jsx("button",{className:`btn ${e==="clear"?"btn-danger":"btn-primary"}`,onClick:a,autoFocus:!0,children:r(e==="collapse"?"unitPanel.collapseBtn":"unitPanel.clearContextBtn")})]})]})})}),w1=x.memo(function({entry:e,defaultExpanded:n=!1,agent:s,onAgentClick:a}){var k;const{t:r}=dt(["common"]),[i,c]=x.useState(n),d=Rs(),f=dr(),{analysis:h}=e,m=d.settings.hideCost,b=Tu(h.statusDescription,m),y=Tu(h.recentWorkSummary,m),w=(k=h.concerns)==null?void 0:k.map(j=>Tu(j,m)).filter(j=>j.length>0),C=s?fr(s.class,f):null,N=j=>{s&&a&&(j.stopPropagation(),a(s.id))};return o.jsxs("div",{className:"supervisor-history-item",children:[o.jsxs("div",{className:"supervisor-history-item-header",onClick:()=>c(!i),children:[o.jsx("span",{className:"supervisor-history-progress-dot",style:{background:$D[h.progress]||"#888"},title:h.progress}),o.jsxs("div",{className:"supervisor-history-item-content",children:[s&&C&&o.jsxs("div",{className:"supervisor-history-agent-line",onClick:N,children:[o.jsx("span",{className:"supervisor-history-agent-icon",children:C.icon}),o.jsx("span",{className:"supervisor-history-agent-name",children:s.name}),o.jsx("span",{className:"supervisor-history-time",children:wp(e.timestamp)})]}),o.jsx("div",{className:"supervisor-history-status",children:b})]}),!s&&o.jsx("span",{className:"supervisor-history-time",children:wp(e.timestamp)})]}),i&&o.jsxs("div",{className:"supervisor-history-item-details",children:[o.jsxs("div",{className:"supervisor-history-summary",children:[o.jsxs("strong",{children:[r("labels.summary"),":"]})," ",y]}),w&&w.length>0&&o.jsxs("div",{className:"supervisor-history-concerns",children:[o.jsxs("strong",{children:[r("labels.concerns"),":"]}),o.jsx("ul",{children:w.map((j,S)=>o.jsx("li",{children:j},S))})]})]})]})}),F2=x.memo(function({agent:e}){const{t:n}=dt(["common"]),s=Rs(),a=dr(),[r,i]=x.useState(!0),[c,d]=x.useState(!0),f=x.useMemo(()=>{const w=s.agents.get(e.id);return!w||!w.isBoss&&w.class!=="boss"||!w.subordinateIds?[]:w.subordinateIds.map(C=>s.agents.get(C)).filter(C=>C!==void 0)},[s.agents,e.id]),h=U.getDelegationHistory(e.id),m=s.pendingDelegation,b=(m==null?void 0:m.bossId)===e.id;x.useEffect(()=>{U.requestDelegationHistory(e.id)},[e.id]);const y=Qp.boss;return o.jsxs("div",{className:"boss-section",children:[o.jsxs("div",{className:"boss-header",children:[o.jsx("span",{className:"boss-crown-icon",style:{color:y.color},children:y.icon}),o.jsx("span",{className:"boss-title",children:n("unitPanel.bossAgent")})]}),o.jsxs("div",{className:"boss-subordinates",children:[o.jsxs("div",{className:"boss-subordinates-header",onClick:()=>i(!r),children:[o.jsxs("div",{className:"unit-stat-label",children:[n("labels.team")," (",f.length,")"]}),o.jsx("span",{className:"boss-toggle",children:r?"▼":"▶"})]}),r&&o.jsx("div",{className:"boss-subordinates-list",children:f.length===0?o.jsx("div",{className:"boss-subordinates-empty",children:n("unitPanel.noSubordinates")}):f.map(w=>{const C=fr(w.class,a),N=Xp(w),k=Math.max(0,Math.min(100,Math.round(N.usedPercent))),j=Math.round((1-k/100)*120),S={width:`${k}%`,"--boss-context-hue":`${j}`};return o.jsxs("div",{className:"boss-subordinate-item",onClick:()=>{U.selectAgent(w.id),U.setTerminalOpen(!0)},children:[o.jsx("span",{className:"boss-subordinate-icon",style:{color:C.color},children:C.icon}),o.jsxs("div",{className:"boss-subordinate-meta",children:[o.jsx("span",{className:"boss-subordinate-name",children:w.name}),o.jsxs("div",{className:"boss-subordinate-context",title:`${k}% context used`,children:[o.jsx("div",{className:"boss-subordinate-context-track",children:o.jsx("div",{className:"boss-subordinate-context-fill",style:S})}),o.jsxs("span",{className:"boss-subordinate-context-value",children:[k,"%"]})]})]}),o.jsx("span",{className:`boss-subordinate-status status-${w.status}`,children:w.status}),o.jsx("button",{className:"boss-subordinate-unlink",onClick:T=>{T.stopPropagation(),U.removeSubordinate(e.id,w.id)},title:n("unitPanel.unlinkSubordinate"),children:"✕"})]},w.id)})})]}),o.jsxs("div",{className:"boss-delegation-history",children:[o.jsxs("div",{className:"boss-delegation-history-header",onClick:()=>d(!c),children:[o.jsxs("div",{className:"unit-stat-label",children:[n("unitPanel.delegationHistory")," (",h.length,")"]}),o.jsx("span",{className:"boss-toggle",children:c?"▼":"▶"})]}),c&&o.jsxs("div",{className:"boss-delegation-history-list",children:[b&&o.jsxs("div",{className:"boss-delegation-pending",children:[o.jsx("span",{className:"delegation-spinner",children:"⏳"}),n("unitPanel.analyzingRequest")]}),h.length===0&&!b?o.jsx("div",{className:"boss-delegation-empty",children:n("unitPanel.noDelegationHistory")}):h.slice(0,10).map(w=>o.jsx(z2,{decision:w},w.id))]})]})]})}),z2=x.memo(function({decision:e}){const{t:n}=dt(["common"]),[s,a]=x.useState(!1),i=Rs().agents.get(e.selectedAgentId),c=i?Qp[i.class]:null,d={high:"#4aff9e",medium:"#ff9e4a",low:"#ff4a4a"};return o.jsxs("div",{className:"delegation-decision-item",children:[o.jsxs("div",{className:"delegation-decision-header",onClick:()=>a(!s),children:[o.jsx("span",{className:"delegation-decision-arrow",children:s?"▼":"▶"}),c&&o.jsx("span",{className:"delegation-decision-icon",style:{color:c.color},children:c.icon}),o.jsxs("span",{className:"delegation-decision-agent",children:["→ ",e.selectedAgentName]}),o.jsx("span",{className:"delegation-decision-confidence",style:{color:d[e.confidence]},title:n("unitPanel.confidence",{level:e.confidence}),children:e.confidence==="high"?"●●●":e.confidence==="medium"?"●●○":"●○○"}),o.jsx("span",{className:"delegation-decision-time",children:wp(e.timestamp)})]}),s&&o.jsxs("div",{className:"delegation-decision-details",children:[o.jsxs("div",{className:"delegation-decision-command",children:[o.jsxs("strong",{children:[n("labels.command"),":"]}),o.jsx("div",{className:"delegation-command-text",children:e.userCommand.length>200?e.userCommand.slice(0,200)+"...":e.userCommand})]}),o.jsxs("div",{className:"delegation-decision-reasoning",children:[o.jsxs("strong",{children:[n("labels.reasoning"),":"]})," ",e.reasoning]}),e.alternativeAgents.length>0&&o.jsxs("div",{className:"delegation-decision-alternatives",children:[o.jsxs("strong",{children:[n("labels.alternatives"),":"]})," ",e.alternativeAgents.join(", ")]})]})]})}),$2=x.memo(function({agentId:e,bossId:n}){const{t:s}=dt(["common"]),r=Rs().agents.get(n);if(!r)return null;const i=Qp.boss,c=d=>{d.stopPropagation(),U.removeSubordinate(n,e)};return o.jsxs("div",{className:"subordinate-badge",children:[o.jsx("span",{className:"subordinate-badge-icon",style:{color:i.color},children:i.icon}),o.jsxs("span",{className:"subordinate-badge-text",children:[s("labels.reportsTo"),": ",o.jsx("strong",{children:r.name})]}),o.jsx("button",{className:"subordinate-badge-goto",onClick:()=>U.selectAgent(n),title:s("unitPanel.goToBoss"),children:"→"}),o.jsx("button",{className:"subordinate-badge-unlink",onClick:c,title:s("unitPanel.unlinkFromBoss"),children:"✕"})]})}),U2=x.memo(function({agentId:e}){const{t:n}=dt(["common"]),s=Rs(),[a,r]=x.useState(!1),i=Array.from(s.agents.values()).filter(f=>f.isBoss===!0||f.class==="boss");if(i.length===0)return null;const c=Qp.boss,d=f=>{const h=s.agents.get(f);if(!h)return;const m=h.subordinateIds||[];U.assignSubordinates(f,[...m,e]),r(!1)};return o.jsx("div",{className:"link-to-boss-section",children:a?o.jsxs("div",{className:"link-to-boss-dropdown",children:[o.jsxs("div",{className:"link-to-boss-header",children:[o.jsx("span",{children:n("unitPanel.selectBoss")}),o.jsx("button",{className:"link-to-boss-close",onClick:()=>r(!1),children:"✕"})]}),o.jsx("div",{className:"link-to-boss-list",children:i.map(f=>{var h;return o.jsxs("div",{className:"link-to-boss-item",onClick:()=>d(f.id),children:[o.jsx("span",{className:"link-to-boss-item-icon",style:{color:c.color},children:c.icon}),o.jsx("span",{className:"link-to-boss-item-name",children:f.name}),o.jsx("span",{className:"link-to-boss-item-count",children:n("unitPanel.agentsCount",{count:((h=f.subordinateIds)==null?void 0:h.length)||0})})]},f.id)})})]}):o.jsxs("button",{className:"link-to-boss-btn",onClick:()=>r(!0),children:[o.jsx("span",{className:"link-to-boss-icon",style:{color:c.color},children:c.icon}),o.jsx("span",{children:n("unitPanel.linkToBoss")})]})})});function _S({onOpenAreaExplorer:t}){const{t:e}=dt(["common"]),n=Rs(),s=Array.from(n.agents.values()),a=Array.from(n.areas.values()),[r,i]=x.useState(""),[c,d]=x.useState(()=>{const I=Fa(pt.COMMANDER_FILTERS,"all");return I==="working"?"active":I||"all"}),f=x.useRef(null),h=x.useMemo(()=>s.map(I=>I.id).sort().join(","),[s]),m=x.useRef(new Set);x.useEffect(()=>{for(const I of s){if(m.current.has(I.id))continue;U.getAgentSupervisorHistory(I.id).length===0&&!U.isLoadingHistoryForAgent(I.id)&&(m.current.add(I.id),U.requestAgentSupervisorHistory(I.id))}},[h]);const b=n.agentsWithUnseenOutput,y=x.useMemo(()=>{const I={all:0,active:0,idle:0,error:0,waiting:0};for(const O of s)I.all++,(O.status==="working"||b.has(O.id))&&I.active++,O.status==="idle"&&!b.has(O.id)&&I.idle++,(O.status==="error"||O.status==="orphaned"||O.status==="offline")&&I.error++,(O.status==="waiting"||O.status==="waiting_permission")&&I.waiting++;return I},[s,b]),w=x.useMemo(()=>{const I=r.toLowerCase().trim();return s.filter(O=>{var _,M;if(c!=="all"&&(c==="active"&&O.status!=="working"&&!b.has(O.id)||c==="idle"&&(O.status!=="idle"||b.has(O.id))||c==="error"&&O.status!=="error"&&O.status!=="orphaned"&&O.status!=="offline"||c==="waiting"&&O.status!=="waiting"&&O.status!=="waiting_permission"))return!1;if(I){const R=O.name.toLowerCase().includes(I),z=((_=O.taskLabel)==null?void 0:_.toLowerCase().includes(I))||!1,$=O.class.toLowerCase().includes(I),W=((M=O.currentTool)==null?void 0:M.toLowerCase().includes(I))||!1;return R||z||$||W}return!0})},[s,r,c,b]),C=x.useMemo(()=>OL(w),[w]),N=LL(C,I=>U.getAreaForAgent(I));if(!r&&c==="all")for(const I of a)N.has(I.id)||N.set(I.id,[]);const k=IL(Array.from(N.keys()),I=>n.areas.get(I)),j=x.useCallback(I=>{d(I),Wr(pt.COMMANDER_FILTERS,I)},[]),S=x.useCallback(()=>{var I;i(""),(I=f.current)==null||I.focus()},[]);if(s.length===0&&a.length===0)return o.jsxs("div",{className:"empty-state",children:[o.jsx("div",{className:"empty-state-icon",children:"⚔️"}),o.jsx("div",{className:"empty-state-title",children:e("agentsList.noAgentsDeployed")}),o.jsx("div",{className:"empty-state-desc",children:e("agentsList.clickNewAgent")})]});const T=r||c!=="all",D=w.length,E=s.length;return o.jsxs("div",{className:"agents-list",children:[o.jsxs("div",{className:"agents-stats-bar",children:[o.jsxs("div",{className:"agents-stats-item",children:[o.jsx("span",{className:"agents-stats-count",children:E}),o.jsx("span",{className:"agents-stats-label",children:e("agentsList.total")})]}),y.active>0&&o.jsxs("div",{className:"agents-stats-item working",children:[o.jsx("span",{className:"agents-stats-count",children:y.active}),o.jsx("span",{className:"agents-stats-label",children:e("agentsList.statusActive")})]}),y.idle>0&&o.jsxs("div",{className:"agents-stats-item idle",children:[o.jsx("span",{className:"agents-stats-count",children:y.idle}),o.jsx("span",{className:"agents-stats-label",children:e("agentsList.statusIdle")})]}),y.waiting>0&&o.jsxs("div",{className:"agents-stats-item waiting",children:[o.jsx("span",{className:"agents-stats-count",children:y.waiting}),o.jsx("span",{className:"agents-stats-label",children:e("agentsList.statusWaiting")})]}),y.error>0&&o.jsxs("div",{className:"agents-stats-item error",children:[o.jsx("span",{className:"agents-stats-count",children:y.error}),o.jsx("span",{className:"agents-stats-label",children:e("agentsList.statusError")})]})]}),o.jsxs("div",{className:"agents-search-bar",children:[o.jsx("span",{className:"agents-search-icon",children:"🔍"}),o.jsx("input",{ref:f,type:"text",className:"agents-search-input",placeholder:e("agentsList.searchPlaceholder"),value:r,onChange:I=>i(I.target.value)}),r&&o.jsx("button",{className:"agents-search-clear",onClick:S,children:"×"})]}),o.jsx("div",{className:"agents-filter-chips",children:["all","active","idle","waiting","error"].map(I=>{const O=y[I];return I!=="all"&&O===0?null:o.jsxs("button",{className:`agents-filter-chip ${I} ${c===I?"selected":""}`,onClick:()=>j(I),children:[e(`agentsList.filter_${I}`),o.jsx("span",{className:"agents-filter-chip-count",children:O})]},I)})}),T&&o.jsxs("div",{className:"agents-filter-info",children:[e("agentsList.showing",{count:D,total:E}),o.jsx("button",{className:"agents-filter-clear",onClick:()=>{i(""),j("all")},children:e("agentsList.clearFilters")})]}),o.jsxs("div",{className:"agents-list-scroll",children:[k.map(I=>{const O=N.get(I),_=I?n.areas.get(I):null;return T&&O.length===0?null:o.jsxs("div",{className:"agents-group",children:[o.jsxs("div",{className:"agents-group-header",style:_?{borderLeftColor:_.color,background:`${_.color}15`}:void 0,children:[_?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"agents-group-dot",style:{background:_.color}}),o.jsx("span",{className:"agents-group-name",children:_.name}),_.directories.length>0&&o.jsx("button",{className:"area-browse-btn",onClick:()=>t==null?void 0:t(_.id),title:e("agentsList.browseFiles"),children:"📂"})]}):o.jsx("span",{className:"agents-group-name unassigned",children:e("agentsList.unassigned")}),o.jsx("span",{className:"agents-group-count",children:O.length})]}),O.length>0&&o.jsx("div",{className:"agents-group-items",style:_?{background:`${_.color}08`}:void 0,children:O.map(M=>o.jsx(H2,{agent:M,area:_,searchQuery:r},M.id))})]},I||"unassigned")}),T&&D===0&&o.jsxs("div",{className:"agents-no-results",children:[o.jsx("span",{className:"agents-no-results-icon",children:"🔎"}),o.jsx("span",{children:e("agentsList.noResults")})]}),s.length>0&&o.jsx(W2,{agents:s})]})]})}const H2=x.memo(function({agent:e,area:n,searchQuery:s=""}){const a=Rs(),r=dr(),i=fr(e.class,r),c=a.selectedAgentIds.has(e.id),d=a.agentsWithUnseenOutput.has(e.id),[,f]=x.useState(0);x.useEffect(()=>{if(e.status==="idle"){const j=setInterval(()=>{f(S=>S+1)},15e3);return()=>clearInterval(j)}},[e.status]);const h=()=>{U.selectAgent(e.id)},m=e.status==="idle"&&e.lastActivity>0,b=e.lastActivity>0?_x(e.lastActivity):void 0,y=Xp(e),w=h1(y.remainingPercent),C=e.provider==="codex"?"CX":e.provider==="opencode"?"OC":"CL",N=e.provider==="codex"?"OpenAI Codex":e.provider==="opencode"?"OpenCode":"Claude",k=j=>{if(!s.trim())return j;const S=s.trim(),T=j.toLowerCase().indexOf(S.toLowerCase());return T===-1?j:o.jsxs(o.Fragment,{children:[j.slice(0,T),o.jsx("span",{className:"agents-search-highlight",children:j.slice(T,T+S.length)}),j.slice(T+S.length)]})};return o.jsxs("div",{className:`agent-item ${c?"selected":""} ${d?"unread":""} ${e.status}`,onClick:h,children:[o.jsxs("div",{className:"agent-item-icon",style:{background:`${i.color}20`},children:[i.icon,d&&o.jsx("span",{className:"agent-item-unread-dot"})]}),o.jsxs("div",{className:"agent-item-info",children:[o.jsxs("div",{className:"agent-item-top-row",children:[o.jsx("span",{className:"agent-item-name",children:k(e.name)}),o.jsx("span",{className:`agent-item-provider ${e.provider}`,title:N,children:C})]}),e.taskLabel&&o.jsx("div",{className:"agent-item-task",children:k(e.taskLabel)}),o.jsxs("div",{className:"agent-item-status",children:[o.jsx("span",{className:`agent-item-status-badge ${e.status}`,children:e.status}),m&&o.jsxs("span",{className:"agent-item-idle",style:{color:b},title:Mx(e.lastActivity),children:["⏱ ",RL(e.lastActivity)]}),e.isBoss&&o.jsx("span",{className:"agent-item-boss-badge",title:"Boss agent",children:"B"})]}),o.jsx("div",{className:"agent-item-context-bar",title:`Context: ${Math.round(y.usedPercent)}% used`,children:o.jsx("div",{className:"agent-item-context-fill",style:{width:`${y.usedPercent}%`,background:w}})})]}),o.jsx("div",{className:`agent-status-dot ${e.status}`})]})}),W2=x.memo(function({agents:e}){const{t:n}=dt(["common"]),s=Rs(),[a,r]=x.useState(()=>Ni(pt.GLOBAL_SUPERVISOR_COLLAPSED)),i=()=>{const h=!a;r(h),Ti(pt.GLOBAL_SUPERVISOR_COLLAPSED,h)},c=x.useMemo(()=>{const h=[];for(const m of e){const b=U.getAgentSupervisorHistory(m.id);for(const y of b)h.push({agent:m,entry:y})}return h.sort((m,b)=>b.entry.timestamp-m.entry.timestamp),h.slice(0,30)},[e,s.supervisor.agentHistories]),d=x.useCallback(h=>{U.selectAgent(h)},[]),f=c.length>0?c[0].entry.timestamp:Date.now();return o.jsxs("div",{className:"global-supervisor-status",children:[o.jsxs("div",{className:"global-supervisor-header",onClick:i,children:[o.jsx("span",{className:"global-supervisor-toggle",children:a?"▶":"▼"}),o.jsx("span",{className:"global-supervisor-title",children:n("agentsList.supervisorStatus")}),c.length>0&&o.jsx("span",{className:"global-supervisor-count",children:c.length}),c.length>0&&o.jsx("span",{className:"global-supervisor-time",children:wp(f)})]}),!a&&o.jsx("div",{className:"global-supervisor-list global-supervisor-timeline",children:c.length===0?o.jsx("div",{className:"global-supervisor-empty",children:n("unitPanel.noSupervisorReports")}):c.map(({agent:h,entry:m})=>o.jsx(w1,{entry:m,agent:h,onAgentClick:d,defaultExpanded:!1},m.id))})]})}),q2=x.memo(function({agents:e}){const{t:n}=dt(["common"]),s=dr(),a=e.reduce((i,c)=>i+c.tokensUsed,0),r=e.filter(i=>i.status==="working").length;return o.jsxs("div",{className:"unit-panel",children:[o.jsxs("div",{className:"unit-panel-header",children:[o.jsx("div",{className:"unit-class-icon",style:{background:"#4a9eff20"},children:"👥"}),o.jsxs("div",{children:[o.jsx("div",{className:"unit-name",children:n("multiAgent.agentsSelected",{count:e.length})}),o.jsx("div",{className:"unit-status",children:n("multiAgent.groupSelection")})]})]}),o.jsxs("div",{className:"unit-stats",children:[o.jsxs("div",{className:"unit-stat",children:[o.jsx("div",{className:"unit-stat-label",children:n("multiAgent.totalTokens")}),o.jsx("div",{className:"unit-stat-value",children:HD(a)})]}),o.jsxs("div",{className:"unit-stat",children:[o.jsx("div",{className:"unit-stat-label",children:n("multiAgent.working")}),o.jsx("div",{className:"unit-stat-value",children:r})]})]}),o.jsx("div",{style:{padding:"8px 0",maxHeight:100,overflowY:"auto"},children:e.map(i=>o.jsx(V2,{agent:i,customClasses:s},i.id))}),o.jsx("div",{className:"unit-actions",children:o.jsx("button",{className:"unit-action-btn",onClick:()=>U.deselectAll(),children:n("buttons.deselectAll")})})]})}),V2=x.memo(function({agent:e,customClasses:n}){const s=fr(e.class,n);return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"4px 0",fontSize:12},children:[o.jsx("span",{children:s.icon}),o.jsx("span",{style:{flex:1},children:e.name}),o.jsx("span",{style:{color:"var(--text-secondary)"},children:e.status})]})});function ES({onFocusAgent:t,onKillAgent:e,onCallSubordinates:n,onOpenAreaExplorer:s}){const a=Rs(),r=U.getSelectedAgents();if(a.selectedAgentIds.size===0)return o.jsx(_S,{onOpenAreaExplorer:s});if(a.selectedAgentIds.size===1){const i=r[0];return i?o.jsx(L2,{agent:i,onFocusAgent:t,onKillAgent:e,onCallSubordinates:n,onOpenAreaExplorer:s}):o.jsx(_S,{onOpenAreaExplorer:s})}return o.jsx(q2,{agents:r})}function Y2(t,e){const n={};return(t[t.length-1]===""?[...t,""]:t).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const G2=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,K2=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Q2={};function MS(t,e){return(Q2.jsx?K2:G2).test(t)}const X2=/[ \t\n\f\r]/g;function J2(t){return typeof t=="object"?t.type==="text"?DS(t.value):!1:DS(t)}function DS(t){return t.replace(X2,"")===""}class td{constructor(e,n,s){this.normal=n,this.property=e,s&&(this.space=s)}}td.prototype.normal={};td.prototype.property={};td.prototype.space=void 0;function k1(t,e){const n={},s={};for(const a of t)Object.assign(n,a.property),Object.assign(s,a.normal);return new td(n,s,e)}function rx(t){return t.toLowerCase()}class Xs{constructor(e,n){this.attribute=n,this.property=e}}Xs.prototype.attribute="";Xs.prototype.booleanish=!1;Xs.prototype.boolean=!1;Xs.prototype.commaOrSpaceSeparated=!1;Xs.prototype.commaSeparated=!1;Xs.prototype.defined=!1;Xs.prototype.mustUseProperty=!1;Xs.prototype.number=!1;Xs.prototype.overloadedBoolean=!1;Xs.prototype.property="";Xs.prototype.spaceSeparated=!1;Xs.prototype.space=void 0;let Z2=0;const Wt=Lo(),is=Lo(),ix=Lo(),tt=Lo(),Rn=Lo(),Hl=Lo(),ra=Lo();function Lo(){return 2**++Z2}const ox=Object.freeze(Object.defineProperty({__proto__:null,boolean:Wt,booleanish:is,commaOrSpaceSeparated:ra,commaSeparated:Hl,number:tt,overloadedBoolean:ix,spaceSeparated:Rn},Symbol.toStringTag,{value:"Module"})),Gg=Object.keys(ox);class Kx extends Xs{constructor(e,n,s,a){let r=-1;if(super(e,n),RS(this,"space",a),typeof s=="number")for(;++r<Gg.length;){const i=Gg[r];RS(this,Gg[r],(s&ox[i])===ox[i])}}}Kx.prototype.defined=!0;function RS(t,e,n){n&&(t[e]=n)}function rc(t){const e={},n={};for(const[s,a]of Object.entries(t.properties)){const r=new Kx(s,t.transform(t.attributes||{},s),a,t.space);t.mustUseProperty&&t.mustUseProperty.includes(s)&&(r.mustUseProperty=!0),e[s]=r,n[rx(s)]=s,n[rx(r.attribute)]=s}return new td(e,n,t.space)}const S1=rc({properties:{ariaActiveDescendant:null,ariaAtomic:is,ariaAutoComplete:null,ariaBusy:is,ariaChecked:is,ariaColCount:tt,ariaColIndex:tt,ariaColSpan:tt,ariaControls:Rn,ariaCurrent:null,ariaDescribedBy:Rn,ariaDetails:null,ariaDisabled:is,ariaDropEffect:Rn,ariaErrorMessage:null,ariaExpanded:is,ariaFlowTo:Rn,ariaGrabbed:is,ariaHasPopup:null,ariaHidden:is,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Rn,ariaLevel:tt,ariaLive:null,ariaModal:is,ariaMultiLine:is,ariaMultiSelectable:is,ariaOrientation:null,ariaOwns:Rn,ariaPlaceholder:null,ariaPosInSet:tt,ariaPressed:is,ariaReadOnly:is,ariaRelevant:null,ariaRequired:is,ariaRoleDescription:Rn,ariaRowCount:tt,ariaRowIndex:tt,ariaRowSpan:tt,ariaSelected:is,ariaSetSize:tt,ariaSort:null,ariaValueMax:tt,ariaValueMin:tt,ariaValueNow:tt,ariaValueText:null,role:null},transform(t,e){return e==="role"?e:"aria-"+e.slice(4).toLowerCase()}});function C1(t,e){return e in t?t[e]:e}function A1(t,e){return C1(t,e.toLowerCase())}const eI=rc({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Hl,acceptCharset:Rn,accessKey:Rn,action:null,allow:null,allowFullScreen:Wt,allowPaymentRequest:Wt,allowUserMedia:Wt,alt:null,as:null,async:Wt,autoCapitalize:null,autoComplete:Rn,autoFocus:Wt,autoPlay:Wt,blocking:Rn,capture:null,charSet:null,checked:Wt,cite:null,className:Rn,cols:tt,colSpan:null,content:null,contentEditable:is,controls:Wt,controlsList:Rn,coords:tt|Hl,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Wt,defer:Wt,dir:null,dirName:null,disabled:Wt,download:ix,draggable:is,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Wt,formTarget:null,headers:Rn,height:tt,hidden:ix,high:tt,href:null,hrefLang:null,htmlFor:Rn,httpEquiv:Rn,id:null,imageSizes:null,imageSrcSet:null,inert:Wt,inputMode:null,integrity:null,is:null,isMap:Wt,itemId:null,itemProp:Rn,itemRef:Rn,itemScope:Wt,itemType:Rn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Wt,low:tt,manifest:null,max:null,maxLength:tt,media:null,method:null,min:null,minLength:tt,multiple:Wt,muted:Wt,name:null,nonce:null,noModule:Wt,noValidate:Wt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Wt,optimum:tt,pattern:null,ping:Rn,placeholder:null,playsInline:Wt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Wt,referrerPolicy:null,rel:Rn,required:Wt,reversed:Wt,rows:tt,rowSpan:tt,sandbox:Rn,scope:null,scoped:Wt,seamless:Wt,selected:Wt,shadowRootClonable:Wt,shadowRootDelegatesFocus:Wt,shadowRootMode:null,shape:null,size:tt,sizes:null,slot:null,span:tt,spellCheck:is,src:null,srcDoc:null,srcLang:null,srcSet:null,start:tt,step:null,style:null,tabIndex:tt,target:null,title:null,translate:null,type:null,typeMustMatch:Wt,useMap:null,value:is,width:tt,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Rn,axis:null,background:null,bgColor:null,border:tt,borderColor:null,bottomMargin:tt,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Wt,declare:Wt,event:null,face:null,frame:null,frameBorder:null,hSpace:tt,leftMargin:tt,link:null,longDesc:null,lowSrc:null,marginHeight:tt,marginWidth:tt,noResize:Wt,noHref:Wt,noShade:Wt,noWrap:Wt,object:null,profile:null,prompt:null,rev:null,rightMargin:tt,rules:null,scheme:null,scrolling:is,standby:null,summary:null,text:null,topMargin:tt,valueType:null,version:null,vAlign:null,vLink:null,vSpace:tt,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Wt,disableRemotePlayback:Wt,prefix:null,property:null,results:tt,security:null,unselectable:null},space:"html",transform:A1}),tI=rc({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:ra,accentHeight:tt,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:tt,amplitude:tt,arabicForm:null,ascent:tt,attributeName:null,attributeType:null,azimuth:tt,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:tt,by:null,calcMode:null,capHeight:tt,className:Rn,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:tt,diffuseConstant:tt,direction:null,display:null,dur:null,divisor:tt,dominantBaseline:null,download:Wt,dx:null,dy:null,edgeMode:null,editable:null,elevation:tt,enableBackground:null,end:null,event:null,exponent:tt,externalResourcesRequired:null,fill:null,fillOpacity:tt,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:Hl,g2:Hl,glyphName:Hl,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:tt,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:tt,horizOriginX:tt,horizOriginY:tt,id:null,ideographic:tt,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:tt,k:tt,k1:tt,k2:tt,k3:tt,k4:tt,kernelMatrix:ra,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:tt,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:tt,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:tt,overlineThickness:tt,paintOrder:null,panose1:null,path:null,pathLength:tt,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Rn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:tt,pointsAtY:tt,pointsAtZ:tt,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ra,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ra,rev:ra,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ra,requiredFeatures:ra,requiredFonts:ra,requiredFormats:ra,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:tt,specularExponent:tt,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:tt,strikethroughThickness:tt,string:null,stroke:null,strokeDashArray:ra,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:tt,strokeOpacity:tt,strokeWidth:null,style:null,surfaceScale:tt,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ra,tabIndex:tt,tableValues:null,target:null,targetX:tt,targetY:tt,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ra,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:tt,underlineThickness:tt,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:tt,values:null,vAlphabetic:tt,vMathematical:tt,vectorEffect:null,vHanging:tt,vIdeographic:tt,version:null,vertAdvY:tt,vertOriginX:tt,vertOriginY:tt,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:tt,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:C1}),j1=rc({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(t,e){return"xlink:"+e.slice(5).toLowerCase()}}),N1=rc({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:A1}),T1=rc({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(t,e){return"xml:"+e.slice(3).toLowerCase()}}),nI={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"},sI=/[A-Z]/g,OS=/-[a-z]/g,aI=/^data[-\w.:]+$/i;function rI(t,e){const n=rx(e);let s=e,a=Xs;if(n in t.normal)return t.property[t.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&aI.test(e)){if(e.charAt(4)==="-"){const r=e.slice(5).replace(OS,oI);s="data"+r.charAt(0).toUpperCase()+r.slice(1)}else{const r=e.slice(4);if(!OS.test(r)){let i=r.replace(sI,iI);i.charAt(0)!=="-"&&(i="-"+i),e="data"+i}}a=Kx}return new a(s,e)}function iI(t){return"-"+t.toLowerCase()}function oI(t){return t.charAt(1).toUpperCase()}const lI=k1([S1,eI,j1,N1,T1],"html"),Qx=k1([S1,tI,j1,N1,T1],"svg");function cI(t){return t.join(" ").trim()}var _l={},Kg,LS;function uI(){if(LS)return Kg;LS=1;var t=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,e=/\n/g,n=/^\s*/,s=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,r=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,i=/^[;\s]*/,c=/^\s+|\s+$/g,d=`
48
- `,f="/",h="*",m="",b="comment",y="declaration";function w(N,k){if(typeof N!="string")throw new TypeError("First argument must be a string");if(!N)return[];k=k||{};var j=1,S=1;function T(W){var L=W.match(e);L&&(j+=L.length);var F=W.lastIndexOf(d);S=~F?W.length-F:S+W.length}function D(){var W={line:j,column:S};return function(L){return L.position=new E(W),_(),L}}function E(W){this.start=W,this.end={line:j,column:S},this.source=k.source}E.prototype.content=N;function I(W){var L=new Error(k.source+":"+j+":"+S+": "+W);if(L.reason=W,L.filename=k.source,L.line=j,L.column=S,L.source=N,!k.silent)throw L}function O(W){var L=W.exec(N);if(L){var F=L[0];return T(F),N=N.slice(F.length),L}}function _(){O(n)}function M(W){var L;for(W=W||[];L=R();)L!==!1&&W.push(L);return W}function R(){var W=D();if(!(f!=N.charAt(0)||h!=N.charAt(1))){for(var L=2;m!=N.charAt(L)&&(h!=N.charAt(L)||f!=N.charAt(L+1));)++L;if(L+=2,m===N.charAt(L-1))return I("End of comment missing");var F=N.slice(2,L-2);return S+=2,T(F),N=N.slice(L),S+=2,W({type:b,comment:F})}}function z(){var W=D(),L=O(s);if(L){if(R(),!O(a))return I("property missing ':'");var F=O(r),H=W({type:y,property:C(L[0].replace(t,m)),value:F?C(F[0].replace(t,m)):m});return O(i),H}}function $(){var W=[];M(W);for(var L;L=z();)L!==!1&&(W.push(L),M(W));return W}return _(),$()}function C(N){return N?N.replace(c,m):m}return Kg=w,Kg}var IS;function dI(){if(IS)return _l;IS=1;var t=_l&&_l.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(_l,"__esModule",{value:!0}),_l.default=n;const e=t(uI());function n(s,a){let r=null;if(!s||typeof s!="string")return r;const i=(0,e.default)(s),c=typeof a=="function";return i.forEach(d=>{if(d.type!=="declaration")return;const{property:f,value:h}=d;c?a(f,h,d):h&&(r=r||{},r[f]=h)}),r}return _l}var cu={},PS;function fI(){if(PS)return cu;PS=1,Object.defineProperty(cu,"__esModule",{value:!0}),cu.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,e=/-([a-z])/g,n=/^[^-]+$/,s=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,r=function(f){return!f||n.test(f)||t.test(f)},i=function(f,h){return h.toUpperCase()},c=function(f,h){return"".concat(h,"-")},d=function(f,h){return h===void 0&&(h={}),r(f)?f:(f=f.toLowerCase(),h.reactCompat?f=f.replace(a,c):f=f.replace(s,c),f.replace(e,i))};return cu.camelCase=d,cu}var uu,BS;function pI(){if(BS)return uu;BS=1;var t=uu&&uu.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},e=t(dI()),n=fI();function s(a,r){var i={};return!a||typeof a!="string"||(0,e.default)(a,function(c,d){c&&d&&(i[(0,n.camelCase)(c,r)]=d)}),i}return s.default=s,uu=s,uu}var hI=pI();const mI=Xu(hI),_1=E1("end"),Xx=E1("start");function E1(t){return e;function e(n){const s=n&&n.position&&n.position[t]||{};if(typeof s.line=="number"&&s.line>0&&typeof s.column=="number"&&s.column>0)return{line:s.line,column:s.column,offset:typeof s.offset=="number"&&s.offset>-1?s.offset:void 0}}}function gI(t){const e=Xx(t),n=_1(t);if(e&&n)return{start:e,end:n}}function Du(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?FS(t.position):"start"in t||"end"in t?FS(t):"line"in t||"column"in t?lx(t):""}function lx(t){return zS(t&&t.line)+":"+zS(t&&t.column)}function FS(t){return lx(t&&t.start)+"-"+lx(t&&t.end)}function zS(t){return t&&typeof t=="number"?t:1}class Ns extends Error{constructor(e,n,s){super(),typeof n=="string"&&(s=n,n=void 0);let a="",r={},i=!1;if(n&&("line"in n&&"column"in n?r={place:n}:"start"in n&&"end"in n?r={place:n}:"type"in n?r={ancestors:[n],place:n.position}:r={...n}),typeof e=="string"?a=e:!r.cause&&e&&(i=!0,a=e.message,r.cause=e),!r.ruleId&&!r.source&&typeof s=="string"){const d=s.indexOf(":");d===-1?r.ruleId=s:(r.source=s.slice(0,d),r.ruleId=s.slice(d+1))}if(!r.place&&r.ancestors&&r.ancestors){const d=r.ancestors[r.ancestors.length-1];d&&(r.place=d.position)}const c=r.place&&"start"in r.place?r.place.start:r.place;this.ancestors=r.ancestors||void 0,this.cause=r.cause||void 0,this.column=c?c.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=c?c.line:void 0,this.name=Du(r.place)||"1:1",this.place=r.place||void 0,this.reason=this.message,this.ruleId=r.ruleId||void 0,this.source=r.source||void 0,this.stack=i&&r.cause&&typeof r.cause.stack=="string"?r.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Ns.prototype.file="";Ns.prototype.name="";Ns.prototype.reason="";Ns.prototype.message="";Ns.prototype.stack="";Ns.prototype.column=void 0;Ns.prototype.line=void 0;Ns.prototype.ancestors=void 0;Ns.prototype.cause=void 0;Ns.prototype.fatal=void 0;Ns.prototype.place=void 0;Ns.prototype.ruleId=void 0;Ns.prototype.source=void 0;const Jx={}.hasOwnProperty,bI=new Map,xI=/[A-Z]/g,yI=new Set(["table","tbody","thead","tfoot","tr"]),vI=new Set(["td","th"]),M1="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function wI(t,e){if(!e||e.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=e.filePath||void 0;let s;if(e.development){if(typeof e.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");s=_I(n,e.jsxDEV)}else{if(typeof e.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof e.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");s=TI(n,e.jsx,e.jsxs)}const a={Fragment:e.Fragment,ancestors:[],components:e.components||{},create:s,elementAttributeNameCase:e.elementAttributeNameCase||"react",evaluater:e.createEvaluater?e.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:e.ignoreInvalidStyle||!1,passKeys:e.passKeys!==!1,passNode:e.passNode||!1,schema:e.space==="svg"?Qx:lI,stylePropertyNameCase:e.stylePropertyNameCase||"dom",tableCellAlignToStyle:e.tableCellAlignToStyle!==!1},r=D1(a,t,void 0);return r&&typeof r!="string"?r:a.create(t,a.Fragment,{children:r||void 0},void 0)}function D1(t,e,n){if(e.type==="element")return kI(t,e,n);if(e.type==="mdxFlowExpression"||e.type==="mdxTextExpression")return SI(t,e);if(e.type==="mdxJsxFlowElement"||e.type==="mdxJsxTextElement")return AI(t,e,n);if(e.type==="mdxjsEsm")return CI(t,e);if(e.type==="root")return jI(t,e,n);if(e.type==="text")return NI(t,e)}function kI(t,e,n){const s=t.schema;let a=s;e.tagName.toLowerCase()==="svg"&&s.space==="html"&&(a=Qx,t.schema=a),t.ancestors.push(e);const r=O1(t,e.tagName,!1),i=EI(t,e);let c=ey(t,e);return yI.has(e.tagName)&&(c=c.filter(function(d){return typeof d=="string"?!J2(d):!0})),R1(t,i,r,e),Zx(i,c),t.ancestors.pop(),t.schema=s,t.create(e,r,i,n)}function SI(t,e){if(e.data&&e.data.estree&&t.evaluater){const s=e.data.estree.body[0];return s.type,t.evaluater.evaluateExpression(s.expression)}Vu(t,e.position)}function CI(t,e){if(e.data&&e.data.estree&&t.evaluater)return t.evaluater.evaluateProgram(e.data.estree);Vu(t,e.position)}function AI(t,e,n){const s=t.schema;let a=s;e.name==="svg"&&s.space==="html"&&(a=Qx,t.schema=a),t.ancestors.push(e);const r=e.name===null?t.Fragment:O1(t,e.name,!0),i=MI(t,e),c=ey(t,e);return R1(t,i,r,e),Zx(i,c),t.ancestors.pop(),t.schema=s,t.create(e,r,i,n)}function jI(t,e,n){const s={};return Zx(s,ey(t,e)),t.create(e,t.Fragment,s,n)}function NI(t,e){return e.value}function R1(t,e,n,s){typeof n!="string"&&n!==t.Fragment&&t.passNode&&(e.node=s)}function Zx(t,e){if(e.length>0){const n=e.length>1?e:e[0];n&&(t.children=n)}}function TI(t,e,n){return s;function s(a,r,i,c){const f=Array.isArray(i.children)?n:e;return c?f(r,i,c):f(r,i)}}function _I(t,e){return n;function n(s,a,r,i){const c=Array.isArray(r.children),d=Xx(s);return e(a,r,i,c,{columnNumber:d?d.column-1:void 0,fileName:t,lineNumber:d?d.line:void 0},void 0)}}function EI(t,e){const n={};let s,a;for(a in e.properties)if(a!=="children"&&Jx.call(e.properties,a)){const r=DI(t,a,e.properties[a]);if(r){const[i,c]=r;t.tableCellAlignToStyle&&i==="align"&&typeof c=="string"&&vI.has(e.tagName)?s=c:n[i]=c}}if(s){const r=n.style||(n.style={});r[t.stylePropertyNameCase==="css"?"text-align":"textAlign"]=s}return n}function MI(t,e){const n={};for(const s of e.attributes)if(s.type==="mdxJsxExpressionAttribute")if(s.data&&s.data.estree&&t.evaluater){const r=s.data.estree.body[0];r.type;const i=r.expression;i.type;const c=i.properties[0];c.type,Object.assign(n,t.evaluater.evaluateExpression(c.argument))}else Vu(t,e.position);else{const a=s.name;let r;if(s.value&&typeof s.value=="object")if(s.value.data&&s.value.data.estree&&t.evaluater){const c=s.value.data.estree.body[0];c.type,r=t.evaluater.evaluateExpression(c.expression)}else Vu(t,e.position);else r=s.value===null?!0:s.value;n[a]=r}return n}function ey(t,e){const n=[];let s=-1;const a=t.passKeys?new Map:bI;for(;++s<e.children.length;){const r=e.children[s];let i;if(t.passKeys){const d=r.type==="element"?r.tagName:r.type==="mdxJsxFlowElement"||r.type==="mdxJsxTextElement"?r.name:void 0;if(d){const f=a.get(d)||0;i=d+"-"+f,a.set(d,f+1)}}const c=D1(t,r,i);c!==void 0&&n.push(c)}return n}function DI(t,e,n){const s=rI(t.schema,e);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=s.commaSeparated?Y2(n):cI(n)),s.property==="style"){let a=typeof n=="object"?n:RI(t,String(n));return t.stylePropertyNameCase==="css"&&(a=OI(a)),["style",a]}return[t.elementAttributeNameCase==="react"&&s.space?nI[s.property]||s.property:s.attribute,n]}}function RI(t,e){try{return mI(e,{reactCompat:!0})}catch(n){if(t.ignoreInvalidStyle)return{};const s=n,a=new Ns("Cannot parse `style` attribute",{ancestors:t.ancestors,cause:s,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw a.file=t.filePath||void 0,a.url=M1+"#cannot-parse-style-attribute",a}}function O1(t,e,n){let s;if(!n)s={type:"Literal",value:e};else if(e.includes(".")){const a=e.split(".");let r=-1,i;for(;++r<a.length;){const c=MS(a[r])?{type:"Identifier",name:a[r]}:{type:"Literal",value:a[r]};i=i?{type:"MemberExpression",object:i,property:c,computed:!!(r&&c.type==="Literal"),optional:!1}:c}s=i}else s=MS(e)&&!/^[a-z]/.test(e)?{type:"Identifier",name:e}:{type:"Literal",value:e};if(s.type==="Literal"){const a=s.value;return Jx.call(t.components,a)?t.components[a]:a}if(t.evaluater)return t.evaluater.evaluateExpression(s);Vu(t)}function Vu(t,e){const n=new Ns("Cannot handle MDX estrees without `createEvaluater`",{ancestors:t.ancestors,place:e,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=t.filePath||void 0,n.url=M1+"#cannot-handle-mdx-estrees-without-createevaluater",n}function OI(t){const e={};let n;for(n in t)Jx.call(t,n)&&(e[LI(n)]=t[n]);return e}function LI(t){let e=t.replace(xI,II);return e.slice(0,3)==="ms-"&&(e="-"+e),e}function II(t){return"-"+t.toLowerCase()}const Qg={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"]},PI={};function ty(t,e){const n=PI,s=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,a=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return L1(t,s,a)}function L1(t,e,n){if(BI(t)){if("value"in t)return t.type==="html"&&!n?"":t.value;if(e&&"alt"in t&&t.alt)return t.alt;if("children"in t)return $S(t.children,e,n)}return Array.isArray(t)?$S(t,e,n):""}function $S(t,e,n){const s=[];let a=-1;for(;++a<t.length;)s[a]=L1(t[a],e,n);return s.join("")}function BI(t){return!!(t&&typeof t=="object")}const US=document.createElement("i");function ny(t){const e="&"+t+";";US.innerHTML=e;const n=US.textContent;return n.charCodeAt(n.length-1)===59&&t!=="semi"||n===e?!1:n}function ua(t,e,n,s){const a=t.length;let r=0,i;if(e<0?e=-e>a?0:a+e:e=e>a?a:e,n=n>0?n:0,s.length<1e4)i=Array.from(s),i.unshift(e,n),t.splice(...i);else for(n&&t.splice(e,n);r<s.length;)i=s.slice(r,r+1e4),i.unshift(e,0),t.splice(...i),r+=1e4,e+=1e4}function Aa(t,e){return t.length>0?(ua(t,t.length,0,e),t):e}const HS={}.hasOwnProperty;function I1(t){const e={};let n=-1;for(;++n<t.length;)FI(e,t[n]);return e}function FI(t,e){let n;for(n in e){const a=(HS.call(t,n)?t[n]:void 0)||(t[n]={}),r=e[n];let i;if(r)for(i in r){HS.call(a,i)||(a[i]=[]);const c=r[i];zI(a[i],Array.isArray(c)?c:c?[c]:[])}}}function zI(t,e){let n=-1;const s=[];for(;++n<e.length;)(e[n].add==="after"?t:s).push(e[n]);ua(t,0,0,s)}function P1(t,e){const n=Number.parseInt(t,e);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Ia(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Ms=Pi(/[A-Za-z]/),js=Pi(/[\dA-Za-z]/),$I=Pi(/[#-'*+\--9=?A-Z^-~]/);function kp(t){return t!==null&&(t<32||t===127)}const cx=Pi(/\d/),UI=Pi(/[\dA-Fa-f]/),HI=Pi(/[!-/:-@[-`{-~]/);function Et(t){return t!==null&&t<-2}function _n(t){return t!==null&&(t<0||t===32)}function en(t){return t===-2||t===-1||t===32}const Jp=Pi(new RegExp("\\p{P}|\\p{S}","u")),Eo=Pi(/\s/);function Pi(t){return e;function e(n){return n!==null&&n>-1&&t.test(String.fromCharCode(n))}}function ic(t){const e=[];let n=-1,s=0,a=0;for(;++n<t.length;){const r=t.charCodeAt(n);let i="";if(r===37&&js(t.charCodeAt(n+1))&&js(t.charCodeAt(n+2)))a=2;else if(r<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(r))||(i=String.fromCharCode(r));else if(r>55295&&r<57344){const c=t.charCodeAt(n+1);r<56320&&c>56319&&c<57344?(i=String.fromCharCode(r,c),a=1):i="�"}else i=String.fromCharCode(r);i&&(e.push(t.slice(s,n),encodeURIComponent(i)),s=n+a+1,i=""),a&&(n+=a,a=0)}return e.join("")+t.slice(s)}function un(t,e,n,s){const a=s?s-1:Number.POSITIVE_INFINITY;let r=0;return i;function i(d){return en(d)?(t.enter(n),c(d)):e(d)}function c(d){return en(d)&&r++<a?(t.consume(d),c):(t.exit(n),e(d))}}const WI={tokenize:qI};function qI(t){const e=t.attempt(this.parser.constructs.contentInitial,s,a);let n;return e;function s(c){if(c===null){t.consume(c);return}return t.enter("lineEnding"),t.consume(c),t.exit("lineEnding"),un(t,e,"linePrefix")}function a(c){return t.enter("paragraph"),r(c)}function r(c){const d=t.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=d),n=d,i(c)}function i(c){if(c===null){t.exit("chunkText"),t.exit("paragraph"),t.consume(c);return}return Et(c)?(t.consume(c),t.exit("chunkText"),r):(t.consume(c),i)}}const VI={tokenize:YI},WS={tokenize:GI};function YI(t){const e=this,n=[];let s=0,a,r,i;return c;function c(S){if(s<n.length){const T=n[s];return e.containerState=T[1],t.attempt(T[0].continuation,d,f)(S)}return f(S)}function d(S){if(s++,e.containerState._closeFlow){e.containerState._closeFlow=void 0,a&&j();const T=e.events.length;let D=T,E;for(;D--;)if(e.events[D][0]==="exit"&&e.events[D][1].type==="chunkFlow"){E=e.events[D][1].end;break}k(s);let I=T;for(;I<e.events.length;)e.events[I][1].end={...E},I++;return ua(e.events,D+1,0,e.events.slice(T)),e.events.length=I,f(S)}return c(S)}function f(S){if(s===n.length){if(!a)return b(S);if(a.currentConstruct&&a.currentConstruct.concrete)return w(S);e.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return e.containerState={},t.check(WS,h,m)(S)}function h(S){return a&&j(),k(s),b(S)}function m(S){return e.parser.lazy[e.now().line]=s!==n.length,i=e.now().offset,w(S)}function b(S){return e.containerState={},t.attempt(WS,y,w)(S)}function y(S){return s++,n.push([e.currentConstruct,e.containerState]),b(S)}function w(S){if(S===null){a&&j(),k(0),t.consume(S);return}return a=a||e.parser.flow(e.now()),t.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:r}),C(S)}function C(S){if(S===null){N(t.exit("chunkFlow"),!0),k(0),t.consume(S);return}return Et(S)?(t.consume(S),N(t.exit("chunkFlow")),s=0,e.interrupt=void 0,c):(t.consume(S),C)}function N(S,T){const D=e.sliceStream(S);if(T&&D.push(null),S.previous=r,r&&(r.next=S),r=S,a.defineSkip(S.start),a.write(D),e.parser.lazy[S.start.line]){let E=a.events.length;for(;E--;)if(a.events[E][1].start.offset<i&&(!a.events[E][1].end||a.events[E][1].end.offset>i))return;const I=e.events.length;let O=I,_,M;for(;O--;)if(e.events[O][0]==="exit"&&e.events[O][1].type==="chunkFlow"){if(_){M=e.events[O][1].end;break}_=!0}for(k(s),E=I;E<e.events.length;)e.events[E][1].end={...M},E++;ua(e.events,O+1,0,e.events.slice(I)),e.events.length=E}}function k(S){let T=n.length;for(;T-- >S;){const D=n[T];e.containerState=D[1],D[0].exit.call(e,t)}n.length=S}function j(){a.write([null]),r=void 0,a=void 0,e.containerState._closeFlow=void 0}}function GI(t,e,n){return un(t,t.attempt(this.parser.constructs.document,e,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Gl(t){if(t===null||_n(t)||Eo(t))return 1;if(Jp(t))return 2}function Zp(t,e,n){const s=[];let a=-1;for(;++a<t.length;){const r=t[a].resolveAll;r&&!s.includes(r)&&(e=r(e,n),s.push(r))}return e}const ux={name:"attention",resolveAll:KI,tokenize:QI};function KI(t,e){let n=-1,s,a,r,i,c,d,f,h;for(;++n<t.length;)if(t[n][0]==="enter"&&t[n][1].type==="attentionSequence"&&t[n][1]._close){for(s=n;s--;)if(t[s][0]==="exit"&&t[s][1].type==="attentionSequence"&&t[s][1]._open&&e.sliceSerialize(t[s][1]).charCodeAt(0)===e.sliceSerialize(t[n][1]).charCodeAt(0)){if((t[s][1]._close||t[n][1]._open)&&(t[n][1].end.offset-t[n][1].start.offset)%3&&!((t[s][1].end.offset-t[s][1].start.offset+t[n][1].end.offset-t[n][1].start.offset)%3))continue;d=t[s][1].end.offset-t[s][1].start.offset>1&&t[n][1].end.offset-t[n][1].start.offset>1?2:1;const m={...t[s][1].end},b={...t[n][1].start};qS(m,-d),qS(b,d),i={type:d>1?"strongSequence":"emphasisSequence",start:m,end:{...t[s][1].end}},c={type:d>1?"strongSequence":"emphasisSequence",start:{...t[n][1].start},end:b},r={type:d>1?"strongText":"emphasisText",start:{...t[s][1].end},end:{...t[n][1].start}},a={type:d>1?"strong":"emphasis",start:{...i.start},end:{...c.end}},t[s][1].end={...i.start},t[n][1].start={...c.end},f=[],t[s][1].end.offset-t[s][1].start.offset&&(f=Aa(f,[["enter",t[s][1],e],["exit",t[s][1],e]])),f=Aa(f,[["enter",a,e],["enter",i,e],["exit",i,e],["enter",r,e]]),f=Aa(f,Zp(e.parser.constructs.insideSpan.null,t.slice(s+1,n),e)),f=Aa(f,[["exit",r,e],["enter",c,e],["exit",c,e],["exit",a,e]]),t[n][1].end.offset-t[n][1].start.offset?(h=2,f=Aa(f,[["enter",t[n][1],e],["exit",t[n][1],e]])):h=0,ua(t,s-1,n-s+3,f),n=s+f.length-h-2;break}}for(n=-1;++n<t.length;)t[n][1].type==="attentionSequence"&&(t[n][1].type="data");return t}function QI(t,e){const n=this.parser.constructs.attentionMarkers.null,s=this.previous,a=Gl(s);let r;return i;function i(d){return r=d,t.enter("attentionSequence"),c(d)}function c(d){if(d===r)return t.consume(d),c;const f=t.exit("attentionSequence"),h=Gl(d),m=!h||h===2&&a||n.includes(d),b=!a||a===2&&h||n.includes(s);return f._open=!!(r===42?m:m&&(a||!b)),f._close=!!(r===42?b:b&&(h||!m)),e(d)}}function qS(t,e){t.column+=e,t.offset+=e,t._bufferIndex+=e}const XI={name:"autolink",tokenize:JI};function JI(t,e,n){let s=0;return a;function a(y){return t.enter("autolink"),t.enter("autolinkMarker"),t.consume(y),t.exit("autolinkMarker"),t.enter("autolinkProtocol"),r}function r(y){return Ms(y)?(t.consume(y),i):y===64?n(y):f(y)}function i(y){return y===43||y===45||y===46||js(y)?(s=1,c(y)):f(y)}function c(y){return y===58?(t.consume(y),s=0,d):(y===43||y===45||y===46||js(y))&&s++<32?(t.consume(y),c):(s=0,f(y))}function d(y){return y===62?(t.exit("autolinkProtocol"),t.enter("autolinkMarker"),t.consume(y),t.exit("autolinkMarker"),t.exit("autolink"),e):y===null||y===32||y===60||kp(y)?n(y):(t.consume(y),d)}function f(y){return y===64?(t.consume(y),h):$I(y)?(t.consume(y),f):n(y)}function h(y){return js(y)?m(y):n(y)}function m(y){return y===46?(t.consume(y),s=0,h):y===62?(t.exit("autolinkProtocol").type="autolinkEmail",t.enter("autolinkMarker"),t.consume(y),t.exit("autolinkMarker"),t.exit("autolink"),e):b(y)}function b(y){if((y===45||js(y))&&s++<63){const w=y===45?b:m;return t.consume(y),w}return n(y)}}const nd={partial:!0,tokenize:ZI};function ZI(t,e,n){return s;function s(r){return en(r)?un(t,a,"linePrefix")(r):a(r)}function a(r){return r===null||Et(r)?e(r):n(r)}}const B1={continuation:{tokenize:tP},exit:nP,name:"blockQuote",tokenize:eP};function eP(t,e,n){const s=this;return a;function a(i){if(i===62){const c=s.containerState;return c.open||(t.enter("blockQuote",{_container:!0}),c.open=!0),t.enter("blockQuotePrefix"),t.enter("blockQuoteMarker"),t.consume(i),t.exit("blockQuoteMarker"),r}return n(i)}function r(i){return en(i)?(t.enter("blockQuotePrefixWhitespace"),t.consume(i),t.exit("blockQuotePrefixWhitespace"),t.exit("blockQuotePrefix"),e):(t.exit("blockQuotePrefix"),e(i))}}function tP(t,e,n){const s=this;return a;function a(i){return en(i)?un(t,r,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i):r(i)}function r(i){return t.attempt(B1,e,n)(i)}}function nP(t){t.exit("blockQuote")}const F1={name:"characterEscape",tokenize:sP};function sP(t,e,n){return s;function s(r){return t.enter("characterEscape"),t.enter("escapeMarker"),t.consume(r),t.exit("escapeMarker"),a}function a(r){return HI(r)?(t.enter("characterEscapeValue"),t.consume(r),t.exit("characterEscapeValue"),t.exit("characterEscape"),e):n(r)}}const z1={name:"characterReference",tokenize:aP};function aP(t,e,n){const s=this;let a=0,r,i;return c;function c(m){return t.enter("characterReference"),t.enter("characterReferenceMarker"),t.consume(m),t.exit("characterReferenceMarker"),d}function d(m){return m===35?(t.enter("characterReferenceMarkerNumeric"),t.consume(m),t.exit("characterReferenceMarkerNumeric"),f):(t.enter("characterReferenceValue"),r=31,i=js,h(m))}function f(m){return m===88||m===120?(t.enter("characterReferenceMarkerHexadecimal"),t.consume(m),t.exit("characterReferenceMarkerHexadecimal"),t.enter("characterReferenceValue"),r=6,i=UI,h):(t.enter("characterReferenceValue"),r=7,i=cx,h(m))}function h(m){if(m===59&&a){const b=t.exit("characterReferenceValue");return i===js&&!ny(s.sliceSerialize(b))?n(m):(t.enter("characterReferenceMarker"),t.consume(m),t.exit("characterReferenceMarker"),t.exit("characterReference"),e)}return i(m)&&a++<r?(t.consume(m),h):n(m)}}const VS={partial:!0,tokenize:iP},YS={concrete:!0,name:"codeFenced",tokenize:rP};function rP(t,e,n){const s=this,a={partial:!0,tokenize:D};let r=0,i=0,c;return d;function d(E){return f(E)}function f(E){const I=s.events[s.events.length-1];return r=I&&I[1].type==="linePrefix"?I[2].sliceSerialize(I[1],!0).length:0,c=E,t.enter("codeFenced"),t.enter("codeFencedFence"),t.enter("codeFencedFenceSequence"),h(E)}function h(E){return E===c?(i++,t.consume(E),h):i<3?n(E):(t.exit("codeFencedFenceSequence"),en(E)?un(t,m,"whitespace")(E):m(E))}function m(E){return E===null||Et(E)?(t.exit("codeFencedFence"),s.interrupt?e(E):t.check(VS,C,T)(E)):(t.enter("codeFencedFenceInfo"),t.enter("chunkString",{contentType:"string"}),b(E))}function b(E){return E===null||Et(E)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),m(E)):en(E)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),un(t,y,"whitespace")(E)):E===96&&E===c?n(E):(t.consume(E),b)}function y(E){return E===null||Et(E)?m(E):(t.enter("codeFencedFenceMeta"),t.enter("chunkString",{contentType:"string"}),w(E))}function w(E){return E===null||Et(E)?(t.exit("chunkString"),t.exit("codeFencedFenceMeta"),m(E)):E===96&&E===c?n(E):(t.consume(E),w)}function C(E){return t.attempt(a,T,N)(E)}function N(E){return t.enter("lineEnding"),t.consume(E),t.exit("lineEnding"),k}function k(E){return r>0&&en(E)?un(t,j,"linePrefix",r+1)(E):j(E)}function j(E){return E===null||Et(E)?t.check(VS,C,T)(E):(t.enter("codeFlowValue"),S(E))}function S(E){return E===null||Et(E)?(t.exit("codeFlowValue"),j(E)):(t.consume(E),S)}function T(E){return t.exit("codeFenced"),e(E)}function D(E,I,O){let _=0;return M;function M(L){return E.enter("lineEnding"),E.consume(L),E.exit("lineEnding"),R}function R(L){return E.enter("codeFencedFence"),en(L)?un(E,z,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):z(L)}function z(L){return L===c?(E.enter("codeFencedFenceSequence"),$(L)):O(L)}function $(L){return L===c?(_++,E.consume(L),$):_>=i?(E.exit("codeFencedFenceSequence"),en(L)?un(E,W,"whitespace")(L):W(L)):O(L)}function W(L){return L===null||Et(L)?(E.exit("codeFencedFence"),I(L)):O(L)}}}function iP(t,e,n){const s=this;return a;function a(i){return i===null?n(i):(t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),r)}function r(i){return s.parser.lazy[s.now().line]?n(i):e(i)}}const Xg={name:"codeIndented",tokenize:lP},oP={partial:!0,tokenize:cP};function lP(t,e,n){const s=this;return a;function a(f){return t.enter("codeIndented"),un(t,r,"linePrefix",5)(f)}function r(f){const h=s.events[s.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?i(f):n(f)}function i(f){return f===null?d(f):Et(f)?t.attempt(oP,i,d)(f):(t.enter("codeFlowValue"),c(f))}function c(f){return f===null||Et(f)?(t.exit("codeFlowValue"),i(f)):(t.consume(f),c)}function d(f){return t.exit("codeIndented"),e(f)}}function cP(t,e,n){const s=this;return a;function a(i){return s.parser.lazy[s.now().line]?n(i):Et(i)?(t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),a):un(t,r,"linePrefix",5)(i)}function r(i){const c=s.events[s.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?e(i):Et(i)?a(i):n(i)}}const uP={name:"codeText",previous:fP,resolve:dP,tokenize:pP};function dP(t){let e=t.length-4,n=3,s,a;if((t[n][1].type==="lineEnding"||t[n][1].type==="space")&&(t[e][1].type==="lineEnding"||t[e][1].type==="space")){for(s=n;++s<e;)if(t[s][1].type==="codeTextData"){t[n][1].type="codeTextPadding",t[e][1].type="codeTextPadding",n+=2,e-=2;break}}for(s=n-1,e++;++s<=e;)a===void 0?s!==e&&t[s][1].type!=="lineEnding"&&(a=s):(s===e||t[s][1].type==="lineEnding")&&(t[a][1].type="codeTextData",s!==a+2&&(t[a][1].end=t[s-1][1].end,t.splice(a+2,s-a-2),e-=s-a-2,s=a+2),a=void 0);return t}function fP(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"}function pP(t,e,n){let s=0,a,r;return i;function i(m){return t.enter("codeText"),t.enter("codeTextSequence"),c(m)}function c(m){return m===96?(t.consume(m),s++,c):(t.exit("codeTextSequence"),d(m))}function d(m){return m===null?n(m):m===32?(t.enter("space"),t.consume(m),t.exit("space"),d):m===96?(r=t.enter("codeTextSequence"),a=0,h(m)):Et(m)?(t.enter("lineEnding"),t.consume(m),t.exit("lineEnding"),d):(t.enter("codeTextData"),f(m))}function f(m){return m===null||m===32||m===96||Et(m)?(t.exit("codeTextData"),d(m)):(t.consume(m),f)}function h(m){return m===96?(t.consume(m),a++,h):a===s?(t.exit("codeTextSequence"),t.exit("codeText"),e(m)):(r.type="codeTextData",f(m))}}class hP{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,n){const s=n??Number.POSITIVE_INFINITY;return s<this.left.length?this.left.slice(e,s):e>this.left.length?this.right.slice(this.right.length-s+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-s+this.left.length).reverse())}splice(e,n,s){const a=n||0;this.setCursor(Math.trunc(e));const r=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return s&&du(this.left,s),r.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),du(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),du(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){const n=this.left.splice(e,Number.POSITIVE_INFINITY);du(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);du(this.left,n.reverse())}}}function du(t,e){let n=0;if(e.length<1e4)t.push(...e);else for(;n<e.length;)t.push(...e.slice(n,n+1e4)),n+=1e4}function $1(t){const e={};let n=-1,s,a,r,i,c,d,f;const h=new hP(t);for(;++n<h.length;){for(;n in e;)n=e[n];if(s=h.get(n),n&&s[1].type==="chunkFlow"&&h.get(n-1)[1].type==="listItemPrefix"&&(d=s[1]._tokenizer.events,r=0,r<d.length&&d[r][1].type==="lineEndingBlank"&&(r+=2),r<d.length&&d[r][1].type==="content"))for(;++r<d.length&&d[r][1].type!=="content";)d[r][1].type==="chunkText"&&(d[r][1]._isInFirstContentOfListItem=!0,r++);if(s[0]==="enter")s[1].contentType&&(Object.assign(e,mP(h,n)),n=e[n],f=!0);else if(s[1]._container){for(r=n,a=void 0;r--;)if(i=h.get(r),i[1].type==="lineEnding"||i[1].type==="lineEndingBlank")i[0]==="enter"&&(a&&(h.get(a)[1].type="lineEndingBlank"),i[1].type="lineEnding",a=r);else if(!(i[1].type==="linePrefix"||i[1].type==="listItemIndent"))break;a&&(s[1].end={...h.get(a)[1].start},c=h.slice(a,n),c.unshift(s),h.splice(a,n-a+1,c))}}return ua(t,0,Number.POSITIVE_INFINITY,h.slice(0)),!f}function mP(t,e){const n=t.get(e)[1],s=t.get(e)[2];let a=e-1;const r=[];let i=n._tokenizer;i||(i=s.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(i._contentTypeTextTrailing=!0));const c=i.events,d=[],f={};let h,m,b=-1,y=n,w=0,C=0;const N=[C];for(;y;){for(;t.get(++a)[1]!==y;);r.push(a),y._tokenizer||(h=s.sliceStream(y),y.next||h.push(null),m&&i.defineSkip(y.start),y._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=!0),i.write(h),y._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=void 0)),m=y,y=y.next}for(y=n;++b<c.length;)c[b][0]==="exit"&&c[b-1][0]==="enter"&&c[b][1].type===c[b-1][1].type&&c[b][1].start.line!==c[b][1].end.line&&(C=b+1,N.push(C),y._tokenizer=void 0,y.previous=void 0,y=y.next);for(i.events=[],y?(y._tokenizer=void 0,y.previous=void 0):N.pop(),b=N.length;b--;){const k=c.slice(N[b],N[b+1]),j=r.pop();d.push([j,j+k.length-1]),t.splice(j,2,k)}for(d.reverse(),b=-1;++b<d.length;)f[w+d[b][0]]=w+d[b][1],w+=d[b][1]-d[b][0]-1;return f}const gP={resolve:xP,tokenize:yP},bP={partial:!0,tokenize:vP};function xP(t){return $1(t),t}function yP(t,e){let n;return s;function s(c){return t.enter("content"),n=t.enter("chunkContent",{contentType:"content"}),a(c)}function a(c){return c===null?r(c):Et(c)?t.check(bP,i,r)(c):(t.consume(c),a)}function r(c){return t.exit("chunkContent"),t.exit("content"),e(c)}function i(c){return t.consume(c),t.exit("chunkContent"),n.next=t.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,a}}function vP(t,e,n){const s=this;return a;function a(i){return t.exit("chunkContent"),t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),un(t,r,"linePrefix")}function r(i){if(i===null||Et(i))return n(i);const c=s.events[s.events.length-1];return!s.parser.constructs.disable.null.includes("codeIndented")&&c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?e(i):t.interrupt(s.parser.constructs.flow,n,e)(i)}}function U1(t,e,n,s,a,r,i,c,d){const f=d||Number.POSITIVE_INFINITY;let h=0;return m;function m(k){return k===60?(t.enter(s),t.enter(a),t.enter(r),t.consume(k),t.exit(r),b):k===null||k===32||k===41||kp(k)?n(k):(t.enter(s),t.enter(i),t.enter(c),t.enter("chunkString",{contentType:"string"}),C(k))}function b(k){return k===62?(t.enter(r),t.consume(k),t.exit(r),t.exit(a),t.exit(s),e):(t.enter(c),t.enter("chunkString",{contentType:"string"}),y(k))}function y(k){return k===62?(t.exit("chunkString"),t.exit(c),b(k)):k===null||k===60||Et(k)?n(k):(t.consume(k),k===92?w:y)}function w(k){return k===60||k===62||k===92?(t.consume(k),y):y(k)}function C(k){return!h&&(k===null||k===41||_n(k))?(t.exit("chunkString"),t.exit(c),t.exit(i),t.exit(s),e(k)):h<f&&k===40?(t.consume(k),h++,C):k===41?(t.consume(k),h--,C):k===null||k===32||k===40||kp(k)?n(k):(t.consume(k),k===92?N:C)}function N(k){return k===40||k===41||k===92?(t.consume(k),C):C(k)}}function H1(t,e,n,s,a,r){const i=this;let c=0,d;return f;function f(y){return t.enter(s),t.enter(a),t.consume(y),t.exit(a),t.enter(r),h}function h(y){return c>999||y===null||y===91||y===93&&!d||y===94&&!c&&"_hiddenFootnoteSupport"in i.parser.constructs?n(y):y===93?(t.exit(r),t.enter(a),t.consume(y),t.exit(a),t.exit(s),e):Et(y)?(t.enter("lineEnding"),t.consume(y),t.exit("lineEnding"),h):(t.enter("chunkString",{contentType:"string"}),m(y))}function m(y){return y===null||y===91||y===93||Et(y)||c++>999?(t.exit("chunkString"),h(y)):(t.consume(y),d||(d=!en(y)),y===92?b:m)}function b(y){return y===91||y===92||y===93?(t.consume(y),c++,m):m(y)}}function W1(t,e,n,s,a,r){let i;return c;function c(b){return b===34||b===39||b===40?(t.enter(s),t.enter(a),t.consume(b),t.exit(a),i=b===40?41:b,d):n(b)}function d(b){return b===i?(t.enter(a),t.consume(b),t.exit(a),t.exit(s),e):(t.enter(r),f(b))}function f(b){return b===i?(t.exit(r),d(i)):b===null?n(b):Et(b)?(t.enter("lineEnding"),t.consume(b),t.exit("lineEnding"),un(t,f,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),h(b))}function h(b){return b===i||b===null||Et(b)?(t.exit("chunkString"),f(b)):(t.consume(b),b===92?m:h)}function m(b){return b===i||b===92?(t.consume(b),h):h(b)}}function Ru(t,e){let n;return s;function s(a){return Et(a)?(t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),n=!0,s):en(a)?un(t,s,n?"linePrefix":"lineSuffix")(a):e(a)}}const wP={name:"definition",tokenize:SP},kP={partial:!0,tokenize:CP};function SP(t,e,n){const s=this;let a;return r;function r(y){return t.enter("definition"),i(y)}function i(y){return H1.call(s,t,c,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function c(y){return a=Ia(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)),y===58?(t.enter("definitionMarker"),t.consume(y),t.exit("definitionMarker"),d):n(y)}function d(y){return _n(y)?Ru(t,f)(y):f(y)}function f(y){return U1(t,h,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function h(y){return t.attempt(kP,m,m)(y)}function m(y){return en(y)?un(t,b,"whitespace")(y):b(y)}function b(y){return y===null||Et(y)?(t.exit("definition"),s.parser.defined.push(a),e(y)):n(y)}}function CP(t,e,n){return s;function s(c){return _n(c)?Ru(t,a)(c):n(c)}function a(c){return W1(t,r,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(c)}function r(c){return en(c)?un(t,i,"whitespace")(c):i(c)}function i(c){return c===null||Et(c)?e(c):n(c)}}const AP={name:"hardBreakEscape",tokenize:jP};function jP(t,e,n){return s;function s(r){return t.enter("hardBreakEscape"),t.consume(r),a}function a(r){return Et(r)?(t.exit("hardBreakEscape"),e(r)):n(r)}}const NP={name:"headingAtx",resolve:TP,tokenize:_P};function TP(t,e){let n=t.length-2,s=3,a,r;return t[s][1].type==="whitespace"&&(s+=2),n-2>s&&t[n][1].type==="whitespace"&&(n-=2),t[n][1].type==="atxHeadingSequence"&&(s===n-1||n-4>s&&t[n-2][1].type==="whitespace")&&(n-=s+1===n?2:4),n>s&&(a={type:"atxHeadingText",start:t[s][1].start,end:t[n][1].end},r={type:"chunkText",start:t[s][1].start,end:t[n][1].end,contentType:"text"},ua(t,s,n-s+1,[["enter",a,e],["enter",r,e],["exit",r,e],["exit",a,e]])),t}function _P(t,e,n){let s=0;return a;function a(h){return t.enter("atxHeading"),r(h)}function r(h){return t.enter("atxHeadingSequence"),i(h)}function i(h){return h===35&&s++<6?(t.consume(h),i):h===null||_n(h)?(t.exit("atxHeadingSequence"),c(h)):n(h)}function c(h){return h===35?(t.enter("atxHeadingSequence"),d(h)):h===null||Et(h)?(t.exit("atxHeading"),e(h)):en(h)?un(t,c,"whitespace")(h):(t.enter("atxHeadingText"),f(h))}function d(h){return h===35?(t.consume(h),d):(t.exit("atxHeadingSequence"),c(h))}function f(h){return h===null||h===35||_n(h)?(t.exit("atxHeadingText"),c(h)):(t.consume(h),f)}}const EP=["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"],GS=["pre","script","style","textarea"],MP={concrete:!0,name:"htmlFlow",resolveTo:OP,tokenize:LP},DP={partial:!0,tokenize:PP},RP={partial:!0,tokenize:IP};function OP(t){let e=t.length;for(;e--&&!(t[e][0]==="enter"&&t[e][1].type==="htmlFlow"););return e>1&&t[e-2][1].type==="linePrefix"&&(t[e][1].start=t[e-2][1].start,t[e+1][1].start=t[e-2][1].start,t.splice(e-2,2)),t}function LP(t,e,n){const s=this;let a,r,i,c,d;return f;function f(q){return h(q)}function h(q){return t.enter("htmlFlow"),t.enter("htmlFlowData"),t.consume(q),m}function m(q){return q===33?(t.consume(q),b):q===47?(t.consume(q),r=!0,C):q===63?(t.consume(q),a=3,s.interrupt?e:B):Ms(q)?(t.consume(q),i=String.fromCharCode(q),N):n(q)}function b(q){return q===45?(t.consume(q),a=2,y):q===91?(t.consume(q),a=5,c=0,w):Ms(q)?(t.consume(q),a=4,s.interrupt?e:B):n(q)}function y(q){return q===45?(t.consume(q),s.interrupt?e:B):n(q)}function w(q){const be="CDATA[";return q===be.charCodeAt(c++)?(t.consume(q),c===be.length?s.interrupt?e:z:w):n(q)}function C(q){return Ms(q)?(t.consume(q),i=String.fromCharCode(q),N):n(q)}function N(q){if(q===null||q===47||q===62||_n(q)){const be=q===47,Ce=i.toLowerCase();return!be&&!r&&GS.includes(Ce)?(a=1,s.interrupt?e(q):z(q)):EP.includes(i.toLowerCase())?(a=6,be?(t.consume(q),k):s.interrupt?e(q):z(q)):(a=7,s.interrupt&&!s.parser.lazy[s.now().line]?n(q):r?j(q):S(q))}return q===45||js(q)?(t.consume(q),i+=String.fromCharCode(q),N):n(q)}function k(q){return q===62?(t.consume(q),s.interrupt?e:z):n(q)}function j(q){return en(q)?(t.consume(q),j):M(q)}function S(q){return q===47?(t.consume(q),M):q===58||q===95||Ms(q)?(t.consume(q),T):en(q)?(t.consume(q),S):M(q)}function T(q){return q===45||q===46||q===58||q===95||js(q)?(t.consume(q),T):D(q)}function D(q){return q===61?(t.consume(q),E):en(q)?(t.consume(q),D):S(q)}function E(q){return q===null||q===60||q===61||q===62||q===96?n(q):q===34||q===39?(t.consume(q),d=q,I):en(q)?(t.consume(q),E):O(q)}function I(q){return q===d?(t.consume(q),d=null,_):q===null||Et(q)?n(q):(t.consume(q),I)}function O(q){return q===null||q===34||q===39||q===47||q===60||q===61||q===62||q===96||_n(q)?D(q):(t.consume(q),O)}function _(q){return q===47||q===62||en(q)?S(q):n(q)}function M(q){return q===62?(t.consume(q),R):n(q)}function R(q){return q===null||Et(q)?z(q):en(q)?(t.consume(q),R):n(q)}function z(q){return q===45&&a===2?(t.consume(q),F):q===60&&a===1?(t.consume(q),H):q===62&&a===4?(t.consume(q),K):q===63&&a===3?(t.consume(q),B):q===93&&a===5?(t.consume(q),G):Et(q)&&(a===6||a===7)?(t.exit("htmlFlowData"),t.check(DP,se,$)(q)):q===null||Et(q)?(t.exit("htmlFlowData"),$(q)):(t.consume(q),z)}function $(q){return t.check(RP,W,se)(q)}function W(q){return t.enter("lineEnding"),t.consume(q),t.exit("lineEnding"),L}function L(q){return q===null||Et(q)?$(q):(t.enter("htmlFlowData"),z(q))}function F(q){return q===45?(t.consume(q),B):z(q)}function H(q){return q===47?(t.consume(q),i="",V):z(q)}function V(q){if(q===62){const be=i.toLowerCase();return GS.includes(be)?(t.consume(q),K):z(q)}return Ms(q)&&i.length<8?(t.consume(q),i+=String.fromCharCode(q),V):z(q)}function G(q){return q===93?(t.consume(q),B):z(q)}function B(q){return q===62?(t.consume(q),K):q===45&&a===2?(t.consume(q),B):z(q)}function K(q){return q===null||Et(q)?(t.exit("htmlFlowData"),se(q)):(t.consume(q),K)}function se(q){return t.exit("htmlFlow"),e(q)}}function IP(t,e,n){const s=this;return a;function a(i){return Et(i)?(t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),r):n(i)}function r(i){return s.parser.lazy[s.now().line]?n(i):e(i)}}function PP(t,e,n){return s;function s(a){return t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),t.attempt(nd,e,n)}}const BP={name:"htmlText",tokenize:FP};function FP(t,e,n){const s=this;let a,r,i;return c;function c(B){return t.enter("htmlText"),t.enter("htmlTextData"),t.consume(B),d}function d(B){return B===33?(t.consume(B),f):B===47?(t.consume(B),D):B===63?(t.consume(B),S):Ms(B)?(t.consume(B),O):n(B)}function f(B){return B===45?(t.consume(B),h):B===91?(t.consume(B),r=0,w):Ms(B)?(t.consume(B),j):n(B)}function h(B){return B===45?(t.consume(B),y):n(B)}function m(B){return B===null?n(B):B===45?(t.consume(B),b):Et(B)?(i=m,H(B)):(t.consume(B),m)}function b(B){return B===45?(t.consume(B),y):m(B)}function y(B){return B===62?F(B):B===45?b(B):m(B)}function w(B){const K="CDATA[";return B===K.charCodeAt(r++)?(t.consume(B),r===K.length?C:w):n(B)}function C(B){return B===null?n(B):B===93?(t.consume(B),N):Et(B)?(i=C,H(B)):(t.consume(B),C)}function N(B){return B===93?(t.consume(B),k):C(B)}function k(B){return B===62?F(B):B===93?(t.consume(B),k):C(B)}function j(B){return B===null||B===62?F(B):Et(B)?(i=j,H(B)):(t.consume(B),j)}function S(B){return B===null?n(B):B===63?(t.consume(B),T):Et(B)?(i=S,H(B)):(t.consume(B),S)}function T(B){return B===62?F(B):S(B)}function D(B){return Ms(B)?(t.consume(B),E):n(B)}function E(B){return B===45||js(B)?(t.consume(B),E):I(B)}function I(B){return Et(B)?(i=I,H(B)):en(B)?(t.consume(B),I):F(B)}function O(B){return B===45||js(B)?(t.consume(B),O):B===47||B===62||_n(B)?_(B):n(B)}function _(B){return B===47?(t.consume(B),F):B===58||B===95||Ms(B)?(t.consume(B),M):Et(B)?(i=_,H(B)):en(B)?(t.consume(B),_):F(B)}function M(B){return B===45||B===46||B===58||B===95||js(B)?(t.consume(B),M):R(B)}function R(B){return B===61?(t.consume(B),z):Et(B)?(i=R,H(B)):en(B)?(t.consume(B),R):_(B)}function z(B){return B===null||B===60||B===61||B===62||B===96?n(B):B===34||B===39?(t.consume(B),a=B,$):Et(B)?(i=z,H(B)):en(B)?(t.consume(B),z):(t.consume(B),W)}function $(B){return B===a?(t.consume(B),a=void 0,L):B===null?n(B):Et(B)?(i=$,H(B)):(t.consume(B),$)}function W(B){return B===null||B===34||B===39||B===60||B===61||B===96?n(B):B===47||B===62||_n(B)?_(B):(t.consume(B),W)}function L(B){return B===47||B===62||_n(B)?_(B):n(B)}function F(B){return B===62?(t.consume(B),t.exit("htmlTextData"),t.exit("htmlText"),e):n(B)}function H(B){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(B),t.exit("lineEnding"),V}function V(B){return en(B)?un(t,G,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(B):G(B)}function G(B){return t.enter("htmlTextData"),i(B)}}const sy={name:"labelEnd",resolveAll:HP,resolveTo:WP,tokenize:qP},zP={tokenize:VP},$P={tokenize:YP},UP={tokenize:GP};function HP(t){let e=-1;const n=[];for(;++e<t.length;){const s=t[e][1];if(n.push(t[e]),s.type==="labelImage"||s.type==="labelLink"||s.type==="labelEnd"){const a=s.type==="labelImage"?4:2;s.type="data",e+=a}}return t.length!==n.length&&ua(t,0,t.length,n),t}function WP(t,e){let n=t.length,s=0,a,r,i,c;for(;n--;)if(a=t[n][1],r){if(a.type==="link"||a.type==="labelLink"&&a._inactive)break;t[n][0]==="enter"&&a.type==="labelLink"&&(a._inactive=!0)}else if(i){if(t[n][0]==="enter"&&(a.type==="labelImage"||a.type==="labelLink")&&!a._balanced&&(r=n,a.type!=="labelLink")){s=2;break}}else a.type==="labelEnd"&&(i=n);const d={type:t[r][1].type==="labelLink"?"link":"image",start:{...t[r][1].start},end:{...t[t.length-1][1].end}},f={type:"label",start:{...t[r][1].start},end:{...t[i][1].end}},h={type:"labelText",start:{...t[r+s+2][1].end},end:{...t[i-2][1].start}};return c=[["enter",d,e],["enter",f,e]],c=Aa(c,t.slice(r+1,r+s+3)),c=Aa(c,[["enter",h,e]]),c=Aa(c,Zp(e.parser.constructs.insideSpan.null,t.slice(r+s+4,i-3),e)),c=Aa(c,[["exit",h,e],t[i-2],t[i-1],["exit",f,e]]),c=Aa(c,t.slice(i+1)),c=Aa(c,[["exit",d,e]]),ua(t,r,t.length,c),t}function qP(t,e,n){const s=this;let a=s.events.length,r,i;for(;a--;)if((s.events[a][1].type==="labelImage"||s.events[a][1].type==="labelLink")&&!s.events[a][1]._balanced){r=s.events[a][1];break}return c;function c(b){return r?r._inactive?m(b):(i=s.parser.defined.includes(Ia(s.sliceSerialize({start:r.end,end:s.now()}))),t.enter("labelEnd"),t.enter("labelMarker"),t.consume(b),t.exit("labelMarker"),t.exit("labelEnd"),d):n(b)}function d(b){return b===40?t.attempt(zP,h,i?h:m)(b):b===91?t.attempt($P,h,i?f:m)(b):i?h(b):m(b)}function f(b){return t.attempt(UP,h,m)(b)}function h(b){return e(b)}function m(b){return r._balanced=!0,n(b)}}function VP(t,e,n){return s;function s(m){return t.enter("resource"),t.enter("resourceMarker"),t.consume(m),t.exit("resourceMarker"),a}function a(m){return _n(m)?Ru(t,r)(m):r(m)}function r(m){return m===41?h(m):U1(t,i,c,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(m)}function i(m){return _n(m)?Ru(t,d)(m):h(m)}function c(m){return n(m)}function d(m){return m===34||m===39||m===40?W1(t,f,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(m):h(m)}function f(m){return _n(m)?Ru(t,h)(m):h(m)}function h(m){return m===41?(t.enter("resourceMarker"),t.consume(m),t.exit("resourceMarker"),t.exit("resource"),e):n(m)}}function YP(t,e,n){const s=this;return a;function a(c){return H1.call(s,t,r,i,"reference","referenceMarker","referenceString")(c)}function r(c){return s.parser.defined.includes(Ia(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)))?e(c):n(c)}function i(c){return n(c)}}function GP(t,e,n){return s;function s(r){return t.enter("reference"),t.enter("referenceMarker"),t.consume(r),t.exit("referenceMarker"),a}function a(r){return r===93?(t.enter("referenceMarker"),t.consume(r),t.exit("referenceMarker"),t.exit("reference"),e):n(r)}}const KP={name:"labelStartImage",resolveAll:sy.resolveAll,tokenize:QP};function QP(t,e,n){const s=this;return a;function a(c){return t.enter("labelImage"),t.enter("labelImageMarker"),t.consume(c),t.exit("labelImageMarker"),r}function r(c){return c===91?(t.enter("labelMarker"),t.consume(c),t.exit("labelMarker"),t.exit("labelImage"),i):n(c)}function i(c){return c===94&&"_hiddenFootnoteSupport"in s.parser.constructs?n(c):e(c)}}const XP={name:"labelStartLink",resolveAll:sy.resolveAll,tokenize:JP};function JP(t,e,n){const s=this;return a;function a(i){return t.enter("labelLink"),t.enter("labelMarker"),t.consume(i),t.exit("labelMarker"),t.exit("labelLink"),r}function r(i){return i===94&&"_hiddenFootnoteSupport"in s.parser.constructs?n(i):e(i)}}const Jg={name:"lineEnding",tokenize:ZP};function ZP(t,e){return n;function n(s){return t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),un(t,e,"linePrefix")}}const tp={name:"thematicBreak",tokenize:eB};function eB(t,e,n){let s=0,a;return r;function r(f){return t.enter("thematicBreak"),i(f)}function i(f){return a=f,c(f)}function c(f){return f===a?(t.enter("thematicBreakSequence"),d(f)):s>=3&&(f===null||Et(f))?(t.exit("thematicBreak"),e(f)):n(f)}function d(f){return f===a?(t.consume(f),s++,d):(t.exit("thematicBreakSequence"),en(f)?un(t,c,"whitespace")(f):c(f))}}const Vs={continuation:{tokenize:aB},exit:iB,name:"list",tokenize:sB},tB={partial:!0,tokenize:oB},nB={partial:!0,tokenize:rB};function sB(t,e,n){const s=this,a=s.events[s.events.length-1];let r=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,i=0;return c;function c(y){const w=s.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!s.containerState.marker||y===s.containerState.marker:cx(y)){if(s.containerState.type||(s.containerState.type=w,t.enter(w,{_container:!0})),w==="listUnordered")return t.enter("listItemPrefix"),y===42||y===45?t.check(tp,n,f)(y):f(y);if(!s.interrupt||y===49)return t.enter("listItemPrefix"),t.enter("listItemValue"),d(y)}return n(y)}function d(y){return cx(y)&&++i<10?(t.consume(y),d):(!s.interrupt||i<2)&&(s.containerState.marker?y===s.containerState.marker:y===41||y===46)?(t.exit("listItemValue"),f(y)):n(y)}function f(y){return t.enter("listItemMarker"),t.consume(y),t.exit("listItemMarker"),s.containerState.marker=s.containerState.marker||y,t.check(nd,s.interrupt?n:h,t.attempt(tB,b,m))}function h(y){return s.containerState.initialBlankLine=!0,r++,b(y)}function m(y){return en(y)?(t.enter("listItemPrefixWhitespace"),t.consume(y),t.exit("listItemPrefixWhitespace"),b):n(y)}function b(y){return s.containerState.size=r+s.sliceSerialize(t.exit("listItemPrefix"),!0).length,e(y)}}function aB(t,e,n){const s=this;return s.containerState._closeFlow=void 0,t.check(nd,a,r);function a(c){return s.containerState.furtherBlankLines=s.containerState.furtherBlankLines||s.containerState.initialBlankLine,un(t,e,"listItemIndent",s.containerState.size+1)(c)}function r(c){return s.containerState.furtherBlankLines||!en(c)?(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,i(c)):(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,t.attempt(nB,e,i)(c))}function i(c){return s.containerState._closeFlow=!0,s.interrupt=void 0,un(t,t.attempt(Vs,e,n),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c)}}function rB(t,e,n){const s=this;return un(t,a,"listItemIndent",s.containerState.size+1);function a(r){const i=s.events[s.events.length-1];return i&&i[1].type==="listItemIndent"&&i[2].sliceSerialize(i[1],!0).length===s.containerState.size?e(r):n(r)}}function iB(t){t.exit(this.containerState.type)}function oB(t,e,n){const s=this;return un(t,a,"listItemPrefixWhitespace",s.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(r){const i=s.events[s.events.length-1];return!en(r)&&i&&i[1].type==="listItemPrefixWhitespace"?e(r):n(r)}}const KS={name:"setextUnderline",resolveTo:lB,tokenize:cB};function lB(t,e){let n=t.length,s,a,r;for(;n--;)if(t[n][0]==="enter"){if(t[n][1].type==="content"){s=n;break}t[n][1].type==="paragraph"&&(a=n)}else t[n][1].type==="content"&&t.splice(n,1),!r&&t[n][1].type==="definition"&&(r=n);const i={type:"setextHeading",start:{...t[s][1].start},end:{...t[t.length-1][1].end}};return t[a][1].type="setextHeadingText",r?(t.splice(a,0,["enter",i,e]),t.splice(r+1,0,["exit",t[s][1],e]),t[s][1].end={...t[r][1].end}):t[s][1]=i,t.push(["exit",i,e]),t}function cB(t,e,n){const s=this;let a;return r;function r(f){let h=s.events.length,m;for(;h--;)if(s.events[h][1].type!=="lineEnding"&&s.events[h][1].type!=="linePrefix"&&s.events[h][1].type!=="content"){m=s.events[h][1].type==="paragraph";break}return!s.parser.lazy[s.now().line]&&(s.interrupt||m)?(t.enter("setextHeadingLine"),a=f,i(f)):n(f)}function i(f){return t.enter("setextHeadingLineSequence"),c(f)}function c(f){return f===a?(t.consume(f),c):(t.exit("setextHeadingLineSequence"),en(f)?un(t,d,"lineSuffix")(f):d(f))}function d(f){return f===null||Et(f)?(t.exit("setextHeadingLine"),e(f)):n(f)}}const uB={tokenize:dB};function dB(t){const e=this,n=t.attempt(nd,s,t.attempt(this.parser.constructs.flowInitial,a,un(t,t.attempt(this.parser.constructs.flow,a,t.attempt(gP,a)),"linePrefix")));return n;function s(r){if(r===null){t.consume(r);return}return t.enter("lineEndingBlank"),t.consume(r),t.exit("lineEndingBlank"),e.currentConstruct=void 0,n}function a(r){if(r===null){t.consume(r);return}return t.enter("lineEnding"),t.consume(r),t.exit("lineEnding"),e.currentConstruct=void 0,n}}const fB={resolveAll:V1()},pB=q1("string"),hB=q1("text");function q1(t){return{resolveAll:V1(t==="text"?mB:void 0),tokenize:e};function e(n){const s=this,a=this.parser.constructs[t],r=n.attempt(a,i,c);return i;function i(h){return f(h)?r(h):c(h)}function c(h){if(h===null){n.consume(h);return}return n.enter("data"),n.consume(h),d}function d(h){return f(h)?(n.exit("data"),r(h)):(n.consume(h),d)}function f(h){if(h===null)return!0;const m=a[h];let b=-1;if(m)for(;++b<m.length;){const y=m[b];if(!y.previous||y.previous.call(s,s.previous))return!0}return!1}}}function V1(t){return e;function e(n,s){let a=-1,r;for(;++a<=n.length;)r===void 0?n[a]&&n[a][1].type==="data"&&(r=a,a++):(!n[a]||n[a][1].type!=="data")&&(a!==r+2&&(n[r][1].end=n[a-1][1].end,n.splice(r+2,a-r-2),a=r+2),r=void 0);return t?t(n,s):n}}function mB(t,e){let n=0;for(;++n<=t.length;)if((n===t.length||t[n][1].type==="lineEnding")&&t[n-1][1].type==="data"){const s=t[n-1][1],a=e.sliceStream(s);let r=a.length,i=-1,c=0,d;for(;r--;){const f=a[r];if(typeof f=="string"){for(i=f.length;f.charCodeAt(i-1)===32;)c++,i--;if(i)break;i=-1}else if(f===-2)d=!0,c++;else if(f!==-1){r++;break}}if(e._contentTypeTextTrailing&&n===t.length&&(c=0),c){const f={type:n===t.length||d||c<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:r?i:s.start._bufferIndex+i,_index:s.start._index+r,line:s.end.line,column:s.end.column-c,offset:s.end.offset-c},end:{...s.end}};s.end={...f.start},s.start.offset===s.end.offset?Object.assign(s,f):(t.splice(n,0,["enter",f,e],["exit",f,e]),n+=2)}n++}return t}const gB={42:Vs,43:Vs,45:Vs,48:Vs,49:Vs,50:Vs,51:Vs,52:Vs,53:Vs,54:Vs,55:Vs,56:Vs,57:Vs,62:B1},bB={91:wP},xB={[-2]:Xg,[-1]:Xg,32:Xg},yB={35:NP,42:tp,45:[KS,tp],60:MP,61:KS,95:tp,96:YS,126:YS},vB={38:z1,92:F1},wB={[-5]:Jg,[-4]:Jg,[-3]:Jg,33:KP,38:z1,42:ux,60:[XI,BP],91:XP,92:[AP,F1],93:sy,95:ux,96:uP},kB={null:[ux,fB]},SB={null:[42,95]},CB={null:[]},AB=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:SB,contentInitial:bB,disable:CB,document:gB,flow:yB,flowInitial:xB,insideSpan:kB,string:vB,text:wB},Symbol.toStringTag,{value:"Module"}));function jB(t,e,n){let s={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const a={},r=[];let i=[],c=[];const d={attempt:I(D),check:I(E),consume:j,enter:S,exit:T,interrupt:I(E,{interrupt:!0})},f={code:null,containerState:{},defineSkip:C,events:[],now:w,parser:t,previous:null,sliceSerialize:b,sliceStream:y,write:m};let h=e.tokenize.call(f,d);return e.resolveAll&&r.push(e),f;function m(R){return i=Aa(i,R),N(),i[i.length-1]!==null?[]:(O(e,0),f.events=Zp(r,f.events,f),f.events)}function b(R,z){return TB(y(R),z)}function y(R){return NB(i,R)}function w(){const{_bufferIndex:R,_index:z,line:$,column:W,offset:L}=s;return{_bufferIndex:R,_index:z,line:$,column:W,offset:L}}function C(R){a[R.line]=R.column,M()}function N(){let R;for(;s._index<i.length;){const z=i[s._index];if(typeof z=="string")for(R=s._index,s._bufferIndex<0&&(s._bufferIndex=0);s._index===R&&s._bufferIndex<z.length;)k(z.charCodeAt(s._bufferIndex));else k(z)}}function k(R){h=h(R)}function j(R){Et(R)?(s.line++,s.column=1,s.offset+=R===-3?2:1,M()):R!==-1&&(s.column++,s.offset++),s._bufferIndex<0?s._index++:(s._bufferIndex++,s._bufferIndex===i[s._index].length&&(s._bufferIndex=-1,s._index++)),f.previous=R}function S(R,z){const $=z||{};return $.type=R,$.start=w(),f.events.push(["enter",$,f]),c.push($),$}function T(R){const z=c.pop();return z.end=w(),f.events.push(["exit",z,f]),z}function D(R,z){O(R,z.from)}function E(R,z){z.restore()}function I(R,z){return $;function $(W,L,F){let H,V,G,B;return Array.isArray(W)?se(W):"tokenize"in W?se([W]):K(W);function K(Z){return ie;function ie(me){const Ee=me!==null&&Z[me],Te=me!==null&&Z.null,Ve=[...Array.isArray(Ee)?Ee:Ee?[Ee]:[],...Array.isArray(Te)?Te:Te?[Te]:[]];return se(Ve)(me)}}function se(Z){return H=Z,V=0,Z.length===0?F:q(Z[V])}function q(Z){return ie;function ie(me){return B=_(),G=Z,Z.partial||(f.currentConstruct=Z),Z.name&&f.parser.constructs.disable.null.includes(Z.name)?Ce():Z.tokenize.call(z?Object.assign(Object.create(f),z):f,d,be,Ce)(me)}}function be(Z){return R(G,B),L}function Ce(Z){return B.restore(),++V<H.length?q(H[V]):F}}}function O(R,z){R.resolveAll&&!r.includes(R)&&r.push(R),R.resolve&&ua(f.events,z,f.events.length-z,R.resolve(f.events.slice(z),f)),R.resolveTo&&(f.events=R.resolveTo(f.events,f))}function _(){const R=w(),z=f.previous,$=f.currentConstruct,W=f.events.length,L=Array.from(c);return{from:W,restore:F};function F(){s=R,f.previous=z,f.currentConstruct=$,f.events.length=W,c=L,M()}}function M(){s.line in a&&s.column<2&&(s.column=a[s.line],s.offset+=a[s.line]-1)}}function NB(t,e){const n=e.start._index,s=e.start._bufferIndex,a=e.end._index,r=e.end._bufferIndex;let i;if(n===a)i=[t[n].slice(s,r)];else{if(i=t.slice(n,a),s>-1){const c=i[0];typeof c=="string"?i[0]=c.slice(s):i.shift()}r>0&&i.push(t[a].slice(0,r))}return i}function TB(t,e){let n=-1;const s=[];let a;for(;++n<t.length;){const r=t[n];let i;if(typeof r=="string")i=r;else switch(r){case-5:{i="\r";break}case-4:{i=`
49
- `;break}case-3:{i=`\r
50
- `;break}case-2:{i=e?" ":" ";break}case-1:{if(!e&&a)continue;i=" ";break}default:i=String.fromCharCode(r)}a=r===-2,s.push(i)}return s.join("")}function _B(t){const s={constructs:I1([AB,...(t||{}).extensions||[]]),content:a(WI),defined:[],document:a(VI),flow:a(uB),lazy:{},string:a(pB),text:a(hB)};return s;function a(r){return i;function i(c){return jB(s,r,c)}}}function EB(t){for(;!$1(t););return t}const QS=/[\0\t\n\r]/g;function MB(){let t=1,e="",n=!0,s;return a;function a(r,i,c){const d=[];let f,h,m,b,y;for(r=e+(typeof r=="string"?r.toString():new TextDecoder(i||void 0).decode(r)),m=0,e="",n&&(r.charCodeAt(0)===65279&&m++,n=void 0);m<r.length;){if(QS.lastIndex=m,f=QS.exec(r),b=f&&f.index!==void 0?f.index:r.length,y=r.charCodeAt(b),!f){e=r.slice(m);break}if(y===10&&m===b&&s)d.push(-3),s=void 0;else switch(s&&(d.push(-5),s=void 0),m<b&&(d.push(r.slice(m,b)),t+=b-m),y){case 0:{d.push(65533),t++;break}case 9:{for(h=Math.ceil(t/4)*4,d.push(-2);t++<h;)d.push(-1);break}case 10:{d.push(-4),t=1;break}default:s=!0,t=1}m=b+1}return c&&(s&&d.push(-5),e&&d.push(e),d.push(null)),d}}const DB=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function RB(t){return t.replace(DB,OB)}function OB(t,e,n){if(e)return e;if(n.charCodeAt(0)===35){const a=n.charCodeAt(1),r=a===120||a===88;return P1(n.slice(r?2:1),r?16:10)}return ny(n)||t}const Y1={}.hasOwnProperty;function LB(t,e,n){return e&&typeof e=="object"&&(n=e,e=void 0),IB(n)(EB(_B(n).document().write(MB()(t,e,!0))))}function IB(t){const e={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:r(Be),autolinkProtocol:_,autolinkEmail:_,atxHeading:r(Ne),blockQuote:r(Te),characterEscape:_,characterReference:_,codeFenced:r(Ve),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:r(Ve,i),codeText:r(We,i),codeTextData:_,data:_,codeFlowValue:_,definition:r(ee),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:r(ne),hardBreakEscape:r(ze),hardBreakTrailing:r(ze),htmlFlow:r(st,i),htmlFlowData:_,htmlText:r(st,i),htmlTextData:_,image:r(pe),label:i,link:r(Be),listItem:r(de),listItemValue:b,listOrdered:r(oe,m),listUnordered:r(oe),paragraph:r(He),reference:q,referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:r(Ne),strong:r(et),thematicBreak:r(fe)},exit:{atxHeading:d(),atxHeadingSequence:D,autolink:d(),autolinkEmail:Ee,autolinkProtocol:me,blockQuote:d(),characterEscapeValue:M,characterReferenceMarkerHexadecimal:Ce,characterReferenceMarkerNumeric:Ce,characterReferenceValue:Z,characterReference:ie,codeFenced:d(N),codeFencedFence:C,codeFencedFenceInfo:y,codeFencedFenceMeta:w,codeFlowValue:M,codeIndented:d(k),codeText:d(L),codeTextData:M,data:M,definition:d(),definitionDestinationString:T,definitionLabelString:j,definitionTitleString:S,emphasis:d(),hardBreakEscape:d(z),hardBreakTrailing:d(z),htmlFlow:d($),htmlFlowData:M,htmlText:d(W),htmlTextData:M,image:d(H),label:G,labelText:V,lineEnding:R,link:d(F),listItem:d(),listOrdered:d(),listUnordered:d(),paragraph:d(),referenceString:be,resourceDestinationString:B,resourceTitleString:K,resource:se,setextHeading:d(O),setextHeadingLineSequence:I,setextHeadingText:E,strong:d(),thematicBreak:d()}};G1(e,(t||{}).mdastExtensions||[]);const n={};return s;function s(X){let ae={type:"root",children:[]};const ke={stack:[ae],tokenStack:[],config:e,enter:c,exit:f,buffer:i,resume:h,data:n},J=[];let he=-1;for(;++he<X.length;)if(X[he][1].type==="listOrdered"||X[he][1].type==="listUnordered")if(X[he][0]==="enter")J.push(he);else{const Oe=J.pop();he=a(X,Oe,he)}for(he=-1;++he<X.length;){const Oe=e[X[he][0]];Y1.call(Oe,X[he][1].type)&&Oe[X[he][1].type].call(Object.assign({sliceSerialize:X[he][2].sliceSerialize},ke),X[he][1])}if(ke.tokenStack.length>0){const Oe=ke.tokenStack[ke.tokenStack.length-1];(Oe[1]||XS).call(ke,void 0,Oe[0])}for(ae.position={start:Ai(X.length>0?X[0][1].start:{line:1,column:1,offset:0}),end:Ai(X.length>0?X[X.length-2][1].end:{line:1,column:1,offset:0})},he=-1;++he<e.transforms.length;)ae=e.transforms[he](ae)||ae;return ae}function a(X,ae,ke){let J=ae-1,he=-1,Oe=!1,$e,xe,Pe,te;for(;++J<=ke;){const ge=X[J];switch(ge[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ge[0]==="enter"?he++:he--,te=void 0;break}case"lineEndingBlank":{ge[0]==="enter"&&($e&&!te&&!he&&!Pe&&(Pe=J),te=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:te=void 0}if(!he&&ge[0]==="enter"&&ge[1].type==="listItemPrefix"||he===-1&&ge[0]==="exit"&&(ge[1].type==="listUnordered"||ge[1].type==="listOrdered")){if($e){let ve=J;for(xe=void 0;ve--;){const Fe=X[ve];if(Fe[1].type==="lineEnding"||Fe[1].type==="lineEndingBlank"){if(Fe[0]==="exit")continue;xe&&(X[xe][1].type="lineEndingBlank",Oe=!0),Fe[1].type="lineEnding",xe=ve}else if(!(Fe[1].type==="linePrefix"||Fe[1].type==="blockQuotePrefix"||Fe[1].type==="blockQuotePrefixWhitespace"||Fe[1].type==="blockQuoteMarker"||Fe[1].type==="listItemIndent"))break}Pe&&(!xe||Pe<xe)&&($e._spread=!0),$e.end=Object.assign({},xe?X[xe][1].start:ge[1].end),X.splice(xe||J,0,["exit",$e,ge[2]]),J++,ke++}if(ge[1].type==="listItemPrefix"){const ve={type:"listItem",_spread:!1,start:Object.assign({},ge[1].start),end:void 0};$e=ve,X.splice(J,0,["enter",ve,ge[2]]),J++,ke++,Pe=void 0,te=!0}}}return X[ae][1]._spread=Oe,ke}function r(X,ae){return ke;function ke(J){c.call(this,X(J),J),ae&&ae.call(this,J)}}function i(){this.stack.push({type:"fragment",children:[]})}function c(X,ae,ke){this.stack[this.stack.length-1].children.push(X),this.stack.push(X),this.tokenStack.push([ae,ke||void 0]),X.position={start:Ai(ae.start),end:void 0}}function d(X){return ae;function ae(ke){X&&X.call(this,ke),f.call(this,ke)}}function f(X,ae){const ke=this.stack.pop(),J=this.tokenStack.pop();if(J)J[0].type!==X.type&&(ae?ae.call(this,X,J[0]):(J[1]||XS).call(this,X,J[0]));else throw new Error("Cannot close `"+X.type+"` ("+Du({start:X.start,end:X.end})+"): it’s not open");ke.position.end=Ai(X.end)}function h(){return ty(this.stack.pop())}function m(){this.data.expectingFirstListItemValue=!0}function b(X){if(this.data.expectingFirstListItemValue){const ae=this.stack[this.stack.length-2];ae.start=Number.parseInt(this.sliceSerialize(X),10),this.data.expectingFirstListItemValue=void 0}}function y(){const X=this.resume(),ae=this.stack[this.stack.length-1];ae.lang=X}function w(){const X=this.resume(),ae=this.stack[this.stack.length-1];ae.meta=X}function C(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function N(){const X=this.resume(),ae=this.stack[this.stack.length-1];ae.value=X.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function k(){const X=this.resume(),ae=this.stack[this.stack.length-1];ae.value=X.replace(/(\r?\n|\r)$/g,"")}function j(X){const ae=this.resume(),ke=this.stack[this.stack.length-1];ke.label=ae,ke.identifier=Ia(this.sliceSerialize(X)).toLowerCase()}function S(){const X=this.resume(),ae=this.stack[this.stack.length-1];ae.title=X}function T(){const X=this.resume(),ae=this.stack[this.stack.length-1];ae.url=X}function D(X){const ae=this.stack[this.stack.length-1];if(!ae.depth){const ke=this.sliceSerialize(X).length;ae.depth=ke}}function E(){this.data.setextHeadingSlurpLineEnding=!0}function I(X){const ae=this.stack[this.stack.length-1];ae.depth=this.sliceSerialize(X).codePointAt(0)===61?1:2}function O(){this.data.setextHeadingSlurpLineEnding=void 0}function _(X){const ke=this.stack[this.stack.length-1].children;let J=ke[ke.length-1];(!J||J.type!=="text")&&(J=ct(),J.position={start:Ai(X.start),end:void 0},ke.push(J)),this.stack.push(J)}function M(X){const ae=this.stack.pop();ae.value+=this.sliceSerialize(X),ae.position.end=Ai(X.end)}function R(X){const ae=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ke=ae.children[ae.children.length-1];ke.position.end=Ai(X.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&e.canContainEols.includes(ae.type)&&(_.call(this,X),M.call(this,X))}function z(){this.data.atHardBreak=!0}function $(){const X=this.resume(),ae=this.stack[this.stack.length-1];ae.value=X}function W(){const X=this.resume(),ae=this.stack[this.stack.length-1];ae.value=X}function L(){const X=this.resume(),ae=this.stack[this.stack.length-1];ae.value=X}function F(){const X=this.stack[this.stack.length-1];if(this.data.inReference){const ae=this.data.referenceType||"shortcut";X.type+="Reference",X.referenceType=ae,delete X.url,delete X.title}else delete X.identifier,delete X.label;this.data.referenceType=void 0}function H(){const X=this.stack[this.stack.length-1];if(this.data.inReference){const ae=this.data.referenceType||"shortcut";X.type+="Reference",X.referenceType=ae,delete X.url,delete X.title}else delete X.identifier,delete X.label;this.data.referenceType=void 0}function V(X){const ae=this.sliceSerialize(X),ke=this.stack[this.stack.length-2];ke.label=RB(ae),ke.identifier=Ia(ae).toLowerCase()}function G(){const X=this.stack[this.stack.length-1],ae=this.resume(),ke=this.stack[this.stack.length-1];if(this.data.inReference=!0,ke.type==="link"){const J=X.children;ke.children=J}else ke.alt=ae}function B(){const X=this.resume(),ae=this.stack[this.stack.length-1];ae.url=X}function K(){const X=this.resume(),ae=this.stack[this.stack.length-1];ae.title=X}function se(){this.data.inReference=void 0}function q(){this.data.referenceType="collapsed"}function be(X){const ae=this.resume(),ke=this.stack[this.stack.length-1];ke.label=ae,ke.identifier=Ia(this.sliceSerialize(X)).toLowerCase(),this.data.referenceType="full"}function Ce(X){this.data.characterReferenceType=X.type}function Z(X){const ae=this.sliceSerialize(X),ke=this.data.characterReferenceType;let J;ke?(J=P1(ae,ke==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):J=ny(ae);const he=this.stack[this.stack.length-1];he.value+=J}function ie(X){const ae=this.stack.pop();ae.position.end=Ai(X.end)}function me(X){M.call(this,X);const ae=this.stack[this.stack.length-1];ae.url=this.sliceSerialize(X)}function Ee(X){M.call(this,X);const ae=this.stack[this.stack.length-1];ae.url="mailto:"+this.sliceSerialize(X)}function Te(){return{type:"blockquote",children:[]}}function Ve(){return{type:"code",lang:null,meta:null,value:""}}function We(){return{type:"inlineCode",value:""}}function ee(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ne(){return{type:"emphasis",children:[]}}function Ne(){return{type:"heading",depth:0,children:[]}}function ze(){return{type:"break"}}function st(){return{type:"html",value:""}}function pe(){return{type:"image",title:null,url:"",alt:null}}function Be(){return{type:"link",title:null,url:"",children:[]}}function oe(X){return{type:"list",ordered:X.type==="listOrdered",start:null,spread:X._spread,children:[]}}function de(X){return{type:"listItem",spread:X._spread,checked:null,children:[]}}function He(){return{type:"paragraph",children:[]}}function et(){return{type:"strong",children:[]}}function ct(){return{type:"text",value:""}}function fe(){return{type:"thematicBreak"}}}function Ai(t){return{line:t.line,column:t.column,offset:t.offset}}function G1(t,e){let n=-1;for(;++n<e.length;){const s=e[n];Array.isArray(s)?G1(t,s):PB(t,s)}}function PB(t,e){let n;for(n in e)if(Y1.call(e,n))switch(n){case"canContainEols":{const s=e[n];s&&t[n].push(...s);break}case"transforms":{const s=e[n];s&&t[n].push(...s);break}case"enter":case"exit":{const s=e[n];s&&Object.assign(t[n],s);break}}}function XS(t,e){throw t?new Error("Cannot close `"+t.type+"` ("+Du({start:t.start,end:t.end})+"): a different token (`"+e.type+"`, "+Du({start:e.start,end:e.end})+") is open"):new Error("Cannot close document, a token (`"+e.type+"`, "+Du({start:e.start,end:e.end})+") is still open")}function BB(t){const e=this;e.parser=n;function n(s){return LB(s,{...e.data("settings"),...t,extensions:e.data("micromarkExtensions")||[],mdastExtensions:e.data("fromMarkdownExtensions")||[]})}}function FB(t,e){const n={type:"element",tagName:"blockquote",properties:{},children:t.wrap(t.all(e),!0)};return t.patch(e,n),t.applyData(e,n)}function zB(t,e){const n={type:"element",tagName:"br",properties:{},children:[]};return t.patch(e,n),[t.applyData(e,n),{type:"text",value:`
51
- `}]}function $B(t,e){const n=e.value?e.value+`
52
- `:"",s={},a=e.lang?e.lang.split(/\s+/):[];a.length>0&&(s.className=["language-"+a[0]]);let r={type:"element",tagName:"code",properties:s,children:[{type:"text",value:n}]};return e.meta&&(r.data={meta:e.meta}),t.patch(e,r),r=t.applyData(e,r),r={type:"element",tagName:"pre",properties:{},children:[r]},t.patch(e,r),r}function UB(t,e){const n={type:"element",tagName:"del",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function HB(t,e){const n={type:"element",tagName:"em",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function WB(t,e){const n=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",s=String(e.identifier).toUpperCase(),a=ic(s.toLowerCase()),r=t.footnoteOrder.indexOf(s);let i,c=t.footnoteCounts.get(s);c===void 0?(c=0,t.footnoteOrder.push(s),i=t.footnoteOrder.length):i=r+1,c+=1,t.footnoteCounts.set(s,c);const d={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+a,id:n+"fnref-"+a+(c>1?"-"+c:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(i)}]};t.patch(e,d);const f={type:"element",tagName:"sup",properties:{},children:[d]};return t.patch(e,f),t.applyData(e,f)}function qB(t,e){const n={type:"element",tagName:"h"+e.depth,properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function VB(t,e){if(t.options.allowDangerousHtml){const n={type:"raw",value:e.value};return t.patch(e,n),t.applyData(e,n)}}function K1(t,e){const n=e.referenceType;let s="]";if(n==="collapsed"?s+="[]":n==="full"&&(s+="["+(e.label||e.identifier)+"]"),e.type==="imageReference")return[{type:"text",value:"!["+e.alt+s}];const a=t.all(e),r=a[0];r&&r.type==="text"?r.value="["+r.value:a.unshift({type:"text",value:"["});const i=a[a.length-1];return i&&i.type==="text"?i.value+=s:a.push({type:"text",value:s}),a}function YB(t,e){const n=String(e.identifier).toUpperCase(),s=t.definitionById.get(n);if(!s)return K1(t,e);const a={src:ic(s.url||""),alt:e.alt};s.title!==null&&s.title!==void 0&&(a.title=s.title);const r={type:"element",tagName:"img",properties:a,children:[]};return t.patch(e,r),t.applyData(e,r)}function GB(t,e){const n={src:ic(e.url)};e.alt!==null&&e.alt!==void 0&&(n.alt=e.alt),e.title!==null&&e.title!==void 0&&(n.title=e.title);const s={type:"element",tagName:"img",properties:n,children:[]};return t.patch(e,s),t.applyData(e,s)}function KB(t,e){const n={type:"text",value:e.value.replace(/\r?\n|\r/g," ")};t.patch(e,n);const s={type:"element",tagName:"code",properties:{},children:[n]};return t.patch(e,s),t.applyData(e,s)}function QB(t,e){const n=String(e.identifier).toUpperCase(),s=t.definitionById.get(n);if(!s)return K1(t,e);const a={href:ic(s.url||"")};s.title!==null&&s.title!==void 0&&(a.title=s.title);const r={type:"element",tagName:"a",properties:a,children:t.all(e)};return t.patch(e,r),t.applyData(e,r)}function XB(t,e){const n={href:ic(e.url)};e.title!==null&&e.title!==void 0&&(n.title=e.title);const s={type:"element",tagName:"a",properties:n,children:t.all(e)};return t.patch(e,s),t.applyData(e,s)}function JB(t,e,n){const s=t.all(e),a=n?ZB(n):Q1(e),r={},i=[];if(typeof e.checked=="boolean"){const h=s[0];let m;h&&h.type==="element"&&h.tagName==="p"?m=h:(m={type:"element",tagName:"p",properties:{},children:[]},s.unshift(m)),m.children.length>0&&m.children.unshift({type:"text",value:" "}),m.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:e.checked,disabled:!0},children:[]}),r.className=["task-list-item"]}let c=-1;for(;++c<s.length;){const h=s[c];(a||c!==0||h.type!=="element"||h.tagName!=="p")&&i.push({type:"text",value:`
53
- `}),h.type==="element"&&h.tagName==="p"&&!a?i.push(...h.children):i.push(h)}const d=s[s.length-1];d&&(a||d.type!=="element"||d.tagName!=="p")&&i.push({type:"text",value:`
54
- `});const f={type:"element",tagName:"li",properties:r,children:i};return t.patch(e,f),t.applyData(e,f)}function ZB(t){let e=!1;if(t.type==="list"){e=t.spread||!1;const n=t.children;let s=-1;for(;!e&&++s<n.length;)e=Q1(n[s])}return e}function Q1(t){const e=t.spread;return e??t.children.length>1}function eF(t,e){const n={},s=t.all(e);let a=-1;for(typeof e.start=="number"&&e.start!==1&&(n.start=e.start);++a<s.length;){const i=s[a];if(i.type==="element"&&i.tagName==="li"&&i.properties&&Array.isArray(i.properties.className)&&i.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const r={type:"element",tagName:e.ordered?"ol":"ul",properties:n,children:t.wrap(s,!0)};return t.patch(e,r),t.applyData(e,r)}function tF(t,e){const n={type:"element",tagName:"p",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function nF(t,e){const n={type:"root",children:t.wrap(t.all(e))};return t.patch(e,n),t.applyData(e,n)}function sF(t,e){const n={type:"element",tagName:"strong",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function aF(t,e){const n=t.all(e),s=n.shift(),a=[];if(s){const i={type:"element",tagName:"thead",properties:{},children:t.wrap([s],!0)};t.patch(e.children[0],i),a.push(i)}if(n.length>0){const i={type:"element",tagName:"tbody",properties:{},children:t.wrap(n,!0)},c=Xx(e.children[1]),d=_1(e.children[e.children.length-1]);c&&d&&(i.position={start:c,end:d}),a.push(i)}const r={type:"element",tagName:"table",properties:{},children:t.wrap(a,!0)};return t.patch(e,r),t.applyData(e,r)}function rF(t,e,n){const s=n?n.children:void 0,r=(s?s.indexOf(e):1)===0?"th":"td",i=n&&n.type==="table"?n.align:void 0,c=i?i.length:e.children.length;let d=-1;const f=[];for(;++d<c;){const m=e.children[d],b={},y=i?i[d]:void 0;y&&(b.align=y);let w={type:"element",tagName:r,properties:b,children:[]};m&&(w.children=t.all(m),t.patch(m,w),w=t.applyData(m,w)),f.push(w)}const h={type:"element",tagName:"tr",properties:{},children:t.wrap(f,!0)};return t.patch(e,h),t.applyData(e,h)}function iF(t,e){const n={type:"element",tagName:"td",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}const JS=9,ZS=32;function oF(t){const e=String(t),n=/\r?\n|\r/g;let s=n.exec(e),a=0;const r=[];for(;s;)r.push(eC(e.slice(a,s.index),a>0,!0),s[0]),a=s.index+s[0].length,s=n.exec(e);return r.push(eC(e.slice(a),a>0,!1)),r.join("")}function eC(t,e,n){let s=0,a=t.length;if(e){let r=t.codePointAt(s);for(;r===JS||r===ZS;)s++,r=t.codePointAt(s)}if(n){let r=t.codePointAt(a-1);for(;r===JS||r===ZS;)a--,r=t.codePointAt(a-1)}return a>s?t.slice(s,a):""}function lF(t,e){const n={type:"text",value:oF(String(e.value))};return t.patch(e,n),t.applyData(e,n)}function cF(t,e){const n={type:"element",tagName:"hr",properties:{},children:[]};return t.patch(e,n),t.applyData(e,n)}const uF={blockquote:FB,break:zB,code:$B,delete:UB,emphasis:HB,footnoteReference:WB,heading:qB,html:VB,imageReference:YB,image:GB,inlineCode:KB,linkReference:QB,link:XB,listItem:JB,list:eF,paragraph:tF,root:nF,strong:sF,table:aF,tableCell:iF,tableRow:rF,text:lF,thematicBreak:cF,toml:Of,yaml:Of,definition:Of,footnoteDefinition:Of};function Of(){}const X1=-1,eh=0,Ou=1,Sp=2,ay=3,ry=4,iy=5,oy=6,J1=7,Z1=8,tC=typeof self=="object"?self:globalThis,dF=(t,e)=>{const n=(a,r)=>(t.set(r,a),a),s=a=>{if(t.has(a))return t.get(a);const[r,i]=e[a];switch(r){case eh:case X1:return n(i,a);case Ou:{const c=n([],a);for(const d of i)c.push(s(d));return c}case Sp:{const c=n({},a);for(const[d,f]of i)c[s(d)]=s(f);return c}case ay:return n(new Date(i),a);case ry:{const{source:c,flags:d}=i;return n(new RegExp(c,d),a)}case iy:{const c=n(new Map,a);for(const[d,f]of i)c.set(s(d),s(f));return c}case oy:{const c=n(new Set,a);for(const d of i)c.add(s(d));return c}case J1:{const{name:c,message:d}=i;return n(new tC[c](d),a)}case Z1:return n(BigInt(i),a);case"BigInt":return n(Object(BigInt(i)),a);case"ArrayBuffer":return n(new Uint8Array(i).buffer,i);case"DataView":{const{buffer:c}=new Uint8Array(i);return n(new DataView(c),i)}}return n(new tC[r](i),a)};return s},nC=t=>dF(new Map,t)(0),El="",{toString:fF}={},{keys:pF}=Object,fu=t=>{const e=typeof t;if(e!=="object"||!t)return[eh,e];const n=fF.call(t).slice(8,-1);switch(n){case"Array":return[Ou,El];case"Object":return[Sp,El];case"Date":return[ay,El];case"RegExp":return[ry,El];case"Map":return[iy,El];case"Set":return[oy,El];case"DataView":return[Ou,n]}return n.includes("Array")?[Ou,n]:n.includes("Error")?[J1,n]:[Sp,n]},Lf=([t,e])=>t===eh&&(e==="function"||e==="symbol"),hF=(t,e,n,s)=>{const a=(i,c)=>{const d=s.push(i)-1;return n.set(c,d),d},r=i=>{if(n.has(i))return n.get(i);let[c,d]=fu(i);switch(c){case eh:{let h=i;switch(d){case"bigint":c=Z1,h=i.toString();break;case"function":case"symbol":if(t)throw new TypeError("unable to serialize "+d);h=null;break;case"undefined":return a([X1],i)}return a([c,h],i)}case Ou:{if(d){let b=i;return d==="DataView"?b=new Uint8Array(i.buffer):d==="ArrayBuffer"&&(b=new Uint8Array(i)),a([d,[...b]],i)}const h=[],m=a([c,h],i);for(const b of i)h.push(r(b));return m}case Sp:{if(d)switch(d){case"BigInt":return a([d,i.toString()],i);case"Boolean":case"Number":case"String":return a([d,i.valueOf()],i)}if(e&&"toJSON"in i)return r(i.toJSON());const h=[],m=a([c,h],i);for(const b of pF(i))(t||!Lf(fu(i[b])))&&h.push([r(b),r(i[b])]);return m}case ay:return a([c,i.toISOString()],i);case ry:{const{source:h,flags:m}=i;return a([c,{source:h,flags:m}],i)}case iy:{const h=[],m=a([c,h],i);for(const[b,y]of i)(t||!(Lf(fu(b))||Lf(fu(y))))&&h.push([r(b),r(y)]);return m}case oy:{const h=[],m=a([c,h],i);for(const b of i)(t||!Lf(fu(b)))&&h.push(r(b));return m}}const{message:f}=i;return a([c,{name:d,message:f}],i)};return r},sC=(t,{json:e,lossy:n}={})=>{const s=[];return hF(!(e||n),!!e,new Map,s)(t),s},Cp=typeof structuredClone=="function"?(t,e)=>e&&("json"in e||"lossy"in e)?nC(sC(t,e)):structuredClone(t):(t,e)=>nC(sC(t,e));function mF(t,e){const n=[{type:"text",value:"↩"}];return e>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(e)}]}),n}function gF(t,e){return"Back to reference "+(t+1)+(e>1?"-"+e:"")}function bF(t){const e=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",n=t.options.footnoteBackContent||mF,s=t.options.footnoteBackLabel||gF,a=t.options.footnoteLabel||"Footnotes",r=t.options.footnoteLabelTagName||"h2",i=t.options.footnoteLabelProperties||{className:["sr-only"]},c=[];let d=-1;for(;++d<t.footnoteOrder.length;){const f=t.footnoteById.get(t.footnoteOrder[d]);if(!f)continue;const h=t.all(f),m=String(f.identifier).toUpperCase(),b=ic(m.toLowerCase());let y=0;const w=[],C=t.footnoteCounts.get(m);for(;C!==void 0&&++y<=C;){w.length>0&&w.push({type:"text",value:" "});let j=typeof n=="string"?n:n(d,y);typeof j=="string"&&(j={type:"text",value:j}),w.push({type:"element",tagName:"a",properties:{href:"#"+e+"fnref-"+b+(y>1?"-"+y:""),dataFootnoteBackref:"",ariaLabel:typeof s=="string"?s:s(d,y),className:["data-footnote-backref"]},children:Array.isArray(j)?j:[j]})}const N=h[h.length-1];if(N&&N.type==="element"&&N.tagName==="p"){const j=N.children[N.children.length-1];j&&j.type==="text"?j.value+=" ":N.children.push({type:"text",value:" "}),N.children.push(...w)}else h.push(...w);const k={type:"element",tagName:"li",properties:{id:e+"fn-"+b},children:t.wrap(h,!0)};t.patch(f,k),c.push(k)}if(c.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:r,properties:{...Cp(i),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:`
55
- `},{type:"element",tagName:"ol",properties:{},children:t.wrap(c,!0)},{type:"text",value:`
56
- `}]}}const th=(function(t){if(t==null)return wF;if(typeof t=="function")return nh(t);if(typeof t=="object")return Array.isArray(t)?xF(t):yF(t);if(typeof t=="string")return vF(t);throw new Error("Expected function, string, or object as test")});function xF(t){const e=[];let n=-1;for(;++n<t.length;)e[n]=th(t[n]);return nh(s);function s(...a){let r=-1;for(;++r<e.length;)if(e[r].apply(this,a))return!0;return!1}}function yF(t){const e=t;return nh(n);function n(s){const a=s;let r;for(r in t)if(a[r]!==e[r])return!1;return!0}}function vF(t){return nh(e);function e(n){return n&&n.type===t}}function nh(t){return e;function e(n,s,a){return!!(kF(n)&&t.call(this,n,typeof s=="number"?s:void 0,a||void 0))}}function wF(){return!0}function kF(t){return t!==null&&typeof t=="object"&&"type"in t}const eN=[],SF=!0,dx=!1,CF="skip";function tN(t,e,n,s){let a;typeof e=="function"&&typeof n!="function"?(s=n,n=e):a=e;const r=th(a),i=s?-1:1;c(t,void 0,[])();function c(d,f,h){const m=d&&typeof d=="object"?d:{};if(typeof m.type=="string"){const y=typeof m.tagName=="string"?m.tagName:typeof m.name=="string"?m.name:void 0;Object.defineProperty(b,"name",{value:"node ("+(d.type+(y?"<"+y+">":""))+")"})}return b;function b(){let y=eN,w,C,N;if((!e||r(d,f,h[h.length-1]||void 0))&&(y=AF(n(d,h)),y[0]===dx))return y;if("children"in d&&d.children){const k=d;if(k.children&&y[0]!==CF)for(C=(s?k.children.length:-1)+i,N=h.concat(k);C>-1&&C<k.children.length;){const j=k.children[C];if(w=c(j,C,N)(),w[0]===dx)return w;C=typeof w[1]=="number"?w[1]:C+i}}return y}}}function AF(t){return Array.isArray(t)?t:typeof t=="number"?[SF,t]:t==null?eN:[t]}function ly(t,e,n,s){let a,r,i;typeof e=="function"&&typeof n!="function"?(r=void 0,i=e,a=n):(r=e,i=n,a=s),tN(t,r,c,a);function c(d,f){const h=f[f.length-1],m=h?h.children.indexOf(d):void 0;return i(d,m,h)}}const fx={}.hasOwnProperty,jF={};function NF(t,e){const n=e||jF,s=new Map,a=new Map,r=new Map,i={...uF,...n.handlers},c={all:f,applyData:_F,definitionById:s,footnoteById:a,footnoteCounts:r,footnoteOrder:[],handlers:i,one:d,options:n,patch:TF,wrap:MF};return ly(t,function(h){if(h.type==="definition"||h.type==="footnoteDefinition"){const m=h.type==="definition"?s:a,b=String(h.identifier).toUpperCase();m.has(b)||m.set(b,h)}}),c;function d(h,m){const b=h.type,y=c.handlers[b];if(fx.call(c.handlers,b)&&y)return y(c,h,m);if(c.options.passThrough&&c.options.passThrough.includes(b)){if("children"in h){const{children:C,...N}=h,k=Cp(N);return k.children=c.all(h),k}return Cp(h)}return(c.options.unknownHandler||EF)(c,h,m)}function f(h){const m=[];if("children"in h){const b=h.children;let y=-1;for(;++y<b.length;){const w=c.one(b[y],h);if(w){if(y&&b[y-1].type==="break"&&(!Array.isArray(w)&&w.type==="text"&&(w.value=aC(w.value)),!Array.isArray(w)&&w.type==="element")){const C=w.children[0];C&&C.type==="text"&&(C.value=aC(C.value))}Array.isArray(w)?m.push(...w):m.push(w)}}}return m}}function TF(t,e){t.position&&(e.position=gI(t))}function _F(t,e){let n=e;if(t&&t.data){const s=t.data.hName,a=t.data.hChildren,r=t.data.hProperties;if(typeof s=="string")if(n.type==="element")n.tagName=s;else{const i="children"in n?n.children:[n];n={type:"element",tagName:s,properties:{},children:i}}n.type==="element"&&r&&Object.assign(n.properties,Cp(r)),"children"in n&&n.children&&a!==null&&a!==void 0&&(n.children=a)}return n}function EF(t,e){const n=e.data||{},s="value"in e&&!(fx.call(n,"hProperties")||fx.call(n,"hChildren"))?{type:"text",value:e.value}:{type:"element",tagName:"div",properties:{},children:t.all(e)};return t.patch(e,s),t.applyData(e,s)}function MF(t,e){const n=[];let s=-1;for(e&&n.push({type:"text",value:`
57
- `});++s<t.length;)s&&n.push({type:"text",value:`
58
- `}),n.push(t[s]);return e&&t.length>0&&n.push({type:"text",value:`
59
- `}),n}function aC(t){let e=0,n=t.charCodeAt(e);for(;n===9||n===32;)e++,n=t.charCodeAt(e);return t.slice(e)}function rC(t,e){const n=NF(t,e),s=n.one(t,void 0),a=bF(n),r=Array.isArray(s)?{type:"root",children:s}:s||{type:"root",children:[]};return a&&r.children.push({type:"text",value:`
60
- `},a),r}function DF(t,e){return t&&"run"in t?async function(n,s){const a=rC(n,{file:s,...e});await t.run(a,s)}:function(n,s){return rC(n,{file:s,...t||e})}}function iC(t){if(t)throw t}var Zg,oC;function RF(){if(oC)return Zg;oC=1;var t=Object.prototype.hasOwnProperty,e=Object.prototype.toString,n=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=function(f){return typeof Array.isArray=="function"?Array.isArray(f):e.call(f)==="[object Array]"},r=function(f){if(!f||e.call(f)!=="[object Object]")return!1;var h=t.call(f,"constructor"),m=f.constructor&&f.constructor.prototype&&t.call(f.constructor.prototype,"isPrototypeOf");if(f.constructor&&!h&&!m)return!1;var b;for(b in f);return typeof b>"u"||t.call(f,b)},i=function(f,h){n&&h.name==="__proto__"?n(f,h.name,{enumerable:!0,configurable:!0,value:h.newValue,writable:!0}):f[h.name]=h.newValue},c=function(f,h){if(h==="__proto__")if(t.call(f,h)){if(s)return s(f,h).value}else return;return f[h]};return Zg=function d(){var f,h,m,b,y,w,C=arguments[0],N=1,k=arguments.length,j=!1;for(typeof C=="boolean"&&(j=C,C=arguments[1]||{},N=2),(C==null||typeof C!="object"&&typeof C!="function")&&(C={});N<k;++N)if(f=arguments[N],f!=null)for(h in f)m=c(C,h),b=c(f,h),C!==b&&(j&&b&&(r(b)||(y=a(b)))?(y?(y=!1,w=m&&a(m)?m:[]):w=m&&r(m)?m:{},i(C,{name:h,newValue:d(j,w,b)})):typeof b<"u"&&i(C,{name:h,newValue:b}));return C},Zg}var OF=RF();const eb=Xu(OF);function px(t){if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)}function LF(){const t=[],e={run:n,use:s};return e;function n(...a){let r=-1;const i=a.pop();if(typeof i!="function")throw new TypeError("Expected function as last argument, not "+i);c(null,...a);function c(d,...f){const h=t[++r];let m=-1;if(d){i(d);return}for(;++m<a.length;)(f[m]===null||f[m]===void 0)&&(f[m]=a[m]);a=f,h?IF(h,c)(...f):i(null,...f)}}function s(a){if(typeof a!="function")throw new TypeError("Expected `middelware` to be a function, not "+a);return t.push(a),e}}function IF(t,e){let n;return s;function s(...i){const c=t.length>i.length;let d;c&&i.push(a);try{d=t.apply(this,i)}catch(f){const h=f;if(c&&n)throw h;return a(h)}c||(d&&d.then&&typeof d.then=="function"?d.then(r,a):d instanceof Error?a(d):r(d))}function a(i,...c){n||(n=!0,e(i,...c))}function r(i){a(null,i)}}const Xa={basename:PF,dirname:BF,extname:FF,join:zF,sep:"/"};function PF(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');sd(t);let n=0,s=-1,a=t.length,r;if(e===void 0||e.length===0||e.length>t.length){for(;a--;)if(t.codePointAt(a)===47){if(r){n=a+1;break}}else s<0&&(r=!0,s=a+1);return s<0?"":t.slice(n,s)}if(e===t)return"";let i=-1,c=e.length-1;for(;a--;)if(t.codePointAt(a)===47){if(r){n=a+1;break}}else i<0&&(r=!0,i=a+1),c>-1&&(t.codePointAt(a)===e.codePointAt(c--)?c<0&&(s=a):(c=-1,s=i));return n===s?s=i:s<0&&(s=t.length),t.slice(n,s)}function BF(t){if(sd(t),t.length===0)return".";let e=-1,n=t.length,s;for(;--n;)if(t.codePointAt(n)===47){if(s){e=n;break}}else s||(s=!0);return e<0?t.codePointAt(0)===47?"/":".":e===1&&t.codePointAt(0)===47?"//":t.slice(0,e)}function FF(t){sd(t);let e=t.length,n=-1,s=0,a=-1,r=0,i;for(;e--;){const c=t.codePointAt(e);if(c===47){if(i){s=e+1;break}continue}n<0&&(i=!0,n=e+1),c===46?a<0?a=e:r!==1&&(r=1):a>-1&&(r=-1)}return a<0||n<0||r===0||r===1&&a===n-1&&a===s+1?"":t.slice(a,n)}function zF(...t){let e=-1,n;for(;++e<t.length;)sd(t[e]),t[e]&&(n=n===void 0?t[e]:n+"/"+t[e]);return n===void 0?".":$F(n)}function $F(t){sd(t);const e=t.codePointAt(0)===47;let n=UF(t,!e);return n.length===0&&!e&&(n="."),n.length>0&&t.codePointAt(t.length-1)===47&&(n+="/"),e?"/"+n:n}function UF(t,e){let n="",s=0,a=-1,r=0,i=-1,c,d;for(;++i<=t.length;){if(i<t.length)c=t.codePointAt(i);else{if(c===47)break;c=47}if(c===47){if(!(a===i-1||r===1))if(a!==i-1&&r===2){if(n.length<2||s!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(d=n.lastIndexOf("/"),d!==n.length-1){d<0?(n="",s=0):(n=n.slice(0,d),s=n.length-1-n.lastIndexOf("/")),a=i,r=0;continue}}else if(n.length>0){n="",s=0,a=i,r=0;continue}}e&&(n=n.length>0?n+"/..":"..",s=2)}else n.length>0?n+="/"+t.slice(a+1,i):n=t.slice(a+1,i),s=i-a-1;a=i,r=0}else c===46&&r>-1?r++:r=-1}return n}function sd(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}const HF={cwd:WF};function WF(){return"/"}function hx(t){return!!(t!==null&&typeof t=="object"&&"href"in t&&t.href&&"protocol"in t&&t.protocol&&t.auth===void 0)}function qF(t){if(typeof t=="string")t=new URL(t);else if(!hx(t)){const e=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+t+"`");throw e.code="ERR_INVALID_ARG_TYPE",e}if(t.protocol!=="file:"){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return VF(t)}function VF(t){if(t.hostname!==""){const s=new TypeError('File URL host must be "localhost" or empty on darwin');throw s.code="ERR_INVALID_FILE_URL_HOST",s}const e=t.pathname;let n=-1;for(;++n<e.length;)if(e.codePointAt(n)===37&&e.codePointAt(n+1)===50){const s=e.codePointAt(n+2);if(s===70||s===102){const a=new TypeError("File URL path must not include encoded / characters");throw a.code="ERR_INVALID_FILE_URL_PATH",a}}return decodeURIComponent(e)}const tb=["history","path","basename","stem","extname","dirname"];class nN{constructor(e){let n;e?hx(e)?n={path:e}:typeof e=="string"||YF(e)?n={value:e}:n=e:n={},this.cwd="cwd"in n?"":HF.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let s=-1;for(;++s<tb.length;){const r=tb[s];r in n&&n[r]!==void 0&&n[r]!==null&&(this[r]=r==="history"?[...n[r]]:n[r])}let a;for(a in n)tb.includes(a)||(this[a]=n[a])}get basename(){return typeof this.path=="string"?Xa.basename(this.path):void 0}set basename(e){sb(e,"basename"),nb(e,"basename"),this.path=Xa.join(this.dirname||"",e)}get dirname(){return typeof this.path=="string"?Xa.dirname(this.path):void 0}set dirname(e){lC(this.basename,"dirname"),this.path=Xa.join(e||"",this.basename)}get extname(){return typeof this.path=="string"?Xa.extname(this.path):void 0}set extname(e){if(nb(e,"extname"),lC(this.dirname,"extname"),e){if(e.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(e.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Xa.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){hx(e)&&(e=qF(e)),sb(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path=="string"?Xa.basename(this.path,this.extname):void 0}set stem(e){sb(e,"stem"),nb(e,"stem"),this.path=Xa.join(this.dirname||"",e+(this.extname||""))}fail(e,n,s){const a=this.message(e,n,s);throw a.fatal=!0,a}info(e,n,s){const a=this.message(e,n,s);return a.fatal=void 0,a}message(e,n,s){const a=new Ns(e,n,s);return this.path&&(a.name=this.path+":"+a.name,a.file=this.path),a.fatal=!1,this.messages.push(a),a}toString(e){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(e||void 0).decode(this.value)}}function nb(t,e){if(t&&t.includes(Xa.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+Xa.sep+"`")}function sb(t,e){if(!t)throw new Error("`"+e+"` cannot be empty")}function lC(t,e){if(!t)throw new Error("Setting `"+e+"` requires `path` to be set too")}function YF(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const GF=(function(t){const s=this.constructor.prototype,a=s[t],r=function(){return a.apply(r,arguments)};return Object.setPrototypeOf(r,s),r}),KF={}.hasOwnProperty;class cy extends GF{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=LF()}copy(){const e=new cy;let n=-1;for(;++n<this.attachers.length;){const s=this.attachers[n];e.use(...s)}return e.data(eb(!0,{},this.namespace)),e}data(e,n){return typeof e=="string"?arguments.length===2?(ib("data",this.frozen),this.namespace[e]=n,this):KF.call(this.namespace,e)&&this.namespace[e]||void 0:e?(ib("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;const e=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...s]=this.attachers[this.freezeIndex];if(s[0]===!1)continue;s[0]===!0&&(s[0]=void 0);const a=n.call(e,...s);typeof a=="function"&&this.transformers.use(a)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const n=If(e),s=this.parser||this.Parser;return ab("parse",s),s(String(n),n)}process(e,n){const s=this;return this.freeze(),ab("process",this.parser||this.Parser),rb("process",this.compiler||this.Compiler),n?a(void 0,n):new Promise(a);function a(r,i){const c=If(e),d=s.parse(c);s.run(d,c,function(h,m,b){if(h||!m||!b)return f(h);const y=m,w=s.stringify(y,b);JF(w)?b.value=w:b.result=w,f(h,b)});function f(h,m){h||!m?i(h):r?r(m):n(void 0,m)}}}processSync(e){let n=!1,s;return this.freeze(),ab("processSync",this.parser||this.Parser),rb("processSync",this.compiler||this.Compiler),this.process(e,a),uC("processSync","process",n),s;function a(r,i){n=!0,iC(r),s=i}}run(e,n,s){cC(e),this.freeze();const a=this.transformers;return!s&&typeof n=="function"&&(s=n,n=void 0),s?r(void 0,s):new Promise(r);function r(i,c){const d=If(n);a.run(e,d,f);function f(h,m,b){const y=m||e;h?c(h):i?i(y):s(void 0,y,b)}}}runSync(e,n){let s=!1,a;return this.run(e,n,r),uC("runSync","run",s),a;function r(i,c){iC(i),a=c,s=!0}}stringify(e,n){this.freeze();const s=If(n),a=this.compiler||this.Compiler;return rb("stringify",a),cC(e),a(e,s)}use(e,...n){const s=this.attachers,a=this.namespace;if(ib("use",this.frozen),e!=null)if(typeof e=="function")d(e,n);else if(typeof e=="object")Array.isArray(e)?c(e):i(e);else throw new TypeError("Expected usable value, not `"+e+"`");return this;function r(f){if(typeof f=="function")d(f,[]);else if(typeof f=="object")if(Array.isArray(f)){const[h,...m]=f;d(h,m)}else i(f);else throw new TypeError("Expected usable value, not `"+f+"`")}function i(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");c(f.plugins),f.settings&&(a.settings=eb(!0,a.settings,f.settings))}function c(f){let h=-1;if(f!=null)if(Array.isArray(f))for(;++h<f.length;){const m=f[h];r(m)}else throw new TypeError("Expected a list of plugins, not `"+f+"`")}function d(f,h){let m=-1,b=-1;for(;++m<s.length;)if(s[m][0]===f){b=m;break}if(b===-1)s.push([f,...h]);else if(h.length>0){let[y,...w]=h;const C=s[b][1];px(C)&&px(y)&&(y=eb(!0,C,y)),s[b]=[f,y,...w]}}}}const QF=new cy().freeze();function ab(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `parser`")}function rb(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `compiler`")}function ib(t,e){if(e)throw new Error("Cannot call `"+t+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function cC(t){if(!px(t)||typeof t.type!="string")throw new TypeError("Expected node, got `"+t+"`")}function uC(t,e,n){if(!n)throw new Error("`"+t+"` finished async. Use `"+e+"` instead")}function If(t){return XF(t)?t:new nN(t)}function XF(t){return!!(t&&typeof t=="object"&&"message"in t&&"messages"in t)}function JF(t){return typeof t=="string"||ZF(t)}function ZF(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const e8="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",dC=[],fC={allowDangerousHtml:!0},t8=/^(https?|ircs?|mailto|xmpp)$/i,n8=[{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 Fr(t){const e=s8(t),n=a8(t);return r8(e.runSync(e.parse(n),n),t)}function s8(t){const e=t.rehypePlugins||dC,n=t.remarkPlugins||dC,s=t.remarkRehypeOptions?{...t.remarkRehypeOptions,...fC}:fC;return QF().use(BB).use(n).use(DF,s).use(e)}function a8(t){const e=t.children||"",n=new nN;return typeof e=="string"&&(n.value=e),n}function r8(t,e){const n=e.allowedElements,s=e.allowElement,a=e.components,r=e.disallowedElements,i=e.skipHtml,c=e.unwrapDisallowed,d=e.urlTransform||i8;for(const h of n8)Object.hasOwn(e,h.from)&&(""+h.from+(h.to?"use `"+h.to+"` instead":"remove it")+e8+h.id,void 0);return ly(t,f),wI(t,{Fragment:o.Fragment,components:a,ignoreInvalidStyle:!0,jsx:o.jsx,jsxs:o.jsxs,passKeys:!0,passNode:!0});function f(h,m,b){if(h.type==="raw"&&b&&typeof m=="number")return i?b.children.splice(m,1):b.children[m]={type:"text",value:h.value},m;if(h.type==="element"){let y;for(y in Qg)if(Object.hasOwn(Qg,y)&&Object.hasOwn(h.properties,y)){const w=h.properties[y],C=Qg[y];(C===null||C.includes(h.tagName))&&(h.properties[y]=d(String(w||""),y,h))}}if(h.type==="element"){let y=n?!n.includes(h.tagName):r?r.includes(h.tagName):!1;if(!y&&s&&typeof m=="number"&&(y=!s(h,m,b)),y&&b&&typeof m=="number")return c&&h.children?b.children.splice(m,1,...h.children):b.children.splice(m,1),m}}}function i8(t){const e=t.indexOf(":"),n=t.indexOf("?"),s=t.indexOf("#"),a=t.indexOf("/");return e===-1||a!==-1&&e>a||n!==-1&&e>n||s!==-1&&e>s||t8.test(t.slice(0,e))?t:""}function pC(t,e){const n=String(t);if(typeof e!="string")throw new TypeError("Expected character");let s=0,a=n.indexOf(e);for(;a!==-1;)s++,a=n.indexOf(e,a+e.length);return s}function o8(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function l8(t,e,n){const a=th((n||{}).ignore||[]),r=c8(e);let i=-1;for(;++i<r.length;)tN(t,"text",c);function c(f,h){let m=-1,b;for(;++m<h.length;){const y=h[m],w=b?b.children:void 0;if(a(y,w?w.indexOf(y):void 0,b))return;b=y}if(b)return d(f,h)}function d(f,h){const m=h[h.length-1],b=r[i][0],y=r[i][1];let w=0;const N=m.children.indexOf(f);let k=!1,j=[];b.lastIndex=0;let S=b.exec(f.value);for(;S;){const T=S.index,D={index:S.index,input:S.input,stack:[...h,f]};let E=y(...S,D);if(typeof E=="string"&&(E=E.length>0?{type:"text",value:E}:void 0),E===!1?b.lastIndex=T+1:(w!==T&&j.push({type:"text",value:f.value.slice(w,T)}),Array.isArray(E)?j.push(...E):E&&j.push(E),w=T+S[0].length,k=!0),!b.global)break;S=b.exec(f.value)}return k?(w<f.value.length&&j.push({type:"text",value:f.value.slice(w)}),m.children.splice(N,1,...j)):j=[f],N+j.length}}function c8(t){const e=[];if(!Array.isArray(t))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!t[0]||Array.isArray(t[0])?t:[t];let s=-1;for(;++s<n.length;){const a=n[s];e.push([u8(a[0]),d8(a[1])])}return e}function u8(t){return typeof t=="string"?new RegExp(o8(t),"g"):t}function d8(t){return typeof t=="function"?t:function(){return t}}const ob="phrasing",lb=["autolink","link","image","label"];function f8(){return{transforms:[y8],enter:{literalAutolink:h8,literalAutolinkEmail:cb,literalAutolinkHttp:cb,literalAutolinkWww:cb},exit:{literalAutolink:x8,literalAutolinkEmail:b8,literalAutolinkHttp:m8,literalAutolinkWww:g8}}}function p8(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:ob,notInConstruct:lb},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:ob,notInConstruct:lb},{character:":",before:"[ps]",after:"\\/",inConstruct:ob,notInConstruct:lb}]}}function h8(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function cb(t){this.config.enter.autolinkProtocol.call(this,t)}function m8(t){this.config.exit.autolinkProtocol.call(this,t)}function g8(t){this.config.exit.data.call(this,t);const e=this.stack[this.stack.length-1];e.type,e.url="http://"+this.sliceSerialize(t)}function b8(t){this.config.exit.autolinkEmail.call(this,t)}function x8(t){this.exit(t)}function y8(t){l8(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,v8],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),w8]],{ignore:["link","linkReference"]})}function v8(t,e,n,s,a){let r="";if(!sN(a)||(/^w/i.test(e)&&(n=e+n,e="",r="http://"),!k8(n)))return!1;const i=S8(n+s);if(!i[0])return!1;const c={type:"link",title:null,url:r+e+i[0],children:[{type:"text",value:e+i[0]}]};return i[1]?[c,{type:"text",value:i[1]}]:c}function w8(t,e,n,s){return!sN(s,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+e+"@"+n,children:[{type:"text",value:e+"@"+n}]}}function k8(t){const e=t.split(".");return!(e.length<2||e[e.length-1]&&(/_/.test(e[e.length-1])||!/[a-zA-Z\d]/.test(e[e.length-1]))||e[e.length-2]&&(/_/.test(e[e.length-2])||!/[a-zA-Z\d]/.test(e[e.length-2])))}function S8(t){const e=/[!"&'),.:;<>?\]}]+$/.exec(t);if(!e)return[t,void 0];t=t.slice(0,e.index);let n=e[0],s=n.indexOf(")");const a=pC(t,"(");let r=pC(t,")");for(;s!==-1&&a>r;)t+=n.slice(0,s+1),n=n.slice(s+1),s=n.indexOf(")"),r++;return[t,n]}function sN(t,e){const n=t.input.charCodeAt(t.index-1);return(t.index===0||Eo(n)||Jp(n))&&(!e||n!==47)}aN.peek=D8;function C8(){this.buffer()}function A8(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function j8(){this.buffer()}function N8(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function T8(t){const e=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ia(this.sliceSerialize(t)).toLowerCase(),n.label=e}function _8(t){this.exit(t)}function E8(t){const e=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ia(this.sliceSerialize(t)).toLowerCase(),n.label=e}function M8(t){this.exit(t)}function D8(){return"["}function aN(t,e,n,s){const a=n.createTracker(s);let r=a.move("[^");const i=n.enter("footnoteReference"),c=n.enter("reference");return r+=a.move(n.safe(n.associationId(t),{after:"]",before:r})),c(),i(),r+=a.move("]"),r}function R8(){return{enter:{gfmFootnoteCallString:C8,gfmFootnoteCall:A8,gfmFootnoteDefinitionLabelString:j8,gfmFootnoteDefinition:N8},exit:{gfmFootnoteCallString:T8,gfmFootnoteCall:_8,gfmFootnoteDefinitionLabelString:E8,gfmFootnoteDefinition:M8}}}function O8(t){let e=!1;return t&&t.firstLineBlank&&(e=!0),{handlers:{footnoteDefinition:n,footnoteReference:aN},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(s,a,r,i){const c=r.createTracker(i);let d=c.move("[^");const f=r.enter("footnoteDefinition"),h=r.enter("label");return d+=c.move(r.safe(r.associationId(s),{before:d,after:"]"})),h(),d+=c.move("]:"),s.children&&s.children.length>0&&(c.shift(4),d+=c.move((e?`
61
- `:" ")+r.indentLines(r.containerFlow(s,c.current()),e?rN:L8))),f(),d}}function L8(t,e,n){return e===0?t:rN(t,e,n)}function rN(t,e,n){return(n?"":" ")+t}const I8=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];iN.peek=$8;function P8(){return{canContainEols:["delete"],enter:{strikethrough:F8},exit:{strikethrough:z8}}}function B8(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:I8}],handlers:{delete:iN}}}function F8(t){this.enter({type:"delete",children:[]},t)}function z8(t){this.exit(t)}function iN(t,e,n,s){const a=n.createTracker(s),r=n.enter("strikethrough");let i=a.move("~~");return i+=n.containerPhrasing(t,{...a.current(),before:i,after:"~"}),i+=a.move("~~"),r(),i}function $8(){return"~"}function U8(t){return t.length}function H8(t,e){const n=e||{},s=(n.align||[]).concat(),a=n.stringLength||U8,r=[],i=[],c=[],d=[];let f=0,h=-1;for(;++h<t.length;){const C=[],N=[];let k=-1;for(t[h].length>f&&(f=t[h].length);++k<t[h].length;){const j=W8(t[h][k]);if(n.alignDelimiters!==!1){const S=a(j);N[k]=S,(d[k]===void 0||S>d[k])&&(d[k]=S)}C.push(j)}i[h]=C,c[h]=N}let m=-1;if(typeof s=="object"&&"length"in s)for(;++m<f;)r[m]=hC(s[m]);else{const C=hC(s);for(;++m<f;)r[m]=C}m=-1;const b=[],y=[];for(;++m<f;){const C=r[m];let N="",k="";C===99?(N=":",k=":"):C===108?N=":":C===114&&(k=":");let j=n.alignDelimiters===!1?1:Math.max(1,d[m]-N.length-k.length);const S=N+"-".repeat(j)+k;n.alignDelimiters!==!1&&(j=N.length+j+k.length,j>d[m]&&(d[m]=j),y[m]=j),b[m]=S}i.splice(1,0,b),c.splice(1,0,y),h=-1;const w=[];for(;++h<i.length;){const C=i[h],N=c[h];m=-1;const k=[];for(;++m<f;){const j=C[m]||"";let S="",T="";if(n.alignDelimiters!==!1){const D=d[m]-(N[m]||0),E=r[m];E===114?S=" ".repeat(D):E===99?D%2?(S=" ".repeat(D/2+.5),T=" ".repeat(D/2-.5)):(S=" ".repeat(D/2),T=S):T=" ".repeat(D)}n.delimiterStart!==!1&&!m&&k.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&j==="")&&(n.delimiterStart!==!1||m)&&k.push(" "),n.alignDelimiters!==!1&&k.push(S),k.push(j),n.alignDelimiters!==!1&&k.push(T),n.padding!==!1&&k.push(" "),(n.delimiterEnd!==!1||m!==f-1)&&k.push("|")}w.push(n.delimiterEnd===!1?k.join("").replace(/ +$/,""):k.join(""))}return w.join(`
62
- `)}function W8(t){return t==null?"":String(t)}function hC(t){const e=typeof t=="string"?t.codePointAt(0):0;return e===67||e===99?99:e===76||e===108?108:e===82||e===114?114:0}function q8(t,e,n,s){const a=n.enter("blockquote"),r=n.createTracker(s);r.move("> "),r.shift(2);const i=n.indentLines(n.containerFlow(t,r.current()),V8);return a(),i}function V8(t,e,n){return">"+(n?"":" ")+t}function Y8(t,e){return mC(t,e.inConstruct,!0)&&!mC(t,e.notInConstruct,!1)}function mC(t,e,n){if(typeof e=="string"&&(e=[e]),!e||e.length===0)return n;let s=-1;for(;++s<e.length;)if(t.includes(e[s]))return!0;return!1}function gC(t,e,n,s){let a=-1;for(;++a<n.unsafe.length;)if(n.unsafe[a].character===`
63
- `&&Y8(n.stack,n.unsafe[a]))return/[ \t]/.test(s.before)?"":" ";return`\\
64
- `}function G8(t,e){const n=String(t);let s=n.indexOf(e),a=s,r=0,i=0;if(typeof e!="string")throw new TypeError("Expected substring");for(;s!==-1;)s===a?++r>i&&(i=r):r=1,a=s+e.length,s=n.indexOf(e,a);return i}function K8(t,e){return!!(e.options.fences===!1&&t.value&&!t.lang&&/[^ \r\n]/.test(t.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(t.value))}function Q8(t){const e=t.options.fence||"`";if(e!=="`"&&e!=="~")throw new Error("Cannot serialize code with `"+e+"` for `options.fence`, expected `` ` `` or `~`");return e}function X8(t,e,n,s){const a=Q8(n),r=t.value||"",i=a==="`"?"GraveAccent":"Tilde";if(K8(t,n)){const m=n.enter("codeIndented"),b=n.indentLines(r,J8);return m(),b}const c=n.createTracker(s),d=a.repeat(Math.max(G8(r,a)+1,3)),f=n.enter("codeFenced");let h=c.move(d);if(t.lang){const m=n.enter(`codeFencedLang${i}`);h+=c.move(n.safe(t.lang,{before:h,after:" ",encode:["`"],...c.current()})),m()}if(t.lang&&t.meta){const m=n.enter(`codeFencedMeta${i}`);h+=c.move(" "),h+=c.move(n.safe(t.meta,{before:h,after:`
65
- `,encode:["`"],...c.current()})),m()}return h+=c.move(`
66
- `),r&&(h+=c.move(r+`
67
- `)),h+=c.move(d),f(),h}function J8(t,e,n){return(n?"":" ")+t}function uy(t){const e=t.options.quote||'"';if(e!=='"'&&e!=="'")throw new Error("Cannot serialize title with `"+e+"` for `options.quote`, expected `\"`, or `'`");return e}function Z8(t,e,n,s){const a=uy(n),r=a==='"'?"Quote":"Apostrophe",i=n.enter("definition");let c=n.enter("label");const d=n.createTracker(s);let f=d.move("[");return f+=d.move(n.safe(n.associationId(t),{before:f,after:"]",...d.current()})),f+=d.move("]: "),c(),!t.url||/[\0- \u007F]/.test(t.url)?(c=n.enter("destinationLiteral"),f+=d.move("<"),f+=d.move(n.safe(t.url,{before:f,after:">",...d.current()})),f+=d.move(">")):(c=n.enter("destinationRaw"),f+=d.move(n.safe(t.url,{before:f,after:t.title?" ":`
68
- `,...d.current()}))),c(),t.title&&(c=n.enter(`title${r}`),f+=d.move(" "+a),f+=d.move(n.safe(t.title,{before:f,after:a,...d.current()})),f+=d.move(a),c()),i(),f}function e9(t){const e=t.options.emphasis||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize emphasis with `"+e+"` for `options.emphasis`, expected `*`, or `_`");return e}function Yu(t){return"&#x"+t.toString(16).toUpperCase()+";"}function Ap(t,e,n){const s=Gl(t),a=Gl(e);return s===void 0?a===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:s===1?a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}oN.peek=t9;function oN(t,e,n,s){const a=e9(n),r=n.enter("emphasis"),i=n.createTracker(s),c=i.move(a);let d=i.move(n.containerPhrasing(t,{after:a,before:c,...i.current()}));const f=d.charCodeAt(0),h=Ap(s.before.charCodeAt(s.before.length-1),f,a);h.inside&&(d=Yu(f)+d.slice(1));const m=d.charCodeAt(d.length-1),b=Ap(s.after.charCodeAt(0),m,a);b.inside&&(d=d.slice(0,-1)+Yu(m));const y=i.move(a);return r(),n.attentionEncodeSurroundingInfo={after:b.outside,before:h.outside},c+d+y}function t9(t,e,n){return n.options.emphasis||"*"}function n9(t,e){let n=!1;return ly(t,function(s){if("value"in s&&/\r?\n|\r/.test(s.value)||s.type==="break")return n=!0,dx}),!!((!t.depth||t.depth<3)&&ty(t)&&(e.options.setext||n))}function s9(t,e,n,s){const a=Math.max(Math.min(6,t.depth||1),1),r=n.createTracker(s);if(n9(t,n)){const h=n.enter("headingSetext"),m=n.enter("phrasing"),b=n.containerPhrasing(t,{...r.current(),before:`
69
- `,after:`
70
- `});return m(),h(),b+`
71
- `+(a===1?"=":"-").repeat(b.length-(Math.max(b.lastIndexOf("\r"),b.lastIndexOf(`
72
- `))+1))}const i="#".repeat(a),c=n.enter("headingAtx"),d=n.enter("phrasing");r.move(i+" ");let f=n.containerPhrasing(t,{before:"# ",after:`
73
- `,...r.current()});return/^[\t ]/.test(f)&&(f=Yu(f.charCodeAt(0))+f.slice(1)),f=f?i+" "+f:i,n.options.closeAtx&&(f+=" "+i),d(),c(),f}lN.peek=a9;function lN(t){return t.value||""}function a9(){return"<"}cN.peek=r9;function cN(t,e,n,s){const a=uy(n),r=a==='"'?"Quote":"Apostrophe",i=n.enter("image");let c=n.enter("label");const d=n.createTracker(s);let f=d.move("![");return f+=d.move(n.safe(t.alt,{before:f,after:"]",...d.current()})),f+=d.move("]("),c(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(c=n.enter("destinationLiteral"),f+=d.move("<"),f+=d.move(n.safe(t.url,{before:f,after:">",...d.current()})),f+=d.move(">")):(c=n.enter("destinationRaw"),f+=d.move(n.safe(t.url,{before:f,after:t.title?" ":")",...d.current()}))),c(),t.title&&(c=n.enter(`title${r}`),f+=d.move(" "+a),f+=d.move(n.safe(t.title,{before:f,after:a,...d.current()})),f+=d.move(a),c()),f+=d.move(")"),i(),f}function r9(){return"!"}uN.peek=i9;function uN(t,e,n,s){const a=t.referenceType,r=n.enter("imageReference");let i=n.enter("label");const c=n.createTracker(s);let d=c.move("![");const f=n.safe(t.alt,{before:d,after:"]",...c.current()});d+=c.move(f+"]["),i();const h=n.stack;n.stack=[],i=n.enter("reference");const m=n.safe(n.associationId(t),{before:d,after:"]",...c.current()});return i(),n.stack=h,r(),a==="full"||!f||f!==m?d+=c.move(m+"]"):a==="shortcut"?d=d.slice(0,-1):d+=c.move("]"),d}function i9(){return"!"}dN.peek=o9;function dN(t,e,n){let s=t.value||"",a="`",r=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(s);)a+="`";for(/[^ \r\n]/.test(s)&&(/^[ \r\n]/.test(s)&&/[ \r\n]$/.test(s)||/^`|`$/.test(s))&&(s=" "+s+" ");++r<n.unsafe.length;){const i=n.unsafe[r],c=n.compilePattern(i);let d;if(i.atBreak)for(;d=c.exec(s);){let f=d.index;s.charCodeAt(f)===10&&s.charCodeAt(f-1)===13&&f--,s=s.slice(0,f)+" "+s.slice(d.index+1)}}return a+s+a}function o9(){return"`"}function fN(t,e){const n=ty(t);return!!(!e.options.resourceLink&&t.url&&!t.title&&t.children&&t.children.length===1&&t.children[0].type==="text"&&(n===t.url||"mailto:"+n===t.url)&&/^[a-z][a-z+.-]+:/i.test(t.url)&&!/[\0- <>\u007F]/.test(t.url))}pN.peek=l9;function pN(t,e,n,s){const a=uy(n),r=a==='"'?"Quote":"Apostrophe",i=n.createTracker(s);let c,d;if(fN(t,n)){const h=n.stack;n.stack=[],c=n.enter("autolink");let m=i.move("<");return m+=i.move(n.containerPhrasing(t,{before:m,after:">",...i.current()})),m+=i.move(">"),c(),n.stack=h,m}c=n.enter("link"),d=n.enter("label");let f=i.move("[");return f+=i.move(n.containerPhrasing(t,{before:f,after:"](",...i.current()})),f+=i.move("]("),d(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(d=n.enter("destinationLiteral"),f+=i.move("<"),f+=i.move(n.safe(t.url,{before:f,after:">",...i.current()})),f+=i.move(">")):(d=n.enter("destinationRaw"),f+=i.move(n.safe(t.url,{before:f,after:t.title?" ":")",...i.current()}))),d(),t.title&&(d=n.enter(`title${r}`),f+=i.move(" "+a),f+=i.move(n.safe(t.title,{before:f,after:a,...i.current()})),f+=i.move(a),d()),f+=i.move(")"),c(),f}function l9(t,e,n){return fN(t,n)?"<":"["}hN.peek=c9;function hN(t,e,n,s){const a=t.referenceType,r=n.enter("linkReference");let i=n.enter("label");const c=n.createTracker(s);let d=c.move("[");const f=n.containerPhrasing(t,{before:d,after:"]",...c.current()});d+=c.move(f+"]["),i();const h=n.stack;n.stack=[],i=n.enter("reference");const m=n.safe(n.associationId(t),{before:d,after:"]",...c.current()});return i(),n.stack=h,r(),a==="full"||!f||f!==m?d+=c.move(m+"]"):a==="shortcut"?d=d.slice(0,-1):d+=c.move("]"),d}function c9(){return"["}function dy(t){const e=t.options.bullet||"*";if(e!=="*"&&e!=="+"&&e!=="-")throw new Error("Cannot serialize items with `"+e+"` for `options.bullet`, expected `*`, `+`, or `-`");return e}function u9(t){const e=dy(t),n=t.options.bulletOther;if(!n)return e==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===e)throw new Error("Expected `bullet` (`"+e+"`) and `bulletOther` (`"+n+"`) to be different");return n}function d9(t){const e=t.options.bulletOrdered||".";if(e!=="."&&e!==")")throw new Error("Cannot serialize items with `"+e+"` for `options.bulletOrdered`, expected `.` or `)`");return e}function mN(t){const e=t.options.rule||"*";if(e!=="*"&&e!=="-"&&e!=="_")throw new Error("Cannot serialize rules with `"+e+"` for `options.rule`, expected `*`, `-`, or `_`");return e}function f9(t,e,n,s){const a=n.enter("list"),r=n.bulletCurrent;let i=t.ordered?d9(n):dy(n);const c=t.ordered?i==="."?")":".":u9(n);let d=e&&n.bulletLastUsed?i===n.bulletLastUsed:!1;if(!t.ordered){const h=t.children?t.children[0]:void 0;if((i==="*"||i==="-")&&h&&(!h.children||!h.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(d=!0),mN(n)===i&&h){let m=-1;for(;++m<t.children.length;){const b=t.children[m];if(b&&b.type==="listItem"&&b.children&&b.children[0]&&b.children[0].type==="thematicBreak"){d=!0;break}}}}d&&(i=c),n.bulletCurrent=i;const f=n.containerFlow(t,s);return n.bulletLastUsed=i,n.bulletCurrent=r,a(),f}function p9(t){const e=t.options.listItemIndent||"one";if(e!=="tab"&&e!=="one"&&e!=="mixed")throw new Error("Cannot serialize items with `"+e+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return e}function h9(t,e,n,s){const a=p9(n);let r=n.bulletCurrent||dy(n);e&&e.type==="list"&&e.ordered&&(r=(typeof e.start=="number"&&e.start>-1?e.start:1)+(n.options.incrementListMarker===!1?0:e.children.indexOf(t))+r);let i=r.length+1;(a==="tab"||a==="mixed"&&(e&&e.type==="list"&&e.spread||t.spread))&&(i=Math.ceil(i/4)*4);const c=n.createTracker(s);c.move(r+" ".repeat(i-r.length)),c.shift(i);const d=n.enter("listItem"),f=n.indentLines(n.containerFlow(t,c.current()),h);return d(),f;function h(m,b,y){return b?(y?"":" ".repeat(i))+m:(y?r:r+" ".repeat(i-r.length))+m}}function m9(t,e,n,s){const a=n.enter("paragraph"),r=n.enter("phrasing"),i=n.containerPhrasing(t,s);return r(),a(),i}const g9=th(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function b9(t,e,n,s){return(t.children.some(function(i){return g9(i)})?n.containerPhrasing:n.containerFlow).call(n,t,s)}function x9(t){const e=t.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}gN.peek=y9;function gN(t,e,n,s){const a=x9(n),r=n.enter("strong"),i=n.createTracker(s),c=i.move(a+a);let d=i.move(n.containerPhrasing(t,{after:a,before:c,...i.current()}));const f=d.charCodeAt(0),h=Ap(s.before.charCodeAt(s.before.length-1),f,a);h.inside&&(d=Yu(f)+d.slice(1));const m=d.charCodeAt(d.length-1),b=Ap(s.after.charCodeAt(0),m,a);b.inside&&(d=d.slice(0,-1)+Yu(m));const y=i.move(a+a);return r(),n.attentionEncodeSurroundingInfo={after:b.outside,before:h.outside},c+d+y}function y9(t,e,n){return n.options.strong||"*"}function v9(t,e,n,s){return n.safe(t.value,s)}function w9(t){const e=t.options.ruleRepetition||3;if(e<3)throw new Error("Cannot serialize rules with repetition `"+e+"` for `options.ruleRepetition`, expected `3` or more");return e}function k9(t,e,n){const s=(mN(n)+(n.options.ruleSpaces?" ":"")).repeat(w9(n));return n.options.ruleSpaces?s.slice(0,-1):s}const bN={blockquote:q8,break:gC,code:X8,definition:Z8,emphasis:oN,hardBreak:gC,heading:s9,html:lN,image:cN,imageReference:uN,inlineCode:dN,link:pN,linkReference:hN,list:f9,listItem:h9,paragraph:m9,root:b9,strong:gN,text:v9,thematicBreak:k9};function S9(){return{enter:{table:C9,tableData:bC,tableHeader:bC,tableRow:j9},exit:{codeText:N9,table:A9,tableData:ub,tableHeader:ub,tableRow:ub}}}function C9(t){const e=t._align;this.enter({type:"table",align:e.map(function(n){return n==="none"?null:n}),children:[]},t),this.data.inTable=!0}function A9(t){this.exit(t),this.data.inTable=void 0}function j9(t){this.enter({type:"tableRow",children:[]},t)}function ub(t){this.exit(t)}function bC(t){this.enter({type:"tableCell",children:[]},t)}function N9(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,T9));const n=this.stack[this.stack.length-1];n.type,n.value=e,this.exit(t)}function T9(t,e){return e==="|"?e:t}function _9(t){const e=t||{},n=e.tableCellPadding,s=e.tablePipeAlign,a=e.stringLength,r=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
74
- `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:b,table:i,tableCell:d,tableRow:c}};function i(y,w,C,N){return f(h(y,C,N),y.align)}function c(y,w,C,N){const k=m(y,C,N),j=f([k]);return j.slice(0,j.indexOf(`
75
- `))}function d(y,w,C,N){const k=C.enter("tableCell"),j=C.enter("phrasing"),S=C.containerPhrasing(y,{...N,before:r,after:r});return j(),k(),S}function f(y,w){return H8(y,{align:w,alignDelimiters:s,padding:n,stringLength:a})}function h(y,w,C){const N=y.children;let k=-1;const j=[],S=w.enter("table");for(;++k<N.length;)j[k]=m(N[k],w,C);return S(),j}function m(y,w,C){const N=y.children;let k=-1;const j=[],S=w.enter("tableRow");for(;++k<N.length;)j[k]=d(N[k],y,w,C);return S(),j}function b(y,w,C){let N=bN.inlineCode(y,w,C);return C.stack.includes("tableCell")&&(N=N.replace(/\|/g,"\\$&")),N}}function E9(){return{exit:{taskListCheckValueChecked:xC,taskListCheckValueUnchecked:xC,paragraph:D9}}}function M9(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:R9}}}function xC(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function D9(t){const e=this.stack[this.stack.length-2];if(e&&e.type==="listItem"&&typeof e.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const s=n.children[0];if(s&&s.type==="text"){const a=e.children;let r=-1,i;for(;++r<a.length;){const c=a[r];if(c.type==="paragraph"){i=c;break}}i===n&&(s.value=s.value.slice(1),s.value.length===0?n.children.shift():n.position&&s.position&&typeof s.position.start.offset=="number"&&(s.position.start.column++,s.position.start.offset++,n.position.start=Object.assign({},s.position.start)))}}this.exit(t)}function R9(t,e,n,s){const a=t.children[0],r=typeof t.checked=="boolean"&&a&&a.type==="paragraph",i="["+(t.checked?"x":" ")+"] ",c=n.createTracker(s);r&&c.move(i);let d=bN.listItem(t,e,n,{...s,...c.current()});return r&&(d=d.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,f)),d;function f(h){return h+i}}function O9(){return[f8(),R8(),P8(),S9(),E9()]}function L9(t){return{extensions:[p8(),O8(t),B8(),_9(t),M9()]}}const I9={tokenize:U9,partial:!0},xN={tokenize:H9,partial:!0},yN={tokenize:W9,partial:!0},vN={tokenize:q9,partial:!0},P9={tokenize:V9,partial:!0},wN={name:"wwwAutolink",tokenize:z9,previous:SN},kN={name:"protocolAutolink",tokenize:$9,previous:CN},Yr={name:"emailAutolink",tokenize:F9,previous:AN},hr={};function B9(){return{text:hr}}let mo=48;for(;mo<123;)hr[mo]=Yr,mo++,mo===58?mo=65:mo===91&&(mo=97);hr[43]=Yr;hr[45]=Yr;hr[46]=Yr;hr[95]=Yr;hr[72]=[Yr,kN];hr[104]=[Yr,kN];hr[87]=[Yr,wN];hr[119]=[Yr,wN];function F9(t,e,n){const s=this;let a,r;return i;function i(m){return!mx(m)||!AN.call(s,s.previous)||fy(s.events)?n(m):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),c(m))}function c(m){return mx(m)?(t.consume(m),c):m===64?(t.consume(m),d):n(m)}function d(m){return m===46?t.check(P9,h,f)(m):m===45||m===95||js(m)?(r=!0,t.consume(m),d):h(m)}function f(m){return t.consume(m),a=!0,d}function h(m){return r&&a&&Ms(s.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(m)):n(m)}}function z9(t,e,n){const s=this;return a;function a(i){return i!==87&&i!==119||!SN.call(s,s.previous)||fy(s.events)?n(i):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(I9,t.attempt(xN,t.attempt(yN,r),n),n)(i))}function r(i){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(i)}}function $9(t,e,n){const s=this;let a="",r=!1;return i;function i(m){return(m===72||m===104)&&CN.call(s,s.previous)&&!fy(s.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),a+=String.fromCodePoint(m),t.consume(m),c):n(m)}function c(m){if(Ms(m)&&a.length<5)return a+=String.fromCodePoint(m),t.consume(m),c;if(m===58){const b=a.toLowerCase();if(b==="http"||b==="https")return t.consume(m),d}return n(m)}function d(m){return m===47?(t.consume(m),r?f:(r=!0,d)):n(m)}function f(m){return m===null||kp(m)||_n(m)||Eo(m)||Jp(m)?n(m):t.attempt(xN,t.attempt(yN,h),n)(m)}function h(m){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(m)}}function U9(t,e,n){let s=0;return a;function a(i){return(i===87||i===119)&&s<3?(s++,t.consume(i),a):i===46&&s===3?(t.consume(i),r):n(i)}function r(i){return i===null?n(i):e(i)}}function H9(t,e,n){let s,a,r;return i;function i(f){return f===46||f===95?t.check(vN,d,c)(f):f===null||_n(f)||Eo(f)||f!==45&&Jp(f)?d(f):(r=!0,t.consume(f),i)}function c(f){return f===95?s=!0:(a=s,s=void 0),t.consume(f),i}function d(f){return a||s||!r?n(f):e(f)}}function W9(t,e){let n=0,s=0;return a;function a(i){return i===40?(n++,t.consume(i),a):i===41&&s<n?r(i):i===33||i===34||i===38||i===39||i===41||i===42||i===44||i===46||i===58||i===59||i===60||i===63||i===93||i===95||i===126?t.check(vN,e,r)(i):i===null||_n(i)||Eo(i)?e(i):(t.consume(i),a)}function r(i){return i===41&&s++,t.consume(i),a}}function q9(t,e,n){return s;function s(c){return c===33||c===34||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===63||c===95||c===126?(t.consume(c),s):c===38?(t.consume(c),r):c===93?(t.consume(c),a):c===60||c===null||_n(c)||Eo(c)?e(c):n(c)}function a(c){return c===null||c===40||c===91||_n(c)||Eo(c)?e(c):s(c)}function r(c){return Ms(c)?i(c):n(c)}function i(c){return c===59?(t.consume(c),s):Ms(c)?(t.consume(c),i):n(c)}}function V9(t,e,n){return s;function s(r){return t.consume(r),a}function a(r){return js(r)?n(r):e(r)}}function SN(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||_n(t)}function CN(t){return!Ms(t)}function AN(t){return!(t===47||mx(t))}function mx(t){return t===43||t===45||t===46||t===95||js(t)}function fy(t){let e=t.length,n=!1;for(;e--;){const s=t[e][1];if((s.type==="labelLink"||s.type==="labelImage")&&!s._balanced){n=!0;break}if(s._gfmAutolinkLiteralWalkedInto){n=!1;break}}return t.length>0&&!n&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const Y9={tokenize:t4,partial:!0};function G9(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:J9,continuation:{tokenize:Z9},exit:e4}},text:{91:{name:"gfmFootnoteCall",tokenize:X9},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:K9,resolveTo:Q9}}}}function K9(t,e,n){const s=this;let a=s.events.length;const r=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let i;for(;a--;){const d=s.events[a][1];if(d.type==="labelImage"){i=d;break}if(d.type==="gfmFootnoteCall"||d.type==="labelLink"||d.type==="label"||d.type==="image"||d.type==="link")break}return c;function c(d){if(!i||!i._balanced)return n(d);const f=Ia(s.sliceSerialize({start:i.end,end:s.now()}));return f.codePointAt(0)!==94||!r.includes(f.slice(1))?n(d):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(d),t.exit("gfmFootnoteCallLabelMarker"),e(d))}}function Q9(t,e){let n=t.length;for(;n--;)if(t[n][1].type==="labelImage"&&t[n][0]==="enter"){t[n][1];break}t[n+1][1].type="data",t[n+3][1].type="gfmFootnoteCallLabelMarker";const s={type:"gfmFootnoteCall",start:Object.assign({},t[n+3][1].start),end:Object.assign({},t[t.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},t[n+3][1].end),end:Object.assign({},t[n+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const r={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},t[t.length-1][1].start)},i={type:"chunkString",contentType:"string",start:Object.assign({},r.start),end:Object.assign({},r.end)},c=[t[n+1],t[n+2],["enter",s,e],t[n+3],t[n+4],["enter",a,e],["exit",a,e],["enter",r,e],["enter",i,e],["exit",i,e],["exit",r,e],t[t.length-2],t[t.length-1],["exit",s,e]];return t.splice(n,t.length-n+1,...c),t}function X9(t,e,n){const s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let r=0,i;return c;function c(m){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(m),t.exit("gfmFootnoteCallLabelMarker"),d}function d(m){return m!==94?n(m):(t.enter("gfmFootnoteCallMarker"),t.consume(m),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",f)}function f(m){if(r>999||m===93&&!i||m===null||m===91||_n(m))return n(m);if(m===93){t.exit("chunkString");const b=t.exit("gfmFootnoteCallString");return a.includes(Ia(s.sliceSerialize(b)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(m),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):n(m)}return _n(m)||(i=!0),r++,t.consume(m),m===92?h:f}function h(m){return m===91||m===92||m===93?(t.consume(m),r++,f):f(m)}}function J9(t,e,n){const s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let r,i=0,c;return d;function d(w){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(w),t.exit("gfmFootnoteDefinitionLabelMarker"),f}function f(w){return w===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(w),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",h):n(w)}function h(w){if(i>999||w===93&&!c||w===null||w===91||_n(w))return n(w);if(w===93){t.exit("chunkString");const C=t.exit("gfmFootnoteDefinitionLabelString");return r=Ia(s.sliceSerialize(C)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(w),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),b}return _n(w)||(c=!0),i++,t.consume(w),w===92?m:h}function m(w){return w===91||w===92||w===93?(t.consume(w),i++,h):h(w)}function b(w){return w===58?(t.enter("definitionMarker"),t.consume(w),t.exit("definitionMarker"),a.includes(r)||a.push(r),un(t,y,"gfmFootnoteDefinitionWhitespace")):n(w)}function y(w){return e(w)}}function Z9(t,e,n){return t.check(nd,e,t.attempt(Y9,e,n))}function e4(t){t.exit("gfmFootnoteDefinition")}function t4(t,e,n){const s=this;return un(t,a,"gfmFootnoteDefinitionIndent",5);function a(r){const i=s.events[s.events.length-1];return i&&i[1].type==="gfmFootnoteDefinitionIndent"&&i[2].sliceSerialize(i[1],!0).length===4?e(r):n(r)}}function n4(t){let n=(t||{}).singleTilde;const s={name:"strikethrough",tokenize:r,resolveAll:a};return n==null&&(n=!0),{text:{126:s},insideSpan:{null:[s]},attentionMarkers:{null:[126]}};function a(i,c){let d=-1;for(;++d<i.length;)if(i[d][0]==="enter"&&i[d][1].type==="strikethroughSequenceTemporary"&&i[d][1]._close){let f=d;for(;f--;)if(i[f][0]==="exit"&&i[f][1].type==="strikethroughSequenceTemporary"&&i[f][1]._open&&i[d][1].end.offset-i[d][1].start.offset===i[f][1].end.offset-i[f][1].start.offset){i[d][1].type="strikethroughSequence",i[f][1].type="strikethroughSequence";const h={type:"strikethrough",start:Object.assign({},i[f][1].start),end:Object.assign({},i[d][1].end)},m={type:"strikethroughText",start:Object.assign({},i[f][1].end),end:Object.assign({},i[d][1].start)},b=[["enter",h,c],["enter",i[f][1],c],["exit",i[f][1],c],["enter",m,c]],y=c.parser.constructs.insideSpan.null;y&&ua(b,b.length,0,Zp(y,i.slice(f+1,d),c)),ua(b,b.length,0,[["exit",m,c],["enter",i[d][1],c],["exit",i[d][1],c],["exit",h,c]]),ua(i,f-1,d-f+3,b),d=f+b.length-2;break}}for(d=-1;++d<i.length;)i[d][1].type==="strikethroughSequenceTemporary"&&(i[d][1].type="data");return i}function r(i,c,d){const f=this.previous,h=this.events;let m=0;return b;function b(w){return f===126&&h[h.length-1][1].type!=="characterEscape"?d(w):(i.enter("strikethroughSequenceTemporary"),y(w))}function y(w){const C=Gl(f);if(w===126)return m>1?d(w):(i.consume(w),m++,y);if(m<2&&!n)return d(w);const N=i.exit("strikethroughSequenceTemporary"),k=Gl(w);return N._open=!k||k===2&&!!C,N._close=!C||C===2&&!!k,c(w)}}}class s4{constructor(){this.map=[]}add(e,n,s){a4(this,e,n,s)}consume(e){if(this.map.sort(function(r,i){return r[0]-i[0]}),this.map.length===0)return;let n=this.map.length;const s=[];for(;n>0;)n-=1,s.push(e.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),e.length=this.map[n][0];s.push(e.slice()),e.length=0;let a=s.pop();for(;a;){for(const r of a)e.push(r);a=s.pop()}this.map.length=0}}function a4(t,e,n,s){let a=0;if(!(n===0&&s.length===0)){for(;a<t.map.length;){if(t.map[a][0]===e){t.map[a][1]+=n,t.map[a][2].push(...s);return}a+=1}t.map.push([e,n,s])}}function r4(t,e){let n=!1;const s=[];for(;e<t.length;){const a=t[e];if(n){if(a[0]==="enter")a[1].type==="tableContent"&&s.push(t[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(a[1].type==="tableContent"){if(t[e-1][1].type==="tableDelimiterMarker"){const r=s.length-1;s[r]=s[r]==="left"?"center":"right"}}else if(a[1].type==="tableDelimiterRow")break}else a[0]==="enter"&&a[1].type==="tableDelimiterRow"&&(n=!0);e+=1}return s}function i4(){return{flow:{null:{name:"table",tokenize:o4,resolveAll:l4}}}}function o4(t,e,n){const s=this;let a=0,r=0,i;return c;function c(M){let R=s.events.length-1;for(;R>-1;){const W=s.events[R][1].type;if(W==="lineEnding"||W==="linePrefix")R--;else break}const z=R>-1?s.events[R][1].type:null,$=z==="tableHead"||z==="tableRow"?E:d;return $===E&&s.parser.lazy[s.now().line]?n(M):$(M)}function d(M){return t.enter("tableHead"),t.enter("tableRow"),f(M)}function f(M){return M===124||(i=!0,r+=1),h(M)}function h(M){return M===null?n(M):Et(M)?r>1?(r=0,s.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(M),t.exit("lineEnding"),y):n(M):en(M)?un(t,h,"whitespace")(M):(r+=1,i&&(i=!1,a+=1),M===124?(t.enter("tableCellDivider"),t.consume(M),t.exit("tableCellDivider"),i=!0,h):(t.enter("data"),m(M)))}function m(M){return M===null||M===124||_n(M)?(t.exit("data"),h(M)):(t.consume(M),M===92?b:m)}function b(M){return M===92||M===124?(t.consume(M),m):m(M)}function y(M){return s.interrupt=!1,s.parser.lazy[s.now().line]?n(M):(t.enter("tableDelimiterRow"),i=!1,en(M)?un(t,w,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(M):w(M))}function w(M){return M===45||M===58?N(M):M===124?(i=!0,t.enter("tableCellDivider"),t.consume(M),t.exit("tableCellDivider"),C):D(M)}function C(M){return en(M)?un(t,N,"whitespace")(M):N(M)}function N(M){return M===58?(r+=1,i=!0,t.enter("tableDelimiterMarker"),t.consume(M),t.exit("tableDelimiterMarker"),k):M===45?(r+=1,k(M)):M===null||Et(M)?T(M):D(M)}function k(M){return M===45?(t.enter("tableDelimiterFiller"),j(M)):D(M)}function j(M){return M===45?(t.consume(M),j):M===58?(i=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(M),t.exit("tableDelimiterMarker"),S):(t.exit("tableDelimiterFiller"),S(M))}function S(M){return en(M)?un(t,T,"whitespace")(M):T(M)}function T(M){return M===124?w(M):M===null||Et(M)?!i||a!==r?D(M):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(M)):D(M)}function D(M){return n(M)}function E(M){return t.enter("tableRow"),I(M)}function I(M){return M===124?(t.enter("tableCellDivider"),t.consume(M),t.exit("tableCellDivider"),I):M===null||Et(M)?(t.exit("tableRow"),e(M)):en(M)?un(t,I,"whitespace")(M):(t.enter("data"),O(M))}function O(M){return M===null||M===124||_n(M)?(t.exit("data"),I(M)):(t.consume(M),M===92?_:O)}function _(M){return M===92||M===124?(t.consume(M),O):O(M)}}function l4(t,e){let n=-1,s=!0,a=0,r=[0,0,0,0],i=[0,0,0,0],c=!1,d=0,f,h,m;const b=new s4;for(;++n<t.length;){const y=t[n],w=y[1];y[0]==="enter"?w.type==="tableHead"?(c=!1,d!==0&&(yC(b,e,d,f,h),h=void 0,d=0),f={type:"table",start:Object.assign({},w.start),end:Object.assign({},w.end)},b.add(n,0,[["enter",f,e]])):w.type==="tableRow"||w.type==="tableDelimiterRow"?(s=!0,m=void 0,r=[0,0,0,0],i=[0,n+1,0,0],c&&(c=!1,h={type:"tableBody",start:Object.assign({},w.start),end:Object.assign({},w.end)},b.add(n,0,[["enter",h,e]])),a=w.type==="tableDelimiterRow"?2:h?3:1):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")?(s=!1,i[2]===0&&(r[1]!==0&&(i[0]=i[1],m=Pf(b,e,r,a,void 0,m),r=[0,0,0,0]),i[2]=n)):w.type==="tableCellDivider"&&(s?s=!1:(r[1]!==0&&(i[0]=i[1],m=Pf(b,e,r,a,void 0,m)),r=i,i=[r[1],n,0,0])):w.type==="tableHead"?(c=!0,d=n):w.type==="tableRow"||w.type==="tableDelimiterRow"?(d=n,r[1]!==0?(i[0]=i[1],m=Pf(b,e,r,a,n,m)):i[1]!==0&&(m=Pf(b,e,i,a,n,m)),a=0):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")&&(i[3]=n)}for(d!==0&&yC(b,e,d,f,h),b.consume(e.events),n=-1;++n<e.events.length;){const y=e.events[n];y[0]==="enter"&&y[1].type==="table"&&(y[1]._align=r4(e.events,n))}return t}function Pf(t,e,n,s,a,r){const i=s===1?"tableHeader":s===2?"tableDelimiter":"tableData",c="tableContent";n[0]!==0&&(r.end=Object.assign({},Pl(e.events,n[0])),t.add(n[0],0,[["exit",r,e]]));const d=Pl(e.events,n[1]);if(r={type:i,start:Object.assign({},d),end:Object.assign({},d)},t.add(n[1],0,[["enter",r,e]]),n[2]!==0){const f=Pl(e.events,n[2]),h=Pl(e.events,n[3]),m={type:c,start:Object.assign({},f),end:Object.assign({},h)};if(t.add(n[2],0,[["enter",m,e]]),s!==2){const b=e.events[n[2]],y=e.events[n[3]];if(b[1].end=Object.assign({},y[1].end),b[1].type="chunkText",b[1].contentType="text",n[3]>n[2]+1){const w=n[2]+1,C=n[3]-n[2]-1;t.add(w,C,[])}}t.add(n[3]+1,0,[["exit",m,e]])}return a!==void 0&&(r.end=Object.assign({},Pl(e.events,a)),t.add(a,0,[["exit",r,e]]),r=void 0),r}function yC(t,e,n,s,a){const r=[],i=Pl(e.events,n);a&&(a.end=Object.assign({},i),r.push(["exit",a,e])),s.end=Object.assign({},i),r.push(["exit",s,e]),t.add(n+1,0,r)}function Pl(t,e){const n=t[e],s=n[0]==="enter"?"start":"end";return n[1][s]}const c4={name:"tasklistCheck",tokenize:d4};function u4(){return{text:{91:c4}}}function d4(t,e,n){const s=this;return a;function a(d){return s.previous!==null||!s._gfmTasklistFirstContentOfListItem?n(d):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(d),t.exit("taskListCheckMarker"),r)}function r(d){return _n(d)?(t.enter("taskListCheckValueUnchecked"),t.consume(d),t.exit("taskListCheckValueUnchecked"),i):d===88||d===120?(t.enter("taskListCheckValueChecked"),t.consume(d),t.exit("taskListCheckValueChecked"),i):n(d)}function i(d){return d===93?(t.enter("taskListCheckMarker"),t.consume(d),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),c):n(d)}function c(d){return Et(d)?e(d):en(d)?t.check({tokenize:f4},e,n)(d):n(d)}}function f4(t,e,n){return un(t,s,"whitespace");function s(a){return a===null?n(a):e(a)}}function p4(t){return I1([B9(),G9(),n4(t),i4(),u4()])}const h4={};function zr(t){const e=this,n=t||h4,s=e.data(),a=s.micromarkExtensions||(s.micromarkExtensions=[]),r=s.fromMarkdownExtensions||(s.fromMarkdownExtensions=[]),i=s.toMarkdownExtensions||(s.toMarkdownExtensions=[]);a.push(p4(n)),r.push(O9()),i.push(L9(n))}var db={exports:{}},vC;function m4(){return vC||(vC=1,(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};/**
76
- * Prism: Lightweight, robust, elegant syntax highlighting
77
- *
78
- * @license MIT <https://opensource.org/licenses/MIT>
79
- * @author Lea Verou <https://lea.verou.me>
80
- * @namespace
81
- * @public
82
- */var n=(function(s){var a=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,r=0,i={},c={manual:s.Prism&&s.Prism.manual,disableWorkerMessageHandler:s.Prism&&s.Prism.disableWorkerMessageHandler,util:{encode:function j(S){return S instanceof d?new d(S.type,j(S.content),S.alias):Array.isArray(S)?S.map(j):S.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/\u00a0/g," ")},type:function(j){return Object.prototype.toString.call(j).slice(8,-1)},objId:function(j){return j.__id||Object.defineProperty(j,"__id",{value:++r}),j.__id},clone:function j(S,T){T=T||{};var D,E;switch(c.util.type(S)){case"Object":if(E=c.util.objId(S),T[E])return T[E];D={},T[E]=D;for(var I in S)S.hasOwnProperty(I)&&(D[I]=j(S[I],T));return D;case"Array":return E=c.util.objId(S),T[E]?T[E]:(D=[],T[E]=D,S.forEach(function(O,_){D[_]=j(O,T)}),D);default:return S}},getLanguage:function(j){for(;j;){var S=a.exec(j.className);if(S)return S[1].toLowerCase();j=j.parentElement}return"none"},setLanguage:function(j,S){j.className=j.className.replace(RegExp(a,"gi"),""),j.classList.add("language-"+S)},currentScript:function(){if(typeof document>"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(D){var j=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(D.stack)||[])[1];if(j){var S=document.getElementsByTagName("script");for(var T in S)if(S[T].src==j)return S[T]}return null}},isActive:function(j,S,T){for(var D="no-"+S;j;){var E=j.classList;if(E.contains(S))return!0;if(E.contains(D))return!1;j=j.parentElement}return!!T}},languages:{plain:i,plaintext:i,text:i,txt:i,extend:function(j,S){var T=c.util.clone(c.languages[j]);for(var D in S)T[D]=S[D];return T},insertBefore:function(j,S,T,D){D=D||c.languages;var E=D[j],I={};for(var O in E)if(E.hasOwnProperty(O)){if(O==S)for(var _ in T)T.hasOwnProperty(_)&&(I[_]=T[_]);T.hasOwnProperty(O)||(I[O]=E[O])}var M=D[j];return D[j]=I,c.languages.DFS(c.languages,function(R,z){z===M&&R!=j&&(this[R]=I)}),I},DFS:function j(S,T,D,E){E=E||{};var I=c.util.objId;for(var O in S)if(S.hasOwnProperty(O)){T.call(S,O,S[O],D||O);var _=S[O],M=c.util.type(_);M==="Object"&&!E[I(_)]?(E[I(_)]=!0,j(_,T,null,E)):M==="Array"&&!E[I(_)]&&(E[I(_)]=!0,j(_,T,O,E))}}},plugins:{},highlightAll:function(j,S){c.highlightAllUnder(document,j,S)},highlightAllUnder:function(j,S,T){var D={callback:T,container:j,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};c.hooks.run("before-highlightall",D),D.elements=Array.prototype.slice.apply(D.container.querySelectorAll(D.selector)),c.hooks.run("before-all-elements-highlight",D);for(var E=0,I;I=D.elements[E++];)c.highlightElement(I,S===!0,D.callback)},highlightElement:function(j,S,T){var D=c.util.getLanguage(j),E=c.languages[D];c.util.setLanguage(j,D);var I=j.parentElement;I&&I.nodeName.toLowerCase()==="pre"&&c.util.setLanguage(I,D);var O=j.textContent,_={element:j,language:D,grammar:E,code:O};function M(z){_.highlightedCode=z,c.hooks.run("before-insert",_),_.element.innerHTML=_.highlightedCode,c.hooks.run("after-highlight",_),c.hooks.run("complete",_),T&&T.call(_.element)}if(c.hooks.run("before-sanity-check",_),I=_.element.parentElement,I&&I.nodeName.toLowerCase()==="pre"&&!I.hasAttribute("tabindex")&&I.setAttribute("tabindex","0"),!_.code){c.hooks.run("complete",_),T&&T.call(_.element);return}if(c.hooks.run("before-highlight",_),!_.grammar){M(c.util.encode(_.code));return}if(S&&s.Worker){var R=new Worker(c.filename);R.onmessage=function(z){M(z.data)},R.postMessage(JSON.stringify({language:_.language,code:_.code,immediateClose:!0}))}else M(c.highlight(_.code,_.grammar,_.language))},highlight:function(j,S,T){var D={code:j,grammar:S,language:T};if(c.hooks.run("before-tokenize",D),!D.grammar)throw new Error('The language "'+D.language+'" has no grammar.');return D.tokens=c.tokenize(D.code,D.grammar),c.hooks.run("after-tokenize",D),d.stringify(c.util.encode(D.tokens),D.language)},tokenize:function(j,S){var T=S.rest;if(T){for(var D in T)S[D]=T[D];delete S.rest}var E=new m;return b(E,E.head,j),h(j,E,S,E.head,0),w(E)},hooks:{all:{},add:function(j,S){var T=c.hooks.all;T[j]=T[j]||[],T[j].push(S)},run:function(j,S){var T=c.hooks.all[j];if(!(!T||!T.length))for(var D=0,E;E=T[D++];)E(S)}},Token:d};s.Prism=c;function d(j,S,T,D){this.type=j,this.content=S,this.alias=T,this.length=(D||"").length|0}d.stringify=function j(S,T){if(typeof S=="string")return S;if(Array.isArray(S)){var D="";return S.forEach(function(M){D+=j(M,T)}),D}var E={type:S.type,content:j(S.content,T),tag:"span",classes:["token",S.type],attributes:{},language:T},I=S.alias;I&&(Array.isArray(I)?Array.prototype.push.apply(E.classes,I):E.classes.push(I)),c.hooks.run("wrap",E);var O="";for(var _ in E.attributes)O+=" "+_+'="'+(E.attributes[_]||"").replace(/"/g,"&quot;")+'"';return"<"+E.tag+' class="'+E.classes.join(" ")+'"'+O+">"+E.content+"</"+E.tag+">"};function f(j,S,T,D){j.lastIndex=S;var E=j.exec(T);if(E&&D&&E[1]){var I=E[1].length;E.index+=I,E[0]=E[0].slice(I)}return E}function h(j,S,T,D,E,I){for(var O in T)if(!(!T.hasOwnProperty(O)||!T[O])){var _=T[O];_=Array.isArray(_)?_:[_];for(var M=0;M<_.length;++M){if(I&&I.cause==O+","+M)return;var R=_[M],z=R.inside,$=!!R.lookbehind,W=!!R.greedy,L=R.alias;if(W&&!R.pattern.global){var F=R.pattern.toString().match(/[imsuy]*$/)[0];R.pattern=RegExp(R.pattern.source,F+"g")}for(var H=R.pattern||R,V=D.next,G=E;V!==S.tail&&!(I&&G>=I.reach);G+=V.value.length,V=V.next){var B=V.value;if(S.length>j.length)return;if(!(B instanceof d)){var K=1,se;if(W){if(se=f(H,G,j,$),!se||se.index>=j.length)break;var Z=se.index,q=se.index+se[0].length,be=G;for(be+=V.value.length;Z>=be;)V=V.next,be+=V.value.length;if(be-=V.value.length,G=be,V.value instanceof d)continue;for(var Ce=V;Ce!==S.tail&&(be<q||typeof Ce.value=="string");Ce=Ce.next)K++,be+=Ce.value.length;K--,B=j.slice(G,be),se.index-=G}else if(se=f(H,0,B,$),!se)continue;var Z=se.index,ie=se[0],me=B.slice(0,Z),Ee=B.slice(Z+ie.length),Te=G+B.length;I&&Te>I.reach&&(I.reach=Te);var Ve=V.prev;me&&(Ve=b(S,Ve,me),G+=me.length),y(S,Ve,K);var We=new d(O,z?c.tokenize(ie,z):ie,L,ie);if(V=b(S,Ve,We),Ee&&b(S,V,Ee),K>1){var ee={cause:O+","+M,reach:Te};h(j,S,T,V.prev,G,ee),I&&ee.reach>I.reach&&(I.reach=ee.reach)}}}}}}function m(){var j={value:null,prev:null,next:null},S={value:null,prev:j,next:null};j.next=S,this.head=j,this.tail=S,this.length=0}function b(j,S,T){var D=S.next,E={value:T,prev:S,next:D};return S.next=E,D.prev=E,j.length++,E}function y(j,S,T){for(var D=S.next,E=0;E<T&&D!==j.tail;E++)D=D.next;S.next=D,D.prev=S,j.length-=E}function w(j){for(var S=[],T=j.head.next;T!==j.tail;)S.push(T.value),T=T.next;return S}if(!s.document)return s.addEventListener&&(c.disableWorkerMessageHandler||s.addEventListener("message",function(j){var S=JSON.parse(j.data),T=S.language,D=S.code,E=S.immediateClose;s.postMessage(c.highlight(D,c.languages[T],T)),E&&s.close()},!1)),c;var C=c.util.currentScript();C&&(c.filename=C.src,C.hasAttribute("data-manual")&&(c.manual=!0));function N(){c.manual||c.highlightAll()}if(!c.manual){var k=document.readyState;k==="loading"||k==="interactive"&&C&&C.defer?document.addEventListener("DOMContentLoaded",N):window.requestAnimationFrame?window.requestAnimationFrame(N):window.setTimeout(N,16)}return c})(e);t.exports&&(t.exports=n),typeof Z0<"u"&&(Z0.Prism=n),n.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]},n.languages.markup.tag.inside["attr-value"].inside.entity=n.languages.markup.entity,n.languages.markup.doctype.inside["internal-subset"].inside=n.languages.markup,n.hooks.add("wrap",function(s){s.type==="entity"&&(s.attributes.title=s.content.replace(/&amp;/,"&"))}),Object.defineProperty(n.languages.markup.tag,"addInlined",{value:function(a,r){var i={};i["language-"+r]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:n.languages[r]},i.cdata=/^<!\[CDATA\[|\]\]>$/i;var c={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:i}};c["language-"+r]={pattern:/[\s\S]+/,inside:n.languages[r]};var d={};d[a]={pattern:RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g,function(){return a}),"i"),lookbehind:!0,greedy:!0,inside:c},n.languages.insertBefore("markup","cdata",d)}}),Object.defineProperty(n.languages.markup.tag,"addAttribute",{value:function(s,a){n.languages.markup.tag.inside["special-attr"].push({pattern:RegExp(/(^|["'\s])/.source+"(?:"+s+")"+/\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,"i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[a,"language-"+a],inside:n.languages[a]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}}),n.languages.html=n.languages.markup,n.languages.mathml=n.languages.markup,n.languages.svg=n.languages.markup,n.languages.xml=n.languages.extend("markup",{}),n.languages.ssml=n.languages.xml,n.languages.atom=n.languages.xml,n.languages.rss=n.languages.xml,(function(s){var a=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;s.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:RegExp("@[\\w-](?:"+/[^;{\s"']|\s+(?!\s)/.source+"|"+a.source+")*?"+/(?:;|(?=\s*\{))/.source),inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp("\\burl\\((?:"+a.source+"|"+/(?:[^\\\r\n()"']|\\[\s\S])*/.source+")\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+a.source+"$"),alias:"url"}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+a.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:a,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},s.languages.css.atrule.inside.rest=s.languages.css;var r=s.languages.markup;r&&(r.tag.addInlined("style","css"),r.tag.addAttribute("style","css"))})(n),n.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},n.languages.javascript=n.languages.extend("clike",{"class-name":[n.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),n.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,n.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:n.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:n.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:n.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:n.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:n.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),n.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:n.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),n.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),n.languages.markup&&(n.languages.markup.tag.addInlined("script","javascript"),n.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),n.languages.js=n.languages.javascript,(function(){if(typeof n>"u"||typeof document>"u")return;Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector);var s="Loading…",a=function(C,N){return"✖ Error "+C+" while fetching file: "+N},r="✖ Error: File does not exist or is empty",i={js:"javascript",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell",sh:"bash",bat:"batch",h:"c",tex:"latex"},c="data-src-status",d="loading",f="loaded",h="failed",m="pre[data-src]:not(["+c+'="'+f+'"]):not(['+c+'="'+d+'"])';function b(C,N,k){var j=new XMLHttpRequest;j.open("GET",C,!0),j.onreadystatechange=function(){j.readyState==4&&(j.status<400&&j.responseText?N(j.responseText):j.status>=400?k(a(j.status,j.statusText)):k(r))},j.send(null)}function y(C){var N=/^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(C||"");if(N){var k=Number(N[1]),j=N[2],S=N[3];return j?S?[k,Number(S)]:[k,void 0]:[k,k]}}n.hooks.add("before-highlightall",function(C){C.selector+=", "+m}),n.hooks.add("before-sanity-check",function(C){var N=C.element;if(N.matches(m)){C.code="",N.setAttribute(c,d);var k=N.appendChild(document.createElement("CODE"));k.textContent=s;var j=N.getAttribute("data-src"),S=C.language;if(S==="none"){var T=(/\.(\w+)$/.exec(j)||[,"none"])[1];S=i[T]||T}n.util.setLanguage(k,S),n.util.setLanguage(N,S);var D=n.plugins.autoloader;D&&D.loadLanguages(S),b(j,function(E){N.setAttribute(c,f);var I=y(N.getAttribute("data-range"));if(I){var O=E.split(/\r\n?|\n/g),_=I[0],M=I[1]==null?O.length:I[1];_<0&&(_+=O.length),_=Math.max(0,Math.min(_-1,O.length)),M<0&&(M+=O.length),M=Math.max(0,Math.min(M,O.length)),E=O.slice(_,M).join(`
83
- `),N.hasAttribute("data-start")||N.setAttribute("data-start",String(_+1))}k.textContent=E,n.highlightElement(k)},function(E){N.setAttribute(c,h),k.textContent=E})}}),n.plugins.fileHighlight={highlight:function(N){for(var k=(N||document).querySelectorAll(m),j=0,S;S=k[j++];)n.highlightElement(S)}};var w=!1;n.fileHighlight=function(){w||(console.warn("Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead."),w=!0),n.plugins.fileHighlight.highlight.apply(this,arguments)}})()})(db)),db.exports}var g4=m4();const da=Xu(g4);Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/};Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/});Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/});Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}});Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}});Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript"));Prism.languages.js=Prism.languages.javascript;var wC={},kC;function b4(){return kC||(kC=1,(function(t){t.languages.typescript=t.languages.extend("javascript",{"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,lookbehind:!0,greedy:!0,inside:null},builtin:/\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/}),t.languages.typescript.keyword.push(/\b(?:abstract|declare|is|keyof|readonly|require)\b/,/\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,/\btype\b(?=\s*(?:[\{*]|$))/),delete t.languages.typescript.parameter,delete t.languages.typescript["literal-property"];var e=t.languages.extend("typescript",{});delete e["class-name"],t.languages.typescript["class-name"].inside=e,t.languages.insertBefore("typescript","function",{decorator:{pattern:/@[$\w\xA0-\uFFFF]+/,inside:{at:{pattern:/^@/,alias:"operator"},function:/^[\s\S]+/}},"generic-function":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,greedy:!0,inside:{function:/^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,generic:{pattern:/<[\s\S]+/,alias:"class-name",inside:e}}}}),t.languages.ts=t.languages.typescript})(Prism)),wC}b4();(function(t){var e=t.util.clone(t.languages.javascript),n=/(?:\s|\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))\*\/)/.source,s=/(?:\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])*\})/.source,a=/(?:\{<S>*\.{3}(?:[^{}]|<BRACES>)*\})/.source;function r(d,f){return d=d.replace(/<S>/g,function(){return n}).replace(/<BRACES>/g,function(){return s}).replace(/<SPREAD>/g,function(){return a}),RegExp(d,f)}a=r(a).source,t.languages.jsx=t.languages.extend("markup",e),t.languages.jsx.tag.pattern=r(/<\/?(?:[\w.:-]+(?:<S>+(?:[\w.:$-]+(?:=(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s{'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*\/?)?>/.source),t.languages.jsx.tag.inside.tag.pattern=/^<\/?[^\s>\/]*/,t.languages.jsx.tag.inside["attr-value"].pattern=/=(?!\{)(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s'">]+)/,t.languages.jsx.tag.inside.tag.inside["class-name"]=/^[A-Z]\w*(?:\.[A-Z]\w*)*$/,t.languages.jsx.tag.inside.comment=e.comment,t.languages.insertBefore("inside","attr-name",{spread:{pattern:r(/<SPREAD>/.source),inside:t.languages.jsx}},t.languages.jsx.tag),t.languages.insertBefore("inside","special-attr",{script:{pattern:r(/=<BRACES>/.source),alias:"language-javascript",inside:{"script-punctuation":{pattern:/^=(?=\{)/,alias:"punctuation"},rest:t.languages.jsx}}},t.languages.jsx.tag);var i=function(d){return d?typeof d=="string"?d:typeof d.content=="string"?d.content:d.content.map(i).join(""):""},c=function(d){for(var f=[],h=0;h<d.length;h++){var m=d[h],b=!1;if(typeof m!="string"&&(m.type==="tag"&&m.content[0]&&m.content[0].type==="tag"?m.content[0].content[0].content==="</"?f.length>0&&f[f.length-1].tagName===i(m.content[0].content[1])&&f.pop():m.content[m.content.length-1].content==="/>"||f.push({tagName:i(m.content[0].content[1]),openedBraces:0}):f.length>0&&m.type==="punctuation"&&m.content==="{"?f[f.length-1].openedBraces++:f.length>0&&f[f.length-1].openedBraces>0&&m.type==="punctuation"&&m.content==="}"?f[f.length-1].openedBraces--:b=!0),(b||typeof m=="string")&&f.length>0&&f[f.length-1].openedBraces===0){var y=i(m);h<d.length-1&&(typeof d[h+1]=="string"||d[h+1].type==="plain-text")&&(y+=i(d[h+1]),d.splice(h+1,1)),h>0&&(typeof d[h-1]=="string"||d[h-1].type==="plain-text")&&(y=i(d[h-1])+y,d.splice(h-1,1),h--),d[h]=new t.Token("plain-text",y,null,y)}m.content&&typeof m.content!="string"&&c(m.content)}};t.hooks.add("after-tokenize",function(d){d.language!=="jsx"&&d.language!=="tsx"||c(d.tokens)})})(Prism);(function(t){var e=t.util.clone(t.languages.typescript);t.languages.tsx=t.languages.extend("jsx",e),delete t.languages.tsx.parameter,delete t.languages.tsx["literal-property"];var n=t.languages.tsx.tag;n.pattern=RegExp(/(^|[^\w$]|(?=<\/))/.source+"(?:"+n.pattern.source+")",n.pattern.flags),n.lookbehind=!0})(Prism);(function(t){var e=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;t.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:RegExp("@[\\w-](?:"+/[^;{\s"']|\s+(?!\s)/.source+"|"+e.source+")*?"+/(?:;|(?=\s*\{))/.source),inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp("\\burl\\((?:"+e.source+"|"+/(?:[^\\\r\n()"']|\\[\s\S])*/.source+")\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+e.source+"$"),alias:"url"}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+e.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:e,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},t.languages.css.atrule.inside.rest=t.languages.css;var n=t.languages.markup;n&&(n.tag.addInlined("style","css"),n.tag.addAttribute("style","css"))})(Prism);Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}};Prism.languages.webmanifest=Prism.languages.json;(function(t){var e=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,s="(?:"+n.source+"(?:[ ]+"+e.source+")?|"+e.source+"(?:[ ]+"+n.source+")?)",a=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-]<PLAIN>)(?:[ \t]*(?:(?![#:])<PLAIN>|:<PLAIN>))*/.source.replace(/<PLAIN>/g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),r=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function i(c,d){d=(d||"").replace(/m/g,"")+"m";var f=/([:\-,[{]\s*(?:\s<<prop>>[ \t]+)?)(?:<<value>>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<<prop>>/g,function(){return s}).replace(/<<value>>/g,function(){return c});return RegExp(f,d)}t.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<<prop>>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<<prop>>/g,function(){return s})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<<prop>>[ \t]+)?)<<key>>(?=\s*:\s)/.source.replace(/<<prop>>/g,function(){return s}).replace(/<<key>>/g,function(){return"(?:"+a+"|"+r+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:i(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:i(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:i(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:i(r),lookbehind:!0,greedy:!0},number:{pattern:i(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:n,important:e,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},t.languages.yml=t.languages.yaml})(Prism);var SC={},CC;function x4(){return CC||(CC=1,Prism.languages.python={comment:{pattern:/(^|[^\\])#.*/,lookbehind:!0,greedy:!0},"string-interpolation":{pattern:/(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,greedy:!0,inside:{interpolation:{pattern:/((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,lookbehind:!0,inside:{"format-spec":{pattern:/(:)[^:(){}]+(?=\}$)/,lookbehind:!0},"conversion-option":{pattern:/![sra](?=[:}]$)/,alias:"punctuation"},rest:null}},string:/[\s\S]+/}},"triple-quoted-string":{pattern:/(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,greedy:!0,alias:"string"},string:{pattern:/(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,greedy:!0},function:{pattern:/((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,lookbehind:!0},"class-name":{pattern:/(\bclass\s+)\w+/i,lookbehind:!0},decorator:{pattern:/(^[\t ]*)@\w+(?:\.\w+)*/m,lookbehind:!0,alias:["annotation","punctuation"],inside:{punctuation:/\./}},keyword:/\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,builtin:/\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,boolean:/\b(?:False|None|True)\b/,number:/\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,operator:/[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),SC}x4();(function(t){var e="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},s={bash:n,environment:{pattern:RegExp("\\$"+e),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+e),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+e),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:s},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:s},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:s.entity}}],environment:{pattern:RegExp("\\$?"+e),alias:"constant"},variable:s.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=t.languages.bash;for(var a=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],r=s.variable[1].inside,i=0;i<a.length;i++)r[a[i]]=t.languages.bash[a[i]];t.languages.sh=t.languages.bash,t.languages.shell=t.languages.bash})(Prism);(function(t){var e=/(?:\\.|[^\\\n\r]|(?:\n|\r\n?)(?![\r\n]))/.source;function n(h){return h=h.replace(/<inner>/g,function(){return e}),RegExp(/((?:^|[^\\])(?:\\{2})*)/.source+"(?:"+h+")")}var s=/(?:\\.|``(?:[^`\r\n]|`(?!`))+``|`[^`\r\n]+`|[^\\|\r\n`])+/.source,a=/\|?__(?:\|__)+\|?(?:(?:\n|\r\n?)|(?![\s\S]))/.source.replace(/__/g,function(){return s}),r=/\|?[ \t]*:?-{3,}:?[ \t]*(?:\|[ \t]*:?-{3,}:?[ \t]*)+\|?(?:\n|\r\n?)/.source;t.languages.markdown=t.languages.extend("markup",{}),t.languages.insertBefore("markdown","prolog",{"front-matter-block":{pattern:/(^(?:\s*[\r\n])?)---(?!.)[\s\S]*?[\r\n]---(?!.)/,lookbehind:!0,greedy:!0,inside:{punctuation:/^---|---$/,"front-matter":{pattern:/\S+(?:\s+\S+)*/,alias:["yaml","language-yaml"],inside:t.languages.yaml}}},blockquote:{pattern:/^>(?:[\t ]*>)*/m,alias:"punctuation"},table:{pattern:RegExp("^"+a+r+"(?:"+a+")*","m"),inside:{"table-data-rows":{pattern:RegExp("^("+a+r+")(?:"+a+")*$"),lookbehind:!0,inside:{"table-data":{pattern:RegExp(s),inside:t.languages.markdown},punctuation:/\|/}},"table-line":{pattern:RegExp("^("+a+")"+r+"$"),lookbehind:!0,inside:{punctuation:/\||:?-{3,}:?/}},"table-header-row":{pattern:RegExp("^"+a+"$"),inside:{"table-header":{pattern:RegExp(s),alias:"important",inside:t.languages.markdown},punctuation:/\|/}}}},code:[{pattern:/((?:^|\n)[ \t]*\n|(?:^|\r\n?)[ \t]*\r\n?)(?: {4}|\t).+(?:(?:\n|\r\n?)(?: {4}|\t).+)*/,lookbehind:!0,alias:"keyword"},{pattern:/^```[\s\S]*?^```$/m,greedy:!0,inside:{"code-block":{pattern:/^(```.*(?:\n|\r\n?))[\s\S]+?(?=(?:\n|\r\n?)^```$)/m,lookbehind:!0},"code-language":{pattern:/^(```).+/,lookbehind:!0},punctuation:/```/}}],title:[{pattern:/\S.*(?:\n|\r\n?)(?:==+|--+)(?=[ \t]*$)/m,alias:"important",inside:{punctuation:/==+$|--+$/}},{pattern:/(^\s*)#.+/m,lookbehind:!0,alias:"important",inside:{punctuation:/^#+|#+$/}}],hr:{pattern:/(^\s*)([*-])(?:[\t ]*\2){2,}(?=\s*$)/m,lookbehind:!0,alias:"punctuation"},list:{pattern:/(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m,lookbehind:!0,alias:"punctuation"},"url-reference":{pattern:/!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/,inside:{variable:{pattern:/^(!?\[)[^\]]+/,lookbehind:!0},string:/(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/,punctuation:/^[\[\]!:]|[<>]/},alias:"url"},bold:{pattern:n(/\b__(?:(?!_)<inner>|_(?:(?!_)<inner>)+_)+__\b|\*\*(?:(?!\*)<inner>|\*(?:(?!\*)<inner>)+\*)+\*\*/.source),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^..)[\s\S]+(?=..$)/,lookbehind:!0,inside:{}},punctuation:/\*\*|__/}},italic:{pattern:n(/\b_(?:(?!_)<inner>|__(?:(?!_)<inner>)+__)+_\b|\*(?:(?!\*)<inner>|\*\*(?:(?!\*)<inner>)+\*\*)+\*/.source),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^.)[\s\S]+(?=.$)/,lookbehind:!0,inside:{}},punctuation:/[*_]/}},strike:{pattern:n(/(~~?)(?:(?!~)<inner>)+\2/.source),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^~~?)[\s\S]+(?=\1$)/,lookbehind:!0,inside:{}},punctuation:/~~?/}},"code-snippet":{pattern:/(^|[^\\`])(?:``[^`\r\n]+(?:`[^`\r\n]+)*``(?!`)|`[^`\r\n]+`(?!`))/,lookbehind:!0,greedy:!0,alias:["code","keyword"]},url:{pattern:n(/!?\[(?:(?!\])<inner>)+\](?:\([^\s)]+(?:[\t ]+"(?:\\.|[^"\\])*")?\)|[ \t]?\[(?:(?!\])<inner>)+\])/.source),lookbehind:!0,greedy:!0,inside:{operator:/^!/,content:{pattern:/(^\[)[^\]]+(?=\])/,lookbehind:!0,inside:{}},variable:{pattern:/(^\][ \t]?\[)[^\]]+(?=\]$)/,lookbehind:!0},url:{pattern:/(^\]\()[^\s)]+/,lookbehind:!0},string:{pattern:/(^[ \t]+)"(?:\\.|[^"\\])*"(?=\)$)/,lookbehind:!0}}}}),["url","bold","italic","strike"].forEach(function(h){["url","bold","italic","strike","code-snippet"].forEach(function(m){h!==m&&(t.languages.markdown[h].inside.content.inside[m]=t.languages.markdown[m])})}),t.hooks.add("after-tokenize",function(h){if(h.language!=="markdown"&&h.language!=="md")return;function m(b){if(!(!b||typeof b=="string"))for(var y=0,w=b.length;y<w;y++){var C=b[y];if(C.type!=="code"){m(C.content);continue}var N=C.content[1],k=C.content[3];if(N&&k&&N.type==="code-language"&&k.type==="code-block"&&typeof N.content=="string"){var j=N.content.replace(/\b#/g,"sharp").replace(/\b\+\+/g,"pp");j=(/[a-z][\w-]*/i.exec(j)||[""])[0].toLowerCase();var S="language-"+j;k.alias?typeof k.alias=="string"?k.alias=[k.alias,S]:k.alias.push(S):k.alias=[S]}}}m(h.tokens)}),t.hooks.add("wrap",function(h){if(h.type==="code-block"){for(var m="",b=0,y=h.classes.length;b<y;b++){var w=h.classes[b],C=/language-(.+)/.exec(w);if(C){m=C[1];break}}var N=t.languages[m];if(N)h.content=t.highlight(f(h.content),N,m);else if(m&&m!=="none"&&t.plugins.autoloader){var k="md-"+new Date().valueOf()+"-"+Math.floor(Math.random()*1e16);h.attributes.id=k,t.plugins.autoloader.loadLanguages(m,function(){var j=document.getElementById(k);j&&(j.innerHTML=t.highlight(j.textContent,t.languages[m],m))})}}});var i=RegExp(t.languages.markup.tag.pattern.source,"gi"),c={amp:"&",lt:"<",gt:">",quot:'"'},d=String.fromCodePoint||String.fromCharCode;function f(h){var m=h.replace(i,"");return m=m.replace(/&(\w{1,8}|#x?[\da-f]{1,8});/gi,function(b,y){if(y=y.toLowerCase(),y[0]==="#"){var w;return y[1]==="x"?w=parseInt(y.slice(2),16):w=Number(y.slice(1)),d(w)}else{var C=c[y];return C||b}}),m}t.languages.md=t.languages.markdown})(Prism);Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/});Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}});delete Prism.languages.go["class-name"];var AC={},jC;function y4(){return jC||(jC=1,(function(t){for(var e=/\/\*(?:[^*/]|\*(?!\/)|\/(?!\*)|<self>)*\*\//.source,n=0;n<2;n++)e=e.replace(/<self>/g,function(){return e});e=e.replace(/<self>/g,function(){return/[^\s\S]/.source}),t.languages.rust={comment:[{pattern:RegExp(/(^|[^\\])/.source+e),lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/b?"(?:\\[\s\S]|[^\\"])*"|b?r(#*)"(?:[^"]|"(?!\1))*"\1/,greedy:!0},char:{pattern:/b?'(?:\\(?:x[0-7][\da-fA-F]|u\{(?:[\da-fA-F]_*){1,6}\}|.)|[^\\\r\n\t'])'/,greedy:!0},attribute:{pattern:/#!?\[(?:[^\[\]"]|"(?:\\[\s\S]|[^\\"])*")*\]/,greedy:!0,alias:"attr-name",inside:{string:null}},"closure-params":{pattern:/([=(,:]\s*|\bmove\s*)\|[^|]*\||\|[^|]*\|(?=\s*(?:\{|->))/,lookbehind:!0,greedy:!0,inside:{"closure-punctuation":{pattern:/^\||\|$/,alias:"punctuation"},rest:null}},"lifetime-annotation":{pattern:/'\w+/,alias:"symbol"},"fragment-specifier":{pattern:/(\$\w+:)[a-z]+/,lookbehind:!0,alias:"punctuation"},variable:/\$\w+/,"function-definition":{pattern:/(\bfn\s+)\w+/,lookbehind:!0,alias:"function"},"type-definition":{pattern:/(\b(?:enum|struct|trait|type|union)\s+)\w+/,lookbehind:!0,alias:"class-name"},"module-declaration":[{pattern:/(\b(?:crate|mod)\s+)[a-z][a-z_\d]*/,lookbehind:!0,alias:"namespace"},{pattern:/(\b(?:crate|self|super)\s*)::\s*[a-z][a-z_\d]*\b(?:\s*::(?:\s*[a-z][a-z_\d]*\s*::)*)?/,lookbehind:!0,alias:"namespace",inside:{punctuation:/::/}}],keyword:[/\b(?:Self|abstract|as|async|await|become|box|break|const|continue|crate|do|dyn|else|enum|extern|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|override|priv|pub|ref|return|self|static|struct|super|trait|try|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/,/\b(?:bool|char|f(?:32|64)|[ui](?:8|16|32|64|128|size)|str)\b/],function:/\b[a-z_]\w*(?=\s*(?:::\s*<|\())/,macro:{pattern:/\b\w+!/,alias:"property"},constant:/\b[A-Z_][A-Z_\d]+\b/,"class-name":/\b[A-Z]\w*\b/,namespace:{pattern:/(?:\b[a-z][a-z_\d]*\s*::\s*)*\b[a-z][a-z_\d]*\s*::(?!\s*<)/,inside:{punctuation:/::/}},number:/\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(?:(?:\d(?:_?\d)*)?\.)?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:f32|f64|[iu](?:8|16|32|64|size)?))?\b/,boolean:/\b(?:false|true)\b/,punctuation:/->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,operator:/[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/},t.languages.rust["closure-params"].inside.rest=t.languages.rust,t.languages.rust.attribute.inside.string=t.languages.rust.string})(Prism)),AC}y4();Prism.languages.sql={comment:{pattern:/(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,lookbehind:!0},variable:[{pattern:/@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,greedy:!0},/@[\w.$]+/],string:{pattern:/(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,greedy:!0,lookbehind:!0},identifier:{pattern:/(^|[^@\\])`(?:\\[\s\S]|[^`\\]|``)*`/,greedy:!0,lookbehind:!0,inside:{punctuation:/^`|`$/}},function:/\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i,keyword:/\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:COL|_INSERT)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:ING|S)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i,boolean:/\b(?:FALSE|NULL|TRUE)\b/i,number:/\b0x[\da-f]+\b|\b\d+(?:\.\d*)?|\B\.\d+\b/i,operator:/[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,punctuation:/[;[\]()`,.]/};const v4={".ts":"typescript",".tsx":"tsx",".js":"javascript",".jsx":"jsx",".mjs":"javascript",".cjs":"javascript",".css":"css",".scss":"scss",".sass":"scss",".less":"css",".html":"markup",".xml":"markup",".svg":"markup",".graphql":"graphql",".gql":"graphql",".java":"java",".kt":"kotlin",".kts":"kotlin",".scala":"scala",".groovy":"groovy",".gradle":"groovy",".clj":"clojure",".cljs":"clojure",".c":"c",".h":"c",".cpp":"cpp",".cc":"cpp",".cxx":"cpp",".hpp":"cpp",".hxx":"cpp",".cs":"csharp",".py":"python",".rb":"ruby",".php":"php",".lua":"lua",".pl":"perl",".pm":"perl",".r":"r",".R":"r",".hs":"haskell",".lhs":"haskell",".ex":"elixir",".exs":"elixir",".erl":"erlang",".hrl":"erlang",".rs":"rust",".go":"go",".swift":"swift",".sh":"bash",".bash":"bash",".zsh":"bash",".fish":"bash",".ps1":"powershell",".psm1":"powershell",".psd1":"powershell",".json":"json",".yaml":"yaml",".yml":"yaml",".toml":"toml",".ini":"ini",".cfg":"ini",".conf":"ini",".md":"markdown",".mdx":"markdown",".sql":"sql",".dockerfile":"docker",".nginx":"nginx",".vim":"vim",".vimrc":"vim",".diff":"diff",".patch":"diff",".makefile":"makefile",".mk":"makefile"},ye="/assets/vscode-icons/",jp={".7z":`${ye}file_type_zip.svg`,".R":`${ye}file_type_r.svg`,".adoc":`${ye}file_type_asciidoc.svg`,".asciidoc":`${ye}file_type_asciidoc.svg`,".astro":`${ye}file_type_astro.svg`,".avi":`${ye}file_type_video.svg`,".babelrc":`${ye}file_type_babel.svg`,".bash":`${ye}file_type_shell.svg`,".bat":`${ye}file_type_bat.svg`,".bmp":`${ye}file_type_image.svg`,".c":`${ye}file_type_c.svg`,".cc":`${ye}file_type_cpp.svg`,".cfg":`${ye}file_type_ini.svg`,".circleci":`${ye}file_type_circleci.svg`,".cjs":`${ye}file_type_js_official.svg`,".clj":`${ye}file_type_clojure.svg`,".cljs":`${ye}file_type_clojure.svg`,".cmd":`${ye}file_type_bat.svg`,".conf":`${ye}file_type_ini.svg`,".cpp":`${ye}file_type_cpp.svg`,".cs":`${ye}file_type_csharp.svg`,".css":`${ye}file_type_css.svg`,".csv":`${ye}file_type_csv.svg`,".cxx":`${ye}file_type_cpp.svg`,".dart":`${ye}file_type_dart.svg`,".diff":`${ye}file_type_diff.svg`,".dockerfile":`${ye}file_type_docker.svg`,".dockerignore":`${ye}file_type_docker.svg`,".env":`${ye}file_type_dotenv.svg`,".env.development":`${ye}file_type_dotenv.svg`,".env.local":`${ye}file_type_dotenv.svg`,".env.production":`${ye}file_type_dotenv.svg`,".env.test":`${ye}file_type_dotenv.svg`,".erb":`${ye}file_type_ruby.svg`,".erl":`${ye}file_type_erlang.svg`,".eslintrc":`${ye}file_type_eslint.svg`,".eslintrc.js":`${ye}file_type_eslint.svg`,".eslintrc.json":`${ye}file_type_eslint.svg`,".ex":`${ye}file_type_elixir.svg`,".exs":`${ye}file_type_elixir.svg`,".fish":`${ye}file_type_shell.svg`,".gif":`${ye}file_type_image.svg`,".git":`${ye}file_type_git.svg`,".gitattributes":`${ye}file_type_git.svg`,".github":`${ye}file_type_github.svg`,".gitignore":`${ye}file_type_git.svg`,".gitlab-ci.yml":`${ye}file_type_gitlab.svg`,".gitmodules":`${ye}file_type_git.svg`,".go":`${ye}file_type_go.svg`,".gql":`${ye}file_type_graphql.svg`,".gradle":`${ye}file_type_gradle.svg`,".graphql":`${ye}file_type_graphql.svg`,".groovy":`${ye}file_type_groovy.svg`,".gz":`${ye}file_type_zip.svg`,".h":`${ye}file_type_c.svg`,".hpp":`${ye}file_type_cpp.svg`,".hrl":`${ye}file_type_erlang.svg`,".hs":`${ye}file_type_haskell.svg`,".htm":`${ye}file_type_html.svg`,".html":`${ye}file_type_html.svg`,".ico":`${ye}file_type_image.svg`,".ini":`${ye}file_type_ini.svg`,".java":`${ye}file_type_java.svg`,".jl":`${ye}file_type_julia.svg`,".jpeg":`${ye}file_type_image.svg`,".jpg":`${ye}file_type_image.svg`,".js":`${ye}file_type_js_official.svg`,".json":`${ye}file_type_json_official.svg`,".json5":`${ye}file_type_json5.svg`,".jsonc":`${ye}file_type_json_official.svg`,".jsx":`${ye}file_type_reactjs.svg`,".kt":`${ye}file_type_kotlin.svg`,".kts":`${ye}file_type_kotlin.svg`,".kubernetes.yaml":`${ye}file_type_kubernetes.svg`,".less":`${ye}file_type_less.svg`,".lhs":`${ye}file_type_haskell.svg`,".lock":`${ye}file_type_lock.svg`,".log":`${ye}file_type_log.svg`,".lua":`${ye}file_type_lua.svg`,".markdown":`${ye}file_type_markdown.svg`,".md":`${ye}file_type_markdown.svg`,".mdown":`${ye}file_type_markdown.svg`,".mdx":`${ye}file_type_markdown.svg`,".mjs":`${ye}file_type_js_official.svg`,".mk":`${ye}file_type_makefile.svg`,".mov":`${ye}file_type_video.svg`,".mp3":`${ye}file_type_audio.svg`,".mp4":`${ye}file_type_video.svg`,".nim":`${ye}file_type_nim.svg`,".nims":`${ye}file_type_nim.svg`,".patch":`${ye}file_type_diff.svg`,".pdf":`${ye}file_type_pdf.svg`,".php":`${ye}file_type_php.svg`,".pl":`${ye}file_type_perl.svg`,".pm":`${ye}file_type_perl.svg`,".png":`${ye}file_type_image.svg`,".prettier.json":`${ye}file_type_prettier.svg`,".prettierrc":`${ye}file_type_prettier.svg`,".ps1":`${ye}file_type_powershell.svg`,".psd1":`${ye}file_type_powershell.svg`,".psm1":`${ye}file_type_powershell.svg`,".py":`${ye}file_type_python.svg`,".pyw":`${ye}file_type_python.svg`,".r":`${ye}file_type_r.svg`,".rar":`${ye}file_type_zip.svg`,".rb":`${ye}file_type_ruby.svg`,".rs":`${ye}file_type_rust.svg`,".rst":`${ye}file_type_rst.svg`,".sass":`${ye}file_type_scss.svg`,".scala":`${ye}file_type_scala.svg`,".scss":`${ye}file_type_scss.svg`,".sh":`${ye}file_type_shell.svg`,".sql":`${ye}file_type_sql.svg`,".sty":`${ye}file_type_latex.svg`,".svelte":`${ye}file_type_svelte.svg`,".svg":`${ye}file_type_svg.svg`,".swift":`${ye}file_type_swift.svg`,".tar":`${ye}file_type_tar.svg`,".tar.bz2":`${ye}file_type_zip.svg`,".tar.gz":`${ye}file_type_zip.svg`,".terraform":`${ye}file_type_terraform.svg`,".tex":`${ye}file_type_latex.svg`,".toml":`${ye}file_type_toml.svg`,".travis.yml":`${ye}file_type_travis.svg`,".ts":`${ye}file_type_typescript_official.svg`,".tsv":`${ye}file_type_tsv.svg`,".tsx":`${ye}file_type_typescript_official.svg`,".txt":`${ye}file_type_text.svg`,".vue":`${ye}file_type_vue.svg`,".webm":`${ye}file_type_video.svg`,".webp":`${ye}file_type_image.svg`,".xml":`${ye}file_type_xml.svg`,".yaml":`${ye}file_type_yaml_official.svg`,".yml":`${ye}file_type_yaml_official.svg`,".zig":`${ye}file_type_zig.svg`,".zip":`${ye}file_type_zip.svg`,".zsh":`${ye}file_type_shell.svg`,"CMakeLists.txt":`${ye}file_type_cmake.svg`,"Cargo.lock":`${ye}file_type_cargo.svg`,"Cargo.toml":`${ye}file_type_cargo.svg`,Dockerfile:`${ye}file_type_docker.svg`,Gemfile:`${ye}file_type_ruby.svg`,"Gemfile.lock":`${ye}file_type_ruby.svg`,Justfile:`${ye}file_type_just.svg`,Makefile:`${ye}file_type_makefile.svg`,Pipfile:`${ye}file_type_python.svg`,"Pipfile.lock":`${ye}file_type_python.svg`,Procfile:`${ye}file_type_procfile.svg`,Vagrantfile:`${ye}file_type_vagrant.svg`,"azure-pipelines.yml":`${ye}file_type_azurepipelines.svg`,"build.gradle":`${ye}file_type_gradle.svg`,"build.sbt":`${ye}file_type_scala.svg`,"docker-compose.yaml":`${ye}file_type_docker.svg`,"docker-compose.yml":`${ye}file_type_docker.svg`,dune:`${ye}file_type_dune.svg`,"gatsby-config.js":`${ye}file_type_gatsby.svg`,"go.mod":`${ye}file_type_go.svg`,"go.sum":`${ye}file_type_go.svg`,"heroku.yml":`${ye}file_type_heroku.svg`,"jsconfig.json":`${ye}file_type_jsconfig.svg`,"kubernetes.yaml":`${ye}file_type_kubernetes.svg`,makefile:`${ye}file_type_makefile.svg`,"meson.build":`${ye}file_type_meson.svg`,"mix.exs":`${ye}file_type_elixir.svg`,"next.config.js":`${ye}file_type_nextjs.svg`,"nuxt.config.js":`${ye}file_type_nuxtjs.svg`,"package-lock.json":`${ye}file_type_npm.svg`,"package.json":`${ye}file_type_npm.svg`,"pnpm-lock.yaml":`${ye}file_type_pnpm.svg`,"pom.xml":`${ye}file_type_maven.svg`,"pubspec.lock":`${ye}file_type_dart.svg`,"pubspec.yaml":`${ye}file_type_dart.svg`,"pyproject.toml":`${ye}file_type_python.svg`,"rebar.config":`${ye}file_type_erlang.svg`,"requirements.txt":`${ye}file_type_python.svg`,"terraform.tfvars":`${ye}file_type_terraform.svg`,"tox.ini":`${ye}file_type_tox.svg`,"tsconfig.json":`${ye}file_type_tsconfig.svg`,"vite.config.js":`${ye}file_type_vite.svg`,"vite.config.ts":`${ye}file_type_vite.svg`,"webpack.config.js":`${ye}file_type_webpack.svg`,"yarn.lock":`${ye}file_type_yarn.svg`,default:`${ye}default_file.svg`},jN={conflict:{icon:"C",color:"#ff5555",label:"Conflicts"},modified:{icon:"M",color:"#c89a5a",label:"Modified"},added:{icon:"A",color:"#5cb88a",label:"Added"},deleted:{icon:"D",color:"#c85a5a",label:"Deleted"},untracked:{icon:"U",color:"#6ab8c8",label:"Untracked"},renamed:{icon:"R",color:"#9a80c0",label:"Renamed"}},w4={c:()=>vt(()=>import("./prism-c-BI05wwL9.js"),[]),cpp:()=>vt(()=>import("./prism-c-BI05wwL9.js"),[]).then(()=>vt(()=>import("./prism-cpp-CK2Ly5dS.js").then(t=>t.p),__vite__mapDeps([7,1]))),java:()=>vt(()=>import("./prism-java-CK6tws4L.js").then(t=>t.p),__vite__mapDeps([8,1])),scala:()=>vt(()=>import("./prism-java-CK6tws4L.js").then(t=>t.p),__vite__mapDeps([8,1])).then(()=>vt(()=>import("./prism-scala-BjNo2HkN.js"),[])),csharp:()=>vt(()=>import("./prism-csharp-ByDDDiWW.js").then(t=>t.p),__vite__mapDeps([9,1])),kotlin:()=>vt(()=>import("./prism-kotlin-B1uvbSyh.js"),[]),groovy:()=>vt(()=>import("./prism-groovy-CGzo1uDg.js"),[]),ruby:()=>vt(()=>import("./prism-ruby-CQBUuZIF.js").then(t=>t.p),__vite__mapDeps([10,1])),php:()=>vt(()=>import("./prism-markup-templating-Ct1xsyfA.js"),[]).then(()=>vt(()=>import("./prism-php-Dt9698bA.js").then(t=>t.p),__vite__mapDeps([11,1]))),scss:()=>vt(()=>import("./prism-scss-CeN16CFC.js").then(t=>t.p),__vite__mapDeps([12,1])),toml:()=>vt(()=>import("./prism-toml-BrQIw_NO.js"),[]),docker:()=>vt(()=>import("./prism-docker-MnIa7k-I.js"),[]),swift:()=>vt(()=>import("./prism-swift--kriB360.js"),[]),lua:()=>vt(()=>import("./prism-lua-Cp_o7ONA.js"),[]),perl:()=>vt(()=>import("./prism-perl-UZfqnD51.js").then(t=>t.p),__vite__mapDeps([13,1])),r:()=>vt(()=>import("./prism-r-TxsGuNZJ.js"),[]),haskell:()=>vt(()=>import("./prism-haskell-Ce8aBmia.js").then(t=>t.p),__vite__mapDeps([14,1])),elixir:()=>vt(()=>import("./prism-elixir-df27OMMQ.js").then(t=>t.p),__vite__mapDeps([15,1])),erlang:()=>vt(()=>import("./prism-erlang-C3Aahqfa.js"),[]),clojure:()=>vt(()=>import("./prism-clojure-u3w_tjfy.js"),[]),graphql:()=>vt(()=>import("./prism-graphql-DJ177lJj.js"),[]),nginx:()=>vt(()=>import("./prism-nginx-43e5TboO.js"),[]),vim:()=>vt(()=>import("./prism-vim-uciLQ2PQ.js"),[]),diff:()=>vt(()=>import("./prism-diff-jN23ddHu.js"),[]),ini:()=>vt(()=>import("./prism-ini-DX5Euru7.js"),[]),powershell:()=>vt(()=>import("./prism-powershell-Ud14i9UV.js"),[]),makefile:()=>vt(()=>import("./prism-makefile-Dk8DMwhC.js"),[])},fb=new Map;async function NN(t){if(t in da.languages)return!0;const e=w4[t];if(!e)return!1;let n=fb.get(t);n||(n=e(),fb.set(t,n));try{return await n,t in da.languages}catch{return!1}finally{fb.delete(t)}}function rV(t){da.highlightElement(t)}function np(t){return v4[t]||"plaintext"}function k4(t){return t in da.languages}function NC(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function Mo(t,e){if(!t)return"";const n=da.languages[e];if(!n)return NC(t);try{return da.highlight(t,n,e)}catch{return NC(t)}}function S4(t){if(typeof document>"u")throw new Error("Clipboard unavailable");const e=document.createElement("textarea");e.value=t,e.setAttribute("readonly","true"),e.style.position="fixed",e.style.top="-9999px",e.style.left="-9999px",document.body.appendChild(e),e.select(),e.setSelectionRange(0,e.value.length);const n=document.execCommand("copy");if(document.body.removeChild(e),!n)throw new Error("Legacy clipboard copy failed")}async function Lu(t){var e;if(typeof navigator<"u"&&((e=navigator.clipboard)!=null&&e.writeText)){await navigator.clipboard.writeText(t);return}S4(t)}function TN(t){const e=document.createElement("div");e.innerHTML=t;const n=e.firstElementChild;n&&(n.style.cssText+='font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif;font-size:14px;color:#1f2328;line-height:1.6');const s={table:"border-collapse:collapse;width:100%;border:1px solid #d1d9e0;margin:12px 0;font-size:13px",th:"background:#f6f8fa;color:#1f2328;padding:6px 12px;border:1px solid #d1d9e0;font-weight:600;text-align:left;white-space:nowrap",td:"padding:6px 12px;border:1px solid #d1d9e0;color:#1f2328;vertical-align:top",h1:"font-size:2em;font-weight:700;margin:24px 0 12px;padding-bottom:6px;border-bottom:2px solid #d1d9e0;color:#1f2328",h2:"font-size:1.5em;font-weight:700;margin:20px 0 10px;padding-bottom:4px;border-bottom:1px solid #d1d9e0;color:#1f2328",h3:"font-size:1.25em;font-weight:600;margin:16px 0 8px;color:#1f2328",h4:"font-size:1.1em;font-weight:600;margin:12px 0 6px;color:#1f2328",h5:"font-size:1em;font-weight:600;margin:10px 0 4px;color:#1f2328",h6:"font-size:0.85em;font-weight:600;margin:10px 0 4px;color:#656d76",pre:'background:#f6f8fa;padding:16px;border-radius:6px;overflow:auto;border:1px solid #d1d9e0;font-family:"SFMono-Regular",Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;line-height:1.5;margin:12px 0;color:#1f2328',blockquote:"border-left:4px solid #d1d9e0;padding:4px 16px;color:#656d76;margin:12px 0;background:#f6f8fa",a:"color:#0969da;text-decoration:underline",ul:"padding-left:28px;margin:8px 0",ol:"padding-left:28px;margin:8px 0",li:"margin:4px 0;color:#1f2328",hr:"border:none;border-top:2px solid #d1d9e0;margin:20px 0",strong:"font-weight:700;color:#1f2328",em:"font-style:italic",p:"margin:8px 0;line-height:1.6"};for(const[r,i]of Object.entries(s))for(const c of Array.from(e.querySelectorAll(r)))c.style.cssText+=i;for(const r of Array.from(e.querySelectorAll("code"))){const i=r.parentElement;i&&i.tagName.toLowerCase()==="pre"?r.style.cssText+='font-family:"SFMono-Regular",Consolas,"Liberation Mono",Menlo,monospace;background:transparent;padding:0;font-size:inherit;color:inherit':r.style.cssText+='background:#eff1f3;padding:2px 6px;border-radius:4px;font-family:"SFMono-Regular",Consolas,"Liberation Mono",Menlo,monospace;font-size:0.85em;color:#cf222e'}for(const r of Array.from(e.querySelectorAll("table"))){r.setAttribute("width","100%"),r.querySelectorAll("tbody tr").forEach((S,T)=>{T%2===0?S.style.cssText+="background:#ffffff":S.style.cssText+="background:#f6f8fa"});const c=Array.from(r.querySelectorAll("thead th, thead td, tr:first-child th, tr:first-child td")),d=c.length;if(d<2)continue;const f=Array.from(r.querySelectorAll("tr")),h=new Array(d).fill(0),m=new Array(d).fill(0);c.forEach((S,T)=>{const D=(S.textContent||"").trim();D.length,h[T]=D.length});for(const S of f)Array.from(S.children).forEach((D,E)=>{if(E<d){const I=(D.textContent||"").trim();m[E]=Math.max(m[E],I.length);const O=I.split(/\s+/);for(const _ of O)h[E]=Math.max(h[E],_.length)}});const b=h.reduce((S,T)=>S+T,0)||1,y=h.map(S=>{const T=S<=3?3:S<=6?5:8;return Math.max(T,Math.round(S/b*50))}),w=y.reduce((S,T)=>S+T,0),C=Math.max(0,100-w),N=m.reduce((S,T)=>S+T,0)||1,k=y.map((S,T)=>S+Math.round(m[T]/N*C)),j=k.reduce((S,T)=>S+T,0);k[k.length-1]+=100-j;for(const S of f)Array.from(S.children).forEach((D,E)=>{if(E<d){const I=`${k[E]}%`;D.setAttribute("width",I),D.style.cssText+=`;width:${I}`}})}const a={"hljs-keyword":"color:#cf222e;font-weight:600","hljs-built_in":"color:#8250df","hljs-type":"color:#8250df","hljs-literal":"color:#0550ae","hljs-number":"color:#0550ae","hljs-string":"color:#0a3069","hljs-comment":"color:#6e7781;font-style:italic","hljs-doctag":"color:#cf222e","hljs-meta":"color:#6e7781","hljs-attr":"color:#8250df","hljs-attribute":"color:#0550ae","hljs-name":"color:#116329","hljs-tag":"color:#116329","hljs-title":"color:#8250df;font-weight:600","hljs-variable":"color:#953800","hljs-params":"color:#1f2328","hljs-function":"color:#8250df","hljs-selector-tag":"color:#116329","hljs-selector-class":"color:#8250df","hljs-selector-id":"color:#0550ae","hljs-property":"color:#0550ae","hljs-regexp":"color:#0a3069","hljs-symbol":"color:#0550ae","hljs-addition":"color:#116329;background:#dafbe1","hljs-deletion":"color:#cf222e;background:#ffebe9"};for(const[r,i]of Object.entries(a))for(const c of Array.from(e.querySelectorAll(`.${r}`)))c.style.cssText+=i;return e.innerHTML}async function _N(t,e){const n=document.createElement("div");n.innerHTML=t,n.style.cssText='position:fixed;left:-9999px;top:-9999px;opacity:0;color:#1f2328;background:#ffffff;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif;font-size:14px;line-height:1.6',document.body.appendChild(n);const s=document.createRange();s.selectNodeContents(n);const a=window.getSelection();a&&(a.removeAllRanges(),a.addRange(s));const r=document.execCommand("copy");if(document.body.removeChild(n),a&&a.removeAllRanges(),!r)throw new Error("Rich text copy failed")}function os({content:t,children:e,position:n="top",delay:s=150,maxWidth:a=280,disabled:r=!1,className:i=""}){const[c,d]=x.useState(!1),[f,h]=x.useState(!1),[m,b]=x.useState({top:0,left:0}),y=x.useRef(null),w=x.useRef(null),C=x.useRef(null),N=x.useRef(null),k=x.useCallback(()=>{if(!y.current||!w.current)return;const D=y.current.getBoundingClientRect(),E=w.current.getBoundingClientRect(),I=window.scrollY,O=window.scrollX,_=8;let M=0,R=0;switch(n){case"top":M=D.top+I-E.height-_,R=D.left+O+(D.width-E.width)/2;break;case"bottom":M=D.bottom+I+_,R=D.left+O+(D.width-E.width)/2;break;case"left":M=D.top+I+(D.height-E.height)/2,R=D.left+O-E.width-_;break;case"right":M=D.top+I+(D.height-E.height)/2,R=D.right+O+_;break}const z=window.innerWidth,$=window.innerHeight;R<_&&(R=_),R+E.width>z-_&&(R=z-E.width-_),M<_&&(M=_),M+E.height>$+I-_&&(M=$+I-E.height-_),b({top:M,left:R})},[n]),j=x.useCallback(()=>{r||(N.current&&(clearTimeout(N.current),N.current=null),C.current=setTimeout(()=>{h(!0),d(!0)},s))},[s,r]),S=x.useCallback(()=>{C.current&&(clearTimeout(C.current),C.current=null),d(!1),N.current=setTimeout(()=>{h(!1)},100)},[]);x.useEffect(()=>{f&&c&&requestAnimationFrame(k)},[f,c,k]),x.useEffect(()=>()=>{C.current&&clearTimeout(C.current),N.current&&clearTimeout(N.current)},[]);const T=f&&t&&ac.createPortal(o.jsxs("div",{ref:w,className:`tide-tooltip tide-tooltip--${n} ${c?"tide-tooltip--visible":"tide-tooltip--hiding"} ${i}`,style:{position:"absolute",top:m.top,left:m.left,maxWidth:a,zIndex:1e4},role:"tooltip",children:[o.jsx("div",{className:"tide-tooltip__content",children:t}),o.jsx("div",{className:"tide-tooltip__arrow"})]}),document.body);return o.jsxs(o.Fragment,{children:[o.jsx("span",{ref:y,className:"tide-tooltip-trigger",onMouseEnter:j,onMouseLeave:S,onFocus:j,onBlur:S,style:{display:"inline-flex"},children:e}),T]})}function iV({text:t,title:e,position:n="top",size:s="md"}){const a=o.jsxs(o.Fragment,{children:[e&&o.jsx("div",{className:"tide-tooltip__title",children:e}),o.jsx("div",{className:"tide-tooltip__text",children:t})]});return o.jsx(os,{content:a,position:n,children:o.jsx("span",{className:`tide-help-icon tide-help-icon--${s}`,tabIndex:0,children:"?"})})}function pb(t,e){return t?Mo(t,e):""}function C4(t,e,n){const s=t.split(`
84
- `),a=e.split(`
85
- `),r=n||"plaintext",i=s.length,c=a.length,d=Array(i+1).fill(null).map(()=>Array(c+1).fill(0));for(let D=1;D<=i;D++)for(let E=1;E<=c;E++)s[D-1]===a[E-1]?d[D][E]=d[D-1][E-1]+1:d[D][E]=Math.max(d[D-1][E],d[D][E-1]);const f=[];let h=i,m=c;for(;h>0||m>0;)h>0&&m>0&&s[h-1]===a[m-1]?(f.push({type:"equal",origIdx:h-1,modIdx:m-1}),h--,m--):m>0&&(h===0||d[h][m-1]>=d[h-1][m])?(f.push({type:"insert",modIdx:m-1}),m--):h>0&&(f.push({type:"delete",origIdx:h-1}),h--);f.reverse();const b=[],y=[],w=[],C=[];w.push({leftLine:0,rightLine:0});let N=-1,k=0,j=-1,S=0;const T=()=>{(k>0||S>0)&&C.push({leftStart:N>=0?N:b.length,leftCount:k,rightStart:j>=0?j:y.length,rightCount:S,type:k>0&&S>0?"modified":k>0?"removed":"added"}),N=-1,k=0,j=-1,S=0};for(const D of f)if(D.type==="equal"){T();const E=s[D.origIdx],I=pb(E,r);b.push({num:D.origIdx+1,text:E,highlighted:I,type:"unchanged"}),y.push({num:D.modIdx+1,text:E,highlighted:I,type:"unchanged"}),w.push({leftLine:b.length,rightLine:y.length})}else if(D.type==="delete"){N<0&&(N=b.length),k++;const E=s[D.origIdx],I=pb(E,r);b.push({num:D.origIdx+1,text:E,highlighted:I,type:"removed"})}else{j<0&&(j=y.length),S++;const E=a[D.modIdx],I=pb(E,r);y.push({num:D.modIdx+1,text:E,highlighted:I,type:"added"})}return T(),w.push({leftLine:b.length,rightLine:y.length}),{leftLines:b,rightLines:y,alignments:w,changeBlocks:C}}function A4(t,e,n,s,a,r){if(e<=0||n<=0)return 0;const i=t/a;let c=null,d=null;for(let k=0;k<s.length-1;k++){const j=s[k],S=s[k+1],T=r?j.leftLine:j.rightLine,D=r?S.leftLine:S.rightLine;if(i>=T&&i<D){c=j,d=S;break}}if(!c||!d)return t/Math.max(1,e-1)*n;const f=r?c.leftLine:c.rightLine,h=r?d.leftLine:d.rightLine,m=r?c.rightLine:c.leftLine,b=r?d.rightLine:d.leftLine,y=h-f,w=b-m;if(y===0)return m*a;const C=(i-f)/y;return(m+C*w)*a}const j4=[".md",".mdx",".markdown"];function gx({originalContent:t,modifiedContent:e,filename:n,language:s,initialModifiedOnly:a=!1}){const{t:r}=dt(["terminal","common"]),i=x.useRef(null),c=x.useRef(null),d=x.useRef(null),f=x.useRef(null),h=x.useRef(null),m=x.useRef(null),b=x.useRef(null),[y,w]=x.useState("idle"),[C,N]=x.useState("idle"),[k,j]=x.useState(a),[S,T]=x.useState(0);x.useEffect(()=>{s&&s!=="plaintext"&&NN(s).then(()=>T(Z=>Z+1))},[s]);const D=!t,E=!e,I=x.useMemo(()=>{const Z=n.substring(n.lastIndexOf(".")).toLowerCase();return j4.includes(Z)},[n]),O=x.useCallback(async()=>{try{if(I&&k&&d.current){const Z=d.current.innerHTML,ie=TN(Z),me=d.current.innerText;await _N(ie,me)}else await Lu(e);w("copied"),setTimeout(()=>w("idle"),2e3)}catch(Z){console.error("Copy modified content failed:",Z),w("error"),setTimeout(()=>w("idle"),2e3)}},[e,I,k]),_=x.useCallback(async()=>{if(!d.current){console.error("Copy HTML: markdown content ref is not available"),N("error"),setTimeout(()=>N("idle"),2e3);return}try{const Z=d.current.innerHTML;await Lu(Z),N("copied"),setTimeout(()=>N("idle"),2e3)}catch(Z){console.error("Copy HTML failed:",Z),N("error"),setTimeout(()=>N("idle"),2e3)}},[]),{leftLines:M,rightLines:R,alignments:z,changeBlocks:$}=x.useMemo(()=>C4(t,e,s),[t,e,s,S]),W=x.useCallback(()=>{const Z=f.current,ie=i.current,me=c.current;if(!Z||!ie||!me)return;const Ee=window.devicePixelRatio||1,Te=Z.parentElement;if(!Te)return;const Ve=Te.clientWidth,We=Te.clientHeight;if(Ve===0||We===0)return;const ee=Math.round(Ve*Ee),ne=Math.round(We*Ee);(Z.width!==ee||Z.height!==ne)&&(Z.width=ee,Z.height=ne);const Ne=Z.getContext("2d");if(!Ne)return;Ne.setTransform(Ee,0,0,Ee,0,0),Ne.clearRect(0,0,Ve,We);const ze=Te.getBoundingClientRect(),st=ie.getBoundingClientRect(),pe=me.getBoundingClientRect(),Be=st.top-ze.top,oe=pe.top-ze.top,de=ie.scrollTop,He=me.scrollTop,et=ie.clientHeight,ct=me.clientHeight;for(const fe of $){const X=Be+fe.leftStart*K-de,ae=Be+(fe.leftStart+Math.max(fe.leftCount,.5))*K-de,ke=oe+fe.rightStart*K-He,J=oe+(fe.rightStart+Math.max(fe.rightCount,.5))*K-He;if(ae<Be&&J<oe||X>Be+et+20&&ke>oe+ct+20)continue;fe.type==="modified"?(Ne.fillStyle="rgba(90, 130, 180, 0.2)",Ne.strokeStyle="rgba(90, 130, 180, 0.45)"):fe.type==="removed"?(Ne.fillStyle="rgba(200, 90, 90, 0.2)",Ne.strokeStyle="rgba(200, 90, 90, 0.45)"):(Ne.fillStyle="rgba(92, 184, 138, 0.2)",Ne.strokeStyle="rgba(92, 184, 138, 0.45)");const he=Ve*.5;Ne.lineWidth=1,Ne.save(),Ne.beginPath(),Ne.rect(0,Be,Ve,We-Be),Ne.clip(),Ne.beginPath(),Ne.moveTo(0,X),Ne.bezierCurveTo(he,X,he,ke,Ve,ke),Ne.lineTo(Ve,J),Ne.bezierCurveTo(he,J,he,ae,0,ae),Ne.closePath(),Ne.fill(),Ne.stroke(),Ne.restore()}},[$]);x.useEffect(()=>{if(k||D||E)return;const Z=f.current,ie=i.current,me=c.current;if(!Z||!ie||!me)return;const Ee=Z.parentElement;if(!Ee)return;const Te=new ResizeObserver(()=>{W()});return Te.observe(Ee),requestAnimationFrame(()=>W()),()=>{Te.disconnect(),h.current&&cancelAnimationFrame(h.current)}},[k,D,E,W]);const{leftBoundaries:L,rightBoundaries:F}=x.useMemo(()=>{const Z=new Map,ie=new Map;for(const me of $){if(me.leftCount>0){const Ee=me.leftStart,Te=me.leftStart+me.leftCount-1;Z.set(Ee,Z.has(Ee)?"both":"top"),Ee===Te?Z.set(Ee,"both"):Z.set(Te,Z.has(Te)?"both":"bottom")}if(me.rightCount>0){const Ee=me.rightStart,Te=me.rightStart+me.rightCount-1;ie.set(Ee,ie.has(Ee)?"both":"top"),Ee===Te?ie.set(Ee,"both"):ie.set(Te,ie.has(Te)?"both":"bottom")}}return{leftBoundaries:Z,rightBoundaries:ie}},[$]),H=x.useMemo(()=>{const Z=R.filter(me=>me.type==="added").length,ie=M.filter(me=>me.type==="removed").length;return{added:Z,removed:ie}},[M,R]),V=x.useMemo(()=>{const Z=[];let ie=!1;R.forEach((Ee,Te)=>{Ee.type==="added"?ie||(Z.push(Te),ie=!0):ie=!1});let me=!1;return M.forEach((Ee,Te)=>{if(Ee.type==="removed"){if(!me){const Ve=Math.min(Te,R.length-1);Z.includes(Ve)||Z.push(Ve),me=!0}}else me=!1}),Z.sort((Ee,Te)=>Ee-Te)},[M,R]),[G,B]=x.useState(0),K=20,se=x.useCallback(Z=>{const ie=i.current,me=c.current;if(!ie||!me||m.current&&m.current!==Z)return;m.current=Z,b.current&&cancelAnimationFrame(b.current);const Ee=Z==="left"?ie:me,Te=Z==="left"?me:ie;Te.scrollLeft=Ee.scrollLeft;const Ve=A4(Ee.scrollTop,Ee.scrollHeight-Ee.clientHeight,Te.scrollHeight-Te.clientHeight,z,K,Z==="left");Te.scrollTop=Ve,h.current&&cancelAnimationFrame(h.current),h.current=requestAnimationFrame(()=>{W(),h.current=null}),b.current=requestAnimationFrame(()=>{m.current=null})},[z,W]);x.useEffect(()=>{const Z=i.current,ie=c.current;if(!Z||!ie)return;const me=()=>se("left"),Ee=()=>se("right");return Z.addEventListener("scroll",me),ie.addEventListener("scroll",Ee),()=>{Z.removeEventListener("scroll",me),ie.removeEventListener("scroll",Ee),b.current&&cancelAnimationFrame(b.current)}},[se]);const q=x.useCallback(Z=>{if(Z<0||Z>=V.length)return;const me=V[Z]*K;c.current&&(c.current.scrollTop=me),B(Z)},[V]),be=x.useCallback(()=>{const Z=Math.min(G+1,V.length-1);q(Z)},[G,V.length,q]),Ce=x.useCallback(()=>{const Z=Math.max(G-1,0);q(Z)},[G,q]);return x.useEffect(()=>{V.length>0&&setTimeout(()=>{q(0),requestAnimationFrame(()=>W())},100)},[V,q,W]),o.jsxs("div",{className:"diff-viewer",children:[o.jsxs("div",{className:"diff-viewer-header",children:[o.jsx("div",{className:"diff-viewer-filename",children:n}),o.jsx("div",{className:"diff-viewer-nav",children:V.length>0&&o.jsxs(o.Fragment,{children:[o.jsx(os,{content:"Previous change (Up)",position:"bottom",children:o.jsx("button",{className:"diff-nav-btn",onClick:Ce,disabled:G===0,children:"↑"})}),o.jsxs("span",{className:"diff-nav-counter",children:[G+1," / ",V.length]}),o.jsx(os,{content:"Next change (Down)",position:"bottom",children:o.jsx("button",{className:"diff-nav-btn",onClick:be,disabled:G===V.length-1,children:"↓"})})]})}),o.jsxs("div",{className:"diff-viewer-stats",children:[H.added>0&&o.jsxs("span",{className:"diff-stat added",children:["+",H.added]}),H.removed>0&&o.jsxs("span",{className:"diff-stat removed",children:["-",H.removed]})]}),o.jsxs("div",{className:"diff-viewer-actions",children:[!D&&!E&&o.jsx(os,{content:k?"Show diff view":"View only modified",position:"bottom",children:o.jsx("button",{className:`diff-toggle-btn ${k?"active":""}`,onClick:()=>j(!k),children:r(k?"terminal:diffViewer.showDiff":"terminal:diffViewer.modifiedOnly")})}),o.jsx(os,{content:I&&k?"Copy as rich text":"Copy modified content",position:"bottom",children:o.jsx("button",{className:`diff-copy-btn ${y}`,onClick:O,children:y==="copied"?`✓ ${r("terminal:diffViewer.copied")}`:y==="error"?`✗ ${r("terminal:diffViewer.errorCopy")}`:r(I&&k?"terminal:diffViewer.copyRichText":"common:buttons.copy")})}),I&&k&&o.jsx(os,{content:"Copy as HTML tags (for Google Docs, HTML editors)",position:"bottom",children:o.jsx("button",{className:`diff-copy-btn ${C}`,onClick:_,children:C==="copied"?`✓ ${r("terminal:diffViewer.copied")}`:C==="error"?`✗ ${r("terminal:diffViewer.errorCopy")}`:r("terminal:diffViewer.copyHtml")})})]})]}),o.jsxs("div",{className:`diff-viewer-panels ${k||D||E?"modified-only":""}`,children:[!k&&!D&&o.jsxs("div",{className:"diff-panel diff-panel-original",children:[o.jsx("div",{className:"diff-panel-header",children:o.jsx("span",{className:"diff-panel-label",children:r("terminal:diffViewer.originalHead")})}),o.jsx("div",{className:"diff-panel-content",ref:i,children:M.map((Z,ie)=>{const me=L.get(ie),Ee=me==="both"?"diff-hunk-top diff-hunk-bottom":me==="top"?"diff-hunk-top":me==="bottom"?"diff-hunk-bottom":"";return o.jsxs("div",{className:`diff-line diff-line-${Z.type} ${Ee}`,children:[o.jsx("span",{className:"diff-line-num",children:Z.num}),o.jsx("span",{className:"diff-line-content",dangerouslySetInnerHTML:{__html:Z.highlighted||"&nbsp;"}})]},ie)})})]}),!k&&!D&&!E&&o.jsx("div",{className:"diff-connector-gutter",children:o.jsx("canvas",{ref:f})}),!E&&o.jsxs("div",{className:"diff-panel diff-panel-modified",children:[o.jsx("div",{className:"diff-panel-header",children:o.jsx("span",{className:"diff-panel-label",children:r(k||D?"terminal:diffViewer.modifiedContent":"terminal:diffViewer.modifiedWorking")})}),k&&I?o.jsx("div",{className:"diff-panel-content diff-markdown-content",ref:d,children:o.jsx("div",{className:"markdown-content",children:o.jsx(Fr,{remarkPlugins:[zr],children:e})})}):o.jsx("div",{className:"diff-panel-content",ref:c,children:R.map((Z,ie)=>{const me=F.get(ie),Ee=me==="both"?"diff-hunk-top diff-hunk-bottom":me==="top"?"diff-hunk-top":me==="bottom"?"diff-hunk-bottom":"";return o.jsxs("div",{className:`diff-line diff-line-${Z.type} ${Ee}`,children:[o.jsx("span",{className:"diff-line-num",children:Z.num}),o.jsx("span",{className:"diff-line-content",dangerouslySetInnerHTML:{__html:Z.highlighted||"&nbsp;"}})]},ie)})})]})]})]})}function N4(t,e){if(!t||t.startsWith("/")||!e||!e.startsWith("/"))return t;const n=t.replace(/^\.\//,""),s=e.split("/").filter(Boolean),a=n.split("/").filter(Boolean),r=[...s];for(const i of a)if(i!=="."){if(i===".."){r.length>0&&r.pop();continue}r.push(i)}return`/${r.join("/")}`}function EN(t){if(!t)return{path:t};const e=t.trim().replace(/^`|`$/g,"").replace(/[),.;]+$/g,""),n=e.match(/^(.*)#L(\d+)(?:C\d+)?$/i);if(n)return{path:n[1],line:Number(n[2])};const s=e.match(/^(.+?\.[^:\s]+):(\d+)(?::\d+)?$/);return s&&s[1].includes(".")?{path:s[1],line:Number(s[2])}:{path:e}}function sh(t,e){const n=EN(t);return{path:N4(n.path,e),line:n.line}}function T4(t,e){try{const n=t.split(`
86
- `),s=e.split(`
87
- `),a=[];let r=0;for(let i=0;i<s.length;i++){const d=s[i].match(/^@@\s+-(\d+)(?:,(\d+))?\s+\+(\d+)(?:,(\d+))?\s+@@/);if(!d)continue;const f=parseInt(d[3],10),h=parseInt(d[4]??"1",10),m=f-1;for(;r<m&&r<n.length;)a.push(n[r]),r++;let b=0;for(let y=i+1;y<s.length;y++){const w=s[y];if(w.startsWith("@@")||w.startsWith("diff "))break;w.startsWith("---")||w.startsWith("+++")||w.startsWith("index ")||w.startsWith("new file")||w.startsWith("deleted file")||w.startsWith("\\")||(w.startsWith("-")?a.push(w.slice(1)):w.startsWith("+")?(b++,r++):(a.push(w.startsWith(" ")?w.slice(1):w),b++,r++))}}for(;r<n.length;)a.push(n[r]),r++;return a.join(`
88
- `)}catch{return null}}const TC=[".md",".mdx",".markdown"],_C=[".png",".jpg",".jpeg",".gif",".webp",".bmp",".ico",".svg"],EC=[".pdf"];function MN({isOpen:t,onClose:e,filePath:n,action:s,editData:a,searchRoot:r}){const{t:i}=dt(["terminal","common"]),[c,d]=x.useState(null),[f,h]=x.useState(!1),[m,b]=x.useState(null),[y,w]=x.useState([]),[C,N]=x.useState([]),[k,j]=x.useState("idle"),[S,T]=x.useState("idle"),[D,E]=x.useState("idle"),[I,O]=x.useState("idle"),[_,M]=x.useState(null),[R,z]=x.useState(null),[$,W]=x.useState(!1),L=x.useRef(null),F=x.useRef(null),H=x.useRef(null),V=x.useMemo(()=>EN(n),[n]),G=V.path,B=(a==null?void 0:a.targetLine)??V.line,K=(a==null?void 0:a.highlightRange)||void 0;x.useEffect(()=>{t&&G?(w([]),N([]),M(null),z(null),Ne()):(d(null),b(null),w([]),N([]),M(null),z(null))},[t,G]),x.useEffect(()=>{t&&H.current&&H.current.focus()},[t]),x.useEffect(()=>{if(!t)return;const xe=Pe=>{if(!(Pe.target instanceof HTMLInputElement||Pe.target instanceof HTMLTextAreaElement)){if(Pe.key==="Escape"){Pe.preventDefault(),Pe.stopPropagation(),e();return}if(Pe.key==="j"||Pe.key==="k"){Pe.preventDefault(),Pe.stopPropagation();const te=Pe.key==="j"?100:-100;if(F.current){const ge=F.current.querySelectorAll(".diff-panel-content");if(ge.length>0)ge.forEach(ve=>{ve.scrollBy({top:te,behavior:"smooth"})});else{const ve=F.current.querySelector(".file-viewer-code-with-lines");ve?ve.scrollBy({top:te,behavior:"smooth"}):F.current.scrollBy({top:te,behavior:"smooth"})}}return}Pe.stopPropagation()}};return window.addEventListener("keydown",xe,{capture:!0}),()=>window.removeEventListener("keydown",xe,{capture:!0})},[t,e]);const se=x.useMemo(()=>{if(!c||!a||a.highlightRange)return null;const{oldString:xe="",newString:Pe="",operation:te}=a;if(!xe&&!Pe)return null;if(te==="append"&&Pe){if(c.content.endsWith(Pe))return c.content.slice(0,c.content.length-Pe.length);const ge=c.content.lastIndexOf(Pe);return ge!==-1?c.content.slice(0,ge)+c.content.slice(ge+Pe.length):null}if(Pe){const ge=c.content.indexOf(Pe);return ge!==-1?c.content.slice(0,ge)+xe+c.content.slice(ge+Pe.length):null}return null},[c,a]),q=!!a&&!a.highlightRange&&(!!a.oldString||!!a.newString),be=(a==null?void 0:a.unifiedDiff)||_,Ce=!!be,Z=x.useMemo(()=>se!==null||!c||!be?null:T4(c.content,be),[se,c,be]),ie=se??Z??R,me=ie!==null&&(q||Ce),Ee=Ce&&!me,Te=K!==void 0;x.useEffect(()=>{if(!c||!a||a.highlightRange||me||a.unifiedDiff||_!==null)return;(async()=>{try{const Pe=c.path||G,te=await Bt(Rt(`/api/files/git-diff?path=${encodeURIComponent(Pe)}`));if(te.ok){const ge=await te.json();if(ge.diff&&ge.diff.trim()){M(ge.diff);return}}}catch{}M("")})()},[c,a,me,G,_]),x.useEffect(()=>{if(!c||!a||a.highlightRange||se!==null||Z!==null||R!==null||!q&&!Ce)return;(async()=>{try{const Pe=c.path||G,te=await Bt(Rt(`/api/files/git-original?path=${encodeURIComponent(Pe)}`));if(te.ok){const ge=await te.json();if(ge.content!==void 0&&ge.content!==c.content){z(ge.content);return}}}catch{}z("")})()},[c,a,se,Z,R,q,Ce,G]),x.useEffect(()=>{if(!c)return;const xe=np(c.extension);if(xe==="plaintext"||xe in da.languages){W(!0);return}W(!1),NN(xe).then(()=>W(!0))},[c]);const Ve=x.useMemo(()=>{if(!c||me||Ee||TC.includes(c.extension))return[];const xe=np(c.extension),Pe=da.languages[xe],te=ge=>ge.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");return c.content.split(`
89
- `).map(ge=>Pe?da.highlight(ge||" ",Pe,xe):te(ge||" "))},[c,me,Ee,$]);x.useEffect(()=>{if(!t||!c||!F.current)return;const xe=window.setTimeout(()=>{const Pe=()=>{if(!F.current)return;const te=F.current.querySelector(".file-line-highlighted");if(te){te.scrollIntoView({block:"center",behavior:"auto"});return}if(B){const ge=F.current.querySelector(`.file-viewer-line-num[data-line="${B}"]`);ge==null||ge.scrollIntoView({block:"center",behavior:"auto"})}};window.requestAnimationFrame(()=>window.requestAnimationFrame(Pe))},0);return()=>window.clearTimeout(xe)},[t,c,Te,K==null?void 0:K.offset,B]);const We=async xe=>{const Pe=xe.substring(xe.lastIndexOf(".")).toLowerCase(),te=EC.includes(Pe),ge=_C.includes(Pe),ve=te||ge?`/api/files/info?path=${encodeURIComponent(xe)}`:`/api/files/read?path=${encodeURIComponent(xe)}`,Fe=await Bt(Rt(ve)),Ke=await Fe.json();if(!Fe.ok){const at=Ke.error==="Path is a directory";return{ok:!1,error:Ke.error,isDirectory:at}}return(te||ge)&&(Ke.content=""),{ok:!0,data:Ke}},ee=async(xe,Pe)=>{var te;try{const ge=await Bt(Rt(`/api/files/resolve?name=${encodeURIComponent(xe)}&root=${encodeURIComponent(Pe)}`)),ve=await ge.json();if(ge.ok&&((te=ve.results)==null?void 0:te.length)>0)return ve.results}catch{}return[]},ne=async xe=>{var Pe;try{const te=await Bt(Rt(`/api/files/list?path=${encodeURIComponent(xe)}`)),ge=await te.json();if(te.ok&&((Pe=ge.files)==null?void 0:Pe.length)>0)return ge.files.slice(0,20).map(ve=>({name:ve.name,path:ve.path,isDirectory:ve.isDirectory,size:ve.size||0,extension:ve.extension||""}))}catch{}return[]},Ne=async()=>{h(!0),b(null),w([]),N([]);try{const xe=await We(G);if(xe.ok){d(xe.data);return}if(xe.isDirectory){const ge=await ne(G);if(ge.length>0){N(ge);return}b(xe.error||i("terminal:fileExplorer.failedToLoad"));return}const Pe=G.split("/").pop()||G,te=r||(G.startsWith("/")?G.split("/").slice(0,-1).join("/"):"");if(te&&Pe){const ge=await ee(Pe,te);if(ge.length===1&&!ge[0].isDirectory){const ve=await We(ge[0].path);if(ve.ok){d(ve.data);return}}else if(ge.length>0){w(ge);return}}b(xe.error||i("terminal:fileExplorer.failedToLoad"))}catch(xe){b(xe.message||i("terminal:fileExplorer.failedToLoad"))}finally{h(!1)}},ze=async xe=>{if(xe.isDirectory){h(!0),w([]),N([]),b(null);try{const Pe=await ne(xe.path);Pe.length>0?N(Pe):b("Empty directory")}catch{b("Failed to load directory")}finally{h(!1)}return}h(!0),w([]),N([]),b(null);try{const Pe=await We(xe.path);Pe.ok?d(Pe.data):b(Pe.error||i("terminal:fileExplorer.failedToLoad"))}catch(Pe){b(Pe.message||i("terminal:fileExplorer.failedToLoad"))}finally{h(!1)}},{handleMouseDown:st,handleClick:pe}=Ta(e),Be=()=>{switch(s){case"created":return i("common:status.created");case"modified":return i("common:status.modified");case"deleted":return i("common:status.deleted");case"read":return i("common:status.read")}},oe=()=>{switch(s){case"created":return"var(--accent-green)";case"modified":return"var(--accent-orange)";case"deleted":return"var(--accent-red)";case"read":return"var(--text-secondary)"}},de=x.useCallback(async()=>{if(!L.current){console.error("Copy Rich Text: markdown content ref is not available"),j("error"),setTimeout(()=>j("idle"),2e3);return}try{const xe=L.current.innerHTML,Pe=TN(xe),te=L.current.innerText;await _N(Pe,te),j("copied"),setTimeout(()=>j("idle"),2e3)}catch(xe){console.error("Copy Rich Text failed:",xe),j("error"),setTimeout(()=>j("idle"),2e3)}},[]),He=x.useCallback(async()=>{if(!L.current){console.error("Copy HTML: markdown content ref is not available"),T("error"),setTimeout(()=>T("idle"),2e3);return}try{const xe=L.current.innerHTML;await Lu(xe),T("copied"),setTimeout(()=>T("idle"),2e3)}catch(xe){console.error("Copy HTML failed:",xe),T("error"),setTimeout(()=>T("idle"),2e3)}},[]),et=x.useCallback(async()=>{if(!c){E("error"),setTimeout(()=>E("idle"),2e3);return}try{await Lu(c.content),E("copied"),setTimeout(()=>E("idle"),2e3)}catch{E("error"),setTimeout(()=>E("idle"),2e3)}},[c]),ct=x.useCallback(async()=>{if(!c){O("error"),setTimeout(()=>O("idle"),2e3);return}try{await Lu(c.content),O("copied"),setTimeout(()=>O("idle"),2e3)}catch{O("error"),setTimeout(()=>O("idle"),2e3)}},[c]),fe=xe=>xe<1024?`${xe} B`:xe<1024*1024?`${(xe/1024).toFixed(1)} KB`:`${(xe/(1024*1024)).toFixed(1)} MB`,X=c&&TC.includes(c.extension),ae=c&&_C.includes(c.extension),ke=c&&EC.includes(c.extension),J=ae?"Image":ke?"PDF":c?np(c.extension):"text",he=Ii(),Oe=ae?Rt(`/api/files/binary?path=${encodeURIComponent(G)}${he?`&token=${encodeURIComponent(he)}`:""}`):null,$e=ke?Rt(`/api/files/binary?path=${encodeURIComponent(G)}${he?`&token=${encodeURIComponent(he)}`:""}`):null;return t?o.jsx(pr,{children:o.jsx("div",{ref:H,className:"file-viewer-overlay",onMouseDown:st,onClick:pe,tabIndex:-1,children:o.jsxs("div",{className:"file-viewer-modal",children:[o.jsxs("div",{className:"file-viewer-header",children:[o.jsxs("div",{className:"file-viewer-title",children:[o.jsx("span",{className:"file-viewer-action",style:{color:oe()},children:Be()}),o.jsx("span",{className:"file-viewer-filename",children:(c==null?void 0:c.filename)||G.split("/").pop()})]}),o.jsxs("div",{className:"file-viewer-header-buttons",children:[X&&c&&!me&&!Ee&&!Te&&o.jsxs(o.Fragment,{children:[o.jsx("button",{className:`file-viewer-copy-html-btn ${k}`,onClick:de,title:i("terminal:fileExplorer.copyRichTextTitle"),children:i(k==="copied"?"common:status.copied":k==="error"?"common:status.error":"terminal:fileExplorer.copyRichText")}),o.jsx("button",{className:`file-viewer-copy-html-btn ${S}`,onClick:He,title:i("terminal:fileExplorer.copyHtmlTitle"),children:i(S==="copied"?"common:status.copied":S==="error"?"common:status.error":"terminal:fileExplorer.copyHtml")}),o.jsx("button",{className:`file-viewer-copy-html-btn ${D}`,onClick:et,title:i("terminal:fileExplorer.copyMarkdownTitle"),children:i(D==="copied"?"common:status.copied":D==="error"?"common:status.error":"terminal:fileExplorer.copyMarkdown")}),o.jsx("button",{className:`file-viewer-copy-html-btn ${I}`,onClick:ct,title:i("terminal:fileExplorer.copyOriginalTitle"),children:i(I==="copied"?"common:status.copied":I==="error"?"common:status.error":"terminal:fileExplorer.copyOriginal")})]}),ae&&Oe||ke&&$e?o.jsx("a",{className:"file-viewer-copy-html-btn",href:`${ae?Oe:$e}&download=true`,download:c==null?void 0:c.filename,title:i(ae?"terminal:fileExplorer.downloadImage":"terminal:fileExplorer.downloadPdf"),children:i("common:buttons.download")}):null,o.jsx("button",{className:"file-viewer-close",onClick:e,children:"×"})]})]}),o.jsx("div",{className:"file-viewer-path",children:(c==null?void 0:c.path)||G}),c&&o.jsxs("div",{className:"file-viewer-meta",children:[o.jsx("span",{children:fe(c.size)}),o.jsx("span",{children:"•"}),o.jsx("span",{children:J}),c.content&&!ae&&!ke&&o.jsxs(o.Fragment,{children:[o.jsx("span",{children:"•"}),o.jsx("span",{children:i("terminal:fileViewer.lineCount",{count:c.content.split(`
90
- `).length})})]})]}),o.jsxs("div",{className:"file-viewer-content",ref:F,children:[f&&o.jsx("div",{className:"file-viewer-loading",children:i("terminal:fileExplorer.loadingFile")}),m&&!y.length&&!C.length&&o.jsx("div",{className:"file-viewer-error",children:m}),y.length>0&&o.jsxs("div",{className:"file-viewer-resolve-results",children:[o.jsxs("div",{className:"file-viewer-resolve-header",children:["Found ",y.length," matching file",y.length>1?"s":""," in project:"]}),o.jsx("div",{className:"file-viewer-resolve-list",children:y.map(xe=>o.jsxs("button",{className:"file-viewer-resolve-item",onClick:()=>ze(xe),children:[o.jsx("span",{className:"file-viewer-resolve-icon",children:xe.isDirectory?"📁":"📄"}),o.jsxs("span",{className:"file-viewer-resolve-info",children:[o.jsx("span",{className:"file-viewer-resolve-name",children:xe.name}),o.jsx("span",{className:"file-viewer-resolve-path",children:xe.path})]}),!xe.isDirectory&&xe.size>0&&o.jsx("span",{className:"file-viewer-resolve-size",children:fe(xe.size)})]},xe.path))})]}),C.length>0&&o.jsxs("div",{className:"file-viewer-resolve-results",children:[o.jsxs("div",{className:"file-viewer-resolve-header",children:["Directory contents (",C.length," items):"]}),o.jsx("div",{className:"file-viewer-resolve-list",children:C.map(xe=>o.jsxs("button",{className:"file-viewer-resolve-item",onClick:()=>ze(xe),children:[o.jsx("span",{className:"file-viewer-resolve-icon",children:xe.isDirectory?"📁":"📄"}),o.jsxs("span",{className:"file-viewer-resolve-info",children:[o.jsx("span",{className:"file-viewer-resolve-name",children:xe.name}),o.jsx("span",{className:"file-viewer-resolve-path",children:xe.path})]}),!xe.isDirectory&&xe.size>0&&o.jsx("span",{className:"file-viewer-resolve-size",children:fe(xe.size)})]},xe.path))})]}),c&&!f&&!m&&(ae&&Oe?o.jsx("div",{className:"file-viewer-image-wrapper",children:o.jsx("img",{src:Oe,alt:c.filename,className:"file-viewer-image"})}):ke&&$e?o.jsx("div",{className:"file-viewer-pdf-embed",children:o.jsx("iframe",{src:$e,title:c.filename,className:"file-viewer-pdf-iframe"})}):me?o.jsx(gx,{originalContent:ie,modifiedContent:c.content,filename:c.filename,language:J}):Ee?o.jsx("pre",{className:"file-viewer-code file-viewer-unified-diff",children:be.split(`
91
- `).map((xe,Pe)=>{let te="diff-ctx";return xe.startsWith("+")&&!xe.startsWith("+++")?te="diff-add":xe.startsWith("-")&&!xe.startsWith("---")?te="diff-del":xe.startsWith("@@")?te="diff-hdr":(xe.startsWith("diff ")||xe.startsWith("index ")||xe.startsWith("---")||xe.startsWith("+++"))&&(te="diff-meta"),o.jsxs("div",{className:`file-line file-line-${te}`,children:[o.jsx("span",{className:"file-line-num",children:Pe+1}),o.jsx("code",{children:xe||" "})]},Pe)})}):Te?o.jsx("pre",{className:"file-viewer-code file-viewer-code-highlighted",children:c.content.split(`
92
- `).map((xe,Pe)=>{const te=Pe+1,ge=K,ve=ge&&te>=ge.offset&&te<ge.offset+ge.limit;return o.jsxs("div",{className:`file-line ${ve?"file-line-highlighted":""}`,children:[o.jsx("span",{className:"file-line-num",children:te}),o.jsx("code",{className:`language-${J}`,dangerouslySetInnerHTML:{__html:Ve[Pe]||xe||" "}})]},Pe)})}):X?o.jsx("div",{className:"file-viewer-markdown markdown-content",ref:L,children:o.jsx(Fr,{remarkPlugins:[zr],children:c.content})}):o.jsx("pre",{className:`file-viewer-code file-viewer-code-lines language-${J}`,children:Ve.map((xe,Pe)=>o.jsxs("div",{className:`file-line ${B===Pe+1?"file-line-highlighted":""}`,children:[o.jsx("span",{className:`file-line-num ${B===Pe+1?"file-viewer-line-num-target":""}`,"data-line":Pe+1,children:Pe+1}),o.jsx("code",{className:`language-${J}`,dangerouslySetInnerHTML:{__html:xe}})]},Pe+1))}))]})]})})}):null}function _4({agentIds:t}){const{t:e}=dt(["terminal"]),n=Yx(),s=s1(),[a,r]=x.useState(null),[i,c]=x.useState(null),[d,f]=x.useState(()=>Ni(pt.TOOLS_COLLAPSED)),[h,m]=x.useState(()=>Ni(pt.FILES_COLLAPSED)),b=()=>{const O=!d;f(O),Ti(pt.TOOLS_COLLAPSED,O)},y=()=>{const O=!h;m(O),Ti(pt.FILES_COLLAPSED,O)},w=x.useMemo(()=>new Set(t),[t]),C=x.useMemo(()=>n.filter(O=>w.has(O.agentId)),[n,w]),N=x.useMemo(()=>s.filter(O=>w.has(O.agentId)),[s,w]),k=t.length>1,j=O=>new Date(O).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),S=O=>{const _=O.split("/");return _.length>2?".../"+_.slice(-2).join("/"):O},T=O=>{switch(O){case"created":return"+";case"modified":return"~";case"deleted":return"-";case"read":return">"}},D=O=>{switch(O){case"created":return"var(--accent-green)";case"modified":return"var(--accent-orange)";case"deleted":return"var(--accent-red)";case"read":return"var(--text-secondary)"}},E=O=>O==="Read"?"📖":O==="Write"?"📝":O==="Edit"?"✏️":O==="Bash"?"💻":O==="Grep"?"🔍":O==="Glob"?"📁":O==="Task"||O==="Agent"?"🤖":O==="WebFetch"?"🌐":O==="WebSearch"?"🔎":"🔧",I=(O,_)=>{r({path:O,action:_})};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"tool-history-stacked",children:[o.jsxs("div",{className:`tool-history-panel ${d?"collapsed":""}`,children:[o.jsxs("div",{className:"tool-history-panel-header",onClick:b,children:[o.jsx("span",{className:"tool-history-panel-toggle",children:d?"▶":"▼"}),e("terminal:toolHistory.tools")," (",C.length,")"]}),!d&&o.jsx("div",{className:"tool-history-panel-content",children:C.length===0?o.jsx("div",{className:"tool-history-empty",children:e("terminal:toolHistory.noToolsYet")}):o.jsx("div",{className:"tool-history-list",children:C.slice(0,50).map((O,_)=>o.jsx(M4,{execution:O,formatTime:j,formatPath:S,getToolIcon:E,showAgentName:k,isExpanded:i===_,onToggle:()=>c(i===_?null:_),onViewFile:M=>r({path:M,action:"modified"})},_))})})]}),o.jsxs("div",{className:`tool-history-panel ${h?"collapsed":""}`,children:[o.jsxs("div",{className:"tool-history-panel-header",onClick:y,children:[o.jsx("span",{className:"tool-history-panel-toggle",children:h?"▶":"▼"}),e("terminal:toolHistory.filesSection")," (",N.length,")"]}),!h&&o.jsx("div",{className:"tool-history-panel-content",children:N.length===0?o.jsx("div",{className:"tool-history-empty",children:e("terminal:toolHistory.noFileChangesYet")}):o.jsx("div",{className:"tool-history-list",children:N.slice(0,50).map((O,_)=>o.jsx(R4,{change:O,formatTime:j,formatPath:S,getActionIcon:T,getActionColor:D,onClick:()=>I(O.filePath,O.action),showAgentName:k},_))})})]})]}),o.jsx(MN,{isOpen:a!==null,onClose:()=>r(null),filePath:(a==null?void 0:a.path)||"",action:(a==null?void 0:a.action)||"read"})]})}function E4(t,e){if(!e)return null;switch(t){case"WebSearch":return e.query||null;case"WebFetch":const n=e.url;return n&&n.length>50?n.slice(0,47)+"...":n||null;case"Read":case"Write":case"Edit":const s=e.file_path||e.path;return s?s.length>40?".../"+s.split("/").slice(-2).join("/"):s:null;case"Bash":const a=e.command;return a?a.length>50?a.slice(0,47)+"...":a:null;case"Grep":return e.pattern?`"${e.pattern}"`:null;case"Glob":return e.pattern||null;case"Task":const r=e.description;return r?r.length>40?r.slice(0,37)+"...":r:null;case"TodoWrite":const i=e.todos;return i!=null&&i.length?`${i.length} item${i.length>1?"s":""}`:null;default:for(const[,c]of Object.entries(e))if(typeof c=="string"&&c.length>0&&c.length<80)return c.length>50?c.slice(0,47)+"...":c;return null}}function M4({execution:t,formatTime:e,formatPath:n,getToolIcon:s,showAgentName:a,isExpanded:r,onToggle:i,onViewFile:c}){const{t:d}=dt(["terminal"]),f=E4(t.toolName,t.toolInput),h=t.toolInput&&Object.keys(t.toolInput).length>0,m=t.toolInput?t.toolInput.file_path||t.toolInput.path:void 0,b=["Write","Edit","Read"].includes(t.toolName)&&m;return o.jsxs("div",{className:`tool-history-item tool-compact ${r?"expanded":""} ${h?"clickable":""}`,children:[o.jsxs("div",{className:"tool-row",onClick:h?i:void 0,title:t.toolName,children:[o.jsx("span",{className:"tool-expand-icon",children:h?r?"▼":"▶":" "}),o.jsx("span",{className:"tool-icon",title:t.toolName,children:s(t.toolName)}),o.jsx("div",{className:"tool-input-inline",title:f||t.toolName,children:f||t.toolName}),a&&o.jsx("span",{className:"tool-agent-compact",children:t.agentName}),o.jsx("span",{className:"tool-time",children:e(t.timestamp)})]}),r&&t.toolInput&&o.jsxs("div",{className:"tool-expanded-details",children:[o.jsxs("div",{className:"tool-expanded-header",children:[o.jsx("span",{className:"tool-expanded-name",children:t.toolName}),b&&o.jsx("button",{className:"tool-view-file-btn",onClick:y=>{y.stopPropagation(),c(m)},children:d("terminal:toolHistory.viewFile")})]}),o.jsx("pre",{className:"tool-input-json",children:D4(t.toolName,t.toolInput)})]})]})}function D4(t,e){if(t==="Write"&&e.content){const n=e.content,s=e.file_path||e.path,a=n.length>2e3?n.slice(0,2e3)+`
93
-
94
- ... (truncated)`:n;return`file: ${s}
95
-
96
- ${a}`}if(t==="Edit"){const n=[];if(e.file_path&&n.push(`file: ${e.file_path}`),e.old_string){const s=e.old_string;n.push(`
97
- - old:
98
- ${s.slice(0,500)}${s.length>500?"...":""}`)}if(e.new_string){const s=e.new_string;n.push(`
99
- + new:
100
- ${s.slice(0,500)}${s.length>500?"...":""}`)}return n.join(`
101
- `)}return t==="Bash"&&e.command?e.command:t==="TodoWrite"&&e.todos?e.todos.map((s,a)=>`${s.status==="completed"?"✓":s.status==="in_progress"?"→":"○"} ${s.content}`).join(`
102
- `):JSON.stringify(e,null,2)}function R4({change:t,formatTime:e,formatPath:n,getActionIcon:s,getActionColor:a,onClick:r,showAgentName:i}){return o.jsxs("div",{className:"tool-history-item file-change clickable",onClick:r,children:[o.jsx("span",{className:"file-action",style:{color:a(t.action)},children:s(t.action)}),o.jsx("span",{className:"file-path",title:t.filePath,children:n(t.filePath)}),i&&o.jsx("span",{className:"tool-agent-compact",children:t.agentName}),o.jsx("span",{className:"tool-time",children:e(t.timestamp)})]})}function Ml(t,e,n){let s=n.initialDeps??[],a,r=!0;function i(){var c,d,f;let h;n.key&&((c=n.debug)!=null&&c.call(n))&&(h=Date.now());const m=t();if(!(m.length!==s.length||m.some((w,C)=>s[C]!==w)))return a;s=m;let y;if(n.key&&((d=n.debug)!=null&&d.call(n))&&(y=Date.now()),a=e(...m),n.key&&((f=n.debug)!=null&&f.call(n))){const w=Math.round((Date.now()-h)*100)/100,C=Math.round((Date.now()-y)*100)/100,N=C/16,k=(j,S)=>{for(j=String(j);j.length<S;)j=" "+j;return j};console.info(`%c⏱ ${k(C,5)} /${k(w,5)} ms`,`
103
- font-size: .6rem;
104
- font-weight: bold;
105
- color: hsl(${Math.max(0,Math.min(120-120*N,120))}deg 100% 31%);`,n==null?void 0:n.key)}return n!=null&&n.onChange&&!(r&&n.skipInitialOnChange)&&n.onChange(a),r=!1,a}return i.updateDeps=c=>{s=c},i}function MC(t,e){if(t===void 0)throw new Error("Unexpected undefined");return t}const O4=(t,e)=>Math.abs(t-e)<1.01,L4=(t,e,n)=>{let s;return function(...a){t.clearTimeout(s),s=t.setTimeout(()=>e.apply(this,a),n)}},DC=t=>{const{offsetWidth:e,offsetHeight:n}=t;return{width:e,height:n}},I4=t=>t,P4=t=>{const e=Math.max(t.startIndex-t.overscan,0),n=Math.min(t.endIndex+t.overscan,t.count-1),s=[];for(let a=e;a<=n;a++)s.push(a);return s},B4=(t,e)=>{const n=t.scrollElement;if(!n)return;const s=t.targetWindow;if(!s)return;const a=i=>{const{width:c,height:d}=i;e({width:Math.round(c),height:Math.round(d)})};if(a(DC(n)),!s.ResizeObserver)return()=>{};const r=new s.ResizeObserver(i=>{const c=()=>{const d=i[0];if(d!=null&&d.borderBoxSize){const f=d.borderBoxSize[0];if(f){a({width:f.inlineSize,height:f.blockSize});return}}a(DC(n))};t.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()});return r.observe(n,{box:"border-box"}),()=>{r.unobserve(n)}},RC={passive:!0},OC=typeof window>"u"?!0:"onscrollend"in window,F4=(t,e)=>{const n=t.scrollElement;if(!n)return;const s=t.targetWindow;if(!s)return;let a=0;const r=t.options.useScrollendEvent&&OC?()=>{}:L4(s,()=>{e(a,!1)},t.options.isScrollingResetDelay),i=h=>()=>{const{horizontal:m,isRtl:b}=t.options;a=m?n.scrollLeft*(b&&-1||1):n.scrollTop,r(),e(a,h)},c=i(!0),d=i(!1);n.addEventListener("scroll",c,RC);const f=t.options.useScrollendEvent&&OC;return f&&n.addEventListener("scrollend",d,RC),()=>{n.removeEventListener("scroll",c),f&&n.removeEventListener("scrollend",d)}},z4=(t,e,n)=>{if(e!=null&&e.borderBoxSize){const s=e.borderBoxSize[0];if(s)return Math.round(s[n.options.horizontal?"inlineSize":"blockSize"])}return t[n.options.horizontal?"offsetWidth":"offsetHeight"]},$4=(t,{adjustments:e=0,behavior:n},s)=>{var a,r;const i=t+e;(r=(a=s.scrollElement)==null?void 0:a.scrollTo)==null||r.call(a,{[s.options.horizontal?"left":"top"]:i,behavior:n})};class U4{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var n,s,a;return((a=(s=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:s.now)==null?void 0:a.call(s))??Date.now()},this.observer=(()=>{let n=null;const s=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(a=>{a.forEach(r=>{const i=()=>{const c=r.target,d=this.indexFromElement(c);if(!c.isConnected){this.observer.unobserve(c);return}this.shouldMeasureDuringScroll(d)&&this.resizeItem(d,this.options.measureElement(c,r,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(i):i()})}));return{disconnect:()=>{var a;(a=s())==null||a.disconnect(),n=null},observe:a=>{var r;return(r=s())==null?void 0:r.observe(a,{box:"border-box"})},unobserve:a=>{var r;return(r=s())==null?void 0:r.unobserve(a)}}})(),this.range=null,this.setOptions=n=>{Object.entries(n).forEach(([s,a])=>{typeof a>"u"&&delete n[s]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:I4,rangeExtractor:P4,onChange:()=>{},measureElement:z4,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...n}},this.notify=n=>{var s,a;(a=(s=this.options).onChange)==null||a.call(s,this,n)},this.maybeNotify=Ml(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const s=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==s){if(this.cleanup(),!s){this.maybeNotify();return}this.scrollElement=s,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(a=>{this.observer.observe(a)}),this.unsubs.push(this.options.observeElementRect(this,a=>{this.scrollRect=a,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(a,r)=>{this.scrollAdjustments=0,this.scrollDirection=r?this.getScrollOffset()<a?"forward":"backward":null,this.scrollOffset=a,this.isScrolling=r,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(n,s)=>{const a=new Map,r=new Map;for(let i=s-1;i>=0;i--){const c=n[i];if(a.has(c.lane))continue;const d=r.get(c.lane);if(d==null||c.end>d.end?r.set(c.lane,c):c.end<d.end&&a.set(c.lane,!0),a.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((i,c)=>i.end===c.end?i.index-c.index:i.end-c.end)[0]:void 0},this.getMeasurementOptions=Ml(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(n,s,a,r,i,c)=>(this.prevLanes!==void 0&&this.prevLanes!==c&&(this.lanesChangedFlag=!0),this.prevLanes=c,this.pendingMeasuredCacheIndexes=[],{count:n,paddingStart:s,scrollMargin:a,getItemKey:r,enabled:i,lanes:c}),{key:!1}),this.getMeasurements=Ml(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:n,paddingStart:s,scrollMargin:a,getItemKey:r,enabled:i,lanes:c},d)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const b of this.laneAssignments.keys())b>=n&&this.laneAssignments.delete(b);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(b=>{this.itemSizeCache.set(b.key,b.size)}));const f=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1);const h=this.measurementsCache.slice(0,f),m=new Array(c).fill(void 0);for(let b=0;b<f;b++){const y=h[b];y&&(m[y.lane]=b)}for(let b=f;b<n;b++){const y=r(b),w=this.laneAssignments.get(b);let C,N;if(w!==void 0&&this.options.lanes>1){C=w;const T=m[C],D=T!==void 0?h[T]:void 0;N=D?D.end+this.options.gap:s+a}else{const T=this.options.lanes===1?h[b-1]:this.getFurthestMeasurement(h,b);N=T?T.end+this.options.gap:s+a,C=T?T.lane:b%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(b,C)}const k=d.get(y),j=typeof k=="number"?k:this.options.estimateSize(b),S=N+j;h[b]={index:b,start:N,size:j,end:S,key:y,lane:C},m[C]=b}return this.measurementsCache=h,h},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Ml(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,s,a,r)=>this.range=n.length>0&&s>0?H4({measurements:n,outerSize:s,scrollOffset:a,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Ml(()=>{let n=null,s=null;const a=this.calculateRange();return a&&(n=a.startIndex,s=a.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,s]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,s]},(n,s,a,r,i)=>r===null||i===null?[]:n({startIndex:r,endIndex:i,overscan:s,count:a}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const s=this.options.indexAttribute,a=n.getAttribute(s);return a?parseInt(a,10):(console.warn(`Missing attribute name '${s}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=n=>{var s;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const a=this.scrollState.index??((s=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:s.index);if(a!==void 0&&this.range){const r=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),i=Math.max(0,a-r),c=Math.min(this.options.count-1,a+r);return n>=i&&n<=c}return!0},this.measureElement=n=>{if(!n){this.elementsCache.forEach((i,c)=>{i.isConnected||(this.observer.unobserve(i),this.elementsCache.delete(c))});return}const s=this.indexFromElement(n),a=this.options.getItemKey(s),r=this.elementsCache.get(a);r!==n&&(r&&this.observer.unobserve(r),this.observer.observe(n),this.elementsCache.set(a,n)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(s)&&this.resizeItem(s,this.options.measureElement(n,void 0,this))},this.resizeItem=(n,s)=>{var a;const r=this.measurementsCache[n];if(!r)return;const i=this.itemSizeCache.get(r.key)??r.size,c=s-i;c!==0&&(((a=this.scrollState)==null?void 0:a.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(r,c,this):r.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=c,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(r.index),this.itemSizeCache=new Map(this.itemSizeCache.set(r.key,s)),this.notify(!1))},this.getVirtualItems=Ml(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,s)=>{const a=[];for(let r=0,i=n.length;r<i;r++){const c=n[r],d=s[c];a.push(d)}return a},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const s=this.getMeasurements();if(s.length!==0)return MC(s[DN(0,s.length-1,a=>MC(s[a]).start,n)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const n=this.scrollElement.document.documentElement;return this.options.horizontal?n.scrollWidth-this.scrollElement.innerWidth:n.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(n,s,a=0)=>{if(!this.scrollElement)return 0;const r=this.getSize(),i=this.getScrollOffset();s==="auto"&&(s=n>=i+r?"end":"start"),s==="center"?n+=(a-r)/2:s==="end"&&(n-=r);const c=this.getMaxScrollOffset();return Math.max(Math.min(c,n),0)},this.getOffsetForIndex=(n,s="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const a=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[n];if(!i)return;if(s==="auto")if(i.end>=r+a-this.options.scrollPaddingEnd)s="end";else if(i.start<=r+this.options.scrollPaddingStart)s="start";else return[r,s];if(s==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),s];const c=s==="end"?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(c,s,i.size),s]},this.scrollToOffset=(n,{align:s="start",behavior:a="auto"}={})=>{const r=this.getOffsetForAlignment(n,s),i=this.now();this.scrollState={index:null,align:s,behavior:a,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:a}),this.scheduleScrollReconcile()},this.scrollToIndex=(n,{align:s="auto",behavior:a="auto"}={})=>{n=Math.max(0,Math.min(n,this.options.count-1));const r=this.getOffsetForIndex(n,s);if(!r)return;const[i,c]=r,d=this.now();this.scrollState={index:n,align:c,behavior:a,startedAt:d,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:a}),this.scheduleScrollReconcile()},this.scrollBy=(n,{behavior:s="auto"}={})=>{const a=this.getScrollOffset()+n,r=this.now();this.scrollState={index:null,align:"start",behavior:s,startedAt:r,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var n;const s=this.getMeasurements();let a;if(s.length===0)a=this.options.paddingStart;else if(this.options.lanes===1)a=((n=s[s.length-1])==null?void 0:n.end)??0;else{const r=Array(this.options.lanes).fill(null);let i=s.length-1;for(;i>=0&&r.some(c=>c===null);){const c=s[i];r[c.lane]===null&&(r[c.lane]=c.end),i--}a=Math.max(...r.filter(c=>c!==null))}return Math.max(a-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(n,{adjustments:s,behavior:a})=>{this.options.scrollToFn(n,{behavior:a,adjustments:s},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const s=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,a=s?s[0]:this.scrollState.lastTargetOffset,r=1,i=a!==this.scrollState.lastTargetOffset;if(!i&&O4(a,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=r){this.scrollState=null;return}}else this.scrollState.stableFrames=0,i&&(this.scrollState.lastTargetOffset=a,this.scrollState.behavior="auto",this._scrollToOffset(a,{adjustments:void 0,behavior:"auto"}));this.scheduleScrollReconcile()}}const DN=(t,e,n,s)=>{for(;t<=e;){const a=(t+e)/2|0,r=n(a);if(r<s)t=a+1;else if(r>s)e=a-1;else return a}return t>0?t-1:0};function H4({measurements:t,outerSize:e,scrollOffset:n,lanes:s}){const a=t.length-1,r=d=>t[d].start;if(t.length<=s)return{startIndex:0,endIndex:a};let i=DN(0,a,r,n),c=i;if(s===1)for(;c<a&&t[c].end<n+e;)c++;else if(s>1){const d=Array(s).fill(0);for(;c<a&&d.some(h=>h<n+e);){const h=t[c];d[h.lane]=h.end,c++}const f=Array(s).fill(n+e);for(;i>=0&&f.some(h=>h>=n);){const h=t[i];f[h.lane]=h.start,i--}i=Math.max(0,i-i%s),c=Math.min(a,c+(s-1-c%s))}return{startIndex:i,endIndex:c}}const LC=typeof document<"u"?x.useLayoutEffect:x.useEffect;function W4({useFlushSync:t=!0,...e}){const n=x.useReducer(()=>({}),{})[1],s={...e,onChange:(r,i)=>{var c;t&&i?ac.flushSync(n):n(),(c=e.onChange)==null||c.call(e,r,i)}},[a]=x.useState(()=>new U4(s));return a.setOptions(s),LC(()=>a._didMount(),[]),LC(()=>a._willUpdate()),a}function RN(t){return W4({observeElementRect:B4,observeElementOffset:F4,scrollToFn:$4,...t})}const IC={30:"#000000",31:"#ef4444",32:"#22c55e",33:"#eab308",34:"#3b82f6",35:"#a855f7",36:"#06b6d4",37:"#e5e5e5",90:"#666666",91:"#f87171",92:"#4ade80",93:"#facc15",94:"#60a5fa",95:"#c084fc",96:"#22d3ee",97:"#ffffff"},PC={40:"#000000",41:"#ef4444",42:"#22c55e",43:"#eab308",44:"#3b82f6",45:"#a855f7",46:"#06b6d4",47:"#e5e5e5",100:"#666666",101:"#f87171",102:"#4ade80",103:"#facc15",104:"#60a5fa",105:"#c084fc",106:"#22d3ee",107:"#ffffff"};function BC(t){const e=[];return t.color&&e.push(`color:${t.color}`),t.bgColor&&e.push(`background-color:${t.bgColor}`),t.bold&&e.push("font-weight:bold"),t.dim&&e.push("opacity:0.6"),t.italic&&e.push("font-style:italic"),t.underline&&e.push("text-decoration:underline"),e.join(";")}function q4(t,e){const n={...t};return e===0?{}:(e===1?n.bold=!0:e===2?n.dim=!0:e===3?n.italic=!0:e===4?n.underline=!0:e===7?n.inverse=!0:e===22?(n.bold=!1,n.dim=!1):e===23?n.italic=!1:e===24?n.underline=!1:e===27?n.inverse=!1:e===39?delete n.color:e===49?delete n.bgColor:e>=30&&e<=37?n.color=IC[e]:e>=40&&e<=47?n.bgColor=PC[e]:e>=90&&e<=97?n.color=IC[e]:e>=100&&e<=107&&(n.bgColor=PC[e]),n)}function Kl(t){const e=/(?:\x1b|\u001b)?\[([0-9;]*)m/g;let n="",s=0,a={},r;for(;(r=e.exec(t))!==null;){const c=t.slice(s,r.index);if(c){const f=BC(a);f?n+=`<span style="${f}">${Bf(c)}</span>`:n+=Bf(c)}const d=r[1].split(";").filter(Boolean).map(Number);if(d.length===0)a={};else for(const f of d)a=q4(a,f);s=r.index+r[0].length}const i=t.slice(s);if(i){const c=BC(a);c?n+=`<span style="${c}">${Bf(i)}</span>`:n+=Bf(i)}return n}function Bf(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const Do=x.memo(function({isOpen:e,position:n,actions:s,onClose:a}){const r=x.useRef(null),i=x.useRef(null);x.useEffect(()=>{if(!e)return;const d=setTimeout(()=>{const f=b=>{r.current&&!r.current.contains(b.target)&&a()},h=b=>{b.key==="Escape"&&a()},m=b=>{var w,C;const y=b.target;y&&y!==document&&y!==document.documentElement&&((w=y.classList)!=null&&w.contains("xterm-viewport")||(C=y.closest)!=null&&C.call(y,".guake-bottom-terminal-embed"))||a()};document.addEventListener("mousedown",f),document.addEventListener("touchstart",f,{passive:!0}),document.addEventListener("keydown",h),window.addEventListener("scroll",m,!0),i.current=()=>{document.removeEventListener("mousedown",f),document.removeEventListener("touchstart",f),document.removeEventListener("keydown",h),window.removeEventListener("scroll",m,!0)}},100);return()=>{var f;clearTimeout(d),(f=i.current)==null||f.call(i),i.current=null}},[e,a]),x.useEffect(()=>{if(!e||!r.current)return;const d=r.current,f=d.getBoundingClientRect(),h=window.innerWidth,m=window.innerHeight;let b=n.x,y=n.y;n.x+f.width>h-10&&(b=h-f.width-10),n.y+f.height>m-10&&(y=m-f.height-10),d.style.left=`${Math.max(10,b)}px`,d.style.top=`${Math.max(10,y)}px`},[e,n]);const c=x.useCallback(d=>{d.disabled||(d.onClick(),a())},[a]);return e?o.jsx("div",{ref:r,className:"context-menu",style:{left:n.x,top:n.y},onClick:d=>d.stopPropagation(),children:s.map((d,f)=>d.divider?o.jsx("div",{className:"context-menu-divider"},`divider-${f}`):o.jsxs("button",{className:`context-menu-item ${d.disabled?"disabled":""} ${d.danger?"danger":""}`,onClick:()=>c(d),onTouchEnd:h=>{h.preventDefault(),h.stopPropagation(),c(d)},disabled:d.disabled,children:[d.icon&&o.jsx("span",{className:"context-menu-icon",children:d.icon}),o.jsx("span",{className:"context-menu-label",children:d.label}),d.shortcut&&o.jsx("span",{className:"context-menu-shortcut",children:d.shortcut})]},d.id))}):null});function ON(t){var e,n,s="";if(typeof t=="string"||typeof t=="number")s+=t;else if(typeof t=="object")if(Array.isArray(t)){var a=t.length;for(e=0;e<a;e++)t[e]&&(n=ON(t[e]))&&(s&&(s+=" "),s+=n)}else for(n in t)t[n]&&(s&&(s+=" "),s+=n);return s}function us(){for(var t,e,n=0,s="",a=arguments.length;n<a;n++)(t=arguments[n])&&(e=ON(t))&&(s&&(s+=" "),s+=e);return s}const LN=6048e5,V4=864e5,ah=6e4,rh=36e5,Y4=1e3,FC=Symbol.for("constructDateFrom");function vn(t,e){return typeof t=="function"?t(e):t&&typeof t=="object"&&FC in t?t[FC](e):t instanceof Date?new t.constructor(e):new Date(e)}function St(t,e){return vn(e||t,t)}function Pa(t,e,n){const s=St(t,n==null?void 0:n.in);return isNaN(e)?vn((n==null?void 0:n.in)||t,NaN):(e&&s.setDate(s.getDate()+e),s)}function za(t,e,n){const s=St(t,n==null?void 0:n.in);if(isNaN(e))return vn(t,NaN);if(!e)return s;const a=s.getDate(),r=vn(t,s.getTime());r.setMonth(s.getMonth()+e+1,0);const i=r.getDate();return a>=i?r:(s.setFullYear(r.getFullYear(),r.getMonth(),a),s)}function IN(t,e,n){return vn(t,+St(t)+e)}function G4(t,e,n){return IN(t,e*rh)}let K4={};function Io(){return K4}function qr(t,e){var c,d,f,h;const n=Io(),s=(e==null?void 0:e.weekStartsOn)??((d=(c=e==null?void 0:e.locale)==null?void 0:c.options)==null?void 0:d.weekStartsOn)??n.weekStartsOn??((h=(f=n.locale)==null?void 0:f.options)==null?void 0:h.weekStartsOn)??0,a=St(t,e==null?void 0:e.in),r=a.getDay(),i=(r<s?7:0)+r-s;return a.setDate(a.getDate()-i),a.setHours(0,0,0,0),a}function Ql(t,e){return qr(t,{...e,weekStartsOn:1})}function PN(t,e){const n=St(t,e==null?void 0:e.in),s=n.getFullYear(),a=vn(n,0);a.setFullYear(s+1,0,4),a.setHours(0,0,0,0);const r=Ql(a),i=vn(n,0);i.setFullYear(s,0,4),i.setHours(0,0,0,0);const c=Ql(i);return n.getTime()>=r.getTime()?s+1:n.getTime()>=c.getTime()?s:s-1}function Np(t){const e=St(t),n=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return n.setUTCFullYear(e.getFullYear()),+t-+n}function Gr(t,...e){const n=vn.bind(null,e.find(s=>typeof s=="object"));return e.map(n)}function Ro(t,e){const n=St(t,e==null?void 0:e.in);return n.setHours(0,0,0,0),n}function Xl(t,e,n){const[s,a]=Gr(n==null?void 0:n.in,t,e),r=Ro(s),i=Ro(a),c=+r-Np(r),d=+i-Np(i);return Math.round((c-d)/V4)}function Q4(t,e){const n=PN(t,e),s=vn(t,0);return s.setFullYear(n,0,4),s.setHours(0,0,0,0),Ql(s)}function Gu(t,e,n){const s=St(t,n==null?void 0:n.in);return s.setTime(s.getTime()+e*ah),s}function py(t,e,n){return za(t,e*3,n)}function X4(t,e,n){return IN(t,e*1e3)}function Tp(t,e,n){return Pa(t,e*7,n)}function Ba(t,e,n){return za(t,e*12,n)}function zC(t,e){let n,s=e==null?void 0:e.in;return t.forEach(a=>{!s&&typeof a=="object"&&(s=vn.bind(null,a));const r=St(a,s);(!n||n<r||isNaN(+r))&&(n=r)}),vn(s,n||NaN)}function $C(t,e){let n,s=e==null?void 0:e.in;return t.forEach(a=>{!s&&typeof a=="object"&&(s=vn.bind(null,a));const r=St(a,s);(!n||n>r||isNaN(+r))&&(n=r)}),vn(s,n||NaN)}function J4(t,e,n){const[s,a]=Gr(n==null?void 0:n.in,t,e);return+Ro(s)==+Ro(a)}function ir(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function Jl(t){return!(!ir(t)&&typeof t!="number"||isNaN(+St(t)))}function _p(t,e,n){const[s,a]=Gr(n==null?void 0:n.in,t,e),r=s.getFullYear()-a.getFullYear(),i=s.getMonth()-a.getMonth();return r*12+i}function _i(t,e){const n=St(t,e==null?void 0:e.in);return Math.trunc(n.getMonth()/3)+1}function Ep(t,e,n){const[s,a]=Gr(n==null?void 0:n.in,t,e),r=s.getFullYear()-a.getFullYear(),i=_i(s)-_i(a);return r*4+i}function Mp(t,e,n){const[s,a]=Gr(n==null?void 0:n.in,t,e);return s.getFullYear()-a.getFullYear()}function Z4(t,e,n){const[s,a]=Gr(n==null?void 0:n.in,t,e),r=UC(s,a),i=Math.abs(Xl(s,a));s.setDate(s.getDate()-r*i);const c=+(UC(s,a)===-r),d=r*(i-c);return d===0?0:d}function UC(t,e){const n=t.getFullYear()-e.getFullYear()||t.getMonth()-e.getMonth()||t.getDate()-e.getDate()||t.getHours()-e.getHours()||t.getMinutes()-e.getMinutes()||t.getSeconds()-e.getSeconds()||t.getMilliseconds()-e.getMilliseconds();return n<0?-1:n>0?1:n}function BN(t,e){const n=St(t,e==null?void 0:e.in);return n.setHours(23,59,59,999),n}function FN(t,e){const n=St(t,e==null?void 0:e.in),s=n.getMonth();return n.setFullYear(n.getFullYear(),s+1,0),n.setHours(23,59,59,999),n}function bx(t,e){const n=St(t,e==null?void 0:e.in),s=n.getMonth(),a=s-s%3;return n.setMonth(a,1),n.setHours(0,0,0,0),n}function zN(t,e){const n=St(t,e==null?void 0:e.in);return n.setDate(1),n.setHours(0,0,0,0),n}function $N(t,e){const n=St(t,e==null?void 0:e.in),s=n.getFullYear();return n.setFullYear(s+1,0,0),n.setHours(23,59,59,999),n}function ih(t,e){const n=St(t,e==null?void 0:e.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function ez(t,e){var c,d;const n=Io(),s=n.weekStartsOn??((d=(c=n.locale)==null?void 0:c.options)==null?void 0:d.weekStartsOn)??0,a=St(t,e==null?void 0:e.in),r=a.getDay(),i=(r<s?-7:0)+6-(r-s);return a.setDate(a.getDate()+i),a.setHours(23,59,59,999),a}const tz={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},nz=(t,e,n)=>{let s;const a=tz[t];return typeof a=="string"?s=a:e===1?s=a.one:s=a.other.replace("{{count}}",e.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+s:s+" ago":s};function hb(t){return(e={})=>{const n=e.width?String(e.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const sz={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},az={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},rz={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},iz={date:hb({formats:sz,defaultWidth:"full"}),time:hb({formats:az,defaultWidth:"full"}),dateTime:hb({formats:rz,defaultWidth:"full"})},oz={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},lz=(t,e,n,s)=>oz[t];function pu(t){return(e,n)=>{const s=n!=null&&n.context?String(n.context):"standalone";let a;if(s==="formatting"&&t.formattingValues){const i=t.defaultFormattingWidth||t.defaultWidth,c=n!=null&&n.width?String(n.width):i;a=t.formattingValues[c]||t.formattingValues[i]}else{const i=t.defaultWidth,c=n!=null&&n.width?String(n.width):t.defaultWidth;a=t.values[c]||t.values[i]}const r=t.argumentCallback?t.argumentCallback(e):e;return a[r]}}const cz={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},uz={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},dz={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},fz={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},pz={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},hz={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},mz=(t,e)=>{const n=Number(t),s=n%100;if(s>20||s<10)switch(s%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},gz={ordinalNumber:mz,era:pu({values:cz,defaultWidth:"wide"}),quarter:pu({values:uz,defaultWidth:"wide",argumentCallback:t=>t-1}),month:pu({values:dz,defaultWidth:"wide"}),day:pu({values:fz,defaultWidth:"wide"}),dayPeriod:pu({values:pz,defaultWidth:"wide",formattingValues:hz,defaultFormattingWidth:"wide"})};function hu(t){return(e,n={})=>{const s=n.width,a=s&&t.matchPatterns[s]||t.matchPatterns[t.defaultMatchWidth],r=e.match(a);if(!r)return null;const i=r[0],c=s&&t.parsePatterns[s]||t.parsePatterns[t.defaultParseWidth],d=Array.isArray(c)?xz(c,m=>m.test(i)):bz(c,m=>m.test(i));let f;f=t.valueCallback?t.valueCallback(d):d,f=n.valueCallback?n.valueCallback(f):f;const h=e.slice(i.length);return{value:f,rest:h}}}function bz(t,e){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return n}function xz(t,e){for(let n=0;n<t.length;n++)if(e(t[n]))return n}function yz(t){return(e,n={})=>{const s=e.match(t.matchPattern);if(!s)return null;const a=s[0],r=e.match(t.parsePattern);if(!r)return null;let i=t.valueCallback?t.valueCallback(r[0]):r[0];i=n.valueCallback?n.valueCallback(i):i;const c=e.slice(a.length);return{value:i,rest:c}}}const vz=/^(\d+)(th|st|nd|rd)?/i,wz=/\d+/i,kz={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},Sz={any:[/^b/i,/^(a|c)/i]},Cz={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Az={any:[/1/i,/2/i,/3/i,/4/i]},jz={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},Nz={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},Tz={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},_z={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},Ez={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Mz={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},Dz={ordinalNumber:yz({matchPattern:vz,parsePattern:wz,valueCallback:t=>parseInt(t,10)}),era:hu({matchPatterns:kz,defaultMatchWidth:"wide",parsePatterns:Sz,defaultParseWidth:"any"}),quarter:hu({matchPatterns:Cz,defaultMatchWidth:"wide",parsePatterns:Az,defaultParseWidth:"any",valueCallback:t=>t+1}),month:hu({matchPatterns:jz,defaultMatchWidth:"wide",parsePatterns:Nz,defaultParseWidth:"any"}),day:hu({matchPatterns:Tz,defaultMatchWidth:"wide",parsePatterns:_z,defaultParseWidth:"any"}),dayPeriod:hu({matchPatterns:Ez,defaultMatchWidth:"any",parsePatterns:Mz,defaultParseWidth:"any"})},UN={code:"en-US",formatDistance:nz,formatLong:iz,formatRelative:lz,localize:gz,match:Dz,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Rz(t,e){const n=St(t,e==null?void 0:e.in);return Xl(n,ih(n))+1}function hy(t,e){const n=St(t,e==null?void 0:e.in),s=+Ql(n)-+Q4(n);return Math.round(s/LN)+1}function my(t,e){var h,m,b,y;const n=St(t,e==null?void 0:e.in),s=n.getFullYear(),a=Io(),r=(e==null?void 0:e.firstWeekContainsDate)??((m=(h=e==null?void 0:e.locale)==null?void 0:h.options)==null?void 0:m.firstWeekContainsDate)??a.firstWeekContainsDate??((y=(b=a.locale)==null?void 0:b.options)==null?void 0:y.firstWeekContainsDate)??1,i=vn((e==null?void 0:e.in)||t,0);i.setFullYear(s+1,0,r),i.setHours(0,0,0,0);const c=qr(i,e),d=vn((e==null?void 0:e.in)||t,0);d.setFullYear(s,0,r),d.setHours(0,0,0,0);const f=qr(d,e);return+n>=+c?s+1:+n>=+f?s:s-1}function Oz(t,e){var c,d,f,h;const n=Io(),s=(e==null?void 0:e.firstWeekContainsDate)??((d=(c=e==null?void 0:e.locale)==null?void 0:c.options)==null?void 0:d.firstWeekContainsDate)??n.firstWeekContainsDate??((h=(f=n.locale)==null?void 0:f.options)==null?void 0:h.firstWeekContainsDate)??1,a=my(t,e),r=vn((e==null?void 0:e.in)||t,0);return r.setFullYear(a,0,s),r.setHours(0,0,0,0),qr(r,e)}function HN(t,e){const n=St(t,e==null?void 0:e.in),s=+qr(n,e)-+Oz(n,e);return Math.round(s/LN)+1}function yn(t,e){const n=t<0?"-":"",s=Math.abs(t).toString().padStart(e,"0");return n+s}const ji={y(t,e){const n=t.getFullYear(),s=n>0?n:1-n;return yn(e==="yy"?s%100:s,e.length)},M(t,e){const n=t.getMonth();return e==="M"?String(n+1):yn(n+1,2)},d(t,e){return yn(t.getDate(),e.length)},a(t,e){const n=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(t,e){return yn(t.getHours()%12||12,e.length)},H(t,e){return yn(t.getHours(),e.length)},m(t,e){return yn(t.getMinutes(),e.length)},s(t,e){return yn(t.getSeconds(),e.length)},S(t,e){const n=e.length,s=t.getMilliseconds(),a=Math.trunc(s*Math.pow(10,n-3));return yn(a,e.length)}},Dl={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},HC={G:function(t,e,n){const s=t.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return n.era(s,{width:"abbreviated"});case"GGGGG":return n.era(s,{width:"narrow"});case"GGGG":default:return n.era(s,{width:"wide"})}},y:function(t,e,n){if(e==="yo"){const s=t.getFullYear(),a=s>0?s:1-s;return n.ordinalNumber(a,{unit:"year"})}return ji.y(t,e)},Y:function(t,e,n,s){const a=my(t,s),r=a>0?a:1-a;if(e==="YY"){const i=r%100;return yn(i,2)}return e==="Yo"?n.ordinalNumber(r,{unit:"year"}):yn(r,e.length)},R:function(t,e){const n=PN(t);return yn(n,e.length)},u:function(t,e){const n=t.getFullYear();return yn(n,e.length)},Q:function(t,e,n){const s=Math.ceil((t.getMonth()+1)/3);switch(e){case"Q":return String(s);case"QQ":return yn(s,2);case"Qo":return n.ordinalNumber(s,{unit:"quarter"});case"QQQ":return n.quarter(s,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(s,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(s,{width:"wide",context:"formatting"})}},q:function(t,e,n){const s=Math.ceil((t.getMonth()+1)/3);switch(e){case"q":return String(s);case"qq":return yn(s,2);case"qo":return n.ordinalNumber(s,{unit:"quarter"});case"qqq":return n.quarter(s,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(s,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(s,{width:"wide",context:"standalone"})}},M:function(t,e,n){const s=t.getMonth();switch(e){case"M":case"MM":return ji.M(t,e);case"Mo":return n.ordinalNumber(s+1,{unit:"month"});case"MMM":return n.month(s,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(s,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(s,{width:"wide",context:"formatting"})}},L:function(t,e,n){const s=t.getMonth();switch(e){case"L":return String(s+1);case"LL":return yn(s+1,2);case"Lo":return n.ordinalNumber(s+1,{unit:"month"});case"LLL":return n.month(s,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(s,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(s,{width:"wide",context:"standalone"})}},w:function(t,e,n,s){const a=HN(t,s);return e==="wo"?n.ordinalNumber(a,{unit:"week"}):yn(a,e.length)},I:function(t,e,n){const s=hy(t);return e==="Io"?n.ordinalNumber(s,{unit:"week"}):yn(s,e.length)},d:function(t,e,n){return e==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):ji.d(t,e)},D:function(t,e,n){const s=Rz(t);return e==="Do"?n.ordinalNumber(s,{unit:"dayOfYear"}):yn(s,e.length)},E:function(t,e,n){const s=t.getDay();switch(e){case"E":case"EE":case"EEE":return n.day(s,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(s,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(s,{width:"short",context:"formatting"});case"EEEE":default:return n.day(s,{width:"wide",context:"formatting"})}},e:function(t,e,n,s){const a=t.getDay(),r=(a-s.weekStartsOn+8)%7||7;switch(e){case"e":return String(r);case"ee":return yn(r,2);case"eo":return n.ordinalNumber(r,{unit:"day"});case"eee":return n.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(a,{width:"short",context:"formatting"});case"eeee":default:return n.day(a,{width:"wide",context:"formatting"})}},c:function(t,e,n,s){const a=t.getDay(),r=(a-s.weekStartsOn+8)%7||7;switch(e){case"c":return String(r);case"cc":return yn(r,e.length);case"co":return n.ordinalNumber(r,{unit:"day"});case"ccc":return n.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(a,{width:"narrow",context:"standalone"});case"cccccc":return n.day(a,{width:"short",context:"standalone"});case"cccc":default:return n.day(a,{width:"wide",context:"standalone"})}},i:function(t,e,n){const s=t.getDay(),a=s===0?7:s;switch(e){case"i":return String(a);case"ii":return yn(a,e.length);case"io":return n.ordinalNumber(a,{unit:"day"});case"iii":return n.day(s,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(s,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(s,{width:"short",context:"formatting"});case"iiii":default:return n.day(s,{width:"wide",context:"formatting"})}},a:function(t,e,n){const a=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(t,e,n){const s=t.getHours();let a;switch(s===12?a=Dl.noon:s===0?a=Dl.midnight:a=s/12>=1?"pm":"am",e){case"b":case"bb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(t,e,n){const s=t.getHours();let a;switch(s>=17?a=Dl.evening:s>=12?a=Dl.afternoon:s>=4?a=Dl.morning:a=Dl.night,e){case"B":case"BB":case"BBB":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(t,e,n){if(e==="ho"){let s=t.getHours()%12;return s===0&&(s=12),n.ordinalNumber(s,{unit:"hour"})}return ji.h(t,e)},H:function(t,e,n){return e==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):ji.H(t,e)},K:function(t,e,n){const s=t.getHours()%12;return e==="Ko"?n.ordinalNumber(s,{unit:"hour"}):yn(s,e.length)},k:function(t,e,n){let s=t.getHours();return s===0&&(s=24),e==="ko"?n.ordinalNumber(s,{unit:"hour"}):yn(s,e.length)},m:function(t,e,n){return e==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):ji.m(t,e)},s:function(t,e,n){return e==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):ji.s(t,e)},S:function(t,e){return ji.S(t,e)},X:function(t,e,n){const s=t.getTimezoneOffset();if(s===0)return"Z";switch(e){case"X":return qC(s);case"XXXX":case"XX":return yo(s);case"XXXXX":case"XXX":default:return yo(s,":")}},x:function(t,e,n){const s=t.getTimezoneOffset();switch(e){case"x":return qC(s);case"xxxx":case"xx":return yo(s);case"xxxxx":case"xxx":default:return yo(s,":")}},O:function(t,e,n){const s=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+WC(s,":");case"OOOO":default:return"GMT"+yo(s,":")}},z:function(t,e,n){const s=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+WC(s,":");case"zzzz":default:return"GMT"+yo(s,":")}},t:function(t,e,n){const s=Math.trunc(+t/1e3);return yn(s,e.length)},T:function(t,e,n){return yn(+t,e.length)}};function WC(t,e=""){const n=t>0?"-":"+",s=Math.abs(t),a=Math.trunc(s/60),r=s%60;return r===0?n+String(a):n+String(a)+e+yn(r,2)}function qC(t,e){return t%60===0?(t>0?"-":"+")+yn(Math.abs(t)/60,2):yo(t,e)}function yo(t,e=""){const n=t>0?"-":"+",s=Math.abs(t),a=yn(Math.trunc(s/60),2),r=yn(s%60,2);return n+a+e+r}const VC=(t,e)=>{switch(t){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});case"PPPP":default:return e.date({width:"full"})}},WN=(t,e)=>{switch(t){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});case"pppp":default:return e.time({width:"full"})}},Lz=(t,e)=>{const n=t.match(/(P+)(p+)?/)||[],s=n[1],a=n[2];if(!a)return VC(t,e);let r;switch(s){case"P":r=e.dateTime({width:"short"});break;case"PP":r=e.dateTime({width:"medium"});break;case"PPP":r=e.dateTime({width:"long"});break;case"PPPP":default:r=e.dateTime({width:"full"});break}return r.replace("{{date}}",VC(s,e)).replace("{{time}}",WN(a,e))},xx={p:WN,P:Lz},Iz=/^D+$/,Pz=/^Y+$/,Bz=["D","DD","YY","YYYY"];function Fz(t){return Iz.test(t)}function zz(t){return Pz.test(t)}function $z(t,e,n){const s=Uz(t,e,n);if(console.warn(s),Bz.includes(t))throw new RangeError(s)}function Uz(t,e,n){const s=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${s} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Hz=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Wz=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,qz=/^'([^]*?)'?$/,Vz=/''/g,Yz=/[a-zA-Z]/;function YC(t,e,n){var h,m,b,y,w,C,N,k;const s=Io(),a=(n==null?void 0:n.locale)??s.locale??UN,r=(n==null?void 0:n.firstWeekContainsDate)??((m=(h=n==null?void 0:n.locale)==null?void 0:h.options)==null?void 0:m.firstWeekContainsDate)??s.firstWeekContainsDate??((y=(b=s.locale)==null?void 0:b.options)==null?void 0:y.firstWeekContainsDate)??1,i=(n==null?void 0:n.weekStartsOn)??((C=(w=n==null?void 0:n.locale)==null?void 0:w.options)==null?void 0:C.weekStartsOn)??s.weekStartsOn??((k=(N=s.locale)==null?void 0:N.options)==null?void 0:k.weekStartsOn)??0,c=St(t,n==null?void 0:n.in);if(!Jl(c))throw new RangeError("Invalid time value");let d=e.match(Wz).map(j=>{const S=j[0];if(S==="p"||S==="P"){const T=xx[S];return T(j,a.formatLong)}return j}).join("").match(Hz).map(j=>{if(j==="''")return{isToken:!1,value:"'"};const S=j[0];if(S==="'")return{isToken:!1,value:Gz(j)};if(HC[S])return{isToken:!0,value:j};if(S.match(Yz))throw new RangeError("Format string contains an unescaped latin alphabet character `"+S+"`");return{isToken:!1,value:j}});a.localize.preprocessor&&(d=a.localize.preprocessor(c,d));const f={firstWeekContainsDate:r,weekStartsOn:i,locale:a};return d.map(j=>{if(!j.isToken)return j.value;const S=j.value;(!(n!=null&&n.useAdditionalWeekYearTokens)&&zz(S)||!(n!=null&&n.useAdditionalDayOfYearTokens)&&Fz(S))&&$z(S,e,String(t));const T=HC[S[0]];return T(c,S,a.localize,f)}).join("")}function Gz(t){const e=t.match(qz);return e?e[1].replace(Vz,"'"):t}function GC(t,e){return St(t,e==null?void 0:e.in).getDate()}function Kz(t,e){return St(t,e==null?void 0:e.in).getDay()}function Qz(t,e){const n=St(t,e==null?void 0:e.in),s=n.getFullYear(),a=n.getMonth(),r=vn(n,0);return r.setFullYear(s,a+1,0),r.setHours(0,0,0,0),r.getDate()}function Xz(){return Object.assign({},Io())}function Cs(t,e){return St(t,e==null?void 0:e.in).getHours()}function Jz(t,e){const n=St(t,e==null?void 0:e.in).getDay();return n===0?7:n}function As(t,e){return St(t,e==null?void 0:e.in).getMinutes()}function Ks(t,e){return St(t,e==null?void 0:e.in).getMonth()}function Ei(t){return St(t).getSeconds()}function yx(t){return+St(t)}function Zt(t,e){return St(t,e==null?void 0:e.in).getFullYear()}function $r(t,e){return+St(t)>+St(e)}function ar(t,e){return+St(t)<+St(e)}function Zz(t,e){return+St(t)==+St(e)}function e3(t,e){const n=t3(e)?new e(0):vn(e,0);return n.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),n.setHours(t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()),n}function t3(t){var e;return typeof t=="function"&&((e=t.prototype)==null?void 0:e.constructor)===t}const n3=10;class qN{constructor(){Xe(this,"subPriority",0)}validate(e,n){return!0}}class s3 extends qN{constructor(e,n,s,a,r){super(),this.value=e,this.validateValue=n,this.setValue=s,this.priority=a,r&&(this.subPriority=r)}validate(e,n){return this.validateValue(e,this.value,n)}set(e,n,s){return this.setValue(e,n,this.value,s)}}class a3 extends qN{constructor(n,s){super();Xe(this,"priority",n3);Xe(this,"subPriority",-1);this.context=n||(a=>vn(s,a))}set(n,s){return s.timestampIsSet?n:vn(n,e3(n,this.context))}}class mn{run(e,n,s,a){const r=this.parse(e,n,s,a);return r?{setter:new s3(r.value,this.validate,this.set,this.priority,this.subPriority),rest:r.rest}:null}validate(e,n,s){return!0}}class r3 extends mn{constructor(){super(...arguments);Xe(this,"priority",140);Xe(this,"incompatibleTokens",["R","u","t","T"])}parse(n,s,a){switch(s){case"G":case"GG":case"GGG":return a.era(n,{width:"abbreviated"})||a.era(n,{width:"narrow"});case"GGGGG":return a.era(n,{width:"narrow"});case"GGGG":default:return a.era(n,{width:"wide"})||a.era(n,{width:"abbreviated"})||a.era(n,{width:"narrow"})}}set(n,s,a){return s.era=a,n.setFullYear(a,0,1),n.setHours(0,0,0,0),n}}const Zn={month:/^(1[0-2]|0?\d)/,date:/^(3[0-1]|[0-2]?\d)/,dayOfYear:/^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/,week:/^(5[0-3]|[0-4]?\d)/,hour23h:/^(2[0-3]|[0-1]?\d)/,hour24h:/^(2[0-4]|[0-1]?\d)/,hour11h:/^(1[0-1]|0?\d)/,hour12h:/^(1[0-2]|0?\d)/,minute:/^[0-5]?\d/,second:/^[0-5]?\d/,singleDigit:/^\d/,twoDigits:/^\d{1,2}/,threeDigits:/^\d{1,3}/,fourDigits:/^\d{1,4}/,anyDigitsSigned:/^-?\d+/,singleDigitSigned:/^-?\d/,twoDigitsSigned:/^-?\d{1,2}/,threeDigitsSigned:/^-?\d{1,3}/,fourDigitsSigned:/^-?\d{1,4}/},er={basicOptionalMinutes:/^([+-])(\d{2})(\d{2})?|Z/,basic:/^([+-])(\d{2})(\d{2})|Z/,basicOptionalSeconds:/^([+-])(\d{2})(\d{2})((\d{2}))?|Z/,extended:/^([+-])(\d{2}):(\d{2})|Z/,extendedOptionalSeconds:/^([+-])(\d{2}):(\d{2})(:(\d{2}))?|Z/};function es(t,e){return t&&{value:e(t.value),rest:t.rest}}function $n(t,e){const n=e.match(t);return n?{value:parseInt(n[0],10),rest:e.slice(n[0].length)}:null}function tr(t,e){const n=e.match(t);if(!n)return null;if(n[0]==="Z")return{value:0,rest:e.slice(1)};const s=n[1]==="+"?1:-1,a=n[2]?parseInt(n[2],10):0,r=n[3]?parseInt(n[3],10):0,i=n[5]?parseInt(n[5],10):0;return{value:s*(a*rh+r*ah+i*Y4),rest:e.slice(n[0].length)}}function VN(t){return $n(Zn.anyDigitsSigned,t)}function Kn(t,e){switch(t){case 1:return $n(Zn.singleDigit,e);case 2:return $n(Zn.twoDigits,e);case 3:return $n(Zn.threeDigits,e);case 4:return $n(Zn.fourDigits,e);default:return $n(new RegExp("^\\d{1,"+t+"}"),e)}}function Dp(t,e){switch(t){case 1:return $n(Zn.singleDigitSigned,e);case 2:return $n(Zn.twoDigitsSigned,e);case 3:return $n(Zn.threeDigitsSigned,e);case 4:return $n(Zn.fourDigitsSigned,e);default:return $n(new RegExp("^-?\\d{1,"+t+"}"),e)}}function gy(t){switch(t){case"morning":return 4;case"evening":return 17;case"pm":case"noon":case"afternoon":return 12;case"am":case"midnight":case"night":default:return 0}}function YN(t,e){const n=e>0,s=n?e:1-e;let a;if(s<=50)a=t||100;else{const r=s+50,i=Math.trunc(r/100)*100,c=t>=r%100;a=t+i-(c?100:0)}return n?a:1-a}function GN(t){return t%400===0||t%4===0&&t%100!==0}class i3 extends mn{constructor(){super(...arguments);Xe(this,"priority",130);Xe(this,"incompatibleTokens",["Y","R","u","w","I","i","e","c","t","T"])}parse(n,s,a){const r=i=>({year:i,isTwoDigitYear:s==="yy"});switch(s){case"y":return es(Kn(4,n),r);case"yo":return es(a.ordinalNumber(n,{unit:"year"}),r);default:return es(Kn(s.length,n),r)}}validate(n,s){return s.isTwoDigitYear||s.year>0}set(n,s,a){const r=n.getFullYear();if(a.isTwoDigitYear){const c=YN(a.year,r);return n.setFullYear(c,0,1),n.setHours(0,0,0,0),n}const i=!("era"in s)||s.era===1?a.year:1-a.year;return n.setFullYear(i,0,1),n.setHours(0,0,0,0),n}}class o3 extends mn{constructor(){super(...arguments);Xe(this,"priority",130);Xe(this,"incompatibleTokens",["y","R","u","Q","q","M","L","I","d","D","i","t","T"])}parse(n,s,a){const r=i=>({year:i,isTwoDigitYear:s==="YY"});switch(s){case"Y":return es(Kn(4,n),r);case"Yo":return es(a.ordinalNumber(n,{unit:"year"}),r);default:return es(Kn(s.length,n),r)}}validate(n,s){return s.isTwoDigitYear||s.year>0}set(n,s,a,r){const i=my(n,r);if(a.isTwoDigitYear){const d=YN(a.year,i);return n.setFullYear(d,0,r.firstWeekContainsDate),n.setHours(0,0,0,0),qr(n,r)}const c=!("era"in s)||s.era===1?a.year:1-a.year;return n.setFullYear(c,0,r.firstWeekContainsDate),n.setHours(0,0,0,0),qr(n,r)}}class l3 extends mn{constructor(){super(...arguments);Xe(this,"priority",130);Xe(this,"incompatibleTokens",["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"])}parse(n,s){return Dp(s==="R"?4:s.length,n)}set(n,s,a){const r=vn(n,0);return r.setFullYear(a,0,4),r.setHours(0,0,0,0),Ql(r)}}class c3 extends mn{constructor(){super(...arguments);Xe(this,"priority",130);Xe(this,"incompatibleTokens",["G","y","Y","R","w","I","i","e","c","t","T"])}parse(n,s){return Dp(s==="u"?4:s.length,n)}set(n,s,a){return n.setFullYear(a,0,1),n.setHours(0,0,0,0),n}}class u3 extends mn{constructor(){super(...arguments);Xe(this,"priority",120);Xe(this,"incompatibleTokens",["Y","R","q","M","L","w","I","d","D","i","e","c","t","T"])}parse(n,s,a){switch(s){case"Q":case"QQ":return Kn(s.length,n);case"Qo":return a.ordinalNumber(n,{unit:"quarter"});case"QQQ":return a.quarter(n,{width:"abbreviated",context:"formatting"})||a.quarter(n,{width:"narrow",context:"formatting"});case"QQQQQ":return a.quarter(n,{width:"narrow",context:"formatting"});case"QQQQ":default:return a.quarter(n,{width:"wide",context:"formatting"})||a.quarter(n,{width:"abbreviated",context:"formatting"})||a.quarter(n,{width:"narrow",context:"formatting"})}}validate(n,s){return s>=1&&s<=4}set(n,s,a){return n.setMonth((a-1)*3,1),n.setHours(0,0,0,0),n}}class d3 extends mn{constructor(){super(...arguments);Xe(this,"priority",120);Xe(this,"incompatibleTokens",["Y","R","Q","M","L","w","I","d","D","i","e","c","t","T"])}parse(n,s,a){switch(s){case"q":case"qq":return Kn(s.length,n);case"qo":return a.ordinalNumber(n,{unit:"quarter"});case"qqq":return a.quarter(n,{width:"abbreviated",context:"standalone"})||a.quarter(n,{width:"narrow",context:"standalone"});case"qqqqq":return a.quarter(n,{width:"narrow",context:"standalone"});case"qqqq":default:return a.quarter(n,{width:"wide",context:"standalone"})||a.quarter(n,{width:"abbreviated",context:"standalone"})||a.quarter(n,{width:"narrow",context:"standalone"})}}validate(n,s){return s>=1&&s<=4}set(n,s,a){return n.setMonth((a-1)*3,1),n.setHours(0,0,0,0),n}}class f3 extends mn{constructor(){super(...arguments);Xe(this,"incompatibleTokens",["Y","R","q","Q","L","w","I","D","i","e","c","t","T"]);Xe(this,"priority",110)}parse(n,s,a){const r=i=>i-1;switch(s){case"M":return es($n(Zn.month,n),r);case"MM":return es(Kn(2,n),r);case"Mo":return es(a.ordinalNumber(n,{unit:"month"}),r);case"MMM":return a.month(n,{width:"abbreviated",context:"formatting"})||a.month(n,{width:"narrow",context:"formatting"});case"MMMMM":return a.month(n,{width:"narrow",context:"formatting"});case"MMMM":default:return a.month(n,{width:"wide",context:"formatting"})||a.month(n,{width:"abbreviated",context:"formatting"})||a.month(n,{width:"narrow",context:"formatting"})}}validate(n,s){return s>=0&&s<=11}set(n,s,a){return n.setMonth(a,1),n.setHours(0,0,0,0),n}}class p3 extends mn{constructor(){super(...arguments);Xe(this,"priority",110);Xe(this,"incompatibleTokens",["Y","R","q","Q","M","w","I","D","i","e","c","t","T"])}parse(n,s,a){const r=i=>i-1;switch(s){case"L":return es($n(Zn.month,n),r);case"LL":return es(Kn(2,n),r);case"Lo":return es(a.ordinalNumber(n,{unit:"month"}),r);case"LLL":return a.month(n,{width:"abbreviated",context:"standalone"})||a.month(n,{width:"narrow",context:"standalone"});case"LLLLL":return a.month(n,{width:"narrow",context:"standalone"});case"LLLL":default:return a.month(n,{width:"wide",context:"standalone"})||a.month(n,{width:"abbreviated",context:"standalone"})||a.month(n,{width:"narrow",context:"standalone"})}}validate(n,s){return s>=0&&s<=11}set(n,s,a){return n.setMonth(a,1),n.setHours(0,0,0,0),n}}function h3(t,e,n){const s=St(t,n==null?void 0:n.in),a=HN(s,n)-e;return s.setDate(s.getDate()-a*7),St(s,n==null?void 0:n.in)}class m3 extends mn{constructor(){super(...arguments);Xe(this,"priority",100);Xe(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","i","t","T"])}parse(n,s,a){switch(s){case"w":return $n(Zn.week,n);case"wo":return a.ordinalNumber(n,{unit:"week"});default:return Kn(s.length,n)}}validate(n,s){return s>=1&&s<=53}set(n,s,a,r){return qr(h3(n,a,r),r)}}function g3(t,e,n){const s=St(t,n==null?void 0:n.in),a=hy(s,n)-e;return s.setDate(s.getDate()-a*7),s}class b3 extends mn{constructor(){super(...arguments);Xe(this,"priority",100);Xe(this,"incompatibleTokens",["y","Y","u","q","Q","M","L","w","d","D","e","c","t","T"])}parse(n,s,a){switch(s){case"I":return $n(Zn.week,n);case"Io":return a.ordinalNumber(n,{unit:"week"});default:return Kn(s.length,n)}}validate(n,s){return s>=1&&s<=53}set(n,s,a){return Ql(g3(n,a))}}const x3=[31,28,31,30,31,30,31,31,30,31,30,31],y3=[31,29,31,30,31,30,31,31,30,31,30,31];class v3 extends mn{constructor(){super(...arguments);Xe(this,"priority",90);Xe(this,"subPriority",1);Xe(this,"incompatibleTokens",["Y","R","q","Q","w","I","D","i","e","c","t","T"])}parse(n,s,a){switch(s){case"d":return $n(Zn.date,n);case"do":return a.ordinalNumber(n,{unit:"date"});default:return Kn(s.length,n)}}validate(n,s){const a=n.getFullYear(),r=GN(a),i=n.getMonth();return r?s>=1&&s<=y3[i]:s>=1&&s<=x3[i]}set(n,s,a){return n.setDate(a),n.setHours(0,0,0,0),n}}class w3 extends mn{constructor(){super(...arguments);Xe(this,"priority",90);Xe(this,"subpriority",1);Xe(this,"incompatibleTokens",["Y","R","q","Q","M","L","w","I","d","E","i","e","c","t","T"])}parse(n,s,a){switch(s){case"D":case"DD":return $n(Zn.dayOfYear,n);case"Do":return a.ordinalNumber(n,{unit:"date"});default:return Kn(s.length,n)}}validate(n,s){const a=n.getFullYear();return GN(a)?s>=1&&s<=366:s>=1&&s<=365}set(n,s,a){return n.setMonth(0,a),n.setHours(0,0,0,0),n}}function by(t,e,n){var m,b,y,w;const s=Io(),a=(n==null?void 0:n.weekStartsOn)??((b=(m=n==null?void 0:n.locale)==null?void 0:m.options)==null?void 0:b.weekStartsOn)??s.weekStartsOn??((w=(y=s.locale)==null?void 0:y.options)==null?void 0:w.weekStartsOn)??0,r=St(t,n==null?void 0:n.in),i=r.getDay(),d=(e%7+7)%7,f=7-a,h=e<0||e>6?e-(i+f)%7:(d+f)%7-(i+f)%7;return Pa(r,h,n)}class k3 extends mn{constructor(){super(...arguments);Xe(this,"priority",90);Xe(this,"incompatibleTokens",["D","i","e","c","t","T"])}parse(n,s,a){switch(s){case"E":case"EE":case"EEE":return a.day(n,{width:"abbreviated",context:"formatting"})||a.day(n,{width:"short",context:"formatting"})||a.day(n,{width:"narrow",context:"formatting"});case"EEEEE":return a.day(n,{width:"narrow",context:"formatting"});case"EEEEEE":return a.day(n,{width:"short",context:"formatting"})||a.day(n,{width:"narrow",context:"formatting"});case"EEEE":default:return a.day(n,{width:"wide",context:"formatting"})||a.day(n,{width:"abbreviated",context:"formatting"})||a.day(n,{width:"short",context:"formatting"})||a.day(n,{width:"narrow",context:"formatting"})}}validate(n,s){return s>=0&&s<=6}set(n,s,a,r){return n=by(n,a,r),n.setHours(0,0,0,0),n}}class S3 extends mn{constructor(){super(...arguments);Xe(this,"priority",90);Xe(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","E","i","c","t","T"])}parse(n,s,a,r){const i=c=>{const d=Math.floor((c-1)/7)*7;return(c+r.weekStartsOn+6)%7+d};switch(s){case"e":case"ee":return es(Kn(s.length,n),i);case"eo":return es(a.ordinalNumber(n,{unit:"day"}),i);case"eee":return a.day(n,{width:"abbreviated",context:"formatting"})||a.day(n,{width:"short",context:"formatting"})||a.day(n,{width:"narrow",context:"formatting"});case"eeeee":return a.day(n,{width:"narrow",context:"formatting"});case"eeeeee":return a.day(n,{width:"short",context:"formatting"})||a.day(n,{width:"narrow",context:"formatting"});case"eeee":default:return a.day(n,{width:"wide",context:"formatting"})||a.day(n,{width:"abbreviated",context:"formatting"})||a.day(n,{width:"short",context:"formatting"})||a.day(n,{width:"narrow",context:"formatting"})}}validate(n,s){return s>=0&&s<=6}set(n,s,a,r){return n=by(n,a,r),n.setHours(0,0,0,0),n}}class C3 extends mn{constructor(){super(...arguments);Xe(this,"priority",90);Xe(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","E","i","e","t","T"])}parse(n,s,a,r){const i=c=>{const d=Math.floor((c-1)/7)*7;return(c+r.weekStartsOn+6)%7+d};switch(s){case"c":case"cc":return es(Kn(s.length,n),i);case"co":return es(a.ordinalNumber(n,{unit:"day"}),i);case"ccc":return a.day(n,{width:"abbreviated",context:"standalone"})||a.day(n,{width:"short",context:"standalone"})||a.day(n,{width:"narrow",context:"standalone"});case"ccccc":return a.day(n,{width:"narrow",context:"standalone"});case"cccccc":return a.day(n,{width:"short",context:"standalone"})||a.day(n,{width:"narrow",context:"standalone"});case"cccc":default:return a.day(n,{width:"wide",context:"standalone"})||a.day(n,{width:"abbreviated",context:"standalone"})||a.day(n,{width:"short",context:"standalone"})||a.day(n,{width:"narrow",context:"standalone"})}}validate(n,s){return s>=0&&s<=6}set(n,s,a,r){return n=by(n,a,r),n.setHours(0,0,0,0),n}}function A3(t,e,n){const s=St(t,n==null?void 0:n.in),a=Jz(s,n),r=e-a;return Pa(s,r,n)}class j3 extends mn{constructor(){super(...arguments);Xe(this,"priority",90);Xe(this,"incompatibleTokens",["y","Y","u","q","Q","M","L","w","d","D","E","e","c","t","T"])}parse(n,s,a){const r=i=>i===0?7:i;switch(s){case"i":case"ii":return Kn(s.length,n);case"io":return a.ordinalNumber(n,{unit:"day"});case"iii":return es(a.day(n,{width:"abbreviated",context:"formatting"})||a.day(n,{width:"short",context:"formatting"})||a.day(n,{width:"narrow",context:"formatting"}),r);case"iiiii":return es(a.day(n,{width:"narrow",context:"formatting"}),r);case"iiiiii":return es(a.day(n,{width:"short",context:"formatting"})||a.day(n,{width:"narrow",context:"formatting"}),r);case"iiii":default:return es(a.day(n,{width:"wide",context:"formatting"})||a.day(n,{width:"abbreviated",context:"formatting"})||a.day(n,{width:"short",context:"formatting"})||a.day(n,{width:"narrow",context:"formatting"}),r)}}validate(n,s){return s>=1&&s<=7}set(n,s,a){return n=A3(n,a),n.setHours(0,0,0,0),n}}class N3 extends mn{constructor(){super(...arguments);Xe(this,"priority",80);Xe(this,"incompatibleTokens",["b","B","H","k","t","T"])}parse(n,s,a){switch(s){case"a":case"aa":case"aaa":return a.dayPeriod(n,{width:"abbreviated",context:"formatting"})||a.dayPeriod(n,{width:"narrow",context:"formatting"});case"aaaaa":return a.dayPeriod(n,{width:"narrow",context:"formatting"});case"aaaa":default:return a.dayPeriod(n,{width:"wide",context:"formatting"})||a.dayPeriod(n,{width:"abbreviated",context:"formatting"})||a.dayPeriod(n,{width:"narrow",context:"formatting"})}}set(n,s,a){return n.setHours(gy(a),0,0,0),n}}class T3 extends mn{constructor(){super(...arguments);Xe(this,"priority",80);Xe(this,"incompatibleTokens",["a","B","H","k","t","T"])}parse(n,s,a){switch(s){case"b":case"bb":case"bbb":return a.dayPeriod(n,{width:"abbreviated",context:"formatting"})||a.dayPeriod(n,{width:"narrow",context:"formatting"});case"bbbbb":return a.dayPeriod(n,{width:"narrow",context:"formatting"});case"bbbb":default:return a.dayPeriod(n,{width:"wide",context:"formatting"})||a.dayPeriod(n,{width:"abbreviated",context:"formatting"})||a.dayPeriod(n,{width:"narrow",context:"formatting"})}}set(n,s,a){return n.setHours(gy(a),0,0,0),n}}class _3 extends mn{constructor(){super(...arguments);Xe(this,"priority",80);Xe(this,"incompatibleTokens",["a","b","t","T"])}parse(n,s,a){switch(s){case"B":case"BB":case"BBB":return a.dayPeriod(n,{width:"abbreviated",context:"formatting"})||a.dayPeriod(n,{width:"narrow",context:"formatting"});case"BBBBB":return a.dayPeriod(n,{width:"narrow",context:"formatting"});case"BBBB":default:return a.dayPeriod(n,{width:"wide",context:"formatting"})||a.dayPeriod(n,{width:"abbreviated",context:"formatting"})||a.dayPeriod(n,{width:"narrow",context:"formatting"})}}set(n,s,a){return n.setHours(gy(a),0,0,0),n}}class E3 extends mn{constructor(){super(...arguments);Xe(this,"priority",70);Xe(this,"incompatibleTokens",["H","K","k","t","T"])}parse(n,s,a){switch(s){case"h":return $n(Zn.hour12h,n);case"ho":return a.ordinalNumber(n,{unit:"hour"});default:return Kn(s.length,n)}}validate(n,s){return s>=1&&s<=12}set(n,s,a){const r=n.getHours()>=12;return r&&a<12?n.setHours(a+12,0,0,0):!r&&a===12?n.setHours(0,0,0,0):n.setHours(a,0,0,0),n}}class M3 extends mn{constructor(){super(...arguments);Xe(this,"priority",70);Xe(this,"incompatibleTokens",["a","b","h","K","k","t","T"])}parse(n,s,a){switch(s){case"H":return $n(Zn.hour23h,n);case"Ho":return a.ordinalNumber(n,{unit:"hour"});default:return Kn(s.length,n)}}validate(n,s){return s>=0&&s<=23}set(n,s,a){return n.setHours(a,0,0,0),n}}class D3 extends mn{constructor(){super(...arguments);Xe(this,"priority",70);Xe(this,"incompatibleTokens",["h","H","k","t","T"])}parse(n,s,a){switch(s){case"K":return $n(Zn.hour11h,n);case"Ko":return a.ordinalNumber(n,{unit:"hour"});default:return Kn(s.length,n)}}validate(n,s){return s>=0&&s<=11}set(n,s,a){return n.getHours()>=12&&a<12?n.setHours(a+12,0,0,0):n.setHours(a,0,0,0),n}}class R3 extends mn{constructor(){super(...arguments);Xe(this,"priority",70);Xe(this,"incompatibleTokens",["a","b","h","H","K","t","T"])}parse(n,s,a){switch(s){case"k":return $n(Zn.hour24h,n);case"ko":return a.ordinalNumber(n,{unit:"hour"});default:return Kn(s.length,n)}}validate(n,s){return s>=1&&s<=24}set(n,s,a){const r=a<=24?a%24:a;return n.setHours(r,0,0,0),n}}class O3 extends mn{constructor(){super(...arguments);Xe(this,"priority",60);Xe(this,"incompatibleTokens",["t","T"])}parse(n,s,a){switch(s){case"m":return $n(Zn.minute,n);case"mo":return a.ordinalNumber(n,{unit:"minute"});default:return Kn(s.length,n)}}validate(n,s){return s>=0&&s<=59}set(n,s,a){return n.setMinutes(a,0,0),n}}class L3 extends mn{constructor(){super(...arguments);Xe(this,"priority",50);Xe(this,"incompatibleTokens",["t","T"])}parse(n,s,a){switch(s){case"s":return $n(Zn.second,n);case"so":return a.ordinalNumber(n,{unit:"second"});default:return Kn(s.length,n)}}validate(n,s){return s>=0&&s<=59}set(n,s,a){return n.setSeconds(a,0),n}}class I3 extends mn{constructor(){super(...arguments);Xe(this,"priority",30);Xe(this,"incompatibleTokens",["t","T"])}parse(n,s){const a=r=>Math.trunc(r*Math.pow(10,-s.length+3));return es(Kn(s.length,n),a)}set(n,s,a){return n.setMilliseconds(a),n}}class P3 extends mn{constructor(){super(...arguments);Xe(this,"priority",10);Xe(this,"incompatibleTokens",["t","T","x"])}parse(n,s){switch(s){case"X":return tr(er.basicOptionalMinutes,n);case"XX":return tr(er.basic,n);case"XXXX":return tr(er.basicOptionalSeconds,n);case"XXXXX":return tr(er.extendedOptionalSeconds,n);case"XXX":default:return tr(er.extended,n)}}set(n,s,a){return s.timestampIsSet?n:vn(n,n.getTime()-Np(n)-a)}}class B3 extends mn{constructor(){super(...arguments);Xe(this,"priority",10);Xe(this,"incompatibleTokens",["t","T","X"])}parse(n,s){switch(s){case"x":return tr(er.basicOptionalMinutes,n);case"xx":return tr(er.basic,n);case"xxxx":return tr(er.basicOptionalSeconds,n);case"xxxxx":return tr(er.extendedOptionalSeconds,n);case"xxx":default:return tr(er.extended,n)}}set(n,s,a){return s.timestampIsSet?n:vn(n,n.getTime()-Np(n)-a)}}class F3 extends mn{constructor(){super(...arguments);Xe(this,"priority",40);Xe(this,"incompatibleTokens","*")}parse(n){return VN(n)}set(n,s,a){return[vn(n,a*1e3),{timestampIsSet:!0}]}}class z3 extends mn{constructor(){super(...arguments);Xe(this,"priority",20);Xe(this,"incompatibleTokens","*")}parse(n){return VN(n)}set(n,s,a){return[vn(n,a),{timestampIsSet:!0}]}}const $3={G:new r3,y:new i3,Y:new o3,R:new l3,u:new c3,Q:new u3,q:new d3,M:new f3,L:new p3,w:new m3,I:new b3,d:new v3,D:new w3,E:new k3,e:new S3,c:new C3,i:new j3,a:new N3,b:new T3,B:new _3,h:new E3,H:new M3,K:new D3,k:new R3,m:new O3,s:new L3,S:new I3,X:new P3,x:new B3,t:new F3,T:new z3},U3=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,H3=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,W3=/^'([^]*?)'?$/,q3=/''/g,V3=/\S/,Y3=/[a-zA-Z]/;function G3(t,e,n,s){var N,k,j,S,T,D,E,I;const a=()=>vn((s==null?void 0:s.in)||n,NaN),r=Xz(),i=(s==null?void 0:s.locale)??r.locale??UN,c=(s==null?void 0:s.firstWeekContainsDate)??((k=(N=s==null?void 0:s.locale)==null?void 0:N.options)==null?void 0:k.firstWeekContainsDate)??r.firstWeekContainsDate??((S=(j=r.locale)==null?void 0:j.options)==null?void 0:S.firstWeekContainsDate)??1,d=(s==null?void 0:s.weekStartsOn)??((D=(T=s==null?void 0:s.locale)==null?void 0:T.options)==null?void 0:D.weekStartsOn)??r.weekStartsOn??((I=(E=r.locale)==null?void 0:E.options)==null?void 0:I.weekStartsOn)??0;if(!e)return t?a():St(n,s==null?void 0:s.in);const f={firstWeekContainsDate:c,weekStartsOn:d,locale:i},h=[new a3(s==null?void 0:s.in,n)],m=e.match(H3).map(O=>{const _=O[0];if(_ in xx){const M=xx[_];return M(O,i.formatLong)}return O}).join("").match(U3),b=[];for(let O of m){const _=O[0],M=$3[_];if(M){const{incompatibleTokens:R}=M;if(Array.isArray(R)){const $=b.find(W=>R.includes(W.token)||W.token===_);if($)throw new RangeError(`The format string mustn't contain \`${$.fullToken}\` and \`${O}\` at the same time`)}else if(M.incompatibleTokens==="*"&&b.length>0)throw new RangeError(`The format string mustn't contain \`${O}\` and any other token at the same time`);b.push({token:_,fullToken:O});const z=M.run(t,O,i.match,f);if(!z)return a();h.push(z.setter),t=z.rest}else{if(_.match(Y3))throw new RangeError("Format string contains an unescaped latin alphabet character `"+_+"`");if(O==="''"?O="'":_==="'"&&(O=K3(O)),t.indexOf(O)===0)t=t.slice(O.length);else return a()}}if(t.length>0&&V3.test(t))return a();const y=h.map(O=>O.priority).sort((O,_)=>_-O).filter((O,_,M)=>M.indexOf(O)===_).map(O=>h.filter(_=>_.priority===O).sort((_,M)=>M.subPriority-_.subPriority)).map(O=>O[0]);let w=St(n,s==null?void 0:s.in);if(isNaN(+w))return a();const C={};for(const O of y){if(!O.validate(w,f))return a();const _=O.set(w,C,f);Array.isArray(_)?(w=_[0],Object.assign(C,_[1])):w=_}return w}function K3(t){return t.match(W3)[1].replace(q3,"'")}function Q3(t,e,n){const[s,a]=Gr(n==null?void 0:n.in,t,e);return s.getFullYear()===a.getFullYear()&&s.getMonth()===a.getMonth()}function X3(t,e,n){const[s,a]=Gr(n==null?void 0:n.in,t,e);return+bx(s)==+bx(a)}function J3(t,e,n){const[s,a]=Gr(n==null?void 0:n.in,t,e);return s.getFullYear()===a.getFullYear()}function Ku(t,e,n){const s=+St(t,n==null?void 0:n.in),[a,r]=[+St(e.start,n==null?void 0:n.in),+St(e.end,n==null?void 0:n.in)].sort((i,c)=>i-c);return s>=a&&s<=r}function Z3(t,e,n){return Pa(t,-1,n)}function e$(t,e){const n=()=>vn(e==null?void 0:e.in,NaN),a=a$(t);let r;if(a.date){const f=r$(a.date,2);r=i$(f.restDateString,f.year)}if(!r||isNaN(+r))return n();const i=+r;let c=0,d;if(a.time&&(c=o$(a.time),isNaN(c)))return n();if(a.timezone){if(d=l$(a.timezone),isNaN(d))return n()}else{const f=new Date(i+c),h=St(0,e==null?void 0:e.in);return h.setFullYear(f.getUTCFullYear(),f.getUTCMonth(),f.getUTCDate()),h.setHours(f.getUTCHours(),f.getUTCMinutes(),f.getUTCSeconds(),f.getUTCMilliseconds()),h}return St(i+c+d,e==null?void 0:e.in)}const Ff={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},t$=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,n$=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,s$=/^([+-])(\d{2})(?::?(\d{2}))?$/;function a$(t){const e={},n=t.split(Ff.dateTimeDelimiter);let s;if(n.length>2)return e;if(/:/.test(n[0])?s=n[0]:(e.date=n[0],s=n[1],Ff.timeZoneDelimiter.test(e.date)&&(e.date=t.split(Ff.timeZoneDelimiter)[0],s=t.substr(e.date.length,t.length))),s){const a=Ff.timezone.exec(s);a?(e.time=s.replace(a[1],""),e.timezone=a[1]):e.time=s}return e}function r$(t,e){const n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+e)+"})|(\\d{2}|[+-]\\d{"+(2+e)+"})$)"),s=t.match(n);if(!s)return{year:NaN,restDateString:""};const a=s[1]?parseInt(s[1]):null,r=s[2]?parseInt(s[2]):null;return{year:r===null?a:r*100,restDateString:t.slice((s[1]||s[2]).length)}}function i$(t,e){if(e===null)return new Date(NaN);const n=t.match(t$);if(!n)return new Date(NaN);const s=!!n[4],a=mu(n[1]),r=mu(n[2])-1,i=mu(n[3]),c=mu(n[4]),d=mu(n[5])-1;if(s)return p$(e,c,d)?c$(e,c,d):new Date(NaN);{const f=new Date(0);return!d$(e,r,i)||!f$(e,a)?new Date(NaN):(f.setUTCFullYear(e,r,Math.max(a,i)),f)}}function mu(t){return t?parseInt(t):1}function o$(t){const e=t.match(n$);if(!e)return NaN;const n=mb(e[1]),s=mb(e[2]),a=mb(e[3]);return h$(n,s,a)?n*rh+s*ah+a*1e3:NaN}function mb(t){return t&&parseFloat(t.replace(",","."))||0}function l$(t){if(t==="Z")return 0;const e=t.match(s$);if(!e)return 0;const n=e[1]==="+"?-1:1,s=parseInt(e[2]),a=e[3]&&parseInt(e[3])||0;return m$(s,a)?n*(s*rh+a*ah):NaN}function c$(t,e,n){const s=new Date(0);s.setUTCFullYear(t,0,4);const a=s.getUTCDay()||7,r=(e-1)*7+n+1-a;return s.setUTCDate(s.getUTCDate()+r),s}const u$=[31,null,31,30,31,30,31,31,30,31,30,31];function KN(t){return t%400===0||t%4===0&&t%100!==0}function d$(t,e,n){return e>=0&&e<=11&&n>=1&&n<=(u$[e]||(KN(t)?29:28))}function f$(t,e){return e>=1&&e<=(KN(t)?366:365)}function p$(t,e,n){return e>=1&&e<=53&&n>=0&&n<=6}function h$(t,e,n){return t===24?e===0&&n===0:n>=0&&n<60&&e>=0&&e<60&&t>=0&&t<25}function m$(t,e){return e>=0&&e<=59}function oa(t,e,n){const s=St(t,n==null?void 0:n.in),a=s.getFullYear(),r=s.getDate(),i=vn(t,0);i.setFullYear(a,e,15),i.setHours(0,0,0,0);const c=Qz(i);return s.setMonth(e,Math.min(r,c)),s}function sp(t,e,n){const s=St(t,n==null?void 0:n.in);return s.setHours(e),s}function ap(t,e,n){const s=St(t,n==null?void 0:n.in);return s.setMinutes(e),s}function Bl(t,e,n){const s=St(t,n==null?void 0:n.in),a=Math.trunc(s.getMonth()/3)+1,r=e-a;return oa(s,s.getMonth()+r*3)}function rp(t,e,n){const s=St(t,n==null?void 0:n.in);return s.setSeconds(e),s}function Ja(t,e,n){const s=St(t,n==null?void 0:n.in);return isNaN(+s)?vn(t,NaN):(s.setFullYear(e),s)}function Ao(t,e,n){return za(t,-e,n)}function QN(t,e,n){return py(t,-1,n)}function KC(t,e,n){return Tp(t,-1,n)}function Ri(t,e,n){return Ba(t,-e,n)}function oh(){return typeof window<"u"}function oc(t){return XN(t)?(t.nodeName||"").toLowerCase():"#document"}function fa(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function mr(t){var e;return(e=(XN(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function XN(t){return oh()?t instanceof Node||t instanceof fa(t).Node:!1}function Ds(t){return oh()?t instanceof Element||t instanceof fa(t).Element:!1}function Kr(t){return oh()?t instanceof HTMLElement||t instanceof fa(t).HTMLElement:!1}function QC(t){return!oh()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof fa(t).ShadowRoot}function ad(t){const{overflow:e,overflowX:n,overflowY:s,display:a}=_a(t);return/auto|scroll|overlay|hidden|clip/.test(e+s+n)&&a!=="inline"&&a!=="contents"}function g$(t){return/^(table|td|th)$/.test(oc(t))}function lh(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const b$=/transform|translate|scale|rotate|perspective|filter/,x$=/paint|layout|strict|content/,go=t=>!!t&&t!=="none";let gb;function xy(t){const e=Ds(t)?_a(t):t;return go(e.transform)||go(e.translate)||go(e.scale)||go(e.rotate)||go(e.perspective)||!yy()&&(go(e.backdropFilter)||go(e.filter))||b$.test(e.willChange||"")||x$.test(e.contain||"")}function y$(t){let e=Oi(t);for(;Kr(e)&&!Zl(e);){if(xy(e))return e;if(lh(e))return null;e=Oi(e)}return null}function yy(){return gb==null&&(gb=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),gb}function Zl(t){return/^(html|body|#document)$/.test(oc(t))}function _a(t){return fa(t).getComputedStyle(t)}function ch(t){return Ds(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Oi(t){if(oc(t)==="html")return t;const e=t.assignedSlot||t.parentNode||QC(t)&&t.host||mr(t);return QC(e)?e.host:e}function JN(t){const e=Oi(t);return Zl(e)?t.ownerDocument?t.ownerDocument.body:t.body:Kr(e)&&ad(e)?e:JN(e)}function Qu(t,e,n){var s;e===void 0&&(e=[]),n===void 0&&(n=!0);const a=JN(t),r=a===((s=t.ownerDocument)==null?void 0:s.body),i=fa(a);if(r){const c=vx(i);return e.concat(i,i.visualViewport||[],ad(a)?a:[],c&&n?Qu(c):[])}else return e.concat(a,Qu(a,[],n))}function vx(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}const ec=Math.min,jo=Math.max,Rp=Math.round,zf=Math.floor,or=t=>({x:t,y:t}),v$={left:"right",right:"left",bottom:"top",top:"bottom"};function w$(t,e,n){return jo(t,ec(e,n))}function uh(t,e){return typeof t=="function"?t(e):t}function tc(t){return t.split("-")[0]}function rd(t){return t.split("-")[1]}function k$(t){return t==="x"?"y":"x"}function vy(t){return t==="y"?"height":"width"}function ko(t){const e=t[0];return e==="t"||e==="b"?"y":"x"}function wy(t){return k$(ko(t))}function S$(t,e,n){n===void 0&&(n=!1);const s=rd(t),a=wy(t),r=vy(a);let i=a==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return e.reference[r]>e.floating[r]&&(i=Op(i)),[i,Op(i)]}function C$(t){const e=Op(t);return[wx(t),e,wx(e)]}function wx(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const XC=["left","right"],JC=["right","left"],A$=["top","bottom"],j$=["bottom","top"];function N$(t,e,n){switch(t){case"top":case"bottom":return n?e?JC:XC:e?XC:JC;case"left":case"right":return e?A$:j$;default:return[]}}function T$(t,e,n,s){const a=rd(t);let r=N$(tc(t),n==="start",s);return a&&(r=r.map(i=>i+"-"+a),e&&(r=r.concat(r.map(wx)))),r}function Op(t){const e=tc(t);return v$[e]+t.slice(e.length)}function _$(t){return{top:0,right:0,bottom:0,left:0,...t}}function ZN(t){return typeof t!="number"?_$(t):{top:t,right:t,bottom:t,left:t}}function Lp(t){const{x:e,y:n,width:s,height:a}=t;return{width:s,height:a,top:n,left:e,right:e+s,bottom:n+a,x:e,y:n}}var E$=typeof document<"u",M$=function(){},Ip=E$?x.useLayoutEffect:M$;const D$={...pj},R$=D$.useInsertionEffect,O$=R$||(t=>t());function L$(t){const e=x.useRef(()=>{});return O$(()=>{e.current=t}),x.useCallback(function(){for(var n=arguments.length,s=new Array(n),a=0;a<n;a++)s[a]=arguments[a];return e.current==null?void 0:e.current(...s)},[])}function ZC(t,e,n){let{reference:s,floating:a}=t;const r=ko(e),i=wy(e),c=vy(i),d=tc(e),f=r==="y",h=s.x+s.width/2-a.width/2,m=s.y+s.height/2-a.height/2,b=s[c]/2-a[c]/2;let y;switch(d){case"top":y={x:h,y:s.y-a.height};break;case"bottom":y={x:h,y:s.y+s.height};break;case"right":y={x:s.x+s.width,y:m};break;case"left":y={x:s.x-a.width,y:m};break;default:y={x:s.x,y:s.y}}switch(rd(e)){case"start":y[i]-=b*(n&&f?-1:1);break;case"end":y[i]+=b*(n&&f?-1:1);break}return y}async function I$(t,e){var n;e===void 0&&(e={});const{x:s,y:a,platform:r,rects:i,elements:c,strategy:d}=t,{boundary:f="clippingAncestors",rootBoundary:h="viewport",elementContext:m="floating",altBoundary:b=!1,padding:y=0}=uh(e,t),w=ZN(y),N=c[b?m==="floating"?"reference":"floating":m],k=Lp(await r.getClippingRect({element:(n=await(r.isElement==null?void 0:r.isElement(N)))==null||n?N:N.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(c.floating)),boundary:f,rootBoundary:h,strategy:d})),j=m==="floating"?{x:s,y:a,width:i.floating.width,height:i.floating.height}:i.reference,S=await(r.getOffsetParent==null?void 0:r.getOffsetParent(c.floating)),T=await(r.isElement==null?void 0:r.isElement(S))?await(r.getScale==null?void 0:r.getScale(S))||{x:1,y:1}:{x:1,y:1},D=Lp(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:j,offsetParent:S,strategy:d}):j);return{top:(k.top-D.top+w.top)/T.y,bottom:(D.bottom-k.bottom+w.bottom)/T.y,left:(k.left-D.left+w.left)/T.x,right:(D.right-k.right+w.right)/T.x}}const P$=50,B$=async(t,e,n)=>{const{placement:s="bottom",strategy:a="absolute",middleware:r=[],platform:i}=n,c=i.detectOverflow?i:{...i,detectOverflow:I$},d=await(i.isRTL==null?void 0:i.isRTL(e));let f=await i.getElementRects({reference:t,floating:e,strategy:a}),{x:h,y:m}=ZC(f,s,d),b=s,y=0;const w={};for(let C=0;C<r.length;C++){const N=r[C];if(!N)continue;const{name:k,fn:j}=N,{x:S,y:T,data:D,reset:E}=await j({x:h,y:m,initialPlacement:s,placement:b,strategy:a,middlewareData:w,rects:f,platform:c,elements:{reference:t,floating:e}});h=S??h,m=T??m,w[k]={...w[k],...D},E&&y<P$&&(y++,typeof E=="object"&&(E.placement&&(b=E.placement),E.rects&&(f=E.rects===!0?await i.getElementRects({reference:t,floating:e,strategy:a}):E.rects),{x:h,y:m}=ZC(f,b,d)),C=-1)}return{x:h,y:m,placement:b,strategy:a,middlewareData:w}},F$=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:s,placement:a,rects:r,platform:i,elements:c,middlewareData:d}=e,{element:f,padding:h=0}=uh(t,e)||{};if(f==null)return{};const m=ZN(h),b={x:n,y:s},y=wy(a),w=vy(y),C=await i.getDimensions(f),N=y==="y",k=N?"top":"left",j=N?"bottom":"right",S=N?"clientHeight":"clientWidth",T=r.reference[w]+r.reference[y]-b[y]-r.floating[w],D=b[y]-r.reference[y],E=await(i.getOffsetParent==null?void 0:i.getOffsetParent(f));let I=E?E[S]:0;(!I||!await(i.isElement==null?void 0:i.isElement(E)))&&(I=c.floating[S]||r.floating[w]);const O=T/2-D/2,_=I/2-C[w]/2-1,M=ec(m[k],_),R=ec(m[j],_),z=M,$=I-C[w]-R,W=I/2-C[w]/2+O,L=w$(z,W,$),F=!d.arrow&&rd(a)!=null&&W!==L&&r.reference[w]/2-(W<z?M:R)-C[w]/2<0,H=F?W<z?W-z:W-$:0;return{[y]:b[y]+H,data:{[y]:L,centerOffset:W-L-H,...F&&{alignmentOffset:H}},reset:F}}}),z$=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,s;const{placement:a,middlewareData:r,rects:i,initialPlacement:c,platform:d,elements:f}=e,{mainAxis:h=!0,crossAxis:m=!0,fallbackPlacements:b,fallbackStrategy:y="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:C=!0,...N}=uh(t,e);if((n=r.arrow)!=null&&n.alignmentOffset)return{};const k=tc(a),j=ko(c),S=tc(c)===c,T=await(d.isRTL==null?void 0:d.isRTL(f.floating)),D=b||(S||!C?[Op(c)]:C$(c)),E=w!=="none";!b&&E&&D.push(...T$(c,C,w,T));const I=[c,...D],O=await d.detectOverflow(e,N),_=[];let M=((s=r.flip)==null?void 0:s.overflows)||[];if(h&&_.push(O[k]),m){const W=S$(a,i,T);_.push(O[W[0]],O[W[1]])}if(M=[...M,{placement:a,overflows:_}],!_.every(W=>W<=0)){var R,z;const W=(((R=r.flip)==null?void 0:R.index)||0)+1,L=I[W];if(L&&(!(m==="alignment"?j!==ko(L):!1)||M.every(V=>ko(V.placement)===j?V.overflows[0]>0:!0)))return{data:{index:W,overflows:M},reset:{placement:L}};let F=(z=M.filter(H=>H.overflows[0]<=0).sort((H,V)=>H.overflows[1]-V.overflows[1])[0])==null?void 0:z.placement;if(!F)switch(y){case"bestFit":{var $;const H=($=M.filter(V=>{if(E){const G=ko(V.placement);return G===j||G==="y"}return!0}).map(V=>[V.placement,V.overflows.filter(G=>G>0).reduce((G,B)=>G+B,0)]).sort((V,G)=>V[1]-G[1])[0])==null?void 0:$[0];H&&(F=H);break}case"initialPlacement":F=c;break}if(a!==F)return{reset:{placement:F}}}return{}}}},$$=new Set(["left","top"]);async function U$(t,e){const{placement:n,platform:s,elements:a}=t,r=await(s.isRTL==null?void 0:s.isRTL(a.floating)),i=tc(n),c=rd(n),d=ko(n)==="y",f=$$.has(i)?-1:1,h=r&&d?-1:1,m=uh(e,t);let{mainAxis:b,crossAxis:y,alignmentAxis:w}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return c&&typeof w=="number"&&(y=c==="end"?w*-1:w),d?{x:y*h,y:b*f}:{x:b*f,y:y*h}}const H$=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,s;const{x:a,y:r,placement:i,middlewareData:c}=e,d=await U$(e,t);return i===((n=c.offset)==null?void 0:n.placement)&&(s=c.arrow)!=null&&s.alignmentOffset?{}:{x:a+d.x,y:r+d.y,data:{...d,placement:i}}}}};function eT(t){const e=_a(t);let n=parseFloat(e.width)||0,s=parseFloat(e.height)||0;const a=Kr(t),r=a?t.offsetWidth:n,i=a?t.offsetHeight:s,c=Rp(n)!==r||Rp(s)!==i;return c&&(n=r,s=i),{width:n,height:s,$:c}}function ky(t){return Ds(t)?t:t.contextElement}function Wl(t){const e=ky(t);if(!Kr(e))return or(1);const n=e.getBoundingClientRect(),{width:s,height:a,$:r}=eT(e);let i=(r?Rp(n.width):n.width)/s,c=(r?Rp(n.height):n.height)/a;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const W$=or(0);function tT(t){const e=fa(t);return!yy()||!e.visualViewport?W$:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function q$(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==fa(t)?!1:e}function Oo(t,e,n,s){e===void 0&&(e=!1),n===void 0&&(n=!1);const a=t.getBoundingClientRect(),r=ky(t);let i=or(1);e&&(s?Ds(s)&&(i=Wl(s)):i=Wl(t));const c=q$(r,n,s)?tT(r):or(0);let d=(a.left+c.x)/i.x,f=(a.top+c.y)/i.y,h=a.width/i.x,m=a.height/i.y;if(r){const b=fa(r),y=s&&Ds(s)?fa(s):s;let w=b,C=vx(w);for(;C&&s&&y!==w;){const N=Wl(C),k=C.getBoundingClientRect(),j=_a(C),S=k.left+(C.clientLeft+parseFloat(j.paddingLeft))*N.x,T=k.top+(C.clientTop+parseFloat(j.paddingTop))*N.y;d*=N.x,f*=N.y,h*=N.x,m*=N.y,d+=S,f+=T,w=fa(C),C=vx(w)}}return Lp({width:h,height:m,x:d,y:f})}function dh(t,e){const n=ch(t).scrollLeft;return e?e.left+n:Oo(mr(t)).left+n}function nT(t,e){const n=t.getBoundingClientRect(),s=n.left+e.scrollLeft-dh(t,n),a=n.top+e.scrollTop;return{x:s,y:a}}function V$(t){let{elements:e,rect:n,offsetParent:s,strategy:a}=t;const r=a==="fixed",i=mr(s),c=e?lh(e.floating):!1;if(s===i||c&&r)return n;let d={scrollLeft:0,scrollTop:0},f=or(1);const h=or(0),m=Kr(s);if((m||!m&&!r)&&((oc(s)!=="body"||ad(i))&&(d=ch(s)),m)){const y=Oo(s);f=Wl(s),h.x=y.x+s.clientLeft,h.y=y.y+s.clientTop}const b=i&&!m&&!r?nT(i,d):or(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-d.scrollLeft*f.x+h.x+b.x,y:n.y*f.y-d.scrollTop*f.y+h.y+b.y}}function Y$(t){return Array.from(t.getClientRects())}function G$(t){const e=mr(t),n=ch(t),s=t.ownerDocument.body,a=jo(e.scrollWidth,e.clientWidth,s.scrollWidth,s.clientWidth),r=jo(e.scrollHeight,e.clientHeight,s.scrollHeight,s.clientHeight);let i=-n.scrollLeft+dh(t);const c=-n.scrollTop;return _a(s).direction==="rtl"&&(i+=jo(e.clientWidth,s.clientWidth)-a),{width:a,height:r,x:i,y:c}}const eA=25;function K$(t,e){const n=fa(t),s=mr(t),a=n.visualViewport;let r=s.clientWidth,i=s.clientHeight,c=0,d=0;if(a){r=a.width,i=a.height;const h=yy();(!h||h&&e==="fixed")&&(c=a.offsetLeft,d=a.offsetTop)}const f=dh(s);if(f<=0){const h=s.ownerDocument,m=h.body,b=getComputedStyle(m),y=h.compatMode==="CSS1Compat"&&parseFloat(b.marginLeft)+parseFloat(b.marginRight)||0,w=Math.abs(s.clientWidth-m.clientWidth-y);w<=eA&&(r-=w)}else f<=eA&&(r+=f);return{width:r,height:i,x:c,y:d}}function Q$(t,e){const n=Oo(t,!0,e==="fixed"),s=n.top+t.clientTop,a=n.left+t.clientLeft,r=Kr(t)?Wl(t):or(1),i=t.clientWidth*r.x,c=t.clientHeight*r.y,d=a*r.x,f=s*r.y;return{width:i,height:c,x:d,y:f}}function tA(t,e,n){let s;if(e==="viewport")s=K$(t,n);else if(e==="document")s=G$(mr(t));else if(Ds(e))s=Q$(e,n);else{const a=tT(t);s={x:e.x-a.x,y:e.y-a.y,width:e.width,height:e.height}}return Lp(s)}function sT(t,e){const n=Oi(t);return n===e||!Ds(n)||Zl(n)?!1:_a(n).position==="fixed"||sT(n,e)}function X$(t,e){const n=e.get(t);if(n)return n;let s=Qu(t,[],!1).filter(c=>Ds(c)&&oc(c)!=="body"),a=null;const r=_a(t).position==="fixed";let i=r?Oi(t):t;for(;Ds(i)&&!Zl(i);){const c=_a(i),d=xy(i);!d&&c.position==="fixed"&&(a=null),(r?!d&&!a:!d&&c.position==="static"&&!!a&&(a.position==="absolute"||a.position==="fixed")||ad(i)&&!d&&sT(t,i))?s=s.filter(h=>h!==i):a=c,i=Oi(i)}return e.set(t,s),s}function J$(t){let{element:e,boundary:n,rootBoundary:s,strategy:a}=t;const i=[...n==="clippingAncestors"?lh(e)?[]:X$(e,this._c):[].concat(n),s],c=tA(e,i[0],a);let d=c.top,f=c.right,h=c.bottom,m=c.left;for(let b=1;b<i.length;b++){const y=tA(e,i[b],a);d=jo(y.top,d),f=ec(y.right,f),h=ec(y.bottom,h),m=jo(y.left,m)}return{width:f-m,height:h-d,x:m,y:d}}function Z$(t){const{width:e,height:n}=eT(t);return{width:e,height:n}}function eU(t,e,n){const s=Kr(e),a=mr(e),r=n==="fixed",i=Oo(t,!0,r,e);let c={scrollLeft:0,scrollTop:0};const d=or(0);function f(){d.x=dh(a)}if(s||!s&&!r)if((oc(e)!=="body"||ad(a))&&(c=ch(e)),s){const y=Oo(e,!0,r,e);d.x=y.x+e.clientLeft,d.y=y.y+e.clientTop}else a&&f();r&&!s&&a&&f();const h=a&&!s&&!r?nT(a,c):or(0),m=i.left+c.scrollLeft-d.x-h.x,b=i.top+c.scrollTop-d.y-h.y;return{x:m,y:b,width:i.width,height:i.height}}function bb(t){return _a(t).position==="static"}function nA(t,e){if(!Kr(t)||_a(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return mr(t)===n&&(n=n.ownerDocument.body),n}function aT(t,e){const n=fa(t);if(lh(t))return n;if(!Kr(t)){let a=Oi(t);for(;a&&!Zl(a);){if(Ds(a)&&!bb(a))return a;a=Oi(a)}return n}let s=nA(t,e);for(;s&&g$(s)&&bb(s);)s=nA(s,e);return s&&Zl(s)&&bb(s)&&!xy(s)?n:s||y$(t)||n}const tU=async function(t){const e=this.getOffsetParent||aT,n=this.getDimensions,s=await n(t.floating);return{reference:eU(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function nU(t){return _a(t).direction==="rtl"}const sU={convertOffsetParentRelativeRectToViewportRelativeRect:V$,getDocumentElement:mr,getClippingRect:J$,getOffsetParent:aT,getElementRects:tU,getClientRects:Y$,getDimensions:Z$,getScale:Wl,isElement:Ds,isRTL:nU};function rT(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function aU(t,e){let n=null,s;const a=mr(t);function r(){var c;clearTimeout(s),(c=n)==null||c.disconnect(),n=null}function i(c,d){c===void 0&&(c=!1),d===void 0&&(d=1),r();const f=t.getBoundingClientRect(),{left:h,top:m,width:b,height:y}=f;if(c||e(),!b||!y)return;const w=zf(m),C=zf(a.clientWidth-(h+b)),N=zf(a.clientHeight-(m+y)),k=zf(h),S={rootMargin:-w+"px "+-C+"px "+-N+"px "+-k+"px",threshold:jo(0,ec(1,d))||1};let T=!0;function D(E){const I=E[0].intersectionRatio;if(I!==d){if(!T)return i();I?i(!1,I):s=setTimeout(()=>{i(!1,1e-7)},1e3)}I===1&&!rT(f,t.getBoundingClientRect())&&i(),T=!1}try{n=new IntersectionObserver(D,{...S,root:a.ownerDocument})}catch{n=new IntersectionObserver(D,S)}n.observe(t)}return i(!0),r}function rU(t,e,n,s){s===void 0&&(s={});const{ancestorScroll:a=!0,ancestorResize:r=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:d=!1}=s,f=ky(t),h=a||r?[...f?Qu(f):[],...e?Qu(e):[]]:[];h.forEach(k=>{a&&k.addEventListener("scroll",n,{passive:!0}),r&&k.addEventListener("resize",n)});const m=f&&c?aU(f,n):null;let b=-1,y=null;i&&(y=new ResizeObserver(k=>{let[j]=k;j&&j.target===f&&y&&e&&(y.unobserve(e),cancelAnimationFrame(b),b=requestAnimationFrame(()=>{var S;(S=y)==null||S.observe(e)})),n()}),f&&!d&&y.observe(f),e&&y.observe(e));let w,C=d?Oo(t):null;d&&N();function N(){const k=Oo(t);C&&!rT(C,k)&&n(),C=k,w=requestAnimationFrame(N)}return n(),()=>{var k;h.forEach(j=>{a&&j.removeEventListener("scroll",n),r&&j.removeEventListener("resize",n)}),m==null||m(),(k=y)==null||k.disconnect(),y=null,d&&cancelAnimationFrame(w)}}const iU=H$,oU=z$,sA=F$,lU=(t,e,n)=>{const s=new Map,a={platform:sU,...n},r={...a.platform,_c:s};return B$(t,e,{...a,platform:r})};var cU=typeof document<"u",uU=function(){},ip=cU?x.useLayoutEffect:uU;function Pp(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,s,a;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(s=n;s--!==0;)if(!Pp(t[s],e[s]))return!1;return!0}if(a=Object.keys(t),n=a.length,n!==Object.keys(e).length)return!1;for(s=n;s--!==0;)if(!{}.hasOwnProperty.call(e,a[s]))return!1;for(s=n;s--!==0;){const r=a[s];if(!(r==="_owner"&&t.$$typeof)&&!Pp(t[r],e[r]))return!1}return!0}return t!==t&&e!==e}function iT(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function aA(t,e){const n=iT(t);return Math.round(e*n)/n}function xb(t){const e=x.useRef(t);return ip(()=>{e.current=t}),e}function dU(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:s=[],platform:a,elements:{reference:r,floating:i}={},transform:c=!0,whileElementsMounted:d,open:f}=t,[h,m]=x.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[b,y]=x.useState(s);Pp(b,s)||y(s);const[w,C]=x.useState(null),[N,k]=x.useState(null),j=x.useCallback(V=>{V!==E.current&&(E.current=V,C(V))},[]),S=x.useCallback(V=>{V!==I.current&&(I.current=V,k(V))},[]),T=r||w,D=i||N,E=x.useRef(null),I=x.useRef(null),O=x.useRef(h),_=d!=null,M=xb(d),R=xb(a),z=xb(f),$=x.useCallback(()=>{if(!E.current||!I.current)return;const V={placement:e,strategy:n,middleware:b};R.current&&(V.platform=R.current),lU(E.current,I.current,V).then(G=>{const B={...G,isPositioned:z.current!==!1};W.current&&!Pp(O.current,B)&&(O.current=B,ac.flushSync(()=>{m(B)}))})},[b,e,n,R,z]);ip(()=>{f===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,m(V=>({...V,isPositioned:!1})))},[f]);const W=x.useRef(!1);ip(()=>(W.current=!0,()=>{W.current=!1}),[]),ip(()=>{if(T&&(E.current=T),D&&(I.current=D),T&&D){if(M.current)return M.current(T,D,$);$()}},[T,D,$,M,_]);const L=x.useMemo(()=>({reference:E,floating:I,setReference:j,setFloating:S}),[j,S]),F=x.useMemo(()=>({reference:T,floating:D}),[T,D]),H=x.useMemo(()=>{const V={position:n,left:0,top:0};if(!F.floating)return V;const G=aA(F.floating,h.x),B=aA(F.floating,h.y);return c?{...V,transform:"translate("+G+"px, "+B+"px)",...iT(F.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:G,top:B}},[n,c,F.floating,h.x,h.y]);return x.useMemo(()=>({...h,update:$,refs:L,elements:F,floatingStyles:H}),[h,$,L,F,H])}const fU=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:s,padding:a}=typeof t=="function"?t(n):t;return s&&e(s)?s.current!=null?sA({element:s.current,padding:a}).fn(n):{}:s?sA({element:s,padding:a}).fn(n):{}}}},pU=(t,e)=>{const n=iU(t);return{name:n.name,fn:n.fn,options:[t,e]}},hU=(t,e)=>{const n=oU(t);return{name:n.name,fn:n.fn,options:[t,e]}},mU=(t,e)=>{const n=fU(t);return{name:n.name,fn:n.fn,options:[t,e]}},gU={...pj};let rA=!1,bU=0;const iA=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+bU++;function xU(){const[t,e]=x.useState(()=>rA?iA():void 0);return Ip(()=>{t==null&&e(iA())},[]),x.useEffect(()=>{rA=!0},[]),t}const yU=gU.useId,oT=yU||xU,vU=x.forwardRef(function(e,n){const{context:{placement:s,elements:{floating:a},middlewareData:{arrow:r,shift:i}},width:c=14,height:d=7,tipRadius:f=0,strokeWidth:h=0,staticOffset:m,stroke:b,d:y,style:{transform:w,...C}={},...N}=e,k=oT(),[j,S]=x.useState(!1);if(Ip(()=>{if(!a)return;_a(a).direction==="rtl"&&S(!0)},[a]),!a)return null;const[T,D]=s.split("-"),E=T==="top"||T==="bottom";let I=m;(E&&i!=null&&i.x||!E&&i!=null&&i.y)&&(I=null);const O=h*2,_=O/2,M=c/2*(f/-8+1),R=d/2*f/4,z=!!y,$=I&&D==="end"?"bottom":"top";let W=I&&D==="end"?"right":"left";I&&j&&(W=D==="end"?"left":"right");const L=(r==null?void 0:r.x)!=null?I||r.x:"",F=(r==null?void 0:r.y)!=null?I||r.y:"",H=y||"M0,0"+(" H"+c)+(" L"+(c-M)+","+(d-R))+(" Q"+c/2+","+d+" "+M+","+(d-R))+" Z",V={top:z?"rotate(180deg)":"",left:z?"rotate(90deg)":"rotate(-90deg)",bottom:z?"":"rotate(180deg)",right:z?"rotate(-90deg)":"rotate(90deg)"}[T];return o.jsxs("svg",{...N,"aria-hidden":!0,ref:n,width:z?c:c+O,height:c,viewBox:"0 0 "+c+" "+(d>c?d:c),style:{position:"absolute",pointerEvents:"none",[W]:L,[$]:F,[T]:E||z?"100%":"calc(100% - "+O/2+"px)",transform:[V,w].filter(G=>!!G).join(" "),...C},children:[O>0&&o.jsx("path",{clipPath:"url(#"+k+")",fill:"none",stroke:b,strokeWidth:O+(y?0:1),d:H}),o.jsx("path",{stroke:O&&!y?N.fill:"none",d:H}),o.jsx("clipPath",{id:k,children:o.jsx("rect",{x:-_,y:_*(z?-1:1),width:c+O,height:c})})]})});function wU(){const t=new Map;return{emit(e,n){var s;(s=t.get(e))==null||s.forEach(a=>a(n))},on(e,n){t.has(e)||t.set(e,new Set),t.get(e).add(n)},off(e,n){var s;(s=t.get(e))==null||s.delete(n)}}}const kU=x.createContext(null),SU=x.createContext(null),CU=()=>{var t;return((t=x.useContext(kU))==null?void 0:t.id)||null},AU=()=>x.useContext(SU);function jU(t){const{open:e=!1,onOpenChange:n,elements:s}=t,a=oT(),r=x.useRef({}),[i]=x.useState(()=>wU()),c=CU()!=null,[d,f]=x.useState(s.reference),h=L$((y,w,C)=>{r.current.openEvent=y?w:void 0,i.emit("openchange",{open:y,event:w,reason:C,nested:c}),n==null||n(y,w,C)}),m=x.useMemo(()=>({setPositionReference:f}),[]),b=x.useMemo(()=>({reference:d||s.reference||null,floating:s.floating||null,domReference:s.reference}),[d,s.reference,s.floating]);return x.useMemo(()=>({dataRef:r,open:e,onOpenChange:h,elements:b,events:i,floatingId:a,refs:m}),[e,h,b,i,a,m])}function NU(t){t===void 0&&(t={});const{nodeId:e}=t,n=jU({...t,elements:{reference:null,floating:null,...t.elements}}),s=t.rootContext||n,a=s.elements,[r,i]=x.useState(null),[c,d]=x.useState(null),h=(a==null?void 0:a.domReference)||r,m=x.useRef(null),b=AU();Ip(()=>{h&&(m.current=h)},[h]);const y=dU({...t,elements:{...a,...c&&{reference:c}}}),w=x.useCallback(S=>{const T=Ds(S)?{getBoundingClientRect:()=>S.getBoundingClientRect(),getClientRects:()=>S.getClientRects(),contextElement:S}:S;d(T),y.refs.setReference(T)},[y.refs]),C=x.useCallback(S=>{(Ds(S)||S===null)&&(m.current=S,i(S)),(Ds(y.refs.reference.current)||y.refs.reference.current===null||S!==null&&!Ds(S))&&y.refs.setReference(S)},[y.refs]),N=x.useMemo(()=>({...y.refs,setReference:C,setPositionReference:w,domReference:m}),[y.refs,C,w]),k=x.useMemo(()=>({...y.elements,domReference:h}),[y.elements,h]),j=x.useMemo(()=>({...y,...s,refs:N,elements:k,nodeId:e}),[y,N,k,e,s]);return Ip(()=>{s.dataRef.current.floatingContext=j;const S=b==null?void 0:b.nodesRef.current.find(T=>T.id===e);S&&(S.context=j)}),x.useMemo(()=>({...y,context:j,refs:N,elements:k}),[y,N,k,j])}/*!
106
- react-datepicker v9.1.0
107
- https://github.com/Hacker0x01/react-datepicker
108
- Released under the MIT License.
109
- */var kx=function(e,n){return kx=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(s,a){s.__proto__=a}||function(s,a){for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(s[r]=a[r])},kx(e,n)};function ws(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");kx(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}var qt=function(){return qt=Object.assign||function(n){for(var s,a=1,r=arguments.length;a<r;a++){s=arguments[a];for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(n[i]=s[i])}return n},qt.apply(this,arguments)};function rr(t,e,n){if(n||arguments.length===2)for(var s=0,a=e.length,r;s<a;s++)(r||!(s in e))&&(r||(r=Array.prototype.slice.call(e,0,s)),r[s]=e[s]);return t.concat(r||Array.prototype.slice.call(e))}var TU=function(t){var e=t.showTimeSelectOnly,n=e===void 0?!1:e,s=t.showTime,a=s===void 0?!1:s,r=t.className,i=t.children,c=t.inline,d=n?"Choose Time":"Choose Date".concat(a?" and Time":"");return Se.createElement("div",{className:r,"aria-label":d,role:c?void 0:"dialog","aria-modal":c?void 0:"true",translate:"no"},i)},_U=function(t,e){var n=x.useRef(null),s=x.useRef(t);x.useEffect(function(){s.current=t},[t]);var a=x.useCallback(function(r){var i,c=r.composed&&r.composedPath&&r.composedPath().find(function(d){return d instanceof Node})||r.target;n.current&&!n.current.contains(c)&&(e&&c instanceof HTMLElement&&c.classList.contains(e)||(i=s.current)===null||i===void 0||i.call(s,r))},[e]);return x.useEffect(function(){return document.addEventListener("mousedown",a),function(){document.removeEventListener("mousedown",a)}},[a]),n},fh=function(t){var e=t.children,n=t.onClickOutside,s=t.className,a=t.containerRef,r=t.style,i=t.ignoreClass,c=_U(n,i);return Se.createElement("div",{className:s,style:r,ref:function(d){c.current=d,a&&(a.current=d)}},e)},$f=null,oA=!1;function lT(){if(oA)return $f;oA=!0;try{var t="date-fns-tz";$f=require(t)}catch{$f=null}return $f}function lA(t,e){if(!e)return t;var n=lT();return n?n.toZonedTime(t,e):t}function Or(t,e){if(!e)return t;var n=lT();return n?n.fromZonedTime(t,e):t}var lt;(function(t){t.ArrowUp="ArrowUp",t.ArrowDown="ArrowDown",t.ArrowLeft="ArrowLeft",t.ArrowRight="ArrowRight",t.PageUp="PageUp",t.PageDown="PageDown",t.Home="Home",t.End="End",t.Enter="Enter",t.Space=" ",t.Tab="Tab",t.Escape="Escape",t.Backspace="Backspace",t.X="x"})(lt||(lt={}));function cT(){var t=typeof window<"u"?window:globalThis;return t}var id=12;function dn(t){if(t==null)return new Date;var e=typeof t=="string"?e$(t):St(t);return Gs(e)?e:new Date}function bo(t,e,n,s,a){a===void 0&&(a=dn());for(var r=nc(n)||nc(Sy()),i=Array.isArray(e)?e:[e],c=0,d=i;c<d.length;c++){var f=d[c],h=G3(t,f,a,{locale:r});if(Gs(h)&&(!s||t===Bn(h,f,n)))return h}if(!s&&t&&t.length>=8){var m=new Date(t);if(Jl(m))return m}return null}function EU(t,e){if(e===void 0&&(e=dn()),!t)return null;var n=t.match(/\b(1\d{3}|2\d{3})\b/);if(!n||!n[1])return null;var s=parseInt(n[1],10),a=t.match(/(?:^|[/\-\s])?(0?[1-9]|1[0-2])(?:[/\-\s]|$)/),r=a&&a[1]?parseInt(a[1],10)-1:e.getMonth();return new Date(s,r,1)}function Gs(t){return Jl(t)}function So(t){return t==null?null:ir(t)&&Jl(t)?t:null}function Bn(t,e,n){if(n==="en")return YC(t,e,{useAdditionalWeekYearTokens:!0,useAdditionalDayOfYearTokens:!0});var s=n?nc(n):void 0;return n&&!s&&console.warn('A locale object was not found for the provided string ["'.concat(n,'"].')),s=s||nc(Sy()),YC(t,e,{locale:s,useAdditionalWeekYearTokens:!0,useAdditionalDayOfYearTokens:!0})}function Ys(t,e){var n=e.dateFormat,s=e.locale,a=Array.isArray(n)&&n.length>0?n[0]:n;return t&&Bn(t,a,s)||""}var uT=" - ";function MU(t,e,n){if(!t&&!e)return"";var s=t?Ys(t,n):"",a=e?Ys(e,n):"",r=n.rangeSeparator||uT;return"".concat(s).concat(r).concat(a)}function DU(t,e){if(!(t!=null&&t.length))return"";var n=t[0]?Ys(t[0],e):"";if(t.length===1)return n;if(t.length===2&&t[1]){var s=Ys(t[1],e);return"".concat(n,", ").concat(s)}var a=t.length-1;return"".concat(n," (+").concat(a,")")}function Lr(t,e){var n=e.hour,s=n===void 0?0:n,a=e.minute,r=a===void 0?0:a,i=e.second,c=i===void 0?0:i;return sp(ap(rp(t,c),r),s)}function RU(t){return hy(t)}function OU(t,e){return Bn(t,"ddd",e)}function wu(t){return Ro(t)}function Mi(t,e,n){var s=nc(e||Sy());return qr(t,{locale:s,weekStartsOn:n})}function Ur(t){return zN(t)}function ku(t){return ih(t)}function cA(t){return bx(t)}function uA(){return Ro(dn())}function dA(t){return BN(t)}function LU(t){return ez(t)}function IU(t){return FN(t)}function Za(t,e){return t&&e?J3(t,e):!t&&!e}function Es(t,e){return t&&e?Q3(t,e):!t&&!e}function Bp(t,e){return t&&e?X3(t,e):!t&&!e}function on(t,e){return t&&e?J4(t,e):!t&&!e}function Co(t,e){return t&&e?Zz(t,e):!t&&!e}function vo(t,e,n){var s,a=Ro(e),r=BN(n);try{s=Ku(t,{start:a,end:r})}catch{s=!1}return s}function Sy(){var t=cT();return t.__localeId__}function nc(t){if(typeof t=="string"){var e=cT();return e.__localeData__?e.__localeData__[t]:void 0}else return t}function PU(t,e,n){return e(Bn(t,"EEEE",n))}function BU(t,e){return Bn(t,"EEEEEE",e)}function FU(t,e){return Bn(t,"EEE",e)}function Cy(t,e){return Bn(oa(dn(),t),"LLLL",e)}function dT(t,e){return Bn(oa(dn(),t),"LLL",e)}function zU(t,e){return Bn(Bl(dn(),t),"QQQ",e)}function ja(t,e){var n=e===void 0?{}:e,s=n.minDate,a=n.maxDate,r=n.excludeDates,i=n.excludeDateIntervals,c=n.includeDates,d=n.includeDateIntervals,f=n.filterDate,h=n.disabled;return h?!0:od(t,{minDate:s,maxDate:a})||r&&r.some(function(m){return m instanceof Date?on(t,m):on(t,m.date)})||i&&i.some(function(m){var b=m.start,y=m.end;return Ku(t,{start:b,end:y})})||c&&!c.some(function(m){return on(t,m)})||d&&!d.some(function(m){var b=m.start,y=m.end;return Ku(t,{start:b,end:y})})||f&&!f(dn(t))||!1}function Ay(t,e){var n=e===void 0?{}:e,s=n.excludeDates,a=n.excludeDateIntervals;return a&&a.length>0?a.some(function(r){var i=r.start,c=r.end;return Ku(t,{start:i,end:c})}):s&&s.some(function(r){var i;return r instanceof Date?on(t,r):on(t,(i=r.date)!==null&&i!==void 0?i:new Date)})||!1}function fT(t,e){var n=e===void 0?{}:e,s=n.minDate,a=n.maxDate,r=n.excludeDates,i=n.includeDates,c=n.filterDate;return od(t,{minDate:s?zN(s):void 0,maxDate:a?FN(a):void 0})||(r==null?void 0:r.some(function(d){return Es(t,d instanceof Date?d:d.date)}))||i&&!i.some(function(d){return Es(t,d)})||c&&!c(dn(t))||!1}function Uf(t,e,n,s){var a=Zt(t),r=Ks(t),i=Zt(e),c=Ks(e),d=Zt(s);return a===i&&a===d?r<=n&&n<=c:a<i?d===a&&r<=n||d===i&&c>=n||d<i&&d>a:!1}function $U(t,e){var n=e===void 0?{}:e,s=n.minDate,a=n.maxDate,r=n.excludeDates,i=n.includeDates;return od(t,{minDate:s,maxDate:a})||r&&r.some(function(c){return Es(c instanceof Date?c:c.date,t)})||i&&!i.some(function(c){return Es(c,t)})||!1}function Hf(t,e){var n=e===void 0?{}:e,s=n.minDate,a=n.maxDate,r=n.excludeDates,i=n.includeDates,c=n.filterDate,d=n.disabled;return d?!0:od(t,{minDate:s,maxDate:a})||(r==null?void 0:r.some(function(f){return Bp(t,f instanceof Date?f:f.date)}))||i&&!i.some(function(f){return Bp(t,f)})||c&&!c(dn(t))||!1}function Wf(t,e,n){if(!e||!n||!Jl(e)||!Jl(n))return!1;var s=Zt(e),a=Zt(n);return s<=t&&a>=t}function op(t,e){var n=e===void 0?{}:e,s=n.minDate,a=n.maxDate,r=n.excludeDates,i=n.includeDates,c=n.filterDate,d=n.disabled;if(d)return!0;var f=new Date(t,0,1);return od(f,{minDate:s?ih(s):void 0,maxDate:a?$N(a):void 0})||(r==null?void 0:r.some(function(h){return Za(f,h instanceof Date?h:h.date)}))||i&&!i.some(function(h){return Za(f,h)})||c&&!c(dn(f))||!1}function qf(t,e,n,s){var a=Zt(t),r=_i(t),i=Zt(e),c=_i(e),d=Zt(s);return a===i&&a===d?r<=n&&n<=c:a<i?d===a&&r<=n||d===i&&c>=n||d<i&&d>a:!1}function od(t,e){var n,s=e===void 0?{}:e,a=s.minDate,r=s.maxDate;return(n=a&&Xl(t,a)<0||r&&Xl(t,r)>0)!==null&&n!==void 0?n:!1}function fA(t,e){return e.some(function(n){return Cs(n)===Cs(t)&&As(n)===As(t)&&Ei(n)===Ei(t)})}function pA(t,e){var n=e===void 0?{}:e,s=n.excludeTimes,a=n.includeTimes,r=n.filterTime;return s&&fA(t,s)||a&&!fA(t,a)||r&&!r(t)||!1}function hA(t,e){var n=e.minTime,s=e.maxTime;if(!n||!s)throw new Error("Both minTime and maxTime props required");var a=dn();a=sp(a,Cs(t)),a=ap(a,As(t)),a=rp(a,Ei(t));var r=dn();r=sp(r,Cs(n)),r=ap(r,As(n)),r=rp(r,Ei(n));var i=dn();i=sp(i,Cs(s)),i=ap(i,As(s)),i=rp(i,Ei(s));var c;try{c=!Ku(a,{start:r,end:i})}catch{c=!1}return c}function mA(t,e){var n=e===void 0?{}:e,s=n.minDate,a=n.includeDates,r=Ao(t,1);return s&&_p(s,r)>0||a&&a.every(function(i){return _p(i,r)>0})||!1}function gA(t,e){var n=e===void 0?{}:e,s=n.maxDate,a=n.includeDates,r=za(t,1);return s&&_p(r,s)>0||a&&a.every(function(i){return _p(r,i)>0})||!1}function UU(t,e){var n=e===void 0?{}:e,s=n.minDate,a=n.includeDates,r=ih(t),i=QN(r);return s&&Ep(s,i)>0||a&&a.every(function(c){return Ep(c,i)>0})||!1}function HU(t,e){var n=e===void 0?{}:e,s=n.maxDate,a=n.includeDates,r=$N(t),i=py(r,1);return s&&Ep(i,s)>0||a&&a.every(function(c){return Ep(i,c)>0})||!1}function bA(t,e){var n=e===void 0?{}:e,s=n.minDate,a=n.includeDates,r=Ri(t,1);return s&&Mp(s,r)>0||a&&a.every(function(i){return Mp(i,r)>0})||!1}function WU(t,e){var n=e===void 0?{}:e,s=n.minDate,a=n.yearItemNumber,r=a===void 0?id:a,i=ku(Ri(t,r)),c=Pr(i,r).endPeriod,d=s&&Zt(s);return d&&d>c||!1}function xA(t,e){var n=e===void 0?{}:e,s=n.maxDate,a=n.includeDates,r=Ba(t,1);return s&&Mp(r,s)>0||a&&a.every(function(i){return Mp(r,i)>0})||!1}function qU(t,e){var n=e===void 0?{}:e,s=n.maxDate,a=n.yearItemNumber,r=a===void 0?id:a,i=Ba(t,r),c=Pr(i,r).startPeriod,d=s&&Zt(s);return d&&d<c||!1}function pT(t){var e=t.minDate,n=t.includeDates;if(n&&e){var s=n.filter(function(a){return Xl(a,e)>=0});return $C(s)}else return n?$C(n):e}function hT(t){var e=t.maxDate,n=t.includeDates;if(n&&e){var s=n.filter(function(a){return Xl(a,e)<=0});return zC(s)}else return n?zC(n):e}function yA(t,e){var n;t===void 0&&(t=[]),e===void 0&&(e="react-datepicker__day--highlighted");for(var s=new Map,a=0,r=t.length;a<r;a++){var i=t[a];if(ir(i)){var c=Bn(i,"MM.dd.yyyy"),d=s.get(c)||[];d.includes(e)||(d.push(e),s.set(c,d))}else if(typeof i=="object"){var f=Object.keys(i),h=(n=f[0])!==null&&n!==void 0?n:"",m=i[h];if(typeof h=="string"&&Array.isArray(m))for(var b=0,y=m.length;b<y;b++){var w=m[b];if(w){var c=Bn(w,"MM.dd.yyyy"),d=s.get(c)||[];d.includes(h)||(d.push(h),s.set(c,d))}}}}return s}function VU(t,e){return t.length!==e.length?!1:t.every(function(n,s){return n===e[s]})}function YU(t,e){t===void 0&&(t=[]),e===void 0&&(e="react-datepicker__day--holidays");var n=new Map;return t.forEach(function(s){var a=s.date,r=s.holidayName;if(ir(a)){var i=Bn(a,"MM.dd.yyyy"),c=n.get(i)||{className:"",holidayNames:[]};if(!("className"in c&&c.className===e&&VU(c.holidayNames,[r]))){c.className=e;var d=c.holidayNames;c.holidayNames=d?rr(rr([],d,!0),[r],!1):[r],n.set(i,c)}}}),n}function GU(t,e,n,s,a){for(var r=a.length,i=[],c=0;c<r;c++){var d=t,f=a[c];f&&(d=G4(d,Cs(f)),d=Gu(d,As(f)),d=X4(d,Ei(f)));var h=Gu(t,(n+1)*s);$r(d,e)&&ar(d,h)&&f!=null&&i.push(f)}return i}function Rl(t){return t<10?"0".concat(t):"".concat(t)}function Pr(t,e){e===void 0&&(e=id);var n=Math.ceil(Zt(t)/e)*e,s=n-(e-1);return{startPeriod:s,endPeriod:n}}function KU(t){var e=new Date(t.getFullYear(),t.getMonth(),t.getDate()),n=new Date(t.getFullYear(),t.getMonth(),t.getDate(),24);return Math.round((+n-+e)/36e5)}function vA(t){var e=t.getSeconds(),n=t.getMilliseconds();return St(t.getTime()-e*1e3-n)}function mT(t,e){return vA(t).getTime()===vA(e).getTime()}function wA(t){if(!ir(t))throw new Error("Invalid date");var e=new Date(t);return e.setHours(0,0,0,0),e}function yb(t,e){if(!ir(t)||!ir(e))throw new Error("Invalid date received");var n=wA(t),s=wA(e);return ar(n,s)}function gT(t){return t.key===lt.Space}var vb=(function(t){ws(e,t);function e(n){var s=t.call(this,n)||this;return s.inputRef=Se.createRef(),s.onTimeChange=function(a){var r,i;s.setState({time:a});var c=s.props.date,d=c instanceof Date&&!isNaN(+c),f=d?c:new Date;if(a!=null&&a.includes(":")){var h=a.split(":"),m=h[0],b=h[1];f.setHours(Number(m)),f.setMinutes(Number(b))}(i=(r=s.props).onChange)===null||i===void 0||i.call(r,f)},s.renderTimeInput=function(){var a=s.state.time,r=s.props,i=r.date,c=r.timeString,d=r.customTimeInput;return d?x.cloneElement(d,{date:i,value:a,onChange:s.onTimeChange}):Se.createElement("input",{type:"time",className:"react-datepicker-time__input",placeholder:"Time",name:"time-input",ref:s.inputRef,onClick:function(){var f;(f=s.inputRef.current)===null||f===void 0||f.focus()},required:!0,value:a,onChange:function(f){s.onTimeChange(f.target.value||c)}})},s.state={time:s.props.timeString},s}return e.getDerivedStateFromProps=function(n,s){return n.timeString!==s.time?{time:n.timeString}:null},e.prototype.render=function(){return Se.createElement("div",{className:"react-datepicker__input-time-container"},Se.createElement("div",{className:"react-datepicker-time__caption"},this.props.timeInputLabel),Se.createElement("div",{className:"react-datepicker-time__input-container"},Se.createElement("div",{className:"react-datepicker-time__input"},this.renderTimeInput())))},e})(x.Component),QU=(function(t){ws(e,t);function e(){var n=t!==null&&t.apply(this,arguments)||this;return n.dayEl=x.createRef(),n.handleClick=function(s){!n.isDisabled()&&n.props.onClick&&n.props.onClick(s)},n.handleMouseEnter=function(s){!n.isDisabled()&&n.props.onMouseEnter&&n.props.onMouseEnter(s)},n.handleOnKeyDown=function(s){var a,r,i=s.key;i===lt.Space&&(s.preventDefault(),s.key=lt.Enter),(r=(a=n.props).handleOnKeyDown)===null||r===void 0||r.call(a,s)},n.isSameDay=function(s){return on(n.props.day,s)},n.isKeyboardSelected=function(){var s;if(n.props.disabledKeyboardNavigation)return!1;var a=n.props.selectsMultiple?(s=n.props.selectedDates)===null||s===void 0?void 0:s.some(function(i){return n.isSameDayOrWeek(i)}):n.isSameDayOrWeek(n.props.selected),r=n.props.preSelection&&n.isDisabled(n.props.preSelection);return!a&&n.isSameDayOrWeek(n.props.preSelection)&&!r},n.isDisabled=function(s){return s===void 0&&(s=n.props.day),ja(s,{minDate:n.props.minDate,maxDate:n.props.maxDate,excludeDates:n.props.excludeDates,excludeDateIntervals:n.props.excludeDateIntervals,includeDateIntervals:n.props.includeDateIntervals,includeDates:n.props.includeDates,filterDate:n.props.filterDate,disabled:n.props.disabled})},n.isExcluded=function(){return Ay(n.props.day,{excludeDates:n.props.excludeDates,excludeDateIntervals:n.props.excludeDateIntervals})},n.isStartOfWeek=function(){return on(n.props.day,Mi(n.props.day,n.props.locale,n.props.calendarStartDay))},n.isSameWeek=function(s){return n.props.showWeekPicker&&on(s,Mi(n.props.day,n.props.locale,n.props.calendarStartDay))},n.isSameDayOrWeek=function(s){return n.isSameDay(s)||n.isSameWeek(s)},n.getHighLightedClass=function(){var s=n.props,a=s.day,r=s.highlightDates;if(!r)return!1;var i=Bn(a,"MM.dd.yyyy");return r.get(i)},n.getHolidaysClass=function(){var s,a=n.props,r=a.day,i=a.holidays;if(!i)return[void 0];var c=Bn(r,"MM.dd.yyyy");return i.has(c)?[(s=i.get(c))===null||s===void 0?void 0:s.className]:[void 0]},n.isInRange=function(){var s=n.props,a=s.day,r=s.startDate,i=s.endDate;return!r||!i?!1:vo(a,r,i)},n.isInSelectingRange=function(){var s,a=n.props,r=a.day,i=a.selectsStart,c=a.selectsEnd,d=a.selectsRange,f=a.selectsDisabledDaysInRange,h=a.startDate,m=a.swapRange,b=a.endDate,y=(s=n.props.selectingDate)!==null&&s!==void 0?s:n.props.preSelection;if(n.isAfterMonth()||n.isBeforeMonth()||!(i||c||d)||!y||!f&&n.isDisabled())return!1;if(i&&b&&(ar(y,b)||Co(y,b)))return vo(r,y,b);if(c&&h&&($r(y,h)||Co(y,h)))return vo(r,h,y);if(d&&h&&!b){if(Co(y,h)||$r(y,h))return vo(r,h,y);if(m&&ar(y,h))return vo(r,y,h)}return!1},n.isSelectingRangeStart=function(){var s;if(!n.isInSelectingRange())return!1;var a=n.props,r=a.day,i=a.startDate,c=a.selectsStart,d=a.swapRange,f=a.selectsRange,h=(s=n.props.selectingDate)!==null&&s!==void 0?s:n.props.preSelection;return c?on(r,h):f&&d&&i&&h?on(r,ar(h,i)?h:i):on(r,i)},n.isSelectingRangeEnd=function(){var s;if(!n.isInSelectingRange())return!1;var a=n.props,r=a.day,i=a.endDate,c=a.selectsEnd,d=a.selectsRange,f=a.swapRange,h=a.startDate,m=(s=n.props.selectingDate)!==null&&s!==void 0?s:n.props.preSelection;return c?on(r,m):d&&f&&h&&m?on(r,ar(m,h)?h:m):d?on(r,m):on(r,i)},n.isRangeStart=function(){var s=n.props,a=s.day,r=s.startDate,i=s.endDate;return!r||!i?!1:on(r,a)},n.isRangeEnd=function(){var s=n.props,a=s.day,r=s.startDate,i=s.endDate;return!r||!i?!1:on(i,a)},n.isWeekend=function(){var s=Kz(n.props.day);return s===0||s===6},n.isAfterMonth=function(){return n.props.month!==void 0&&(n.props.month+1)%12===Ks(n.props.day)},n.isBeforeMonth=function(){return n.props.month!==void 0&&(Ks(n.props.day)+1)%12===n.props.month},n.isCurrentDay=function(){return n.isSameDay(dn())},n.isSelected=function(){var s;return n.props.selectsMultiple?(s=n.props.selectedDates)===null||s===void 0?void 0:s.some(function(a){return n.isSameDayOrWeek(a)}):n.isSameDayOrWeek(n.props.selected)},n.getClassNames=function(s){var a=n.props.dayClassName?n.props.dayClassName(s):void 0;return us("react-datepicker__day",a,"react-datepicker__day--"+OU(n.props.day),{"react-datepicker__day--disabled":n.isDisabled(),"react-datepicker__day--excluded":n.isExcluded(),"react-datepicker__day--selected":n.isSelected(),"react-datepicker__day--keyboard-selected":n.isKeyboardSelected(),"react-datepicker__day--range-start":n.isRangeStart(),"react-datepicker__day--range-end":n.isRangeEnd(),"react-datepicker__day--in-range":n.isInRange(),"react-datepicker__day--in-selecting-range":n.isInSelectingRange(),"react-datepicker__day--selecting-range-start":n.isSelectingRangeStart(),"react-datepicker__day--selecting-range-end":n.isSelectingRangeEnd(),"react-datepicker__day--today":n.isCurrentDay(),"react-datepicker__day--weekend":n.isWeekend(),"react-datepicker__day--outside-month":n.isAfterMonth()||n.isBeforeMonth()},n.getHighLightedClass(),n.getHolidaysClass())},n.getAriaLabel=function(){var s=n.props,a=s.day,r=s.ariaLabelPrefixWhenEnabled,i=r===void 0?"Choose":r,c=s.ariaLabelPrefixWhenDisabled,d=c===void 0?"Not available":c,f=n.isDisabled()||n.isExcluded()?d:i;return"".concat(f," ").concat(Bn(a,"PPPP",n.props.locale))},n.getTitle=function(){var s=n.props,a=s.day,r=s.holidays,i=r===void 0?new Map:r,c=s.excludeDates,d=Bn(a,"MM.dd.yyyy"),f=[];return i.has(d)&&f.push.apply(f,i.get(d).holidayNames),n.isExcluded()&&f.push(c==null?void 0:c.filter(function(h){return h instanceof Date?on(h,a):on(h==null?void 0:h.date,a)}).map(function(h){if(!(h instanceof Date))return h==null?void 0:h.message})),f.join(", ")},n.getTabIndex=function(){var s=n.props.selected,a=n.props.preSelection,r=!(n.props.showWeekPicker&&(n.props.showWeekNumber||!n.isStartOfWeek()))&&(n.isKeyboardSelected()||n.isSameDay(s)&&on(a,s))?0:-1;return r},n.handleFocusDay=function(){var s;n.shouldFocusDay()&&((s=n.dayEl.current)===null||s===void 0||s.focus({preventScroll:!0}))},n.renderDayContents=function(){return n.props.monthShowsDuplicateDaysEnd&&n.isAfterMonth()||n.props.monthShowsDuplicateDaysStart&&n.isBeforeMonth()?null:n.props.renderDayContents?n.props.renderDayContents(GC(n.props.day),n.props.day):GC(n.props.day)},n.render=function(){return Se.createElement("div",{ref:n.dayEl,className:n.getClassNames(n.props.day),onKeyDown:n.handleOnKeyDown,onClick:n.handleClick,onMouseEnter:n.props.usePointerEvent?void 0:n.handleMouseEnter,onPointerEnter:n.props.usePointerEvent?n.handleMouseEnter:void 0,tabIndex:n.getTabIndex(),"aria-label":n.getAriaLabel(),role:"gridcell",title:n.getTitle(),"aria-disabled":n.isDisabled(),"aria-current":n.isCurrentDay()?"date":void 0,"aria-selected":n.isSelected()||n.isInRange()},n.renderDayContents(),n.getTitle()!==""&&Se.createElement("span",{className:"overlay"},n.getTitle()))},n}return e.prototype.componentDidMount=function(){this.handleFocusDay()},e.prototype.componentDidUpdate=function(){this.handleFocusDay()},e.prototype.shouldFocusDay=function(){var n=!1;return this.getTabIndex()===0&&this.isSameDay(this.props.preSelection)&&((!document.activeElement||document.activeElement===document.body)&&(n=!0),this.props.inline&&!this.props.shouldFocusDayInline&&(n=!1),this.isDayActiveElement()&&(n=!0),this.isDuplicateDay()&&(n=!1)),n},e.prototype.isDayActiveElement=function(){var n,s,a;return((s=(n=this.props.containerRef)===null||n===void 0?void 0:n.current)===null||s===void 0?void 0:s.contains(document.activeElement))&&((a=document.activeElement)===null||a===void 0?void 0:a.classList.contains("react-datepicker__day"))},e.prototype.isDuplicateDay=function(){return this.props.monthShowsDuplicateDaysEnd&&this.isAfterMonth()||this.props.monthShowsDuplicateDaysStart&&this.isBeforeMonth()},e})(x.Component),XU=(function(t){ws(e,t);function e(){var n=t!==null&&t.apply(this,arguments)||this;return n.weekNumberEl=x.createRef(),n.handleClick=function(s){n.props.onClick&&n.props.onClick(s)},n.handleOnKeyDown=function(s){var a,r,i=s.key;i===lt.Space&&(s.preventDefault(),s.key=lt.Enter),(r=(a=n.props).handleOnKeyDown)===null||r===void 0||r.call(a,s)},n.isKeyboardSelected=function(){return!n.props.disabledKeyboardNavigation&&!on(n.props.date,n.props.selected)&&on(n.props.date,n.props.preSelection)},n.getTabIndex=function(){return n.props.showWeekPicker&&n.props.showWeekNumber&&(n.isKeyboardSelected()||on(n.props.date,n.props.selected)&&on(n.props.preSelection,n.props.selected))?0:-1},n.handleFocusWeekNumber=function(s){var a=!1;n.getTabIndex()===0&&!(s!=null&&s.isInputFocused)&&on(n.props.date,n.props.preSelection)&&((!document.activeElement||document.activeElement===document.body)&&(a=!0),n.props.inline&&!n.props.shouldFocusDayInline&&(a=!1),n.props.containerRef&&n.props.containerRef.current&&n.props.containerRef.current.contains(document.activeElement)&&document.activeElement&&document.activeElement.classList.contains("react-datepicker__week-number")&&(a=!0)),a&&n.weekNumberEl.current&&n.weekNumberEl.current.focus({preventScroll:!0})},n}return Object.defineProperty(e,"defaultProps",{get:function(){return{ariaLabelPrefix:"week "}},enumerable:!1,configurable:!0}),e.prototype.componentDidMount=function(){this.handleFocusWeekNumber()},e.prototype.componentDidUpdate=function(n){this.handleFocusWeekNumber(n)},e.prototype.render=function(){var n=this.props,s=n.weekNumber,a=n.isWeekDisabled,r=n.ariaLabelPrefix,i=r===void 0?e.defaultProps.ariaLabelPrefix:r,c=n.onClick,d={"react-datepicker__week-number":!0,"react-datepicker__week-number--clickable":!!c&&!a,"react-datepicker__week-number--selected":!!c&&on(this.props.date,this.props.selected)};return Se.createElement("div",{ref:this.weekNumberEl,className:us(d),"aria-label":"".concat(i," ").concat(this.props.weekNumber),onClick:this.handleClick,onKeyDown:this.handleOnKeyDown,tabIndex:this.getTabIndex(),role:"gridcell"},s)},e})(x.Component),JU=(function(t){ws(e,t);function e(){var n=t!==null&&t.apply(this,arguments)||this;return n.isDisabled=function(s){return ja(s,{minDate:n.props.minDate,maxDate:n.props.maxDate,excludeDates:n.props.excludeDates,excludeDateIntervals:n.props.excludeDateIntervals,includeDateIntervals:n.props.includeDateIntervals,includeDates:n.props.includeDates,filterDate:n.props.filterDate})},n.handleDayClick=function(s,a){n.props.onDayClick&&n.props.onDayClick(s,a)},n.handleDayMouseEnter=function(s){n.props.onDayMouseEnter&&n.props.onDayMouseEnter(s)},n.handleWeekClick=function(s,a,r){for(var i,c,d,f=new Date(s),h=0;h<7;h++){var m=new Date(s);m.setDate(m.getDate()+h);var b=!n.isDisabled(m);if(b){f=m;break}}typeof n.props.onWeekSelect=="function"&&n.props.onWeekSelect(f,a,r),n.props.showWeekPicker&&n.handleDayClick(f,r),((i=n.props.shouldCloseOnSelect)!==null&&i!==void 0?i:e.defaultProps.shouldCloseOnSelect)&&((d=(c=n.props).setOpen)===null||d===void 0||d.call(c,!1))},n.formatWeekNumber=function(s){return n.props.formatWeekNumber?n.props.formatWeekNumber(s):RU(s)},n.isWeekDisabled=function(){for(var s=n.startOfWeek(),a=Pa(s,6),r=new Date(s);r<=a;){if(!n.isDisabled(r))return!1;r=Pa(r,1)}return!0},n.renderDays=function(){var s=n.startOfWeek(),a=[],r=n.formatWeekNumber(s);if(n.props.showWeekNumber){var i=n.props.onWeekSelect||n.props.showWeekPicker?n.handleWeekClick.bind(n,s,r):void 0;a.push(Se.createElement(XU,qt({key:"W"},e.defaultProps,n.props,{weekNumber:r,isWeekDisabled:n.isWeekDisabled(),date:s,onClick:i})))}return a.concat([0,1,2,3,4,5,6].map(function(c){var d=Pa(s,c);return Se.createElement(QU,qt({},e.defaultProps,n.props,{ariaLabelPrefixWhenEnabled:n.props.chooseDayAriaLabelPrefix,ariaLabelPrefixWhenDisabled:n.props.disabledDayAriaLabelPrefix,key:d.valueOf(),day:d,onClick:n.handleDayClick.bind(n,d),onMouseEnter:n.handleDayMouseEnter.bind(n,d)}))}))},n.startOfWeek=function(){return Mi(n.props.day,n.props.locale,n.props.calendarStartDay)},n.isKeyboardSelected=function(){return!n.props.disabledKeyboardNavigation&&!on(n.startOfWeek(),n.props.selected)&&on(n.startOfWeek(),n.props.preSelection)},n}return Object.defineProperty(e,"defaultProps",{get:function(){return{shouldCloseOnSelect:!0}},enumerable:!1,configurable:!0}),e.prototype.render=function(){var n={"react-datepicker__week":!0,"react-datepicker__week--selected":on(this.startOfWeek(),this.props.selected),"react-datepicker__week--keyboard-selected":this.isKeyboardSelected()},s=this.props.weekClassName?this.props.weekClassName(this.startOfWeek()):void 0;return Se.createElement("div",{className:us(n,s),role:"row"},this.renderDays())},e})(x.Component),gu,ZU=6,ql={TWO_COLUMNS:"two_columns",THREE_COLUMNS:"three_columns",FOUR_COLUMNS:"four_columns"},wb=(gu={},gu[ql.TWO_COLUMNS]={grid:[[0,1],[2,3],[4,5],[6,7],[8,9],[10,11]],verticalNavigationOffset:2},gu[ql.THREE_COLUMNS]={grid:[[0,1,2],[3,4,5],[6,7,8],[9,10,11]],verticalNavigationOffset:3},gu[ql.FOUR_COLUMNS]={grid:[[0,1,2,3],[4,5,6,7],[8,9,10,11]],verticalNavigationOffset:4},gu),Vf=1;function kA(t,e){return t?ql.FOUR_COLUMNS:e?ql.TWO_COLUMNS:ql.THREE_COLUMNS}var eH=(function(t){ws(e,t);function e(){var n=t!==null&&t.apply(this,arguments)||this;return n.MONTH_REFS=rr([],Array(12),!0).map(function(){return x.createRef()}),n.QUARTER_REFS=rr([],Array(4),!0).map(function(){return x.createRef()}),n.isDisabled=function(s){return ja(s,{minDate:n.props.minDate,maxDate:n.props.maxDate,excludeDates:n.props.excludeDates,excludeDateIntervals:n.props.excludeDateIntervals,includeDateIntervals:n.props.includeDateIntervals,includeDates:n.props.includeDates,filterDate:n.props.filterDate,disabled:n.props.disabled})},n.isExcluded=function(s){return Ay(s,{excludeDates:n.props.excludeDates,excludeDateIntervals:n.props.excludeDateIntervals})},n.handleDayClick=function(s,a){var r,i;(i=(r=n.props).onDayClick)===null||i===void 0||i.call(r,s,a,n.props.orderInDisplay)},n.handleDayMouseEnter=function(s){var a,r;(r=(a=n.props).onDayMouseEnter)===null||r===void 0||r.call(a,s)},n.handleMouseLeave=function(){var s,a;(a=(s=n.props).onMouseLeave)===null||a===void 0||a.call(s)},n.isRangeStartMonth=function(s){var a=n.props,r=a.day,i=a.startDate,c=a.endDate;return!i||!c?!1:Es(oa(r,s),i)},n.isRangeStartQuarter=function(s){var a=n.props,r=a.day,i=a.startDate,c=a.endDate;return!i||!c?!1:Bp(Bl(r,s),i)},n.isRangeEndMonth=function(s){var a=n.props,r=a.day,i=a.startDate,c=a.endDate;return!i||!c?!1:Es(oa(r,s),c)},n.isRangeEndQuarter=function(s){var a=n.props,r=a.day,i=a.startDate,c=a.endDate;return!i||!c?!1:Bp(Bl(r,s),c)},n.isInSelectingRangeMonth=function(s){var a,r=n.props,i=r.day,c=r.selectsStart,d=r.selectsEnd,f=r.selectsRange,h=r.startDate,m=r.endDate,b=(a=n.props.selectingDate)!==null&&a!==void 0?a:n.props.preSelection;return!(c||d||f)||!b?!1:c&&m?Uf(b,m,s,i):d&&h||f&&h&&!m?Uf(h,b,s,i):!1},n.isSelectingMonthRangeStart=function(s){var a;if(!n.isInSelectingRangeMonth(s))return!1;var r=n.props,i=r.day,c=r.startDate,d=r.selectsStart,f=oa(i,s),h=(a=n.props.selectingDate)!==null&&a!==void 0?a:n.props.preSelection;return d?Es(f,h):Es(f,c)},n.isSelectingMonthRangeEnd=function(s){var a;if(!n.isInSelectingRangeMonth(s))return!1;var r=n.props,i=r.day,c=r.endDate,d=r.selectsEnd,f=r.selectsRange,h=oa(i,s),m=(a=n.props.selectingDate)!==null&&a!==void 0?a:n.props.preSelection;return d||f?Es(h,m):Es(h,c)},n.isInSelectingRangeQuarter=function(s){var a,r=n.props,i=r.day,c=r.selectsStart,d=r.selectsEnd,f=r.selectsRange,h=r.startDate,m=r.endDate,b=(a=n.props.selectingDate)!==null&&a!==void 0?a:n.props.preSelection;return!(c||d||f)||!b?!1:c&&m?qf(b,m,s,i):d&&h||f&&h&&!m?qf(h,b,s,i):!1},n.isWeekInMonth=function(s){var a=n.props.day,r=Pa(s,6);return Es(s,a)||Es(r,a)},n.isCurrentMonth=function(s,a){return Zt(s)===Zt(dn())&&a===Ks(dn())},n.isCurrentQuarter=function(s,a){return Zt(s)===Zt(dn())&&a===_i(dn())},n.isSelectedMonth=function(s,a,r){return Ks(r)===a&&Zt(s)===Zt(r)},n.isSelectMonthInList=function(s,a,r){return r.some(function(i){return n.isSelectedMonth(s,a,i)})},n.isSelectedQuarter=function(s,a,r){return _i(r)===a&&Zt(s)===Zt(r)},n.isSelectQuarterInList=function(s,a,r){return r.some(function(i){return n.isSelectedQuarter(s,a,i)})},n.isMonthSelected=function(){var s=n.props,a=s.day,r=s.selected,i=s.selectedDates,c=s.selectsMultiple,d=Ks(a);return c?i==null?void 0:i.some(function(f){return n.isSelectedMonth(a,d,f)}):!!r&&n.isSelectedMonth(a,d,r)},n.isQuarterSelected=function(){var s=n.props,a=s.day,r=s.selected,i=s.selectedDates,c=s.selectsMultiple,d=_i(a);return c?i==null?void 0:i.some(function(f){return n.isSelectedQuarter(a,d,f)}):!!r&&n.isSelectedQuarter(a,d,r)},n.renderWeeks=function(){if(!Gs(n.props.day))return[];for(var s=[],a=n.props.fixedHeight,r=0,i=!1,c=Mi(Ur(n.props.day),n.props.locale,n.props.calendarStartDay),d=function(w){return n.props.showWeekPicker?Mi(w,n.props.locale,n.props.calendarStartDay):n.props.preSelection},f=function(w){return n.props.showWeekPicker?Mi(w,n.props.locale,n.props.calendarStartDay):n.props.selected},h=n.props.selected?f(n.props.selected):void 0,m=n.props.preSelection?d(n.props.preSelection):void 0;s.push(Se.createElement(JU,qt({},n.props,{ariaLabelPrefix:n.props.weekAriaLabelPrefix,key:r,day:c,month:Ks(n.props.day),onDayClick:n.handleDayClick,onDayMouseEnter:n.handleDayMouseEnter,selected:h,preSelection:m,showWeekNumber:n.props.showWeekNumbers}))),!i;){r++,c=Tp(c,1);var b=a&&r>=ZU,y=!a&&!n.isWeekInMonth(c);if(b||y)if(n.props.peekNextMonth)i=!0;else break}return s},n.onMonthClick=function(s,a){var r=n.isMonthDisabledForLabelDate(a),i=r.isDisabled,c=r.labelDate;i||n.handleDayClick(Ur(c),s)},n.onMonthMouseEnter=function(s){var a=n.isMonthDisabledForLabelDate(s),r=a.isDisabled,i=a.labelDate;r||n.handleDayMouseEnter(Ur(i))},n.handleMonthNavigation=function(s,a){var r,i,c,d;(i=(r=n.props).setPreSelection)===null||i===void 0||i.call(r,a),(d=(c=n.MONTH_REFS[s])===null||c===void 0?void 0:c.current)===null||d===void 0||d.focus()},n.handleKeyboardNavigation=function(s,a,r){var i,c=n.props,d=c.selected,f=c.preSelection,h=c.setPreSelection,m=c.minDate,b=c.maxDate,y=c.showFourColumnMonthYearPicker,w=c.showTwoColumnMonthYearPicker;if(f){var C=kA(y,w),N=n.getVerticalOffset(C),k=(i=wb[C])===null||i===void 0?void 0:i.grid,j=function(I,O,_){var M,R,z=O,$=_;switch(I){case lt.ArrowRight:z=za(O,Vf),$=_===11?0:_+Vf;break;case lt.ArrowLeft:z=Ao(O,Vf),$=_===0?11:_-Vf;break;case lt.ArrowUp:z=Ao(O,N),$=!((M=k==null?void 0:k[0])===null||M===void 0)&&M.includes(_)?_+12-N:_-N;break;case lt.ArrowDown:z=za(O,N),$=!((R=k==null?void 0:k[k.length-1])===null||R===void 0)&&R.includes(_)?_-12+N:_+N;break}return{newCalculatedDate:z,newCalculatedMonth:$}},S=function(I,O,_){for(var M=40,R=I,z=!1,$=0,W=j(R,O,_),L=W.newCalculatedDate,F=W.newCalculatedMonth;!z;){if($>=M){L=O,F=_;break}if(m&&L<m){R=lt.ArrowRight;var H=j(R,L,F);L=H.newCalculatedDate,F=H.newCalculatedMonth}if(b&&L>b){R=lt.ArrowLeft;var H=j(R,L,F);L=H.newCalculatedDate,F=H.newCalculatedMonth}if($U(L,n.props)){var H=j(R,L,F);L=H.newCalculatedDate,F=H.newCalculatedMonth}else z=!0;$++}return{newCalculatedDate:L,newCalculatedMonth:F}};if(a===lt.Enter){n.isMonthDisabled(r)||(n.onMonthClick(s,r),h==null||h(d));return}var T=S(a,f,r),D=T.newCalculatedDate,E=T.newCalculatedMonth;switch(a){case lt.ArrowRight:case lt.ArrowLeft:case lt.ArrowUp:case lt.ArrowDown:n.handleMonthNavigation(E,D);break}}},n.getVerticalOffset=function(s){var a,r;return(r=(a=wb[s])===null||a===void 0?void 0:a.verticalNavigationOffset)!==null&&r!==void 0?r:0},n.onMonthKeyDown=function(s,a){var r=n.props,i=r.disabledKeyboardNavigation,c=r.handleOnMonthKeyDown,d=s.key;d!==lt.Tab&&s.preventDefault(),i||n.handleKeyboardNavigation(s,d,a),c&&c(s)},n.onQuarterClick=function(s,a){var r=Bl(n.props.day,a);Hf(r,n.props)||n.handleDayClick(cA(r),s)},n.onQuarterMouseEnter=function(s){var a=Bl(n.props.day,s);Hf(a,n.props)||n.handleDayMouseEnter(cA(a))},n.handleQuarterNavigation=function(s,a){var r,i,c,d;n.isDisabled(a)||n.isExcluded(a)||((i=(r=n.props).setPreSelection)===null||i===void 0||i.call(r,a),(d=(c=n.QUARTER_REFS[s-1])===null||c===void 0?void 0:c.current)===null||d===void 0||d.focus())},n.onQuarterKeyDown=function(s,a){var r,i,c=s.key;if(!n.props.disabledKeyboardNavigation)switch(c){case lt.Enter:n.onQuarterClick(s,a),(i=(r=n.props).setPreSelection)===null||i===void 0||i.call(r,n.props.selected);break;case lt.ArrowRight:if(!n.props.preSelection)break;n.handleQuarterNavigation(a===4?1:a+1,py(n.props.preSelection,1));break;case lt.ArrowLeft:if(!n.props.preSelection)break;n.handleQuarterNavigation(a===1?4:a-1,QN(n.props.preSelection));break}},n.isMonthDisabledForLabelDate=function(s){var a,r=n.props,i=r.day,c=r.disabled,d=r.minDate,f=r.maxDate,h=r.excludeDates,m=r.includeDates,b=oa(i,s);return c?{isDisabled:!0,labelDate:oa(i,s)}:{isDisabled:(a=(d||f||h||m)&&fT(b,n.props))!==null&&a!==void 0?a:!1,labelDate:b}},n.isMonthDisabled=function(s){var a=n.isMonthDisabledForLabelDate(s).isDisabled;return a},n.getMonthClassNames=function(s){var a=n.props,r=a.day,i=a.startDate,c=a.endDate,d=a.preSelection,f=a.monthClassName,h=f?f(oa(r,s)):void 0,m=n.getSelection();return us("react-datepicker__month-text","react-datepicker__month-".concat(s),h,{"react-datepicker__month-text--disabled":n.isMonthDisabled(s),"react-datepicker__month-text--selected":m?n.isSelectMonthInList(r,s,m):void 0,"react-datepicker__month-text--keyboard-selected":!n.props.disabledKeyboardNavigation&&d&&n.isSelectedMonth(r,s,d)&&!n.isMonthSelected()&&!n.isMonthDisabled(s),"react-datepicker__month-text--in-selecting-range":n.isInSelectingRangeMonth(s),"react-datepicker__month-text--in-range":i&&c?Uf(i,c,s,r):void 0,"react-datepicker__month-text--range-start":n.isRangeStartMonth(s),"react-datepicker__month-text--range-end":n.isRangeEndMonth(s),"react-datepicker__month-text--selecting-range-start":n.isSelectingMonthRangeStart(s),"react-datepicker__month-text--selecting-range-end":n.isSelectingMonthRangeEnd(s),"react-datepicker__month-text--today":n.isCurrentMonth(r,s)})},n.getTabIndex=function(s){if(n.props.preSelection==null)return"-1";var a=Ks(n.props.preSelection),r=n.isMonthDisabledForLabelDate(a).isDisabled,i=s===a&&!(r||n.props.disabledKeyboardNavigation)?"0":"-1";return i},n.getQuarterTabIndex=function(s){if(n.props.preSelection==null)return"-1";var a=_i(n.props.preSelection),r=Hf(n.props.day,n.props),i=s===a&&!(r||n.props.disabledKeyboardNavigation)?"0":"-1";return i},n.getAriaLabel=function(s){var a=n.props,r=a.chooseDayAriaLabelPrefix,i=r===void 0?"Choose":r,c=a.disabledDayAriaLabelPrefix,d=c===void 0?"Not available":c,f=a.day,h=a.locale,m=oa(f,s),b=n.isDisabled(m)||n.isExcluded(m)?d:i;return"".concat(b," ").concat(Bn(m,"MMMM yyyy",h))},n.getQuarterClassNames=function(s){var a=n.props,r=a.day,i=a.startDate,c=a.endDate,d=a.minDate,f=a.maxDate,h=a.excludeDates,m=a.includeDates,b=a.filterDate,y=a.preSelection,w=a.disabledKeyboardNavigation,C=a.disabled,N=(d||f||h||m||b||C)&&Hf(Bl(r,s),n.props),k=n.getSelection();return us("react-datepicker__quarter-text","react-datepicker__quarter-".concat(s),{"react-datepicker__quarter-text--disabled":N,"react-datepicker__quarter-text--selected":k?n.isSelectQuarterInList(r,s,k):void 0,"react-datepicker__quarter-text--keyboard-selected":!w&&y&&n.isSelectedQuarter(r,s,y)&&!n.isQuarterSelected()&&!N,"react-datepicker__quarter-text--in-selecting-range":n.isInSelectingRangeQuarter(s),"react-datepicker__quarter-text--in-range":i&&c?qf(i,c,s,r):void 0,"react-datepicker__quarter-text--range-start":n.isRangeStartQuarter(s),"react-datepicker__quarter-text--range-end":n.isRangeEndQuarter(s),"react-datepicker__quarter-text--today":n.isCurrentQuarter(r,s)})},n.getMonthContent=function(s){var a=n.props,r=a.showFullMonthYearPicker,i=a.renderMonthContent,c=a.locale,d=a.day,f=dT(s,c),h=Cy(s,c);return i?i(s,f,h,d):r?h:f},n.getQuarterContent=function(s){var a,r=n.props,i=r.renderQuarterContent,c=r.locale,d=zU(s,c);return(a=i==null?void 0:i(s,d))!==null&&a!==void 0?a:d},n.renderMonths=function(){var s,a=n.props,r=a.showTwoColumnMonthYearPicker,i=a.showFourColumnMonthYearPicker,c=a.day,d=a.selected,f=(s=wb[kA(i,r)])===null||s===void 0?void 0:s.grid;return f==null?void 0:f.map(function(h,m){return Se.createElement("div",{className:"react-datepicker__month-wrapper",key:m},h.map(function(b,y){return Se.createElement("div",{ref:n.MONTH_REFS[b],key:y,onClick:function(w){n.onMonthClick(w,b)},onKeyDown:function(w){gT(w)&&(w.preventDefault(),w.key=lt.Enter),n.onMonthKeyDown(w,b)},onMouseEnter:n.props.usePointerEvent?void 0:function(){return n.onMonthMouseEnter(b)},onPointerEnter:n.props.usePointerEvent?function(){return n.onMonthMouseEnter(b)}:void 0,tabIndex:Number(n.getTabIndex(b)),className:n.getMonthClassNames(b),"aria-disabled":n.isMonthDisabled(b),role:"option","aria-label":n.getAriaLabel(b),"aria-current":n.isCurrentMonth(c,b)?"date":void 0,"aria-selected":d?n.isSelectedMonth(c,b,d):void 0},n.getMonthContent(b))}))})},n.renderQuarters=function(){var s=n.props,a=s.day,r=s.selected,i=[1,2,3,4];return Se.createElement("div",{className:"react-datepicker__quarter-wrapper"},i.map(function(c,d){return Se.createElement("div",{key:d,ref:n.QUARTER_REFS[d],role:"option",onClick:function(f){n.onQuarterClick(f,c)},onKeyDown:function(f){n.onQuarterKeyDown(f,c)},onMouseEnter:n.props.usePointerEvent?void 0:function(){return n.onQuarterMouseEnter(c)},onPointerEnter:n.props.usePointerEvent?function(){return n.onQuarterMouseEnter(c)}:void 0,className:n.getQuarterClassNames(c),"aria-selected":r?n.isSelectedQuarter(a,c,r):void 0,tabIndex:Number(n.getQuarterTabIndex(c)),"aria-current":n.isCurrentQuarter(a,c)?"date":void 0},n.getQuarterContent(c))}))},n.getClassNames=function(){var s=n.props,a=s.selectingDate,r=s.selectsStart,i=s.selectsEnd,c=s.showMonthYearPicker,d=s.showQuarterYearPicker,f=s.showWeekPicker;return us("react-datepicker__month",{"react-datepicker__month--selecting-range":a&&(r||i)},{"react-datepicker__monthPicker":c},{"react-datepicker__quarterPicker":d},{"react-datepicker__weekPicker":f})},n}return e.prototype.getSelection=function(){var n=this.props,s=n.selected,a=n.selectedDates,r=n.selectsMultiple;if(r)return a;if(s)return[s]},e.prototype.render=function(){var n=this.props,s=n.showMonthYearPicker,a=n.showQuarterYearPicker,r=n.day,i=n.ariaLabelPrefix,c=i===void 0?"Month ":i,d=c?c.trim()+" ":"",f=Gs(r)?"".concat(d).concat(Bn(r,"MMMM, yyyy",this.props.locale)):"",h=s||a;return h?Se.createElement("div",{className:this.getClassNames(),onMouseLeave:this.props.usePointerEvent?void 0:this.handleMouseLeave,onPointerLeave:this.props.usePointerEvent?this.handleMouseLeave:void 0,"aria-label":f,role:"listbox"},s?this.renderMonths():this.renderQuarters()):Se.createElement("div",{role:"table"},this.props.dayNamesHeader&&Se.createElement("div",{role:"rowgroup"},this.props.dayNamesHeader),this.props.monthHeader&&Se.createElement("div",{role:"rowgroup"},this.props.monthHeader),Se.createElement("div",{className:this.getClassNames(),onMouseLeave:this.props.usePointerEvent?void 0:this.handleMouseLeave,onPointerLeave:this.props.usePointerEvent?this.handleMouseLeave:void 0,"aria-label":f,role:"rowgroup"},this.renderWeeks()),this.props.monthFooter&&Se.createElement("div",{role:"rowgroup"},this.props.monthFooter))},e})(x.Component),tH=(function(t){ws(e,t);function e(){var n=t!==null&&t.apply(this,arguments)||this;return n.monthOptionButtonsRef={},n.isSelectedMonth=function(s){return n.props.month===s},n.handleOptionKeyDown=function(s,a){var r;switch(a.key){case"Enter":a.preventDefault(),n.onChange(s);break;case"Escape":a.preventDefault(),n.props.onCancel();break;case"ArrowUp":case"ArrowDown":{a.preventDefault();var i=(s+(a.key==="ArrowUp"?-1:1)+n.props.monthNames.length)%n.props.monthNames.length;(r=n.monthOptionButtonsRef[i])===null||r===void 0||r.focus();break}}},n.renderOptions=function(){return n.monthOptionButtonsRef={},n.props.monthNames.map(function(s,a){return Se.createElement("div",{ref:function(r){n.monthOptionButtonsRef[a]=r,n.isSelectedMonth(a)&&(r==null||r.focus())},role:"button",tabIndex:0,className:n.isSelectedMonth(a)?"react-datepicker__month-option react-datepicker__month-option--selected_month":"react-datepicker__month-option",key:s,onClick:n.onChange.bind(n,a),onKeyDown:n.handleOptionKeyDown.bind(n,a),"aria-selected":n.isSelectedMonth(a)?"true":void 0},n.isSelectedMonth(a)?Se.createElement("span",{className:"react-datepicker__month-option--selected"},"✓"):"",s)})},n.onChange=function(s){return n.props.onChange(s)},n.handleClickOutside=function(){return n.props.onCancel()},n}return e.prototype.render=function(){return Se.createElement(fh,{className:"react-datepicker__month-dropdown",onClickOutside:this.handleClickOutside},this.renderOptions())},e})(x.Component),nH=(function(t){ws(e,t);function e(){var n=t!==null&&t.apply(this,arguments)||this;return n.state={dropdownVisible:!1},n.renderSelectOptions=function(s){return s.map(function(a,r){return Se.createElement("option",{key:a,value:r},a)})},n.renderSelectMode=function(s){return Se.createElement("select",{value:n.props.month,className:"react-datepicker__month-select",onChange:function(a){return n.onChange(parseInt(a.target.value))}},n.renderSelectOptions(s))},n.renderReadView=function(s,a){return Se.createElement("button",{key:"read",type:"button",style:{visibility:s?"visible":"hidden"},className:"react-datepicker__month-read-view",onClick:n.toggleDropdown},Se.createElement("span",{className:"react-datepicker__month-read-view--down-arrow"}),Se.createElement("span",{className:"react-datepicker__month-read-view--selected-month"},a[n.props.month]))},n.renderDropdown=function(s){return Se.createElement(tH,qt({key:"dropdown"},n.props,{monthNames:s,onChange:n.onChange,onCancel:n.toggleDropdown}))},n.renderScrollMode=function(s){var a=n.state.dropdownVisible,r=[n.renderReadView(!a,s)];return a&&r.unshift(n.renderDropdown(s)),r},n.onChange=function(s){n.toggleDropdown(),s!==n.props.month&&n.props.onChange(s)},n.toggleDropdown=function(){return n.setState({dropdownVisible:!n.state.dropdownVisible})},n}return e.prototype.render=function(){var n=this,s=[0,1,2,3,4,5,6,7,8,9,10,11].map(this.props.useShortMonthInDropdown?function(r){return dT(r,n.props.locale)}:function(r){return Cy(r,n.props.locale)}),a;switch(this.props.dropdownMode){case"scroll":a=this.renderScrollMode(s);break;case"select":a=this.renderSelectMode(s);break}return Se.createElement("div",{className:"react-datepicker__month-dropdown-container react-datepicker__month-dropdown-container--".concat(this.props.dropdownMode)},a)},e})(x.Component),SA=5;function sH(t,e,n){for(var s=[],a=t??Ri(n,SA),r=e??Ba(n,SA),i=Ur(a),c=Ur(r);!$r(i,c);)s.push(dn(i)),i=za(i,1);return s}var aH=(function(t){ws(e,t);function e(n){var s=t.call(this,n)||this;return s.renderOptions=function(){return s.state.monthYearsList.map(function(a){var r=yx(a),i=Za(s.props.date,a)&&Es(s.props.date,a);return Se.createElement("div",{className:i?"react-datepicker__month-year-option--selected_month-year":"react-datepicker__month-year-option",key:r,onClick:s.onChange.bind(s,r),"aria-selected":i?"true":void 0},i?Se.createElement("span",{className:"react-datepicker__month-year-option--selected"},"✓"):"",Bn(a,s.props.dateFormat,s.props.locale))})},s.onChange=function(a){return s.props.onChange(a)},s.handleClickOutside=function(){s.props.onCancel()},s.state={monthYearsList:sH(s.props.minDate,s.props.maxDate,s.props.date)},s}return e.prototype.render=function(){var n=us({"react-datepicker__month-year-dropdown":!0,"react-datepicker__month-year-dropdown--scrollable":this.props.scrollableMonthYearDropdown});return Se.createElement(fh,{className:n,onClickOutside:this.handleClickOutside},this.renderOptions())},e})(x.Component),CA=5,rH=(function(t){ws(e,t);function e(){var n=t!==null&&t.apply(this,arguments)||this;return n.state={dropdownVisible:!1},n.renderSelectOptions=function(){for(var s,a,r=(s=n.props.minDate)!==null&&s!==void 0?s:Ri(n.props.date,CA),i=(a=n.props.maxDate)!==null&&a!==void 0?a:Ba(n.props.date,CA),c=Ur(r),d=Ur(i),f=[];!$r(c,d);){var h=yx(c);f.push(Se.createElement("option",{key:h,value:h},Bn(c,n.props.dateFormat,n.props.locale))),c=za(c,1)}return f},n.onSelectChange=function(s){n.onChange(parseInt(s.target.value))},n.renderSelectMode=function(){return Se.createElement("select",{value:yx(Ur(n.props.date)),className:"react-datepicker__month-year-select",onChange:n.onSelectChange},n.renderSelectOptions())},n.renderReadView=function(s){var a=Bn(n.props.date,n.props.dateFormat,n.props.locale);return Se.createElement("div",{key:"read",style:{visibility:s?"visible":"hidden"},className:"react-datepicker__month-year-read-view",onClick:n.toggleDropdown},Se.createElement("span",{className:"react-datepicker__month-year-read-view--down-arrow"}),Se.createElement("span",{className:"react-datepicker__month-year-read-view--selected-month-year"},a))},n.renderDropdown=function(){return Se.createElement(aH,qt({key:"dropdown"},n.props,{onChange:n.onChange,onCancel:n.toggleDropdown}))},n.renderScrollMode=function(){var s=n.state.dropdownVisible,a=[n.renderReadView(!s)];return s&&a.unshift(n.renderDropdown()),a},n.onChange=function(s){n.toggleDropdown();var a=dn(s);Za(n.props.date,a)&&Es(n.props.date,a)||n.props.onChange(a)},n.toggleDropdown=function(){return n.setState({dropdownVisible:!n.state.dropdownVisible})},n}return e.prototype.render=function(){var n;switch(this.props.dropdownMode){case"scroll":n=this.renderScrollMode();break;case"select":n=this.renderSelectMode();break}return Se.createElement("div",{className:"react-datepicker__month-year-dropdown-container react-datepicker__month-year-dropdown-container--".concat(this.props.dropdownMode)},n)},e})(x.Component),iH=(function(t){ws(e,t);function e(){var n=t!==null&&t.apply(this,arguments)||this;return n.state={height:null},n.scrollToTheSelectedTime=function(){requestAnimationFrame(function(){var s,a,r;n.list&&(n.list.scrollTop=(r=n.centerLi&&e.calcCenterPosition(n.props.monthRef?n.props.monthRef.clientHeight-((a=(s=n.header)===null||s===void 0?void 0:s.clientHeight)!==null&&a!==void 0?a:0):n.list.clientHeight,n.centerLi))!==null&&r!==void 0?r:0)})},n.handleClick=function(s){var a,r;(n.props.minTime||n.props.maxTime)&&hA(s,n.props)||(n.props.excludeTimes||n.props.includeTimes||n.props.filterTime)&&pA(s,n.props)||(r=(a=n.props).onChange)===null||r===void 0||r.call(a,s)},n.isSelectedTime=function(s){var a=So(n.props.selected);return a&&mT(a,s)},n.isDisabledTime=function(s){return(n.props.minTime||n.props.maxTime)&&hA(s,n.props)||(n.props.excludeTimes||n.props.includeTimes||n.props.filterTime)&&pA(s,n.props)},n.liClasses=function(s){var a,r=["react-datepicker__time-list-item",n.props.timeClassName?n.props.timeClassName(s):void 0];return n.isSelectedTime(s)&&r.push("react-datepicker__time-list-item--selected"),n.isDisabledTime(s)&&r.push("react-datepicker__time-list-item--disabled"),n.props.injectTimes&&(Cs(s)*3600+As(s)*60+Ei(s))%(((a=n.props.intervals)!==null&&a!==void 0?a:e.defaultProps.intervals)*60)!==0&&r.push("react-datepicker__time-list-item--injected"),r.join(" ")},n.handleOnKeyDown=function(s,a){var r,i;s.key===lt.Space&&(s.preventDefault(),s.key=lt.Enter),(s.key===lt.ArrowUp||s.key===lt.ArrowLeft)&&s.target instanceof HTMLElement&&s.target.previousSibling&&(s.preventDefault(),s.target.previousSibling instanceof HTMLElement&&s.target.previousSibling.focus()),(s.key===lt.ArrowDown||s.key===lt.ArrowRight)&&s.target instanceof HTMLElement&&s.target.nextSibling&&(s.preventDefault(),s.target.nextSibling instanceof HTMLElement&&s.target.nextSibling.focus()),s.key===lt.Enter&&n.handleClick(a),(i=(r=n.props).handleOnKeyDown)===null||i===void 0||i.call(r,s)},n.renderTimes=function(){for(var s,a=[],r=typeof n.props.format=="string"?n.props.format:"p",i=(s=n.props.intervals)!==null&&s!==void 0?s:e.defaultProps.intervals,c=So(n.props.selected)||So(n.props.openToDate)||dn(),d=wu(c),f=n.props.injectTimes&&n.props.injectTimes.sort(function(N,k){return N.getTime()-k.getTime()}),h=60*KU(c),m=h/i,b=0;b<m;b++){var y=Gu(d,b*i);if(a.push(y),f){var w=GU(d,y,b,i,f);a=a.concat(w)}}var C=a.reduce(function(N,k){return k.getTime()<=c.getTime()?k:N},a[0]);return a.map(function(N){return Se.createElement("li",{key:N.valueOf(),onClick:n.handleClick.bind(n,N),className:n.liClasses(N),ref:function(k){N===C&&(n.centerLi=k)},onKeyDown:function(k){n.handleOnKeyDown(k,N)},tabIndex:N===C?0:-1,role:"option","aria-selected":n.isSelectedTime(N)?"true":void 0,"aria-disabled":n.isDisabledTime(N)?"true":void 0},Bn(N,r,n.props.locale))})},n.renderTimeCaption=function(){return n.props.showTimeCaption===!1?Se.createElement(Se.Fragment,null):Se.createElement("div",{className:"react-datepicker__header react-datepicker__header--time ".concat(n.props.showTimeSelectOnly?"react-datepicker__header--time--only":""),ref:function(s){n.header=s}},Se.createElement("div",{className:"react-datepicker-time__header"},n.props.timeCaption))},n}return Object.defineProperty(e,"defaultProps",{get:function(){return{intervals:30,todayButton:null,timeCaption:"Time",showTimeCaption:!0}},enumerable:!1,configurable:!0}),e.prototype.componentDidMount=function(){this.scrollToTheSelectedTime(),this.observeDatePickerHeightChanges()},e.prototype.componentWillUnmount=function(){var n;(n=this.resizeObserver)===null||n===void 0||n.disconnect()},e.prototype.observeDatePickerHeightChanges=function(){var n=this,s=this.props.monthRef;this.updateContainerHeight(),s&&(this.resizeObserver=new ResizeObserver(function(){n.updateContainerHeight()}),this.resizeObserver.observe(s))},e.prototype.updateContainerHeight=function(){if(this.props.monthRef&&this.header){var n=this.props.monthRef.clientHeight-this.header.clientHeight;this.state.height!==n&&this.setState({height:n})}},e.prototype.render=function(){var n=this,s,a=this.state.height;return Se.createElement("div",{className:"react-datepicker__time-container ".concat(((s=this.props.todayButton)!==null&&s!==void 0?s:e.defaultProps.todayButton)?"react-datepicker__time-container--with-today-button":"")},this.renderTimeCaption(),Se.createElement("div",{className:"react-datepicker__time"},Se.createElement("div",{className:"react-datepicker__time-box"},Se.createElement("ul",{className:"react-datepicker__time-list",ref:function(r){n.list=r},style:a?{height:a}:{},role:"listbox","aria-label":this.props.timeCaption},this.renderTimes()))))},e.calcCenterPosition=function(n,s){return s.offsetTop-(n/2-s.clientHeight/2)},e})(x.Component),AA=3,oH=(function(t){ws(e,t);function e(n){var s=t.call(this,n)||this;return s.YEAR_REFS=rr([],Array(s.props.yearItemNumber),!0).map(function(){return x.createRef()}),s.isDisabled=function(a){return ja(a,{minDate:s.props.minDate,maxDate:s.props.maxDate,excludeDates:s.props.excludeDates,includeDates:s.props.includeDates,filterDate:s.props.filterDate})},s.isExcluded=function(a){return Ay(a,{excludeDates:s.props.excludeDates})},s.selectingDate=function(){var a;return(a=s.props.selectingDate)!==null&&a!==void 0?a:s.props.preSelection},s.updateFocusOnPaginate=function(a){var r=function(){var i,c;(c=(i=s.YEAR_REFS[a])===null||i===void 0?void 0:i.current)===null||c===void 0||c.focus()};window.requestAnimationFrame(r)},s.handleYearClick=function(a,r){s.props.onDayClick&&s.props.onDayClick(a,r)},s.handleYearNavigation=function(a,r){var i,c,d,f,h=s.props,m=h.date,b=h.yearItemNumber;if(!(m===void 0||b===void 0)){var y=Pr(m,b).startPeriod;s.isDisabled(r)||s.isExcluded(r)||((c=(i=s.props).setPreSelection)===null||c===void 0||c.call(i,r),a-y<0?s.updateFocusOnPaginate(b-(y-a)):a-y>=b?s.updateFocusOnPaginate(Math.abs(b-(a-y))):(f=(d=s.YEAR_REFS[a-y])===null||d===void 0?void 0:d.current)===null||f===void 0||f.focus())}},s.isSameDay=function(a,r){return on(a,r)},s.isCurrentYear=function(a){return a===Zt(dn())},s.isRangeStart=function(a){return s.props.startDate&&s.props.endDate&&Za(Ja(dn(),a),s.props.startDate)},s.isRangeEnd=function(a){return s.props.startDate&&s.props.endDate&&Za(Ja(dn(),a),s.props.endDate)},s.isInRange=function(a){return Wf(a,s.props.startDate,s.props.endDate)},s.isInSelectingRange=function(a){var r=s.props,i=r.selectsStart,c=r.selectsEnd,d=r.selectsRange,f=r.startDate,h=r.endDate;return!(i||c||d)||!s.selectingDate()?!1:i&&h?Wf(a,s.selectingDate(),h):c&&f||d&&f&&!h?Wf(a,f,s.selectingDate()):!1},s.isSelectingRangeStart=function(a){var r;if(!s.isInSelectingRange(a))return!1;var i=s.props,c=i.startDate,d=i.selectsStart,f=Ja(dn(),a);return d?Za(f,(r=s.selectingDate())!==null&&r!==void 0?r:null):Za(f,c??null)},s.isSelectingRangeEnd=function(a){var r;if(!s.isInSelectingRange(a))return!1;var i=s.props,c=i.endDate,d=i.selectsEnd,f=i.selectsRange,h=Ja(dn(),a);return d||f?Za(h,(r=s.selectingDate())!==null&&r!==void 0?r:null):Za(h,c??null)},s.isKeyboardSelected=function(a){if(!(s.props.disabledKeyboardNavigation||s.props.date===void 0||s.props.preSelection==null)){var r=s.props,i=r.minDate,c=r.maxDate,d=r.excludeDates,f=r.includeDates,h=r.filterDate,m=r.selected,b=ku(Ja(s.props.date,a)),y=(i||c||d||f||h)&&op(a,s.props),w=!!m&&on(b,ku(m)),C=on(b,ku(s.props.preSelection));return!s.props.inline&&!w&&C&&!y}},s.isSelectedYear=function(a){var r=s.props,i=r.selectsMultiple,c=r.selected,d=r.selectedDates;return i?d==null?void 0:d.some(function(f){return a===Zt(f)}):!!c&&a===Zt(c)},s.onYearClick=function(a,r){var i=s.props.date;i!==void 0&&s.handleYearClick(ku(Ja(i,r)),a)},s.onYearKeyDown=function(a,r){var i,c,d=a.key,f=s.props,h=f.date,m=f.yearItemNumber,b=f.handleOnKeyDown;if(d!==lt.Tab&&a.preventDefault(),!s.props.disabledKeyboardNavigation)switch(d){case lt.Enter:if(s.props.selected==null)break;s.onYearClick(a,r),(c=(i=s.props).setPreSelection)===null||c===void 0||c.call(i,s.props.selected);break;case lt.ArrowRight:if(s.props.preSelection==null)break;s.handleYearNavigation(r+1,Ba(s.props.preSelection,1));break;case lt.ArrowLeft:if(s.props.preSelection==null)break;s.handleYearNavigation(r-1,Ri(s.props.preSelection,1));break;case lt.ArrowUp:{if(h===void 0||m===void 0||s.props.preSelection==null)break;var y=Pr(h,m).startPeriod,w=AA,C=r-w;if(C<y){var N=m%w;r>=y&&r<y+N?w=N:w+=N,C=r-w}s.handleYearNavigation(C,Ri(s.props.preSelection,w));break}case lt.ArrowDown:{if(h===void 0||m===void 0||s.props.preSelection==null)break;var k=Pr(h,m).endPeriod,w=AA,C=r+w;if(C>k){var N=m%w;r<=k&&r>k-N?w=N:w+=N,C=r+w}s.handleYearNavigation(C,Ba(s.props.preSelection,w));break}}b&&b(a)},s.getYearClassNames=function(a){var r=s.props,i=r.date,c=r.disabled,d=r.minDate,f=r.maxDate,h=r.excludeDates,m=r.includeDates,b=r.filterDate,y=r.yearClassName;return us("react-datepicker__year-text","react-datepicker__year-".concat(a),i?y==null?void 0:y(Ja(i,a)):void 0,{"react-datepicker__year-text--selected":s.isSelectedYear(a),"react-datepicker__year-text--disabled":(d||f||h||m||b||c)&&op(a,s.props),"react-datepicker__year-text--keyboard-selected":s.isKeyboardSelected(a),"react-datepicker__year-text--range-start":s.isRangeStart(a),"react-datepicker__year-text--range-end":s.isRangeEnd(a),"react-datepicker__year-text--in-range":s.isInRange(a),"react-datepicker__year-text--in-selecting-range":s.isInSelectingRange(a),"react-datepicker__year-text--selecting-range-start":s.isSelectingRangeStart(a),"react-datepicker__year-text--selecting-range-end":s.isSelectingRangeEnd(a),"react-datepicker__year-text--today":s.isCurrentYear(a)})},s.getYearTabIndex=function(a){if(s.props.disabledKeyboardNavigation||s.props.preSelection==null)return"-1";var r=Zt(s.props.preSelection),i=op(a,s.props);return a===r&&!i?"0":"-1"},s.getYearContent=function(a){return s.props.renderYearContent?s.props.renderYearContent(a):a},s}return e.prototype.render=function(){var n=this,s=[],a=this.props,r=a.date,i=a.yearItemNumber,c=a.onYearMouseEnter,d=a.onYearMouseLeave;if(r===void 0)return null;for(var f=Pr(r,i),h=f.startPeriod,m=f.endPeriod,b=function(C){s.push(Se.createElement("div",{ref:y.YEAR_REFS[C-h],onClick:function(N){n.onYearClick(N,C)},onKeyDown:function(N){gT(N)&&(N.preventDefault(),N.key=lt.Enter),n.onYearKeyDown(N,C)},tabIndex:Number(y.getYearTabIndex(C)),className:y.getYearClassNames(C),onMouseEnter:y.props.usePointerEvent?void 0:function(N){return c(N,C)},onPointerEnter:y.props.usePointerEvent?function(N){return c(N,C)}:void 0,onMouseLeave:y.props.usePointerEvent?void 0:function(N){return d(N,C)},onPointerLeave:y.props.usePointerEvent?function(N){return d(N,C)}:void 0,key:C,"aria-current":y.isCurrentYear(C)?"date":void 0},y.getYearContent(C)))},y=this,w=h;w<=m;w++)b(w);return Se.createElement("div",{className:"react-datepicker__year"},Se.createElement("div",{className:"react-datepicker__year-wrapper",onMouseLeave:this.props.usePointerEvent?void 0:this.props.clearSelectingDate,onPointerLeave:this.props.usePointerEvent?this.props.clearSelectingDate:void 0},s))},e})(x.Component);function lH(t,e,n,s){for(var a=[],r=0;r<2*e+1;r++){var i=t+e-r,c=!0;n&&(c=Zt(n)<=i),s&&c&&(c=Zt(s)>=i),c&&a.push(i)}return a}var cH=(function(t){ws(e,t);function e(n){var s=t.call(this,n)||this;s.yearOptionButtonsRef={},s.handleOptionKeyDown=function(c,d){var f;switch(d.key){case"Enter":d.preventDefault(),s.onChange(c);break;case"Escape":d.preventDefault(),s.props.onCancel();break;case"ArrowUp":case"ArrowDown":{d.preventDefault();var h=c+(d.key==="ArrowUp"?1:-1);s.yearOptionButtonsRef[h]&&((f=s.yearOptionButtonsRef[h])===null||f===void 0||f.focus());break}}},s.renderOptions=function(){s.yearOptionButtonsRef={};var c=s.props.year,d=s.state.yearsList.map(function(m){return Se.createElement("div",{ref:function(b){s.yearOptionButtonsRef[m]=b,m===c&&(b==null||b.focus())},role:"button",tabIndex:0,className:c===m?"react-datepicker__year-option react-datepicker__year-option--selected_year":"react-datepicker__year-option",key:m,onClick:s.onChange.bind(s,m),onKeyDown:s.handleOptionKeyDown.bind(s,m),"aria-selected":c===m?"true":void 0},c===m?Se.createElement("span",{className:"react-datepicker__year-option--selected"},"✓"):"",m)}),f=s.props.minDate?Zt(s.props.minDate):null,h=s.props.maxDate?Zt(s.props.maxDate):null;return(!h||!s.state.yearsList.find(function(m){return m===h}))&&d.unshift(Se.createElement("div",{className:"react-datepicker__year-option",key:"upcoming",onClick:s.incrementYears},Se.createElement("a",{className:"react-datepicker__navigation react-datepicker__navigation--years react-datepicker__navigation--years-upcoming"}))),(!f||!s.state.yearsList.find(function(m){return m===f}))&&d.push(Se.createElement("div",{className:"react-datepicker__year-option",key:"previous",onClick:s.decrementYears},Se.createElement("a",{className:"react-datepicker__navigation react-datepicker__navigation--years react-datepicker__navigation--years-previous"}))),d},s.onChange=function(c){s.props.onChange(c)},s.handleClickOutside=function(){s.props.onCancel()},s.shiftYears=function(c){var d=s.state.yearsList.map(function(f){return f+c});s.setState({yearsList:d})},s.incrementYears=function(){return s.shiftYears(1)},s.decrementYears=function(){return s.shiftYears(-1)};var a=n.yearDropdownItemNumber,r=n.scrollableYearDropdown,i=a||(r?10:5);return s.state={yearsList:lH(s.props.year,i,s.props.minDate,s.props.maxDate)},s.dropdownRef=x.createRef(),s}return e.prototype.componentDidMount=function(){var n=this.dropdownRef.current;if(n){var s=n.children?Array.from(n.children):null,a=s?s.find(function(r){return r.ariaSelected}):null;n.scrollTop=a&&a instanceof HTMLElement?a.offsetTop+(a.clientHeight-n.clientHeight)/2:(n.scrollHeight-n.clientHeight)/2}},e.prototype.render=function(){var n=us({"react-datepicker__year-dropdown":!0,"react-datepicker__year-dropdown--scrollable":this.props.scrollableYearDropdown});return Se.createElement(fh,{className:n,containerRef:this.dropdownRef,onClickOutside:this.handleClickOutside},this.renderOptions())},e})(x.Component),uH=(function(t){ws(e,t);function e(){var n=t!==null&&t.apply(this,arguments)||this;return n.state={dropdownVisible:!1},n.renderSelectOptions=function(){for(var s=n.props.minDate?Zt(n.props.minDate):1900,a=n.props.maxDate?Zt(n.props.maxDate):2100,r=[],i=s;i<=a;i++)r.push(Se.createElement("option",{key:i,value:i},i));return r},n.onSelectChange=function(s){n.onChange(parseInt(s.target.value))},n.renderSelectMode=function(){return Se.createElement("select",{value:n.props.year,className:"react-datepicker__year-select",onChange:n.onSelectChange},n.renderSelectOptions())},n.renderReadView=function(s){return Se.createElement("button",{key:"read",type:"button",style:{visibility:s?"visible":"hidden"},className:"react-datepicker__year-read-view",onClick:n.toggleDropdown},Se.createElement("span",{className:"react-datepicker__year-read-view--down-arrow"}),Se.createElement("span",{className:"react-datepicker__year-read-view--selected-year"},n.props.year))},n.renderDropdown=function(){return Se.createElement(cH,qt({key:"dropdown"},n.props,{onChange:n.onChange,onCancel:n.toggleDropdown}))},n.renderScrollMode=function(){var s=n.state.dropdownVisible,a=[n.renderReadView(!s)];return s&&a.unshift(n.renderDropdown()),a},n.onChange=function(s){n.toggleDropdown(),s!==n.props.year&&n.props.onChange(s)},n.toggleDropdown=function(s){n.setState({dropdownVisible:!n.state.dropdownVisible},function(){n.props.adjustDateOnChange&&n.handleYearChange(n.props.date,s)})},n.handleYearChange=function(s,a){var r;(r=n.onSelect)===null||r===void 0||r.call(n,s,a),n.setOpen()},n.onSelect=function(s,a){var r,i;(i=(r=n.props).onSelect)===null||i===void 0||i.call(r,s,a)},n.setOpen=function(){var s,a;(a=(s=n.props).setOpen)===null||a===void 0||a.call(s,!0)},n}return e.prototype.render=function(){var n;switch(this.props.dropdownMode){case"scroll":n=this.renderScrollMode();break;case"select":n=this.renderSelectMode();break}return Se.createElement("div",{className:"react-datepicker__year-dropdown-container react-datepicker__year-dropdown-container--".concat(this.props.dropdownMode)},n)},e})(x.Component),dH=["react-datepicker__year-select","react-datepicker__month-select","react-datepicker__month-year-select"],bT="react-datepicker-ignore-onclickoutside",fH=function(t){var e=(t.className||"").split(/\s+/);return dH.some(function(n){return e.indexOf(n)>=0})},pH=(function(t){ws(e,t);function e(n){var s=t.call(this,n)||this;return s.monthContainer=void 0,s.handleClickOutside=function(a){s.props.onClickOutside(a)},s.setClickOutsideRef=function(){return s.containerRef.current},s.handleDropdownFocus=function(a){var r,i;fH(a.target)&&((i=(r=s.props).onDropdownFocus)===null||i===void 0||i.call(r,a))},s.getDateInView=function(){var a=s.props,r=a.preSelection,i=a.selected,c=a.openToDate,d=pT(s.props),f=hT(s.props),h=dn(),m=c||i||r;return m||(d&&ar(h,d)?d:f&&$r(h,f)?f:h)},s.increaseMonth=function(){s.setState(function(a){var r=a.date;return{date:za(r,1)}},function(){return s.handleMonthChange(s.state.date)})},s.decreaseMonth=function(){s.setState(function(a){var r=a.date;return{date:Ao(r,1)}},function(){return s.handleMonthChange(s.state.date)})},s.handleDayClick=function(a,r,i){s.props.onSelect(a,r,i),s.props.setPreSelection&&s.props.setPreSelection(a)},s.handleDayMouseEnter=function(a){s.setState({selectingDate:a}),s.props.onDayMouseEnter&&s.props.onDayMouseEnter(a)},s.handleMonthMouseLeave=function(){s.setState({selectingDate:void 0}),s.props.onMonthMouseLeave&&s.props.onMonthMouseLeave()},s.handleYearMouseEnter=function(a,r){s.setState({selectingDate:Ja(dn(),r)}),s.props.onYearMouseEnter&&s.props.onYearMouseEnter(a,r)},s.handleYearMouseLeave=function(a,r){s.props.onYearMouseLeave&&s.props.onYearMouseLeave(a,r)},s.handleYearChange=function(a){var r,i,c,d;(i=(r=s.props).onYearChange)===null||i===void 0||i.call(r,a),s.setState({isRenderAriaLiveMessage:!0}),s.props.adjustDateOnChange&&(s.props.onSelect(a),(d=(c=s.props).setOpen)===null||d===void 0||d.call(c,!0)),s.props.setPreSelection&&s.props.setPreSelection(a)},s.getEnabledPreSelectionDateForMonth=function(a){if(!ja(a,s.props))return a;for(var r=Ur(a),i=IU(a),c=Z4(i,r),d=null,f=0;f<=c;f++){var h=Pa(r,f);if(!ja(h,s.props)){d=h;break}}return d},s.handleMonthChange=function(a){var r,i,c,d=(r=s.getEnabledPreSelectionDateForMonth(a))!==null&&r!==void 0?r:a;s.handleCustomMonthChange(d),s.props.adjustDateOnChange&&(s.props.onSelect(d),(c=(i=s.props).setOpen)===null||c===void 0||c.call(i,!0)),s.props.setPreSelection&&s.props.setPreSelection(d)},s.handleCustomMonthChange=function(a){var r,i;(i=(r=s.props).onMonthChange)===null||i===void 0||i.call(r,a),s.setState({isRenderAriaLiveMessage:!0})},s.handleMonthYearChange=function(a){s.handleYearChange(a),s.handleMonthChange(a)},s.changeYear=function(a){s.setState(function(r){var i=r.date;return{date:Ja(i,Number(a))}},function(){return s.handleYearChange(s.state.date)})},s.changeMonth=function(a){s.setState(function(r){var i=r.date;return{date:oa(i,Number(a))}},function(){var r,i;s.handleMonthChange(s.state.date),(i=(r=s.props).onMonthSelectedInChange)===null||i===void 0||i.call(r,0)})},s.changeMonthYear=function(a){s.setState(function(r){var i=r.date;return{date:Ja(oa(i,Ks(a)),Zt(a))}},function(){return s.handleMonthYearChange(s.state.date)})},s.header=function(a,r){if(a===void 0&&(a=s.state.date),r===void 0&&(r=0),!Gs(a))return[];var i=s.props.disabled,c=Mi(a,s.props.locale,s.props.calendarStartDay),d=[];return s.props.showWeekNumbers&&d.push(Se.createElement("div",{key:"W",className:"react-datepicker__day-name ".concat(i?"react-datepicker__day-name--disabled":""),role:"columnheader"},Se.createElement("span",{className:"react-datepicker__sr-only"},"Week number"),Se.createElement("span",{"aria-hidden":"true"},s.props.weekLabel||"#"))),d.concat([0,1,2,3,4,5,6].map(function(f){var h=Pa(c,f),m=s.formatWeekday(h,s.props.locale),b=Bn(h,"EEEE",s.props.locale),y=s.props.weekDayClassName?s.props.weekDayClassName(h):void 0;if(s.props.renderCustomDayName){var w=s.props.renderCustomDayName({day:h,shortName:m,fullName:b,locale:s.props.locale,customDayNameCount:r});return Se.createElement("div",{key:f,role:"columnheader",className:us("react-datepicker__day-name",y,i?"react-datepicker__day-name--disabled":"")},w)}return Se.createElement("div",{key:f,role:"columnheader",className:us("react-datepicker__day-name",y,i?"react-datepicker__day-name--disabled":"")},Se.createElement("span",{className:"react-datepicker__sr-only"},b),Se.createElement("span",{"aria-hidden":"true"},m))}))},s.formatWeekday=function(a,r){return s.props.formatWeekDay?PU(a,s.props.formatWeekDay,r):s.props.useWeekdaysShort?FU(a,r):BU(a,r)},s.decreaseYear=function(){s.setState(function(a){var r,i=a.date;return{date:Ri(i,s.props.showYearPicker?(r=s.props.yearItemNumber)!==null&&r!==void 0?r:e.defaultProps.yearItemNumber:1)}},function(){return s.handleYearChange(s.state.date)})},s.clearSelectingDate=function(){s.setState({selectingDate:void 0})},s.renderPreviousButton=function(){var a,r,i;if(!s.props.renderCustomHeader){var c=(a=s.props.monthsShown)!==null&&a!==void 0?a:e.defaultProps.monthsShown,d=s.props.showPreviousMonths?c-1:0,f=(r=s.props.monthSelectedIn)!==null&&r!==void 0?r:d,h=Ao(s.state.date,f),m;switch(!0){case s.props.disabled:m=!0;break;case s.props.showMonthYearPicker:m=bA(s.state.date,s.props);break;case s.props.showYearPicker:m=WU(s.state.date,s.props);break;case s.props.showQuarterYearPicker:m=UU(s.state.date,s.props);break;default:m=mA(h,s.props);break}if(!(!((i=s.props.forceShowMonthNavigation)!==null&&i!==void 0?i:e.defaultProps.forceShowMonthNavigation)&&!s.props.showDisabledMonthNavigation&&m||s.props.showTimeSelectOnly)){var b=["react-datepicker__navigation-icon","react-datepicker__navigation-icon--previous"],y=["react-datepicker__navigation","react-datepicker__navigation--previous"],w=s.decreaseMonth;(s.props.showMonthYearPicker||s.props.showQuarterYearPicker||s.props.showYearPicker)&&(w=s.decreaseYear),m&&s.props.showDisabledMonthNavigation&&(y.push("react-datepicker__navigation--previous--disabled"),w=void 0);var C=s.props.showMonthYearPicker||s.props.showQuarterYearPicker||s.props.showYearPicker,N=s.props,k=N.previousMonthButtonLabel,j=k===void 0?e.defaultProps.previousMonthButtonLabel:k,S=N.previousYearButtonLabel,T=S===void 0?e.defaultProps.previousYearButtonLabel:S,D=s.props,E=D.previousMonthAriaLabel,I=E===void 0?typeof j=="string"?j:"Previous Month":E,O=D.previousYearAriaLabel,_=O===void 0?typeof T=="string"?T:"Previous Year":O;return Se.createElement("button",{type:"button",className:y.join(" "),onClick:w,onKeyDown:s.props.handleOnKeyDown,"aria-label":C?_:I},Se.createElement("span",{className:b.join(" ")},C?T:j))}}},s.increaseYear=function(){s.setState(function(a){var r,i=a.date;return{date:Ba(i,s.props.showYearPicker?(r=s.props.yearItemNumber)!==null&&r!==void 0?r:e.defaultProps.yearItemNumber:1)}},function(){return s.handleYearChange(s.state.date)})},s.renderNextButton=function(){var a;if(!s.props.renderCustomHeader){var r;switch(!0){case s.props.disabled:r=!0;break;case s.props.showMonthYearPicker:r=xA(s.state.date,s.props);break;case s.props.showYearPicker:r=qU(s.state.date,s.props);break;case s.props.showQuarterYearPicker:r=HU(s.state.date,s.props);break;default:r=gA(s.state.date,s.props);break}if(!(!((a=s.props.forceShowMonthNavigation)!==null&&a!==void 0?a:e.defaultProps.forceShowMonthNavigation)&&!s.props.showDisabledMonthNavigation&&r||s.props.showTimeSelectOnly)){var i=["react-datepicker__navigation","react-datepicker__navigation--next"],c=["react-datepicker__navigation-icon","react-datepicker__navigation-icon--next"];s.props.showTimeSelect&&i.push("react-datepicker__navigation--next--with-time"),s.props.todayButton&&i.push("react-datepicker__navigation--next--with-today-button");var d=s.increaseMonth;(s.props.showMonthYearPicker||s.props.showQuarterYearPicker||s.props.showYearPicker)&&(d=s.increaseYear),r&&s.props.showDisabledMonthNavigation&&(i.push("react-datepicker__navigation--next--disabled"),d=void 0);var f=s.props.showMonthYearPicker||s.props.showQuarterYearPicker||s.props.showYearPicker,h=s.props,m=h.nextMonthButtonLabel,b=m===void 0?e.defaultProps.nextMonthButtonLabel:m,y=h.nextYearButtonLabel,w=y===void 0?e.defaultProps.nextYearButtonLabel:y,C=s.props,N=C.nextMonthAriaLabel,k=N===void 0?typeof b=="string"?b:"Next Month":N,j=C.nextYearAriaLabel,S=j===void 0?typeof w=="string"?w:"Next Year":j;return Se.createElement("button",{type:"button",className:i.join(" "),onClick:d,onKeyDown:s.props.handleOnKeyDown,"aria-label":f?S:k},Se.createElement("span",{className:c.join(" ")},f?w:b))}}},s.renderCurrentMonth=function(a){a===void 0&&(a=s.state.date);var r=["react-datepicker__current-month"];return s.props.showYearDropdown&&r.push("react-datepicker__current-month--hasYearDropdown"),s.props.showMonthDropdown&&r.push("react-datepicker__current-month--hasMonthDropdown"),s.props.showMonthYearDropdown&&r.push("react-datepicker__current-month--hasMonthYearDropdown"),Se.createElement("h2",{className:r.join(" ")},Gs(a)?Bn(a,s.props.dateFormat,s.props.locale):"")},s.renderYearDropdown=function(a){if(a===void 0&&(a=!1),!(!s.props.showYearDropdown||a))return Se.createElement(uH,qt({},e.defaultProps,s.props,{date:s.state.date,onChange:s.changeYear,year:Zt(s.state.date)}))},s.renderMonthDropdown=function(a){if(a===void 0&&(a=!1),!(!s.props.showMonthDropdown||a))return Se.createElement(nH,qt({},e.defaultProps,s.props,{month:Ks(s.state.date),onChange:s.changeMonth}))},s.renderMonthYearDropdown=function(a){if(a===void 0&&(a=!1),!(!s.props.showMonthYearDropdown||a))return Se.createElement(rH,qt({},e.defaultProps,s.props,{date:s.state.date,onChange:s.changeMonthYear}))},s.handleTodayButtonClick=function(a){s.props.onSelect(uA(),a),s.props.setPreSelection&&s.props.setPreSelection(uA())},s.renderTodayButton=function(){if(!(!s.props.todayButton||s.props.showTimeSelectOnly))return Se.createElement("div",{className:"react-datepicker__today-button",onClick:s.handleTodayButtonClick},s.props.todayButton)},s.renderDayNamesHeader=function(a,r){return r===void 0&&(r=0),Se.createElement("div",{className:"react-datepicker__day-names",role:"row"},s.header(a,r))},s.renderDefaultHeader=function(a){var r=a.monthDate,i=a.i,c=Se.createElement("div",{className:us("react-datepicker__header",{"react-datepicker__header--has-time-select":s.props.showTimeSelect,"react-datepicker__header--middle":s.props.monthHeaderPosition==="middle","react-datepicker__header--bottom":s.props.monthHeaderPosition==="bottom"})},s.renderCurrentMonth(r),Se.createElement("div",{className:"react-datepicker__header__dropdown react-datepicker__header__dropdown--".concat(s.props.dropdownMode),onFocus:s.handleDropdownFocus},s.renderMonthDropdown(i!==0),s.renderMonthYearDropdown(i!==0),s.renderYearDropdown(i!==0)));return s.props.monthHeaderPosition==="top"?c:Se.createElement("div",{className:"react-datepicker__header-wrapper"},s.renderPreviousButton()||null,s.renderNextButton()||null,c)},s.renderCustomHeader=function(a){var r,i,c=a.monthDate,d=a.i;if(s.props.showTimeSelect&&!s.state.monthContainer||s.props.showTimeSelectOnly)return null;var f=s.props,h=f.showYearPicker,m=f.yearItemNumber,b;if(h){var y=Pr(c,m),w=y.startPeriod,C=y.endPeriod;b={startYear:w,endYear:C}}var N=mA(s.state.date,s.props),k=gA(s.state.date,s.props),j=bA(s.state.date,s.props),S=xA(s.state.date,s.props);return Se.createElement("div",{className:"react-datepicker__header react-datepicker__header--custom",onFocus:s.props.onDropdownFocus},(i=(r=s.props).renderCustomHeader)===null||i===void 0?void 0:i.call(r,qt(qt(qt({},s.state),h&&{visibleYearsRange:b}),{customHeaderCount:d,monthDate:c,changeMonth:s.changeMonth,changeYear:s.changeYear,decreaseMonth:s.decreaseMonth,increaseMonth:s.increaseMonth,decreaseYear:s.decreaseYear,increaseYear:s.increaseYear,prevMonthButtonDisabled:N,nextMonthButtonDisabled:k,prevYearButtonDisabled:j,nextYearButtonDisabled:S})))},s.renderYearHeader=function(a){var r=a.monthDate,i=s.props,c=i.showYearPicker,d=i.yearItemNumber,f=d===void 0?e.defaultProps.yearItemNumber:d,h=Pr(r,f),m=h.startPeriod,b=h.endPeriod;return Se.createElement("div",{className:"react-datepicker__header react-datepicker-year-header"},c?"".concat(m," - ").concat(b):Zt(r))},s.renderHeader=function(a){var r=a.monthDate,i=a.i,c=i===void 0?0:i,d={monthDate:r,i:c};switch(!0){case s.props.renderCustomHeader!==void 0:return s.renderCustomHeader(d);case(s.props.showMonthYearPicker||s.props.showQuarterYearPicker||s.props.showYearPicker):return s.renderYearHeader(d);default:return s.renderDefaultHeader(d)}},s.renderMonths=function(){var a,r;if(!(s.props.showTimeSelectOnly||s.props.showYearPicker)){for(var i=[],c=(a=s.props.monthsShown)!==null&&a!==void 0?a:e.defaultProps.monthsShown,d=s.props.showPreviousMonths?c-1:0,f=s.props.showMonthYearPicker||s.props.showQuarterYearPicker?Ba(s.state.date,d):Ao(s.state.date,d),h=(r=s.props.monthSelectedIn)!==null&&r!==void 0?r:d,m=0;m<c;++m){var b=m-h+d,y=s.props.showMonthYearPicker||s.props.showQuarterYearPicker?Ba(f,b):za(f,b),w="month-".concat(m),C=m<c-1,N=m>0;i.push(Se.createElement("div",{key:w,ref:function(k){s.monthContainer=k??void 0},className:"react-datepicker__month-container"},s.props.monthHeaderPosition==="top"&&s.renderHeader({monthDate:y,i:m}),Se.createElement(eH,qt({},e.defaultProps,s.props,{containerRef:s.containerRef,ariaLabelPrefix:s.props.monthAriaLabelPrefix,day:y,onDayClick:s.handleDayClick,handleOnKeyDown:s.props.handleOnDayKeyDown,handleOnMonthKeyDown:s.props.handleOnKeyDown,onDayMouseEnter:s.handleDayMouseEnter,onMouseLeave:s.handleMonthMouseLeave,orderInDisplay:m,selectingDate:s.state.selectingDate,monthShowsDuplicateDaysEnd:C,monthShowsDuplicateDaysStart:N,dayNamesHeader:s.renderDayNamesHeader(y,m),monthHeader:s.props.monthHeaderPosition==="middle"?s.renderHeader({monthDate:y,i:m}):void 0,monthFooter:s.props.monthHeaderPosition==="bottom"?s.renderHeader({monthDate:y,i:m}):void 0}))))}return i}},s.renderYears=function(){if(!s.props.showTimeSelectOnly&&s.props.showYearPicker)return Se.createElement("div",{className:"react-datepicker__year--container"},s.renderHeader({monthDate:s.state.date}),Se.createElement(oH,qt({},e.defaultProps,s.props,{selectingDate:s.state.selectingDate,date:s.state.date,onDayClick:s.handleDayClick,clearSelectingDate:s.clearSelectingDate,onYearMouseEnter:s.handleYearMouseEnter,onYearMouseLeave:s.handleYearMouseLeave})))},s.renderTimeSection=function(){if(s.props.showTimeSelect&&(s.state.monthContainer||s.props.showTimeSelectOnly))return Se.createElement(iH,qt({},e.defaultProps,s.props,{onChange:s.props.onTimeChange,format:s.props.timeFormat,intervals:s.props.timeIntervals,monthRef:s.state.monthContainer}))},s.renderInputTimeSection=function(){var a,r;if(s.props.showTimeInput){if(s.props.selectsRange){var i=s.props,c=i.startDate,d=i.endDate,f=c?new Date(c):void 0,h=f&&Gs(f)&&!!c,m=h?"".concat(Rl(f.getHours()),":").concat(Rl(f.getMinutes())):"",b=d?new Date(d):void 0,y=b&&Gs(b)&&!!d,w=y?"".concat(Rl(b.getHours()),":").concat(Rl(b.getMinutes())):"";return Se.createElement(Se.Fragment,null,Se.createElement(vb,qt({},e.defaultProps,s.props,{date:f,timeString:m,onChange:function(j){var S,T;(T=(S=s.props).onTimeChange)===null||T===void 0||T.call(S,j,"start")},timeInputLabel:((a=s.props.timeInputLabel)!==null&&a!==void 0?a:"Time")+" (Start)"})),Se.createElement(vb,qt({},e.defaultProps,s.props,{date:b,timeString:w,onChange:function(j){var S,T;(T=(S=s.props).onTimeChange)===null||T===void 0||T.call(S,j,"end")},timeInputLabel:((r=s.props.timeInputLabel)!==null&&r!==void 0?r:"Time")+" (End)"})))}var C=s.props.selected?new Date(s.props.selected):void 0,N=C&&Gs(C)&&!!s.props.selected,k=N?"".concat(Rl(C.getHours()),":").concat(Rl(C.getMinutes())):"";return Se.createElement(vb,qt({},e.defaultProps,s.props,{date:C,timeString:k,onChange:function(j){var S,T;(T=(S=s.props).onTimeChange)===null||T===void 0||T.call(S,j)}}))}},s.renderAriaLiveRegion=function(){var a;if(!Gs(s.state.date))return Se.createElement("span",{role:"alert","aria-live":"polite",className:"react-datepicker__aria-live"});var r=Pr(s.state.date,(a=s.props.yearItemNumber)!==null&&a!==void 0?a:e.defaultProps.yearItemNumber),i=r.startPeriod,c=r.endPeriod,d;return s.props.showYearPicker?d="".concat(i," - ").concat(c):s.props.showMonthYearPicker||s.props.showQuarterYearPicker?d=Zt(s.state.date):d="".concat(Cy(Ks(s.state.date),s.props.locale)," ").concat(Zt(s.state.date)),Se.createElement("span",{role:"alert","aria-live":"polite",className:"react-datepicker__aria-live"},s.state.isRenderAriaLiveMessage&&d)},s.renderChildren=function(){if(s.props.children)return Se.createElement("div",{className:"react-datepicker__children-container"},s.props.children)},s.containerRef=x.createRef(),s.state={date:s.getDateInView(),selectingDate:void 0,monthContainer:void 0,isRenderAriaLiveMessage:!1},s}return Object.defineProperty(e,"defaultProps",{get:function(){return{monthsShown:1,forceShowMonthNavigation:!1,outsideClickIgnoreClass:bT,timeCaption:"Time",previousYearButtonLabel:"Previous Year",nextYearButtonLabel:"Next Year",previousMonthButtonLabel:"Previous Month",nextMonthButtonLabel:"Next Month",yearItemNumber:id,monthHeaderPosition:"top"}},enumerable:!1,configurable:!0}),e.prototype.componentDidMount=function(){var n=this;this.props.showTimeSelect&&(this.assignMonthContainer=(function(){n.setState({monthContainer:n.monthContainer})})())},e.prototype.componentDidUpdate=function(n){var s=this;if(this.props.preSelection&&Gs(this.props.preSelection)&&(!on(this.props.preSelection,n.preSelection)||this.props.monthSelectedIn!==n.monthSelectedIn)){var a=!Es(this.state.date,this.props.preSelection);this.setState({date:this.props.preSelection},function(){return a&&s.handleCustomMonthChange(s.state.date)})}else this.props.openToDate&&!on(this.props.openToDate,n.openToDate)&&this.setState({date:this.props.openToDate})},e.prototype.render=function(){var n=this.props.container||TU;return Se.createElement(fh,{onClickOutside:this.handleClickOutside,style:{display:"contents"},ignoreClass:this.props.outsideClickIgnoreClass},Se.createElement("div",{style:{display:"contents"},ref:this.containerRef},Se.createElement(n,{className:us("react-datepicker",this.props.className,{"react-datepicker--time-only":this.props.showTimeSelectOnly}),showTime:this.props.showTimeSelect||this.props.showTimeInput,showTimeSelectOnly:this.props.showTimeSelectOnly,inline:this.props.inline},this.renderAriaLiveRegion(),this.props.monthHeaderPosition==="top"&&this.renderPreviousButton(),this.props.monthHeaderPosition==="top"&&this.renderNextButton(),this.renderMonths(),this.renderYears(),this.renderTodayButton(),this.renderTimeSection(),this.renderInputTimeSection(),this.renderChildren())))},e})(x.Component),hH=function(t){var e=t.icon,n=t.className,s=n===void 0?"":n,a=t.onClick,r="react-datepicker__calendar-icon";if(typeof e=="string")return Se.createElement("i",{className:"".concat(r," ").concat(e," ").concat(s),"aria-hidden":"true",onClick:a});if(Se.isValidElement(e)){var i=e;return Se.cloneElement(i,{className:"".concat(i.props.className||""," ").concat(r," ").concat(s),onClick:function(c){typeof i.props.onClick=="function"&&i.props.onClick(c),typeof a=="function"&&a(c)}})}return Se.createElement("svg",{className:"".concat(r," ").concat(s),xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",onClick:a},Se.createElement("path",{d:"M96 32V64H48C21.5 64 0 85.5 0 112v48H448V112c0-26.5-21.5-48-48-48H352V32c0-17.7-14.3-32-32-32s-32 14.3-32 32V64H160V32c0-17.7-14.3-32-32-32S96 14.3 96 32zM448 192H0V464c0 26.5 21.5 48 48 48H400c26.5 0 48-21.5 48-48V192z"}))},xT=(function(t){ws(e,t);function e(n){var s=t.call(this,n)||this;return s.portalRoot=null,s.el=document.createElement("div"),s}return e.prototype.componentDidMount=function(){this.portalRoot=(this.props.portalHost||document).getElementById(this.props.portalId),this.portalRoot||(this.portalRoot=document.createElement("div"),this.portalRoot.setAttribute("id",this.props.portalId),(this.props.portalHost||document.body).appendChild(this.portalRoot)),this.portalRoot.appendChild(this.el)},e.prototype.componentWillUnmount=function(){this.portalRoot&&this.portalRoot.removeChild(this.el)},e.prototype.render=function(){return C2.createPortal(this.props.children,this.el)},e})(x.Component),mH="[tabindex], a, button, input, select, textarea",gH=function(t){return(t instanceof HTMLAnchorElement||!t.disabled)&&t.tabIndex!==-1},yT=(function(t){ws(e,t);function e(n){var s=t.call(this,n)||this;return s.getTabChildren=function(){var a;return Array.prototype.slice.call((a=s.tabLoopRef.current)===null||a===void 0?void 0:a.querySelectorAll(mH),1,-1).filter(gH)},s.handleFocusStart=function(){var a=s.getTabChildren();a&&a.length>1&&a[a.length-1].focus()},s.handleFocusEnd=function(){var a=s.getTabChildren();a&&a.length>1&&a[0].focus()},s.tabLoopRef=x.createRef(),s}return e.prototype.render=function(){var n;return((n=this.props.enableTabLoop)!==null&&n!==void 0?n:e.defaultProps.enableTabLoop)?Se.createElement("div",{className:"react-datepicker__tab-loop",ref:this.tabLoopRef},Se.createElement("div",{className:"react-datepicker__tab-loop__start",tabIndex:0,onFocus:this.handleFocusStart}),this.props.children,Se.createElement("div",{className:"react-datepicker__tab-loop__end",tabIndex:0,onFocus:this.handleFocusEnd})):this.props.children},e.defaultProps={enableTabLoop:!0},e})(x.Component);function bH(t){function e(n){var s,a=typeof n.hidePopper=="boolean"?n.hidePopper:!0,r=x.useRef(null),i=NU(qt({open:!a,whileElementsMounted:rU,placement:n.popperPlacement,middleware:rr([hU({padding:15}),pU(10),mU({element:r})],(s=n.popperModifiers)!==null&&s!==void 0?s:[],!0)},n.popperProps)),c=qt(qt({},n),{hidePopper:a,popperProps:qt(qt({},i),{arrowRef:r})});return Se.createElement(t,qt({},c))}return e.displayName="withFloating(".concat(t.displayName||t.name||"Component",")"),e}var xH=function(t){var e=t.className,n=t.wrapperClassName,s=t.hidePopper,a=s===void 0?!0:s,r=t.popperComponent,i=t.targetComponent,c=t.enableTabLoop,d=t.popperOnKeyDown,f=t.portalId,h=t.portalHost,m=t.popperProps,b=t.showArrow,y=t.popperTargetRef,w=t.monthHeaderPosition;x.useEffect(function(){y!=null&&y.current&&m.refs.setPositionReference(y.current)},[y,m.refs]);var C=void 0;if(!a){var N=us("react-datepicker-popper",!b&&"react-datepicker-popper-offset",w==="middle"&&"react-datepicker-popper--header-middle",w==="bottom"&&"react-datepicker-popper--header-bottom",e);C=Se.createElement(yT,{enableTabLoop:c},Se.createElement("div",{ref:m.refs.setFloating,style:m.floatingStyles,className:N,"data-placement":m.placement,onKeyDown:d},r,b&&Se.createElement(vU,{ref:m.arrowRef,context:m.context,fill:"currentColor",strokeWidth:1,height:8,width:16,style:{transform:"translateY(-1px)"},className:"react-datepicker__triangle"})))}t.popperContainer&&(C=x.createElement(t.popperContainer,{},C)),f&&!a&&(C=Se.createElement(xT,{portalId:f,portalHost:h},C));var k=us("react-datepicker-wrapper",n);return Se.createElement(Se.Fragment,null,Se.createElement("div",{ref:m.refs.setReference,className:k},i),C)},yH=bH(xH);function jA(t,e){return t&&e?Ks(t)!==Ks(e)||Zt(t)!==Zt(e):t!==e}var kb="Date input not valid.",vH=(function(t){ws(e,t);function e(n){var s=t.call(this,n)||this;return s.calendar=null,s.input=null,s.getPreSelection=function(){var a=s.props.timeZone,r=s.props.openToDate?s.props.openToDate:s.props.selectsEnd&&s.props.startDate?s.props.startDate:s.props.selectsStart&&s.props.endDate?s.props.endDate:dn();return a?lA(r,a):r},s.modifyHolidays=function(){var a;return(a=s.props.holidays)===null||a===void 0?void 0:a.reduce(function(r,i){var c=bo(i.date,"yyyy-MM-dd",void 0,!1);return c?rr(rr([],r,!0),[qt(qt({},i),{date:c})],!1):r},[])},s.calcInitialState=function(){var a=s.props.timeZone,r=s.getPreSelection(),i=pT(s.props),c=hT(s.props),d=i&&ar(r,wu(i))?i:c&&$r(r,dA(c))?c:r,f=s.props.selectsRange?s.props.startDate:s.props.selected;return f&&a&&(f=lA(f,a)),{open:s.props.startOpen||!1,preventFocus:!1,inputValue:null,preSelection:f??d,highlightDates:yA(s.props.highlightDates),focused:!1,shouldFocusDayInline:!1,isRenderAriaLiveMessage:!1,wasHidden:!1}},s.getInputValue=function(){var a,r=s.props,i=r.locale,c=r.startDate,d=r.endDate,f=r.rangeSeparator,h=r.selected,m=r.selectedDates,b=r.selectsMultiple,y=r.selectsRange,w=r.formatMultipleDates,C=r.value,N=(a=s.props.dateFormat)!==null&&a!==void 0?a:e.defaultProps.dateFormat,k=s.state.inputValue;if(typeof C=="string")return C;if(typeof k=="string")return k;if(y)return MU(c,d,{dateFormat:N,locale:i,rangeSeparator:f});if(b){if(w){var j=function(S){return Ys(S,{dateFormat:N,locale:i})};return w(m??[],j)}return DU(m??[],{dateFormat:N,locale:i})}return Ys(h,{dateFormat:N,locale:i})},s.resetHiddenStatus=function(){s.setState(qt(qt({},s.state),{wasHidden:!1}))},s.setHiddenStatus=function(){s.setState(qt(qt({},s.state),{wasHidden:!0}))},s.setHiddenStateOnVisibilityHidden=function(){document.visibilityState==="hidden"&&s.setHiddenStatus()},s.clearPreventFocusTimeout=function(){s.preventFocusTimeout&&clearTimeout(s.preventFocusTimeout)},s.setFocus=function(){var a,r;(r=(a=s.input)===null||a===void 0?void 0:a.focus)===null||r===void 0||r.call(a,{preventScroll:!0})},s.setBlur=function(){var a,r;(r=(a=s.input)===null||a===void 0?void 0:a.blur)===null||r===void 0||r.call(a),s.cancelFocusInput()},s.deferBlur=function(){requestAnimationFrame(function(){s.setBlur()})},s.setOpen=function(a,r){r===void 0&&(r=!1),s.setState({open:a,preSelection:a&&s.state.open?s.state.preSelection:s.calcInitialState().preSelection,lastPreSelectChange:Sb},function(){a||s.setState(function(i){return{focused:r?i.focused:!1}},function(){!r&&s.deferBlur(),s.setState({inputValue:null})})})},s.inputOk=function(){return ir(s.state.preSelection)},s.isCalendarOpen=function(){return s.props.open===void 0?s.state.open&&!s.props.disabled&&!s.props.readOnly:s.props.open},s.handleFocus=function(a){var r,i,c=s.state.wasHidden,d=c?s.state.open:!0;c&&s.resetHiddenStatus(),s.state.preventFocus||((i=(r=s.props).onFocus)===null||i===void 0||i.call(r,a),d&&!s.props.preventOpenOnFocus&&!s.props.readOnly&&s.setOpen(!0)),s.setState({focused:!0})},s.sendFocusBackToInput=function(){s.preventFocusTimeout&&s.clearPreventFocusTimeout(),s.setState({preventFocus:!0},function(){s.preventFocusTimeout=setTimeout(function(){s.setFocus(),s.setState({preventFocus:!1})})})},s.cancelFocusInput=function(){clearTimeout(s.inputFocusTimeout),s.inputFocusTimeout=void 0},s.deferFocusInput=function(){s.cancelFocusInput(),s.inputFocusTimeout=setTimeout(function(){return s.setFocus()},1)},s.handleDropdownFocus=function(){s.cancelFocusInput()},s.resetInputValue=function(){s.setState(qt(qt({},s.state),{inputValue:null}))},s.handleBlur=function(a){var r,i;(!s.state.open||s.props.withPortal||s.props.showTimeInput)&&((i=(r=s.props).onBlur)===null||i===void 0||i.call(r,a));var c=s.state.inputValue;if(typeof c=="string"&&c.length>0){var d=/[a-zA-Z0-9]/.test(c);!d&&s.props.selected&&s.setSelected(null,void 0,!0)}s.resetInputValue(),s.state.open&&s.props.open===!1&&s.setOpen(!1),s.setState({focused:!1})},s.handleCalendarClickOutside=function(a){var r,i;(i=(r=s.props).onClickOutside)===null||i===void 0||i.call(r,a),!s.props.inline&&!a.defaultPrevented&&s.setOpen(!1),s.props.withPortal&&a.preventDefault()},s.handleChange=function(){for(var a,r,i,c,d,f,h,m,b=[],y=0;y<arguments.length;y++)b[y]=arguments[y];var w=b[0];if(!(s.props.onChangeRaw&&(s.props.onChangeRaw.apply(s,b),!w||typeof w.isDefaultPrevented!="function"||w.isDefaultPrevented()))){s.setState({inputValue:(w==null?void 0:w.target)instanceof HTMLInputElement?w.target.value:null,lastPreSelectChange:wH});var C=s.props,N=C.selectsRange,k=C.startDate,j=C.endDate,S=(a=s.props.dateFormat)!==null&&a!==void 0?a:e.defaultProps.dateFormat,T=(r=s.props.strictParsing)!==null&&r!==void 0?r:e.defaultProps.strictParsing,D=(w==null?void 0:w.target)instanceof HTMLInputElement?w.target.value:"";if(N){var E=s.props.rangeSeparator,I=E.trim(),O=D.split(S.includes(I)?E:I,2).map(function(H){return H.trim()}),_=O[0],M=O[1],R=bo(_??"",S,s.props.locale,T),z=R?bo(M??"",S,s.props.locale,T):null,$=((i=So(k))===null||i===void 0?void 0:i.getTime())!==(R==null?void 0:R.getTime()),W=((c=So(j))===null||c===void 0?void 0:c.getTime())!==(z==null?void 0:z.getTime());if(!$&&!W||R&&ja(R,s.props)||z&&ja(z,s.props))return;R&&s.setState({preSelection:R}),(f=(d=s.props).onChange)===null||f===void 0||f.call(d,[R,z],w)}else{var L=bo(D,S,s.props.locale,T,(h=s.props.selected)!==null&&h!==void 0?h:void 0);if(L||!D)s.setSelected(L,w,!0);else if(!s.props.inline){var F=EU(D,(m=s.state.preSelection)!==null&&m!==void 0?m:void 0);F&&(!s.props.minDate||!ar(F,s.props.minDate))&&(!s.props.maxDate||!$r(F,s.props.maxDate))&&s.setState({preSelection:F})}}}},s.handleSelect=function(a,r,i){var c;if(!s.props.readOnly){var d=s.props,f=d.selectsRange,h=d.startDate,m=d.endDate,b=d.locale,y=d.swapRange,w=(c=s.props.dateFormat)!==null&&c!==void 0?c:e.defaultProps.dateFormat,C=!f||h&&!m&&(y||!yb(a,h));if(s.props.shouldCloseOnSelect&&!s.props.showTimeSelect&&C&&s.sendFocusBackToInput(),s.props.onChangeRaw){var N=Ys(a,{dateFormat:w,locale:b});s.props.onChangeRaw(r,{date:a,formattedDate:N})}s.setSelected(a,r,!1,i),s.props.showDateSelect&&s.setState({isRenderAriaLiveMessage:!0}),!s.props.shouldCloseOnSelect||s.props.showTimeSelect?s.setPreSelection(a):C&&s.setOpen(!1)}},s.setSelected=function(a,r,i,c){var d,f,h=s.props.timeZone,m=a;if(m&&h&&(m=Or(m,h)),s.props.showYearPicker){if(m!==null&&op(Zt(m),s.props))return}else if(s.props.showMonthYearPicker){if(m!==null&&fT(m,s.props))return}else if(m!==null&&ja(m,s.props))return;var b=s.props,y=b.onChange,w=b.selectsRange,C=b.startDate,N=b.endDate,k=b.selectsMultiple,j=b.selectedDates,S=b.minTime,T=b.swapRange;if(!Co(s.props.selected,m)||s.props.allowSameDay||w||k)if(m!==null&&(s.props.selected&&(!i||!s.props.showTimeSelect&&!s.props.showTimeSelectOnly&&!s.props.showTimeInput)&&(m=Lr(m,{hour:Cs(s.props.selected),minute:As(s.props.selected),second:Ei(s.props.selected)})),!i&&(s.props.showTimeSelect||s.props.showTimeSelectOnly)&&S&&(m=Lr(m,{hour:S.getHours(),minute:S.getMinutes(),second:S.getSeconds()})),s.props.inline||s.setState({preSelection:m}),s.props.focusSelectedMonth||s.setState({monthSelectedIn:c})),w){var D=y,E=!C&&!N,I=C&&!N,O=!C&&!!N,_=C&&N;E?D==null||D([m,null],r):I?m===null?D==null||D([null,null],r):yb(m,C)?T?D==null||D([m,C],r):D==null||D([m,null],r):D==null||D([C,m],r):O&&(m&&yb(m,N)?D==null||D([m,N],r):D==null||D([m,null],r)),_&&(D==null||D([m,null],r))}else if(k){var M=y;if(m!==null)if(!(j!=null&&j.length))M==null||M([m],r);else{var R=j.some(function($){return on($,m)});if(R){var z=j.filter(function($){return!on($,m)});M==null||M(z,r)}else M==null||M(rr(rr([],j,!0),[m],!1),r)}}else y==null||y(m,r);i||((f=(d=s.props).onSelect)===null||f===void 0||f.call(d,m,r),s.setState({inputValue:null}))},s.setPreSelection=function(a){if(!s.props.readOnly){var r=ir(s.props.minDate),i=ir(s.props.maxDate),c=!0;if(a){var d=wu(a);if(r&&i)c=vo(a,s.props.minDate,s.props.maxDate);else if(r){var f=wu(s.props.minDate);c=$r(a,f)||Co(d,f)}else if(i){var h=dA(s.props.maxDate);c=ar(a,h)||Co(d,h)}}c&&s.setState({preSelection:a})}},s.toggleCalendar=function(){s.setOpen(!s.state.open)},s.handleTimeChange=function(a,r){var i,c;if(!s.props.selectsMultiple){var d=s.props,f=d.selectsRange,h=d.startDate,m=d.endDate,b=d.onChange,y=d.timeZone;if(f){var w=b;if(r==="start"){if(h){var C=Lr(h,{hour:Cs(a),minute:As(a)});s.setState({preSelection:C}),y&&(C=Or(C,y)),w==null||w([C,m?y?Or(m,y):m:null],void 0)}}else if(r==="end"){if(m){var N=Lr(m,{hour:Cs(a),minute:As(a)});s.setState({preSelection:N}),y&&(N=Or(N,y)),w==null||w([h?y?Or(h,y):h:null,N],void 0)}}else{var k=h&&!m;if(k){var C=Lr(h,{hour:Cs(a),minute:As(a)});s.setState({preSelection:C}),y&&(C=Or(C,y)),w==null||w([C,null],void 0)}else if(h&&m){var N=Lr(m,{hour:Cs(a),minute:As(a)});s.setState({preSelection:N}),y&&(N=Or(N,y)),w==null||w([y?Or(h,y):h,N],void 0)}else{var j=Lr(s.getPreSelection(),{hour:Cs(a),minute:As(a)});s.setState({preSelection:j})}}}else{var S=s.props.selected?s.props.selected:s.getPreSelection(),j=s.props.selected?a:Lr(S,{hour:Cs(a),minute:As(a)});s.setState({preSelection:j}),j&&y&&(j=Or(j,y)),(c=(i=s.props).onChange)===null||c===void 0||c.call(i,j)}s.props.shouldCloseOnSelect&&!s.props.showTimeInput&&(s.sendFocusBackToInput(),s.setOpen(!1)),s.props.showTimeInput&&s.setOpen(!0),(s.props.showTimeSelectOnly||s.props.showTimeSelect)&&s.setState({isRenderAriaLiveMessage:!0}),s.setState({inputValue:null})}},s.onInputClick=function(){var a,r;!s.props.disabled&&!s.props.readOnly&&s.setOpen(!0),(r=(a=s.props).onInputClick)===null||r===void 0||r.call(a)},s.handleTimeOnlyArrowKey=function(a){var r,i,c,d,f=So(s.props.selected)||s.state.preSelection||dn(),h=(r=s.props.timeIntervals)!==null&&r!==void 0?r:30,m=(i=s.props.dateFormat)!==null&&i!==void 0?i:e.defaultProps.dateFormat,b=Array.isArray(m)?m[0]:m,y=wu(f),w=Cs(f)*60+As(f),C=1440-h,N;if(a===lt.ArrowUp){var k=Math.max(0,w-h);N=Gu(y,k)}else{var k=Math.min(C,w+h);N=Gu(y,k)}var j=Bn(N,b||e.defaultProps.dateFormat,s.props.locale);if(s.setState({preSelection:N,inputValue:j}),!(s.props.selectsRange||s.props.selectsMultiple)){var S=s.props.selected?s.props.selected:s.getPreSelection(),T=s.props.selected?N:Lr(S,{hour:Cs(N),minute:As(N)});(d=(c=s.props).onChange)===null||d===void 0||d.call(c,T),(s.props.showTimeSelectOnly||s.props.showTimeSelect)&&s.setState({isRenderAriaLiveMessage:!0}),requestAnimationFrame(function(){s.scrollToTimeOption(N)})}},s.handleTimeOnlyEnterKey=function(a){var r,i,c,d,f=a.target,h=f.value,m=(r=s.props.dateFormat)!==null&&r!==void 0?r:e.defaultProps.dateFormat,b=s.props.timeFormat||"p",y=s.state.preSelection||So(s.props.selected)||dn(),w=bo(h,m,s.props.locale,(i=s.props.strictParsing)!==null&&i!==void 0?i:!1,y),C=y;if(w&&Gs(w))C=w;else{var N=((c=s.calendar)===null||c===void 0?void 0:c.containerRef.current)instanceof Element&&s.calendar.containerRef.current.querySelector(".react-datepicker__time-list-item[tabindex='0']");if(N instanceof HTMLElement){var k=(d=N.textContent)===null||d===void 0?void 0:d.trim();if(k){var j=bo(k,b,s.props.locale,!1,y);j&&Gs(j)&&(C=j)}}}s.handleTimeChange(C),s.setOpen(!1),s.sendFocusBackToInput()},s.scrollToTimeOption=function(a){var r,i;if(!((r=s.calendar)===null||r===void 0)&&r.containerRef.current){for(var c=s.calendar.containerRef.current,d=Array.from(c.querySelectorAll(".react-datepicker__time-list-item")),f=null,h=1/0,m=s.props.timeFormat||"p",b=0,y=d;b<y.length;b++){var w=y[b],C=(i=w.textContent)===null||i===void 0?void 0:i.trim();if(C){var N=bo(C,m,s.props.locale,!1,a);if(N&&Gs(N)){if(mT(N,a)){f=w;break}var k=Math.abs(N.getTime()-a.getTime());k<h&&(h=k,f=w)}}}f&&(d.forEach(function(j){j.setAttribute("tabindex","-1")}),f.setAttribute("tabindex","0"),f.scrollIntoView({behavior:"smooth",block:"center"}))}},s.onInputKeyDown=function(a){var r,i,c,d,f,h;(i=(r=s.props).onKeyDown)===null||i===void 0||i.call(r,a);var m=a.key;if(!s.state.open&&!s.props.inline&&!s.props.preventOpenOnFocus){(m===lt.ArrowDown||m===lt.ArrowUp||m===lt.Enter)&&((c=s.onInputClick)===null||c===void 0||c.call(s));return}if(s.state.open&&s.props.showTimeSelectOnly){if(m===lt.ArrowDown||m===lt.ArrowUp){a.preventDefault(),s.handleTimeOnlyArrowKey(m);return}if(m===lt.Enter){a.preventDefault(),s.handleTimeOnlyEnterKey(a);return}}if(s.state.open){if(m===lt.ArrowDown||m===lt.ArrowUp){a.preventDefault();var b=s.props.showTimeSelectOnly?".react-datepicker__time-list-item[tabindex='0']":s.props.showWeekPicker&&s.props.showWeekNumbers?'.react-datepicker__week-number[tabindex="0"]':s.props.showFullMonthYearPicker||s.props.showMonthYearPicker?'.react-datepicker__month-text[tabindex="0"]':'.react-datepicker__day[tabindex="0"]',y=((d=s.calendar)===null||d===void 0?void 0:d.containerRef.current)instanceof Element&&s.calendar.containerRef.current.querySelector(b);y instanceof HTMLElement&&y.focus({preventScroll:!0});return}var w=dn(s.state.preSelection);m===lt.Enter?(a.preventDefault(),a.target.blur(),s.inputOk()&&s.state.lastPreSelectChange===Sb?(s.handleSelect(w,a),!s.props.shouldCloseOnSelect&&s.setPreSelection(w)):s.setOpen(!1)):m===lt.Escape?(a.preventDefault(),a.target.blur(),s.sendFocusBackToInput(),s.setOpen(!1)):m===lt.Tab&&s.setOpen(!1),s.inputOk()||(h=(f=s.props).onInputError)===null||h===void 0||h.call(f,{code:1,msg:kb})}},s.onPortalKeyDown=function(a){var r=a.key;r===lt.Escape&&(a.preventDefault(),s.setState({preventFocus:!0},function(){s.setOpen(!1),setTimeout(function(){s.setFocus(),s.setState({preventFocus:!1})})}))},s.onDayKeyDown=function(a){var r,i,c,d,f,h,m=s.props,b=m.minDate,y=m.maxDate,w=m.disabledKeyboardNavigation,C=m.showWeekPicker,N=m.shouldCloseOnSelect,k=m.locale,j=m.calendarStartDay,S=m.adjustDateOnChange,T=m.inline;if((i=(r=s.props).onKeyDown)===null||i===void 0||i.call(r,a),!w){var D=a.key,E=a.shiftKey,I=dn(s.state.preSelection),O=function(R,z){var $=z;switch(R){case lt.ArrowRight:$=C?Tp(z,1):Pa(z,1);break;case lt.ArrowLeft:$=C?KC(z):Z3(z);break;case lt.ArrowUp:$=KC(z);break;case lt.ArrowDown:$=Tp(z,1);break;case lt.PageUp:$=E?Ri(z,1):Ao(z,1);break;case lt.PageDown:$=E?Ba(z,1):za(z,1);break;case lt.Home:$=Mi(z,k,j);break;case lt.End:$=LU(z);break}return $},_=function(R,z){for(var $=40,W=R,L=!1,F=0,H=O(R,z);!L;){if(F>=$){H=z;break}b&&H<b&&(W=lt.ArrowRight,H=ja(b,s.props)?O(W,H):b),y&&H>y&&(W=lt.ArrowLeft,H=ja(y,s.props)?O(W,H):y),ja(H,s.props)?((W===lt.PageUp||W===lt.Home)&&(W=lt.ArrowRight),(W===lt.PageDown||W===lt.End)&&(W=lt.ArrowLeft),H=O(W,H)):L=!0,F++}return H};if(D===lt.Enter){a.preventDefault(),s.handleSelect(I,a),!N&&s.setPreSelection(I);return}else if(D===lt.Escape){a.preventDefault(),s.setOpen(!1),s.inputOk()||(d=(c=s.props).onInputError)===null||d===void 0||d.call(c,{code:1,msg:kb});return}var M=null;switch(D){case lt.ArrowLeft:case lt.ArrowRight:case lt.ArrowUp:case lt.ArrowDown:case lt.PageUp:case lt.PageDown:case lt.Home:case lt.End:M=_(D,I);break}if(!M){(h=(f=s.props).onInputError)===null||h===void 0||h.call(f,{code:1,msg:kb});return}a.preventDefault(),s.setState({lastPreSelectChange:Sb}),S&&s.setSelected(M),s.setPreSelection(M),T&&s.setState({shouldFocusDayInline:!0})}},s.onPopperKeyDown=function(a){var r=a.key;r===lt.Escape&&(a.preventDefault(),s.sendFocusBackToInput(),s.setOpen(!1))},s.onClearClick=function(a){a&&a.preventDefault&&a.preventDefault(),s.sendFocusBackToInput();var r=s.props,i=r.selectsRange,c=r.onChange;i?c==null||c([null,null],a):c==null||c(null,a),s.setState({inputValue:null})},s.clear=function(){s.onClearClick()},s.onScroll=function(a){typeof s.props.closeOnScroll=="boolean"&&s.props.closeOnScroll?(a.target===document||a.target===document.documentElement||a.target===document.body)&&s.setOpen(!1):typeof s.props.closeOnScroll=="function"&&s.props.closeOnScroll(a)&&s.setOpen(!1)},s.handleMonthSelectedInChange=function(a){s.setState({monthSelectedIn:a})},s.renderCalendar=function(){var a,r;return!s.props.inline&&!s.isCalendarOpen()?null:Se.createElement(pH,qt({showMonthYearDropdown:void 0,ref:function(i){s.calendar=i}},s.props,s.state,{setOpen:s.setOpen,dateFormat:(a=s.props.dateFormatCalendar)!==null&&a!==void 0?a:e.defaultProps.dateFormatCalendar,onSelect:s.handleSelect,onClickOutside:s.handleCalendarClickOutside,holidays:YU(s.modifyHolidays()),outsideClickIgnoreClass:s.props.outsideClickIgnoreClass,onDropdownFocus:s.handleDropdownFocus,onTimeChange:s.handleTimeChange,className:s.props.calendarClassName,container:s.props.calendarContainer,handleOnKeyDown:s.props.onKeyDown,handleOnDayKeyDown:s.onDayKeyDown,setPreSelection:s.setPreSelection,dropdownMode:(r=s.props.dropdownMode)!==null&&r!==void 0?r:e.defaultProps.dropdownMode,onMonthSelectedInChange:s.handleMonthSelectedInChange}),s.props.children)},s.renderAriaLiveRegion=function(){var a,r=s.props.locale,i=(a=s.props.dateFormat)!==null&&a!==void 0?a:e.defaultProps.dateFormat,c=s.props.showTimeInput||s.props.showTimeSelect,d=c?"PPPPp":"PPPP",f;return s.props.selectsRange?f="Selected start date: ".concat(Ys(s.props.startDate,{dateFormat:d,locale:r}),". ").concat(s.props.endDate?"End date: "+Ys(s.props.endDate,{dateFormat:d,locale:r}):""):s.props.showTimeSelectOnly?f="Selected time: ".concat(Ys(s.props.selected,{dateFormat:i,locale:r})):s.props.showYearPicker?f="Selected year: ".concat(Ys(s.props.selected,{dateFormat:"yyyy",locale:r})):s.props.showMonthYearPicker?f="Selected month: ".concat(Ys(s.props.selected,{dateFormat:"MMMM yyyy",locale:r})):s.props.showQuarterYearPicker?f="Selected quarter: ".concat(Ys(s.props.selected,{dateFormat:"yyyy, QQQ",locale:r})):f="Selected date: ".concat(Ys(s.props.selected,{dateFormat:d,locale:r})),Se.createElement("span",{role:"alert","aria-live":"polite",className:"react-datepicker__aria-live"},f)},s.renderDateInput=function(){var a,r,i,c,d,f,h,m=us(s.props.className,(a={},a[s.props.outsideClickIgnoreClass||e.defaultProps.outsideClickIgnoreClass]=s.state.open,a)),b=s.props.customInput||Se.createElement("input",{type:"text"}),y=s.props.customInputRef||"ref",w={},C=(i=s.props["aria-describedby"])!==null&&i!==void 0?i:s.props.ariaDescribedBy,N=(c=s.props["aria-invalid"])!==null&&c!==void 0?c:s.props.ariaInvalid,k=(d=s.props["aria-label"])!==null&&d!==void 0?d:s.props.ariaLabel,j=(f=s.props["aria-labelledby"])!==null&&f!==void 0?f:s.props.ariaLabelledBy,S=(h=s.props["aria-required"])!==null&&h!==void 0?h:s.props.ariaRequired;return C!=null&&(w["aria-describedby"]=C),N!=null&&(w["aria-invalid"]=N),k!=null&&(w["aria-label"]=k),j!=null&&(w["aria-labelledby"]=j),S!=null&&(w["aria-required"]=S),x.cloneElement(b,qt((r={},r[y]=function(T){s.input=T},r.value=s.getInputValue(),r.onBlur=s.handleBlur,r.onChange=s.handleChange,r.onClick=s.onInputClick,r.onFocus=s.handleFocus,r.onKeyDown=s.onInputKeyDown,r.id=s.props.id,r.name=s.props.name,r.form=s.props.form,r.autoFocus=s.props.autoFocus,r.placeholder=s.props.placeholderText,r.disabled=s.props.disabled,r.autoComplete=s.props.autoComplete,r.className=us(b.props.className,m),r.title=s.props.title,r.readOnly=s.props.readOnly,r.required=s.props.required,r.tabIndex=s.props.tabIndex,r),w))},s.renderClearButton=function(){var a=s.props,r=a.isClearable,i=a.disabled,c=a.selected,d=a.startDate,f=a.endDate,h=a.clearButtonTitle,m=a.clearButtonClassName,b=m===void 0?"":m,y=a.ariaLabelClose,w=y===void 0?"Close":y,C=a.selectedDates,N=a.readOnly;return r&&!N&&(c!=null||d!=null||f!=null||C!=null&&C.length)?Se.createElement("button",{type:"button",className:us("react-datepicker__close-icon",b,{"react-datepicker__close-icon--disabled":i}),disabled:i,"aria-label":w,onClick:s.onClearClick,title:h,tabIndex:-1}):null},s.state=s.calcInitialState(),s.preventFocusTimeout=void 0,s}return Object.defineProperty(e,"defaultProps",{get:function(){return{allowSameDay:!1,dateFormat:"MM/dd/yyyy",dateFormatCalendar:"LLLL yyyy",disabled:!1,disabledKeyboardNavigation:!1,dropdownMode:"scroll",preventOpenOnFocus:!1,monthsShown:1,outsideClickIgnoreClass:bT,readOnly:!1,rangeSeparator:uT,withPortal:!1,selectsDisabledDaysInRange:!1,shouldCloseOnSelect:!0,showTimeSelect:!1,showTimeInput:!1,showPreviousMonths:!1,showMonthYearPicker:!1,showFullMonthYearPicker:!1,showTwoColumnMonthYearPicker:!1,showFourColumnMonthYearPicker:!1,showYearPicker:!1,showQuarterYearPicker:!1,showWeekPicker:!1,strictParsing:!1,swapRange:!1,timeIntervals:30,timeCaption:"Time",previousMonthAriaLabel:"Previous Month",previousMonthButtonLabel:"Previous Month",nextMonthAriaLabel:"Next Month",nextMonthButtonLabel:"Next Month",previousYearAriaLabel:"Previous Year",previousYearButtonLabel:"Previous Year",nextYearAriaLabel:"Next Year",nextYearButtonLabel:"Next Year",timeInputLabel:"Time",enableTabLoop:!0,yearItemNumber:id,focusSelectedMonth:!1,showPopperArrow:!0,excludeScrollbar:!0,customTimeInput:null,calendarStartDay:void 0,toggleCalendarOnIconClick:!1,usePointerEvent:!1}},enumerable:!1,configurable:!0}),e.prototype.componentDidMount=function(){window.addEventListener("scroll",this.onScroll,!0),document.addEventListener("visibilitychange",this.setHiddenStateOnVisibilityHidden)},e.prototype.componentDidUpdate=function(n,s){var a,r,i,c;this.props.selectsRange&&jA(n.startDate,this.props.startDate)?this.setPreSelection(this.props.startDate):jA(n.selected,this.props.selected)&&this.setPreSelection(this.props.selected),this.state.monthSelectedIn!==void 0&&n.monthsShown!==this.props.monthsShown&&this.setState({monthSelectedIn:0}),this.props.selectsRange&&s.open===!1&&this.state.open===!0&&this.state.monthSelectedIn!==0&&this.setState({monthSelectedIn:0}),n.highlightDates!==this.props.highlightDates&&this.setState({highlightDates:yA(this.props.highlightDates)}),!s.focused&&!Co(n.selected,this.props.selected)&&this.setState({inputValue:null}),s.open!==this.state.open&&(s.open===!1&&this.state.open===!0&&((r=(a=this.props).onCalendarOpen)===null||r===void 0||r.call(a)),s.open===!0&&this.state.open===!1&&((c=(i=this.props).onCalendarClose)===null||c===void 0||c.call(i)))},e.prototype.componentWillUnmount=function(){this.clearPreventFocusTimeout(),window.removeEventListener("scroll",this.onScroll,!0),document.removeEventListener("visibilitychange",this.setHiddenStateOnVisibilityHidden)},e.prototype.renderInputContainer=function(){var n=this.props,s=n.showIcon,a=n.icon,r=n.calendarIconClassname,i=n.calendarIconClassName,c=n.toggleCalendarOnIconClick,d=this.state.open;return r&&console.warn("calendarIconClassname props is deprecated. should use calendarIconClassName props."),Se.createElement("div",{className:"react-datepicker__input-container".concat(s?" react-datepicker__view-calendar-icon":"")},s&&Se.createElement(hH,qt({icon:a,className:us(i,!i&&r,d&&"react-datepicker-ignore-onclickoutside")},c?{onClick:this.toggleCalendar}:null)),this.state.isRenderAriaLiveMessage&&this.renderAriaLiveRegion(),this.renderDateInput(),this.renderClearButton())},e.prototype.render=function(){var n=this.renderCalendar();if(this.props.inline)return n;if(this.props.withPortal){var s=this.state.open?Se.createElement(yT,{enableTabLoop:this.props.enableTabLoop},Se.createElement("div",{className:"react-datepicker__portal",tabIndex:-1,onKeyDown:this.onPortalKeyDown},n)):null;return this.state.open&&this.props.portalId&&(s=Se.createElement(xT,qt({portalId:this.props.portalId},this.props),s)),Se.createElement(Se.Fragment,null,this.renderInputContainer(),s)}return Se.createElement(yH,qt({},this.props,{className:this.props.popperClassName,hidePopper:!this.isCalendarOpen(),targetComponent:this.renderInputContainer(),popperComponent:n,popperOnKeyDown:this.onPopperKeyDown,showArrow:this.props.showPopperArrow,monthHeaderPosition:this.props.monthHeaderPosition}))},e})(x.Component),wH="input",Sb="navigate";const kH=[25,50,100,250,500,1e3],SH=250,bu=t=>String(t).padStart(2,"0"),Yf=t=>t?/(datetime|timestamp|timestamptz|datetime2|smalldatetime)/i.test(t):!1,NA=t=>`${t.getFullYear()}-${bu(t.getMonth()+1)}-${bu(t.getDate())} ${bu(t.getHours())}:${bu(t.getMinutes())}:${bu(t.getSeconds())}`,TA=t=>{if(t==null)return null;if(t instanceof Date)return t;const e=String(t).trim();if(!e)return null;if(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(:\d{2})?(\.\d+)?$/.test(e)){const s=e.replace(" ","T"),a=new Date(s);return Number.isNaN(a.getTime())?null:a}if(/^\d{4}-\d{2}-\d{2}T/.test(e)){const s=new Date(e.replace(/Z$/,""));return Number.isNaN(s.getTime())?null:s}const n=new Date(e);return Number.isNaN(n.getTime())?null:n},CH=t=>t===null?"NULL":t===void 0?"undefined":typeof t=="object"?JSON.stringify(t,null,2):String(t),AH=t=>t==null?"":typeof t=="object"?JSON.stringify(t):String(t),jH=t=>{const e=t.match(/FROM\s+(?:`?[\w]+`?\.)?`?([\w]+)`?(?:\s+(?:AS\s+)?\w+)?(?=\s|;|$)/i);return e!=null&&e[1]?e[1]:null},Cb=t=>!t||!t.columns?[]:t.columns.filter(e=>e.primaryKey).map(e=>e.name),NH=(t,e,n,s,a,r,i=!0)=>{const c=b=>t==="mysql"?`\`${b}\``:t==="postgres"?`"${b}"`:b,d=b=>b===null?"NULL":typeof b=="boolean"?b?"1":"0":typeof b=="number"?String(b):typeof b=="object"?`'${JSON.stringify(b).replace(/'/g,"''")}'`:`'${String(b).replace(/'/g,"''")}'`,f=`${c(n)} = ${d(r)}`,h=[];for(const[b,y]of Object.entries(s))h.push(`${c(b)} = ${d(y)}`);i&&(a===null?h.push(`${c(n)} IS NULL`):typeof a=="object"||h.push(`${c(n)} = ${d(a)}`));const m=h.join(" AND ");return`UPDATE ${c(e)} SET ${f} WHERE ${m}`},TH=({result:t,buildingId:e,building:n})=>{var ae,ke;const{t:s}=dt(["terminal"]),a=Gx(e),[r,i]=x.useState(0),[c,d]=x.useState(SH),[f,h]=x.useState(null),[m,b]=x.useState("asc"),[y,w]=x.useState(null),[C,N]=x.useState(!1),[k,j]=x.useState({}),[S,T]=x.useState(null),[D,E]=x.useState(null),[I,O]=x.useState(null),[_,M]=x.useState(!1),[R,z]=x.useState(null),[$,W]=x.useState(null),[L,F]=x.useState(new Map),[H,V]=x.useState(null),[G,B]=x.useState(null),K=x.useRef(null),se=x.useRef(null),q=x.useRef(null),be=x.useRef(!1),Ce=t.status==="error",Z=!t.rows||t.rows.length===0;x.useEffect(()=>{var he,Oe;const J=jH(t.query||"");if(E(J),M(!1),O(null),F(new Map),J&&a.activeConnectionId&&a.activeDatabase){const $e=`${a.activeConnectionId}:${a.activeDatabase}:${J}`,xe=(Oe=(he=a.tableSchemas)==null?void 0:he.get)==null?void 0:Oe.call(he,$e);if(xe){O(xe);const Pe=Cb(xe);M(Pe.length>0)}else U.getTableSchema(e,a.activeConnectionId,a.activeDatabase,J)}},[t.query,t.rows,e,a.activeConnectionId,a.activeDatabase]),x.useEffect(()=>{var J,he;if(D&&a.activeConnectionId&&a.activeDatabase){const Oe=`${a.activeConnectionId}:${a.activeDatabase}:${D}`,$e=(he=(J=a.tableSchemas)==null?void 0:J.get)==null?void 0:he.call(J,Oe);if($e){O(Pe=>Pe===$e?Pe:$e);const xe=Cb($e);M(xe.length>0)}}},[a.tableSchemas,D,a.activeConnectionId,a.activeDatabase]);const ie=x.useMemo(()=>!f||!t.rows?t.rows:[...t.rows].sort((J,he)=>{const Oe=J[f],$e=he[f];if(Oe===null&&$e===null)return 0;if(Oe===null)return m==="asc"?-1:1;if($e===null)return m==="asc"?1:-1;if(typeof Oe=="number"&&typeof $e=="number")return m==="asc"?Oe-$e:$e-Oe;const xe=String(Oe),Pe=String($e);return m==="asc"?xe.localeCompare(Pe):Pe.localeCompare(xe)}),[t.rows,f,m]),me=x.useMemo(()=>{if(!ie)return[];const J=r*c;return ie.slice(J,J+c)},[ie,r,c]),Ee=Math.ceil(((ie==null?void 0:ie.length)??0)/c),Te=((ae=t.fields)==null?void 0:ae.map(J=>J.name))??Object.keys(((ke=t.rows)==null?void 0:ke[0])||{}),Ve=x.useMemo(()=>{const J=new Map;return(t.fields??[]).forEach(he=>{he!=null&&he.name&&J.set(he.name,String(he.type??""))}),J},[t.fields]),We=x.useMemo(()=>Cb(I),[I]),ee=x.useCallback((J,he)=>{const Oe=Ve.get(J);if(Yf(Oe)){const $e=TA(he);return $e?NA($e):""}return AH(he)},[Ve]),ne=x.useMemo(()=>_?"Editable":!a.activeConnectionId||!a.activeDatabase?"Read-only: no active connection or database":D?I?We.length===0?"Read-only: table has no primary key":"Read-only: editing unavailable":"Read-only: loading table schema":"Read-only: query is not a single-table SELECT",[_,a.activeConnectionId,a.activeDatabase,D,I,We.length]),Ne=x.useCallback(J=>{if(be.current){be.current=!1;return}f===J?b(he=>he==="asc"?"desc":"asc"):(h(J),b("asc"))},[f]),ze=x.useCallback((J,he,Oe,$e)=>{!_||S||G||T({rowIndex:Oe,rowKey:$e,columnName:J,originalValue:he,currentValue:ee(J,he),isUpdating:!1})},[_,S,G,ee]),st=x.useCallback((J,he)=>{w({column:J,value:he})},[]),pe=x.useCallback(J=>{var tn,Ae;if(!D||!I||!a.activeConnectionId||!a.activeDatabase)return;const{rowIndex:he,columnName:Oe,originalValue:$e,currentValue:xe}=J,Pe=String(xe??"");if(xe!==null&&Pe===ee(Oe,$e)){T(null);return}const te=r*c+he,ge=ie==null?void 0:ie[te];if(!ge)return;const ve=We;if(ve.length===0){T(Le=>Le?{...Le,error:"No primary key found"}:null);return}const Fe={};for(const Le of ve)Fe[Le]=ge[Le];let Ke=Pe;const at=Ve.get(Oe);if(xe===null)Ke=null;else if(Yf(at))Ke=Pe.trim()===""?null:Pe.trim();else if(typeof $e=="number")if(Pe.trim()==="")Ke=null;else{const Le=Number(Pe);if(Number.isNaN(Le)){T(Ye=>Ye?{...Ye,isUpdating:!1,error:"Invalid number value"}:null);return}Ke=Le}else if(typeof $e=="boolean"){const Le=Pe.trim().toLowerCase();if(Le==="true"||Le==="1")Ke=!0;else if(Le==="false"||Le==="0")Ke=!1;else{T(Ye=>Ye?{...Ye,isUpdating:!1,error:"Invalid boolean value"}:null);return}}else if($e!==null&&typeof $e=="object")try{Ke=JSON.parse(Pe)}catch{T(Le=>Le?{...Le,isUpdating:!1,error:"Invalid JSON value"}:null);return}T(Le=>Le?{...Le,isUpdating:!0}:null);const ft=(tn=n.database)==null?void 0:tn.connections.find(Le=>Le.id===a.activeConnectionId),wt=(ft==null?void 0:ft.engine)||"mysql",it=NH(wt,D,Oe,Fe,$e,Ke,!Yf(at));W(it);const gt=JSON.stringify(Fe),ht=((Ae=t.query)==null?void 0:Ae.trim())||"",Gt=`${Date.now()}-${Math.random().toString(36).slice(2,10)}`;B({requestId:Gt,query:it,rowKey:gt,columnName:Oe,parsedValue:Ke,startedAt:Date.now(),originalQuery:ht}),U.executeSilentQuery(e,a.activeConnectionId,a.activeDatabase,it,Gt)},[D,I,r,c,ie,We,e,a.activeConnectionId,a.activeDatabase,t.query,ee,Ve]);x.useEffect(()=>{const J=a.lastSilentQueryResult;if(!(!G||!J)&&!(J.requestId&&J.requestId!==G.requestId)&&!(J.timestamp<G.startedAt)){if(!J.success){z({message:J.error||"Update failed on backend",type:"error"}),setTimeout(()=>z(null),5e3),T(he=>he&&{...he,isUpdating:!1,error:J.error||"Update failed on backend"}),B(null);return}if(J.affectedRows===0){z({message:"No rows were updated",type:"error"}),setTimeout(()=>z(null),5e3),T(he=>he&&{...he,isUpdating:!1,error:"No rows were updated"}),B(null);return}F(he=>{const Oe=new Map(he),$e=Oe.get(G.rowKey)||{};return $e[G.columnName]=G.parsedValue,Oe.set(G.rowKey,$e),Oe}),T(null),z({message:"Row updated successfully",type:"success"}),setTimeout(()=>z(null),3e3),G.originalQuery&&a.activeConnectionId&&a.activeDatabase&&setTimeout(()=>{U.executeQuery(e,a.activeConnectionId,a.activeDatabase,G.originalQuery)},200),B(null)}},[G,a.lastSilentQueryResult,a.activeConnectionId,a.activeDatabase,e]),x.useEffect(()=>{if(!G)return;const J=window.setTimeout(()=>{z({message:"Update timed out waiting for backend",type:"error"}),setTimeout(()=>z(null),5e3),T(he=>he&&{...he,isUpdating:!1,error:"Update timed out waiting for backend"}),B(null)},1e4);return()=>window.clearTimeout(J)},[G]);const Be=x.useCallback(()=>{S&&pe(S)},[S,pe]),oe=x.useCallback((J,he,Oe,$e,xe)=>{J.preventDefault(),J.stopPropagation(),V({position:{x:J.clientX,y:J.clientY},rowIndex:$e,rowKey:xe,columnName:he,value:Oe})},[S,D,I,r,c,ie,We,e,a.activeConnectionId,a.activeDatabase]),de=x.useMemo(()=>{if(!H)return[];const J=!_||!!S||!!G||!D||!I||!a.activeConnectionId||!a.activeDatabase;return[{id:"editability",label:_?"Cell actions":ne,icon:_?"▣":"ℹ",disabled:!0,onClick:()=>{}},{id:"divider-1",label:"",divider:!0,onClick:()=>{}},{id:"edit-cell",label:"Edit Cell",icon:"✏️",disabled:J,onClick:()=>{T({rowIndex:H.rowIndex,rowKey:H.rowKey,columnName:H.columnName,originalValue:H.value,currentValue:ee(H.columnName,H.value),isUpdating:!1})}},{id:"set-null",label:"Set NULL",icon:"∅",disabled:J||H.value===null,onClick:()=>{pe({rowIndex:H.rowIndex,rowKey:H.rowKey,columnName:H.columnName,originalValue:H.value,currentValue:null,isUpdating:!1})}}]},[H,_,S,G,D,I,a.activeConnectionId,a.activeDatabase,ne,pe,ee]),He=x.useCallback(J=>{J.key==="Enter"?(J.preventDefault(),Be()):J.key==="Escape"&&(J.preventDefault(),J.stopPropagation(),T(null))},[Be]),et=x.useCallback((J,he)=>{J.preventDefault(),J.stopPropagation();const Oe=J.target.closest("th");if(!Oe)return;const $e=Oe.getBoundingClientRect().width;q.current={column:he,startX:J.clientX,startWidth:$e};const xe=te=>{if(!q.current)return;const ge=te.clientX-q.current.startX,ve=Math.max(50,q.current.startWidth+ge);j(Fe=>({...Fe,[q.current.column]:ve}))},Pe=()=>{q.current=null,be.current=!0,document.removeEventListener("mousemove",xe),document.removeEventListener("mouseup",Pe),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",xe),document.addEventListener("mouseup",Pe),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]);x.useEffect(()=>{if(!y)return;const J=Oe=>{Oe.key==="Escape"&&(Oe.stopPropagation(),w(null))},he=Oe=>{K.current&&!K.current.contains(Oe.target)&&w(null)};return document.addEventListener("keydown",J),document.addEventListener("mousedown",he),()=>{document.removeEventListener("keydown",J),document.removeEventListener("mousedown",he)}},[y]);const ct=S?`${S.rowKey}:${S.columnName}`:null;x.useEffect(()=>{se.current&&ct&&(se.current.focus(),se.current.select())},[ct]);const fe=x.useCallback(async()=>{var xe;if(!t.rows||t.rows.length===0)return;const J=((xe=t.fields)==null?void 0:xe.map(Pe=>Pe.name))??Object.keys(t.rows[0]||{}),he=ie??t.rows,Oe=["<table><thead><tr>"];J.forEach(Pe=>Oe.push(`<th>${Pe}</th>`)),Oe.push("</tr></thead><tbody>"),he.forEach(Pe=>{Oe.push("<tr>"),J.forEach(te=>{const ge=Pe[te];Oe.push(`<td>${ge===null?"NULL":typeof ge=="object"?JSON.stringify(ge):String(ge)}</td>`)}),Oe.push("</tr>")}),Oe.push("</tbody></table>");const $e=[J.join(" ")];he.forEach(Pe=>{$e.push(J.map(te=>{const ge=Pe[te];return ge===null?"NULL":typeof ge=="object"?JSON.stringify(ge):String(ge)}).join(" "))});try{const Pe=new Blob([Oe.join("")],{type:"text/html"}),te=new Blob([$e.join(`
110
- `)],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/html":Pe,"text/plain":te})]),N(!0),setTimeout(()=>N(!1),2e3)}catch{await navigator.clipboard.writeText($e.join(`
111
- `)),N(!0),setTimeout(()=>N(!1),2e3)}},[t,ie]),X=J=>{if(J===null)return o.jsx("span",{className:"results-table__null",children:"NULL"});if(J===void 0)return o.jsx("span",{className:"results-table__null",children:"undefined"});if(typeof J=="boolean")return o.jsx("span",{className:`results-table__bool results-table__bool--${J}`,children:String(J)});if(typeof J=="number")return o.jsx("span",{className:"results-table__number",children:J.toLocaleString()});if(J instanceof Date)return o.jsx("span",{className:"results-table__date",children:J.toISOString()});if(typeof J=="object")return o.jsx("span",{className:"results-table__json",title:JSON.stringify(J,null,2),children:JSON.stringify(J)});const he=String(J);return he.length>100?o.jsxs("span",{className:"results-table__long",title:he,children:[he.substring(0,100),"..."]}):he};return Ce?o.jsx("div",{className:"results-table results-table--error",children:o.jsxs("div",{className:"results-table__error",children:[o.jsxs("div",{className:"results-table__error-header",children:[o.jsx("span",{className:"results-table__error-icon",children:"✗"}),s("terminal:database.queryError")]}),o.jsx("div",{className:"results-table__error-message",children:t.error}),t.errorCode&&o.jsx("div",{className:"results-table__error-code",children:s("terminal:database.errorCode",{code:t.errorCode})}),o.jsx("div",{className:"results-table__error-query",children:o.jsx("code",{children:t.query})})]})}):Z?o.jsx("div",{className:"results-table results-table--success",children:o.jsxs("div",{className:"results-table__success",children:[o.jsx("span",{className:"results-table__success-icon",children:"✓"}),s("terminal:database.querySuccess"),t.affectedRows!==void 0&&o.jsx("span",{className:"results-table__affected",children:s("terminal:database.rowsAffected",{count:t.affectedRows})}),o.jsxs("span",{className:"results-table__duration",children:[t.duration,"ms"]})]})}):o.jsxs("div",{className:"results-table",children:[o.jsxs("div",{className:"results-table__status-bar",children:[o.jsxs("div",{className:"results-table__status-info",children:[o.jsx("span",{className:"results-table__row-count",children:s("terminal:database.rowCount",{count:t.rowCount})}),o.jsxs("span",{className:"results-table__duration",children:[t.duration,"ms"]}),o.jsx("span",{className:`results-table__edit-status ${_?"results-table__edit-status--editable":"results-table__edit-status--readonly"}`,title:ne,children:ne}),o.jsx("button",{className:`results-table__copy-btn ${C?"results-table__copy-btn--success":""}`,onClick:fe,title:s("terminal:database.copyAllResults"),children:s(C?"terminal:database.copied":"terminal:database.copyAll")})]}),o.jsxs("div",{className:"results-table__pagination",children:[o.jsx("select",{className:"results-table__page-size",value:c,onChange:J=>{d(Number(J.target.value)),i(0)},children:kH.map(J=>o.jsx("option",{value:J,children:s("terminal:database.rowsPerPage",{count:J})},J))}),o.jsx("button",{className:"results-table__page-btn",disabled:r===0,onClick:()=>i(0),title:s("terminal:database.firstPage"),children:"«"}),o.jsx("button",{className:"results-table__page-btn",disabled:r===0,onClick:()=>i(J=>J-1),title:s("terminal:database.previousPage"),children:"‹"}),o.jsx("span",{className:"results-table__page-info",children:s("terminal:database.pageInfo",{current:r+1,total:Ee})}),o.jsx("button",{className:"results-table__page-btn",disabled:r>=Ee-1,onClick:()=>i(J=>J+1),title:s("terminal:database.nextPage"),children:"›"}),o.jsx("button",{className:"results-table__page-btn",disabled:r>=Ee-1,onClick:()=>i(Ee-1),title:s("terminal:database.lastPage"),children:"»"})]})]}),o.jsx("div",{className:"results-table__wrapper",children:o.jsxs("table",{className:`results-table__table ${Object.keys(k).length>0?"results-table__table--resized":""}`,children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{className:"results-table__row-num",children:"#"}),Te.map(J=>{var $e;const he=($e=t.fields)==null?void 0:$e.find(xe=>xe.name===J),Oe=f===J;return o.jsxs("th",{className:`results-table__header ${Oe?"results-table__header--sorted":""}`,onClick:()=>Ne(J),title:he!=null&&he.type?`Type: ${he.type}`:void 0,style:k[J]?{width:k[J],minWidth:k[J],maxWidth:k[J]}:void 0,children:[o.jsx("span",{className:"results-table__header-name",children:J}),Oe&&o.jsx("span",{className:"results-table__sort-indicator",children:m==="asc"?"▲":"▼"}),o.jsx("span",{className:"results-table__resize-handle",onMouseDown:xe=>et(xe,J)})]},J)})]})}),o.jsx("tbody",{children:me.map((J,he)=>o.jsxs("tr",{className:"results-table__row",children:[o.jsx("td",{className:"results-table__row-num",children:r*c+he+1}),Te.map(Oe=>{const $e=JSON.stringify(Object.fromEntries(We.map(ge=>[ge,J[ge]]))),xe=(S==null?void 0:S.rowKey)===$e&&(S==null?void 0:S.columnName)===Oe,Pe=L.get($e),te=Pe?Pe[Oe]:J[Oe];return o.jsx("td",{className:`results-table__cell ${xe?"results-table__cell--editing":""} ${_?"results-table__cell--editable":""} ${Pe&&Pe[Oe]!==J[Oe]?"results-table__cell--updated":""}`,onClick:()=>ze(Oe,te,he,$e),onDoubleClick:()=>st(Oe,te),onContextMenu:ge=>oe(ge,Oe,te,he,$e),children:xe?o.jsxs("div",{className:"results-table__cell-input-wrapper",children:[Yf(Ve.get(S.columnName))?o.jsx(vH,{selected:TA(S.currentValue),onChange:ge=>{const ve=Array.isArray(ge)?ge[0]:ge;T(Fe=>Fe?{...Fe,currentValue:ve?NA(ve):""}:null)},onCalendarClose:Be,showTimeSelect:!0,showTimeInput:!0,timeIntervals:1,timeFormat:"HH:mm:ss",dateFormat:"yyyy-MM-dd HH:mm:ss",className:"results-table__cell-input results-table__cell-input--datetime",disabled:S.isUpdating,placeholderText:"Select date and time",autoFocus:!0}):o.jsx("input",{ref:se,type:"text",className:"results-table__cell-input",value:String(S.currentValue??""),onChange:ge=>T(ve=>ve?{...ve,currentValue:ge.target.value}:null),onBlur:Be,onKeyDown:He,disabled:S.isUpdating,autoFocus:!0}),S.isUpdating&&o.jsx("span",{className:"results-table__cell-feedback results-table__cell-feedback--loading",children:"⏳"}),S.error&&o.jsx("button",{type:"button",className:"results-table__cell-feedback results-table__cell-feedback--error results-table__cell-feedback-btn",title:`${S.error}. Click to cancel editing.`,onMouseDown:ge=>{ge.preventDefault(),ge.stopPropagation()},onClick:ge=>{ge.preventDefault(),ge.stopPropagation(),T(null)},children:"✕"})]}):X(te)},Oe)})]},he))})]})}),y&&o.jsx("div",{className:"results-table__detail-backdrop",children:o.jsxs("div",{className:"results-table__detail",ref:K,children:[o.jsxs("div",{className:"results-table__detail-header",children:[o.jsx("span",{className:"results-table__detail-column",children:y.column}),o.jsxs("div",{className:"results-table__detail-actions",children:[_&&o.jsx("button",{className:"results-table__detail-edit-btn",onClick:()=>{w(null);const J=me.find(he=>Te.some(Oe=>he[Oe]===y.value&&Oe===y.column));if(J){const he=me.indexOf(J),Oe=JSON.stringify(Object.fromEntries(We.map($e=>[$e,J[$e]])));T({rowIndex:he,rowKey:Oe,columnName:y.column,originalValue:y.value,currentValue:ee(y.column,y.value),isUpdating:!1})}},title:"Edit this cell",children:"✏️"}),o.jsx("button",{className:"results-table__detail-close",onClick:()=>w(null),children:"✕"})]})]}),o.jsx("textarea",{className:"results-table__detail-textarea",value:CH(y.value),readOnly:!0,onFocus:J=>J.target.select()})]})}),R&&o.jsx("div",{className:`results-table__toast results-table__toast--${R.type}`,children:R.message}),$&&o.jsxs("div",{className:"results-table__query-log",children:[o.jsx("div",{className:"results-table__query-log-label",children:"Executed Query:"}),o.jsx("code",{className:"results-table__query-log-code",children:$})]}),o.jsx(Do,{isOpen:H!==null,position:(H==null?void 0:H.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:de,onClose:()=>V(null)})]})};function jy(t){const e=[];let n=!1,s=!1,a=!1,r=!1,i=0;for(let d=0;d<t.length;d++){const f=t[d],h=t[d+1];if(a){f===`
112
- `&&(a=!1);continue}if(r){f==="*"&&h==="/"&&(r=!1,d++);continue}if(n){if(f==="'"&&h==="'"){d++;continue}f==="'"&&(n=!1);continue}if(s){if(f==='"'&&h==='"'){d++;continue}f==='"'&&(s=!1);continue}if(f==="-"&&h==="-"){a=!0,d++;continue}if(f==="/"&&h==="*"){r=!0,d++;continue}if(f==="'"){n=!0;continue}if(f==='"'){s=!0;continue}if(f===";"){const m=t.slice(i,d).trim();m&&e.push({sql:m,start:i,end:d}),i=d+1}}const c=t.slice(i).trim();return c&&e.push({sql:c,start:i,end:t.length}),e}function _H(t,e){const n=jy(t);if(n.length===0)return null;for(const s of n)if(e>=s.start&&e<=s.end)return s.sql;return n[n.length-1].sql}const oV=({query:t,onChange:e,onExecute:n,isExecuting:s,disabled:a,autoFocus:r=!0})=>{const{t:i}=dt(["terminal"]),c=x.useRef(null),d=x.useRef(null),f=x.useRef(!1),h="query-editor-height",m=80,b=800,[y,w]=x.useState(()=>{try{const I=localStorage.getItem(h);if(I){const O=Number(I);if(O>=m&&O<=b)return O}}catch{}return 150}),C=x.useCallback(I=>{try{localStorage.setItem(h,String(I))}catch{}},[]),N=x.useCallback(I=>{I.preventDefault(),f.current=!0;const O=I.clientY,_=y,M=z=>{const $=z.clientY-O,W=Math.max(m,Math.min(b,_+$));w(W)},R=()=>{var $;f.current=!1,document.removeEventListener("mousemove",M),document.removeEventListener("mouseup",R),document.body.style.cursor="",document.body.style.userSelect="";const z=($=c.current)==null?void 0:$.parentElement;z&&C(z.getBoundingClientRect().height)};document.addEventListener("mousemove",M),document.addEventListener("mouseup",R),document.body.style.cursor="row-resize",document.body.style.userSelect="none"},[y,C]);x.useEffect(()=>{if(r&&!a&&c.current){const I=setTimeout(()=>{var O;(O=c.current)==null||O.focus()},100);return()=>clearTimeout(I)}},[r,a]);const k=x.useCallback(I=>{const O=I.currentTarget;d.current&&(d.current.scrollLeft=O.scrollLeft,d.current.scrollTop=O.scrollTop)},[]),j=x.useMemo(()=>jy(t).length>1,[t]),S=x.useCallback(I=>{if((I.ctrlKey||I.metaKey)&&I.shiftKey&&I.key==="Enter"){I.preventDefault(),!a&&!s&&n("all");return}if((I.ctrlKey||I.metaKey)&&I.key==="Enter"&&(I.preventDefault(),!a&&!s&&n("cursor")),I.key==="Tab"){I.preventDefault();const O=I.currentTarget,_=O.selectionStart,M=O.selectionEnd,R=t.substring(0,_)+" "+t.substring(M);e(R),setTimeout(()=>{O.selectionStart=O.selectionEnd=_+2},0)}},[t,e,n,a,s]),T=x.useMemo(()=>{if(!t)return"";try{return da.highlight(t,da.languages.sql,"sql")}catch{return t}},[t]),D=x.useMemo(()=>t.split(`
113
- `).map((O,_)=>_+1),[t]),E=x.useCallback(()=>{var I;return((I=c.current)==null?void 0:I.selectionStart)??0},[]);return o.jsxs("div",{className:"query-editor",children:[o.jsxs("div",{className:"query-editor__toolbar",children:[o.jsxs("div",{className:"query-editor__buttons",children:[o.jsx("button",{className:"query-editor__execute",onClick:()=>n("cursor"),disabled:a||s||!t.trim(),title:i("terminal:database.executeShortcut"),children:s?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"query-editor__spinner"}),i("common:status.running")]}):o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"query-editor__play-icon",children:"▶"}),i(j?"terminal:database.runAtCursor":"terminal:database.runQuery")]})}),j&&o.jsxs("button",{className:"query-editor__execute-cursor",onClick:()=>n("all"),disabled:a||s||!t.trim(),title:i("terminal:database.executeCursorShortcut"),children:[o.jsx("span",{className:"query-editor__cursor-icon",children:"▶▶"}),i("terminal:database.runAll")]})]}),o.jsx("div",{className:"query-editor__hint",children:i(j?"terminal:database.pressCtrlEnterMulti":"terminal:database.pressCtrlEnter")})]}),o.jsxs("div",{className:"query-editor__input-wrapper",children:[o.jsx("div",{className:"query-editor__line-numbers",children:D.map(I=>o.jsx("span",{children:I},I))}),o.jsxs("div",{className:"query-editor__editor",style:{height:y},children:[o.jsx("pre",{ref:d,className:"query-editor__highlight","aria-hidden":"true",dangerouslySetInnerHTML:{__html:T+`
114
- `}}),o.jsx("textarea",{ref:c,className:"query-editor__textarea",value:t,onChange:I=>e(I.target.value),onKeyDown:S,onScroll:k,placeholder:i(a?"terminal:database.selectDbPlaceholder":"terminal:database.enterQueryPlaceholder"),disabled:a,spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off","data-cursor-pos":E()})]})]}),o.jsx("div",{className:"query-editor__resize-handle",onMouseDown:N})]})},_A=t=>`db-panel-${t}`,EH=({building:t})=>{var O,_,M,R,z,$;const e=Gx(t.id),n=oL(t.id),s=lL(t.id),a=((O=t.database)==null?void 0:O.connections)??[],[r,i]=x.useState(""),[c,d]=x.useState(!1),f=x.useRef(null),h=x.useRef(null),m=x.useMemo(()=>{if(!r)return"";try{return da.highlight(r,da.languages.sql,"sql")}catch{return r}},[r]),b=x.useCallback(()=>{h.current&&f.current&&(h.current.scrollLeft=f.current.scrollLeft,h.current.scrollTop=f.current.scrollTop)},[]),y=e.activeConnectionId??((_=t.database)==null?void 0:_.activeConnectionId)??((M=a[0])==null?void 0:M.id),w=e.activeDatabase??((R=t.database)==null?void 0:R.activeDatabase),C=a.find(W=>W.id===y),N=y?((z=e.databases)==null?void 0:z.get(y))??[]:[],k=y&&w?(($=e.tables)==null?void 0:$.get(`${y}:${w}`))??[]:[];x.useEffect(()=>{if(!c&&a.length>0){try{const W=localStorage.getItem(_A(t.id));if(W){const L=JSON.parse(W);L.connectionId&&a.some(F=>F.id===L.connectionId)&&(U.setActiveConnection(t.id,L.connectionId),U.listDatabases(t.id,L.connectionId),L.database&&(U.setActiveDatabase(t.id,L.database),U.listTables(t.id,L.connectionId,L.database)),L.lastQuery&&i(L.lastQuery))}}catch{}!e.activeConnectionId&&a[0]&&(U.setActiveConnection(t.id,a[0].id),U.listDatabases(t.id,a[0].id)),d(!0)}},[t.id,a,c,e.activeConnectionId]),x.useEffect(()=>{if(c)try{const W=_A(t.id),L=JSON.parse(localStorage.getItem(W)||"{}");L.lastQuery=r,y&&(L.connectionId=y),w&&(L.database=w),localStorage.setItem(W,JSON.stringify(L))}catch{}},[t.id,r,y,w,c]);const j=x.useCallback(W=>{U.setActiveConnection(t.id,W),U.listDatabases(t.id,W)},[t.id]),S=x.useCallback(W=>{y&&(U.setActiveDatabase(t.id,W),U.listTables(t.id,y,W))},[t.id,y]),T=x.useCallback(()=>{var F;if(!y||!w||!r.trim()||s)return;const W=((F=f.current)==null?void 0:F.selectionStart)??0;if(jy(r).length<=1)U.executeQuery(t.id,y,w,r.trim());else{const H=_H(r,W);H?U.executeQuery(t.id,y,w,H):U.executeQuery(t.id,y,w,r.trim())}},[t.id,y,w,r,s]),D=x.useCallback(W=>{(W.ctrlKey||W.metaKey)&&W.key==="Enter"&&(W.preventDefault(),T())},[T]),E=x.useCallback(W=>{const L=`SELECT * FROM ${W} LIMIT 100`;i(L),y&&w&&U.executeQuery(t.id,y,w,L)},[t.id,y,w]),I=n[0];return a.length===0?o.jsx("div",{className:"db-inline",children:o.jsx("div",{className:"db-inline__empty",children:"🔌 No connections configured"})}):o.jsxs("div",{className:"db-inline",children:[o.jsxs("div",{className:"db-inline__toolbar",children:[a.length>1&&o.jsx("select",{className:"db-inline__select",value:y??"",onChange:W=>j(W.target.value),title:"Connection",children:a.map(W=>o.jsxs("option",{value:W.id,children:[W.engine==="mysql"?"🐬":"🐘"," ",W.name]},W.id))}),a.length===1&&C&&o.jsxs("span",{className:"db-inline__connection-badge",title:`${C.host}:${C.port}`,children:[C.engine==="mysql"?"🐬":"🐘"," ",C.name]}),o.jsxs("select",{className:"db-inline__select",value:w??"",onChange:W=>S(W.target.value),title:"Database",children:[o.jsx("option",{value:"",children:"Select database..."}),N.map(W=>o.jsx("option",{value:W,children:W},W))]}),k.length>0&&o.jsxs("select",{className:"db-inline__select db-inline__select--tables",value:"",onChange:W=>{W.target.value&&E(W.target.value)},title:"Quick query table",children:[o.jsxs("option",{value:"",children:["Tables (",k.length,")"]}),k.map(W=>o.jsx("option",{value:W.name,children:W.name},W.name))]}),o.jsx("button",{className:"db-inline__run",onClick:T,disabled:s||!w||!r.trim(),title:"Execute (Ctrl+Enter)",children:s?"⏳":"▶"})]}),o.jsxs("div",{className:"db-inline__editor",children:[o.jsx("pre",{ref:h,className:"db-inline__highlight","aria-hidden":"true",dangerouslySetInnerHTML:{__html:m+`
115
- `}}),o.jsx("textarea",{ref:f,className:"db-inline__textarea",value:r,onChange:W=>i(W.target.value),onKeyDown:D,onScroll:b,placeholder:"SELECT * FROM ...",spellCheck:!1,rows:2})]}),o.jsx("div",{className:"db-inline__results",children:I?o.jsx(TH,{result:I,buildingId:t.id,building:t}):o.jsx("div",{className:"db-inline__empty",children:w?"Run a query or select a table above":"Select a database to get started"})})]})};function MH(){const t=x.useRef(!1),e=x.useRef(!1),n=x.useRef(null),s=x.useRef(0),a=x.useRef(!1),r=x.useRef(0),i=x.useRef(0),c=x.useRef(0),d=x.useCallback((w,C)=>{const N=document.querySelector(".app");N&&(N.style.setProperty("--keyboard-height",`${w}px`),N.style.setProperty("--keyboard-visible",C?"1":"0"),N.classList.toggle("keyboard-visible",C)),s.current=w,a.current=C},[]),f=x.useCallback(()=>{d(0,!1),e.current=!1},[d]),h=x.useCallback(()=>{r.current&&(cancelAnimationFrame(r.current),r.current=0),window.visualViewport&&n.current&&(window.visualViewport.removeEventListener("resize",n.current),window.visualViewport.removeEventListener("scroll",n.current),n.current=null)},[]),m=x.useCallback(()=>{if(t.current=!0,!(window.innerWidth<=768))return;if(h(),e.current=!0,!(typeof window.__nativeKeyboardHeight=="number")&&window.visualViewport){i.current=Math.max(0,window.innerHeight-(window.visualViewport.height+window.visualViewport.offsetTop)),c.current=window.innerHeight;const N=()=>{const k=window.visualViewport;k&&(r.current&&cancelAnimationFrame(r.current),r.current=requestAnimationFrame(()=>{if(!t.current){f();return}const j=k.height+k.offsetTop,S=Math.max(0,window.innerHeight-j),T=Math.max(0,c.current-window.innerHeight),D=S>=120||T>=120;D||(i.current=S,c.current=window.innerHeight);const E=T>=120?0:D?Math.max(0,S):0;(E!==s.current||D!==a.current)&&d(E,D),D&&setTimeout(()=>{e.current=!1},300)}))};n.current=N,window.visualViewport.addEventListener("resize",N),window.visualViewport.addEventListener("scroll",N),N()}},[h,f,d]),b=x.useCallback(()=>{t.current=!1,window.innerWidth<=768&&setTimeout(()=>{t.current||(f(),h())},100)},[f,h]),y=x.useCallback(()=>{window.innerWidth<=768&&s.current>0&&(t.current=!1,f(),h())},[f,h]);return{isInputFocusedRef:t,keyboardScrollLockRef:e,handleInputFocus:m,handleInputBlur:b,cleanup:y}}function DH(){const[t,e]=x.useState(()=>{const d=Dx(pt.TERMINAL_HEIGHT,oS);return d>=lS&&d<=cS?d:oS}),n=x.useRef(!1),s=x.useRef(0),a=x.useRef(0),r=x.useRef(null),i=x.useRef(t);i.current=t;const c=x.useCallback(d=>{d.preventDefault(),n.current=!0,s.current=d.clientY,a.current=t,document.body.style.cursor="ns-resize",document.body.style.userSelect="none",U.setTerminalResizing(!0)},[t]);return x.useEffect(()=>{const d=h=>{if(!n.current)return;const m=h.clientY-s.current,b=window.innerHeight,y=m/b*100,w=Math.min(cS,Math.max(lS,a.current+y));e(w)},f=()=>{n.current&&(n.current=!1,document.body.style.cursor="",document.body.style.userSelect="",Rx(pt.TERMINAL_HEIGHT,i.current),U.setTerminalResizing(!1))};return document.addEventListener("mousemove",d),document.addEventListener("mouseup",f),()=>{document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",f)}},[]),{terminalHeight:t,terminalRef:r,handleResizeStart:c}}const RH=120,OH=.7;function LH(){const[t,e]=x.useState(()=>Dx(pt.MOBILE_OVERVIEW_HEIGHT,0)),n=x.useRef(t);n.current=t;const s=x.useRef(0),a=x.useRef(0),r=()=>Math.floor(window.innerHeight*OH),i=m=>Math.min(r(),Math.max(RH,m)),c=x.useCallback(m=>{e(m);const b=document.querySelector(".guake-terminal");b&&b.style.setProperty("--guake-mobile-overview-height",`${m}px`)},[]),d=x.useCallback(()=>{document.body.style.cursor="",document.body.style.userSelect="",Rx(pt.MOBILE_OVERVIEW_HEIGHT,n.current),U.setTerminalResizing(!1)},[]),f=x.useCallback(m=>{m.preventDefault();const b=document.querySelector(".agent-overview-panel"),y=n.current>0?n.current:(b==null?void 0:b.getBoundingClientRect().height)??240;s.current=m.clientY,a.current=y,document.body.style.cursor="ns-resize",document.body.style.userSelect="none",U.setTerminalResizing(!0);const w=N=>{const k=N.clientY-s.current;c(i(a.current+k))},C=()=>{document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",C),d()};document.addEventListener("mousemove",w),document.addEventListener("mouseup",C)},[c,d]),h=x.useCallback(m=>{if(m.touches.length!==1)return;const b=document.querySelector(".agent-overview-panel"),y=n.current>0?n.current:(b==null?void 0:b.getBoundingClientRect().height)??240;s.current=m.touches[0].clientY,a.current=y,document.body.style.cursor="ns-resize",document.body.style.userSelect="none",U.setTerminalResizing(!0);const w=N=>{if(N.touches.length!==1)return;N.preventDefault();const k=N.touches[0].clientY-s.current;c(i(a.current+k))},C=()=>{document.removeEventListener("touchmove",w),document.removeEventListener("touchend",C),document.removeEventListener("touchcancel",C),d()};document.addEventListener("touchmove",w,{passive:!1}),document.addEventListener("touchend",C),document.addEventListener("touchcancel",C)},[c,d]);return{mobileOverviewHeight:t,handleResizeMouseDown:f,handleResizeTouchStart:h}}function IH({agents:t,selectedAgentId:e,isOpen:n,overviewPanelOpen:s,loadingHistory:a,hasModalOpen:r=!1,outputRef:i}){const c=ur(),d=Yx(),h=Vr().vibrationIntensity??1,m=()=>{if(typeof document>"u")return!1;const z=document.querySelector(".agent-bar");if(!z)return!1;const $=window.getComputedStyle(z);if($.display==="none"||$.visibility==="hidden")return!1;const W=z.getBoundingClientRect();return W.width>0&&W.height>0},b=x.useMemo(()=>{const z=Array.from(t.values());if(!s&&m()){const se=GR(),q=z.filter(ee=>{if(U.isAgentInArchivedArea(ee.id))return!1;if(se){const ne=U.getAreaForAgent(ee.id);if(!zx((ne==null?void 0:ne.id)??null))return!1}return!0}).sort((ee,ne)=>(ee.createdAt||0)-(ne.createdAt||0)),be=Na(pt.AGENT_ORDER,[]),Ce=new Set(q.map(ee=>ee.id)),Z=be.filter(ee=>Ce.has(ee)),ie=q.filter(ee=>!Z.includes(ee.id)).map(ee=>ee.id),me=[...Z,...ie],Ee=new Map(q.map(ee=>[ee.id,ee])),Te=me.map(ee=>Ee.get(ee)).filter(ee=>ee!==void 0),Ve=new Map;for(const ee of Te){const ne=U.getAreaForAgent(ee.id),Ne=(ne==null?void 0:ne.id)??null;Ve.has(Ne)||Ve.set(Ne,{name:(ne==null?void 0:ne.name)??"",agents:[]}),Ve.get(Ne).agents.push(ee)}const We=Array.from(Ve.entries());return We.sort(([ee,ne],[Ne,ze])=>ee===null&&Ne!==null?1:ee!==null&&Ne===null?-1:ee===null&&Ne===null?0:ne.name.localeCompare(ze.name)),We.flatMap(([,ee])=>ee.agents)}const $=Na(pt.AOP_CONFIG,{groupByArea:!0,sortMode:"recent",filterMode:"all",sameAreaOnly:!1}),W=U.getState(),L=new Map;for(const se of d)L.has(se.agentId)||L.set(se.agentId,se.timestamp);const F=new Map;for(const se of z){const q=U.getAreaForAgent(se.id);!q||q.archived||F.set(se.id,q.id)}let H=z.filter(se=>{if($.filterMode==="working"&&se.status!=="working"||$.filterMode==="idle"&&se.status!=="idle"||$.filterMode==="error"&&se.status!=="error")return!1;if($.sameAreaOnly&&e){const q=F.get(e)??null,be=F.get(se.id)??null;if(q!==be)return!1}return!0});const V=se=>[...se].sort((q,be)=>{const Ce=!!(q.isBoss||q.class==="boss"),Z=!!(be.isBoss||be.class==="boss");if(Ce!==Z)return Ce?-1:1;if($.sortMode==="name")return q.name.localeCompare(be.name);if($.sortMode==="status"){const Ee=["working","waiting_input","waiting_permission","error","idle","stopped"],Te=Ee.indexOf(q.status)-Ee.indexOf(be.status);if(Te!==0)return Te;const Ve=W.agentsWithUnseenOutput.has(q.id),We=W.agentsWithUnseenOutput.has(be.id);if(Ve!==We)return Ve?-1:1;if(q.status==="working"&&be.status==="working")return q.name.localeCompare(be.name);if(q.status==="idle"&&be.status==="idle"){const ee=!!q.taskLabel,ne=!!be.taskLabel;return ee!==ne?ee?-1:1:(be.lastActivity||0)-(q.lastActivity||0)}return(be.lastActivity||0)-(q.lastActivity||0)}const ie=L.get(q.id)||0;return(L.get(be.id)||0)-ie});if(!$.groupByArea)return V(H);const G=[],B=new Set;for(const[se,q]of c){if(q.archived)continue;const be=H.filter(Ce=>F.get(Ce.id)===se);if(be.length>0){const Ce=V(be);G.push(...Ce);for(const Z of Ce)B.add(Z.id)}}const K=V(H.filter(se=>!B.has(se.id)));return G.push(...K),H=G,H},[t,c,d,e,s]),[y,w]=x.useState(0),[C,N]=x.useState(""),k=x.useRef(null),[j,S]=x.useState(null),T=e?b.findIndex(z=>z.id===e):-1,D=T>0?b[T-1]:b[b.length-1],E=T<b.length-1?b[T+1]:b[0],I=x.useRef(null),O=x.useCallback(()=>{if(!e||b.length<=1)return;const z=b.findIndex(W=>W.id===e);if(z===-1)return;const $=(z-1+b.length)%b.length;S("left"),w(0),N(""),U.setLastSelectionViaSwipe(!0),U.selectAgent(b[$].id)},[e,b]),_=x.useCallback(()=>{if(!e||b.length<=1)return;const z=b.findIndex(W=>W.id===e);if(z===-1)return;const $=(z+1)%b.length;S("right"),w(0),N(""),U.setLastSelectionViaSwipe(!0),U.selectAgent(b[$].id)},[e,b]),M=x.useCallback(z=>{w(z),N("is-swiping")},[]),R=x.useCallback(()=>{N("is-animating"),w(0),k.current&&clearTimeout(k.current),k.current=setTimeout(()=>{N("")},100)},[]);return x.useEffect(()=>{if(!j||a)return;const z=j;S(null),requestAnimationFrame(()=>{N(z==="left"?"swipe-in-left":"swipe-in-right"),k.current=setTimeout(()=>{N("")},120)})},[j,a]),x.useEffect(()=>()=>{k.current&&clearTimeout(k.current)},[]),Fk(I,{enabled:n&&b.length>1,onSwipeLeft:_,onSwipeRight:O,onSwipeMove:M,onSwipeCancel:R,threshold:40,maxVerticalMovement:50,vibrationIntensity:h}),Fk(i,{enabled:n&&b.length>1,onSwipeLeft:_,onSwipeRight:O,onSwipeMove:M,onSwipeCancel:R,threshold:50,maxVerticalMovement:35,vibrationIntensity:h}),x.useEffect(()=>{const z=$=>{if(!n||b.length<=1||r)return;const W=U.getShortcuts(),L=W.find(K=>K.id==="prev-working-agent"),F=W.find(K=>K.id==="next-working-agent"),H=W.find(K=>K.id==="prev-agent-terminal"),V=W.find(K=>K.id==="next-agent-terminal"),G=$.altKey&&$.shiftKey&&!$.ctrlKey&&!$.metaKey&&$.code==="KeyJ",B=$.altKey&&$.shiftKey&&!$.ctrlKey&&!$.metaKey&&$.code==="KeyK";if(Tn($,L)){$.preventDefault();const K=U.getState();let se=b.filter(Ce=>K.agentsWithUnseenOutput.has(Ce.id));if(se.length===0&&(se=b.filter(Ce=>Ce.status==="working")),se.length===0)return;const q=e?se.findIndex(Ce=>Ce.id===e):-1,be=q===-1?se.length-1:(q-1+se.length)%se.length;U.selectAgent(se[be].id);return}if(Tn($,F)){$.preventDefault();const K=U.getState();let se=b.filter(Ce=>K.agentsWithUnseenOutput.has(Ce.id));if(se.length===0&&(se=b.filter(Ce=>Ce.status==="working")),se.length===0)return;const q=e?se.findIndex(Ce=>Ce.id===e):-1,be=q===-1?0:(q+1)%se.length;U.selectAgent(se[be].id);return}if(Tn($,H)||B){$.preventDefault(),O();return}if(Tn($,V)||G){$.preventDefault(),_();return}};return document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)},[n,b,e,O,_,r]),{sortedAgents:b,swipeOffset:y,swipeAnimationClass:C,currentAgentIndex:T,prevAgent:D,nextAgent:E,headerRef:I,outputRef:i,handleSwipeLeft:O,handleSwipeRight:_}}function PH(t){if("type"in t&&"content"in t){const n=t;let s=n.content||"";return n._bashOutput&&(s+=" "+n._bashOutput),n._bashCommand&&(s+=" "+n._bashCommand),n.toolName&&(s+=" "+n.toolName),s}return t.text||""}function BH(t,e){if(e==="advanced")return!0;if("type"in t&&"content"in t){const a=t,r=a.content||"";return!(a.type==="user"&&(r.includes("<command-name>/cost</command-name>")||r.includes("<command-name>/compact</command-name>"))||a.type==="tool_result")}const n=t;if(e==="chat"){if(n.isUserPrompt)return!0;const a=n.text||"";return!(a.startsWith("Using tool:")||a.startsWith("Tool result:")||a.startsWith("Tool error:"))}return!(n.text||"").startsWith("Tool result:")}function FH({selectedAgentId:t,isOpen:e,allItems:n,viewMode:s,hasMoreHistory:a,loadAllHistory:r,loadingMore:i}){const[c,d]=x.useState(!1),[f,h]=x.useState(""),[m,b]=x.useState(0),[y,w]=x.useState(null),[C,N]=x.useState(!1),k=x.useRef(null),j=x.useRef(!1);x.useEffect(()=>{if(!c){j.current=!1;return}if(!a){N(!1);return}i||j.current||(j.current=!0,N(!0),r().finally(()=>{N(!1)}))},[c,a,i,r]);const S=x.useMemo(()=>{if(!f.trim()||f.trim().length<2)return[];const _=f.trim().toLowerCase(),M=[];for(let R=0;R<n.length;R++)PH(n[R]).toLowerCase().includes(_)&&BH(n[R],s)&&M.push(R);return M},[n,f,s]);x.useEffect(()=>{if(S.length>0){const _=S.length-1;b(_),w(S[_])}else b(0),w(null)},[S]),x.useEffect(()=>{c&&k.current&&requestAnimationFrame(()=>{var _;(_=k.current)==null||_.focus()})},[c]);const T=x.useCallback(()=>{if(S.length===0)return;const _=(m+1)%S.length;b(_),w(S[_])},[m,S]),D=x.useCallback(()=>{if(S.length===0)return;const _=(m-1+S.length)%S.length;b(_),w(S[_])},[m,S]),E=x.useCallback(()=>{d(_=>(_&&(h(""),b(0),w(null),N(!1)),!_))},[]),I=x.useCallback(()=>{d(!1),h(""),b(0),w(null),N(!1)},[]);x.useEffect(()=>{c&&(h(""),b(0),w(null))},[t]),x.useEffect(()=>{const _=M=>{var R;(M.ctrlKey||M.metaKey)&&M.key==="f"&&e&&(M.preventDefault(),c?(R=k.current)==null||R.focus():d(!0))};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[e,c]);const O=c&&f.trim().length>=2&&S.length>0?f.trim():void 0;return{searchMode:c,searchQuery:f,setSearchQuery:h,searchInputRef:k,toggleSearch:E,closeSearch:I,highlightQuery:O,matchIndices:S,currentMatch:m,navigateNext:T,navigatePrev:D,scrollToIndex:y,loadingFullHistory:C}}const zH=new Map,$H=[];function UH({selectedAgentId:t}){const[e,n]=x.useState(new Map),[s,a]=x.useState(new Map),[r,i]=x.useState(new Map),[c,d]=x.useState(new Map),f=x.useRef(new Map),h=x.useRef(0);x.useEffect(()=>{if(!t||e.has(t))return;const z=Fa(`${pt.INPUT_TEXT_PREFIX}${t}`);z&&n(W=>new Map(W).set(t,z));const $=Fa(`${pt.PASTED_TEXTS_PREFIX}${t}`);if($)try{const W=JSON.parse($),L=new Map(W);i(H=>new Map(H).set(t,L));const F=Math.max(0,...W.map(([H])=>H));f.current.set(t,F)}catch{}},[t,e]);const m=t&&e.get(t)||"",b=t&&s.get(t)||!1,y=(t?r.get(t):void 0)||zH,w=(t?c.get(t):void 0)||$H,C=m.includes(`
116
- `),k=typeof window<"u"&&window.innerWidth<=768||b||C||m.length>50,j=x.useCallback(z=>{t&&(n($=>new Map($).set(t,z)),z?Wr(`${pt.INPUT_TEXT_PREFIX}${t}`,z):Pk(`${pt.INPUT_TEXT_PREFIX}${t}`))},[t]),S=x.useCallback(z=>{t&&a($=>new Map($).set(t,z))},[t]),T=x.useCallback(z=>{t&&i($=>{const W=new Map($),L=$.get(t)||new Map,F=typeof z=="function"?z(L):z;if(W.set(t,F),F.size>0){const H=JSON.stringify(Array.from(F.entries()));Wr(`${pt.PASTED_TEXTS_PREFIX}${t}`,H)}else Pk(`${pt.PASTED_TEXTS_PREFIX}${t}`);return W})},[t]),D=x.useCallback(z=>{t&&d($=>{const W=new Map($),L=$.get(t)||[],F=typeof z=="function"?z(L):z;return W.set(t,F),W})},[t]),E=x.useCallback(()=>{if(!t)return 0;const $=(f.current.get(t)||0)+1;return f.current.set(t,$),$},[t]),I=x.useCallback(()=>{t&&f.current.set(t,0)},[t]),O=x.useCallback(z=>{D($=>$.filter(W=>W.id!==z))},[D]),_=x.useCallback(async(z,$)=>{try{const W=$||(z instanceof File?z.name:""),L=encodeURIComponent(W),F=await Bt(Rt("/api/files/upload"),{method:"POST",headers:{"Content-Type":z.type||"application/octet-stream","X-Filename":L},body:z});if(!F.ok)return console.error("Upload failed:",await F.text()),null;const H=await F.json();return h.current+=1,{id:h.current,name:H.filename,path:H.absolutePath,isImage:H.isImage,size:H.size}}catch(W){return console.error("Upload error:",W),null}},[]),M=x.useCallback(z=>{let $=z;for(const[W,L]of y){const F=new RegExp(`\\[Pasted text #${W} \\+\\d+ lines\\]`,"g");$=$.replace(F,L)}return $},[y]),R=x.useCallback(()=>{const z=(m.match(/\n/g)||[]).length+1,$=Math.ceil(m.length/60),W=Math.max(z,$,2);return Math.min(W,10)},[m]);return x.useMemo(()=>({command:m,setCommand:j,forceTextarea:b,setForceTextarea:S,useTextarea:k,pastedTexts:y,setPastedTexts:T,incrementPastedCount:E,resetPastedCount:I,attachedFiles:w,setAttachedFiles:D,removeAttachedFile:O,uploadFile:_,expandPastedTexts:M,getTextareaRows:R}),[m,j,b,S,k,y,T,E,I,w,D,O,_,M,R])}const Ab=10;function HH({totalMessages:t,isOpen:e,hasModalOpen:n=!1,scrollContainerRef:s,selectedAgentId:a,inputRef:r,textareaRef:i,useTextarea:c=!1}){const[d,f]=x.useState(-1),h=x.useRef(null);x.useEffect(()=>{h.current!==a&&(f(-1),h.current=a)},[a]);const m=x.useCallback(()=>{f(-1)},[]),b=x.useRef(null),y=D=>1-Math.pow(1-D,3),w=x.useCallback((D,E,I=200)=>{b.current&&cancelAnimationFrame(b.current);const O=D.scrollTop,_=E-O,M=performance.now(),R=z=>{const $=z-M,W=Math.min($/I,1),L=y(W);D.scrollTop=O+_*L,W<1?b.current=requestAnimationFrame(R):b.current=null};b.current=requestAnimationFrame(R)},[]),C=x.useCallback(D=>{if(!s.current)return;const E=s.current,I=E.querySelector(`[data-message-index="${D}"]`);if(I){const O=E.getBoundingClientRect(),_=I.getBoundingClientRect(),M=20;if(_.top<O.top+M){const R=E.scrollTop+(_.top-O.top)-M;w(E,R,180)}else if(_.bottom>O.bottom-M){const R=E.scrollTop+(_.bottom-O.bottom)+M;w(E,R,180)}}},[s,w]);x.useEffect(()=>()=>{b.current&&cancelAnimationFrame(b.current)},[]);const N=x.useCallback(()=>{t!==0&&f(D=>{let E;return D===-1?E=t-1:D>0?E=D-1:E=0,requestAnimationFrame(()=>C(E)),E})},[t,C]),k=x.useCallback(()=>{t!==0&&f(D=>{let E;if(D===-1)E=t-1;else if(D<t-1)E=D+1;else return-1;return requestAnimationFrame(()=>C(E)),E})},[t,C]),j=x.useCallback(()=>{t!==0&&f(D=>{let E;return D===-1?E=t-1:E=Math.max(0,D-Ab),requestAnimationFrame(()=>C(E)),E})},[t,C]),S=x.useCallback(()=>{t!==0&&f(D=>{let E;if(D===-1)E=t-1;else{if(D+Ab>=t)return-1;E=D+Ab}return requestAnimationFrame(()=>C(E)),E})},[t,C]),T=x.useCallback(D=>d===D,[d]);return x.useEffect(()=>{const D=E=>{if(!e||n)return;const I=U.getShortcuts(),O=I.find(L=>L.id==="prev-message"),_=I.find(L=>L.id==="next-message"),M=I.find(L=>L.id==="page-up-messages"),R=I.find(L=>L.id==="page-down-messages"),z=I.find(L=>L.id==="activate-message");if(Tn(E,O)){E.preventDefault(),document.activeElement instanceof HTMLElement&&document.activeElement.blur(),N();return}if(Tn(E,_)){E.preventDefault(),document.activeElement instanceof HTMLElement&&document.activeElement.blur(),k();return}if(Tn(E,M)){E.preventDefault(),document.activeElement instanceof HTMLElement&&document.activeElement.blur(),j();return}if(Tn(E,R)){E.preventDefault(),document.activeElement instanceof HTMLElement&&document.activeElement.blur(),S();return}if(E.key==="Escape"&&d!==-1){E.preventDefault(),m();return}const $=E.target,W=$.tagName==="INPUT"||$.tagName==="TEXTAREA"||$.isContentEditable;if(Tn(E,z)&&d!==-1&&!W){E.preventDefault();const L=s.current;if(!L)return;const F=L.querySelector(`[data-message-index="${d}"]`);if(!F)return;const H=[".clickable-path",".output-tool-use.bash-clickable",".clickable-bash",".history-view-md-btn"];for(const G of H){const B=F.querySelector(G);if(B){B.click();return}}const V=F.querySelector(".output-tool-use");V!=null&&V.classList.contains("bash-clickable")&&V.click();return}if(d!==-1&&!W){const L=Tn(E,O)||Tn(E,_)||Tn(E,M)||Tn(E,R),F=["Escape","Tab","Shift","Control","Alt","Meta","CapsLock"].includes(E.key),H=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(E.key),V=E.key.startsWith("F")&&E.key.length<=3;if(!L&&!F&&!H&&!V&&!E.ctrlKey&&!E.metaKey){const G=c?i==null?void 0:i.current:r==null?void 0:r.current;if(G){G.focus(),f(-1);return}}}};return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[e,n,N,k,j,S,m,d,r,i,c]),x.useEffect(()=>{d>=t&&t>0?f(t-1):t===0&&f(-1)},[t,d]),{selectedIndex:d,setSelectedIndex:f,clearSelection:m,navigatePrev:N,navigateNext:k,navigatePageUp:j,navigatePageDown:S,isSelected:T}}const WH=3e4;function qH(t){const[e,n]=x.useState(new Map),[s,a]=x.useState(new Set),r=x.useRef(null),i=x.useMemo(()=>!t||t.length===0?null:[...new Set(t.map(h=>h.dir))].sort(),[t]),c=i?i.join(`
117
- `):"",d=x.useCallback(async()=>{if(!i||i.length===0){n(new Map);return}const h=Ii(),m={};h&&(m.Authorization=`Bearer ${h}`);const b=Ea(),y=new Map;await Promise.all(i.map(async w=>{try{const C=await fetch(`${b}/api/files/git-branch?path=${encodeURIComponent(w)}`,{headers:m});if(C.ok){const N=await C.json();N.branch&&y.set(w,{branch:N.branch,ahead:N.ahead||0,behind:N.behind||0})}}catch{}})),n(y)},[i]);x.useEffect(()=>{if(!i||i.length===0){n(new Map);return}return d(),r.current=setInterval(d,WH),()=>{r.current&&clearInterval(r.current)}},[c,d]);const f=x.useCallback(async h=>{a(m=>new Set(m).add(h));try{await Bt(Rt("/api/files/git-fetch"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:h})}),await d()}catch{}finally{a(m=>{const b=new Set(m);return b.delete(h),b})}},[d]);return{branches:e,fetchRemote:f,fetchingDirs:s,refetch:d}}const fs={Read:"📖",Write:"✏️",Edit:"📝",Bash:"💻",Glob:"🔍",Grep:"🔎",Task:"📋",Agent:"🤖",WebFetch:"🌐",WebSearch:"🌍",TodoWrite:"✅",NotebookEdit:"📓",AskFollowupQuestion:"❓",AskUserQuestion:"❓",AttemptCompletion:"✨",ListFiles:"📂",SearchFiles:"🔎",ExecuteCommand:"⚙️",spawn_agent:"🧬",send_input:"📨",wait:"⏳",default:"⚡"},VH={Read:"tools:display.toolNames.read",Write:"tools:display.toolNames.write",Edit:"tools:display.toolNames.edit",Bash:"tools:display.toolNames.bash",Glob:"tools:display.toolNames.glob",Grep:"tools:display.toolNames.grep",Task:"tools:display.toolNames.task",Agent:"tools:display.toolNames.agent",WebFetch:"tools:display.toolNames.webFetch",WebSearch:"tools:display.toolNames.webSearch",TodoWrite:"tools:display.toolNames.todoWrite",NotebookEdit:"tools:display.toolNames.notebookEdit",AskFollowupQuestion:"tools:display.toolNames.askFollowupQuestion",AskUserQuestion:"tools:display.toolNames.askUserQuestion",AttemptCompletion:"tools:display.toolNames.attemptCompletion",ListFiles:"tools:display.toolNames.listFiles",SearchFiles:"tools:display.toolNames.searchFiles",ExecuteCommand:"tools:display.toolNames.executeCommand",spawn_agent:"tools:display.toolNames.spawnAgent",send_input:"tools:display.toolNames.sendInput",wait:"tools:display.toolNames.wait"};function vT(t,e){const n=VH[t];return n&&e(n,{defaultValue:t})||t}function Fp(t){return(typeof t=="string"?new Date(t):new Date(t)).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}function wT(t,e){var n;try{const s=JSON.parse(e);switch(t){case"Read":case"Write":case"Edit":case"NotebookEdit":{const a=s.file_path||s.path||s.notebook_path;if(a)return a;break}case"Bash":{const a=s.command;if(a)return ST(a);break}case"Grep":{const a=s.pattern,r=s.path;if(a&&r)return`"${a}" in ${r}`;if(a)return`"${a}"`;break}case"Glob":{const a=s.pattern,r=s.path;if(a&&r)return`${a} in ${r}`;if(a)return a;break}case"WebFetch":{const a=s.url;if(a)return a;break}case"WebSearch":{const a=s.query;if(a)return`"${a}"`;break}case"Task":case"Agent":{const a=s.description,r=s.subagent_type;if(a)return r?`[${r}] ${a}`:a;if(s.prompt)return s.prompt;break}case"ExitPlanMode":case"EnterPlanMode":{const a=s.allowedPrompts;return Array.isArray(a)&&a.length>0?a.map(r=>r.prompt||r.tool||"").filter(Boolean).join(", "):t==="ExitPlanMode"&&typeof s.plan=="string"&&s.plan.trim().length>0?s.plan.trim():t==="ExitPlanMode"?"Plan ready":"Entering plan mode"}case"TodoWrite":{const a=s.todos;if(Array.isArray(a)&&a.length>0){const r=a.filter(f=>f.status==="completed").length,i=a.filter(f=>f.status==="in_progress").length,c=a.filter(f=>f.status==="pending").length,d=[];return r>0&&d.push(`${r} done`),i>0&&d.push(`${i} active`),c>0&&d.push(`${c} pending`),`${a.length} items (${d.join(", ")})`}break}case"AskUserQuestion":case"AskFollowupQuestion":{const a=s.questions||s.question;if(a){const r=Array.isArray(a)?(n=a[0])==null?void 0:n.question:a;if(r)return r}break}default:{for(const[,a]of Object.entries(s))if(typeof a=="string"&&a.length>0)return a;break}}}catch{}return null}function kT(t){if(!t.includes("curl")||!t.includes("/api/exec"))return null;const e=[],n=[/(?:-d|--data|--data-raw)\s+'((?:\\'|[^'])*)'/g,/(?:-d|--data|--data-raw)\s+"((?:\\"|[^"])*)"/g];for(const s of n){let a;for(;(a=s.exec(t))!==null;)a[1]&&e.push(a[1])}for(const s of e){const a=[s,s.replace(/\\"/g,'"'),s.replace(/\\'/g,"'"),s.replace(/\\"/g,'"').replace(/\\\\/g,"\\")];for(const r of a){const i=r.trim();if(!(!i.startsWith("{")||!i.endsWith("}")))try{const c=JSON.parse(i);if(typeof c.command=="string"&&c.command.length>0)return c.command}catch{}}}return null}function ST(t){return kT(t)||t}const EA=/(^|[\s("'`])((?:\.{1,2}\/|~\/|\/)?[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*\.[A-Za-z0-9._-]+(?::\d+(?::\d+)?)?)/g;function YH(t){return!t||t.startsWith("-")||t.includes("://")||t.includes("*")?!1:t.includes(".")&&!t.endsWith(".")}function CT(t){if(!t)return[{text:""}];const e=[];let n=0;EA.lastIndex=0;let s;for(;(s=EA.exec(t))!==null;){const a=s[0],r=s[1]||"",i=s[2]||"",c=s.index;c>n&&e.push({text:t.slice(n,c)}),r&&e.push({text:r}),YH(i)?e.push({text:i,fileRef:i}):e.push({text:i}),n=c+a.length}return n<t.length&&e.push({text:t.slice(n)}),e.length>0?e:[{text:t}]}const zp="tide-file://",GH=/(^|[\s(>])((?:\.\.?\/|\/)?(?:[A-Za-z0-9._-]+\/)*[A-Za-z0-9._-]+(?:\.[A-Za-z0-9._-]+)+(?:#L\d+(?:C\d+)?)?(?::\d+(?::\d+)?)?)(?=$|[\s),.;])/g,KH=/`((?:\.\.?\/|\/)?(?:[A-Za-z0-9._-]+\/)*[A-Za-z0-9._-]+(?:\.[A-Za-z0-9._-]+)+(?:#L\d+(?:C\d+)?)?(?::\d+(?::\d+)?)?)`/g,QH=/\.(com|org|net|io|dev|app|co|me|info|biz|us|uk|de|fr|jp|cn|ru|edu|gov|mil|int|xyz|tech|online|site|store|blog|cloud|ai|gg|tv|cc|sh|fm|to|ly|gl|so|is|it|at|nl|ch|se|no|fi|dk|be|cz|pl|pt|br|mx|ar|cl|in|au|nz|za|sg|hk|tw|kr|id|ph|th|vn|my)(?:[:/\s#?]|$)/i;function MA(t){if(!t||t.includes("://")||t.startsWith("www.")||t.includes("@"))return!1;const e=t.split("/")[0];return QH.test(e)?!1:t.includes(".")&&!t.endsWith(".")}function lp(t){if(!t||!t.includes("."))return t;const e=t.split(`
118
- `);let n=!1;return e.map(a=>{if(a.trimStart().startsWith("```"))return n=!n,a;if(n)return a;const i=a.replace(KH,(c,d)=>{if(!MA(d))return c;const f=encodeURIComponent(d);return`[\`${d}\`](${zp}${f})`});return i.replace(GH,(c,d,f,h)=>{const m=h+d.length,b=m>0?i[m-1]:"",y=m+f.length<i.length?i[m+f.length]:"";if(b==="("&&m>1&&i[m-2]==="]"||b==="["||y==="]"||!MA(f))return c;const w=encodeURIComponent(f);return`${d}[${f}](${zp}${w})`})}).join(`
119
- `)}function XH(t){if(!t||!t.startsWith(zp))return null;const e=t.slice(zp.length);if(!e)return null;try{return decodeURIComponent(e)}catch{return e}}function Li(t){return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}function AT(t){const e=t.trim();if(!e)return null;let n,s=e;const a=e.match(/^(\S+)\s+-lc\s+([\s\S]+)$/);if(a&&(n=`${a[1]} -lc`,s=Li(a[2].trim())),!/\brg\s+--files\b/.test(s)||!/\|\s*rg\b/.test(s))return null;const r=s.match(/\|\s*rg\b\s+(.+)$/);if(!r)return null;const i=r[1].trim();if(!i)return null;const c=i.replace(/^(?:-\S+\s+)*/,"").trim(),d=Li(c||i);return d?{shellPrefix:n,commandBody:s,searchTerm:d}:null}function jT(t){const e=t.trim();if(!e)return null;let n,s=e;const a=e.match(/^(\S+)\s+-lc\s+([\s\S]+)$/);a&&(n=`${a[1]} -lc`,s=Li(a[2].trim()));const r=/\bcurl\b[\s\S]*\/api\/notify\b/.test(s),i=/\bgdbus\b[\s\S]*org\.freedesktop\.Notifications\.Notify\b/.test(s);if(!r&&!i)return null;let c,d;const f=s.match(/-d\s+((['"])([\s\S]*?)\2)/);if(f){const h=Li(f[1]).replace(/\\"/g,'"'),m=h.match(/"title"\s*:\s*"([^"]*)"/),b=h.match(/"message"\s*:\s*"([^"]*)"/);m!=null&&m[1]&&(c=m[1]),b!=null&&b[1]&&(d=b[1])}if(!c||!d){const h=s.match(/Notifications\.Notify[\s\S]*?\s'[^']*'\s+\d+\s+'[^']*'\s+'([^']*)'\s+'([^']*)'/);!c&&(h!=null&&h[1])&&(c=h[1]),!d&&(h!=null&&h[2])&&(d=h[2])}return{shellPrefix:n,commandBody:s,title:c,message:d,viaCurl:r,viaGdbus:i}}function NT(t){const e=t.trim();if(!e)return null;let n,s=e;const a=e.match(/^(\S+)\s+-lc\s+([\s\S]+)$/);if(a&&(n=`${a[1]} -lc`,s=Li(a[2].trim())),!/\bcurl\b/.test(s)||!/PATCH/.test(s)||!/\/api\/agents\//.test(s))return null;const r=s.match(/-d\s+((['"])([\s\S]*?)\2)/);if(!r)return null;const c=Li(r[1]).replace(/\\"/g,'"').match(/"taskLabel"\s*:\s*"([^"]*)"/);return c!=null&&c[1]?{shellPrefix:n,commandBody:s,taskLabel:c[1]}:null}function TT(t){const e=t.trim();if(!e)return null;let n,s=e;const a=e.match(/^(\S+)\s+-lc\s+([\s\S]+)$/);if(a&&(n=`${a[1]} -lc`,s=Li(a[2].trim())),!/\bcurl\b/.test(s)||!/\/api\/agents\/.*\/report-task\b/.test(s))return null;let r="",i="completed";const c=s.match(/<<'?EOF'?\s*\n([\s\S]*?)\nEOF/);if(c)try{const d=JSON.parse(c[1].trim());r=d.summary||"",i=d.status==="failed"?"failed":"completed"}catch{}else{const d=s.match(/-d\s+((['"])([\s\S]*?)\2)/);if(d){const f=Li(d[1]).replace(/\\"/g,'"'),h=f.match(/"summary"\s*:\s*"([^"]*)"/),m=f.match(/"status"\s*:\s*"([^"]*)"/);h&&(r=h[1]),(m==null?void 0:m[1])==="failed"&&(i="failed")}}return{shellPrefix:n,commandBody:s,summary:r,status:i}}const DA=300;function JH(t){if(!t)return!1;if(t.startsWith("Using tool:"))return!0;if(t.startsWith("Tool input:")||t.startsWith("Tool result:")||t.startsWith("Bash output:")||t.startsWith("Tokens:")||t.startsWith("Cost:"))return!1;if(t.startsWith("[thinking]"))return!0;if(t.startsWith("[raw]")||t.startsWith("Session started:")||t.startsWith("Session initialized"))return!1;const e=t.trim();return!(e.startsWith("{")&&['"file_path"','"command"','"pattern"','"path"','"content"','"old_string"','"new_string"','"query"','"url"','"prompt"','"notebook_path"','"description"','"offset"','"limit"'].some(s=>e.includes(s)))}function ZH(t){if(!t||t.startsWith("Using tool:")||t.startsWith("Tool input:")||t.startsWith("Tool result:")||t.startsWith("Tokens:")||t.startsWith("Cost:")||t.startsWith("[thinking]")||t.startsWith("[raw]")||t.startsWith("Session started:")||t.startsWith("Session initialized"))return!1;const e=t.trim();return!(e.startsWith("{")&&['"file_path"','"command"','"pattern"','"path"','"content"','"old_string"','"new_string"','"query"','"url"','"prompt"','"notebook_path"','"description"','"offset"','"limit"'].some(a=>e.includes(a))||[/^(let me|i'll|i will|now i|first,? i|i need to|i should|i'm going to)/i,/^(looking at|reading|checking|searching|exploring|examining|investigating)/i,/^(based on|from what|according to|it (looks|seems|appears))/i,/^(this (shows|indicates|suggests|means|is))/i,/^(the (code|file|function|class|component|implementation))/i,/^(now (let|i))/i].some(s=>s.test(e)))}function _T({outputs:t,viewMode:e}){return x.useMemo(()=>{if(e==="advanced")return t;if(e==="chat")return t.filter(s=>s.isUserPrompt?!0:s.text?ZH(s.text):!1);const n=[];for(let s=0;s<t.length;s++){const a=t[s];if(a.isUserPrompt){n.push(a);continue}if(!a.text){n.push(a);continue}if(a.text.startsWith("Using tool:")){const r=a.text.replace("Using tool:","").trim();let i=null,c,d,f,h;for(let b=s+1;b<t.length&&b<=s+20;b++){const y=t[b];if(y.text.startsWith("Tool input:")){const w=y.text.replace("Tool input:","").trim();if(i=wT(r,w),r==="Edit")try{const C=JSON.parse(w);(C.old_string!==void 0||C.new_string!==void 0||C.unified_diff!==void 0)&&(c={oldString:C.old_string||"",newString:C.new_string||"",operation:typeof C.operation=="string"?C.operation:void 0,unifiedDiff:typeof C.unified_diff=="string"?C.unified_diff:void 0})}catch{}if(r==="TodoWrite")try{const C=JSON.parse(w);Array.isArray(C.todos)&&(d=w)}catch{}if(r==="Bash")try{const C=JSON.parse(w);C.command&&(h=C.command)}catch{}}if(r==="Bash"&&y.text.startsWith("Bash output:")&&(f=y.text.replace("Bash output:","").trim()),y.text.startsWith("Using tool:"))break}r==="Bash"&&i&&i.length>DA&&(i=i.substring(0,DA-3)+"...");const m=r==="Bash"&&!f;n.push({...a,_toolKeyParam:i||void 0,_editData:c,_todoInput:d,_bashOutput:f,_bashCommand:h,_isRunning:m});continue}JH(a.text)&&n.push(a)}return n},[t,e])}function ET({outputs:t,viewMode:e}){const n=x.useRef(0),s=x.useRef(0),a=_T({outputs:t,viewMode:e});if(t.length!==n.current||a.length!==s.current){const r=t.length>0?t[t.length-1]:null,i=r!=null&&r.text?r.text.slice(0,40):null;Uu.info(`Filter: in=${t.length} out=${a.length} mode=${e}`,{inputLen:t.length,outputLen:a.length,viewMode:e,lastInput:i},"useFilteredOutputs"),n.current=t.length,s.current=a.length}return a}function e6(t){const e=t.replace(/^[\p{Emoji_Presentation}\p{Extended_Pictographic}\uFE0F]+\s*/u,"").trim();if(!e)return null;const n=U.getState().agents;for(const[s,a]of n)if(a.name===e)return s;return null}function Iu(t){return typeof t=="string"||typeof t=="number"?String(t):Array.isArray(t)?t.map(Iu).join(""):Se.isValidElement(t)?Iu(t.props.children):""}const t6=/\.(com|org|net|io|dev|app|co|me|info|biz|us|uk|de|fr|jp|cn|ru|edu|gov|mil|int|xyz|tech|online|site|store|blog|cloud|ai|gg|tv|cc|sh|fm|to|ly|gl|so|is|it|at|nl|ch|se|no|fi|dk|be|cz|pl|pt|br|mx|ar|cl|in|au|nz|za|sg|hk|tw|kr|id|ph|th|vn|my)$/i;function Ny(t){const e=t.split("/")[0].split("?")[0].split("#")[0];return t6.test(e)}function n6(t){return!t||t.startsWith("#")||/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(t)||Ny(t)?!1:t.includes(".")||t.startsWith("/")||t.startsWith("./")||t.startsWith("../")}function s6(t){if(!t||t.includes(`
120
- `))return!1;const e=t.trim();return!e||/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(e)||Ny(e)?!1:e.includes(".")&&(e.includes("/")||/^[A-Za-z0-9._-]+\.[A-Za-z0-9._-]+$/.test(e))}const ld=({onFileClick:t}={})=>({h1:({children:e})=>o.jsx("h1",{style:{fontSize:"1.4em",color:"var(--accent-pink)",fontWeight:600,margin:"0.6em 0 0.3em"},children:e}),h2:({children:e})=>o.jsx("h2",{style:{fontSize:"1.25em",color:"var(--accent-purple)",fontWeight:600,margin:"0.6em 0 0.3em"},children:e}),h3:({children:e})=>o.jsx("h3",{style:{fontSize:"1.15em",color:"var(--accent-cyan)",fontWeight:600,margin:"0.6em 0 0.3em"},children:e}),h4:({children:e})=>o.jsx("h4",{style:{fontSize:"1.1em",color:"var(--accent-green)",fontWeight:600,margin:"0.6em 0 0.3em"},children:e}),h5:({children:e})=>o.jsx("h5",{style:{fontSize:"1.05em",color:"var(--accent-yellow)",fontWeight:600,margin:"0.6em 0 0.3em"},children:e}),h6:({children:e})=>o.jsx("h6",{style:{fontSize:"1em",color:"var(--accent-orange)",fontWeight:600,margin:"0.6em 0 0.3em"},children:e}),p:({children:e})=>o.jsx("p",{style:{margin:"0.4em 0"},children:e}),strong:({children:e})=>{const n=Iu(e),s=e6(n);return s?o.jsx("strong",{className:"clickable-agent-name",style:{color:"var(--accent-orange)",fontWeight:600,cursor:"pointer"},onClick:a=>{a.stopPropagation(),U.selectAgent(s),U.setTerminalOpen(!0)},children:e}):o.jsx("strong",{style:{color:"var(--accent-orange)",fontWeight:600},children:e})},em:({children:e})=>o.jsx("em",{style:{color:"var(--accent-yellow)",fontStyle:"italic"},children:e}),del:({children:e})=>o.jsx("del",{style:{color:"var(--accent-red)",textDecoration:"line-through"},children:e}),code:({children:e,className:n})=>{if(n==null?void 0:n.includes("language-")){const a=(n==null?void 0:n.replace("language-",""))??"",r=Iu(e);if(a&&k4(a)){const i=Mo(r,a);return o.jsx("code",{className:n,style:{background:"none",padding:0,fontSize:"12px",lineHeight:1.5},dangerouslySetInnerHTML:{__html:i}})}return o.jsx("code",{style:{background:"none",padding:0,color:"var(--text-primary)",fontSize:"12px",lineHeight:1.5},children:e})}return o.jsx("code",{style:{background:"color-mix(in srgb, var(--bg-tertiary) 80%, transparent)",color:"var(--accent-green)",padding:"0.15em 0.4em",borderRadius:"3px",fontSize:"0.9em"},children:e})},pre:({children:e})=>o.jsx("pre",{style:{background:"color-mix(in srgb, var(--bg-primary) 90%, transparent)",border:"1px solid var(--border-color)",borderRadius:"6px",padding:"12px",margin:"0.6em 0",overflowX:"auto"},children:e}),ul:({children:e})=>o.jsx("ul",{style:{margin:"0.5em 0",paddingLeft:"1.5em",lineHeight:1.5},children:e}),ol:({children:e})=>o.jsx("ol",{style:{margin:"0.5em 0",paddingLeft:"1.5em",lineHeight:1.5},children:e}),li:({children:e})=>o.jsx("li",{style:{margin:"0.2em 0",paddingLeft:"0.3em"},children:e}),blockquote:({children:e})=>o.jsx("blockquote",{style:{borderLeft:"3px solid var(--accent-purple)",margin:"0.5em 0",padding:"0.5em 1em",background:"color-mix(in srgb, var(--accent-purple) 10%, transparent)",borderRadius:"0 4px 4px 0"},children:e}),a:({children:e,href:n})=>{const s=typeof n=="string"?n.trim():"",a=XH(s),r=Iu(e).trim(),i=a||(s&&n6(s)?s:null)||((!s||s==="#")&&s6(r)?r:null);if(i&&t)return o.jsx("a",{href:"#",onClick:d=>{d.preventDefault(),d.stopPropagation(),t(i)},className:"clickable-path",title:`Open ${i}`,children:e});if(!s)return o.jsx("span",{children:e});const c=!s.includes("://")&&Ny(s)?`https://${s}`:s;return o.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent-cyan)",textDecoration:"underline"},children:e})},hr:()=>o.jsx("hr",{style:{border:"none",borderTop:"1px solid var(--border-color)",margin:"1em 0"}}),table:({children:e})=>o.jsx("table",{style:{width:"100%",borderCollapse:"collapse",margin:"0.6em 0",fontSize:"12px"},children:e}),th:({children:e})=>o.jsx("th",{style:{border:"1px solid var(--border-color)",padding:"6px 10px",textAlign:"left",background:"color-mix(in srgb, var(--bg-tertiary) 80%, transparent)",fontWeight:600,color:"var(--accent-pink)"},children:e}),td:({children:e})=>o.jsx("td",{style:{border:"1px solid var(--border-color)",padding:"6px 10px",textAlign:"left",background:"color-mix(in srgb, var(--bg-secondary) 50%, transparent)"},children:e}),input:({checked:e,type:n})=>n==="checkbox"?o.jsx("input",{type:"checkbox",checked:e,readOnly:!0,style:{marginRight:"0.5em",accentColor:"var(--accent-green)"}}):null});ld();function Ty(t){const e=t.trimStart();if(!e.startsWith(nx))return{hasContext:!1,context:null,userMessage:t};const n=e.lastIndexOf(xS);if(n===-1)return{hasContext:!1,context:null,userMessage:t};const s=e.slice(nx.length,n).trim(),a=e.slice(n+xS.length).trim();return{hasContext:!0,context:s,userMessage:a}}function _y(t){const e=t.replace(/\r\n/g,`
121
- `).trim(),n="Follow all instructions below for this task.",s="## User Request",a=e.lastIndexOf(s);if(a!==-1){const h=e.slice(0,a).trim(),m=e.slice(a+s.length).trim();if(m)return{hasInstructions:h.length>0,instructions:h.length>0?h:null,userMessage:m}}let r=e;const i=[],c=[/^(?:You)?# AGENTS\.md instructions[^\n]*\n[\s\S]*?<\/INSTRUCTIONS>\s*/i,/^(?:You)?<environment_context>\s*[\s\S]*?<\/environment_context>\s*/i,/^(?:You)?Follow all instructions below for this task\.\s*/i];let d=!1,f=!0;for(;f;){f=!1;for(const h of c){const m=r.match(h);if(m){i.push(m[0].trim()),r=r.slice(m[0].length).trimStart(),d=!0,f=!0;break}}}return d&&r?{hasInstructions:!0,instructions:i.join(`
122
-
123
- `),userMessage:r.trim()}:e.includes(n)?{hasInstructions:!1,instructions:null,userMessage:t}:{hasInstructions:!1,instructions:null,userMessage:t}}function MT(t){const e=t.match(/^\[DELEGATED TASK from boss "([^"]+)" \(([^)]+)\)\]\s*\n\n([\s\S]*?)\n\n---\nThis task was delegated by your boss agent\./);return e?{isDelegatedTask:!0,bossName:e[1],bossId:e[2],taskCommand:e[3].trim()}:{isDelegatedTask:!1,bossName:"",bossId:"",taskCommand:""}}function DT(t){const e=t.match(/^\[TASK REPORT from ([^(]+?)\s*\(([^)]+)\)\]\s*\n\nStatus:\s*(\w+)\nOriginal task:\s*([\s\S]*?)\n(?:\nSummary:\s*([\s\S]*?))?\n\nYou may review/);return e?{isTaskReport:!0,agentName:e[1].trim(),agentId:e[2].trim(),status:e[3].trim(),originalTask:e[4].trim(),summary:(e[5]||"").trim()}:{isTaskReport:!1,agentName:"",agentId:"",status:"",originalTask:"",summary:""}}function RT(t){const e=t.match(/<subagent_notification>\s*([\s\S]*?)\s*<\/subagent_notification>/);if(!e)return{hasNotification:!1,agentId:"",status:{},contentWithoutNotification:t};try{const n=JSON.parse(e[1].trim()),s=n.agent_id||"",a={};if(n.status&&typeof n.status=="object")for(const[i,c]of Object.entries(n.status))a[i]=typeof c=="string"?c:JSON.stringify(c);const r=t.replace(/<subagent_notification>\s*[\s\S]*?<\/subagent_notification>\s*/g,"").trim();return{hasNotification:!0,agentId:s,status:a,contentWithoutNotification:r}}catch{return{hasNotification:!1,agentId:"",status:{},contentWithoutNotification:t}}}function OT(t){const e=t.match(/```delegation\s*\n([\s\S]*?)\n```/);if(!e)return{hasDelegation:!1,delegations:[],contentWithoutBlock:t};try{const n=JSON.parse(e[1].trim()),a=(Array.isArray(n)?n:[n]).map(i=>({selectedAgentId:i.selectedAgentId||"",selectedAgentName:i.selectedAgentName||"Unknown",taskCommand:i.taskCommand||"",reasoning:i.reasoning||"",alternativeAgents:i.alternativeAgents||[],confidence:i.confidence||"medium"})),r=t.replace(/```delegation\s*\n[\s\S]*?\n```/,"").trim();return{hasDelegation:!0,delegations:a,contentWithoutBlock:r}}catch{return{hasDelegation:!1,delegations:[],contentWithoutBlock:t}}}function LT(t){const e=t.match(/```work-plan\s*\n([\s\S]*?)\n```/);if(!e)return{hasWorkPlan:!1,workPlan:null,contentWithoutBlock:t};try{const n=JSON.parse(e[1].trim()),s={name:n.name||"Unnamed Plan",description:n.description||"",phases:(n.phases||[]).map(r=>({id:r.id||"",name:r.name||"",execution:r.execution||"sequential",dependsOn:r.dependsOn||[],tasks:(r.tasks||[]).map(i=>({id:i.id||"",description:i.description||"",suggestedClass:i.suggestedClass||"builder",assignToAgent:i.assignToAgent||null,assignToAgentName:i.assignToAgentName||null,priority:i.priority||"medium",blockedBy:i.blockedBy||[]}))}))},a=t.replace(/```work-plan\s*\n[\s\S]*?\n```/,"").trim();return{hasWorkPlan:!0,workPlan:s,contentWithoutBlock:a}}catch{return{hasWorkPlan:!1,workPlan:null,contentWithoutBlock:t}}}function $p({context:t,defaultCollapsed:e=!0,onFileClick:n}){const{t:s}=dt(["tools"]),[a,r]=x.useState(e),i=ld({onFileClick:n}),c=t.match(/# YOUR TEAM \((\d+) agents?\)/),d=c?parseInt(c[1],10):0;return o.jsxs("div",{className:`boss-context ${a?"collapsed":"expanded"}`,children:[o.jsxs("div",{className:"boss-context-header",onClick:()=>r(!a),children:[o.jsx("span",{className:"boss-context-icon",children:"👑"}),o.jsx("span",{className:"boss-context-label",children:s("tools:bossContext.teamContext",{count:d})}),o.jsx("span",{className:"boss-context-toggle",children:a?"▶":"▼"})]}),!a&&o.jsx("div",{className:"boss-context-content",children:o.jsx(Fr,{remarkPlugins:[zr],components:i,children:t})})]})}function IT({delegation:t}){const{t:e}=dt(["tools"]),n={high:"#22c55e",medium:"#f59e0b",low:"#ef4444"},s={high:"✅",medium:"⚠️",low:"❓"};return o.jsxs("div",{className:"delegation-block",children:[o.jsxs("div",{className:"delegation-header",children:[o.jsx("span",{className:"delegation-icon",children:"📨"}),o.jsx("span",{className:"delegation-title",children:e("tools:delegation.taskDelegated")}),o.jsxs("span",{className:"delegation-confidence",style:{color:n[t.confidence]},children:[s[t.confidence]," ",t.confidence]})]}),o.jsxs("div",{className:"delegation-details",children:[o.jsxs("div",{className:"delegation-target",children:[o.jsx("span",{className:"delegation-label",children:e("tools:delegation.to")}),o.jsx("span",{className:"delegation-agent-name clickable-agent-name",onClick:()=>{U.selectAgent(t.selectedAgentId),U.setTerminalOpen(!0)},children:t.selectedAgentName})]}),t.taskCommand&&o.jsxs("div",{className:"delegation-task-command",children:[o.jsx("span",{className:"delegation-label",children:e("tools:delegation.task")}),o.jsx("span",{className:"delegation-command-text",children:t.taskCommand})]}),t.reasoning&&o.jsxs("div",{className:"delegation-reasoning",children:[o.jsx("span",{className:"delegation-label",children:e("tools:delegation.why")}),o.jsx("span",{className:"delegation-reason-text",children:t.reasoning})]}),t.alternativeAgents.length>0&&o.jsxs("div",{className:"delegation-alternatives",children:[o.jsx("span",{className:"delegation-label",children:e("tools:delegation.alternatives")}),o.jsx("span",{className:"delegation-alt-list",children:t.alternativeAgents.map((a,r)=>o.jsxs("span",{className:"delegation-alt-agent",children:[a.name,a.reason?` (${a.reason})`:""]},a.id||r))})]})]}),o.jsx("div",{className:"delegation-footer",children:o.jsxs("span",{className:"delegation-auto-forward",children:["↗️ ",e("tools:delegation.autoForwarding",{name:t.selectedAgentName})]})})]})}function a6({bossName:t,taskCommand:e}){const{t:n}=dt(["tools"]),[s,a]=x.useState(!1),r=e.length>60?e.slice(0,60)+"...":e;return o.jsxs("div",{className:`delegated-task-header ${s?"expanded":"compact"}`,children:[o.jsxs("div",{className:"delegated-task-badge",onClick:()=>a(!s),children:[o.jsx("span",{className:"delegated-task-icon",children:"👑"}),o.jsxs("span",{className:"delegated-task-label",children:[n("tools:delegation.via")," ",o.jsx("strong",{children:t})]}),o.jsx("span",{className:"delegated-task-toggle",children:s?"▼":"▶"})]}),s&&o.jsx("div",{className:"delegated-task-command",children:e}),!s&&o.jsx("div",{className:"delegated-task-preview",children:r})]})}function PT({bossName:t,bossId:e,taskCommand:n}){const[s,a]=x.useState(!0),r=n.length>80?n.slice(0,80)+"...":n;return o.jsxs("div",{className:`delegated-task-message ${s?"expanded":"compact"}`,children:[o.jsxs("div",{className:"delegated-task-message-badge",onClick:()=>a(!s),children:[o.jsx("span",{className:"delegated-task-message-icon",children:"📋"}),o.jsxs("span",{className:"delegated-task-message-label",children:["Delegated by ",o.jsx("strong",{className:"clickable-agent-name",onClick:i=>{i.stopPropagation(),U.selectAgent(e),U.setTerminalOpen(!0)},children:t})]}),o.jsx("span",{className:"delegated-task-message-id",children:e.slice(0,8)}),o.jsx("span",{className:"delegated-task-message-toggle",children:s?"▼":"▶"})]}),s?o.jsx("div",{className:"delegated-task-message-command",children:n}):o.jsx("div",{className:"delegated-task-message-preview",children:r})]})}function BT({agentName:t,agentId:e,status:n,originalTask:s,summary:a}){const[r,i]=x.useState(!1),c=n==="COMPLETED";return o.jsxs("div",{className:`task-report-header ${r?"expanded":"compact"} status-${c?"completed":"failed"}`,children:[o.jsxs("div",{className:"task-report-badge",onClick:()=>i(!r),children:[o.jsx("span",{className:"task-report-icon",children:c?"✅":"❌"}),o.jsxs("span",{className:"task-report-label",children:[o.jsx("strong",{className:"clickable-agent-name",onClick:d=>{d.stopPropagation(),U.selectAgent(e),U.setTerminalOpen(!0)},children:t})," — Task ",c?"Completed":"Failed"]}),o.jsx("span",{className:"task-report-id",children:e.slice(0,8)}),o.jsx("span",{className:"task-report-toggle",children:r?"▼":"▶"})]}),a&&o.jsx("div",{className:"task-report-summary",children:a}),r&&o.jsx("div",{className:"task-report-details",children:o.jsxs("div",{className:"task-report-original-task",children:[o.jsx("span",{className:"task-report-detail-label",children:"Original task:"}),o.jsx("span",{className:"task-report-detail-value",children:s})]})})]})}function FT({agentId:t,status:e}){const n=Object.entries(e),s=n.some(([d])=>d==="errored"||d==="error"||d==="failed"),a=n.some(([d])=>d==="completed"),r=t.slice(-12),i=n.map(([,d])=>d).join("; "),c=i.replace(/Visit https?:\/\/[^\s]+/g,"").replace(/\s+/g," ").trim();return o.jsxs("div",{className:`subagent-notification ${s?"subagent-notification--error":a?"subagent-notification--completed":"subagent-notification--info"}`,children:[o.jsx("span",{className:"subagent-notification__icon",children:s?"⚠":a?"✓":"🧬"}),o.jsx("span",{className:"subagent-notification__label",children:"Subagent"}),o.jsx("span",{className:"subagent-notification__id",children:r}),o.jsx("span",{className:"subagent-notification__status",children:n.map(([d])=>d).join(", ")}),c&&o.jsx("span",{className:"subagent-notification__message",title:i,children:c})]})}const r6={high:"🔴",medium:"🟡",low:"🟢"},i6={scout:"🔍",builder:"🔨",debugger:"🐛",architect:"📐",warrior:"⚔️",support:"🛡️"};function zT({workPlan:t}){const{t:e}=dt(["tools"]),[n,s]=x.useState(new Set(t.phases.map(i=>i.id))),a=i=>{s(c=>{const d=new Set(c);return d.has(i)?d.delete(i):d.add(i),d})},r=t.phases.reduce((i,c)=>i+c.tasks.length,0);return o.jsxs("div",{className:"work-plan-block",children:[o.jsxs("div",{className:"work-plan-header",children:[o.jsx("span",{className:"work-plan-icon",children:"📋"}),o.jsx("span",{className:"work-plan-title",children:t.name}),o.jsxs("span",{className:"work-plan-stats",children:[e("tools:workPlan.phases",{count:t.phases.length})," · ",e("tools:workPlan.tasks",{count:r})]})]}),t.description&&o.jsx("div",{className:"work-plan-description",children:t.description}),o.jsx("div",{className:"work-plan-phases",children:t.phases.map((i,c)=>o.jsxs("div",{className:`work-plan-phase ${n.has(i.id)?"expanded":"collapsed"}`,children:[o.jsxs("div",{className:"work-plan-phase-header",onClick:()=>a(i.id),children:[o.jsx("span",{className:"work-plan-phase-number",children:c+1}),o.jsx("span",{className:"work-plan-phase-name",children:i.name}),o.jsx("span",{className:`work-plan-phase-execution ${i.execution}`,children:i.execution==="parallel"?`⚡ ${e("tools:workPlan.parallel")}`:`→ ${e("tools:workPlan.sequential")}`}),i.dependsOn.length>0&&o.jsxs("span",{className:"work-plan-phase-depends",children:[e("tools:workPlan.dependsOn")," ",i.dependsOn.join(", ")]}),o.jsx("span",{className:"work-plan-phase-toggle",children:n.has(i.id)?"▼":"▶"})]}),n.has(i.id)&&o.jsx("div",{className:"work-plan-tasks",children:i.tasks.map(d=>o.jsxs("div",{className:`work-plan-task priority-${d.priority}`,children:[o.jsxs("div",{className:"work-plan-task-header",children:[o.jsx("span",{className:"work-plan-task-id",children:d.id}),o.jsx("span",{className:"work-plan-task-priority",title:`Priority: ${d.priority}`,children:r6[d.priority]}),o.jsxs("span",{className:"work-plan-task-class",title:`Suggested: ${d.suggestedClass}`,children:[i6[d.suggestedClass]||"👤"," ",d.suggestedClass]})]}),o.jsx("div",{className:"work-plan-task-description",children:d.description}),o.jsxs("div",{className:"work-plan-task-assignment",children:[o.jsx("span",{className:"work-plan-task-assignment-label",children:e("tools:workPlan.assignedTo")}),o.jsx("span",{className:`work-plan-task-agent ${d.assignToAgentName?"assigned":"auto"}`,children:d.assignToAgentName||e("tools:workPlan.autoAssign")})]}),d.blockedBy.length>0&&o.jsxs("div",{className:"work-plan-task-blocked",children:["⏳ ",e("tools:workPlan.blockedBy")," ",d.blockedBy.join(", ")]})]},d.id))})]},i.id))}),o.jsx("div",{className:"work-plan-footer",children:o.jsxs("span",{className:"work-plan-approval-hint",children:["💡 ",e("tools:workPlan.reviewHint")]})})]})}const o6={id:"dracula",name:"Dracula",description:"Vampire purple with fangs pink",colors:{bgPrimary:"#282a36",bgSecondary:"#21222c",bgTertiary:"#343746",borderColor:"#44475a",textPrimary:"#f8f8f2",textSecondary:"#bfbfbf",textMuted:"#6272a4",accentBlue:"#8be9fd",accentGreen:"#50fa7b",accentOrange:"#ffb86c",accentRed:"#ff5555",accentPurple:"#bd93f9",accentCyan:"#8be9fd",accentClaude:"#50fa7b",accentClaudeLight:"#69ff94",accentPink:"#ff79c6",accentYellow:"#f1fa8c",msgUserBg:"rgba(189, 147, 249, 0.12)",msgUserBorder:"#bd93f9",msgUserText:"#bd93f9",msgAssistantBg:"rgba(255, 121, 198, 0.12)",msgAssistantBorder:"#ff79c6",msgAssistantText:"#ff79c6",toolUseBg:"rgba(255, 184, 108, 0.08)",toolUseBorder:"#ffb86c",toolUseText:"#ffb86c",toolUseName:"#8be9fd",toolResultBg:"rgba(80, 250, 123, 0.08)",toolResultBorder:"#50fa7b",toolResultText:"#50fa7b",outputLineBg:"rgba(189, 147, 249, 0.04)",contextBarBg:"rgba(189, 147, 249, 0.25)",contextBarFill:"#bd93f9",taskLabelColor:"#ff79c6"}},$T={id:"muted",name:"Muted",description:"Foggy dawn through frosted glass",colors:{bgPrimary:"#16181c",bgSecondary:"#1c1f24",bgTertiary:"#24282e",borderColor:"#33393f",textPrimary:"#c8ccd4",textSecondary:"#9099a4",textMuted:"#5c6670",accentBlue:"#7aa8c8",accentGreen:"#8ab898",accentOrange:"#c8a878",accentRed:"#c88888",accentPurple:"#a898b8",accentCyan:"#88b8c0",accentClaude:"#8ab898",accentClaudeLight:"#9ac8a8",accentPink:"#b898a8",accentYellow:"#c8c098",msgUserBg:"rgba(138, 184, 152, 0.06)",msgUserBorder:"rgba(138, 184, 152, 0.3)",msgUserText:"#8ab898",msgAssistantBg:"rgba(168, 152, 184, 0.06)",msgAssistantBorder:"rgba(168, 152, 184, 0.3)",msgAssistantText:"#a898b8",toolUseBg:"rgba(200, 168, 120, 0.05)",toolUseBorder:"rgba(200, 168, 120, 0.3)",toolUseText:"#c8a878",toolUseName:"#88b8c0",toolResultBg:"rgba(136, 184, 192, 0.05)",toolResultBorder:"rgba(136, 184, 192, 0.3)",toolResultText:"#88b8c0",outputLineBg:"rgba(144, 153, 164, 0.03)",contextBarBg:"rgba(168, 152, 184, 0.2)",contextBarFill:"#a898b8",taskLabelColor:"#c8a878"}},l6={id:"muted-red",name:"Rosewood",description:"Aged wine by candlelight",colors:{bgPrimary:"#1a1014",bgSecondary:"#221418",bgTertiary:"#2c1c20",borderColor:"#482830",textPrimary:"#f0e4e8",textSecondary:"#c8b0b8",textMuted:"#8c6878",accentBlue:"#8898c8",accentGreen:"#78a890",accentOrange:"#d8a068",accentRed:"#c85868",accentPurple:"#a878a0",accentCyan:"#88a8b0",accentClaude:"#78a890",accentClaudeLight:"#88b8a0",accentPink:"#d88898",accentYellow:"#d8c088",msgUserBg:"rgba(216, 136, 152, 0.10)",msgUserBorder:"#d88898",msgUserText:"#d88898",msgAssistantBg:"rgba(200, 88, 104, 0.10)",msgAssistantBorder:"#c85868",msgAssistantText:"#c85868",toolUseBg:"rgba(216, 160, 104, 0.08)",toolUseBorder:"#d8a068",toolUseText:"#d8a068",toolUseName:"#d8c088",toolResultBg:"rgba(168, 120, 160, 0.08)",toolResultBorder:"#a878a0",toolResultText:"#a878a0",outputLineBg:"rgba(200, 88, 104, 0.03)",contextBarBg:"rgba(216, 136, 152, 0.25)",contextBarFill:"#d88898",taskLabelColor:"#d8c088"}},c6={id:"nord",name:"Nord",description:"Polar night with aurora",colors:{bgPrimary:"#2e3440",bgSecondary:"#3b4252",bgTertiary:"#434c5e",borderColor:"#4c566a",textPrimary:"#eceff4",textSecondary:"#d8dee9",textMuted:"#7b88a1",accentBlue:"#81a1c1",accentGreen:"#a3be8c",accentOrange:"#d08770",accentRed:"#bf616a",accentPurple:"#b48ead",accentCyan:"#88c0d0",accentClaude:"#a3be8c",accentClaudeLight:"#b3ce9c",accentPink:"#b48ead",accentYellow:"#ebcb8b",msgUserBg:"rgba(136, 192, 208, 0.10)",msgUserBorder:"#88c0d0",msgUserText:"#88c0d0",msgAssistantBg:"rgba(163, 190, 140, 0.10)",msgAssistantBorder:"#a3be8c",msgAssistantText:"#a3be8c",toolUseBg:"rgba(208, 135, 112, 0.08)",toolUseBorder:"#d08770",toolUseText:"#d08770",toolUseName:"#ebcb8b",toolResultBg:"rgba(180, 142, 173, 0.08)",toolResultBorder:"#b48ead",toolResultText:"#b48ead",outputLineBg:"rgba(67, 76, 94, 0.3)",contextBarBg:"rgba(129, 161, 193, 0.25)",contextBarFill:"#81a1c1",taskLabelColor:"#ebcb8b"}},u6={id:"solarized-dark",name:"Solarized",description:"Precision-engineered contrast",colors:{bgPrimary:"#002b36",bgSecondary:"#073642",bgTertiary:"#094652",borderColor:"#586e75",textPrimary:"#93a1a1",textSecondary:"#839496",textMuted:"#657b83",accentBlue:"#268bd2",accentGreen:"#859900",accentOrange:"#cb4b16",accentRed:"#dc322f",accentPurple:"#6c71c4",accentCyan:"#2aa198",accentClaude:"#859900",accentClaudeLight:"#95a910",accentPink:"#d33682",accentYellow:"#b58900",msgUserBg:"rgba(42, 161, 152, 0.12)",msgUserBorder:"#2aa198",msgUserText:"#2aa198",msgAssistantBg:"rgba(133, 153, 0, 0.12)",msgAssistantBorder:"#859900",msgAssistantText:"#859900",toolUseBg:"rgba(203, 75, 22, 0.10)",toolUseBorder:"#cb4b16",toolUseText:"#cb4b16",toolUseName:"#b58900",toolResultBg:"rgba(108, 113, 196, 0.10)",toolResultBorder:"#6c71c4",toolResultText:"#6c71c4",outputLineBg:"rgba(7, 54, 66, 0.5)",contextBarBg:"rgba(38, 139, 210, 0.25)",contextBarFill:"#268bd2",taskLabelColor:"#b58900"}},d6={id:"monokai",name:"Monokai",description:"Neon jungle on warm charcoal",colors:{bgPrimary:"#272822",bgSecondary:"#1e1f1a",bgTertiary:"#3e3d32",borderColor:"#49483e",textPrimary:"#f8f8f2",textSecondary:"#cfcfc2",textMuted:"#75715e",accentBlue:"#66d9ef",accentGreen:"#a6e22e",accentOrange:"#fd971f",accentRed:"#f92672",accentPurple:"#ae81ff",accentCyan:"#66d9ef",accentClaude:"#a6e22e",accentClaudeLight:"#b6f23e",accentPink:"#f92672",accentYellow:"#e6db74",msgUserBg:"rgba(249, 38, 114, 0.10)",msgUserBorder:"#f92672",msgUserText:"#f92672",msgAssistantBg:"rgba(166, 226, 46, 0.10)",msgAssistantBorder:"#a6e22e",msgAssistantText:"#a6e22e",toolUseBg:"rgba(253, 151, 31, 0.08)",toolUseBorder:"#fd971f",toolUseText:"#fd971f",toolUseName:"#66d9ef",toolResultBg:"rgba(174, 129, 255, 0.08)",toolResultBorder:"#ae81ff",toolResultText:"#ae81ff",outputLineBg:"rgba(62, 61, 50, 0.3)",contextBarBg:"rgba(249, 38, 114, 0.25)",contextBarFill:"#f92672",taskLabelColor:"#fd971f"}},f6={id:"gruvbox",name:"Gruvbox",description:"Retro coffee shop warmth",colors:{bgPrimary:"#282828",bgSecondary:"#1d2021",bgTertiary:"#3c3836",borderColor:"#504945",textPrimary:"#ebdbb2",textSecondary:"#d5c4a1",textMuted:"#928374",accentBlue:"#83a598",accentGreen:"#b8bb26",accentOrange:"#fe8019",accentRed:"#fb4934",accentPurple:"#d3869b",accentCyan:"#8ec07c",accentClaude:"#b8bb26",accentClaudeLight:"#c8cb36",accentPink:"#d3869b",accentYellow:"#fabd2f",msgUserBg:"rgba(254, 128, 25, 0.10)",msgUserBorder:"#fe8019",msgUserText:"#fe8019",msgAssistantBg:"rgba(142, 192, 124, 0.10)",msgAssistantBorder:"#8ec07c",msgAssistantText:"#8ec07c",toolUseBg:"rgba(250, 189, 47, 0.08)",toolUseBorder:"#fabd2f",toolUseText:"#fabd2f",toolUseName:"#83a598",toolResultBg:"rgba(211, 134, 155, 0.08)",toolResultBorder:"#d3869b",toolResultText:"#d3869b",outputLineBg:"rgba(60, 56, 54, 0.4)",contextBarBg:"rgba(254, 128, 25, 0.25)",contextBarFill:"#fe8019",taskLabelColor:"#fabd2f"}},p6={id:"atom",name:"Atom",description:"Deep space exploration",colors:{bgPrimary:"#0c1014",bgSecondary:"#121820",bgTertiary:"#1a222c",borderColor:"#283040",textPrimary:"#d8e0f0",textSecondary:"#9ca8c0",textMuted:"#5a6880",accentBlue:"#5dade2",accentGreen:"#58d68d",accentOrange:"#f0b060",accentRed:"#ec7063",accentPurple:"#af7ac5",accentCyan:"#48c9b0",accentClaude:"#58d68d",accentClaudeLight:"#68e69d",accentPink:"#f1948a",accentYellow:"#f7dc6f",msgUserBg:"rgba(93, 173, 226, 0.10)",msgUserBorder:"#5dade2",msgUserText:"#5dade2",msgAssistantBg:"rgba(88, 214, 141, 0.10)",msgAssistantBorder:"#58d68d",msgAssistantText:"#58d68d",toolUseBg:"rgba(240, 176, 96, 0.08)",toolUseBorder:"#f0b060",toolUseText:"#f0b060",toolUseName:"#48c9b0",toolResultBg:"rgba(175, 122, 197, 0.08)",toolResultBorder:"#af7ac5",toolResultText:"#af7ac5",outputLineBg:"rgba(26, 34, 44, 0.5)",contextBarBg:"rgba(175, 122, 197, 0.25)",contextBarFill:"#af7ac5",taskLabelColor:"#f7dc6f"}},h6={id:"cyberpunk",name:"Cyberpunk",description:"Neon noir dystopia",colors:{bgPrimary:"#030308",bgSecondary:"#08080f",bgTertiary:"#101018",borderColor:"#181828",textPrimary:"#e8e8ff",textSecondary:"#a0a0c8",textMuted:"#5050a0",accentBlue:"#00f0ff",accentGreen:"#00ff9f",accentOrange:"#ff6600",accentRed:"#ff003c",accentPurple:"#bf00ff",accentCyan:"#00f0ff",accentClaude:"#00ff9f",accentClaudeLight:"#50ffbf",accentPink:"#ff00aa",accentYellow:"#fff000",msgUserBg:"rgba(255, 0, 170, 0.12)",msgUserBorder:"#ff00aa",msgUserText:"#ff00aa",msgAssistantBg:"rgba(0, 255, 159, 0.10)",msgAssistantBorder:"#00ff9f",msgAssistantText:"#00ff9f",toolUseBg:"rgba(191, 0, 255, 0.10)",toolUseBorder:"#bf00ff",toolUseText:"#bf00ff",toolUseName:"#00f0ff",toolResultBg:"rgba(0, 240, 255, 0.08)",toolResultBorder:"#00f0ff",toolResultText:"#00f0ff",outputLineBg:"rgba(191, 0, 255, 0.03)",contextBarBg:"rgba(255, 0, 170, 0.30)",contextBarFill:"#ff00aa",taskLabelColor:"#fff000"}},m6={id:"synthwave",name:"Synthwave",description:"Sunset over chrome horizon",colors:{bgPrimary:"#241b30",bgSecondary:"#1a1424",bgTertiary:"#2e2540",borderColor:"#4a3860",textPrimary:"#f8e8f8",textSecondary:"#c8a8d0",textMuted:"#7860a0",accentBlue:"#2de2e6",accentGreen:"#0abdc6",accentOrange:"#ff9e64",accentRed:"#ff3864",accentPurple:"#9d4edd",accentCyan:"#2de2e6",accentClaude:"#0abdc6",accentClaudeLight:"#2ad0d8",accentPink:"#f706cf",accentYellow:"#fede5d",msgUserBg:"rgba(247, 6, 207, 0.12)",msgUserBorder:"#f706cf",msgUserText:"#f706cf",msgAssistantBg:"rgba(45, 226, 230, 0.10)",msgAssistantBorder:"#2de2e6",msgAssistantText:"#2de2e6",toolUseBg:"rgba(255, 158, 100, 0.10)",toolUseBorder:"#ff9e64",toolUseText:"#ff9e64",toolUseName:"#fede5d",toolResultBg:"rgba(157, 78, 221, 0.10)",toolResultBorder:"#9d4edd",toolResultText:"#9d4edd",outputLineBg:"rgba(157, 78, 221, 0.05)",contextBarBg:"rgba(247, 6, 207, 0.25)",contextBarFill:"#f706cf",taskLabelColor:"#fede5d"}},g6={id:"abyss",name:"Abyss",description:"Pitch-black void, vivid accents",colors:{bgPrimary:"#08090c",bgSecondary:"#0e1014",bgTertiary:"#16181e",borderColor:"#242830",textPrimary:"#b0b4bc",textSecondary:"#808690",textMuted:"#4c5058",accentBlue:"#3d8ab8",accentGreen:"#3ea868",accentOrange:"#c07848",accentRed:"#b84848",accentPurple:"#8060b0",accentCyan:"#3ca8a8",accentClaude:"#3ea868",accentClaudeLight:"#50b878",accentPink:"#a85880",accentYellow:"#b8a840",msgUserBg:"#181c24",msgUserBorder:"#6a4e96",msgUserText:"#d0d4dc",msgAssistantBg:"#12161e",msgAssistantBorder:"#1c3838",msgAssistantText:"#a0a8b4",toolUseBg:"#161a22",toolUseBorder:"#3a2820",toolUseText:"#989ea8",toolUseName:"#c07848",toolResultBg:"#121824",toolResultBorder:"#202038",toolResultText:"#989ea8",outputLineBg:"#0a0c10",contextBarBg:"rgba(60, 68, 76, 0.25)",contextBarFill:"#4c5460",taskLabelColor:"#c07848"}},b6={id:"obsidian-bloom",name:"Obsidian Bloom",description:"Ultra-dark graphite with subtle cool borders",colors:{bgPrimary:"#050608",bgSecondary:"#0a0b0f",bgTertiary:"#111319",borderColor:"#2a2f3a",textPrimary:"#c4cad4",textSecondary:"#9aa3b1",textMuted:"#67707d",accentBlue:"#8aa3c7",accentGreen:"#82a39a",accentOrange:"#b39479",accentRed:"#ad7d8a",accentPurple:"#9a8fbd",accentCyan:"#86a8b7",accentClaude:"#9ca6c9",accentClaudeLight:"#bcc3df",accentPink:"#aa92bb",accentYellow:"#b8ac8f",msgUserBg:"rgba(21, 26, 35, 0.92)",msgUserBorder:"#4c627f",msgUserText:"#b8c8df",msgAssistantBg:"rgba(22, 20, 32, 0.92)",msgAssistantBorder:"#5d5479",msgAssistantText:"#c2bcdb",toolUseBg:"rgba(28, 23, 20, 0.9)",toolUseBorder:"#6b5646",toolUseText:"#c8b3a1",toolUseName:"#b8ac8f",toolResultBg:"rgba(20, 23, 30, 0.9)",toolResultBorder:"#4e5a73",toolResultText:"#b0bdd2",outputLineBg:"rgba(10, 11, 15, 0.7)",contextBarBg:"rgba(94, 106, 126, 0.22)",contextBarFill:"#6f7f99",taskLabelColor:"#9ea6b8"}},x6={id:"catppuccin",name:"Catppuccin",description:"Cozy pastel mocha cafe",colors:{bgPrimary:"#1e1e2e",bgSecondary:"#181825",bgTertiary:"#313244",borderColor:"#45475a",textPrimary:"#cdd6f4",textSecondary:"#bac2de",textMuted:"#6c7086",accentBlue:"#89b4fa",accentGreen:"#a6e3a1",accentOrange:"#fab387",accentRed:"#f38ba8",accentPurple:"#cba6f7",accentCyan:"#94e2d5",accentClaude:"#a6e3a1",accentClaudeLight:"#b6f3b1",accentPink:"#f5c2e7",accentYellow:"#f9e2af",msgUserBg:"rgba(180, 190, 254, 0.10)",msgUserBorder:"#b4befe",msgUserText:"#b4befe",msgAssistantBg:"rgba(148, 226, 213, 0.10)",msgAssistantBorder:"#94e2d5",msgAssistantText:"#94e2d5",toolUseBg:"rgba(250, 179, 135, 0.08)",toolUseBorder:"#fab387",toolUseText:"#fab387",toolUseName:"#f9e2af",toolResultBg:"rgba(203, 166, 247, 0.08)",toolResultBorder:"#cba6f7",toolResultText:"#cba6f7",outputLineBg:"rgba(49, 50, 68, 0.4)",contextBarBg:"rgba(245, 194, 231, 0.25)",contextBarFill:"#f5c2e7",taskLabelColor:"#fab387"}},y6={id:"github-dark",name:"GitHub Dark",description:"Developer professional minimal",colors:{bgPrimary:"#0d1117",bgSecondary:"#161b22",bgTertiary:"#21262d",borderColor:"#30363d",textPrimary:"#c9d1d9",textSecondary:"#8b949e",textMuted:"#484f58",accentBlue:"#58a6ff",accentGreen:"#3fb950",accentOrange:"#d29922",accentRed:"#f85149",accentPurple:"#a371f7",accentCyan:"#79c0ff",accentClaude:"#3fb950",accentClaudeLight:"#56d364",accentPink:"#f778ba",accentYellow:"#e3b341",msgUserBg:"rgba(88, 166, 255, 0.08)",msgUserBorder:"#58a6ff",msgUserText:"#58a6ff",msgAssistantBg:"rgba(63, 185, 80, 0.08)",msgAssistantBorder:"#3fb950",msgAssistantText:"#3fb950",toolUseBg:"rgba(210, 153, 34, 0.08)",toolUseBorder:"#d29922",toolUseText:"#d29922",toolUseName:"#79c0ff",toolResultBg:"rgba(163, 113, 247, 0.08)",toolResultBorder:"#a371f7",toolResultText:"#a371f7",outputLineBg:"rgba(33, 38, 45, 0.5)",contextBarBg:"rgba(88, 166, 255, 0.25)",contextBarFill:"#58a6ff",taskLabelColor:"#d29922"}},v6={id:"one-dark",name:"One Dark",description:"Moonlit late night coding",colors:{bgPrimary:"#282c34",bgSecondary:"#21252b",bgTertiary:"#2c323c",borderColor:"#3e4451",textPrimary:"#abb2bf",textSecondary:"#828997",textMuted:"#5c6370",accentBlue:"#61afef",accentGreen:"#98c379",accentOrange:"#d19a66",accentRed:"#e06c75",accentPurple:"#c678dd",accentCyan:"#56b6c2",accentClaude:"#98c379",accentClaudeLight:"#a8d389",accentPink:"#e06c75",accentYellow:"#e5c07b",msgUserBg:"rgba(86, 182, 194, 0.10)",msgUserBorder:"#56b6c2",msgUserText:"#56b6c2",msgAssistantBg:"rgba(152, 195, 121, 0.10)",msgAssistantBorder:"#98c379",msgAssistantText:"#98c379",toolUseBg:"rgba(209, 154, 102, 0.08)",toolUseBorder:"#d19a66",toolUseText:"#d19a66",toolUseName:"#e5c07b",toolResultBg:"rgba(198, 120, 221, 0.08)",toolResultBorder:"#c678dd",toolResultText:"#c678dd",outputLineBg:"rgba(44, 50, 60, 0.5)",contextBarBg:"rgba(97, 175, 239, 0.25)",contextBarFill:"#61afef",taskLabelColor:"#d19a66"}},w6={id:"midnight-harbor",name:"Midnight Harbor",description:"Low-glare ocean twilight",colors:{bgPrimary:"#0e141d",bgSecondary:"#151d28",bgTertiary:"#1f2a38",borderColor:"#33465a",textPrimary:"#d9e2ed",textSecondary:"#aebdce",textMuted:"#7f93a8",accentBlue:"#7baed6",accentGreen:"#7fc3b8",accentOrange:"#cfa77f",accentRed:"#c9879c",accentPurple:"#9b9fd1",accentCyan:"#79bccc",accentClaude:"#8ea8d9",accentClaudeLight:"#b2c2e8",accentPink:"#c79fbe",accentYellow:"#d7c28f",msgUserBg:"rgba(123, 174, 214, 0.12)",msgUserBorder:"#7baed6",msgUserText:"#9cc3e2",msgAssistantBg:"rgba(142, 168, 217, 0.12)",msgAssistantBorder:"#8ea8d9",msgAssistantText:"#b2c2e8",toolUseBg:"rgba(207, 167, 127, 0.10)",toolUseBorder:"#cfa77f",toolUseText:"#ddbf9f",toolUseName:"#d7c28f",toolResultBg:"rgba(155, 159, 209, 0.10)",toolResultBorder:"#9b9fd1",toolResultText:"#b9bbe2",outputLineBg:"rgba(31, 42, 56, 0.5)",contextBarBg:"rgba(123, 174, 214, 0.24)",contextBarFill:"#7baed6",taskLabelColor:"#d7c28f"}},k6={id:"ember-noir",name:"Ember Noir",description:"Soft plum dusk with rose-indigo accents",colors:{bgPrimary:"#151118",bgSecondary:"#1d1723",bgTertiary:"#292132",borderColor:"#473b56",textPrimary:"#e7deed",textSecondary:"#c4b4d0",textMuted:"#93839f",accentBlue:"#88a9d6",accentGreen:"#8ab9ad",accentOrange:"#cf9b79",accentRed:"#cb8a9b",accentPurple:"#ae8ec8",accentCyan:"#86b8c6",accentClaude:"#9ca7df",accentClaudeLight:"#bcc3ea",accentPink:"#cd9fbc",accentYellow:"#d5bf93",msgUserBg:"rgba(203, 138, 155, 0.12)",msgUserBorder:"#cb8a9b",msgUserText:"#d7a6b3",msgAssistantBg:"rgba(156, 167, 223, 0.12)",msgAssistantBorder:"#9ca7df",msgAssistantText:"#bcc3ea",toolUseBg:"rgba(213, 191, 147, 0.10)",toolUseBorder:"#d5bf93",toolUseText:"#e0cfad",toolUseName:"#88a9d6",toolResultBg:"rgba(174, 142, 200, 0.10)",toolResultBorder:"#ae8ec8",toolResultText:"#c6aed8",outputLineBg:"rgba(41, 33, 50, 0.52)",contextBarBg:"rgba(203, 138, 155, 0.24)",contextBarFill:"#cb8a9b",taskLabelColor:"#d5bf93"}},S6={id:"classic",name:"Classic",description:"Original transparent style",colors:{bgPrimary:"#0d0d14",bgSecondary:"#14141e",bgTertiary:"#1c1c28",borderColor:"#2a2a3a",textPrimary:"#d0d0d8",textSecondary:"#8a8a98",textMuted:"#5a6a8a",accentBlue:"#5a8fd4",accentGreen:"#50fa7b",accentOrange:"#c89a5a",accentRed:"#c85a5a",accentPurple:"#9a80c0",accentCyan:"#8be9fd",accentClaude:"#50fa7b",accentClaudeLight:"#69ff94",accentPink:"#c87a9a",accentYellow:"#c8c87a",msgUserBg:"rgba(139, 233, 253, 0.12)",msgUserBorder:"transparent",msgUserText:"#8be9fd",msgAssistantBg:"rgba(80, 250, 123, 0.12)",msgAssistantBorder:"transparent",msgAssistantText:"#50fa7b",toolUseBg:"rgba(255, 184, 108, 0.05)",toolUseBorder:"transparent",toolUseText:"#8be9fd",toolUseName:"#ffb86c",toolResultBg:"rgba(80, 250, 123, 0.06)",toolResultBorder:"transparent",toolResultText:"#50fa7b",outputLineBg:"transparent",contextBarBg:"rgba(106, 154, 120, 0.25)",contextBarFill:"#6a9a78",taskLabelColor:"#8be9fd"}},ia=[S6,g6,b6,o6,$T,l6,c6,u6,d6,f6,p6,h6,m6,x6,y6,v6,w6,k6];function Pu(t){return ia.find(e=>e.id===t)||$T}const C6="classic";function Up(t){const e=document.documentElement,{colors:n}=t;e.style.setProperty("--bg-primary",n.bgPrimary),e.style.setProperty("--bg-secondary",n.bgSecondary),e.style.setProperty("--bg-tertiary",n.bgTertiary),e.style.setProperty("--border-color",n.borderColor),e.style.setProperty("--text-primary",n.textPrimary),e.style.setProperty("--text-secondary",n.textSecondary),e.style.setProperty("--text-muted",n.textMuted),e.style.setProperty("--accent-blue",n.accentBlue),e.style.setProperty("--accent-green",n.accentGreen),e.style.setProperty("--accent-orange",n.accentOrange),e.style.setProperty("--accent-red",n.accentRed),e.style.setProperty("--accent-purple",n.accentPurple),e.style.setProperty("--accent-cyan",n.accentCyan),e.style.setProperty("--accent-claude",n.accentClaude),e.style.setProperty("--accent-claude-light",n.accentClaudeLight),e.style.setProperty("--accent-pink",n.accentPink),e.style.setProperty("--accent-yellow",n.accentYellow),e.style.setProperty("--msg-user-bg",n.msgUserBg),e.style.setProperty("--msg-user-border",n.msgUserBorder),e.style.setProperty("--msg-user-text",n.msgUserText),e.style.setProperty("--msg-assistant-bg",n.msgAssistantBg),e.style.setProperty("--msg-assistant-border",n.msgAssistantBorder),e.style.setProperty("--msg-assistant-text",n.msgAssistantText),e.style.setProperty("--tool-use-bg",n.toolUseBg),e.style.setProperty("--tool-use-border",n.toolUseBorder),e.style.setProperty("--tool-use-text",n.toolUseText),e.style.setProperty("--tool-use-name",n.toolUseName),e.style.setProperty("--tool-result-bg",n.toolResultBg),e.style.setProperty("--tool-result-border",n.toolResultBorder),e.style.setProperty("--tool-result-text",n.toolResultText),e.style.setProperty("--output-line-bg",n.outputLineBg),e.style.setProperty("--context-bar-bg",n.contextBarBg),e.style.setProperty("--context-bar-fill",n.contextBarFill),e.style.setProperty("--task-label-color",n.taskLabelColor);try{localStorage.setItem("tide-theme",t.id)}catch{}}function Ey(){try{const t=localStorage.getItem("tide-theme");if(t&&ia.some(e=>e.id===t))return t}catch{}return C6}function A6(){const t=Ey(),e=Pu(t);Up(e)}const j6=x.memo(function({selectedAgent:e,selectedAgentId:n,sortedAgents:s,swipeOffset:a,viewMode:r,setViewMode:i,searchMode:c,toggleSearch:d,closeSearch:f,debugPanelOpen:h,setDebugPanelOpen:m,debuggerEnabled:b,setDebuggerEnabled:y,outputsLength:w,setContextConfirm:C,headerRef:N,isSnapshotView:k=!1,onSaveSnapshot:j,overviewPanelOpen:S=!1,setOverviewPanelOpen:T,agentInfoOpen:D=!1,onToggleAgentInfo:E,isFullscreen:I=!1,onToggleFullscreen:O,onNavigateBack:_,onNavigateForward:M,canNavigateBack:R=!1,canNavigateForward:z=!1,gitPanelOpen:$=!1,setGitPanelOpen:W,buildingsPanelOpen:L=!1,setBuildingsPanelOpen:F,workflowPanelOpen:H=!1,setWorkflowPanelOpen:V,hasWorkflow:G=!1}){var xe,Pe;const{t:B}=dt(["terminal","common"]),K=GO();Vr();const se=Jj(n),q=()=>{const te=Bg.indexOf(r),ge=Bg[(te+1)%Bg.length];i(ge),Wr(pt.VIEW_MODE,ge)},be=()=>{const te=!h;m(te),te&&!b&&(y(!0),vs.setEnabled(!0))},Ce=()=>{c?f():d()},Z=()=>{window.confirm(B("common:confirm.removeAgent",{name:e.name}))&&U.removeAgentFromServer(n)},ie=e.currentTask||e.lastAssignedTask||(se==null?void 0:se.text),me=e.taskLabel||ie,Ee=(xe=K.lastReport)==null?void 0:xe.agentSummaries.find(te=>te.agentId===e.id||te.agentName===e.name),Te={on_track:"#4aff9e",stalled:"#ff9e4a",blocked:"#ff4a4a",completed:"#4a9eff",idle:"#888"},We=(e.class==="boss"||e.isBoss)&&e.subordinateIds&&e.subordinateIds.length>0,ee=pL(n),ne=r1(e.class in _o?null:e.class),Ne=(ne==null?void 0:ne.icon)||((Pe=_o[e.class])==null?void 0:Pe.icon)||"🤖",ze=ur(),st=Se.useMemo(()=>{var te;for(const ge of ze.values())if((te=ge.assignedAgentIds)!=null&&te.includes(n))return ge;return null},[ze,n]),[pe,Be]=x.useState(!1),oe=x.useRef(null),[de,He]=x.useState(!1),[et,ct]=x.useState(!1),[fe,X]=x.useState(()=>Ey()),ae=x.useRef(null),ke=B(r==="simple"?"terminal:header.simpleView":r==="chat"?"terminal:header.chatView":"terminal:header.advancedView"),J=r==="simple"?"○":r==="chat"?"◐":"◉",he=x.useCallback(()=>{Be(!1)},[]),Oe=x.useCallback(()=>{He(!1),ct(!1)},[]),$e=te=>{const ge=Pu(te);Up(ge),X(te)};return x.useEffect(()=>{if(!pe)return;const te=ge=>{oe.current&&!oe.current.contains(ge.target)&&he()};return document.addEventListener("mousedown",te),()=>document.removeEventListener("mousedown",te)},[pe,he]),x.useEffect(()=>{if(!de)return;const te=ge=>{ae.current&&!ae.current.contains(ge.target)&&Oe()};return document.addEventListener("mousedown",te),document.addEventListener("touchstart",te),()=>{document.removeEventListener("mousedown",te),document.removeEventListener("touchstart",te)}},[de,Oe]),o.jsxs("div",{className:`guake-header ${s.length>1?"has-multiple-agents":""} ${a>.1?"swiping-right":""} ${a<-.1?"swiping-left":""}`,ref:N,style:st?{borderBottomColor:`color-mix(in srgb, ${st.color} 50%, var(--border-color))`}:void 0,children:[o.jsxs("div",{className:"guake-header-left",children:[o.jsxs("div",{className:"guake-header-title-row",children:[e.isDetached&&o.jsx(os,{content:o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"tide-tooltip__title",children:"🔄 Reattaching Session..."}),o.jsxs("div",{className:"tide-tooltip__text",children:["This agent's Claude process is running independently. Tide Commander is automatically attempting to reattach to the existing session. If reattachment fails, send a new message to manually resume the session.",o.jsx("br",{}),o.jsx("br",{}),o.jsx("strong",{children:"Status:"})," Recovering session context and output history..."]})]}),position:"bottom",className:"tide-tooltip--detached",children:o.jsx("span",{className:"guake-detached-badge",title:"Agent is detached - reattaching...",children:o.jsx("span",{className:"guake-detached-spinner",children:"🔄"})})}),E?o.jsxs("button",{className:`guake-title-btn ${D?"active":""}`,onClick:E,title:B("terminal:header.showAgentInfo"),children:[o.jsx("span",{className:"guake-agent-avatar",children:Ne}),o.jsxs("span",{className:"guake-title-block",children:[o.jsxs("span",{className:"guake-title-main-row",children:[o.jsx("span",{className:"guake-title",children:e.name}),(e.taskLabel||ie)&&o.jsx("span",{className:"guake-title-task-chip",children:e.taskLabel||ie})]}),me&&o.jsx("span",{className:"guake-mobile-title-context",children:me})]}),o.jsx("span",{className:"guake-title-accessory",children:o.jsx("img",{src:e.provider==="codex"?"/assets/codex.png":e.provider==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:e.provider,className:"guake-provider-icon",title:e.provider==="codex"?"Codex Agent":e.provider==="opencode"?"OpenCode Agent":"Claude Agent"})})]}):o.jsxs("div",{className:"guake-title-with-provider",children:[o.jsx("span",{className:"guake-agent-avatar",children:Ne}),o.jsxs("span",{className:"guake-title-block",children:[o.jsxs("span",{className:"guake-title-main-row",children:[o.jsx("span",{className:"guake-title",children:e.name}),(e.taskLabel||ie)&&o.jsx("span",{className:"guake-title-task-chip",children:e.taskLabel||ie})]}),me&&o.jsx("span",{className:"guake-mobile-title-context",children:me})]}),o.jsx("span",{className:"guake-title-accessory",children:o.jsx("img",{src:e.provider==="codex"?"/assets/codex.png":e.provider==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:e.provider,className:"guake-provider-icon",title:e.provider==="codex"?"Codex Agent":e.provider==="opencode"?"OpenCode Agent":"Claude Agent"})})]})]}),o.jsxs("div",{className:"guake-header-meta",children:[Ee&&o.jsx("span",{className:"guake-status-line",title:`${Ee.statusDescription}
124
- ${Ee.recentWorkSummary}`,children:o.jsx("span",{className:"guake-supervisor-badge",style:{color:Te[Ee.progress]||"#888"},children:Ee.progress.replace("_"," ")})}),ee.filter(te=>te.status==="spawning"||te.status==="working").length>0&&o.jsx("span",{className:"guake-subagents-indicator",children:ee.filter(te=>te.status==="spawning"||te.status==="working").map(te=>o.jsxs("span",{className:"guake-subagent-badge active",title:`${te.name} (${te.subagentType}) - ${te.status}`,children:[o.jsx("span",{className:"guake-subagent-icon",children:"⑂"}),o.jsx("span",{className:"guake-subagent-name",children:te.name})]},te.id))})]})]}),o.jsxs("div",{className:"guake-actions",children:[o.jsxs("div",{className:"guake-action-cluster guake-action-cluster--compact hide-on-mobile",children:[!k&&o.jsxs(o.Fragment,{children:[o.jsx("button",{className:"guake-icon-action guake-nav-btn",onClick:_,title:"Back (Alt+Left)",disabled:!R,children:o.jsx("span",{className:"guake-action-icon",children:"←"})}),o.jsx("button",{className:"guake-icon-action guake-nav-btn",onClick:M,title:"Forward (Alt+Right)",disabled:!z,children:o.jsx("span",{className:"guake-action-icon",children:"→"})})]}),!k&&T&&o.jsx("button",{className:`guake-icon-action guake-overview-toggle ${S?"active":""}`,onClick:()=>T(!S),title:B(S?"terminal:header.hideOverview":"terminal:header.showOverview"),children:o.jsx("span",{className:"guake-action-icon",children:"📊"})}),!k&&W&&o.jsx("button",{className:`guake-icon-action guake-git-toggle ${$?"active":""}`,onClick:()=>W(!$),title:$?"Hide Git Changes":"Show Git Changes",children:o.jsx("span",{className:"guake-action-icon",children:"🌿"})}),!k&&G&&V&&o.jsx("button",{className:`guake-icon-action guake-workflow-toggle ${H?"active":""}`,onClick:()=>V(!H),title:H?"Hide Workflow":"Show Workflow",children:o.jsx("span",{className:"guake-action-icon",children:"🔄"})}),o.jsx("button",{className:`guake-icon-action guake-fullscreen-toggle ${I?"active":""}`,onClick:O,title:B(I?"terminal:header.exitFullscreen":"terminal:header.enterFullscreen"),children:o.jsx("span",{className:"guake-action-icon",children:I?"🗗":"⛶"})}),o.jsx("button",{className:`guake-icon-action guake-search-toggle ${c?"active":""}`,onClick:Ce,title:B("terminal:header.search"),children:o.jsx("span",{className:"guake-action-icon",children:"🔍"})}),o.jsx("button",{className:"guake-icon-action danger",onClick:()=>C("clear"),title:B("terminal:header.clearContext"),children:o.jsx("span",{className:"guake-action-icon",children:"🧹"})})]}),!k&&o.jsxs("div",{className:"guake-desktop-more hide-on-mobile",ref:oe,children:[o.jsx("button",{className:`guake-desktop-more-btn ${pe?"active":""}`,onClick:()=>Be(!pe),title:B("terminal:header.moreActions","More actions"),children:"⋮"}),pe&&o.jsxs("div",{className:"guake-desktop-menu",children:[o.jsxs("button",{className:"guake-desktop-menu-item",onClick:()=>{q(),he()},children:[o.jsx("span",{className:"guake-desktop-menu-icon",children:J}),"View: ",ke]}),j&&w>0&&o.jsxs("button",{className:"guake-desktop-menu-item",onClick:()=>{j(),he()},children:[o.jsx("span",{className:"guake-desktop-menu-icon",children:"⭐"}),B("terminal:header.saveSnapshot")]}),F&&o.jsxs("button",{className:`guake-desktop-menu-item ${L?"active":""}`,onClick:()=>{F(!L),he()},children:[o.jsx("span",{className:"guake-desktop-menu-icon",children:"🏗️"}),L?"Hide Buildings":"Show Buildings"]}),o.jsxs("button",{className:`guake-desktop-menu-item ${h?"active":""}`,onClick:()=>{be(),he()},children:[o.jsx("span",{className:"guake-desktop-menu-icon",children:"🐛"}),B(h?"terminal:header.hideDebug":"terminal:header.showDebug")]}),o.jsx("div",{className:"guake-desktop-menu-divider"}),o.jsxs("button",{className:"guake-desktop-menu-item",onClick:()=>{C("collapse"),he()},disabled:e.status!=="idle",children:[o.jsx("span",{className:"guake-desktop-menu-icon",children:"📦"}),B("terminal:header.collapseContext")]}),We&&o.jsxs("button",{className:"guake-desktop-menu-item danger",onClick:()=>{C("clear-subordinates"),he()},children:[o.jsx("span",{className:"guake-desktop-menu-icon",children:"👑"}),B("terminal:header.clearAllSubordinates")]}),o.jsx("div",{className:"guake-desktop-menu-divider"}),o.jsxs("button",{className:"guake-desktop-menu-item danger",onClick:()=>{Z(),he()},children:[o.jsx("span",{className:"guake-desktop-menu-icon",children:"❌"}),B("terminal:header.removeAgent")]})]})]}),!k&&o.jsxs("div",{className:"guake-mobile-more show-on-mobile",ref:ae,children:[o.jsx("button",{className:`guake-mobile-more-btn ${de?"active":""}`,onClick:()=>He(!de),title:B("terminal:header.moreActions","More actions"),children:"⋮"}),de&&o.jsxs("div",{className:"guake-mobile-menu",children:[o.jsxs("button",{className:"guake-mobile-menu-item",onClick:()=>{_==null||_(),Oe()},disabled:!R,children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"←"}),"Back"]}),o.jsxs("button",{className:"guake-mobile-menu-item",onClick:()=>{M==null||M(),Oe()},disabled:!z,children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"→"}),"Forward"]}),o.jsxs("button",{className:"guake-mobile-menu-item",onClick:()=>{q(),Oe()},children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:r==="simple"?"○":r==="chat"?"◐":"◉"}),B(r==="simple"?"terminal:header.simpleView":r==="chat"?"terminal:header.chatView":"terminal:header.advancedView")]}),w>0&&o.jsxs("button",{className:"guake-mobile-menu-item",onClick:()=>{U.clearOutputs(n),Oe()},children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"🗑"}),B("terminal:header.clearOutput")]}),j&&w>0&&o.jsxs("button",{className:"guake-mobile-menu-item",onClick:()=>{j(),Oe()},children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"⭐"}),B("terminal:header.saveSnapshot")]}),o.jsxs("button",{className:`guake-mobile-menu-item ${I?"active":""}`,onClick:()=>{O==null||O(),Oe()},children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:I?"🗗":"⛶"}),B(I?"terminal:header.exitFullscreen":"terminal:header.enterFullscreen")]}),o.jsxs("button",{className:"guake-mobile-menu-item",onClick:()=>{Ce(),Oe()},children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:c?"✕":"🔍"}),B("terminal:header.search")]}),T&&o.jsxs("button",{className:`guake-mobile-menu-item ${S?"active":""}`,onClick:()=>{T(!S),Oe()},children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"📊"}),B(S?"terminal:header.hideOverview":"terminal:header.showOverview")]}),W&&o.jsxs("button",{className:`guake-mobile-menu-item ${$?"active":""}`,onClick:()=>{W(!$),Oe()},children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"🌿"}),$?"Hide Git Changes":"Show Git Changes"]}),G&&V&&o.jsxs("button",{className:`guake-mobile-menu-item ${H?"active":""}`,onClick:()=>{V(!H),Oe()},children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"🔄"}),H?"Hide Workflow":"Show Workflow"]}),F&&o.jsxs("button",{className:`guake-mobile-menu-item ${L?"active":""}`,onClick:()=>{F(!L),Oe()},children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"🏗️"}),L?"Hide Buildings":"Show Buildings"]}),o.jsxs("button",{className:`guake-mobile-menu-item ${h?"active":""}`,onClick:()=>{be(),Oe()},children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"🐛"}),B(h?"terminal:header.hideDebug":"terminal:header.showDebug")]}),o.jsxs("button",{className:`guake-mobile-menu-item ${et?"active":""}`,onClick:()=>ct(!et),children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"🎨"}),B("terminal:themeSelector.selectTheme"),o.jsx("span",{className:"guake-mobile-theme-arrow",children:et?"▲":"▼"})]}),et&&o.jsx("div",{className:"guake-mobile-theme-list",children:ia.map(te=>o.jsxs("button",{className:`guake-mobile-theme-option ${te.id===fe?"active":""}`,onClick:()=>$e(te.id),children:[o.jsx("span",{className:"guake-mobile-theme-preview",style:{background:`linear-gradient(135deg, ${te.colors.bgPrimary} 0%, ${te.colors.bgSecondary} 50%, ${te.colors.accentPurple} 100%)`}}),o.jsx("span",{className:"guake-mobile-theme-name",children:te.name}),te.id===fe&&o.jsx("span",{className:"guake-mobile-theme-check",children:"✓"})]},te.id))}),o.jsx("div",{className:"guake-mobile-menu-divider"}),o.jsxs("button",{className:"guake-mobile-menu-item",onClick:()=>{C("collapse"),Oe()},disabled:e.status!=="idle",children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"📦"}),B("terminal:header.collapseContext")]}),o.jsxs("button",{className:"guake-mobile-menu-item danger",onClick:()=>{C("clear"),Oe()},children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"🧹"}),B("terminal:header.clearContext")]}),We&&o.jsxs("button",{className:"guake-mobile-menu-item danger",onClick:()=>{C("clear-subordinates"),Oe()},children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"👑🗑️"}),B("terminal:header.clearAllSubordinates")]}),o.jsx("div",{className:"guake-mobile-menu-divider"}),o.jsxs("button",{className:"guake-mobile-menu-item danger",onClick:()=>{Z(),Oe()},children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"❌"}),B("terminal:header.removeAgent")]})]})]}),o.jsx("button",{className:"guake-close-btn show-on-mobile",onClick:()=>U.setMobileView("3d"),title:B("terminal:header.closeTerminal"),children:"✕"})]})]})});function N6({searchInputRef:t,searchQuery:e,setSearchQuery:n,closeSearch:s,matchCount:a,currentMatch:r,navigateNext:i,navigatePrev:c,loadingFullHistory:d}){const{t:f}=dt(["terminal","common"]);return o.jsxs("div",{className:"guake-search",children:[o.jsx("input",{ref:t,type:"text",placeholder:f("terminal:header.searchPlaceholder"),value:e,onChange:h=>n(h.target.value),onKeyDown:h=>{h.key==="Escape"?(h.preventDefault(),s()):h.key==="Enter"&&(h.preventDefault(),h.shiftKey?c():i())}}),e.trim().length>=2&&o.jsx("span",{className:"guake-search-count",children:d?`${a>0?`${r+1} / ${a}`:"..."} loading`:a>0?`${r+1} / ${a}`:f("terminal:header.searchNoResults","No results")}),o.jsx("button",{className:"guake-search-nav",onClick:c,disabled:a===0,title:"Previous match (Shift+Enter)",children:"▲"}),o.jsx("button",{className:"guake-search-nav",onClick:i,disabled:a===0,title:"Next match (Enter)",children:"▼"}),o.jsx("button",{className:"guake-search-close",onClick:s,title:"Close search (Escape)",children:"✕"})]})}function T6({request:t,onApprove:e,onDeny:n}){const{t:s}=dt(["tools"]),a=fs[t.tool]||fs.default,r=c=>t.tool==="Bash"&&c.command?String(c.command):(t.tool==="Write"||t.tool==="Edit"||t.tool==="Read")&&c.file_path?String(c.file_path):t.tool==="WebFetch"&&c.url?String(c.url):t.tool,i=()=>{if(t.tool==="Write"||t.tool==="Edit"){const d=String(t.toolInput.file_path||"").split("/").slice(0,-1).join("/");return s("tools:permission.rememberAllowDir",{dir:d})}if(t.tool==="Bash"){const d=String(t.toolInput.command||"").split(/\s+/)[0];return s("tools:permission.rememberAllowCmd",{cmd:d})}return s("tools:permission.rememberAllowTool",{tool:t.tool})};return t.status!=="pending"?null:o.jsxs("div",{className:"permission-inline",children:[o.jsx("span",{className:"permission-inline-icon",children:a}),o.jsx("span",{className:"permission-inline-tool",children:t.tool}),o.jsx("span",{className:"permission-inline-target",children:r(t.toolInput)}),o.jsx("button",{className:"permission-inline-btn approve-remember",onClick:()=>e(!0),title:i(),children:"✓+"}),o.jsx("button",{className:"permission-inline-btn approve",onClick:()=>e(!1),title:s("tools:permission.approveOnce"),children:"✓"}),o.jsx("button",{className:"permission-inline-btn deny",onClick:n,title:s("tools:permission.deny"),children:"✕"})]})}function Ol(t,e){return e?t.split(new RegExp(`(${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi")).map((s,a)=>s.toLowerCase()===e.toLowerCase()?o.jsx("mark",{className:"search-highlight",children:s},a):s):t}function My(t){const e=Ea();if(t.startsWith("http"))return t;if(t.startsWith("/uploads/"))return`${e}${t}`;if(t.includes("tide-commander-uploads")){const n=t.split("/").pop()||"image";return`${e}/uploads/${n}`}else return t}function UT(t){var s;const e=((s=t.split(".").pop())==null?void 0:s.toLowerCase())||"",n={pdf:"file_type_pdf.svg",doc:"file_type_word.svg",docx:"file_type_word.svg",xls:"file_type_excel.svg",xlsx:"file_type_excel.svg",ppt:"file_type_powerpoint.svg",pptx:"file_type_powerpoint.svg",txt:"file_type_text.svg",md:"file_type_markdown.svg",js:"file_type_javascript_official.svg",jsx:"file_type_javascript_official.svg",ts:"file_type_typescript_official.svg",tsx:"file_type_typescript_official.svg",py:"file_type_python.svg",java:"file_type_java.svg",cpp:"file_type_cpp.svg",c:"file_type_cpp.svg",h:"file_type_cpp.svg",hpp:"file_type_cpp.svg",cs:"file_type_csharp.svg",go:"file_type_go.svg",rs:"file_type_rust.svg",php:"file_type_php.svg",rb:"file_type_ruby.svg",swift:"file_type_swift.svg",kt:"file_type_kotlin.svg",scala:"file_type_scala.svg",r:"file_type_r.svg",html:"file_type_html.svg",htm:"file_type_html.svg",css:"file_type_css.svg",scss:"file_type_scss.svg",sass:"file_type_sass.svg",less:"file_type_less.svg",json:"file_type_json_official.svg",yaml:"file_type_yaml_official.svg",yml:"file_type_yaml_official.svg",xml:"file_type_xml.svg",toml:"file_type_toml.svg",ini:"file_type_ini.svg",env:"file_type_dotenv.svg",sh:"file_type_shell.svg",bash:"file_type_shell.svg",zsh:"file_type_shell.svg",fish:"file_type_shell.svg",png:"file_type_image.svg",jpg:"file_type_image.svg",jpeg:"file_type_image.svg",gif:"file_type_image.svg",svg:"file_type_image.svg",webp:"file_type_image.svg",zip:"file_type_zip.svg",tar:"file_type_tar.svg",gz:"file_type_gzip.svg",rar:"file_type_rar.svg","7z":"file_type_zip.svg",mp3:"file_type_audio.svg",mp4:"file_type_video.svg",wav:"file_type_audio.svg",mov:"file_type_video.svg",mkv:"file_type_video.svg",flv:"file_type_video.svg",avi:"file_type_video.svg",default:"default_file.svg"};return n[e]||n.default}function zl(t,e,n){const s=/\[(Image|File):\s*([^\]]+)\]/g,a=[];let r=0,i;const c=ld({onFileClick:n});for(;(i=s.exec(t))!==null;){if(i.index>r){const m=lp(t.slice(r,i.index));a.push(o.jsx("div",{className:"markdown-content",children:o.jsx(Fr,{remarkPlugins:[zr],components:c,children:m})},`text-${r}`))}const d=i[1]==="Image",f=i[2].trim(),h=f.split("/").pop()||(d?"image":"file");if(d){const m=My(f);a.push(o.jsxs("span",{className:"image-reference clickable",onClick:()=>e==null?void 0:e(m,h),title:On.t("terminal:content.clickToViewImage"),children:[o.jsx("img",{src:m,alt:h,className:"image-reference-thumb"}),h]},`img-${i.index}`))}else{const m=UT(h);a.push(o.jsxs("span",{className:"file-reference clickable",onClick:()=>n==null?void 0:n(f),title:On.t("terminal:content.clickToViewFile",{path:f}),children:[o.jsx("img",{src:`/assets/vscode-icons/${m}`,alt:h,style:{width:"12px",height:"12px",display:"inline",marginRight:"4px"}}),h]},`file-${i.index}`))}r=i.index+i[0].length}if(r<t.length){const d=lp(t.slice(r));a.push(o.jsx("div",{className:"markdown-content",children:o.jsx(Fr,{remarkPlugins:[zr],components:c,children:d})},`text-${r}`))}return a.length===0?o.jsx("div",{className:"markdown-content",children:o.jsx(Fr,{remarkPlugins:[zr],components:c,children:lp(t)})}):o.jsx(o.Fragment,{children:a})}function Bu(t,e,n){const s=/\[(Image|File):\s*([^\]]+)\]/g,a=[];let r=0,i;for(;(i=s.exec(t))!==null;){if(i.index>r){const h=t.slice(r,i.index);a.push(o.jsx("span",{className:"user-prompt-text",children:h},`text-${r}`))}const c=i[1]==="Image",d=i[2].trim(),f=d.split("/").pop()||(c?"image":"file");if(c){const h=My(d);a.push(o.jsxs("span",{className:"image-reference clickable",onClick:()=>e==null?void 0:e(h,f),title:On.t("terminal:content.clickToViewImage"),children:[o.jsx("img",{src:h,alt:f,className:"image-reference-thumb"}),f]},`img-${i.index}`))}else{const h=UT(f);a.push(o.jsxs("span",{className:"file-reference clickable",onClick:()=>n==null?void 0:n(d),title:On.t("terminal:content.clickToViewFile",{path:d}),children:[o.jsx("img",{src:`/assets/vscode-icons/${h}`,alt:f,style:{width:"12px",height:"12px",display:"inline",marginRight:"4px"}}),f]},`file-${i.index}`))}r=i.index+i[0].length}if(r<t.length){const c=t.slice(r);a.push(o.jsx("span",{className:"user-prompt-text",children:c},`text-${r}`))}return a.length===0?o.jsx("span",{className:"user-prompt-text",children:t}):o.jsx(o.Fragment,{children:a})}function _6({id:t,lineCount:e,fullText:n,onRemove:s}){const{t:a}=dt(["tools","common"]),[r,i]=x.useState(!1),c=d=>{d.stopPropagation(),i(!0)};return o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"pasted-text-chip",onClick:c,title:a("tools:pastedText.clickToView"),children:[o.jsx("span",{className:"pasted-text-chip-icon",children:"📋"}),o.jsx("span",{className:"pasted-text-chip-label",children:a("tools:pastedText.pastedNumber",{id:t})}),o.jsx("span",{className:"pasted-text-chip-count",children:a("tools:pastedText.lineCount",{count:e})}),o.jsx("button",{className:"pasted-text-chip-remove",onClick:d=>{d.stopPropagation(),s()},title:a("common:buttons.remove"),children:"×"})]}),r&&o.jsx(E6,{id:t,lineCount:e,content:n,onClose:()=>i(!1)})]})}function E6({id:t,lineCount:e,content:n,onClose:s}){const{t:a}=dt(["tools","common"]),{handleMouseDown:r,handleClick:i}=Ta(s),[c,d]=x.useState(!1),f=async()=>{try{await navigator.clipboard.writeText(n),d(!0),setTimeout(()=>d(!1),2e3)}catch(h){console.error("Failed to copy:",h)}};return o.jsx("div",{className:"modal-overlay visible pasted-text-modal-overlay",onMouseDown:r,onClick:i,children:o.jsxs("div",{className:"modal pasted-text-modal",children:[o.jsxs("div",{className:"pasted-text-modal-header",children:[o.jsxs("div",{className:"pasted-text-modal-title",children:[o.jsx("span",{className:"pasted-text-modal-icon",children:"📋"}),o.jsx("span",{children:a("tools:pastedText.pastedTextTitle",{id:t})}),o.jsx("span",{className:"pasted-text-modal-count",children:a("tools:pastedText.lineCountFull",{count:e})})]}),o.jsxs("div",{className:"pasted-text-modal-actions",children:[o.jsx("button",{className:"btn btn-secondary btn-sm",onClick:f,children:c?`✓ ${a("common:toast.copied")}`:a("common:buttons.copy")}),o.jsx("button",{className:"pasted-text-modal-close",onClick:s,children:"×"})]})]}),o.jsx("div",{className:"pasted-text-modal-body",children:o.jsx("pre",{className:"pasted-text-content",children:n})})]})})}const M6={language:"Spanish",model:"medium"};function HT(t={}){var w;const[e,n]=x.useState(!1),[s,a]=x.useState(!1),[r,i]=x.useState(null),c=x.useRef(null),d=x.useRef([]),f=x.useRef(null),h={...M6,...t},m=x.useCallback(async()=>{i(null);try{if(!window.isSecureContext){console.error("[STT] Not in secure context - microphone requires HTTPS"),i("Microphone requires HTTPS");return}const C=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,sampleRate:16e3}});f.current=C,d.current=[];const N=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus","audio/ogg",""];let k="";for(const T of N)if(!T||MediaRecorder.isTypeSupported(T)){k=T;break}console.log("[STT] Using MIME type:",k||"browser default");const j={};k&&(j.mimeType=k);const S=new MediaRecorder(C,j);S.ondataavailable=T=>{T.data.size>0&&d.current.push(T.data)},c.current=S,S.start(100),n(!0),console.log("[STT] Recording started")}catch(C){console.error("[STT] Failed to start recording:",C),C instanceof Error?C.name==="NotAllowedError"||C.name==="PermissionDeniedError"?i("Microphone permission denied"):C.name==="NotFoundError"||C.name==="DevicesNotFoundError"?i("No microphone found"):C.name==="NotReadableError"||C.name==="TrackStartError"?i("Microphone in use by another app"):C.name==="OverconstrainedError"?i("Microphone constraints not supported"):i(`Microphone error: ${C.message}`):i("Failed to access microphone")}},[]),b=x.useCallback(async()=>!c.current||!e?null:new Promise(C=>{const N=c.current;N.onstop=async()=>{var S,T;f.current&&(f.current.getTracks().forEach(D=>D.stop()),f.current=null);const k=((S=d.current[0])==null?void 0:S.type)||"audio/webm",j=new Blob(d.current,{type:k});if(d.current=[],console.log("[STT] Recording stopped, audio size:",j.size),j.size<1e3){i("Recording too short"),n(!1),C(null);return}a(!0);try{const D=await D6(j);console.log("[STT] Sending audio for transcription...");const I=await(await Bt(Rt("/api/stt/transcribe"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({audio:D,language:h.language,model:h.model})})).json();I.success&&I.text?(console.log("[STT] Transcription:",I.text),(T=h.onTranscription)==null||T.call(h,I.text),C(I.text)):(console.error("[STT] Transcription failed:",I.error),i(I.error||"Transcription failed"),C(null))}catch(D){console.error("[STT] Failed to transcribe:",D),i("Failed to transcribe audio"),C(null)}finally{a(!1)}n(!1)},N.stop()}),[e,h]),y=x.useCallback(async()=>e?b():(await m(),null),[e,m,b]);return{recording:e,transcribing:s,error:r,startRecording:m,stopRecording:b,toggleRecording:y,supported:typeof navigator<"u"&&!!((w=navigator.mediaDevices)!=null&&w.getUserMedia)&&typeof MediaRecorder<"u"}}function D6(t){return new Promise((e,n)=>{const s=new FileReader;s.onloadend=()=>{const a=s.result.split(",")[1];e(a)},s.onerror=n,s.readAsDataURL(t)})}const R6=x.memo(function({agentId:e,isWorking:n,timestamp:s}){const{t:a}=dt(["terminal"]),[r,i]=x.useState(0);return x.useEffect(()=>{if(!n||!s){i(0);return}i(Date.now()-s);const c=setInterval(()=>{i(Date.now()-s)},1e3);return()=>clearInterval(c)},[n,s]),n?o.jsxs("div",{className:"guake-stop-bar",children:[o.jsx("span",{className:"guake-elapsed-timer",children:WT(r)}),o.jsxs("button",{className:"guake-stop-btn",onClick:()=>U.stopAgent(e),title:a("terminal:input.stopOperation"),children:[o.jsx("span",{className:"stop-icon",children:"■"}),o.jsx("span",{className:"stop-label",children:a("terminal:input.stop")})]})]}):null});function RA(t){const e={pdf:"file_type_pdf.svg",doc:"file_type_word.svg",docx:"file_type_word.svg",xls:"file_type_excel.svg",xlsx:"file_type_excel.svg",ppt:"file_type_powerpoint.svg",pptx:"file_type_powerpoint.svg",txt:"file_type_text.svg",md:"file_type_markdown.svg",js:"file_type_javascript_official.svg",jsx:"file_type_javascript_official.svg",ts:"file_type_typescript_official.svg",tsx:"file_type_typescript_official.svg",py:"file_type_python.svg",java:"file_type_java.svg",cpp:"file_type_cpp.svg",c:"file_type_cpp.svg",h:"file_type_cpp.svg",hpp:"file_type_cpp.svg",cs:"file_type_csharp.svg",go:"file_type_go.svg",rs:"file_type_rust.svg",php:"file_type_php.svg",rb:"file_type_ruby.svg",swift:"file_type_swift.svg",kt:"file_type_kotlin.svg",scala:"file_type_scala.svg",r:"file_type_r.svg",html:"file_type_html.svg",htm:"file_type_html.svg",css:"file_type_css.svg",scss:"file_type_scss.svg",sass:"file_type_sass.svg",less:"file_type_less.svg",json:"file_type_json_official.svg",yaml:"file_type_yaml_official.svg",yml:"file_type_yaml_official.svg",xml:"file_type_xml.svg",toml:"file_type_toml.svg",ini:"file_type_ini.svg",env:"file_type_dotenv.svg",sh:"file_type_shell.svg",bash:"file_type_shell.svg",zsh:"file_type_shell.svg",fish:"file_type_shell.svg",png:"file_type_image.svg",jpg:"file_type_image.svg",jpeg:"file_type_image.svg",gif:"file_type_image.svg",svg:"file_type_image.svg",webp:"file_type_image.svg",zip:"file_type_zip.svg",tar:"file_type_tar.svg",gz:"file_type_gzip.svg",rar:"file_type_rar.svg","7z":"file_type_zip.svg",mp3:"file_type_audio.svg",mp4:"file_type_video.svg",wav:"file_type_audio.svg",mov:"file_type_video.svg",mkv:"file_type_video.svg",flv:"file_type_video.svg",avi:"file_type_video.svg",default:"default_file.svg"};return e[t.toLowerCase()]||e.default}function WT(t){const e=Math.floor(t/1e3),n=Math.floor(e/60),s=e%60;return`${n}:${s.toString().padStart(2,"0")}`}const OA=72,O6=128,L6=x.memo(function({selectedAgent:e,selectedAgentId:n,isOpen:s,command:a,setCommand:r,forceTextarea:i,setForceTextarea:c,useTextarea:d,attachedFiles:f,setAttachedFiles:h,removeAttachedFile:m,uploadFile:b,pastedTexts:y,expandPastedTexts:w,incrementPastedCount:C,setPastedTexts:N,resetPastedCount:k,handleInputFocus:j,handleInputBlur:S,pendingPermissions:T,showCompletion:D,completionElapsed:E,onImageClick:I,inputRef:O,textareaRef:_,isSnapshotView:M=!1,onClearHistory:R,onSendCommand:z,canSwipeClose:$=!1,onSwipeCloseOffsetChange:W,onSwipeClose:L}){const{t:F}=dt(["terminal","common"]),H=x.useRef(null),V=x.useRef(null),G=O||H,B=_||V,K=x.useRef(null),se=x.useRef(null),q=x.useRef(d),be=x.useRef(0),Ce=x.useRef(null),Z=x.useRef({isTracking:!1,startY:0,startX:0}),[ie,me]=x.useState(0),[Ee,Te]=x.useState("idle"),Ve=Vr(),We=Jj(n),ee=e.status==="working",ne=x.useCallback(()=>{const te=K.current,ge=d?B.current:G.current;te==null||te.focus({preventScroll:!0}),ge==null||ge.focus({preventScroll:!0})},[G,B,d]),{recording:Ne,transcribing:ze,toggleRecording:st}=HT({language:"Spanish",model:"medium",onTranscription:te=>{te.trim()&&n&&U.sendCommand(n,te.trim())}}),pe=x.useCallback(()=>{Ce.current&&(clearTimeout(Ce.current),Ce.current=null)},[]),Be=x.useCallback((te="idle")=>{pe(),me(0),Te(te),W==null||W(0),te==="returning"&&(Ce.current=setTimeout(()=>{Te("idle"),Ce.current=null},160))},[pe,W]),oe=x.useCallback(te=>{if(!$||!L||window.innerWidth>768||te.touches.length!==1)return;pe();const ge=te.touches[0];Z.current={isTracking:!0,startY:ge.clientY,startX:ge.clientX},Te("idle"),me(0),W==null||W(0)},[$,L,pe,W]),de=x.useCallback(te=>{if(!Z.current.isTracking)return;const ge=te.touches[0],ve=ge.clientY-Z.current.startY,Fe=Math.abs(ge.clientX-Z.current.startX);if(Fe>48&&Fe>Math.abs(ve)){Z.current.isTracking=!1,Be("returning");return}if(ve>=0){me(0),Te("idle");return}const Ke=Math.min(O6,Math.abs(ve));Ke>8&&te.preventDefault(),me(Ke),Te("dragging"),W==null||W(Ke)},[Be,W]),He=x.useCallback(()=>{if(Z.current.isTracking){if(Z.current.isTracking=!1,!$||!L){Be("returning");return}if(ie>=OA){L();return}Be("returning")}},[$,L,ie,Be,W]),et=x.useCallback(()=>{Z.current.isTracking=!1,Be("returning")},[Be]);x.useEffect(()=>()=>pe(),[pe]),x.useEffect(()=>{$||(Z.current.isTracking=!1,Be("idle"))},[$,Be]);const ct=te=>{be.current=te.target.selectionStart||te.target.value.length,r(te.target.value)};x.useEffect(()=>{const te=B.current;if(!te||!d)return;const ve=window.innerWidth<=768?200:180;requestAnimationFrame(()=>{te.style.height="0px",te.style.overflow="hidden";const Fe=te.scrollHeight,Ke=Math.max(46,Math.min(Fe,ve));te.style.height=`${Ke}px`,te.style.overflow=Ke>=ve?"auto":"hidden"})},[a,d]),x.useEffect(()=>{q.current!==d&&(q.current=d,requestAnimationFrame(()=>{const te=be.current;d&&B.current?(ne(),B.current.setSelectionRange(te,te)):!d&&G.current&&(ne(),G.current.setSelectionRange(te,te))}))},[ne,G,B,d]);const fe=x.useRef(!1);x.useEffect(()=>{const te=fe.current;fe.current=s;const ge=typeof window<"u"&&window.matchMedia("(pointer: coarse)").matches,ve=U.consumeSwipeSelectionFlag(),Fe=U.consumeDirectClickSelectionFlag();if(s&&(!te||n)&&!(ge&&(ve||Fe))){const at=setTimeout(()=>{ne()},50);return()=>clearTimeout(at)}},[s,ne,n]);const X=te=>{const ge=new RegExp(`\\[Pasted text #${te} \\+\\d+ lines\\]\\s*`,"g");r(a.replace(ge,"").trim()),N(ve=>{const Fe=new Map(ve);return Fe.delete(te),Fe})},ke=(()=>{const te=/\[Pasted text #(\d+) \+(\d+) lines\]/g,ge=[];let ve;for(;(ve=te.exec(a))!==null;)ge.push({id:parseInt(ve[1],10),lineCount:parseInt(ve[2],10)});return ge})(),J=()=>{var ve,Fe;if(!a.trim()&&f.length===0||!n)return;if(a.trim()==="/clear"&&f.length===0){U.clearContext(n),R(),r(""),c(!1),N(new Map),h([]),k();return}let te=w(a.trim());if(f.length>0){const Ke=f.map(at=>at.isImage?`[Image: ${at.path}]`:`[File: ${at.path}]`).join(`
125
- `);te?te=`${te}
126
-
127
- ${Ke}`:te=Ke}U.sendCommand(n,te),z==null||z(),r(""),c(!1),N(new Map),h([]),k(),window.innerWidth<=768&&((ve=G.current)==null||ve.blur(),(Fe=B.current)==null||Fe.blur())},he=te=>{const ge=window.innerWidth<=768;if(te.key==="Enter"){if(ge){d||(te.preventDefault(),c(!0),setTimeout(()=>{r(a+`
128
- `)},0));return}if(te.shiftKey){d||(te.preventDefault(),c(!0));return}te.preventDefault(),J()}},Oe=te=>{},$e=te=>{te.button===1&&(te.preventDefault(),te.stopPropagation())},xe=async te=>{const ge=te.clipboardData.items;for(const it of ge){if(it.type.startsWith("image/")){te.preventDefault();const gt=it.getAsFile();if(gt){const ht=await b(gt);ht&&h(Gt=>[...Gt,ht])}return}if(it.kind==="file"){te.preventDefault();const gt=it.getAsFile();if(gt){const ht=await b(gt);ht&&h(Gt=>[...Gt,ht])}return}}const ve=te.clipboardData.files;if(ve.length>0){te.preventDefault();for(const it of ve){const gt=await b(it);gt&&h(ht=>[...ht,gt])}return}const Fe=te.clipboardData.getData("text"),Ke=!Fe.includes(`
129
- `),at=/^[/~][^\s]*$|^[A-Za-z]:\\[^\s]*$/.test(Fe.trim()),ft=/\.[a-zA-Z0-9]{1,5}$/.test(Fe.trim());if(Ke&&at&&ft){te.preventDefault();try{const it=await fetch("/api/files/by-path",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Fe.trim()})});if(it.ok){const gt=await it.blob(),ht=Fe.trim().split(/[/\\]/).pop()||"file",Gt=await b(gt,ht);Gt&&h(tn=>[...tn,Gt]);return}}catch{}r(a+Fe);return}const wt=(Fe.match(/\n/g)||[]).length+1;if(wt>5){te.preventDefault();const it=C();N(Ye=>new Map(Ye).set(it,Fe));const gt=`[Pasted text #${it} +${wt} lines]`,ht=te.target,Gt=ht.selectionStart||0,tn=ht.selectionEnd||0,Ae=a.slice(0,Gt)+gt+a.slice(tn),Le=Gt+gt.length;be.current=Le,r(Ae),d?requestAnimationFrame(()=>{B.current&&B.current.setSelectionRange(Le,Le)}):c(!0)}},Pe=async te=>{const ge=te.target.files;if(ge){for(const ve of ge){const Fe=await b(ve);Fe&&h(Ke=>[...Ke,Fe])}se.current&&(se.current.value="")}};return o.jsxs(o.Fragment,{children:[T.length>0&&o.jsx("div",{className:"permission-bar",children:T.map(te=>o.jsx(T6,{request:te,onApprove:ge=>U.respondToPermissionRequest(te.id,!0,void 0,ge),onDeny:()=>U.respondToPermissionRequest(te.id,!1)},te.id))}),ke.length>0&&o.jsx("div",{className:"guake-pasted-texts",children:ke.map(({id:te,lineCount:ge})=>{const ve=y.get(te)||"";return o.jsx(_6,{id:te,lineCount:ge,fullText:ve,onRemove:()=>X(te)},te)})}),f.length>0&&o.jsx("div",{className:"guake-attachments",children:f.map(te=>{var Ke;const ge=te.isImage?My(te.path):null,ve=((Ke=te.name.split(".").pop())==null?void 0:Ke.toLowerCase())||"",Fe=["pdf","doc","docx","xls","xlsx","ppt","pptx"].includes(ve);return o.jsxs("div",{className:`guake-attachment ${te.isImage?"is-image clickable":""} ${Fe?"is-document":""}`,onClick:()=>{te.isImage&&I(ge,te.name)},children:[te.isImage&&ge?o.jsx("img",{src:ge,alt:te.name,className:"guake-attachment-thumb"}):o.jsx("img",{src:`/assets/vscode-icons/${RA(ve)}`,alt:te.name,className:"guake-attachment-icon",style:{width:"24px",height:"24px"}}),o.jsxs("div",{className:"guake-attachment-info",children:[o.jsxs("div",{className:"guake-attachment-name-row",children:[o.jsx("img",{src:`/assets/vscode-icons/${RA(ve)}`,alt:ve,className:"guake-attachment-type-icon",style:{width:"11px",height:"11px"}}),o.jsx("span",{className:"guake-attachment-name",title:te.path,children:te.name})]}),o.jsxs("span",{className:"guake-attachment-size",children:["(",Math.round(te.size/1024),"KB)"]})]}),o.jsx("button",{className:"guake-attachment-remove",onClick:at=>{at.stopPropagation(),m(te.id)},title:F("terminal:input.removeAttachment"),children:"×"})]},te.id)})}),o.jsx("div",{className:`guake-input-wrapper ${e.status==="working"?"has-stop-btn is-working":""} ${D?"is-completed":""} ${M?"is-snapshot-view":""}`,children:o.jsxs("div",{className:`guake-input-swipe-shell ${Ee!=="idle"?"swipe-close-active":""} ${ie>=OA?"swipe-close-ready":""}`,onTouchStart:oe,onTouchMove:de,onTouchEnd:He,onTouchCancel:et,children:[!M&&(()=>{const te=e.contextStats,ge=te?te.totalTokens:e.contextUsed||0,ve=te?te.contextWindow:e.contextLimit||2e5,Fe=te?te.usedPercent:Math.round(ge/ve*100),Ke=Math.max(0,Math.min(100,Fe)),at=Math.max(0,100-Ke),ft=Ke>=80?"#ff4a4a":Ke>=60?"#ff9e4a":Ke>=40?"#ffd700":"#4aff9e",wt=(ge/1e3).toFixed(1),it=(ve/1e3).toFixed(1);return o.jsxs("div",{className:"mobile-context-bar show-on-mobile",onClick:()=>U.setContextModalAgentId(n),children:[o.jsx("span",{className:"mobile-context-bar-fill",style:{width:`${Math.min(100,Ke)}%`,backgroundColor:ft}}),o.jsxs("span",{className:"mobile-context-bar-text",children:[o.jsxs("span",{style:{color:ft},children:[wt,"k/",it,"k"]}),o.jsxs("span",{className:"mobile-context-bar-pct",children:["(",at,"% free)"]})]})]})})(),o.jsx(R6,{agentId:n,isWorking:ee,timestamp:We==null?void 0:We.timestamp}),D&&E!==null&&o.jsx("div",{className:"guake-completion-time",children:WT(E)}),o.jsxs("div",{className:`guake-input ${d?"guake-input-expanded":""}`,children:[o.jsx("input",{ref:se,type:"file",multiple:!0,onChange:Pe,style:{display:"none"},accept:"*"}),o.jsxs("div",{ref:K,className:"guake-input-container",tabIndex:-1,onAuxClick:$e,children:[o.jsx("button",{className:"guake-attach-btn",onClick:()=>{var te;return(te=se.current)==null?void 0:te.click()},title:F("terminal:input.attachOrPaste"),children:"📎"}),Ve.experimentalTTS&&o.jsx("button",{className:`guake-mic-btn ${Ne?"recording":""} ${ze?"transcribing":""}`,onClick:st,title:F(Ne?"terminal:input.stopRecording":ze?"terminal:input.transcribing":"terminal:input.voiceInput"),disabled:ze,children:ze?"⏳":Ne?"🔴":"🎤"}),d?o.jsx("textarea",{ref:B,placeholder:F("terminal:input.placeholder",{agent:e.name}),value:a,onChange:ct,onKeyDown:he,onPaste:xe,onMouseDown:Oe,onFocus:j,onBlur:S}):o.jsx("input",{ref:G,type:"text",placeholder:F("terminal:input.placeholder",{agent:e.name}),value:a,onChange:ct,onKeyDown:he,onPaste:xe,onMouseDown:Oe,onFocus:j,onBlur:S}),o.jsx("button",{onClick:J,disabled:!a.trim()&&f.length===0,title:F("terminal:input.send"),children:"➤"})]})]})]})})]})});function I6({agent:t,content:e,isOpen:n,onClose:s}){const{t:a}=dt(["tools","common","terminal"]),r=x.useCallback(()=>{navigator.clipboard.writeText(e)},[e]),{handleMouseDown:i,handleClick:c}=Ta(s);return n?o.jsx(pr,{children:o.jsx("div",{className:"modal-overlay visible",onMouseDown:i,onClick:c,children:o.jsxs("div",{className:"modal agent-response-modal",children:[o.jsxs("div",{className:"modal-header agent-response-modal-header",children:[o.jsxs("div",{className:"agent-response-modal-title",children:[o.jsx("span",{className:"agent-response-modal-icon",children:"📝"}),o.jsxs("span",{children:[t.name," - ",a("terminal:modals.rawOutput")]})]}),o.jsx("button",{className:"agent-response-modal-close",onClick:s,title:a("common:buttons.close"),children:"×"})]}),o.jsx("div",{className:"modal-body agent-response-modal-body",children:e?o.jsx("pre",{className:"agent-response-raw",children:e}):o.jsxs("div",{className:"agent-response-empty",children:[o.jsx("span",{className:"agent-response-empty-icon",children:"📭"}),o.jsx("span",{children:a("tools:response.noContent")})]})}),o.jsxs("div",{className:"modal-footer agent-response-modal-footer",children:[o.jsx("button",{className:"btn btn-primary",onClick:r,children:a("common:buttons.copy")}),o.jsx("button",{className:"btn btn-secondary",onClick:s,children:a("common:buttons.close")})]})]})})}):null}function P6({url:t,name:e,onClose:n}){const{handleMouseDown:s,handleClick:a}=Ta(n);return o.jsx(pr,{children:o.jsx("div",{className:"image-modal-overlay",onMouseDown:s,onClick:a,children:o.jsxs("div",{className:"image-modal",children:[o.jsxs("div",{className:"image-modal-header",children:[o.jsx("span",{className:"image-modal-title",children:e}),o.jsx("button",{className:"image-modal-close",onClick:n,children:"×"})]}),o.jsx("div",{className:"image-modal-content",children:o.jsx("img",{src:t,alt:e})})]})})})}function B6({state:t,onClose:e}){const{t:n}=dt(["terminal","common"]),{handleMouseDown:s,handleClick:a}=Ta(e);return o.jsx(pr,{children:o.jsx("div",{className:"bash-modal-overlay",onMouseDown:s,onClick:a,children:o.jsxs("div",{className:"bash-modal",children:[o.jsxs("div",{className:"bash-modal-header",children:[o.jsx("span",{className:"bash-modal-icon",children:"$"}),o.jsx("span",{className:"bash-modal-title",children:n("terminal:modals.terminalOutput")}),o.jsx("button",{className:"bash-modal-close",onClick:e,children:"×"})]}),o.jsx("div",{className:"bash-modal-command",children:o.jsx("pre",{dangerouslySetInnerHTML:{__html:Mo(t.command,"bash")}})}),o.jsx("div",{className:`bash-modal-content ${t.isLive?"is-loading":""}`,children:o.jsx("pre",{dangerouslySetInnerHTML:{__html:Kl(t.output)}})})]})})})}function F6({action:t,selectedAgentId:e,subordinateCount:n,onClose:s,onClearHistory:a}){const{t:r}=dt(["terminal","common"]),{handleMouseDown:i,handleClick:c}=Ta(s),d=()=>{e&&(t==="collapse"?U.collapseContext(e):t==="clear-subordinates"?U.clearAllSubordinatesContext(e):(U.clearContext(e),a())),s()},f=()=>r(t==="collapse"?"terminal:modals.collapseContext":t==="clear-subordinates"?"terminal:modals.clearAllSubordinatesContext":"terminal:modals.clearContext");return o.jsx(pr,{children:o.jsx("div",{className:"modal-overlay visible guake-context-confirm-overlay",onMouseDown:i,onClick:c,children:o.jsxs("div",{className:"modal confirm-modal guake-context-confirm-modal",children:[o.jsx("div",{className:"modal-header",children:f()}),o.jsx("div",{className:"modal-body confirm-modal-body",children:t==="collapse"?o.jsxs(o.Fragment,{children:[o.jsx("p",{children:r("terminal:modals.collapseConfirm")}),o.jsx("p",{className:"confirm-modal-note",children:r("terminal:modals.collapseNote")})]}):t==="clear-subordinates"?o.jsxs(o.Fragment,{children:[o.jsx("p",{children:r("terminal:modals.clearSubordinatesConfirm",{count:n})}),o.jsx("p",{className:"confirm-modal-note",children:r("terminal:modals.clearSubordinatesNote")})]}):o.jsxs(o.Fragment,{children:[o.jsx("p",{children:r("terminal:modals.clearConfirm")}),o.jsx("p",{className:"confirm-modal-note",children:r("terminal:modals.clearNote")})]})}),o.jsxs("div",{className:"modal-footer",children:[o.jsx("button",{className:"btn btn-secondary",onClick:s,children:r("common:buttons.cancel")}),o.jsx("button",{className:`btn ${t==="clear"||t==="clear-subordinates"?"btn-danger":"btn-primary"}`,onClick:d,autoFocus:!0,children:r(t==="collapse"?"common:buttons.collapse":t==="clear-subordinates"?"terminal:modals.clearAll":"terminal:modals.clearContext")})]})]})})})}function z6(){const t=Vx(),e=ed(),n=t?e.get(t):null;return n?o.jsx(y1,{agent:n,isOpen:!!t,onClose:()=>U.closeContextModal(),onRefresh:()=>{t&&U.refreshAgentContext(t)}}):null}function $6(){const t=qx(),e=XO(),n=JO();return t?o.jsx(MN,{isOpen:!!t,onClose:()=>U.clearFileViewerPath(),filePath:t,action:e?"modified":"read",editData:e||void 0,searchRoot:n||void 0}):null}function U6({agent:t,content:e,onClose:n}){return t?o.jsx(I6,{agent:t,content:e||"",isOpen:!!e,onClose:n}):null}function LA(t){if(!t)return"N/A";try{return new Date(t).toLocaleString()}catch{return"N/A"}}function H6({agent:t,isOpen:e,onClose:n}){var S,T,D,E,I;const{t:s}=dt(["terminal","common"]),{handleMouseDown:a,handleClick:r}=Ta(n),i=tL((t==null?void 0:t.id)||null),c=r1((t==null?void 0:t.class)||null);if(!e||!t)return null;const d=t.provider==="codex"?t.codexModel||"gpt-5.3-codex":t.provider==="opencode"?t.opencodeModel||"minimax/MiniMax-M1-80k":t.model||"sonnet",f=((S=c==null?void 0:c.instructions)==null?void 0:S.trim())||"",h=((T=t.customInstructions)==null?void 0:T.trim())||"",m=f.length>0,b=h.length>0,y=m||b,w=m&&b,C=[f,h].filter(Boolean).join(`
130
-
131
- `),N=Math.max(1,((D=t.contextStats)==null?void 0:D.contextWindow)||t.contextLimit||2e5),k=((E=t.contextStats)==null?void 0:E.totalTokens)||t.contextUsed||0,j=((I=t.contextStats)==null?void 0:I.usedPercent)||Math.round(k/N*100);return o.jsx(pr,{children:o.jsx("div",{className:"agent-info-modal-overlay",onMouseDown:a,onClick:r,children:o.jsxs("div",{className:"agent-info-modal",children:[o.jsxs("div",{className:"agent-info-modal-header",children:[o.jsxs("div",{className:"agent-info-modal-title",children:[o.jsx("span",{className:"icon",children:"ℹ️"}),o.jsx("span",{children:s("terminal:agentInfo.title",{name:t.name})})]}),o.jsx("button",{className:"agent-info-modal-close",onClick:n,children:"×"})]}),o.jsxs("div",{className:"agent-info-modal-body",children:[o.jsxs("section",{className:"agent-info-section",children:[o.jsx("h4",{children:s("terminal:agentInfo.runtime")}),o.jsxs("div",{className:"agent-info-grid",children:[o.jsxs("div",{className:"agent-info-item",children:[o.jsx("span",{children:s("terminal:agentInfo.backend")}),o.jsxs("strong",{children:[o.jsx("img",{src:t.provider==="codex"?"/assets/codex.png":t.provider==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:t.provider,className:"agent-info-provider-icon",title:t.provider==="codex"?"Codex Agent":t.provider==="opencode"?"OpenCode Agent":"Claude Agent"}),t.provider==="codex"?"Codex":t.provider==="opencode"?"OpenCode":"Claude"]})]}),o.jsxs("div",{className:"agent-info-item",children:[o.jsx("span",{children:s("terminal:agentInfo.model")}),o.jsx("strong",{children:d})]}),o.jsxs("div",{className:"agent-info-item",children:[o.jsx("span",{children:s("terminal:agentInfo.status")}),o.jsx("strong",{children:t.status})]}),o.jsxs("div",{className:"agent-info-item",children:[o.jsx("span",{children:s("terminal:agentInfo.class")}),o.jsx("strong",{children:t.class})]}),o.jsxs("div",{className:"agent-info-item",children:[o.jsx("span",{children:s("terminal:agentInfo.permission")}),o.jsx("strong",{children:t.permissionMode})]}),o.jsxs("div",{className:"agent-info-item",children:[o.jsx("span",{children:s("terminal:agentInfo.session")}),o.jsx("strong",{children:t.sessionId||s("terminal:agentInfo.notStarted")})]})]})]}),o.jsxs("section",{className:"agent-info-section",children:[o.jsx("h4",{children:s("terminal:agentInfo.promptAndInstructions")}),o.jsxs("div",{className:"agent-info-prompts",children:[w&&o.jsxs("div",{className:"agent-info-prompt-block",children:[o.jsx("span",{children:s("terminal:agentInfo.customPrompt")}),o.jsx("pre",{children:C})]}),!y&&o.jsxs("div",{className:"agent-info-prompt-block",children:[o.jsx("span",{children:s("terminal:agentInfo.customPrompt")}),o.jsx("strong",{className:"warn",children:s("terminal:agentInfo.notConfigured")})]}),o.jsxs("div",{className:"agent-info-prompt-block",children:[o.jsx("span",{children:s("terminal:agentInfo.classPrompt")}),m?o.jsx("pre",{children:f}):o.jsx("strong",{children:s("terminal:agentInfo.none")})]}),o.jsxs("div",{className:"agent-info-prompt-block",children:[o.jsx("span",{children:s("terminal:agentInfo.agentPrompt")}),b?o.jsx("pre",{children:h}):o.jsx("strong",{children:s("terminal:agentInfo.none")})]})]})]}),o.jsxs("section",{className:"agent-info-section",children:[o.jsx("h4",{children:s("terminal:agentInfo.skills",{count:i.length})}),i.length===0?o.jsx("div",{className:"agent-info-empty",children:s("terminal:agentInfo.noSkills")}):o.jsx("div",{className:"agent-info-skills",children:i.map(O=>o.jsxs("div",{className:"agent-info-skill",children:[o.jsx("div",{className:"agent-info-skill-name",children:O.name}),o.jsx("div",{className:"agent-info-skill-desc",children:O.description})]},O.id))})]}),o.jsxs("section",{className:"agent-info-section",children:[o.jsx("h4",{children:s("terminal:agentInfo.diagnostics")}),o.jsxs("div",{className:"agent-info-grid",children:[o.jsxs("div",{className:"agent-info-item",children:[o.jsx("span",{children:s("terminal:agentInfo.context")}),o.jsxs("strong",{children:[k.toLocaleString()," / ",N.toLocaleString()," (",j,"%)"]})]}),o.jsxs("div",{className:"agent-info-item",children:[o.jsx("span",{children:s("terminal:agentInfo.tasksSent")}),o.jsx("strong",{children:t.taskCount})]}),o.jsxs("div",{className:"agent-info-item",children:[o.jsx("span",{children:s("terminal:agentInfo.workingDir")}),o.jsx("strong",{children:t.cwd})]}),o.jsxs("div",{className:"agent-info-item",children:[o.jsx("span",{children:s("terminal:agentInfo.lastActivity")}),o.jsx("strong",{children:LA(t.lastActivity)})]}),o.jsxs("div",{className:"agent-info-item",children:[o.jsx("span",{children:s("terminal:agentInfo.created")}),o.jsx("strong",{children:LA(t.createdAt)})]}),o.jsxs("div",{className:"agent-info-item",children:[o.jsx("span",{children:s("terminal:agentInfo.detached")}),o.jsx("strong",{children:t.isDetached?s("terminal:agentInfo.yes"):s("terminal:agentInfo.no")})]})]})]})]})]})})})}function W6(t){return t.isDirectory?"":jp[t.extension]||jp.default}function ph(t){return jp[t]||jp.default}function lV(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function q6(t,e){if(!e)return null;const n=t.toLowerCase().indexOf(e.toLowerCase());return n===-1?null:{start:n,end:n+e.length}}function jb(t){if(t.length===0)return[];const e={isDirectory:!0,children:[],fileCount:0};for(const r of t){const i=r.path.split("/");let c=e;for(let d=0;d<i.length-1;d++){const f=i[d],h=i.slice(0,d+1).join("/");let m=c.children.find(b=>b.isDirectory&&b.name===f);m||(m={name:f,path:h,isDirectory:!0,children:[],fileCount:0},c.children.push(m)),c=m}c.children.push({name:r.name,path:r.path,isDirectory:!1,file:r,children:[],fileCount:1})}function n(r){for(r.children=r.children.map(n);r.isDirectory&&r.children.length===1&&r.children[0].isDirectory;){const i=r.children[0];r.name=r.name?r.name+"/"+i.name:i.name,r.path=i.path,r.children=i.children}return r}function s(r){return r.isDirectory?(r.fileCount=r.children.reduce((i,c)=>i+s(c),0),r.fileCount):1}function a(r){return[...r].sort((i,c)=>i.isDirectory&&!c.isDirectory?-1:!i.isDirectory&&c.isDirectory?1:i.name.toLowerCase().localeCompare(c.name.toLowerCase())).map(i=>(i.isDirectory&&(i.children=a(i.children)),i))}return e.children=e.children.map(n),s(e),e.children=a(e.children),e.children}function V6(t,e){for(const n of t)n.isDirectory&&(e.add(n.path),V6(n.children,e))}function Y6(t){var i;const e=t.split(`
132
- `),n=[];let s=null,a=0,r=0;for(const c of e){if(c.startsWith("diff --git")||c.startsWith("index ")||c.startsWith("--- ")||c.startsWith("+++ ")||c.startsWith("new file mode")||c.startsWith("deleted file mode")||c.startsWith("old mode")||c.startsWith("new mode")||c.startsWith("similarity index")||c.startsWith("rename from")||c.startsWith("rename to")||c.startsWith("Binary files"))continue;const d=c.match(/^@@\s+-(\d+)(?:,(\d+))?\s+\+(\d+)(?:,(\d+))?\s+@@(.*)$/);if(d){s={header:((i=d[5])==null?void 0:i.trim())||"",oldStart:parseInt(d[1],10),oldCount:parseInt(d[2]??"1",10),newStart:parseInt(d[3],10),newCount:parseInt(d[4]??"1",10),lines:[]},a=s.oldStart,r=s.newStart,n.push(s);continue}if(s){if(c.startsWith("+"))s.lines.push({type:"added",content:c.slice(1),newNum:r}),r++;else if(c.startsWith("-"))s.lines.push({type:"removed",content:c.slice(1),oldNum:a}),a++;else if(c.startsWith(" ")||c==="")s.lines.push({type:"context",content:c.startsWith(" ")?c.slice(1):c,oldNum:a,newNum:r}),a++,r++;else if(c.startsWith("\\"))continue}}return n}function G6(t,e){const n=t.split(`
133
- `),s=e.split(`
134
- `),a=n.length,r=s.length,i=Array(a+1).fill(null).map(()=>Array(r+1).fill(0));for(let w=1;w<=a;w++)for(let C=1;C<=r;C++)n[w-1]===s[C-1]?i[w][C]=i[w-1][C-1]+1:i[w][C]=Math.max(i[w-1][C],i[w][C-1]);const c=[];let d=a,f=r;for(;d>0||f>0;)d>0&&f>0&&n[d-1]===s[f-1]?(c.push({type:"equal",origIdx:d-1,modIdx:f-1}),d--,f--):f>0&&(d===0||i[d][f-1]>=i[d-1][f])?(c.push({type:"insert",modIdx:f-1}),f--):d>0&&(c.push({type:"delete",origIdx:d-1}),d--);c.reverse();const h=[],m=[];let b=0,y=0;for(const w of c)if(w.type==="equal"){const C=n[w.origIdx];h.push({num:w.origIdx+1,text:C,type:"unchanged"}),m.push({num:w.modIdx+1,text:C,type:"unchanged"})}else if(w.type==="delete"){const C=n[w.origIdx];h.push({num:w.origIdx+1,text:C,type:"removed"}),y++}else{const C=s[w.modIdx];m.push({num:w.modIdx+1,text:C,type:"added"}),b++}return{leftLines:h,rightLines:m,stats:{added:b,removed:y}}}function qT({content:t,onFileClick:e}){const{t:n}=dt(["tools","common","terminal"]),s=x.useRef(null),a=x.useRef(null),r=x.useRef(null),i=x.useCallback(c=>{const d=s.current,f=a.current;if(!d||!f||r.current&&r.current!==c)return;r.current=c;const h=c==="left"?d:f,m=c==="left"?f:d;m.scrollTop=h.scrollTop,m.scrollLeft=h.scrollLeft,requestAnimationFrame(()=>{r.current=null})},[]);x.useEffect(()=>{const c=s.current,d=a.current;if(!c||!d)return;const f=()=>i("left"),h=()=>i("right");return c.addEventListener("scroll",f),d.addEventListener("scroll",h),()=>{c.removeEventListener("scroll",f),d.removeEventListener("scroll",h)}},[i]);try{const c=JSON.parse(t),{file_path:d,old_string:f,new_string:h,replace_all:m,unified_diff:b}=c;if(!d)return o.jsx("pre",{className:"output-input-content",children:t});const y=d.split("/").pop()||d;if(b){const k=Y6(b),j={added:0,removed:0};for(const S of k)for(const T of S.lines)T.type==="added"&&j.added++,T.type==="removed"&&j.removed++;return o.jsxs("div",{className:"edit-tool-diff",children:[o.jsxs("div",{className:"edit-tool-header",children:[o.jsx("span",{className:"edit-tool-file clickable",onClick:()=>e==null?void 0:e(d,{oldString:f||"",newString:h||"",unifiedDiff:b}),title:n("terminal:history.openFileWithDiff",{path:d}),children:y}),o.jsx("span",{className:"edit-tool-path",children:d}),o.jsxs("div",{className:"edit-tool-stats",children:[j.added>0&&o.jsxs("span",{className:"edit-stat added",children:["+",j.added]}),j.removed>0&&o.jsxs("span",{className:"edit-stat removed",children:["-",j.removed]})]}),m&&o.jsx("span",{className:"edit-tool-badge",children:n("tools:diff.replaceAll")})]}),o.jsxs("div",{className:"edit-tool-unified",children:[k.map((S,T)=>o.jsxs("div",{className:"diff-hunk",children:[o.jsxs("div",{className:"diff-hunk-header",children:[o.jsxs("span",{className:"diff-hunk-range",children:["@@ -",S.oldStart,",",S.oldCount," +",S.newStart,",",S.newCount," @@"]}),S.header&&o.jsx("span",{className:"diff-hunk-context",children:S.header})]}),S.lines.map((D,E)=>o.jsxs("div",{className:`diff-line diff-line-${D.type}`,children:[o.jsx("span",{className:"diff-line-num diff-line-num-old",children:D.type!=="added"?D.oldNum:""}),o.jsx("span",{className:"diff-line-num diff-line-num-new",children:D.type!=="removed"?D.newNum:""}),o.jsx("span",{className:"diff-line-marker",children:D.type==="added"?"+":D.type==="removed"?"-":" "}),o.jsx("span",{className:"diff-line-content",children:D.content||" "})]},E))]},T)),k.length===0&&o.jsx("div",{className:"diff-empty",children:"No changes detected"})]})]})}const{leftLines:w,rightLines:C,stats:N}=G6(f||"",h||"");return o.jsxs("div",{className:"edit-tool-diff",children:[o.jsxs("div",{className:"edit-tool-header",children:[o.jsx("span",{className:"edit-tool-file clickable",onClick:()=>e==null?void 0:e(d,{oldString:f||"",newString:h||""}),title:n("terminal:history.openFileWithDiff",{path:d}),children:y}),o.jsx("span",{className:"edit-tool-path",children:d}),o.jsxs("div",{className:"edit-tool-stats",children:[N.added>0&&o.jsxs("span",{className:"edit-stat added",children:["+",N.added]}),N.removed>0&&o.jsxs("span",{className:"edit-stat removed",children:["-",N.removed]})]}),m&&o.jsx("span",{className:"edit-tool-badge",children:n("tools:diff.replaceAll")})]}),o.jsxs("div",{className:"edit-tool-panels",children:[o.jsxs("div",{className:"edit-panel edit-panel-original",children:[o.jsx("div",{className:"edit-panel-header",children:o.jsx("span",{className:"edit-panel-label",children:n("tools:diff.original")})}),o.jsxs("div",{className:"edit-panel-content",ref:s,children:[w.map((k,j)=>o.jsxs("div",{className:`edit-line edit-line-${k.type}`,children:[o.jsx("span",{className:"edit-line-num",children:k.num}),o.jsx("span",{className:"edit-line-content",children:k.text||" "})]},j)),w.length===0&&o.jsxs("div",{className:"edit-line edit-line-empty",children:[o.jsx("span",{className:"edit-line-num",children:"-"}),o.jsx("span",{className:"edit-line-content edit-empty-text",children:n("common:status.empty")})]})]})]}),o.jsxs("div",{className:"edit-panel edit-panel-modified",children:[o.jsx("div",{className:"edit-panel-header",children:o.jsx("span",{className:"edit-panel-label",children:n("tools:diff.modified")})}),o.jsxs("div",{className:"edit-panel-content",ref:a,children:[C.map((k,j)=>o.jsxs("div",{className:`edit-line edit-line-${k.type}`,children:[o.jsx("span",{className:"edit-line-num",children:k.num}),o.jsx("span",{className:"edit-line-content",children:k.text||" "})]},j)),C.length===0&&o.jsxs("div",{className:"edit-line edit-line-empty",children:[o.jsx("span",{className:"edit-line-num",children:"-"}),o.jsx("span",{className:"edit-line-content edit-empty-text",children:n("common:status.empty")})]})]})]})]})]})}catch{return o.jsx("pre",{className:"output-input-content",children:t})}}function VT({content:t,onFileClick:e}){try{const n=JSON.parse(t),{file_path:s,offset:a,limit:r}=n;if(!s)return o.jsx("pre",{className:"output-input-content",children:t});const i=s.split("/").pop()||s,c=a!==void 0&&r!==void 0,d=()=>{c?e==null||e(s,{highlightRange:{offset:a,limit:r}}):e==null||e(s)};return o.jsxs("div",{className:"read-tool-input",children:[o.jsxs("span",{className:"read-tool-file clickable",onClick:d,title:`Open ${s}${c?" (with highlighted lines)":""}`,children:["📄 ",i]}),o.jsx("span",{className:"read-tool-path",children:s}),(a!==void 0||r!==void 0)&&o.jsxs("span",{className:"read-tool-range",children:[a!==void 0&&`offset: ${a}`,a!==void 0&&r!==void 0&&", ",r!==void 0&&`limit: ${r}`]})]})}catch{return o.jsx("pre",{className:"output-input-content",children:t})}}function Hp({content:t}){const{t:e}=dt(["tools"]);try{const s=JSON.parse(t).todos;if(!Array.isArray(s)||s.length===0)return o.jsx("pre",{className:"output-input-content",children:t});const a={completed:s.filter(r=>r.status==="completed").length,in_progress:s.filter(r=>r.status==="in_progress").length,pending:s.filter(r=>r.status==="pending").length};return o.jsxs("div",{className:"todo-tool-input",children:[o.jsxs("div",{className:"todo-tool-header",children:[o.jsxs("span",{className:"todo-tool-title",children:["📋 ",e("tools:todoList.title")]}),o.jsxs("div",{className:"todo-tool-stats",children:[a.completed>0&&o.jsxs("span",{className:"todo-stat completed",children:["✓ ",a.completed]}),a.in_progress>0&&o.jsxs("span",{className:"todo-stat in-progress",children:["► ",a.in_progress]}),a.pending>0&&o.jsxs("span",{className:"todo-stat pending",children:["○ ",a.pending]})]})]}),o.jsx("div",{className:"todo-tool-list",children:s.map((r,i)=>o.jsxs("div",{className:`todo-item todo-${r.status}`,children:[o.jsx("span",{className:"todo-status-icon",children:r.status==="completed"?"✓":r.status==="in_progress"?"►":"○"}),o.jsx("span",{className:"todo-content",children:r.content})]},i))})]})}catch{return o.jsx("pre",{className:"output-input-content",children:t})}}function YT({content:t}){const[e,n]=x.useState(null);try{const a=JSON.parse(t).questions;return!Array.isArray(a)||a.length===0?o.jsx("pre",{className:"output-input-content",children:t}):o.jsx("div",{className:"ask-question-input",children:a.map((r,i)=>o.jsxs("div",{className:"ask-question-block",children:[o.jsxs("div",{className:"ask-question-header",children:[r.header&&o.jsx("span",{className:"ask-question-badge",children:r.header}),o.jsx("span",{className:"ask-question-text",children:r.question}),r.multiSelect&&o.jsx("span",{className:"ask-question-multi",children:"multi"})]}),r.options&&r.options.length>0&&o.jsx("div",{className:"ask-question-options",children:r.options.map((c,d)=>{const f=i*100+d,h=e===f;return o.jsxs("div",{className:`ask-question-option ${h?"expanded":""}`,onClick:()=>n(h?null:f),children:[o.jsxs("div",{className:"ask-option-row",children:[o.jsx("span",{className:"ask-option-number",children:d+1}),o.jsx("span",{className:"ask-option-label",children:c.label}),c.markdown&&o.jsx("span",{className:"ask-option-preview-hint",children:h?"▼":"▶"})]}),c.description&&o.jsx("div",{className:"ask-option-desc",children:c.description}),c.markdown&&h&&o.jsx("pre",{className:"ask-option-markdown",children:c.markdown})]},d)})})]},i))})}catch{return o.jsx("pre",{className:"output-input-content",children:t})}}function Sx({content:t}){const[e,n]=x.useState(!1);try{const s=JSON.parse(t),a=typeof s.plan=="string"?s.plan.trim():"";if(!a)return o.jsx("pre",{className:"output-input-content",children:t});const r=a.match(/^#+\s+(.+)$/m),i=((r==null?void 0:r[1])||a.split(`
135
- `).find(c=>c.trim().length>0)||"Plan ready").trim();return o.jsxs("div",{className:"plan-tool-input",children:[o.jsxs("div",{className:"plan-tool-header",children:[o.jsx("span",{className:"plan-tool-title",children:"🗺 Plan"}),o.jsx("button",{type:"button",className:"plan-tool-toggle",onClick:()=>n(c=>!c),title:e?"Collapse plan":"Expand plan",children:e?"▼ Hide":"▶ Show"})]}),e?o.jsx("div",{className:"plan-tool-markdown markdown-content",children:o.jsx(Fr,{remarkPlugins:[zr],children:a})}):o.jsx("div",{className:"plan-tool-collapsed-preview",children:i})]})}catch{return o.jsx("pre",{className:"output-input-content",children:t})}}function K6(t){return Array.isArray(t)?t.map(e=>String(e).trim()).filter(e=>e.length>0):typeof t=="string"?t.split(",").map(e=>e.trim()).filter(e=>e.length>0):[]}function Q6(t){return Object.entries(t).filter(([,e])=>e!==void 0).map(([e,n])=>({key:e,value:typeof n=="string"?n:JSON.stringify(n)}))}function GT(t){const e=t.match(/(?:^|[\s,;])select\s*:\s*([^\n;]+)/i),n=t.match(/(?:^|[\s,;])fallback\s*:\s*([^\n;]+)/i),s=t.match(/(?:^|[\s,;])(?:show|show_hide|hide)\s*:\s*([^\n;]+)/i);return{selectedTools:e?e[1].split(",").map(r=>r.trim()).filter(Boolean):[],fallback:n?n[1].trim():null,showHide:s?s[1].trim():null}}function X6(t){const e=typeof t.tool=="string"?t.tool.toLowerCase():"",n=typeof t.type=="string"?t.type.toLowerCase():"",s=typeof t.label=="string"?t.label.toLowerCase():"";let a=K6(t.select??t.selected??t.selected_tools??t.tools),r=t.fallback??t.use_fallback??t.fallbackMode,i=t.show??t.show_hide??t.showHidden??t.hide;const c=t.query_params??t.query??t.params??t.arguments,d=Object.values(t).filter(b=>typeof b=="string").map(b=>b).join(" ; "),f=GT(d);if(a.length===0&&f.selectedTools.length>0&&(a=f.selectedTools),r===void 0&&f.fallback!==null&&(r=f.fallback),i===void 0&&f.showHide!==null&&(i=f.showHide),!(e.includes("toolsearch")||n.includes("toolsearch")||s.includes("toolsearch")||a.length>0||c!==void 0))return null;const m=c&&typeof c=="object"&&!Array.isArray(c)?Q6(c):[];return{selectedTools:a,fallback:r!==void 0?String(r):null,showHide:i!==void 0?String(i):null,queryParams:m}}function J6(t){const e=GT(t),n=t.match(/(?:^|\s)(?:query|params|query_params)\s*:\s*(.+)$/i);if(e.selectedTools.length===0&&!n)return null;const s=[];return n&&n[1].split(/[;,]/).map(a=>a.trim()).filter(Boolean).forEach(a=>{const r=a.match(/^([^:=]+)\s*[:=]\s*(.+)$/);r?s.push({key:r[1].trim(),value:r[2].trim()}):s.push({key:"query",value:a})}),{selectedTools:e.selectedTools,fallback:e.fallback,showHide:e.showHide,queryParams:s}}function KT(t){try{const e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return X6(e)}catch{}return J6(t)}function QT(t){return KT(t)!==null}function Wp({content:t,agentName:e}){const[n,s]=x.useState(!1),a=KT(t);if(!a)return o.jsx("pre",{className:"output-input-content",children:t});const r=a.selectedTools.length>0?a.selectedTools.slice(0,4).join(", "):"-",c=a.selectedTools.length>4?`${r} +${a.selectedTools.length-4}`:r;return o.jsxs("div",{className:"toolsearch-input",children:[o.jsxs("div",{className:"toolsearch-header",children:[o.jsx("span",{className:"toolsearch-badge",children:"⚡ ToolSearch"}),e&&o.jsx("span",{className:"toolsearch-agent",children:e}),o.jsxs("span",{className:"toolsearch-meta-pill",children:["Tools: ",c]}),o.jsxs("span",{className:"toolsearch-meta-pill",children:["Fallback: ",a.fallback??"-"]}),o.jsxs("span",{className:"toolsearch-meta-pill",children:["Show/Hide: ",a.showHide??"-"]}),o.jsx("button",{type:"button",className:"toolsearch-toggle",onClick:()=>s(d=>!d),title:n?"Hide details":"Show details",children:n?"▼ Hide":"▶ Show"})]}),n?o.jsxs("div",{className:"toolsearch-query-block",children:[o.jsx("div",{className:"toolsearch-tools",children:a.selectedTools.length>0?a.selectedTools.map(d=>o.jsx("span",{className:"toolsearch-tool-chip",children:d},d)):o.jsx("span",{className:"toolsearch-empty",children:"No selected tools"})}),o.jsx("div",{className:"toolsearch-query-title",children:"Query Parameters"}),a.queryParams.length>0?o.jsx("div",{className:"toolsearch-query-list",children:a.queryParams.map((d,f)=>o.jsxs("div",{className:"toolsearch-query-row",children:[o.jsx("span",{className:"toolsearch-query-key",children:d.key}),o.jsx("span",{className:"toolsearch-query-value",children:d.value})]},`${d.key}-${f}`))}):o.jsx("div",{className:"toolsearch-empty",children:"No query parameters provided"})]}):o.jsx("div",{className:"toolsearch-preview",children:"Collapsed"})]})}function IA({toolName:t,content:e}){const[n,s]=x.useState(!1);if(!e||e.trim()==="{}")return null;const a=e.length>220?`${e.slice(0,220)}...`:e;return o.jsxs("div",{className:"unknown-tool-input",children:[o.jsx("div",{className:"unknown-tool-header",children:o.jsx("button",{type:"button",className:"unknown-tool-toggle",onClick:()=>s(r=>!r),title:n?"Collapse details":"Expand details",children:n?"▼ Hide":"▶ Show"})}),n?o.jsx("pre",{className:"output-input-content",children:e}):o.jsx("pre",{className:"unknown-tool-preview",children:a})]})}function Dy(){const[t,e]=x.useState(!1),n=x.useRef(null),s=x.useCallback(async i=>{if(!i.trim()){console.warn("[TTS] No text to speak");return}n.current&&(n.current.pause(),n.current=null),console.log("[TTS] Requesting audio from server (auto-detect language):",i.substring(0,100)+"..."),e(!0);try{const c=await Bt(Rt("/api/tts/speak"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:i})});if(!c.ok){const m=await c.json();console.error("[TTS] Server error:",m),e(!1);return}const d=await c.blob(),f=URL.createObjectURL(d),h=new Audio(f);n.current=h,h.onended=()=>{e(!1),URL.revokeObjectURL(f),n.current=null},h.onerror=m=>{console.error("[TTS] Audio playback error:",m),e(!1),URL.revokeObjectURL(f),n.current=null},await h.play(),console.log("[TTS] Playing audio in browser")}catch(c){console.error("[TTS] Failed to get audio:",c),e(!1)}},[]),a=x.useCallback(()=>{n.current&&(n.current.pause(),n.current=null),e(!1)},[]),r=x.useCallback(i=>{console.log("[TTS] Toggle called, currently speaking:",t),t?a():s(i)},[t,s,a]);return{speak:s,stop:a,toggle:r,speaking:t,supported:!0}}function Z6(t){const e=t.split("/").pop()||t,n=e.lastIndexOf(".");return n<=0?"":e.slice(n).toLowerCase()}function e5(t){const e=t.content.slice(0,50),n=`H${t.type[0].toUpperCase()}`;let s=0;for(let a=0;a<e.length;a++)s=(s<<5)-s+e.charCodeAt(a),s|=0;return`${n}:${(s>>>0).toString(16).slice(0,6)}`}const XT=x.memo(function({message:e,agentId:n,highlight:s,simpleView:a,onImageClick:r,onFileClick:i,onBashClick:c,onViewMarkdown:d}){var Te,Ve;const{t:f}=dt(["tools","common","terminal"]),[h,m]=x.useState(new Set),[b,y]=x.useState(!1),w=e1(),C=Vr(),{type:N,content:k,toolName:j,timestamp:S,_bashOutput:T,_bashCommand:D}=e,E=Tu(k,w),{toggle:I,speaking:O}=Dy(),_=ld({onFileClick:i?We=>i(We):void 0}),M=n?(Te=U.getState().agents.get(n))==null?void 0:Te.name:null,R=n?(Ve=U.getState().agents.get(n))==null?void 0:Ve.provider:void 0,z=R==="codex"?"Codex":R==="opencode"?"OpenCode":"Claude",W=N==="tool_use"&&(j==="Task"||j==="Agent")&&e.toolInput&&(e.toolInput.name||e.toolInput.description)||null||M,L=S?Fp(new Date(S).getTime()):"",F=S?new Date(S).getTime():0,H=e5(e);if(N==="assistant"&&!E.trim())return o.jsxs("div",{className:"output-line output-empty-message",children:[L&&o.jsx("span",{className:"output-timestamp",title:`${F} | ${H}`,children:L}),o.jsxs("span",{className:"history-role",children:[R&&o.jsx("img",{src:R==="codex"?"/assets/codex.png":R==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:"",className:"history-role-icon"}),z]}),o.jsx("span",{className:"empty-message-label",children:f("terminal:history.emptyMessage","empty message")})]});if(E.startsWith("This session is being continued from a previous conversation that ran out of context"))return o.jsxs("div",{className:`output-line output-session-continuation ${b?"expanded":""}`,onClick:()=>y(!b),title:f("terminal:history.clickToExpandCollapse"),children:[L&&o.jsx("span",{className:"output-timestamp",title:`${F} | ${H}`,children:L}),o.jsx("span",{className:"session-continuation-icon",children:"🔗"}),o.jsx("span",{className:"session-continuation-label",children:f("tools:display.sessionContinued")}),o.jsx("span",{className:"session-continuation-toggle",children:b?"▼":"▶"}),b&&o.jsx("div",{className:"session-continuation-content",children:o.jsx(Fr,{remarkPlugins:[zr],components:_,children:E})})]});const G=E.trimStart().startsWith(nx),B=!G&&E.includes("<local-command-stdout>")&&E.includes("Context Usage");if(!G&&(E.includes("## Context Usage")||E.includes("Context Usage")&&E.includes("Tokens:")&&E.includes("Free space")||B)){const We=E.match(/<local-command-stdout>([\s\S]*?)<\/local-command-stdout>/),ee=We?We[1]:E,ne=ee.match(/\*?\*?Tokens:\*?\*?\s*([\d.]+)k?\s*\/\s*([\d.]+)k?\s*\((\d+)%\)/),ze=(oe=>{const de=new RegExp(`\\|\\s*${oe}\\s*\\|\\s*([\\d.]+)k?\\s*\\|\\s*([\\d.]+)%`,"i"),He=ee.match(de);if(He)return{tokens:He[1]+"k",percent:He[2]+"%"};const et=new RegExp(`${oe}\\s+([\\d.]+)k?\\s+([\\d.]+)%`,"i"),ct=ee.match(et);return ct?{tokens:ct[1]+"k",percent:ct[2]+"%"}:null})("Messages"),st=ne?parseInt(ne[3]):0,pe=100-st,Be=()=>{n&&U.setContextModalAgentId(n)};return o.jsxs("div",{className:"output-line output-context-stats",style:{cursor:n?"pointer":"default"},onClick:Be,title:n?f("terminal:history.clickForContextStats"):void 0,children:[L&&o.jsxs("span",{className:"output-timestamp context-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{className:"context-debug-hash",children:["[",H,"]"]})]}),o.jsx("span",{className:"context-icon",children:"📊"}),o.jsx("span",{className:"context-label",children:f("terminal:history.contextLabel")}),o.jsx("div",{className:"context-bar",children:o.jsx("div",{className:"context-bar-fill",style:{width:`${st}%`}})}),o.jsx("span",{className:"context-tokens",children:ne?`${ne[1]}k/${ne[2]}k`:"?"}),o.jsxs("span",{className:"context-free",children:["(",f("terminal:history.percentFree",{percent:pe.toFixed(0)}),")"]}),ze&&o.jsx("span",{className:"context-msgs",children:f("terminal:history.msgsLabel",{tokens:ze.tokens})})]})}if(!G&&(E.includes("<local-command-caveat>")||E.includes("<command-name>/context</command-name>")||E.includes("<command-name>/cost</command-name>")||E.includes("<command-name>/compact</command-name>")))return null;const se=N==="user"?Ty(E):null,q=We=>{if(!We)return null;let ee=We;if(ee.includes("<persisted-output>")){ee=ee.replace(/<\/?persisted-output>/g,"").trim();const Be=ee.match(/Preview \(first [^)]+\):\s*([\s\S]*)/);if(Be)ee=Be[1].trim();else{const oe=ee.indexOf("{");oe!==-1&&(ee=ee.slice(oe))}}const ne=Be=>{try{const oe=JSON.parse(Be);if(oe&&typeof oe=="object"&&typeof oe.output=="string")return oe.output.split(`
136
- `).filter(de=>de.length>0)}catch{}return null},Ne=ne(ee);if(Ne)return Ne;const ze=ee.indexOf("{"),st=ee.lastIndexOf("}");if(ze!==-1&&st>ze){const Be=ne(ee.slice(ze,st+1));if(Be)return Be}const pe=ee.match(/"output"\s*:\s*"([\s\S]*)/);if(pe){let Be=pe[1];const oe=Be.match(/","(?:duration|exitCode|taskId|success)":/);oe&&oe.index!==void 0&&(Be=Be.slice(0,oe.index)),Be=Be.replace(/\.\.\.\s*$/,"");try{Be=JSON.parse(`"${Be}"`)}catch{Be=Be.replace(/\\u([0-9a-fA-F]{4})/g,(He,et)=>String.fromCharCode(parseInt(et,16))).replace(/\\n/g,`
137
- `).replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\\\/g,"\\")}const de=Be.split(`
138
- `).filter(He=>He.length>0);if(de.length>0)return de}return null};if(N==="tool_use"){const We=fs[j||""]||fs.default,ee=j?vT(j,f):"",ne=e.toolInput?JSON.stringify(e.toolInput):E;if(a){let Ne=j&&ne?wT(j,ne):null;j==="Bash"&&Ne&&Ne.length>300&&(Ne=Ne.substring(0,297)+"...");const st=["Read","Edit","Write","Glob","Grep","NotebookEdit"].includes(j||""),pe=Ne&&(st||Ne.startsWith("/")||Ne.includes("/")),Be=st&&pe&&i,oe=j==="Bash"&&c,de=D||Ne||"",He=oe&&de?AT(de):null,et=oe&&de?jT(de):null,ct=oe&&de?NT(de):null,fe=oe&&de?TT(de):null,X=()=>{if(Be&&Ne){if(j==="Edit"&&ne)try{const $e=JSON.parse(ne);if($e.old_string!==void 0||$e.new_string!==void 0||$e.unified_diff!==void 0){i(Ne,{oldString:$e.old_string||"",newString:$e.new_string||"",operation:typeof $e.operation=="string"?$e.operation:void 0,unifiedDiff:typeof $e.unified_diff=="string"?$e.unified_diff:void 0});return}}catch{}if(j==="Read"&&ne)try{const $e=JSON.parse(ne);if($e.offset!==void 0&&$e.limit!==void 0){i(Ne,{highlightRange:{offset:$e.offset,limit:$e.limit}});return}}catch{}i(Ne)}},ae=()=>{oe&&de&&c(de,T||f("tools:display.noOutputAvailable"))},ke=()=>{var Pe;if(!Ne)return null;if(!i)return o.jsx("span",{dangerouslySetInnerHTML:{__html:Mo(Ne,"bash")}});const $e=n?(Pe=U.getState().agents.get(n))==null?void 0:Pe.cwd:void 0;return CT(Ne).map((te,ge)=>{if(!te.fileRef)return o.jsx("span",{dangerouslySetInnerHTML:{__html:Mo(te.text,"bash")}},`cmd-${ge}`);const ve=sh(te.fileRef,$e);return o.jsx("span",{className:"clickable-path",onClick:Fe=>{Fe.stopPropagation(),i(ve.path)},title:f("tools:display.clickToViewFile"),style:{cursor:"pointer",textDecoration:"underline",textDecorationStyle:"dotted"},children:te.text},`cmd-file-${ge}`)})},J=oe?f("tools:display.clickToViewOutput"):Be?f("tools:display.clickToViewFile"):void 0,he=/\bcurl\b[\s\S]*\/api\/exec\b/.test(de);let Oe=null;if(he&&T){const $e=q(T);$e&&$e.length>0&&(Oe={output:$e})}if(j==="TodoWrite"&&ne)return o.jsxs("div",{className:"output-line output-tool-use output-tool-simple output-todo-inline",children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),W&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${W}`,children:W}),o.jsx("span",{className:"output-tool-icon",children:We}),o.jsx("span",{className:"output-tool-name",children:ee}),o.jsx(Hp,{content:ne})]});if((j==="AskUserQuestion"||j==="AskFollowupQuestion")&&ne){let $e=!1;try{const xe=JSON.parse(ne);$e=Array.isArray(xe.questions)&&xe.questions.length>0}catch{}if($e)return o.jsxs("div",{className:"output-line output-tool-use output-tool-simple output-ask-question-inline",children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),W&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${W}`,children:W}),o.jsx("span",{className:"output-tool-icon",children:We}),o.jsx("span",{className:"output-tool-name",children:ee}),o.jsx(YT,{content:ne})]})}return j==="ExitPlanMode"&&ne?o.jsxs("div",{className:"output-line output-tool-use output-tool-simple output-plan-inline",children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),W&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${W}`,children:W}),o.jsx("span",{className:"output-tool-icon",children:We}),o.jsx("span",{className:"output-tool-name",children:ee}),o.jsx(Sx,{content:ne})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:`output-line output-tool-use output-tool-simple ${oe?"clickable-bash":""} ${et?"bash-notify-use":""}`,onClick:oe?ae:void 0,style:oe?{cursor:"pointer"}:void 0,title:oe?f("tools:display.clickToViewOutput"):void 0,children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),W&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${W}`,children:W}),o.jsx("span",{className:"output-tool-icon",children:We}),o.jsx("span",{className:"output-tool-name",children:ee}),oe&&et?o.jsxs("span",{className:"output-tool-param bash-command bash-notify-param",onClick:ae,title:et.commandBody,style:{cursor:"pointer"},children:[et.shellPrefix&&o.jsx("span",{className:"bash-search-shell",children:et.shellPrefix}),o.jsx("span",{className:"bash-notify-chip",children:"notify"}),et.title&&o.jsx("span",{className:"bash-notify-title",children:et.title}),et.message&&o.jsx("span",{className:"bash-notify-message",children:et.message})]}):oe&&ct?o.jsxs("span",{className:"output-tool-param bash-command bash-task-label-param",onClick:ae,title:ct.commandBody,style:{cursor:"pointer"},children:[o.jsx("span",{className:"bash-task-label-chip",children:"📋 task"}),o.jsx("span",{className:"bash-task-label-value",children:ct.taskLabel})]}):oe&&fe?o.jsxs("span",{className:"output-tool-param bash-command bash-report-task-param",onClick:ae,title:fe.commandBody,style:{cursor:"pointer"},children:[o.jsx("span",{className:`bash-report-task-chip ${fe.status==="failed"?"status-failed":"status-completed"}`,children:fe.status==="failed"?"❌ report":"✅ report"}),fe.summary&&o.jsx("span",{className:"bash-report-task-summary",children:fe.summary})]}):oe&&He?o.jsxs("span",{className:"output-tool-param bash-command bash-search-param",onClick:ae,title:He.commandBody,style:{cursor:"pointer"},children:[He.shellPrefix&&o.jsx("span",{className:"bash-search-shell",children:He.shellPrefix}),o.jsx("span",{className:"bash-search-chip",children:"search"}),o.jsx("span",{className:"bash-search-term",children:He.searchTerm})]}):Ne&&o.jsxs("span",{className:`output-tool-param ${Be?"clickable-path":""}`,onClick:Be?X:void 0,title:J,style:Be?{cursor:"pointer",textDecoration:"underline",textDecorationStyle:"dotted"}:void 0,children:[st&&pe&&(()=>{const $e=Z6(Ne),xe=$e?ph($e):"";return xe?o.jsx("img",{className:"output-tool-file-icon",src:xe,alt:""}):null})(),oe?ke():Ne]})]}),he&&Oe&&o.jsx("div",{className:"exec-task-output-container",children:o.jsx("div",{className:"exec-task-inline status-completed",children:(()=>{const $e=`history-curl-${S}`,xe=h.has($e),Pe=Oe.output.slice(-6),te=Oe.output.length>6,ge=xe?Oe.output:Pe;return o.jsxs(o.Fragment,{children:[te&&o.jsxs("div",{className:"exec-task-toggle",onClick:()=>m(ve=>{const Fe=new Set(ve);return Fe.has($e)?Fe.delete($e):Fe.add($e),Fe}),children:[o.jsx("span",{className:"exec-task-toggle-arrow",children:xe?"▼":"▶"}),o.jsx("span",{className:"exec-task-toggle-text",children:xe?f("tools:skills.hide"):f("tools:skills.showAll",{count:Oe.output.length})})]}),o.jsx("div",{className:"exec-task-inline-terminal",children:o.jsx("pre",{className:"exec-task-inline-output",children:ge.map((ve,Fe)=>o.jsx("div",{dangerouslySetInnerHTML:{__html:Kl(ve)}},Fe))})})]})})()})})]})}return j==="Edit"&&ne?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"output-line output-tool-use",children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),W&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${W}`,children:W}),o.jsx("span",{className:"output-tool-icon",children:We}),o.jsx("span",{className:"output-tool-name",children:ee})]}),o.jsx("div",{className:"output-line output-tool-input",children:o.jsx(qT,{content:ne,onFileClick:i})})]}):j==="Read"&&ne?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"output-line output-tool-use",children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),W&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${W}`,children:W}),o.jsx("span",{className:"output-tool-icon",children:We}),o.jsx("span",{className:"output-tool-name",children:ee})]}),o.jsx("div",{className:"output-line output-tool-input",children:o.jsx(VT,{content:ne,onFileClick:i})})]}):j==="TodoWrite"&&ne?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"output-line output-tool-use",children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),W&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${W}`,children:W}),o.jsx("span",{className:"output-tool-icon",children:We}),o.jsx("span",{className:"output-tool-name",children:ee})]}),o.jsx("div",{className:"output-line output-tool-input",children:o.jsx(Hp,{content:ne})})]}):j==="ExitPlanMode"&&ne?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"output-line output-tool-use",children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),W&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${W}`,children:W}),o.jsx("span",{className:"output-tool-icon",children:We}),o.jsx("span",{className:"output-tool-name",children:ee})]}),o.jsx("div",{className:"output-line output-tool-input",children:o.jsx(Sx,{content:ne})})]}):j==="ToolSearch"&&ne?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"output-line output-tool-use",children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),W&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${W}`,children:W}),o.jsx("span",{className:"output-tool-icon",children:"⚡"}),o.jsx("span",{className:"output-tool-name",children:"ToolSearch"})]}),o.jsx("div",{className:"output-line output-tool-input",children:o.jsx(Wp,{content:ne,agentName:W})})]}):ne&&QT(ne)?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"output-line output-tool-use",children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),W&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${W}`,children:W}),o.jsx("span",{className:"output-tool-icon",children:"⚡"}),o.jsx("span",{className:"output-tool-name",children:"ToolSearch"})]}),o.jsx("div",{className:"output-line output-tool-input",children:o.jsx(Wp,{content:ne,agentName:W})})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"output-line output-tool-use",children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),W&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${W}`,children:W}),o.jsx("span",{className:"output-tool-icon",children:We}),o.jsx("span",{className:"output-tool-name",children:ee})]}),ne&&o.jsx("div",{className:"output-line output-tool-input",children:o.jsx("pre",{className:"output-input-content",children:Ol(ne,s)})})]})}if(N==="tool_result"){if(a)return null;const We=E.toLowerCase().includes("error")||E.toLowerCase().includes("failed");if(j==="Bash"){const ee=We||E.toLowerCase().includes("command not found")||E.toLowerCase().includes("permission denied"),ne=E.includes("... (truncated,");return o.jsxs("div",{className:`output-line output-bash-result ${ee?"is-error":""}`,children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),o.jsxs("div",{className:"bash-output-container",children:[o.jsxs("div",{className:"bash-output-header",children:[o.jsx("span",{className:"bash-output-icon",children:"$"}),o.jsx("span",{className:"bash-output-label",children:f("tools:display.terminalOutput")}),ne&&o.jsx("span",{className:"bash-output-truncated",children:f("tools:display.truncated")})]}),o.jsx("pre",{className:"bash-output-content",dangerouslySetInnerHTML:{__html:Kl(E)}})]})]})}return o.jsxs("div",{className:`output-line output-tool-result ${We?"is-error":""}`,children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),o.jsx("span",{className:"output-result-icon",children:We?"❌":"✓"}),o.jsx("pre",{className:"output-result-content",children:Ol(E,s)})]})}const be=N==="user",Ce=!be&&/^\s*(?:[\u{1F300}-\u{1FAFF}\u2600-\u27BF]\s*)?\[System\]/u.test(E),Z=be?"history-line history-user":Ce?"history-line history-system":"history-line history-assistant",ie=Ce?f("tools:display.system"):z;if(be&&se){const ee=_y(se.userMessage).userMessage,ne=MT(ee.trim());if(ne.isDelegatedTask)return o.jsxs("div",{className:Z,children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),o.jsx("span",{className:"history-content",children:o.jsx(PT,{bossName:ne.bossName,bossId:ne.bossId,taskCommand:ne.taskCommand})})]});const Ne=DT(ee.trim());if(Ne.isTaskReport)return o.jsxs("div",{className:Z,children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),o.jsxs("span",{className:"history-content",children:[se.hasContext&&se.context&&o.jsx($p,{context:se.context,onFileClick:i?st=>i(st):void 0},`boss-${S||E.slice(0,50)}`),o.jsx(BT,{agentName:Ne.agentName,agentId:Ne.agentId,status:Ne.status,originalTask:Ne.originalTask,summary:Ne.summary})]})]});const ze=RT(ee.trim());return ze.hasNotification?o.jsxs("div",{className:Z,children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),o.jsxs("span",{className:"history-content",children:[o.jsx(FT,{agentId:ze.agentId,status:ze.status}),ze.contentWithoutNotification&&o.jsx("span",{className:"user-prompt-text",children:s?o.jsx("div",{children:Ol(ze.contentWithoutNotification,s)}):Bu(ze.contentWithoutNotification,r,i)})]})]}):o.jsxs("div",{className:Z,children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),o.jsx("span",{className:"history-role history-role-chip",children:f("common:labels.you")}),o.jsxs("span",{className:"history-content user-prompt-text",children:[se.hasContext&&se.context&&o.jsx($p,{context:se.context,onFileClick:i?st=>i(st):void 0},`boss-${S||E.slice(0,50)}`),s?o.jsx("div",{children:Ol(ee,s)}):Bu(ee,r,i)]})]})}const me=OT(E),Ee=LT(me.contentWithoutBlock);return me.hasDelegation||Ee.hasWorkPlan?o.jsxs("div",{className:Z,children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),o.jsxs("span",{className:"history-role",children:[!Ce&&R&&o.jsx("img",{src:R==="codex"?"/assets/codex.png":R==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:"",className:"history-role-icon",title:R==="codex"?f("terminal:history.codexAgent"):R==="opencode"?"OpenCode Agent":f("terminal:history.claudeAgent")}),ie]}),o.jsxs("span",{className:"history-content markdown-content",children:[s?o.jsx("div",{children:Ol(Ee.contentWithoutBlock,s)}):zl(Ee.contentWithoutBlock,r,i),Ee.hasWorkPlan&&Ee.workPlan&&o.jsx(zT,{workPlan:Ee.workPlan}),me.hasDelegation&&me.delegations.map((We,ee)=>o.jsx(IT,{delegation:We},`del-${ee}`))]}),o.jsxs("div",{className:"message-action-btns",children:[C.experimentalTTS&&o.jsx("button",{className:"history-speak-btn",onClick:We=>{We.stopPropagation(),I(E)},title:f(O?"terminal:history.stopSpeaking":"terminal:history.speakSpanish"),children:O?"🔊":"🔈"}),d&&o.jsx("button",{className:"history-view-md-btn",onClick:We=>{We.stopPropagation(),d(E)},title:f("terminal:history.viewAsMarkdown"),children:"📄"})]})]}):o.jsxs("div",{className:Z,children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),o.jsxs("span",{className:`history-role ${be?"history-role-chip":""}`,children:[!be&&!Ce&&R&&o.jsx("img",{src:R==="codex"?"/assets/codex.png":R==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:"",className:"history-role-icon",title:R==="codex"?f("terminal:history.codexAgent"):R==="opencode"?"OpenCode Agent":f("terminal:history.claudeAgent")}),be?f("common:labels.you"):ie]}),o.jsx("span",{className:`history-content ${be?"user-prompt-text":"markdown-content"}`,children:s?o.jsx("div",{children:Ol(E,s)}):be?Bu(E,r,i):zl(E,r,i)}),!be&&o.jsxs("div",{className:"message-action-btns",children:[C.experimentalTTS&&o.jsx("button",{className:"history-speak-btn",onClick:We=>{We.stopPropagation(),I(E)},title:f(O?"terminal:history.stopSpeaking":"terminal:history.speakSpanish"),children:O?"🔊":"🔈"}),d&&o.jsx("button",{className:"history-view-md-btn",onClick:We=>{We.stopPropagation(),d(E)},title:f("terminal:history.viewAsMarkdown"),children:"📄"})]})]})});function t5(t){const e=t.split("/").pop()||t,n=e.lastIndexOf(".");return n<=0?"":e.slice(n).toLowerCase()}const n5=x.memo(function({entries:e,isWorking:n}){const[s,a]=x.useState(!1),r=x.useRef(null);x.useEffect(()=>{n&&s&&r.current&&(r.current.scrollTop=r.current.scrollHeight)},[e.length,n,s]);const i=s?e:e.slice(-3);return o.jsxs("div",{className:"subagent-stream-panel",children:[o.jsxs("div",{className:"subagent-stream-toggle",onClick:()=>a(!s),children:[o.jsx("span",{className:"stream-toggle-arrow",children:s?"▼":"▶"}),o.jsx("span",{children:s?"Hide stream":`Stream (${e.length} events)`})]}),(s||e.length<=3)&&o.jsxs("div",{className:"subagent-stream-list",ref:r,children:[i.map((c,d)=>o.jsxs("div",{className:`subagent-stream-entry entry-${c.type}${c.isError?" entry-error":""}`,children:[c.type==="text"&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"stream-entry-icon",children:"🤖"}),o.jsx("span",{className:"stream-entry-text",children:c.text})]}),c.type==="tool_use"&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"stream-entry-icon",children:fs[c.toolName||""]||fs.default}),o.jsx("span",{className:"stream-entry-tool",children:c.toolName}),c.toolKeyParam&&o.jsx("span",{className:"stream-entry-param",children:c.toolKeyParam})]}),c.type==="tool_result"&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"stream-entry-icon",children:c.isError?"✗":"✓"}),o.jsx("span",{className:"stream-entry-result",children:c.resultPreview})]})]},d)),n&&o.jsx("span",{className:"subagent-cursor",children:"▌"})]})]})});function s5(t){const e=t.text.slice(0,50),n=`${t.isUserPrompt?"U":""}${t.isStreaming?"S":"F"}${t.isDelegation?"D":""}`;let s=0;for(let a=0;a<e.length;a++)s=(s<<5)-s+e.charCodeAt(a),s|=0;return`${n}:${(s>>>0).toString(16).slice(0,6)}`}function a5({output:t,debugHash:e,agentId:n,onClose:s}){const{t:a}=dt(["tools","common"]),r=x.useRef(null);x.useEffect(()=>{const N=k=>{r.current&&!r.current.contains(k.target)&&s()};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[s]);const i=N=>{navigator.clipboard.writeText(N)},d=new Date(t.timestamp).toISOString();let f="assistant";t.isUserPrompt?f="user":t.text.startsWith("Using tool:")?f="tool_use":t.text.startsWith("Tool input:")?f="tool_input":t.text.startsWith("Tool result:")?f="tool_result":t.text.startsWith("Bash output:")?f="bash_output":t.text.startsWith("Tokens:")||t.text.startsWith("Cost:")?f="stats":t.text.startsWith("[thinking]")?f="thinking":t.skillUpdate&&(f="skill_update");const h=t.uuid?"server":t.isUserPrompt?"client (user)":"client/system",m=()=>{const N={uuid:t.uuid||null,hash:e,type:f,timestamp:t.timestamp,iso:d,agentId:n||null,isStreaming:t.isStreaming,source:h,textLen:t.text.length,textPreview:t.text.slice(0,120)};t.isDelegation&&(N.isDelegation=!0),t.toolName&&(N.toolName=t.toolName),t.toolInput&&(N.toolInput=t.toolInput),t.toolOutput&&(N.toolOutputLen=t.toolOutput.length),t.subagentName&&(N.subagentName=t.subagentName),t.isUserPrompt&&(N.isUserPrompt=!0),t.skillUpdate&&(N.skillUpdate=t.skillUpdate),navigator.clipboard.writeText(JSON.stringify(N,null,2))},b=n?U.getState().agentOutputs.get(n):null,y=b?b.indexOf(t):-1,w=b?b.length:0,C=[{label:"UUID",value:t.uuid||"(none)",mono:!0},{label:"Hash",value:e,mono:!0},{label:"Type",value:f},{label:"Source",value:h},{label:"Agent",value:n||"(none)",mono:!0},{label:"Time",value:d,mono:!0},{label:"Epoch",value:String(t.timestamp),mono:!0},{label:"Index",value:y>=0?`${y} / ${w}`:"(unknown)",mono:!0},{label:"Text",value:`[${t.text.length} chars] ${t.text.slice(0,120)}`,mono:!0}];return t.isStreaming&&C.push({label:"State",value:"streaming"}),t.isDelegation&&C.push({label:"Flag",value:"delegation"}),t.toolName&&C.push({label:"Tool",value:t.toolName}),t.toolInput&&C.push({label:"ToolIn",value:JSON.stringify(t.toolInput).slice(0,200),mono:!0}),t.toolOutput&&C.push({label:"ToolOut",value:`[${t.toolOutput.length} chars] ${t.toolOutput.slice(0,120)}`,mono:!0}),t.subagentName&&C.push({label:"Subagent",value:t.subagentName}),o.jsxs("div",{className:"msg-meta-tooltip",ref:r,children:[o.jsxs("div",{className:"msg-meta-tooltip__header",children:[o.jsx("span",{children:a("tools:metadata.messageInfo")}),o.jsxs("div",{className:"msg-meta-tooltip__actions",children:[o.jsx("button",{className:"msg-meta-tooltip__copy-all",onClick:m,title:a("tools:metadata.copyAllAsJSON"),children:"JSON"}),o.jsx("button",{className:"msg-meta-tooltip__close",onClick:s,children:"×"})]})]}),o.jsx("div",{className:"msg-meta-tooltip__body",children:C.map(({label:N,value:k,mono:j})=>o.jsxs("div",{className:"msg-meta-tooltip__row",children:[o.jsx("span",{className:"msg-meta-tooltip__label",children:N}),o.jsx("span",{className:`msg-meta-tooltip__value ${j?"mono":""}`,onClick:()=>i(k),title:a("tools:metadata.clickToCopy"),children:k})]},N))})]})}function Gn({output:t,timeStr:e,debugHash:n,agentId:s}){const{t:a}=dt(["tools"]),[r,i]=x.useState(!1),c=x.useCallback(f=>{f.stopPropagation(),i(h=>!h)},[]),d=x.useCallback(()=>i(!1),[]);return o.jsxs("span",{className:"output-timestamp-wrapper",children:[o.jsx("span",{className:"output-timestamp output-timestamp--clickable",onClick:c,title:a("tools:metadata.clickForMessageInfo"),children:e}),r&&o.jsx(a5,{output:t,debugHash:n,agentId:s||null,onClose:d})]})}const Ry=x.memo(function({output:e,agentId:n,execTasks:s=[],subagents:a,onImageClick:r,onFileClick:i,onBashClick:c,onViewMarkdown:d}){var pe,Be,oe;const{t:f}=dt(["tools","common"]),h=e1(),m=Vr(),[b,y]=x.useState(new Set),{text:w,isStreaming:C,isUserPrompt:N,timestamp:k,skillUpdate:j,_toolKeyParam:S,_editData:T,_todoInput:D,_bashOutput:E,_bashCommand:I,_isRunning:O}=e,_=Tu(w,h),M=e.toolName,R=e.toolInput,z=e.toolOutput;let $=S;if(!$&&R&&typeof R=="object"){const de=R;if(M==="Glob"&&de.pattern)$=de.path?`${de.pattern} in ${de.path}`:de.pattern;else if(M==="Grep"&&de.pattern)$=de.path?`"${de.pattern}" in ${de.path}`:`"${de.pattern}"`;else if((M==="AskUserQuestion"||M==="AskFollowupQuestion")&&de.questions){const He=de.questions;Array.isArray(He)&&((pe=He[0])!=null&&pe.question)&&($=He[0].question)}else if((M==="Task"||M==="Agent")&&typeof de.description=="string"){const He=de.description,et=de.subagent_type;$=et?`[${et}] ${He}`:He}else if(M==="ExitPlanMode"||M==="EnterPlanMode"){const He=de.allowedPrompts;Array.isArray(He)&&He.length>0?$=He.map(et=>et.prompt||et.tool||"").filter(Boolean).join(", "):M==="ExitPlanMode"&&typeof de.plan=="string"&&de.plan.trim().length>0?$=de.plan.trim():$=M==="ExitPlanMode"?"Plan ready":"Entering plan mode"}else if(M==="spawn_agent"||M==="send_input"||M==="wait"){const He=de.prompt,et=de.receiver_thread_ids;He?$=He.length>100?He.slice(0,97)+"...":He:et&&et.length>0?$=`waiting on ${et.length} thread(s)`:M==="wait"&&($="waiting for subagents")}else if(M==="TodoWrite"&&Array.isArray(de.todos)){const He=de.todos,et=He.filter(ae=>ae.status==="completed").length,ct=He.filter(ae=>ae.status==="in_progress").length,fe=He.filter(ae=>ae.status==="pending").length,X=[];et>0&&X.push(`${et} done`),ct>0&&X.push(`${ct} active`),fe>0&&X.push(`${fe} pending`),$=`${He.length} items (${X.join(", ")})`}else if($=de.file_path||de.path||de.notebook_path||de.command||de.pattern||de.url||de.query||de.description,!$)try{const He=JSON.stringify(de);He&&He!=="{}"&&($=He.length>200?He.slice(0,197)+"...":He)}catch{}}const W=n?(Be=U.getState().agents.get(n))==null?void 0:Be.name:null,L=e.subagentName||W,F=n?(oe=U.getState().agents.get(n))==null?void 0:oe.provider:void 0,H=F==="codex"?"Codex":F==="opencode"?"OpenCode":"Claude",[V,G]=x.useState(!1),[B,K]=x.useState(!1),{toggle:se,speaking:q}=Dy(),be=Fp(k||Date.now()),Ce=s5(e);if(j)return o.jsxs("div",{className:"output-line output-skill-update",children:[o.jsx(Gn,{output:e,timeStr:be,debugHash:Ce,agentId:n}),o.jsx("span",{className:"skill-update-icon",children:"🔄"}),o.jsx("span",{className:"skill-update-label",children:f("tools:skills.skillsUpdated")}),o.jsx("span",{className:"skill-update-list",children:j.skills.map((de,He)=>o.jsxs("span",{className:"skill-update-item",title:de.description,children:[de.name,He<j.skills.length-1?", ":""]},de.name))})]});if(_.startsWith("This session is being continued from a previous conversation that ran out of context"))return o.jsxs("div",{className:`output-line output-session-continuation ${V?"expanded":""}`,onClick:()=>G(!V),title:"Click to expand/collapse",children:[o.jsx(Gn,{output:e,timeStr:be,debugHash:Ce,agentId:n}),o.jsx("span",{className:"session-continuation-icon",children:"🔗"}),o.jsx("span",{className:"session-continuation-label",children:f("tools:display.sessionContinued")}),o.jsx("span",{className:"session-continuation-toggle",children:V?"▼":"▶"}),V&&o.jsx("div",{className:"session-continuation-content",children:zl(_,r,i)})]});const ie=n?U.getLastDelegationReceived(n):null;if(N){const de=_.trim();if(de==="/context"||de==="/cost"||de==="/compact")return null;const He=Ty(_),et=_y(He.userMessage),ct=et.userMessage,fe=MT(ct.trim());if(fe.isDelegatedTask)return o.jsxs("div",{className:"output-line output-user",children:[o.jsx(Gn,{output:e,timeStr:be,debugHash:Ce,agentId:n}),o.jsx(PT,{bossName:fe.bossName,bossId:fe.bossId,taskCommand:fe.taskCommand})]});const X=DT(ct.trim());if(X.isTaskReport)return o.jsxs("div",{className:"output-line output-user",children:[o.jsx(Gn,{output:e,timeStr:be,debugHash:Ce,agentId:n}),He.hasContext&&He.context&&o.jsx($p,{context:He.context,onFileClick:i},`boss-stream-${_.slice(0,50)}`),o.jsx(BT,{agentName:X.agentName,agentId:X.agentId,status:X.status,originalTask:X.originalTask,summary:X.summary})]});const ae=RT(ct.trim());if(ae.hasNotification)return o.jsxs("div",{className:"output-line output-user",children:[o.jsx(Gn,{output:e,timeStr:be,debugHash:Ce,agentId:n}),o.jsx(FT,{agentId:ae.agentId,status:ae.status}),ae.contentWithoutNotification&&o.jsx("span",{className:"history-content user-prompt-text",children:Bu(ae.contentWithoutNotification,r,i)})]});const ke=ie&&_.trim()===ie.taskCommand.trim();return o.jsxs("div",{className:"output-line output-user",children:[o.jsx(Gn,{output:e,timeStr:be,debugHash:Ce,agentId:n}),ke?o.jsx(a6,{bossName:ie.bossName,taskCommand:ie.taskCommand}):o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"output-role output-role-chip output-role-user-chip",children:f("common:labels.you")}),He.hasContext&&He.context&&o.jsx($p,{context:He.context,onFileClick:i},`boss-stream-${_.slice(0,50)}`),Bu(et.userMessage,r,i)]})]})}if(_.startsWith("Using tool:")){const de=_.replace("Using tool:","").trim(),He=vT(de,f),et=fs[de]||fs.default,ct=new Set(["Bash","Read","Write","Edit","Glob","Grep","NotebookEdit","Task","Agent","TodoWrite","AskUserQuestion","AskFollowupQuestion","ExitPlanMode","EnterPlanMode","web_search","ToolSearch","spawn_agent","send_input","wait"]),fe=D||(de==="TodoWrite"&&R&&typeof R=="object"&&Array.isArray(R.todos)?JSON.stringify(R):void 0);if(de==="TodoWrite"&&fe)return o.jsxs("div",{className:`output-line output-tool-use output-todo-inline ${C?"output-streaming":""}`,children:[o.jsx(Gn,{output:e,timeStr:be,debugHash:Ce,agentId:n}),L&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${L}`,children:L}),o.jsx("span",{className:"output-tool-icon",children:et}),o.jsx("span",{className:"output-tool-name",children:He}),o.jsx(Hp,{content:fe})]});const X=(de==="AskUserQuestion"||de==="AskFollowupQuestion")&&R&&typeof R=="object"&&Array.isArray(R.questions)?JSON.stringify(R):void 0;if((de==="AskUserQuestion"||de==="AskFollowupQuestion")&&X)return o.jsxs("div",{className:`output-line output-tool-use output-ask-question-inline ${C?"output-streaming":""}`,children:[o.jsx(Gn,{output:e,timeStr:be,debugHash:Ce,agentId:n}),L&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${L}`,children:L}),o.jsx("span",{className:"output-tool-icon",children:et}),o.jsx("span",{className:"output-tool-name",children:He}),o.jsx(YT,{content:X})]});const ae=de==="ExitPlanMode"&&R&&typeof R=="object"&&typeof R.plan=="string"?JSON.stringify(R):void 0;if(de==="ExitPlanMode"&&ae)return o.jsxs("div",{className:`output-line output-tool-use output-plan-inline ${C?"output-streaming":""}`,children:[o.jsx(Gn,{output:e,timeStr:be,debugHash:Ce,agentId:n}),L&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${L}`,children:L}),o.jsx("span",{className:"output-tool-icon",children:et}),o.jsx("span",{className:"output-tool-name",children:He}),o.jsx(Sx,{content:ae})]});const ke=de==="ToolSearch"&&R&&typeof R=="object"?JSON.stringify(R):void 0;if(de==="ToolSearch"&&ke)return o.jsxs("div",{className:`output-line output-tool-use output-toolsearch-inline ${C?"output-streaming":""}`,children:[o.jsx(Gn,{output:e,timeStr:be,debugHash:Ce,agentId:n}),o.jsx("span",{className:"output-tool-icon",children:"⚡"}),o.jsx("span",{className:"output-tool-name",children:"ToolSearch"}),o.jsx(Wp,{content:ke,agentName:L})]});if(["spawn_agent","send_input","wait"].includes(de)){const bt=R,rt=bt==null?void 0:bt.prompt,xt=bt==null?void 0:bt.receiver_thread_ids,$t=rt?rt.length>120?rt.slice(0,117)+"...":rt:void 0,En=de==="spawn_agent"?"Spawn Agent":de==="send_input"?"Send Input":"Wait";return o.jsxs("div",{className:`output-line output-tool-use output-collab-tool output-collab-${de} ${C?"output-streaming":""}`,children:[o.jsx(Gn,{output:e,timeStr:be,debugHash:Ce,agentId:n}),L&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${L}`,children:L}),o.jsx("span",{className:"output-tool-icon",children:et}),o.jsx("span",{className:"output-tool-name collab-tool-name",children:En}),xt&&xt.length>0&&o.jsx("span",{className:"collab-thread-ids",children:xt.map(nn=>nn.slice(-8)).join(", ")}),$t&&o.jsx("span",{className:"collab-prompt-preview",title:rt,children:$t})]})}const he=R&&typeof R=="object"?JSON.stringify(R,null,2):void 0,$e=["Read","Edit","Write","Glob","Grep","NotebookEdit"].includes(de),xe=R&&typeof R=="object"?R:null,Pe=xe?(typeof xe.file_path=="string"?xe.file_path:void 0)||(typeof xe.path=="string"?xe.path:void 0)||(typeof xe.notebook_path=="string"?xe.notebook_path:void 0):void 0,te=S||Pe,ge=!!te&&($e||te.startsWith("/")||te.includes("/")),ve=$e&&ge&&i,Fe=de==="Edit"&&xe?{oldString:String(xe.old_string??""),newString:String(xe.new_string??""),operation:typeof xe.operation=="string"?xe.operation:void 0}:void 0,Ke=de==="Read"&&xe&&typeof xe.offset=="number"&&typeof xe.limit=="number"?{highlightRange:{offset:xe.offset,limit:xe.limit}}:void 0,at=de==="Bash"&&c,ft=!!E||!!z,wt=I||S||$||"",it=ST(wt),gt=/\bcurl\b[\s\S]*\/api\/exec\b/.test(wt),ht=k?new Date(k).getTime():0,Gt=gt?kT(wt):null,tn=gt&&s.length>0?(()=>{if(Gt){const rt=s.filter(xt=>xt.command===Gt);if(rt.length>0)return[rt.reduce(($t,En)=>En.startedAt>$t.startedAt?En:$t)]}const bt=s.filter(rt=>rt.startedAt>=ht&&rt.startedAt<=ht+5e3);return bt.length>0?[bt.reduce((xt,$t)=>$t.startedAt>xt.startedAt?$t:xt)]:[]})():[],Ae=!!(at&&gt&&tn.length>0),Le=(de==="Task"||de==="Agent")&&a&&e.uuid?(()=>{for(const[,bt]of a)if(bt.toolUseId===e.uuid)return bt})():void 0,Ye=at&&wt?AT(wt):null,Ze=at&&wt?jT(wt):null,Ot=at&&wt?NT(wt):null,Ft=at&&wt?TT(wt):null,Lt=bt=>{if(bt.stopPropagation(),ve&&te){const rt=T||Fe;de==="Edit"&&rt?i(te,rt):de==="Read"&&Ke?i(te,Ke):i(te)}},Vt=()=>{if(at&&wt){const bt=O?f("tools:display.running"):E||f("tools:display.noOutputCaptured");c(wt,bt)}},ln=()=>{var xt;if(!it)return null;if(!i)return o.jsx("span",{dangerouslySetInnerHTML:{__html:Mo(it,"bash")}});const bt=n?(xt=U.getState().agents.get(n))==null?void 0:xt.cwd:void 0;return CT(it).map(($t,En)=>{if(!$t.fileRef)return o.jsx("span",{dangerouslySetInnerHTML:{__html:Mo($t.text,"bash")}},`cmd-${En}`);const nn=sh($t.fileRef,bt);return o.jsx("span",{className:"clickable-path",onClick:Un=>{Un.stopPropagation(),i(nn.path)},title:f("tools:display.clickToViewFile"),style:{cursor:"pointer",textDecoration:"underline",textDecorationStyle:"dotted"},children:$t.text},`cmd-file-${En}`)})};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:`output-line output-tool-use ${C?"output-streaming":""} ${at?"bash-clickable":""} ${Ze?"bash-notify-use":""}`,onClick:at?Vt:void 0,title:at?f("tools:display.clickToViewOutput"):void 0,children:[o.jsx(Gn,{output:e,timeStr:be,debugHash:Ce,agentId:n}),L&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${L}`,children:L}),o.jsx("span",{className:"output-tool-icon",children:et}),o.jsx("span",{className:"output-tool-name",children:He}),at&&wt&&(Ze?o.jsxs("span",{className:"output-tool-param bash-command bash-notify-param",onClick:Vt,title:Ze.commandBody,style:{cursor:"pointer"},children:[Ze.shellPrefix&&o.jsx("span",{className:"bash-search-shell",children:Ze.shellPrefix}),o.jsx("span",{className:"bash-notify-chip",children:"notify"}),Ze.title&&o.jsx("span",{className:"bash-notify-title",children:Ze.title}),Ze.message&&o.jsx("span",{className:"bash-notify-message",children:Ze.message})]}):Ot?o.jsxs("span",{className:"output-tool-param bash-command bash-task-label-param",onClick:Vt,title:Ot.commandBody,style:{cursor:"pointer"},children:[o.jsx("span",{className:"bash-task-label-chip",children:"📋 task"}),o.jsx("span",{className:"bash-task-label-value",children:Ot.taskLabel})]}):Ft?o.jsxs("span",{className:"output-tool-param bash-command bash-report-task-param",onClick:Vt,title:Ft.commandBody,style:{cursor:"pointer"},children:[o.jsx("span",{className:`bash-report-task-chip ${Ft.status==="failed"?"status-failed":"status-completed"}`,children:Ft.status==="failed"?"❌ report":"✅ report"}),Ft.summary&&o.jsx("span",{className:"bash-report-task-summary",children:Ft.summary})]}):Ye?o.jsxs("span",{className:"output-tool-param bash-command bash-search-param",onClick:Vt,title:Ye.commandBody,style:{cursor:"pointer"},children:[Ye.shellPrefix&&o.jsx("span",{className:"bash-search-shell",children:Ye.shellPrefix}),o.jsx("span",{className:"bash-search-chip",children:"search"}),o.jsx("span",{className:"bash-search-term",children:Ye.searchTerm})]}):o.jsx("span",{className:"output-tool-param bash-command",onClick:Vt,title:f("tools:display.clickToViewOutput"),style:{cursor:"pointer",fontFamily:"monospace",fontSize:"0.9em",color:"#888"},children:ln()})),!at&&$&&o.jsxs("span",{className:`output-tool-param ${ve?"clickable-path":""}`,onClick:ve?Lt:void 0,title:ve?f(de==="Edit"&&(T||Fe)?"tools:display.clickToViewDiff":"tools:display.clickToViewFile"):void 0,style:ve?{cursor:"pointer",textDecoration:"underline",textDecorationStyle:"dotted"}:void 0,children:[$e&&ge&&(()=>{const bt=t5(te),rt=bt?ph(bt):"";return rt?o.jsx("img",{className:"output-tool-file-icon",src:rt,alt:""}):null})(),$]}),at&&!O&&o.jsx("span",{className:"bash-output-indicator",children:s.some(bt=>bt.status==="completed")?"✅":ft?"📄":"💻"}),C&&o.jsx("span",{className:"output-tool-loading",children:"..."})]}),!ct.has(de)&&he&&o.jsxs("div",{className:"output-line output-tool-input output-tool-input-fallback",children:[o.jsx(Gn,{output:e,timeStr:be,debugHash:Ce,agentId:n}),o.jsx(IA,{toolName:de,content:he})]}),Ae&&o.jsx("div",{className:"exec-task-output-container",children:tn.map(bt=>{const rt=b.has(bt.taskId),xt=bt.output.slice(-6),$t=bt.output.length>6,En=rt?bt.output:xt;return o.jsxs("div",{className:`exec-task-inline status-${bt.status}`,children:[$t&&o.jsxs("div",{className:"exec-task-toggle",onClick:()=>y(nn=>{const Un=new Set(nn);return Un.has(bt.taskId)?Un.delete(bt.taskId):Un.add(bt.taskId),Un}),children:[o.jsx("span",{className:"exec-task-toggle-arrow",children:rt?"▼":"▶"}),o.jsx("span",{className:"exec-task-toggle-text",children:rt?f("tools:skills.hide"):f("tools:skills.showAll",{count:bt.output.length})})]}),o.jsx("div",{className:"exec-task-inline-terminal",children:o.jsxs("pre",{className:"exec-task-inline-output",children:[En.map((nn,Un)=>o.jsx("div",{dangerouslySetInnerHTML:{__html:Kl(nn)}},Un)),bt.status==="running"&&o.jsx("span",{className:"exec-task-cursor",children:"▌"})]})})]},bt.taskId)})}),Le&&(Le.status==="working"||Le.activities&&Le.activities.length>0||Le.stats)&&o.jsx("div",{className:"subagent-activity-container",children:o.jsxs("div",{className:`subagent-activity-inline status-${Le.status}`,children:[o.jsxs("div",{className:"subagent-activity-header",children:[o.jsx("span",{className:"subagent-type-badge",children:Le.subagentType}),o.jsx("span",{className:"subagent-elapsed",children:Le.completedAt?`${((Le.completedAt-Le.startedAt)/1e3).toFixed(0)}s`:`${((Date.now()-Le.startedAt)/1e3).toFixed(0)}s`})]}),Le.activities&&Le.activities.length>0&&o.jsxs("div",{className:"subagent-activity-list",children:[Le.activities.slice(-8).map((bt,rt)=>o.jsxs("div",{className:"subagent-activity-item",children:[o.jsx("span",{className:"activity-icon",children:fs[bt.toolName]||fs.default}),o.jsx("span",{className:"activity-tool",children:bt.toolName}),o.jsx("span",{className:"activity-desc",children:bt.description.length>80?bt.description.slice(0,77)+"...":bt.description})]},rt)),Le.status==="working"&&o.jsx("span",{className:"subagent-cursor",children:"▌"})]}),Le.stats&&o.jsxs("div",{className:"subagent-stats-bar",children:[o.jsxs("span",{children:[(Le.stats.durationMs/1e3).toFixed(0),"s"]}),o.jsxs("span",{children:[(Le.stats.tokensUsed/1e3).toFixed(1),"K tokens"]}),o.jsxs("span",{children:[Le.stats.toolUseCount," tools"]})]}),Le.streamEntries&&Le.streamEntries.length>0&&o.jsx(n5,{entries:Le.streamEntries,isWorking:Le.status==="working"})]})})]})}if(_.startsWith("Tool input:")){const de=_.replace("Tool input:","").trim();if(QT(de))return o.jsxs("div",{className:"output-line output-tool-input",children:[o.jsx(Gn,{output:e,timeStr:be,debugHash:Ce,agentId:n}),o.jsx(Wp,{content:de,agentName:L})]});try{const He=JSON.parse(de);if(He.file_path&&(He.old_string!==void 0||He.new_string!==void 0))return o.jsxs("div",{className:"output-line output-tool-input",children:[o.jsx(Gn,{output:e,timeStr:be,debugHash:Ce,agentId:n}),o.jsx(qT,{content:de,onFileClick:i})]});if(He.file_path&&He.old_string===void 0&&He.new_string===void 0)return o.jsxs("div",{className:"output-line output-tool-input",children:[o.jsx(Gn,{output:e,timeStr:be,debugHash:Ce,agentId:n}),o.jsx(VT,{content:de,onFileClick:i})]});if(Array.isArray(He.todos))return o.jsxs("div",{className:"output-line output-tool-input",children:[o.jsx(Gn,{output:e,timeStr:be,debugHash:Ce,agentId:n}),o.jsx(Hp,{content:de})]})}catch{}return o.jsxs("div",{className:"output-line output-tool-input",children:[o.jsx(Gn,{output:e,timeStr:be,debugHash:Ce,agentId:n}),o.jsx(IA,{toolName:M||"UnknownTool",content:de})]})}if(_.startsWith("Tool result:")){const de=_.replace("Tool result:","").trim(),He=de.toLowerCase().includes("error")||de.toLowerCase().includes("failed");return o.jsxs("div",{className:`output-line output-tool-result ${He?"is-error":""}`,children:[o.jsx(Gn,{output:e,timeStr:be,debugHash:Ce,agentId:n}),o.jsx("span",{className:"output-result-icon",children:He?"❌":"✓"}),o.jsx("pre",{className:"output-result-content",children:de})]})}if(_.startsWith("Bash output:")){const de=_.replace("Bash output:","").trim(),He=de.toLowerCase().includes("error")||de.toLowerCase().includes("failed")||de.toLowerCase().includes("command not found")||de.toLowerCase().includes("permission denied"),et=de.includes("... (truncated,");return o.jsxs("div",{className:`output-line output-bash-result ${He?"is-error":""}`,children:[o.jsx(Gn,{output:e,timeStr:be,debugHash:Ce,agentId:n}),o.jsxs("div",{className:"bash-output-container",children:[o.jsxs("div",{className:"bash-output-header",children:[o.jsx("span",{className:"bash-output-icon",children:"$"}),o.jsx("span",{className:"bash-output-label",children:f("tools:display.terminalOutput")}),et&&o.jsx("span",{className:"bash-output-truncated",children:f("tools:display.truncated")})]}),o.jsx("pre",{className:"bash-output-content",dangerouslySetInnerHTML:{__html:Kl(de)}})]})]})}if(_.includes("## Context Usage")||_.includes("Context Usage")&&_.includes("Tokens:")&&_.includes("Free space")||_.includes("<local-command-caveat>")||_.includes("<command-name>/context</command-name>")||_.includes("<command-name>/cost</command-name>")||_.includes("<command-name>/compact</command-name>"))return null;const Ee=_.startsWith("[thinking]"),Te=Ee?_.replace(/^\[thinking\]\s*/,""):"",Ve=Ee?(Te||"(processing)").replace(/\*+/g,"").replace(/\s+/g," ").trim():"",We=/^\s*(?:[\u{1F300}-\u{1FAFF}\u2600-\u27BF]\s*)?\[System\]/u.test(_),ee=!!(e.subagentName&&z&&/^[✅❌]\s*Subagent\s/.test(_));let ne="output-line",Ne=!0,ze=!1;if(_.startsWith("Session started:")||_.startsWith("Session initialized")?(ne+=" output-session",Ne=!1):_.startsWith("Tokens:")||_.startsWith("Cost:")?(ne+=" output-stats",Ne=!1):Ee?(ne+=" output-thinking output-tool-use",Ne=!1):_.startsWith("[raw]")?(ne+=" output-raw",Ne=!1):We?ne+=" output-text output-system markdown-content":(ne+=" output-text output-claude markdown-content",ze=!0),C&&(ne+=" output-streaming"),ze&&!C){const de=OT(_),He=LT(de.contentWithoutBlock);if(de.hasDelegation||He.hasWorkPlan)return o.jsxs("div",{className:ne,children:[o.jsx(Gn,{output:e,timeStr:be,debugHash:Ce,agentId:n}),o.jsxs("span",{className:"output-role",children:[F&&o.jsx("img",{src:F==="codex"?"/assets/codex.png":F==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:"",className:"output-role-icon",title:F==="codex"?"Codex Agent":F==="opencode"?"OpenCode Agent":"Claude Agent"}),H]}),o.jsx("div",{className:"markdown-content",children:zl(He.contentWithoutBlock,r,i)}),He.hasWorkPlan&&He.workPlan&&o.jsx(zT,{workPlan:He.workPlan}),de.hasDelegation&&de.delegations.map((et,ct)=>o.jsx(IT,{delegation:et},`del-${ct}`)),o.jsxs("div",{className:"message-action-btns",children:[m.experimentalTTS&&o.jsx("button",{className:"history-speak-btn",onClick:et=>{et.stopPropagation(),se(_)},title:q?"Stop speaking":"Speak (Spanish)",children:q?"🔊":"🔈"}),d&&o.jsx("button",{className:"history-view-md-btn",onClick:et=>{et.stopPropagation(),d(z||_)},title:"View as Markdown",children:"📄"})]})]})}const st=ze?H:We?f("tools:display.system"):null;return o.jsxs("div",{className:ne,children:[o.jsx(Gn,{output:e,timeStr:be,debugHash:Ce,agentId:n}),st&&o.jsxs("span",{className:"output-role",children:[ze&&F&&o.jsx("img",{src:F==="codex"?"/assets/codex.png":F==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:"",className:"output-role-icon",title:F==="codex"?"Codex Agent":F==="opencode"?"OpenCode Agent":"Claude Agent"}),st]}),Ne?o.jsx("div",{className:"markdown-content",children:zl(_,r,i)}):Ee?o.jsxs(o.Fragment,{children:[L&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${L}`,children:L}),o.jsx("span",{className:"output-tool-name output-thinking-label",children:f(F==="codex"?"tools:display.codexThinking":"tools:display.thinking")}),o.jsx("span",{className:"output-tool-param output-thinking-content",title:Ve,children:Ve})]}):_,ee&&z&&o.jsxs("div",{className:"subagent-result-section",children:[o.jsxs("button",{className:"subagent-result-toggle",onClick:de=>{de.stopPropagation(),K(!B)},children:[o.jsx("span",{className:"subagent-result-arrow",children:B?"▼":"▶"}),B?"Hide result":"Show result"]}),B&&o.jsx("div",{className:"subagent-result-content markdown-content",children:zl(z,r,i)})]}),ze&&!C&&o.jsxs("div",{className:"message-action-btns",children:[m.experimentalTTS&&o.jsx("button",{className:"history-speak-btn",onClick:de=>{de.stopPropagation(),se(_)},title:q?"Stop speaking":"Speak (Spanish)",children:q?"🔊":"🔈"}),d&&o.jsx("button",{className:"history-view-md-btn",onClick:de=>{de.stopPropagation(),d(z||_)},title:"View as Markdown",children:"📄"})]})]})}),Ll={user:60,assistant:120,tool_use:40,tool_result:80,default:60};function r5(t){var n,s;if("type"in t)return Ll[t.type]||Ll.default;const e=t;return e.isUserPrompt?Ll.user:(n=e.text)!=null&&n.startsWith("Using tool:")?Ll.tool_use:(s=e.text)!=null&&s.startsWith("Tool result:")?Ll.tool_result:Ll.assistant}const i5=x.memo(function({item:e,isHistory:n,agentId:s,execTasks:a,subagents:r,simpleView:i,isSelected:c,messageIndex:d,searchHighlight:f,onImageClick:h,onFileClick:m,onBashClick:b,onViewMarkdown:y}){return o.jsx("div",{"data-message-index":d,className:`message-nav-wrapper ${c?"message-selected":""}`,children:n?o.jsx(XT,{message:e,agentId:s,simpleView:i,highlight:f,onImageClick:h,onFileClick:m,onBashClick:b,onViewMarkdown:y}):o.jsx(Ry,{output:e,agentId:s,execTasks:a,subagents:r,onImageClick:h,onFileClick:m,onBashClick:b,onViewMarkdown:y})})}),o5=x.memo(function({historyMessages:e,liveOutputs:n,agentId:s,execTasks:a=[],subagents:r,viewMode:i,searchHighlight:c,searchActiveIndex:d,selectedMessageIndex:f,isMessageSelected:h,onImageClick:m,onFileClick:b,onBashClick:y,onViewMarkdown:w,scrollContainerRef:C,onScrollTopReached:N,isLoadingMore:k,hasMore:j,shouldAutoScroll:S,onUserScroll:T,pinToBottom:D=!1,onPinCancel:E,isLoadingHistory:I}){const O=x.useMemo(()=>[...e,...n],[e,n]),_=e.length,M=x.useRef(!1),R=x.useRef(O.length),z=x.useRef(!1),$=x.useRef(O.length);$.current=O.length;const W=x.useRef(0),L=RN({count:O.length,getScrollElement:()=>C.current,estimateSize:K=>r5(O[K]),overscan:10,initialRect:{width:500,height:800},measureElement:K=>K.getBoundingClientRect().height});x.useEffect(()=>()=>{L.elementsCache.clear()},[L]);const F=x.useCallback(()=>{const K=C.current;if(!K)return;const se=$.current;se<=0||(L.scrollToIndex(se-1,{align:"end"}),K.scrollTop=K.scrollHeight)},[C,L]);x.useLayoutEffect(()=>{D&&(I||O.length!==0&&(M.current=!0,z.current=!0,F()))},[D,I,O.length,F]),x.useEffect(()=>{if(!D){M.current=!1,z.current=!1;return}if(I||O.length===0)return;let K;const se=()=>{M.current=!0,F(),K=requestAnimationFrame(se)};return K=requestAnimationFrame(se),()=>cancelAnimationFrame(K)},[D,I,O.length,F]),x.useEffect(()=>{if(S&&O.length!==0){if(O.length<=R.current){R.current=O.length;return}R.current=O.length,M.current=!0,F(),requestAnimationFrame(()=>{M.current=!1})}},[O.length,S,F]);const H=L.getTotalSize();x.useEffect(()=>{const K=W.current;W.current=H,S&&(D||H<=K||H-K<2||(M.current=!0,F(),requestAnimationFrame(()=>{M.current=!1})))},[H,S,D,F]);const V=x.useCallback(()=>{if(!C.current)return;const{scrollTop:K,scrollHeight:se,clientHeight:q}=C.current;D&&!M.current&&(E==null||E()),!(se-K-q<150)&&!M.current&&!z.current&&T&&T(),K<200&&j&&!k&&N&&N()},[j,k,N,T,C,D,E]);x.useEffect(()=>{const K=C.current;if(K)return K.addEventListener("scroll",V,{passive:!0}),()=>K.removeEventListener("scroll",V)},[V,C]),x.useEffect(()=>{const K=C.current;if(!K)return;const se=new ResizeObserver(()=>{M.current=!0,K.dispatchEvent(new Event("scroll")),requestAnimationFrame(()=>{M.current=!1})});return se.observe(K),()=>se.disconnect()},[C]),x.useEffect(()=>{if(f!==null&&f>=0&&f<O.length){M.current=!0,L.scrollToIndex(f,{align:"center"});const K=setTimeout(()=>{M.current=!1},100);return()=>clearTimeout(K)}},[f,L,O.length]),x.useEffect(()=>{if(d!=null&&d>=0&&d<O.length){M.current=!0,L.scrollToIndex(d,{align:"center"});const K=setTimeout(()=>{M.current=!1},100);return()=>clearTimeout(K)}},[d,L,O.length]);const G=L.getVirtualItems(),B=i!=="advanced";return o.jsx("div",{style:{height:`${L.getTotalSize()}px`,width:"100%",position:"relative"},children:G.map(K=>{const se=O[K.index],q=K.index<_;return o.jsx("div",{"data-index":K.index,ref:L.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${K.start}px)`},children:o.jsx(i5,{item:se,isHistory:q,agentId:s,execTasks:a,subagents:r,simpleView:B,isSelected:h(K.index),messageIndex:K.index,searchHighlight:c,onImageClick:m,onFileClick:b,onBashClick:y,onViewMarkdown:w})},K.key)})})});function PA(t){const e=[];let n=0;try{JSON.parse(t)}catch(i){return e.push(o.jsxs("span",{className:"json-error",children:["[Invalid JSON: ",String(i).slice(0,50),"]"]},n++)),e.push(o.jsx("span",{children:t},n++)),e}const s=/("(?:\\.|[^"\\])*")\s*:|("(?:\\.|[^"\\])*")|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)|(\btrue\b|\bfalse\b)|(\bnull\b)|([{}[\],:])/g;let a=0,r;for(;(r=s.exec(t))!==null;){r.index>a&&e.push(o.jsx("span",{children:t.slice(a,r.index)},n++));const[i,c,d,f,h,m,b]=r;c?(e.push(o.jsx("span",{className:"json-key",children:c.slice(0,-1)},n++)),e.push(o.jsx("span",{className:"json-punct",children:":"},n++))):d?e.push(o.jsx("span",{className:"json-string",children:d},n++)):f?e.push(o.jsx("span",{className:"json-number",children:f},n++)):h?e.push(o.jsx("span",{className:"json-boolean",children:h},n++)):m?e.push(o.jsx("span",{className:"json-null",children:m},n++)):b&&e.push(o.jsx("span",{className:"json-punct",children:b},n++)),a=r.index+i.length}return a<t.length&&e.push(o.jsx("span",{children:t.slice(a)},n++)),e}function BA(t){const e=[],n=/\u001b\[([0-9;]*)m/g;let s={bold:!1,dim:!1},a=0,r=0;const i=f=>{if(f===0){s={bold:!1,dim:!1};return}if(f===1){s.bold=!0;return}if(f===2){s.dim=!0;return}if(f===22){s.bold=!1,s.dim=!1;return}if(f===39){s.color=void 0;return}const h={30:"black",31:"red",32:"green",33:"yellow",34:"blue",35:"magenta",36:"cyan",37:"white",90:"bright-black",91:"bright-red",92:"bright-green",93:"bright-yellow",94:"bright-blue",95:"bright-magenta",96:"bright-cyan",97:"bright-white"};h[f]&&(s.color=h[f])},c=()=>{const f=["ansi"];return s.color&&f.push(`ansi-fg-${s.color}`),s.bold&&f.push("ansi-bold"),s.dim&&f.push("ansi-dim"),f.join(" ")};let d;for(;(d=n.exec(t))!==null;){if(d.index>a){const h=t.slice(a,d.index);e.push(o.jsx("span",{className:c(),children:h},r++))}const f=(d[1]||"0").split(";").map(h=>h===""?0:Number(h)).filter(h=>Number.isFinite(h));f.length===0?i(0):f.forEach(i),a=n.lastIndex}return a<t.length&&e.push(o.jsx("span",{className:c(),children:t.slice(a)},r++)),e}const l5=({agentId:t,onClose:e})=>{const{t:n}=dt(["terminal","common","tools"]),[s,a]=x.useState("messages"),[r,i]=x.useState([]),[c,d]=x.useState([]),[f,h]=x.useState(null),[m,b]=x.useState(""),[y,w]=x.useState(!1),[C,N]=x.useState(!1),[k,j]=x.useState({total:0,sent:0,received:0,messageTypes:[]}),[S,T]=x.useState(new Set),[D,E]=x.useState(new Set),[I,O]=x.useState("all"),[_,M]=x.useState("all"),[R,z]=x.useState("all"),[$,W]=x.useState(!1),[L,F]=x.useState(""),[H,V]=x.useState(!0),G=x.useRef(null),B=x.useRef(null),K=x.useCallback(()=>{const pe=vs.getMessages(t);i([...pe]),j(vs.getStats(t))},[t]),se=x.useCallback(()=>{const pe=vs.getLogs();d([...pe])},[]),q=x.useCallback(async()=>{w(!0),b("");try{const pe=await Bt(Rt(`/api/agents/${encodeURIComponent(t)}/process-output`)),Be=await pe.json();if(!pe.ok){h(null),b((Be==null?void 0:Be.error)||"Failed to load process output");return}h(Be)}catch(pe){h(null),b(pe instanceof Error?pe.message:"Failed to load process output")}finally{w(!1),N(!0)}},[t]);x.useEffect(()=>(K(),vs.subscribe(Be=>{(Be===t||Be==="all")&&K()})),[t,K]),x.useEffect(()=>(se(),vs.subscribeLogs(()=>{se()})),[se]);const be=x.useMemo(()=>r.filter(pe=>{if($){const Be=pe.payload;if(!(Be!=null&&Be.text)||typeof Be.text!="string")return!1}if(I!=="all"&&pe.direction!==I||_!=="all"&&pe.type!==_)return!1;if(L){const Be=L.toLowerCase(),oe=pe.type.toLowerCase().includes(Be),de=JSON.stringify(pe.payload).toLowerCase().includes(Be);return oe||de}return!0}),[r,I,_,$,L]),Ce=x.useMemo(()=>c.filter(pe=>{var Be;if(R!=="all"&&pe.level!==R)return!1;if(L){const oe=L.toLowerCase(),de=pe.message.toLowerCase().includes(oe),He=((Be=pe.source)==null?void 0:Be.toLowerCase().includes(oe))||!1,et=pe.data?JSON.stringify(pe.data).toLowerCase().includes(oe):!1;return de||He||et}return!0}),[c,R,L]);x.useEffect(()=>{H&&G.current&&s==="messages"&&(G.current.scrollTop=G.current.scrollHeight)},[be,H,s]),x.useEffect(()=>{H&&B.current&&s==="logs"&&(B.current.scrollTop=B.current.scrollHeight)},[Ce,H,s]),x.useEffect(()=>{s==="process"&&!C&&!y&&q()},[s,C,y,q]),x.useEffect(()=>{h(null),b(""),w(!1),N(!1)},[t]);const Z=pe=>{T(Be=>{const oe=new Set(Be);return oe.has(pe)?oe.delete(pe):oe.add(pe),oe})},ie=()=>{T(new Set(be.map(pe=>pe.id)))},me=()=>{T(new Set)},Ee=pe=>{navigator.clipboard.writeText(pe.raw)},Te=()=>{const pe=be.map(Be=>Be.raw).join(`
139
-
140
- `);navigator.clipboard.writeText(pe)},Ve=()=>{vs.clearMessages(t)},We=()=>{vs.clearLogs()},ee=()=>{if(!f)return;const pe=[`agentId: ${f.agentId}`,`pid: ${f.pid}`,`source: ${f.source}`,`command: ${f.command}`,`exitCode: ${f.exitCode??"null"}`,`fetchedAt: ${new Date(f.fetchedAt).toISOString()}`,"","[stdout]",f.output||"(empty)","","[stderr]",f.errorOutput||"(empty)"].join(`
141
- `);navigator.clipboard.writeText(pe)},ne=pe=>{E(Be=>{const oe=new Set(Be);return oe.has(pe)?oe.delete(pe):oe.add(pe),oe})},Ne=pe=>{switch(pe){case"debug":return{icon:"🔍",className:"log-debug"};case"info":return{icon:"ℹ️",className:"log-info"};case"warn":return{icon:"⚠️",className:"log-warn"};case"error":return{icon:"❌",className:"log-error"}}},ze=pe=>new Date(pe).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3}),st=pe=>pe<1024?`${pe}B`:pe<1024*1024?`${(pe/1024).toFixed(1)}KB`:`${(pe/(1024*1024)).toFixed(1)}MB`;return o.jsxs("div",{className:"agent-debug-panel",children:[o.jsxs("div",{className:"agent-debug-header",children:[o.jsxs("div",{className:"agent-debug-title",children:[o.jsx("span",{className:"icon",children:"🐛"}),n("terminal:debug.title")]}),o.jsx("button",{className:"close-btn",onClick:e,title:n("common:buttons.close"),children:"✕"})]}),o.jsxs("div",{className:"agent-debug-tabs",children:[o.jsxs("button",{className:`tab ${s==="messages"?"active":""}`,onClick:()=>a("messages"),children:["📨 ",n("terminal:debug.messages")," (",k.total,")"]}),o.jsxs("button",{className:`tab ${s==="logs"?"active":""}`,onClick:()=>a("logs"),children:["📋 ",n("terminal:debug.logs")," (",c.length,")"]}),o.jsxs("button",{className:`tab ${s==="process"?"active":""}`,onClick:()=>a("process"),children:["🧪 ",n("terminal:debug.processOutput")]})]}),s==="messages"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"agent-debug-stats",children:[o.jsxs("span",{className:"stat stat-sent",children:["↑ ",k.sent]}),o.jsxs("span",{className:"stat stat-received",children:["↓ ",k.received]}),o.jsxs("span",{className:"stat",children:["Types: ",k.messageTypes.length]}),o.jsxs("button",{className:`text-only-toggle ${$?"active":""}`,onClick:()=>W(!$),title:n($?"terminal:debug.allMessages":"terminal:debug.textOnly"),children:["💬 ",n($?"terminal:debug.textOnly":"terminal:debug.allMessages")]})]}),o.jsxs("div",{className:"agent-debug-controls",children:[o.jsxs("select",{value:I,onChange:pe=>O(pe.target.value),className:"filter-select",children:[o.jsx("option",{value:"all",children:n("terminal:debug.allDirections")}),o.jsx("option",{value:"sent",children:n("terminal:debug.sentOnly")}),o.jsx("option",{value:"received",children:n("terminal:debug.receivedOnly")})]}),o.jsxs("select",{value:_,onChange:pe=>M(pe.target.value),className:"filter-select",children:[o.jsx("option",{value:"all",children:n("terminal:debug.allTypes")}),k.messageTypes.map(pe=>o.jsx("option",{value:pe,children:pe},pe))]}),o.jsx("input",{type:"text",placeholder:n("terminal:debug.search"),value:L,onChange:pe=>F(pe.target.value),className:"search-input"})]}),o.jsxs("div",{className:"agent-debug-actions",children:[o.jsx("button",{onClick:ie,className:"action-btn",title:n("tools:display.expandAll"),children:n("tools:display.expandAll")}),o.jsx("button",{onClick:me,className:"action-btn",title:n("tools:display.collapseAll"),children:n("tools:display.collapseAll")}),o.jsx("button",{onClick:Te,className:"action-btn",title:n("terminal:debug.copyAll"),children:n("terminal:debug.copyAll")}),o.jsx("button",{onClick:Ve,className:"action-btn clear-btn",title:n("common:buttons.clear"),children:n("common:buttons.clear")}),o.jsxs("label",{className:"auto-scroll-label",children:[o.jsx("input",{type:"checkbox",checked:H,onChange:pe=>V(pe.target.checked)}),o.jsx("span",{className:"toggle-switch"}),n("terminal:debug.autoScroll")]})]}),o.jsx("div",{className:"agent-debug-messages",ref:G,children:be.length===0?o.jsx("div",{className:"no-messages",children:r.length===0?n("terminal:debug.noMessagesCaptured"):n("terminal:debug.noMessagesMatch")}):be.map(pe=>{const Be=S.has(pe.id),oe=pe.payload,de=oe!=null&&oe.text&&typeof oe.text=="string"?oe.text:"",He=pe.type==="event"&&(oe==null?void 0:oe.type)==="tool_start",et=pe.type==="event"&&(oe==null?void 0:oe.type)==="tool_result",ct=pe.type==="output"&&(de.startsWith("Using tool:")||de.startsWith("Tool input:")||de.startsWith("Tool result:")),fe=de.startsWith("Using tool:"),X=de.startsWith("Tool input:"),ae=de.startsWith("Tool result:");let ke="",J=null,he="";if(fe)ke=de.replace("Using tool:","").trim();else if(X)try{const gt=de.replace("Tool input:","").trim();J=JSON.parse(gt)}catch{}else ae&&(he=de.replace("Tool result:","").trim());const $e=He||et||ct,xe=He||fe||X,Pe=et||ae,te=(oe==null?void 0:oe.toolName)||ke,ge=(oe==null?void 0:oe.toolInput)||J,ve=(oe==null?void 0:oe.toolOutput)||he,Fe=de&&!ct,Ke=pe.type==="event"?oe==null?void 0:oe.type:null,ft=(()=>{var gt;if(pe.type!=="event"||!oe)return null;switch(Ke){case"init":return oe.model?`model: ${oe.model}`:null;case"text":return oe.text?oe.text.slice(0,50)+(oe.text.length>50?"...":""):null;case"step_complete":const ht=oe.tokens;return ht?`${ht.input||0} in / ${ht.output||0} out`:null;case"error":return((gt=oe.errorMessage)==null?void 0:gt.slice(0,40))||null;case"thinking":return oe.text?`"${oe.text.slice(0,30)}..."`:null;default:return null}})(),it=xe&&ge?(()=>{if(!ge)return null;const gt=Object.keys(ge);if(gt.length===0)return null;const ht=["file_path","path","pattern","command","content","query"];return gt.sort((tn,Ae)=>{const Le=ht.indexOf(tn),Ye=ht.indexOf(Ae);return Le===-1&&Ye===-1?0:Le===-1?1:Ye===-1?-1:Le-Ye}).slice(0,3).map(tn=>{let Ae=ge[tn];return typeof Ae=="string"?Ae.length>60&&(Ae=Ae.slice(0,60)+"..."):typeof Ae=="object"&&(Ae=JSON.stringify(Ae).slice(0,40)+"..."),{key:tn,value:Ae}})})():null;return o.jsxs("div",{className:`debug-message debug-message-${pe.direction} ${Fe?"has-text-preview":""} ${$e?"is-tool-event":""} ${xe?"tool-start":""} ${Pe?"tool-result":""}`,children:[o.jsxs("div",{className:"message-header",onClick:()=>Z(pe.id),children:[o.jsx("span",{className:"expand-icon",children:Be?"▼":"▶"}),o.jsx("span",{className:`direction direction-${pe.direction}`,children:pe.direction==="sent"?"↑ SENT":"↓ RECEIVED"}),o.jsx("span",{className:"message-type",children:$e?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"tool-icon",children:xe?"🔧":"✅"}),xe?"tool_start":"tool_result"]}):Ke?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"event-base",children:pe.type}),o.jsx("span",{className:"event-subtype",children:Ke})]}):pe.type}),$e&&te&&o.jsx("span",{className:"tool-name-inline",children:te}),!$e&&ft&&o.jsx("span",{className:"event-summary",children:ft}),o.jsx("span",{className:"message-time",children:ze(pe.timestamp)}),o.jsx("span",{className:"message-size",children:st(pe.size)}),o.jsx("button",{className:"copy-btn",onClick:gt=>{gt.stopPropagation(),Ee(pe)},title:"Copy message",children:"📋"})]}),Be&&o.jsxs("div",{className:"message-body",children:[xe&&(ge||X&&!J)&&o.jsxs("div",{className:"tool-preview",children:[it&&it.length>0&&o.jsx("div",{className:"tool-inputs",children:it.map(({key:gt,value:ht})=>o.jsxs("div",{className:"tool-input-item",children:[o.jsxs("span",{className:"tool-input-key",children:[gt,":"]}),o.jsx("span",{className:"tool-input-value",children:String(ht)})]},gt))}),X&&!J&&o.jsx("div",{className:"tool-raw-input",children:de.replace("Tool input:","").trim().slice(0,200)})]}),Pe&&ve&&o.jsx("div",{className:"tool-preview tool-result-preview",children:o.jsx("div",{className:"tool-output-preview",children:typeof ve=="string"?ve.slice(0,200)+(ve.length>200?"...":""):JSON.stringify(ve).slice(0,200)})}),Fe&&!$e&&o.jsx("div",{className:"message-text-preview expanded",children:o.jsx("span",{className:"text-content",children:oe.text})}),o.jsx("pre",{children:PA(JSON.stringify(pe.payload,(gt,ht)=>ht===void 0?null:typeof ht=="object"&&ht!==null&&!(ht instanceof Date)&&!Array.isArray(ht)&&typeof ht[Symbol.iterator]=="function"?Array.from(ht):typeof ht=="function"?`[Function: ${ht.name||"anonymous"}]`:ht,2))})]})]},pe.id)})})]}),s==="logs"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"agent-debug-controls",children:[o.jsxs("select",{value:R,onChange:pe=>z(pe.target.value),className:"filter-select",children:[o.jsx("option",{value:"all",children:n("terminal:debug.allLevels")}),o.jsx("option",{value:"debug",children:n("terminal:debug.debug")}),o.jsx("option",{value:"info",children:n("terminal:debug.info")}),o.jsx("option",{value:"warn",children:n("terminal:debug.warning")}),o.jsx("option",{value:"error",children:n("terminal:debug.error")})]}),o.jsx("input",{type:"text",placeholder:n("terminal:debug.searchLogs"),value:L,onChange:pe=>F(pe.target.value),className:"search-input"})]}),o.jsxs("div",{className:"agent-debug-actions",children:[o.jsx("button",{onClick:We,className:"action-btn clear-btn",title:n("terminal:debug.clearLogs"),children:n("terminal:debug.clearLogs")}),o.jsxs("label",{className:"auto-scroll-label",children:[o.jsx("input",{type:"checkbox",checked:H,onChange:pe=>V(pe.target.checked)}),o.jsx("span",{className:"toggle-switch"}),n("terminal:debug.autoScroll")]})]}),o.jsx("div",{className:"agent-debug-messages agent-debug-logs",ref:B,children:Ce.length===0?o.jsx("div",{className:"no-messages",children:c.length===0?n("terminal:debug.noLogsYet"):n("terminal:debug.noLogsMatch")}):Ce.map(pe=>{const Be=D.has(pe.id),oe=Ne(pe.level);return o.jsxs("div",{className:`debug-message debug-log ${oe.className}`,children:[o.jsxs("div",{className:"message-header",onClick:()=>ne(pe.id),children:[o.jsx("span",{className:"expand-icon",children:Be?"▼":"▶"}),o.jsx("span",{className:"log-level-icon",children:oe.icon}),o.jsx("span",{className:"log-level",children:pe.level.toUpperCase()}),pe.source&&o.jsxs("span",{className:"log-source",children:["[",pe.source,"]"]}),o.jsx("span",{className:"log-message",children:pe.message}),o.jsx("span",{className:"message-time",children:ze(pe.timestamp)})]}),Be&&pe.data!==void 0?o.jsx("div",{className:"message-body",children:o.jsx("pre",{children:o.jsx(o.Fragment,{children:PA(JSON.stringify(pe.data,(de,He)=>He===void 0?null:typeof He=="object"&&He!==null&&!(He instanceof Date)&&!Array.isArray(He)&&typeof He[Symbol.iterator]=="function"?Array.from(He):typeof He=="function"?`[Function: ${He.name||"anonymous"}]`:He,2))})})}):null]},pe.id)})})]}),s==="process"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"agent-debug-actions process-actions",children:[o.jsx("button",{onClick:()=>{q()},className:"action-btn",title:"Refresh process output",disabled:y,children:n(y?"common:status.loading":"common:buttons.refresh")}),o.jsx("button",{onClick:ee,className:"action-btn",title:"Copy process output",disabled:!f,children:n("terminal:debug.copyOutput")})]}),o.jsx("div",{className:"agent-debug-messages agent-debug-process-output",children:m?o.jsx("div",{className:"process-error",children:m}):f?o.jsxs("div",{className:"process-output-block",children:[o.jsxs("div",{className:"process-meta-grid",children:[o.jsxs("div",{className:"meta-item",children:[o.jsx("span",{className:"meta-label",children:n("terminal:debug.pid")}),o.jsx("span",{className:"meta-value",children:f.pid})]}),o.jsxs("div",{className:"meta-item",children:[o.jsx("span",{className:"meta-label",children:n("tools:metadata.source")}),o.jsx("span",{className:"meta-value",children:f.source})]}),o.jsxs("div",{className:"meta-item",children:[o.jsx("span",{className:"meta-label",children:n("terminal:debug.exit")}),o.jsx("span",{className:"meta-value",children:f.exitCode??"null"})]}),o.jsxs("div",{className:"meta-item",children:[o.jsx("span",{className:"meta-label",children:n("terminal:debug.fetched")}),o.jsx("span",{className:"meta-value",children:new Date(f.fetchedAt).toLocaleString("en-US",{hour12:!1})})]})]}),o.jsxs("div",{className:"process-command",children:[o.jsx("span",{className:"meta-label",children:n("terminal:debug.command")}),o.jsx("code",{children:f.command})]}),o.jsx("div",{className:"process-stream-label",children:"stdout"}),o.jsx("pre",{className:"ansi-output",children:BA(f.output||"(empty)")}),o.jsx("div",{className:"process-stream-label",children:"stderr"}),o.jsx("pre",{className:"ansi-output",children:BA(f.errorOutput||"(empty)")})]}):o.jsx("div",{className:"no-messages",children:n(y?"terminal:debug.loadingProcessOutput":"terminal:debug.noProcessOutput")})})]})]})},c5=3,u5=3;function d5(t){const[e,n]=x.useState([]),[s,a]=x.useState(!1),[r,i]=x.useState(new Set),[c,d]=x.useState(new Set),f=x.useRef(e),h=x.useRef(c),m=x.useRef(r);x.useEffect(()=>{f.current=e},[e]),x.useEffect(()=>{h.current=c},[c]),x.useEffect(()=>{m.current=r},[r]);const b=x.useCallback(async()=>{if(t){a(!0);try{const j=await Bt(Rt(`/api/files/tree?path=${encodeURIComponent(t)}&depth=${c5}`)),S=await j.json();if(j.ok&&S.tree){const T=cp(S.tree),D={name:S.name,path:t,isDirectory:!0,size:0,extension:"",children:T};n([D]);const E=new Set([t]);Cx(T,E),d(E),i(new Set([t]))}}catch(j){console.error("[FileExplorer] Failed to load tree:",j),n([])}a(!1)}},[t]),y=x.useCallback(async j=>{try{const S=await Bt(Rt(`/api/files/tree?path=${encodeURIComponent(j)}&depth=${u5}`)),T=await S.json();if(S.ok&&T.tree){const D=cp(T.tree);return n(E=>{const I=JSON.parse(JSON.stringify(E)),O=Su(I,j);return O&&(O.children=D),I}),d(E=>{const I=new Set(E);return I.add(j),Cx(T.tree,I),I}),D}}catch(S){console.error("[FileExplorer] Failed to load children:",S)}return null},[]),w=x.useCallback(async j=>{await y(j)},[y]),C=x.useCallback((j,S)=>{if(!j||!S||j===S)return;const T=E=>E===j?S:E.startsWith(`${j}/`)?`${S}${E.slice(j.length)}`:E,D=E=>{const I=E.map(O=>{const _=T(O.path),M=O.children?D(O.children):void 0;return{...O,path:_,name:_.split("/").pop()||O.name,extension:O.isDirectory?"":f5(_),children:M}});return cp(I)};n(E=>D(E)),d(E=>{const I=new Set;for(const O of E)I.add(T(O));return I})},[]),N=x.useCallback(async j=>{if(m.current.has(j))i(T=>{const D=new Set(T);return D.delete(j),D});else{i(D=>{const E=new Set(D);return E.add(j),E});let T=Su(f.current,j);for(;T&&T.isDirectory;){let D=T.children;if((!D||D.length===0)&&!h.current.has(T.path)&&(D=await y(T.path)||[]),!D||D.length===0)break;const E=D.filter(_=>_.isDirectory);if(D.some(_=>!_.isDirectory)||E.length!==1)break;const O=E[0];i(_=>{const M=new Set(_);return M.add(O.path),M}),T=O}}},[y]),k=x.useCallback(async j=>{var _;if(!j)return;const S=(t==null?void 0:t.replace(/\/+$/,""))||null,T=()=>new Promise(M=>{requestAnimationFrame(()=>M())}),D=async(M,R=20)=>{for(let z=0;z<R;z++){const $=Su(f.current,M);if($)return $;await T()}return null},E=[];if(S&&j.startsWith(S)){E.push(S);const R=j.substring(S.length).split("/").filter(Boolean);let z=S;for(const $ of R)z=`${z}/${$}`,E.push(z)}else E.push(j);for(const M of E){const R=await D(M);R!=null&&R.isDirectory&&(h.current.has(R.path)||(await y(R.path),await T()))}const I=new Set(m.current);let O=0;for(;O<E.length;){const M=E[O],R=Su(f.current,M);if(!(R!=null&&R.isDirectory)){O++;continue}let z=R;for(;z.children&&z.children.length===1&&((_=z.children[0])!=null&&_.isDirectory);)z=z.children[0];for(I.add(z.path);O<E.length;){if(E[O]===z.path){O++;break}O++}}i(I),await T()},[t,y]);return{tree:e,loading:s,expandedPaths:r,loadTree:b,reloadDirectory:w,renamePathInTree:C,togglePath:N,expandToPath:k,setExpandedPaths:i}}function f5(t){const e=t.lastIndexOf(".");return e===-1?"":t.slice(e).toLowerCase()}function Su(t,e){for(const n of t){if(n.path===e)return n;if(n.children){const s=Su(n.children,e);if(s)return s}}return null}function Cx(t,e){for(const n of t)n.isDirectory&&n.children&&n.children.length>0&&(e.add(n.path),Cx(n.children,e))}function p5(t){return[...t].sort((e,n)=>e.isDirectory&&!n.isDirectory?-1:!e.isDirectory&&n.isDirectory?1:e.name.toLowerCase().localeCompare(n.name.toLowerCase()))}function cp(t){return p5(t).map(n=>n.isDirectory&&n.children?{...n,children:cp(n.children)}:n)}function FA(t){switch(t){case"modified":return"#c89a5a";case"added":return"#5cb88a";case"deleted":return"#c85a5a";case"untracked":return"#6ab8c8";case"renamed":return"#9a80c0";default:return}}function h5(t){return[...t].sort((e,n)=>e.isDirectory&&!n.isDirectory?-1:!e.isDirectory&&n.isDirectory?1:e.name.toLowerCase().localeCompare(n.name.toLowerCase()))}function Ax(t){var s;if(!t.isDirectory)return{displayName:t.name,terminalNode:t,expansionPath:t.path};const e=[t.name];let n=t;for(;n.children&&n.children.length===1&&((s=n.children[0])!=null&&s.isDirectory);)n=n.children[0],e.push(n.name);return{displayName:e.join("/"),terminalNode:n,expansionPath:n.path}}function m5({text:t,query:e}){const n=q6(t,e);return n?o.jsxs(o.Fragment,{children:[t.slice(0,n.start),o.jsx("mark",{className:"search-highlight",children:t.slice(n.start,n.end)}),t.slice(n.end)]}):o.jsx(o.Fragment,{children:t})}function g5({node:t,depth:e,selectedPath:n,expandedPaths:s,onSelect:a,onToggle:r,onContextMenu:i,searchQuery:c}){const d=x.useMemo(()=>Ax(t),[t]),f=s.has(d.expansionPath),h=n===t.path||n===d.expansionPath,m=FA(t.gitStatus),b=x.useMemo(()=>d.terminalNode.children?h5(d.terminalNode.children):[],[d]),y=C=>{C.stopPropagation(),t.isDirectory?r(d.expansionPath):a(t)},w=C=>{i&&(C.preventDefault(),C.stopPropagation(),i(C,d.terminalNode))};return o.jsxs("div",{className:"tree-node-wrapper",children:[o.jsxs("div",{className:`tree-node ${h?"selected":""} ${t.isDirectory?"directory":"file"} ${f?"expanded":""}`,style:{paddingLeft:`${e*16}px`},onClick:y,onContextMenu:w,"data-path":t.path,children:[t.isDirectory?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:`tree-arrow ${f?"expanded":""}`,children:"▸"}),o.jsxs("span",{className:"tree-folder-icon-wrapper",children:[o.jsx("span",{className:"tree-folder-icon",style:{backgroundImage:`url('${f?"/assets/vscode-icons/default_folder_opened.svg":"/assets/vscode-icons/default_folder.svg"}')`},role:"img","aria-label":"folder"}),t.hasGitChanges&&o.jsx("span",{className:"tree-folder-git-dot",style:{backgroundColor:FA(t.gitStatus)||"#c89a5a"}})]})]}):o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"tree-arrow-spacer"}),o.jsx("span",{className:"tree-icon",style:{backgroundImage:`url('${W6(t)}')`},role:"img","aria-label":"file"})]}),o.jsx("span",{className:"tree-name",style:m?{color:m}:void 0,children:o.jsx(m5,{text:d.displayName,query:c})})]}),t.isDirectory&&f&&b.length>0&&o.jsx("div",{className:"tree-children",children:b.map(C=>o.jsx(Oy,{node:C,depth:e+1,selectedPath:n,expandedPaths:s,onSelect:a,onToggle:r,onContextMenu:i,searchQuery:c},C.path))})]})}const Oy=x.memo(g5,(t,e)=>{if(t.node!==e.node||t.depth!==e.depth||t.searchQuery!==e.searchQuery||t.onContextMenu!==e.onContextMenu)return!1;const n=Ax(t.node).expansionPath,s=Ax(e.node).expansionPath,a=t.selectedPath===t.node.path||t.selectedPath===n,r=e.selectedPath===e.node.path||e.selectedPath===s;if(a!==r)return!1;if(t.node.isDirectory){const i=t.expandedPaths.has(n),c=e.expandedPaths.has(s);if(i!==c||c&&(t.expandedPaths!==e.expandedPaths||t.selectedPath!==e.selectedPath))return!1}return!0});Oy.displayName="TreeNodeItem";function Nb(t){const e=t.lastIndexOf(".")>=0?t.substring(t.lastIndexOf(".")):"";return np(e)}function b5(t,e){if(e.type==="circle"){const a=t.x-e.center.x,r=t.z-e.center.z,i=Math.max(e.width,e.height)/2;return a*a+r*r<=i*i}const n=e.width/2,s=e.height/2;return t.x>=e.center.x-n&&t.x<=e.center.x+n&&t.z>=e.center.z-s&&t.z<=e.center.z+s}function Gf(t){return t==="modified"||t==="renamed"||t==="deleted"||t==="conflict"}function JT({node:t,depth:e,expandedDirs:n,onToggleDir:s,onFileClick:a,onContextMenu:r,onDiscard:i,repoDir:c}){if(t.isDirectory){const m=n.has(t.path),b=m?"/assets/vscode-icons/default_folder_opened.svg":"/assets/vscode-icons/default_folder.svg";return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"guake-git-file guake-git-tree-dir",style:{paddingLeft:`${12+e*20}px`},onClick:()=>s(t.path),children:[o.jsx("span",{className:"guake-git-repo-arrow",style:{marginRight:4},children:m?"▼":"▶"}),o.jsx("img",{src:b,alt:"",className:"guake-git-file-icon guake-git-folder-icon"}),o.jsx("span",{className:"guake-git-file-name",children:t.name}),o.jsx("span",{className:"guake-git-repo-count",style:{marginLeft:"auto"},children:t.fileCount})]}),m&&t.children.map(y=>o.jsx(JT,{node:y,depth:e+1,expandedDirs:n,onToggleDir:s,onFileClick:a,onContextMenu:r,onDiscard:i,repoDir:c},y.path))]})}const d=t.file,f=jN[d.status],h=ph(d.name);return o.jsxs("div",{className:"guake-git-file","data-status":d.status,style:{paddingLeft:`${28+e*20}px`},onClick:()=>a(d,c),onContextMenu:r?m=>r(m,d,c):void 0,title:d.path,children:[h&&o.jsx("img",{src:h,alt:"",className:"guake-git-file-icon"}),o.jsx("span",{className:"guake-git-file-name",children:d.name}),o.jsx("span",{className:"guake-git-file-status",style:{color:f.color,marginLeft:"auto"},title:f.label,children:f.icon}),i&&o.jsx("button",{className:"guake-git-discard-btn",title:d.status==="untracked"||d.status==="added"?"Delete file":"Discard changes",onClick:m=>i(m,d,c),children:"↩"})]})}function x5({agentId:t,agents:e,onClose:n,branchInfoMap:s,fetchRemote:a,fetchingDirs:r}){const{t:i}=dt(["terminal","common"]),c=ur(),[d,f]=x.useState([]),[h,m]=x.useState(!1),[b,y]=x.useState(new Set),[w,C]=x.useState(new Set),[N,k]=x.useState(null),[j,S]=x.useState(!1),[T,D]=x.useState(()=>Fa(pt.GIT_PANEL_VIEW_MODE,"flat")==="tree"?"tree":"flat"),[E,I]=x.useState(()=>Fa(pt.GIT_PANEL_MODE,"changes")==="explorer"?"explorer":"changes"),[O,_]=x.useState(()=>Na(pt.GIT_PANEL_FOLDER_IDX,0)),M=x.useCallback(fe=>{D(fe),Wr(pt.GIT_PANEL_VIEW_MODE,fe)},[]),R=x.useCallback(fe=>{I(fe),Wr(pt.GIT_PANEL_MODE,fe)},[]),z=x.useCallback(fe=>{_(fe),La(pt.GIT_PANEL_FOLDER_IDX,fe)},[]),[$,W]=x.useState(null),[L,F]=x.useState(null),[H,V]=x.useState(null),G=Se.useRef(!1),B=Se.useRef(t),K=x.useMemo(()=>{const fe=new Set,X=[];for(const ke of c.values())if(!(ke.archived||ke.directories.length===0)&&ke.assignedAgentIds.includes(t)){fe.add(ke.id);for(const J of ke.directories)J&&J.trim()&&X.push(J)}const ae=e.get(t);if(ae){for(const ke of c.values())if(!(ke.archived||ke.directories.length===0||fe.has(ke.id))&&b5({x:ae.position.x,z:ae.position.z},ke))for(const J of ke.directories)J&&J.trim()&&X.push(J)}return ae!=null&&ae.cwd&&!X.includes(ae.cwd)&&X.unshift(ae.cwd),[...new Set(X)]},[t,e,c]),se=K.length>0?K[O]||K[0]:null,q=d5(E==="explorer"?se:null);x.useEffect(()=>{E==="explorer"&&se&&q.loadTree()},[E,se]);const be=x.useMemo(()=>{if(q.tree.length===0||d.length===0||!se)return q.tree;const fe=new Map;for(const ae of d)for(const ke of ae.gitStatus.files){const J=ke.path.startsWith("/")?ke.path:`${ae.dir.replace(/\/$/,"")}/${ke.path}`;fe.set(J,ke.status)}if(fe.size===0)return q.tree;const X=ae=>ae.map(ke=>{if(ke.isDirectory){const he=ke.children?X(ke.children):void 0,Oe=he?he.some($e=>$e.gitStatus||$e.hasGitChanges):!1;return Oe||he!==ke.children?{...ke,children:he,hasGitChanges:Oe}:ke}const J=fe.get(ke.path);return J?{...ke,gitStatus:J}:ke});return X(q.tree)},[q.tree,d,se]);x.useEffect(()=>{B.current!==t&&(B.current=t,G.current=!1,f([]),y(new Set),C(new Set),k(null),z(0),W(null))},[t]);const Ce=Se.useRef(0),Z=x.useCallback(async()=>{if(K.length===0)return;const fe=++Ce.current;m(!0);try{const X=[];if(await Promise.all(K.map(async ae=>{try{const ke=await Bt(Rt(`/api/files/git-status?path=${encodeURIComponent(ae)}`));if(ke.ok){const J=await ke.json();if(J.isGitRepo&&J.files.length>0){const he=ae.split("/").filter(Boolean).pop()||ae;X.push({dir:ae,dirName:he,gitStatus:J})}}}catch{}})),fe!==Ce.current)return;X.sort((ae,ke)=>ae.dirName.localeCompare(ke.dirName)),f(X),!G.current&&X.length>0&&(G.current=!0,y(new Set(X.map(ae=>ae.dir))))}finally{fe===Ce.current&&m(!1)}},[K]);x.useEffect(()=>{Z();const fe=setInterval(Z,15e3);return()=>clearInterval(fe)},[Z]);const ie=x.useCallback(async()=>{K.length!==0&&(await Promise.all(K.map(fe=>a(fe))),await Z())},[K,a,Z]),me=x.useCallback(fe=>{y(X=>{const ae=new Set(X);return ae.has(fe)?ae.delete(fe):ae.add(fe),ae})},[]),Ee=x.useCallback(fe=>{C(X=>{const ae=new Set(X);return ae.has(fe)?ae.delete(fe):ae.add(fe),ae})},[]),Te=x.useCallback(async(fe,X)=>{const ae=fe.path.startsWith("/")?fe.path:`${X.replace(/\/$/,"")}/${fe.path}`;S(!0);try{if(Gf(fe.status)){let ke="",J="";if(fe.status!=="deleted")try{const he=await Bt(Rt(`/api/files/read?path=${encodeURIComponent(ae)}`));if(he.ok){const Oe=await he.json();Oe.content!=null&&(J=Oe.content)}}catch{}try{const he=await Bt(Rt(`/api/files/git-original?path=${encodeURIComponent(ae)}`));if(he.ok){const Oe=await he.json();Oe.content!=null&&(ke=Oe.content)}}catch{}k({type:"diff",data:{filePath:ae,fileName:fe.name,originalContent:ke,modifiedContent:J,language:Nb(fe.name)}})}else{let ke="";try{const J=await Bt(Rt(`/api/files/read?path=${encodeURIComponent(ae)}`));if(J.ok){const he=await J.json();he.content!=null&&(ke=he.content)}}catch{}k({type:"content",data:{filePath:ae,fileName:fe.name,content:ke,language:Nb(fe.name)},isNewFile:!0})}}catch{}finally{S(!1)}},[]),Ve=x.useCallback(async fe=>{if(!fe.isDirectory){W(fe.path),S(!0);try{const X=fe.name,ae=Nb(X);if(fe.gitStatus&&Gf(fe.gitStatus)){let ke="",J="";if(fe.gitStatus!=="deleted")try{const he=await Bt(Rt(`/api/files/read?path=${encodeURIComponent(fe.path)}`));if(he.ok){const Oe=await he.json();Oe.content!=null&&(J=Oe.content)}}catch{}try{const he=await Bt(Rt(`/api/files/git-original?path=${encodeURIComponent(fe.path)}`));if(he.ok){const Oe=await he.json();Oe.content!=null&&(ke=Oe.content)}}catch{}k({type:"diff",data:{filePath:fe.path,fileName:X,originalContent:ke,modifiedContent:J,language:ae}})}else{let ke="";try{const J=await Bt(Rt(`/api/files/read?path=${encodeURIComponent(fe.path)}`));if(J.ok){const he=await J.json();he.content!=null&&(ke=he.content)}}catch{}k({type:"content",data:{filePath:fe.path,fileName:X,content:ke,language:ae},isNewFile:fe.gitStatus==="added"||fe.gitStatus==="untracked"})}}finally{S(!1)}}},[]),We=x.useMemo(()=>{const fe=[],X=(ae,ke,J)=>{for(const he of ae)if(he.isDirectory)X(he.children,ke,J);else{const Oe=ke.find($e=>$e.path===he.path);Oe&&fe.push({file:Oe,repoDir:J})}};for(const ae of d)if(b.has(ae.dir))if(T==="tree"){const ke=jb(ae.gitStatus.files);X(ke,ae.gitStatus.files,ae.dir)}else for(const ke of ae.gitStatus.files)fe.push({file:ke,repoDir:ae.dir});return fe},[d,T,b]),ee=x.useCallback(async fe=>{if(!N)return;const X=N.data.filePath,ae=We.findIndex(({file:Oe,repoDir:$e})=>(Oe.path.startsWith("/")?Oe.path:`${$e.replace(/\/$/,"")}/${Oe.path}`)===X);if(ae<0)return;const ke=ae+fe;if(ke<0||ke>=We.length)return;const{file:J,repoDir:he}=We[ke];await Te(J,he)},[N,We,Te]),ne=x.useMemo(()=>{if(!N)return-1;const fe=N.data.filePath;return We.findIndex(({file:X,repoDir:ae})=>(X.path.startsWith("/")?X.path:`${ae.replace(/\/$/,"")}/${X.path}`)===fe)},[N,We]),Ne=x.useCallback(()=>k(null),[]),ze=x.useCallback(()=>F(null),[]),st=x.useCallback(async fe=>{try{const X=await Bt(Rt("/api/files/delete"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:fe.path})});if(X.ok){if(fe.status==="added")try{await Bt(Rt("/api/files/git-discard"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:[{path:fe.path,status:"added"}],directory:fe.repoDir})})}catch{}}else{const ae=await X.json().catch(()=>({error:"Unknown error"}));console.error("Delete failed:",ae.error)}Z(),E==="explorer"&&q.loadTree()}catch(X){console.error("Delete request failed:",X)}finally{V(null)}},[Z,E,q]),[pe,Be]=x.useState(null),oe=x.useCallback(async fe=>{try{await Bt(Rt("/api/files/git-discard"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:[{path:fe.path,status:fe.status}],directory:fe.repoDir})}),Z()}catch{}finally{Be(null)}},[Z]),de=x.useCallback((fe,X,ae)=>{fe.stopPropagation();const ke=X.path.startsWith("/")?X.path:`${ae.replace(/\/$/,"")}/${X.path}`;X.status==="untracked"||X.status==="added"?V({path:ke,name:X.name,status:X.status,repoDir:ae}):Be({path:ke,name:X.name,status:X.status,repoDir:ae})},[]),He=x.useCallback((fe,X,ae)=>{fe.preventDefault(),fe.stopPropagation();const ke=X.path.startsWith("/")?X.path:`${ae.replace(/\/$/,"")}/${X.path}`,J=[];J.push({id:"view",label:Gf(X.status)?"View Diff":"View File",icon:Gf(X.status)?"📊":"📄",onClick:()=>Te(X,ae)}),J.push({id:"div1",label:"",divider:!0,onClick:()=>{}}),J.push({id:"copy-path",label:"Copy Full Path",icon:"🧷",onClick:()=>{navigator.clipboard.writeText(ke)}}),J.push({id:"copy-rel",label:"Copy Relative Path",icon:"📋",onClick:()=>{navigator.clipboard.writeText(X.path)}}),X.status!=="deleted"&&(J.push({id:"div2",label:"",divider:!0,onClick:()=>{}}),J.push({id:"open-editor",label:"Open in Editor",icon:"✏️",onClick:async()=>{try{await Bt(Rt("/api/files/open-in-editor"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:ke})})}catch{}}})),(X.status==="modified"||X.status==="deleted"||X.status==="renamed")&&(J.push({id:"div3",label:"",divider:!0,onClick:()=>{}}),J.push({id:"discard",label:"Discard Changes",icon:"↩️",danger:!0,onClick:async()=>{try{await Bt(Rt("/api/files/git-discard"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:[{path:ke,status:X.status}],directory:ae})}),Z()}catch{}}})),X.status!=="deleted"&&(X.status==="modified"||X.status==="renamed"||J.push({id:"div-del",label:"",divider:!0,onClick:()=>{}}),J.push({id:"delete",label:"Delete File",icon:"🗑️",danger:!0,onClick:()=>V({path:ke,name:X.name,status:X.status,repoDir:ae})})),F({isOpen:!0,position:{x:fe.clientX,y:fe.clientY},actions:J})},[Te]),et=x.useCallback((fe,X)=>{fe.preventDefault(),fe.stopPropagation();const ae=[];if(X.isDirectory||(ae.push({id:"view",label:"View File",icon:"📄",onClick:()=>Ve(X)}),ae.push({id:"div1",label:"",divider:!0,onClick:()=>{}})),ae.push({id:"copy-path",label:"Copy Full Path",icon:"🧷",onClick:()=>{navigator.clipboard.writeText(X.path)}}),se){const ke=X.path.startsWith(se)?X.path.slice(se.replace(/\/$/,"").length+1):X.path;ae.push({id:"copy-rel",label:"Copy Relative Path",icon:"📋",onClick:()=>{navigator.clipboard.writeText(ke)}})}X.isDirectory||(ae.push({id:"div2",label:"",divider:!0,onClick:()=>{}}),ae.push({id:"open-editor",label:"Open in Editor",icon:"✏️",onClick:async()=>{try{await Bt(Rt("/api/files/open-in-editor"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:X.path})})}catch{}}}),ae.push({id:"div-del",label:"",divider:!0,onClick:()=>{}}),ae.push({id:"delete",label:"Delete File",icon:"🗑️",danger:!0,onClick:()=>V({path:X.path,name:X.name,status:X.gitStatus||"untracked",repoDir:se||""})})),F({isOpen:!0,position:{x:fe.clientX,y:fe.clientY},actions:ae})},[Ve,se]),ct=d.reduce((fe,X)=>fe+X.gitStatus.files.length,0);return x.useEffect(()=>{if(!N&&!H&&!pe)return;const fe=X=>{X.key==="Escape"&&(X.stopImmediatePropagation(),X.preventDefault(),pe?Be(null):H?V(null):Ne())};return document.addEventListener("keydown",fe,!0),()=>document.removeEventListener("keydown",fe,!0)},[N,Ne,H,pe]),Xt("guake-git-diff-modal",N!==null,Ne),Xt("guake-git-delete-confirm",H!==null,()=>V(null)),Xt("guake-git-discard-confirm",pe!==null,()=>Be(null)),x.useEffect(()=>{if(T==="tree"&&w.size===0&&d.length>0){const fe=new Set;for(const X of d){const ae=jb(X.gitStatus.files),ke=J=>{for(const he of J)he.isDirectory&&(fe.add(he.path),ke(he.children))};ke(ae)}C(fe)}},[T,d]),o.jsxs(o.Fragment,{children:[H&&o.jsx("div",{className:"guake-git-diff-modal-overlay",onClick:()=>V(null),children:o.jsxs("div",{className:"guake-git-delete-confirm",onClick:fe=>fe.stopPropagation(),children:[o.jsxs("p",{children:["Delete ",o.jsx("strong",{children:H.name}),"?"]}),o.jsx("p",{className:"guake-git-delete-path",children:H.path}),o.jsxs("div",{className:"guake-git-delete-actions",children:[o.jsx("button",{className:"guake-git-delete-cancel",onClick:()=>V(null),children:"Cancel"}),o.jsx("button",{className:"guake-git-delete-btn",onClick:()=>st(H),children:"Delete"})]})]})}),pe&&o.jsx("div",{className:"guake-git-diff-modal-overlay",onClick:()=>Be(null),children:o.jsxs("div",{className:"guake-git-delete-confirm",onClick:fe=>fe.stopPropagation(),children:[o.jsxs("p",{children:["Discard changes to ",o.jsx("strong",{children:pe.name}),"?"]}),o.jsx("p",{className:"guake-git-delete-path",children:pe.path}),o.jsxs("div",{className:"guake-git-delete-actions",children:[o.jsx("button",{className:"guake-git-delete-cancel",onClick:()=>Be(null),children:"Cancel"}),o.jsx("button",{className:"guake-git-delete-btn",onClick:()=>oe(pe),children:"Discard"})]})]})}),N&&o.jsx("div",{className:"guake-git-diff-modal-overlay",onClick:Ne,children:o.jsxs("div",{className:"guake-git-diff-modal",onClick:fe=>fe.stopPropagation(),children:[o.jsxs("div",{className:"guake-git-diff-modal-header",children:[E==="changes"&&o.jsxs("div",{className:"guake-git-diff-nav",children:[o.jsx("button",{className:"guake-git-diff-nav-btn",onClick:()=>ee(-1),disabled:ne<=0,title:"Previous file",children:"‹"}),o.jsx("button",{className:"guake-git-diff-nav-btn",onClick:()=>ee(1),disabled:ne<0||ne>=We.length-1,title:"Next file",children:"›"}),ne>=0&&o.jsxs("span",{className:"guake-git-diff-nav-counter",children:[ne+1," / ",We.length]})]}),o.jsxs("span",{className:"guake-git-diff-filename",title:N.data.filePath,children:[N.data.filePath,N.type==="content"&&N.isNewFile&&o.jsx("span",{className:"guake-git-content-badge",children:"new file"})]}),o.jsx("button",{className:"guake-git-close",onClick:Ne,title:"Close (Esc)",children:"×"})]}),o.jsx("div",{className:"guake-git-diff-content",children:N.type==="diff"?o.jsx(gx,{originalContent:N.data.originalContent,modifiedContent:N.data.modifiedContent,filename:N.data.fileName,language:N.data.language}):o.jsx(gx,{originalContent:"",modifiedContent:N.data.content,filename:N.data.fileName,language:N.data.language,initialModifiedOnly:!0})})]})}),o.jsxs("div",{className:"guake-git-panel",children:[o.jsxs("div",{className:"guake-git-header",children:[o.jsx("div",{className:"guake-git-title",children:o.jsxs("div",{className:"guake-git-tabs",children:[o.jsxs("button",{className:`guake-git-tab ${E==="changes"?"active":""}`,onClick:()=>R("changes"),children:["🌿 Changes",ct>0&&o.jsx("span",{className:"guake-git-badge",children:ct})]}),o.jsx("button",{className:`guake-git-tab ${E==="explorer"?"active":""}`,onClick:()=>R("explorer"),children:"📁 Files"})]})}),o.jsxs("div",{className:"guake-git-header-actions",children:[o.jsx("button",{className:`guake-git-fetch-btn ${r.size>0?"fetching":""}`,onClick:ie,title:"Git fetch",disabled:r.size>0,children:r.size>0?"⏳":"⇣"}),E==="changes"&&o.jsxs(o.Fragment,{children:[o.jsx("button",{className:`guake-git-view-toggle ${T==="flat"?"active":""}`,onClick:()=>M("flat"),title:"Flat view",children:"☰"}),o.jsx("button",{className:`guake-git-view-toggle ${T==="tree"?"active":""}`,onClick:()=>M("tree"),title:"Tree view",children:"🌲"}),o.jsx("button",{className:"guake-git-refresh",onClick:Z,title:"Refresh",disabled:h,children:h?"⏳":"↻"})]}),E==="explorer"&&o.jsx("button",{className:"guake-git-refresh",onClick:()=>q.loadTree(),title:"Refresh",disabled:q.loading,children:q.loading?"⏳":"↻"}),o.jsx("button",{className:"guake-git-close",onClick:n,title:"Close",children:"×"})]})]}),o.jsxs("div",{className:"guake-git-body",children:[E==="changes"&&o.jsxs(o.Fragment,{children:[h&&d.length===0&&o.jsx("div",{className:"guake-git-loading",children:"Loading git status..."}),!h&&d.length===0&&o.jsx("div",{className:"guake-git-empty",children:"No git changes found"}),d.map(({dir:fe,dirName:X,gitStatus:ae})=>{const ke=s.get(fe);return o.jsxs("div",{className:"guake-git-repo",children:[o.jsxs("div",{className:`guake-git-repo-header ${b.has(fe)?"expanded":""}`,onClick:()=>me(fe),children:[o.jsx("span",{className:"guake-git-repo-arrow",children:b.has(fe)?"▼":"▶"}),o.jsx("span",{className:"guake-git-repo-name",children:X}),ae.branch&&o.jsxs("span",{className:"guake-git-repo-branch",children:["⎇ ",ae.branch]}),ke&&ke.ahead>0&&o.jsxs("span",{className:"guake-branch-ahead",children:["↑",ke.ahead]}),ke&&ke.behind>0&&o.jsxs("span",{className:"guake-branch-behind",children:["↓",ke.behind]}),o.jsx("span",{className:"guake-git-repo-count",children:ae.files.length})]}),b.has(fe)&&T==="flat"&&o.jsx("div",{className:"guake-git-file-list",children:ae.files.map(J=>{const he=jN[J.status],Oe=ph(J.name);return o.jsxs("div",{className:"guake-git-file","data-status":J.status,onClick:()=>Te(J,fe),onContextMenu:$e=>He($e,J,fe),title:J.path,children:[Oe&&o.jsx("img",{src:Oe,alt:"",className:"guake-git-file-icon"}),o.jsx("span",{className:"guake-git-file-name",children:J.name}),o.jsx("span",{className:"guake-git-file-dir",children:J.path.includes("/")?J.path.substring(0,J.path.lastIndexOf("/")):""}),o.jsx("span",{className:"guake-git-file-status",style:{color:he.color},title:he.label,children:he.icon}),o.jsx("button",{className:"guake-git-discard-btn",title:J.status==="untracked"||J.status==="added"?"Delete file":"Discard changes",onClick:$e=>de($e,J,fe),children:"↩"})]},J.path)})}),b.has(fe)&&T==="tree"&&o.jsx("div",{className:"guake-git-file-list",children:jb(ae.files).map(J=>o.jsx(JT,{node:J,depth:0,expandedDirs:w,onToggleDir:Ee,onFileClick:Te,onContextMenu:He,onDiscard:de,repoDir:fe},J.path))})]},fe)})]}),E==="explorer"&&o.jsxs(o.Fragment,{children:[K.length>1&&o.jsx("div",{className:"guake-git-folder-selector",children:K.map((fe,X)=>{const ae=fe.split("/").filter(Boolean).pop()||fe,ke=s.get(fe);return o.jsxs("button",{className:`guake-git-folder-btn ${X===O?"active":""}`,onClick:()=>z(X),title:fe,children:["📂 ",ae,ke&&o.jsxs("span",{className:"guake-git-folder-branch",children:[" ⎇ ",ke.branch]}),ke&&ke.ahead>0&&o.jsxs("span",{className:"guake-branch-ahead",children:["↑",ke.ahead]}),ke&&ke.behind>0&&o.jsxs("span",{className:"guake-branch-behind",children:["↓",ke.behind]})]},fe)})}),q.loading&&q.tree.length===0&&o.jsx("div",{className:"guake-git-loading",children:"Loading files..."}),!q.loading&&q.tree.length===0&&o.jsx("div",{className:"guake-git-empty",children:"No files found"}),o.jsx("div",{className:"guake-git-explorer-tree",children:be.map(fe=>o.jsx(Oy,{node:fe,depth:0,selectedPath:$,expandedPaths:q.expandedPaths,onSelect:Ve,onToggle:q.togglePath,onContextMenu:et,searchQuery:""},fe.path))})]})]})]}),L&&o.jsx(Do,{isOpen:L.isOpen,position:L.position,worldPosition:{x:0,z:0},actions:L.actions,onClose:ze})]})}async function hh(t,e){const n=Ii(),s=await fetch(`${Ea()}${t}`,{method:"POST",headers:{"Content-Type":"application/json","X-Auth-Token":n},body:JSON.stringify(e)});if(!s.ok)throw new Error(`Bulk action failed: ${s.statusText}`);const a=await s.json(),r=a.failed||[];return{succeeded:a.deleted||a.stopped||a.cleared||a.moved||[],failed:r}}async function y5(t){return hh("/api/agents/bulk/delete",{agentIds:t})}async function v5(t){return hh("/api/agents/bulk/stop",{agentIds:t})}async function w5(t){return hh("/api/agents/bulk/clear-context",{agentIds:t})}async function k5(t,e){return hh("/api/agents/bulk/move-area",{agentIds:t,areaId:e})}function S5(t){return Array.from(t.values())}const C5={">1h":3600*1e3,">6h":360*60*1e3,">1d":1440*60*1e3,">3d":4320*60*1e3,">7d":10080*60*1e3,">30d":720*60*60*1e3};function A5(t){const e=Date.now()-t;return e<6e4?"<1m":e<36e5?`${Math.floor(e/6e4)}m`:e<864e5?`${Math.floor(e/36e5)}h`:`${Math.floor(e/864e5)}d`}function zA(t,e){for(const n of e)if(n.assignedAgentIds.includes(t.id))return n;return null}function j5({isOpen:t,onClose:e}){const n=Kp(),s=ur(),a=S5(s),[r,i]=x.useState("all"),[c,d]=x.useState("any"),[f,h]=x.useState("all"),[m,b]=x.useState("all"),[y,w]=x.useState("all"),[C,N]=x.useState(""),[k,j]=x.useState(new Set),[S,T]=x.useState(null),[D,E]=x.useState(""),[I,O]=x.useState(null),[_,M]=x.useState(null),[R,z]=x.useState(!1);x.useEffect(()=>{t&&(j(new Set),O(null),M(null),T(null))},[t]);const $=x.useMemo(()=>{const G=Date.now(),B=C.toLowerCase().trim();return n.filter(K=>{if(r!=="all"&&K.status!==r||c!=="any"&&G-K.lastActivity<C5[c])return!1;if(f!=="all"){const se=zA(K,a);if(f==="unassigned"){if(se!==null)return!1}else if(!se||se.id!==f)return!1}if(m!=="all"&&K.provider!==m||y!=="all"&&(K.model||"sonnet")!==y)return!1;if(B){const se=K.name.toLowerCase().includes(B),q=K.class.toLowerCase().includes(B);if(!se&&!q)return!1}return!0})},[n,a,r,c,f,m,y,C]);x.useEffect(()=>{const G=new Set($.map(B=>B.id));j(B=>{const K=new Set;for(const se of B)G.has(se)&&K.add(se);return K.size!==B.size?K:B})},[$]);const W=x.useCallback(G=>{j(B=>{const K=new Set(B);return K.has(G)?K.delete(G):K.add(G),K})},[]),L=x.useCallback(()=>{j(new Set($.map(G=>G.id)))},[$]),F=x.useCallback(()=>{j(new Set)},[]),H=x.useCallback(async G=>{const B=Array.from(k);if(B.length!==0){z(!0),O(null),M(null);try{let K,se="";switch(G){case"delete":K=await y5(B),se="Deleted",K.failed.length===0&&j(new Set);break;case"stop":K=await v5(B),se="Stopped";break;case"clear-context":K=await w5(B),se="Cleared context for";break;case"move-area":K=await k5(B,D||null),se="Moved";break}K&&(K.failed.length>0?M(`${se} ${K.succeeded.length} agent(s). Failed: ${K.failed.length}`):M(`${se} ${K.succeeded.length} agent(s)`))}catch(K){O(K instanceof Error?K.message:"Action failed")}finally{z(!1),T(null)}}},[k,D]),V=x.useCallback(G=>{G.key==="Escape"&&(S?T(null):e())},[S,e]);return t?o.jsx(pr,{children:o.jsx("div",{className:`modal-overlay ${t?"visible":""}`,onClick:e,children:o.jsxs("div",{className:"bulk-manage-modal",onClick:G=>G.stopPropagation(),onKeyDown:V,children:[o.jsxs("div",{className:"modal-header",children:[o.jsx("h2",{children:"Bulk Agent Management"}),o.jsx("button",{className:"modal-close",onClick:e,"aria-label":"Close",children:"✕"})]}),o.jsx("div",{className:"bulk-filters",children:o.jsxs("div",{className:"filter-row",children:[o.jsxs("select",{value:r,onChange:G=>i(G.target.value),className:"bulk-filter-select",children:[o.jsx("option",{value:"all",children:"All Status"}),o.jsx("option",{value:"idle",children:"Idle"}),o.jsx("option",{value:"working",children:"Working"}),o.jsx("option",{value:"error",children:"Error"}),o.jsx("option",{value:"stopped",children:"Stopped"})]}),o.jsxs("select",{value:c,onChange:G=>d(G.target.value),className:"bulk-filter-select",children:[o.jsx("option",{value:"any",children:"Any Idle Time"}),o.jsx("option",{value:">1h",children:"> 1 hour"}),o.jsx("option",{value:">6h",children:"> 6 hours"}),o.jsx("option",{value:">1d",children:"> 1 day"}),o.jsx("option",{value:">3d",children:"> 3 days"}),o.jsx("option",{value:">7d",children:"> 7 days"}),o.jsx("option",{value:">30d",children:"> 30 days"})]}),o.jsxs("select",{value:f,onChange:G=>h(G.target.value),className:"bulk-filter-select",children:[o.jsx("option",{value:"all",children:"All Areas"}),o.jsx("option",{value:"unassigned",children:"Unassigned"}),a.map(G=>o.jsx("option",{value:G.id,children:G.name},G.id))]}),o.jsxs("select",{value:m,onChange:G=>b(G.target.value),className:"bulk-filter-select",children:[o.jsx("option",{value:"all",children:"All Providers"}),o.jsx("option",{value:"claude",children:"Claude"}),o.jsx("option",{value:"codex",children:"Codex"}),o.jsx("option",{value:"opencode",children:"OpenCode"})]}),o.jsxs("select",{value:y,onChange:G=>w(G.target.value),className:"bulk-filter-select",children:[o.jsx("option",{value:"all",children:"All Models"}),o.jsx("option",{value:"opus",children:"Opus"}),o.jsx("option",{value:"sonnet",children:"Sonnet"}),o.jsx("option",{value:"haiku",children:"Haiku"})]}),o.jsx("input",{type:"text",placeholder:"Search name/class...",value:C,onChange:G=>N(G.target.value),className:"bulk-filter-search"})]})}),o.jsxs("div",{className:"bulk-count-bar",children:[o.jsxs("span",{className:"bulk-count",children:[$.length," matched, ",k.size," selected"]}),o.jsxs("div",{className:"bulk-select-controls",children:[o.jsx("button",{className:"bulk-link-btn",onClick:L,children:"Select all"}),o.jsx("button",{className:"bulk-link-btn",onClick:F,children:"Select none"})]})]}),I&&o.jsxs("div",{className:"bulk-alert bulk-alert-error",children:[o.jsx("span",{className:"alert-icon",children:"!"}),I]}),_&&o.jsxs("div",{className:"bulk-alert bulk-alert-success",children:[o.jsx("span",{className:"alert-icon",children:"✓"}),_]}),o.jsx("div",{className:"bulk-agent-list",children:$.length===0?o.jsx("div",{className:"bulk-empty",children:"No agents match the current filters"}):o.jsxs("table",{className:"bulk-table",children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{className:"col-check",children:o.jsx("input",{type:"checkbox",checked:k.size===$.length&&$.length>0,onChange:()=>k.size===$.length?F():L()})}),o.jsx("th",{className:"col-name",children:"Name"}),o.jsx("th",{className:"col-class",children:"Class"}),o.jsx("th",{className:"col-status",children:"Status"}),o.jsx("th",{className:"col-idle",children:"Idle"}),o.jsx("th",{className:"col-area",children:"Area"})]})}),o.jsx("tbody",{children:$.map(G=>{const B=zA(G,a);return o.jsxs("tr",{className:k.has(G.id)?"selected":"",onClick:()=>W(G.id),children:[o.jsx("td",{className:"col-check",children:o.jsx("input",{type:"checkbox",checked:k.has(G.id),onChange:()=>W(G.id),onClick:K=>K.stopPropagation()})}),o.jsx("td",{className:"col-name",children:G.name}),o.jsx("td",{className:"col-class",children:G.class}),o.jsx("td",{className:"col-status",children:o.jsx("span",{className:`bulk-status bulk-status-${G.status}`,children:G.status})}),o.jsx("td",{className:"col-idle",children:A5(G.lastActivity)}),o.jsx("td",{className:"col-area",children:B?o.jsx("span",{className:"bulk-area-badge",style:{borderColor:B.color},children:B.name}):o.jsx("span",{className:"bulk-area-none",children:"--"})})]},G.id)})})]})}),S&&o.jsx("div",{className:"bulk-confirm-overlay",children:o.jsxs("div",{className:"bulk-confirm-box",children:[o.jsx("p",{children:S==="delete"?`Delete ${k.size} agent(s)? This cannot be undone.`:`Clear context for ${k.size} agent(s)? This will restart their sessions.`}),o.jsxs("div",{className:"bulk-confirm-actions",children:[o.jsx("button",{className:"btn btn-secondary",onClick:()=>T(null),disabled:R,children:"Cancel"}),o.jsx("button",{className:"btn btn-danger",onClick:()=>H(S),disabled:R,children:R?"Working...":"Confirm"})]})]})}),o.jsxs("div",{className:"modal-footer bulk-footer",children:[o.jsxs("div",{className:"footer-buttons-left",children:[o.jsx("button",{className:"btn btn-danger",disabled:k.size===0||R,onClick:()=>T("delete"),children:"Delete Selected"}),o.jsx("button",{className:"btn btn-secondary",disabled:k.size===0||R,onClick:()=>T("clear-context"),children:"Clear Context"})]}),o.jsxs("div",{className:"footer-buttons-right",children:[o.jsx("button",{className:"btn btn-secondary",disabled:k.size===0||R,onClick:()=>H("stop"),children:"Stop Selected"}),o.jsxs("select",{value:D,onChange:G=>E(G.target.value),className:"bulk-filter-select",disabled:k.size===0||R,children:[o.jsx("option",{value:"",children:"Unassign area"}),a.map(G=>o.jsx("option",{value:G.id,children:G.name},G.id))]}),o.jsx("button",{className:"btn btn-primary",disabled:k.size===0||R,onClick:()=>H("move-area"),children:"Move to Area"})]})]})]})})}):null}const N5={working:"🟢",idle:"💤",waiting_input:"🟡",waiting_permission:"🟠",error:"🔴",stopped:"⚫"},$A={working:"overview.statusLabels.working",idle:"overview.statusLabels.idle",waiting_input:"overview.statusLabels.waitingInput",waiting_permission:"overview.statusLabels.waitingPermission",error:"overview.statusLabels.error",stopped:"overview.statusLabels.stopped"};function T5(t){const e=U.getState().agentOutputs.get(t);if(!e||e.length===0)return null;for(let n=e.length-1;n>=0;n--){const s=e[n];if(s.isStreaming)continue;const a=s.text;if(!(a.startsWith("Using tool:")||a.startsWith("Tool input:")||a.startsWith("Tool result:")||a.startsWith("Bash output:"))&&!(a.startsWith("Tokens:")||a.startsWith("Cost:")||a.startsWith("Context:"))&&a.trim().length!==0)return s}return null}function _5(t){const e=U.getState().agentOutputs.get(t);if(!e)return 0;let n=0;for(const s of e){if(s.isStreaming)continue;const a=s.text;a.startsWith("Using tool:")||a.startsWith("Tool input:")||a.startsWith("Tool result:")||a.startsWith("Bash output:")||a.startsWith("Tokens:")||a.startsWith("Cost:")||a.startsWith("Context:")||a.trim().length!==0&&n++}return n}function Kf(t,e){const n=t.split(`
142
- `)[0];return n.length>e?n.slice(0,e)+"...":n}function E5({activeAgentId:t,onClose:e,onSelectAgent:n,agentListRef:s,twoFingerState:a}){const{t:r}=dt(["terminal","common"]),i=Kp(),[c]=Fj(),d=x.useMemo(()=>c?i.filter(Ae=>{const Le=U.getAreaForAgent(Ae.id);return zx((Le==null?void 0:Le.id)??null)}):i,[i,c]),f=c1(),h=Yx(),m=fL(),b=ur(),y=s1();x.useEffect(()=>{for(const Ae of d)!U.hasHistoryBeenFetched(Ae.id)&&!U.isLoadingHistoryForAgent(Ae.id)&&U.requestAgentSupervisorHistory(Ae.id)},[d]);const w=x.useMemo(()=>Na(pt.AOP_CONFIG,{groupByArea:!0,sortMode:"recent",filterMode:"all",allExpanded:!1,sameAreaOnly:!1,showSubagents:!0,showRecentActivity:!0,visibleAreaIds:null}),[]),[C,N]=x.useState(()=>w.allExpanded?new Set(d.map(Ae=>Ae.id)):new Set),[k,j]=x.useState(new Set),[S,T]=x.useState(null),[D,E]=x.useState(""),[I,O]=x.useState(w.sortMode),[_,M]=x.useState(w.filterMode),[R,z]=x.useState(""),[$,W]=x.useState(w.groupByArea),[L,F]=x.useState(w.allExpanded),[H,V]=x.useState(w.sameAreaOnly),[G,B]=x.useState(w.showSubagents),[K,se]=x.useState(w.showRecentActivity),[q,be]=x.useState(w.visibleAreaIds?new Set(w.visibleAreaIds):null),[Ce,Z]=x.useState(!1),[ie,me]=x.useState(""),[Ee,Te]=x.useState(!1),Ve=x.useRef(null),[We,ee]=x.useState(()=>typeof window<"u"?window.matchMedia("(max-width: 768px)").matches:!1),[ne,Ne]=x.useState(()=>typeof window<"u"?window.matchMedia("(max-width: 768px)").matches:!1),[ze,st]=x.useState(null),[pe,Be]=x.useState(null),oe=x.useRef(null),de=x.useRef(null),He=s||de,et=x.useRef(!1),ct=x.useRef(new Map),fe=a||{hoveredAgentId:null};x.useEffect(()=>{if(typeof window>"u")return;const Ae=window.matchMedia("(max-width: 768px)"),Le=Ze=>{ee(Ze),Ne(Ze)};Le(Ae.matches);const Ye=Ze=>Le(Ze.matches);return Ae.addEventListener("change",Ye),()=>Ae.removeEventListener("change",Ye)},[]),x.useEffect(()=>{if(!Ce){me("");return}const Ae=Le=>{Ve.current&&!Ve.current.contains(Le.target)&&(Z(!1),me(""))};return document.addEventListener("mousedown",Ae),()=>document.removeEventListener("mousedown",Ae)},[Ce]),x.useEffect(()=>{const Ae=Le=>{var Ze,Ot;Le.altKey&&Le.shiftKey&&!Le.ctrlKey&&!Le.metaKey&&Le.code==="KeyF"&&(Le.preventDefault(),(Ze=oe.current)==null||Ze.focus(),(Ot=oe.current)==null||Ot.select())};return document.addEventListener("keydown",Ae,!0),()=>document.removeEventListener("keydown",Ae,!0)},[]),x.useEffect(()=>{La(pt.AOP_CONFIG,{groupByArea:$,sortMode:I,filterMode:_,allExpanded:L,sameAreaOnly:H,showSubagents:G,showRecentActivity:K,visibleAreaIds:q?Array.from(q):null})},[$,I,_,L,H,G,K,q]);const X=x.useMemo(()=>{const Ae=[];for(const[,Le]of b)Le.archived||Ae.push({id:Le.id,name:Le.name,color:Le.color});return Ae.sort((Le,Ye)=>Le.name.localeCompare(Ye.name,void 0,{sensitivity:"base"})),Ae},[b]),ae=q===null,ke=x.useCallback(Ae=>{be(Le=>{if(Le===null){const Ze=new Set(X.map(Ot=>Ot.id));return Ze.add("__unassigned__"),Ze.delete(Ae),Ze}const Ye=new Set(Le);return Ye.has(Ae)?Ye.delete(Ae):Ye.add(Ae),Ye.size>=X.length+1?null:Ye})},[X]),J=x.useCallback(()=>be(null),[]),he=x.useMemo(()=>{const Ae=new Map;for(const Le of d){const Ye=U.getAreaForAgent(Le.id);!Ye||Ye.archived||Ae.set(Le.id,{color:Ye.color,name:Ye.name})}return Ae},[d,b]),Oe=x.useMemo(()=>{const Ae=new Map;for(const Le of h){const Ye=Ae.get(Le.agentId)||[];Ye.push(Le),Ae.set(Le.agentId,Ye)}return Ae},[h]),$e=x.useMemo(()=>{const Ae=new Map;for(const[,Le]of m){const Ye=Ae.get(Le.parentAgentId)||[];Ye.push(Le),Ae.set(Le.parentAgentId,Ye)}return Ae},[m]),xe=x.useMemo(()=>{const Ae=new Map;for(const Le of d){const Ye=U.getAreaForAgent(Le.id);!Ye||Ye.archived||Ae.set(Le.id,Ye.id)}return Ae},[d,b]),[Pe,te]=x.useMemo(()=>{const Ae=xe.get(t)??null,Le=new Map;return[d.filter(Ze=>{if(_==="working"&&Ze.status!=="working"||_==="idle"&&Ze.status!=="idle"||_==="error"&&Ze.status!=="error"||H&&(xe.get(Ze.id)??null)!==Ae)return!1;if(R){const Ot=R.toLowerCase();if(Ze.name.toLowerCase().includes(Ot)||Ze.id.includes(Ot)||(Ze.class||"").toLowerCase().includes(Ot)||(Ze.taskLabel||"").toLowerCase().includes(Ot))return!0;const Ft=Ze.lastAssignedTask||"";if(Ft.toLowerCase().includes(Ot))return Le.set(Ze.id,{type:"task",text:Ft}),!0;const Lt=U.getAgentSupervisorHistory(Ze.id);for(const Vt of Lt){const ln=Vt.analysis.recentWorkSummary,bt=Vt.analysis.statusDescription;if(ln.toLowerCase().includes(Ot))return Le.set(Ze.id,{type:"history",text:ln}),!0;if(bt.toLowerCase().includes(Ot))return Le.set(Ze.id,{type:"history",text:bt}),!0}for(const Vt of y)if(Vt.agentId===Ze.id&&Vt.filePath.toLowerCase().includes(Ot))return Le.set(Ze.id,{type:"file",text:Vt.filePath}),!0;return!1}return!0}),Le]},[d,_,R,H,xe,t,y]),ge=x.useCallback((Ae,Le="__default__")=>{const Ye=new Set(Ae.map(rt=>rt.id)),Ze=ct.current.get(Le),Ot=!Ze||Ze.length!==Ae.length||Ze.some(rt=>!Ye.has(rt)),Ft=rt=>{const xt=!!(rt.isBoss||rt.class==="boss");if(I==="name")return`${xt?"0":"1"}`;if(I==="status"){const En=["working","waiting_input","waiting_permission","error","idle","stopped"].indexOf(rt.status),nn=f.has(rt.id)?"0":"1";return`${xt?"0":"1"}-${En}-${nn}`}return`${xt?"0":"1"}`};let Lt=!1;if(Ze&&!Ot){const rt=ct.current.get(Le+"__buckets");if(rt)for(const xt of Ae){const $t=Ze.indexOf(xt.id);if($t>=0&&rt[$t]!==Ft(xt)){Lt=!0;break}}else Lt=!0}let Vt;if(Ot||Lt||I==="recent")Vt=[...Ae].sort((rt,xt)=>{var Os,ps;const $t=!!(rt.isBoss||rt.class==="boss"),En=!!(xt.isBoss||xt.class==="boss");if($t!==En)return $t?-1:1;if(I==="name")return rt.name.localeCompare(xt.name);if(I==="status"){const ks=["working","waiting_input","waiting_permission","error","idle","stopped"],Qn=ks.indexOf(rt.status)-ks.indexOf(xt.status);if(Qn!==0)return Qn;const Ss=f.has(rt.id),Fn=f.has(xt.id);if(Ss!==Fn)return Ss?-1:1;if(rt.status==="working"&&xt.status==="working")return rt.name.localeCompare(xt.name);if(rt.status==="idle"&&xt.status==="idle"){const Ls=!!rt.taskLabel,Is=!!xt.taskLabel;return Ls!==Is?Ls?-1:1:(xt.lastActivity||0)-(rt.lastActivity||0)}return(xt.lastActivity||0)-(rt.lastActivity||0)}const nn=((Os=(Oe.get(rt.id)||[])[0])==null?void 0:Os.timestamp)||rt.lastActivity||0;return(((ps=(Oe.get(xt.id)||[])[0])==null?void 0:ps.timestamp)||xt.lastActivity||0)-nn});else{const rt=new Map(Ae.map(xt=>[xt.id,xt]));Vt=Ze.map(xt=>rt.get(xt)).filter(Boolean)}const ln=Vt.map(rt=>rt.id),bt=Vt.map(rt=>Ft(rt));return ct.current.set(Le,ln),ct.current.set(Le+"__buckets",bt),Vt},[I,Oe,f]),ve=x.useMemo(()=>{if(!$)return[{area:null,agents:ge(Pe,"__flat__")}];const Ae=new Map,Le=[];for(const Ze of Pe){const Ot=U.getAreaForAgent(Ze.id);if(!Ot||Ot.archived){Le.push(Ze);continue}const Ft=Ae.get(Ot.id);Ft?Ft.push(Ze):Ae.set(Ot.id,[Ze])}const Ye=[];for(const[Ze,Ot]of b){if(Ot.archived||q&&!q.has(Ze))continue;const Ft=Ae.get(Ze)||[];Ft.length>0&&Ye.push({area:Ot,agents:ge(Ft,`area_${Ze}`)})}return Le.length>0&&(!q||q.has("__unassigned__"))&&Ye.push({area:null,agents:ge(Le,"__unassigned__")}),Ye},[b,Pe,ge,$,q]),Fe=x.useCallback(Ae=>{const Le=Lt=>f.has(Lt.id),Ye=Ae.findIndex(Lt=>Le(Lt)&&Lt.status!=="working"),Ze=Ye>=0,Ot=Ae.findIndex(Lt=>Lt.status==="idle"&&!Le(Lt)),Ft=Ot>=0&&Ae.slice(0,Ot).some(Lt=>Lt.status==="working"||Le(Lt));return Ae.map((Lt,Vt)=>o.jsxs(Se.Fragment,{children:[Ze&&Vt===Ye&&o.jsx("div",{className:"aop-status-separator aop-status-separator--unread",role:"separator","aria-label":"unread notifications",children:o.jsx("span",{children:"Unread notifications"})}),Ft&&Vt===Ot&&o.jsx("div",{className:"aop-status-separator",role:"separator","aria-label":"idle agents",children:o.jsx("span",{children:r("terminal:overview.statusLabels.idle")})}),o.jsx(M5,{agent:Lt,isActive:Lt.id===t,isExpanded:C.has(Lt.id),isMobile:We,hasPendingRead:f.has(Lt.id),isTwoFingerHovered:fe.hoveredAgentId===Lt.id,showSubagents:G,showRecentActivity:K,showAreaChip:!$,toolExecs:Oe.get(Lt.id)||[],subagents:$e.get(Lt.id)||[],areaInfo:he.get(Lt.id),matchContext:te.get(Lt.id),onToggle:()=>at(Lt.id),onSelect:()=>n(Lt.id),onClearContext:()=>U.clearContext(Lt.id),onContextMenu:ln=>Be({agentId:Lt.id,position:ln})})]},Lt.id))},[r,t,C,f,fe.hoveredAgentId,G,K,$,Oe,$e,he,te,n]),Ke=x.useMemo(()=>{const Ae={total:d.length,working:0,idle:0,error:0};for(const Le of d)Le.status==="working"?Ae.working++:Le.status==="error"?Ae.error++:Le.status==="idle"&&Ae.idle++;return Ae},[d]),at=Ae=>{N(Le=>{const Ye=new Set(Le);return Ye.has(Ae)?Ye.delete(Ae):Ye.add(Ae),Ye})},ft=Ae=>{j(Le=>{const Ye=new Set(Le);return Ye.has(Ae)?Ye.delete(Ae):Ye.add(Ae),Ye})},wt=()=>{N(new Set(d.map(Ae=>Ae.id))),F(!0)},it=()=>{N(new Set),F(!1)},gt=x.useCallback(Ae=>{window.dispatchEvent(new CustomEvent("tide:open-spawn-modal",{detail:{areaId:Ae.id,position:{x:Ae.center.x,z:Ae.center.z}}}))},[]),ht=x.useCallback((Ae,Le)=>{st({areaId:Ae.id,position:Le})},[]),Gt=x.useMemo(()=>{if(!ze)return[];const Ae=b.get(ze.areaId);return Ae?[{id:"spawn-agent",label:r("common:agentBar.newAgent"),icon:"+",onClick:()=>gt(Ae)}]:[]},[ze,b,gt,r]),tn=x.useMemo(()=>{if(!pe)return[];const Ae=d.find(Ye=>Ye.id===pe.agentId);if(!Ae)return[];const Le=C.has(Ae.id);return[{id:"toggle-expand",label:Le?r("terminal:overview.collapse",{defaultValue:"Collapse"}):r("terminal:overview.expand",{defaultValue:"Expand"}),icon:Le?"▾":"▸",onClick:()=>at(Ae.id)},{id:"clear-context",label:r("terminal:overview.clearContext",{defaultValue:"Clear context"}),icon:"🧹",onClick:()=>U.clearContext(Ae.id)},{id:"remove-agent",label:r("terminal:overview.removeAgent",{defaultValue:"Remove agent"}),icon:"🗑",danger:!0,onClick:()=>U.removeAgent(Ae.id)}]},[pe,d,C,r]);return x.useEffect(()=>{const Ae=He.current;if(!Ae)return;const Le=requestAnimationFrame(()=>{const Ye=Ae.querySelector(".aop-agent-card.active");if(!Ye)return;const Ze=Ae.getBoundingClientRect(),Ot=Ye.getBoundingClientRect(),Ft=Ot.top-Ze.top,Lt=Ae.scrollTop+Ft-(Ze.height-Ot.height)/2,Vt=Math.max(0,Lt);Math.abs(Ae.scrollTop-Vt)<2||(Ae.scrollTo({top:Vt,behavior:et.current?"smooth":"auto"}),et.current=!0)});return()=>cancelAnimationFrame(Le)},[t]),o.jsxs("div",{className:`agent-overview-panel${We&&ne?" mobile-filters-collapsed":""}`,children:[o.jsxs("div",{className:"aop-stats-row",children:[o.jsx("span",{className:"stat",children:r("terminal:overview.agents",{count:Ke.total})}),Ke.working>0&&o.jsxs("span",{className:"stat stat-working",children:["🟢 ",Ke.working]}),Ke.idle>0&&o.jsxs("span",{className:"stat stat-idle",children:["💤 ",Ke.idle]}),Ke.error>0&&o.jsxs("span",{className:"stat stat-error",children:["🔴 ",Ke.error]}),o.jsxs("div",{className:"aop-row-controls",children:[o.jsx("button",{type:"button",className:"aop-search-toggle",onClick:()=>{Ne(!1),requestAnimationFrame(()=>{var Ae;return(Ae=oe.current)==null?void 0:Ae.focus()})},title:"Search agents",children:"🔍"}),o.jsx("button",{type:"button",className:`aop-filters-toggle${ne?" collapsed":""}`,onClick:()=>Ne(Ae=>!Ae),title:ne?"Show filters":"Hide filters",children:ne?"Filters":"Hide filters"}),o.jsxs("select",{value:_,onChange:Ae=>M(Ae.target.value),className:"filter-select",children:[o.jsx("option",{value:"all",children:r("terminal:overview.allStatus")}),o.jsx("option",{value:"working",children:r("terminal:overview.statusLabels.working")}),o.jsx("option",{value:"idle",children:r("terminal:overview.statusLabels.idle")}),o.jsx("option",{value:"error",children:r("terminal:overview.statusLabels.error")})]}),o.jsxs("select",{value:I,onChange:Ae=>O(Ae.target.value),className:"filter-select",children:[o.jsx("option",{value:"recent",children:r("terminal:overview.mostRecent")}),o.jsx("option",{value:"status",children:r("terminal:overview.byStatus")}),o.jsx("option",{value:"name",children:r("terminal:overview.byName")})]}),o.jsx("input",{ref:oe,type:"text",placeholder:r("terminal:overview.searchAgents"),value:R,onChange:Ae=>z(Ae.target.value),onKeyDown:Ae=>{Ae.key==="Enter"&&(Ae.nativeEvent.isComposing||R.trim().length!==0&&Pe.length!==0&&(Ae.preventDefault(),n(Pe[0].id),z("")))},className:"search-input"}),o.jsx("button",{className:"close-btn",onClick:e,title:r("common:buttons.close"),children:"✕"})]})]}),o.jsxs("div",{className:"aop-actions",children:[o.jsx("button",{onClick:wt,className:"action-btn",title:r("common:buttons.expand"),children:r("common:buttons.expand")}),o.jsx("button",{onClick:it,className:"action-btn",title:r("common:buttons.collapse"),children:r("common:buttons.collapse")}),o.jsx("button",{onClick:()=>W(Ae=>!Ae),className:`action-btn action-btn--toggle${$?" active":""}`,title:r("terminal:overview.areas"),children:r("terminal:overview.areas")}),$&&X.length>0&&o.jsxs("div",{className:"aop-area-filter",ref:Ve,children:[o.jsxs("button",{className:`action-btn action-btn--toggle${ae?"":" active"}`,onClick:()=>Z(Ae=>!Ae),title:"Filter areas",children:[ae?"All areas":`${q.size} areas`,o.jsx("span",{className:"aop-area-filter-caret",children:Ce?"▴":"▾"})]}),Ce&&o.jsxs("div",{className:"aop-area-filter-dropdown",children:[X.length>=5&&o.jsx("div",{className:"aop-area-filter-search",children:o.jsx("input",{type:"text",placeholder:"Filter areas...",value:ie,onChange:Ae=>me(Ae.target.value),onClick:Ae=>Ae.stopPropagation(),autoFocus:!0})}),(()=>{const Ae=ie.toLowerCase().trim(),Le=Ae?X.filter(Ze=>Ze.name.toLowerCase().includes(Ae)):X,Ye=!Ae||"unassigned".includes(Ae);return o.jsxs(o.Fragment,{children:[!Ae&&o.jsxs(o.Fragment,{children:[o.jsxs("label",{className:"aop-area-filter-option",onClick:J,children:[o.jsx("input",{type:"checkbox",checked:ae,readOnly:!0}),o.jsx("span",{className:"aop-area-filter-color",style:{background:"#6272a4"}}),o.jsx("span",{children:"All"})]}),o.jsx("div",{className:"aop-area-filter-divider"})]}),Le.map(Ze=>{const Ot=ae||((q==null?void 0:q.has(Ze.id))??!1);return o.jsxs("label",{className:"aop-area-filter-option",onClick:Ft=>{Ft.preventDefault(),ke(Ze.id)},children:[o.jsx("input",{type:"checkbox",checked:Ot,readOnly:!0}),o.jsx("span",{className:"aop-area-filter-color",style:{background:Ze.color}}),o.jsx("span",{className:"aop-area-filter-name",children:Ze.name})]},Ze.id)}),Ye&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"aop-area-filter-divider"}),o.jsxs("label",{className:"aop-area-filter-option",onClick:Ze=>{Ze.preventDefault(),ke("__unassigned__")},children:[o.jsx("input",{type:"checkbox",checked:ae||((q==null?void 0:q.has("__unassigned__"))??!1),readOnly:!0}),o.jsx("span",{className:"aop-area-filter-color",style:{background:"#6272a4"}}),o.jsx("span",{className:"aop-area-filter-name",children:"Unassigned"})]})]}),Ae&&Le.length===0&&!Ye&&o.jsx("div",{className:"aop-area-filter-empty",children:"No matching areas"})]})})()]})]}),o.jsx("button",{onClick:()=>V(Ae=>!Ae),className:`action-btn action-btn--toggle${H?" active":""}`,title:r("terminal:overview.sameAreaOnly"),children:r("terminal:overview.sameAreaOnly")}),o.jsx("button",{onClick:()=>B(Ae=>!Ae),className:`action-btn action-btn--toggle${G?" active":""}`,title:"Subagents",children:"Subagents"}),o.jsx("button",{onClick:()=>se(Ae=>!Ae),className:`action-btn action-btn--toggle${K?" active":""}`,title:r("terminal:overview.recentActivity"),children:"Activity"}),o.jsx("button",{onClick:()=>Te(!0),className:"action-btn",title:"Bulk manage agents",children:"Bulk Manage"})]}),o.jsx("div",{className:"aop-agent-list",ref:He,children:ve.length===0?o.jsx("div",{className:"aop-empty",children:d.length===0?r("terminal:overview.noAgentsDeployed"):r("terminal:overview.noAgentsMatch")}):ve.map(Ae=>{var Ft,Lt,Vt;const Le=((Ft=Ae.area)==null?void 0:Ft.id)||"__unassigned__",Ye=((Lt=Ae.area)==null?void 0:Lt.name)||($?r("terminal:overview.unassigned"):""),Ze=((Vt=Ae.area)==null?void 0:Vt.color)||"#6272a4",Ot=k.has(Le);return o.jsxs("div",{className:"aop-area-group",children:[$&&o.jsxs("div",{className:"aop-area-header",onClick:()=>ft(Le),style:{borderLeftColor:Ze},children:[o.jsx("span",{className:"aop-area-expand",children:Ot?"▸":"▾"}),o.jsx("span",{className:"aop-area-color",style:{background:Ze}}),o.jsx("span",{className:"aop-area-name",onContextMenu:ln=>{Ae.area&&(ln.preventDefault(),ln.stopPropagation(),ht(Ae.area,{x:ln.clientX,y:ln.clientY}))},children:Ye}),o.jsx("button",{type:"button",className:"aop-area-eye-btn",title:"Hide area",onClick:ln=>{ln.preventDefault(),ln.stopPropagation(),ke(Le)},children:"◉"}),Ae.area&&o.jsx("button",{type:"button",className:"aop-area-eye-btn",title:"Edit area prompt",onClick:ln=>{ln.preventDefault(),ln.stopPropagation();const bt=Ae.area;S===bt.id?T(null):(E(bt.prompt||""),T(bt.id))},children:"✎"}),Ae.area&&(()=>{const ln=Ae.area;return o.jsx("button",{type:"button",className:"aop-area-add-btn",title:r("common:agentBar.newAgent"),onClick:bt=>{bt.preventDefault(),bt.stopPropagation();const rt=bt.currentTarget.getBoundingClientRect();ht(ln,{x:rt.left,y:rt.bottom+6})},children:"+"})})(),o.jsx("span",{className:"aop-area-count",children:Ae.agents.length})]}),S===Le&&Ae.area&&o.jsxs("div",{className:"aop-area-prompt-editor",onClick:ln=>ln.stopPropagation(),children:[o.jsx("textarea",{className:"aop-area-prompt-textarea",value:D,onChange:ln=>E(ln.target.value),placeholder:"System prompt for agents in this area...",rows:3,autoFocus:!0}),o.jsxs("div",{className:"aop-area-prompt-actions",children:[o.jsx("button",{className:"aop-area-prompt-save",onClick:()=>{U.updateArea(Ae.area.id,{prompt:D}),T(null)},children:"Save"}),o.jsx("button",{className:"aop-area-prompt-cancel",onClick:()=>T(null),children:"Cancel"})]})]}),(!$||!Ot)&&o.jsx("div",{className:$?"aop-area-content":void 0,children:Fe(Ae.agents)})]},Le)})}),o.jsx(Do,{isOpen:ze!==null,position:(ze==null?void 0:ze.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:Gt,onClose:()=>st(null)}),o.jsx(Do,{isOpen:pe!==null,position:(pe==null?void 0:pe.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:tn,onClose:()=>Be(null)}),o.jsx(j5,{isOpen:Ee,onClose:()=>Te(!1)})]})}function M5({agent:t,isActive:e,isExpanded:n,isMobile:s,hasPendingRead:a,isTwoFingerHovered:r,showSubagents:i,showRecentActivity:c,showAreaChip:d,toolExecs:f,subagents:h,areaInfo:m,matchContext:b,onToggle:y,onSelect:w,onClearContext:C,onContextMenu:N}){const{t:k}=dt(["terminal","common"]),j=dr(),S=fr(t.class,j),T=t.isBoss||t.class==="boss",D=N5[t.status]||"❓",E=$A[t.status]?k(`terminal:${$A[t.status]}`):t.status,I=f.slice(0,s?4:8),O=T5(t.id),_=_5(t.id),M=s?40:80,R=x.useMemo(()=>{var He,et,ct,fe,X,ae,ke;const oe=[],de=new Set;for(const J of h)oe.push({id:J.id,name:J.name,type:J.subagentType,description:J.description,status:J.status,timestamp:J.startedAt}),de.add(J.name);for(const J of f){if(J.toolName!=="Task"&&J.toolName!=="Agent")continue;const Oe=((He=J.toolInput)==null?void 0:He.description)||((et=J.toolInput)==null?void 0:et.name)||""||((fe=(ct=J.toolInput)==null?void 0:ct.prompt)==null?void 0:fe.slice(0,40))||"Task";de.has(Oe)||(de.add(Oe),oe.push({id:`task-${J.timestamp}`,name:Oe,type:((X=J.toolInput)==null?void 0:X.subagent_type)||"unknown",description:(ke=(ae=J.toolInput)==null?void 0:ae.prompt)==null?void 0:ke.slice(0,100),status:"completed",timestamp:J.timestamp}))}return oe.sort((J,he)=>he.timestamp-J.timestamp),oe},[h,f]),z=R.filter(oe=>oe.status==="working"||oe.status==="spawning"),$=i&&R.length>0,W=c&&I.length>0,L=$||W,F=t.contextLimit>0?t.contextUsed/t.contextLimit:0,H=Math.min(100,F*100),V=Math.min(1,Math.max(0,F)),B=`hsl(${Math.round((1-V)*120)} 80% 45% / 0.55)`,K=112,se=56,[q,be]=x.useState(0),[Ce,Z]=x.useState(!1),[ie,me]=x.useState(!1),Ee=x.useRef(0),Te=x.useRef(0),Ve=x.useRef(0),We=x.useRef(!1),ee=x.useRef(!1),ne=x.useRef(!1);x.useEffect(()=>{s||(be(0),Z(!1),me(!1))},[s]);const Ne=x.useCallback(()=>{if(ne.current){ne.current=!1;return}if(Ce){be(0),Z(!1),ne.current=!0;return}w()},[w,Ce]),ze=x.useCallback(oe=>{if(!s||oe.touches.length!==1)return;const de=oe.touches[0];Ee.current=de.clientX,Te.current=de.clientY,Ve.current=Ce?K:0,We.current=!1,ee.current=!1,me(!0)},[s,Ce]),st=x.useCallback(oe=>{if(!s||!ie||oe.touches.length!==1)return;const de=oe.touches[0],He=de.clientX-Ee.current,et=de.clientY-Te.current;if(!We.current){if(Math.abs(He)<8&&Math.abs(et)<8)return;We.current=!0,ee.current=Math.abs(He)>Math.abs(et)}if(!ee.current)return;oe.preventDefault();const ct=Math.max(0,Math.min(K,Ve.current-He));be(ct)},[s,ie]),pe=x.useCallback(()=>{if(!s||!ie)return;if(me(!1),!ee.current){Ce||be(0);return}const oe=q>=se,de=oe!==Ce||q!==(oe?K:0);Z(oe),be(oe?K:0),de&&(ne.current=!0)},[s,ie,q,Ce]),Be=x.useCallback(oe=>{oe.stopPropagation(),C(),Z(!1),be(0),ne.current=!0},[C]);return o.jsxs("div",{className:`aop-agent-swipe${s?" swipe-enabled":""}${Ce?" revealed":""}`,children:[s&&o.jsxs("button",{type:"button",className:"aop-swipe-clear-action",onClick:Be,title:k("terminal:overview.clearContext",{defaultValue:"Clear context"}),children:["🧹 ",k("terminal:overview.clearContext",{defaultValue:"Clear"})]}),o.jsxs("div",{className:`aop-agent-card ${T?"boss":""} ${e?"active":""} ${t.status} ${a?"unread":""}${r?" two-finger-hover":""}`,"data-agent-id":t.id,onClick:Ne,onTouchStart:ze,onTouchMove:st,onTouchEnd:pe,onTouchCancel:pe,style:s?{transform:`translateX(-${q}px)`,transition:ie?"none":"transform 0.18s ease"}:void 0,children:[o.jsxs("div",{className:"aop-agent-header",onContextMenu:oe=>{oe.preventDefault(),oe.stopPropagation(),N({x:oe.clientX,y:oe.clientY})},children:[o.jsx("button",{type:"button",className:"aop-expand-icon","aria-label":n?"Collapse agent":"Expand agent",onClick:oe=>{oe.stopPropagation(),y()},children:n?"▾":"▸"}),o.jsx("span",{className:"aop-agent-status",title:E,children:D}),t.status==="working"&&o.jsx("span",{className:"aop-working-indicator","aria-label":k("terminal:overview.statusLabels.working"),title:k("terminal:overview.statusLabels.working")}),o.jsx("img",{src:t.provider==="codex"?"/assets/codex.png":t.provider==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:t.provider,className:"aop-provider-icon",title:t.provider==="codex"?"Codex Agent":t.provider==="opencode"?"OpenCode Agent":"Claude Agent"}),o.jsxs("span",{className:"aop-agent-name",title:k("terminal:overview.clickToSwitch"),style:m?{background:`${m.color}12`,borderColor:`${m.color}28`}:void 0,children:[T&&o.jsx("span",{className:"aop-boss-crown","aria-hidden":"true",children:"👑"}),t.name]}),o.jsx("span",{className:"aop-agent-class-icon",style:{color:`color-mix(in srgb, ${S.color} 60%, var(--text-muted))`},title:t.class||"agent",children:S.icon}),a&&o.jsx("span",{className:"aop-pending-read-indicator",title:"Pending read",children:"!"}),_>0&&o.jsx("span",{className:"aop-msg-count",title:k("terminal:overview.messages",{count:_}),children:_}),z.length>0&&o.jsxs("span",{className:"aop-subagent-count",title:z.map(oe=>`${oe.name}: ${oe.description||oe.type}`).join(`
143
- `),children:["⑂",z.length]}),R.length>0&&z.length===0&&o.jsxs("span",{className:"aop-subagent-count",title:k("terminal:overview.subagentsCompleted",{count:R.length}),style:{opacity:.5},children:["⑂",R.length]}),t.class&&o.jsx("span",{className:"aop-agent-class",style:{color:`color-mix(in srgb, ${S.color} 65%, var(--text-muted))`,background:`${S.color}10`,borderColor:`${S.color}25`},children:t.class}),d&&m&&o.jsx("span",{className:"aop-area-chip",style:{background:`${m.color}10`,borderColor:`${m.color}25`,color:`color-mix(in srgb, ${m.color} 65%, var(--text-muted))`},children:m.name})]}),t.taskLabel&&o.jsxs("div",{className:"aop-task-label",title:t.taskLabel,children:[o.jsx("span",{className:"task-prefix",children:"📋"}),o.jsx("span",{className:"task-text",children:Kf(t.taskLabel,M)})]}),O&&(n||O.isUserPrompt)&&o.jsxs("div",{className:`aop-last-message ${O.isUserPrompt?"user":"assistant"}`,title:O.text.split(`
144
- `)[0],children:[o.jsx("span",{className:"lm-prefix",children:O.isUserPrompt?"▶":"◀"}),o.jsx("span",{className:"lm-text",children:Kf(O.text,M)}),o.jsx("span",{className:"lm-time",children:Fp(O.timestamp)})]}),b&&o.jsxs("div",{className:`aop-match-context aop-match-context--${b.type}`,title:b.text,children:[o.jsx("span",{className:"match-icon",children:b.type==="history"?"📜":b.type==="file"?"📄":"💬"}),o.jsx("span",{className:"match-label",children:b.type==="history"?"history":b.type==="file"?"file":"task"}),o.jsx("span",{className:"match-text",children:Kf(b.text,M)})]}),n&&o.jsxs("div",{className:"aop-agent-body",children:[$&&o.jsxs("div",{className:"aop-subagents",children:[o.jsx("div",{className:"aop-section-label",children:k("terminal:overview.subagents",{count:R.length})}),R.map(oe=>o.jsxs("div",{className:`aop-subagent-item ${oe.status}`,children:[o.jsx("span",{className:"sub-icon",children:oe.status==="completed"?"✅":oe.status==="failed"?"❌":oe.status==="unknown"?"⬜":"⑂"}),o.jsx("span",{className:"sub-name",children:oe.name}),o.jsx("span",{className:"sub-type",children:oe.type}),oe.description&&o.jsx("span",{className:"sub-desc",title:oe.description,children:Kf(oe.description,s?30:50)})]},oe.id))]}),W&&o.jsxs("div",{className:"aop-tool-timeline",children:[o.jsx("div",{className:"aop-section-label",children:k("terminal:overview.recentActivity")}),I.map((oe,de)=>{var et,ct;const He=oe.toolInput&&(oe.toolInput.file_path||((et=oe.toolInput.command)==null?void 0:et.slice(0,40))||oe.toolInput.pattern||oe.toolInput.description||((ct=oe.toolInput.prompt)==null?void 0:ct.slice(0,50)))||"";return o.jsxs("div",{className:"aop-timeline-entry",children:[o.jsx("span",{className:"tl-time",children:Fp(oe.timestamp)}),o.jsx("span",{className:"tl-icon",children:fs[oe.toolName]||fs.default}),o.jsx("span",{className:"tl-tool",children:oe.toolName}),He&&o.jsx("span",{className:"tl-param",children:He})]},`${oe.timestamp}-${de}`)})]}),!L&&(i||c)&&o.jsx("div",{className:"aop-no-activity",children:k("terminal:overview.noToolActivity")})]}),t.contextLimit>0&&o.jsx("div",{className:"aop-context-bar",title:`${Math.round(F*100)}% context used (${Math.round(t.contextUsed/1e3)}k / ${Math.round(t.contextLimit/1e3)}k)`,children:o.jsx("div",{className:"aop-context-fill",style:{width:`${H}%`,backgroundColor:B}})})]})]})}const D5={running:"🟢",stopped:"⚫",error:"🔴",unknown:"❓",starting:"🟡",stopping:"🟠"};function Tb(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(0)}KB`:t<1024*1024*1024?`${(t/1024/1024).toFixed(0)}MB`:`${(t/1024/1024/1024).toFixed(1)}GB`}function UA(t){const e=t.replace(/\/$/,"").split("/");return e.length<=2?t:`.../${e.slice(-2).join("/")}`}function _b(t){const e=window.location.protocol,n=window.location.hostname;return`${e}//${n}:${t}`}function R5({agentId:t,onClose:e}){const{t:n}=dt(["terminal","common"]),s=Wx(),a=ur(),[r,i]=x.useState(null),c=x.useMemo(()=>U.getAreaForAgent(t),[t,a]),d=x.useMemo(()=>{if(!c)return[];const k=[];for(const j of s.values())U.isPositionInArea(j.position,c)&&k.push(j);return k.sort((j,S)=>j.status==="running"&&S.status!=="running"?-1:j.status!=="running"&&S.status==="running"?1:j.name.localeCompare(S.name)),k},[c,s]),f=x.useCallback(k=>{U.selectBuilding(k),window.dispatchEvent(new CustomEvent("tide:building-action",{detail:{buildingId:k}}))},[]),h=x.useCallback((k,j)=>{U.sendBuildingCommand(k,j)},[]),m=x.useCallback((k,j)=>{k.preventDefault(),k.stopPropagation(),i({buildingId:j,position:{x:k.clientX,y:k.clientY}})},[]),b=x.useCallback(()=>{i(null)},[]),y=x.useCallback(()=>{if(!c)return{x:0,z:0};const k=()=>(Math.random()-.5)*2;return{x:c.center.x+k(),z:c.center.z+k()}},[c]),w=x.useCallback(()=>{if(!c)return;const k=y();window.dispatchEvent(new CustomEvent("tide:building-create",{detail:{position:k}}))},[c,y]),C=x.useMemo(()=>{var E;if(!r)return[];const k=U.getState().buildings.get(r.buildingId);if(!k)return[];const j=[],S=k.type==="server"||k.type==="docker"||k.type==="terminal",T=k.status==="running",D=k.type==="boss";if(j.push({id:"open",label:k.type==="database"?"Open Database":k.type==="folder"?"Open Folder":k.type==="boss"?"View Boss Logs":k.type==="terminal"?"Open Terminal":k.type==="server"&&((E=k.pm2)!=null&&E.enabled)?"View PM2 Logs":"Open",icon:k.type==="database"?"🗄️":k.type==="folder"?"📁":k.type==="terminal"?"💻":"👁️",onClick:()=>f(k.id)}),S&&(T||j.push({id:"start",label:"Start",icon:"▶",onClick:()=>U.sendBuildingCommand(k.id,"start")}),T&&(j.push({id:"restart",label:"Restart",icon:"🔄",onClick:()=>U.sendBuildingCommand(k.id,"restart")}),j.push({id:"stop",label:"Stop",icon:"⏹",onClick:()=>U.sendBuildingCommand(k.id,"stop")}))),D&&k.subordinateBuildingIds&&k.subordinateBuildingIds.length>0&&(j.push({id:"start-all",label:"Start All Subordinates",icon:"🚀",onClick:()=>{for(const I of k.subordinateBuildingIds)U.sendBuildingCommand(I,"start")}}),j.push({id:"stop-all",label:"Stop All Subordinates",icon:"⏸️",onClick:()=>{for(const I of k.subordinateBuildingIds)U.sendBuildingCommand(I,"stop")}}),j.push({id:"restart-all",label:"Restart All Subordinates",icon:"♻️",onClick:()=>{for(const I of k.subordinateBuildingIds)U.sendBuildingCommand(I,"restart")}})),S&&j.push({id:"health-check",label:"Health Check",icon:"🩺",onClick:()=>U.sendBuildingCommand(k.id,"healthCheck")}),j.push({id:"divider-edit",label:"",divider:!0,onClick:()=>{}}),j.push({id:"edit",label:"Edit Building",icon:"✏️",onClick:()=>{window.dispatchEvent(new CustomEvent("tide:building-edit",{detail:{buildingId:k.id}}))}}),j.push({id:"clone",label:"Clone Building",icon:"📋",onClick:()=>{const I=y();U.createBuilding({name:`${k.name} (Copy)`,type:k.type,style:k.style,color:k.color,scale:k.scale,position:I,cwd:k.cwd,folderPath:k.folderPath,commands:k.commands,pm2:k.pm2,docker:k.docker,database:k.database,terminal:k.terminal,urls:k.urls,subordinateBuildingIds:k.subordinateBuildingIds})}}),k.urls&&k.urls.length>0)for(const I of k.urls)j.push({id:`url-${I.label}`,label:I.label,icon:"🔗",onClick:()=>window.open(I.url,"_blank","noopener,noreferrer")});return j.push({id:"divider-danger",label:"",divider:!0,onClick:()=>{}}),j.push({id:"delete",label:"Delete Building",icon:"🗑️",danger:!0,onClick:()=>U.deleteBuilding(k.id)}),j},[r,s,f,y]),N=x.useCallback(k=>{const j=[];if(k.pm2Status){const S=k.pm2Status;S.ports&&S.ports.length>0&&j.push(o.jsxs("div",{className:"guake-building-detail",children:[o.jsx("span",{className:"detail-label",children:"Ports"}),o.jsx("span",{className:"detail-value detail-ports",children:S.ports.map((T,D)=>o.jsxs("a",{className:"guake-building-port-link",href:_b(T),target:"_blank",rel:"noopener noreferrer",onClick:E=>E.stopPropagation(),title:`Open :${T} in browser`,children:[":",T,D<S.ports.length-1?" ":""]},T))})]},"pm2-ports"))}if(k.dockerStatus){const S=k.dockerStatus,T=[];if(S.status&&T.push(o.jsx("span",{className:"detail-value",children:S.status},"st")),S.health&&S.health!=="none"){const D=S.health==="healthy"?"detail-ok":S.health==="unhealthy"?"detail-err":"";T.push(o.jsx("span",{className:`detail-value ${D}`,children:S.health},"h"))}if(S.memory!==void 0){const D=S.memoryLimit?`${Tb(S.memory)}/${Tb(S.memoryLimit)}`:Tb(S.memory);T.push(o.jsx("span",{className:"detail-value",children:D},"mem"))}S.cpu!==void 0&&T.push(o.jsxs("span",{className:"detail-value",children:[S.cpu.toFixed(1),"%"]},"cpu")),T.length>0&&j.push(o.jsxs("div",{className:"guake-building-detail",children:[o.jsx("span",{className:"detail-label",children:"Docker"}),T]},"docker")),S.image&&j.push(o.jsxs("div",{className:"guake-building-detail",children:[o.jsx("span",{className:"detail-label",children:"Image"}),o.jsx("span",{className:"detail-value detail-mono",children:S.image})]},"docker-img")),S.ports&&S.ports.length>0&&j.push(o.jsxs("div",{className:"guake-building-detail",children:[o.jsx("span",{className:"detail-label",children:"Ports"}),o.jsx("span",{className:"detail-value detail-ports",children:S.ports.map((D,E)=>o.jsxs("a",{className:"guake-building-port-link",href:_b(D.host),target:"_blank",rel:"noopener noreferrer",onClick:I=>I.stopPropagation(),title:`Open :${D.host} in browser`,children:[D.host,":",D.container,E<S.ports.length-1?" ":""]},`${D.host}-${D.container}`))})]},"docker-ports")),S.services&&S.services.length>0&&j.push(o.jsxs("div",{className:"guake-building-detail",children:[o.jsx("span",{className:"detail-label",children:"Services"}),o.jsxs("span",{className:"detail-value",children:[S.services.length," svc"]})]},"docker-svc"))}if(k.type==="database"&&k.database){const S=k.database,T=S.activeConnectionId?S.connections.find(D=>D.id===S.activeConnectionId):S.connections[0];T&&(j.push(o.jsxs("div",{className:"guake-building-detail",children:[o.jsx("span",{className:"detail-label",children:T.engine.toUpperCase()}),o.jsxs("span",{className:"detail-value detail-mono",children:[T.host,":",T.port]})]},"db-conn")),(S.activeDatabase||T.database)&&j.push(o.jsxs("div",{className:"guake-building-detail",children:[o.jsx("span",{className:"detail-label",children:"DB"}),o.jsx("span",{className:"detail-value",children:S.activeDatabase||T.database})]},"db-name"))),S.connections.length>1&&j.push(o.jsxs("div",{className:"guake-building-detail",children:[o.jsx("span",{className:"detail-label",children:"Connections"}),o.jsx("span",{className:"detail-value",children:S.connections.length})]},"db-count"))}if(k.type==="boss"&&k.subordinateBuildingIds&&k.subordinateBuildingIds.length>0){const S=k.subordinateBuildingIds;let T=0,D=0;for(const I of S){const O=s.get(I);(O==null?void 0:O.status)==="running"&&T++,(O==null?void 0:O.status)==="error"&&D++}const E=[];E.push(`${T}/${S.length} up`),D>0&&E.push(`${D} err`),j.push(o.jsxs("div",{className:"guake-building-detail",children:[o.jsx("span",{className:"detail-label",children:"Subs"}),o.jsx("span",{className:`detail-value ${D>0?"detail-err":T===S.length?"detail-ok":""}`,children:E.join(", ")})]},"boss-subs"))}if(k.terminalStatus){const S=k.terminalStatus;j.push(o.jsxs("div",{className:"guake-building-detail",children:[o.jsx("span",{className:"detail-label",children:"Terminal"}),o.jsx("span",{className:"detail-value detail-ports",children:S.port?o.jsxs("a",{className:"guake-building-port-link",href:_b(S.port),target:"_blank",rel:"noopener noreferrer",onClick:T=>T.stopPropagation(),title:`Open :${S.port} in browser`,children:[":",S.port]}):o.jsx("span",{children:"—"})})]},"terminal")),S.tmuxSession&&j.push(o.jsxs("div",{className:"guake-building-detail",children:[o.jsx("span",{className:"detail-label",children:"Session"}),o.jsx("span",{className:"detail-value detail-mono",children:S.tmuxSession})]},"terminal-session"))}return k.type==="folder"&&k.folderPath&&(j.push(o.jsxs("div",{className:"guake-building-detail",children:[o.jsx("span",{className:"detail-label",children:"Path"}),o.jsx("span",{className:"detail-value detail-mono",title:k.folderPath,children:UA(k.folderPath)})]},"folder-path")),k.gitChangesCount!==void 0&&k.gitChangesCount>0&&j.push(o.jsxs("div",{className:"guake-building-detail",children:[o.jsx("span",{className:"detail-label",children:"Git"}),o.jsxs("span",{className:"detail-value detail-warn",children:[k.gitChangesCount," changes"]})]},"folder-git"))),k.cwd&&k.type!=="folder"&&!k.pm2Status&&!k.dockerStatus&&j.push(o.jsxs("div",{className:"guake-building-detail",children:[o.jsx("span",{className:"detail-label",children:"Dir"}),o.jsx("span",{className:"detail-value detail-mono",title:k.cwd,children:UA(k.cwd)})]},"cwd")),k.lastError&&k.status==="error"&&j.push(o.jsxs("div",{className:"guake-building-detail",children:[o.jsx("span",{className:"detail-label detail-err",children:"Err"}),o.jsx("span",{className:"detail-value detail-err detail-ellipsis",title:k.lastError,children:k.lastError.length>40?k.lastError.slice(0,40)+"...":k.lastError})]},"error")),j},[s]);return o.jsxs("div",{className:"guake-buildings-panel",children:[o.jsxs("div",{className:"guake-buildings-header",children:[o.jsxs("div",{className:"guake-buildings-title",children:[o.jsx("span",{className:"guake-buildings-icon",children:"🏗️"}),o.jsx("span",{children:(c==null?void 0:c.name)||n("terminal:buildings.title",{defaultValue:"Buildings"})}),o.jsx("span",{className:"guake-buildings-count",children:d.length})]}),o.jsxs("div",{className:"guake-buildings-header-actions",children:[c&&o.jsx("button",{className:"guake-buildings-add",onClick:w,title:"Add building to area",children:"+"}),o.jsx("button",{className:"guake-buildings-close",onClick:e,title:n("common:buttons.close"),children:"✕"})]})]}),o.jsx("div",{className:"guake-buildings-body",children:c?d.length===0?o.jsx("div",{className:"guake-buildings-empty",children:n("terminal:buildings.noBuildings",{defaultValue:"No buildings in this area"})}):d.map(k=>{var E,I;const j=vL[k.type],S=D5[k.status]||"❓",T=k.type==="server"||k.type==="docker"||k.type==="terminal",D=k.status==="running";return o.jsxs("div",{className:`guake-building-item ${k.status}`,onClick:()=>f(k.id),onContextMenu:O=>m(O,k.id),children:[o.jsxs("div",{className:"guake-building-row",children:[o.jsx("span",{className:"guake-building-type-icon",title:j.description,children:j.icon}),o.jsx("span",{className:"guake-building-name",children:k.name}),o.jsx("span",{className:"guake-building-status",title:k.status,children:S})]}),N(k),k.urls&&k.urls.length>0&&o.jsx("div",{className:"guake-building-urls",children:k.urls.map((O,_)=>o.jsxs("a",{className:"guake-building-link",href:O.url,target:"_blank",rel:"noopener noreferrer",onClick:M=>M.stopPropagation(),children:["🔗 ",O.label]},_))}),T&&o.jsxs("div",{className:"guake-building-actions",children:[!D&&o.jsx("button",{className:"guake-building-action start",onClick:O=>{O.stopPropagation(),h(k.id,"start")},title:"Start",children:"▶"}),D&&o.jsxs(o.Fragment,{children:[o.jsx("button",{className:"guake-building-action restart",onClick:O=>{O.stopPropagation(),h(k.id,"restart")},title:"Restart",children:"🔄"}),o.jsx("button",{className:"guake-building-action stop",onClick:O=>{O.stopPropagation(),h(k.id,"stop")},title:"Stop",children:"⏹"}),k.type==="terminal"&&((E=k.terminalStatus)==null?void 0:E.url)&&o.jsx("button",{className:"guake-building-action terminal-below",onClick:O=>{O.stopPropagation(),window.dispatchEvent(new CustomEvent("tide:open-bottom-terminal",{detail:{buildingId:k.id}}))},onContextMenu:O=>{O.preventDefault(),O.stopPropagation(),window.dispatchEvent(new CustomEvent("tide:split-bottom-panel",{detail:{buildingId:k.id,type:"terminal",direction:"horizontal"}}))},title:"Open terminal below (right-click to split)",children:"⬇"}),k.type==="server"&&((I=k.pm2)==null?void 0:I.enabled)&&o.jsx("button",{className:"guake-building-action terminal-below",onClick:O=>{O.stopPropagation(),window.dispatchEvent(new CustomEvent("tide:open-bottom-pm2-logs",{detail:{buildingId:k.id}}))},onContextMenu:O=>{O.preventDefault(),O.stopPropagation(),window.dispatchEvent(new CustomEvent("tide:split-bottom-panel",{detail:{buildingId:k.id,type:"pm2-logs",direction:"horizontal"}}))},title:"Show logs below (right-click to split)",children:"📜"}),k.type==="database"&&k.database&&o.jsx("button",{className:"guake-building-action-btn",onClick:O=>{O.stopPropagation(),window.dispatchEvent(new CustomEvent("tide:open-bottom-database",{detail:{buildingId:k.id}}))},onContextMenu:O=>{O.preventDefault(),O.stopPropagation(),window.dispatchEvent(new CustomEvent("tide:split-bottom-panel",{detail:{buildingId:k.id,type:"database",direction:"horizontal"}}))},title:"Show database below (right-click to split)",children:"🗄️"})]})]})]},k.id)}):o.jsx("div",{className:"guake-buildings-empty",children:n("terminal:buildings.noArea",{defaultValue:"Agent is not in an area"})})}),o.jsx(Do,{isOpen:r!==null,position:(r==null?void 0:r.position)||{x:0,y:0},worldPosition:{x:0,z:0},actions:C,onClose:b})]})}const Eb={action:"#cba6f7",wait:"#f9e2af",decision:"#89b4fa",end:"#a6e3a1"},qp={running:"#a6e3a1",paused:"#f9e2af",completed:"#89b4fa",failed:"#f38ba8",cancelled:"#6c7086"};function O5(t){return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function L5(t){return new Date(t).toLocaleDateString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function I5({agentId:t,onClose:e}){const[n,s]=x.useState([]),[a,r]=x.useState([]),[i,c]=x.useState(!0),[d,f]=x.useState(null),h=x.useRef(null),m=x.useCallback(async()=>{try{const[k,j]=await Promise.all([Bt(Rt("/api/workflows/definitions")),Bt(Rt("/api/workflows/instances"))]);if(k.ok){const S=await k.json();s(S)}if(j.ok){const S=await j.json();r(S.instances||S||[])}}catch{}finally{c(!1)}},[]);x.useEffect(()=>(m(),h.current=setInterval(m,1e4),()=>{h.current&&clearInterval(h.current)}),[m]);const b=n.filter(k=>k.states.some(j=>{var S;return((S=j.action)==null?void 0:S.type)==="agent_task"&&j.action.agentId===t})),y=new Set(b.map(k=>k.id)),w=a.filter(k=>y.has(k.workflowDefId)||k.agentId===t).sort((k,j)=>k.status==="running"&&j.status!=="running"?-1:j.status==="running"&&k.status!=="running"?1:j.updatedAt-k.updatedAt);x.useEffect(()=>{if(w.length===0){f(null);return}w.find(j=>j.id===d)||f(w[0].id)},[w,d]);const C=w.find(k=>k.id===d)??null,N=C?n.find(k=>k.id===C.workflowDefId)??null:null;return o.jsxs("div",{className:"guake-git-panel",children:[o.jsxs("div",{className:"guake-git-header",children:[o.jsxs("div",{className:"guake-git-title",children:[o.jsx("span",{style:{padding:"0 12px",fontWeight:600,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:"Workflow"}),w.length>0&&o.jsx("span",{style:mt.headerBadge,children:w.length})]}),o.jsxs("div",{className:"guake-git-header-actions",children:[o.jsx("button",{className:"guake-git-refresh",onClick:m,title:"Refresh",disabled:i,children:i?"⏳":"↻"}),o.jsx("button",{className:"guake-git-close",onClick:e,title:"Close",children:"×"})]})]}),o.jsxs("div",{className:"guake-git-body",style:{display:"flex",flexDirection:"column",gap:0},children:[i&&w.length===0&&o.jsx("div",{style:mt.emptyState,children:o.jsx("span",{style:mt.loadingText,children:"Loading workflows..."})}),!i&&w.length===0&&o.jsxs("div",{style:mt.emptyState,children:[o.jsx("span",{style:mt.emptyIcon,children:"⊘"}),o.jsx("span",{children:"No workflow instances for this agent"})]}),w.length>0&&o.jsx("div",{style:mt.instanceList,children:w.map(k=>{const j=k.id===d,S=n.find(D=>D.id===k.workflowDefId),T=S==null?void 0:S.states.find(D=>D.id===k.currentStateId);return o.jsxs("button",{onClick:()=>f(k.id),style:{...mt.instanceRow,...j?mt.instanceRowSelected:{}},children:[o.jsxs("div",{style:mt.instanceRowTop,children:[o.jsx("span",{style:{...mt.statusDot,backgroundColor:qp[k.status]||"#6c7086"}}),o.jsx("span",{style:mt.instanceName,children:k.workflowName}),o.jsx("span",{style:{...mt.instanceStatus,color:qp[k.status]||"#6c7086"},children:k.status})]}),o.jsxs("div",{style:mt.instanceRowBottom,children:[o.jsx("span",{style:mt.instanceState,children:(T==null?void 0:T.name)||k.currentStateId}),o.jsx("span",{style:mt.instanceTime,children:L5(k.updatedAt)})]})]},k.id)})}),C&&N&&o.jsx(P5,{definition:N,instance:C,onRefresh:m})]})]})}function P5({definition:t,instance:e,onRefresh:n}){const s=t.states.find(i=>i.id===e.currentStateId),[a,r]=x.useState("states");return o.jsxs("div",{style:mt.instanceView,children:[o.jsxs("div",{style:mt.statusBar,children:[o.jsx("span",{style:{...mt.statusBadge,color:qp[e.status]||"#6c7086",borderColor:qp[e.status]||"#6c7086"},children:e.status}),o.jsxs("span",{style:mt.currentLabel,children:["Current: ",o.jsx("strong",{children:(s==null?void 0:s.name)||e.currentStateId})]})]}),o.jsx(B5,{definition:t,instance:e,onRefresh:n}),o.jsx("div",{style:mt.tabs,children:["states","timeline","variables"].map(i=>o.jsx("button",{onClick:()=>r(i),style:{...mt.tab,...a===i?mt.tabActive:{}},children:i==="states"?"States":i==="timeline"?"Timeline":"Variables"},i))}),o.jsxs("div",{style:mt.tabContent,children:[a==="states"&&o.jsx(F5,{definition:t,currentStateId:e.currentStateId}),a==="timeline"&&o.jsx(z5,{definition:t,instance:e}),a==="variables"&&o.jsx($5,{variables:e.variables})]})]})}function B5({definition:t,instance:e,onRefresh:n}){const[s,a]=x.useState([]),[r,i]=x.useState(!1),[c,d]=x.useState(null),[f,h]=x.useState(null),m=x.useCallback(async()=>{if(e.status!=="running"){a([]);return}i(!0);try{const y=await Bt(Rt(`/api/workflows/instances/${e.id}/available-transitions`));if(y.ok){const C=((await y.json()).transitions||[]).map(N=>{const k=t.states.find(j=>j.id===N.targetStateId);return{...N,targetStateName:k==null?void 0:k.name}});a(C)}}catch{}finally{i(!1)}},[e.id,e.status,t]);x.useEffect(()=>{m()},[m,e.currentStateId]);const b=x.useCallback(async y=>{d(y),h(null);try{const w=await Bt(Rt(`/api/workflows/instances/${e.id}/transition`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetStateId:y,reason:"Transitioned via UI panel"})});if(w.ok)setTimeout(()=>{m(),n()},500);else{const C=await w.json().catch(()=>({error:"Transition failed"}));h(C.error||"Transition failed")}}catch{h("Network error")}finally{d(null)}},[e.id,m,n]);return e.status!=="running"?null:r&&s.length===0?o.jsx("div",{style:mt.transitionSection,children:o.jsx("span",{style:mt.loadingText,children:"Loading transitions..."})}):s.length===0?null:o.jsxs("div",{style:mt.transitionSection,children:[o.jsx("div",{style:mt.transitionLabel,children:"Available Transitions"}),o.jsx("div",{style:mt.transitionButtons,children:s.map(y=>o.jsxs("button",{onClick:()=>b(y.targetStateId),disabled:c!==null,style:{...mt.transitionBtn,opacity:c===y.targetStateId?.6:1},title:`${y.name} → ${y.targetStateName||y.targetStateId}`,children:[c===y.targetStateId?"...":y.name,o.jsxs("span",{style:mt.transitionArrow,children:["→"," ",y.targetStateName||y.targetStateId]})]},y.id))}),f&&o.jsx("div",{style:mt.transitionError,children:f})]})}function F5({definition:t,currentStateId:e}){return o.jsx("div",{style:mt.stateList,children:t.states.map(n=>{const s=n.id===e;return o.jsxs("div",{style:{...mt.stateItem,...s?mt.stateItemCurrent:{}},children:[o.jsxs("div",{style:mt.stateHeader,children:[o.jsx("span",{style:{...mt.stateTypeBadge,backgroundColor:`${Eb[n.type]}22`,color:Eb[n.type],borderColor:`${Eb[n.type]}44`},children:n.type}),o.jsx("span",{style:mt.stateName,children:n.name}),s&&o.jsx("span",{style:mt.currentBadge,children:"CURRENT"})]}),n.description&&o.jsx("div",{style:mt.stateDescription,children:n.description}),n.transitions.length>0&&o.jsx("div",{style:mt.stateTransitions,children:n.transitions.map(a=>{var r;return o.jsxs("span",{style:mt.transitionChip,children:[a.name," ","→"," ",((r=t.states.find(i=>i.id===a.targetStateId))==null?void 0:r.name)||a.targetStateId]},a.id)})})]},n.id)})})}function z5({definition:t,instance:e}){return!e.history||e.history.length===0?o.jsx("div",{style:mt.emptyState,children:"No timeline events yet"}):o.jsx("div",{style:mt.timeline,children:(e.history??[]).map((n,s)=>{const a=t.states.find(i=>i.id===n.toStateId),r=n.fromStateId?t.states.find(i=>i.id===n.fromStateId):null;return o.jsxs("div",{style:mt.timelineEntry,children:[o.jsx("div",{style:mt.timelineDot}),o.jsxs("div",{style:mt.timelineContent,children:[o.jsxs("div",{style:mt.timelineHeader,children:[o.jsx("span",{style:mt.timelineTime,children:O5(n.timestamp)}),n.transitionName&&o.jsxs("span",{style:mt.timelineTransition,children:["via ",n.transitionName]})]}),o.jsxs("div",{style:mt.timelineStates,children:[r&&o.jsxs(o.Fragment,{children:[o.jsx("span",{style:mt.timelineStateName,children:r.name}),o.jsx("span",{style:mt.timelineArrow,children:"→"})]}),o.jsx("span",{style:{...mt.timelineStateName,fontWeight:600},children:(a==null?void 0:a.name)||n.toStateId})]}),n.details&&o.jsx("div",{style:mt.timelineDetails,children:n.details})]})]},s)})})}function $5({variables:t}){const e=Object.entries(t);if(e.length===0)return o.jsx("div",{style:mt.emptyState,children:"No variables set"});const n=e.filter(([a])=>!a.startsWith("wi_")),s=e.filter(([a])=>a.startsWith("wi_"));return o.jsxs("div",{style:mt.variablesSection,children:[n.length>0&&o.jsxs("div",{style:mt.varGroup,children:[o.jsx("div",{style:mt.varGroupLabel,children:"Variables"}),n.map(([a,r])=>o.jsxs("div",{style:mt.varRow,children:[o.jsx("span",{style:mt.varKey,children:a}),o.jsx("span",{style:mt.varValue,children:typeof r=="object"?JSON.stringify(r):String(r??"")})]},a))]}),s.length>0&&o.jsxs("div",{style:mt.varGroup,children:[o.jsx("div",{style:mt.varGroupLabel,children:"Internal"}),s.map(([a,r])=>o.jsxs("div",{style:mt.varRow,children:[o.jsx("span",{style:{...mt.varKey,opacity:.6},children:a}),o.jsx("span",{style:{...mt.varValue,opacity:.6},children:typeof r=="object"?JSON.stringify(r):String(r??"")})]},a))]})]})}const mt={headerBadge:{fontSize:10,fontWeight:700,background:"var(--accent-color, #cba6f7)",color:"#1e1e2e",borderRadius:8,padding:"0 5px",marginLeft:6,minWidth:16,textAlign:"center",lineHeight:"16px"},instanceList:{display:"flex",flexDirection:"column",gap:2,padding:"4px 4px 0",maxHeight:180,overflowY:"auto",flexShrink:0,borderBottom:"1px solid var(--border-color, #313244)"},instanceRow:{display:"flex",flexDirection:"column",gap:2,padding:"5px 8px",border:"1px solid transparent",borderRadius:4,background:"transparent",cursor:"pointer",textAlign:"left",width:"100%",color:"inherit"},instanceRowSelected:{background:"rgba(203, 166, 247, 0.08)",border:"1px solid var(--accent-color, #cba6f7)"},instanceRowTop:{display:"flex",alignItems:"center",gap:6},instanceRowBottom:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingLeft:12},statusDot:{display:"inline-block",width:7,height:7,borderRadius:"50%",flexShrink:0},instanceName:{fontSize:11,fontWeight:600,color:"var(--text-primary, #cdd6f4)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},instanceStatus:{fontSize:9,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.3px",flexShrink:0},instanceState:{fontSize:10,color:"var(--text-secondary, #a6adc8)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},instanceTime:{fontSize:9,color:"var(--text-secondary, #a6adc8)",opacity:.7,flexShrink:0,whiteSpace:"nowrap"},emptyState:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,padding:24,color:"var(--text-secondary, #a6adc8)",fontSize:12},emptyIcon:{fontSize:20,opacity:.5},loadingText:{fontSize:11,color:"var(--text-secondary, #a6adc8)",fontStyle:"italic"},instanceView:{display:"flex",flexDirection:"column",flex:1,minHeight:0},statusBar:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",borderBottom:"1px solid var(--border-color, #313244)",flexShrink:0},statusBadge:{fontSize:10,fontWeight:700,textTransform:"uppercase",border:"1px solid",borderRadius:4,padding:"1px 6px",letterSpacing:"0.5px"},currentLabel:{fontSize:12,color:"var(--text-secondary, #a6adc8)"},transitionSection:{padding:"8px 12px",borderBottom:"1px solid var(--border-color, #313244)",flexShrink:0},transitionLabel:{fontSize:10,fontWeight:600,textTransform:"uppercase",color:"var(--text-secondary, #a6adc8)",marginBottom:6,letterSpacing:"0.5px"},transitionButtons:{display:"flex",flexDirection:"column",gap:4},transitionBtn:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,padding:"6px 10px",border:"1px solid var(--accent-color, #cba6f7)",borderRadius:4,background:"transparent",color:"var(--accent-color, #cba6f7)",cursor:"pointer",fontSize:12,fontWeight:500,transition:"background 0.15s"},transitionArrow:{fontSize:10,opacity:.7,fontWeight:400},transitionError:{fontSize:11,color:"#f38ba8",marginTop:4},tabs:{display:"flex",borderBottom:"1px solid var(--border-color, #313244)",flexShrink:0},tab:{flex:1,padding:"6px 8px",border:"none",borderBottom:"2px solid transparent",background:"transparent",color:"var(--text-secondary, #a6adc8)",cursor:"pointer",fontSize:11,fontWeight:500,textAlign:"center"},tabActive:{color:"var(--text-primary, #cdd6f4)",borderBottomColor:"var(--accent-color, #cba6f7)"},tabContent:{flex:1,overflow:"auto",minHeight:0},stateList:{display:"flex",flexDirection:"column",gap:2,padding:4},stateItem:{padding:"6px 8px",borderRadius:4,border:"1px solid transparent"},stateItemCurrent:{border:"1px solid var(--accent-color, #cba6f7)",background:"rgba(203, 166, 247, 0.08)",boxShadow:"0 0 8px rgba(203, 166, 247, 0.15)"},stateHeader:{display:"flex",alignItems:"center",gap:6},stateTypeBadge:{fontSize:9,fontWeight:700,textTransform:"uppercase",border:"1px solid",borderRadius:3,padding:"0 4px",letterSpacing:"0.3px"},stateName:{fontSize:12,fontWeight:500,color:"var(--text-primary, #cdd6f4)"},currentBadge:{fontSize:8,fontWeight:700,color:"#cba6f7",background:"rgba(203, 166, 247, 0.15)",borderRadius:3,padding:"1px 4px",marginLeft:"auto",letterSpacing:"0.5px"},stateDescription:{fontSize:11,color:"var(--text-secondary, #a6adc8)",marginTop:3,paddingLeft:2},stateTransitions:{display:"flex",flexWrap:"wrap",gap:4,marginTop:4},transitionChip:{fontSize:9,color:"var(--text-secondary, #a6adc8)",background:"var(--surface-1, #313244)",borderRadius:3,padding:"1px 5px"},timeline:{padding:"4px 8px"},timelineEntry:{display:"flex",gap:8,paddingBottom:10,position:"relative"},timelineDot:{width:8,height:8,borderRadius:"50%",background:"var(--accent-color, #cba6f7)",flexShrink:0,marginTop:3},timelineContent:{flex:1,minWidth:0},timelineHeader:{display:"flex",alignItems:"center",gap:6,marginBottom:2},timelineTime:{fontSize:10,color:"var(--text-secondary, #a6adc8)",fontFamily:"monospace"},timelineTransition:{fontSize:10,color:"#89b4fa",fontStyle:"italic"},timelineStates:{display:"flex",alignItems:"center",gap:4,fontSize:11,color:"var(--text-primary, #cdd6f4)"},timelineStateName:{fontWeight:400},timelineArrow:{color:"var(--text-secondary, #a6adc8)",fontSize:10},timelineDetails:{fontSize:10,color:"var(--text-secondary, #a6adc8)",marginTop:2,whiteSpace:"pre-wrap",wordBreak:"break-word"},variablesSection:{padding:4},varGroup:{marginBottom:8},varGroupLabel:{fontSize:10,fontWeight:600,textTransform:"uppercase",color:"var(--text-secondary, #a6adc8)",padding:"4px 8px",letterSpacing:"0.5px"},varRow:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:8,padding:"3px 8px",borderRadius:3},varKey:{fontSize:11,fontFamily:"monospace",color:"#cba6f7",flexShrink:0},varValue:{fontSize:11,fontFamily:"monospace",color:"var(--text-primary, #cdd6f4)",textAlign:"right",wordBreak:"break-all"}};function U5({progress:t,defaultExpanded:e=!1,onAgentClick:n,onDismiss:s,onFileClick:a,onBashClick:r}){const[i,c]=x.useState(null),d=x.useRef(t.status),f=i!==null?!i:e;x.useEffect(()=>{d.current!==t.status&&(d.current==="working"&&(t.status==="completed"||t.status==="failed")&&c(!1),d.current=t.status)},[t.status]);const h={working:"#4a9eff",completed:"#22c55e",failed:"#ef4444"},m={working:"⚙️",completed:"✅",failed:"❌"},{t:b}=dt(["tools"]),y=x.useMemo(()=>ld({onFileClick:a?j=>a(j):void 0}),[a]),w={working:b("tools:progress.workingOn"),completed:b("tools:progress.taskFinished"),failed:b("tools:progress.taskFailed")},C=t.taskDescription.length>80?t.taskDescription.slice(0,80)+"...":t.taskDescription,N=()=>{const j=t.completedAt||Date.now(),S=Math.floor((j-t.startedAt)/1e3);if(S<60)return`${S}s`;const T=Math.floor(S/60),D=S%60;return`${T}m ${D}s`},k=()=>{c(f)};return o.jsxs("div",{className:`agent-progress-indicator status-${t.status} ${f?"expanded":"collapsed"}`,children:[o.jsxs("div",{className:"agent-progress-header",onClick:k,children:[o.jsx("span",{className:"agent-progress-status-icon",style:{color:h[t.status]},children:m[t.status]}),o.jsx("span",{className:"agent-progress-agent-name",onClick:j=>{n&&(j.stopPropagation(),n(t.agentId))},children:t.agentName}),o.jsx("span",{className:"agent-progress-status-text",style:{color:h[t.status]},children:w[t.status]}),o.jsx("span",{className:"agent-progress-elapsed",children:N()}),s&&o.jsx("span",{className:"agent-progress-dismiss",title:"Dismiss",onClick:j=>{j.stopPropagation(),s(t.agentId)},children:"×"}),o.jsx("span",{className:"agent-progress-toggle",children:f?"▼":"▶"})]}),!f&&o.jsx("div",{className:"agent-progress-task-preview",children:C}),f&&o.jsxs("div",{className:"agent-progress-expanded",children:[o.jsx("div",{className:"agent-progress-task-full",children:o.jsx("div",{className:"markdown-content",children:o.jsx(Fr,{remarkPlugins:[zr],components:y,children:lp(t.taskDescription)})})}),t.output.length>0&&o.jsx("div",{className:"agent-progress-output-section",children:o.jsx(H5,{output:t.output,agentId:t.agentId,maxHeight:200,onFileClick:a,onBashClick:r})})]})]})}function H5({output:t,agentId:e,maxHeight:n=200,onFileClick:s,onBashClick:a}){const r=x.useRef(null),c=_T({outputs:t,viewMode:"simple"});return x.useEffect(()=>{r.current&&(r.current.scrollTop=r.current.scrollHeight)},[c]),c.length===0?null:o.jsx("div",{ref:r,className:"agent-progress-output",style:{maxHeight:`${n}px`},children:c.map((d,f)=>o.jsx(Ry,{output:d,agentId:e,onFileClick:s,onBashClick:a},`progress-${f}`))})}const W5=x.memo(function(){const{t:e}=dt(["terminal"]),[n,s]=x.useState(!1),[a,r]=x.useState(()=>Ey()),[i,c]=x.useState(-1),d=x.useRef(null),f=x.useRef(null),h=ia.findIndex(C=>C.id===a);x.useEffect(()=>{if(!n)return;const C=N=>{d.current&&!d.current.contains(N.target)&&s(!1)};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[n]),x.useEffect(()=>{n&&c(h)},[n,h]);const m=C=>{const N=C==="next"?(h+1)%ia.length:(h-1+ia.length)%ia.length,k=ia[N],j=Pu(k.id);Up(j),r(k.id)},b=C=>{n||(C.key==="ArrowUp"||C.key==="ArrowLeft"?(C.preventDefault(),m("prev")):C.key==="ArrowDown"||C.key==="ArrowRight"?(C.preventDefault(),m("next")):(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),s(!0)))};x.useEffect(()=>{if(!n)return;const C=N=>{var k,j;N.key==="Escape"?(s(!1),(k=f.current)==null||k.focus()):N.key==="ArrowDown"?(N.preventDefault(),c(S=>(S+1)%ia.length)):N.key==="ArrowUp"?(N.preventDefault(),c(S=>(S-1+ia.length)%ia.length)):N.key==="Enter"&&i>=0&&(N.preventDefault(),y(ia[i].id),(j=f.current)==null||j.focus())};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[n,i]);const y=C=>{const N=Pu(C);Up(N),r(C),s(!1)},w=Pu(a);return o.jsxs("div",{className:"theme-selector",ref:d,children:[o.jsxs("button",{ref:f,className:"theme-selector-trigger",onClick:()=>s(!n),onKeyDown:b,title:e("terminal:themeSelector.themeTitle",{name:w.name}),children:[o.jsx("span",{className:"theme-selector-icon",children:"🎨"}),o.jsx("span",{className:"theme-selector-name",children:w.name}),o.jsx("span",{className:"theme-selector-arrow",children:n?"▲":"▼"})]}),n&&o.jsxs("div",{className:"theme-selector-dropdown",onMouseDown:C=>C.stopPropagation(),onClick:C=>C.stopPropagation(),children:[o.jsx("div",{className:"theme-selector-header",children:e("terminal:themeSelector.selectTheme")}),o.jsx("div",{className:"theme-selector-list",children:ia.map((C,N)=>o.jsxs("button",{className:`theme-selector-option ${C.id===a?"active":""} ${N===i?"highlighted":""}`,onClick:k=>{k.stopPropagation(),y(C.id)},onMouseDown:k=>k.stopPropagation(),onMouseEnter:()=>c(N),children:[o.jsx("span",{className:"theme-option-preview",style:{background:`linear-gradient(135deg, ${C.colors.bgPrimary} 0%, ${C.colors.bgSecondary} 50%, ${C.colors.accentPurple} 100%)`}}),o.jsxs("span",{className:"theme-option-info",children:[o.jsx("span",{className:"theme-option-name",children:C.name}),o.jsx("span",{className:"theme-option-desc",children:C.description})]}),C.id===a&&o.jsx("span",{className:"theme-option-check",children:"✓"})]},C.id))})]})]})}),HA=48,q5=49,V5=50,WA=48,Y5={background:"#1a1a2e",foreground:"#f8f8f2",cursor:"#f8f8f2",cursorAccent:"#1a1a2e",selectionBackground:"#44475a",black:"#21222c",red:"#ff5555",green:"#50fa7b",yellow:"#f1fa8c",blue:"#bd93f9",magenta:"#ff79c6",cyan:"#8be9fd",white:"#f8f8f2",brightBlack:"#6272a4",brightRed:"#ff6e6e",brightGreen:"#69ff94",brightYellow:"#ffffa5",brightBlue:"#d6acff",brightMagenta:"#ff92df",brightCyan:"#a4ffff",brightWhite:"#ffffff"};function G5(t,e){let n=null;const s=(...a)=>{n&&clearTimeout(n),n=setTimeout(()=>t(...a),e)};return s.cancel=()=>{n&&clearTimeout(n)},s}const Yt=(...t)=>console.log("[TerminalEmbed]",...t);function qA(t){var e;Yt("copyToClipboard called, text:",t.slice(0,50)),Yt("navigator.clipboard available:",!!navigator.clipboard),Yt("document.hasFocus:",document.hasFocus()),(e=navigator.clipboard)!=null&&e.writeText?navigator.clipboard.writeText(t).then(()=>Yt("clipboard.writeText SUCCESS"),n=>{Yt("clipboard.writeText FAILED:",(n==null?void 0:n.message)||n),VA(t)}):(Yt("navigator.clipboard not available, using fallback"),VA(t))}function VA(t){const e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.left="-9999px",e.style.opacity="0",document.body.appendChild(e),e.focus(),e.select();try{const n=document.execCommand("copy");Yt("execCommand fallback:",n?"SUCCESS":"FAILED")}catch(n){Yt("execCommand fallback error",n)}document.body.removeChild(e)}const jx=x.memo(function({terminalUrl:e,visible:n}){const s=x.useRef(null),a=x.useRef(null),r=x.useRef(null),i=x.useRef(null),c=x.useRef(!1),d=x.useRef(new TextEncoder),f=x.useCallback(m=>{const b=i.current;if(!b||b.readyState!==WebSocket.OPEN)return;const y=d.current.encode(m),w=new Uint8Array(y.length+1);w[0]=WA,w.set(y,1),b.send(w)},[]),h=x.useCallback((m,b)=>{const y=i.current;!y||y.readyState!==WebSocket.OPEN||y.send("1"+JSON.stringify({columns:m,rows:b}))},[]);return x.useEffect(()=>{if(Yt("useEffect fired",{visible:n,init:c.current,hasContainer:!!s.current,terminalUrl:e}),!n||c.current||!s.current)return;c.current=!0;let m=!1,b=null,y=null,w=null,C=null,N=null,k=null;return(async()=>{Yt("Lazy-loading xterm.js modules...");const[j,S,T,D]=await Promise.all([vt(()=>import("./xterm-BqvuqXEL.js"),[]),vt(()=>import("./addon-fit-YJmn1quW.js"),[]),vt(()=>import("./addon-clipboard-Ckztrdv4.js"),[]),vt(()=>import("./addon-web-links-BWjmmSgS.js"),[])]);if(m){Yt("Destroyed after module load, aborting");return}if(await vt(()=>Promise.resolve({}),__vite__mapDeps([16])),Yt("Modules loaded, xterm exports:",Object.keys(j)),m||!s.current)return;const E=j.Terminal,I=S.FitAddon,O=T.ClipboardAddon,_=D.WebLinksAddon;b=new E({theme:Y5,fontSize:13,scrollback:5e3,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Menlo', 'Monaco', 'Courier New', monospace",cursorBlink:!0,allowProposedApi:!0,disableStdin:!1,rightClickSelectsWord:!1}),a.current=b,y=new I,r.current=y,b.loadAddon(y),b.loadAddon(new O),b.loadAddon(new _),b.attachCustomKeyEventHandler(V=>!(V.ctrlKey&&V.key==="c"&&b.hasSelection()||V.ctrlKey&&V.key==="v"||V.ctrlKey&&V.shiftKey&&V.key==="C"||V.ctrlKey&&V.shiftKey&&V.key==="V"));const M=s.current.getBoundingClientRect();Yt("Container dimensions before open:",{w:M.width,h:M.height}),b.open(s.current),y.fit(),Yt("Terminal opened, cols:",b.cols,"rows:",b.rows),b.onSelectionChange(()=>{Yt(">>> onSelectionChange FIRED",{hasSelection:b.hasSelection()});const V=b.hasSelection()?b.getSelection():"";V&&(Yt("onSelectionChange copying text:",V.slice(0,50)),qA(V))}),s.current.addEventListener("mousedown",V=>{Yt("mousedown",{button:V.button,shiftKey:V.shiftKey,metaKey:V.metaKey,ctrlKey:V.ctrlKey})}),s.current.addEventListener("mouseup",V=>{Yt("mouseup",{button:V.button,shiftKey:V.shiftKey,hasSel:b.hasSelection()})}),Yt("Registering OSC 52 handler"),b.parser.registerOscHandler(52,V=>{Yt(">>> OSC 52 received",{dataLength:V.length,data:V.slice(0,80)});const G=V.split(";"),B=G.length>1?G.slice(1).join(";"):G[0];if(B)try{const K=Uint8Array.from(atob(B),q=>q.charCodeAt(0)),se=new TextDecoder().decode(K);Yt("OSC 52 decoded:",se.slice(0,50)),qA(se)}catch{}return!1}),k=V=>V.preventDefault(),s.current.addEventListener("contextmenu",k),b.onData(V=>f(V)),b.onBinary(V=>{const G=i.current;if(!G||G.readyState!==WebSocket.OPEN)return;const B=new Uint8Array(V.length+1);B[0]=WA;for(let K=0;K<V.length;K++)B[K+1]=V.charCodeAt(K);G.send(B)}),C=G5(()=>{y&&b&&(y.fit(),h(b.cols,b.rows))},100),N=new ResizeObserver(()=>C()),N.observe(s.current);const R=e.endsWith("/")?e.slice(0,-1):e,z=Gb(`${R}/token`);Yt("Fetching ttyd token from:",z);let $="";try{const V=await fetch(z);if(Yt("Token response status:",V.status,"content-type:",V.headers.get("content-type")),V.ok){const G=await V.text();Yt("Token raw response:",G);try{$=JSON.parse(G).token||""}catch{$=G.trim()}Yt("Parsed ttyd token:",$?$.slice(0,16)+"...":"(empty)")}else Yt("Token fetch failed:",V.status,V.statusText)}catch(V){Yt("Token fetch error:",V)}if(m)return;const W=window.location.protocol==="https:"?"wss:":"ws:",L=Gb(`${R}/ws`),F=`${W}//${window.location.host}${L}`;Yt("Connecting WebSocket to:",F),w=new WebSocket(F,["tty"]),w.binaryType="arraybuffer",i.current=w,w.onopen=()=>{if(Yt("WebSocket OPEN"),b&&y){y.fit();const V=JSON.stringify({AuthToken:$,columns:b.cols,rows:b.rows});Yt("Sending init message (as binary):",V),w.send(d.current.encode(V))}};let H=0;w.onmessage=V=>{if(b){if(H++,H<=5){const G=V.data instanceof ArrayBuffer?"ArrayBuffer":typeof V.data,B=V.data instanceof ArrayBuffer?V.data.byteLength:V.data.length;if(Yt(`WS message #${H}: type=${G} size=${B}`),V.data instanceof ArrayBuffer){const K=new Uint8Array(V.data).slice(0,20);Yt(` First bytes: [${Array.from(K).join(", ")}]`)}}if(V.data instanceof ArrayBuffer){const G=new Uint8Array(V.data);if(G.length<1)return;const B=G[0];B===HA?b.write(G.subarray(1)):B===q5?Yt("Received SET_TITLE"):B===V5?Yt("Received SET_PREFS:",new TextDecoder().decode(G.subarray(1))):Yt("Unknown binary cmd:",B,"char:",String.fromCharCode(B))}else typeof V.data=="string"&&(H<=5&&Yt("String message, first char code:",V.data.charCodeAt(0)),V.data.charCodeAt(0)===HA&&b.write(V.data.slice(1)))}},w.onclose=V=>{Yt("WebSocket CLOSED, code:",V.code,"reason:",V.reason,"wasClean:",V.wasClean,"totalMessages:",H),b&&!m&&b.write(`\r
145
- \x1B[90m[Terminal disconnected]\x1B[0m\r
146
- `)},w.onerror=V=>{Yt("WebSocket ERROR:",V)},b.onResize(({cols:V,rows:G})=>h(V,G))})(),()=>{var j;m=!0,c.current=!1,C==null||C.cancel(),N==null||N.disconnect(),k&&((j=s.current)==null||j.removeEventListener("contextmenu",k)),w&&w.readyState<=WebSocket.OPEN&&w.close(),i.current=null,b==null||b.dispose(),a.current=null,r.current=null}},[n,e,f,h]),x.useEffect(()=>{n&&r.current&&a.current&&requestAnimationFrame(()=>{var m;(m=r.current)==null||m.fit(),a.current&&h(a.current.cols,a.current.rows)})},[n,h]),o.jsx("div",{ref:s,className:"guake-bottom-terminal-embed",style:{display:n?void 0:"none"}})}),YA=1e4,K5=3e4,Q5=12e4,X5=128,J5=95;function Mb(t){const e=Ty(t);return _y(e.userMessage).userMessage.trim().replace(/\r\n/g,`
147
- `)}function Qf(t){return t.trim().replace(/\r\n/g,`
148
- `)}function Z5(t){return t.startsWith("Using tool:")||t.startsWith("Tool input:")||t.startsWith("Tool result:")||t.startsWith("Bash output:")||t.startsWith("Session started:")||t.startsWith("[thinking]")||t.startsWith("Tokens:")||t.startsWith("Cost:")||t.startsWith("Context (estimated from Codex turn usage):")||t.startsWith("🔄 [System]")||t.startsWith("📋 [System]")||t.startsWith("[System]")}function eW(t,e){if(e.type==="rectangle"&&e.width&&e.height){const n=e.width/2,s=e.height/2;return t.x>=e.center.x-n&&t.x<=e.center.x+n&&t.z>=e.center.z-s&&t.z<=e.center.z+s}if(e.type==="circle"&&e.radius){const n=t.x-e.center.x,s=t.z-e.center.z;return n*n+s*s<=e.radius*e.radius}return!1}let tW=1;function Xf(){return`bp-${tW++}`}const nW=x.memo(function({buildingId:e,filterText:n,maxRetention:s}){const{streamingBuildingLogs:a}=Rs(),r=a.get(e)||"",i=x.useRef(null),c=x.useRef(!1),d=x.useRef(0),f=n.trim().toLowerCase(),h=30,m=x.useCallback(()=>{const S=i.current;if(!S)return;const T=S.scrollTop+S.clientHeight>=S.scrollHeight-h;c.current=!T},[]),b=x.useMemo(()=>Gj(r,s),[r,s]);x.useLayoutEffect(()=>{const S=i.current;if(!S)return;const T=d.current,D=S.scrollHeight;if(c.current){const E=T-D;E>0&&(S.scrollTop=Math.max(0,S.scrollTop-E))}else S.scrollTop=D;d.current=S.scrollHeight},[b,f]);const y=x.useMemo(()=>b?f?b.split(`
149
- `).filter(S=>S.toLowerCase().includes(f)).join(`
150
- `):b:"",[b,f]),w=x.useMemo(()=>y?y.split(`
151
- `):[],[y]),C=x.useMemo(()=>w.map(S=>Kl(S||" ")),[w]),N=x.useMemo(()=>b?f&&!y?"No log lines match the current filter.":null:"Waiting for logs...",[b,f,y]),k=RN({count:C.length,getScrollElement:()=>i.current,estimateSize:()=>20,overscan:12,measureElement:S=>S.getBoundingClientRect().height}),j=k.getVirtualItems();return o.jsx("div",{ref:i,className:"guake-bottom-pm2-logs",onScroll:m,children:N?o.jsx("div",{className:"guake-bottom-pm2-logs-empty",children:N}):o.jsx("div",{className:"guake-bottom-pm2-logs-inner",style:{height:k.getTotalSize()},children:j.map(S=>o.jsx("div",{ref:k.measureElement,className:"guake-bottom-pm2-log-line","data-index":S.index,style:{transform:`translateY(${S.start}px)`},dangerouslySetInnerHTML:{__html:C[S.index]}},S.key))})})});x.memo(function({src:e,title:n}){const s=x.useRef(null),[a,r]=x.useState(!1),[i,c]=x.useState(null);x.useEffect(()=>{r(!1),c(null);const h=setTimeout(()=>c(e),400);return()=>clearTimeout(h)},[e]);const d=x.useCallback(()=>{var m;const h=s.current;if(h){document.activeElement===h&&h.blur();try{(m=h.contentWindow)==null||m.blur()}catch{}}},[]),f=x.useCallback(()=>{const h=document.querySelector(".guake-input-container"),m=h==null?void 0:h.querySelector("textarea, input");h==null||h.focus({preventScroll:!0}),m==null||m.focus({preventScroll:!0})},[]);return x.useEffect(()=>{if(!i)return;const h=Date.now(),m=()=>{Date.now()-h>1500||(d(),f())};return window.addEventListener("focus",m,!0),document.addEventListener("focusin",m,!0),()=>{window.removeEventListener("focus",m,!0),document.removeEventListener("focusin",m,!0)}},[f,d,i]),o.jsxs(o.Fragment,{children:[!a&&o.jsx("div",{className:"guake-bottom-terminal-starting",children:o.jsx("span",{children:"Loading terminal..."})}),o.jsx("iframe",{ref:s,src:i??void 0,className:`guake-bottom-terminal-iframe${a?"":" iframe-loading"}`,title:n,allow:"clipboard-read; clipboard-write",loading:"lazy",tabIndex:-1,onLoad:()=>{r(!0),d(),f()}})]})});const sW=x.memo(function({onSaveSnapshot:e}={}){var xd,Ko,ti,yd,mc;const{t:n}=dt(["terminal","common"]),s=ed(),a=Ux(),r=t1(),i=Hx(),c=i1(),d=o1(),f=n1(),h=qx(),m=Vx(),b=cL(),y=!!b,w=x.useMemo(()=>b?{id:b.agentId,name:b.agentName,class:b.agentClass,status:"idle",provider:"claude",position:{x:0,y:0,z:0},cwd:b.cwd,permissionMode:"interactive",tokensUsed:0,contextUsed:0,contextLimit:2e5,taskCount:0,createdAt:b.createdAt,lastActivity:b.createdAt}:null,[b]),C=Array.from(a),k=C.length===1?C[0]:null,S=(Qj(k)||null)??(y?w:null),T=k??(y?(b==null?void 0:b.agentId)??null:null),D=!!(S!=null&&S.sessionId)&&!y,E=ur(),I=Wx(),O=x.useMemo(()=>{if(!T)return null;const Q=new Set,ue=[];for(const Me of E.values())Me.archived||Me.directories.length===0||Me.assignedAgentIds.includes(T)&&(Q.add(Me.id),ue.push(Me));const ce=s.get(T);if(ce)for(const Me of E.values())Me.archived||Me.directories.length===0||Q.has(Me.id)||eW({x:ce.position.x,z:ce.position.z},Me)&&(Q.add(Me.id),ue.push(Me));return ue.length===0?null:ue.flatMap(Me=>Me.directories.filter(nt=>nt&&nt.trim().length>0).map(nt=>({areaId:Me.id,areaName:Me.name,dir:nt})))},[T,E,s]),_=x.useMemo(()=>{var ce;if(!T)return[];const Q=U.getAreaForAgent(T);if(!Q)return[];const ue=[];for(const Me of I.values())Me.type==="terminal"&&U.isPositionInArea(Me.position,Q)&&ue.push({id:Me.id,name:Me.name,hasUrl:!!((ce=Me.terminalStatus)!=null&&ce.url)});return ue},[T,I,E]),M=x.useMemo(()=>{var ce;if(!T)return[];const Q=U.getAreaForAgent(T);if(!Q)return[];const ue=[];for(const Me of I.values())Me.type==="server"&&((ce=Me.pm2)!=null&&ce.enabled)&&U.isPositionInArea(Me.position,Q)&&ue.push({id:Me.id,name:Me.name});return ue},[T,I,E]),R=x.useMemo(()=>{if(!T)return[];const Q=U.getAreaForAgent(T);if(!Q)return[];const ue=[];for(const ce of I.values())ce.type==="database"&&ce.database&&U.isPositionInArea(ce.position,Q)&&ue.push({id:ce.id,name:ce.name});return ue},[T,I,E]),{branches:z,fetchRemote:$,fetchingDirs:W}=qH(O),{terminalHeight:L,terminalRef:F,handleResizeStart:H}=DH(),{mobileOverviewHeight:V,handleResizeMouseDown:G,handleResizeTouchStart:B}=LH(),K=MH(),[se,q]=x.useState(()=>{const Q=Dx(pt.SIDE_PANEL_WIDTH,420);return Math.max(280,Math.min(700,Q))}),be=x.useRef(null),Ce=x.useCallback((Q,ue)=>{Q.preventDefault(),be.current={startX:Q.clientX,startW:se},document.body.style.cursor="ew-resize",document.body.style.userSelect="none",U.setTerminalResizing(!0);let ce=se;const Me=ut=>{if(!be.current)return;const Nt=ut.clientX-be.current.startX,_t=ue==="left"?-Nt:Nt;ce=Math.max(280,Math.min(700,be.current.startW+_t)),q(ce)},nt=()=>{be.current=null,document.body.style.cursor="",document.body.style.userSelect="",U.setTerminalResizing(!1),document.removeEventListener("mousemove",Me),document.removeEventListener("mouseup",nt),Rx(pt.SIDE_PANEL_WIDTH,ce)};document.addEventListener("mousemove",Me),document.addEventListener("mouseup",nt)},[se]),Z=Xj(T),ie=x.useMemo(()=>y&&b?b.outputs.map(Q=>({text:Q.text||"",timestamp:Q.timestamp,isStreaming:!1,isUserPrompt:!1})):Z,[y,b,Z]),me=x.useRef(null),Ee=x.useRef(null),Te=x.useRef(null),Ve=x.useRef(null),[We,ee]=x.useState(()=>{const Q=Fa(pt.VIEW_MODE);return Q==="simple"||Q==="chat"||Q==="advanced"?Q:Fa(pt.ADVANCED_VIEW)==="true"?"advanced":"simple"}),[ne,Ne]=x.useState(()=>Ni(pt.TERMINAL_FULLSCREEN,!1)),[ze,st]=x.useState(null),[pe,Be]=x.useState(null),[oe,de]=x.useState(null),[He,et]=x.useState(null),[ct,fe]=x.useState(!1);Xt("guake-image-modal",ze!==null,()=>st(null)),Xt("guake-bash-modal",pe!==null,()=>Be(null)),Xt("guake-response-modal",He!==null,()=>et(null)),Xt("guake-context-confirm",oe!==null,()=>de(null)),Xt("guake-agent-info",ct,()=>fe(!1));const[X,ae]=x.useState(!1),[ke,J]=x.useState(()=>vs.isEnabled()),[he,Oe]=x.useState(()=>Ni(pt.GIT_PANEL_OPEN,!1)),$e=x.useCallback(Q=>{Oe(Q),Ti(pt.GIT_PANEL_OPEN,Q)},[]),[xe,Pe]=x.useState(()=>Ni(pt.BUILDINGS_PANEL_OPEN,!1)),te=x.useCallback(Q=>{Pe(Q),Ti(pt.BUILDINGS_PANEL_OPEN,Q)},[]),[ge,ve]=x.useState(()=>Ni(pt.WORKFLOW_PANEL_OPEN,!1)),Fe=x.useCallback(Q=>{ve(Q),Ti(pt.WORKFLOW_PANEL_OPEN,Q)},[]),[Ke,at]=x.useState(!1);x.useEffect(()=>{if(!T){at(!1);return}let Q=!1;return(async()=>{try{const ue=await Bt(Rt("/api/workflows/definitions"));if(Q||!ue.ok)return;const Me=(await ue.json()).some(nt=>nt.states.some(ut=>{var Nt,_t;return((Nt=ut.action)==null?void 0:Nt.type)==="agent_task"&&((_t=ut.action)==null?void 0:_t.agentId)===T}));Q||at(Me)}catch{Q||at(!1)}})(),()=>{Q=!0}},[T]);const ft=mL(),wt=x.useCallback(Q=>U.setOverviewPanelOpen(Q),[]),[it,gt]=x.useState([]),[ht,Gt]=x.useState({}),[tn,Ae]=x.useState(()=>Yj()),[Le,Ye]=x.useState(()=>{try{return localStorage.getItem("tide:bottom-split-direction")==="vertical"?"vertical":"horizontal"}catch{return"horizontal"}}),[Ze,Ot]=x.useState(()=>{try{const Q=localStorage.getItem("tide:bottom-terminal-height");return Q?Math.max(120,Math.min(600,Number(Q))):250}catch{return 250}}),Ft=x.useRef(null),[Lt,Vt]=x.useState([1]),ln=x.useRef(null),bt=x.useRef(null),[rt,xt]=x.useState(null),[$t,En]=x.useState(null),nn=x.useMemo(()=>it.filter(Q=>Q.areaId===$t),[it,$t]),Un=x.useMemo(()=>new Set(nn.map(Q=>Q.buildingId)),[nn]),Os=x.useRef(new Map);x.useEffect(()=>{try{const Q=localStorage.getItem("tide:bottom-panels-v2");if(Q){const ue=JSON.parse(Q);Os.current=new Map(ue.map(([ce,Me])=>[ce,Me.map(nt=>({id:nt.id??Xf(),type:nt.type,buildingId:nt.buildingId}))]))}else{const ue=localStorage.getItem("tide:bottom-terminals");if(ue){const ce=JSON.parse(ue);for(const[Me,nt]of ce)Os.current.set(Me,[{id:Xf(),type:"terminal",buildingId:nt}])}}}catch{}},[]);const ps=x.useCallback(Q=>{if(!T)return;const ue=U.getAreaForAgent(T);if(ue)try{Q.length>0?Os.current.set(ue.id,Q.map(Me=>({id:Me.id,type:Me.type,buildingId:Me.buildingId}))):Os.current.delete(ue.id);const ce=Array.from(Os.current.entries());localStorage.setItem("tide:bottom-panels-v2",JSON.stringify(ce))}catch{}},[T]),ks=x.useCallback(()=>{if(!T)return null;const Q=U.getAreaForAgent(T);return(Q==null?void 0:Q.id)??null},[T]),Qn=x.useCallback((Q,ue)=>{const ce=ks();Gt({}),gt(Me=>{for(const _t of Me)_t.areaId===ce&&_t.type==="pm2-logs"&&U.stopLogStreaming(_t.buildingId);const nt=Me.filter(_t=>_t.areaId!==ce),ut={id:Xf(),type:ue,buildingId:Q,areaId:ce??void 0},Nt=[...nt,ut];return ps([ut]),Nt})},[ps,ks]),Ss=x.useCallback((Q,ue,ce)=>{const Me=ks();Ye(ce);try{localStorage.setItem("tide:bottom-split-direction",ce)}catch{}gt(nt=>{const ut=nt.filter(sn=>sn.areaId===Me);if(ut.length>=4||ut.some(sn=>sn.buildingId===Q))return nt;const Nt={id:Xf(),type:ue,buildingId:Q,areaId:Me??void 0},_t=[...nt,Nt];return ps(ut.concat(Nt)),_t})},[ps,ks]),Fn=x.useCallback(Q=>{Gt(ue=>{if(!(Q in ue))return ue;const ce={...ue};return delete ce[Q],ce}),gt(ue=>{const ce=ue.find(ut=>ut.id===Q);(ce==null?void 0:ce.type)==="pm2-logs"&&U.stopLogStreaming(ce.buildingId);const Me=ue.filter(ut=>ut.id!==Q),nt=ce==null?void 0:ce.areaId;return nt&&ps(Me.filter(ut=>ut.areaId===nt)),Me})},[ps]);x.useCallback(()=>{Gt({}),gt(Q=>{for(const ue of Q)ue.type==="pm2-logs"&&U.stopLogStreaming(ue.buildingId);return ps([]),[]})},[ps]),x.useEffect(()=>{if(!T){En(null);return}const Q=U.getAreaForAgent(T);if(!Q){En(null);return}En(Q.id),gt(ue=>{if(ue.filter(ut=>ut.areaId===Q.id).length>0)return ue;const Me=Os.current.get(Q.id);if(!Me||Me.length===0)return ue;const nt=Me.map(ut=>({id:ut.id,type:ut.type,buildingId:ut.buildingId,areaId:Q.id}));return[...ue,...nt]})},[T]),x.useEffect(()=>{const Q=ue=>{const ce=ue.detail;ce!=null&&ce.buildingId&&Qn(ce.buildingId,"terminal")};return window.addEventListener("tide:open-bottom-terminal",Q),()=>window.removeEventListener("tide:open-bottom-terminal",Q)},[Qn]),x.useEffect(()=>{const Q=ue=>{const ce=ue.detail;ce!=null&&ce.buildingId&&Qn(ce.buildingId,"pm2-logs")};return window.addEventListener("tide:open-bottom-pm2-logs",Q),()=>window.removeEventListener("tide:open-bottom-pm2-logs",Q)},[Qn]),x.useEffect(()=>{const Q=ue=>{const ce=ue.detail;ce!=null&&ce.buildingId&&Qn(ce.buildingId,"database")};return window.addEventListener("tide:open-bottom-database",Q),()=>window.removeEventListener("tide:open-bottom-database",Q)},[Qn]),x.useEffect(()=>{const Q=ue=>{const ce=ue.detail;ce!=null&&ce.buildingId&&(ce!=null&&ce.type)&&(ce!=null&&ce.direction)&&(nn.length===0?Qn(ce.buildingId,ce.type):Ss(ce.buildingId,ce.type,ce.direction))};return window.addEventListener("tide:split-bottom-panel",Q),()=>window.removeEventListener("tide:split-bottom-panel",Q)},[nn.length,Qn,Ss]),x.useEffect(()=>{Vt(Q=>Q.length===nn.length?Q:nn.length<=1?[1]:(nn.length>Q.length,Array(nn.length).fill(1)))},[nn.length]);const Ls=x.useCallback((Q,ue)=>{var sn;Q.preventDefault();const ce=Le==="horizontal";ln.current={index:ue,startPos:ce?Q.clientX:Q.clientY,startRatios:[...Lt]},document.body.style.cursor=ce?"col-resize":"row-resize",document.body.style.userSelect="none";const Me=(sn=bt.current)==null?void 0:sn.querySelectorAll("iframe");Me==null||Me.forEach(gn=>gn.style.pointerEvents="none");const nt=bt.current,ut=nt?ce?nt.offsetWidth:nt.offsetHeight:1,Nt=gn=>{const qn=ln.current;if(!qn||!nt)return;const Qo=(ce?gn.clientX:gn.clientY)-qn.startPos,Ki=qn.startRatios.reduce((bc,vd)=>bc+vd,0),gc=Qo/ut*Ki,Xo=[...qn.startRatios],Jo=.1*Ki;Xo[ue]=Math.max(Jo,qn.startRatios[ue]+gc),Xo[ue+1]=Math.max(Jo,qn.startRatios[ue+1]-gc),Vt(Xo)},_t=()=>{ln.current=null,document.body.style.cursor="",document.body.style.userSelect="",Me==null||Me.forEach(gn=>gn.style.pointerEvents=""),document.removeEventListener("mousemove",Nt),document.removeEventListener("mouseup",_t)};document.addEventListener("mousemove",Nt),document.addEventListener("mouseup",_t)},[Le,Lt]),Is=x.useRef(new Set);x.useEffect(()=>{const Q=new Set(it.filter(ue=>ue.type==="pm2-logs").map(ue=>ue.buildingId));for(const ue of Q)Is.current.has(ue)||U.startLogStreaming(ue,200);Is.current=Q},[it]);const wn=x.useRef(new Set);x.useEffect(()=>{var ce;const Q=it.filter(Me=>Me.type==="terminal");for(const Me of Q){const nt=I.get(Me.buildingId);!!((ce=nt==null?void 0:nt.terminalStatus)!=null&&ce.url)?wn.current.add(Me.buildingId):wn.current.has(Me.buildingId)&&(wn.current.delete(Me.buildingId),Fn(Me.id))}const ue=new Set(Q.map(Me=>Me.buildingId));for(const Me of wn.current)ue.has(Me)||wn.current.delete(Me)},[it,I,Fn]);const Po=x.useCallback(Q=>{Q.preventDefault(),Ft.current={startY:Q.clientY,startH:Ze};let ue=Ze;const ce=nt=>{if(!Ft.current)return;const ut=Ft.current.startY-nt.clientY;ue=Math.max(120,Math.min(600,Ft.current.startH+ut)),Ot(ue)},Me=()=>{Ft.current=null,document.removeEventListener("mousemove",ce),document.removeEventListener("mouseup",Me);try{localStorage.setItem("tide:bottom-terminal-height",String(ue))}catch{}};document.addEventListener("mousemove",ce),document.addEventListener("mouseup",Me)},[Ze]),[Bo,Ps]=x.useState(!1),[Ua,Bi]=x.useState(null),Fi=x.useRef(null),Bs=x.useRef(null),[lc,Ma]=x.useState(!1),[Ts,hs]=x.useState(!1),[Mn,zi]=x.useState(!1),[je,Je]=x.useState(!1),Ct=x.useRef(0),ot=r&&S!==null,jn=x.useRef([]),Mt=x.useRef(-1),At=x.useRef(!1),kn=x.useRef(!1),ms=x.useRef(!1),Dn=x.useRef(null),[Fs,Qr]=x.useState(!1),[pa,mh]=x.useState(!1),ha=x.useCallback(()=>{const Q=jn.current,ue=Mt.current;Qr(ue>0),mh(ue>=0&&ue<Q.length-1)},[]),$i=x.useCallback(Q=>{const ue=jn.current;if(ue.length===0)return;let ce=Mt.current+Q;for(;ce>=0&&ce<ue.length;){const Me=ue[ce];if(s.has(Me)){At.current=!0,Mt.current=ce,ha(),U.selectAgent(Me);return}ce+=Q}},[s,ha]),gr=x.useCallback(()=>{$i(-1)},[$i]),Ui=x.useCallback(()=>{$i(1)},[$i]),cc=x.useCallback((Q,ue)=>{if(typeof window>"u")return;const ce=window.history.state,nt={...typeof ce=="object"&&ce!==null?ce:{},__guakeAgentNav:{agentId:Q}};ue==="replace"?window.history.replaceState(nt,"",window.location.href):window.history.pushState(nt,"",window.location.href)},[]),Fo=x.useCallback(()=>{Ne(Q=>{const ue=!Q;return Ti(pt.TERMINAL_FULLSCREEN,ue),ue})},[]),It=qj({selectedAgentId:T,hasSessionId:D,reconnectCount:c,historyRefreshTrigger:d,lastPrompts:i,outputScrollRef:me}),Hn=IH({agents:s,selectedAgentId:T,isOpen:ot,overviewPanelOpen:ft,loadingHistory:It.fetchingHistory,hasModalOpen:!!(ze||pe||He||h||m),outputRef:me});x.useEffect(()=>{const Q=F.current;if(!Q||!ot)return;const ue=Me=>{Me.button===3?(Me.preventDefault(),Me.stopPropagation(),gr()):Me.button===4&&(Me.preventDefault(),Me.stopPropagation(),Ui())},ce=Me=>{(Me.button===3||Me.button===4)&&Me.preventDefault()};return Q.addEventListener("mouseup",ue),Q.addEventListener("mousedown",ce),()=>{Q.removeEventListener("mouseup",ue),Q.removeEventListener("mousedown",ce)}},[ot,gr,Ui]);const uc=x.useCallback(Q=>{U.setLastSelectionViaDirectClick(!0),U.selectAgent(Q)},[]),Xr=typeof window<"u"&&window.innerWidth<=768&&ft&&ot,Jr=nR({gestureRef:me,agentListRef:Ee,enabled:Xr,onSelect:uc}),ts=UH({selectedAgentId:k}),zo=QO(),cd=x.useMemo(()=>y||!T?[]:Array.from(zo.values()).filter(Q=>Q.agentId===T&&Q.status==="pending"),[y,T,zo]),Ha=(S==null?void 0:S.class)==="boss"||(S==null?void 0:S.isBoss),zs=sL(!y&&Ha?T:null),Hi=x.useMemo(()=>Array.from(zs.values()).filter(Q=>Q.status==="working"),[zs]),br=x.useMemo(()=>Array.from(zs.values()).filter(Q=>Q.status==="completed"||Q.status==="failed").map(Q=>Q.agentId),[zs]),[ma,$o]=x.useState(!0),Uo=aL(y?null:T),ud=hL(y?null:T);x.useEffect(()=>{X&&!ke&&(J(!0),vs.setEnabled(!0))},[X,ke]),x.useEffect(()=>{ot||fe(!1)},[ot]),x.useEffect(()=>{if(!T||!Ha||y||br.length===0)return;const Q=window.setTimeout(()=>{br.forEach(ue=>{U.clearAgentTaskProgress(T,ue)})},300);return()=>window.clearTimeout(Q)},[T,Ha,y,br]),x.useEffect(()=>{const Q=S==null?void 0:S.status;if(Fi.current==="working"&&Q==="idle"){Bs.current&&clearTimeout(Bs.current);const ce=T?i.get(T):void 0;Bi(ce!=null&&ce.timestamp?Date.now()-ce.timestamp:null),Ps(!0),Bs.current=setTimeout(()=>{Ps(!1),Bi(null),Bs.current=null},4e3)}else Q==="working"&&(Bs.current&&(clearTimeout(Bs.current),Bs.current=null),Ps(!1),Bi(null));return Fi.current=Q||null,()=>{Bs.current&&clearTimeout(Bs.current)}},[S==null?void 0:S.status]);const Wi=x.useMemo(()=>{const{history:Q}=It,ue=new Map;for(const Me of Q)Me.type==="tool_result"&&Me.toolUseId&&ue.set(Me.toolUseId,Me.content);return(Me=>Me.map(nt=>{if(nt.type==="tool_use"&&nt.toolName==="Bash"&&nt.toolUseId){const ut=ue.get(nt.toolUseId);let Nt;try{Nt=(nt.toolInput||(nt.content?JSON.parse(nt.content):{})).command}catch{}return{...nt,_bashOutput:ut,_bashCommand:Nt}}return nt}))(Q)},[It.history,We]),qi=ET({outputs:ie,viewMode:We}),Wa=x.useMemo(()=>{const Q=[],ue=new Set,ce=new Set;let Me=null,nt=0;for(const ut of Wi){if(ut.type==="assistant"){const gn=ut.uuid?`uuid:${ut.uuid}:${Qf(ut.content)}`:`sig:${ut.timestamp}:${Qf(ut.content)}`;if(ue.has(gn))continue;ue.add(gn),Q.push(ut);continue}if(ut.type!=="user"){Q.push(ut);continue}const Nt=Mb(ut.content),_t=ut.uuid?`uuid:${ut.uuid}:${Nt}`:null;if(_t&&ce.has(_t))continue;const sn=ut.timestamp?new Date(ut.timestamp).getTime():0;Me===Nt&&Math.abs(sn-nt)<=YA||(Q.push(ut),_t&&ce.add(_t),Me=Nt,nt=sn)}return Q},[Wi]),Wn=x.useMemo(()=>{const Q=new Map,ue=new Set,ce=new Map;for(const Nt of Wa){const _t=Nt.timestamp?new Date(Nt.timestamp).getTime():0;if(Nt.type==="user"){const qn=Mb(Nt.content),Va=Q.get(qn)??0;_t>Va&&Q.set(qn,_t);continue}if(Nt.type!=="assistant")continue;Nt.uuid&&ue.add(Nt.uuid);const sn=Qf(Nt.content),gn=ce.get(sn)??0;_t>gn&&ce.set(sn,_t)}const Me=[];let nt=null,ut=0;for(const Nt of qi){if(!Nt.isUserPrompt){if(!Nt.isStreaming&&!Z5(Nt.text)){if(Nt.uuid&&ue.has(Nt.uuid))continue;const qn=Qf(Nt.text),Va=Nt.timestamp||0,Qo=ce.get(qn);if(Qo&&Math.abs(Va-Qo)<=Q5)continue}Me.push(Nt);continue}const _t=Mb(Nt.text),sn=Nt.timestamp||0,gn=Q.get(_t);gn&&sn>=gn&&sn-gn<=K5||nt===_t&&Math.abs(sn-ut)<=YA||(Me.push(Nt),nt=_t,ut=sn)}return Me},[qi,Wa]),xr=x.useMemo(()=>[...Wa,...Wn],[Wa,Wn]),Ln=FH({selectedAgentId:T,isOpen:ot,allItems:xr,viewMode:We,hasMoreHistory:It.hasMore,loadAllHistory:It.loadAllHistory,loadingMore:It.loadingMore}),Vi=Wa.length+Wn.length,dd=HH({totalMessages:Vi,isOpen:ot,hasModalOpen:!!(ze||pe||He||h),scrollContainerRef:me,selectedAgentId:T,inputRef:Te,textareaRef:Ve,useTextarea:ts.useTextarea});x.useEffect(()=>{if(!(!(pe!=null&&pe.isLive)||!pe.command)){for(const Q of Wn)if(Q._bashCommand===pe.command&&Q._bashOutput){Be({command:pe.command,output:Q._bashOutput,isLive:!1});return}}},[pe,Wn]);const Ho=x.useCallback((Q,ue)=>{st({url:Q,name:ue})},[]),Wo=x.useCallback((Q,ue)=>{const ce=sh(Q,S==null?void 0:S.cwd),Me=ce.line?{...ue||{},targetLine:ce.line}:ue;U.setFileViewerPath(ce.path,Me,S==null?void 0:S.cwd)},[S==null?void 0:S.cwd]),Zr=x.useCallback((Q,ue)=>{Be({command:Q,output:ue,isLive:ue==="Running..."})},[]),qo=x.useCallback(Q=>{et(Q)},[]),fd=x.useCallback(()=>{fe(Q=>!Q)},[]),[gh,Vo]=x.useState(!0),[pd,ei]=x.useState(0),[dc,fc]=x.useState(!1),Yi=x.useRef(!1),pc=x.useRef(!1),Yo=x.useRef(!1),hd=x.useCallback(()=>{Yo.current||(Yi.current=!0,Vo(!1))},[]),bh=x.useCallback(()=>hs(!1),[]),xh=x.useCallback(()=>{Yi.current=!1,Vo(!0)},[]),yh=x.useCallback(()=>{typeof window>"u"||window.innerWidth>768||(fc(!0),ei(X5),document.activeElement instanceof HTMLElement&&document.activeElement.blur(),setTimeout(()=>{U.setMobileView("3d"),fc(!1),ei(0)},J5))},[]),vh=x.useCallback(Q=>{dc||ei(Q)},[dc]);x.useEffect(()=>{Vo(!0),ei(0),fc(!1),Yi.current=!1,pc.current=!0,Yo.current=!0;const Q=setTimeout(()=>{Yo.current=!1},3e3);return()=>clearTimeout(Q)},[T]),x.useEffect(()=>{if(!T){jn.current=[],Mt.current=-1,ha(),ms.current=!1,Dn.current=null;return}const Q=jn.current;if(At.current){At.current=!1,ha();return}const ue=Mt.current;if(ue>=0&&Q[ue]===T){ha();return}const ce=ue<Q.length-1?Q.slice(0,ue+1):Q.slice();ce.push(T),ce.length>100&&ce.shift(),jn.current=ce,Mt.current=ce.length-1,ha()},[T,ha]),x.useEffect(()=>{if(!(!ot||!T)){if(!ms.current){cc(T,"replace"),ms.current=!0,Dn.current=T;return}if(kn.current){kn.current=!1,Dn.current=T;return}Dn.current!==T&&(cc(T,"push"),Dn.current=T)}},[ot,T,cc]),x.useEffect(()=>{if(!ot)return;const Q=ue=>{var ut,Nt;const ce=(Nt=(ut=ue.state)==null?void 0:ut.__guakeAgentNav)==null?void 0:Nt.agentId;if(!ce||typeof ce!="string"||!s.has(ce)||ce===k)return;kn.current=!0,At.current=!0;const Me=jn.current,nt=Me.lastIndexOf(ce);nt>=0?Mt.current=nt:(Me.push(ce),Mt.current=Me.length-1),ha(),U.selectAgent(ce)};return window.addEventListener("popstate",Q),()=>window.removeEventListener("popstate",Q)},[ot,s,k,ha]),x.useEffect(()=>{if(!pc.current||!T||Mn||It.fetchingHistory)return;let Q=0,ue=0;return Q=requestAnimationFrame(()=>{ue=requestAnimationFrame(()=>{me.current&&(me.current.scrollTop=me.current.scrollHeight),pc.current=!1})}),()=>{cancelAnimationFrame(Q),cancelAnimationFrame(ue)}},[T,Mn,It.fetchingHistory,It.historyLoadVersion]);const Go=x.useRef(It.handleScroll);Go.current=It.handleScroll;const wh=x.useCallback(()=>{if(!me.current||K.keyboardScrollLockRef.current)return;const{scrollTop:Q,scrollHeight:ue,clientHeight:ce}=me.current,Me=ue-Q-ce<150;Yo.current||(Yi.current=!Me,Me&&Vo(!0)),Go.current(K.keyboardScrollLockRef)},[me,K.keyboardScrollLockRef]),kh=Z.length>0&&((Ko=(xd=Z[Z.length-1])==null?void 0:xd.text)==null?void 0:Ko.length)||0;x.useEffect(()=>{K.keyboardScrollLockRef.current||Yi.current||requestAnimationFrame(()=>{me.current&&(me.current.scrollTop=me.current.scrollHeight)})},[Z.length,kh,K.keyboardScrollLockRef,me]);const md=x.useRef(null);x.useLayoutEffect(()=>{const Q=md.current;Q!==null&&Q!==k?(Ma(!1),k&&It.hasCachedHistory(k)||zi(!0),U.getState().currentSnapshot&&U.setCurrentSnapshot(null)):k||Ma(!1),md.current=k},[k]),x.useEffect(()=>{if(!Mn||It.fetchingHistory)return;const Q=requestAnimationFrame(()=>{me.current&&(me.current.scrollTop=me.current.scrollHeight),zi(!1)});return()=>cancelAnimationFrame(Q)},[Mn,It.fetchingHistory,It.historyLoadVersion]);const qa=x.useRef(!1);x.useEffect(()=>{ot&&k&&U.clearUnseenForAgent(k)},[ot,k]),x.useEffect(()=>{qa.current=!0,hs(!0)},[T,c]),x.useEffect(()=>{It.fetchingHistory&&(qa.current=!0,hs(!0))},[It.fetchingHistory]),x.useEffect(()=>{if(!Ts||!ot||It.fetchingHistory)return;const Q=me.current;if(!Q)return;let ue=null;const ce=performance.now();let Me=0,nt=-1;const ut=()=>{const{scrollTop:_t,scrollHeight:sn,clientHeight:gn}=Q;return sn-_t-gn<=2},Nt=()=>{const _t=performance.now(),sn=Q.scrollHeight,gn=Math.abs(sn-nt)<=1,qn=ut();if(gn&&qn?Me+=1:Me=0,nt=sn,Me>=3){hs(!1),ue=null;return}if(_t-ce>8e3){hs(!1),ue=null;return}ue=requestAnimationFrame(Nt)};return ue=requestAnimationFrame(Nt),()=>{ue!==null&&cancelAnimationFrame(ue)}},[Ts,ot,It.fetchingHistory,It.historyLoadVersion]);const gd=x.useRef(!1);x.useEffect(()=>{gd.current&&!Ts&&qa.current&&(qa.current=!1,Ma(!0)),gd.current=Ts},[Ts]),x.useEffect(()=>{if(!ot||!qa.current||Ts||It.fetchingHistory)return;const Q=requestAnimationFrame(()=>{qa.current&&(qa.current=!1,Ma(!0))});return()=>cancelAnimationFrame(Q)},[It.historyLoadVersion,ot,Ts,It.fetchingHistory]),x.useEffect(()=>{const Q=ue=>{if(ue.key==="`"&&!ue.ctrlKey&&!ue.altKey&&S){const ce=ue.target;ce.tagName!=="INPUT"&&ce.tagName!=="TEXTAREA"&&(ue.preventDefault(),U.toggleTerminal())}};return document.addEventListener("keydown",Q),()=>document.removeEventListener("keydown",Q)},[S]),x.useEffect(()=>{if(!ot)return;const Q=ue=>{ue.altKey&&(ue.key!=="ArrowLeft"&&ue.key!=="ArrowRight"||(ue.key==="ArrowLeft"&&Fs?(ue.preventDefault(),gr()):ue.key==="ArrowRight"&&pa&&(ue.preventDefault(),Ui())))};return document.addEventListener("keydown",Q),()=>document.removeEventListener("keydown",Q)},[ot,Fs,pa,gr,Ui]),x.useEffect(()=>{const Q=ue=>{ue.key==="Escape"&&(h?(ue.stopImmediatePropagation(),U.clearFileViewerPath()):m?(ue.stopImmediatePropagation(),U.closeContextModal()):He?(ue.stopImmediatePropagation(),et(null)):pe?(ue.stopImmediatePropagation(),Be(null)):ze?(ue.stopImmediatePropagation(),st(null)):Ln.searchMode&&(ue.stopImmediatePropagation(),Ln.closeSearch()))};return document.addEventListener("keydown",Q,!0),()=>document.removeEventListener("keydown",Q,!0)},[ze,pe,He,Ln,h,m]);const bd=x.useRef(ot),Gi=x.useRef(!1);x.useEffect(()=>{bd.current=ot},[ot]),x.useEffect(()=>{if(window.innerWidth<=768)return;const ue=nt=>{var sn;if(!(nt instanceof Element))return!1;const ut=(sn=F.current)==null?void 0:sn.contains(nt),Nt=nt.closest(".agent-bar"),_t=!!nt.closest(".modal-overlay, .modal, .image-modal-overlay, .image-modal, .bash-modal-overlay, .bash-modal, .agent-info-modal-overlay, .agent-info-modal, .agent-response-modal, .pasted-text-modal-overlay, .pasted-text-modal, .file-viewer-overlay, .file-viewer-modal, .context-view-modal, .guake-context-confirm-overlay, .guake-context-confirm-modal, .pm2-logs-modal-overlay, .pm2-logs-modal, .database-panel-modal, .context-menu, .guake-git-diff-modal-overlay, .guake-git-delete-confirm");return!!ut||!!Nt||_t},ce=nt=>{if(!bd.current){Gi.current=!1;return}if(JD("terminal")){Gi.current=!1;return}Gi.current=!ue(nt.target)},Me=nt=>{Gi.current&&(ue(nt.target)||U.setTerminalOpen(!1),Gi.current=!1)};return document.addEventListener("mousedown",ce,!0),document.addEventListener("mouseup",Me,!0),()=>{document.removeEventListener("mousedown",ce,!0),document.removeEventListener("mouseup",Me,!0)}},[]),x.useEffect(()=>{const Q=()=>{document.hidden&&K.cleanup()};return document.addEventListener("visibilitychange",Q),()=>document.removeEventListener("visibilitychange",Q)},[K]),x.useEffect(()=>()=>K.cleanup(),[T,K]);const hc=typeof window<"u"&&window.innerWidth<=768;if(!S)return hc&&f==="terminal"&&a.size===0?o.jsx("div",{ref:F,className:`guake-terminal open ${ne?"fullscreen":""}`,style:{"--terminal-height":`${L}%`},children:o.jsx("div",{className:"guake-content",children:o.jsx("div",{className:"guake-output",style:{display:"flex",alignItems:"center",justifyContent:"center",color:"#6272a4"},children:o.jsxs("div",{style:{textAlign:"center"},children:[o.jsx("div",{style:{fontSize:"48px",marginBottom:"16px"},children:"👆"}),o.jsx("div",{style:{fontSize:"16px"},children:n("terminal:empty.tapAgent")}),o.jsx("div",{style:{fontSize:"14px",marginTop:"8px",opacity:.7},children:n("terminal:empty.switchTo3D")})]})})})}):hc&&f==="terminal"&&a.size>0?o.jsx("div",{ref:F,className:`guake-terminal open ${ne?"fullscreen":""}`,style:{"--terminal-height":`${L}%`},children:o.jsx("div",{className:"guake-content",children:o.jsx("div",{className:"guake-output",style:{display:"flex",alignItems:"center",justifyContent:"center",color:"#6272a4"},children:o.jsxs("div",{className:"guake-empty loading",children:[n("terminal:empty.loadingTerminal"),o.jsxs("span",{className:"loading-dots",children:[o.jsx("span",{}),o.jsx("span",{}),o.jsx("span",{})]})]})})})}):null;if(!T)return null;const Sh=Q=>{Q.preventDefault(),Q.stopPropagation(),Ct.current++,Q.dataTransfer.types.includes("Files")&&Je(!0)},Ch=Q=>{Q.preventDefault(),Q.stopPropagation()},Ah=Q=>{Q.preventDefault(),Q.stopPropagation(),Ct.current--,Ct.current===0&&Je(!1)},jh=async Q=>{Q.preventDefault(),Q.stopPropagation(),Ct.current=0,Je(!1);const ue=Q.dataTransfer.files;if(ue.length)for(const ce of ue){const Me=await ts.uploadFile(ce);Me&&ts.setAttachedFiles(nt=>[...nt,Me])}};return o.jsxs("div",{ref:F,className:`guake-terminal ${ot?"open":"collapsed"} ${ne&&ot?"fullscreen":""} ${X&&ot?"with-debug-panel":""} ${he&&ot?"with-git-panel":""} ${xe&&ot?"with-buildings-panel":""} ${ge&&ot?"with-workflow-panel":""} ${ft&&ot?"with-overview-panel":""} ${je?"drag-over":""} ${pd>0?"mobile-swipe-close-active":""} ${dc?"mobile-swipe-close-closing":""}`,style:{"--terminal-height":`${L}%`,"--mobile-swipe-close-offset":`${pd}px`,"--guake-side-panel-width":`${se}px`,...V>0?{"--guake-mobile-overview-height":`${V}px`}:{}},onDragEnter:Sh,onDragOver:Ch,onDragLeave:Ah,onDrop:jh,children:[o.jsxs("div",{className:"guake-drop-overlay",children:[o.jsx("div",{className:"drop-border"}),o.jsx("span",{className:"drop-icon",children:"📎"}),o.jsx("span",{className:"drop-label",children:n("terminal:input.dropToAttach")})]}),!y&&X&&ot&&T&&o.jsx(l5,{agentId:T,onClose:()=>ae(!1)}),!y&&he&&ot&&T&&o.jsx(x5,{agentId:T,agents:s,onClose:()=>$e(!1),branchInfoMap:z,fetchRemote:$,fetchingDirs:W}),!y&&xe&&ot&&T&&o.jsx(R5,{agentId:T,onClose:()=>te(!1)}),!y&&ge&&ot&&T&&o.jsx(I5,{agentId:T,onClose:()=>Fe(!1)}),!y&&(X||he||xe||ge)&&ot&&o.jsx("div",{className:"guake-side-panel-resize right",onMouseDown:Q=>Ce(Q,"right")}),!y&&ft&&ot&&T&&o.jsx(E5,{activeAgentId:T,onClose:()=>wt(!1),onSelectAgent:Q=>{U.setLastSelectionViaDirectClick(!0),U.selectAgent(Q)},agentListRef:Ee,twoFingerState:Jr}),!y&&ft&&ot&&T&&o.jsx("div",{className:"guake-side-panel-resize left",onMouseDown:Q=>Ce(Q,"left")}),!y&&ft&&ot&&T&&o.jsx("div",{className:"aop-resize-handle",onMouseDown:G,onTouchStart:B}),o.jsxs("div",{className:"guake-content",children:[o.jsx(j6,{selectedAgent:S,selectedAgentId:T,sortedAgents:Hn.sortedAgents,swipeOffset:Hn.swipeOffset,viewMode:We,setViewMode:ee,searchMode:Ln.searchMode,toggleSearch:Ln.toggleSearch,closeSearch:Ln.closeSearch,debugPanelOpen:X,setDebugPanelOpen:ae,debuggerEnabled:ke,setDebuggerEnabled:J,gitPanelOpen:he,setGitPanelOpen:$e,buildingsPanelOpen:xe,setBuildingsPanelOpen:te,workflowPanelOpen:ge,setWorkflowPanelOpen:Fe,hasWorkflow:Ke,overviewPanelOpen:ft,setOverviewPanelOpen:wt,agentInfoOpen:ct,onToggleAgentInfo:fd,isFullscreen:ne,onToggleFullscreen:Fo,onNavigateBack:gr,onNavigateForward:Ui,canNavigateBack:Fs,canNavigateForward:pa,outputsLength:Wa.length+Wn.length,setContextConfirm:de,headerRef:Hn.headerRef,onSaveSnapshot:y?void 0:e,isSnapshotView:y}),Ln.searchMode&&o.jsx(N6,{searchInputRef:Ln.searchInputRef,searchQuery:Ln.searchQuery,setSearchQuery:Ln.setSearchQuery,closeSearch:Ln.closeSearch,matchCount:Ln.matchIndices.length,currentMatch:Ln.currentMatch,navigateNext:Ln.navigateNext,navigatePrev:Ln.navigatePrev,loadingFullHistory:Ln.loadingFullHistory}),o.jsxs("div",{className:`guake-swipe-container ${Hn.swipeAnimationClass}`,style:Hn.swipeOffset!==0?{transform:`translateX(${Hn.swipeOffset*40}%)`}:void 0,children:[Hn.sortedAgents.length>1&&Hn.swipeOffset!==0&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:`swipe-indicator left ${Hn.swipeOffset>.3?"visible":""}`,children:[o.jsx("span",{className:"indicator-icon",children:"←"}),o.jsx("span",{className:"indicator-name",children:(ti=Hn.nextAgent)==null?void 0:ti.name})]}),o.jsxs("div",{className:`swipe-indicator right ${Hn.swipeOffset<-.3?"visible":""}`,children:[o.jsx("span",{className:"indicator-name",children:(yd=Hn.prevAgent)==null?void 0:yd.name}),o.jsx("span",{className:"indicator-icon",children:"→"})]})]}),Hn.sortedAgents.length>1&&Hn.sortedAgents.length<=8&&Hn.swipeOffset!==0&&o.jsx("div",{className:`swipe-dots ${Math.abs(Hn.swipeOffset)>.1?"visible":""}`,children:Hn.sortedAgents.map((Q,ue)=>o.jsx("div",{className:`swipe-dot ${ue===Hn.currentAgentIndex?"active":""}`},Q.id))}),o.jsx("div",{className:"guake-output",ref:me,onScroll:wh,children:o.jsxs("div",{className:`guake-history-content ${lc?"fade-in":""}`,children:[Mn&&o.jsxs("div",{className:"guake-empty loading",children:[n("terminal:empty.loadingConversation"),o.jsxs("span",{className:"loading-dots",children:[o.jsx("span",{}),o.jsx("span",{}),o.jsx("span",{})]})]}),!Mn&&It.loadingHistory&&It.history.length===0&&Z.length===0&&o.jsxs("div",{className:"guake-empty loading",children:[n("terminal:empty.loadingConversation"),o.jsxs("span",{className:"loading-dots",children:[o.jsx("span",{}),o.jsx("span",{}),o.jsx("span",{})]})]}),!Mn&&!It.loadingHistory&&It.history.length===0&&ie.length===0&&S.status!=="working"&&o.jsx("div",{className:"guake-empty",children:n("terminal:empty.noOutput")}),!Mn&&It.hasMore&&!Ln.searchMode&&o.jsx("div",{className:"guake-load-more",children:It.loadingMore?o.jsx("span",{children:n("terminal:empty.loadingOlder")}):o.jsx("button",{onClick:It.loadMoreHistory,children:n("terminal:empty.loadMore",{count:It.totalCount-It.history.length})})}),!Mn&&o.jsx(o5,{historyMessages:Wa,liveOutputs:Wn,agentId:T,execTasks:Uo,subagents:ud,viewMode:We,searchHighlight:Ln.highlightQuery,searchActiveIndex:Ln.scrollToIndex,selectedMessageIndex:dd.selectedIndex,isMessageSelected:dd.isSelected,onImageClick:Ho,onFileClick:Wo,onBashClick:Zr,onViewMarkdown:qo,scrollContainerRef:me,onScrollTopReached:It.loadMoreHistory,isLoadingMore:It.loadingMore,hasMore:It.hasMore,shouldAutoScroll:gh,onUserScroll:hd,pinToBottom:Ts,onPinCancel:bh,isLoadingHistory:It.fetchingHistory},T),!Mn&&Ha&&Hi.length>0&&o.jsxs("div",{className:`agent-progress-container ${ma?"collapsed":"expanded"}`,children:[o.jsxs("div",{className:"agent-progress-container-header",onClick:()=>$o(Q=>!Q),role:"button",tabIndex:0,onKeyDown:Q=>{(Q.key==="Enter"||Q.key===" ")&&(Q.preventDefault(),$o(ue=>!ue))},children:[o.jsx("span",{className:"progress-crown",children:"👑"}),o.jsx("span",{children:n("terminal:empty.subordinateProgress")}),o.jsx("span",{className:"progress-count",children:n("terminal:empty.activeCount",{count:Hi.length})}),o.jsx("span",{className:"agent-progress-container-toggle",children:ma?"▶":"▼"})]}),!ma&&Hi.map(Q=>o.jsx(U5,{progress:Q,defaultExpanded:Q.status==="working",onAgentClick:ue=>{U.selectAgent(ue),U.setTerminalOpen(!0)},onDismiss:ue=>{T&&U.clearAgentTaskProgress(T,ue)},onFileClick:Wo,onBashClick:Zr},Q.agentId))]})]})})]}),o.jsx(L6,{selectedAgent:S,selectedAgentId:T,isOpen:ot,command:ts.command,setCommand:ts.setCommand,forceTextarea:ts.forceTextarea,setForceTextarea:ts.setForceTextarea,useTextarea:ts.useTextarea,attachedFiles:ts.attachedFiles,setAttachedFiles:ts.setAttachedFiles,removeAttachedFile:ts.removeAttachedFile,uploadFile:ts.uploadFile,pastedTexts:ts.pastedTexts,expandPastedTexts:ts.expandPastedTexts,incrementPastedCount:ts.incrementPastedCount,setPastedTexts:ts.setPastedTexts,resetPastedCount:ts.resetPastedCount,handleInputFocus:K.handleInputFocus,handleInputBlur:K.handleInputBlur,pendingPermissions:cd,showCompletion:Bo,completionElapsed:Ua,onImageClick:Ho,inputRef:Te,textareaRef:Ve,isSnapshotView:y,onClearHistory:It.clearHistory,onSendCommand:xh,canSwipeClose:hc&&f==="terminal"&&!Mn&&!Ln.searchMode&&!It.fetchingHistory,onSwipeCloseOffsetChange:vh,onSwipeClose:yh}),o.jsxs("div",{className:"guake-agent-status-bar",children:[!y&&(S==null?void 0:S.isDetached)&&o.jsx(os,{content:o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"tide-tooltip__title",children:["🔄 ",n("terminal:empty.reattachingSessionTitle")]}),o.jsxs("div",{className:"tide-tooltip__text",children:[n("terminal:empty.reattachingSessionDesc"),o.jsx("br",{}),o.jsx("br",{}),o.jsxs("strong",{children:[n("common:labels.status"),":"]})," ",n("terminal:empty.reattachingSessionStatus")]})]}),position:"top",className:"tide-tooltip--detached",children:o.jsxs("span",{className:"guake-detached-badge",title:n("terminal:empty.reattachingBadge"),children:[o.jsx("span",{className:"guake-detached-spinner",children:"🔄"})," ",n("terminal:empty.reattaching")]})}),(S==null?void 0:S.cwd)&&o.jsxs("span",{className:"guake-agent-cwd",title:S.cwd,children:["📁 ",S.cwd.split("/").filter(Boolean).slice(-2).join("/")||S.cwd]}),O&&O.map(({areaId:Q,areaName:ue,dir:ce})=>{const Me=z.get(ce),nt=W.has(ce);return o.jsxs("span",{className:"guake-agent-area-dir",title:`${ue}: ${ce}${Me?` (${Me.branch}${Me.ahead?` ↑${Me.ahead}`:""}${Me.behind?` ↓${Me.behind}`:""})`:""}`,onClick:()=>U.openFileExplorerForAreaFolder(Q,ce),children:["📂 ",ce.split("/").filter(Boolean).pop()||ce,Me&&o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"guake-agent-area-branch",children:[" ⎇ ",Me.branch]}),Me.ahead>0&&o.jsxs("span",{className:"guake-branch-ahead",title:`${Me.ahead} ahead`,children:["↑",Me.ahead]}),Me.behind>0&&o.jsxs("span",{className:"guake-branch-behind",title:`${Me.behind} behind`,children:["↓",Me.behind]}),o.jsx("span",{className:`guake-area-fetch-btn ${nt?"fetching":""}`,title:"Git fetch",onClick:ut=>{ut.stopPropagation(),$(ce)},children:nt?"⏳":"⇣"})]})]},`${Q}:${ce}`)}),!y&&S&&(()=>{const Q=S.contextStats,ue=!!Q,ce=Q?Q.totalTokens:S.contextUsed||0,Me=Q?Q.contextWindow:S.contextLimit||2e5,nt=Q?Q.usedPercent:Math.round(ce/Me*100),ut=Math.max(0,Math.min(100,nt)),Nt=Math.max(0,100-ut),_t=ut>=80?"#ff4a4a":ut>=60?"#ff9e4a":ut>=40?"#ffd700":"#4aff9e",sn=(ce/1e3).toFixed(1),gn=(Me/1e3).toFixed(1);return o.jsxs("span",{className:"guake-agent-context",onClick:()=>U.setContextModalAgentId(T),title:n(ue?"terminal:context.clickToViewStats":"terminal:context.clickToFetchStats"),children:[o.jsx("span",{className:"context-icon",children:"📊"}),o.jsxs("span",{className:"context-label",children:[n("terminal:agentInfo.context"),":"]}),o.jsx("span",{className:"context-bar-mini",children:o.jsx("span",{className:"context-bar-mini-fill",style:{width:`${Math.min(100,ut)}%`,backgroundColor:_t}})}),o.jsxs("span",{className:"context-tokens",style:{color:_t},children:[sn,"k/",gn,"k"]}),o.jsxs("span",{className:"context-free",children:["(",n("terminal:context.percentFree",{percent:Nt}),")"]}),!ue&&o.jsx("span",{className:"context-warning",title:n("terminal:context.clickToFetchStats"),children:"⚠️"})]})})(),o.jsxs("span",{className:"guake-status-right",children:[_.length>0&&o.jsx("span",{className:"guake-status-terminals",children:_.map(Q=>{const ue=Un.has(Q.id);return o.jsx("button",{className:`guake-status-terminal-btn ${ue?"active":""} ${Q.hasUrl?"":"offline"}`,title:`${ue?"Hide":"Show"} terminal: ${Q.name}${Q.hasUrl?"":" (starting...)"}`,onClick:()=>{if(ue){const ce=it.find(Me=>Me.buildingId===Q.id);ce&&Fn(ce.id)}else Q.hasUrl||U.sendBuildingCommand(Q.id,"start"),Qn(Q.id,"terminal")},onContextMenu:ce=>{ce.preventDefault(),ce.stopPropagation(),Un.has(Q.id)||xt({position:{x:ce.clientX,y:ce.clientY},buildingId:Q.id,type:"terminal"})},children:"💻"},Q.id)})}),M.length>0&&o.jsx("span",{className:"guake-status-terminals",children:M.map(Q=>{const ue=Un.has(Q.id);return o.jsx("button",{className:`guake-status-terminal-btn ${ue?"active":""}`,title:`${ue?"Hide":"Show"} logs: ${Q.name}`,onClick:()=>{if(ue){const ce=it.find(Me=>Me.buildingId===Q.id);ce&&Fn(ce.id)}else Qn(Q.id,"pm2-logs")},onContextMenu:ce=>{ce.preventDefault(),ce.stopPropagation(),Un.has(Q.id)||xt({position:{x:ce.clientX,y:ce.clientY},buildingId:Q.id,type:"pm2-logs"})},children:"📜"},Q.id)})}),R.length>0&&o.jsx("span",{className:"guake-status-terminals",children:R.map(Q=>{const ue=Un.has(Q.id);return o.jsx("button",{className:`guake-status-terminal-btn ${ue?"active":""}`,title:`${ue?"Hide":"Show"} database: ${Q.name}`,onClick:()=>{if(ue){const ce=it.find(Me=>Me.buildingId===Q.id);ce&&Fn(ce.id)}else Qn(Q.id,"database")},onContextMenu:ce=>{ce.preventDefault(),ce.stopPropagation(),Un.has(Q.id)||xt({position:{x:ce.clientX,y:ce.clientY},buildingId:Q.id,type:"database"})},children:"🗄️"},Q.id)})}),o.jsx(W5,{})]})]}),(()=>{const Q=[];return rt&&(Q.push({id:"open",label:"Open",icon:"⬇",onClick:()=>Qn(rt.buildingId,rt.type)}),nn.length>0&&(Q.push({id:"split-right",label:"Split Right",icon:"↔",onClick:()=>Ss(rt.buildingId,rt.type,"horizontal")}),Q.push({id:"split-below",label:"Split Below",icon:"↕",onClick:()=>Ss(rt.buildingId,rt.type,"vertical")}))),o.jsx(pr,{children:o.jsx(Do,{isOpen:rt!==null,position:(rt==null?void 0:rt.position)||{x:0,y:0},worldPosition:{x:0,z:0},actions:Q,onClose:()=>xt(null)})})})(),nn.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"guake-bottom-terminal-resize",onMouseDown:Po}),o.jsx("div",{ref:bt,className:`guake-bottom-panels-container ${Le}`,style:{height:Ze},onWheel:Q=>Q.stopPropagation(),children:nn.map((Q,ue)=>{const ce=I.get(Q.buildingId);if(!ce)return null;const Me=Lt[ue]??1,nt=(()=>{var ut;if(Q.type==="terminal")return(ut=ce.terminalStatus)!=null&&ut.url?o.jsxs("div",{className:"guake-bottom-panel",style:{flex:Me},children:[o.jsxs("div",{className:"guake-bottom-terminal-header",children:[o.jsxs("span",{className:"guake-bottom-terminal-title",children:["💻 ",ce.name]}),o.jsx("button",{className:"guake-bottom-terminal-close",onClick:()=>Fn(Q.id),children:o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsx(jx,{terminalUrl:ce.terminalStatus.url,visible:!0})]},Q.id):o.jsxs("div",{className:"guake-bottom-panel",style:{flex:Me},children:[o.jsxs("div",{className:"guake-bottom-terminal-header",children:[o.jsxs("span",{className:"guake-bottom-terminal-title",children:["💻 ",ce.name," (starting...)"]}),o.jsx("button",{className:"guake-bottom-terminal-close",onClick:()=>Fn(Q.id),children:o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsx("div",{className:"guake-bottom-terminal-starting",children:o.jsx("span",{children:"Starting terminal..."})})]},Q.id);if(Q.type==="pm2-logs"){const Nt=ht[Q.id]||"";return o.jsxs("div",{className:"guake-bottom-panel",style:{flex:Me},children:[o.jsxs("div",{className:"guake-bottom-terminal-header",children:[o.jsxs("span",{className:"guake-bottom-terminal-title",children:["📜 ",ce.name]}),o.jsxs("div",{className:"guake-bottom-terminal-controls",children:[o.jsx("input",{type:"text",className:"guake-bottom-terminal-filter",value:Nt,onChange:_t=>{const sn=_t.target.value;Gt(gn=>{if(!sn.trim()){if(!(Q.id in gn))return gn;const qn={...gn};return delete qn[Q.id],qn}return{...gn,[Q.id]:sn}})},placeholder:"Filter logs","aria-label":`Filter logs for ${ce.name}`,spellCheck:!1}),o.jsx("select",{className:"guake-bottom-terminal-retention",value:tn===null?"unlimited":String(tn),onChange:_t=>{const sn=_t.target.value==="unlimited"?null:Number(_t.target.value);Ae(sn),EO(sn)},"aria-label":`Max log retention for ${ce.name}`,children:_O.map(_t=>o.jsx("option",{value:_t===null?"unlimited":String(_t),children:_t===null?"Unlimited":`${_t.toLocaleString()} lines`},_t===null?"unlimited":_t))}),o.jsx("button",{className:"guake-bottom-terminal-close",onClick:()=>U.clearStreamingLogs(Q.buildingId),title:"Clear logs",children:o.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:o.jsx("path",{d:"M3 6h18M8 6V4a2 2 0 012-2h4a2 2 0 012 2v2M19 6l-1 14a2 2 0 01-2 2H8a2 2 0 01-2-2L5 6"})})}),o.jsx("button",{className:"guake-bottom-terminal-close",onClick:()=>U.sendBuildingCommand(Q.buildingId,"restart"),title:"Restart",children:o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("path",{d:"M1 4v6h6"}),o.jsx("path",{d:"M3.51 15a9 9 0 105.64-11.36L3 10"})]})}),o.jsx("button",{className:"guake-bottom-terminal-close",onClick:()=>Fn(Q.id),children:o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),o.jsx(nW,{buildingId:Q.buildingId,filterText:Nt,maxRetention:tn})]},Q.id)}return o.jsxs("div",{className:"guake-bottom-panel",style:{flex:Me},children:[o.jsxs("div",{className:"guake-bottom-terminal-header",children:[o.jsxs("span",{className:"guake-bottom-terminal-title",children:["🗄️ ",ce.name]}),o.jsx("button",{className:"guake-bottom-terminal-close",onClick:()=>Fn(Q.id),children:o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsx(EH,{building:ce})]},Q.id)})();return ue>0?o.jsxs(Se.Fragment,{children:[o.jsx("div",{className:`guake-split-divider ${Le}`,onMouseDown:ut=>Ls(ut,ue-1)}),nt]},Q.id):nt})})]}),it.filter(Q=>Q.areaId!==$t&&Q.type==="terminal").map(Q=>{var ce;const ue=I.get(Q.buildingId);return(ce=ue==null?void 0:ue.terminalStatus)!=null&&ce.url?o.jsx(jx,{terminalUrl:ue.terminalStatus.url,visible:!1},Q.id):null})]}),ot&&!ne&&o.jsx("div",{className:"guake-resize-handle",onMouseDown:H,title:n("common:rightPanel.dragToResize")}),!(ot&&ne)&&o.jsxs("div",{className:"guake-handle",onClick:()=>{ot&&U.toggleTerminal()},onDoubleClick:()=>{ot||U.toggleTerminal()},style:{top:ot?`min(${L}%, calc(100vh - 72px))`:"0"},children:[o.jsx("span",{className:"guake-handle-icon",children:ot?"▲":"▼"}),o.jsx("span",{className:"guake-handle-text",children:S.name})]}),ze&&o.jsx(P6,{url:ze.url,name:ze.name,onClose:()=>st(null)}),pe&&o.jsx(B6,{state:pe,onClose:()=>Be(null)}),oe&&o.jsx(F6,{action:oe,selectedAgentId:T,subordinateCount:((mc=S==null?void 0:S.subordinateIds)==null?void 0:mc.length)||0,onClose:()=>de(null),onClearHistory:It.clearHistory}),o.jsx(z6,{}),o.jsx($6,{}),o.jsx(H6,{agent:S,isOpen:ct,onClose:()=>fe(!1)}),!y&&o.jsx(U6,{agent:S,content:He,onClose:()=>et(null)})]})});function aW(t){return t.trim().replace(/^v/i,"")}function GA(t){const n=aW(t).match(/^(\d+(?:\.\d+)*)(?:-([0-9A-Za-z.-]+))?/);if(!n)return null;const s=n[1].split(".").map(r=>Number.parseInt(r,10));if(s.some(Number.isNaN))return null;const a=n[2]?n[2].split("."):[];return{core:s,prerelease:a}}function rW(t,e){if(t.length===0&&e.length===0)return 0;if(t.length===0)return 1;if(e.length===0)return-1;const n=Math.max(t.length,e.length);for(let s=0;s<n;s+=1){const a=t[s],r=e[s];if(a===void 0)return-1;if(r===void 0)return 1;const i=/^\d+$/.test(a)?Number.parseInt(a,10):null,c=/^\d+$/.test(r)?Number.parseInt(r,10):null;if(i!==null&&c!==null){if(i>c)return 1;if(i<c)return-1;continue}if(i!==null)return-1;if(c!==null)return 1;const d=a.localeCompare(r);if(d!==0)return d>0?1:-1}return 0}function iW(t,e){const n=GA(t),s=GA(e);if(!n||!s)return null;const a=Math.max(n.core.length,s.core.length);for(let r=0;r<a;r+=1){const i=n.core[r]??0,c=s.core[r]??0;if(i>c)return 1;if(i<c)return-1}return rW(n.prerelease,s.prerelease)}function oW(t,e){const n=iW(t,e);return n===null?"unknown":n<0?"behind":n>0?"ahead":"equal"}async function lW(t,e={}){const{timeoutMs:n=5e3,fetchImpl:s=fetch}=e;try{const a=new AbortController,r=setTimeout(()=>a.abort(),n),i=Date.now(),c=await s(`https://registry.npmjs.org/${encodeURIComponent(t)}/latest?t=${i}`,{signal:a.signal,headers:{Accept:"application/json"}});if(clearTimeout(r),!c.ok)return null;const d=await c.json();return typeof d.version=="string"?d.version:null}catch{return null}}async function cW(t,e,n={}){const s=await lW(t,n);return s?{currentVersion:e,latestVersion:s,relation:oW(e,s)}:{currentVersion:e,latestVersion:null,relation:"unknown"}}const uW="tide-commander",Db="1.40.2";function dW(){const[t,e]=x.useState({currentVersion:Db,latestVersion:null,relation:"unknown",isChecking:!1}),n=x.useCallback(async()=>{e(a=>({...a,isChecking:!0}));const s=await cW(uW,Db);e({currentVersion:Db,latestVersion:s.latestVersion,relation:s.relation,isChecking:!1})},[]);return x.useEffect(()=>{n()},[n]),{...t,refresh:n}}const fW=x.memo(function({agent:e,currentIndex:n,agentIndex:s,isTouchInput:a,isTouchDragEnabled:r,isSelected:i,hasUnseenOutput:c,isDragging:d,isDragOver:f,customClasses:h,onDragStart:m,onDragEnd:b,onDragOver:y,onDragEnter:w,onDragLeave:C,onDrop:N,onAgentClick:k,onAgentDoubleClick:j,onTouchStart:S,onTouchMove:T,onTouchEnd:D,onTouchCancel:E,onHoverEnter:I,onHoverLeave:O,onItemRef:_}){const M=x.useMemo(()=>fr(e.class,h),[e.class,h]),R=!a||r,z=x.useCallback($=>{_(e.id,$)},[e.id,_]);return o.jsxs("div",{ref:z,className:`agent-bar-item ${i?"selected":""} ${e.status} ${e.isBoss?"is-boss":""} ${d?"dragging":""} ${f?"drag-over":""} ${r?"touch-drag-enabled":""}`,draggable:R,onDragStart:$=>m($,e),onDragEnd:b,onDragOver:$=>y($,s),onDragEnter:$=>w($,s),onDragLeave:C,onDrop:$=>N($,s),onTouchStart:$=>S($,e.id),onTouchMove:T,onTouchEnd:D,onTouchCancel:E,onClick:$=>k(e,$),onDoubleClick:()=>j(e),onMouseEnter:()=>I(e),onMouseLeave:O,title:a?`${e.name} (${n+1}) - Long press to reorder`:`${e.name} (${n+1}) - Drag to reorder within group`,children:[o.jsxs("div",{className:"agent-bar-avatar",children:[o.jsx("span",{className:"agent-bar-icon",children:M.icon}),o.jsx("span",{className:"agent-bar-status",style:{backgroundColor:Ex(e.status)}}),c&&o.jsx("span",{className:"agent-bar-notification-badge",title:"New output available - click to view"}),e.status==="idle"&&e.lastActivity>0&&o.jsx("span",{className:"agent-bar-idle-clock",style:{color:_x(e.lastActivity)},title:Mx(e.lastActivity),children:"⏱"})]}),o.jsxs("span",{className:"agent-bar-hotkey",title:`Ctrl+${n+1}`,children:["^",n+1]})]})}),pW=x.memo(function({onFocusAgent:e,onSpawnClick:n,onSpawnBossClick:s,onNewBuildingClick:a,onNewAreaClick:r}){const{t:i}=dt(["common"]),c=ed(),d=ur(),f=Ux(),h=WO(),m=Hx(),b=Vr(),y=dr(),w=c1(),[C]=Fj(),[N,k]=x.useState(!1);Dj("AgentBar");const j=x.useRef(null),S=x.useRef(null),T=x.useRef(null),D=x.useRef(new Map);x.useEffect(()=>{{k(!1);return}},[b.experimental2DView]),x.useEffect(()=>{const ve=S.current;if(!ve)return;const Fe=Ke=>{ve.scrollWidth<=ve.clientWidth||(Ke.preventDefault(),Math.abs(Ke.deltaX)>Math.abs(Ke.deltaY)?ve.scrollLeft+=Ke.deltaX:ve.scrollLeft+=Ke.deltaY)};return ve.addEventListener("wheel",Fe,{passive:!1}),()=>ve.removeEventListener("wheel",Fe)},[]);const[E,I]=x.useState(null),[O,_]=x.useState(new Map),[M,R]=x.useState(null),[z,$]=x.useState(null),W=x.useRef(0),[L,F]=x.useState(null),H=x.useRef(null),V=x.useRef(null),G=x.useRef(null),B=x.useRef(null),K=350,se=8,q=x.useMemo(()=>typeof window>"u"?!1:"ontouchstart"in window||window.matchMedia("(pointer: coarse)").matches,[]),be=x.useMemo(()=>Array.from(c.values()).filter(ve=>{if(U.isAgentInArchivedArea(ve.id))return!1;if(C){const Fe=U.getAreaForAgent(ve.id);if(!zx((Fe==null?void 0:Fe.id)??null))return!1}return!0}).sort((ve,Fe)=>(ve.createdAt||0)-(Fe.createdAt||0)),[c,d,C]),{orderedAgents:Ce,moveAgent:Z}=mO(be),ie=Ce,me=x.useMemo(()=>{const ve=new Map;for(const Fe of ie)ve.set(Fe.id,U.getAreaForAgent(Fe.id));return ve},[ie,d]),Ee=x.useMemo(()=>{const ve=new Map;for(const Ke of ie){const at=me.get(Ke.id)||null,ft=(at==null?void 0:at.id)||null;ve.has(ft)||ve.set(ft,{area:at,agents:[]}),ve.get(ft).agents.push(Ke)}const Fe=Array.from(ve.values());return Fe.sort((Ke,at)=>{var ft,wt;return!Ke.area&&at.area?1:Ke.area&&!at.area?-1:!Ke.area&&!at.area?0:(((ft=Ke.area)==null?void 0:ft.name)||"").localeCompare(((wt=at.area)==null?void 0:wt.name)||"")}),Fe},[ie,me]),Te=x.useRef(e);Te.current=e;const Ve=x.useRef(M);Ve.current=M;const We=x.useRef(ie);We.current=ie;const ee=x.useRef(me);ee.current=me;const ne=x.useRef(Z);ne.current=Z,x.useEffect(()=>{const ve=new Map(O);let Fe=!1;for(const Ke of ie){const at=O.get(Ke.id);Ke.currentTool?(!at||at.tool!==Ke.currentTool)&&(ve.set(Ke.id,{tool:Ke.currentTool,key:Date.now()}),Fe=!0):at&&setTimeout(()=>{_(ft=>{const wt=new Map(ft);return wt.delete(Ke.id),wt})},1500)}Fe&&_(ve)},[ie.map(ve=>ve.currentTool).join(",")]),x.useEffect(()=>{const ve=h;if(!ve)return;const Fe=D.current.get(ve),Ke=S.current;Fe&&Ke&&requestAnimationFrame(()=>{const at=Fe.getBoundingClientRect(),ft=Ke.getBoundingClientRect(),it=at.left-ft.left+Ke.scrollLeft+at.width/2,gt=Ke.clientWidth;Ke.scrollTo({left:it-gt/2,behavior:"smooth"})})},[h]);const Ne=x.useCallback((ve,Fe)=>{if(G.current===ve.id){G.current=null,Fe.preventDefault(),Fe.stopPropagation();return}U.setLastSelectionViaDirectClick(!0),Fe.shiftKey?U.addToSelection(ve.id):U.selectAgent(ve.id),U.setTerminalOpen(!0)},[]),ze=x.useCallback(ve=>{var Fe;(Fe=Te.current)==null||Fe.call(Te,ve.id),U.setTerminalOpen(!0)},[]),st=x.useCallback(()=>I(null),[]),pe=x.useCallback((ve,Fe)=>{Fe?D.current.set(ve,Fe):D.current.delete(ve)},[]),Be=x.useCallback((ve,Fe)=>{R(Fe),F(Fe.id),ve.dataTransfer.effectAllowed="move",ve.dataTransfer.setData("text/plain",Fe.id),requestAnimationFrame(()=>{ve.target.classList.add("dragging")})},[]),oe=x.useCallback(ve=>{R(null),$(null),F(null),W.current=0,ve.target.classList.remove("dragging")},[]),de=x.useCallback((ve,Fe)=>{ve.preventDefault();const Ke=Ve.current;if(Ke){const at=ee.current.get(Ke.id),ft=We.current[Fe],wt=ft?ee.current.get(ft.id):null,it=(at==null?void 0:at.id)??null,gt=(wt==null?void 0:wt.id)??null;ve.dataTransfer.dropEffect=it===gt?"move":"none"}else ve.dataTransfer.dropEffect="move"},[]),He=x.useCallback((ve,Fe)=>{ve.preventDefault(),W.current++;const Ke=Ve.current;if(Ke){const at=ee.current.get(Ke.id),ft=We.current[Fe],wt=ft?ee.current.get(ft.id):null,it=(at==null?void 0:at.id)??null,gt=(wt==null?void 0:wt.id)??null;$(it===gt?Fe:null)}else $(Fe)},[]),et=x.useCallback(ve=>{W.current--,W.current===0&&$(null)},[]),ct=x.useCallback((ve,Fe)=>{ve.preventDefault();const Ke=Ve.current;if(!Ke)return;const at=We.current,ft=ee.current,wt=at.findIndex(it=>it.id===Ke.id);if(wt!==-1&&wt!==Fe){const it=ft.get(Ke.id),gt=at[Fe],ht=gt?ft.get(gt.id):null,Gt=(it==null?void 0:it.id)??null,tn=(ht==null?void 0:ht.id)??null;Gt===tn&&ne.current(wt,Fe)}R(null),$(null),F(null),W.current=0},[]),fe=x.useCallback(()=>{H.current&&(clearTimeout(H.current),H.current=null)},[]),X=x.useCallback(()=>{B.current&&(clearTimeout(B.current),B.current=null)},[]),ae=x.useCallback((ve,Fe)=>{if(!q||ve.touches.length!==1)return;fe(),X(),F(null);const Ke=ve.touches[0];V.current={agentId:Fe,x:Ke.clientX,y:Ke.clientY},H.current=setTimeout(()=>{F(Fe),G.current=Fe,H.current=null},K)},[fe,X,q]),ke=x.useCallback(ve=>{if(!q||ve.touches.length!==1)return;const Fe=V.current;if(!Fe||!H.current)return;const Ke=ve.touches[0],at=Ke.clientX-Fe.x,ft=Ke.clientY-Fe.y;Math.sqrt(at*at+ft*ft)>se&&(fe(),V.current=null)},[fe,q]),J=x.useCallback(()=>{fe(),V.current=null,Ve.current||F(null),X(),B.current=setTimeout(()=>{G.current=null,B.current=null},450)},[fe,X]);x.useEffect(()=>()=>{fe(),X()},[fe,X]);const he=ve=>{const Fe=`common:status.${ve}`;return i(Fe,{defaultValue:i("common:status.unknown")})},{currentVersion:Oe,latestVersion:$e,relation:xe,isChecking:Pe}=dW(),te=Oe;let ge=0;return o.jsxs("div",{className:"agent-bar",ref:j,children:[o.jsxs("div",{className:"agent-bar-scroll",ref:S,children:[o.jsxs("div",{className:"agent-bar-version",title:$e?`Tide Commander v${te} (npm: v${$e})`:`Tide Commander v${te}`,children:[o.jsxs("span",{children:["v",te]}),xe==="behind"&&$e?o.jsxs("span",{className:"agent-bar-version-badge agent-bar-version-badge-behind",title:`Behind npm latest v${$e}`,children:["npm v",$e]}):xe==="ahead"&&$e?o.jsxs("span",{className:"agent-bar-version-badge agent-bar-version-badge-ahead",title:`Ahead of npm latest v${$e}`,children:["npm v",$e]}):null,xe==="behind"?o.jsx("a",{href:"https://github.com/deivid11/tide-commander/releases",target:"_blank",rel:"noopener noreferrer",className:"agent-bar-version-status agent-bar-version-status-behind",title:i("common:agentBar.behindNpmTooltip",{defaultValue:"Current version is behind npm latest"}),children:i("common:agentBar.behindNpm",{defaultValue:"(behind npm)"})}):xe==="ahead"?o.jsx("span",{className:"agent-bar-version-status agent-bar-version-status-ahead",title:i("common:agentBar.aheadNpmTooltip",{defaultValue:"Current version is newer than npm latest"}),children:i("common:agentBar.aheadNpm",{defaultValue:"(ahead of npm)"})}):xe==="equal"?o.jsx("a",{href:"https://github.com/deivid11/tide-commander/releases",target:"_blank",rel:"noopener noreferrer",className:"agent-bar-version-status",children:i("common:agentBar.updated")}):Pe?o.jsx("span",{className:"agent-bar-version-status",children:i("common:agentBar.checkingNpm",{defaultValue:"(checking npm)"})}):o.jsx("span",{className:"agent-bar-version-status",children:i("common:agentBar.unknownNpm",{defaultValue:"(npm unknown)"})}),N&&o.jsx(os,{content:"Refresh 3D Scene (HMR changes pending)",position:"bottom",children:o.jsx("button",{className:"agent-bar-hmr-refresh",onClick:Hj,children:"↻"})})]}),o.jsxs("div",{className:"agent-bar-list",ref:T,children:[o.jsx(os,{content:i("common:agentBar.spawnNewAgent"),position:"bottom",children:o.jsxs("button",{className:"agent-bar-spawn-btn",onClick:n,children:[o.jsx("span",{className:"agent-bar-spawn-icon",children:"+"}),o.jsx("span",{className:"agent-bar-spawn-label",children:i("common:agentBar.newAgent")})]})}),o.jsx(os,{content:i("common:agentBar.spawnBoss"),position:"bottom",children:o.jsxs("button",{className:"agent-bar-spawn-btn agent-bar-boss-btn",onClick:s,children:[o.jsx("span",{className:"agent-bar-spawn-icon",children:"👑"}),o.jsx("span",{className:"agent-bar-spawn-label",children:i("common:agentBar.newBoss")})]})}),o.jsx(os,{content:i("common:agentBar.addNewBuilding"),position:"bottom",children:o.jsxs("button",{className:"agent-bar-spawn-btn agent-bar-building-btn",onClick:a,children:[o.jsx("span",{className:"agent-bar-spawn-icon",children:"🏢"}),o.jsx("span",{className:"agent-bar-spawn-label",children:i("common:agentBar.newBuilding")})]})}),o.jsx(os,{content:i("common:agentBar.drawNewArea"),position:"bottom",children:o.jsxs("button",{className:"agent-bar-spawn-btn agent-bar-area-btn",onClick:r,children:[o.jsx("span",{className:"agent-bar-spawn-icon",children:"🔲"}),o.jsx("span",{className:"agent-bar-spawn-label",children:i("common:agentBar.newArea")})]})}),Ee.map(ve=>{var at,ft,wt,it,gt;const Fe=ve.agents,Ke=!ve.area;return o.jsxs("div",{className:`agent-bar-group ${Ke?"unassigned":""}`,style:{borderColor:((at=ve.area)==null?void 0:at.color)||void 0,background:ve.area?`${ve.area.color}15`:void 0},children:[o.jsx("div",{className:"agent-bar-area-label",children:o.jsx("span",{className:"agent-bar-area-name",style:{color:((ft=ve.area)==null?void 0:ft.color)||"#888"},children:((wt=ve.area)==null?void 0:wt.name)||i("common:agentBar.unassigned")})}),((it=ve.area)==null?void 0:it.directories)&&ve.area.directories.length>0&&o.jsx("div",{className:"agent-bar-folders",children:ve.area.directories.map((ht,Gt)=>o.jsxs("div",{className:"agent-bar-folder-item",onClick:tn=>{tn.stopPropagation(),U.openFileExplorer(ht)},children:[o.jsx("span",{className:"agent-bar-folder-icon",children:"📁"}),o.jsxs("div",{className:"agent-bar-folder-tooltip",children:[o.jsx("div",{className:"agent-bar-folder-tooltip-path",children:ht}),o.jsx("div",{className:"agent-bar-folder-tooltip-hint",children:i("common:agentBar.clickToOpen")})]})]},Gt))}),Fe.map(ht=>{const Gt=ge++,tn=ie.findIndex(Ae=>Ae.id===ht.id);return o.jsx(fW,{agent:ht,currentIndex:Gt,agentIndex:tn,isTouchInput:q,isTouchDragEnabled:L===ht.id,isSelected:f.has(ht.id),hasUnseenOutput:w.has(ht.id),isDragging:(M==null?void 0:M.id)===ht.id,isDragOver:z===tn,customClasses:y,onDragStart:Be,onDragEnd:oe,onDragOver:de,onDragEnter:He,onDragLeave:et,onDrop:ct,onAgentClick:Ne,onAgentDoubleClick:ze,onTouchStart:ae,onTouchMove:ke,onTouchEnd:J,onTouchCancel:J,onHoverEnter:I,onHoverLeave:st,onItemRef:pe},ht.id)})]},((gt=ve.area)==null?void 0:gt.id)||"unassigned")})]})]}),Array.from(O.entries()).map(([ve,Fe])=>{const Ke=D.current.get(ve);if(!Ke)return null;const at=Ke.getBoundingClientRect(),ft=fs[Fe.tool]||fs.default;return o.jsxs("div",{className:"agent-bar-tool-bubble",title:Fe.tool,style:{position:"fixed",left:at.left+at.width/2,bottom:window.innerHeight-at.top+8},children:[o.jsx("span",{className:"agent-bar-tool-icon",children:ft}),o.jsx("span",{className:"agent-bar-tool-name",children:Fe.tool})]},`tool-${ve}-${Fe.key}`)}),E&&(()=>{const ve=U.getAreaForAgent(E.id),Fe=m.get(E.id),Ke=fr(E.class,y),at=U.getAgentSupervisorHistory(E.id),ft=at.length>0?at[at.length-1]:void 0,wt=Date.now()-(E.createdAt||Date.now()),it=Math.floor(wt/6e4),gt=Math.floor(it/60),ht=gt>0?`${gt}h ${it%60}m`:`${it}m`,Gt=Ze=>Ze>=1e6?`${(Ze/1e6).toFixed(1)}M`:Ze>=1e3?`${(Ze/1e3).toFixed(1)}K`:Ze.toString(),tn=E.contextLimit>0?Math.round(E.contextUsed/E.contextLimit*100):0,Ae=Ze=>{switch(Ze){case"on_track":return"#4aff9e";case"completed":return"#4a9eff";case"stalled":return"#ff9e4a";case"blocked":return"#ff4a4a";case"idle":return"#888888";default:return"#888888"}},Le=D.current.get(E.id),Ye={};if(Le){const Ze=Le.getBoundingClientRect();Ye.position="fixed",Ye.left=Ze.left+Ze.width/2,Ye.bottom=window.innerHeight-Ze.top+12}return o.jsxs("div",{className:"agent-bar-tooltip",style:Ye,children:[o.jsxs("div",{className:"agent-bar-tooltip-header",children:[o.jsx("span",{className:"agent-bar-tooltip-icon",children:Ke.icon}),o.jsxs("span",{className:"agent-bar-tooltip-name",children:[o.jsx("img",{src:E.provider==="codex"?"/assets/codex.png":E.provider==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:E.provider,className:"agent-bar-provider-icon",title:E.provider==="codex"?"Codex Agent":E.provider==="opencode"?"OpenCode Agent":"Claude Agent"}),E.name]}),o.jsx("span",{className:"agent-bar-tooltip-status",style:{color:Ex(E.status)},children:he(E.status)})]}),o.jsxs("div",{className:"agent-bar-tooltip-info",children:[o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[i("common:labels.class"),":"]}),o.jsxs("span",{className:"agent-bar-tooltip-value",children:[E.class," — ",Ke.description]})]}),ve&&o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[i("common:agentPopup.area"),":"]}),o.jsx("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-area",style:{color:ve.color},children:ve.name})]}),o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[i("common:agentPopup.directory"),":"]}),o.jsx("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-path",children:E.cwd})]}),o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[i("common:labels.uptime"),":"]}),o.jsx("span",{className:"agent-bar-tooltip-value",children:ht})]}),o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[i("common:labels.tokens"),":"]}),o.jsxs("span",{className:"agent-bar-tooltip-value",children:[Gt(E.tokensUsed)," ",i("common:agentPopup.used")]})]}),o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[i("common:labels.context"),":"]}),o.jsxs("span",{className:"agent-bar-tooltip-value",style:{color:tn>80?"#ff4a4a":tn>60?"#ff9e4a":void 0},children:[Gt(E.contextUsed)," / ",Gt(E.contextLimit)," (",tn,"%)"]})]}),E.currentTool&&o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[i("common:agentPopup.tool"),":"]}),o.jsxs("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-tool",children:[fs[E.currentTool]||fs.default," ",E.currentTool]})]}),E.taskLabel&&o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsx("span",{className:"agent-bar-tooltip-label",children:"📋 Task:"}),o.jsx("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-tool",children:E.taskLabel})]}),E.currentTask&&o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[i("common:labels.task"),":"]}),o.jsxs("span",{className:"agent-bar-tooltip-value",children:[E.currentTask.substring(0,150),E.currentTask.length>150?"...":""]})]}),E.lastAssignedTask&&!E.currentTask&&o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[i("common:agentPopup.assignedTask"),":"]}),o.jsxs("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-query",children:[E.lastAssignedTask.substring(0,200),E.lastAssignedTask.length>200?"...":""]})]}),Fe&&o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[i("common:agentPopup.lastQuery"),":"]}),o.jsxs("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-query",children:[Fe.text.substring(0,300),Fe.text.length>300?"...":""]})]}),ft&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"agent-bar-tooltip-divider"}),o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[i("common:agentPopup.supervisor"),":"]}),o.jsx("span",{className:"agent-bar-tooltip-value",style:{color:Ae(ft.analysis.progress)},children:ft.analysis.progress.replace("_"," ")})]}),o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[i("common:labels.status"),":"]}),o.jsx("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-supervisor",children:ft.analysis.statusDescription})]}),ft.analysis.recentWorkSummary&&o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[i("common:labels.summary"),":"]}),o.jsxs("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-supervisor",children:[ft.analysis.recentWorkSummary.substring(0,300),ft.analysis.recentWorkSummary.length>300?"...":""]})]}),ft.analysis.concerns&&ft.analysis.concerns.length>0&&o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[i("common:labels.concerns"),":"]}),o.jsx("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-concerns",children:ft.analysis.concerns.join("; ")})]})]})]})]})})()]})});function hW({activeTool:t,onExit:e}){const{t:n}=dt(["notifications","terminal"]);if(!t||t==="select")return null;const s=n(t==="rectangle"?"notifications:drawing.rectangleTool":"notifications:drawing.circleTool"),a=t==="rectangle"?"▭":"○";return o.jsxs("div",{className:"drawing-mode-indicator",children:[o.jsxs("div",{className:"drawing-mode-content",children:[o.jsx("span",{className:"drawing-mode-icon",children:a}),o.jsxs("div",{className:"drawing-mode-text",children:[o.jsxs("span",{className:"drawing-mode-title",children:[n("terminal:drawingMode.drawingArea"),": ",s]}),o.jsxs("span",{className:"drawing-mode-hint",children:[n("terminal:drawingMode.clickAndDrag")," • ",n("terminal:drawingMode.pressEscape")]})]})]}),o.jsx("button",{className:"drawing-mode-exit",onClick:e,title:n("terminal:drawingMode.exitDrawingMode"),children:"✕"})]})}const mW={idle:"common:status.idle",working:"common:status.working",waiting:"common:status.waiting",error:"common:status.error",offline:"common:status.offline"},Rb=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString(),gW=t=>{switch(t){case"on_track":return"#4aff9e";case"completed":return"#4a9eff";case"stalled":return"#ff9e4a";case"blocked":return"#ff4a4a";case"idle":return"#888888";default:return"#888888"}},bW=x.memo(function({agent:e,screenPos:n,onClose:s}){const{t:a}=dt(["common"]),r=dr(),i=U.getAreaForAgent(e.id),c=U.getState().lastPrompts.get(e.id),d=fr(e.class,r),f=U.getAgentSupervisorHistory(e.id),h=f.length>0?f[f.length-1]:void 0,m=Date.now()-(e.createdAt||Date.now()),b=Math.floor(m/6e4),y=Math.floor(b/60),w=y>0?`${y}h ${b%60}m`:`${b}m`,C=e.contextLimit>0?Math.round(e.contextUsed/e.contextLimit*100):0,N=x.useMemo(()=>{let S=n.x-150,T=n.y-320-10;return typeof window<"u"&&(S<10?S=10:S+300>window.innerWidth-10&&(S=window.innerWidth-300-10),T<10&&(T=n.y+10)),{position:"fixed",left:S,top:T,zIndex:1e4,maxWidth:300,maxHeight:320,fontSize:"0.85em"}},[n.x,n.y]);return o.jsxs("div",{className:"agent-hover-popup",style:N,onMouseLeave:s,children:[o.jsxs("div",{className:"agent-bar-tooltip-header",children:[o.jsx("span",{className:"agent-bar-tooltip-icon",children:d.icon}),o.jsx("span",{className:"agent-bar-tooltip-name",children:e.name}),o.jsx("span",{className:"agent-bar-tooltip-status",style:{color:Ex(e.status)},children:a(mW[e.status]||"common:status.unknown")})]}),o.jsxs("div",{className:"agent-bar-tooltip-info",children:[o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[a("common:labels.class"),":"]}),o.jsxs("span",{className:"agent-bar-tooltip-value",children:[e.class," — ",d.description]})]}),i&&o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[a("common:agentPopup.area"),":"]}),o.jsx("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-area",style:{color:i.color},children:i.name})]}),o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[a("common:agentPopup.directory"),":"]}),o.jsx("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-path",children:e.cwd})]}),o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[a("common:labels.uptime"),":"]}),o.jsx("span",{className:"agent-bar-tooltip-value",children:w})]}),o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[a("common:labels.tokens"),":"]}),o.jsxs("span",{className:"agent-bar-tooltip-value",children:[Rb(e.tokensUsed)," ",a("common:agentPopup.used")]})]}),o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[a("common:labels.context"),":"]}),o.jsxs("span",{className:"agent-bar-tooltip-value",style:{color:C>80?"#ff4a4a":C>60?"#ff9e4a":void 0},children:[Rb(e.contextUsed)," / ",Rb(e.contextLimit)," (",C,"%)"]})]}),e.currentTool&&o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[a("common:agentPopup.tool"),":"]}),o.jsxs("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-tool",children:[fs[e.currentTool]||fs.default," ",e.currentTool]})]}),e.currentTask&&o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[a("common:labels.task"),":"]}),o.jsxs("span",{className:"agent-bar-tooltip-value",children:[e.currentTask.substring(0,150),e.currentTask.length>150?"...":""]})]}),e.lastAssignedTask&&!e.currentTask&&o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[a("common:agentPopup.assignedTask"),":"]}),o.jsxs("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-query",children:[e.lastAssignedTask.substring(0,200),e.lastAssignedTask.length>200?"...":""]})]}),c&&o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[a("common:agentPopup.lastQuery"),":"]}),o.jsxs("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-query",children:[c.text.substring(0,300),c.text.length>300?"...":""]})]}),h&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"agent-bar-tooltip-divider"}),o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[a("common:agentPopup.supervisor"),":"]}),o.jsx("span",{className:"agent-bar-tooltip-value",style:{color:gW(h.analysis.progress)},children:h.analysis.progress.replace("_"," ")})]}),o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[a("common:labels.status"),":"]}),o.jsx("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-supervisor",children:h.analysis.statusDescription})]}),h.analysis.recentWorkSummary&&o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[a("common:labels.summary"),":"]}),o.jsxs("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-supervisor",children:[h.analysis.recentWorkSummary.substring(0,300),h.analysis.recentWorkSummary.length>300?"...":""]})]}),h.analysis.concerns&&h.analysis.concerns.length>0&&o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[a("common:labels.concerns"),":"]}),o.jsx("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-concerns",children:h.analysis.concerns.join("; ")})]})]})]})]})});function KA(t){if(t===0)return"0 B";const e=1024,n=["B","KB","MB","GB"],s=Math.floor(Math.log(t)/Math.log(e));return parseFloat((t/Math.pow(e,s)).toFixed(1))+" "+n[s]}function QA(t){const n=Date.now()-t,s=Math.floor(n/(1e3*60*60)),a=Math.floor(n%(1e3*60*60)/(1e3*60));return s>0?`${s}h ${a}m`:`${a}m`}const XA={30:"#1a1a1a",31:"#e74c3c",32:"#2ecc71",33:"#f39c12",34:"#3498db",35:"#9b59b6",36:"#00bcd4",37:"#ecf0f1",90:"#7f8c8d",91:"#ff6b6b",92:"#4ade80",93:"#fbbf24",94:"#60a5fa",95:"#c084fc",96:"#22d3ee",97:"#ffffff"};function xW(t){const e=[],n=/\x1B\[([0-9;]*)m/g;let s=0,a=null,r;for(;(r=n.exec(t))!==null;){if(r.index>s){const c=t.slice(s,r.index);a?e.push(o.jsx("span",{style:{color:a},children:c},e.length)):e.push(c)}const i=r[1].split(";").map(Number);for(const c of i)c===0||c===39?a=null:XA[c]&&(a=XA[c]);s=n.lastIndex}if(s<t.length){const i=t.slice(s);a?e.push(o.jsx("span",{style:{color:a},children:i},e.length)):e.push(i)}return e.length>0?e:[t]}const yW=x.memo(function({building:e,screenPos:n,onClose:s,onOpenSettings:a,onOpenLogsModal:r,onOpenUrlInModal:i}){var F,H,V,G,B,K,se,q,be,Ce,Z,ie,me,Ee,Te,Ve,We,ee,ne,Ne;const{t:c}=dt(["terminal","common"]),[d,f]=x.useState(!1),[h,m]=x.useState(null),[b,y]=x.useState(!1),w=x.useRef(null),C=x.useRef(h);C.current=h;const{buildingLogs:N}=Rs(),k=U.getBuildingLogs(e.id),j=(F=e.pm2)==null?void 0:F.enabled,S=(H=e.docker)==null?void 0:H.enabled,T=x.useRef(null),D=x.useRef(null),E=x.useCallback(ze=>{ze.preventDefault();const st=C.current?C.current.x:0,pe=C.current?C.current.y:0;w.current={mouseX:ze.clientX,mouseY:ze.clientY,popupX:st,popupY:pe},y(!0),T.current=Be=>{if(!w.current)return;const oe=Be.clientX-w.current.mouseX,de=Be.clientY-w.current.mouseY;m({x:w.current.popupX+oe,y:w.current.popupY+de})},D.current=()=>{y(!1),w.current=null,T.current&&document.removeEventListener("mousemove",T.current),D.current&&document.removeEventListener("mouseup",D.current)},document.addEventListener("mousemove",T.current),document.addEventListener("mouseup",D.current)},[]);x.useEffect(()=>()=>{T.current&&document.removeEventListener("mousemove",T.current),D.current&&document.removeEventListener("mouseup",D.current)},[]);const I=ze=>{if(ze==="logs"){if((j||S)&&r){r();return}U.sendBuildingCommand(e.id,ze),f(!0)}else U.sendBuildingCommand(e.id,ze)},O=(ze,st)=>{if(ze){const pe=`http://localhost:${ze}`;st&&i?i(pe):window.open(pe,"_blank")}},_=((V=e.pm2Status)==null?void 0:V.ports)||[],M=((B=(G=e.dockerStatus)==null?void 0:G.ports)==null?void 0:B.map(ze=>ze.host))||[],R=j?_:S?M:[],z=j?!!((K=e.pm2)!=null&&K.script):S?!!((se=e.docker)!=null&&se.image)||((q=e.docker)==null?void 0:q.mode)==="compose"||((be=e.docker)==null?void 0:be.mode)==="existing":!!((Ce=e.commands)!=null&&Ce.start),$=j?!!((Z=e.pm2)!=null&&Z.script):S?!0:!!((ie=e.commands)!=null&&ie.stop),W=j?!!((me=e.pm2)!=null&&me.script):S?!0:!!((Ee=e.commands)!=null&&Ee.restart),L=x.useMemo(()=>{const st=d?400:250;let pe=n.x+20,Be=n.y-80;return typeof window<"u"&&!h&&(n.x+20+280>window.innerWidth&&(pe=n.x-280-20),n.y-80<0?Be=10:n.y-80+st>window.innerHeight&&(Be=window.innerHeight-st-10)),{position:"fixed",left:pe+((h==null?void 0:h.x)||0),top:Be+((h==null?void 0:h.y)||0),zIndex:1e3,cursor:b?"grabbing":void 0}},[n.x,n.y,d,h,b]);return o.jsxs("div",{className:"building-action-popup",style:L,onClick:ze=>ze.stopPropagation(),children:[o.jsxs("div",{className:`building-popup-header ${b?"dragging":""}`,onMouseDown:E,children:[o.jsx("span",{className:"building-popup-name",children:e.name}),R.length>0&&o.jsx("span",{className:"building-popup-ports",children:R.map(ze=>o.jsxs("a",{href:`http://localhost:${ze}`,className:"building-popup-port-link",onClick:st=>{st.preventDefault(),st.stopPropagation(),O(ze,st.altKey)},onMouseDown:st=>st.stopPropagation(),title:`Open http://localhost:${ze} (Alt+Click for modal)`,children:[":",ze]},ze))}),o.jsx("span",{className:"building-popup-status",style:{backgroundColor:Vb[e.status]},children:e.status}),o.jsx("button",{className:"building-popup-close",onClick:s,children:"x"})]}),j&&e.pm2Status&&o.jsxs("div",{className:"building-popup-metrics",children:[o.jsxs("span",{className:"metric",children:[o.jsx("span",{className:"label",children:"PID"}),o.jsx("span",{className:"value",children:e.pm2Status.pid||"-"})]}),o.jsxs("span",{className:"metric",children:[o.jsx("span",{className:"label",children:"CPU"}),o.jsxs("span",{className:"value",children:[((Te=e.pm2Status.cpu)==null?void 0:Te.toFixed(1))||"0","%"]})]}),o.jsxs("span",{className:"metric",children:[o.jsx("span",{className:"label",children:"MEM"}),o.jsx("span",{className:"value",children:KA(e.pm2Status.memory||0)})]}),e.pm2Status.restarts!==void 0&&e.pm2Status.restarts>0&&o.jsxs("span",{className:"metric",children:[o.jsx("span",{className:"label",children:"RST"}),o.jsx("span",{className:"value",children:e.pm2Status.restarts})]}),e.pm2Status.uptime&&o.jsxs("span",{className:"metric",children:[o.jsx("span",{className:"label",children:"UP"}),o.jsx("span",{className:"value",children:QA(e.pm2Status.uptime)})]})]}),S&&e.dockerStatus&&o.jsxs("div",{className:"building-popup-metrics",children:[o.jsxs("span",{className:"metric",children:[o.jsx("span",{className:"label",children:"ID"}),o.jsx("span",{className:"value",children:e.dockerStatus.containerId||"-"})]}),e.dockerStatus.cpu!==void 0&&o.jsxs("span",{className:"metric",children:[o.jsx("span",{className:"label",children:"CPU"}),o.jsxs("span",{className:"value",children:[e.dockerStatus.cpu.toFixed(1),"%"]})]}),e.dockerStatus.memory!==void 0&&o.jsxs("span",{className:"metric",children:[o.jsx("span",{className:"label",children:"MEM"}),o.jsx("span",{className:"value",children:KA(e.dockerStatus.memory)})]}),e.dockerStatus.health&&e.dockerStatus.health!=="none"&&o.jsxs("span",{className:"metric",children:[o.jsx("span",{className:"label",children:"HEALTH"}),o.jsx("span",{className:"value",style:{color:e.dockerStatus.health==="healthy"?"#4ade80":e.dockerStatus.health==="unhealthy"?"#f87171":"#fbbf24"},children:e.dockerStatus.health==="healthy"?"✓":e.dockerStatus.health==="unhealthy"?"✗":"..."})]}),e.dockerStatus.startedAt&&o.jsxs("span",{className:"metric",children:[o.jsx("span",{className:"label",children:"UP"}),o.jsx("span",{className:"value",children:QA(e.dockerStatus.startedAt)})]})]}),S&&((Ve=e.dockerStatus)==null?void 0:Ve.services)&&e.dockerStatus.services.length>0&&o.jsx("div",{className:"building-popup-services",children:e.dockerStatus.services.map((ze,st)=>o.jsxs("span",{className:"service-item",title:`${ze.name}: ${ze.status}`,children:[o.jsx("span",{className:"service-indicator",style:{backgroundColor:ze.status==="running"?"#4ade80":"#f87171"}}),o.jsx("span",{className:"service-name",children:ze.name})]},st))}),(e.lastError||j&&((We=e.pm2Status)==null?void 0:We.status)==="errored"||S&&((ee=e.dockerStatus)==null?void 0:ee.status)==="dead")&&o.jsxs("div",{className:"building-popup-error",children:[e.lastError||c("terminal:building.processFailedToStart"),j&&((ne=e.pm2Status)==null?void 0:ne.restarts)&&e.pm2Status.restarts>5&&o.jsxs("span",{className:"error-hint",children:[" - ",c("terminal:building.checkLogsOrConfig")]}),S&&((Ne=e.dockerStatus)==null?void 0:Ne.health)==="unhealthy"&&o.jsxs("span",{className:"error-hint",children:[" - ",c("terminal:building.healthCheckFailing")]})]}),o.jsxs("div",{className:"building-popup-actions",children:[o.jsxs("button",{className:"action-btn start",onClick:()=>I("start"),disabled:!z||e.status==="running"||e.status==="starting",title:c(z?"terminal:buildingAction.start":"terminal:buildingAction.noStartCommand"),children:[o.jsx("span",{className:"icon",children:"▶"}),c("terminal:buildingAction.start")]}),o.jsxs("button",{className:"action-btn stop",onClick:()=>I("stop"),disabled:!$||e.status==="stopped"||e.status==="stopping",title:c($?"terminal:buildingAction.stop":"terminal:buildingAction.noStopCommand"),children:[o.jsx("span",{className:"icon",children:"■"}),c("terminal:buildingAction.stop")]}),o.jsxs("button",{className:"action-btn restart",onClick:()=>I("restart"),disabled:!W,title:c(W?"terminal:buildingAction.restart":"terminal:buildingAction.noRestartCommand"),children:[o.jsx("span",{className:"icon",children:"↺"}),c("terminal:buildingAction.restart")]}),o.jsxs("button",{className:"action-btn logs",onClick:()=>I("logs"),title:c("terminal:buildingAction.viewLogs"),children:[o.jsx("span",{className:"icon",children:"📄"}),c("terminal:logs.title")]}),R.length===1&&o.jsxs("button",{className:"action-btn open-url",onClick:ze=>O(R[0],ze.altKey),title:`Open http://localhost:${R[0]} (Alt+Click for modal)`,children:[o.jsx("span",{className:"icon",children:"🔗"}),c("terminal:buildingAction.openInBrowser")]}),R.length>1&&o.jsxs("div",{className:"action-btn-group",children:[o.jsxs("span",{className:"action-btn-label",children:[c("terminal:buildingAction.openInBrowser"),":"]}),R.map(ze=>o.jsxs("button",{className:"action-btn open-url port-btn",onClick:st=>O(ze,st.altKey),title:`Open http://localhost:${ze} (Alt+Click for modal)`,children:[":",ze]},ze))]})]}),d&&k.length>0&&o.jsxs("div",{className:"building-popup-logs",children:[o.jsxs("div",{className:"logs-header",children:[o.jsx("span",{children:c("terminal:logs.title")}),o.jsx("button",{onClick:()=>U.clearBuildingLogs(e.id),children:c("terminal:logs.clear")})]}),o.jsx("div",{className:"logs-content",children:k.slice(-50).map((ze,st)=>o.jsx("pre",{children:xW(ze)},st))})]}),o.jsx("button",{className:"building-popup-settings",onClick:a,children:c("terminal:buildingAction.fullSettings")})]})});function vW(t){if(t===0)return"0 B";const e=1024,n=["B","KB","MB","GB"],s=Math.floor(Math.log(t)/Math.log(e));return parseFloat((t/Math.pow(e,s)).toFixed(1))+" "+n[s]}function wW(t){const n=Date.now()-t,s=Math.floor(n/(1e3*60*60)),a=Math.floor(n%(1e3*60*60)/(1e3*60));return s>0?`${s}h ${a}m`:`${a}m`}const kW=x.memo(function({building:e,screenPos:n,onClose:s,onOpenSettings:a,onOpenLogsModal:r,onOpenUrlInModal:i}){const{t:c}=dt(["terminal","common"]),[d,f]=x.useState(null),[h,m]=x.useState(!1),b=x.useRef(null),y=x.useRef(d);y.current=d;const{buildings:w}=Rs(),N=(e.subordinateBuildingIds||[]).map(_=>w.get(_)).filter(_=>_!==void 0),k=x.useRef(null),j=x.useRef(null),S=x.useCallback(_=>{_.preventDefault();const M=y.current?y.current.x:0,R=y.current?y.current.y:0;b.current={mouseX:_.clientX,mouseY:_.clientY,popupX:M,popupY:R},m(!0),k.current=z=>{if(!b.current)return;const $=z.clientX-b.current.mouseX,W=z.clientY-b.current.mouseY;f({x:b.current.popupX+$,y:b.current.popupY+W})},j.current=()=>{m(!1),b.current=null,k.current&&document.removeEventListener("mousemove",k.current),j.current&&document.removeEventListener("mouseup",j.current)},document.addEventListener("mousemove",k.current),document.addEventListener("mouseup",j.current)},[]);x.useEffect(()=>()=>{k.current&&document.removeEventListener("mousemove",k.current),j.current&&document.removeEventListener("mouseup",j.current)},[]);const T=_=>{U.sendBossBuildingCommand(e.id,_)},D=N.reduce((_,M)=>(_[M.status]=(_[M.status]||0)+1,_),{}),E=N.some(_=>{var M;return(M=_.pm2)==null?void 0:M.enabled}),I=(_,M)=>{const R=`http://localhost:${_}`;M&&i?i(R):window.open(R,"_blank")},O=x.useMemo(()=>{let R=n.x+20,z=n.y-80;return typeof window<"u"&&!d&&(n.x+20+340>window.innerWidth&&(R=n.x-340-20),n.y-80<0?z=10:n.y-80+350>window.innerHeight&&(z=window.innerHeight-350-10)),{position:"fixed",left:R+((d==null?void 0:d.x)||0),top:z+((d==null?void 0:d.y)||0),zIndex:1e3,cursor:h?"grabbing":void 0}},[n.x,n.y,d,h]);return o.jsxs("div",{className:"building-action-popup boss-building-popup",style:O,onClick:_=>_.stopPropagation(),children:[o.jsxs("div",{className:`building-popup-header boss-header ${h?"dragging":""}`,onMouseDown:S,children:[o.jsx("span",{className:"boss-icon",children:"👑"}),o.jsx("span",{className:"building-popup-name",children:e.name}),o.jsx("span",{className:"subordinate-count",children:c("terminal:building.unitsCount",{count:N.length})}),o.jsx("button",{className:"building-popup-close",onClick:s,children:"x"})]}),o.jsxs("div",{className:"boss-status-overview",children:[Object.entries(D).map(([_,M])=>o.jsxs("span",{className:"status-badge",style:{backgroundColor:Vb[_]||"#666"},children:[M," ",_]},_)),N.length===0&&o.jsx("span",{className:"no-subordinates",children:c("terminal:building.noSubordinates")})]}),N.length>0&&o.jsx("div",{className:"subordinate-list",children:N.map(_=>{var M,R,z;return o.jsxs("div",{className:"subordinate-item",children:[o.jsx("span",{className:"sub-status-dot",style:{backgroundColor:Vb[_.status]}}),o.jsx("span",{className:"sub-name",children:_.name}),((M=_.pm2Status)==null?void 0:M.ports)&&_.pm2Status.ports.length>0&&o.jsx("span",{className:"sub-port",children:_.pm2Status.ports.map($=>o.jsxs("a",{href:`http://localhost:${$}`,className:"building-popup-port-link",onClick:W=>{W.preventDefault(),W.stopPropagation(),I($,W.altKey)},title:`Open http://localhost:${$} (Alt+Click for modal)`,children:[":",$]},$))}),_.pm2Status&&o.jsxs("span",{className:"sub-metrics",children:[(R=_.pm2Status.cpu)==null?void 0:R.toFixed(0),"% | ",vW(_.pm2Status.memory||0)]}),((z=_.pm2Status)==null?void 0:z.uptime)&&o.jsx("span",{className:"sub-uptime",children:wW(_.pm2Status.uptime)})]},_.id)})}),o.jsxs("div",{className:"building-popup-actions boss-actions",children:[o.jsxs("button",{className:"action-btn start",onClick:()=>T("start_all"),disabled:N.length===0,title:c("terminal:building.startAllSubs"),children:[o.jsx("span",{className:"icon",children:"▶"}),c("terminal:building.startAll")]}),o.jsxs("button",{className:"action-btn stop",onClick:()=>T("stop_all"),disabled:N.length===0,title:c("terminal:building.stopAllSubs"),children:[o.jsx("span",{className:"icon",children:"■"}),c("terminal:building.stopAll")]}),o.jsxs("button",{className:"action-btn restart",onClick:()=>T("restart_all"),disabled:N.length===0,title:c("terminal:building.restartAllSubs"),children:[o.jsx("span",{className:"icon",children:"↺"}),c("terminal:building.restartAll")]}),E&&o.jsxs("button",{className:"action-btn logs",onClick:r,title:c("terminal:building.viewUnifiedLogs"),children:[o.jsx("span",{className:"icon",children:"📄"}),c("terminal:building.logs")]})]}),o.jsx("button",{className:"building-popup-settings",onClick:a,children:c("terminal:building.fullSettings")})]})}),SW=x.memo(function({building:e,screenPos:n,onClose:s,onOpenSettings:a,onOpenDatabasePanel:r}){var D;const{t:i}=dt(["terminal","common"]),[c,d]=x.useState(null),[f,h]=x.useState(!1),m=x.useRef(null),b=x.useRef(c);b.current=c;const y=Gx(e.id),w=((D=e.database)==null?void 0:D.connections)??[],C=x.useRef(null),N=x.useRef(null),k=x.useCallback(E=>{E.preventDefault();const I=b.current?b.current.x:0,O=b.current?b.current.y:0;m.current={mouseX:E.clientX,mouseY:E.clientY,popupX:I,popupY:O},h(!0),C.current=_=>{if(!m.current)return;const M=_.clientX-m.current.mouseX,R=_.clientY-m.current.mouseY;d({x:m.current.popupX+M,y:m.current.popupY+R})},N.current=()=>{h(!1),m.current=null,C.current&&document.removeEventListener("mousemove",C.current),N.current&&document.removeEventListener("mouseup",N.current)},document.addEventListener("mousemove",C.current),document.addEventListener("mouseup",N.current)},[]);x.useEffect(()=>()=>{C.current&&document.removeEventListener("mousemove",C.current),N.current&&document.removeEventListener("mouseup",N.current)},[]);const j=E=>{U.testDatabaseConnection(e.id,E)},S=E=>y.connectionStatus.get(E),T=x.useMemo(()=>{let O=n.x+20,_=n.y-80;return typeof window<"u"&&!c&&(n.x+20+320>window.innerWidth&&(O=n.x-320-20),n.y-80<0?_=10:n.y-80+300>window.innerHeight&&(_=window.innerHeight-300-10)),{position:"fixed",left:O+((c==null?void 0:c.x)||0),top:_+((c==null?void 0:c.y)||0),zIndex:1e3,cursor:f?"grabbing":void 0}},[n.x,n.y,c,f]);return o.jsxs("div",{className:"building-action-popup database-building-popup",style:T,onClick:E=>E.stopPropagation(),children:[o.jsxs("div",{className:`building-popup-header database-header ${f?"dragging":""}`,onMouseDown:k,children:[o.jsx("span",{className:"database-icon",children:"🗄️"}),o.jsx("span",{className:"building-popup-name",children:e.name}),o.jsx("span",{className:"connection-count",children:i("terminal:building.connCount",{count:w.length})}),o.jsx("button",{className:"building-popup-close",onClick:s,children:"x"})]}),w.length>0?o.jsx("div",{className:"database-connection-list",children:w.map(E=>{var O;const I=S(E.id);return o.jsxs("div",{className:"database-connection-item",children:[o.jsx("span",{className:"conn-engine",children:((O=wL[E.engine])==null?void 0:O.icon)??"🗄️"}),o.jsx("span",{className:"conn-name",children:E.name}),o.jsx("span",{className:"conn-host",children:E.engine==="sqlite"?E.filepath||E.database||":memory:":`${E.host}:${E.port}`}),I&&o.jsx("span",{className:`conn-status ${I.connected?"connected":"disconnected"}`,children:I.connected?"●":"○"}),o.jsx("button",{className:"conn-test-btn",onClick:()=>j(E.id),title:i("terminal:building.testConnection"),children:"↻"})]},E.id)})}):o.jsxs("div",{className:"database-no-connections",children:[o.jsx("p",{children:i("terminal:building.noConnections")}),o.jsx("p",{className:"hint",children:i("terminal:building.clickSettingsToAdd")})]}),o.jsxs("div",{className:"building-popup-actions database-actions",children:[o.jsxs("button",{className:"action-btn query",onClick:r,disabled:w.length===0,title:i("terminal:building.openDbExplorer"),children:[o.jsx("span",{className:"icon",children:"⌨"}),i("terminal:building.query")]}),o.jsxs("button",{className:"action-btn test-all",onClick:()=>w.forEach(E=>j(E.id)),disabled:w.length===0,title:i("terminal:building.testAllConnections"),children:[o.jsx("span",{className:"icon",children:"↻"}),i("terminal:building.testAll")]})]}),o.jsx("button",{className:"building-popup-settings",onClick:a,children:i("common:buttons.settings")})]})});function CW({visible:t=!0,position:e="top-right"}){const[n,s]=x.useState(0),[a,r]=x.useState([]),[i,c]=x.useState(null),[d,f]=x.useState([]),[h,m]=x.useState(null),[b,y]=x.useState(null),[w,C]=x.useState(!1),[N,k]=x.useState("fps"),[j,S]=x.useState(null),[T,D]=x.useState(null),[E,I]=x.useState(null),[O,_]=x.useState(typeof window<"u"?window.innerWidth:1024),[M,R]=x.useState(null);x.useEffect(()=>{const Z=()=>_(window.innerWidth);return window.addEventListener("resize",Z),()=>window.removeEventListener("resize",Z)},[]);const z=Kp(),$=x.useMemo(()=>{const Z=z.filter(me=>me.memoryUsageMB!==void 0&&me.memoryUsageMB>0);return{totalMB:Z.reduce((me,Ee)=>me+(Ee.memoryUsageMB||0),0),agentCount:Z.length,agents:Z.map(me=>({name:me.name,memoryMB:me.memoryUsageMB||0,status:me.status})).sort((me,Ee)=>Ee.memoryMB-me.memoryMB)}},[z]),W=x.useRef([]),L=x.useRef(null);if(x.useEffect(()=>{W.current=d},[d]),x.useEffect(()=>{L.current=h},[h]),x.useEffect(()=>{if(!t)return;const Z=async()=>{try{const me=await Bt(Rt("/api/perf"));if(me.ok){const Ee=await me.json();D(Ee)}}catch{}};Z();const ie=setInterval(Z,w?3e3:1e4);return()=>clearInterval(ie)},[t,w]),x.useEffect(()=>{if(!t)return;const Z=su.getUsage();Z&&M===null&&R(Z.usedMB);const ie=setInterval(()=>{var st,pe;Nf.update();const me=Nf.getStats();s(me.current),r(Be=>[...Be,me.current].slice(-60));const Ee=su.getUsage();Ee&&c(Ee);const Te=window.__tideScene;if(Te){const Be=(st=Te.getMemoryDiagnostics)==null?void 0:st.call(Te);Be!=null&&Be.threeJs&&m(Be.threeJs);const oe=Te.renderer;if((pe=oe==null?void 0:oe.info)!=null&&pe.memory){const de=oe.info.memory.textures||0,He=Math.round(de*1);I({count:de,estimatedMB:He})}}const Ve=document.getElementsByTagName("*"),We=document.getElementsByTagName("canvas"),ee=document.getElementsByTagName("img"),ne=document.getElementsByTagName("video");let Ne=0;for(let Be=0;Be<Math.min(Ve.length,500);Be++){const oe=Ve[Be];oe.onclick&&Ne++,oe.onmousedown&&Ne++,oe.onkeydown&&Ne++}Ne+=10,S({nodeCount:Ve.length,listenerCount:Ne,canvasCount:We.length,imageCount:ee.length,videoCount:ne.length}),Ee&&f(Be=>{const oe=L.current,de={timestamp:Date.now(),heapMB:Ee.usedMB,geometries:(oe==null?void 0:oe.geometries)??0,textures:(oe==null?void 0:oe.textures)??0};return[...Be,de].slice(-120)});const ze=W.current;if(ze.length>=10){const Be=ze[0],oe=ze[ze.length-1],de=(oe.timestamp-Be.timestamp)/1e3/60;de>.1&&y((oe.heapMB-Be.heapMB)/de)}},1e3);return()=>{clearInterval(ie)}},[t,M]),!t)return null;const F=Z=>{const ie=Math.floor(Z/3600),me=Math.floor(Z%3600/60),Ee=Z%60;return ie>0?`${ie}h ${me}m`:me>0?`${me}m ${Ee}s`:`${Ee}s`},H=Z=>Z>=55?"#4aff9e":Z>=30?"#ffcc00":"#ff4a4a",V=(Z,ie)=>{const me=Z/ie;return me<.5?"#4aff9e":me<.8?"#ffcc00":"#ff4a4a"},G=Z=>Z===null?"#888":Z<1?"#4aff9e":Z<5?"#ffcc00":"#ff4a4a",B=Nf.getStats(),se=O<=768?80:10,q={"top-left":{top:10,left:10},"top-right":{top:10,right:10},"bottom-left":{bottom:se,left:10},"bottom-right":{bottom:se,right:10}},be=M&&i?i.usedMB-M:0,Ce=Z=>({padding:"2px 8px",fontSize:"9px",border:"none",background:N===Z?"rgba(74, 158, 255, 0.4)":"rgba(255, 255, 255, 0.1)",color:N===Z?"#4a9eff":"#888",borderRadius:"3px",cursor:"pointer"});return o.jsxs("div",{style:{position:"fixed",...q[e],zIndex:99999,fontFamily:"monospace",fontSize:"11px",background:"rgba(0, 0, 0, 0.9)",border:"1px solid rgba(255, 255, 255, 0.2)",borderRadius:"4px",padding:"6px 10px",color:"#fff",userSelect:"none",minWidth:w?"260px":"120px",maxWidth:"calc(100vw - 20px)",maxHeight:w?"calc(100vh - 100px)":"auto",overflowY:w?"auto":"visible",transition:"all 0.2s ease"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer"},onClick:()=>C(!w),children:[o.jsx("span",{style:{color:H(n),fontWeight:"bold",fontSize:"14px"},children:n}),o.jsx("span",{style:{color:"#666",fontSize:"10px"},children:"FPS"}),i&&o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{color:"#444"},children:"|"}),o.jsx("span",{style:{color:V(i.usedMB,i.totalMB),fontWeight:"bold"},children:i.usedMB}),o.jsx("span",{style:{color:"#666",fontSize:"10px"},children:"MB"})]}),b!==null&&Math.abs(b)>.5&&o.jsxs("span",{style:{color:G(b),fontSize:"10px",marginLeft:"4px"},children:[b>0?"+":"",b.toFixed(1),"/m"]}),T&&o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{color:"#444"},children:"|"}),o.jsx("span",{style:{color:"#ff9e4a",fontWeight:"bold"},children:T.process.rssMB}),o.jsx("span",{style:{color:"#666",fontSize:"10px"},children:"SRV"})]}),o.jsx("span",{style:{color:"#444",marginLeft:"auto",fontSize:"10px"},children:w?"▼":"▶"})]}),w&&o.jsxs("div",{style:{marginTop:"8px",borderTop:"1px solid rgba(255,255,255,0.1)",paddingTop:"8px"},children:[o.jsxs("div",{style:{display:"flex",gap:"4px",marginBottom:"8px",flexWrap:"wrap"},children:[o.jsx("button",{style:Ce("fps"),onClick:()=>k("fps"),children:"FPS"}),o.jsx("button",{style:Ce("memory"),onClick:()=>k("memory"),children:"Memory"}),o.jsx("button",{style:Ce("threejs"),onClick:()=>k("threejs"),children:"3D"}),o.jsx("button",{style:Ce("dom"),onClick:()=>k("dom"),children:"DOM"}),o.jsx("button",{style:Ce("server"),onClick:()=>k("server"),children:"Server"}),o.jsx("button",{style:Ce("http"),onClick:()=>k("http"),children:"HTTP"})]}),N==="fps"&&o.jsxs("div",{children:[o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"2px 10px",fontSize:"10px",marginBottom:"8px"},children:[o.jsx("span",{style:{color:"#888"},children:"Current:"}),o.jsx("span",{style:{color:H(B.current)},children:B.current}),o.jsx("span",{style:{color:"#888"},children:"Min:"}),o.jsx("span",{style:{color:H(B.min)},children:B.min}),o.jsx("span",{style:{color:"#888"},children:"Max:"}),o.jsx("span",{style:{color:H(B.max)},children:B.max}),o.jsx("span",{style:{color:"#888"},children:"Avg:"}),o.jsx("span",{style:{color:H(B.avg)},children:B.avg})]}),o.jsxs("div",{style:{marginBottom:"8px"},children:[o.jsx("div",{style:{color:"#666",fontSize:"9px",marginBottom:"2px"},children:"60s History:"}),o.jsx("div",{style:{display:"flex",alignItems:"flex-end",height:"30px",gap:"1px",background:"rgba(0,0,0,0.3)",padding:"2px",borderRadius:"2px"},children:a.slice(-60).map((Z,ie)=>o.jsx("div",{style:{width:"3px",height:`${Math.min(100,Z/60*100)}%`,background:H(Z),opacity:.8}},ie))})]})]}),N==="memory"&&i&&o.jsxs("div",{children:[o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"2px 10px",fontSize:"10px",marginBottom:"8px"},children:[o.jsx("span",{style:{color:"#888"},children:"Used:"}),o.jsxs("span",{style:{color:V(i.usedMB,i.totalMB)},children:[i.usedMB," MB"]}),o.jsx("span",{style:{color:"#888"},children:"Total:"}),o.jsxs("span",{children:[i.totalMB," MB"]}),o.jsx("span",{style:{color:"#888"},children:"Limit:"}),o.jsxs("span",{children:[i.limitMB," MB"]}),o.jsx("span",{style:{color:"#888"},children:"Baseline:"}),o.jsxs("span",{children:[M??"—"," MB"]}),o.jsx("span",{style:{color:"#888"},children:"Growth:"}),o.jsxs("span",{style:{color:be>50?"#ff4a4a":be>20?"#ffcc00":"#4aff9e"},children:[be>0?"+":"",be," MB"]}),o.jsx("span",{style:{color:"#888"},children:"Rate:"}),o.jsx("span",{style:{color:G(b)},children:b!==null?`${b.toFixed(2)} MB/min`:"—"})]}),o.jsx("div",{style:{marginBottom:"8px"},children:o.jsx("div",{style:{height:"8px",background:"rgba(255,255,255,0.1)",borderRadius:"4px",overflow:"hidden"},children:o.jsx("div",{style:{height:"100%",width:`${i.usedMB/i.limitMB*100}%`,background:V(i.usedMB,i.totalMB),transition:"width 0.3s ease"}})})}),d.length>1&&o.jsxs("div",{children:[o.jsx("div",{style:{color:"#666",fontSize:"9px",marginBottom:"2px"},children:"Memory History:"}),o.jsx("div",{style:{display:"flex",alignItems:"flex-end",height:"40px",gap:"1px",background:"rgba(0,0,0,0.3)",padding:"2px",borderRadius:"2px"},children:d.slice(-60).map((Z,ie)=>{const me=Math.min(...d.map(We=>We.heapMB)),Te=Math.max(...d.map(We=>We.heapMB))-me||1,Ve=(Z.heapMB-me)/Te*100;return o.jsx("div",{style:{width:"3px",height:`${Math.max(5,Ve)}%`,background:Z.heapMB>(M??0)+50?"#ff4a4a":"#4a9eff",opacity:.8},title:`${Z.heapMB}MB`},ie)})})]}),$.agentCount>0&&o.jsxs("div",{style:{marginTop:"8px"},children:[o.jsxs("div",{style:{color:"#666",fontSize:"9px",marginBottom:"2px"},children:["Agent Memory (",$.agentCount,"):"]}),o.jsxs("div",{style:{fontSize:"10px"},children:[o.jsxs("div",{style:{color:"#4aff9e",fontWeight:"bold",marginBottom:"2px"},children:["Total: ",$.totalMB,"MB"]}),o.jsx("div",{style:{maxHeight:"50px",overflowY:"auto"},children:$.agents.slice(0,4).map((Z,ie)=>o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"1px"},children:[o.jsx("span",{style:{color:Z.status==="working"?"#4aff9e":"#666",maxWidth:"120px",overflow:"hidden",textOverflow:"ellipsis"},children:Z.name}),o.jsxs("span",{style:{color:"#4a9eff"},children:[Z.memoryMB,"MB"]})]},ie))})]})]}),o.jsxs("div",{style:{marginTop:"8px",padding:"6px",background:"rgba(0,0,0,0.3)",borderRadius:"4px"},children:[o.jsx("div",{style:{color:"#888",fontSize:"9px",marginBottom:"4px"},children:"Memory Breakdown (estimated):"}),o.jsxs("div",{style:{fontSize:"9px"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"2px"},children:[o.jsx("span",{style:{color:"#4a9eff"},children:"JS Heap"}),o.jsxs("span",{style:{color:"#4a9eff"},children:[i.usedMB," MB"]})]}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"2px"},children:[o.jsx("span",{style:{color:"#ff9e4a"},children:"GPU/Textures"}),o.jsxs("span",{style:{color:"#ff9e4a"},children:["~",(E==null?void 0:E.estimatedMB)??0," MB"]})]}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"2px"},children:[o.jsxs("span",{style:{color:"#9e4aff"},children:["DOM (",(j==null?void 0:j.nodeCount.toLocaleString())??0," nodes)"]}),o.jsxs("span",{style:{color:"#9e4aff"},children:["~",Math.round(((j==null?void 0:j.nodeCount)??0)*.5/1024)," MB"]})]}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",borderTop:"1px solid rgba(255,255,255,0.1)",paddingTop:"4px",marginTop:"4px"},children:[o.jsx("span",{style:{color:"#fff",fontWeight:"bold"},children:"Est. Total"}),o.jsxs("span",{style:{color:"#fff",fontWeight:"bold"},children:["~",i.usedMB+((E==null?void 0:E.estimatedMB)??0)+Math.round(((j==null?void 0:j.nodeCount)??0)*.5/1024)," MB"]})]})]})]})]}),N==="threejs"&&o.jsx("div",{children:h?o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"2px 10px",fontSize:"10px",marginBottom:"8px"},children:[o.jsx("span",{style:{color:"#888"},children:"Geometries:"}),o.jsx("span",{style:{color:"#4aff9e"},children:h.geometries}),o.jsx("span",{style:{color:"#888"},children:"Textures:"}),o.jsx("span",{style:{color:"#ff9e4a"},children:h.textures}),o.jsx("span",{style:{color:"#888"},children:"Programs:"}),o.jsx("span",{style:{color:"#9e4aff"},children:h.programs})]}),d.length>1&&o.jsxs("div",{children:[o.jsx("div",{style:{color:"#666",fontSize:"9px",marginBottom:"2px"},children:"Resource History:"}),o.jsx("div",{style:{display:"flex",alignItems:"flex-end",height:"40px",gap:"1px",background:"rgba(0,0,0,0.3)",padding:"2px",borderRadius:"2px"},children:d.slice(-60).map((Z,ie)=>{const me=Math.max(...d.map(Ee=>Ee.textures))||1;return o.jsx("div",{style:{width:"3px",height:`${Z.textures/me*100}%`,background:"#ff9e4a",opacity:.8},title:`${Z.textures} textures`},ie)})})]}),o.jsx("div",{style:{color:"#666",fontSize:"9px",marginTop:"8px"},children:"Tip: Watch textures count. If it keeps increasing, there's a leak."})]}):o.jsxs("div",{style:{color:"#666",fontSize:"10px"},children:["Three.js stats unavailable.",o.jsx("br",{}),"SceneManager not exposed."]})}),N==="dom"&&o.jsx("div",{children:j?o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"2px 10px",fontSize:"10px",marginBottom:"8px"},children:[o.jsx("span",{style:{color:"#888"},children:"DOM Nodes:"}),o.jsx("span",{style:{color:j.nodeCount>5e3?"#ff4a4a":j.nodeCount>2e3?"#ffcc00":"#4aff9e"},children:j.nodeCount.toLocaleString()}),o.jsx("span",{style:{color:"#888"},children:"Canvases:"}),o.jsx("span",{style:{color:"#4a9eff"},children:j.canvasCount}),o.jsx("span",{style:{color:"#888"},children:"Images:"}),o.jsx("span",{style:{color:"#ff9e4a"},children:j.imageCount}),o.jsx("span",{style:{color:"#888"},children:"Videos:"}),o.jsx("span",{style:{color:"#9e4aff"},children:j.videoCount})]}),E&&o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"2px 10px",fontSize:"10px",marginBottom:"8px",borderTop:"1px solid rgba(255,255,255,0.1)",paddingTop:"6px"},children:[o.jsx("span",{style:{color:"#888"},children:"GPU Textures:"}),o.jsx("span",{style:{color:"#ff9e4a"},children:E.count}),o.jsx("span",{style:{color:"#888"},children:"Est. VRAM:"}),o.jsxs("span",{style:{color:E.estimatedMB>100?"#ff4a4a":"#4aff9e"},children:["~",E.estimatedMB," MB"]})]}),o.jsxs("div",{style:{marginTop:"8px",padding:"6px",background:"rgba(0,0,0,0.3)",borderRadius:"4px"},children:[o.jsx("div",{style:{color:"#888",fontSize:"9px",marginBottom:"4px"},children:"Memory Breakdown (estimated):"}),o.jsxs("div",{style:{fontSize:"9px"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"2px"},children:[o.jsx("span",{style:{color:"#4a9eff"},children:"JS Heap"}),o.jsxs("span",{style:{color:"#4a9eff"},children:[(i==null?void 0:i.usedMB)??0," MB"]})]}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"2px"},children:[o.jsx("span",{style:{color:"#ff9e4a"},children:"GPU/Textures"}),o.jsxs("span",{style:{color:"#ff9e4a"},children:["~",(E==null?void 0:E.estimatedMB)??0," MB"]})]}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"2px"},children:[o.jsx("span",{style:{color:"#9e4aff"},children:"DOM (~0.5KB/node)"}),o.jsxs("span",{style:{color:"#9e4aff"},children:["~",Math.round(j.nodeCount*.5/1024)," MB"]})]}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",borderTop:"1px solid rgba(255,255,255,0.1)",paddingTop:"4px",marginTop:"4px"},children:[o.jsx("span",{style:{color:"#fff",fontWeight:"bold"},children:"Est. Total"}),o.jsxs("span",{style:{color:"#fff",fontWeight:"bold"},children:["~",((i==null?void 0:i.usedMB)??0)+((E==null?void 0:E.estimatedMB)??0)+Math.round(j.nodeCount*.5/1024)," MB"]})]})]})]}),o.jsx("div",{style:{color:"#666",fontSize:"9px",marginTop:"8px"},children:"Note: Task Manager shows more due to browser overhead, decoded images, and WebGL buffers."})]}):o.jsx("div",{style:{color:"#666",fontSize:"10px"},children:"Loading DOM stats..."})}),N==="server"&&o.jsx("div",{children:T?o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"2px 10px",fontSize:"10px",marginBottom:"8px"},children:[o.jsx("span",{style:{color:"#888"},children:"Uptime:"}),o.jsx("span",{style:{color:"#4aff9e"},children:F(T.uptime)}),o.jsx("span",{style:{color:"#888"},children:"Heap Used:"}),o.jsxs("span",{style:{color:T.process.heapUsedMB>500?"#ff4a4a":"#4aff9e"},children:[T.process.heapUsedMB," MB"]}),o.jsx("span",{style:{color:"#888"},children:"Heap Total:"}),o.jsxs("span",{children:[T.process.heapTotalMB," MB"]}),o.jsx("span",{style:{color:"#888"},children:"RSS:"}),o.jsxs("span",{style:{color:"#4a9eff"},children:[T.process.rssMB," MB"]}),o.jsx("span",{style:{color:"#888"},children:"External:"}),o.jsxs("span",{children:[T.process.externalMB," MB"]})]}),o.jsxs("div",{style:{borderTop:"1px solid rgba(255,255,255,0.1)",paddingTop:"6px",marginBottom:"8px"},children:[o.jsx("div",{style:{color:"#666",fontSize:"9px",marginBottom:"4px"},children:"System:"}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"2px 10px",fontSize:"10px"},children:[o.jsx("span",{style:{color:"#888"},children:"Load Avg:"}),o.jsx("span",{style:{color:T.system.loadAvg[0]>T.system.cpuCount?"#ff4a4a":"#4aff9e"},children:T.system.loadAvg.join(" ")}),o.jsx("span",{style:{color:"#888"},children:"CPUs:"}),o.jsx("span",{children:T.system.cpuCount}),o.jsx("span",{style:{color:"#888"},children:"Sys Memory:"}),o.jsxs("span",{children:[T.system.totalMemMB-T.system.freeMemMB," / ",T.system.totalMemMB," MB"]})]})]}),o.jsxs("div",{style:{borderTop:"1px solid rgba(255,255,255,0.1)",paddingTop:"6px",marginBottom:"8px"},children:[o.jsx("div",{style:{color:"#666",fontSize:"9px",marginBottom:"4px"},children:"WebSocket:"}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"2px 10px",fontSize:"10px"},children:[o.jsx("span",{style:{color:"#888"},children:"Clients:"}),o.jsx("span",{style:{color:"#4a9eff"},children:T.websocket.clients}),o.jsx("span",{style:{color:"#888"},children:"Sent:"}),o.jsx("span",{children:T.websocket.messagesSent.toLocaleString()}),o.jsx("span",{style:{color:"#888"},children:"Received:"}),o.jsx("span",{children:T.websocket.messagesReceived.toLocaleString()})]})]}),T.agents.total>0&&o.jsxs("div",{style:{borderTop:"1px solid rgba(255,255,255,0.1)",paddingTop:"6px"},children:[o.jsxs("div",{style:{color:"#666",fontSize:"9px",marginBottom:"4px"},children:["Agents (",T.agents.working,"w / ",T.agents.idle,"i / ",T.agents.total,"t):"]}),o.jsx("div",{style:{maxHeight:"80px",overflowY:"auto",fontSize:"10px"},children:T.agents.processes.map(Z=>o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"1px"},children:[o.jsx("span",{style:{color:Z.status==="working"?"#4aff9e":Z.status==="idle"?"#888":"#ff4a4a",maxWidth:"100px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Z.name}),o.jsxs("span",{style:{color:"#4a9eff"},children:[Z.memoryMB!=null?`${Z.memoryMB}MB`:"—",Z.pid?` (${Z.pid})`:""]})]},Z.id))})]})]}):o.jsx("div",{style:{color:"#666",fontSize:"10px"},children:"Loading server metrics..."})}),N==="http"&&o.jsx("div",{children:T?o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"2px 10px",fontSize:"10px",marginBottom:"8px"},children:[o.jsx("span",{style:{color:"#888"},children:"Req/sec (30s):"}),o.jsx("span",{style:{color:"#4aff9e"},children:T.http.reqPerSec}),o.jsx("span",{style:{color:"#888"},children:"Avg Latency:"}),o.jsxs("span",{style:{color:T.http.avgLatencyMs>100?"#ff4a4a":T.http.avgLatencyMs>50?"#ffcc00":"#4aff9e"},children:[T.http.avgLatencyMs," ms"]}),o.jsx("span",{style:{color:"#888"},children:"Max Latency:"}),o.jsxs("span",{style:{color:T.http.maxLatencyMs>500?"#ff4a4a":T.http.maxLatencyMs>200?"#ffcc00":"#4aff9e"},children:[T.http.maxLatencyMs," ms"]}),o.jsx("span",{style:{color:"#888"},children:"Recent Reqs:"}),o.jsx("span",{children:T.http.recentRequests})]}),o.jsxs("div",{style:{marginBottom:"8px"},children:[o.jsx("div",{style:{color:"#666",fontSize:"9px",marginBottom:"4px"},children:"Avg Latency:"}),o.jsx("div",{style:{height:"8px",background:"rgba(255,255,255,0.1)",borderRadius:"4px",overflow:"hidden"},children:o.jsx("div",{style:{height:"100%",width:`${Math.min(100,T.http.avgLatencyMs/500*100)}%`,background:T.http.avgLatencyMs>100?"#ff4a4a":T.http.avgLatencyMs>50?"#ffcc00":"#4aff9e",transition:"width 0.3s ease"}})}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"8px",color:"#444",marginTop:"2px"},children:[o.jsx("span",{children:"0ms"}),o.jsx("span",{children:"500ms"})]})]}),o.jsxs("div",{style:{borderTop:"1px solid rgba(255,255,255,0.1)",paddingTop:"6px"},children:[o.jsx("div",{style:{color:"#666",fontSize:"9px",marginBottom:"4px"},children:"Server Process:"}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"2px 10px",fontSize:"10px"},children:[o.jsx("span",{style:{color:"#888"},children:"CPU (user):"}),o.jsxs("span",{style:{color:"#4a9eff"},children:[T.process.cpuUser," ms"]}),o.jsx("span",{style:{color:"#888"},children:"CPU (system):"}),o.jsxs("span",{style:{color:"#ff9e4a"},children:[T.process.cpuSystem," ms"]}),o.jsx("span",{style:{color:"#888"},children:"WS Clients:"}),o.jsx("span",{style:{color:"#4aff9e"},children:T.websocket.clients})]})]})]}):o.jsx("div",{style:{color:"#666",fontSize:"10px"},children:"Loading HTTP metrics..."})}),o.jsxs("div",{style:{display:"flex",gap:"4px",marginTop:"8px",borderTop:"1px solid rgba(255,255,255,0.1)",paddingTop:"8px",flexWrap:"wrap"},children:[o.jsx("button",{onClick:Z=>{Z.stopPropagation();const ie=["=== Tide Commander Performance Stats ===",`Timestamp: ${new Date().toISOString()}`,"","--- FPS ---",`Current: ${B.current}`,`Min: ${B.min}`,`Max: ${B.max}`,`Avg: ${B.avg}`];i&&ie.push("","--- Memory ---",`Heap Used: ${i.usedMB} MB`,`Heap Total: ${i.totalMB} MB`,`Heap Limit: ${i.limitMB} MB`,`Baseline: ${M??"N/A"} MB`,`Growth: ${be>0?"+":""}${be} MB`,`Growth Rate: ${b!==null?`${b.toFixed(2)} MB/min`:"N/A"}`),h&&ie.push("","--- Three.js ---",`Geometries: ${h.geometries}`,`Textures: ${h.textures}`,`Programs: ${h.programs}`),$.agentCount>0&&(ie.push("","--- Agent Memory ---",`Total: ${$.totalMB} MB`,`Agents: ${$.agentCount}`),$.agents.slice(0,5).forEach(Ee=>{ie.push(` ${Ee.name}: ${Ee.memoryMB} MB (${Ee.status})`)})),j&&ie.push("","--- DOM ---",`DOM Nodes: ${j.nodeCount.toLocaleString()}`,`Canvases: ${j.canvasCount}`,`Images: ${j.imageCount}`,`Videos: ${j.videoCount}`),E&&ie.push("","--- Estimated Memory ---",`GPU Textures: ${E.count}`,`Est. VRAM: ~${E.estimatedMB} MB`,`Est. DOM: ~${Math.round(((j==null?void 0:j.nodeCount)??0)*.5/1024)} MB`,`Est. Total: ~${((i==null?void 0:i.usedMB)??0)+E.estimatedMB+Math.round(((j==null?void 0:j.nodeCount)??0)*.5/1024)} MB`),T&&(ie.push("","--- Server ---",`Uptime: ${F(T.uptime)}`,`Heap: ${T.process.heapUsedMB}/${T.process.heapTotalMB} MB`,`RSS: ${T.process.rssMB} MB`,`Load Avg: ${T.system.loadAvg.join(" ")}`,`System Memory: ${T.system.totalMemMB-T.system.freeMemMB}/${T.system.totalMemMB} MB`,"","--- WebSocket ---",`Clients: ${T.websocket.clients}`,`Sent: ${T.websocket.messagesSent}`,`Received: ${T.websocket.messagesReceived}`,"","--- HTTP ---",`Req/sec: ${T.http.reqPerSec}`,`Avg Latency: ${T.http.avgLatencyMs} ms`,`Max Latency: ${T.http.maxLatencyMs} ms`),T.agents.processes.length>0&&(ie.push("","--- Agent Processes ---",`Total: ${T.agents.total} (${T.agents.working} working, ${T.agents.idle} idle)`),T.agents.processes.forEach(Ee=>{ie.push(` ${Ee.name}: ${Ee.memoryMB!=null?`${Ee.memoryMB}MB`:"N/A"} (${Ee.status})${Ee.pid?` PID:${Ee.pid}`:""}`)})));const me=ie.join(`
152
- `);navigator.clipboard.writeText(me).then(()=>{const Ee=Z.currentTarget,Te=Ee.textContent;Ee.textContent="Copied!",setTimeout(()=>{Ee.textContent=Te},1e3)})},style:{flex:1,background:"rgba(74, 255, 158, 0.3)",border:"1px solid rgba(74, 255, 158, 0.5)",color:"#4aff9e",padding:"4px 6px",borderRadius:"3px",fontSize:"9px",cursor:"pointer"},children:"Copy Stats"}),o.jsx("button",{onClick:Z=>{Z.stopPropagation(),su.report();const ie=window.__tideScene;ie!=null&&ie.logMemoryDiagnostics&&ie.logMemoryDiagnostics()},style:{flex:1,background:"rgba(74, 158, 255, 0.3)",border:"1px solid rgba(74, 158, 255, 0.5)",color:"#4a9eff",padding:"4px 6px",borderRadius:"3px",fontSize:"9px",cursor:"pointer"},children:"Console"}),o.jsx("button",{onClick:Z=>{Z.stopPropagation(),Jb.clear(),Nf.reset(),su.reset(),r([]),f([]);const ie=su.getUsage();ie&&R(ie.usedMB)},style:{flex:1,background:"rgba(255, 74, 74, 0.3)",border:"1px solid rgba(255, 74, 74, 0.5)",color:"#ff4a4a",padding:"4px 6px",borderRadius:"3px",fontSize:"9px",cursor:"pointer"},children:"Reset"})]})]})]})}function AW(){const t=l1(),e=x.useCallback(n=>{U.setViewMode(n)},[]);return[t,e]}const jW=["3d","2d","dashboard"],NW=x.memo(function({className:e=""}){const{t:n}=dt(["common"]),[s,a]=AW(),r=x.useRef(null),[i,c]=x.useState(null);x.useLayoutEffect(()=>{const f=r.current;if(!f)return;const h=f.querySelector(".view-mode-toggle__btn--active");h&&c({left:h.offsetLeft,width:h.offsetWidth})},[s]);const d=x.useCallback(f=>{if(f!==s){if(typeof window<"u"&&window.dispatchEvent(new CustomEvent("tide:viewmode-switch-pressed",{detail:{mode:f}})),f==="3d"){requestAnimationFrame(()=>a(f));return}a(f)}},[s,a]);return o.jsxs("div",{className:`view-mode-toggle ${e}`,ref:r,children:[i&&o.jsx("div",{className:"view-mode-toggle__indicator",style:{left:i.left,width:i.width}}),jW.map(f=>o.jsxs("button",{className:`view-mode-toggle__btn ${s===f?"view-mode-toggle__btn--active":""}`,onClick:()=>d(f),title:n(`common:viewMode.descriptions.${f}`),children:[o.jsxs("span",{className:"view-mode-toggle__icon",children:[f==="2d"&&o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),o.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),o.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"21"})]}),f==="3d"&&o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),o.jsx("path",{d:"M2 17l10 5 10-5"}),o.jsx("path",{d:"M2 12l10 5 10-5"})]}),f==="dashboard"&&o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("rect",{x:"3",y:"3",width:"7",height:"9",rx:"1"}),o.jsx("rect",{x:"14",y:"3",width:"7",height:"5",rx:"1"}),o.jsx("rect",{x:"14",y:"12",width:"7",height:"9",rx:"1"}),o.jsx("rect",{x:"3",y:"16",width:"7",height:"5",rx:"1"})]})]}),o.jsx("span",{className:"view-mode-toggle__label",children:n(`common:viewMode.labels.${f}`)})]},f))]})});function ZT({className:t}){const{t:e}=dt(["terminal"]),[n,s]=x.useState(!1),[a,r]=x.useState(null),i=Dy(),c=x.useCallback(async y=>{if(y.trim()){console.log("[VoiceAssistant] Transcribed:",y),s(!0),r(null);try{const C=await(await Bt(Rt("/api/voice-assistant/process"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:y})})).json();if(C.success&&C.response)console.log("[VoiceAssistant] Response:",C.response),i.speak(C.response);else{const N=C.error||e("terminal:voiceAssistant.failedToProcess");console.error("[VoiceAssistant] Error:",N),r(N),i.speak(N)}}catch(w){console.error("[VoiceAssistant] Request failed:",w);const C=e("terminal:voiceAssistant.unavailable");r(C),i.speak(C)}finally{s(!1)}}},[i]),d=HT({language:"Spanish",model:"medium",onTranscription:c}),f=d.recording||d.transcribing||n||i.speaking,h=()=>d.error?`${e("terminal:voiceAssistant.error")}: ${d.error}`:a?`${e("terminal:voiceAssistant.error")}: ${a}`:d.recording?e("terminal:voiceAssistant.recording"):d.transcribing?e("terminal:voiceAssistant.transcribing"):n?e("terminal:voiceAssistant.processing"):i.speaking?e("terminal:voiceAssistant.speaking"):e("terminal:voiceAssistant.title"),m=()=>{const y=["voice-assistant-btn",t].filter(Boolean);return d.recording&&y.push("recording"),(d.transcribing||n)&&y.push("processing"),i.speaking&&y.push("speaking"),(a||d.error)&&y.push("error"),y.join(" ")},b=()=>{if(r(null),i.speaking){i.stop();return}d.transcribing||n||d.toggleRecording()};return o.jsxs("button",{className:m(),onClick:b,title:d.supported?h():e("terminal:voiceAssistant.notSupported"),disabled:!d.supported||d.transcribing||n,children:[d.recording?o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor",children:[o.jsx("path",{d:"M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3z"}),o.jsx("path",{d:"M17 11c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.61 6.43 6 6.92V21h2v-3.08c3.39-.49 6-3.39 6-6.92h-2z"})]}):i.speaking?o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5",fill:"currentColor"}),o.jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),o.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]}):o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("path",{d:"M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"}),o.jsx("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),o.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"23"}),o.jsx("line",{x1:"8",y1:"23",x2:"16",y2:"23"})]}),f&&o.jsx("span",{className:"voice-assistant-indicator"})]})}const TW=x.memo(function({isOpen:e,onToggle:n,onShowTerminal:s,onOpenSidebar:a,onOpenToolbox:r,onOpenCommander:i,onOpenSupervisor:c,onOpenControls:d,onOpenSkills:f,onOpenSnapshots:h,onTakeSnapshot:m,canTakeSnapshot:b,mobileView:y}){const{t:w}=dt(["terminal","common"]),C=Vr(),N=k=>{k(),n()};return o.jsxs(o.Fragment,{children:[C.experimentalVoiceAssistant&&o.jsx(ZT,{className:"mobile-voice-assistant"}),y!=="terminal"&&o.jsx("button",{className:`mobile-fab-toggle ${e?"open":""}`,onClick:n,onTouchStart:k=>k.stopPropagation(),title:w(e?"terminal:mobileFab.closeMenu":"terminal:mobileFab.openMenu"),children:e?"✕":"☰"}),y==="3d"&&o.jsxs("div",{className:`mobile-fab-menu ${e?"open":""}`,children:[o.jsx("button",{className:"mobile-fab-option",onClick:()=>N(s),onTouchEnd:k=>{k.preventDefault(),N(s)},title:w("terminal:mobileFab.showTerminal"),children:"💬"}),o.jsx("button",{className:"mobile-fab-option",onClick:()=>N(a),onTouchEnd:k=>{k.preventDefault(),N(a)},title:w("terminal:header.openSidebar"),children:"📋"}),b&&o.jsx("button",{className:"mobile-fab-option mobile-fab-option--highlight",onClick:()=>N(m),onTouchEnd:k=>{k.preventDefault(),N(m)},title:w("terminal:mobileFab.takeSnapshot"),children:"⭐"}),o.jsx("button",{className:"mobile-fab-option",onClick:()=>N(r),onTouchEnd:k=>{k.preventDefault(),N(r)},title:w("common:floatingButtons.settingsAndTools"),children:"⚙️"}),o.jsx("button",{className:"mobile-fab-option",onClick:()=>N(i),onTouchEnd:k=>{k.preventDefault(),N(i)},title:w("common:floatingButtons.commanderView"),children:"📊"}),o.jsx("button",{className:"mobile-fab-option",onClick:()=>N(c),onTouchEnd:k=>{k.preventDefault(),N(c)},title:w("common:floatingButtons.supervisorOverview"),children:"🎖️"}),o.jsx("button",{className:"mobile-fab-option",onClick:()=>N(d),onTouchEnd:k=>{k.preventDefault(),N(d)},title:w("common:floatingButtons.controls"),children:"⌨️"}),o.jsx("button",{className:"mobile-fab-option",onClick:()=>N(f),onTouchEnd:k=>{k.preventDefault(),N(f)},title:w("common:floatingButtons.manageSkills"),children:"⭐"}),o.jsx("button",{className:"mobile-fab-option",onClick:()=>N(h),onTouchEnd:k=>{k.preventDefault(),N(h)},title:w("common:floatingButtons.viewSnapshots"),children:"📸"})]})]})}),_W=x.memo(function({onOpenToolbox:e,onOpenCommander:n,onOpenSupervisor:s,onOpenControls:a,onOpenSkills:r,onOpenSnapshots:i,isGeneratingReport:c,pip:d}){const{t:f}=dt(["common","terminal"]),h=Vr();return o.jsxs(o.Fragment,{children:[h.experimentalVoiceAssistant&&o.jsx(ZT,{}),o.jsx(os,{content:f("common:floatingButtons.settingsAndTools"),position:"left",children:o.jsx("button",{className:"floating-settings-btn",onClick:e,children:o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),o.jsx("circle",{cx:"12",cy:"12",r:"3"})]})})}),o.jsx(os,{content:f("common:floatingButtons.commanderView"),position:"left",children:o.jsx("button",{className:"commander-toggle-btn",onClick:n,children:o.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("rect",{x:"3",y:"3",width:"7",height:"7"}),o.jsx("rect",{x:"14",y:"3",width:"7",height:"7"}),o.jsx("rect",{x:"3",y:"14",width:"7",height:"7"}),o.jsx("rect",{x:"14",y:"14",width:"7",height:"7"})]})})}),o.jsx(os,{content:f("common:floatingButtons.viewSnapshots"),position:"left",children:o.jsx("button",{className:"snapshots-toggle-btn",onClick:i,children:"📸"})}),o.jsx(os,{content:f(c?"terminal:supervisor.generating":"common:floatingButtons.supervisorOverview"),position:"left",children:o.jsxs("button",{className:`supervisor-toggle-btn ${c?"generating":""}`,onClick:s,children:["🎖️",c&&o.jsx("span",{className:"supervisor-generating-indicator"})]})}),o.jsx(os,{content:f("common:floatingButtons.controls"),position:"left",children:o.jsx("button",{className:"shortcuts-toggle-btn",onClick:a,children:o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("line",{x1:"4",y1:"21",x2:"4",y2:"14"}),o.jsx("line",{x1:"4",y1:"10",x2:"4",y2:"3"}),o.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"12"}),o.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"3"}),o.jsx("line",{x1:"20",y1:"21",x2:"20",y2:"16"}),o.jsx("line",{x1:"20",y1:"12",x2:"20",y2:"3"}),o.jsx("line",{x1:"1",y1:"14",x2:"7",y2:"14"}),o.jsx("line",{x1:"9",y1:"8",x2:"15",y2:"8"}),o.jsx("line",{x1:"17",y1:"16",x2:"23",y2:"16"})]})})}),o.jsx(os,{content:f("common:floatingButtons.manageSkills"),position:"left",children:o.jsx("button",{className:"skills-toggle-btn",onClick:r,children:o.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:o.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"})})})}),o.jsx(os,{content:d.isSupported?d.isOpen?f("common:floatingButtons.closePip"):f("common:floatingButtons.openPip"):f("common:floatingButtons.pipNotSupported"),position:"left",disabled:!d.isSupported,children:o.jsx("button",{className:`pip-toggle-btn ${d.isOpen?"active":""}`,onClick:()=>d.isSupported&&d.toggle({width:320,height:400}),disabled:!d.isSupported,children:o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),o.jsx("rect",{x:"12",y:"9",width:"8",height:"6",rx:"1"})]})})})]})}),EW=Se.lazy(()=>vt(()=>import("./SpawnModal-DQ4uUm1y.js"),__vite__mapDeps([17,3,1,4])).then(t=>({default:t.SpawnModal}))),MW=Se.lazy(()=>vt(()=>import("./BossSpawnModal-DLJInoVf.js"),__vite__mapDeps([18,3,1,4])).then(t=>({default:t.BossSpawnModal}))),DW=Se.lazy(()=>vt(()=>import("./SubordinateAssignmentModal-BDUDt6WC.js"),__vite__mapDeps([19,3,1,4])).then(t=>({default:t.SubordinateAssignmentModal}))),RW=Se.lazy(()=>vt(()=>import("./index-BSl18-4e.js"),__vite__mapDeps([20,3,1,4,21])).then(t=>({default:t.Toolbox}))),OW=Se.lazy(()=>vt(()=>import("./index-mQmnkGdF.js"),__vite__mapDeps([22,3,1,4])).then(t=>({default:t.BuildingConfigModal}))),LW=Se.lazy(()=>vt(()=>import("./index-BwkNteiZ.js"),__vite__mapDeps([23,24,3,1,4])).then(t=>({default:t.CommanderView}))),IW=Se.lazy(()=>vt(()=>import("./SupervisorPanel-BZaBI9BA.js"),__vite__mapDeps([25,3,1,4])).then(t=>({default:t.SupervisorPanel}))),PW=Se.lazy(()=>vt(()=>import("./index-DJdXbeWz.js").then(t=>t.y),[]).then(t=>({default:t.FileExplorerPanel}))),BW=Se.lazy(()=>vt(()=>import("./index-Bxjd0N-j.js"),__vite__mapDeps([26,3,1,4])).then(t=>({default:t.Spotlight}))),FW=Se.lazy(()=>vt(()=>import("./ControlsModal-Cnnhwfr_.js"),__vite__mapDeps([27,3,1,4])).then(t=>({default:t.ControlsModal}))),zW=Se.lazy(()=>vt(()=>import("./SkillsPanel-D5wo2MHh.js"),__vite__mapDeps([28,3,1,4])).then(t=>({default:t.SkillsPanel}))),$W=Se.lazy(()=>vt(()=>Promise.resolve().then(()=>S2),void 0).then(t=>({default:t.AgentEditModal}))),UW=Se.lazy(()=>vt(()=>import("./SnapshotManager-BLjpctX_.js"),__vite__mapDeps([29,3,1,4])).then(t=>({default:t.SnapshotManager}))),HW=Se.lazy(()=>vt(()=>import("./RestoreArchivedAreaModal-C-X90Qxe.js"),__vite__mapDeps([30,3,1,4])).then(t=>({default:t.RestoreArchivedAreaModal}))),WW=Se.lazy(()=>vt(()=>import("./IntegrationsPanel-DLmIJEUy.js"),__vite__mapDeps([31,3,1,4])).then(t=>({default:t.IntegrationsPanel}))),qW=Se.lazy(()=>vt(()=>import("./MonitoringModal-PnEKvezF.js"),__vite__mapDeps([32,3,1,4])).then(t=>({default:t.MonitoringModal}))),VW=Se.lazy(()=>vt(()=>import("./WorkflowEditorPanel-D49yDqth.js"),__vite__mapDeps([33,3,1,4])).then(t=>({default:t.WorkflowEditorPanel}))),YW=Se.lazy(()=>vt(()=>import("./TriggerManagerPanel-DuBiclsE.js"),__vite__mapDeps([34,3,1,4])).then(t=>({default:t.TriggerManagerPanel})));function GW({spawnModal:t,bossSpawnModal:e,subordinateModal:n,toolboxModal:s,commanderModal:a,deleteConfirmModal:r,supervisorModal:i,spotlightModal:c,controlsModal:d,skillsModal:f,integrationsModal:h,monitoringModal:m,workflowEditorModal:b,triggerManagerModal:y,buildingModal:w,agentEditModal:C,snapshotsModal:N,restoreArchivedModal:k,explorerModal:j,contextMenu:S,spawnPosition:T,spawnAreaId:D,explorerFolderPath:E,contextMenuActions:I,buildingInitialPosition:O,sceneConfig:_,onConfigChange:M,onToolChange:R,onOpenAreaExplorer:z,onDeleteSelectedAgents:$,pendingBuildingDelete:W,onCancelBuildingDelete:L,onConfirmBuildingDelete:F,showBackNavModal:H,onCloseBackNavModal:V,onLeave:G,onOpenPM2LogsModal:B,onOpenBossLogsModal:K,onOpenDatabasePanel:se,onSyncScene:q}){const be=Rs(),Ce=Array.from(be.snapshots.values()),Z=be.snapshotsLoading;be.currentSnapshot,x.useEffect(()=>{N.isOpen&&U.fetchSnapshots()},[N.isOpen]);const ie=W==="selected",me=W&&W!=="selected"?be.buildings.get(W):null,Ee=be.selectedBuildingIds.size;return o.jsxs(x.Suspense,{fallback:null,children:[o.jsx(RW,{config:_,onConfigChange:M,onToolChange:R,isOpen:s.isOpen,onClose:s.close,onOpenBuildingModal:Te=>w.open(Te||null),onOpenAreaExplorer:z,onOpenIntegrationsModal:Te=>h.open(Te),onOpenMonitoringModal:()=>m.open(),onOpenWorkflowEditor:()=>b.open(),onOpenTriggerManager:()=>y.open()}),o.jsx(OW,{isOpen:w.isOpen,onClose:w.close,buildingId:w.data,initialPosition:O||void 0}),o.jsx(EW,{isOpen:t.isOpen,onClose:t.close,onSpawnStart:()=>{},onSpawnEnd:()=>{},spawnPosition:T,spawnAreaId:D}),o.jsx(MW,{isOpen:e.isOpen,onClose:e.close,onSpawnStart:()=>{},onSpawnEnd:()=>{},spawnPosition:T}),o.jsx(DW,{isOpen:n.isOpen,bossId:n.data||"",onClose:n.close}),C.isOpen&&C.data&&(()=>{const Te=be.agents.get(C.data);return Te?o.jsx($W,{agent:Te,isOpen:C.isOpen,onClose:C.close}):null})(),r.isOpen&&o.jsx("div",{className:"modal-overlay visible",onClick:r.close,onKeyDown:Te=>{Te.key==="Escape"&&r.close(),Te.key==="Enter"&&$()},children:o.jsxs("div",{className:"modal confirm-modal",onClick:Te=>Te.stopPropagation(),children:[o.jsx("div",{className:"modal-header",children:"Remove Agents"}),o.jsxs("div",{className:"modal-body confirm-modal-body",children:[o.jsxs("p",{children:["Remove ",be.selectedAgentIds.size," selected agent",be.selectedAgentIds.size>1?"s":""," from the battlefield?"]}),o.jsx("p",{className:"confirm-modal-note",children:"Claude Code sessions will continue running in the background."})]}),o.jsxs("div",{className:"modal-footer",children:[o.jsx("button",{className:"btn btn-secondary",onClick:r.close,children:"Cancel"}),o.jsx("button",{className:"btn btn-danger",onClick:$,autoFocus:!0,children:"Remove"})]})]})}),(me||ie)&&o.jsx("div",{className:"modal-overlay visible",onClick:L,onKeyDown:Te=>{Te.key==="Escape"&&L(),Te.key==="Enter"&&F()},children:o.jsxs("div",{className:"modal confirm-modal",onClick:Te=>Te.stopPropagation(),children:[o.jsxs("div",{className:"modal-header",children:["Delete Building",ie&&Ee>1?"s":""]}),o.jsxs("div",{className:"modal-body confirm-modal-body",children:[ie?o.jsxs("p",{children:["Delete ",Ee," selected building",Ee>1?"s":"","?"]}):o.jsxs("p",{children:["Delete ",o.jsx("strong",{children:me==null?void 0:me.name}),"?"]}),o.jsxs("p",{className:"confirm-modal-note",children:["This will permanently remove the building",ie&&Ee>1?"s":""," and ",ie&&Ee>1?"their":"its"," configuration."]})]}),o.jsxs("div",{className:"modal-footer",children:[o.jsx("button",{className:"btn btn-secondary",onClick:L,children:"Cancel"}),o.jsx("button",{className:"btn btn-danger",onClick:F,autoFocus:!0,children:"Delete"})]})]})}),H&&o.jsx("div",{className:"modal-overlay navigation-confirm-overlay visible",onClick:V,onKeyDown:Te=>{Te.key==="Escape"&&V()},children:o.jsxs("div",{className:"modal confirm-modal navigation-confirm-modal",onClick:Te=>Te.stopPropagation(),children:[o.jsx("div",{className:"modal-header",children:"Leave Tide Commander?"}),o.jsxs("div",{className:"modal-body confirm-modal-body",children:[o.jsx("p",{children:"Are you sure you want to leave this page?"}),o.jsx("p",{className:"confirm-modal-note",children:"Active Claude Code sessions will continue running in the background."})]}),o.jsxs("div",{className:"modal-footer",children:[o.jsx("button",{className:"btn btn-secondary",onClick:V,autoFocus:!0,children:"Stay"}),o.jsx("button",{className:"btn btn-danger",onClick:G,children:"Leave"})]})]})}),o.jsx(x.Profiler,{id:"CommanderView",onRender:yu,children:o.jsx(LW,{isOpen:a.isOpen,onClose:a.close})}),o.jsx(IW,{isOpen:i.isOpen,onClose:i.close}),o.jsx(PW,{isOpen:j.isOpen||E!==null||be.explorerAreaId!==null,areaId:j.id||be.explorerAreaId||null,folderPath:E,onChangeArea:Te=>j.open(Te),onClose:()=>{j.close(),U.closeFileExplorer()}}),o.jsx(BW,{isOpen:c.isOpen,onClose:c.close,onOpenSpawnModal:()=>t.open(),onOpenCommanderView:()=>a.open(),onOpenToolbox:()=>s.open(),onOpenSupervisor:()=>i.open(),onOpenFileExplorer:Te=>j.open(Te),onOpenPM2LogsModal:B,onOpenBossLogsModal:K,onOpenDatabasePanel:se,onOpenMonitoringModal:()=>m.open()}),o.jsx(FW,{isOpen:d.isOpen,onClose:d.close}),o.jsx(zW,{isOpen:f.isOpen,onClose:f.close}),o.jsx(WW,{isOpen:h.isOpen,onClose:h.close,initialTab:h.data}),o.jsx(qW,{isOpen:m.isOpen,onClose:m.close}),o.jsx(VW,{isOpen:b.isOpen,onClose:b.close}),o.jsx(YW,{isOpen:y.isOpen,onClose:y.close}),o.jsx(HW,{isOpen:k.isOpen,restorePosition:k.data??null,onClose:k.close,onRestored:q}),N.isOpen&&o.jsx("div",{className:"modal-overlay visible",onClick:N.close,children:o.jsx("div",{className:"modal snapshot-manager-modal",onClick:Te=>Te.stopPropagation(),children:o.jsx(UW,{snapshots:Ce,isLoading:Z,onViewSnapshot:async Te=>{await U.loadSnapshot(Te),be.selectedAgentIds.clear(),U.setTerminalOpen(!0),N.close()},onDeleteSnapshot:async Te=>{await U.deleteSnapshot(Te),await U.fetchSnapshots()},onRestoreSnapshot:async Te=>{await U.restoreFiles(Te)},onExportSnapshot:async Te=>{await U.loadSnapshot(Te),N.close()},onClose:N.close})})}),o.jsx(Do,{isOpen:S.isOpen,position:S.screenPosition,worldPosition:S.worldPosition,actions:I,onClose:S.close})]})}function KW({pip:t,title:e="Tide Commander",children:n}){return x.useEffect(()=>{t.pipWindow&&e&&(t.pipWindow.document.title=e)},[t.pipWindow,e]),!t.isOpen||!t.pipContainer?null:ac.createPortal(n,t.pipContainer)}function Ly(t){switch(t){case"working":return"⚡";case"waiting":return"⏳";case"waiting_permission":return"🔐";case"error":return"❌";case"offline":return"💤";case"orphaned":return"👻";case"idle":default:return"●"}}function Iy(t){switch(t){case"working":return"#4aff9e";case"waiting":return"#ff9e4a";case"waiting_permission":return"#ff4a9e";case"error":return"#ff4a4a";case"offline":return"#666";case"orphaned":return"#9e4aff";case"idle":default:return"#888"}}function Py(t){const e=_o[t.class];return(e==null?void 0:e.icon)||"🤖"}function Ob({agent:t,onClick:e}){const n=Iy(t.status),s=Ly(t.status),a=Py(t);return o.jsxs("div",{className:`pip-agent-card pip-status-${t.status}`,onClick:()=>e(t.id),title:"Click to view conversation",children:[o.jsxs("div",{className:"pip-agent-header",children:[o.jsx("span",{className:"pip-agent-icon",children:a}),o.jsx("span",{className:"pip-agent-name",children:t.name}),o.jsx("span",{className:"pip-agent-status",style:{color:n},children:s})]}),t.taskLabel&&o.jsxs("div",{className:"pip-agent-task",children:["📋 ",t.taskLabel]}),!t.taskLabel&&t.status==="working"&&t.currentTask&&o.jsx("div",{className:"pip-agent-task",children:t.currentTask.length>60?t.currentTask.slice(0,60)+"...":t.currentTask}),t.currentTool&&o.jsxs("div",{className:"pip-agent-tool",children:[o.jsx("span",{className:"pip-tool-label",children:"Tool:"})," ",t.currentTool]}),o.jsxs("div",{className:"pip-agent-context",children:[o.jsx("div",{className:"pip-context-bar",children:o.jsx("div",{className:"pip-context-fill",style:{width:`${Math.min(Math.round(t.contextUsed/t.contextLimit*100),100)}%`,backgroundColor:t.contextUsed/t.contextLimit*100>80?"#ff4a4a":t.contextUsed/t.contextLimit*100>50?"#ff9e4a":"#4aff9e"}})}),o.jsxs("span",{className:"pip-context-percent",children:[Math.round(t.contextUsed/t.contextLimit*100),"%"]})]})]})}function xu(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString()}const JA={systemPrompt:"#4a9eff",systemTools:"#9e4aff",messages:"#4aff9e",freeSpace:"rgba(255,255,255,0.1)",autocompactBuffer:"#ff9e4a"},ZA={systemPrompt:"System Prompt",systemTools:"System Tools",messages:"Messages",freeSpace:"Free Space",autocompactBuffer:"Autocompact Buffer"};function QW({agent:t,onBack:e}){const n=Py(t),s=Iy(t.status),a=t.contextStats,r=Math.round(t.contextUsed/t.contextLimit*100),i=t.contextUsed/t.contextLimit*100>80?"#ff4a4a":t.contextUsed/t.contextLimit*100>50?"#ff9e4a":"#4aff9e",c=["systemPrompt","systemTools","messages","autocompactBuffer","freeSpace"];return o.jsxs("div",{className:"pip-container pip-stats-container",children:[o.jsxs("div",{className:"pip-header pip-header-conversation",children:[o.jsx("button",{className:"pip-back-btn",onClick:e,title:"Back to conversation",children:"←"}),o.jsx("span",{className:"pip-agent-icon",children:n}),o.jsx("span",{className:"pip-title",children:t.name}),o.jsx("span",{className:"pip-agent-status-small",style:{color:s},children:Ly(t.status)})]}),o.jsx("div",{className:"pip-stats-content",children:a?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"pip-model-info",children:[o.jsxs("div",{className:"pip-model-info-item",children:[o.jsx("div",{className:"pip-model-info-label",children:"Model"}),o.jsx("div",{className:"pip-model-info-value",children:a.model})]}),o.jsxs("div",{className:"pip-model-info-item",children:[o.jsx("div",{className:"pip-model-info-label",children:"Window"}),o.jsx("div",{className:"pip-model-info-value",children:xu(a.contextWindow)})]})]}),o.jsxs("div",{className:"pip-stats-section",children:[o.jsxs("div",{className:"pip-usage-header",children:[o.jsx("span",{className:"pip-usage-label",children:"Context Usage"}),o.jsxs("span",{className:"pip-usage-value",style:{color:i},children:[xu(a.totalTokens)," / ",xu(a.contextWindow)," (",a.usedPercent,"%)"]})]}),o.jsx("div",{className:"pip-stacked-bar",children:c.map(d=>{const f=a.categories[d];return!f||f.percent<=0?null:o.jsx("div",{className:"pip-stacked-bar-segment",style:{width:`${f.percent}%`,backgroundColor:JA[d]},title:`${ZA[d]}: ${xu(f.tokens)}`},d)})})]}),o.jsxs("div",{className:"pip-stats-section",children:[o.jsx("h3",{className:"pip-stats-title",children:"Token Breakdown"}),o.jsx("div",{className:"pip-category-list",children:c.map(d=>{const f=a.categories[d];if(!f)return null;const h=d==="freeSpace";return o.jsxs("div",{className:`pip-category-item ${h?"free-space":""}`,children:[o.jsx("div",{className:"pip-category-color",style:{backgroundColor:JA[d]}}),o.jsxs("div",{className:"pip-category-info",children:[o.jsx("div",{className:"pip-category-name",children:ZA[d]}),o.jsxs("div",{className:"pip-category-tokens",children:[xu(f.tokens)," (",f.percent.toFixed(1),"%)"]})]})]},d)})})]}),o.jsxs("div",{className:"pip-stats-updated",children:["Updated: ",new Date(a.lastUpdated).toLocaleTimeString()]})]}):o.jsxs("div",{className:"pip-stats-section",children:[o.jsx("h3",{className:"pip-stats-title",children:"Context Usage"}),o.jsxs("div",{className:"pip-stats-bar-container",children:[o.jsx("div",{className:"pip-stats-bar",children:o.jsx("div",{className:"pip-stats-bar-fill",style:{width:`${Math.min(r,100)}%`,backgroundColor:i}})}),o.jsxs("span",{className:"pip-stats-percent",style:{color:i},children:[r,"%"]})]}),o.jsx("div",{className:"pip-stats-info",children:o.jsx("p",{className:"pip-stats-info-text",children:"Context usage represents how much of the conversation window is filled. Detailed breakdown not available yet."})})]})})]})}function XW({agentId:t,onBack:e}){const n=Qj(t),s=Xj(t),a=i1(),r=o1(),i=Hx(),c=x.useRef(null),d=x.useRef(null),[f,h]=x.useState(""),[m,b]=x.useState(!1),[y]=x.useState("simple"),w=!!(n!=null&&n.sessionId),C=qj({selectedAgentId:t,hasSessionId:w,reconnectCount:a,historyRefreshTrigger:r,lastPrompts:i,outputScrollRef:c}),N=ET({outputs:s,viewMode:y}),k=x.useMemo(()=>{const{history:$}=C,W=new Map;for(const F of $)F.type==="tool_result"&&F.toolUseId&&W.set(F.toolUseId,F.content);return(F=>F.map(H=>{if(H.type==="tool_use"&&H.toolName==="Bash"&&H.toolUseId){const V=W.get(H.toolUseId);let G;try{G=(H.toolInput||(H.content?JSON.parse(H.content):{})).command}catch{}return{...H,_bashOutput:V,_bashCommand:G}}return H}))($.filter(F=>F.type==="user"||F.type==="assistant"||F.type==="tool_use"))},[C.history]),[j,S]=x.useState({top:!1,bottom:!0}),T=x.useCallback(()=>{if(!c.current)return;const{scrollTop:$,scrollHeight:W,clientHeight:L}=c.current;S({top:$>20,bottom:$<W-L-20})},[]);x.useEffect(()=>{c.current&&(c.current.scrollTop=c.current.scrollHeight,T())},[s.length,k.length,T]);const D=x.useCallback(()=>{c.current&&c.current.scrollBy({top:-200,behavior:"smooth"})},[]),E=x.useCallback(()=>{c.current&&c.current.scrollBy({top:200,behavior:"smooth"})},[]),I=x.useCallback(()=>{const $=f.trim();!$||!n||(U.sendCommand(t,$),h(""),setTimeout(()=>{var W;return(W=d.current)==null?void 0:W.focus()},50))},[f,t,n]),O=x.useCallback($=>{h($.target.value)},[]),_=x.useCallback($=>{$.key==="Enter"&&!$.shiftKey&&($.preventDefault(),I())},[I]);x.useEffect(()=>{const $=setTimeout(()=>{var W;return(W=d.current)==null?void 0:W.focus()},100);return()=>clearTimeout($)},[t]);const M=x.useCallback(($,W)=>{const L=sh($,n==null?void 0:n.cwd),F=L.line?{...W||{},targetLine:L.line}:W;U.setFileViewerPath(L.path,F,n==null?void 0:n.cwd)},[n==null?void 0:n.cwd]);if(!n)return o.jsx("div",{className:"pip-container",children:o.jsxs("div",{className:"pip-header pip-header-conversation",children:[o.jsx("button",{className:"pip-back-btn",onClick:e,title:"Back to agents list",children:"←"}),o.jsx("span",{className:"pip-title",children:"Agent not found"})]})});const R=Py(n),z=Iy(n.status);return m?o.jsx(QW,{agent:n,onBack:()=>b(!1)}):o.jsxs("div",{className:"pip-container pip-conversation-container",children:[o.jsxs("div",{className:"pip-header pip-header-conversation",children:[o.jsx("button",{className:"pip-back-btn",onClick:e,title:"Back to agents list",children:"←"}),o.jsx("span",{className:"pip-agent-icon",children:R}),o.jsx("span",{className:"pip-title",children:n.name}),o.jsx("span",{className:"pip-agent-status-small",style:{color:z},children:Ly(n.status)})]}),o.jsx("div",{className:"pip-context-section",children:o.jsx(v1,{contextInfo:Xp(n),onClick:()=>b(!0)})}),o.jsxs("div",{className:"pip-conversation-wrapper",children:[o.jsxs("div",{className:"pip-conversation guake-output",ref:c,onScroll:T,children:[!C.loadingHistory&&C.hasMore&&o.jsx("div",{className:"guake-load-more pip-load-more",children:C.loadingMore?o.jsx("span",{children:"Loading older messages..."}):o.jsxs("button",{onClick:C.loadMoreHistory,children:["Load more (",C.totalCount-C.history.length," older)"]})}),C.loadingHistory&&o.jsx("div",{className:"pip-loading-indicator",children:o.jsxs("span",{className:"loading-dots",children:[o.jsx("span",{children:"."}),o.jsx("span",{children:"."}),o.jsx("span",{children:"."})]})}),k.map(($,W)=>o.jsx(XT,{message:$,agentId:t,simpleView:!0,onFileClick:M},`h-${W}`)),N.map(($,W)=>o.jsx(Ry,{output:$,agentId:t,onFileClick:M},`o-${W}`)),!C.loadingHistory&&k.length===0&&N.length===0&&n.status!=="working"&&o.jsx("div",{className:"pip-empty",children:o.jsx("p",{children:"No conversation yet"})})]}),o.jsxs("div",{className:"pip-scroll-controls",children:[j.top&&o.jsx("button",{className:"pip-scroll-btn pip-scroll-up",onClick:D,title:"Scroll up",children:"↑"}),j.bottom&&o.jsx("button",{className:"pip-scroll-btn pip-scroll-down",onClick:E,title:"Scroll down",children:"↓"})]})]}),n.currentTool&&o.jsx("div",{className:"pip-current-tool",children:o.jsxs("span",{className:"pip-tool-indicator",children:["Using: ",n.currentTool]})}),o.jsxs("div",{className:"pip-input-area",children:[o.jsx("input",{ref:d,type:"text",className:"pip-input",placeholder:`Message ${n.name}...`,value:f,onChange:O,onKeyDown:_,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}),o.jsx("button",{className:"pip-send-btn",onClick:I,disabled:!f.trim(),title:"Send message",children:"➤"})]})]})}function JW({onSelectAgent:t}){const e=Kp(),n=e.filter(c=>c.status==="working"),s=e.filter(c=>c.status==="waiting"||c.status==="waiting_permission"),a=e.filter(c=>c.status!=="working"&&c.status!=="waiting"&&c.status!=="waiting_permission"),r=e.length,i=n.length+s.length;return o.jsxs("div",{className:"pip-container",children:[o.jsxs("div",{className:"pip-header",children:[o.jsx("span",{className:"pip-title",children:"Tide Commander"}),o.jsxs("span",{className:"pip-stats",children:[i,"/",r," active"]})]}),o.jsxs("div",{className:"pip-agents-list",children:[n.length>0&&o.jsxs("div",{className:"pip-section",children:[o.jsxs("div",{className:"pip-section-title",children:["Working (",n.length,")"]}),n.map(c=>o.jsx(Ob,{agent:c,onClick:t},c.id))]}),s.length>0&&o.jsxs("div",{className:"pip-section",children:[o.jsxs("div",{className:"pip-section-title",children:["Waiting (",s.length,")"]}),s.map(c=>o.jsx(Ob,{agent:c,onClick:t},c.id))]}),a.length>0&&o.jsxs("div",{className:"pip-section",children:[o.jsxs("div",{className:"pip-section-title",children:["Idle (",a.length,")"]}),a.map(c=>o.jsx(Ob,{agent:c,onClick:t},c.id))]}),e.length===0&&o.jsx("div",{className:"pip-empty",children:o.jsx("p",{children:"No agents spawned yet"})})]})]})}function ZW(){const[t,e]=x.useState(null),n=a=>{e(a)},s=()=>{e(null)};return t?o.jsx(XW,{agentId:t,onBack:s}):o.jsx(JW,{onSelectAgent:n})}function eq(t){const e=t.trim();if(!e)return{ok:!0,normalizedUrl:""};let n;try{n=new URL(e)}catch{return{ok:!1,normalizedUrl:"",error:"Invalid URL format. Use http://host:port"}}return n.protocol!=="http:"&&n.protocol!=="https:"?{ok:!1,normalizedUrl:"",error:"Unsupported protocol. Use http or https"}:{ok:!0,normalizedUrl:e}}async function tq(t,e=5e3,n=fetch){if(!t)return{ok:!0};const a=`${t.replace(/\/$/,"")}/api/health`,r=new AbortController,i=setTimeout(()=>r.abort(),e);try{const c=await n(a,{method:"GET",cache:"no-store",signal:r.signal});return c.ok?{ok:!0}:{ok:!1,error:`Host reachable but unhealthy (${c.status})`}}catch(c){return c instanceof Error&&c.name==="AbortError"?{ok:!1,error:"Connection timed out while checking host"}:{ok:!1,error:"Host unreachable. Check URL, host, and port"}}finally{clearTimeout(i)}}const nq=4e3;function sq(){const t=Zj(),[e,n]=x.useState(!1),[s,a]=x.useState(!1),[r,i]=x.useState(!0),[c,d]=x.useState(()=>Ox()),[f,h]=x.useState(!1),[m,b]=x.useState(null),[y,w]=x.useState(null),C=x.useRef(!0),N=x.useCallback((D=7e3)=>U.getState().isConnected?Promise.resolve(!0):new Promise(E=>{let I=!1;const O=R=>{I||(I=!0,clearTimeout(M),_(),E(R))},_=U.subscribe(()=>{U.getState().isConnected&&O(!0)}),M=setTimeout(()=>O(!1),D)}),[]);x.useEffect(()=>{const D=setTimeout(()=>i(!1),3e3);return()=>clearTimeout(D)},[]),x.useEffect(()=>()=>{C.current=!1},[]),x.useEffect(()=>YD(D=>{d(D)}),[]);const k=x.useCallback(()=>{navigator.clipboard.writeText("bunx tide-commander").then(()=>{a(!0),setTimeout(()=>a(!1),2e3)}).catch(()=>{})},[]),j=x.useCallback(async()=>{if(f)return;const D=Date.now(),E=()=>nq-(Date.now()-D);b(null),w("Validating URL");const I=c.trim()||"http://localhost:6200",O=eq(I);if(!O.ok){w(null),b(O.error||"Invalid backend URL");return}h(!0),w("Checking host reachability");const _=E();if(_<=0){h(!1),w(null),b("Connection timeout after 4 seconds");return}const M=await tq(O.normalizedUrl,_);if(!M.ok){if(!C.current)return;h(!1),w(null),E()<=0?b("Connection timeout after 4 seconds"):b(M.error||"Failed to reach host");return}VD(O.normalizedUrl),w("Connecting to server"),$R();const R=E();if(R<=0){h(!1),w(null),b("Connection timeout after 4 seconds");return}const z=await N(R);if(C.current){if(!z){h(!1),w(null),E()<=0?b("Connection timeout after 4 seconds"):b("Could not establish WebSocket connection. Verify host and auth token, then retry");return}h(!1),w("Connected"),b(null)}},[c,f,N]),S=x.useCallback(D=>{D.key==="Enter"&&!f&&j()},[j,f]),T=x.useCallback(()=>{n(!0)},[]);return t||e||r?null:o.jsx("div",{className:"not-connected-overlay",children:o.jsxs("div",{className:"not-connected-panel",children:[o.jsx("h2",{className:"not-connected-title",children:"Tide Commander"}),o.jsx("p",{className:"not-connected-description",children:"A visual multi-agent orchestrator for Claude Code and Codex. Deploy, control, and monitor your AI team from an RTS-inspired interface."}),o.jsx("p",{className:"not-connected-privacy",children:"Tide Commander syncs with Claude Code instances running on your local machine. No files or code are sent to this server."}),o.jsxs("div",{className:"not-connected-setup",children:[o.jsx("p",{className:"not-connected-setup-label",children:"Get started:"}),o.jsxs("div",{className:"not-connected-code",onClick:k,title:"Click to copy",children:[o.jsx("span",{children:"bunx tide-commander"}),o.jsx("span",{className:"not-connected-copy-icon",children:s?"✓":"⧉"})]})]}),o.jsxs("div",{className:"not-connected-url-section",children:[o.jsx("label",{className:"not-connected-url-label",htmlFor:"backend-url",children:"Backend URL"}),o.jsx("div",{className:"not-connected-url-row",children:o.jsx("input",{id:"backend-url",type:"text",className:"not-connected-url-input",placeholder:"http://localhost:6200",value:c,disabled:f,onChange:D=>{const E=D.target.value;d(E),m&&b(null)},onKeyDown:S})}),o.jsx("span",{className:"config-hint",children:"Leave empty for auto-detect"}),y&&!m&&o.jsx("div",{className:"not-connected-status","aria-live":"polite",children:y}),m&&o.jsx("div",{className:"not-connected-error","aria-live":"assertive",children:m})]}),o.jsxs("div",{className:"not-connected-actions",children:[o.jsx("button",{className:"not-connected-btn not-connected-btn-retry",onClick:()=>{j()},disabled:f,children:f?"Connecting...":"↻ Connect"}),o.jsx("button",{className:"not-connected-btn not-connected-btn-explore",onClick:T,children:"Explore"})]})]})})}const ej="tide-onboarding-dismissed";function aq({onCreateAgent:t}){const{t:e}=dt("common"),n=Zj(),s=Kj(),[a,r]=x.useState(()=>sessionStorage.getItem(ej)==="1"),i=n&&!a&&s===0,c=x.useCallback(()=>{r(!0),sessionStorage.setItem(ej,"1")},[]),d=x.useCallback(()=>{c(),t()},[c,t]),f=x.useCallback(h=>{h.key==="Escape"&&c()},[c]);return i?o.jsx(pr,{children:o.jsx("div",{className:"modal-overlay visible",onClick:c,onKeyDown:f,children:o.jsxs("div",{className:"modal onboarding-modal",onClick:h=>h.stopPropagation(),children:[o.jsxs("div",{className:"onboarding-header",children:[o.jsx("h2",{children:e("onboarding.title")}),o.jsx("p",{className:"onboarding-subtitle",children:e("onboarding.subtitle")})]}),o.jsxs("div",{className:"onboarding-steps",children:[o.jsxs("div",{className:"onboarding-step",children:[o.jsx("span",{className:"onboarding-step-number",children:"1"}),o.jsxs("div",{children:[o.jsx("strong",{children:e("onboarding.step1Title")}),o.jsx("p",{children:e("onboarding.step1Desc")})]})]}),o.jsxs("div",{className:"onboarding-step",children:[o.jsx("span",{className:"onboarding-step-number",children:"2"}),o.jsxs("div",{children:[o.jsx("strong",{children:e("onboarding.step2Title")}),o.jsx("p",{children:e("onboarding.step2Desc")})]})]}),o.jsxs("div",{className:"onboarding-step",children:[o.jsx("span",{className:"onboarding-step-number",children:"3"}),o.jsxs("div",{children:[o.jsx("strong",{children:e("onboarding.step3Title")}),o.jsx("p",{children:e("onboarding.step3Desc")})]})]})]}),o.jsxs("div",{className:"onboarding-actions",children:[o.jsx("button",{className:"btn onboarding-cta",onClick:d,autoFocus:!0,children:e("onboarding.createFirst")}),o.jsx("button",{className:"btn btn-secondary",onClick:c,children:e("onboarding.explore")})]})]})})}):null}function e_(){return{"Content-Type":"application/json","X-Auth-Token":Ii()}}async function rq(t){const e=await fetch(`${Ea()}/api/areas/${t}/organize`,{method:"POST",headers:e_()});if(!e.ok)throw new Error(`Failed to organize area: ${e.statusText}`);const n=await e.json();return{organized:Array.isArray(n.organized)?n.organized:[],buildings:Array.isArray(n.buildings)?n.buildings:[]}}async function iq(){const t=await fetch(`${Ea()}/api/areas/organize-all`,{method:"POST",headers:e_()});if(!t.ok)throw new Error(`Failed to organize all areas: ${t.statusText}`);const e=await t.json();return Array.isArray(e.organized)?{organized:e.organized,buildings:Array.isArray(e.buildings)?e.buildings:[]}:(Array.isArray(e.results)?e.results:[]).reduce((n,s)=>(n.organized.push(...s.organized),n.buildings.push(...s.buildings),n),{organized:[],buildings:[]})}function t_(t,e){var s,a;const n=U.getState();for(const r of t.organized){const i=n.agents.get(r.agentId);if(i){const c={...i,position:r.position};U.updateAgent(c),(s=e.current)==null||s.updateAgent(c,!0)}}for(const r of t.buildings){const i=n.buildings.get(r.buildingId);i&&(U.updateBuilding(r.buildingId,{position:r.position}),(a=e.current)==null||a.updateBuilding({...i,position:r.position}))}}function oq(t,e,n,s,a,r){const i=[];if(e.type==="agent"&&e.id){const d=n.get(e.id);if(d)return i.push({id:"select-agent",label:`Select ${d.name}`,icon:"👆",onClick:()=>{var f;U.selectAgent(e.id),(f=r.sceneRef.current)==null||f.refreshSelectionVisuals()}}),i.push({id:"focus-agent",label:"Focus Camera",icon:"🎯",onClick:()=>{var f;(f=r.sceneRef.current)==null||f.focusAgent(e.id)}}),i.push({id:"open-terminal",label:"Open Terminal",icon:"💬",onClick:()=>{U.selectAgent(e.id),U.setTerminalOpen(!0)}}),i.push({id:"edit-agent",label:"Edit Agent",icon:"✏️",onClick:()=>{r.openAgentEditModal(e.id)}}),i.push({id:"divider-agent",label:"",divider:!0,onClick:()=>{}}),i.push({id:"delete-agent",label:`Remove ${d.name}`,icon:"❌",danger:!0,onClick:()=>{var f;U.removeAgentFromServer(e.id),(f=r.sceneRef.current)==null||f.removeAgent(e.id),r.showToast("info","Agent Removed",`${d.name} removed from view`)}}),i}if(e.type==="area"&&e.id){const d=s.get(e.id);if(d)return i.push({id:"select-area",label:`Select "${d.name}"`,icon:"📐",onClick:()=>{U.selectArea(e.id),r.openToolboxModal()}}),d.directories&&d.directories.length>0&&i.push({id:"open-explorer",label:"Open File Explorer",icon:"📁",onClick:()=>{r.openExplorerModal(e.id)}}),i.push({id:"spawn-in-area",label:"Spawn Agent",icon:"🤖",onClick:()=>{window.dispatchEvent(new CustomEvent("tide:open-spawn-modal",{detail:{areaId:e.id,position:{x:d.center.x,z:d.center.z}}}))}}),i.push({id:"divider-area-layer",label:"",divider:!0,onClick:()=>{}}),i.push({id:"bring-to-front",label:"Bring to Front",icon:"⬆️",onClick:()=>{var f;U.bringAreaToFront(e.id),(f=r.sceneRef.current)==null||f.syncAreas()}}),i.push({id:"send-to-back",label:"Send to Back",icon:"⬇️",onClick:()=>{var f;U.sendAreaToBack(e.id),(f=r.sceneRef.current)==null||f.syncAreas()}}),d.assignedAgentIds.length>0&&i.push({id:"organize-area",label:"Organize Area",icon:"✨",onClick:()=>{rq(e.id).then(f=>{t_(f,r.sceneRef),r.showToast("success","Area Organized",`Arranged ${f.organized.length} agent${f.organized.length!==1?"s":""} in "${d.name}"`)}).catch(f=>{console.error("organize area error:",f),r.showToast("error","Organize Failed",f.message||"Failed to organize area")})}}),i.push({id:"divider-area",label:"",divider:!0,onClick:()=>{}}),i.push({id:"archive-area",label:`Archive "${d.name}"`,icon:"📦",onClick:()=>{var m,b;const f=d.assignedAgentIds.length;U.archiveArea(e.id,y=>U.stopAgent(y)),(m=r.sceneRef.current)==null||m.syncAreas(),(b=r.sceneRef.current)==null||b.syncAgents(Array.from(U.getState().agents.values()));const h=f>0?` (${f} agent${f>1?"s":""} stopped)`:"";r.showToast("info","Zone Archived",`"${d.name}" has been archived${h}`)}}),i.push({id:"delete-area",label:`Delete "${d.name}"`,icon:"🗑️",danger:!0,onClick:()=>{var f;U.deleteArea(e.id),(f=r.sceneRef.current)==null||f.syncAreas(),r.showToast("info","Area Deleted",`"${d.name}" has been deleted`)}}),i}if(e.type==="building"&&e.id){const d=a.get(e.id);if(d)return i.push({id:"select-building",label:`Select "${d.name}"`,icon:"🏢",onClick:()=>{U.selectBuilding(e.id),r.openToolboxModal()}}),i.push({id:"edit-building",label:"Edit Building",icon:"✏️",onClick:()=>{r.openBuildingModal(e.id)}}),i.push({id:"clone-building",label:"Clone Building",icon:"📋",onClick:()=>{const f={name:`${d.name} (Copy)`,type:d.type,style:d.style,color:d.color,scale:d.scale,position:{x:d.position.x+2,z:d.position.z+2},cwd:d.cwd,folderPath:d.folderPath,commands:d.commands,pm2:d.pm2,docker:d.docker,database:d.database,urls:d.urls,subordinateBuildingIds:d.subordinateBuildingIds};U.createBuilding(f),r.showToast("success","Building Cloned",`Created "${f.name}"`)}}),d.type==="folder"&&d.folderPath&&i.push({id:"open-folder",label:"Open Folder",icon:"📁",onClick:()=>{U.openFileExplorer(d.folderPath)}}),i.push({id:"divider-building",label:"",divider:!0,onClick:()=>{}}),i.push({id:"delete-building",label:`Delete "${d.name}"`,icon:"🗑️",danger:!0,onClick:()=>{r.requestBuildingDelete(e.id)}}),i}i.push({id:"spawn-agent",label:"Spawn Agent Here",icon:"🤖",shortcut:"N",onClick:()=>{r.setSpawnPosition(t),r.openSpawnModal()}}),i.push({id:"spawn-boss",label:"Spawn Boss Here",icon:"👑",onClick:()=>{r.setSpawnPosition(t),r.openBossSpawnModal()}}),i.push({id:"divider-1",label:"",divider:!0,onClick:()=>{}}),i.push({id:"draw-area",label:"Draw Area",icon:"📐",onClick:()=>{var d;(d=r.sceneRef.current)==null||d.setDrawingTool("rectangle"),typeof window<"u"&&window.__tideScene2D_setDrawingTool&&window.__tideScene2D_setDrawingTool("rectangle"),r.showToast("info","Rectangle Tool","Click and drag on the battlefield to draw an area")}}),i.push({id:"new-building",label:"Place Building",icon:"🏢",onClick:()=>{r.openBuildingModal(null)}});const c=Array.from(s.values()).filter(d=>d.archived).length;return c>0&&i.push({id:"restore-archived",label:`Restore Archived Zone (${c})`,icon:"📦",onClick:()=>{r.openRestoreArchivedModal(t)}}),i.push({id:"divider-2",label:"",divider:!0,onClick:()=>{}}),i.push({id:"open-settings",label:"Settings",icon:"⚙️",onClick:()=>{r.openToolboxModal()}}),i.push({id:"open-commander",label:"Commander View",icon:"📊",shortcut:"⌘K",onClick:()=>{r.openCommanderModal()}}),i}const lq=Se.lazy(()=>vt(()=>import("./index-DZ3f9mNd.js"),__vite__mapDeps([35,3,1,4,36])).then(t=>({default:t.DatabasePanel}))),cq=Se.lazy(()=>vt(()=>import("./PM2LogsModal-EB_Au0iK.js"),__vite__mapDeps([37,38,3,1,4])).then(t=>({default:t.PM2LogsModal}))),uq=Se.lazy(()=>vt(()=>import("./DockerLogsModal-D4CbWK3-.js"),__vite__mapDeps([39,38,3,1,4])).then(t=>({default:t.DockerLogsModal}))),dq=Se.lazy(()=>vt(()=>import("./BossLogsModal-CaDrNfm1.js"),__vite__mapDeps([40,38,3,1,4])).then(t=>({default:t.BossLogsModal}))),fq=Se.lazy(()=>vt(()=>import("./Scene2DCanvas-DlVguRVM.js"),__vite__mapDeps([41,3,1,4,42])).then(t=>({default:t.Scene2DCanvas}))),pq=Se.lazy(()=>vt(()=>import("./index-BiGvhrCO.js"),__vite__mapDeps([43,3,1,4,44])).then(t=>({default:t.DashboardView}))),hq=Se.lazy(()=>vt(()=>import("./IframeModal-BJ4oeDBn.js"),__vite__mapDeps([45,3,1,4,46])).then(t=>({default:t.IframeModal}))),mq=Se.lazy(()=>vt(()=>import("./SaveSnapshotModal-D6XAjL2T.js"),__vite__mapDeps([47,3,1,4])).then(t=>({default:t.SaveSnapshotModal})));function gq(){const{t}=dt(["common","notifications"]),e=x.useRef(null),n=x.useRef(null),s=cs(),a=cs(),r=cs(),i=cs(),c=cs(),d=cs(),f=cs(),h=cs(),m=cs(),b=cs(),y=cs(),w=cs(),C=cs(),N=cs(),k=cs(),j=cs(),S=cs(),T=cs(),D=cs(),E=GD(),I=ZO(),O=KD(),_=iR(),[M,R]=x.useState(null),z=QR(),[$,W]=x.useState(!1),[L,F]=x.useState(null),[H,V]=x.useState(null),[G,B]=x.useState(null),[K,se]=x.useState(null),[q,be]=x.useState(null),[Ce,Z]=x.useState(null),[ie,me]=x.useState(null),[Ee,Te]=x.useState(null),[Ve,We]=x.useState(null),[ee,ne]=x.useState(null),Ne=x.useCallback(je=>{ne(je),je&&localStorage.setItem("tide-commander-last-database-building",je)},[]),ze=x.useCallback(()=>Ne(null),[Ne]),{handleMouseDown:st,handleClick:pe}=Ta(ze),Be=x.useCallback(()=>We(null),[]),{handleMouseDown:oe,handleClick:de}=Ta(Be),He=x.useRef(Ce);He.current=Ce;const et=x.useCallback(je=>{Z(je)},[]),ct=x.useCallback(()=>He.current,[]),fe=x.useRef(null),[X,ae]=x.useState(Uj),[ke,J]=x.useState(0),[he,Oe]=x.useState(!1),[$e,xe]=x.useState(()=>localStorage.getItem("tide-commander-sidebar-collapsed")==="true"),[Pe,te]=x.useState(!1),[ge,ve]=x.useState(!1),Fe=n1(),Ke=l1(),at=qx(),ft=Vx(),wt=t1(),{showToast:it}=d1(),{showAgentNotification:gt}=jL(),{showBackNavModal:ht,setShowBackNavModal:Gt,handleLeave:tn}=hO();oO({showToast:it,showAgentNotification:gt});const[Ae,Le]=x.useState(!1);x.useEffect(()=>{const je=Je=>{var ot;((ot=Je.detail)==null?void 0:ot.mode)==="3d"&&Le(!0)};return window.addEventListener("tide:viewmode-switch-pressed",je),()=>{window.removeEventListener("tide:viewmode-switch-pressed",je)}},[]),x.useEffect(()=>{Ke==="3d"&&Le(!0)},[Ke]);const Ye=iO({canvasRef:e,selectionBoxRef:n,viewMode:Ke,sceneMountKey:ke,showToast:it,showAgentNotification:gt,toolboxModal:i,contextMenu:O,setHoveredAgentPopup:be,setBuildingPopup:et,getBuildingPopup:ct,openBuildingModal:je=>k.open(je),openPM2LogsModal:je=>me(je),openBossLogsModal:je=>Te(je),openDatabasePanel:je=>Ne(je),onSceneLoadingChange:Le}),Ze=Kj(),Ot=ur(),Ft=Wx(),Lt=Ux(),Vt=YO(),ln=VO(),bt=qO(),rt=Vr(),xt=KO(),$t=uL(),En=dL(),nn=x.useMemo(()=>Array.from(Lt),[Lt]),Un=x.useRef(!1);Dj("AppContent"),lO(Ye),cO(Ye),uO(Ye),bO(),dO(Ye,ln),fO(Ye,rt.powerSaving),x.useEffect(()=>{var je;document.title=((je=rt.tabTitle)==null?void 0:je.trim())||"Tide Commander"},[rt.tabTitle]),x.useEffect(()=>{var Dn,Fs;if(Un.current||typeof window>"u")return;const je=new URLSearchParams(window.location.search),Je=(Dn=je.get("agentId"))==null?void 0:Dn.trim(),Ct=(Fs=je.get("agentName"))==null?void 0:Fs.trim();if(!Je&&!Ct||Ze===0)return;const ot=U.getState().agents,jn=je.get("openTerminal"),Mt=jn?["1","true","yes"].includes(jn.toLowerCase()):!0;let At=Je?ot.get(Je):void 0;if(!At&&Ct){const Qr=Ct.toLowerCase();At=Array.from(ot.values()).find(pa=>pa.name.toLowerCase()===Qr)}if(!At){console.warn("[DeepLink] No matching agent found for query params",{rawAgentId:Je,rawAgentName:Ct}),Un.current=!0;return}U.selectAgent(At.id),Mt&&U.setTerminalOpen(!0),je.delete("agentId"),je.delete("agentName"),je.delete("openTerminal");const kn=je.toString(),ms=`${window.location.pathname}${kn?`?${kn}`:""}${window.location.hash}`;window.history.replaceState({},document.title,ms),Un.current=!0},[Ze]),pO({sceneRef:Ye,spawnModal:s,commanderModal:c,explorerModal:E,spotlightModal:h,deleteConfirmModal:d,onRequestBuildingDelete:()=>se("selected"),onOpenDatabasePanel:Ne,onCloseDatabasePanel:ze,databasePanelOpen:ee!==null}),Xt("spawn-modal",s.isOpen,s.close),Xt("boss-spawn-modal",a.isOpen,a.close),Xt("subordinate-modal",r.isOpen,r.close),Xt("toolbox-modal",i.isOpen,i.close),Xt("commander-modal",c.isOpen,c.close),Xt("delete-confirm-modal",d.isOpen,d.close),Xt("supervisor-modal",f.isOpen,f.close),Xt("spotlight-modal",h.isOpen,h.close),Xt("controls-modal",m.isOpen,m.close),Xt("skills-modal",b.isOpen,b.close),Xt("integrations-modal",y.isOpen,y.close),Xt("monitoring-modal",w.isOpen,w.close),Xt("workflow-editor-modal",C.isOpen,C.close),Xt("trigger-manager-modal",N.isOpen,N.close),Xt("building-modal",k.isOpen,k.close),Xt("agent-edit-modal",j.isOpen,j.close),Xt("snapshots-modal",S.isOpen,S.close),Xt("save-snapshot-modal",T.isOpen,T.close),Xt("explorer-modal",E.isOpen||I!==null,()=>{E.close(),U.closeFileExplorer()}),Xt("context-menu",O.isOpen,O.close),Xt("mobile-sidebar",he,()=>Oe(!1)),Xt("mobile-fab-menu",ge,()=>ve(!1)),Xt("file-viewer",at!==null,()=>U.clearFileViewerPath()),Xt("context-modal",ft!==null,()=>U.closeContextModal()),Xt("terminal",wt,()=>U.setTerminalOpen(!1)),Xt("pm2-logs-modal",ie!==null,()=>me(null)),Xt("boss-logs-modal",Ee!==null,()=>Te(null)),Xt("database-panel",ee!==null,ze),Xt("terminal-modal",Ve!==null,Be);const Os=x.useRef(wt),ps=x.useRef(b),ks=x.useRef(m);ps.current=b,ks.current=m,x.useEffect(()=>{Os.current&&!wt&&(ps.current.close(),ks.current.close()),Os.current=wt},[wt]),x.useEffect(()=>{},[]),x.useEffect(()=>{if(Fe!=="3d"||Ke!=="3d")return;const je=setTimeout(()=>window.dispatchEvent(new Event("resize")),80);return()=>clearTimeout(je)},[Fe,Ke]);const Qn=x.useCallback(je=>{var Je,Ct,ot,jn,Mt,At,kn,ms,Dn,Fs;ae(je),aO(je),(Je=Ye.current)==null||Je.setCharacterScale(je.characterScale),(Ct=Ye.current)==null||Ct.setScale3D(je.scale3d),(ot=Ye.current)==null||ot.setTimeMode(je.timeMode),(jn=Ye.current)==null||jn.setTerrainConfig(je.terrain),(Mt=Ye.current)==null||Mt.setFloorStyle(je.terrain.floorStyle),(At=Ye.current)==null||At.setGridVisible(je.gridVisible),(kn=Ye.current)==null||kn.setAgentModelStyle(je.modelStyle),(ms=Ye.current)==null||ms.setIdleAnimation(je.animations.idleAnimation),(Dn=Ye.current)==null||Dn.setWorkingAnimation(je.animations.workingAnimation),(Fs=Ye.current)==null||Fs.setFpsLimit(je.fpsLimit)},[Ye]),Ss=x.useCallback(je=>{var Je;if((Je=Ye.current)==null||Je.setDrawingTool(je),typeof window<"u"&&window.__tideScene2D_setDrawingTool&&window.__tideScene2D_setDrawingTool(je),je==="rectangle"||je==="circle"){const Ct=t(je==="rectangle"?"notifications:drawing.rectangleTool":"notifications:drawing.circleTool");it("info",Ct,t("notifications:drawing.clickAndDrag"),3e3)}},[Ye,it]),Fn=x.useCallback(je=>{var Je;(Je=Ye.current)==null||Je.focusAgent(je)},[Ye]),Ls=x.useCallback(je=>{U.killAgent(je)},[]),Is=x.useCallback(je=>{var Je;(Je=Ye.current)==null||Je.callSubordinates(je)},[Ye]),wn=x.useCallback(je=>{E.open(je)},[E]),Po=x.useCallback(()=>{k.open(null)},[k]),Bo=x.useCallback(()=>{var je;(je=Ye.current)==null||je.setDrawingTool("rectangle"),typeof window<"u"&&window.__tideScene2D_setDrawingTool&&window.__tideScene2D_setDrawingTool("rectangle"),it("info",t("notifications:drawing.rectangleTool"),t("notifications:drawing.clickAndDrag"),3e3)},[Ye,it]),Ps=x.useCallback(je=>{R(je)},[]),Ua=x.useCallback(()=>{R(null)},[]),Bi=x.useCallback(()=>{const je=Array.from(U.getState().selectedAgentIds);je.forEach(Je=>{var Ct;U.removeAgentFromServer(Je),(Ct=Ye.current)==null||Ct.removeAgent(Je)}),d.close(),it("info",t("notifications:toast.agentsRemoved"),t("notifications:toast.agentsRemovedMsg",{count:je.length}))},[it,d,Ye,t]),Fi=x.useCallback(()=>{var je,Je;if(K==="selected"){const Ct=Vt.size;U.deleteSelectedBuildings(),(je=Ye.current)==null||je.syncBuildings(),it("info",t("notifications:toast.buildingsDeleted"),t("notifications:toast.buildingsDeletedMsg",{count:Ct}))}else if(K){const Ct=Ft.get(K);U.deleteBuilding(K),(Je=Ye.current)==null||Je.syncBuildings(),it("info",t("notifications:toast.buildingDeleted"),t("notifications:toast.buildingDeletedMsg",{name:(Ct==null?void 0:Ct.name)||"Building"}))}se(null)},[K,Ft,Vt.size,it,Ye,t]),Bs=x.useMemo(()=>oq(O.worldPosition,O.target,U.getState().agents,Ot,Ft,{showToast:it,openSpawnModal:()=>s.open(),openBossSpawnModal:()=>a.open(),openToolboxModal:()=>i.open(),openCommanderModal:()=>c.open(),openExplorerModal:je=>E.open(je),openBuildingModal:je=>k.open(je),openAgentEditModal:je=>j.open(je),requestBuildingDelete:je=>se(je),setSpawnPosition:F,openRestoreArchivedModal:je=>D.open(je),sceneRef:Ye}),[O.worldPosition,O.target,Ot,Ft,s,a,k,i,c,E,j,D,it,Ye]);x.useEffect(()=>{!s.isOpen&&!a.isOpen&&(F(null),B(null))},[s.isOpen,a.isOpen]),x.useEffect(()=>{const je=Mt=>{const At=Mt.detail;B((At==null?void 0:At.areaId)||null),F((At==null?void 0:At.position)||null),s.open()},Je=Mt=>{var ms,Dn;const At=Mt.detail;if(!(At!=null&&At.buildingId))return;const kn=U.getState().buildings.get(At.buildingId);kn&&(kn.type==="server"&&((ms=kn.pm2)!=null&&ms.enabled)?me(At.buildingId):kn.type==="boss"?Te(At.buildingId):kn.type==="database"?Ne(At.buildingId):kn.type==="folder"&&kn.folderPath?U.openFileExplorer(kn.folderPath):kn.type==="terminal"&&((Dn=kn.terminalStatus)!=null&&Dn.url)?We(At.buildingId):k.open(At.buildingId))},Ct=Mt=>{const At=Mt.detail;At!=null&&At.buildingId&&k.open(At.buildingId)},ot=Mt=>{const At=Mt.detail;V((At==null?void 0:At.position)||null),k.open(null)},jn=Mt=>{const At=Mt.detail;At!=null&&At.buildingId?We(At.buildingId):At!=null&&At.url&&R(At.url)};return window.addEventListener("tide:open-spawn-modal",je),window.addEventListener("tide:building-action",Je),window.addEventListener("tide:building-edit",Ct),window.addEventListener("tide:building-create",ot),window.addEventListener("tide:open-iframe-modal",jn),()=>{window.removeEventListener("tide:open-spawn-modal",je),window.removeEventListener("tide:building-action",Je),window.removeEventListener("tide:building-edit",Ct),window.removeEventListener("tide:building-create",ot),window.removeEventListener("tide:open-iframe-modal",jn)}},[s,k]);const lc=bt==="rectangle"||bt==="circle",Ma=x.useCallback(()=>{var je;(je=Ye.current)==null||je.setDrawingTool(null),typeof window<"u"&&window.__tideScene2D_setDrawingTool&&window.__tideScene2D_setDrawingTool(null)},[Ye]),Ts=x.useCallback(()=>ve(je=>!je),[]),hs=x.useCallback(()=>U.setMobileView("terminal"),[]),Mn=x.useCallback(()=>Oe(!0),[]),zi=nn.length===1&&U.getOutputs(nn[0]).length>0;return o.jsxs("div",{className:`app ${wt?"terminal-open":""} ${lc?"drawing-mode":""} ${$e?"sidebar-collapsed":""} mobile-view-${Fe} view-mode-${Ke}`,children:[o.jsx(sq,{}),o.jsx(aq,{onCreateAgent:s.open}),o.jsx(CW,{visible:rt.showFPS,position:"bottom-right"}),o.jsxs("div",{className:"app-top-bar",children:[o.jsx(NW,{className:"app-view-mode-toggle"}),o.jsx(XR,{}),o.jsxs("button",{className:"app-organize-all-btn",disabled:$,title:"Auto-organize all agents in their areas",onClick:()=>{W(!0),iq().then(je=>{t_(je,Ye),it("success","Organized",`Arranged ${je.organized.length} agent${je.organized.length!==1?"s":""}`)}).catch(je=>{console.error("organize all error:",je),it("error","Organize Failed",je.message||"Failed to organize")}).finally(()=>W(!1))},children:[$?"⏳":"✨"," Organize"]})]}),o.jsxs("main",{className:"main-content",children:[o.jsxs("div",{className:"battlefield-container",children:[z&&o.jsxs("div",{className:"workspace-switch-overlay",children:[o.jsx("div",{className:"workspace-switch-spinner"}),o.jsx("span",{className:"workspace-switch-text",children:"Switching workspace..."})]}),o.jsx(Se.Suspense,{fallback:null,children:Ke==="dashboard"?o.jsx(pq,{onSelectAgent:je=>U.selectAgent(je),onFocusAgent:je=>{U.setViewMode("3d"),Fn(je)},onKillAgent:Ls,onSelectBuilding:je=>U.selectBuilding(je),onOpenTerminal:je=>{U.selectAgent(je),U.setTerminalOpen(!0)},onFocusZone:je=>{U.setViewMode("3d");const Je=U.getState().areas.get(je);Je&&Je.assignedAgentIds.length>0&&Fn(Je.assignedAgentIds[0])}}):Ke==="2d"?o.jsx(fq,{onAgentClick:(je,Je)=>{Je?U.addToSelection(je):U.selectAgent(je)},onAgentDoubleClick:je=>{if(window.innerWidth<=768){U.openTerminalOnMobile(je);return}U.selectAgent(je),U.setTerminalOpen(!0)},onBuildingClick:(je,Je)=>{U.selectBuilding(je);const Ct=U.getState().buildings.get(je);(Ct==null?void 0:Ct.type)==="folder"&&Ct.folderPath?U.openFileExplorer(Ct.folderPath):((Ct==null?void 0:Ct.type)==="server"||(Ct==null?void 0:Ct.type)==="boss"||(Ct==null?void 0:Ct.type)==="database")&&(fe.current&&clearTimeout(fe.current),fe.current=setTimeout(()=>{et({buildingId:je,screenPos:Je,fromClick:!0}),fe.current=null},150))},onBuildingDoubleClick:je=>{var Ct;fe.current&&(clearTimeout(fe.current),fe.current=null),et(null);const Je=U.getState().buildings.get(je);(Je==null?void 0:Je.type)==="server"&&((Ct=Je.pm2)!=null&&Ct.enabled)?me(je):(Je==null?void 0:Je.type)==="boss"?Te(je):(Je==null?void 0:Je.type)==="database"?Ne(je):(Je==null?void 0:Je.type)==="folder"&&Je.folderPath?U.openFileExplorer(Je.folderPath):k.open(je)},onGroundClick:()=>{U.selectAgent(null),U.selectBuilding(null)},onAreaDoubleClick:je=>{U.selectArea(je),i.open()},onContextMenu:(je,Je,Ct)=>{const ot=Ct?{type:Ct.type,id:Ct.id}:{type:"ground"};O.open(je,Je,ot)},onMoveCommand:(je,Je)=>{const ot=je.length,jn=[];if(ot===1)jn.push({x:Je.x,y:0,z:Je.z});else if(ot<=6){const Mt=1.2*Math.max(1,ot/3);for(let At=0;At<ot;At++){const kn=At/ot*Math.PI*2-Math.PI/2;jn.push({x:Je.x+Math.cos(kn)*Mt,y:0,z:Je.z+Math.sin(kn)*Mt})}}else{const Mt=Math.ceil(Math.sqrt(ot)),At=Math.ceil(ot/Mt),kn=(Mt-1)*1.2/2,ms=(At-1)*1.2/2;for(let Dn=0;Dn<ot;Dn++){const Fs=Dn%Mt,Qr=Math.floor(Dn/Mt);jn.push({x:Je.x+Fs*1.2-kn,y:0,z:Je.z+Qr*1.2-ms})}}je.forEach((Mt,At)=>{U.moveAgent(Mt,jn[At])})},onBuildingDragMove:(je,Je)=>{var ot;const Ct=U.getState().buildings.get(je);Ct&&(U.getState().buildings.set(je,{...Ct,position:{x:Je.x,z:Je.z}}),(ot=window.__tideScene2D)==null||ot.syncBuildings())},onBuildingDragEnd:(je,Je)=>{U.updateBuildingPosition(je,Je)},scale2d:X.scale2d,showTaskLabels:X.show2DTaskLabels,showGrid:X.gridVisible,fpsLimit:X.fpsLimit}):o.jsxs(Se.Fragment,{children:[o.jsx("canvas",{ref:e,id:"battlefield",tabIndex:0}),o.jsx("div",{ref:n,id:"selection-box"})]},ke)}),Ae&&o.jsxs("div",{className:"scene-loading-overlay",children:[o.jsx("div",{className:"scene-loading-overlay__spinner"}),o.jsx("span",{className:"scene-loading-overlay__label",children:"Loading 3D scene…"})]})]}),o.jsx(TW,{isOpen:ge,onToggle:Ts,onShowTerminal:hs,onOpenSidebar:Mn,onOpenToolbox:i.open,onOpenCommander:c.open,onOpenSupervisor:f.open,onOpenControls:m.open,onOpenSkills:b.open,onOpenSnapshots:S.open,onTakeSnapshot:T.open,canTakeSnapshot:zi,mobileView:Fe}),he&&o.jsx("div",{className:"sidebar-overlay",onClick:()=>Oe(!1)}),!1,o.jsx("button",{className:`sidebar-collapse-edge-btn ${$e?"is-collapsed":""} ${Pe?"can-pin":""}`,onClick:()=>{if(window.innerWidth<=768)Oe(!he);else{const Je=!$e;xe(Je),localStorage.setItem("tide-commander-sidebar-collapsed",String(Je))}},title:$e?"Open sidebar":"Close sidebar",children:o.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:Pe?o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"10",r:"3"}),o.jsx("line",{x1:"12",y1:"13",x2:"12",y2:"21"}),o.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"})]}):o.jsx("polyline",{points:$e?"15 18 9 12 15 6":"9 18 15 12 9 6"})})}),o.jsxs("aside",{className:`sidebar ${he?"sidebar-open":""} ${$e?"sidebar-collapsed":""}`,children:[o.jsx("button",{className:"sidebar-close-btn show-on-mobile",onClick:()=>Oe(!1),title:"Close sidebar",children:"✕"}),nn.length>0?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"sidebar-section unit-section",children:o.jsx(x.Profiler,{id:"UnitPanel",onRender:yu,children:o.jsx(ES,{onFocusAgent:Fn,onKillAgent:Ls,onCallSubordinates:Is,onOpenAreaExplorer:wn})})}),o.jsx("div",{className:"sidebar-section tool-history-section",children:o.jsx(x.Profiler,{id:"ToolHistory",onRender:yu,children:o.jsx(_4,{agentIds:nn})})})]}):o.jsx("div",{className:"sidebar-section unit-section",children:o.jsx(x.Profiler,{id:"UnitPanel",onRender:yu,children:o.jsx(ES,{onFocusAgent:Fn,onKillAgent:Ls,onCallSubordinates:Is,onOpenAreaExplorer:wn})})})]}),o.jsx(x.Profiler,{id:"GuakeOutputPanel",onRender:yu,children:o.jsx(sW,{onSaveSnapshot:T.open})})]}),o.jsx(_W,{onOpenToolbox:i.open,onOpenCommander:c.open,onOpenSupervisor:f.open,onOpenControls:m.open,onOpenSkills:b.open,onOpenSnapshots:S.open,isGeneratingReport:xt,pip:_}),o.jsx(hW,{activeTool:bt,onExit:Ma}),q&&(()=>{const je=U.getState().agents.get(q.agentId);return je?o.jsx(bW,{agent:je,screenPos:q.screenPos,onClose:()=>be(null)}):null})(),Ce&&(()=>{const je=Ft.get(Ce.buildingId);if(!je)return null;const Je=()=>et(null);return je.type==="boss"?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"building-popup-backdrop",onClick:Je}),o.jsx(kW,{building:je,screenPos:Ce.screenPos,onClose:Je,onOpenSettings:()=>{Je(),k.open(Ce.buildingId)},onOpenLogsModal:()=>{Je(),Te(Ce.buildingId)},onOpenUrlInModal:Ps})]}):je.type==="database"?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"building-popup-backdrop",onClick:Je}),o.jsx(SW,{building:je,screenPos:Ce.screenPos,onClose:Je,onOpenSettings:()=>{Je(),k.open(Ce.buildingId)},onOpenDatabasePanel:()=>{Je(),Ne(Ce.buildingId)}})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"building-popup-backdrop",onClick:Je}),o.jsx(yW,{building:je,screenPos:Ce.screenPos,onClose:Je,onOpenSettings:()=>{Je(),k.open(Ce.buildingId)},onOpenLogsModal:()=>{me(Ce.buildingId)},onOpenUrlInModal:Ps})]})})(),ie&&(()=>{var Je;const je=Ft.get(ie);return je?(Je=je.docker)!=null&&Je.enabled?o.jsx(uq,{building:je,isOpen:!0,onClose:()=>me(null)}):o.jsx(cq,{building:je,isOpen:!0,onClose:()=>me(null)}):null})(),Ee&&(()=>{const je=Ft.get(Ee);return je?o.jsx(dq,{building:je,isOpen:!0,onClose:()=>Te(null)}):null})(),ee&&(()=>{const je=Ft.get(ee);return je?o.jsx("div",{className:"modal-overlay visible",onMouseDown:st,onClick:pe,children:o.jsx("div",{className:"database-panel-modal",children:o.jsx(lq,{building:je,onClose:ze})})}):null})(),Ve&&(()=>{var Je;const je=Ft.get(Ve);return!je||!((Je=je.terminalStatus)!=null&&Je.url)?null:o.jsx("div",{className:"modal-overlay visible",onMouseDown:oe,onClick:de,children:o.jsxs("div",{className:"terminal-modal-container",children:[o.jsxs("div",{className:"terminal-modal-header",children:[o.jsxs("span",{className:"terminal-modal-title",children:["Terminal - ",je.name]}),o.jsx("button",{className:"terminal-modal-close",onClick:Be,children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsx(jx,{terminalUrl:je.terminalStatus.url,visible:!0})]})})})(),o.jsx(KW,{pip:_,title:"Tide Commander - Agents",children:o.jsx(ZW,{})}),o.jsx(hq,{url:M||"",title:M?`Preview - ${M}`:"",isOpen:!!M,onClose:Ua}),T.isOpen&&nn.length===1&&(()=>{const je=nn[0],Je=U.getState().agents.get(je);if(!Je)return null;const Ct=U.getOutputs(je);return o.jsx(mq,{isOpen:T.isOpen,onClose:T.close,agent:Je,outputCount:Ct.length,onSave:async ot=>{try{const jn=Ct.map(Mt=>({type:"message",content:Mt.text,timestamp:new Date(Mt.timestamp).toISOString()}));await U.createSnapshot(ot.agentId,Je.name,ot.title,ot.description,jn,[]),T.close(),it("success",t("notifications:toast.snapshotSaved"),t("notifications:toast.snapshotSavedMsg"))}catch(jn){const Mt=jn instanceof Error?jn.message:t("notifications:toast.snapshotFailedMsg");it("error",t("notifications:toast.snapshotFailed"),Mt)}},isSaving:$t,error:En||void 0})})(),o.jsx(pW,{onFocusAgent:Fn,onSpawnClick:s.open,onSpawnBossClick:a.open,onNewBuildingClick:Po,onNewAreaClick:Bo}),o.jsx(GW,{spawnModal:s,bossSpawnModal:a,subordinateModal:r,toolboxModal:i,commanderModal:c,deleteConfirmModal:d,supervisorModal:f,spotlightModal:h,controlsModal:m,skillsModal:b,integrationsModal:y,monitoringModal:w,workflowEditorModal:C,triggerManagerModal:N,buildingModal:k,buildingInitialPosition:H,agentEditModal:j,snapshotsModal:S,restoreArchivedModal:D,explorerModal:E,contextMenu:O,spawnPosition:L,spawnAreaId:G,explorerFolderPath:I,contextMenuActions:Bs,sceneConfig:X,onConfigChange:Qn,onToolChange:Ss,onOpenAreaExplorer:wn,onDeleteSelectedAgents:Bi,pendingBuildingDelete:K,onCancelBuildingDelete:()=>se(null),onConfirmBuildingDelete:Fi,showBackNavModal:ht,onCloseBackNavModal:()=>Gt(!1),onLeave:tn,onOpenPM2LogsModal:je=>me(je),onOpenBossLogsModal:je=>Te(je),onOpenDatabasePanel:je=>Ne(je),onSyncScene:()=>{var je,Je;(je=Ye.current)==null||je.syncAreas(),(Je=Ye.current)==null||Je.syncAgents(Array.from(U.getState().agents.values()))}})]})}function bq(){return o.jsx(yL,{children:o.jsx(AL,{children:o.jsx(gq,{})})})}class xq extends x.Component{constructor(n){super(n);Xe(this,"handleReload",()=>{window.location.reload()});Xe(this,"handleDismiss",()=>{this.setState({hasError:!1,error:null,errorInfo:null})});this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,s){console.error("[Tide] React Error:",n,s),this.setState({errorInfo:s})}render(){if(this.state.hasError){const{error:n,errorInfo:s}=this.state;return o.jsx("div",{style:{position:"fixed",inset:0,background:"#1a1a2e",color:"#fff",fontFamily:"monospace",padding:"32px",overflow:"auto",zIndex:99999},children:o.jsxs("div",{style:{maxWidth:"900px",margin:"0 auto"},children:[o.jsxs("h1",{style:{color:"#ff4a4a",fontSize:"24px",marginBottom:"16px",display:"flex",alignItems:"center",gap:"12px"},children:[o.jsx("span",{style:{fontSize:"32px"},children:"💥"}),On.t("errors:crash.title")]}),o.jsx("div",{style:{background:"#2a2a3e",borderRadius:"8px",padding:"16px",marginBottom:"16px"},children:o.jsxs("div",{style:{color:"#ff6b6b",fontSize:"18px",marginBottom:"8px"},children:[n==null?void 0:n.name,": ",n==null?void 0:n.message]})}),o.jsxs("div",{style:{background:"#2a2a3e",borderRadius:"8px",padding:"16px",marginBottom:"16px"},children:[o.jsx("div",{style:{color:"#888",marginBottom:"8px",fontSize:"12px"},children:On.t("errors:crash.stackTrace")}),o.jsx("pre",{style:{color:"#ccc",fontSize:"12px",lineHeight:"1.5",whiteSpace:"pre-wrap",wordBreak:"break-word",margin:0},children:n==null?void 0:n.stack})]}),(s==null?void 0:s.componentStack)&&o.jsxs("div",{style:{background:"#2a2a3e",borderRadius:"8px",padding:"16px",marginBottom:"16px"},children:[o.jsx("div",{style:{color:"#888",marginBottom:"8px",fontSize:"12px"},children:On.t("errors:crash.componentStack")}),o.jsx("pre",{style:{color:"#ccc",fontSize:"12px",lineHeight:"1.5",whiteSpace:"pre-wrap",wordBreak:"break-word",margin:0},children:s.componentStack})]}),o.jsxs("div",{style:{display:"flex",gap:"12px"},children:[o.jsx("button",{onClick:this.handleReload,style:{background:"#4a9eff",color:"#fff",border:"none",borderRadius:"6px",padding:"12px 24px",fontSize:"14px",cursor:"pointer"},children:On.t("common:buttons.reloadPage")}),o.jsx("button",{onClick:this.handleDismiss,style:{background:"#444",color:"#fff",border:"none",borderRadius:"6px",padding:"12px 24px",fontSize:"14px",cursor:"pointer"},children:On.t("common:buttons.tryToContinue")})]}),o.jsx("div",{style:{marginTop:"24px",color:"#666",fontSize:"12px"},children:On.t("errors:crash.checkConsole")})]})})}return this.props.children}}A6();document.addEventListener("wheel",t=>{if(Math.abs(t.deltaX)>Math.abs(t.deltaY)&&Math.abs(t.deltaX)>0){const e=t.target;if(e.tagName==="CANVAS"){t.preventDefault();return}let n=e;for(;n&&n!==document.documentElement;){if(n.scrollWidth>n.clientWidth)return;n=n.parentElement}t.preventDefault()}},{passive:!1});const n_=document.getElementById("app");if(!n_)throw new Error("Could not find #app container");const yq=CM.createRoot(n_);yq.render(o.jsx(Se.StrictMode,{children:o.jsx(x.Suspense,{fallback:o.jsx("div",{style:{background:"#0a0a0a",height:"100vh"}}),children:o.jsx(xq,{children:o.jsx(bq,{})})})}));console.log("[Tide] Tide Commander initialized");export{Df as $,NL as A,c1 as B,qD as C,wL as D,Mx as E,aV as F,_x as G,ed as H,Wx as I,ur as J,Ux as K,eL as L,dr as M,Iq as N,TL as O,Fa as P,oV as Q,TH as R,pt as S,fs as T,Jq as U,Bt as V,b1 as W,iV as X,k2 as Y,Mu as Z,Rf as _,Gx as a,ph as a$,Hg as a0,Wr as a1,Qp as a2,Xq as a3,Qj as a4,yp as a5,Aq as a6,vL as a7,Vb as a8,Yq as a9,WD as aA,o5 as aB,P6 as aC,B6 as aD,U6 as aE,zq as aF,Xj as aG,Uq as aH,Hq as aI,Dx as aJ,Rx as aK,np as aL,lV as aM,vt as aN,NN as aO,rV as aP,TN as aQ,_N as aR,Lu as aS,Fr as aT,zr as aU,W6 as aV,q6 as aW,d1 as aX,jb as aY,V6 as aZ,Do as a_,Ii as aa,Cq as ab,Wq as ac,Ey as ad,ia as ae,Pu as af,Up as ag,Ea as ah,pr as ai,Ox as aj,YD as ak,On as al,$R as am,VD as an,Gq as ao,Kq as ap,Qq as aq,Vq as ar,i1 as as,iS as at,Lq as au,Jj as av,Xt as aw,UH as ax,_T as ay,sh as az,oL as b,jN as b0,da as b1,RN as b2,d5 as b3,Oy as b4,gx as b5,v4 as b6,s1 as b7,_q as b8,Pq as b9,Eq as ba,Bq as bb,Fq as bc,Oq as bd,Dq as be,$q as bf,Kp as bg,PL as bh,x2 as bi,v2 as bj,Zq as bk,_o as bl,Ju as bm,_L as bn,eV as bo,sV as bp,tV as bq,Rq as br,Mq as bs,nV as bt,UR as bu,HR as bv,su as bw,Lx as bx,qq as c,lL as d,jy as e,Rs as f,_H as g,Ta as h,Kl as i,o as j,vS as k,Na as l,Tn as m,Nq as n,jq as o,Nf as p,zx as q,x as r,U as s,Tq as t,dt as u,Gb as v,Rt as w,GR as x,KR as y,Se as z};