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
@@ -0,0 +1,152 @@
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-DBpmD8r7.js","assets/modulepreload-polyfill-B5Qt9EMX.js","assets/vendor-three-Chj50gSY.js","assets/web-1BwWjkKM.js","assets/SceneManager-BgkqWsDb.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-BdCgTKpM.js","assets/BossSpawnModal-Cohl0WaH.js","assets/SubordinateAssignmentModal-BoaofULj.js","assets/index-VO6fNr63.js","assets/index-Bykeknjl.css","assets/index-BiJ_hIit.js","assets/index-BgTRovwT.js","assets/index-BKRKKMPQ.js","assets/SupervisorPanel-D8Cp77my.js","assets/index-CDAtstMx.js","assets/ControlsModal-CAVkg9mM.js","assets/SkillsPanel-CO-Zt0Tq.js","assets/SnapshotManager-D4Uzw6Tp.js","assets/RestoreArchivedAreaModal-BajWqtWn.js","assets/IntegrationsPanel-BPKoNwZm.js","assets/MonitoringModal-DzqEa0fQ.js","assets/WorkflowEditorPanel-EtzhBZWw.js","assets/TriggerManagerPanel-CFf3Tud5.js","assets/index-2YWd58Wh.js","assets/index-CprCD9du.css","assets/PM2LogsModal-DZXPRV5-.js","assets/LogViewerModal-Bx9IDiFM.js","assets/DockerLogsModal-BXv9Hzg-.js","assets/BossLogsModal-CehuxNwV.js","assets/Scene2DCanvas-DWDmyh_y.js","assets/Scene2DCanvas-DwXbvB-b.css","assets/index-DByGRjfY.js","assets/index-BZyCMBzi.css","assets/IframeModal-DlS7y7PK.js","assets/IframeModal-DJkCGwT6.css","assets/SaveSnapshotModal-LqaLezB-.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 Tx,g as Zu,a as tj,c as Z0}from"./vendor-react--Eh9ivFN.js";import{T as ME,a as Ib,b as nj,L as sj,c as ju,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 Pb,f as dp,g as Co,I as OE,Q as rj,h as LE,O as ij,i as IE,j as PE,B as Nu,k as BE,l as oj,N as FE,m as zE,n as $E,o as Bb,p as lj,R as Fb,q as UE,r as HE,s as WE,t as Jf,u as qE,v as _x,w as cj,x as Pl,y as VE,z as uj,A as YE,E as Ol,G as GE,H as KE,J as QE,K as XE,U as yg,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 zb,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 vg={exports:{}},eu={};/**
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 eu;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 eu.Fragment=e,eu.jsx=n,eu.jsxs=n,eu}var rk;function yM(){return rk||(rk=1,vg.exports=xM()),vg.exports}var o=yM(),x=Tx();const je=Zu(x),pj=bM({__proto__:null,default:je},[x]);var wg={exports:{}},tu={},kg={exports:{}},Sg={};/**
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(z,W){var V=z.length;z.push(W);e:for(;0<V;){var G=V-1>>>1,B=z[G];if(0<a(B,W))z[G]=W,z[V]=B,V=G;else break e}}function n(z){return z.length===0?null:z[0]}function s(z){if(z.length===0)return null;var W=z[0],V=z.pop();if(V!==W){z[0]=V;e:for(var G=0,B=z.length,K=B>>>1;G<K;){var se=2*(G+1)-1,q=z[se],me=se+1,ce=z[me];if(0>a(q,V))me<B&&0>a(ce,q)?(z[G]=ce,z[me]=V,G=me):(z[G]=q,z[se]=V,G=se);else if(me<B&&0>a(ce,V))z[G]=ce,z[me]=V,G=me;else break e}}return W}function a(z,W){var V=z.sortIndex-W.sortIndex;return V!==0?V:z.id-W.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,A=!1,N=!1,k=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;function T(z){for(var W=n(f);W!==null;){if(W.callback===null)s(f);else if(W.startTime<=z)s(f),W.sortIndex=W.expirationTime,e(d,W);else break;W=n(f)}}function D(z){if(A=!1,T(z),!w)if(n(d)!==null)w=!0,E||(E=!0,F());else{var W=n(f);W!==null&&L(D,W.startTime-z)}}var E=!1,P=-1,O=5,_=-1;function M(){return N?!0:!(t.unstable_now()-_<O)}function R(){if(N=!1,E){var z=t.unstable_now();_=z;var W=!0;try{e:{w=!1,A&&(A=!1,j(P),P=-1),y=!0;var V=b;try{t:{for(T(z),m=n(d);m!==null&&!(m.expirationTime>z&&M());){var G=m.callback;if(typeof G=="function"){m.callback=null,b=m.priorityLevel;var B=G(m.expirationTime<=z);if(z=t.unstable_now(),typeof B=="function"){m.callback=B,T(z),W=!0;break t}m===n(d)&&s(d),T(z)}else s(d);m=n(d)}if(m!==null)W=!0;else{var K=n(f);K!==null&&L(D,K.startTime-z),W=!1}}break e}finally{m=null,b=V,y=!1}W=void 0}}finally{W?F():E=!1}}}var F;if(typeof S=="function")F=function(){S(R)};else if(typeof MessageChannel<"u"){var $=new MessageChannel,H=$.port2;$.port1.onmessage=R,F=function(){H.postMessage(null)}}else F=function(){k(R,0)};function L(z,W){P=k(function(){z(t.unstable_now())},W)}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(z){z.callback=null},t.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):O=0<z?Math.floor(1e3/z):5},t.unstable_getCurrentPriorityLevel=function(){return b},t.unstable_next=function(z){switch(b){case 1:case 2:case 3:var W=3;break;default:W=b}var V=b;b=W;try{return z()}finally{b=V}},t.unstable_requestPaint=function(){N=!0},t.unstable_runWithPriority=function(z,W){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var V=b;b=z;try{return W()}finally{b=V}},t.unstable_scheduleCallback=function(z,W,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,z){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,z={id:h++,callback:W,priorityLevel:z,startTime:V,expirationTime:B,sortIndex:-1},V>G?(z.sortIndex=V,e(f,z),n(d)===null&&z===n(f)&&(A?(j(P),P=-1):A=!0,L(D,V-G))):(z.sortIndex=B,e(d,z),w||y||(w=!0,E||(E=!0,F()))),z},t.unstable_shouldYield=M,t.unstable_wrapCallback=function(z){var W=b;return function(){var V=b;b=W;try{return z.apply(this,arguments)}finally{b=V}}}})(Sg)),Sg}var ok;function wM(){return ok||(ok=1,kg.exports=vM()),kg.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 tu;lk=1;var t=wM(),e=Tx(),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 C=v.alternate;if(C===null){if(g=v.return,g!==null){p=g;continue}break}if(v.child===C.child){for(C=v.child;C;){if(C===p)return d(v),l;if(C===g)return d(v),u;C=C.sibling}throw Error(s(188))}if(p.return!==g.return)p=v,g=C;else{for(var I=!1,Y=v.child;Y;){if(Y===p){I=!0,p=v,g=C;break}if(Y===g){I=!0,g=v,p=C;break}Y=Y.sibling}if(!I){for(Y=C.child;Y;){if(Y===p){I=!0,p=C,g=v;break}if(Y===g){I=!0,g=C,p=v;break}Y=Y.sibling}if(!I)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"),A=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"),P=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),_=Symbol.for("react.activity"),M=Symbol.for("react.memo_cache_sentinel"),R=Symbol.iterator;function F(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 H(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 A: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 P:return u=l.displayName||null,u!==null?u:H(l.type)||"Memo";case O:u=l._payload,l=l._init;try{return H(l(u))}catch{}}return null}var L=Array.isArray,z=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W=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 me=K(null),ce=K(null),ee=K(null),pe=K(null);function Ne(l,u){switch(q(ee,u),q(ce,l),q(me,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(me),q(me,l)}function ye(){se(me),se(ce),se(ee)}function Me(l){l.memoizedState!==null&&q(pe,l);var u=me.current,p=S0(u,l.type);u!==p&&(q(ce,l),q(me,p))}function qe(l){ce.current===l&&(se(me),se(ce)),pe.current===l&&(se(pe),Qc._currentValue=V)}var He,X;function ne(l){if(He===void 0)try{throw Error()}catch(p){var u=p.stack.trim().match(/\n( *(at )?)/);He=u&&u[1]||"",X=-1<p.stack.indexOf(`
27
+ at`)?" (<anonymous>)":-1<p.stack.indexOf("@")?"@unknown:0:0":""}return`
28
+ `+He+l+X}var Te=!1;function We(l,u){if(!l||Te)return"";Te=!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($e){var Ie=$e}Reflect.construct(l,[],Qe)}else{try{Qe.call()}catch($e){Ie=$e}l.call(Qe.prototype)}}else{try{throw Error()}catch($e){Ie=$e}(Qe=l())&&typeof Qe.catch=="function"&&Qe.catch(function(){})}}catch($e){if($e&&Ie&&typeof $e.stack=="string")return[$e.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 C=g.DetermineComponentFrameRoot(),I=C[0],Y=C[1];if(I&&Y){var re=I.split(`
29
+ `),Re=Y.split(`
30
+ `);for(v=g=0;g<re.length&&!re[g].includes("DetermineComponentFrameRoot");)g++;for(;v<Re.length&&!Re[v].includes("DetermineComponentFrameRoot");)v++;if(g===re.length||v===Re.length)for(g=re.length-1,v=Re.length-1;1<=g&&0<=v&&re[g]!==Re[v];)v--;for(;1<=g&&0<=v;g--,v--)if(re[g]!==Re[v]){if(g!==1||v!==1)do if(g--,v--,0>v||re[g]!==Re[v]){var Ve=`
31
+ `+re[g].replace(" at new "," at ");return l.displayName&&Ve.includes("<anonymous>")&&(Ve=Ve.replace("<anonymous>",l.displayName)),Ve}while(1<=g&&0<=v);break}}}finally{Te=!1,Error.prepareStackTrace=p}return(p=l?l.displayName||l.name:"")?ne(p):""}function nt(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 We(l.type,!1);case 11:return We(l.type.render,!1);case 1:return We(l.type,!0);case 31:return ne("Activity");default:return""}}function we(l){try{var u="",p=null;do u+=nt(l,p),p=l,l=l.return;while(l);return u}catch(g){return`
32
+ Error generating stack: `+g.message+`
33
+ `+g.stack}}var Le=Object.prototype.hasOwnProperty,ie=t.unstable_scheduleCallback,de=t.unstable_cancelCallback,Ue=t.unstable_shouldYield,Ze=t.unstable_requestPaint,lt=t.unstable_now,fe=t.unstable_getCurrentPriorityLevel,J=t.unstable_ImmediatePriority,ae=t.unstable_UserBlockingPriority,Se=t.unstable_NormalPriority,Z=t.unstable_LowPriority,he=t.unstable_IdlePriority,De=t.log,ze=t.unstable_setDisableYieldValue,be=null,Pe=null;function te(l){if(typeof De=="function"&&ze(l),Pe&&typeof Pe.setStrictMode=="function")try{Pe.setStrictMode(be,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 st=256,xt=262144,ht=4194304;function ot(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 ft(l,u,p){var g=l.pendingLanes;if(g===0)return 0;var v=0,C=l.suspendedLanes,I=l.pingedLanes;l=l.warmLanes;var Y=g&134217727;return Y!==0?(g=Y&~C,g!==0?v=ot(g):(I&=Y,I!==0?v=ot(I):p||(p=Y&~l,p!==0&&(v=ot(p))))):(Y=g&~C,Y!==0?v=ot(Y):I!==0?v=ot(I):p||(p=g&~l,p!==0&&(v=ot(p)))),v===0?0:u!==0&&u!==v&&(u&C)===0&&(C=v&-v,p=u&-u,C>=p||C===32&&(p&4194048)!==0)?u:v}function ut(l,u){return(l.pendingLanes&~(l.suspendedLanes&~l.pingedLanes)&u)===0}function ln(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 Kt(){var l=ht;return ht<<=1,(ht&62914560)===0&&(ht=4194304),l}function Ce(l){for(var u=[],p=0;31>p;p++)u.push(l);return u}function Be(l,u){l.pendingLanes|=u,u!==268435456&&(l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0)}function Ye(l,u,p,g,v,C){var I=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,Re=l.hiddenUpdates;for(p=I&~p;0<p;){var Ve=31-ge(p),Qe=1<<Ve;Y[Ve]=0,re[Ve]=-1;var Ie=Re[Ve];if(Ie!==null)for(Re[Ve]=null,Ve=0;Ve<Ie.length;Ve++){var $e=Ie[Ve];$e!==null&&($e.lane&=-536870913)}p&=~Qe}g!==0&&et(l,g,0),C!==0&&v===0&&l.tag!==0&&(l.suspendedLanes|=C&~(I&~u))}function et(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 Et(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 $t(l,u){var p=u&-u;return p=(p&42)!==0?1:Dt(p),(p&(l.suspendedLanes|u))!==0?0:p}function Dt(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 qt(l){return l&=-l,2<l?8<l?(l&134217727)!==0?32:268435456:8:2}function cn(){var l=W.p;return l!==0?l:(l=window.event,l===void 0?32:V0(l.type))}function yt(l,u){var p=W.p;try{return W.p=l,u()}finally{W.p=p}}var rt=Math.random().toString(36).slice(2),ct="__reactFiber$"+rt,Ft="__reactProps$"+rt,_n="__reactContainer$"+rt,En="__reactEvents$"+rt,bn="__reactListeners$"+rt,Is="__reactHandles$"+rt,_s="__reactResources$"+rt,ts="__reactMarker$"+rt;function Ks(l){delete l[ct],delete l[Ft],delete l[En],delete l[bn],delete l[Is]}function Bn(l){var u=l[ct];if(u)return u;for(var p=l.parentNode;p;){if(u=p[_n]||p[ct]){if(p=u.alternate,u.child!==null||p!==null&&p.child!==null)for(l=E0(l);l!==null;){if(p=l[ct])return p;l=E0(l)}return u}l=p,p=l.parentNode}return null}function us(l){if(l=l[ct]||l[_n]){var u=l.tag;if(u===5||u===6||u===13||u===31||u===26||u===27||u===3)return l}return null}function Un(l){var u=l.tag;if(u===5||u===26||u===27||u===6)return l.stateNode;throw Error(s(33))}function Qs(l){var u=l[_s];return u||(u=l[_s]={hoistableStyles:new Map,hoistableScripts:new Map}),u}function On(l){l[ts]=!0}var Wa=new Set,zo={};function pa(l,u){ha(l,u),ha(l+"Capture",u)}function ha(l,u){for(zo[l]=u,l=0;l<u.length;l++)Wa.add(u[l])}var ic=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]*$"),Qr={},$i={};function Xs(l){return Le.call($i,l)?!0:Le.call(Qr,l)?!1:ic.test(l)?$i[l]=!0:(Qr[l]=!0,!1)}function Xr(l,u,p){if(Xs(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 Da(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 ns(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 ss(l){switch(typeof l){case"bigint":case"boolean":case"number":case"string":case"undefined":return l;case"object":return l;default:return""}}function gs(l){var u=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(u==="checkbox"||u==="radio")}function Ae(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,C=g.set;return Object.defineProperty(l,u,{configurable:!0,get:function(){return v.call(this)},set:function(I){p=""+I,C.call(this,I)}}),Object.defineProperty(l,u,{enumerable:g.enumerable}),{getValue:function(){return p},setValue:function(I){p=""+I},stopTracking:function(){l._valueTracker=null,delete l[u]}}}}function Je(l){if(!l._valueTracker){var u=gs(l)?"checked":"value";l._valueTracker=Ae(l,u,""+l[u])}}function jt(l){if(!l)return!1;var u=l._valueTracker;if(!u)return!0;var p=u.getValue(),g="";return l&&(g=gs(l)?l.checked?"true":"false":l.value),l=g,l!==p?(u.setValue(l),!0):!1}function Vt(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 gt=/[\n"\\]/g;function Lt(l){return l.replace(gt,function(u){return"\\"+u.charCodeAt(0).toString(16)+" "})}function kt(l,u,p,g,v,C,I,Y){l.name="",I!=null&&typeof I!="function"&&typeof I!="symbol"&&typeof I!="boolean"?l.type=I:l.removeAttribute("type"),u!=null?I==="number"?(u===0&&l.value===""||l.value!=u)&&(l.value=""+ss(u)):l.value!==""+ss(u)&&(l.value=""+ss(u)):I!=="submit"&&I!=="reset"||l.removeAttribute("value"),u!=null?bs(l,I,ss(u)):p!=null?bs(l,I,ss(p)):g!=null&&l.removeAttribute("value"),v==null&&C!=null&&(l.defaultChecked=!!C),v!=null&&(l.checked=v&&typeof v!="function"&&typeof v!="symbol"),Y!=null&&typeof Y!="function"&&typeof Y!="symbol"&&typeof Y!="boolean"?l.name=""+ss(Y):l.removeAttribute("name")}function xn(l,u,p,g,v,C,I,Y){if(C!=null&&typeof C!="function"&&typeof C!="symbol"&&typeof C!="boolean"&&(l.type=C),u!=null||p!=null){if(!(C!=="submit"&&C!=="reset"||u!=null)){Je(l);return}p=p!=null?""+ss(p):"",u=u!=null?""+ss(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,I!=null&&typeof I!="function"&&typeof I!="symbol"&&typeof I!="boolean"&&(l.name=I),Je(l)}function bs(l,u,p){u==="number"&&Vt(l.ownerDocument)===l||l.defaultValue===""+p||(l.defaultValue=""+p)}function Fn(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=""+ss(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 Cs(l,u,p){if(u!=null&&(u=""+ss(u),u!==l.value&&(l.value=u),p==null)){l.defaultValue!==u&&(l.defaultValue=u);return}l.defaultValue=p!=null?""+ss(p):""}function qa(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=ss(u),l.defaultValue=p,g=l.textContent,g===p&&g!==""&&g!==null&&(l.value=g),Je(l)}function Va(l,u){if(u){var p=l.firstChild;if(p&&p===l.lastChild&&p.nodeType===3){p.nodeValue=u;return}}l.textContent=u}var oc=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 dd(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||oc.has(u)?u==="float"?l.cssFloat=p:l[u]=(""+p).trim():l[u]=p+"px"}function ma(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&&dd(l,v,g)}else for(var C in u)u.hasOwnProperty(C)&&dd(l,C,u[C])}function Jr(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"]]),Hi=/^[\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 Zr(l){return Hi.test(""+l)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":l}function Ra(){}var zt=null;function Hn(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var ei=null,ti=null;function fd(l){var u=us(l);if(u&&(l=u.stateNode)){var p=l[Ft]||null;e:switch(l=u.stateNode,u.type){case"input":if(kt(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="'+Lt(""+u)+'"][type="radio"]'),u=0;u<p.length;u++){var g=p[u];if(g!==l&&g.form===l.form){var v=g[Ft]||null;if(!v)throw Error(s(90));kt(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&&jt(g)}break e;case"textarea":Cs(l,p.value,p.defaultValue);break e;case"select":u=p.value,u!=null&&Fn(l,!!p.multiple,u,!1)}}}var Qn=!1;function lc(l,u,p){if(Qn)return l(u,p);Qn=!0;try{var g=l(u);return g}finally{if(Qn=!1,(ei!==null||ti!==null)&&(tf(),ei&&(u=ei,l=ti,ti=ei=null,fd(u),l)))for(u=0;u<l.length;u++)fd(l[u])}}function Wi(l,u){var p=l.stateNode;if(p===null)return null;var g=p[Ft]||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 Ps=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ni=!1;if(Ps)try{var gr={};Object.defineProperty(gr,"passive",{get:function(){ni=!0}}),window.addEventListener("test",gr,gr),window.removeEventListener("test",gr,gr)}catch{ni=!1}var ga=null,qi=null,Vi=null;function pd(){if(Vi)return Vi;var l,u=qi,p=u.length,g,v="value"in ga?ga.value:ga.textContent,C=v.length;for(l=0;l<p&&u[l]===v[l];l++);var I=p-l;for(g=1;g<=I&&u[p-g]===v[C-g];g++);return Vi=v.slice(l,1<g?1-g:void 0)}function $o(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 Yi(){return!0}function cc(){return!1}function Wn(l){function u(p,g,v,C,I){this._reactName=p,this._targetInst=v,this.type=g,this.nativeEvent=C,this.target=I,this.currentTarget=null;for(var Y in l)l.hasOwnProperty(Y)&&(p=l[Y],this[Y]=p?p(C):C[Y]);return this.isDefaultPrevented=(C.defaultPrevented!=null?C.defaultPrevented:C.returnValue===!1)?Yi:cc,this.isPropagationStopped=cc,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=Yi)},stopPropagation:function(){var p=this.nativeEvent;p&&(p.stopPropagation?p.stopPropagation():typeof p.cancelBubble!="unknown"&&(p.cancelBubble=!0),this.isPropagationStopped=Yi)},persist:function(){},isPersistent:Yi}),u}var Es={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(l){return l.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Uo=Wn(Es),Mn=m({},Es,{view:0,detail:0}),mh=Wn(Mn),Ho,Wo,si,Gi=m({},Mn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:pc,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!==si&&(si&&l.type==="mousemove"?(Ho=l.screenX-si.screenX,Wo=l.screenY-si.screenY):Wo=Ho=0,si=l),Ho)},movementY:function(l){return"movementY"in l?l.movementY:Wo}}),hd=Wn(Gi),gh=m({},Gi,{dataTransfer:0}),bh=Wn(gh),qo=m({},Mn,{relatedTarget:0}),Vo=Wn(qo),Yo=m({},Es,{animationName:0,elapsedTime:0,pseudoElement:0}),uc=Wn(Yo),dc=m({},Es,{clipboardData:function(l){return"clipboardData"in l?l.clipboardData:window.clipboardData}}),Ki=Wn(dc),fc=m({},Es,{data:0}),Qi=Wn(fc),xh={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},yh={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"},vh={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function wh(l){var u=this.nativeEvent;return u.getModifierState?u.getModifierState(l):(l=vh[l])?!!u[l]:!1}function pc(){return wh}var md=m({},Mn,{key:function(l){if(l.key){var u=xh[l.key]||l.key;if(u!=="Unidentified")return u}return l.type==="keypress"?(l=$o(l),l===13?"Enter":String.fromCharCode(l)):l.type==="keydown"||l.type==="keyup"?yh[l.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:pc,charCode:function(l){return l.type==="keypress"?$o(l):0},keyCode:function(l){return l.type==="keydown"||l.type==="keyup"?l.keyCode:0},which:function(l){return l.type==="keypress"?$o(l):l.type==="keydown"||l.type==="keyup"?l.keyCode:0}}),kh=Wn(md),Sh=m({},Gi,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),hc=Wn(Sh),br=m({},Mn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:pc}),gd=Wn(br),bd=m({},Es,{propertyName:0,elapsedTime:0,pseudoElement:0}),Xi=Wn(bd),mc=m({},Gi,{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(mc),Ah=m({},Es,{newState:0,oldState:0}),jh=Wn(Ah),Nh=[9,13,27,32],Go=Ps&&"CompositionEvent"in window,ai=null;Ps&&"documentMode"in document&&(ai=document.documentMode);var xd=Ps&&"TextEvent"in window&&!ai,gc=Ps&&(!Go||ai&&8<ai&&11>=ai),bc=" ",Q=!1;function ue(l,u){switch(l){case"keyup":return Nh.indexOf(u.keyCode)!==-1;case"keydown":return u.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function le(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var _e=!1;function at(l,u){switch(l){case"compositionend":return le(u);case"keypress":return u.which!==32?null:(Q=!0,bc);case"textInput":return l=u.data,l===bc&&Q?null:l;default:return null}}function dt(l,u){if(_e)return l==="compositionend"||!Go&&ue(l,u)?(l=pd(),Vi=qi=ga=null,_e=!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 gc&&u.locale!=="ko"?null:u.data;default:return null}}var Nt={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 _t(l){var u=l&&l.nodeName&&l.nodeName.toLowerCase();return u==="input"?!!Nt[l.type]:u==="textarea"}function nn(l,u,p,g){ei?ti?ti.push(g):ti=[g]:ei=g,u=cf(u,"onChange"),0<u.length&&(p=new Uo("onChange","change",null,p,g),l.push({event:p,listeners:u}))}var fn=null,qn=null;function Ko(l){g0(l,0)}function xr(l){var u=Un(l);if(jt(u))return l}function xc(l,u){if(l==="change")return u}var yc=!1;if(Ps){var Ji;if(Ps){var Qo="oninput"in document;if(!Qo){var yd=document.createElement("div");yd.setAttribute("oninput","return;"),Qo=typeof yd.oninput=="function"}Ji=Qo}else Ji=!1;yc=Ji&&(!document.documentMode||9<document.documentMode)}function vd(){fn&&(fn.detachEvent("onpropertychange",Fy),qn=fn=null)}function Fy(l){if(l.propertyName==="value"&&xr(qn)){var u=[];nn(u,qn,l,Hn(l)),lc(Ko,u)}}function s_(l,u,p){l==="focusin"?(vd(),fn=u,qn=p,fn.attachEvent("onpropertychange",Fy)):l==="focusout"&&vd()}function a_(l){if(l==="selectionchange"||l==="keyup"||l==="keydown")return xr(qn)}function r_(l,u){if(l==="click")return xr(u)}function i_(l,u){if(l==="input"||l==="change")return xr(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 vc(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(!Le.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=Vt(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=Vt(l.document)}return u}function Th(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_=Ps&&"documentMode"in document&&11>=document.documentMode,Xo=null,_h=null,wc=null,Eh=!1;function Wy(l,u,p){var g=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;Eh||Xo==null||Xo!==Vt(g)||(g=Xo,"selectionStart"in g&&Th(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}),wc&&vc(wc,g)||(wc=g,g=cf(_h,"onSelect"),0<g.length&&(u=new Uo("onSelect","select",null,u,p),l.push({event:u,listeners:g}),u.target=Xo)))}function Zi(l,u){var p={};return p[l.toLowerCase()]=u.toLowerCase(),p["Webkit"+l]="webkit"+u,p["Moz"+l]="moz"+u,p}var Jo={animationend:Zi("Animation","AnimationEnd"),animationiteration:Zi("Animation","AnimationIteration"),animationstart:Zi("Animation","AnimationStart"),transitionrun:Zi("Transition","TransitionRun"),transitionstart:Zi("Transition","TransitionStart"),transitioncancel:Zi("Transition","TransitionCancel"),transitionend:Zi("Transition","TransitionEnd")},Mh={},qy={};Ps&&(qy=document.createElement("div").style,"AnimationEvent"in window||(delete Jo.animationend.animation,delete Jo.animationiteration.animation,delete Jo.animationstart.animation),"TransitionEvent"in window||delete Jo.transitionend.transition);function eo(l){if(Mh[l])return Mh[l];if(!Jo[l])return l;var u=Jo[l],p;for(p in u)if(u.hasOwnProperty(p)&&p in qy)return Mh[l]=u[p];return l}var Vy=eo("animationend"),Yy=eo("animationiteration"),Gy=eo("animationstart"),c_=eo("transitionrun"),u_=eo("transitionstart"),d_=eo("transitioncancel"),Ky=eo("transitionend"),Qy=new Map,Dh="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(" ");Dh.push("scrollEnd");function Oa(l,u){Qy.set(l,u),pa(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)},ba=[],Zo=0,Rh=0;function kd(){for(var l=Zo,u=Rh=Zo=0;u<l;){var p=ba[u];ba[u++]=null;var g=ba[u];ba[u++]=null;var v=ba[u];ba[u++]=null;var C=ba[u];if(ba[u++]=null,g!==null&&v!==null){var I=g.pending;I===null?v.next=v:(v.next=I.next,I.next=v),g.pending=v}C!==0&&Xy(p,v,C)}}function Sd(l,u,p,g){ba[Zo++]=l,ba[Zo++]=u,ba[Zo++]=p,ba[Zo++]=g,Rh|=g,l.lanes|=g,l=l.alternate,l!==null&&(l.lanes|=g)}function Oh(l,u,p,g){return Sd(l,u,p,g),Cd(l)}function to(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,C=l.return;C!==null;)C.childLanes|=p,g=C.alternate,g!==null&&(g.childLanes|=p),C.tag===22&&(l=C.stateNode,l===null||l._visibility&1||(v=!0)),l=C,C=C.return;return l.tag===3?(C=l.stateNode,v&&u!==null&&(v=31-ge(p),l=C.hiddenUpdates,g=l[v],g===null?l[v]=[u]:g.push(u),u.lane=p|536870912),C):null}function Cd(l){if(50<Hc)throw Hc=0,Hm=null,Error(s(185));for(var u=l.return;u!==null;)l=u,u=l.return;return l.tag===3?l.stateNode:null}var el={};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 Lh(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,C){var I=0;if(g=l,typeof l=="function")Lh(l)&&(I=1);else if(typeof l=="string")I=bE(l,p,me.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=C,l;case A:return no(p.children,v,C,u);case N:I=8,v|=24;break;case k:return l=Zs(12,p,u,v|2),l.elementType=k,l.lanes=C,l;case D:return l=Zs(13,p,u,v),l.elementType=D,l.lanes=C,l;case E:return l=Zs(19,p,u,v),l.elementType=E,l.lanes=C,l;default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case S:I=10;break e;case j:I=9;break e;case T:I=11;break e;case P:I=14;break e;case O:I=16,g=null;break e}I=29,p=Error(s(130,l===null?"null":typeof l,"")),g=null}return u=Zs(I,p,u,v),u.elementType=l,u.type=g,u.lanes=C,u}function no(l,u,p,g){return l=Zs(7,l,g,u),l.lanes=p,l}function Ih(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 Ph(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 xa(l,u){if(typeof l=="object"&&l!==null){var p=ev.get(l);return p!==void 0?p:(u={value:l,source:u,stack:we(u)},ev.set(l,u),u)}return{value:l,source:u,stack:we(u)}}var tl=[],nl=0,jd=null,kc=0,ya=[],va=0,ri=null,Ya=1,Ga="";function vr(l,u){tl[nl++]=kc,tl[nl++]=jd,jd=l,kc=u}function tv(l,u,p){ya[va++]=Ya,ya[va++]=Ga,ya[va++]=ri,ri=l;var g=Ya;l=Ga;var v=32-ge(g)-1;g&=~(1<<v),p+=1;var C=32-ge(u)+v;if(30<C){var I=v-v%5;C=(g&(1<<I)-1).toString(32),g>>=I,v-=I,Ya=1<<32-ge(u)+v|p<<v|g,Ga=C+l}else Ya=1<<C|p<<v|g,Ga=l}function Bh(l){l.return!==null&&(vr(l,1),tv(l,1,0))}function Fh(l){for(;l===jd;)jd=tl[--nl],tl[nl]=null,kc=tl[--nl],tl[nl]=null;for(;l===ri;)ri=ya[--va],ya[va]=null,Ga=ya[--va],ya[va]=null,Ya=ya[--va],ya[va]=null}function nv(l,u){ya[va++]=Ya,ya[va++]=Ga,ya[va++]=ri,Ya=u.id,Ga=u.overflow,ri=l}var xs=null,Ln=null,on=!1,ii=null,wa=!1,zh=Error(s(519));function oi(l){var u=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Sc(xa(u,l)),zh}function sv(l){var u=l.stateNode,p=l.type,g=l.memoizedProps;switch(u[ct]=l,u[Ft]=g,p){case"dialog":Xt("cancel",u),Xt("close",u);break;case"iframe":case"object":case"embed":Xt("load",u);break;case"video":case"audio":for(p=0;p<qc.length;p++)Xt(qc[p],u);break;case"source":Xt("error",u);break;case"img":case"image":case"link":Xt("error",u),Xt("load",u);break;case"details":Xt("toggle",u);break;case"input":Xt("invalid",u),xn(u,g.value,g.defaultValue,g.checked,g.defaultChecked,g.type,g.name,!0);break;case"select":Xt("invalid",u);break;case"textarea":Xt("invalid",u),qa(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&&(Xt("beforetoggle",u),Xt("toggle",u)),g.onScroll!=null&&Xt("scroll",u),g.onScrollEnd!=null&&Xt("scrollend",u),g.onClick!=null&&(u.onclick=Ra),u=!0):u=!1,u||oi(l,!0)}function av(l){for(xs=l.return;xs;)switch(xs.tag){case 5:case 31:case 13:wa=!1;return;case 27:case 3:wa=!0;return;default:xs=xs.return}}function sl(l){if(l!==xs)return!1;if(!on)return av(l),on=!0,!1;var u=l.tag,p;if((p=u!==3&&u!==27)&&((p=u===5)&&(p=l.type,p=!(p!=="form"&&p!=="button")||ag(l.type,l.memoizedProps)),p=!p),p&&Ln&&oi(l),av(l),u===13){if(l=l.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(s(317));Ln=_0(l)}else if(u===31){if(l=l.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(s(317));Ln=_0(l)}else u===27?(u=Ln,wi(l.type)?(l=cg,cg=null,Ln=l):Ln=u):Ln=xs?Sa(l.stateNode.nextSibling):null;return!0}function so(){Ln=xs=null,on=!1}function $h(){var l=ii;return l!==null&&($s===null?$s=l:$s.push.apply($s,l),ii=null),l}function Sc(l){ii===null?ii=[l]:ii.push(l)}var Uh=K(null),ao=null,wr=null;function li(l,u,p){q(Uh,u._currentValue),u._currentValue=p}function kr(l){l._currentValue=Uh.current,se(Uh)}function Hh(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 Wh(l,u,p,g){var v=l.child;for(v!==null&&(v.return=l);v!==null;){var C=v.dependencies;if(C!==null){var I=v.child;C=C.firstContext;e:for(;C!==null;){var Y=C;C=v;for(var re=0;re<u.length;re++)if(Y.context===u[re]){C.lanes|=p,Y=C.alternate,Y!==null&&(Y.lanes|=p),Hh(C.return,p,l),g||(I=null);break e}C=Y.next}}else if(v.tag===18){if(I=v.return,I===null)throw Error(s(341));I.lanes|=p,C=I.alternate,C!==null&&(C.lanes|=p),Hh(I,p,l),I=null}else I=v.child;if(I!==null)I.return=v;else for(I=v;I!==null;){if(I===l){I=null;break}if(v=I.sibling,v!==null){v.return=I.return,I=v;break}I=I.return}v=I}}function al(l,u,p,g){l=null;for(var v=u,C=!1;v!==null;){if(!C){if((v.flags&524288)!==0)C=!0;else if((v.flags&262144)!==0)break}if(v.tag===10){var I=v.alternate;if(I===null)throw Error(s(387));if(I=I.memoizedProps,I!==null){var Y=v.type;Js(v.pendingProps.value,I.value)||(l!==null?l.push(Y):l=[Y])}}else if(v===pe.current){if(I=v.alternate,I===null)throw Error(s(387));I.memoizedState.memoizedState!==v.memoizedState.memoizedState&&(l!==null?l.push(Qc):l=[Qc])}v=v.return}l!==null&&Wh(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 ro(l){ao=l,wr=null,l=l.dependencies,l!==null&&(l.firstContext=null)}function ys(l){return rv(ao,l)}function Td(l,u){return ao===null&&ro(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,as={$$typeof:S,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function qh(){return{controller:new p_,data:new Map,refCount:0}}function Cc(l){l.refCount--,l.refCount===0&&h_(m_,function(){l.controller.abort()})}var Ac=null,Vh=0,rl=0,il=null;function g_(l,u){if(Ac===null){var p=Ac=[];Vh=0,rl=Km(),il={status:"pending",value:void 0,then:function(g){p.push(g)}}}return Vh++,u.then(iv,iv),u}function iv(){if(--Vh===0&&Ac!==null){il!==null&&(il.status="fulfilled");var l=Ac;Ac=null,rl=0,il=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=z.S;z.S=function(l,u){Ww=lt(),typeof u=="object"&&u!==null&&typeof u.then=="function"&&g_(l,u),ov!==null&&ov(l,u)};var io=K(null);function Yh(){var l=io.current;return l!==null?l:jn.pooledCache}function _d(l,u){u===null?q(io,io.current):q(io,u.pool)}function lv(){var l=Yh();return l===null?null:{parent:as._currentValue,pool:l}}var ol=Error(s(460)),Gh=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(Ra,Ra),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(Ra,Ra);else{if(l=jn,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 lo=u,ol}}function oo(l){try{var u=l._init;return u(l._payload)}catch(p){throw p!==null&&typeof p=="object"&&typeof p.then=="function"?(lo=p,ol):p}}var lo=null;function dv(){if(lo===null)throw Error(s(459));var l=lo;return lo=null,l}function fv(l){if(l===ol||l===Ed)throw Error(s(483))}var ll=null,jc=0;function Dd(l){var u=jc;return jc+=1,ll===null&&(ll=[]),uv(ll,l,u)}function Nc(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(ke,oe){if(l){var Ee=ke.deletions;Ee===null?(ke.deletions=[oe],ke.flags|=16):Ee.push(oe)}}function p(ke,oe){if(!l)return null;for(;oe!==null;)u(ke,oe),oe=oe.sibling;return null}function g(ke){for(var oe=new Map;ke!==null;)ke.key!==null?oe.set(ke.key,ke):oe.set(ke.index,ke),ke=ke.sibling;return oe}function v(ke,oe){return ke=yr(ke,oe),ke.index=0,ke.sibling=null,ke}function C(ke,oe,Ee){return ke.index=Ee,l?(Ee=ke.alternate,Ee!==null?(Ee=Ee.index,Ee<oe?(ke.flags|=67108866,oe):Ee):(ke.flags|=67108866,oe)):(ke.flags|=1048576,oe)}function I(ke){return l&&ke.alternate===null&&(ke.flags|=67108866),ke}function Y(ke,oe,Ee,Ge){return oe===null||oe.tag!==6?(oe=Ih(Ee,ke.mode,Ge),oe.return=ke,oe):(oe=v(oe,Ee),oe.return=ke,oe)}function re(ke,oe,Ee,Ge){var Tt=Ee.type;return Tt===A?Ve(ke,oe,Ee.props.children,Ge,Ee.key):oe!==null&&(oe.elementType===Tt||typeof Tt=="object"&&Tt!==null&&Tt.$$typeof===O&&oo(Tt)===oe.type)?(oe=v(oe,Ee.props),Nc(oe,Ee),oe.return=ke,oe):(oe=Ad(Ee.type,Ee.key,Ee.props,null,ke.mode,Ge),Nc(oe,Ee),oe.return=ke,oe)}function Re(ke,oe,Ee,Ge){return oe===null||oe.tag!==4||oe.stateNode.containerInfo!==Ee.containerInfo||oe.stateNode.implementation!==Ee.implementation?(oe=Ph(Ee,ke.mode,Ge),oe.return=ke,oe):(oe=v(oe,Ee.children||[]),oe.return=ke,oe)}function Ve(ke,oe,Ee,Ge,Tt){return oe===null||oe.tag!==7?(oe=no(Ee,ke.mode,Ge,Tt),oe.return=ke,oe):(oe=v(oe,Ee),oe.return=ke,oe)}function Qe(ke,oe,Ee){if(typeof oe=="string"&&oe!==""||typeof oe=="number"||typeof oe=="bigint")return oe=Ih(""+oe,ke.mode,Ee),oe.return=ke,oe;if(typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case y:return Ee=Ad(oe.type,oe.key,oe.props,null,ke.mode,Ee),Nc(Ee,oe),Ee.return=ke,Ee;case w:return oe=Ph(oe,ke.mode,Ee),oe.return=ke,oe;case O:return oe=oo(oe),Qe(ke,oe,Ee)}if(L(oe)||F(oe))return oe=no(oe,ke.mode,Ee,null),oe.return=ke,oe;if(typeof oe.then=="function")return Qe(ke,Dd(oe),Ee);if(oe.$$typeof===S)return Qe(ke,Td(ke,oe),Ee);Rd(ke,oe)}return null}function Ie(ke,oe,Ee,Ge){var Tt=oe!==null?oe.key:null;if(typeof Ee=="string"&&Ee!==""||typeof Ee=="number"||typeof Ee=="bigint")return Tt!==null?null:Y(ke,oe,""+Ee,Ge);if(typeof Ee=="object"&&Ee!==null){switch(Ee.$$typeof){case y:return Ee.key===Tt?re(ke,oe,Ee,Ge):null;case w:return Ee.key===Tt?Re(ke,oe,Ee,Ge):null;case O:return Ee=oo(Ee),Ie(ke,oe,Ee,Ge)}if(L(Ee)||F(Ee))return Tt!==null?null:Ve(ke,oe,Ee,Ge,null);if(typeof Ee.then=="function")return Ie(ke,oe,Dd(Ee),Ge);if(Ee.$$typeof===S)return Ie(ke,oe,Td(ke,Ee),Ge);Rd(ke,Ee)}return null}function $e(ke,oe,Ee,Ge,Tt){if(typeof Ge=="string"&&Ge!==""||typeof Ge=="number"||typeof Ge=="bigint")return ke=ke.get(Ee)||null,Y(oe,ke,""+Ge,Tt);if(typeof Ge=="object"&&Ge!==null){switch(Ge.$$typeof){case y:return ke=ke.get(Ge.key===null?Ee:Ge.key)||null,re(oe,ke,Ge,Tt);case w:return ke=ke.get(Ge.key===null?Ee:Ge.key)||null,Re(oe,ke,Ge,Tt);case O:return Ge=oo(Ge),$e(ke,oe,Ee,Ge,Tt)}if(L(Ge)||F(Ge))return ke=ke.get(Ee)||null,Ve(oe,ke,Ge,Tt,null);if(typeof Ge.then=="function")return $e(ke,oe,Ee,Dd(Ge),Tt);if(Ge.$$typeof===S)return $e(ke,oe,Ee,Td(oe,Ge),Tt);Rd(oe,Ge)}return null}function vt(ke,oe,Ee,Ge){for(var Tt=null,pn=null,St=oe,Ht=oe=0,an=null;St!==null&&Ht<Ee.length;Ht++){St.index>Ht?(an=St,St=null):an=St.sibling;var hn=Ie(ke,St,Ee[Ht],Ge);if(hn===null){St===null&&(St=an);break}l&&St&&hn.alternate===null&&u(ke,St),oe=C(hn,oe,Ht),pn===null?Tt=hn:pn.sibling=hn,pn=hn,St=an}if(Ht===Ee.length)return p(ke,St),on&&vr(ke,Ht),Tt;if(St===null){for(;Ht<Ee.length;Ht++)St=Qe(ke,Ee[Ht],Ge),St!==null&&(oe=C(St,oe,Ht),pn===null?Tt=St:pn.sibling=St,pn=St);return on&&vr(ke,Ht),Tt}for(St=g(St);Ht<Ee.length;Ht++)an=$e(St,ke,Ht,Ee[Ht],Ge),an!==null&&(l&&an.alternate!==null&&St.delete(an.key===null?Ht:an.key),oe=C(an,oe,Ht),pn===null?Tt=an:pn.sibling=an,pn=an);return l&&St.forEach(function(ji){return u(ke,ji)}),on&&vr(ke,Ht),Tt}function Rt(ke,oe,Ee,Ge){if(Ee==null)throw Error(s(151));for(var Tt=null,pn=null,St=oe,Ht=oe=0,an=null,hn=Ee.next();St!==null&&!hn.done;Ht++,hn=Ee.next()){St.index>Ht?(an=St,St=null):an=St.sibling;var ji=Ie(ke,St,hn.value,Ge);if(ji===null){St===null&&(St=an);break}l&&St&&ji.alternate===null&&u(ke,St),oe=C(ji,oe,Ht),pn===null?Tt=ji:pn.sibling=ji,pn=ji,St=an}if(hn.done)return p(ke,St),on&&vr(ke,Ht),Tt;if(St===null){for(;!hn.done;Ht++,hn=Ee.next())hn=Qe(ke,hn.value,Ge),hn!==null&&(oe=C(hn,oe,Ht),pn===null?Tt=hn:pn.sibling=hn,pn=hn);return on&&vr(ke,Ht),Tt}for(St=g(St);!hn.done;Ht++,hn=Ee.next())hn=$e(St,ke,Ht,hn.value,Ge),hn!==null&&(l&&hn.alternate!==null&&St.delete(hn.key===null?Ht:hn.key),oe=C(hn,oe,Ht),pn===null?Tt=hn:pn.sibling=hn,pn=hn);return l&&St.forEach(function(TE){return u(ke,TE)}),on&&vr(ke,Ht),Tt}function An(ke,oe,Ee,Ge){if(typeof Ee=="object"&&Ee!==null&&Ee.type===A&&Ee.key===null&&(Ee=Ee.props.children),typeof Ee=="object"&&Ee!==null){switch(Ee.$$typeof){case y:e:{for(var Tt=Ee.key;oe!==null;){if(oe.key===Tt){if(Tt=Ee.type,Tt===A){if(oe.tag===7){p(ke,oe.sibling),Ge=v(oe,Ee.props.children),Ge.return=ke,ke=Ge;break e}}else if(oe.elementType===Tt||typeof Tt=="object"&&Tt!==null&&Tt.$$typeof===O&&oo(Tt)===oe.type){p(ke,oe.sibling),Ge=v(oe,Ee.props),Nc(Ge,Ee),Ge.return=ke,ke=Ge;break e}p(ke,oe);break}else u(ke,oe);oe=oe.sibling}Ee.type===A?(Ge=no(Ee.props.children,ke.mode,Ge,Ee.key),Ge.return=ke,ke=Ge):(Ge=Ad(Ee.type,Ee.key,Ee.props,null,ke.mode,Ge),Nc(Ge,Ee),Ge.return=ke,ke=Ge)}return I(ke);case w:e:{for(Tt=Ee.key;oe!==null;){if(oe.key===Tt)if(oe.tag===4&&oe.stateNode.containerInfo===Ee.containerInfo&&oe.stateNode.implementation===Ee.implementation){p(ke,oe.sibling),Ge=v(oe,Ee.children||[]),Ge.return=ke,ke=Ge;break e}else{p(ke,oe);break}else u(ke,oe);oe=oe.sibling}Ge=Ph(Ee,ke.mode,Ge),Ge.return=ke,ke=Ge}return I(ke);case O:return Ee=oo(Ee),An(ke,oe,Ee,Ge)}if(L(Ee))return vt(ke,oe,Ee,Ge);if(F(Ee)){if(Tt=F(Ee),typeof Tt!="function")throw Error(s(150));return Ee=Tt.call(Ee),Rt(ke,oe,Ee,Ge)}if(typeof Ee.then=="function")return An(ke,oe,Dd(Ee),Ge);if(Ee.$$typeof===S)return An(ke,oe,Td(ke,Ee),Ge);Rd(ke,Ee)}return typeof Ee=="string"&&Ee!==""||typeof Ee=="number"||typeof Ee=="bigint"?(Ee=""+Ee,oe!==null&&oe.tag===6?(p(ke,oe.sibling),Ge=v(oe,Ee),Ge.return=ke,ke=Ge):(p(ke,oe),Ge=Ih(Ee,ke.mode,Ge),Ge.return=ke,ke=Ge),I(ke)):p(ke,oe)}return function(ke,oe,Ee,Ge){try{jc=0;var Tt=An(ke,oe,Ee,Ge);return ll=null,Tt}catch(St){if(St===ol||St===Ed)throw St;var pn=Zs(29,St,null,ke.mode);return pn.lanes=Ge,pn.return=ke,pn}finally{}}}var co=pv(!0),hv=pv(!1),ci=!1;function Kh(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Qh(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 ui(l){return{lane:l,tag:0,payload:null,callback:null,next:null}}function di(l,u,p){var g=l.updateQueue;if(g===null)return null;if(g=g.shared,(mn&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 Tc(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,Et(l,p)}}function Xh(l,u){var p=l.updateQueue,g=l.alternate;if(g!==null&&(g=g.updateQueue,p===g)){var v=null,C=null;if(p=p.firstBaseUpdate,p!==null){do{var I={lane:p.lane,tag:p.tag,payload:p.payload,callback:null,next:null};C===null?v=C=I:C=C.next=I,p=p.next}while(p!==null);C===null?v=C=u:C=C.next=u}else v=C=u;p={baseState:g.baseState,firstBaseUpdate:v,lastBaseUpdate:C,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 Jh=!1;function _c(){if(Jh){var l=il;if(l!==null)throw l}}function Ec(l,u,p,g){Jh=!1;var v=l.updateQueue;ci=!1;var C=v.firstBaseUpdate,I=v.lastBaseUpdate,Y=v.shared.pending;if(Y!==null){v.shared.pending=null;var re=Y,Re=re.next;re.next=null,I===null?C=Re:I.next=Re,I=re;var Ve=l.alternate;Ve!==null&&(Ve=Ve.updateQueue,Y=Ve.lastBaseUpdate,Y!==I&&(Y===null?Ve.firstBaseUpdate=Re:Y.next=Re,Ve.lastBaseUpdate=re))}if(C!==null){var Qe=v.baseState;I=0,Ve=Re=re=null,Y=C;do{var Ie=Y.lane&-536870913,$e=Ie!==Y.lane;if($e?(sn&Ie)===Ie:(g&Ie)===Ie){Ie!==0&&Ie===rl&&(Jh=!0),Ve!==null&&(Ve=Ve.next={lane:0,tag:Y.tag,payload:Y.payload,callback:null,next:null});e:{var vt=l,Rt=Y;Ie=u;var An=p;switch(Rt.tag){case 1:if(vt=Rt.payload,typeof vt=="function"){Qe=vt.call(An,Qe,Ie);break e}Qe=vt;break e;case 3:vt.flags=vt.flags&-65537|128;case 0:if(vt=Rt.payload,Ie=typeof vt=="function"?vt.call(An,Qe,Ie):vt,Ie==null)break e;Qe=m({},Qe,Ie);break e;case 2:ci=!0}}Ie=Y.callback,Ie!==null&&(l.flags|=64,$e&&(l.flags|=8192),$e=v.callbacks,$e===null?v.callbacks=[Ie]:$e.push(Ie))}else $e={lane:Ie,tag:Y.tag,payload:Y.payload,callback:Y.callback,next:null},Ve===null?(Re=Ve=$e,re=Qe):Ve=Ve.next=$e,I|=Ie;if(Y=Y.next,Y===null){if(Y=v.shared.pending,Y===null)break;$e=Y,Y=$e.next,$e.next=null,v.lastBaseUpdate=$e,v.shared.pending=null}}while(!0);Ve===null&&(re=Qe),v.baseState=re,v.firstBaseUpdate=Re,v.lastBaseUpdate=Ve,C===null&&(v.shared.lanes=0),gi|=I,l.lanes=I,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 cl=K(null),Od=K(0);function bv(l,u){l=Mr,q(Od,l),q(cl,u),Mr=l|u.baseLanes}function Zh(){q(Od,Mr),q(cl,cl.current)}function em(){Mr=Od.current,se(cl),se(Od)}var ea=K(null),ka=null;function fi(l){var u=l.alternate;q(Xn,Xn.current&1),q(ea,l),ka===null&&(u===null||cl.current!==null||u.memoizedState!==null)&&(ka=l)}function tm(l){q(Xn,Xn.current),q(ea,l),ka===null&&(ka=l)}function xv(l){l.tag===22?(q(Xn,Xn.current),q(ea,l),ka===null&&(ka=l)):pi()}function pi(){q(Xn,Xn.current),q(ea,ea.current)}function ta(l){se(ea),ka===l&&(ka=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||og(p)||lg(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,rs=null,Id=!1,ul=!1,uo=!1,Pd=0,Mc=0,dl=null,x_=0;function Vn(){throw Error(s(321))}function nm(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 sm(l,u,p,g,v,C){return Sr=C,Ut=u,u.memoizedState=null,u.updateQueue=null,u.lanes=0,z.H=l===null||l.memoizedState===null?tw:xm,uo=!1,C=p(g,v),uo=!1,ul&&(C=vv(u,p,g,v)),yv(l),C}function yv(l){z.H=Oc;var u=Sn!==null&&Sn.next!==null;if(Sr=0,rs=Sn=Ut=null,Id=!1,Mc=0,dl=null,u)throw Error(s(300));l===null||is||(l=l.dependencies,l!==null&&Nd(l)&&(is=!0))}function vv(l,u,p,g){Ut=l;var v=0;do{if(ul&&(dl=null),Mc=0,ul=!1,25<=v)throw Error(s(301));if(v+=1,rs=Sn=null,l.updateQueue!=null){var C=l.updateQueue;C.lastEffect=null,C.events=null,C.stores=null,C.memoCache!=null&&(C.memoCache.index=0)}z.H=nw,C=u(p,g)}while(ul);return C}function y_(){var l=z.H,u=l.useState()[0];return u=typeof u.then=="function"?Dc(u):u,l=l.useState()[0],(Sn!==null?Sn.memoizedState:null)!==l&&(Ut.flags|=1024),u}function am(){var l=Pd!==0;return Pd=0,l}function rm(l,u,p){u.updateQueue=l.updateQueue,u.flags&=-2053,l.lanes&=~p}function im(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,rs=Sn=Ut=null,ul=!1,Mc=Pd=0,dl=null}function Ms(){var l={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return rs===null?Ut.memoizedState=rs=l:rs=rs.next=l,rs}function Jn(){if(Sn===null){var l=Ut.alternate;l=l!==null?l.memoizedState:null}else l=Sn.next;var u=rs===null?Ut.memoizedState:rs.next;if(u!==null)rs=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},rs===null?Ut.memoizedState=rs=l:rs=rs.next=l}return rs}function Bd(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Dc(l){var u=Mc;return Mc+=1,dl===null&&(dl=[]),l=uv(dl,l,u),u=Ut,(rs===null?u.memoizedState:rs.next)===null&&(u=u.alternate,z.H=u===null||u.memoizedState===null?tw:xm),l}function Fd(l){if(l!==null&&typeof l=="object"){if(typeof l.then=="function")return Dc(l);if(l.$$typeof===S)return ys(l)}throw Error(s(438,String(l)))}function om(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 lm(u,Sn,l)}function lm(l,u,p){var g=l.queue;if(g===null)throw Error(s(311));g.lastRenderedReducer=p;var v=l.baseQueue,C=g.pending;if(C!==null){if(v!==null){var I=v.next;v.next=C.next,C.next=I}u.baseQueue=v=C,g.pending=null}if(C=l.baseState,v===null)l.memoizedState=C;else{u=v.next;var Y=I=null,re=null,Re=u,Ve=!1;do{var Qe=Re.lane&-536870913;if(Qe!==Re.lane?(sn&Qe)===Qe:(Sr&Qe)===Qe){var Ie=Re.revertLane;if(Ie===0)re!==null&&(re=re.next={lane:0,revertLane:0,gesture:null,action:Re.action,hasEagerState:Re.hasEagerState,eagerState:Re.eagerState,next:null}),Qe===rl&&(Ve=!0);else if((Sr&Ie)===Ie){Re=Re.next,Ie===rl&&(Ve=!0);continue}else Qe={lane:0,revertLane:Re.revertLane,gesture:null,action:Re.action,hasEagerState:Re.hasEagerState,eagerState:Re.eagerState,next:null},re===null?(Y=re=Qe,I=C):re=re.next=Qe,Ut.lanes|=Ie,gi|=Ie;Qe=Re.action,uo&&p(C,Qe),C=Re.hasEagerState?Re.eagerState:p(C,Qe)}else Ie={lane:Qe,revertLane:Re.revertLane,gesture:Re.gesture,action:Re.action,hasEagerState:Re.hasEagerState,eagerState:Re.eagerState,next:null},re===null?(Y=re=Ie,I=C):re=re.next=Ie,Ut.lanes|=Qe,gi|=Qe;Re=Re.next}while(Re!==null&&Re!==u);if(re===null?I=C:re.next=Y,!Js(C,l.memoizedState)&&(is=!0,Ve&&(p=il,p!==null)))throw p;l.memoizedState=C,l.baseState=I,l.baseQueue=re,g.lastRenderedState=C}return v===null&&(g.lanes=0),[l.memoizedState,g.dispatch]}function cm(l){var u=Jn(),p=u.queue;if(p===null)throw Error(s(311));p.lastRenderedReducer=l;var g=p.dispatch,v=p.pending,C=u.memoizedState;if(v!==null){p.pending=null;var I=v=v.next;do C=l(C,I.action),I=I.next;while(I!==v);Js(C,u.memoizedState)||(is=!0),u.memoizedState=C,u.baseQueue===null&&(u.baseState=C),p.lastRenderedState=C}return[C,g]}function wv(l,u,p){var g=Ut,v=Jn(),C=on;if(C){if(p===void 0)throw Error(s(407));p=p()}else p=u();var I=!Js((Sn||v).memoizedState,p);if(I&&(v.memoizedState=p,is=!0),v=v.queue,fm(Cv.bind(null,g,v,l),[l]),v.getSnapshot!==u||I||rs!==null&&rs.memoizedState.tag&1){if(g.flags|=2048,fl(9,{destroy:void 0},Sv.bind(null,g,v,p,u),null),jn===null)throw Error(s(349));C||(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=to(l,2);u!==null&&Us(u,l,2)}function um(l){var u=Ms();if(typeof l=="function"){var p=l;if(l=p(),uo){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,lm(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 C={payload:v,action:l,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(I){C.listeners.push(I)}};z.T!==null?p(!0):C.isTransition=!1,g(C),p=u.pending,p===null?(C.next=u.pending=C,Tv(u,C)):(C.next=p.next,u.pending=p.next=C)}}function Tv(l,u){var p=u.action,g=u.payload,v=l.state;if(u.isTransition){var C=z.T,I={};z.T=I;try{var Y=p(v,g),re=z.S;re!==null&&re(I,Y),_v(l,u,Y)}catch(Re){dm(l,u,Re)}finally{C!==null&&I.types!==null&&(C.types=I.types),z.T=C}}else try{C=p(v,g),_v(l,u,C)}catch(Re){dm(l,u,Re)}}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 dm(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 dm(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(on){var p=jn.formState;if(p!==null){e:{var g=Ut;if(on){if(Ln){t:{for(var v=Ln,C=wa;v.nodeType!==8;){if(!C){v=null;break t}if(v=Sa(v.nextSibling),v===null){v=null;break t}}C=v.data,v=C==="F!"||C==="F"?v:null}if(v){Ln=Sa(v.nextSibling),g=v.data==="F!";break e}}oi(g)}g=!1}g&&(u=p[0])}}return p=Ms(),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=um(!1),C=bm.bind(null,Ut,!1,g.queue),g=Ms(),v={state:u,dispatch:null,action:l,pending:null},g.queue=v,p=v_.bind(null,Ut,v,C,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=lm(l,u,Dv)[0],l=zd(Cr)[0],typeof u=="object"&&u!==null&&typeof u.then=="function")try{var g=Dc(u)}catch(I){throw I===ol?Ed:I}else g=u;u=Jn();var v=u.queue,C=v.dispatch;return p!==u.memoizedState&&(Ut.flags|=2048,fl(9,{destroy:void 0},w_.bind(null,v,p),null)),[g,C,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 fl(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=Ms();Ut.flags|=l,v.memoizedState=fl(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 C=v.memoizedState.inst;Sn!==null&&g!==null&&nm(g,Sn.memoizedState.deps)?v.memoizedState=fl(u,C,p,g):(Ut.flags|=l,v.memoizedState=fl(1|u,C,p,g))}function Bv(l,u){$d(8390656,8,l,u)}function fm(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((mn&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 pm(){}function Wv(l,u){var p=Jn();u=u===void 0?null:u;var g=p.memoizedState;return u!==null&&nm(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&&nm(u,g[1]))return g[0];if(g=l(),uo){te(!0);try{l()}finally{te(!1)}}return p.memoizedState=[g,u],g}function hm(l,u,p){return p===void 0||(Sr&1073741824)!==0&&(sn&261930)===0?l.memoizedState=u:(l.memoizedState=p,l=Vw(),Ut.lanes|=l,gi|=l,p)}function Vv(l,u,p,g){return Js(p,u)?p:cl.current!==null?(l=hm(l,p,g),Js(l,u)||(is=!0),l):(Sr&42)===0||(Sr&1073741824)!==0&&(sn&261930)===0?(is=!0,l.memoizedState=p):(l=Vw(),Ut.lanes|=l,gi|=l,u)}function Yv(l,u,p,g,v){var C=W.p;W.p=C!==0&&8>C?C:8;var I=z.T,Y={};z.T=Y,bm(l,!1,u,p);try{var re=v(),Re=z.S;if(Re!==null&&Re(Y,re),re!==null&&typeof re=="object"&&typeof re.then=="function"){var Ve=b_(re,g);Rc(l,u,Ve,aa(l))}else Rc(l,u,g,aa(l))}catch(Qe){Rc(l,u,{then:function(){},status:"rejected",reason:Qe},aa())}finally{W.p=C,I!==null&&Y.types!==null&&(I.types=Y.types),z.T=I}}function S_(){}function mm(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),Rc(l,u.next.queue,{},aa())}function gm(){return ys(Qc)}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=ui(p);var g=di(u,l,p);g!==null&&(Us(g,u,p),Tc(g,u,p)),u={cache:qh()},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=Oh(l,u,p,g),p!==null&&(Us(p,l,g),ew(p,u,g)))}function Jv(l,u,p){var g=aa();Rc(l,u,p,g)}function Rc(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 C=l.alternate;if(l.lanes===0&&(C===null||C.lanes===0)&&(C=u.lastRenderedReducer,C!==null))try{var I=u.lastRenderedState,Y=C(I,p);if(v.hasEagerState=!0,v.eagerState=Y,Js(Y,I))return Sd(l,u,v,0),jn===null&&kd(),!1}catch{}finally{}if(p=Oh(l,u,v,g),p!==null)return Us(p,l,g),ew(p,u,g),!0}return!1}function bm(l,u,p,g){if(g={lane:2,revertLane:Km(),gesture:null,action:g,hasEagerState:!1,eagerState:null,next:null},Hd(l)){if(u)throw Error(s(479))}else u=Oh(l,p,g,2),u!==null&&Us(u,l,2)}function Hd(l){var u=l.alternate;return l===Ut||u!==null&&u===Ut}function Zv(l,u){ul=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,Et(l,p)}}var Oc={readContext:ys,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};Oc.useEffectEvent=Vn;var tw={readContext:ys,use:Fd,useCallback:function(l,u){return Ms().memoizedState=[l,u===void 0?null:u],l},useContext:ys,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=Ms();u=u===void 0?null:u;var g=l();if(uo){te(!0);try{l()}finally{te(!1)}}return p.memoizedState=[g,u],g},useReducer:function(l,u,p){var g=Ms();if(p!==void 0){var v=p(u);if(uo){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=Ms();return l={current:l},u.memoizedState=l},useState:function(l){l=um(l);var u=l.queue,p=Jv.bind(null,Ut,u);return u.dispatch=p,[l.memoizedState,p]},useDebugValue:pm,useDeferredValue:function(l,u){var p=Ms();return hm(p,l,u)},useTransition:function(){var l=um(!1);return l=Yv.bind(null,Ut,l.queue,!0,!1),Ms().memoizedState=l,[!1,l]},useSyncExternalStore:function(l,u,p){var g=Ut,v=Ms();if(on){if(p===void 0)throw Error(s(407));p=p()}else{if(p=u(),jn===null)throw Error(s(349));(sn&127)!==0||kv(g,u,p)}v.memoizedState=p;var C={value:p,getSnapshot:u};return v.queue=C,Bv(Cv.bind(null,g,C,l),[l]),g.flags|=2048,fl(9,{destroy:void 0},Sv.bind(null,g,C,p,u),null),p},useId:function(){var l=Ms(),u=jn.identifierPrefix;if(on){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:gm,useFormState:Rv,useActionState:Rv,useOptimistic:function(l){var u=Ms();u.memoizedState=u.baseState=l;var p={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return u.queue=p,u=bm.bind(null,Ut,!0,p),p.dispatch=u,[l,u]},useMemoCache:om,useCacheRefresh:function(){return Ms().memoizedState=C_.bind(null,Ut)},useEffectEvent:function(l){var u=Ms(),p={impl:l};return u.memoizedState=p,function(){if((mn&2)!==0)throw Error(s(440));return p.impl.apply(void 0,arguments)}}},xm={readContext:ys,use:Fd,useCallback:Wv,useContext:ys,useEffect:fm,useImperativeHandle:Hv,useInsertionEffect:zv,useLayoutEffect:$v,useMemo:qv,useReducer:zd,useRef:Pv,useState:function(){return zd(Cr)},useDebugValue:pm,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:Dc(l),u]},useSyncExternalStore:wv,useId:Qv,useHostTransitionStatus:gm,useFormState:Ov,useActionState:Ov,useOptimistic:function(l,u){var p=Jn();return Nv(p,Sn,l,u)},useMemoCache:om,useCacheRefresh:Xv};xm.useEffectEvent=Fv;var nw={readContext:ys,use:Fd,useCallback:Wv,useContext:ys,useEffect:fm,useImperativeHandle:Hv,useInsertionEffect:zv,useLayoutEffect:$v,useMemo:qv,useReducer:cm,useRef:Pv,useState:function(){return cm(Cr)},useDebugValue:pm,useDeferredValue:function(l,u){var p=Jn();return Sn===null?hm(p,l,u):Vv(p,Sn.memoizedState,l,u)},useTransition:function(){var l=cm(Cr)[0],u=Jn().memoizedState;return[typeof l=="boolean"?l:Dc(l),u]},useSyncExternalStore:wv,useId:Qv,useHostTransitionStatus:gm,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:om,useCacheRefresh:Xv};nw.useEffectEvent=Fv;function ym(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 vm={enqueueSetState:function(l,u,p){l=l._reactInternals;var g=aa(),v=ui(g);v.payload=u,p!=null&&(v.callback=p),u=di(l,v,g),u!==null&&(Us(u,l,g),Tc(u,l,g))},enqueueReplaceState:function(l,u,p){l=l._reactInternals;var g=aa(),v=ui(g);v.tag=1,v.payload=u,p!=null&&(v.callback=p),u=di(l,v,g),u!==null&&(Us(u,l,g),Tc(u,l,g))},enqueueForceUpdate:function(l,u){l=l._reactInternals;var p=aa(),g=ui(p);g.tag=2,u!=null&&(g.callback=u),u=di(l,g,p),u!==null&&(Us(u,l,p),Tc(u,l,p))}};function sw(l,u,p,g,v,C,I){return l=l.stateNode,typeof l.shouldComponentUpdate=="function"?l.shouldComponentUpdate(g,C,I):u.prototype&&u.prototype.isPureReactComponent?!vc(p,g)||!vc(v,C):!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&&vm.enqueueReplaceState(u,u.state,null)}function fo(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 wm(l,u,p){return p=ui(p),p.tag=3,p.payload={element:null},p.callback=function(){Wd(l,u)},p}function cw(l){return l=ui(l),l.tag=3,l}function uw(l,u,p,g){var v=p.type.getDerivedStateFromError;if(typeof v=="function"){var C=g.value;l.payload=function(){return v(C)},l.callback=function(){lw(u,p,g)}}var I=p.stateNode;I!==null&&typeof I.componentDidCatch=="function"&&(l.callback=function(){lw(u,p,g),typeof v!="function"&&(bi===null?bi=new Set([this]):bi.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&&al(u,p,v,!0),p=ea.current,p!==null){switch(p.tag){case 31:case 13:return ka===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),Vm(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)),Vm(l,g,v)),!1}throw Error(s(435,p.tag))}return Vm(l,g,v),nf(),!1}if(on)return u=ea.current,u!==null?((u.flags&65536)===0&&(u.flags|=256),u.flags|=65536,u.lanes=v,g!==zh&&(l=Error(s(422),{cause:g}),Sc(xa(l,p)))):(g!==zh&&(u=Error(s(423),{cause:g}),Sc(xa(u,p))),l=l.current.alternate,l.flags|=65536,v&=-v,l.lanes|=v,g=xa(g,p),v=wm(l.stateNode,g,v),Xh(l,v),Yn!==4&&(Yn=2)),!1;var C=Error(s(520),{cause:g});if(C=xa(C,p),Uc===null?Uc=[C]:Uc.push(C),Yn!==4&&(Yn=2),u===null)return!0;g=xa(g,p),p=u;do{switch(p.tag){case 3:return p.flags|=65536,l=v&-v,p.lanes|=l,l=wm(p.stateNode,g,l),Xh(p,l),!1;case 1:if(u=p.type,C=p.stateNode,(p.flags&128)===0&&(typeof u.getDerivedStateFromError=="function"||C!==null&&typeof C.componentDidCatch=="function"&&(bi===null||!bi.has(C))))return p.flags|=65536,v&=-v,p.lanes|=v,v=cw(v),uw(v,l,p,g),Xh(p,v),!1}p=p.return}while(p!==null);return!1}var km=Error(s(461)),is=!1;function vs(l,u,p,g){u.child=l===null?hv(u,null,p,g):co(u,l.child,p,g)}function dw(l,u,p,g,v){p=p.render;var C=u.ref;if("ref"in g){var I={};for(var Y in g)Y!=="ref"&&(I[Y]=g[Y])}else I=g;return ro(u),g=sm(l,u,p,I,C,v),Y=am(),l!==null&&!is?(rm(l,u,v),Ar(l,u,v)):(on&&Y&&Bh(u),u.flags|=1,vs(l,u,g,v),u.child)}function fw(l,u,p,g,v){if(l===null){var C=p.type;return typeof C=="function"&&!Lh(C)&&C.defaultProps===void 0&&p.compare===null?(u.tag=15,u.type=C,pw(l,u,C,g,v)):(l=Ad(p.type,null,g,u,u.mode,v),l.ref=u.ref,l.return=u,u.child=l)}if(C=l.child,!Em(l,v)){var I=C.memoizedProps;if(p=p.compare,p=p!==null?p:vc,p(I,g)&&l.ref===u.ref)return Ar(l,u,v)}return u.flags|=1,l=yr(C,g),l.ref=u.ref,l.return=u,u.child=l}function pw(l,u,p,g,v){if(l!==null){var C=l.memoizedProps;if(vc(C,g)&&l.ref===u.ref)if(is=!1,u.pendingProps=g=C,Em(l,v))(l.flags&131072)!==0&&(is=!0);else return u.lanes=l.lanes,Ar(l,u,v)}return Sm(l,u,p,g,v)}function hw(l,u,p,g){var v=g.children,C=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(C=C!==null?C.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&~C}else g=0,u.child=null;return mw(l,u,C,p,g)}if((p&536870912)!==0)u.memoizedState={baseLanes:0,cachePool:null},l!==null&&_d(u,C!==null?C.cachePool:null),C!==null?bv(u,C):Zh(),xv(u);else return g=u.lanes=536870912,mw(l,u,C!==null?C.baseLanes|p:p,p,g)}else C!==null?(_d(u,C.cachePool),bv(u,C),pi(),u.memoizedState=null):(l!==null&&_d(u,null),Zh(),pi());return vs(l,u,v,p),u.child}function Lc(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 C=Yh();return C=C===null?null:{parent:as._currentValue,pool:C},u.memoizedState={baseLanes:p,cachePool:C},l!==null&&_d(u,null),Zh(),xv(u),l!==null&&al(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 co(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(on){if(g.mode==="hidden")return l=qd(u,g),u.lanes=536870912,Lc(null,l);if(tm(u),(l=Ln)?(l=T0(l,wa),l=l!==null&&l.data==="&"?l:null,l!==null&&(u.memoizedState={dehydrated:l,treeContext:ri!==null?{id:Ya,overflow:Ga}:null,retryLane:536870912,hydrationErrors:null},p=Zy(l),p.return=u,u.child=p,xs=u,Ln=null)):l=null,l===null)throw oi(u);return u.lanes=536870912,null}return qd(u,g)}var C=l.memoizedState;if(C!==null){var I=C.dehydrated;if(tm(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(is||al(l,u,p,!1),v=(p&l.childLanes)!==0,is||v){if(g=jn,g!==null&&(I=$t(g,p),I!==0&&I!==C.retryLane))throw C.retryLane=I,to(l,I),Us(g,l,I),km;nf(),u=gw(l,u,p)}else l=C.treeContext,Ln=Sa(I.nextSibling),xs=u,on=!0,ii=null,wa=!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 Sm(l,u,p,g,v){return ro(u),p=sm(l,u,p,g,void 0,v),g=am(),l!==null&&!is?(rm(l,u,v),Ar(l,u,v)):(on&&g&&Bh(u),u.flags|=1,vs(l,u,p,v),u.child)}function bw(l,u,p,g,v,C){return ro(u),u.updateQueue=null,p=vv(u,g,p,v),yv(l),g=am(),l!==null&&!is?(rm(l,u,C),Ar(l,u,C)):(on&&g&&Bh(u),u.flags|=1,vs(l,u,p,C),u.child)}function xw(l,u,p,g,v){if(ro(u),u.stateNode===null){var C=el,I=p.contextType;typeof I=="object"&&I!==null&&(C=ys(I)),C=new p(g,C),u.memoizedState=C.state!==null&&C.state!==void 0?C.state:null,C.updater=vm,u.stateNode=C,C._reactInternals=u,C=u.stateNode,C.props=g,C.state=u.memoizedState,C.refs={},Kh(u),I=p.contextType,C.context=typeof I=="object"&&I!==null?ys(I):el,C.state=u.memoizedState,I=p.getDerivedStateFromProps,typeof I=="function"&&(ym(u,p,I,g),C.state=u.memoizedState),typeof p.getDerivedStateFromProps=="function"||typeof C.getSnapshotBeforeUpdate=="function"||typeof C.UNSAFE_componentWillMount!="function"&&typeof C.componentWillMount!="function"||(I=C.state,typeof C.componentWillMount=="function"&&C.componentWillMount(),typeof C.UNSAFE_componentWillMount=="function"&&C.UNSAFE_componentWillMount(),I!==C.state&&vm.enqueueReplaceState(C,C.state,null),Ec(u,g,C,v),_c(),C.state=u.memoizedState),typeof C.componentDidMount=="function"&&(u.flags|=4194308),g=!0}else if(l===null){C=u.stateNode;var Y=u.memoizedProps,re=fo(p,Y);C.props=re;var Re=C.context,Ve=p.contextType;I=el,typeof Ve=="object"&&Ve!==null&&(I=ys(Ve));var Qe=p.getDerivedStateFromProps;Ve=typeof Qe=="function"||typeof C.getSnapshotBeforeUpdate=="function",Y=u.pendingProps!==Y,Ve||typeof C.UNSAFE_componentWillReceiveProps!="function"&&typeof C.componentWillReceiveProps!="function"||(Y||Re!==I)&&aw(u,C,g,I),ci=!1;var Ie=u.memoizedState;C.state=Ie,Ec(u,g,C,v),_c(),Re=u.memoizedState,Y||Ie!==Re||ci?(typeof Qe=="function"&&(ym(u,p,Qe,g),Re=u.memoizedState),(re=ci||sw(u,p,re,g,Ie,Re,I))?(Ve||typeof C.UNSAFE_componentWillMount!="function"&&typeof C.componentWillMount!="function"||(typeof C.componentWillMount=="function"&&C.componentWillMount(),typeof C.UNSAFE_componentWillMount=="function"&&C.UNSAFE_componentWillMount()),typeof C.componentDidMount=="function"&&(u.flags|=4194308)):(typeof C.componentDidMount=="function"&&(u.flags|=4194308),u.memoizedProps=g,u.memoizedState=Re),C.props=g,C.state=Re,C.context=I,g=re):(typeof C.componentDidMount=="function"&&(u.flags|=4194308),g=!1)}else{C=u.stateNode,Qh(l,u),I=u.memoizedProps,Ve=fo(p,I),C.props=Ve,Qe=u.pendingProps,Ie=C.context,Re=p.contextType,re=el,typeof Re=="object"&&Re!==null&&(re=ys(Re)),Y=p.getDerivedStateFromProps,(Re=typeof Y=="function"||typeof C.getSnapshotBeforeUpdate=="function")||typeof C.UNSAFE_componentWillReceiveProps!="function"&&typeof C.componentWillReceiveProps!="function"||(I!==Qe||Ie!==re)&&aw(u,C,g,re),ci=!1,Ie=u.memoizedState,C.state=Ie,Ec(u,g,C,v),_c();var $e=u.memoizedState;I!==Qe||Ie!==$e||ci||l!==null&&l.dependencies!==null&&Nd(l.dependencies)?(typeof Y=="function"&&(ym(u,p,Y,g),$e=u.memoizedState),(Ve=ci||sw(u,p,Ve,g,Ie,$e,re)||l!==null&&l.dependencies!==null&&Nd(l.dependencies))?(Re||typeof C.UNSAFE_componentWillUpdate!="function"&&typeof C.componentWillUpdate!="function"||(typeof C.componentWillUpdate=="function"&&C.componentWillUpdate(g,$e,re),typeof C.UNSAFE_componentWillUpdate=="function"&&C.UNSAFE_componentWillUpdate(g,$e,re)),typeof C.componentDidUpdate=="function"&&(u.flags|=4),typeof C.getSnapshotBeforeUpdate=="function"&&(u.flags|=1024)):(typeof C.componentDidUpdate!="function"||I===l.memoizedProps&&Ie===l.memoizedState||(u.flags|=4),typeof C.getSnapshotBeforeUpdate!="function"||I===l.memoizedProps&&Ie===l.memoizedState||(u.flags|=1024),u.memoizedProps=g,u.memoizedState=$e),C.props=g,C.state=$e,C.context=re,g=Ve):(typeof C.componentDidUpdate!="function"||I===l.memoizedProps&&Ie===l.memoizedState||(u.flags|=4),typeof C.getSnapshotBeforeUpdate!="function"||I===l.memoizedProps&&Ie===l.memoizedState||(u.flags|=1024),g=!1)}return C=g,Vd(l,u),g=(u.flags&128)!==0,C||g?(C=u.stateNode,p=g&&typeof p.getDerivedStateFromError!="function"?null:C.render(),u.flags|=1,l!==null&&g?(u.child=co(u,l.child,null,v),u.child=co(u,null,p,v)):vs(l,u,p,v),u.memoizedState=C.state,l=u.child):l=Ar(l,u,v),l}function yw(l,u,p,g){return so(),u.flags|=256,vs(l,u,p,g),u.child}var Cm={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Am(l){return{baseLanes:l,cachePool:lv()}}function jm(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,C=(u.flags&128)!==0,I;if((I=C)||(I=l!==null&&l.memoizedState===null?!1:(Xn.current&2)!==0),I&&(v=!0,u.flags&=-129),I=(u.flags&32)!==0,u.flags&=-33,l===null){if(on){if(v?fi(u):pi(),(l=Ln)?(l=T0(l,wa),l=l!==null&&l.data!=="&"?l:null,l!==null&&(u.memoizedState={dehydrated:l,treeContext:ri!==null?{id:Ya,overflow:Ga}:null,retryLane:536870912,hydrationErrors:null},p=Zy(l),p.return=u,u.child=p,xs=u,Ln=null)):l=null,l===null)throw oi(u);return lg(l)?u.lanes=32:u.lanes=536870912,null}var Y=g.children;return g=g.fallback,v?(pi(),v=u.mode,Y=Yd({mode:"hidden",children:Y},v),g=no(g,v,p,null),Y.return=u,g.return=u,Y.sibling=g,u.child=Y,g=u.child,g.memoizedState=Am(p),g.childLanes=jm(l,I,p),u.memoizedState=Cm,Lc(null,g)):(fi(u),Nm(u,Y))}var re=l.memoizedState;if(re!==null&&(Y=re.dehydrated,Y!==null)){if(C)u.flags&256?(fi(u),u.flags&=-257,u=Tm(l,u,p)):u.memoizedState!==null?(pi(),u.child=l.child,u.flags|=128,u=null):(pi(),Y=g.fallback,v=u.mode,g=Yd({mode:"visible",children:g.children},v),Y=no(Y,v,p,null),Y.flags|=2,g.return=u,Y.return=u,g.sibling=Y,u.child=g,co(u,l.child,null,p),g=u.child,g.memoizedState=Am(p),g.childLanes=jm(l,I,p),u.memoizedState=Cm,u=Lc(null,g));else if(fi(u),lg(Y)){if(I=Y.nextSibling&&Y.nextSibling.dataset,I)var Re=I.dgst;I=Re,g=Error(s(419)),g.stack="",g.digest=I,Sc({value:g,source:null,stack:null}),u=Tm(l,u,p)}else if(is||al(l,u,p,!1),I=(p&l.childLanes)!==0,is||I){if(I=jn,I!==null&&(g=$t(I,p),g!==0&&g!==re.retryLane))throw re.retryLane=g,to(l,g),Us(I,l,g),km;og(Y)||nf(),u=Tm(l,u,p)}else og(Y)?(u.flags|=192,u.child=l.child,u=null):(l=re.treeContext,Ln=Sa(Y.nextSibling),xs=u,on=!0,ii=null,wa=!1,l!==null&&nv(u,l),u=Nm(u,g.children),u.flags|=4096);return u}return v?(pi(),Y=g.fallback,v=u.mode,re=l.child,Re=re.sibling,g=yr(re,{mode:"hidden",children:g.children}),g.subtreeFlags=re.subtreeFlags&65011712,Re!==null?Y=yr(Re,Y):(Y=no(Y,v,p,null),Y.flags|=2),Y.return=u,g.return=u,g.sibling=Y,u.child=g,Lc(null,g),g=u.child,Y=l.child.memoizedState,Y===null?Y=Am(p):(v=Y.cachePool,v!==null?(re=as._currentValue,v=v.parent!==re?{parent:re,pool:re}:v):v=lv(),Y={baseLanes:Y.baseLanes|p,cachePool:v}),g.memoizedState=Y,g.childLanes=jm(l,I,p),u.memoizedState=Cm,Lc(l.child,g)):(fi(u),p=l.child,l=p.sibling,p=yr(p,{mode:"visible",children:g.children}),p.return=u,p.sibling=null,l!==null&&(I=u.deletions,I===null?(u.deletions=[l],u.flags|=16):I.push(l)),u.child=p,u.memoizedState=null,p)}function Nm(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 Tm(l,u,p){return co(u,l.child,null,p),l=Nm(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),Hh(l.return,u,p)}function _m(l,u,p,g,v,C){var I=l.memoizedState;I===null?l.memoizedState={isBackwards:u,rendering:null,renderingStartTime:0,last:g,tail:p,tailMode:v,treeForkCount:C}:(I.isBackwards=u,I.rendering=null,I.renderingStartTime=0,I.last=g,I.tail=p,I.tailMode=v,I.treeForkCount=C)}function kw(l,u,p){var g=u.pendingProps,v=g.revealOrder,C=g.tail;g=g.children;var I=Xn.current,Y=(I&2)!==0;if(Y?(I=I&1|2,u.flags|=128):I&=1,q(Xn,I),vs(l,u,g,p),g=on?kc: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),_m(u,!1,v,p,C,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}_m(u,!0,p,null,C,g);break;case"together":_m(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),gi|=u.lanes,(p&u.childLanes)===0)if(l!==null){if(al(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 Em(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:Ne(u,u.stateNode.containerInfo),li(u,as,l.memoizedState.cache),so();break;case 27:case 5:Me(u);break;case 4:Ne(u,u.stateNode.containerInfo);break;case 10:li(u,u.type,u.memoizedProps.value);break;case 31:if(u.memoizedState!==null)return u.flags|=128,tm(u),null;break;case 13:var g=u.memoizedState;if(g!==null)return g.dehydrated!==null?(fi(u),u.flags|=128,null):(p&u.child.childLanes)!==0?vw(l,u,p):(fi(u),l=Ar(l,u,p),l!==null?l.sibling:null);fi(u);break;case 19:var v=(l.flags&128)!==0;if(g=(p&u.childLanes)!==0,g||(al(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:li(u,as,l.memoizedState.cache)}return Ar(l,u,p)}function Sw(l,u,p){if(l!==null)if(l.memoizedProps!==u.pendingProps)is=!0;else{if(!Em(l,p)&&(u.flags&128)===0)return is=!1,T_(l,u,p);is=(l.flags&131072)!==0}else is=!1,on&&(u.flags&1048576)!==0&&tv(u,kc,u.index);switch(u.lanes=0,u.tag){case 16:e:{var g=u.pendingProps;if(l=oo(u.elementType),u.type=l,typeof l=="function")Lh(l)?(g=fo(l,g),u.tag=1,u=xw(null,u,l,g,p)):(u.tag=0,u=Sm(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===P){u.tag=14,u=fw(null,u,l,g,p);break e}}throw u=H(l)||l,Error(s(306,u,""))}}return u;case 0:return Sm(l,u,u.type,u.pendingProps,p);case 1:return g=u.type,v=fo(g,u.pendingProps),xw(l,u,g,v,p);case 3:e:{if(Ne(u,u.stateNode.containerInfo),l===null)throw Error(s(387));g=u.pendingProps;var C=u.memoizedState;v=C.element,Qh(l,u),Ec(u,g,null,p);var I=u.memoizedState;if(g=I.cache,li(u,as,g),g!==C.cache&&Wh(u,[as],p,!0),_c(),g=I.element,C.isDehydrated)if(C={element:g,isDehydrated:!1,cache:I.cache},u.updateQueue.baseState=C,u.memoizedState=C,u.flags&256){u=yw(l,u,g,p);break e}else if(g!==v){v=xa(Error(s(424)),u),Sc(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(Ln=Sa(l.firstChild),xs=u,on=!0,ii=null,wa=!0,p=hv(u,null,g,p),u.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling}else{if(so(),g===v){u=Ar(l,u,p);break e}vs(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:on||(p=u.type,l=u.pendingProps,g=uf(ee.current).createElement(p),g[ct]=u,g[Ft]=l,ws(g,p,l),On(g),u.stateNode=g):u.memoizedState=O0(u.type,l.memoizedProps,u.pendingProps,l.memoizedState),null;case 27:return Me(u),l===null&&on&&(g=u.stateNode=M0(u.type,u.pendingProps,ee.current),xs=u,wa=!0,v=Ln,wi(u.type)?(cg=v,Ln=Sa(g.firstChild)):Ln=v),vs(l,u,u.pendingProps.children,p),Vd(l,u),l===null&&(u.flags|=4194304),u.child;case 5:return l===null&&on&&((v=g=Ln)&&(g=aE(g,u.type,u.pendingProps,wa),g!==null?(u.stateNode=g,xs=u,Ln=Sa(g.firstChild),wa=!1,v=!0):v=!1),v||oi(u)),Me(u),v=u.type,C=u.pendingProps,I=l!==null?l.memoizedProps:null,g=C.children,ag(v,C)?g=null:I!==null&&ag(v,I)&&(u.flags|=32),u.memoizedState!==null&&(v=sm(l,u,y_,null,null,p),Qc._currentValue=v),Vd(l,u),vs(l,u,g,p),u.child;case 6:return l===null&&on&&((l=p=Ln)&&(p=rE(p,u.pendingProps,wa),p!==null?(u.stateNode=p,xs=u,Ln=null,l=!0):l=!1),l||oi(u)),null;case 13:return vw(l,u,p);case 4:return Ne(u,u.stateNode.containerInfo),g=u.pendingProps,l===null?u.child=co(u,null,g,p):vs(l,u,g,p),u.child;case 11:return dw(l,u,u.type,u.pendingProps,p);case 7:return vs(l,u,u.pendingProps,p),u.child;case 8:return vs(l,u,u.pendingProps.children,p),u.child;case 12:return vs(l,u,u.pendingProps.children,p),u.child;case 10:return g=u.pendingProps,li(u,u.type,g.value),vs(l,u,g.children,p),u.child;case 9:return v=u.type._context,g=u.pendingProps.children,ro(u),v=ys(v),g=g(v),u.flags|=1,vs(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 ro(u),g=ys(as),l===null?(v=Yh(),v===null&&(v=jn,C=qh(),v.pooledCache=C,C.refCount++,C!==null&&(v.pooledCacheLanes|=p),v=C),u.memoizedState={parent:g,cache:v},Kh(u),li(u,as,v)):((l.lanes&p)!==0&&(Qh(l,u),Ec(u,null,null,p),_c()),v=l.memoizedState,C=u.memoizedState,v.parent!==g?(v={parent:g,cache:g},u.memoizedState=v,u.lanes===0&&(u.memoizedState=u.updateQueue.baseState=v),li(u,as,g)):(g=C.cache,li(u,as,g),g!==v.cache&&Wh(u,[as],p,!0))),vs(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 Mm(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 lo=Md,Gh}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 lo=Md,Gh}function Gd(l,u){u!==null&&(l.flags|=4),l.flags&16384&&(u=l.tag!==22?Kt():536870912,l.lanes|=u,gl|=u)}function Ic(l,u){if(!on)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 In(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(Fh(u),u.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return In(u),null;case 1:return In(u),null;case 3:return p=u.stateNode,g=null,l!==null&&(g=l.memoizedState.cache),u.memoizedState.cache!==g&&(u.flags|=2048),kr(as),ye(),p.pendingContext&&(p.context=p.pendingContext,p.pendingContext=null),(l===null||l.child===null)&&(sl(u)?jr(u):l===null||l.memoizedState.isDehydrated&&(u.flags&256)===0||(u.flags|=1024,$h())),In(u),null;case 26:var v=u.type,C=u.memoizedState;return l===null?(jr(u),C!==null?(In(u),Cw(u,C)):(In(u),Mm(u,v,null,g,p))):C?C!==l.memoizedState?(jr(u),In(u),Cw(u,C)):(In(u),u.flags&=-16777217):(l=l.memoizedProps,l!==g&&jr(u),In(u),Mm(u,v,l,g,p)),null;case 27:if(qe(u),p=ee.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 In(u),null}l=me.current,sl(u)?sv(u):(l=M0(v,g,p),u.stateNode=l,jr(u))}return In(u),null;case 5:if(qe(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 In(u),null}if(C=me.current,sl(u))sv(u);else{var I=uf(ee.current);switch(C){case 1:C=I.createElementNS("http://www.w3.org/2000/svg",v);break;case 2:C=I.createElementNS("http://www.w3.org/1998/Math/MathML",v);break;default:switch(v){case"svg":C=I.createElementNS("http://www.w3.org/2000/svg",v);break;case"math":C=I.createElementNS("http://www.w3.org/1998/Math/MathML",v);break;case"script":C=I.createElement("div"),C.innerHTML="<script><\/script>",C=C.removeChild(C.firstChild);break;case"select":C=typeof g.is=="string"?I.createElement("select",{is:g.is}):I.createElement("select"),g.multiple?C.multiple=!0:g.size&&(C.size=g.size);break;default:C=typeof g.is=="string"?I.createElement(v,{is:g.is}):I.createElement(v)}}C[ct]=u,C[Ft]=g;e:for(I=u.child;I!==null;){if(I.tag===5||I.tag===6)C.appendChild(I.stateNode);else if(I.tag!==4&&I.tag!==27&&I.child!==null){I.child.return=I,I=I.child;continue}if(I===u)break e;for(;I.sibling===null;){if(I.return===null||I.return===u)break e;I=I.return}I.sibling.return=I.return,I=I.sibling}u.stateNode=C;e:switch(ws(C,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 In(u),Mm(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=ee.current,sl(u)){if(l=u.stateNode,p=u.memoizedProps,g=null,v=xs,v!==null)switch(v.tag){case 27:case 5:g=v.memoizedProps}l[ct]=u,l=!!(l.nodeValue===p||g!==null&&g.suppressHydrationWarning===!0||v0(l.nodeValue,p)),l||oi(u,!0)}else l=uf(l).createTextNode(g),l[ct]=u,u.stateNode=l}return In(u),null;case 31:if(p=u.memoizedState,l===null||l.memoizedState!==null){if(g=sl(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[ct]=u}else so(),(u.flags&128)===0&&(u.memoizedState=null),u.flags|=4;In(u),l=!1}else p=$h(),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 In(u),null;case 13:if(g=u.memoizedState,l===null||l.memoizedState!==null&&l.memoizedState.dehydrated!==null){if(v=sl(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[ct]=u}else so(),(u.flags&128)===0&&(u.memoizedState=null),u.flags|=4;In(u),v=!1}else v=$h(),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),C=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(C=g.memoizedState.cachePool.pool),C!==v&&(g.flags|=2048)),p!==l&&p&&(u.child.flags|=8192),Gd(u,u.updateQueue),In(u),null);case 4:return ye(),l===null&&Zm(u.stateNode.containerInfo),In(u),null;case 10:return kr(u.type),In(u),null;case 19:if(se(Xn),g=u.memoizedState,g===null)return In(u),null;if(v=(u.flags&128)!==0,C=g.rendering,C===null)if(v)Ic(g,!1);else{if(Yn!==0||l!==null&&(l.flags&128)!==0)for(l=u.child;l!==null;){if(C=Ld(l),C!==null){for(u.flags|=128,Ic(g,!1),l=C.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),on&&vr(u,g.treeForkCount),u.child}l=l.sibling}g.tail!==null&&lt()>Zd&&(u.flags|=128,v=!0,Ic(g,!1),u.lanes=4194304)}else{if(!v)if(l=Ld(C),l!==null){if(u.flags|=128,v=!0,l=l.updateQueue,u.updateQueue=l,Gd(u,l),Ic(g,!0),g.tail===null&&g.tailMode==="hidden"&&!C.alternate&&!on)return In(u),null}else 2*lt()-g.renderingStartTime>Zd&&p!==536870912&&(u.flags|=128,v=!0,Ic(g,!1),u.lanes=4194304);g.isBackwards?(C.sibling=u.child,u.child=C):(l=g.last,l!==null?l.sibling=C:u.child=C,g.last=C)}return g.tail!==null?(l=g.tail,g.rendering=l,g.tail=l.sibling,g.renderingStartTime=lt(),l.sibling=null,p=Xn.current,q(Xn,v?p&1|2:p&1),on&&vr(u,g.treeForkCount),l):(In(u),null);case 22:case 23:return ta(u),em(),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&&(In(u),u.subtreeFlags&6&&(u.flags|=8192)):In(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(io),null;case 24:return p=null,l!==null&&(p=l.memoizedState.cache),u.memoizedState.cache!==p&&(u.flags|=2048),kr(as),In(u),null;case 25:return null;case 30:return null}throw Error(s(156,u.tag))}function E_(l,u){switch(Fh(u),u.tag){case 1:return l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 3:return kr(as),ye(),l=u.flags,(l&65536)!==0&&(l&128)===0?(u.flags=l&-65537|128,u):null;case 26:case 27:case 5:return qe(u),null;case 31:if(u.memoizedState!==null){if(ta(u),u.alternate===null)throw Error(s(340));so()}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));so()}return l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 19:return se(Xn),null;case 4:return ye(),null;case 10:return kr(u.type),null;case 22:case 23:return ta(u),em(),l!==null&&se(io),l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 24:return kr(as),null;case 25:return null;default:return null}}function Aw(l,u){switch(Fh(u),u.tag){case 3:kr(as),ye();break;case 26:case 27:case 5:qe(u);break;case 4:ye();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),em(),l!==null&&se(io);break;case 24:kr(as)}}function Pc(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 C=p.create,I=p.inst;g=C(),I.destroy=g}p=p.next}while(p!==v)}}catch(Y){vn(u,u.return,Y)}}function hi(l,u,p){try{var g=u.updateQueue,v=g!==null?g.lastEffect:null;if(v!==null){var C=v.next;g=C;do{if((g.tag&l)===l){var I=g.inst,Y=I.destroy;if(Y!==void 0){I.destroy=void 0,v=u;var re=p,Re=Y;try{Re()}catch(Ve){vn(v,re,Ve)}}}g=g.next}while(g!==C)}}catch(Ve){vn(u,u.return,Ve)}}function jw(l){var u=l.updateQueue;if(u!==null){var p=l.stateNode;try{gv(u,p)}catch(g){vn(l,l.return,g)}}}function Nw(l,u,p){p.props=fo(l.type,l.memoizedProps),p.state=l.memoizedState;try{p.componentWillUnmount()}catch(g){vn(l,u,g)}}function Bc(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){vn(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){vn(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){vn(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){vn(l,l.return,v)}}function Dm(l,u,p){try{var g=l.stateNode;J_(g,l.type,p,u),g[Ft]=u}catch(v){vn(l,l.return,v)}}function _w(l){return l.tag===5||l.tag===3||l.tag===26||l.tag===27&&wi(l.type)||l.tag===4}function Rm(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&&wi(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 Om(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=Ra));else if(g!==4&&(g===27&&wi(l.type)&&(p=l.stateNode,u=null),l=l.child,l!==null))for(Om(l,u,p),l=l.sibling;l!==null;)Om(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&&wi(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]);ws(u,g,p),u[ct]=l,u[Ft]=p}catch(C){vn(l,l.return,C)}}var Nr=!1,os=!1,Lm=!1,Mw=typeof WeakSet=="function"?WeakSet:Set,hs=null;function M_(l,u){if(l=l.containerInfo,ng=bf,l=Hy(l),Th(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,C=g.focusNode;g=g.focusOffset;try{p.nodeType,C.nodeType}catch{p=null;break e}var I=0,Y=-1,re=-1,Re=0,Ve=0,Qe=l,Ie=null;t:for(;;){for(var $e;Qe!==p||v!==0&&Qe.nodeType!==3||(Y=I+v),Qe!==C||g!==0&&Qe.nodeType!==3||(re=I+g),Qe.nodeType===3&&(I+=Qe.nodeValue.length),($e=Qe.firstChild)!==null;)Ie=Qe,Qe=$e;for(;;){if(Qe===l)break t;if(Ie===p&&++Re===v&&(Y=I),Ie===C&&++Ve===g&&(re=I),($e=Qe.nextSibling)!==null)break;Qe=Ie,Ie=Qe.parentNode}Qe=$e}p=Y===-1||re===-1?null:{start:Y,end:re}}else p=null}p=p||{start:0,end:0}}else p=null;for(sg={focusedElem:l,selectionRange:p},bf=!1,hs=u;hs!==null;)if(u=hs,l=u.child,(u.subtreeFlags&1028)!==0&&l!==null)l.return=u,hs=l;else for(;hs!==null;){switch(u=hs,C=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&&C!==null){l=void 0,p=u,v=C.memoizedProps,C=C.memoizedState,g=p.stateNode;try{var vt=fo(p.type,v);l=g.getSnapshotBeforeUpdate(vt,C),g.__reactInternalSnapshotBeforeUpdate=l}catch(Rt){vn(p,p.return,Rt)}}break;case 3:if((l&1024)!==0){if(l=u.stateNode.containerInfo,p=l.nodeType,p===9)ig(l);else if(p===1)switch(l.nodeName){case"HEAD":case"HTML":case"BODY":ig(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,hs=l;break}hs=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&&Pc(5,p);break;case 1:if(_r(l,p),g&4)if(l=p.stateNode,u===null)try{l.componentDidMount()}catch(I){vn(p,p.return,I)}else{var v=fo(p.type,u.memoizedProps);u=u.memoizedState;try{l.componentDidUpdate(v,u,l.__reactInternalSnapshotBeforeUpdate)}catch(I){vn(p,p.return,I)}}g&64&&jw(p),g&512&&Bc(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(I){vn(p,p.return,I)}}break;case 27:u===null&&g&4&&Ew(p);case 26:case 5:_r(l,p),u===null&&g&4&&Tw(p),g&512&&Bc(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||os,v=Nr;var C=os;Nr=g,(os=u)&&!C?Er(l,p,(p.subtreeFlags&8772)!==0):_r(l,p),Nr=v,os=C}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&&Ks(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,Bs=!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(be,p)}catch{}switch(p.tag){case 26:os||Ka(p,u),Tr(l,u,p),p.memoizedState?p.memoizedState.count--:p.stateNode&&(p=p.stateNode,p.parentNode.removeChild(p));break;case 27:os||Ka(p,u);var g=zn,v=Bs;wi(p.type)&&(zn=p.stateNode,Bs=!1),Tr(l,u,p),Yc(p.stateNode),zn=g,Bs=v;break;case 5:os||Ka(p,u);case 6:if(g=zn,v=Bs,zn=null,Tr(l,u,p),zn=g,Bs=v,zn!==null)if(Bs)try{(zn.nodeType===9?zn.body:zn.nodeName==="HTML"?zn.ownerDocument.body:zn).removeChild(p.stateNode)}catch(C){vn(p,u,C)}else try{zn.removeChild(p.stateNode)}catch(C){vn(p,u,C)}break;case 18:zn!==null&&(Bs?(l=zn,j0(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,p.stateNode),Cl(l)):j0(zn,p.stateNode));break;case 4:g=zn,v=Bs,zn=p.stateNode.containerInfo,Bs=!0,Tr(l,u,p),zn=g,Bs=v;break;case 0:case 11:case 14:case 15:hi(2,p,u),os||hi(4,p,u),Tr(l,u,p);break;case 1:os||(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:os=(g=os)||p.memoizedState!==null,Tr(l,u,p),os=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{Cl(l)}catch(p){vn(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{Cl(l)}catch(p){vn(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 Fs(l,u){var p=u.deletions;if(p!==null)for(var g=0;g<p.length;g++){var v=p[g],C=l,I=u,Y=I;e:for(;Y!==null;){switch(Y.tag){case 27:if(wi(Y.type)){zn=Y.stateNode,Bs=!1;break e}break;case 5:zn=Y.stateNode,Bs=!1;break e;case 3:case 4:zn=Y.stateNode.containerInfo,Bs=!0;break e}Y=Y.return}if(zn===null)throw Error(s(160));Ow(C,I,v),zn=null,Bs=!1,C=v.alternate,C!==null&&(C.return=null),v.return=null}if(u.subtreeFlags&13886)for(u=u.child;u!==null;)Pw(u,l),u=u.sibling}var La=null;function Pw(l,u){var p=l.alternate,g=l.flags;switch(l.tag){case 0:case 11:case 14:case 15:Fs(u,l),zs(l),g&4&&(hi(3,l,l.return),Pc(3,l),hi(5,l,l.return));break;case 1:Fs(u,l),zs(l),g&512&&(os||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=La;if(Fs(u,l),zs(l),g&512&&(os||p===null||Ka(p,p.return)),g&4){var C=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":C=v.getElementsByTagName("title")[0],(!C||C[ts]||C[ct]||C.namespaceURI==="http://www.w3.org/2000/svg"||C.hasAttribute("itemprop"))&&(C=v.createElement(g),v.head.insertBefore(C,v.querySelector("head > title"))),ws(C,g,p),C[ct]=l,On(C),g=C;break e;case"link":var I=P0("link","href",v).get(g+(p.href||""));if(I){for(var Y=0;Y<I.length;Y++)if(C=I[Y],C.getAttribute("href")===(p.href==null||p.href===""?null:p.href)&&C.getAttribute("rel")===(p.rel==null?null:p.rel)&&C.getAttribute("title")===(p.title==null?null:p.title)&&C.getAttribute("crossorigin")===(p.crossOrigin==null?null:p.crossOrigin)){I.splice(Y,1);break t}}C=v.createElement(g),ws(C,g,p),v.head.appendChild(C);break;case"meta":if(I=P0("meta","content",v).get(g+(p.content||""))){for(Y=0;Y<I.length;Y++)if(C=I[Y],C.getAttribute("content")===(p.content==null?null:""+p.content)&&C.getAttribute("name")===(p.name==null?null:p.name)&&C.getAttribute("property")===(p.property==null?null:p.property)&&C.getAttribute("http-equiv")===(p.httpEquiv==null?null:p.httpEquiv)&&C.getAttribute("charset")===(p.charSet==null?null:p.charSet)){I.splice(Y,1);break t}}C=v.createElement(g),ws(C,g,p),v.head.appendChild(C);break;default:throw Error(s(468,g))}C[ct]=l,On(C),g=C}l.stateNode=g}else B0(v,l.type,l.stateNode);else l.stateNode=I0(v,g,l.memoizedProps);else C!==g?(C===null?p.stateNode!==null&&(p=p.stateNode,p.parentNode.removeChild(p)):C.count--,g===null?B0(v,l.type,l.stateNode):I0(v,g,l.memoizedProps)):g===null&&l.stateNode!==null&&Dm(l,l.memoizedProps,p.memoizedProps)}break;case 27:Fs(u,l),zs(l),g&512&&(os||p===null||Ka(p,p.return)),p!==null&&g&4&&Dm(l,l.memoizedProps,p.memoizedProps);break;case 5:if(Fs(u,l),zs(l),g&512&&(os||p===null||Ka(p,p.return)),l.flags&32){v=l.stateNode;try{Va(v,"")}catch(vt){vn(l,l.return,vt)}}g&4&&l.stateNode!=null&&(v=l.memoizedProps,Dm(l,v,p!==null?p.memoizedProps:v)),g&1024&&(Lm=!0);break;case 6:if(Fs(u,l),zs(l),g&4){if(l.stateNode===null)throw Error(s(162));g=l.memoizedProps,p=l.stateNode;try{p.nodeValue=g}catch(vt){vn(l,l.return,vt)}}break;case 3:if(pf=null,v=La,La=df(u.containerInfo),Fs(u,l),La=v,zs(l),g&4&&p!==null&&p.memoizedState.isDehydrated)try{Cl(u.containerInfo)}catch(vt){vn(l,l.return,vt)}Lm&&(Lm=!1,Bw(l));break;case 4:g=La,La=df(l.stateNode.containerInfo),Fs(u,l),zs(l),La=g;break;case 12:Fs(u,l),zs(l);break;case 31:Fs(u,l),zs(l),g&4&&(g=l.updateQueue,g!==null&&(l.updateQueue=null,Qd(l,g)));break;case 13:Fs(u,l),zs(l),l.child.flags&8192&&l.memoizedState!==null!=(p!==null&&p.memoizedState!==null)&&(Jd=lt()),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,Re=Nr,Ve=os;if(Nr=Re||v,os=Ve||re,Fs(u,l),os=Ve,Nr=Re,zs(l),g&8192)e:for(u=l.stateNode,u._visibility=v?u._visibility&-2:u._visibility|1,v&&(p===null||re||Nr||os||po(l)),p=null,u=l;;){if(u.tag===5||u.tag===26){if(p===null){re=p=u;try{if(C=re.stateNode,v)I=C.style,typeof I.setProperty=="function"?I.setProperty("display","none","important"):I.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(vt){vn(re,re.return,vt)}}}else if(u.tag===6){if(p===null){re=u;try{re.stateNode.nodeValue=v?"":re.memoizedProps}catch(vt){vn(re,re.return,vt)}}}else if(u.tag===18){if(p===null){re=u;try{var $e=re.stateNode;v?N0($e,!0):N0(re.stateNode,!1)}catch(vt){vn(re,re.return,vt)}}}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:Fs(u,l),zs(l),g&4&&(g=l.updateQueue,g!==null&&(l.updateQueue=null,Qd(l,g)));break;case 30:break;case 21:break;default:Fs(u,l),zs(l)}}function zs(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,C=Rm(l);Kd(l,C,v);break;case 5:var I=p.stateNode;p.flags&32&&(Va(I,""),p.flags&=-33);var Y=Rm(l);Kd(l,Y,I);break;case 3:case 4:var re=p.stateNode.containerInfo,Re=Rm(l);Om(l,Re,re);break;default:throw Error(s(161))}}catch(Ve){vn(l,l.return,Ve)}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 po(l){for(l=l.child;l!==null;){var u=l;switch(u.tag){case 0:case 11:case 14:case 15:hi(4,u,u.return),po(u);break;case 1:Ka(u,u.return);var p=u.stateNode;typeof p.componentWillUnmount=="function"&&Nw(u,u.return,p),po(u);break;case 27:Yc(u.stateNode);case 26:case 5:Ka(u,u.return),po(u);break;case 22:u.memoizedState===null&&po(u);break;case 30:po(u);break;default:po(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,C=u,I=C.flags;switch(C.tag){case 0:case 11:case 15:Er(v,C,p),Pc(4,C);break;case 1:if(Er(v,C,p),g=C,v=g.stateNode,typeof v.componentDidMount=="function")try{v.componentDidMount()}catch(Re){vn(g,g.return,Re)}if(g=C,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(Re){vn(g,g.return,Re)}}p&&I&64&&jw(C),Bc(C,C.return);break;case 27:Ew(C);case 26:case 5:Er(v,C,p),p&&g===null&&I&4&&Tw(C),Bc(C,C.return);break;case 12:Er(v,C,p);break;case 31:Er(v,C,p),p&&I&4&&Lw(v,C);break;case 13:Er(v,C,p),p&&I&4&&Iw(v,C);break;case 22:C.memoizedState===null&&Er(v,C,p),Bc(C,C.return);break;case 30:break;default:Er(v,C,p)}u=u.sibling}}function Im(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&&Cc(p))}function Pm(l,u){l=null,u.alternate!==null&&(l=u.alternate.memoizedState.cache),u=u.memoizedState.cache,u!==l&&(u.refCount++,l!=null&&Cc(l))}function Ia(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:Ia(l,u,p,g),v&2048&&Pc(9,u);break;case 1:Ia(l,u,p,g);break;case 3:Ia(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&&Cc(l)));break;case 12:if(v&2048){Ia(l,u,p,g),l=u.stateNode;try{var C=u.memoizedProps,I=C.id,Y=C.onPostCommit;typeof Y=="function"&&Y(I,u.alternate===null?"mount":"update",l.passiveEffectDuration,-0)}catch(re){vn(u,u.return,re)}}else Ia(l,u,p,g);break;case 31:Ia(l,u,p,g);break;case 13:Ia(l,u,p,g);break;case 23:break;case 22:C=u.stateNode,I=u.alternate,u.memoizedState!==null?C._visibility&2?Ia(l,u,p,g):Fc(l,u):C._visibility&2?Ia(l,u,p,g):(C._visibility|=2,pl(l,u,p,g,(u.subtreeFlags&10256)!==0||!1)),v&2048&&Im(I,u);break;case 24:Ia(l,u,p,g),v&2048&&Pm(u.alternate,u);break;default:Ia(l,u,p,g)}}function pl(l,u,p,g,v){for(v=v&&((u.subtreeFlags&10256)!==0||!1),u=u.child;u!==null;){var C=l,I=u,Y=p,re=g,Re=I.flags;switch(I.tag){case 0:case 11:case 15:pl(C,I,Y,re,v),Pc(8,I);break;case 23:break;case 22:var Ve=I.stateNode;I.memoizedState!==null?Ve._visibility&2?pl(C,I,Y,re,v):Fc(C,I):(Ve._visibility|=2,pl(C,I,Y,re,v)),v&&Re&2048&&Im(I.alternate,I);break;case 24:pl(C,I,Y,re,v),v&&Re&2048&&Pm(I.alternate,I);break;default:pl(C,I,Y,re,v)}u=u.sibling}}function Fc(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:Fc(p,g),v&2048&&Im(g.alternate,g);break;case 24:Fc(p,g),v&2048&&Pm(g.alternate,g);break;default:Fc(p,g)}u=u.sibling}}var zc=8192;function hl(l,u,p){if(l.subtreeFlags&zc)for(l=l.child;l!==null;)zw(l,u,p),l=l.sibling}function zw(l,u,p){switch(l.tag){case 26:hl(l,u,p),l.flags&zc&&l.memoizedState!==null&&xE(p,La,l.memoizedState,l.memoizedProps);break;case 5:hl(l,u,p);break;case 3:case 4:var g=La;La=df(l.stateNode.containerInfo),hl(l,u,p),La=g;break;case 22:l.memoizedState===null&&(g=l.alternate,g!==null&&g.memoizedState!==null?(g=zc,zc=16777216,hl(l,u,p),zc=g):hl(l,u,p));break;default:hl(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 $c(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];hs=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:$c(l),l.flags&2048&&hi(9,l,l.return);break;case 3:$c(l);break;case 12:$c(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)):$c(l);break;default:$c(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];hs=g,Hw(g,l)}$w(l)}for(l=l.child;l!==null;){switch(u=l,u.tag){case 0:case 11:case 15:hi(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(;hs!==null;){var p=hs;switch(p.tag){case 0:case 11:case 15:hi(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:Cc(p.memoizedState.cache)}if(g=p.child,g!==null)g.return=p,hs=g;else e:for(p=l;hs!==null;){g=hs;var v=g.sibling,C=g.return;if(Rw(g),g===p){hs=null;break e}if(v!==null){v.return=C,hs=v;break e}hs=C}}}var R_={getCacheForType:function(l){var u=ys(as),p=u.data.get(l);return p===void 0&&(p=l(),u.data.set(l,p)),p},cacheSignal:function(){return ys(as).controller.signal}},O_=typeof WeakMap=="function"?WeakMap:Map,mn=0,jn=null,Qt=null,sn=0,yn=0,na=null,mi=!1,ml=!1,Bm=!1,Mr=0,Yn=0,gi=0,ho=0,Fm=0,sa=0,gl=0,Uc=null,$s=null,zm=!1,Jd=0,Ww=0,Zd=1/0,ef=null,bi=null,ds=0,xi=null,bl=null,Dr=0,$m=0,Um=null,qw=null,Hc=0,Hm=null;function aa(){return(mn&2)!==0&&sn!==0?sn&-sn:z.T!==null?Km():cn()}function Vw(){if(sa===0)if((sn&536870912)===0||on){var l=xt;xt<<=1,(xt&3932160)===0&&(xt=262144),sa=l}else sa=536870912;return l=ea.current,l!==null&&(l.flags|=32),sa}function Us(l,u,p){(l===jn&&(yn===2||yn===9)||l.cancelPendingCommit!==null)&&(xl(l,0),yi(l,sn,sa,!1)),Be(l,p),((mn&2)===0||l!==jn)&&(l===jn&&((mn&2)===0&&(ho|=p),Yn===4&&yi(l,sn,sa,!1)),Qa(l))}function Yw(l,u,p){if((mn&6)!==0)throw Error(s(327));var g=!p&&(u&127)===0&&(u&l.expiredLanes)===0||ut(l,u),v=g?P_(l,u):qm(l,u,!0),C=g;do{if(v===0){ml&&!g&&yi(l,u,0,!1);break}else{if(p=l.current.alternate,C&&!L_(p)){v=qm(l,u,!1),C=!1;continue}if(v===2){if(C=u,l.errorRecoveryDisabledLanes&C)var I=0;else I=l.pendingLanes&-536870913,I=I!==0?I:I&536870912?536870912:0;if(I!==0){u=I;e:{var Y=l;v=Uc;var re=Y.current.memoizedState.isDehydrated;if(re&&(xl(Y,I).flags|=256),I=qm(Y,I,!1),I!==2){if(Bm&&!re){Y.errorRecoveryDisabledLanes|=C,ho|=C,v=4;break e}C=$s,$s=v,C!==null&&($s===null?$s=C:$s.push.apply($s,C))}v=I}if(C=!1,v!==2)continue}}if(v===1){xl(l,0),yi(l,u,0,!0);break}e:{switch(g=l,C=v,C){case 0:case 1:throw Error(s(345));case 4:if((u&4194048)!==u)break;case 6:yi(g,u,sa,!mi);break e;case 2:$s=null;break;case 3:case 5:break;default:throw Error(s(329))}if((u&62914560)===u&&(v=Jd+300-lt(),10<v)){if(yi(g,u,sa,!mi),ft(g,0,!0)!==0)break e;Dr=u,g.timeoutHandle=C0(Gw.bind(null,g,p,$s,ef,zm,u,sa,ho,gl,mi,C,"Throttled",-0,0),v);break e}Gw(g,p,$s,ef,zm,u,sa,ho,gl,mi,C,null,-0,0)}}break}while(!0);Qa(l)}function Gw(l,u,p,g,v,C,I,Y,re,Re,Ve,Qe,Ie,$e){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:Ra},zw(u,C,Qe);var vt=(C&62914560)===C?Jd-lt():(C&4194048)===C?Ww-lt():0;if(vt=yE(Qe,vt),vt!==null){Dr=C,l.cancelPendingCommit=vt(n0.bind(null,l,u,C,p,g,v,I,Y,re,Ve,Qe,null,Ie,$e)),yi(l,C,I,!Re);return}}n0(l,u,C,p,g,v,I,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],C=v.getSnapshot;v=v.value;try{if(!Js(C(),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 yi(l,u,p,g){u&=~Fm,u&=~ho,l.suspendedLanes|=u,l.pingedLanes&=~u,g&&(l.warmLanes|=u),g=l.expirationTimes;for(var v=u;0<v;){var C=31-ge(v),I=1<<C;g[C]=-1,v&=~I}p!==0&&et(l,p,u)}function tf(){return(mn&6)===0?(Wc(0),!1):!0}function Wm(){if(Qt!==null){if(yn===0)var l=Qt.return;else l=Qt,wr=ao=null,im(l),ll=null,jc=0,l=Qt;for(;l!==null;)Aw(l.alternate,l),l=l.return;Qt=null}}function xl(l,u){var p=l.timeoutHandle;p!==-1&&(l.timeoutHandle=-1,tE(p)),p=l.cancelPendingCommit,p!==null&&(l.cancelPendingCommit=null,p()),Dr=0,Wm(),jn=l,Qt=p=yr(l.current,null),sn=u,yn=0,na=null,mi=!1,ml=ut(l,u),Bm=!1,gl=sa=Fm=ho=gi=Yn=0,$s=Uc=null,zm=!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),C=1<<v;u|=l[v],g&=~C}return Mr=u,kd(),p}function Kw(l,u){Ut=null,z.H=Oc,u===ol||u===Ed?(u=dv(),yn=3):u===Gh?(u=dv(),yn=4):yn=u===km?8:u!==null&&typeof u=="object"&&typeof u.then=="function"?6:1,na=u,Qt===null&&(Yn=1,Wd(l,xa(u,l.current)))}function Qw(){var l=ea.current;return l===null?!0:(sn&4194048)===sn?ka===null:(sn&62914560)===sn||(sn&536870912)!==0?l===ka:!1}function Xw(){var l=z.H;return z.H=Oc,l===null?Oc:l}function Jw(){var l=z.A;return z.A=R_,l}function nf(){Yn=4,mi||(sn&4194048)!==sn&&ea.current!==null||(ml=!0),(gi&134217727)===0&&(ho&134217727)===0||jn===null||yi(jn,sn,sa,!1)}function qm(l,u,p){var g=mn;mn|=2;var v=Xw(),C=Jw();(jn!==l||sn!==u)&&(ef=null,xl(l,u)),u=!1;var I=Yn;e:do try{if(yn!==0&&Qt!==null){var Y=Qt,re=na;switch(yn){case 8:Wm(),I=6;break e;case 3:case 2:case 9:case 6:ea.current===null&&(u=!0);var Re=yn;if(yn=0,na=null,yl(l,Y,re,Re),p&&ml){I=0;break e}break;default:Re=yn,yn=0,na=null,yl(l,Y,re,Re)}}I_(),I=Yn;break}catch(Ve){Kw(l,Ve)}while(!0);return u&&l.shellSuspendCounter++,wr=ao=null,mn=g,z.H=v,z.A=C,Qt===null&&(jn=null,sn=0,kd()),I}function I_(){for(;Qt!==null;)Zw(Qt)}function P_(l,u){var p=mn;mn|=2;var g=Xw(),v=Jw();jn!==l||sn!==u?(ef=null,Zd=lt()+500,xl(l,u)):ml=ut(l,u);e:do try{if(yn!==0&&Qt!==null){u=Qt;var C=na;t:switch(yn){case 1:yn=0,na=null,yl(l,u,C,1);break;case 2:case 9:if(cv(C)){yn=0,na=null,e0(u);break}u=function(){yn!==2&&yn!==9||jn!==l||(yn=7),Qa(l)},C.then(u,u);break e;case 3:yn=7;break e;case 4:yn=5;break e;case 7:cv(C)?(yn=0,na=null,e0(u)):(yn=0,na=null,yl(l,u,C,7));break;case 5:var I=null;switch(Qt.tag){case 26:I=Qt.memoizedState;case 5:case 27:var Y=Qt;if(I?F0(I):Y.stateNode.complete){yn=0,na=null;var re=Y.sibling;if(re!==null)Qt=re;else{var Re=Y.return;Re!==null?(Qt=Re,sf(Re)):Qt=null}break t}}yn=0,na=null,yl(l,u,C,5);break;case 6:yn=0,na=null,yl(l,u,C,6);break;case 8:Wm(),Yn=6;break e;default:throw Error(s(462))}}B_();break}catch(Ve){Kw(l,Ve)}while(!0);return wr=ao=null,z.H=g,z.A=v,mn=p,Qt!==null?0:(jn=null,sn=0,kd(),Yn)}function B_(){for(;Qt!==null&&!Ue();)Zw(Qt)}function Zw(l){var u=Sw(l.alternate,l,Mr);l.memoizedProps=l.pendingProps,u===null?sf(l):Qt=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,sn);break;case 11:u=bw(p,u,u.pendingProps,u.type.render,u.ref,sn);break;case 5:im(u);default:Aw(p,u),u=Qt=Jy(u,Mr),u=Sw(p,u,Mr)}l.memoizedProps=l.pendingProps,u===null?sf(l):Qt=u}function yl(l,u,p,g){wr=ao=null,im(u),ll=null,jc=0;var v=u.return;try{if(j_(l,v,u,p,sn)){Yn=1,Wd(l,xa(p,l.current)),Qt=null;return}}catch(C){if(v!==null)throw Qt=v,C;Yn=1,Wd(l,xa(p,l.current)),Qt=null;return}u.flags&32768?(on||g===1?l=!0:ml||(sn&536870912)!==0?l=!1:(mi=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,mi);return}l=u.return;var p=__(u.alternate,u,Mr);if(p!==null){Qt=p;return}if(u=u.sibling,u!==null){Qt=u;return}Qt=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,Qt=p;return}if(p=l.return,p!==null&&(p.flags|=32768,p.subtreeFlags=0,p.deletions=null),!u&&(l=l.sibling,l!==null)){Qt=l;return}Qt=l=p}while(l!==null);Yn=6,Qt=null}function n0(l,u,p,g,v,C,I,Y,re){l.cancelPendingCommit=null;do af();while(ds!==0);if((mn&6)!==0)throw Error(s(327));if(u!==null){if(u===l.current)throw Error(s(177));if(C=u.lanes|u.childLanes,C|=Rh,Ye(l,p,C,I,Y,re),l===jn&&(Qt=jn=null,sn=0),bl=u,xi=l,Dr=p,$m=C,Um=v,qw=g,(u.subtreeFlags&10256)!==0||(u.flags&10256)!==0?(l.callbackNode=null,l.callbackPriority=0,U_(Se,function(){return o0(),null})):(l.callbackNode=null,l.callbackPriority=0),g=(u.flags&13878)!==0,(u.subtreeFlags&13878)!==0||g){g=z.T,z.T=null,v=W.p,W.p=2,I=mn,mn|=4;try{M_(l,u,p)}finally{mn=I,W.p=v,z.T=g}}ds=1,s0(),a0(),r0()}}function s0(){if(ds===1){ds=0;var l=xi,u=bl,p=(u.flags&13878)!==0;if((u.subtreeFlags&13878)!==0||p){p=z.T,z.T=null;var g=W.p;W.p=2;var v=mn;mn|=4;try{Pw(u,l);var C=sg,I=Hy(l.containerInfo),Y=C.focusedElem,re=C.selectionRange;if(I!==Y&&Y&&Y.ownerDocument&&Uy(Y.ownerDocument.documentElement,Y)){if(re!==null&&Th(Y)){var Re=re.start,Ve=re.end;if(Ve===void 0&&(Ve=Re),"selectionStart"in Y)Y.selectionStart=Re,Y.selectionEnd=Math.min(Ve,Y.value.length);else{var Qe=Y.ownerDocument||document,Ie=Qe&&Qe.defaultView||window;if(Ie.getSelection){var $e=Ie.getSelection(),vt=Y.textContent.length,Rt=Math.min(re.start,vt),An=re.end===void 0?Rt:Math.min(re.end,vt);!$e.extend&&Rt>An&&(I=An,An=Rt,Rt=I);var ke=$y(Y,Rt),oe=$y(Y,An);if(ke&&oe&&($e.rangeCount!==1||$e.anchorNode!==ke.node||$e.anchorOffset!==ke.offset||$e.focusNode!==oe.node||$e.focusOffset!==oe.offset)){var Ee=Qe.createRange();Ee.setStart(ke.node,ke.offset),$e.removeAllRanges(),Rt>An?($e.addRange(Ee),$e.extend(oe.node,oe.offset)):(Ee.setEnd(oe.node,oe.offset),$e.addRange(Ee))}}}}for(Qe=[],$e=Y;$e=$e.parentNode;)$e.nodeType===1&&Qe.push({element:$e,left:$e.scrollLeft,top:$e.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=!!ng,sg=ng=null}finally{mn=v,W.p=g,z.T=p}}l.current=u,ds=2}}function a0(){if(ds===2){ds=0;var l=xi,u=bl,p=(u.flags&8772)!==0;if((u.subtreeFlags&8772)!==0||p){p=z.T,z.T=null;var g=W.p;W.p=2;var v=mn;mn|=4;try{Dw(l,u.alternate,u)}finally{mn=v,W.p=g,z.T=p}}ds=3}}function r0(){if(ds===4||ds===3){ds=0,Ze();var l=xi,u=bl,p=Dr,g=qw;(u.subtreeFlags&10256)!==0||(u.flags&10256)!==0?ds=5:(ds=0,bl=xi=null,i0(l,l.pendingLanes));var v=l.pendingLanes;if(v===0&&(bi=null),qt(p),u=u.stateNode,Pe&&typeof Pe.onCommitFiberRoot=="function")try{Pe.onCommitFiberRoot(be,u,void 0,(u.current.flags&128)===128)}catch{}if(g!==null){u=z.T,v=W.p,W.p=2,z.T=null;try{for(var C=l.onRecoverableError,I=0;I<g.length;I++){var Y=g[I];C(Y.value,{componentStack:Y.stack})}}finally{z.T=u,W.p=v}}(Dr&3)!==0&&af(),Qa(l),v=l.pendingLanes,(p&261930)!==0&&(v&42)!==0?l===Hm?Hc++:(Hc=0,Hm=l):Hc=0,Wc(0)}}function i0(l,u){(l.pooledCacheLanes&=u)===0&&(u=l.pooledCache,u!=null&&(l.pooledCache=null,Cc(u)))}function af(){return s0(),a0(),r0(),o0()}function o0(){if(ds!==5)return!1;var l=xi,u=$m;$m=0;var p=qt(Dr),g=z.T,v=W.p;try{W.p=32>p?32:p,z.T=null,p=Um,Um=null;var C=xi,I=Dr;if(ds=0,bl=xi=null,Dr=0,(mn&6)!==0)throw Error(s(331));var Y=mn;if(mn|=4,Uw(C.current),Fw(C,C.current,I,p),mn=Y,Wc(0,!1),Pe&&typeof Pe.onPostCommitFiberRoot=="function")try{Pe.onPostCommitFiberRoot(be,C)}catch{}return!0}finally{W.p=v,z.T=g,i0(l,u)}}function l0(l,u,p){u=xa(p,u),u=wm(l.stateNode,u,2),l=di(l,u,2),l!==null&&(Be(l,2),Qa(l))}function vn(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"&&(bi===null||!bi.has(g))){l=xa(p,l),p=cw(2),g=di(u,p,2),g!==null&&(uw(p,g,u,l),Be(g,2),Qa(g));break}}u=u.return}}function Vm(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)||(Bm=!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,jn===l&&(sn&p)===p&&(Yn===4||Yn===3&&(sn&62914560)===sn&&300>lt()-Jd?(mn&2)===0&&xl(l,0):Fm|=p,gl===sn&&(gl=0)),Qa(l)}function c0(l,u){u===0&&(u=Kt()),l=to(l,u),l!==null&&(Be(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 ie(l,u)}var rf=null,vl=null,Ym=!1,of=!1,Gm=!1,vi=0;function Qa(l){l!==vl&&l.next===null&&(vl===null?rf=vl=l:vl=vl.next=l),of=!0,Ym||(Ym=!0,W_())}function Wc(l,u){if(!Gm&&of){Gm=!0;do for(var p=!1,g=rf;g!==null;){if(l!==0){var v=g.pendingLanes;if(v===0)var C=0;else{var I=g.suspendedLanes,Y=g.pingedLanes;C=(1<<31-ge(42|l)+1)-1,C&=v&~(I&~Y),C=C&201326741?C&201326741|1:C?C|2:0}C!==0&&(p=!0,p0(g,C))}else C=sn,C=ft(g,g===jn?C:0,g.cancelPendingCommit!==null||g.timeoutHandle!==-1),(C&3)===0||ut(g,C)||(p=!0,p0(g,C));g=g.next}while(p);Gm=!1}}function H_(){u0()}function u0(){of=Ym=!1;var l=0;vi!==0&&eE()&&(l=vi);for(var u=lt(),p=null,g=rf;g!==null;){var v=g.next,C=d0(g,u);C===0?(g.next=null,p===null?rf=v:p.next=v,v===null&&(vl=p)):(p=g,(l!==0||(C&3)!==0)&&(of=!0)),g=v}ds!==0&&ds!==5||Wc(l),vi!==0&&(vi=0)}function d0(l,u){for(var p=l.suspendedLanes,g=l.pingedLanes,v=l.expirationTimes,C=l.pendingLanes&-62914561;0<C;){var I=31-ge(C),Y=1<<I,re=v[I];re===-1?((Y&p)===0||(Y&g)!==0)&&(v[I]=ln(Y,u)):re<=u&&(l.expiredLanes|=Y),C&=~Y}if(u=jn,p=sn,p=ft(l,l===u?p:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),g=l.callbackNode,p===0||l===u&&(yn===2||yn===9)||l.cancelPendingCommit!==null)return g!==null&&g!==null&&de(g),l.callbackNode=null,l.callbackPriority=0;if((p&3)===0||ut(l,p)){if(u=p&-p,u===l.callbackPriority)return u;switch(g!==null&&de(g),qt(p)){case 2:case 8:p=ae;break;case 32:p=Se;break;case 268435456:p=he;break;default:p=Se}return g=f0.bind(null,l),p=ie(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(ds!==0&&ds!==5)return l.callbackNode=null,l.callbackPriority=0,null;var p=l.callbackNode;if(af()&&l.callbackNode!==p)return null;var g=sn;return g=ft(l,l===jn?g:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),g===0?null:(Yw(l,g,u),d0(l,lt()),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(){(mn&6)!==0?ie(J,H_):u0()})}function Km(){if(vi===0){var l=rl;l===0&&(l=st,st<<=1,(st&261888)===0&&(st=256)),vi=l}return vi}function h0(l){return l==null||typeof l=="symbol"||typeof l=="boolean"?null:typeof l=="function"?l:Zr(""+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 C=h0((v[Ft]||null).action),I=g.submitter;I&&(u=(u=I[Ft]||null)?h0(u.formAction):I.getAttribute("formAction"),u!==null&&(C=u,I=null));var Y=new Uo("action","action",null,g,v);l.push({event:Y,listeners:[{instance:null,listener:function(){if(g.defaultPrevented){if(vi!==0){var re=I?m0(v,I):new FormData(v);mm(p,{pending:!0,data:re,method:v.method,action:C},null,re)}}else typeof C=="function"&&(Y.preventDefault(),re=I?m0(v,I):new FormData(v),mm(p,{pending:!0,data:re,method:v.method,action:C},C,re))},currentTarget:v}]})}}for(var Qm=0;Qm<Dh.length;Qm++){var Xm=Dh[Qm],V_=Xm.toLowerCase(),Y_=Xm[0].toUpperCase()+Xm.slice(1);Oa(V_,"on"+Y_)}Oa(Vy,"onAnimationEnd"),Oa(Yy,"onAnimationIteration"),Oa(Gy,"onAnimationStart"),Oa("dblclick","onDoubleClick"),Oa("focusin","onFocus"),Oa("focusout","onBlur"),Oa(c_,"onTransitionRun"),Oa(u_,"onTransitionStart"),Oa(d_,"onTransitionCancel"),Oa(Ky,"onTransitionEnd"),ha("onMouseEnter",["mouseout","mouseover"]),ha("onMouseLeave",["mouseout","mouseover"]),ha("onPointerEnter",["pointerout","pointerover"]),ha("onPointerLeave",["pointerout","pointerover"]),pa("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),pa("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),pa("onBeforeInput",["compositionend","keypress","textInput","paste"]),pa("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),pa("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),pa("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var qc="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(qc));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 C=void 0;if(u)for(var I=g.length-1;0<=I;I--){var Y=g[I],re=Y.instance,Re=Y.currentTarget;if(Y=Y.listener,re!==C&&v.isPropagationStopped())break e;C=Y,v.currentTarget=Re;try{C(v)}catch(Ve){wd(Ve)}v.currentTarget=null,C=re}else for(I=0;I<g.length;I++){if(Y=g[I],re=Y.instance,Re=Y.currentTarget,Y=Y.listener,re!==C&&v.isPropagationStopped())break e;C=Y,v.currentTarget=Re;try{C(v)}catch(Ve){wd(Ve)}v.currentTarget=null,C=re}}}}function Xt(l,u){var p=u[En];p===void 0&&(p=u[En]=new Set);var g=l+"__bubble";p.has(g)||(b0(u,l,2,!1),p.add(g))}function Jm(l,u,p){var g=0;u&&(g|=4),b0(p,l,g,u)}var lf="_reactListening"+Math.random().toString(36).slice(2);function Zm(l){if(!l[lf]){l[lf]=!0,Wa.forEach(function(p){p!=="selectionchange"&&(G_.has(p)||Jm(p,!1,l),Jm(p,!0,l))});var u=l.nodeType===9?l:l.ownerDocument;u===null||u[lf]||(u[lf]=!0,Jm("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=hg}p=v.bind(null,u,p,l),v=void 0,!ni||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 eg(l,u,p,g,v){var C=g;if((u&1)===0&&(u&2)===0&&g!==null)e:for(;;){if(g===null)return;var I=g.tag;if(I===3||I===4){var Y=g.stateNode.containerInfo;if(Y===v)break;if(I===4)for(I=g.return;I!==null;){var re=I.tag;if((re===3||re===4)&&I.stateNode.containerInfo===v)return;I=I.return}for(;Y!==null;){if(I=Bn(Y),I===null)return;if(re=I.tag,re===5||re===6||re===26||re===27){g=C=I;continue e}Y=Y.parentNode}}g=g.return}lc(function(){var Re=C,Ve=Hn(p),Qe=[];e:{var Ie=Qy.get(l);if(Ie!==void 0){var $e=Uo,vt=l;switch(l){case"keypress":if($o(p)===0)break e;case"keydown":case"keyup":$e=kh;break;case"focusin":vt="focus",$e=Vo;break;case"focusout":vt="blur",$e=Vo;break;case"beforeblur":case"afterblur":$e=Vo;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":$e=hd;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":$e=bh;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":$e=gd;break;case Vy:case Yy:case Gy:$e=uc;break;case Ky:$e=Xi;break;case"scroll":case"scrollend":$e=mh;break;case"wheel":$e=Ch;break;case"copy":case"cut":case"paste":$e=Ki;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":$e=hc;break;case"toggle":case"beforetoggle":$e=jh}var Rt=(u&4)!==0,An=!Rt&&(l==="scroll"||l==="scrollend"),ke=Rt?Ie!==null?Ie+"Capture":null:Ie;Rt=[];for(var oe=Re,Ee;oe!==null;){var Ge=oe;if(Ee=Ge.stateNode,Ge=Ge.tag,Ge!==5&&Ge!==26&&Ge!==27||Ee===null||ke===null||(Ge=Wi(oe,ke),Ge!=null&&Rt.push(Vc(oe,Ge,Ee))),An)break;oe=oe.return}0<Rt.length&&(Ie=new $e(Ie,vt,null,p,Ve),Qe.push({event:Ie,listeners:Rt}))}}if((u&7)===0){e:{if(Ie=l==="mouseover"||l==="pointerover",$e=l==="mouseout"||l==="pointerout",Ie&&p!==zt&&(vt=p.relatedTarget||p.fromElement)&&(Bn(vt)||vt[_n]))break e;if(($e||Ie)&&(Ie=Ve.window===Ve?Ve:(Ie=Ve.ownerDocument)?Ie.defaultView||Ie.parentWindow:window,$e?(vt=p.relatedTarget||p.toElement,$e=Re,vt=vt?Bn(vt):null,vt!==null&&(An=r(vt),Rt=vt.tag,vt!==An||Rt!==5&&Rt!==27&&Rt!==6)&&(vt=null)):($e=null,vt=Re),$e!==vt)){if(Rt=hd,Ge="onMouseLeave",ke="onMouseEnter",oe="mouse",(l==="pointerout"||l==="pointerover")&&(Rt=hc,Ge="onPointerLeave",ke="onPointerEnter",oe="pointer"),An=$e==null?Ie:Un($e),Ee=vt==null?Ie:Un(vt),Ie=new Rt(Ge,oe+"leave",$e,p,Ve),Ie.target=An,Ie.relatedTarget=Ee,Ge=null,Bn(Ve)===Re&&(Rt=new Rt(ke,oe+"enter",vt,p,Ve),Rt.target=Ee,Rt.relatedTarget=An,Ge=Rt),An=Ge,$e&&vt)t:{for(Rt=K_,ke=$e,oe=vt,Ee=0,Ge=ke;Ge;Ge=Rt(Ge))Ee++;Ge=0;for(var Tt=oe;Tt;Tt=Rt(Tt))Ge++;for(;0<Ee-Ge;)ke=Rt(ke),Ee--;for(;0<Ge-Ee;)oe=Rt(oe),Ge--;for(;Ee--;){if(ke===oe||oe!==null&&ke===oe.alternate){Rt=ke;break t}ke=Rt(ke),oe=Rt(oe)}Rt=null}else Rt=null;$e!==null&&x0(Qe,Ie,$e,Rt,!1),vt!==null&&An!==null&&x0(Qe,An,vt,Rt,!0)}}e:{if(Ie=Re?Un(Re):window,$e=Ie.nodeName&&Ie.nodeName.toLowerCase(),$e==="select"||$e==="input"&&Ie.type==="file")var pn=xc;else if(_t(Ie))if(yc)pn=i_;else{pn=a_;var St=s_}else $e=Ie.nodeName,!$e||$e.toLowerCase()!=="input"||Ie.type!=="checkbox"&&Ie.type!=="radio"?Re&&Jr(Re.elementType)&&(pn=xc):pn=r_;if(pn&&(pn=pn(l,Re))){nn(Qe,pn,p,Ve);break e}St&&St(l,Ie,Re),l==="focusout"&&Re&&Ie.type==="number"&&Re.memoizedProps.value!=null&&bs(Ie,"number",Ie.value)}switch(St=Re?Un(Re):window,l){case"focusin":(_t(St)||St.contentEditable==="true")&&(Xo=St,_h=Re,wc=null);break;case"focusout":wc=_h=Xo=null;break;case"mousedown":Eh=!0;break;case"contextmenu":case"mouseup":case"dragend":Eh=!1,Wy(Qe,p,Ve);break;case"selectionchange":if(l_)break;case"keydown":case"keyup":Wy(Qe,p,Ve)}var Ht;if(Go)e:{switch(l){case"compositionstart":var an="onCompositionStart";break e;case"compositionend":an="onCompositionEnd";break e;case"compositionupdate":an="onCompositionUpdate";break e}an=void 0}else _e?ue(l,p)&&(an="onCompositionEnd"):l==="keydown"&&p.keyCode===229&&(an="onCompositionStart");an&&(gc&&p.locale!=="ko"&&(_e||an!=="onCompositionStart"?an==="onCompositionEnd"&&_e&&(Ht=pd()):(ga=Ve,qi="value"in ga?ga.value:ga.textContent,_e=!0)),St=cf(Re,an),0<St.length&&(an=new Qi(an,l,null,p,Ve),Qe.push({event:an,listeners:St}),Ht?an.data=Ht:(Ht=le(p),Ht!==null&&(an.data=Ht)))),(Ht=xd?at(l,p):dt(l,p))&&(an=cf(Re,"onBeforeInput"),0<an.length&&(St=new Qi("onBeforeInput","beforeinput",null,p,Ve),Qe.push({event:St,listeners:an}),St.data=Ht)),q_(Qe,l,Re,p,Ve)}g0(Qe,u)})}function Vc(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,C=v.stateNode;if(v=v.tag,v!==5&&v!==26&&v!==27||C===null||(v=Wi(l,p),v!=null&&g.unshift(Vc(l,v,C)),v=Wi(l,u),v!=null&&g.push(Vc(l,v,C))),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 C=u._reactName,I=[];p!==null&&p!==g;){var Y=p,re=Y.alternate,Re=Y.stateNode;if(Y=Y.tag,re!==null&&re===g)break;Y!==5&&Y!==26&&Y!==27||Re===null||(re=Re,v?(Re=Wi(p,C),Re!=null&&I.unshift(Vc(p,Re,re))):v||(Re=Wi(p,C),Re!=null&&I.push(Vc(p,Re,re)))),p=p.return}I.length!==0&&l.push({event:u,listeners:I})}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,C){switch(p){case"children":typeof g=="string"?u==="body"||u==="textarea"&&g===""||Va(l,g):(typeof g=="number"||typeof g=="bigint")&&u!=="body"&&Va(l,""+g);break;case"className":Da(l,"class",g);break;case"tabIndex":Da(l,"tabindex",g);break;case"dir":case"role":case"viewBox":case"width":case"height":Da(l,p,g);break;case"style":ma(l,g,C);break;case"data":if(u!=="object"){Da(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=Zr(""+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 C=="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=Zr(""+g),l.setAttribute(p,g);break;case"onClick":g!=null&&(l.onclick=Ra);break;case"onScroll":g!=null&&Xt("scroll",l);break;case"onScrollEnd":g!=null&&Xt("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=Zr(""+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":Xt("beforetoggle",l),Xt("toggle",l),Xr(l,"popover",g);break;case"xlinkActuate":ns(l,"http://www.w3.org/1999/xlink","xlink:actuate",g);break;case"xlinkArcrole":ns(l,"http://www.w3.org/1999/xlink","xlink:arcrole",g);break;case"xlinkRole":ns(l,"http://www.w3.org/1999/xlink","xlink:role",g);break;case"xlinkShow":ns(l,"http://www.w3.org/1999/xlink","xlink:show",g);break;case"xlinkTitle":ns(l,"http://www.w3.org/1999/xlink","xlink:title",g);break;case"xlinkType":ns(l,"http://www.w3.org/1999/xlink","xlink:type",g);break;case"xmlBase":ns(l,"http://www.w3.org/XML/1998/namespace","xml:base",g);break;case"xmlLang":ns(l,"http://www.w3.org/XML/1998/namespace","xml:lang",g);break;case"xmlSpace":ns(l,"http://www.w3.org/XML/1998/namespace","xml:space",g);break;case"is":Xr(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,Xr(l,p,g))}}function tg(l,u,p,g,v,C){switch(p){case"style":ma(l,g,C);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"?Va(l,g):(typeof g=="number"||typeof g=="bigint")&&Va(l,""+g);break;case"onScroll":g!=null&&Xt("scroll",l);break;case"onScrollEnd":g!=null&&Xt("scrollend",l);break;case"onClick":g!=null&&(l.onclick=Ra);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!zo.hasOwnProperty(p))e:{if(p[0]==="o"&&p[1]==="n"&&(v=p.endsWith("Capture"),u=p.slice(2,v?p.length-7:void 0),C=l[Ft]||null,C=C!=null?C[p]:null,typeof C=="function"&&l.removeEventListener(u,C,v),typeof g=="function")){typeof C!="function"&&C!==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,""):Xr(l,p,g)}}}function ws(l,u,p){switch(u){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Xt("error",l),Xt("load",l);var g=!1,v=!1,C;for(C in p)if(p.hasOwnProperty(C)){var I=p[C];if(I!=null)switch(C){case"src":g=!0;break;case"srcSet":v=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,u));default:Cn(l,u,C,I,p,null)}}v&&Cn(l,u,"srcSet",p.srcSet,p,null),g&&Cn(l,u,"src",p.src,p,null);return;case"input":Xt("invalid",l);var Y=C=I=v=null,re=null,Re=null;for(g in p)if(p.hasOwnProperty(g)){var Ve=p[g];if(Ve!=null)switch(g){case"name":v=Ve;break;case"type":I=Ve;break;case"checked":re=Ve;break;case"defaultChecked":Re=Ve;break;case"value":C=Ve;break;case"defaultValue":Y=Ve;break;case"children":case"dangerouslySetInnerHTML":if(Ve!=null)throw Error(s(137,u));break;default:Cn(l,u,g,Ve,p,null)}}xn(l,C,Y,re,Re,I,v,!1);return;case"select":Xt("invalid",l),g=I=C=null;for(v in p)if(p.hasOwnProperty(v)&&(Y=p[v],Y!=null))switch(v){case"value":C=Y;break;case"defaultValue":I=Y;break;case"multiple":g=Y;default:Cn(l,u,v,Y,p,null)}u=C,p=I,l.multiple=!!g,u!=null?Fn(l,!!g,u,!1):p!=null&&Fn(l,!!g,p,!0);return;case"textarea":Xt("invalid",l),C=v=g=null;for(I in p)if(p.hasOwnProperty(I)&&(Y=p[I],Y!=null))switch(I){case"value":g=Y;break;case"defaultValue":v=Y;break;case"children":C=Y;break;case"dangerouslySetInnerHTML":if(Y!=null)throw Error(s(91));break;default:Cn(l,u,I,Y,p,null)}qa(l,g,v,C);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":Xt("beforetoggle",l),Xt("toggle",l),Xt("cancel",l),Xt("close",l);break;case"iframe":case"object":Xt("load",l);break;case"video":case"audio":for(g=0;g<qc.length;g++)Xt(qc[g],l);break;case"image":Xt("error",l),Xt("load",l);break;case"details":Xt("toggle",l);break;case"embed":case"source":case"link":Xt("error",l),Xt("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(Re in p)if(p.hasOwnProperty(Re)&&(g=p[Re],g!=null))switch(Re){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,u));default:Cn(l,u,Re,g,p,null)}return;default:if(Jr(u)){for(Ve in p)p.hasOwnProperty(Ve)&&(g=p[Ve],g!==void 0&&tg(l,u,Ve,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,C=null,I=null,Y=null,re=null,Re=null,Ve=null;for($e in p){var Qe=p[$e];if(p.hasOwnProperty($e)&&Qe!=null)switch($e){case"checked":break;case"value":break;case"defaultValue":re=Qe;default:g.hasOwnProperty($e)||Cn(l,u,$e,null,g,Qe)}}for(var Ie in g){var $e=g[Ie];if(Qe=p[Ie],g.hasOwnProperty(Ie)&&($e!=null||Qe!=null))switch(Ie){case"type":C=$e;break;case"name":v=$e;break;case"checked":Re=$e;break;case"defaultChecked":Ve=$e;break;case"value":I=$e;break;case"defaultValue":Y=$e;break;case"children":case"dangerouslySetInnerHTML":if($e!=null)throw Error(s(137,u));break;default:$e!==Qe&&Cn(l,u,Ie,$e,g,Qe)}}kt(l,I,Y,re,Re,Ve,C,v);return;case"select":$e=I=Y=Ie=null;for(C in p)if(re=p[C],p.hasOwnProperty(C)&&re!=null)switch(C){case"value":break;case"multiple":$e=re;default:g.hasOwnProperty(C)||Cn(l,u,C,null,g,re)}for(v in g)if(C=g[v],re=p[v],g.hasOwnProperty(v)&&(C!=null||re!=null))switch(v){case"value":Ie=C;break;case"defaultValue":Y=C;break;case"multiple":I=C;default:C!==re&&Cn(l,u,v,C,g,re)}u=Y,p=I,g=$e,Ie!=null?Fn(l,!!p,Ie,!1):!!g!=!!p&&(u!=null?Fn(l,!!p,u,!0):Fn(l,!!p,p?[]:"",!1));return;case"textarea":$e=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(I in g)if(v=g[I],C=p[I],g.hasOwnProperty(I)&&(v!=null||C!=null))switch(I){case"value":Ie=v;break;case"defaultValue":$e=v;break;case"children":break;case"dangerouslySetInnerHTML":if(v!=null)throw Error(s(91));break;default:v!==C&&Cn(l,u,I,v,g,C)}Cs(l,Ie,$e);return;case"option":for(var vt in p)if(Ie=p[vt],p.hasOwnProperty(vt)&&Ie!=null&&!g.hasOwnProperty(vt))switch(vt){case"selected":l.selected=!1;break;default:Cn(l,u,vt,null,g,Ie)}for(re in g)if(Ie=g[re],$e=p[re],g.hasOwnProperty(re)&&Ie!==$e&&(Ie!=null||$e!=null))switch(re){case"selected":l.selected=Ie&&typeof Ie!="function"&&typeof Ie!="symbol";break;default:Cn(l,u,re,Ie,g,$e)}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 Rt in p)Ie=p[Rt],p.hasOwnProperty(Rt)&&Ie!=null&&!g.hasOwnProperty(Rt)&&Cn(l,u,Rt,null,g,Ie);for(Re in g)if(Ie=g[Re],$e=p[Re],g.hasOwnProperty(Re)&&Ie!==$e&&(Ie!=null||$e!=null))switch(Re){case"children":case"dangerouslySetInnerHTML":if(Ie!=null)throw Error(s(137,u));break;default:Cn(l,u,Re,Ie,g,$e)}return;default:if(Jr(u)){for(var An in p)Ie=p[An],p.hasOwnProperty(An)&&Ie!==void 0&&!g.hasOwnProperty(An)&&tg(l,u,An,void 0,g,Ie);for(Ve in g)Ie=g[Ve],$e=p[Ve],!g.hasOwnProperty(Ve)||Ie===$e||Ie===void 0&&$e===void 0||tg(l,u,Ve,Ie,g,$e);return}}for(var ke in p)Ie=p[ke],p.hasOwnProperty(ke)&&Ie!=null&&!g.hasOwnProperty(ke)&&Cn(l,u,ke,null,g,Ie);for(Qe in g)Ie=g[Qe],$e=p[Qe],!g.hasOwnProperty(Qe)||Ie===$e||Ie==null&&$e==null||Cn(l,u,Qe,Ie,g,$e)}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],C=v.transferSize,I=v.initiatorType,Y=v.duration;if(C&&Y&&w0(I)){for(I=0,Y=v.responseEnd,g+=1;g<p.length;g++){var re=p[g],Re=re.startTime;if(Re>Y)break;var Ve=re.transferSize,Qe=re.initiatorType;Ve&&w0(Qe)&&(re=re.responseEnd,I+=Ve*(re<Y?1:(Y-Re)/(re-Re)))}if(--g,u+=8*(C+I)/(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 ng=null,sg=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 ag(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 rg=null;function eE(){var l=window.event;return l&&l.type==="popstate"?l===rg?!1:(rg=l,!0):(rg=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 wi(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),Cl(u);return}g--}else if(p==="$"||p==="$?"||p==="$~"||p==="$!"||p==="&")g++;else if(p==="html")Yc(l.ownerDocument.documentElement);else if(p==="head"){p=l.ownerDocument.head,Yc(p);for(var C=p.firstChild;C;){var I=C.nextSibling,Y=C.nodeName;C[ts]||Y==="SCRIPT"||Y==="STYLE"||Y==="LINK"&&C.rel.toLowerCase()==="stylesheet"||p.removeChild(C),C=I}}else p==="body"&&Yc(l.ownerDocument.body);p=v}while(p);Cl(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 ig(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":ig(p),Ks(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[ts])switch(u){case"meta":if(!l.hasAttribute("itemprop"))break;return l;case"link":if(C=l.getAttribute("rel"),C==="stylesheet"&&l.hasAttribute("data-precedence"))break;if(C!==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(C=l.getAttribute("src"),(C!==(v.src==null?null:v.src)||l.getAttribute("type")!==(v.type==null?null:v.type)||l.getAttribute("crossorigin")!==(v.crossOrigin==null?null:v.crossOrigin))&&C&&l.hasAttribute("async")&&!l.hasAttribute("itemprop"))break;return l;default:return l}}else if(u==="input"&&l.type==="hidden"){var C=v.name==null?null:""+v.name;if(v.type==="hidden"&&l.getAttribute("name")===C)return l}else return l;if(l=Sa(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=Sa(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=Sa(l.nextSibling),l===null))return null;return l}function og(l){return l.data==="$?"||l.data==="$~"}function lg(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 Sa(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 cg=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 Sa(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 Yc(l){for(var u=l.attributes;u.length;)l.removeAttributeNode(u[0]);Ks(l)}var Ca=new Map,D0=new Set;function df(l){return typeof l.getRootNode=="function"?l.getRootNode():l.nodeType===9?l:l.ownerDocument}var Rr=W.d;W.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=us(l);u!==null&&u.tag===5&&u.type==="form"?Kv(u):Rr.r(l)}var wl=typeof document>"u"?null:document;function R0(l,u,p){var g=wl;if(g&&typeof u=="string"&&u){var v=Lt(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"),ws(u,"link",l),On(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=wl;if(g&&l&&u){var v='link[rel="preload"][as="'+Lt(u)+'"]';u==="image"&&p&&p.imageSrcSet?(v+='[imagesrcset="'+Lt(p.imageSrcSet)+'"]',typeof p.imageSizes=="string"&&(v+='[imagesizes="'+Lt(p.imageSizes)+'"]')):v+='[href="'+Lt(l)+'"]';var C=v;switch(u){case"style":C=kl(l);break;case"script":C=Sl(l)}Ca.has(C)||(l=m({rel:"preload",href:u==="image"&&p&&p.imageSrcSet?void 0:l,as:u},p),Ca.set(C,l),g.querySelector(v)!==null||u==="style"&&g.querySelector(Gc(C))||u==="script"&&g.querySelector(Kc(C))||(u=g.createElement("link"),ws(u,"link",l),On(u),g.head.appendChild(u)))}}function fE(l,u){Rr.m(l,u);var p=wl;if(p&&l){var g=u&&typeof u.as=="string"?u.as:"script",v='link[rel="modulepreload"][as="'+Lt(g)+'"][href="'+Lt(l)+'"]',C=v;switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":C=Sl(l)}if(!Ca.has(C)&&(l=m({rel:"modulepreload",href:l},u),Ca.set(C,l),p.querySelector(v)===null)){switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(p.querySelector(Kc(C)))return}g=p.createElement("link"),ws(g,"link",l),On(g),p.head.appendChild(g)}}}function pE(l,u,p){Rr.S(l,u,p);var g=wl;if(g&&l){var v=Qs(g).hoistableStyles,C=kl(l);u=u||"default";var I=v.get(C);if(!I){var Y={loading:0,preload:null};if(I=g.querySelector(Gc(C)))Y.loading=5;else{l=m({rel:"stylesheet",href:l,"data-precedence":u},p),(p=Ca.get(C))&&ug(l,p);var re=I=g.createElement("link");On(re),ws(re,"link",l),re._p=new Promise(function(Re,Ve){re.onload=Re,re.onerror=Ve}),re.addEventListener("load",function(){Y.loading|=1}),re.addEventListener("error",function(){Y.loading|=2}),Y.loading|=4,ff(I,u,g)}I={type:"stylesheet",instance:I,count:1,state:Y},v.set(C,I)}}}function hE(l,u){Rr.X(l,u);var p=wl;if(p&&l){var g=Qs(p).hoistableScripts,v=Sl(l),C=g.get(v);C||(C=p.querySelector(Kc(v)),C||(l=m({src:l,async:!0},u),(u=Ca.get(v))&&dg(l,u),C=p.createElement("script"),On(C),ws(C,"link",l),p.head.appendChild(C)),C={type:"script",instance:C,count:1,state:null},g.set(v,C))}}function mE(l,u){Rr.M(l,u);var p=wl;if(p&&l){var g=Qs(p).hoistableScripts,v=Sl(l),C=g.get(v);C||(C=p.querySelector(Kc(v)),C||(l=m({src:l,async:!0,type:"module"},u),(u=Ca.get(v))&&dg(l,u),C=p.createElement("script"),On(C),ws(C,"link",l),p.head.appendChild(C)),C={type:"script",instance:C,count:1,state:null},g.set(v,C))}}function O0(l,u,p,g){var v=(v=ee.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=kl(p.href),p=Qs(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=kl(p.href);var C=Qs(v).hoistableStyles,I=C.get(l);if(I||(v=v.ownerDocument||v,I={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},C.set(l,I),(C=v.querySelector(Gc(l)))&&!C._p&&(I.instance=C,I.state.loading=5),Ca.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},Ca.set(l,p),C||gE(v,l,p,I.state))),u&&g===null)throw Error(s(528,""));return I}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=Sl(p),p=Qs(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 kl(l){return'href="'+Lt(l)+'"'}function Gc(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}),ws(u,"link",p),On(u),l.head.appendChild(u))}function Sl(l){return'[src="'+Lt(l)+'"]'}function Kc(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~="'+Lt(p.href)+'"]');if(g)return u.instance=g,On(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"),On(g),ws(g,"style",v),ff(g,p.precedence,l),u.instance=g;case"stylesheet":v=kl(p.href);var C=l.querySelector(Gc(v));if(C)return u.state.loading|=4,u.instance=C,On(C),C;g=L0(p),(v=Ca.get(v))&&ug(g,v),C=(l.ownerDocument||l).createElement("link"),On(C);var I=C;return I._p=new Promise(function(Y,re){I.onload=Y,I.onerror=re}),ws(C,"link",g),u.state.loading|=4,ff(C,p.precedence,l),u.instance=C;case"script":return C=Sl(p.src),(v=l.querySelector(Kc(C)))?(u.instance=v,On(v),v):(g=p,(v=Ca.get(C))&&(g=m({},p),dg(g,v)),l=l.ownerDocument||l,v=l.createElement("script"),On(v),ws(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,C=v,I=0;I<g.length;I++){var Y=g[I];if(Y.dataset.precedence===u)C=Y;else if(C!==v)break}C?C.parentNode.insertBefore(l,C.nextSibling):(u=p.nodeType===9?p.head:p,u.insertBefore(l,u.firstChild))}function ug(l,u){l.crossOrigin==null&&(l.crossOrigin=u.crossOrigin),l.referrerPolicy==null&&(l.referrerPolicy=u.referrerPolicy),l.title==null&&(l.title=u.title)}function dg(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 C=p[v];if(!(C[ts]||C[ct]||l==="link"&&C.getAttribute("rel")==="stylesheet")&&C.namespaceURI!=="http://www.w3.org/2000/svg"){var I=C.getAttribute(u)||"";I=l+I;var Y=g.get(I);Y?Y.push(C):g.set(I,[C])}}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=kl(g.href),C=u.querySelector(Gc(v));if(C){u=C._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=C,On(C);return}C=u.ownerDocument||u,g=L0(g),(v=Ca.get(v))&&ug(g,v),C=C.createElement("link"),On(C);var I=C;I._p=new Promise(function(Y,re){I.onload=Y,I.onerror=re}),ws(C,"link",g),p.instance=C}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 fg=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 C=l.unsuspend;l.unsuspend=null,C()}},6e4+u);0<l.imgBytes&&fg===0&&(fg=62500*Z_());var v=setTimeout(function(){if(l.waitingForImages=!1,l.count===0&&(l.stylesheets&&gf(l,l.stylesheets),l.unsuspend)){var C=l.unsuspend;l.unsuspend=null,C()}},(l.imgBytes>fg?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]"),C=0;C<v.length;C++){var I=v[C];(I.nodeName==="LINK"||I.getAttribute("media")!=="not all")&&(p.set(I.dataset.precedence,I),g=I)}g&&p.set(null,g)}v=u.instance,I=v.getAttribute("data-precedence"),C=p.get(I)||g,C===g&&p.set(null,v),p.set(I,v),this.count++,g=hf.bind(this),v.addEventListener("load",g),v.addEventListener("error",g),C?C.parentNode.insertBefore(v,C.nextSibling):(l=l.nodeType===9?l.head:l,l.insertBefore(v,l.firstChild)),u.state.loading|=4}}var Qc={$$typeof:S,Provider:null,Consumer:null,_currentValue:V,_currentValue2:V,_threadCount:0};function wE(l,u,p,g,v,C,I,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=Ce(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ce(0),this.hiddenUpdates=Ce(null),this.identifierPrefix=g,this.onUncaughtError=v,this.onCaughtError=C,this.onRecoverableError=I,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=re,this.incompleteTransitions=new Map}function z0(l,u,p,g,v,C,I,Y,re,Re,Ve,Qe){return l=new wE(l,u,p,I,re,Re,Ve,Qe,Y),u=1,C===!0&&(u|=24),C=Zs(3,null,null,u),l.current=C,C.stateNode=l,u=qh(),u.refCount++,l.pooledCache=u,u.refCount++,C.memoizedState={element:g,isDehydrated:p,cache:u},Kh(C),l}function $0(l){return l?(l=el,l):el}function U0(l,u,p,g,v,C){v=$0(v),g.context===null?g.context=v:g.pendingContext=v,g=ui(u),g.payload={element:p},C=C===void 0?null:C,C!==null&&(g.callback=C),p=di(l,g,u),p!==null&&(Us(p,l,u),Tc(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 pg(l,u){H0(l,u),(l=l.alternate)&&H0(l,u)}function W0(l){if(l.tag===13||l.tag===31){var u=to(l,67108864);u!==null&&Us(u,l,67108864),pg(l,67108864)}}function q0(l){if(l.tag===13||l.tag===31){var u=aa();u=Dt(u);var p=to(l,u);p!==null&&Us(p,l,u),pg(l,u)}}var bf=!0;function kE(l,u,p,g){var v=z.T;z.T=null;var C=W.p;try{W.p=2,hg(l,u,p,g)}finally{W.p=C,z.T=v}}function SE(l,u,p,g){var v=z.T;z.T=null;var C=W.p;try{W.p=8,hg(l,u,p,g)}finally{W.p=C,z.T=v}}function hg(l,u,p,g){if(bf){var v=mg(g);if(v===null)eg(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 C=us(v);if(C!==null)switch(C.tag){case 3:if(C=C.stateNode,C.current.memoizedState.isDehydrated){var I=ot(C.pendingLanes);if(I!==0){var Y=C;for(Y.pendingLanes|=2,Y.entangledLanes|=2;I;){var re=1<<31-ge(I);Y.entanglements[1]|=re,I&=~re}Qa(C),(mn&6)===0&&(Zd=lt()+500,Wc(0))}}break;case 31:case 13:Y=to(C,2),Y!==null&&Us(Y,C,2),tf(),pg(C,2)}if(C=mg(g),C===null&&eg(l,u,g,xf,p),C===v)break;v=C}v!==null&&g.stopPropagation()}else eg(l,u,g,null,p)}}function mg(l){return l=Hn(l),gg(l)}var xf=null;function gg(l){if(xf=null,l=Bn(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 J:return 2;case ae:return 8;case Se:case Z:return 32;case he:return 268435456;default:return 32}default:return 32}}var bg=!1,ki=null,Si=null,Ci=null,Xc=new Map,Jc=new Map,Ai=[],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":ki=null;break;case"dragenter":case"dragleave":Si=null;break;case"mouseover":case"mouseout":Ci=null;break;case"pointerover":case"pointerout":Xc.delete(u.pointerId);break;case"gotpointercapture":case"lostpointercapture":Jc.delete(u.pointerId)}}function Zc(l,u,p,g,v,C){return l===null||l.nativeEvent!==C?(l={blockedOn:u,domEventName:p,eventSystemFlags:g,nativeEvent:C,targetContainers:[v]},u!==null&&(u=us(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 ki=Zc(ki,l,u,p,g,v),!0;case"dragenter":return Si=Zc(Si,l,u,p,g,v),!0;case"mouseover":return Ci=Zc(Ci,l,u,p,g,v),!0;case"pointerover":var C=v.pointerId;return Xc.set(C,Zc(Xc.get(C)||null,l,u,p,g,v)),!0;case"gotpointercapture":return C=v.pointerId,Jc.set(C,Zc(Jc.get(C)||null,l,u,p,g,v)),!0}return!1}function G0(l){var u=Bn(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,yt(l.priority,function(){q0(p)});return}}else if(u===31){if(u=c(p),u!==null){l.blockedOn=u,yt(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=mg(l.nativeEvent);if(p===null){p=l.nativeEvent;var g=new p.constructor(p.type,p);zt=g,p.target.dispatchEvent(g),zt=null}else return u=us(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(){bg=!1,ki!==null&&yf(ki)&&(ki=null),Si!==null&&yf(Si)&&(Si=null),Ci!==null&&yf(Ci)&&(Ci=null),Xc.forEach(K0),Jc.forEach(K0)}function vf(l,u){l.blockedOn===u&&(l.blockedOn=null,bg||(bg=!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(gg(g||p)===null)continue;break}var C=us(p);C!==null&&(l.splice(u,3),u-=3,mm(C,{pending:!0,data:v,method:p.method,action:g},g,v))}}))}function Cl(l){function u(re){return vf(re,l)}ki!==null&&vf(ki,l),Si!==null&&vf(Si,l),Ci!==null&&vf(Ci,l),Xc.forEach(u),Jc.forEach(u);for(var p=0;p<Ai.length;p++){var g=Ai[p];g.blockedOn===l&&(g.blockedOn=null)}for(;0<Ai.length&&(p=Ai[0],p.blockedOn===null);)G0(p),p.blockedOn===null&&Ai.shift();if(p=(l.ownerDocument||l).$$reactFormReplay,p!=null)for(g=0;g<p.length;g+=3){var v=p[g],C=p[g+1],I=v[Ft]||null;if(typeof C=="function")I||Q0(p);else if(I){var Y=null;if(C&&C.hasAttribute("formAction")){if(v=C,I=C[Ft]||null)Y=I.formAction;else if(gg(v)!==null)continue}else Y=I.action;typeof Y=="function"?p[g+1]=Y:(p.splice(g,3),g-=3),Q0(p)}}}function X0(){function l(C){C.canIntercept&&C.info==="react-transition"&&C.intercept({handler:function(){return new Promise(function(I){return v=I})},focusReset:"manual",scroll:"manual"})}function u(){v!==null&&(v(),v=null),g||setTimeout(p,20)}function p(){if(!g&&!navigation.transition){var C=navigation.currentEntry;C&&C.url!=null&&navigation.navigate(C.url,{state:C.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 xg(l){this._internalRoot=l}kf.prototype.render=xg.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=xg.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[_n]=null}};function kf(l){this._internalRoot=l}kf.prototype.unstable_scheduleHydration=function(l){if(l){var u=cn();l={blockedOn:null,target:l,priority:u};for(var p=0;p<Ai.length&&u!==0&&u<Ai[p].priority;p++);Ai.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"));W.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:z,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Sf=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Sf.isDisabled&&Sf.supportsFiber)try{be=Sf.inject(NE),Pe=Sf}catch{}}return tu.createRoot=function(l,u){if(!a(l))throw Error(s(299));var p=!1,g="",v=rw,C=iw,I=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&&(C=u.onCaughtError),u.onRecoverableError!==void 0&&(I=u.onRecoverableError)),u=z0(l,1,!1,null,null,p,g,null,v,C,I,X0),l[_n]=u.current,Zm(l),new xg(u)},tu.hydrateRoot=function(l,u,p){if(!a(l))throw Error(s(299));var g=!1,v="",C=rw,I=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&&(C=p.onUncaughtError),p.onCaughtError!==void 0&&(I=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,C,I,Y,X0),u.context=$0(null),p=u.current,g=aa(),g=Dt(g),v=ui(g),v.callback=null,di(p,v,g),p=g,u.current.lanes=p,Be(u,p),Qa(u),l[_n]=u.current,Zm(l),new kf(u)},tu.version="19.2.4",tu}var ck;function SM(){if(ck)return wg.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(),wg.exports=kM(),wg.exports}var CM=SM();const Bt=t=>typeof t=="string",nu=()=>{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||Bt(t),Tu=(t,e,n)=>{const s=Bt(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}=Tu(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=Tu(t,i,Object);for(;c.obj===void 0&&i.length;)r=`${i[i.length-1]}.${r}`,i=i.slice(0,i.length-1),c=Tu(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}=Tu(t,e,Object);a[r]=a[r]||[],a[r].push(n)},fp=(t,e)=>{const{obj:n,k:s}=Tu(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?Bt(t[s])||t[s]instanceof String||Bt(e[s])||e[s]instanceof String?n&&(t[s]=e[s]):hj(t[s],e[s],n):t[s]=e[s]);return t},mo=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),_M={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"},EM=t=>Bt(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},$b=(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},$u=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:(Bt(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):Bt(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||!Bt(s)?d:$b((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)(Bt(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 Fl(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 Cg=t=>!Bt(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=Cg(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:Bt(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:Bt(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=Fl(e,{...this.options,...a})),Array.isArray(e)||(e=[String(e)]),e=e.map($=>typeof $=="function"?Fl($,{...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 A=(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&&!Bt(a.count),D=hp.hasDefaultValue(a),E=T?this.pluralResolver.getSuffix(m,a.count,a):"",P=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${P}`]||a.defaultValue;let M=w;S&&!w&&D&&(M=_);const R=Cg(M),F=Object.prototype.toString.apply(M);if(S&&M&&R&&!k.includes(F)&&!(Bt(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(A,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),H=$?[]:{},L=$?N:A;for(const z in M)if(Object.prototype.hasOwnProperty.call(M,z)){const W=`${L}${i}${z}`;D&&!w?H[z]=this.translate(W,{...a,defaultValue:Cg(_)?_[z]:void 0,joinArrays:!1,ns:d}):H[z]=this.translate(W,{...a,joinArrays:!1,ns:d}),H[z]===W&&(H[z]=M[z])}w=H}}else if(S&&Bt(j)&&Array.isArray(w))w=w.join(j),w&&(w=this.extendTranslation(w,e,a,s));else{let $=!1,H=!1;!this.isValidLookup(w)&&D&&($=!0,w=_),this.isValidLookup(w)||(H=!0,w=c);const z=(a.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&H?void 0:w,W=D&&_!==w&&this.options.updateMissing;if(H||$||W){if(this.logger.log(W?"updateKey":"missingKey",m,f,c,W?_: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 me=D&&q!==w?q:z;this.options.missingKeyHandler?this.options.missingKeyHandler(K,f,se,me,W,a):(ce=this.backendConnector)!=null&&ce.saveMissing&&this.backendConnector.saveMissing(K,f,se,me,W,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),H&&w===c&&this.options.appendNamespaceToMissingKey&&(w=`${f}${h}${c}`),(H||$)&&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=Bt(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&&!Bt(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=Bt(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 Bt(e)&&(e=[e]),Array.isArray(e)&&(e=e.map(d=>typeof d=="function"?Fl(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&&!Bt(n.count),y=b&&!n.ordinal&&n.count===0,w=n.context!==void 0&&(Bt(n.context)||typeof n.context=="number")&&n.context!=="",A=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[`${A[0]}-${N}`]&&((k=this.utils)!=null&&k.hasLoadedNamespace)&&!((j=this.utils)!=null&&j.hasLoadedNamespace(c))&&(this.checkedLoadedFor[`${A[0]}-${N}`]=!0,this.logger.warn(`key "${a}" for languages "${A.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!!!")),A.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 P;b&&(P=this.pluralResolver.getSuffix(S,n.count,n));const O=`${this.options.pluralSeparator}zero`,_=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(b&&(n.ordinal&&P.startsWith(_)&&T.push(h+P.replace(_,this.options.pluralSeparator)),T.push(h+P),y&&T.push(h+O)),w){const M=`${h}${this.options.contextSeparator||"_"}${n.context}`;T.push(M),b&&(n.ordinal&&P.startsWith(_)&&T.push(M+P.replace(_,this.options.pluralSeparator)),T.push(M+P),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&&!Bt(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=$u(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=$u(e),!e||!e.includes("-"))return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(Bt(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)),Bt(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 Bt(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))):Bt(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=$u(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&&Bt(n)&&(r=$b(t,n,s),r===void 0&&(r=$b(e,n,s))),r},Ag=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:A,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?mo(r):i||"{{",this.suffix=c?mo(c):d||"}}",this.formatSeparator=f||",",this.unescapePrefix=h?"":m||"-",this.unescapeSuffix=this.unescapePrefix?"":h||"",this.nestingPrefix=b?mo(b):y||mo("$t("),this.nestingSuffix=w?mo(w):A||mo(")"),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 A=w.split(this.formatSeparator),N=A.shift().trim(),k=A.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=>Ag(w)},{regex:this.regexp,safeValue:w=>this.escapeValue?Ag(this.escape(w)):Ag(w)}].forEach(w=>{for(c=0;r=w.regex.exec(e);){const A=r[1].trim();if(i=f(A),i===void 0)if(typeof h=="function"){const k=h(e,r,a);i=Bt(k)?k:""}else if(a&&Object.prototype.hasOwnProperty.call(a,A))i="";else if(m){i=r[0];continue}else this.logger.warn(`missed to pass in variable ${A} for interpolating ${e}`),i="";else!Bt(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(`${mo(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(A){return this.logger.warn(`failed parsing options string in nesting for key ${d}`,A),`${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&&!Bt(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&&!Bt(r))return r;Bt(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($u(s),a),e[i]=c),c(n)}},FM=t=>(e,n,s)=>t($u(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();Bt(e)&&(e=this.languageUtils.toResolveHierarchy(e)),Bt(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 A;w.length===5?A=w(e,n,s,a,y):A=w(e,n,s,a),A&&typeof A.then=="function"?A.then(N=>c(null,N)).catch(c):c(null,A)}catch(A){c(A)}else w(e,n,s,a,c,y)}!e||!e[0]||this.store.addResource(e[0],n,s,a)}}}const jg=()=>({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]),Bt(t[1])&&(e.defaultValue=t[1]),Bt(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=>(Bt(t.ns)&&(t.ns=[t.ns]),Bt(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),Bt(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 _u 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&&(Bt(e.ns)?e.defaultNS=e.ns:e.ns.includes("translation")||(e.defaultNS=e.ns[0]));const s=jg();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=nu(),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=Bt(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=nu();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=nu();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=Bt(c)?c:c&&c[0],f=this.store.hasLanguageSomeTranslations(d)?d:this.services.languageUtils.getBestMatchFromCodes(Bt(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=Fl(d.keyPrefix,f));const h=this.options.keySeparator||".";let m;return d.keyPrefix&&Array.isArray(r)?m=r.map(b=>(typeof b=="function"&&(b=Fl(b,f)),`${d.keyPrefix}${h}${b}`)):(typeof r=="function"&&(r=Fl(r,f)),m=d.keyPrefix?`${d.keyPrefix}${h}${r}`:r),this.t(m,d)};return Bt(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=nu();return this.options.ns?(Bt(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=nu();Bt(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(jg());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 _u(e,n);return s.createInstance=_u.createInstance,s}cloneInstance(e={},n=Cf){const s=e.forkResourceStore;s&&delete e.forkResourceStore;const a={...this.options,...e,isClone:!0},r=new _u(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={...jg().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 Rn=_u.createInstance();Rn.createInstance;Rn.dir;Rn.init;Rn.loadResources;Rn.reloadResources;Rn.use;Rn.changeLanguage;Rn.getFixedT;Rn.t;Rn.exists;Rn.setDefaultNamespace;Rn.hasLoadedNamespace;Rn.loadNamespaces;Rn.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);Eo(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={},Ub=(t,e,n,s)=>{Eo(n)&&kk[n]||(Eo(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)}},Hb=(t,e,n)=>{t.loadNamespaces(e,bj(t,n))},Sk=(t,e,n,s)=>{if(Eo(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return Hb(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?(Ub(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}}),Eo=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 Wb={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:QM,transDefaultProps:void 0};const XM=(t={})=>{Wb={...Wb,...t}},JM=()=>Wb;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 Ng={exports:{}},Tg={};/**
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 Tg;Ck=1;var t=Tx();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}}),A=w[0].inst,N=w[1];return r(function(){A.value=y,A.getSnapshot=b,d(A)&&N({inst:A})},[m,y,b]),a(function(){return d(A)&&N({inst:A}),m(function(){d(A)&&N({inst:A})})},[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 Tg.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:h,Tg}var Ak;function rD(){return Ak||(Ak=1,Ng.exports=aD()),Ng.exports}var iD=rD();const oD=(t,e)=>{if(Eo(e))return e;if(VM(e)&&Eo(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=()=>()=>{},pt=(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||Ub(r,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const i=x.useMemo(()=>{var F;return{...JM(),...(F=r==null?void 0:r.options)==null?void 0:F.react,...e}},[r,e]),{useSuspense:c,keyPrefix:d}=i,f=t||a||((_=r==null?void 0:r.options)==null?void 0:_.defaultNS),h=Eo(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(F=>{if(!r)return cD;const{bindI18n:$,bindI18nStore:H}=i,L=()=>{b.current+=1,F()};return $&&r.on($,L),H&&r.store.on(H,L),()=>{$&&$.split(" ").forEach(z=>r.off(z,L)),H&&H.split(" ").forEach(z=>r.store.off(z,L))}},[r,i]),w=x.useRef(),A=x.useCallback(()=>{if(!r)return lD;const F=!!(r.isInitialized||r.initializedStoreOnce)&&m.every(V=>qM(V,r,i)),$=e.lng||r.language,H=b.current,L=w.current;if(L&&L.ready===F&&L.lng===$&&L.keyPrefix===d&&L.revision===H)return L;const W={t:r.getFixedT($,i.nsMode==="fallback"?m:m[0],d),ready:F,lng:$,keyPrefix:d,revision:H};return w.current=W,W},[r,m,d,i,e.lng]),[N,k]=x.useState(0),{t:j,ready:S}=iD.useSyncExternalStore(y,A,A);x.useEffect(()=>{if(r&&!S&&!c){const F=()=>k($=>$+1);e.lng?Sk(r,e.lng,m,F):Hb(r,m,F)}},[r,e.lng,m,S,c,N]);const T=r||{},D=x.useRef(null),E=x.useRef(),P=F=>{const $=Object.getOwnPropertyDescriptors(F);$.__original&&delete $.__original;const H=Object.create(Object.getPrototypeOf(F),$);if(!Object.prototype.hasOwnProperty.call(H,"__original"))try{Object.defineProperty(H,"__original",{value:F,writable:!1,enumerable:!1,configurable:!1})}catch{}return H},O=x.useMemo(()=>{const F=T,$=F==null?void 0:F.language;let H=F;F&&(D.current&&D.current.__original===F?E.current!==$?(H=P(F),D.current=H,E.current=$):H=D.current:(H=P(F),D.current=H,E.current=$));const L=!S&&!c?(...W)=>(Ub(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(...W)):j,z=[L,H,S];return z.t=L,z.i18n=H,z.ready=S,z},[j,T,S,T.resolvedLanguage,T.language,T.languages]);if(r&&c&&!S)throw new Promise(F=>{const $=()=>F();e.lng?Sk(r,e.lng,m,$):Hb(r,m,$)});return O};function qb(t){"@babel/helpers - typeof";return qb=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},qb(t)}function yj(){return typeof XMLHttpRequest=="function"||(typeof XMLHttpRequest>"u"?"undefined":qb(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={},wt=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 Mo(e)=="symbol"?e:e+""}function bD(t,e){if(Mo(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var s=n.call(t,e);if(Mo(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Mo(t){"@babel/helpers - typeof";return Mo=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},Mo(t)}var Li=typeof fetch=="function"?fetch:void 0;typeof global<"u"&&global.fetch?Li=global.fetch:typeof window<"u"&&window.fetch&&(Li=window.fetch);var Uu;yj()&&(typeof global<"u"&&global.XMLHttpRequest?Uu=global.XMLHttpRequest:typeof window<"u"&&window.XMLHttpRequest&&(Uu=window.XMLHttpRequest));var mp;typeof ActiveXObject=="function"&&(typeof global<"u"&&global.ActiveXObject?mp=global.ActiveXObject:typeof window<"u"&&window.ActiveXObject&&(mp=window.ActiveXObject));typeof Li!="function"&&(Li=void 0);if(!Li&&!Uu&&!mp)try{wt(()=>import("./browser-ponyfill-DZOWXZ4K.js").then(t=>t.b),__vite__mapDeps([0,1])).then(function(t){Li=t.default}).catch(function(){})}catch{}var Vb=function(e,n){if(n&&Mo(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):Li(e,n).then(r).catch(s)},Mk=!1,xD=function(e,n,s,a){e.queryStringParams&&(n=Vb(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&&Mo(s)==="object"&&(s=Vb("",s).slice(1)),e.queryStringParams&&(n=Vb(n,e.queryStringParams));try{var r=Uu?new Uu: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(){},Li&&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 Wl(t){"@babel/helpers - typeof";return Wl=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},Wl(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 _g(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 Wl(e)=="symbol"?e:e+""}function CD(t,e){if(Wl(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var s=n.call(t,e);if(Wl(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=_g(_g(_g({},AD()),this.options||{}),a),this.allOptions=r,this.services&&this.options.reloadInterval){var i=setInterval(function(){return s.reload()},this.options.reloadInterval);Wl(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,A;try{typeof m.data=="string"?w=i.options.parse(m.data,a,r):w=m.data}catch{A="failed parsing "+n+" to json"}if(A)return s(A,!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(A,N){f+=1,h.push(A),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 Al=null;const Lk=()=>{if(Al!==null)return Al;try{if(Al=typeof window<"u"&&window.localStorage!==null,!Al)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Al=!1}return Al};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 jl=null;const Ik=()=>{if(jl!==null)return jl;try{if(jl=typeof window<"u"&&window.sessionStorage!==null,!jl)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{jl=!1}return jl};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"},Yb={running:"#4aff9e",stopped:"#888888",error:"#ff4a4a",unknown:"#ffaa00",starting:"#4a9eff",stopping:"#ffaa00"},$D={on_track:"#4aff9e",stalled:"#ff9e4a",blocked:"#ff4a4a",completed:"#4a9eff",idle:"#888888"},Aq=["#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 Ex(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 Mx(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 Dx(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 Eu(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:""}Rn.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(Rn)});const mt={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"},Gb="tide-backend-url-change";function Ta(t,e){try{const n=localStorage.getItem(t);return n===null?e:JSON.parse(n)}catch{return e}}function $a(t,e=""){try{return localStorage.getItem(t)??e}catch{return e}}function Ei(t,e=!1){try{const n=localStorage.getItem(t);return n===null?e:n==="true"}catch{return e}}function Rx(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 Pa(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 Mi(t,e){try{localStorage.setItem(t,String(e))}catch(n){console.error(`Failed to save to localStorage: ${t}`,n)}}function Ox(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 Ma(){const t=Lx();return t?t.replace(/\/$/,""):`${window.location.protocol}//${window.location.host}`}function Fi(){return $a(mt.AUTH_TOKEN,"")}function Lx(){return $a(mt.BACKEND_URL,"")}function VD(t){const e=t.trim();Wr(mt.BACKEND_URL,e),typeof window<"u"&&window.dispatchEvent(new CustomEvent(Gb,{detail:e}))}function YD(t){if(typeof window>"u")return()=>{};const e=s=>{t(s.detail)},n=s=>{s.key===mt.BACKEND_URL&&t(s.newValue??"")};return window.addEventListener(Gb,e),window.addEventListener("storage",n),()=>{window.removeEventListener(Gb,e),window.removeEventListener("storage",n)}}function Ot(t){return`${Ma()}${t}`}async function Pt(t,e){const n=Fi(),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 Kb(t){const e=Fi();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 fs(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 Jt(t,e,n){const s=x.useRef(n);s.current=n,x.useEffect(()=>e?XD(t,()=>s.current()):void 0,[t,e])}const Hu=5,Eg={0:0,1:4,2:8,3:14,4:25,5:50};let Mu=null,Bk=!1;async function eR(){if(Bk)return Mu;Bk=!0;try{const t=await wt(()=>import("./index-DBpmD8r7.js"),__vite__mapDeps([2,3,1,4]));Mu={Haptics:t.Haptics,ImpactStyle:t.ImpactStyle}}catch{}return Mu}eR();function xp(t){const e=Math.round(t),n=e<=0?0:e>=Hu?Hu:e;if(n!==0){if(Mu){const{Haptics:s,ImpactStyle:a}=Mu;if(n<=2&&typeof s.selectionChanged=="function"){s.selectionChanged().catch(()=>{navigator.vibrate&&navigator.vibrate(Eg[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(Eg[n])});return}}navigator.vibrate&&navigator.vibrate(Eg[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(A=>{if(A.touches.length!==1)return;const N=A.touches[0];h.current={startX:N.clientX,startY:N.clientY,startTime:Date.now(),isTracking:!0,hasMovedEnough:!1}},[]),b=x.useCallback(A=>{if(!h.current.isTracking||A.touches.length!==1)return;const N=A.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(A=>{const N=h.current.isTracking,k=h.current.hasMovedEnough;if(!N)return;const j=A.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 A=h.current.hasMovedEnough;h.current.isTracking=!1,h.current.hasMovedEnough=!1,A&&(d==null||d())},[d]);x.useEffect(()=>{const A=t.current;if(!(!A||!a||!(window.innerWidth<=768&&"ontouchstart"in window)))return A.addEventListener("touchstart",m,{passive:!0}),A.addEventListener("touchmove",b,{passive:!0}),A.addEventListener("touchend",y,{passive:!0}),A.addEventListener("touchcancel",w,{passive:!0}),()=>{A.removeEventListener("touchstart",m),A.removeEventListener("touchmove",b),A.removeEventListener("touchend",y),A.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 P=D.closest("[data-agent-id]");P&&k.contains(P)&&(E=P.dataset.agentId)}if(E!==h.current&&(h.current=E,d(E),E)){const P=U.getState().settings.vibrationIntensity??1;xp(P)}},[n]),A=x.useCallback(()=>{const N=h.current;if(N){const k=U.getState().settings.vibrationIntensity??1,j=k<=0?0:Math.min(k+1,Hu);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,P=0,O=0,_=0,M=0,R=0;const F=()=>{M&&(cancelAnimationFrame(M),M=0)},$=()=>{if(Math.abs(_)<$k){_=0;return}N.scrollTop+=_,_*=tR,M=requestAnimationFrame($)},H=V=>{if(F(),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,P=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&&(_=(P-B)/se*16),P=B,O=K}},z=V=>{if(f.current&&V.touches.length===0){A();return}f.current||(S||j)&&V.touches.length===0&&(S&&Math.abs(_)>$k&&(M=requestAnimationFrame($)),S=!1,j=!1)},W=()=>{S=!1,j=!1,F(),f.current&&y()};return N.addEventListener("touchstart",H,{passive:!1}),N.addEventListener("touchmove",L,{passive:!1}),N.addEventListener("touchend",z,{passive:!0}),N.addEventListener("touchcancel",W,{passive:!0}),()=>{N.removeEventListener("touchstart",H),N.removeEventListener("touchmove",L),N.removeEventListener("touchend",z),N.removeEventListener("touchcancel",W),N.style.touchAction=k,F();const V=n.current;V&&(V.style.paddingTop="",V.style.paddingBottom="")}},[e,n,s,b,y,w,A]),{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 A=w.document.createElement("div");A.id="pip-root",A.style.width="100%",A.style.height="100%",w.document.body.appendChild(A),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(A),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 su(){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:su(),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:su(),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:su(),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:su(),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:su(),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 ks=new oR,Wu={debug:(t,e,n)=>ks.debug(t,e,n),info:(t,e,n)=>ks.info(t,e,n),warn:(t,e,n)=>ks.warn(t,e,n),error:(t,e,n)=>ks.error(t,e,n)};/*! Capacitor: https://capacitorjs.com/ - MIT License */var ql;(function(t){t.Unimplemented="UNIMPLEMENTED",t.Unavailable="UNAVAILABLE"})(ql||(ql={}));class Mg 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(),A=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(A){const F=A==null?void 0:A.methods.find($=>_===$.name);if(F)return F.rtype==="promise"?$=>n.nativePromise(m,_.toString(),$):($,H)=>n.nativeCallback(m,_.toString(),$,H);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 Mg(`"${m}" plugin is not implemented on ${w}`,ql.Unimplemented)}},S=O=>{let _;const M=(...R)=>{const F=k().then($=>{const H=j($,O);if(H){const L=H(...R);return _=L==null?void 0:L.remove,L}else throw new Mg(`"${m}.${O}()" is not implemented on ${w}`,ql.Unimplemented)});return O==="addListener"&&(F.remove=async()=>_()),F};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:$},_)},F=new Promise($=>M.then(()=>$({remove:R})));return F.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await R()},F},P=new Proxy({},{get(O,_){switch(_){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return A?E:T;case"removeListener":return D;default:return S(_)}}});return s[m]=P,f.set(m,{name:m,proxy:P,platforms:new Set([...Object.keys(b),...A?[w]:[]])}),P};return n.convertFileSrc||(n.convertFileSrc=m=>m),n.getPlatform=a,n.handleError=d,n.isNativePlatform=r,n.isPluginAvailable=i,n.registerPlugin=h,n.Exception=Mg,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:{}),ed=yp.registerPlugin;class Ix{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,ql.Unimplemented)}unavailable(e="not available"){return new yp.Exception(e,ql.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 Ix{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)}}}ed("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 Ix{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 jq=ed("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 Ix{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")}}ed("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 Px=ed("LocalNotifications",{web:()=>wt(()=>import("./web-1BwWjkKM.js"),__vite__mapDeps([5,3,1,4])).then(t=>new t.LocalNotificationsWeb)}),xR=ed("ServerConfig");let yR=100;const vR="agent_alerts",Qb="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 td(){try{return yp.isNativePlatform()}catch{return!1}}async function kR(){if(td())try{const t=await Px.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(td())try{const r=yR++;console.log("[Notifications] Scheduling native notification id="+r,e),await Px.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(Qb,{detail:a}))}}}let Dg=!1;async function CR(t){const e=[];if(Dg)return()=>{};if(Dg=!0,t){const n=s=>{const a=s;a.detail&&t(a.detail)};window.addEventListener(Qb,n),e.push(()=>window.removeEventListener(Qb,n))}if(td())try{const n=await Px.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()),Dg=!1}}function AR(t,e){td()&&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,au=t=>{window.__tideWsState.isConnecting=t},Xb=()=>window.__tideWsState.reconnectAttempts,Jb=t=>{window.__tideWsState.reconnectAttempts=t},Tj=()=>window.__tideWsState.reconnectTimeout,_j=t=>{window.__tideWsState.reconnectTimeout=t},Gk=10,Bx="tide_ws_has_connected";function Kk(){return sessionStorage.getItem(Bx)==="true"}function NR(t){sessionStorage.setItem(Bx,"true")}function TR(){sessionStorage.removeItem(Bx)}let Ej=null;const _R=t=>{Ej=t},Qk=()=>Ej,Oe={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&&(Oe.onToast=t.onToast),t.onAgentCreated&&(Oe.onAgentCreated=t.onAgentCreated),t.onAgentUpdated&&(Oe.onAgentUpdated=t.onAgentUpdated),t.onAgentDeleted&&(Oe.onAgentDeleted=t.onAgentDeleted),t.onAgentsSync&&(Oe.onAgentsSync=t.onAgentsSync),t.onAreasSync&&(Oe.onAreasSync=t.onAreasSync),t.onSpawnError&&(Oe.onSpawnError=t.onSpawnError),t.onSpawnSuccess&&(Oe.onSpawnSuccess=t.onSpawnSuccess),t.onToolUse&&(Oe.onToolUse=t.onToolUse),t.onDirectoryNotFound&&(Oe.onDirectoryNotFound=t.onDirectoryNotFound),t.onDelegation&&(Oe.onDelegation=t.onDelegation),t.onCustomClassesSync&&(Oe.onCustomClassesSync=t.onCustomClassesSync),t.onReconnect&&(Oe.onReconnect=t.onReconnect),t.onAgentNotification&&(Oe.onAgentNotification=t.onAgentNotification),t.onBuildingUpdated&&(Oe.onBuildingUpdated=t.onBuildingUpdated),t.onSubagentStarted&&(Oe.onSubagentStarted=t.onSubagentStarted),t.onSubagentCompleted&&(Oe.onSubagentCompleted=t.onSubagentCompleted)}function ER(){Oe.onToast=null,Oe.onAgentCreated=null,Oe.onAgentUpdated=null,Oe.onAgentDeleted=null,Oe.onAgentsSync=null,Oe.onAreasSync=null,Oe.onSpawnError=null,Oe.onSpawnSuccess=null,Oe.onToolUse=null,Oe.onDirectoryNotFound=null,Oe.onDelegation=null,Oe.onCustomClassesSync=null,Oe.onReconnect=null,Oe.onAgentNotification=null,Oe.onSubagentStarted=null,Oe.onSubagentCompleted=null}function MR(){Oe.onAgentCreated=null,Oe.onAgentUpdated=null,Oe.onAgentDeleted=null,Oe.onAgentsSync=null,Oe.onAreasSync=null,Oe.onToolUse=null,Oe.onDelegation=null,Oe.onCustomClassesSync=null,Oe.onBuildingUpdated=null,Oe.onSubagentStarted=null,Oe.onSubagentCompleted=null}const jf=new Map,DR=new Map,Zb={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 ru=new OR;function wu(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 ex=mt.PENDING_MESSAGES,LR=300*1e3;function Rj(){try{const t=localStorage.getItem(ex);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(ex):localStorage.setItem(ex,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=Oe.onToast)==null||s.call(Oe,"success","Messages Sent",`${e} ${a} delivered after reconnecting.`)}return e}function Fx(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=Fx(t);return console.log("[AgentDebugger] SENT - type:",t.type,"agentId:",s,"payload:",t.payload),s&&ks.captureSent(s,n),e.send(n),!0}catch{return!1}}function zx(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=Oe.onToast)==null||s.call(Oe,"warning","Message Queued","Connection lost. Your message will be sent when reconnected.")):(a=Oe.onToast)==null||a.call(Oe,"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=Oe.onToast)==null||r.call(Oe,"warning","Message Queued","Still connecting. Your message will be sent automatically.")):(i=Oe.onToast)==null||i.call(Oe,"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=Oe.onToast)==null||d.call(Oe,"warning","Message Queued","Connection lost. Your message will be sent when reconnected.")):(f=Oe.onToast)==null||f.call(Oe,"warning","Reconnecting...","Connection lost. Reconnecting to server...")),!1;try{const b=JSON.stringify(t),y=Fx(t);return console.log("[AgentDebugger] SENT - type:",t.type,"agentId:",y,"payload:",t.payload),y&&ks.captureSent(y,b),e.send(b),!0}catch(b){return t.type==="send_command"?(Tf(t),(h=Oe.onToast)==null||h.call(Oe,"warning","Message Queued","Send failed. Your message will be retried when reconnected.")):(m=Oe.onToast)==null||m.call(Oe,"error","Send Failed",`Failed to send message: ${b}`),!1}}const ku=new Set,BR=5e3;function Xk(t){if(!t.isDetached||!t.sessionId){ku.delete(t.id);return}ku.has(t.id)||(ku.add(t.id),zx({type:"reattach_agent",payload:{agentId:t.id}}),setTimeout(()=>{ku.delete(t.id)},BR))}function FR(t){var e,n,s,a,r,i,c,d,f,h,m,b,y,w,A,N,k,j,S,T,D,E,P,O;switch(Zb.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=Oe.onAgentsSync)==null||e.call(Oe,_),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=Oe.onAgentCreated)==null||s.call(Oe,_),(a=Oe.onSpawnSuccess)==null||a.call(Oe),window.__spawnModalSuccess&&(console.log("[WebSocket] Calling __spawnModalSuccess"),window.__spawnModalSuccess()),(r=Oe.onToast)==null||r.call(Oe,"success","Agent Deployed",`${_.name} is ready for commands`);break}case"agent_updated":{const _=t.payload,R=U.getState().agents.get(_.id),F=(R==null?void 0:R.status)!==_.status;console.log(`[Tide] Agent updated: ${_.name} (${_.id}) status=${_.status} (was ${R==null?void 0:R.status})${F?" ⚡ STATUS CHANGED":""}`),F&&console.log(`[Tide] 🔔 Status change for ${_.name}: ${R==null?void 0:R.status} → ${_.status}`),F&&(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=Oe.onAgentUpdated)==null||i.call(Oe,_,$);break}case"agent_deleted":{const{id:_}=t.payload;ku.delete(_),U.removeAgent(_),(c=Oe.onAgentDeleted)==null||c.call(Oe,_);break}case"activity":{const _=t.payload;U.addActivity(_);break}case"event":{const _=t.payload;if(Wu.debug(`Event: ${_.type}`,{agentId:_.agentId,toolName:_.toolName},"ws:event"),_.type==="tool_start"&&_.toolName&&((d=Oe.onToolUse)==null||d.call(Oe,_.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;Wu.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"compacting_status":{const{agentId:_,active:M}=t.payload;U.setAgentCompacting(_,M);break}case"error":{const _=t.payload;console.error("[WebSocket] Error from server:",_.message),(f=Oe.onToast)==null||f.call(Oe,"error","Error",_.message),(h=Oe.onSpawnError)==null||h.call(Oe),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=Oe.onDirectoryNotFound)==null||m.call(Oe,_),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=Oe.onAreasSync)==null||b.call(Oe);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=Oe.onBuildingUpdated)==null||y.call(Oe,_);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:F,isError:$}=t.payload;U.appendBossStreamingLogChunk(_,M,R,F,$);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=Oe.onToast)==null||w.call(Oe,"info","Task Delegated",`Delegated to ${_.selectedAgentName}: ${_.reasoning.slice(0,80)}...`),_.bossId&&_.selectedAgentId&&((A=Oe.onDelegation)==null||A.call(Oe,_.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=Oe.onAgentCreated)==null||N.call(Oe,_),zx({type:"move_agent",payload:{agentId:_.id,position:M}}),(k=Oe.onToast)==null||k.call(Oe,"success","Agent Deployed",`${_.name} spawned by boss, walking to position`);break}case"agent_task_started":{const{bossId:_,subordinateId:M,subordinateName:R,taskDescription:F}=t.payload;console.log(`[WebSocket] Agent ${R} started task for boss ${_}: ${F.slice(0,50)}...`),U.handleAgentTaskStarted(_,M,R,F);break}case"agent_task_output":{const{bossId:_,subordinateId:M,output:R,isStreaming:F,timestamp:$,subagentName:H,toolName:L,toolInput:z,toolOutput:W}=t.payload;U.handleAgentTaskOutput(_,M,{text:R,isStreaming:F||!1,timestamp:$||Date.now(),subagentName:H,toolName:L,toolInput:z,toolOutput:W});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=Oe.onCustomClassesSync)==null||j.call(Oe,M);break}case"custom_agent_class_created":{const _=t.payload;U.addCustomAgentClassFromServer(_),console.log(`[WebSocket] Custom agent class created: ${_.name}`),(S=Oe.onCustomClassesSync)==null||S.call(Oe,U.getState().customAgentClasses);break}case"custom_agent_class_updated":{const _=t.payload;U.updateCustomAgentClassFromServer(_),console.log(`[WebSocket] Custom agent class updated: ${_.name}`),(T=Oe.onCustomClassesSync)==null||T.call(Oe,U.getState().customAgentClasses);break}case"custom_agent_class_deleted":{const{id:_}=t.payload;U.removeCustomAgentClassFromServer(_),console.log(`[WebSocket] Custom agent class deleted: ${_}`),(D=Oe.onCustomClassesSync)==null||D.call(Oe,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=Oe.onAgentNotification)==null||E.call(Oe,_);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 F=[0,80,220,500,1e3];for(const $ of F)window.setTimeout(()=>{window.focus()},$);break}case"exec_task_started":{const{taskId:_,agentId:M,agentName:R,command:F,cwd:$}=t.payload;console.log(`[WebSocket] Exec task started: ${_} for agent ${R}: ${F.slice(0,50)}...`),U.handleExecTaskStarted(_,M,R,F,$);break}case"exec_task_output":{const{taskId:_,agentId:M,output:R,isError:F}=t.payload;U.handleExecTaskOutput(_,M,R,F);break}case"exec_task_completed":{const{taskId:_,agentId:M,exitCode:R,success:F}=t.payload;console.log(`[WebSocket] Exec task completed: ${_} for agent ${M}, success: ${F}`),U.handleExecTaskCompleted(_,M,R,F);break}case"subagent_started":{const _=t.payload;console.log(`[WebSocket] Subagent started: ${_.name} (${_.id}) for agent ${_.parentAgentId}`),U.addSubagent(_),(P=Oe.onSubagentStarted)==null||P.call(Oe,_);break}case"subagent_output":{const{subagentId:_,parentAgentId:M,text:R,timestamp:F}=t.payload,$=R.indexOf(":");if($>0){const H=R.slice(0,$).trim(),L=R.slice($+1).trim();U.addSubagentActivity(_,M,{toolName:H,description:L,timestamp:F})}else R.startsWith("Using ")&&U.addSubagentActivity(_,M,{toolName:R.slice(6).trim(),description:"",timestamp:F});break}case"subagent_completed":{const{subagentId:_,parentAgentId:M,success:R,resultPreview:F,subagentName:$,durationMs:H,tokensUsed:L,toolUseCount:z}=t.payload;console.log(`[WebSocket] Subagent completed: ${_} for agent ${M}, success: ${R}`),(H||L||z)&&U.updateSubagentStats(_,M,{durationMs:H||0,tokensUsed:L||0,toolUseCount:z||0}),U.completeSubagent(_,M,R),(O=Oe.onSubagentCompleted)==null||O.call(Oe,_);const W=U.getSubagent(_)||U.getSubagentByToolUseId(_),V=$||(W==null?void 0:W.name)||_,G=R?"✅":"❌",B=H?` (${(H/1e3).toFixed(0)}s · ${((L||0)/1e3).toFixed(1)}K tokens · ${z||0} tools)`:"";U.addOutput(M,{text:`${G} Subagent ${V} ${R?"completed":"failed"}${B}`,isStreaming:!1,timestamp:Date.now(),subagentName:V,toolOutput:F});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:F,serverVersion:$}=t.payload;U.setConnectionStatus(_,M,{connected:R,error:F,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:F}=t.payload;U.setTables(_,M,R,F),console.log(`[WebSocket] Received ${F.length} tables for ${R}`);break}case"table_schema":{const{buildingId:_,connectionId:M,database:R,table:F,columns:$,indexes:H,foreignKeys:L}=t.payload;U.setTableSchema(_,M,R,F,{columns:$,indexes:H||[],foreignKeys:L||[]}),console.log(`[WebSocket] Received schema for ${F}`);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:F,affectedRows:$,error:H}=t.payload;U.setSilentQueryResult(_,{query:M,requestId:R,success:F,affectedRows:$,error:H}),console.log(`[WebSocket] Silent query ${F?"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}}Zb.end(`ws:${t.type}`)}_R(()=>qu());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(),Jb(0),setTimeout(()=>qu(),100)}function qu(){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()&&Oe.onReconnect&&Oe.onReconnect();return}Jb(Xb()+1),au(!0);const n=Lx(),s=Fi(),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{au(!1),Zk();return}Yk(i),i.onopen=()=>{var d,f,h;const c=Kk();au(!1),Jb(0),NR(),U.setConnected(!0),U.startStatusPolling(),U.clearAllPermissions(),c?((d=Oe.onToast)==null||d.call(Oe,"success","Reconnected","Connection restored - refreshing data..."),(f=Oe.onReconnect)==null||f.call(Oe)):(h=Oe.onToast)==null||h.call(Oe,"success","Connected","Connected to Tide Commander server"),AR(n,s),IR()},i.onmessage=c=>{try{const d=JSON.parse(c.data),f=Fx(d);console.log("[AgentDebugger] RECEIVED - type:",d.type,"agentId:",f,"payload:",d.payload),f&&ks.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;au(!1),Yk(null),U.setConnected(!1),U.stopStatusPolling();const c=Xb();c<Gk?((d=Oe.onToast)==null||d.call(Oe,"warning","Disconnected",`Connection lost. Reconnecting... (attempt ${c+1}/${Gk})`),Zk()):(f=Oe.onToast)==null||f.call(Oe,"error","Connection Failed",`Could not connect to server. Please check if the backend is running on port ${a}.`)},i.onerror=()=>{au(!1)},U.setSendMessage(zx)}function Zk(){const t=Xb(),e=Math.min(1e3*Math.pow(2,t-1),3e4);_j(setTimeout(qu,e))}function UR(t,e){const n={position:t,target:e};Pa(mt.CAMERA_STATE,n)}function HR(){return Ta(mt.CAMERA_STATE,null)}function Nq(t,e,n){const s={posX:t,posZ:e,zoom:n};Pa(mt.CAMERA_STATE_2D,s)}function Tq(){return Ta(mt.CAMERA_STATE_2D,null)}function tc(){return{Authorization:`Bearer ${Fi()}`,"Content-Type":"application/json"}}async function WR(){const t=await fetch(`${Ma()}/api/workspaces`,{headers:tc()});if(!t.ok)throw new Error(`Failed to fetch workspaces: ${t.statusText}`);return t.json()}async function qR(t,e){const n=await fetch(`${Ma()}/api/workspaces`,{method:"POST",headers:tc(),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(`${Ma()}/api/workspaces/${t}`,{method:"PUT",headers:tc(),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(`${Ma()}/api/workspaces/${t}`,{method:"DELETE",headers:tc()});if(!e.ok)throw new Error(`Failed to delete workspace: ${e.statusText}`)}async function YR(){const t=await fetch(`${Ma()}/api/workspaces/active`,{headers:tc()});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(`${Ma()}/api/workspaces/active`,{method:"PUT",headers:tc(),body:JSON.stringify({workspaceId:t})});if(!e.ok)throw new Error(`Failed to set active workspace: ${e.statusText}`)}const Vu=new Set;let sr=null,wo=[],Pj=!1;const tx=new Set;function Rg(t){Pj=t,tx.forEach(e=>e(t))}const Bj="tide-commander-active-workspace";function nS(){return typeof window>"u"?null:localStorage.getItem(Bj)||null}function Og(t){typeof window>"u"||localStorage.setItem(Bj,t||"")}function iu(){Vu.forEach(t=>t())}function GR(){return sr}function $x(t){return sr?t?sr.areaIds.includes(t):!1:!0}function _q(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 Vu.add(e),()=>{Vu.delete(e)}},[]),[sr,wo]}function KR(t){return Vu.add(t),()=>{Vu.delete(t)}}function QR(){const[t,e]=x.useState(Pj);return x.useEffect(()=>{const n=s=>e(s);return tx.add(n),()=>{tx.delete(n)}},[]),t}const Lg=new Map,XR=je.memo(function(){const{t:e}=pt("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),[A,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 z=nS(),[W,V]=await Promise.all([WR(),YR()]);if(L)return;const G=z&&W.some(B=>B.id===z)?z:V&&W.some(B=>B.id===V)?V:null;a(W),wo=W,i(G),Og(G),sr=W.find(B=>B.id===G)??null,iu()}catch(z){console.error("workspace error:",z)}finally{L||b(!1)}})(),()=>{L=!0}},[]),x.useEffect(()=>{if(!c&&!f)return;const L=z=>{D.current&&!D.current.contains(z.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]),P=x.useCallback(async L=>{Rg(!0);const z=Date.now();if(r){const B=HR();B&&(Lg.set(r,B),eS(r,{cameraState:B}).then(K=>{a(se=>{const q=se.map(me=>me.id===r?K:me);return wo=q,q})}).catch(K=>console.error("workspace error:",K)))}i(L),Og(L),d(!1);const W=L?s.find(B=>B.id===L)??null:null;if(sr=W,wo=s,iu(),L){const K=(W==null?void 0:W.cameraState)??Lg.get(L);K&&(UR(K.position,K.target),Lg.set(L,K))}tS(L).catch(B=>console.error("workspace error:",B));const V=Date.now()-z,G=400;V<G?setTimeout(()=>Rg(!1),G-V):Rg(!1)},[r,s]),O=x.useMemo(()=>Array.from(n.values()).filter(L=>!L.archived),[n]),_=x.useCallback(async()=>{if(A.trim())try{const L=await qR(A.trim(),k),z=[...s,L];a(z),wo=z,iu(),N(""),j([]),T(!1)}catch(L){console.error("workspace error:",L)}},[A,k,s]),M=x.useCallback(async()=>{if(!(!y||!A.trim()))try{const L=await eS(y,{name:A.trim(),areaIds:k}),z=s.map(W=>W.id===y?L:W);a(z),wo=z,y===r&&(sr=L),iu(),w(null),N(""),j([])}catch(L){console.error("workspace error:",L)}},[y,A,k,s,r]),R=x.useCallback(async L=>{try{await VR(L);const z=s.filter(W=>W.id!==L);a(z),wo=z,r===L&&(i(null),Og(null),sr=null,await tS(null).catch(W=>console.error("workspace error:",W))),iu()}catch(z){console.error("workspace error:",z)}},[s,r]),F=x.useCallback(L=>{w(L.id),N(L.name),j([...L.areaIds]),T(!1)},[]),$=x.useCallback(()=>{w(null),N(""),j([]),T(!0)},[]),H=x.useCallback(L=>{j(z=>z.includes(L)?z.filter(W=>W!==L):[...z,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:()=>P(null),children:e("agentBar.allWorkspaces",{defaultValue:"All"})}),s.map(L=>o.jsxs("button",{className:`workspace-switcher-option ${L.id===r?"active":""}`,onClick:()=>P(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:A,onChange:z=>N(z.target.value),className:"workspace-switcher-input",placeholder:"Workspace name",autoFocus:!0,onKeyDown:z=>{z.key==="Enter"&&M(),z.key==="Escape"&&w(null)}}),o.jsxs("div",{className:"workspace-switcher-area-list",children:[O.map(z=>o.jsxs("label",{className:"workspace-switcher-area-check",children:[o.jsx("input",{type:"checkbox",checked:k.includes(z.id),onChange:()=>H(z.id)}),o.jsx("span",{style:{color:z.color},children:z.name})]},z.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:()=>F(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:A,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:()=>H(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 Yu(t){typeof window<"u"&&(window.__tidePersistedScene=t)}function Du(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(),Yu(null)):console.log("[App] No persistedScene to dispose"),Du(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{}Yu(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=Ta(mt.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){Pa(mt.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)}Yu(null)}Du(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:A}){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"){A==null||A(!1);return}if(!t.current||!e.current)return;let D=!1;A==null||A(!0);const E=Gp(),O=zj()===t.current;function _(){var R,F,$,H,L,z,W,V;(R=N.current)==null||R.setOnToast(a),(F=N.current)==null||F.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)}),(H=N.current)==null||H.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)}),(z=N.current)==null||z.setOnGroundClick(()=>{f(null)}),(W=N.current)==null||W.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),Du(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),A==null||A(!1)}finally{S.current=requestAnimationFrame(()=>{T.current=requestAnimationFrame(()=>{A==null||A(!1),T.current=null}),S.current=null})}else{const R=t.current,F=e.current,$=async()=>{if(D){console.log("[Tide] Effect cleaned up before scene init, skipping"),A==null||A(!1);return}if(!R.isConnected||!F.isConnected){console.warn("[Tide] Canvas disconnected before initialization"),A==null||A(!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:H}=await wt(async()=>{const{SceneManager:W}=await import("./SceneManager-BgkqWsDb.js");return{SceneManager:W}},__vite__mapDeps([6,4,3,1]));if(D){A==null||A(!1);return}const L=new H(R,F);N.current=L,Yu(L),Du(R);const z=Uj();L.setCharacterScale(z.characterScale),L.setScale3D(z.scale3d),L.setTimeMode(z.timeMode),L.setTerrainConfig(z.terrain),L.setFloorStyle(z.terrain.floorStyle,!0),L.setGridVisible(z.gridVisible),L.setAgentModelStyle(z.modelStyle),L.setIdleAnimation(z.animations.idleAnimation),L.setWorkingAnimation(z.animations.workingAnimation),L.setFpsLimit(z.fpsLimit),L.syncAreas(),L.syncBuildings(),L.loadCharacterModels().then(()=>{console.log("[Tide] Character models ready");const W=U.getState();W.customAgentClasses.size>0&&(console.log("[Tide] Applying custom classes from store:",W.customAgentClasses.size),L.setCustomAgentClasses(W.customAgentClasses)),W.agents.size>0&&(console.log("[Tide] Syncing agents from store:",W.agents.size),L.syncAgents(Array.from(W.agents.values()))),L.upgradeAgentModels()}).catch(W=>{console.warn("[Tide] Some models failed to load, using fallback:",W)}).finally(()=>{A==null||A(!1)}),_()}catch(H){console.error("[Tide] Failed to initialize 3D scene:",H),A==null||A(!1)}};j.current=requestAnimationFrame(()=>void $())}Mj({onAgentCreated:R=>{var F,$,H;(F=N.current)==null||F.addAgent(R),($=N.current)==null||$.refreshSelectionVisuals(),(H=window.__spawnModalSuccess)==null||H.call(window)},onAgentUpdated:(R,F)=>{var H;const $=U.getState().agents.get(R.id)||R;(H=N.current)==null||H.updateAgent($,F)},onAgentDeleted:R=>{var F;(F=N.current)==null||F.removeAgent(R)},onAgentsSync:R=>{var $;const F=Array.from(U.getState().agents.values());($=N.current)==null||$.syncAgents(F)},onAreasSync:()=>{var F,$;(F=N.current)==null||F.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 F;(F=window.__spawnModalDirNotFound)==null||F.call(window,R)},onToolUse:(R,F,$)=>{var H;(H=N.current)==null||H.showToolBubble(R,F,$)},onDelegation:(R,F)=>{var $;($=N.current)==null||$.showDelegationEffect(R,F)},onCustomClassesSync:R=>{var F,$;(F=N.current)==null||F.setCustomAgentClasses(R),($=N.current)==null||$.upgradeAgentModels()},onBuildingUpdated:R=>{var F;(F=N.current)==null||F.updateBuilding(R)},onSubagentStarted:R=>{var F;(F=N.current)==null||F.addSubagentEffect(R.id,R.parentAgentId,R.name,R.subagentType)},onSubagentCompleted:R=>{var H;const F=U.getSubagent(R)||U.getSubagentByToolUseId(R),$=(F==null?void 0:F.id)||R;(H=N.current)==null||H.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,Yu(null),Du(null))}},[n,s]),N}function oO({showToast:t,showAgentNotification:e}){x.useEffect(()=>{Mj({onToast:t,onReconnect:()=>{U.triggerReconnect()},onAgentNotification:a=>{e(a)}}),JR()||(qu(),$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(()=>qu(),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 It(t,e,n,s,a={},r="global"){return{id:t,name:e,description:n,key:s,modifiers:a,enabled:!0,context:r}}const Ig=[It("toggle-commander","Toggle Commander","Open/close Commander View","k",{ctrl:!0}),It("toggle-commander-tab","Toggle Commander (Tab)","Open/close Commander View with Tab","Tab",{}),It("spawn-agent","Spawn Agent","Open new agent spawn modal","n",{alt:!0}),It("select-agent-1","Select Agent 1","Select first agent","1",{ctrl:!0}),It("select-agent-2","Select Agent 2","Select second agent","2",{ctrl:!0}),It("select-agent-3","Select Agent 3","Select third agent","3",{ctrl:!0}),It("select-agent-4","Select Agent 4","Select fourth agent","4",{ctrl:!0}),It("select-agent-5","Select Agent 5","Select fifth agent","5",{ctrl:!0}),It("select-agent-6","Select Agent 6","Select sixth agent","6",{ctrl:!0}),It("select-agent-7","Select Agent 7","Select seventh agent","7",{ctrl:!0}),It("select-agent-8","Select Agent 8","Select eighth agent","8",{ctrl:!0}),It("select-agent-9","Select Agent 9","Select ninth agent","9",{ctrl:!0}),It("delete-selected","Delete Selected","Remove selected agents","Delete",{}),It("delete-selected-backspace","Delete Selected (Backspace)","Remove selected agents","Backspace",{}),It("deselect-all","Deselect All","Clear agent selection","Escape",{}),It("open-terminal","Open Terminal","Open terminal for selected agent","Space",{}),It("dashboard-selector-toggle","Dashboard Selector","Enable dashboard card selector",",",{}),It("dashboard-vim-left","Dashboard Left","Move dashboard selector left","h",{}),It("dashboard-vim-down","Dashboard Down","Move dashboard selector down","j",{}),It("dashboard-vim-up","Dashboard Up","Move dashboard selector up","k",{}),It("dashboard-vim-right","Dashboard Right","Move dashboard selector right","l",{}),It("next-agent","Next Agent","Select next agent on battlefield","l",{alt:!0}),It("prev-agent","Previous Agent","Select previous agent on battlefield","h",{alt:!0}),It("next-working-agent","Next Working Agent","Select next working agent on battlefield","l",{alt:!0,shift:!0}),It("prev-working-agent","Previous Working Agent","Select previous working agent on battlefield","h",{alt:!0,shift:!0}),It("next-message","Next Message","Navigate to next message in terminal","j",{alt:!0}),It("prev-message","Previous Message","Navigate to previous message in terminal","k",{alt:!0}),It("page-down-messages","Page Down Messages","Jump down 10 messages in terminal","d",{alt:!0,shift:!0}),It("page-up-messages","Page Up Messages","Jump up 10 messages in terminal","u",{alt:!0}),It("next-agent-terminal","Next Agent (Terminal)","Switch to next agent in terminal","l",{alt:!0}),It("prev-agent-terminal","Previous Agent (Terminal)","Switch to previous agent in terminal","h",{alt:!0}),It("activate-message","Activate Message","Click on interactive element in selected message","Space",{}),It("toggle-file-explorer","Toggle File Explorer","Open/close file explorer","e",{alt:!0}),It("file-explorer-close-tab","Close File Tab","Close active file tab in explorer","w",{alt:!0}),It("toggle-spotlight","Toggle Spotlight","Open/close global search","p",{alt:!0}),It("open-database","Open Database","Open last used database query builder","d",{alt:!0}),It("toggle-2d-view","Cycle View Mode","Cycle between 3D, 2D, and Dashboard views","2",{alt:!0}),It("clear-context","Clear Context","Clear context of the selected agent","c",{alt:!0,shift:!0}),It("commander-close","Close Commander","Close Commander View","Escape",{},"commander"),It("commander-vim-left","Navigate Left","Move focus left (Vim H)","h",{alt:!0},"commander"),It("commander-vim-down","Navigate Down","Move focus down (Vim J)","j",{alt:!0},"commander"),It("commander-vim-up","Navigate Up","Move focus up (Vim K)","k",{alt:!0},"commander"),It("commander-vim-right","Navigate Right","Move focus right (Vim L)","l",{alt:!0},"commander"),It("commander-expand","Expand/Collapse","Toggle agent expansion","o",{alt:!0},"commander"),It("commander-new-agent","New Agent","Open spawn form in commander","n",{alt:!0},"commander"),It("commander-next-tab","Next Tab","Switch to next area tab","Tab",{},"commander"),It("commander-prev-tab","Previous Tab","Switch to previous area tab","Tab",{shift:!0},"commander"),It("toolbox-close","Close Toolbox","Close Settings panel","Escape",{},"toolbox")];function Nn(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 Eq(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 Mq(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,F,$,H;const b=U.getShortcuts(),y=m.target,w=y.tagName==="INPUT"||y.tagName==="TEXTAREA"||y.getAttribute("contenteditable")==="true"||!!y.closest(".cm-editor"),A=b.find(L=>L.id==="deselect-all");if(Nn(m,A)){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(),(F=t.current)==null||F.refreshSelectionVisuals())}for(let L=1;L<=9;L++){const z=b.find(W=>W.id===`select-agent-${L}`);if(Nn(m,z)){m.preventDefault();const W=U.getState(),V=L-1,G=Array.from(W.agents.keys());V<G.length&&(U.selectAgent(G[V]),($=t.current)==null||$.refreshSelectionVisuals());return}}const N=b.find(L=>L.id==="spawn-agent");if(Nn(m,N)){m.preventDefault(),e.open();return}const k=b.find(L=>L.id==="toggle-commander-tab");if(Nn(m,k)&&!w){m.preventDefault(),n.toggle();return}const j=b.find(L=>L.id==="toggle-commander");if(Nn(m,j)){m.preventDefault(),n.toggle();return}const S=b.find(L=>L.id==="toggle-file-explorer");if(Nn(m,S)){m.preventDefault();const L=U.getState();if(s.isOpen||L.explorerFolderPath!==null||L.explorerAreaId!==null)s.close(),U.closeFileExplorer();else{const W=U.getLastExplorerState();if((W==null?void 0:W.type)==="folder")U.openFileExplorer(W.path);else if((W==null?void 0:W.type)==="area")if(L.areas.has(W.areaId))s.open(W.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"),z=U.getState();if(L){const W=z.buildings.get(L);if((W==null?void 0:W.type)==="database"){c(L);return}}for(const[W,V]of z.buildings)if(V.type==="database"){c(W);return}return}const T=b.find(L=>L.id==="toggle-spotlight");if(Nn(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(Nn(m,D)){m.preventDefault();const L=U.getState().viewMode,z=L==="3d"?"2d":L==="2d"?"dashboard":"3d";U.setViewMode(z);return}const E=b.find(L=>L.id==="clear-context");if(Nn(m,E)){m.preventDefault();const L=U.getState(),z=L.selectedAgentIds.size===1?Array.from(L.selectedAgentIds)[0]:null;z&&U.clearContext(z);return}const P=b.find(L=>L.id==="next-working-agent"),O=b.find(L=>L.id==="prev-working-agent");if((Nn(m,P)||Nn(m,O))&&!w){const L=U.getState();if(L.terminalOpen)return;const z=Array.from(L.agents.values());let W=z.filter(K=>L.agentsWithUnseenOutput.has(K.id));if(W.length===0&&(W=z.filter(K=>K.status==="working")),W.length===0)return;m.preventDefault();const V=L.selectedAgentIds.size===1?Array.from(L.selectedAgentIds)[0]:null,G=V?W.findIndex(K=>K.id===V):-1;let B;Nn(m,P)?B=G===-1?0:(G+1)%W.length:B=G===-1?W.length-1:(G-1+W.length)%W.length,U.selectAgent(W[B].id),(H=t.current)==null||H.refreshSelectionVisuals();return}const _=b.find(L=>L.id==="delete-selected"),M=b.find(L=>L.id==="delete-selected-backspace");if((Nn(m,_)||Nn(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 Pg="agent-order-change";function mO(t){const e=x.useMemo(()=>new Set(t.map(d=>d.id)),[t]),[n,s]=x.useState(()=>Ta(mt.AGENT_ORDER,[]));x.useEffect(()=>{const d=f=>{s(f.detail)};return window.addEventListener(Pg,d),()=>{window.removeEventListener(Pg,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),Pa(mt.AGENT_ORDER,d),window.dispatchEvent(new CustomEvent(Pg,{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([]),Pa(mt.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 _a(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 Pt(Ot(`/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 Pt(Ot(`/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 A=w.directoryGitCounts?[...w.directoryGitCounts]:new Array(w.directories.length).fill(0);let N=!1;for(const{dirIndex:k,count:j}of y)A[k]!==j&&(A[k]=j,N=!0);N&&U.updateAreaLocal(b,{directoryGitCounts:A})}}catch{}};return e(),t.current=setInterval(e,gO),()=>{t.current&&(clearInterval(t.current),t.current=null)}},[])}const Bg={historyLimit:500,hideCost:!0,showFPS:!1,powerSaving:!1,customAgentNames:[],experimental2DView:!1,experimentalVoiceAssistant:!1,experimentalTTS:!1,experimentalEchoPrompt:!1,externalEditorCommand:"",vibrationIntensity:1,tabTitle:"",tmuxMode:!1},iS=90,Fg=["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 nx(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=nx(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,A]=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),P=x.useRef(!1),O=x.useRef(!1),_=x.useRef(null),M=x.useRef(!1),R=x.useRef(null),F=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(ce=>ce+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 ce=U.getOutputs(t);ce.length>0&&(q=ce.map(ee=>({...ee})))}F.current&&(clearTimeout(F.current),F.current=null),B&&la.delete(t),D.current+=1;const me=D.current;if(m(!0),!B){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&&!B&&(F.current=setTimeout(()=>{f(!0)},150)),Pt(Ot(`/api/agents/${t}/history?limit=${iS}&offset=0`)).then(ce=>{if(!ce.ok)throw new Error(`HTTP ${ce.status}: ${ce.statusText}`);return ce.json()}).then(ce=>{if(me!==D.current)return;const ee=Array.isArray(ce.messages)?ce.messages:[],pe=Array.isArray(ce.subagents)?ce.subagents:[];c(ee),E.current=ee.length;const Ne=ce.hasMore||!1;if(k(Ne),O.current=Ne,S(ce.totalCount||0),pe.length>0&&U.hydrateSubagentsFromHistory(t,pe),la.set(t,{messages:ee,hasMore:Ne,totalCount:ce.totalCount||0}),kO(),q&&q.length>0){const ye=ee.length>0?Math.max(...ee.map(X=>X.timestamp?new Date(X.timestamp).getTime():0)):0,Me=new Set(ee.map(X=>X.uuid).filter(X=>typeof X=="string"&&X.length>0)),qe=new Map;for(const X of ee){if(X.type!=="user"&&X.type!=="assistant")continue;const ne=nx(X.type,X.content),Te=X.timestamp?new Date(X.timestamp).getTime():0,We=qe.get(ne)??0;Te>We&&qe.set(ne,Te)}const He=q.filter(X=>uS(X,Me,qe,ye));U.clearOutputs(t);for(const X of He)U.addOutput(t,X)}else if(ee.length>0){const ye=Math.max(...ee.map(ne=>ne.timestamp?new Date(ne.timestamp).getTime():0)),Me=new Set(ee.map(ne=>ne.uuid).filter(ne=>typeof ne=="string"&&ne.length>0)),qe=new Map;for(const ne of ee){if(ne.type!=="user"&&ne.type!=="assistant")continue;const Te=nx(ne.type,ne.content),We=ne.timestamp?new Date(ne.timestamp).getTime():0,nt=qe.get(Te)??0;We>nt&&qe.set(Te,We)}const He=U.getOutputs(t),X=He.filter(ne=>{const Te=uS(ne,Me,qe,ye);return Te||console.warn(`[HISTORY-DEDUP] Removing live output: uuid=${ne.uuid||"none"} ts=${ne.timestamp} lastHistTs=${ye} text="${ne.text.slice(0,80)}"`),Te});if(He.length!==X.length){console.warn(`[HISTORY-DEDUP] Cleared ${He.length-X.length}/${He.length} overlapping outputs for agent ${t}`),U.clearOutputs(t);for(const ne of X)U.addOutput(t,ne)}}if(!a.get(t)){for(let ye=ee.length-1;ye>=0;ye--)if(ee[ye].type==="user"){U.setLastPrompt(t,ee[ye].content);break}}}).catch(ce=>{if(console.error("Failed to load history:",ce),c([]),E.current=0,k(!1),O.current=!1,S(0),K&&q&&q.length>0){U.clearOutputs(t);for(const ee of q)U.addOutput(t,ee)}}).finally(()=>{T.current&&me===D.current&&(F.current&&(clearTimeout(F.current),F.current=null),f(!1),m(!1),y(ce=>ce+1))})},[t,e,n,s]);const $=x.useCallback(async()=>{if(!t||P.current||!O.current)return;const V=r.current;if(!V){console.warn("loadMoreHistory: outputScrollRef not connected");return}const G=V.scrollHeight-V.scrollTop;P.current=!0,A(!0);const B=E.current;try{const se=await(await Pt(Ot(`/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 ee=[...se.messages,...ce];return E.current=ee.length,ee});const me=se.hasMore||!1;O.current=me,k(me),requestAnimationFrame(()=>{requestAnimationFrame(()=>{T.current&&(r.current&&(r.current.scrollTop=r.current.scrollHeight-G),P.current=!1,A(!1))})})}else{if(!T.current)return;P.current=!1,A(!1)}}catch(K){if(console.error("Failed to load more history:",K),!T.current)return;P.current=!1,A(!1)}},[t,r]),H=x.useCallback(V=>{if(!r.current||V.current)return;const{scrollTop:G}=r.current;!P.current&&O.current&&G<xO&&$()},[$,r]),L=x.useCallback(()=>{c([]),E.current=0,t&&la.delete(t)},[t]),z=x.useRef(!1),W=x.useCallback(async()=>{var V,G;if(!(!t||!O.current)&&!(P.current||z.current)){z.current=!0,P.current=!0,A(!0);try{const K=await(await Pt(Ot(`/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&&(P.current=!1,z.current=!1,A(!1))}}},[t]);return{history:i,loadingHistory:d,fetchingHistory:h,historyLoadVersion:b,loadingMore:w,hasMore:N,totalCount:j,isMountedRef:T,loadMoreHistory:$,loadAllHistory:W,allLoaded:!N,handleScroll:H,clearHistory:L,hasCachedHistory:x.useCallback(V=>la.has(V),[])}}function ou(...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)&&ou("[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&&ou(`[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),ou(`[Store] Agent ${r.name} completed work - marked as unseen`),f=!0))}),f&&a&&a(),n(),d&&ou(`[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,A,N,k,j,S){ou("[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:A,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:A,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 Pt(Ot("/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]);Wu.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",zg=5e3,_O=[1e3,2500,5e3,1e4,null];function Yj(){if(typeof window>"u")return zg;try{const t=window.localStorage.getItem(Vj);if(!t)return zg;if(t==="unlimited")return null;const e=Number(t);if(Number.isFinite(e)&&e>0)return Math.floor(e)}catch{}return zg}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 A=new Map(m.bossStreamingLogs);A.set(i,w),m.bossStreamingLogs=A}),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,A,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:A,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},A=new Map(m.databaseState);A.set(i,w),m.databaseState=A}}),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 A={...y,tableSchemas:w},N=new Map(b.databaseState);N.set(i,A),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},A=new Map(b.databaseState);A.set(i,w),b.databaseState=A}}),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 Pt(Ot("/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 Pt(Ot("/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 Pt(Ot(`/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 Pt(Ot(`/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 Pt(Ot(`/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,$g=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=$g.get(t);s&&clearTimeout(s),$g.set(t,setTimeout(()=>{$g.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 Ug={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 go(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 Hg=[go("left-click-select","Select/Click","Select agents, click on buildings/areas","left",{},"primary-action"),go("left-drag-selection","Selection Box","Drag to select multiple agents","left",{},"selection-box"),go("right-click-context","Context Menu / Move","Show context menu or move selected agents","right",{},"context-menu"),go("alt-right-drag-pan","Camera Pan","Pan camera with Alt+Right-drag","right",{alt:!0},"camera-pan",1),go("middle-drag-orbit","Camera Orbit","Orbit camera with middle-drag","middle",{},"camera-orbit",1),go("shift-middle-drag-pan","Camera Pan (Alt)","Alternative pan with Shift+Middle-drag","middle",{shift:!0},"camera-pan",1),go("wheel-zoom","Zoom","Zoom camera with scroll wheel","middle",{},"camera-zoom",1)],Dq={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 Rq(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 Oq(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 Lq(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 Ys(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 Ha(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 Ux(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 At(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 Ls(){const[,t]=x.useState({});return x.useEffect(()=>U.subscribe(()=>t({})),[]),U.getState()}function nd(){return At(x.useCallback(t=>t.agents,[]),Ha)}function Kj(){return At(x.useCallback(t=>t.agents.size,[]))}function Kp(){const t=nd(),e=x.useRef([]),n=Array.from(t.values());return Ys(e.current,n)||(e.current=n),e.current}function Qj(t){return At(x.useCallback(e=>t?e.agents.get(t):void 0,[t]))}function Hx(){return At(x.useCallback(t=>t.selectedAgentIds,[]),Ux)}function WO(){return At(x.useCallback(t=>t.lastSelectedAgentId,[]))}function Xj(t){const e=x.useRef([]),n=x.useRef(0),s=At(x.useCallback(a=>t&&a.agentOutputs.get(t)||e.current,[t]),Ys);return s.length!==n.current&&(Wu.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 qO(t){return At(x.useCallback(e=>t?e.compactingAgents.has(t):!1,[t]))}function Jj(t){return At(x.useCallback(e=>t?e.lastPrompts.get(t):void 0,[t]))}function Wx(){return At(x.useCallback(t=>t.lastPrompts,[]),Ha)}function Zj(){return At(x.useCallback(t=>t.isConnected,[]))}function ur(){return At(x.useCallback(t=>t.areas,[]),Ha)}function VO(){return At(x.useCallback(t=>t.activeTool,[]))}function YO(){return At(x.useCallback(t=>t.selectedAreaId,[]))}function qx(){return At(x.useCallback(t=>t.buildings,[]),Ha)}function GO(){return At(x.useCallback(t=>t.selectedBuildingIds,[]),Ux)}function KO(){return At(x.useCallback(t=>t.supervisor,[]))}function Iq(){return At(x.useCallback(t=>t.supervisor.lastReport,[]))}function QO(){return At(x.useCallback(t=>t.supervisor.generatingReport,[]))}function XO(){return At(x.useCallback(t=>t.permissionRequests,[]),Ha)}function Vr(){return At(x.useCallback(t=>t.settings,[]))}function eN(){return At(x.useCallback(t=>t.settings.hideCost,[]))}function Pq(){return At(x.useCallback(t=>t.settings.customAgentNames,[]),Ys)}function Bq(){return At(x.useCallback(t=>t.shortcuts,[]),Ys)}function Fq(){return At(x.useCallback(t=>t.mouseControls,[]))}function zq(){return At(x.useCallback(t=>t.mouseControls.trackpad,[]))}function tN(){return At(x.useCallback(t=>t.terminalOpen,[]))}function nN(){return At(x.useCallback(t=>t.mobileView,[]))}function Vx(){return At(x.useCallback(t=>t.fileViewerPath,[]))}function JO(){return At(x.useCallback(t=>t.fileViewerEditData,[]))}function ZO(){return At(x.useCallback(t=>t.fileViewerSearchRoot,[]))}function eL(){return At(x.useCallback(t=>t.explorerFolderPath,[]))}function Yx(){return At(x.useCallback(t=>t.contextModalAgentId,[]))}function $q(){return At(x.useCallback(t=>t.commanderExpandRequest,[]))}function Gx(){return At(x.useCallback(t=>t.toolExecutions,[]),Ys)}function sN(){return At(x.useCallback(t=>t.fileChanges,[]),Ys)}function aN(){return At(x.useCallback(t=>t.skills,[]),Ha)}function tL(){const t=aN(),e=x.useRef([]),n=Array.from(t.values());return Ys(e.current,n)||(e.current=n),e.current}function Uq(t){return At(x.useCallback(e=>t?e.skills.get(t):void 0,[t]))}function nL(t){const e=x.useRef([]),n=nd(),s=aN();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 sL(){return At(x.useCallback(t=>t.customAgentClasses,[]),Ha)}function dr(){const t=sL(),e=x.useRef([]),n=Array.from(t.values());return Ys(e.current,n)||(e.current=n),e.current}function rN(t){return At(x.useCallback(e=>t?e.customAgentClasses.get(t):void 0,[t]))}function iN(){return At(x.useCallback(t=>t.reconnectCount,[]))}function oN(){return At(x.useCallback(t=>t.historyRefreshTrigger,[]))}function Hq(){return At(x.useCallback(t=>t.supervisor.globalUsage,[]))}function Wq(){return At(x.useCallback(t=>t.supervisor.refreshingUsage,[]))}function aL(t){const e=x.useRef(new Map);return At(x.useCallback(n=>t&&n.agentTaskProgress.get(t)||e.current,[t]),Ha)}function rL(t){return At(x.useCallback(e=>!t||!e.execTasks?[]:Array.from(e.execTasks.values()).filter(n=>n.agentId===t),[t]),Ys)}function iL(){return At(x.useCallback(t=>t.secrets,[]),Ha)}function qq(){const t=iL(),e=x.useRef([]),n=Array.from(t.values());return Ys(e.current,n)||(e.current=n),e.current}const oL={connectionStatus:new Map,databases:new Map,tables:new Map,tableSchemas:new Map,queryResults:[],queryHistory:[],executingQuery:!1,activeConnectionId:null,activeDatabase:null,lastSilentQueryResult:null};function Kx(t){return At(x.useCallback(e=>(t?e.databaseState.get(t):void 0)??oL,[t]))}function lL(t){return At(x.useCallback(e=>{if(!t)return[];const n=e.databaseState.get(t);return(n==null?void 0:n.queryResults)??[]},[t]),Ys)}function Vq(t){return At(x.useCallback(e=>{if(!t)return[];const n=e.databaseState.get(t);return(n==null?void 0:n.queryHistory)??[]},[t]),Ys)}function cL(t){return At(x.useCallback(e=>{if(!t)return!1;const n=e.databaseState.get(t);return(n==null?void 0:n.executingQuery)??!1},[t]))}function Yq(){return At(t=>t.dockerContainersList,Ys)}function uL(){return At(t=>t.currentSnapshot)}function dL(){return At(t=>t.snapshotsLoading)}function fL(){return At(t=>t.snapshotsError)}function pL(){return At(t=>t.subagents,Ha)}function hL(t){return At(x.useCallback(e=>t?Array.from(e.subagents.values()).filter(n=>n.parentAgentId===t):[],[t]),Ys)}function mL(t){const e=x.useRef(new Map);return At(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]),Ha)}function lN(){return At(t=>t.viewMode)}function gL(){return At(x.useCallback(t=>t.overviewPanelOpen,[]))}function cN(){return At(x.useCallback(t=>t.agentsWithUnseenOutput,[]),Ux)}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,compactingAgents:new Set,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=$a(mt.SCENE_VIEW_MODE,"3d");return i==="2d"||i==="3d"||i==="dashboard"?i:"3d"})(),overviewPanelOpen:Ei(mt.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=Ta(mt.SETTINGS,null);if(e){const n={...Bg,...e},s=Number(n.vibrationIntensity);return n.vibrationIntensity=Number.isFinite(s)?Math.max(0,Math.min(Hu,Math.round(s))):Bg.vibrationIntensity,n}return{...Bg}}loadShortcuts(){const e=Ta(mt.SHORTCUTS,null);return e?Ig.map(s=>{const a=e.find(r=>r.id===s.id);return a?{...s,...a}:s}):[...Ig]}loadMouseControls(){var n;const e=Ta(mt.MOUSE_CONTROLS,null);return e?{bindings:Hg.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:{...Ug,...e.sensitivity},trackpad:{...Mf,...e.trackpad,sensitivity:{...Mf.sensitivity,...(n=e.trackpad)==null?void 0:n.sensitivity}}}:{bindings:[...Hg],sensitivity:{...Ug},trackpad:{...Mf}}}loadMobileView(){const e=$a(mt.MOBILE_VIEW,"");return e==="terminal"||e==="3d"?e:typeof window<"u"&&window.innerWidth<=768&&"ontouchstart"in window?"3d":"terminal"}loadUnseenAgents(){const e=Ta(mt.UNSEEN_AGENTS,[]);return new Set(e)}saveUnseenAgents(){const e=Array.from(this.state.agentsWithUnseenOutput);Pa(mt.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,Mi(mt.AOP_OPEN,e),this.notify()}setMobileView(e){if(this.state.mobileView=e,Wr(mt.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(mt.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(Hu,Math.round(s))):this.state.settings.vibrationIntensity}this.state.settings={...this.state.settings,...n},Pa(mt.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=[...Ig],this.saveShortcuts(),this.notify()}saveShortcuts(){Pa(mt.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:[...Hg],sensitivity:{...Ug},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(){Pa(mt.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)}setAgentCompacting(e,n){const s=new Set(this.state.compactingAgents);n?s.add(e):s.delete(e),this.state.compactingAgents=s,this.notify()}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 bL(){return typeof window<"u"?(window.__tideStore&&window.__tideStoreVersion===bS||(window.__tideStore=new gS,window.__tideStoreVersion=bS),window.__tideStore):new gS}const U=bL(),uN=x.createContext(null),xL={error:"❌",success:"✅",warning:"⚠️",info:"ℹ️"};let yL=0;function vL({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:++yL,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(uN.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:xL[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 dN(){const t=x.useContext(uN);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const Do={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=Do,Ru={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:"🚀"}},Wg={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:"🧠"}},sx="<<<BOSS_CONTEXT_START>>>",xS="<<<BOSS_CONTEXT_END>>>",wL={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"}},Gq={"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"}},Kq={"":{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)"}},Qq={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"}},Xq={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"}},kL={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}},fN=x.createContext(null);function pN(t){const e=Do[t];if(e)return e.icon;const s=U.getState().customAgentClasses.get(t);return s?s.icon:"🤖"}function SL(t){const e=Do[t];if(e)return e.color;const s=U.getState().customAgentClasses.get(t);return s?s.color:"#888888"}const CL=3,yS=80;function AL({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=pN(t.agentClass),m=SL(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]),A=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:A,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 jL({children:t}){const{t:e}=pt(["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>CL){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),!td()){const h=pN(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(fN.Provider,{value:{showAgentNotification:i},children:[t,o.jsx("div",{id:"agent-notification-container",children:n.map(d=>o.jsx(AL,{notification:d,onDismiss:r,onClick:c},d.id))})]})}function NL(){const t=x.useContext(fN);if(!t)throw new Error("useAgentNotification must be used within AgentNotificationProvider");return t}const TL={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"}},_L=["Alex","Sam","Jordan","Taylor","Casey","Morgan","Riley","Quinn","Avery","Blake","Cameron","Drew","Emery","Finley","Harper","Jamie","Kai","Logan","Max","Nico","Parker","Reese","Sage","Sky"],Jq=_L,EL={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"},Zq=[{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"}],eV=[{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"}],tV=3,nV=5,sV=1e3,aV=50,rV=1.2;function ML(t){return typeof t=="string"?t:"#"+t.toString(16).padStart(6,"0")}function fr(t,e){const n=TL[t];if(n)return{icon:n.icon,color:ML(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 DL=2e5,RL=258400;function lu(t){return Math.max(0,Math.min(100,t))}function vS(t){const e=t.provider==="codex"||t.provider==="opencode"?RL:DL,n=Math.max(1,Math.round(t.contextLimit||e)),s=Math.max(0,Math.min(Math.round(t.contextUsed||0),n)),a=lu(Number((s/n*100).toFixed(1))),r=t.contextStats;if(!r)return{totalTokens:s,contextWindow:n,usedPercent:a,freePercent:lu(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=lu(Number((r.usedPercent??c/i*100).toFixed(1)));return n!==i||s!==c?{totalTokens:s,contextWindow:n,usedPercent:a,freePercent:lu(Number((100-a).toFixed(1)))}:{totalTokens:c,contextWindow:i,usedPercent:d,freePercent:lu(Number((100-d).toFixed(1)))}}function OL(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 hN(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 LL(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 IL(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 PL(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===Ib||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===Ib)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 BL extends sj{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(n){return new HL(n)}),this.register(function(n){return new WL(n)}),this.register(function(n){return new ZL(n)}),this.register(function(n){return new e2(n)}),this.register(function(n){return new t2(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 KL(n)}),this.register(function(n){return new UL(n)}),this.register(function(n){return new QL(n)}),this.register(function(n){return new qL(n)}),this.register(function(n){return new JL(n)}),this.register(function(n){return new XL(n)}),this.register(function(n){return new zL(n)}),this.register(function(n){return new n2(n)}),this.register(function(n){return new s2(n)})}load(e,n,s,a){const r=this;let i;if(this.resourcePath!=="")i=this.resourcePath;else if(this.path!==""){const f=ju.extractUrlBase(e);i=ju.resolveURL(f,this.path)}else i=ju.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))===mN){try{i[Zt.KHR_BINARY_GLTF]=new a2(e)}catch(m){a&&a(m);return}r=JSON.parse(i[Zt.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 b2(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 Zt.KHR_MATERIALS_UNLIT:i[m]=new $L;break;case Zt.KHR_DRACO_MESH_COMPRESSION:i[m]=new r2(r,this.dracoLoader);break;case Zt.KHR_TEXTURE_TRANSFORM:i[m]=new i2;break;case Zt.KHR_MESH_QUANTIZATION:i[m]=new o2;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 FL(){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 Zt={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 zL{constructor(e){this.parser=e,this.name=Zt.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 Pb(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 $L{constructor(){this.name=Zt.KHR_MATERIALS_UNLIT}getMaterialType(){return Pl}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 UL{constructor(e){this.parser=e,this.name=Zt.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 HL{constructor(e){this.parser=e,this.name=Zt.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 WL{constructor(e){this.parser=e,this.name=Zt.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 qL{constructor(e){this.parser=e,this.name=Zt.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 VL{constructor(e){this.parser=e,this.name=Zt.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 YL{constructor(e){this.parser=e,this.name=Zt.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 GL{constructor(e){this.parser=e,this.name=Zt.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 KL{constructor(e){this.parser=e,this.name=Zt.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 QL{constructor(e){this.parser=e,this.name=Zt.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 XL{constructor(e){this.parser=e,this.name=Zt.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 JL{constructor(e){this.parser=e,this.name=Zt.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 ZL{constructor(e){this.parser=e,this.name=Zt.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 e2{constructor(e){this.parser=e,this.name=Zt.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 t2{constructor(e){this.parser=e,this.name=Zt.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 n2{constructor(e){this.name=Zt.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 s2{constructor(e){this.name=Zt.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!==Aa.TRIANGLES&&f.mode!==Aa.TRIANGLE_STRIP&&f.mode!==Aa.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 A=new dp,N=new Co,k=new rj,j=new Co(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,A.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 mN="glTF",cu=12,SS={JSON:1313821514,BIN:5130562};class a2{constructor(e){this.name=Zt.KHR_BINARY_GLTF,this.content=null,this.body=null;const n=new DataView(e,0,cu),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!==mN)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-cu,r=new DataView(e,cu);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,cu+i,c);this.content=s.decode(f)}else if(d===SS.BIN){const f=cu+i;this.body=e.slice(f,f+c)}i+=c}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class r2{constructor(e,n){if(!n)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Zt.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=ax[h]||h.toLowerCase();c[m]=i[h]}for(const h in e.attributes){const m=ax[h]||h.toLowerCase();if(i[h]!==void 0){const b=s.accessors[e.attributes[h]],y=zl[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 A=y.attributes[w],N=d[w];N!==void 0&&(A.normalized=N)}m(y)},c,f,lr,b)})})}}class i2{constructor(){this.name=Zt.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 o2{constructor(){this.name=Zt.KHR_MESH_QUANTIZATION}}class gN 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,A=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[A+T+c],E=i[A+T+d]*h,P=i[w+T+c],O=i[w+T]*h;r[T]=j*D+S*E+N*P+k*O}return r}}const l2=new rj;class c2 extends gN{interpolate_(e,n,s,a){const r=super.interpolate_(e,n,s,a);return l2.fromArray(r).normalize().toArray(r),r}}const Aa={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},zl={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},CS={9728:lj,9729:Bb,9984:$E,9985:zE,9986:FE,9987:oj},AS={33071:HE,33648:UE,10497:Fb},qg={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ax={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"},Ni={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},u2={CUBICSPLINE:void 0,LINEAR:fj,STEP:sM},Vg={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function d2(t){return t.DefaultMaterial===void 0&&(t.DefaultMaterial=new _x({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:rM})),t.DefaultMaterial}function bo(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 f2(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 p2(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 h2(t){let e;const n=t.extensions&&t.extensions[Zt.KHR_DRACO_MESH_COMPRESSION];if(n?e="draco:"+n.bufferView+":"+n.indices+":"+Yg(n.attributes):e=t.indices+":"+Yg(t.attributes)+":"+t.mode,t.targets!==void 0)for(let s=0,a=t.targets.length;s<a;s++)e+=":"+Yg(t.targets[s]);return e}function Yg(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 rx(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 m2(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 g2=new dp;class b2{constructor(e={},n={}){this.json=e,this.extensions={},this.plugins={},this.options=n,this.cache=new FL,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 bo(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[Zt.KHR_BINARY_GLTF].body);const a=this.options;return new Promise(function(r,i){s.load(ju.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=qg[a.type],c=zl[a.componentType],d=a.normalized===!0,f=new c(a.count*i);return Promise.resolve(new Nu(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=qg[a.type],f=zl[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 A,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||(A=new f(c,k*y,a.count*y/h),S=new BE(A,y/h),n.cache.add(j,S)),N=new aM(S,d,b%y/h,w)}else c===null?A=new f(a.count*d):A=new f(c,b,a.count*d),N=new Nu(A,d,w);if(a.sparse!==void 0){const k=qg.SCALAR,j=zl[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 Nu(N.array.slice(),N.itemSize,N.normalized)),N.normalized=!1;for(let P=0,O=D.length;P<O;P++){const _=D[P];if(N.setX(_,E[P*d]),d>=2&&N.setY(_,E[P*d+1]),d>=3&&N.setZ(_,E[P*d+2]),d>=4&&N.setW(_,E[P*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]||Bb,h.minFilter=CS[b.minFilter]||oj,h.wrapS=AS[b.wrapS]||Fb,h.wrapT=AS[b.wrapT]||Fb,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==lj&&h.minFilter!==Bb,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(A){const N=new ek(A);N.needsUpdate=!0,b(N)}),n.load(ju.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||m2(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[Zt.KHR_TEXTURE_TRANSFORM]){const c=s.extensions!==void 0?s.extensions[Zt.KHR_TEXTURE_TRANSFORM]:void 0;if(c){const d=r.associations.get(i);i=r.extensions[Zt.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 _x}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[Zt.KHR_MATERIALS_UNLIT]){const m=a[Zt.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||Vg.OPAQUE;if(h===Vg.BLEND?(c.transparent=!0,c.depthWrite=!1):(c.transparent=!1,h===Vg.MASK&&(c.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&i!==Pl&&(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!==Pl&&(f.push(n.assignTexture(c,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(c.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&i!==Pl){const m=r.emissiveFactor;c.emissive=new Hr().setRGB(m[0],m[1],m[2],lr)}return r.emissiveTexture!==void 0&&i!==Pl&&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&&bo(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[Zt.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=h2(f),m=a[h];if(m)i.push(m.promise);else{let b;f.extensions&&f.extensions[Zt.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?d2(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 A=h[y],N=i[y];let k;const j=f[y];if(N.mode===Aa.TRIANGLES||N.mode===Aa.TRIANGLE_STRIP||N.mode===Aa.TRIANGLE_FAN||N.mode===void 0)k=r.isSkinnedMesh===!0?new YE(A,j):new Ol(A,j),k.isSkinnedMesh===!0&&k.normalizeSkinWeights(),N.mode===Aa.TRIANGLE_STRIP?k.geometry=kS(k.geometry,nj):N.mode===Aa.TRIANGLE_FAN&&(k.geometry=kS(k.geometry,Ib));else if(N.mode===Aa.LINES)k=new GE(A,j);else if(N.mode===Aa.LINE_STRIP)k=new KE(A,j);else if(N.mode===Aa.LINE_LOOP)k=new QE(A,j);else if(N.mode===Aa.POINTS)k=new XE(A,j);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+N.mode);Object.keys(k.geometry.morphAttributes).length>0&&p2(k,r),k.name=n.createUniqueName(r.name||"mesh_"+e),Ir(k,r),N.extensions&&bo(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&&bo(a,m[0],r),m[0];const b=new yg;r.extensions&&bo(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],A=y.target,N=A.node,k=a.parameters!==void 0?a.parameters[w.input]:w.input,j=a.parameters!==void 0?a.parameters[w.output]:w.output;A.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(A))}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],A=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],P=A[j],O=N[j];if(T===void 0)continue;T.updateMatrix&&T.updateMatrix();const _=s._createAnimationTracks(T,D,E,P,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,g2)});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 yg: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&&bo(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 yg;s.name&&(r.name=a.createUniqueName(s.name)),Ir(r,s),s.extensions&&bo(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=[];Ni[r.path]===Ni.weights?e.traverse(function(b){b.morphTargetInfluences&&d.push(b.name?b.name:b.uuid)}):d.push(c);let f;switch(Ni[r.path]){case Ni.weights:f=nk;break;case Ni.rotation:f=sk;break;case Ni.position:case Ni.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?u2[a.interpolation]:fj,m=this._getArrayFromAccessor(s);for(let b=0,y=d.length;b<y;b++){const w=new f(d[b]+"."+Ni[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=rx(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?c2:gN;return new a(this.times,this.values,this.getValueSize()/3,s)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function x2(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 Co(d[0],d[1],d[2]),new Co(f[0],f[1],f[2])),c.normalized){const h=rx(zl[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 Co,d=new Co;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 A=rx(zl[b.componentType]);d.multiplyScalar(A)}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=ax[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 zb.workingColorSpace!==lr&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${zb.workingColorSpace}" not supported.`),Ir(t,e),x2(t,e,n),Promise.all(a).then(function(){return e.targets!==void 0?f2(t,e.targets,n):t})}const Gg=new WeakMap;class y2 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(Gg.has(e)){const d=Gg.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)}),Gg.set(e,{key:s,promise:c}),c}_createGeometry(e){const n=new uj;e.index&&n.setIndex(new Nu(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 Nu(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),zb.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=v2.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 v2(){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(A=>A.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 A={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),A.attributes.push(T)}return w===i.TRIANGULAR_MESH&&(A.index=s(i,c,b)),i.destroy(b),A}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,A=w*h.BYTES_PER_ELEMENT,N=r(i,h),k=i._malloc(A);c.GetAttributeDataArrayForAllPoints(d,m,N,A,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 w2=(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 P=r.exports.sbrk,O=S+3&-4,_=P(O*T),M=P(D.length),R=new Uint8Array(r.exports.memory.buffer);R.set(D,M);var F=k(_,S,T,M,D.length);if(F==0&&E&&E(_,O,T),j.set(R.subarray(_,_+S*T)),P(_-P(0)),F!=0)throw new Error("Malformed buffer data: "+F)}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 A(k,j,S,T,D){for(var E=m[0],P=1;P<m.length;++P)m[P].pending<E.pending&&(E=m[P]);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?A(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 k2={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 bN({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),A=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),[P,O]=x.useState(!1),_=x.useRef(!1),M=x.useRef(0),R=x.useRef(new Co),F=x.useRef(!1),$=x.useRef({x:0,y:0}),H=x.useRef({x:0,y:0});x.useEffect(()=>{const z=h.current;if(!z)return;O(!1);const W=new uM;W.background=new Hr(1710628),b.current=W;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),z.appendChild(G.domElement),m.current=G;const B=new fM(16777215,1);W.add(B);const K=new Pb(16777215,1.5);K.position.set(2,3,2),W.add(K);const se=new Pb(4890367,.6);se.position.set(-2,1,-1),W.add(se);const q=new pM(1,32),me=new _x({color:2763322,roughness:.8}),ce=new Ol(q,me);ce.rotation.x=-Math.PI/2,ce.position.y=0,W.add(ce);const ee=new hM(.35,.42,32),pe=new Pl({color:NS.idle,side:cj,transparent:!0,opacity:.8}),Ne=new Ol(ee,pe);Ne.rotation.x=-Math.PI/2,Ne.position.y=.01,W.add(Ne),j.current=Ne,E(!0);const ye=ne=>{F.current=!0,$.current={x:ne.clientX,y:ne.clientY},z.style.cursor="grabbing"},Me=ne=>{if(!F.current||!w.current)return;const Te=ne.clientX-$.current.x,We=ne.clientY-$.current.y;H.current.y+=Te*.01,H.current.x+=We*.01,H.current.x=Math.max(-Math.PI/4,Math.min(Math.PI/4,H.current.x)),w.current.rotation.y=H.current.y,w.current.rotation.x=H.current.x,$.current={x:ne.clientX,y:ne.clientY}},qe=()=>{F.current=!1,z.style.cursor="grab"},He=()=>{F.current=!1,z.style.cursor="grab"};z.addEventListener("mousedown",ye),window.addEventListener("mousemove",Me),window.addEventListener("mouseup",qe),z.addEventListener("mouseleave",He),z.style.cursor="grab";const X=()=>{S.current=requestAnimationFrame(X);const ne=T.current.getDelta();if(A.current)A.current.update(ne);else if(w.current&&!_.current){M.current+=ne;const Te=M.current,we=Math.sin(Te*1.5)*.02,de=Math.sin(Te*.8)*.01;w.current.position.set(R.current.x+de,R.current.y+we,R.current.z)}m.current&&b.current&&y.current&&m.current.render(b.current,y.current)};return X(),()=>{if(cancelAnimationFrame(S.current),z.removeEventListener("mousedown",ye),window.removeEventListener("mousemove",Me),window.removeEventListener("mouseup",qe),z.removeEventListener("mouseleave",He),w.current&&b.current&&(b.current.remove(w.current),w.current.traverse(ne=>{var Te,We;ne instanceof Ol&&((Te=ne.geometry)==null||Te.dispose(),Array.isArray(ne.material)?ne.material.forEach(nt=>{nt.map&&nt.map.dispose(),nt.dispose()}):ne.material&&(ne.material.map&&((We=ne.material.map)==null||We.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 Te;ne instanceof Ol&&((Te=ne.geometry)==null||Te.dispose(),ne.material instanceof Jf&&ne.material.dispose())}),b.current.clear()),A.current=null,k.current=null,N.current.clear(),m.current){try{const Te=m.current.getContext().getExtension("WEBGL_lose_context");Te&&Te.loseContext()}catch{}m.current.dispose(),z.contains(m.current.domElement)&&z.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 z=new BL,W=new y2;W.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.7/"),z.setDRACOLoader(W),z.setMeshoptDecoder(w2);let V=null;const G=B=>{w.current&&b.current&&(b.current.remove(w.current),w.current=null,A.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,me=(r==null?void 0:r.z)??0;if(K.position.set(se,me,q),K.visible=!0,H.current={x:0,y:0},K.rotation.set(0,0,0),K.traverse(ce=>{if(ce instanceof Ol&&(ce.castShadow=!0,ce.receiveShadow=!0,ce.material)){const ee=ce.material;ee.map&&(ee.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);A.current=ce,N.current.clear();for(const ee of B.animations)N.current.set(ee.name.toLowerCase(),ee);if(i!==""){const ee=i?N.current.get(i.toLowerCase())||B.animations[0]:N.current.get("idle")||B.animations[0];if(ee){const pe=ce.clipAction(ee);pe.reset().play(),k.current=pe}}}else _.current=!1,A.current=null,N.current.clear()};if(n)V=URL.createObjectURL(n),console.log("[ModelPreview] Loading custom model from file:",n.name,"blob URL:",V),z.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=Kb(s);console.log("[ModelPreview] Loading custom model from URL:",s),z.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?EL[t]:void 0)||"character-male-a.glb";z.load(`/assets/characters/${B}`,G,void 0,K=>{console.error("[ModelPreview] Failed to load model:",B,K)})}return()=>{V&&URL.revokeObjectURL(V),W.dispose()}},[t,e,n,s,a,r,D]);const L=z=>{if(!A.current)return;const W=k2[z],V=N.current.get(W);if(!V){const B=N.current.get("idle");if(B){const K=A.current.clipAction(B);K.reset().play(),k.current=K}return}const G=A.current.clipAction(V);z==="working"?G.timeScale=1.5:z==="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 z=j.current.material;z.color.setHex(NS[c]),c==="working"?z.opacity=.6+Math.sin(Date.now()*.005)*.4:z.opacity=.8}L(c)}},[c,D]),x.useEffect(()=>{if(!D||!A.current||c!=="idle")return;if(i===""){k.current&&(k.current.stop(),k.current=null);return}const z=i?i.toLowerCase():"idle",W=N.current.get(z);if(W){const V=A.current.clipAction(W);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]),P?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 S2({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),[A,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 F=new URLSearchParams({path:R,dirs:r?"true":"false",limit:"15"}),$=await Pt(Ot(`/api/files/autocomplete?${F}`));if($.ok){const H=await $.json();h(H.suggestions||[]),b(-1)}}catch(F){console.error("Failed to fetch path suggestions:",F)}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 F=R.isDirectory?R.path+"/":R.path;e(F),w(R.isDirectory),b(-1),($=k.current)==null||$.focus(),R.isDirectory&&T(F)},[e,T]),P=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(F=>F<f.length-1?F+1:F);break;case"ArrowUp":R.preventDefault(),b(F=>F>0?F-1:-1);break;case"Tab":if(R.preventDefault(),f.length>0){const F=m>=0?m:0;E(f[F])}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 F=j.current.querySelectorAll(".folder-input-suggestion")[m];F&&F.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:P,onFocus:O,onBlur:_,placeholder:s,autoFocus:i,disabled:d,autoComplete:"off",spellCheck:!1}),y&&(f.length>0||A)&&o.jsx("div",{ref:j,className:"folder-input-suggestions",children:A&&f.length===0?o.jsx("div",{className:"folder-input-loading",children:"Loading..."}):f.map((R,F)=>o.jsxs("div",{className:`folder-input-suggestion ${F===m?"selected":""}`,onClick:()=>E(R),onMouseEnter:()=>b(F),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 xN({agent:t,isOpen:e,onClose:n}){const{t:s}=pt(["terminal","common","tools"]),a=tL(),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,A]=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,P]=x.useState(t.opencodeModel||"minimax/MiniMax-M1-80k"),[O,_]=x.useState(t.useChrome||!1),[M,R]=x.useState(t.cwd),[F,$]=x.useState(new Set),[H,L]=x.useState(""),[z,W]=x.useState(!1),[V,G]=x.useState("");x.useMemo(()=>a.filter(X=>X.enabled&&(X.assignedAgentIds.includes(t.id)||X.assignedAgentClasses.includes(t.class))),[a,t.id,t.class]),x.useEffect(()=>{const X=a.filter(ne=>ne.assignedAgentIds.includes(t.id)).map(ne=>ne.id);$(new Set(X))},[a,t.id]),x.useEffect(()=>{if(e){c(t.name),f(t.class),m(t.permissionMode),y(t.provider||"claude"),A(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"),P(t.opencodeModel||"minimax/MiniMax-M1-80k"),_(t.useChrome||!1),R(t.cwd);const X=a.filter(ne=>ne.assignedAgentIds.includes(t.id)).map(ne=>ne.id);$(new Set(X))}},[e,t,a]);const B=x.useMemo(()=>a.filter(X=>X.enabled),[a]),K=x.useMemo(()=>{if(!H.trim())return B;const X=H.toLowerCase();return B.filter(ne=>ne.name.toLowerCase().includes(X)||ne.description.toLowerCase().includes(X)||ne.slug.toLowerCase().includes(X))},[B,H]),se=x.useMemo(()=>B.filter(X=>X.assignedAgentClasses.includes(d)),[B,d]),q=x.useCallback(X=>{$(ne=>{const Te=new Set(ne);return Te.has(X)?Te.delete(X):Te.add(X),Te})},[]),me=x.useMemo(()=>{const X=r.find(ne=>ne.id===d);if(X!=null&&X.model)return X.model},[r,d]),ce=x.useMemo(()=>{const X=r.find(ne=>ne.id===d);if(X!=null&&X.customModelPath)return Ot(`/api/custom-models/${X.id}`)},[r,d]),ee=x.useMemo(()=>{const X=r.find(ne=>ne.id===d);return X==null?void 0:X.modelScale},[r,d]),pe=x.useMemo(()=>r.find(X=>X.id===d),[r,d]);x.useEffect(()=>{pe&&(G(pe.instructions||""),W(!1))},[pe==null?void 0:pe.id]);const Ne=x.useMemo(()=>r.find(ne=>ne.id===d)?"scout":d,[r,d]),ye=x.useMemo(()=>{const X=i.trim();if(X&&X!==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(We=>We.assignedAgentIds.includes(t.id)).map(We=>We.id).sort().join(","),Te=Array.from(F).sort().join(",");return ne!==Te},[i,d,h,b,N,j,T,w,E,O,M,F,t,a]),Me=()=>{const X=i.trim(),ne={};X&&X!==t.name&&U.renameAgent(t.id,X),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 Te=a.filter(nt=>nt.assignedAgentIds.includes(t.id)).map(nt=>nt.id).sort().join(","),We=Array.from(F).sort().join(",");Te!==We&&(ne.skillIds=Array.from(F)),Object.keys(ne).length>0&&U.updateAgentProperties(t.id,ne),n()},{handleMouseDown:qe,handleClick:He}=_a(n);return e?o.jsx("div",{className:"modal-overlay visible",onMouseDown:qe,onClick:He,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(bN,{agentClass:Ne,modelFile:me,customModelUrl:ce,modelScale:ee,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(X=>o.jsxs("button",{className:`class-chip ${d===X.id?"selected":""}`,onClick:()=>f(X.id),title:X.description,children:[o.jsx("span",{className:"class-chip-icon",children:X.icon}),o.jsx("span",{className:"class-chip-name",children:X.name})]},X.id)),Object.entries(Do).filter(([X])=>X!=="boss").map(([X,ne])=>o.jsxs("button",{className:`class-chip ${d===X?"selected":""}`,onClick:()=>f(X),title:ne.description,children:[o.jsx("span",{className:"class-chip-icon",children:ne.icon}),o.jsx("span",{className:"class-chip-name",children:X.charAt(0).toUpperCase()+X.slice(1)})]},X))]})]})]}),pe&&o.jsxs("div",{className:"custom-class-notice",children:[o.jsxs("div",{className:"custom-class-notice-header",onClick:()=>W(!z),style:{cursor:"pointer"},children:[o.jsx("span",{children:"📋"}),o.jsx("span",{children:pe.instructions?s("terminal:spawn.hasCustomInstructions"):"Add custom instructions"}),o.jsx("span",{style:{marginLeft:"auto",fontSize:11,opacity:.6},children:z?"▲":"▼"})]}),!z&&pe.instructions&&o.jsx("div",{className:"custom-class-notice-info",children:s("terminal:spawn.instructionsInjected",{count:pe.instructions.length})}),z&&o.jsxs("div",{className:"custom-class-instructions-editor",children:[o.jsx("textarea",{value:V,onChange:X=>G(X.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(pe.id,{instructions:V}),W(!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(pe.instructions||""),W(!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:X=>c(X.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(Ru).map(X=>o.jsxs("button",{className:`spawn-select-btn ${h===X?"selected":""}`,onClick:()=>m(X),title:Ru[X].description,children:[o.jsx("span",{children:X==="bypass"?"⚡":"🔐"}),o.jsx("span",{children:Ru[X].label})]},X))})]})]}),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(X=>o.jsxs("button",{className:`spawn-select-btn ${N===X?"selected":""}`,onClick:()=>k(X),title:Rf[X].description,children:[o.jsx("span",{children:Rf[X].icon}),o.jsx("span",{children:Rf[X].label})]},X))}):b==="codex"?o.jsx("div",{className:"spawn-select-row spawn-select-row--codex-models",children:Object.keys(Df).map(X=>o.jsxs("button",{className:`spawn-select-btn ${T===X?"selected":""}`,onClick:()=>D(X),title:Df[X].description,children:[o.jsx("span",{children:Df[X].icon}),o.jsx("span",{children:Df[X].label})]},X))}):b==="opencode"?o.jsx("input",{type:"text",className:"spawn-input",value:E,onChange:X=>P(X.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(Wg).map(X=>o.jsx("button",{className:`spawn-select-btn spawn-select-btn--compact ${j===X?"selected":""}`,onClick:()=>S(X),title:Wg[X].description,children:o.jsx("span",{children:Wg[X].label})},X))]})]})]}),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:X=>A(ne=>({...ne,fullAuto:X.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:X=>A(ne=>({...ne,search:X.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:X=>A(ne=>({...ne,sandbox:X.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:X=>A(ne=>({...ne,approvalMode:X.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:X=>A(ne=>({...ne,profile:X.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:X=>_(X.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(S2,{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:H,onChange:X=>L(X.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:H})}):K.map(X=>{const ne=se.includes(X),We=F.has(X.id)||ne;return o.jsxs("button",{className:`skill-chip ${We?"selected":""} ${ne?"class-based":""}`,onClick:()=>!ne&&q(X.id),title:ne?s("terminal:spawn.assignedViaClass"):X.name,children:[We&&o.jsx("span",{className:"skill-check",children:"✓"}),o.jsx("span",{className:"skill-chip-name",children:X.name}),X.builtin&&o.jsx("span",{className:"skill-chip-badge builtin",children:"TC"}),ne&&o.jsx("span",{className:"skill-chip-badge",children:"class"})]},X.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:Me,disabled:!ye,children:s("common:buttons2.saveChanges")})]})]})}):null}const C2=Object.freeze(Object.defineProperty({__proto__:null,AgentEditModal:xN},Symbol.toStringTag,{value:"Module"}));var nc=tj();const A2=Zu(nc);function pr({children:t}){return typeof document>"u"?null:nc.createPortal(t,document.body)}function uu(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 j2(t){return t>=80?"#ff4a4a":t>=60?"#ff9e4a":t>=40?"#ffd700":"#4aff9e"}const N2={systemPrompt:"#4a9eff",systemTools:"#9e4aff",messages:"#4aff9e",freeSpace:"rgba(255,255,255,0.1)",autocompactBuffer:"#ff9e4a"},T2={systemPrompt:"terminal:context.systemPrompt",systemTools:"terminal:context.systemTools",messages:"terminal:context.messagesCategory",freeSpace:"terminal:context.freeSpace",autocompactBuffer:"terminal:context.autocompactBuffer"},_2={systemPrompt:"terminal:context.systemPromptDesc",systemTools:"terminal:context.systemToolsDesc",messages:"terminal:context.messagesDesc",freeSpace:"terminal:context.freeSpaceDesc",autocompactBuffer:"terminal:context.autocompactBufferDesc"};function yN({agent:t,isOpen:e,onClose:n,onRefresh:s}){const{t:a}=pt(["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(T2[w]),description:a(_2[w]),color:N2[w]})):[],[r]),m=x.useMemo(()=>h.filter(w=>w.key!=="freeSpace"),[h]),{handleMouseDown:b,handleClick:y}=_a(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:uu(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:j2(r.usedPercent)},children:[uu(r.totalTokens)," / ",uu(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}: ${uu(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:uu(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 E2=x.memo(function({tokensUsed:e,createdAt:n}){const{t:s}=pt(["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)})]})]})}),vN=x.memo(function({contextInfo:e,onClick:n}){const{t:s}=pt(["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:hN(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")})]})}),M2=x.memo(function({lastActivity:e}){const{t:n}=pt(["common"]);return o.jsxs("div",{className:"unit-idle-timer",title:n("unitPanel.timeSinceActivity"),style:{color:Ex(e)},children:["⏱ ",Dx(e)]})}),D2=x.memo(function({task:e}){const{t:n}=pt(["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})]})}),R2=x.memo(function({cwd:e}){const{t:n}=pt(["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})]})}),O2=x.memo(function({text:e,maxLength:n=150}){const{t:s}=pt(["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})]})}),L2=x.memo(function({text:e,maxLength:n=200}){const{t:s}=pt(["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 I2({agent:t,onFocusAgent:e,onKillAgent:n,onCallSubordinates:s,onOpenAreaExplorer:a}){var ye,Me;const{t:r}=pt(["common"]),i=Ls(),c=dr(),{showToast:d}=dN(),f=i.agents.get(t.id)||t,h=fr(f.class,c),m=c.find(qe=>qe.id===f.class),b=m==null?void 0:m.model,y=m!=null&&m.customModelPath?Ot(`/api/custom-models/${m.id}`):void 0,w=m==null?void 0:m.modelScale,[A,N]=x.useState(!1),[k,j]=x.useState(f.name),S=x.useRef(null),[,T]=x.useState(0),[D,E]=x.useState(!0),[P,O]=x.useState(!1),[_,M]=x.useState([]),[R,F]=x.useState(null),[$,H]=x.useState(!1),[L,z]=x.useState(!1),W=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(()=>{A&&S.current&&(S.current.focus(),S.current.select())},[A]),x.useEffect(()=>{if(f.status==="idle"){const qe=setInterval(()=>{T(He=>He+1)},15e3);return()=>clearInterval(qe)}},[f.status]),x.useEffect(()=>{f.permissionMode==="interactive"&&Pt(Ot("/api/remembered-patterns")).then(qe=>qe.json()).then(M).catch(qe=>console.error("Failed to fetch remembered patterns:",qe))},[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),me=async(qe,He)=>{try{(await Pt(Ot(`/api/remembered-patterns/${qe}/${encodeURIComponent(He)}`),{method:"DELETE"})).ok&&M(ne=>ne.filter(Te=>!(Te.tool===qe&&Te.pattern===He)))}catch(X){console.error("Failed to remove pattern:",X)}},ce=async()=>{if(confirm(r("confirm.clearPatterns")))try{(await Pt(Ot("/api/remembered-patterns"),{method:"DELETE"})).ok&&M([])}catch(qe){console.error("Failed to clear patterns:",qe)}},ee=()=>{confirm(r("confirm.terminateAgent"))&&n(f.id)},pe=()=>{const qe=k.trim();qe&&qe!==f.name?U.renameAgent(f.id,qe):j(f.name),N(!1)},Ne=qe=>{qe.key==="Enter"?pe():qe.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(bN,{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:[A?o.jsx("input",{ref:S,type:"text",className:"unit-name-input",value:k,onChange:qe=>j(qe.target.value),onBlur:pe,onKeyDown:Ne}):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(M2,{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:()=>H(!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:()=>F("collapse"),title:r("unitPanel.collapseContext"),disabled:f.status!=="idle",children:"📦"}),o.jsx("button",{className:"unit-action-icon warning",onClick:()=>F("clear"),title:r("unitPanel.clearContext"),children:"🧹"}),o.jsx("button",{className:"unit-action-icon danger",onClick:ee,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(O2,{text:q.text}),se&&o.jsx(L2,{text:se.text}),o.jsx(E2,{tokensUsed:f.tokensUsed,createdAt:f.createdAt}),o.jsx(vN,{contextInfo:G,onClick:()=>z(!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(D2,{task:f.currentTask}),o.jsx(R2,{cwd:f.cwd}),o.jsx(P2,{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:(ye=Ru[f.permissionMode])==null?void 0:ye.description,children:[o.jsx("span",{className:"unit-permission-mode-icon",children:f.permissionMode==="bypass"?"⚡":"🔐"}),o.jsx("span",{className:"unit-permission-mode-label",children:((Me=Ru[f.permissionMode])==null?void 0:Me.label)||f.permissionMode})]})]}),f.permissionMode==="interactive"&&o.jsx(B2,{patterns:_,showPatterns:P,onToggle:()=>O(!P),onRemovePattern:me,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 qe=f.provider==="codex"?`codex resume ${f.sessionId}`:f.provider==="opencode"?`opencode resume ${f.sessionId}`:`claude --resume ${f.sessionId}`;try{await navigator.clipboard.writeText(qe),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:[W.length>0&&o.jsx("span",{className:"unit-supervisor-history-count",children:W.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")}):W.length===0?o.jsx("div",{className:"unit-supervisor-history-empty",children:r("unitPanel.noSupervisorReports")}):W.slice(0,10).map((qe,He)=>o.jsx(wN,{entry:qe,defaultExpanded:He===0},qe.id))})]}),(f.isBoss||f.class==="boss")&&o.jsx(z2,{agent:f}),f.bossId&&o.jsx(U2,{agentId:f.id,bossId:f.bossId}),f.class!=="boss"&&!f.isBoss&&!f.bossId&&o.jsx(H2,{agentId:f.id}),R&&o.jsx(F2,{action:R,agentName:f.name,onClose:()=>F(null),onConfirm:()=>{R==="collapse"?U.collapseContext(f.id):U.clearContext(f.id),F(null)}}),o.jsx(xN,{agent:f,isOpen:$,onClose:()=>H(!1)}),o.jsx(yN,{agent:f,isOpen:L,onClose:()=>z(!1),onRefresh:()=>{U.refreshAgentContext(f.id)}})]})}const P2=x.memo(function({currentAgentId:e}){const{t:n}=pt(["common"]),s=Ls(),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)})})]})}),B2=x.memo(function({patterns:e,showPatterns:n,onToggle:s,onRemovePattern:a,onClearAll:r}){const{t:i}=pt(["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")})]})})]})}),F2=x.memo(function({action:e,agentName:n,onClose:s,onConfirm:a}){const{t:r}=pt(["common"]),{handleMouseDown:i,handleClick:c}=_a(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")})]})]})})}),wN=x.memo(function({entry:e,defaultExpanded:n=!1,agent:s,onAgentClick:a}){var k;const{t:r}=pt(["common"]),[i,c]=x.useState(n),d=Ls(),f=dr(),{analysis:h}=e,m=d.settings.hideCost,b=Eu(h.statusDescription,m),y=Eu(h.recentWorkSummary,m),w=(k=h.concerns)==null?void 0:k.map(j=>Eu(j,m)).filter(j=>j.length>0),A=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&&A&&o.jsxs("div",{className:"supervisor-history-agent-line",onClick:N,children:[o.jsx("span",{className:"supervisor-history-agent-icon",children:A.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))})]})]})]})}),z2=x.memo(function({agent:e}){const{t:n}=pt(["common"]),s=Ls(),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(A=>s.agents.get(A)).filter(A=>A!==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 A=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:A.color},children:A.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($2,{decision:w},w.id))]})]})]})}),$2=x.memo(function({decision:e}){const{t:n}=pt(["common"]),[s,a]=x.useState(!1),i=Ls().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(", ")]})]})]})}),U2=x.memo(function({agentId:e,bossId:n}){const{t:s}=pt(["common"]),r=Ls().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:"✕"})]})}),H2=x.memo(function({agentId:e}){const{t:n}=pt(["common"]),s=Ls(),[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}=pt(["common"]),n=Ls(),s=Array.from(n.agents.values()),a=Array.from(n.areas.values()),[r,i]=x.useState(""),[c,d]=x.useState(()=>{const P=$a(mt.COMMANDER_FILTERS,"all");return P==="working"?"active":P||"all"}),f=x.useRef(null),h=x.useMemo(()=>s.map(P=>P.id).sort().join(","),[s]),m=x.useRef(new Set);x.useEffect(()=>{for(const P of s){if(m.current.has(P.id))continue;U.getAgentSupervisorHistory(P.id).length===0&&!U.isLoadingHistoryForAgent(P.id)&&(m.current.add(P.id),U.requestAgentSupervisorHistory(P.id))}},[h]);const b=n.agentsWithUnseenOutput,y=x.useMemo(()=>{const P={all:0,active:0,idle:0,error:0,waiting:0};for(const O of s)P.all++,(O.status==="working"||b.has(O.id))&&P.active++,O.status==="idle"&&!b.has(O.id)&&P.idle++,(O.status==="error"||O.status==="orphaned"||O.status==="offline")&&P.error++,(O.status==="waiting"||O.status==="waiting_permission")&&P.waiting++;return P},[s,b]),w=x.useMemo(()=>{const P=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(P){const R=O.name.toLowerCase().includes(P),F=((_=O.taskLabel)==null?void 0:_.toLowerCase().includes(P))||!1,$=O.class.toLowerCase().includes(P),H=((M=O.currentTool)==null?void 0:M.toLowerCase().includes(P))||!1;return R||F||$||H}return!0})},[s,r,c,b]),A=x.useMemo(()=>LL(w),[w]),N=IL(A,P=>U.getAreaForAgent(P));if(!r&&c==="all")for(const P of a)N.has(P.id)||N.set(P.id,[]);const k=PL(Array.from(N.keys()),P=>n.areas.get(P)),j=x.useCallback(P=>{d(P),Wr(mt.COMMANDER_FILTERS,P)},[]),S=x.useCallback(()=>{var P;i(""),(P=f.current)==null||P.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:P=>i(P.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(P=>{const O=y[P];return P!=="all"&&O===0?null:o.jsxs("button",{className:`agents-filter-chip ${P} ${c===P?"selected":""}`,onClick:()=>j(P),children:[e(`agentsList.filter_${P}`),o.jsx("span",{className:"agents-filter-chip-count",children:O})]},P)})}),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(P=>{const O=N.get(P),_=P?n.areas.get(P):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(W2,{agent:M,area:_,searchQuery:r},M.id))})]},P||"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(q2,{agents:s})]})]})}const W2=x.memo(function({agent:e,area:n,searchQuery:s=""}){const a=Ls(),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?Ex(e.lastActivity):void 0,y=Xp(e),w=hN(y.remainingPercent),A=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:A})]}),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:Dx(e.lastActivity),children:["⏱ ",OL(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}`})]})}),q2=x.memo(function({agents:e}){const{t:n}=pt(["common"]),s=Ls(),[a,r]=x.useState(()=>Ei(mt.GLOBAL_SUPERVISOR_COLLAPSED)),i=()=>{const h=!a;r(h),Mi(mt.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(wN,{entry:m,agent:h,onAgentClick:d,defaultExpanded:!1},m.id))})]})}),V2=x.memo(function({agents:e}){const{t:n}=pt(["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(Y2,{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")})})]})}),Y2=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=Ls(),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(I2,{agent:i,onFocusAgent:t,onKillAgent:e,onCallSubordinates:n,onOpenAreaExplorer:s}):o.jsx(_S,{onOpenAreaExplorer:s})}return o.jsx(V2,{agents:r})}function G2(t,e){const n={};return(t[t.length-1]===""?[...t,""]:t).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const K2=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Q2=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,X2={};function MS(t,e){return(X2.jsx?Q2:K2).test(t)}const J2=/[ \t\n\f\r]/g;function Z2(t){return typeof t=="object"?t.type==="text"?DS(t.value):!1:DS(t)}function DS(t){return t.replace(J2,"")===""}class sd{constructor(e,n,s){this.normal=n,this.property=e,s&&(this.space=s)}}sd.prototype.normal={};sd.prototype.property={};sd.prototype.space=void 0;function kN(t,e){const n={},s={};for(const a of t)Object.assign(n,a.property),Object.assign(s,a.normal);return new sd(n,s,e)}function ix(t){return t.toLowerCase()}class Gs{constructor(e,n){this.attribute=n,this.property=e}}Gs.prototype.attribute="";Gs.prototype.booleanish=!1;Gs.prototype.boolean=!1;Gs.prototype.commaOrSpaceSeparated=!1;Gs.prototype.commaSeparated=!1;Gs.prototype.defined=!1;Gs.prototype.mustUseProperty=!1;Gs.prototype.number=!1;Gs.prototype.overloadedBoolean=!1;Gs.prototype.property="";Gs.prototype.spaceSeparated=!1;Gs.prototype.space=void 0;let eI=0;const Wt=Bo(),ls=Bo(),ox=Bo(),tt=Bo(),Dn=Bo(),$l=Bo(),ra=Bo();function Bo(){return 2**++eI}const lx=Object.freeze(Object.defineProperty({__proto__:null,boolean:Wt,booleanish:ls,commaOrSpaceSeparated:ra,commaSeparated:$l,number:tt,overloadedBoolean:ox,spaceSeparated:Dn},Symbol.toStringTag,{value:"Module"})),Kg=Object.keys(lx);class Qx extends Gs{constructor(e,n,s,a){let r=-1;if(super(e,n),RS(this,"space",a),typeof s=="number")for(;++r<Kg.length;){const i=Kg[r];RS(this,Kg[r],(s&lx[i])===lx[i])}}}Qx.prototype.defined=!0;function RS(t,e,n){n&&(t[e]=n)}function sc(t){const e={},n={};for(const[s,a]of Object.entries(t.properties)){const r=new Qx(s,t.transform(t.attributes||{},s),a,t.space);t.mustUseProperty&&t.mustUseProperty.includes(s)&&(r.mustUseProperty=!0),e[s]=r,n[ix(s)]=s,n[ix(r.attribute)]=s}return new sd(e,n,t.space)}const SN=sc({properties:{ariaActiveDescendant:null,ariaAtomic:ls,ariaAutoComplete:null,ariaBusy:ls,ariaChecked:ls,ariaColCount:tt,ariaColIndex:tt,ariaColSpan:tt,ariaControls:Dn,ariaCurrent:null,ariaDescribedBy:Dn,ariaDetails:null,ariaDisabled:ls,ariaDropEffect:Dn,ariaErrorMessage:null,ariaExpanded:ls,ariaFlowTo:Dn,ariaGrabbed:ls,ariaHasPopup:null,ariaHidden:ls,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Dn,ariaLevel:tt,ariaLive:null,ariaModal:ls,ariaMultiLine:ls,ariaMultiSelectable:ls,ariaOrientation:null,ariaOwns:Dn,ariaPlaceholder:null,ariaPosInSet:tt,ariaPressed:ls,ariaReadOnly:ls,ariaRelevant:null,ariaRequired:ls,ariaRoleDescription:Dn,ariaRowCount:tt,ariaRowIndex:tt,ariaRowSpan:tt,ariaSelected:ls,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 CN(t,e){return e in t?t[e]:e}function AN(t,e){return CN(t,e.toLowerCase())}const tI=sc({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:$l,acceptCharset:Dn,accessKey:Dn,action:null,allow:null,allowFullScreen:Wt,allowPaymentRequest:Wt,allowUserMedia:Wt,alt:null,as:null,async:Wt,autoCapitalize:null,autoComplete:Dn,autoFocus:Wt,autoPlay:Wt,blocking:Dn,capture:null,charSet:null,checked:Wt,cite:null,className:Dn,cols:tt,colSpan:null,content:null,contentEditable:ls,controls:Wt,controlsList:Dn,coords:tt|$l,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Wt,defer:Wt,dir:null,dirName:null,disabled:Wt,download:ox,draggable:ls,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Wt,formTarget:null,headers:Dn,height:tt,hidden:ox,high:tt,href:null,hrefLang:null,htmlFor:Dn,httpEquiv:Dn,id:null,imageSizes:null,imageSrcSet:null,inert:Wt,inputMode:null,integrity:null,is:null,isMap:Wt,itemId:null,itemProp:Dn,itemRef:Dn,itemScope:Wt,itemType:Dn,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:Dn,placeholder:null,playsInline:Wt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Wt,referrerPolicy:null,rel:Dn,required:Wt,reversed:Wt,rows:tt,rowSpan:tt,sandbox:Dn,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:ls,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:ls,width:tt,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Dn,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:ls,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:AN}),nI=sc({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:Dn,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:$l,g2:$l,glyphName:$l,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:Dn,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:CN}),jN=sc({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()}}),NN=sc({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:AN}),TN=sc({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(t,e){return"xml:"+e.slice(3).toLowerCase()}}),sI={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"},aI=/[A-Z]/g,OS=/-[a-z]/g,rI=/^data[-\w.:]+$/i;function iI(t,e){const n=ix(e);let s=e,a=Gs;if(n in t.normal)return t.property[t.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&rI.test(e)){if(e.charAt(4)==="-"){const r=e.slice(5).replace(OS,lI);s="data"+r.charAt(0).toUpperCase()+r.slice(1)}else{const r=e.slice(4);if(!OS.test(r)){let i=r.replace(aI,oI);i.charAt(0)!=="-"&&(i="-"+i),e="data"+i}}a=Qx}return new a(s,e)}function oI(t){return"-"+t.toLowerCase()}function lI(t){return t.charAt(1).toUpperCase()}const cI=kN([SN,tI,jN,NN,TN],"html"),Xx=kN([SN,nI,jN,NN,TN],"svg");function uI(t){return t.join(" ").trim()}var Nl={},Qg,LS;function dI(){if(LS)return Qg;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(H){var L=H.match(e);L&&(j+=L.length);var z=H.lastIndexOf(d);S=~z?H.length-z:S+H.length}function D(){var H={line:j,column:S};return function(L){return L.position=new E(H),_(),L}}function E(H){this.start=H,this.end={line:j,column:S},this.source=k.source}E.prototype.content=N;function P(H){var L=new Error(k.source+":"+j+":"+S+": "+H);if(L.reason=H,L.filename=k.source,L.line=j,L.column=S,L.source=N,!k.silent)throw L}function O(H){var L=H.exec(N);if(L){var z=L[0];return T(z),N=N.slice(z.length),L}}function _(){O(n)}function M(H){var L;for(H=H||[];L=R();)L!==!1&&H.push(L);return H}function R(){var H=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 P("End of comment missing");var z=N.slice(2,L-2);return S+=2,T(z),N=N.slice(L),S+=2,H({type:b,comment:z})}}function F(){var H=D(),L=O(s);if(L){if(R(),!O(a))return P("property missing ':'");var z=O(r),W=H({type:y,property:A(L[0].replace(t,m)),value:z?A(z[0].replace(t,m)):m});return O(i),W}}function $(){var H=[];M(H);for(var L;L=F();)L!==!1&&(H.push(L),M(H));return H}return _(),$()}function A(N){return N?N.replace(c,m):m}return Qg=w,Qg}var IS;function fI(){if(IS)return Nl;IS=1;var t=Nl&&Nl.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Nl,"__esModule",{value:!0}),Nl.default=n;const e=t(dI());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 Nl}var du={},PS;function pI(){if(PS)return du;PS=1,Object.defineProperty(du,"__esModule",{value:!0}),du.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 du.camelCase=d,du}var fu,BS;function hI(){if(BS)return fu;BS=1;var t=fu&&fu.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},e=t(fI()),n=pI();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,fu=s,fu}var mI=hI();const gI=Zu(mI),_N=EN("end"),Jx=EN("start");function EN(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 bI(t){const e=Jx(t),n=_N(t);if(e&&n)return{start:e,end:n}}function Ou(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?cx(t):""}function cx(t){return zS(t&&t.line)+":"+zS(t&&t.column)}function FS(t){return cx(t&&t.start)+"-"+cx(t&&t.end)}function zS(t){return t&&typeof t=="number"?t:1}class Ts 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=Ou(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}}Ts.prototype.file="";Ts.prototype.name="";Ts.prototype.reason="";Ts.prototype.message="";Ts.prototype.stack="";Ts.prototype.column=void 0;Ts.prototype.line=void 0;Ts.prototype.ancestors=void 0;Ts.prototype.cause=void 0;Ts.prototype.fatal=void 0;Ts.prototype.place=void 0;Ts.prototype.ruleId=void 0;Ts.prototype.source=void 0;const Zx={}.hasOwnProperty,xI=new Map,yI=/[A-Z]/g,vI=new Set(["table","tbody","thead","tfoot","tr"]),wI=new Set(["td","th"]),MN="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function kI(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=EI(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=_I(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"?Xx:cI,stylePropertyNameCase:e.stylePropertyNameCase||"dom",tableCellAlignToStyle:e.tableCellAlignToStyle!==!1},r=DN(a,t,void 0);return r&&typeof r!="string"?r:a.create(t,a.Fragment,{children:r||void 0},void 0)}function DN(t,e,n){if(e.type==="element")return SI(t,e,n);if(e.type==="mdxFlowExpression"||e.type==="mdxTextExpression")return CI(t,e);if(e.type==="mdxJsxFlowElement"||e.type==="mdxJsxTextElement")return jI(t,e,n);if(e.type==="mdxjsEsm")return AI(t,e);if(e.type==="root")return NI(t,e,n);if(e.type==="text")return TI(t,e)}function SI(t,e,n){const s=t.schema;let a=s;e.tagName.toLowerCase()==="svg"&&s.space==="html"&&(a=Xx,t.schema=a),t.ancestors.push(e);const r=ON(t,e.tagName,!1),i=MI(t,e);let c=ty(t,e);return vI.has(e.tagName)&&(c=c.filter(function(d){return typeof d=="string"?!Z2(d):!0})),RN(t,i,r,e),ey(i,c),t.ancestors.pop(),t.schema=s,t.create(e,r,i,n)}function CI(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)}Gu(t,e.position)}function AI(t,e){if(e.data&&e.data.estree&&t.evaluater)return t.evaluater.evaluateProgram(e.data.estree);Gu(t,e.position)}function jI(t,e,n){const s=t.schema;let a=s;e.name==="svg"&&s.space==="html"&&(a=Xx,t.schema=a),t.ancestors.push(e);const r=e.name===null?t.Fragment:ON(t,e.name,!0),i=DI(t,e),c=ty(t,e);return RN(t,i,r,e),ey(i,c),t.ancestors.pop(),t.schema=s,t.create(e,r,i,n)}function NI(t,e,n){const s={};return ey(s,ty(t,e)),t.create(e,t.Fragment,s,n)}function TI(t,e){return e.value}function RN(t,e,n,s){typeof n!="string"&&n!==t.Fragment&&t.passNode&&(e.node=s)}function ey(t,e){if(e.length>0){const n=e.length>1?e:e[0];n&&(t.children=n)}}function _I(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 EI(t,e){return n;function n(s,a,r,i){const c=Array.isArray(r.children),d=Jx(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 MI(t,e){const n={};let s,a;for(a in e.properties)if(a!=="children"&&Zx.call(e.properties,a)){const r=RI(t,a,e.properties[a]);if(r){const[i,c]=r;t.tableCellAlignToStyle&&i==="align"&&typeof c=="string"&&wI.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 DI(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 Gu(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 Gu(t,e.position);else r=s.value===null?!0:s.value;n[a]=r}return n}function ty(t,e){const n=[];let s=-1;const a=t.passKeys?new Map:xI;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=DN(t,r,i);c!==void 0&&n.push(c)}return n}function RI(t,e,n){const s=iI(t.schema,e);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=s.commaSeparated?G2(n):uI(n)),s.property==="style"){let a=typeof n=="object"?n:OI(t,String(n));return t.stylePropertyNameCase==="css"&&(a=LI(a)),["style",a]}return[t.elementAttributeNameCase==="react"&&s.space?sI[s.property]||s.property:s.attribute,n]}}function OI(t,e){try{return gI(e,{reactCompat:!0})}catch(n){if(t.ignoreInvalidStyle)return{};const s=n,a=new Ts("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=MN+"#cannot-parse-style-attribute",a}}function ON(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 Zx.call(t.components,a)?t.components[a]:a}if(t.evaluater)return t.evaluater.evaluateExpression(s);Gu(t)}function Gu(t,e){const n=new Ts("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=MN+"#cannot-handle-mdx-estrees-without-createevaluater",n}function LI(t){const e={};let n;for(n in t)Zx.call(t,n)&&(e[II(n)]=t[n]);return e}function II(t){let e=t.replace(yI,PI);return e.slice(0,3)==="ms-"&&(e="-"+e),e}function PI(t){return"-"+t.toLowerCase()}const Xg={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"]},BI={};function ny(t,e){const n=BI,s=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,a=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return LN(t,s,a)}function LN(t,e,n){if(FI(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]=LN(t[a],e,n);return s.join("")}function FI(t){return!!(t&&typeof t=="object")}const US=document.createElement("i");function sy(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 ja(t,e){return t.length>0?(ua(t,t.length,0,e),t):e}const HS={}.hasOwnProperty;function IN(t){const e={};let n=-1;for(;++n<t.length;)zI(e,t[n]);return e}function zI(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];$I(a[i],Array.isArray(c)?c:c?[c]:[])}}}function $I(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 PN(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 Ba(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Rs=zi(/[A-Za-z]/),Ns=zi(/[\dA-Za-z]/),UI=zi(/[#-'*+\--9=?A-Z^-~]/);function kp(t){return t!==null&&(t<32||t===127)}const ux=zi(/\d/),HI=zi(/[\dA-Fa-f]/),WI=zi(/[!-/:-@[-`{-~]/);function Mt(t){return t!==null&&t<-2}function Tn(t){return t!==null&&(t<0||t===32)}function tn(t){return t===-2||t===-1||t===32}const Jp=zi(new RegExp("\\p{P}|\\p{S}","u")),Ro=zi(/\s/);function zi(t){return e;function e(n){return n!==null&&n>-1&&t.test(String.fromCharCode(n))}}function ac(t){const e=[];let n=-1,s=0,a=0;for(;++n<t.length;){const r=t.charCodeAt(n);let i="";if(r===37&&Ns(t.charCodeAt(n+1))&&Ns(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 tn(d)?(t.enter(n),c(d)):e(d)}function c(d){return tn(d)&&r++<a?(t.consume(d),c):(t.exit(n),e(d))}}const qI={tokenize:VI};function VI(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 Mt(c)?(t.consume(c),t.exit("chunkText"),r):(t.consume(c),i)}}const YI={tokenize:GI},WS={tokenize:KI};function GI(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 P=T;for(;P<e.events.length;)e.events[P][1].end={...E},P++;return ua(e.events,D+1,0,e.events.slice(T)),e.events.length=P,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}),A(S)}function A(S){if(S===null){N(t.exit("chunkFlow"),!0),k(0),t.consume(S);return}return Mt(S)?(t.consume(S),N(t.exit("chunkFlow")),s=0,e.interrupt=void 0,c):(t.consume(S),A)}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 P=e.events.length;let O=P,_,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=P;E<e.events.length;)e.events[E][1].end={...M},E++;ua(e.events,O+1,0,e.events.slice(P)),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 KI(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 Vl(t){if(t===null||Tn(t)||Ro(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 dx={name:"attention",resolveAll:QI,tokenize:XI};function QI(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=ja(f,[["enter",t[s][1],e],["exit",t[s][1],e]])),f=ja(f,[["enter",a,e],["enter",i,e],["exit",i,e],["enter",r,e]]),f=ja(f,Zp(e.parser.constructs.insideSpan.null,t.slice(s+1,n),e)),f=ja(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=ja(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 XI(t,e){const n=this.parser.constructs.attentionMarkers.null,s=this.previous,a=Vl(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=Vl(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 JI={name:"autolink",tokenize:ZI};function ZI(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 Rs(y)?(t.consume(y),i):y===64?n(y):f(y)}function i(y){return y===43||y===45||y===46||Ns(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||Ns(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):UI(y)?(t.consume(y),f):n(y)}function h(y){return Ns(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||Ns(y))&&s++<63){const w=y===45?b:m;return t.consume(y),w}return n(y)}}const ad={partial:!0,tokenize:eP};function eP(t,e,n){return s;function s(r){return tn(r)?un(t,a,"linePrefix")(r):a(r)}function a(r){return r===null||Mt(r)?e(r):n(r)}}const BN={continuation:{tokenize:nP},exit:sP,name:"blockQuote",tokenize:tP};function tP(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 tn(i)?(t.enter("blockQuotePrefixWhitespace"),t.consume(i),t.exit("blockQuotePrefixWhitespace"),t.exit("blockQuotePrefix"),e):(t.exit("blockQuotePrefix"),e(i))}}function nP(t,e,n){const s=this;return a;function a(i){return tn(i)?un(t,r,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i):r(i)}function r(i){return t.attempt(BN,e,n)(i)}}function sP(t){t.exit("blockQuote")}const FN={name:"characterEscape",tokenize:aP};function aP(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 WI(r)?(t.enter("characterEscapeValue"),t.consume(r),t.exit("characterEscapeValue"),t.exit("characterEscape"),e):n(r)}}const zN={name:"characterReference",tokenize:rP};function rP(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=Ns,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=HI,h):(t.enter("characterReferenceValue"),r=7,i=ux,h(m))}function h(m){if(m===59&&a){const b=t.exit("characterReferenceValue");return i===Ns&&!sy(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:oP},YS={concrete:!0,name:"codeFenced",tokenize:iP};function iP(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 P=s.events[s.events.length-1];return r=P&&P[1].type==="linePrefix"?P[2].sliceSerialize(P[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"),tn(E)?un(t,m,"whitespace")(E):m(E))}function m(E){return E===null||Mt(E)?(t.exit("codeFencedFence"),s.interrupt?e(E):t.check(VS,A,T)(E)):(t.enter("codeFencedFenceInfo"),t.enter("chunkString",{contentType:"string"}),b(E))}function b(E){return E===null||Mt(E)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),m(E)):tn(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||Mt(E)?m(E):(t.enter("codeFencedFenceMeta"),t.enter("chunkString",{contentType:"string"}),w(E))}function w(E){return E===null||Mt(E)?(t.exit("chunkString"),t.exit("codeFencedFenceMeta"),m(E)):E===96&&E===c?n(E):(t.consume(E),w)}function A(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&&tn(E)?un(t,j,"linePrefix",r+1)(E):j(E)}function j(E){return E===null||Mt(E)?t.check(VS,A,T)(E):(t.enter("codeFlowValue"),S(E))}function S(E){return E===null||Mt(E)?(t.exit("codeFlowValue"),j(E)):(t.consume(E),S)}function T(E){return t.exit("codeFenced"),e(E)}function D(E,P,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"),tn(L)?un(E,F,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):F(L)}function F(L){return L===c?(E.enter("codeFencedFenceSequence"),$(L)):O(L)}function $(L){return L===c?(_++,E.consume(L),$):_>=i?(E.exit("codeFencedFenceSequence"),tn(L)?un(E,H,"whitespace")(L):H(L)):O(L)}function H(L){return L===null||Mt(L)?(E.exit("codeFencedFence"),P(L)):O(L)}}}function oP(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 Jg={name:"codeIndented",tokenize:cP},lP={partial:!0,tokenize:uP};function cP(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):Mt(f)?t.attempt(lP,i,d)(f):(t.enter("codeFlowValue"),c(f))}function c(f){return f===null||Mt(f)?(t.exit("codeFlowValue"),i(f)):(t.consume(f),c)}function d(f){return t.exit("codeIndented"),e(f)}}function uP(t,e,n){const s=this;return a;function a(i){return s.parser.lazy[s.now().line]?n(i):Mt(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):Mt(i)?a(i):n(i)}}const dP={name:"codeText",previous:pP,resolve:fP,tokenize:hP};function fP(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 pP(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"}function hP(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)):Mt(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||Mt(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 mP{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&&pu(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),pu(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),pu(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);pu(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);pu(this.left,n.reverse())}}}function pu(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 $N(t){const e={};let n=-1,s,a,r,i,c,d,f;const h=new mP(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,gP(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 gP(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,A=0;const N=[A];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&&(A=b+1,N.push(A),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 bP={resolve:yP,tokenize:vP},xP={partial:!0,tokenize:wP};function yP(t){return $N(t),t}function vP(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):Mt(c)?t.check(xP,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 wP(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||Mt(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 UN(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"}),A(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||Mt(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 A(k){return!h&&(k===null||k===41||Tn(k))?(t.exit("chunkString"),t.exit(c),t.exit(i),t.exit(s),e(k)):h<f&&k===40?(t.consume(k),h++,A):k===41?(t.consume(k),h--,A):k===null||k===32||k===40||kp(k)?n(k):(t.consume(k),k===92?N:A)}function N(k){return k===40||k===41||k===92?(t.consume(k),A):A(k)}}function HN(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):Mt(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||Mt(y)||c++>999?(t.exit("chunkString"),h(y)):(t.consume(y),d||(d=!tn(y)),y===92?b:m)}function b(y){return y===91||y===92||y===93?(t.consume(y),c++,m):m(y)}}function WN(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):Mt(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||Mt(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 Lu(t,e){let n;return s;function s(a){return Mt(a)?(t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),n=!0,s):tn(a)?un(t,s,n?"linePrefix":"lineSuffix")(a):e(a)}}const kP={name:"definition",tokenize:CP},SP={partial:!0,tokenize:AP};function CP(t,e,n){const s=this;let a;return r;function r(y){return t.enter("definition"),i(y)}function i(y){return HN.call(s,t,c,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function c(y){return a=Ba(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 Tn(y)?Lu(t,f)(y):f(y)}function f(y){return UN(t,h,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function h(y){return t.attempt(SP,m,m)(y)}function m(y){return tn(y)?un(t,b,"whitespace")(y):b(y)}function b(y){return y===null||Mt(y)?(t.exit("definition"),s.parser.defined.push(a),e(y)):n(y)}}function AP(t,e,n){return s;function s(c){return Tn(c)?Lu(t,a)(c):n(c)}function a(c){return WN(t,r,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(c)}function r(c){return tn(c)?un(t,i,"whitespace")(c):i(c)}function i(c){return c===null||Mt(c)?e(c):n(c)}}const jP={name:"hardBreakEscape",tokenize:NP};function NP(t,e,n){return s;function s(r){return t.enter("hardBreakEscape"),t.consume(r),a}function a(r){return Mt(r)?(t.exit("hardBreakEscape"),e(r)):n(r)}}const TP={name:"headingAtx",resolve:_P,tokenize:EP};function _P(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 EP(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||Tn(h)?(t.exit("atxHeadingSequence"),c(h)):n(h)}function c(h){return h===35?(t.enter("atxHeadingSequence"),d(h)):h===null||Mt(h)?(t.exit("atxHeading"),e(h)):tn(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||Tn(h)?(t.exit("atxHeadingText"),c(h)):(t.consume(h),f)}}const MP=["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"],DP={concrete:!0,name:"htmlFlow",resolveTo:LP,tokenize:IP},RP={partial:!0,tokenize:BP},OP={partial:!0,tokenize:PP};function LP(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 IP(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,A):q===63?(t.consume(q),a=3,s.interrupt?e:B):Rs(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):Rs(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 me="CDATA[";return q===me.charCodeAt(c++)?(t.consume(q),c===me.length?s.interrupt?e:F:w):n(q)}function A(q){return Rs(q)?(t.consume(q),i=String.fromCharCode(q),N):n(q)}function N(q){if(q===null||q===47||q===62||Tn(q)){const me=q===47,ce=i.toLowerCase();return!me&&!r&&GS.includes(ce)?(a=1,s.interrupt?e(q):F(q)):MP.includes(i.toLowerCase())?(a=6,me?(t.consume(q),k):s.interrupt?e(q):F(q)):(a=7,s.interrupt&&!s.parser.lazy[s.now().line]?n(q):r?j(q):S(q))}return q===45||Ns(q)?(t.consume(q),i+=String.fromCharCode(q),N):n(q)}function k(q){return q===62?(t.consume(q),s.interrupt?e:F):n(q)}function j(q){return tn(q)?(t.consume(q),j):M(q)}function S(q){return q===47?(t.consume(q),M):q===58||q===95||Rs(q)?(t.consume(q),T):tn(q)?(t.consume(q),S):M(q)}function T(q){return q===45||q===46||q===58||q===95||Ns(q)?(t.consume(q),T):D(q)}function D(q){return q===61?(t.consume(q),E):tn(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,P):tn(q)?(t.consume(q),E):O(q)}function P(q){return q===d?(t.consume(q),d=null,_):q===null||Mt(q)?n(q):(t.consume(q),P)}function O(q){return q===null||q===34||q===39||q===47||q===60||q===61||q===62||q===96||Tn(q)?D(q):(t.consume(q),O)}function _(q){return q===47||q===62||tn(q)?S(q):n(q)}function M(q){return q===62?(t.consume(q),R):n(q)}function R(q){return q===null||Mt(q)?F(q):tn(q)?(t.consume(q),R):n(q)}function F(q){return q===45&&a===2?(t.consume(q),z):q===60&&a===1?(t.consume(q),W):q===62&&a===4?(t.consume(q),K):q===63&&a===3?(t.consume(q),B):q===93&&a===5?(t.consume(q),G):Mt(q)&&(a===6||a===7)?(t.exit("htmlFlowData"),t.check(RP,se,$)(q)):q===null||Mt(q)?(t.exit("htmlFlowData"),$(q)):(t.consume(q),F)}function $(q){return t.check(OP,H,se)(q)}function H(q){return t.enter("lineEnding"),t.consume(q),t.exit("lineEnding"),L}function L(q){return q===null||Mt(q)?$(q):(t.enter("htmlFlowData"),F(q))}function z(q){return q===45?(t.consume(q),B):F(q)}function W(q){return q===47?(t.consume(q),i="",V):F(q)}function V(q){if(q===62){const me=i.toLowerCase();return GS.includes(me)?(t.consume(q),K):F(q)}return Rs(q)&&i.length<8?(t.consume(q),i+=String.fromCharCode(q),V):F(q)}function G(q){return q===93?(t.consume(q),B):F(q)}function B(q){return q===62?(t.consume(q),K):q===45&&a===2?(t.consume(q),B):F(q)}function K(q){return q===null||Mt(q)?(t.exit("htmlFlowData"),se(q)):(t.consume(q),K)}function se(q){return t.exit("htmlFlow"),e(q)}}function PP(t,e,n){const s=this;return a;function a(i){return Mt(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 BP(t,e,n){return s;function s(a){return t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),t.attempt(ad,e,n)}}const FP={name:"htmlText",tokenize:zP};function zP(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):Rs(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):Rs(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):Mt(B)?(i=m,W(B)):(t.consume(B),m)}function b(B){return B===45?(t.consume(B),y):m(B)}function y(B){return B===62?z(B):B===45?b(B):m(B)}function w(B){const K="CDATA[";return B===K.charCodeAt(r++)?(t.consume(B),r===K.length?A:w):n(B)}function A(B){return B===null?n(B):B===93?(t.consume(B),N):Mt(B)?(i=A,W(B)):(t.consume(B),A)}function N(B){return B===93?(t.consume(B),k):A(B)}function k(B){return B===62?z(B):B===93?(t.consume(B),k):A(B)}function j(B){return B===null||B===62?z(B):Mt(B)?(i=j,W(B)):(t.consume(B),j)}function S(B){return B===null?n(B):B===63?(t.consume(B),T):Mt(B)?(i=S,W(B)):(t.consume(B),S)}function T(B){return B===62?z(B):S(B)}function D(B){return Rs(B)?(t.consume(B),E):n(B)}function E(B){return B===45||Ns(B)?(t.consume(B),E):P(B)}function P(B){return Mt(B)?(i=P,W(B)):tn(B)?(t.consume(B),P):z(B)}function O(B){return B===45||Ns(B)?(t.consume(B),O):B===47||B===62||Tn(B)?_(B):n(B)}function _(B){return B===47?(t.consume(B),z):B===58||B===95||Rs(B)?(t.consume(B),M):Mt(B)?(i=_,W(B)):tn(B)?(t.consume(B),_):z(B)}function M(B){return B===45||B===46||B===58||B===95||Ns(B)?(t.consume(B),M):R(B)}function R(B){return B===61?(t.consume(B),F):Mt(B)?(i=R,W(B)):tn(B)?(t.consume(B),R):_(B)}function F(B){return B===null||B===60||B===61||B===62||B===96?n(B):B===34||B===39?(t.consume(B),a=B,$):Mt(B)?(i=F,W(B)):tn(B)?(t.consume(B),F):(t.consume(B),H)}function $(B){return B===a?(t.consume(B),a=void 0,L):B===null?n(B):Mt(B)?(i=$,W(B)):(t.consume(B),$)}function H(B){return B===null||B===34||B===39||B===60||B===61||B===96?n(B):B===47||B===62||Tn(B)?_(B):(t.consume(B),H)}function L(B){return B===47||B===62||Tn(B)?_(B):n(B)}function z(B){return B===62?(t.consume(B),t.exit("htmlTextData"),t.exit("htmlText"),e):n(B)}function W(B){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(B),t.exit("lineEnding"),V}function V(B){return tn(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 ay={name:"labelEnd",resolveAll:WP,resolveTo:qP,tokenize:VP},$P={tokenize:YP},UP={tokenize:GP},HP={tokenize:KP};function WP(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 qP(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=ja(c,t.slice(r+1,r+s+3)),c=ja(c,[["enter",h,e]]),c=ja(c,Zp(e.parser.constructs.insideSpan.null,t.slice(r+s+4,i-3),e)),c=ja(c,[["exit",h,e],t[i-2],t[i-1],["exit",f,e]]),c=ja(c,t.slice(i+1)),c=ja(c,[["exit",d,e]]),ua(t,r,t.length,c),t}function VP(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(Ba(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($P,h,i?h:m)(b):b===91?t.attempt(UP,h,i?f:m)(b):i?h(b):m(b)}function f(b){return t.attempt(HP,h,m)(b)}function h(b){return e(b)}function m(b){return r._balanced=!0,n(b)}}function YP(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 Tn(m)?Lu(t,r)(m):r(m)}function r(m){return m===41?h(m):UN(t,i,c,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(m)}function i(m){return Tn(m)?Lu(t,d)(m):h(m)}function c(m){return n(m)}function d(m){return m===34||m===39||m===40?WN(t,f,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(m):h(m)}function f(m){return Tn(m)?Lu(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 GP(t,e,n){const s=this;return a;function a(c){return HN.call(s,t,r,i,"reference","referenceMarker","referenceString")(c)}function r(c){return s.parser.defined.includes(Ba(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)))?e(c):n(c)}function i(c){return n(c)}}function KP(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 QP={name:"labelStartImage",resolveAll:ay.resolveAll,tokenize:XP};function XP(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 JP={name:"labelStartLink",resolveAll:ay.resolveAll,tokenize:ZP};function ZP(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 Zg={name:"lineEnding",tokenize:eB};function eB(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:tB};function tB(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||Mt(f))?(t.exit("thematicBreak"),e(f)):n(f)}function d(f){return f===a?(t.consume(f),s++,d):(t.exit("thematicBreakSequence"),tn(f)?un(t,c,"whitespace")(f):c(f))}}const Hs={continuation:{tokenize:rB},exit:oB,name:"list",tokenize:aB},nB={partial:!0,tokenize:lB},sB={partial:!0,tokenize:iB};function aB(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:ux(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 ux(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(ad,s.interrupt?n:h,t.attempt(nB,b,m))}function h(y){return s.containerState.initialBlankLine=!0,r++,b(y)}function m(y){return tn(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 rB(t,e,n){const s=this;return s.containerState._closeFlow=void 0,t.check(ad,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||!tn(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(sB,e,i)(c))}function i(c){return s.containerState._closeFlow=!0,s.interrupt=void 0,un(t,t.attempt(Hs,e,n),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c)}}function iB(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 oB(t){t.exit(this.containerState.type)}function lB(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!tn(r)&&i&&i[1].type==="listItemPrefixWhitespace"?e(r):n(r)}}const KS={name:"setextUnderline",resolveTo:cB,tokenize:uB};function cB(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 uB(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"),tn(f)?un(t,d,"lineSuffix")(f):d(f))}function d(f){return f===null||Mt(f)?(t.exit("setextHeadingLine"),e(f)):n(f)}}const dB={tokenize:fB};function fB(t){const e=this,n=t.attempt(ad,s,t.attempt(this.parser.constructs.flowInitial,a,un(t,t.attempt(this.parser.constructs.flow,a,t.attempt(bP,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 pB={resolveAll:VN()},hB=qN("string"),mB=qN("text");function qN(t){return{resolveAll:VN(t==="text"?gB: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 VN(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 gB(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 bB={42:Hs,43:Hs,45:Hs,48:Hs,49:Hs,50:Hs,51:Hs,52:Hs,53:Hs,54:Hs,55:Hs,56:Hs,57:Hs,62:BN},xB={91:kP},yB={[-2]:Jg,[-1]:Jg,32:Jg},vB={35:TP,42:tp,45:[KS,tp],60:DP,61:KS,95:tp,96:YS,126:YS},wB={38:zN,92:FN},kB={[-5]:Zg,[-4]:Zg,[-3]:Zg,33:QP,38:zN,42:dx,60:[JI,FP],91:JP,92:[jP,FN],93:ay,95:dx,96:dP},SB={null:[dx,pB]},CB={null:[42,95]},AB={null:[]},jB=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:CB,contentInitial:xB,disable:AB,document:bB,flow:vB,flowInitial:yB,insideSpan:SB,string:wB,text:kB},Symbol.toStringTag,{value:"Module"}));function NB(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:P(D),check:P(E),consume:j,enter:S,exit:T,interrupt:P(E,{interrupt:!0})},f={code:null,containerState:{},defineSkip:A,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=ja(i,R),N(),i[i.length-1]!==null?[]:(O(e,0),f.events=Zp(r,f.events,f),f.events)}function b(R,F){return _B(y(R),F)}function y(R){return TB(i,R)}function w(){const{_bufferIndex:R,_index:F,line:$,column:H,offset:L}=s;return{_bufferIndex:R,_index:F,line:$,column:H,offset:L}}function A(R){a[R.line]=R.column,M()}function N(){let R;for(;s._index<i.length;){const F=i[s._index];if(typeof F=="string")for(R=s._index,s._bufferIndex<0&&(s._bufferIndex=0);s._index===R&&s._bufferIndex<F.length;)k(F.charCodeAt(s._bufferIndex));else k(F)}}function k(R){h=h(R)}function j(R){Mt(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,F){const $=F||{};return $.type=R,$.start=w(),f.events.push(["enter",$,f]),c.push($),$}function T(R){const F=c.pop();return F.end=w(),f.events.push(["exit",F,f]),F}function D(R,F){O(R,F.from)}function E(R,F){F.restore()}function P(R,F){return $;function $(H,L,z){let W,V,G,B;return Array.isArray(H)?se(H):"tokenize"in H?se([H]):K(H);function K(ee){return pe;function pe(Ne){const ye=Ne!==null&&ee[Ne],Me=Ne!==null&&ee.null,qe=[...Array.isArray(ye)?ye:ye?[ye]:[],...Array.isArray(Me)?Me:Me?[Me]:[]];return se(qe)(Ne)}}function se(ee){return W=ee,V=0,ee.length===0?z:q(ee[V])}function q(ee){return pe;function pe(Ne){return B=_(),G=ee,ee.partial||(f.currentConstruct=ee),ee.name&&f.parser.constructs.disable.null.includes(ee.name)?ce():ee.tokenize.call(F?Object.assign(Object.create(f),F):f,d,me,ce)(Ne)}}function me(ee){return R(G,B),L}function ce(ee){return B.restore(),++V<W.length?q(W[V]):z}}}function O(R,F){R.resolveAll&&!r.includes(R)&&r.push(R),R.resolve&&ua(f.events,F,f.events.length-F,R.resolve(f.events.slice(F),f)),R.resolveTo&&(f.events=R.resolveTo(f.events,f))}function _(){const R=w(),F=f.previous,$=f.currentConstruct,H=f.events.length,L=Array.from(c);return{from:H,restore:z};function z(){s=R,f.previous=F,f.currentConstruct=$,f.events.length=H,c=L,M()}}function M(){s.line in a&&s.column<2&&(s.column=a[s.line],s.offset+=a[s.line]-1)}}function TB(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 _B(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 EB(t){const s={constructs:IN([jB,...(t||{}).extensions||[]]),content:a(qI),defined:[],document:a(YI),flow:a(dB),lazy:{},string:a(hB),text:a(mB)};return s;function a(r){return i;function i(c){return NB(s,r,c)}}}function MB(t){for(;!$N(t););return t}const QS=/[\0\t\n\r]/g;function DB(){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 RB=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function OB(t){return t.replace(RB,LB)}function LB(t,e,n){if(e)return e;if(n.charCodeAt(0)===35){const a=n.charCodeAt(1),r=a===120||a===88;return PN(n.slice(r?2:1),r?16:10)}return sy(n)||t}const YN={}.hasOwnProperty;function IB(t,e,n){return e&&typeof e=="object"&&(n=e,e=void 0),PB(n)(MB(EB(n).document().write(DB()(t,e,!0))))}function PB(t){const e={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:r(Le),autolinkProtocol:_,autolinkEmail:_,atxHeading:r(Te),blockQuote:r(Me),characterEscape:_,characterReference:_,codeFenced:r(qe),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:r(qe,i),codeText:r(He,i),codeTextData:_,data:_,codeFlowValue:_,definition:r(X),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:r(ne),hardBreakEscape:r(We),hardBreakTrailing:r(We),htmlFlow:r(nt,i),htmlFlowData:_,htmlText:r(nt,i),htmlTextData:_,image:r(we),label:i,link:r(Le),listItem:r(de),listItemValue:b,listOrdered:r(ie,m),listUnordered:r(ie),paragraph:r(Ue),reference:q,referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:r(Te),strong:r(Ze),thematicBreak:r(fe)},exit:{atxHeading:d(),atxHeadingSequence:D,autolink:d(),autolinkEmail:ye,autolinkProtocol:Ne,blockQuote:d(),characterEscapeValue:M,characterReferenceMarkerHexadecimal:ce,characterReferenceMarkerNumeric:ce,characterReferenceValue:ee,characterReference:pe,codeFenced:d(N),codeFencedFence:A,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(F),hardBreakTrailing:d(F),htmlFlow:d($),htmlFlowData:M,htmlText:d(H),htmlTextData:M,image:d(W),label:G,labelText:V,lineEnding:R,link:d(z),listItem:d(),listOrdered:d(),listUnordered:d(),paragraph:d(),referenceString:me,resourceDestinationString:B,resourceTitleString:K,resource:se,setextHeading:d(O),setextHeadingLineSequence:P,setextHeadingText:E,strong:d(),thematicBreak:d()}};GN(e,(t||{}).mdastExtensions||[]);const n={};return s;function s(J){let ae={type:"root",children:[]};const Se={stack:[ae],tokenStack:[],config:e,enter:c,exit:f,buffer:i,resume:h,data:n},Z=[];let he=-1;for(;++he<J.length;)if(J[he][1].type==="listOrdered"||J[he][1].type==="listUnordered")if(J[he][0]==="enter")Z.push(he);else{const De=Z.pop();he=a(J,De,he)}for(he=-1;++he<J.length;){const De=e[J[he][0]];YN.call(De,J[he][1].type)&&De[J[he][1].type].call(Object.assign({sliceSerialize:J[he][2].sliceSerialize},Se),J[he][1])}if(Se.tokenStack.length>0){const De=Se.tokenStack[Se.tokenStack.length-1];(De[1]||XS).call(Se,void 0,De[0])}for(ae.position={start:Ti(J.length>0?J[0][1].start:{line:1,column:1,offset:0}),end:Ti(J.length>0?J[J.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(J,ae,Se){let Z=ae-1,he=-1,De=!1,ze,be,Pe,te;for(;++Z<=Se;){const ge=J[Z];switch(ge[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ge[0]==="enter"?he++:he--,te=void 0;break}case"lineEndingBlank":{ge[0]==="enter"&&(ze&&!te&&!he&&!Pe&&(Pe=Z),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(ze){let ve=Z;for(be=void 0;ve--;){const Fe=J[ve];if(Fe[1].type==="lineEnding"||Fe[1].type==="lineEndingBlank"){if(Fe[0]==="exit")continue;be&&(J[be][1].type="lineEndingBlank",De=!0),Fe[1].type="lineEnding",be=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&&(!be||Pe<be)&&(ze._spread=!0),ze.end=Object.assign({},be?J[be][1].start:ge[1].end),J.splice(be||Z,0,["exit",ze,ge[2]]),Z++,Se++}if(ge[1].type==="listItemPrefix"){const ve={type:"listItem",_spread:!1,start:Object.assign({},ge[1].start),end:void 0};ze=ve,J.splice(Z,0,["enter",ve,ge[2]]),Z++,Se++,Pe=void 0,te=!0}}}return J[ae][1]._spread=De,Se}function r(J,ae){return Se;function Se(Z){c.call(this,J(Z),Z),ae&&ae.call(this,Z)}}function i(){this.stack.push({type:"fragment",children:[]})}function c(J,ae,Se){this.stack[this.stack.length-1].children.push(J),this.stack.push(J),this.tokenStack.push([ae,Se||void 0]),J.position={start:Ti(ae.start),end:void 0}}function d(J){return ae;function ae(Se){J&&J.call(this,Se),f.call(this,Se)}}function f(J,ae){const Se=this.stack.pop(),Z=this.tokenStack.pop();if(Z)Z[0].type!==J.type&&(ae?ae.call(this,J,Z[0]):(Z[1]||XS).call(this,J,Z[0]));else throw new Error("Cannot close `"+J.type+"` ("+Ou({start:J.start,end:J.end})+"): it’s not open");Se.position.end=Ti(J.end)}function h(){return ny(this.stack.pop())}function m(){this.data.expectingFirstListItemValue=!0}function b(J){if(this.data.expectingFirstListItemValue){const ae=this.stack[this.stack.length-2];ae.start=Number.parseInt(this.sliceSerialize(J),10),this.data.expectingFirstListItemValue=void 0}}function y(){const J=this.resume(),ae=this.stack[this.stack.length-1];ae.lang=J}function w(){const J=this.resume(),ae=this.stack[this.stack.length-1];ae.meta=J}function A(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function N(){const J=this.resume(),ae=this.stack[this.stack.length-1];ae.value=J.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function k(){const J=this.resume(),ae=this.stack[this.stack.length-1];ae.value=J.replace(/(\r?\n|\r)$/g,"")}function j(J){const ae=this.resume(),Se=this.stack[this.stack.length-1];Se.label=ae,Se.identifier=Ba(this.sliceSerialize(J)).toLowerCase()}function S(){const J=this.resume(),ae=this.stack[this.stack.length-1];ae.title=J}function T(){const J=this.resume(),ae=this.stack[this.stack.length-1];ae.url=J}function D(J){const ae=this.stack[this.stack.length-1];if(!ae.depth){const Se=this.sliceSerialize(J).length;ae.depth=Se}}function E(){this.data.setextHeadingSlurpLineEnding=!0}function P(J){const ae=this.stack[this.stack.length-1];ae.depth=this.sliceSerialize(J).codePointAt(0)===61?1:2}function O(){this.data.setextHeadingSlurpLineEnding=void 0}function _(J){const Se=this.stack[this.stack.length-1].children;let Z=Se[Se.length-1];(!Z||Z.type!=="text")&&(Z=lt(),Z.position={start:Ti(J.start),end:void 0},Se.push(Z)),this.stack.push(Z)}function M(J){const ae=this.stack.pop();ae.value+=this.sliceSerialize(J),ae.position.end=Ti(J.end)}function R(J){const ae=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Se=ae.children[ae.children.length-1];Se.position.end=Ti(J.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&e.canContainEols.includes(ae.type)&&(_.call(this,J),M.call(this,J))}function F(){this.data.atHardBreak=!0}function $(){const J=this.resume(),ae=this.stack[this.stack.length-1];ae.value=J}function H(){const J=this.resume(),ae=this.stack[this.stack.length-1];ae.value=J}function L(){const J=this.resume(),ae=this.stack[this.stack.length-1];ae.value=J}function z(){const J=this.stack[this.stack.length-1];if(this.data.inReference){const ae=this.data.referenceType||"shortcut";J.type+="Reference",J.referenceType=ae,delete J.url,delete J.title}else delete J.identifier,delete J.label;this.data.referenceType=void 0}function W(){const J=this.stack[this.stack.length-1];if(this.data.inReference){const ae=this.data.referenceType||"shortcut";J.type+="Reference",J.referenceType=ae,delete J.url,delete J.title}else delete J.identifier,delete J.label;this.data.referenceType=void 0}function V(J){const ae=this.sliceSerialize(J),Se=this.stack[this.stack.length-2];Se.label=OB(ae),Se.identifier=Ba(ae).toLowerCase()}function G(){const J=this.stack[this.stack.length-1],ae=this.resume(),Se=this.stack[this.stack.length-1];if(this.data.inReference=!0,Se.type==="link"){const Z=J.children;Se.children=Z}else Se.alt=ae}function B(){const J=this.resume(),ae=this.stack[this.stack.length-1];ae.url=J}function K(){const J=this.resume(),ae=this.stack[this.stack.length-1];ae.title=J}function se(){this.data.inReference=void 0}function q(){this.data.referenceType="collapsed"}function me(J){const ae=this.resume(),Se=this.stack[this.stack.length-1];Se.label=ae,Se.identifier=Ba(this.sliceSerialize(J)).toLowerCase(),this.data.referenceType="full"}function ce(J){this.data.characterReferenceType=J.type}function ee(J){const ae=this.sliceSerialize(J),Se=this.data.characterReferenceType;let Z;Se?(Z=PN(ae,Se==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Z=sy(ae);const he=this.stack[this.stack.length-1];he.value+=Z}function pe(J){const ae=this.stack.pop();ae.position.end=Ti(J.end)}function Ne(J){M.call(this,J);const ae=this.stack[this.stack.length-1];ae.url=this.sliceSerialize(J)}function ye(J){M.call(this,J);const ae=this.stack[this.stack.length-1];ae.url="mailto:"+this.sliceSerialize(J)}function Me(){return{type:"blockquote",children:[]}}function qe(){return{type:"code",lang:null,meta:null,value:""}}function He(){return{type:"inlineCode",value:""}}function X(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ne(){return{type:"emphasis",children:[]}}function Te(){return{type:"heading",depth:0,children:[]}}function We(){return{type:"break"}}function nt(){return{type:"html",value:""}}function we(){return{type:"image",title:null,url:"",alt:null}}function Le(){return{type:"link",title:null,url:"",children:[]}}function ie(J){return{type:"list",ordered:J.type==="listOrdered",start:null,spread:J._spread,children:[]}}function de(J){return{type:"listItem",spread:J._spread,checked:null,children:[]}}function Ue(){return{type:"paragraph",children:[]}}function Ze(){return{type:"strong",children:[]}}function lt(){return{type:"text",value:""}}function fe(){return{type:"thematicBreak"}}}function Ti(t){return{line:t.line,column:t.column,offset:t.offset}}function GN(t,e){let n=-1;for(;++n<e.length;){const s=e[n];Array.isArray(s)?GN(t,s):BB(t,s)}}function BB(t,e){let n;for(n in e)if(YN.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+"` ("+Ou({start:t.start,end:t.end})+"): a different token (`"+e.type+"`, "+Ou({start:e.start,end:e.end})+") is open"):new Error("Cannot close document, a token (`"+e.type+"`, "+Ou({start:e.start,end:e.end})+") is still open")}function FB(t){const e=this;e.parser=n;function n(s){return IB(s,{...e.data("settings"),...t,extensions:e.data("micromarkExtensions")||[],mdastExtensions:e.data("fromMarkdownExtensions")||[]})}}function zB(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 $B(t,e){const n={type:"element",tagName:"br",properties:{},children:[]};return t.patch(e,n),[t.applyData(e,n),{type:"text",value:`
51
+ `}]}function UB(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 HB(t,e){const n={type:"element",tagName:"del",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function WB(t,e){const n={type:"element",tagName:"em",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function qB(t,e){const n=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",s=String(e.identifier).toUpperCase(),a=ac(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 VB(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 YB(t,e){if(t.options.allowDangerousHtml){const n={type:"raw",value:e.value};return t.patch(e,n),t.applyData(e,n)}}function KN(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 GB(t,e){const n=String(e.identifier).toUpperCase(),s=t.definitionById.get(n);if(!s)return KN(t,e);const a={src:ac(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 KB(t,e){const n={src:ac(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 QB(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 XB(t,e){const n=String(e.identifier).toUpperCase(),s=t.definitionById.get(n);if(!s)return KN(t,e);const a={href:ac(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 JB(t,e){const n={href:ac(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 ZB(t,e,n){const s=t.all(e),a=n?eF(n):QN(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 eF(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=QN(n[s])}return e}function QN(t){const e=t.spread;return e??t.children.length>1}function tF(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 nF(t,e){const n={type:"element",tagName:"p",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function sF(t,e){const n={type:"root",children:t.wrap(t.all(e))};return t.patch(e,n),t.applyData(e,n)}function aF(t,e){const n={type:"element",tagName:"strong",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function rF(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=Jx(e.children[1]),d=_N(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 iF(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 oF(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 lF(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 cF(t,e){const n={type:"text",value:lF(String(e.value))};return t.patch(e,n),t.applyData(e,n)}function uF(t,e){const n={type:"element",tagName:"hr",properties:{},children:[]};return t.patch(e,n),t.applyData(e,n)}const dF={blockquote:zB,break:$B,code:UB,delete:HB,emphasis:WB,footnoteReference:qB,heading:VB,html:YB,imageReference:GB,image:KB,inlineCode:QB,linkReference:XB,link:JB,listItem:ZB,list:tF,paragraph:nF,root:sF,strong:aF,table:rF,tableCell:oF,tableRow:iF,text:cF,thematicBreak:uF,toml:Of,yaml:Of,definition:Of,footnoteDefinition:Of};function Of(){}const XN=-1,eh=0,Iu=1,Sp=2,ry=3,iy=4,oy=5,ly=6,JN=7,ZN=8,tC=typeof self=="object"?self:globalThis,fF=(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 XN:return n(i,a);case Iu:{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 ry:return n(new Date(i),a);case iy:{const{source:c,flags:d}=i;return n(new RegExp(c,d),a)}case oy:{const c=n(new Map,a);for(const[d,f]of i)c.set(s(d),s(f));return c}case ly:{const c=n(new Set,a);for(const d of i)c.add(s(d));return c}case JN:{const{name:c,message:d}=i;return n(new tC[c](d),a)}case ZN: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=>fF(new Map,t)(0),Tl="",{toString:pF}={},{keys:hF}=Object,hu=t=>{const e=typeof t;if(e!=="object"||!t)return[eh,e];const n=pF.call(t).slice(8,-1);switch(n){case"Array":return[Iu,Tl];case"Object":return[Sp,Tl];case"Date":return[ry,Tl];case"RegExp":return[iy,Tl];case"Map":return[oy,Tl];case"Set":return[ly,Tl];case"DataView":return[Iu,n]}return n.includes("Array")?[Iu,n]:n.includes("Error")?[JN,n]:[Sp,n]},Lf=([t,e])=>t===eh&&(e==="function"||e==="symbol"),mF=(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]=hu(i);switch(c){case eh:{let h=i;switch(d){case"bigint":c=ZN,h=i.toString();break;case"function":case"symbol":if(t)throw new TypeError("unable to serialize "+d);h=null;break;case"undefined":return a([XN],i)}return a([c,h],i)}case Iu:{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 hF(i))(t||!Lf(hu(i[b])))&&h.push([r(b),r(i[b])]);return m}case ry:return a([c,i.toISOString()],i);case iy:{const{source:h,flags:m}=i;return a([c,{source:h,flags:m}],i)}case oy:{const h=[],m=a([c,h],i);for(const[b,y]of i)(t||!(Lf(hu(b))||Lf(hu(y))))&&h.push([r(b),r(y)]);return m}case ly:{const h=[],m=a([c,h],i);for(const b of i)(t||!Lf(hu(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 mF(!(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 gF(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 bF(t,e){return"Back to reference "+(t+1)+(e>1?"-"+e:"")}function xF(t){const e=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",n=t.options.footnoteBackContent||gF,s=t.options.footnoteBackLabel||bF,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=ac(m.toLowerCase());let y=0;const w=[],A=t.footnoteCounts.get(m);for(;A!==void 0&&++y<=A;){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 kF;if(typeof t=="function")return nh(t);if(typeof t=="object")return Array.isArray(t)?yF(t):vF(t);if(typeof t=="string")return wF(t);throw new Error("Expected function, string, or object as test")});function yF(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 vF(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 wF(t){return nh(e);function e(n){return n&&n.type===t}}function nh(t){return e;function e(n,s,a){return!!(SF(n)&&t.call(this,n,typeof s=="number"?s:void 0,a||void 0))}}function kF(){return!0}function SF(t){return t!==null&&typeof t=="object"&&"type"in t}const e1=[],CF=!0,fx=!1,AF="skip";function t1(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=e1,w,A,N;if((!e||r(d,f,h[h.length-1]||void 0))&&(y=jF(n(d,h)),y[0]===fx))return y;if("children"in d&&d.children){const k=d;if(k.children&&y[0]!==AF)for(A=(s?k.children.length:-1)+i,N=h.concat(k);A>-1&&A<k.children.length;){const j=k.children[A];if(w=c(j,A,N)(),w[0]===fx)return w;A=typeof w[1]=="number"?w[1]:A+i}}return y}}}function jF(t){return Array.isArray(t)?t:typeof t=="number"?[CF,t]:t==null?e1:[t]}function cy(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),t1(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 px={}.hasOwnProperty,NF={};function TF(t,e){const n=e||NF,s=new Map,a=new Map,r=new Map,i={...dF,...n.handlers},c={all:f,applyData:EF,definitionById:s,footnoteById:a,footnoteCounts:r,footnoteOrder:[],handlers:i,one:d,options:n,patch:_F,wrap:DF};return cy(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(px.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:A,...N}=h,k=Cp(N);return k.children=c.all(h),k}return Cp(h)}return(c.options.unknownHandler||MF)(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 A=w.children[0];A&&A.type==="text"&&(A.value=aC(A.value))}Array.isArray(w)?m.push(...w):m.push(w)}}}return m}}function _F(t,e){t.position&&(e.position=bI(t))}function EF(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 MF(t,e){const n=e.data||{},s="value"in e&&!(px.call(n,"hProperties")||px.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 DF(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=TF(t,e),s=n.one(t,void 0),a=xF(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 RF(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 eb,oC;function OF(){if(oC)return eb;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 eb=function d(){var f,h,m,b,y,w,A=arguments[0],N=1,k=arguments.length,j=!1;for(typeof A=="boolean"&&(j=A,A=arguments[1]||{},N=2),(A==null||typeof A!="object"&&typeof A!="function")&&(A={});N<k;++N)if(f=arguments[N],f!=null)for(h in f)m=c(A,h),b=c(f,h),A!==b&&(j&&b&&(r(b)||(y=a(b)))?(y?(y=!1,w=m&&a(m)?m:[]):w=m&&r(m)?m:{},i(A,{name:h,newValue:d(j,w,b)})):typeof b<"u"&&i(A,{name:h,newValue:b}));return A},eb}var LF=OF();const tb=Zu(LF);function hx(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 IF(){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?PF(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 PF(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:BF,dirname:FF,extname:zF,join:$F,sep:"/"};function BF(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');rd(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 FF(t){if(rd(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 zF(t){rd(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 $F(...t){let e=-1,n;for(;++e<t.length;)rd(t[e]),t[e]&&(n=n===void 0?t[e]:n+"/"+t[e]);return n===void 0?".":UF(n)}function UF(t){rd(t);const e=t.codePointAt(0)===47;let n=HF(t,!e);return n.length===0&&!e&&(n="."),n.length>0&&t.codePointAt(t.length-1)===47&&(n+="/"),e?"/"+n:n}function HF(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 rd(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}const WF={cwd:qF};function qF(){return"/"}function mx(t){return!!(t!==null&&typeof t=="object"&&"href"in t&&t.href&&"protocol"in t&&t.protocol&&t.auth===void 0)}function VF(t){if(typeof t=="string")t=new URL(t);else if(!mx(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 YF(t)}function YF(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 nb=["history","path","basename","stem","extname","dirname"];class n1{constructor(e){let n;e?mx(e)?n={path:e}:typeof e=="string"||GF(e)?n={value:e}:n=e:n={},this.cwd="cwd"in n?"":WF.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let s=-1;for(;++s<nb.length;){const r=nb[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)nb.includes(a)||(this[a]=n[a])}get basename(){return typeof this.path=="string"?Xa.basename(this.path):void 0}set basename(e){ab(e,"basename"),sb(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(sb(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){mx(e)&&(e=VF(e)),ab(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){ab(e,"stem"),sb(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 Ts(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 sb(t,e){if(t&&t.includes(Xa.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+Xa.sep+"`")}function ab(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 GF(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const KF=(function(t){const s=this.constructor.prototype,a=s[t],r=function(){return a.apply(r,arguments)};return Object.setPrototypeOf(r,s),r}),QF={}.hasOwnProperty;class uy extends KF{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=IF()}copy(){const e=new uy;let n=-1;for(;++n<this.attachers.length;){const s=this.attachers[n];e.use(...s)}return e.data(tb(!0,{},this.namespace)),e}data(e,n){return typeof e=="string"?arguments.length===2?(ob("data",this.frozen),this.namespace[e]=n,this):QF.call(this.namespace,e)&&this.namespace[e]||void 0:e?(ob("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 rb("parse",s),s(String(n),n)}process(e,n){const s=this;return this.freeze(),rb("process",this.parser||this.Parser),ib("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);ZF(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(),rb("processSync",this.parser||this.Parser),ib("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 ib("stringify",a),cC(e),a(e,s)}use(e,...n){const s=this.attachers,a=this.namespace;if(ob("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=tb(!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 A=s[b][1];hx(A)&&hx(y)&&(y=tb(!0,A,y)),s[b]=[f,y,...w]}}}}const XF=new uy().freeze();function rb(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `parser`")}function ib(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `compiler`")}function ob(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(!hx(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 JF(t)?t:new n1(t)}function JF(t){return!!(t&&typeof t=="object"&&"message"in t&&"messages"in t)}function ZF(t){return typeof t=="string"||e8(t)}function e8(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const t8="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",dC=[],fC={allowDangerousHtml:!0},n8=/^(https?|ircs?|mailto|xmpp)$/i,s8=[{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=a8(t),n=r8(t);return i8(e.runSync(e.parse(n),n),t)}function a8(t){const e=t.rehypePlugins||dC,n=t.remarkPlugins||dC,s=t.remarkRehypeOptions?{...t.remarkRehypeOptions,...fC}:fC;return XF().use(FB).use(n).use(RF,s).use(e)}function r8(t){const e=t.children||"",n=new n1;return typeof e=="string"&&(n.value=e),n}function i8(t,e){const n=e.allowedElements,s=e.allowElement,a=e.components,r=e.disallowedElements,i=e.skipHtml,c=e.unwrapDisallowed,d=e.urlTransform||o8;for(const h of s8)Object.hasOwn(e,h.from)&&(""+h.from+(h.to?"use `"+h.to+"` instead":"remove it")+t8+h.id,void 0);return cy(t,f),kI(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 Xg)if(Object.hasOwn(Xg,y)&&Object.hasOwn(h.properties,y)){const w=h.properties[y],A=Xg[y];(A===null||A.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 o8(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||n8.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 l8(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function c8(t,e,n){const a=th((n||{}).ignore||[]),r=u8(e);let i=-1;for(;++i<r.length;)t1(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 u8(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([d8(a[0]),f8(a[1])])}return e}function d8(t){return typeof t=="string"?new RegExp(l8(t),"g"):t}function f8(t){return typeof t=="function"?t:function(){return t}}const lb="phrasing",cb=["autolink","link","image","label"];function p8(){return{transforms:[v8],enter:{literalAutolink:m8,literalAutolinkEmail:ub,literalAutolinkHttp:ub,literalAutolinkWww:ub},exit:{literalAutolink:y8,literalAutolinkEmail:x8,literalAutolinkHttp:g8,literalAutolinkWww:b8}}}function h8(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:lb,notInConstruct:cb},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:lb,notInConstruct:cb},{character:":",before:"[ps]",after:"\\/",inConstruct:lb,notInConstruct:cb}]}}function m8(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function ub(t){this.config.enter.autolinkProtocol.call(this,t)}function g8(t){this.config.exit.autolinkProtocol.call(this,t)}function b8(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 x8(t){this.config.exit.autolinkEmail.call(this,t)}function y8(t){this.exit(t)}function v8(t){c8(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,w8],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),k8]],{ignore:["link","linkReference"]})}function w8(t,e,n,s,a){let r="";if(!s1(a)||(/^w/i.test(e)&&(n=e+n,e="",r="http://"),!S8(n)))return!1;const i=C8(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 k8(t,e,n,s){return!s1(s,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+e+"@"+n,children:[{type:"text",value:e+"@"+n}]}}function S8(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 C8(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 s1(t,e){const n=t.input.charCodeAt(t.index-1);return(t.index===0||Ro(n)||Jp(n))&&(!e||n!==47)}a1.peek=R8;function A8(){this.buffer()}function j8(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function N8(){this.buffer()}function T8(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function _8(t){const e=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ba(this.sliceSerialize(t)).toLowerCase(),n.label=e}function E8(t){this.exit(t)}function M8(t){const e=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ba(this.sliceSerialize(t)).toLowerCase(),n.label=e}function D8(t){this.exit(t)}function R8(){return"["}function a1(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 O8(){return{enter:{gfmFootnoteCallString:A8,gfmFootnoteCall:j8,gfmFootnoteDefinitionLabelString:N8,gfmFootnoteDefinition:T8},exit:{gfmFootnoteCallString:_8,gfmFootnoteCall:E8,gfmFootnoteDefinitionLabelString:M8,gfmFootnoteDefinition:D8}}}function L8(t){let e=!1;return t&&t.firstLineBlank&&(e=!0),{handlers:{footnoteDefinition:n,footnoteReference:a1},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?r1:I8))),f(),d}}function I8(t,e,n){return e===0?t:r1(t,e,n)}function r1(t,e,n){return(n?"":" ")+t}const P8=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];i1.peek=U8;function B8(){return{canContainEols:["delete"],enter:{strikethrough:z8},exit:{strikethrough:$8}}}function F8(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:P8}],handlers:{delete:i1}}}function z8(t){this.enter({type:"delete",children:[]},t)}function $8(t){this.exit(t)}function i1(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 U8(){return"~"}function H8(t){return t.length}function W8(t,e){const n=e||{},s=(n.align||[]).concat(),a=n.stringLength||H8,r=[],i=[],c=[],d=[];let f=0,h=-1;for(;++h<t.length;){const A=[],N=[];let k=-1;for(t[h].length>f&&(f=t[h].length);++k<t[h].length;){const j=q8(t[h][k]);if(n.alignDelimiters!==!1){const S=a(j);N[k]=S,(d[k]===void 0||S>d[k])&&(d[k]=S)}A.push(j)}i[h]=A,c[h]=N}let m=-1;if(typeof s=="object"&&"length"in s)for(;++m<f;)r[m]=hC(s[m]);else{const A=hC(s);for(;++m<f;)r[m]=A}m=-1;const b=[],y=[];for(;++m<f;){const A=r[m];let N="",k="";A===99?(N=":",k=":"):A===108?N=":":A===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 A=i[h],N=c[h];m=-1;const k=[];for(;++m<f;){const j=A[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 q8(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 V8(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()),Y8);return a(),i}function Y8(t,e,n){return">"+(n?"":" ")+t}function G8(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
+ `&&G8(n.stack,n.unsafe[a]))return/[ \t]/.test(s.before)?"":" ";return`\\
64
+ `}function K8(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 Q8(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 X8(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 J8(t,e,n,s){const a=X8(n),r=t.value||"",i=a==="`"?"GraveAccent":"Tilde";if(Q8(t,n)){const m=n.enter("codeIndented"),b=n.indentLines(r,Z8);return m(),b}const c=n.createTracker(s),d=a.repeat(Math.max(K8(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 Z8(t,e,n){return(n?"":" ")+t}function dy(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 e9(t,e,n,s){const a=dy(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 t9(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 Ku(t){return"&#x"+t.toString(16).toUpperCase()+";"}function Ap(t,e,n){const s=Vl(t),a=Vl(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}}o1.peek=n9;function o1(t,e,n,s){const a=t9(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=Ku(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)+Ku(m));const y=i.move(a);return r(),n.attentionEncodeSurroundingInfo={after:b.outside,before:h.outside},c+d+y}function n9(t,e,n){return n.options.emphasis||"*"}function s9(t,e){let n=!1;return cy(t,function(s){if("value"in s&&/\r?\n|\r/.test(s.value)||s.type==="break")return n=!0,fx}),!!((!t.depth||t.depth<3)&&ny(t)&&(e.options.setext||n))}function a9(t,e,n,s){const a=Math.max(Math.min(6,t.depth||1),1),r=n.createTracker(s);if(s9(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=Ku(f.charCodeAt(0))+f.slice(1)),f=f?i+" "+f:i,n.options.closeAtx&&(f+=" "+i),d(),c(),f}l1.peek=r9;function l1(t){return t.value||""}function r9(){return"<"}c1.peek=i9;function c1(t,e,n,s){const a=dy(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 i9(){return"!"}u1.peek=o9;function u1(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 o9(){return"!"}d1.peek=l9;function d1(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 l9(){return"`"}function f1(t,e){const n=ny(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))}p1.peek=c9;function p1(t,e,n,s){const a=dy(n),r=a==='"'?"Quote":"Apostrophe",i=n.createTracker(s);let c,d;if(f1(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 c9(t,e,n){return f1(t,n)?"<":"["}h1.peek=u9;function h1(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 u9(){return"["}function fy(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 d9(t){const e=fy(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 f9(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 m1(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 p9(t,e,n,s){const a=n.enter("list"),r=n.bulletCurrent;let i=t.ordered?f9(n):fy(n);const c=t.ordered?i==="."?")":".":d9(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),m1(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 h9(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 m9(t,e,n,s){const a=h9(n);let r=n.bulletCurrent||fy(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 g9(t,e,n,s){const a=n.enter("paragraph"),r=n.enter("phrasing"),i=n.containerPhrasing(t,s);return r(),a(),i}const b9=th(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function x9(t,e,n,s){return(t.children.some(function(i){return b9(i)})?n.containerPhrasing:n.containerFlow).call(n,t,s)}function y9(t){const e=t.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}g1.peek=v9;function g1(t,e,n,s){const a=y9(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=Ku(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)+Ku(m));const y=i.move(a+a);return r(),n.attentionEncodeSurroundingInfo={after:b.outside,before:h.outside},c+d+y}function v9(t,e,n){return n.options.strong||"*"}function w9(t,e,n,s){return n.safe(t.value,s)}function k9(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 S9(t,e,n){const s=(m1(n)+(n.options.ruleSpaces?" ":"")).repeat(k9(n));return n.options.ruleSpaces?s.slice(0,-1):s}const b1={blockquote:V8,break:gC,code:J8,definition:e9,emphasis:o1,hardBreak:gC,heading:a9,html:l1,image:c1,imageReference:u1,inlineCode:d1,link:p1,linkReference:h1,list:p9,listItem:m9,paragraph:g9,root:x9,strong:g1,text:w9,thematicBreak:S9};function C9(){return{enter:{table:A9,tableData:bC,tableHeader:bC,tableRow:N9},exit:{codeText:T9,table:j9,tableData:db,tableHeader:db,tableRow:db}}}function A9(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 j9(t){this.exit(t),this.data.inTable=void 0}function N9(t){this.enter({type:"tableRow",children:[]},t)}function db(t){this.exit(t)}function bC(t){this.enter({type:"tableCell",children:[]},t)}function T9(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,_9));const n=this.stack[this.stack.length-1];n.type,n.value=e,this.exit(t)}function _9(t,e){return e==="|"?e:t}function E9(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,A,N){return f(h(y,A,N),y.align)}function c(y,w,A,N){const k=m(y,A,N),j=f([k]);return j.slice(0,j.indexOf(`
75
+ `))}function d(y,w,A,N){const k=A.enter("tableCell"),j=A.enter("phrasing"),S=A.containerPhrasing(y,{...N,before:r,after:r});return j(),k(),S}function f(y,w){return W8(y,{align:w,alignDelimiters:s,padding:n,stringLength:a})}function h(y,w,A){const N=y.children;let k=-1;const j=[],S=w.enter("table");for(;++k<N.length;)j[k]=m(N[k],w,A);return S(),j}function m(y,w,A){const N=y.children;let k=-1;const j=[],S=w.enter("tableRow");for(;++k<N.length;)j[k]=d(N[k],y,w,A);return S(),j}function b(y,w,A){let N=b1.inlineCode(y,w,A);return A.stack.includes("tableCell")&&(N=N.replace(/\|/g,"\\$&")),N}}function M9(){return{exit:{taskListCheckValueChecked:xC,taskListCheckValueUnchecked:xC,paragraph:R9}}}function D9(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:O9}}}function xC(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function R9(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 O9(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=b1.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 L9(){return[p8(),O8(),B8(),C9(),M9()]}function I9(t){return{extensions:[h8(),L8(t),F8(),E9(t),D9()]}}const P9={tokenize:H9,partial:!0},x1={tokenize:W9,partial:!0},y1={tokenize:q9,partial:!0},v1={tokenize:V9,partial:!0},B9={tokenize:Y9,partial:!0},w1={name:"wwwAutolink",tokenize:$9,previous:S1},k1={name:"protocolAutolink",tokenize:U9,previous:C1},Yr={name:"emailAutolink",tokenize:z9,previous:A1},hr={};function F9(){return{text:hr}}let xo=48;for(;xo<123;)hr[xo]=Yr,xo++,xo===58?xo=65:xo===91&&(xo=97);hr[43]=Yr;hr[45]=Yr;hr[46]=Yr;hr[95]=Yr;hr[72]=[Yr,k1];hr[104]=[Yr,k1];hr[87]=[Yr,w1];hr[119]=[Yr,w1];function z9(t,e,n){const s=this;let a,r;return i;function i(m){return!gx(m)||!A1.call(s,s.previous)||py(s.events)?n(m):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),c(m))}function c(m){return gx(m)?(t.consume(m),c):m===64?(t.consume(m),d):n(m)}function d(m){return m===46?t.check(B9,h,f)(m):m===45||m===95||Ns(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&&Rs(s.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(m)):n(m)}}function $9(t,e,n){const s=this;return a;function a(i){return i!==87&&i!==119||!S1.call(s,s.previous)||py(s.events)?n(i):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(P9,t.attempt(x1,t.attempt(y1,r),n),n)(i))}function r(i){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(i)}}function U9(t,e,n){const s=this;let a="",r=!1;return i;function i(m){return(m===72||m===104)&&C1.call(s,s.previous)&&!py(s.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),a+=String.fromCodePoint(m),t.consume(m),c):n(m)}function c(m){if(Rs(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)||Tn(m)||Ro(m)||Jp(m)?n(m):t.attempt(x1,t.attempt(y1,h),n)(m)}function h(m){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(m)}}function H9(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 W9(t,e,n){let s,a,r;return i;function i(f){return f===46||f===95?t.check(v1,d,c)(f):f===null||Tn(f)||Ro(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 q9(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(v1,e,r)(i):i===null||Tn(i)||Ro(i)?e(i):(t.consume(i),a)}function r(i){return i===41&&s++,t.consume(i),a}}function V9(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||Tn(c)||Ro(c)?e(c):n(c)}function a(c){return c===null||c===40||c===91||Tn(c)||Ro(c)?e(c):s(c)}function r(c){return Rs(c)?i(c):n(c)}function i(c){return c===59?(t.consume(c),s):Rs(c)?(t.consume(c),i):n(c)}}function Y9(t,e,n){return s;function s(r){return t.consume(r),a}function a(r){return Ns(r)?n(r):e(r)}}function S1(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||Tn(t)}function C1(t){return!Rs(t)}function A1(t){return!(t===47||gx(t))}function gx(t){return t===43||t===45||t===46||t===95||Ns(t)}function py(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 G9={tokenize:n4,partial:!0};function K9(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:Z9,continuation:{tokenize:e4},exit:t4}},text:{91:{name:"gfmFootnoteCall",tokenize:J9},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Q9,resolveTo:X9}}}}function Q9(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=Ba(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 X9(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 J9(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||Tn(m))return n(m);if(m===93){t.exit("chunkString");const b=t.exit("gfmFootnoteCallString");return a.includes(Ba(s.sliceSerialize(b)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(m),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):n(m)}return Tn(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 Z9(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||Tn(w))return n(w);if(w===93){t.exit("chunkString");const A=t.exit("gfmFootnoteDefinitionLabelString");return r=Ba(s.sliceSerialize(A)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(w),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),b}return Tn(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 e4(t,e,n){return t.check(ad,e,t.attempt(G9,e,n))}function t4(t){t.exit("gfmFootnoteDefinition")}function n4(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 s4(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 A=Vl(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=Vl(w);return N._open=!k||k===2&&!!A,N._close=!A||A===2&&!!k,c(w)}}}class a4{constructor(){this.map=[]}add(e,n,s){r4(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 r4(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 i4(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 o4(){return{flow:{null:{name:"table",tokenize:l4,resolveAll:c4}}}}function l4(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 H=s.events[R][1].type;if(H==="lineEnding"||H==="linePrefix")R--;else break}const F=R>-1?s.events[R][1].type:null,$=F==="tableHead"||F==="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):Mt(M)?r>1?(r=0,s.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(M),t.exit("lineEnding"),y):n(M):tn(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||Tn(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,tn(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"),A):D(M)}function A(M){return tn(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||Mt(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 tn(M)?un(t,T,"whitespace")(M):T(M)}function T(M){return M===124?w(M):M===null||Mt(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"),P(M)}function P(M){return M===124?(t.enter("tableCellDivider"),t.consume(M),t.exit("tableCellDivider"),P):M===null||Mt(M)?(t.exit("tableRow"),e(M)):tn(M)?un(t,P,"whitespace")(M):(t.enter("data"),O(M))}function O(M){return M===null||M===124||Tn(M)?(t.exit("data"),P(M)):(t.consume(M),M===92?_:O)}function _(M){return M===92||M===124?(t.consume(M),O):O(M)}}function c4(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 a4;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=i4(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({},Ll(e.events,n[0])),t.add(n[0],0,[["exit",r,e]]));const d=Ll(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=Ll(e.events,n[2]),h=Ll(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,A=n[3]-n[2]-1;t.add(w,A,[])}}t.add(n[3]+1,0,[["exit",m,e]])}return a!==void 0&&(r.end=Object.assign({},Ll(e.events,a)),t.add(a,0,[["exit",r,e]]),r=void 0),r}function yC(t,e,n,s,a){const r=[],i=Ll(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 Ll(t,e){const n=t[e],s=n[0]==="enter"?"start":"end";return n[1][s]}const u4={name:"tasklistCheck",tokenize:f4};function d4(){return{text:{91:u4}}}function f4(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 Tn(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 Mt(d)?e(d):tn(d)?t.check({tokenize:p4},e,n)(d):n(d)}}function p4(t,e,n){return un(t,s,"whitespace");function s(a){return a===null?n(a):e(a)}}function h4(t){return IN([F9(),K9(),s4(t),o4(),d4()])}const m4={};function zr(t){const e=this,n=t||m4,s=e.data(),a=s.micromarkExtensions||(s.micromarkExtensions=[]),r=s.fromMarkdownExtensions||(s.fromMarkdownExtensions=[]),i=s.toMarkdownExtensions||(s.toMarkdownExtensions=[]);a.push(h4(n)),r.push(L9()),i.push(I9(n))}var fb={exports:{}},vC;function g4(){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 P in S)S.hasOwnProperty(P)&&(D[P]=j(S[P],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],P={};for(var O in E)if(E.hasOwnProperty(O)){if(O==S)for(var _ in T)T.hasOwnProperty(_)&&(P[_]=T[_]);T.hasOwnProperty(O)||(P[O]=E[O])}var M=D[j];return D[j]=P,c.languages.DFS(c.languages,function(R,F){F===M&&R!=j&&(this[R]=P)}),P},DFS:function j(S,T,D,E){E=E||{};var P=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[P(_)]?(E[P(_)]=!0,j(_,T,null,E)):M==="Array"&&!E[P(_)]&&(E[P(_)]=!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,P;P=D.elements[E++];)c.highlightElement(P,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 P=j.parentElement;P&&P.nodeName.toLowerCase()==="pre"&&c.util.setLanguage(P,D);var O=j.textContent,_={element:j,language:D,grammar:E,code:O};function M(F){_.highlightedCode=F,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",_),P=_.element.parentElement,P&&P.nodeName.toLowerCase()==="pre"&&!P.hasAttribute("tabindex")&&P.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(F){M(F.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},P=S.alias;P&&(Array.isArray(P)?Array.prototype.push.apply(E.classes,P):E.classes.push(P)),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 P=E[1].length;E.index+=P,E[0]=E[0].slice(P)}return E}function h(j,S,T,D,E,P){for(var O in T)if(!(!T.hasOwnProperty(O)||!T[O])){var _=T[O];_=Array.isArray(_)?_:[_];for(var M=0;M<_.length;++M){if(P&&P.cause==O+","+M)return;var R=_[M],F=R.inside,$=!!R.lookbehind,H=!!R.greedy,L=R.alias;if(H&&!R.pattern.global){var z=R.pattern.toString().match(/[imsuy]*$/)[0];R.pattern=RegExp(R.pattern.source,z+"g")}for(var W=R.pattern||R,V=D.next,G=E;V!==S.tail&&!(P&&G>=P.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(H){if(se=f(W,G,j,$),!se||se.index>=j.length)break;var ee=se.index,q=se.index+se[0].length,me=G;for(me+=V.value.length;ee>=me;)V=V.next,me+=V.value.length;if(me-=V.value.length,G=me,V.value instanceof d)continue;for(var ce=V;ce!==S.tail&&(me<q||typeof ce.value=="string");ce=ce.next)K++,me+=ce.value.length;K--,B=j.slice(G,me),se.index-=G}else if(se=f(W,0,B,$),!se)continue;var ee=se.index,pe=se[0],Ne=B.slice(0,ee),ye=B.slice(ee+pe.length),Me=G+B.length;P&&Me>P.reach&&(P.reach=Me);var qe=V.prev;Ne&&(qe=b(S,qe,Ne),G+=Ne.length),y(S,qe,K);var He=new d(O,F?c.tokenize(pe,F):pe,L,pe);if(V=b(S,qe,He),ye&&b(S,V,ye),K>1){var X={cause:O+","+M,reach:Me};h(j,S,T,V.prev,G,X),P&&X.reach>P.reach&&(P.reach=X.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 A=c.util.currentScript();A&&(c.filename=A.src,A.hasAttribute("data-manual")&&(c.manual=!0));function N(){c.manual||c.highlightAll()}if(!c.manual){var k=document.readyState;k==="loading"||k==="interactive"&&A&&A.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(A,N){return"✖ Error "+A+" 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(A,N,k){var j=new XMLHttpRequest;j.open("GET",A,!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(A){var N=/^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(A||"");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(A){A.selector+=", "+m}),n.hooks.add("before-sanity-check",function(A){var N=A.element;if(N.matches(m)){A.code="",N.setAttribute(c,d);var k=N.appendChild(document.createElement("CODE"));k.textContent=s;var j=N.getAttribute("data-src"),S=A.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 P=y(N.getAttribute("data-range"));if(P){var O=E.split(/\r\n?|\n/g),_=P[0],M=P[1]==null?O.length:P[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)}})()})(fb)),fb.exports}var b4=g4();const da=Zu(b4);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 x4(){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}x4();(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 y4(){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}y4();(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 A=b[y];if(A.type!=="code"){m(A.content);continue}var N=A.content[1],k=A.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],A=/language-(.+)/.exec(w);if(A){m=A[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 A=c[y];return A||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 v4(){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}v4();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 w4={".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"},xe="/assets/vscode-icons/",jp={".7z":`${xe}file_type_zip.svg`,".R":`${xe}file_type_r.svg`,".adoc":`${xe}file_type_asciidoc.svg`,".asciidoc":`${xe}file_type_asciidoc.svg`,".astro":`${xe}file_type_astro.svg`,".avi":`${xe}file_type_video.svg`,".babelrc":`${xe}file_type_babel.svg`,".bash":`${xe}file_type_shell.svg`,".bat":`${xe}file_type_bat.svg`,".bmp":`${xe}file_type_image.svg`,".c":`${xe}file_type_c.svg`,".cc":`${xe}file_type_cpp.svg`,".cfg":`${xe}file_type_ini.svg`,".circleci":`${xe}file_type_circleci.svg`,".cjs":`${xe}file_type_js_official.svg`,".clj":`${xe}file_type_clojure.svg`,".cljs":`${xe}file_type_clojure.svg`,".cmd":`${xe}file_type_bat.svg`,".conf":`${xe}file_type_ini.svg`,".cpp":`${xe}file_type_cpp.svg`,".cs":`${xe}file_type_csharp.svg`,".css":`${xe}file_type_css.svg`,".csv":`${xe}file_type_csv.svg`,".cxx":`${xe}file_type_cpp.svg`,".dart":`${xe}file_type_dart.svg`,".diff":`${xe}file_type_diff.svg`,".dockerfile":`${xe}file_type_docker.svg`,".dockerignore":`${xe}file_type_docker.svg`,".env":`${xe}file_type_dotenv.svg`,".env.development":`${xe}file_type_dotenv.svg`,".env.local":`${xe}file_type_dotenv.svg`,".env.production":`${xe}file_type_dotenv.svg`,".env.test":`${xe}file_type_dotenv.svg`,".erb":`${xe}file_type_ruby.svg`,".erl":`${xe}file_type_erlang.svg`,".eslintrc":`${xe}file_type_eslint.svg`,".eslintrc.js":`${xe}file_type_eslint.svg`,".eslintrc.json":`${xe}file_type_eslint.svg`,".ex":`${xe}file_type_elixir.svg`,".exs":`${xe}file_type_elixir.svg`,".fish":`${xe}file_type_shell.svg`,".gif":`${xe}file_type_image.svg`,".git":`${xe}file_type_git.svg`,".gitattributes":`${xe}file_type_git.svg`,".github":`${xe}file_type_github.svg`,".gitignore":`${xe}file_type_git.svg`,".gitlab-ci.yml":`${xe}file_type_gitlab.svg`,".gitmodules":`${xe}file_type_git.svg`,".go":`${xe}file_type_go.svg`,".gql":`${xe}file_type_graphql.svg`,".gradle":`${xe}file_type_gradle.svg`,".graphql":`${xe}file_type_graphql.svg`,".groovy":`${xe}file_type_groovy.svg`,".gz":`${xe}file_type_zip.svg`,".h":`${xe}file_type_c.svg`,".hpp":`${xe}file_type_cpp.svg`,".hrl":`${xe}file_type_erlang.svg`,".hs":`${xe}file_type_haskell.svg`,".htm":`${xe}file_type_html.svg`,".html":`${xe}file_type_html.svg`,".ico":`${xe}file_type_image.svg`,".ini":`${xe}file_type_ini.svg`,".java":`${xe}file_type_java.svg`,".jl":`${xe}file_type_julia.svg`,".jpeg":`${xe}file_type_image.svg`,".jpg":`${xe}file_type_image.svg`,".js":`${xe}file_type_js_official.svg`,".json":`${xe}file_type_json_official.svg`,".json5":`${xe}file_type_json5.svg`,".jsonc":`${xe}file_type_json_official.svg`,".jsx":`${xe}file_type_reactjs.svg`,".kt":`${xe}file_type_kotlin.svg`,".kts":`${xe}file_type_kotlin.svg`,".kubernetes.yaml":`${xe}file_type_kubernetes.svg`,".less":`${xe}file_type_less.svg`,".lhs":`${xe}file_type_haskell.svg`,".lock":`${xe}file_type_lock.svg`,".log":`${xe}file_type_log.svg`,".lua":`${xe}file_type_lua.svg`,".markdown":`${xe}file_type_markdown.svg`,".md":`${xe}file_type_markdown.svg`,".mdown":`${xe}file_type_markdown.svg`,".mdx":`${xe}file_type_markdown.svg`,".mjs":`${xe}file_type_js_official.svg`,".mk":`${xe}file_type_makefile.svg`,".mov":`${xe}file_type_video.svg`,".mp3":`${xe}file_type_audio.svg`,".mp4":`${xe}file_type_video.svg`,".nim":`${xe}file_type_nim.svg`,".nims":`${xe}file_type_nim.svg`,".patch":`${xe}file_type_diff.svg`,".pdf":`${xe}file_type_pdf.svg`,".php":`${xe}file_type_php.svg`,".pl":`${xe}file_type_perl.svg`,".pm":`${xe}file_type_perl.svg`,".png":`${xe}file_type_image.svg`,".prettier.json":`${xe}file_type_prettier.svg`,".prettierrc":`${xe}file_type_prettier.svg`,".ps1":`${xe}file_type_powershell.svg`,".psd1":`${xe}file_type_powershell.svg`,".psm1":`${xe}file_type_powershell.svg`,".py":`${xe}file_type_python.svg`,".pyw":`${xe}file_type_python.svg`,".r":`${xe}file_type_r.svg`,".rar":`${xe}file_type_zip.svg`,".rb":`${xe}file_type_ruby.svg`,".rs":`${xe}file_type_rust.svg`,".rst":`${xe}file_type_rst.svg`,".sass":`${xe}file_type_scss.svg`,".scala":`${xe}file_type_scala.svg`,".scss":`${xe}file_type_scss.svg`,".sh":`${xe}file_type_shell.svg`,".sql":`${xe}file_type_sql.svg`,".sty":`${xe}file_type_latex.svg`,".svelte":`${xe}file_type_svelte.svg`,".svg":`${xe}file_type_svg.svg`,".swift":`${xe}file_type_swift.svg`,".tar":`${xe}file_type_tar.svg`,".tar.bz2":`${xe}file_type_zip.svg`,".tar.gz":`${xe}file_type_zip.svg`,".terraform":`${xe}file_type_terraform.svg`,".tex":`${xe}file_type_latex.svg`,".toml":`${xe}file_type_toml.svg`,".travis.yml":`${xe}file_type_travis.svg`,".ts":`${xe}file_type_typescript_official.svg`,".tsv":`${xe}file_type_tsv.svg`,".tsx":`${xe}file_type_typescript_official.svg`,".txt":`${xe}file_type_text.svg`,".vue":`${xe}file_type_vue.svg`,".webm":`${xe}file_type_video.svg`,".webp":`${xe}file_type_image.svg`,".xml":`${xe}file_type_xml.svg`,".yaml":`${xe}file_type_yaml_official.svg`,".yml":`${xe}file_type_yaml_official.svg`,".zig":`${xe}file_type_zig.svg`,".zip":`${xe}file_type_zip.svg`,".zsh":`${xe}file_type_shell.svg`,"CMakeLists.txt":`${xe}file_type_cmake.svg`,"Cargo.lock":`${xe}file_type_cargo.svg`,"Cargo.toml":`${xe}file_type_cargo.svg`,Dockerfile:`${xe}file_type_docker.svg`,Gemfile:`${xe}file_type_ruby.svg`,"Gemfile.lock":`${xe}file_type_ruby.svg`,Justfile:`${xe}file_type_just.svg`,Makefile:`${xe}file_type_makefile.svg`,Pipfile:`${xe}file_type_python.svg`,"Pipfile.lock":`${xe}file_type_python.svg`,Procfile:`${xe}file_type_procfile.svg`,Vagrantfile:`${xe}file_type_vagrant.svg`,"azure-pipelines.yml":`${xe}file_type_azurepipelines.svg`,"build.gradle":`${xe}file_type_gradle.svg`,"build.sbt":`${xe}file_type_scala.svg`,"docker-compose.yaml":`${xe}file_type_docker.svg`,"docker-compose.yml":`${xe}file_type_docker.svg`,dune:`${xe}file_type_dune.svg`,"gatsby-config.js":`${xe}file_type_gatsby.svg`,"go.mod":`${xe}file_type_go.svg`,"go.sum":`${xe}file_type_go.svg`,"heroku.yml":`${xe}file_type_heroku.svg`,"jsconfig.json":`${xe}file_type_jsconfig.svg`,"kubernetes.yaml":`${xe}file_type_kubernetes.svg`,makefile:`${xe}file_type_makefile.svg`,"meson.build":`${xe}file_type_meson.svg`,"mix.exs":`${xe}file_type_elixir.svg`,"next.config.js":`${xe}file_type_nextjs.svg`,"nuxt.config.js":`${xe}file_type_nuxtjs.svg`,"package-lock.json":`${xe}file_type_npm.svg`,"package.json":`${xe}file_type_npm.svg`,"pnpm-lock.yaml":`${xe}file_type_pnpm.svg`,"pom.xml":`${xe}file_type_maven.svg`,"pubspec.lock":`${xe}file_type_dart.svg`,"pubspec.yaml":`${xe}file_type_dart.svg`,"pyproject.toml":`${xe}file_type_python.svg`,"rebar.config":`${xe}file_type_erlang.svg`,"requirements.txt":`${xe}file_type_python.svg`,"terraform.tfvars":`${xe}file_type_terraform.svg`,"tox.ini":`${xe}file_type_tox.svg`,"tsconfig.json":`${xe}file_type_tsconfig.svg`,"vite.config.js":`${xe}file_type_vite.svg`,"vite.config.ts":`${xe}file_type_vite.svg`,"webpack.config.js":`${xe}file_type_webpack.svg`,"yarn.lock":`${xe}file_type_yarn.svg`,default:`${xe}default_file.svg`},j1={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"}},k4={c:()=>wt(()=>import("./prism-c-BI05wwL9.js"),[]),cpp:()=>wt(()=>import("./prism-c-BI05wwL9.js"),[]).then(()=>wt(()=>import("./prism-cpp-CK2Ly5dS.js").then(t=>t.p),__vite__mapDeps([7,1]))),java:()=>wt(()=>import("./prism-java-CK6tws4L.js").then(t=>t.p),__vite__mapDeps([8,1])),scala:()=>wt(()=>import("./prism-java-CK6tws4L.js").then(t=>t.p),__vite__mapDeps([8,1])).then(()=>wt(()=>import("./prism-scala-BjNo2HkN.js"),[])),csharp:()=>wt(()=>import("./prism-csharp-ByDDDiWW.js").then(t=>t.p),__vite__mapDeps([9,1])),kotlin:()=>wt(()=>import("./prism-kotlin-B1uvbSyh.js"),[]),groovy:()=>wt(()=>import("./prism-groovy-CGzo1uDg.js"),[]),ruby:()=>wt(()=>import("./prism-ruby-CQBUuZIF.js").then(t=>t.p),__vite__mapDeps([10,1])),php:()=>wt(()=>import("./prism-markup-templating-Ct1xsyfA.js"),[]).then(()=>wt(()=>import("./prism-php-Dt9698bA.js").then(t=>t.p),__vite__mapDeps([11,1]))),scss:()=>wt(()=>import("./prism-scss-CeN16CFC.js").then(t=>t.p),__vite__mapDeps([12,1])),toml:()=>wt(()=>import("./prism-toml-BrQIw_NO.js"),[]),docker:()=>wt(()=>import("./prism-docker-MnIa7k-I.js"),[]),swift:()=>wt(()=>import("./prism-swift--kriB360.js"),[]),lua:()=>wt(()=>import("./prism-lua-Cp_o7ONA.js"),[]),perl:()=>wt(()=>import("./prism-perl-UZfqnD51.js").then(t=>t.p),__vite__mapDeps([13,1])),r:()=>wt(()=>import("./prism-r-TxsGuNZJ.js"),[]),haskell:()=>wt(()=>import("./prism-haskell-Ce8aBmia.js").then(t=>t.p),__vite__mapDeps([14,1])),elixir:()=>wt(()=>import("./prism-elixir-df27OMMQ.js").then(t=>t.p),__vite__mapDeps([15,1])),erlang:()=>wt(()=>import("./prism-erlang-C3Aahqfa.js"),[]),clojure:()=>wt(()=>import("./prism-clojure-u3w_tjfy.js"),[]),graphql:()=>wt(()=>import("./prism-graphql-DJ177lJj.js"),[]),nginx:()=>wt(()=>import("./prism-nginx-43e5TboO.js"),[]),vim:()=>wt(()=>import("./prism-vim-uciLQ2PQ.js"),[]),diff:()=>wt(()=>import("./prism-diff-jN23ddHu.js"),[]),ini:()=>wt(()=>import("./prism-ini-DX5Euru7.js"),[]),powershell:()=>wt(()=>import("./prism-powershell-Ud14i9UV.js"),[]),makefile:()=>wt(()=>import("./prism-makefile-Dk8DMwhC.js"),[])},pb=new Map;async function N1(t){if(t in da.languages)return!0;const e=k4[t];if(!e)return!1;let n=pb.get(t);n||(n=e(),pb.set(t,n));try{return await n,t in da.languages}catch{return!1}finally{pb.delete(t)}}function iV(t){da.highlightElement(t)}function np(t){return w4[t]||"plaintext"}function S4(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 Oo(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 C4(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 Pu(t){var e;if(typeof navigator<"u"&&((e=navigator.clipboard)!=null&&e.writeText)){await navigator.clipboard.writeText(t);return}C4(t)}function T1(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 P=(D.textContent||"").trim();m[E]=Math.max(m[E],P.length);const O=P.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),A=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*A)),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 P=`${k[E]}%`;D.setAttribute("width",P),D.style.cssText+=`;width:${P}`}})}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 _1(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 cs({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),A=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(),P=window.scrollY,O=window.scrollX,_=8;let M=0,R=0;switch(n){case"top":M=D.top+P-E.height-_,R=D.left+O+(D.width-E.width)/2;break;case"bottom":M=D.bottom+P+_,R=D.left+O+(D.width-E.width)/2;break;case"left":M=D.top+P+(D.height-E.height)/2,R=D.left+O-E.width-_;break;case"right":M=D.top+P+(D.height-E.height)/2,R=D.right+O+_;break}const F=window.innerWidth,$=window.innerHeight;R<_&&(R=_),R+E.width>F-_&&(R=F-E.width-_),M<_&&(M=_),M+E.height>$+P-_&&(M=$+P-E.height-_),b({top:M,left:R})},[n]),j=x.useCallback(()=>{r||(N.current&&(clearTimeout(N.current),N.current=null),A.current=setTimeout(()=>{h(!0),d(!0)},s))},[s,r]),S=x.useCallback(()=>{A.current&&(clearTimeout(A.current),A.current=null),d(!1),N.current=setTimeout(()=>{h(!1)},100)},[]);x.useEffect(()=>{f&&c&&requestAnimationFrame(k)},[f,c,k]),x.useEffect(()=>()=>{A.current&&clearTimeout(A.current),N.current&&clearTimeout(N.current)},[]);const T=f&&t&&nc.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 oV({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(cs,{content:a,position:n,children:o.jsx("span",{className:`tide-help-icon tide-help-icon--${s}`,tabIndex:0,children:"?"})})}function hb(t,e){return t?Oo(t,e):""}function A4(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=[],A=[];w.push({leftLine:0,rightLine:0});let N=-1,k=0,j=-1,S=0;const T=()=>{(k>0||S>0)&&A.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],P=hb(E,r);b.push({num:D.origIdx+1,text:E,highlighted:P,type:"unchanged"}),y.push({num:D.modIdx+1,text:E,highlighted:P,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],P=hb(E,r);b.push({num:D.origIdx+1,text:E,highlighted:P,type:"removed"})}else{j<0&&(j=y.length),S++;const E=a[D.modIdx],P=hb(E,r);y.push({num:D.modIdx+1,text:E,highlighted:P,type:"added"})}return T(),w.push({leftLine:b.length,rightLine:y.length}),{leftLines:b,rightLines:y,alignments:w,changeBlocks:A}}function j4(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 A=(i-f)/y;return(m+A*w)*a}const N4=[".md",".mdx",".markdown"];function bx({originalContent:t,modifiedContent:e,filename:n,language:s,initialModifiedOnly:a=!1}){const{t:r}=pt(["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"),[A,N]=x.useState("idle"),[k,j]=x.useState(a),[S,T]=x.useState(0);x.useEffect(()=>{s&&s!=="plaintext"&&N1(s).then(()=>T(ee=>ee+1))},[s]);const D=!t,E=!e,P=x.useMemo(()=>{const ee=n.substring(n.lastIndexOf(".")).toLowerCase();return N4.includes(ee)},[n]),O=x.useCallback(async()=>{try{if(P&&k&&d.current){const ee=d.current.innerHTML,pe=T1(ee),Ne=d.current.innerText;await _1(pe,Ne)}else await Pu(e);w("copied"),setTimeout(()=>w("idle"),2e3)}catch(ee){console.error("Copy modified content failed:",ee),w("error"),setTimeout(()=>w("idle"),2e3)}},[e,P,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 ee=d.current.innerHTML;await Pu(ee),N("copied"),setTimeout(()=>N("idle"),2e3)}catch(ee){console.error("Copy HTML failed:",ee),N("error"),setTimeout(()=>N("idle"),2e3)}},[]),{leftLines:M,rightLines:R,alignments:F,changeBlocks:$}=x.useMemo(()=>A4(t,e,s),[t,e,s,S]),H=x.useCallback(()=>{const ee=f.current,pe=i.current,Ne=c.current;if(!ee||!pe||!Ne)return;const ye=window.devicePixelRatio||1,Me=ee.parentElement;if(!Me)return;const qe=Me.clientWidth,He=Me.clientHeight;if(qe===0||He===0)return;const X=Math.round(qe*ye),ne=Math.round(He*ye);(ee.width!==X||ee.height!==ne)&&(ee.width=X,ee.height=ne);const Te=ee.getContext("2d");if(!Te)return;Te.setTransform(ye,0,0,ye,0,0),Te.clearRect(0,0,qe,He);const We=Me.getBoundingClientRect(),nt=pe.getBoundingClientRect(),we=Ne.getBoundingClientRect(),Le=nt.top-We.top,ie=we.top-We.top,de=pe.scrollTop,Ue=Ne.scrollTop,Ze=pe.clientHeight,lt=Ne.clientHeight;for(const fe of $){const J=Le+fe.leftStart*K-de,ae=Le+(fe.leftStart+Math.max(fe.leftCount,.5))*K-de,Se=ie+fe.rightStart*K-Ue,Z=ie+(fe.rightStart+Math.max(fe.rightCount,.5))*K-Ue;if(ae<Le&&Z<ie||J>Le+Ze+20&&Se>ie+lt+20)continue;fe.type==="modified"?(Te.fillStyle="rgba(90, 130, 180, 0.2)",Te.strokeStyle="rgba(90, 130, 180, 0.45)"):fe.type==="removed"?(Te.fillStyle="rgba(200, 90, 90, 0.2)",Te.strokeStyle="rgba(200, 90, 90, 0.45)"):(Te.fillStyle="rgba(92, 184, 138, 0.2)",Te.strokeStyle="rgba(92, 184, 138, 0.45)");const he=qe*.5;Te.lineWidth=1,Te.save(),Te.beginPath(),Te.rect(0,Le,qe,He-Le),Te.clip(),Te.beginPath(),Te.moveTo(0,J),Te.bezierCurveTo(he,J,he,Se,qe,Se),Te.lineTo(qe,Z),Te.bezierCurveTo(he,Z,he,ae,0,ae),Te.closePath(),Te.fill(),Te.stroke(),Te.restore()}},[$]);x.useEffect(()=>{if(k||D||E)return;const ee=f.current,pe=i.current,Ne=c.current;if(!ee||!pe||!Ne)return;const ye=ee.parentElement;if(!ye)return;const Me=new ResizeObserver(()=>{H()});return Me.observe(ye),requestAnimationFrame(()=>H()),()=>{Me.disconnect(),h.current&&cancelAnimationFrame(h.current)}},[k,D,E,H]);const{leftBoundaries:L,rightBoundaries:z}=x.useMemo(()=>{const ee=new Map,pe=new Map;for(const Ne of $){if(Ne.leftCount>0){const ye=Ne.leftStart,Me=Ne.leftStart+Ne.leftCount-1;ee.set(ye,ee.has(ye)?"both":"top"),ye===Me?ee.set(ye,"both"):ee.set(Me,ee.has(Me)?"both":"bottom")}if(Ne.rightCount>0){const ye=Ne.rightStart,Me=Ne.rightStart+Ne.rightCount-1;pe.set(ye,pe.has(ye)?"both":"top"),ye===Me?pe.set(ye,"both"):pe.set(Me,pe.has(Me)?"both":"bottom")}}return{leftBoundaries:ee,rightBoundaries:pe}},[$]),W=x.useMemo(()=>{const ee=R.filter(Ne=>Ne.type==="added").length,pe=M.filter(Ne=>Ne.type==="removed").length;return{added:ee,removed:pe}},[M,R]),V=x.useMemo(()=>{const ee=[];let pe=!1;R.forEach((ye,Me)=>{ye.type==="added"?pe||(ee.push(Me),pe=!0):pe=!1});let Ne=!1;return M.forEach((ye,Me)=>{if(ye.type==="removed"){if(!Ne){const qe=Math.min(Me,R.length-1);ee.includes(qe)||ee.push(qe),Ne=!0}}else Ne=!1}),ee.sort((ye,Me)=>ye-Me)},[M,R]),[G,B]=x.useState(0),K=20,se=x.useCallback(ee=>{const pe=i.current,Ne=c.current;if(!pe||!Ne||m.current&&m.current!==ee)return;m.current=ee,b.current&&cancelAnimationFrame(b.current);const ye=ee==="left"?pe:Ne,Me=ee==="left"?Ne:pe;Me.scrollLeft=ye.scrollLeft;const qe=j4(ye.scrollTop,ye.scrollHeight-ye.clientHeight,Me.scrollHeight-Me.clientHeight,F,K,ee==="left");Me.scrollTop=qe,h.current&&cancelAnimationFrame(h.current),h.current=requestAnimationFrame(()=>{H(),h.current=null}),b.current=requestAnimationFrame(()=>{m.current=null})},[F,H]);x.useEffect(()=>{const ee=i.current,pe=c.current;if(!ee||!pe)return;const Ne=()=>se("left"),ye=()=>se("right");return ee.addEventListener("scroll",Ne),pe.addEventListener("scroll",ye),()=>{ee.removeEventListener("scroll",Ne),pe.removeEventListener("scroll",ye),b.current&&cancelAnimationFrame(b.current)}},[se]);const q=x.useCallback(ee=>{if(ee<0||ee>=V.length)return;const Ne=V[ee]*K;c.current&&(c.current.scrollTop=Ne),B(ee)},[V]),me=x.useCallback(()=>{const ee=Math.min(G+1,V.length-1);q(ee)},[G,V.length,q]),ce=x.useCallback(()=>{const ee=Math.max(G-1,0);q(ee)},[G,q]);return x.useEffect(()=>{V.length>0&&setTimeout(()=>{q(0),requestAnimationFrame(()=>H())},100)},[V,q,H]),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(cs,{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(cs,{content:"Next change (Down)",position:"bottom",children:o.jsx("button",{className:"diff-nav-btn",onClick:me,disabled:G===V.length-1,children:"↓"})})]})}),o.jsxs("div",{className:"diff-viewer-stats",children:[W.added>0&&o.jsxs("span",{className:"diff-stat added",children:["+",W.added]}),W.removed>0&&o.jsxs("span",{className:"diff-stat removed",children:["-",W.removed]})]}),o.jsxs("div",{className:"diff-viewer-actions",children:[!D&&!E&&o.jsx(cs,{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(cs,{content:P&&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(P&&k?"terminal:diffViewer.copyRichText":"common:buttons.copy")})}),P&&k&&o.jsx(cs,{content:"Copy as HTML tags (for Google Docs, HTML editors)",position:"bottom",children:o.jsx("button",{className:`diff-copy-btn ${A}`,onClick:_,children:A==="copied"?`✓ ${r("terminal:diffViewer.copied")}`:A==="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((ee,pe)=>{const Ne=L.get(pe),ye=Ne==="both"?"diff-hunk-top diff-hunk-bottom":Ne==="top"?"diff-hunk-top":Ne==="bottom"?"diff-hunk-bottom":"";return o.jsxs("div",{className:`diff-line diff-line-${ee.type} ${ye}`,children:[o.jsx("span",{className:"diff-line-num",children:ee.num}),o.jsx("span",{className:"diff-line-content",dangerouslySetInnerHTML:{__html:ee.highlighted||"&nbsp;"}})]},pe)})})]}),!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&&P?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((ee,pe)=>{const Ne=z.get(pe),ye=Ne==="both"?"diff-hunk-top diff-hunk-bottom":Ne==="top"?"diff-hunk-top":Ne==="bottom"?"diff-hunk-bottom":"";return o.jsxs("div",{className:`diff-line diff-line-${ee.type} ${ye}`,children:[o.jsx("span",{className:"diff-line-num",children:ee.num}),o.jsx("span",{className:"diff-line-content",dangerouslySetInnerHTML:{__html:ee.highlighted||"&nbsp;"}})]},pe)})})]})]})]})}function T4(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 E1(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=E1(t);return{path:T4(n.path,e),line:n.line}}function _4(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 M1({isOpen:t,onClose:e,filePath:n,action:s,editData:a,searchRoot:r}){const{t:i}=pt(["terminal","common"]),[c,d]=x.useState(null),[f,h]=x.useState(!1),[m,b]=x.useState(null),[y,w]=x.useState([]),[A,N]=x.useState([]),[k,j]=x.useState("idle"),[S,T]=x.useState("idle"),[D,E]=x.useState("idle"),[P,O]=x.useState("idle"),[_,M]=x.useState(null),[R,F]=x.useState(null),[$,H]=x.useState(!1),L=x.useRef(null),z=x.useRef(null),W=x.useRef(null),V=x.useMemo(()=>E1(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),F(null),Te()):(d(null),b(null),w([]),N([]),M(null),F(null))},[t,G]),x.useEffect(()=>{t&&W.current&&W.current.focus()},[t]),x.useEffect(()=>{if(!t)return;const be=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(z.current){const ge=z.current.querySelectorAll(".diff-panel-content");if(ge.length>0)ge.forEach(ve=>{ve.scrollBy({top:te,behavior:"smooth"})});else{const ve=z.current.querySelector(".file-viewer-code-with-lines");ve?ve.scrollBy({top:te,behavior:"smooth"}):z.current.scrollBy({top:te,behavior:"smooth"})}}return}Pe.stopPropagation()}};return window.addEventListener("keydown",be,{capture:!0}),()=>window.removeEventListener("keydown",be,{capture:!0})},[t,e]);const se=x.useMemo(()=>{if(!c||!a||a.highlightRange)return null;const{oldString:be="",newString:Pe="",operation:te}=a;if(!be&&!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)+be+c.content.slice(ge+Pe.length):null}return null},[c,a]),q=!!a&&!a.highlightRange&&(!!a.oldString||!!a.newString),me=(a==null?void 0:a.unifiedDiff)||_,ce=!!me,ee=x.useMemo(()=>se!==null||!c||!me?null:_4(c.content,me),[se,c,me]),pe=se??ee??R,Ne=pe!==null&&(q||ce),ye=ce&&!Ne,Me=K!==void 0;x.useEffect(()=>{if(!c||!a||a.highlightRange||Ne||a.unifiedDiff||_!==null)return;(async()=>{try{const Pe=c.path||G,te=await Pt(Ot(`/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,Ne,G,_]),x.useEffect(()=>{if(!c||!a||a.highlightRange||se!==null||ee!==null||R!==null||!q&&!ce)return;(async()=>{try{const Pe=c.path||G,te=await Pt(Ot(`/api/files/git-original?path=${encodeURIComponent(Pe)}`));if(te.ok){const ge=await te.json();if(ge.content!==void 0&&ge.content!==c.content){F(ge.content);return}}}catch{}F("")})()},[c,a,se,ee,R,q,ce,G]),x.useEffect(()=>{if(!c)return;const be=np(c.extension);if(be==="plaintext"||be in da.languages){H(!0);return}H(!1),N1(be).then(()=>H(!0))},[c]);const qe=x.useMemo(()=>{if(!c||Ne||ye||TC.includes(c.extension))return[];const be=np(c.extension),Pe=da.languages[be],te=ge=>ge.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");return c.content.split(`
89
+ `).map(ge=>Pe?da.highlight(ge||" ",Pe,be):te(ge||" "))},[c,Ne,ye,$]);x.useEffect(()=>{if(!t||!c||!z.current)return;const be=window.setTimeout(()=>{const Pe=()=>{if(!z.current)return;const te=z.current.querySelector(".file-line-highlighted");if(te){te.scrollIntoView({block:"center",behavior:"auto"});return}if(B){const ge=z.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(be)},[t,c,Me,K==null?void 0:K.offset,B]);const He=async be=>{const Pe=be.substring(be.lastIndexOf(".")).toLowerCase(),te=EC.includes(Pe),ge=_C.includes(Pe),ve=te||ge?`/api/files/info?path=${encodeURIComponent(be)}`:`/api/files/read?path=${encodeURIComponent(be)}`,Fe=await Pt(Ot(ve)),Ke=await Fe.json();if(!Fe.ok){const st=Ke.error==="Path is a directory";return{ok:!1,error:Ke.error,isDirectory:st}}return(te||ge)&&(Ke.content=""),{ok:!0,data:Ke}},X=async(be,Pe)=>{var te;try{const ge=await Pt(Ot(`/api/files/resolve?name=${encodeURIComponent(be)}&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 be=>{var Pe;try{const te=await Pt(Ot(`/api/files/list?path=${encodeURIComponent(be)}`)),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[]},Te=async()=>{h(!0),b(null),w([]),N([]);try{const be=await He(G);if(be.ok){d(be.data);return}if(be.isDirectory){const ge=await ne(G);if(ge.length>0){N(ge);return}b(be.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 X(Pe,te);if(ge.length===1&&!ge[0].isDirectory){const ve=await He(ge[0].path);if(ve.ok){d(ve.data);return}}else if(ge.length>0){w(ge);return}}b(be.error||i("terminal:fileExplorer.failedToLoad"))}catch(be){b(be.message||i("terminal:fileExplorer.failedToLoad"))}finally{h(!1)}},We=async be=>{if(be.isDirectory){h(!0),w([]),N([]),b(null);try{const Pe=await ne(be.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 He(be.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:nt,handleClick:we}=_a(e),Le=()=>{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")}},ie=()=>{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 be=L.current.innerHTML,Pe=T1(be),te=L.current.innerText;await _1(Pe,te),j("copied"),setTimeout(()=>j("idle"),2e3)}catch(be){console.error("Copy Rich Text failed:",be),j("error"),setTimeout(()=>j("idle"),2e3)}},[]),Ue=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 be=L.current.innerHTML;await Pu(be),T("copied"),setTimeout(()=>T("idle"),2e3)}catch(be){console.error("Copy HTML failed:",be),T("error"),setTimeout(()=>T("idle"),2e3)}},[]),Ze=x.useCallback(async()=>{if(!c){E("error"),setTimeout(()=>E("idle"),2e3);return}try{await Pu(c.content),E("copied"),setTimeout(()=>E("idle"),2e3)}catch{E("error"),setTimeout(()=>E("idle"),2e3)}},[c]),lt=x.useCallback(async()=>{if(!c){O("error"),setTimeout(()=>O("idle"),2e3);return}try{await Pu(c.content),O("copied"),setTimeout(()=>O("idle"),2e3)}catch{O("error"),setTimeout(()=>O("idle"),2e3)}},[c]),fe=be=>be<1024?`${be} B`:be<1024*1024?`${(be/1024).toFixed(1)} KB`:`${(be/(1024*1024)).toFixed(1)} MB`,J=c&&TC.includes(c.extension),ae=c&&_C.includes(c.extension),Se=c&&EC.includes(c.extension),Z=ae?"Image":Se?"PDF":c?np(c.extension):"text",he=Fi(),De=ae?Ot(`/api/files/binary?path=${encodeURIComponent(G)}${he?`&token=${encodeURIComponent(he)}`:""}`):null,ze=Se?Ot(`/api/files/binary?path=${encodeURIComponent(G)}${he?`&token=${encodeURIComponent(he)}`:""}`):null;return t?o.jsx(pr,{children:o.jsx("div",{ref:W,className:"file-viewer-overlay",onMouseDown:nt,onClick:we,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:ie()},children:Le()}),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:[J&&c&&!Ne&&!ye&&!Me&&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:Ue,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:Ze,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 ${P}`,onClick:lt,title:i("terminal:fileExplorer.copyOriginalTitle"),children:i(P==="copied"?"common:status.copied":P==="error"?"common:status.error":"terminal:fileExplorer.copyOriginal")})]}),ae&&De||Se&&ze?o.jsx("a",{className:"file-viewer-copy-html-btn",href:`${ae?De:ze}&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:Z}),c.content&&!ae&&!Se&&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:z,children:[f&&o.jsx("div",{className:"file-viewer-loading",children:i("terminal:fileExplorer.loadingFile")}),m&&!y.length&&!A.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(be=>o.jsxs("button",{className:"file-viewer-resolve-item",onClick:()=>We(be),children:[o.jsx("span",{className:"file-viewer-resolve-icon",children:be.isDirectory?"📁":"📄"}),o.jsxs("span",{className:"file-viewer-resolve-info",children:[o.jsx("span",{className:"file-viewer-resolve-name",children:be.name}),o.jsx("span",{className:"file-viewer-resolve-path",children:be.path})]}),!be.isDirectory&&be.size>0&&o.jsx("span",{className:"file-viewer-resolve-size",children:fe(be.size)})]},be.path))})]}),A.length>0&&o.jsxs("div",{className:"file-viewer-resolve-results",children:[o.jsxs("div",{className:"file-viewer-resolve-header",children:["Directory contents (",A.length," items):"]}),o.jsx("div",{className:"file-viewer-resolve-list",children:A.map(be=>o.jsxs("button",{className:"file-viewer-resolve-item",onClick:()=>We(be),children:[o.jsx("span",{className:"file-viewer-resolve-icon",children:be.isDirectory?"📁":"📄"}),o.jsxs("span",{className:"file-viewer-resolve-info",children:[o.jsx("span",{className:"file-viewer-resolve-name",children:be.name}),o.jsx("span",{className:"file-viewer-resolve-path",children:be.path})]}),!be.isDirectory&&be.size>0&&o.jsx("span",{className:"file-viewer-resolve-size",children:fe(be.size)})]},be.path))})]}),c&&!f&&!m&&(ae&&De?o.jsx("div",{className:"file-viewer-image-wrapper",children:o.jsx("img",{src:De,alt:c.filename,className:"file-viewer-image"})}):Se&&ze?o.jsx("div",{className:"file-viewer-pdf-embed",children:o.jsx("iframe",{src:ze,title:c.filename,className:"file-viewer-pdf-iframe"})}):Ne?o.jsx(bx,{originalContent:pe,modifiedContent:c.content,filename:c.filename,language:Z}):ye?o.jsx("pre",{className:"file-viewer-code file-viewer-unified-diff",children:me.split(`
91
+ `).map((be,Pe)=>{let te="diff-ctx";return be.startsWith("+")&&!be.startsWith("+++")?te="diff-add":be.startsWith("-")&&!be.startsWith("---")?te="diff-del":be.startsWith("@@")?te="diff-hdr":(be.startsWith("diff ")||be.startsWith("index ")||be.startsWith("---")||be.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:be||" "})]},Pe)})}):Me?o.jsx("pre",{className:"file-viewer-code file-viewer-code-highlighted",children:c.content.split(`
92
+ `).map((be,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-${Z}`,dangerouslySetInnerHTML:{__html:qe[Pe]||be||" "}})]},Pe)})}):J?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-${Z}`,children:qe.map((be,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-${Z}`,dangerouslySetInnerHTML:{__html:be}})]},Pe+1))}))]})]})})}):null}function E4({agentIds:t}){const{t:e}=pt(["terminal"]),n=Gx(),s=sN(),[a,r]=x.useState(null),[i,c]=x.useState(null),[d,f]=x.useState(()=>Ei(mt.TOOLS_COLLAPSED)),[h,m]=x.useState(()=>Ei(mt.FILES_COLLAPSED)),b=()=>{const O=!d;f(O),Mi(mt.TOOLS_COLLAPSED,O)},y=()=>{const O=!h;m(O),Mi(mt.FILES_COLLAPSED,O)},w=x.useMemo(()=>new Set(t),[t]),A=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"?"🔎":"🔧",P=(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")," (",A.length,")"]}),!d&&o.jsx("div",{className:"tool-history-panel-content",children:A.length===0?o.jsx("div",{className:"tool-history-empty",children:e("terminal:toolHistory.noToolsYet")}):o.jsx("div",{className:"tool-history-list",children:A.slice(0,50).map((O,_)=>o.jsx(D4,{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(O4,{change:O,formatTime:j,formatPath:S,getActionIcon:T,getActionColor:D,onClick:()=>P(O.filePath,O.action),showAgentName:k},_))})})]})]}),o.jsx(M1,{isOpen:a!==null,onClose:()=>r(null),filePath:(a==null?void 0:a.path)||"",action:(a==null?void 0:a.action)||"read"})]})}function M4(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 D4({execution:t,formatTime:e,formatPath:n,getToolIcon:s,showAgentName:a,isExpanded:r,onToggle:i,onViewFile:c}){const{t:d}=pt(["terminal"]),f=M4(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:R4(t.toolName,t.toolInput)})]})]})}function R4(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 O4({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 _l(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,A)=>s[A]!==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,A=Math.round((Date.now()-y)*100)/100,N=A/16,k=(j,S)=>{for(j=String(j);j.length<S;)j=" "+j;return j};console.info(`%c⏱ ${k(A,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 L4=(t,e)=>Math.abs(t-e)<1.01,I4=(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}},P4=t=>t,B4=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},F4=(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,z4=(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?()=>{}:I4(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)}},$4=(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"]},U4=(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 H4{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:P4,rangeExtractor:B4,onChange:()=>{},measureElement:$4,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=_l(()=>(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=_l(()=>[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=_l(()=>[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 A,N;if(w!==void 0&&this.options.lanes>1){A=w;const T=m[A],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,A=T?T.lane:b%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(b,A)}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:A},m[A]=b}return this.measurementsCache=h,h},{key:!1,debug:()=>this.options.debug}),this.calculateRange=_l(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,s,a,r)=>this.range=n.length>0&&s>0?W4({measurements:n,outerSize:s,scrollOffset:a,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=_l(()=>{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=_l(()=>[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[D1(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&&L4(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 D1=(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 W4({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=D1(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 q4({useFlushSync:t=!0,...e}){const n=x.useReducer(()=>({}),{})[1],s={...e,onChange:(r,i)=>{var c;t&&i?nc.flushSync(n):n(),(c=e.onChange)==null||c.call(e,r,i)}},[a]=x.useState(()=>new H4(s));return a.setOptions(s),LC(()=>a._didMount(),[]),LC(()=>a._willUpdate()),a}function R1(t){return q4({observeElementRect:F4,observeElementOffset:z4,scrollToFn:U4,...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 V4(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 Yl(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=V4(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 Lo=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,A;const y=b.target;y&&y!==document&&y!==document.documentElement&&((w=y.classList)!=null&&w.contains("xterm-viewport")||(A=y.closest)!=null&&A.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 O1(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=O1(t[e]))&&(s&&(s+=" "),s+=n)}else for(n in t)t[n]&&(s&&(s+=" "),s+=n);return s}function ps(){for(var t,e,n=0,s="",a=arguments.length;n<a;n++)(t=arguments[n])&&(e=O1(t))&&(s&&(s+=" "),s+=e);return s}const L1=6048e5,Y4=864e5,ah=6e4,rh=36e5,G4=1e3,FC=Symbol.for("constructDateFrom");function kn(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 Ct(t,e){return kn(e||t,t)}function Fa(t,e,n){const s=Ct(t,n==null?void 0:n.in);return isNaN(e)?kn((n==null?void 0:n.in)||t,NaN):(e&&s.setDate(s.getDate()+e),s)}function Ua(t,e,n){const s=Ct(t,n==null?void 0:n.in);if(isNaN(e))return kn(t,NaN);if(!e)return s;const a=s.getDate(),r=kn(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 I1(t,e,n){return kn(t,+Ct(t)+e)}function K4(t,e,n){return I1(t,e*rh)}let Q4={};function Fo(){return Q4}function qr(t,e){var c,d,f,h;const n=Fo(),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=Ct(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 Gl(t,e){return qr(t,{...e,weekStartsOn:1})}function P1(t,e){const n=Ct(t,e==null?void 0:e.in),s=n.getFullYear(),a=kn(n,0);a.setFullYear(s+1,0,4),a.setHours(0,0,0,0);const r=Gl(a),i=kn(n,0);i.setFullYear(s,0,4),i.setHours(0,0,0,0);const c=Gl(i);return n.getTime()>=r.getTime()?s+1:n.getTime()>=c.getTime()?s:s-1}function Np(t){const e=Ct(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=kn.bind(null,e.find(s=>typeof s=="object"));return e.map(n)}function Io(t,e){const n=Ct(t,e==null?void 0:e.in);return n.setHours(0,0,0,0),n}function Kl(t,e,n){const[s,a]=Gr(n==null?void 0:n.in,t,e),r=Io(s),i=Io(a),c=+r-Np(r),d=+i-Np(i);return Math.round((c-d)/Y4)}function X4(t,e){const n=P1(t,e),s=kn(t,0);return s.setFullYear(n,0,4),s.setHours(0,0,0,0),Gl(s)}function Qu(t,e,n){const s=Ct(t,n==null?void 0:n.in);return s.setTime(s.getTime()+e*ah),s}function hy(t,e,n){return Ua(t,e*3,n)}function J4(t,e,n){return I1(t,e*1e3)}function Tp(t,e,n){return Fa(t,e*7,n)}function za(t,e,n){return Ua(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=kn.bind(null,a));const r=Ct(a,s);(!n||n<r||isNaN(+r))&&(n=r)}),kn(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=kn.bind(null,a));const r=Ct(a,s);(!n||n>r||isNaN(+r))&&(n=r)}),kn(s,n||NaN)}function Z4(t,e,n){const[s,a]=Gr(n==null?void 0:n.in,t,e);return+Io(s)==+Io(a)}function ir(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function Ql(t){return!(!ir(t)&&typeof t!="number"||isNaN(+Ct(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 Di(t,e){const n=Ct(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=Di(s)-Di(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 ez(t,e,n){const[s,a]=Gr(n==null?void 0:n.in,t,e),r=UC(s,a),i=Math.abs(Kl(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 B1(t,e){const n=Ct(t,e==null?void 0:e.in);return n.setHours(23,59,59,999),n}function F1(t,e){const n=Ct(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 xx(t,e){const n=Ct(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 z1(t,e){const n=Ct(t,e==null?void 0:e.in);return n.setDate(1),n.setHours(0,0,0,0),n}function $1(t,e){const n=Ct(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=Ct(t,e==null?void 0:e.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function tz(t,e){var c,d;const n=Fo(),s=n.weekStartsOn??((d=(c=n.locale)==null?void 0:c.options)==null?void 0:d.weekStartsOn)??0,a=Ct(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 nz={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"}},sz=(t,e,n)=>{let s;const a=nz[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 mb(t){return(e={})=>{const n=e.width?String(e.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const az={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},rz={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},iz={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},oz={date:mb({formats:az,defaultWidth:"full"}),time:mb({formats:rz,defaultWidth:"full"}),dateTime:mb({formats:iz,defaultWidth:"full"})},lz={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},cz=(t,e,n,s)=>lz[t];function mu(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 uz={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},dz={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},fz={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"]},pz={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"]},hz={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"}},mz={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"}},gz=(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"},bz={ordinalNumber:gz,era:mu({values:uz,defaultWidth:"wide"}),quarter:mu({values:dz,defaultWidth:"wide",argumentCallback:t=>t-1}),month:mu({values:fz,defaultWidth:"wide"}),day:mu({values:pz,defaultWidth:"wide"}),dayPeriod:mu({values:hz,defaultWidth:"wide",formattingValues:mz,defaultFormattingWidth:"wide"})};function gu(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)?yz(c,m=>m.test(i)):xz(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 xz(t,e){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return n}function yz(t,e){for(let n=0;n<t.length;n++)if(e(t[n]))return n}function vz(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 wz=/^(\d+)(th|st|nd|rd)?/i,kz=/\d+/i,Sz={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},Cz={any:[/^b/i,/^(a|c)/i]},Az={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},jz={any:[/1/i,/2/i,/3/i,/4/i]},Nz={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},Tz={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]},_z={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},Ez={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]},Mz={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},Dz={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}},Rz={ordinalNumber:vz({matchPattern:wz,parsePattern:kz,valueCallback:t=>parseInt(t,10)}),era:gu({matchPatterns:Sz,defaultMatchWidth:"wide",parsePatterns:Cz,defaultParseWidth:"any"}),quarter:gu({matchPatterns:Az,defaultMatchWidth:"wide",parsePatterns:jz,defaultParseWidth:"any",valueCallback:t=>t+1}),month:gu({matchPatterns:Nz,defaultMatchWidth:"wide",parsePatterns:Tz,defaultParseWidth:"any"}),day:gu({matchPatterns:_z,defaultMatchWidth:"wide",parsePatterns:Ez,defaultParseWidth:"any"}),dayPeriod:gu({matchPatterns:Mz,defaultMatchWidth:"any",parsePatterns:Dz,defaultParseWidth:"any"})},U1={code:"en-US",formatDistance:sz,formatLong:oz,formatRelative:cz,localize:bz,match:Rz,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Oz(t,e){const n=Ct(t,e==null?void 0:e.in);return Kl(n,ih(n))+1}function my(t,e){const n=Ct(t,e==null?void 0:e.in),s=+Gl(n)-+X4(n);return Math.round(s/L1)+1}function gy(t,e){var h,m,b,y;const n=Ct(t,e==null?void 0:e.in),s=n.getFullYear(),a=Fo(),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=kn((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=kn((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 Lz(t,e){var c,d,f,h;const n=Fo(),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=gy(t,e),r=kn((e==null?void 0:e.in)||t,0);return r.setFullYear(a,0,s),r.setHours(0,0,0,0),qr(r,e)}function H1(t,e){const n=Ct(t,e==null?void 0:e.in),s=+qr(n,e)-+Lz(n,e);return Math.round(s/L1)+1}function wn(t,e){const n=t<0?"-":"",s=Math.abs(t).toString().padStart(e,"0");return n+s}const _i={y(t,e){const n=t.getFullYear(),s=n>0?n:1-n;return wn(e==="yy"?s%100:s,e.length)},M(t,e){const n=t.getMonth();return e==="M"?String(n+1):wn(n+1,2)},d(t,e){return wn(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 wn(t.getHours()%12||12,e.length)},H(t,e){return wn(t.getHours(),e.length)},m(t,e){return wn(t.getMinutes(),e.length)},s(t,e){return wn(t.getSeconds(),e.length)},S(t,e){const n=e.length,s=t.getMilliseconds(),a=Math.trunc(s*Math.pow(10,n-3));return wn(a,e.length)}},El={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 _i.y(t,e)},Y:function(t,e,n,s){const a=gy(t,s),r=a>0?a:1-a;if(e==="YY"){const i=r%100;return wn(i,2)}return e==="Yo"?n.ordinalNumber(r,{unit:"year"}):wn(r,e.length)},R:function(t,e){const n=P1(t);return wn(n,e.length)},u:function(t,e){const n=t.getFullYear();return wn(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 wn(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 wn(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 _i.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 wn(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=H1(t,s);return e==="wo"?n.ordinalNumber(a,{unit:"week"}):wn(a,e.length)},I:function(t,e,n){const s=my(t);return e==="Io"?n.ordinalNumber(s,{unit:"week"}):wn(s,e.length)},d:function(t,e,n){return e==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):_i.d(t,e)},D:function(t,e,n){const s=Oz(t);return e==="Do"?n.ordinalNumber(s,{unit:"dayOfYear"}):wn(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 wn(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 wn(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 wn(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=El.noon:s===0?a=El.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=El.evening:s>=12?a=El.afternoon:s>=4?a=El.morning:a=El.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 _i.h(t,e)},H:function(t,e,n){return e==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):_i.H(t,e)},K:function(t,e,n){const s=t.getHours()%12;return e==="Ko"?n.ordinalNumber(s,{unit:"hour"}):wn(s,e.length)},k:function(t,e,n){let s=t.getHours();return s===0&&(s=24),e==="ko"?n.ordinalNumber(s,{unit:"hour"}):wn(s,e.length)},m:function(t,e,n){return e==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):_i.m(t,e)},s:function(t,e,n){return e==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):_i.s(t,e)},S:function(t,e){return _i.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 ko(s);case"XXXXX":case"XXX":default:return ko(s,":")}},x:function(t,e,n){const s=t.getTimezoneOffset();switch(e){case"x":return qC(s);case"xxxx":case"xx":return ko(s);case"xxxxx":case"xxx":default:return ko(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"+ko(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"+ko(s,":")}},t:function(t,e,n){const s=Math.trunc(+t/1e3);return wn(s,e.length)},T:function(t,e,n){return wn(+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+wn(r,2)}function qC(t,e){return t%60===0?(t>0?"-":"+")+wn(Math.abs(t)/60,2):ko(t,e)}function ko(t,e=""){const n=t>0?"-":"+",s=Math.abs(t),a=wn(Math.trunc(s/60),2),r=wn(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"})}},W1=(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"})}},Iz=(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}}",W1(a,e))},yx={p:W1,P:Iz},Pz=/^D+$/,Bz=/^Y+$/,Fz=["D","DD","YY","YYYY"];function zz(t){return Pz.test(t)}function $z(t){return Bz.test(t)}function Uz(t,e,n){const s=Hz(t,e,n);if(console.warn(s),Fz.includes(t))throw new RangeError(s)}function Hz(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 Wz=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,qz=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Vz=/^'([^]*?)'?$/,Yz=/''/g,Gz=/[a-zA-Z]/;function YC(t,e,n){var h,m,b,y,w,A,N,k;const s=Fo(),a=(n==null?void 0:n.locale)??s.locale??U1,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)??((A=(w=n==null?void 0:n.locale)==null?void 0:w.options)==null?void 0:A.weekStartsOn)??s.weekStartsOn??((k=(N=s.locale)==null?void 0:N.options)==null?void 0:k.weekStartsOn)??0,c=Ct(t,n==null?void 0:n.in);if(!Ql(c))throw new RangeError("Invalid time value");let d=e.match(qz).map(j=>{const S=j[0];if(S==="p"||S==="P"){const T=yx[S];return T(j,a.formatLong)}return j}).join("").match(Wz).map(j=>{if(j==="''")return{isToken:!1,value:"'"};const S=j[0];if(S==="'")return{isToken:!1,value:Kz(j)};if(HC[S])return{isToken:!0,value:j};if(S.match(Gz))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)&&$z(S)||!(n!=null&&n.useAdditionalDayOfYearTokens)&&zz(S))&&Uz(S,e,String(t));const T=HC[S[0]];return T(c,S,a.localize,f)}).join("")}function Kz(t){const e=t.match(Vz);return e?e[1].replace(Yz,"'"):t}function GC(t,e){return Ct(t,e==null?void 0:e.in).getDate()}function Qz(t,e){return Ct(t,e==null?void 0:e.in).getDay()}function Xz(t,e){const n=Ct(t,e==null?void 0:e.in),s=n.getFullYear(),a=n.getMonth(),r=kn(n,0);return r.setFullYear(s,a+1,0),r.setHours(0,0,0,0),r.getDate()}function Jz(){return Object.assign({},Fo())}function As(t,e){return Ct(t,e==null?void 0:e.in).getHours()}function Zz(t,e){const n=Ct(t,e==null?void 0:e.in).getDay();return n===0?7:n}function js(t,e){return Ct(t,e==null?void 0:e.in).getMinutes()}function Vs(t,e){return Ct(t,e==null?void 0:e.in).getMonth()}function Ri(t){return Ct(t).getSeconds()}function vx(t){return+Ct(t)}function en(t,e){return Ct(t,e==null?void 0:e.in).getFullYear()}function $r(t,e){return+Ct(t)>+Ct(e)}function ar(t,e){return+Ct(t)<+Ct(e)}function e3(t,e){return+Ct(t)==+Ct(e)}function t3(t,e){const n=n3(e)?new e(0):kn(e,0);return n.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),n.setHours(t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()),n}function n3(t){var e;return typeof t=="function"&&((e=t.prototype)==null?void 0:e.constructor)===t}const s3=10;class q1{constructor(){Xe(this,"subPriority",0)}validate(e,n){return!0}}class a3 extends q1{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 r3 extends q1{constructor(n,s){super();Xe(this,"priority",s3);Xe(this,"subPriority",-1);this.context=n||(a=>kn(s,a))}set(n,s){return s.timestampIsSet?n:kn(n,t3(n,this.context))}}class gn{run(e,n,s,a){const r=this.parse(e,n,s,a);return r?{setter:new a3(r.value,this.validate,this.set,this.priority,this.subPriority),rest:r.rest}:null}validate(e,n,s){return!0}}class i3 extends gn{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*G4),rest:e.slice(n[0].length)}}function V1(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 by(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 Y1(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 G1(t){return t%400===0||t%4===0&&t%100!==0}class o3 extends gn{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=Y1(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 l3 extends gn{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=gy(n,r);if(a.isTwoDigitYear){const d=Y1(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 c3 extends gn{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=kn(n,0);return r.setFullYear(a,0,4),r.setHours(0,0,0,0),Gl(r)}}class u3 extends gn{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 d3 extends gn{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 f3 extends gn{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 p3 extends gn{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 h3 extends gn{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 m3(t,e,n){const s=Ct(t,n==null?void 0:n.in),a=H1(s,n)-e;return s.setDate(s.getDate()-a*7),Ct(s,n==null?void 0:n.in)}class g3 extends gn{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(m3(n,a,r),r)}}function b3(t,e,n){const s=Ct(t,n==null?void 0:n.in),a=my(s,n)-e;return s.setDate(s.getDate()-a*7),s}class x3 extends gn{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 Gl(b3(n,a))}}const y3=[31,28,31,30,31,30,31,31,30,31,30,31],v3=[31,29,31,30,31,30,31,31,30,31,30,31];class w3 extends gn{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=G1(a),i=n.getMonth();return r?s>=1&&s<=v3[i]:s>=1&&s<=y3[i]}set(n,s,a){return n.setDate(a),n.setHours(0,0,0,0),n}}class k3 extends gn{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 G1(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 xy(t,e,n){var m,b,y,w;const s=Fo(),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=Ct(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 Fa(r,h,n)}class S3 extends gn{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=xy(n,a,r),n.setHours(0,0,0,0),n}}class C3 extends gn{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=xy(n,a,r),n.setHours(0,0,0,0),n}}class A3 extends gn{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=xy(n,a,r),n.setHours(0,0,0,0),n}}function j3(t,e,n){const s=Ct(t,n==null?void 0:n.in),a=Zz(s,n),r=e-a;return Fa(s,r,n)}class N3 extends gn{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=j3(n,a),n.setHours(0,0,0,0),n}}class T3 extends gn{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(by(a),0,0,0),n}}class _3 extends gn{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(by(a),0,0,0),n}}class E3 extends gn{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(by(a),0,0,0),n}}class M3 extends gn{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 D3 extends gn{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 R3 extends gn{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 O3 extends gn{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 L3 extends gn{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 I3 extends gn{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 P3 extends gn{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 B3 extends gn{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:kn(n,n.getTime()-Np(n)-a)}}class F3 extends gn{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:kn(n,n.getTime()-Np(n)-a)}}class z3 extends gn{constructor(){super(...arguments);Xe(this,"priority",40);Xe(this,"incompatibleTokens","*")}parse(n){return V1(n)}set(n,s,a){return[kn(n,a*1e3),{timestampIsSet:!0}]}}class $3 extends gn{constructor(){super(...arguments);Xe(this,"priority",20);Xe(this,"incompatibleTokens","*")}parse(n){return V1(n)}set(n,s,a){return[kn(n,a),{timestampIsSet:!0}]}}const U3={G:new i3,y:new o3,Y:new l3,R:new c3,u:new u3,Q:new d3,q:new f3,M:new p3,L:new h3,w:new g3,I:new x3,d:new w3,D:new k3,E:new S3,e:new C3,c:new A3,i:new N3,a:new T3,b:new _3,B:new E3,h:new M3,H:new D3,K:new R3,k:new O3,m:new L3,s:new I3,S:new P3,X:new B3,x:new F3,t:new z3,T:new $3},H3=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,W3=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,q3=/^'([^]*?)'?$/,V3=/''/g,Y3=/\S/,G3=/[a-zA-Z]/;function K3(t,e,n,s){var N,k,j,S,T,D,E,P;const a=()=>kn((s==null?void 0:s.in)||n,NaN),r=Jz(),i=(s==null?void 0:s.locale)??r.locale??U1,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??((P=(E=r.locale)==null?void 0:E.options)==null?void 0:P.weekStartsOn)??0;if(!e)return t?a():Ct(n,s==null?void 0:s.in);const f={firstWeekContainsDate:c,weekStartsOn:d,locale:i},h=[new r3(s==null?void 0:s.in,n)],m=e.match(W3).map(O=>{const _=O[0];if(_ in yx){const M=yx[_];return M(O,i.formatLong)}return O}).join("").match(H3),b=[];for(let O of m){const _=O[0],M=U3[_];if(M){const{incompatibleTokens:R}=M;if(Array.isArray(R)){const $=b.find(H=>R.includes(H.token)||H.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 F=M.run(t,O,i.match,f);if(!F)return a();h.push(F.setter),t=F.rest}else{if(_.match(G3))throw new RangeError("Format string contains an unescaped latin alphabet character `"+_+"`");if(O==="''"?O="'":_==="'"&&(O=Q3(O)),t.indexOf(O)===0)t=t.slice(O.length);else return a()}}if(t.length>0&&Y3.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=Ct(n,s==null?void 0:s.in);if(isNaN(+w))return a();const A={};for(const O of y){if(!O.validate(w,f))return a();const _=O.set(w,A,f);Array.isArray(_)?(w=_[0],Object.assign(A,_[1])):w=_}return w}function Q3(t){return t.match(q3)[1].replace(V3,"'")}function X3(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 J3(t,e,n){const[s,a]=Gr(n==null?void 0:n.in,t,e);return+xx(s)==+xx(a)}function Z3(t,e,n){const[s,a]=Gr(n==null?void 0:n.in,t,e);return s.getFullYear()===a.getFullYear()}function Xu(t,e,n){const s=+Ct(t,n==null?void 0:n.in),[a,r]=[+Ct(e.start,n==null?void 0:n.in),+Ct(e.end,n==null?void 0:n.in)].sort((i,c)=>i-c);return s>=a&&s<=r}function e$(t,e,n){return Fa(t,-1,n)}function t$(t,e){const n=()=>kn(e==null?void 0:e.in,NaN),a=r$(t);let r;if(a.date){const f=i$(a.date,2);r=o$(f.restDateString,f.year)}if(!r||isNaN(+r))return n();const i=+r;let c=0,d;if(a.time&&(c=l$(a.time),isNaN(c)))return n();if(a.timezone){if(d=c$(a.timezone),isNaN(d))return n()}else{const f=new Date(i+c),h=Ct(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 Ct(i+c+d,e==null?void 0:e.in)}const Ff={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},n$=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,s$=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,a$=/^([+-])(\d{2})(?::?(\d{2}))?$/;function r$(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 i$(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 o$(t,e){if(e===null)return new Date(NaN);const n=t.match(n$);if(!n)return new Date(NaN);const s=!!n[4],a=bu(n[1]),r=bu(n[2])-1,i=bu(n[3]),c=bu(n[4]),d=bu(n[5])-1;if(s)return h$(e,c,d)?u$(e,c,d):new Date(NaN);{const f=new Date(0);return!f$(e,r,i)||!p$(e,a)?new Date(NaN):(f.setUTCFullYear(e,r,Math.max(a,i)),f)}}function bu(t){return t?parseInt(t):1}function l$(t){const e=t.match(s$);if(!e)return NaN;const n=gb(e[1]),s=gb(e[2]),a=gb(e[3]);return m$(n,s,a)?n*rh+s*ah+a*1e3:NaN}function gb(t){return t&&parseFloat(t.replace(",","."))||0}function c$(t){if(t==="Z")return 0;const e=t.match(a$);if(!e)return 0;const n=e[1]==="+"?-1:1,s=parseInt(e[2]),a=e[3]&&parseInt(e[3])||0;return g$(s,a)?n*(s*rh+a*ah):NaN}function u$(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 d$=[31,null,31,30,31,30,31,31,30,31,30,31];function K1(t){return t%400===0||t%4===0&&t%100!==0}function f$(t,e,n){return e>=0&&e<=11&&n>=1&&n<=(d$[e]||(K1(t)?29:28))}function p$(t,e){return e>=1&&e<=(K1(t)?366:365)}function h$(t,e,n){return e>=1&&e<=53&&n>=0&&n<=6}function m$(t,e,n){return t===24?e===0&&n===0:n>=0&&n<60&&e>=0&&e<60&&t>=0&&t<25}function g$(t,e){return e>=0&&e<=59}function oa(t,e,n){const s=Ct(t,n==null?void 0:n.in),a=s.getFullYear(),r=s.getDate(),i=kn(t,0);i.setFullYear(a,e,15),i.setHours(0,0,0,0);const c=Xz(i);return s.setMonth(e,Math.min(r,c)),s}function sp(t,e,n){const s=Ct(t,n==null?void 0:n.in);return s.setHours(e),s}function ap(t,e,n){const s=Ct(t,n==null?void 0:n.in);return s.setMinutes(e),s}function Il(t,e,n){const s=Ct(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=Ct(t,n==null?void 0:n.in);return s.setSeconds(e),s}function Ja(t,e,n){const s=Ct(t,n==null?void 0:n.in);return isNaN(+s)?kn(t,NaN):(s.setFullYear(e),s)}function To(t,e,n){return Ua(t,-e,n)}function Q1(t,e,n){return hy(t,-1,n)}function KC(t,e,n){return Tp(t,-1,n)}function Ii(t,e,n){return za(t,-e,n)}function oh(){return typeof window<"u"}function rc(t){return X1(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=(X1(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function X1(t){return oh()?t instanceof Node||t instanceof fa(t).Node:!1}function Os(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 id(t){const{overflow:e,overflowX:n,overflowY:s,display:a}=Ea(t);return/auto|scroll|overlay|hidden|clip/.test(e+s+n)&&a!=="inline"&&a!=="contents"}function b$(t){return/^(table|td|th)$/.test(rc(t))}function lh(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const x$=/transform|translate|scale|rotate|perspective|filter/,y$=/paint|layout|strict|content/,yo=t=>!!t&&t!=="none";let bb;function yy(t){const e=Os(t)?Ea(t):t;return yo(e.transform)||yo(e.translate)||yo(e.scale)||yo(e.rotate)||yo(e.perspective)||!vy()&&(yo(e.backdropFilter)||yo(e.filter))||x$.test(e.willChange||"")||y$.test(e.contain||"")}function v$(t){let e=Pi(t);for(;Kr(e)&&!Xl(e);){if(yy(e))return e;if(lh(e))return null;e=Pi(e)}return null}function vy(){return bb==null&&(bb=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),bb}function Xl(t){return/^(html|body|#document)$/.test(rc(t))}function Ea(t){return fa(t).getComputedStyle(t)}function ch(t){return Os(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Pi(t){if(rc(t)==="html")return t;const e=t.assignedSlot||t.parentNode||QC(t)&&t.host||mr(t);return QC(e)?e.host:e}function J1(t){const e=Pi(t);return Xl(e)?t.ownerDocument?t.ownerDocument.body:t.body:Kr(e)&&id(e)?e:J1(e)}function Ju(t,e,n){var s;e===void 0&&(e=[]),n===void 0&&(n=!0);const a=J1(t),r=a===((s=t.ownerDocument)==null?void 0:s.body),i=fa(a);if(r){const c=wx(i);return e.concat(i,i.visualViewport||[],id(a)?a:[],c&&n?Ju(c):[])}else return e.concat(a,Ju(a,[],n))}function wx(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}const Jl=Math.min,_o=Math.max,Rp=Math.round,zf=Math.floor,or=t=>({x:t,y:t}),w$={left:"right",right:"left",bottom:"top",top:"bottom"};function k$(t,e,n){return _o(t,Jl(e,n))}function uh(t,e){return typeof t=="function"?t(e):t}function Zl(t){return t.split("-")[0]}function od(t){return t.split("-")[1]}function S$(t){return t==="x"?"y":"x"}function wy(t){return t==="y"?"height":"width"}function Ao(t){const e=t[0];return e==="t"||e==="b"?"y":"x"}function ky(t){return S$(Ao(t))}function C$(t,e,n){n===void 0&&(n=!1);const s=od(t),a=ky(t),r=wy(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 A$(t){const e=Op(t);return[kx(t),e,kx(e)]}function kx(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const XC=["left","right"],JC=["right","left"],j$=["top","bottom"],N$=["bottom","top"];function T$(t,e,n){switch(t){case"top":case"bottom":return n?e?JC:XC:e?XC:JC;case"left":case"right":return e?j$:N$;default:return[]}}function _$(t,e,n,s){const a=od(t);let r=T$(Zl(t),n==="start",s);return a&&(r=r.map(i=>i+"-"+a),e&&(r=r.concat(r.map(kx)))),r}function Op(t){const e=Zl(t);return w$[e]+t.slice(e.length)}function E$(t){return{top:0,right:0,bottom:0,left:0,...t}}function Z1(t){return typeof t!="number"?E$(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 M$=typeof document<"u",D$=function(){},Ip=M$?x.useLayoutEffect:D$;const R$={...pj},O$=R$.useInsertionEffect,L$=O$||(t=>t());function I$(t){const e=x.useRef(()=>{});return L$(()=>{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=Ao(e),i=ky(e),c=wy(i),d=Zl(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(od(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 P$(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=Z1(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 B$=50,F$=async(t,e,n)=>{const{placement:s="bottom",strategy:a="absolute",middleware:r=[],platform:i}=n,c=i.detectOverflow?i:{...i,detectOverflow:P$},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 A=0;A<r.length;A++){const N=r[A];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<B$&&(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)),A=-1)}return{x:h,y:m,placement:b,strategy:a,middlewareData:w}},z$=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=Z1(h),b={x:n,y:s},y=ky(a),w=wy(y),A=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 P=E?E[S]:0;(!P||!await(i.isElement==null?void 0:i.isElement(E)))&&(P=c.floating[S]||r.floating[w]);const O=T/2-D/2,_=P/2-A[w]/2-1,M=Jl(m[k],_),R=Jl(m[j],_),F=M,$=P-A[w]-R,H=P/2-A[w]/2+O,L=k$(F,H,$),z=!d.arrow&&od(a)!=null&&H!==L&&r.reference[w]/2-(H<F?M:R)-A[w]/2<0,W=z?H<F?H-F:H-$:0;return{[y]:b[y]+W,data:{[y]:L,centerOffset:H-L-W,...z&&{alignmentOffset:W}},reset: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:A=!0,...N}=uh(t,e);if((n=r.arrow)!=null&&n.alignmentOffset)return{};const k=Zl(a),j=Ao(c),S=Zl(c)===c,T=await(d.isRTL==null?void 0:d.isRTL(f.floating)),D=b||(S||!A?[Op(c)]:A$(c)),E=w!=="none";!b&&E&&D.push(..._$(c,A,w,T));const P=[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 H=C$(a,i,T);_.push(O[H[0]],O[H[1]])}if(M=[...M,{placement:a,overflows:_}],!_.every(H=>H<=0)){var R,F;const H=(((R=r.flip)==null?void 0:R.index)||0)+1,L=P[H];if(L&&(!(m==="alignment"?j!==Ao(L):!1)||M.every(V=>Ao(V.placement)===j?V.overflows[0]>0:!0)))return{data:{index:H,overflows:M},reset:{placement:L}};let z=(F=M.filter(W=>W.overflows[0]<=0).sort((W,V)=>W.overflows[1]-V.overflows[1])[0])==null?void 0:F.placement;if(!z)switch(y){case"bestFit":{var $;const W=($=M.filter(V=>{if(E){const G=Ao(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];W&&(z=W);break}case"initialPlacement":z=c;break}if(a!==z)return{reset:{placement:z}}}return{}}}},U$=new Set(["left","top"]);async function H$(t,e){const{placement:n,platform:s,elements:a}=t,r=await(s.isRTL==null?void 0:s.isRTL(a.floating)),i=Zl(n),c=od(n),d=Ao(n)==="y",f=U$.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 W$=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 H$(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=Ea(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 Sy(t){return Os(t)?t:t.contextElement}function Ul(t){const e=Sy(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 q$=or(0);function tT(t){const e=fa(t);return!vy()||!e.visualViewport?q$:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function V$(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==fa(t)?!1:e}function Po(t,e,n,s){e===void 0&&(e=!1),n===void 0&&(n=!1);const a=t.getBoundingClientRect(),r=Sy(t);let i=or(1);e&&(s?Os(s)&&(i=Ul(s)):i=Ul(t));const c=V$(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&&Os(s)?fa(s):s;let w=b,A=wx(w);for(;A&&s&&y!==w;){const N=Ul(A),k=A.getBoundingClientRect(),j=Ea(A),S=k.left+(A.clientLeft+parseFloat(j.paddingLeft))*N.x,T=k.top+(A.clientTop+parseFloat(j.paddingTop))*N.y;d*=N.x,f*=N.y,h*=N.x,m*=N.y,d+=S,f+=T,w=fa(A),A=wx(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:Po(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 Y$(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)&&((rc(s)!=="body"||id(i))&&(d=ch(s)),m)){const y=Po(s);f=Ul(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 G$(t){return Array.from(t.getClientRects())}function K$(t){const e=mr(t),n=ch(t),s=t.ownerDocument.body,a=_o(e.scrollWidth,e.clientWidth,s.scrollWidth,s.clientWidth),r=_o(e.scrollHeight,e.clientHeight,s.scrollHeight,s.clientHeight);let i=-n.scrollLeft+dh(t);const c=-n.scrollTop;return Ea(s).direction==="rtl"&&(i+=_o(e.clientWidth,s.clientWidth)-a),{width:a,height:r,x:i,y:c}}const eA=25;function Q$(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=vy();(!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 X$(t,e){const n=Po(t,!0,e==="fixed"),s=n.top+t.clientTop,a=n.left+t.clientLeft,r=Kr(t)?Ul(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=Q$(t,n);else if(e==="document")s=K$(mr(t));else if(Os(e))s=X$(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=Pi(t);return n===e||!Os(n)||Xl(n)?!1:Ea(n).position==="fixed"||sT(n,e)}function J$(t,e){const n=e.get(t);if(n)return n;let s=Ju(t,[],!1).filter(c=>Os(c)&&rc(c)!=="body"),a=null;const r=Ea(t).position==="fixed";let i=r?Pi(t):t;for(;Os(i)&&!Xl(i);){const c=Ea(i),d=yy(i);!d&&c.position==="fixed"&&(a=null),(r?!d&&!a:!d&&c.position==="static"&&!!a&&(a.position==="absolute"||a.position==="fixed")||id(i)&&!d&&sT(t,i))?s=s.filter(h=>h!==i):a=c,i=Pi(i)}return e.set(t,s),s}function Z$(t){let{element:e,boundary:n,rootBoundary:s,strategy:a}=t;const i=[...n==="clippingAncestors"?lh(e)?[]:J$(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=_o(y.top,d),f=Jl(y.right,f),h=Jl(y.bottom,h),m=_o(y.left,m)}return{width:f-m,height:h-d,x:m,y:d}}function eU(t){const{width:e,height:n}=eT(t);return{width:e,height:n}}function tU(t,e,n){const s=Kr(e),a=mr(e),r=n==="fixed",i=Po(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((rc(e)!=="body"||id(a))&&(c=ch(e)),s){const y=Po(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 xb(t){return Ea(t).position==="static"}function nA(t,e){if(!Kr(t)||Ea(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=Pi(t);for(;a&&!Xl(a);){if(Os(a)&&!xb(a))return a;a=Pi(a)}return n}let s=nA(t,e);for(;s&&b$(s)&&xb(s);)s=nA(s,e);return s&&Xl(s)&&xb(s)&&!yy(s)?n:s||v$(t)||n}const nU=async function(t){const e=this.getOffsetParent||aT,n=this.getDimensions,s=await n(t.floating);return{reference:tU(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function sU(t){return Ea(t).direction==="rtl"}const aU={convertOffsetParentRelativeRectToViewportRelativeRect:Y$,getDocumentElement:mr,getClippingRect:Z$,getOffsetParent:aT,getElementRects:nU,getClientRects:G$,getDimensions:eU,getScale:Ul,isElement:Os,isRTL:sU};function rT(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function rU(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),A=zf(a.clientWidth-(h+b)),N=zf(a.clientHeight-(m+y)),k=zf(h),S={rootMargin:-w+"px "+-A+"px "+-N+"px "+-k+"px",threshold:_o(0,Jl(1,d))||1};let T=!0;function D(E){const P=E[0].intersectionRatio;if(P!==d){if(!T)return i();P?i(!1,P):s=setTimeout(()=>{i(!1,1e-7)},1e3)}P===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 iU(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=Sy(t),h=a||r?[...f?Ju(f):[],...e?Ju(e):[]]:[];h.forEach(k=>{a&&k.addEventListener("scroll",n,{passive:!0}),r&&k.addEventListener("resize",n)});const m=f&&c?rU(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,A=d?Po(t):null;d&&N();function N(){const k=Po(t);A&&!rT(A,k)&&n(),A=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 oU=W$,lU=$$,sA=z$,cU=(t,e,n)=>{const s=new Map,a={platform:aU,...n},r={...a.platform,_c:s};return F$(t,e,{...a,platform:r})};var uU=typeof document<"u",dU=function(){},ip=uU?x.useLayoutEffect:dU;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 yb(t){const e=x.useRef(t);return ip(()=>{e.current=t}),e}function fU(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,A]=x.useState(null),[N,k]=x.useState(null),j=x.useCallback(V=>{V!==E.current&&(E.current=V,A(V))},[]),S=x.useCallback(V=>{V!==P.current&&(P.current=V,k(V))},[]),T=r||w,D=i||N,E=x.useRef(null),P=x.useRef(null),O=x.useRef(h),_=d!=null,M=yb(d),R=yb(a),F=yb(f),$=x.useCallback(()=>{if(!E.current||!P.current)return;const V={placement:e,strategy:n,middleware:b};R.current&&(V.platform=R.current),cU(E.current,P.current,V).then(G=>{const B={...G,isPositioned:F.current!==!1};H.current&&!Pp(O.current,B)&&(O.current=B,nc.flushSync(()=>{m(B)}))})},[b,e,n,R,F]);ip(()=>{f===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,m(V=>({...V,isPositioned:!1})))},[f]);const H=x.useRef(!1);ip(()=>(H.current=!0,()=>{H.current=!1}),[]),ip(()=>{if(T&&(E.current=T),D&&(P.current=D),T&&D){if(M.current)return M.current(T,D,$);$()}},[T,D,$,M,_]);const L=x.useMemo(()=>({reference:E,floating:P,setReference:j,setFloating:S}),[j,S]),z=x.useMemo(()=>({reference:T,floating:D}),[T,D]),W=x.useMemo(()=>{const V={position:n,left:0,top:0};if(!z.floating)return V;const G=aA(z.floating,h.x),B=aA(z.floating,h.y);return c?{...V,transform:"translate("+G+"px, "+B+"px)",...iT(z.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:G,top:B}},[n,c,z.floating,h.x,h.y]);return x.useMemo(()=>({...h,update:$,refs:L,elements:z,floatingStyles:W}),[h,$,L,z,W])}const pU=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):{}}}},hU=(t,e)=>{const n=oU(t);return{name:n.name,fn:n.fn,options:[t,e]}},mU=(t,e)=>{const n=lU(t);return{name:n.name,fn:n.fn,options:[t,e]}},gU=(t,e)=>{const n=pU(t);return{name:n.name,fn:n.fn,options:[t,e]}},bU={...pj};let rA=!1,xU=0;const iA=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+xU++;function yU(){const[t,e]=x.useState(()=>rA?iA():void 0);return Ip(()=>{t==null&&e(iA())},[]),x.useEffect(()=>{rA=!0},[]),t}const vU=bU.useId,oT=vU||yU,wU=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,...A}={},...N}=e,k=oT(),[j,S]=x.useState(!1);if(Ip(()=>{if(!a)return;Ea(a).direction==="rtl"&&S(!0)},[a]),!a)return null;const[T,D]=s.split("-"),E=T==="top"||T==="bottom";let P=m;(E&&i!=null&&i.x||!E&&i!=null&&i.y)&&(P=null);const O=h*2,_=O/2,M=c/2*(f/-8+1),R=d/2*f/4,F=!!y,$=P&&D==="end"?"bottom":"top";let H=P&&D==="end"?"right":"left";P&&j&&(H=D==="end"?"left":"right");const L=(r==null?void 0:r.x)!=null?P||r.x:"",z=(r==null?void 0:r.y)!=null?P||r.y:"",W=y||"M0,0"+(" H"+c)+(" L"+(c-M)+","+(d-R))+(" Q"+c/2+","+d+" "+M+","+(d-R))+" Z",V={top:F?"rotate(180deg)":"",left:F?"rotate(90deg)":"rotate(-90deg)",bottom:F?"":"rotate(180deg)",right:F?"rotate(-90deg)":"rotate(90deg)"}[T];return o.jsxs("svg",{...N,"aria-hidden":!0,ref:n,width:F?c:c+O,height:c,viewBox:"0 0 "+c+" "+(d>c?d:c),style:{position:"absolute",pointerEvents:"none",[H]:L,[$]:z,[T]:E||F?"100%":"calc(100% - "+O/2+"px)",transform:[V,w].filter(G=>!!G).join(" "),...A},children:[O>0&&o.jsx("path",{clipPath:"url(#"+k+")",fill:"none",stroke:b,strokeWidth:O+(y?0:1),d:W}),o.jsx("path",{stroke:O&&!y?N.fill:"none",d:W}),o.jsx("clipPath",{id:k,children:o.jsx("rect",{x:-_,y:_*(F?-1:1),width:c+O,height:c})})]})});function kU(){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 SU=x.createContext(null),CU=x.createContext(null),AU=()=>{var t;return((t=x.useContext(SU))==null?void 0:t.id)||null},jU=()=>x.useContext(CU);function NU(t){const{open:e=!1,onOpenChange:n,elements:s}=t,a=oT(),r=x.useRef({}),[i]=x.useState(()=>kU()),c=AU()!=null,[d,f]=x.useState(s.reference),h=I$((y,w,A)=>{r.current.openEvent=y?w:void 0,i.emit("openchange",{open:y,event:w,reason:A,nested:c}),n==null||n(y,w,A)}),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 TU(t){t===void 0&&(t={});const{nodeId:e}=t,n=NU({...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=jU();Ip(()=>{h&&(m.current=h)},[h]);const y=fU({...t,elements:{...a,...c&&{reference:c}}}),w=x.useCallback(S=>{const T=Os(S)?{getBoundingClientRect:()=>S.getBoundingClientRect(),getClientRects:()=>S.getClientRects(),contextElement:S}:S;d(T),y.refs.setReference(T)},[y.refs]),A=x.useCallback(S=>{(Os(S)||S===null)&&(m.current=S,i(S)),(Os(y.refs.reference.current)||y.refs.reference.current===null||S!==null&&!Os(S))&&y.refs.setReference(S)},[y.refs]),N=x.useMemo(()=>({...y.refs,setReference:A,setPositionReference:w,domReference:m}),[y.refs,A,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 Sx=function(e,n){return Sx=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])},Sx(e,n)};function Ss(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Sx(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}var Yt=function(){return Yt=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},Yt.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 _U=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 je.createElement("div",{className:r,"aria-label":d,role:c?void 0:"dialog","aria-modal":c?void 0:"true",translate:"no"},i)},EU=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=EU(n,i);return je.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 it;(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"})(it||(it={}));function cT(){var t=typeof window<"u"?window:globalThis;return t}var ld=12;function dn(t){if(t==null)return new Date;var e=typeof t=="string"?t$(t):Ct(t);return qs(e)?e:new Date}function vo(t,e,n,s,a){a===void 0&&(a=dn());for(var r=ec(n)||ec(Cy()),i=Array.isArray(e)?e:[e],c=0,d=i;c<d.length;c++){var f=d[c],h=K3(t,f,a,{locale:r});if(qs(h)&&(!s||t===Pn(h,f,n)))return h}if(!s&&t&&t.length>=8){var m=new Date(t);if(Ql(m))return m}return null}function MU(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 qs(t){return Ql(t)}function jo(t){return t==null?null:ir(t)&&Ql(t)?t:null}function Pn(t,e,n){if(n==="en")return YC(t,e,{useAdditionalWeekYearTokens:!0,useAdditionalDayOfYearTokens:!0});var s=n?ec(n):void 0;return n&&!s&&console.warn('A locale object was not found for the provided string ["'.concat(n,'"].')),s=s||ec(Cy()),YC(t,e,{locale:s,useAdditionalWeekYearTokens:!0,useAdditionalDayOfYearTokens:!0})}function Ws(t,e){var n=e.dateFormat,s=e.locale,a=Array.isArray(n)&&n.length>0?n[0]:n;return t&&Pn(t,a,s)||""}var uT=" - ";function DU(t,e,n){if(!t&&!e)return"";var s=t?Ws(t,n):"",a=e?Ws(e,n):"",r=n.rangeSeparator||uT;return"".concat(s).concat(r).concat(a)}function RU(t,e){if(!(t!=null&&t.length))return"";var n=t[0]?Ws(t[0],e):"";if(t.length===1)return n;if(t.length===2&&t[1]){var s=Ws(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 OU(t){return my(t)}function LU(t,e){return Pn(t,"ddd",e)}function Su(t){return Io(t)}function Oi(t,e,n){var s=ec(e||Cy());return qr(t,{locale:s,weekStartsOn:n})}function Ur(t){return z1(t)}function Cu(t){return ih(t)}function cA(t){return xx(t)}function uA(){return Io(dn())}function dA(t){return B1(t)}function IU(t){return tz(t)}function PU(t){return F1(t)}function Za(t,e){return t&&e?Z3(t,e):!t&&!e}function Ds(t,e){return t&&e?X3(t,e):!t&&!e}function Bp(t,e){return t&&e?J3(t,e):!t&&!e}function rn(t,e){return t&&e?Z4(t,e):!t&&!e}function No(t,e){return t&&e?e3(t,e):!t&&!e}function So(t,e,n){var s,a=Io(e),r=B1(n);try{s=Xu(t,{start:a,end:r})}catch{s=!1}return s}function Cy(){var t=cT();return t.__localeId__}function ec(t){if(typeof t=="string"){var e=cT();return e.__localeData__?e.__localeData__[t]:void 0}else return t}function BU(t,e,n){return e(Pn(t,"EEEE",n))}function FU(t,e){return Pn(t,"EEEEEE",e)}function zU(t,e){return Pn(t,"EEE",e)}function Ay(t,e){return Pn(oa(dn(),t),"LLLL",e)}function dT(t,e){return Pn(oa(dn(),t),"LLL",e)}function $U(t,e){return Pn(Il(dn(),t),"QQQ",e)}function Na(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:cd(t,{minDate:s,maxDate:a})||r&&r.some(function(m){return m instanceof Date?rn(t,m):rn(t,m.date)})||i&&i.some(function(m){var b=m.start,y=m.end;return Xu(t,{start:b,end:y})})||c&&!c.some(function(m){return rn(t,m)})||d&&!d.some(function(m){var b=m.start,y=m.end;return Xu(t,{start:b,end:y})})||f&&!f(dn(t))||!1}function jy(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 Xu(t,{start:i,end:c})}):s&&s.some(function(r){var i;return r instanceof Date?rn(t,r):rn(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 cd(t,{minDate:s?z1(s):void 0,maxDate:a?F1(a):void 0})||(r==null?void 0:r.some(function(d){return Ds(t,d instanceof Date?d:d.date)}))||i&&!i.some(function(d){return Ds(t,d)})||c&&!c(dn(t))||!1}function Uf(t,e,n,s){var a=en(t),r=Vs(t),i=en(e),c=Vs(e),d=en(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 UU(t,e){var n=e===void 0?{}:e,s=n.minDate,a=n.maxDate,r=n.excludeDates,i=n.includeDates;return cd(t,{minDate:s,maxDate:a})||r&&r.some(function(c){return Ds(c instanceof Date?c:c.date,t)})||i&&!i.some(function(c){return Ds(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:cd(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||!Ql(e)||!Ql(n))return!1;var s=en(e),a=en(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 cd(f,{minDate:s?ih(s):void 0,maxDate:a?$1(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=en(t),r=Di(t),i=en(e),c=Di(e),d=en(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 cd(t,e){var n,s=e===void 0?{}:e,a=s.minDate,r=s.maxDate;return(n=a&&Kl(t,a)<0||r&&Kl(t,r)>0)!==null&&n!==void 0?n:!1}function fA(t,e){return e.some(function(n){return As(n)===As(t)&&js(n)===js(t)&&Ri(n)===Ri(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,As(t)),a=ap(a,js(t)),a=rp(a,Ri(t));var r=dn();r=sp(r,As(n)),r=ap(r,js(n)),r=rp(r,Ri(n));var i=dn();i=sp(i,As(s)),i=ap(i,js(s)),i=rp(i,Ri(s));var c;try{c=!Xu(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=To(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=Ua(t,1);return s&&_p(r,s)>0||a&&a.every(function(i){return _p(r,i)>0})||!1}function HU(t,e){var n=e===void 0?{}:e,s=n.minDate,a=n.includeDates,r=ih(t),i=Q1(r);return s&&Ep(s,i)>0||a&&a.every(function(c){return Ep(c,i)>0})||!1}function WU(t,e){var n=e===void 0?{}:e,s=n.maxDate,a=n.includeDates,r=$1(t),i=hy(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=Ii(t,1);return s&&Mp(s,r)>0||a&&a.every(function(i){return Mp(i,r)>0})||!1}function qU(t,e){var n=e===void 0?{}:e,s=n.minDate,a=n.yearItemNumber,r=a===void 0?ld:a,i=Cu(Ii(t,r)),c=Pr(i,r).endPeriod,d=s&&en(s);return d&&d>c||!1}function xA(t,e){var n=e===void 0?{}:e,s=n.maxDate,a=n.includeDates,r=za(t,1);return s&&Mp(r,s)>0||a&&a.every(function(i){return Mp(r,i)>0})||!1}function VU(t,e){var n=e===void 0?{}:e,s=n.maxDate,a=n.yearItemNumber,r=a===void 0?ld:a,i=za(t,r),c=Pr(i,r).startPeriod,d=s&&en(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 Kl(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 Kl(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=Pn(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=Pn(w,"MM.dd.yyyy"),d=s.get(c)||[];d.includes(h)||(d.push(h),s.set(c,d))}}}}return s}function YU(t,e){return t.length!==e.length?!1:t.every(function(n,s){return n===e[s]})}function GU(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=Pn(a,"MM.dd.yyyy"),c=n.get(i)||{className:"",holidayNames:[]};if(!("className"in c&&c.className===e&&YU(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 KU(t,e,n,s,a){for(var r=a.length,i=[],c=0;c<r;c++){var d=t,f=a[c];f&&(d=K4(d,As(f)),d=Qu(d,js(f)),d=J4(d,Ri(f)));var h=Qu(t,(n+1)*s);$r(d,e)&&ar(d,h)&&f!=null&&i.push(f)}return i}function Ml(t){return t<10?"0".concat(t):"".concat(t)}function Pr(t,e){e===void 0&&(e=ld);var n=Math.ceil(en(t)/e)*e,s=n-(e-1);return{startPeriod:s,endPeriod:n}}function QU(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 Ct(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 vb(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===it.Space}var wb=(function(t){Ss(e,t);function e(n){var s=t.call(this,n)||this;return s.inputRef=je.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}):je.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 je.createElement("div",{className:"react-datepicker__input-time-container"},je.createElement("div",{className:"react-datepicker-time__caption"},this.props.timeInputLabel),je.createElement("div",{className:"react-datepicker-time__input-container"},je.createElement("div",{className:"react-datepicker-time__input"},this.renderTimeInput())))},e})(x.Component),XU=(function(t){Ss(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===it.Space&&(s.preventDefault(),s.key=it.Enter),(r=(a=n.props).handleOnKeyDown)===null||r===void 0||r.call(a,s)},n.isSameDay=function(s){return rn(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),Na(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 jy(n.props.day,{excludeDates:n.props.excludeDates,excludeDateIntervals:n.props.excludeDateIntervals})},n.isStartOfWeek=function(){return rn(n.props.day,Oi(n.props.day,n.props.locale,n.props.calendarStartDay))},n.isSameWeek=function(s){return n.props.showWeekPicker&&rn(s,Oi(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=Pn(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=Pn(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:So(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)||No(y,b)))return So(r,y,b);if(c&&h&&($r(y,h)||No(y,h)))return So(r,h,y);if(d&&h&&!b){if(No(y,h)||$r(y,h))return So(r,h,y);if(m&&ar(y,h))return So(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?rn(r,h):f&&d&&i&&h?rn(r,ar(h,i)?h:i):rn(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?rn(r,m):d&&f&&h&&m?rn(r,ar(m,h)?h:m):d?rn(r,m):rn(r,i)},n.isRangeStart=function(){var s=n.props,a=s.day,r=s.startDate,i=s.endDate;return!r||!i?!1:rn(r,a)},n.isRangeEnd=function(){var s=n.props,a=s.day,r=s.startDate,i=s.endDate;return!r||!i?!1:rn(i,a)},n.isWeekend=function(){var s=Qz(n.props.day);return s===0||s===6},n.isAfterMonth=function(){return n.props.month!==void 0&&(n.props.month+1)%12===Vs(n.props.day)},n.isBeforeMonth=function(){return n.props.month!==void 0&&(Vs(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 ps("react-datepicker__day",a,"react-datepicker__day--"+LU(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(Pn(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=Pn(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?rn(h,a):rn(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)&&rn(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 je.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()!==""&&je.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),JU=(function(t){Ss(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===it.Space&&(s.preventDefault(),s.key=it.Enter),(r=(a=n.props).handleOnKeyDown)===null||r===void 0||r.call(a,s)},n.isKeyboardSelected=function(){return!n.props.disabledKeyboardNavigation&&!rn(n.props.date,n.props.selected)&&rn(n.props.date,n.props.preSelection)},n.getTabIndex=function(){return n.props.showWeekPicker&&n.props.showWeekNumber&&(n.isKeyboardSelected()||rn(n.props.date,n.props.selected)&&rn(n.props.preSelection,n.props.selected))?0:-1},n.handleFocusWeekNumber=function(s){var a=!1;n.getTabIndex()===0&&!(s!=null&&s.isInputFocused)&&rn(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&&rn(this.props.date,this.props.selected)};return je.createElement("div",{ref:this.weekNumberEl,className:ps(d),"aria-label":"".concat(i," ").concat(this.props.weekNumber),onClick:this.handleClick,onKeyDown:this.handleOnKeyDown,tabIndex:this.getTabIndex(),role:"gridcell"},s)},e})(x.Component),ZU=(function(t){Ss(e,t);function e(){var n=t!==null&&t.apply(this,arguments)||this;return n.isDisabled=function(s){return Na(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):OU(s)},n.isWeekDisabled=function(){for(var s=n.startOfWeek(),a=Fa(s,6),r=new Date(s);r<=a;){if(!n.isDisabled(r))return!1;r=Fa(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(je.createElement(JU,Yt({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=Fa(s,c);return je.createElement(XU,Yt({},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 Oi(n.props.day,n.props.locale,n.props.calendarStartDay)},n.isKeyboardSelected=function(){return!n.props.disabledKeyboardNavigation&&!rn(n.startOfWeek(),n.props.selected)&&rn(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":rn(this.startOfWeek(),this.props.selected),"react-datepicker__week--keyboard-selected":this.isKeyboardSelected()},s=this.props.weekClassName?this.props.weekClassName(this.startOfWeek()):void 0;return je.createElement("div",{className:ps(n,s),role:"row"},this.renderDays())},e})(x.Component),xu,eH=6,Hl={TWO_COLUMNS:"two_columns",THREE_COLUMNS:"three_columns",FOUR_COLUMNS:"four_columns"},kb=(xu={},xu[Hl.TWO_COLUMNS]={grid:[[0,1],[2,3],[4,5],[6,7],[8,9],[10,11]],verticalNavigationOffset:2},xu[Hl.THREE_COLUMNS]={grid:[[0,1,2],[3,4,5],[6,7,8],[9,10,11]],verticalNavigationOffset:3},xu[Hl.FOUR_COLUMNS]={grid:[[0,1,2,3],[4,5,6,7],[8,9,10,11]],verticalNavigationOffset:4},xu),Vf=1;function kA(t,e){return t?Hl.FOUR_COLUMNS:e?Hl.TWO_COLUMNS:Hl.THREE_COLUMNS}var tH=(function(t){Ss(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 Na(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 jy(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:Ds(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(Il(r,s),i)},n.isRangeEndMonth=function(s){var a=n.props,r=a.day,i=a.startDate,c=a.endDate;return!i||!c?!1:Ds(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(Il(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?Ds(f,h):Ds(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?Ds(h,m):Ds(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=Fa(s,6);return Ds(s,a)||Ds(r,a)},n.isCurrentMonth=function(s,a){return en(s)===en(dn())&&a===Vs(dn())},n.isCurrentQuarter=function(s,a){return en(s)===en(dn())&&a===Di(dn())},n.isSelectedMonth=function(s,a,r){return Vs(r)===a&&en(s)===en(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 Di(r)===a&&en(s)===en(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=Vs(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=Di(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(!qs(n.props.day))return[];for(var s=[],a=n.props.fixedHeight,r=0,i=!1,c=Oi(Ur(n.props.day),n.props.locale,n.props.calendarStartDay),d=function(w){return n.props.showWeekPicker?Oi(w,n.props.locale,n.props.calendarStartDay):n.props.preSelection},f=function(w){return n.props.showWeekPicker?Oi(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(je.createElement(ZU,Yt({},n.props,{ariaLabelPrefix:n.props.weekAriaLabelPrefix,key:r,day:c,month:Vs(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>=eH,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 A=kA(y,w),N=n.getVerticalOffset(A),k=(i=kb[A])===null||i===void 0?void 0:i.grid,j=function(P,O,_){var M,R,F=O,$=_;switch(P){case it.ArrowRight:F=Ua(O,Vf),$=_===11?0:_+Vf;break;case it.ArrowLeft:F=To(O,Vf),$=_===0?11:_-Vf;break;case it.ArrowUp:F=To(O,N),$=!((M=k==null?void 0:k[0])===null||M===void 0)&&M.includes(_)?_+12-N:_-N;break;case it.ArrowDown:F=Ua(O,N),$=!((R=k==null?void 0:k[k.length-1])===null||R===void 0)&&R.includes(_)?_-12+N:_+N;break}return{newCalculatedDate:F,newCalculatedMonth:$}},S=function(P,O,_){for(var M=40,R=P,F=!1,$=0,H=j(R,O,_),L=H.newCalculatedDate,z=H.newCalculatedMonth;!F;){if($>=M){L=O,z=_;break}if(m&&L<m){R=it.ArrowRight;var W=j(R,L,z);L=W.newCalculatedDate,z=W.newCalculatedMonth}if(b&&L>b){R=it.ArrowLeft;var W=j(R,L,z);L=W.newCalculatedDate,z=W.newCalculatedMonth}if(UU(L,n.props)){var W=j(R,L,z);L=W.newCalculatedDate,z=W.newCalculatedMonth}else F=!0;$++}return{newCalculatedDate:L,newCalculatedMonth:z}};if(a===it.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 it.ArrowRight:case it.ArrowLeft:case it.ArrowUp:case it.ArrowDown:n.handleMonthNavigation(E,D);break}}},n.getVerticalOffset=function(s){var a,r;return(r=(a=kb[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!==it.Tab&&s.preventDefault(),i||n.handleKeyboardNavigation(s,d,a),c&&c(s)},n.onQuarterClick=function(s,a){var r=Il(n.props.day,a);Hf(r,n.props)||n.handleDayClick(cA(r),s)},n.onQuarterMouseEnter=function(s){var a=Il(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 it.Enter:n.onQuarterClick(s,a),(i=(r=n.props).setPreSelection)===null||i===void 0||i.call(r,n.props.selected);break;case it.ArrowRight:if(!n.props.preSelection)break;n.handleQuarterNavigation(a===4?1:a+1,hy(n.props.preSelection,1));break;case it.ArrowLeft:if(!n.props.preSelection)break;n.handleQuarterNavigation(a===1?4:a-1,Q1(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 ps("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=Vs(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=Di(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(Pn(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,A=a.disabled,N=(d||f||h||m||b||A)&&Hf(Il(r,s),n.props),k=n.getSelection();return ps("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=Ay(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=$U(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=kb[kA(i,r)])===null||s===void 0?void 0:s.grid;return f==null?void 0:f.map(function(h,m){return je.createElement("div",{className:"react-datepicker__month-wrapper",key:m},h.map(function(b,y){return je.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=it.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 je.createElement("div",{className:"react-datepicker__quarter-wrapper"},i.map(function(c,d){return je.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 ps("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=qs(r)?"".concat(d).concat(Pn(r,"MMMM, yyyy",this.props.locale)):"",h=s||a;return h?je.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()):je.createElement("div",{role:"table"},this.props.dayNamesHeader&&je.createElement("div",{role:"rowgroup"},this.props.dayNamesHeader),this.props.monthHeader&&je.createElement("div",{role:"rowgroup"},this.props.monthHeader),je.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&&je.createElement("div",{role:"rowgroup"},this.props.monthFooter))},e})(x.Component),nH=(function(t){Ss(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 je.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)?je.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 je.createElement(fh,{className:"react-datepicker__month-dropdown",onClickOutside:this.handleClickOutside},this.renderOptions())},e})(x.Component),sH=(function(t){Ss(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 je.createElement("option",{key:a,value:r},a)})},n.renderSelectMode=function(s){return je.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 je.createElement("button",{key:"read",type:"button",style:{visibility:s?"visible":"hidden"},className:"react-datepicker__month-read-view",onClick:n.toggleDropdown},je.createElement("span",{className:"react-datepicker__month-read-view--down-arrow"}),je.createElement("span",{className:"react-datepicker__month-read-view--selected-month"},a[n.props.month]))},n.renderDropdown=function(s){return je.createElement(nH,Yt({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 Ay(r,n.props.locale)}),a;switch(this.props.dropdownMode){case"scroll":a=this.renderScrollMode(s);break;case"select":a=this.renderSelectMode(s);break}return je.createElement("div",{className:"react-datepicker__month-dropdown-container react-datepicker__month-dropdown-container--".concat(this.props.dropdownMode)},a)},e})(x.Component),SA=5;function aH(t,e,n){for(var s=[],a=t??Ii(n,SA),r=e??za(n,SA),i=Ur(a),c=Ur(r);!$r(i,c);)s.push(dn(i)),i=Ua(i,1);return s}var rH=(function(t){Ss(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=vx(a),i=Za(s.props.date,a)&&Ds(s.props.date,a);return je.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?je.createElement("span",{className:"react-datepicker__month-year-option--selected"},"✓"):"",Pn(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:aH(s.props.minDate,s.props.maxDate,s.props.date)},s}return e.prototype.render=function(){var n=ps({"react-datepicker__month-year-dropdown":!0,"react-datepicker__month-year-dropdown--scrollable":this.props.scrollableMonthYearDropdown});return je.createElement(fh,{className:n,onClickOutside:this.handleClickOutside},this.renderOptions())},e})(x.Component),CA=5,iH=(function(t){Ss(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:Ii(n.props.date,CA),i=(a=n.props.maxDate)!==null&&a!==void 0?a:za(n.props.date,CA),c=Ur(r),d=Ur(i),f=[];!$r(c,d);){var h=vx(c);f.push(je.createElement("option",{key:h,value:h},Pn(c,n.props.dateFormat,n.props.locale))),c=Ua(c,1)}return f},n.onSelectChange=function(s){n.onChange(parseInt(s.target.value))},n.renderSelectMode=function(){return je.createElement("select",{value:vx(Ur(n.props.date)),className:"react-datepicker__month-year-select",onChange:n.onSelectChange},n.renderSelectOptions())},n.renderReadView=function(s){var a=Pn(n.props.date,n.props.dateFormat,n.props.locale);return je.createElement("div",{key:"read",style:{visibility:s?"visible":"hidden"},className:"react-datepicker__month-year-read-view",onClick:n.toggleDropdown},je.createElement("span",{className:"react-datepicker__month-year-read-view--down-arrow"}),je.createElement("span",{className:"react-datepicker__month-year-read-view--selected-month-year"},a))},n.renderDropdown=function(){return je.createElement(rH,Yt({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)&&Ds(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 je.createElement("div",{className:"react-datepicker__month-year-dropdown-container react-datepicker__month-year-dropdown-container--".concat(this.props.dropdownMode)},n)},e})(x.Component),oH=(function(t){Ss(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=jo(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&&(As(s)*3600+js(s)*60+Ri(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===it.Space&&(s.preventDefault(),s.key=it.Enter),(s.key===it.ArrowUp||s.key===it.ArrowLeft)&&s.target instanceof HTMLElement&&s.target.previousSibling&&(s.preventDefault(),s.target.previousSibling instanceof HTMLElement&&s.target.previousSibling.focus()),(s.key===it.ArrowDown||s.key===it.ArrowRight)&&s.target instanceof HTMLElement&&s.target.nextSibling&&(s.preventDefault(),s.target.nextSibling instanceof HTMLElement&&s.target.nextSibling.focus()),s.key===it.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=jo(n.props.selected)||jo(n.props.openToDate)||dn(),d=Su(c),f=n.props.injectTimes&&n.props.injectTimes.sort(function(N,k){return N.getTime()-k.getTime()}),h=60*QU(c),m=h/i,b=0;b<m;b++){var y=Qu(d,b*i);if(a.push(y),f){var w=KU(d,y,b,i,f);a=a.concat(w)}}var A=a.reduce(function(N,k){return k.getTime()<=c.getTime()?k:N},a[0]);return a.map(function(N){return je.createElement("li",{key:N.valueOf(),onClick:n.handleClick.bind(n,N),className:n.liClasses(N),ref:function(k){N===A&&(n.centerLi=k)},onKeyDown:function(k){n.handleOnKeyDown(k,N)},tabIndex:N===A?0:-1,role:"option","aria-selected":n.isSelectedTime(N)?"true":void 0,"aria-disabled":n.isDisabledTime(N)?"true":void 0},Pn(N,r,n.props.locale))})},n.renderTimeCaption=function(){return n.props.showTimeCaption===!1?je.createElement(je.Fragment,null):je.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}},je.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 je.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(),je.createElement("div",{className:"react-datepicker__time"},je.createElement("div",{className:"react-datepicker__time-box"},je.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,lH=(function(t){Ss(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 Na(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 jy(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 rn(a,r)},s.isCurrentYear=function(a){return a===en(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=Cu(Ja(s.props.date,a)),y=(i||c||d||f||h)&&op(a,s.props),w=!!m&&rn(b,Cu(m)),A=rn(b,Cu(s.props.preSelection));return!s.props.inline&&!w&&A&&!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===en(f)}):!!c&&a===en(c)},s.onYearClick=function(a,r){var i=s.props.date;i!==void 0&&s.handleYearClick(Cu(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!==it.Tab&&a.preventDefault(),!s.props.disabledKeyboardNavigation)switch(d){case it.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 it.ArrowRight:if(s.props.preSelection==null)break;s.handleYearNavigation(r+1,za(s.props.preSelection,1));break;case it.ArrowLeft:if(s.props.preSelection==null)break;s.handleYearNavigation(r-1,Ii(s.props.preSelection,1));break;case it.ArrowUp:{if(h===void 0||m===void 0||s.props.preSelection==null)break;var y=Pr(h,m).startPeriod,w=AA,A=r-w;if(A<y){var N=m%w;r>=y&&r<y+N?w=N:w+=N,A=r-w}s.handleYearNavigation(A,Ii(s.props.preSelection,w));break}case it.ArrowDown:{if(h===void 0||m===void 0||s.props.preSelection==null)break;var k=Pr(h,m).endPeriod,w=AA,A=r+w;if(A>k){var N=m%w;r<=k&&r>k-N?w=N:w+=N,A=r+w}s.handleYearNavigation(A,za(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 ps("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=en(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(A){s.push(je.createElement("div",{ref:y.YEAR_REFS[A-h],onClick:function(N){n.onYearClick(N,A)},onKeyDown:function(N){gT(N)&&(N.preventDefault(),N.key=it.Enter),n.onYearKeyDown(N,A)},tabIndex:Number(y.getYearTabIndex(A)),className:y.getYearClassNames(A),onMouseEnter:y.props.usePointerEvent?void 0:function(N){return c(N,A)},onPointerEnter:y.props.usePointerEvent?function(N){return c(N,A)}:void 0,onMouseLeave:y.props.usePointerEvent?void 0:function(N){return d(N,A)},onPointerLeave:y.props.usePointerEvent?function(N){return d(N,A)}:void 0,key:A,"aria-current":y.isCurrentYear(A)?"date":void 0},y.getYearContent(A)))},y=this,w=h;w<=m;w++)b(w);return je.createElement("div",{className:"react-datepicker__year"},je.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 cH(t,e,n,s){for(var a=[],r=0;r<2*e+1;r++){var i=t+e-r,c=!0;n&&(c=en(n)<=i),s&&c&&(c=en(s)>=i),c&&a.push(i)}return a}var uH=(function(t){Ss(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 je.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?je.createElement("span",{className:"react-datepicker__year-option--selected"},"✓"):"",m)}),f=s.props.minDate?en(s.props.minDate):null,h=s.props.maxDate?en(s.props.maxDate):null;return(!h||!s.state.yearsList.find(function(m){return m===h}))&&d.unshift(je.createElement("div",{className:"react-datepicker__year-option",key:"upcoming",onClick:s.incrementYears},je.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(je.createElement("div",{className:"react-datepicker__year-option",key:"previous",onClick:s.decrementYears},je.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:cH(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=ps({"react-datepicker__year-dropdown":!0,"react-datepicker__year-dropdown--scrollable":this.props.scrollableYearDropdown});return je.createElement(fh,{className:n,containerRef:this.dropdownRef,onClickOutside:this.handleClickOutside},this.renderOptions())},e})(x.Component),dH=(function(t){Ss(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?en(n.props.minDate):1900,a=n.props.maxDate?en(n.props.maxDate):2100,r=[],i=s;i<=a;i++)r.push(je.createElement("option",{key:i,value:i},i));return r},n.onSelectChange=function(s){n.onChange(parseInt(s.target.value))},n.renderSelectMode=function(){return je.createElement("select",{value:n.props.year,className:"react-datepicker__year-select",onChange:n.onSelectChange},n.renderSelectOptions())},n.renderReadView=function(s){return je.createElement("button",{key:"read",type:"button",style:{visibility:s?"visible":"hidden"},className:"react-datepicker__year-read-view",onClick:n.toggleDropdown},je.createElement("span",{className:"react-datepicker__year-read-view--down-arrow"}),je.createElement("span",{className:"react-datepicker__year-read-view--selected-year"},n.props.year))},n.renderDropdown=function(){return je.createElement(uH,Yt({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 je.createElement("div",{className:"react-datepicker__year-dropdown-container react-datepicker__year-dropdown-container--".concat(this.props.dropdownMode)},n)},e})(x.Component),fH=["react-datepicker__year-select","react-datepicker__month-select","react-datepicker__month-year-select"],bT="react-datepicker-ignore-onclickoutside",pH=function(t){var e=(t.className||"").split(/\s+/);return fH.some(function(n){return e.indexOf(n)>=0})},hH=(function(t){Ss(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;pH(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:Ua(r,1)}},function(){return s.handleMonthChange(s.state.date)})},s.decreaseMonth=function(){s.setState(function(a){var r=a.date;return{date:To(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(!Na(a,s.props))return a;for(var r=Ur(a),i=PU(a),c=ez(i,r),d=null,f=0;f<=c;f++){var h=Fa(r,f);if(!Na(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,Vs(a)),en(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),!qs(a))return[];var i=s.props.disabled,c=Oi(a,s.props.locale,s.props.calendarStartDay),d=[];return s.props.showWeekNumbers&&d.push(je.createElement("div",{key:"W",className:"react-datepicker__day-name ".concat(i?"react-datepicker__day-name--disabled":""),role:"columnheader"},je.createElement("span",{className:"react-datepicker__sr-only"},"Week number"),je.createElement("span",{"aria-hidden":"true"},s.props.weekLabel||"#"))),d.concat([0,1,2,3,4,5,6].map(function(f){var h=Fa(c,f),m=s.formatWeekday(h,s.props.locale),b=Pn(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 je.createElement("div",{key:f,role:"columnheader",className:ps("react-datepicker__day-name",y,i?"react-datepicker__day-name--disabled":"")},w)}return je.createElement("div",{key:f,role:"columnheader",className:ps("react-datepicker__day-name",y,i?"react-datepicker__day-name--disabled":"")},je.createElement("span",{className:"react-datepicker__sr-only"},b),je.createElement("span",{"aria-hidden":"true"},m))}))},s.formatWeekday=function(a,r){return s.props.formatWeekDay?BU(a,s.props.formatWeekDay,r):s.props.useWeekdaysShort?zU(a,r):FU(a,r)},s.decreaseYear=function(){s.setState(function(a){var r,i=a.date;return{date:Ii(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=To(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=qU(s.state.date,s.props);break;case s.props.showQuarterYearPicker:m=HU(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 A=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,P=E===void 0?typeof j=="string"?j:"Previous Month":E,O=D.previousYearAriaLabel,_=O===void 0?typeof T=="string"?T:"Previous Year":O;return je.createElement("button",{type:"button",className:y.join(" "),onClick:w,onKeyDown:s.props.handleOnKeyDown,"aria-label":A?_:P},je.createElement("span",{className:b.join(" ")},A?T:j))}}},s.increaseYear=function(){s.setState(function(a){var r,i=a.date;return{date:za(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=VU(s.state.date,s.props);break;case s.props.showQuarterYearPicker:r=WU(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,A=s.props,N=A.nextMonthAriaLabel,k=N===void 0?typeof b=="string"?b:"Next Month":N,j=A.nextYearAriaLabel,S=j===void 0?typeof w=="string"?w:"Next Year":j;return je.createElement("button",{type:"button",className:i.join(" "),onClick:d,onKeyDown:s.props.handleOnKeyDown,"aria-label":f?S:k},je.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"),je.createElement("h2",{className:r.join(" ")},qs(a)?Pn(a,s.props.dateFormat,s.props.locale):"")},s.renderYearDropdown=function(a){if(a===void 0&&(a=!1),!(!s.props.showYearDropdown||a))return je.createElement(dH,Yt({},e.defaultProps,s.props,{date:s.state.date,onChange:s.changeYear,year:en(s.state.date)}))},s.renderMonthDropdown=function(a){if(a===void 0&&(a=!1),!(!s.props.showMonthDropdown||a))return je.createElement(sH,Yt({},e.defaultProps,s.props,{month:Vs(s.state.date),onChange:s.changeMonth}))},s.renderMonthYearDropdown=function(a){if(a===void 0&&(a=!1),!(!s.props.showMonthYearDropdown||a))return je.createElement(iH,Yt({},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 je.createElement("div",{className:"react-datepicker__today-button",onClick:s.handleTodayButtonClick},s.props.todayButton)},s.renderDayNamesHeader=function(a,r){return r===void 0&&(r=0),je.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=je.createElement("div",{className:ps("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),je.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:je.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,A=y.endPeriod;b={startYear:w,endYear:A}}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 je.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,Yt(Yt(Yt({},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 je.createElement("div",{className:"react-datepicker__header react-datepicker-year-header"},c?"".concat(m," - ").concat(b):en(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?za(s.state.date,d):To(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?za(f,b):Ua(f,b),w="month-".concat(m),A=m<c-1,N=m>0;i.push(je.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}),je.createElement(tH,Yt({},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:A,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 je.createElement("div",{className:"react-datepicker__year--container"},s.renderHeader({monthDate:s.state.date}),je.createElement(lH,Yt({},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 je.createElement(oH,Yt({},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&&qs(f)&&!!c,m=h?"".concat(Ml(f.getHours()),":").concat(Ml(f.getMinutes())):"",b=d?new Date(d):void 0,y=b&&qs(b)&&!!d,w=y?"".concat(Ml(b.getHours()),":").concat(Ml(b.getMinutes())):"";return je.createElement(je.Fragment,null,je.createElement(wb,Yt({},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)"})),je.createElement(wb,Yt({},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 A=s.props.selected?new Date(s.props.selected):void 0,N=A&&qs(A)&&!!s.props.selected,k=N?"".concat(Ml(A.getHours()),":").concat(Ml(A.getMinutes())):"";return je.createElement(wb,Yt({},e.defaultProps,s.props,{date:A,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(!qs(s.state.date))return je.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=en(s.state.date):d="".concat(Ay(Vs(s.state.date),s.props.locale)," ").concat(en(s.state.date)),je.createElement("span",{role:"alert","aria-live":"polite",className:"react-datepicker__aria-live"},s.state.isRenderAriaLiveMessage&&d)},s.renderChildren=function(){if(s.props.children)return je.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:ld,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&&qs(this.props.preSelection)&&(!rn(this.props.preSelection,n.preSelection)||this.props.monthSelectedIn!==n.monthSelectedIn)){var a=!Ds(this.state.date,this.props.preSelection);this.setState({date:this.props.preSelection},function(){return a&&s.handleCustomMonthChange(s.state.date)})}else this.props.openToDate&&!rn(this.props.openToDate,n.openToDate)&&this.setState({date:this.props.openToDate})},e.prototype.render=function(){var n=this.props.container||_U;return je.createElement(fh,{onClickOutside:this.handleClickOutside,style:{display:"contents"},ignoreClass:this.props.outsideClickIgnoreClass},je.createElement("div",{style:{display:"contents"},ref:this.containerRef},je.createElement(n,{className:ps("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),mH=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 je.createElement("i",{className:"".concat(r," ").concat(e," ").concat(s),"aria-hidden":"true",onClick:a});if(je.isValidElement(e)){var i=e;return je.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 je.createElement("svg",{className:"".concat(r," ").concat(s),xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",onClick:a},je.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){Ss(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 A2.createPortal(this.props.children,this.el)},e})(x.Component),gH="[tabindex], a, button, input, select, textarea",bH=function(t){return(t instanceof HTMLAnchorElement||!t.disabled)&&t.tabIndex!==-1},yT=(function(t){Ss(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(gH),1,-1).filter(bH)},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)?je.createElement("div",{className:"react-datepicker__tab-loop",ref:this.tabLoopRef},je.createElement("div",{className:"react-datepicker__tab-loop__start",tabIndex:0,onFocus:this.handleFocusStart}),this.props.children,je.createElement("div",{className:"react-datepicker__tab-loop__end",tabIndex:0,onFocus:this.handleFocusEnd})):this.props.children},e.defaultProps={enableTabLoop:!0},e})(x.Component);function xH(t){function e(n){var s,a=typeof n.hidePopper=="boolean"?n.hidePopper:!0,r=x.useRef(null),i=TU(Yt({open:!a,whileElementsMounted:iU,placement:n.popperPlacement,middleware:rr([mU({padding:15}),hU(10),gU({element:r})],(s=n.popperModifiers)!==null&&s!==void 0?s:[],!0)},n.popperProps)),c=Yt(Yt({},n),{hidePopper:a,popperProps:Yt(Yt({},i),{arrowRef:r})});return je.createElement(t,Yt({},c))}return e.displayName="withFloating(".concat(t.displayName||t.name||"Component",")"),e}var yH=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 A=void 0;if(!a){var N=ps("react-datepicker-popper",!b&&"react-datepicker-popper-offset",w==="middle"&&"react-datepicker-popper--header-middle",w==="bottom"&&"react-datepicker-popper--header-bottom",e);A=je.createElement(yT,{enableTabLoop:c},je.createElement("div",{ref:m.refs.setFloating,style:m.floatingStyles,className:N,"data-placement":m.placement,onKeyDown:d},r,b&&je.createElement(wU,{ref:m.arrowRef,context:m.context,fill:"currentColor",strokeWidth:1,height:8,width:16,style:{transform:"translateY(-1px)"},className:"react-datepicker__triangle"})))}t.popperContainer&&(A=x.createElement(t.popperContainer,{},A)),f&&!a&&(A=je.createElement(xT,{portalId:f,portalHost:h},A));var k=ps("react-datepicker-wrapper",n);return je.createElement(je.Fragment,null,je.createElement("div",{ref:m.refs.setReference,className:k},i),A)},vH=xH(yH);function jA(t,e){return t&&e?Vs(t)!==Vs(e)||en(t)!==en(e):t!==e}var Sb="Date input not valid.",wH=(function(t){Ss(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=vo(i.date,"yyyy-MM-dd",void 0,!1);return c?rr(rr([],r,!0),[Yt(Yt({},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,Su(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,A=r.value,N=(a=s.props.dateFormat)!==null&&a!==void 0?a:e.defaultProps.dateFormat,k=s.state.inputValue;if(typeof A=="string")return A;if(typeof k=="string")return k;if(y)return DU(c,d,{dateFormat:N,locale:i,rangeSeparator:f});if(b){if(w){var j=function(S){return Ws(S,{dateFormat:N,locale:i})};return w(m??[],j)}return RU(m??[],{dateFormat:N,locale:i})}return Ws(h,{dateFormat:N,locale:i})},s.resetHiddenStatus=function(){s.setState(Yt(Yt({},s.state),{wasHidden:!1}))},s.setHiddenStatus=function(){s.setState(Yt(Yt({},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:Cb},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(Yt(Yt({},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:kH});var A=s.props,N=A.selectsRange,k=A.startDate,j=A.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,P=E.trim(),O=D.split(S.includes(P)?E:P,2).map(function(W){return W.trim()}),_=O[0],M=O[1],R=vo(_??"",S,s.props.locale,T),F=R?vo(M??"",S,s.props.locale,T):null,$=((i=jo(k))===null||i===void 0?void 0:i.getTime())!==(R==null?void 0:R.getTime()),H=((c=jo(j))===null||c===void 0?void 0:c.getTime())!==(F==null?void 0:F.getTime());if(!$&&!H||R&&Na(R,s.props)||F&&Na(F,s.props))return;R&&s.setState({preSelection:R}),(f=(d=s.props).onChange)===null||f===void 0||f.call(d,[R,F],w)}else{var L=vo(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 z=MU(D,(m=s.state.preSelection)!==null&&m!==void 0?m:void 0);z&&(!s.props.minDate||!ar(z,s.props.minDate))&&(!s.props.maxDate||!$r(z,s.props.maxDate))&&s.setState({preSelection:z})}}}},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,A=!f||h&&!m&&(y||!vb(a,h));if(s.props.shouldCloseOnSelect&&!s.props.showTimeSelect&&A&&s.sendFocusBackToInput(),s.props.onChangeRaw){var N=Ws(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):A&&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(en(m),s.props))return}else if(s.props.showMonthYearPicker){if(m!==null&&fT(m,s.props))return}else if(m!==null&&Na(m,s.props))return;var b=s.props,y=b.onChange,w=b.selectsRange,A=b.startDate,N=b.endDate,k=b.selectsMultiple,j=b.selectedDates,S=b.minTime,T=b.swapRange;if(!No(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:As(s.props.selected),minute:js(s.props.selected),second:Ri(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=!A&&!N,P=A&&!N,O=!A&&!!N,_=A&&N;E?D==null||D([m,null],r):P?m===null?D==null||D([null,null],r):vb(m,A)?T?D==null||D([m,A],r):D==null||D([m,null],r):D==null||D([A,m],r):O&&(m&&vb(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 rn($,m)});if(R){var F=j.filter(function($){return!rn($,m)});M==null||M(F,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=Su(a);if(r&&i)c=So(a,s.props.minDate,s.props.maxDate);else if(r){var f=Su(s.props.minDate);c=$r(a,f)||No(d,f)}else if(i){var h=dA(s.props.maxDate);c=ar(a,h)||No(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 A=Lr(h,{hour:As(a),minute:js(a)});s.setState({preSelection:A}),y&&(A=Or(A,y)),w==null||w([A,m?y?Or(m,y):m:null],void 0)}}else if(r==="end"){if(m){var N=Lr(m,{hour:As(a),minute:js(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 A=Lr(h,{hour:As(a),minute:js(a)});s.setState({preSelection:A}),y&&(A=Or(A,y)),w==null||w([A,null],void 0)}else if(h&&m){var N=Lr(m,{hour:As(a),minute:js(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:As(a),minute:js(a)});s.setState({preSelection:j})}}}else{var S=s.props.selected?s.props.selected:s.getPreSelection(),j=s.props.selected?a:Lr(S,{hour:As(a),minute:js(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=jo(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=Su(f),w=As(f)*60+js(f),A=1440-h,N;if(a===it.ArrowUp){var k=Math.max(0,w-h);N=Qu(y,k)}else{var k=Math.min(A,w+h);N=Qu(y,k)}var j=Pn(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:As(N),minute:js(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||jo(s.props.selected)||dn(),w=vo(h,m,s.props.locale,(i=s.props.strictParsing)!==null&&i!==void 0?i:!1,y),A=y;if(w&&qs(w))A=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=vo(k,b,s.props.locale,!1,y);j&&qs(j)&&(A=j)}}}s.handleTimeChange(A),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],A=(i=w.textContent)===null||i===void 0?void 0:i.trim();if(A){var N=vo(A,m,s.props.locale,!1,a);if(N&&qs(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===it.ArrowDown||m===it.ArrowUp||m===it.Enter)&&((c=s.onInputClick)===null||c===void 0||c.call(s));return}if(s.state.open&&s.props.showTimeSelectOnly){if(m===it.ArrowDown||m===it.ArrowUp){a.preventDefault(),s.handleTimeOnlyArrowKey(m);return}if(m===it.Enter){a.preventDefault(),s.handleTimeOnlyEnterKey(a);return}}if(s.state.open){if(m===it.ArrowDown||m===it.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===it.Enter?(a.preventDefault(),a.target.blur(),s.inputOk()&&s.state.lastPreSelectChange===Cb?(s.handleSelect(w,a),!s.props.shouldCloseOnSelect&&s.setPreSelection(w)):s.setOpen(!1)):m===it.Escape?(a.preventDefault(),a.target.blur(),s.sendFocusBackToInput(),s.setOpen(!1)):m===it.Tab&&s.setOpen(!1),s.inputOk()||(h=(f=s.props).onInputError)===null||h===void 0||h.call(f,{code:1,msg:Sb})}},s.onPortalKeyDown=function(a){var r=a.key;r===it.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,A=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,P=dn(s.state.preSelection),O=function(R,F){var $=F;switch(R){case it.ArrowRight:$=A?Tp(F,1):Fa(F,1);break;case it.ArrowLeft:$=A?KC(F):e$(F);break;case it.ArrowUp:$=KC(F);break;case it.ArrowDown:$=Tp(F,1);break;case it.PageUp:$=E?Ii(F,1):To(F,1);break;case it.PageDown:$=E?za(F,1):Ua(F,1);break;case it.Home:$=Oi(F,k,j);break;case it.End:$=IU(F);break}return $},_=function(R,F){for(var $=40,H=R,L=!1,z=0,W=O(R,F);!L;){if(z>=$){W=F;break}b&&W<b&&(H=it.ArrowRight,W=Na(b,s.props)?O(H,W):b),y&&W>y&&(H=it.ArrowLeft,W=Na(y,s.props)?O(H,W):y),Na(W,s.props)?((H===it.PageUp||H===it.Home)&&(H=it.ArrowRight),(H===it.PageDown||H===it.End)&&(H=it.ArrowLeft),W=O(H,W)):L=!0,z++}return W};if(D===it.Enter){a.preventDefault(),s.handleSelect(P,a),!N&&s.setPreSelection(P);return}else if(D===it.Escape){a.preventDefault(),s.setOpen(!1),s.inputOk()||(d=(c=s.props).onInputError)===null||d===void 0||d.call(c,{code:1,msg:Sb});return}var M=null;switch(D){case it.ArrowLeft:case it.ArrowRight:case it.ArrowUp:case it.ArrowDown:case it.PageUp:case it.PageDown:case it.Home:case it.End:M=_(D,P);break}if(!M){(h=(f=s.props).onInputError)===null||h===void 0||h.call(f,{code:1,msg:Sb});return}a.preventDefault(),s.setState({lastPreSelectChange:Cb}),S&&s.setSelected(M),s.setPreSelection(M),T&&s.setState({shouldFocusDayInline:!0})}},s.onPopperKeyDown=function(a){var r=a.key;r===it.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:je.createElement(hH,Yt({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:GU(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(Ws(s.props.startDate,{dateFormat:d,locale:r}),". ").concat(s.props.endDate?"End date: "+Ws(s.props.endDate,{dateFormat:d,locale:r}):""):s.props.showTimeSelectOnly?f="Selected time: ".concat(Ws(s.props.selected,{dateFormat:i,locale:r})):s.props.showYearPicker?f="Selected year: ".concat(Ws(s.props.selected,{dateFormat:"yyyy",locale:r})):s.props.showMonthYearPicker?f="Selected month: ".concat(Ws(s.props.selected,{dateFormat:"MMMM yyyy",locale:r})):s.props.showQuarterYearPicker?f="Selected quarter: ".concat(Ws(s.props.selected,{dateFormat:"yyyy, QQQ",locale:r})):f="Selected date: ".concat(Ws(s.props.selected,{dateFormat:d,locale:r})),je.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=ps(s.props.className,(a={},a[s.props.outsideClickIgnoreClass||e.defaultProps.outsideClickIgnoreClass]=s.state.open,a)),b=s.props.customInput||je.createElement("input",{type:"text"}),y=s.props.customInputRef||"ref",w={},A=(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 A!=null&&(w["aria-describedby"]=A),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,Yt((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=ps(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,A=a.selectedDates,N=a.readOnly;return r&&!N&&(c!=null||d!=null||f!=null||A!=null&&A.length)?je.createElement("button",{type:"button",className:ps("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:ld,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&&!No(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."),je.createElement("div",{className:"react-datepicker__input-container".concat(s?" react-datepicker__view-calendar-icon":"")},s&&je.createElement(mH,Yt({icon:a,className:ps(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?je.createElement(yT,{enableTabLoop:this.props.enableTabLoop},je.createElement("div",{className:"react-datepicker__portal",tabIndex:-1,onKeyDown:this.onPortalKeyDown},n)):null;return this.state.open&&this.props.portalId&&(s=je.createElement(xT,Yt({portalId:this.props.portalId},this.props),s)),je.createElement(je.Fragment,null,this.renderInputContainer(),s)}return je.createElement(vH,Yt({},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),kH="input",Cb="navigate";const SH=[25,50,100,250,500,1e3],CH=250,yu=t=>String(t).padStart(2,"0"),Yf=t=>t?/(datetime|timestamp|timestamptz|datetime2|smalldatetime)/i.test(t):!1,NA=t=>`${t.getFullYear()}-${yu(t.getMonth()+1)}-${yu(t.getDate())} ${yu(t.getHours())}:${yu(t.getMinutes())}:${yu(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},AH=t=>t===null?"NULL":t===void 0?"undefined":typeof t=="object"?JSON.stringify(t,null,2):String(t),jH=t=>t==null?"":typeof t=="object"?JSON.stringify(t):String(t),NH=t=>{const e=t.match(/FROM\s+(?:`?[\w]+`?\.)?`?([\w]+)`?(?:\s+(?:AS\s+)?\w+)?(?=\s|;|$)/i);return e!=null&&e[1]?e[1]:null},Ab=t=>!t||!t.columns?[]:t.columns.filter(e=>e.primaryKey).map(e=>e.name),TH=(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}`},_H=({result:t,buildingId:e,building:n})=>{var ae,Se;const{t:s}=pt(["terminal"]),a=Kx(e),[r,i]=x.useState(0),[c,d]=x.useState(CH),[f,h]=x.useState(null),[m,b]=x.useState("asc"),[y,w]=x.useState(null),[A,N]=x.useState(!1),[k,j]=x.useState({}),[S,T]=x.useState(null),[D,E]=x.useState(null),[P,O]=x.useState(null),[_,M]=x.useState(!1),[R,F]=x.useState(null),[$,H]=x.useState(null),[L,z]=x.useState(new Map),[W,V]=x.useState(null),[G,B]=x.useState(null),K=x.useRef(null),se=x.useRef(null),q=x.useRef(null),me=x.useRef(!1),ce=t.status==="error",ee=!t.rows||t.rows.length===0;x.useEffect(()=>{var he,De;const Z=NH(t.query||"");if(E(Z),M(!1),O(null),z(new Map),Z&&a.activeConnectionId&&a.activeDatabase){const ze=`${a.activeConnectionId}:${a.activeDatabase}:${Z}`,be=(De=(he=a.tableSchemas)==null?void 0:he.get)==null?void 0:De.call(he,ze);if(be){O(be);const Pe=Ab(be);M(Pe.length>0)}else U.getTableSchema(e,a.activeConnectionId,a.activeDatabase,Z)}},[t.query,t.rows,e,a.activeConnectionId,a.activeDatabase]),x.useEffect(()=>{var Z,he;if(D&&a.activeConnectionId&&a.activeDatabase){const De=`${a.activeConnectionId}:${a.activeDatabase}:${D}`,ze=(he=(Z=a.tableSchemas)==null?void 0:Z.get)==null?void 0:he.call(Z,De);if(ze){O(Pe=>Pe===ze?Pe:ze);const be=Ab(ze);M(be.length>0)}}},[a.tableSchemas,D,a.activeConnectionId,a.activeDatabase]);const pe=x.useMemo(()=>!f||!t.rows?t.rows:[...t.rows].sort((Z,he)=>{const De=Z[f],ze=he[f];if(De===null&&ze===null)return 0;if(De===null)return m==="asc"?-1:1;if(ze===null)return m==="asc"?1:-1;if(typeof De=="number"&&typeof ze=="number")return m==="asc"?De-ze:ze-De;const be=String(De),Pe=String(ze);return m==="asc"?be.localeCompare(Pe):Pe.localeCompare(be)}),[t.rows,f,m]),Ne=x.useMemo(()=>{if(!pe)return[];const Z=r*c;return pe.slice(Z,Z+c)},[pe,r,c]),ye=Math.ceil(((pe==null?void 0:pe.length)??0)/c),Me=((ae=t.fields)==null?void 0:ae.map(Z=>Z.name))??Object.keys(((Se=t.rows)==null?void 0:Se[0])||{}),qe=x.useMemo(()=>{const Z=new Map;return(t.fields??[]).forEach(he=>{he!=null&&he.name&&Z.set(he.name,String(he.type??""))}),Z},[t.fields]),He=x.useMemo(()=>Ab(P),[P]),X=x.useCallback((Z,he)=>{const De=qe.get(Z);if(Yf(De)){const ze=TA(he);return ze?NA(ze):""}return jH(he)},[qe]),ne=x.useMemo(()=>_?"Editable":!a.activeConnectionId||!a.activeDatabase?"Read-only: no active connection or database":D?P?He.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,P,He.length]),Te=x.useCallback(Z=>{if(me.current){me.current=!1;return}f===Z?b(he=>he==="asc"?"desc":"asc"):(h(Z),b("asc"))},[f]),We=x.useCallback((Z,he,De,ze)=>{!_||S||G||T({rowIndex:De,rowKey:ze,columnName:Z,originalValue:he,currentValue:X(Z,he),isUpdating:!1})},[_,S,G,X]),nt=x.useCallback((Z,he)=>{w({column:Z,value:he})},[]),we=x.useCallback(Z=>{var Kt,Ce;if(!D||!P||!a.activeConnectionId||!a.activeDatabase)return;const{rowIndex:he,columnName:De,originalValue:ze,currentValue:be}=Z,Pe=String(be??"");if(be!==null&&Pe===X(De,ze)){T(null);return}const te=r*c+he,ge=pe==null?void 0:pe[te];if(!ge)return;const ve=He;if(ve.length===0){T(Be=>Be?{...Be,error:"No primary key found"}:null);return}const Fe={};for(const Be of ve)Fe[Be]=ge[Be];let Ke=Pe;const st=qe.get(De);if(be===null)Ke=null;else if(Yf(st))Ke=Pe.trim()===""?null:Pe.trim();else if(typeof ze=="number")if(Pe.trim()==="")Ke=null;else{const Be=Number(Pe);if(Number.isNaN(Be)){T(Ye=>Ye?{...Ye,isUpdating:!1,error:"Invalid number value"}:null);return}Ke=Be}else if(typeof ze=="boolean"){const Be=Pe.trim().toLowerCase();if(Be==="true"||Be==="1")Ke=!0;else if(Be==="false"||Be==="0")Ke=!1;else{T(Ye=>Ye?{...Ye,isUpdating:!1,error:"Invalid boolean value"}:null);return}}else if(ze!==null&&typeof ze=="object")try{Ke=JSON.parse(Pe)}catch{T(Be=>Be?{...Be,isUpdating:!1,error:"Invalid JSON value"}:null);return}T(Be=>Be?{...Be,isUpdating:!0}:null);const xt=(Kt=n.database)==null?void 0:Kt.connections.find(Be=>Be.id===a.activeConnectionId),ht=(xt==null?void 0:xt.engine)||"mysql",ot=TH(ht,D,De,Fe,ze,Ke,!Yf(st));H(ot);const ft=JSON.stringify(Fe),ut=((Ce=t.query)==null?void 0:Ce.trim())||"",ln=`${Date.now()}-${Math.random().toString(36).slice(2,10)}`;B({requestId:ln,query:ot,rowKey:ft,columnName:De,parsedValue:Ke,startedAt:Date.now(),originalQuery:ut}),U.executeSilentQuery(e,a.activeConnectionId,a.activeDatabase,ot,ln)},[D,P,r,c,pe,He,e,a.activeConnectionId,a.activeDatabase,t.query,X,qe]);x.useEffect(()=>{const Z=a.lastSilentQueryResult;if(!(!G||!Z)&&!(Z.requestId&&Z.requestId!==G.requestId)&&!(Z.timestamp<G.startedAt)){if(!Z.success){F({message:Z.error||"Update failed on backend",type:"error"}),setTimeout(()=>F(null),5e3),T(he=>he&&{...he,isUpdating:!1,error:Z.error||"Update failed on backend"}),B(null);return}if(Z.affectedRows===0){F({message:"No rows were updated",type:"error"}),setTimeout(()=>F(null),5e3),T(he=>he&&{...he,isUpdating:!1,error:"No rows were updated"}),B(null);return}z(he=>{const De=new Map(he),ze=De.get(G.rowKey)||{};return ze[G.columnName]=G.parsedValue,De.set(G.rowKey,ze),De}),T(null),F({message:"Row updated successfully",type:"success"}),setTimeout(()=>F(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 Z=window.setTimeout(()=>{F({message:"Update timed out waiting for backend",type:"error"}),setTimeout(()=>F(null),5e3),T(he=>he&&{...he,isUpdating:!1,error:"Update timed out waiting for backend"}),B(null)},1e4);return()=>window.clearTimeout(Z)},[G]);const Le=x.useCallback(()=>{S&&we(S)},[S,we]),ie=x.useCallback((Z,he,De,ze,be)=>{Z.preventDefault(),Z.stopPropagation(),V({position:{x:Z.clientX,y:Z.clientY},rowIndex:ze,rowKey:be,columnName:he,value:De})},[S,D,P,r,c,pe,He,e,a.activeConnectionId,a.activeDatabase]),de=x.useMemo(()=>{if(!W)return[];const Z=!_||!!S||!!G||!D||!P||!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:Z,onClick:()=>{T({rowIndex:W.rowIndex,rowKey:W.rowKey,columnName:W.columnName,originalValue:W.value,currentValue:X(W.columnName,W.value),isUpdating:!1})}},{id:"set-null",label:"Set NULL",icon:"∅",disabled:Z||W.value===null,onClick:()=>{we({rowIndex:W.rowIndex,rowKey:W.rowKey,columnName:W.columnName,originalValue:W.value,currentValue:null,isUpdating:!1})}}]},[W,_,S,G,D,P,a.activeConnectionId,a.activeDatabase,ne,we,X]),Ue=x.useCallback(Z=>{Z.key==="Enter"?(Z.preventDefault(),Le()):Z.key==="Escape"&&(Z.preventDefault(),Z.stopPropagation(),T(null))},[Le]),Ze=x.useCallback((Z,he)=>{Z.preventDefault(),Z.stopPropagation();const De=Z.target.closest("th");if(!De)return;const ze=De.getBoundingClientRect().width;q.current={column:he,startX:Z.clientX,startWidth:ze};const be=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,me.current=!0,document.removeEventListener("mousemove",be),document.removeEventListener("mouseup",Pe),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",be),document.addEventListener("mouseup",Pe),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]);x.useEffect(()=>{if(!y)return;const Z=De=>{De.key==="Escape"&&(De.stopPropagation(),w(null))},he=De=>{K.current&&!K.current.contains(De.target)&&w(null)};return document.addEventListener("keydown",Z),document.addEventListener("mousedown",he),()=>{document.removeEventListener("keydown",Z),document.removeEventListener("mousedown",he)}},[y]);const lt=S?`${S.rowKey}:${S.columnName}`:null;x.useEffect(()=>{se.current&&lt&&(se.current.focus(),se.current.select())},[lt]);const fe=x.useCallback(async()=>{var be;if(!t.rows||t.rows.length===0)return;const Z=((be=t.fields)==null?void 0:be.map(Pe=>Pe.name))??Object.keys(t.rows[0]||{}),he=pe??t.rows,De=["<table><thead><tr>"];Z.forEach(Pe=>De.push(`<th>${Pe}</th>`)),De.push("</tr></thead><tbody>"),he.forEach(Pe=>{De.push("<tr>"),Z.forEach(te=>{const ge=Pe[te];De.push(`<td>${ge===null?"NULL":typeof ge=="object"?JSON.stringify(ge):String(ge)}</td>`)}),De.push("</tr>")}),De.push("</tbody></table>");const ze=[Z.join(" ")];he.forEach(Pe=>{ze.push(Z.map(te=>{const ge=Pe[te];return ge===null?"NULL":typeof ge=="object"?JSON.stringify(ge):String(ge)}).join(" "))});try{const Pe=new Blob([De.join("")],{type:"text/html"}),te=new Blob([ze.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(ze.join(`
111
+ `)),N(!0),setTimeout(()=>N(!1),2e3)}},[t,pe]),J=Z=>{if(Z===null)return o.jsx("span",{className:"results-table__null",children:"NULL"});if(Z===void 0)return o.jsx("span",{className:"results-table__null",children:"undefined"});if(typeof Z=="boolean")return o.jsx("span",{className:`results-table__bool results-table__bool--${Z}`,children:String(Z)});if(typeof Z=="number")return o.jsx("span",{className:"results-table__number",children:Z.toLocaleString()});if(Z instanceof Date)return o.jsx("span",{className:"results-table__date",children:Z.toISOString()});if(typeof Z=="object")return o.jsx("span",{className:"results-table__json",title:JSON.stringify(Z,null,2),children:JSON.stringify(Z)});const he=String(Z);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})})]})}):ee?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 ${A?"results-table__copy-btn--success":""}`,onClick:fe,title:s("terminal:database.copyAllResults"),children:s(A?"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:Z=>{d(Number(Z.target.value)),i(0)},children:SH.map(Z=>o.jsx("option",{value:Z,children:s("terminal:database.rowsPerPage",{count:Z})},Z))}),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(Z=>Z-1),title:s("terminal:database.previousPage"),children:"‹"}),o.jsx("span",{className:"results-table__page-info",children:s("terminal:database.pageInfo",{current:r+1,total:ye})}),o.jsx("button",{className:"results-table__page-btn",disabled:r>=ye-1,onClick:()=>i(Z=>Z+1),title:s("terminal:database.nextPage"),children:"›"}),o.jsx("button",{className:"results-table__page-btn",disabled:r>=ye-1,onClick:()=>i(ye-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:"#"}),Me.map(Z=>{var ze;const he=(ze=t.fields)==null?void 0:ze.find(be=>be.name===Z),De=f===Z;return o.jsxs("th",{className:`results-table__header ${De?"results-table__header--sorted":""}`,onClick:()=>Te(Z),title:he!=null&&he.type?`Type: ${he.type}`:void 0,style:k[Z]?{width:k[Z],minWidth:k[Z],maxWidth:k[Z]}:void 0,children:[o.jsx("span",{className:"results-table__header-name",children:Z}),De&&o.jsx("span",{className:"results-table__sort-indicator",children:m==="asc"?"▲":"▼"}),o.jsx("span",{className:"results-table__resize-handle",onMouseDown:be=>Ze(be,Z)})]},Z)})]})}),o.jsx("tbody",{children:Ne.map((Z,he)=>o.jsxs("tr",{className:"results-table__row",children:[o.jsx("td",{className:"results-table__row-num",children:r*c+he+1}),Me.map(De=>{const ze=JSON.stringify(Object.fromEntries(He.map(ge=>[ge,Z[ge]]))),be=(S==null?void 0:S.rowKey)===ze&&(S==null?void 0:S.columnName)===De,Pe=L.get(ze),te=Pe?Pe[De]:Z[De];return o.jsx("td",{className:`results-table__cell ${be?"results-table__cell--editing":""} ${_?"results-table__cell--editable":""} ${Pe&&Pe[De]!==Z[De]?"results-table__cell--updated":""}`,onClick:()=>We(De,te,he,ze),onDoubleClick:()=>nt(De,te),onContextMenu:ge=>ie(ge,De,te,he,ze),children:be?o.jsxs("div",{className:"results-table__cell-input-wrapper",children:[Yf(qe.get(S.columnName))?o.jsx(wH,{selected:TA(S.currentValue),onChange:ge=>{const ve=Array.isArray(ge)?ge[0]:ge;T(Fe=>Fe?{...Fe,currentValue:ve?NA(ve):""}:null)},onCalendarClose:Le,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:Le,onKeyDown:Ue,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:"✕"})]}):J(te)},De)})]},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 Z=Ne.find(he=>Me.some(De=>he[De]===y.value&&De===y.column));if(Z){const he=Ne.indexOf(Z),De=JSON.stringify(Object.fromEntries(He.map(ze=>[ze,Z[ze]])));T({rowIndex:he,rowKey:De,columnName:y.column,originalValue:y.value,currentValue:X(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:AH(y.value),readOnly:!0,onFocus:Z=>Z.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(Lo,{isOpen:W!==null,position:(W==null?void 0:W.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:de,onClose:()=>V(null)})]})};function Ny(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 EH(t,e){const n=Ny(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 lV=({query:t,onChange:e,onExecute:n,isExecuting:s,disabled:a,autoFocus:r=!0})=>{const{t:i}=pt(["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 P=localStorage.getItem(h);if(P){const O=Number(P);if(O>=m&&O<=b)return O}}catch{}return 150}),A=x.useCallback(P=>{try{localStorage.setItem(h,String(P))}catch{}},[]),N=x.useCallback(P=>{P.preventDefault(),f.current=!0;const O=P.clientY,_=y,M=F=>{const $=F.clientY-O,H=Math.max(m,Math.min(b,_+$));w(H)},R=()=>{var $;f.current=!1,document.removeEventListener("mousemove",M),document.removeEventListener("mouseup",R),document.body.style.cursor="",document.body.style.userSelect="";const F=($=c.current)==null?void 0:$.parentElement;F&&A(F.getBoundingClientRect().height)};document.addEventListener("mousemove",M),document.addEventListener("mouseup",R),document.body.style.cursor="row-resize",document.body.style.userSelect="none"},[y,A]);x.useEffect(()=>{if(r&&!a&&c.current){const P=setTimeout(()=>{var O;(O=c.current)==null||O.focus()},100);return()=>clearTimeout(P)}},[r,a]);const k=x.useCallback(P=>{const O=P.currentTarget;d.current&&(d.current.scrollLeft=O.scrollLeft,d.current.scrollTop=O.scrollTop)},[]),j=x.useMemo(()=>Ny(t).length>1,[t]),S=x.useCallback(P=>{if((P.ctrlKey||P.metaKey)&&P.shiftKey&&P.key==="Enter"){P.preventDefault(),!a&&!s&&n("all");return}if((P.ctrlKey||P.metaKey)&&P.key==="Enter"&&(P.preventDefault(),!a&&!s&&n("cursor")),P.key==="Tab"){P.preventDefault();const O=P.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 P;return((P=c.current)==null?void 0:P.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(P=>o.jsx("span",{children:P},P))}),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:P=>e(P.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}`,MH=({building:t})=>{var O,_,M,R,F,$;const e=Kx(t.id),n=lL(t.id),s=cL(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),A=a.find(H=>H.id===y),N=y?((F=e.databases)==null?void 0:F.get(y))??[]:[],k=y&&w?(($=e.tables)==null?void 0:$.get(`${y}:${w}`))??[]:[];x.useEffect(()=>{if(!c&&a.length>0){try{const H=localStorage.getItem(_A(t.id));if(H){const L=JSON.parse(H);L.connectionId&&a.some(z=>z.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 H=_A(t.id),L=JSON.parse(localStorage.getItem(H)||"{}");L.lastQuery=r,y&&(L.connectionId=y),w&&(L.database=w),localStorage.setItem(H,JSON.stringify(L))}catch{}},[t.id,r,y,w,c]);const j=x.useCallback(H=>{U.setActiveConnection(t.id,H),U.listDatabases(t.id,H)},[t.id]),S=x.useCallback(H=>{y&&(U.setActiveDatabase(t.id,H),U.listTables(t.id,y,H))},[t.id,y]),T=x.useCallback(()=>{var z;if(!y||!w||!r.trim()||s)return;const H=((z=f.current)==null?void 0:z.selectionStart)??0;if(Ny(r).length<=1)U.executeQuery(t.id,y,w,r.trim());else{const W=EH(r,H);W?U.executeQuery(t.id,y,w,W):U.executeQuery(t.id,y,w,r.trim())}},[t.id,y,w,r,s]),D=x.useCallback(H=>{(H.ctrlKey||H.metaKey)&&H.key==="Enter"&&(H.preventDefault(),T())},[T]),E=x.useCallback(H=>{const L=`SELECT * FROM ${H} LIMIT 100`;i(L),y&&w&&U.executeQuery(t.id,y,w,L)},[t.id,y,w]),P=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:H=>j(H.target.value),title:"Connection",children:a.map(H=>o.jsxs("option",{value:H.id,children:[H.engine==="mysql"?"🐬":"🐘"," ",H.name]},H.id))}),a.length===1&&A&&o.jsxs("span",{className:"db-inline__connection-badge",title:`${A.host}:${A.port}`,children:[A.engine==="mysql"?"🐬":"🐘"," ",A.name]}),o.jsxs("select",{className:"db-inline__select",value:w??"",onChange:H=>S(H.target.value),title:"Database",children:[o.jsx("option",{value:"",children:"Select database..."}),N.map(H=>o.jsx("option",{value:H,children:H},H))]}),k.length>0&&o.jsxs("select",{className:"db-inline__select db-inline__select--tables",value:"",onChange:H=>{H.target.value&&E(H.target.value)},title:"Quick query table",children:[o.jsxs("option",{value:"",children:["Tables (",k.length,")"]}),k.map(H=>o.jsx("option",{value:H.name,children:H.name},H.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:H=>i(H.target.value),onKeyDown:D,onScroll:b,placeholder:"SELECT * FROM ...",spellCheck:!1,rows:2})]}),o.jsx("div",{className:"db-inline__results",children:P?o.jsx(_H,{result:P,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 DH(){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,A)=>{const N=document.querySelector(".app");N&&(N.style.setProperty("--keyboard-height",`${w}px`),N.style.setProperty("--keyboard-visible",A?"1":"0"),N.classList.toggle("keyboard-visible",A)),s.current=w,a.current=A},[]),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 RH(){const[t,e]=x.useState(()=>{const d=Rx(mt.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="",Ox(mt.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 OH=120,LH=.7;function IH(){const[t,e]=x.useState(()=>Rx(mt.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*LH),i=m=>Math.min(r(),Math.max(OH,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="",Ox(mt.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))},A=()=>{document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",A),d()};document.addEventListener("mousemove",w),document.addEventListener("mouseup",A)},[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))},A=()=>{document.removeEventListener("touchmove",w),document.removeEventListener("touchend",A),document.removeEventListener("touchcancel",A),d()};document.addEventListener("touchmove",w,{passive:!1}),document.addEventListener("touchend",A),document.addEventListener("touchcancel",A)},[c,d]);return{mobileOverviewHeight:t,handleResizeMouseDown:f,handleResizeTouchStart:h}}function PH({agents:t,selectedAgentId:e,isOpen:n,overviewPanelOpen:s,loadingHistory:a,hasModalOpen:r=!1,outputRef:i}){const c=ur(),d=Gx(),h=Vr().vibrationIntensity??1,m=()=>{if(typeof document>"u")return!1;const F=document.querySelector(".agent-bar");if(!F)return!1;const $=window.getComputedStyle(F);if($.display==="none"||$.visibility==="hidden")return!1;const H=F.getBoundingClientRect();return H.width>0&&H.height>0},b=x.useMemo(()=>{const F=Array.from(t.values());if(!s&&m()){const se=GR(),q=F.filter(X=>{if(U.isAgentInArchivedArea(X.id))return!1;if(se){const ne=U.getAreaForAgent(X.id);if(!$x((ne==null?void 0:ne.id)??null))return!1}return!0}).sort((X,ne)=>(X.createdAt||0)-(ne.createdAt||0)),me=Ta(mt.AGENT_ORDER,[]),ce=new Set(q.map(X=>X.id)),ee=me.filter(X=>ce.has(X)),pe=q.filter(X=>!ee.includes(X.id)).map(X=>X.id),Ne=[...ee,...pe],ye=new Map(q.map(X=>[X.id,X])),Me=Ne.map(X=>ye.get(X)).filter(X=>X!==void 0),qe=new Map;for(const X of Me){const ne=U.getAreaForAgent(X.id),Te=(ne==null?void 0:ne.id)??null;qe.has(Te)||qe.set(Te,{name:(ne==null?void 0:ne.name)??"",agents:[]}),qe.get(Te).agents.push(X)}const He=Array.from(qe.entries());return He.sort(([X,ne],[Te,We])=>X===null&&Te!==null?1:X!==null&&Te===null?-1:X===null&&Te===null?0:ne.name.localeCompare(We.name)),He.flatMap(([,X])=>X.agents)}const $=Ta(mt.AOP_CONFIG,{groupByArea:!0,sortMode:"recent",filterMode:"all",sameAreaOnly:!1}),H=U.getState(),L=new Map;for(const se of d)L.has(se.agentId)||L.set(se.agentId,se.timestamp);const z=new Map;for(const se of F){const q=U.getAreaForAgent(se.id);!q||q.archived||z.set(se.id,q.id)}let W=F.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=z.get(e)??null,me=z.get(se.id)??null;if(q!==me)return!1}return!0});const V=se=>[...se].sort((q,me)=>{const ce=!!(q.isBoss||q.class==="boss"),ee=!!(me.isBoss||me.class==="boss");if(ce!==ee)return ce?-1:1;if($.sortMode==="name")return q.name.localeCompare(me.name);if($.sortMode==="status"){const ye=["working","waiting_input","waiting_permission","error","idle","stopped"],Me=ye.indexOf(q.status)-ye.indexOf(me.status);if(Me!==0)return Me;const qe=H.agentsWithUnseenOutput.has(q.id),He=H.agentsWithUnseenOutput.has(me.id);if(qe!==He)return qe?-1:1;if(q.status==="working"&&me.status==="working")return q.name.localeCompare(me.name);if(q.status==="idle"&&me.status==="idle"){const X=!!q.taskLabel,ne=!!me.taskLabel;return X!==ne?X?-1:1:(me.lastActivity||0)-(q.lastActivity||0)}return(me.lastActivity||0)-(q.lastActivity||0)}const pe=L.get(q.id)||0;return(L.get(me.id)||0)-pe});if(!$.groupByArea)return V(W);const G=[],B=new Set;for(const[se,q]of c){if(q.archived)continue;const me=W.filter(ce=>z.get(ce.id)===se);if(me.length>0){const ce=V(me);G.push(...ce);for(const ee of ce)B.add(ee.id)}}const K=V(W.filter(se=>!B.has(se.id)));return G.push(...K),W=G,W},[t,c,d,e,s]),[y,w]=x.useState(0),[A,N]=x.useState(""),k=x.useRef(null),[j,S]=x.useState(null),T=e?b.findIndex(F=>F.id===e):-1,D=T>0?b[T-1]:b[b.length-1],E=T<b.length-1?b[T+1]:b[0],P=x.useRef(null),O=x.useCallback(()=>{if(!e||b.length<=1)return;const F=b.findIndex(H=>H.id===e);if(F===-1)return;const $=(F-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 F=b.findIndex(H=>H.id===e);if(F===-1)return;const $=(F+1)%b.length;S("right"),w(0),N(""),U.setLastSelectionViaSwipe(!0),U.selectAgent(b[$].id)},[e,b]),M=x.useCallback(F=>{w(F),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 F=j;S(null),requestAnimationFrame(()=>{N(F==="left"?"swipe-in-left":"swipe-in-right"),k.current=setTimeout(()=>{N("")},120)})},[j,a]),x.useEffect(()=>()=>{k.current&&clearTimeout(k.current)},[]),Fk(P,{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 F=$=>{if(!n||b.length<=1||r)return;const H=U.getShortcuts(),L=H.find(K=>K.id==="prev-working-agent"),z=H.find(K=>K.id==="next-working-agent"),W=H.find(K=>K.id==="prev-agent-terminal"),V=H.find(K=>K.id==="next-agent-terminal"),G=$.altKey&&$.shiftKey&&!$.ctrlKey&&!$.metaKey&&$.code==="KeyJ",B=$.altKey&&$.shiftKey&&!$.ctrlKey&&!$.metaKey&&$.code==="KeyK";if(Nn($,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,me=q===-1?se.length-1:(q-1+se.length)%se.length;U.selectAgent(se[me].id);return}if(Nn($,z)){$.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,me=q===-1?0:(q+1)%se.length;U.selectAgent(se[me].id);return}if(Nn($,W)||B){$.preventDefault(),O();return}if(Nn($,V)||G){$.preventDefault(),_();return}};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[n,b,e,O,_,r]),{sortedAgents:b,swipeOffset:y,swipeAnimationClass:A,currentAgentIndex:T,prevAgent:D,nextAgent:E,headerRef:P,outputRef:i,handleSwipeLeft:O,handleSwipeRight:_}}function BH(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 FH(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 zH({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),[A,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++)BH(n[R]).toLowerCase().includes(_)&&FH(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)),!_))},[]),P=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:P,highlightQuery:O,matchIndices:S,currentMatch:m,navigateNext:T,navigatePrev:D,scrollToIndex:y,loadingFullHistory:A}}const $H=new Map,UH=[];function HH({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 F=$a(`${mt.INPUT_TEXT_PREFIX}${t}`);F&&n(H=>new Map(H).set(t,F));const $=$a(`${mt.PASTED_TEXTS_PREFIX}${t}`);if($)try{const H=JSON.parse($),L=new Map(H);i(W=>new Map(W).set(t,L));const z=Math.max(0,...H.map(([W])=>W));f.current.set(t,z)}catch{}},[t,e]);const m=t&&e.get(t)||"",b=t&&s.get(t)||!1,y=(t?r.get(t):void 0)||$H,w=(t?c.get(t):void 0)||UH,A=m.includes(`
116
+ `),k=typeof window<"u"&&window.innerWidth<=768||b||A||m.length>50,j=x.useCallback(F=>{t&&(n($=>new Map($).set(t,F)),F?Wr(`${mt.INPUT_TEXT_PREFIX}${t}`,F):Pk(`${mt.INPUT_TEXT_PREFIX}${t}`))},[t]),S=x.useCallback(F=>{t&&a($=>new Map($).set(t,F))},[t]),T=x.useCallback(F=>{t&&i($=>{const H=new Map($),L=$.get(t)||new Map,z=typeof F=="function"?F(L):F;if(H.set(t,z),z.size>0){const W=JSON.stringify(Array.from(z.entries()));Wr(`${mt.PASTED_TEXTS_PREFIX}${t}`,W)}else Pk(`${mt.PASTED_TEXTS_PREFIX}${t}`);return H})},[t]),D=x.useCallback(F=>{t&&d($=>{const H=new Map($),L=$.get(t)||[],z=typeof F=="function"?F(L):F;return H.set(t,z),H})},[t]),E=x.useCallback(()=>{if(!t)return 0;const $=(f.current.get(t)||0)+1;return f.current.set(t,$),$},[t]),P=x.useCallback(()=>{t&&f.current.set(t,0)},[t]),O=x.useCallback(F=>{D($=>$.filter(H=>H.id!==F))},[D]),_=x.useCallback(async(F,$)=>{try{const H=$||(F instanceof File?F.name:""),L=encodeURIComponent(H),z=await Pt(Ot("/api/files/upload"),{method:"POST",headers:{"Content-Type":F.type||"application/octet-stream","X-Filename":L},body:F});if(!z.ok)return console.error("Upload failed:",await z.text()),null;const W=await z.json();return h.current+=1,{id:h.current,name:W.filename,path:W.absolutePath,isImage:W.isImage,size:W.size}}catch(H){return console.error("Upload error:",H),null}},[]),M=x.useCallback(F=>{let $=F;for(const[H,L]of y){const z=new RegExp(`\\[Pasted text #${H} \\+\\d+ lines\\]`,"g");$=$.replace(z,L)}return $},[y]),R=x.useCallback(()=>{const F=(m.match(/\n/g)||[]).length+1,$=Math.ceil(m.length/60),H=Math.max(F,$,2);return Math.min(H,10)},[m]);return x.useMemo(()=>({command:m,setCommand:j,forceTextarea:b,setForceTextarea:S,useTextarea:k,pastedTexts:y,setPastedTexts:T,incrementPastedCount:E,resetPastedCount:P,attachedFiles:w,setAttachedFiles:D,removeAttachedFile:O,uploadFile:_,expandPastedTexts:M,getTextareaRows:R}),[m,j,b,S,k,y,T,E,P,w,D,O,_,M,R])}const jb=10;function WH({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,P=200)=>{b.current&&cancelAnimationFrame(b.current);const O=D.scrollTop,_=E-O,M=performance.now(),R=F=>{const $=F-M,H=Math.min($/P,1),L=y(H);D.scrollTop=O+_*L,H<1?b.current=requestAnimationFrame(R):b.current=null};b.current=requestAnimationFrame(R)},[]),A=x.useCallback(D=>{if(!s.current)return;const E=s.current,P=E.querySelector(`[data-message-index="${D}"]`);if(P){const O=E.getBoundingClientRect(),_=P.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(()=>A(E)),E})},[t,A]),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(()=>A(E)),E})},[t,A]),j=x.useCallback(()=>{t!==0&&f(D=>{let E;return D===-1?E=t-1:E=Math.max(0,D-jb),requestAnimationFrame(()=>A(E)),E})},[t,A]),S=x.useCallback(()=>{t!==0&&f(D=>{let E;if(D===-1)E=t-1;else{if(D+jb>=t)return-1;E=D+jb}return requestAnimationFrame(()=>A(E)),E})},[t,A]),T=x.useCallback(D=>d===D,[d]);return x.useEffect(()=>{const D=E=>{if(!e||n)return;const P=U.getShortcuts(),O=P.find(L=>L.id==="prev-message"),_=P.find(L=>L.id==="next-message"),M=P.find(L=>L.id==="page-up-messages"),R=P.find(L=>L.id==="page-down-messages"),F=P.find(L=>L.id==="activate-message");if(Nn(E,O)){E.preventDefault(),document.activeElement instanceof HTMLElement&&document.activeElement.blur(),N();return}if(Nn(E,_)){E.preventDefault(),document.activeElement instanceof HTMLElement&&document.activeElement.blur(),k();return}if(Nn(E,M)){E.preventDefault(),document.activeElement instanceof HTMLElement&&document.activeElement.blur(),j();return}if(Nn(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,H=$.tagName==="INPUT"||$.tagName==="TEXTAREA"||$.isContentEditable;if(Nn(E,F)&&d!==-1&&!H){E.preventDefault();const L=s.current;if(!L)return;const z=L.querySelector(`[data-message-index="${d}"]`);if(!z)return;const W=[".clickable-path",".output-tool-use.bash-clickable",".clickable-bash",".history-view-md-btn"];for(const G of W){const B=z.querySelector(G);if(B){B.click();return}}const V=z.querySelector(".output-tool-use");V!=null&&V.classList.contains("bash-clickable")&&V.click();return}if(d!==-1&&!H){const L=Nn(E,O)||Nn(E,_)||Nn(E,M)||Nn(E,R),z=["Escape","Tab","Shift","Control","Alt","Meta","CapsLock"].includes(E.key),W=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(E.key),V=E.key.startsWith("F")&&E.key.length<=3;if(!L&&!z&&!W&&!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 qH=3e4;function VH(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=Fi(),m={};h&&(m.Authorization=`Bearer ${h}`);const b=Ma(),y=new Map;await Promise.all(i.map(async w=>{try{const A=await fetch(`${b}/api/files/git-branch?path=${encodeURIComponent(w)}`,{headers:m});if(A.ok){const N=await A.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,qH),()=>{r.current&&clearInterval(r.current)}},[c,d]);const f=x.useCallback(async h=>{a(m=>new Set(m).add(h));try{await Pt(Ot("/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 ms={Read:"📖",Write:"✏️",Edit:"📝",Bash:"💻",Glob:"🔍",Grep:"🔎",Task:"📋",Agent:"🤖",WebFetch:"🌐",WebSearch:"🌍",TodoWrite:"✅",NotebookEdit:"📓",AskFollowupQuestion:"❓",AskUserQuestion:"❓",AttemptCompletion:"✨",ListFiles:"📂",SearchFiles:"🔎",ExecuteCommand:"⚙️",spawn_agent:"🧬",send_input:"📨",wait:"⏳",default:"⚡"},YH={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=YH[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 GH(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}),GH(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://",KH=/(^|[\s(>])((?:\.\.?\/|\/)?(?:[A-Za-z0-9._-]+\/)*[A-Za-z0-9._-]+(?:\.[A-Za-z0-9._-]+)+(?:#L\d+(?:C\d+)?)?(?::\d+(?::\d+)?)?)(?=$|[\s),.;])/g,QH=/`((?:\.\.?\/|\/)?(?:[A-Za-z0-9._-]+\/)*[A-Za-z0-9._-]+(?:\.[A-Za-z0-9._-]+)+(?:#L\d+(?:C\d+)?)?(?::\d+(?::\d+)?)?)`/g,XH=/\.(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 XH.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(QH,(c,d)=>{if(!MA(d))return c;const f=encodeURIComponent(d);return`[\`${d}\`](${zp}${f})`});return i.replace(KH,(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 JH(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 Bi(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=Bi(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=Bi(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=Bi(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=Bi(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=Bi(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=Bi(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=Bi(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=Bi(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 ZH(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 e6(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?e6(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 A=JSON.parse(w);(A.old_string!==void 0||A.new_string!==void 0||A.unified_diff!==void 0)&&(c={oldString:A.old_string||"",newString:A.new_string||"",operation:typeof A.operation=="string"?A.operation:void 0,unifiedDiff:typeof A.unified_diff=="string"?A.unified_diff:void 0})}catch{}if(r==="TodoWrite")try{const A=JSON.parse(w);Array.isArray(A.todos)&&(d=w)}catch{}if(r==="Bash")try{const A=JSON.parse(w);A.command&&(h=A.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}ZH(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;Wu.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 t6(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 Bu(t){return typeof t=="string"||typeof t=="number"?String(t):Array.isArray(t)?t.map(Bu).join(""):je.isValidElement(t)?Bu(t.props.children):""}const n6=/\.(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 Ty(t){const e=t.split("/")[0].split("?")[0].split("#")[0];return n6.test(e)}function s6(t){return!t||t.startsWith("#")||/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(t)||Ty(t)?!1:t.includes(".")||t.startsWith("/")||t.startsWith("./")||t.startsWith("../")}function a6(t){if(!t||t.includes(`
120
+ `))return!1;const e=t.trim();return!e||/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(e)||Ty(e)?!1:e.includes(".")&&(e.includes("/")||/^[A-Za-z0-9._-]+\.[A-Za-z0-9._-]+$/.test(e))}const ud=({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=Bu(e),s=t6(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=Bu(e);if(a&&S4(a)){const i=Oo(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=JH(s),r=Bu(e).trim(),i=a||(s&&s6(s)?s:null)||((!s||s==="#")&&a6(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("://")&&Ty(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});ud();function _y(t){const e=t.trimStart();if(!e.startsWith(sx))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(sx.length,n).trim(),a=e.slice(n+xS.length).trim();return{hasContext:!0,context:s,userMessage:a}}function Ey(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}=pt(["tools"]),[a,r]=x.useState(e),i=ud({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}=pt(["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 r6({bossName:t,taskCommand:e}){const{t:n}=pt(["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 i6={high:"🔴",medium:"🟡",low:"🟢"},o6={scout:"🔍",builder:"🔨",debugger:"🐛",architect:"📐",warrior:"⚔️",support:"🛡️"};function zT({workPlan:t}){const{t:e}=pt(["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:i6[d.priority]}),o.jsxs("span",{className:"work-plan-task-class",title:`Suggested: ${d.suggestedClass}`,children:[o6[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 l6={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"}},c6={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"}},u6={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"}},d6={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"}},f6={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"}},p6={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"}},h6={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"}},m6={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"}},g6={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"}},b6={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"}},x6={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"}},y6={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"}},v6={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"}},w6={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"}},k6={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"}},S6={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"}},C6={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=[C6,b6,x6,l6,$T,c6,u6,d6,f6,p6,h6,m6,g6,y6,v6,w6,k6,S6];function Fu(t){return ia.find(e=>e.id===t)||$T}const A6="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 My(){try{const t=localStorage.getItem("tide-theme");if(t&&ia.some(e=>e.id===t))return t}catch{}return A6}function j6(){const t=My(),e=Fu(t);Up(e)}const N6=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:A,headerRef:N,isSnapshotView:k=!1,onSaveSnapshot:j,overviewPanelOpen:S=!1,setOverviewPanelOpen:T,agentInfoOpen:D=!1,onToggleAgentInfo:E,isFullscreen:P=!1,onToggleFullscreen:O,onNavigateBack:_,onNavigateForward:M,canNavigateBack:R=!1,canNavigateForward:F=!1,gitPanelOpen:$=!1,setGitPanelOpen:H,buildingsPanelOpen:L=!1,setBuildingsPanelOpen:z,workflowPanelOpen:W=!1,setWorkflowPanelOpen:V,hasWorkflow:G=!1}){var be,Pe;const{t:B}=pt(["terminal","common"]),K=KO();Vr();const se=Jj(n),q=()=>{const te=Fg.indexOf(r),ge=Fg[(te+1)%Fg.length];i(ge),Wr(mt.VIEW_MODE,ge)},me=()=>{const te=!h;m(te),te&&!b&&(y(!0),ks.setEnabled(!0))},ce=()=>{c?f():d()},ee=()=>{window.confirm(B("common:confirm.removeAgent",{name:e.name}))&&U.removeAgentFromServer(n)},pe=e.currentTask||e.lastAssignedTask||(se==null?void 0:se.text),Ne=e.taskLabel||pe,ye=(be=K.lastReport)==null?void 0:be.agentSummaries.find(te=>te.agentId===e.id||te.agentName===e.name),Me={on_track:"#4aff9e",stalled:"#ff9e4a",blocked:"#ff4a4a",completed:"#4a9eff",idle:"#888"},He=(e.class==="boss"||e.isBoss)&&e.subordinateIds&&e.subordinateIds.length>0,X=hL(n),ne=rN(e.class in Do?null:e.class),Te=(ne==null?void 0:ne.icon)||((Pe=Do[e.class])==null?void 0:Pe.icon)||"🤖",We=ur(),nt=je.useMemo(()=>{var te;for(const ge of We.values())if((te=ge.assignedAgentIds)!=null&&te.includes(n))return ge;return null},[We,n]),[we,Le]=x.useState(!1),ie=x.useRef(null),[de,Ue]=x.useState(!1),[Ze,lt]=x.useState(!1),[fe,J]=x.useState(()=>My()),ae=x.useRef(null),Se=B(r==="simple"?"terminal:header.simpleView":r==="chat"?"terminal:header.chatView":"terminal:header.advancedView"),Z=r==="simple"?"○":r==="chat"?"◐":"◉",he=x.useCallback(()=>{Le(!1)},[]),De=x.useCallback(()=>{Ue(!1),lt(!1)},[]),ze=te=>{const ge=Fu(te);Up(ge),J(te)};return x.useEffect(()=>{if(!we)return;const te=ge=>{ie.current&&!ie.current.contains(ge.target)&&he()};return document.addEventListener("mousedown",te),()=>document.removeEventListener("mousedown",te)},[we,he]),x.useEffect(()=>{if(!de)return;const te=ge=>{ae.current&&!ae.current.contains(ge.target)&&De()};return document.addEventListener("mousedown",te),document.addEventListener("touchstart",te),()=>{document.removeEventListener("mousedown",te),document.removeEventListener("touchstart",te)}},[de,De]),o.jsxs("div",{className:`guake-header ${s.length>1?"has-multiple-agents":""} ${a>.1?"swiping-right":""} ${a<-.1?"swiping-left":""}`,ref:N,style:nt?{borderBottomColor:`color-mix(in srgb, ${nt.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(cs,{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:Te}),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||pe)&&o.jsx("span",{className:"guake-title-task-chip",children:e.taskLabel||pe})]}),Ne&&o.jsx("span",{className:"guake-mobile-title-context",children:Ne})]}),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:Te}),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||pe)&&o.jsx("span",{className:"guake-title-task-chip",children:e.taskLabel||pe})]}),Ne&&o.jsx("span",{className:"guake-mobile-title-context",children:Ne})]}),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:[ye&&o.jsx("span",{className:"guake-status-line",title:`${ye.statusDescription}
124
+ ${ye.recentWorkSummary}`,children:o.jsx("span",{className:"guake-supervisor-badge",style:{color:Me[ye.progress]||"#888"},children:ye.progress.replace("_"," ")})}),X.filter(te=>te.status==="spawning"||te.status==="working").length>0&&o.jsx("span",{className:"guake-subagents-indicator",children:X.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:!F,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&&H&&o.jsx("button",{className:`guake-icon-action guake-git-toggle ${$?"active":""}`,onClick:()=>H(!$),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 ${W?"active":""}`,onClick:()=>V(!W),title:W?"Hide Workflow":"Show Workflow",children:o.jsx("span",{className:"guake-action-icon",children:"🔄"})}),o.jsx("button",{className:`guake-icon-action guake-fullscreen-toggle ${P?"active":""}`,onClick:O,title:B(P?"terminal:header.exitFullscreen":"terminal:header.enterFullscreen"),children:o.jsx("span",{className:"guake-action-icon",children:P?"🗗":"⛶"})}),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:()=>A("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:ie,children:[o.jsx("button",{className:`guake-desktop-more-btn ${we?"active":""}`,onClick:()=>Le(!we),title:B("terminal:header.moreActions","More actions"),children:"⋮"}),we&&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:Z}),"View: ",Se]}),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")]}),z&&o.jsxs("button",{className:`guake-desktop-menu-item ${L?"active":""}`,onClick:()=>{z(!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:()=>{me(),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:()=>{A("collapse"),he()},disabled:e.status!=="idle",children:[o.jsx("span",{className:"guake-desktop-menu-icon",children:"📦"}),B("terminal:header.collapseContext")]}),He&&o.jsxs("button",{className:"guake-desktop-menu-item danger",onClick:()=>{A("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:()=>{ee(),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:()=>Ue(!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||_(),De()},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(),De()},disabled:!F,children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"→"}),"Forward"]}),o.jsxs("button",{className:"guake-mobile-menu-item",onClick:()=>{q(),De()},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),De()},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(),De()},children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"⭐"}),B("terminal:header.saveSnapshot")]}),o.jsxs("button",{className:`guake-mobile-menu-item ${P?"active":""}`,onClick:()=>{O==null||O(),De()},children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:P?"🗗":"⛶"}),B(P?"terminal:header.exitFullscreen":"terminal:header.enterFullscreen")]}),o.jsxs("button",{className:"guake-mobile-menu-item",onClick:()=>{ce(),De()},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),De()},children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"📊"}),B(S?"terminal:header.hideOverview":"terminal:header.showOverview")]}),H&&o.jsxs("button",{className:`guake-mobile-menu-item ${$?"active":""}`,onClick:()=>{H(!$),De()},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 ${W?"active":""}`,onClick:()=>{V(!W),De()},children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"🔄"}),W?"Hide Workflow":"Show Workflow"]}),z&&o.jsxs("button",{className:`guake-mobile-menu-item ${L?"active":""}`,onClick:()=>{z(!L),De()},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:()=>{me(),De()},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 ${Ze?"active":""}`,onClick:()=>lt(!Ze),children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"🎨"}),B("terminal:themeSelector.selectTheme"),o.jsx("span",{className:"guake-mobile-theme-arrow",children:Ze?"▲":"▼"})]}),Ze&&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:()=>ze(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:()=>{A("collapse"),De()},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:()=>{A("clear"),De()},children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"🧹"}),B("terminal:header.clearContext")]}),He&&o.jsxs("button",{className:"guake-mobile-menu-item danger",onClick:()=>{A("clear-subordinates"),De()},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:()=>{ee(),De()},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 T6({searchInputRef:t,searchQuery:e,setSearchQuery:n,closeSearch:s,matchCount:a,currentMatch:r,navigateNext:i,navigatePrev:c,loadingFullHistory:d}){const{t:f}=pt(["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 _6({request:t,onApprove:e,onDeny:n}){const{t:s}=pt(["tools"]),a=ms[t.tool]||ms.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 Dl(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 Dy(t){const e=Ma();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 Bl(t,e,n){const s=/\[(Image|File):\s*([^\]]+)\]/g,a=[];let r=0,i;const c=ud({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=Dy(f);a.push(o.jsxs("span",{className:"image-reference clickable",onClick:()=>e==null?void 0:e(m,h),title:Rn.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:Rn.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 zu(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=Dy(d);a.push(o.jsxs("span",{className:"image-reference clickable",onClick:()=>e==null?void 0:e(h,f),title:Rn.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:Rn.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 E6({id:t,lineCount:e,fullText:n,onRemove:s}){const{t:a}=pt(["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(M6,{id:t,lineCount:e,content:n,onClose:()=>i(!1)})]})}function M6({id:t,lineCount:e,content:n,onClose:s}){const{t:a}=pt(["tools","common"]),{handleMouseDown:r,handleClick:i}=_a(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 D6={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={...D6,...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 A=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,sampleRate:16e3}});f.current=A,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(A,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(A){console.error("[STT] Failed to start recording:",A),A instanceof Error?A.name==="NotAllowedError"||A.name==="PermissionDeniedError"?i("Microphone permission denied"):A.name==="NotFoundError"||A.name==="DevicesNotFoundError"?i("No microphone found"):A.name==="NotReadableError"||A.name==="TrackStartError"?i("Microphone in use by another app"):A.name==="OverconstrainedError"?i("Microphone constraints not supported"):i(`Microphone error: ${A.message}`):i("Failed to access microphone")}},[]),b=x.useCallback(async()=>!c.current||!e?null:new Promise(A=>{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),A(null);return}a(!0);try{const D=await R6(j);console.log("[STT] Sending audio for transcription...");const P=await(await Pt(Ot("/api/stt/transcribe"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({audio:D,language:h.language,model:h.model})})).json();P.success&&P.text?(console.log("[STT] Transcription:",P.text),(T=h.onTranscription)==null||T.call(h,P.text),A(P.text)):(console.error("[STT] Transcription failed:",P.error),i(P.error||"Transcription failed"),A(null))}catch(D){console.error("[STT] Failed to transcribe:",D),i("Failed to transcribe audio"),A(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 R6(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 O6=x.memo(function({agentId:e,isWorking:n,timestamp:s}){const{t:a}=pt(["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,L6=128,I6=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:A,setPastedTexts:N,resetPastedCount:k,handleInputFocus:j,handleInputBlur:S,pendingPermissions:T,showCompletion:D,completionElapsed:E,onImageClick:P,inputRef:O,textareaRef:_,isSnapshotView:M=!1,onClearHistory:R,onSendCommand:F,canSwipeClose:$=!1,onSwipeCloseOffsetChange:H,onSwipeClose:L}){const{t:z}=pt(["terminal","common"]),W=x.useRef(null),V=x.useRef(null),G=O||W,B=_||V,K=x.useRef(null),se=x.useRef(null),q=x.useRef(d),me=x.useRef(0),ce=x.useRef(null),ee=x.useRef({isTracking:!1,startY:0,startX:0}),[pe,Ne]=x.useState(0),[ye,Me]=x.useState("idle"),qe=Vr(),He=Jj(n),X=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:Te,transcribing:We,toggleRecording:nt}=HT({language:"Spanish",model:"medium",onTranscription:te=>{te.trim()&&n&&U.sendCommand(n,te.trim())}}),we=x.useCallback(()=>{ce.current&&(clearTimeout(ce.current),ce.current=null)},[]),Le=x.useCallback((te="idle")=>{we(),Ne(0),Me(te),H==null||H(0),te==="returning"&&(ce.current=setTimeout(()=>{Me("idle"),ce.current=null},160))},[we,H]),ie=x.useCallback(te=>{if(!$||!L||window.innerWidth>768||te.touches.length!==1)return;we();const ge=te.touches[0];ee.current={isTracking:!0,startY:ge.clientY,startX:ge.clientX},Me("idle"),Ne(0),H==null||H(0)},[$,L,we,H]),de=x.useCallback(te=>{if(!ee.current.isTracking)return;const ge=te.touches[0],ve=ge.clientY-ee.current.startY,Fe=Math.abs(ge.clientX-ee.current.startX);if(Fe>48&&Fe>Math.abs(ve)){ee.current.isTracking=!1,Le("returning");return}if(ve>=0){Ne(0),Me("idle");return}const Ke=Math.min(L6,Math.abs(ve));Ke>8&&te.preventDefault(),Ne(Ke),Me("dragging"),H==null||H(Ke)},[Le,H]),Ue=x.useCallback(()=>{if(ee.current.isTracking){if(ee.current.isTracking=!1,!$||!L){Le("returning");return}if(pe>=OA){L();return}Le("returning")}},[$,L,pe,Le,H]),Ze=x.useCallback(()=>{ee.current.isTracking=!1,Le("returning")},[Le]);x.useEffect(()=>()=>we(),[we]),x.useEffect(()=>{$||(ee.current.isTracking=!1,Le("idle"))},[$,Le]);const lt=te=>{me.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=me.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 st=setTimeout(()=>{ne()},50);return()=>clearTimeout(st)}},[s,ne,n]);const J=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})},Se=(()=>{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})(),Z=()=>{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(st=>st.isImage?`[Image: ${st.path}]`:`[File: ${st.path}]`).join(`
125
+ `);te?te=`${te}
126
+
127
+ ${Ke}`:te=Ke}U.sendCommand(n,te),F==null||F(),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(),Z()}},De=te=>{},ze=te=>{te.button===1&&(te.preventDefault(),te.stopPropagation())},be=async te=>{const ge=te.clipboardData.items;for(const ot of ge){if(ot.type.startsWith("image/")){te.preventDefault();const ft=ot.getAsFile();if(ft){const ut=await b(ft);ut&&h(ln=>[...ln,ut])}return}if(ot.kind==="file"){te.preventDefault();const ft=ot.getAsFile();if(ft){const ut=await b(ft);ut&&h(ln=>[...ln,ut])}return}}const ve=te.clipboardData.files;if(ve.length>0){te.preventDefault();for(const ot of ve){const ft=await b(ot);ft&&h(ut=>[...ut,ft])}return}const Fe=te.clipboardData.getData("text"),Ke=!Fe.includes(`
129
+ `),st=/^[/~][^\s]*$|^[A-Za-z]:\\[^\s]*$/.test(Fe.trim()),xt=/\.[a-zA-Z0-9]{1,5}$/.test(Fe.trim());if(Ke&&st&&xt){te.preventDefault();try{const ot=await fetch("/api/files/by-path",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Fe.trim()})});if(ot.ok){const ft=await ot.blob(),ut=Fe.trim().split(/[/\\]/).pop()||"file",ln=await b(ft,ut);ln&&h(Kt=>[...Kt,ln]);return}}catch{}r(a+Fe);return}const ht=(Fe.match(/\n/g)||[]).length+1;if(ht>5){te.preventDefault();const ot=A();N(Ye=>new Map(Ye).set(ot,Fe));const ft=`[Pasted text #${ot} +${ht} lines]`,ut=te.target,ln=ut.selectionStart||0,Kt=ut.selectionEnd||0,Ce=a.slice(0,ln)+ft+a.slice(Kt),Be=ln+ft.length;me.current=Be,r(Ce),d?requestAnimationFrame(()=>{B.current&&B.current.setSelectionRange(Be,Be)}):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(_6,{request:te,onApprove:ge=>U.respondToPermissionRequest(te.id,!0,void 0,ge),onDeny:()=>U.respondToPermissionRequest(te.id,!1)},te.id))}),Se.length>0&&o.jsx("div",{className:"guake-pasted-texts",children:Se.map(({id:te,lineCount:ge})=>{const ve=y.get(te)||"";return o.jsx(E6,{id:te,lineCount:ge,fullText:ve,onRemove:()=>J(te)},te)})}),f.length>0&&o.jsx("div",{className:"guake-attachments",children:f.map(te=>{var Ke;const ge=te.isImage?Dy(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&&P(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:st=>{st.stopPropagation(),m(te.id)},title:z("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 ${ye!=="idle"?"swipe-close-active":""} ${pe>=OA?"swipe-close-ready":""}`,onTouchStart:ie,onTouchMove:de,onTouchEnd:Ue,onTouchCancel:Ze,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)),st=Math.max(0,100-Ke),xt=Ke>=80?"#ff4a4a":Ke>=60?"#ff9e4a":Ke>=40?"#ffd700":"#4aff9e",ht=(ge/1e3).toFixed(1),ot=(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:xt}}),o.jsxs("span",{className:"mobile-context-bar-text",children:[o.jsxs("span",{style:{color:xt},children:[ht,"k/",ot,"k"]}),o.jsxs("span",{className:"mobile-context-bar-pct",children:["(",st,"% free)"]})]})]})})(),o.jsx(O6,{agentId:n,isWorking:X,timestamp:He==null?void 0:He.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:ze,children:[o.jsx("button",{className:"guake-attach-btn",onClick:()=>{var te;return(te=se.current)==null?void 0:te.click()},title:z("terminal:input.attachOrPaste"),children:"📎"}),qe.experimentalTTS&&o.jsx("button",{className:`guake-mic-btn ${Te?"recording":""} ${We?"transcribing":""}`,onClick:nt,title:z(Te?"terminal:input.stopRecording":We?"terminal:input.transcribing":"terminal:input.voiceInput"),disabled:We,children:We?"⏳":Te?"🔴":"🎤"}),d?o.jsx("textarea",{ref:B,placeholder:z("terminal:input.placeholder",{agent:e.name}),value:a,onChange:lt,onKeyDown:he,onPaste:be,onMouseDown:De,onFocus:j,onBlur:S}):o.jsx("input",{ref:G,type:"text",placeholder:z("terminal:input.placeholder",{agent:e.name}),value:a,onChange:lt,onKeyDown:he,onPaste:be,onMouseDown:De,onFocus:j,onBlur:S}),o.jsx("button",{onClick:Z,disabled:!a.trim()&&f.length===0,title:z("terminal:input.send"),children:"➤"})]})]})]})})]})});function P6({agent:t,content:e,isOpen:n,onClose:s}){const{t:a}=pt(["tools","common","terminal"]),r=x.useCallback(()=>{navigator.clipboard.writeText(e)},[e]),{handleMouseDown:i,handleClick:c}=_a(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 B6({url:t,name:e,onClose:n}){const{handleMouseDown:s,handleClick:a}=_a(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 F6({state:t,onClose:e}){const{t:n}=pt(["terminal","common"]),{handleMouseDown:s,handleClick:a}=_a(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:Oo(t.command,"bash")}})}),o.jsx("div",{className:`bash-modal-content ${t.isLive?"is-loading":""}`,children:o.jsx("pre",{dangerouslySetInnerHTML:{__html:Yl(t.output)}})})]})})})}function z6({action:t,selectedAgentId:e,subordinateCount:n,onClose:s,onClearHistory:a}){const{t:r}=pt(["terminal","common"]),{handleMouseDown:i,handleClick:c}=_a(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 $6(){const t=Yx(),e=nd(),n=t?e.get(t):null;return n?o.jsx(yN,{agent:n,isOpen:!!t,onClose:()=>U.closeContextModal(),onRefresh:()=>{t&&U.refreshAgentContext(t)}}):null}function U6(){const t=Vx(),e=JO(),n=ZO();return t?o.jsx(M1,{isOpen:!!t,onClose:()=>U.clearFileViewerPath(),filePath:t,action:e?"modified":"read",editData:e||void 0,searchRoot:n||void 0}):null}function H6({agent:t,content:e,onClose:n}){return t?o.jsx(P6,{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 W6({agent:t,isOpen:e,onClose:n}){var S,T,D,E,P;const{t:s}=pt(["terminal","common"]),{handleMouseDown:a,handleClick:r}=_a(n),i=nL((t==null?void 0:t.id)||null),c=rN((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,A=[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=((P=t.contextStats)==null?void 0:P.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:A})]}),!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 q6(t){return t.isDirectory?"":jp[t.extension]||jp.default}function ph(t){return jp[t]||jp.default}function cV(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function V6(t,e){if(!e)return null;const n=t.toLowerCase().indexOf(e.toLowerCase());return n===-1?null:{start:n,end:n+e.length}}function Nb(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 Y6(t,e){for(const n of t)n.isDirectory&&(e.add(n.path),Y6(n.children,e))}function G6(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 K6(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 A=1;A<=r;A++)n[w-1]===s[A-1]?i[w][A]=i[w-1][A-1]+1:i[w][A]=Math.max(i[w-1][A],i[w][A-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 A=n[w.origIdx];h.push({num:w.origIdx+1,text:A,type:"unchanged"}),m.push({num:w.modIdx+1,text:A,type:"unchanged"})}else if(w.type==="delete"){const A=n[w.origIdx];h.push({num:w.origIdx+1,text:A,type:"removed"}),y++}else{const A=s[w.modIdx];m.push({num:w.modIdx+1,text:A,type:"added"}),b++}return{leftLines:h,rightLines:m,stats:{added:b,removed:y}}}function qT({content:t,onFileClick:e}){const{t:n}=pt(["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=G6(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:A,stats:N}=K6(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:[A.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)),A.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}=pt(["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 Cx({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 Q6(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 X6(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 J6(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=Q6(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)?X6(c):[];return{selectedTools:a,fallback:r!==void 0?String(r):null,showHide:i!==void 0?String(i):null,queryParams:m}}function Z6(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 J6(e)}catch{}return Z6(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 Ry(){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 Pt(Ot("/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 e5(t){const e=t.split("/").pop()||t,n=e.lastIndexOf(".");return n<=0?"":e.slice(n).toLowerCase()}function t5(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 Me,qe;const{t:f}=pt(["tools","common","terminal"]),[h,m]=x.useState(new Set),[b,y]=x.useState(!1),w=eN(),A=Vr(),{type:N,content:k,toolName:j,timestamp:S,_bashOutput:T,_bashCommand:D}=e,E=Eu(k,w),{toggle:P,speaking:O}=Ry(),_=ud({onFileClick:i?He=>i(He):void 0}),M=n?(Me=U.getState().agents.get(n))==null?void 0:Me.name:null,R=n?(qe=U.getState().agents.get(n))==null?void 0:qe.provider:void 0,F=R==="codex"?"Codex":R==="opencode"?"OpenCode":"Claude",H=N==="tool_use"&&(j==="Task"||j==="Agent")&&e.toolInput&&(e.toolInput.name||e.toolInput.description)||null||M,L=S?Fp(new Date(S).getTime()):"",z=S?new Date(S).getTime():0,W=t5(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:`${z} | ${W}`,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"}),F]}),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:`${z} | ${W}`,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(sx),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 He=E.match(/<local-command-stdout>([\s\S]*?)<\/local-command-stdout>/),X=He?He[1]:E,ne=X.match(/\*?\*?Tokens:\*?\*?\s*([\d.]+)k?\s*\/\s*([\d.]+)k?\s*\((\d+)%\)/),We=(ie=>{const de=new RegExp(`\\|\\s*${ie}\\s*\\|\\s*([\\d.]+)k?\\s*\\|\\s*([\\d.]+)%`,"i"),Ue=X.match(de);if(Ue)return{tokens:Ue[1]+"k",percent:Ue[2]+"%"};const Ze=new RegExp(`${ie}\\s+([\\d.]+)k?\\s+([\\d.]+)%`,"i"),lt=X.match(Ze);return lt?{tokens:lt[1]+"k",percent:lt[2]+"%"}:null})("Messages"),nt=ne?parseInt(ne[3]):0,we=100-nt,Le=()=>{n&&U.setContextModalAgentId(n)};return o.jsxs("div",{className:"output-line output-context-stats",style:{cursor:n?"pointer":"default"},onClick:Le,title:n?f("terminal:history.clickForContextStats"):void 0,children:[L&&o.jsxs("span",{className:"output-timestamp context-timestamp",title:`${z} | ${W}`,children:[L," ",o.jsxs("span",{className:"context-debug-hash",children:["[",W,"]"]})]}),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:`${nt}%`}})}),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:we.toFixed(0)}),")"]}),We&&o.jsx("span",{className:"context-msgs",children:f("terminal:history.msgsLabel",{tokens:We.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"?_y(E):null,q=He=>{if(!He)return null;let X=He;if(X.includes("<persisted-output>")){X=X.replace(/<\/?persisted-output>/g,"").trim();const Le=X.match(/Preview \(first [^)]+\):\s*([\s\S]*)/);if(Le)X=Le[1].trim();else{const ie=X.indexOf("{");ie!==-1&&(X=X.slice(ie))}}const ne=Le=>{try{const ie=JSON.parse(Le);if(ie&&typeof ie=="object"&&typeof ie.output=="string")return ie.output.split(`
136
+ `).filter(de=>de.length>0)}catch{}return null},Te=ne(X);if(Te)return Te;const We=X.indexOf("{"),nt=X.lastIndexOf("}");if(We!==-1&&nt>We){const Le=ne(X.slice(We,nt+1));if(Le)return Le}const we=X.match(/"output"\s*:\s*"([\s\S]*)/);if(we){let Le=we[1];const ie=Le.match(/","(?:duration|exitCode|taskId|success)":/);ie&&ie.index!==void 0&&(Le=Le.slice(0,ie.index)),Le=Le.replace(/\.\.\.\s*$/,"");try{Le=JSON.parse(`"${Le}"`)}catch{Le=Le.replace(/\\u([0-9a-fA-F]{4})/g,(Ue,Ze)=>String.fromCharCode(parseInt(Ze,16))).replace(/\\n/g,`
137
+ `).replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\\\/g,"\\")}const de=Le.split(`
138
+ `).filter(Ue=>Ue.length>0);if(de.length>0)return de}return null};if(N==="tool_use"){const He=ms[j||""]||ms.default,X=j?vT(j,f):"",ne=e.toolInput?JSON.stringify(e.toolInput):E;if(a){let Te=j&&ne?wT(j,ne):null;j==="Bash"&&Te&&Te.length>300&&(Te=Te.substring(0,297)+"...");const nt=["Read","Edit","Write","Glob","Grep","NotebookEdit"].includes(j||""),we=Te&&(nt||Te.startsWith("/")||Te.includes("/")),Le=nt&&we&&i,ie=j==="Bash"&&c,de=D||Te||"",Ue=ie&&de?AT(de):null,Ze=ie&&de?jT(de):null,lt=ie&&de?NT(de):null,fe=ie&&de?TT(de):null,J=()=>{if(Le&&Te){if(j==="Edit"&&ne)try{const ze=JSON.parse(ne);if(ze.old_string!==void 0||ze.new_string!==void 0||ze.unified_diff!==void 0){i(Te,{oldString:ze.old_string||"",newString:ze.new_string||"",operation:typeof ze.operation=="string"?ze.operation:void 0,unifiedDiff:typeof ze.unified_diff=="string"?ze.unified_diff:void 0});return}}catch{}if(j==="Read"&&ne)try{const ze=JSON.parse(ne);if(ze.offset!==void 0&&ze.limit!==void 0){i(Te,{highlightRange:{offset:ze.offset,limit:ze.limit}});return}}catch{}i(Te)}},ae=()=>{ie&&de&&c(de,T||f("tools:display.noOutputAvailable"))},Se=()=>{var Pe;if(!Te)return null;if(!i)return o.jsx("span",{dangerouslySetInnerHTML:{__html:Oo(Te,"bash")}});const ze=n?(Pe=U.getState().agents.get(n))==null?void 0:Pe.cwd:void 0;return CT(Te).map((te,ge)=>{if(!te.fileRef)return o.jsx("span",{dangerouslySetInnerHTML:{__html:Oo(te.text,"bash")}},`cmd-${ge}`);const ve=sh(te.fileRef,ze);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}`)})},Z=ie?f("tools:display.clickToViewOutput"):Le?f("tools:display.clickToViewFile"):void 0,he=/\bcurl\b[\s\S]*\/api\/exec\b/.test(de);let De=null;if(he&&T){const ze=q(T);ze&&ze.length>0&&(De={output:ze})}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:`${z} | ${W}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",W,"]"]})]}),H&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${H}`,children:H}),o.jsx("span",{className:"output-tool-icon",children:He}),o.jsx("span",{className:"output-tool-name",children:X}),o.jsx(Hp,{content:ne})]});if((j==="AskUserQuestion"||j==="AskFollowupQuestion")&&ne){let ze=!1;try{const be=JSON.parse(ne);ze=Array.isArray(be.questions)&&be.questions.length>0}catch{}if(ze)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:`${z} | ${W}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",W,"]"]})]}),H&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${H}`,children:H}),o.jsx("span",{className:"output-tool-icon",children:He}),o.jsx("span",{className:"output-tool-name",children:X}),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:`${z} | ${W}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",W,"]"]})]}),H&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${H}`,children:H}),o.jsx("span",{className:"output-tool-icon",children:He}),o.jsx("span",{className:"output-tool-name",children:X}),o.jsx(Cx,{content:ne})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:`output-line output-tool-use output-tool-simple ${ie?"clickable-bash":""} ${Ze?"bash-notify-use":""}`,onClick:ie?ae:void 0,style:ie?{cursor:"pointer"}:void 0,title:ie?f("tools:display.clickToViewOutput"):void 0,children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${z} | ${W}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",W,"]"]})]}),H&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${H}`,children:H}),o.jsx("span",{className:"output-tool-icon",children:He}),o.jsx("span",{className:"output-tool-name",children:X}),ie&&Ze?o.jsxs("span",{className:"output-tool-param bash-command bash-notify-param",onClick:ae,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})]}):ie&&lt?o.jsxs("span",{className:"output-tool-param bash-command bash-task-label-param",onClick:ae,title:lt.commandBody,style:{cursor:"pointer"},children:[o.jsx("span",{className:"bash-task-label-chip",children:"📋 task"}),o.jsx("span",{className:"bash-task-label-value",children:lt.taskLabel})]}):ie&&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})]}):ie&&Ue?o.jsxs("span",{className:"output-tool-param bash-command bash-search-param",onClick:ae,title:Ue.commandBody,style:{cursor:"pointer"},children:[Ue.shellPrefix&&o.jsx("span",{className:"bash-search-shell",children:Ue.shellPrefix}),o.jsx("span",{className:"bash-search-chip",children:"search"}),o.jsx("span",{className:"bash-search-term",children:Ue.searchTerm})]}):Te&&o.jsxs("span",{className:`output-tool-param ${Le?"clickable-path":""}`,onClick:Le?J:void 0,title:Z,style:Le?{cursor:"pointer",textDecoration:"underline",textDecorationStyle:"dotted"}:void 0,children:[nt&&we&&(()=>{const ze=e5(Te),be=ze?ph(ze):"";return be?o.jsx("img",{className:"output-tool-file-icon",src:be,alt:""}):null})(),ie?Se():Te]})]}),he&&De&&o.jsx("div",{className:"exec-task-output-container",children:o.jsx("div",{className:"exec-task-inline status-completed",children:(()=>{const ze=`history-curl-${S}`,be=h.has(ze),Pe=De.output.slice(-6),te=De.output.length>6,ge=be?De.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(ze)?Fe.delete(ze):Fe.add(ze),Fe}),children:[o.jsx("span",{className:"exec-task-toggle-arrow",children:be?"▼":"▶"}),o.jsx("span",{className:"exec-task-toggle-text",children:be?f("tools:skills.hide"):f("tools:skills.showAll",{count:De.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:Yl(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:`${z} | ${W}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",W,"]"]})]}),H&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${H}`,children:H}),o.jsx("span",{className:"output-tool-icon",children:He}),o.jsx("span",{className:"output-tool-name",children:X})]}),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:`${z} | ${W}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",W,"]"]})]}),H&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${H}`,children:H}),o.jsx("span",{className:"output-tool-icon",children:He}),o.jsx("span",{className:"output-tool-name",children:X})]}),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:`${z} | ${W}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",W,"]"]})]}),H&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${H}`,children:H}),o.jsx("span",{className:"output-tool-icon",children:He}),o.jsx("span",{className:"output-tool-name",children:X})]}),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:`${z} | ${W}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",W,"]"]})]}),H&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${H}`,children:H}),o.jsx("span",{className:"output-tool-icon",children:He}),o.jsx("span",{className:"output-tool-name",children:X})]}),o.jsx("div",{className:"output-line output-tool-input",children:o.jsx(Cx,{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:`${z} | ${W}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",W,"]"]})]}),H&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${H}`,children:H}),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:H})})]}):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:`${z} | ${W}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",W,"]"]})]}),H&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${H}`,children:H}),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:H})})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"output-line output-tool-use",children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${z} | ${W}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",W,"]"]})]}),H&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${H}`,children:H}),o.jsx("span",{className:"output-tool-icon",children:He}),o.jsx("span",{className:"output-tool-name",children:X})]}),ne&&o.jsx("div",{className:"output-line output-tool-input",children:o.jsx("pre",{className:"output-input-content",children:Dl(ne,s)})})]})}if(N==="tool_result"){if(a)return null;const He=E.toLowerCase().includes("error")||E.toLowerCase().includes("failed");if(j==="Bash"){const X=He||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 ${X?"is-error":""}`,children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${z} | ${W}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",W,"]"]})]}),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:Yl(E)}})]})]})}return o.jsxs("div",{className:`output-line output-tool-result ${He?"is-error":""}`,children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${z} | ${W}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",W,"]"]})]}),o.jsx("span",{className:"output-result-icon",children:He?"❌":"✓"}),o.jsx("pre",{className:"output-result-content",children:Dl(E,s)})]})}const me=N==="user",ce=!me&&/^\s*(?:[\u{1F300}-\u{1FAFF}\u2600-\u27BF]\s*)?\[System\]/u.test(E),ee=me?"history-line history-user":ce?"history-line history-system":"history-line history-assistant",pe=ce?f("tools:display.system"):F;if(me&&se){const X=Ey(se.userMessage).userMessage,ne=MT(X.trim());if(ne.isDelegatedTask)return o.jsxs("div",{className:ee,children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${z} | ${W}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",W,"]"]})]}),o.jsx("span",{className:"history-content",children:o.jsx(PT,{bossName:ne.bossName,bossId:ne.bossId,taskCommand:ne.taskCommand})})]});const Te=DT(X.trim());if(Te.isTaskReport)return o.jsxs("div",{className:ee,children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${z} | ${W}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",W,"]"]})]}),o.jsxs("span",{className:"history-content",children:[se.hasContext&&se.context&&o.jsx($p,{context:se.context,onFileClick:i?nt=>i(nt):void 0},`boss-${S||E.slice(0,50)}`),o.jsx(BT,{agentName:Te.agentName,agentId:Te.agentId,status:Te.status,originalTask:Te.originalTask,summary:Te.summary})]})]});const We=RT(X.trim());return We.hasNotification?o.jsxs("div",{className:ee,children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${z} | ${W}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",W,"]"]})]}),o.jsxs("span",{className:"history-content",children:[o.jsx(FT,{agentId:We.agentId,status:We.status}),We.contentWithoutNotification&&o.jsx("span",{className:"user-prompt-text",children:s?o.jsx("div",{children:Dl(We.contentWithoutNotification,s)}):zu(We.contentWithoutNotification,r,i)})]})]}):o.jsxs("div",{className:ee,children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${z} | ${W}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",W,"]"]})]}),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?nt=>i(nt):void 0},`boss-${S||E.slice(0,50)}`),s?o.jsx("div",{children:Dl(X,s)}):zu(X,r,i)]})]})}const Ne=OT(E),ye=LT(Ne.contentWithoutBlock);return Ne.hasDelegation||ye.hasWorkPlan?o.jsxs("div",{className:ee,children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${z} | ${W}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",W,"]"]})]}),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")}),pe]}),o.jsxs("span",{className:"history-content markdown-content",children:[s?o.jsx("div",{children:Dl(ye.contentWithoutBlock,s)}):Bl(ye.contentWithoutBlock,r,i),ye.hasWorkPlan&&ye.workPlan&&o.jsx(zT,{workPlan:ye.workPlan}),Ne.hasDelegation&&Ne.delegations.map((He,X)=>o.jsx(IT,{delegation:He},`del-${X}`))]}),o.jsxs("div",{className:"message-action-btns",children:[A.experimentalTTS&&o.jsx("button",{className:"history-speak-btn",onClick:He=>{He.stopPropagation(),P(E)},title:f(O?"terminal:history.stopSpeaking":"terminal:history.speakSpanish"),children:O?"🔊":"🔈"}),d&&o.jsx("button",{className:"history-view-md-btn",onClick:He=>{He.stopPropagation(),d(E)},title:f("terminal:history.viewAsMarkdown"),children:"📄"})]})]}):o.jsxs("div",{className:ee,children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${z} | ${W}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",W,"]"]})]}),o.jsxs("span",{className:`history-role ${me?"history-role-chip":""}`,children:[!me&&!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")}),me?f("common:labels.you"):pe]}),o.jsx("span",{className:`history-content ${me?"user-prompt-text":"markdown-content"}`,children:s?o.jsx("div",{children:Dl(E,s)}):me?zu(E,r,i):Bl(E,r,i)}),!me&&o.jsxs("div",{className:"message-action-btns",children:[A.experimentalTTS&&o.jsx("button",{className:"history-speak-btn",onClick:He=>{He.stopPropagation(),P(E)},title:f(O?"terminal:history.stopSpeaking":"terminal:history.speakSpanish"),children:O?"🔊":"🔈"}),d&&o.jsx("button",{className:"history-view-md-btn",onClick:He=>{He.stopPropagation(),d(E)},title:f("terminal:history.viewAsMarkdown"),children:"📄"})]})]})});function n5(t){const e=t.split("/").pop()||t,n=e.lastIndexOf(".");return n<=0?"":e.slice(n).toLowerCase()}const s5=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:ms[c.toolName||""]||ms.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 a5(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 r5({output:t,debugHash:e,agentId:n,onClose:s}){const{t:a}=pt(["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,A=[{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&&A.push({label:"State",value:"streaming"}),t.isDelegation&&A.push({label:"Flag",value:"delegation"}),t.toolName&&A.push({label:"Tool",value:t.toolName}),t.toolInput&&A.push({label:"ToolIn",value:JSON.stringify(t.toolInput).slice(0,200),mono:!0}),t.toolOutput&&A.push({label:"ToolOut",value:`[${t.toolOutput.length} chars] ${t.toolOutput.slice(0,120)}`,mono:!0}),t.subagentName&&A.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:A.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}=pt(["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(r5,{output:t,debugHash:n,agentId:s||null,onClose:d})]})}const Oy=x.memo(function({output:e,agentId:n,execTasks:s=[],subagents:a,onImageClick:r,onFileClick:i,onBashClick:c,onViewMarkdown:d}){var we,Le,ie;const{t:f}=pt(["tools","common"]),h=eN(),m=Vr(),[b,y]=x.useState(new Set),{text:w,isStreaming:A,isUserPrompt:N,timestamp:k,skillUpdate:j,_toolKeyParam:S,_editData:T,_todoInput:D,_bashOutput:E,_bashCommand:P,_isRunning:O}=e,_=Eu(w,h),M=e.toolName,R=e.toolInput,F=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 Ue=de.questions;Array.isArray(Ue)&&((we=Ue[0])!=null&&we.question)&&($=Ue[0].question)}else if((M==="Task"||M==="Agent")&&typeof de.description=="string"){const Ue=de.description,Ze=de.subagent_type;$=Ze?`[${Ze}] ${Ue}`:Ue}else if(M==="ExitPlanMode"||M==="EnterPlanMode"){const Ue=de.allowedPrompts;Array.isArray(Ue)&&Ue.length>0?$=Ue.map(Ze=>Ze.prompt||Ze.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 Ue=de.prompt,Ze=de.receiver_thread_ids;Ue?$=Ue.length>100?Ue.slice(0,97)+"...":Ue:Ze&&Ze.length>0?$=`waiting on ${Ze.length} thread(s)`:M==="wait"&&($="waiting for subagents")}else if(M==="TodoWrite"&&Array.isArray(de.todos)){const Ue=de.todos,Ze=Ue.filter(ae=>ae.status==="completed").length,lt=Ue.filter(ae=>ae.status==="in_progress").length,fe=Ue.filter(ae=>ae.status==="pending").length,J=[];Ze>0&&J.push(`${Ze} done`),lt>0&&J.push(`${lt} active`),fe>0&&J.push(`${fe} pending`),$=`${Ue.length} items (${J.join(", ")})`}else if($=de.file_path||de.path||de.notebook_path||de.command||de.pattern||de.url||de.query||de.description,!$)try{const Ue=JSON.stringify(de);Ue&&Ue!=="{}"&&($=Ue.length>200?Ue.slice(0,197)+"...":Ue)}catch{}}const H=n?(Le=U.getState().agents.get(n))==null?void 0:Le.name:null,L=e.subagentName||H,z=n?(ie=U.getState().agents.get(n))==null?void 0:ie.provider:void 0,W=z==="codex"?"Codex":z==="opencode"?"OpenCode":"Claude",[V,G]=x.useState(!1),[B,K]=x.useState(!1),{toggle:se,speaking:q}=Ry(),me=Fp(k||Date.now()),ce=a5(e);if(j)return o.jsxs("div",{className:"output-line output-skill-update",children:[o.jsx(Gn,{output:e,timeStr:me,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,Ue)=>o.jsxs("span",{className:"skill-update-item",title:de.description,children:[de.name,Ue<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:me,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:Bl(_,r,i)})]});const pe=n?U.getLastDelegationReceived(n):null;if(N){const de=_.trim();if(de==="/context"||de==="/cost"||de==="/compact")return null;const Ue=_y(_),Ze=Ey(Ue.userMessage),lt=Ze.userMessage,fe=MT(lt.trim());if(fe.isDelegatedTask)return o.jsxs("div",{className:"output-line output-user",children:[o.jsx(Gn,{output:e,timeStr:me,debugHash:ce,agentId:n}),o.jsx(PT,{bossName:fe.bossName,bossId:fe.bossId,taskCommand:fe.taskCommand})]});const J=DT(lt.trim());if(J.isTaskReport)return o.jsxs("div",{className:"output-line output-user",children:[o.jsx(Gn,{output:e,timeStr:me,debugHash:ce,agentId:n}),Ue.hasContext&&Ue.context&&o.jsx($p,{context:Ue.context,onFileClick:i},`boss-stream-${_.slice(0,50)}`),o.jsx(BT,{agentName:J.agentName,agentId:J.agentId,status:J.status,originalTask:J.originalTask,summary:J.summary})]});const ae=RT(lt.trim());if(ae.hasNotification)return o.jsxs("div",{className:"output-line output-user",children:[o.jsx(Gn,{output:e,timeStr:me,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:zu(ae.contentWithoutNotification,r,i)})]});const Se=pe&&_.trim()===pe.taskCommand.trim();return o.jsxs("div",{className:"output-line output-user",children:[o.jsx(Gn,{output:e,timeStr:me,debugHash:ce,agentId:n}),Se?o.jsx(r6,{bossName:pe.bossName,taskCommand:pe.taskCommand}):o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"output-role output-role-chip output-role-user-chip",children:f("common:labels.you")}),Ue.hasContext&&Ue.context&&o.jsx($p,{context:Ue.context,onFileClick:i},`boss-stream-${_.slice(0,50)}`),zu(Ze.userMessage,r,i)]})]})}if(_.startsWith("Using tool:")){const de=_.replace("Using tool:","").trim(),Ue=vT(de,f),Ze=ms[de]||ms.default,lt=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 ${A?"output-streaming":""}`,children:[o.jsx(Gn,{output:e,timeStr:me,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:Ze}),o.jsx("span",{className:"output-tool-name",children:Ue}),o.jsx(Hp,{content:fe})]});const J=(de==="AskUserQuestion"||de==="AskFollowupQuestion")&&R&&typeof R=="object"&&Array.isArray(R.questions)?JSON.stringify(R):void 0;if((de==="AskUserQuestion"||de==="AskFollowupQuestion")&&J)return o.jsxs("div",{className:`output-line output-tool-use output-ask-question-inline ${A?"output-streaming":""}`,children:[o.jsx(Gn,{output:e,timeStr:me,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:Ze}),o.jsx("span",{className:"output-tool-name",children:Ue}),o.jsx(YT,{content:J})]});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 ${A?"output-streaming":""}`,children:[o.jsx(Gn,{output:e,timeStr:me,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:Ze}),o.jsx("span",{className:"output-tool-name",children:Ue}),o.jsx(Cx,{content:ae})]});const Se=de==="ToolSearch"&&R&&typeof R=="object"?JSON.stringify(R):void 0;if(de==="ToolSearch"&&Se)return o.jsxs("div",{className:`output-line output-tool-use output-toolsearch-inline ${A?"output-streaming":""}`,children:[o.jsx(Gn,{output:e,timeStr:me,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:Se,agentName:L})]});if(["spawn_agent","send_input","wait"].includes(de)){const yt=R,rt=yt==null?void 0:yt.prompt,ct=yt==null?void 0:yt.receiver_thread_ids,Ft=rt?rt.length>120?rt.slice(0,117)+"...":rt:void 0,_n=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} ${A?"output-streaming":""}`,children:[o.jsx(Gn,{output:e,timeStr:me,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:Ze}),o.jsx("span",{className:"output-tool-name collab-tool-name",children:_n}),ct&&ct.length>0&&o.jsx("span",{className:"collab-thread-ids",children:ct.map(En=>En.slice(-8)).join(", ")}),Ft&&o.jsx("span",{className:"collab-prompt-preview",title:rt,children:Ft})]})}const he=R&&typeof R=="object"?JSON.stringify(R,null,2):void 0,ze=["Read","Edit","Write","Glob","Grep","NotebookEdit"].includes(de),be=R&&typeof R=="object"?R:null,Pe=be?(typeof be.file_path=="string"?be.file_path:void 0)||(typeof be.path=="string"?be.path:void 0)||(typeof be.notebook_path=="string"?be.notebook_path:void 0):void 0,te=S||Pe,ge=!!te&&(ze||te.startsWith("/")||te.includes("/")),ve=ze&&ge&&i,Fe=de==="Edit"&&be?{oldString:String(be.old_string??""),newString:String(be.new_string??""),operation:typeof be.operation=="string"?be.operation:void 0}:void 0,Ke=de==="Read"&&be&&typeof be.offset=="number"&&typeof be.limit=="number"?{highlightRange:{offset:be.offset,limit:be.limit}}:void 0,st=de==="Bash"&&c,xt=!!E||!!F,ht=P||S||$||"",ot=ST(ht),ft=/\bcurl\b[\s\S]*\/api\/exec\b/.test(ht),ut=k?new Date(k).getTime():0,ln=ft?kT(ht):null,Kt=ft&&s.length>0?(()=>{if(ln){const rt=s.filter(ct=>ct.command===ln);if(rt.length>0)return[rt.reduce((Ft,_n)=>_n.startedAt>Ft.startedAt?_n:Ft)]}const yt=s.filter(rt=>rt.startedAt>=ut&&rt.startedAt<=ut+5e3);return yt.length>0?[yt.reduce((ct,Ft)=>Ft.startedAt>ct.startedAt?Ft:ct)]:[]})():[],Ce=!!(st&&ft&&Kt.length>0),Be=(de==="Task"||de==="Agent")&&a&&e.uuid?(()=>{for(const[,yt]of a)if(yt.toolUseId===e.uuid)return yt})():void 0,Ye=st&&ht?AT(ht):null,et=st&&ht?jT(ht):null,Et=st&&ht?NT(ht):null,$t=st&&ht?TT(ht):null,Dt=yt=>{if(yt.stopPropagation(),ve&&te){const rt=T||Fe;de==="Edit"&&rt?i(te,rt):de==="Read"&&Ke?i(te,Ke):i(te)}},qt=()=>{if(st&&ht){const yt=O?f("tools:display.running"):E||f("tools:display.noOutputCaptured");c(ht,yt)}},cn=()=>{var ct;if(!ot)return null;if(!i)return o.jsx("span",{dangerouslySetInnerHTML:{__html:Oo(ot,"bash")}});const yt=n?(ct=U.getState().agents.get(n))==null?void 0:ct.cwd:void 0;return CT(ot).map((Ft,_n)=>{if(!Ft.fileRef)return o.jsx("span",{dangerouslySetInnerHTML:{__html:Oo(Ft.text,"bash")}},`cmd-${_n}`);const En=sh(Ft.fileRef,yt);return o.jsx("span",{className:"clickable-path",onClick:bn=>{bn.stopPropagation(),i(En.path)},title:f("tools:display.clickToViewFile"),style:{cursor:"pointer",textDecoration:"underline",textDecorationStyle:"dotted"},children:Ft.text},`cmd-file-${_n}`)})};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:`output-line output-tool-use ${A?"output-streaming":""} ${st?"bash-clickable":""} ${et?"bash-notify-use":""}`,onClick:st?qt:void 0,title:st?f("tools:display.clickToViewOutput"):void 0,children:[o.jsx(Gn,{output:e,timeStr:me,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:Ze}),o.jsx("span",{className:"output-tool-name",children:Ue}),st&&ht&&(et?o.jsxs("span",{className:"output-tool-param bash-command bash-notify-param",onClick:qt,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})]}):Et?o.jsxs("span",{className:"output-tool-param bash-command bash-task-label-param",onClick:qt,title:Et.commandBody,style:{cursor:"pointer"},children:[o.jsx("span",{className:"bash-task-label-chip",children:"📋 task"}),o.jsx("span",{className:"bash-task-label-value",children:Et.taskLabel})]}):$t?o.jsxs("span",{className:"output-tool-param bash-command bash-report-task-param",onClick:qt,title:$t.commandBody,style:{cursor:"pointer"},children:[o.jsx("span",{className:`bash-report-task-chip ${$t.status==="failed"?"status-failed":"status-completed"}`,children:$t.status==="failed"?"❌ report":"✅ report"}),$t.summary&&o.jsx("span",{className:"bash-report-task-summary",children:$t.summary})]}):Ye?o.jsxs("span",{className:"output-tool-param bash-command bash-search-param",onClick:qt,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:qt,title:f("tools:display.clickToViewOutput"),style:{cursor:"pointer",fontFamily:"monospace",fontSize:"0.9em",color:"#888"},children:cn()})),!st&&$&&o.jsxs("span",{className:`output-tool-param ${ve?"clickable-path":""}`,onClick:ve?Dt: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:[ze&&ge&&(()=>{const yt=n5(te),rt=yt?ph(yt):"";return rt?o.jsx("img",{className:"output-tool-file-icon",src:rt,alt:""}):null})(),$]}),st&&!O&&o.jsx("span",{className:"bash-output-indicator",children:s.some(yt=>yt.status==="completed")?"✅":xt?"📄":"💻"}),A&&o.jsx("span",{className:"output-tool-loading",children:"..."})]}),!lt.has(de)&&he&&o.jsxs("div",{className:"output-line output-tool-input output-tool-input-fallback",children:[o.jsx(Gn,{output:e,timeStr:me,debugHash:ce,agentId:n}),o.jsx(IA,{toolName:de,content:he})]}),Ce&&o.jsx("div",{className:"exec-task-output-container",children:Kt.map(yt=>{const rt=b.has(yt.taskId),ct=yt.output.slice(-6),Ft=yt.output.length>6,_n=rt?yt.output:ct;return o.jsxs("div",{className:`exec-task-inline status-${yt.status}`,children:[Ft&&o.jsxs("div",{className:"exec-task-toggle",onClick:()=>y(En=>{const bn=new Set(En);return bn.has(yt.taskId)?bn.delete(yt.taskId):bn.add(yt.taskId),bn}),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:yt.output.length})})]}),o.jsx("div",{className:"exec-task-inline-terminal",children:o.jsxs("pre",{className:"exec-task-inline-output",children:[_n.map((En,bn)=>o.jsx("div",{dangerouslySetInnerHTML:{__html:Yl(En)}},bn)),yt.status==="running"&&o.jsx("span",{className:"exec-task-cursor",children:"▌"})]})})]},yt.taskId)})}),Be&&(Be.status==="working"||Be.activities&&Be.activities.length>0||Be.stats)&&o.jsx("div",{className:"subagent-activity-container",children:o.jsxs("div",{className:`subagent-activity-inline status-${Be.status}`,children:[o.jsxs("div",{className:"subagent-activity-header",children:[o.jsx("span",{className:"subagent-type-badge",children:Be.subagentType}),o.jsx("span",{className:"subagent-elapsed",children:Be.completedAt?`${((Be.completedAt-Be.startedAt)/1e3).toFixed(0)}s`:`${((Date.now()-Be.startedAt)/1e3).toFixed(0)}s`})]}),Be.activities&&Be.activities.length>0&&o.jsxs("div",{className:"subagent-activity-list",children:[Be.activities.slice(-8).map((yt,rt)=>o.jsxs("div",{className:"subagent-activity-item",children:[o.jsx("span",{className:"activity-icon",children:ms[yt.toolName]||ms.default}),o.jsx("span",{className:"activity-tool",children:yt.toolName}),o.jsx("span",{className:"activity-desc",children:yt.description.length>80?yt.description.slice(0,77)+"...":yt.description})]},rt)),Be.status==="working"&&o.jsx("span",{className:"subagent-cursor",children:"▌"})]}),Be.stats&&o.jsxs("div",{className:"subagent-stats-bar",children:[o.jsxs("span",{children:[(Be.stats.durationMs/1e3).toFixed(0),"s"]}),o.jsxs("span",{children:[(Be.stats.tokensUsed/1e3).toFixed(1),"K tokens"]}),o.jsxs("span",{children:[Be.stats.toolUseCount," tools"]})]}),Be.streamEntries&&Be.streamEntries.length>0&&o.jsx(s5,{entries:Be.streamEntries,isWorking:Be.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:me,debugHash:ce,agentId:n}),o.jsx(Wp,{content:de,agentName:L})]});try{const Ue=JSON.parse(de);if(Ue.file_path&&(Ue.old_string!==void 0||Ue.new_string!==void 0))return o.jsxs("div",{className:"output-line output-tool-input",children:[o.jsx(Gn,{output:e,timeStr:me,debugHash:ce,agentId:n}),o.jsx(qT,{content:de,onFileClick:i})]});if(Ue.file_path&&Ue.old_string===void 0&&Ue.new_string===void 0)return o.jsxs("div",{className:"output-line output-tool-input",children:[o.jsx(Gn,{output:e,timeStr:me,debugHash:ce,agentId:n}),o.jsx(VT,{content:de,onFileClick:i})]});if(Array.isArray(Ue.todos))return o.jsxs("div",{className:"output-line output-tool-input",children:[o.jsx(Gn,{output:e,timeStr:me,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:me,debugHash:ce,agentId:n}),o.jsx(IA,{toolName:M||"UnknownTool",content:de})]})}if(_.startsWith("Tool result:")){const de=_.replace("Tool result:","").trim(),Ue=de.toLowerCase().includes("error")||de.toLowerCase().includes("failed");return o.jsxs("div",{className:`output-line output-tool-result ${Ue?"is-error":""}`,children:[o.jsx(Gn,{output:e,timeStr:me,debugHash:ce,agentId:n}),o.jsx("span",{className:"output-result-icon",children:Ue?"❌":"✓"}),o.jsx("pre",{className:"output-result-content",children:de})]})}if(_.startsWith("Bash output:")){const de=_.replace("Bash output:","").trim(),Ue=de.toLowerCase().includes("error")||de.toLowerCase().includes("failed")||de.toLowerCase().includes("command not found")||de.toLowerCase().includes("permission denied"),Ze=de.includes("... (truncated,");return o.jsxs("div",{className:`output-line output-bash-result ${Ue?"is-error":""}`,children:[o.jsx(Gn,{output:e,timeStr:me,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")}),Ze&&o.jsx("span",{className:"bash-output-truncated",children:f("tools:display.truncated")})]}),o.jsx("pre",{className:"bash-output-content",dangerouslySetInnerHTML:{__html:Yl(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 ye=_.startsWith("[thinking]"),Me=ye?_.replace(/^\[thinking\]\s*/,""):"",qe=ye?(Me||"(processing)").replace(/\*+/g,"").replace(/\s+/g," ").trim():"",He=/^\s*(?:[\u{1F300}-\u{1FAFF}\u2600-\u27BF]\s*)?\[System\]/u.test(_),X=!!(e.subagentName&&F&&/^[✅❌]\s*Subagent\s/.test(_));let ne="output-line",Te=!0,We=!1;if(_.startsWith("Session started:")||_.startsWith("Session initialized")?(ne+=" output-session",Te=!1):_.startsWith("Tokens:")||_.startsWith("Cost:")?(ne+=" output-stats",Te=!1):ye?(ne+=" output-thinking output-tool-use",Te=!1):_.startsWith("[raw]")?(ne+=" output-raw",Te=!1):He?ne+=" output-text output-system markdown-content":(ne+=" output-text output-claude markdown-content",We=!0),A&&(ne+=" output-streaming"),We&&!A){const de=OT(_),Ue=LT(de.contentWithoutBlock);if(de.hasDelegation||Ue.hasWorkPlan)return o.jsxs("div",{className:ne,children:[o.jsx(Gn,{output:e,timeStr:me,debugHash:ce,agentId:n}),o.jsxs("span",{className:"output-role",children:[z&&o.jsx("img",{src:z==="codex"?"/assets/codex.png":z==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:"",className:"output-role-icon",title:z==="codex"?"Codex Agent":z==="opencode"?"OpenCode Agent":"Claude Agent"}),W]}),o.jsx("div",{className:"markdown-content",children:Bl(Ue.contentWithoutBlock,r,i)}),Ue.hasWorkPlan&&Ue.workPlan&&o.jsx(zT,{workPlan:Ue.workPlan}),de.hasDelegation&&de.delegations.map((Ze,lt)=>o.jsx(IT,{delegation:Ze},`del-${lt}`)),o.jsxs("div",{className:"message-action-btns",children:[m.experimentalTTS&&o.jsx("button",{className:"history-speak-btn",onClick:Ze=>{Ze.stopPropagation(),se(_)},title:q?"Stop speaking":"Speak (Spanish)",children:q?"🔊":"🔈"}),d&&o.jsx("button",{className:"history-view-md-btn",onClick:Ze=>{Ze.stopPropagation(),d(F||_)},title:"View as Markdown",children:"📄"})]})]})}const nt=We?W:He?f("tools:display.system"):null;return o.jsxs("div",{className:ne,children:[o.jsx(Gn,{output:e,timeStr:me,debugHash:ce,agentId:n}),nt&&o.jsxs("span",{className:"output-role",children:[We&&z&&o.jsx("img",{src:z==="codex"?"/assets/codex.png":z==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:"",className:"output-role-icon",title:z==="codex"?"Codex Agent":z==="opencode"?"OpenCode Agent":"Claude Agent"}),nt]}),Te?o.jsx("div",{className:"markdown-content",children:Bl(_,r,i)}):ye?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(z==="codex"?"tools:display.codexThinking":"tools:display.thinking")}),o.jsx("span",{className:"output-tool-param output-thinking-content",title:qe,children:qe})]}):_,X&&F&&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:Bl(F,r,i)})]}),We&&!A&&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(F||_)},title:"View as Markdown",children:"📄"})]})]})}),Rl={user:60,assistant:120,tool_use:40,tool_result:80,default:60};function i5(t){var n,s;if("type"in t)return Rl[t.type]||Rl.default;const e=t;return e.isUserPrompt?Rl.user:(n=e.text)!=null&&n.startsWith("Using tool:")?Rl.tool_use:(s=e.text)!=null&&s.startsWith("Tool result:")?Rl.tool_result:Rl.assistant}const o5=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(Oy,{output:e,agentId:s,execTasks:a,subagents:r,onImageClick:h,onFileClick:m,onBashClick:b,onViewMarkdown:y})})}),l5=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:A,onScrollTopReached:N,isLoadingMore:k,hasMore:j,shouldAutoScroll:S,onUserScroll:T,pinToBottom:D=!1,onPinCancel:E,isLoadingHistory:P}){const O=x.useMemo(()=>[...e,...n],[e,n]),_=e.length,M=x.useRef(!1),R=x.useRef(O.length),F=x.useRef(!1),$=x.useRef(O.length);$.current=O.length;const H=x.useRef(0),L=R1({count:O.length,getScrollElement:()=>A.current,estimateSize:K=>i5(O[K]),overscan:10,initialRect:{width:500,height:800},measureElement:K=>K.getBoundingClientRect().height});x.useEffect(()=>()=>{L.elementsCache.clear()},[L]);const z=x.useCallback(()=>{const K=A.current;if(!K)return;const se=$.current;se<=0||(L.scrollToIndex(se-1,{align:"end"}),K.scrollTop=K.scrollHeight)},[A,L]);x.useLayoutEffect(()=>{D&&(P||O.length!==0&&(M.current=!0,F.current=!0,z()))},[D,P,O.length,z]),x.useEffect(()=>{if(!D){M.current=!1,F.current=!1;return}if(P||O.length===0)return;let K;const se=()=>{M.current=!0,z(),K=requestAnimationFrame(se)};return K=requestAnimationFrame(se),()=>cancelAnimationFrame(K)},[D,P,O.length,z]),x.useEffect(()=>{if(S&&O.length!==0){if(O.length<=R.current){R.current=O.length;return}R.current=O.length,M.current=!0,z(),requestAnimationFrame(()=>{M.current=!1})}},[O.length,S,z]);const W=L.getTotalSize();x.useEffect(()=>{const K=H.current;H.current=W,S&&(D||W<=K||W-K<2||(M.current=!0,z(),requestAnimationFrame(()=>{M.current=!1})))},[W,S,D,z]);const V=x.useCallback(()=>{if(!A.current)return;const{scrollTop:K,scrollHeight:se,clientHeight:q}=A.current;D&&!M.current&&(E==null||E()),!(se-K-q<150)&&!M.current&&!F.current&&T&&T(),K<200&&j&&!k&&N&&N()},[j,k,N,T,A,D,E]);x.useEffect(()=>{const K=A.current;if(K)return K.addEventListener("scroll",V,{passive:!0}),()=>K.removeEventListener("scroll",V)},[V,A]),x.useEffect(()=>{const K=A.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()},[A]),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(o5,{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 c5=({agentId:t,onClose:e})=>{const{t:n}=pt(["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),[A,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),[P,O]=x.useState("all"),[_,M]=x.useState("all"),[R,F]=x.useState("all"),[$,H]=x.useState(!1),[L,z]=x.useState(""),[W,V]=x.useState(!0),G=x.useRef(null),B=x.useRef(null),K=x.useCallback(()=>{const we=ks.getMessages(t);i([...we]),j(ks.getStats(t))},[t]),se=x.useCallback(()=>{const we=ks.getLogs();d([...we])},[]),q=x.useCallback(async()=>{w(!0),b("");try{const we=await Pt(Ot(`/api/agents/${encodeURIComponent(t)}/process-output`)),Le=await we.json();if(!we.ok){h(null),b((Le==null?void 0:Le.error)||"Failed to load process output");return}h(Le)}catch(we){h(null),b(we instanceof Error?we.message:"Failed to load process output")}finally{w(!1),N(!0)}},[t]);x.useEffect(()=>(K(),ks.subscribe(Le=>{(Le===t||Le==="all")&&K()})),[t,K]),x.useEffect(()=>(se(),ks.subscribeLogs(()=>{se()})),[se]);const me=x.useMemo(()=>r.filter(we=>{if($){const Le=we.payload;if(!(Le!=null&&Le.text)||typeof Le.text!="string")return!1}if(P!=="all"&&we.direction!==P||_!=="all"&&we.type!==_)return!1;if(L){const Le=L.toLowerCase(),ie=we.type.toLowerCase().includes(Le),de=JSON.stringify(we.payload).toLowerCase().includes(Le);return ie||de}return!0}),[r,P,_,$,L]),ce=x.useMemo(()=>c.filter(we=>{var Le;if(R!=="all"&&we.level!==R)return!1;if(L){const ie=L.toLowerCase(),de=we.message.toLowerCase().includes(ie),Ue=((Le=we.source)==null?void 0:Le.toLowerCase().includes(ie))||!1,Ze=we.data?JSON.stringify(we.data).toLowerCase().includes(ie):!1;return de||Ue||Ze}return!0}),[c,R,L]);x.useEffect(()=>{W&&G.current&&s==="messages"&&(G.current.scrollTop=G.current.scrollHeight)},[me,W,s]),x.useEffect(()=>{W&&B.current&&s==="logs"&&(B.current.scrollTop=B.current.scrollHeight)},[ce,W,s]),x.useEffect(()=>{s==="process"&&!A&&!y&&q()},[s,A,y,q]),x.useEffect(()=>{h(null),b(""),w(!1),N(!1)},[t]);const ee=we=>{T(Le=>{const ie=new Set(Le);return ie.has(we)?ie.delete(we):ie.add(we),ie})},pe=()=>{T(new Set(me.map(we=>we.id)))},Ne=()=>{T(new Set)},ye=we=>{navigator.clipboard.writeText(we.raw)},Me=()=>{const we=me.map(Le=>Le.raw).join(`
139
+
140
+ `);navigator.clipboard.writeText(we)},qe=()=>{ks.clearMessages(t)},He=()=>{ks.clearLogs()},X=()=>{if(!f)return;const we=[`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(we)},ne=we=>{E(Le=>{const ie=new Set(Le);return ie.has(we)?ie.delete(we):ie.add(we),ie})},Te=we=>{switch(we){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"}}},We=we=>new Date(we).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3}),nt=we=>we<1024?`${we}B`:we<1024*1024?`${(we/1024).toFixed(1)}KB`:`${(we/(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:()=>H(!$),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:P,onChange:we=>O(we.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:we=>M(we.target.value),className:"filter-select",children:[o.jsx("option",{value:"all",children:n("terminal:debug.allTypes")}),k.messageTypes.map(we=>o.jsx("option",{value:we,children:we},we))]}),o.jsx("input",{type:"text",placeholder:n("terminal:debug.search"),value:L,onChange:we=>z(we.target.value),className:"search-input"})]}),o.jsxs("div",{className:"agent-debug-actions",children:[o.jsx("button",{onClick:pe,className:"action-btn",title:n("tools:display.expandAll"),children:n("tools:display.expandAll")}),o.jsx("button",{onClick:Ne,className:"action-btn",title:n("tools:display.collapseAll"),children:n("tools:display.collapseAll")}),o.jsx("button",{onClick:Me,className:"action-btn",title:n("terminal:debug.copyAll"),children:n("terminal:debug.copyAll")}),o.jsx("button",{onClick:qe,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:W,onChange:we=>V(we.target.checked)}),o.jsx("span",{className:"toggle-switch"}),n("terminal:debug.autoScroll")]})]}),o.jsx("div",{className:"agent-debug-messages",ref:G,children:me.length===0?o.jsx("div",{className:"no-messages",children:r.length===0?n("terminal:debug.noMessagesCaptured"):n("terminal:debug.noMessagesMatch")}):me.map(we=>{const Le=S.has(we.id),ie=we.payload,de=ie!=null&&ie.text&&typeof ie.text=="string"?ie.text:"",Ue=we.type==="event"&&(ie==null?void 0:ie.type)==="tool_start",Ze=we.type==="event"&&(ie==null?void 0:ie.type)==="tool_result",lt=we.type==="output"&&(de.startsWith("Using tool:")||de.startsWith("Tool input:")||de.startsWith("Tool result:")),fe=de.startsWith("Using tool:"),J=de.startsWith("Tool input:"),ae=de.startsWith("Tool result:");let Se="",Z=null,he="";if(fe)Se=de.replace("Using tool:","").trim();else if(J)try{const ft=de.replace("Tool input:","").trim();Z=JSON.parse(ft)}catch{}else ae&&(he=de.replace("Tool result:","").trim());const ze=Ue||Ze||lt,be=Ue||fe||J,Pe=Ze||ae,te=(ie==null?void 0:ie.toolName)||Se,ge=(ie==null?void 0:ie.toolInput)||Z,ve=(ie==null?void 0:ie.toolOutput)||he,Fe=de&&!lt,Ke=we.type==="event"?ie==null?void 0:ie.type:null,xt=(()=>{var ft;if(we.type!=="event"||!ie)return null;switch(Ke){case"init":return ie.model?`model: ${ie.model}`:null;case"text":return ie.text?ie.text.slice(0,50)+(ie.text.length>50?"...":""):null;case"step_complete":const ut=ie.tokens;return ut?`${ut.input||0} in / ${ut.output||0} out`:null;case"error":return((ft=ie.errorMessage)==null?void 0:ft.slice(0,40))||null;case"thinking":return ie.text?`"${ie.text.slice(0,30)}..."`:null;default:return null}})(),ot=be&&ge?(()=>{if(!ge)return null;const ft=Object.keys(ge);if(ft.length===0)return null;const ut=["file_path","path","pattern","command","content","query"];return ft.sort((Kt,Ce)=>{const Be=ut.indexOf(Kt),Ye=ut.indexOf(Ce);return Be===-1&&Ye===-1?0:Be===-1?1:Ye===-1?-1:Be-Ye}).slice(0,3).map(Kt=>{let Ce=ge[Kt];return typeof Ce=="string"?Ce.length>60&&(Ce=Ce.slice(0,60)+"..."):typeof Ce=="object"&&(Ce=JSON.stringify(Ce).slice(0,40)+"..."),{key:Kt,value:Ce}})})():null;return o.jsxs("div",{className:`debug-message debug-message-${we.direction} ${Fe?"has-text-preview":""} ${ze?"is-tool-event":""} ${be?"tool-start":""} ${Pe?"tool-result":""}`,children:[o.jsxs("div",{className:"message-header",onClick:()=>ee(we.id),children:[o.jsx("span",{className:"expand-icon",children:Le?"▼":"▶"}),o.jsx("span",{className:`direction direction-${we.direction}`,children:we.direction==="sent"?"↑ SENT":"↓ RECEIVED"}),o.jsx("span",{className:"message-type",children:ze?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"tool-icon",children:be?"🔧":"✅"}),be?"tool_start":"tool_result"]}):Ke?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"event-base",children:we.type}),o.jsx("span",{className:"event-subtype",children:Ke})]}):we.type}),ze&&te&&o.jsx("span",{className:"tool-name-inline",children:te}),!ze&&xt&&o.jsx("span",{className:"event-summary",children:xt}),o.jsx("span",{className:"message-time",children:We(we.timestamp)}),o.jsx("span",{className:"message-size",children:nt(we.size)}),o.jsx("button",{className:"copy-btn",onClick:ft=>{ft.stopPropagation(),ye(we)},title:"Copy message",children:"📋"})]}),Le&&o.jsxs("div",{className:"message-body",children:[be&&(ge||J&&!Z)&&o.jsxs("div",{className:"tool-preview",children:[ot&&ot.length>0&&o.jsx("div",{className:"tool-inputs",children:ot.map(({key:ft,value:ut})=>o.jsxs("div",{className:"tool-input-item",children:[o.jsxs("span",{className:"tool-input-key",children:[ft,":"]}),o.jsx("span",{className:"tool-input-value",children:String(ut)})]},ft))}),J&&!Z&&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&&!ze&&o.jsx("div",{className:"message-text-preview expanded",children:o.jsx("span",{className:"text-content",children:ie.text})}),o.jsx("pre",{children:PA(JSON.stringify(we.payload,(ft,ut)=>ut===void 0?null:typeof ut=="object"&&ut!==null&&!(ut instanceof Date)&&!Array.isArray(ut)&&typeof ut[Symbol.iterator]=="function"?Array.from(ut):typeof ut=="function"?`[Function: ${ut.name||"anonymous"}]`:ut,2))})]})]},we.id)})})]}),s==="logs"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"agent-debug-controls",children:[o.jsxs("select",{value:R,onChange:we=>F(we.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:we=>z(we.target.value),className:"search-input"})]}),o.jsxs("div",{className:"agent-debug-actions",children:[o.jsx("button",{onClick:He,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:W,onChange:we=>V(we.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(we=>{const Le=D.has(we.id),ie=Te(we.level);return o.jsxs("div",{className:`debug-message debug-log ${ie.className}`,children:[o.jsxs("div",{className:"message-header",onClick:()=>ne(we.id),children:[o.jsx("span",{className:"expand-icon",children:Le?"▼":"▶"}),o.jsx("span",{className:"log-level-icon",children:ie.icon}),o.jsx("span",{className:"log-level",children:we.level.toUpperCase()}),we.source&&o.jsxs("span",{className:"log-source",children:["[",we.source,"]"]}),o.jsx("span",{className:"log-message",children:we.message}),o.jsx("span",{className:"message-time",children:We(we.timestamp)})]}),Le&&we.data!==void 0?o.jsx("div",{className:"message-body",children:o.jsx("pre",{children:o.jsx(o.Fragment,{children:PA(JSON.stringify(we.data,(de,Ue)=>Ue===void 0?null:typeof Ue=="object"&&Ue!==null&&!(Ue instanceof Date)&&!Array.isArray(Ue)&&typeof Ue[Symbol.iterator]=="function"?Array.from(Ue):typeof Ue=="function"?`[Function: ${Ue.name||"anonymous"}]`:Ue,2))})})}):null]},we.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:X,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")})})]})]})},u5=3,d5=3;function f5(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 Pt(Ot(`/api/files/tree?path=${encodeURIComponent(t)}&depth=${u5}`)),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]);Ax(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 Pt(Ot(`/api/files/tree?path=${encodeURIComponent(j)}&depth=${d5}`)),T=await S.json();if(S.ok&&T.tree){const D=cp(T.tree);return n(E=>{const P=JSON.parse(JSON.stringify(E)),O=Au(P,j);return O&&(O.children=D),P}),d(E=>{const P=new Set(E);return P.add(j),Ax(T.tree,P),P}),D}}catch(S){console.error("[FileExplorer] Failed to load children:",S)}return null},[]),w=x.useCallback(async j=>{await y(j)},[y]),A=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 P=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?"":p5(_),children:M}});return cp(P)};n(E=>D(E)),d(E=>{const P=new Set;for(const O of E)P.add(T(O));return P})},[]),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=Au(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 F=0;F<R;F++){const $=Au(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 F=S;for(const $ of R)F=`${F}/${$}`,E.push(F)}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 P=new Set(m.current);let O=0;for(;O<E.length;){const M=E[O],R=Au(f.current,M);if(!(R!=null&&R.isDirectory)){O++;continue}let F=R;for(;F.children&&F.children.length===1&&((_=F.children[0])!=null&&_.isDirectory);)F=F.children[0];for(P.add(F.path);O<E.length;){if(E[O]===F.path){O++;break}O++}}i(P),await T()},[t,y]);return{tree:e,loading:s,expandedPaths:r,loadTree:b,reloadDirectory:w,renamePathInTree:A,togglePath:N,expandToPath:k,setExpandedPaths:i}}function p5(t){const e=t.lastIndexOf(".");return e===-1?"":t.slice(e).toLowerCase()}function Au(t,e){for(const n of t){if(n.path===e)return n;if(n.children){const s=Au(n.children,e);if(s)return s}}return null}function Ax(t,e){for(const n of t)n.isDirectory&&n.children&&n.children.length>0&&(e.add(n.path),Ax(n.children,e))}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 cp(t){return h5(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 m5(t){return[...t].sort((e,n)=>e.isDirectory&&!n.isDirectory?-1:!e.isDirectory&&n.isDirectory?1:e.name.toLowerCase().localeCompare(n.name.toLowerCase()))}function jx(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 g5({text:t,query:e}){const n=V6(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 b5({node:t,depth:e,selectedPath:n,expandedPaths:s,onSelect:a,onToggle:r,onContextMenu:i,searchQuery:c}){const d=x.useMemo(()=>jx(t),[t]),f=s.has(d.expansionPath),h=n===t.path||n===d.expansionPath,m=FA(t.gitStatus),b=x.useMemo(()=>d.terminalNode.children?m5(d.terminalNode.children):[],[d]),y=A=>{A.stopPropagation(),t.isDirectory?r(d.expansionPath):a(t)},w=A=>{i&&(A.preventDefault(),A.stopPropagation(),i(A,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('${q6(t)}')`},role:"img","aria-label":"file"})]}),o.jsx("span",{className:"tree-name",style:m?{color:m}:void 0,children:o.jsx(g5,{text:d.displayName,query:c})})]}),t.isDirectory&&f&&b.length>0&&o.jsx("div",{className:"tree-children",children:b.map(A=>o.jsx(Ly,{node:A,depth:e+1,selectedPath:n,expandedPaths:s,onSelect:a,onToggle:r,onContextMenu:i,searchQuery:c},A.path))})]})}const Ly=x.memo(b5,(t,e)=>{if(t.node!==e.node||t.depth!==e.depth||t.searchQuery!==e.searchQuery||t.onContextMenu!==e.onContextMenu)return!1;const n=jx(t.node).expansionPath,s=jx(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});Ly.displayName="TreeNodeItem";function Tb(t){const e=t.lastIndexOf(".")>=0?t.substring(t.lastIndexOf(".")):"";return np(e)}function x5(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=j1[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 y5({agentId:t,agents:e,onClose:n,branchInfoMap:s,fetchRemote:a,fetchingDirs:r}){const{t:i}=pt(["terminal","common"]),c=ur(),[d,f]=x.useState([]),[h,m]=x.useState(!1),[b,y]=x.useState(new Set),[w,A]=x.useState(new Set),[N,k]=x.useState(null),[j,S]=x.useState(!1),[T,D]=x.useState(()=>$a(mt.GIT_PANEL_VIEW_MODE,"flat")==="tree"?"tree":"flat"),[E,P]=x.useState(()=>$a(mt.GIT_PANEL_MODE,"changes")==="explorer"?"explorer":"changes"),[O,_]=x.useState(()=>Ta(mt.GIT_PANEL_FOLDER_IDX,0)),M=x.useCallback(fe=>{D(fe),Wr(mt.GIT_PANEL_VIEW_MODE,fe)},[]),R=x.useCallback(fe=>{P(fe),Wr(mt.GIT_PANEL_MODE,fe)},[]),F=x.useCallback(fe=>{_(fe),Pa(mt.GIT_PANEL_FOLDER_IDX,fe)},[]),[$,H]=x.useState(null),[L,z]=x.useState(null),[W,V]=x.useState(null),G=je.useRef(!1),B=je.useRef(t),K=x.useMemo(()=>{const fe=new Set,J=[];for(const Se of c.values())if(!(Se.archived||Se.directories.length===0)&&Se.assignedAgentIds.includes(t)){fe.add(Se.id);for(const Z of Se.directories)Z&&Z.trim()&&J.push(Z)}const ae=e.get(t);if(ae){for(const Se of c.values())if(!(Se.archived||Se.directories.length===0||fe.has(Se.id))&&x5({x:ae.position.x,z:ae.position.z},Se))for(const Z of Se.directories)Z&&Z.trim()&&J.push(Z)}return ae!=null&&ae.cwd&&!J.includes(ae.cwd)&&J.unshift(ae.cwd),[...new Set(J)]},[t,e,c]),se=K.length>0?K[O]||K[0]:null,q=f5(E==="explorer"?se:null);x.useEffect(()=>{E==="explorer"&&se&&q.loadTree()},[E,se]);const me=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 Se of ae.gitStatus.files){const Z=Se.path.startsWith("/")?Se.path:`${ae.dir.replace(/\/$/,"")}/${Se.path}`;fe.set(Z,Se.status)}if(fe.size===0)return q.tree;const J=ae=>ae.map(Se=>{if(Se.isDirectory){const he=Se.children?J(Se.children):void 0,De=he?he.some(ze=>ze.gitStatus||ze.hasGitChanges):!1;return De||he!==Se.children?{...Se,children:he,hasGitChanges:De}:Se}const Z=fe.get(Se.path);return Z?{...Se,gitStatus:Z}:Se});return J(q.tree)},[q.tree,d,se]);x.useEffect(()=>{B.current!==t&&(B.current=t,G.current=!1,f([]),y(new Set),A(new Set),k(null),F(0),H(null))},[t]);const ce=je.useRef(0),ee=x.useCallback(async()=>{if(K.length===0)return;const fe=++ce.current;m(!0);try{const J=[];if(await Promise.all(K.map(async ae=>{try{const Se=await Pt(Ot(`/api/files/git-status?path=${encodeURIComponent(ae)}`));if(Se.ok){const Z=await Se.json();if(Z.isGitRepo&&Z.files.length>0){const he=ae.split("/").filter(Boolean).pop()||ae;J.push({dir:ae,dirName:he,gitStatus:Z})}}}catch{}})),fe!==ce.current)return;J.sort((ae,Se)=>ae.dirName.localeCompare(Se.dirName)),f(J),!G.current&&J.length>0&&(G.current=!0,y(new Set(J.map(ae=>ae.dir))))}finally{fe===ce.current&&m(!1)}},[K]);x.useEffect(()=>{ee();const fe=setInterval(ee,15e3);return()=>clearInterval(fe)},[ee]);const pe=x.useCallback(async()=>{K.length!==0&&(await Promise.all(K.map(fe=>a(fe))),await ee())},[K,a,ee]),Ne=x.useCallback(fe=>{y(J=>{const ae=new Set(J);return ae.has(fe)?ae.delete(fe):ae.add(fe),ae})},[]),ye=x.useCallback(fe=>{A(J=>{const ae=new Set(J);return ae.has(fe)?ae.delete(fe):ae.add(fe),ae})},[]),Me=x.useCallback(async(fe,J)=>{const ae=fe.path.startsWith("/")?fe.path:`${J.replace(/\/$/,"")}/${fe.path}`;S(!0);try{if(Gf(fe.status)){let Se="",Z="";if(fe.status!=="deleted")try{const he=await Pt(Ot(`/api/files/read?path=${encodeURIComponent(ae)}`));if(he.ok){const De=await he.json();De.content!=null&&(Z=De.content)}}catch{}try{const he=await Pt(Ot(`/api/files/git-original?path=${encodeURIComponent(ae)}`));if(he.ok){const De=await he.json();De.content!=null&&(Se=De.content)}}catch{}k({type:"diff",data:{filePath:ae,fileName:fe.name,originalContent:Se,modifiedContent:Z,language:Tb(fe.name)}})}else{let Se="";try{const Z=await Pt(Ot(`/api/files/read?path=${encodeURIComponent(ae)}`));if(Z.ok){const he=await Z.json();he.content!=null&&(Se=he.content)}}catch{}k({type:"content",data:{filePath:ae,fileName:fe.name,content:Se,language:Tb(fe.name)},isNewFile:!0})}}catch{}finally{S(!1)}},[]),qe=x.useCallback(async fe=>{if(!fe.isDirectory){H(fe.path),S(!0);try{const J=fe.name,ae=Tb(J);if(fe.gitStatus&&Gf(fe.gitStatus)){let Se="",Z="";if(fe.gitStatus!=="deleted")try{const he=await Pt(Ot(`/api/files/read?path=${encodeURIComponent(fe.path)}`));if(he.ok){const De=await he.json();De.content!=null&&(Z=De.content)}}catch{}try{const he=await Pt(Ot(`/api/files/git-original?path=${encodeURIComponent(fe.path)}`));if(he.ok){const De=await he.json();De.content!=null&&(Se=De.content)}}catch{}k({type:"diff",data:{filePath:fe.path,fileName:J,originalContent:Se,modifiedContent:Z,language:ae}})}else{let Se="";try{const Z=await Pt(Ot(`/api/files/read?path=${encodeURIComponent(fe.path)}`));if(Z.ok){const he=await Z.json();he.content!=null&&(Se=he.content)}}catch{}k({type:"content",data:{filePath:fe.path,fileName:J,content:Se,language:ae},isNewFile:fe.gitStatus==="added"||fe.gitStatus==="untracked"})}}finally{S(!1)}}},[]),He=x.useMemo(()=>{const fe=[],J=(ae,Se,Z)=>{for(const he of ae)if(he.isDirectory)J(he.children,Se,Z);else{const De=Se.find(ze=>ze.path===he.path);De&&fe.push({file:De,repoDir:Z})}};for(const ae of d)if(b.has(ae.dir))if(T==="tree"){const Se=Nb(ae.gitStatus.files);J(Se,ae.gitStatus.files,ae.dir)}else for(const Se of ae.gitStatus.files)fe.push({file:Se,repoDir:ae.dir});return fe},[d,T,b]),X=x.useCallback(async fe=>{if(!N)return;const J=N.data.filePath,ae=He.findIndex(({file:De,repoDir:ze})=>(De.path.startsWith("/")?De.path:`${ze.replace(/\/$/,"")}/${De.path}`)===J);if(ae<0)return;const Se=ae+fe;if(Se<0||Se>=He.length)return;const{file:Z,repoDir:he}=He[Se];await Me(Z,he)},[N,He,Me]),ne=x.useMemo(()=>{if(!N)return-1;const fe=N.data.filePath;return He.findIndex(({file:J,repoDir:ae})=>(J.path.startsWith("/")?J.path:`${ae.replace(/\/$/,"")}/${J.path}`)===fe)},[N,He]),Te=x.useCallback(()=>k(null),[]),We=x.useCallback(()=>z(null),[]),nt=x.useCallback(async fe=>{try{const J=await Pt(Ot("/api/files/delete"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:fe.path})});if(J.ok){if(fe.status==="added")try{await Pt(Ot("/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 J.json().catch(()=>({error:"Unknown error"}));console.error("Delete failed:",ae.error)}ee(),E==="explorer"&&q.loadTree()}catch(J){console.error("Delete request failed:",J)}finally{V(null)}},[ee,E,q]),[we,Le]=x.useState(null),ie=x.useCallback(async fe=>{try{await Pt(Ot("/api/files/git-discard"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:[{path:fe.path,status:fe.status}],directory:fe.repoDir})}),ee()}catch{}finally{Le(null)}},[ee]),de=x.useCallback((fe,J,ae)=>{fe.stopPropagation();const Se=J.path.startsWith("/")?J.path:`${ae.replace(/\/$/,"")}/${J.path}`;J.status==="untracked"||J.status==="added"?V({path:Se,name:J.name,status:J.status,repoDir:ae}):Le({path:Se,name:J.name,status:J.status,repoDir:ae})},[]),Ue=x.useCallback((fe,J,ae)=>{fe.preventDefault(),fe.stopPropagation();const Se=J.path.startsWith("/")?J.path:`${ae.replace(/\/$/,"")}/${J.path}`,Z=[];Z.push({id:"view",label:Gf(J.status)?"View Diff":"View File",icon:Gf(J.status)?"📊":"📄",onClick:()=>Me(J,ae)}),Z.push({id:"div1",label:"",divider:!0,onClick:()=>{}}),Z.push({id:"copy-path",label:"Copy Full Path",icon:"🧷",onClick:()=>{navigator.clipboard.writeText(Se)}}),Z.push({id:"copy-rel",label:"Copy Relative Path",icon:"📋",onClick:()=>{navigator.clipboard.writeText(J.path)}}),J.status!=="deleted"&&(Z.push({id:"div2",label:"",divider:!0,onClick:()=>{}}),Z.push({id:"open-editor",label:"Open in Editor",icon:"✏️",onClick:async()=>{try{await Pt(Ot("/api/files/open-in-editor"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Se})})}catch{}}})),(J.status==="modified"||J.status==="deleted"||J.status==="renamed")&&(Z.push({id:"div3",label:"",divider:!0,onClick:()=>{}}),Z.push({id:"discard",label:"Discard Changes",icon:"↩️",danger:!0,onClick:async()=>{try{await Pt(Ot("/api/files/git-discard"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:[{path:Se,status:J.status}],directory:ae})}),ee()}catch{}}})),J.status!=="deleted"&&(J.status==="modified"||J.status==="renamed"||Z.push({id:"div-del",label:"",divider:!0,onClick:()=>{}}),Z.push({id:"delete",label:"Delete File",icon:"🗑️",danger:!0,onClick:()=>V({path:Se,name:J.name,status:J.status,repoDir:ae})})),z({isOpen:!0,position:{x:fe.clientX,y:fe.clientY},actions:Z})},[Me]),Ze=x.useCallback((fe,J)=>{fe.preventDefault(),fe.stopPropagation();const ae=[];if(J.isDirectory||(ae.push({id:"view",label:"View File",icon:"📄",onClick:()=>qe(J)}),ae.push({id:"div1",label:"",divider:!0,onClick:()=>{}})),ae.push({id:"copy-path",label:"Copy Full Path",icon:"🧷",onClick:()=>{navigator.clipboard.writeText(J.path)}}),se){const Se=J.path.startsWith(se)?J.path.slice(se.replace(/\/$/,"").length+1):J.path;ae.push({id:"copy-rel",label:"Copy Relative Path",icon:"📋",onClick:()=>{navigator.clipboard.writeText(Se)}})}J.isDirectory||(ae.push({id:"div2",label:"",divider:!0,onClick:()=>{}}),ae.push({id:"open-editor",label:"Open in Editor",icon:"✏️",onClick:async()=>{try{await Pt(Ot("/api/files/open-in-editor"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:J.path})})}catch{}}}),ae.push({id:"div-del",label:"",divider:!0,onClick:()=>{}}),ae.push({id:"delete",label:"Delete File",icon:"🗑️",danger:!0,onClick:()=>V({path:J.path,name:J.name,status:J.gitStatus||"untracked",repoDir:se||""})})),z({isOpen:!0,position:{x:fe.clientX,y:fe.clientY},actions:ae})},[qe,se]),lt=d.reduce((fe,J)=>fe+J.gitStatus.files.length,0);return x.useEffect(()=>{if(!N&&!W&&!we)return;const fe=J=>{J.key==="Escape"&&(J.stopImmediatePropagation(),J.preventDefault(),we?Le(null):W?V(null):Te())};return document.addEventListener("keydown",fe,!0),()=>document.removeEventListener("keydown",fe,!0)},[N,Te,W,we]),Jt("guake-git-diff-modal",N!==null,Te),Jt("guake-git-delete-confirm",W!==null,()=>V(null)),Jt("guake-git-discard-confirm",we!==null,()=>Le(null)),x.useEffect(()=>{if(T==="tree"&&w.size===0&&d.length>0){const fe=new Set;for(const J of d){const ae=Nb(J.gitStatus.files),Se=Z=>{for(const he of Z)he.isDirectory&&(fe.add(he.path),Se(he.children))};Se(ae)}A(fe)}},[T,d]),o.jsxs(o.Fragment,{children:[W&&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:W.name}),"?"]}),o.jsx("p",{className:"guake-git-delete-path",children:W.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:()=>nt(W),children:"Delete"})]})]})}),we&&o.jsx("div",{className:"guake-git-diff-modal-overlay",onClick:()=>Le(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:we.name}),"?"]}),o.jsx("p",{className:"guake-git-delete-path",children:we.path}),o.jsxs("div",{className:"guake-git-delete-actions",children:[o.jsx("button",{className:"guake-git-delete-cancel",onClick:()=>Le(null),children:"Cancel"}),o.jsx("button",{className:"guake-git-delete-btn",onClick:()=>ie(we),children:"Discard"})]})]})}),N&&o.jsx("div",{className:"guake-git-diff-modal-overlay",onClick:Te,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:()=>X(-1),disabled:ne<=0,title:"Previous file",children:"‹"}),o.jsx("button",{className:"guake-git-diff-nav-btn",onClick:()=>X(1),disabled:ne<0||ne>=He.length-1,title:"Next file",children:"›"}),ne>=0&&o.jsxs("span",{className:"guake-git-diff-nav-counter",children:[ne+1," / ",He.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:Te,title:"Close (Esc)",children:"×"})]}),o.jsx("div",{className:"guake-git-diff-content",children:N.type==="diff"?o.jsx(bx,{originalContent:N.data.originalContent,modifiedContent:N.data.modifiedContent,filename:N.data.fileName,language:N.data.language}):o.jsx(bx,{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",lt>0&&o.jsx("span",{className:"guake-git-badge",children:lt})]}),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:pe,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:ee,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:J,gitStatus:ae})=>{const Se=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:()=>Ne(fe),children:[o.jsx("span",{className:"guake-git-repo-arrow",children:b.has(fe)?"▼":"▶"}),o.jsx("span",{className:"guake-git-repo-name",children:J}),ae.branch&&o.jsxs("span",{className:"guake-git-repo-branch",children:["⎇ ",ae.branch]}),Se&&Se.ahead>0&&o.jsxs("span",{className:"guake-branch-ahead",children:["↑",Se.ahead]}),Se&&Se.behind>0&&o.jsxs("span",{className:"guake-branch-behind",children:["↓",Se.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(Z=>{const he=j1[Z.status],De=ph(Z.name);return o.jsxs("div",{className:"guake-git-file","data-status":Z.status,onClick:()=>Me(Z,fe),onContextMenu:ze=>Ue(ze,Z,fe),title:Z.path,children:[De&&o.jsx("img",{src:De,alt:"",className:"guake-git-file-icon"}),o.jsx("span",{className:"guake-git-file-name",children:Z.name}),o.jsx("span",{className:"guake-git-file-dir",children:Z.path.includes("/")?Z.path.substring(0,Z.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:Z.status==="untracked"||Z.status==="added"?"Delete file":"Discard changes",onClick:ze=>de(ze,Z,fe),children:"↩"})]},Z.path)})}),b.has(fe)&&T==="tree"&&o.jsx("div",{className:"guake-git-file-list",children:Nb(ae.files).map(Z=>o.jsx(JT,{node:Z,depth:0,expandedDirs:w,onToggleDir:ye,onFileClick:Me,onContextMenu:Ue,onDiscard:de,repoDir:fe},Z.path))})]},fe)})]}),E==="explorer"&&o.jsxs(o.Fragment,{children:[K.length>1&&o.jsx("div",{className:"guake-git-folder-selector",children:K.map((fe,J)=>{const ae=fe.split("/").filter(Boolean).pop()||fe,Se=s.get(fe);return o.jsxs("button",{className:`guake-git-folder-btn ${J===O?"active":""}`,onClick:()=>F(J),title:fe,children:["📂 ",ae,Se&&o.jsxs("span",{className:"guake-git-folder-branch",children:[" ⎇ ",Se.branch]}),Se&&Se.ahead>0&&o.jsxs("span",{className:"guake-branch-ahead",children:["↑",Se.ahead]}),Se&&Se.behind>0&&o.jsxs("span",{className:"guake-branch-behind",children:["↓",Se.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:me.map(fe=>o.jsx(Ly,{node:fe,depth:0,selectedPath:$,expandedPaths:q.expandedPaths,onSelect:qe,onToggle:q.togglePath,onContextMenu:Ze,searchQuery:""},fe.path))})]})]})]}),L&&o.jsx(Lo,{isOpen:L.isOpen,position:L.position,worldPosition:{x:0,z:0},actions:L.actions,onClose:We})]})}async function hh(t,e){const n=Fi(),s=await fetch(`${Ma()}${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 v5(t){return hh("/api/agents/bulk/delete",{agentIds:t})}async function w5(t){return hh("/api/agents/bulk/stop",{agentIds:t})}async function k5(t){return hh("/api/agents/bulk/clear-context",{agentIds:t})}async function S5(t,e){return hh("/api/agents/bulk/move-area",{agentIds:t,areaId:e})}function C5(t){return Array.from(t.values())}const A5={">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 j5(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 N5({isOpen:t,onClose:e}){const n=Kp(),s=ur(),a=C5(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"),[A,N]=x.useState(""),[k,j]=x.useState(new Set),[S,T]=x.useState(null),[D,E]=x.useState(""),[P,O]=x.useState(null),[_,M]=x.useState(null),[R,F]=x.useState(!1);x.useEffect(()=>{t&&(j(new Set),O(null),M(null),T(null))},[t]);const $=x.useMemo(()=>{const G=Date.now(),B=A.toLowerCase().trim();return n.filter(K=>{if(r!=="all"&&K.status!==r||c!=="any"&&G-K.lastActivity<A5[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,A]);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 H=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)))},[$]),z=x.useCallback(()=>{j(new Set)},[]),W=x.useCallback(async G=>{const B=Array.from(k);if(B.length!==0){F(!0),O(null),M(null);try{let K,se="";switch(G){case"delete":K=await v5(B),se="Deleted",K.failed.length===0&&j(new Set);break;case"stop":K=await w5(B),se="Stopped";break;case"clear-context":K=await k5(B),se="Cleared context for";break;case"move-area":K=await S5(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{F(!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:A,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:z,children:"Select none"})]})]}),P&&o.jsxs("div",{className:"bulk-alert bulk-alert-error",children:[o.jsx("span",{className:"alert-icon",children:"!"}),P]}),_&&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?z():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:()=>H(G.id),children:[o.jsx("td",{className:"col-check",children:o.jsx("input",{type:"checkbox",checked:k.has(G.id),onChange:()=>H(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:j5(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:()=>W(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:()=>W("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:()=>W("move-area"),children:"Move to Area"})]})]})]})})}):null}const T5={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 _5(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 E5(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 M5({activeAgentId:t,onClose:e,onSelectAgent:n,agentListRef:s,twoFingerState:a}){const{t:r}=pt(["terminal","common"]),i=Kp(),[c]=Fj(),d=x.useMemo(()=>c?i.filter(Ce=>{const Be=U.getAreaForAgent(Ce.id);return $x((Be==null?void 0:Be.id)??null)}):i,[i,c]),f=cN(),h=Gx(),m=pL(),b=ur(),y=sN();x.useEffect(()=>{for(const Ce of d)!U.hasHistoryBeenFetched(Ce.id)&&!U.isLoadingHistoryForAgent(Ce.id)&&U.requestAgentSupervisorHistory(Ce.id)},[d]);const w=x.useMemo(()=>Ta(mt.AOP_CONFIG,{groupByArea:!0,sortMode:"recent",filterMode:"all",allExpanded:!1,sameAreaOnly:!1,showSubagents:!0,showRecentActivity:!0,visibleAreaIds:null}),[]),[A,N]=x.useState(()=>w.allExpanded?new Set(d.map(Ce=>Ce.id)):new Set),[k,j]=x.useState(new Set),[S,T]=x.useState(null),[D,E]=x.useState(""),[P,O]=x.useState(w.sortMode),[_,M]=x.useState(w.filterMode),[R,F]=x.useState(""),[$,H]=x.useState(w.groupByArea),[L,z]=x.useState(w.allExpanded),[W,V]=x.useState(w.sameAreaOnly),[G,B]=x.useState(w.showSubagents),[K,se]=x.useState(w.showRecentActivity),[q,me]=x.useState(w.visibleAreaIds?new Set(w.visibleAreaIds):null),[ce,ee]=x.useState(!1),[pe,Ne]=x.useState(""),[ye,Me]=x.useState(!1),qe=x.useRef(null),[He,X]=x.useState(()=>typeof window<"u"?window.matchMedia("(max-width: 768px)").matches:!1),[ne,Te]=x.useState(()=>typeof window<"u"?window.matchMedia("(max-width: 768px)").matches:!1),[We,nt]=x.useState(null),[we,Le]=x.useState(null),ie=x.useRef(null),de=x.useRef(null),Ue=s||de,Ze=x.useRef(!1),lt=x.useRef(new Map),fe=a||{hoveredAgentId:null};x.useEffect(()=>{if(typeof window>"u")return;const Ce=window.matchMedia("(max-width: 768px)"),Be=et=>{X(et),Te(et)};Be(Ce.matches);const Ye=et=>Be(et.matches);return Ce.addEventListener("change",Ye),()=>Ce.removeEventListener("change",Ye)},[]),x.useEffect(()=>{if(!ce){Ne("");return}const Ce=Be=>{qe.current&&!qe.current.contains(Be.target)&&(ee(!1),Ne(""))};return document.addEventListener("mousedown",Ce),()=>document.removeEventListener("mousedown",Ce)},[ce]),x.useEffect(()=>{const Ce=Be=>{var et,Et;Be.altKey&&Be.shiftKey&&!Be.ctrlKey&&!Be.metaKey&&Be.code==="KeyF"&&(Be.preventDefault(),(et=ie.current)==null||et.focus(),(Et=ie.current)==null||Et.select())};return document.addEventListener("keydown",Ce,!0),()=>document.removeEventListener("keydown",Ce,!0)},[]),x.useEffect(()=>{Pa(mt.AOP_CONFIG,{groupByArea:$,sortMode:P,filterMode:_,allExpanded:L,sameAreaOnly:W,showSubagents:G,showRecentActivity:K,visibleAreaIds:q?Array.from(q):null})},[$,P,_,L,W,G,K,q]);const J=x.useMemo(()=>{const Ce=[];for(const[,Be]of b)Be.archived||Ce.push({id:Be.id,name:Be.name,color:Be.color});return Ce.sort((Be,Ye)=>Be.name.localeCompare(Ye.name,void 0,{sensitivity:"base"})),Ce},[b]),ae=q===null,Se=x.useCallback(Ce=>{me(Be=>{if(Be===null){const et=new Set(J.map(Et=>Et.id));return et.add("__unassigned__"),et.delete(Ce),et}const Ye=new Set(Be);return Ye.has(Ce)?Ye.delete(Ce):Ye.add(Ce),Ye.size>=J.length+1?null:Ye})},[J]),Z=x.useCallback(()=>me(null),[]),he=x.useMemo(()=>{const Ce=new Map;for(const Be of d){const Ye=U.getAreaForAgent(Be.id);!Ye||Ye.archived||Ce.set(Be.id,{color:Ye.color,name:Ye.name})}return Ce},[d,b]),De=x.useMemo(()=>{const Ce=new Map;for(const Be of h){const Ye=Ce.get(Be.agentId)||[];Ye.push(Be),Ce.set(Be.agentId,Ye)}return Ce},[h]),ze=x.useMemo(()=>{const Ce=new Map;for(const[,Be]of m){const Ye=Ce.get(Be.parentAgentId)||[];Ye.push(Be),Ce.set(Be.parentAgentId,Ye)}return Ce},[m]),be=x.useMemo(()=>{const Ce=new Map;for(const Be of d){const Ye=U.getAreaForAgent(Be.id);!Ye||Ye.archived||Ce.set(Be.id,Ye.id)}return Ce},[d,b]),[Pe,te]=x.useMemo(()=>{const Ce=be.get(t)??null,Be=new Map;return[d.filter(et=>{if(_==="working"&&et.status!=="working"||_==="idle"&&et.status!=="idle"||_==="error"&&et.status!=="error"||W&&(be.get(et.id)??null)!==Ce)return!1;if(R){const Et=R.toLowerCase();if(et.name.toLowerCase().includes(Et)||et.id.includes(Et)||(et.class||"").toLowerCase().includes(Et)||(et.taskLabel||"").toLowerCase().includes(Et))return!0;const $t=et.lastAssignedTask||"";if($t.toLowerCase().includes(Et))return Be.set(et.id,{type:"task",text:$t}),!0;const Dt=U.getAgentSupervisorHistory(et.id);for(const qt of Dt){const cn=qt.analysis.recentWorkSummary,yt=qt.analysis.statusDescription;if(cn.toLowerCase().includes(Et))return Be.set(et.id,{type:"history",text:cn}),!0;if(yt.toLowerCase().includes(Et))return Be.set(et.id,{type:"history",text:yt}),!0}for(const qt of y)if(qt.agentId===et.id&&qt.filePath.toLowerCase().includes(Et))return Be.set(et.id,{type:"file",text:qt.filePath}),!0;return!1}return!0}),Be]},[d,_,R,W,be,t,y]),ge=x.useCallback((Ce,Be="__default__")=>{const Ye=new Set(Ce.map(rt=>rt.id)),et=lt.current.get(Be),Et=!et||et.length!==Ce.length||et.some(rt=>!Ye.has(rt)),$t=rt=>{const ct=!!(rt.isBoss||rt.class==="boss");if(P==="name")return`${ct?"0":"1"}`;if(P==="status"){const _n=["working","waiting_input","waiting_permission","error","idle","stopped"].indexOf(rt.status),En=f.has(rt.id)?"0":"1";return`${ct?"0":"1"}-${_n}-${En}`}return`${ct?"0":"1"}`};let Dt=!1;if(et&&!Et){const rt=lt.current.get(Be+"__buckets");if(rt)for(const ct of Ce){const Ft=et.indexOf(ct.id);if(Ft>=0&&rt[Ft]!==$t(ct)){Dt=!0;break}}else Dt=!0}let qt;if(Et||Dt||P==="recent")qt=[...Ce].sort((rt,ct)=>{var Is,_s;const Ft=!!(rt.isBoss||rt.class==="boss"),_n=!!(ct.isBoss||ct.class==="boss");if(Ft!==_n)return Ft?-1:1;if(P==="name")return rt.name.localeCompare(ct.name);if(P==="status"){const ts=["working","waiting_input","waiting_permission","error","idle","stopped"],Ks=ts.indexOf(rt.status)-ts.indexOf(ct.status);if(Ks!==0)return Ks;const Bn=f.has(rt.id),us=f.has(ct.id);if(Bn!==us)return Bn?-1:1;if(rt.status==="working"&&ct.status==="working")return rt.name.localeCompare(ct.name);if(rt.status==="idle"&&ct.status==="idle"){const Un=!!rt.taskLabel,Qs=!!ct.taskLabel;return Un!==Qs?Un?-1:1:(ct.lastActivity||0)-(rt.lastActivity||0)}return(ct.lastActivity||0)-(rt.lastActivity||0)}const En=((Is=(De.get(rt.id)||[])[0])==null?void 0:Is.timestamp)||rt.lastActivity||0;return(((_s=(De.get(ct.id)||[])[0])==null?void 0:_s.timestamp)||ct.lastActivity||0)-En});else{const rt=new Map(Ce.map(ct=>[ct.id,ct]));qt=et.map(ct=>rt.get(ct)).filter(Boolean)}const cn=qt.map(rt=>rt.id),yt=qt.map(rt=>$t(rt));return lt.current.set(Be,cn),lt.current.set(Be+"__buckets",yt),qt},[P,De,f]),ve=x.useMemo(()=>{if(!$)return[{area:null,agents:ge(Pe,"__flat__")}];const Ce=new Map,Be=[];for(const et of Pe){const Et=U.getAreaForAgent(et.id);if(!Et||Et.archived){Be.push(et);continue}const $t=Ce.get(Et.id);$t?$t.push(et):Ce.set(Et.id,[et])}const Ye=[];for(const[et,Et]of b){if(Et.archived||q&&!q.has(et))continue;const $t=Ce.get(et)||[];$t.length>0&&Ye.push({area:Et,agents:ge($t,`area_${et}`)})}return Be.length>0&&(!q||q.has("__unassigned__"))&&Ye.push({area:null,agents:ge(Be,"__unassigned__")}),Ye},[b,Pe,ge,$,q]),Fe=x.useCallback(Ce=>{const Be=Dt=>f.has(Dt.id),Ye=Ce.findIndex(Dt=>Be(Dt)&&Dt.status!=="working"),et=Ye>=0,Et=Ce.findIndex(Dt=>Dt.status==="idle"&&!Be(Dt)),$t=Et>=0&&Ce.slice(0,Et).some(Dt=>Dt.status==="working"||Be(Dt));return Ce.map((Dt,qt)=>o.jsxs(je.Fragment,{children:[et&&qt===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"})}),$t&&qt===Et&&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(D5,{agent:Dt,isActive:Dt.id===t,isExpanded:A.has(Dt.id),isMobile:He,hasPendingRead:f.has(Dt.id),isTwoFingerHovered:fe.hoveredAgentId===Dt.id,showSubagents:G,showRecentActivity:K,showAreaChip:!$,toolExecs:De.get(Dt.id)||[],subagents:ze.get(Dt.id)||[],areaInfo:he.get(Dt.id),matchContext:te.get(Dt.id),onToggle:()=>st(Dt.id),onSelect:()=>n(Dt.id),onClearContext:()=>U.clearContext(Dt.id),onContextMenu:cn=>Le({agentId:Dt.id,position:cn})})]},Dt.id))},[r,t,A,f,fe.hoveredAgentId,G,K,$,De,ze,he,te,n]),Ke=x.useMemo(()=>{const Ce={total:d.length,working:0,idle:0,error:0};for(const Be of d)Be.status==="working"?Ce.working++:Be.status==="error"?Ce.error++:Be.status==="idle"&&Ce.idle++;return Ce},[d]),st=Ce=>{N(Be=>{const Ye=new Set(Be);return Ye.has(Ce)?Ye.delete(Ce):Ye.add(Ce),Ye})},xt=Ce=>{j(Be=>{const Ye=new Set(Be);return Ye.has(Ce)?Ye.delete(Ce):Ye.add(Ce),Ye})},ht=()=>{N(new Set(d.map(Ce=>Ce.id))),z(!0)},ot=()=>{N(new Set),z(!1)},ft=x.useCallback(Ce=>{window.dispatchEvent(new CustomEvent("tide:open-spawn-modal",{detail:{areaId:Ce.id,position:{x:Ce.center.x,z:Ce.center.z}}}))},[]),ut=x.useCallback((Ce,Be)=>{nt({areaId:Ce.id,position:Be})},[]),ln=x.useMemo(()=>{if(!We)return[];const Ce=b.get(We.areaId);return Ce?[{id:"spawn-agent",label:r("common:agentBar.newAgent"),icon:"+",onClick:()=>ft(Ce)}]:[]},[We,b,ft,r]),Kt=x.useMemo(()=>{if(!we)return[];const Ce=d.find(Ye=>Ye.id===we.agentId);if(!Ce)return[];const Be=A.has(Ce.id);return[{id:"toggle-expand",label:Be?r("terminal:overview.collapse",{defaultValue:"Collapse"}):r("terminal:overview.expand",{defaultValue:"Expand"}),icon:Be?"▾":"▸",onClick:()=>st(Ce.id)},{id:"clear-context",label:r("terminal:overview.clearContext",{defaultValue:"Clear context"}),icon:"🧹",onClick:()=>U.clearContext(Ce.id)},{id:"remove-agent",label:r("terminal:overview.removeAgent",{defaultValue:"Remove agent"}),icon:"🗑",danger:!0,onClick:()=>U.removeAgent(Ce.id)}]},[we,d,A,r]);return x.useEffect(()=>{const Ce=Ue.current;if(!Ce)return;const Be=requestAnimationFrame(()=>{const Ye=Ce.querySelector(".aop-agent-card.active");if(!Ye)return;const et=Ce.getBoundingClientRect(),Et=Ye.getBoundingClientRect(),$t=Et.top-et.top,Dt=Ce.scrollTop+$t-(et.height-Et.height)/2,qt=Math.max(0,Dt);Math.abs(Ce.scrollTop-qt)<2||(Ce.scrollTo({top:qt,behavior:Ze.current?"smooth":"auto"}),Ze.current=!0)});return()=>cancelAnimationFrame(Be)},[t]),o.jsxs("div",{className:`agent-overview-panel${He&&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:()=>{Te(!1),requestAnimationFrame(()=>{var Ce;return(Ce=ie.current)==null?void 0:Ce.focus()})},title:"Search agents",children:"🔍"}),o.jsx("button",{type:"button",className:`aop-filters-toggle${ne?" collapsed":""}`,onClick:()=>Te(Ce=>!Ce),title:ne?"Show filters":"Hide filters",children:ne?"Filters":"Hide filters"}),o.jsxs("select",{value:_,onChange:Ce=>M(Ce.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:P,onChange:Ce=>O(Ce.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:ie,type:"text",placeholder:r("terminal:overview.searchAgents"),value:R,onChange:Ce=>F(Ce.target.value),onKeyDown:Ce=>{Ce.key==="Enter"&&(Ce.nativeEvent.isComposing||R.trim().length!==0&&Pe.length!==0&&(Ce.preventDefault(),n(Pe[0].id),F("")))},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:ht,className:"action-btn",title:r("common:buttons.expand"),children:r("common:buttons.expand")}),o.jsx("button",{onClick:ot,className:"action-btn",title:r("common:buttons.collapse"),children:r("common:buttons.collapse")}),o.jsx("button",{onClick:()=>H(Ce=>!Ce),className:`action-btn action-btn--toggle${$?" active":""}`,title:r("terminal:overview.areas"),children:r("terminal:overview.areas")}),$&&J.length>0&&o.jsxs("div",{className:"aop-area-filter",ref:qe,children:[o.jsxs("button",{className:`action-btn action-btn--toggle${ae?"":" active"}`,onClick:()=>ee(Ce=>!Ce),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:[J.length>=5&&o.jsx("div",{className:"aop-area-filter-search",children:o.jsx("input",{type:"text",placeholder:"Filter areas...",value:pe,onChange:Ce=>Ne(Ce.target.value),onClick:Ce=>Ce.stopPropagation(),autoFocus:!0})}),(()=>{const Ce=pe.toLowerCase().trim(),Be=Ce?J.filter(et=>et.name.toLowerCase().includes(Ce)):J,Ye=!Ce||"unassigned".includes(Ce);return o.jsxs(o.Fragment,{children:[!Ce&&o.jsxs(o.Fragment,{children:[o.jsxs("label",{className:"aop-area-filter-option",onClick:Z,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"})]}),Be.map(et=>{const Et=ae||((q==null?void 0:q.has(et.id))??!1);return o.jsxs("label",{className:"aop-area-filter-option",onClick:$t=>{$t.preventDefault(),Se(et.id)},children:[o.jsx("input",{type:"checkbox",checked:Et,readOnly:!0}),o.jsx("span",{className:"aop-area-filter-color",style:{background:et.color}}),o.jsx("span",{className:"aop-area-filter-name",children:et.name})]},et.id)}),Ye&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"aop-area-filter-divider"}),o.jsxs("label",{className:"aop-area-filter-option",onClick:et=>{et.preventDefault(),Se("__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"})]})]}),Ce&&Be.length===0&&!Ye&&o.jsx("div",{className:"aop-area-filter-empty",children:"No matching areas"})]})})()]})]}),o.jsx("button",{onClick:()=>V(Ce=>!Ce),className:`action-btn action-btn--toggle${W?" active":""}`,title:r("terminal:overview.sameAreaOnly"),children:r("terminal:overview.sameAreaOnly")}),o.jsx("button",{onClick:()=>B(Ce=>!Ce),className:`action-btn action-btn--toggle${G?" active":""}`,title:"Subagents",children:"Subagents"}),o.jsx("button",{onClick:()=>se(Ce=>!Ce),className:`action-btn action-btn--toggle${K?" active":""}`,title:r("terminal:overview.recentActivity"),children:"Activity"}),o.jsx("button",{onClick:()=>Me(!0),className:"action-btn",title:"Bulk manage agents",children:"Bulk Manage"})]}),o.jsx("div",{className:"aop-agent-list",ref:Ue,children:ve.length===0?o.jsx("div",{className:"aop-empty",children:d.length===0?r("terminal:overview.noAgentsDeployed"):r("terminal:overview.noAgentsMatch")}):ve.map(Ce=>{var $t,Dt,qt;const Be=(($t=Ce.area)==null?void 0:$t.id)||"__unassigned__",Ye=((Dt=Ce.area)==null?void 0:Dt.name)||($?r("terminal:overview.unassigned"):""),et=((qt=Ce.area)==null?void 0:qt.color)||"#6272a4",Et=k.has(Be);return o.jsxs("div",{className:"aop-area-group",children:[$&&o.jsxs("div",{className:"aop-area-header",onClick:()=>xt(Be),style:{borderLeftColor:et},children:[o.jsx("span",{className:"aop-area-expand",children:Et?"▸":"▾"}),o.jsx("span",{className:"aop-area-color",style:{background:et}}),o.jsx("span",{className:"aop-area-name",onContextMenu:cn=>{Ce.area&&(cn.preventDefault(),cn.stopPropagation(),ut(Ce.area,{x:cn.clientX,y:cn.clientY}))},children:Ye}),o.jsx("button",{type:"button",className:"aop-area-eye-btn",title:"Hide area",onClick:cn=>{cn.preventDefault(),cn.stopPropagation(),Se(Be)},children:"◉"}),Ce.area&&o.jsx("button",{type:"button",className:"aop-area-eye-btn",title:"Edit area prompt",onClick:cn=>{cn.preventDefault(),cn.stopPropagation();const yt=Ce.area;S===yt.id?T(null):(E(yt.prompt||""),T(yt.id))},children:"✎"}),Ce.area&&(()=>{const cn=Ce.area;return o.jsx("button",{type:"button",className:"aop-area-add-btn",title:r("common:agentBar.newAgent"),onClick:yt=>{yt.preventDefault(),yt.stopPropagation();const rt=yt.currentTarget.getBoundingClientRect();ut(cn,{x:rt.left,y:rt.bottom+6})},children:"+"})})(),o.jsx("span",{className:"aop-area-count",children:Ce.agents.length})]}),S===Be&&Ce.area&&o.jsxs("div",{className:"aop-area-prompt-editor",onClick:cn=>cn.stopPropagation(),children:[o.jsx("textarea",{className:"aop-area-prompt-textarea",value:D,onChange:cn=>E(cn.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(Ce.area.id,{prompt:D}),T(null)},children:"Save"}),o.jsx("button",{className:"aop-area-prompt-cancel",onClick:()=>T(null),children:"Cancel"})]})]}),(!$||!Et)&&o.jsx("div",{className:$?"aop-area-content":void 0,children:Fe(Ce.agents)})]},Be)})}),o.jsx(Lo,{isOpen:We!==null,position:(We==null?void 0:We.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:ln,onClose:()=>nt(null)}),o.jsx(Lo,{isOpen:we!==null,position:(we==null?void 0:we.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:Kt,onClose:()=>Le(null)}),o.jsx(N5,{isOpen:ye,onClose:()=>Me(!1)})]})}function D5({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:A,onContextMenu:N}){const{t:k}=pt(["terminal","common"]),j=dr(),S=fr(t.class,j),T=t.isBoss||t.class==="boss",D=T5[t.status]||"❓",E=$A[t.status]?k(`terminal:${$A[t.status]}`):t.status,P=f.slice(0,s?4:8),O=_5(t.id),_=E5(t.id),M=s?40:80,R=x.useMemo(()=>{var Ue,Ze,lt,fe,J,ae,Se;const ie=[],de=new Set;for(const Z of h)ie.push({id:Z.id,name:Z.name,type:Z.subagentType,description:Z.description,status:Z.status,timestamp:Z.startedAt}),de.add(Z.name);for(const Z of f){if(Z.toolName!=="Task"&&Z.toolName!=="Agent")continue;const De=((Ue=Z.toolInput)==null?void 0:Ue.description)||((Ze=Z.toolInput)==null?void 0:Ze.name)||""||((fe=(lt=Z.toolInput)==null?void 0:lt.prompt)==null?void 0:fe.slice(0,40))||"Task";de.has(De)||(de.add(De),ie.push({id:`task-${Z.timestamp}`,name:De,type:((J=Z.toolInput)==null?void 0:J.subagent_type)||"unknown",description:(Se=(ae=Z.toolInput)==null?void 0:ae.prompt)==null?void 0:Se.slice(0,100),status:"completed",timestamp:Z.timestamp}))}return ie.sort((Z,he)=>he.timestamp-Z.timestamp),ie},[h,f]),F=R.filter(ie=>ie.status==="working"||ie.status==="spawning"),$=i&&R.length>0,H=c&&P.length>0,L=$||H,z=t.contextLimit>0?t.contextUsed/t.contextLimit:0,W=Math.min(100,z*100),V=Math.min(1,Math.max(0,z)),B=`hsl(${Math.round((1-V)*120)} 80% 45% / 0.55)`,K=112,se=56,[q,me]=x.useState(0),[ce,ee]=x.useState(!1),[pe,Ne]=x.useState(!1),ye=x.useRef(0),Me=x.useRef(0),qe=x.useRef(0),He=x.useRef(!1),X=x.useRef(!1),ne=x.useRef(!1);x.useEffect(()=>{s||(me(0),ee(!1),Ne(!1))},[s]);const Te=x.useCallback(()=>{if(ne.current){ne.current=!1;return}if(ce){me(0),ee(!1),ne.current=!0;return}w()},[w,ce]),We=x.useCallback(ie=>{if(!s||ie.touches.length!==1)return;const de=ie.touches[0];ye.current=de.clientX,Me.current=de.clientY,qe.current=ce?K:0,He.current=!1,X.current=!1,Ne(!0)},[s,ce]),nt=x.useCallback(ie=>{if(!s||!pe||ie.touches.length!==1)return;const de=ie.touches[0],Ue=de.clientX-ye.current,Ze=de.clientY-Me.current;if(!He.current){if(Math.abs(Ue)<8&&Math.abs(Ze)<8)return;He.current=!0,X.current=Math.abs(Ue)>Math.abs(Ze)}if(!X.current)return;ie.preventDefault();const lt=Math.max(0,Math.min(K,qe.current-Ue));me(lt)},[s,pe]),we=x.useCallback(()=>{if(!s||!pe)return;if(Ne(!1),!X.current){ce||me(0);return}const ie=q>=se,de=ie!==ce||q!==(ie?K:0);ee(ie),me(ie?K:0),de&&(ne.current=!0)},[s,pe,q,ce]),Le=x.useCallback(ie=>{ie.stopPropagation(),A(),ee(!1),me(0),ne.current=!0},[A]);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:Le,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:Te,onTouchStart:We,onTouchMove:nt,onTouchEnd:we,onTouchCancel:we,style:s?{transform:`translateX(-${q}px)`,transition:pe?"none":"transform 0.18s ease"}:void 0,children:[o.jsxs("div",{className:"aop-agent-header",onContextMenu:ie=>{ie.preventDefault(),ie.stopPropagation(),N({x:ie.clientX,y:ie.clientY})},children:[o.jsx("button",{type:"button",className:"aop-expand-icon","aria-label":n?"Collapse agent":"Expand agent",onClick:ie=>{ie.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:_}),F.length>0&&o.jsxs("span",{className:"aop-subagent-count",title:F.map(ie=>`${ie.name}: ${ie.description||ie.type}`).join(`
143
+ `),children:["⑂",F.length]}),R.length>0&&F.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(ie=>o.jsxs("div",{className:`aop-subagent-item ${ie.status}`,children:[o.jsx("span",{className:"sub-icon",children:ie.status==="completed"?"✅":ie.status==="failed"?"❌":ie.status==="unknown"?"⬜":"⑂"}),o.jsx("span",{className:"sub-name",children:ie.name}),o.jsx("span",{className:"sub-type",children:ie.type}),ie.description&&o.jsx("span",{className:"sub-desc",title:ie.description,children:Kf(ie.description,s?30:50)})]},ie.id))]}),H&&o.jsxs("div",{className:"aop-tool-timeline",children:[o.jsx("div",{className:"aop-section-label",children:k("terminal:overview.recentActivity")}),P.map((ie,de)=>{var Ze,lt;const Ue=ie.toolInput&&(ie.toolInput.file_path||((Ze=ie.toolInput.command)==null?void 0:Ze.slice(0,40))||ie.toolInput.pattern||ie.toolInput.description||((lt=ie.toolInput.prompt)==null?void 0:lt.slice(0,50)))||"";return o.jsxs("div",{className:"aop-timeline-entry",children:[o.jsx("span",{className:"tl-time",children:Fp(ie.timestamp)}),o.jsx("span",{className:"tl-icon",children:ms[ie.toolName]||ms.default}),o.jsx("span",{className:"tl-tool",children:ie.toolName}),Ue&&o.jsx("span",{className:"tl-param",children:Ue})]},`${ie.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(z*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:`${W}%`,backgroundColor:B}})})]})]})}const R5={running:"🟢",stopped:"⚫",error:"🔴",unknown:"❓",starting:"🟡",stopping:"🟠"};function _b(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 Eb(t){const e=window.location.protocol,n=window.location.hostname;return`${e}//${n}:${t}`}function O5({agentId:t,onClose:e}){const{t:n}=pt(["terminal","common"]),s=qx(),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]),A=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 P of k.subordinateBuildingIds)U.sendBuildingCommand(P,"start")}}),j.push({id:"stop-all",label:"Stop All Subordinates",icon:"⏸️",onClick:()=>{for(const P of k.subordinateBuildingIds)U.sendBuildingCommand(P,"stop")}}),j.push({id:"restart-all",label:"Restart All Subordinates",icon:"♻️",onClick:()=>{for(const P of k.subordinateBuildingIds)U.sendBuildingCommand(P,"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 P=y();U.createBuilding({name:`${k.name} (Copy)`,type:k.type,style:k.style,color:k.color,scale:k.scale,position:P,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 P of k.urls)j.push({id:`url-${P.label}`,label:P.label,icon:"🔗",onClick:()=>window.open(P.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:Eb(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?`${_b(S.memory)}/${_b(S.memoryLimit)}`:_b(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:Eb(D.host),target:"_blank",rel:"noopener noreferrer",onClick:P=>P.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 P of S){const O=s.get(P);(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:Eb(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,P;const j=wL[k.type],S=R5[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"&&((P=k.pm2)==null?void 0:P.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(Lo,{isOpen:r!==null,position:(r==null?void 0:r.position)||{x:0,y:0},worldPosition:{x:0,z:0},actions:A,onClose:b})]})}const Mb={action:"#cba6f7",wait:"#f9e2af",decision:"#89b4fa",end:"#a6e3a1"},qp={running:"#a6e3a1",paused:"#f9e2af",completed:"#89b4fa",failed:"#f38ba8",cancelled:"#6c7086"};function L5(t){return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function I5(t){return new Date(t).toLocaleDateString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function P5({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([Pt(Ot("/api/workflows/definitions")),Pt(Ot("/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 A=w.find(k=>k.id===d)??null,N=A?n.find(k=>k.id===A.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:bt.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:bt.emptyState,children:o.jsx("span",{style:bt.loadingText,children:"Loading workflows..."})}),!i&&w.length===0&&o.jsxs("div",{style:bt.emptyState,children:[o.jsx("span",{style:bt.emptyIcon,children:"⊘"}),o.jsx("span",{children:"No workflow instances for this agent"})]}),w.length>0&&o.jsx("div",{style:bt.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:{...bt.instanceRow,...j?bt.instanceRowSelected:{}},children:[o.jsxs("div",{style:bt.instanceRowTop,children:[o.jsx("span",{style:{...bt.statusDot,backgroundColor:qp[k.status]||"#6c7086"}}),o.jsx("span",{style:bt.instanceName,children:k.workflowName}),o.jsx("span",{style:{...bt.instanceStatus,color:qp[k.status]||"#6c7086"},children:k.status})]}),o.jsxs("div",{style:bt.instanceRowBottom,children:[o.jsx("span",{style:bt.instanceState,children:(T==null?void 0:T.name)||k.currentStateId}),o.jsx("span",{style:bt.instanceTime,children:I5(k.updatedAt)})]})]},k.id)})}),A&&N&&o.jsx(B5,{definition:N,instance:A,onRefresh:m})]})]})}function B5({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:bt.instanceView,children:[o.jsxs("div",{style:bt.statusBar,children:[o.jsx("span",{style:{...bt.statusBadge,color:qp[e.status]||"#6c7086",borderColor:qp[e.status]||"#6c7086"},children:e.status}),o.jsxs("span",{style:bt.currentLabel,children:["Current: ",o.jsx("strong",{children:(s==null?void 0:s.name)||e.currentStateId})]})]}),o.jsx(F5,{definition:t,instance:e,onRefresh:n}),o.jsx("div",{style:bt.tabs,children:["states","timeline","variables"].map(i=>o.jsx("button",{onClick:()=>r(i),style:{...bt.tab,...a===i?bt.tabActive:{}},children:i==="states"?"States":i==="timeline"?"Timeline":"Variables"},i))}),o.jsxs("div",{style:bt.tabContent,children:[a==="states"&&o.jsx(z5,{definition:t,currentStateId:e.currentStateId}),a==="timeline"&&o.jsx($5,{definition:t,instance:e}),a==="variables"&&o.jsx(U5,{variables:e.variables})]})]})}function F5({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 Pt(Ot(`/api/workflows/instances/${e.id}/available-transitions`));if(y.ok){const A=((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(A)}}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 Pt(Ot(`/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 A=await w.json().catch(()=>({error:"Transition failed"}));h(A.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:bt.transitionSection,children:o.jsx("span",{style:bt.loadingText,children:"Loading transitions..."})}):s.length===0?null:o.jsxs("div",{style:bt.transitionSection,children:[o.jsx("div",{style:bt.transitionLabel,children:"Available Transitions"}),o.jsx("div",{style:bt.transitionButtons,children:s.map(y=>o.jsxs("button",{onClick:()=>b(y.targetStateId),disabled:c!==null,style:{...bt.transitionBtn,opacity:c===y.targetStateId?.6:1},title:`${y.name} → ${y.targetStateName||y.targetStateId}`,children:[c===y.targetStateId?"...":y.name,o.jsxs("span",{style:bt.transitionArrow,children:["→"," ",y.targetStateName||y.targetStateId]})]},y.id))}),f&&o.jsx("div",{style:bt.transitionError,children:f})]})}function z5({definition:t,currentStateId:e}){return o.jsx("div",{style:bt.stateList,children:t.states.map(n=>{const s=n.id===e;return o.jsxs("div",{style:{...bt.stateItem,...s?bt.stateItemCurrent:{}},children:[o.jsxs("div",{style:bt.stateHeader,children:[o.jsx("span",{style:{...bt.stateTypeBadge,backgroundColor:`${Mb[n.type]}22`,color:Mb[n.type],borderColor:`${Mb[n.type]}44`},children:n.type}),o.jsx("span",{style:bt.stateName,children:n.name}),s&&o.jsx("span",{style:bt.currentBadge,children:"CURRENT"})]}),n.description&&o.jsx("div",{style:bt.stateDescription,children:n.description}),n.transitions.length>0&&o.jsx("div",{style:bt.stateTransitions,children:n.transitions.map(a=>{var r;return o.jsxs("span",{style:bt.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 $5({definition:t,instance:e}){return!e.history||e.history.length===0?o.jsx("div",{style:bt.emptyState,children:"No timeline events yet"}):o.jsx("div",{style:bt.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:bt.timelineEntry,children:[o.jsx("div",{style:bt.timelineDot}),o.jsxs("div",{style:bt.timelineContent,children:[o.jsxs("div",{style:bt.timelineHeader,children:[o.jsx("span",{style:bt.timelineTime,children:L5(n.timestamp)}),n.transitionName&&o.jsxs("span",{style:bt.timelineTransition,children:["via ",n.transitionName]})]}),o.jsxs("div",{style:bt.timelineStates,children:[r&&o.jsxs(o.Fragment,{children:[o.jsx("span",{style:bt.timelineStateName,children:r.name}),o.jsx("span",{style:bt.timelineArrow,children:"→"})]}),o.jsx("span",{style:{...bt.timelineStateName,fontWeight:600},children:(a==null?void 0:a.name)||n.toStateId})]}),n.details&&o.jsx("div",{style:bt.timelineDetails,children:n.details})]})]},s)})})}function U5({variables:t}){const e=Object.entries(t);if(e.length===0)return o.jsx("div",{style:bt.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:bt.variablesSection,children:[n.length>0&&o.jsxs("div",{style:bt.varGroup,children:[o.jsx("div",{style:bt.varGroupLabel,children:"Variables"}),n.map(([a,r])=>o.jsxs("div",{style:bt.varRow,children:[o.jsx("span",{style:bt.varKey,children:a}),o.jsx("span",{style:bt.varValue,children:typeof r=="object"?JSON.stringify(r):String(r??"")})]},a))]}),s.length>0&&o.jsxs("div",{style:bt.varGroup,children:[o.jsx("div",{style:bt.varGroupLabel,children:"Internal"}),s.map(([a,r])=>o.jsxs("div",{style:bt.varRow,children:[o.jsx("span",{style:{...bt.varKey,opacity:.6},children:a}),o.jsx("span",{style:{...bt.varValue,opacity:.6},children:typeof r=="object"?JSON.stringify(r):String(r??"")})]},a))]})]})}const bt={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 H5({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}=pt(["tools"]),y=x.useMemo(()=>ud({onFileClick:a?j=>a(j):void 0}),[a]),w={working:b("tools:progress.workingOn"),completed:b("tools:progress.taskFinished"),failed:b("tools:progress.taskFailed")},A=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:A}),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(W5,{output:t.output,agentId:t.agentId,maxHeight:200,onFileClick:a,onBashClick:r})})]})]})}function W5({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(Oy,{output:d,agentId:e,onFileClick:s,onBashClick:a},`progress-${f}`))})}const q5=x.memo(function(){const{t:e}=pt(["terminal"]),[n,s]=x.useState(!1),[a,r]=x.useState(()=>My()),[i,c]=x.useState(-1),d=x.useRef(null),f=x.useRef(null),h=ia.findIndex(A=>A.id===a);x.useEffect(()=>{if(!n)return;const A=N=>{d.current&&!d.current.contains(N.target)&&s(!1)};return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[n]),x.useEffect(()=>{n&&c(h)},[n,h]);const m=A=>{const N=A==="next"?(h+1)%ia.length:(h-1+ia.length)%ia.length,k=ia[N],j=Fu(k.id);Up(j),r(k.id)},b=A=>{n||(A.key==="ArrowUp"||A.key==="ArrowLeft"?(A.preventDefault(),m("prev")):A.key==="ArrowDown"||A.key==="ArrowRight"?(A.preventDefault(),m("next")):(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),s(!0)))};x.useEffect(()=>{if(!n)return;const A=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",A),()=>document.removeEventListener("keydown",A)},[n,i]);const y=A=>{const N=Fu(A);Up(N),r(A),s(!1)},w=Fu(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:A=>A.stopPropagation(),onClick:A=>A.stopPropagation(),children:[o.jsx("div",{className:"theme-selector-header",children:e("terminal:themeSelector.selectTheme")}),o.jsx("div",{className:"theme-selector-list",children:ia.map((A,N)=>o.jsxs("button",{className:`theme-selector-option ${A.id===a?"active":""} ${N===i?"highlighted":""}`,onClick:k=>{k.stopPropagation(),y(A.id)},onMouseDown:k=>k.stopPropagation(),onMouseEnter:()=>c(N),children:[o.jsx("span",{className:"theme-option-preview",style:{background:`linear-gradient(135deg, ${A.colors.bgPrimary} 0%, ${A.colors.bgSecondary} 50%, ${A.colors.accentPurple} 100%)`}}),o.jsxs("span",{className:"theme-option-info",children:[o.jsx("span",{className:"theme-option-name",children:A.name}),o.jsx("span",{className:"theme-option-desc",children:A.description})]}),A.id===a&&o.jsx("span",{className:"theme-option-check",children:"✓"})]},A.id))})]})]})}),HA=48,V5=49,Y5=50,WA=48,G5={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 K5(t,e){let n=null;const s=(...a)=>{n&&clearTimeout(n),n=setTimeout(()=>t(...a),e)};return s.cancel=()=>{n&&clearTimeout(n)},s}const Gt=(...t)=>console.log("[TerminalEmbed]",...t);function qA(t){var e;Gt("copyToClipboard called, text:",t.slice(0,50)),Gt("navigator.clipboard available:",!!navigator.clipboard),Gt("document.hasFocus:",document.hasFocus()),(e=navigator.clipboard)!=null&&e.writeText?navigator.clipboard.writeText(t).then(()=>Gt("clipboard.writeText SUCCESS"),n=>{Gt("clipboard.writeText FAILED:",(n==null?void 0:n.message)||n),VA(t)}):(Gt("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");Gt("execCommand fallback:",n?"SUCCESS":"FAILED")}catch(n){Gt("execCommand fallback error",n)}document.body.removeChild(e)}const Nx=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(Gt("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,A=null,N=null,k=null;return(async()=>{Gt("Lazy-loading xterm.js modules...");const[j,S,T,D]=await Promise.all([wt(()=>import("./xterm-BqvuqXEL.js"),[]),wt(()=>import("./addon-fit-YJmn1quW.js"),[]),wt(()=>import("./addon-clipboard-Ckztrdv4.js"),[]),wt(()=>import("./addon-web-links-BWjmmSgS.js"),[])]);if(m){Gt("Destroyed after module load, aborting");return}if(await wt(()=>Promise.resolve({}),__vite__mapDeps([16])),Gt("Modules loaded, xterm exports:",Object.keys(j)),m||!s.current)return;const E=j.Terminal,P=S.FitAddon,O=T.ClipboardAddon,_=D.WebLinksAddon;b=new E({theme:G5,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 P,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();Gt("Container dimensions before open:",{w:M.width,h:M.height}),b.open(s.current),y.fit(),Gt("Terminal opened, cols:",b.cols,"rows:",b.rows),b.onSelectionChange(()=>{Gt(">>> onSelectionChange FIRED",{hasSelection:b.hasSelection()});const V=b.hasSelection()?b.getSelection():"";V&&(Gt("onSelectionChange copying text:",V.slice(0,50)),qA(V))}),s.current.addEventListener("mousedown",V=>{Gt("mousedown",{button:V.button,shiftKey:V.shiftKey,metaKey:V.metaKey,ctrlKey:V.ctrlKey})}),s.current.addEventListener("mouseup",V=>{Gt("mouseup",{button:V.button,shiftKey:V.shiftKey,hasSel:b.hasSelection()})}),Gt("Registering OSC 52 handler"),b.parser.registerOscHandler(52,V=>{Gt(">>> 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);Gt("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)}),A=K5(()=>{y&&b&&(y.fit(),h(b.cols,b.rows))},100),N=new ResizeObserver(()=>A()),N.observe(s.current);const R=e.endsWith("/")?e.slice(0,-1):e,F=Kb(`${R}/token`);Gt("Fetching ttyd token from:",F);let $="";try{const V=await fetch(F);if(Gt("Token response status:",V.status,"content-type:",V.headers.get("content-type")),V.ok){const G=await V.text();Gt("Token raw response:",G);try{$=JSON.parse(G).token||""}catch{$=G.trim()}Gt("Parsed ttyd token:",$?$.slice(0,16)+"...":"(empty)")}else Gt("Token fetch failed:",V.status,V.statusText)}catch(V){Gt("Token fetch error:",V)}if(m)return;const H=window.location.protocol==="https:"?"wss:":"ws:",L=Kb(`${R}/ws`),z=`${H}//${window.location.host}${L}`;Gt("Connecting WebSocket to:",z),w=new WebSocket(z,["tty"]),w.binaryType="arraybuffer",i.current=w,w.onopen=()=>{if(Gt("WebSocket OPEN"),b&&y){y.fit();const V=JSON.stringify({AuthToken:$,columns:b.cols,rows:b.rows});Gt("Sending init message (as binary):",V),w.send(d.current.encode(V))}};let W=0;w.onmessage=V=>{if(b){if(W++,W<=5){const G=V.data instanceof ArrayBuffer?"ArrayBuffer":typeof V.data,B=V.data instanceof ArrayBuffer?V.data.byteLength:V.data.length;if(Gt(`WS message #${W}: type=${G} size=${B}`),V.data instanceof ArrayBuffer){const K=new Uint8Array(V.data).slice(0,20);Gt(` 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===V5?Gt("Received SET_TITLE"):B===Y5?Gt("Received SET_PREFS:",new TextDecoder().decode(G.subarray(1))):Gt("Unknown binary cmd:",B,"char:",String.fromCharCode(B))}else typeof V.data=="string"&&(W<=5&&Gt("String message, first char code:",V.data.charCodeAt(0)),V.data.charCodeAt(0)===HA&&b.write(V.data.slice(1)))}},w.onclose=V=>{Gt("WebSocket CLOSED, code:",V.code,"reason:",V.reason,"wasClean:",V.wasClean,"totalMessages:",W),b&&!m&&b.write(`\r
145
+ \x1B[90m[Terminal disconnected]\x1B[0m\r
146
+ `)},w.onerror=V=>{Gt("WebSocket ERROR:",V)},b.onResize(({cols:V,rows:G})=>h(V,G))})(),()=>{var j;m=!0,c.current=!1,A==null||A.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,Q5=3e4,X5=12e4,J5=128,Z5=95;function Db(t){const e=_y(t);return Ey(e.userMessage).userMessage.trim().replace(/\r\n/g,`
147
+ `)}function Qf(t){return t.trim().replace(/\r\n/g,`
148
+ `)}function eW(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 tW(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 nW=1;function Xf(){return`bp-${nW++}`}const sW=x.memo(function({buildingId:e,filterText:n,maxRetention:s}){const{streamingBuildingLogs:a}=Ls(),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]),A=x.useMemo(()=>w.map(S=>Yl(S||" ")),[w]),N=x.useMemo(()=>b?f&&!y?"No log lines match the current filter.":null:"Waiting for logs...",[b,f,y]),k=R1({count:A.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:A[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 aW=x.memo(function({onSaveSnapshot:e}={}){var Go,ai,xd,gc,bc;const{t:n}=pt(["terminal","common"]),s=nd(),a=Hx(),r=tN(),i=Wx(),c=iN(),d=oN(),f=nN(),h=Vx(),m=Yx(),b=uL(),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]),A=Array.from(a),k=A.length===1?A[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(),P=qx(),O=x.useMemo(()=>{if(!T)return null;const Q=new Set,ue=[];for(const _e of E.values())_e.archived||_e.directories.length===0||_e.assignedAgentIds.includes(T)&&(Q.add(_e.id),ue.push(_e));const le=s.get(T);if(le)for(const _e of E.values())_e.archived||_e.directories.length===0||Q.has(_e.id)||tW({x:le.position.x,z:le.position.z},_e)&&(Q.add(_e.id),ue.push(_e));return ue.length===0?null:ue.flatMap(_e=>_e.directories.filter(at=>at&&at.trim().length>0).map(at=>({areaId:_e.id,areaName:_e.name,dir:at})))},[T,E,s]),_=x.useMemo(()=>{var le;if(!T)return[];const Q=U.getAreaForAgent(T);if(!Q)return[];const ue=[];for(const _e of P.values())_e.type==="terminal"&&U.isPositionInArea(_e.position,Q)&&ue.push({id:_e.id,name:_e.name,hasUrl:!!((le=_e.terminalStatus)!=null&&le.url)});return ue},[T,P,E]),M=x.useMemo(()=>{var le;if(!T)return[];const Q=U.getAreaForAgent(T);if(!Q)return[];const ue=[];for(const _e of P.values())_e.type==="server"&&((le=_e.pm2)!=null&&le.enabled)&&U.isPositionInArea(_e.position,Q)&&ue.push({id:_e.id,name:_e.name});return ue},[T,P,E]),R=x.useMemo(()=>{if(!T)return[];const Q=U.getAreaForAgent(T);if(!Q)return[];const ue=[];for(const le of P.values())le.type==="database"&&le.database&&U.isPositionInArea(le.position,Q)&&ue.push({id:le.id,name:le.name});return ue},[T,P,E]),{branches:F,fetchRemote:$,fetchingDirs:H}=VH(O),{terminalHeight:L,terminalRef:z,handleResizeStart:W}=RH(),{mobileOverviewHeight:V,handleResizeMouseDown:G,handleResizeTouchStart:B}=IH(),K=DH(),[se,q]=x.useState(()=>{const Q=Rx(mt.SIDE_PANEL_WIDTH,420);return Math.max(280,Math.min(700,Q))}),me=x.useRef(null),ce=x.useCallback((Q,ue)=>{Q.preventDefault(),me.current={startX:Q.clientX,startW:se},document.body.style.cursor="ew-resize",document.body.style.userSelect="none",U.setTerminalResizing(!0);let le=se;const _e=dt=>{if(!me.current)return;const Nt=dt.clientX-me.current.startX,_t=ue==="left"?-Nt:Nt;le=Math.max(280,Math.min(700,me.current.startW+_t)),q(le)},at=()=>{me.current=null,document.body.style.cursor="",document.body.style.userSelect="",U.setTerminalResizing(!1),document.removeEventListener("mousemove",_e),document.removeEventListener("mouseup",at),Ox(mt.SIDE_PANEL_WIDTH,le)};document.addEventListener("mousemove",_e),document.addEventListener("mouseup",at)},[se]),ee=Xj(T),pe=qO(T),Ne=x.useMemo(()=>y&&b?b.outputs.map(Q=>({text:Q.text||"",timestamp:Q.timestamp,isStreaming:!1,isUserPrompt:!1})):ee,[y,b,ee]),ye=x.useRef(null),Me=x.useRef(null),qe=x.useRef(null),He=x.useRef(null),[X,ne]=x.useState(()=>{const Q=$a(mt.VIEW_MODE);return Q==="simple"||Q==="chat"||Q==="advanced"?Q:$a(mt.ADVANCED_VIEW)==="true"?"advanced":"simple"}),[Te,We]=x.useState(()=>Ei(mt.TERMINAL_FULLSCREEN,!1)),[nt,we]=x.useState(null),[Le,ie]=x.useState(null),[de,Ue]=x.useState(null),[Ze,lt]=x.useState(null),[fe,J]=x.useState(!1);Jt("guake-image-modal",nt!==null,()=>we(null)),Jt("guake-bash-modal",Le!==null,()=>ie(null)),Jt("guake-response-modal",Ze!==null,()=>lt(null)),Jt("guake-context-confirm",de!==null,()=>Ue(null)),Jt("guake-agent-info",fe,()=>J(!1));const[ae,Se]=x.useState(!1),[Z,he]=x.useState(()=>ks.isEnabled()),[De,ze]=x.useState(()=>Ei(mt.GIT_PANEL_OPEN,!1)),be=x.useCallback(Q=>{ze(Q),Mi(mt.GIT_PANEL_OPEN,Q)},[]),[Pe,te]=x.useState(()=>Ei(mt.BUILDINGS_PANEL_OPEN,!1)),ge=x.useCallback(Q=>{te(Q),Mi(mt.BUILDINGS_PANEL_OPEN,Q)},[]),[ve,Fe]=x.useState(()=>Ei(mt.WORKFLOW_PANEL_OPEN,!1)),Ke=x.useCallback(Q=>{Fe(Q),Mi(mt.WORKFLOW_PANEL_OPEN,Q)},[]),[st,xt]=x.useState(!1);x.useEffect(()=>{if(!T){xt(!1);return}let Q=!1;return(async()=>{try{const ue=await Pt(Ot("/api/workflows/definitions"));if(Q||!ue.ok)return;const _e=(await ue.json()).some(at=>at.states.some(dt=>{var Nt,_t;return((Nt=dt.action)==null?void 0:Nt.type)==="agent_task"&&((_t=dt.action)==null?void 0:_t.agentId)===T}));Q||xt(_e)}catch{Q||xt(!1)}})(),()=>{Q=!0}},[T]);const ht=gL(),ot=x.useCallback(Q=>U.setOverviewPanelOpen(Q),[]),[ft,ut]=x.useState([]),[ln,Kt]=x.useState({}),[Ce,Be]=x.useState(()=>Yj()),[Ye,et]=x.useState(()=>{try{return localStorage.getItem("tide:bottom-split-direction")==="vertical"?"vertical":"horizontal"}catch{return"horizontal"}}),[Et,$t]=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}}),Dt=x.useRef(null),[qt,cn]=x.useState([1]),yt=x.useRef(null),rt=x.useRef(null),[ct,Ft]=x.useState(null),[_n,En]=x.useState(null),bn=x.useMemo(()=>ft.filter(Q=>Q.areaId===_n),[ft,_n]),Is=x.useMemo(()=>new Set(bn.map(Q=>Q.buildingId)),[bn]),_s=x.useRef(new Map);x.useEffect(()=>{try{const Q=localStorage.getItem("tide:bottom-panels-v2");if(Q){const ue=JSON.parse(Q);_s.current=new Map(ue.map(([le,_e])=>[le,_e.map(at=>({id:at.id??Xf(),type:at.type,buildingId:at.buildingId}))]))}else{const ue=localStorage.getItem("tide:bottom-terminals");if(ue){const le=JSON.parse(ue);for(const[_e,at]of le)_s.current.set(_e,[{id:Xf(),type:"terminal",buildingId:at}])}}}catch{}},[]);const ts=x.useCallback(Q=>{if(!T)return;const ue=U.getAreaForAgent(T);if(ue)try{Q.length>0?_s.current.set(ue.id,Q.map(_e=>({id:_e.id,type:_e.type,buildingId:_e.buildingId}))):_s.current.delete(ue.id);const le=Array.from(_s.current.entries());localStorage.setItem("tide:bottom-panels-v2",JSON.stringify(le))}catch{}},[T]),Ks=x.useCallback(()=>{if(!T)return null;const Q=U.getAreaForAgent(T);return(Q==null?void 0:Q.id)??null},[T]),Bn=x.useCallback((Q,ue)=>{const le=Ks();Kt({}),ut(_e=>{for(const _t of _e)_t.areaId===le&&_t.type==="pm2-logs"&&U.stopLogStreaming(_t.buildingId);const at=_e.filter(_t=>_t.areaId!==le),dt={id:Xf(),type:ue,buildingId:Q,areaId:le??void 0},Nt=[...at,dt];return ts([dt]),Nt})},[ts,Ks]),us=x.useCallback((Q,ue,le)=>{const _e=Ks();et(le);try{localStorage.setItem("tide:bottom-split-direction",le)}catch{}ut(at=>{const dt=at.filter(nn=>nn.areaId===_e);if(dt.length>=4||dt.some(nn=>nn.buildingId===Q))return at;const Nt={id:Xf(),type:ue,buildingId:Q,areaId:_e??void 0},_t=[...at,Nt];return ts(dt.concat(Nt)),_t})},[ts,Ks]),Un=x.useCallback(Q=>{Kt(ue=>{if(!(Q in ue))return ue;const le={...ue};return delete le[Q],le}),ut(ue=>{const le=ue.find(dt=>dt.id===Q);(le==null?void 0:le.type)==="pm2-logs"&&U.stopLogStreaming(le.buildingId);const _e=ue.filter(dt=>dt.id!==Q),at=le==null?void 0:le.areaId;return at&&ts(_e.filter(dt=>dt.areaId===at)),_e})},[ts]);x.useCallback(()=>{Kt({}),ut(Q=>{for(const ue of Q)ue.type==="pm2-logs"&&U.stopLogStreaming(ue.buildingId);return ts([]),[]})},[ts]),x.useEffect(()=>{if(!T){En(null);return}const Q=U.getAreaForAgent(T);if(!Q){En(null);return}En(Q.id),ut(ue=>{if(ue.filter(dt=>dt.areaId===Q.id).length>0)return ue;const _e=_s.current.get(Q.id);if(!_e||_e.length===0)return ue;const at=_e.map(dt=>({id:dt.id,type:dt.type,buildingId:dt.buildingId,areaId:Q.id}));return[...ue,...at]})},[T]),x.useEffect(()=>{const Q=ue=>{const le=ue.detail;le!=null&&le.buildingId&&Bn(le.buildingId,"terminal")};return window.addEventListener("tide:open-bottom-terminal",Q),()=>window.removeEventListener("tide:open-bottom-terminal",Q)},[Bn]),x.useEffect(()=>{const Q=ue=>{const le=ue.detail;le!=null&&le.buildingId&&Bn(le.buildingId,"pm2-logs")};return window.addEventListener("tide:open-bottom-pm2-logs",Q),()=>window.removeEventListener("tide:open-bottom-pm2-logs",Q)},[Bn]),x.useEffect(()=>{const Q=ue=>{const le=ue.detail;le!=null&&le.buildingId&&Bn(le.buildingId,"database")};return window.addEventListener("tide:open-bottom-database",Q),()=>window.removeEventListener("tide:open-bottom-database",Q)},[Bn]),x.useEffect(()=>{const Q=ue=>{const le=ue.detail;le!=null&&le.buildingId&&(le!=null&&le.type)&&(le!=null&&le.direction)&&(bn.length===0?Bn(le.buildingId,le.type):us(le.buildingId,le.type,le.direction))};return window.addEventListener("tide:split-bottom-panel",Q),()=>window.removeEventListener("tide:split-bottom-panel",Q)},[bn.length,Bn,us]),x.useEffect(()=>{cn(Q=>Q.length===bn.length?Q:bn.length<=1?[1]:(bn.length>Q.length,Array(bn.length).fill(1)))},[bn.length]);const Qs=x.useCallback((Q,ue)=>{var nn;Q.preventDefault();const le=Ye==="horizontal";yt.current={index:ue,startPos:le?Q.clientX:Q.clientY,startRatios:[...qt]},document.body.style.cursor=le?"col-resize":"row-resize",document.body.style.userSelect="none";const _e=(nn=rt.current)==null?void 0:nn.querySelectorAll("iframe");_e==null||_e.forEach(fn=>fn.style.pointerEvents="none");const at=rt.current,dt=at?le?at.offsetWidth:at.offsetHeight:1,Nt=fn=>{const qn=yt.current;if(!qn||!at)return;const xr=(le?fn.clientX:fn.clientY)-qn.startPos,xc=qn.startRatios.reduce((yd,vd)=>yd+vd,0),yc=xr/dt*xc,Ji=[...qn.startRatios],Qo=.1*xc;Ji[ue]=Math.max(Qo,qn.startRatios[ue]+yc),Ji[ue+1]=Math.max(Qo,qn.startRatios[ue+1]-yc),cn(Ji)},_t=()=>{yt.current=null,document.body.style.cursor="",document.body.style.userSelect="",_e==null||_e.forEach(fn=>fn.style.pointerEvents=""),document.removeEventListener("mousemove",Nt),document.removeEventListener("mouseup",_t)};document.addEventListener("mousemove",Nt),document.addEventListener("mouseup",_t)},[Ye,qt]),On=x.useRef(new Set);x.useEffect(()=>{const Q=new Set(ft.filter(ue=>ue.type==="pm2-logs").map(ue=>ue.buildingId));for(const ue of Q)On.current.has(ue)||U.startLogStreaming(ue,200);On.current=Q},[ft]);const Wa=x.useRef(new Set);x.useEffect(()=>{var le;const Q=ft.filter(_e=>_e.type==="terminal");for(const _e of Q){const at=P.get(_e.buildingId);!!((le=at==null?void 0:at.terminalStatus)!=null&&le.url)?Wa.current.add(_e.buildingId):Wa.current.has(_e.buildingId)&&(Wa.current.delete(_e.buildingId),Un(_e.id))}const ue=new Set(Q.map(_e=>_e.buildingId));for(const _e of Wa.current)ue.has(_e)||Wa.current.delete(_e)},[ft,P,Un]);const zo=x.useCallback(Q=>{Q.preventDefault(),Dt.current={startY:Q.clientY,startH:Et};let ue=Et;const le=at=>{if(!Dt.current)return;const dt=Dt.current.startY-at.clientY;ue=Math.max(120,Math.min(600,Dt.current.startH+dt)),$t(ue)},_e=()=>{Dt.current=null,document.removeEventListener("mousemove",le),document.removeEventListener("mouseup",_e);try{localStorage.setItem("tide:bottom-terminal-height",String(ue))}catch{}};document.addEventListener("mousemove",le),document.addEventListener("mouseup",_e)},[Et]),[pa,ha]=x.useState(!1),[ic,Qr]=x.useState(null),$i=x.useRef(null),Xs=x.useRef(null),[Xr,Da]=x.useState(!1),[ns,ss]=x.useState(!1),[gs,Ae]=x.useState(!1),[Je,jt]=x.useState(!1),Vt=x.useRef(0),gt=r&&S!==null,Lt=x.useRef([]),kt=x.useRef(-1),xn=x.useRef(!1),bs=x.useRef(!1),Fn=x.useRef(!1),Cs=x.useRef(null),[qa,Va]=x.useState(!1),[oc,dd]=x.useState(!1),ma=x.useCallback(()=>{const Q=Lt.current,ue=kt.current;Va(ue>0),dd(ue>=0&&ue<Q.length-1)},[]),Jr=x.useCallback(Q=>{const ue=Lt.current;if(ue.length===0)return;let le=kt.current+Q;for(;le>=0&&le<ue.length;){const _e=ue[le];if(s.has(_e)){xn.current=!0,kt.current=le,ma(),U.selectAgent(_e);return}le+=Q}},[s,ma]),Ui=x.useCallback(()=>{Jr(-1)},[Jr]),Hi=x.useCallback(()=>{Jr(1)},[Jr]),Zr=x.useCallback((Q,ue)=>{if(typeof window>"u")return;const le=window.history.state,at={...typeof le=="object"&&le!==null?le:{},__guakeAgentNav:{agentId:Q}};ue==="replace"?window.history.replaceState(at,"",window.location.href):window.history.pushState(at,"",window.location.href)},[]),Ra=x.useCallback(()=>{We(Q=>{const ue=!Q;return Mi(mt.TERMINAL_FULLSCREEN,ue),ue})},[]),zt=qj({selectedAgentId:T,hasSessionId:D,reconnectCount:c,historyRefreshTrigger:d,lastPrompts:i,outputScrollRef:ye}),Hn=PH({agents:s,selectedAgentId:T,isOpen:gt,overviewPanelOpen:ht,loadingHistory:zt.fetchingHistory,hasModalOpen:!!(nt||Le||Ze||h||m),outputRef:ye});x.useEffect(()=>{const Q=z.current;if(!Q||!gt)return;const ue=_e=>{_e.button===3?(_e.preventDefault(),_e.stopPropagation(),Ui()):_e.button===4&&(_e.preventDefault(),_e.stopPropagation(),Hi())},le=_e=>{(_e.button===3||_e.button===4)&&_e.preventDefault()};return Q.addEventListener("mouseup",ue),Q.addEventListener("mousedown",le),()=>{Q.removeEventListener("mouseup",ue),Q.removeEventListener("mousedown",le)}},[gt,Ui,Hi]);const ei=x.useCallback(Q=>{U.setLastSelectionViaDirectClick(!0),U.selectAgent(Q)},[]),ti=typeof window<"u"&&window.innerWidth<=768&&ht&&gt,fd=nR({gestureRef:ye,agentListRef:Me,enabled:ti,onSelect:ei}),Qn=HH({selectedAgentId:k}),lc=XO(),Wi=x.useMemo(()=>y||!T?[]:Array.from(lc.values()).filter(Q=>Q.agentId===T&&Q.status==="pending"),[y,T,lc]),Ps=(S==null?void 0:S.class)==="boss"||(S==null?void 0:S.isBoss),ni=aL(!y&&Ps?T:null),gr=x.useMemo(()=>Array.from(ni.values()).filter(Q=>Q.status==="working"),[ni]),ga=x.useMemo(()=>Array.from(ni.values()).filter(Q=>Q.status==="completed"||Q.status==="failed").map(Q=>Q.agentId),[ni]),[qi,Vi]=x.useState(!0),pd=rL(y?null:T),$o=mL(y?null:T);x.useEffect(()=>{ae&&!Z&&(he(!0),ks.setEnabled(!0))},[ae,Z]),x.useEffect(()=>{gt||J(!1)},[gt]),x.useEffect(()=>{if(!T||!Ps||y||ga.length===0)return;const Q=window.setTimeout(()=>{ga.forEach(ue=>{U.clearAgentTaskProgress(T,ue)})},300);return()=>window.clearTimeout(Q)},[T,Ps,y,ga]),x.useEffect(()=>{const Q=S==null?void 0:S.status;if($i.current==="working"&&Q==="idle"){Xs.current&&clearTimeout(Xs.current);const le=T?i.get(T):void 0;Qr(le!=null&&le.timestamp?Date.now()-le.timestamp:null),ha(!0),Xs.current=setTimeout(()=>{ha(!1),Qr(null),Xs.current=null},4e3)}else Q==="working"&&(Xs.current&&(clearTimeout(Xs.current),Xs.current=null),ha(!1),Qr(null));return $i.current=Q||null,()=>{Xs.current&&clearTimeout(Xs.current)}},[S==null?void 0:S.status]);const Yi=x.useMemo(()=>{const{history:Q}=zt,ue=new Map;for(const _e of Q)_e.type==="tool_result"&&_e.toolUseId&&ue.set(_e.toolUseId,_e.content);return(_e=>_e.map(at=>{if(at.type==="tool_use"&&at.toolName==="Bash"&&at.toolUseId){const dt=ue.get(at.toolUseId);let Nt;try{Nt=(at.toolInput||(at.content?JSON.parse(at.content):{})).command}catch{}return{...at,_bashOutput:dt,_bashCommand:Nt}}return at}))(Q)},[zt.history,X]),cc=ET({outputs:Ne,viewMode:X}),Wn=x.useMemo(()=>{const Q=[],ue=new Set,le=new Set;let _e=null,at=0;for(const dt of Yi){if(dt.type==="assistant"){const fn=dt.uuid?`uuid:${dt.uuid}:${Qf(dt.content)}`:`sig:${dt.timestamp}:${Qf(dt.content)}`;if(ue.has(fn))continue;ue.add(fn),Q.push(dt);continue}if(dt.type!=="user"){Q.push(dt);continue}const Nt=Db(dt.content),_t=dt.uuid?`uuid:${dt.uuid}:${Nt}`:null;if(_t&&le.has(_t))continue;const nn=dt.timestamp?new Date(dt.timestamp).getTime():0;_e===Nt&&Math.abs(nn-at)<=YA||(Q.push(dt),_t&&le.add(_t),_e=Nt,at=nn)}return Q},[Yi]),Es=x.useMemo(()=>{const Q=new Map,ue=new Set,le=new Map;for(const Nt of Wn){const _t=Nt.timestamp?new Date(Nt.timestamp).getTime():0;if(Nt.type==="user"){const qn=Db(Nt.content),Ko=Q.get(qn)??0;_t>Ko&&Q.set(qn,_t);continue}if(Nt.type!=="assistant")continue;Nt.uuid&&ue.add(Nt.uuid);const nn=Qf(Nt.content),fn=le.get(nn)??0;_t>fn&&le.set(nn,_t)}const _e=[];let at=null,dt=0;for(const Nt of cc){if(!Nt.isUserPrompt){if(!Nt.isStreaming&&!eW(Nt.text)){if(Nt.uuid&&ue.has(Nt.uuid))continue;const qn=Qf(Nt.text),Ko=Nt.timestamp||0,xr=le.get(qn);if(xr&&Math.abs(Ko-xr)<=X5)continue}_e.push(Nt);continue}const _t=Db(Nt.text),nn=Nt.timestamp||0,fn=Q.get(_t);fn&&nn>=fn&&nn-fn<=Q5||at===_t&&Math.abs(nn-dt)<=YA||(_e.push(Nt),at=_t,dt=nn)}return _e},[cc,Wn]),Uo=x.useMemo(()=>[...Wn,...Es],[Wn,Es]),Mn=zH({selectedAgentId:T,isOpen:gt,allItems:Uo,viewMode:X,hasMoreHistory:zt.hasMore,loadAllHistory:zt.loadAllHistory,loadingMore:zt.loadingMore}),mh=Wn.length+Es.length,Ho=WH({totalMessages:mh,isOpen:gt,hasModalOpen:!!(nt||Le||Ze||h),scrollContainerRef:ye,selectedAgentId:T,inputRef:qe,textareaRef:He,useTextarea:Qn.useTextarea});x.useEffect(()=>{if(!(!(Le!=null&&Le.isLive)||!Le.command)){for(const Q of Es)if(Q._bashCommand===Le.command&&Q._bashOutput){ie({command:Le.command,output:Q._bashOutput,isLive:!1});return}}},[Le,Es]);const Wo=x.useCallback((Q,ue)=>{we({url:Q,name:ue})},[]),si=x.useCallback((Q,ue)=>{const le=sh(Q,S==null?void 0:S.cwd),_e=le.line?{...ue||{},targetLine:le.line}:ue;U.setFileViewerPath(le.path,_e,S==null?void 0:S.cwd)},[S==null?void 0:S.cwd]),Gi=x.useCallback((Q,ue)=>{ie({command:Q,output:ue,isLive:ue==="Running..."})},[]),hd=x.useCallback(Q=>{lt(Q)},[]),gh=x.useCallback(()=>{J(Q=>!Q)},[]),[bh,qo]=x.useState(!0),[Vo,Yo]=x.useState(0),[uc,dc]=x.useState(!1),Ki=x.useRef(!1),fc=x.useRef(!1),Qi=x.useRef(!1),xh=x.useCallback(()=>{Qi.current||(Ki.current=!0,qo(!1))},[]),yh=x.useCallback(()=>ss(!1),[]),vh=x.useCallback(()=>{Ki.current=!1,qo(!0)},[]),wh=x.useCallback(()=>{typeof window>"u"||window.innerWidth>768||(dc(!0),Yo(J5),document.activeElement instanceof HTMLElement&&document.activeElement.blur(),setTimeout(()=>{U.setMobileView("3d"),dc(!1),Yo(0)},Z5))},[]),pc=x.useCallback(Q=>{uc||Yo(Q)},[uc]);x.useEffect(()=>{qo(!0),Yo(0),dc(!1),Ki.current=!1,fc.current=!0,Qi.current=!0;const Q=setTimeout(()=>{Qi.current=!1},3e3);return()=>clearTimeout(Q)},[T]),x.useEffect(()=>{if(!T){Lt.current=[],kt.current=-1,ma(),Fn.current=!1,Cs.current=null;return}const Q=Lt.current;if(xn.current){xn.current=!1,ma();return}const ue=kt.current;if(ue>=0&&Q[ue]===T){ma();return}const le=ue<Q.length-1?Q.slice(0,ue+1):Q.slice();le.push(T),le.length>100&&le.shift(),Lt.current=le,kt.current=le.length-1,ma()},[T,ma]),x.useEffect(()=>{if(!(!gt||!T)){if(!Fn.current){Zr(T,"replace"),Fn.current=!0,Cs.current=T;return}if(bs.current){bs.current=!1,Cs.current=T;return}Cs.current!==T&&(Zr(T,"push"),Cs.current=T)}},[gt,T,Zr]),x.useEffect(()=>{if(!gt)return;const Q=ue=>{var dt,Nt;const le=(Nt=(dt=ue.state)==null?void 0:dt.__guakeAgentNav)==null?void 0:Nt.agentId;if(!le||typeof le!="string"||!s.has(le)||le===k)return;bs.current=!0,xn.current=!0;const _e=Lt.current,at=_e.lastIndexOf(le);at>=0?kt.current=at:(_e.push(le),kt.current=_e.length-1),ma(),U.selectAgent(le)};return window.addEventListener("popstate",Q),()=>window.removeEventListener("popstate",Q)},[gt,s,k,ma]),x.useEffect(()=>{if(!fc.current||!T||gs||zt.fetchingHistory)return;let Q=0,ue=0;return Q=requestAnimationFrame(()=>{ue=requestAnimationFrame(()=>{ye.current&&(ye.current.scrollTop=ye.current.scrollHeight),fc.current=!1})}),()=>{cancelAnimationFrame(Q),cancelAnimationFrame(ue)}},[T,gs,zt.fetchingHistory,zt.historyLoadVersion]);const md=x.useRef(zt.handleScroll);md.current=zt.handleScroll;const kh=x.useCallback(()=>{if(!ye.current||K.keyboardScrollLockRef.current)return;const{scrollTop:Q,scrollHeight:ue,clientHeight:le}=ye.current,_e=ue-Q-le<150;Qi.current||(Ki.current=!_e,_e&&qo(!0)),md.current(K.keyboardScrollLockRef)},[ye,K.keyboardScrollLockRef]),Sh=ee.length>0&&((ai=(Go=ee[ee.length-1])==null?void 0:Go.text)==null?void 0:ai.length)||0;x.useEffect(()=>{K.keyboardScrollLockRef.current||Ki.current||requestAnimationFrame(()=>{ye.current&&(ye.current.scrollTop=ye.current.scrollHeight)})},[ee.length,Sh,K.keyboardScrollLockRef,ye]);const hc=x.useRef(null);x.useLayoutEffect(()=>{const Q=hc.current;Q!==null&&Q!==k?(Da(!1),k&&zt.hasCachedHistory(k)||Ae(!0),U.getState().currentSnapshot&&U.setCurrentSnapshot(null)):k||Da(!1),hc.current=k},[k]),x.useEffect(()=>{if(!gs||zt.fetchingHistory)return;const Q=requestAnimationFrame(()=>{ye.current&&(ye.current.scrollTop=ye.current.scrollHeight),Ae(!1)});return()=>cancelAnimationFrame(Q)},[gs,zt.fetchingHistory,zt.historyLoadVersion]);const br=x.useRef(!1);x.useEffect(()=>{gt&&k&&U.clearUnseenForAgent(k)},[gt,k]),x.useEffect(()=>{br.current=!0,ss(!0)},[T,c]),x.useEffect(()=>{zt.fetchingHistory&&(br.current=!0,ss(!0))},[zt.fetchingHistory]),x.useEffect(()=>{if(!ns||!gt||zt.fetchingHistory)return;const Q=ye.current;if(!Q)return;let ue=null;const le=performance.now();let _e=0,at=-1;const dt=()=>{const{scrollTop:_t,scrollHeight:nn,clientHeight:fn}=Q;return nn-_t-fn<=2},Nt=()=>{const _t=performance.now(),nn=Q.scrollHeight,fn=Math.abs(nn-at)<=1,qn=dt();if(fn&&qn?_e+=1:_e=0,at=nn,_e>=3){ss(!1),ue=null;return}if(_t-le>8e3){ss(!1),ue=null;return}ue=requestAnimationFrame(Nt)};return ue=requestAnimationFrame(Nt),()=>{ue!==null&&cancelAnimationFrame(ue)}},[ns,gt,zt.fetchingHistory,zt.historyLoadVersion]);const gd=x.useRef(!1);x.useEffect(()=>{gd.current&&!ns&&br.current&&(br.current=!1,Da(!0)),gd.current=ns},[ns]),x.useEffect(()=>{if(!gt||!br.current||ns||zt.fetchingHistory)return;const Q=requestAnimationFrame(()=>{br.current&&(br.current=!1,Da(!0))});return()=>cancelAnimationFrame(Q)},[zt.historyLoadVersion,gt,ns,zt.fetchingHistory]),x.useEffect(()=>{const Q=ue=>{if(ue.key==="`"&&!ue.ctrlKey&&!ue.altKey&&S){const le=ue.target;le.tagName!=="INPUT"&&le.tagName!=="TEXTAREA"&&(ue.preventDefault(),U.toggleTerminal())}};return document.addEventListener("keydown",Q),()=>document.removeEventListener("keydown",Q)},[S]),x.useEffect(()=>{if(!gt)return;const Q=ue=>{ue.altKey&&(ue.key!=="ArrowLeft"&&ue.key!=="ArrowRight"||(ue.key==="ArrowLeft"&&qa?(ue.preventDefault(),Ui()):ue.key==="ArrowRight"&&oc&&(ue.preventDefault(),Hi())))};return document.addEventListener("keydown",Q),()=>document.removeEventListener("keydown",Q)},[gt,qa,oc,Ui,Hi]),x.useEffect(()=>{const Q=ue=>{ue.key==="Escape"&&(h?(ue.stopImmediatePropagation(),U.clearFileViewerPath()):m?(ue.stopImmediatePropagation(),U.closeContextModal()):Ze?(ue.stopImmediatePropagation(),lt(null)):Le?(ue.stopImmediatePropagation(),ie(null)):nt?(ue.stopImmediatePropagation(),we(null)):Mn.searchMode&&(ue.stopImmediatePropagation(),Mn.closeSearch()))};return document.addEventListener("keydown",Q,!0),()=>document.removeEventListener("keydown",Q,!0)},[nt,Le,Ze,Mn,h,m]);const bd=x.useRef(gt),Xi=x.useRef(!1);x.useEffect(()=>{bd.current=gt},[gt]),x.useEffect(()=>{if(window.innerWidth<=768)return;const ue=at=>{var nn;if(!(at instanceof Element))return!1;const dt=(nn=z.current)==null?void 0:nn.contains(at),Nt=at.closest(".agent-bar"),_t=!!at.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!!dt||!!Nt||_t},le=at=>{if(!bd.current){Xi.current=!1;return}if(JD("terminal")){Xi.current=!1;return}Xi.current=!ue(at.target)},_e=at=>{Xi.current&&(ue(at.target)||U.setTerminalOpen(!1),Xi.current=!1)};return document.addEventListener("mousedown",le,!0),document.addEventListener("mouseup",_e,!0),()=>{document.removeEventListener("mousedown",le,!0),document.removeEventListener("mouseup",_e,!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 mc=typeof window<"u"&&window.innerWidth<=768;if(!S)return mc&&f==="terminal"&&a.size===0?o.jsx("div",{ref:z,className:`guake-terminal open ${Te?"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")})]})})})}):mc&&f==="terminal"&&a.size>0?o.jsx("div",{ref:z,className:`guake-terminal open ${Te?"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 Ch=Q=>{Q.preventDefault(),Q.stopPropagation(),Vt.current++,Q.dataTransfer.types.includes("Files")&&jt(!0)},Ah=Q=>{Q.preventDefault(),Q.stopPropagation()},jh=Q=>{Q.preventDefault(),Q.stopPropagation(),Vt.current--,Vt.current===0&&jt(!1)},Nh=async Q=>{Q.preventDefault(),Q.stopPropagation(),Vt.current=0,jt(!1);const ue=Q.dataTransfer.files;if(ue.length)for(const le of ue){const _e=await Qn.uploadFile(le);_e&&Qn.setAttachedFiles(at=>[...at,_e])}};return o.jsxs("div",{ref:z,className:`guake-terminal ${gt?"open":"collapsed"} ${Te&&gt?"fullscreen":""} ${ae&&gt?"with-debug-panel":""} ${De&&gt?"with-git-panel":""} ${Pe&&gt?"with-buildings-panel":""} ${ve&&gt?"with-workflow-panel":""} ${ht&&gt?"with-overview-panel":""} ${Je?"drag-over":""} ${Vo>0?"mobile-swipe-close-active":""} ${uc?"mobile-swipe-close-closing":""}`,style:{"--terminal-height":`${L}%`,"--mobile-swipe-close-offset":`${Vo}px`,"--guake-side-panel-width":`${se}px`,...V>0?{"--guake-mobile-overview-height":`${V}px`}:{}},onDragEnter:Ch,onDragOver:Ah,onDragLeave:jh,onDrop:Nh,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&&ae&&gt&&T&&o.jsx(c5,{agentId:T,onClose:()=>Se(!1)}),!y&&De&&gt&&T&&o.jsx(y5,{agentId:T,agents:s,onClose:()=>be(!1),branchInfoMap:F,fetchRemote:$,fetchingDirs:H}),!y&&Pe&&gt&&T&&o.jsx(O5,{agentId:T,onClose:()=>ge(!1)}),!y&&ve&&gt&&T&&o.jsx(P5,{agentId:T,onClose:()=>Ke(!1)}),!y&&(ae||De||Pe||ve)&&gt&&o.jsx("div",{className:"guake-side-panel-resize right",onMouseDown:Q=>ce(Q,"right")}),!y&&ht&&gt&&T&&o.jsx(M5,{activeAgentId:T,onClose:()=>ot(!1),onSelectAgent:Q=>{U.setLastSelectionViaDirectClick(!0),U.selectAgent(Q)},agentListRef:Me,twoFingerState:fd}),!y&&ht&&gt&&T&&o.jsx("div",{className:"guake-side-panel-resize left",onMouseDown:Q=>ce(Q,"left")}),!y&&ht&&gt&&T&&o.jsx("div",{className:"aop-resize-handle",onMouseDown:G,onTouchStart:B}),o.jsxs("div",{className:"guake-content",children:[o.jsx(N6,{selectedAgent:S,selectedAgentId:T,sortedAgents:Hn.sortedAgents,swipeOffset:Hn.swipeOffset,viewMode:X,setViewMode:ne,searchMode:Mn.searchMode,toggleSearch:Mn.toggleSearch,closeSearch:Mn.closeSearch,debugPanelOpen:ae,setDebugPanelOpen:Se,debuggerEnabled:Z,setDebuggerEnabled:he,gitPanelOpen:De,setGitPanelOpen:be,buildingsPanelOpen:Pe,setBuildingsPanelOpen:ge,workflowPanelOpen:ve,setWorkflowPanelOpen:Ke,hasWorkflow:st,overviewPanelOpen:ht,setOverviewPanelOpen:ot,agentInfoOpen:fe,onToggleAgentInfo:gh,isFullscreen:Te,onToggleFullscreen:Ra,onNavigateBack:Ui,onNavigateForward:Hi,canNavigateBack:qa,canNavigateForward:oc,outputsLength:Wn.length+Es.length,setContextConfirm:Ue,headerRef:Hn.headerRef,onSaveSnapshot:y?void 0:e,isSnapshotView:y}),Mn.searchMode&&o.jsx(T6,{searchInputRef:Mn.searchInputRef,searchQuery:Mn.searchQuery,setSearchQuery:Mn.setSearchQuery,closeSearch:Mn.closeSearch,matchCount:Mn.matchIndices.length,currentMatch:Mn.currentMatch,navigateNext:Mn.navigateNext,navigatePrev:Mn.navigatePrev,loadingFullHistory:Mn.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:(xd=Hn.nextAgent)==null?void 0:xd.name})]}),o.jsxs("div",{className:`swipe-indicator right ${Hn.swipeOffset<-.3?"visible":""}`,children:[o.jsx("span",{className:"indicator-name",children:(gc=Hn.prevAgent)==null?void 0:gc.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:ye,onScroll:kh,children:o.jsxs("div",{className:`guake-history-content ${Xr?"fade-in":""}`,children:[gs&&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",{})]})]}),!gs&&zt.loadingHistory&&zt.history.length===0&&ee.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",{})]})]}),!gs&&!zt.loadingHistory&&zt.history.length===0&&Ne.length===0&&S.status!=="working"&&o.jsx("div",{className:"guake-empty",children:n("terminal:empty.noOutput")}),!gs&&zt.hasMore&&!Mn.searchMode&&o.jsx("div",{className:"guake-load-more",children:zt.loadingMore?o.jsx("span",{children:n("terminal:empty.loadingOlder")}):o.jsx("button",{onClick:zt.loadMoreHistory,children:n("terminal:empty.loadMore",{count:zt.totalCount-zt.history.length})})}),!gs&&o.jsx(l5,{historyMessages:Wn,liveOutputs:Es,agentId:T,execTasks:pd,subagents:$o,viewMode:X,searchHighlight:Mn.highlightQuery,searchActiveIndex:Mn.scrollToIndex,selectedMessageIndex:Ho.selectedIndex,isMessageSelected:Ho.isSelected,onImageClick:Wo,onFileClick:si,onBashClick:Gi,onViewMarkdown:hd,scrollContainerRef:ye,onScrollTopReached:zt.loadMoreHistory,isLoadingMore:zt.loadingMore,hasMore:zt.hasMore,shouldAutoScroll:bh,onUserScroll:xh,pinToBottom:ns,onPinCancel:yh,isLoadingHistory:zt.fetchingHistory},T),!gs&&pe&&o.jsxs("div",{className:"compacting-indicator",children:[o.jsx("div",{className:"compacting-bar",children:o.jsx("div",{className:"compacting-bar-fill"})}),o.jsx("span",{className:"compacting-label",children:"Compacting context..."})]}),!gs&&Ps&&gr.length>0&&o.jsxs("div",{className:`agent-progress-container ${qi?"collapsed":"expanded"}`,children:[o.jsxs("div",{className:"agent-progress-container-header",onClick:()=>Vi(Q=>!Q),role:"button",tabIndex:0,onKeyDown:Q=>{(Q.key==="Enter"||Q.key===" ")&&(Q.preventDefault(),Vi(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:gr.length})}),o.jsx("span",{className:"agent-progress-container-toggle",children:qi?"▶":"▼"})]}),!qi&&gr.map(Q=>o.jsx(H5,{progress:Q,defaultExpanded:Q.status==="working",onAgentClick:ue=>{U.selectAgent(ue),U.setTerminalOpen(!0)},onDismiss:ue=>{T&&U.clearAgentTaskProgress(T,ue)},onFileClick:si,onBashClick:Gi},Q.agentId))]})]})})]}),o.jsx(I6,{selectedAgent:S,selectedAgentId:T,isOpen:gt,command:Qn.command,setCommand:Qn.setCommand,forceTextarea:Qn.forceTextarea,setForceTextarea:Qn.setForceTextarea,useTextarea:Qn.useTextarea,attachedFiles:Qn.attachedFiles,setAttachedFiles:Qn.setAttachedFiles,removeAttachedFile:Qn.removeAttachedFile,uploadFile:Qn.uploadFile,pastedTexts:Qn.pastedTexts,expandPastedTexts:Qn.expandPastedTexts,incrementPastedCount:Qn.incrementPastedCount,setPastedTexts:Qn.setPastedTexts,resetPastedCount:Qn.resetPastedCount,handleInputFocus:K.handleInputFocus,handleInputBlur:K.handleInputBlur,pendingPermissions:Wi,showCompletion:pa,completionElapsed:ic,onImageClick:Wo,inputRef:qe,textareaRef:He,isSnapshotView:y,onClearHistory:zt.clearHistory,onSendCommand:vh,canSwipeClose:mc&&f==="terminal"&&!gs&&!Mn.searchMode&&!zt.fetchingHistory,onSwipeCloseOffsetChange:pc,onSwipeClose:wh}),o.jsxs("div",{className:"guake-agent-status-bar",children:[!y&&(S==null?void 0:S.isDetached)&&o.jsx(cs,{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:le})=>{const _e=F.get(le),at=H.has(le);return o.jsxs("span",{className:"guake-agent-area-dir",title:`${ue}: ${le}${_e?` (${_e.branch}${_e.ahead?` ↑${_e.ahead}`:""}${_e.behind?` ↓${_e.behind}`:""})`:""}`,onClick:()=>U.openFileExplorerForAreaFolder(Q,le),children:["📂 ",le.split("/").filter(Boolean).pop()||le,_e&&o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"guake-agent-area-branch",children:[" ⎇ ",_e.branch]}),_e.ahead>0&&o.jsxs("span",{className:"guake-branch-ahead",title:`${_e.ahead} ahead`,children:["↑",_e.ahead]}),_e.behind>0&&o.jsxs("span",{className:"guake-branch-behind",title:`${_e.behind} behind`,children:["↓",_e.behind]}),o.jsx("span",{className:`guake-area-fetch-btn ${at?"fetching":""}`,title:"Git fetch",onClick:dt=>{dt.stopPropagation(),$(le)},children:at?"⏳":"⇣"})]})]},`${Q}:${le}`)}),!y&&S&&(()=>{const Q=S.contextStats,ue=!!Q,le=Q?Q.totalTokens:S.contextUsed||0,_e=Q?Q.contextWindow:S.contextLimit||2e5,at=Q?Q.usedPercent:Math.round(le/_e*100),dt=Math.max(0,Math.min(100,at)),Nt=Math.max(0,100-dt),_t=dt>=80?"#ff4a4a":dt>=60?"#ff9e4a":dt>=40?"#ffd700":"#4aff9e",nn=(le/1e3).toFixed(1),fn=(_e/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,dt)}%`,backgroundColor:_t}})}),o.jsxs("span",{className:"context-tokens",style:{color:_t},children:[nn,"k/",fn,"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=Is.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 le=ft.find(_e=>_e.buildingId===Q.id);le&&Un(le.id)}else Q.hasUrl||U.sendBuildingCommand(Q.id,"start"),Bn(Q.id,"terminal")},onContextMenu:le=>{le.preventDefault(),le.stopPropagation(),Is.has(Q.id)||Ft({position:{x:le.clientX,y:le.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=Is.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 le=ft.find(_e=>_e.buildingId===Q.id);le&&Un(le.id)}else Bn(Q.id,"pm2-logs")},onContextMenu:le=>{le.preventDefault(),le.stopPropagation(),Is.has(Q.id)||Ft({position:{x:le.clientX,y:le.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=Is.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 le=ft.find(_e=>_e.buildingId===Q.id);le&&Un(le.id)}else Bn(Q.id,"database")},onContextMenu:le=>{le.preventDefault(),le.stopPropagation(),Is.has(Q.id)||Ft({position:{x:le.clientX,y:le.clientY},buildingId:Q.id,type:"database"})},children:"🗄️"},Q.id)})}),o.jsx(q5,{})]})]}),(()=>{const Q=[];return ct&&(Q.push({id:"open",label:"Open",icon:"⬇",onClick:()=>Bn(ct.buildingId,ct.type)}),bn.length>0&&(Q.push({id:"split-right",label:"Split Right",icon:"↔",onClick:()=>us(ct.buildingId,ct.type,"horizontal")}),Q.push({id:"split-below",label:"Split Below",icon:"↕",onClick:()=>us(ct.buildingId,ct.type,"vertical")}))),o.jsx(pr,{children:o.jsx(Lo,{isOpen:ct!==null,position:(ct==null?void 0:ct.position)||{x:0,y:0},worldPosition:{x:0,z:0},actions:Q,onClose:()=>Ft(null)})})})(),bn.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"guake-bottom-terminal-resize",onMouseDown:zo}),o.jsx("div",{ref:rt,className:`guake-bottom-panels-container ${Ye}`,style:{height:Et},onWheel:Q=>Q.stopPropagation(),children:bn.map((Q,ue)=>{const le=P.get(Q.buildingId);if(!le)return null;const _e=qt[ue]??1,at=(()=>{var dt;if(Q.type==="terminal")return(dt=le.terminalStatus)!=null&&dt.url?o.jsxs("div",{className:"guake-bottom-panel",style:{flex:_e},children:[o.jsxs("div",{className:"guake-bottom-terminal-header",children:[o.jsxs("span",{className:"guake-bottom-terminal-title",children:["💻 ",le.name]}),o.jsx("button",{className:"guake-bottom-terminal-close",onClick:()=>Un(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(Nx,{terminalUrl:le.terminalStatus.url,visible:!0})]},Q.id):o.jsxs("div",{className:"guake-bottom-panel",style:{flex:_e},children:[o.jsxs("div",{className:"guake-bottom-terminal-header",children:[o.jsxs("span",{className:"guake-bottom-terminal-title",children:["💻 ",le.name," (starting...)"]}),o.jsx("button",{className:"guake-bottom-terminal-close",onClick:()=>Un(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=ln[Q.id]||"";return o.jsxs("div",{className:"guake-bottom-panel",style:{flex:_e},children:[o.jsxs("div",{className:"guake-bottom-terminal-header",children:[o.jsxs("span",{className:"guake-bottom-terminal-title",children:["📜 ",le.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 nn=_t.target.value;Kt(fn=>{if(!nn.trim()){if(!(Q.id in fn))return fn;const qn={...fn};return delete qn[Q.id],qn}return{...fn,[Q.id]:nn}})},placeholder:"Filter logs","aria-label":`Filter logs for ${le.name}`,spellCheck:!1}),o.jsx("select",{className:"guake-bottom-terminal-retention",value:Ce===null?"unlimited":String(Ce),onChange:_t=>{const nn=_t.target.value==="unlimited"?null:Number(_t.target.value);Be(nn),EO(nn)},"aria-label":`Max log retention for ${le.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:()=>Un(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(sW,{buildingId:Q.buildingId,filterText:Nt,maxRetention:Ce})]},Q.id)}return o.jsxs("div",{className:"guake-bottom-panel",style:{flex:_e},children:[o.jsxs("div",{className:"guake-bottom-terminal-header",children:[o.jsxs("span",{className:"guake-bottom-terminal-title",children:["🗄️ ",le.name]}),o.jsx("button",{className:"guake-bottom-terminal-close",onClick:()=>Un(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(MH,{building:le})]},Q.id)})();return ue>0?o.jsxs(je.Fragment,{children:[o.jsx("div",{className:`guake-split-divider ${Ye}`,onMouseDown:dt=>Qs(dt,ue-1)}),at]},Q.id):at})})]}),ft.filter(Q=>Q.areaId!==_n&&Q.type==="terminal").map(Q=>{var le;const ue=P.get(Q.buildingId);return(le=ue==null?void 0:ue.terminalStatus)!=null&&le.url?o.jsx(Nx,{terminalUrl:ue.terminalStatus.url,visible:!1},Q.id):null})]}),gt&&!Te&&o.jsx("div",{className:"guake-resize-handle",onMouseDown:W,title:n("common:rightPanel.dragToResize")}),!(gt&&Te)&&o.jsxs("div",{className:"guake-handle",onClick:()=>{gt&&U.toggleTerminal()},onDoubleClick:()=>{gt||U.toggleTerminal()},style:{top:gt?`min(${L}%, calc(100vh - 72px))`:"0"},children:[o.jsx("span",{className:"guake-handle-icon",children:gt?"▲":"▼"}),o.jsx("span",{className:"guake-handle-text",children:S.name})]}),nt&&o.jsx(B6,{url:nt.url,name:nt.name,onClose:()=>we(null)}),Le&&o.jsx(F6,{state:Le,onClose:()=>ie(null)}),de&&o.jsx(z6,{action:de,selectedAgentId:T,subordinateCount:((bc=S==null?void 0:S.subordinateIds)==null?void 0:bc.length)||0,onClose:()=>Ue(null),onClearHistory:zt.clearHistory}),o.jsx($6,{}),o.jsx(U6,{}),o.jsx(W6,{agent:S,isOpen:fe,onClose:()=>J(!1)}),!y&&o.jsx(H6,{agent:S,content:Ze,onClose:()=>lt(null)})]})});function rW(t){return t.trim().replace(/^v/i,"")}function GA(t){const n=rW(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 iW(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 oW(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 iW(n.prerelease,s.prerelease)}function lW(t,e){const n=oW(t,e);return n===null?"unknown":n<0?"behind":n>0?"ahead":"equal"}async function cW(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 uW(t,e,n={}){const s=await cW(t,n);return s?{currentVersion:e,latestVersion:s,relation:lW(e,s)}:{currentVersion:e,latestVersion:null,relation:"unknown"}}const dW="tide-commander",Rb="1.40.4";function fW(){const[t,e]=x.useState({currentVersion:Rb,latestVersion:null,relation:"unknown",isChecking:!1}),n=x.useCallback(async()=>{e(a=>({...a,isChecking:!0}));const s=await uW(dW,Rb);e({currentVersion:Rb,latestVersion:s.latestVersion,relation:s.relation,isChecking:!1})},[]);return x.useEffect(()=>{n()},[n]),{...t,refresh:n}}const pW=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:A,onDrop:N,onAgentClick:k,onAgentDoubleClick:j,onTouchStart:S,onTouchMove:T,onTouchEnd:D,onTouchCancel:E,onHoverEnter:P,onHoverLeave:O,onItemRef:_}){const M=x.useMemo(()=>fr(e.class,h),[e.class,h]),R=!a||r,F=x.useCallback($=>{_(e.id,$)},[e.id,_]);return o.jsxs("div",{ref:F,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:A,onDrop:$=>N($,s),onTouchStart:$=>S($,e.id),onTouchMove:T,onTouchEnd:D,onTouchCancel:E,onClick:$=>k(e,$),onDoubleClick:()=>j(e),onMouseEnter:()=>P(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:Mx(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:Ex(e.lastActivity)},title:Dx(e.lastActivity),children:"⏱"})]}),o.jsxs("span",{className:"agent-bar-hotkey",title:`Ctrl+${n+1}`,children:["^",n+1]})]})}),hW=x.memo(function({onFocusAgent:e,onSpawnClick:n,onSpawnBossClick:s,onNewBuildingClick:a,onNewAreaClick:r}){const{t:i}=pt(["common"]),c=nd(),d=ur(),f=Hx(),h=WO(),m=Wx(),b=Vr(),y=dr(),w=cN(),[A]=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,P]=x.useState(null),[O,_]=x.useState(new Map),[M,R]=x.useState(null),[F,$]=x.useState(null),H=x.useRef(0),[L,z]=x.useState(null),W=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,[]),me=x.useMemo(()=>Array.from(c.values()).filter(ve=>{if(U.isAgentInArchivedArea(ve.id))return!1;if(A){const Fe=U.getAreaForAgent(ve.id);if(!$x((Fe==null?void 0:Fe.id)??null))return!1}return!0}).sort((ve,Fe)=>(ve.createdAt||0)-(Fe.createdAt||0)),[c,d,A]),{orderedAgents:ce,moveAgent:ee}=mO(me),pe=ce,Ne=x.useMemo(()=>{const ve=new Map;for(const Fe of pe)ve.set(Fe.id,U.getAreaForAgent(Fe.id));return ve},[pe,d]),ye=x.useMemo(()=>{const ve=new Map;for(const Ke of pe){const st=Ne.get(Ke.id)||null,xt=(st==null?void 0:st.id)||null;ve.has(xt)||ve.set(xt,{area:st,agents:[]}),ve.get(xt).agents.push(Ke)}const Fe=Array.from(ve.values());return Fe.sort((Ke,st)=>{var xt,ht;return!Ke.area&&st.area?1:Ke.area&&!st.area?-1:!Ke.area&&!st.area?0:(((xt=Ke.area)==null?void 0:xt.name)||"").localeCompare(((ht=st.area)==null?void 0:ht.name)||"")}),Fe},[pe,Ne]),Me=x.useRef(e);Me.current=e;const qe=x.useRef(M);qe.current=M;const He=x.useRef(pe);He.current=pe;const X=x.useRef(Ne);X.current=Ne;const ne=x.useRef(ee);ne.current=ee,x.useEffect(()=>{const ve=new Map(O);let Fe=!1;for(const Ke of pe){const st=O.get(Ke.id);Ke.currentTool?(!st||st.tool!==Ke.currentTool)&&(ve.set(Ke.id,{tool:Ke.currentTool,key:Date.now()}),Fe=!0):st&&setTimeout(()=>{_(xt=>{const ht=new Map(xt);return ht.delete(Ke.id),ht})},1500)}Fe&&_(ve)},[pe.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 st=Fe.getBoundingClientRect(),xt=Ke.getBoundingClientRect(),ot=st.left-xt.left+Ke.scrollLeft+st.width/2,ft=Ke.clientWidth;Ke.scrollTo({left:ot-ft/2,behavior:"smooth"})})},[h]);const Te=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)},[]),We=x.useCallback(ve=>{var Fe;(Fe=Me.current)==null||Fe.call(Me,ve.id),U.setTerminalOpen(!0)},[]),nt=x.useCallback(()=>P(null),[]),we=x.useCallback((ve,Fe)=>{Fe?D.current.set(ve,Fe):D.current.delete(ve)},[]),Le=x.useCallback((ve,Fe)=>{R(Fe),z(Fe.id),ve.dataTransfer.effectAllowed="move",ve.dataTransfer.setData("text/plain",Fe.id),requestAnimationFrame(()=>{ve.target.classList.add("dragging")})},[]),ie=x.useCallback(ve=>{R(null),$(null),z(null),H.current=0,ve.target.classList.remove("dragging")},[]),de=x.useCallback((ve,Fe)=>{ve.preventDefault();const Ke=qe.current;if(Ke){const st=X.current.get(Ke.id),xt=He.current[Fe],ht=xt?X.current.get(xt.id):null,ot=(st==null?void 0:st.id)??null,ft=(ht==null?void 0:ht.id)??null;ve.dataTransfer.dropEffect=ot===ft?"move":"none"}else ve.dataTransfer.dropEffect="move"},[]),Ue=x.useCallback((ve,Fe)=>{ve.preventDefault(),H.current++;const Ke=qe.current;if(Ke){const st=X.current.get(Ke.id),xt=He.current[Fe],ht=xt?X.current.get(xt.id):null,ot=(st==null?void 0:st.id)??null,ft=(ht==null?void 0:ht.id)??null;$(ot===ft?Fe:null)}else $(Fe)},[]),Ze=x.useCallback(ve=>{H.current--,H.current===0&&$(null)},[]),lt=x.useCallback((ve,Fe)=>{ve.preventDefault();const Ke=qe.current;if(!Ke)return;const st=He.current,xt=X.current,ht=st.findIndex(ot=>ot.id===Ke.id);if(ht!==-1&&ht!==Fe){const ot=xt.get(Ke.id),ft=st[Fe],ut=ft?xt.get(ft.id):null,ln=(ot==null?void 0:ot.id)??null,Kt=(ut==null?void 0:ut.id)??null;ln===Kt&&ne.current(ht,Fe)}R(null),$(null),z(null),H.current=0},[]),fe=x.useCallback(()=>{W.current&&(clearTimeout(W.current),W.current=null)},[]),J=x.useCallback(()=>{B.current&&(clearTimeout(B.current),B.current=null)},[]),ae=x.useCallback((ve,Fe)=>{if(!q||ve.touches.length!==1)return;fe(),J(),z(null);const Ke=ve.touches[0];V.current={agentId:Fe,x:Ke.clientX,y:Ke.clientY},W.current=setTimeout(()=>{z(Fe),G.current=Fe,W.current=null},K)},[fe,J,q]),Se=x.useCallback(ve=>{if(!q||ve.touches.length!==1)return;const Fe=V.current;if(!Fe||!W.current)return;const Ke=ve.touches[0],st=Ke.clientX-Fe.x,xt=Ke.clientY-Fe.y;Math.sqrt(st*st+xt*xt)>se&&(fe(),V.current=null)},[fe,q]),Z=x.useCallback(()=>{fe(),V.current=null,qe.current||z(null),J(),B.current=setTimeout(()=>{G.current=null,B.current=null},450)},[fe,J]);x.useEffect(()=>()=>{fe(),J()},[fe,J]);const he=ve=>{const Fe=`common:status.${ve}`;return i(Fe,{defaultValue:i("common:status.unknown")})},{currentVersion:De,latestVersion:ze,relation:be,isChecking:Pe}=fW(),te=De;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:ze?`Tide Commander v${te} (npm: v${ze})`:`Tide Commander v${te}`,children:[o.jsxs("span",{children:["v",te]}),be==="behind"&&ze?o.jsxs("span",{className:"agent-bar-version-badge agent-bar-version-badge-behind",title:`Behind npm latest v${ze}`,children:["npm v",ze]}):be==="ahead"&&ze?o.jsxs("span",{className:"agent-bar-version-badge agent-bar-version-badge-ahead",title:`Ahead of npm latest v${ze}`,children:["npm v",ze]}):null,be==="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)"})}):be==="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)"})}):be==="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(cs,{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(cs,{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(cs,{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(cs,{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(cs,{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")})]})}),ye.map(ve=>{var st,xt,ht,ot,ft;const Fe=ve.agents,Ke=!ve.area;return o.jsxs("div",{className:`agent-bar-group ${Ke?"unassigned":""}`,style:{borderColor:((st=ve.area)==null?void 0:st.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:((xt=ve.area)==null?void 0:xt.color)||"#888"},children:((ht=ve.area)==null?void 0:ht.name)||i("common:agentBar.unassigned")})}),((ot=ve.area)==null?void 0:ot.directories)&&ve.area.directories.length>0&&o.jsx("div",{className:"agent-bar-folders",children:ve.area.directories.map((ut,ln)=>o.jsxs("div",{className:"agent-bar-folder-item",onClick:Kt=>{Kt.stopPropagation(),U.openFileExplorer(ut)},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:ut}),o.jsx("div",{className:"agent-bar-folder-tooltip-hint",children:i("common:agentBar.clickToOpen")})]})]},ln))}),Fe.map(ut=>{const ln=ge++,Kt=pe.findIndex(Ce=>Ce.id===ut.id);return o.jsx(pW,{agent:ut,currentIndex:ln,agentIndex:Kt,isTouchInput:q,isTouchDragEnabled:L===ut.id,isSelected:f.has(ut.id),hasUnseenOutput:w.has(ut.id),isDragging:(M==null?void 0:M.id)===ut.id,isDragOver:F===Kt,customClasses:y,onDragStart:Le,onDragEnd:ie,onDragOver:de,onDragEnter:Ue,onDragLeave:Ze,onDrop:lt,onAgentClick:Te,onAgentDoubleClick:We,onTouchStart:ae,onTouchMove:Se,onTouchEnd:Z,onTouchCancel:Z,onHoverEnter:P,onHoverLeave:nt,onItemRef:we},ut.id)})]},((ft=ve.area)==null?void 0:ft.id)||"unassigned")})]})]}),Array.from(O.entries()).map(([ve,Fe])=>{const Ke=D.current.get(ve);if(!Ke)return null;const st=Ke.getBoundingClientRect(),xt=ms[Fe.tool]||ms.default;return o.jsxs("div",{className:"agent-bar-tool-bubble",title:Fe.tool,style:{position:"fixed",left:st.left+st.width/2,bottom:window.innerHeight-st.top+8},children:[o.jsx("span",{className:"agent-bar-tool-icon",children:xt}),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),st=U.getAgentSupervisorHistory(E.id),xt=st.length>0?st[st.length-1]:void 0,ht=Date.now()-(E.createdAt||Date.now()),ot=Math.floor(ht/6e4),ft=Math.floor(ot/60),ut=ft>0?`${ft}h ${ot%60}m`:`${ot}m`,ln=et=>et>=1e6?`${(et/1e6).toFixed(1)}M`:et>=1e3?`${(et/1e3).toFixed(1)}K`:et.toString(),Kt=E.contextLimit>0?Math.round(E.contextUsed/E.contextLimit*100):0,Ce=et=>{switch(et){case"on_track":return"#4aff9e";case"completed":return"#4a9eff";case"stalled":return"#ff9e4a";case"blocked":return"#ff4a4a";case"idle":return"#888888";default:return"#888888"}},Be=D.current.get(E.id),Ye={};if(Be){const et=Be.getBoundingClientRect();Ye.position="fixed",Ye.left=et.left+et.width/2,Ye.bottom=window.innerHeight-et.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:Mx(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:ut})]}),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:[ln(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:Kt>80?"#ff4a4a":Kt>60?"#ff9e4a":void 0},children:[ln(E.contextUsed)," / ",ln(E.contextLimit)," (",Kt,"%)"]})]}),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:[ms[E.currentTool]||ms.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?"...":""]})]}),xt&&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:Ce(xt.analysis.progress)},children:xt.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:xt.analysis.statusDescription})]}),xt.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:[xt.analysis.recentWorkSummary.substring(0,300),xt.analysis.recentWorkSummary.length>300?"...":""]})]}),xt.analysis.concerns&&xt.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:xt.analysis.concerns.join("; ")})]})]})]})]})})()]})});function mW({activeTool:t,onExit:e}){const{t:n}=pt(["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 gW={idle:"common:status.idle",working:"common:status.working",waiting:"common:status.waiting",error:"common:status.error",offline:"common:status.offline"},Ob=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString(),bW=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"}},xW=x.memo(function({agent:e,screenPos:n,onClose:s}){const{t:a}=pt(["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`,A=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:Mx(e.status)},children:a(gW[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:[Ob(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:A>80?"#ff4a4a":A>60?"#ff9e4a":void 0},children:[Ob(e.contextUsed)," / ",Ob(e.contextLimit)," (",A,"%)"]})]}),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:[ms[e.currentTool]||ms.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:bW(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 yW(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 vW=x.memo(function({building:e,screenPos:n,onClose:s,onOpenSettings:a,onOpenLogsModal:r,onOpenUrlInModal:i}){var z,W,V,G,B,K,se,q,me,ce,ee,pe,Ne,ye,Me,qe,He,X,ne,Te;const{t:c}=pt(["terminal","common"]),[d,f]=x.useState(!1),[h,m]=x.useState(null),[b,y]=x.useState(!1),w=x.useRef(null),A=x.useRef(h);A.current=h;const{buildingLogs:N}=Ls(),k=U.getBuildingLogs(e.id),j=(z=e.pm2)==null?void 0:z.enabled,S=(W=e.docker)==null?void 0:W.enabled,T=x.useRef(null),D=x.useRef(null),E=x.useCallback(We=>{We.preventDefault();const nt=A.current?A.current.x:0,we=A.current?A.current.y:0;w.current={mouseX:We.clientX,mouseY:We.clientY,popupX:nt,popupY:we},y(!0),T.current=Le=>{if(!w.current)return;const ie=Le.clientX-w.current.mouseX,de=Le.clientY-w.current.mouseY;m({x:w.current.popupX+ie,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 P=We=>{if(We==="logs"){if((j||S)&&r){r();return}U.sendBuildingCommand(e.id,We),f(!0)}else U.sendBuildingCommand(e.id,We)},O=(We,nt)=>{if(We){const we=`http://localhost:${We}`;nt&&i?i(we):window.open(we,"_blank")}},_=((V=e.pm2Status)==null?void 0:V.ports)||[],M=((B=(G=e.dockerStatus)==null?void 0:G.ports)==null?void 0:B.map(We=>We.host))||[],R=j?_:S?M:[],F=j?!!((K=e.pm2)!=null&&K.script):S?!!((se=e.docker)!=null&&se.image)||((q=e.docker)==null?void 0:q.mode)==="compose"||((me=e.docker)==null?void 0:me.mode)==="existing":!!((ce=e.commands)!=null&&ce.start),$=j?!!((ee=e.pm2)!=null&&ee.script):S?!0:!!((pe=e.commands)!=null&&pe.stop),H=j?!!((Ne=e.pm2)!=null&&Ne.script):S?!0:!!((ye=e.commands)!=null&&ye.restart),L=x.useMemo(()=>{const nt=d?400:250;let we=n.x+20,Le=n.y-80;return typeof window<"u"&&!h&&(n.x+20+280>window.innerWidth&&(we=n.x-280-20),n.y-80<0?Le=10:n.y-80+nt>window.innerHeight&&(Le=window.innerHeight-nt-10)),{position:"fixed",left:we+((h==null?void 0:h.x)||0),top:Le+((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:We=>We.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(We=>o.jsxs("a",{href:`http://localhost:${We}`,className:"building-popup-port-link",onClick:nt=>{nt.preventDefault(),nt.stopPropagation(),O(We,nt.altKey)},onMouseDown:nt=>nt.stopPropagation(),title:`Open http://localhost:${We} (Alt+Click for modal)`,children:[":",We]},We))}),o.jsx("span",{className:"building-popup-status",style:{backgroundColor:Yb[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:[((Me=e.pm2Status.cpu)==null?void 0:Me.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&&((qe=e.dockerStatus)==null?void 0:qe.services)&&e.dockerStatus.services.length>0&&o.jsx("div",{className:"building-popup-services",children:e.dockerStatus.services.map((We,nt)=>o.jsxs("span",{className:"service-item",title:`${We.name}: ${We.status}`,children:[o.jsx("span",{className:"service-indicator",style:{backgroundColor:We.status==="running"?"#4ade80":"#f87171"}}),o.jsx("span",{className:"service-name",children:We.name})]},nt))}),(e.lastError||j&&((He=e.pm2Status)==null?void 0:He.status)==="errored"||S&&((X=e.dockerStatus)==null?void 0:X.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&&((Te=e.dockerStatus)==null?void 0:Te.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:()=>P("start"),disabled:!F||e.status==="running"||e.status==="starting",title:c(F?"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:()=>P("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:()=>P("restart"),disabled:!H,title:c(H?"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:()=>P("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:We=>O(R[0],We.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(We=>o.jsxs("button",{className:"action-btn open-url port-btn",onClick:nt=>O(We,nt.altKey),title:`Open http://localhost:${We} (Alt+Click for modal)`,children:[":",We]},We))]})]}),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((We,nt)=>o.jsx("pre",{children:yW(We)},nt))})]}),o.jsx("button",{className:"building-popup-settings",onClick:a,children:c("terminal:buildingAction.fullSettings")})]})});function wW(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 kW(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 SW=x.memo(function({building:e,screenPos:n,onClose:s,onOpenSettings:a,onOpenLogsModal:r,onOpenUrlInModal:i}){const{t:c}=pt(["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}=Ls(),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=F=>{if(!b.current)return;const $=F.clientX-b.current.mouseX,H=F.clientY-b.current.mouseY;f({x:b.current.popupX+$,y:b.current.popupY+H})},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}),P=(_,M)=>{const R=`http://localhost:${_}`;M&&i?i(R):window.open(R,"_blank")},O=x.useMemo(()=>{let R=n.x+20,F=n.y-80;return typeof window<"u"&&!d&&(n.x+20+340>window.innerWidth&&(R=n.x-340-20),n.y-80<0?F=10:n.y-80+350>window.innerHeight&&(F=window.innerHeight-350-10)),{position:"fixed",left:R+((d==null?void 0:d.x)||0),top:F+((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:Yb[_]||"#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,F;return o.jsxs("div",{className:"subordinate-item",children:[o.jsx("span",{className:"sub-status-dot",style:{backgroundColor:Yb[_.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:H=>{H.preventDefault(),H.stopPropagation(),P($,H.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),"% | ",wW(_.pm2Status.memory||0)]}),((F=_.pm2Status)==null?void 0:F.uptime)&&o.jsx("span",{className:"sub-uptime",children:kW(_.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")})]})}),CW=x.memo(function({building:e,screenPos:n,onClose:s,onOpenSettings:a,onOpenDatabasePanel:r}){var D;const{t:i}=pt(["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=Kx(e.id),w=((D=e.database)==null?void 0:D.connections)??[],A=x.useRef(null),N=x.useRef(null),k=x.useCallback(E=>{E.preventDefault();const P=b.current?b.current.x:0,O=b.current?b.current.y:0;m.current={mouseX:E.clientX,mouseY:E.clientY,popupX:P,popupY:O},h(!0),A.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,A.current&&document.removeEventListener("mousemove",A.current),N.current&&document.removeEventListener("mouseup",N.current)},document.addEventListener("mousemove",A.current),document.addEventListener("mouseup",N.current)},[]);x.useEffect(()=>()=>{A.current&&document.removeEventListener("mousemove",A.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 P=S(E.id);return o.jsxs("div",{className:"database-connection-item",children:[o.jsx("span",{className:"conn-engine",children:((O=kL[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}`}),P&&o.jsx("span",{className:`conn-status ${P.connected?"connected":"disconnected"}`,children:P.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 AW({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,A]=x.useState(!1),[N,k]=x.useState("fps"),[j,S]=x.useState(null),[T,D]=x.useState(null),[E,P]=x.useState(null),[O,_]=x.useState(typeof window<"u"?window.innerWidth:1024),[M,R]=x.useState(null);x.useEffect(()=>{const ee=()=>_(window.innerWidth);return window.addEventListener("resize",ee),()=>window.removeEventListener("resize",ee)},[]);const F=Kp(),$=x.useMemo(()=>{const ee=F.filter(Ne=>Ne.memoryUsageMB!==void 0&&Ne.memoryUsageMB>0);return{totalMB:ee.reduce((Ne,ye)=>Ne+(ye.memoryUsageMB||0),0),agentCount:ee.length,agents:ee.map(Ne=>({name:Ne.name,memoryMB:Ne.memoryUsageMB||0,status:Ne.status})).sort((Ne,ye)=>ye.memoryMB-Ne.memoryMB)}},[F]),H=x.useRef([]),L=x.useRef(null);if(x.useEffect(()=>{H.current=d},[d]),x.useEffect(()=>{L.current=h},[h]),x.useEffect(()=>{if(!t)return;const ee=async()=>{try{const Ne=await Pt(Ot("/api/perf"));if(Ne.ok){const ye=await Ne.json();D(ye)}}catch{}};ee();const pe=setInterval(ee,w?3e3:1e4);return()=>clearInterval(pe)},[t,w]),x.useEffect(()=>{if(!t)return;const ee=ru.getUsage();ee&&M===null&&R(ee.usedMB);const pe=setInterval(()=>{var nt,we;Nf.update();const Ne=Nf.getStats();s(Ne.current),r(Le=>[...Le,Ne.current].slice(-60));const ye=ru.getUsage();ye&&c(ye);const Me=window.__tideScene;if(Me){const Le=(nt=Me.getMemoryDiagnostics)==null?void 0:nt.call(Me);Le!=null&&Le.threeJs&&m(Le.threeJs);const ie=Me.renderer;if((we=ie==null?void 0:ie.info)!=null&&we.memory){const de=ie.info.memory.textures||0,Ue=Math.round(de*1);P({count:de,estimatedMB:Ue})}}const qe=document.getElementsByTagName("*"),He=document.getElementsByTagName("canvas"),X=document.getElementsByTagName("img"),ne=document.getElementsByTagName("video");let Te=0;for(let Le=0;Le<Math.min(qe.length,500);Le++){const ie=qe[Le];ie.onclick&&Te++,ie.onmousedown&&Te++,ie.onkeydown&&Te++}Te+=10,S({nodeCount:qe.length,listenerCount:Te,canvasCount:He.length,imageCount:X.length,videoCount:ne.length}),ye&&f(Le=>{const ie=L.current,de={timestamp:Date.now(),heapMB:ye.usedMB,geometries:(ie==null?void 0:ie.geometries)??0,textures:(ie==null?void 0:ie.textures)??0};return[...Le,de].slice(-120)});const We=H.current;if(We.length>=10){const Le=We[0],ie=We[We.length-1],de=(ie.timestamp-Le.timestamp)/1e3/60;de>.1&&y((ie.heapMB-Le.heapMB)/de)}},1e3);return()=>{clearInterval(pe)}},[t,M]),!t)return null;const z=ee=>{const pe=Math.floor(ee/3600),Ne=Math.floor(ee%3600/60),ye=ee%60;return pe>0?`${pe}h ${Ne}m`:Ne>0?`${Ne}m ${ye}s`:`${ye}s`},W=ee=>ee>=55?"#4aff9e":ee>=30?"#ffcc00":"#ff4a4a",V=(ee,pe)=>{const Ne=ee/pe;return Ne<.5?"#4aff9e":Ne<.8?"#ffcc00":"#ff4a4a"},G=ee=>ee===null?"#888":ee<1?"#4aff9e":ee<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}},me=M&&i?i.usedMB-M:0,ce=ee=>({padding:"2px 8px",fontSize:"9px",border:"none",background:N===ee?"rgba(74, 158, 255, 0.4)":"rgba(255, 255, 255, 0.1)",color:N===ee?"#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:()=>A(!w),children:[o.jsx("span",{style:{color:W(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:W(B.current)},children:B.current}),o.jsx("span",{style:{color:"#888"},children:"Min:"}),o.jsx("span",{style:{color:W(B.min)},children:B.min}),o.jsx("span",{style:{color:"#888"},children:"Max:"}),o.jsx("span",{style:{color:W(B.max)},children:B.max}),o.jsx("span",{style:{color:"#888"},children:"Avg:"}),o.jsx("span",{style:{color:W(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((ee,pe)=>o.jsx("div",{style:{width:"3px",height:`${Math.min(100,ee/60*100)}%`,background:W(ee),opacity:.8}},pe))})]})]}),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:me>50?"#ff4a4a":me>20?"#ffcc00":"#4aff9e"},children:[me>0?"+":"",me," 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((ee,pe)=>{const Ne=Math.min(...d.map(He=>He.heapMB)),Me=Math.max(...d.map(He=>He.heapMB))-Ne||1,qe=(ee.heapMB-Ne)/Me*100;return o.jsx("div",{style:{width:"3px",height:`${Math.max(5,qe)}%`,background:ee.heapMB>(M??0)+50?"#ff4a4a":"#4a9eff",opacity:.8},title:`${ee.heapMB}MB`},pe)})})]}),$.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((ee,pe)=>o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"1px"},children:[o.jsx("span",{style:{color:ee.status==="working"?"#4aff9e":"#666",maxWidth:"120px",overflow:"hidden",textOverflow:"ellipsis"},children:ee.name}),o.jsxs("span",{style:{color:"#4a9eff"},children:[ee.memoryMB,"MB"]})]},pe))})]})]}),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((ee,pe)=>{const Ne=Math.max(...d.map(ye=>ye.textures))||1;return o.jsx("div",{style:{width:"3px",height:`${ee.textures/Ne*100}%`,background:"#ff9e4a",opacity:.8},title:`${ee.textures} textures`},pe)})})]}),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:z(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(ee=>o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"1px"},children:[o.jsx("span",{style:{color:ee.status==="working"?"#4aff9e":ee.status==="idle"?"#888":"#ff4a4a",maxWidth:"100px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:ee.name}),o.jsxs("span",{style:{color:"#4a9eff"},children:[ee.memoryMB!=null?`${ee.memoryMB}MB`:"—",ee.pid?` (${ee.pid})`:""]})]},ee.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:ee=>{ee.stopPropagation();const pe=["=== Tide Commander Performance Stats ===",`Timestamp: ${new Date().toISOString()}`,"","--- FPS ---",`Current: ${B.current}`,`Min: ${B.min}`,`Max: ${B.max}`,`Avg: ${B.avg}`];i&&pe.push("","--- Memory ---",`Heap Used: ${i.usedMB} MB`,`Heap Total: ${i.totalMB} MB`,`Heap Limit: ${i.limitMB} MB`,`Baseline: ${M??"N/A"} MB`,`Growth: ${me>0?"+":""}${me} MB`,`Growth Rate: ${b!==null?`${b.toFixed(2)} MB/min`:"N/A"}`),h&&pe.push("","--- Three.js ---",`Geometries: ${h.geometries}`,`Textures: ${h.textures}`,`Programs: ${h.programs}`),$.agentCount>0&&(pe.push("","--- Agent Memory ---",`Total: ${$.totalMB} MB`,`Agents: ${$.agentCount}`),$.agents.slice(0,5).forEach(ye=>{pe.push(` ${ye.name}: ${ye.memoryMB} MB (${ye.status})`)})),j&&pe.push("","--- DOM ---",`DOM Nodes: ${j.nodeCount.toLocaleString()}`,`Canvases: ${j.canvasCount}`,`Images: ${j.imageCount}`,`Videos: ${j.videoCount}`),E&&pe.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&&(pe.push("","--- Server ---",`Uptime: ${z(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&&(pe.push("","--- Agent Processes ---",`Total: ${T.agents.total} (${T.agents.working} working, ${T.agents.idle} idle)`),T.agents.processes.forEach(ye=>{pe.push(` ${ye.name}: ${ye.memoryMB!=null?`${ye.memoryMB}MB`:"N/A"} (${ye.status})${ye.pid?` PID:${ye.pid}`:""}`)})));const Ne=pe.join(`
152
+ `);navigator.clipboard.writeText(Ne).then(()=>{const ye=ee.currentTarget,Me=ye.textContent;ye.textContent="Copied!",setTimeout(()=>{ye.textContent=Me},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:ee=>{ee.stopPropagation(),ru.report();const pe=window.__tideScene;pe!=null&&pe.logMemoryDiagnostics&&pe.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:ee=>{ee.stopPropagation(),Zb.clear(),Nf.reset(),ru.reset(),r([]),f([]);const pe=ru.getUsage();pe&&R(pe.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 jW(){const t=lN(),e=x.useCallback(n=>{U.setViewMode(n)},[]);return[t,e]}const NW=["3d","2d","dashboard"],TW=x.memo(function({className:e=""}){const{t:n}=pt(["common"]),[s,a]=jW(),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}}),NW.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}=pt(["terminal"]),[n,s]=x.useState(!1),[a,r]=x.useState(null),i=Ry(),c=x.useCallback(async y=>{if(y.trim()){console.log("[VoiceAssistant] Transcribed:",y),s(!0),r(null);try{const A=await(await Pt(Ot("/api/voice-assistant/process"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:y})})).json();if(A.success&&A.response)console.log("[VoiceAssistant] Response:",A.response),i.speak(A.response);else{const N=A.error||e("terminal:voiceAssistant.failedToProcess");console.error("[VoiceAssistant] Error:",N),r(N),i.speak(N)}}catch(w){console.error("[VoiceAssistant] Request failed:",w);const A=e("terminal:voiceAssistant.unavailable");r(A),i.speak(A)}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 _W=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}=pt(["terminal","common"]),A=Vr(),N=k=>{k(),n()};return o.jsxs(o.Fragment,{children:[A.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:"📸"})]})]})}),EW=x.memo(function({onOpenToolbox:e,onOpenCommander:n,onOpenSupervisor:s,onOpenControls:a,onOpenSkills:r,onOpenSnapshots:i,isGeneratingReport:c,pip:d}){const{t:f}=pt(["common","terminal"]),h=Vr();return o.jsxs(o.Fragment,{children:[h.experimentalVoiceAssistant&&o.jsx(ZT,{}),o.jsx(cs,{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(cs,{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(cs,{content:f("common:floatingButtons.viewSnapshots"),position:"left",children:o.jsx("button",{className:"snapshots-toggle-btn",onClick:i,children:"📸"})}),o.jsx(cs,{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(cs,{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(cs,{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(cs,{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"})]})})})]})}),MW=je.lazy(()=>wt(()=>import("./SpawnModal-BdCgTKpM.js"),__vite__mapDeps([17,3,1,4])).then(t=>({default:t.SpawnModal}))),DW=je.lazy(()=>wt(()=>import("./BossSpawnModal-Cohl0WaH.js"),__vite__mapDeps([18,3,1,4])).then(t=>({default:t.BossSpawnModal}))),RW=je.lazy(()=>wt(()=>import("./SubordinateAssignmentModal-BoaofULj.js"),__vite__mapDeps([19,3,1,4])).then(t=>({default:t.SubordinateAssignmentModal}))),OW=je.lazy(()=>wt(()=>import("./index-VO6fNr63.js"),__vite__mapDeps([20,3,1,4,21])).then(t=>({default:t.Toolbox}))),LW=je.lazy(()=>wt(()=>import("./index-BiJ_hIit.js"),__vite__mapDeps([22,3,1,4])).then(t=>({default:t.BuildingConfigModal}))),IW=je.lazy(()=>wt(()=>import("./index-BgTRovwT.js"),__vite__mapDeps([23,24,3,1,4])).then(t=>({default:t.CommanderView}))),PW=je.lazy(()=>wt(()=>import("./SupervisorPanel-D8Cp77my.js"),__vite__mapDeps([25,3,1,4])).then(t=>({default:t.SupervisorPanel}))),BW=je.lazy(()=>wt(()=>import("./index-BKRKKMPQ.js").then(t=>t.y),[]).then(t=>({default:t.FileExplorerPanel}))),FW=je.lazy(()=>wt(()=>import("./index-CDAtstMx.js"),__vite__mapDeps([26,3,1,4])).then(t=>({default:t.Spotlight}))),zW=je.lazy(()=>wt(()=>import("./ControlsModal-CAVkg9mM.js"),__vite__mapDeps([27,3,1,4])).then(t=>({default:t.ControlsModal}))),$W=je.lazy(()=>wt(()=>import("./SkillsPanel-CO-Zt0Tq.js"),__vite__mapDeps([28,3,1,4])).then(t=>({default:t.SkillsPanel}))),UW=je.lazy(()=>wt(()=>Promise.resolve().then(()=>C2),void 0).then(t=>({default:t.AgentEditModal}))),HW=je.lazy(()=>wt(()=>import("./SnapshotManager-D4Uzw6Tp.js"),__vite__mapDeps([29,3,1,4])).then(t=>({default:t.SnapshotManager}))),WW=je.lazy(()=>wt(()=>import("./RestoreArchivedAreaModal-BajWqtWn.js"),__vite__mapDeps([30,3,1,4])).then(t=>({default:t.RestoreArchivedAreaModal}))),qW=je.lazy(()=>wt(()=>import("./IntegrationsPanel-BPKoNwZm.js"),__vite__mapDeps([31,3,1,4])).then(t=>({default:t.IntegrationsPanel}))),VW=je.lazy(()=>wt(()=>import("./MonitoringModal-DzqEa0fQ.js"),__vite__mapDeps([32,3,1,4])).then(t=>({default:t.MonitoringModal}))),YW=je.lazy(()=>wt(()=>import("./WorkflowEditorPanel-EtzhBZWw.js"),__vite__mapDeps([33,3,1,4])).then(t=>({default:t.WorkflowEditorPanel}))),GW=je.lazy(()=>wt(()=>import("./TriggerManagerPanel-CFf3Tud5.js"),__vite__mapDeps([34,3,1,4])).then(t=>({default:t.TriggerManagerPanel})));function KW({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:A,snapshotsModal:N,restoreArchivedModal:k,explorerModal:j,contextMenu:S,spawnPosition:T,spawnAreaId:D,explorerFolderPath:E,contextMenuActions:P,buildingInitialPosition:O,sceneConfig:_,onConfigChange:M,onToolChange:R,onOpenAreaExplorer:F,onDeleteSelectedAgents:$,pendingBuildingDelete:H,onCancelBuildingDelete:L,onConfirmBuildingDelete:z,showBackNavModal:W,onCloseBackNavModal:V,onLeave:G,onOpenPM2LogsModal:B,onOpenBossLogsModal:K,onOpenDatabasePanel:se,onSyncScene:q}){const me=Ls(),ce=Array.from(me.snapshots.values()),ee=me.snapshotsLoading;me.currentSnapshot,x.useEffect(()=>{N.isOpen&&U.fetchSnapshots()},[N.isOpen]);const pe=H==="selected",Ne=H&&H!=="selected"?me.buildings.get(H):null,ye=me.selectedBuildingIds.size;return o.jsxs(x.Suspense,{fallback:null,children:[o.jsx(OW,{config:_,onConfigChange:M,onToolChange:R,isOpen:s.isOpen,onClose:s.close,onOpenBuildingModal:Me=>w.open(Me||null),onOpenAreaExplorer:F,onOpenIntegrationsModal:Me=>h.open(Me),onOpenMonitoringModal:()=>m.open(),onOpenWorkflowEditor:()=>b.open(),onOpenTriggerManager:()=>y.open()}),o.jsx(LW,{isOpen:w.isOpen,onClose:w.close,buildingId:w.data,initialPosition:O||void 0}),o.jsx(MW,{isOpen:t.isOpen,onClose:t.close,onSpawnStart:()=>{},onSpawnEnd:()=>{},spawnPosition:T,spawnAreaId:D}),o.jsx(DW,{isOpen:e.isOpen,onClose:e.close,onSpawnStart:()=>{},onSpawnEnd:()=>{},spawnPosition:T}),o.jsx(RW,{isOpen:n.isOpen,bossId:n.data||"",onClose:n.close}),A.isOpen&&A.data&&(()=>{const Me=me.agents.get(A.data);return Me?o.jsx(UW,{agent:Me,isOpen:A.isOpen,onClose:A.close}):null})(),r.isOpen&&o.jsx("div",{className:"modal-overlay visible",onClick:r.close,onKeyDown:Me=>{Me.key==="Escape"&&r.close(),Me.key==="Enter"&&$()},children:o.jsxs("div",{className:"modal confirm-modal",onClick:Me=>Me.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 ",me.selectedAgentIds.size," selected agent",me.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"})]})]})}),(Ne||pe)&&o.jsx("div",{className:"modal-overlay visible",onClick:L,onKeyDown:Me=>{Me.key==="Escape"&&L(),Me.key==="Enter"&&z()},children:o.jsxs("div",{className:"modal confirm-modal",onClick:Me=>Me.stopPropagation(),children:[o.jsxs("div",{className:"modal-header",children:["Delete Building",pe&&ye>1?"s":""]}),o.jsxs("div",{className:"modal-body confirm-modal-body",children:[pe?o.jsxs("p",{children:["Delete ",ye," selected building",ye>1?"s":"","?"]}):o.jsxs("p",{children:["Delete ",o.jsx("strong",{children:Ne==null?void 0:Ne.name}),"?"]}),o.jsxs("p",{className:"confirm-modal-note",children:["This will permanently remove the building",pe&&ye>1?"s":""," and ",pe&&ye>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:z,autoFocus:!0,children:"Delete"})]})]})}),W&&o.jsx("div",{className:"modal-overlay navigation-confirm-overlay visible",onClick:V,onKeyDown:Me=>{Me.key==="Escape"&&V()},children:o.jsxs("div",{className:"modal confirm-modal navigation-confirm-modal",onClick:Me=>Me.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:wu,children:o.jsx(IW,{isOpen:a.isOpen,onClose:a.close})}),o.jsx(PW,{isOpen:i.isOpen,onClose:i.close}),o.jsx(BW,{isOpen:j.isOpen||E!==null||me.explorerAreaId!==null,areaId:j.id||me.explorerAreaId||null,folderPath:E,onChangeArea:Me=>j.open(Me),onClose:()=>{j.close(),U.closeFileExplorer()}}),o.jsx(FW,{isOpen:c.isOpen,onClose:c.close,onOpenSpawnModal:()=>t.open(),onOpenCommanderView:()=>a.open(),onOpenToolbox:()=>s.open(),onOpenSupervisor:()=>i.open(),onOpenFileExplorer:Me=>j.open(Me),onOpenPM2LogsModal:B,onOpenBossLogsModal:K,onOpenDatabasePanel:se,onOpenMonitoringModal:()=>m.open()}),o.jsx(zW,{isOpen:d.isOpen,onClose:d.close}),o.jsx($W,{isOpen:f.isOpen,onClose:f.close}),o.jsx(qW,{isOpen:h.isOpen,onClose:h.close,initialTab:h.data}),o.jsx(VW,{isOpen:m.isOpen,onClose:m.close}),o.jsx(YW,{isOpen:b.isOpen,onClose:b.close}),o.jsx(GW,{isOpen:y.isOpen,onClose:y.close}),o.jsx(WW,{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:Me=>Me.stopPropagation(),children:o.jsx(HW,{snapshots:ce,isLoading:ee,onViewSnapshot:async Me=>{await U.loadSnapshot(Me),me.selectedAgentIds.clear(),U.setTerminalOpen(!0),N.close()},onDeleteSnapshot:async Me=>{await U.deleteSnapshot(Me),await U.fetchSnapshots()},onRestoreSnapshot:async Me=>{await U.restoreFiles(Me)},onExportSnapshot:async Me=>{await U.loadSnapshot(Me),N.close()},onClose:N.close})})}),o.jsx(Lo,{isOpen:S.isOpen,position:S.screenPosition,worldPosition:S.worldPosition,actions:P,onClose:S.close})]})}function QW({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:nc.createPortal(n,t.pipContainer)}function Iy(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 Py(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 By(t){const e=Do[t.class];return(e==null?void 0:e.icon)||"🤖"}function Lb({agent:t,onClick:e}){const n=Py(t.status),s=Iy(t.status),a=By(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 vu(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 XW({agent:t,onBack:e}){const n=By(t),s=Py(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:Iy(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:vu(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:[vu(a.totalTokens)," / ",vu(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]}: ${vu(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:[vu(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 JW({agentId:t,onBack:e}){const n=Qj(t),s=Xj(t),a=iN(),r=oN(),i=Wx(),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),A=qj({selectedAgentId:t,hasSessionId:w,reconnectCount:a,historyRefreshTrigger:r,lastPrompts:i,outputScrollRef:c}),N=ET({outputs:s,viewMode:y}),k=x.useMemo(()=>{const{history:$}=A,H=new Map;for(const z of $)z.type==="tool_result"&&z.toolUseId&&H.set(z.toolUseId,z.content);return(z=>z.map(W=>{if(W.type==="tool_use"&&W.toolName==="Bash"&&W.toolUseId){const V=H.get(W.toolUseId);let G;try{G=(W.toolInput||(W.content?JSON.parse(W.content):{})).command}catch{}return{...W,_bashOutput:V,_bashCommand:G}}return W}))($.filter(z=>z.type==="user"||z.type==="assistant"||z.type==="tool_use"))},[A.history]),[j,S]=x.useState({top:!1,bottom:!0}),T=x.useCallback(()=>{if(!c.current)return;const{scrollTop:$,scrollHeight:H,clientHeight:L}=c.current;S({top:$>20,bottom:$<H-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"})},[]),P=x.useCallback(()=>{const $=f.trim();!$||!n||(U.sendCommand(t,$),h(""),setTimeout(()=>{var H;return(H=d.current)==null?void 0:H.focus()},50))},[f,t,n]),O=x.useCallback($=>{h($.target.value)},[]),_=x.useCallback($=>{$.key==="Enter"&&!$.shiftKey&&($.preventDefault(),P())},[P]);x.useEffect(()=>{const $=setTimeout(()=>{var H;return(H=d.current)==null?void 0:H.focus()},100);return()=>clearTimeout($)},[t]);const M=x.useCallback(($,H)=>{const L=sh($,n==null?void 0:n.cwd),z=L.line?{...H||{},targetLine:L.line}:H;U.setFileViewerPath(L.path,z,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=By(n),F=Py(n.status);return m?o.jsx(XW,{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:F},children:Iy(n.status)})]}),o.jsx("div",{className:"pip-context-section",children:o.jsx(vN,{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:[!A.loadingHistory&&A.hasMore&&o.jsx("div",{className:"guake-load-more pip-load-more",children:A.loadingMore?o.jsx("span",{children:"Loading older messages..."}):o.jsxs("button",{onClick:A.loadMoreHistory,children:["Load more (",A.totalCount-A.history.length," older)"]})}),A.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(($,H)=>o.jsx(XT,{message:$,agentId:t,simpleView:!0,onFileClick:M},`h-${H}`)),N.map(($,H)=>o.jsx(Oy,{output:$,agentId:t,onFileClick:M},`o-${H}`)),!A.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:P,disabled:!f.trim(),title:"Send message",children:"➤"})]})]})}function ZW({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(Lb,{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(Lb,{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(Lb,{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 eq(){const[t,e]=x.useState(null),n=a=>{e(a)},s=()=>{e(null)};return t?o.jsx(JW,{agentId:t,onBack:s}):o.jsx(ZW,{onSelectAgent:n})}function tq(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 nq(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 sq=4e3;function aq(){const t=Zj(),[e,n]=x.useState(!1),[s,a]=x.useState(!1),[r,i]=x.useState(!0),[c,d]=x.useState(!1),[f,h]=x.useState(()=>Lx()),[m,b]=x.useState(!1),[y,w]=x.useState(null),[A,N]=x.useState(null),k=x.useRef(!0),j=x.useRef(!1),S=x.useCallback((O=7e3)=>U.getState().isConnected?Promise.resolve(!0):new Promise(_=>{let M=!1;const R=H=>{M||(M=!0,clearTimeout($),F(),_(H))},F=U.subscribe(()=>{U.getState().isConnected&&R(!0)}),$=setTimeout(()=>R(!1),O)}),[]);x.useEffect(()=>{const O=setTimeout(()=>i(!1),3e3);return()=>clearTimeout(O)},[]),x.useEffect(()=>{if(t){j.current=!0,d(!1);return}if(j.current){i(!0),d(!0);const O=setTimeout(()=>{i(!1),d(!1)},1e4);return()=>clearTimeout(O)}},[t]),x.useEffect(()=>()=>{k.current=!1},[]),x.useEffect(()=>YD(O=>{h(O)}),[]);const T=x.useCallback(()=>{navigator.clipboard.writeText("bunx tide-commander").then(()=>{a(!0),setTimeout(()=>a(!1),2e3)}).catch(()=>{})},[]),D=x.useCallback(async()=>{if(m)return;const O=Date.now(),_=()=>sq-(Date.now()-O);w(null),N("Validating URL");const M=f.trim()||"http://localhost:6200",R=tq(M);if(!R.ok){N(null),w(R.error||"Invalid backend URL");return}b(!0),N("Checking host reachability");const F=_();if(F<=0){b(!1),N(null),w("Connection timeout after 4 seconds");return}const $=await nq(R.normalizedUrl,F);if(!$.ok){if(!k.current)return;b(!1),N(null),_()<=0?w("Connection timeout after 4 seconds"):w($.error||"Failed to reach host");return}VD(R.normalizedUrl),N("Connecting to server"),$R();const H=_();if(H<=0){b(!1),N(null),w("Connection timeout after 4 seconds");return}const L=await S(H);if(k.current){if(!L){b(!1),N(null),_()<=0?w("Connection timeout after 4 seconds"):w("Could not establish WebSocket connection. Verify host and auth token, then retry");return}b(!1),N("Connected"),w(null)}},[f,m,S]),E=x.useCallback(O=>{O.key==="Enter"&&!m&&D()},[D,m]),P=x.useCallback(()=>{n(!0)},[]);return t||e?null:r&&c?o.jsxs("div",{className:"reconnecting-toast",children:[o.jsx("span",{className:"reconnecting-spinner"}),"Reconnecting..."]}):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:T,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:f,disabled:m,onChange:O=>{const _=O.target.value;h(_),y&&w(null)},onKeyDown:E})}),o.jsx("span",{className:"config-hint",children:"Leave empty for auto-detect"}),A&&!y&&o.jsx("div",{className:"not-connected-status","aria-live":"polite",children:A}),y&&o.jsx("div",{className:"not-connected-error","aria-live":"assertive",children:y})]}),o.jsxs("div",{className:"not-connected-actions",children:[o.jsx("button",{className:"not-connected-btn not-connected-btn-retry",onClick:()=>{D()},disabled:m,children:m?"Connecting...":"↻ Connect"}),o.jsx("button",{className:"not-connected-btn not-connected-btn-explore",onClick:P,children:"Explore"})]})]})})}const ej="tide-onboarding-dismissed";function rq({onCreateAgent:t}){const{t:e}=pt("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":Fi()}}async function iq(t){const e=await fetch(`${Ma()}/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 oq(){const t=await fetch(`${Ma()}/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 lq(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:()=>{iq(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 cq=je.lazy(()=>wt(()=>import("./index-2YWd58Wh.js"),__vite__mapDeps([35,3,1,4,36])).then(t=>({default:t.DatabasePanel}))),uq=je.lazy(()=>wt(()=>import("./PM2LogsModal-DZXPRV5-.js"),__vite__mapDeps([37,38,3,1,4])).then(t=>({default:t.PM2LogsModal}))),dq=je.lazy(()=>wt(()=>import("./DockerLogsModal-BXv9Hzg-.js"),__vite__mapDeps([39,38,3,1,4])).then(t=>({default:t.DockerLogsModal}))),fq=je.lazy(()=>wt(()=>import("./BossLogsModal-CehuxNwV.js"),__vite__mapDeps([40,38,3,1,4])).then(t=>({default:t.BossLogsModal}))),pq=je.lazy(()=>wt(()=>import("./Scene2DCanvas-DWDmyh_y.js"),__vite__mapDeps([41,3,1,4,42])).then(t=>({default:t.Scene2DCanvas}))),hq=je.lazy(()=>wt(()=>import("./index-DByGRjfY.js"),__vite__mapDeps([43,3,1,4,44])).then(t=>({default:t.DashboardView}))),mq=je.lazy(()=>wt(()=>import("./IframeModal-DlS7y7PK.js"),__vite__mapDeps([45,3,1,4,46])).then(t=>({default:t.IframeModal}))),gq=je.lazy(()=>wt(()=>import("./SaveSnapshotModal-LqaLezB-.js"),__vite__mapDeps([47,3,1,4])).then(t=>({default:t.SaveSnapshotModal})));function bq(){const{t}=pt(["common","notifications"]),e=x.useRef(null),n=x.useRef(null),s=fs(),a=fs(),r=fs(),i=fs(),c=fs(),d=fs(),f=fs(),h=fs(),m=fs(),b=fs(),y=fs(),w=fs(),A=fs(),N=fs(),k=fs(),j=fs(),S=fs(),T=fs(),D=fs(),E=GD(),P=eL(),O=KD(),_=iR(),[M,R]=x.useState(null),F=QR(),[$,H]=x.useState(!1),[L,z]=x.useState(null),[W,V]=x.useState(null),[G,B]=x.useState(null),[K,se]=x.useState(null),[q,me]=x.useState(null),[ce,ee]=x.useState(null),[pe,Ne]=x.useState(null),[ye,Me]=x.useState(null),[qe,He]=x.useState(null),[X,ne]=x.useState(null),Te=x.useCallback(Ae=>{ne(Ae),Ae&&localStorage.setItem("tide-commander-last-database-building",Ae)},[]),We=x.useCallback(()=>Te(null),[Te]),{handleMouseDown:nt,handleClick:we}=_a(We),Le=x.useCallback(()=>He(null),[]),{handleMouseDown:ie,handleClick:de}=_a(Le),Ue=x.useRef(ce);Ue.current=ce;const Ze=x.useCallback(Ae=>{ee(Ae)},[]),lt=x.useCallback(()=>Ue.current,[]),fe=x.useRef(null),[J,ae]=x.useState(Uj),[Se,Z]=x.useState(0),[he,De]=x.useState(!1),[ze,be]=x.useState(()=>localStorage.getItem("tide-commander-sidebar-collapsed")==="true"),[Pe,te]=x.useState(!1),[ge,ve]=x.useState(!1),Fe=nN(),Ke=lN(),st=Vx(),xt=Yx(),ht=tN(),{showToast:ot}=dN(),{showAgentNotification:ft}=NL(),{showBackNavModal:ut,setShowBackNavModal:ln,handleLeave:Kt}=hO();oO({showToast:ot,showAgentNotification:ft});const[Ce,Be]=x.useState(!1);x.useEffect(()=>{const Ae=Je=>{var Vt;((Vt=Je.detail)==null?void 0:Vt.mode)==="3d"&&Be(!0)};return window.addEventListener("tide:viewmode-switch-pressed",Ae),()=>{window.removeEventListener("tide:viewmode-switch-pressed",Ae)}},[]),x.useEffect(()=>{Ke==="3d"&&Be(!0)},[Ke]);const Ye=iO({canvasRef:e,selectionBoxRef:n,viewMode:Ke,sceneMountKey:Se,showToast:ot,showAgentNotification:ft,toolboxModal:i,contextMenu:O,setHoveredAgentPopup:me,setBuildingPopup:Ze,getBuildingPopup:lt,openBuildingModal:Ae=>k.open(Ae),openPM2LogsModal:Ae=>Ne(Ae),openBossLogsModal:Ae=>Me(Ae),openDatabasePanel:Ae=>Te(Ae),onSceneLoadingChange:Be}),et=Kj(),Et=ur(),$t=qx(),Dt=Hx(),qt=GO(),cn=YO(),yt=VO(),rt=Vr(),ct=QO(),Ft=dL(),_n=fL(),En=x.useMemo(()=>Array.from(Dt),[Dt]),bn=x.useRef(!1);Dj("AppContent"),lO(Ye),cO(Ye),uO(Ye),bO(),dO(Ye,cn),fO(Ye,rt.powerSaving),x.useEffect(()=>{var Ae;document.title=((Ae=rt.tabTitle)==null?void 0:Ae.trim())||"Tide Commander"},[rt.tabTitle]),x.useEffect(()=>{var Fn,Cs;if(bn.current||typeof window>"u")return;const Ae=new URLSearchParams(window.location.search),Je=(Fn=Ae.get("agentId"))==null?void 0:Fn.trim(),jt=(Cs=Ae.get("agentName"))==null?void 0:Cs.trim();if(!Je&&!jt||et===0)return;const Vt=U.getState().agents,gt=Ae.get("openTerminal"),Lt=gt?["1","true","yes"].includes(gt.toLowerCase()):!0;let kt=Je?Vt.get(Je):void 0;if(!kt&&jt){const qa=jt.toLowerCase();kt=Array.from(Vt.values()).find(Va=>Va.name.toLowerCase()===qa)}if(!kt){console.warn("[DeepLink] No matching agent found for query params",{rawAgentId:Je,rawAgentName:jt}),bn.current=!0;return}U.selectAgent(kt.id),Lt&&U.setTerminalOpen(!0),Ae.delete("agentId"),Ae.delete("agentName"),Ae.delete("openTerminal");const xn=Ae.toString(),bs=`${window.location.pathname}${xn?`?${xn}`:""}${window.location.hash}`;window.history.replaceState({},document.title,bs),bn.current=!0},[et]),pO({sceneRef:Ye,spawnModal:s,commanderModal:c,explorerModal:E,spotlightModal:h,deleteConfirmModal:d,onRequestBuildingDelete:()=>se("selected"),onOpenDatabasePanel:Te,onCloseDatabasePanel:We,databasePanelOpen:X!==null}),Jt("spawn-modal",s.isOpen,s.close),Jt("boss-spawn-modal",a.isOpen,a.close),Jt("subordinate-modal",r.isOpen,r.close),Jt("toolbox-modal",i.isOpen,i.close),Jt("commander-modal",c.isOpen,c.close),Jt("delete-confirm-modal",d.isOpen,d.close),Jt("supervisor-modal",f.isOpen,f.close),Jt("spotlight-modal",h.isOpen,h.close),Jt("controls-modal",m.isOpen,m.close),Jt("skills-modal",b.isOpen,b.close),Jt("integrations-modal",y.isOpen,y.close),Jt("monitoring-modal",w.isOpen,w.close),Jt("workflow-editor-modal",A.isOpen,A.close),Jt("trigger-manager-modal",N.isOpen,N.close),Jt("building-modal",k.isOpen,k.close),Jt("agent-edit-modal",j.isOpen,j.close),Jt("snapshots-modal",S.isOpen,S.close),Jt("save-snapshot-modal",T.isOpen,T.close),Jt("explorer-modal",E.isOpen||P!==null,()=>{E.close(),U.closeFileExplorer()}),Jt("context-menu",O.isOpen,O.close),Jt("mobile-sidebar",he,()=>De(!1)),Jt("mobile-fab-menu",ge,()=>ve(!1)),Jt("file-viewer",st!==null,()=>U.clearFileViewerPath()),Jt("context-modal",xt!==null,()=>U.closeContextModal()),Jt("terminal",ht,()=>U.setTerminalOpen(!1)),Jt("pm2-logs-modal",pe!==null,()=>Ne(null)),Jt("boss-logs-modal",ye!==null,()=>Me(null)),Jt("database-panel",X!==null,We),Jt("terminal-modal",qe!==null,Le);const Is=x.useRef(ht),_s=x.useRef(b),ts=x.useRef(m);_s.current=b,ts.current=m,x.useEffect(()=>{Is.current&&!ht&&(_s.current.close(),ts.current.close()),Is.current=ht},[ht]),x.useEffect(()=>{},[]),x.useEffect(()=>{if(Fe!=="3d"||Ke!=="3d")return;const Ae=setTimeout(()=>window.dispatchEvent(new Event("resize")),80);return()=>clearTimeout(Ae)},[Fe,Ke]);const Ks=x.useCallback(Ae=>{var Je,jt,Vt,gt,Lt,kt,xn,bs,Fn,Cs;ae(Ae),aO(Ae),(Je=Ye.current)==null||Je.setCharacterScale(Ae.characterScale),(jt=Ye.current)==null||jt.setScale3D(Ae.scale3d),(Vt=Ye.current)==null||Vt.setTimeMode(Ae.timeMode),(gt=Ye.current)==null||gt.setTerrainConfig(Ae.terrain),(Lt=Ye.current)==null||Lt.setFloorStyle(Ae.terrain.floorStyle),(kt=Ye.current)==null||kt.setGridVisible(Ae.gridVisible),(xn=Ye.current)==null||xn.setAgentModelStyle(Ae.modelStyle),(bs=Ye.current)==null||bs.setIdleAnimation(Ae.animations.idleAnimation),(Fn=Ye.current)==null||Fn.setWorkingAnimation(Ae.animations.workingAnimation),(Cs=Ye.current)==null||Cs.setFpsLimit(Ae.fpsLimit)},[Ye]),Bn=x.useCallback(Ae=>{var Je;if((Je=Ye.current)==null||Je.setDrawingTool(Ae),typeof window<"u"&&window.__tideScene2D_setDrawingTool&&window.__tideScene2D_setDrawingTool(Ae),Ae==="rectangle"||Ae==="circle"){const jt=t(Ae==="rectangle"?"notifications:drawing.rectangleTool":"notifications:drawing.circleTool");ot("info",jt,t("notifications:drawing.clickAndDrag"),3e3)}},[Ye,ot]),us=x.useCallback(Ae=>{var Je;(Je=Ye.current)==null||Je.focusAgent(Ae)},[Ye]),Un=x.useCallback(Ae=>{U.killAgent(Ae)},[]),Qs=x.useCallback(Ae=>{var Je;(Je=Ye.current)==null||Je.callSubordinates(Ae)},[Ye]),On=x.useCallback(Ae=>{E.open(Ae)},[E]),Wa=x.useCallback(()=>{k.open(null)},[k]),zo=x.useCallback(()=>{var Ae;(Ae=Ye.current)==null||Ae.setDrawingTool("rectangle"),typeof window<"u"&&window.__tideScene2D_setDrawingTool&&window.__tideScene2D_setDrawingTool("rectangle"),ot("info",t("notifications:drawing.rectangleTool"),t("notifications:drawing.clickAndDrag"),3e3)},[Ye,ot]),pa=x.useCallback(Ae=>{R(Ae)},[]),ha=x.useCallback(()=>{R(null)},[]),ic=x.useCallback(()=>{const Ae=Array.from(U.getState().selectedAgentIds);Ae.forEach(Je=>{var jt;U.removeAgentFromServer(Je),(jt=Ye.current)==null||jt.removeAgent(Je)}),d.close(),ot("info",t("notifications:toast.agentsRemoved"),t("notifications:toast.agentsRemovedMsg",{count:Ae.length}))},[ot,d,Ye,t]),Qr=x.useCallback(()=>{var Ae,Je;if(K==="selected"){const jt=qt.size;U.deleteSelectedBuildings(),(Ae=Ye.current)==null||Ae.syncBuildings(),ot("info",t("notifications:toast.buildingsDeleted"),t("notifications:toast.buildingsDeletedMsg",{count:jt}))}else if(K){const jt=$t.get(K);U.deleteBuilding(K),(Je=Ye.current)==null||Je.syncBuildings(),ot("info",t("notifications:toast.buildingDeleted"),t("notifications:toast.buildingDeletedMsg",{name:(jt==null?void 0:jt.name)||"Building"}))}se(null)},[K,$t,qt.size,ot,Ye,t]),$i=x.useMemo(()=>lq(O.worldPosition,O.target,U.getState().agents,Et,$t,{showToast:ot,openSpawnModal:()=>s.open(),openBossSpawnModal:()=>a.open(),openToolboxModal:()=>i.open(),openCommanderModal:()=>c.open(),openExplorerModal:Ae=>E.open(Ae),openBuildingModal:Ae=>k.open(Ae),openAgentEditModal:Ae=>j.open(Ae),requestBuildingDelete:Ae=>se(Ae),setSpawnPosition:z,openRestoreArchivedModal:Ae=>D.open(Ae),sceneRef:Ye}),[O.worldPosition,O.target,Et,$t,s,a,k,i,c,E,j,D,ot,Ye]);x.useEffect(()=>{!s.isOpen&&!a.isOpen&&(z(null),B(null))},[s.isOpen,a.isOpen]),x.useEffect(()=>{const Ae=Lt=>{const kt=Lt.detail;B((kt==null?void 0:kt.areaId)||null),z((kt==null?void 0:kt.position)||null),s.open()},Je=Lt=>{var bs,Fn;const kt=Lt.detail;if(!(kt!=null&&kt.buildingId))return;const xn=U.getState().buildings.get(kt.buildingId);xn&&(xn.type==="server"&&((bs=xn.pm2)!=null&&bs.enabled)?Ne(kt.buildingId):xn.type==="boss"?Me(kt.buildingId):xn.type==="database"?Te(kt.buildingId):xn.type==="folder"&&xn.folderPath?U.openFileExplorer(xn.folderPath):xn.type==="terminal"&&((Fn=xn.terminalStatus)!=null&&Fn.url)?He(kt.buildingId):k.open(kt.buildingId))},jt=Lt=>{const kt=Lt.detail;kt!=null&&kt.buildingId&&k.open(kt.buildingId)},Vt=Lt=>{const kt=Lt.detail;V((kt==null?void 0:kt.position)||null),k.open(null)},gt=Lt=>{const kt=Lt.detail;kt!=null&&kt.buildingId?He(kt.buildingId):kt!=null&&kt.url&&R(kt.url)};return window.addEventListener("tide:open-spawn-modal",Ae),window.addEventListener("tide:building-action",Je),window.addEventListener("tide:building-edit",jt),window.addEventListener("tide:building-create",Vt),window.addEventListener("tide:open-iframe-modal",gt),()=>{window.removeEventListener("tide:open-spawn-modal",Ae),window.removeEventListener("tide:building-action",Je),window.removeEventListener("tide:building-edit",jt),window.removeEventListener("tide:building-create",Vt),window.removeEventListener("tide:open-iframe-modal",gt)}},[s,k]);const Xs=yt==="rectangle"||yt==="circle",Xr=x.useCallback(()=>{var Ae;(Ae=Ye.current)==null||Ae.setDrawingTool(null),typeof window<"u"&&window.__tideScene2D_setDrawingTool&&window.__tideScene2D_setDrawingTool(null)},[Ye]),Da=x.useCallback(()=>ve(Ae=>!Ae),[]),ns=x.useCallback(()=>U.setMobileView("terminal"),[]),ss=x.useCallback(()=>De(!0),[]),gs=En.length===1&&U.getOutputs(En[0]).length>0;return o.jsxs("div",{className:`app ${ht?"terminal-open":""} ${Xs?"drawing-mode":""} ${ze?"sidebar-collapsed":""} mobile-view-${Fe} view-mode-${Ke}`,children:[o.jsx(aq,{}),o.jsx(rq,{onCreateAgent:s.open}),o.jsx(AW,{visible:rt.showFPS,position:"bottom-right"}),o.jsxs("div",{className:"app-top-bar",children:[o.jsx(TW,{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:()=>{H(!0),oq().then(Ae=>{t_(Ae,Ye),ot("success","Organized",`Arranged ${Ae.organized.length} agent${Ae.organized.length!==1?"s":""}`)}).catch(Ae=>{console.error("organize all error:",Ae),ot("error","Organize Failed",Ae.message||"Failed to organize")}).finally(()=>H(!1))},children:[$?"⏳":"✨"," Organize"]})]}),o.jsxs("main",{className:"main-content",children:[o.jsxs("div",{className:"battlefield-container",children:[F&&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(je.Suspense,{fallback:null,children:Ke==="dashboard"?o.jsx(hq,{onSelectAgent:Ae=>U.selectAgent(Ae),onFocusAgent:Ae=>{U.setViewMode("3d"),us(Ae)},onKillAgent:Un,onSelectBuilding:Ae=>U.selectBuilding(Ae),onOpenTerminal:Ae=>{U.selectAgent(Ae),U.setTerminalOpen(!0)},onFocusZone:Ae=>{U.setViewMode("3d");const Je=U.getState().areas.get(Ae);Je&&Je.assignedAgentIds.length>0&&us(Je.assignedAgentIds[0])}}):Ke==="2d"?o.jsx(pq,{onAgentClick:(Ae,Je)=>{Je?U.addToSelection(Ae):U.selectAgent(Ae)},onAgentDoubleClick:Ae=>{if(window.innerWidth<=768){U.openTerminalOnMobile(Ae);return}U.selectAgent(Ae),U.setTerminalOpen(!0)},onBuildingClick:(Ae,Je)=>{U.selectBuilding(Ae);const jt=U.getState().buildings.get(Ae);(jt==null?void 0:jt.type)==="folder"&&jt.folderPath?U.openFileExplorer(jt.folderPath):((jt==null?void 0:jt.type)==="server"||(jt==null?void 0:jt.type)==="boss"||(jt==null?void 0:jt.type)==="database")&&(fe.current&&clearTimeout(fe.current),fe.current=setTimeout(()=>{Ze({buildingId:Ae,screenPos:Je,fromClick:!0}),fe.current=null},150))},onBuildingDoubleClick:Ae=>{var jt;fe.current&&(clearTimeout(fe.current),fe.current=null),Ze(null);const Je=U.getState().buildings.get(Ae);(Je==null?void 0:Je.type)==="server"&&((jt=Je.pm2)!=null&&jt.enabled)?Ne(Ae):(Je==null?void 0:Je.type)==="boss"?Me(Ae):(Je==null?void 0:Je.type)==="database"?Te(Ae):(Je==null?void 0:Je.type)==="folder"&&Je.folderPath?U.openFileExplorer(Je.folderPath):k.open(Ae)},onGroundClick:()=>{U.selectAgent(null),U.selectBuilding(null)},onAreaDoubleClick:Ae=>{U.selectArea(Ae),i.open()},onContextMenu:(Ae,Je,jt)=>{const Vt=jt?{type:jt.type,id:jt.id}:{type:"ground"};O.open(Ae,Je,Vt)},onMoveCommand:(Ae,Je)=>{const Vt=Ae.length,gt=[];if(Vt===1)gt.push({x:Je.x,y:0,z:Je.z});else if(Vt<=6){const Lt=1.2*Math.max(1,Vt/3);for(let kt=0;kt<Vt;kt++){const xn=kt/Vt*Math.PI*2-Math.PI/2;gt.push({x:Je.x+Math.cos(xn)*Lt,y:0,z:Je.z+Math.sin(xn)*Lt})}}else{const Lt=Math.ceil(Math.sqrt(Vt)),kt=Math.ceil(Vt/Lt),xn=(Lt-1)*1.2/2,bs=(kt-1)*1.2/2;for(let Fn=0;Fn<Vt;Fn++){const Cs=Fn%Lt,qa=Math.floor(Fn/Lt);gt.push({x:Je.x+Cs*1.2-xn,y:0,z:Je.z+qa*1.2-bs})}}Ae.forEach((Lt,kt)=>{U.moveAgent(Lt,gt[kt])})},onBuildingDragMove:(Ae,Je)=>{var Vt;const jt=U.getState().buildings.get(Ae);jt&&(U.getState().buildings.set(Ae,{...jt,position:{x:Je.x,z:Je.z}}),(Vt=window.__tideScene2D)==null||Vt.syncBuildings())},onBuildingDragEnd:(Ae,Je)=>{U.updateBuildingPosition(Ae,Je)},scale2d:J.scale2d,showTaskLabels:J.show2DTaskLabels,showGrid:J.gridVisible,fpsLimit:J.fpsLimit}):o.jsxs(je.Fragment,{children:[o.jsx("canvas",{ref:e,id:"battlefield",tabIndex:0}),o.jsx("div",{ref:n,id:"selection-box"})]},Se)}),Ce&&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(_W,{isOpen:ge,onToggle:Da,onShowTerminal:ns,onOpenSidebar:ss,onOpenToolbox:i.open,onOpenCommander:c.open,onOpenSupervisor:f.open,onOpenControls:m.open,onOpenSkills:b.open,onOpenSnapshots:S.open,onTakeSnapshot:T.open,canTakeSnapshot:gs,mobileView:Fe}),he&&o.jsx("div",{className:"sidebar-overlay",onClick:()=>De(!1)}),!1,o.jsx("button",{className:`sidebar-collapse-edge-btn ${ze?"is-collapsed":""} ${Pe?"can-pin":""}`,onClick:()=>{if(window.innerWidth<=768)De(!he);else{const Je=!ze;be(Je),localStorage.setItem("tide-commander-sidebar-collapsed",String(Je))}},title:ze?"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:ze?"15 18 9 12 15 6":"9 18 15 12 9 6"})})}),o.jsxs("aside",{className:`sidebar ${he?"sidebar-open":""} ${ze?"sidebar-collapsed":""}`,children:[o.jsx("button",{className:"sidebar-close-btn show-on-mobile",onClick:()=>De(!1),title:"Close sidebar",children:"✕"}),En.length>0?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"sidebar-section unit-section",children:o.jsx(x.Profiler,{id:"UnitPanel",onRender:wu,children:o.jsx(ES,{onFocusAgent:us,onKillAgent:Un,onCallSubordinates:Qs,onOpenAreaExplorer:On})})}),o.jsx("div",{className:"sidebar-section tool-history-section",children:o.jsx(x.Profiler,{id:"ToolHistory",onRender:wu,children:o.jsx(E4,{agentIds:En})})})]}):o.jsx("div",{className:"sidebar-section unit-section",children:o.jsx(x.Profiler,{id:"UnitPanel",onRender:wu,children:o.jsx(ES,{onFocusAgent:us,onKillAgent:Un,onCallSubordinates:Qs,onOpenAreaExplorer:On})})})]}),o.jsx(x.Profiler,{id:"GuakeOutputPanel",onRender:wu,children:o.jsx(aW,{onSaveSnapshot:T.open})})]}),o.jsx(EW,{onOpenToolbox:i.open,onOpenCommander:c.open,onOpenSupervisor:f.open,onOpenControls:m.open,onOpenSkills:b.open,onOpenSnapshots:S.open,isGeneratingReport:ct,pip:_}),o.jsx(mW,{activeTool:yt,onExit:Xr}),q&&(()=>{const Ae=U.getState().agents.get(q.agentId);return Ae?o.jsx(xW,{agent:Ae,screenPos:q.screenPos,onClose:()=>me(null)}):null})(),ce&&(()=>{const Ae=$t.get(ce.buildingId);if(!Ae)return null;const Je=()=>Ze(null);return Ae.type==="boss"?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"building-popup-backdrop",onClick:Je}),o.jsx(SW,{building:Ae,screenPos:ce.screenPos,onClose:Je,onOpenSettings:()=>{Je(),k.open(ce.buildingId)},onOpenLogsModal:()=>{Je(),Me(ce.buildingId)},onOpenUrlInModal:pa})]}):Ae.type==="database"?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"building-popup-backdrop",onClick:Je}),o.jsx(CW,{building:Ae,screenPos:ce.screenPos,onClose:Je,onOpenSettings:()=>{Je(),k.open(ce.buildingId)},onOpenDatabasePanel:()=>{Je(),Te(ce.buildingId)}})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"building-popup-backdrop",onClick:Je}),o.jsx(vW,{building:Ae,screenPos:ce.screenPos,onClose:Je,onOpenSettings:()=>{Je(),k.open(ce.buildingId)},onOpenLogsModal:()=>{Ne(ce.buildingId)},onOpenUrlInModal:pa})]})})(),pe&&(()=>{var Je;const Ae=$t.get(pe);return Ae?(Je=Ae.docker)!=null&&Je.enabled?o.jsx(dq,{building:Ae,isOpen:!0,onClose:()=>Ne(null)}):o.jsx(uq,{building:Ae,isOpen:!0,onClose:()=>Ne(null)}):null})(),ye&&(()=>{const Ae=$t.get(ye);return Ae?o.jsx(fq,{building:Ae,isOpen:!0,onClose:()=>Me(null)}):null})(),X&&(()=>{const Ae=$t.get(X);return Ae?o.jsx("div",{className:"modal-overlay visible",onMouseDown:nt,onClick:we,children:o.jsx("div",{className:"database-panel-modal",children:o.jsx(cq,{building:Ae,onClose:We})})}):null})(),qe&&(()=>{var Je;const Ae=$t.get(qe);return!Ae||!((Je=Ae.terminalStatus)!=null&&Je.url)?null:o.jsx("div",{className:"modal-overlay visible",onMouseDown:ie,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 - ",Ae.name]}),o.jsx("button",{className:"terminal-modal-close",onClick:Le,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(Nx,{terminalUrl:Ae.terminalStatus.url,visible:!0})]})})})(),o.jsx(QW,{pip:_,title:"Tide Commander - Agents",children:o.jsx(eq,{})}),o.jsx(mq,{url:M||"",title:M?`Preview - ${M}`:"",isOpen:!!M,onClose:ha}),T.isOpen&&En.length===1&&(()=>{const Ae=En[0],Je=U.getState().agents.get(Ae);if(!Je)return null;const jt=U.getOutputs(Ae);return o.jsx(gq,{isOpen:T.isOpen,onClose:T.close,agent:Je,outputCount:jt.length,onSave:async Vt=>{try{const gt=jt.map(Lt=>({type:"message",content:Lt.text,timestamp:new Date(Lt.timestamp).toISOString()}));await U.createSnapshot(Vt.agentId,Je.name,Vt.title,Vt.description,gt,[]),T.close(),ot("success",t("notifications:toast.snapshotSaved"),t("notifications:toast.snapshotSavedMsg"))}catch(gt){const Lt=gt instanceof Error?gt.message:t("notifications:toast.snapshotFailedMsg");ot("error",t("notifications:toast.snapshotFailed"),Lt)}},isSaving:Ft,error:_n||void 0})})(),o.jsx(hW,{onFocusAgent:us,onSpawnClick:s.open,onSpawnBossClick:a.open,onNewBuildingClick:Wa,onNewAreaClick:zo}),o.jsx(KW,{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:A,triggerManagerModal:N,buildingModal:k,buildingInitialPosition:W,agentEditModal:j,snapshotsModal:S,restoreArchivedModal:D,explorerModal:E,contextMenu:O,spawnPosition:L,spawnAreaId:G,explorerFolderPath:P,contextMenuActions:$i,sceneConfig:J,onConfigChange:Ks,onToolChange:Bn,onOpenAreaExplorer:On,onDeleteSelectedAgents:ic,pendingBuildingDelete:K,onCancelBuildingDelete:()=>se(null),onConfirmBuildingDelete:Qr,showBackNavModal:ut,onCloseBackNavModal:()=>ln(!1),onLeave:Kt,onOpenPM2LogsModal:Ae=>Ne(Ae),onOpenBossLogsModal:Ae=>Me(Ae),onOpenDatabasePanel:Ae=>Te(Ae),onSyncScene:()=>{var Ae,Je;(Ae=Ye.current)==null||Ae.syncAreas(),(Je=Ye.current)==null||Je.syncAgents(Array.from(U.getState().agents.values()))}})]})}function xq(){return o.jsx(vL,{children:o.jsx(jL,{children:o.jsx(bq,{})})})}class yq 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:"💥"}),Rn.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:Rn.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:Rn.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:Rn.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:Rn.t("common:buttons.tryToContinue")})]}),o.jsx("div",{style:{marginTop:"24px",color:"#666",fontSize:"12px"},children:Rn.t("errors:crash.checkConsole")})]})})}return this.props.children}}j6();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 vq=CM.createRoot(n_);vq.render(o.jsx(je.StrictMode,{children:o.jsx(x.Suspense,{fallback:o.jsx("div",{style:{background:"#0a0a0a",height:"100vh"}}),children:o.jsx(yq,{children:o.jsx(xq,{})})})}));console.log("[Tide] Tide Commander initialized");export{Df as $,TL as A,cN as B,qD as C,kL as D,Dx as E,rV as F,Ex as G,nd as H,qx as I,ur as J,Hx as K,tL as L,dr as M,Pq as N,_L as O,$a as P,lV as Q,_H as R,mt as S,ms as T,Zq as U,Pt as V,bN as W,oV as X,S2 as Y,Ru as Z,Rf as _,Kx as a,ph as a$,Wg as a0,Wr as a1,Qp as a2,Jq as a3,Qj as a4,yp as a5,jq as a6,wL as a7,Yb as a8,Gq as a9,WD as aA,l5 as aB,B6 as aC,F6 as aD,H6 as aE,$q as aF,Xj as aG,Hq as aH,Wq as aI,Rx as aJ,Ox as aK,np as aL,cV as aM,wt as aN,N1 as aO,iV as aP,T1 as aQ,_1 as aR,Pu as aS,Fr as aT,zr as aU,q6 as aV,V6 as aW,dN as aX,Nb as aY,Y6 as aZ,Lo as a_,Fi as aa,Aq as ab,qq as ac,My as ad,ia as ae,Fu as af,Up as ag,Ma as ah,pr as ai,Lx as aj,YD as ak,Rn as al,$R as am,VD as an,Kq as ao,Qq as ap,Xq as aq,Yq as ar,iN as as,iS as at,Iq as au,Jj as av,Jt as aw,HH as ax,_T as ay,sh as az,lL as b,j1 as b0,da as b1,R1 as b2,f5 as b3,Ly as b4,bx as b5,w4 as b6,sN as b7,Eq as b8,Bq as b9,Mq as ba,Fq as bb,zq as bc,Lq as bd,Rq as be,Uq as bf,Kp as bg,BL as bh,y2 as bi,w2 as bj,eV as bk,Do as bl,ed as bm,EL as bn,tV as bo,aV as bp,nV as bq,Oq as br,Dq as bs,sV as bt,UR as bu,HR as bv,ru as bw,Ix as bx,Vq as c,cL as d,Ny as e,Ls as f,EH as g,_a as h,Yl as i,o as j,vS as k,Ta as l,Nn as m,Tq as n,Nq as o,Nf as p,$x as q,x as r,U as s,_q as t,pt as u,Kb as v,Ot as w,GR as x,KR as y,je as z};