livedesk 0.1.260 → 0.1.261
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import{r as
|
|
1
|
+
import{r as Ib,a as f,W as Jo,S as ny,K as ec,b as Sn,A as nn,L as oc,M as an,c as Bb,C as qn,d as cc,e as Vi,F as Or,f as mh,B as jx,T as Fb,g as Hb,h as hh,i as $b,R as tc,m as ph,H as Vo,U as Ub,N as gh,j as ay,k as Pb,l as pc,n as od,o as kx,p as xh,q as qb,s as yd,t as sy,u as Ju,v as cd,w as nc,X as Hr,x as Gb,y as uc,z as ly,D as Yb,E as iy,G as Vb,I as Kb,J as Wb,O as Ym,P as Qb,Q as Xb,V as Zb,Y as Jb,Z as eS,_ as tS,$ as nS,a0 as aS,a1 as sS,a2 as Mx,a3 as lS,a4 as iS,a5 as ed,a6 as Ko,a7 as td,a8 as Vm,a9 as Wo,aa as rS,ab as pm,ac as oS,ad as cS,ae as uS,af as Ax,ag as Bi,ah as dS,ai as Nx,aj as ry,ak as Tx,al as fS}from"./icons-Dm0ih4lI.js";import{r as oy}from"./react-CgbB2ESH.js";import{c as mS}from"./supabase-C7qjtLN3.js";(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))r(c);new MutationObserver(c=>{for(const d of c)if(d.type==="childList")for(const h of d.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&r(h)}).observe(document,{childList:!0,subtree:!0});function i(c){const d={};return c.integrity&&(d.integrity=c.integrity),c.referrerPolicy&&(d.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?d.credentials="include":c.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function r(c){if(c.ep)return;c.ep=!0;const d=i(c);fetch(c.href,d)}})();var gm={exports:{}},Uo={};var Rx;function hS(){if(Rx)return Uo;Rx=1;var n=Symbol.for("react.transitional.element"),a=Symbol.for("react.fragment");function i(r,c,d){var h=null;if(d!==void 0&&(h=""+d),c.key!==void 0&&(h=""+c.key),"key"in c){d={};for(var p in c)p!=="key"&&(d[p]=c[p])}else d=c;return c=d.ref,{$$typeof:n,type:r,key:h,ref:c!==void 0?c:null,props:d}}return Uo.Fragment=a,Uo.jsx=i,Uo.jsxs=i,Uo}var Ex;function pS(){return Ex||(Ex=1,gm.exports=hS()),gm.exports}var l=pS(),xm={exports:{}},Po={},vm={exports:{}},ym={};var Dx;function gS(){return Dx||(Dx=1,(function(n){function a(z,Y){var U=z.length;z.push(Y);e:for(;0<U;){var R=U-1>>>1,J=z[R];if(0<c(J,Y))z[R]=Y,z[U]=J,U=R;else break e}}function i(z){return z.length===0?null:z[0]}function r(z){if(z.length===0)return null;var Y=z[0],U=z.pop();if(U!==Y){z[0]=U;e:for(var R=0,J=z.length,he=J>>>1;R<he;){var $=2*(R+1)-1,ie=z[$],we=$+1,me=z[we];if(0>c(ie,U))we<J&&0>c(me,ie)?(z[R]=me,z[we]=U,R=we):(z[R]=ie,z[$]=U,R=$);else if(we<J&&0>c(me,U))z[R]=me,z[we]=U,R=we;else break e}}return Y}function c(z,Y){var U=z.sortIndex-Y.sortIndex;return U!==0?U:z.id-Y.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var d=performance;n.unstable_now=function(){return d.now()}}else{var h=Date,p=h.now();n.unstable_now=function(){return h.now()-p}}var x=[],g=[],w=1,v=null,b=3,k=!1,j=!1,M=!1,T=!1,C=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,D=typeof setImmediate<"u"?setImmediate:null;function H(z){for(var Y=i(g);Y!==null;){if(Y.callback===null)r(g);else if(Y.startTime<=z)r(g),Y.sortIndex=Y.expirationTime,a(x,Y);else break;Y=i(g)}}function B(z){if(M=!1,H(z),!j)if(i(x)!==null)j=!0,q||(q=!0,Q());else{var Y=i(g);Y!==null&&K(B,Y.startTime-z)}}var q=!1,L=-1,F=5,ue=-1;function W(){return T?!0:!(n.unstable_now()-ue<F)}function ce(){if(T=!1,q){var z=n.unstable_now();ue=z;var Y=!0;try{e:{j=!1,M&&(M=!1,A(L),L=-1),k=!0;var U=b;try{t:{for(H(z),v=i(x);v!==null&&!(v.expirationTime>z&&W());){var R=v.callback;if(typeof R=="function"){v.callback=null,b=v.priorityLevel;var J=R(v.expirationTime<=z);if(z=n.unstable_now(),typeof J=="function"){v.callback=J,H(z),Y=!0;break t}v===i(x)&&r(x),H(z)}else r(x);v=i(x)}if(v!==null)Y=!0;else{var he=i(g);he!==null&&K(B,he.startTime-z),Y=!1}}break e}finally{v=null,b=U,k=!1}Y=void 0}}finally{Y?Q():q=!1}}}var Q;if(typeof D=="function")Q=function(){D(ce)};else if(typeof MessageChannel<"u"){var se=new MessageChannel,oe=se.port2;se.port1.onmessage=ce,Q=function(){oe.postMessage(null)}}else Q=function(){C(ce,0)};function K(z,Y){L=C(function(){z(n.unstable_now())},Y)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(z){z.callback=null},n.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"):F=0<z?Math.floor(1e3/z):5},n.unstable_getCurrentPriorityLevel=function(){return b},n.unstable_next=function(z){switch(b){case 1:case 2:case 3:var Y=3;break;default:Y=b}var U=b;b=Y;try{return z()}finally{b=U}},n.unstable_requestPaint=function(){T=!0},n.unstable_runWithPriority=function(z,Y){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var U=b;b=z;try{return Y()}finally{b=U}},n.unstable_scheduleCallback=function(z,Y,U){var R=n.unstable_now();switch(typeof U=="object"&&U!==null?(U=U.delay,U=typeof U=="number"&&0<U?R+U:R):U=R,z){case 1:var J=-1;break;case 2:J=250;break;case 5:J=1073741823;break;case 4:J=1e4;break;default:J=5e3}return J=U+J,z={id:w++,callback:Y,priorityLevel:z,startTime:U,expirationTime:J,sortIndex:-1},U>R?(z.sortIndex=U,a(g,z),i(x)===null&&z===i(g)&&(M?(A(L),L=-1):M=!0,K(B,U-R))):(z.sortIndex=J,a(x,z),j||k||(j=!0,q||(q=!0,Q()))),z},n.unstable_shouldYield=W,n.unstable_wrapCallback=function(z){var Y=b;return function(){var U=b;b=Y;try{return z.apply(this,arguments)}finally{b=U}}}})(ym)),ym}var Lx;function xS(){return Lx||(Lx=1,vm.exports=gS()),vm.exports}var zx;function vS(){if(zx)return Po;zx=1;var n=xS(),a=Ib(),i=oy();function r(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var s=2;s<arguments.length;s++)t+="&args[]="+encodeURIComponent(arguments[s])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function c(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function d(e){var t=e,s=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(s=t.return),e=t.return;while(e)}return t.tag===3?s:null}function h(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function p(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function x(e){if(d(e)!==e)throw Error(r(188))}function g(e){var t=e.alternate;if(!t){if(t=d(e),t===null)throw Error(r(188));return t!==e?null:e}for(var s=e,o=t;;){var u=s.return;if(u===null)break;var m=u.alternate;if(m===null){if(o=u.return,o!==null){s=o;continue}break}if(u.child===m.child){for(m=u.child;m;){if(m===s)return x(u),e;if(m===o)return x(u),t;m=m.sibling}throw Error(r(188))}if(s.return!==o.return)s=u,o=m;else{for(var S=!1,N=u.child;N;){if(N===s){S=!0,s=u,o=m;break}if(N===o){S=!0,o=u,s=m;break}N=N.sibling}if(!S){for(N=m.child;N;){if(N===s){S=!0,s=m,o=u;break}if(N===o){S=!0,o=m,s=u;break}N=N.sibling}if(!S)throw Error(r(189))}}if(s.alternate!==o)throw Error(r(190))}if(s.tag!==3)throw Error(r(188));return s.stateNode.current===s?e:t}function w(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=w(e),t!==null)return t;e=e.sibling}return null}var v=Object.assign,b=Symbol.for("react.element"),k=Symbol.for("react.transitional.element"),j=Symbol.for("react.portal"),M=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),A=Symbol.for("react.consumer"),D=Symbol.for("react.context"),H=Symbol.for("react.forward_ref"),B=Symbol.for("react.suspense"),q=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),F=Symbol.for("react.lazy"),ue=Symbol.for("react.activity"),W=Symbol.for("react.memo_cache_sentinel"),ce=Symbol.iterator;function Q(e){return e===null||typeof e!="object"?null:(e=ce&&e[ce]||e["@@iterator"],typeof e=="function"?e:null)}var se=Symbol.for("react.client.reference");function oe(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===se?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case M:return"Fragment";case C:return"Profiler";case T:return"StrictMode";case B:return"Suspense";case q:return"SuspenseList";case ue:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case j:return"Portal";case D:return e.displayName||"Context";case A:return(e._context.displayName||"Context")+".Consumer";case H:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case L:return t=e.displayName||null,t!==null?t:oe(e.type)||"Memo";case F:t=e._payload,e=e._init;try{return oe(e(t))}catch{}}return null}var K=Array.isArray,z=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Y=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,U={pending:!1,data:null,method:null,action:null},R=[],J=-1;function he(e){return{current:e}}function $(e){0>J||(e.current=R[J],R[J]=null,J--)}function ie(e,t){J++,R[J]=e.current,e.current=t}var we=he(null),me=he(null),ze=he(null),Pe=he(null);function de(e,t){switch(ie(ze,t),ie(me,e),ie(we,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vg(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vg(t),e=Kg(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}$(we),ie(we,e)}function He(){$(we),$(me),$(ze)}function Le(e){e.memoizedState!==null&&ie(Pe,e);var t=we.current,s=Kg(t,e.type);t!==s&&(ie(me,e),ie(we,s))}function Fe(e){me.current===e&&($(we),$(me)),Pe.current===e&&($(Pe),Bo._currentValue=U)}var qe,ne;function ye(e){if(qe===void 0)try{throw Error()}catch(s){var t=s.stack.trim().match(/\n( *(at )?)/);qe=t&&t[1]||"",ne=-1<s.stack.indexOf(`
|
|
2
2
|
at`)?" (<anonymous>)":-1<s.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
3
3
|
`+qe+e+ne}var be=!1;function Z(e,t){if(!e||be)return"";be=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var o={DetermineComponentFrameRoot:function(){try{if(t){var ve=function(){throw Error()};if(Object.defineProperty(ve.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ve,[])}catch(re){var ae=re}Reflect.construct(e,[],ve)}else{try{ve.call()}catch(re){ae=re}e.call(ve.prototype)}}else{try{throw Error()}catch(re){ae=re}(ve=e())&&typeof ve.catch=="function"&&ve.catch(function(){})}}catch(re){if(re&&ae&&typeof re.stack=="string")return[re.stack,ae.stack]}return[null,null]}};o.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var u=Object.getOwnPropertyDescriptor(o.DetermineComponentFrameRoot,"name");u&&u.configurable&&Object.defineProperty(o.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var m=o.DetermineComponentFrameRoot(),S=m[0],N=m[1];if(S&&N){var I=S.split(`
|
|
4
4
|
`),te=N.split(`
|
|
5
5
|
`);for(u=o=0;o<I.length&&!I[o].includes("DetermineComponentFrameRoot");)o++;for(;u<te.length&&!te[u].includes("DetermineComponentFrameRoot");)u++;if(o===I.length||u===te.length)for(o=I.length-1,u=te.length-1;1<=o&&0<=u&&I[o]!==te[u];)u--;for(;1<=o&&0<=u;o--,u--)if(I[o]!==te[u]){if(o!==1||u!==1)do if(o--,u--,0>u||I[o]!==te[u]){var fe=`
|
|
6
6
|
`+I[o].replace(" at new "," at ");return e.displayName&&fe.includes("<anonymous>")&&(fe=fe.replace("<anonymous>",e.displayName)),fe}while(1<=o&&0<=u);break}}}finally{be=!1,Error.prepareStackTrace=s}return(s=e?e.displayName||e.name:"")?ye(s):""}function le(e,t){switch(e.tag){case 26:case 27:case 5:return ye(e.type);case 16:return ye("Lazy");case 13:return e.child!==t&&t!==null?ye("Suspense Fallback"):ye("Suspense");case 19:return ye("SuspenseList");case 0:case 15:return Z(e.type,!1);case 11:return Z(e.type.render,!1);case 1:return Z(e.type,!0);case 31:return ye("Activity");default:return""}}function Me(e){try{var t="",s=null;do t+=le(e,s),s=e,e=e.return;while(e);return t}catch(o){return`
|
|
7
7
|
Error generating stack: `+o.message+`
|
|
8
|
-
`+o.stack}}var je=Object.prototype.hasOwnProperty,ct=n.unstable_scheduleCallback,sn=n.unstable_cancelCallback,ke=n.unstable_shouldYield,Ne=n.unstable_requestPaint,Oe=n.unstable_now,Dt=n.unstable_getCurrentPriorityLevel,Za=n.unstable_ImmediatePriority,Nt=n.unstable_UserBlockingPriority,Gn=n.unstable_NormalPriority,ii=n.unstable_LowPriority,Te=n.unstable_IdlePriority,za=n.log,Xe=n.unstable_setDisableYieldValue,_a=null,Je=null;function yn(e){if(typeof za=="function"&&Xe(e),Je&&typeof Je.setStrictMode=="function")try{Je.setStrictMode(_a,e)}catch{}}var qt=Math.clz32?Math.clz32:pl,_s=Math.log,Gt=Math.LN2;function pl(e){return e>>>=0,e===0?32:31-(_s(e)/Gt|0)|0}var Oa=256,Ja=262144,ya=4194304;function es(e){var t=e&42;if(t!==0)return t;switch(e&-e){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 e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function ln(e,t,s){var o=e.pendingLanes;if(o===0)return 0;var u=0,m=e.suspendedLanes,S=e.pingedLanes;e=e.warmLanes;var N=o&134217727;return N!==0?(o=N&~m,o!==0?u=es(o):(S&=N,S!==0?u=es(S):s||(s=N&~e,s!==0&&(u=es(s))))):(N=o&~m,N!==0?u=es(N):S!==0?u=es(S):s||(s=o&~e,s!==0&&(u=es(s)))),u===0?0:t!==0&&t!==u&&(t&m)===0&&(m=u&-u,s=t&-t,m>=s||m===32&&(s&4194048)!==0)?t:u}function Hn(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Yn(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+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 t+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 gl(){var e=ya;return ya<<=1,(ya&62914560)===0&&(ya=4194304),e}function Ia(e){for(var t=[],s=0;31>s;s++)t.push(e);return t}function Ba(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Ss(e,t,s,o,u,m){var S=e.pendingLanes;e.pendingLanes=s,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=s,e.entangledLanes&=s,e.errorRecoveryDisabledLanes&=s,e.shellSuspendCounter=0;var N=e.entanglements,I=e.expirationTimes,te=e.hiddenUpdates;for(s=S&~s;0<s;){var fe=31-qt(s),ve=1<<fe;N[fe]=0,I[fe]=-1;var ae=te[fe];if(ae!==null)for(te[fe]=null,fe=0;fe<ae.length;fe++){var re=ae[fe];re!==null&&(re.lane&=-536870913)}s&=~ve}o!==0&&ts(e,o,0),m!==0&&u===0&&e.tag!==0&&(e.suspendedLanes|=m&~(S&~t))}function ts(e,t,s){e.pendingLanes|=t,e.suspendedLanes&=~t;var o=31-qt(t);e.entangledLanes|=t,e.entanglements[o]=e.entanglements[o]|1073741824|s&261930}function Vn(e,t){var s=e.entangledLanes|=t;for(e=e.entanglements;s;){var o=31-qt(s),u=1<<o;u&t|e[o]&t&&(e[o]|=t),s&=~u}}function wa(e,t){var s=t&-t;return s=(s&42)!==0?1:Fa(s),(s&(e.suspendedLanes|t))!==0?0:s}function Fa(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=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:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function ns(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function as(){var e=Y.p;return e!==0?e:(e=window.event,e===void 0?32:xx(e.type))}function Os(e,t){var s=Y.p;try{return Y.p=e,t()}finally{Y.p=s}}var Kn=Math.random().toString(36).slice(2),X="__reactFiber$"+Kn,Se="__reactProps$"+Kn,De="__reactContainer$"+Kn,Ze="__reactEvents$"+Kn,Tt="__reactListeners$"+Kn,ut="__reactHandles$"+Kn,Ue="__reactResources$"+Kn,at="__reactMarker$"+Kn;function Rt(e){delete e[X],delete e[Se],delete e[Ze],delete e[Tt],delete e[ut]}function _t(e){var t=e[X];if(t)return t;for(var s=e.parentNode;s;){if(t=s[De]||s[X]){if(s=t.alternate,t.child!==null||s!==null&&s.child!==null)for(e=tx(e);e!==null;){if(s=e[X])return s;e=tx(e)}return t}e=s,s=e.parentNode}return null}function Yt(e){if(e=e[X]||e[De]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function xt(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(r(33))}function Ot(e){var t=e[Ue];return t||(t=e[Ue]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function vt(e){e[at]=!0}var Wn=new Set,Qn={};function Vt(e,t){It(e,t),It(e+"Capture",t)}function It(e,t){for(Qn[e]=t,e=0;e<t.length;e++)Wn.add(t[e])}var xl=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]*$"),ss={},Cs={};function Pr(e){return je.call(Cs,e)?!0:je.call(ss,e)?!1:xl.test(e)?Cs[e]=!0:(ss[e]=!0,!1)}function ri(e,t,s){if(Pr(t))if(s===null)e.removeAttribute(t);else{switch(typeof s){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var o=t.toLowerCase().slice(0,5);if(o!=="data-"&&o!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+s)}}function ba(e,t,s){if(s===null)e.removeAttribute(t);else{switch(typeof s){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+s)}}function Mn(e,t,s,o){if(o===null)e.removeAttribute(s);else{switch(typeof o){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(s);return}e.setAttributeNS(t,s,""+o)}}function Kt(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function vc(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function qr(e,t,s){var o=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var u=o.get,m=o.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return u.call(this)},set:function(S){s=""+S,m.call(this,S)}}),Object.defineProperty(e,t,{enumerable:o.enumerable}),{getValue:function(){return s},setValue:function(S){s=""+S},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function yc(e){if(!e._valueTracker){var t=vc(e)?"checked":"value";e._valueTracker=qr(e,t,""+e[t])}}function wc(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var s=t.getValue(),o="";return e&&(o=vc(e)?e.checked?"true":"false":e.value),e=o,e!==s?(t.setValue(e),!0):!1}function ls(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var Nd=/[\n"\\]/g;function mn(e){return e.replace(Nd,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function oi(e,t,s,o,u,m,S,N){e.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?e.type=S:e.removeAttribute("type"),t!=null?S==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+Kt(t)):e.value!==""+Kt(t)&&(e.value=""+Kt(t)):S!=="submit"&&S!=="reset"||e.removeAttribute("value"),t!=null?bc(e,S,Kt(t)):s!=null?bc(e,S,Kt(s)):o!=null&&e.removeAttribute("value"),u==null&&m!=null&&(e.defaultChecked=!!m),u!=null&&(e.checked=u&&typeof u!="function"&&typeof u!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?e.name=""+Kt(N):e.removeAttribute("name")}function Td(e,t,s,o,u,m,S,N){if(m!=null&&typeof m!="function"&&typeof m!="symbol"&&typeof m!="boolean"&&(e.type=m),t!=null||s!=null){if(!(m!=="submit"&&m!=="reset"||t!=null)){yc(e);return}s=s!=null?""+Kt(s):"",t=t!=null?""+Kt(t):s,N||t===e.value||(e.value=t),e.defaultValue=t}o=o??u,o=typeof o!="function"&&typeof o!="symbol"&&!!o,e.checked=N?e.checked:!!o,e.defaultChecked=!!o,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(e.name=S),yc(e)}function bc(e,t,s){t==="number"&&ls(e.ownerDocument)===e||e.defaultValue===""+s||(e.defaultValue=""+s)}function ci(e,t,s,o){if(e=e.options,t){t={};for(var u=0;u<s.length;u++)t["$"+s[u]]=!0;for(s=0;s<e.length;s++)u=t.hasOwnProperty("$"+e[s].value),e[s].selected!==u&&(e[s].selected=u),u&&o&&(e[s].defaultSelected=!0)}else{for(s=""+Kt(s),t=null,u=0;u<e.length;u++){if(e[u].value===s){e[u].selected=!0,o&&(e[u].defaultSelected=!0);return}t!==null||e[u].disabled||(t=e[u])}t!==null&&(t.selected=!0)}}function Sc(e,t,s){if(t!=null&&(t=""+Kt(t),t!==e.value&&(e.value=t),s==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=s!=null?""+Kt(s):""}function Gr(e,t,s,o){if(t==null){if(o!=null){if(s!=null)throw Error(r(92));if(K(o)){if(1<o.length)throw Error(r(93));o=o[0]}s=o}s==null&&(s=""),t=s}s=Kt(t),e.defaultValue=s,o=e.textContent,o===s&&o!==""&&o!==null&&(e.value=o),yc(e)}function Is(e,t){if(t){var s=e.firstChild;if(s&&s===e.lastChild&&s.nodeType===3){s.nodeValue=t;return}}e.textContent=t}var Rd=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 Cc(e,t,s){var o=t.indexOf("--")===0;s==null||typeof s=="boolean"||s===""?o?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":o?e.setProperty(t,s):typeof s!="number"||s===0||Rd.has(t)?t==="float"?e.cssFloat=s:e[t]=(""+s).trim():e[t]=s+"px"}function jc(e,t,s){if(t!=null&&typeof t!="object")throw Error(r(62));if(e=e.style,s!=null){for(var o in s)!s.hasOwnProperty(o)||t!=null&&t.hasOwnProperty(o)||(o.indexOf("--")===0?e.setProperty(o,""):o==="float"?e.cssFloat="":e[o]="");for(var u in t)o=t[u],t.hasOwnProperty(u)&&s[u]!==o&&Cc(e,u,o)}else for(var m in t)t.hasOwnProperty(m)&&Cc(e,m,t[m])}function ui(e){if(e.indexOf("-")===-1)return!1;switch(e){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 kc=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"]]),di=/^[\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 Sa(e){return di.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Xn(){}var Xi=null;function Zi(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ha=null,Bs=null;function Yr(e){var t=Yt(e);if(t&&(e=t.stateNode)){var s=e[Se]||null;e:switch(e=t.stateNode,t.type){case"input":if(oi(e,s.value,s.defaultValue,s.defaultValue,s.checked,s.defaultChecked,s.type,s.name),t=s.name,s.type==="radio"&&t!=null){for(s=e;s.parentNode;)s=s.parentNode;for(s=s.querySelectorAll('input[name="'+mn(""+t)+'"][type="radio"]'),t=0;t<s.length;t++){var o=s[t];if(o!==e&&o.form===e.form){var u=o[Se]||null;if(!u)throw Error(r(90));oi(o,u.value,u.defaultValue,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name)}}for(t=0;t<s.length;t++)o=s[t],o.form===e.form&&wc(o)}break e;case"textarea":Sc(e,s.value,s.defaultValue);break e;case"select":t=s.value,t!=null&&ci(e,!!s.multiple,t,!1)}}}var Ye=!1;function lt(e,t,s){if(Ye)return e(t,s);Ye=!0;try{var o=e(t);return o}finally{if(Ye=!1,(Ha!==null||Bs!==null)&&(mu(),Ha&&(t=Ha,e=Bs,Bs=Ha=null,Yr(t),e)))for(t=0;t<e.length;t++)Yr(e[t])}}function An(e,t){var s=e.stateNode;if(s===null)return null;var o=s[Se]||null;if(o===null)return null;s=o[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(o=!o.disabled)||(e=e.type,o=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!o;break e;default:e=!1}if(e)return null;if(s&&typeof s!="function")throw Error(r(231,t,typeof s));return s}var Ca=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),$a=!1;if(Ca)try{var Ke={};Object.defineProperty(Ke,"passive",{get:function(){$a=!0}}),window.addEventListener("test",Ke,Ke),window.removeEventListener("test",Ke,Ke)}catch{$a=!1}var is=null,Vr=null,Fs=null;function vl(){if(Fs)return Fs;var e,t=Vr,s=t.length,o,u="value"in is?is.value:is.textContent,m=u.length;for(e=0;e<s&&t[e]===u[e];e++);var S=s-e;for(o=1;o<=S&&t[s-o]===u[m-o];o++);return Fs=u.slice(e,1<o?1-o:void 0)}function yl(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function rs(){return!0}function Zn(){return!1}function Wt(e){function t(s,o,u,m,S){this._reactName=s,this._targetInst=u,this.type=o,this.nativeEvent=m,this.target=S,this.currentTarget=null;for(var N in e)e.hasOwnProperty(N)&&(s=e[N],this[N]=s?s(m):m[N]);return this.isDefaultPrevented=(m.defaultPrevented!=null?m.defaultPrevented:m.returnValue===!1)?rs:Zn,this.isPropagationStopped=Zn,this}return v(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var s=this.nativeEvent;s&&(s.preventDefault?s.preventDefault():typeof s.returnValue!="unknown"&&(s.returnValue=!1),this.isDefaultPrevented=rs)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=rs)},persist:function(){},isPersistent:rs}),t}var Qt={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Hs=Wt(Qt),Ae=v({},Qt,{view:0,detail:0}),Mc=Wt(Ae),Kr,Jn,fi,Ji=v({},Ae,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Sl,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==fi&&(fi&&e.type==="mousemove"?(Kr=e.screenX-fi.screenX,Jn=e.screenY-fi.screenY):Jn=Kr=0,fi=e),Kr)},movementY:function(e){return"movementY"in e?e.movementY:Jn}}),wl=Wt(Ji),At=v({},Ji,{dataTransfer:0}),Ac=Wt(At),er=v({},Ae,{relatedTarget:0}),os=Wt(er),Ed=v({},Qt,{animationName:0,elapsedTime:0,pseudoElement:0}),Dd=Wt(Ed),Xt=v({},Qt,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),bl=Wt(Xt),Ld=v({},Qt,{data:0}),Wr=Wt(Ld),cs={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Nc={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"},tr={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function $s(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=tr[e])?!!t[e]:!1}function Sl(){return $s}var hn=v({},Ae,{key:function(e){if(e.key){var t=cs[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=yl(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Nc[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Sl,charCode:function(e){return e.type==="keypress"?yl(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?yl(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),zd=Wt(hn),Tc=v({},Ji,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Us=Wt(Tc),_d=v({},Ae,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Sl}),Zt=Wt(_d),Ps=v({},Qt,{propertyName:0,elapsedTime:0,pseudoElement:0}),us=Wt(Ps),Od=v({},Ji,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),Id=Wt(Od),nr=v({},Qt,{newState:0,oldState:0}),ar=Wt(nr),Rc=[9,13,27,32],js=Ca&&"CompositionEvent"in window,Cl=null;Ca&&"documentMode"in document&&(Cl=document.documentMode);var Ec=Ca&&"TextEvent"in window&&!Cl,Dc=Ca&&(!js||Cl&&8<Cl&&11>=Cl),qs=" ",Lc=!1;function Qr(e,t){switch(e){case"keyup":return Rc.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function zc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var jl=!1;function Bd(e,t){switch(e){case"compositionend":return zc(t);case"keypress":return t.which!==32?null:(Lc=!0,qs);case"textInput":return e=t.data,e===qs&&Lc?null:e;default:return null}}function _c(e,t){if(jl)return e==="compositionend"||!js&&Qr(e,t)?(e=vl(),Fs=Vr=is=null,jl=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Dc&&t.locale!=="ko"?null:t.data;default:return null}}var mi={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 ds(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!mi[e.type]:t==="textarea"}function hi(e,t,s,o){Ha?Bs?Bs.push(o):Bs=[o]:Ha=o,t=wu(t,"onChange"),0<t.length&&(s=new Hs("onChange","change",null,s,o),e.push({event:s,listeners:t}))}var Ua=null,ja=null;function Xr(e){$g(e,0)}function sr(e){var t=xt(e);if(wc(t))return e}function Zr(e,t){if(e==="change")return t}var lr=!1;if(Ca){var pi;if(Ca){var ks="oninput"in document;if(!ks){var Oc=document.createElement("div");Oc.setAttribute("oninput","return;"),ks=typeof Oc.oninput=="function"}pi=ks}else pi=!1;lr=pi&&(!document.documentMode||9<document.documentMode)}function gi(){Ua&&(Ua.detachEvent("onpropertychange",xi),ja=Ua=null)}function xi(e){if(e.propertyName==="value"&&sr(ja)){var t=[];hi(t,ja,e,Zi(e)),lt(Xr,t)}}function Jr(e,t,s){e==="focusin"?(gi(),Ua=t,ja=s,Ua.attachEvent("onpropertychange",xi)):e==="focusout"&&gi()}function eo(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return sr(ja)}function ir(e,t){if(e==="click")return sr(t)}function rr(e,t){if(e==="input"||e==="change")return sr(t)}function to(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var zn=typeof Object.is=="function"?Object.is:to;function Pa(e,t){if(zn(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var s=Object.keys(e),o=Object.keys(t);if(s.length!==o.length)return!1;for(o=0;o<s.length;o++){var u=s[o];if(!je.call(t,u)||!zn(e[u],t[u]))return!1}return!0}function Gs(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function vi(e,t){var s=Gs(e);e=0;for(var o;s;){if(s.nodeType===3){if(o=e+s.textContent.length,e<=t&&o>=t)return{node:s,offset:t-e};e=o}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=Gs(s)}}function kl(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?kl(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function ka(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=ls(e.document);t instanceof e.HTMLIFrameElement;){try{var s=typeof t.contentWindow.location.href=="string"}catch{s=!1}if(s)e=t.contentWindow;else break;t=ls(e.document)}return t}function yi(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}var no=Ca&&"documentMode"in document&&11>=document.documentMode,Ys=null,pn=null,Ml=null,wi=!1;function bi(e,t,s){var o=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;wi||Ys==null||Ys!==ls(o)||(o=Ys,"selectionStart"in o&&yi(o)?o={start:o.selectionStart,end:o.selectionEnd}:(o=(o.ownerDocument&&o.ownerDocument.defaultView||window).getSelection(),o={anchorNode:o.anchorNode,anchorOffset:o.anchorOffset,focusNode:o.focusNode,focusOffset:o.focusOffset}),Ml&&Pa(Ml,o)||(Ml=o,o=wu(pn,"onSelect"),0<o.length&&(t=new Hs("onSelect","select",null,t,s),e.push({event:t,listeners:o}),t.target=Ys)))}function Vs(e,t){var s={};return s[e.toLowerCase()]=t.toLowerCase(),s["Webkit"+e]="webkit"+t,s["Moz"+e]="moz"+t,s}var Ma={animationend:Vs("Animation","AnimationEnd"),animationiteration:Vs("Animation","AnimationIteration"),animationstart:Vs("Animation","AnimationStart"),transitionrun:Vs("Transition","TransitionRun"),transitionstart:Vs("Transition","TransitionStart"),transitioncancel:Vs("Transition","TransitionCancel"),transitionend:Vs("Transition","TransitionEnd")},ao={},Ks={};Ca&&(Ks=document.createElement("div").style,"AnimationEvent"in window||(delete Ma.animationend.animation,delete Ma.animationiteration.animation,delete Ma.animationstart.animation),"TransitionEvent"in window||delete Ma.transitionend.transition);function Ms(e){if(ao[e])return ao[e];if(!Ma[e])return e;var t=Ma[e],s;for(s in t)if(t.hasOwnProperty(s)&&s in Ks)return ao[e]=t[s];return e}var Al=Ms("animationend"),so=Ms("animationiteration"),or=Ms("animationstart"),Ic=Ms("transitionrun"),Fd=Ms("transitionstart"),lo=Ms("transitioncancel"),Bc=Ms("transitionend"),io=new Map,cr="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(" ");cr.push("scrollEnd");function ea(e,t){io.set(e,t),Vt(t,[e])}var ur=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},Nn=[],$n=0,Nl=0;function dr(){for(var e=$n,t=Nl=$n=0;t<e;){var s=Nn[t];Nn[t++]=null;var o=Nn[t];Nn[t++]=null;var u=Nn[t];Nn[t++]=null;var m=Nn[t];if(Nn[t++]=null,o!==null&&u!==null){var S=o.pending;S===null?u.next=u:(u.next=S.next,S.next=u),o.pending=u}m!==0&&Ci(s,u,m)}}function Tl(e,t,s,o){Nn[$n++]=e,Nn[$n++]=t,Nn[$n++]=s,Nn[$n++]=o,Nl|=o,e.lanes|=o,e=e.alternate,e!==null&&(e.lanes|=o)}function Si(e,t,s,o){return Tl(e,t,s,o),ji(e)}function Ce(e,t){return Tl(e,null,null,t),ji(e)}function Ci(e,t,s){e.lanes|=s;var o=e.alternate;o!==null&&(o.lanes|=s);for(var u=!1,m=e.return;m!==null;)m.childLanes|=s,o=m.alternate,o!==null&&(o.childLanes|=s),m.tag===22&&(e=m.stateNode,e===null||e._visibility&1||(u=!0)),e=m,m=m.return;return e.tag===3?(m=e.stateNode,u&&t!==null&&(u=31-qt(s),e=m.hiddenUpdates,o=e[u],o===null?e[u]=[t]:o.push(t),t.lane=s|536870912),m):null}function ji(e){if(50<Eo)throw Eo=0,Ff=null,Error(r(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Rl={};function Ih(e,t,s,o){this.tag=e,this.key=s,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=o,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Tn(e,t,s,o){return new Ih(e,t,s,o)}function ro(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ta(e,t){var s=e.alternate;return s===null?(s=Tn(e.tag,t,e.key,e.mode),s.elementType=e.elementType,s.type=e.type,s.stateNode=e.stateNode,s.alternate=e,e.alternate=s):(s.pendingProps=t,s.type=e.type,s.flags=0,s.subtreeFlags=0,s.deletions=null),s.flags=e.flags&65011712,s.childLanes=e.childLanes,s.lanes=e.lanes,s.child=e.child,s.memoizedProps=e.memoizedProps,s.memoizedState=e.memoizedState,s.updateQueue=e.updateQueue,t=e.dependencies,s.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},s.sibling=e.sibling,s.index=e.index,s.ref=e.ref,s.refCleanup=e.refCleanup,s}function rn(e,t){e.flags&=65011714;var s=e.alternate;return s===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=s.childLanes,e.lanes=s.lanes,e.child=s.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=s.memoizedProps,e.memoizedState=s.memoizedState,e.updateQueue=s.updateQueue,e.type=s.type,t=s.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function wn(e,t,s,o,u,m){var S=0;if(o=e,typeof e=="function")ro(e)&&(S=1);else if(typeof e=="string")S=Cb(e,s,we.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case ue:return e=Tn(31,s,t,u),e.elementType=ue,e.lanes=m,e;case M:return et(s.children,u,m,t);case T:S=8,u|=24;break;case C:return e=Tn(12,s,t,u|2),e.elementType=C,e.lanes=m,e;case B:return e=Tn(13,s,t,u),e.elementType=B,e.lanes=m,e;case q:return e=Tn(19,s,t,u),e.elementType=q,e.lanes=m,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case D:S=10;break e;case A:S=9;break e;case H:S=11;break e;case L:S=14;break e;case F:S=16,o=null;break e}S=29,s=Error(r(130,e===null?"null":typeof e,"")),o=null}return t=Tn(S,s,t,u),t.elementType=e,t.type=o,t.lanes=m,t}function et(e,t,s,o){return e=Tn(7,e,o,t),e.lanes=s,e}function oo(e,t,s){return e=Tn(6,e,null,t),e.lanes=s,e}function Fc(e){var t=Tn(18,null,null,0);return t.stateNode=e,t}function co(e,t,s){return t=Tn(4,e.children!==null?e.children:[],e.key,t),t.lanes=s,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Hc=new WeakMap;function na(e,t){if(typeof e=="object"&&e!==null){var s=Hc.get(e);return s!==void 0?s:(t={value:e,source:t,stack:Me(t)},Hc.set(e,t),t)}return{value:e,source:t,stack:Me(t)}}var El=[],Dl=0,fr=null,ki=0,aa=[],sa=0,As=null,qa=1,Ga="";function fs(e,t){El[Dl++]=ki,El[Dl++]=fr,fr=e,ki=t}function $c(e,t,s){aa[sa++]=qa,aa[sa++]=Ga,aa[sa++]=As,As=e;var o=qa;e=Ga;var u=32-qt(o)-1;o&=~(1<<u),s+=1;var m=32-qt(t)+u;if(30<m){var S=u-u%5;m=(o&(1<<S)-1).toString(32),o>>=S,u-=S,qa=1<<32-qt(t)+u|s<<u|o,Ga=m+e}else qa=1<<m|s<<u|o,Ga=e}function Mi(e){e.return!==null&&(fs(e,1),$c(e,1,0))}function Ai(e){for(;e===fr;)fr=El[--Dl],El[Dl]=null,ki=El[--Dl],El[Dl]=null;for(;e===As;)As=aa[--sa],aa[sa]=null,Ga=aa[--sa],aa[sa]=null,qa=aa[--sa],aa[sa]=null}function Uc(e,t){aa[sa++]=qa,aa[sa++]=Ga,aa[sa++]=As,qa=t.id,Ga=t.overflow,As=e}var gn=null,kt=null,it=!1,Ns=null,la=!1,uo=Error(r(519));function Ts(e){var t=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ni(na(t,e)),uo}function Pc(e){var t=e.stateNode,s=e.type,o=e.memoizedProps;switch(t[X]=e,t[Se]=o,s){case"dialog":ot("cancel",t),ot("close",t);break;case"iframe":case"object":case"embed":ot("load",t);break;case"video":case"audio":for(s=0;s<Lo.length;s++)ot(Lo[s],t);break;case"source":ot("error",t);break;case"img":case"image":case"link":ot("error",t),ot("load",t);break;case"details":ot("toggle",t);break;case"input":ot("invalid",t),Td(t,o.value,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name,!0);break;case"select":ot("invalid",t);break;case"textarea":ot("invalid",t),Gr(t,o.value,o.defaultValue,o.children)}s=o.children,typeof s!="string"&&typeof s!="number"&&typeof s!="bigint"||t.textContent===""+s||o.suppressHydrationWarning===!0||Gg(t.textContent,s)?(o.popover!=null&&(ot("beforetoggle",t),ot("toggle",t)),o.onScroll!=null&&ot("scroll",t),o.onScrollEnd!=null&&ot("scrollend",t),o.onClick!=null&&(t.onclick=Xn),t=!0):t=!1,t||Ts(e,!0)}function Ws(e){for(gn=e.return;gn;)switch(gn.tag){case 5:case 31:case 13:la=!1;return;case 27:case 3:la=!0;return;default:gn=gn.return}}function Qs(e){if(e!==gn)return!1;if(!it)return Ws(e),it=!0,!1;var t=e.tag,s;if((s=t!==3&&t!==27)&&((s=t===5)&&(s=e.type,s=!(s!=="form"&&s!=="button")||em(e.type,e.memoizedProps)),s=!s),s&&kt&&Ts(e),Ws(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(r(317));kt=ex(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(r(317));kt=ex(e)}else t===27?(t=kt,Vl(e.type)?(e=lm,lm=null,kt=e):kt=t):kt=gn?Ka(e.stateNode.nextSibling):null;return!0}function ms(){kt=gn=null,it=!1}function fo(){var e=Ns;return e!==null&&(fa===null?fa=e:fa.push.apply(fa,e),Ns=null),e}function Ni(e){Ns===null?Ns=[e]:Ns.push(e)}var mr=he(null),Ya=null,hs=null;function Lt(e,t,s){ie(mr,t._currentValue),t._currentValue=s}function ia(e){e._currentValue=mr.current,$(mr)}function hr(e,t,s){for(;e!==null;){var o=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,o!==null&&(o.childLanes|=t)):o!==null&&(o.childLanes&t)!==t&&(o.childLanes|=t),e===s)break;e=e.return}}function mo(e,t,s,o){var u=e.child;for(u!==null&&(u.return=e);u!==null;){var m=u.dependencies;if(m!==null){var S=u.child;m=m.firstContext;e:for(;m!==null;){var N=m;m=u;for(var I=0;I<t.length;I++)if(N.context===t[I]){m.lanes|=s,N=m.alternate,N!==null&&(N.lanes|=s),hr(m.return,s,e),o||(S=null);break e}m=N.next}}else if(u.tag===18){if(S=u.return,S===null)throw Error(r(341));S.lanes|=s,m=S.alternate,m!==null&&(m.lanes|=s),hr(S,s,e),S=null}else S=u.child;if(S!==null)S.return=u;else for(S=u;S!==null;){if(S===e){S=null;break}if(u=S.sibling,u!==null){u.return=S.return,S=u;break}S=S.return}u=S}}function Ti(e,t,s,o){e=null;for(var u=t,m=!1;u!==null;){if(!m){if((u.flags&524288)!==0)m=!0;else if((u.flags&262144)!==0)break}if(u.tag===10){var S=u.alternate;if(S===null)throw Error(r(387));if(S=S.memoizedProps,S!==null){var N=u.type;zn(u.pendingProps.value,S.value)||(e!==null?e.push(N):e=[N])}}else if(u===Pe.current){if(S=u.alternate,S===null)throw Error(r(387));S.memoizedState.memoizedState!==u.memoizedState.memoizedState&&(e!==null?e.push(Bo):e=[Bo])}u=u.return}e!==null&&mo(t,e,s,o),t.flags|=262144}function pr(e){for(e=e.firstContext;e!==null;){if(!zn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Xs(e){Ya=e,hs=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function on(e){return Ll(Ya,e)}function Zs(e,t){return Ya===null&&Xs(e),Ll(e,t)}function Ll(e,t){var s=t._currentValue;if(t={context:t,memoizedValue:s,next:null},hs===null){if(e===null)throw Error(r(308));hs=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else hs=hs.next=t;return s}var qc=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(s,o){e.push(o)}};this.abort=function(){t.aborted=!0,e.forEach(function(s){return s()})}},Hd=n.unstable_scheduleCallback,$d=n.unstable_NormalPriority,Ht={$$typeof:D,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function ho(){return{controller:new qc,data:new Map,refCount:0}}function Ri(e){e.refCount--,e.refCount===0&&Hd($d,function(){e.controller.abort()})}var Ei=null,po=0,xn=0,zl=null;function Ud(e,t){if(Ei===null){var s=Ei=[];po=0,xn=Gf(),zl={status:"pending",value:void 0,then:function(o){s.push(o)}}}return po++,t.then(Js,Js),t}function Js(){if(--po===0&&Ei!==null){zl!==null&&(zl.status="fulfilled");var e=Ei;Ei=null,xn=0,zl=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function Pd(e,t){var s=[],o={status:"pending",value:null,reason:null,then:function(u){s.push(u)}};return e.then(function(){o.status="fulfilled",o.value=t;for(var u=0;u<s.length;u++)(0,s[u])(t)},function(u){for(o.status="rejected",o.reason=u,u=0;u<s.length;u++)(0,s[u])(void 0)}),o}var gr=z.S;z.S=function(e,t){pg=Oe(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&Ud(e,t),gr!==null&&gr(e,t)};var y=he(null);function E(){var e=y.current;return e!==null?e:Mt.pooledCache}function _(e,t){t===null?ie(y,y.current):ie(y,t.pool)}function G(){var e=E();return e===null?null:{parent:Ht._currentValue,pool:e}}var O=Error(r(460)),pe=Error(r(474)),xe=Error(r(542)),Re={then:function(){}};function Ve(e){return e=e.status,e==="fulfilled"||e==="rejected"}function We(e,t,s){switch(s=e[s],s===void 0?e.push(t):s!==t&&(t.then(Xn,Xn),t=s),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,ps(e),e;default:if(typeof t.status=="string")t.then(Xn,Xn);else{if(e=Mt,e!==null&&100<e.shellSuspendCounter)throw Error(r(482));e=t,e.status="pending",e.then(function(o){if(t.status==="pending"){var u=t;u.status="fulfilled",u.value=o}},function(o){if(t.status==="pending"){var u=t;u.status="rejected",u.reason=o}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,ps(e),e}throw $t=t,O}}function yt(e){try{var t=e._init;return t(e._payload)}catch(s){throw s!==null&&typeof s=="object"&&typeof s.then=="function"?($t=s,O):s}}var $t=null;function ra(){if($t===null)throw Error(r(459));var e=$t;return $t=null,e}function ps(e){if(e===O||e===xe)throw Error(r(483))}var oa=null,gs=0;function el(e){var t=gs;return gs+=1,oa===null&&(oa=[]),We(oa,e,t)}function Di(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function Gc(e,t){throw t.$$typeof===b?Error(r(525)):(e=Object.prototype.toString.call(t),Error(r(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function Bh(e){function t(V,P){if(e){var ee=V.deletions;ee===null?(V.deletions=[P],V.flags|=16):ee.push(P)}}function s(V,P){if(!e)return null;for(;P!==null;)t(V,P),P=P.sibling;return null}function o(V){for(var P=new Map;V!==null;)V.key!==null?P.set(V.key,V):P.set(V.index,V),V=V.sibling;return P}function u(V,P){return V=ta(V,P),V.index=0,V.sibling=null,V}function m(V,P,ee){return V.index=ee,e?(ee=V.alternate,ee!==null?(ee=ee.index,ee<P?(V.flags|=67108866,P):ee):(V.flags|=67108866,P)):(V.flags|=1048576,P)}function S(V){return e&&V.alternate===null&&(V.flags|=67108866),V}function N(V,P,ee,ge){return P===null||P.tag!==6?(P=oo(ee,V.mode,ge),P.return=V,P):(P=u(P,ee),P.return=V,P)}function I(V,P,ee,ge){var $e=ee.type;return $e===M?fe(V,P,ee.props.children,ge,ee.key):P!==null&&(P.elementType===$e||typeof $e=="object"&&$e!==null&&$e.$$typeof===F&&yt($e)===P.type)?(P=u(P,ee.props),Di(P,ee),P.return=V,P):(P=wn(ee.type,ee.key,ee.props,null,V.mode,ge),Di(P,ee),P.return=V,P)}function te(V,P,ee,ge){return P===null||P.tag!==4||P.stateNode.containerInfo!==ee.containerInfo||P.stateNode.implementation!==ee.implementation?(P=co(ee,V.mode,ge),P.return=V,P):(P=u(P,ee.children||[]),P.return=V,P)}function fe(V,P,ee,ge,$e){return P===null||P.tag!==7?(P=et(ee,V.mode,ge,$e),P.return=V,P):(P=u(P,ee),P.return=V,P)}function ve(V,P,ee){if(typeof P=="string"&&P!==""||typeof P=="number"||typeof P=="bigint")return P=oo(""+P,V.mode,ee),P.return=V,P;if(typeof P=="object"&&P!==null){switch(P.$$typeof){case k:return ee=wn(P.type,P.key,P.props,null,V.mode,ee),Di(ee,P),ee.return=V,ee;case j:return P=co(P,V.mode,ee),P.return=V,P;case F:return P=yt(P),ve(V,P,ee)}if(K(P)||Q(P))return P=et(P,V.mode,ee,null),P.return=V,P;if(typeof P.then=="function")return ve(V,el(P),ee);if(P.$$typeof===D)return ve(V,Zs(V,P),ee);Gc(V,P)}return null}function ae(V,P,ee,ge){var $e=P!==null?P.key:null;if(typeof ee=="string"&&ee!==""||typeof ee=="number"||typeof ee=="bigint")return $e!==null?null:N(V,P,""+ee,ge);if(typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case k:return ee.key===$e?I(V,P,ee,ge):null;case j:return ee.key===$e?te(V,P,ee,ge):null;case F:return ee=yt(ee),ae(V,P,ee,ge)}if(K(ee)||Q(ee))return $e!==null?null:fe(V,P,ee,ge,null);if(typeof ee.then=="function")return ae(V,P,el(ee),ge);if(ee.$$typeof===D)return ae(V,P,Zs(V,ee),ge);Gc(V,ee)}return null}function re(V,P,ee,ge,$e){if(typeof ge=="string"&&ge!==""||typeof ge=="number"||typeof ge=="bigint")return V=V.get(ee)||null,N(P,V,""+ge,$e);if(typeof ge=="object"&&ge!==null){switch(ge.$$typeof){case k:return V=V.get(ge.key===null?ee:ge.key)||null,I(P,V,ge,$e);case j:return V=V.get(ge.key===null?ee:ge.key)||null,te(P,V,ge,$e);case F:return ge=yt(ge),re(V,P,ee,ge,$e)}if(K(ge)||Q(ge))return V=V.get(ee)||null,fe(P,V,ge,$e,null);if(typeof ge.then=="function")return re(V,P,ee,el(ge),$e);if(ge.$$typeof===D)return re(V,P,ee,Zs(P,ge),$e);Gc(P,ge)}return null}function _e(V,P,ee,ge){for(var $e=null,ht=null,Ie=P,st=P=0,ft=null;Ie!==null&&st<ee.length;st++){Ie.index>st?(ft=Ie,Ie=null):ft=Ie.sibling;var pt=ae(V,Ie,ee[st],ge);if(pt===null){Ie===null&&(Ie=ft);break}e&&Ie&&pt.alternate===null&&t(V,Ie),P=m(pt,P,st),ht===null?$e=pt:ht.sibling=pt,ht=pt,Ie=ft}if(st===ee.length)return s(V,Ie),it&&fs(V,st),$e;if(Ie===null){for(;st<ee.length;st++)Ie=ve(V,ee[st],ge),Ie!==null&&(P=m(Ie,P,st),ht===null?$e=Ie:ht.sibling=Ie,ht=Ie);return it&&fs(V,st),$e}for(Ie=o(Ie);st<ee.length;st++)ft=re(Ie,V,st,ee[st],ge),ft!==null&&(e&&ft.alternate!==null&&Ie.delete(ft.key===null?st:ft.key),P=m(ft,P,st),ht===null?$e=ft:ht.sibling=ft,ht=ft);return e&&Ie.forEach(function(Zl){return t(V,Zl)}),it&&fs(V,st),$e}function Ge(V,P,ee,ge){if(ee==null)throw Error(r(151));for(var $e=null,ht=null,Ie=P,st=P=0,ft=null,pt=ee.next();Ie!==null&&!pt.done;st++,pt=ee.next()){Ie.index>st?(ft=Ie,Ie=null):ft=Ie.sibling;var Zl=ae(V,Ie,pt.value,ge);if(Zl===null){Ie===null&&(Ie=ft);break}e&&Ie&&Zl.alternate===null&&t(V,Ie),P=m(Zl,P,st),ht===null?$e=Zl:ht.sibling=Zl,ht=Zl,Ie=ft}if(pt.done)return s(V,Ie),it&&fs(V,st),$e;if(Ie===null){for(;!pt.done;st++,pt=ee.next())pt=ve(V,pt.value,ge),pt!==null&&(P=m(pt,P,st),ht===null?$e=pt:ht.sibling=pt,ht=pt);return it&&fs(V,st),$e}for(Ie=o(Ie);!pt.done;st++,pt=ee.next())pt=re(Ie,V,st,pt.value,ge),pt!==null&&(e&&pt.alternate!==null&&Ie.delete(pt.key===null?st:pt.key),P=m(pt,P,st),ht===null?$e=pt:ht.sibling=pt,ht=pt);return e&&Ie.forEach(function(zb){return t(V,zb)}),it&&fs(V,st),$e}function jt(V,P,ee,ge){if(typeof ee=="object"&&ee!==null&&ee.type===M&&ee.key===null&&(ee=ee.props.children),typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case k:e:{for(var $e=ee.key;P!==null;){if(P.key===$e){if($e=ee.type,$e===M){if(P.tag===7){s(V,P.sibling),ge=u(P,ee.props.children),ge.return=V,V=ge;break e}}else if(P.elementType===$e||typeof $e=="object"&&$e!==null&&$e.$$typeof===F&&yt($e)===P.type){s(V,P.sibling),ge=u(P,ee.props),Di(ge,ee),ge.return=V,V=ge;break e}s(V,P);break}else t(V,P);P=P.sibling}ee.type===M?(ge=et(ee.props.children,V.mode,ge,ee.key),ge.return=V,V=ge):(ge=wn(ee.type,ee.key,ee.props,null,V.mode,ge),Di(ge,ee),ge.return=V,V=ge)}return S(V);case j:e:{for($e=ee.key;P!==null;){if(P.key===$e)if(P.tag===4&&P.stateNode.containerInfo===ee.containerInfo&&P.stateNode.implementation===ee.implementation){s(V,P.sibling),ge=u(P,ee.children||[]),ge.return=V,V=ge;break e}else{s(V,P);break}else t(V,P);P=P.sibling}ge=co(ee,V.mode,ge),ge.return=V,V=ge}return S(V);case F:return ee=yt(ee),jt(V,P,ee,ge)}if(K(ee))return _e(V,P,ee,ge);if(Q(ee)){if($e=Q(ee),typeof $e!="function")throw Error(r(150));return ee=$e.call(ee),Ge(V,P,ee,ge)}if(typeof ee.then=="function")return jt(V,P,el(ee),ge);if(ee.$$typeof===D)return jt(V,P,Zs(V,ee),ge);Gc(V,ee)}return typeof ee=="string"&&ee!==""||typeof ee=="number"||typeof ee=="bigint"?(ee=""+ee,P!==null&&P.tag===6?(s(V,P.sibling),ge=u(P,ee),ge.return=V,V=ge):(s(V,P),ge=oo(ee,V.mode,ge),ge.return=V,V=ge),S(V)):s(V,P)}return function(V,P,ee,ge){try{gs=0;var $e=jt(V,P,ee,ge);return oa=null,$e}catch(Ie){if(Ie===O||Ie===xe)throw Ie;var ht=Tn(29,Ie,null,V.mode);return ht.lanes=ge,ht.return=V,ht}}}var Li=Bh(!0),Fh=Bh(!1),_l=!1;function qd(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Gd(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Ol(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Il(e,t,s){var o=e.updateQueue;if(o===null)return null;if(o=o.shared,(gt&2)!==0){var u=o.pending;return u===null?t.next=t:(t.next=u.next,u.next=t),o.pending=t,t=ji(e),Ci(e,null,s),t}return Tl(e,o,t,s),ji(e)}function go(e,t,s){if(t=t.updateQueue,t!==null&&(t=t.shared,(s&4194048)!==0)){var o=t.lanes;o&=e.pendingLanes,s|=o,t.lanes=s,Vn(e,s)}}function Yd(e,t){var s=e.updateQueue,o=e.alternate;if(o!==null&&(o=o.updateQueue,s===o)){var u=null,m=null;if(s=s.firstBaseUpdate,s!==null){do{var S={lane:s.lane,tag:s.tag,payload:s.payload,callback:null,next:null};m===null?u=m=S:m=m.next=S,s=s.next}while(s!==null);m===null?u=m=t:m=m.next=t}else u=m=t;s={baseState:o.baseState,firstBaseUpdate:u,lastBaseUpdate:m,shared:o.shared,callbacks:o.callbacks},e.updateQueue=s;return}e=s.lastBaseUpdate,e===null?s.firstBaseUpdate=t:e.next=t,s.lastBaseUpdate=t}var Vd=!1;function xo(){if(Vd){var e=zl;if(e!==null)throw e}}function vo(e,t,s,o){Vd=!1;var u=e.updateQueue;_l=!1;var m=u.firstBaseUpdate,S=u.lastBaseUpdate,N=u.shared.pending;if(N!==null){u.shared.pending=null;var I=N,te=I.next;I.next=null,S===null?m=te:S.next=te,S=I;var fe=e.alternate;fe!==null&&(fe=fe.updateQueue,N=fe.lastBaseUpdate,N!==S&&(N===null?fe.firstBaseUpdate=te:N.next=te,fe.lastBaseUpdate=I))}if(m!==null){var ve=u.baseState;S=0,fe=te=I=null,N=m;do{var ae=N.lane&-536870913,re=ae!==N.lane;if(re?(dt&ae)===ae:(o&ae)===ae){ae!==0&&ae===xn&&(Vd=!0),fe!==null&&(fe=fe.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var _e=e,Ge=N;ae=t;var jt=s;switch(Ge.tag){case 1:if(_e=Ge.payload,typeof _e=="function"){ve=_e.call(jt,ve,ae);break e}ve=_e;break e;case 3:_e.flags=_e.flags&-65537|128;case 0:if(_e=Ge.payload,ae=typeof _e=="function"?_e.call(jt,ve,ae):_e,ae==null)break e;ve=v({},ve,ae);break e;case 2:_l=!0}}ae=N.callback,ae!==null&&(e.flags|=64,re&&(e.flags|=8192),re=u.callbacks,re===null?u.callbacks=[ae]:re.push(ae))}else re={lane:ae,tag:N.tag,payload:N.payload,callback:N.callback,next:null},fe===null?(te=fe=re,I=ve):fe=fe.next=re,S|=ae;if(N=N.next,N===null){if(N=u.shared.pending,N===null)break;re=N,N=re.next,re.next=null,u.lastBaseUpdate=re,u.shared.pending=null}}while(!0);fe===null&&(I=ve),u.baseState=I,u.firstBaseUpdate=te,u.lastBaseUpdate=fe,m===null&&(u.shared.lanes=0),Ul|=S,e.lanes=S,e.memoizedState=ve}}function Hh(e,t){if(typeof e!="function")throw Error(r(191,e));e.call(t)}function $h(e,t){var s=e.callbacks;if(s!==null)for(e.callbacks=null,e=0;e<s.length;e++)Hh(s[e],t)}var xr=he(null),Yc=he(0);function Uh(e,t){e=cl,ie(Yc,e),ie(xr,t),cl=e|t.baseLanes}function Kd(){ie(Yc,cl),ie(xr,xr.current)}function Wd(){cl=Yc.current,$(xr),$(Yc)}var Aa=he(null),Va=null;function Bl(e){var t=e.alternate;ie(Jt,Jt.current&1),ie(Aa,e),Va===null&&(t===null||xr.current!==null||t.memoizedState!==null)&&(Va=e)}function Qd(e){ie(Jt,Jt.current),ie(Aa,e),Va===null&&(Va=e)}function Ph(e){e.tag===22?(ie(Jt,Jt.current),ie(Aa,e),Va===null&&(Va=e)):Fl()}function Fl(){ie(Jt,Jt.current),ie(Aa,Aa.current)}function Na(e){$(Aa),Va===e&&(Va=null),$(Jt)}var Jt=he(0);function Vc(e){for(var t=e;t!==null;){if(t.tag===13){var s=t.memoizedState;if(s!==null&&(s=s.dehydrated,s===null||am(s)||sm(s)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder==="forwards"||t.memoizedProps.revealOrder==="backwards"||t.memoizedProps.revealOrder==="unstable_legacy-backwards"||t.memoizedProps.revealOrder==="together")){if((t.flags&128)!==0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var tl=0,tt=null,St=null,cn=null,Kc=!1,vr=!1,zi=!1,Wc=0,yo=0,yr=null,jw=0;function Ut(){throw Error(r(321))}function Xd(e,t){if(t===null)return!1;for(var s=0;s<t.length&&s<e.length;s++)if(!zn(e[s],t[s]))return!1;return!0}function Zd(e,t,s,o,u,m){return tl=m,tt=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,z.H=e===null||e.memoizedState===null?Mp:hf,zi=!1,m=s(o,u),zi=!1,vr&&(m=Gh(t,s,o,u)),qh(e),m}function qh(e){z.H=So;var t=St!==null&&St.next!==null;if(tl=0,cn=St=tt=null,Kc=!1,yo=0,yr=null,t)throw Error(r(300));e===null||un||(e=e.dependencies,e!==null&&pr(e)&&(un=!0))}function Gh(e,t,s,o){tt=e;var u=0;do{if(vr&&(yr=null),yo=0,vr=!1,25<=u)throw Error(r(301));if(u+=1,cn=St=null,e.updateQueue!=null){var m=e.updateQueue;m.lastEffect=null,m.events=null,m.stores=null,m.memoCache!=null&&(m.memoCache.index=0)}z.H=Ap,m=t(s,o)}while(vr);return m}function kw(){var e=z.H,t=e.useState()[0];return t=typeof t.then=="function"?wo(t):t,e=e.useState()[0],(St!==null?St.memoizedState:null)!==e&&(tt.flags|=1024),t}function Jd(){var e=Wc!==0;return Wc=0,e}function ef(e,t,s){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s}function tf(e){if(Kc){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Kc=!1}tl=0,cn=St=tt=null,vr=!1,yo=Wc=0,yr=null}function Un(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return cn===null?tt.memoizedState=cn=e:cn=cn.next=e,cn}function en(){if(St===null){var e=tt.alternate;e=e!==null?e.memoizedState:null}else e=St.next;var t=cn===null?tt.memoizedState:cn.next;if(t!==null)cn=t,St=e;else{if(e===null)throw tt.alternate===null?Error(r(467)):Error(r(310));St=e,e={memoizedState:St.memoizedState,baseState:St.baseState,baseQueue:St.baseQueue,queue:St.queue,next:null},cn===null?tt.memoizedState=cn=e:cn=cn.next=e}return cn}function Qc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function wo(e){var t=yo;return yo+=1,yr===null&&(yr=[]),e=We(yr,e,t),t=tt,(cn===null?t.memoizedState:cn.next)===null&&(t=t.alternate,z.H=t===null||t.memoizedState===null?Mp:hf),e}function Xc(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return wo(e);if(e.$$typeof===D)return on(e)}throw Error(r(438,String(e)))}function nf(e){var t=null,s=tt.updateQueue;if(s!==null&&(t=s.memoCache),t==null){var o=tt.alternate;o!==null&&(o=o.updateQueue,o!==null&&(o=o.memoCache,o!=null&&(t={data:o.data.map(function(u){return u.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),s===null&&(s=Qc(),tt.updateQueue=s),s.memoCache=t,s=t.data[t.index],s===void 0)for(s=t.data[t.index]=Array(e),o=0;o<e;o++)s[o]=W;return t.index++,s}function nl(e,t){return typeof t=="function"?t(e):t}function Zc(e){var t=en();return af(t,St,e)}function af(e,t,s){var o=e.queue;if(o===null)throw Error(r(311));o.lastRenderedReducer=s;var u=e.baseQueue,m=o.pending;if(m!==null){if(u!==null){var S=u.next;u.next=m.next,m.next=S}t.baseQueue=u=m,o.pending=null}if(m=e.baseState,u===null)e.memoizedState=m;else{t=u.next;var N=S=null,I=null,te=t,fe=!1;do{var ve=te.lane&-536870913;if(ve!==te.lane?(dt&ve)===ve:(tl&ve)===ve){var ae=te.revertLane;if(ae===0)I!==null&&(I=I.next={lane:0,revertLane:0,gesture:null,action:te.action,hasEagerState:te.hasEagerState,eagerState:te.eagerState,next:null}),ve===xn&&(fe=!0);else if((tl&ae)===ae){te=te.next,ae===xn&&(fe=!0);continue}else ve={lane:0,revertLane:te.revertLane,gesture:null,action:te.action,hasEagerState:te.hasEagerState,eagerState:te.eagerState,next:null},I===null?(N=I=ve,S=m):I=I.next=ve,tt.lanes|=ae,Ul|=ae;ve=te.action,zi&&s(m,ve),m=te.hasEagerState?te.eagerState:s(m,ve)}else ae={lane:ve,revertLane:te.revertLane,gesture:te.gesture,action:te.action,hasEagerState:te.hasEagerState,eagerState:te.eagerState,next:null},I===null?(N=I=ae,S=m):I=I.next=ae,tt.lanes|=ve,Ul|=ve;te=te.next}while(te!==null&&te!==t);if(I===null?S=m:I.next=N,!zn(m,e.memoizedState)&&(un=!0,fe&&(s=zl,s!==null)))throw s;e.memoizedState=m,e.baseState=S,e.baseQueue=I,o.lastRenderedState=m}return u===null&&(o.lanes=0),[e.memoizedState,o.dispatch]}function sf(e){var t=en(),s=t.queue;if(s===null)throw Error(r(311));s.lastRenderedReducer=e;var o=s.dispatch,u=s.pending,m=t.memoizedState;if(u!==null){s.pending=null;var S=u=u.next;do m=e(m,S.action),S=S.next;while(S!==u);zn(m,t.memoizedState)||(un=!0),t.memoizedState=m,t.baseQueue===null&&(t.baseState=m),s.lastRenderedState=m}return[m,o]}function Yh(e,t,s){var o=tt,u=en(),m=it;if(m){if(s===void 0)throw Error(r(407));s=s()}else s=t();var S=!zn((St||u).memoizedState,s);if(S&&(u.memoizedState=s,un=!0),u=u.queue,of(Wh.bind(null,o,u,e),[e]),u.getSnapshot!==t||S||cn!==null&&cn.memoizedState.tag&1){if(o.flags|=2048,wr(9,{destroy:void 0},Kh.bind(null,o,u,s,t),null),Mt===null)throw Error(r(349));m||(tl&127)!==0||Vh(o,t,s)}return s}function Vh(e,t,s){e.flags|=16384,e={getSnapshot:t,value:s},t=tt.updateQueue,t===null?(t=Qc(),tt.updateQueue=t,t.stores=[e]):(s=t.stores,s===null?t.stores=[e]:s.push(e))}function Kh(e,t,s,o){t.value=s,t.getSnapshot=o,Qh(t)&&Xh(e)}function Wh(e,t,s){return s(function(){Qh(t)&&Xh(e)})}function Qh(e){var t=e.getSnapshot;e=e.value;try{var s=t();return!zn(e,s)}catch{return!0}}function Xh(e){var t=Ce(e,2);t!==null&&ma(t,e,2)}function lf(e){var t=Un();if(typeof e=="function"){var s=e;if(e=s(),zi){yn(!0);try{s()}finally{yn(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:nl,lastRenderedState:e},t}function Zh(e,t,s,o){return e.baseState=s,af(e,St,typeof o=="function"?o:nl)}function Mw(e,t,s,o,u){if(tu(e))throw Error(r(485));if(e=t.action,e!==null){var m={payload:u,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(S){m.listeners.push(S)}};z.T!==null?s(!0):m.isTransition=!1,o(m),s=t.pending,s===null?(m.next=t.pending=m,Jh(t,m)):(m.next=s.next,t.pending=s.next=m)}}function Jh(e,t){var s=t.action,o=t.payload,u=e.state;if(t.isTransition){var m=z.T,S={};z.T=S;try{var N=s(u,o),I=z.S;I!==null&&I(S,N),ep(e,t,N)}catch(te){rf(e,t,te)}finally{m!==null&&S.types!==null&&(m.types=S.types),z.T=m}}else try{m=s(u,o),ep(e,t,m)}catch(te){rf(e,t,te)}}function ep(e,t,s){s!==null&&typeof s=="object"&&typeof s.then=="function"?s.then(function(o){tp(e,t,o)},function(o){return rf(e,t,o)}):tp(e,t,s)}function tp(e,t,s){t.status="fulfilled",t.value=s,np(t),e.state=s,t=e.pending,t!==null&&(s=t.next,s===t?e.pending=null:(s=s.next,t.next=s,Jh(e,s)))}function rf(e,t,s){var o=e.pending;if(e.pending=null,o!==null){o=o.next;do t.status="rejected",t.reason=s,np(t),t=t.next;while(t!==o)}e.action=null}function np(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function ap(e,t){return t}function sp(e,t){if(it){var s=Mt.formState;if(s!==null){e:{var o=tt;if(it){if(kt){t:{for(var u=kt,m=la;u.nodeType!==8;){if(!m){u=null;break t}if(u=Ka(u.nextSibling),u===null){u=null;break t}}m=u.data,u=m==="F!"||m==="F"?u:null}if(u){kt=Ka(u.nextSibling),o=u.data==="F!";break e}}Ts(o)}o=!1}o&&(t=s[0])}}return s=Un(),s.memoizedState=s.baseState=t,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ap,lastRenderedState:t},s.queue=o,s=Cp.bind(null,tt,o),o.dispatch=s,o=lf(!1),m=mf.bind(null,tt,!1,o.queue),o=Un(),u={state:t,dispatch:null,action:e,pending:null},o.queue=u,s=Mw.bind(null,tt,u,m,s),u.dispatch=s,o.memoizedState=e,[t,s,!1]}function lp(e){var t=en();return ip(t,St,e)}function ip(e,t,s){if(t=af(e,t,ap)[0],e=Zc(nl)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var o=wo(t)}catch(S){throw S===O?xe:S}else o=t;t=en();var u=t.queue,m=u.dispatch;return s!==t.memoizedState&&(tt.flags|=2048,wr(9,{destroy:void 0},Aw.bind(null,u,s),null)),[o,m,e]}function Aw(e,t){e.action=t}function rp(e){var t=en(),s=St;if(s!==null)return ip(t,s,e);en(),t=t.memoizedState,s=en();var o=s.queue.dispatch;return s.memoizedState=e,[t,o,!1]}function wr(e,t,s,o){return e={tag:e,create:s,deps:o,inst:t,next:null},t=tt.updateQueue,t===null&&(t=Qc(),tt.updateQueue=t),s=t.lastEffect,s===null?t.lastEffect=e.next=e:(o=s.next,s.next=e,e.next=o,t.lastEffect=e),e}function op(){return en().memoizedState}function Jc(e,t,s,o){var u=Un();tt.flags|=e,u.memoizedState=wr(1|t,{destroy:void 0},s,o===void 0?null:o)}function eu(e,t,s,o){var u=en();o=o===void 0?null:o;var m=u.memoizedState.inst;St!==null&&o!==null&&Xd(o,St.memoizedState.deps)?u.memoizedState=wr(t,m,s,o):(tt.flags|=e,u.memoizedState=wr(1|t,m,s,o))}function cp(e,t){Jc(8390656,8,e,t)}function of(e,t){eu(2048,8,e,t)}function Nw(e){tt.flags|=4;var t=tt.updateQueue;if(t===null)t=Qc(),tt.updateQueue=t,t.events=[e];else{var s=t.events;s===null?t.events=[e]:s.push(e)}}function up(e){var t=en().memoizedState;return Nw({ref:t,nextImpl:e}),function(){if((gt&2)!==0)throw Error(r(440));return t.impl.apply(void 0,arguments)}}function dp(e,t){return eu(4,2,e,t)}function fp(e,t){return eu(4,4,e,t)}function mp(e,t){if(typeof t=="function"){e=e();var s=t(e);return function(){typeof s=="function"?s():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function hp(e,t,s){s=s!=null?s.concat([e]):null,eu(4,4,mp.bind(null,t,e),s)}function cf(){}function pp(e,t){var s=en();t=t===void 0?null:t;var o=s.memoizedState;return t!==null&&Xd(t,o[1])?o[0]:(s.memoizedState=[e,t],e)}function gp(e,t){var s=en();t=t===void 0?null:t;var o=s.memoizedState;if(t!==null&&Xd(t,o[1]))return o[0];if(o=e(),zi){yn(!0);try{e()}finally{yn(!1)}}return s.memoizedState=[o,t],o}function uf(e,t,s){return s===void 0||(tl&1073741824)!==0&&(dt&261930)===0?e.memoizedState=t:(e.memoizedState=s,e=xg(),tt.lanes|=e,Ul|=e,s)}function xp(e,t,s,o){return zn(s,t)?s:xr.current!==null?(e=uf(e,s,o),zn(e,t)||(un=!0),e):(tl&42)===0||(tl&1073741824)!==0&&(dt&261930)===0?(un=!0,e.memoizedState=s):(e=xg(),tt.lanes|=e,Ul|=e,t)}function vp(e,t,s,o,u){var m=Y.p;Y.p=m!==0&&8>m?m:8;var S=z.T,N={};z.T=N,mf(e,!1,t,s);try{var I=u(),te=z.S;if(te!==null&&te(N,I),I!==null&&typeof I=="object"&&typeof I.then=="function"){var fe=Pd(I,o);bo(e,t,fe,Ea(e))}else bo(e,t,o,Ea(e))}catch(ve){bo(e,t,{then:function(){},status:"rejected",reason:ve},Ea())}finally{Y.p=m,S!==null&&N.types!==null&&(S.types=N.types),z.T=S}}function Tw(){}function df(e,t,s,o){if(e.tag!==5)throw Error(r(476));var u=yp(e).queue;vp(e,u,t,U,s===null?Tw:function(){return wp(e),s(o)})}function yp(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:U,baseState:U,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:nl,lastRenderedState:U},next:null};var s={};return t.next={memoizedState:s,baseState:s,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:nl,lastRenderedState:s},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function wp(e){var t=yp(e);t.next===null&&(t=e.alternate.memoizedState),bo(e,t.next.queue,{},Ea())}function ff(){return on(Bo)}function bp(){return en().memoizedState}function Sp(){return en().memoizedState}function Rw(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var s=Ea();e=Ol(s);var o=Il(t,e,s);o!==null&&(ma(o,t,s),go(o,t,s)),t={cache:ho()},e.payload=t;return}t=t.return}}function Ew(e,t,s){var o=Ea();s={lane:o,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},tu(e)?jp(t,s):(s=Si(e,t,s,o),s!==null&&(ma(s,e,o),kp(s,t,o)))}function Cp(e,t,s){var o=Ea();bo(e,t,s,o)}function bo(e,t,s,o){var u={lane:o,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null};if(tu(e))jp(t,u);else{var m=e.alternate;if(e.lanes===0&&(m===null||m.lanes===0)&&(m=t.lastRenderedReducer,m!==null))try{var S=t.lastRenderedState,N=m(S,s);if(u.hasEagerState=!0,u.eagerState=N,zn(N,S))return Tl(e,t,u,0),Mt===null&&dr(),!1}catch{}if(s=Si(e,t,u,o),s!==null)return ma(s,e,o),kp(s,t,o),!0}return!1}function mf(e,t,s,o){if(o={lane:2,revertLane:Gf(),gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},tu(e)){if(t)throw Error(r(479))}else t=Si(e,s,o,2),t!==null&&ma(t,e,2)}function tu(e){var t=e.alternate;return e===tt||t!==null&&t===tt}function jp(e,t){vr=Kc=!0;var s=e.pending;s===null?t.next=t:(t.next=s.next,s.next=t),e.pending=t}function kp(e,t,s){if((s&4194048)!==0){var o=t.lanes;o&=e.pendingLanes,s|=o,t.lanes=s,Vn(e,s)}}var So={readContext:on,use:Xc,useCallback:Ut,useContext:Ut,useEffect:Ut,useImperativeHandle:Ut,useLayoutEffect:Ut,useInsertionEffect:Ut,useMemo:Ut,useReducer:Ut,useRef:Ut,useState:Ut,useDebugValue:Ut,useDeferredValue:Ut,useTransition:Ut,useSyncExternalStore:Ut,useId:Ut,useHostTransitionStatus:Ut,useFormState:Ut,useActionState:Ut,useOptimistic:Ut,useMemoCache:Ut,useCacheRefresh:Ut};So.useEffectEvent=Ut;var Mp={readContext:on,use:Xc,useCallback:function(e,t){return Un().memoizedState=[e,t===void 0?null:t],e},useContext:on,useEffect:cp,useImperativeHandle:function(e,t,s){s=s!=null?s.concat([e]):null,Jc(4194308,4,mp.bind(null,t,e),s)},useLayoutEffect:function(e,t){return Jc(4194308,4,e,t)},useInsertionEffect:function(e,t){Jc(4,2,e,t)},useMemo:function(e,t){var s=Un();t=t===void 0?null:t;var o=e();if(zi){yn(!0);try{e()}finally{yn(!1)}}return s.memoizedState=[o,t],o},useReducer:function(e,t,s){var o=Un();if(s!==void 0){var u=s(t);if(zi){yn(!0);try{s(t)}finally{yn(!1)}}}else u=t;return o.memoizedState=o.baseState=u,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:u},o.queue=e,e=e.dispatch=Ew.bind(null,tt,e),[o.memoizedState,e]},useRef:function(e){var t=Un();return e={current:e},t.memoizedState=e},useState:function(e){e=lf(e);var t=e.queue,s=Cp.bind(null,tt,t);return t.dispatch=s,[e.memoizedState,s]},useDebugValue:cf,useDeferredValue:function(e,t){var s=Un();return uf(s,e,t)},useTransition:function(){var e=lf(!1);return e=vp.bind(null,tt,e.queue,!0,!1),Un().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,s){var o=tt,u=Un();if(it){if(s===void 0)throw Error(r(407));s=s()}else{if(s=t(),Mt===null)throw Error(r(349));(dt&127)!==0||Vh(o,t,s)}u.memoizedState=s;var m={value:s,getSnapshot:t};return u.queue=m,cp(Wh.bind(null,o,m,e),[e]),o.flags|=2048,wr(9,{destroy:void 0},Kh.bind(null,o,m,s,t),null),s},useId:function(){var e=Un(),t=Mt.identifierPrefix;if(it){var s=Ga,o=qa;s=(o&~(1<<32-qt(o)-1)).toString(32)+s,t="_"+t+"R_"+s,s=Wc++,0<s&&(t+="H"+s.toString(32)),t+="_"}else s=jw++,t="_"+t+"r_"+s.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:ff,useFormState:sp,useActionState:sp,useOptimistic:function(e){var t=Un();t.memoizedState=t.baseState=e;var s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=s,t=mf.bind(null,tt,!0,s),s.dispatch=t,[e,t]},useMemoCache:nf,useCacheRefresh:function(){return Un().memoizedState=Rw.bind(null,tt)},useEffectEvent:function(e){var t=Un(),s={impl:e};return t.memoizedState=s,function(){if((gt&2)!==0)throw Error(r(440));return s.impl.apply(void 0,arguments)}}},hf={readContext:on,use:Xc,useCallback:pp,useContext:on,useEffect:of,useImperativeHandle:hp,useInsertionEffect:dp,useLayoutEffect:fp,useMemo:gp,useReducer:Zc,useRef:op,useState:function(){return Zc(nl)},useDebugValue:cf,useDeferredValue:function(e,t){var s=en();return xp(s,St.memoizedState,e,t)},useTransition:function(){var e=Zc(nl)[0],t=en().memoizedState;return[typeof e=="boolean"?e:wo(e),t]},useSyncExternalStore:Yh,useId:bp,useHostTransitionStatus:ff,useFormState:lp,useActionState:lp,useOptimistic:function(e,t){var s=en();return Zh(s,St,e,t)},useMemoCache:nf,useCacheRefresh:Sp};hf.useEffectEvent=up;var Ap={readContext:on,use:Xc,useCallback:pp,useContext:on,useEffect:of,useImperativeHandle:hp,useInsertionEffect:dp,useLayoutEffect:fp,useMemo:gp,useReducer:sf,useRef:op,useState:function(){return sf(nl)},useDebugValue:cf,useDeferredValue:function(e,t){var s=en();return St===null?uf(s,e,t):xp(s,St.memoizedState,e,t)},useTransition:function(){var e=sf(nl)[0],t=en().memoizedState;return[typeof e=="boolean"?e:wo(e),t]},useSyncExternalStore:Yh,useId:bp,useHostTransitionStatus:ff,useFormState:rp,useActionState:rp,useOptimistic:function(e,t){var s=en();return St!==null?Zh(s,St,e,t):(s.baseState=e,[e,s.queue.dispatch])},useMemoCache:nf,useCacheRefresh:Sp};Ap.useEffectEvent=up;function pf(e,t,s,o){t=e.memoizedState,s=s(o,t),s=s==null?t:v({},t,s),e.memoizedState=s,e.lanes===0&&(e.updateQueue.baseState=s)}var gf={enqueueSetState:function(e,t,s){e=e._reactInternals;var o=Ea(),u=Ol(o);u.payload=t,s!=null&&(u.callback=s),t=Il(e,u,o),t!==null&&(ma(t,e,o),go(t,e,o))},enqueueReplaceState:function(e,t,s){e=e._reactInternals;var o=Ea(),u=Ol(o);u.tag=1,u.payload=t,s!=null&&(u.callback=s),t=Il(e,u,o),t!==null&&(ma(t,e,o),go(t,e,o))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var s=Ea(),o=Ol(s);o.tag=2,t!=null&&(o.callback=t),t=Il(e,o,s),t!==null&&(ma(t,e,s),go(t,e,s))}};function Np(e,t,s,o,u,m,S){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(o,m,S):t.prototype&&t.prototype.isPureReactComponent?!Pa(s,o)||!Pa(u,m):!0}function Tp(e,t,s,o){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(s,o),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(s,o),t.state!==e&&gf.enqueueReplaceState(t,t.state,null)}function _i(e,t){var s=t;if("ref"in t){s={};for(var o in t)o!=="ref"&&(s[o]=t[o])}if(e=e.defaultProps){s===t&&(s=v({},s));for(var u in e)s[u]===void 0&&(s[u]=e[u])}return s}function Rp(e){ur(e)}function Ep(e){console.error(e)}function Dp(e){ur(e)}function nu(e,t){try{var s=e.onUncaughtError;s(t.value,{componentStack:t.stack})}catch(o){setTimeout(function(){throw o})}}function Lp(e,t,s){try{var o=e.onCaughtError;o(s.value,{componentStack:s.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(u){setTimeout(function(){throw u})}}function xf(e,t,s){return s=Ol(s),s.tag=3,s.payload={element:null},s.callback=function(){nu(e,t)},s}function zp(e){return e=Ol(e),e.tag=3,e}function _p(e,t,s,o){var u=s.type.getDerivedStateFromError;if(typeof u=="function"){var m=o.value;e.payload=function(){return u(m)},e.callback=function(){Lp(t,s,o)}}var S=s.stateNode;S!==null&&typeof S.componentDidCatch=="function"&&(e.callback=function(){Lp(t,s,o),typeof u!="function"&&(Pl===null?Pl=new Set([this]):Pl.add(this));var N=o.stack;this.componentDidCatch(o.value,{componentStack:N!==null?N:""})})}function Dw(e,t,s,o,u){if(s.flags|=32768,o!==null&&typeof o=="object"&&typeof o.then=="function"){if(t=s.alternate,t!==null&&Ti(t,s,u,!0),s=Aa.current,s!==null){switch(s.tag){case 31:case 13:return Va===null?hu():s.alternate===null&&Pt===0&&(Pt=3),s.flags&=-257,s.flags|=65536,s.lanes=u,o===Re?s.flags|=16384:(t=s.updateQueue,t===null?s.updateQueue=new Set([o]):t.add(o),Uf(e,o,u)),!1;case 22:return s.flags|=65536,o===Re?s.flags|=16384:(t=s.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([o])},s.updateQueue=t):(s=t.retryQueue,s===null?t.retryQueue=new Set([o]):s.add(o)),Uf(e,o,u)),!1}throw Error(r(435,s.tag))}return Uf(e,o,u),hu(),!1}if(it)return t=Aa.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=u,o!==uo&&(e=Error(r(422),{cause:o}),Ni(na(e,s)))):(o!==uo&&(t=Error(r(423),{cause:o}),Ni(na(t,s))),e=e.current.alternate,e.flags|=65536,u&=-u,e.lanes|=u,o=na(o,s),u=xf(e.stateNode,o,u),Yd(e,u),Pt!==4&&(Pt=2)),!1;var m=Error(r(520),{cause:o});if(m=na(m,s),Ro===null?Ro=[m]:Ro.push(m),Pt!==4&&(Pt=2),t===null)return!0;o=na(o,s),s=t;do{switch(s.tag){case 3:return s.flags|=65536,e=u&-u,s.lanes|=e,e=xf(s.stateNode,o,e),Yd(s,e),!1;case 1:if(t=s.type,m=s.stateNode,(s.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||m!==null&&typeof m.componentDidCatch=="function"&&(Pl===null||!Pl.has(m))))return s.flags|=65536,u&=-u,s.lanes|=u,u=zp(u),_p(u,e,s,o),Yd(s,u),!1}s=s.return}while(s!==null);return!1}var vf=Error(r(461)),un=!1;function Rn(e,t,s,o){t.child=e===null?Fh(t,null,s,o):Li(t,e.child,s,o)}function Op(e,t,s,o,u){s=s.render;var m=t.ref;if("ref"in o){var S={};for(var N in o)N!=="ref"&&(S[N]=o[N])}else S=o;return Xs(t),o=Zd(e,t,s,S,m,u),N=Jd(),e!==null&&!un?(ef(e,t,u),al(e,t,u)):(it&&N&&Mi(t),t.flags|=1,Rn(e,t,o,u),t.child)}function Ip(e,t,s,o,u){if(e===null){var m=s.type;return typeof m=="function"&&!ro(m)&&m.defaultProps===void 0&&s.compare===null?(t.tag=15,t.type=m,Bp(e,t,m,o,u)):(e=wn(s.type,null,o,t,t.mode,u),e.ref=t.ref,e.return=t,t.child=e)}if(m=e.child,!Mf(e,u)){var S=m.memoizedProps;if(s=s.compare,s=s!==null?s:Pa,s(S,o)&&e.ref===t.ref)return al(e,t,u)}return t.flags|=1,e=ta(m,o),e.ref=t.ref,e.return=t,t.child=e}function Bp(e,t,s,o,u){if(e!==null){var m=e.memoizedProps;if(Pa(m,o)&&e.ref===t.ref)if(un=!1,t.pendingProps=o=m,Mf(e,u))(e.flags&131072)!==0&&(un=!0);else return t.lanes=e.lanes,al(e,t,u)}return yf(e,t,s,o,u)}function Fp(e,t,s,o){var u=o.children,m=e!==null?e.memoizedState:null;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.mode==="hidden"){if((t.flags&128)!==0){if(m=m!==null?m.baseLanes|s:s,e!==null){for(o=t.child=e.child,u=0;o!==null;)u=u|o.lanes|o.childLanes,o=o.sibling;o=u&~m}else o=0,t.child=null;return Hp(e,t,m,s,o)}if((s&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&_(t,m!==null?m.cachePool:null),m!==null?Uh(t,m):Kd(),Ph(t);else return o=t.lanes=536870912,Hp(e,t,m!==null?m.baseLanes|s:s,s,o)}else m!==null?(_(t,m.cachePool),Uh(t,m),Fl(),t.memoizedState=null):(e!==null&&_(t,null),Kd(),Fl());return Rn(e,t,u,s),t.child}function Co(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Hp(e,t,s,o,u){var m=E();return m=m===null?null:{parent:Ht._currentValue,pool:m},t.memoizedState={baseLanes:s,cachePool:m},e!==null&&_(t,null),Kd(),Ph(t),e!==null&&Ti(e,t,o,!0),t.childLanes=u,null}function au(e,t){return t=lu({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function $p(e,t,s){return Li(t,e.child,null,s),e=au(t,t.pendingProps),e.flags|=2,Na(t),t.memoizedState=null,e}function Lw(e,t,s){var o=t.pendingProps,u=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(it){if(o.mode==="hidden")return e=au(t,o),t.lanes=536870912,Co(null,e);if(Qd(t),(e=kt)?(e=Jg(e,la),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:As!==null?{id:qa,overflow:Ga}:null,retryLane:536870912,hydrationErrors:null},s=Fc(e),s.return=t,t.child=s,gn=t,kt=null)):e=null,e===null)throw Ts(t);return t.lanes=536870912,null}return au(t,o)}var m=e.memoizedState;if(m!==null){var S=m.dehydrated;if(Qd(t),u)if(t.flags&256)t.flags&=-257,t=$p(e,t,s);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(r(558));else if(un||Ti(e,t,s,!1),u=(s&e.childLanes)!==0,un||u){if(o=Mt,o!==null&&(S=wa(o,s),S!==0&&S!==m.retryLane))throw m.retryLane=S,Ce(e,S),ma(o,e,S),vf;hu(),t=$p(e,t,s)}else e=m.treeContext,kt=Ka(S.nextSibling),gn=t,it=!0,Ns=null,la=!1,e!==null&&Uc(t,e),t=au(t,o),t.flags|=4096;return t}return e=ta(e.child,{mode:o.mode,children:o.children}),e.ref=t.ref,t.child=e,e.return=t,e}function su(e,t){var s=t.ref;if(s===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof s!="function"&&typeof s!="object")throw Error(r(284));(e===null||e.ref!==s)&&(t.flags|=4194816)}}function yf(e,t,s,o,u){return Xs(t),s=Zd(e,t,s,o,void 0,u),o=Jd(),e!==null&&!un?(ef(e,t,u),al(e,t,u)):(it&&o&&Mi(t),t.flags|=1,Rn(e,t,s,u),t.child)}function Up(e,t,s,o,u,m){return Xs(t),t.updateQueue=null,s=Gh(t,o,s,u),qh(e),o=Jd(),e!==null&&!un?(ef(e,t,m),al(e,t,m)):(it&&o&&Mi(t),t.flags|=1,Rn(e,t,s,m),t.child)}function Pp(e,t,s,o,u){if(Xs(t),t.stateNode===null){var m=Rl,S=s.contextType;typeof S=="object"&&S!==null&&(m=on(S)),m=new s(o,m),t.memoizedState=m.state!==null&&m.state!==void 0?m.state:null,m.updater=gf,t.stateNode=m,m._reactInternals=t,m=t.stateNode,m.props=o,m.state=t.memoizedState,m.refs={},qd(t),S=s.contextType,m.context=typeof S=="object"&&S!==null?on(S):Rl,m.state=t.memoizedState,S=s.getDerivedStateFromProps,typeof S=="function"&&(pf(t,s,S,o),m.state=t.memoizedState),typeof s.getDerivedStateFromProps=="function"||typeof m.getSnapshotBeforeUpdate=="function"||typeof m.UNSAFE_componentWillMount!="function"&&typeof m.componentWillMount!="function"||(S=m.state,typeof m.componentWillMount=="function"&&m.componentWillMount(),typeof m.UNSAFE_componentWillMount=="function"&&m.UNSAFE_componentWillMount(),S!==m.state&&gf.enqueueReplaceState(m,m.state,null),vo(t,o,m,u),xo(),m.state=t.memoizedState),typeof m.componentDidMount=="function"&&(t.flags|=4194308),o=!0}else if(e===null){m=t.stateNode;var N=t.memoizedProps,I=_i(s,N);m.props=I;var te=m.context,fe=s.contextType;S=Rl,typeof fe=="object"&&fe!==null&&(S=on(fe));var ve=s.getDerivedStateFromProps;fe=typeof ve=="function"||typeof m.getSnapshotBeforeUpdate=="function",N=t.pendingProps!==N,fe||typeof m.UNSAFE_componentWillReceiveProps!="function"&&typeof m.componentWillReceiveProps!="function"||(N||te!==S)&&Tp(t,m,o,S),_l=!1;var ae=t.memoizedState;m.state=ae,vo(t,o,m,u),xo(),te=t.memoizedState,N||ae!==te||_l?(typeof ve=="function"&&(pf(t,s,ve,o),te=t.memoizedState),(I=_l||Np(t,s,I,o,ae,te,S))?(fe||typeof m.UNSAFE_componentWillMount!="function"&&typeof m.componentWillMount!="function"||(typeof m.componentWillMount=="function"&&m.componentWillMount(),typeof m.UNSAFE_componentWillMount=="function"&&m.UNSAFE_componentWillMount()),typeof m.componentDidMount=="function"&&(t.flags|=4194308)):(typeof m.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=o,t.memoizedState=te),m.props=o,m.state=te,m.context=S,o=I):(typeof m.componentDidMount=="function"&&(t.flags|=4194308),o=!1)}else{m=t.stateNode,Gd(e,t),S=t.memoizedProps,fe=_i(s,S),m.props=fe,ve=t.pendingProps,ae=m.context,te=s.contextType,I=Rl,typeof te=="object"&&te!==null&&(I=on(te)),N=s.getDerivedStateFromProps,(te=typeof N=="function"||typeof m.getSnapshotBeforeUpdate=="function")||typeof m.UNSAFE_componentWillReceiveProps!="function"&&typeof m.componentWillReceiveProps!="function"||(S!==ve||ae!==I)&&Tp(t,m,o,I),_l=!1,ae=t.memoizedState,m.state=ae,vo(t,o,m,u),xo();var re=t.memoizedState;S!==ve||ae!==re||_l||e!==null&&e.dependencies!==null&&pr(e.dependencies)?(typeof N=="function"&&(pf(t,s,N,o),re=t.memoizedState),(fe=_l||Np(t,s,fe,o,ae,re,I)||e!==null&&e.dependencies!==null&&pr(e.dependencies))?(te||typeof m.UNSAFE_componentWillUpdate!="function"&&typeof m.componentWillUpdate!="function"||(typeof m.componentWillUpdate=="function"&&m.componentWillUpdate(o,re,I),typeof m.UNSAFE_componentWillUpdate=="function"&&m.UNSAFE_componentWillUpdate(o,re,I)),typeof m.componentDidUpdate=="function"&&(t.flags|=4),typeof m.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof m.componentDidUpdate!="function"||S===e.memoizedProps&&ae===e.memoizedState||(t.flags|=4),typeof m.getSnapshotBeforeUpdate!="function"||S===e.memoizedProps&&ae===e.memoizedState||(t.flags|=1024),t.memoizedProps=o,t.memoizedState=re),m.props=o,m.state=re,m.context=I,o=fe):(typeof m.componentDidUpdate!="function"||S===e.memoizedProps&&ae===e.memoizedState||(t.flags|=4),typeof m.getSnapshotBeforeUpdate!="function"||S===e.memoizedProps&&ae===e.memoizedState||(t.flags|=1024),o=!1)}return m=o,su(e,t),o=(t.flags&128)!==0,m||o?(m=t.stateNode,s=o&&typeof s.getDerivedStateFromError!="function"?null:m.render(),t.flags|=1,e!==null&&o?(t.child=Li(t,e.child,null,u),t.child=Li(t,null,s,u)):Rn(e,t,s,u),t.memoizedState=m.state,e=t.child):e=al(e,t,u),e}function qp(e,t,s,o){return ms(),t.flags|=256,Rn(e,t,s,o),t.child}var wf={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function bf(e){return{baseLanes:e,cachePool:G()}}function Sf(e,t,s){return e=e!==null?e.childLanes&~s:0,t&&(e|=Ra),e}function Gp(e,t,s){var o=t.pendingProps,u=!1,m=(t.flags&128)!==0,S;if((S=m)||(S=e!==null&&e.memoizedState===null?!1:(Jt.current&2)!==0),S&&(u=!0,t.flags&=-129),S=(t.flags&32)!==0,t.flags&=-33,e===null){if(it){if(u?Bl(t):Fl(),(e=kt)?(e=Jg(e,la),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:As!==null?{id:qa,overflow:Ga}:null,retryLane:536870912,hydrationErrors:null},s=Fc(e),s.return=t,t.child=s,gn=t,kt=null)):e=null,e===null)throw Ts(t);return sm(e)?t.lanes=32:t.lanes=536870912,null}var N=o.children;return o=o.fallback,u?(Fl(),u=t.mode,N=lu({mode:"hidden",children:N},u),o=et(o,u,s,null),N.return=t,o.return=t,N.sibling=o,t.child=N,o=t.child,o.memoizedState=bf(s),o.childLanes=Sf(e,S,s),t.memoizedState=wf,Co(null,o)):(Bl(t),Cf(t,N))}var I=e.memoizedState;if(I!==null&&(N=I.dehydrated,N!==null)){if(m)t.flags&256?(Bl(t),t.flags&=-257,t=jf(e,t,s)):t.memoizedState!==null?(Fl(),t.child=e.child,t.flags|=128,t=null):(Fl(),N=o.fallback,u=t.mode,o=lu({mode:"visible",children:o.children},u),N=et(N,u,s,null),N.flags|=2,o.return=t,N.return=t,o.sibling=N,t.child=o,Li(t,e.child,null,s),o=t.child,o.memoizedState=bf(s),o.childLanes=Sf(e,S,s),t.memoizedState=wf,t=Co(null,o));else if(Bl(t),sm(N)){if(S=N.nextSibling&&N.nextSibling.dataset,S)var te=S.dgst;S=te,o=Error(r(419)),o.stack="",o.digest=S,Ni({value:o,source:null,stack:null}),t=jf(e,t,s)}else if(un||Ti(e,t,s,!1),S=(s&e.childLanes)!==0,un||S){if(S=Mt,S!==null&&(o=wa(S,s),o!==0&&o!==I.retryLane))throw I.retryLane=o,Ce(e,o),ma(S,e,o),vf;am(N)||hu(),t=jf(e,t,s)}else am(N)?(t.flags|=192,t.child=e.child,t=null):(e=I.treeContext,kt=Ka(N.nextSibling),gn=t,it=!0,Ns=null,la=!1,e!==null&&Uc(t,e),t=Cf(t,o.children),t.flags|=4096);return t}return u?(Fl(),N=o.fallback,u=t.mode,I=e.child,te=I.sibling,o=ta(I,{mode:"hidden",children:o.children}),o.subtreeFlags=I.subtreeFlags&65011712,te!==null?N=ta(te,N):(N=et(N,u,s,null),N.flags|=2),N.return=t,o.return=t,o.sibling=N,t.child=o,Co(null,o),o=t.child,N=e.child.memoizedState,N===null?N=bf(s):(u=N.cachePool,u!==null?(I=Ht._currentValue,u=u.parent!==I?{parent:I,pool:I}:u):u=G(),N={baseLanes:N.baseLanes|s,cachePool:u}),o.memoizedState=N,o.childLanes=Sf(e,S,s),t.memoizedState=wf,Co(e.child,o)):(Bl(t),s=e.child,e=s.sibling,s=ta(s,{mode:"visible",children:o.children}),s.return=t,s.sibling=null,e!==null&&(S=t.deletions,S===null?(t.deletions=[e],t.flags|=16):S.push(e)),t.child=s,t.memoizedState=null,s)}function Cf(e,t){return t=lu({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function lu(e,t){return e=Tn(22,e,null,t),e.lanes=0,e}function jf(e,t,s){return Li(t,e.child,null,s),e=Cf(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Yp(e,t,s){e.lanes|=t;var o=e.alternate;o!==null&&(o.lanes|=t),hr(e.return,t,s)}function kf(e,t,s,o,u,m){var S=e.memoizedState;S===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:o,tail:s,tailMode:u,treeForkCount:m}:(S.isBackwards=t,S.rendering=null,S.renderingStartTime=0,S.last=o,S.tail=s,S.tailMode=u,S.treeForkCount=m)}function Vp(e,t,s){var o=t.pendingProps,u=o.revealOrder,m=o.tail;o=o.children;var S=Jt.current,N=(S&2)!==0;if(N?(S=S&1|2,t.flags|=128):S&=1,ie(Jt,S),Rn(e,t,o,s),o=it?ki:0,!N&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Yp(e,s,t);else if(e.tag===19)Yp(e,s,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(u){case"forwards":for(s=t.child,u=null;s!==null;)e=s.alternate,e!==null&&Vc(e)===null&&(u=s),s=s.sibling;s=u,s===null?(u=t.child,t.child=null):(u=s.sibling,s.sibling=null),kf(t,!1,u,s,m,o);break;case"backwards":case"unstable_legacy-backwards":for(s=null,u=t.child,t.child=null;u!==null;){if(e=u.alternate,e!==null&&Vc(e)===null){t.child=u;break}e=u.sibling,u.sibling=s,s=u,u=e}kf(t,!0,s,null,m,o);break;case"together":kf(t,!1,null,null,void 0,o);break;default:t.memoizedState=null}return t.child}function al(e,t,s){if(e!==null&&(t.dependencies=e.dependencies),Ul|=t.lanes,(s&t.childLanes)===0)if(e!==null){if(Ti(e,t,s,!1),(s&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(r(153));if(t.child!==null){for(e=t.child,s=ta(e,e.pendingProps),t.child=s,s.return=t;e.sibling!==null;)e=e.sibling,s=s.sibling=ta(e,e.pendingProps),s.return=t;s.sibling=null}return t.child}function Mf(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&pr(e)))}function zw(e,t,s){switch(t.tag){case 3:de(t,t.stateNode.containerInfo),Lt(t,Ht,e.memoizedState.cache),ms();break;case 27:case 5:Le(t);break;case 4:de(t,t.stateNode.containerInfo);break;case 10:Lt(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Qd(t),null;break;case 13:var o=t.memoizedState;if(o!==null)return o.dehydrated!==null?(Bl(t),t.flags|=128,null):(s&t.child.childLanes)!==0?Gp(e,t,s):(Bl(t),e=al(e,t,s),e!==null?e.sibling:null);Bl(t);break;case 19:var u=(e.flags&128)!==0;if(o=(s&t.childLanes)!==0,o||(Ti(e,t,s,!1),o=(s&t.childLanes)!==0),u){if(o)return Vp(e,t,s);t.flags|=128}if(u=t.memoizedState,u!==null&&(u.rendering=null,u.tail=null,u.lastEffect=null),ie(Jt,Jt.current),o)break;return null;case 22:return t.lanes=0,Fp(e,t,s,t.pendingProps);case 24:Lt(t,Ht,e.memoizedState.cache)}return al(e,t,s)}function Kp(e,t,s){if(e!==null)if(e.memoizedProps!==t.pendingProps)un=!0;else{if(!Mf(e,s)&&(t.flags&128)===0)return un=!1,zw(e,t,s);un=(e.flags&131072)!==0}else un=!1,it&&(t.flags&1048576)!==0&&$c(t,ki,t.index);switch(t.lanes=0,t.tag){case 16:e:{var o=t.pendingProps;if(e=yt(t.elementType),t.type=e,typeof e=="function")ro(e)?(o=_i(e,o),t.tag=1,t=Pp(null,t,e,o,s)):(t.tag=0,t=yf(null,t,e,o,s));else{if(e!=null){var u=e.$$typeof;if(u===H){t.tag=11,t=Op(null,t,e,o,s);break e}else if(u===L){t.tag=14,t=Ip(null,t,e,o,s);break e}}throw t=oe(e)||e,Error(r(306,t,""))}}return t;case 0:return yf(e,t,t.type,t.pendingProps,s);case 1:return o=t.type,u=_i(o,t.pendingProps),Pp(e,t,o,u,s);case 3:e:{if(de(t,t.stateNode.containerInfo),e===null)throw Error(r(387));o=t.pendingProps;var m=t.memoizedState;u=m.element,Gd(e,t),vo(t,o,null,s);var S=t.memoizedState;if(o=S.cache,Lt(t,Ht,o),o!==m.cache&&mo(t,[Ht],s,!0),xo(),o=S.element,m.isDehydrated)if(m={element:o,isDehydrated:!1,cache:S.cache},t.updateQueue.baseState=m,t.memoizedState=m,t.flags&256){t=qp(e,t,o,s);break e}else if(o!==u){u=na(Error(r(424)),t),Ni(u),t=qp(e,t,o,s);break e}else for(e=t.stateNode.containerInfo,e.nodeType===9?e=e.body:e=e.nodeName==="HTML"?e.ownerDocument.body:e,kt=Ka(e.firstChild),gn=t,it=!0,Ns=null,la=!0,s=Fh(t,null,o,s),t.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling;else{if(ms(),o===u){t=al(e,t,s);break e}Rn(e,t,o,s)}t=t.child}return t;case 26:return su(e,t),e===null?(s=lx(t.type,null,t.pendingProps,null))?t.memoizedState=s:it||(s=t.type,e=t.pendingProps,o=bu(ze.current).createElement(s),o[X]=t,o[Se]=e,En(o,s,e),vt(o),t.stateNode=o):t.memoizedState=lx(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return Le(t),e===null&&it&&(o=t.stateNode=nx(t.type,t.pendingProps,ze.current),gn=t,la=!0,u=kt,Vl(t.type)?(lm=u,kt=Ka(o.firstChild)):kt=u),Rn(e,t,t.pendingProps.children,s),su(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&it&&((u=o=kt)&&(o=ub(o,t.type,t.pendingProps,la),o!==null?(t.stateNode=o,gn=t,kt=Ka(o.firstChild),la=!1,u=!0):u=!1),u||Ts(t)),Le(t),u=t.type,m=t.pendingProps,S=e!==null?e.memoizedProps:null,o=m.children,em(u,m)?o=null:S!==null&&em(u,S)&&(t.flags|=32),t.memoizedState!==null&&(u=Zd(e,t,kw,null,null,s),Bo._currentValue=u),su(e,t),Rn(e,t,o,s),t.child;case 6:return e===null&&it&&((e=s=kt)&&(s=db(s,t.pendingProps,la),s!==null?(t.stateNode=s,gn=t,kt=null,e=!0):e=!1),e||Ts(t)),null;case 13:return Gp(e,t,s);case 4:return de(t,t.stateNode.containerInfo),o=t.pendingProps,e===null?t.child=Li(t,null,o,s):Rn(e,t,o,s),t.child;case 11:return Op(e,t,t.type,t.pendingProps,s);case 7:return Rn(e,t,t.pendingProps,s),t.child;case 8:return Rn(e,t,t.pendingProps.children,s),t.child;case 12:return Rn(e,t,t.pendingProps.children,s),t.child;case 10:return o=t.pendingProps,Lt(t,t.type,o.value),Rn(e,t,o.children,s),t.child;case 9:return u=t.type._context,o=t.pendingProps.children,Xs(t),u=on(u),o=o(u),t.flags|=1,Rn(e,t,o,s),t.child;case 14:return Ip(e,t,t.type,t.pendingProps,s);case 15:return Bp(e,t,t.type,t.pendingProps,s);case 19:return Vp(e,t,s);case 31:return Lw(e,t,s);case 22:return Fp(e,t,s,t.pendingProps);case 24:return Xs(t),o=on(Ht),e===null?(u=E(),u===null&&(u=Mt,m=ho(),u.pooledCache=m,m.refCount++,m!==null&&(u.pooledCacheLanes|=s),u=m),t.memoizedState={parent:o,cache:u},qd(t),Lt(t,Ht,u)):((e.lanes&s)!==0&&(Gd(e,t),vo(t,null,null,s),xo()),u=e.memoizedState,m=t.memoizedState,u.parent!==o?(u={parent:o,cache:o},t.memoizedState=u,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=u),Lt(t,Ht,o)):(o=m.cache,Lt(t,Ht,o),o!==u.cache&&mo(t,[Ht],s,!0))),Rn(e,t,t.pendingProps.children,s),t.child;case 29:throw t.pendingProps}throw Error(r(156,t.tag))}function sl(e){e.flags|=4}function Af(e,t,s,o,u){if((t=(e.mode&32)!==0)&&(t=!1),t){if(e.flags|=16777216,(u&335544128)===u)if(e.stateNode.complete)e.flags|=8192;else if(bg())e.flags|=8192;else throw $t=Re,pe}else e.flags&=-16777217}function Wp(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!ux(t))if(bg())e.flags|=8192;else throw $t=Re,pe}function iu(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?gl():536870912,e.lanes|=t,jr|=t)}function jo(e,t){if(!it)switch(e.tailMode){case"hidden":t=e.tail;for(var s=null;t!==null;)t.alternate!==null&&(s=t),t=t.sibling;s===null?e.tail=null:s.sibling=null;break;case"collapsed":s=e.tail;for(var o=null;s!==null;)s.alternate!==null&&(o=s),s=s.sibling;o===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:o.sibling=null}}function Et(e){var t=e.alternate!==null&&e.alternate.child===e.child,s=0,o=0;if(t)for(var u=e.child;u!==null;)s|=u.lanes|u.childLanes,o|=u.subtreeFlags&65011712,o|=u.flags&65011712,u.return=e,u=u.sibling;else for(u=e.child;u!==null;)s|=u.lanes|u.childLanes,o|=u.subtreeFlags,o|=u.flags,u.return=e,u=u.sibling;return e.subtreeFlags|=o,e.childLanes=s,t}function _w(e,t,s){var o=t.pendingProps;switch(Ai(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Et(t),null;case 1:return Et(t),null;case 3:return s=t.stateNode,o=null,e!==null&&(o=e.memoizedState.cache),t.memoizedState.cache!==o&&(t.flags|=2048),ia(Ht),He(),s.pendingContext&&(s.context=s.pendingContext,s.pendingContext=null),(e===null||e.child===null)&&(Qs(t)?sl(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,fo())),Et(t),null;case 26:var u=t.type,m=t.memoizedState;return e===null?(sl(t),m!==null?(Et(t),Wp(t,m)):(Et(t),Af(t,u,null,o,s))):m?m!==e.memoizedState?(sl(t),Et(t),Wp(t,m)):(Et(t),t.flags&=-16777217):(e=e.memoizedProps,e!==o&&sl(t),Et(t),Af(t,u,e,o,s)),null;case 27:if(Fe(t),s=ze.current,u=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==o&&sl(t);else{if(!o){if(t.stateNode===null)throw Error(r(166));return Et(t),null}e=we.current,Qs(t)?Pc(t):(e=nx(u,o,s),t.stateNode=e,sl(t))}return Et(t),null;case 5:if(Fe(t),u=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==o&&sl(t);else{if(!o){if(t.stateNode===null)throw Error(r(166));return Et(t),null}if(m=we.current,Qs(t))Pc(t);else{var S=bu(ze.current);switch(m){case 1:m=S.createElementNS("http://www.w3.org/2000/svg",u);break;case 2:m=S.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;default:switch(u){case"svg":m=S.createElementNS("http://www.w3.org/2000/svg",u);break;case"math":m=S.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;case"script":m=S.createElement("div"),m.innerHTML="<script><\/script>",m=m.removeChild(m.firstChild);break;case"select":m=typeof o.is=="string"?S.createElement("select",{is:o.is}):S.createElement("select"),o.multiple?m.multiple=!0:o.size&&(m.size=o.size);break;default:m=typeof o.is=="string"?S.createElement(u,{is:o.is}):S.createElement(u)}}m[X]=t,m[Se]=o;e:for(S=t.child;S!==null;){if(S.tag===5||S.tag===6)m.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===t)break e;for(;S.sibling===null;){if(S.return===null||S.return===t)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}t.stateNode=m;e:switch(En(m,u,o),u){case"button":case"input":case"select":case"textarea":o=!!o.autoFocus;break e;case"img":o=!0;break e;default:o=!1}o&&sl(t)}}return Et(t),Af(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,s),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==o&&sl(t);else{if(typeof o!="string"&&t.stateNode===null)throw Error(r(166));if(e=ze.current,Qs(t)){if(e=t.stateNode,s=t.memoizedProps,o=null,u=gn,u!==null)switch(u.tag){case 27:case 5:o=u.memoizedProps}e[X]=t,e=!!(e.nodeValue===s||o!==null&&o.suppressHydrationWarning===!0||Gg(e.nodeValue,s)),e||Ts(t,!0)}else e=bu(e).createTextNode(o),e[X]=t,t.stateNode=e}return Et(t),null;case 31:if(s=t.memoizedState,e===null||e.memoizedState!==null){if(o=Qs(t),s!==null){if(e===null){if(!o)throw Error(r(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(r(557));e[X]=t}else ms(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Et(t),e=!1}else s=fo(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=s),e=!0;if(!e)return t.flags&256?(Na(t),t):(Na(t),null);if((t.flags&128)!==0)throw Error(r(558))}return Et(t),null;case 13:if(o=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(u=Qs(t),o!==null&&o.dehydrated!==null){if(e===null){if(!u)throw Error(r(318));if(u=t.memoizedState,u=u!==null?u.dehydrated:null,!u)throw Error(r(317));u[X]=t}else ms(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Et(t),u=!1}else u=fo(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=u),u=!0;if(!u)return t.flags&256?(Na(t),t):(Na(t),null)}return Na(t),(t.flags&128)!==0?(t.lanes=s,t):(s=o!==null,e=e!==null&&e.memoizedState!==null,s&&(o=t.child,u=null,o.alternate!==null&&o.alternate.memoizedState!==null&&o.alternate.memoizedState.cachePool!==null&&(u=o.alternate.memoizedState.cachePool.pool),m=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(m=o.memoizedState.cachePool.pool),m!==u&&(o.flags|=2048)),s!==e&&s&&(t.child.flags|=8192),iu(t,t.updateQueue),Et(t),null);case 4:return He(),e===null&&Wf(t.stateNode.containerInfo),Et(t),null;case 10:return ia(t.type),Et(t),null;case 19:if($(Jt),o=t.memoizedState,o===null)return Et(t),null;if(u=(t.flags&128)!==0,m=o.rendering,m===null)if(u)jo(o,!1);else{if(Pt!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(m=Vc(e),m!==null){for(t.flags|=128,jo(o,!1),e=m.updateQueue,t.updateQueue=e,iu(t,e),t.subtreeFlags=0,e=s,s=t.child;s!==null;)rn(s,e),s=s.sibling;return ie(Jt,Jt.current&1|2),it&&fs(t,o.treeForkCount),t.child}e=e.sibling}o.tail!==null&&Oe()>du&&(t.flags|=128,u=!0,jo(o,!1),t.lanes=4194304)}else{if(!u)if(e=Vc(m),e!==null){if(t.flags|=128,u=!0,e=e.updateQueue,t.updateQueue=e,iu(t,e),jo(o,!0),o.tail===null&&o.tailMode==="hidden"&&!m.alternate&&!it)return Et(t),null}else 2*Oe()-o.renderingStartTime>du&&s!==536870912&&(t.flags|=128,u=!0,jo(o,!1),t.lanes=4194304);o.isBackwards?(m.sibling=t.child,t.child=m):(e=o.last,e!==null?e.sibling=m:t.child=m,o.last=m)}return o.tail!==null?(e=o.tail,o.rendering=e,o.tail=e.sibling,o.renderingStartTime=Oe(),e.sibling=null,s=Jt.current,ie(Jt,u?s&1|2:s&1),it&&fs(t,o.treeForkCount),e):(Et(t),null);case 22:case 23:return Na(t),Wd(),o=t.memoizedState!==null,e!==null?e.memoizedState!==null!==o&&(t.flags|=8192):o&&(t.flags|=8192),o?(s&536870912)!==0&&(t.flags&128)===0&&(Et(t),t.subtreeFlags&6&&(t.flags|=8192)):Et(t),s=t.updateQueue,s!==null&&iu(t,s.retryQueue),s=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(s=e.memoizedState.cachePool.pool),o=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(o=t.memoizedState.cachePool.pool),o!==s&&(t.flags|=2048),e!==null&&$(y),null;case 24:return s=null,e!==null&&(s=e.memoizedState.cache),t.memoizedState.cache!==s&&(t.flags|=2048),ia(Ht),Et(t),null;case 25:return null;case 30:return null}throw Error(r(156,t.tag))}function Ow(e,t){switch(Ai(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ia(Ht),He(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Fe(t),null;case 31:if(t.memoizedState!==null){if(Na(t),t.alternate===null)throw Error(r(340));ms()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Na(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));ms()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return $(Jt),null;case 4:return He(),null;case 10:return ia(t.type),null;case 22:case 23:return Na(t),Wd(),e!==null&&$(y),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return ia(Ht),null;case 25:return null;default:return null}}function Qp(e,t){switch(Ai(t),t.tag){case 3:ia(Ht),He();break;case 26:case 27:case 5:Fe(t);break;case 4:He();break;case 31:t.memoizedState!==null&&Na(t);break;case 13:Na(t);break;case 19:$(Jt);break;case 10:ia(t.type);break;case 22:case 23:Na(t),Wd(),e!==null&&$(y);break;case 24:ia(Ht)}}function ko(e,t){try{var s=t.updateQueue,o=s!==null?s.lastEffect:null;if(o!==null){var u=o.next;s=u;do{if((s.tag&e)===e){o=void 0;var m=s.create,S=s.inst;o=m(),S.destroy=o}s=s.next}while(s!==u)}}catch(N){bt(t,t.return,N)}}function Hl(e,t,s){try{var o=t.updateQueue,u=o!==null?o.lastEffect:null;if(u!==null){var m=u.next;o=m;do{if((o.tag&e)===e){var S=o.inst,N=S.destroy;if(N!==void 0){S.destroy=void 0,u=t;var I=s,te=N;try{te()}catch(fe){bt(u,I,fe)}}}o=o.next}while(o!==m)}}catch(fe){bt(t,t.return,fe)}}function Xp(e){var t=e.updateQueue;if(t!==null){var s=e.stateNode;try{$h(t,s)}catch(o){bt(e,e.return,o)}}}function Zp(e,t,s){s.props=_i(e.type,e.memoizedProps),s.state=e.memoizedState;try{s.componentWillUnmount()}catch(o){bt(e,t,o)}}function Mo(e,t){try{var s=e.ref;if(s!==null){switch(e.tag){case 26:case 27:case 5:var o=e.stateNode;break;case 30:o=e.stateNode;break;default:o=e.stateNode}typeof s=="function"?e.refCleanup=s(o):s.current=o}}catch(u){bt(e,t,u)}}function Rs(e,t){var s=e.ref,o=e.refCleanup;if(s!==null)if(typeof o=="function")try{o()}catch(u){bt(e,t,u)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof s=="function")try{s(null)}catch(u){bt(e,t,u)}else s.current=null}function Jp(e){var t=e.type,s=e.memoizedProps,o=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":s.autoFocus&&o.focus();break e;case"img":s.src?o.src=s.src:s.srcSet&&(o.srcset=s.srcSet)}}catch(u){bt(e,e.return,u)}}function Nf(e,t,s){try{var o=e.stateNode;sb(o,e.type,s,t),o[Se]=t}catch(u){bt(e,e.return,u)}}function eg(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Vl(e.type)||e.tag===4}function Tf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||eg(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Vl(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Rf(e,t,s){var o=e.tag;if(o===5||o===6)e=e.stateNode,t?(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s).insertBefore(e,t):(t=s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,t.appendChild(e),s=s._reactRootContainer,s!=null||t.onclick!==null||(t.onclick=Xn));else if(o!==4&&(o===27&&Vl(e.type)&&(s=e.stateNode,t=null),e=e.child,e!==null))for(Rf(e,t,s),e=e.sibling;e!==null;)Rf(e,t,s),e=e.sibling}function ru(e,t,s){var o=e.tag;if(o===5||o===6)e=e.stateNode,t?s.insertBefore(e,t):s.appendChild(e);else if(o!==4&&(o===27&&Vl(e.type)&&(s=e.stateNode),e=e.child,e!==null))for(ru(e,t,s),e=e.sibling;e!==null;)ru(e,t,s),e=e.sibling}function tg(e){var t=e.stateNode,s=e.memoizedProps;try{for(var o=e.type,u=t.attributes;u.length;)t.removeAttributeNode(u[0]);En(t,o,s),t[X]=e,t[Se]=s}catch(m){bt(e,e.return,m)}}var ll=!1,dn=!1,Ef=!1,ng=typeof WeakSet=="function"?WeakSet:Set,bn=null;function Iw(e,t){if(e=e.containerInfo,Zf=Nu,e=ka(e),yi(e)){if("selectionStart"in e)var s={start:e.selectionStart,end:e.selectionEnd};else e:{s=(s=e.ownerDocument)&&s.defaultView||window;var o=s.getSelection&&s.getSelection();if(o&&o.rangeCount!==0){s=o.anchorNode;var u=o.anchorOffset,m=o.focusNode;o=o.focusOffset;try{s.nodeType,m.nodeType}catch{s=null;break e}var S=0,N=-1,I=-1,te=0,fe=0,ve=e,ae=null;t:for(;;){for(var re;ve!==s||u!==0&&ve.nodeType!==3||(N=S+u),ve!==m||o!==0&&ve.nodeType!==3||(I=S+o),ve.nodeType===3&&(S+=ve.nodeValue.length),(re=ve.firstChild)!==null;)ae=ve,ve=re;for(;;){if(ve===e)break t;if(ae===s&&++te===u&&(N=S),ae===m&&++fe===o&&(I=S),(re=ve.nextSibling)!==null)break;ve=ae,ae=ve.parentNode}ve=re}s=N===-1||I===-1?null:{start:N,end:I}}else s=null}s=s||{start:0,end:0}}else s=null;for(Jf={focusedElem:e,selectionRange:s},Nu=!1,bn=t;bn!==null;)if(t=bn,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,bn=e;else for(;bn!==null;){switch(t=bn,m=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(s=0;s<e.length;s++)u=e[s],u.ref.impl=u.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&m!==null){e=void 0,s=t,u=m.memoizedProps,m=m.memoizedState,o=s.stateNode;try{var _e=_i(s.type,u);e=o.getSnapshotBeforeUpdate(_e,m),o.__reactInternalSnapshotBeforeUpdate=e}catch(Ge){bt(s,s.return,Ge)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,s=e.nodeType,s===9)nm(e);else if(s===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":nm(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(r(163))}if(e=t.sibling,e!==null){e.return=t.return,bn=e;break}bn=t.return}}function ag(e,t,s){var o=s.flags;switch(s.tag){case 0:case 11:case 15:rl(e,s),o&4&&ko(5,s);break;case 1:if(rl(e,s),o&4)if(e=s.stateNode,t===null)try{e.componentDidMount()}catch(S){bt(s,s.return,S)}else{var u=_i(s.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(u,t,e.__reactInternalSnapshotBeforeUpdate)}catch(S){bt(s,s.return,S)}}o&64&&Xp(s),o&512&&Mo(s,s.return);break;case 3:if(rl(e,s),o&64&&(e=s.updateQueue,e!==null)){if(t=null,s.child!==null)switch(s.child.tag){case 27:case 5:t=s.child.stateNode;break;case 1:t=s.child.stateNode}try{$h(e,t)}catch(S){bt(s,s.return,S)}}break;case 27:t===null&&o&4&&tg(s);case 26:case 5:rl(e,s),t===null&&o&4&&Jp(s),o&512&&Mo(s,s.return);break;case 12:rl(e,s);break;case 31:rl(e,s),o&4&&ig(e,s);break;case 13:rl(e,s),o&4&&rg(e,s),o&64&&(e=s.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(s=Yw.bind(null,s),fb(e,s))));break;case 22:if(o=s.memoizedState!==null||ll,!o){t=t!==null&&t.memoizedState!==null||dn,u=ll;var m=dn;ll=o,(dn=t)&&!m?ol(e,s,(s.subtreeFlags&8772)!==0):rl(e,s),ll=u,dn=m}break;case 30:break;default:rl(e,s)}}function sg(e){var t=e.alternate;t!==null&&(e.alternate=null,sg(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Rt(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var zt=null,ca=!1;function il(e,t,s){for(s=s.child;s!==null;)lg(e,t,s),s=s.sibling}function lg(e,t,s){if(Je&&typeof Je.onCommitFiberUnmount=="function")try{Je.onCommitFiberUnmount(_a,s)}catch{}switch(s.tag){case 26:dn||Rs(s,t),il(e,t,s),s.memoizedState?s.memoizedState.count--:s.stateNode&&(s=s.stateNode,s.parentNode.removeChild(s));break;case 27:dn||Rs(s,t);var o=zt,u=ca;Vl(s.type)&&(zt=s.stateNode,ca=!1),il(e,t,s),_o(s.stateNode),zt=o,ca=u;break;case 5:dn||Rs(s,t);case 6:if(o=zt,u=ca,zt=null,il(e,t,s),zt=o,ca=u,zt!==null)if(ca)try{(zt.nodeType===9?zt.body:zt.nodeName==="HTML"?zt.ownerDocument.body:zt).removeChild(s.stateNode)}catch(m){bt(s,t,m)}else try{zt.removeChild(s.stateNode)}catch(m){bt(s,t,m)}break;case 18:zt!==null&&(ca?(e=zt,Xg(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,s.stateNode),Dr(e)):Xg(zt,s.stateNode));break;case 4:o=zt,u=ca,zt=s.stateNode.containerInfo,ca=!0,il(e,t,s),zt=o,ca=u;break;case 0:case 11:case 14:case 15:Hl(2,s,t),dn||Hl(4,s,t),il(e,t,s);break;case 1:dn||(Rs(s,t),o=s.stateNode,typeof o.componentWillUnmount=="function"&&Zp(s,t,o)),il(e,t,s);break;case 21:il(e,t,s);break;case 22:dn=(o=dn)||s.memoizedState!==null,il(e,t,s),dn=o;break;default:il(e,t,s)}}function ig(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Dr(e)}catch(s){bt(t,t.return,s)}}}function rg(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Dr(e)}catch(s){bt(t,t.return,s)}}function Bw(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new ng),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new ng),t;default:throw Error(r(435,e.tag))}}function ou(e,t){var s=Bw(e);t.forEach(function(o){if(!s.has(o)){s.add(o);var u=Vw.bind(null,e,o);o.then(u,u)}})}function ua(e,t){var s=t.deletions;if(s!==null)for(var o=0;o<s.length;o++){var u=s[o],m=e,S=t,N=S;e:for(;N!==null;){switch(N.tag){case 27:if(Vl(N.type)){zt=N.stateNode,ca=!1;break e}break;case 5:zt=N.stateNode,ca=!1;break e;case 3:case 4:zt=N.stateNode.containerInfo,ca=!0;break e}N=N.return}if(zt===null)throw Error(r(160));lg(m,S,u),zt=null,ca=!1,m=u.alternate,m!==null&&(m.return=null),u.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)og(t,e),t=t.sibling}var xs=null;function og(e,t){var s=e.alternate,o=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:ua(t,e),da(e),o&4&&(Hl(3,e,e.return),ko(3,e),Hl(5,e,e.return));break;case 1:ua(t,e),da(e),o&512&&(dn||s===null||Rs(s,s.return)),o&64&&ll&&(e=e.updateQueue,e!==null&&(o=e.callbacks,o!==null&&(s=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=s===null?o:s.concat(o))));break;case 26:var u=xs;if(ua(t,e),da(e),o&512&&(dn||s===null||Rs(s,s.return)),o&4){var m=s!==null?s.memoizedState:null;if(o=e.memoizedState,s===null)if(o===null)if(e.stateNode===null){e:{o=e.type,s=e.memoizedProps,u=u.ownerDocument||u;t:switch(o){case"title":m=u.getElementsByTagName("title")[0],(!m||m[at]||m[X]||m.namespaceURI==="http://www.w3.org/2000/svg"||m.hasAttribute("itemprop"))&&(m=u.createElement(o),u.head.insertBefore(m,u.querySelector("head > title"))),En(m,o,s),m[X]=e,vt(m),o=m;break e;case"link":var S=ox("link","href",u).get(o+(s.href||""));if(S){for(var N=0;N<S.length;N++)if(m=S[N],m.getAttribute("href")===(s.href==null||s.href===""?null:s.href)&&m.getAttribute("rel")===(s.rel==null?null:s.rel)&&m.getAttribute("title")===(s.title==null?null:s.title)&&m.getAttribute("crossorigin")===(s.crossOrigin==null?null:s.crossOrigin)){S.splice(N,1);break t}}m=u.createElement(o),En(m,o,s),u.head.appendChild(m);break;case"meta":if(S=ox("meta","content",u).get(o+(s.content||""))){for(N=0;N<S.length;N++)if(m=S[N],m.getAttribute("content")===(s.content==null?null:""+s.content)&&m.getAttribute("name")===(s.name==null?null:s.name)&&m.getAttribute("property")===(s.property==null?null:s.property)&&m.getAttribute("http-equiv")===(s.httpEquiv==null?null:s.httpEquiv)&&m.getAttribute("charset")===(s.charSet==null?null:s.charSet)){S.splice(N,1);break t}}m=u.createElement(o),En(m,o,s),u.head.appendChild(m);break;default:throw Error(r(468,o))}m[X]=e,vt(m),o=m}e.stateNode=o}else cx(u,e.type,e.stateNode);else e.stateNode=rx(u,o,e.memoizedProps);else m!==o?(m===null?s.stateNode!==null&&(s=s.stateNode,s.parentNode.removeChild(s)):m.count--,o===null?cx(u,e.type,e.stateNode):rx(u,o,e.memoizedProps)):o===null&&e.stateNode!==null&&Nf(e,e.memoizedProps,s.memoizedProps)}break;case 27:ua(t,e),da(e),o&512&&(dn||s===null||Rs(s,s.return)),s!==null&&o&4&&Nf(e,e.memoizedProps,s.memoizedProps);break;case 5:if(ua(t,e),da(e),o&512&&(dn||s===null||Rs(s,s.return)),e.flags&32){u=e.stateNode;try{Is(u,"")}catch(_e){bt(e,e.return,_e)}}o&4&&e.stateNode!=null&&(u=e.memoizedProps,Nf(e,u,s!==null?s.memoizedProps:u)),o&1024&&(Ef=!0);break;case 6:if(ua(t,e),da(e),o&4){if(e.stateNode===null)throw Error(r(162));o=e.memoizedProps,s=e.stateNode;try{s.nodeValue=o}catch(_e){bt(e,e.return,_e)}}break;case 3:if(ju=null,u=xs,xs=Su(t.containerInfo),ua(t,e),xs=u,da(e),o&4&&s!==null&&s.memoizedState.isDehydrated)try{Dr(t.containerInfo)}catch(_e){bt(e,e.return,_e)}Ef&&(Ef=!1,cg(e));break;case 4:o=xs,xs=Su(e.stateNode.containerInfo),ua(t,e),da(e),xs=o;break;case 12:ua(t,e),da(e);break;case 31:ua(t,e),da(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,ou(e,o)));break;case 13:ua(t,e),da(e),e.child.flags&8192&&e.memoizedState!==null!=(s!==null&&s.memoizedState!==null)&&(uu=Oe()),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,ou(e,o)));break;case 22:u=e.memoizedState!==null;var I=s!==null&&s.memoizedState!==null,te=ll,fe=dn;if(ll=te||u,dn=fe||I,ua(t,e),dn=fe,ll=te,da(e),o&8192)e:for(t=e.stateNode,t._visibility=u?t._visibility&-2:t._visibility|1,u&&(s===null||I||ll||dn||Oi(e)),s=null,t=e;;){if(t.tag===5||t.tag===26){if(s===null){I=s=t;try{if(m=I.stateNode,u)S=m.style,typeof S.setProperty=="function"?S.setProperty("display","none","important"):S.display="none";else{N=I.stateNode;var ve=I.memoizedProps.style,ae=ve!=null&&ve.hasOwnProperty("display")?ve.display:null;N.style.display=ae==null||typeof ae=="boolean"?"":(""+ae).trim()}}catch(_e){bt(I,I.return,_e)}}}else if(t.tag===6){if(s===null){I=t;try{I.stateNode.nodeValue=u?"":I.memoizedProps}catch(_e){bt(I,I.return,_e)}}}else if(t.tag===18){if(s===null){I=t;try{var re=I.stateNode;u?Zg(re,!0):Zg(I.stateNode,!1)}catch(_e){bt(I,I.return,_e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;s===t&&(s=null),t=t.return}s===t&&(s=null),t.sibling.return=t.return,t=t.sibling}o&4&&(o=e.updateQueue,o!==null&&(s=o.retryQueue,s!==null&&(o.retryQueue=null,ou(e,s))));break;case 19:ua(t,e),da(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,ou(e,o)));break;case 30:break;case 21:break;default:ua(t,e),da(e)}}function da(e){var t=e.flags;if(t&2){try{for(var s,o=e.return;o!==null;){if(eg(o)){s=o;break}o=o.return}if(s==null)throw Error(r(160));switch(s.tag){case 27:var u=s.stateNode,m=Tf(e);ru(e,m,u);break;case 5:var S=s.stateNode;s.flags&32&&(Is(S,""),s.flags&=-33);var N=Tf(e);ru(e,N,S);break;case 3:case 4:var I=s.stateNode.containerInfo,te=Tf(e);Rf(e,te,I);break;default:throw Error(r(161))}}catch(fe){bt(e,e.return,fe)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function cg(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;cg(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function rl(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)ag(e,t.alternate,t),t=t.sibling}function Oi(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Hl(4,t,t.return),Oi(t);break;case 1:Rs(t,t.return);var s=t.stateNode;typeof s.componentWillUnmount=="function"&&Zp(t,t.return,s),Oi(t);break;case 27:_o(t.stateNode);case 26:case 5:Rs(t,t.return),Oi(t);break;case 22:t.memoizedState===null&&Oi(t);break;case 30:Oi(t);break;default:Oi(t)}e=e.sibling}}function ol(e,t,s){for(s=s&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var o=t.alternate,u=e,m=t,S=m.flags;switch(m.tag){case 0:case 11:case 15:ol(u,m,s),ko(4,m);break;case 1:if(ol(u,m,s),o=m,u=o.stateNode,typeof u.componentDidMount=="function")try{u.componentDidMount()}catch(te){bt(o,o.return,te)}if(o=m,u=o.updateQueue,u!==null){var N=o.stateNode;try{var I=u.shared.hiddenCallbacks;if(I!==null)for(u.shared.hiddenCallbacks=null,u=0;u<I.length;u++)Hh(I[u],N)}catch(te){bt(o,o.return,te)}}s&&S&64&&Xp(m),Mo(m,m.return);break;case 27:tg(m);case 26:case 5:ol(u,m,s),s&&o===null&&S&4&&Jp(m),Mo(m,m.return);break;case 12:ol(u,m,s);break;case 31:ol(u,m,s),s&&S&4&&ig(u,m);break;case 13:ol(u,m,s),s&&S&4&&rg(u,m);break;case 22:m.memoizedState===null&&ol(u,m,s),Mo(m,m.return);break;case 30:break;default:ol(u,m,s)}t=t.sibling}}function Df(e,t){var s=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(s=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==s&&(e!=null&&e.refCount++,s!=null&&Ri(s))}function Lf(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Ri(e))}function vs(e,t,s,o){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)ug(e,t,s,o),t=t.sibling}function ug(e,t,s,o){var u=t.flags;switch(t.tag){case 0:case 11:case 15:vs(e,t,s,o),u&2048&&ko(9,t);break;case 1:vs(e,t,s,o);break;case 3:vs(e,t,s,o),u&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Ri(e)));break;case 12:if(u&2048){vs(e,t,s,o),e=t.stateNode;try{var m=t.memoizedProps,S=m.id,N=m.onPostCommit;typeof N=="function"&&N(S,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(I){bt(t,t.return,I)}}else vs(e,t,s,o);break;case 31:vs(e,t,s,o);break;case 13:vs(e,t,s,o);break;case 23:break;case 22:m=t.stateNode,S=t.alternate,t.memoizedState!==null?m._visibility&2?vs(e,t,s,o):Ao(e,t):m._visibility&2?vs(e,t,s,o):(m._visibility|=2,br(e,t,s,o,(t.subtreeFlags&10256)!==0||!1)),u&2048&&Df(S,t);break;case 24:vs(e,t,s,o),u&2048&&Lf(t.alternate,t);break;default:vs(e,t,s,o)}}function br(e,t,s,o,u){for(u=u&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var m=e,S=t,N=s,I=o,te=S.flags;switch(S.tag){case 0:case 11:case 15:br(m,S,N,I,u),ko(8,S);break;case 23:break;case 22:var fe=S.stateNode;S.memoizedState!==null?fe._visibility&2?br(m,S,N,I,u):Ao(m,S):(fe._visibility|=2,br(m,S,N,I,u)),u&&te&2048&&Df(S.alternate,S);break;case 24:br(m,S,N,I,u),u&&te&2048&&Lf(S.alternate,S);break;default:br(m,S,N,I,u)}t=t.sibling}}function Ao(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var s=e,o=t,u=o.flags;switch(o.tag){case 22:Ao(s,o),u&2048&&Df(o.alternate,o);break;case 24:Ao(s,o),u&2048&&Lf(o.alternate,o);break;default:Ao(s,o)}t=t.sibling}}var No=8192;function Sr(e,t,s){if(e.subtreeFlags&No)for(e=e.child;e!==null;)dg(e,t,s),e=e.sibling}function dg(e,t,s){switch(e.tag){case 26:Sr(e,t,s),e.flags&No&&e.memoizedState!==null&&jb(s,xs,e.memoizedState,e.memoizedProps);break;case 5:Sr(e,t,s);break;case 3:case 4:var o=xs;xs=Su(e.stateNode.containerInfo),Sr(e,t,s),xs=o;break;case 22:e.memoizedState===null&&(o=e.alternate,o!==null&&o.memoizedState!==null?(o=No,No=16777216,Sr(e,t,s),No=o):Sr(e,t,s));break;default:Sr(e,t,s)}}function fg(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function To(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var s=0;s<t.length;s++){var o=t[s];bn=o,hg(o,e)}fg(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)mg(e),e=e.sibling}function mg(e){switch(e.tag){case 0:case 11:case 15:To(e),e.flags&2048&&Hl(9,e,e.return);break;case 3:To(e);break;case 12:To(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,cu(e)):To(e);break;default:To(e)}}function cu(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var s=0;s<t.length;s++){var o=t[s];bn=o,hg(o,e)}fg(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Hl(8,t,t.return),cu(t);break;case 22:s=t.stateNode,s._visibility&2&&(s._visibility&=-3,cu(t));break;default:cu(t)}e=e.sibling}}function hg(e,t){for(;bn!==null;){var s=bn;switch(s.tag){case 0:case 11:case 15:Hl(8,s,t);break;case 23:case 22:if(s.memoizedState!==null&&s.memoizedState.cachePool!==null){var o=s.memoizedState.cachePool.pool;o!=null&&o.refCount++}break;case 24:Ri(s.memoizedState.cache)}if(o=s.child,o!==null)o.return=s,bn=o;else e:for(s=e;bn!==null;){o=bn;var u=o.sibling,m=o.return;if(sg(o),o===s){bn=null;break e}if(u!==null){u.return=m,bn=u;break e}bn=m}}}var Fw={getCacheForType:function(e){var t=on(Ht),s=t.data.get(e);return s===void 0&&(s=e(),t.data.set(e,s)),s},cacheSignal:function(){return on(Ht).controller.signal}},Hw=typeof WeakMap=="function"?WeakMap:Map,gt=0,Mt=null,rt=null,dt=0,wt=0,Ta=null,$l=!1,Cr=!1,zf=!1,cl=0,Pt=0,Ul=0,Ii=0,_f=0,Ra=0,jr=0,Ro=null,fa=null,Of=!1,uu=0,pg=0,du=1/0,fu=null,Pl=null,vn=0,ql=null,kr=null,ul=0,If=0,Bf=null,gg=null,Eo=0,Ff=null;function Ea(){return(gt&2)!==0&&dt!==0?dt&-dt:z.T!==null?Gf():as()}function xg(){if(Ra===0)if((dt&536870912)===0||it){var e=Ja;Ja<<=1,(Ja&3932160)===0&&(Ja=262144),Ra=e}else Ra=536870912;return e=Aa.current,e!==null&&(e.flags|=32),Ra}function ma(e,t,s){(e===Mt&&(wt===2||wt===9)||e.cancelPendingCommit!==null)&&(Mr(e,0),Gl(e,dt,Ra,!1)),Ba(e,s),((gt&2)===0||e!==Mt)&&(e===Mt&&((gt&2)===0&&(Ii|=s),Pt===4&&Gl(e,dt,Ra,!1)),Es(e))}function vg(e,t,s){if((gt&6)!==0)throw Error(r(327));var o=!s&&(t&127)===0&&(t&e.expiredLanes)===0||Hn(e,t),u=o?Pw(e,t):$f(e,t,!0),m=o;do{if(u===0){Cr&&!o&&Gl(e,t,0,!1);break}else{if(s=e.current.alternate,m&&!$w(s)){u=$f(e,t,!1),m=!1;continue}if(u===2){if(m=t,e.errorRecoveryDisabledLanes&m)var S=0;else S=e.pendingLanes&-536870913,S=S!==0?S:S&536870912?536870912:0;if(S!==0){t=S;e:{var N=e;u=Ro;var I=N.current.memoizedState.isDehydrated;if(I&&(Mr(N,S).flags|=256),S=$f(N,S,!1),S!==2){if(zf&&!I){N.errorRecoveryDisabledLanes|=m,Ii|=m,u=4;break e}m=fa,fa=u,m!==null&&(fa===null?fa=m:fa.push.apply(fa,m))}u=S}if(m=!1,u!==2)continue}}if(u===1){Mr(e,0),Gl(e,t,0,!0);break}e:{switch(o=e,m=u,m){case 0:case 1:throw Error(r(345));case 4:if((t&4194048)!==t)break;case 6:Gl(o,t,Ra,!$l);break e;case 2:fa=null;break;case 3:case 5:break;default:throw Error(r(329))}if((t&62914560)===t&&(u=uu+300-Oe(),10<u)){if(Gl(o,t,Ra,!$l),ln(o,0,!0)!==0)break e;ul=t,o.timeoutHandle=Wg(yg.bind(null,o,s,fa,fu,Of,t,Ra,Ii,jr,$l,m,"Throttled",-0,0),u);break e}yg(o,s,fa,fu,Of,t,Ra,Ii,jr,$l,m,null,-0,0)}}break}while(!0);Es(e)}function yg(e,t,s,o,u,m,S,N,I,te,fe,ve,ae,re){if(e.timeoutHandle=-1,ve=t.subtreeFlags,ve&8192||(ve&16785408)===16785408){ve={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Xn},dg(t,m,ve);var _e=(m&62914560)===m?uu-Oe():(m&4194048)===m?pg-Oe():0;if(_e=kb(ve,_e),_e!==null){ul=m,e.cancelPendingCommit=_e(Ag.bind(null,e,t,m,s,o,u,S,N,I,fe,ve,null,ae,re)),Gl(e,m,S,!te);return}}Ag(e,t,m,s,o,u,S,N,I)}function $w(e){for(var t=e;;){var s=t.tag;if((s===0||s===11||s===15)&&t.flags&16384&&(s=t.updateQueue,s!==null&&(s=s.stores,s!==null)))for(var o=0;o<s.length;o++){var u=s[o],m=u.getSnapshot;u=u.value;try{if(!zn(m(),u))return!1}catch{return!1}}if(s=t.child,t.subtreeFlags&16384&&s!==null)s.return=t,t=s;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Gl(e,t,s,o){t&=~_f,t&=~Ii,e.suspendedLanes|=t,e.pingedLanes&=~t,o&&(e.warmLanes|=t),o=e.expirationTimes;for(var u=t;0<u;){var m=31-qt(u),S=1<<m;o[m]=-1,u&=~S}s!==0&&ts(e,s,t)}function mu(){return(gt&6)===0?(Do(0),!1):!0}function Hf(){if(rt!==null){if(wt===0)var e=rt.return;else e=rt,hs=Ya=null,tf(e),oa=null,gs=0,e=rt;for(;e!==null;)Qp(e.alternate,e),e=e.return;rt=null}}function Mr(e,t){var s=e.timeoutHandle;s!==-1&&(e.timeoutHandle=-1,rb(s)),s=e.cancelPendingCommit,s!==null&&(e.cancelPendingCommit=null,s()),ul=0,Hf(),Mt=e,rt=s=ta(e.current,null),dt=t,wt=0,Ta=null,$l=!1,Cr=Hn(e,t),zf=!1,jr=Ra=_f=Ii=Ul=Pt=0,fa=Ro=null,Of=!1,(t&8)!==0&&(t|=t&32);var o=e.entangledLanes;if(o!==0)for(e=e.entanglements,o&=t;0<o;){var u=31-qt(o),m=1<<u;t|=e[u],o&=~m}return cl=t,dr(),s}function wg(e,t){tt=null,z.H=So,t===O||t===xe?(t=ra(),wt=3):t===pe?(t=ra(),wt=4):wt=t===vf?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,Ta=t,rt===null&&(Pt=1,nu(e,na(t,e.current)))}function bg(){var e=Aa.current;return e===null?!0:(dt&4194048)===dt?Va===null:(dt&62914560)===dt||(dt&536870912)!==0?e===Va:!1}function Sg(){var e=z.H;return z.H=So,e===null?So:e}function Cg(){var e=z.A;return z.A=Fw,e}function hu(){Pt=4,$l||(dt&4194048)!==dt&&Aa.current!==null||(Cr=!0),(Ul&134217727)===0&&(Ii&134217727)===0||Mt===null||Gl(Mt,dt,Ra,!1)}function $f(e,t,s){var o=gt;gt|=2;var u=Sg(),m=Cg();(Mt!==e||dt!==t)&&(fu=null,Mr(e,t)),t=!1;var S=Pt;e:do try{if(wt!==0&&rt!==null){var N=rt,I=Ta;switch(wt){case 8:Hf(),S=6;break e;case 3:case 2:case 9:case 6:Aa.current===null&&(t=!0);var te=wt;if(wt=0,Ta=null,Ar(e,N,I,te),s&&Cr){S=0;break e}break;default:te=wt,wt=0,Ta=null,Ar(e,N,I,te)}}Uw(),S=Pt;break}catch(fe){wg(e,fe)}while(!0);return t&&e.shellSuspendCounter++,hs=Ya=null,gt=o,z.H=u,z.A=m,rt===null&&(Mt=null,dt=0,dr()),S}function Uw(){for(;rt!==null;)jg(rt)}function Pw(e,t){var s=gt;gt|=2;var o=Sg(),u=Cg();Mt!==e||dt!==t?(fu=null,du=Oe()+500,Mr(e,t)):Cr=Hn(e,t);e:do try{if(wt!==0&&rt!==null){t=rt;var m=Ta;t:switch(wt){case 1:wt=0,Ta=null,Ar(e,t,m,1);break;case 2:case 9:if(Ve(m)){wt=0,Ta=null,kg(t);break}t=function(){wt!==2&&wt!==9||Mt!==e||(wt=7),Es(e)},m.then(t,t);break e;case 3:wt=7;break e;case 4:wt=5;break e;case 7:Ve(m)?(wt=0,Ta=null,kg(t)):(wt=0,Ta=null,Ar(e,t,m,7));break;case 5:var S=null;switch(rt.tag){case 26:S=rt.memoizedState;case 5:case 27:var N=rt;if(S?ux(S):N.stateNode.complete){wt=0,Ta=null;var I=N.sibling;if(I!==null)rt=I;else{var te=N.return;te!==null?(rt=te,pu(te)):rt=null}break t}}wt=0,Ta=null,Ar(e,t,m,5);break;case 6:wt=0,Ta=null,Ar(e,t,m,6);break;case 8:Hf(),Pt=6;break e;default:throw Error(r(462))}}qw();break}catch(fe){wg(e,fe)}while(!0);return hs=Ya=null,z.H=o,z.A=u,gt=s,rt!==null?0:(Mt=null,dt=0,dr(),Pt)}function qw(){for(;rt!==null&&!ke();)jg(rt)}function jg(e){var t=Kp(e.alternate,e,cl);e.memoizedProps=e.pendingProps,t===null?pu(e):rt=t}function kg(e){var t=e,s=t.alternate;switch(t.tag){case 15:case 0:t=Up(s,t,t.pendingProps,t.type,void 0,dt);break;case 11:t=Up(s,t,t.pendingProps,t.type.render,t.ref,dt);break;case 5:tf(t);default:Qp(s,t),t=rt=rn(t,cl),t=Kp(s,t,cl)}e.memoizedProps=e.pendingProps,t===null?pu(e):rt=t}function Ar(e,t,s,o){hs=Ya=null,tf(t),oa=null,gs=0;var u=t.return;try{if(Dw(e,u,t,s,dt)){Pt=1,nu(e,na(s,e.current)),rt=null;return}}catch(m){if(u!==null)throw rt=u,m;Pt=1,nu(e,na(s,e.current)),rt=null;return}t.flags&32768?(it||o===1?e=!0:Cr||(dt&536870912)!==0?e=!1:($l=e=!0,(o===2||o===9||o===3||o===6)&&(o=Aa.current,o!==null&&o.tag===13&&(o.flags|=16384))),Mg(t,e)):pu(t)}function pu(e){var t=e;do{if((t.flags&32768)!==0){Mg(t,$l);return}e=t.return;var s=_w(t.alternate,t,cl);if(s!==null){rt=s;return}if(t=t.sibling,t!==null){rt=t;return}rt=t=e}while(t!==null);Pt===0&&(Pt=5)}function Mg(e,t){do{var s=Ow(e.alternate,e);if(s!==null){s.flags&=32767,rt=s;return}if(s=e.return,s!==null&&(s.flags|=32768,s.subtreeFlags=0,s.deletions=null),!t&&(e=e.sibling,e!==null)){rt=e;return}rt=e=s}while(e!==null);Pt=6,rt=null}function Ag(e,t,s,o,u,m,S,N,I){e.cancelPendingCommit=null;do gu();while(vn!==0);if((gt&6)!==0)throw Error(r(327));if(t!==null){if(t===e.current)throw Error(r(177));if(m=t.lanes|t.childLanes,m|=Nl,Ss(e,s,m,S,N,I),e===Mt&&(rt=Mt=null,dt=0),kr=t,ql=e,ul=s,If=m,Bf=u,gg=o,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,Kw(Gn,function(){return Dg(),null})):(e.callbackNode=null,e.callbackPriority=0),o=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||o){o=z.T,z.T=null,u=Y.p,Y.p=2,S=gt,gt|=4;try{Iw(e,t,s)}finally{gt=S,Y.p=u,z.T=o}}vn=1,Ng(),Tg(),Rg()}}function Ng(){if(vn===1){vn=0;var e=ql,t=kr,s=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||s){s=z.T,z.T=null;var o=Y.p;Y.p=2;var u=gt;gt|=4;try{og(t,e);var m=Jf,S=ka(e.containerInfo),N=m.focusedElem,I=m.selectionRange;if(S!==N&&N&&N.ownerDocument&&kl(N.ownerDocument.documentElement,N)){if(I!==null&&yi(N)){var te=I.start,fe=I.end;if(fe===void 0&&(fe=te),"selectionStart"in N)N.selectionStart=te,N.selectionEnd=Math.min(fe,N.value.length);else{var ve=N.ownerDocument||document,ae=ve&&ve.defaultView||window;if(ae.getSelection){var re=ae.getSelection(),_e=N.textContent.length,Ge=Math.min(I.start,_e),jt=I.end===void 0?Ge:Math.min(I.end,_e);!re.extend&&Ge>jt&&(S=jt,jt=Ge,Ge=S);var V=vi(N,Ge),P=vi(N,jt);if(V&&P&&(re.rangeCount!==1||re.anchorNode!==V.node||re.anchorOffset!==V.offset||re.focusNode!==P.node||re.focusOffset!==P.offset)){var ee=ve.createRange();ee.setStart(V.node,V.offset),re.removeAllRanges(),Ge>jt?(re.addRange(ee),re.extend(P.node,P.offset)):(ee.setEnd(P.node,P.offset),re.addRange(ee))}}}}for(ve=[],re=N;re=re.parentNode;)re.nodeType===1&&ve.push({element:re,left:re.scrollLeft,top:re.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;N<ve.length;N++){var ge=ve[N];ge.element.scrollLeft=ge.left,ge.element.scrollTop=ge.top}}Nu=!!Zf,Jf=Zf=null}finally{gt=u,Y.p=o,z.T=s}}e.current=t,vn=2}}function Tg(){if(vn===2){vn=0;var e=ql,t=kr,s=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||s){s=z.T,z.T=null;var o=Y.p;Y.p=2;var u=gt;gt|=4;try{ag(e,t.alternate,t)}finally{gt=u,Y.p=o,z.T=s}}vn=3}}function Rg(){if(vn===4||vn===3){vn=0,Ne();var e=ql,t=kr,s=ul,o=gg;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?vn=5:(vn=0,kr=ql=null,Eg(e,e.pendingLanes));var u=e.pendingLanes;if(u===0&&(Pl=null),ns(s),t=t.stateNode,Je&&typeof Je.onCommitFiberRoot=="function")try{Je.onCommitFiberRoot(_a,t,void 0,(t.current.flags&128)===128)}catch{}if(o!==null){t=z.T,u=Y.p,Y.p=2,z.T=null;try{for(var m=e.onRecoverableError,S=0;S<o.length;S++){var N=o[S];m(N.value,{componentStack:N.stack})}}finally{z.T=t,Y.p=u}}(ul&3)!==0&&gu(),Es(e),u=e.pendingLanes,(s&261930)!==0&&(u&42)!==0?e===Ff?Eo++:(Eo=0,Ff=e):Eo=0,Do(0)}}function Eg(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Ri(t)))}function gu(){return Ng(),Tg(),Rg(),Dg()}function Dg(){if(vn!==5)return!1;var e=ql,t=If;If=0;var s=ns(ul),o=z.T,u=Y.p;try{Y.p=32>s?32:s,z.T=null,s=Bf,Bf=null;var m=ql,S=ul;if(vn=0,kr=ql=null,ul=0,(gt&6)!==0)throw Error(r(331));var N=gt;if(gt|=4,mg(m.current),ug(m,m.current,S,s),gt=N,Do(0,!1),Je&&typeof Je.onPostCommitFiberRoot=="function")try{Je.onPostCommitFiberRoot(_a,m)}catch{}return!0}finally{Y.p=u,z.T=o,Eg(e,t)}}function Lg(e,t,s){t=na(s,t),t=xf(e.stateNode,t,2),e=Il(e,t,2),e!==null&&(Ba(e,2),Es(e))}function bt(e,t,s){if(e.tag===3)Lg(e,e,s);else for(;t!==null;){if(t.tag===3){Lg(t,e,s);break}else if(t.tag===1){var o=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(Pl===null||!Pl.has(o))){e=na(s,e),s=zp(2),o=Il(t,s,2),o!==null&&(_p(s,o,t,e),Ba(o,2),Es(o));break}}t=t.return}}function Uf(e,t,s){var o=e.pingCache;if(o===null){o=e.pingCache=new Hw;var u=new Set;o.set(t,u)}else u=o.get(t),u===void 0&&(u=new Set,o.set(t,u));u.has(s)||(zf=!0,u.add(s),e=Gw.bind(null,e,t,s),t.then(e,e))}function Gw(e,t,s){var o=e.pingCache;o!==null&&o.delete(t),e.pingedLanes|=e.suspendedLanes&s,e.warmLanes&=~s,Mt===e&&(dt&s)===s&&(Pt===4||Pt===3&&(dt&62914560)===dt&&300>Oe()-uu?(gt&2)===0&&Mr(e,0):_f|=s,jr===dt&&(jr=0)),Es(e)}function zg(e,t){t===0&&(t=gl()),e=Ce(e,t),e!==null&&(Ba(e,t),Es(e))}function Yw(e){var t=e.memoizedState,s=0;t!==null&&(s=t.retryLane),zg(e,s)}function Vw(e,t){var s=0;switch(e.tag){case 31:case 13:var o=e.stateNode,u=e.memoizedState;u!==null&&(s=u.retryLane);break;case 19:o=e.stateNode;break;case 22:o=e.stateNode._retryCache;break;default:throw Error(r(314))}o!==null&&o.delete(t),zg(e,s)}function Kw(e,t){return ct(e,t)}var xu=null,Nr=null,Pf=!1,vu=!1,qf=!1,Yl=0;function Es(e){e!==Nr&&e.next===null&&(Nr===null?xu=Nr=e:Nr=Nr.next=e),vu=!0,Pf||(Pf=!0,Qw())}function Do(e,t){if(!qf&&vu){qf=!0;do for(var s=!1,o=xu;o!==null;){if(e!==0){var u=o.pendingLanes;if(u===0)var m=0;else{var S=o.suspendedLanes,N=o.pingedLanes;m=(1<<31-qt(42|e)+1)-1,m&=u&~(S&~N),m=m&201326741?m&201326741|1:m?m|2:0}m!==0&&(s=!0,Bg(o,m))}else m=dt,m=ln(o,o===Mt?m:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),(m&3)===0||Hn(o,m)||(s=!0,Bg(o,m));o=o.next}while(s);qf=!1}}function Ww(){_g()}function _g(){vu=Pf=!1;var e=0;Yl!==0&&ib()&&(e=Yl);for(var t=Oe(),s=null,o=xu;o!==null;){var u=o.next,m=Og(o,t);m===0?(o.next=null,s===null?xu=u:s.next=u,u===null&&(Nr=s)):(s=o,(e!==0||(m&3)!==0)&&(vu=!0)),o=u}vn!==0&&vn!==5||Do(e),Yl!==0&&(Yl=0)}function Og(e,t){for(var s=e.suspendedLanes,o=e.pingedLanes,u=e.expirationTimes,m=e.pendingLanes&-62914561;0<m;){var S=31-qt(m),N=1<<S,I=u[S];I===-1?((N&s)===0||(N&o)!==0)&&(u[S]=Yn(N,t)):I<=t&&(e.expiredLanes|=N),m&=~N}if(t=Mt,s=dt,s=ln(e,e===t?s:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o=e.callbackNode,s===0||e===t&&(wt===2||wt===9)||e.cancelPendingCommit!==null)return o!==null&&o!==null&&sn(o),e.callbackNode=null,e.callbackPriority=0;if((s&3)===0||Hn(e,s)){if(t=s&-s,t===e.callbackPriority)return t;switch(o!==null&&sn(o),ns(s)){case 2:case 8:s=Nt;break;case 32:s=Gn;break;case 268435456:s=Te;break;default:s=Gn}return o=Ig.bind(null,e),s=ct(s,o),e.callbackPriority=t,e.callbackNode=s,t}return o!==null&&o!==null&&sn(o),e.callbackPriority=2,e.callbackNode=null,2}function Ig(e,t){if(vn!==0&&vn!==5)return e.callbackNode=null,e.callbackPriority=0,null;var s=e.callbackNode;if(gu()&&e.callbackNode!==s)return null;var o=dt;return o=ln(e,e===Mt?o:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o===0?null:(vg(e,o,t),Og(e,Oe()),e.callbackNode!=null&&e.callbackNode===s?Ig.bind(null,e):null)}function Bg(e,t){if(gu())return null;vg(e,t,!0)}function Qw(){ob(function(){(gt&6)!==0?ct(Za,Ww):_g()})}function Gf(){if(Yl===0){var e=xn;e===0&&(e=Oa,Oa<<=1,(Oa&261888)===0&&(Oa=256)),Yl=e}return Yl}function Fg(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Sa(""+e)}function Hg(e,t){var s=t.ownerDocument.createElement("input");return s.name=t.name,s.value=t.value,e.id&&s.setAttribute("form",e.id),t.parentNode.insertBefore(s,t),e=new FormData(e),s.parentNode.removeChild(s),e}function Xw(e,t,s,o,u){if(t==="submit"&&s&&s.stateNode===u){var m=Fg((u[Se]||null).action),S=o.submitter;S&&(t=(t=S[Se]||null)?Fg(t.formAction):S.getAttribute("formAction"),t!==null&&(m=t,S=null));var N=new Hs("action","action",null,o,u);e.push({event:N,listeners:[{instance:null,listener:function(){if(o.defaultPrevented){if(Yl!==0){var I=S?Hg(u,S):new FormData(u);df(s,{pending:!0,data:I,method:u.method,action:m},null,I)}}else typeof m=="function"&&(N.preventDefault(),I=S?Hg(u,S):new FormData(u),df(s,{pending:!0,data:I,method:u.method,action:m},m,I))},currentTarget:u}]})}}for(var Yf=0;Yf<cr.length;Yf++){var Vf=cr[Yf],Zw=Vf.toLowerCase(),Jw=Vf[0].toUpperCase()+Vf.slice(1);ea(Zw,"on"+Jw)}ea(Al,"onAnimationEnd"),ea(so,"onAnimationIteration"),ea(or,"onAnimationStart"),ea("dblclick","onDoubleClick"),ea("focusin","onFocus"),ea("focusout","onBlur"),ea(Ic,"onTransitionRun"),ea(Fd,"onTransitionStart"),ea(lo,"onTransitionCancel"),ea(Bc,"onTransitionEnd"),It("onMouseEnter",["mouseout","mouseover"]),It("onMouseLeave",["mouseout","mouseover"]),It("onPointerEnter",["pointerout","pointerover"]),It("onPointerLeave",["pointerout","pointerover"]),Vt("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Vt("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Vt("onBeforeInput",["compositionend","keypress","textInput","paste"]),Vt("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Vt("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Vt("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Lo="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(" "),eb=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Lo));function $g(e,t){t=(t&4)!==0;for(var s=0;s<e.length;s++){var o=e[s],u=o.event;o=o.listeners;e:{var m=void 0;if(t)for(var S=o.length-1;0<=S;S--){var N=o[S],I=N.instance,te=N.currentTarget;if(N=N.listener,I!==m&&u.isPropagationStopped())break e;m=N,u.currentTarget=te;try{m(u)}catch(fe){ur(fe)}u.currentTarget=null,m=I}else for(S=0;S<o.length;S++){if(N=o[S],I=N.instance,te=N.currentTarget,N=N.listener,I!==m&&u.isPropagationStopped())break e;m=N,u.currentTarget=te;try{m(u)}catch(fe){ur(fe)}u.currentTarget=null,m=I}}}}function ot(e,t){var s=t[Ze];s===void 0&&(s=t[Ze]=new Set);var o=e+"__bubble";s.has(o)||(Ug(t,e,2,!1),s.add(o))}function Kf(e,t,s){var o=0;t&&(o|=4),Ug(s,e,o,t)}var yu="_reactListening"+Math.random().toString(36).slice(2);function Wf(e){if(!e[yu]){e[yu]=!0,Wn.forEach(function(s){s!=="selectionchange"&&(eb.has(s)||Kf(s,!1,e),Kf(s,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[yu]||(t[yu]=!0,Kf("selectionchange",!1,t))}}function Ug(e,t,s,o){switch(xx(t)){case 2:var u=Nb;break;case 8:u=Tb;break;default:u=um}s=u.bind(null,t,s,e),u=void 0,!$a||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(u=!0),o?u!==void 0?e.addEventListener(t,s,{capture:!0,passive:u}):e.addEventListener(t,s,!0):u!==void 0?e.addEventListener(t,s,{passive:u}):e.addEventListener(t,s,!1)}function Qf(e,t,s,o,u){var m=o;if((t&1)===0&&(t&2)===0&&o!==null)e:for(;;){if(o===null)return;var S=o.tag;if(S===3||S===4){var N=o.stateNode.containerInfo;if(N===u)break;if(S===4)for(S=o.return;S!==null;){var I=S.tag;if((I===3||I===4)&&S.stateNode.containerInfo===u)return;S=S.return}for(;N!==null;){if(S=_t(N),S===null)return;if(I=S.tag,I===5||I===6||I===26||I===27){o=m=S;continue e}N=N.parentNode}}o=o.return}lt(function(){var te=m,fe=Zi(s),ve=[];e:{var ae=io.get(e);if(ae!==void 0){var re=Hs,_e=e;switch(e){case"keypress":if(yl(s)===0)break e;case"keydown":case"keyup":re=zd;break;case"focusin":_e="focus",re=os;break;case"focusout":_e="blur",re=os;break;case"beforeblur":case"afterblur":re=os;break;case"click":if(s.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":re=wl;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":re=Ac;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":re=Zt;break;case Al:case so:case or:re=Dd;break;case Bc:re=us;break;case"scroll":case"scrollend":re=Mc;break;case"wheel":re=Id;break;case"copy":case"cut":case"paste":re=bl;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":re=Us;break;case"toggle":case"beforetoggle":re=ar}var Ge=(t&4)!==0,jt=!Ge&&(e==="scroll"||e==="scrollend"),V=Ge?ae!==null?ae+"Capture":null:ae;Ge=[];for(var P=te,ee;P!==null;){var ge=P;if(ee=ge.stateNode,ge=ge.tag,ge!==5&&ge!==26&&ge!==27||ee===null||V===null||(ge=An(P,V),ge!=null&&Ge.push(zo(P,ge,ee))),jt)break;P=P.return}0<Ge.length&&(ae=new re(ae,_e,null,s,fe),ve.push({event:ae,listeners:Ge}))}}if((t&7)===0){e:{if(ae=e==="mouseover"||e==="pointerover",re=e==="mouseout"||e==="pointerout",ae&&s!==Xi&&(_e=s.relatedTarget||s.fromElement)&&(_t(_e)||_e[De]))break e;if((re||ae)&&(ae=fe.window===fe?fe:(ae=fe.ownerDocument)?ae.defaultView||ae.parentWindow:window,re?(_e=s.relatedTarget||s.toElement,re=te,_e=_e?_t(_e):null,_e!==null&&(jt=d(_e),Ge=_e.tag,_e!==jt||Ge!==5&&Ge!==27&&Ge!==6)&&(_e=null)):(re=null,_e=te),re!==_e)){if(Ge=wl,ge="onMouseLeave",V="onMouseEnter",P="mouse",(e==="pointerout"||e==="pointerover")&&(Ge=Us,ge="onPointerLeave",V="onPointerEnter",P="pointer"),jt=re==null?ae:xt(re),ee=_e==null?ae:xt(_e),ae=new Ge(ge,P+"leave",re,s,fe),ae.target=jt,ae.relatedTarget=ee,ge=null,_t(fe)===te&&(Ge=new Ge(V,P+"enter",_e,s,fe),Ge.target=ee,Ge.relatedTarget=jt,ge=Ge),jt=ge,re&&_e)t:{for(Ge=tb,V=re,P=_e,ee=0,ge=V;ge;ge=Ge(ge))ee++;ge=0;for(var $e=P;$e;$e=Ge($e))ge++;for(;0<ee-ge;)V=Ge(V),ee--;for(;0<ge-ee;)P=Ge(P),ge--;for(;ee--;){if(V===P||P!==null&&V===P.alternate){Ge=V;break t}V=Ge(V),P=Ge(P)}Ge=null}else Ge=null;re!==null&&Pg(ve,ae,re,Ge,!1),_e!==null&&jt!==null&&Pg(ve,jt,_e,Ge,!0)}}e:{if(ae=te?xt(te):window,re=ae.nodeName&&ae.nodeName.toLowerCase(),re==="select"||re==="input"&&ae.type==="file")var ht=Zr;else if(ds(ae))if(lr)ht=rr;else{ht=eo;var Ie=Jr}else re=ae.nodeName,!re||re.toLowerCase()!=="input"||ae.type!=="checkbox"&&ae.type!=="radio"?te&&ui(te.elementType)&&(ht=Zr):ht=ir;if(ht&&(ht=ht(e,te))){hi(ve,ht,s,fe);break e}Ie&&Ie(e,ae,te),e==="focusout"&&te&&ae.type==="number"&&te.memoizedProps.value!=null&&bc(ae,"number",ae.value)}switch(Ie=te?xt(te):window,e){case"focusin":(ds(Ie)||Ie.contentEditable==="true")&&(Ys=Ie,pn=te,Ml=null);break;case"focusout":Ml=pn=Ys=null;break;case"mousedown":wi=!0;break;case"contextmenu":case"mouseup":case"dragend":wi=!1,bi(ve,s,fe);break;case"selectionchange":if(no)break;case"keydown":case"keyup":bi(ve,s,fe)}var st;if(js)e:{switch(e){case"compositionstart":var ft="onCompositionStart";break e;case"compositionend":ft="onCompositionEnd";break e;case"compositionupdate":ft="onCompositionUpdate";break e}ft=void 0}else jl?Qr(e,s)&&(ft="onCompositionEnd"):e==="keydown"&&s.keyCode===229&&(ft="onCompositionStart");ft&&(Dc&&s.locale!=="ko"&&(jl||ft!=="onCompositionStart"?ft==="onCompositionEnd"&&jl&&(st=vl()):(is=fe,Vr="value"in is?is.value:is.textContent,jl=!0)),Ie=wu(te,ft),0<Ie.length&&(ft=new Wr(ft,e,null,s,fe),ve.push({event:ft,listeners:Ie}),st?ft.data=st:(st=zc(s),st!==null&&(ft.data=st)))),(st=Ec?Bd(e,s):_c(e,s))&&(ft=wu(te,"onBeforeInput"),0<ft.length&&(Ie=new Wr("onBeforeInput","beforeinput",null,s,fe),ve.push({event:Ie,listeners:ft}),Ie.data=st)),Xw(ve,e,te,s,fe)}$g(ve,t)})}function zo(e,t,s){return{instance:e,listener:t,currentTarget:s}}function wu(e,t){for(var s=t+"Capture",o=[];e!==null;){var u=e,m=u.stateNode;if(u=u.tag,u!==5&&u!==26&&u!==27||m===null||(u=An(e,s),u!=null&&o.unshift(zo(e,u,m)),u=An(e,t),u!=null&&o.push(zo(e,u,m))),e.tag===3)return o;e=e.return}return[]}function tb(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Pg(e,t,s,o,u){for(var m=t._reactName,S=[];s!==null&&s!==o;){var N=s,I=N.alternate,te=N.stateNode;if(N=N.tag,I!==null&&I===o)break;N!==5&&N!==26&&N!==27||te===null||(I=te,u?(te=An(s,m),te!=null&&S.unshift(zo(s,te,I))):u||(te=An(s,m),te!=null&&S.push(zo(s,te,I)))),s=s.return}S.length!==0&&e.push({event:t,listeners:S})}var nb=/\r\n?/g,ab=/\u0000|\uFFFD/g;function qg(e){return(typeof e=="string"?e:""+e).replace(nb,`
|
|
9
|
-
`).replace(ab,"")}function Gg(e,t){return t=qg(t),qg(e)===t}function Ct(e,t,s,o,u,m){switch(s){case"children":typeof o=="string"?t==="body"||t==="textarea"&&o===""||Is(e,o):(typeof o=="number"||typeof o=="bigint")&&t!=="body"&&Is(e,""+o);break;case"className":ba(e,"class",o);break;case"tabIndex":ba(e,"tabindex",o);break;case"dir":case"role":case"viewBox":case"width":case"height":ba(e,s,o);break;case"style":jc(e,o,m);break;case"data":if(t!=="object"){ba(e,"data",o);break}case"src":case"href":if(o===""&&(t!=="a"||s!=="href")){e.removeAttribute(s);break}if(o==null||typeof o=="function"||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(s);break}o=Sa(""+o),e.setAttribute(s,o);break;case"action":case"formAction":if(typeof o=="function"){e.setAttribute(s,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof m=="function"&&(s==="formAction"?(t!=="input"&&Ct(e,t,"name",u.name,u,null),Ct(e,t,"formEncType",u.formEncType,u,null),Ct(e,t,"formMethod",u.formMethod,u,null),Ct(e,t,"formTarget",u.formTarget,u,null)):(Ct(e,t,"encType",u.encType,u,null),Ct(e,t,"method",u.method,u,null),Ct(e,t,"target",u.target,u,null)));if(o==null||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(s);break}o=Sa(""+o),e.setAttribute(s,o);break;case"onClick":o!=null&&(e.onclick=Xn);break;case"onScroll":o!=null&&ot("scroll",e);break;case"onScrollEnd":o!=null&&ot("scrollend",e);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(r(61));if(s=o.__html,s!=null){if(u.children!=null)throw Error(r(60));e.innerHTML=s}}break;case"multiple":e.multiple=o&&typeof o!="function"&&typeof o!="symbol";break;case"muted":e.muted=o&&typeof o!="function"&&typeof o!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(o==null||typeof o=="function"||typeof o=="boolean"||typeof o=="symbol"){e.removeAttribute("xlink:href");break}s=Sa(""+o),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",s);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":o!=null&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(s,""+o):e.removeAttribute(s);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":o&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(s,""):e.removeAttribute(s);break;case"capture":case"download":o===!0?e.setAttribute(s,""):o!==!1&&o!=null&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(s,o):e.removeAttribute(s);break;case"cols":case"rows":case"size":case"span":o!=null&&typeof o!="function"&&typeof o!="symbol"&&!isNaN(o)&&1<=o?e.setAttribute(s,o):e.removeAttribute(s);break;case"rowSpan":case"start":o==null||typeof o=="function"||typeof o=="symbol"||isNaN(o)?e.removeAttribute(s):e.setAttribute(s,o);break;case"popover":ot("beforetoggle",e),ot("toggle",e),ri(e,"popover",o);break;case"xlinkActuate":Mn(e,"http://www.w3.org/1999/xlink","xlink:actuate",o);break;case"xlinkArcrole":Mn(e,"http://www.w3.org/1999/xlink","xlink:arcrole",o);break;case"xlinkRole":Mn(e,"http://www.w3.org/1999/xlink","xlink:role",o);break;case"xlinkShow":Mn(e,"http://www.w3.org/1999/xlink","xlink:show",o);break;case"xlinkTitle":Mn(e,"http://www.w3.org/1999/xlink","xlink:title",o);break;case"xlinkType":Mn(e,"http://www.w3.org/1999/xlink","xlink:type",o);break;case"xmlBase":Mn(e,"http://www.w3.org/XML/1998/namespace","xml:base",o);break;case"xmlLang":Mn(e,"http://www.w3.org/XML/1998/namespace","xml:lang",o);break;case"xmlSpace":Mn(e,"http://www.w3.org/XML/1998/namespace","xml:space",o);break;case"is":ri(e,"is",o);break;case"innerText":case"textContent":break;default:(!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(s=kc.get(s)||s,ri(e,s,o))}}function Xf(e,t,s,o,u,m){switch(s){case"style":jc(e,o,m);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(r(61));if(s=o.__html,s!=null){if(u.children!=null)throw Error(r(60));e.innerHTML=s}}break;case"children":typeof o=="string"?Is(e,o):(typeof o=="number"||typeof o=="bigint")&&Is(e,""+o);break;case"onScroll":o!=null&&ot("scroll",e);break;case"onScrollEnd":o!=null&&ot("scrollend",e);break;case"onClick":o!=null&&(e.onclick=Xn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Qn.hasOwnProperty(s))e:{if(s[0]==="o"&&s[1]==="n"&&(u=s.endsWith("Capture"),t=s.slice(2,u?s.length-7:void 0),m=e[Se]||null,m=m!=null?m[s]:null,typeof m=="function"&&e.removeEventListener(t,m,u),typeof o=="function")){typeof m!="function"&&m!==null&&(s in e?e[s]=null:e.hasAttribute(s)&&e.removeAttribute(s)),e.addEventListener(t,o,u);break e}s in e?e[s]=o:o===!0?e.setAttribute(s,""):ri(e,s,o)}}}function En(e,t,s){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":ot("error",e),ot("load",e);var o=!1,u=!1,m;for(m in s)if(s.hasOwnProperty(m)){var S=s[m];if(S!=null)switch(m){case"src":o=!0;break;case"srcSet":u=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,t));default:Ct(e,t,m,S,s,null)}}u&&Ct(e,t,"srcSet",s.srcSet,s,null),o&&Ct(e,t,"src",s.src,s,null);return;case"input":ot("invalid",e);var N=m=S=u=null,I=null,te=null;for(o in s)if(s.hasOwnProperty(o)){var fe=s[o];if(fe!=null)switch(o){case"name":u=fe;break;case"type":S=fe;break;case"checked":I=fe;break;case"defaultChecked":te=fe;break;case"value":m=fe;break;case"defaultValue":N=fe;break;case"children":case"dangerouslySetInnerHTML":if(fe!=null)throw Error(r(137,t));break;default:Ct(e,t,o,fe,s,null)}}Td(e,m,N,I,te,S,u,!1);return;case"select":ot("invalid",e),o=S=m=null;for(u in s)if(s.hasOwnProperty(u)&&(N=s[u],N!=null))switch(u){case"value":m=N;break;case"defaultValue":S=N;break;case"multiple":o=N;default:Ct(e,t,u,N,s,null)}t=m,s=S,e.multiple=!!o,t!=null?ci(e,!!o,t,!1):s!=null&&ci(e,!!o,s,!0);return;case"textarea":ot("invalid",e),m=u=o=null;for(S in s)if(s.hasOwnProperty(S)&&(N=s[S],N!=null))switch(S){case"value":o=N;break;case"defaultValue":u=N;break;case"children":m=N;break;case"dangerouslySetInnerHTML":if(N!=null)throw Error(r(91));break;default:Ct(e,t,S,N,s,null)}Gr(e,o,u,m);return;case"option":for(I in s)s.hasOwnProperty(I)&&(o=s[I],o!=null)&&(I==="selected"?e.selected=o&&typeof o!="function"&&typeof o!="symbol":Ct(e,t,I,o,s,null));return;case"dialog":ot("beforetoggle",e),ot("toggle",e),ot("cancel",e),ot("close",e);break;case"iframe":case"object":ot("load",e);break;case"video":case"audio":for(o=0;o<Lo.length;o++)ot(Lo[o],e);break;case"image":ot("error",e),ot("load",e);break;case"details":ot("toggle",e);break;case"embed":case"source":case"link":ot("error",e),ot("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(te in s)if(s.hasOwnProperty(te)&&(o=s[te],o!=null))switch(te){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,t));default:Ct(e,t,te,o,s,null)}return;default:if(ui(t)){for(fe in s)s.hasOwnProperty(fe)&&(o=s[fe],o!==void 0&&Xf(e,t,fe,o,s,void 0));return}}for(N in s)s.hasOwnProperty(N)&&(o=s[N],o!=null&&Ct(e,t,N,o,s,null))}function sb(e,t,s,o){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var u=null,m=null,S=null,N=null,I=null,te=null,fe=null;for(re in s){var ve=s[re];if(s.hasOwnProperty(re)&&ve!=null)switch(re){case"checked":break;case"value":break;case"defaultValue":I=ve;default:o.hasOwnProperty(re)||Ct(e,t,re,null,o,ve)}}for(var ae in o){var re=o[ae];if(ve=s[ae],o.hasOwnProperty(ae)&&(re!=null||ve!=null))switch(ae){case"type":m=re;break;case"name":u=re;break;case"checked":te=re;break;case"defaultChecked":fe=re;break;case"value":S=re;break;case"defaultValue":N=re;break;case"children":case"dangerouslySetInnerHTML":if(re!=null)throw Error(r(137,t));break;default:re!==ve&&Ct(e,t,ae,re,o,ve)}}oi(e,S,N,I,te,fe,m,u);return;case"select":re=S=N=ae=null;for(m in s)if(I=s[m],s.hasOwnProperty(m)&&I!=null)switch(m){case"value":break;case"multiple":re=I;default:o.hasOwnProperty(m)||Ct(e,t,m,null,o,I)}for(u in o)if(m=o[u],I=s[u],o.hasOwnProperty(u)&&(m!=null||I!=null))switch(u){case"value":ae=m;break;case"defaultValue":N=m;break;case"multiple":S=m;default:m!==I&&Ct(e,t,u,m,o,I)}t=N,s=S,o=re,ae!=null?ci(e,!!s,ae,!1):!!o!=!!s&&(t!=null?ci(e,!!s,t,!0):ci(e,!!s,s?[]:"",!1));return;case"textarea":re=ae=null;for(N in s)if(u=s[N],s.hasOwnProperty(N)&&u!=null&&!o.hasOwnProperty(N))switch(N){case"value":break;case"children":break;default:Ct(e,t,N,null,o,u)}for(S in o)if(u=o[S],m=s[S],o.hasOwnProperty(S)&&(u!=null||m!=null))switch(S){case"value":ae=u;break;case"defaultValue":re=u;break;case"children":break;case"dangerouslySetInnerHTML":if(u!=null)throw Error(r(91));break;default:u!==m&&Ct(e,t,S,u,o,m)}Sc(e,ae,re);return;case"option":for(var _e in s)ae=s[_e],s.hasOwnProperty(_e)&&ae!=null&&!o.hasOwnProperty(_e)&&(_e==="selected"?e.selected=!1:Ct(e,t,_e,null,o,ae));for(I in o)ae=o[I],re=s[I],o.hasOwnProperty(I)&&ae!==re&&(ae!=null||re!=null)&&(I==="selected"?e.selected=ae&&typeof ae!="function"&&typeof ae!="symbol":Ct(e,t,I,ae,o,re));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 Ge in s)ae=s[Ge],s.hasOwnProperty(Ge)&&ae!=null&&!o.hasOwnProperty(Ge)&&Ct(e,t,Ge,null,o,ae);for(te in o)if(ae=o[te],re=s[te],o.hasOwnProperty(te)&&ae!==re&&(ae!=null||re!=null))switch(te){case"children":case"dangerouslySetInnerHTML":if(ae!=null)throw Error(r(137,t));break;default:Ct(e,t,te,ae,o,re)}return;default:if(ui(t)){for(var jt in s)ae=s[jt],s.hasOwnProperty(jt)&&ae!==void 0&&!o.hasOwnProperty(jt)&&Xf(e,t,jt,void 0,o,ae);for(fe in o)ae=o[fe],re=s[fe],!o.hasOwnProperty(fe)||ae===re||ae===void 0&&re===void 0||Xf(e,t,fe,ae,o,re);return}}for(var V in s)ae=s[V],s.hasOwnProperty(V)&&ae!=null&&!o.hasOwnProperty(V)&&Ct(e,t,V,null,o,ae);for(ve in o)ae=o[ve],re=s[ve],!o.hasOwnProperty(ve)||ae===re||ae==null&&re==null||Ct(e,t,ve,ae,o,re)}function Yg(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function lb(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,s=performance.getEntriesByType("resource"),o=0;o<s.length;o++){var u=s[o],m=u.transferSize,S=u.initiatorType,N=u.duration;if(m&&N&&Yg(S)){for(S=0,N=u.responseEnd,o+=1;o<s.length;o++){var I=s[o],te=I.startTime;if(te>N)break;var fe=I.transferSize,ve=I.initiatorType;fe&&Yg(ve)&&(I=I.responseEnd,S+=fe*(I<N?1:(N-te)/(I-te)))}if(--o,t+=8*(m+S)/(u.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var Zf=null,Jf=null;function bu(e){return e.nodeType===9?e:e.ownerDocument}function Vg(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Kg(e,t){if(e===0)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&t==="foreignObject"?0:e}function em(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.children=="bigint"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var tm=null;function ib(){var e=window.event;return e&&e.type==="popstate"?e===tm?!1:(tm=e,!0):(tm=null,!1)}var Wg=typeof setTimeout=="function"?setTimeout:void 0,rb=typeof clearTimeout=="function"?clearTimeout:void 0,Qg=typeof Promise=="function"?Promise:void 0,ob=typeof queueMicrotask=="function"?queueMicrotask:typeof Qg<"u"?function(e){return Qg.resolve(null).then(e).catch(cb)}:Wg;function cb(e){setTimeout(function(){throw e})}function Vl(e){return e==="head"}function Xg(e,t){var s=t,o=0;do{var u=s.nextSibling;if(e.removeChild(s),u&&u.nodeType===8)if(s=u.data,s==="/$"||s==="/&"){if(o===0){e.removeChild(u),Dr(t);return}o--}else if(s==="$"||s==="$?"||s==="$~"||s==="$!"||s==="&")o++;else if(s==="html")_o(e.ownerDocument.documentElement);else if(s==="head"){s=e.ownerDocument.head,_o(s);for(var m=s.firstChild;m;){var S=m.nextSibling,N=m.nodeName;m[at]||N==="SCRIPT"||N==="STYLE"||N==="LINK"&&m.rel.toLowerCase()==="stylesheet"||s.removeChild(m),m=S}}else s==="body"&&_o(e.ownerDocument.body);s=u}while(s);Dr(t)}function Zg(e,t){var s=e;e=0;do{var o=s.nextSibling;if(s.nodeType===1?t?(s._stashedDisplay=s.style.display,s.style.display="none"):(s.style.display=s._stashedDisplay||"",s.getAttribute("style")===""&&s.removeAttribute("style")):s.nodeType===3&&(t?(s._stashedText=s.nodeValue,s.nodeValue=""):s.nodeValue=s._stashedText||""),o&&o.nodeType===8)if(s=o.data,s==="/$"){if(e===0)break;e--}else s!=="$"&&s!=="$?"&&s!=="$~"&&s!=="$!"||e++;s=o}while(s)}function nm(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var s=t;switch(t=t.nextSibling,s.nodeName){case"HTML":case"HEAD":case"BODY":nm(s),Rt(s);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(s.rel.toLowerCase()==="stylesheet")continue}e.removeChild(s)}}function ub(e,t,s,o){for(;e.nodeType===1;){var u=s;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!o&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(o){if(!e[at])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(m=e.getAttribute("rel"),m==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(m!==u.rel||e.getAttribute("href")!==(u.href==null||u.href===""?null:u.href)||e.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin)||e.getAttribute("title")!==(u.title==null?null:u.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(m=e.getAttribute("src"),(m!==(u.src==null?null:u.src)||e.getAttribute("type")!==(u.type==null?null:u.type)||e.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin))&&m&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(t==="input"&&e.type==="hidden"){var m=u.name==null?null:""+u.name;if(u.type==="hidden"&&e.getAttribute("name")===m)return e}else return e;if(e=Ka(e.nextSibling),e===null)break}return null}function db(e,t,s){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!s||(e=Ka(e.nextSibling),e===null))return null;return e}function Jg(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=Ka(e.nextSibling),e===null))return null;return e}function am(e){return e.data==="$?"||e.data==="$~"}function sm(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function fb(e,t){var s=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||s.readyState!=="loading")t();else{var o=function(){t(),s.removeEventListener("DOMContentLoaded",o)};s.addEventListener("DOMContentLoaded",o),e._reactRetry=o}}function Ka(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?"||t==="$~"||t==="&"||t==="F!"||t==="F")break;if(t==="/$"||t==="/&")return null}}return e}var lm=null;function ex(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="/$"||s==="/&"){if(t===0)return Ka(e.nextSibling);t--}else s!=="$"&&s!=="$!"&&s!=="$?"&&s!=="$~"&&s!=="&"||t++}e=e.nextSibling}return null}function tx(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="$"||s==="$!"||s==="$?"||s==="$~"||s==="&"){if(t===0)return e;t--}else s!=="/$"&&s!=="/&"||t++}e=e.previousSibling}return null}function nx(e,t,s){switch(t=bu(s),e){case"html":if(e=t.documentElement,!e)throw Error(r(452));return e;case"head":if(e=t.head,!e)throw Error(r(453));return e;case"body":if(e=t.body,!e)throw Error(r(454));return e;default:throw Error(r(451))}}function _o(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Rt(e)}var Wa=new Map,ax=new Set;function Su(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var dl=Y.d;Y.d={f:mb,r:hb,D:pb,C:gb,L:xb,m:vb,X:wb,S:yb,M:bb};function mb(){var e=dl.f(),t=mu();return e||t}function hb(e){var t=Yt(e);t!==null&&t.tag===5&&t.type==="form"?wp(t):dl.r(e)}var Tr=typeof document>"u"?null:document;function sx(e,t,s){var o=Tr;if(o&&typeof t=="string"&&t){var u=mn(t);u='link[rel="'+e+'"][href="'+u+'"]',typeof s=="string"&&(u+='[crossorigin="'+s+'"]'),ax.has(u)||(ax.add(u),e={rel:e,crossOrigin:s,href:t},o.querySelector(u)===null&&(t=o.createElement("link"),En(t,"link",e),vt(t),o.head.appendChild(t)))}}function pb(e){dl.D(e),sx("dns-prefetch",e,null)}function gb(e,t){dl.C(e,t),sx("preconnect",e,t)}function xb(e,t,s){dl.L(e,t,s);var o=Tr;if(o&&e&&t){var u='link[rel="preload"][as="'+mn(t)+'"]';t==="image"&&s&&s.imageSrcSet?(u+='[imagesrcset="'+mn(s.imageSrcSet)+'"]',typeof s.imageSizes=="string"&&(u+='[imagesizes="'+mn(s.imageSizes)+'"]')):u+='[href="'+mn(e)+'"]';var m=u;switch(t){case"style":m=Rr(e);break;case"script":m=Er(e)}Wa.has(m)||(e=v({rel:"preload",href:t==="image"&&s&&s.imageSrcSet?void 0:e,as:t},s),Wa.set(m,e),o.querySelector(u)!==null||t==="style"&&o.querySelector(Oo(m))||t==="script"&&o.querySelector(Io(m))||(t=o.createElement("link"),En(t,"link",e),vt(t),o.head.appendChild(t)))}}function vb(e,t){dl.m(e,t);var s=Tr;if(s&&e){var o=t&&typeof t.as=="string"?t.as:"script",u='link[rel="modulepreload"][as="'+mn(o)+'"][href="'+mn(e)+'"]',m=u;switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":m=Er(e)}if(!Wa.has(m)&&(e=v({rel:"modulepreload",href:e},t),Wa.set(m,e),s.querySelector(u)===null)){switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(s.querySelector(Io(m)))return}o=s.createElement("link"),En(o,"link",e),vt(o),s.head.appendChild(o)}}}function yb(e,t,s){dl.S(e,t,s);var o=Tr;if(o&&e){var u=Ot(o).hoistableStyles,m=Rr(e);t=t||"default";var S=u.get(m);if(!S){var N={loading:0,preload:null};if(S=o.querySelector(Oo(m)))N.loading=5;else{e=v({rel:"stylesheet",href:e,"data-precedence":t},s),(s=Wa.get(m))&&im(e,s);var I=S=o.createElement("link");vt(I),En(I,"link",e),I._p=new Promise(function(te,fe){I.onload=te,I.onerror=fe}),I.addEventListener("load",function(){N.loading|=1}),I.addEventListener("error",function(){N.loading|=2}),N.loading|=4,Cu(S,t,o)}S={type:"stylesheet",instance:S,count:1,state:N},u.set(m,S)}}}function wb(e,t){dl.X(e,t);var s=Tr;if(s&&e){var o=Ot(s).hoistableScripts,u=Er(e),m=o.get(u);m||(m=s.querySelector(Io(u)),m||(e=v({src:e,async:!0},t),(t=Wa.get(u))&&rm(e,t),m=s.createElement("script"),vt(m),En(m,"link",e),s.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},o.set(u,m))}}function bb(e,t){dl.M(e,t);var s=Tr;if(s&&e){var o=Ot(s).hoistableScripts,u=Er(e),m=o.get(u);m||(m=s.querySelector(Io(u)),m||(e=v({src:e,async:!0,type:"module"},t),(t=Wa.get(u))&&rm(e,t),m=s.createElement("script"),vt(m),En(m,"link",e),s.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},o.set(u,m))}}function lx(e,t,s,o){var u=(u=ze.current)?Su(u):null;if(!u)throw Error(r(446));switch(e){case"meta":case"title":return null;case"style":return typeof s.precedence=="string"&&typeof s.href=="string"?(t=Rr(s.href),s=Ot(u).hoistableStyles,o=s.get(t),o||(o={type:"style",instance:null,count:0,state:null},s.set(t,o)),o):{type:"void",instance:null,count:0,state:null};case"link":if(s.rel==="stylesheet"&&typeof s.href=="string"&&typeof s.precedence=="string"){e=Rr(s.href);var m=Ot(u).hoistableStyles,S=m.get(e);if(S||(u=u.ownerDocument||u,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},m.set(e,S),(m=u.querySelector(Oo(e)))&&!m._p&&(S.instance=m,S.state.loading=5),Wa.has(e)||(s={rel:"preload",as:"style",href:s.href,crossOrigin:s.crossOrigin,integrity:s.integrity,media:s.media,hrefLang:s.hrefLang,referrerPolicy:s.referrerPolicy},Wa.set(e,s),m||Sb(u,e,s,S.state))),t&&o===null)throw Error(r(528,""));return S}if(t&&o!==null)throw Error(r(529,""));return null;case"script":return t=s.async,s=s.src,typeof s=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Er(s),s=Ot(u).hoistableScripts,o=s.get(t),o||(o={type:"script",instance:null,count:0,state:null},s.set(t,o)),o):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,e))}}function Rr(e){return'href="'+mn(e)+'"'}function Oo(e){return'link[rel="stylesheet"]['+e+"]"}function ix(e){return v({},e,{"data-precedence":e.precedence,precedence:null})}function Sb(e,t,s,o){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?o.loading=1:(t=e.createElement("link"),o.preload=t,t.addEventListener("load",function(){return o.loading|=1}),t.addEventListener("error",function(){return o.loading|=2}),En(t,"link",s),vt(t),e.head.appendChild(t))}function Er(e){return'[src="'+mn(e)+'"]'}function Io(e){return"script[async]"+e}function rx(e,t,s){if(t.count++,t.instance===null)switch(t.type){case"style":var o=e.querySelector('style[data-href~="'+mn(s.href)+'"]');if(o)return t.instance=o,vt(o),o;var u=v({},s,{"data-href":s.href,"data-precedence":s.precedence,href:null,precedence:null});return o=(e.ownerDocument||e).createElement("style"),vt(o),En(o,"style",u),Cu(o,s.precedence,e),t.instance=o;case"stylesheet":u=Rr(s.href);var m=e.querySelector(Oo(u));if(m)return t.state.loading|=4,t.instance=m,vt(m),m;o=ix(s),(u=Wa.get(u))&&im(o,u),m=(e.ownerDocument||e).createElement("link"),vt(m);var S=m;return S._p=new Promise(function(N,I){S.onload=N,S.onerror=I}),En(m,"link",o),t.state.loading|=4,Cu(m,s.precedence,e),t.instance=m;case"script":return m=Er(s.src),(u=e.querySelector(Io(m)))?(t.instance=u,vt(u),u):(o=s,(u=Wa.get(m))&&(o=v({},s),rm(o,u)),e=e.ownerDocument||e,u=e.createElement("script"),vt(u),En(u,"link",o),e.head.appendChild(u),t.instance=u);case"void":return null;default:throw Error(r(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(o=t.instance,t.state.loading|=4,Cu(o,s.precedence,e));return t.instance}function Cu(e,t,s){for(var o=s.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),u=o.length?o[o.length-1]:null,m=u,S=0;S<o.length;S++){var N=o[S];if(N.dataset.precedence===t)m=N;else if(m!==u)break}m?m.parentNode.insertBefore(e,m.nextSibling):(t=s.nodeType===9?s.head:s,t.insertBefore(e,t.firstChild))}function im(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function rm(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var ju=null;function ox(e,t,s){if(ju===null){var o=new Map,u=ju=new Map;u.set(s,o)}else u=ju,o=u.get(s),o||(o=new Map,u.set(s,o));if(o.has(e))return o;for(o.set(e,null),s=s.getElementsByTagName(e),u=0;u<s.length;u++){var m=s[u];if(!(m[at]||m[X]||e==="link"&&m.getAttribute("rel")==="stylesheet")&&m.namespaceURI!=="http://www.w3.org/2000/svg"){var S=m.getAttribute(t)||"";S=e+S;var N=o.get(S);N?N.push(m):o.set(S,[m])}}return o}function cx(e,t,s){e=e.ownerDocument||e,e.head.insertBefore(s,t==="title"?e.querySelector("head > title"):null)}function Cb(e,t,s){if(s===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;return t.rel==="stylesheet"?(e=t.disabled,typeof t.precedence=="string"&&e==null):!0;case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function ux(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function jb(e,t,s,o){if(s.type==="stylesheet"&&(typeof o.media!="string"||matchMedia(o.media).matches!==!1)&&(s.state.loading&4)===0){if(s.instance===null){var u=Rr(o.href),m=t.querySelector(Oo(u));if(m){t=m._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=ku.bind(e),t.then(e,e)),s.state.loading|=4,s.instance=m,vt(m);return}m=t.ownerDocument||t,o=ix(o),(u=Wa.get(u))&&im(o,u),m=m.createElement("link"),vt(m);var S=m;S._p=new Promise(function(N,I){S.onload=N,S.onerror=I}),En(m,"link",o),s.instance=m}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(s,t),(t=s.state.preload)&&(s.state.loading&3)===0&&(e.count++,s=ku.bind(e),t.addEventListener("load",s),t.addEventListener("error",s))}}var om=0;function kb(e,t){return e.stylesheets&&e.count===0&&Au(e,e.stylesheets),0<e.count||0<e.imgCount?function(s){var o=setTimeout(function(){if(e.stylesheets&&Au(e,e.stylesheets),e.unsuspend){var m=e.unsuspend;e.unsuspend=null,m()}},6e4+t);0<e.imgBytes&&om===0&&(om=62500*lb());var u=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Au(e,e.stylesheets),e.unsuspend)){var m=e.unsuspend;e.unsuspend=null,m()}},(e.imgBytes>om?50:800)+t);return e.unsuspend=s,function(){e.unsuspend=null,clearTimeout(o),clearTimeout(u)}}:null}function ku(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Au(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Mu=null;function Au(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Mu=new Map,t.forEach(Mb,e),Mu=null,ku.call(e))}function Mb(e,t){if(!(t.state.loading&4)){var s=Mu.get(e);if(s)var o=s.get(null);else{s=new Map,Mu.set(e,s);for(var u=e.querySelectorAll("link[data-precedence],style[data-precedence]"),m=0;m<u.length;m++){var S=u[m];(S.nodeName==="LINK"||S.getAttribute("media")!=="not all")&&(s.set(S.dataset.precedence,S),o=S)}o&&s.set(null,o)}u=t.instance,S=u.getAttribute("data-precedence"),m=s.get(S)||o,m===o&&s.set(null,u),s.set(S,u),this.count++,o=ku.bind(this),u.addEventListener("load",o),u.addEventListener("error",o),m?m.parentNode.insertBefore(u,m.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(u,e.firstChild)),t.state.loading|=4}}var Bo={$$typeof:D,Provider:null,Consumer:null,_currentValue:U,_currentValue2:U,_threadCount:0};function Ab(e,t,s,o,u,m,S,N,I){this.tag=1,this.containerInfo=e,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=Ia(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ia(0),this.hiddenUpdates=Ia(null),this.identifierPrefix=o,this.onUncaughtError=u,this.onCaughtError=m,this.onRecoverableError=S,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=I,this.incompleteTransitions=new Map}function dx(e,t,s,o,u,m,S,N,I,te,fe,ve){return e=new Ab(e,t,s,S,I,te,fe,ve,N),t=1,m===!0&&(t|=24),m=Tn(3,null,null,t),e.current=m,m.stateNode=e,t=ho(),t.refCount++,e.pooledCache=t,t.refCount++,m.memoizedState={element:o,isDehydrated:s,cache:t},qd(m),e}function fx(e){return e?(e=Rl,e):Rl}function mx(e,t,s,o,u,m){u=fx(u),o.context===null?o.context=u:o.pendingContext=u,o=Ol(t),o.payload={element:s},m=m===void 0?null:m,m!==null&&(o.callback=m),s=Il(e,o,t),s!==null&&(ma(s,e,t),go(s,e,t))}function hx(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var s=e.retryLane;e.retryLane=s!==0&&s<t?s:t}}function cm(e,t){hx(e,t),(e=e.alternate)&&hx(e,t)}function px(e){if(e.tag===13||e.tag===31){var t=Ce(e,67108864);t!==null&&ma(t,e,67108864),cm(e,67108864)}}function gx(e){if(e.tag===13||e.tag===31){var t=Ea();t=Fa(t);var s=Ce(e,t);s!==null&&ma(s,e,t),cm(e,t)}}var Nu=!0;function Nb(e,t,s,o){var u=z.T;z.T=null;var m=Y.p;try{Y.p=2,um(e,t,s,o)}finally{Y.p=m,z.T=u}}function Tb(e,t,s,o){var u=z.T;z.T=null;var m=Y.p;try{Y.p=8,um(e,t,s,o)}finally{Y.p=m,z.T=u}}function um(e,t,s,o){if(Nu){var u=dm(o);if(u===null)Qf(e,t,o,Tu,s),vx(e,o);else if(Eb(u,e,t,s,o))o.stopPropagation();else if(vx(e,o),t&4&&-1<Rb.indexOf(e)){for(;u!==null;){var m=Yt(u);if(m!==null)switch(m.tag){case 3:if(m=m.stateNode,m.current.memoizedState.isDehydrated){var S=es(m.pendingLanes);if(S!==0){var N=m;for(N.pendingLanes|=2,N.entangledLanes|=2;S;){var I=1<<31-qt(S);N.entanglements[1]|=I,S&=~I}Es(m),(gt&6)===0&&(du=Oe()+500,Do(0))}}break;case 31:case 13:N=Ce(m,2),N!==null&&ma(N,m,2),mu(),cm(m,2)}if(m=dm(o),m===null&&Qf(e,t,o,Tu,s),m===u)break;u=m}u!==null&&o.stopPropagation()}else Qf(e,t,o,null,s)}}function dm(e){return e=Zi(e),fm(e)}var Tu=null;function fm(e){if(Tu=null,e=_t(e),e!==null){var t=d(e);if(t===null)e=null;else{var s=t.tag;if(s===13){if(e=h(t),e!==null)return e;e=null}else if(s===31){if(e=p(t),e!==null)return e;e=null}else if(s===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Tu=e,null}function xx(e){switch(e){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(Dt()){case Za:return 2;case Nt:return 8;case Gn:case ii:return 32;case Te:return 268435456;default:return 32}default:return 32}}var mm=!1,Kl=null,Wl=null,Ql=null,Fo=new Map,Ho=new Map,Xl=[],Rb="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 vx(e,t){switch(e){case"focusin":case"focusout":Kl=null;break;case"dragenter":case"dragleave":Wl=null;break;case"mouseover":case"mouseout":Ql=null;break;case"pointerover":case"pointerout":Fo.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ho.delete(t.pointerId)}}function $o(e,t,s,o,u,m){return e===null||e.nativeEvent!==m?(e={blockedOn:t,domEventName:s,eventSystemFlags:o,nativeEvent:m,targetContainers:[u]},t!==null&&(t=Yt(t),t!==null&&px(t)),e):(e.eventSystemFlags|=o,t=e.targetContainers,u!==null&&t.indexOf(u)===-1&&t.push(u),e)}function Eb(e,t,s,o,u){switch(t){case"focusin":return Kl=$o(Kl,e,t,s,o,u),!0;case"dragenter":return Wl=$o(Wl,e,t,s,o,u),!0;case"mouseover":return Ql=$o(Ql,e,t,s,o,u),!0;case"pointerover":var m=u.pointerId;return Fo.set(m,$o(Fo.get(m)||null,e,t,s,o,u)),!0;case"gotpointercapture":return m=u.pointerId,Ho.set(m,$o(Ho.get(m)||null,e,t,s,o,u)),!0}return!1}function yx(e){var t=_t(e.target);if(t!==null){var s=d(t);if(s!==null){if(t=s.tag,t===13){if(t=h(s),t!==null){e.blockedOn=t,Os(e.priority,function(){gx(s)});return}}else if(t===31){if(t=p(s),t!==null){e.blockedOn=t,Os(e.priority,function(){gx(s)});return}}else if(t===3&&s.stateNode.current.memoizedState.isDehydrated){e.blockedOn=s.tag===3?s.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Ru(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var s=dm(e.nativeEvent);if(s===null){s=e.nativeEvent;var o=new s.constructor(s.type,s);Xi=o,s.target.dispatchEvent(o),Xi=null}else return t=Yt(s),t!==null&&px(t),e.blockedOn=s,!1;t.shift()}return!0}function wx(e,t,s){Ru(e)&&s.delete(t)}function Db(){mm=!1,Kl!==null&&Ru(Kl)&&(Kl=null),Wl!==null&&Ru(Wl)&&(Wl=null),Ql!==null&&Ru(Ql)&&(Ql=null),Fo.forEach(wx),Ho.forEach(wx)}function Eu(e,t){e.blockedOn===t&&(e.blockedOn=null,mm||(mm=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,Db)))}var Du=null;function bx(e){Du!==e&&(Du=e,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){Du===e&&(Du=null);for(var t=0;t<e.length;t+=3){var s=e[t],o=e[t+1],u=e[t+2];if(typeof o!="function"){if(fm(o||s)===null)continue;break}var m=Yt(s);m!==null&&(e.splice(t,3),t-=3,df(m,{pending:!0,data:u,method:s.method,action:o},o,u))}}))}function Dr(e){function t(I){return Eu(I,e)}Kl!==null&&Eu(Kl,e),Wl!==null&&Eu(Wl,e),Ql!==null&&Eu(Ql,e),Fo.forEach(t),Ho.forEach(t);for(var s=0;s<Xl.length;s++){var o=Xl[s];o.blockedOn===e&&(o.blockedOn=null)}for(;0<Xl.length&&(s=Xl[0],s.blockedOn===null);)yx(s),s.blockedOn===null&&Xl.shift();if(s=(e.ownerDocument||e).$$reactFormReplay,s!=null)for(o=0;o<s.length;o+=3){var u=s[o],m=s[o+1],S=u[Se]||null;if(typeof m=="function")S||bx(s);else if(S){var N=null;if(m&&m.hasAttribute("formAction")){if(u=m,S=m[Se]||null)N=S.formAction;else if(fm(u)!==null)continue}else N=S.action;typeof N=="function"?s[o+1]=N:(s.splice(o,3),o-=3),bx(s)}}}function Sx(){function e(m){m.canIntercept&&m.info==="react-transition"&&m.intercept({handler:function(){return new Promise(function(S){return u=S})},focusReset:"manual",scroll:"manual"})}function t(){u!==null&&(u(),u=null),o||setTimeout(s,20)}function s(){if(!o&&!navigation.transition){var m=navigation.currentEntry;m&&m.url!=null&&navigation.navigate(m.url,{state:m.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var o=!1,u=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(s,100),function(){o=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),u!==null&&(u(),u=null)}}}function hm(e){this._internalRoot=e}Lu.prototype.render=hm.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(r(409));var s=t.current,o=Ea();mx(s,o,e,t,null,null)},Lu.prototype.unmount=hm.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;mx(e.current,2,null,e,null,null),mu(),t[De]=null}};function Lu(e){this._internalRoot=e}Lu.prototype.unstable_scheduleHydration=function(e){if(e){var t=as();e={blockedOn:null,target:e,priority:t};for(var s=0;s<Xl.length&&t!==0&&t<Xl[s].priority;s++);Xl.splice(s,0,e),s===0&&yx(e)}};var Cx=a.version;if(Cx!=="19.2.7")throw Error(r(527,Cx,"19.2.7"));Y.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(r(188)):(e=Object.keys(e).join(","),Error(r(268,e)));return e=g(t),e=e!==null?w(e):null,e=e===null?null:e.stateNode,e};var Lb={bundleType:0,version:"19.2.7",rendererPackageName:"react-dom",currentDispatcherRef:z,reconcilerVersion:"19.2.7"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var zu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zu.isDisabled&&zu.supportsFiber)try{_a=zu.inject(Lb),Je=zu}catch{}}return Po.createRoot=function(e,t){if(!c(e))throw Error(r(299));var s=!1,o="",u=Rp,m=Ep,S=Dp;return t!=null&&(t.unstable_strictMode===!0&&(s=!0),t.identifierPrefix!==void 0&&(o=t.identifierPrefix),t.onUncaughtError!==void 0&&(u=t.onUncaughtError),t.onCaughtError!==void 0&&(m=t.onCaughtError),t.onRecoverableError!==void 0&&(S=t.onRecoverableError)),t=dx(e,1,!1,null,null,s,o,null,u,m,S,Sx),e[De]=t.current,Wf(e),new hm(t)},Po.hydrateRoot=function(e,t,s){if(!c(e))throw Error(r(299));var o=!1,u="",m=Rp,S=Ep,N=Dp,I=null;return s!=null&&(s.unstable_strictMode===!0&&(o=!0),s.identifierPrefix!==void 0&&(u=s.identifierPrefix),s.onUncaughtError!==void 0&&(m=s.onUncaughtError),s.onCaughtError!==void 0&&(S=s.onCaughtError),s.onRecoverableError!==void 0&&(N=s.onRecoverableError),s.formState!==void 0&&(I=s.formState)),t=dx(e,1,!0,t,s??null,o,u,I,m,S,N,Sx),t.context=fx(null),s=t.current,o=Ea(),o=Fa(o),u=Ol(o),u.callback=null,Il(s,u,o),s=o,t.current.lanes=s,Ba(t,s),Es(t),e[De]=t.current,Wf(e),new Lu(t)},Po.version="19.2.7",Po}var _x;function xS(){if(_x)return xm.exports;_x=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(a){console.error(a)}}return n(),xm.exports=gS(),xm.exports}var vS=xS();const yS="https://otbyfkjxrkngvjziawki.supabase.co",wS="sb_publishable_NpUs0RDJH2YnllsqTKO6TQ_1jTdSsNQ",Ds=dS(yS,wS,{auth:{autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"pkce",storageKey:"livedesk.mindexec.supabase.auth"}});function ei(n,a,i){if(i<0||a<0||a+i>n.length)throw new Error("Invalid LZO1X block: input overrun.")}function wm(n,a,i){let r=0;for(;ei(n,a.inputIndex,1),n[a.inputIndex]===0;)r+=1,a.inputIndex+=1;const c=r*255+i+n[a.inputIndex];return a.inputIndex+=1,c}function _u(n,a,i,r){if(ei(n,a.inputIndex,r),a.outputIndex+r>i.length)throw new Error("Invalid LZO1X block: output overrun.");i.set(n.subarray(a.inputIndex,a.inputIndex+r),a.outputIndex),a.inputIndex+=r,a.outputIndex+=r}function bS(n,a,i,r){const c=a-i;if(c<=0||r<=0)throw new Error("Invalid LZO1X block: invalid match distance.");let d=Math.min(c,r);for(n.set(n.subarray(i,i+d),a);d<r;){const h=Math.min(d,r-d);n.copyWithin(a+d,a,a+h),d+=h}return a+r}function cy(n,a){if(!(n instanceof Uint8Array)||n.length<3||a<0)throw new Error("Invalid LZO1X block.");const i=new Uint8Array(a),r={inputIndex:0,outputIndex:0};let c=0,d=0;if(n[r.inputIndex]>=22){const h=n[r.inputIndex]-17;r.inputIndex+=1,_u(n,r,i,h),c=4}else n[r.inputIndex]>=18&&(c=n[r.inputIndex]-17,r.inputIndex+=1,_u(n,r,i,c));for(;;){ei(n,r.inputIndex,1);const h=n[r.inputIndex];r.inputIndex+=1;let p,x;if((h&192)!==0)ei(n,r.inputIndex,1),x=r.outputIndex-((n[r.inputIndex]<<3)+(h>>2&7)+1),r.inputIndex+=1,d=(h>>5)+1,p=h&3;else if((h&32)!==0){d=(h&31)+2,d===2&&(d+=wm(n,r,31)),ei(n,r.inputIndex,2);const g=n[r.inputIndex]|n[r.inputIndex+1]<<8;r.inputIndex+=2,x=r.outputIndex-((g>>2)+1),p=g&3}else if((h&16)!==0){d=(h&7)+2,d===2&&(d+=wm(n,r,7)),ei(n,r.inputIndex,2);const g=n[r.inputIndex]|n[r.inputIndex+1]<<8;if(r.inputIndex+=2,x=r.outputIndex-(((h&8)<<11)+(g>>2)),p=g&3,x===r.outputIndex)break;x-=16384}else if(c===0){let g=h+3;g===3&&(g+=wm(n,r,15)),_u(n,r,i,g),c=4;continue}else c!==4?(ei(n,r.inputIndex,1),p=h&3,x=r.outputIndex-((h>>2)+(n[r.inputIndex]<<2)+1),r.inputIndex+=1,d=2):(ei(n,r.inputIndex,1),p=h&3,x=r.outputIndex-((h>>2)+(n[r.inputIndex]<<2)+2049),r.inputIndex+=1,d=3);if(x<0||r.outputIndex+d+p>i.length)throw new Error("Invalid LZO1X block: lookbehind overrun.");r.outputIndex=bS(i,r.outputIndex,x,d),c=p,_u(n,r,i,p)}if(d!==3||r.inputIndex!==n.length||r.outputIndex!==i.length)throw new Error("Invalid LZO1X block: incomplete output.");return i}const Ox=16,Ix=8,SS=24*1024*1024,uy=new Uint8Array(new Uint32Array([16909060]).buffer)[0]===4,Km=new Uint32Array(65536);for(let n=0;n<Km.length;n+=1){const a=Math.round((n>>11&31)*255/31),i=Math.round((n>>5&63)*255/63),r=Math.round((n&31)*255/31);Km[n]=uy?(a|i<<8|r<<16|4278190080)>>>0:(a<<24|i<<16|r<<8|255)>>>0}function Jl(n,a){return n[a]|n[a+1]<<8}function CS(n,a){const i=Number(a);if(!Number.isSafeInteger(i)||i<Ox||i>SS)throw new Error(`Invalid Mode 5 packet length: ${a}.`);const r=cy(new Uint8Array(n),i);if(r[0]!==76||r[1]!==68||r[2]!==53||r[3]!==68)throw new Error("Invalid Mode 5 packet magic.");if(r[4]!==1)throw new Error(`Unsupported Mode 5 packet version: ${r[4]}.`);const c=(r[5]&1)!==0,d=Jl(r,6),h=Jl(r,8),p=Jl(r,10),x=Jl(r,12);if(d<=0||h<=0||d>3840||h>2160)throw new Error(`Invalid Mode 5 frame size: ${d}x${h}.`);if(p<=0||p>256||x>8192)throw new Error(`Invalid Mode 5 tile header: ${p}/${x}.`);const g=[];let w=Ox;for(let v=0;v<x;v+=1){if(w+Ix>r.length)throw new Error("Mode 5 tile header is truncated.");const b=Jl(r,w),k=Jl(r,w+2),j=Jl(r,w+4),M=Jl(r,w+6);w+=Ix;const T=j*M*2;if(j<=0||M<=0||j>p||M>p||b+j>d||k+M>h||w+T>r.length)throw new Error(`Invalid Mode 5 tile ${v}.`);g.push({x:b,y:k,width:j,height:M,pixels:r.subarray(w,w+T)}),w+=T}if(w!==r.length)throw new Error(`Mode 5 packet has ${r.length-w} trailing bytes.`);return{keyFrame:c,width:d,height:h,tileSize:p,tiles:g}}function jS(n,a,i,r){if(!(n instanceof Uint8ClampedArray)||n.length!==a*i*4||r.width!==a||r.height!==i)throw new Error("Mode 5 canvas state does not match the packet dimensions.");let c=a,d=i,h=0,p=0;const x=new Uint32Array(n.buffer,n.byteOffset,n.byteLength>>>2);for(const g of r.tiles){const w=uy&&(g.pixels.byteOffset&1)===0?new Uint16Array(g.pixels.buffer,g.pixels.byteOffset,g.pixels.byteLength>>>1):null;let v=0;for(let b=0;b<g.height;b+=1){let k=(g.y+b)*a+g.x;for(let j=0;j<g.width;j+=1){const M=v<<1,T=w?w[v]:g.pixels[M]|g.pixels[M+1]<<8;x[k]=Km[T],v+=1,k+=1}}c=Math.min(c,g.x),d=Math.min(d,g.y),h=Math.max(h,g.x+g.width),p=Math.max(p,g.y+g.height)}return r.tiles.length>0?{x:c,y:d,width:h-c,height:p-d}:null}const xa=new WeakMap,dc=new WeakMap,Wm=new WeakMap,fc=new Set,Gi=new Set,ud=new WeakMap,Qm=new WeakMap,Xm=new WeakMap,dd=new WeakMap,vh=32,kS=2,MS=2,AS=2,NS=18,TS=40,RS=0,ES=750,dy=80,Bx=5,DS=150,LS=24,zS=180,_S=1200,OS=18,IS=.65,BS=2e3,FS=500,fy=250;let fd=!1;function HS(){return typeof navigator>"u"?!1:/mac/i.test(`${navigator.platform||""} ${navigator.userAgent||""}`)}function $S(){const n=Math.max(1,Number(navigator.hardwareConcurrency||8));return Math.max(4,Math.min(16,Math.round(n/2)))}let Ki={h264DecodeAcceleration:"prefer-hardware",h264HardwareDecoderBudget:$S()};function US(n){n.h264DecodeAcceleration&&(Ki={...Ki,h264DecodeAcceleration:n.h264DecodeAcceleration}),Number.isFinite(Number(n.h264HardwareDecoderBudget))&&(Ki.h264HardwareDecoderBudget=Math.max(1,Math.min(64,Math.round(Number(n.h264HardwareDecoderBudget)))))}function my(n,a=Ki.h264DecodeAcceleration){const i=ud.get(n);return i?.requested===a?(i.actual!=="prefer-hardware"&&Gi.delete(n),i.actual):(i&&ud.delete(n),a!=="prefer-hardware"?(Gi.delete(n),a):Gi.has(n)?"prefer-hardware":Gi.size<Ki.h264HardwareDecoderBudget?(Gi.add(n),"prefer-hardware"):"prefer-software")}function wd(n,a){return a!=="prefer-hardware"?!1:(ud.set(n,{requested:a,actual:"prefer-software"}),Gi.delete(n),!0)}function PS(n,a,i,r=64){try{let c=Qm.get(n);c||(c={canvas:document.createElement("canvas"),lastHash:"",initialized:!1},Qm.set(n,c));const d=Math.max(8,Math.min(64,Math.round(r))),h=Math.max(1,Math.round(d*Math.max(1,i)/Math.max(1,a)));(c.canvas.width!==d||c.canvas.height!==h)&&(c.canvas.width=d,c.canvas.height=h);const p=c.canvas.getContext("2d",{willReadFrequently:!0});if(!p)return{visualHash:"",visualChanged:!0};p.drawImage(n,0,0,Math.max(1,a),Math.max(1,i),0,0,d,h);const x=p.getImageData(0,0,d,h).data;let g=2166136261;for(let b=0;b<x.length;b+=4)g^=x[b],g=Math.imul(g,16777619),g^=x[b+1],g=Math.imul(g,16777619),g^=x[b+2],g=Math.imul(g,16777619);const w=(g>>>0).toString(16).padStart(8,"0"),v=!c.initialized||w!==c.lastHash;return c.initialized=!0,c.lastHash=w,{visualHash:w,visualChanged:v}}catch{return{visualHash:"",visualChanged:!0}}}function Zm(n,a,i,r=fy,c=64){let d=Xm.get(n);d||(d={lastHash:"",initialized:!1,lastCanvasSampleAt:0},Xm.set(n,d));const h=performance.now();if(d.initialized&&r>0&&h-d.lastCanvasSampleAt<r)return{visualHash:d.lastHash,visualChanged:!1};const p=PS(n,a,i,c);return d.initialized=!0,d.lastHash=p.visualHash,d.lastCanvasSampleAt=h,p}function qS(n,a){let i=dd.get(n);i||(i={lastHash:"",initialized:!1},dd.set(n,i));const r=String(a.contentHash||""),c=!i.initialized||!r||r!==i.lastHash;return i.initialized=!0,i.lastHash=r,{visualHash:r,visualChanged:c}}function hy(n,a){const i=Wm.get(n);if(i)return i;const r=n.getContext("2d",{alpha:!1,desynchronized:a==="interactive"});if(r){const c=r.getContextAttributes?.(),d={context:r,presentation:c?.desynchronized?"desync":"sync"};return Wm.set(n,d),d}return null}function GS(n){const a=String(n.frameMode||n.mode||"").toLowerCase(),i=String(n.compression||"").toLowerCase(),r=String(n.mimeType||"").toLowerCase();return a==="mode2-lzo"||i==="lzo1x"||r==="application/vnd.livedesk.lzo-rgb565"||a==="mode2-lz4"||String(n.compression||"").toLowerCase()==="lz4"||r==="application/vnd.livedesk.lz4-raw"}function YS(n){return String(n.frameMode||n.mode||"").toLowerCase()==="mode3-h264-hw"||String(n.codec||"").toLowerCase()==="h264"||String(n.mimeType||"").toLowerCase()==="video/h264"}function VS(n){const a=String(n.frameMode||n.mode||"").toLowerCase(),i=String(n.mimeType||"").toLowerCase();return a==="mode5-lzo-delta"||i==="application/vnd.livedesk.lzo-rgb565-delta"}function Fx(n,a,i){let r=i,c=a;if(r===15){let d=255;for(;d===255;){if(c>=n.length)throw new Error("Invalid LZ4 block: length overrun.");d=n[c],c+=1,r+=d}}return{length:r,cursor:c}}function KS(n,a){const i=new Uint8Array(a);let r=0,c=0;for(;r<n.length;){const d=n[r];r+=1;const h=Fx(n,r,d>>4);r=h.cursor;const p=h.length;if(r+p>n.length||c+p>i.length)throw new Error("Invalid LZ4 block: literal overrun.");if(i.set(n.subarray(r,r+p),c),r+=p,c+=p,r>=n.length)break;if(r+2>n.length)throw new Error("Invalid LZ4 block: missing offset.");const x=n[r]|n[r+1]<<8;if(r+=2,x<=0||x>c)throw new Error("Invalid LZ4 block: bad match offset.");const g=Fx(n,r,d&15);r=g.cursor;const w=g.length+4;if(c+w>i.length)throw new Error("Invalid LZ4 block: match overrun.");let v=c-x;for(let b=0;b<w;b+=1)i[c]=i[v],c+=1,v+=1}if(c!==i.length)throw new Error("Invalid LZ4 block: incomplete output.");return i}function WS(n){const a=Math.max(1,Math.floor(n.width||0)),i=Math.max(1,Math.floor(n.height||0)),r=String(n.compression||"").toLowerCase(),c=String(n.pixelFormat||n.codec||"").toLowerCase();if(r==="lzo1x"||String(n.frameMode||n.mode||"").toLowerCase()==="mode2-lzo"||String(n.mimeType||"").toLowerCase()==="application/vnd.livedesk.lzo-rgb565"){const w=Math.max(1,Math.floor(n.bytesPerPixel||2)),v=a*i*2,b=Math.floor(n.uncompressedByteLength||v);if(w!==2||b!==v)throw new Error(`Invalid mode2 RGB565 frame size: ${b} for ${a}x${i}.`);if(c&&c!=="rgb565le"&&c!=="rgb565")throw new Error(`Unsupported mode2 pixel format: ${c}`);const k=cy(new Uint8Array(n.payload),v),j=new Uint8ClampedArray(a*i*4);for(let M=0,T=0;M<k.length;M+=2,T+=4){const C=k[M]|k[M+1]<<8,A=C>>11&31,D=C>>5&63,H=C&31;j[T]=A<<3|A>>2,j[T+1]=D<<2|D>>4,j[T+2]=H<<3|H>>2,j[T+3]=255}return new ImageData(j,a,i)}const h=Math.max(1,Math.floor(n.bytesPerPixel||4)),p=Math.max(a*i*h,Math.floor(n.uncompressedByteLength||0)),x=KS(new Uint8Array(n.payload),p);if(h!==4)throw new Error(`Unsupported mode2 pixel size: ${h}`);const g=new Uint8ClampedArray(a*i*4);if(c==="rgba32"||c==="rgba")g.set(x.subarray(0,g.length));else for(let w=0,v=0;v<g.length;w+=4,v+=4)g[v]=x[w+2],g[v+1]=x[w+1],g[v+2]=x[w],g[v+3]=x[w+3];return new ImageData(g,a,i)}function Hx(n,a="smooth"){const i=window.VideoDecoder;if(!i||!window.EncodedVideoChunk)throw new Error("WebCodecs H.264 decode is not supported in this browser.");const r=xa.get(n);if(r&&r.decoder.state!=="closed"&&r.latencyMode===a)return r;r&&ws(n);let c;return c={decoder:new i({output:h=>{if(xa.get(n)!==c){h.close();return}const p=Number(h.timestamp||0);c.outputSerial+=1;let x=c.pendingFrames.get(p);if(x)c.pendingFrames.delete(p);else if(c.pendingFrames.size>0){const j=c.pendingFrames.entries().next().value;j&&(c.pendingFrames.delete(j[0]),x=j[1],c.timestampFallbacks+=1)}const g=h.displayWidth||h.codedWidth||n.width||960,w=h.displayHeight||h.codedHeight||n.height||540,v=Number(x?.frame.durationUs||0),b=Number(h.duration||0),k=Math.max(16,Math.min(250,(v>0?v:b||83333)/1e3));for(c.targetPaintIntervalMs=k,c.decodedFrames.push({videoFrame:h,pending:x,decodedAt:performance.now(),width:g,height:w,durationMs:k}),c.lastOutputAt=performance.now();c.decodedFrames.length>py(c);)md(c,c.decodedFrames.shift());gy(c),c.renderTimer!==null&&c.renderScheduledAt>0&&performance.now()-c.renderScheduledAt>FS&&(typeof document>"u"||document.visibilityState==="visible")&&(window.cancelAnimationFrame(c.renderTimer),c.renderTimer=null,c.renderScheduledAt=0),c.renderTimer!==null&&c.decodedFrames.length>=vh&&(window.cancelAnimationFrame(c.renderTimer),c.renderTimer=null,c.renderScheduledAt=0),hd(n,c)},error:()=>{xa.get(n)===c&&(wd(n,c.hardwareAcceleration),yh(c),fc.delete(n),xa.delete(n))}}),configured:!1,configKey:"",codec:"",hardwareAcceleration:my(n),latencyMode:a,keyFrameSeen:!1,droppedForLatency:0,pendingFrames:new Map,decodedFrames:[],renderTimer:null,renderScheduledAt:0,flushTimer:null,flushInFlight:!1,flushCount:0,timestampFallbacks:0,inputSerial:0,outputSerial:0,lastFlushInputSerial:0,lastOutputAt:0,lastPaintAt:0,lastInputAt:0,interactiveBufferPrimed:!1,interactiveBufferStartedAt:0,interactiveBufferWaitCount:0,interactiveBufferWaitMs:0,interactiveQueueDrainCount:0,lastInputFrameSeq:void 0,targetPaintIntervalMs:1e3/12,nextChunkTimestampUs:0,healthSampleStartedAt:performance.now(),healthInputSerial:0,healthOutputSerial:0},xa.set(n,c),fc.add(n),c}function yh(n){n.renderTimer!==null&&(window.cancelAnimationFrame(n.renderTimer),n.renderTimer=null),n.renderScheduledAt=0,n.flushTimer!==null&&(window.clearTimeout(n.flushTimer),n.flushTimer=null),n.flushInFlight=!1;for(const a of n.decodedFrames)a.videoFrame.close();n.decodedFrames=[],n.interactiveBufferPrimed=!1,n.interactiveBufferStartedAt=0}function md(n,a){a&&(a.videoFrame.close(),n.droppedForLatency+=1)}function py(n){return n.latencyMode==="interactive"?MS:String(n.decodedFrames[0]?.pending?.frame.frameMode||n.decodedFrames[0]?.pending?.frame.mode||"").toLowerCase()==="mode4-h264-atlas"?kS:vh}function gy(n,a=performance.now()){const i=py(n);for(;n.decodedFrames.length>i;)md(n,n.decodedFrames.shift());const r=n.latencyMode==="interactive"?dy:ES;let c=n.decodedFrames[0];for(;n.decodedFrames.length>1&&c?.pending&&a-c.pending.queuedAt>r;)md(n,n.decodedFrames.shift()),c=n.decodedFrames[0]}function xy(n,a){if(a.hardwareAcceleration!=="prefer-hardware"||a.flushTimer!==null||a.flushInFlight)return;const i=a.latencyMode==="interactive"?LS:DS,r=a.latencyMode==="interactive";a.flushTimer=window.setTimeout(async()=>{a.flushTimer=null;const c=performance.now();for(const[p,x]of a.pendingFrames.entries())c-x.queuedAt>BS&&a.pendingFrames.delete(p);if(xa.get(n)!==a||a.decoder.state!=="configured"||a.pendingFrames.size===0||a.inputSerial<=a.lastFlushInputSerial||!r&&a.lastOutputAt>0&&c-a.lastOutputAt<i)return;const d=a.inputSerial,h=performance.now();a.flushInFlight=!0,a.flushCount+=1;try{await a.decoder.flush(),a.lastFlushInputSerial=Math.max(a.lastFlushInputSerial,d)}catch{xa.get(n)===a&&nd(a)}finally{a.flushInFlight=!1;const p=performance.now()-h;if(r&&p>=zS&&a.hardwareAcceleration==="prefer-hardware"){fd=!0,wd(n,a.hardwareAcceleration),ws(n);return}xa.get(n)===a&&a.inputSerial>d&&a.pendingFrames.size>0&&(r||performance.now()-a.lastOutputAt>=i)&&xy(n,a)}},i)}function $x(n,a,i){const r=performance.now();try{(n.width!==i.width||n.height!==i.height)&&(n.width=i.width,n.height=i.height);const c=hy(n,a.latencyMode);if(c?.context.drawImage(i.videoFrame,0,0,i.width,i.height),i.pending){const d=performance.now(),p=a.latencyMode==="interactive"?qS(n,i.pending.frame):Zm(n,i.width,i.height,fy,64);try{a.onPaint?.(i.pending.frame,{deviceId:i.pending.frame.deviceId,frameSeq:i.pending.frame.frameSeq,mode:i.pending.frame.frameMode||i.pending.frame.mode||i.pending.frame.codec||i.pending.frame.mimeType,width:i.width,height:i.height,byteLength:i.pending.frame.byteLength,queuedForMs:Math.max(0,r-i.pending.queuedAt),decodedForMs:Math.max(0,i.decodedAt-i.pending.queuedAt),scheduledForMs:Math.max(0,r-i.decodedAt),drawMs:Math.max(0,d-r),queueSize:i.pending.queueSize,renderQueueSize:a.decodedFrames.length,droppedForLatency:a.droppedForLatency,h264DecodeAcceleration:a.hardwareAcceleration,decoderLabel:a.hardwareAcceleration,decoderFlushCount:a.flushCount,decoderTimestampFallbacks:a.timestampFallbacks,decoderInputCount:a.inputSerial,decoderOutputCount:a.outputSerial,targetPaintIntervalMs:a.targetPaintIntervalMs,canvasPresentation:c?.presentation||"sync",interactiveBufferWaitCount:a.interactiveBufferWaitCount,interactiveBufferWaitMs:a.interactiveBufferWaitMs,interactiveQueueDrainCount:a.interactiveQueueDrainCount,visualHash:p.visualHash,visualChanged:p.visualChanged,paintedAt:d})}catch{}}a.lastPaintAt=performance.now()}finally{i.videoFrame.close()}}function hd(n,a){if(a.renderTimer!==null||a.decodedFrames.length===0)return;const i=Math.max(16,Math.min(250,a.targetPaintIntervalMs||1e3/12)),r=()=>{if(a.renderTimer=null,a.renderScheduledAt=0,a.decodedFrames.length===0)return;const c=performance.now();if(gy(a,c),a.decodedFrames.length===0)return;if(a.latencyMode==="interactive"){const x=a.targetPaintIntervalMs<=TS,g=a.targetPaintIntervalMs<=20;if(g&&!a.interactiveBufferPrimed){a.interactiveBufferStartedAt<=0&&(a.interactiveBufferStartedAt=c,a.interactiveBufferWaitCount+=1);const M=a.decodedFrames.length>=AS,T=c-a.interactiveBufferStartedAt>=NS;if(!M&&!T){a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(r);return}a.interactiveBufferWaitMs+=Math.max(0,c-a.interactiveBufferStartedAt),a.interactiveBufferPrimed=!0}else g||(a.interactiveBufferPrimed=!0);const w=a.decodedFrames[0],v=w?.pending?Math.max(0,c-w.pending.queuedAt):0,b=a.lastPaintAt>0?a.lastPaintAt+i:c;if(!(!x||c+Bx>=b||v>=dy)){a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(r);return}const j=a.decodedFrames.shift();if(j)try{$x(n,a,j)}catch{}a.decodedFrames.length===0&&(a.interactiveQueueDrainCount+=1,a.interactiveBufferPrimed=!1,a.interactiveBufferStartedAt=0),hd(n,a);return}const d=a.lastPaintAt>0?a.lastPaintAt+i:c+RS;if(!(c+Bx>=d||a.decodedFrames.length>=vh-1)){a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(r);return}const p=a.decodedFrames.shift();if(p)try{$x(n,a,p)}catch{}hd(n,a)};a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(r)}function vy(n,a){if(xa.get(n)!==a||a.decoder.state==="closed")return!1;for(a.renderTimer!==null&&(window.cancelAnimationFrame(a.renderTimer),a.renderTimer=null),a.renderScheduledAt=0;a.decodedFrames.length>1;)md(a,a.decodedFrames.shift());return a.lastPaintAt=0,a.interactiveBufferPrimed=!1,a.interactiveBufferStartedAt=0,hd(n,a),!0}function bm(){if(!(typeof document>"u"||document.visibilityState!=="visible"))for(const n of fc){const a=xa.get(n);if(!a||a.decoder.state==="closed"){fc.delete(n);continue}vy(n,a)}}typeof document<"u"&&typeof window<"u"&&(document.addEventListener("visibilitychange",bm),window.addEventListener("focus",bm),window.addEventListener("pageshow",bm));function ws(n){Gi.delete(n),fc.delete(n),dd.delete(n);const a=xa.get(n);if(a){xa.delete(n);try{yh(a),a.decoder.state!=="closed"&&a.decoder.close()}catch{}}}function qo(n){n&&(ud.delete(n),Wm.delete(n),Xm.delete(n),Qm.delete(n),dd.delete(n),dc.delete(n),ws(n))}function nd(n,a=1){try{n.decoder.state!=="closed"&&n.decoder.reset()}catch{}n.configured=!1,n.configKey="",n.keyFrameSeen=!1,n.pendingFrames.clear(),yh(n),n.lastPaintAt=0,n.lastOutputAt=0,n.lastInputAt=0,n.interactiveBufferPrimed=!1,n.interactiveBufferStartedAt=0,n.lastInputFrameSeq=void 0,n.nextChunkTimestampUs=0,n.healthSampleStartedAt=performance.now(),n.healthInputSerial=n.inputSerial,n.healthOutputSerial=n.outputSerial,n.droppedForLatency+=Math.max(1,Math.min(1e4,Math.floor(a)))}function Ou(n,a,i,r){n.decoder.configure(a),n.configured=!0,n.configKey=i,n.codec=a.codec,n.hardwareAcceleration=r,n.keyFrameSeen=!1,n.nextChunkTimestampUs=0,n.lastInputFrameSeq=void 0}function QS(n,a){if(a.latencyMode!=="interactive"||a.hardwareAcceleration!=="prefer-hardware")return!1;const i=performance.now();if(i-a.healthSampleStartedAt<_S)return!1;const r=a.inputSerial-a.healthInputSerial,c=a.outputSerial-a.healthOutputSerial;return a.healthSampleStartedAt=i,a.healthInputSerial=a.inputSerial,a.healthOutputSerial=a.outputSerial,r<OS||c/Math.max(1,r)>=IS?!1:(fd=!0,wd(n,a.hardwareAcceleration),ws(n),!0)}function Ux(n,a=1){if(!n)return!1;const i=xa.get(n);return i?(i.droppedForLatency+=Math.max(1,Math.min(1e4,Math.floor(a))),ws(n),!0):!1}function XS(n){if(!n)return!1;const a=xa.get(n);return a?vy(n,a):!1}function ZS(n,a,i,r="interactive"){ws(n);const c=performance.now(),d=CS(a.payload,a.uncompressedByteLength||0),h=String(a.streamId||"mode5");let p=dc.get(n);if(!p||p.streamId!==h||p.width!==d.width||p.height!==d.height){const M=new Uint8ClampedArray(d.width*d.height*4);for(let T=3;T<M.length;T+=4)M[T]=255;p={streamId:h,width:d.width,height:d.height,rgba:M,imageData:new ImageData(M,d.width,d.height),keyFrameSeen:!1,inputSerial:0,outputSerial:0},dc.set(n,p)}if(!p)throw new Error("Mode 5 canvas state could not be initialized.");p.inputSerial+=1;const g=Number(a.streamFrameSeq||0);if(g>0&&(p.lastStreamFrameSeq=g),!d.keyFrame&&!p.keyFrameSeen)return;d.keyFrame&&(p.keyFrameSeen=!0);const w=jS(p.rgba,p.width,p.height,d),v=performance.now();(n.width!==p.width||n.height!==p.height)&&(n.width=p.width,n.height=p.height);const b=hy(n,r),k=performance.now();w&&b?.context.putImageData(p.imageData,0,0,w.x,w.y,w.width,w.height);const j=performance.now();p.outputSerial+=1,i?.(a,{deviceId:a.deviceId,frameSeq:a.frameSeq,mode:a.frameMode||a.mode||a.mimeType,width:p.width,height:p.height,byteLength:a.byteLength,queuedForMs:Math.max(0,j-c),decodedForMs:Math.max(0,v-c),scheduledForMs:0,drawMs:Math.max(0,j-k),queueSize:0,renderQueueSize:0,droppedForLatency:0,h264DecodeAcceleration:"prefer-software",decoderLabel:"lzo-rgb565-delta",decoderFlushCount:0,decoderTimestampFallbacks:0,decoderInputCount:p.inputSerial,decoderOutputCount:p.outputSerial,targetPaintIntervalMs:Math.max(1,Number(a.durationUs||0)/1e3||1e3/30),canvasPresentation:b?.presentation||"sync",interactiveBufferWaitCount:0,interactiveBufferWaitMs:0,interactiveQueueDrainCount:0,visualHash:String(a.contentHash||""),visualChanged:Number(a.deltaVisualTileCount||0)>0,paintedAt:j})}const Sm=[{code:30,maxFrameSize:1620,maxMacroblocksPerSecond:40500},{code:31,maxFrameSize:3600,maxMacroblocksPerSecond:108e3},{code:32,maxFrameSize:5120,maxMacroblocksPerSecond:216e3},{code:40,maxFrameSize:8192,maxMacroblocksPerSecond:245760},{code:41,maxFrameSize:8192,maxMacroblocksPerSecond:245760},{code:42,maxFrameSize:8704,maxMacroblocksPerSecond:522240},{code:50,maxFrameSize:22080,maxMacroblocksPerSecond:589824},{code:51,maxFrameSize:36864,maxMacroblocksPerSecond:983040},{code:52,maxFrameSize:36864,maxMacroblocksPerSecond:2073600}];function Px(n,a){for(let i=Math.max(0,a);i+3<n.length;i+=1)if(!(n[i]!==0||n[i+1]!==0)){if(n[i+2]===1)return{index:i,length:3};if(n[i+2]===0&&n[i+3]===1)return{index:i,length:4}}return null}function JS(n){const a=new Uint8Array(n);let i=0;for(;i<a.length;){const r=Px(a,i);if(!r)break;const c=r.index+r.length,d=Px(a,c),h=d?.index??a.length;if(c<h&&(a[c]&31)===7){const p=[];let x=0;for(let g=c+1;g<h;g+=1){const w=a[g];if(x>=2&&w===3){x=0;continue}p.push(w),x=w===0?x+1:0}if(p.length>=3)return`avc1.${p.slice(0,3).map(g=>g.toString(16).toUpperCase().padStart(2,"0")).join("")}`}i=d?d.index:a.length}return""}function e0(n,a,i,r,c=""){const d=Math.ceil(n/16)*Math.ceil(a/16),h=i>0?1e6/i:30,p=d*h,x=Sm.find(g=>d<=g.maxFrameSize&&p<=g.maxMacroblocksPerSecond)||Sm[Sm.length-1];return JS(r)||c||`avc1.42E0${x.code.toString(16).toUpperCase().padStart(2,"0")}`}function t0(n,a,i,r,c="smooth"){dc.delete(n);const d=String(a.h264Format||"").toLowerCase()==="avc"?"avc":"annexb",h=Math.max(1,Math.floor(a.width||960)),p=Math.max(1,Math.floor(a.height||540)),x=Math.max(1,Math.floor(a.durationUs||1e6/12));let g=Hx(n,c);const w=e0(h,p,x,a.payload,g.codec),v=String(a.frameMode||a.mode||"").toLowerCase(),b=c==="interactive"&&r==="prefer-hardware"&&HS(),j=v==="mode4-h264-atlas"?"prefer-software":my(n,c==="interactive"&&(fd||b)?"prefer-software":r),M=[a.streamId||"",a.commandId||"",h,p,w,d,j,c].join("|");g.onPaint=i,g.configured&&g.decoder.state!=="configured"&&(g.configured=!1,g.configKey=""),g.configured&&g.configKey!==M&&(ws(n),g=Hx(n,c),g.onPaint=i);const T={codec:w,codedWidth:h,codedHeight:p,hardwareAcceleration:j,optimizeForLatency:!0,avc:{format:d}};g.configured||Ou(g,T,M,j);const C=a.isKeyFrame===!0||String(a.chunkType||"").toLowerCase()==="key";Number(a.frameSeq||0);const A=Number(a.streamFrameSeq||0);if(A>0&&g.lastInputFrameSeq!==void 0){if(A<=g.lastInputFrameSeq){if(!C||A===g.lastInputFrameSeq)return;nd(g,g.lastInputFrameSeq-A+1),Ou(g,T,M,j)}if(A>g.lastInputFrameSeq+1){if(nd(g,A-g.lastInputFrameSeq-1),!C)return;Ou(g,T,M,j)}}if(A>0&&(g.lastInputFrameSeq=A),!C&&!g.keyFrameSeen)return;C&&(g.keyFrameSeen=!0);const D=Number(g.decoder.decodeQueueSize||0);if(D>8){if(g.latencyMode==="interactive"&&g.hardwareAcceleration==="prefer-hardware"){fd=!0,wd(n,g.hardwareAcceleration),ws(n);return}if(nd(g),!C)return;Ou(g,T,M,j),g.keyFrameSeen=!0}const H=g.nextChunkTimestampUs;g.nextChunkTimestampUs+=x,g.pendingFrames.set(H,{frame:a,queuedAt:performance.now(),queueSize:D}),g.inputSerial+=1,g.lastInputAt=performance.now();const B=new EncodedVideoChunk({type:C?"key":"delta",timestamp:H,duration:x,data:a.payload});try{g.decoder.decode(B)}catch(q){throw ws(n),q}xy(n,g),QS(n,g)}async function Cm(n,a,i,r,c,d="smooth"){if(VS(a)){i()||ZS(n,a,r,d);return}if(YS(a)){i()||t0(n,a,r,c,d);return}if(dc.delete(n),GS(a)){ws(n);const v=WS(a);if(i())return;(n.width!==v.width||n.height!==v.height)&&(n.width=v.width,n.height=v.height);const b=n.getContext("2d"),k=performance.now();b?.putImageData(v,0,0);const j=performance.now(),M=Zm(n,v.width,v.height);r?.(a,{deviceId:a.deviceId,frameSeq:a.frameSeq,mode:a.frameMode||a.mode||a.codec||a.mimeType,width:v.width,height:v.height,byteLength:a.byteLength,queuedForMs:0,decodedForMs:0,scheduledForMs:0,drawMs:Math.max(0,j-k),queueSize:0,renderQueueSize:0,droppedForLatency:0,h264DecodeAcceleration:Ki.h264DecodeAcceleration,decoderLabel:"lzo-rgb565",decoderFlushCount:0,decoderTimestampFallbacks:0,decoderInputCount:0,decoderOutputCount:0,targetPaintIntervalMs:0,canvasPresentation:"sync",interactiveBufferWaitCount:0,interactiveBufferWaitMs:0,interactiveQueueDrainCount:0,visualHash:M.visualHash,visualChanged:M.visualChanged,paintedAt:j});return}ws(n);const h=new Blob([a.payload],{type:a.mimeType}),p=await createImageBitmap(h);if(i()){p.close();return}const x=a.width||p.width||960,g=a.height||p.height||540;(n.width!==x||n.height!==g)&&(n.width=x,n.height=g);const w=n.getContext("2d");if(w){const v=performance.now();w.clearRect(0,0,x,g),w.drawImage(p,0,0,x,g);const b=performance.now(),k=Zm(n,x,g);r?.(a,{deviceId:a.deviceId,frameSeq:a.frameSeq,mode:a.frameMode||a.mode||a.codec||a.mimeType,width:x,height:g,byteLength:a.byteLength,queuedForMs:0,decodedForMs:0,scheduledForMs:0,drawMs:Math.max(0,b-v),queueSize:0,renderQueueSize:0,droppedForLatency:0,h264DecodeAcceleration:Ki.h264DecodeAcceleration,decoderLabel:"image",decoderFlushCount:0,decoderTimestampFallbacks:0,decoderInputCount:0,decoderOutputCount:0,targetPaintIntervalMs:0,canvasPresentation:"sync",interactiveBufferWaitCount:0,interactiveBufferWaitMs:0,interactiveQueueDrainCount:0,visualHash:k.visualHash,visualChanged:k.visualChanged,paintedAt:b})}p.close()}const ac=5179,Ln=li(`http://127.0.0.1:${ac}`);function n0(n){const a=n.split(".").map(i=>Number(i));return a.length===4&&a.every(i=>Number.isInteger(i)&&i>=0&&i<=255)?a:[]}function a0(n){const a=n.trim().toLowerCase();return a==="localhost"||a==="127.0.0.1"||a==="::1"||a==="[::1]"}function s0(n){const a=n.trim().toLowerCase();return!a||a==="0.0.0.0"||a==="::"||a==="[::]"}function l0(n){const a=n0(n);return a.length===0?!1:a[0]===10||a[0]===172&&a[1]>=16&&a[1]<=31||a[0]===192&&a[1]===168}function i0(n){return n.includes(":")&&!n.startsWith("[")?`[${n}]`:n}function r0(n){const a=String(n||"").trim();if(!a)return null;const i=/^[a-z][a-z\d+.-]*:\/\//i.test(a)?a:`tcp://${a}`;try{const r=new URL(i),c=r.hostname.replace(/^\[|\]$/g,""),d=Number(r.port);return!c||!Number.isInteger(d)||d<1||d>65535||s0(c)?null:{host:c,port:d}}catch{return null}}function li(n){const a=String(n||"").trim()||`http://127.0.0.1:${ac}`,i=/^[a-z][a-z\d+.-]*:\/\//i.test(a)?a:`http://${a}`;try{const r=new URL(i);return r.port||(r.port=String(ac)),r.hash="",r.search="",r.toString().replace(/\/+$/,"")}catch{return`http://127.0.0.1:${ac}`}}function o0(n){const a=r0(n);return a?li(`http://${i0(a.host)}:${ac}`):""}function qx(n){const i=[n?.endpoint,...Array.isArray(n?.endpoint_candidates)?n.endpoint_candidates:[]].map(r=>o0(String(r||""))).filter(Boolean);return[...new Set(i)]}function sc(n=Ln){if(!(typeof window>"u"||window.location.protocol!=="https:"))try{const a=new URL(n);if(a.protocol!=="http:")return;if(a0(a.hostname))return"loopback";if(l0(a.hostname))return"local"}catch{return}}function bd(n,a=Ln){const i=new URL(n,li(a));return i.protocol=i.protocol==="https:"?"wss:":"ws:",i.toString()}async function Be(n,a,i=Ln){const r=li(i),c={...a,headers:{"Content-Type":"application/json",...a?.headers||{}},cache:"no-store"},d=sc(r);d&&(c.targetAddressSpace=d);let h;try{h=await fetch(`${r}${n}`,c)}catch(p){throw d?new Error("LiveDesk Hub is not reachable at this local network address. If Chrome shows a local network prompt, allow it; otherwise restart the Hub so port 5179 is open on the network."):p}if(!h.ok)throw new Error(`${h.status} ${h.statusText}`);return await h.json()}function Jm(n){if(!n)return"-";const a=Date.now()-Date.parse(n);return Number.isFinite(a)?a<1e3?"now":a<6e4?`${Math.round(a/1e3)}s`:a<36e5?`${Math.round(a/6e4)}m`:`${Math.round(a/36e5)}h`:"-"}async function qi(n){await navigator.clipboard.writeText(n)}const Gx="livedesk_remote_host_targets",c0="livedesk_entitlements";function u0(n){const i=(Array.isArray(n)?n:[n||Ln]).map(r=>li(r||Ln));return[...new Set(i.filter(Boolean))]}function d0(){const[n,a]=f.useState(null),[i,r]=f.useState(!0);return f.useEffect(()=>{let c=!0;Ds.auth.getSession().then(({data:h})=>{c&&(a(h.session??null),r(!1))});const{data:{subscription:d}}=Ds.auth.onAuthStateChange((h,p)=>{a(p),r(!1)});return()=>{c=!1,d.unsubscribe()}},[]),{session:n,loading:i}}function f0(n,a=!0){const[i,r]=f.useState(null),[c,d]=f.useState([]),[h,p]=f.useState(""),[x,g]=f.useState(""),[w,v]=f.useState(0),b=f.useRef(new Map),k=Array.isArray(n)?n.join(`
|
|
10
|
-
`):String(n||""),j=f.useMemo(()=>u0(n),[k]),M=f.useMemo(()=>j.find(A=>sc(A)==="loopback")||j[0]||Ln,[j]),T=f.useCallback(async()=>{if(!a){r(null),d([]),g(""),p("");return}let A=null;const D=Date.now(),H=j.filter(B=>(b.current.get(B)||0)<=D);if(H.length===0)throw new Error("No LiveDesk Hub endpoint is reachable. Retrying shortly.");for(const B of H)try{const[q,L]=await Promise.all([Be("/api/remote/status",void 0,B),Be("/api/remote/devices",void 0,B)]);if(!Array.isArray(L.devices))throw new Error("Invalid Hub devices response.");b.current.delete(B),r(q),d(L.devices),g(B),p("");return}catch(q){A=q,b.current.set(B,Date.now()+1e4)}throw g(""),A||new Error("No LiveDesk Hub endpoint is reachable.")},[a,j]),C=f.useCallback(()=>{b.current.clear(),T().catch(A=>{p(A instanceof Error?A.message:String(A))}),v(A=>A+1)},[T]);return f.useEffect(()=>{if(!a){r(null),d([]),g(""),p("");return}let A=!0;const D=async()=>{try{await T()}catch(B){A&&p(B instanceof Error?B.message:String(B))}};D();const H=window.setInterval(D,2500);return()=>{A=!1,window.clearInterval(H)}},[a,T,w]),{status:i,devices:c,error:h,refresh:C,hubBaseUrl:x||M,hubCandidates:j}}function m0(n){const[a,i]=f.useState(null),[r,c]=f.useState(""),d=n?.user?.id||"",h=f.useCallback(async()=>{if(!d){i(null);return}const{data:p,error:x}=await Ds.from(Gx).select("*").eq("user_id",d).maybeSingle();if(x){c(x.message);return}i(p),c("")},[d]);return f.useEffect(()=>{h()},[h]),f.useEffect(()=>{if(!d)return;const p=Ds.channel(`livedesk-remote-host-targets-${d.replace(/[^a-zA-Z0-9]/g,"")}`).on("postgres_changes",{event:"*",schema:"public",table:Gx,filter:`user_id=eq.${d}`},x=>i(x.new)).subscribe();return()=>{Ds.removeChannel(p)}},[d]),{target:a,error:r,refresh:h}}function h0(n){const[a,i]=f.useState(null),[r,c]=f.useState(!1),[d,h]=f.useState(""),p=n?.user?.id||"",x=f.useCallback(async()=>{if(!p){i(null),h(""),c(!1);return}c(!0);const{data:w,error:v}=await Ds.from(c0).select("*").eq("user_id",p).eq("product_key","livedesk").maybeSingle();if(v){h(v.message),c(!1);return}i(w),h(""),c(!1)},[p]);f.useEffect(()=>{x()},[x]);const g=f.useMemo(()=>!a||a.status!=="active"?!1:a.expires_at?new Date(a.expires_at).getTime()>Date.now():!0,[a]);return{entitlement:a,licensed:g,loading:r,error:d,refresh:x}}const lc={totalFrames:0,totalBytes:0,framesPerSecond:0,bytesPerSecond:0,sampleMs:0,lastUpdatedAt:0},p0=2500,g0=3e4,x0=64*1024,v0=6,y0=v0,yy=new Map;function w0(n){return yy.get(n)}const Yx={totalSent:0,totalDropped:0,sentPerSecond:0,droppedPerSecond:0,bufferedAmount:0,lastInputType:"",lastInputSeq:0,lastRoundTripMs:0,lastAgentApplyMs:0,lastUpdatedAt:0};function Vx(n){const a=Date.parse(String(n||""));if(!Number.isFinite(a))return 0;const i=Date.now()-a;return i>0&&i<=g0?i:0}function Kx(n,a,i=Ln,r={}){const[c,d]=f.useState(new Map),[h,p]=f.useState("idle"),[x,g]=f.useState(""),[w,v]=f.useState(lc),b=f.useRef(new Map),k=f.useRef(new Map),j=f.useRef(0),M=f.useRef(new Map),T=f.useRef({enabled:!1,token:"",reason:""}),C=f.useRef(new Set),[A,D]=f.useState(0),H=f.useRef(r.onFrame),B=f.useRef({totalFrames:0,totalBytes:0,sampleFrames:0,sampleBytes:0,sampleStartedAt:0}),q=f.useMemo(()=>[...n].sort().join(","),[n]),L=Number.isFinite(r.fps)?Number(r.fps):2,F=Number.isFinite(r.maxWidth)?Number(r.maxWidth):640,ue=Number.isFinite(r.maxHeight)?Number(r.maxHeight):360,W=Number.isFinite(r.quality)?Number(r.quality):45,ce=String(r.frameMode||r.mode||"mode3-h264-hw").trim()||"mode3-h264-hw",Q=r.streamPurpose==="control"?"control":"wall",se=r.forceRestart===!0,oe=String(r.forceRestartToken||"").trim(),K=String(r.restartReason||"").trim();T.current={enabled:se,token:oe,reason:K};const z=f.useMemo(()=>{const $=Object.entries(r.monitorSelections||{}).filter(([ie])=>!!ie).sort(([ie],[we])=>ie.localeCompare(we));return JSON.stringify(Object.fromEntries($))},[r.monitorSelections]);f.useEffect(()=>{H.current=r.onFrame},[r.onFrame]);const Y=f.useCallback(($,ie="livedesk-frame-socket-release")=>{$.disposed=!0;try{$.socket.readyState===WebSocket.CONNECTING||$.socket.readyState===WebSocket.OPEN?$.socket.close(1e3,ie):$.socket.close()}catch{}},[]),U=f.useCallback(()=>{const $=[...k.current.values()].map(ie=>ie.socket);if($.length===0){p("idle");return}if($.some(ie=>ie.readyState===WebSocket.OPEN)){p("open");return}if($.some(ie=>ie.readyState===WebSocket.CONNECTING)){p("connecting");return}p("closed")},[]),R=f.useCallback(($,ie,we,me)=>{if(ie.disposed||ie.socket.readyState!==WebSocket.OPEN)return!1;try{return ie.socket.send(JSON.stringify({...ie.payload,type:"restart-live",deviceIds:[$],forceRestart:!0,restartReason:we,restartToken:me})),!0}catch{return!1}},[]),J=f.useCallback(($,ie)=>{if(!$||$.byteLength<5)return;const we=Date.now(),ze=new DataView($).getUint32(0,!1);if(ze<=0||ze+4>$.byteLength)return;const Pe=new Uint8Array($.slice(4,4+ze)),de=JSON.parse(new TextDecoder().decode(Pe));if(Math.max(Vx(de.receivedAt),Vx(de.capturedAt))>p0)return;const Le=$.slice(4+ze),Fe={deviceId:String(de.deviceId||""),kind:de.kind==="thumbnail"?"thumbnail":"live",frameSeq:Number(de.frameSeq||0),streamFrameSeq:Number(de.streamFrameSeq||0)||void 0,streamId:String(de.streamId||""),commandId:de.commandId?String(de.commandId):void 0,width:Number(de.width||0),height:Number(de.height||0),sourceWidth:Number(de.sourceWidth||0)||void 0,sourceHeight:Number(de.sourceHeight||0)||void 0,mimeType:String(de.mimeType||"image/jpeg"),mode:de.mode?String(de.mode):void 0,frameMode:de.frameMode?String(de.frameMode):void 0,frameProfile:de.frameProfile?String(de.frameProfile):void 0,encoding:de.encoding?String(de.encoding):void 0,codec:de.codec?String(de.codec):void 0,compression:de.compression?String(de.compression):void 0,pixelFormat:de.pixelFormat?String(de.pixelFormat):void 0,bytesPerPixel:Number(de.bytesPerPixel||0)||0,uncompressedByteLength:Number(de.uncompressedByteLength||0)||0,h264Format:de.h264Format?String(de.h264Format):void 0,isKeyFrame:de.isKeyFrame===!0,chunkType:de.chunkType?String(de.chunkType):void 0,timestampUs:Number(de.timestampUs||0)||0,durationUs:Number(de.durationUs||0)||0,sourceGapMs:Number(de.sourceGapMs||0)||0,agentSendGapMs:Number(de.agentSendGapMs||0)||0,agentSendDurationMs:Number(de.agentSendDurationMs||0)||0,agentSendDurationFrameSeq:Number(de.agentSendDurationFrameSeq||0)||0,agentPaceMs:Number(de.agentPaceMs||0)||0,agentQueueBeforePaceMs:Number(de.agentQueueBeforePaceMs||0)||0,agentFrameAgeMs:Number(de.agentFrameAgeMs||0)||0,droppedByAgent:Number(de.droppedByAgent||0)||0,hubIngressDropped:Number(de.hubIngressDropped||0)||0,hubClientDropped:Number(de.hubClientDropped||0)||0,hardwareEncoder:de.hardwareEncoder?String(de.hardwareEncoder):void 0,platformProfile:de.platformProfile?String(de.platformProfile):void 0,monitorIndex:Number.isFinite(Number(de.monitorIndex))?Number(de.monitorIndex):void 0,monitorCount:Number.isFinite(Number(de.monitorCount))?Number(de.monitorCount):void 0,requestedFps:Number(de.requestedFps||0)||0,effectiveFps:Number(de.effectiveFps||0)||0,captureAverageMs:Number(de.captureAverageMs||0)||0,captureP95Ms:Number(de.captureP95Ms||0)||0,slowFrameCount:Number(de.slowFrameCount||0)||0,captureHelperRestarts:Number(de.captureHelperRestarts||0)||0,capturedAt:String(de.capturedAt||""),receivedAt:String(de.receivedAt||""),hubPacketAt:de.hubPacketAt?String(de.hubPacketAt):void 0,hubPacketEpochMs:Number.isFinite(Number(de.hubPacketEpochMs))?Number(de.hubPacketEpochMs):void 0,browserReceivedEpochMs:we,byteLength:Number(de.byteLength||Le.byteLength),contentHash:de.contentHash?String(de.contentHash):void 0,captureMs:Number(de.captureMs||0)||0,captureStageMs:Number(de.captureStageMs||0)||0,convertMs:Number(de.convertMs||0)||0,compressMs:Number(de.compressMs||0)||0,captureSourceSerial:Number(de.captureSourceSerial||0)||0,captureSourceSkipped:Number(de.captureSourceSkipped||0)||0,deltaTileSize:Number(de.deltaTileSize||0)||0,deltaTileCount:Number(de.deltaTileCount||0)||0,deltaVisualTileCount:Number(de.deltaVisualTileCount||0)||0,deltaRefreshTileCount:Number(de.deltaRefreshTileCount||0)||0,deltaTotalTiles:Number(de.deltaTotalTiles||0)||0,payload:Le};if(!Fe.deviceId)return;const qe={streamId:ie.lastFrameStreamId,commandId:ie.lastFrameCommandId,order:ie.lastFrameOrder},ne=Number(Fe.streamFrameSeq||Fe.frameSeq||0),ye=!!qe.commandId&&!!Fe.commandId,be=qe.streamId===Fe.streamId&&(!ye||qe.commandId===Fe.commandId),Z=qe.order;if(be&&Z>=ne&&(Z===ne||ye))return;ie.lastFrameStreamId=Fe.streamId,ie.lastFrameCommandId=Fe.commandId||"",ie.lastFrameOrder=ne;const le=B.current;le.totalFrames+=1,le.totalBytes+=Le.byteLength,le.sampleFrames+=1,le.sampleBytes+=Le.byteLength,b.current.set(Fe.deviceId,Fe),H.current?.(Fe)},[]);f.useEffect(()=>{const $=window.setInterval(()=>{const ie=performance.now(),we=B.current,me=Math.max(1,ie-we.sampleStartedAt);v({totalFrames:we.totalFrames,totalBytes:we.totalBytes,framesPerSecond:we.sampleFrames*1e3/me,bytesPerSecond:we.sampleBytes*1e3/me,sampleMs:me,lastUpdatedAt:Date.now()}),d(new Map(b.current)),we.sampleFrames=0,we.sampleBytes=0,we.sampleStartedAt=ie},2e3);return()=>{window.clearInterval($)}},[]),f.useEffect(()=>{const $=q?q.split(",").filter(Boolean):[],ie=new Set($),we=performance.now();for(const[me,ze]of k.current.entries())ie.has(me)||(Y(ze,"livedesk-device-unsubscribed"),k.current.delete(me),M.current.delete(me),b.current.delete(me));if($.length===0){for(const me of k.current.values())Y(me,"livedesk-no-devices");k.current.clear(),M.current.clear(),b.current=new Map,d(new Map),g(""),B.current={totalFrames:0,totalBytes:0,sampleFrames:0,sampleBytes:0,sampleStartedAt:0},v(lc),U();return}B.current.sampleStartedAt<=0&&(B.current.sampleStartedAt=we,v({...lc,lastUpdatedAt:Date.now()}));for(const me of $){const ze=r.monitorSelections?.[me],Pe=Number.isFinite(Number(ze))?{[me]:Number(ze)}:{},de={type:"subscribe",deviceIds:[me],autoStartLive:a,fps:L,maxWidth:F,maxHeight:ue,quality:W,mode:ce,frameMode:ce,streamPurpose:Q,monitorSelections:Pe},He=JSON.stringify(de),Le=k.current.get(me);if(Le){const ye=Le.socket.readyState===WebSocket.CONNECTING||Le.socket.readyState===WebSocket.OPEN;if(Le.payloadKey===He&&ye&&!Le.disposed)continue}const Fe=Le&&(Le.socket.readyState===WebSocket.CONNECTING||Le.socket.readyState===WebSocket.OPEN)&&!Le.disposed?Le.handoffFrom&&!Le.handoffCompleted?Le.handoffFrom:Le:void 0;Le&&Le!==Fe&&Y(Le,"livedesk-subscription-superseded");const qe=new WebSocket(bd(`/api/remote/frames/ws?devices=${encodeURIComponent(me)}`,i));qe.binaryType="arraybuffer";const ne={socket:qe,payload:de,payloadKey:He,generation:j.current+1,disposed:!1,handoffFrom:Fe,handoffCompleted:!1,lastFrameStreamId:"",lastFrameCommandId:"",lastFrameOrder:-1};j.current=ne.generation,k.current.set(me,ne),qe.addEventListener("open",()=>{if(ne.disposed||k.current.get(me)!==ne){Y(ne,"livedesk-stale-frame-socket");return}g("");const ye=T.current,be=ye.enabled&&(!ye.token||M.current.get(me)!==ye.token);qe.send(JSON.stringify({...ne.payload,forceRestart:be,restartReason:be?ye.reason:"",restartToken:be?ye.token:""})),be&&ye.token&&M.current.set(me,ye.token);const Z=ne.handoffFrom;ne.handoffFrom=void 0,ne.handoffCompleted=!0,Z&&!Z.disposed&&Y(Z,"livedesk-subscription-replaced"),U()}),qe.addEventListener("message",ye=>{if(ne.disposed||k.current.get(me)!==ne)return;if(typeof ye.data=="string"){try{const Z=JSON.parse(ye.data);if(Z?.type==="RemoteFrameSubscriptionError")g(String(Z.error||"control-stream-start-failed"));else if(Z?.type==="RemoteFrameLiveAutoStart"){const Me=(Array.isArray(Z.skipped)?Z.skipped:[]).find(je=>je?.deviceId===me);Me?g(String(Me.reason||"control-stream-start-failed")):Array.isArray(Z.started)&&Z.started.some(je=>je?.deviceId===me)&&g("")}}catch{}return}const be=ye.data instanceof ArrayBuffer?ye.data:null;be&&(g(""),J(be,ne))}),qe.addEventListener("error",()=>{ne.disposed||k.current.get(me)!==ne||(g("frame-socket-error"),p("error"))}),qe.addEventListener("close",()=>{const ye=!ne.disposed;ne.disposed=!0;const be=k.current.get(me);let Z=!1;if(be===ne){const le=ne.handoffFrom;ne.handoffFrom=void 0,le&&!le.disposed&&(le.socket.readyState===WebSocket.CONNECTING||le.socket.readyState===WebSocket.OPEN)?(k.current.set(me,le),Z=!0):k.current.delete(me)}if(U(),ye&&be===ne&&!Z){const le=window.setTimeout(()=>{C.current.delete(le),D(Me=>Me+1)},750);C.current.add(le)}})}U()},[a,Y,q,L,ce,J,i,ue,F,z,r.monitorSelections,W,A,Q,U]),f.useEffect(()=>{if(!se||!oe)return;const $=q?q.split(",").filter(Boolean):[];for(const ie of $){if(M.current.get(ie)===oe)continue;const we=k.current.get(ie);!we||!R(ie,we,K,oe)||M.current.set(ie,oe)}},[q,se,oe,K,R]),f.useEffect(()=>()=>{for(const $ of k.current.values())Y($,"livedesk-hook-unmount");k.current.clear();for(const $ of C.current)window.clearTimeout($);C.current.clear()},[Y]);const he=f.useCallback(($,ie="browser-stale")=>{const we=Array.isArray($)&&$.length>0?$:q.split(",").filter(Boolean);if(we.length===0)return!1;let me=!1;for(const ze of we){const Pe=k.current.get(ze);!Pe||Pe.socket.readyState!==WebSocket.OPEN||(me=R(ze,Pe,ie,`${Date.now()}-${Math.random().toString(36).slice(2)}`)||me)}return me},[q,R]);return{frames:c,state:h,error:x,stats:w,restartLive:he}}function b0(n,a,i=Ln,r={}){const[c,d]=f.useState(null),[h,p]=f.useState(null),[x,g]=f.useState("idle"),[w,v]=f.useState(lc),b=f.useRef(null),k=f.useRef(r.onFrame),j=f.useRef(null),M=f.useRef(0),T=f.useRef({totalFrames:0,totalBytes:0,sampleFrames:0,sampleBytes:0,sampleStartedAt:0}),C=f.useMemo(()=>[...new Set(n.filter(Boolean))].join(","),[n]),A=f.useMemo(()=>[...new Set((r.captureDeviceIds||n).filter(Boolean))].join(","),[n,r.captureDeviceIds]),D=f.useMemo(()=>JSON.stringify(r.monitorSelections||{}),[r.monitorSelections]),H=f.useMemo(()=>({deviceIds:C.split(",").filter(Boolean),captureDeviceIds:A.split(",").filter(Boolean),fps:Number(r.fps||20),width:Number(r.width||1920),height:Number(r.height||1080),tileWidth:Number(r.tileWidth||320),tileHeight:Number(r.tileHeight||180),monitorSelections:r.monitorSelections||{}}),[A,C,D,r.fps,r.height,r.monitorSelections,r.tileHeight,r.tileWidth,r.width]),B=f.useMemo(()=>JSON.stringify(H),[H]),q=f.useRef(H);q.current=H;const L=a&&H.deviceIds.length>0,F=f.useCallback(W=>W.readyState!==WebSocket.OPEN?!1:(W.send(JSON.stringify({type:"configure",...q.current})),!0),[]);f.useEffect(()=>{k.current=r.onFrame},[r.onFrame]),f.useEffect(()=>{const W=window.setInterval(()=>{const ce=T.current,Q=performance.now(),se=Math.max(1,Q-ce.sampleStartedAt);v({totalFrames:ce.totalFrames,totalBytes:ce.totalBytes,framesPerSecond:ce.sampleFrames*1e3/se,bytesPerSecond:ce.sampleBytes*1e3/se,sampleMs:se,lastUpdatedAt:Date.now()});const oe=j.current;oe&&oe.frameSeq!==M.current&&(M.current=oe.frameSeq,d(oe)),ce.sampleFrames=0,ce.sampleBytes=0,ce.sampleStartedAt=Q},1e3);return()=>window.clearInterval(W)},[]),f.useEffect(()=>{if(!L){b.current?.close(),b.current=null,d(null),j.current=null,M.current=0,p(null),g("idle"),v(lc);return}let W=!1,ce=0;const Q=()=>{if(W)return;const se=new WebSocket(bd("/api/remote/atlas/ws",i));se.binaryType="arraybuffer",b.current=se,g("connecting"),se.addEventListener("open",()=>{T.current.sampleStartedAt=performance.now(),g("open"),F(se)}),se.addEventListener("message",oe=>{if(typeof oe.data=="string"){try{const z=JSON.parse(oe.data);z?.type==="Mode4AtlasLayout"&&p({layoutVersion:Number(z.layoutVersion||0),width:Number(z.width||1920),height:Number(z.height||1080),columns:Number(z.columns||1),rows:Number(z.rows||1),tiles:Array.isArray(z.tiles)?z.tiles:[]})}catch{}return}const K=oe.data instanceof ArrayBuffer?oe.data:null;if(!(!K||K.byteLength<5))try{const z=Date.now(),U=new DataView(K).getUint32(0,!1);if(U<=0||U+4>K.byteLength)return;const R=JSON.parse(new TextDecoder().decode(new Uint8Array(K,4,U))),J=K.slice(4+U),he={deviceId:String(R.deviceId||"__livedesk_mode4_atlas__"),kind:"live",frameSeq:Number(R.frameSeq||0),streamFrameSeq:Number(R.streamFrameSeq||0)||void 0,streamId:String(R.streamId||"mode4-atlas"),commandId:R.commandId?String(R.commandId):void 0,width:Number(R.width||1920),height:Number(R.height||1080),sourceWidth:Number(R.sourceWidth||R.width||1920),sourceHeight:Number(R.sourceHeight||R.height||1080),mimeType:String(R.mimeType||"video/h264"),mode:String(R.mode||"mode4-h264-atlas"),frameMode:String(R.frameMode||"mode4-h264-atlas"),frameProfile:String(R.frameProfile||"mode4-h264-atlas-v1"),encoding:String(R.encoding||"video-atlas"),codec:String(R.codec||"h264"),compression:String(R.compression||"video/h264"),h264Format:String(R.h264Format||"annexb"),isKeyFrame:R.isKeyFrame===!0,chunkType:String(R.chunkType||""),timestampUs:Number(R.timestampUs||0),durationUs:Number(R.durationUs||0),hardwareEncoder:R.hardwareEncoder?String(R.hardwareEncoder):void 0,platformProfile:R.platformProfile?String(R.platformProfile):void 0,capturedAt:String(R.capturedAt||""),receivedAt:String(R.receivedAt||""),hubPacketAt:R.hubPacketAt?String(R.hubPacketAt):void 0,hubPacketEpochMs:Number(R.hubPacketEpochMs||0)||void 0,browserReceivedEpochMs:z,byteLength:J.byteLength,layoutVersion:Number(R.layoutVersion||0),atlasComposeMs:Number(R.atlasComposeMs||0),atlasPoolStarved:Number(R.atlasPoolStarved||0),atlasReadyTiles:Number(R.atlasReadyTiles||0),atlasTileCount:Number(R.atlasTileCount||0),payload:J},$=T.current;$.totalFrames+=1,$.totalBytes+=J.byteLength,$.sampleFrames+=1,$.sampleBytes+=J.byteLength,j.current=he,M.current===0&&(M.current=he.frameSeq,d(he)),k.current?.(he)}catch{}}),se.addEventListener("error",()=>g("error")),se.addEventListener("close",()=>{b.current===se&&(b.current=null),!W&&(g("closed"),ce=window.setTimeout(Q,1200))})};return Q(),()=>{W=!0,window.clearTimeout(ce),b.current?.close(),b.current=null}},[L,i,F]),f.useEffect(()=>{if(!L)return;const W=b.current;W&&F(W)},[B,L,F]);const ue=f.useCallback(()=>{const W=b.current;return W?F(W):!1},[F]);return{frame:c,layout:h,state:x,stats:w,refreshInputs:ue}}function S0(n,a=Ln){const i=f.useRef(null),r=f.useRef(0),c=f.useRef(0),d=f.useRef(new Map),[h,p]=f.useState("idle"),[x,g]=f.useState(""),[w,v]=f.useState(Yx),b=f.useRef({totalSent:0,totalDropped:0,sampleSent:0,sampleDropped:0,sampleStartedAt:0,lastInputType:"",lastInputSeq:0,lastRoundTripMs:0,lastAgentApplyMs:0});f.useEffect(()=>{if(!n){i.current?.close(),i.current=null,c.current=0,p("idle"),g(""),v(Yx);return}const j=new WebSocket(bd("/api/remote/input/ws",a));return i.current=j,b.current.sampleStartedAt=performance.now(),p("connecting"),g(""),j.addEventListener("open",()=>{g(""),p("open")}),j.addEventListener("message",M=>{if(typeof M.data=="string")try{const T=JSON.parse(M.data);if(T?.type==="RemoteInputError"){g(String(T.error||T.result?.error||"Remote input failed.")),p("error");return}if(T?.type!=="RemoteInputApplied")return;const C=Number(T.inputSeq||0),A=d.current.get(C);A!==void 0&&(b.current.lastRoundTripMs=Math.max(0,performance.now()-A),d.current.delete(C)),b.current.lastInputSeq=C,b.current.lastAgentApplyMs=Math.max(0,Number(T.agentApplyMs||0))}catch{}}),j.addEventListener("close",()=>p("closed")),j.addEventListener("error",()=>p("error")),()=>{j.close(),d.current.clear(),i.current===j&&(i.current=null)}},[n,a]),f.useEffect(()=>{if(!n)return;const j=window.setInterval(()=>{const M=performance.now(),T=b.current,C=Math.max(1,M-T.sampleStartedAt);v({totalSent:T.totalSent,totalDropped:T.totalDropped,sentPerSecond:T.sampleSent*1e3/C,droppedPerSecond:T.sampleDropped*1e3/C,bufferedAmount:i.current?.bufferedAmount||0,lastInputType:T.lastInputType,lastInputSeq:T.lastInputSeq,lastRoundTripMs:T.lastRoundTripMs,lastAgentApplyMs:T.lastAgentApplyMs,lastUpdatedAt:Date.now()}),T.sampleSent=0,T.sampleDropped=0,T.sampleStartedAt=M},1e3);return()=>window.clearInterval(j)},[n]);const k=f.useCallback((j,M)=>{const T=i.current;if(!T||T.readyState!==WebSocket.OPEN||!j)return!1;const C=String(M.type||"").toLowerCase(),A=C==="pointermove",H=A||C==="wheel",B=b.current;if(A&&T.bufferedAmount>x0)return B.totalDropped+=1,B.sampleDropped+=1,B.lastInputType="pointermove-drop",!1;const q=r.current+1;r.current=q;const L=Date.now(),F=!H||q-c.current>=y0;for(F&&(d.current.set(q,performance.now()),H&&(c.current=q)),A||yy.set(j,{inputSeq:q,inputType:C||"input",sentAt:performance.now()});d.current.size>256;){const ue=d.current.keys().next().value;if(ue===void 0)break;d.current.delete(ue)}return T.send(JSON.stringify({type:"input",requestId:H?"":crypto.randomUUID(),fireAndForget:H,deviceId:j,input:{...M,inputSeq:q,requestAck:F,issuedAtEpochMs:L,issuedAt:new Date(L).toISOString()}})),B.totalSent+=1,B.sampleSent+=1,B.lastInputType=C||"input",!0},[]);return{state:h,sendInput:k,stats:w,error:x}}function C0(n){const a=String(n||"").toLowerCase();return a.includes("audio/pcm")||a.includes("audio/l16")||a.includes("f32le")||a.includes("s16le")}const Iu={queuedMs:0,browserAgeMs:0,captureAgeMs:0,captureStatusAgeMs:0,silentForMs:0,captureAlive:!1,helperAlive:!1,captureRestartCount:0,localProcessingAgeMs:0,lastPacketAgeMs:0,lastAcceptedAgeMs:0,framesReceived:0,drops:0,resyncs:0,pendingDecodes:0,lastFrameSeq:0,audioContextState:"closed",stalledCount:0,automaticRestarts:0,lastUpdatedAt:0},j0=.08,k0=.25,M0=.02,Wx=300,A0=4,Bu=1500,jm=5e3,N0=2e3,T0=1e4,Fu=[0,1e3,3e3];function Qx(n){const a=Date.parse(String(n||""));return Number.isFinite(a)?Math.max(0,Date.now()-a):0}function R0(n,a,i){const r=Math.max(1,Math.min(8,Math.floor(a.channels||2))),c=Math.max(8e3,Math.min(192e3,Math.floor(a.sampleRate||48e3))),d=String(a.mimeType||"").toLowerCase(),h=d.includes("s16le")||d.includes("audio/l16"),p=h?2:4,x=Math.floor(i.byteLength/p),g=Math.floor(x/r),w=n.createBuffer(r,g,c),v=new DataView(i);for(let b=0;b<r;b+=1){const k=w.getChannelData(b);for(let j=0;j<g;j+=1){const T=(j*r+b)*p;k[j]=h?Math.max(-1,Math.min(1,v.getInt16(T,!0)/32768)):Math.max(-1,Math.min(1,v.getFloat32(T,!0)))}}return w}function E0(n,a,i=Ln){const r=f.useRef(null),c=f.useRef(0),[d,h]=f.useState("idle"),[p,x]=f.useState(null),[g,w]=f.useState(Iu),[v,b]=f.useState("");return f.useEffect(()=>{if(!a||!n){h("idle"),x(null),w(Iu),b("");return}h("connecting"),x(null),w(Iu),b("");const k=window.AudioContext||window.webkitAudioContext;if(!k){h("unsupported"),w(Iu),b("Audio playback is not supported in this browser.");return}const j=new k;r.current=j,c.current=j.currentTime;const M=new WebSocket(bd("/api/remote/audio/ws?devices="+encodeURIComponent(n),i));M.binaryType="arraybuffer";const T=new Set,C={browserAgeMs:0,captureAgeMs:0,captureStatusAgeMs:0,silentForMs:0,captureAlive:!1,helperAlive:!1,captureRestartCount:0,localProcessingAgeMs:0,lastPacketAt:0,lastAcceptedAt:0,framesReceived:0,drops:0,resyncs:0,pendingDecodes:0,lastFrameSeq:0,audioContextState:String(j.state),stalledCount:0,automaticRestarts:0,activeStreamId:"",lastCaptureStatusAt:0,lastPcmAtEpochMs:0};let A=!1,D=0,H=!1,B=0,q=0;const L=(z=!0)=>{for(const Y of T)try{Y.stop()}catch{}T.clear(),z&&(c.current=j.currentTime+j0)},F=()=>{C.audioContextState=String(j.state),!A&&(C.audioContextState==="suspended"||C.audioContextState==="interrupted"?h("suspended"):C.audioContextState==="closed"&&(h("error"),b("The browser audio context is closed. Toggle Remote Audio off and on to recover.")))},ue=async()=>{if(A||String(j.state)==="closed")return!1;try{if(String(j.state)!=="running"&&await j.resume(),C.audioContextState=String(j.state),!A&&!H&&C.audioContextState==="running"){const z=C.lastAcceptedAt>0&&performance.now()-C.lastAcceptedAt<=Bu,Y=C.lastCaptureStatusAt>0&&performance.now()-C.lastCaptureStatusAt<=jm&&C.captureAlive&&C.helperAlive;h(z?"playing":Y?"silent":"open")}return C.audioContextState==="running"}catch(z){return A||(h("suspended"),b(z instanceof Error?"Audio playback is suspended: "+z.message:"Audio playback is suspended.")),!1}},W=async()=>{if(A||H||M.readyState!==WebSocket.OPEN)return;if(B>=Fu.length){h("error"),b("Remote audio stopped sending frames. Toggle Audio off and on to retry.");return}const z=B;B+=1,H=!0,C.stalledCount+=1,C.automaticRestarts+=1,h("reconnecting");try{const Y=await Be("/api/remote/devices/"+encodeURIComponent(n)+"/audio/stop",{method:"POST",body:JSON.stringify({})},i);if(Y.ok===!1)throw new Error(Y.error||"Remote audio stop failed.");if(A)return;const U=await Be("/api/remote/devices/"+encodeURIComponent(n)+"/audio/start",{method:"POST",body:JSON.stringify({streamId:"audio-restart-"+Date.now(),mimeType:"audio/pcm;format=f32le",sampleRate:48e3,channels:2})},i);if(U.ok===!1)throw new Error(U.error||"Remote audio start failed.");const R=performance.now();D=R,C.lastPacketAt=R,C.lastAcceptedAt=0,C.lastCaptureStatusAt=0,C.lastPcmAtEpochMs=0,C.captureAlive=!1,C.helperAlive=!1,C.silentForMs=0,q=R+(Fu[z+1]??3e3),b(""),A||h("open")}catch(Y){A||(q=performance.now()+(Fu[z+1]??3e3),h("error"),b(Y instanceof Error?"Remote audio restart failed: "+Y.message:"Remote audio restart failed."))}finally{H=!1}},ce=()=>{C.drops+=1},Q=window.setInterval(()=>{if(A)return;const z=performance.now(),Y=C.lastPacketAt>0?Math.max(0,z-C.lastPacketAt):D>0?Math.max(0,z-D):0,U=C.lastAcceptedAt>0?Math.max(0,z-C.lastAcceptedAt):0,R=C.lastCaptureStatusAt>0?Math.max(0,z-C.lastCaptureStatusAt):0,J=M.readyState===WebSocket.OPEN,he=C.lastCaptureStatusAt>0,$=he&&R<=jm,ie=he&&(!C.captureAlive||!C.helperAlive)&&R>N0,we=he&&R>jm,me=!he&&D>0&&z-D>T0,ze=D>0&&(C.lastAcceptedAt<=0?z-D>Bu:U>Bu);J&&D>0&&(ie||we||me)?B>=Fu.length&&!H?(h("error"),b("Remote audio capture heartbeat stopped. Toggle Audio off and on to retry.")):!H&&z>=q?W():H||h("stalled"):J&&ze&&!H&&C.audioContextState!=="suspended"&&C.audioContextState!=="interrupted"&&h($?"silent":"open"),w({queuedMs:Math.max(0,(c.current-j.currentTime)*1e3),browserAgeMs:C.browserAgeMs,captureAgeMs:C.captureAgeMs,captureStatusAgeMs:R,silentForMs:C.silentForMs,captureAlive:C.captureAlive,helperAlive:C.helperAlive,captureRestartCount:C.captureRestartCount,localProcessingAgeMs:C.localProcessingAgeMs,lastPacketAgeMs:Y,lastAcceptedAgeMs:U,framesReceived:C.framesReceived,drops:C.drops,resyncs:C.resyncs,pendingDecodes:C.pendingDecodes,lastFrameSeq:C.lastFrameSeq,audioContextState:C.audioContextState,stalledCount:C.stalledCount,automaticRestarts:C.automaticRestarts,lastUpdatedAt:Date.now()})},250),se=()=>{F(),(String(j.state)==="suspended"||String(j.state)==="interrupted")&&ue()},oe=()=>{document.visibilityState==="visible"&&ue()},K=()=>{ue()};return j.addEventListener("statechange",se),document.addEventListener("visibilitychange",oe),window.addEventListener("pageshow",K),window.addEventListener("pointerdown",K),window.addEventListener("keydown",K),h("connecting"),b(""),F(),M.addEventListener("open",()=>{A||(D=performance.now(),C.lastPacketAt=D,C.lastAcceptedAt=0,C.lastCaptureStatusAt=0,C.lastPcmAtEpochMs=0,C.captureAlive=!1,C.helperAlive=!1,C.silentForMs=0,h("open"),M.send(JSON.stringify({type:"subscribe",deviceIds:[n]})),ue())}),M.addEventListener("message",z=>{if(typeof z.data=="string")return;const Y=z.data instanceof ArrayBuffer?z.data:null;if(!Y||Y.byteLength<5)return;const U=performance.now();C.lastPacketAt=U,(async()=>{try{const J=new DataView(Y).getUint32(0,!1);if(J<=0||J+4>Y.byteLength){ce();return}const he=new Uint8Array(Y.slice(4,4+J)),$=JSON.parse(new TextDecoder().decode(he)),ie=Y.slice(4+J),we=String($.frameKind||$.kind||"").toLowerCase();if($.type==="remote.audio.status"||we==="audio-status"){if(C.lastCaptureStatusAt=U,C.captureAlive=$.captureAlive===!0,C.helperAlive=$.helperAlive===!0,C.captureRestartCount=Math.max(0,Number($.restartCount||0)||0),C.lastPcmAtEpochMs=Math.max(0,Number($.lastPcmAtEpochMs||0)||0),C.silentForMs=Math.max(0,Number($.silentForMs||0)||0),C.captureAgeMs=C.lastPcmAtEpochMs>0?Math.max(0,Date.now()-C.lastPcmAtEpochMs):C.silentForMs,C.captureAlive&&C.helperAlive){if(B=0,q=0,!H){b("");const ze=String(j.state)==="running",Pe=C.lastAcceptedAt>0&&performance.now()-C.lastAcceptedAt<=Bu;h(ze?Pe?"playing":"silent":"suspended")}}else H||h("stalled");return}const me={deviceId:String($.deviceId||""),frameSeq:Number($.frameSeq||0),streamId:String($.streamId||""),mimeType:String($.mimeType||"audio/webm;codecs=opus"),sampleRate:Number($.sampleRate||48e3),channels:Number($.channels||2),capturedAt:String($.capturedAt||""),receivedAt:String($.receivedAt||""),byteLength:Number($.byteLength||ie.byteLength),payload:ie};if(!me.deviceId||A)return;if(performance.now()-U>Wx){ce();return}if(C.pendingDecodes>=A0){ce();return}C.pendingDecodes+=1;try{const ze=C0(me.mimeType)?R0(j,me,ie):await j.decodeAudioData(ie.slice(0));if(C.localProcessingAgeMs=Math.max(0,performance.now()-U),A)return;if(C.localProcessingAgeMs>Wx){ce();return}if(me.frameSeq>0&&me.frameSeq<=C.lastFrameSeq){ce();return}if(C.activeStreamId&&me.streamId!==C.activeStreamId&&me.frameSeq<=C.lastFrameSeq){ce();return}me.streamId&&me.streamId!==C.activeStreamId&&(C.activeStreamId=me.streamId,C.lastFrameSeq=0,L());const Pe=j.currentTime;Math.max(0,c.current-Pe)>k0&&(L(),C.resyncs+=1);const He=j.createBufferSource();He.buffer=ze,He.connect(j.destination),T.add(He),He.onended=()=>{T.delete(He),He.onended=null};const Le=Math.max(j.currentTime+M0,c.current);He.start(Le),c.current=Le+ze.duration,C.browserAgeMs=Qx(me.receivedAt),C.captureAgeMs=Qx(me.capturedAt),C.lastAcceptedAt=performance.now(),C.framesReceived+=1,C.lastFrameSeq=me.frameSeq,B=0,q=0,x(me),ue();const Fe=String(j.state)==="running";Fe&&b(""),h(Fe?"playing":"suspended")}finally{C.pendingDecodes=Math.max(0,C.pendingDecodes-1)}}catch(R){A||(h("error"),b(R instanceof Error?R.message:String(R)))}})()}),M.addEventListener("error",()=>{A||(h("error"),b("Remote audio WebSocket error."))}),M.addEventListener("close",()=>{A||h("closed")}),()=>{A=!0,window.clearInterval(Q),j.removeEventListener("statechange",se),document.removeEventListener("visibilitychange",oe),window.removeEventListener("pageshow",K),window.removeEventListener("pointerdown",K),window.removeEventListener("keydown",K),L(!1),M.close(),j.close().catch(()=>{}),r.current===j&&(r.current=null)}},[n,a,i]),{state:d,lastFrame:p,stats:g,error:v}}const eh={revision:0,settings:{connection:{usePinToAddDevices:!0,pinValidityMinutes:30,rotatePinAfterPairing:!0,allowNewDevices:!0,approveNewDevices:!0,startWithComputer:!0,keepRunningInTray:!0,showConnectionNotifications:!0},security:{accessMode:"trusted-only",requireEncryptedConnections:!0,allowInternetConnections:!1,allowLanConnections:!0,allowUnencryptedLanFallback:!1,requireNewDeviceApproval:!0,requireAdministratorForSecurityChanges:!0,visibleControlIndicator:!0,lockOnControlEnd:!0,disconnectIdleControlSessions:!0,idleControlMinutes:30,keepSessionHistory:!0,sessionHistoryDays:30},control:{allowKeyboardMouse:!0,allowSystemShortcuts:!0,allowClipboardText:!0,allowRemoteRestart:!1,reconnectAfterRemoteRestart:!0,allowSwitchingMonitors:!0,showConnectionToolbar:!0,showRemoteCursor:!0,openControlOnDoubleClick:!0,startRemoteAudioWithControl:!1,fitRemoteScreen:!0,rememberLastMonitor:!0,keepControlReadyBetweenPages:!0},wall:{performanceMode:"auto",autoStart:!0,connectedOnly:!1,keepEmptySlots:!0,showDeviceStatus:!0,showPerformanceDetails:!1,pauseHiddenTiles:!0,reduceWhenHidden:!0,autoAdjustTileQuality:!0,rememberDevicePositions:!0},filesAudio:{allowFileTransfer:!0,allowFolderSync:!1,askBeforeReceivingFiles:!0,openReceivedFolder:!1,notifyTransferComplete:!0,allowOverwrite:!1,defaultReceiveFolder:"Desktop/LiveDeskFiles",maxFileSizeBytes:1073741824,allowRemoteAudio:!0,startAudioMuted:!1,rememberVolume:!0,automaticallyRecoverAudio:!0,showAudioTroubleshooting:!1,rollingBufferEnabled:!1,recordingQuality:"standard",timelapseIntervalSeconds:10,includeRemoteCursor:!0,captureSaveLocation:"LiveDesk Captures",captureAutoDelete:"never"},agent:{enabled:!1,defaultPermissionMode:"safe-auto",askBeforeDestructive:!0,allowProcessManagement:!0,allowServiceManagement:!0,allowFileChanges:!0,allowCommandExecution:!1,allowSoftwareInstallation:!1,allowPowerActions:!1,keepAuditHistory:!0,timeoutMinutes:10},advanced:{wallFrameMode:"auto",wallFps:20,wallMaxWidth:960,wallMaxHeight:540,wallQuality:55,controlFrameMode:"mode3-h264-hw",controlFps:30,controlMaxWidth:1920,controlMaxHeight:1080,controlQuality:60,transport:"auto",allowPlainLanFallback:!1,verboseLogs:!1,frameStatistics:!1}}},D0=[{id:"connection",label:"Connection",icon:Jo},{id:"security",label:"Security",icon:Sn},{id:"control",label:"Control",icon:an},{id:"wall",label:"Wall",icon:cc},{id:"files-audio",label:"Files & Audio",icon:Or},{id:"agent",label:"Agent",icon:Vi},{id:"advanced",label:"Advanced",icon:mh}];function Fi(n,a){return n?.settings?.[a]||eh.settings[a]}function nt({icon:n,title:a,description:i,children:r,disabled:c=!1,recommended:d=!1}){return l.jsxs("div",{className:`product-setting-row ${c?"disabled":""}`,children:[l.jsx("div",{className:"product-setting-control",children:r}),n&&l.jsx("span",{className:"product-setting-icon",children:l.jsx(n,{size:17})}),l.jsxs("div",{className:"product-setting-copy",children:[l.jsx("strong",{children:a}),d&&l.jsx("em",{children:"Recommended"}),l.jsx("small",{children:i})]})]})}function mt({checked:n,onChange:a,disabled:i=!1,label:r}){return l.jsxs("label",{className:"product-switch",children:[l.jsx("input",{"aria-label":r,type:"checkbox",checked:n,disabled:i,onChange:c=>a(c.target.checked)}),l.jsx("span",{})]})}function fl({value:n,onChange:a,options:i,disabled:r=!1,label:c}){return l.jsx("select",{"aria-label":c,value:String(n),disabled:r,onChange:d=>a(d.target.value),children:i.map(([d,h])=>l.jsx("option",{value:d,children:h},d))})}function L0({hubUrl:n="",initialTab:a="connection",pin:i,wall:r,control:c,agent:d,advancedExtras:h,captureGallery:p}){const[x,g]=f.useState(a),[w,v]=f.useState(null),[b,k]=f.useState("loading"),[j,M]=f.useState("");f.useEffect(()=>{let U=!0;return k("loading"),Be("/api/settings",void 0,n).then(R=>{U&&(v({revision:Number(R.revision||0),updatedAt:R.updatedAt,settings:R.settings}),k("saved"))}).catch(R=>{U&&(M(R instanceof Error?R.message:String(R)),v(eh),k("failed"))}),()=>{U=!1}},[n]);const T=async(U,R,J)=>{const he=w||eh,$=he,ie={...he,settings:{...he.settings,[U]:{...Fi(he,U),[R]:J}}};v(ie),k("saving"),M("");try{const we=await Be("/api/settings",{method:"PATCH",body:JSON.stringify({revision:he.revision,[U]:{[R]:J}})},n);v({revision:we.revision,updatedAt:we.updatedAt,settings:we.settings}),k("saved")}catch(we){v($),k("failed"),M(we instanceof Error?we.message:String(we))}},C=(U,R)=>J=>{T(U,R,J)},A=Fi(w,"security"),D=Fi(w,"connection"),H=Fi(w,"control"),B=Fi(w,"wall"),q=Fi(w,"filesAudio"),L=Fi(w,"agent"),F=f.useMemo(()=>A.allowInternetConnections===!1?{label:"Local only",tone:"local",detail:"Internet connections are disabled."}:A.requireEncryptedConnections&&A.requireNewDeviceApproval&&A.accessMode==="trusted-only"?{label:"Protected",tone:"protected",detail:"Encrypted connections and trusted-device approval are active."}:{label:"Needs attention",tone:"attention",detail:"Review access and encryption settings before sharing this Hub."},[A]),ue=`settings-panel-${x}`,W=l.jsxs("div",{className:"settings-tab-content product-settings-content",children:[l.jsxs("section",{className:"product-settings-hero",children:[l.jsxs("div",{children:[l.jsxs("span",{className:"settings-eyebrow",children:[l.jsx(Jo,{size:14})," Connection"]}),l.jsx("h2",{children:"Connect a device"}),l.jsx("p",{children:"Use the short PIN on the computer you want to add. The PIN is temporary and can be replaced at any time."})]}),l.jsxs("div",{className:"product-save-state",role:"status",children:[l.jsx(ny,{size:14})," ",b==="saving"?"Saving":b==="failed"?"Failed":b==="loading"?"Loading":"Saved"]})]}),i,l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Connection behavior"}),l.jsx("h3",{children:"New device access"})]}),l.jsx(ec,{size:20})]}),l.jsx(nt,{icon:ec,title:"Use PIN to add new devices",description:"Allow temporary PIN pairing from the client.",recommended:!0,children:l.jsx(mt,{checked:!!D.usePinToAddDevices,onChange:C("connection","usePinToAddDevices"),label:"Use PIN to add new devices"})}),l.jsx(nt,{icon:Sn,title:"Approve new devices on this Hub",description:"Ask for approval before an unfamiliar computer becomes trusted.",children:l.jsx(mt,{checked:!!D.approveNewDevices,onChange:C("connection","approveNewDevices"),label:"Approve new devices"})}),l.jsx(nt,{icon:nn,title:"Show connection notifications",description:"Show a short notice when a computer connects or leaves.",children:l.jsx(mt,{checked:!!D.showConnectionNotifications,onChange:C("connection","showConnectionNotifications"),label:"Show connection notifications"})})]})]}),ce=l.jsxs("div",{className:"settings-tab-content product-settings-content",children:[l.jsxs("section",{className:`security-status-card ${F.tone}`,children:[l.jsxs("div",{children:[l.jsx("span",{children:"Security status"}),l.jsx("strong",{children:F.label}),l.jsx("small",{children:F.detail})]}),l.jsx(Sn,{size:28})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Access mode"}),l.jsx("h3",{children:"Who may use this Hub?"})]}),l.jsx(oc,{size:20})]}),l.jsx(nt,{icon:Sn,title:"Access mode",description:"Choose the default boundary for remote sessions.",recommended:!0,children:l.jsx(fl,{value:String(A.accessMode),onChange:C("security","accessMode"),label:"Access mode",options:[["trusted-only","Trusted devices only"],["ask-every-time","Ask every time"],["view-only","View only"],["block-remote-access","Block remote access"]]})}),l.jsx(nt,{icon:Jo,title:"Require encrypted connections",description:"External connections cannot disable this protection.",recommended:!0,children:l.jsx(mt,{checked:!!A.requireEncryptedConnections,onChange:C("security","requireEncryptedConnections"),label:"Require encrypted connections"})}),l.jsx(nt,{icon:Jo,title:"Allow internet connections",description:"Keep off unless you intentionally expose this Hub beyond the LAN.",children:l.jsx(mt,{checked:!!A.allowInternetConnections,onChange:C("security","allowInternetConnections"),label:"Allow internet connections"})}),l.jsx(nt,{icon:an,title:"Allow LAN connections",description:"Permit connections from the local network.",children:l.jsx(mt,{checked:!!A.allowLanConnections,onChange:C("security","allowLanConnections"),label:"Allow LAN connections"})}),l.jsx(nt,{icon:Sn,title:"Require approval for new devices",description:"New computers must be approved before remote access is granted.",children:l.jsx(mt,{checked:!!A.requireNewDeviceApproval,onChange:C("security","requireNewDeviceApproval"),label:"Require approval for new devices"})})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Session protection"}),l.jsx("h3",{children:"End sessions safely"})]}),l.jsx(nn,{size:20})]}),l.jsx(nt,{icon:an,title:"Show an indicator while Control is active",description:"Make active remote control visible on the local computer.",children:l.jsx(mt,{checked:!!A.visibleControlIndicator,onChange:C("security","visibleControlIndicator"),label:"Show Control indicator"})}),l.jsx(nt,{icon:oc,title:"Lock the remote computer when Control ends",description:"Protect the local screen after a Control session.",children:l.jsx(mt,{checked:!!A.lockOnControlEnd,onChange:C("security","lockOnControlEnd"),label:"Lock after Control ends"})}),l.jsx(nt,{icon:nn,title:"Disconnect idle Control sessions",description:"Automatically close inactive Control sessions.",children:l.jsx(mt,{checked:!!A.disconnectIdleControlSessions,onChange:C("security","disconnectIdleControlSessions"),label:"Disconnect idle sessions"})}),l.jsx(nt,{icon:nn,title:"Idle timeout",description:"Time before an inactive Control session closes.",disabled:!A.disconnectIdleControlSessions,children:l.jsx(fl,{value:Number(A.idleControlMinutes),onChange:U=>C("security","idleControlMinutes")(Number(U)),disabled:!A.disconnectIdleControlSessions,label:"Idle timeout",options:[["5","5 minutes"],["15","15 minutes"],["30","30 minutes"],["60","1 hour"],["1440","Never"]]})})]})]}),Q=l.jsxs("div",{className:"settings-tab-content product-settings-content",children:[l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Remote use"}),l.jsx("h3",{children:"What can a connected user do?"})]}),l.jsx(an,{size:20})]}),l.jsx(nt,{icon:an,title:"Keyboard and mouse control",description:"Allow the Hub to send keyboard and pointer input.",recommended:!0,children:l.jsx(mt,{checked:!!H.allowKeyboardMouse,onChange:C("control","allowKeyboardMouse"),label:"Keyboard and mouse control"})}),l.jsx(nt,{icon:Ob,title:"System shortcuts",description:"Allow shortcut keys such as Alt-Tab and the system key.",children:l.jsx(mt,{checked:!!H.allowSystemShortcuts,onChange:C("control","allowSystemShortcuts"),label:"System shortcuts"})}),l.jsx(nt,{icon:ec,title:"Clipboard text sharing",description:"Share plain text through the remote session.",children:l.jsx(mt,{checked:!!H.allowClipboardText,onChange:C("control","allowClipboardText"),label:"Clipboard text sharing"})}),l.jsx(nt,{icon:nn,title:"Remote restart",description:"Allow restart requests from Control.",disabled:!H.allowKeyboardMouse,children:l.jsx(mt,{checked:!!H.allowRemoteRestart,onChange:C("control","allowRemoteRestart"),disabled:!H.allowKeyboardMouse,label:"Remote restart"})}),l.jsx(nt,{icon:an,title:"Switching monitors",description:"Allow the viewer to select another connected display.",children:l.jsx(mt,{checked:!!H.allowSwitchingMonitors,onChange:C("control","allowSwitchingMonitors"),label:"Switching monitors"})})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Session behavior"}),l.jsx("h3",{children:"Make Control predictable"})]}),l.jsx(qn,{size:20})]}),l.jsx(nt,{icon:an,title:"Open Control on double-click",description:"Double-clicking a Wall tile opens its Control view.",children:l.jsx(mt,{checked:!!H.openControlOnDoubleClick,onChange:C("control","openControlOnDoubleClick"),label:"Open Control on double-click"})}),l.jsx(nt,{icon:nn,title:"Start audio with Control",description:"Keep audio muted by default for new sessions.",children:l.jsx(mt,{checked:!!H.startRemoteAudioWithControl,onChange:C("control","startRemoteAudioWithControl"),label:"Start audio with Control"})}),l.jsx(nt,{icon:an,title:"Fit remote screen to window",description:"Scale the remote display to the available Control area.",children:l.jsx(mt,{checked:!!H.fitRemoteScreen,onChange:C("control","fitRemoteScreen"),label:"Fit remote screen"})}),l.jsx(nt,{icon:nn,title:"Keep Control ready between pages",description:"Faster reconnection for 1 minute.",recommended:!0,children:l.jsx(mt,{checked:!!H.keepControlReadyBetweenPages,onChange:C("control","keepControlReadyBetweenPages"),label:"Keep Control ready between pages"})})]})]}),se=l.jsxs("div",{className:"settings-tab-content product-settings-content",children:[l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Performance mode"}),l.jsx("h3",{children:"Let LiveDesk choose the best path"})]}),l.jsx(cc,{size:20})]}),l.jsx(nt,{icon:Vi,title:"Performance mode",description:"Automatic mode balances responsiveness and image quality.",recommended:!0,children:l.jsx(fl,{value:String(B.performanceMode),onChange:C("wall","performanceMode"),label:"Performance mode",options:[["auto","Auto"],["responsive","Prioritize responsiveness"],["quality","Prioritize image quality"],["custom","Custom"]]})}),l.jsx("p",{className:"settings-help",children:"Streaming details are available under Advanced for diagnostics and development."})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Wall behavior"}),l.jsx("h3",{children:"What should the Wall show?"})]}),l.jsx(nn,{size:20})]}),[["autoStart","Start Wall automatically","Start a live view when a computer connects."],["connectedOnly","Show only connected devices","Hide disconnected slots."],["keepEmptySlots","Keep empty slots visible","Preserve the layout when a device leaves."],["showDeviceStatus","Show device status on tiles","Display compact machine status."],["showPerformanceDetails","Show performance details","Show advanced frame diagnostics on tiles."],["pauseHiddenTiles","Pause hidden tiles","Reduce capture work for tiles outside the visible area."],["reduceWhenHidden","Reduce activity when the window is hidden","Lower background work when the browser is not visible."],["autoAdjustTileQuality","Automatically adjust tile quality","Adapt tile quality to Wall size and load."]].map(([U,R,J])=>l.jsx(nt,{icon:an,title:R,description:J,children:l.jsx(mt,{checked:!!B[U],onChange:C("wall",U),label:R})},U))]})]}),oe=l.jsxs("div",{className:"settings-tab-content product-settings-content",children:[l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"File permissions"}),l.jsx("h3",{children:"Move files deliberately"})]}),l.jsx(Or,{size:20})]}),l.jsx(nt,{icon:Or,title:"Allow file transfer",description:"Permit Hub-to-device file delivery.",recommended:!0,children:l.jsx(mt,{checked:!!q.allowFileTransfer,onChange:C("filesAudio","allowFileTransfer"),label:"Allow file transfer"})}),l.jsx(nt,{icon:cc,title:"Allow folder sync",description:"Enable recurring folder synchronization.",disabled:!q.allowFileTransfer,children:l.jsx(mt,{checked:!!q.allowFolderSync,onChange:C("filesAudio","allowFolderSync"),disabled:!q.allowFileTransfer,label:"Allow folder sync"})}),l.jsx(nt,{icon:Sn,title:"Ask before receiving files",description:"Require local confirmation before a transfer is written.",children:l.jsx(mt,{checked:!!q.askBeforeReceivingFiles,onChange:C("filesAudio","askBeforeReceivingFiles"),label:"Ask before receiving files"})}),l.jsx(nt,{icon:Or,title:"Allow overwrite",description:"Permit replacing an existing destination file.",children:l.jsx(mt,{checked:!!q.allowOverwrite,onChange:C("filesAudio","allowOverwrite"),label:"Allow overwrite"})})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Audio permissions"}),l.jsx("h3",{children:"Remote sound"})]}),l.jsx(nn,{size:20})]}),l.jsx(nt,{icon:nn,title:"Allow remote audio",description:"Permit audio capture from connected computers.",recommended:!0,children:l.jsx(mt,{checked:!!q.allowRemoteAudio,onChange:C("filesAudio","allowRemoteAudio"),label:"Allow remote audio"})}),l.jsx(nt,{icon:nn,title:"Start audio muted",description:"New audio sessions begin silent.",children:l.jsx(mt,{checked:!!q.startAudioMuted,onChange:C("filesAudio","startAudioMuted"),label:"Start audio muted"})}),l.jsx(nt,{icon:nn,title:"Automatically recover audio",description:"Recover from temporary capture or transport stalls.",children:l.jsx(mt,{checked:!!q.automaticallyRecoverAudio,onChange:C("filesAudio","automaticallyRecoverAudio"),label:"Automatically recover audio"})})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Capture defaults"}),l.jsx("h3",{children:"Screen recording"})]}),l.jsx(an,{size:20})]}),l.jsx(nt,{icon:nn,title:"Keep a Last 30s buffer",description:"Keep recent video in memory only until you explicitly save it.",children:l.jsx(mt,{checked:!!q.rollingBufferEnabled,onChange:C("filesAudio","rollingBufferEnabled"),label:"Keep a Last 30s buffer"})}),l.jsx(nt,{icon:nn,title:"Recording quality",description:"Choose the WebM bitrate profile.",children:l.jsx(fl,{value:String(q.recordingQuality),onChange:C("filesAudio","recordingQuality"),label:"Recording quality",options:[["standard","Standard"],["high","High"]]})}),l.jsx(nt,{icon:nn,title:"Timelapse interval",description:"Capture one frame at the selected interval.",children:l.jsx(fl,{value:Number(q.timelapseIntervalSeconds),onChange:U=>C("filesAudio","timelapseIntervalSeconds")(Number(U)),label:"Timelapse interval",options:[["5","5 seconds"],["10","10 seconds"],["30","30 seconds"],["60","60 seconds"]]})}),l.jsx(nt,{icon:an,title:"Include remote cursor",description:"Include the cursor indicator when the source provides it.",children:l.jsx(mt,{checked:!!q.includeRemoteCursor,onChange:C("filesAudio","includeRemoteCursor"),label:"Include remote cursor"})}),l.jsx(nt,{icon:Or,title:"Capture save location",description:"Captures are stored inside the Hub capture library.",children:l.jsx(fl,{value:String(q.captureSaveLocation),onChange:C("filesAudio","captureSaveLocation"),label:"Capture save location",options:[[String(q.captureSaveLocation||"LiveDesk Captures"),"LiveDesk Captures"]]})}),l.jsx(nt,{icon:Or,title:"Automatic deletion",description:"Keep saved captures until you delete them.",children:l.jsx(fl,{value:String(q.captureAutoDelete),onChange:C("filesAudio","captureAutoDelete"),label:"Automatic deletion",options:[["never","Never"],["7-days","After 7 days"],["30-days","After 30 days"]]})})]}),p]}),K=l.jsxs("div",{className:"settings-tab-content product-settings-content",children:[l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Agent safety"}),l.jsx("h3",{children:"AI workstation operations"})]}),l.jsx(Vi,{size:20})]}),l.jsx(nt,{icon:Vi,title:"Enable AI Agent on devices",description:"Allow Agent runs to reach connected workstations.",recommended:!0,children:l.jsx(mt,{checked:!!L.enabled,onChange:C("agent","enabled"),label:"Enable AI Agent"})}),l.jsx(nt,{icon:Sn,title:"Default permission mode",description:"Safe Auto keeps destructive operations behind approval.",children:l.jsx(fl,{value:String(L.defaultPermissionMode),onChange:C("agent","defaultPermissionMode"),label:"Default Agent permission mode",options:[["ask","Ask"],["safe-auto","Safe Auto"],["full-access","Full Access"],["custom","Custom"]]})}),l.jsx(nt,{icon:Sn,title:"Ask before destructive operations",description:"Locked on for Safe Auto and destructive actions.",disabled:!L.enabled,children:l.jsx(mt,{checked:!!L.askBeforeDestructive,onChange:C("agent","askBeforeDestructive"),disabled:!L.enabled,label:"Ask before destructive operations"})}),l.jsx(nt,{icon:nn,title:"Keep Agent audit history",description:"Retain an inspectable record of Agent runs.",children:l.jsx(mt,{checked:!!L.keepAuditHistory,onChange:C("agent","keepAuditHistory"),label:"Keep Agent audit history"})}),l.jsx(nt,{icon:nn,title:"Stop Agent tasks after timeout",description:"Maximum runtime for one task.",children:l.jsx(fl,{value:Number(L.timeoutMinutes),onChange:U=>C("agent","timeoutMinutes")(Number(U)),label:"Agent task timeout",options:[["1","1 minute"],["5","5 minutes"],["10","10 minutes"],["30","30 minutes"],["60","1 hour"]]})})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Detailed permissions"}),l.jsx("h3",{children:"Capabilities"})]}),l.jsx(Sn,{size:20})]}),[["allowProcessManagement","Allow process management"],["allowServiceManagement","Allow service management"],["allowFileChanges","Allow file changes"],["allowCommandExecution","Allow command execution"],["allowSoftwareInstallation","Allow software installation"],["allowPowerActions","Allow power actions"]].map(([U,R])=>l.jsx(nt,{icon:Sn,title:R,description:U.includes("allowCommand")||U.includes("Installation")||U.includes("Power")?"Disabled by default for safety.":"Applied by the Hub and checked again by the Client.",children:l.jsx(mt,{checked:!!L[U],onChange:C("agent",U),label:R})},U))]}),l.jsx("p",{className:"settings-help",children:"The existing Codex runtime and audit controls remain available below in Advanced and the Agent diagnostics panel."})]}),Y=x==="connection"?W:x==="security"?ce:x==="control"?Q:x==="wall"?se:x==="files-audio"?oe:x==="agent"?l.jsxs(l.Fragment,{children:[K,d]}):l.jsxs("div",{className:"settings-tab-content product-settings-content",children:[h,l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Developer controls"}),l.jsx("h3",{children:"Streaming and diagnostics"})]}),l.jsx(mh,{size:20})]}),l.jsx("p",{className:"settings-help",children:"Codec, frame rate, resolution, quality, Atlas layout, and decoder preferences are intentionally kept here."}),r,c]})]});return l.jsxs("section",{className:"settings-page",children:[l.jsx("div",{className:"settings-page-tabs",role:"tablist","aria-label":"LiveDesk settings",children:D0.map(({id:U,label:R,icon:J})=>l.jsxs("button",{className:x===U?"active":"",id:`settings-tab-${U}`,role:"tab","aria-selected":x===U,"aria-controls":`settings-panel-${U}`,tabIndex:x===U?0:-1,onClick:()=>g(U),type:"button",children:[l.jsx(J,{size:16}),R]},U))}),j&&l.jsx("div",{className:"agent-settings-alert error",role:"alert",children:j}),l.jsx("section",{className:"settings-page-panel",id:ue,role:"tabpanel","aria-labelledby":`settings-tab-${x}`,tabIndex:0,children:Y})]})}function z0({children:n}){return l.jsx("div",{className:"settings-tab-content",children:n})}function _0({children:n}){return l.jsx("div",{className:"settings-tab-content",children:n})}function O0({children:n}){return l.jsx("div",{className:"settings-tab-content",children:n})}const wy={enabled:!0,provider:"codex",codexModelId:"",codexReasoningEffort:"medium",codexTaskTimeoutMs:6e5,codexMaxToolCalls:20,codexWorkingDirectory:"",codexResumeSessions:!0,codexShowDetailedEvents:!0,deterministicParserFirst:!0,generateSummary:!0,fallbackSummary:!0,includeRawDeviceDetails:!1,baseUrl:"https://opencode.ai/zen/go/v1",defaultModelId:"deepseek-v4-flash"};function Xx(n){return{...wy,...n||{}}}function I0({hubUrl:n}){const[a,i]=f.useState(wy),[r,c]=f.useState(null),[d,h]=f.useState(""),[p,x]=f.useState(""),[g,w]=f.useState(""),[v,b]=f.useState("");f.useEffect(()=>{let F=!0;return Be("/api/settings/agent",void 0,n).then(ue=>{F&&(c(ue.settings),i(Xx(ue.settings)))}).catch(ue=>{F&&b(ue instanceof Error?ue.message:String(ue))}),()=>{F=!1}},[n]);const k=(F,ue)=>i(W=>({...W,[F]:ue})),j=F=>{c(F),i(Xx(F))},M=async()=>{x("save"),b(""),w("");try{const F={...a};d.trim()&&(F.apiKey=d.trim());const ue=await Be("/api/settings/agent",{method:"PUT",body:JSON.stringify(F)},n);j(ue.settings),h(""),w("Agent settings saved.")}catch(F){b(F instanceof Error?F.message:String(F))}finally{x("")}},T=async()=>{x("reset"),b("");try{const F=await Be("/api/settings/agent/reset",{method:"POST",body:JSON.stringify({})},n);j(F.settings),w("Codex defaults restored.")}catch(F){b(F instanceof Error?F.message:String(F))}finally{x("")}},C=async()=>{x("test"),b(""),w("");try{const F=await Be("/api/settings/agent/test",{method:"POST",body:JSON.stringify({})},n),ue=await Be("/api/settings/agent",void 0,n);j(ue.settings),w(`Codex connection verified with ${F.connection?.modelName||"the configured model"}${F.connection?.latencyMs?` in ${F.connection.latencyMs} ms.`:"."}`)}catch(F){b(F instanceof Error?F.message:String(F))}finally{x("")}},A=async()=>{x("clear-key"),b("");try{const F=await Be("/api/settings/agent/api-key",{method:"DELETE"},n);j(F.settings),h(""),w("The optional OpenCode Go key was removed.")}catch(F){b(F instanceof Error?F.message:String(F))}finally{x("")}},D=r?.codexInstallation==="installed"&&r.codexAuth==="signed-in",H=r?.securityStatus,B=H?.state||"unavailable",q=B==="verified"?"Verified":B==="configured"?"Configured":"Unavailable",L=[["Codex home",H?.isolatedCodexHome],["Environment variables",H?.restrictedEnvironment],["LiveDesk MCP only",H?.livedeskMcpOnly],["Selected-device scope",H?.selectedDeviceScopeEnforced],["Fail-closed execution",H?.failClosed]];return l.jsxs("div",{className:"settings-tab-content agent-settings-content",children:[l.jsxs("header",{className:"agent-settings-header",children:[l.jsxs("div",{children:[l.jsxs("span",{className:"settings-eyebrow",children:[l.jsx(jx,{size:14})," Agent AI"]}),l.jsx("h2",{children:"Codex SDK"}),l.jsx("p",{children:"Codex owns the agent reasoning loop. LiveDesk keeps the existing task manager and exposes only safe, read-only workstation tools."})]}),l.jsxs("label",{className:"settings-toggle agent-enable-toggle",children:[l.jsx("input",{type:"checkbox",checked:a.enabled,onChange:F=>k("enabled",F.target.checked)}),l.jsx("span",{children:"Enable Agent AI"})]})]}),v&&l.jsx("div",{className:"agent-settings-alert error",role:"alert",children:v}),g&&l.jsx("div",{className:"agent-settings-alert success",role:"status",children:g}),l.jsxs("div",{className:"settings-section-grid",children:[l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Provider"}),l.jsx("h3",{children:"Codex is the default"})]}),l.jsx(ec,{size:20})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Agent provider"}),l.jsxs("select",{value:a.provider,onChange:F=>k("provider",F.target.value),children:[l.jsx("option",{value:"codex",children:"Codex SDK"}),l.jsx("option",{value:"opencode-go",children:"OpenCode Go (optional legacy)"})]})]}),l.jsxs("div",{className:"agent-connection-row",children:[l.jsx("span",{className:`agent-connection-dot ${D?"connected":r?.codexAuth==="not-signed-in"?"unavailable":""}`}),l.jsx("span",{children:r?.codexInstallation==="not-installed"?"Codex SDK not installed":r?.codexAuth==="signed-in"?"Codex CLI signed in":r?.codexAuth==="not-signed-in"?"Codex CLI sign-in required":"Codex status not tested"}),l.jsxs("button",{className:"settings-reset",onClick:()=>{C()},disabled:p!==""||a.provider!=="codex",type:"button",children:[l.jsx(Ib,{size:15})," ",p==="test"?"Testing":"Test connection"]})]}),l.jsxs("p",{className:"settings-help",children:[l.jsx(Bb,{size:12})," Authentication is owned by the installed Codex CLI. LiveDesk never asks for or stores a ChatGPT token."]}),r?.codexPath&&l.jsxs("p",{className:"settings-help",children:["CLI: ",r.codexPath]})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Codex runtime"}),l.jsx("h3",{children:"Model and reasoning"})]}),l.jsx(jx,{size:20})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Model"}),l.jsx("input",{value:a.codexModelId,onChange:F=>k("codexModelId",F.target.value),placeholder:"Codex default",disabled:a.provider!=="codex"})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Reasoning effort"}),l.jsxs("select",{value:a.codexReasoningEffort,onChange:F=>k("codexReasoningEffort",F.target.value),disabled:a.provider!=="codex",children:[l.jsx("option",{value:"minimal",children:"Minimal"}),l.jsx("option",{value:"low",children:"Low"}),l.jsx("option",{value:"medium",children:"Medium"}),l.jsx("option",{value:"high",children:"High"}),l.jsx("option",{value:"xhigh",children:"Extra high"})]})]}),l.jsxs("div",{className:"settings-field-grid",children:[l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Task timeout (ms)"}),l.jsx("input",{type:"number",min:"30000",max:"1800000",step:"10000",value:a.codexTaskTimeoutMs,onChange:F=>k("codexTaskTimeoutMs",Number(F.target.value)),disabled:a.provider!=="codex"})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Max tool calls"}),l.jsx("input",{type:"number",min:"1",max:"100",value:a.codexMaxToolCalls,onChange:F=>k("codexMaxToolCalls",Number(F.target.value)),disabled:a.provider!=="codex"})]})]})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Workspace"}),l.jsx("h3",{children:"Restricted execution context"})]}),l.jsx(Sn,{size:20})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Working directory"}),l.jsx("input",{value:r?.agentWorkspacePath||a.codexWorkingDirectory,readOnly:!0})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:a.codexResumeSessions,onChange:F=>k("codexResumeSessions",F.target.checked),disabled:a.provider!=="codex"}),l.jsx("span",{children:"Allow session resume"})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:a.codexShowDetailedEvents,onChange:F=>k("codexShowDetailedEvents",F.target.checked),disabled:a.provider!=="codex"}),l.jsx("span",{children:"Show detailed Codex events"})]}),l.jsx("p",{className:"settings-help",children:"The agent receives no project path or arbitrary filesystem directory. It can call LiveDesk MCP tools only."})]})]}),a.provider==="opencode-go"&&l.jsxs("section",{className:"settings-section-card agent-legacy-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Developer fallback"}),l.jsx("h3",{children:"OpenCode Go"})]}),l.jsx(ec,{size:20})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Base URL"}),l.jsx("input",{value:a.baseUrl,onChange:F=>k("baseUrl",F.target.value)})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"API key"}),l.jsx("input",{type:"password",value:d,onChange:F=>h(F.target.value),placeholder:r?.hasApiKey?r.apiKeyPreview:"Stored only in the Hub",autoComplete:"new-password"})]}),l.jsxs("div",{className:"settings-action-row",children:[l.jsxs("button",{className:"settings-reset",onClick:()=>{A()},disabled:p!==""||!r?.hasApiKey,type:"button",children:[l.jsx(hh,{size:15})," Clear key"]}),l.jsx("span",{className:"settings-help",children:"This provider does not run the Codex MCP tool loop."})]})]}),l.jsxs("div",{className:"settings-section-grid",children:[l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Agent behavior"}),l.jsx("h3",{children:"Predictable operation"})]}),l.jsx(qn,{size:20})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:a.deterministicParserFirst,onChange:F=>k("deterministicParserFirst",F.target.checked)}),l.jsx("span",{children:"Use deterministic parser before Codex"})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:a.generateSummary,onChange:F=>k("generateSummary",F.target.checked)}),l.jsx("span",{children:"Generate task summaries"})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:a.fallbackSummary,onChange:F=>k("fallbackSummary",F.target.checked)}),l.jsx("span",{children:"Fallback to deterministic summaries"})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:a.includeRawDeviceDetails,onChange:F=>k("includeRawDeviceDetails",F.target.checked)}),l.jsx("span",{children:"Include raw device details in summaries"})]})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Safety"}),l.jsx("h3",{children:"Locked execution boundary"})]}),l.jsx(Sn,{size:20})]}),["Arbitrary shell commands","PowerShell and Bash","Filesystem writes, deletes, and installs","Reboot, shutdown, and process termination","Network access and web search"].map(F=>l.jsxs("div",{className:"agent-safety-row",children:[l.jsx(Fb,{size:15}),l.jsx("span",{children:F}),l.jsx("strong",{children:"Blocked"})]},F)),L.map(([F])=>l.jsxs("div",{className:"agent-safety-row",children:[l.jsx(Sn,{size:15}),l.jsx("span",{children:F}),l.jsx("strong",{className:B==="unavailable"?"agent-safety-failed":B==="configured"?"agent-safety-configured":"agent-safety-verified",children:q})]},F)),l.jsx("p",{className:"settings-help",children:"Configured means the boundary is present but has not completed runtime verification. Test the connection or start an Agent run to verify it."})]})]}),l.jsxs("div",{className:"settings-action-row agent-settings-actions",children:[l.jsxs("button",{className:"settings-reset",onClick:()=>{T()},disabled:p!=="",type:"button",children:[l.jsx(tc,{size:15})," Reset defaults"]}),l.jsxs("button",{className:"text-button primary",onClick:()=>{M()},disabled:p!=="",type:"button",children:[l.jsx(ny,{size:15})," ",p==="save"?"Saving":"Save Agent settings"]})]})]})}new Date().valueOf();function Ls(n){const[a,i]=f.useState(n),r=f.useRef(n);return f.useEffect(()=>{if(r.current!==n){if(Array.isArray(r.current)&&Array.isArray(n)&&r.current.length===0&&n.length===0)return;r.current=n,i(n)}},[n]),[a,i]}function wh(n,a){return typeof n=="function"?typeof a=="object"?n(a):n():n}function $r(n,a="data-id"){let i=n;for(!i.tagName&&n.target&&(i=n.target);i;){if(i.getAttribute&&i.getAttribute(a))return i;i=i.parentNode}return null}function B0(n,a="data-id"){const i=$r(n,a);return i?i.getAttribute(a):null}function mc(n,a="data-id"){const i=$r(n,a);return i?Sd(i,a):null}function Sd(n,a="data-id"){const i=n.getAttribute(a);return i?F0(i):null}function Cn(n){return typeof n=="string"?":"+n:n}function F0(n){if(n.startsWith(":"))return n.substring(1);const a=n*1;return isNaN(a)?n:a}function H0(){return{detect:()=>!0,addEvent:function(n,a,i){return n.addEventListener(a,i),()=>n.removeEventListener(a,i)},addGlobalEvent:function(n,a){return document.addEventListener(n,a),()=>document.removeEventListener(n,a)},getTopNode:function(){return window.document.body}}}var va=H0();function bh(n){Object.assign(va,n)}function Zx(n,a,i){function r(c){const d=$r(c);if(!d)return;const h=Sd(d);if(typeof a=="function")return a(h,c);let p,x=c.target;for(;x!=d;){if(p=x.dataset?x.dataset.action:null,p&&a[p]){a[p](h,c);return}x=x.parentNode}a[i]&&a[i](h,c)}va.addEvent(n,i,r)}function Ur(n,a){Zx(n,a,"click"),a.dblclick&&Zx(n,a.dblclick,"dblclick")}function $0(n,a){for(let i=n.length-1;i>=0;i--)if(n[i]===a){n.splice(i,1);break}}function U0(n,a,i){for(let r=0;r<hl.length;r++){if(r===i)continue;const c=hl[r],d=c.props.parent?.();if(d&&n.contains(d)&&c.node.contains(a))return!0}return!1}var by=new Date,pd=!1,Hu=[],hl=[],Jx=n=>{const a=n.target;if(pd||!a.isConnected){pd=!1;return}for(let i=hl.length-1;i>=0;i--){const{node:r,date:c,props:d}=hl[i];if(!(c>by)&&!r.contains(a)&&r!==a&&(U0(r,a,i)||(d.callback&&d.callback(n),d.modal||n.defaultPrevented)))break}},P0=n=>{by=new Date,pd=!0;for(let a=hl.length-1;a>=0;a--){const{node:i}=hl[a];if(!i.contains(n.target)&&i!==n.target){pd=!1;break}}};function zs(n,a){Hu.length||(Hu=[va.addGlobalEvent("click",Jx,n),va.addGlobalEvent("contextmenu",Jx,n),va.addGlobalEvent("mousedown",P0,n)]),typeof a!="object"&&(a={callback:a});const i={node:n,date:new Date,props:a};return hl.push(i),{destroy(){$0(hl,i),hl.length||(Hu.forEach(r=>r()),Hu=[])}}}var $u=n=>n.indexOf("bottom")!==-1,Uu=n=>n.indexOf("left")!==-1,Pu=n=>n.indexOf("right")!==-1,km=n=>n.indexOf("top")!==-1,ev=n=>n.indexOf("fit")!==-1,Go=n=>n.indexOf("overlap")!==-1,q0=n=>n.split("-").every(a=>["center","fit"].indexOf(a)>-1),G0=n=>{const a=n.match(/(start|center|end)/);return a?a[0]:null};function Y0(n,a){let i=0;const r=va.getTopNode(n);for(;n&&n!==r;){const c=getComputedStyle(n).position;if((c==="absolute"||c==="relative"||c==="fixed")&&(i=parseInt(getComputedStyle(n).zIndex)||0),n=n.parentNode,n===a)break}return i}var fn,_n,Yo,Dn;function Sy(n,a,i="bottom",r=0,c=0){if(!n)return null;fn=r,_n=c,Yo="auto";let d=0,h=0,p=i;const x=Cy(n),g=Go(i)?va.getTopNode(n):x;if(!x)return null;const w=x.getBoundingClientRect(),v=n.getBoundingClientRect(),b=g.getBoundingClientRect(),k=window.getComputedStyle(g),j={left:0,top:0,bottom:0,right:0};for(const H in j){const B=`border-${H}-width`;j[H]=parseFloat(k.getPropertyValue(B))}if(a){const H=Y0(a,x);d=Math.max(H+1,20)}if(a){if(Dn=a.getBoundingClientRect(),ev(i)&&(Yo=Dn.width+"px"),i!=="point")if(q0(i))ev(i)?fn=0:(fn=b.width/2,h=1),_n=(b.height-v.height)/2;else{const H=Go(i)?0:1;fn=Pu(i)?Dn.right+H:Dn.left-H,_n=$u(i)?Dn.bottom+1:Dn.top;const B=G0(i);B&&(Pu(i)||Uu(i)?B==="center"?_n-=(v.height-Dn.height)/2:B==="end"&&(_n-=v.height-Dn.height):($u(i)||km(i))&&(B==="center"?fn-=(v.width-Dn.width)/2:B==="end"&&(fn-=v.width-Dn.width),Go(i)||(fn+=1)))}}else Dn={left:r,right:r,top:c,bottom:c};const M=(Uu(i)||Pu(i))&&($u(i)||km(i));Uu(i)&&(h=2);const T=fn-v.width-b.left;a&&Uu(i)&&!M&&T<0&&(fn=Dn.right,h=0,p=p.replace("left","right"));const C=fn+v.width*(1-h/2)-b.right;if(C>0)if(!Pu(i))fn=b.right-j.right-v.width;else{const H=Dn.left-b.x-v.width;a&&!M&&H>=0?(fn=Dn.left-v.width,p=p.replace("right","left")):fn-=C+j.right}h&&(fn=Math.round(fn-v.width*h/2));const A=T<0||C>0||!M;km(i)&&(_n=Dn.top-v.height,a&&_n<b.y&&A&&(_n=Dn.bottom,p=p.replace("top","bottom")));const D=_n+v.height-b.bottom;return D>0&&(a&&$u(i)&&A?(_n-=v.height+Dn.height+1,p=p.replace("bottom","top")):_n-=D+j.bottom),fn-=w.left+j.left,_n-=w.top+j.top,fn=(Go(i)?fn:Math.max(fn,0))+g.scrollLeft,_n=(Go(i)?_n:Math.max(_n,0))+g.scrollTop,Yo=Yo||"auto",{at:p,x:fn,y:_n,z:d,width:Yo}}function Cy(n){const a=va.getTopNode(n);for(n&&(n=n.parentElement);n;){const i=getComputedStyle(n).position;if(n===a||i==="relative"||i==="absolute"||i==="fixed")return n;n=n.parentNode}return null}function V0(n){const a=[];let i=n;const r=va.getTopNode(n);for(;i&&i!==r&&!i.getAttribute("data-wx-portal-root");)getComputedStyle(i).position==="absolute"&&a.push(i),i=i.parentNode;return a}var tv=new Date().valueOf();function Sh(){return tv+=1,tv}function In(n){return n<10?"0"+n:n.toString()}function K0(n){const a=In(n);return a.length==2?"0"+a:a}function jy(n){const a=Math.floor(n/11)*11;return{start:a,end:a+11}}function Mm(n){const a=(n.getDay()+6)%7,i=new Date(n.valueOf());i.setDate(n.getDate()+(3-a)),i.setHours(0,0,0,0);const r=new Date(i.getFullYear(),0,1),c=Math.round((i.getTime()-r.getTime())/864e5);return 1+Math.floor(c/7)}var nv=["",""];function W0(n,a,i){switch(n){case"%d":return In(a.getDate());case"%m":return In(a.getMonth()+1);case"%j":return a.getDate();case"%n":return a.getMonth()+1;case"%y":return In(a.getFullYear()%100);case"%Y":return a.getFullYear();case"%D":return i.dayShort[a.getDay()];case"%l":return i.dayFull[a.getDay()];case"%M":return i.monthShort[a.getMonth()];case"%F":return i.monthFull[a.getMonth()];case"%h":return In((a.getHours()+11)%12+1);case"%g":return(a.getHours()+11)%12+1;case"%G":return a.getHours();case"%H":return In(a.getHours());case"%i":return In(a.getMinutes());case"%a":return((a.getHours()>11?i.pm:i.am)||nv)[0];case"%A":return((a.getHours()>11?i.pm:i.am)||nv)[1];case"%s":return In(a.getSeconds());case"%S":return K0(a.getMilliseconds());case"%W":return In(Mm(a));case"%w":{const r=i.weekStart??1;if(r===1)return In(Mm(a));const c=(a.getDay()-r+7)%7,d=(1-r+7)%7,h=new Date(a.valueOf());return h.setDate(a.getDate()+(d-c)),In(Mm(h))}case"%c":{let r=a.getFullYear()+"";return r+="-"+In(a.getMonth()+1),r+="-"+In(a.getDate()),r+="T",r+=In(a.getHours()),r+=":"+In(a.getMinutes()),r+=":"+In(a.getSeconds()),r}case"%Q":return Math.floor(a.getMonth()/3)+1;default:return n}}var Q0=/%[a-zA-Z]/g;function Ir(n,a){return typeof n=="function"?n:function(i){return i?(i.getMonth||(i=new Date(i)),n.replace(Q0,r=>W0(r,i,a))):""}}function av(n){return n&&typeof n=="object"&&!Array.isArray(n)}function th(n,a){for(const i in a){const r=a[i];av(n[i])&&av(r)?n[i]=th({...n[i]},a[i]):n[i]=a[i]}return n}function gc(n){return{getGroup(a){const i=n[a];return r=>i&&i[r]||r},getRaw(){return n},extend(a,i){if(!a)return this;let r;return i?r=th({...a},n):r=th({...n},a),gc(r)}}}var X0=oy();const Z0="en-US",J0={monthFull:["January","February","March","April","May","June","July","August","September","October","November","December"],monthShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayFull:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],hours:"Hours",minutes:"Minutes",done:"Done",clear:"Clear",today:"Today",am:["am","AM"],pm:["pm","PM"],weekStart:0,clockFormat:24},e1={ok:"OK",cancel:"Cancel",select:"Select","No data":"No data","Rows per page":"Rows per page","Total pages":"Total pages"},t1={timeFormat:"%H:%i",dateFormat:"%m/%d/%Y",monthYearFormat:"%F %Y",yearFormat:"%Y"},ky={core:e1,calendar:J0,formats:t1,lang:Z0},Ch=f.createContext(""),My=f.createContext({}),bs=f.createContext(null),Ay=f.createContext(null),kn=Object.freeze(Object.defineProperty({__proto__:null,fieldId:Ay,helpers:My,i18n:bs,theme:Ch},Symbol.toStringTag,{value:"Module"}));function Ny(n){const a=f.useContext(Ay),[i]=f.useState(()=>n||a||Sh());return i}function ic({type:n="",css:a="",icon:i="",disabled:r=!1,title:c="",tooltip:d,text:h="",children:p,onClick:x}){const g=f.useMemo(()=>{let v=n?n.split(" ").filter(b=>b!=="").map(b=>"wx-"+b).join(" "):"";return a+(a?" ":"")+v},[n,a]),w=v=>{x&&x(v)};return l.jsxs("button",{title:c,className:`wx-2ZWgb4 wx-button ${g} ${i&&!p?"wx-icon":""}`,disabled:r,onClick:w,"data-tooltip-text":d,children:[i&&l.jsx("i",{className:"wx-2ZWgb4 "+i}),p||h||" "]})}function n1({id:n,label:a="",inputValue:i="",value:r=!1,onChange:c,disabled:d=!1,css:h=""}){const p=Ny(n),[x,g]=Ls(r),w=({target:v})=>{const b=v.checked;g(b),c&&c({value:b,inputValue:i})};return l.jsxs("div",{className:`wx-2IvefP wx-checkbox ${h}`,children:[l.jsx("input",{type:"checkbox",id:p,disabled:d,className:"wx-2IvefP wx-check",checked:x,value:i,onChange:w}),l.jsxs("label",{htmlFor:p,className:"wx-2IvefP wx-label",children:[l.jsx("span",{className:"wx-2IvefP wx-before"}),a&&l.jsx("span",{className:"wx-2IvefP wx-after",children:a})]})]})}function jh({theme:n="",target:a,children:i}){const r=f.useRef(null),c=f.useRef(null),[d,h]=f.useState(null);r.current||(r.current=document.createElement("div"));const p=f.useContext(Ch);return f.useEffect(()=>{h(a||a1(c.current)||va.getTopNode(c.current))},[c.current]),l.jsxs(l.Fragment,{children:[l.jsx("span",{ref:c,style:{display:"none"}}),c.current&&d?X0.createPortal(l.jsx("div",{className:`wx-3ZWsT0 wx-${n||p}-theme`,children:i}),d):null]})}function a1(n){const a=va.getTopNode(n);for(;n&&n!==a&&!n.getAttribute("data-wx-portal-root");)n=n.parentNode;return n}function s1({left:n=0,top:a=0,at:i="bottom",parent:r=null,width:c="auto",css:d="",onCancel:h,children:p,trackScroll:x=!1}){const[g,w]=f.useState(0),[v,b]=f.useState(0),[k,j]=f.useState("auto"),[M,T]=f.useState(!1),C=f.useRef(null),A=f.useRef(null),D=f.useRef(h);f.useEffect(()=>{D.current=h},[h]);function H(q){return r&&(c+"").indexOf("%")>-1?c.replace(/(\d+)%/,(L,F)=>(F=F*r.offsetWidth/100+"px",c.replace(L,F))):c&&c!=="auto"?c:q}const B=f.useCallback(()=>{if(!C.current)return;const q=Sy(C.current,r,i,n,a);q&&(w(q.x),b(q.y),j(H(q.width)))},[C,r,i,n,a,c]);return f.useLayoutEffect(()=>{const q=F=>{D.current&&F.target!==A.current&&C.current&&!C.current.contains(F.target)&&D.current(F)};let L;return requestAnimationFrame(()=>{B(),T(!0),x&&C.current&&(A.current=Cy(C.current),A.current&&A.current.addEventListener("scroll",q,!0)),r&&(L=new ResizeObserver(B),L.observe(r))}),()=>{x&&A.current&&A.current.removeEventListener("scroll",q,!0),L?.disconnect()}},[]),f.useLayoutEffect(()=>{B()},[r,i,n,a]),f.useEffect(()=>{const q=L=>{D.current&&D.current(L)};if(C.current)return zs(C.current,{callback:q,parent:()=>r}).destroy},[r]),l.jsx("div",{ref:C,className:["wx-37M6Fj","wx-popup",d].filter(Boolean).join(" "),style:{position:"absolute",visibility:M?"visible":"hidden",top:v+"px",left:g+"px",width:k},children:p})}function l1({position:n="bottom",align:a="start",autoFit:i=!0,onCancel:r=null,width:c="100%",css:d="",children:h}){const p=f.useRef(null),[x,g]=f.useState(n),[w,v]=f.useState(a),b=f.useRef(r);return f.useEffect(()=>{b.current=r},[r]),f.useEffect(()=>{if(i){const k=p.current;if(k){const j=k.getBoundingClientRect(),M=document.body.getBoundingClientRect();j.right>=M.right&&v("end"),j.bottom>=M.bottom&&g("top")}}},[]),f.useEffect(()=>{if(p.current){const k=j=>{b.current&&b.current(j)};return zs(p.current,k).destroy}},[]),l.jsx("div",{ref:p,className:["wx-dropdown",`wx-${x}-${w}`,d||"","wx-aaaVytZW"].filter(Boolean).join(" "),style:{width:c},children:h})}function kh({position:n="bottom",align:a="start",autoFit:i=!0,inline:r=!1,onCancel:c,width:d="100%",children:h,...p}){const[x,g]=f.useState(void 0),w=f.useRef(null),v=f.useMemo(()=>`${n}-${a}`,[n,a]);return f.useLayoutEffect(()=>{w.current&&g(w.current.parentNode)},[]),l.jsxs(l.Fragment,{children:[x&&(r?l.jsx(l1,{onCancel:c,position:n,align:a,autoFit:i,width:d,...p,children:h}):l.jsx(jh,{children:l.jsx(s1,{parent:x,at:v,onCancel:c,width:d,...p,children:h})})),l.jsx("span",{ref:w,className:"wx-portal-node wx-32GZ52"})]})}function Cd(){return gc(ky)}function i1(){let n=null,a=!1,i=!1,r,c,d,h;const p=(v,b,k,j,M)=>{r=v,c=b,d=k,h=j,i=M},x=v=>{n=v,a=n!==null,d(n)},g=(v,b)=>{if(!i&&v!==null&&r){const k=r.querySelectorAll(".wx-list > .wx-item")[v];k&&(k.scrollIntoView({block:"nearest"}),b&&b.preventDefault())}},w=(v,b)=>{const k=v===null?null:Math.max(0,Math.min(n+v,c.length-1));k!==n&&(x(k),r?g(k,b):requestAnimationFrame(()=>g(k,b)))};return{move:v=>{const b=mc(v),k=c.findIndex(j=>j.id===b);k!==n&&x(k)},keydown:(v,b)=>{switch(v.code){case"Enter":a?h():x(0);break;case"Space":a||x(0);break;case"Escape":d(n=null);break;case"Tab":d(n=null);break;case"ArrowDown":w(a?1:b||0,v);break;case"ArrowUp":w(a?-1:b||0,v);break}},init:p,navigate:w}}const sv=10,r1=f.memo(function({data:n,checkboxes:a,itemTemplate:i,value:r}){return l.jsxs(l.Fragment,{children:[a&&l.jsx(n1,{id:n.id,css:"wx-list-checkbox",value:r&&r.includes(n.id)}),i?wh(i,{option:n}):n.label]})});function lv({visibleItems:n,visibleRange:a,navIndex:i,checkboxes:r,itemTemplate:c,value:d,measureRefCallback:h}){return n.map((p,x)=>{const g=a.start+x;return l.jsx("div",{ref:x===0?h:void 0,className:`wx-233fr7 wx-item ${g===i?"wx-focus":""}`,"data-id":p.id,children:l.jsx(r1,{data:p,checkboxes:r,itemTemplate:c,value:d})},p.id)})}function jd({items:n=[],children:a,onSelect:i,onReady:r,virtualized:c=!1,checkboxes:d,multiselect:h,value:p,...x}){const g=f.useRef(),w=f.useRef(!1),v=f.useRef(i1()),[b,k]=f.useState(null),j=f.useRef(b),[M,T]=f.useState(0),[C,A]=f.useState(24),D=f.useRef(!1),H=(f.useContext(bs)||Cd()).getGroup("core"),B=f.useRef(n);f.useEffect(()=>{B.current=n},[n]);const q=f.useRef(p);f.useEffect(()=>{q.current=p},[p]);const L=f.useRef(0);f.useEffect(()=>{L.current=C},[C]);const F=f.useCallback($=>{$&&$.stopPropagation();const ie=B.current,we=q.current,me=j.current;let ze;const Pe=ie[me]?.id;h?we&&we.includes(Pe)?ze=we.filter(de=>de!==Pe):ze=[...we||[],Pe]:ze=Pe,i&&i({id:ze})},[h,i]),ue=f.useRef(F);f.useEffect(()=>{ue.current=F},[F]);const W=f.useCallback($=>{if(g.current){let ie=$*L.current-g.current.clientHeight+L.current;T(ie),g.current.scrollTop=ie}},[L.current]),ce=f.useCallback($=>{g.current=$,c&&($&&!w.current&&j.current!==null&&requestAnimationFrame(()=>{g.current&&(W(j.current),w.current=!0)}),$||(w.current=!1))},[W]),Q=f.useCallback($=>{if(!$||D.current)return;const ie=$.getBoundingClientRect().height;ie&&(A(ie),L.current=ie,D.current=!0)},[]);f.useEffect(()=>{v.current.init(g.current,n,$=>{k($),j.current=$},$=>ue.current($),c)},[n,g.current,c]),f.useEffect(()=>{const $=(we,me)=>{v.current.navigate(we,me),W(j.current)},ie=(we,me)=>{const ze=j.current,Pe=B.current;if(ze!==0&&ze!==Pe.length-1&&(we.key==="ArrowDown"||we.key==="ArrowUp")&&we.preventDefault(),v.current.keydown(we,me),g.current){const de=g.current.scrollTop<=j.current*L.current,He=g.current.scrollTop+g.current.clientHeight>=j.current*L.current+L.current;de?He||W(j.current):(g.current.scrollTop=j.current*L.current,T(g.current.scrollTop))}};r&&r({navigate:c?$:v.current.navigate,keydown:c?ie:v.current.keydown,move:v.current.move})},[]);const se=f.useRef(0),oe=f.useRef(n);oe.current!==n&&(oe.current=n,se.current+=1);const K=f.useCallback(()=>{v.current.navigate(null)},[v]),z=f.useCallback($=>{c&&T($.target.scrollTop)},[c]),Y=f.useMemo(()=>Math.ceil((g.current?.clientHeight||0)/C),[C,M]),U=f.useMemo(()=>{if(!c)return{start:0,end:n.length};if(!n.length)return{start:0,end:0};const $=Math.floor(M/C),ie=$+Y;return{start:Math.max(0,$-sv),end:Math.min(n.length,ie+sv)}},[c,n,M,C,Y]),R=f.useMemo(()=>{if(!c)return n;const{start:$,end:ie}=U;return n.slice($,ie).map(we=>({...we}))},[c,n,U]),J=U.start*C,he=n.length*C;return f.useEffect(()=>{c&&T(0)},[n,c]),f.useEffect(()=>{b===null&&(w.current=!1)},[b]),b===null?null:l.jsx(kh,{onCancel:K,...x,children:l.jsx("div",{className:"wx-233fr7 wx-list",ref:ce,onClick:F,onMouseMove:v.current.move,onScroll:z,children:n.length?c?l.jsx("div",{className:"wx-233fr7 wx-list-wrapper",style:{height:`${he}px`},children:l.jsx("div",{className:"wx-233fr7 wx-list-content",style:{transform:`translateY(${J}px)`},children:l.jsx(lv,{visibleRange:U,visibleItems:R,navIndex:b,measureRefCallback:Q,checkboxes:d,itemTemplate:a,value:p})})}):l.jsx(lv,{visibleRange:U,visibleItems:R,navIndex:b,measureRefCallback:Q,checkboxes:d,itemTemplate:a,value:p}):l.jsx("div",{className:"wx-233fr7 wx-no-data",children:H("No data")})})},se.current)}function Mh({value:n="",id:a,readonly:i=!1,focus:r=!1,select:c=!1,type:d="text",placeholder:h="",disabled:p=!1,error:x=!1,title:g="",tooltip:w,css:v="",icon:b="",clear:k=!1,onChange:j}){const M=Ny(a),[T,C]=Ls(n),A=f.useRef(null),D=f.useMemo(()=>b&&v.indexOf("wx-icon-left")===-1?"wx-icon-right "+v:v,[b,v]),H=f.useMemo(()=>b&&v.indexOf("wx-icon-left")!==-1,[b,v]);f.useEffect(()=>{const ue=setTimeout(()=>{r&&A.current&&A.current.focus(),c&&A.current&&A.current.select()},1);return()=>clearTimeout(ue)},[r,c]);const B=f.useCallback(ue=>{const W=ue.target.value;C(W),j&&j({value:W,input:!0})},[j]),q=f.useCallback(ue=>j&&j({value:ue.target.value}),[j]);function L(ue){ue.stopPropagation(),C(""),j&&j({value:""})}let F=d;return d!=="password"&&d!=="number"&&(F="text"),f.useEffect(()=>{const ue=q,W=A.current;return W.addEventListener("change",ue),()=>{W&&W.removeEventListener("change",ue)}},[q]),l.jsxs("div",{className:`wx-hQ64J4 wx-text ${D} ${x?"wx-error":""} ${p?"wx-disabled":""} ${k?"wx-clear":""}`,"data-tooltip-text":w,children:[l.jsx("input",{className:"wx-hQ64J4 wx-input",ref:A,id:M,readOnly:i,disabled:p,placeholder:h,type:F,title:g,value:T,onInput:B}),k&&!p&&T?l.jsxs(l.Fragment,{children:[l.jsx("i",{className:"wx-hQ64J4 wx-icon wxi-close",onClick:L}),H&&l.jsx("i",{className:`wx-hQ64J4 wx-icon ${b}`})]}):b?l.jsx("i",{className:`wx-hQ64J4 wx-icon ${b}`}):null]})}function o1({date:n,type:a,part:i,onShift:r}){const{calendar:c,formats:d}=f.useContext(bs).getRaw(),h=n.getFullYear(),p=f.useMemo(()=>{switch(a){case"month":return Ir(d.monthYearFormat,c)(n);case"year":return Ir(d.yearFormat,c)(n);case"duodecade":{const{start:g,end:w}=jy(h),v=Ir(d.yearFormat,c);return`${v(new Date(g,0,1))} - ${v(new Date(w,11,31))}`}default:return""}},[n,a,h,c,d]);function x(){r&&r({diff:0,type:a})}return l.jsxs("div",{className:"wx-8HQVQV wx-header",children:[i!=="right"?l.jsx("i",{className:"wx-8HQVQV wx-pager wxi-angle-left",onClick:()=>r&&r({diff:-1,type:a})}):l.jsx("span",{className:"wx-8HQVQV wx-spacer"}),l.jsx("span",{className:"wx-8HQVQV wx-label",onClick:x,children:p}),i!=="left"?l.jsx("i",{className:"wx-8HQVQV wx-pager wxi-angle-right",onClick:()=>r&&r({diff:1,type:a})}):l.jsx("span",{className:"wx-8HQVQV wx-spacer"})]})}function Ah({onClick:n,children:a}){return l.jsx("button",{className:"wx-3s8W4d wx-button",onClick:n,children:a})}function c1({value:n,current:a,part:i="",markers:r=null,css:c="",onCancel:d,onChange:h}){const p=(f.useContext(bs)||Cd()).getRaw().calendar,x=(p.weekStart||7)%7,g=p.dayShort.slice(x).concat(p.dayShort.slice(0,x)),w=(B,q,L)=>new Date(B.getFullYear(),B.getMonth()+(q||0),B.getDate()+(L||0));let v=i!=="normal";function b(B){const q=B.getDay();return q===0||q===6}function k(){const B=w(a,0,1-a.getDate());return B.setDate(B.getDate()-(B.getDay()-(x-7))%7),B}function j(){const B=w(a,1,-a.getDate());return B.setDate(B.getDate()+(6-B.getDay()+x)%7),B}const M=f.useRef(0);function T(B,q){q.timeStamp!==M.current&&(M.current=q.timeStamp,q.stopPropagation(),h&&h(new Date(B)),d&&d())}const C=f.useMemo(()=>i=="normal"?[n?w(n).valueOf():0]:n?[n.start?w(n.start).valueOf():0,n.end?w(n.end).valueOf():0]:[0,0],[i,n]),A=f.useMemo(()=>{const B=k(),q=j(),L=a.getMonth();let F=[];for(let ue=B;ue<=q;ue.setDate(ue.getDate()+1)){const W={day:ue.getDate(),in:ue.getMonth()===L,date:ue.valueOf()};let ce="";if(ce+=W.in?"":" wx-inactive",ce+=C.indexOf(W.date)>-1?" wx-selected":"",v){const Q=W.date==C[0],se=W.date==C[1];Q&&!se?ce+=" wx-left":se&&!Q&&(ce+=" wx-right"),W.date>C[0]&&W.date<C[1]&&(ce+=" wx-inrange")}if(ce+=b(ue)?" wx-weekend":"",r){const Q=r(ue);Q&&(ce+=" "+Q)}F.push({...W,css:ce})}return F},[a,C,v,r]),D=f.useRef(null);let H=f.useRef({});return H.current.click=T,f.useEffect(()=>{Ur(D.current,H.current)},[]),l.jsxs("div",{className:`wx-398RBS wx-month ${c}`,children:[l.jsx("div",{className:"wx-398RBS wx-weekdays",children:g.map(B=>l.jsx("div",{className:"wx-398RBS wx-weekday",children:B},B))}),l.jsx("div",{className:"wx-398RBS wx-days",ref:D,children:A.map(B=>l.jsx("div",{className:`wx-398RBS wx-day ${B.css} ${B.in?"":"wx-out"}`,"data-id":B.date,children:B.day},B.date))})]})}function u1({value:n,current:a,part:i,onCancel:r,onChange:c,onShift:d}){const h=f.useRef(new Date),[p,x]=Ls(n||h.current),[g,w]=Ls(a||h.current),v=f.useContext(bs).getRaw().calendar,b=v.monthShort||[],k=f.useMemo(()=>g.getMonth(),[g]),j=f.useCallback((C,A)=>{if(C!=null){A.stopPropagation();const D=new Date(g);D.setMonth(C),w(D),d&&d({current:D})}i==="normal"&&x(new Date(g)),r&&r()},[g,i,d,r]),M=f.useCallback(()=>{const C=new Date(Ty(p,i)||g);C.setMonth(g.getMonth()),C.setFullYear(g.getFullYear()),c&&c(C)},[p,g,i,c]),T=f.useCallback(C=>{const A=C.target.closest("[data-id]");if(A){const D=parseInt(A.getAttribute("data-id"),10);j(D,C)}},[j]);return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"wx-34U8T8 wx-months",onClick:T,children:b.map((C,A)=>l.jsx("div",{className:"wx-34U8T8 wx-month"+(k===A?" wx-current":""),"data-id":A,children:C},A))}),l.jsx("div",{className:"wx-34U8T8 wx-buttons",children:l.jsx(Ah,{onClick:M,children:v.done})})]})}const Am="wx-1XEF33",d1=({value:n,current:a,onCancel:i,onChange:r,onShift:c,part:d})=>{const h=f.useContext(bs).getRaw().calendar,[p,x]=Ls(a),[g,w]=Ls(n),v=f.useMemo(()=>p.getFullYear(),[p]),b=f.useMemo(()=>{const{start:C,end:A}=jy(v),D=[];for(let H=C;H<=A;++H)D.push(H);return D},[v]),k={click:j};function j(C,A){if(C){A.stopPropagation();const D=new Date(p);D.setFullYear(C),x(D),c&&c({current:D})}d==="normal"&&w(new Date(p)),i&&i()}function M(){const C=new Date(Ty(g,d)||p);C.setFullYear(p.getFullYear()),r&&r(C)}const T=f.useRef(null);return f.useEffect(()=>{T.current&&Ur(T.current,k)},[]),l.jsxs(l.Fragment,{children:[l.jsx("div",{className:Am+" wx-years",ref:T,children:b.map((C,A)=>l.jsx("div",{className:Am+` wx-year ${v==C?"wx-current":""} ${A===0?"wx-prev-decade":""} ${A===11?"wx-next-decade":""}`,"data-id":C,children:C},A))}),l.jsx("div",{className:Am+" wx-buttons",children:l.jsx(Ah,{onClick:M,children:h.done})})]})},iv={month:{component:c1,next:m1,prev:f1},year:{component:u1,next:p1,prev:h1},duodecade:{component:d1,next:x1,prev:g1}};function f1(n){return n=new Date(n),n.setMonth(n.getMonth()-1),n}function m1(n){return n=new Date(n),n.setMonth(n.getMonth()+1),n}function h1(n){return n=new Date(n),n.setFullYear(n.getFullYear()-1),n}function p1(n){return n=new Date(n),n.setFullYear(n.getFullYear()+1),n}function g1(n){return n=new Date(n),n.setFullYear(n.getFullYear()-10),n}function x1(n){return n=new Date(n),n.setFullYear(n.getFullYear()+10),n}function Ty(n,a){let i;if(a==="normal")i=n;else{const{start:r,end:c}=n;a==="left"?i=r:a=="right"?i=c:i=r&&c}return i}const v1=["clear","today"];function y1(n){if(n==="done")return-1;if(n==="clear")return null;if(n==="today")return new Date}function w1({value:n,current:a,onCurrentChange:i,part:r="normal",markers:c=null,buttons:d,css:h="",onShift:p,onChange:x}){const g=f.useContext(bs).getGroup("calendar"),[w,v]=f.useState("month"),b=Array.isArray(d)?d:d?v1:[],k=(A,D)=>{A.preventDefault(),x&&x({value:D})},j=()=>{w==="duodecade"?v("year"):w==="year"&&v("month")},M=A=>{const{diff:D,current:H}=A;if(D===0){w==="month"?v("year"):w==="year"&&v("duodecade");return}if(D){const B=iv[w];i(D>0?B.next(a):B.prev(a))}else H&&i(H);p&&p()},T=A=>{v("month"),x&&x({select:!0,value:A})},C=f.useMemo(()=>iv[w].component,[w]);return l.jsx("div",{className:`wx-2Gr4AS wx-calendar ${r!=="normal"&&r!=="both"?"wx-part":""} ${h}`,children:l.jsxs("div",{className:"wx-2Gr4AS wx-wrap",children:[l.jsx(o1,{date:a,part:r,type:w,onShift:M}),l.jsxs("div",{children:[l.jsx(C,{value:n,current:a,onCurrentChange:i,part:r,markers:c,onCancel:j,onChange:T,onShift:M}),w==="month"&&b.length>0&&l.jsx("div",{className:"wx-2Gr4AS wx-buttons",children:b.map(A=>l.jsx("div",{className:"wx-2Gr4AS wx-button-item",children:l.jsx(Ah,{onClick:D=>k(D,y1(A)),children:g(A)})},A))})]})]})})}function Nh(n){let{words:a=null,optional:i=!1,children:r}=n,c=f.useContext(bs);const d=f.useMemo(()=>{let h=c;return(!h||!h.extend)&&(h=gc(ky)),a!==null&&(h=h.extend(a,i)),h},[a,i,c]);return l.jsx(bs.Provider,{value:d,children:r})}function rv(n,a,i,r){if(!n||r){const c=a?new Date(a):new Date;c.setDate(1),i(c)}else if(n.getDate()!==1){const c=new Date(n);c.setDate(1),i(c)}}const b1=["clear","today"];function Ry({value:n,current:a,markers:i=null,buttons:r=b1,css:c="",onChange:d}){const[h,p]=Ls(n),[x,g]=Ls(a);f.useEffect(()=>{rv(x,h,g,!1)},[h,x]);const w=f.useCallback(b=>{const k=b.value;k?(p(new Date(k)),rv(x,new Date(k),g,!0)):p(null),d&&d({value:k?new Date(k):null})},[d,x]),v=f.useCallback(b=>{g(b)},[g]);return x?l.jsx(Nh,{children:l.jsx(w1,{value:h,current:x,markers:i,buttons:r,css:c,onChange:w,onCurrentChange:v})}):null}function S1(n){return n||(n={}),n.width||(n.width="unset"),n}const C1=["clear","today"];function j1({value:n,id:a,disabled:i=!1,error:r=!1,placeholder:c="",format:d="",buttons:h=C1,css:p="",title:x="",tooltip:g,editable:w=!1,clear:v=!1,onChange:b,dropdown:k={}}){const{calendar:j,formats:M}=(f.useContext(bs)||Cd()).getRaw(),T=d||M?.dateFormat;let C=typeof T=="function"?T:Ir(T,j);const[A,D]=f.useState(n),[H,B]=f.useState(!1);f.useEffect(()=>{D(n)},[n]);function q(){B(!1)}function L(W){const ce=W===A||W&&A&&W.valueOf()===A.valueOf()||!W&&!A;D(W),ce||b&&b({value:W}),setTimeout(q,1)}const F=f.useMemo(()=>A?C(A):"",[A,C]);function ue({value:W,input:ce}){if(!w&&!v||ce)return;let Q=typeof w=="function"?w(W):W?new Date(W):null;Q=isNaN(Q)?A||null:Q||null,L(Q)}return f.useEffect(()=>{const W=q;return window.addEventListener("scroll",W),()=>window.removeEventListener("scroll",W)},[]),l.jsxs("div",{className:"wx-1lKOFG wx-datepicker",onClick:()=>B(!0),children:[l.jsx(Mh,{css:`wx-date-input ${p}`,title:x,tooltip:g,value:F,id:a,readonly:!w,disabled:i,error:r,placeholder:c,onInput:q,onChange:ue,icon:"wxi-calendar",clear:v}),H&&!i&&l.jsx(kh,{onCancel:q,...S1(k),children:l.jsx(Ry,{buttons:h,value:A,onChange:W=>L(W.value)})})]})}function k1({value:n="",options:a=[],textOptions:i=null,placeholder:r="",disabled:c=!1,error:d=!1,title:h="",tooltip:p,textField:x="label",clear:g=!1,css:w="",children:v,onChange:b,dropdown:k={}}){const j=f.useRef(null),M=f.useRef(null);let[T,C]=Ls(n);function A(L){j.current=L.navigate,M.current=L.keydown}const D=f.useMemo(()=>T||T===0?(i||a).find(L=>L.id===T):null,[T,i,a]),H=f.useCallback(({id:L})=>{(L||L===0)&&(C(L),j.current(null),b&&b({value:L}))},[C,b]),B=f.useCallback(L=>{L.stopPropagation(),C(""),b&&b({value:""})},[C,b]),q=f.useCallback(()=>a.findIndex(L=>L.id===T),[a,T]);return l.jsxs("div",{className:`wx-2YgblL wx-richselect ${w} ${d?"wx-2YgblL wx-error":""} ${c?"wx-2YgblL wx-disabled":""} ${v?"":"wx-2YgblL wx-nowrap"}`,title:h,onClick:()=>j.current(q()),onKeyDown:L=>M.current(L,q()),tabIndex:0,"data-tooltip-text":p,children:[l.jsx("div",{className:"wx-2YgblL wx-label",children:D?v?v(D):D[x]:r?l.jsx("span",{className:"wx-2YgblL wx-placeholder",children:r}):" "}),g&&!c&&T?l.jsx("i",{className:"wx-2YgblL wx-icon wxi-close",onClick:B}):l.jsx("i",{className:"wx-2YgblL wx-icon wxi-angle-down"}),!c&&l.jsx(jd,{items:a,onReady:A,onSelect:H,...k,children:({option:L})=>v?v(L):L[x]})]})}const M1=({options:n=[],value:a="",css:i="",children:r,onChange:c})=>{const[d,h]=f.useState(a),p=x=>{h(x),c&&c({value:x})};return f.useEffect(()=>{h(a)},[a]),l.jsx("div",{className:`wx-0hMO7P wx-segmented ${i}`,children:n.map(x=>l.jsx("button",{className:`wx-0hMO7P wx-segment ${x.css} ${x.id===d?"wx-selected":""}`,title:x.title,onClick:()=>p(x.id),"data-tooltip-text":x.tooltip,children:r?wh(r,{option:x}):l.jsxs(l.Fragment,{children:[x.icon&&l.jsx("i",{className:`wx-0hMO7P wx-icon ${x.icon} ${x.label?"":"wx-only"}`}),x.label&&l.jsx("span",{className:"wx-0hMO7P wx-label",children:x.label})]})},x.id))})};function A1({notice:n={}}){function a(){n.remove&&n.remove()}return l.jsxs("div",{className:`wx-11sNg5 wx-notice wx-${n.type?n.type:""}`,role:"status","aria-live":"polite",children:[l.jsx("div",{className:"wx-11sNg5 wx-text",children:n.text}),l.jsx("div",{className:"wx-11sNg5 wx-button",children:l.jsx("i",{className:"wx-11sNg5 wxi-close",onClick:a})})]})}function N1({data:n=[]}){return l.jsx("div",{className:"wx-3nwoO9 wx-notices",children:n.map(a=>l.jsx(A1,{notice:a},a.id))})}function nh({title:n="",buttons:a=["cancel","ok"],header:i,children:r,footer:c,css:d="",onConfirm:h,onCancel:p}){const x=(f.useContext(bs)||Cd()).getGroup("core"),g=f.useRef(null);f.useEffect(()=>{g.current?.focus()},[]);function w(b){switch(b.code){case"Enter":{const k=b.target.tagName;if(k==="TEXTAREA"||k==="BUTTON")return;h&&h({event:b});break}case"Escape":p&&p({event:b});break}}function v(b,k){const j={event:b,button:k};k==="cancel"?p&&p(j):h&&h(j)}return l.jsx("div",{className:`wx-1FxkZa wx-modal ${d}`,ref:g,tabIndex:0,onKeyDown:w,children:l.jsxs("div",{className:"wx-1FxkZa wx-window",children:[i||(n?l.jsx("div",{className:"wx-1FxkZa wx-header",children:n}):null),l.jsx("div",{children:r}),c||a&&l.jsx("div",{className:"wx-1FxkZa wx-buttons",children:a.map(b=>l.jsx("div",{className:"wx-1FxkZa wx-button",children:l.jsx(ic,{type:`block ${b==="ok"?"primary":"secondary"}`,onClick:k=>v(k,b),children:x(b)})},b))})]})})}function T1({children:n},a){const[i,r]=f.useState(null),[c,d]=f.useState([]);return f.useImperativeHandle(a,()=>({showModal:h=>{const p={...h};return r(p),new Promise((x,g)=>{p.resolve=w=>{r(null),x(w)},p.reject=w=>{r(null),g(w)}})},showNotice:h=>{h={...h},h.id=h.id||Sh(),h.remove=()=>d(p=>p.filter(x=>x.id!==h.id)),h.expire!=-1&&setTimeout(h.remove,h.expire||5100),d(p=>[...p,h])}}),[]),l.jsxs(l.Fragment,{children:[n,i&&l.jsx(nh,{title:i.title,buttons:i.buttons,onConfirm:i.resolve,onCancel:i.reject,children:i.message}),l.jsx(N1,{data:c})]})}const R1=f.forwardRef(T1);function E1(n){let{children:a}=n,i=f.useRef();const r=f.useMemo(()=>({showNotice:c=>i.current.showNotice(c),showModal:c=>i.current.showModal(c)}),[]);return l.jsx(My.Provider,{value:r,children:l.jsx(R1,{ref:i,children:a})})}const D1=({value:n=!1,type:a="",icon:i="",disabled:r=!1,iconActive:c="",onClick:d,title:h="",tooltip:p,css:x="",text:g="",textActive:w="",children:v,active:b,onChange:k})=>{const[j,M]=Ls(n),T=f.useMemo(()=>(j?"pressed":"")+(a?" "+a:""),[j,a]),C=f.useCallback(A=>{let D=!j;d&&d(A),A.defaultPrevented||(M(D),k&&k({value:D}))},[j,d,k]);return j&&b?l.jsx(ic,{title:h,tooltip:p,text:j&&w||g,css:x,type:T,icon:j&&c||i,onClick:C,disabled:r,children:wh(b,{value:j})}):v?l.jsx(ic,{title:h,tooltip:p,text:j&&w||g,css:x,type:T,icon:j&&c||i,onClick:C,disabled:r,children:v}):l.jsx(ic,{title:h,tooltip:p,text:j&&w||g,css:x,type:T,icon:j&&c||i,onClick:C,disabled:r})};function L1(){return l.jsx(l.Fragment,{})}function ov(n){const{fonts:a=!0,children:i}=n;return l.jsx(Ch.Provider,{value:"willow",children:l.jsxs(l.Fragment,{children:[i&&i&&l.jsx("div",{className:"wx-theme wx-willow-theme",children:i}),a&&l.jsxs(l.Fragment,{children:[l.jsx("link",{rel:"preconnect",href:"https://cdn.svar.dev",crossOrigin:"true"}),l.jsx(L1,{}),l.jsx("link",{rel:"stylesheet",href:"https://cdn.svar.dev/fonts/wxi/wx-icons.css"})]})]})})}bh(va);const Th={grid:{"Add before":"Add before","Add after":"Add after",Copy:"Copy",Cut:"Cut",Paste:"Paste",Delete:"Delete","New row":"New row","Move up":"Move up","Move down":"Move down",Undo:"Undo",Redo:"Redo",selected:"selected"}};new Date().valueOf();var Ey=class{constructor(n){this._nextHandler=null,this._dispatch=n,this.exec=this.exec.bind(this)}async exec(n,a){return this._dispatch(n,a),this._nextHandler&&await this._nextHandler.exec(n,a),a}setNext(n){return this._nextHandler=n}};new Date().valueOf();var z1=class{constructor(n){const a={id:0,$level:0,data:[],parent:null},i=new Map;i.set(0,a),this._pool=i,n&&n.length&&this.parse(n,0)}parse(n,a){const i=this._pool;for(let c=0;c<n.length;c++){const d=n[c];d.parent=d.parent||a,d.data=null,i.set(d.id,d)}for(let c=0;c<n.length;c++){const d=n[c],h=i.get(d.parent);h&&(h.data||(h.data=[]),h.data.push(d))}const r=i.get(a);this.setLevel(r,r.$level+1,!1)}add(n,a){const i=this._pool.get(n.parent||0);n.$level=i.$level+1,this._pool.set(n.id,n),i.data?a===-1?i.data=[...i.data,n]:cv(i,a,n):i.data=[n]}addAfter(n,a){if(!a)return this.add(n,-1);const i=this.byId(a),r=this.byId(i.parent),c=qu(r,i.id)+1;n.parent=r.id,n.$level=r.$level+1,this.add(n,c)}remove(n){const a=this._pool.get(n);this._remove(a);const i=this._pool.get(a.parent);i.data=i.data.filter(r=>r.id!=n),this._clearBranch(i)}_remove(n){n.data&&n.data.forEach(a=>this._remove(a)),this._pool.delete(n.id)}update(n,a){let i=this._pool.get(n);const r=this._pool.get(i.parent),c=qu(r,i.id);i={...i,...a},r&&c>=0&&(r.data[c]=i,r.data=[...r.data]),this._pool.set(i.id,i)}move(n,a,i){const r=this._pool.get(n),c=a==="child",d=this._pool.get(i),h=d.$level+(c?1:0);if(!r||!d)return;const p=this._pool.get(r.parent),x=c?d:this._pool.get(d.parent);x.data||(x.data=[]);const g=qu(p,r.id);_1(p,g);const w=c?x.data.length:qu(x,d.id)+(a==="after"?1:0);if(cv(x,w,r),p.id===x.id&&g===w)return null;r.parent=x.id,r.$level!==h&&(r.$level=h,this.setLevel(r,h+1,!0)),this.update(r.id,r),this._clearBranch(p)}_clearBranch(n){n.data&&!n.data.length&&(n.open&&delete n.open,this.update(n.id,{data:null}))}toArray(){const n=[],a=this._pool.get(0).data;return a&&Dy(a,n),n}byId(n){return this._pool.get(n)}getBranch(n){return this._pool.get(n).data}forEach(n){this._pool.forEach((a,i)=>{i!==0&&n(a)})}eachChild(n,a){const i=this.byId(a);!i||!i.data||i.data.forEach((r,c)=>{n(this.byId(r.id),c),this.eachChild(n,r.id)})}setLevel(n,a,i){n.data&&(n.data=n.data.map(r=>(i&&(r={...r},this._pool.set(r.id,r)),r.$level=a,r.data&&this.setLevel(r,a+1,i),r)))}};function Dy(n,a){n.forEach(i=>{a.push(i),i.open===!0&&Dy(i.data,a)})}function _1(n,a){const i=[...n.data];i.splice(a,1),n.data=i}function cv(n,a,i){const r=[...n.data];r.splice(a,0,i),n.data=r}function qu(n,a){return n?.data.findIndex(i=>i.id===a)}var Ly=2,O1=class{constructor(a){a&&(this._writable=a.writable,this._async=a.async),this._values={},this._state={}}setState(a,i=0){const r={};return this._wrapProperties(a,this._state,this._values,"",r,i),r}getState(){return this._values}getReactive(){return this._state}_wrapProperties(a,i,r,c,d,h){for(const p in a){const x=i[p],g=r[p],w=a[p];if(x&&(g===w&&typeof w!="object"||w instanceof Date&&g instanceof Date&&g.getTime()===w.getTime()))continue;const v=c+(c?".":"")+p;x?(x.__parse(w,v,d,h)&&(r[p]=w),h&Ly?d[v]=x.__trigger:x.__trigger()):(w&&w.__reactive?i[p]=this._wrapNested(w,w,v,d):i[p]=this._wrapWritable(w),r[p]=w),d[v]=d[v]||null}}_wrapNested(a,i,r,c){const d=this._wrapWritable(a);return this._wrapProperties(a,d,i,r,c,0),d.__parse=(h,p,x,g)=>(this._wrapProperties(h,d,i,p,x,g),!1),d}_wrapWritable(a){const i=[],r=function(){for(let c=0;c<i.length;c++)i[c](a)};return{subscribe:c=>(i.push(c),this._async?setTimeout(c,1,a):c(a),()=>{const d=i.indexOf(c);d>=0&&i.splice(d,1)}),__trigger:()=>{i.length&&(this._async?setTimeout(r,1):r())},__parse:function(c){return a=c,!0}}}};function uv(n,a){return Object.defineProperty(n,"__reactive",{value:!0,enumerable:!1,writable:!1}),n}var I1=class{constructor(a,i,r,c){typeof a=="function"?this._setter=a:this._setter=a.setState.bind(a),this._routes=i,this._parsers=r,this._prev={},this._triggers=new Map,this._sources=new Map,this._routes.forEach(d=>{d.in.forEach(h=>{const p=this._triggers.get(h)||[];p.push(d),this._triggers.set(h,p)}),d.out.forEach(h=>{const p=this._sources.get(h)||{};d.in.forEach(x=>p[x]=!0),this._sources.set(h,p)})}),this._routes.forEach(d=>{d.length=Math.max(...d.in.map(h=>zy(h,this._sources,1)))}),this._bus=c}init(a){const i={};for(const r in a)if(this._prev[r]!==a[r]){const c=this._parsers[r];i[r]=c?c(a[r]):a[r]}this._prev=this._prev?{...this._prev,...a}:{...a},this.setState(i),this._bus&&this._bus.exec("init-state",i)}setStateAsync(a){const i=this._setter(a,Ly);return this._async?Object.assign(this._async.signals,i):this._async={signals:i,timer:setTimeout(this._applyState.bind(this),1)},i}_applyState(){const a=this._async;if(a){this._async=null,this._triggerUpdates(a.signals,[]);for(const i in a.signals){const r=a.signals[i];r&&r()}}}setState(a,i=[]){const r=this._setter(a);return this._triggerUpdates(r,i),r}_triggerUpdates(a,i){const r=Object.keys(a),c=!i.length;i=i||[];for(let d=0;d<r.length;d++){const h=r[d],p=this._triggers.get(h);p&&p.forEach(x=>{i.indexOf(x)==-1&&i.push(x)})}c&&this._execNext(i)}_execNext(a){for(;a.length;){a.sort((r,c)=>r.length<c.length?1:-1);const i=a[a.length-1];a.splice(a.length-1),i.exec(a)}}};function zy(n,a,i){const r=a.get(n);if(!r)return i;const c=Object.keys(r).map(d=>zy(d,a,i+1));return Math.max(...c)}var B1=class{constructor(){this._nextHandler=null,this._handlers={},this._tag=new WeakMap,this.exec=this.exec.bind(this)}on(a,i,r){let c=this._handlers[a];c?r&&r.intercept?c.unshift(i):c.push(i):c=this._handlers[a]=[i],r&&r.tag&&this._tag.set(i,r.tag)}intercept(a,i,r){this.on(a,i,{...r,intercept:!0})}detach(a){for(const i in this._handlers){const r=this._handlers[i];for(let c=r.length-1;c>=0;c--)this._tag.get(r[c])===a&&r.splice(c,1)}}async exec(a,i){const r=this._handlers[a];if(r)for(let c=0;c<r.length;c++){const d=r[c](i);if(d===!1||d&&d.then&&await d===!1)return}return this._nextHandler&&await this._nextHandler.exec(a,i),i}setNext(a){return this._nextHandler=a}};const Lr=1024;function hc(n){return n<Lr?`${n} B`:n<Lr**2?`${(n/Lr).toFixed(1)} KB`:n<Lr**3?`${(n/Lr**2).toFixed(1)} MB`:`${(n/Lr**3).toFixed(1)} GB`}function dv(n,a){a||(a={key:"name",order:"asc"});const i=n.filter(h=>h.type==="folder"),r=n.filter(h=>h.type!=="folder"),c=i.sort(fv(a)),d=r.sort(fv(a));return[...c,...d]}function F1(n,a){return typeof n=="string"?n.localeCompare(a,void 0,{numeric:!0}):typeof n=="object"?n.getTime()-a.getTime():(n??0)-(a??0)}function H1(n,a){return typeof n=="string"?-n.localeCompare(a,void 0,{numeric:!0}):typeof a=="object"?a.getTime()-n.getTime():(a??0)-(n??0)}function fv({key:n,order:a}){const i=a==="asc"?F1:H1;return(r,c)=>i(r[n],c[n])}function Rh(n,a){const i=n==="/"?1:n.split("/").length;return i>=a.length?null:a[i].id}function $1(n){return n.length>1?n[n.length-2].id:null}let U1=class extends z1{constructor(a){const i={id:"/",name:"My files",open:!0,$level:1,parent:0,ext:"",type:"folder"};super([i]),this.parse(a,"/")}parse(a,i,r){!a||!a.length||(a.forEach(c=>this.parseId(c,r?i:void 0)),super.parse(a,i))}parseId(a,i){if(a.parent===0)return;const r=a.id,c=r.lastIndexOf("/");if(a.parent=i??(c===0?"/":r.slice(0,c)),a.name=r.slice(c+1),a.type=a.type||"file",a.type!=="folder"){const d=a.name.lastIndexOf("."),h=d!==-1?a.name.slice(d+1):"";a.ext=h!=="new"?h?.toLocaleLowerCase():""}}getParents(a){const i=[];let r=this.byId(a);if(!r)return i;for(;r.id!==0;)i.push(r),r=this.byId(r.parent);return i.reverse()}findFiles(a,i="/"){const r=[],c=a.toLocaleLowerCase();return this.eachChild(d=>{d.name.toLowerCase().indexOf(c)!==-1&&r.push(d)},i),r}add(a,i){const r=this.byId(a.parent||"/"),c=a.data?[...a.data]:null;a.data=null,super.add(a,i??r.data?r.data.length:0),c&&c.forEach(d=>this.add(d))}renameFiles(a,i,r){const c=this.byId(a),d=this.normalizeFile(c,i),h=[];return d.data?.forEach(p=>h.push(this.renameFiles(p.id,d.id,r))),h.length&&(d.data=h),r[a]=d.id,d}copyFiles(a,i,r){const c={};return a.forEach(d=>{const h=this.renameFiles(d,i,c);this.add(h),r&&this.remove(d),c[d]=h.id}),c}moveFiles(a,i){if(this.byId(a[0]).parent!==i)return this.copyFiles(a,i,!0)}serialize(a="/"){const i=[],r=this.byId(a);return r?(r.data?.forEach(c=>{const{id:d,date:h,type:p,size:x,lazy:g}=c,w={id:d,date:h,type:p??"file"};g&&(w.lazy=g),x&&(w.size=x),i.push(w);const v=this.serialize(d);v.length&&i.push(...v)}),i):null}normalizeFile(a,i){const r=a.name,c=r.lastIndexOf("."),d=c!==-1?r.slice(c+1):"",h=d?`.${d}`:"";let p=c!==-1?r.slice(0,c):r,x=i+(i==="/"?"":"/")+p;for(;this.byId(x+h);){const g=".new";x+=g,p+=g}return{...a,id:x+h,name:p+h,parent:i,ext:d.toLocaleLowerCase()}}},P1=class extends O1{in;_router;constructor(a){super({writable:a,async:!1});const i=[];for(let d=0;d<2;d++)i.push({in:["data",`panels.${d}.path`],out:[`panels.${d}._crumbs`],exec:h=>{const{data:p,panels:x}=this.getState(),g=[];g[d]={_crumbs:p.getParents(x[d].path)},this.setState({panels:g},h)}}),i.push({in:["data",`panels.${d}.path`,`panels.${d}._sorts`,"search"],out:[`panels.${d}._files`],exec:h=>{const{data:p,panels:x,search:g}=this.getState();let w;g?w=p.findFiles(g,x[d].path):w=p.byId(x[d].path)?.data||[];const{path:v,_sorts:b}=x[d];w=dv(w,b[v]);const k=[];k[d]={_files:w},this.setState({panels:k},h)}}),i.push({in:["data",`panels.${d}.selected`,`panels.${d}._sorts`],out:[`panels.${d}._selected`],exec:h=>{const{data:p,panels:x}=this.getState(),g=[];x[d].selected.forEach(j=>{const M=p.byId(j);M&&g.push(M)});const{path:w,_sorts:v}=x[d],b=dv(g,v[w]),k=[];k[d]={_selected:b},this.setState({panels:k},h)}});this._router=new I1(super.setState.bind(this),i,{data:d=>new U1(d)});const r=this.in=new B1;r.on("select-file",({id:d,toggle:h,range:p,panel:x,type:g})=>{const{panels:w,activePanel:v}=this.getState();typeof x>"u"&&(x=v),d||(h=p=!1);let b=[...w[x].selected];if(h){const j=b.indexOf(d);j===-1?b.push(d):b.splice(j,1)}else if(p&&w[x]._lastSelected){const j=w[x]._files;let M=j.findIndex(A=>A.id==w[x]._lastSelected),T=j.findIndex(A=>A.id==d);T<M&&([M,T]=[T,M]);const C=j.slice(M,T+1).map(A=>A.id);b=[...new Set([...b,...C])]}else b=d?[d]:[];const k=[];k[x]={selected:b,_lastSelected:d,_selectNavigation:g==="navigation"},this.setState({panels:k})}),r.on("set-path",({id:d,panel:h,selected:p})=>{const{data:x,activePanel:g}=this.getState(),w=x.byId(d);if(w){const v=[];typeof h>"u"&&(h=g),v[h]={path:d},this.setState({panels:v}),r.exec("select-file",{panel:h}),p&&p.forEach(b=>r.exec("select-file",{id:b,panel:h,toggle:!0})),w.lazy&&r.exec("request-data",{id:d})}}),r.on("provide-data",({id:d,data:h})=>{const{mode:p,data:x}=this.getState(),g=x.byId(d);g&&(g.lazy||(g.data=[]),g.lazy=!1,x.parse(h,d,p==="search"),this.setState({data:x}))}),r.on("open-tree-folder",({id:d,mode:h})=>{const{data:p}=this.getState();p.update(d,{open:h}),this.setState({data:p})}),r.on("show-preview",({mode:d})=>{this.setState({preview:d})}),r.on("rename-file",d=>{const{id:h,name:p}=d,{data:x,panels:g}=this.getState(),w=x.byId(h);if(w.name!==p){w.name=p;const v=x.normalizeFile(w,w.parent);d.newId=v.id,v.data=null,x.add(v);let b={[h]:v.id};w.data?.forEach(j=>b={...x.moveFiles([j.id],v.id),...b});const k=g.map(j=>({selected:j.selected,_crumbs:j._crumbs,_lastSelected:j._lastSelected,_sorts:j._sorts}));x.remove(h),this._updatePanels(k,b),this.setState({data:x,panels:k})}}),r.on("create-file",d=>{const{file:h,parent:p}=d,{data:x}=this.getState(),g=x.normalizeFile(h,p);g.type=h.type||"file",d.newId=g.id,x.add(g),this.setState({data:x}),r.exec("select-file",{id:g.id})}),r.on("delete-files",({ids:d})=>{const{data:h,panels:p}=this.getState(),x=p.map(g=>({selected:g.selected,_crumbs:g._crumbs,_lastSelected:g._lastSelected,_sorts:g._sorts}));d.forEach(g=>h.remove(g)),this._updatePanels(x,{}),this.setState({data:h,panels:x})}),r.on("copy-files",d=>{const{ids:h,target:p}=d;if(this._isPlacedIntoSelf(h,p)){console.error("You cannot copy a folder into itself"),d.skipProvider=!0;return}const{data:x,panels:g,activePanel:w}=this.getState(),v=x.copyFiles(h,p);d.newIds=h.map(b=>v[b]),this.setState({data:x}),g[w].path==p&&(r.exec("select-file",{}),h.forEach(b=>{r.exec("select-file",{id:v[b],toggle:!0})}))}),r.on("move-files",d=>{const{ids:h,target:p}=d;if(this._isPlacedIntoSelf(h,p)){console.error("You cannot move a folder into itself"),d.skipProvider=!0;return}const{data:x,panels:g,activePanel:w}=this.getState(),v=x.moveFiles(h,p);if(v){d.newIds=h.map(k=>v[k]);const b=g.map(k=>({selected:k.selected,_crumbs:k._crumbs,_lastSelected:k._lastSelected,_sorts:k._sorts}));this._updatePanels(b,v,!0),this.setState({data:x,panels:b}),g[w].path==p&&(r.exec("select-file",{}),h.forEach(k=>{r.exec("select-file",{id:v[k],toggle:!0})}))}});let c=null;r.on("filter-files",({text:d})=>{if(!d){c&&this.setState({...c});return}r.exec("select-file",{});const{panels:h,mode:p}=this.getState();c||(c={panels:h,mode:p,search:""}),this.setState({mode:"search",search:d})}),r.on("set-mode",({mode:d})=>{const{activePanel:h}=this.getState(),p=[];p[h]={_selectNavigation:!1};const x={mode:d,search:"",panels:p};c=null,this.setState(x)}),r.on("set-active-panel",({panel:d})=>{this.setState({activePanel:d})}),r.on("sort-files",({key:d,order:h,panel:p,path:x})=>{const{activePanel:g,panels:w}=this.getState();p=p??g,x=x??w[p].path;const v=[];v[p]={_sorts:{...w[p]._sorts,[x]:{key:d,order:h}}},this.setState({panels:v})}),this.initOnce()}initOnce(){const a=[];for(let r=0;r<2;r++)a[r]=uv({_crumbs:[],_files:[],_selected:[],_sorts:{},path:"/",selected:[],...a[r]});const i={panels:uv(a),data:[],search:""};this._router.init(i)}init(a){const i={...a};this._router.init(i)}setState(a,i){return this._router.setState(a,i)}getFile(a){const{data:i}=this.getState();return i.byId(a)||null}serialize(a){const{data:i}=this.getState();return i.serialize(a)}_updatePanels(a,i,r){const{data:c}=this.getState();a.forEach(d=>{const h=[];d.selected.forEach(g=>{c.byId(g)?h.push(g):!r&&i[g]&&h.push(i[g])}),d.selected=h,c.byId(d._lastSelected)||(d._lastSelected=r?null:i[d._lastSelected]||null);const p={};Object.keys(d._sorts).forEach(g=>{c.byId(g)?p[g]=d._sorts[g]:i[g]&&!r&&(p[i[g]]=d._sorts[g])}),d._sorts=p;const x=d._crumbs[d._crumbs.length-1];x?.id!=="/"&&(i[x.id]?d.path=i[x.id]:c.byId(x.id)||(d.path="/"))})}_isPlacedIntoSelf(a,i){return a.some(r=>r===i||this.getState().data.getParents(i).some(c=>c.id===r))}};function q1(n){switch(n){case"body":return[{icon:"wxi-content-paste",text:"Paste",hotkey:"Ctrl+V",id:"paste"}];case"add":return[{icon:"mdi mdi-folder-plus-outline",text:"Add new file",id:"add-file"},{icon:"mdi mdi-file-plus-outline",text:"Add new folder",id:"add-folder"},{icon:"mdi mdi-file-upload-outline",text:"Upload file",id:"upload",comp:"upload"}];case"multiselect":return[{icon:"wxi-content-copy",text:"Copy",hotkey:"Ctrl+C",id:"copy"},{icon:"wxi-content-cut",text:"Cut",hotkey:"Ctrl+X",id:"move"},{comp:"separator"},{icon:"wxi-close",text:"Delete",hotkey:"Delete",id:"delete"}];default:return[n==="folder"?null:{icon:"wxi-download",text:"Download",hotkey:"Ctrl+D",id:"download"},{icon:"wxi-content-copy",text:"Copy",hotkey:"Ctrl+C",id:"copy"},{icon:"wxi-content-cut",text:"Cut",hotkey:"Ctrl+X",id:"move"},{icon:"wxi-content-paste",text:"Paste",hotkey:"Ctrl+V",id:"paste"},{comp:"separator"},{icon:"wxi-edit",text:"Rename",hotkey:"Ctrl+R",id:"rename"},{icon:"wxi-close",text:"Delete",hotkey:"Delete",id:"delete"}].filter(a=>a!==null)}}function G1(n,a="data-id"){let i=n;for(!i.tagName&&n.target&&(i=n.target);i;){if(i.getAttribute&&i.getAttribute(a))return i;i=i.parentNode}return null}function Y1(n,a="data-id"){const i=G1(n,a);return i?i.getAttribute(a):null}new Date().valueOf();function V1(n,a){const{api:i}=a;function r(d,h){const p=a.getPanel(),x=p.selected,g=h.ctrlKey||h.metaKey,w=h.shiftKey;let v;const b=x?.[0]?i.getFile(x[0]):null;x?.length?x.length>1?v=a.menuOptions("multiselect"):v=a.menuOptions(b.type,b):v=a.menuOptions("body");const k=`${g?"ctrl+":""}${w?"shift+":""}${d}`,j=v?v.find(T=>T.hotkey?.toLowerCase()===k):!1,M=a.performAction;if(j)switch(k){case"ctrl+c":M("copy");break;case"ctrl+x":M("move");break;case"ctrl+v":M("paste",b);break;case"delete":M("delete");break;case"ctrl+r":h.preventDefault(),M("rename",b);break;case"ctrl+d":h.preventDefault(),M("download",b);break;default:j.handler?.({context:b})}switch(d){case"enter":{if(g||w)break;const{_crumbs:T,_selectNavigation:C}=p;if(C){const A=$1(T);if(A){const D=Rh(A,T);i.exec("set-path",{id:A,selected:[D]})}}else if(x.length===1){const A=i.getFile(x[0]);A&&i.exec(A.type==="folder"?"set-path":"open-file",{id:A.id})}break}case"arrowup":case"arrowleft":{const{_files:T,_selected:C,path:A,_selectNavigation:D}=p;let H;if(C.length){const B=C.at(0).id,q=T.findIndex(L=>L.id===B);if(q!==-1){const L=q-1;T[L]?H=T[L].id:A!=="/"&&!(g||w)&&i.exec("select-file",{type:"navigation"})}}else{if(D)break;if(A!=="/"){i.exec("select-file",{type:"navigation"});break}H=T.at(0)?.id}H&&i.exec("select-file",{id:H,toggle:g,range:w});break}case"arrowdown":case"arrowright":{const{_files:T,_selected:C,path:A,_selectNavigation:D}=p;let H;if(C.length){const B=C.at(-1).id,q=T.findIndex(L=>L.id===B);if(q!==-1){const L=q+1;T[L]&&(H=T[L].id)}}else{if(A!=="/"&&!D){i.exec("select-file",{type:"navigation"});break}H=T.at(0)?.id}H&&i.exec("select-file",{id:H,toggle:g,range:w});break}}}function c(d){const h=d.code.replace("Key","").toLowerCase();r(h,d),h=="tab"&&setTimeout(()=>{const p=document.activeElement;p.className.indexOf("table")!=-1&&i.exec("set-active-panel",{panel:+Y1(p,"data-panel")})})}return n.addEventListener("keydown",c),{destroy:()=>{n.removeEventListener("keydown",c)}}}function K1(n,a="data-id"){let i=n;for(!i.tagName&&n.target&&(i=n.target);i;){if(i.getAttribute&&i.getAttribute(a))return i;i=i.parentNode}return null}function W1(n,a="data-id"){const i=n.getAttribute(a);return i?Q1(i):null}function Q1(n){if(n.startsWith(":"))return n.substring(1);const a=n*1;return isNaN(a)?n:a}function X1(){return{detect:()=>!0,addEvent:function(n,a,i){return n.addEventListener(a,i),()=>n.removeEventListener(a,i)},addGlobalEvent:function(n,a){return document.addEventListener(n,a),()=>document.removeEventListener(n,a)},getTopNode:function(){return window.document.body}}}var Z1=X1();new Date().valueOf();function _y(n){const[a,i]=f.useState(n),r=f.useRef(n);return f.useEffect(()=>{if(r.current!==n){if(Array.isArray(r.current)&&Array.isArray(n)&&r.current.length===0&&n.length===0)return;r.current=n,i(n)}},[n]),[a,i]}function J1(n,a,i){const[r,c]=f.useState(()=>a);return n||console.warn(`Writable ${i} is not defined`),f.useEffect(()=>n?n.subscribe(h=>{c(()=>h)}):void 0,[n]),r}function Qe(n,a){const i=n.getState(),r=n.getReactiveState();return J1(r[a],i[a],a)}function eC(n,a){const i=f.useRef(a);i.current=a;const[r,c]=f.useState(1);return f.useEffect(()=>n.subscribe(h=>{i.current=h,c(p=>p+1)}),[n]),[i.current,r]}function Xa(n,a){const i=n.getState(),r=n.getReactiveState();return eC(r[a],i[a])}function Oy(n){const a={};return n.split(";").forEach(i=>{const[r,c]=i.split(":");if(c){let d=r.trim();d.indexOf("-")&&(d=d.replace(/-([a-z])/g,(h,p)=>p.toUpperCase())),a[d]=c.trim()}}),a}function Iy(n){let a=n,i=[];return{subscribe:p=>{i.push(p),p(a)},unsubscribe:p=>{i=i.filter(x=>x!==p)},set:p=>{a=p,i.forEach(x=>x(a))},update:p=>{a=p(a),i.forEach(x=>x(a))}}}function mv(n,a,i){function r(c){const d=K1(c);if(!d)return;const h=W1(d);if(typeof a=="function")return a(h,c);let p,x=c.target;for(;x!=d;){if(p=x.dataset?x.dataset.action:null,p&&a[p]){a[p](h,c);return}x=x.parentNode}a[i]&&a[i](h,c)}return Z1.addEvent(n,i,r)}function tC(n,a){const i=[mv(n,a,"click")];return a.dblclick&&i.push(mv(n,a.dblclick,"dblclick")),()=>{i.forEach(r=>r())}}function By(n,a){return n.map((i,r)=>{const c=a(i,r);return i.data&&i.data.length&&(c.data=By(i.data,a)),c}).filter(Boolean)}function Fy(n,a){const i=[];return n.forEach(r=>{if(r.data){const c=Fy(r.data,a);c.length&&i.push({...r,data:c})}else a(r)&&i.push(r)}),i}function nC(n){return By(n,(a,i)=>{const r={...a,id:a.id||Sh()};return r.type&&(r.comp=r.type),r.comp==="separator"&&n[i-1]?.comp==="separator"?null:r})}const Hy={};function aC(n){return Hy[n]||n}function sC(n,a){Hy[n]=a}function lC({onClick:n,onShow:a,option:i}){const r=f.useRef(null),c=f.useCallback(()=>{a(i.data?i.id:!1,r.current)},[a,i]),d=f.useCallback(p=>{if(i.data){p.stopPropagation(),a(i.id,r.current);return}n(p)},[n,a,i]),h=f.useMemo(()=>i&&i.comp?aC(i.comp):null,[i]);return l.jsxs("div",{ref:r,className:`wx-cDCz9rZQ wx-option ${i.css||""} ${i.disabled?"wx-disabled":""}`,"data-id":Cn(i.id),onMouseEnter:c,onClick:d,children:[i.icon?l.jsx("i",{className:`wx-cDCz9rZQ wx-icon ${i.icon}`}):null,i.comp?h?l.jsx(h,{item:i,option:i}):null:l.jsxs("span",{className:"wx-cDCz9rZQ wx-value",children:[" ",i.text," "]}),i.subtext?l.jsx("span",{className:"wx-cDCz9rZQ wx-subtext",children:i.subtext}):null,i.data?l.jsx("i",{className:"wx-cDCz9rZQ wx-sub-icon wxi-angle-right"}):null]})}function Eh({options:n,left:a=0,top:i=0,at:r="bottom",parent:c=null,mount:d=null,context:h=null,css:p="",onClick:x,onCancel:g}){const[w,v]=f.useState(-1e4),[b,k]=f.useState(-1e4),[j,M]=f.useState(20),[T,C]=f.useState(),A=f.useRef(null),[D,H]=f.useState(!1),[B,q]=f.useState(null),L=f.useCallback(()=>{const oe=Sy(A.current,c,r,a,i);oe&&(v(oe.x),k(oe.y),C(oe.width));let K=oe?.z??20;const z=c?V0(c):[];let Y=0;for(const U of z){const R=parseInt(getComputedStyle(U).zIndex,10);R>Y&&(Y=R)}Y>=K&&(K=Y+1),M(K)},[c,r,a,i]);f.useEffect(()=>{d&&d(L)},[]);const F=f.useCallback(()=>{H(!1)},[]),ue=f.useCallback((oe,K)=>{H(oe),q(K)},[]),W=f.useMemo(()=>nC(n),[n]);f.useEffect(()=>{L()},[c,L]);const ce=f.useRef(x),Q=f.useRef(g),se=f.useRef(c);return f.useEffect(()=>{ce.current=x},[x]),f.useEffect(()=>{Q.current=g},[g]),f.useEffect(()=>{se.current=c},[c]),f.useEffect(()=>{if(!A.current)return;function oe(K){Q.current?Q.current(K):ce.current&&ce.current({action:null,option:null})}return zs(A.current,{callback:oe,modal:!0,parent:()=>se.current}).destroy},[]),l.jsx("div",{ref:A,"data-wx-menu":"true",className:`wx-XMmAGqVx wx-menu ${p}`,style:{position:"absolute",top:b+"px",left:w+"px",width:T,zIndex:j},onMouseLeave:F,children:W.map(oe=>l.jsxs(f.Fragment,{children:[oe.comp==="separator"?l.jsx("div",{className:"wx-XMmAGqVx wx-separator"}):l.jsx(lC,{option:oe,onShow:ue,onClick:K=>{if(!oe.data&&!K.defaultPrevented){const z={context:h,action:oe,option:oe,event:K};oe.handler&&oe.handler(z),x&&x(z),K.stopPropagation()}}}),oe.data&&D===oe.id?l.jsx(Eh,{css:p,options:oe.data,at:"right-overlap",parent:B,context:h,onClick:x,onCancel:g}):null]},oe.id))})}const $y=f.forwardRef(function(n,a){const{options:i,at:r="bottom",resolver:c=null,dataKey:d="contextId",filter:h=null,css:p="",children:x,onClick:g}=n,[w,v]=f.useState(null),[b,k]=f.useState(null),[j,M]=f.useState(0),[T,C]=f.useState(0),A=f.useRef(null),D=f.useMemo(()=>`data-${d.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,[d]),H=f.useMemo(()=>w!==null&&h?Fy(i,F=>h(F,w)):i,[w,h,i]);function B(F){k(null),g&&g(F)}function q(F){if(A.current===F){A.current=null;return}k(null),g&&g({action:null,option:null})}const L=f.useCallback((F,ue)=>{if(!F){k(null);return}if(F.defaultPrevented)return;const W=F.target;if(W&&W.dataset&&W.dataset.menuIgnore)return;if(b&&b===W){k(null),F.preventDefault();return}M(F.clientX+1),C(F.clientY+1);let ce=typeof ue<"u"?ue:mc(W,D);c&&(ce=c(ce,F),!ce)||(v(ce),k(W),A.current=F.nativeEvent||F,F.preventDefault())},[b,D,c]);return f.useImperativeHandle(a,()=>({show:L}),[L]),l.jsxs(l.Fragment,{children:[x?l.jsx("span",{onClick:L,"data-menu-ignore":"true",children:typeof x=="function"?x():x}):null,b?l.jsx(jh,{children:l.jsx(Eh,{css:p,at:r,top:T,left:j,parent:b,context:w,onClick:B,onCancel:q,options:H},b)}):null]})}),iC=f.forwardRef(function(n,a){const{options:i,at:r="bottom",css:c="",children:d,onClick:h}=n,[p,x]=f.useState(null),g=f.useRef(null);function w(j){x(null),h&&h(j)}function v(j){if(g.current===j){g.current=null;return}x(null),h&&h({action:null,option:null})}const b=f.useCallback(j=>{x(j.target),g.current=j.nativeEvent||j,j.preventDefault()},[]);f.useImperativeHandle(a,()=>({show:b}),[b]);function k(j){let M=j.target;for(;!M.dataset.menuIgnore;)x(M),M=M.parentNode}return l.jsxs(l.Fragment,{children:[l.jsx("span",{onClick:k,"data-menu-ignore":"true",children:d}),p?l.jsx(jh,{children:l.jsx(Eh,{css:c,at:r,parent:p,options:i,onClick:w,onCancel:v})}):null]})}),rC=f.forwardRef(function(n,a){const{options:i,at:r="bottom",resolver:c=null,dataKey:d="contextId",filter:h=null,css:p="",children:x,onClick:g}=n,w=f.useRef(null),v=f.useCallback((b,k)=>{w.current.show(b,k)},[]);return f.useImperativeHandle(a,()=>({show:v}),[v]),l.jsxs(l.Fragment,{children:[x?l.jsx("span",{onContextMenu:v,"data-menu-ignore":"true",children:x}):null,l.jsx($y,{css:p,at:r,options:i,resolver:c,dataKey:d,filter:h,ref:w,onClick:g})]})}),oC={uploader:{B:"B",KB:"KB",MB:"MB",GB:"GB",TB:"TB",PB:"PB",EB:"EB","Drop files here or":"Drop files here or","select files":"select files"}};let cC=class{constructor(a,i,r,c,d){this.setFiles=a,this.setReady=i,this.setSignal=r,this.setDrag=c,d&&d.length&&this.setFiles(d)}open(a){this.setSignal(["click",a||{}])}getState(){let a="server";const i=this.files;for(let r=0;r<i.length;r++){if(i[r].status==="client")return"client";i[r].status==="error"&&(a="error")}return a}droparea(a,i){i=i||{};const r=()=>{i.dragEnter&&i.dragEnter(),this.setDrag(!0)},c=()=>{i.dragLeave&&i.dragLeave(),this.setDrag(!1)},d=p=>{p.preventDefault()},h=p=>{p.preventDefault(),this.setDrag(!1),this.setSignal(["drop",i,p]),i.dragLeave&&i.dragLeave(),i.drop&&i.drop()};return a.addEventListener("dragenter",r),a.addEventListener("dragleave",c),a.addEventListener("dragover",d,!0),a.addEventListener("drop",h,!0),()=>{a.removeEventListener("dragenter",r),a.removeEventListener("dragleave",c),a.removeEventListener("dragover",d,!0),a.removeEventListener("drop",h,!0)}}updateFile(a,i){const r=this.files.findIndex(d=>d.id===a);if(r===-1)return;const c=[...this.files];return c[r]={...c[r],...i},this.files=c,this.setFiles(this.files),this.files[r]}deleteFile(a){this.files=this.files.filter(i=>i.id!==a),this.setFiles(this.files)}addFile(a,i){i?this.files=[...this.files,a]:this.files=[a],this.setFiles(this.files)}deleteAll(){this.files=[],this.setFiles(this.files)}};function Uy(n){const[a,i]=f.useState([]),[r,c]=f.useState(Promise.resolve(null)),[d,h]=f.useState(null),[p,x]=f.useState(!1),g=f.useRef();return g.current||(g.current=new cC(i,c,h,x,n)),g.current.files=a,g.current.ready=r,g.current.signal=d,g.current.drag=p,g.current}function uC(n,a){{if(n){const i=n.getGroup(a);if(i)return i}return gc(oC).getGroup(a)}}const dC=()=>Math.random().toString(36).substr(2,9),fC=({data:n,accept:a="",multiple:i=!0,folder:r=!1,uploadURL:c="",apiOnly:d=!1,disabled:h=!1,children:p,onChange:x,onUpload:g})=>{const w=f.useRef(null),v=f.useRef(null),[b,k]=f.useState({}),j=Uy(),M=n||j,T=f.useContext(kn.i18n),C=uC(T,"uploader");f.useEffect(()=>{w.current&&r&&(w.current.webkitdirectory=!0)},[r]),f.useEffect(()=>{if(!d&&v.current&&!h)return M.droparea(v.current)},[d,h,v]);const A=W=>{const ce=new FormData;return ce.append("upload",W.file),fetch(c,{method:"POST",body:ce}).then(Q=>Q.json()).then(Q=>({id:W.id,...Q}),()=>({id:W.id,status:"error"})).catch(Q=>(console.log(Q),{id:W.id,status:"error"}))},D=(W,ce)=>{const Q=M.updateFile(W,ce),se={...Q,status:M.getState()};Q&&Q.uploaded&&Q.uploaded(se),g&&g(se),Q.temp&&M.deleteFile(Q.id)},H=W=>{if(!W)return;const ce=typeof c=="function"?c(W):A(W);M.setReady(ce.then(Q=>{Q.status=Q.status||"server",D(W.id,Q)}).catch(Q=>{D(W.id,{status:"error",error:Q})}))},B=(W,ce)=>{const Q={...ce||b,id:dC(),status:"client",name:W.name,file:W};Q.selected&&Q.selected(Q),x&&x(Q),M.addFile(Q,i),H(Q),w.current&&(w.current.value="")},q=(W,ce,Q)=>{W.isFile?W.file(se=>{B(se,Q)}):W.isDirectory&&W.createReader().readEntries(se=>{se.forEach(oe=>{q(oe,ce+oe.name+"/",Q)})})},L=W=>{Array.from(W.target.files).forEach(ce=>B(ce))},F=(W,ce)=>{Array.from(W.dataTransfer.items).forEach(Q=>{const se=Q.webkitGetAsEntry();se&&q(se,"",ce)})},ue=()=>{w.current&&w.current.click()};return f.useEffect(()=>{if(M.signal){const[W,ce,Q]=M.signal;k(ce),W==="click"?ue():W==="drop"&&F(Q,ce),M.setSignal(null)}},[M.signal]),d?l.jsxs(l.Fragment,{children:[l.jsx("input",{type:"file",className:"wx-at1A8tb8 wx-input",ref:w,onChange:L,accept:a,multiple:i,disabled:h}),p]}):l.jsxs("div",{className:`wx-at1A8tb8 wx-label ${M.drag?"wx-active":""} ${h?"wx-disabled":""}`,ref:v,children:[l.jsx("input",{type:"file",className:"wx-at1A8tb8 wx-input",ref:w,onChange:L,accept:a,multiple:i,disabled:h}),p||l.jsx("div",{className:"wx-at1A8tb8 wx-dropzone",children:l.jsxs("span",{children:[C("Drop files here or")," ",l.jsx("span",{className:"wx-at1A8tb8 wx-action",onClick:ue,children:C("select files")})]})})]})};new Date().valueOf();function mC(n,a){if(Object.keys(n).length!==Object.keys(a).length)return!1;for(const i in a){const r=n[i],c=a[i];if(!kd(r,c))return!1}return!0}function kd(n,a){if(typeof n=="number"||typeof n=="string"||typeof n=="boolean"||n===null)return n===a;if(typeof n!=typeof a||(n===null||a===null)&&n!==a||n instanceof Date&&a instanceof Date&&n.getTime()!==a.getTime())return!1;if(typeof n=="object")if(Array.isArray(n)&&Array.isArray(a)){if(n.length!==a.length)return!1;for(let i=n.length-1;i>=0;i--)if(!kd(n[i],a[i]))return!1;return!0}else return mC(n,a);return n===a}function ah(n){if(typeof n!="object"||n===null)return n;if(n instanceof Date)return new Date(n);if(n instanceof Array)return n.map(ah);const a={};for(const i in n)a[i]=ah(n[i]);return a}var Py=2,hC=class{constructor(n){n&&(this._writable=n.writable,this._async=n.async),this._values={},this._state={}}setState(n,a=0){const i={};return this._wrapProperties(n,this._state,this._values,"",i,a),i}getState(){return this._values}getReactive(){return this._state}_wrapProperties(n,a,i,r,c,d){for(const h in n){const p=a[h],x=i[h],g=n[h];if(p&&(x===g&&typeof g!="object"||g instanceof Date&&x instanceof Date&&x.getTime()===g.getTime()))continue;const w=r+(r?".":"")+h;p?(p.__parse(g,w,c,d)&&(i[h]=g),d&Py?c[w]=p.__trigger:p.__trigger()):(g&&g.__reactive?a[h]=this._wrapNested(g,g,w,c):a[h]=this._wrapWritable(g),i[h]=g),c[w]=c[w]||null}}_wrapNested(n,a,i,r){const c=this._wrapWritable(n);return this._wrapProperties(n,c,a,i,r,0),c.__parse=(d,h,p,x)=>(this._wrapProperties(d,c,a,h,p,x),!1),c}_wrapWritable(n){const a=[],i=function(){for(let r=0;r<a.length;r++)a[r](n)};return{subscribe:r=>(a.push(r),this._async?setTimeout(r,1,n):r(n),()=>{const c=a.indexOf(r);c>=0&&a.splice(c,1)}),__trigger:()=>{a.length&&(this._async?setTimeout(i,1):i())},__parse:function(r){return n=r,!0}}}},pC=class{constructor(n,a,i,r){typeof n=="function"?this._setter=n:this._setter=n.setState.bind(n),this._routes=a,this._parsers=i,this._prev={},this._triggers=new Map,this._sources=new Map,this._routes.forEach(c=>{c.in.forEach(d=>{const h=this._triggers.get(d)||[];h.push(c),this._triggers.set(d,h)}),c.out.forEach(d=>{const h=this._sources.get(d)||{};c.in.forEach(p=>h[p]=!0),this._sources.set(d,h)})}),this._routes.forEach(c=>{c.length=Math.max(...c.in.map(d=>qy(d,this._sources,1)))}),this._bus=r}init(n){const a={};for(const i in n)if(this._prev[i]!==n[i]){const r=this._parsers[i];a[i]=r?r(n[i]):n[i]}this._prev=this._prev?{...this._prev,...n}:{...n},this.setState(a),this._bus&&this._bus.exec("init-state",a)}setStateAsync(n){const a=this._setter(n,Py);return this._async?Object.assign(this._async.signals,a):this._async={signals:a,timer:setTimeout(this._applyState.bind(this),1)},a}_applyState(){const n=this._async;if(n){this._async=null,this._triggerUpdates(n.signals,[]);for(const a in n.signals){const i=n.signals[a];i&&i()}}}setState(n,a=[]){const i=this._setter(n);return this._triggerUpdates(i,a),i}_triggerUpdates(n,a){const i=Object.keys(n),r=!a.length;a=a||[];for(let c=0;c<i.length;c++){const d=i[c],h=this._triggers.get(d);h&&h.forEach(p=>{a.indexOf(p)==-1&&a.push(p)})}r&&this._execNext(a)}_execNext(n){for(;n.length;){n.sort((i,r)=>i.length<r.length?1:-1);const a=n[n.length-1];n.splice(n.length-1),a.exec(n)}}};function qy(n,a,i){const r=a.get(n);if(!r)return i;const c=Object.keys(r).map(d=>qy(d,a,i+1));return Math.max(...c)}var gC=class{constructor(){this._nextHandler=null,this._handlers={},this._tag=new WeakMap,this.exec=this.exec.bind(this)}on(n,a,i){let r=this._handlers[n];r?i&&i.intercept?r.unshift(a):r.push(a):r=this._handlers[n]=[a],i&&i.tag&&this._tag.set(a,i.tag)}intercept(n,a,i){this.on(n,a,{...i,intercept:!0})}detach(n){for(const a in this._handlers){const i=this._handlers[a];for(let r=i.length-1;r>=0;r--)this._tag.get(i[r])===n&&i.splice(r,1)}}async exec(n,a){const i=this._handlers[n];if(i)for(let r=0;r<i.length;r++){const c=i[r](a);if(c===!1||c&&c.then&&await c===!1)return}return this._nextHandler&&await this._nextHandler.exec(n,a),a}setNext(n){return this._nextHandler=n}};function xC(n){return a=>a[n]}function vC(n){return(a,i)=>a[n]=i}function si(n,a){return(a.getter||xC(a.id))(n)}function Nm(n,a,i){return(a.setter||vC(a.id))(n,i)}function yC(n,a){const i=document.createElement("a");i.href=URL.createObjectURL(n),i.download=a,document.body.appendChild(i),i.click(),document.body.removeChild(i)}function ai(n,a){let i=si(n,a)??"";return a.template?i=a.template(i,n,a):a.optionsMap&&(Array.isArray(i)?i=i.map(r=>a.optionsMap.get(r)).join(", "):i=a.optionsMap.get(i)),typeof i>"u"?"":i+""}function wC(n,a){const i=/\n|"|;|,/;let r="";const c=a.rows||`
|
|
11
|
-
`,d=a.cols||" ",h=n._columns,p=n.flatData;a.header!==!1&&h[0].header&&(r=hv("header",h,r,d,c));for(let x=0;x<p.length;x++){const g=[];for(let w=0;w<h.length;w++){let v=ai(p[x],h[w]);i.test(v)&&(v='"'+v.replace(/"/g,'""')+'"'),g.push(v)}r+=(r?c:"")+g.join(d)}return a.footer!==!1&&h[0].footer&&(r=hv("footer",h,r,d,c)),r}function hv(n,a,i,r,c){const d=/\n|"|;|,/;for(let h=0;h<a[0][n].length;h++){const p=[];for(let x=0;x<a.length;x++){let g=(a[x][n][h].text||"")+"";d.test(g)&&(g='"'+g.replace(/"/g,'""')+'"'),p.push(g)}i+=(i?c:"")+p.join(r)}return i}const bC="portrait",SC=100,CC="a4",jC={a3:{width:11.7,height:16.5},a4:{width:8.27,height:11.7},letter:{width:8.5,height:11}};function kC(n,a){const i=[];let r=[],c=0;const d=n.filter(p=>!p.hidden),h=MC(a);return d.forEach((p,x)=>{c+p.width<=h?(c+=p.width,r.push(p)):(r.length&&i.push(r),r=[p],c=p.width),x===d.length-1&&r.length&&i.push(r)}),i}function pv(n,a,i){const r=[];return n.forEach((c,d)=>{const h=c[a];for(let p=0;p<i.length;p++){r[p]||(r[p]=[]);const x={...h[p]};if(r[p][d]!==null){if(!d&&!x.rowspan&&!x.colspan){let g=1,w=n[d+g][a][p],v=x.width;for(;!w.rowspan&&!w.colspan;)g++,w=n[d+g][a][p],v+=w.width;x.colspan=g,x.width=v,x.height=i[p]}if(r[p].push(x),!x.collapsed&&x.colspan>1){let g=x.colspan-1;if(x.colspan+d>n.length){const w=x.colspan-(x.colspan+d-n.length);x.colspan=w,x.width=n.slice(d,d+g+1).reduce((v,b)=>v+b.width,0),w>1&&(g=w-1)}for(let w=0;w<g;w++)r[p].push(null)}if(x.rowspan>1){const g=x.rowspan;for(let w=1;w<g;w++)r[p+w]||(r[p+w]=[]),r[p+w].push(null)}}}if(c.collapsed)for(let p=0;p<r.length;p++){const x=r[p],g=x[d];if(g&&g.collapsed){if(x[d]=null,!p)break}else{const w=g||x.findLast(v=>v?.colspan>=1);w&&(w.colspan=w.colspan-1,w.width=w.width-c.width)}}}),r.map(c=>c.filter(d=>d&&d.colspan!==0))}function MC(n){const{mode:a,ppi:i,paper:r}=n,{width:c,height:d}=jC[r];return AC(a==="portrait"?c:d,i)}function AC(n,a){return n*a}function NC(n={}){const{mode:a,ppi:i,paper:r}=n;return{mode:a||bC,ppi:i||SC,paper:r||CC}}function Gy(n,a){return n.flexgrow?`min-width:${a}px;width:auto`:`width:${n.width}px; max-width:${n.width}px; height:${n.height}px`}function TC(n,a,i){let r=n[i.id];if(i.filter.type==="richselect"&&r){const c=i.filter.config?.options||a.find(({id:d})=>d==i.id).options;c&&(r=c.find(({id:d})=>d==r).label)}return r??""}const gv=["resize-column","hide-column","update-cell"],RC=["delete-row","update-row","update-cell"],EC=["move-item"],DC=["resize-column","move-item"];class LC{undo=[];redo=[];progress={};in;getState;setState;_previousValues={};constructor(a,i,r){this.in=a,this.getState=i,this.setState=r,this.setHandlers(),this.resetStateHistory()}getHandlers(){return{"add-row":{handler:a=>({action:"delete-row",data:{id:a.id},source:{action:"add-row",data:a}})},"delete-row":{handler:a=>{const{id:i}=a,{data:r}=this.getPrev(),c=r.findIndex(d=>d.id===i);return{action:"add-row",data:{id:i,row:r[c],before:c<r.length-1?r[c+1].id:void 0},source:{action:"delete-row",data:a}}}},"update-cell":{handler:a=>{const{id:i,column:r}=a,c=this.getRow(i),d=this.getColumn(r),h=si(c,d);return kd(h,a.value)?null:{action:"update-cell",data:{id:i,column:r,value:h},source:{action:"update-cell",data:a}}}},"update-row":{handler:a=>{const{id:i,row:r}=a,c=this.getRow(i);for(const d in r)Object.keys(c).includes(d)||(c[d]=void 0);return{action:"update-row",data:{id:i,row:c},source:{action:"update-row",data:a}}}},"copy-row":{handler:a=>{const{id:i}=a,{data:r}=this.getState(),c=r.findIndex(h=>h.id===i),d=r[c];return{action:"delete-row",data:{id:i},source:{action:"add-row",data:{id:i,row:d,before:c<r.length-1?r[c+1].id:void 0}}}}},"resize-column":{handler:a=>{const{id:i,width:r}=a,c=this.getColumn(i),{_sizes:d}=this.getState();return{action:"resize-column",data:{id:i,width:c.width??d.columnWidth},source:{action:"resize-column",data:{id:i,width:r}}}}},"hide-column":{handler:a=>{const{id:i}=a,r=this.getColumn(i);return{action:"hide-column",data:{id:i,mode:r.hidden},source:{action:"hide-column",data:a}}}},"collapse-column":{handler:a=>{const{id:i,row:r,mode:c}=a;return{action:"collapse-column",data:{id:i,row:r,mode:typeof c=="boolean"?!c:c},source:{action:"collapse-column",data:a}}}},"move-item":{handler:a=>{const{id:i,target:r,mode:c}=a,{flatData:d}=this.getPrev(),h=d.findIndex(p=>p.id===i);return{action:"move-item",data:{id:i,target:d[h+(h?-1:1)].id,mode:h?"after":"before"},source:{action:"move-item",data:{id:i,target:r,mode:c}}}}},"open-row":{handler:a=>{const{id:i,nested:r}=a;return{action:"close-row",data:{id:i,nested:r},source:{action:"open-row",data:a}}}},"close-row":{handler:a=>{const{id:i,nested:r}=a;return{action:"open-row",data:{id:i,nested:r},source:{action:"close-row",data:a}}}}}}resetHistory(){this.undo=[],this.redo=[],this.progress={},this.resetStateHistory()}getPrev(){return this._previousValues}setHandlers(){const a=this.getHandlers();for(const i in a)this.in.intercept(i,r=>{if(!(r.eventSource==="undo"||r.eventSource==="redo"||r.skipUndo)){if(DC.includes(i)){(r.inProgress&&!this.progress[i]||typeof r.inProgress!="boolean")&&(EC.includes(i)&&this.setPrev("flatData"),gv.includes(i)&&this.setPrev("columns")),this.progress[i]=r.inProgress;return}RC.includes(i)&&this.setPrev("data"),gv.includes(i)&&this.setPrev("columns")}}),this.in.on(i,r=>{if(r.eventSource==="undo"||r.eventSource==="redo"||r.skipUndo||r.inProgress)return;const c=a[i].handler(r);c&&this.addToHistory(c)})}setPrev(a){this._previousValues[a]=ah(this.getState()[a])}addToHistory(a){this.undo.push(a),this.redo=[],this.setStateHistory()}handleUndo(){if(!this.undo.length)return;const a=this.undo.pop();this.redo.push({...a.source,source:a}),this.in.exec(a.action,{...a.data,eventSource:"undo"}),this.setStateHistory()}handleRedo(){if(!this.redo.length)return;const a=this.redo.pop();this.undo.push({...a.source,source:a}),this.in.exec(a.action,{...a.data,eventSource:"redo"}),this.setStateHistory()}resetStateHistory(){this.setState({history:{undo:0,redo:0}})}setStateHistory(){this.setState({history:{undo:this.undo.length,redo:this.redo.length}})}getRow(a){const{data:i}=this.getPrev();return this.getState().tree?this.getTreeRow(i,a):i.find(r=>r.id===a)}getTreeRow(a,i){for(let r=0;r<a.length;r++){if(a[r].id===i)return a[r];if(a[r].data){const c=this.getTreeRow(a[r].data,i);if(c)return c}}return null}getColumn(a){const{columns:i}=this.getPrev();return i.find(r=>r.id===a)}}function Yy(n,a){return typeof n>"u"||n===null?-1:typeof a>"u"||a===null?1:n===a?0:n>a?1:-1}function zC(n,a){return-Yy(n,a)}function _C(n,a){if(typeof a.sort=="function")return function(r,c){const d=a.sort(r,c);return n==="asc"?d:-d};const i=n==="asc"?Yy:zC;return function(r,c){return i(si(r,a),si(c,a))}}function OC(n,a){if(!n||!n.length)return;const i=n.map(r=>{const c=a.find(d=>d.id==r.key);return _C(r.order,c)});return n.length===1?i[0]:function(r,c){for(let d=0;d<i.length;d++){const h=i[d](r,c);if(h!==0)return h}return 0}}const Gu=28,IC=20;function BC(){if(typeof document>"u")return"willow";const n=document.querySelector('[class^="wx"][class$="theme"]');return n?n.className.substring(3,n.className.length-6):"willow"}function gd(n,a,i,r,c){const d=document.createElement("div"),h=document.createElement("div"),p=document.body;c=c?`${c}px`:"auto";let x,g;h.className=a,d.classList.add(`wx-${i}-theme`),d.style.cssText=`height:auto;position:absolute;top:0px;left:100px;overflow:hidden;width=${c};white-space:nowrap;`,d.appendChild(h),p.appendChild(d),typeof n!="object"&&(n=[n]);for(let w=0;w<n.length;w++){h.innerText=n[w]+"";const v=d.getBoundingClientRect(),b=Math.ceil(v.width)+(r&&r.length?r[w]:0),k=Math.ceil(v.height);x=Math.max(x||0,b),g=Math.max(g||0,k)}return d.remove(),{width:x,height:g}}function xv(n,a,i,r,c){const d=[];for(let h=0;h<n.length;h++){const p=n[h][a],x=p.length;for(let g=0;g<x;g++){const{text:w,vertical:v,collapsed:b,rowspan:k,css:j}=p[g];if(!w){d[g]=Math.max(d[g]||0,r);continue}let M=0;if(v&&!b){let T=`wx-measure-cell-${a}`;if(T+=j?` ${j}`:"",M=gd(w,T,c).width,(k>1||!p[g+1])&&i>g+1){const C=k||i-g,A=d.slice(g,g+C).reduce((D,H)=>D+H,0);if(A<M){const D=Math.ceil((M-A)/C);for(let H=g;H<g+C;H++)d[H]=(d[H]||r)+D}continue}}d[g]=Math.max(d[g]||r,M)}}return d}function FC(n,a,i){const r=[],c=[];let d="wx-measure-cell-body";d+=n.css?` ${n.css}`:"";for(let h=0;h<a.length;h++){const p=a[h],x=ai(p,n);x&&(r.push(x),n.treetoggle?c.push(a[h].$level*Gu+(a[h].$count?Gu:0)+(n.draggable?Gu:0)):n.draggable&&c.push(Gu))}return gd(r,d,i,c).width}function HC(n,a){const i="wx-measure-cell-header",r=n.sort?IC:0;let c=n.header;if(typeof c=="string")return gd(c,i,a).width+r;let d;Array.isArray(c)||(c=[c]);for(let h=0;h<c.length;h++){const p=c[h],x=typeof p=="string"?p:p.text,g=i+(typeof p=="string"?"":` ${p.css}`);let w=gd(x,g,a).width;h===c.length-1&&(w+=r),d=Math.max(d||0,w)}return d}const $C={text:(n,a)=>n?n.toString().toLowerCase().indexOf(a.toLowerCase())!==-1:!a,richselect:(n,a)=>typeof a!="number"&&!a?!0:n==a,datepicker:(n,a)=>a?n&&PC(n,a):!0,multiselect:(n,a)=>!a||a?.length===0?!0:Array.isArray(n)?n?.some(i=>a.includes(i)):n&&a.includes(n)};function Vy(n){return $C[n]}function UC(n,a){const i=[];for(const r in n){const c=a.find(x=>x.id==r),{config:d,type:h}=c.header.find(x=>x.filter).filter,p=n[r];i.push(x=>{const g=si(x,c);return d?.handler?d.handler(g,p):Vy(h)(g,p)})}return r=>{for(let c=0;c<i.length;c++)if(!i[c](r))return!1;return!0}}function PC(n,a){return n.getFullYear()===a.getFullYear()&&n.getMonth()===a.getMonth()&&n.getDate()===a.getDate()}let qC=class extends hC{in;_router;_branches;_xlsxWorker;_historyManager;constructor(a){super({writable:a,async:!1});const i={rowHeight:37,columnWidth:160,headerHeight:36,footerHeight:36};this._router=new pC(super.setState.bind(this),[{in:["columns","sizes","_skin"],out:["_columns","_sizes"],exec:c=>{const{columns:d,sizes:h,_skin:p}=this.getState(),x=this.copyColumns(d),g=x.reduce((b,k)=>Math.max(k.header.length,b),0),w=x.reduce((b,k)=>Math.max(k.footer.length,b),0);x.forEach(this.setCollapsibleColumns);const v=this.normalizeSizes(x,h,g,w,p);for(let b=0;b<x.length;b++)this.normalizeColumns(x,b,"header",g,v),this.normalizeColumns(x,b,"footer",w,v);this.setState({_columns:x,_sizes:v},c)}},{in:["data","tree","_filterIds"],out:["flatData","_rowHeightFromData"],exec:c=>{const{data:d,tree:h,dynamic:p,_filterIds:x}=this.getState(),g=x&&new Set(x),w=h?this.flattenRows(d,[],x):g?d.filter(b=>g.has(b.id)):d,v=!p&&w.some(b=>b.rowHeight);this.setState({flatData:w,_rowHeightFromData:v},c)}}],{sizes:c=>({...i,...c})});const r=this.in=new gC;r.on("close-editor",({ignore:c})=>{const{editor:d}=this.getState();d&&(c||r.exec("update-cell",d),this.setState({editor:null}))}),r.on("open-editor",({id:c,column:d})=>{let h=this.getState().editor;h&&r.exec("close-editor",{});const p=this.getRow(c),x=d?this.getColumn(d):this.getNextEditor(p);if(x?.editor){let g=x.editor;if(typeof g=="function"&&(g=g(p,x)),!g)return;h={column:x.id,id:c,value:si(p,x)??"",renderedValue:ai(p,x),type:g.type||g},typeof g=="object"&&g.config&&(h.config=g.config,g.config.options&&(h.options=g.config.options)),x.options&&!h.options&&(h.options=x.options),this.setState({editor:h})}}),r.on("editor",({value:c})=>{let d=this.getState().editor;if(d){d={...d},d.value=c;const h=this.getColumn(d.column),p={...this.getRow(d.id)};Nm(p,h,c),d.renderedValue=ai(p,h),this.setState({editor:d})}}),r.on("add-row",c=>{const d=this.getState();let{data:h}=d;const{select:p,_filterIds:x}=d,{row:g,before:w,after:v,select:b}=c;if(c.id=g.id=c.id||g.id||Yu(),w||v){const j=w||v,M=h.findIndex(T=>T.id===j);h=[...h],h.splice(M+(v?1:0),0,c.row)}else h=[...h,c.row];const k={data:h};x&&(k._filterIds=[...x,c.id]),this.setState(k),!(typeof b=="boolean"&&!b)&&(b||p)&&r.exec("select-row",{id:g.id,show:!0})}),r.on("delete-row",c=>{const{data:d,selectedRows:h,focusCell:p,editor:x}=this.getState(),{id:g}=c,w={data:d.filter(v=>v.id!==g)};this.isSelected(g)&&(w.selectedRows=h.filter(v=>v!==g)),x?.id===g&&(w.editor=null),this.setState(w),p?.row===g&&this.in.exec("focus-cell",{eventSource:"delete-row"})}),r.on("update-cell",c=>{const d=this.getState();let{data:h}=d;h=[...h];const{tree:p}=d,{id:x,column:g,value:w}=c,v=this.getColumn(g);if(p){const b={...this._branches[x]};Nm(b,v,w);const k=this.updateTreeRow(b);b.$parent===0&&(h=k)}else{const b=h.findIndex(j=>j.id===x),k={...h[b]};Nm(k,v,w),h[b]=k}this.setState({data:h})}),r.on("update-row",c=>{let{data:d}=this.getState();const{id:h,row:p}=c,x=d.findIndex(g=>g.id===h);d=[...d],d[x]={...d[x],...p},this.setState({data:d})}),r.on("select-row",({id:c,toggle:d,range:h,mode:p,show:x,column:g})=>{const w=this.getState(),{focusCell:v}=w;let{selectedRows:b}=w;if(b.length||(h=d=!1),h){const{data:k}=this.getState();let j=k.findIndex(T=>T.id===b[b.length-1]),M=k.findIndex(T=>T.id===c);j>M&&([j,M]=[M,j]),k.slice(j,M+1).forEach(T=>{this.isSelected(T.id)||b.push(T.id)})}else if(d&&this.isSelected(c)){if(p===!0)return;b=b.filter(k=>k!==c)}else if(d){if(p===!1)return;b.push(c)}else b=[c];this.setState({selectedRows:[...b]}),v?.row!==c&&this.in.exec("focus-cell",{eventSource:"select-row"}),x&&this.in.exec("scroll",{row:c,column:g})}),this.in.on("focus-cell",c=>{const{row:d,column:h,eventSource:p}=c,{_columns:x,split:g}=this.getState();d&&h?(this.setState({focusCell:{row:d,column:h}}),p!=="click"&&((!g.left||x.findIndex(w=>w.id===c.column)>=g.left)&&(!g.right||x.findIndex(w=>w.id===c.column)<x.length-g.right)?this.in.exec("scroll",{row:d,column:h}):this.in.exec("scroll",{row:d}))):this.setState({focusCell:null})}),r.on("resize-column",c=>{const{id:d,auto:h,maxRows:p,inProgress:x}=c;if(x===!1)return;let g=c.width||0;const w=[...this.getState().columns],v=this.getColumn(d);if(h){if(h==="data"||h===!0){const{flatData:b,_skin:k}=this.getState();let j=b.length;p&&(j=Math.min(p,j));const M=b.slice(0,j);g=FC(v,M,k)}if(h==="header"||h===!0){const{_skin:b}=this.getState();g=Math.max(HC(v,b),g)}}v.width=Math.max(17,g),delete v.flexgrow,this.setState({columns:w})}),r.on("hide-column",c=>{const{id:d,mode:h}=c,p=[...this.getState().columns],x=this.getColumn(d),g=p.reduce((w,v)=>w+(v.hidden?0:1),0);!h||g>1?(x.hidden=!x.hidden,this.setState({columns:p})):c.skipUndo=!0}),r.on("sort-rows",c=>{const{key:d,add:h,sort:p}=c,x=this.getState(),{columns:g,data:w,tree:v}=x;if(p){const A=[...w];A.sort(p),this.setState({data:A});return}const{order:b="asc"}=c;let k=x.sortMarks;const j=Object.keys(k),M=j.length;!h||!M||M===1&&k[d]?k={[d]:{order:b}}:(M===1&&(k[j[0]]={...k[j[0]],index:0}),k={...k,[d]:{order:b,index:typeof h=="number"?h:k[d]?.index??M}});const T=Object.keys(k).sort((A,D)=>k[A].index-k[D].index).map(A=>({key:A,order:k[A].order}));this.setState({sortMarks:k});const C=OC(T,g);if(C){const A=[...w];v?this.sortTree(A,C):A.sort(C),this.setState({data:A})}}),r.on("filter-rows",c=>{const{value:d,key:h,filter:p}=c;if(!Object.keys(c).length){this.setState({filterValues:{},_filterIds:null});return}const x=this.getState(),{data:g,tree:w,_columns:v}=x;let b=x.filterValues;const k={};h&&(b={...b,[h]:d},k.filterValues=b);const j=p??UC(b,v);let M=[];w?M=this.filterTree(g,j,M):g.forEach(T=>{j(T)&&M.push(T.id)}),k._filterIds=M,this.setState(k)}),r.on("collapse-column",c=>{const{id:d,row:h,mode:p}=c,x=[...this.getState().columns],g=this.getColumn(d).header,w=Array.isArray(g)?g[h]:g;typeof w=="object"&&(w.collapsed=p??!w.collapsed,this.setState({columns:x}))}),r.on("move-item",c=>{const{id:d,inProgress:h}=c;let{target:p,mode:x="after"}=c;const{data:g,flatData:w,tree:v}=this.getState(),b=w.findIndex(M=>M.id===d);let k;if(x==="up"||x==="down"){if(x==="up"){if(b===0)return;k=b-1,x="before"}else if(x==="down"){if(b===w.length-1)return;k=b+1,x="after"}p=w[k]&&w[k].id}else k=w.findIndex(M=>M.id===p);if(b===-1||k===-1||h===!1)return;let j;v||(j=this.moveItem(d,p,g,x)),this.setState({data:v?this.normalizeTreeRows(j):j})}),r.on("copy-row",c=>{const{id:d,target:h,mode:p="after"}=c,x=this.getState(),{flatData:g,_filterIds:w}=x;let{data:v}=x;const b=this.getRow(d);if(!b)return;const k={...b,id:Yu()};c.id=k.id;const j=g.findIndex(T=>T.id===h);if(j===-1)return;v.splice(j+(p==="after"?1:0),0,k),v=[...v];const M={data:v};w&&(M._filterIds=[...w,k.id]),this.setState(M)}),r.on("open-row",c=>{const{id:d,nested:h}=c;this.toggleBranch(d,!0,h)}),r.on("close-row",c=>{const{id:d,nested:h}=c;this.toggleBranch(d,!1,h)}),r.on("export-data",c=>new Promise((d,h)=>{const p=c.format||"csv",x=`${c.fileName||"data"}.${p}`;if(p==="csv"){const g=wC(this.getState(),c.csv||{});c.download!==!1?yC(new Blob(["\uFEFF"+g],{type:"text/csv"}),x):c.result=g,d(!0)}else h()})),r.on("hotkey",({key:c,event:d,isInput:h})=>{switch(c){case"arrowup":{const{flatData:p,focusCell:x,select:g}=this.getState();if(d.preventDefault(),h)return;const w=x?x.column:this._getFirstVisibleColumn()?.id,v=x?this.getPrevRow(x.row)?.id:p[p.length-1]?.id;w&&v&&(this.in.exec("focus-cell",{row:v,column:w,eventSource:"key"}),g&&this.in.exec("select-row",{id:v}));break}case"arrowdown":{const{flatData:p,focusCell:x,select:g}=this.getState();if(d.preventDefault(),h)return;const w=x?x.column:this._getFirstVisibleColumn()?.id,v=x?this.getNextRow(x.row)?.id:p[0]?.id;w&&v&&(this.in.exec("focus-cell",{row:v,column:w,eventSource:"key"}),g&&this.in.exec("select-row",{id:v}));break}case"arrowright":{const{focusCell:p}=this.getState();if(h)return;if(d.preventDefault(),p){const x=this.getNextColumn(p.column,!0)?.id;x&&this.in.exec("focus-cell",{row:p.row,column:x,eventSource:"key"})}break}case"arrowleft":{const{focusCell:p}=this.getState();if(h)return;if(d.preventDefault(),p){const x=this.getPrevColumn(p.column,!0)?.id;x&&this.in.exec("focus-cell",{row:p.row,column:x,eventSource:"key"})}break}case"tab":{const{editor:p,focusCell:x,select:g}=this.getState();if(p){d.preventDefault();const w=p.column;let v=p.id,b=this.getNextEditor(this.getRow(v),this.getColumn(w));if(!b){const k=this.getNextRow(v);k&&(v=k.id,b=this.getNextEditor(k))}b&&(this.in.exec("open-editor",{id:v,column:b.id}),this.in.exec("focus-cell",{row:v,column:b.id,eventSource:"key"}),g&&!this.isSelected(v)&&this.in.exec("select-row",{id:v}))}else x&&this.in.exec("focus-cell",{eventSource:"key"});break}case"shift+tab":{const{editor:p,focusCell:x,select:g}=this.getState();if(p){d.preventDefault();const w=p.column;let v=p.id,b=this.getPrevEditor(this.getRow(v),this.getColumn(w));if(!b){const k=this.getPrevRow(v);k&&(v=k.id,b=this.getPrevEditor(k))}b&&(this.in.exec("open-editor",{id:v,column:b.id}),this.in.exec("focus-cell",{row:v,column:b.id,eventSource:"key"}),g&&!this.isSelected(v)&&this.in.exec("select-row",{id:v}))}else x&&this.in.exec("focus-cell",{eventSource:"key"});break}case"escape":{const{editor:p}=this.getState();p&&(this.in.exec("close-editor",{ignore:p.type!="multiselect"}),this.in.exec("focus-cell",{row:p.id,column:p.column,eventSource:"key"}));break}case"f2":{const{editor:p,focusCell:x}=this.getState();!p&&x&&this.in.exec("open-editor",{id:x.row,column:x.column});break}case"enter":{const{focusCell:p,tree:x}=this.getState();if(!h&&x&&p&&this.getColumn(p.column).treetoggle){const g=this.getRow(p.row);if(!g.data)return;this.in.exec(g.open?"close-row":"open-row",{id:p.row,nested:!0})}break}case"home":{const{editor:p,focusCell:x}=this.getState();if(!p&&x){d.preventDefault();const g=this._getFirstVisibleColumn()?.id;this.in.exec("focus-cell",{row:x.row,column:g,eventSource:"key"})}break}case"ctrl+home":{const{editor:p,focusCell:x,flatData:g,select:w}=this.getState();if(!p&&x){d.preventDefault();const v=g[0]?.id,b=this._getFirstVisibleColumn()?.id;v&&b&&(this.in.exec("focus-cell",{row:v,column:b,eventSource:"key"}),w&&!this.isSelected(v)&&this.in.exec("select-row",{id:v}))}break}case"end":{const{editor:p,focusCell:x}=this.getState();if(!p&&x){d.preventDefault();const g=this._getLastVisibleColumn()?.id,w=x.row;this.in.exec("focus-cell",{row:w,column:g,eventSource:"key"})}break}case"ctrl+end":{const{editor:p,focusCell:x,flatData:g,select:w}=this.getState();if(!p&&x){d.preventDefault();const v=g.at(-1).id,b=this._getLastVisibleColumn()?.id;v&&b&&(this.in.exec("focus-cell",{row:v,column:b,eventSource:"key"}),w&&!this.isSelected(v)&&this.in.exec("select-row",{id:v}))}break}case"ctrl+z":{this.in.exec("undo",{});break}case"ctrl+y":{this.in.exec("redo",{});break}}}),r.on("scroll",c=>{const{_columns:d,split:h,_sizes:p,flatData:x,dynamic:g,_rowHeightFromData:w}=this.getState();let v=-1,b=-1,k=0,j=0;if(c.column){v=0;const M=d.findIndex(T=>T.id===c.column);k=d[M].width;for(let T=h.left??0;T<M;T++){const C=d[T];C.hidden||(v+=C.width)}}if(c.row&&!g){const M=x.findIndex(T=>T.id===c.row);M>=0&&(w?(b=x.slice(0,M).reduce((T,C)=>T+(C.rowHeight||p.rowHeight),0),j=x[M].rowHeight):b=p.rowHeight*M)}this.setState({scroll:{top:b,left:v,width:k,height:j||p.rowHeight}})}),r.on("scroll-to",c=>{const d={};c.top!==void 0&&(d.scrollTop=c.top),c.left!==void 0&&(d.scrollLeft=c.left),Object.keys(d).length&&this.setState(d)}),r.on("print",c=>{const d=NC(c);this.setState({_print:d}),this.setStateAsync({_print:null})}),r.on("undo",()=>{this._historyManager?.handleUndo()}),r.on("redo",()=>{this._historyManager?.handleRedo()}),this.initOnce()}getXlsxWorker(a){if(!this._xlsxWorker){const i=window.URL.createObjectURL(new Blob([`importScripts('${a}');`],{type:"text/javascript"}));this._xlsxWorker=new Promise(r=>{const c=new Worker(i);c.addEventListener("message",d=>{d.data.type==="init"&&r(c)})})}return this._xlsxWorker}initOnce(){const a={sortMarks:{},_filterIds:null,data:[],filterValues:{},scroll:null,scrollLeft:0,scrollTop:0,editor:null,focusCell:null,_print:null,history:{undo:0,redo:0},search:null};this._router.init(a)}init(a){a.hasOwnProperty("_skin")&&!a._skin&&(a._skin=BC()),a.columns&&a.columns.forEach(i=>{i.options&&(i.optionsMap=new Map(i.options.map(r=>[r.id,r.label])))}),kd(this.getState().data,a.data)||(a.tree?a.data=this.normalizeTreeRows(a.data):a.data=this.normalizeRows(a.data),this.setState({_filterIds:null,filterValues:{},sortMarks:{},search:null}),this._historyManager&&this._historyManager.resetHistory()),a.tree&&(a.undo=!1,a.reorder=!1),a.split?.right&&(a.split.right=0),a.undo&&!this._historyManager&&(this._historyManager=new LC(this.in,this.getState.bind(this),this.setState.bind(this))),this._router.init({...a})}setState(a,i){return this._router.setState(a,i)}setStateAsync(a){this._router.setStateAsync(a)}getRow(a){const{tree:i}=this.getState();return i?this._branches[a]:this.getState().data.find(r=>r.id===a)}getRowIndex(a,i){return i||(i=this.getState().flatData),i.findIndex(r=>r.id===a)}getNextRow(a){const i=this.getState().flatData,r=this.getRowIndex(a,i);return i[r+1]}getPrevRow(a){const i=this.getState().flatData,r=this.getRowIndex(a,i);return i[r-1]}getColumn(a){return this.getState().columns.find(i=>i.id===a)}getNextColumn(a,i){const r=this.getState()._columns,c=r.findIndex(d=>d.id===a);return i?this._getFirstVisibleColumn(c+1):r[c+1]}getPrevColumn(a,i){const r=this.getState()._columns,c=r.findIndex(d=>d.id===a);return i?this._getLastVisibleColumn(c-1):r[c-1]}_getFirstVisibleColumn(a){const i=this.getState()._columns;let r=a??0;for(;r<i.length&&(i[r]?.hidden||i[r]?.collapsed);)r++;return i[r]}_getLastVisibleColumn(a){const i=this.getState()._columns;let r=a??i.length-1;for(;r<i.length&&(i[r]?.hidden||i[r]?.collapsed);)r--;return i[r]}isCellEditable(a,i){const{editor:r,hidden:c}=i;return!r||c?!1:typeof r=="function"?r(a,i):!0}getNextEditor(a,i){let r=this.getState().columns;if(i){const c=r.findIndex(d=>d.id===i.id);r=r.slice(c+1)}return r.find(c=>this.isCellEditable(a,c))}getPrevEditor(a,i){let r=this.getState().columns;if(i){const c=r.findLastIndex(d=>d.id===i.id);r=r.slice(0,c)}return r.findLast(c=>this.isCellEditable(a,c))}toggleBranch(a,i,r){let c=this._branches[a],{data:d}=this.getState();if(d=[...d],a!==0){c={...c,open:i};const h=this.updateTreeRow(c);c.$parent===0&&(d=h)}r&&c.data?.length&&c.data.forEach(h=>{const p=this.toggleKids(h,i,r);a===0&&(d=p)}),this.setState({data:d})}toggleKids(a,i,r){a={...a,open:i};const c=this.updateTreeRow(a);return r&&a.data?.length&&a.data.forEach(d=>{this.toggleKids(d,i,r)}),c}updateTreeRow(a){const i=a.id;this._branches[i]=a;const r=this._branches[a.$parent],c=r.data.findIndex(d=>d.id===i);return r.data=[...r.data],r.data[c]=a,r.data}isSelected(a){return this.getState().selectedRows.indexOf(a)!==-1}findAndRemove(a,i){for(let r=0;r<a.length;r++){if(a[r].id===i)return a.splice(r,1)[0];if(a[r].data){const c=[...a[r].data],d=this.findAndRemove(c,i);if(d)return a[r]={...a[r],data:c},d}}return null}insertItem(a,i,r,c){for(let d=0;d<a.length;d++){if(a[d].id===i){const h=a[d],p=c==="before"?d:d+1;if(h.data){if(c==="before"){const x=d>0?a[d-1]:null;return x?.data&&x.open?a[d-1]={...x,data:[...x.data,r]}:a.splice(p,0,r),!0}else if(h.open)return a[d]={...h,data:[r,...h.data]},!0}return a.splice(p,0,r),!0}if(a[d].data&&(a[d]={...a[d],data:[...a[d].data]},this.insertItem(a[d].data,i,r,c)))return!0}return!1}moveItem(a,i,r,c){const d=[...r],h=this.findAndRemove(d,a);return this.insertItem(d,i,h,c),d}copyColumns(a){const i=[];for(let r=0;r<a.length;r++){const c={...a[r]};this.copyHeaderFooter(c,"header"),this.copyHeaderFooter(c,"footer"),i[r]=c}return i}copyHeaderFooter(a,i){let r=a[i];r=Array.isArray(r)?[...r]:[r],r.forEach((c,d)=>{r[d]=typeof c=="string"?{text:c}:{...c}}),a[i]=r}setCollapsibleColumns(a,i,r){let c=a.header;for(let d=0;d<c.length;d++){const h=c[d];if(h.collapsible&&h.collapsed){if(h.collapsible!=="first"){a.collapsed=!0,a.width=36,h.vertical=!0;const x=c.length-d;c=c.slice(0,d+1),c[d].rowspan=x}const p=h.colspan;if(p){const x=c[d+1];let g=1;x&&x.colspan&&!x.collapsed&&(g=x.colspan);for(let w=g;w<p;w++){const v=r[i+w];v&&(v.hidden=!0)}}}}}normalizeColumns(a,i,r,c,d){const h=a[i];h.width||(h.width=h.flexgrow?17:d.columnWidth),h._colindex=i+1;const p=h[r],x=d[`${r}RowHeights`];for(let g=0;g<c;g++){const w=p[g];w.id=h.id,g===p.length-1&&(w.rowspan=w.rowspan?Math.min(w.rowspan,c-g):c-g);for(let v=1;v<w.rowspan;v++){p.splice(g+v,0,{_hidden:!0});for(let b=1;b<w.colspan;b++)a[i+b][r].splice(g+v,0,{})}if(w.rowspan){const v=(w.rowspan===c?x:x.slice(g,w.rowspan+g)).reduce((b,k)=>b+k,0);w.height=v,g+w.rowspan!=c&&w.height--}if(w.colspan){let v=h.width,b=h.flexgrow||0;const k=w.colspan;for(let j=1;j<k;j++){const M=a[i+j];M&&(M.hidden?w.colspan-=1:M.flexgrow?b+=M.flexgrow:v+=M.width||d.columnWidth),b?w.flexgrow=b:w.width=v}}else w.width=h.width,w.flexgrow=h.flexgrow;r==="header"&&w.filter&&typeof w.filter=="string"&&(w.filter={type:w.filter})}p.length>c&&(p.length=c),h[r]=p}normalizeRows(a){for(let i=0;i<a.length;i++)a[i].id||(a[i].id=Yu());return a}normalizeTreeRows(a,i,r){return!i&&!r&&(this._branches={0:{data:a}}),a.forEach(c=>{c.id||(c.id=Yu()),c.$level=i||0,c.$parent=r||0,this._branches[c.id]=c,c.data&&(c.data.length?(c.$count=c.data.length,this.normalizeTreeRows(c.data,c.$level+1,c.id)):(delete c.data,delete c.$count,delete c.open))}),a}sortTree(a,i){a.sort(i),a.forEach(r=>{r.data&&this.sortTree(r.data,i)})}filterTree(a,i,r){return a.forEach(c=>{i(c)&&r.push(c.id),c.data&&this.filterTree(c.data,i,r)}),r}flattenRows(a,i,r){const c=i;return a.forEach(d=>{(!r||r.includes(d.id))&&c.push(d),d.data?.length&&d.open!==!1&&this.flattenRows(d.data,c,r)}),c}createFilter(a){const{_columns:i}=this.getState(),r=[];for(const c in a){const d=i.find(g=>g.id==c),{config:h,type:p}=d.header.find(g=>g.filter).filter,x=a[c];r.push(g=>{const w=si(g,d);return h?.handler?h.handler(w,x):Vy(p)(w,x)})}return c=>{for(let d=0;d<r.length;d++)if(!r[d](c))return!1;return!0}}searchRows(a,i){a=a.trim().toLowerCase();const r={};if(!a)return r;const{flatData:c,columns:d}=this.getState(),h=i?d.filter(p=>i[p.id]):d;return c.forEach(p=>{const x={};h.forEach(g=>{const w=ai(p,g);String(w).toLowerCase().includes(a)&&(x[g.id]=!0)}),Object.keys(x).length&&(r[p.id]=x)}),r}normalizeSizes(a,i,r,c,d){const h=xv(a,"header",r,i.headerHeight,d),p=xv(a,"footer",c,i.footerHeight,d),x=h.reduce((w,v)=>w+v,0),g=p.reduce((w,v)=>w+v,0);return{...i,headerRowHeights:h,footerRowHeights:p,headerHeight:x,footerHeight:g}}},GC=new Date().valueOf();function Yu(){return"temp://"+GC++}function YC(n,a="data-id"){let i=n;for(!i.tagName&&n.target&&(i=n.target);i;){if(i.getAttribute&&i.getAttribute(a))return i;i=i.parentNode}return null}new Date().valueOf();var VC=class{constructor(){this.store=new Map}configure(n,a){this.node=a;for(const i in n)if(n[i]){const r=i.toLowerCase().replace(/[ ]/g,""),c=n[i];this.store.set(r,c)}}},Br=[],KC={subscribe:n=>{WC();const a=new VC;return Br.push(a),n(a),()=>{const i=Br.findIndex(r=>r===a);i>=0&&Br.splice(i,1)}}},vv=!1;function WC(){vv||(vv=!0,document.addEventListener("keydown",n=>{if(Br.length&&(n.ctrlKey||n.altKey||n.metaKey||n.shiftKey||n.key.length>1||n.key===" ")){const a=[];n.ctrlKey&&a.push("ctrl"),n.altKey&&a.push("alt"),n.metaKey&&a.push("meta"),n.shiftKey&&a.push("shift");let i=n.code.replace("Key","").toLocaleLowerCase();n.key===" "&&(i="space"),a.push(i);const r=a.join("+");for(let c=Br.length-1;c>=0;c--){const d=Br[c],h=d.store.get(r)||d.store.get(i);h&&d.node.contains(n.target)&&h(n,{key:r,evKey:i})}}}))}const QC={tab:!0,"shift+tab":!0,arrowup:!0,arrowdown:!0,arrowright:!0,arrowleft:!0,enter:!0,escape:!0,f2:!0,home:!0,end:!0,"ctrl+home":!0,"ctrl+end":!0,"ctrl+z":!0,"ctrl+y":!0};function XC(n,{keys:a,exec:i}){if(!a)return;function r(h){const p=h.target;return p.tagName==="INPUT"||p.tagName==="TEXTAREA"||YC(p,"data-header-id")?.classList.contains("wx-filter")||!!p.closest(".wx-cell.wx-editor")}const c={};for(const h in a){const p=a[h];typeof p<"u"&&(typeof p=="function"?c[h]=p:p&&(c[h]=x=>{const g=r(x);i({key:h,event:x,isInput:g})}))}const d=KC.subscribe(h=>{h.configure(c,n)});return{destroy:()=>{d()}}}function ZC(n,a){let i=null;a.scroll.subscribe(r=>{if(!r||r===i)return;i=r;const{left:c,top:d,height:h,width:p}=r,x=a.getHeight(),g=a.getWidth(),w=a.getScrollMargin();if(d>=0){const v=n.scrollTop;d<v?n.scrollTop=d:d+h>v+x&&(n.scrollTop=d-x+h)}if(c>=0){const v=n.scrollLeft;c<v?n.scrollLeft=c:c+p>v+g-w&&(n.scrollLeft=c-g+p+w)}}),a.scrollLeft?.subscribe?.(r=>{requestAnimationFrame(()=>{Math.abs(n.scrollLeft-r)>1&&(n.scrollLeft=r)})}),a.scrollTop?.subscribe?.(r=>{requestAnimationFrame(()=>{Math.abs(n.scrollTop-r)>1&&(n.scrollTop=r)})})}const La=f.createContext(null);function JC(n,a){const i=new ResizeObserver(r=>{requestAnimationFrame(()=>a(r[0].contentRect))});return i.observe(n.parentNode),{destroy(){i.disconnect()}}}const yv=5,ej=700;function ad(n){const a=n.getBoundingClientRect(),i=document.body,r=a.top+i.scrollTop-i.clientTop||0,c=a.left+i.scrollLeft-i.clientLeft||0;return{y:Math.round(r),x:Math.round(c),width:n.offsetWidth,height:n.offsetHeight}}function sh(n,a){const i=ad(a);return{x:n.clientX-i.x,y:n.clientY-i.y}}function tj(n,a){const i=a.current;let r=null,c,d,h=!1,p=!1;const x=document.createElement("DIV");x.className="wx-drag-zone",x.setAttribute("tabindex",-1);function g(){clearTimeout(c),c=null}function w(L){const F=$r(L);F&&(r={container:x,sourceNode:L.target,from:Sd(F),pos:sh(L,n)},d=r.pos,v(L))}function v(L){if(!r)return;const F=r.pos=sh(L,n);if(!h){if(!p&&!L?.target?.getAttribute("draggable-data")&&Math.abs(d.x-F.x)<yv&&Math.abs(d.y-F.y)<yv)return;if(B(L)===!1)return q()}if(p){const ue=window.scrollX||document.documentElement.scrollLeft||document.body.scrollLeft,W=window.scrollY||document.documentElement.scrollTop||document.body.scrollTop;r.targetNode=document.elementFromPoint(L.pageX-ue,L.pageY-W)}else r.targetNode=L.target;i.move&&i.move(L,r),x.style.left=-(r.offset?r.offset.x:0)+"px",x.style.top=r.pos.y+(r.offset?r.offset.y:0)+"px"}function b(L){x.parentNode&&x.parentNode.removeChild(x),x.innerHTML="",h&&i.end&&i.end(L,r),r=d=null,q()}function k(L){i.getReorder&&!i.getReorder()||L.button===0&&(H(L),window.addEventListener("mousemove",j),window.addEventListener("mouseup",M),w(L))}function j(L){v(L)}function M(L){b(L)}function T(L){if(i.getReorder&&!i.getReorder())return;c=setTimeout(()=>{p=!0,w(L.touches[0])},ej),H(L);function F(){c&&g(),L.target.removeEventListener("touchmove",C),L.target.removeEventListener("touchend",F),b(L)}L.target.addEventListener("touchmove",C),L.target.addEventListener("touchend",F),n.addEventListener("contextmenu",A)}function C(L){h?(L.preventDefault(),v(L.touches[0])):c&&g()}function A(L){if(h||c)return L.preventDefault(),!1}function D(L){L.preventDefault()}function H(L){if(!i.getDraggableInfo)return;const{hasDraggable:F}=i.getDraggableInfo();(!F||L.target.getAttribute("draggable-data"))&&(document.body.style.userSelect="none",document.body.style.webkitUserSelect="none")}function B(L){if(h=!0,i.start){if(i.start(L,r)===!1)return!1;n.appendChild(x),document.body.style.cursor="move"}}function q(L){h=p=!1,document.body.style.cursor="",document.body.style.userSelect="",document.body.style.webkitUserSelect="",window.removeEventListener("mousemove",j),window.removeEventListener("mouseup",M),L&&(n.removeEventListener("mousedown",k),n.removeEventListener("touchstart",T),n.removeEventListener("dragstart",D))}return n.addEventListener("mousedown",k),n.addEventListener("touchstart",T),n.addEventListener("dragstart",D),{destroy(){q(!0)}}}const nj=.004;function aj(){return{dirX:0,dirY:0,scrollSpeedFactor:1}}function sj(n,a,i,r){const{node:c,left:d,top:h,bottom:p,sense:x,xScroll:g,yScroll:w}=r,v=sh(n,c);i.scrollState||(i.scrollState=aj());let b=0,k=0;v.x<d+x?b=-1:v.x>a.width-x&&(b=1),v.y<h+Math.round(x/2)?k=-1:v.y>a.height-p-Math.round(x/2)&&(k=1),(i.scrollState.dirX!==b||i.scrollState.dirY!==k)&&(Ky(i),i.scrollState.dirX=b,i.scrollState.dirY=k),(g&&i.scrollState.dirX!==0||w&&i.scrollState.dirY!==0)&&lj(i,r,{x:i.scrollState.dirX,y:i.scrollState.dirY})}function lj(n,a,i){n.autoScrollTimer||(n.autoScrollTimer=setTimeout(()=>{n.activeAutoScroll=setInterval(ij,15,n,a,i)},250))}function Ky(n){n.scrollSpeedFactor=1,n.autoScrollTimer&&(n.autoScrollTimer=clearTimeout(n.autoScrollTimer),n.activeAutoScroll=clearInterval(n.activeAutoScroll))}function ij(n,a,i){const{x:r,y:c}=i;n.scrollSpeedFactor+=nj,r!==0&&oj(n,a,r),c!==0&&rj(n,a,c)}function rj(n,a,i){const r=a.node.scrollTop;Wy(r+Math.round(a.sense/3)*n.scrollSpeedFactor*i,"scrollTop",a)}function oj(n,a,i){const r=a.node.scrollLeft;Wy(r+Math.round(a.sense/3)*n.scrollSpeedFactor*i,"scrollLeft",a)}function Wy(n,a,i){i.node[a]=n}function Md(n,a,i,r,c,d){const h={};return n&&(h.width=`${n}px`,h.minWidth=`${n}px`),a&&(h.flexGrow=a),d&&(h.height=`${d}px`),i&&(h.position="sticky",i.left&&(h.left=`${r}px`),i.right&&(h.right=`${c}px`)),h}function Qy(n,a,i){let r="";if(n.fixed)for(const c in n.fixed){let d=n.fixed[c]===-1;!d&&n.fixed.leftSize&&a.colspan&&(d=a.colspan+n._colindex-1===n.fixed.leftSize),r+=d?"wx-shadow ":"wx-fixed "}return r+=a.rowspan>1?"wx-rowspan ":"",r+=a.colspan>1?"wx-colspan ":"",r+=a.vertical?"wx-vertical ":"",r+=i?i(n)+" ":"",r}function cj(n){const{row:a,column:i,cellStyle:r=null,columnStyle:c=null,children:d,focusable:h}=n,p=f.useContext(La),x=Qe(p,"focusCell"),g=Qe(p,"search"),w=Qe(p,"reorder"),v=f.useMemo(()=>g?.rows[a.id]&&g.rows[a.id][i.id],[g,a.id,i.id]),b=f.useMemo(()=>Md(i.width,i.flexgrow,i.fixed,i.left,i.right),[i.width,i.flexgrow,i.fixed,i.left,i.right]);function k(B,q){let L="wx-cell";return L+=i.fixed?" "+(i.fixed===-1?"wx-shadow":"wx-fixed"):"",L+=B?" "+B(i):"",L+=q?" "+q(a,i):"",L+=i.treetoggle?" wx-tree-cell":"",L}const j=f.useMemo(()=>k(c,r),[c,r,i,a]),M=f.useMemo(()=>typeof i.draggable=="function"?i.draggable(a,i)!==!1:i.draggable,[i,a]),T=f.useRef(null);f.useEffect(()=>{T.current&&h&&x?.row===a.id&&x?.column===i.id&&T.current.focus()},[x,h,a.id,i.id]);const C=f.useCallback(()=>{h&&!x&&p.exec("focus-cell",{row:a.id,column:i.id,eventSource:"focus"})},[p,h,x,a.id,i.id]);function A(B){const q=new RegExp(`(${g.value.trim()})`,"gi");return String(B).split(q).map(L=>({text:L,highlight:q.test(L)}))}const D=f.useMemo(()=>{const B=i.fixed&&i.fixed.left===-1||i.fixed.right===-1,q=i.fixed&&i.fixed.right;return[j,B?"wx-shadow":"",q?"wx-fixed-right":""].filter(Boolean).join(" ")},[j,i]),H=i.cell;return l.jsxs("div",{className:"wx-TSCaXsGV "+D,ref:T,onFocus:C,style:b,"data-row-id":Cn(a.id),"data-col-id":Cn(i.id),tabIndex:h?"0":"-1",role:"gridcell","aria-colindex":i._colindex,"aria-readonly":i.editor?void 0:!0,children:[w&&i.draggable?M?l.jsx("i",{"draggable-data":"true",className:"wx-TSCaXsGV wx-draggable wxi-drag"}):l.jsx("i",{className:"wx-TSCaXsGV wx-draggable-stub"}):null,i.treetoggle?l.jsxs(l.Fragment,{children:[l.jsx("span",{style:{marginLeft:`${a.$level*28}px`}}),a.$count?l.jsx("i",{"data-action":"toggle-row",className:`wx-TSCaXsGV wx-table-tree-toggle wxi-menu-${a.open!==!1?"down":"right"}`}):null]}):null,H?l.jsx(H,{api:p,row:a,column:i,onAction:({action:B,data:q})=>p.exec(B,q)}):d?d():v?l.jsx("span",{children:A(ai(a,i)).map(({highlight:B,text:q},L)=>B?l.jsx("mark",{className:"wx-TSCaXsGV wx-search",children:q},L):l.jsx("span",{children:q},L))}):ai(a,i)]})}function wv(n,a){let i,r;function c(p){i=p.clientX,n.style.opacity=1,document.body.style.cursor="ew-resize",document.body.style.userSelect="none",window.addEventListener("mousemove",d),window.addEventListener("mouseup",h),a&&a.down&&a.down(n)}function d(p){r=p.clientX-i,a&&a.move&&a.move(r)}function h(){n.style.opacity="",document.body.style.cursor="",document.body.style.userSelect="",a&&a.up&&a.up(r),window.removeEventListener("mousemove",d),window.removeEventListener("mouseup",h)}return n.addEventListener("mousedown",c),{destroy(){n.removeEventListener("mousedown",c)}}}function uj({filter:n,column:a,action:i,filterValue:r}){function c({value:d}){i({value:d,key:a.id})}return l.jsx(Mh,{...n.config??{},value:r,onChange:c})}function dj({filter:n,column:a,action:i,filterValue:r}){const c=f.useContext(La),d=Qe(c,"flatData"),h=f.useMemo(()=>n?.config?.options||a?.options||x(),[n,a,d]),p=f.useMemo(()=>n?.config?.template,[n]);function x(){const v=[];return d.forEach(b=>{const k=si(b,a);v.includes(k)||v.push(k)}),v.map(b=>({id:b,label:b}))}function g({value:v}){i({value:v,key:a.id})}function w(v){v.key!=="Tab"&&v.preventDefault()}return l.jsx("div",{style:{width:"100%"},onKeyDown:w,children:l.jsx(k1,{placeholder:"",clear:!0,...n?.config??{},options:h,value:r,onChange:g,children:v=>p?p(v):v.label})})}function fj({filter:n,column:a,action:i,filterValue:r}){function c({value:d}){i({value:d,key:a.id})}return l.jsx("div",{className:"wx-aaaK5VYO",style:{width:"100%"},children:l.jsx(j1,{placeholder:"",clear:!0,...n?.config??{},value:r,onChange:c})})}function Xy(n){const{value:a,options:i=[],placeholder:r="",clear:c=!1,text:d=null,template:h=null,cell:p=null,dropdown:x={},autoOpen:g=!1,onChange:w,onAction:v}=n,[b,k]=_y(a||[]),j=f.useMemo(()=>(b||[]).map(W=>i.find(ce=>ce.id===W)).filter(Boolean),[b,i]),M=f.useRef(null),T=f.useRef(null),[C,A]=f.useState(null),D=()=>{const W=b||[];if(!W.length)return 0;const ce=i.find(Q=>W.includes(Q.id));return ce?i.indexOf(ce):0};function H(W){T.current=W.navigate,A(()=>W.keydown),g&&W.navigate(D())}f.useEffect(()=>{g&&(M.current?.focus(),typeof window<"u"&&window.getSelection&&window.getSelection().removeAllRanges())},[]);function B({id:W}){k(W),w&&w({value:W})}function q(W){W.stopPropagation(),k([]),w&&w({value:[]})}function L(){T.current?.(D())}function F(){T.current?.(null)}function ue(W){C?.(W,D())}return l.jsxs("div",{ref:M,className:"wx-multiselect wx-aadNNOwy",onClick:L,onKeyDown:ue,tabIndex:0,children:[l.jsx("div",{className:"wx-label wx-aadNNOwy",children:h?h(j):p?l.jsx(p,{data:j,onAction:v}):d?l.jsx("span",{className:"wx-text wx-aadNNOwy",children:d}):j.length?l.jsx("span",{className:"wx-text wx-aadNNOwy",children:j.map(W=>W.label).join(", ")}):r?l.jsx("span",{className:"wx-placeholder wx-aadNNOwy",children:r}):" "}),c&&b?.length?l.jsx("i",{className:"wx-icon wxi-close wx-aadNNOwy",onClick:q}):l.jsx("i",{className:"wx-icon wxi-angle-down wx-aadNNOwy"}),l.jsx(jd,{items:i,onReady:H,onSelect:B,multiselect:!0,checkboxes:!0,value:b||[],onCancel:F,...x,children:({option:W})=>l.jsx("div",{className:"wx-option wx-aadNNOwy",children:h?h(W):p?l.jsx(p,{data:W,onAction:v}):W.label})})]})}function mj({filter:n,column:a,action:i,filterValue:r}){const c=f.useContext(kn.i18n)?.getGroup("grid")||gc(Th).getGroup("grid"),d=f.useMemo(()=>({clear:!0,...n?.config||{}}),[n]),h=f.useMemo(()=>d.options||a.options,[d,a]),p=f.useMemo(()=>{const w=r?.length;return w?w<3?r.map(v=>a.optionsMap.get(v)).join(", "):w+" "+c("selected"):""},[r,a,c]);function x({value:w}){i({value:w,key:a.id})}function g(w){w.key!=="Tab"&&w.preventDefault()}return l.jsx("div",{style:{width:"100%"},onKeyDown:g,children:l.jsx(Xy,{placeholder:"",...d,options:h,value:r||[],text:p,onChange:x})})}const hj={text:uj,richselect:dj,datepicker:fj,multiselect:mj};function pj({filter:n,column:a}){const i=f.useContext(La),r=Qe(i,"filterValues");function c(h){i.exec("filter-rows",h)}const d=f.useMemo(()=>hj[n.type],[n.type]);return l.jsx(d,{filter:n,column:a,action:c,filterValue:r[a.id]})}function gj(n){const{cell:a,column:i,row:r,lastRow:c,sortRow:d,columnStyle:h,bodyHeight:p,hasSplit:x}=n,g=f.useContext(La),w=Qe(g,"sortMarks"),v=f.useMemo(()=>w?w[i.id]:void 0,[w,i.id]),b=f.useRef(),k=f.useCallback(oe=>{b.current=a.flexgrow?oe.parentNode.clientWidth:a.width},[a.flexgrow,a.width]),j=f.useCallback((oe,K)=>{g.exec("resize-column",{id:a.id,width:Math.max(1,(b.current||0)+oe),inProgress:K})},[g,a.id]),M=f.useCallback(oe=>j(oe,!0),[j]),T=f.useCallback(oe=>j(oe,!1),[j]),C=f.useCallback(oe=>{if(!i.sort||a.filter)return;let K=v?.order;K&&(K=K==="asc"?"desc":"asc"),g.exec("sort-rows",{key:a.id,add:oe.ctrlKey||oe.metaKey,order:K})},[g,a.id,a.filter,i.sort,v?.order]),A=f.useCallback(oe=>{oe&&oe.stopPropagation(),g.exec("collapse-column",{id:a.id,row:r})},[g,a.id,r]),D=f.useCallback(oe=>{oe.key==="Enter"&&A()},[A]),H=f.useCallback(oe=>{oe.key==="Enter"&&!a.filter&&C(oe)},[C,a.filter]),B=f.useMemo(()=>a.collapsed&&i.collapsed,[a.collapsed,i.collapsed]),q=f.useMemo(()=>B&&!x&&a.collapsible!=="header",[B,x,a.collapsible]),L=f.useMemo(()=>q?{top:-p/2,position:"absolute"}:{},[q,p]),F=f.useMemo(()=>Md(a.width,a.flexgrow,i.fixed,i.left,a.right??i.right,a.height+(B&&q?p:0)),[a.width,a.flexgrow,i.fixed,i.left,a.right,i.right,a.height,B,q,p]),ue=f.useMemo(()=>Qy(i,a,h),[i,a,h]),W=f.useCallback(()=>Object.fromEntries(Object.entries(a).filter(([oe])=>oe!=="cell")),[a]),ce=`wx-cell ${ue} ${a.css||""} wx-collapsed`,Q=["wx-cell",ue,a.css||"",a.filter?"wx-filter":"",i.fixed&&i.fixed.right?"wx-fixed-right":""].filter(Boolean).join(" "),se=f.useRef(null);return f.useEffect(()=>{const oe=se.current;if(!oe)return;const K=wv(oe,{down:k,move:M,up:T});return()=>{typeof K=="function"&&K()}},[k,M,T,wv]),B?l.jsx("div",{className:"wx-RsQD74qC "+ce,style:F,role:"button","aria-label":`Expand column ${a.text||""}`,"aria-expanded":!a.collapsed,tabIndex:0,onKeyDown:D,onClick:A,"data-header-id":Cn(i.id),children:l.jsx("div",{className:"wx-RsQD74qC wx-text",style:L,children:a.text||""})}):l.jsxs("div",{className:"wx-RsQD74qC "+Q,style:F,onClick:C,"data-header-id":Cn(i.id),tabIndex:!a._hidden&&i.sort&&!a.filter?0:void 0,role:"columnheader","aria-colindex":i._colindex,"aria-colspan":a.colspan>1?a.colspan:void 0,"aria-rowspan":a.rowspan>1?a.rowspan:void 0,"aria-sort":!v?.order||a.filter?"none":v?.order==="asc"?"ascending":"descending",onKeyDown:H,children:[a.collapsible?l.jsx("div",{className:"wx-RsQD74qC wx-collapse",role:"button","aria-label":a.collapsed?"Expand column":"Collapse column","aria-expanded":!a.collapsed,tabIndex:0,onKeyDown:D,onClick:A,children:l.jsx("i",{className:`wx-RsQD74qC wxi-angle-${a.collapsed?"down":"right"}`})}):null,a.cell?(()=>{const oe=a.cell;return l.jsx(oe,{api:g,cell:W(),column:i,row:r,onAction:({action:K,data:z})=>g.exec(K,z)})})():a.filter?l.jsx(pj,{filter:a.filter,column:i}):l.jsx("div",{className:"wx-RsQD74qC wx-text",children:a.text||""}),i.resize&&c&&!a._hidden?l.jsx("div",{className:"wx-RsQD74qC wx-grip",role:"presentation","aria-label":"Resize column",ref:se,onClick:oe=>oe.stopPropagation(),children:l.jsx("div",{})}):null,d?l.jsx("div",{className:"wx-RsQD74qC wx-sort",children:v?l.jsxs(l.Fragment,{children:[typeof v.index<"u"?l.jsx("div",{className:"wx-RsQD74qC wx-order",children:v.index+1}):null,l.jsx("i",{className:`wx-RsQD74qC wxi-arrow-${v.order==="asc"?"up":"down"}`})]}):null}):null]})}function xj({cell:n,column:a,row:i,columnStyle:r}){const c=f.useContext(La),d=f.useMemo(()=>Md(n?.width,n?.flexgrow,a?.fixed,a?.left,n?.right??a?.right,n?.height),[n?.width,n?.flexgrow,a?.fixed,a?.left,n?.right,a?.right,n?.height]),h=f.useMemo(()=>Qy(a,n,r),[a,n,r]),p=f.useCallback(()=>Object.fromEntries(Object.entries(n||{}).filter(([g])=>g!=="cell")),[n]),x=`wx-6Sdi3Dfd wx-cell ${h||""} ${n?.css||""}`+(a?.fixed&&a?.fixed.right?" wx-fixed-right":"");return l.jsx("div",{className:x,style:d,children:!a?.collapsed&&!n?.collapsed?n?.cell?ph.createElement(n.cell,{api:c,cell:p(),column:a,row:i,onAction:({action:g,data:w})=>c.exec(g,w)}):l.jsx("div",{className:"wx-6Sdi3Dfd wx-text",children:n?.text||""}):null})}function bv({deltaLeft:n,contentWidth:a,columns:i,type:r="header",columnStyle:c,bodyHeight:d}){const h=f.useContext(La),p=Qe(h,"_sizes"),x=Qe(h,"split"),g=f.useMemo(()=>p?.[`${r}RowHeights`],[p,r]),w=f.useMemo(()=>{let M=[];if(i&&i.length){const T=i[0][r].length;for(let C=0;C<T;C++){let A=0;M.push([]),i.forEach((D,H)=>{const B={...D[r][C]};A||M[C].push(B),B.colspan>1?A=B.colspan-1:A&&A--})}}return M},[i,r]),v=f.useMemo(()=>x?.left||x?.right,[x]);function b(M){return i.find(T=>T.id===M)}function k(M,T){let C=T;return M.rowspan&&(C+=M.rowspan-1),C===w.length-1}function j(M,T,C){if(!C.sort)return!1;for(let A=w.length-1;A>=0;A--){const D=C.header[A];if(!D.filter&&!D._hidden)return T===A}return k(M,T)}return l.jsx("div",{className:`wx-sAsPVaUK wx-${r}`,style:{paddingLeft:`${n}px`,width:`${a}px`},role:"rowgroup",children:w.map((M,T)=>l.jsx("div",{className:r==="header"?"wx-sAsPVaUK wx-h-row":"wx-sAsPVaUK wx-f-row",style:{height:`${g?.[T]}px`,display:"flex"},role:"row",children:M.map(C=>{const A=b(C.id);return r==="header"?l.jsx(gj,{cell:C,columnStyle:c,column:A,row:T,lastRow:k(C,T),bodyHeight:d,sortRow:j(C,T,A),hasSplit:v},C.id):l.jsx(xj,{cell:C,columnStyle:c,column:b(C.id),row:T},C.id)})},T))})}function vj({overlay:n}){const a=f.useContext(La);function i(c){return typeof c=="function"}const r=n;return l.jsx("div",{className:"wx-1ty666CQ wx-overlay",children:i(n)?l.jsx(r,{onAction:({action:c,data:d})=>a.exec(c,d)}):n})}function yj(n){const{editor:a,onSave:i,onApply:r}=n,[c,d]=f.useState(a?.value||""),{type:h="text"}=f.useMemo(()=>a?.config||{},[a]),p=f.useRef(null);f.useEffect(()=>{p.current&&p.current.focus()},[]),f.useEffect(()=>{if(!p.current)return;const w=zs(p.current,()=>i(!0));return()=>w.destroy()},[i]);function x(){p.current&&(d(p.current.value),r(p.current.value))}function g({key:w}){w==="Enter"&&i()}return l.jsx("input",{className:"wx-e7Ao5ejY wx-text",onInput:x,onKeyDown:g,ref:p,type:h,value:c})}function wj({editor:n,onAction:a,onSave:i,onApply:r,onCancel:c}){const[d,h]=f.useState(n?.value),[p,x]=f.useState(n?.renderedValue),[g,w]=f.useState(n?.options||[]),v=f.useMemo(()=>n?.config?.template,[n]),b=f.useMemo(()=>n?.config?.cell,[n]),k=f.useMemo(()=>n?.config?.dropdown||{},[n]),j=f.useMemo(()=>({trackScroll:!0,...k}),[k]),M=f.useMemo(()=>(g||[]).findIndex(L=>L.id===d),[g,d]),T=f.useRef(null),C=f.useRef(null),A=f.useCallback(L=>{T.current=L.navigate,C.current=L.keydown,T.current(M)},[M,T]),D=f.useCallback(L=>{const F=L?.target?.value??"";x(F);const ue=F?(n?.options||[]).filter(W=>(W.label||"").toLowerCase().includes(F.toLowerCase())):n?.options||[];w(ue),ue.length?T.current(-1/0):T.current(null)},[n]),H=f.useRef(null);f.useEffect(()=>{H.current&&H.current.focus()},[]);const B=f.useRef(i);f.useEffect(()=>{B.current=i},[i]),f.useEffect(()=>{if(!H.current)return;const L=zs(H.current,()=>B.current(!0));return()=>L.destroy()},[]),f.useEffect(()=>{h(n?.value),x(n?.renderedValue),w(n?.options||[])},[n]);const q=f.useCallback(({id:L})=>{r(L),i()},[r,i]);return l.jsxs(l.Fragment,{children:[l.jsx("input",{className:"wx-0UYfSd1x wx-input",ref:H,value:p??"",onChange:D,onKeyDown:L=>C.current?C.current(L,M):void 0}),l.jsx(jd,{items:g,onReady:A,onSelect:q,...j,onCancel:c,children:({option:L})=>v?v(L):b?l.jsx(b,{data:L,onAction:a}):L.label})]})}function bj({editor:n,onAction:a,onSave:i,onApply:r,onCancel:c}){const[d]=f.useState(()=>n.value||new Date),{template:h,cell:p,dropdown:x={}}=n?.config||{},g=f.useMemo(()=>({trackScroll:!0,width:"auto",...x}),[x]);function w({value:j}){r(j),i()}const v=f.useRef(null),[b,k]=f.useState(null);return f.useEffect(()=>{v.current&&v.current.focus(),typeof window<"u"&&window.getSelection&&window.getSelection().removeAllRanges()},[]),f.useEffect(()=>{if(!b)return;const j=zs(b,()=>i(!0));return()=>j.destroy()},[b,i]),l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"wx-lNWNYUb6 wx-value",ref:v,tabIndex:0,onClick:c,onKeyDown:j=>j.preventDefault(),children:h?h(d):p?l.jsx(p,{data:n.value,onAction:a}):l.jsx("span",{className:"wx-lNWNYUb6 wx-text",children:n.renderedValue})}),l.jsx(kh,{...g,onCancel:c,children:l.jsx("div",{ref:k,className:"wx-lNWNYUb6",children:l.jsx(Ry,{value:d,onChange:w,buttons:n.config?.buttons})})})]})}function Sj(n){const{editor:a}=n,i=n.onAction??n.onaction,r=n.onSave??n.onsave,c=n.onApply??n.onapply,d=n.onCancel??n.oncancel,h=a.config||{},{dropdown:p={}}=h,x=f.useMemo(()=>({trackScroll:!0,...p}),[p]),[g]=f.useState(a.options.find(D=>D.id===a.value)),[w]=f.useState(a.value),[v]=f.useState(a.options),b=f.useMemo(()=>v.findIndex(D=>D.id===w),[v,w]);function k({id:D}){c(D),r()}let j;const[M,T]=f.useState();function C(D){j=D.navigate,T(()=>D.keydown),j(b)}const A=f.useRef(null);return f.useEffect(()=>{A.current&&A.current.focus(),typeof window<"u"&&window.getSelection&&window.getSelection().removeAllRanges()},[]),f.useEffect(()=>{if(!A.current)return;const D=zs(A.current,()=>r(!0));return()=>D.destroy()},[r]),l.jsxs(l.Fragment,{children:[l.jsx("div",{ref:A,className:"wx-ywGRk611 wx-value",tabIndex:0,onClick:d,onKeyDown:D=>{M(D,b),D.preventDefault()},children:h.template?h.template(g):h.cell?(()=>{const D=h.cell;return l.jsx(D,{data:g,onAction:i})})():l.jsx("span",{className:"wx-ywGRk611 wx-text",children:a.renderedValue})}),l.jsx(jd,{items:v,onReady:C,onSelect:k,...x,onCancel:d,children:({option:D})=>h.template?h.template(D):h.cell?(()=>{const H=h.cell;return l.jsx(H,{data:D,onAction:i})})():D.label})]})}function Cj(n){const{editor:a,onAction:i,onSave:r,onApply:c}=n,d=a?.config||{},h=a?.options??[],p=a?.value||[],x=a?.renderedValue,g=f.useMemo(()=>({trackScroll:!0,...d.dropdown||{}}),[d]);function w({value:b}){c(b)}const v=f.useRef(null);return f.useEffect(()=>{if(!v.current)return;const b=zs(v.current,()=>r(!0));return()=>b.destroy()},[r]),l.jsx("div",{ref:v,className:"wx-value wx-aacZ4gNU",onClick:()=>r(!0),children:l.jsx(Xy,{value:p,options:h,text:x,template:d.template,cell:d.cell,clear:d.clear,dropdown:g,autoOpen:!0,onChange:w,onAction:i})})}const jj={text:yj,combo:wj,datepicker:bj,richselect:Sj,multiselect:Cj};function kj({column:n,row:a}){const i=f.useContext(La),r=Qe(i,"editor"),c=f.useCallback((j,M)=>{i.exec("close-editor",{ignore:j}),M&&i.exec("focus-cell",{...M,eventSource:"click"})},[i]),d=f.useCallback(j=>{const M=j?null:{row:r?.id,column:r?.column};c(!1,M)},[r,c]),h=f.useCallback(()=>{c(!0,{row:r?.id,column:r?.column})},[r,c]),p=f.useCallback(j=>{i.exec("editor",{value:j})},[i]),x=f.useCallback(j=>{j.key==="Enter"&&r&&(n.editor.type==="multiselect"?p(r.value):h())},[r,n.editor,h,p]),g=f.useMemo(()=>Md(n.width,n.flexgrow,n.fixed,n.left,n.right),[n.width,n.flexgrow,n.fixed,n.left,n.right]),w=f.useMemo(()=>{let j=n.editor;if(typeof j=="function"&&(j=j(a,n)),!j)return null;let M=typeof j=="string"?j:j.type;return jj[M]},[n,a]),v=f.useRef(null);f.useEffect(()=>{v.current&&typeof g=="string"&&v.current.setAttribute("style",g)},[g]);const b=typeof a.$parent<"u"?"gridcell":"cell",k=typeof a.$parent<"u"?!n.editor:void 0;return l.jsx("div",{className:"wx-8l724t2g wx-cell wx-editor",ref:v,style:typeof g=="object"&&g!==null?g:void 0,role:b,"aria-readonly":k,tabIndex:-1,onClick:j=>j.stopPropagation(),onDoubleClick:j=>j.stopPropagation(),onKeyDown:x,children:w?l.jsx(w,{editor:r,onSave:d,onApply:p,onCancel:h,onAction:({action:j,data:M})=>i.exec(j,M)}):null})}function Sv(n){const{columns:a,type:i,columnStyle:r}=n,c=f.useContext(La),{filterValues:d,_columns:h,_sizes:p}=c.getState();function x(g){return r?" "+r(g):""}return l.jsx(l.Fragment,{children:a.map((g,w)=>l.jsx("tr",{children:g.map(v=>{const b=h.find(M=>M.id===v.id),k=`wx-print-cell-${i}${x(b)}${v.filter?" wx-print-cell-filter":""}${v.vertical?" wx-vertical":""}`,j=v.cell;return l.jsx("th",{style:Oy(Gy(v,p.columnWidth)),className:"wx-Gy81xq2u "+k,rowSpan:v.rowspan,colSpan:v.colspan,children:j?l.jsx(j,{api:c,cell:Object.fromEntries(Object.entries(v).filter(([M])=>M!=="cell")),column:b,row:w}):v.filter?l.jsx("div",{className:"wx-Gy81xq2u wx-print-filter",children:TC(d,h,v)}):l.jsx("div",{className:"wx-Gy81xq2u wx-text",children:v.text??""})},v.id)})},w))})}function Mj(n){const{columns:a,rowStyle:i,columnStyle:r,cellStyle:c,header:d,footer:h,reorder:p}=n,x=f.useContext(La),{flatData:g,_sizes:w}=x.getState(),v=d&&pv(a,"header",w.headerRowHeights),b=h&&pv(a,"footer",w.footerRowHeights);function k(M,T){let C="";return C+=r?" "+r(T):"",C+=c?" "+c(M,T):"",C}function j(M,T){return typeof T.draggable=="function"?T.draggable(M,T)!==!1:T.draggable}return l.jsxs("table",{className:`wx-8NTMLH0z wx-print-grid ${a.some(M=>M.flexgrow)?"wx-flex-columns":""}`,children:[d?l.jsx("thead",{children:l.jsx(Sv,{columns:v,type:"header",columnStyle:r})}):null,l.jsx("tbody",{children:g.map((M,T)=>l.jsx("tr",{className:"wx-8NTMLH0z wx-row"+(i?" "+i(M):""),style:{height:`${M.rowHeight||w.rowHeight}px`},children:a.map(C=>C.collapsed?null:l.jsxs("td",{className:`wx-8NTMLH0z wx-print-cell wx-cell ${k(M,C)}`,style:Oy(Gy(C,w.columnWidth)),children:[p&&C.draggable?l.jsx("span",{className:"wx-8NTMLH0z wx-print-draggable",children:j(M,C)?l.jsx("i",{className:"wx-8NTMLH0z wxi-drag"}):null}):null,C.treetoggle?l.jsxs(l.Fragment,{children:[l.jsx("span",{style:{marginLeft:M.$level*28+"px"}}),M.$count?l.jsx("i",{className:`wx-8NTMLH0z wx-print-grid-tree-toggle wxi-menu-${M.open!==!1?"down":"right"}`}):null]}):null,C.cell?(()=>{const A=C.cell;return l.jsx(A,{api:x,row:M,column:C})})():l.jsx("span",{children:ai(M,C)})]},C.id))},T))}),h?l.jsx("tfoot",{children:l.jsx(Sv,{columns:b,type:"footer",columnStyle:r})}):null]})}function Aj(n){const{config:a,...i}=n,r=f.useContext(La),{_skin:c,_columns:d}=r.getState(),h=f.useMemo(()=>kC(d,a),[]),p=f.useRef(null);return f.useEffect(()=>{const x=document.body;x.classList.add("wx-print");const g=p.current;if(!g)return;const w=g.cloneNode(!0);x.appendChild(w);const v=`@media print { @page { size: ${a.paper} ${a.mode}; }`,b=document.createElement("style");b.setAttribute("type","text/css"),b.setAttribute("media","print"),document.getElementsByTagName("head")[0].appendChild(b),b.appendChild(document.createTextNode(v)),window.print(),b.remove(),x.classList.remove("wx-print"),w.remove()},[]),l.jsx("div",{className:`wx-4zwCKA7C wx-${c}-theme wx-print-container`,ref:p,children:h.map((x,g)=>l.jsx("div",{className:"wx-4zwCKA7C wx-print-grid-wrapper",children:l.jsx(Mj,{columns:x,...i})},g))})}function Nj(n){const{header:a,footer:i,overlay:r,multiselect:c,onreorder:d,rowStyle:h,columnStyle:p,cellStyle:x,autoRowHeight:g,resize:w,clientWidth:v,clientHeight:b,responsiveLevel:k,hotkeys:j}=n,M=f.useContext(La),T=Qe(M,"dynamic"),C=Qe(M,"_columns"),A=Qe(M,"flatData"),D=Qe(M,"split"),H=Qe(M,"_sizes"),[B,q]=Xa(M,"selectedRows"),L=Qe(M,"select"),F=Qe(M,"editor"),ue=Qe(M,"scrollLeft"),W=Qe(M,"scrollTop"),ce=Qe(M,"tree"),Q=Qe(M,"focusCell"),se=Qe(M,"_print"),oe=Qe(M,"undo"),K=Qe(M,"reorder"),z=Qe(M,"_rowHeightFromData"),[Y,U]=f.useState(0);f.useEffect(()=>{U(Ia())},[]);const[R,J]=f.useState(0),he=f.useMemo(()=>(C||[]).some(X=>!X.hidden&&X.flexgrow),[C]),$=f.useMemo(()=>H?.rowHeight||0,[H]),ie=f.useRef(null),[we,me]=f.useState(null),[ze,Pe]=f.useState(null),de=f.useMemo(()=>{let X=[],Se=0;return D&&D.left&&(X=(C||[]).slice(0,D.left).filter(De=>!De.hidden).map(De=>({...De})),X.forEach(De=>{De.fixed={left:1,leftSize:D.left},De.left=Se,Se+=De.width}),X.length&&(X[X.length-1].fixed.left=-1)),{columns:X,width:Se}},[D,C]),He=f.useMemo(()=>{let X=[],Se=0;if(D&&D.right){X=(C||[]).slice(D.right*-1).filter(De=>!De.hidden).map(De=>({...De}));for(let De=X.length-1;De>=0;De--){const Ze=X[De];Ze.fixed={right:1},Ze.right=Se,Se+=Ze.width}X.length&&(X[0].fixed={right:-1})}return{columns:X,width:Se}},[D,C]),Le=f.useMemo(()=>{const X=(C||[]).slice(D?.left||0,(C||[]).length-(D?.right??0)).filter(Se=>!Se.hidden);return X.forEach(Se=>{Se.fixed=0}),X},[C,D]),Fe=f.useMemo(()=>(C||[]).reduce((X,Se)=>(Se.hidden||(X+=Se.width),X),0),[C]),qe=1;function ne(X,Se,De){let Ze=Se,Tt=X;if(Le.length){let ut=Le.length;for(let Ue=X;Ue>=0;Ue--)Le[Ue][De].forEach(at=>{at.colspan>1&&Ue>X-at.colspan&&Ue<ut&&(ut=Ue)});if(ut!==Le.length&&ut<X){for(let Ue=ut;Ue<X;Ue++)Ze-=Le[Ue].width;Tt=ut}}return{index:Tt,delta:Ze}}const ye=f.useMemo(()=>{let X,Se,De;const Ze=ue||0,Tt=(ue||0)+(v||0);let ut=0,Ue=0,at=0,Rt=0;Le.forEach((Vt,It)=>{Ze>at&&(ut=It,Rt=at),at=at+Vt.width,Tt>at&&(Ue=It+qe)});const _t={header:0,footer:0};for(let Vt=Ue;Vt>=ut;Vt--)["header","footer"].forEach(It=>{Le[Vt]&&Le[Vt][It].forEach(xl=>{const ss=xl.colspan;if(ss&&ss>1){const Cs=ss-(Ue-Vt+1);Cs>0&&(_t[It]=Math.max(_t[It],Cs))}})});const Yt=ne(ut,Rt,"header"),xt=ne(ut,Rt,"footer"),Ot=Yt.delta,vt=Yt.index,Wn=xt.delta,Qn=xt.index;return he&&Fe>(v||0)?X=Se=De=[...de.columns,...Le,...He.columns]:(X=[...de.columns,...Le.slice(ut,Ue+1),...He.columns],Se=[...de.columns,...Le.slice(vt,Ue+_t.header+1),...He.columns],De=[...de.columns,...Le.slice(Qn,Ue+_t.footer+1),...He.columns]),{data:X||[],header:Se||[],footer:De||[],d:Rt,df:Wn,dh:Ot}},[Le,de,He,ue,v,he,Fe]),be=f.useMemo(()=>a&&H?.headerHeight||0,[a,H]),Z=f.useMemo(()=>i&&H?.footerHeight||0,[i,H]),le=f.useMemo(()=>v&&b?Fe>=v:!1,[v,b,Fe]),[Me,je]=f.useState(!1),ct=f.useMemo(()=>(b||0)-be-Z-(le?Y:0),[b,be,Z,le,Y]),sn=f.useMemo(()=>Math.ceil((ct||0)/($||1))+1,[ct,$]),ke=f.useRef([]),[Ne,Oe]=f.useState(0),[Dt,Za]=f.useState(void 0),Nt=f.useMemo(()=>{let X=0,Se=0;const De=2,Ze=W||0;if(g){let Ue=Ze;for(;Ue>0;)Ue-=ke.current[X]||$,X++;Se=Ze-Ue;for(let at=Math.max(0,X-De-1);at<X;at++)Se-=ke.current[X-at]||$;X=Math.max(0,X-De)}else{if(z){let Ue=0,at=0;for(let xt=0;xt<(A||[]).length;xt++){const Ot=A[xt].rowHeight||$;if(at+Ot>Ze){Ue=xt;break}at+=Ot}X=Math.max(0,Ue-De);for(let xt=0;xt<X;xt++)Se+=A[xt].rowHeight||$;let Rt=0,_t=0;for(let xt=Ue+1;xt<(A||[]).length;xt++){const Ot=A[xt].rowHeight||$;if(Rt++,_t+Ot>ct)break;_t+=Ot}const Yt=Math.min(T?T.rowCount:(A||[]).length,Ue+Rt+De);return{d:Se,start:X,end:Yt}}X=Math.floor(Ze/($||1)),X=Math.max(0,X-De),Se=X*($||0)}const Tt=T?T.rowCount:(A||[]).length,ut=Math.min(Tt,X+(sn||0)+De);return{d:Se,start:X,end:ut}},[g,z,W,$,T,A,sn,ct]),Gn=f.useMemo(()=>{const X=T?T.rowCount:(A||[]).length;if(g)return Ne+Nt.d+(X-(Dt||0))*($||0);if(!z)return X*($||0);let Se=0;for(let De=0;De<X;De++)Se+=A[De]?.rowHeight||$;return Se},[T,A,$,g,z,Ne,Nt.d,Dt]),ii=f.useRef({});ii.current={clientWidth:v,clientHeight:b,fullHeight:Gn,headerHeight:be,footerHeight:Z,fullWidth:Fe,SCROLLSIZE:Y};const Te=f.useCallback(()=>{const X=ii.current;je(X.clientWidth&&X.clientHeight?X.fullHeight+X.headerHeight+X.footerHeight>=X.clientHeight-(X.fullWidth>=X.clientWidth?X.SCROLLSIZE:0):!1)},[]);f.useEffect(()=>{const X=requestAnimationFrame(Te);return()=>window.cancelAnimationFrame(X)},[R,Te]),f.useEffect(()=>{Te()},[b,Te]);const za=f.useMemo(()=>he&&Fe<=(v||0)?(v||0)-0-(Me?Y:0):Fe,[he,Fe,v,Me,Y,le]),Xe=f.useMemo(()=>he&&Fe<=(v||0)?v||0:za<(v||0)?Fe+(Me?Y:0):-1,[he,Fe,v,za,Me,Y]),_a=f.useRef({});f.useEffect(()=>{if(T&&(_a.current.start!==Nt.start||_a.current.end!==Nt.end)){const{start:X,end:Se}=Nt;_a.current={start:X,end:Se},M&&M.exec&&M.exec("request-data",{row:{start:X,end:Se}})}},[T,Nt,M]);const Je=f.useMemo(()=>T?A||[]:(A||[]).slice(Nt.start,Nt.end),[T,A,Nt]),yn=f.useMemo(()=>(B||[]).filter(X=>(Je||[]).some(Se=>Se.id===X)),[q,Je]),qt=f.useMemo(()=>Nt.start,[Nt.start]),_s=f.useRef({top:W,left:ue});_s.current={top:W,left:ue};const Gt=f.useCallback(X=>{const Se=X.target.scrollTop,De=X.target.scrollLeft,Ze=_s.current;(Se!==Ze.top||De!==Ze.left)&&M.exec("scroll-to",{top:Se,left:De})},[M]),pl=f.useCallback(X=>{X.shiftKey&&X.preventDefault(),ie.current&&ie.current.focus&&ie.current.focus()},[]),Oa=f.useCallback(()=>!!(C||[]).find(X=>!!X.draggable),[C]),Ja=f.useRef(null),ya=f.useRef(null),es=f.useRef({dblclick:(X,Se)=>{const De={id:X,column:mc(Se,"data-col-id")};M.exec("open-editor",De)},click:(X,Se)=>{if(Se.target.closest("input")||Ja.current)return;const De=mc(Se,"data-col-id");if(Q?.id!==X&&M.exec("focus-cell",{row:X,column:De,eventSource:"click"}),L===!1)return;const Ze=c&&(Se.ctrlKey||Se.metaKey),Tt=c&&Se.shiftKey;(Ze||B.length>1||!B.includes(X))&&M.exec("select-row",{id:X,toggle:Ze,range:Tt})},"toggle-row":X=>{const Se=M.getRow(X);M.exec(Se.open!==!1?"close-row":"open-row",{id:X})},"ignore-click":()=>!1}),ln=f.useMemo(()=>({top:be,bottom:Z,left:de.width,xScroll:le,yScroll:Me,sense:g&&ze?ze.offsetHeight:Math.max(H?.rowHeight||0,40),node:ie.current&&ie.current.firstElementChild}),[be,Z,de.width,le,Me,g,ze,H]);function Hn(X,Se){const{container:De,sourceNode:Ze,from:Tt}=Se;if(Oa()&&!Ze.getAttribute("draggable-data"))return!1;me(Tt),ce&&M.getRow(Tt).open&&M.exec("close-row",{id:Tt,nested:!0});const ut=$r(Ze),Ue=ut.cloneNode(!0);Ue.classList.remove("wx-selected"),Ue.querySelectorAll("[tabindex]").forEach(Yt=>Yt.setAttribute("tabindex","-1")),De.appendChild(Ue),Pe(Ue);const at=(ue||0)-ye.d,Rt=Me?Y:0;De.style.width=Math.min((v||0)-Rt,he&&Fe<=(v||0)?za:za-Rt)+at+"px";const _t=ad(ut);Se.offset={x:at,y:-Math.round(_t.height/2)},ya.current||(ya.current=X.clientY)}function Yn(X,Se){const{from:De}=Se,Ze=Se.pos,Tt=ad(ie.current);Ze.x=Tt.x;const ut=ln.top;if(Ze.y<ut)Ze.y=ut;else{const Ue=Tt.height-(le&&Y>0?Y:Math.round(ln.sense/2))-ln.bottom;Ze.y>Ue&&(Ze.y=Ue)}if(ie.current.contains(Se.targetNode)){const Ue=$r(Se.targetNode),at=Ue&&Sd(Ue);if(at&&at!==De){Se.to=at;const Rt=g?ze?.offsetHeight:H?.rowHeight;if(ze&&((W||0)===0||Ze.y>ut+Rt-1)){const _t=Ue.getBoundingClientRect(),Yt=ad(ze).y,xt=_t.y,Ot=Yt>xt?-1:1,vt=Ot===1?"after":"before",Wn=M.getState().flatData,Qn=Math.abs(Wn.findIndex(It=>It.id===De)-Wn.findIndex(It=>It.id===at)),Vt=Qn!==1?vt==="before"?"after":"before":vt;if(Qn===1&&(Ot===-1&&X.clientY>ya.current||Ot===1&&X.clientY<ya.current))return;ya.current=X.clientY,M.exec("move-item",{id:De,target:at,mode:Vt,inProgress:!0})}}d&&d({event:X,context:Se})}sj(X,Tt,Se,ln)}function gl(X,Se){const{from:De,to:Ze}=Se;M.exec("move-item",{id:De,target:Ze,inProgress:!1}),Ja.current=setTimeout(()=>{Ja.current=0},1),me(null),Pe(null),ya.current=null,Ky(Se)}function Ia(){const X=document.createElement("div");X.style.cssText="position:absolute;left:-1000px;width:100px;padding:0px;margin:0px;min-height:100px;overflow-y:scroll;",document.body.appendChild(X);const Se=X.offsetWidth-X.clientWidth;return document.body.removeChild(X),Se}const Ba=f.useMemo(()=>Xe>0?{width:`${Xe}px`}:void 0,[Xe]),Ss=f.useRef(null);function ts(){Promise.resolve().then(()=>{let X=0,Se=qt;const De=Ss.current;De&&(Array.from(De.children).forEach((Ze,Tt)=>{ke.current[qt+Tt]=Ze.offsetHeight,X+=Ze.offsetHeight,Se++}),Oe(X),Za(Se))})}f.useEffect(()=>{Je&&g&&ts()},[Je,g,qt]);let[Vn,wa]=f.useState();f.useEffect(()=>{if(Q&&(!L||!yn.length||yn.includes(Q.row)))wa({...Q});else if(Je.length&&ye.data.length){if(!Vn||yn.length&&!yn.includes(Vn.row)||Je.findIndex(X=>X.id===Vn.row)===-1||ye.data.findIndex(X=>X.id===Vn.column&&!X.collapsed)===-1){const X=yn[0]||Je[0].id,Se=ye.data.findIndex(De=>!De.collapsed);wa(Se!==-1?{row:X,column:ye.data[Se].id}:null)}}else wa(null)},[Q]);const Fa=f.useRef(null);f.useEffect(()=>{const X=ie.current;if(!X)return;const Se=JC(X,w);return()=>{typeof Se=="function"&&Se()}},[w]);const ns=f.useRef({});Object.assign(ns.current,{start:Hn,move:Yn,end:gl,getReorder:()=>K,getDraggableInfo:()=>({hasDraggable:Oa()})}),f.useEffect(()=>{const X=ie.current;return X?tj(X,ns).destroy:void 0},[K,ie.current]),f.useEffect(()=>{const X=ie.current;return X?XC(X,{keys:j!==!1&&{...QC,"ctrl+z":oe,"ctrl+y":oe,...j},exec:Se=>M.exec("hotkey",Se)}).destroy:void 0},[M,oe,j]);const as=f.useRef({scroll:M.getReactiveState().scroll,scrollLeft:M.getReactiveState().scrollLeft,scrollTop:M.getReactiveState().scrollTop});as.current.getWidth=()=>(v||0)-(Me?Y:0),as.current.getHeight=()=>ct,as.current.getScrollMargin=()=>de.width+He.width,f.useEffect(()=>{ZC(Fa.current,as.current)},[]);const Os=f.useRef(null);f.useEffect(()=>{const X=Os.current;if(!X)return;const Se=[];Se.push(zs(X,()=>Q&&M.exec("focus-cell",{eventSource:"click"})).destroy),Se.push(tC(X,es.current)),J(X.clientHeight);const De=new ResizeObserver(()=>{J(X.clientHeight)});return De.observe(X),Se.push(()=>De.disconnect()),()=>Se.forEach(Ze=>Ze())},[]);const Kn=`wx-grid ${k?`wx-responsive-${k}`:""}`;return f.useEffect(()=>{Q&&(Je.some(X=>X.id===Q.row)&&ye.data.some(X=>X.id===Q.column&&!X.collapsed)||M.exec("focus-cell",{eventSource:"destroy"}))},[Q,Je,ye.data,M]),l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"wx-4VuBwK2D "+Kn,style:{"--header-height":`${be}px`,"--footer-height":`${Z}px`,"--split-left-width":`${de.width}px`,"--split-right-width":`${He.width}px`},children:l.jsx("div",{ref:ie,className:"wx-4VuBwK2D wx-table-box",style:Ba,role:ce?"treegrid":"grid","aria-colcount":ye.data.length,"aria-rowcount":Je.length,"aria-multiselectable":ce&&c?!0:void 0,tabIndex:-1,children:l.jsxs("div",{ref:Fa,className:"wx-4VuBwK2D wx-scroll",style:{overflowX:le?"scroll":"hidden",overflowY:Me?"scroll":"hidden"},onScroll:Gt,children:[a?l.jsx("div",{className:"wx-4VuBwK2D wx-header-wrapper",children:l.jsx(bv,{contentWidth:za,deltaLeft:ye.dh,columns:ye.header,columnStyle:p,bodyHeight:ct-+i})}):null,l.jsxs("div",{ref:Os,className:"wx-4VuBwK2D wx-body",style:{width:`${za}px`,height:`${Gn}px`},onMouseDown:X=>pl(X),children:[r?l.jsx(vj,{overlay:r}):null,l.jsx("div",{ref:Ss,className:"wx-4VuBwK2D wx-data",style:{paddingTop:`${Nt.d}px`,paddingLeft:`${ye.d}px`},children:Je.map((X,Se)=>{const De=B.indexOf(X.id)!==-1,Ze=we===X.id,Tt="wx-row"+(g?" wx-autoheight":"")+(h?" "+h(X):"")+(De?" wx-selected":"")+(Ze?" wx-inactive":""),ut=g?{minHeight:`${X.rowHeight||$}px`}:{height:`${X.rowHeight||$}px`};return l.jsx("div",{className:"wx-4VuBwK2D "+Tt,"data-id":Cn(X.id),"data-context-id":Cn(X.id),style:ut,role:"row","aria-rowindex":Se,"aria-expanded":X.open,"aria-level":ce?X.$level+1:void 0,"aria-selected":ce?De:void 0,tabIndex:-1,children:ye.data.map(Ue=>Ue.collapsed?l.jsx("div",{className:"wx-4VuBwK2D wx-cell wx-collapsed"},Ue.id):F?.id===X.id&&F.column===Ue.id?l.jsx(kj,{row:X,column:Ue},Ue.id):l.jsx(cj,{row:X,column:Ue,columnStyle:p,cellStyle:x,reorder:K,focusable:Vn?.row===X.id&&Vn?.column===Ue.id},Ue.id))},X.id)})})]}),i&&(A||[]).length?l.jsx(bv,{type:"footer",contentWidth:za,deltaLeft:ye.df,columns:ye.footer,columnStyle:p}):null]})})}),se?l.jsx(Aj,{config:se,rowStyle:h,columnStyle:p,cellStyle:x,header:a,footer:i,reorder:K}):null]})}const Tj=n=>n.split("-").map(a=>a?a.charAt(0).toUpperCase()+a.slice(1):"").join(""),Rj=f.forwardRef(function({data:n=[],columns:a=[],rowStyle:i=null,columnStyle:r=null,cellStyle:c=null,selectedRows:d,select:h=!0,multiselect:p=!1,header:x=!0,footer:g=!1,dynamic:w=null,overlay:v=null,reorder:b=!1,onReorder:k=null,autoRowHeight:j=!1,sizes:M,split:T,tree:C=!1,autoConfig:A=!1,init:D=null,responsive:H=null,sortMarks:B,undo:q=!1,hotkeys:L=null,filterValues:F,...ue},W){const ce=f.useRef();ce.current=ue;const Q=f.useMemo(()=>new qC(Iy),[]),se=f.useMemo(()=>Q.in,[Q]),oe=f.useRef(null);oe.current===null&&(oe.current=new Ey((He,Le)=>{const Fe="on"+Tj(He);ce.current&&ce.current[Fe]&&ce.current[Fe](Le)}),se.setNext(oe.current));const K=f.useMemo(()=>({getState:Q.getState.bind(Q),getReactiveState:Q.getReactive.bind(Q),getStores:()=>({data:Q}),exec:se.exec,setNext:He=>(oe.current=oe.current.setNext(He),oe.current),intercept:se.intercept.bind(se),on:se.on.bind(se),detach:se.detach.bind(se),getRow:Q.getRow.bind(Q),getColumn:Q.getColumn.bind(Q)}),[Q,se]),[z,Y]=f.useState(0),[U,R]=f.useState(0),[J,he]=f.useState(null),[$,ie]=f.useState(null),we=f.useMemo(()=>{if(A&&!a.length&&n.length){const He=n[0],Le=[];for(let Fe in He)if(Fe!=="id"&&Fe[0]!=="$"){let qe={id:Fe,header:Fe[0].toUpperCase()+Fe.slice(1)};typeof A=="object"&&(qe={...qe,...A}),Le.push(qe)}return Le}return($&&$.columns)??a},[A,a,n,$]),me=f.useMemo(()=>($&&$.sizes)??M,[$,M]),ze=f.useCallback(He=>{if(Y(He.width),R(He.height),H){const Le=Object.keys(H).map(Number).sort((Fe,qe)=>Fe-qe).find(Fe=>He.width<=Fe)??null;Le!==J&&(ie(H[Le]),he(Le))}},[H,J]),Pe=f.useContext(kn.theme),de=f.useRef(0);return f.useEffect(()=>{if(!de.current)D&&D(K);else{const He=Q.getState();Q.init({data:n,columns:we,split:T||He.split,sizes:me||He.sizes,selectedRows:d||He.selectedRows,dynamic:w,tree:C,sortMarks:B||He.sortMarks,filterValues:F||He.filterValues,undo:q,reorder:b,_skin:Pe,_select:h})}de.current++},[Q,n,we,T,me,d,w,C,B,F,q,b,Pe,h,D,K]),de.current===0&&Q.init({data:n,columns:we,split:T||{left:0},sizes:me||{},selectedRows:d||[],dynamic:w,tree:C,sortMarks:B||{},filterValues:F||{},undo:q,reorder:b,_skin:Pe,select:h}),f.useImperativeHandle(W,()=>({...K}),[K]),l.jsx(La.Provider,{value:K,children:l.jsx(Nh,{words:Th,optional:!0,children:l.jsx(Nj,{header:x,footer:g,overlay:v,rowStyle:i,columnStyle:r,cellStyle:c,onReorder:k,multiselect:p,autoRowHeight:j,clientWidth:z,clientHeight:U,responsiveLevel:J,resize:ze,hotkeys:L})})})});bh(va);const jn=f.createContext(null),Dh=f.createContext(null),Lh=f.createContext(null);function Ej({children:n}){const a=f.useContext(kn.i18n),i=f.useMemo(()=>a.getGroup("filemanager"),[a]),r=f.useContext(jn),[c]=Xa(r,"panels"),d=Qe(r,"activePanel"),h=c[d].path,[p,x]=f.useState(null),[g,w]=f.useState(null),[v,b]=f.useState(""),[k,j]=f.useState(""),[M,T]=f.useState(!1);function C(){const B=v.trim();if(!B){T(!0);return}p.add?r.exec("create-file",{file:{...p.item,name:B},parent:h}):k!==B&&r.exec("rename-file",{id:p.item.id,name:B}),A()}function A(){x(null),T(null),j(""),b("")}function D(){r.exec("delete-files",{ids:g.selected}),w(null)}const H=f.useMemo(()=>({showPrompt(B){const q=B.item.name||(B.item.type==="folder"?i("New folder"):`${i("New file")}.txt`);j(q),b(q),x({...B})},showConfirm(B){w({...B})}}),[i]);return l.jsxs(Dh.Provider,{value:H,children:[l.jsx(E1,{children:n}),p?l.jsx(nh,{title:i(`Enter ${p.item.type} name`),onConfirm:C,onCancel:A,children:l.jsx(Mh,{error:M,select:!0,focus:!0,value:v,onChange:({value:B})=>b(B)})}):null,g?l.jsx(nh,{title:i("Are you sure you want to delete these items:"),onConfirm:D,onCancel:()=>w(null),children:g.selected?l.jsx("ul",{className:"wx-gq7BMzEP wx-list",children:g.selected.map((B,q)=>l.jsx("li",{children:B},q))}):null}):null]})}let Cv={"7z":!0,rar:!0,zip:!0,css:!0,html:!0,js:!0,php:!0,md:!0,xml:!0,sql:!0,aif:!0,mid:!0,mp3:!0,waw:!0,wma:!0,doc:!0,docx:!0,txt:!0,avi:!0,mov:!0,mp4:!0,mpeg:!0,mpg:!0,pdf:!0,xls:!0,xlsx:!0,gif:!0,jpg:!0,jpeg:!0,png:!0,psd:!0,tiff:!0,svg:!0,folder:!0,file:!0,multiple:!0,search:!0,none:!0};function Dj(n){const a=n.lastIndexOf("."),i=a>0&&a<n.length-1?Math.min(10,n.length-a):Math.min(5,n.length),r=n.slice(0,-i),c=n.slice(-i);return[r,c]}function Lj({item:n}){const a=f.useContext(jn),i=f.useContext(kn.i18n).getGroup("filemanager"),r=f.useContext(jn).templates,[c]=Xa(a,"panels"),d=Qe(a,"activePanel"),h=Qe(a,"mode"),p=c[d].selected,x=f.useMemo(()=>r.preview(n,214,163),[r,n]),g=f.useMemo(()=>r.icon(n,"big"),[r,n]),[w,v]=f.useMemo(()=>Dj(n.name),[n.name]);return l.jsx(l.Fragment,{children:n.id==="/wx-filemanager-parent-link"?h!=="search"?l.jsx("div",{className:"wx-GAOa4kDV wx-back-item",children:l.jsxs("div",{className:`wx-GAOa4kDV wx-back ${n.navigation?"wx-selected":""}`,"data-id":Cn("/wx-filemanager-parent-link"),children:[l.jsx("i",{className:"wx-GAOa4kDV wxi-arrow-left"}),l.jsx("span",{children:i("Back to parent folder")})]})}):null:l.jsxs("div",{className:`wx-GAOa4kDV wx-item ${p?.length&&p.indexOf(n.id)>=0?"wx-selected":""}`,"data-id":Cn(n.id),children:[x?l.jsx("div",{className:"wx-GAOa4kDV wx-preview wx-file-preview",children:l.jsx("img",{className:"wx-GAOa4kDV wx-card-preview",alt:i("A miniature file preview"),src:x})}):g?l.jsx("div",{className:"wx-GAOa4kDV wx-preview wx-file-icon",children:l.jsx("img",{className:"wx-GAOa4kDV wx-card-preview",alt:"",src:g})}):l.jsx("div",{className:"wx-GAOa4kDV wx-preview",children:l.jsx("i",{className:`wx-GAOa4kDV wxi-${n.type}`})}),n.type==="folder"?l.jsxs("div",{className:"wx-GAOa4kDV wx-info",children:[l.jsxs("div",{className:"wx-GAOa4kDV wx-folder-name",children:[l.jsx("span",{className:"wx-GAOa4kDV wx-type",children:i("Folder")}),l.jsxs("span",{className:"wx-GAOa4kDV wx-name",children:[l.jsx("span",{children:w}),l.jsx("span",{children:v})]})]}),l.jsx("div",{"data-action-id":Cn(n.id),className:"wx-GAOa4kDV wx-more",children:l.jsx("i",{className:"wx-GAOa4kDV wxi-dots-v"})})]}):l.jsxs("div",{className:"wx-GAOa4kDV wx-info",children:[l.jsx("div",{className:"wx-GAOa4kDV wx-file-name",children:l.jsxs("span",{className:"wx-GAOa4kDV wx-name",children:[l.jsx("span",{children:w}),l.jsx("span",{children:v})]})}),l.jsx("div",{"data-action-id":Cn(n.id),className:"wx-GAOa4kDV wx-more",children:l.jsx("i",{className:"wx-GAOa4kDV wxi-dots-v"})})]})]})})}function Zy(){const n=f.useContext(jn),a=f.useContext(kn.i18n),i=f.useMemo(()=>a.getGroup("filemanager"),[a]),[r]=Xa(n,"panels"),c=Qe(n,"activePanel"),d=Qe(n,"mode"),h=r[c]._files,p=r[c].selected,x=r[c].path,g=r[c]._crumbs,w=r[c]._selectNavigation,v=f.useCallback((A,D)=>{const H=D&&(D.ctrlKey||D.metaKey),B=D&&D.shiftKey;if(A==="/wx-filemanager-parent-link"){if(p.length&&(H||B))return;n.exec("select-file",{type:"navigation"});return}let q=A==="body"&&D?null:A;const L=D.target.className.indexOf("wx-more")!==-1||D.target.className.indexOf("wxi-dots-v")!==-1;setTimeout(()=>{n.exec("select-file",{id:q,toggle:H&&!L,range:B&&!L,panel:c})},1)},[n,p,c]),b=f.useCallback(()=>{g.length>1&&n.exec("set-path",{id:g[g.length-2].id,panel:c,selected:[g[g.length-1].id]})},[n,g,c]),k=f.useCallback(A=>{if(A==="/wx-filemanager-parent-link")return b();d==="search"&&n.exec("filter-files",{text:""});const D=h.find(H=>H.id===A);D&&(D.type=="folder"?n.exec("set-path",{id:D.id,panel:c}):n.exec("open-file",{id:D.id}))},[n,b,d,h,c]),j=f.useCallback((A,D)=>{(!p?.length||!p.filter(H=>H?.id===A).length>0)&&v(A,D)},[p,v]),M=f.useMemo(()=>x!=="/"?[{id:"/wx-filemanager-parent-link",name:i("Back to parent folder"),navigation:w},...h]:h,[x,i,w,h]),T=f.useRef(null),C=f.useRef();return f.useEffect(()=>{T.current&&(C.current?(C.current.click=v,C.current._dblclick=k,C.current.context=j):(C.current={click:v,dblclick:A=>C.current._dblclick(A),_dblclick:k,context:j},Ur(T.current,C.current)))},[v,k,j]),d=="search"&&!M.length?l.jsx("div",{className:"wx-iyjASZCY wx-not-found",children:l.jsx("div",{className:"wx-iyjASZCY wx-not-found-text",children:i("Looks like nothing is here")})}):l.jsx("div",{tabIndex:0,className:"wx-iyjASZCY "+("wx-cards"+(x!=="/"&&d!=="search"?" wx-has-back-link":"")),"data-id":Cn("body"),ref:T,children:M.map(A=>l.jsx(Lj,{item:A},A.id))})}function Wi({name:n="",spin:a=!1,onClick:i}){return l.jsx("i",{"data-menu-ignore":"true",className:`wx-uwcvNSAG wx-icon wxi-${n} ${a?"wx-spin":""} ${i?"wx-clickable":""}`,onClick:()=>{i&&i()}})}function zj(){const n=f.useContext(kn.i18n).getGroup("filemanager"),a=f.useContext(jn),i=Qe(a,"activePanel"),[r]=Xa(a,"panels"),c=f.useMemo(()=>r[i]._crumbs,[r,i]);function d(){a.exec("filter-files",{text:""})}return l.jsxs("div",{className:"wx-GDJvtROw wx-search",children:[l.jsxs("div",{className:"wx-GDJvtROw wx-toolbar",children:[l.jsx("div",{className:"wx-GDJvtROw wx-back-icon",children:l.jsx(Wi,{name:"angle-left",onClick:d})}),l.jsxs("div",{className:"wx-GDJvtROw wx-text",children:[n("Search results in")," ",Array.isArray(c)&&c.map((h,p)=>l.jsxs(f.Fragment,{children:[p?"/":null,h.id=="/"?n(h.name):h.name]},p))]})]}),l.jsx(Zy,{})]})}function Tm({narrowMode:n,extraInfo:a}){const i=f.useContext(jn),{preview:r,icon:c}=i.templates,d=f.useContext(kn.i18n),h=f.useMemo(()=>d.getGroup("filemanager"),[d]),p=f.useMemo(()=>Ir("%D, %d %F %Y, %H:%i",d.getRaw().calendar),[d]),[x,g]=Xa(i,"panels"),w=Qe(i,"activePanel"),v=Qe(i,"preview"),b=Qe(i,"search"),k=f.useMemo(()=>{const L=x&&w!=null&&x[w]?._selected?.length||0;return b&&!L},[b,g,w]),j=f.useMemo(()=>{const L=x&&w!=null?x[w]:null;return L?k?L._files:L._selected:[]},[k,g,w]),M=f.useCallback((L,F)=>(L?`${L} ${h(L>1?"folders":"folder")} `:"")+(F?`${F} ${h(F>1?"files":"file")}`:""),[h]),T=f.useCallback(()=>{i.exec("show-preview",{mode:!v})},[i,v]),C=f.useCallback(L=>L.type==="folder"?h("Folder"):L.ext||h("Unknown file"),[h]),A=f.useMemo(()=>{let L,F,ue,W,ce,Q,se,oe;if(j.length===1&&!k){F=j[0],L=F.name;const K=r(F,400,500);K?(ue=K,W=""):(W=c(F,"big"),ue=""),ce=F.type!=="folder"}else{if(F=ce=null,L="",j.length){let K=0,z=0,Y=0,U=[],R;j.forEach(he=>{typeof he.size>"u"&&(R=!0,K=void 0),R||(K+=he.size),U.push(C(he)),he.type==="folder"?z++:Y++});const J=new Set(U);Q=J.size>1?h("multiple"):[...J][0],se=M(z,Y),oe=K,k||(L=h("Multiple files"))}W=c({type:k?"search":j.length?"multiple":"none"},"big"),ue=""}return{name:L,item:F,previewSrc:ue,iconSrc:W,showDownloadIcon:ce,type:Q,totalCount:se,totalSize:oe}},[j,k,r,c,h,C,M]),D=f.useCallback(()=>{i.exec("download-file",{id:j[0].id})},[i,j]),H=f.useCallback(async L=>{if(!a||!L)return null;try{return await a(L)}catch(F){return console.log(F),null}},[a]),[B,q]=f.useState(null);return f.useEffect(()=>{let L=!1;return q(null),Promise.resolve(H(A.item)).then(F=>{L||q(F)}).catch(()=>{L||q(null)}),()=>{L=!0}},[H,A.item]),l.jsx("div",{className:"wx-O0BTtRrH wx-wrapper",children:j&&j.length?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"wx-O0BTtRrH wx-preview",children:[l.jsxs("div",{className:"wx-O0BTtRrH wx-toolbar",children:[l.jsx("div",{className:"wx-O0BTtRrH wx-name",children:A.name}),l.jsxs("div",{className:"wx-O0BTtRrH wx-icons",children:[A.showDownloadIcon?l.jsx(Wi,{name:"download",onClick:D}):null,n?l.jsx(Wi,{name:"close",onClick:T}):null]})]}),A.previewSrc?l.jsx("div",{className:"wx-O0BTtRrH wx-img-wrapper",children:l.jsx("img",{src:A.previewSrc,alt:h("A miniature file preview")})}):A.iconSrc?l.jsx("div",{className:"wx-O0BTtRrH wx-icon-wrapper",children:l.jsx("img",{src:A.iconSrc,alt:h("A miniature file preview")})}):l.jsx("div",{className:"wx-O0BTtRrH wx-icon-wrapper",children:A.item?l.jsx("i",{className:`wx-O0BTtRrH wx-icon wxi-${A.item.type}`}):l.jsx("i",{className:`wx-O0BTtRrH wx-icon wxi-${k?"search":"file-multiple-outline"}`})})]}),l.jsxs("div",{className:"wx-O0BTtRrH wx-info-panel",children:[l.jsx("div",{className:"wx-O0BTtRrH wx-title",children:h(k?"Found":"Information")}),l.jsxs("div",{className:"wx-O0BTtRrH wx-list",children:[A.item?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"wx-O0BTtRrH wx-name",children:h("Type")}),l.jsx("span",{className:"wx-O0BTtRrH wx-value",children:C(A.item)}),typeof A.item.size<"u"?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"wx-O0BTtRrH wx-name",children:h("Size")}),l.jsx("span",{className:"wx-O0BTtRrH wx-value",children:hc(A.item.size)})]}):null,l.jsx("span",{className:"wx-O0BTtRrH wx-name",children:h("Date")}),l.jsxs("span",{className:"wx-O0BTtRrH wx-value",children:[p(A.item.date)," "]})]}):l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"wx-O0BTtRrH wx-name",children:h("Count")}),l.jsx("span",{className:"wx-O0BTtRrH wx-value",children:A.totalCount}),l.jsx("span",{className:"wx-O0BTtRrH wx-name",children:h("Type")}),l.jsx("span",{className:"wx-O0BTtRrH wx-value",children:A.type}),typeof A.totalSize<"u"?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"wx-O0BTtRrH wx-name",children:h("Size")}),l.jsx("span",{className:"wx-O0BTtRrH wx-value",children:hc(A.totalSize)})]}):null]}),B?Object.entries(B).map(([L,F])=>l.jsxs(ph.Fragment,{children:[l.jsx("span",{className:"wx-O0BTtRrH wx-name",children:L}),l.jsx("span",{className:"wx-O0BTtRrH wx-value",children:F})]},L)):null]})]})]}):l.jsxs("div",{className:"wx-O0BTtRrH wx-no-info-panel",children:[l.jsxs("div",{className:"wx-O0BTtRrH wx-toolbar",children:[l.jsx("div",{className:"wx-O0BTtRrH wx-name",children:A.name}),l.jsx("div",{className:"wx-O0BTtRrH wx-icons",children:n?l.jsx(Wi,{name:"close",onClick:T}):null})]}),l.jsx("div",{className:"wx-O0BTtRrH wx-no-info-wrapper",children:l.jsxs("div",{className:"wx-O0BTtRrH wx-no-info",children:[A.previewSrc?l.jsx("div",{className:"wx-O0BTtRrH wx-img-wrapper",children:l.jsx("img",{src:A.previewSrc,alt:h("A miniature file preview")})}):A.iconSrc?l.jsx("div",{className:"wx-O0BTtRrH wx-icon-wrapper",children:l.jsx("img",{src:A.iconSrc,alt:h("A miniature file preview")})}):l.jsx("div",{className:"wx-O0BTtRrH wx-icon-wrapper",children:l.jsx("i",{className:`wx-O0BTtRrH wx-icon wxi-${k?"search":"message-question-outline"}`})}),l.jsx("span",{className:"wx-O0BTtRrH wx-text",children:k?"":h("Select file or folder to view details")})]})})]})})}function Jy({panel:n}){const a=f.useContext(jn),i=f.useContext(kn.i18n),r=f.useMemo(()=>i.getGroup("filemanager"),[i]),[c,d]=Xa(a,"panels"),h=f.useMemo(()=>c[n]._files,[d,n]),p=f.useMemo(()=>c[n]._crumbs||[],[d,n]);function x(j){const M=Rh(j,p);a.exec("set-path",{id:j,panel:n,...M&&{selected:[M]}})}const[g,w]=f.useState(null);f.useEffect(()=>{h&&w(null)},[h]);function v(){w(!0),a.exec("request-data",{id:p[p.length-1].id}),setTimeout(()=>{w(null)},5e3)}const b=f.useRef(null),k=f.useRef();return f.useEffect(()=>{k.current?k.current.click=x:(k.current={click:x},Ur(b.current,k.current))},[x]),l.jsxs("div",{className:"wx-SNY5LTYx wx-breadcrumbs","data-menu-ignore":"true",ref:b,children:[l.jsx("div",{className:"wx-SNY5LTYx wx-refresh-icon",children:l.jsx(Wi,{name:"refresh",spin:!!g,onClick:v})}),p.map((j,M)=>l.jsxs(ph.Fragment,{children:[M?l.jsx(Wi,{name:"angle-right"}):null,l.jsx("div",{className:"wx-SNY5LTYx wx-item","data-id":Cn(j.id),"data-menu-ignore":"true",children:j.id=="/"?r(j.name):j.name})]},M))]})}function _j({row:n}){const a=f.useContext(kn.i18n),[i]=f.useState(()=>a.getGroup("filemanager")),r=f.useContext(jn).templates,[c]=f.useState(()=>r.icon(n,"small"));return l.jsx("div",{className:"wx-qgAqG6sL wx-name-cell",children:n.id==="/wx-filemanager-parent-link"?l.jsxs(l.Fragment,{children:[l.jsx("i",{className:"wx-qgAqG6sL wxi-arrow-left"}),l.jsxs("span",{className:"wx-qgAqG6sL wx-name",children:[" ",i("Back to parent folder")]})]}):l.jsxs(l.Fragment,{children:[c?l.jsx("img",{className:"wx-qgAqG6sL wx-icon",alt:"",src:c,height:"24px",width:"24px"}):l.jsx("i",{className:`wx-qgAqG6sL wxi-${n.type}`}),l.jsxs("span",{className:"wx-qgAqG6sL wx-name",children:[" ",n.name," "]})]})})}function ew({children:n}){const a=f.useContext(jn),i=Qe(a,"activePanel"),r=f.useContext(Lh),c=f.useRef(null);let d=f.useRef({});return d.current.drop=()=>{const h=c.current,p=B0(h,"data-panel");p&&p!=i&&a.exec("set-active-panel",{panel:p*1})},d.current.dragEnter=()=>{const h=c.current;h&&h.classList.toggle("wx-active")},d.current.dragLeave=()=>{const h=c.current;h&&h.classList.toggle("wx-active")},f.useEffect(()=>{const h=c.current;return r.droparea(h,d.current)},[]),l.jsx("div",{className:"wx-LT9X7tb7 wx-upload-area",ref:c,children:n})}function lh({panel:n,active:a=!1,onClick:i,onContextMenu:r}){const c=f.useContext(jn),d=f.useContext(kn.i18n),h=f.useMemo(()=>d.getGroup("filemanager"),[d]),p=f.useMemo(()=>Ir("%d %M %Y",d.getRaw().calendar),[d]),[x]=Xa(c,"panels"),g=x[n].selected,w=x[n].path,v=x[n]._crumbs,b=x[n]._sorts,k=x[n]._selectNavigation,j=x[n]._files,M=f.useMemo(()=>[{id:"name",header:h("Name"),flexgrow:3,sort:!0,resize:!0,cell:_j},{id:"size",header:h("Size"),width:100,sort:!0,resize:!0,template:Q=>typeof Q=="number"?hc(Q):""},{id:"date",header:h("Date"),width:120,sort:!0,resize:!0,template:Q=>Q?p(Q):""}],[h,p]),T=f.useRef(null),C=f.useRef(null),A=f.useMemo(()=>k?["/wx-filemanager-parent-link"]:[...g],[k,g]);function D(Q,se){if(se&&se.target&&se.target.className&&se.target.className.indexOf("wx-grip")!==-1)return;const oe=se&&(se.ctrlKey||se.metaKey),K=se&&se.shiftKey;if(Q==="/wx-filemanager-parent-link"){if(g.length&&(oe||K))return;c.exec("select-file",{type:"navigation"});return}let z=Q==="body"&&se?null:Q;!T.current&&!C.current?c.exec("select-file",{id:z,toggle:oe,range:K,panel:n}):(T.current=null,C.current=null)}function H(){v.length>1&&c.exec("set-path",{id:v[v.length-2].id,panel:n,selected:[v[v.length-1].id]})}function B(Q){if(Q==="/wx-filemanager-parent-link")return H();const se=j.find(oe=>oe.id===Q);se&&(se.type==="folder"?c.exec("set-path",{id:se.id,panel:n}):c.exec("open-file",{id:se.id}))}function q(Q){const se=Q.key,oe=b[w];let K=oe?"asc":"desc";oe&&oe.key===se&&(K=oe.order==="asc"?"desc":"asc"),c.exec("sort-files",{key:se,order:K,panel:n,path:w})}function L(Q){Q.intercept("sort-rows",se=>(T.current=!0,q(se),!1)),Q.intercept("select-row",()=>!1),Q.on("resize-column",()=>C.current=!0),Q.intercept("hotkey",()=>!1)}const F=f.useMemo(()=>w!=="/"?[{id:"/wx-filemanager-parent-link",name:h("Back to parent folder")},...j]:j,[w,j,h]),ue=f.useMemo(()=>{if(F&&b&&b[w]){const{key:Q,order:se}=b[w];return{[Q]:{order:se}}}},[F,b,w]),W=f.useRef(null),ce=f.useRef();return f.useEffect(()=>{ce.current?(ce.current.click=D,ce.current._dblclick=B):(ce.current={click:D,dblclick:Q=>ce.current._dblclick(Q),_dblclick:B},Ur(W.current,ce.current))},[D,B]),l.jsxs("div",{onClick:i,onContextMenu:r,className:"wx-SSaVhET7 wx-wrapper",children:[l.jsx(Jy,{panel:n}),l.jsx("div",{"data-id":Cn("body"),className:`wx-SSaVhET7 wx-list ${a?"wx-active":""}`,ref:W,children:l.jsx(ew,{children:l.jsx(Rj,{init:L,data:F,columns:M,selectedRows:A,columnStyle:()=>"wx-SSaVhET7 wx-each-cell",sizes:{rowHeight:42,headerHeight:42},sortMarks:ue})})})]})}function Oj(){const n=f.useContext(jn),a=Qe(n,"activePanel");function i(r){n.exec("set-active-panel",{panel:r})}return l.jsxs("div",{className:"wx-L55BfJa2 wx-panels","data-id":Cn("body"),children:[l.jsx("div",{className:"wx-L55BfJa2 wx-item","data-panel":0,children:l.jsx(lh,{panel:0,active:a==0,onClick:()=>i(0),onContextMenu:()=>i(0)})}),l.jsx("div",{className:"wx-L55BfJa2 wx-item","data-panel":1,children:l.jsx(lh,{panel:1,active:a==1,onClick:()=>i(1),onContextMenu:()=>i(1)})})]})}function tw({folderIcon:n=!1,folder:a={}}){const i=f.useContext(jn),[r,c]=Xa(i,"panels"),d=Qe(i,"activePanel"),h=f.useMemo(()=>r[d].path,[c,d]),p=f.useContext(kn.i18n),x=f.useMemo(()=>p.getGroup("filemanager"),[p]),g=f.useMemo(()=>!!a.data?.find(k=>k.type==="folder"),[a]),w=f.useMemo(()=>a.id=="/"?x(a.name):a.name,[a,x]),v=f.useMemo(()=>a.$level>1?(a.$level-1)*20:0,[a]),b=a.open;return l.jsxs(l.Fragment,{children:[l.jsxs("li",{"data-id":Cn(a.id),className:`wx-NYfhvGIt wx-folder${h===a.id?" wx-selected":""}`,style:{paddingLeft:`${v}px`},children:[g?l.jsx("i",{className:`wx-NYfhvGIt wx-toggle wxi-${b?"angle-down":"angle-right"}`,"data-action":"toggle"}):l.jsx("span",{className:"wx-NYfhvGIt wx-toggle-placeholder"}),l.jsx("i",{className:"wx-NYfhvGIt "+(n||"wxi-folder")}),l.jsxs("span",{className:"wx-NYfhvGIt wx-name",children:[" ",w," "]})]}),b&&a.data&&a.data.length&&g?l.jsx(l.Fragment,{children:a.data.map(k=>k.type==="folder"?l.jsx(tw,{folder:k},k.id):null)}):null]})}function Ij(){const n=f.useContext(jn),[a,i]=Xa(n,"data"),[r,c]=Xa(n,"panels"),d=Qe(n,"activePanel"),h=f.useMemo(()=>r[d]._crumbs,[c,d]),p=f.useCallback(k=>{n.exec("open-tree-folder",{id:k,mode:!a.byId(k).open})},[n,i]),x=f.useCallback(k=>{const j=Rh(k,h);n.exec("set-path",{id:k,panel:d,...j&&{selected:[j]}})},[n,h,d]),[g,w]=f.useState([]);f.useEffect(()=>{w(a.byId(0).data)},[i]);const v=f.useRef(null),b=f.useRef();return f.useEffect(()=>{b.current?(b.current.click=x,b.current.toggle=p):(b.current={click:x,toggle:p},Ur(v.current,b.current))},[x,p]),l.jsx("ul",{ref:v,className:"wx-LyHJ6R6A",children:g.map(k=>k.type==="folder"?l.jsx(tw,{folder:k},k.id):null)})}function Bj(){const n=f.useContext(jn),a=f.useContext(kn.i18n),i=f.useMemo(()=>a.getGroup("filemanager"),[a]),r=Qe(n,"drive"),c=r?r.used:"",d=r?r.total:"";return c&&d?l.jsxs("div",{className:"wx-DetSyKGG wx-drive",children:[l.jsx("progress",{value:c,max:d,className:"wx-DetSyKGG wx-progress"}),l.jsxs("p",{children:[hc(c)," ",i("of")," ",hc(d)," ",i("used")]})]}):null}function Fj({option:n}){const a=f.useContext(kn.i18n).getGroup("filemanager"),i=f.useContext(Lh),r=f.useCallback(()=>{i.open({})},[i]);return l.jsx("div",{className:"wx-9XiKcxq5 wx-upload-button",onClick:r,children:l.jsx("span",{children:a(n.text)})})}function Hj({readonly:n,menuOptions:a}){const i=f.useContext(kn.i18n).getGroup("filemanager"),{showPrompt:r}=f.useContext(Dh);f.useEffect(()=>{sC("upload",Fj)},[]);function c({action:h}){h&&(h.id==="add-file"?r({item:{type:"file",size:0,date:new Date},add:!0}):h.id==="add-folder"&&r({item:{type:"folder",date:new Date},add:!0}))}const d=f.useMemo(()=>a("add").map(h=>(h.text=i(h.text),h)),[a,i]);return l.jsxs("div",{className:"wx-FlucfALM wx-wrapper",children:[!n&&l.jsx("div",{className:"wx-FlucfALM wx-button",children:l.jsx(iC,{options:d,at:"bottom-fit",onClick:c,children:l.jsx(ic,{type:"primary block",children:i("Add New")})})}),l.jsx("div",{className:"wx-FlucfALM wx-tree",children:l.jsx(Ij,{})}),l.jsx(Bj,{})]})}function $j({value:n="",onSearch:a}){const[i,r]=_y(n),c=f.useContext(kn.i18n).getGroup("filemanager"),d=f.useRef(null),h=f.useMemo(()=>i!==""?"wxi-close":"wxi-search",[i]);function p(g){const w=g.target.value;r(w),a&&a({value:w})}function x(){r(""),d.current&&d.current.focus(),a&&a({value:""})}return l.jsxs("div",{className:"wx-lUZMtgT1 wx-search-input",children:[l.jsx("i",{className:`wx-lUZMtgT1 wx-icon ${h}`,onClick:x}),l.jsx("input",{type:"text",className:"wx-lUZMtgT1 wx-text",ref:d,value:i,onInput:p,placeholder:c("Search")})]})}function Uj({narrowMode:n=!1,onShowTree:a}){const i=f.useContext(jn),r=f.useContext(kn.i18n).getGroup("filemanager"),c=Qe(i,"mode"),d=Qe(i,"preview"),h=Qe(i,"search"),p=[{icon:"wxi-view-sequential",id:"table"},{icon:"wxi-view-grid",id:"cards"},{icon:"wxi-view-column",id:"panels"}];function x({value:v}){i.exec("set-mode",{mode:v})}function g(v){v.preventDefault(),i.exec("show-preview",{mode:!d})}function w(v){i.exec("filter-files",{text:v.value})}return l.jsxs("div",{className:"wx-5PZQQztG wx-toolbar",children:[l.jsxs("div",{className:"wx-5PZQQztG wx-left "+(n?"wx-left-narrow":""),children:[n?c==="panels"||c==="search"?null:l.jsx("div",{className:"wx-5PZQQztG wx-sidebar-icon","data-id":Cn("toggle-tree"),children:l.jsx(Wi,{onClick:()=>a&&a(),name:"subtask"})}):l.jsx("div",{className:"wx-5PZQQztG wx-name",children:r("Files")}),l.jsx($j,{onSearch:w,value:h})]}),l.jsxs("div",{className:"wx-5PZQQztG wx-right",children:[n?null:l.jsx("div",{className:"wx-5PZQQztG wx-preview-icon",children:l.jsx(D1,{onClick:g,value:d,children:l.jsx("i",{className:"wx-5PZQQztG wxi-eye"})})}),l.jsx("div",{className:"wx-5PZQQztG wx-modes",children:l.jsx(M1,{value:c,options:p,onChange:x})})]})]})}function Pj(){const n=f.useContext(jn),a=Qe(n,"activePanel");return l.jsxs("div",{className:"wx-NwohNJzN wx-wrapper",children:[l.jsx(Jy,{panel:a}),l.jsx(ew,{children:l.jsx(Zy,{})})]})}function qj({readonly:n=!1,menuOptions:a,extraInfo:i}){const r=f.useRef(null),c=f.useRef(null),[d,h]=f.useState(void 0),[p,x]=f.useState(void 0),[g,w]=f.useState(!1),v=Uy(),b=f.useContext(jn),{showPrompt:k,showConfirm:j}=f.useContext(Dh),M=f.useContext(kn.i18n),T=f.useMemo(()=>M.getGroup("filemanager"),[M]),C=Qe(b,"mode"),A=Qe(b,"preview"),D=Qe(b,"activePanel"),[H,B]=Xa(b,"panels"),q=f.useMemo(()=>(H&&D!=null?H[D]:null)?.selected??[],[B,D]),L=f.useMemo(()=>(H&&D!=null?H[D]:null)?.path,[B,D]),[F,ue]=f.useState([]);f.useEffect(()=>{const J=r.current;if(!J)return;const he=new ResizeObserver($=>{const ie=$[0]?.borderBoxSize?.[0]?.inlineSize;typeof ie=="number"&&x(ie<768)});return he.observe(J),()=>{he.disconnect()}},[]);const W=f.useCallback(()=>{w(J=>!J)},[]),ce=f.useCallback(J=>{p&&mc(J)!=="toggle-tree"&&w(!1)},[p]);f.useEffect(()=>{const J=c.current;if(J)return zs(J,ce).destroy},[ce]),f.useEffect(()=>{const J=c.current;if(!J)return;const he=new ResizeObserver(()=>{J&&h(J.clientWidth)});return he.observe(J),J&&h(J.clientWidth),()=>{he.disconnect()}},[]);const Q=f.useMemo(()=>({icon:"wxi-eye",text:"Preview",id:"preview"}),[]),se=f.useCallback(J=>{let he=p?[Q]:[];return J==="file"&&(he=[...he,...a().filter($=>$.id==="download")]),he},[p,Q,a]),oe=f.useRef(null),K=f.useCallback((J,he,$)=>{const ie=$?[he.id]:q;switch(J){case"download":b.exec("download-file",{id:he.id});break;case"copy":case"move":oe.current={action:J,ids:ie};break;case"paste":oe.current&&b.exec(oe.current.action==="copy"?"copy-files":"move-files",{ids:oe.current.ids,target:he?.type==="folder"?he.id:L});break;case"rename":k({item:he});break;case"delete":j({selected:ie});break;case"preview":b.exec("show-preview",{mode:!A});break}},[b,q,L,k,j,A]),z=f.useCallback(()=>H?.[D],[H,D]);f.useEffect(()=>{const J=r.current;if(!J)return;const he=V1(J,{api:b,menuOptions:n?se:a,performAction:K,getPanel:z});return()=>{typeof he=="function"?he():he&&typeof he.destroy=="function"&&he.destroy()}},[b,n,se,a,K,z]);const Y=f.useCallback((J,he)=>{const $=J?b.getFile(J):null,ie=he.target.closest(".tree-item.folder");let we;if(n)we=se($?.type);else{switch(J){case"body":we=a(J);break;default:if($)if(!ie&&q.length>1)we=p?[Q,...a("multiselect")]:a("multiselect");else if(J==="/")we=a("folder",$).filter(me=>me.id==="paste");else{const me=a($.type,$);me&&(we=p?[Q,...me]:me)}}C==="search"&&(we=we?.filter(me=>me.id!=="paste"))}if($?.id&&(!q.length||!q.some(me=>me===$.id))&&!ie&&b.exec("select-file",{id:$.id}),we?.length)return we.forEach(me=>{ie&&(me.hotkey=""),me.text&&(me.text=T(me.text)),me.hotkey&&(me.subtext=me.hotkey)}),ue(we),$||{}},[b,n,se,a,q,p,Q,C,T]),U=f.useCallback(J=>{const{action:he,context:$}=J;he&&K(he.id,$,!he.hotkey)},[K]);async function R(J){await Promise.resolve();const{name:he,size:$}=J.file;b.exec("create-file",{file:{name:he,size:$,date:new Date,file:J.file},parent:L})}return l.jsx("div",{className:"wx-RJbNonjJ wx-filemanager wx-flex",ref:r,"data-menu-ignore":"false",children:p&&A?l.jsx("div",{className:"wx-RJbNonjJ wx-info-narrow",children:l.jsx(Tm,{narrowMode:p,extraInfo:i})}):l.jsxs(l.Fragment,{children:[l.jsx(Uj,{narrowMode:p,onShowTree:W}),l.jsx(rC,{dataKey:"id",at:"point",options:F,resolver:Y,onClick:U,children:l.jsxs($y,{dataKey:"actionId",options:F,resolver:Y,onClick:U,children:[l.jsx(fC,{data:v,apiOnly:!0,uploadURL:R}),l.jsx(Lh.Provider,{value:v,children:l.jsx("div",{className:"wx-RJbNonjJ wx-content-wrapper wx-flex",children:C!=="panels"&&C!=="search"?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"wx-RJbNonjJ "+["wx-sidebar",p?"wx-sidebar-narrow":"",g?"wx-sidebar-visible":""].filter(Boolean).join(" "),ref:c,children:l.jsx(Hj,{readonly:n,menuOptions:a})}),l.jsxs("div",{className:"wx-RJbNonjJ wx-content",style:{width:`calc(100% - ${d||0}px - 10px)`},children:[l.jsx("div",{className:`wx-RJbNonjJ wx-content-item${A?"":"-fit"}`,"data-id":Cn("body"),children:C==="table"?l.jsx(lh,{panel:D}):l.jsx(Pj,{})}),A?l.jsx("div",{className:"wx-RJbNonjJ wx-info",children:l.jsx(Tm,{extraInfo:i})}):null]})]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:`wx-RJbNonjJ wx-content-item${A?"":"-fit"}`,children:C==="panels"?l.jsx(Oj,{}):l.jsx(zj,{})}),A?l.jsx("div",{className:"wx-RJbNonjJ wx-info",children:l.jsx(Tm,{extraInfo:i})}):null]})})})]})})]})})}const Gj=n=>n.split("-").map(a=>a?a.charAt(0).toUpperCase()+a.slice(1):"").join("");function Yj(n,a){const{type:i,ext:r}=n;if(i==="folder")return!1;let c;return i&&i!=="file"&&Cv[i]?c=i:r?c=Cv[r]?r:"file":c="unknown",`https://cdn.svar.dev/icons/filemanager/vivid/${a}/${c}.svg`}const Vj=f.forwardRef(function(n,a){const{data:i=[],mode:r="cards",drive:c=null,preview:d=!1,panels:h=null,activePanel:p=0,readonly:x=!1,menuOptions:g=q1,extraInfo:w=null,init:v=null,icons:b=Yj,previews:k=null,...j}=n,M=f.useRef();M.current=j;const T=f.useMemo(()=>new P1(Iy),[]),C=f.useMemo(()=>T.in,[T]),A=f.useRef(null);A.current===null&&(A.current=new Ey((B,q)=>{const L="on"+Gj(B);M.current&&M.current[L]&&M.current[L](q)}),C.setNext(A.current));const D=f.useMemo(()=>({getState:T.getState.bind(T),getReactiveState:T.getReactive.bind(T),getStores:()=>({data:T}),exec:C.exec,setNext:B=>(A.current=A.current.setNext(B),A.current),intercept:C.intercept.bind(C),on:C.on.bind(C),detach:C.detach.bind(C),getFile:T.getFile.bind(T),serialize:T.serialize.bind(T),templates:{preview:k||(()=>null),icon:b==="simple"?(()=>null):b}}),[T,C]),H=f.useRef(0);return f.useEffect(()=>{if(!H.current)v&&v(D);else{const B=T.getState();T.init({data:i,mode:r,drive:c,preview:d,panels:h||B.panels||[],activePanel:p})}H.current++},[T,i,r,c,d,h,p,v,D]),H.current===0&&T.init({data:i,mode:r,drive:c,preview:d,panels:h||[],activePanel:p}),f.useImperativeHandle(a,()=>({...D}),[D]),l.jsx(jn.Provider,{value:D,children:l.jsx(Nh,{words:Th,optional:!0,children:l.jsx(Ej,{children:l.jsx(qj,{readonly:x,menuOptions:g,extraInfo:w})})})})});function Kj({fonts:n=!0,children:a}){return a?l.jsx(ov,{fonts:n,children:a}):l.jsx(ov,{fonts:n})}bh(va);function zh(n,a){if(!n||typeof n!="object"||Array.isArray(n))throw new Error(`Invalid Hub ${a} response.`);return n}function xc(n,a,i){const r=zh(n,i);if(!Array.isArray(r[a]))throw new Error(`Invalid Hub ${i} response: ${a} must be an array.`);return r[a]}function Wj(n,a,i){const r=zh(n,i);if(!r[a]||typeof r[a]!="object"||Array.isArray(r[a]))throw new Error(`Invalid Hub ${i} response: ${a} must be an object.`);return r[a]}async function jv(n,a=!1){return xc(await Be(`/api/remote/filesystem/roots${a?"?refresh=1":""}`,void 0,n),"roots","filesystem roots")}async function Rm(n,a){const i=await Be(`/api/remote/filesystem/entries?id=${encodeURIComponent(n)}`,void 0,a);return{folder:Wj(i,"folder","filesystem entries"),entries:xc(i,"entries","filesystem entries")}}async function Qj(n,a){return Be("/api/remote/filesystem/selection/scan",{method:"POST",body:JSON.stringify({itemIds:n})},a)}async function Xj(n,a,i,r){return Be("/api/remote/files/from-hub",{method:"POST",body:JSON.stringify({itemIds:n,deviceIds:a,remoteDirectory:i})},r)}async function Zj(n,a=!1){const i=await Be(`/api/remote/files/jobs?active=${a?"1":"0"}`,void 0,n);return{jobs:xc(i,"jobs","file transfer jobs")}}async function Jj(n,a){return Be(`/api/remote/files/jobs/${encodeURIComponent(n)}`,void 0,a)}async function ek(n,a){return Be(`/api/remote/files/jobs/${encodeURIComponent(n)}/cancel`,{method:"POST"},a)}async function kv(n){return xc(await Be("/api/remote/filesystem/shared-folders",void 0,n),"folders","shared folders")}async function tk(n,a){return Be("/api/remote/filesystem/shared-folders",{method:"POST",body:JSON.stringify({sourceId:n})},a)}async function nk(n,a,i){return Be(`/api/remote/filesystem/shared-folders/${encodeURIComponent(n)}`,{method:"PATCH",body:JSON.stringify(a)},i)}async function ak(n,a){return Be(`/api/remote/filesystem/shared-folders/${encodeURIComponent(n)}`,{method:"DELETE"},a)}async function sk(n,a,i,r){const c=await Be(`/api/remote/filesystem/shared-folders/${encodeURIComponent(n)}/sync`,{method:"POST",body:JSON.stringify({deviceIds:a,remoteDirectory:i})},r),d=zh(c,"shared folder sync");return{ok:d.ok===!0,jobs:xc(c,"jobs","shared folder sync"),files:Number(d.files||0),totalBytes:Number(d.totalBytes||0)}}function lk(n){return{id:String(n.id),parentId:n.parent,name:n.name,type:n.type==="file"?"file":"folder",size:Number(n.size||0),modifiedAt:n.date?.toISOString()||null,displayPath:String(n.displayPath||n.name),hasChildren:n.lazy===!0||!!n.data?.length,locked:n.locked===!0}}function Mv(n){if(!Number.isFinite(n)||n<=0)return"0 B";const a=["B","KB","MB","GB","TB"];let i=n,r=0;for(;i>=1024&&r<a.length-1;)i/=1024,r+=1;return`${i.toFixed(r===0||i>=100?0:1)} ${a[r]}`}function sd(n){return n.driveType==="network"?"network":n.driveType==="removable"?"removable":"local"}function ik(n){const a=n.filter(i=>sd(i)==="local");return a.find(i=>/\bC:/i.test(`${i.name} ${i.displayPath||""}`))||a[0]||n[0]||null}function rk({hubUrl:n,roots:a,loading:i,error:r,onRefreshRoots:c,onImportFiles:d,onImportFolder:h,onSelectionChange:p,onShareItem:x,onAddSyncFolder:g,onNotice:w}){const v=f.useRef(null),b=f.useRef("/"),k=f.useRef(0),j=f.useRef([]),M=f.useRef(new Map),[T,C]=f.useState(null),[A,D]=f.useState([]),[H,B]=f.useState([]),[q,L]=f.useState(0),[F,ue]=f.useState(null),[W,ce]=f.useState(!1),[Q,se]=f.useState(""),[oe,K]=f.useState(new Set),z=a.find(ne=>ne.id===T)||null,Y=A[A.length-1]||null,U=z?Y?.svarPath||`/${z.name}`:null,R=U;f.useEffect(()=>{j.current=A,b.current=R||"/"},[R,A]);const J=f.useMemo(()=>(M.current.clear(),!z||!R||A.length===0?[]:(A.forEach(ne=>M.current.set(ne.svarPath,ne.hubId)),[...A.map((ne,ye)=>({id:ne.svarPath,parent:ye===0?"/":A[ye-1].svarPath,type:"folder",name:ne.name,date:ne.modifiedAt?new Date(ne.modifiedAt):void 0,lazy:!1})),...H.map(ne=>{const ye=`${R}/${ne.name}`;return M.current.set(ye,ne.id),{id:ye,parent:R,name:ne.name,type:ne.type==="file"?"file":"folder",...ne.type==="file"?{size:ne.size}:{},date:ne.modifiedAt?new Date(ne.modifiedAt):void 0,lazy:ne.type!=="file"&&ne.hasChildren===!0,displayPath:ne.displayPath,locked:ne.locked,driveType:ne.driveType,totalBytes:ne.totalBytes,freeBytes:ne.freeBytes}})])),[z,H,R,A]),he=ne=>M.current.get(String(ne))||String(ne),$=ne=>lk({...ne,id:he(String(ne.id)),parent:he(String(ne.parent))}),ie=async(ne,ye)=>{const be=ne[ne.length-1];if(!be)return;const Z=++k.current;ce(!0),se("");try{const le=await Rm(be.hubId,n);if(Z!==k.current)return;if(!Array.isArray(le.entries))throw new Error("Invalid Hub filesystem entries response.");const Me={...be,displayPath:le.folder.displayPath||be.displayPath,modifiedAt:le.folder.modifiedAt||be.modifiedAt},je=[...ne.slice(0,-1),Me];j.current=je,D(je),B(le.entries),L(ct=>ct+1)}catch(le){if(Z!==k.current)return;console.error("[LiveDesk FS] folder navigation failed",{folderId:be.hubId,error:le}),se(le instanceof Error?`${ye}: ${le.message}`:`${ye}: Unable to read this folder.`)}finally{Z===k.current&&ce(!1)}},we=async ne=>{const ye={svarPath:`/${ne.name}`,hubId:ne.id,name:ne.name,displayPath:ne.displayPath,modifiedAt:ne.modifiedAt},be=++k.current;C(ne.id),j.current=[ye],D([ye]),b.current=ye.svarPath,B([]),se(""),ce(!0),ue(ne.id),K(Z=>{const le=new Set(Z);return le.delete(ne.id),le});try{const Z=await Rm(ne.id,n);if(be!==k.current)return;if(!Array.isArray(Z.entries))throw new Error("Invalid Hub filesystem entries response.");const le={...ye,displayPath:Z.folder.displayPath||ye.displayPath,modifiedAt:Z.folder.modifiedAt||ye.modifiedAt};j.current=[le],D([le]),B(Z.entries),L(Me=>Me+1)}catch(Z){if(be!==k.current)return;console.error("[LiveDesk FS] getEntries failed",{rootId:ne.id,error:Z}),K(le=>new Set(le).add(ne.id)),se(Z instanceof Error?`${ne.name}: ${Z.message}`:`${ne.name}: Unable to read this drive.`),w(Z instanceof Error?`${ne.name}: ${Z.message}`:`${ne.name}: Unable to read this drive.`)}finally{be===k.current&&(ue(null),ce(!1))}},me=ne=>{const ye=j.current;ne<0||ne>=ye.length||ne===ye.length-1||ie(ye.slice(0,ne+1),ye[ne].name)},ze=(ne,ye)=>{if(ne.type!=="folder")return;const be=j.current,Z=be.findIndex(Me=>Me.svarPath===ye);if(Z<0)return;const le={svarPath:`${ye}/${ne.name}`,hubId:ne.id,name:ne.name,displayPath:ne.displayPath,modifiedAt:ne.modifiedAt};ie([...be.slice(0,Z+1),le],ne.name)},Pe=()=>me(j.current.length-2),de=ne=>{if(ne.key!=="Enter"&&ne.code!=="Enter"&&ne.code!=="NumpadEnter"||ne.target?.closest('button, input, textarea, [contenteditable="true"]'))return;const be=v.current;if(!be)return;const Z=be.getState().panels?.flatMap(Me=>Me.selected||[])||[];if(Z.length!==1)return;const le=be.getFile(String(Z[0]));le?.type==="folder"&&(ne.preventDefault(),ne.stopPropagation(),ze($(le),String(le.parent||b.current)))};f.useEffect(()=>{const ne=a.find(ye=>ye.id===T)||ik(a);if(K(ye=>new Set([...ye].filter(be=>a.some(Z=>Z.id===be)))),!ne){C(null),j.current=[],D([]),B([]);return}we(ne)},[a]);const He=ne=>{v.current=ne,ne.on("request-data",async({id:ye})=>{const be=String(ye),Z=he(be);try{const le=await Rm(Z,n);if(!Array.isArray(le.entries))throw new Error("Invalid Hub filesystem entries response.");const Me=le.entries.map(je=>{const ct=`${be}/${je.name}`;return M.current.set(ct,je.id),{id:ct,parent:be,name:je.name,type:je.type==="file"?"file":"folder",...je.type==="file"?{size:je.size}:{},date:je.modifiedAt?new Date(je.modifiedAt):void 0,lazy:je.type!=="file"&&je.hasChildren===!0,displayPath:je.displayPath,locked:je.locked,driveType:je.driveType,totalBytes:je.totalBytes,freeBytes:je.freeBytes}});await ne.exec("provide-data",{id:be,data:Me})}catch(le){console.error("[LiveDesk FS] nested getEntries failed",{id:Z,error:le}),w(le instanceof Error?le.message:"Unable to read this folder.")}}),ne.intercept("set-path",({id:ye})=>{const be=String(ye),Z=j.current.findIndex(Me=>Me.svarPath===be);if(Z>=0)return me(Z),!1;const le=ne.getFile(be);if(le?.type==="folder")return ze($(le),String(le.parent||b.current)),!1}),ne.intercept("open-file",()=>!1),ne.on("select-file",()=>{window.setTimeout(()=>{const Z=(ne.getState().panels?.flatMap(le=>le.selected||[])||[]).map(le=>ne.getFile(le)).filter(Boolean).map(le=>$(le));p(Z.map(le=>le.id),Z)},0)})},Le=(ne,ye)=>{const be=ye?$(ye):null,Z=()=>{const le=be?.type==="file"?String(ye?.parent||b.current):String(ye?.id||b.current);v.current?.exec("request-data",{id:le})};return ne==="body"?[{id:"refresh",text:"Refresh",icon:"mdi mdi-refresh",handler:Z},{id:"properties",text:"Properties",icon:"mdi mdi-information-outline",handler:()=>w("Select a file or folder to view its properties.")}]:ne==="multiselect"?[{id:"share",text:"Share to workstations",icon:"mdi mdi-share-variant",handler:()=>{(v.current?.getState().panels?.flatMap(Me=>Me.selected||[])||[]).forEach(Me=>{const je=v.current?.getFile(Me);je&&x($(je))})}},{id:"refresh",text:"Refresh",icon:"mdi mdi-refresh",handler:Z}]:be?[{id:"share",text:"Share to workstations",icon:"mdi mdi-share-variant",handler:()=>x(be)},...be.type==="folder"?[{id:"sync",text:"Add folder to Sync",icon:"mdi mdi-folder-sync-outline",handler:()=>g(be)}]:[],{id:"copy-path",text:"Copy path",icon:"mdi mdi-content-copy",handler:()=>{qi(be.displayPath||be.name)}},{id:"refresh",text:"Refresh",icon:"mdi mdi-refresh",handler:Z},{id:"properties",text:"Properties",icon:"mdi mdi-information-outline",handler:()=>w(`${be.name}
|
|
12
|
-
${be.displayPath||""}`)}]:[]},Fe=async()=>{try{await c()}catch(ne){w(ne instanceof Error?ne.message:"Unable to refresh Hub drives.")}},qe=[{id:"local",label:"Local drives",icon:Vo,roots:a.filter(ne=>sd(ne)==="local")},{id:"removable",label:"Removable drives",icon:Hb,roots:a.filter(ne=>sd(ne)==="removable")},{id:"network",label:"Network drives",icon:gh,roots:a.filter(ne=>sd(ne)==="network")}];return l.jsxs("section",{className:"hub-file-explorer-panel","aria-label":"Hub file explorer",children:[l.jsxs("div",{className:"hub-file-explorer-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Hub file explorer"}),l.jsxs("strong",{children:[l.jsx(Vo,{size:16})," Browse files on this Hub"]})]}),l.jsxs("div",{className:"hub-file-explorer-heading-actions",children:[l.jsx("button",{className:"icon-button",onClick:d,title:"Import files from this browser",type:"button",children:l.jsx(ay,{size:16})}),l.jsx("button",{className:"icon-button",onClick:h,title:"Import folder from this browser",type:"button",children:l.jsx($b,{size:16})}),l.jsx("button",{className:"icon-button",onClick:()=>{Fe()},title:"Refresh drives",type:"button",children:l.jsx(pc,{size:16})})]})]}),i?l.jsxs("div",{className:"hub-file-explorer-state",children:[l.jsx(Vo,{size:24}),l.jsx("strong",{children:"Connecting to LiveDesk Hub file system..."})]}):r?l.jsxs("div",{className:"hub-file-explorer-state error",role:"alert",children:[l.jsx(oc,{size:24}),l.jsx("strong",{children:r})]}):l.jsxs("div",{className:"hub-file-explorer-content",children:[l.jsxs("aside",{className:"hub-file-explorer-drive-sidebar","aria-label":"Hub drives",children:[l.jsxs("div",{className:"hub-drive-sidebar-title",children:[l.jsx(Vo,{size:15}),l.jsx("strong",{children:"This PC"})]}),qe.map(ne=>ne.roots.length>0&&l.jsxs("section",{className:"hub-drive-group",children:[l.jsxs("h3",{children:[l.jsx(ne.icon,{size:13}),ne.label]}),l.jsx("div",{className:"hub-drive-list",children:ne.roots.map(ye=>{const be=ne.icon,Z=oe.has(ye.id)||ye.locked===!0;return l.jsxs("button",{className:`hub-drive-item ${T===ye.id?"active":""} ${Z?"unavailable":""}`,onClick:()=>{we(ye)},"aria-pressed":T===ye.id,type:"button",children:[l.jsx("span",{className:"hub-drive-item-icon",children:l.jsx(be,{size:16})}),l.jsxs("span",{className:"hub-drive-item-copy",children:[l.jsx("strong",{children:ye.name}),l.jsx("small",{children:ye.displayPath||ye.name}),l.jsxs("em",{children:[Mv(ye.freeBytes||0)," free / ",Mv(ye.totalBytes||0)]})]}),F===ye.id?l.jsx(od,{className:"hub-drive-item-status spin",size:15}):Z?l.jsx(kx,{className:"hub-drive-item-status",size:15}):null]},ye.id)})})]},ne.id)),a.length===0&&l.jsxs("div",{className:"hub-drive-sidebar-empty",children:[l.jsx(oc,{size:17}),l.jsx("span",{children:"No drives available."})]})]}),l.jsxs("div",{className:"hub-file-explorer-browser",children:[l.jsxs("div",{className:"hub-file-explorer-navigation",children:[l.jsx("nav",{className:"hub-file-explorer-breadcrumbs","aria-label":"Current Hub folder",children:A.map((ne,ye)=>l.jsxs("span",{className:"hub-file-explorer-breadcrumb-item",children:[ye>0&&l.jsx(xh,{size:13,"aria-hidden":"true"}),l.jsx("button",{className:`hub-file-explorer-breadcrumb ${ye===A.length-1?"current":""}`,onClick:()=>me(ye),"aria-current":ye===A.length-1?"location":void 0,type:"button",children:ne.name})]},ne.svarPath))}),l.jsxs("div",{className:"hub-file-explorer-navigation-actions",children:[W&&l.jsx(od,{className:"hub-file-explorer-loading-icon spin",size:15,"aria-label":"Loading folder"}),l.jsx("button",{className:"icon-button",onClick:Pe,disabled:A.length<=1||W,title:"Back to parent folder",type:"button",children:l.jsx(Ub,{size:16})})]})]}),Q&&l.jsxs("div",{className:"hub-file-explorer-folder-error",role:"alert",children:[l.jsx(kx,{size:15}),l.jsx("span",{children:Q})]}),l.jsx("div",{className:"hub-file-explorer-svar",onKeyDownCapture:de,children:l.jsx(Kj,{fonts:!1,children:l.jsx(Vj,{data:J,panels:U?[{path:U,selected:[]}]:void 0,readonly:!0,mode:"table",preview:!1,init:He,icons:"simple",menuOptions:Le},`${z?.id||"no-root"}:${q}`)})})]})]})]})}class ok extends f.Component{state={error:null};static getDerivedStateFromError(a){return{error:a}}componentDidCatch(a,i){console.error("[LiveDesk] Share Files runtime error",a,i.componentStack)}render(){return this.state.error?l.jsxs("section",{className:"file-share-error-boundary",role:"alert",children:[l.jsx(yd,{size:24}),l.jsx("strong",{children:"Share Files could not be opened."}),l.jsx("span",{children:this.state.error.message||"An unexpected file explorer error occurred."}),l.jsxs("button",{className:"text-button",onClick:this.props.onRetry,type:"button",children:[l.jsx(pc,{size:15})," Retry"]})]}):this.props.children}}function ck(n){return n.deviceName||n.hostname||n.deviceId}function uk({devices:n,mode:a,selectedIds:i,onModeChange:r,onToggle:c}){const d=new Set(i);return l.jsxs("section",{className:"distribution-targets",children:[l.jsxs("div",{className:"file-share-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Target"}),l.jsx("strong",{children:a==="all"?`${n.length} connected`:`${i.length} selected`})]}),l.jsxs("div",{className:"file-share-tabs compact","aria-label":"File transfer targets",children:[l.jsxs("button",{className:a==="all"?"active":"",onClick:()=>r("all"),type:"button",children:[l.jsx(sy,{size:14})," All connected"]}),l.jsxs("button",{className:a==="selected"?"active":"",onClick:()=>r("selected"),type:"button",children:[l.jsx(an,{size:14})," Selected"]})]})]}),l.jsx("div",{className:"file-share-device-list","aria-label":"Connected workstation targets",children:n.length===0?l.jsx("div",{className:"file-share-empty-inline",children:"No connected workstations."}):n.map(h=>{const p=a==="all"||d.has(h.deviceId);return l.jsxs("label",{className:`file-share-device-option ${p?"selected":""}`,children:[l.jsx("input",{type:"checkbox",checked:p,disabled:a==="all",onChange:()=>c(h.deviceId)}),l.jsx(an,{size:20,"aria-hidden":"true"}),l.jsxs("span",{children:[l.jsx("strong",{children:ck(h)}),l.jsxs("small",{children:["Slot ",h.slotNumber?String(h.slotNumber).padStart(3,"0"):"-"," / ",h.platform||"unknown OS"]})]}),l.jsx(qn,{size:17,"aria-hidden":"true"})]},h.deviceId)})})]})}function dk(n){if(!Number.isFinite(n)||n<=0)return"0 B";const a=["B","KB","MB","GB","TB"];let i=n,r=0;for(;i>=1024&&r<a.length-1;)i/=1024,r+=1;return`${i.toFixed(r===0||i>=100?0:1)} ${a[r]}`}function fk({folders:n,loading:a,busy:i,canSync:r,onSyncAll:c,onSync:d,onToggleAuto:h,onRemove:p,onAdd:x}){return l.jsxs("section",{className:"file-share-sync-panel",children:[l.jsxs("div",{className:"file-share-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Hub folders"}),l.jsx("strong",{children:"Continuous sync"})]}),l.jsxs("button",{className:"text-button compact",onClick:c,disabled:i||!r||n.length===0,type:"button",children:[l.jsx(Ju,{size:15})," ",i?"Syncing":"Sync all"]})]}),a?l.jsx("div",{className:"file-share-empty-state",children:"Loading Hub sync folders..."}):n.length===0?l.jsxs("button",{className:"file-share-empty-state interactive",onClick:x,type:"button",children:[l.jsx(Ju,{size:28}),l.jsx("strong",{children:"Add a selected Hub folder"}),l.jsx("span",{children:"Hub keeps the manifest and can sync while this browser is closed."})]}):l.jsx("div",{className:"file-share-sync-list",children:n.map(g=>l.jsxs("article",{className:`file-share-sync-row state-${g.status}`,children:[l.jsx("div",{className:"file-share-sync-icon",children:l.jsx(Ju,{size:19})}),l.jsxs("div",{className:"file-share-sync-info",children:[l.jsx("strong",{children:g.name}),l.jsx("span",{children:g.displayPath}),l.jsxs("small",{children:[g.fileCount," files / ",dk(g.totalBytes)," · ",g.lastSyncedAt?`Last sync ${Jm(g.lastSyncedAt)} ago`:g.message||"Not synced yet"]})]}),l.jsxs("label",{className:"file-share-auto-sync",children:[l.jsx("input",{type:"checkbox",checked:g.autoSync,onChange:()=>h(g)}),l.jsx("span",{children:"Auto"})]}),l.jsxs("button",{className:"text-button compact",onClick:()=>d(g),disabled:i||!r||g.status==="syncing",type:"button",children:[l.jsx(pc,{size:14})," Sync now"]}),l.jsx("button",{className:"icon-button",onClick:()=>p(g),title:"Remove sync folder",type:"button",children:l.jsx(hh,{size:15})})]},g.id))})]})}function mk(n){const i=(n.targetMode==="all"?n.devices.map(r=>r.deviceId):n.selectedTargetIds).length>0;return l.jsxs("aside",{className:"file-share-distribution-panel",children:[l.jsxs("div",{className:"file-share-distribution-head",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Distribution"}),l.jsx("strong",{children:"Hub → workstations"})]}),l.jsx(cd,{size:18})]}),l.jsxs("div",{className:"file-share-tabs",role:"tablist","aria-label":"Distribution mode",children:[l.jsx("button",{className:n.tab==="send"?"active":"",onClick:()=>n.onTabChange("send"),role:"tab","aria-selected":n.tab==="send",type:"button",children:"Send"}),l.jsx("button",{className:n.tab==="sync"?"active":"",onClick:()=>n.onTabChange("sync"),role:"tab","aria-selected":n.tab==="sync",type:"button",children:"Sync"})]}),n.tab==="send"?l.jsxs(l.Fragment,{children:[l.jsx(uk,{devices:n.devices,mode:n.targetMode,selectedIds:n.selectedTargetIds,onModeChange:n.onTargetModeChange,onToggle:n.onTargetToggle}),l.jsxs("label",{className:"file-share-destination",children:[l.jsx("span",{children:"Destination folder"}),l.jsxs("div",{children:[l.jsx(nc,{size:15}),l.jsx("input",{value:n.remoteDirectory,onChange:r=>n.onRemoteDirectoryChange(r.target.value),placeholder:"Desktop/LiveDeskFiles"})]}),l.jsx("small",{children:"Blank uses Desktop/LiveDeskFiles."})]}),l.jsxs("div",{className:"file-share-selection-summary",children:[l.jsx("span",{children:"Selected"}),l.jsx("strong",{children:n.selectedSummary})]}),l.jsxs("button",{className:"file-share-share-button",onClick:n.onShare,disabled:!n.canShare,type:"button",children:[l.jsx(cd,{size:17})," Share selected"]}),l.jsxs("button",{className:"file-share-secondary-button",onClick:n.onAddSync,disabled:!n.canAddSync,type:"button",children:[l.jsx(nc,{size:16})," Add selected folder to Sync"]})]}):l.jsx(fk,{folders:n.folders,loading:n.foldersLoading,busy:n.syncBusy,canSync:i,onSyncAll:n.onSyncAll,onSync:n.onSync,onToggleAuto:n.onToggleAuto,onRemove:n.onRemove,onAdd:n.onAddFolder})]})}function hk(n){if(!Number.isFinite(n)||n<=0)return"0 B";const a=["B","KB","MB","GB","TB"];let i=n,r=0;for(;i>=1024&&r<a.length-1;)i/=1024,r+=1;return`${i.toFixed(r===0||i>=100?0:1)} ${a[r]}`}function Av(n){return n.totalBytes>0?Math.max(0,Math.min(100,Math.round(n.sentBytes/n.totalBytes*100))):n.totalFiles>0?Math.max(0,Math.min(100,Math.round(n.completedFiles/n.totalFiles*100))):n.state==="completed"?100:0}function Nv(n){return n.state==="scanning"?"Scanning selected Hub items":n.state==="queued"?"Preparing transfer":n.state==="sending"?`${n.completedFiles}/${n.totalFiles} · ${n.currentPath||"sending"}`:n.state==="completed"?`Sent ${n.totalFiles} file${n.totalFiles===1?"":"s"} to ${n.targetCount} workstation${n.targetCount===1?"":"s"}`:n.state==="partially-failed"?`${n.failedTargets.length} workstation${n.failedTargets.length===1?"":"s"} failed`:n.state==="cancelled"?"Transfer cancelled":n.error||"Transfer failed"}function Tv(n){return["completed","partially-failed","failed","cancelled"].includes(n)}function pk({hubUrl:n,devices:a,localFeatureAccess:i,upgradeNotice:r,notice:c,remoteDirectory:d,onRemoteDirectoryChange:h,targetMode:p,selectedTargetIds:x,onTargetModeChange:g,onTargetToggle:w,filePickerRef:v,folderPickerRef:b,onBrowserFileImport:k,onBrowserFolderImport:j,onNotice:M,onTransferChange:T}){const C=Array.isArray(a)?a:[],[A,D]=f.useState([]),[H,B]=f.useState(!0),[q,L]=f.useState(""),[F,ue]=f.useState([]),[W,ce]=f.useState([]),[Q,se]=f.useState(null),[oe,K]=f.useState(!1),[z,Y]=f.useState([]),[U,R]=f.useState(!0),[J,he]=f.useState(!1),[$,ie]=f.useState("send"),[we,me]=f.useState([]),ze=f.useRef(new Set),Pe=f.useMemo(()=>p==="all"?C.map(ke=>ke.deviceId):x.filter(ke=>C.some(Ne=>Ne.deviceId===ke)),[C,x,p]),de=we.find(ke=>!Tv(ke.state)),He=W.length===1&&W[0].type==="folder"?W[0]:null,Le=W.length===0?"Select files or folders from the Hub explorer.":oe?"Calculating selection size...":Q?`${Q.files} files, ${Q.folders} folders · ${hk(Q.totalBytes)}`:`${W.length} item${W.length===1?"":"s"} selected`,Fe=ke=>{T({id:ke.jobId,state:ke.state,progress:Av(ke),message:Nv(ke)})},qe=f.useCallback(async()=>{const ke=await jv(n,!0);return D(ke),L(""),ke},[n]),ne=async()=>{try{const Ne=(await Zj(n,!0)).jobs||[],Oe=await Promise.all([...ze.current].map(async Nt=>{try{return await Jj(Nt,n)}catch{return null}})),Dt=[...Ne,...Oe.filter(Boolean)],Za=[...new Map(Dt.map(Nt=>[Nt.jobId,Nt])).values()];me(Za),Za.forEach(Fe),Za.filter(Nt=>Tv(Nt.state)).forEach(Nt=>ze.current.delete(Nt.jobId))}catch{}};f.useEffect(()=>{let ke=!0;B(!0),L(""),Promise.all([qe(),kv(n).then(Oe=>{ke&&Y(Oe)})]).catch(Oe=>{ke&&(L(Oe instanceof Error?"Hub file system is unavailable. Make sure LiveDesk Hub is running on this computer.":"Hub file system is unavailable."),M(Oe instanceof Error?Oe.message:"Hub file system is unavailable."))}).finally(()=>{ke&&(B(!1),R(!1))}),ne();const Ne=window.setInterval(()=>{ne()},800);return()=>{ke=!1,window.clearInterval(Ne)}},[n,qe]),f.useEffect(()=>{if(F.length===0){se(null);return}let ke=!1;return K(!0),Qj(F,n).then(Ne=>{ke||se(Ne)}).catch(Ne=>{ke||M(Ne instanceof Error?Ne.message:"Unable to calculate selected size.")}).finally(()=>{ke||K(!1)}),()=>{ke=!0}},[n,F.join("|")]);const ye=(ke,Ne)=>{ue(ke),ce(Ne)},be=ke=>{ke.forEach(Ne=>ze.current.add(Ne.jobId)),me(Ne=>[...new Map([...Ne,...ke].map(Oe=>[Oe.jobId,Oe])).values()]),ke.forEach(Fe)},Z=async()=>{if(!i){M(r);return}if(F.length===0){M("Select files or folders from the Hub explorer.");return}if(Pe.length===0){M("Choose at least one connected workstation.");return}if(de){M("A Hub transfer is already running.");return}try{const ke=await Xj(F,Pe,d.trim(),n);ze.current.add(ke.jobId),M("Hub transfer queued."),await ne()}catch(ke){M(ke instanceof Error?ke.message:"Unable to start Hub transfer.")}},le=async ke=>{const Ne=ke||He;if(!Ne||Ne.type!=="folder"){M("Select one folder to add it to Sync.");return}try{const Oe=await tk(Ne.id,n);Y(Dt=>[...Dt.filter(Za=>Za.id!==Oe.folder.id),Oe.folder]),ie("sync"),M(`${Ne.name} is ready for Hub sync.`)}catch(Oe){M(Oe instanceof Error?Oe.message:"Unable to add the Hub folder to Sync.")}},Me=async ke=>{if(Pe.length===0){M("Choose at least one connected workstation.");return}he(!0),Y(Ne=>Ne.map(Oe=>Oe.id===ke.id?{...Oe,status:"syncing"}:Oe));try{const Ne=await sk(ke.id,Pe,d.trim(),n);be(Ne.jobs||[]),M(Ne.jobs?.length?"Hub sync queued.":"No changed files to sync.");const Oe=await kv(n);Y(Oe)}catch(Ne){M(Ne instanceof Error?Ne.message:"Unable to sync the Hub folder."),Y(Oe=>Oe.map(Dt=>Dt.id===ke.id?{...Dt,status:"error",message:"Sync failed"}:Dt))}finally{he(!1)}},je=async()=>{he(!0);try{for(const ke of z)await Me(ke)}finally{he(!1)}},ct=async ke=>{try{const Ne=await nk(ke.id,{autoSync:!ke.autoSync},n);Y(Oe=>Oe.map(Dt=>Dt.id===ke.id?Ne.folder:Dt))}catch(Ne){M(Ne instanceof Error?Ne.message:"Unable to update auto sync.")}},sn=async ke=>{try{await ak(ke.id,n),Y(Ne=>Ne.filter(Oe=>Oe.id!==ke.id))}catch(Ne){M(Ne instanceof Error?Ne.message:"Unable to remove the sync folder.")}};return l.jsxs("section",{className:"livedesk-file-explorer",children:[l.jsx("input",{ref:v,className:"hidden-file-input",type:"file",multiple:!0,onChange:ke=>{ke.currentTarget.files&&k(ke.currentTarget.files),ke.currentTarget.value=""}}),l.jsx("input",{ref:b,className:"hidden-file-input",type:"file",multiple:!0,webkitdirectory:"",directory:"",onChange:ke=>{ke.currentTarget.files&&j(ke.currentTarget.files),ke.currentTarget.value=""}}),(c||q)&&l.jsxs("section",{className:"file-share-notice",role:q?"alert":void 0,children:[q||c,l.jsx("button",{className:"icon-button",onClick:()=>{L(""),B(!0),jv(n).then(ke=>D(ke)).catch(()=>L("Hub file system is unavailable.")).finally(()=>B(!1))},title:"Retry",type:"button",children:l.jsx(pc,{size:15})})]}),l.jsx("div",{className:"file-share-workspace",children:l.jsxs(ok,{onRetry:()=>window.location.reload(),children:[l.jsx(rk,{hubUrl:n,roots:A,loading:H,error:q,onRefreshRoots:qe,onImportFiles:()=>v.current?.click(),onImportFolder:()=>b.current?.click(),onSelectionChange:ye,onShareItem:ke=>{ue([ke.id]),ce([ke]),ie("send")},onAddSyncFolder:ke=>{ue([ke.id]),ce([ke]),le(ke)},onNotice:M}),l.jsx(mk,{devices:C,targetMode:p,selectedTargetIds:x,onTargetModeChange:g,onTargetToggle:w,remoteDirectory:d,onRemoteDirectoryChange:h,selectedEntries:W,selectedSummary:Le,canShare:i&&!de&&F.length>0&&Pe.length>0&&!oe,onShare:()=>{Z()},canAddSync:!!He,onAddSync:()=>{le()},tab:$,onTabChange:ie,folders:z,foldersLoading:U,syncBusy:J,onSyncAll:()=>{je()},onSync:ke=>{Me(ke)},onToggleAuto:ke=>{ct(ke)},onRemove:ke=>{sn(ke)},onAddFolder:()=>{le()}})]})}),de&&l.jsx("footer",{className:"file-share-workspace-footer",children:l.jsxs("span",{children:[Nv(de)," · ",Av(de),"% ",l.jsx("button",{className:"icon-button",onClick:()=>{ek(de.jobId,n).then(ke=>{me(Ne=>Ne.map(Oe=>Oe.jobId===ke.jobId?ke:Oe)),Fe(ke)})},title:"Cancel transfer",type:"button",children:l.jsx(Hr,{size:14})})]})})]})}const gk=f.forwardRef(function({value:a,onChange:i,onSubmit:r,onOpenSuggestedTasks:c,suggestedOpen:d=!1,suggestedTaskCount:h,disabled:p=!1},x){return l.jsxs("form",{className:"agents-composer",onSubmit:g=>{g.preventDefault(),r()},children:[l.jsxs("button",{className:`agents-suggested-trigger ${d?"active":""}`,type:"button","aria-label":h===void 0?"Open Suggested tasks":`Open Suggested tasks (${h} available)`,"aria-expanded":d,onClick:c,disabled:p,children:[l.jsx(Pb,{size:17}),h!==void 0&&l.jsx("span",{className:"agents-suggested-count","aria-hidden":"true",children:h})]}),l.jsx("textarea",{ref:x,value:a,onChange:g=>i(g.target.value.slice(0,4e3)),placeholder:"Ask LiveDesk to work across your machines...","aria-label":"Ask LiveDesk",rows:2,disabled:p}),l.jsxs("button",{className:"agents-run-button",type:"submit",disabled:p||!a.trim(),children:[p?l.jsx(od,{className:"spin",size:16}):l.jsx(cd,{size:16}),p?"Running":"Run"]})]})}),xk=["read","processControl","serviceControl","applicationControl","fileRead","fileWrite","fileDelete","shell","script","softwareInstall","network","systemPower","systemConfiguration","userAccount"];function nw(n){return n.deviceName?.trim()||n.hostname?.trim()||n.deviceId}function vk(n){return n==="running"||n==="completed"||n==="failed"||n==="cancelled"?n:"queued"}function yk(n){switch(n){case"process.list":return"Process list";case"system.health":return"System health";case"gpu.status":return"GPU status";case"disk.status":return"Disk status";case"service.status":return"Service status";case"diagnostics.collect":return"Diagnostics";case"process.control":return"Process control";case"service.control":return"Service control";case"application.launch":return"Launch application";case"application.close":return"Close application";case"file.read":return"Read file";case"file.write":return"Write file";case"file.delete":return"Delete file";case"file.list":return"List directory";case"command.run":return"Run command";case"script.run":return"Run script";case"software.install":return"Install software";case"network.status":return"Network status";case"system.power":return"Power action";case"system.configure":return"System configuration";case"logs.collect":return"Collect logs"}}function wk(n){const a=n.match(/\[([^\]]+)\]/)?.[1]?.trim();if(a)return a;if(n.includes("comfyui"))return"comfyui";if(n.includes("ollama"))return"ollama";const i=n.match(/process(?:\s+(?:named|called))?\s+([a-z0-9._-]+)/i)?.[1];return i&&!["is","running","process"].includes(i)?i:void 0}function bk(n){const a=n.trim().toLowerCase();return!a||/(stop|restart|kill|terminate|start|launch|close|delete|write|edit|run command|execute|install|shutdown|reboot|sleep|power|file|folder|script|application)/i.test(a)?null:/(process|프로세스|실행 중|실행중|comfyui|running|processes)/i.test(a)?{operation:"process.list",query:wk(a)}:/(gpu|그래픽|vram|gpu 상태)/i.test(a)?{operation:"gpu.status"}:/(disk|디스크|storage|저장 공간)/i.test(a)?{operation:"disk.status"}:/(service|서비스)/i.test(a)?{operation:"service.status"}:/(diagnostic|진단|로그)/i.test(a)?{operation:"diagnostics.collect"}:/(health|system|시스템|상태)/i.test(a)?{operation:"system.health"}:null}const Sk=["이 작업은 아직 지원되지 않습니다.","","현재 지원:","• 시스템 상태 확인","• GPU 상태 확인","• 디스크 상태 확인","• 프로세스 조회","• 서비스 상태 조회","• 진단 로그 수집"].join(`
|
|
13
|
-
`);function Ck(n){return n&&typeof n=="object"&&!Array.isArray(n)?n:null}function Da(n){return typeof n=="number"&&Number.isFinite(n)?n:null}function Vu(n){const a=Da(n);return a===null?"":a<1024**2?`${Math.round(a/1024)}K`:a<1024**3?`${(a/1024**2).toFixed(0)}M`:`${(a/1024**3).toFixed(1)}G`}function jk(n){const a=Da(n);return a===null?"":`${Math.round((a<=1?a:a/100)*100)}%`}function kk(n){return!n||/^(?:[\w .-]+ )?collected(?:\.)?$/i.test(n.trim())?"":n.trim()}function xd(n,a){if(a.error)return a.error;const i=Ck(a.data),r=kk(a.result||"");if(!i)return r||a.stage||a.status;if(n==="system.health"){const c=typeof i.machine=="string"?i.machine:"",d=Vu(i.freeMemoryBytes),h=Vu(i.totalMemoryBytes),p=Da(i.totalMemoryBytes)&&Da(i.freeMemoryBytes)!==null?`${Math.round(Da(i.freeMemoryBytes)/Da(i.totalMemoryBytes)*100)}% RAM free`:"";return[c,d&&h?`RAM ${d}/${h}`:"",p,typeof i.platform=="string"?i.platform:""].filter(Boolean).join(" · ")||r||a.status}if(n==="disk.status"){const c=typeof i.root=="string"?i.root:"",d=Vu(i.freeBytes),h=Da(i.totalBytes)&&Da(i.freeBytes)!==null?`${Math.round(Da(i.freeBytes)/Da(i.totalBytes)*100)}% free`:"";return[c,d&&`${d} free`,h].filter(Boolean).join(" · ")||r||a.status}if(n==="gpu.status"){const c=typeof i.name=="string"&&i.name?i.name:"No GPU provider",d=jk(i.usageRatio),h=Da(i.temperatureC)!==null?`${Math.round(Da(i.temperatureC))}°C`:"",p=Vu(i.freeMemoryBytes);return[c,d&&`GPU ${d}`,h,p&&`${p} free`].filter(Boolean).join(" · ")||r||a.status}if(n==="process.list"){const c=Da(i.count);return c!==null?`${c} matching process${c===1?"":"es"}`:r||a.status}if(n==="network.status"){const c=Array.isArray(i.adapters)?i.adapters.length:null;return c!==null?`${c} active adapter${c===1?"":"s"}`:r||a.status}return r||a.stage||a.status}function Rv(n,a){const i=xd(n,a);return a.status==="failed"||a.status==="cancelled"||/\b(?:warning|failed|error|offline|not running|low|timeout|timed out)\b/i.test(`${a.result||""} ${i}`)}function Mk({state:n,operation:a}){const i=n.status==="completed"?uc:n.status==="failed"||n.status==="cancelled"?Hr:n.status==="running"?od:ly,r=n.status==="running"?n.stage||"Working":n.status==="completed"?a?xd(a,n):n.result||"Completed":n.status==="failed"?n.error||"Failed":n.status==="cancelled"?"Cancelled":"Queued";return l.jsxs("div",{className:`agent-target-row status-${n.status}`,"data-agent-target-id":n.deviceId,children:[l.jsx("span",{className:"agent-target-status","aria-hidden":"true",children:l.jsx(i,{size:15})}),l.jsx("strong",{children:n.deviceName}),l.jsx("span",{className:"agent-target-state",children:n.status[0].toUpperCase()+n.status.slice(1)}),l.jsx("small",{children:r})]})}function Ak({operation:n,states:a,status:i,onCancel:r,onRetry:c,busy:d=!1}){const h=["running","queued"].includes(i),[p,x]=f.useState(!1),[g,w]=f.useState("all"),v=f.useMemo(()=>({total:a.length,completed:a.filter(D=>D.status==="completed").length,failed:a.filter(D=>D.status==="failed").length,running:a.filter(D=>D.status==="running").length,queued:a.filter(D=>D.status==="queued").length,cancelled:a.filter(D=>D.status==="cancelled").length}),[a]),b=a.filter(D=>Rv(n,D)),k=b.filter(D=>D.status==="completed").length,j=v.failed>0,M=b.length>0,T=a.filter(D=>g==="issues"?Rv(n,D):g==="running"?D.status==="running"||D.status==="queued":g==="completed"?D.status==="completed":g==="failed"?D.status==="failed":!0),C=M&&!h||i==="completed-with-failures"?"Completed with issues":i[0]?.toUpperCase()+i.slice(1),A=a.filter(D=>D.status==="completed").map(D=>xd(n,D)).filter(Boolean).filter((D,H,B)=>B.indexOf(D)===H).slice(0,2);return l.jsxs("section",{className:"agent-task-block","aria-label":"Task execution",children:[l.jsxs("div",{className:"agent-task-head",children:[l.jsxs("div",{children:[l.jsx("span",{children:"LiveDesk Agent"}),l.jsx("strong",{children:yk(n)})]}),l.jsx("span",{className:`agent-task-status status-${M?"completed-with-failures":i}`,children:C})]}),l.jsxs("div",{className:"agent-task-summary","aria-label":"Task summary",children:[l.jsxs("strong",{children:[v.total," targets"]}),l.jsxs("span",{className:"summary-completed",children:[v.completed," completed"]}),v.running>0&&l.jsxs("span",{className:"summary-running",children:[v.running," running"]}),v.queued>0&&l.jsxs("span",{children:[v.queued," queued"]}),j&&l.jsxs("span",{className:"summary-failed",children:[v.failed," failed"]}),k>0&&l.jsxs("span",{className:"summary-cancelled",children:[k," warning"]}),v.cancelled>0&&l.jsxs("span",{className:"summary-cancelled",children:[v.cancelled," cancelled"]})]}),A.length>0&&l.jsxs("div",{className:"agent-task-result-preview",title:A.join(" · "),children:[l.jsx("span",{children:"Result"}),A.join(" · ")]}),l.jsx("div",{className:"agent-target-chips","aria-label":"Target status overview",children:a.map((D,H)=>{const B=D.status==="completed"?"✓":D.status==="failed"?"×":D.status==="cancelled"?"!":D.status==="running"?"…":"·";return l.jsxs("span",{className:`agent-target-chip status-${D.status}`,title:`${D.deviceName}: ${xd(n,D)}`,"aria-label":`${H+1}. ${D.deviceName}: ${D.status}`,children:[l.jsx("b",{children:String(H+1).padStart(2,"0")}),l.jsx("span",{children:B})]},D.deviceId)})}),a.length>0&&l.jsx("div",{className:"agent-task-details-toggle",children:l.jsxs("button",{type:"button",onClick:()=>x(D=>!D),"aria-expanded":p,children:[p?l.jsx(qb,{size:14}):l.jsx(iy,{size:14}),p?"Hide details":"Show details"]})}),p&&l.jsxs("div",{className:"agent-task-details",children:[l.jsx("div",{className:"agent-task-filters",role:"tablist","aria-label":"Task result filter",children:["all","issues","running","completed","failed"].map(D=>l.jsx("button",{className:g===D?"active":"",onClick:()=>w(D),role:"tab","aria-selected":g===D,type:"button",children:D==="all"?"All":D==="issues"?"Issues only":D[0].toUpperCase()+D.slice(1)},D))}),l.jsx("div",{className:"agent-task-rows",children:T.length>0?T.map(D=>l.jsx(Mk,{operation:n,state:D},D.deviceId)):l.jsx("small",{className:"agent-task-no-results",children:"No targets match this filter."})})]}),(h||j)&&l.jsxs("div",{className:"agent-task-actions",children:[h&&r&&l.jsxs("button",{onClick:r,disabled:d,type:"button",children:[l.jsx(Gb,{size:14})," Cancel"]}),!h&&j&&c&&l.jsxs("button",{onClick:c,disabled:d,type:"button",children:[l.jsx(tc,{size:14})," Retry failed"]})]})]})}function Nk(n){try{return JSON.stringify(n,null,2).slice(0,6e3)}catch{return"{}"}}function Tk({approval:n,busy:a=!1,onApprove:i,onReject:r}){return l.jsxs("article",{className:"agent-approval-card","aria-label":"Agent approval required",children:[l.jsxs("div",{className:"agent-approval-head",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Approval required"}),l.jsx("strong",{children:n.toolName})]}),l.jsx("span",{className:`agent-approval-risk risk-${n.risk}`,children:n.risk})]}),l.jsx("p",{children:n.description}),l.jsx("pre",{children:Nk(n.arguments)}),l.jsxs("small",{children:["Permission: ",n.permissionMode," · Scope: selected devices only · Expires in 5 minutes"]}),l.jsxs("div",{className:"agent-approval-actions",children:[l.jsxs("button",{className:"reject",disabled:a,onClick:r,type:"button",children:[l.jsx(Hr,{size:14})," Reject"]}),l.jsxs("button",{disabled:a,onClick:()=>i("once"),type:"button",children:[l.jsx(uc,{size:14})," Once"]}),l.jsx("button",{disabled:a,onClick:()=>i("same-action-this-run"),type:"button",children:"Allow same action"}),l.jsx("button",{disabled:a,onClick:()=>i("category-this-run"),type:"button",children:"Allow category"})]}),l.jsxs("div",{className:"agent-approval-scope",children:[l.jsx(yd,{size:13})," Approval is bound to this run, tool, arguments, selected devices, and policy hash."]})]})}function Rk({items:n,onCancel:a,onRetry:i,busyBatchId:r,approvals:c,onApprove:d,onReject:h,busyApprovalId:p}){return l.jsxs("section",{className:"agents-conversation","aria-live":"polite",children:[c.filter(x=>x.status==="pending").map(x=>l.jsx(Tk,{approval:x,busy:p===x.approvalId,onApprove:g=>d(x,g),onReject:()=>h(x)},x.approvalId)),n.length===0&&l.jsxs("div",{className:"agents-empty-conversation",children:[l.jsx("strong",{children:"Ask LiveDesk to work across your machines."}),l.jsx("span",{children:"Start with a read-only request such as “모든 PC에서 ComfyUI가 실행 중인지 확인해줘”."})]}),n.map(x=>{if(x.type==="task"){const g=x;return l.jsx(Ak,{operation:g.operation,states:g.states,status:g.status,onCancel:()=>a(g.batchId,g.agentRunId),onRetry:()=>i(g.batchId),busy:r===g.batchId},g.id)}return l.jsxs("article",{className:`agents-message ${x.type}`,children:[l.jsx("span",{children:x.type==="user"?"You":"LiveDesk Agent"}),l.jsx("p",{children:x.text})]},x.id)})]})}const Ev=["Recommended","Health & capacity","Processes & services","AI workloads","Files & configuration","Software & automation","Network & connectivity","Power & maintenance","Troubleshooting & recovery"],tn=["windows","macos","linux"],ti={"system.health":{label:"system health",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:tn},"gpu.status":{label:"GPU status",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:tn},"disk.status":{label:"disk status",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:tn},"process.list":{label:"process inspection",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:tn},"service.status":{label:"service inspection",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:tn},"diagnostics.collect":{label:"diagnostics collection",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:tn},"process.control":{label:"process control",permissionCategory:"processControl",readOnly:!1,risk:"high",supportedPlatforms:tn},"service.control":{label:"service control",permissionCategory:"serviceControl",readOnly:!1,risk:"high",supportedPlatforms:["windows","linux"]},"application.launch":{label:"application launch",permissionCategory:"applicationControl",readOnly:!1,risk:"medium",supportedPlatforms:tn},"application.close":{label:"application close",permissionCategory:"applicationControl",readOnly:!1,risk:"medium",supportedPlatforms:tn},"file.read":{label:"file reading",permissionCategory:"fileRead",readOnly:!0,risk:"low",supportedPlatforms:tn},"file.write":{label:"file writing",permissionCategory:"fileWrite",readOnly:!1,risk:"high",supportedPlatforms:tn},"file.delete":{label:"file deletion",permissionCategory:"fileDelete",readOnly:!1,risk:"critical",supportedPlatforms:tn},"file.list":{label:"directory listing",permissionCategory:"fileRead",readOnly:!0,risk:"low",supportedPlatforms:tn},"command.run":{label:"command execution",permissionCategory:"shell",readOnly:!1,risk:"critical",supportedPlatforms:tn},"script.run":{label:"script execution",permissionCategory:"script",readOnly:!1,risk:"high",supportedPlatforms:tn},"software.install":{label:"software installation",permissionCategory:"softwareInstall",readOnly:!1,risk:"high",supportedPlatforms:tn},"network.status":{label:"network inspection",permissionCategory:"network",readOnly:!0,risk:"low",supportedPlatforms:tn},"system.power":{label:"power control",permissionCategory:"systemPower",readOnly:!1,risk:"critical",supportedPlatforms:tn},"system.configure":{label:"system configuration",permissionCategory:"systemConfiguration",readOnly:!1,risk:"critical",supportedPlatforms:tn},"logs.collect":{label:"log collection",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:tn}};new Set(Object.keys(ti));const Ek={Recommended:["recommended","overview","fleet","요약","추천"],"Health & capacity":["health","capacity","performance","상태","성능","용량"],"Processes & services":["process","service","application","프로세스","서비스","앱"],"AI workloads":["ai","gpu","comfyui","ollama","인공지능","모델"],"Files & configuration":["file","config","directory","파일","설정","폴더"],"Software & automation":["software","install","automation","프로그램","설치","자동화"],"Network & connectivity":["network","connection","adapter","네트워크","연결","어댑터"],"Power & maintenance":["power","maintenance","restart","전원","유지보수","재시작"],"Troubleshooting & recovery":["troubleshooting","recovery","incident","문제해결","복구","장애"]},Dv=["low","medium","high","critical"];function Dk(n){return n.reduce((a,i)=>{const r=ti[i].risk;return Dv.indexOf(r)>Dv.indexOf(a)?r:a},"low")}function Lk(n){return tn.filter(a=>n.every(i=>ti[i].supportedPlatforms.includes(a)))}function Ee(n,a,i,r,c,d,h={}){const p=h.description||r,x=c.flatMap(w=>w.split(".")),g=[...new Set([...Ek[a],...d,...x])];return{id:n,category:a,title:i,prompt:r,description:p,requiredOperations:c,risk:h.risk||Dk(c),targetSupport:h.targetSupport||"single-or-multiple",supportedPlatforms:h.supportedPlatforms||Lk(c),keywords:g,recommended:h.recommended??!1,enabled:!0}}const aw=[Ee("recommended-fleet-health","Recommended","Summarize current target health","Summarize system health, GPU, and disk capacity for the current target workstations.",["system.health","gpu.status","disk.status"],["summary","overview"],{recommended:!0}),Ee("recommended-attention","Recommended","Find targets needing attention","Identify current targets with high resource use, low disk space, or service warnings.",["system.health","disk.status","service.status"],["attention","warning","monitor"],{recommended:!0}),Ee("recommended-performance-compare","Recommended","Compare selected performance","Compare CPU, memory, disk, and GPU capacity across the current targets.",["system.health","disk.status","gpu.status"],["compare","benchmark"],{recommended:!0}),Ee("recommended-gpu-vram","Recommended","Review GPU and VRAM availability","Show GPU temperature, utilization, and VRAM availability for the current targets.",["gpu.status"],["graphics","temperature","utilization"],{recommended:!0}),Ee("recommended-low-disk","Recommended","Locate low disk capacity","Find current targets with low free disk capacity and report the affected volumes.",["disk.status"],["storage","free space","capacity"],{recommended:!0}),Ee("recommended-ai-workers","Recommended","Verify ComfyUI and Ollama workers","Check whether ComfyUI and Ollama workers and their services are available on the current targets.",["process.list","service.status"],["comfyui","ollama","worker"],{recommended:!0}),Ee("recommended-recover-ai","Recommended","Recover stopped AI workers","Find stopped AI workers and relaunch the registered worker application or service on the target workstation.",["process.list","application.launch","service.control"],["recover","start","ai worker"],{targetSupport:"single",recommended:!0}),Ee("recommended-incident-diagnostics","Recommended","Collect an incident diagnostic bundle","Collect health, service, network, and recent log diagnostics for the current targets.",["diagnostics.collect","logs.collect","system.health","network.status"],["incident","report","evidence"],{recommended:!0}),Ee("health-cpu-memory","Health & capacity","Check high CPU and memory use","Find current targets with unusually high CPU or memory usage.",["system.health"],["cpu","memory","load","높은 사용량"]),Ee("health-uptime","Health & capacity","Review workstation uptime","Show uptime, boot time, and current system health for the target workstations.",["system.health"],["uptime","boot","가동시간"]),Ee("health-gpu-temperature","Health & capacity","Check GPU temperature","Check GPU temperature and thermal warnings on the current targets.",["gpu.status"],["thermal","temperature","발열"]),Ee("health-vram-usage","Health & capacity","Check VRAM usage","Report GPU memory usage and remaining VRAM on the current targets.",["gpu.status"],["vram","gpu memory","video memory"]),Ee("health-low-disk","Health & capacity","Find low disk space","Find volumes below a safe free-space threshold on the current targets.",["disk.status"],["disk","storage","free space","디스크"]),Ee("health-gpu-compare","Health & capacity","Compare GPU capacity","Compare GPU model, memory, temperature, and utilization across the current targets.",["gpu.status"],["compare","graphics","capacity"]),Ee("health-system-warnings","Health & capacity","Collect system warnings","Review health, disk, and network status for warnings that need attention.",["system.health","disk.status","network.status"],["warnings","alerts","경고"]),Ee("health-capacity-report","Health & capacity","Build a capacity report","Create a concise capacity report covering CPU, memory, GPU, disk, and network status.",["system.health","gpu.status","disk.status","network.status"],["report","capacity","inventory"]),Ee("process-find-name","Processes & services","Find a running process by name","Find process named [process name] on the current targets.",["process.list"],["find","running","name","실행 중"]),Ee("process-resource-heavy","Processes & services","Find resource-heavy processes","List the processes using the most CPU or memory on the current targets.",["process.list","system.health"],["top","cpu","memory","resource"]),Ee("process-stop-named","Processes & services","Stop a named process","Stop process named [process name] on the target workstation after checking its current state.",["process.list","process.control"],["stop","terminate","종료"],{targetSupport:"single"}),Ee("process-restart-named","Processes & services","Restart a named process","Check process named [process name] and restart it with its registered launch details when available.",["process.list","process.control"],["restart","relaunch","재시작"],{targetSupport:"single"}),Ee("process-launch-app","Processes & services","Launch a registered application","Launch the registered application [application] on the target workstation with [arguments].",["application.launch"],["launch","open","실행"],{targetSupport:"single"}),Ee("process-close-app","Processes & services","Close an application","Close application [application] on the target workstation and report whether it exited cleanly.",["application.close","process.list"],["close","exit","앱 종료"],{targetSupport:"single"}),Ee("service-status-name","Processes & services","Check a service status","Check service [service name] and report its state on the current targets.",["service.status"],["service","status","서비스 상태"]),Ee("service-restart-name","Processes & services","Restart a service safely","Check service [service name], stop it, wait for it to stop, then start it and verify the result.",["service.status","service.control"],["restart","start","stop","서비스 재시작"],{targetSupport:"single"}),Ee("ai-comfyui-status","AI workloads","Check ComfyUI availability","Check the ComfyUI process, service state, and GPU readiness on the current targets.",["process.list","service.status","gpu.status"],["comfyui","stable diffusion","image generation"]),Ee("ai-start-comfyui","AI workloads","Start ComfyUI","If ComfyUI is stopped, launch its registered application or service and verify it is running.",["process.list","application.launch","service.status"],["comfyui","start","launch"],{targetSupport:"single"}),Ee("ai-restart-ollama","AI workloads","Restart Ollama","Check Ollama, restart its registered application or service, and verify the worker is ready.",["process.list","application.close","application.launch","service.status"],["ollama","restart","llm"],{targetSupport:"single"}),Ee("ai-stable-diffusion","AI workloads","Check Stable Diffusion workers","Check Stable Diffusion or Automatic1111 processes and their GPU usage on the current targets.",["process.list","gpu.status"],["stable diffusion","automatic1111","sd"]),Ee("ai-gpu-readiness","AI workloads","Check GPU readiness for AI","Check GPU temperature, VRAM, utilization, and system health before an AI workload starts.",["gpu.status","system.health"],["readiness","inference","training"]),Ee("ai-worker-logs","AI workloads","Collect AI worker logs","Collect recent logs and relevant log files for the AI worker on the target workstation.",["logs.collect","file.list","file.read"],["logs","diagnostics","worker"],{targetSupport:"single"}),Ee("ai-llama-cpp","AI workloads","Check llama.cpp workers","Find llama.cpp or local model worker processes and inspect their recent logs.",["process.list","logs.collect"],["llama.cpp","local model","inference"]),Ee("ai-recover-orphan-python","AI workloads","Recover an orphaned Python worker","Find an orphaned Python AI worker, stop the stale process, then launch its registered worker again.",["process.list","process.control","application.launch"],["python","orphaned","recovery"],{targetSupport:"single"}),Ee("files-list-directory","Files & configuration","List a directory","List files and folders under [path] on the target workstation.",["file.list"],["directory","folder","list","목록"],{targetSupport:"single"}),Ee("files-read-config","Files & configuration","Read a configuration file","Read the relevant settings from configuration file [path] on the target workstation.",["file.read"],["config","settings","read","구성"]),Ee("files-recent-logs","Files & configuration","Find recent log files","List recent log files under [path] and summarize the latest entries.",["file.list","file.read"],["logs","recent","tail"]),Ee("files-update-config","Files & configuration","Update a configuration value","Read configuration file [path], update [change], and report the exact change made.",["file.read","file.write"],["edit","update","설정 변경"],{targetSupport:"single"}),Ee("files-delete-temp","Files & configuration","Delete temporary files","Find temporary files under [path], delete only the requested matches, and report the freed space.",["file.list","file.delete","disk.status"],["cleanup","temp","delete","정리"],{targetSupport:"single"}),Ee("files-compare-config","Files & configuration","Compare configuration files","Read configuration file [path] on the target workstation and compare it with [reference path].",["file.read"],["compare","diff","configuration"]),Ee("files-set-environment","Files & configuration","Set an environment variable","Set environment variable [name] to [value] for the target workstation and verify the resulting configuration.",["system.configure","file.read"],["environment","variable","env","환경변수"],{targetSupport:"single"}),Ee("files-archive-diagnostics","Files & configuration","Write a diagnostic manifest","Collect selected diagnostics and write a manifest file to [path] on the target workstation.",["diagnostics.collect","file.write"],["manifest","export","diagnostic file"],{targetSupport:"single"}),Ee("software-winget-install","Software & automation","Install software with winget","Install package [package name] with winget on the Windows target workstation, then verify it.",["software.install","process.list"],["winget","windows","install","설치"],{targetSupport:"single",supportedPlatforms:["windows"]}),Ee("software-apt-install","Software & automation","Install software with apt","Install package [package name] with apt on the Linux target workstation, then verify it.",["software.install","process.list"],["apt","linux","package","설치"],{targetSupport:"single",supportedPlatforms:["linux"]}),Ee("software-brew-install","Software & automation","Install software with Homebrew","Install package [package name] with brew on the macOS target workstation, then verify it.",["software.install","process.list"],["brew","homebrew","macos","설치"],{targetSupport:"single",supportedPlatforms:["macos"]}),Ee("software-npm-install","Software & automation","Install an npm package","Install npm package [package name] on the target workstation and verify the installed version.",["software.install","command.run"],["npm","node","package"],{targetSupport:"single"}),Ee("software-run-script","Software & automation","Run a registered script","Run the registered script [script path] on the target workstation and report its result.",["script.run"],["script","automation","registered"],{targetSupport:"single"}),Ee("software-run-command","Software & automation","Run a command on one target","Run command [command] on the target workstation and return its exit status and output.",["command.run"],["command","shell","terminal"],{targetSupport:"single"}),Ee("software-verify-install","Software & automation","Verify an installed tool","Check whether [application] is installed, running, and available on the PATH of the current targets.",["process.list","system.health"],["verify","installed","path"]),Ee("software-toolchain-setup","Software & automation","Set up a toolchain","Install the requested package [package name], configure [change], and verify the toolchain on the target workstation.",["software.install","system.configure","process.list"],["toolchain","setup","developer"],{targetSupport:"single"}),Ee("network-adapter-status","Network & connectivity","Check network adapters","Show adapter state, address, and link information for the current targets.",["network.status"],["adapter","ethernet","wifi","네트워크 상태"]),Ee("network-disconnected","Network & connectivity","Find disconnected targets","Find current targets with disconnected or degraded network adapters.",["network.status"],["disconnected","offline","연결 끊김"]),Ee("network-link-speed","Network & connectivity","Check link speed","Report network link speed and duplex information for the current targets.",["network.status"],["speed","bandwidth","duplex"]),Ee("network-warnings","Network & connectivity","Review network warnings","Review network status and recent logs for connectivity warnings on the current targets.",["network.status","logs.collect"],["warning","latency","packet loss"]),Ee("network-diagnostics","Network & connectivity","Collect network diagnostics","Collect network status, system diagnostics, and relevant logs for the current targets.",["network.status","diagnostics.collect","logs.collect"],["diagnostics","incident","connectivity"]),Ee("network-service-failures","Network & connectivity","Find network service failures","Check network status and relevant service states on the current targets.",["network.status","service.status"],["service","failure","dns"]),Ee("network-compare","Network & connectivity","Compare target connectivity","Compare adapter state, addresses, and link speed across the current targets.",["network.status"],["compare","inventory","connectivity"]),Ee("network-intermittent","Network & connectivity","Investigate intermittent connectivity","Investigate intermittent connectivity using network status, service state, and diagnostics evidence.",["network.status","service.status","diagnostics.collect"],["intermittent","unstable","recovery"]),Ee("power-lock","Power & maintenance","Lock the workstation","Lock the target workstation and report the resulting power action status.",["system.power"],["lock","security","잠금"],{targetSupport:"single",risk:"critical"}),Ee("power-logoff","Power & maintenance","Log off the workstation","Log off the target workstation after warning that interactive sessions will close.",["system.power"],["logoff","session","로그오프"],{targetSupport:"single",risk:"critical"}),Ee("power-sleep","Power & maintenance","Put the workstation to sleep","Put the target workstation to sleep after confirming the requested delay of [delay].",["system.power"],["sleep","suspend","절전"],{targetSupport:"single",risk:"critical"}),Ee("power-restart","Power & maintenance","Restart the workstation","Restart the target workstation after confirming that active work may be interrupted.",["system.power"],["restart","reboot","재부팅"],{targetSupport:"single",risk:"critical"}),Ee("power-shutdown","Power & maintenance","Shut down the workstation","Shut down the target workstation after confirming that active work may be interrupted.",["system.power"],["shutdown","power off","종료"],{targetSupport:"single",risk:"critical"}),Ee("power-maintenance-restart","Power & maintenance","Restart after maintenance","Check the target workstation, restart it after maintenance, and verify that it returns online.",["system.health","system.power","network.status"],["maintenance","reboot","verify"],{targetSupport:"single",risk:"critical"}),Ee("power-timezone","Power & maintenance","Set the workstation timezone","Set the target workstation timezone to [timezone] and verify the resulting system configuration.",["system.configure"],["timezone","clock","시간대"],{targetSupport:"single",risk:"critical"}),Ee("power-persistent-environment","Power & maintenance","Persist an environment variable","Persist environment variable [name] with value [value] for the target workstation and verify it.",["system.configure"],["environment","persistent","환경변수"],{targetSupport:"single",risk:"critical"}),Ee("recovery-app-wont-start","Troubleshooting & recovery","Investigate an app that will not start","Inspect [application], review its logs, launch the registered application, and verify the process.",["process.list","application.launch","logs.collect"],["app failure","start","실행 오류"],{targetSupport:"single"}),Ee("recovery-failed-service","Troubleshooting & recovery","Recover a failed service","Inspect service [service name], collect logs, restart it safely, and verify its running state.",["service.status","logs.collect","service.control"],["service failure","recover","서비스 복구"],{targetSupport:"single"}),Ee("recovery-repeated-process","Troubleshooting & recovery","Investigate a repeatedly stopping process","Inspect process [process name], collect diagnostics, stop stale instances, and relaunch the registered process.",["process.list","diagnostics.collect","process.control","application.launch"],["crash loop","process","반복 종료"],{targetSupport:"single"}),Ee("recovery-low-disk","Troubleshooting & recovery","Recover from low disk space","Inspect disk capacity, find temporary files, remove only the requested files, and verify free space.",["disk.status","file.list","file.delete"],["disk full","cleanup","저장공간 부족"],{targetSupport:"single"}),Ee("recovery-gpu-overheating","Troubleshooting & recovery","Investigate GPU overheating","Inspect GPU temperature and processes, then close the specified workload if it is causing the thermal warning.",["gpu.status","process.list","application.close"],["overheating","thermal","GPU 발열"],{targetSupport:"single"}),Ee("recovery-high-vram","Troubleshooting & recovery","Recover high VRAM usage","Inspect VRAM usage and GPU processes, then stop the specified stale workload if necessary.",["gpu.status","process.list","process.control"],["vram","memory pressure","VRAM 부족"],{targetSupport:"single"}),Ee("recovery-network-instability","Troubleshooting & recovery","Recover network instability","Collect network diagnostics, inspect network services, and report the safest recovery action for the target workstation.",["network.status","service.status","diagnostics.collect"],["network","unstable","네트워크 복구"],{targetSupport:"single"}),Ee("recovery-incident-report","Troubleshooting & recovery","Create a full incident report","Create a full incident report from health, process, service, network, and log evidence for the current targets.",["system.health","process.list","service.status","network.status","logs.collect"],["incident","report","장애 보고서"])],Em={read:"allow",processControl:"allow",serviceControl:"allow",applicationControl:"ask",fileRead:"allow",fileWrite:"allow",fileDelete:"ask",shell:"ask",script:"ask",softwareInstall:"ask",network:"allow",systemPower:"ask",systemConfiguration:"ask",userAccount:"deny"};function zk(n,a){return n==="safe-auto"?Em:n==="full-access"?{...Em,processControl:"allow",serviceControl:"allow",applicationControl:"allow",fileDelete:"allow",shell:"allow",script:"allow",softwareInstall:"allow",systemPower:"allow",systemConfiguration:"allow"}:n==="custom"&&a?a:{...Em,processControl:"ask",serviceControl:"ask",applicationControl:"ask",fileWrite:"ask",network:"ask"}}function _k(n,a,i){const r=zk(a,i),c=n.requiredOperations.map(d=>r[ti[d].permissionCategory]);if(c.includes("deny")){const d=n.requiredOperations.find(h=>r[ti[h].permissionCategory]==="deny");return{state:"blocked",label:"Blocked",reason:`This task requires ${ti[d].label}, which is blocked by the current permission policy.`}}return c.includes("ask")?{state:"approval",label:"Approval required",reason:"This task requires approval before the requested changes can reach a workstation."}:n.requiredOperations.every(d=>ti[d].readOnly)?{state:"read-only",label:"Read only"}:a==="full-access"?{state:"full-access",label:"Full Access"}:{state:"auto",label:"Auto allowed"}}function Ok(n){const a=String(n||"").trim().toLowerCase();return a==="windows"||a==="win32"||a==="win32nt"?"windows":a==="macos"||a==="macosx"||a==="darwin"||a==="osx"?"macos":a==="linux"?"linux":null}function Ik(n,a,i){const r=new Set(i);return n.filter(c=>c.connected&&(a==="all"||r.has(c.deviceId)))}function Bk(n,a){const i=Ok(n.platform);if(!i||!a.supportedPlatforms.includes(i))return!1;const r=n.capabilities?.agentTools;return!Array.isArray(r)||r.length===0?a.requiredOperations.every(c=>ti[c].readOnly):a.requiredOperations.every(c=>r.includes(c))}function sw(n,a,i,r,c,d){const h=_k(n,c,d),p=Ik(a,i,r),x=p.map(k=>k.deviceId),g={...h,available:!1,availableDeviceIds:[],unsupportedDeviceIds:x,risk:n.risk,supportedPlatforms:n.supportedPlatforms};if(p.length===0)return{...g,reason:"Select at least one connected workstation."};if(n.targetSupport==="single"&&p.length!==1)return{...g,reason:"This task supports one workstation at a time."};if(h.state==="blocked")return g;const w=p.filter(k=>Bk(k,n)),v=w.map(k=>k.deviceId),b=x.filter(k=>!v.includes(k));return w.length===0?{...g,unsupportedDeviceIds:b,reason:"No current target supports the required platform and client capabilities."}:{...g,available:!0,availableDeviceIds:v,unsupportedDeviceIds:b}}function Fk(n,a,i,r,c,d){return n.filter(h=>h.enabled&&sw(h,a,i,r,c,d).available).length}const Dm="livedesk.agentPromptRecent",Lm="livedesk.agentPromptFavorites",Hk={Recommended:Vi,"Health & capacity":nn,"Processes & services":Zb,"AI workloads":Xb,"Files & configuration":Qb,"Software & automation":mh,"Network & connectivity":gh,"Power & maintenance":Sn,"Troubleshooting & recovery":Wb};function Lv(n){if(typeof window>"u")return[];try{const a=JSON.parse(window.localStorage.getItem(n)||"[]");return Array.isArray(a)?a.filter(i=>typeof i=="string"):[]}catch{return[]}}function Ku(n,a){try{window.localStorage.setItem(n,JSON.stringify(a))}catch{}}function zm(n){return n==="all"?"All tasks":n==="recent"?"Recent":n==="favorites"?"Favorites":n==="read-only"?"Read only":n==="auto"?"Auto allowed":n==="approval"?"Approval required":n==="full-access"?"Full Access":n==="available"?"Available":n==="unavailable"?"Unavailable":n}function $k(n){return n==="all"?"All":n==="recent"?"Recent":n==="favorites"?"Favorites":n==="read-only"?"Read only":n==="auto"?"Auto":n==="approval"?"Approval":n==="full-access"?"Full access":n==="available"?"Available":n==="unavailable"?"Unavailable":{Recommended:"Recommended","Health & capacity":"Health","Processes & services":"Processes","AI workloads":"AI","Files & configuration":"Files","Software & automation":"Software","Network & connectivity":"Network","Power & maintenance":"Power","Troubleshooting & recovery":"Recovery"}[n]}function Uk(n,a,i){if(!i.trim())return!0;const r=i.trim().toLowerCase();return[n.title,n.prompt,n.description,n.category,n.risk,a.label,...n.keywords,...n.requiredOperations,...n.supportedPlatforms].join(" ").toLowerCase().includes(r)}function Pk(n){return`permission-${n}`}function qk(n){return n==="low"?"Low risk":n==="medium"?"Medium risk":n==="high"?"High risk":"Critical risk"}function Gk(n){return n==="windows"?"Windows":n==="macos"?"macOS":"Linux"}function Yk({devices:n,targetMode:a,selectedIds:i,permissionMode:r,customCategories:c,onSelectPrompt:d,onClose:h}){const[p,x]=f.useState(""),[g,w]=f.useState("all"),[v,b]=f.useState(()=>Lv(Dm)),[k,j]=f.useState(()=>Lv(Lm)),[M,T]=f.useState(0),[C,A]=f.useState(""),D=f.useRef(null),H=f.useRef(null),B=f.useMemo(()=>aw.filter(K=>K.enabled),[]),q=f.useMemo(()=>new Map(B.map(K=>[K.id,sw(K,n,a,i,r,c)])),[c,n,r,i,a,B]),L=f.useMemo(()=>[...q.values()].filter(K=>K.available).length,[q]),F=f.useMemo(()=>n.filter(K=>K.connected&&(a==="all"||i.includes(K.deviceId))).length,[n,i,a]),ue=f.useMemo(()=>{const K=B.filter(z=>Uk(z,q.get(z.id),p));return g==="recent"?v.map(z=>K.find(Y=>Y.id===z)).filter(z=>!!z):g==="favorites"?k.map(z=>K.find(Y=>Y.id===z)).filter(z=>!!z):g==="all"?K:K.filter(z=>{const Y=q.get(z.id);return g==="read-only"?Y.state==="read-only":g==="auto"?Y.state==="auto":g==="approval"?Y.state==="approval":g==="full-access"?Y.state==="full-access":g==="available"?Y.available:g==="unavailable"?!Y.available:z.category===g})},[q,k,g,v,p,B]),W=f.useMemo(()=>g!=="all"?[{category:zm(g),templates:ue}]:Ev.map(K=>({category:K,templates:ue.filter(z=>z.category===K)})).filter(K=>K.templates.length>0),[g,ue]);f.useEffect(()=>{T(K=>Math.min(K,Math.max(0,ue.length-1)))},[ue.length]),f.useEffect(()=>{Ku(Dm,v)},[v]),f.useEffect(()=>{Ku(Lm,k)},[k]),f.useEffect(()=>{H.current?.focus();const K=Y=>{Y.target instanceof Node&&!D.current?.contains(Y.target)&&h()},z=Y=>{Y.key==="Escape"&&(Y.preventDefault(),h())};return document.addEventListener("pointerdown",K),document.addEventListener("keydown",z),()=>{document.removeEventListener("pointerdown",K),document.removeEventListener("keydown",z)}},[h]);const ce=K=>{const z=q.get(K.id);if(!z.available){A(z.reason||"This task is not available for the current targets and permission policy.");return}const Y=[K.id,...v.filter(U=>U!==K.id)].slice(0,10);b(Y),Ku(Dm,Y),d(K.prompt),h()},Q=K=>{j(z=>{const Y=z.includes(K)?z.filter(U=>U!==K):[K,...z];return Ku(Lm,Y),Y})},se=K=>{K.key==="ArrowDown"?(K.preventDefault(),T(z=>Math.min(z+1,Math.max(0,ue.length-1)))):K.key==="ArrowUp"?(K.preventDefault(),T(z=>Math.max(z-1,0))):K.key==="Enter"&&ue[M]&&(K.preventDefault(),ce(ue[M]))};let oe=-1;return l.jsxs("section",{className:"agents-suggested-tasks",ref:D,"aria-label":"Suggested tasks",children:[l.jsxs("header",{className:"agents-suggested-header",children:[l.jsxs("div",{children:[l.jsxs("span",{className:"agents-suggested-title",children:[l.jsx(Vi,{size:15})," Suggested tasks"]}),l.jsxs("small",{children:[L," available · ",B.length," total. Choose a task, edit it, then run it."]})]}),l.jsx("button",{className:"agents-suggested-close",type:"button","aria-label":"Close suggested tasks",onClick:h,children:l.jsx(Hr,{size:16})})]}),l.jsxs("label",{className:"agents-suggested-search",children:[l.jsx(Yb,{size:15,"aria-hidden":"true"}),l.jsx("input",{ref:H,value:p,onChange:K=>x(K.target.value),onKeyDown:se,placeholder:"Search tasks...","aria-label":"Search suggested tasks"})]}),l.jsx("div",{className:"agents-suggested-filters","aria-label":"Task categories and availability filters",children:["all","recent","favorites","read-only","auto","approval","full-access","available","unavailable",...Ev].map(K=>{const z=K==="recent"?Vb:K==="favorites"?Ym:K==="all"?Vi:K==="available"?qn:K==="unavailable"?Kb:K==="read-only"||K==="auto"||K==="approval"||K==="full-access"?Sn:Hk[K];return l.jsxs("button",{className:g===K?"active":"",type:"button",title:zm(K),"aria-label":zm(K),"aria-pressed":g===K,onClick:()=>{w(K),T(0),A("")},children:[l.jsx(z,{size:12})," ",$k(K)]},K)})}),C&&l.jsx("div",{className:"agents-suggested-notice",role:"status",children:C}),l.jsxs("div",{className:"agents-suggested-list",role:"listbox","aria-label":"Suggested tasks",children:[W.map(K=>l.jsxs("div",{className:"agents-suggested-group",children:[l.jsx("strong",{children:K.category}),K.templates.map(z=>{oe+=1;const Y=oe===M,U=k.includes(z.id),R=q.get(z.id),J=R.availableDeviceIds.length+R.unsupportedDeviceIds.length||F,he=R.available?`Available on ${R.availableDeviceIds.length} of ${J} target${J===1?"":"s"}`:`Unavailable: ${R.reason||"not supported by the current targets"}`;return l.jsxs("div",{className:`agents-suggested-item ${Y?"active":""} ${R.available?"":"unavailable"}`,children:[l.jsxs("button",{className:"agents-suggested-prompt",type:"button",role:"option","aria-selected":Y,"aria-disabled":!R.available,onClick:()=>ce(z),children:[l.jsx("span",{children:z.title}),l.jsx("small",{className:"agents-suggested-description",children:z.description}),l.jsxs("span",{className:"agents-suggested-meta",children:[l.jsx("em",{children:z.category}),l.jsx("em",{className:Pk(R.state),children:R.label}),l.jsx("em",{className:`risk-${z.risk}`,children:qk(z.risk)}),l.jsx("em",{children:z.supportedPlatforms.map(Gk).join(" · ")}),l.jsx("em",{className:R.available?"availability-ok":"availability-unavailable",children:he}),R.available&&R.unsupportedDeviceIds.length>0&&l.jsxs("em",{className:"availability-warning",children:["Unsupported on ",R.unsupportedDeviceIds.length]})]})]}),l.jsx("button",{className:`agents-suggested-favorite ${U?"favorite":""}`,type:"button","aria-label":U?`Remove ${z.title} from favorites`:`Add ${z.title} to favorites`,"aria-pressed":U,onClick:()=>Q(z.id),children:l.jsx(Ym,{size:14,fill:U?"currentColor":"none"})})]},z.id)})]},K.category)),ue.length===0&&l.jsx("p",{className:"agents-suggested-empty",children:"No tasks match this search or current filter."})]})]})}function Vk({devices:n,mode:a,selectedIds:i,onModeChange:r,onToggle:c,permissionMode:d,onPermissionModeChange:h}){const p=n.filter(g=>g.connected),x=i.filter(g=>p.some(w=>w.deviceId===g)).length;return l.jsxs("section",{className:"agents-target-picker","aria-label":"Agent targets",children:[l.jsxs("div",{className:"agents-target-toolbar",children:[l.jsx("span",{className:"agents-section-label",children:"Targets"}),l.jsxs("div",{className:"agents-target-modes",children:[l.jsxs("button",{className:a==="all"?"active":"",onClick:()=>r("all"),type:"button",children:[l.jsx(sy,{size:14})," All connected ",l.jsx("small",{children:p.length})]}),l.jsxs("button",{className:a==="selected"?"active":"",onClick:()=>r("selected"),type:"button",children:[l.jsx(uc,{size:14})," Selected ",x]})]}),l.jsxs("label",{className:`agents-permission-picker permission-${d}`,children:[l.jsx(yd,{size:14}),l.jsx("span",{children:"Permission"}),l.jsxs("select",{value:d,onChange:g=>h(g.target.value),"aria-label":"Agent permission mode",children:[l.jsx("option",{value:"ask",children:"Ask"}),l.jsx("option",{value:"safe-auto",children:"Safe Auto"}),l.jsx("option",{value:"full-access",children:"Full Access"}),l.jsx("option",{value:"custom",children:"Custom"})]}),l.jsx(iy,{size:13,"aria-hidden":"true"})]})]}),l.jsx("div",{className:"agents-target-list",children:n.length===0?l.jsx("span",{className:"agents-target-empty",children:"No workstations discovered."}):n.map(g=>{const w=a==="all"?g.connected:i.includes(g.deviceId);return l.jsxs("label",{className:`agents-target-option ${w?"selected":""} ${g.connected?"":"offline"}`,children:[l.jsx("input",{type:"checkbox",checked:w,disabled:!g.connected||a==="all",onChange:()=>c(g.deviceId)}),l.jsx("span",{className:"agents-target-icon",children:l.jsx(an,{size:15})}),l.jsxs("span",{children:[l.jsx("strong",{children:nw(g)}),l.jsx("small",{children:g.connected?"Connected":"Offline"})]}),w&&l.jsx(uc,{className:"agents-target-check",size:15,"aria-hidden":"true"})]},g.deviceId)})})]})}async function Kk(n,a){return Be("/api/settings/agent/plan",{method:"POST",body:JSON.stringify({instruction:a})},n)}async function Wk(n,a){return Be("/api/settings/agent/run",{method:"POST",body:JSON.stringify(a)},n)}async function Qk(n,a){return Be(`/api/settings/agent/runs/${encodeURIComponent(a)}`,void 0,n)}async function Xk(n,a){return Be(`/api/settings/agent/runs/${encodeURIComponent(a)}/cancel`,{method:"POST",body:JSON.stringify({})},n)}async function Zk(n){return Be("/api/settings/agent/runs/cancel-all",{method:"POST",body:JSON.stringify({})},n)}async function Jk(n,a,i,r){return Be(`/api/settings/agent/runs/${encodeURIComponent(a)}/approvals/${encodeURIComponent(i)}/approve`,{method:"POST",body:JSON.stringify({scope:r})},n)}async function eM(n,a,i,r="User rejected this action."){return Be(`/api/settings/agent/runs/${encodeURIComponent(a)}/approvals/${encodeURIComponent(i)}/reject`,{method:"POST",body:JSON.stringify({reason:r})},n)}async function tM(n,a,i){return Be(`/api/settings/agent/policies/${encodeURIComponent(a)}`,{method:"PUT",body:JSON.stringify({categories:i})},n)}async function nM(n,a){return Be("/api/settings/agent/summary",{method:"POST",body:JSON.stringify(a)},n)}async function aM(n,a){return Be("/api/remote/tasks",{method:"POST",body:JSON.stringify({instruction:a.instruction,deviceIds:a.deviceIds,operation:a.operation,targetQuery:a.targetQuery,approvalLevel:"read-only"})},n)}async function sM(n,a){return Be(`/api/remote/tasks/${encodeURIComponent(a)}`,void 0,n)}async function lM(n,a){return Be(`/api/remote/tasks/${encodeURIComponent(a)}/cancel`,{method:"POST",body:JSON.stringify({})},n)}async function iM(n,a){return Be(`/api/remote/tasks/${encodeURIComponent(a)}/retry`,{method:"POST",body:JSON.stringify({failedOnly:!0})},n)}function Hi(n){return`${n}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function Wu(n,a){const i=new Map(a.map(r=>[r.deviceId,nw(r)]));return n.results.map(r=>({deviceId:r.deviceId,deviceName:r.deviceName||i.get(r.deviceId)||r.deviceId,status:vk(r.status),stage:r.stage||(r.status==="running"?"Checking processes":void 0),result:r.result,data:r.data,error:r.error,sequence:Number.isSafeInteger(r.sequence)?r.sequence:0}))}function rM(n,a){const i=new Map(a.map(r=>[r.deviceId,r]));return n.map(r=>{const c=i.get(r.deviceId);return!c||c.sequence<=r.sequence?r:c})}function oM(n,a){const i=a.filter(d=>d.status==="completed"),r=a.filter(d=>d.status==="failed");if(n.operation==="process.list"){const h=`${i.filter(p=>{const x=p.result||"";return!/not running|no process/i.test(x)&&/running|online|found/i.test(x)}).length}대에서 요청한 프로세스가 실행 중입니다.`;return r.length>0?`${h}
|
|
8
|
+
`+o.stack}}var je=Object.prototype.hasOwnProperty,ct=n.unstable_scheduleCallback,sn=n.unstable_cancelCallback,ke=n.unstable_shouldYield,Ne=n.unstable_requestPaint,Oe=n.unstable_now,Dt=n.unstable_getCurrentPriorityLevel,Za=n.unstable_ImmediatePriority,Nt=n.unstable_UserBlockingPriority,Gn=n.unstable_NormalPriority,ii=n.unstable_LowPriority,Te=n.unstable_IdlePriority,za=n.log,Ze=n.unstable_setDisableYieldValue,_a=null,Ke=null;function yn(e){if(typeof za=="function"&&Ze(e),Ke&&typeof Ke.setStrictMode=="function")try{Ke.setStrictMode(_a,e)}catch{}}var qt=Math.clz32?Math.clz32:pl,_s=Math.log,Gt=Math.LN2;function pl(e){return e>>>=0,e===0?32:31-(_s(e)/Gt|0)|0}var Oa=256,Ja=262144,ya=4194304;function es(e){var t=e&42;if(t!==0)return t;switch(e&-e){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 e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function ln(e,t,s){var o=e.pendingLanes;if(o===0)return 0;var u=0,m=e.suspendedLanes,S=e.pingedLanes;e=e.warmLanes;var N=o&134217727;return N!==0?(o=N&~m,o!==0?u=es(o):(S&=N,S!==0?u=es(S):s||(s=N&~e,s!==0&&(u=es(s))))):(N=o&~m,N!==0?u=es(N):S!==0?u=es(S):s||(s=o&~e,s!==0&&(u=es(s)))),u===0?0:t!==0&&t!==u&&(t&m)===0&&(m=u&-u,s=t&-t,m>=s||m===32&&(s&4194048)!==0)?t:u}function Hn(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Yn(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+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 t+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 gl(){var e=ya;return ya<<=1,(ya&62914560)===0&&(ya=4194304),e}function Ia(e){for(var t=[],s=0;31>s;s++)t.push(e);return t}function Ba(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Ss(e,t,s,o,u,m){var S=e.pendingLanes;e.pendingLanes=s,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=s,e.entangledLanes&=s,e.errorRecoveryDisabledLanes&=s,e.shellSuspendCounter=0;var N=e.entanglements,I=e.expirationTimes,te=e.hiddenUpdates;for(s=S&~s;0<s;){var fe=31-qt(s),ve=1<<fe;N[fe]=0,I[fe]=-1;var ae=te[fe];if(ae!==null)for(te[fe]=null,fe=0;fe<ae.length;fe++){var re=ae[fe];re!==null&&(re.lane&=-536870913)}s&=~ve}o!==0&&ts(e,o,0),m!==0&&u===0&&e.tag!==0&&(e.suspendedLanes|=m&~(S&~t))}function ts(e,t,s){e.pendingLanes|=t,e.suspendedLanes&=~t;var o=31-qt(t);e.entangledLanes|=t,e.entanglements[o]=e.entanglements[o]|1073741824|s&261930}function Vn(e,t){var s=e.entangledLanes|=t;for(e=e.entanglements;s;){var o=31-qt(s),u=1<<o;u&t|e[o]&t&&(e[o]|=t),s&=~u}}function wa(e,t){var s=t&-t;return s=(s&42)!==0?1:Fa(s),(s&(e.suspendedLanes|t))!==0?0:s}function Fa(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=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:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function ns(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function as(){var e=Y.p;return e!==0?e:(e=window.event,e===void 0?32:xx(e.type))}function Os(e,t){var s=Y.p;try{return Y.p=e,t()}finally{Y.p=s}}var Kn=Math.random().toString(36).slice(2),X="__reactFiber$"+Kn,Se="__reactProps$"+Kn,De="__reactContainer$"+Kn,Je="__reactEvents$"+Kn,Tt="__reactListeners$"+Kn,ut="__reactHandles$"+Kn,Ue="__reactResources$"+Kn,at="__reactMarker$"+Kn;function Rt(e){delete e[X],delete e[Se],delete e[Je],delete e[Tt],delete e[ut]}function _t(e){var t=e[X];if(t)return t;for(var s=e.parentNode;s;){if(t=s[De]||s[X]){if(s=t.alternate,t.child!==null||s!==null&&s.child!==null)for(e=tx(e);e!==null;){if(s=e[X])return s;e=tx(e)}return t}e=s,s=e.parentNode}return null}function Yt(e){if(e=e[X]||e[De]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function xt(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(r(33))}function Ot(e){var t=e[Ue];return t||(t=e[Ue]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function vt(e){e[at]=!0}var Wn=new Set,Qn={};function Vt(e,t){It(e,t),It(e+"Capture",t)}function It(e,t){for(Qn[e]=t,e=0;e<t.length;e++)Wn.add(t[e])}var xl=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]*$"),ss={},Cs={};function Pr(e){return je.call(Cs,e)?!0:je.call(ss,e)?!1:xl.test(e)?Cs[e]=!0:(ss[e]=!0,!1)}function ri(e,t,s){if(Pr(t))if(s===null)e.removeAttribute(t);else{switch(typeof s){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var o=t.toLowerCase().slice(0,5);if(o!=="data-"&&o!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+s)}}function ba(e,t,s){if(s===null)e.removeAttribute(t);else{switch(typeof s){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+s)}}function Mn(e,t,s,o){if(o===null)e.removeAttribute(s);else{switch(typeof o){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(s);return}e.setAttributeNS(t,s,""+o)}}function Kt(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function vc(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function qr(e,t,s){var o=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var u=o.get,m=o.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return u.call(this)},set:function(S){s=""+S,m.call(this,S)}}),Object.defineProperty(e,t,{enumerable:o.enumerable}),{getValue:function(){return s},setValue:function(S){s=""+S},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function yc(e){if(!e._valueTracker){var t=vc(e)?"checked":"value";e._valueTracker=qr(e,t,""+e[t])}}function wc(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var s=t.getValue(),o="";return e&&(o=vc(e)?e.checked?"true":"false":e.value),e=o,e!==s?(t.setValue(e),!0):!1}function ls(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var Nd=/[\n"\\]/g;function mn(e){return e.replace(Nd,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function oi(e,t,s,o,u,m,S,N){e.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?e.type=S:e.removeAttribute("type"),t!=null?S==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+Kt(t)):e.value!==""+Kt(t)&&(e.value=""+Kt(t)):S!=="submit"&&S!=="reset"||e.removeAttribute("value"),t!=null?bc(e,S,Kt(t)):s!=null?bc(e,S,Kt(s)):o!=null&&e.removeAttribute("value"),u==null&&m!=null&&(e.defaultChecked=!!m),u!=null&&(e.checked=u&&typeof u!="function"&&typeof u!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?e.name=""+Kt(N):e.removeAttribute("name")}function Td(e,t,s,o,u,m,S,N){if(m!=null&&typeof m!="function"&&typeof m!="symbol"&&typeof m!="boolean"&&(e.type=m),t!=null||s!=null){if(!(m!=="submit"&&m!=="reset"||t!=null)){yc(e);return}s=s!=null?""+Kt(s):"",t=t!=null?""+Kt(t):s,N||t===e.value||(e.value=t),e.defaultValue=t}o=o??u,o=typeof o!="function"&&typeof o!="symbol"&&!!o,e.checked=N?e.checked:!!o,e.defaultChecked=!!o,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(e.name=S),yc(e)}function bc(e,t,s){t==="number"&&ls(e.ownerDocument)===e||e.defaultValue===""+s||(e.defaultValue=""+s)}function ci(e,t,s,o){if(e=e.options,t){t={};for(var u=0;u<s.length;u++)t["$"+s[u]]=!0;for(s=0;s<e.length;s++)u=t.hasOwnProperty("$"+e[s].value),e[s].selected!==u&&(e[s].selected=u),u&&o&&(e[s].defaultSelected=!0)}else{for(s=""+Kt(s),t=null,u=0;u<e.length;u++){if(e[u].value===s){e[u].selected=!0,o&&(e[u].defaultSelected=!0);return}t!==null||e[u].disabled||(t=e[u])}t!==null&&(t.selected=!0)}}function Sc(e,t,s){if(t!=null&&(t=""+Kt(t),t!==e.value&&(e.value=t),s==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=s!=null?""+Kt(s):""}function Gr(e,t,s,o){if(t==null){if(o!=null){if(s!=null)throw Error(r(92));if(K(o)){if(1<o.length)throw Error(r(93));o=o[0]}s=o}s==null&&(s=""),t=s}s=Kt(t),e.defaultValue=s,o=e.textContent,o===s&&o!==""&&o!==null&&(e.value=o),yc(e)}function Is(e,t){if(t){var s=e.firstChild;if(s&&s===e.lastChild&&s.nodeType===3){s.nodeValue=t;return}}e.textContent=t}var Rd=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 Cc(e,t,s){var o=t.indexOf("--")===0;s==null||typeof s=="boolean"||s===""?o?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":o?e.setProperty(t,s):typeof s!="number"||s===0||Rd.has(t)?t==="float"?e.cssFloat=s:e[t]=(""+s).trim():e[t]=s+"px"}function jc(e,t,s){if(t!=null&&typeof t!="object")throw Error(r(62));if(e=e.style,s!=null){for(var o in s)!s.hasOwnProperty(o)||t!=null&&t.hasOwnProperty(o)||(o.indexOf("--")===0?e.setProperty(o,""):o==="float"?e.cssFloat="":e[o]="");for(var u in t)o=t[u],t.hasOwnProperty(u)&&s[u]!==o&&Cc(e,u,o)}else for(var m in t)t.hasOwnProperty(m)&&Cc(e,m,t[m])}function ui(e){if(e.indexOf("-")===-1)return!1;switch(e){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 kc=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"]]),di=/^[\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 Sa(e){return di.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Xn(){}var Xi=null;function Zi(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ha=null,Bs=null;function Yr(e){var t=Yt(e);if(t&&(e=t.stateNode)){var s=e[Se]||null;e:switch(e=t.stateNode,t.type){case"input":if(oi(e,s.value,s.defaultValue,s.defaultValue,s.checked,s.defaultChecked,s.type,s.name),t=s.name,s.type==="radio"&&t!=null){for(s=e;s.parentNode;)s=s.parentNode;for(s=s.querySelectorAll('input[name="'+mn(""+t)+'"][type="radio"]'),t=0;t<s.length;t++){var o=s[t];if(o!==e&&o.form===e.form){var u=o[Se]||null;if(!u)throw Error(r(90));oi(o,u.value,u.defaultValue,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name)}}for(t=0;t<s.length;t++)o=s[t],o.form===e.form&&wc(o)}break e;case"textarea":Sc(e,s.value,s.defaultValue);break e;case"select":t=s.value,t!=null&&ci(e,!!s.multiple,t,!1)}}}var Ye=!1;function lt(e,t,s){if(Ye)return e(t,s);Ye=!0;try{var o=e(t);return o}finally{if(Ye=!1,(Ha!==null||Bs!==null)&&(mu(),Ha&&(t=Ha,e=Bs,Bs=Ha=null,Yr(t),e)))for(t=0;t<e.length;t++)Yr(e[t])}}function An(e,t){var s=e.stateNode;if(s===null)return null;var o=s[Se]||null;if(o===null)return null;s=o[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(o=!o.disabled)||(e=e.type,o=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!o;break e;default:e=!1}if(e)return null;if(s&&typeof s!="function")throw Error(r(231,t,typeof s));return s}var Ca=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),$a=!1;if(Ca)try{var We={};Object.defineProperty(We,"passive",{get:function(){$a=!0}}),window.addEventListener("test",We,We),window.removeEventListener("test",We,We)}catch{$a=!1}var is=null,Vr=null,Fs=null;function vl(){if(Fs)return Fs;var e,t=Vr,s=t.length,o,u="value"in is?is.value:is.textContent,m=u.length;for(e=0;e<s&&t[e]===u[e];e++);var S=s-e;for(o=1;o<=S&&t[s-o]===u[m-o];o++);return Fs=u.slice(e,1<o?1-o:void 0)}function yl(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function rs(){return!0}function Zn(){return!1}function Wt(e){function t(s,o,u,m,S){this._reactName=s,this._targetInst=u,this.type=o,this.nativeEvent=m,this.target=S,this.currentTarget=null;for(var N in e)e.hasOwnProperty(N)&&(s=e[N],this[N]=s?s(m):m[N]);return this.isDefaultPrevented=(m.defaultPrevented!=null?m.defaultPrevented:m.returnValue===!1)?rs:Zn,this.isPropagationStopped=Zn,this}return v(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var s=this.nativeEvent;s&&(s.preventDefault?s.preventDefault():typeof s.returnValue!="unknown"&&(s.returnValue=!1),this.isDefaultPrevented=rs)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=rs)},persist:function(){},isPersistent:rs}),t}var Qt={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Hs=Wt(Qt),Ae=v({},Qt,{view:0,detail:0}),Mc=Wt(Ae),Kr,Jn,fi,Ji=v({},Ae,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Sl,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==fi&&(fi&&e.type==="mousemove"?(Kr=e.screenX-fi.screenX,Jn=e.screenY-fi.screenY):Jn=Kr=0,fi=e),Kr)},movementY:function(e){return"movementY"in e?e.movementY:Jn}}),wl=Wt(Ji),At=v({},Ji,{dataTransfer:0}),Ac=Wt(At),er=v({},Ae,{relatedTarget:0}),os=Wt(er),Ed=v({},Qt,{animationName:0,elapsedTime:0,pseudoElement:0}),Dd=Wt(Ed),Xt=v({},Qt,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),bl=Wt(Xt),Ld=v({},Qt,{data:0}),Wr=Wt(Ld),cs={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Nc={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"},tr={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function $s(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=tr[e])?!!t[e]:!1}function Sl(){return $s}var hn=v({},Ae,{key:function(e){if(e.key){var t=cs[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=yl(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Nc[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Sl,charCode:function(e){return e.type==="keypress"?yl(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?yl(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),zd=Wt(hn),Tc=v({},Ji,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Us=Wt(Tc),_d=v({},Ae,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Sl}),Zt=Wt(_d),Ps=v({},Qt,{propertyName:0,elapsedTime:0,pseudoElement:0}),us=Wt(Ps),Od=v({},Ji,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),Id=Wt(Od),nr=v({},Qt,{newState:0,oldState:0}),ar=Wt(nr),Rc=[9,13,27,32],js=Ca&&"CompositionEvent"in window,Cl=null;Ca&&"documentMode"in document&&(Cl=document.documentMode);var Ec=Ca&&"TextEvent"in window&&!Cl,Dc=Ca&&(!js||Cl&&8<Cl&&11>=Cl),qs=" ",Lc=!1;function Qr(e,t){switch(e){case"keyup":return Rc.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function zc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var jl=!1;function Bd(e,t){switch(e){case"compositionend":return zc(t);case"keypress":return t.which!==32?null:(Lc=!0,qs);case"textInput":return e=t.data,e===qs&&Lc?null:e;default:return null}}function _c(e,t){if(jl)return e==="compositionend"||!js&&Qr(e,t)?(e=vl(),Fs=Vr=is=null,jl=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Dc&&t.locale!=="ko"?null:t.data;default:return null}}var mi={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 ds(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!mi[e.type]:t==="textarea"}function hi(e,t,s,o){Ha?Bs?Bs.push(o):Bs=[o]:Ha=o,t=wu(t,"onChange"),0<t.length&&(s=new Hs("onChange","change",null,s,o),e.push({event:s,listeners:t}))}var Ua=null,ja=null;function Xr(e){$g(e,0)}function sr(e){var t=xt(e);if(wc(t))return e}function Zr(e,t){if(e==="change")return t}var lr=!1;if(Ca){var pi;if(Ca){var ks="oninput"in document;if(!ks){var Oc=document.createElement("div");Oc.setAttribute("oninput","return;"),ks=typeof Oc.oninput=="function"}pi=ks}else pi=!1;lr=pi&&(!document.documentMode||9<document.documentMode)}function gi(){Ua&&(Ua.detachEvent("onpropertychange",xi),ja=Ua=null)}function xi(e){if(e.propertyName==="value"&&sr(ja)){var t=[];hi(t,ja,e,Zi(e)),lt(Xr,t)}}function Jr(e,t,s){e==="focusin"?(gi(),Ua=t,ja=s,Ua.attachEvent("onpropertychange",xi)):e==="focusout"&&gi()}function eo(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return sr(ja)}function ir(e,t){if(e==="click")return sr(t)}function rr(e,t){if(e==="input"||e==="change")return sr(t)}function to(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var zn=typeof Object.is=="function"?Object.is:to;function Pa(e,t){if(zn(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var s=Object.keys(e),o=Object.keys(t);if(s.length!==o.length)return!1;for(o=0;o<s.length;o++){var u=s[o];if(!je.call(t,u)||!zn(e[u],t[u]))return!1}return!0}function Gs(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function vi(e,t){var s=Gs(e);e=0;for(var o;s;){if(s.nodeType===3){if(o=e+s.textContent.length,e<=t&&o>=t)return{node:s,offset:t-e};e=o}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=Gs(s)}}function kl(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?kl(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function ka(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=ls(e.document);t instanceof e.HTMLIFrameElement;){try{var s=typeof t.contentWindow.location.href=="string"}catch{s=!1}if(s)e=t.contentWindow;else break;t=ls(e.document)}return t}function yi(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}var no=Ca&&"documentMode"in document&&11>=document.documentMode,Ys=null,pn=null,Ml=null,wi=!1;function bi(e,t,s){var o=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;wi||Ys==null||Ys!==ls(o)||(o=Ys,"selectionStart"in o&&yi(o)?o={start:o.selectionStart,end:o.selectionEnd}:(o=(o.ownerDocument&&o.ownerDocument.defaultView||window).getSelection(),o={anchorNode:o.anchorNode,anchorOffset:o.anchorOffset,focusNode:o.focusNode,focusOffset:o.focusOffset}),Ml&&Pa(Ml,o)||(Ml=o,o=wu(pn,"onSelect"),0<o.length&&(t=new Hs("onSelect","select",null,t,s),e.push({event:t,listeners:o}),t.target=Ys)))}function Vs(e,t){var s={};return s[e.toLowerCase()]=t.toLowerCase(),s["Webkit"+e]="webkit"+t,s["Moz"+e]="moz"+t,s}var Ma={animationend:Vs("Animation","AnimationEnd"),animationiteration:Vs("Animation","AnimationIteration"),animationstart:Vs("Animation","AnimationStart"),transitionrun:Vs("Transition","TransitionRun"),transitionstart:Vs("Transition","TransitionStart"),transitioncancel:Vs("Transition","TransitionCancel"),transitionend:Vs("Transition","TransitionEnd")},ao={},Ks={};Ca&&(Ks=document.createElement("div").style,"AnimationEvent"in window||(delete Ma.animationend.animation,delete Ma.animationiteration.animation,delete Ma.animationstart.animation),"TransitionEvent"in window||delete Ma.transitionend.transition);function Ms(e){if(ao[e])return ao[e];if(!Ma[e])return e;var t=Ma[e],s;for(s in t)if(t.hasOwnProperty(s)&&s in Ks)return ao[e]=t[s];return e}var Al=Ms("animationend"),so=Ms("animationiteration"),or=Ms("animationstart"),Ic=Ms("transitionrun"),Fd=Ms("transitionstart"),lo=Ms("transitioncancel"),Bc=Ms("transitionend"),io=new Map,cr="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(" ");cr.push("scrollEnd");function ea(e,t){io.set(e,t),Vt(t,[e])}var ur=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},Nn=[],$n=0,Nl=0;function dr(){for(var e=$n,t=Nl=$n=0;t<e;){var s=Nn[t];Nn[t++]=null;var o=Nn[t];Nn[t++]=null;var u=Nn[t];Nn[t++]=null;var m=Nn[t];if(Nn[t++]=null,o!==null&&u!==null){var S=o.pending;S===null?u.next=u:(u.next=S.next,S.next=u),o.pending=u}m!==0&&Ci(s,u,m)}}function Tl(e,t,s,o){Nn[$n++]=e,Nn[$n++]=t,Nn[$n++]=s,Nn[$n++]=o,Nl|=o,e.lanes|=o,e=e.alternate,e!==null&&(e.lanes|=o)}function Si(e,t,s,o){return Tl(e,t,s,o),ji(e)}function Ce(e,t){return Tl(e,null,null,t),ji(e)}function Ci(e,t,s){e.lanes|=s;var o=e.alternate;o!==null&&(o.lanes|=s);for(var u=!1,m=e.return;m!==null;)m.childLanes|=s,o=m.alternate,o!==null&&(o.childLanes|=s),m.tag===22&&(e=m.stateNode,e===null||e._visibility&1||(u=!0)),e=m,m=m.return;return e.tag===3?(m=e.stateNode,u&&t!==null&&(u=31-qt(s),e=m.hiddenUpdates,o=e[u],o===null?e[u]=[t]:o.push(t),t.lane=s|536870912),m):null}function ji(e){if(50<Eo)throw Eo=0,Ff=null,Error(r(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Rl={};function Ih(e,t,s,o){this.tag=e,this.key=s,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=o,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Tn(e,t,s,o){return new Ih(e,t,s,o)}function ro(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ta(e,t){var s=e.alternate;return s===null?(s=Tn(e.tag,t,e.key,e.mode),s.elementType=e.elementType,s.type=e.type,s.stateNode=e.stateNode,s.alternate=e,e.alternate=s):(s.pendingProps=t,s.type=e.type,s.flags=0,s.subtreeFlags=0,s.deletions=null),s.flags=e.flags&65011712,s.childLanes=e.childLanes,s.lanes=e.lanes,s.child=e.child,s.memoizedProps=e.memoizedProps,s.memoizedState=e.memoizedState,s.updateQueue=e.updateQueue,t=e.dependencies,s.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},s.sibling=e.sibling,s.index=e.index,s.ref=e.ref,s.refCleanup=e.refCleanup,s}function rn(e,t){e.flags&=65011714;var s=e.alternate;return s===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=s.childLanes,e.lanes=s.lanes,e.child=s.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=s.memoizedProps,e.memoizedState=s.memoizedState,e.updateQueue=s.updateQueue,e.type=s.type,t=s.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function wn(e,t,s,o,u,m){var S=0;if(o=e,typeof e=="function")ro(e)&&(S=1);else if(typeof e=="string")S=kb(e,s,we.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case ue:return e=Tn(31,s,t,u),e.elementType=ue,e.lanes=m,e;case M:return et(s.children,u,m,t);case T:S=8,u|=24;break;case C:return e=Tn(12,s,t,u|2),e.elementType=C,e.lanes=m,e;case B:return e=Tn(13,s,t,u),e.elementType=B,e.lanes=m,e;case q:return e=Tn(19,s,t,u),e.elementType=q,e.lanes=m,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case D:S=10;break e;case A:S=9;break e;case H:S=11;break e;case L:S=14;break e;case F:S=16,o=null;break e}S=29,s=Error(r(130,e===null?"null":typeof e,"")),o=null}return t=Tn(S,s,t,u),t.elementType=e,t.type=o,t.lanes=m,t}function et(e,t,s,o){return e=Tn(7,e,o,t),e.lanes=s,e}function oo(e,t,s){return e=Tn(6,e,null,t),e.lanes=s,e}function Fc(e){var t=Tn(18,null,null,0);return t.stateNode=e,t}function co(e,t,s){return t=Tn(4,e.children!==null?e.children:[],e.key,t),t.lanes=s,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Hc=new WeakMap;function na(e,t){if(typeof e=="object"&&e!==null){var s=Hc.get(e);return s!==void 0?s:(t={value:e,source:t,stack:Me(t)},Hc.set(e,t),t)}return{value:e,source:t,stack:Me(t)}}var El=[],Dl=0,fr=null,ki=0,aa=[],sa=0,As=null,qa=1,Ga="";function fs(e,t){El[Dl++]=ki,El[Dl++]=fr,fr=e,ki=t}function $c(e,t,s){aa[sa++]=qa,aa[sa++]=Ga,aa[sa++]=As,As=e;var o=qa;e=Ga;var u=32-qt(o)-1;o&=~(1<<u),s+=1;var m=32-qt(t)+u;if(30<m){var S=u-u%5;m=(o&(1<<S)-1).toString(32),o>>=S,u-=S,qa=1<<32-qt(t)+u|s<<u|o,Ga=m+e}else qa=1<<m|s<<u|o,Ga=e}function Mi(e){e.return!==null&&(fs(e,1),$c(e,1,0))}function Ai(e){for(;e===fr;)fr=El[--Dl],El[Dl]=null,ki=El[--Dl],El[Dl]=null;for(;e===As;)As=aa[--sa],aa[sa]=null,Ga=aa[--sa],aa[sa]=null,qa=aa[--sa],aa[sa]=null}function Uc(e,t){aa[sa++]=qa,aa[sa++]=Ga,aa[sa++]=As,qa=t.id,Ga=t.overflow,As=e}var gn=null,kt=null,it=!1,Ns=null,la=!1,uo=Error(r(519));function Ts(e){var t=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ni(na(t,e)),uo}function Pc(e){var t=e.stateNode,s=e.type,o=e.memoizedProps;switch(t[X]=e,t[Se]=o,s){case"dialog":ot("cancel",t),ot("close",t);break;case"iframe":case"object":case"embed":ot("load",t);break;case"video":case"audio":for(s=0;s<Lo.length;s++)ot(Lo[s],t);break;case"source":ot("error",t);break;case"img":case"image":case"link":ot("error",t),ot("load",t);break;case"details":ot("toggle",t);break;case"input":ot("invalid",t),Td(t,o.value,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name,!0);break;case"select":ot("invalid",t);break;case"textarea":ot("invalid",t),Gr(t,o.value,o.defaultValue,o.children)}s=o.children,typeof s!="string"&&typeof s!="number"&&typeof s!="bigint"||t.textContent===""+s||o.suppressHydrationWarning===!0||Gg(t.textContent,s)?(o.popover!=null&&(ot("beforetoggle",t),ot("toggle",t)),o.onScroll!=null&&ot("scroll",t),o.onScrollEnd!=null&&ot("scrollend",t),o.onClick!=null&&(t.onclick=Xn),t=!0):t=!1,t||Ts(e,!0)}function Ws(e){for(gn=e.return;gn;)switch(gn.tag){case 5:case 31:case 13:la=!1;return;case 27:case 3:la=!0;return;default:gn=gn.return}}function Qs(e){if(e!==gn)return!1;if(!it)return Ws(e),it=!0,!1;var t=e.tag,s;if((s=t!==3&&t!==27)&&((s=t===5)&&(s=e.type,s=!(s!=="form"&&s!=="button")||em(e.type,e.memoizedProps)),s=!s),s&&kt&&Ts(e),Ws(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(r(317));kt=ex(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(r(317));kt=ex(e)}else t===27?(t=kt,Vl(e.type)?(e=lm,lm=null,kt=e):kt=t):kt=gn?Ka(e.stateNode.nextSibling):null;return!0}function ms(){kt=gn=null,it=!1}function fo(){var e=Ns;return e!==null&&(fa===null?fa=e:fa.push.apply(fa,e),Ns=null),e}function Ni(e){Ns===null?Ns=[e]:Ns.push(e)}var mr=he(null),Ya=null,hs=null;function Lt(e,t,s){ie(mr,t._currentValue),t._currentValue=s}function ia(e){e._currentValue=mr.current,$(mr)}function hr(e,t,s){for(;e!==null;){var o=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,o!==null&&(o.childLanes|=t)):o!==null&&(o.childLanes&t)!==t&&(o.childLanes|=t),e===s)break;e=e.return}}function mo(e,t,s,o){var u=e.child;for(u!==null&&(u.return=e);u!==null;){var m=u.dependencies;if(m!==null){var S=u.child;m=m.firstContext;e:for(;m!==null;){var N=m;m=u;for(var I=0;I<t.length;I++)if(N.context===t[I]){m.lanes|=s,N=m.alternate,N!==null&&(N.lanes|=s),hr(m.return,s,e),o||(S=null);break e}m=N.next}}else if(u.tag===18){if(S=u.return,S===null)throw Error(r(341));S.lanes|=s,m=S.alternate,m!==null&&(m.lanes|=s),hr(S,s,e),S=null}else S=u.child;if(S!==null)S.return=u;else for(S=u;S!==null;){if(S===e){S=null;break}if(u=S.sibling,u!==null){u.return=S.return,S=u;break}S=S.return}u=S}}function Ti(e,t,s,o){e=null;for(var u=t,m=!1;u!==null;){if(!m){if((u.flags&524288)!==0)m=!0;else if((u.flags&262144)!==0)break}if(u.tag===10){var S=u.alternate;if(S===null)throw Error(r(387));if(S=S.memoizedProps,S!==null){var N=u.type;zn(u.pendingProps.value,S.value)||(e!==null?e.push(N):e=[N])}}else if(u===Pe.current){if(S=u.alternate,S===null)throw Error(r(387));S.memoizedState.memoizedState!==u.memoizedState.memoizedState&&(e!==null?e.push(Bo):e=[Bo])}u=u.return}e!==null&&mo(t,e,s,o),t.flags|=262144}function pr(e){for(e=e.firstContext;e!==null;){if(!zn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Xs(e){Ya=e,hs=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function on(e){return Ll(Ya,e)}function Zs(e,t){return Ya===null&&Xs(e),Ll(e,t)}function Ll(e,t){var s=t._currentValue;if(t={context:t,memoizedValue:s,next:null},hs===null){if(e===null)throw Error(r(308));hs=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else hs=hs.next=t;return s}var qc=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(s,o){e.push(o)}};this.abort=function(){t.aborted=!0,e.forEach(function(s){return s()})}},Hd=n.unstable_scheduleCallback,$d=n.unstable_NormalPriority,Ht={$$typeof:D,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function ho(){return{controller:new qc,data:new Map,refCount:0}}function Ri(e){e.refCount--,e.refCount===0&&Hd($d,function(){e.controller.abort()})}var Ei=null,po=0,xn=0,zl=null;function Ud(e,t){if(Ei===null){var s=Ei=[];po=0,xn=Gf(),zl={status:"pending",value:void 0,then:function(o){s.push(o)}}}return po++,t.then(Js,Js),t}function Js(){if(--po===0&&Ei!==null){zl!==null&&(zl.status="fulfilled");var e=Ei;Ei=null,xn=0,zl=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function Pd(e,t){var s=[],o={status:"pending",value:null,reason:null,then:function(u){s.push(u)}};return e.then(function(){o.status="fulfilled",o.value=t;for(var u=0;u<s.length;u++)(0,s[u])(t)},function(u){for(o.status="rejected",o.reason=u,u=0;u<s.length;u++)(0,s[u])(void 0)}),o}var gr=z.S;z.S=function(e,t){pg=Oe(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&Ud(e,t),gr!==null&&gr(e,t)};var y=he(null);function E(){var e=y.current;return e!==null?e:Mt.pooledCache}function _(e,t){t===null?ie(y,y.current):ie(y,t.pool)}function G(){var e=E();return e===null?null:{parent:Ht._currentValue,pool:e}}var O=Error(r(460)),pe=Error(r(474)),xe=Error(r(542)),Re={then:function(){}};function Ve(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Qe(e,t,s){switch(s=e[s],s===void 0?e.push(t):s!==t&&(t.then(Xn,Xn),t=s),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,ps(e),e;default:if(typeof t.status=="string")t.then(Xn,Xn);else{if(e=Mt,e!==null&&100<e.shellSuspendCounter)throw Error(r(482));e=t,e.status="pending",e.then(function(o){if(t.status==="pending"){var u=t;u.status="fulfilled",u.value=o}},function(o){if(t.status==="pending"){var u=t;u.status="rejected",u.reason=o}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,ps(e),e}throw $t=t,O}}function yt(e){try{var t=e._init;return t(e._payload)}catch(s){throw s!==null&&typeof s=="object"&&typeof s.then=="function"?($t=s,O):s}}var $t=null;function ra(){if($t===null)throw Error(r(459));var e=$t;return $t=null,e}function ps(e){if(e===O||e===xe)throw Error(r(483))}var oa=null,gs=0;function el(e){var t=gs;return gs+=1,oa===null&&(oa=[]),Qe(oa,e,t)}function Di(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function Gc(e,t){throw t.$$typeof===b?Error(r(525)):(e=Object.prototype.toString.call(t),Error(r(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function Bh(e){function t(V,P){if(e){var ee=V.deletions;ee===null?(V.deletions=[P],V.flags|=16):ee.push(P)}}function s(V,P){if(!e)return null;for(;P!==null;)t(V,P),P=P.sibling;return null}function o(V){for(var P=new Map;V!==null;)V.key!==null?P.set(V.key,V):P.set(V.index,V),V=V.sibling;return P}function u(V,P){return V=ta(V,P),V.index=0,V.sibling=null,V}function m(V,P,ee){return V.index=ee,e?(ee=V.alternate,ee!==null?(ee=ee.index,ee<P?(V.flags|=67108866,P):ee):(V.flags|=67108866,P)):(V.flags|=1048576,P)}function S(V){return e&&V.alternate===null&&(V.flags|=67108866),V}function N(V,P,ee,ge){return P===null||P.tag!==6?(P=oo(ee,V.mode,ge),P.return=V,P):(P=u(P,ee),P.return=V,P)}function I(V,P,ee,ge){var $e=ee.type;return $e===M?fe(V,P,ee.props.children,ge,ee.key):P!==null&&(P.elementType===$e||typeof $e=="object"&&$e!==null&&$e.$$typeof===F&&yt($e)===P.type)?(P=u(P,ee.props),Di(P,ee),P.return=V,P):(P=wn(ee.type,ee.key,ee.props,null,V.mode,ge),Di(P,ee),P.return=V,P)}function te(V,P,ee,ge){return P===null||P.tag!==4||P.stateNode.containerInfo!==ee.containerInfo||P.stateNode.implementation!==ee.implementation?(P=co(ee,V.mode,ge),P.return=V,P):(P=u(P,ee.children||[]),P.return=V,P)}function fe(V,P,ee,ge,$e){return P===null||P.tag!==7?(P=et(ee,V.mode,ge,$e),P.return=V,P):(P=u(P,ee),P.return=V,P)}function ve(V,P,ee){if(typeof P=="string"&&P!==""||typeof P=="number"||typeof P=="bigint")return P=oo(""+P,V.mode,ee),P.return=V,P;if(typeof P=="object"&&P!==null){switch(P.$$typeof){case k:return ee=wn(P.type,P.key,P.props,null,V.mode,ee),Di(ee,P),ee.return=V,ee;case j:return P=co(P,V.mode,ee),P.return=V,P;case F:return P=yt(P),ve(V,P,ee)}if(K(P)||Q(P))return P=et(P,V.mode,ee,null),P.return=V,P;if(typeof P.then=="function")return ve(V,el(P),ee);if(P.$$typeof===D)return ve(V,Zs(V,P),ee);Gc(V,P)}return null}function ae(V,P,ee,ge){var $e=P!==null?P.key:null;if(typeof ee=="string"&&ee!==""||typeof ee=="number"||typeof ee=="bigint")return $e!==null?null:N(V,P,""+ee,ge);if(typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case k:return ee.key===$e?I(V,P,ee,ge):null;case j:return ee.key===$e?te(V,P,ee,ge):null;case F:return ee=yt(ee),ae(V,P,ee,ge)}if(K(ee)||Q(ee))return $e!==null?null:fe(V,P,ee,ge,null);if(typeof ee.then=="function")return ae(V,P,el(ee),ge);if(ee.$$typeof===D)return ae(V,P,Zs(V,ee),ge);Gc(V,ee)}return null}function re(V,P,ee,ge,$e){if(typeof ge=="string"&&ge!==""||typeof ge=="number"||typeof ge=="bigint")return V=V.get(ee)||null,N(P,V,""+ge,$e);if(typeof ge=="object"&&ge!==null){switch(ge.$$typeof){case k:return V=V.get(ge.key===null?ee:ge.key)||null,I(P,V,ge,$e);case j:return V=V.get(ge.key===null?ee:ge.key)||null,te(P,V,ge,$e);case F:return ge=yt(ge),re(V,P,ee,ge,$e)}if(K(ge)||Q(ge))return V=V.get(ee)||null,fe(P,V,ge,$e,null);if(typeof ge.then=="function")return re(V,P,ee,el(ge),$e);if(ge.$$typeof===D)return re(V,P,ee,Zs(P,ge),$e);Gc(P,ge)}return null}function _e(V,P,ee,ge){for(var $e=null,ht=null,Ie=P,st=P=0,ft=null;Ie!==null&&st<ee.length;st++){Ie.index>st?(ft=Ie,Ie=null):ft=Ie.sibling;var pt=ae(V,Ie,ee[st],ge);if(pt===null){Ie===null&&(Ie=ft);break}e&&Ie&&pt.alternate===null&&t(V,Ie),P=m(pt,P,st),ht===null?$e=pt:ht.sibling=pt,ht=pt,Ie=ft}if(st===ee.length)return s(V,Ie),it&&fs(V,st),$e;if(Ie===null){for(;st<ee.length;st++)Ie=ve(V,ee[st],ge),Ie!==null&&(P=m(Ie,P,st),ht===null?$e=Ie:ht.sibling=Ie,ht=Ie);return it&&fs(V,st),$e}for(Ie=o(Ie);st<ee.length;st++)ft=re(Ie,V,st,ee[st],ge),ft!==null&&(e&&ft.alternate!==null&&Ie.delete(ft.key===null?st:ft.key),P=m(ft,P,st),ht===null?$e=ft:ht.sibling=ft,ht=ft);return e&&Ie.forEach(function(Zl){return t(V,Zl)}),it&&fs(V,st),$e}function Ge(V,P,ee,ge){if(ee==null)throw Error(r(151));for(var $e=null,ht=null,Ie=P,st=P=0,ft=null,pt=ee.next();Ie!==null&&!pt.done;st++,pt=ee.next()){Ie.index>st?(ft=Ie,Ie=null):ft=Ie.sibling;var Zl=ae(V,Ie,pt.value,ge);if(Zl===null){Ie===null&&(Ie=ft);break}e&&Ie&&Zl.alternate===null&&t(V,Ie),P=m(Zl,P,st),ht===null?$e=Zl:ht.sibling=Zl,ht=Zl,Ie=ft}if(pt.done)return s(V,Ie),it&&fs(V,st),$e;if(Ie===null){for(;!pt.done;st++,pt=ee.next())pt=ve(V,pt.value,ge),pt!==null&&(P=m(pt,P,st),ht===null?$e=pt:ht.sibling=pt,ht=pt);return it&&fs(V,st),$e}for(Ie=o(Ie);!pt.done;st++,pt=ee.next())pt=re(Ie,V,st,pt.value,ge),pt!==null&&(e&&pt.alternate!==null&&Ie.delete(pt.key===null?st:pt.key),P=m(pt,P,st),ht===null?$e=pt:ht.sibling=pt,ht=pt);return e&&Ie.forEach(function(Ob){return t(V,Ob)}),it&&fs(V,st),$e}function jt(V,P,ee,ge){if(typeof ee=="object"&&ee!==null&&ee.type===M&&ee.key===null&&(ee=ee.props.children),typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case k:e:{for(var $e=ee.key;P!==null;){if(P.key===$e){if($e=ee.type,$e===M){if(P.tag===7){s(V,P.sibling),ge=u(P,ee.props.children),ge.return=V,V=ge;break e}}else if(P.elementType===$e||typeof $e=="object"&&$e!==null&&$e.$$typeof===F&&yt($e)===P.type){s(V,P.sibling),ge=u(P,ee.props),Di(ge,ee),ge.return=V,V=ge;break e}s(V,P);break}else t(V,P);P=P.sibling}ee.type===M?(ge=et(ee.props.children,V.mode,ge,ee.key),ge.return=V,V=ge):(ge=wn(ee.type,ee.key,ee.props,null,V.mode,ge),Di(ge,ee),ge.return=V,V=ge)}return S(V);case j:e:{for($e=ee.key;P!==null;){if(P.key===$e)if(P.tag===4&&P.stateNode.containerInfo===ee.containerInfo&&P.stateNode.implementation===ee.implementation){s(V,P.sibling),ge=u(P,ee.children||[]),ge.return=V,V=ge;break e}else{s(V,P);break}else t(V,P);P=P.sibling}ge=co(ee,V.mode,ge),ge.return=V,V=ge}return S(V);case F:return ee=yt(ee),jt(V,P,ee,ge)}if(K(ee))return _e(V,P,ee,ge);if(Q(ee)){if($e=Q(ee),typeof $e!="function")throw Error(r(150));return ee=$e.call(ee),Ge(V,P,ee,ge)}if(typeof ee.then=="function")return jt(V,P,el(ee),ge);if(ee.$$typeof===D)return jt(V,P,Zs(V,ee),ge);Gc(V,ee)}return typeof ee=="string"&&ee!==""||typeof ee=="number"||typeof ee=="bigint"?(ee=""+ee,P!==null&&P.tag===6?(s(V,P.sibling),ge=u(P,ee),ge.return=V,V=ge):(s(V,P),ge=oo(ee,V.mode,ge),ge.return=V,V=ge),S(V)):s(V,P)}return function(V,P,ee,ge){try{gs=0;var $e=jt(V,P,ee,ge);return oa=null,$e}catch(Ie){if(Ie===O||Ie===xe)throw Ie;var ht=Tn(29,Ie,null,V.mode);return ht.lanes=ge,ht.return=V,ht}}}var Li=Bh(!0),Fh=Bh(!1),_l=!1;function qd(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Gd(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Ol(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Il(e,t,s){var o=e.updateQueue;if(o===null)return null;if(o=o.shared,(gt&2)!==0){var u=o.pending;return u===null?t.next=t:(t.next=u.next,u.next=t),o.pending=t,t=ji(e),Ci(e,null,s),t}return Tl(e,o,t,s),ji(e)}function go(e,t,s){if(t=t.updateQueue,t!==null&&(t=t.shared,(s&4194048)!==0)){var o=t.lanes;o&=e.pendingLanes,s|=o,t.lanes=s,Vn(e,s)}}function Yd(e,t){var s=e.updateQueue,o=e.alternate;if(o!==null&&(o=o.updateQueue,s===o)){var u=null,m=null;if(s=s.firstBaseUpdate,s!==null){do{var S={lane:s.lane,tag:s.tag,payload:s.payload,callback:null,next:null};m===null?u=m=S:m=m.next=S,s=s.next}while(s!==null);m===null?u=m=t:m=m.next=t}else u=m=t;s={baseState:o.baseState,firstBaseUpdate:u,lastBaseUpdate:m,shared:o.shared,callbacks:o.callbacks},e.updateQueue=s;return}e=s.lastBaseUpdate,e===null?s.firstBaseUpdate=t:e.next=t,s.lastBaseUpdate=t}var Vd=!1;function xo(){if(Vd){var e=zl;if(e!==null)throw e}}function vo(e,t,s,o){Vd=!1;var u=e.updateQueue;_l=!1;var m=u.firstBaseUpdate,S=u.lastBaseUpdate,N=u.shared.pending;if(N!==null){u.shared.pending=null;var I=N,te=I.next;I.next=null,S===null?m=te:S.next=te,S=I;var fe=e.alternate;fe!==null&&(fe=fe.updateQueue,N=fe.lastBaseUpdate,N!==S&&(N===null?fe.firstBaseUpdate=te:N.next=te,fe.lastBaseUpdate=I))}if(m!==null){var ve=u.baseState;S=0,fe=te=I=null,N=m;do{var ae=N.lane&-536870913,re=ae!==N.lane;if(re?(dt&ae)===ae:(o&ae)===ae){ae!==0&&ae===xn&&(Vd=!0),fe!==null&&(fe=fe.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var _e=e,Ge=N;ae=t;var jt=s;switch(Ge.tag){case 1:if(_e=Ge.payload,typeof _e=="function"){ve=_e.call(jt,ve,ae);break e}ve=_e;break e;case 3:_e.flags=_e.flags&-65537|128;case 0:if(_e=Ge.payload,ae=typeof _e=="function"?_e.call(jt,ve,ae):_e,ae==null)break e;ve=v({},ve,ae);break e;case 2:_l=!0}}ae=N.callback,ae!==null&&(e.flags|=64,re&&(e.flags|=8192),re=u.callbacks,re===null?u.callbacks=[ae]:re.push(ae))}else re={lane:ae,tag:N.tag,payload:N.payload,callback:N.callback,next:null},fe===null?(te=fe=re,I=ve):fe=fe.next=re,S|=ae;if(N=N.next,N===null){if(N=u.shared.pending,N===null)break;re=N,N=re.next,re.next=null,u.lastBaseUpdate=re,u.shared.pending=null}}while(!0);fe===null&&(I=ve),u.baseState=I,u.firstBaseUpdate=te,u.lastBaseUpdate=fe,m===null&&(u.shared.lanes=0),Ul|=S,e.lanes=S,e.memoizedState=ve}}function Hh(e,t){if(typeof e!="function")throw Error(r(191,e));e.call(t)}function $h(e,t){var s=e.callbacks;if(s!==null)for(e.callbacks=null,e=0;e<s.length;e++)Hh(s[e],t)}var xr=he(null),Yc=he(0);function Uh(e,t){e=cl,ie(Yc,e),ie(xr,t),cl=e|t.baseLanes}function Kd(){ie(Yc,cl),ie(xr,xr.current)}function Wd(){cl=Yc.current,$(xr),$(Yc)}var Aa=he(null),Va=null;function Bl(e){var t=e.alternate;ie(Jt,Jt.current&1),ie(Aa,e),Va===null&&(t===null||xr.current!==null||t.memoizedState!==null)&&(Va=e)}function Qd(e){ie(Jt,Jt.current),ie(Aa,e),Va===null&&(Va=e)}function Ph(e){e.tag===22?(ie(Jt,Jt.current),ie(Aa,e),Va===null&&(Va=e)):Fl()}function Fl(){ie(Jt,Jt.current),ie(Aa,Aa.current)}function Na(e){$(Aa),Va===e&&(Va=null),$(Jt)}var Jt=he(0);function Vc(e){for(var t=e;t!==null;){if(t.tag===13){var s=t.memoizedState;if(s!==null&&(s=s.dehydrated,s===null||am(s)||sm(s)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder==="forwards"||t.memoizedProps.revealOrder==="backwards"||t.memoizedProps.revealOrder==="unstable_legacy-backwards"||t.memoizedProps.revealOrder==="together")){if((t.flags&128)!==0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var tl=0,tt=null,St=null,cn=null,Kc=!1,vr=!1,zi=!1,Wc=0,yo=0,yr=null,Mw=0;function Ut(){throw Error(r(321))}function Xd(e,t){if(t===null)return!1;for(var s=0;s<t.length&&s<e.length;s++)if(!zn(e[s],t[s]))return!1;return!0}function Zd(e,t,s,o,u,m){return tl=m,tt=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,z.H=e===null||e.memoizedState===null?Mp:hf,zi=!1,m=s(o,u),zi=!1,vr&&(m=Gh(t,s,o,u)),qh(e),m}function qh(e){z.H=So;var t=St!==null&&St.next!==null;if(tl=0,cn=St=tt=null,Kc=!1,yo=0,yr=null,t)throw Error(r(300));e===null||un||(e=e.dependencies,e!==null&&pr(e)&&(un=!0))}function Gh(e,t,s,o){tt=e;var u=0;do{if(vr&&(yr=null),yo=0,vr=!1,25<=u)throw Error(r(301));if(u+=1,cn=St=null,e.updateQueue!=null){var m=e.updateQueue;m.lastEffect=null,m.events=null,m.stores=null,m.memoCache!=null&&(m.memoCache.index=0)}z.H=Ap,m=t(s,o)}while(vr);return m}function Aw(){var e=z.H,t=e.useState()[0];return t=typeof t.then=="function"?wo(t):t,e=e.useState()[0],(St!==null?St.memoizedState:null)!==e&&(tt.flags|=1024),t}function Jd(){var e=Wc!==0;return Wc=0,e}function ef(e,t,s){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s}function tf(e){if(Kc){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Kc=!1}tl=0,cn=St=tt=null,vr=!1,yo=Wc=0,yr=null}function Un(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return cn===null?tt.memoizedState=cn=e:cn=cn.next=e,cn}function en(){if(St===null){var e=tt.alternate;e=e!==null?e.memoizedState:null}else e=St.next;var t=cn===null?tt.memoizedState:cn.next;if(t!==null)cn=t,St=e;else{if(e===null)throw tt.alternate===null?Error(r(467)):Error(r(310));St=e,e={memoizedState:St.memoizedState,baseState:St.baseState,baseQueue:St.baseQueue,queue:St.queue,next:null},cn===null?tt.memoizedState=cn=e:cn=cn.next=e}return cn}function Qc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function wo(e){var t=yo;return yo+=1,yr===null&&(yr=[]),e=Qe(yr,e,t),t=tt,(cn===null?t.memoizedState:cn.next)===null&&(t=t.alternate,z.H=t===null||t.memoizedState===null?Mp:hf),e}function Xc(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return wo(e);if(e.$$typeof===D)return on(e)}throw Error(r(438,String(e)))}function nf(e){var t=null,s=tt.updateQueue;if(s!==null&&(t=s.memoCache),t==null){var o=tt.alternate;o!==null&&(o=o.updateQueue,o!==null&&(o=o.memoCache,o!=null&&(t={data:o.data.map(function(u){return u.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),s===null&&(s=Qc(),tt.updateQueue=s),s.memoCache=t,s=t.data[t.index],s===void 0)for(s=t.data[t.index]=Array(e),o=0;o<e;o++)s[o]=W;return t.index++,s}function nl(e,t){return typeof t=="function"?t(e):t}function Zc(e){var t=en();return af(t,St,e)}function af(e,t,s){var o=e.queue;if(o===null)throw Error(r(311));o.lastRenderedReducer=s;var u=e.baseQueue,m=o.pending;if(m!==null){if(u!==null){var S=u.next;u.next=m.next,m.next=S}t.baseQueue=u=m,o.pending=null}if(m=e.baseState,u===null)e.memoizedState=m;else{t=u.next;var N=S=null,I=null,te=t,fe=!1;do{var ve=te.lane&-536870913;if(ve!==te.lane?(dt&ve)===ve:(tl&ve)===ve){var ae=te.revertLane;if(ae===0)I!==null&&(I=I.next={lane:0,revertLane:0,gesture:null,action:te.action,hasEagerState:te.hasEagerState,eagerState:te.eagerState,next:null}),ve===xn&&(fe=!0);else if((tl&ae)===ae){te=te.next,ae===xn&&(fe=!0);continue}else ve={lane:0,revertLane:te.revertLane,gesture:null,action:te.action,hasEagerState:te.hasEagerState,eagerState:te.eagerState,next:null},I===null?(N=I=ve,S=m):I=I.next=ve,tt.lanes|=ae,Ul|=ae;ve=te.action,zi&&s(m,ve),m=te.hasEagerState?te.eagerState:s(m,ve)}else ae={lane:ve,revertLane:te.revertLane,gesture:te.gesture,action:te.action,hasEagerState:te.hasEagerState,eagerState:te.eagerState,next:null},I===null?(N=I=ae,S=m):I=I.next=ae,tt.lanes|=ve,Ul|=ve;te=te.next}while(te!==null&&te!==t);if(I===null?S=m:I.next=N,!zn(m,e.memoizedState)&&(un=!0,fe&&(s=zl,s!==null)))throw s;e.memoizedState=m,e.baseState=S,e.baseQueue=I,o.lastRenderedState=m}return u===null&&(o.lanes=0),[e.memoizedState,o.dispatch]}function sf(e){var t=en(),s=t.queue;if(s===null)throw Error(r(311));s.lastRenderedReducer=e;var o=s.dispatch,u=s.pending,m=t.memoizedState;if(u!==null){s.pending=null;var S=u=u.next;do m=e(m,S.action),S=S.next;while(S!==u);zn(m,t.memoizedState)||(un=!0),t.memoizedState=m,t.baseQueue===null&&(t.baseState=m),s.lastRenderedState=m}return[m,o]}function Yh(e,t,s){var o=tt,u=en(),m=it;if(m){if(s===void 0)throw Error(r(407));s=s()}else s=t();var S=!zn((St||u).memoizedState,s);if(S&&(u.memoizedState=s,un=!0),u=u.queue,of(Wh.bind(null,o,u,e),[e]),u.getSnapshot!==t||S||cn!==null&&cn.memoizedState.tag&1){if(o.flags|=2048,wr(9,{destroy:void 0},Kh.bind(null,o,u,s,t),null),Mt===null)throw Error(r(349));m||(tl&127)!==0||Vh(o,t,s)}return s}function Vh(e,t,s){e.flags|=16384,e={getSnapshot:t,value:s},t=tt.updateQueue,t===null?(t=Qc(),tt.updateQueue=t,t.stores=[e]):(s=t.stores,s===null?t.stores=[e]:s.push(e))}function Kh(e,t,s,o){t.value=s,t.getSnapshot=o,Qh(t)&&Xh(e)}function Wh(e,t,s){return s(function(){Qh(t)&&Xh(e)})}function Qh(e){var t=e.getSnapshot;e=e.value;try{var s=t();return!zn(e,s)}catch{return!0}}function Xh(e){var t=Ce(e,2);t!==null&&ma(t,e,2)}function lf(e){var t=Un();if(typeof e=="function"){var s=e;if(e=s(),zi){yn(!0);try{s()}finally{yn(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:nl,lastRenderedState:e},t}function Zh(e,t,s,o){return e.baseState=s,af(e,St,typeof o=="function"?o:nl)}function Nw(e,t,s,o,u){if(tu(e))throw Error(r(485));if(e=t.action,e!==null){var m={payload:u,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(S){m.listeners.push(S)}};z.T!==null?s(!0):m.isTransition=!1,o(m),s=t.pending,s===null?(m.next=t.pending=m,Jh(t,m)):(m.next=s.next,t.pending=s.next=m)}}function Jh(e,t){var s=t.action,o=t.payload,u=e.state;if(t.isTransition){var m=z.T,S={};z.T=S;try{var N=s(u,o),I=z.S;I!==null&&I(S,N),ep(e,t,N)}catch(te){rf(e,t,te)}finally{m!==null&&S.types!==null&&(m.types=S.types),z.T=m}}else try{m=s(u,o),ep(e,t,m)}catch(te){rf(e,t,te)}}function ep(e,t,s){s!==null&&typeof s=="object"&&typeof s.then=="function"?s.then(function(o){tp(e,t,o)},function(o){return rf(e,t,o)}):tp(e,t,s)}function tp(e,t,s){t.status="fulfilled",t.value=s,np(t),e.state=s,t=e.pending,t!==null&&(s=t.next,s===t?e.pending=null:(s=s.next,t.next=s,Jh(e,s)))}function rf(e,t,s){var o=e.pending;if(e.pending=null,o!==null){o=o.next;do t.status="rejected",t.reason=s,np(t),t=t.next;while(t!==o)}e.action=null}function np(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function ap(e,t){return t}function sp(e,t){if(it){var s=Mt.formState;if(s!==null){e:{var o=tt;if(it){if(kt){t:{for(var u=kt,m=la;u.nodeType!==8;){if(!m){u=null;break t}if(u=Ka(u.nextSibling),u===null){u=null;break t}}m=u.data,u=m==="F!"||m==="F"?u:null}if(u){kt=Ka(u.nextSibling),o=u.data==="F!";break e}}Ts(o)}o=!1}o&&(t=s[0])}}return s=Un(),s.memoizedState=s.baseState=t,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ap,lastRenderedState:t},s.queue=o,s=Cp.bind(null,tt,o),o.dispatch=s,o=lf(!1),m=mf.bind(null,tt,!1,o.queue),o=Un(),u={state:t,dispatch:null,action:e,pending:null},o.queue=u,s=Nw.bind(null,tt,u,m,s),u.dispatch=s,o.memoizedState=e,[t,s,!1]}function lp(e){var t=en();return ip(t,St,e)}function ip(e,t,s){if(t=af(e,t,ap)[0],e=Zc(nl)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var o=wo(t)}catch(S){throw S===O?xe:S}else o=t;t=en();var u=t.queue,m=u.dispatch;return s!==t.memoizedState&&(tt.flags|=2048,wr(9,{destroy:void 0},Tw.bind(null,u,s),null)),[o,m,e]}function Tw(e,t){e.action=t}function rp(e){var t=en(),s=St;if(s!==null)return ip(t,s,e);en(),t=t.memoizedState,s=en();var o=s.queue.dispatch;return s.memoizedState=e,[t,o,!1]}function wr(e,t,s,o){return e={tag:e,create:s,deps:o,inst:t,next:null},t=tt.updateQueue,t===null&&(t=Qc(),tt.updateQueue=t),s=t.lastEffect,s===null?t.lastEffect=e.next=e:(o=s.next,s.next=e,e.next=o,t.lastEffect=e),e}function op(){return en().memoizedState}function Jc(e,t,s,o){var u=Un();tt.flags|=e,u.memoizedState=wr(1|t,{destroy:void 0},s,o===void 0?null:o)}function eu(e,t,s,o){var u=en();o=o===void 0?null:o;var m=u.memoizedState.inst;St!==null&&o!==null&&Xd(o,St.memoizedState.deps)?u.memoizedState=wr(t,m,s,o):(tt.flags|=e,u.memoizedState=wr(1|t,m,s,o))}function cp(e,t){Jc(8390656,8,e,t)}function of(e,t){eu(2048,8,e,t)}function Rw(e){tt.flags|=4;var t=tt.updateQueue;if(t===null)t=Qc(),tt.updateQueue=t,t.events=[e];else{var s=t.events;s===null?t.events=[e]:s.push(e)}}function up(e){var t=en().memoizedState;return Rw({ref:t,nextImpl:e}),function(){if((gt&2)!==0)throw Error(r(440));return t.impl.apply(void 0,arguments)}}function dp(e,t){return eu(4,2,e,t)}function fp(e,t){return eu(4,4,e,t)}function mp(e,t){if(typeof t=="function"){e=e();var s=t(e);return function(){typeof s=="function"?s():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function hp(e,t,s){s=s!=null?s.concat([e]):null,eu(4,4,mp.bind(null,t,e),s)}function cf(){}function pp(e,t){var s=en();t=t===void 0?null:t;var o=s.memoizedState;return t!==null&&Xd(t,o[1])?o[0]:(s.memoizedState=[e,t],e)}function gp(e,t){var s=en();t=t===void 0?null:t;var o=s.memoizedState;if(t!==null&&Xd(t,o[1]))return o[0];if(o=e(),zi){yn(!0);try{e()}finally{yn(!1)}}return s.memoizedState=[o,t],o}function uf(e,t,s){return s===void 0||(tl&1073741824)!==0&&(dt&261930)===0?e.memoizedState=t:(e.memoizedState=s,e=xg(),tt.lanes|=e,Ul|=e,s)}function xp(e,t,s,o){return zn(s,t)?s:xr.current!==null?(e=uf(e,s,o),zn(e,t)||(un=!0),e):(tl&42)===0||(tl&1073741824)!==0&&(dt&261930)===0?(un=!0,e.memoizedState=s):(e=xg(),tt.lanes|=e,Ul|=e,t)}function vp(e,t,s,o,u){var m=Y.p;Y.p=m!==0&&8>m?m:8;var S=z.T,N={};z.T=N,mf(e,!1,t,s);try{var I=u(),te=z.S;if(te!==null&&te(N,I),I!==null&&typeof I=="object"&&typeof I.then=="function"){var fe=Pd(I,o);bo(e,t,fe,Ea(e))}else bo(e,t,o,Ea(e))}catch(ve){bo(e,t,{then:function(){},status:"rejected",reason:ve},Ea())}finally{Y.p=m,S!==null&&N.types!==null&&(S.types=N.types),z.T=S}}function Ew(){}function df(e,t,s,o){if(e.tag!==5)throw Error(r(476));var u=yp(e).queue;vp(e,u,t,U,s===null?Ew:function(){return wp(e),s(o)})}function yp(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:U,baseState:U,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:nl,lastRenderedState:U},next:null};var s={};return t.next={memoizedState:s,baseState:s,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:nl,lastRenderedState:s},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function wp(e){var t=yp(e);t.next===null&&(t=e.alternate.memoizedState),bo(e,t.next.queue,{},Ea())}function ff(){return on(Bo)}function bp(){return en().memoizedState}function Sp(){return en().memoizedState}function Dw(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var s=Ea();e=Ol(s);var o=Il(t,e,s);o!==null&&(ma(o,t,s),go(o,t,s)),t={cache:ho()},e.payload=t;return}t=t.return}}function Lw(e,t,s){var o=Ea();s={lane:o,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},tu(e)?jp(t,s):(s=Si(e,t,s,o),s!==null&&(ma(s,e,o),kp(s,t,o)))}function Cp(e,t,s){var o=Ea();bo(e,t,s,o)}function bo(e,t,s,o){var u={lane:o,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null};if(tu(e))jp(t,u);else{var m=e.alternate;if(e.lanes===0&&(m===null||m.lanes===0)&&(m=t.lastRenderedReducer,m!==null))try{var S=t.lastRenderedState,N=m(S,s);if(u.hasEagerState=!0,u.eagerState=N,zn(N,S))return Tl(e,t,u,0),Mt===null&&dr(),!1}catch{}if(s=Si(e,t,u,o),s!==null)return ma(s,e,o),kp(s,t,o),!0}return!1}function mf(e,t,s,o){if(o={lane:2,revertLane:Gf(),gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},tu(e)){if(t)throw Error(r(479))}else t=Si(e,s,o,2),t!==null&&ma(t,e,2)}function tu(e){var t=e.alternate;return e===tt||t!==null&&t===tt}function jp(e,t){vr=Kc=!0;var s=e.pending;s===null?t.next=t:(t.next=s.next,s.next=t),e.pending=t}function kp(e,t,s){if((s&4194048)!==0){var o=t.lanes;o&=e.pendingLanes,s|=o,t.lanes=s,Vn(e,s)}}var So={readContext:on,use:Xc,useCallback:Ut,useContext:Ut,useEffect:Ut,useImperativeHandle:Ut,useLayoutEffect:Ut,useInsertionEffect:Ut,useMemo:Ut,useReducer:Ut,useRef:Ut,useState:Ut,useDebugValue:Ut,useDeferredValue:Ut,useTransition:Ut,useSyncExternalStore:Ut,useId:Ut,useHostTransitionStatus:Ut,useFormState:Ut,useActionState:Ut,useOptimistic:Ut,useMemoCache:Ut,useCacheRefresh:Ut};So.useEffectEvent=Ut;var Mp={readContext:on,use:Xc,useCallback:function(e,t){return Un().memoizedState=[e,t===void 0?null:t],e},useContext:on,useEffect:cp,useImperativeHandle:function(e,t,s){s=s!=null?s.concat([e]):null,Jc(4194308,4,mp.bind(null,t,e),s)},useLayoutEffect:function(e,t){return Jc(4194308,4,e,t)},useInsertionEffect:function(e,t){Jc(4,2,e,t)},useMemo:function(e,t){var s=Un();t=t===void 0?null:t;var o=e();if(zi){yn(!0);try{e()}finally{yn(!1)}}return s.memoizedState=[o,t],o},useReducer:function(e,t,s){var o=Un();if(s!==void 0){var u=s(t);if(zi){yn(!0);try{s(t)}finally{yn(!1)}}}else u=t;return o.memoizedState=o.baseState=u,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:u},o.queue=e,e=e.dispatch=Lw.bind(null,tt,e),[o.memoizedState,e]},useRef:function(e){var t=Un();return e={current:e},t.memoizedState=e},useState:function(e){e=lf(e);var t=e.queue,s=Cp.bind(null,tt,t);return t.dispatch=s,[e.memoizedState,s]},useDebugValue:cf,useDeferredValue:function(e,t){var s=Un();return uf(s,e,t)},useTransition:function(){var e=lf(!1);return e=vp.bind(null,tt,e.queue,!0,!1),Un().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,s){var o=tt,u=Un();if(it){if(s===void 0)throw Error(r(407));s=s()}else{if(s=t(),Mt===null)throw Error(r(349));(dt&127)!==0||Vh(o,t,s)}u.memoizedState=s;var m={value:s,getSnapshot:t};return u.queue=m,cp(Wh.bind(null,o,m,e),[e]),o.flags|=2048,wr(9,{destroy:void 0},Kh.bind(null,o,m,s,t),null),s},useId:function(){var e=Un(),t=Mt.identifierPrefix;if(it){var s=Ga,o=qa;s=(o&~(1<<32-qt(o)-1)).toString(32)+s,t="_"+t+"R_"+s,s=Wc++,0<s&&(t+="H"+s.toString(32)),t+="_"}else s=Mw++,t="_"+t+"r_"+s.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:ff,useFormState:sp,useActionState:sp,useOptimistic:function(e){var t=Un();t.memoizedState=t.baseState=e;var s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=s,t=mf.bind(null,tt,!0,s),s.dispatch=t,[e,t]},useMemoCache:nf,useCacheRefresh:function(){return Un().memoizedState=Dw.bind(null,tt)},useEffectEvent:function(e){var t=Un(),s={impl:e};return t.memoizedState=s,function(){if((gt&2)!==0)throw Error(r(440));return s.impl.apply(void 0,arguments)}}},hf={readContext:on,use:Xc,useCallback:pp,useContext:on,useEffect:of,useImperativeHandle:hp,useInsertionEffect:dp,useLayoutEffect:fp,useMemo:gp,useReducer:Zc,useRef:op,useState:function(){return Zc(nl)},useDebugValue:cf,useDeferredValue:function(e,t){var s=en();return xp(s,St.memoizedState,e,t)},useTransition:function(){var e=Zc(nl)[0],t=en().memoizedState;return[typeof e=="boolean"?e:wo(e),t]},useSyncExternalStore:Yh,useId:bp,useHostTransitionStatus:ff,useFormState:lp,useActionState:lp,useOptimistic:function(e,t){var s=en();return Zh(s,St,e,t)},useMemoCache:nf,useCacheRefresh:Sp};hf.useEffectEvent=up;var Ap={readContext:on,use:Xc,useCallback:pp,useContext:on,useEffect:of,useImperativeHandle:hp,useInsertionEffect:dp,useLayoutEffect:fp,useMemo:gp,useReducer:sf,useRef:op,useState:function(){return sf(nl)},useDebugValue:cf,useDeferredValue:function(e,t){var s=en();return St===null?uf(s,e,t):xp(s,St.memoizedState,e,t)},useTransition:function(){var e=sf(nl)[0],t=en().memoizedState;return[typeof e=="boolean"?e:wo(e),t]},useSyncExternalStore:Yh,useId:bp,useHostTransitionStatus:ff,useFormState:rp,useActionState:rp,useOptimistic:function(e,t){var s=en();return St!==null?Zh(s,St,e,t):(s.baseState=e,[e,s.queue.dispatch])},useMemoCache:nf,useCacheRefresh:Sp};Ap.useEffectEvent=up;function pf(e,t,s,o){t=e.memoizedState,s=s(o,t),s=s==null?t:v({},t,s),e.memoizedState=s,e.lanes===0&&(e.updateQueue.baseState=s)}var gf={enqueueSetState:function(e,t,s){e=e._reactInternals;var o=Ea(),u=Ol(o);u.payload=t,s!=null&&(u.callback=s),t=Il(e,u,o),t!==null&&(ma(t,e,o),go(t,e,o))},enqueueReplaceState:function(e,t,s){e=e._reactInternals;var o=Ea(),u=Ol(o);u.tag=1,u.payload=t,s!=null&&(u.callback=s),t=Il(e,u,o),t!==null&&(ma(t,e,o),go(t,e,o))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var s=Ea(),o=Ol(s);o.tag=2,t!=null&&(o.callback=t),t=Il(e,o,s),t!==null&&(ma(t,e,s),go(t,e,s))}};function Np(e,t,s,o,u,m,S){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(o,m,S):t.prototype&&t.prototype.isPureReactComponent?!Pa(s,o)||!Pa(u,m):!0}function Tp(e,t,s,o){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(s,o),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(s,o),t.state!==e&&gf.enqueueReplaceState(t,t.state,null)}function _i(e,t){var s=t;if("ref"in t){s={};for(var o in t)o!=="ref"&&(s[o]=t[o])}if(e=e.defaultProps){s===t&&(s=v({},s));for(var u in e)s[u]===void 0&&(s[u]=e[u])}return s}function Rp(e){ur(e)}function Ep(e){console.error(e)}function Dp(e){ur(e)}function nu(e,t){try{var s=e.onUncaughtError;s(t.value,{componentStack:t.stack})}catch(o){setTimeout(function(){throw o})}}function Lp(e,t,s){try{var o=e.onCaughtError;o(s.value,{componentStack:s.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(u){setTimeout(function(){throw u})}}function xf(e,t,s){return s=Ol(s),s.tag=3,s.payload={element:null},s.callback=function(){nu(e,t)},s}function zp(e){return e=Ol(e),e.tag=3,e}function _p(e,t,s,o){var u=s.type.getDerivedStateFromError;if(typeof u=="function"){var m=o.value;e.payload=function(){return u(m)},e.callback=function(){Lp(t,s,o)}}var S=s.stateNode;S!==null&&typeof S.componentDidCatch=="function"&&(e.callback=function(){Lp(t,s,o),typeof u!="function"&&(Pl===null?Pl=new Set([this]):Pl.add(this));var N=o.stack;this.componentDidCatch(o.value,{componentStack:N!==null?N:""})})}function zw(e,t,s,o,u){if(s.flags|=32768,o!==null&&typeof o=="object"&&typeof o.then=="function"){if(t=s.alternate,t!==null&&Ti(t,s,u,!0),s=Aa.current,s!==null){switch(s.tag){case 31:case 13:return Va===null?hu():s.alternate===null&&Pt===0&&(Pt=3),s.flags&=-257,s.flags|=65536,s.lanes=u,o===Re?s.flags|=16384:(t=s.updateQueue,t===null?s.updateQueue=new Set([o]):t.add(o),Uf(e,o,u)),!1;case 22:return s.flags|=65536,o===Re?s.flags|=16384:(t=s.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([o])},s.updateQueue=t):(s=t.retryQueue,s===null?t.retryQueue=new Set([o]):s.add(o)),Uf(e,o,u)),!1}throw Error(r(435,s.tag))}return Uf(e,o,u),hu(),!1}if(it)return t=Aa.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=u,o!==uo&&(e=Error(r(422),{cause:o}),Ni(na(e,s)))):(o!==uo&&(t=Error(r(423),{cause:o}),Ni(na(t,s))),e=e.current.alternate,e.flags|=65536,u&=-u,e.lanes|=u,o=na(o,s),u=xf(e.stateNode,o,u),Yd(e,u),Pt!==4&&(Pt=2)),!1;var m=Error(r(520),{cause:o});if(m=na(m,s),Ro===null?Ro=[m]:Ro.push(m),Pt!==4&&(Pt=2),t===null)return!0;o=na(o,s),s=t;do{switch(s.tag){case 3:return s.flags|=65536,e=u&-u,s.lanes|=e,e=xf(s.stateNode,o,e),Yd(s,e),!1;case 1:if(t=s.type,m=s.stateNode,(s.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||m!==null&&typeof m.componentDidCatch=="function"&&(Pl===null||!Pl.has(m))))return s.flags|=65536,u&=-u,s.lanes|=u,u=zp(u),_p(u,e,s,o),Yd(s,u),!1}s=s.return}while(s!==null);return!1}var vf=Error(r(461)),un=!1;function Rn(e,t,s,o){t.child=e===null?Fh(t,null,s,o):Li(t,e.child,s,o)}function Op(e,t,s,o,u){s=s.render;var m=t.ref;if("ref"in o){var S={};for(var N in o)N!=="ref"&&(S[N]=o[N])}else S=o;return Xs(t),o=Zd(e,t,s,S,m,u),N=Jd(),e!==null&&!un?(ef(e,t,u),al(e,t,u)):(it&&N&&Mi(t),t.flags|=1,Rn(e,t,o,u),t.child)}function Ip(e,t,s,o,u){if(e===null){var m=s.type;return typeof m=="function"&&!ro(m)&&m.defaultProps===void 0&&s.compare===null?(t.tag=15,t.type=m,Bp(e,t,m,o,u)):(e=wn(s.type,null,o,t,t.mode,u),e.ref=t.ref,e.return=t,t.child=e)}if(m=e.child,!Mf(e,u)){var S=m.memoizedProps;if(s=s.compare,s=s!==null?s:Pa,s(S,o)&&e.ref===t.ref)return al(e,t,u)}return t.flags|=1,e=ta(m,o),e.ref=t.ref,e.return=t,t.child=e}function Bp(e,t,s,o,u){if(e!==null){var m=e.memoizedProps;if(Pa(m,o)&&e.ref===t.ref)if(un=!1,t.pendingProps=o=m,Mf(e,u))(e.flags&131072)!==0&&(un=!0);else return t.lanes=e.lanes,al(e,t,u)}return yf(e,t,s,o,u)}function Fp(e,t,s,o){var u=o.children,m=e!==null?e.memoizedState:null;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.mode==="hidden"){if((t.flags&128)!==0){if(m=m!==null?m.baseLanes|s:s,e!==null){for(o=t.child=e.child,u=0;o!==null;)u=u|o.lanes|o.childLanes,o=o.sibling;o=u&~m}else o=0,t.child=null;return Hp(e,t,m,s,o)}if((s&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&_(t,m!==null?m.cachePool:null),m!==null?Uh(t,m):Kd(),Ph(t);else return o=t.lanes=536870912,Hp(e,t,m!==null?m.baseLanes|s:s,s,o)}else m!==null?(_(t,m.cachePool),Uh(t,m),Fl(),t.memoizedState=null):(e!==null&&_(t,null),Kd(),Fl());return Rn(e,t,u,s),t.child}function Co(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Hp(e,t,s,o,u){var m=E();return m=m===null?null:{parent:Ht._currentValue,pool:m},t.memoizedState={baseLanes:s,cachePool:m},e!==null&&_(t,null),Kd(),Ph(t),e!==null&&Ti(e,t,o,!0),t.childLanes=u,null}function au(e,t){return t=lu({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function $p(e,t,s){return Li(t,e.child,null,s),e=au(t,t.pendingProps),e.flags|=2,Na(t),t.memoizedState=null,e}function _w(e,t,s){var o=t.pendingProps,u=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(it){if(o.mode==="hidden")return e=au(t,o),t.lanes=536870912,Co(null,e);if(Qd(t),(e=kt)?(e=Jg(e,la),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:As!==null?{id:qa,overflow:Ga}:null,retryLane:536870912,hydrationErrors:null},s=Fc(e),s.return=t,t.child=s,gn=t,kt=null)):e=null,e===null)throw Ts(t);return t.lanes=536870912,null}return au(t,o)}var m=e.memoizedState;if(m!==null){var S=m.dehydrated;if(Qd(t),u)if(t.flags&256)t.flags&=-257,t=$p(e,t,s);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(r(558));else if(un||Ti(e,t,s,!1),u=(s&e.childLanes)!==0,un||u){if(o=Mt,o!==null&&(S=wa(o,s),S!==0&&S!==m.retryLane))throw m.retryLane=S,Ce(e,S),ma(o,e,S),vf;hu(),t=$p(e,t,s)}else e=m.treeContext,kt=Ka(S.nextSibling),gn=t,it=!0,Ns=null,la=!1,e!==null&&Uc(t,e),t=au(t,o),t.flags|=4096;return t}return e=ta(e.child,{mode:o.mode,children:o.children}),e.ref=t.ref,t.child=e,e.return=t,e}function su(e,t){var s=t.ref;if(s===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof s!="function"&&typeof s!="object")throw Error(r(284));(e===null||e.ref!==s)&&(t.flags|=4194816)}}function yf(e,t,s,o,u){return Xs(t),s=Zd(e,t,s,o,void 0,u),o=Jd(),e!==null&&!un?(ef(e,t,u),al(e,t,u)):(it&&o&&Mi(t),t.flags|=1,Rn(e,t,s,u),t.child)}function Up(e,t,s,o,u,m){return Xs(t),t.updateQueue=null,s=Gh(t,o,s,u),qh(e),o=Jd(),e!==null&&!un?(ef(e,t,m),al(e,t,m)):(it&&o&&Mi(t),t.flags|=1,Rn(e,t,s,m),t.child)}function Pp(e,t,s,o,u){if(Xs(t),t.stateNode===null){var m=Rl,S=s.contextType;typeof S=="object"&&S!==null&&(m=on(S)),m=new s(o,m),t.memoizedState=m.state!==null&&m.state!==void 0?m.state:null,m.updater=gf,t.stateNode=m,m._reactInternals=t,m=t.stateNode,m.props=o,m.state=t.memoizedState,m.refs={},qd(t),S=s.contextType,m.context=typeof S=="object"&&S!==null?on(S):Rl,m.state=t.memoizedState,S=s.getDerivedStateFromProps,typeof S=="function"&&(pf(t,s,S,o),m.state=t.memoizedState),typeof s.getDerivedStateFromProps=="function"||typeof m.getSnapshotBeforeUpdate=="function"||typeof m.UNSAFE_componentWillMount!="function"&&typeof m.componentWillMount!="function"||(S=m.state,typeof m.componentWillMount=="function"&&m.componentWillMount(),typeof m.UNSAFE_componentWillMount=="function"&&m.UNSAFE_componentWillMount(),S!==m.state&&gf.enqueueReplaceState(m,m.state,null),vo(t,o,m,u),xo(),m.state=t.memoizedState),typeof m.componentDidMount=="function"&&(t.flags|=4194308),o=!0}else if(e===null){m=t.stateNode;var N=t.memoizedProps,I=_i(s,N);m.props=I;var te=m.context,fe=s.contextType;S=Rl,typeof fe=="object"&&fe!==null&&(S=on(fe));var ve=s.getDerivedStateFromProps;fe=typeof ve=="function"||typeof m.getSnapshotBeforeUpdate=="function",N=t.pendingProps!==N,fe||typeof m.UNSAFE_componentWillReceiveProps!="function"&&typeof m.componentWillReceiveProps!="function"||(N||te!==S)&&Tp(t,m,o,S),_l=!1;var ae=t.memoizedState;m.state=ae,vo(t,o,m,u),xo(),te=t.memoizedState,N||ae!==te||_l?(typeof ve=="function"&&(pf(t,s,ve,o),te=t.memoizedState),(I=_l||Np(t,s,I,o,ae,te,S))?(fe||typeof m.UNSAFE_componentWillMount!="function"&&typeof m.componentWillMount!="function"||(typeof m.componentWillMount=="function"&&m.componentWillMount(),typeof m.UNSAFE_componentWillMount=="function"&&m.UNSAFE_componentWillMount()),typeof m.componentDidMount=="function"&&(t.flags|=4194308)):(typeof m.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=o,t.memoizedState=te),m.props=o,m.state=te,m.context=S,o=I):(typeof m.componentDidMount=="function"&&(t.flags|=4194308),o=!1)}else{m=t.stateNode,Gd(e,t),S=t.memoizedProps,fe=_i(s,S),m.props=fe,ve=t.pendingProps,ae=m.context,te=s.contextType,I=Rl,typeof te=="object"&&te!==null&&(I=on(te)),N=s.getDerivedStateFromProps,(te=typeof N=="function"||typeof m.getSnapshotBeforeUpdate=="function")||typeof m.UNSAFE_componentWillReceiveProps!="function"&&typeof m.componentWillReceiveProps!="function"||(S!==ve||ae!==I)&&Tp(t,m,o,I),_l=!1,ae=t.memoizedState,m.state=ae,vo(t,o,m,u),xo();var re=t.memoizedState;S!==ve||ae!==re||_l||e!==null&&e.dependencies!==null&&pr(e.dependencies)?(typeof N=="function"&&(pf(t,s,N,o),re=t.memoizedState),(fe=_l||Np(t,s,fe,o,ae,re,I)||e!==null&&e.dependencies!==null&&pr(e.dependencies))?(te||typeof m.UNSAFE_componentWillUpdate!="function"&&typeof m.componentWillUpdate!="function"||(typeof m.componentWillUpdate=="function"&&m.componentWillUpdate(o,re,I),typeof m.UNSAFE_componentWillUpdate=="function"&&m.UNSAFE_componentWillUpdate(o,re,I)),typeof m.componentDidUpdate=="function"&&(t.flags|=4),typeof m.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof m.componentDidUpdate!="function"||S===e.memoizedProps&&ae===e.memoizedState||(t.flags|=4),typeof m.getSnapshotBeforeUpdate!="function"||S===e.memoizedProps&&ae===e.memoizedState||(t.flags|=1024),t.memoizedProps=o,t.memoizedState=re),m.props=o,m.state=re,m.context=I,o=fe):(typeof m.componentDidUpdate!="function"||S===e.memoizedProps&&ae===e.memoizedState||(t.flags|=4),typeof m.getSnapshotBeforeUpdate!="function"||S===e.memoizedProps&&ae===e.memoizedState||(t.flags|=1024),o=!1)}return m=o,su(e,t),o=(t.flags&128)!==0,m||o?(m=t.stateNode,s=o&&typeof s.getDerivedStateFromError!="function"?null:m.render(),t.flags|=1,e!==null&&o?(t.child=Li(t,e.child,null,u),t.child=Li(t,null,s,u)):Rn(e,t,s,u),t.memoizedState=m.state,e=t.child):e=al(e,t,u),e}function qp(e,t,s,o){return ms(),t.flags|=256,Rn(e,t,s,o),t.child}var wf={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function bf(e){return{baseLanes:e,cachePool:G()}}function Sf(e,t,s){return e=e!==null?e.childLanes&~s:0,t&&(e|=Ra),e}function Gp(e,t,s){var o=t.pendingProps,u=!1,m=(t.flags&128)!==0,S;if((S=m)||(S=e!==null&&e.memoizedState===null?!1:(Jt.current&2)!==0),S&&(u=!0,t.flags&=-129),S=(t.flags&32)!==0,t.flags&=-33,e===null){if(it){if(u?Bl(t):Fl(),(e=kt)?(e=Jg(e,la),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:As!==null?{id:qa,overflow:Ga}:null,retryLane:536870912,hydrationErrors:null},s=Fc(e),s.return=t,t.child=s,gn=t,kt=null)):e=null,e===null)throw Ts(t);return sm(e)?t.lanes=32:t.lanes=536870912,null}var N=o.children;return o=o.fallback,u?(Fl(),u=t.mode,N=lu({mode:"hidden",children:N},u),o=et(o,u,s,null),N.return=t,o.return=t,N.sibling=o,t.child=N,o=t.child,o.memoizedState=bf(s),o.childLanes=Sf(e,S,s),t.memoizedState=wf,Co(null,o)):(Bl(t),Cf(t,N))}var I=e.memoizedState;if(I!==null&&(N=I.dehydrated,N!==null)){if(m)t.flags&256?(Bl(t),t.flags&=-257,t=jf(e,t,s)):t.memoizedState!==null?(Fl(),t.child=e.child,t.flags|=128,t=null):(Fl(),N=o.fallback,u=t.mode,o=lu({mode:"visible",children:o.children},u),N=et(N,u,s,null),N.flags|=2,o.return=t,N.return=t,o.sibling=N,t.child=o,Li(t,e.child,null,s),o=t.child,o.memoizedState=bf(s),o.childLanes=Sf(e,S,s),t.memoizedState=wf,t=Co(null,o));else if(Bl(t),sm(N)){if(S=N.nextSibling&&N.nextSibling.dataset,S)var te=S.dgst;S=te,o=Error(r(419)),o.stack="",o.digest=S,Ni({value:o,source:null,stack:null}),t=jf(e,t,s)}else if(un||Ti(e,t,s,!1),S=(s&e.childLanes)!==0,un||S){if(S=Mt,S!==null&&(o=wa(S,s),o!==0&&o!==I.retryLane))throw I.retryLane=o,Ce(e,o),ma(S,e,o),vf;am(N)||hu(),t=jf(e,t,s)}else am(N)?(t.flags|=192,t.child=e.child,t=null):(e=I.treeContext,kt=Ka(N.nextSibling),gn=t,it=!0,Ns=null,la=!1,e!==null&&Uc(t,e),t=Cf(t,o.children),t.flags|=4096);return t}return u?(Fl(),N=o.fallback,u=t.mode,I=e.child,te=I.sibling,o=ta(I,{mode:"hidden",children:o.children}),o.subtreeFlags=I.subtreeFlags&65011712,te!==null?N=ta(te,N):(N=et(N,u,s,null),N.flags|=2),N.return=t,o.return=t,o.sibling=N,t.child=o,Co(null,o),o=t.child,N=e.child.memoizedState,N===null?N=bf(s):(u=N.cachePool,u!==null?(I=Ht._currentValue,u=u.parent!==I?{parent:I,pool:I}:u):u=G(),N={baseLanes:N.baseLanes|s,cachePool:u}),o.memoizedState=N,o.childLanes=Sf(e,S,s),t.memoizedState=wf,Co(e.child,o)):(Bl(t),s=e.child,e=s.sibling,s=ta(s,{mode:"visible",children:o.children}),s.return=t,s.sibling=null,e!==null&&(S=t.deletions,S===null?(t.deletions=[e],t.flags|=16):S.push(e)),t.child=s,t.memoizedState=null,s)}function Cf(e,t){return t=lu({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function lu(e,t){return e=Tn(22,e,null,t),e.lanes=0,e}function jf(e,t,s){return Li(t,e.child,null,s),e=Cf(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Yp(e,t,s){e.lanes|=t;var o=e.alternate;o!==null&&(o.lanes|=t),hr(e.return,t,s)}function kf(e,t,s,o,u,m){var S=e.memoizedState;S===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:o,tail:s,tailMode:u,treeForkCount:m}:(S.isBackwards=t,S.rendering=null,S.renderingStartTime=0,S.last=o,S.tail=s,S.tailMode=u,S.treeForkCount=m)}function Vp(e,t,s){var o=t.pendingProps,u=o.revealOrder,m=o.tail;o=o.children;var S=Jt.current,N=(S&2)!==0;if(N?(S=S&1|2,t.flags|=128):S&=1,ie(Jt,S),Rn(e,t,o,s),o=it?ki:0,!N&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Yp(e,s,t);else if(e.tag===19)Yp(e,s,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(u){case"forwards":for(s=t.child,u=null;s!==null;)e=s.alternate,e!==null&&Vc(e)===null&&(u=s),s=s.sibling;s=u,s===null?(u=t.child,t.child=null):(u=s.sibling,s.sibling=null),kf(t,!1,u,s,m,o);break;case"backwards":case"unstable_legacy-backwards":for(s=null,u=t.child,t.child=null;u!==null;){if(e=u.alternate,e!==null&&Vc(e)===null){t.child=u;break}e=u.sibling,u.sibling=s,s=u,u=e}kf(t,!0,s,null,m,o);break;case"together":kf(t,!1,null,null,void 0,o);break;default:t.memoizedState=null}return t.child}function al(e,t,s){if(e!==null&&(t.dependencies=e.dependencies),Ul|=t.lanes,(s&t.childLanes)===0)if(e!==null){if(Ti(e,t,s,!1),(s&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(r(153));if(t.child!==null){for(e=t.child,s=ta(e,e.pendingProps),t.child=s,s.return=t;e.sibling!==null;)e=e.sibling,s=s.sibling=ta(e,e.pendingProps),s.return=t;s.sibling=null}return t.child}function Mf(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&pr(e)))}function Ow(e,t,s){switch(t.tag){case 3:de(t,t.stateNode.containerInfo),Lt(t,Ht,e.memoizedState.cache),ms();break;case 27:case 5:Le(t);break;case 4:de(t,t.stateNode.containerInfo);break;case 10:Lt(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Qd(t),null;break;case 13:var o=t.memoizedState;if(o!==null)return o.dehydrated!==null?(Bl(t),t.flags|=128,null):(s&t.child.childLanes)!==0?Gp(e,t,s):(Bl(t),e=al(e,t,s),e!==null?e.sibling:null);Bl(t);break;case 19:var u=(e.flags&128)!==0;if(o=(s&t.childLanes)!==0,o||(Ti(e,t,s,!1),o=(s&t.childLanes)!==0),u){if(o)return Vp(e,t,s);t.flags|=128}if(u=t.memoizedState,u!==null&&(u.rendering=null,u.tail=null,u.lastEffect=null),ie(Jt,Jt.current),o)break;return null;case 22:return t.lanes=0,Fp(e,t,s,t.pendingProps);case 24:Lt(t,Ht,e.memoizedState.cache)}return al(e,t,s)}function Kp(e,t,s){if(e!==null)if(e.memoizedProps!==t.pendingProps)un=!0;else{if(!Mf(e,s)&&(t.flags&128)===0)return un=!1,Ow(e,t,s);un=(e.flags&131072)!==0}else un=!1,it&&(t.flags&1048576)!==0&&$c(t,ki,t.index);switch(t.lanes=0,t.tag){case 16:e:{var o=t.pendingProps;if(e=yt(t.elementType),t.type=e,typeof e=="function")ro(e)?(o=_i(e,o),t.tag=1,t=Pp(null,t,e,o,s)):(t.tag=0,t=yf(null,t,e,o,s));else{if(e!=null){var u=e.$$typeof;if(u===H){t.tag=11,t=Op(null,t,e,o,s);break e}else if(u===L){t.tag=14,t=Ip(null,t,e,o,s);break e}}throw t=oe(e)||e,Error(r(306,t,""))}}return t;case 0:return yf(e,t,t.type,t.pendingProps,s);case 1:return o=t.type,u=_i(o,t.pendingProps),Pp(e,t,o,u,s);case 3:e:{if(de(t,t.stateNode.containerInfo),e===null)throw Error(r(387));o=t.pendingProps;var m=t.memoizedState;u=m.element,Gd(e,t),vo(t,o,null,s);var S=t.memoizedState;if(o=S.cache,Lt(t,Ht,o),o!==m.cache&&mo(t,[Ht],s,!0),xo(),o=S.element,m.isDehydrated)if(m={element:o,isDehydrated:!1,cache:S.cache},t.updateQueue.baseState=m,t.memoizedState=m,t.flags&256){t=qp(e,t,o,s);break e}else if(o!==u){u=na(Error(r(424)),t),Ni(u),t=qp(e,t,o,s);break e}else for(e=t.stateNode.containerInfo,e.nodeType===9?e=e.body:e=e.nodeName==="HTML"?e.ownerDocument.body:e,kt=Ka(e.firstChild),gn=t,it=!0,Ns=null,la=!0,s=Fh(t,null,o,s),t.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling;else{if(ms(),o===u){t=al(e,t,s);break e}Rn(e,t,o,s)}t=t.child}return t;case 26:return su(e,t),e===null?(s=lx(t.type,null,t.pendingProps,null))?t.memoizedState=s:it||(s=t.type,e=t.pendingProps,o=bu(ze.current).createElement(s),o[X]=t,o[Se]=e,En(o,s,e),vt(o),t.stateNode=o):t.memoizedState=lx(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return Le(t),e===null&&it&&(o=t.stateNode=nx(t.type,t.pendingProps,ze.current),gn=t,la=!0,u=kt,Vl(t.type)?(lm=u,kt=Ka(o.firstChild)):kt=u),Rn(e,t,t.pendingProps.children,s),su(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&it&&((u=o=kt)&&(o=fb(o,t.type,t.pendingProps,la),o!==null?(t.stateNode=o,gn=t,kt=Ka(o.firstChild),la=!1,u=!0):u=!1),u||Ts(t)),Le(t),u=t.type,m=t.pendingProps,S=e!==null?e.memoizedProps:null,o=m.children,em(u,m)?o=null:S!==null&&em(u,S)&&(t.flags|=32),t.memoizedState!==null&&(u=Zd(e,t,Aw,null,null,s),Bo._currentValue=u),su(e,t),Rn(e,t,o,s),t.child;case 6:return e===null&&it&&((e=s=kt)&&(s=mb(s,t.pendingProps,la),s!==null?(t.stateNode=s,gn=t,kt=null,e=!0):e=!1),e||Ts(t)),null;case 13:return Gp(e,t,s);case 4:return de(t,t.stateNode.containerInfo),o=t.pendingProps,e===null?t.child=Li(t,null,o,s):Rn(e,t,o,s),t.child;case 11:return Op(e,t,t.type,t.pendingProps,s);case 7:return Rn(e,t,t.pendingProps,s),t.child;case 8:return Rn(e,t,t.pendingProps.children,s),t.child;case 12:return Rn(e,t,t.pendingProps.children,s),t.child;case 10:return o=t.pendingProps,Lt(t,t.type,o.value),Rn(e,t,o.children,s),t.child;case 9:return u=t.type._context,o=t.pendingProps.children,Xs(t),u=on(u),o=o(u),t.flags|=1,Rn(e,t,o,s),t.child;case 14:return Ip(e,t,t.type,t.pendingProps,s);case 15:return Bp(e,t,t.type,t.pendingProps,s);case 19:return Vp(e,t,s);case 31:return _w(e,t,s);case 22:return Fp(e,t,s,t.pendingProps);case 24:return Xs(t),o=on(Ht),e===null?(u=E(),u===null&&(u=Mt,m=ho(),u.pooledCache=m,m.refCount++,m!==null&&(u.pooledCacheLanes|=s),u=m),t.memoizedState={parent:o,cache:u},qd(t),Lt(t,Ht,u)):((e.lanes&s)!==0&&(Gd(e,t),vo(t,null,null,s),xo()),u=e.memoizedState,m=t.memoizedState,u.parent!==o?(u={parent:o,cache:o},t.memoizedState=u,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=u),Lt(t,Ht,o)):(o=m.cache,Lt(t,Ht,o),o!==u.cache&&mo(t,[Ht],s,!0))),Rn(e,t,t.pendingProps.children,s),t.child;case 29:throw t.pendingProps}throw Error(r(156,t.tag))}function sl(e){e.flags|=4}function Af(e,t,s,o,u){if((t=(e.mode&32)!==0)&&(t=!1),t){if(e.flags|=16777216,(u&335544128)===u)if(e.stateNode.complete)e.flags|=8192;else if(bg())e.flags|=8192;else throw $t=Re,pe}else e.flags&=-16777217}function Wp(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!ux(t))if(bg())e.flags|=8192;else throw $t=Re,pe}function iu(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?gl():536870912,e.lanes|=t,jr|=t)}function jo(e,t){if(!it)switch(e.tailMode){case"hidden":t=e.tail;for(var s=null;t!==null;)t.alternate!==null&&(s=t),t=t.sibling;s===null?e.tail=null:s.sibling=null;break;case"collapsed":s=e.tail;for(var o=null;s!==null;)s.alternate!==null&&(o=s),s=s.sibling;o===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:o.sibling=null}}function Et(e){var t=e.alternate!==null&&e.alternate.child===e.child,s=0,o=0;if(t)for(var u=e.child;u!==null;)s|=u.lanes|u.childLanes,o|=u.subtreeFlags&65011712,o|=u.flags&65011712,u.return=e,u=u.sibling;else for(u=e.child;u!==null;)s|=u.lanes|u.childLanes,o|=u.subtreeFlags,o|=u.flags,u.return=e,u=u.sibling;return e.subtreeFlags|=o,e.childLanes=s,t}function Iw(e,t,s){var o=t.pendingProps;switch(Ai(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Et(t),null;case 1:return Et(t),null;case 3:return s=t.stateNode,o=null,e!==null&&(o=e.memoizedState.cache),t.memoizedState.cache!==o&&(t.flags|=2048),ia(Ht),He(),s.pendingContext&&(s.context=s.pendingContext,s.pendingContext=null),(e===null||e.child===null)&&(Qs(t)?sl(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,fo())),Et(t),null;case 26:var u=t.type,m=t.memoizedState;return e===null?(sl(t),m!==null?(Et(t),Wp(t,m)):(Et(t),Af(t,u,null,o,s))):m?m!==e.memoizedState?(sl(t),Et(t),Wp(t,m)):(Et(t),t.flags&=-16777217):(e=e.memoizedProps,e!==o&&sl(t),Et(t),Af(t,u,e,o,s)),null;case 27:if(Fe(t),s=ze.current,u=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==o&&sl(t);else{if(!o){if(t.stateNode===null)throw Error(r(166));return Et(t),null}e=we.current,Qs(t)?Pc(t):(e=nx(u,o,s),t.stateNode=e,sl(t))}return Et(t),null;case 5:if(Fe(t),u=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==o&&sl(t);else{if(!o){if(t.stateNode===null)throw Error(r(166));return Et(t),null}if(m=we.current,Qs(t))Pc(t);else{var S=bu(ze.current);switch(m){case 1:m=S.createElementNS("http://www.w3.org/2000/svg",u);break;case 2:m=S.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;default:switch(u){case"svg":m=S.createElementNS("http://www.w3.org/2000/svg",u);break;case"math":m=S.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;case"script":m=S.createElement("div"),m.innerHTML="<script><\/script>",m=m.removeChild(m.firstChild);break;case"select":m=typeof o.is=="string"?S.createElement("select",{is:o.is}):S.createElement("select"),o.multiple?m.multiple=!0:o.size&&(m.size=o.size);break;default:m=typeof o.is=="string"?S.createElement(u,{is:o.is}):S.createElement(u)}}m[X]=t,m[Se]=o;e:for(S=t.child;S!==null;){if(S.tag===5||S.tag===6)m.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===t)break e;for(;S.sibling===null;){if(S.return===null||S.return===t)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}t.stateNode=m;e:switch(En(m,u,o),u){case"button":case"input":case"select":case"textarea":o=!!o.autoFocus;break e;case"img":o=!0;break e;default:o=!1}o&&sl(t)}}return Et(t),Af(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,s),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==o&&sl(t);else{if(typeof o!="string"&&t.stateNode===null)throw Error(r(166));if(e=ze.current,Qs(t)){if(e=t.stateNode,s=t.memoizedProps,o=null,u=gn,u!==null)switch(u.tag){case 27:case 5:o=u.memoizedProps}e[X]=t,e=!!(e.nodeValue===s||o!==null&&o.suppressHydrationWarning===!0||Gg(e.nodeValue,s)),e||Ts(t,!0)}else e=bu(e).createTextNode(o),e[X]=t,t.stateNode=e}return Et(t),null;case 31:if(s=t.memoizedState,e===null||e.memoizedState!==null){if(o=Qs(t),s!==null){if(e===null){if(!o)throw Error(r(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(r(557));e[X]=t}else ms(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Et(t),e=!1}else s=fo(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=s),e=!0;if(!e)return t.flags&256?(Na(t),t):(Na(t),null);if((t.flags&128)!==0)throw Error(r(558))}return Et(t),null;case 13:if(o=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(u=Qs(t),o!==null&&o.dehydrated!==null){if(e===null){if(!u)throw Error(r(318));if(u=t.memoizedState,u=u!==null?u.dehydrated:null,!u)throw Error(r(317));u[X]=t}else ms(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Et(t),u=!1}else u=fo(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=u),u=!0;if(!u)return t.flags&256?(Na(t),t):(Na(t),null)}return Na(t),(t.flags&128)!==0?(t.lanes=s,t):(s=o!==null,e=e!==null&&e.memoizedState!==null,s&&(o=t.child,u=null,o.alternate!==null&&o.alternate.memoizedState!==null&&o.alternate.memoizedState.cachePool!==null&&(u=o.alternate.memoizedState.cachePool.pool),m=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(m=o.memoizedState.cachePool.pool),m!==u&&(o.flags|=2048)),s!==e&&s&&(t.child.flags|=8192),iu(t,t.updateQueue),Et(t),null);case 4:return He(),e===null&&Wf(t.stateNode.containerInfo),Et(t),null;case 10:return ia(t.type),Et(t),null;case 19:if($(Jt),o=t.memoizedState,o===null)return Et(t),null;if(u=(t.flags&128)!==0,m=o.rendering,m===null)if(u)jo(o,!1);else{if(Pt!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(m=Vc(e),m!==null){for(t.flags|=128,jo(o,!1),e=m.updateQueue,t.updateQueue=e,iu(t,e),t.subtreeFlags=0,e=s,s=t.child;s!==null;)rn(s,e),s=s.sibling;return ie(Jt,Jt.current&1|2),it&&fs(t,o.treeForkCount),t.child}e=e.sibling}o.tail!==null&&Oe()>du&&(t.flags|=128,u=!0,jo(o,!1),t.lanes=4194304)}else{if(!u)if(e=Vc(m),e!==null){if(t.flags|=128,u=!0,e=e.updateQueue,t.updateQueue=e,iu(t,e),jo(o,!0),o.tail===null&&o.tailMode==="hidden"&&!m.alternate&&!it)return Et(t),null}else 2*Oe()-o.renderingStartTime>du&&s!==536870912&&(t.flags|=128,u=!0,jo(o,!1),t.lanes=4194304);o.isBackwards?(m.sibling=t.child,t.child=m):(e=o.last,e!==null?e.sibling=m:t.child=m,o.last=m)}return o.tail!==null?(e=o.tail,o.rendering=e,o.tail=e.sibling,o.renderingStartTime=Oe(),e.sibling=null,s=Jt.current,ie(Jt,u?s&1|2:s&1),it&&fs(t,o.treeForkCount),e):(Et(t),null);case 22:case 23:return Na(t),Wd(),o=t.memoizedState!==null,e!==null?e.memoizedState!==null!==o&&(t.flags|=8192):o&&(t.flags|=8192),o?(s&536870912)!==0&&(t.flags&128)===0&&(Et(t),t.subtreeFlags&6&&(t.flags|=8192)):Et(t),s=t.updateQueue,s!==null&&iu(t,s.retryQueue),s=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(s=e.memoizedState.cachePool.pool),o=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(o=t.memoizedState.cachePool.pool),o!==s&&(t.flags|=2048),e!==null&&$(y),null;case 24:return s=null,e!==null&&(s=e.memoizedState.cache),t.memoizedState.cache!==s&&(t.flags|=2048),ia(Ht),Et(t),null;case 25:return null;case 30:return null}throw Error(r(156,t.tag))}function Bw(e,t){switch(Ai(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ia(Ht),He(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Fe(t),null;case 31:if(t.memoizedState!==null){if(Na(t),t.alternate===null)throw Error(r(340));ms()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Na(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));ms()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return $(Jt),null;case 4:return He(),null;case 10:return ia(t.type),null;case 22:case 23:return Na(t),Wd(),e!==null&&$(y),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return ia(Ht),null;case 25:return null;default:return null}}function Qp(e,t){switch(Ai(t),t.tag){case 3:ia(Ht),He();break;case 26:case 27:case 5:Fe(t);break;case 4:He();break;case 31:t.memoizedState!==null&&Na(t);break;case 13:Na(t);break;case 19:$(Jt);break;case 10:ia(t.type);break;case 22:case 23:Na(t),Wd(),e!==null&&$(y);break;case 24:ia(Ht)}}function ko(e,t){try{var s=t.updateQueue,o=s!==null?s.lastEffect:null;if(o!==null){var u=o.next;s=u;do{if((s.tag&e)===e){o=void 0;var m=s.create,S=s.inst;o=m(),S.destroy=o}s=s.next}while(s!==u)}}catch(N){bt(t,t.return,N)}}function Hl(e,t,s){try{var o=t.updateQueue,u=o!==null?o.lastEffect:null;if(u!==null){var m=u.next;o=m;do{if((o.tag&e)===e){var S=o.inst,N=S.destroy;if(N!==void 0){S.destroy=void 0,u=t;var I=s,te=N;try{te()}catch(fe){bt(u,I,fe)}}}o=o.next}while(o!==m)}}catch(fe){bt(t,t.return,fe)}}function Xp(e){var t=e.updateQueue;if(t!==null){var s=e.stateNode;try{$h(t,s)}catch(o){bt(e,e.return,o)}}}function Zp(e,t,s){s.props=_i(e.type,e.memoizedProps),s.state=e.memoizedState;try{s.componentWillUnmount()}catch(o){bt(e,t,o)}}function Mo(e,t){try{var s=e.ref;if(s!==null){switch(e.tag){case 26:case 27:case 5:var o=e.stateNode;break;case 30:o=e.stateNode;break;default:o=e.stateNode}typeof s=="function"?e.refCleanup=s(o):s.current=o}}catch(u){bt(e,t,u)}}function Rs(e,t){var s=e.ref,o=e.refCleanup;if(s!==null)if(typeof o=="function")try{o()}catch(u){bt(e,t,u)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof s=="function")try{s(null)}catch(u){bt(e,t,u)}else s.current=null}function Jp(e){var t=e.type,s=e.memoizedProps,o=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":s.autoFocus&&o.focus();break e;case"img":s.src?o.src=s.src:s.srcSet&&(o.srcset=s.srcSet)}}catch(u){bt(e,e.return,u)}}function Nf(e,t,s){try{var o=e.stateNode;ib(o,e.type,s,t),o[Se]=t}catch(u){bt(e,e.return,u)}}function eg(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Vl(e.type)||e.tag===4}function Tf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||eg(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Vl(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Rf(e,t,s){var o=e.tag;if(o===5||o===6)e=e.stateNode,t?(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s).insertBefore(e,t):(t=s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,t.appendChild(e),s=s._reactRootContainer,s!=null||t.onclick!==null||(t.onclick=Xn));else if(o!==4&&(o===27&&Vl(e.type)&&(s=e.stateNode,t=null),e=e.child,e!==null))for(Rf(e,t,s),e=e.sibling;e!==null;)Rf(e,t,s),e=e.sibling}function ru(e,t,s){var o=e.tag;if(o===5||o===6)e=e.stateNode,t?s.insertBefore(e,t):s.appendChild(e);else if(o!==4&&(o===27&&Vl(e.type)&&(s=e.stateNode),e=e.child,e!==null))for(ru(e,t,s),e=e.sibling;e!==null;)ru(e,t,s),e=e.sibling}function tg(e){var t=e.stateNode,s=e.memoizedProps;try{for(var o=e.type,u=t.attributes;u.length;)t.removeAttributeNode(u[0]);En(t,o,s),t[X]=e,t[Se]=s}catch(m){bt(e,e.return,m)}}var ll=!1,dn=!1,Ef=!1,ng=typeof WeakSet=="function"?WeakSet:Set,bn=null;function Fw(e,t){if(e=e.containerInfo,Zf=Nu,e=ka(e),yi(e)){if("selectionStart"in e)var s={start:e.selectionStart,end:e.selectionEnd};else e:{s=(s=e.ownerDocument)&&s.defaultView||window;var o=s.getSelection&&s.getSelection();if(o&&o.rangeCount!==0){s=o.anchorNode;var u=o.anchorOffset,m=o.focusNode;o=o.focusOffset;try{s.nodeType,m.nodeType}catch{s=null;break e}var S=0,N=-1,I=-1,te=0,fe=0,ve=e,ae=null;t:for(;;){for(var re;ve!==s||u!==0&&ve.nodeType!==3||(N=S+u),ve!==m||o!==0&&ve.nodeType!==3||(I=S+o),ve.nodeType===3&&(S+=ve.nodeValue.length),(re=ve.firstChild)!==null;)ae=ve,ve=re;for(;;){if(ve===e)break t;if(ae===s&&++te===u&&(N=S),ae===m&&++fe===o&&(I=S),(re=ve.nextSibling)!==null)break;ve=ae,ae=ve.parentNode}ve=re}s=N===-1||I===-1?null:{start:N,end:I}}else s=null}s=s||{start:0,end:0}}else s=null;for(Jf={focusedElem:e,selectionRange:s},Nu=!1,bn=t;bn!==null;)if(t=bn,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,bn=e;else for(;bn!==null;){switch(t=bn,m=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(s=0;s<e.length;s++)u=e[s],u.ref.impl=u.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&m!==null){e=void 0,s=t,u=m.memoizedProps,m=m.memoizedState,o=s.stateNode;try{var _e=_i(s.type,u);e=o.getSnapshotBeforeUpdate(_e,m),o.__reactInternalSnapshotBeforeUpdate=e}catch(Ge){bt(s,s.return,Ge)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,s=e.nodeType,s===9)nm(e);else if(s===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":nm(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(r(163))}if(e=t.sibling,e!==null){e.return=t.return,bn=e;break}bn=t.return}}function ag(e,t,s){var o=s.flags;switch(s.tag){case 0:case 11:case 15:rl(e,s),o&4&&ko(5,s);break;case 1:if(rl(e,s),o&4)if(e=s.stateNode,t===null)try{e.componentDidMount()}catch(S){bt(s,s.return,S)}else{var u=_i(s.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(u,t,e.__reactInternalSnapshotBeforeUpdate)}catch(S){bt(s,s.return,S)}}o&64&&Xp(s),o&512&&Mo(s,s.return);break;case 3:if(rl(e,s),o&64&&(e=s.updateQueue,e!==null)){if(t=null,s.child!==null)switch(s.child.tag){case 27:case 5:t=s.child.stateNode;break;case 1:t=s.child.stateNode}try{$h(e,t)}catch(S){bt(s,s.return,S)}}break;case 27:t===null&&o&4&&tg(s);case 26:case 5:rl(e,s),t===null&&o&4&&Jp(s),o&512&&Mo(s,s.return);break;case 12:rl(e,s);break;case 31:rl(e,s),o&4&&ig(e,s);break;case 13:rl(e,s),o&4&&rg(e,s),o&64&&(e=s.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(s=Kw.bind(null,s),hb(e,s))));break;case 22:if(o=s.memoizedState!==null||ll,!o){t=t!==null&&t.memoizedState!==null||dn,u=ll;var m=dn;ll=o,(dn=t)&&!m?ol(e,s,(s.subtreeFlags&8772)!==0):rl(e,s),ll=u,dn=m}break;case 30:break;default:rl(e,s)}}function sg(e){var t=e.alternate;t!==null&&(e.alternate=null,sg(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Rt(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var zt=null,ca=!1;function il(e,t,s){for(s=s.child;s!==null;)lg(e,t,s),s=s.sibling}function lg(e,t,s){if(Ke&&typeof Ke.onCommitFiberUnmount=="function")try{Ke.onCommitFiberUnmount(_a,s)}catch{}switch(s.tag){case 26:dn||Rs(s,t),il(e,t,s),s.memoizedState?s.memoizedState.count--:s.stateNode&&(s=s.stateNode,s.parentNode.removeChild(s));break;case 27:dn||Rs(s,t);var o=zt,u=ca;Vl(s.type)&&(zt=s.stateNode,ca=!1),il(e,t,s),_o(s.stateNode),zt=o,ca=u;break;case 5:dn||Rs(s,t);case 6:if(o=zt,u=ca,zt=null,il(e,t,s),zt=o,ca=u,zt!==null)if(ca)try{(zt.nodeType===9?zt.body:zt.nodeName==="HTML"?zt.ownerDocument.body:zt).removeChild(s.stateNode)}catch(m){bt(s,t,m)}else try{zt.removeChild(s.stateNode)}catch(m){bt(s,t,m)}break;case 18:zt!==null&&(ca?(e=zt,Xg(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,s.stateNode),Dr(e)):Xg(zt,s.stateNode));break;case 4:o=zt,u=ca,zt=s.stateNode.containerInfo,ca=!0,il(e,t,s),zt=o,ca=u;break;case 0:case 11:case 14:case 15:Hl(2,s,t),dn||Hl(4,s,t),il(e,t,s);break;case 1:dn||(Rs(s,t),o=s.stateNode,typeof o.componentWillUnmount=="function"&&Zp(s,t,o)),il(e,t,s);break;case 21:il(e,t,s);break;case 22:dn=(o=dn)||s.memoizedState!==null,il(e,t,s),dn=o;break;default:il(e,t,s)}}function ig(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Dr(e)}catch(s){bt(t,t.return,s)}}}function rg(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Dr(e)}catch(s){bt(t,t.return,s)}}function Hw(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new ng),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new ng),t;default:throw Error(r(435,e.tag))}}function ou(e,t){var s=Hw(e);t.forEach(function(o){if(!s.has(o)){s.add(o);var u=Ww.bind(null,e,o);o.then(u,u)}})}function ua(e,t){var s=t.deletions;if(s!==null)for(var o=0;o<s.length;o++){var u=s[o],m=e,S=t,N=S;e:for(;N!==null;){switch(N.tag){case 27:if(Vl(N.type)){zt=N.stateNode,ca=!1;break e}break;case 5:zt=N.stateNode,ca=!1;break e;case 3:case 4:zt=N.stateNode.containerInfo,ca=!0;break e}N=N.return}if(zt===null)throw Error(r(160));lg(m,S,u),zt=null,ca=!1,m=u.alternate,m!==null&&(m.return=null),u.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)og(t,e),t=t.sibling}var xs=null;function og(e,t){var s=e.alternate,o=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:ua(t,e),da(e),o&4&&(Hl(3,e,e.return),ko(3,e),Hl(5,e,e.return));break;case 1:ua(t,e),da(e),o&512&&(dn||s===null||Rs(s,s.return)),o&64&&ll&&(e=e.updateQueue,e!==null&&(o=e.callbacks,o!==null&&(s=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=s===null?o:s.concat(o))));break;case 26:var u=xs;if(ua(t,e),da(e),o&512&&(dn||s===null||Rs(s,s.return)),o&4){var m=s!==null?s.memoizedState:null;if(o=e.memoizedState,s===null)if(o===null)if(e.stateNode===null){e:{o=e.type,s=e.memoizedProps,u=u.ownerDocument||u;t:switch(o){case"title":m=u.getElementsByTagName("title")[0],(!m||m[at]||m[X]||m.namespaceURI==="http://www.w3.org/2000/svg"||m.hasAttribute("itemprop"))&&(m=u.createElement(o),u.head.insertBefore(m,u.querySelector("head > title"))),En(m,o,s),m[X]=e,vt(m),o=m;break e;case"link":var S=ox("link","href",u).get(o+(s.href||""));if(S){for(var N=0;N<S.length;N++)if(m=S[N],m.getAttribute("href")===(s.href==null||s.href===""?null:s.href)&&m.getAttribute("rel")===(s.rel==null?null:s.rel)&&m.getAttribute("title")===(s.title==null?null:s.title)&&m.getAttribute("crossorigin")===(s.crossOrigin==null?null:s.crossOrigin)){S.splice(N,1);break t}}m=u.createElement(o),En(m,o,s),u.head.appendChild(m);break;case"meta":if(S=ox("meta","content",u).get(o+(s.content||""))){for(N=0;N<S.length;N++)if(m=S[N],m.getAttribute("content")===(s.content==null?null:""+s.content)&&m.getAttribute("name")===(s.name==null?null:s.name)&&m.getAttribute("property")===(s.property==null?null:s.property)&&m.getAttribute("http-equiv")===(s.httpEquiv==null?null:s.httpEquiv)&&m.getAttribute("charset")===(s.charSet==null?null:s.charSet)){S.splice(N,1);break t}}m=u.createElement(o),En(m,o,s),u.head.appendChild(m);break;default:throw Error(r(468,o))}m[X]=e,vt(m),o=m}e.stateNode=o}else cx(u,e.type,e.stateNode);else e.stateNode=rx(u,o,e.memoizedProps);else m!==o?(m===null?s.stateNode!==null&&(s=s.stateNode,s.parentNode.removeChild(s)):m.count--,o===null?cx(u,e.type,e.stateNode):rx(u,o,e.memoizedProps)):o===null&&e.stateNode!==null&&Nf(e,e.memoizedProps,s.memoizedProps)}break;case 27:ua(t,e),da(e),o&512&&(dn||s===null||Rs(s,s.return)),s!==null&&o&4&&Nf(e,e.memoizedProps,s.memoizedProps);break;case 5:if(ua(t,e),da(e),o&512&&(dn||s===null||Rs(s,s.return)),e.flags&32){u=e.stateNode;try{Is(u,"")}catch(_e){bt(e,e.return,_e)}}o&4&&e.stateNode!=null&&(u=e.memoizedProps,Nf(e,u,s!==null?s.memoizedProps:u)),o&1024&&(Ef=!0);break;case 6:if(ua(t,e),da(e),o&4){if(e.stateNode===null)throw Error(r(162));o=e.memoizedProps,s=e.stateNode;try{s.nodeValue=o}catch(_e){bt(e,e.return,_e)}}break;case 3:if(ju=null,u=xs,xs=Su(t.containerInfo),ua(t,e),xs=u,da(e),o&4&&s!==null&&s.memoizedState.isDehydrated)try{Dr(t.containerInfo)}catch(_e){bt(e,e.return,_e)}Ef&&(Ef=!1,cg(e));break;case 4:o=xs,xs=Su(e.stateNode.containerInfo),ua(t,e),da(e),xs=o;break;case 12:ua(t,e),da(e);break;case 31:ua(t,e),da(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,ou(e,o)));break;case 13:ua(t,e),da(e),e.child.flags&8192&&e.memoizedState!==null!=(s!==null&&s.memoizedState!==null)&&(uu=Oe()),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,ou(e,o)));break;case 22:u=e.memoizedState!==null;var I=s!==null&&s.memoizedState!==null,te=ll,fe=dn;if(ll=te||u,dn=fe||I,ua(t,e),dn=fe,ll=te,da(e),o&8192)e:for(t=e.stateNode,t._visibility=u?t._visibility&-2:t._visibility|1,u&&(s===null||I||ll||dn||Oi(e)),s=null,t=e;;){if(t.tag===5||t.tag===26){if(s===null){I=s=t;try{if(m=I.stateNode,u)S=m.style,typeof S.setProperty=="function"?S.setProperty("display","none","important"):S.display="none";else{N=I.stateNode;var ve=I.memoizedProps.style,ae=ve!=null&&ve.hasOwnProperty("display")?ve.display:null;N.style.display=ae==null||typeof ae=="boolean"?"":(""+ae).trim()}}catch(_e){bt(I,I.return,_e)}}}else if(t.tag===6){if(s===null){I=t;try{I.stateNode.nodeValue=u?"":I.memoizedProps}catch(_e){bt(I,I.return,_e)}}}else if(t.tag===18){if(s===null){I=t;try{var re=I.stateNode;u?Zg(re,!0):Zg(I.stateNode,!1)}catch(_e){bt(I,I.return,_e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;s===t&&(s=null),t=t.return}s===t&&(s=null),t.sibling.return=t.return,t=t.sibling}o&4&&(o=e.updateQueue,o!==null&&(s=o.retryQueue,s!==null&&(o.retryQueue=null,ou(e,s))));break;case 19:ua(t,e),da(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,ou(e,o)));break;case 30:break;case 21:break;default:ua(t,e),da(e)}}function da(e){var t=e.flags;if(t&2){try{for(var s,o=e.return;o!==null;){if(eg(o)){s=o;break}o=o.return}if(s==null)throw Error(r(160));switch(s.tag){case 27:var u=s.stateNode,m=Tf(e);ru(e,m,u);break;case 5:var S=s.stateNode;s.flags&32&&(Is(S,""),s.flags&=-33);var N=Tf(e);ru(e,N,S);break;case 3:case 4:var I=s.stateNode.containerInfo,te=Tf(e);Rf(e,te,I);break;default:throw Error(r(161))}}catch(fe){bt(e,e.return,fe)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function cg(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;cg(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function rl(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)ag(e,t.alternate,t),t=t.sibling}function Oi(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Hl(4,t,t.return),Oi(t);break;case 1:Rs(t,t.return);var s=t.stateNode;typeof s.componentWillUnmount=="function"&&Zp(t,t.return,s),Oi(t);break;case 27:_o(t.stateNode);case 26:case 5:Rs(t,t.return),Oi(t);break;case 22:t.memoizedState===null&&Oi(t);break;case 30:Oi(t);break;default:Oi(t)}e=e.sibling}}function ol(e,t,s){for(s=s&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var o=t.alternate,u=e,m=t,S=m.flags;switch(m.tag){case 0:case 11:case 15:ol(u,m,s),ko(4,m);break;case 1:if(ol(u,m,s),o=m,u=o.stateNode,typeof u.componentDidMount=="function")try{u.componentDidMount()}catch(te){bt(o,o.return,te)}if(o=m,u=o.updateQueue,u!==null){var N=o.stateNode;try{var I=u.shared.hiddenCallbacks;if(I!==null)for(u.shared.hiddenCallbacks=null,u=0;u<I.length;u++)Hh(I[u],N)}catch(te){bt(o,o.return,te)}}s&&S&64&&Xp(m),Mo(m,m.return);break;case 27:tg(m);case 26:case 5:ol(u,m,s),s&&o===null&&S&4&&Jp(m),Mo(m,m.return);break;case 12:ol(u,m,s);break;case 31:ol(u,m,s),s&&S&4&&ig(u,m);break;case 13:ol(u,m,s),s&&S&4&&rg(u,m);break;case 22:m.memoizedState===null&&ol(u,m,s),Mo(m,m.return);break;case 30:break;default:ol(u,m,s)}t=t.sibling}}function Df(e,t){var s=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(s=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==s&&(e!=null&&e.refCount++,s!=null&&Ri(s))}function Lf(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Ri(e))}function vs(e,t,s,o){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)ug(e,t,s,o),t=t.sibling}function ug(e,t,s,o){var u=t.flags;switch(t.tag){case 0:case 11:case 15:vs(e,t,s,o),u&2048&&ko(9,t);break;case 1:vs(e,t,s,o);break;case 3:vs(e,t,s,o),u&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Ri(e)));break;case 12:if(u&2048){vs(e,t,s,o),e=t.stateNode;try{var m=t.memoizedProps,S=m.id,N=m.onPostCommit;typeof N=="function"&&N(S,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(I){bt(t,t.return,I)}}else vs(e,t,s,o);break;case 31:vs(e,t,s,o);break;case 13:vs(e,t,s,o);break;case 23:break;case 22:m=t.stateNode,S=t.alternate,t.memoizedState!==null?m._visibility&2?vs(e,t,s,o):Ao(e,t):m._visibility&2?vs(e,t,s,o):(m._visibility|=2,br(e,t,s,o,(t.subtreeFlags&10256)!==0||!1)),u&2048&&Df(S,t);break;case 24:vs(e,t,s,o),u&2048&&Lf(t.alternate,t);break;default:vs(e,t,s,o)}}function br(e,t,s,o,u){for(u=u&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var m=e,S=t,N=s,I=o,te=S.flags;switch(S.tag){case 0:case 11:case 15:br(m,S,N,I,u),ko(8,S);break;case 23:break;case 22:var fe=S.stateNode;S.memoizedState!==null?fe._visibility&2?br(m,S,N,I,u):Ao(m,S):(fe._visibility|=2,br(m,S,N,I,u)),u&&te&2048&&Df(S.alternate,S);break;case 24:br(m,S,N,I,u),u&&te&2048&&Lf(S.alternate,S);break;default:br(m,S,N,I,u)}t=t.sibling}}function Ao(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var s=e,o=t,u=o.flags;switch(o.tag){case 22:Ao(s,o),u&2048&&Df(o.alternate,o);break;case 24:Ao(s,o),u&2048&&Lf(o.alternate,o);break;default:Ao(s,o)}t=t.sibling}}var No=8192;function Sr(e,t,s){if(e.subtreeFlags&No)for(e=e.child;e!==null;)dg(e,t,s),e=e.sibling}function dg(e,t,s){switch(e.tag){case 26:Sr(e,t,s),e.flags&No&&e.memoizedState!==null&&Mb(s,xs,e.memoizedState,e.memoizedProps);break;case 5:Sr(e,t,s);break;case 3:case 4:var o=xs;xs=Su(e.stateNode.containerInfo),Sr(e,t,s),xs=o;break;case 22:e.memoizedState===null&&(o=e.alternate,o!==null&&o.memoizedState!==null?(o=No,No=16777216,Sr(e,t,s),No=o):Sr(e,t,s));break;default:Sr(e,t,s)}}function fg(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function To(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var s=0;s<t.length;s++){var o=t[s];bn=o,hg(o,e)}fg(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)mg(e),e=e.sibling}function mg(e){switch(e.tag){case 0:case 11:case 15:To(e),e.flags&2048&&Hl(9,e,e.return);break;case 3:To(e);break;case 12:To(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,cu(e)):To(e);break;default:To(e)}}function cu(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var s=0;s<t.length;s++){var o=t[s];bn=o,hg(o,e)}fg(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Hl(8,t,t.return),cu(t);break;case 22:s=t.stateNode,s._visibility&2&&(s._visibility&=-3,cu(t));break;default:cu(t)}e=e.sibling}}function hg(e,t){for(;bn!==null;){var s=bn;switch(s.tag){case 0:case 11:case 15:Hl(8,s,t);break;case 23:case 22:if(s.memoizedState!==null&&s.memoizedState.cachePool!==null){var o=s.memoizedState.cachePool.pool;o!=null&&o.refCount++}break;case 24:Ri(s.memoizedState.cache)}if(o=s.child,o!==null)o.return=s,bn=o;else e:for(s=e;bn!==null;){o=bn;var u=o.sibling,m=o.return;if(sg(o),o===s){bn=null;break e}if(u!==null){u.return=m,bn=u;break e}bn=m}}}var $w={getCacheForType:function(e){var t=on(Ht),s=t.data.get(e);return s===void 0&&(s=e(),t.data.set(e,s)),s},cacheSignal:function(){return on(Ht).controller.signal}},Uw=typeof WeakMap=="function"?WeakMap:Map,gt=0,Mt=null,rt=null,dt=0,wt=0,Ta=null,$l=!1,Cr=!1,zf=!1,cl=0,Pt=0,Ul=0,Ii=0,_f=0,Ra=0,jr=0,Ro=null,fa=null,Of=!1,uu=0,pg=0,du=1/0,fu=null,Pl=null,vn=0,ql=null,kr=null,ul=0,If=0,Bf=null,gg=null,Eo=0,Ff=null;function Ea(){return(gt&2)!==0&&dt!==0?dt&-dt:z.T!==null?Gf():as()}function xg(){if(Ra===0)if((dt&536870912)===0||it){var e=Ja;Ja<<=1,(Ja&3932160)===0&&(Ja=262144),Ra=e}else Ra=536870912;return e=Aa.current,e!==null&&(e.flags|=32),Ra}function ma(e,t,s){(e===Mt&&(wt===2||wt===9)||e.cancelPendingCommit!==null)&&(Mr(e,0),Gl(e,dt,Ra,!1)),Ba(e,s),((gt&2)===0||e!==Mt)&&(e===Mt&&((gt&2)===0&&(Ii|=s),Pt===4&&Gl(e,dt,Ra,!1)),Es(e))}function vg(e,t,s){if((gt&6)!==0)throw Error(r(327));var o=!s&&(t&127)===0&&(t&e.expiredLanes)===0||Hn(e,t),u=o?Gw(e,t):$f(e,t,!0),m=o;do{if(u===0){Cr&&!o&&Gl(e,t,0,!1);break}else{if(s=e.current.alternate,m&&!Pw(s)){u=$f(e,t,!1),m=!1;continue}if(u===2){if(m=t,e.errorRecoveryDisabledLanes&m)var S=0;else S=e.pendingLanes&-536870913,S=S!==0?S:S&536870912?536870912:0;if(S!==0){t=S;e:{var N=e;u=Ro;var I=N.current.memoizedState.isDehydrated;if(I&&(Mr(N,S).flags|=256),S=$f(N,S,!1),S!==2){if(zf&&!I){N.errorRecoveryDisabledLanes|=m,Ii|=m,u=4;break e}m=fa,fa=u,m!==null&&(fa===null?fa=m:fa.push.apply(fa,m))}u=S}if(m=!1,u!==2)continue}}if(u===1){Mr(e,0),Gl(e,t,0,!0);break}e:{switch(o=e,m=u,m){case 0:case 1:throw Error(r(345));case 4:if((t&4194048)!==t)break;case 6:Gl(o,t,Ra,!$l);break e;case 2:fa=null;break;case 3:case 5:break;default:throw Error(r(329))}if((t&62914560)===t&&(u=uu+300-Oe(),10<u)){if(Gl(o,t,Ra,!$l),ln(o,0,!0)!==0)break e;ul=t,o.timeoutHandle=Wg(yg.bind(null,o,s,fa,fu,Of,t,Ra,Ii,jr,$l,m,"Throttled",-0,0),u);break e}yg(o,s,fa,fu,Of,t,Ra,Ii,jr,$l,m,null,-0,0)}}break}while(!0);Es(e)}function yg(e,t,s,o,u,m,S,N,I,te,fe,ve,ae,re){if(e.timeoutHandle=-1,ve=t.subtreeFlags,ve&8192||(ve&16785408)===16785408){ve={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Xn},dg(t,m,ve);var _e=(m&62914560)===m?uu-Oe():(m&4194048)===m?pg-Oe():0;if(_e=Ab(ve,_e),_e!==null){ul=m,e.cancelPendingCommit=_e(Ag.bind(null,e,t,m,s,o,u,S,N,I,fe,ve,null,ae,re)),Gl(e,m,S,!te);return}}Ag(e,t,m,s,o,u,S,N,I)}function Pw(e){for(var t=e;;){var s=t.tag;if((s===0||s===11||s===15)&&t.flags&16384&&(s=t.updateQueue,s!==null&&(s=s.stores,s!==null)))for(var o=0;o<s.length;o++){var u=s[o],m=u.getSnapshot;u=u.value;try{if(!zn(m(),u))return!1}catch{return!1}}if(s=t.child,t.subtreeFlags&16384&&s!==null)s.return=t,t=s;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Gl(e,t,s,o){t&=~_f,t&=~Ii,e.suspendedLanes|=t,e.pingedLanes&=~t,o&&(e.warmLanes|=t),o=e.expirationTimes;for(var u=t;0<u;){var m=31-qt(u),S=1<<m;o[m]=-1,u&=~S}s!==0&&ts(e,s,t)}function mu(){return(gt&6)===0?(Do(0),!1):!0}function Hf(){if(rt!==null){if(wt===0)var e=rt.return;else e=rt,hs=Ya=null,tf(e),oa=null,gs=0,e=rt;for(;e!==null;)Qp(e.alternate,e),e=e.return;rt=null}}function Mr(e,t){var s=e.timeoutHandle;s!==-1&&(e.timeoutHandle=-1,cb(s)),s=e.cancelPendingCommit,s!==null&&(e.cancelPendingCommit=null,s()),ul=0,Hf(),Mt=e,rt=s=ta(e.current,null),dt=t,wt=0,Ta=null,$l=!1,Cr=Hn(e,t),zf=!1,jr=Ra=_f=Ii=Ul=Pt=0,fa=Ro=null,Of=!1,(t&8)!==0&&(t|=t&32);var o=e.entangledLanes;if(o!==0)for(e=e.entanglements,o&=t;0<o;){var u=31-qt(o),m=1<<u;t|=e[u],o&=~m}return cl=t,dr(),s}function wg(e,t){tt=null,z.H=So,t===O||t===xe?(t=ra(),wt=3):t===pe?(t=ra(),wt=4):wt=t===vf?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,Ta=t,rt===null&&(Pt=1,nu(e,na(t,e.current)))}function bg(){var e=Aa.current;return e===null?!0:(dt&4194048)===dt?Va===null:(dt&62914560)===dt||(dt&536870912)!==0?e===Va:!1}function Sg(){var e=z.H;return z.H=So,e===null?So:e}function Cg(){var e=z.A;return z.A=$w,e}function hu(){Pt=4,$l||(dt&4194048)!==dt&&Aa.current!==null||(Cr=!0),(Ul&134217727)===0&&(Ii&134217727)===0||Mt===null||Gl(Mt,dt,Ra,!1)}function $f(e,t,s){var o=gt;gt|=2;var u=Sg(),m=Cg();(Mt!==e||dt!==t)&&(fu=null,Mr(e,t)),t=!1;var S=Pt;e:do try{if(wt!==0&&rt!==null){var N=rt,I=Ta;switch(wt){case 8:Hf(),S=6;break e;case 3:case 2:case 9:case 6:Aa.current===null&&(t=!0);var te=wt;if(wt=0,Ta=null,Ar(e,N,I,te),s&&Cr){S=0;break e}break;default:te=wt,wt=0,Ta=null,Ar(e,N,I,te)}}qw(),S=Pt;break}catch(fe){wg(e,fe)}while(!0);return t&&e.shellSuspendCounter++,hs=Ya=null,gt=o,z.H=u,z.A=m,rt===null&&(Mt=null,dt=0,dr()),S}function qw(){for(;rt!==null;)jg(rt)}function Gw(e,t){var s=gt;gt|=2;var o=Sg(),u=Cg();Mt!==e||dt!==t?(fu=null,du=Oe()+500,Mr(e,t)):Cr=Hn(e,t);e:do try{if(wt!==0&&rt!==null){t=rt;var m=Ta;t:switch(wt){case 1:wt=0,Ta=null,Ar(e,t,m,1);break;case 2:case 9:if(Ve(m)){wt=0,Ta=null,kg(t);break}t=function(){wt!==2&&wt!==9||Mt!==e||(wt=7),Es(e)},m.then(t,t);break e;case 3:wt=7;break e;case 4:wt=5;break e;case 7:Ve(m)?(wt=0,Ta=null,kg(t)):(wt=0,Ta=null,Ar(e,t,m,7));break;case 5:var S=null;switch(rt.tag){case 26:S=rt.memoizedState;case 5:case 27:var N=rt;if(S?ux(S):N.stateNode.complete){wt=0,Ta=null;var I=N.sibling;if(I!==null)rt=I;else{var te=N.return;te!==null?(rt=te,pu(te)):rt=null}break t}}wt=0,Ta=null,Ar(e,t,m,5);break;case 6:wt=0,Ta=null,Ar(e,t,m,6);break;case 8:Hf(),Pt=6;break e;default:throw Error(r(462))}}Yw();break}catch(fe){wg(e,fe)}while(!0);return hs=Ya=null,z.H=o,z.A=u,gt=s,rt!==null?0:(Mt=null,dt=0,dr(),Pt)}function Yw(){for(;rt!==null&&!ke();)jg(rt)}function jg(e){var t=Kp(e.alternate,e,cl);e.memoizedProps=e.pendingProps,t===null?pu(e):rt=t}function kg(e){var t=e,s=t.alternate;switch(t.tag){case 15:case 0:t=Up(s,t,t.pendingProps,t.type,void 0,dt);break;case 11:t=Up(s,t,t.pendingProps,t.type.render,t.ref,dt);break;case 5:tf(t);default:Qp(s,t),t=rt=rn(t,cl),t=Kp(s,t,cl)}e.memoizedProps=e.pendingProps,t===null?pu(e):rt=t}function Ar(e,t,s,o){hs=Ya=null,tf(t),oa=null,gs=0;var u=t.return;try{if(zw(e,u,t,s,dt)){Pt=1,nu(e,na(s,e.current)),rt=null;return}}catch(m){if(u!==null)throw rt=u,m;Pt=1,nu(e,na(s,e.current)),rt=null;return}t.flags&32768?(it||o===1?e=!0:Cr||(dt&536870912)!==0?e=!1:($l=e=!0,(o===2||o===9||o===3||o===6)&&(o=Aa.current,o!==null&&o.tag===13&&(o.flags|=16384))),Mg(t,e)):pu(t)}function pu(e){var t=e;do{if((t.flags&32768)!==0){Mg(t,$l);return}e=t.return;var s=Iw(t.alternate,t,cl);if(s!==null){rt=s;return}if(t=t.sibling,t!==null){rt=t;return}rt=t=e}while(t!==null);Pt===0&&(Pt=5)}function Mg(e,t){do{var s=Bw(e.alternate,e);if(s!==null){s.flags&=32767,rt=s;return}if(s=e.return,s!==null&&(s.flags|=32768,s.subtreeFlags=0,s.deletions=null),!t&&(e=e.sibling,e!==null)){rt=e;return}rt=e=s}while(e!==null);Pt=6,rt=null}function Ag(e,t,s,o,u,m,S,N,I){e.cancelPendingCommit=null;do gu();while(vn!==0);if((gt&6)!==0)throw Error(r(327));if(t!==null){if(t===e.current)throw Error(r(177));if(m=t.lanes|t.childLanes,m|=Nl,Ss(e,s,m,S,N,I),e===Mt&&(rt=Mt=null,dt=0),kr=t,ql=e,ul=s,If=m,Bf=u,gg=o,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,Qw(Gn,function(){return Dg(),null})):(e.callbackNode=null,e.callbackPriority=0),o=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||o){o=z.T,z.T=null,u=Y.p,Y.p=2,S=gt,gt|=4;try{Fw(e,t,s)}finally{gt=S,Y.p=u,z.T=o}}vn=1,Ng(),Tg(),Rg()}}function Ng(){if(vn===1){vn=0;var e=ql,t=kr,s=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||s){s=z.T,z.T=null;var o=Y.p;Y.p=2;var u=gt;gt|=4;try{og(t,e);var m=Jf,S=ka(e.containerInfo),N=m.focusedElem,I=m.selectionRange;if(S!==N&&N&&N.ownerDocument&&kl(N.ownerDocument.documentElement,N)){if(I!==null&&yi(N)){var te=I.start,fe=I.end;if(fe===void 0&&(fe=te),"selectionStart"in N)N.selectionStart=te,N.selectionEnd=Math.min(fe,N.value.length);else{var ve=N.ownerDocument||document,ae=ve&&ve.defaultView||window;if(ae.getSelection){var re=ae.getSelection(),_e=N.textContent.length,Ge=Math.min(I.start,_e),jt=I.end===void 0?Ge:Math.min(I.end,_e);!re.extend&&Ge>jt&&(S=jt,jt=Ge,Ge=S);var V=vi(N,Ge),P=vi(N,jt);if(V&&P&&(re.rangeCount!==1||re.anchorNode!==V.node||re.anchorOffset!==V.offset||re.focusNode!==P.node||re.focusOffset!==P.offset)){var ee=ve.createRange();ee.setStart(V.node,V.offset),re.removeAllRanges(),Ge>jt?(re.addRange(ee),re.extend(P.node,P.offset)):(ee.setEnd(P.node,P.offset),re.addRange(ee))}}}}for(ve=[],re=N;re=re.parentNode;)re.nodeType===1&&ve.push({element:re,left:re.scrollLeft,top:re.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;N<ve.length;N++){var ge=ve[N];ge.element.scrollLeft=ge.left,ge.element.scrollTop=ge.top}}Nu=!!Zf,Jf=Zf=null}finally{gt=u,Y.p=o,z.T=s}}e.current=t,vn=2}}function Tg(){if(vn===2){vn=0;var e=ql,t=kr,s=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||s){s=z.T,z.T=null;var o=Y.p;Y.p=2;var u=gt;gt|=4;try{ag(e,t.alternate,t)}finally{gt=u,Y.p=o,z.T=s}}vn=3}}function Rg(){if(vn===4||vn===3){vn=0,Ne();var e=ql,t=kr,s=ul,o=gg;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?vn=5:(vn=0,kr=ql=null,Eg(e,e.pendingLanes));var u=e.pendingLanes;if(u===0&&(Pl=null),ns(s),t=t.stateNode,Ke&&typeof Ke.onCommitFiberRoot=="function")try{Ke.onCommitFiberRoot(_a,t,void 0,(t.current.flags&128)===128)}catch{}if(o!==null){t=z.T,u=Y.p,Y.p=2,z.T=null;try{for(var m=e.onRecoverableError,S=0;S<o.length;S++){var N=o[S];m(N.value,{componentStack:N.stack})}}finally{z.T=t,Y.p=u}}(ul&3)!==0&&gu(),Es(e),u=e.pendingLanes,(s&261930)!==0&&(u&42)!==0?e===Ff?Eo++:(Eo=0,Ff=e):Eo=0,Do(0)}}function Eg(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Ri(t)))}function gu(){return Ng(),Tg(),Rg(),Dg()}function Dg(){if(vn!==5)return!1;var e=ql,t=If;If=0;var s=ns(ul),o=z.T,u=Y.p;try{Y.p=32>s?32:s,z.T=null,s=Bf,Bf=null;var m=ql,S=ul;if(vn=0,kr=ql=null,ul=0,(gt&6)!==0)throw Error(r(331));var N=gt;if(gt|=4,mg(m.current),ug(m,m.current,S,s),gt=N,Do(0,!1),Ke&&typeof Ke.onPostCommitFiberRoot=="function")try{Ke.onPostCommitFiberRoot(_a,m)}catch{}return!0}finally{Y.p=u,z.T=o,Eg(e,t)}}function Lg(e,t,s){t=na(s,t),t=xf(e.stateNode,t,2),e=Il(e,t,2),e!==null&&(Ba(e,2),Es(e))}function bt(e,t,s){if(e.tag===3)Lg(e,e,s);else for(;t!==null;){if(t.tag===3){Lg(t,e,s);break}else if(t.tag===1){var o=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(Pl===null||!Pl.has(o))){e=na(s,e),s=zp(2),o=Il(t,s,2),o!==null&&(_p(s,o,t,e),Ba(o,2),Es(o));break}}t=t.return}}function Uf(e,t,s){var o=e.pingCache;if(o===null){o=e.pingCache=new Uw;var u=new Set;o.set(t,u)}else u=o.get(t),u===void 0&&(u=new Set,o.set(t,u));u.has(s)||(zf=!0,u.add(s),e=Vw.bind(null,e,t,s),t.then(e,e))}function Vw(e,t,s){var o=e.pingCache;o!==null&&o.delete(t),e.pingedLanes|=e.suspendedLanes&s,e.warmLanes&=~s,Mt===e&&(dt&s)===s&&(Pt===4||Pt===3&&(dt&62914560)===dt&&300>Oe()-uu?(gt&2)===0&&Mr(e,0):_f|=s,jr===dt&&(jr=0)),Es(e)}function zg(e,t){t===0&&(t=gl()),e=Ce(e,t),e!==null&&(Ba(e,t),Es(e))}function Kw(e){var t=e.memoizedState,s=0;t!==null&&(s=t.retryLane),zg(e,s)}function Ww(e,t){var s=0;switch(e.tag){case 31:case 13:var o=e.stateNode,u=e.memoizedState;u!==null&&(s=u.retryLane);break;case 19:o=e.stateNode;break;case 22:o=e.stateNode._retryCache;break;default:throw Error(r(314))}o!==null&&o.delete(t),zg(e,s)}function Qw(e,t){return ct(e,t)}var xu=null,Nr=null,Pf=!1,vu=!1,qf=!1,Yl=0;function Es(e){e!==Nr&&e.next===null&&(Nr===null?xu=Nr=e:Nr=Nr.next=e),vu=!0,Pf||(Pf=!0,Zw())}function Do(e,t){if(!qf&&vu){qf=!0;do for(var s=!1,o=xu;o!==null;){if(e!==0){var u=o.pendingLanes;if(u===0)var m=0;else{var S=o.suspendedLanes,N=o.pingedLanes;m=(1<<31-qt(42|e)+1)-1,m&=u&~(S&~N),m=m&201326741?m&201326741|1:m?m|2:0}m!==0&&(s=!0,Bg(o,m))}else m=dt,m=ln(o,o===Mt?m:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),(m&3)===0||Hn(o,m)||(s=!0,Bg(o,m));o=o.next}while(s);qf=!1}}function Xw(){_g()}function _g(){vu=Pf=!1;var e=0;Yl!==0&&ob()&&(e=Yl);for(var t=Oe(),s=null,o=xu;o!==null;){var u=o.next,m=Og(o,t);m===0?(o.next=null,s===null?xu=u:s.next=u,u===null&&(Nr=s)):(s=o,(e!==0||(m&3)!==0)&&(vu=!0)),o=u}vn!==0&&vn!==5||Do(e),Yl!==0&&(Yl=0)}function Og(e,t){for(var s=e.suspendedLanes,o=e.pingedLanes,u=e.expirationTimes,m=e.pendingLanes&-62914561;0<m;){var S=31-qt(m),N=1<<S,I=u[S];I===-1?((N&s)===0||(N&o)!==0)&&(u[S]=Yn(N,t)):I<=t&&(e.expiredLanes|=N),m&=~N}if(t=Mt,s=dt,s=ln(e,e===t?s:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o=e.callbackNode,s===0||e===t&&(wt===2||wt===9)||e.cancelPendingCommit!==null)return o!==null&&o!==null&&sn(o),e.callbackNode=null,e.callbackPriority=0;if((s&3)===0||Hn(e,s)){if(t=s&-s,t===e.callbackPriority)return t;switch(o!==null&&sn(o),ns(s)){case 2:case 8:s=Nt;break;case 32:s=Gn;break;case 268435456:s=Te;break;default:s=Gn}return o=Ig.bind(null,e),s=ct(s,o),e.callbackPriority=t,e.callbackNode=s,t}return o!==null&&o!==null&&sn(o),e.callbackPriority=2,e.callbackNode=null,2}function Ig(e,t){if(vn!==0&&vn!==5)return e.callbackNode=null,e.callbackPriority=0,null;var s=e.callbackNode;if(gu()&&e.callbackNode!==s)return null;var o=dt;return o=ln(e,e===Mt?o:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o===0?null:(vg(e,o,t),Og(e,Oe()),e.callbackNode!=null&&e.callbackNode===s?Ig.bind(null,e):null)}function Bg(e,t){if(gu())return null;vg(e,t,!0)}function Zw(){ub(function(){(gt&6)!==0?ct(Za,Xw):_g()})}function Gf(){if(Yl===0){var e=xn;e===0&&(e=Oa,Oa<<=1,(Oa&261888)===0&&(Oa=256)),Yl=e}return Yl}function Fg(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Sa(""+e)}function Hg(e,t){var s=t.ownerDocument.createElement("input");return s.name=t.name,s.value=t.value,e.id&&s.setAttribute("form",e.id),t.parentNode.insertBefore(s,t),e=new FormData(e),s.parentNode.removeChild(s),e}function Jw(e,t,s,o,u){if(t==="submit"&&s&&s.stateNode===u){var m=Fg((u[Se]||null).action),S=o.submitter;S&&(t=(t=S[Se]||null)?Fg(t.formAction):S.getAttribute("formAction"),t!==null&&(m=t,S=null));var N=new Hs("action","action",null,o,u);e.push({event:N,listeners:[{instance:null,listener:function(){if(o.defaultPrevented){if(Yl!==0){var I=S?Hg(u,S):new FormData(u);df(s,{pending:!0,data:I,method:u.method,action:m},null,I)}}else typeof m=="function"&&(N.preventDefault(),I=S?Hg(u,S):new FormData(u),df(s,{pending:!0,data:I,method:u.method,action:m},m,I))},currentTarget:u}]})}}for(var Yf=0;Yf<cr.length;Yf++){var Vf=cr[Yf],eb=Vf.toLowerCase(),tb=Vf[0].toUpperCase()+Vf.slice(1);ea(eb,"on"+tb)}ea(Al,"onAnimationEnd"),ea(so,"onAnimationIteration"),ea(or,"onAnimationStart"),ea("dblclick","onDoubleClick"),ea("focusin","onFocus"),ea("focusout","onBlur"),ea(Ic,"onTransitionRun"),ea(Fd,"onTransitionStart"),ea(lo,"onTransitionCancel"),ea(Bc,"onTransitionEnd"),It("onMouseEnter",["mouseout","mouseover"]),It("onMouseLeave",["mouseout","mouseover"]),It("onPointerEnter",["pointerout","pointerover"]),It("onPointerLeave",["pointerout","pointerover"]),Vt("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Vt("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Vt("onBeforeInput",["compositionend","keypress","textInput","paste"]),Vt("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Vt("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Vt("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Lo="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(" "),nb=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Lo));function $g(e,t){t=(t&4)!==0;for(var s=0;s<e.length;s++){var o=e[s],u=o.event;o=o.listeners;e:{var m=void 0;if(t)for(var S=o.length-1;0<=S;S--){var N=o[S],I=N.instance,te=N.currentTarget;if(N=N.listener,I!==m&&u.isPropagationStopped())break e;m=N,u.currentTarget=te;try{m(u)}catch(fe){ur(fe)}u.currentTarget=null,m=I}else for(S=0;S<o.length;S++){if(N=o[S],I=N.instance,te=N.currentTarget,N=N.listener,I!==m&&u.isPropagationStopped())break e;m=N,u.currentTarget=te;try{m(u)}catch(fe){ur(fe)}u.currentTarget=null,m=I}}}}function ot(e,t){var s=t[Je];s===void 0&&(s=t[Je]=new Set);var o=e+"__bubble";s.has(o)||(Ug(t,e,2,!1),s.add(o))}function Kf(e,t,s){var o=0;t&&(o|=4),Ug(s,e,o,t)}var yu="_reactListening"+Math.random().toString(36).slice(2);function Wf(e){if(!e[yu]){e[yu]=!0,Wn.forEach(function(s){s!=="selectionchange"&&(nb.has(s)||Kf(s,!1,e),Kf(s,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[yu]||(t[yu]=!0,Kf("selectionchange",!1,t))}}function Ug(e,t,s,o){switch(xx(t)){case 2:var u=Rb;break;case 8:u=Eb;break;default:u=um}s=u.bind(null,t,s,e),u=void 0,!$a||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(u=!0),o?u!==void 0?e.addEventListener(t,s,{capture:!0,passive:u}):e.addEventListener(t,s,!0):u!==void 0?e.addEventListener(t,s,{passive:u}):e.addEventListener(t,s,!1)}function Qf(e,t,s,o,u){var m=o;if((t&1)===0&&(t&2)===0&&o!==null)e:for(;;){if(o===null)return;var S=o.tag;if(S===3||S===4){var N=o.stateNode.containerInfo;if(N===u)break;if(S===4)for(S=o.return;S!==null;){var I=S.tag;if((I===3||I===4)&&S.stateNode.containerInfo===u)return;S=S.return}for(;N!==null;){if(S=_t(N),S===null)return;if(I=S.tag,I===5||I===6||I===26||I===27){o=m=S;continue e}N=N.parentNode}}o=o.return}lt(function(){var te=m,fe=Zi(s),ve=[];e:{var ae=io.get(e);if(ae!==void 0){var re=Hs,_e=e;switch(e){case"keypress":if(yl(s)===0)break e;case"keydown":case"keyup":re=zd;break;case"focusin":_e="focus",re=os;break;case"focusout":_e="blur",re=os;break;case"beforeblur":case"afterblur":re=os;break;case"click":if(s.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":re=wl;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":re=Ac;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":re=Zt;break;case Al:case so:case or:re=Dd;break;case Bc:re=us;break;case"scroll":case"scrollend":re=Mc;break;case"wheel":re=Id;break;case"copy":case"cut":case"paste":re=bl;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":re=Us;break;case"toggle":case"beforetoggle":re=ar}var Ge=(t&4)!==0,jt=!Ge&&(e==="scroll"||e==="scrollend"),V=Ge?ae!==null?ae+"Capture":null:ae;Ge=[];for(var P=te,ee;P!==null;){var ge=P;if(ee=ge.stateNode,ge=ge.tag,ge!==5&&ge!==26&&ge!==27||ee===null||V===null||(ge=An(P,V),ge!=null&&Ge.push(zo(P,ge,ee))),jt)break;P=P.return}0<Ge.length&&(ae=new re(ae,_e,null,s,fe),ve.push({event:ae,listeners:Ge}))}}if((t&7)===0){e:{if(ae=e==="mouseover"||e==="pointerover",re=e==="mouseout"||e==="pointerout",ae&&s!==Xi&&(_e=s.relatedTarget||s.fromElement)&&(_t(_e)||_e[De]))break e;if((re||ae)&&(ae=fe.window===fe?fe:(ae=fe.ownerDocument)?ae.defaultView||ae.parentWindow:window,re?(_e=s.relatedTarget||s.toElement,re=te,_e=_e?_t(_e):null,_e!==null&&(jt=d(_e),Ge=_e.tag,_e!==jt||Ge!==5&&Ge!==27&&Ge!==6)&&(_e=null)):(re=null,_e=te),re!==_e)){if(Ge=wl,ge="onMouseLeave",V="onMouseEnter",P="mouse",(e==="pointerout"||e==="pointerover")&&(Ge=Us,ge="onPointerLeave",V="onPointerEnter",P="pointer"),jt=re==null?ae:xt(re),ee=_e==null?ae:xt(_e),ae=new Ge(ge,P+"leave",re,s,fe),ae.target=jt,ae.relatedTarget=ee,ge=null,_t(fe)===te&&(Ge=new Ge(V,P+"enter",_e,s,fe),Ge.target=ee,Ge.relatedTarget=jt,ge=Ge),jt=ge,re&&_e)t:{for(Ge=ab,V=re,P=_e,ee=0,ge=V;ge;ge=Ge(ge))ee++;ge=0;for(var $e=P;$e;$e=Ge($e))ge++;for(;0<ee-ge;)V=Ge(V),ee--;for(;0<ge-ee;)P=Ge(P),ge--;for(;ee--;){if(V===P||P!==null&&V===P.alternate){Ge=V;break t}V=Ge(V),P=Ge(P)}Ge=null}else Ge=null;re!==null&&Pg(ve,ae,re,Ge,!1),_e!==null&&jt!==null&&Pg(ve,jt,_e,Ge,!0)}}e:{if(ae=te?xt(te):window,re=ae.nodeName&&ae.nodeName.toLowerCase(),re==="select"||re==="input"&&ae.type==="file")var ht=Zr;else if(ds(ae))if(lr)ht=rr;else{ht=eo;var Ie=Jr}else re=ae.nodeName,!re||re.toLowerCase()!=="input"||ae.type!=="checkbox"&&ae.type!=="radio"?te&&ui(te.elementType)&&(ht=Zr):ht=ir;if(ht&&(ht=ht(e,te))){hi(ve,ht,s,fe);break e}Ie&&Ie(e,ae,te),e==="focusout"&&te&&ae.type==="number"&&te.memoizedProps.value!=null&&bc(ae,"number",ae.value)}switch(Ie=te?xt(te):window,e){case"focusin":(ds(Ie)||Ie.contentEditable==="true")&&(Ys=Ie,pn=te,Ml=null);break;case"focusout":Ml=pn=Ys=null;break;case"mousedown":wi=!0;break;case"contextmenu":case"mouseup":case"dragend":wi=!1,bi(ve,s,fe);break;case"selectionchange":if(no)break;case"keydown":case"keyup":bi(ve,s,fe)}var st;if(js)e:{switch(e){case"compositionstart":var ft="onCompositionStart";break e;case"compositionend":ft="onCompositionEnd";break e;case"compositionupdate":ft="onCompositionUpdate";break e}ft=void 0}else jl?Qr(e,s)&&(ft="onCompositionEnd"):e==="keydown"&&s.keyCode===229&&(ft="onCompositionStart");ft&&(Dc&&s.locale!=="ko"&&(jl||ft!=="onCompositionStart"?ft==="onCompositionEnd"&&jl&&(st=vl()):(is=fe,Vr="value"in is?is.value:is.textContent,jl=!0)),Ie=wu(te,ft),0<Ie.length&&(ft=new Wr(ft,e,null,s,fe),ve.push({event:ft,listeners:Ie}),st?ft.data=st:(st=zc(s),st!==null&&(ft.data=st)))),(st=Ec?Bd(e,s):_c(e,s))&&(ft=wu(te,"onBeforeInput"),0<ft.length&&(Ie=new Wr("onBeforeInput","beforeinput",null,s,fe),ve.push({event:Ie,listeners:ft}),Ie.data=st)),Jw(ve,e,te,s,fe)}$g(ve,t)})}function zo(e,t,s){return{instance:e,listener:t,currentTarget:s}}function wu(e,t){for(var s=t+"Capture",o=[];e!==null;){var u=e,m=u.stateNode;if(u=u.tag,u!==5&&u!==26&&u!==27||m===null||(u=An(e,s),u!=null&&o.unshift(zo(e,u,m)),u=An(e,t),u!=null&&o.push(zo(e,u,m))),e.tag===3)return o;e=e.return}return[]}function ab(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Pg(e,t,s,o,u){for(var m=t._reactName,S=[];s!==null&&s!==o;){var N=s,I=N.alternate,te=N.stateNode;if(N=N.tag,I!==null&&I===o)break;N!==5&&N!==26&&N!==27||te===null||(I=te,u?(te=An(s,m),te!=null&&S.unshift(zo(s,te,I))):u||(te=An(s,m),te!=null&&S.push(zo(s,te,I)))),s=s.return}S.length!==0&&e.push({event:t,listeners:S})}var sb=/\r\n?/g,lb=/\u0000|\uFFFD/g;function qg(e){return(typeof e=="string"?e:""+e).replace(sb,`
|
|
9
|
+
`).replace(lb,"")}function Gg(e,t){return t=qg(t),qg(e)===t}function Ct(e,t,s,o,u,m){switch(s){case"children":typeof o=="string"?t==="body"||t==="textarea"&&o===""||Is(e,o):(typeof o=="number"||typeof o=="bigint")&&t!=="body"&&Is(e,""+o);break;case"className":ba(e,"class",o);break;case"tabIndex":ba(e,"tabindex",o);break;case"dir":case"role":case"viewBox":case"width":case"height":ba(e,s,o);break;case"style":jc(e,o,m);break;case"data":if(t!=="object"){ba(e,"data",o);break}case"src":case"href":if(o===""&&(t!=="a"||s!=="href")){e.removeAttribute(s);break}if(o==null||typeof o=="function"||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(s);break}o=Sa(""+o),e.setAttribute(s,o);break;case"action":case"formAction":if(typeof o=="function"){e.setAttribute(s,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof m=="function"&&(s==="formAction"?(t!=="input"&&Ct(e,t,"name",u.name,u,null),Ct(e,t,"formEncType",u.formEncType,u,null),Ct(e,t,"formMethod",u.formMethod,u,null),Ct(e,t,"formTarget",u.formTarget,u,null)):(Ct(e,t,"encType",u.encType,u,null),Ct(e,t,"method",u.method,u,null),Ct(e,t,"target",u.target,u,null)));if(o==null||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(s);break}o=Sa(""+o),e.setAttribute(s,o);break;case"onClick":o!=null&&(e.onclick=Xn);break;case"onScroll":o!=null&&ot("scroll",e);break;case"onScrollEnd":o!=null&&ot("scrollend",e);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(r(61));if(s=o.__html,s!=null){if(u.children!=null)throw Error(r(60));e.innerHTML=s}}break;case"multiple":e.multiple=o&&typeof o!="function"&&typeof o!="symbol";break;case"muted":e.muted=o&&typeof o!="function"&&typeof o!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(o==null||typeof o=="function"||typeof o=="boolean"||typeof o=="symbol"){e.removeAttribute("xlink:href");break}s=Sa(""+o),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",s);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":o!=null&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(s,""+o):e.removeAttribute(s);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":o&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(s,""):e.removeAttribute(s);break;case"capture":case"download":o===!0?e.setAttribute(s,""):o!==!1&&o!=null&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(s,o):e.removeAttribute(s);break;case"cols":case"rows":case"size":case"span":o!=null&&typeof o!="function"&&typeof o!="symbol"&&!isNaN(o)&&1<=o?e.setAttribute(s,o):e.removeAttribute(s);break;case"rowSpan":case"start":o==null||typeof o=="function"||typeof o=="symbol"||isNaN(o)?e.removeAttribute(s):e.setAttribute(s,o);break;case"popover":ot("beforetoggle",e),ot("toggle",e),ri(e,"popover",o);break;case"xlinkActuate":Mn(e,"http://www.w3.org/1999/xlink","xlink:actuate",o);break;case"xlinkArcrole":Mn(e,"http://www.w3.org/1999/xlink","xlink:arcrole",o);break;case"xlinkRole":Mn(e,"http://www.w3.org/1999/xlink","xlink:role",o);break;case"xlinkShow":Mn(e,"http://www.w3.org/1999/xlink","xlink:show",o);break;case"xlinkTitle":Mn(e,"http://www.w3.org/1999/xlink","xlink:title",o);break;case"xlinkType":Mn(e,"http://www.w3.org/1999/xlink","xlink:type",o);break;case"xmlBase":Mn(e,"http://www.w3.org/XML/1998/namespace","xml:base",o);break;case"xmlLang":Mn(e,"http://www.w3.org/XML/1998/namespace","xml:lang",o);break;case"xmlSpace":Mn(e,"http://www.w3.org/XML/1998/namespace","xml:space",o);break;case"is":ri(e,"is",o);break;case"innerText":case"textContent":break;default:(!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(s=kc.get(s)||s,ri(e,s,o))}}function Xf(e,t,s,o,u,m){switch(s){case"style":jc(e,o,m);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(r(61));if(s=o.__html,s!=null){if(u.children!=null)throw Error(r(60));e.innerHTML=s}}break;case"children":typeof o=="string"?Is(e,o):(typeof o=="number"||typeof o=="bigint")&&Is(e,""+o);break;case"onScroll":o!=null&&ot("scroll",e);break;case"onScrollEnd":o!=null&&ot("scrollend",e);break;case"onClick":o!=null&&(e.onclick=Xn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Qn.hasOwnProperty(s))e:{if(s[0]==="o"&&s[1]==="n"&&(u=s.endsWith("Capture"),t=s.slice(2,u?s.length-7:void 0),m=e[Se]||null,m=m!=null?m[s]:null,typeof m=="function"&&e.removeEventListener(t,m,u),typeof o=="function")){typeof m!="function"&&m!==null&&(s in e?e[s]=null:e.hasAttribute(s)&&e.removeAttribute(s)),e.addEventListener(t,o,u);break e}s in e?e[s]=o:o===!0?e.setAttribute(s,""):ri(e,s,o)}}}function En(e,t,s){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":ot("error",e),ot("load",e);var o=!1,u=!1,m;for(m in s)if(s.hasOwnProperty(m)){var S=s[m];if(S!=null)switch(m){case"src":o=!0;break;case"srcSet":u=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,t));default:Ct(e,t,m,S,s,null)}}u&&Ct(e,t,"srcSet",s.srcSet,s,null),o&&Ct(e,t,"src",s.src,s,null);return;case"input":ot("invalid",e);var N=m=S=u=null,I=null,te=null;for(o in s)if(s.hasOwnProperty(o)){var fe=s[o];if(fe!=null)switch(o){case"name":u=fe;break;case"type":S=fe;break;case"checked":I=fe;break;case"defaultChecked":te=fe;break;case"value":m=fe;break;case"defaultValue":N=fe;break;case"children":case"dangerouslySetInnerHTML":if(fe!=null)throw Error(r(137,t));break;default:Ct(e,t,o,fe,s,null)}}Td(e,m,N,I,te,S,u,!1);return;case"select":ot("invalid",e),o=S=m=null;for(u in s)if(s.hasOwnProperty(u)&&(N=s[u],N!=null))switch(u){case"value":m=N;break;case"defaultValue":S=N;break;case"multiple":o=N;default:Ct(e,t,u,N,s,null)}t=m,s=S,e.multiple=!!o,t!=null?ci(e,!!o,t,!1):s!=null&&ci(e,!!o,s,!0);return;case"textarea":ot("invalid",e),m=u=o=null;for(S in s)if(s.hasOwnProperty(S)&&(N=s[S],N!=null))switch(S){case"value":o=N;break;case"defaultValue":u=N;break;case"children":m=N;break;case"dangerouslySetInnerHTML":if(N!=null)throw Error(r(91));break;default:Ct(e,t,S,N,s,null)}Gr(e,o,u,m);return;case"option":for(I in s)s.hasOwnProperty(I)&&(o=s[I],o!=null)&&(I==="selected"?e.selected=o&&typeof o!="function"&&typeof o!="symbol":Ct(e,t,I,o,s,null));return;case"dialog":ot("beforetoggle",e),ot("toggle",e),ot("cancel",e),ot("close",e);break;case"iframe":case"object":ot("load",e);break;case"video":case"audio":for(o=0;o<Lo.length;o++)ot(Lo[o],e);break;case"image":ot("error",e),ot("load",e);break;case"details":ot("toggle",e);break;case"embed":case"source":case"link":ot("error",e),ot("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(te in s)if(s.hasOwnProperty(te)&&(o=s[te],o!=null))switch(te){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,t));default:Ct(e,t,te,o,s,null)}return;default:if(ui(t)){for(fe in s)s.hasOwnProperty(fe)&&(o=s[fe],o!==void 0&&Xf(e,t,fe,o,s,void 0));return}}for(N in s)s.hasOwnProperty(N)&&(o=s[N],o!=null&&Ct(e,t,N,o,s,null))}function ib(e,t,s,o){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var u=null,m=null,S=null,N=null,I=null,te=null,fe=null;for(re in s){var ve=s[re];if(s.hasOwnProperty(re)&&ve!=null)switch(re){case"checked":break;case"value":break;case"defaultValue":I=ve;default:o.hasOwnProperty(re)||Ct(e,t,re,null,o,ve)}}for(var ae in o){var re=o[ae];if(ve=s[ae],o.hasOwnProperty(ae)&&(re!=null||ve!=null))switch(ae){case"type":m=re;break;case"name":u=re;break;case"checked":te=re;break;case"defaultChecked":fe=re;break;case"value":S=re;break;case"defaultValue":N=re;break;case"children":case"dangerouslySetInnerHTML":if(re!=null)throw Error(r(137,t));break;default:re!==ve&&Ct(e,t,ae,re,o,ve)}}oi(e,S,N,I,te,fe,m,u);return;case"select":re=S=N=ae=null;for(m in s)if(I=s[m],s.hasOwnProperty(m)&&I!=null)switch(m){case"value":break;case"multiple":re=I;default:o.hasOwnProperty(m)||Ct(e,t,m,null,o,I)}for(u in o)if(m=o[u],I=s[u],o.hasOwnProperty(u)&&(m!=null||I!=null))switch(u){case"value":ae=m;break;case"defaultValue":N=m;break;case"multiple":S=m;default:m!==I&&Ct(e,t,u,m,o,I)}t=N,s=S,o=re,ae!=null?ci(e,!!s,ae,!1):!!o!=!!s&&(t!=null?ci(e,!!s,t,!0):ci(e,!!s,s?[]:"",!1));return;case"textarea":re=ae=null;for(N in s)if(u=s[N],s.hasOwnProperty(N)&&u!=null&&!o.hasOwnProperty(N))switch(N){case"value":break;case"children":break;default:Ct(e,t,N,null,o,u)}for(S in o)if(u=o[S],m=s[S],o.hasOwnProperty(S)&&(u!=null||m!=null))switch(S){case"value":ae=u;break;case"defaultValue":re=u;break;case"children":break;case"dangerouslySetInnerHTML":if(u!=null)throw Error(r(91));break;default:u!==m&&Ct(e,t,S,u,o,m)}Sc(e,ae,re);return;case"option":for(var _e in s)ae=s[_e],s.hasOwnProperty(_e)&&ae!=null&&!o.hasOwnProperty(_e)&&(_e==="selected"?e.selected=!1:Ct(e,t,_e,null,o,ae));for(I in o)ae=o[I],re=s[I],o.hasOwnProperty(I)&&ae!==re&&(ae!=null||re!=null)&&(I==="selected"?e.selected=ae&&typeof ae!="function"&&typeof ae!="symbol":Ct(e,t,I,ae,o,re));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 Ge in s)ae=s[Ge],s.hasOwnProperty(Ge)&&ae!=null&&!o.hasOwnProperty(Ge)&&Ct(e,t,Ge,null,o,ae);for(te in o)if(ae=o[te],re=s[te],o.hasOwnProperty(te)&&ae!==re&&(ae!=null||re!=null))switch(te){case"children":case"dangerouslySetInnerHTML":if(ae!=null)throw Error(r(137,t));break;default:Ct(e,t,te,ae,o,re)}return;default:if(ui(t)){for(var jt in s)ae=s[jt],s.hasOwnProperty(jt)&&ae!==void 0&&!o.hasOwnProperty(jt)&&Xf(e,t,jt,void 0,o,ae);for(fe in o)ae=o[fe],re=s[fe],!o.hasOwnProperty(fe)||ae===re||ae===void 0&&re===void 0||Xf(e,t,fe,ae,o,re);return}}for(var V in s)ae=s[V],s.hasOwnProperty(V)&&ae!=null&&!o.hasOwnProperty(V)&&Ct(e,t,V,null,o,ae);for(ve in o)ae=o[ve],re=s[ve],!o.hasOwnProperty(ve)||ae===re||ae==null&&re==null||Ct(e,t,ve,ae,o,re)}function Yg(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function rb(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,s=performance.getEntriesByType("resource"),o=0;o<s.length;o++){var u=s[o],m=u.transferSize,S=u.initiatorType,N=u.duration;if(m&&N&&Yg(S)){for(S=0,N=u.responseEnd,o+=1;o<s.length;o++){var I=s[o],te=I.startTime;if(te>N)break;var fe=I.transferSize,ve=I.initiatorType;fe&&Yg(ve)&&(I=I.responseEnd,S+=fe*(I<N?1:(N-te)/(I-te)))}if(--o,t+=8*(m+S)/(u.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var Zf=null,Jf=null;function bu(e){return e.nodeType===9?e:e.ownerDocument}function Vg(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Kg(e,t){if(e===0)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&t==="foreignObject"?0:e}function em(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.children=="bigint"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var tm=null;function ob(){var e=window.event;return e&&e.type==="popstate"?e===tm?!1:(tm=e,!0):(tm=null,!1)}var Wg=typeof setTimeout=="function"?setTimeout:void 0,cb=typeof clearTimeout=="function"?clearTimeout:void 0,Qg=typeof Promise=="function"?Promise:void 0,ub=typeof queueMicrotask=="function"?queueMicrotask:typeof Qg<"u"?function(e){return Qg.resolve(null).then(e).catch(db)}:Wg;function db(e){setTimeout(function(){throw e})}function Vl(e){return e==="head"}function Xg(e,t){var s=t,o=0;do{var u=s.nextSibling;if(e.removeChild(s),u&&u.nodeType===8)if(s=u.data,s==="/$"||s==="/&"){if(o===0){e.removeChild(u),Dr(t);return}o--}else if(s==="$"||s==="$?"||s==="$~"||s==="$!"||s==="&")o++;else if(s==="html")_o(e.ownerDocument.documentElement);else if(s==="head"){s=e.ownerDocument.head,_o(s);for(var m=s.firstChild;m;){var S=m.nextSibling,N=m.nodeName;m[at]||N==="SCRIPT"||N==="STYLE"||N==="LINK"&&m.rel.toLowerCase()==="stylesheet"||s.removeChild(m),m=S}}else s==="body"&&_o(e.ownerDocument.body);s=u}while(s);Dr(t)}function Zg(e,t){var s=e;e=0;do{var o=s.nextSibling;if(s.nodeType===1?t?(s._stashedDisplay=s.style.display,s.style.display="none"):(s.style.display=s._stashedDisplay||"",s.getAttribute("style")===""&&s.removeAttribute("style")):s.nodeType===3&&(t?(s._stashedText=s.nodeValue,s.nodeValue=""):s.nodeValue=s._stashedText||""),o&&o.nodeType===8)if(s=o.data,s==="/$"){if(e===0)break;e--}else s!=="$"&&s!=="$?"&&s!=="$~"&&s!=="$!"||e++;s=o}while(s)}function nm(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var s=t;switch(t=t.nextSibling,s.nodeName){case"HTML":case"HEAD":case"BODY":nm(s),Rt(s);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(s.rel.toLowerCase()==="stylesheet")continue}e.removeChild(s)}}function fb(e,t,s,o){for(;e.nodeType===1;){var u=s;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!o&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(o){if(!e[at])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(m=e.getAttribute("rel"),m==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(m!==u.rel||e.getAttribute("href")!==(u.href==null||u.href===""?null:u.href)||e.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin)||e.getAttribute("title")!==(u.title==null?null:u.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(m=e.getAttribute("src"),(m!==(u.src==null?null:u.src)||e.getAttribute("type")!==(u.type==null?null:u.type)||e.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin))&&m&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(t==="input"&&e.type==="hidden"){var m=u.name==null?null:""+u.name;if(u.type==="hidden"&&e.getAttribute("name")===m)return e}else return e;if(e=Ka(e.nextSibling),e===null)break}return null}function mb(e,t,s){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!s||(e=Ka(e.nextSibling),e===null))return null;return e}function Jg(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=Ka(e.nextSibling),e===null))return null;return e}function am(e){return e.data==="$?"||e.data==="$~"}function sm(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function hb(e,t){var s=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||s.readyState!=="loading")t();else{var o=function(){t(),s.removeEventListener("DOMContentLoaded",o)};s.addEventListener("DOMContentLoaded",o),e._reactRetry=o}}function Ka(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?"||t==="$~"||t==="&"||t==="F!"||t==="F")break;if(t==="/$"||t==="/&")return null}}return e}var lm=null;function ex(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="/$"||s==="/&"){if(t===0)return Ka(e.nextSibling);t--}else s!=="$"&&s!=="$!"&&s!=="$?"&&s!=="$~"&&s!=="&"||t++}e=e.nextSibling}return null}function tx(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="$"||s==="$!"||s==="$?"||s==="$~"||s==="&"){if(t===0)return e;t--}else s!=="/$"&&s!=="/&"||t++}e=e.previousSibling}return null}function nx(e,t,s){switch(t=bu(s),e){case"html":if(e=t.documentElement,!e)throw Error(r(452));return e;case"head":if(e=t.head,!e)throw Error(r(453));return e;case"body":if(e=t.body,!e)throw Error(r(454));return e;default:throw Error(r(451))}}function _o(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Rt(e)}var Wa=new Map,ax=new Set;function Su(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var dl=Y.d;Y.d={f:pb,r:gb,D:xb,C:vb,L:yb,m:wb,X:Sb,S:bb,M:Cb};function pb(){var e=dl.f(),t=mu();return e||t}function gb(e){var t=Yt(e);t!==null&&t.tag===5&&t.type==="form"?wp(t):dl.r(e)}var Tr=typeof document>"u"?null:document;function sx(e,t,s){var o=Tr;if(o&&typeof t=="string"&&t){var u=mn(t);u='link[rel="'+e+'"][href="'+u+'"]',typeof s=="string"&&(u+='[crossorigin="'+s+'"]'),ax.has(u)||(ax.add(u),e={rel:e,crossOrigin:s,href:t},o.querySelector(u)===null&&(t=o.createElement("link"),En(t,"link",e),vt(t),o.head.appendChild(t)))}}function xb(e){dl.D(e),sx("dns-prefetch",e,null)}function vb(e,t){dl.C(e,t),sx("preconnect",e,t)}function yb(e,t,s){dl.L(e,t,s);var o=Tr;if(o&&e&&t){var u='link[rel="preload"][as="'+mn(t)+'"]';t==="image"&&s&&s.imageSrcSet?(u+='[imagesrcset="'+mn(s.imageSrcSet)+'"]',typeof s.imageSizes=="string"&&(u+='[imagesizes="'+mn(s.imageSizes)+'"]')):u+='[href="'+mn(e)+'"]';var m=u;switch(t){case"style":m=Rr(e);break;case"script":m=Er(e)}Wa.has(m)||(e=v({rel:"preload",href:t==="image"&&s&&s.imageSrcSet?void 0:e,as:t},s),Wa.set(m,e),o.querySelector(u)!==null||t==="style"&&o.querySelector(Oo(m))||t==="script"&&o.querySelector(Io(m))||(t=o.createElement("link"),En(t,"link",e),vt(t),o.head.appendChild(t)))}}function wb(e,t){dl.m(e,t);var s=Tr;if(s&&e){var o=t&&typeof t.as=="string"?t.as:"script",u='link[rel="modulepreload"][as="'+mn(o)+'"][href="'+mn(e)+'"]',m=u;switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":m=Er(e)}if(!Wa.has(m)&&(e=v({rel:"modulepreload",href:e},t),Wa.set(m,e),s.querySelector(u)===null)){switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(s.querySelector(Io(m)))return}o=s.createElement("link"),En(o,"link",e),vt(o),s.head.appendChild(o)}}}function bb(e,t,s){dl.S(e,t,s);var o=Tr;if(o&&e){var u=Ot(o).hoistableStyles,m=Rr(e);t=t||"default";var S=u.get(m);if(!S){var N={loading:0,preload:null};if(S=o.querySelector(Oo(m)))N.loading=5;else{e=v({rel:"stylesheet",href:e,"data-precedence":t},s),(s=Wa.get(m))&&im(e,s);var I=S=o.createElement("link");vt(I),En(I,"link",e),I._p=new Promise(function(te,fe){I.onload=te,I.onerror=fe}),I.addEventListener("load",function(){N.loading|=1}),I.addEventListener("error",function(){N.loading|=2}),N.loading|=4,Cu(S,t,o)}S={type:"stylesheet",instance:S,count:1,state:N},u.set(m,S)}}}function Sb(e,t){dl.X(e,t);var s=Tr;if(s&&e){var o=Ot(s).hoistableScripts,u=Er(e),m=o.get(u);m||(m=s.querySelector(Io(u)),m||(e=v({src:e,async:!0},t),(t=Wa.get(u))&&rm(e,t),m=s.createElement("script"),vt(m),En(m,"link",e),s.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},o.set(u,m))}}function Cb(e,t){dl.M(e,t);var s=Tr;if(s&&e){var o=Ot(s).hoistableScripts,u=Er(e),m=o.get(u);m||(m=s.querySelector(Io(u)),m||(e=v({src:e,async:!0,type:"module"},t),(t=Wa.get(u))&&rm(e,t),m=s.createElement("script"),vt(m),En(m,"link",e),s.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},o.set(u,m))}}function lx(e,t,s,o){var u=(u=ze.current)?Su(u):null;if(!u)throw Error(r(446));switch(e){case"meta":case"title":return null;case"style":return typeof s.precedence=="string"&&typeof s.href=="string"?(t=Rr(s.href),s=Ot(u).hoistableStyles,o=s.get(t),o||(o={type:"style",instance:null,count:0,state:null},s.set(t,o)),o):{type:"void",instance:null,count:0,state:null};case"link":if(s.rel==="stylesheet"&&typeof s.href=="string"&&typeof s.precedence=="string"){e=Rr(s.href);var m=Ot(u).hoistableStyles,S=m.get(e);if(S||(u=u.ownerDocument||u,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},m.set(e,S),(m=u.querySelector(Oo(e)))&&!m._p&&(S.instance=m,S.state.loading=5),Wa.has(e)||(s={rel:"preload",as:"style",href:s.href,crossOrigin:s.crossOrigin,integrity:s.integrity,media:s.media,hrefLang:s.hrefLang,referrerPolicy:s.referrerPolicy},Wa.set(e,s),m||jb(u,e,s,S.state))),t&&o===null)throw Error(r(528,""));return S}if(t&&o!==null)throw Error(r(529,""));return null;case"script":return t=s.async,s=s.src,typeof s=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Er(s),s=Ot(u).hoistableScripts,o=s.get(t),o||(o={type:"script",instance:null,count:0,state:null},s.set(t,o)),o):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,e))}}function Rr(e){return'href="'+mn(e)+'"'}function Oo(e){return'link[rel="stylesheet"]['+e+"]"}function ix(e){return v({},e,{"data-precedence":e.precedence,precedence:null})}function jb(e,t,s,o){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?o.loading=1:(t=e.createElement("link"),o.preload=t,t.addEventListener("load",function(){return o.loading|=1}),t.addEventListener("error",function(){return o.loading|=2}),En(t,"link",s),vt(t),e.head.appendChild(t))}function Er(e){return'[src="'+mn(e)+'"]'}function Io(e){return"script[async]"+e}function rx(e,t,s){if(t.count++,t.instance===null)switch(t.type){case"style":var o=e.querySelector('style[data-href~="'+mn(s.href)+'"]');if(o)return t.instance=o,vt(o),o;var u=v({},s,{"data-href":s.href,"data-precedence":s.precedence,href:null,precedence:null});return o=(e.ownerDocument||e).createElement("style"),vt(o),En(o,"style",u),Cu(o,s.precedence,e),t.instance=o;case"stylesheet":u=Rr(s.href);var m=e.querySelector(Oo(u));if(m)return t.state.loading|=4,t.instance=m,vt(m),m;o=ix(s),(u=Wa.get(u))&&im(o,u),m=(e.ownerDocument||e).createElement("link"),vt(m);var S=m;return S._p=new Promise(function(N,I){S.onload=N,S.onerror=I}),En(m,"link",o),t.state.loading|=4,Cu(m,s.precedence,e),t.instance=m;case"script":return m=Er(s.src),(u=e.querySelector(Io(m)))?(t.instance=u,vt(u),u):(o=s,(u=Wa.get(m))&&(o=v({},s),rm(o,u)),e=e.ownerDocument||e,u=e.createElement("script"),vt(u),En(u,"link",o),e.head.appendChild(u),t.instance=u);case"void":return null;default:throw Error(r(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(o=t.instance,t.state.loading|=4,Cu(o,s.precedence,e));return t.instance}function Cu(e,t,s){for(var o=s.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),u=o.length?o[o.length-1]:null,m=u,S=0;S<o.length;S++){var N=o[S];if(N.dataset.precedence===t)m=N;else if(m!==u)break}m?m.parentNode.insertBefore(e,m.nextSibling):(t=s.nodeType===9?s.head:s,t.insertBefore(e,t.firstChild))}function im(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function rm(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var ju=null;function ox(e,t,s){if(ju===null){var o=new Map,u=ju=new Map;u.set(s,o)}else u=ju,o=u.get(s),o||(o=new Map,u.set(s,o));if(o.has(e))return o;for(o.set(e,null),s=s.getElementsByTagName(e),u=0;u<s.length;u++){var m=s[u];if(!(m[at]||m[X]||e==="link"&&m.getAttribute("rel")==="stylesheet")&&m.namespaceURI!=="http://www.w3.org/2000/svg"){var S=m.getAttribute(t)||"";S=e+S;var N=o.get(S);N?N.push(m):o.set(S,[m])}}return o}function cx(e,t,s){e=e.ownerDocument||e,e.head.insertBefore(s,t==="title"?e.querySelector("head > title"):null)}function kb(e,t,s){if(s===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;return t.rel==="stylesheet"?(e=t.disabled,typeof t.precedence=="string"&&e==null):!0;case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function ux(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function Mb(e,t,s,o){if(s.type==="stylesheet"&&(typeof o.media!="string"||matchMedia(o.media).matches!==!1)&&(s.state.loading&4)===0){if(s.instance===null){var u=Rr(o.href),m=t.querySelector(Oo(u));if(m){t=m._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=ku.bind(e),t.then(e,e)),s.state.loading|=4,s.instance=m,vt(m);return}m=t.ownerDocument||t,o=ix(o),(u=Wa.get(u))&&im(o,u),m=m.createElement("link"),vt(m);var S=m;S._p=new Promise(function(N,I){S.onload=N,S.onerror=I}),En(m,"link",o),s.instance=m}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(s,t),(t=s.state.preload)&&(s.state.loading&3)===0&&(e.count++,s=ku.bind(e),t.addEventListener("load",s),t.addEventListener("error",s))}}var om=0;function Ab(e,t){return e.stylesheets&&e.count===0&&Au(e,e.stylesheets),0<e.count||0<e.imgCount?function(s){var o=setTimeout(function(){if(e.stylesheets&&Au(e,e.stylesheets),e.unsuspend){var m=e.unsuspend;e.unsuspend=null,m()}},6e4+t);0<e.imgBytes&&om===0&&(om=62500*rb());var u=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Au(e,e.stylesheets),e.unsuspend)){var m=e.unsuspend;e.unsuspend=null,m()}},(e.imgBytes>om?50:800)+t);return e.unsuspend=s,function(){e.unsuspend=null,clearTimeout(o),clearTimeout(u)}}:null}function ku(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Au(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Mu=null;function Au(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Mu=new Map,t.forEach(Nb,e),Mu=null,ku.call(e))}function Nb(e,t){if(!(t.state.loading&4)){var s=Mu.get(e);if(s)var o=s.get(null);else{s=new Map,Mu.set(e,s);for(var u=e.querySelectorAll("link[data-precedence],style[data-precedence]"),m=0;m<u.length;m++){var S=u[m];(S.nodeName==="LINK"||S.getAttribute("media")!=="not all")&&(s.set(S.dataset.precedence,S),o=S)}o&&s.set(null,o)}u=t.instance,S=u.getAttribute("data-precedence"),m=s.get(S)||o,m===o&&s.set(null,u),s.set(S,u),this.count++,o=ku.bind(this),u.addEventListener("load",o),u.addEventListener("error",o),m?m.parentNode.insertBefore(u,m.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(u,e.firstChild)),t.state.loading|=4}}var Bo={$$typeof:D,Provider:null,Consumer:null,_currentValue:U,_currentValue2:U,_threadCount:0};function Tb(e,t,s,o,u,m,S,N,I){this.tag=1,this.containerInfo=e,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=Ia(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ia(0),this.hiddenUpdates=Ia(null),this.identifierPrefix=o,this.onUncaughtError=u,this.onCaughtError=m,this.onRecoverableError=S,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=I,this.incompleteTransitions=new Map}function dx(e,t,s,o,u,m,S,N,I,te,fe,ve){return e=new Tb(e,t,s,S,I,te,fe,ve,N),t=1,m===!0&&(t|=24),m=Tn(3,null,null,t),e.current=m,m.stateNode=e,t=ho(),t.refCount++,e.pooledCache=t,t.refCount++,m.memoizedState={element:o,isDehydrated:s,cache:t},qd(m),e}function fx(e){return e?(e=Rl,e):Rl}function mx(e,t,s,o,u,m){u=fx(u),o.context===null?o.context=u:o.pendingContext=u,o=Ol(t),o.payload={element:s},m=m===void 0?null:m,m!==null&&(o.callback=m),s=Il(e,o,t),s!==null&&(ma(s,e,t),go(s,e,t))}function hx(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var s=e.retryLane;e.retryLane=s!==0&&s<t?s:t}}function cm(e,t){hx(e,t),(e=e.alternate)&&hx(e,t)}function px(e){if(e.tag===13||e.tag===31){var t=Ce(e,67108864);t!==null&&ma(t,e,67108864),cm(e,67108864)}}function gx(e){if(e.tag===13||e.tag===31){var t=Ea();t=Fa(t);var s=Ce(e,t);s!==null&&ma(s,e,t),cm(e,t)}}var Nu=!0;function Rb(e,t,s,o){var u=z.T;z.T=null;var m=Y.p;try{Y.p=2,um(e,t,s,o)}finally{Y.p=m,z.T=u}}function Eb(e,t,s,o){var u=z.T;z.T=null;var m=Y.p;try{Y.p=8,um(e,t,s,o)}finally{Y.p=m,z.T=u}}function um(e,t,s,o){if(Nu){var u=dm(o);if(u===null)Qf(e,t,o,Tu,s),vx(e,o);else if(Lb(u,e,t,s,o))o.stopPropagation();else if(vx(e,o),t&4&&-1<Db.indexOf(e)){for(;u!==null;){var m=Yt(u);if(m!==null)switch(m.tag){case 3:if(m=m.stateNode,m.current.memoizedState.isDehydrated){var S=es(m.pendingLanes);if(S!==0){var N=m;for(N.pendingLanes|=2,N.entangledLanes|=2;S;){var I=1<<31-qt(S);N.entanglements[1]|=I,S&=~I}Es(m),(gt&6)===0&&(du=Oe()+500,Do(0))}}break;case 31:case 13:N=Ce(m,2),N!==null&&ma(N,m,2),mu(),cm(m,2)}if(m=dm(o),m===null&&Qf(e,t,o,Tu,s),m===u)break;u=m}u!==null&&o.stopPropagation()}else Qf(e,t,o,null,s)}}function dm(e){return e=Zi(e),fm(e)}var Tu=null;function fm(e){if(Tu=null,e=_t(e),e!==null){var t=d(e);if(t===null)e=null;else{var s=t.tag;if(s===13){if(e=h(t),e!==null)return e;e=null}else if(s===31){if(e=p(t),e!==null)return e;e=null}else if(s===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Tu=e,null}function xx(e){switch(e){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(Dt()){case Za:return 2;case Nt:return 8;case Gn:case ii:return 32;case Te:return 268435456;default:return 32}default:return 32}}var mm=!1,Kl=null,Wl=null,Ql=null,Fo=new Map,Ho=new Map,Xl=[],Db="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 vx(e,t){switch(e){case"focusin":case"focusout":Kl=null;break;case"dragenter":case"dragleave":Wl=null;break;case"mouseover":case"mouseout":Ql=null;break;case"pointerover":case"pointerout":Fo.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ho.delete(t.pointerId)}}function $o(e,t,s,o,u,m){return e===null||e.nativeEvent!==m?(e={blockedOn:t,domEventName:s,eventSystemFlags:o,nativeEvent:m,targetContainers:[u]},t!==null&&(t=Yt(t),t!==null&&px(t)),e):(e.eventSystemFlags|=o,t=e.targetContainers,u!==null&&t.indexOf(u)===-1&&t.push(u),e)}function Lb(e,t,s,o,u){switch(t){case"focusin":return Kl=$o(Kl,e,t,s,o,u),!0;case"dragenter":return Wl=$o(Wl,e,t,s,o,u),!0;case"mouseover":return Ql=$o(Ql,e,t,s,o,u),!0;case"pointerover":var m=u.pointerId;return Fo.set(m,$o(Fo.get(m)||null,e,t,s,o,u)),!0;case"gotpointercapture":return m=u.pointerId,Ho.set(m,$o(Ho.get(m)||null,e,t,s,o,u)),!0}return!1}function yx(e){var t=_t(e.target);if(t!==null){var s=d(t);if(s!==null){if(t=s.tag,t===13){if(t=h(s),t!==null){e.blockedOn=t,Os(e.priority,function(){gx(s)});return}}else if(t===31){if(t=p(s),t!==null){e.blockedOn=t,Os(e.priority,function(){gx(s)});return}}else if(t===3&&s.stateNode.current.memoizedState.isDehydrated){e.blockedOn=s.tag===3?s.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Ru(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var s=dm(e.nativeEvent);if(s===null){s=e.nativeEvent;var o=new s.constructor(s.type,s);Xi=o,s.target.dispatchEvent(o),Xi=null}else return t=Yt(s),t!==null&&px(t),e.blockedOn=s,!1;t.shift()}return!0}function wx(e,t,s){Ru(e)&&s.delete(t)}function zb(){mm=!1,Kl!==null&&Ru(Kl)&&(Kl=null),Wl!==null&&Ru(Wl)&&(Wl=null),Ql!==null&&Ru(Ql)&&(Ql=null),Fo.forEach(wx),Ho.forEach(wx)}function Eu(e,t){e.blockedOn===t&&(e.blockedOn=null,mm||(mm=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,zb)))}var Du=null;function bx(e){Du!==e&&(Du=e,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){Du===e&&(Du=null);for(var t=0;t<e.length;t+=3){var s=e[t],o=e[t+1],u=e[t+2];if(typeof o!="function"){if(fm(o||s)===null)continue;break}var m=Yt(s);m!==null&&(e.splice(t,3),t-=3,df(m,{pending:!0,data:u,method:s.method,action:o},o,u))}}))}function Dr(e){function t(I){return Eu(I,e)}Kl!==null&&Eu(Kl,e),Wl!==null&&Eu(Wl,e),Ql!==null&&Eu(Ql,e),Fo.forEach(t),Ho.forEach(t);for(var s=0;s<Xl.length;s++){var o=Xl[s];o.blockedOn===e&&(o.blockedOn=null)}for(;0<Xl.length&&(s=Xl[0],s.blockedOn===null);)yx(s),s.blockedOn===null&&Xl.shift();if(s=(e.ownerDocument||e).$$reactFormReplay,s!=null)for(o=0;o<s.length;o+=3){var u=s[o],m=s[o+1],S=u[Se]||null;if(typeof m=="function")S||bx(s);else if(S){var N=null;if(m&&m.hasAttribute("formAction")){if(u=m,S=m[Se]||null)N=S.formAction;else if(fm(u)!==null)continue}else N=S.action;typeof N=="function"?s[o+1]=N:(s.splice(o,3),o-=3),bx(s)}}}function Sx(){function e(m){m.canIntercept&&m.info==="react-transition"&&m.intercept({handler:function(){return new Promise(function(S){return u=S})},focusReset:"manual",scroll:"manual"})}function t(){u!==null&&(u(),u=null),o||setTimeout(s,20)}function s(){if(!o&&!navigation.transition){var m=navigation.currentEntry;m&&m.url!=null&&navigation.navigate(m.url,{state:m.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var o=!1,u=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(s,100),function(){o=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),u!==null&&(u(),u=null)}}}function hm(e){this._internalRoot=e}Lu.prototype.render=hm.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(r(409));var s=t.current,o=Ea();mx(s,o,e,t,null,null)},Lu.prototype.unmount=hm.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;mx(e.current,2,null,e,null,null),mu(),t[De]=null}};function Lu(e){this._internalRoot=e}Lu.prototype.unstable_scheduleHydration=function(e){if(e){var t=as();e={blockedOn:null,target:e,priority:t};for(var s=0;s<Xl.length&&t!==0&&t<Xl[s].priority;s++);Xl.splice(s,0,e),s===0&&yx(e)}};var Cx=a.version;if(Cx!=="19.2.7")throw Error(r(527,Cx,"19.2.7"));Y.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(r(188)):(e=Object.keys(e).join(","),Error(r(268,e)));return e=g(t),e=e!==null?w(e):null,e=e===null?null:e.stateNode,e};var _b={bundleType:0,version:"19.2.7",rendererPackageName:"react-dom",currentDispatcherRef:z,reconcilerVersion:"19.2.7"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var zu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zu.isDisabled&&zu.supportsFiber)try{_a=zu.inject(_b),Ke=zu}catch{}}return Po.createRoot=function(e,t){if(!c(e))throw Error(r(299));var s=!1,o="",u=Rp,m=Ep,S=Dp;return t!=null&&(t.unstable_strictMode===!0&&(s=!0),t.identifierPrefix!==void 0&&(o=t.identifierPrefix),t.onUncaughtError!==void 0&&(u=t.onUncaughtError),t.onCaughtError!==void 0&&(m=t.onCaughtError),t.onRecoverableError!==void 0&&(S=t.onRecoverableError)),t=dx(e,1,!1,null,null,s,o,null,u,m,S,Sx),e[De]=t.current,Wf(e),new hm(t)},Po.hydrateRoot=function(e,t,s){if(!c(e))throw Error(r(299));var o=!1,u="",m=Rp,S=Ep,N=Dp,I=null;return s!=null&&(s.unstable_strictMode===!0&&(o=!0),s.identifierPrefix!==void 0&&(u=s.identifierPrefix),s.onUncaughtError!==void 0&&(m=s.onUncaughtError),s.onCaughtError!==void 0&&(S=s.onCaughtError),s.onRecoverableError!==void 0&&(N=s.onRecoverableError),s.formState!==void 0&&(I=s.formState)),t=dx(e,1,!0,t,s??null,o,u,I,m,S,N,Sx),t.context=fx(null),s=t.current,o=Ea(),o=Fa(o),u=Ol(o),u.callback=null,Il(s,u,o),s=o,t.current.lanes=s,Ba(t,s),Es(t),e[De]=t.current,Wf(e),new Lu(t)},Po.version="19.2.7",Po}var _x;function yS(){if(_x)return xm.exports;_x=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(a){console.error(a)}}return n(),xm.exports=vS(),xm.exports}var wS=yS();const bS="https://otbyfkjxrkngvjziawki.supabase.co",SS="sb_publishable_NpUs0RDJH2YnllsqTKO6TQ_1jTdSsNQ",Ds=mS(bS,SS,{auth:{autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"pkce",storageKey:"livedesk.mindexec.supabase.auth"}});function ei(n,a,i){if(i<0||a<0||a+i>n.length)throw new Error("Invalid LZO1X block: input overrun.")}function wm(n,a,i){let r=0;for(;ei(n,a.inputIndex,1),n[a.inputIndex]===0;)r+=1,a.inputIndex+=1;const c=r*255+i+n[a.inputIndex];return a.inputIndex+=1,c}function _u(n,a,i,r){if(ei(n,a.inputIndex,r),a.outputIndex+r>i.length)throw new Error("Invalid LZO1X block: output overrun.");i.set(n.subarray(a.inputIndex,a.inputIndex+r),a.outputIndex),a.inputIndex+=r,a.outputIndex+=r}function CS(n,a,i,r){const c=a-i;if(c<=0||r<=0)throw new Error("Invalid LZO1X block: invalid match distance.");let d=Math.min(c,r);for(n.set(n.subarray(i,i+d),a);d<r;){const h=Math.min(d,r-d);n.copyWithin(a+d,a,a+h),d+=h}return a+r}function cy(n,a){if(!(n instanceof Uint8Array)||n.length<3||a<0)throw new Error("Invalid LZO1X block.");const i=new Uint8Array(a),r={inputIndex:0,outputIndex:0};let c=0,d=0;if(n[r.inputIndex]>=22){const h=n[r.inputIndex]-17;r.inputIndex+=1,_u(n,r,i,h),c=4}else n[r.inputIndex]>=18&&(c=n[r.inputIndex]-17,r.inputIndex+=1,_u(n,r,i,c));for(;;){ei(n,r.inputIndex,1);const h=n[r.inputIndex];r.inputIndex+=1;let p,x;if((h&192)!==0)ei(n,r.inputIndex,1),x=r.outputIndex-((n[r.inputIndex]<<3)+(h>>2&7)+1),r.inputIndex+=1,d=(h>>5)+1,p=h&3;else if((h&32)!==0){d=(h&31)+2,d===2&&(d+=wm(n,r,31)),ei(n,r.inputIndex,2);const g=n[r.inputIndex]|n[r.inputIndex+1]<<8;r.inputIndex+=2,x=r.outputIndex-((g>>2)+1),p=g&3}else if((h&16)!==0){d=(h&7)+2,d===2&&(d+=wm(n,r,7)),ei(n,r.inputIndex,2);const g=n[r.inputIndex]|n[r.inputIndex+1]<<8;if(r.inputIndex+=2,x=r.outputIndex-(((h&8)<<11)+(g>>2)),p=g&3,x===r.outputIndex)break;x-=16384}else if(c===0){let g=h+3;g===3&&(g+=wm(n,r,15)),_u(n,r,i,g),c=4;continue}else c!==4?(ei(n,r.inputIndex,1),p=h&3,x=r.outputIndex-((h>>2)+(n[r.inputIndex]<<2)+1),r.inputIndex+=1,d=2):(ei(n,r.inputIndex,1),p=h&3,x=r.outputIndex-((h>>2)+(n[r.inputIndex]<<2)+2049),r.inputIndex+=1,d=3);if(x<0||r.outputIndex+d+p>i.length)throw new Error("Invalid LZO1X block: lookbehind overrun.");r.outputIndex=CS(i,r.outputIndex,x,d),c=p,_u(n,r,i,p)}if(d!==3||r.inputIndex!==n.length||r.outputIndex!==i.length)throw new Error("Invalid LZO1X block: incomplete output.");return i}const Ox=16,Ix=8,jS=24*1024*1024,uy=new Uint8Array(new Uint32Array([16909060]).buffer)[0]===4,Km=new Uint32Array(65536);for(let n=0;n<Km.length;n+=1){const a=Math.round((n>>11&31)*255/31),i=Math.round((n>>5&63)*255/63),r=Math.round((n&31)*255/31);Km[n]=uy?(a|i<<8|r<<16|4278190080)>>>0:(a<<24|i<<16|r<<8|255)>>>0}function Jl(n,a){return n[a]|n[a+1]<<8}function kS(n,a){const i=Number(a);if(!Number.isSafeInteger(i)||i<Ox||i>jS)throw new Error(`Invalid Mode 5 packet length: ${a}.`);const r=cy(new Uint8Array(n),i);if(r[0]!==76||r[1]!==68||r[2]!==53||r[3]!==68)throw new Error("Invalid Mode 5 packet magic.");if(r[4]!==1)throw new Error(`Unsupported Mode 5 packet version: ${r[4]}.`);const c=(r[5]&1)!==0,d=Jl(r,6),h=Jl(r,8),p=Jl(r,10),x=Jl(r,12);if(d<=0||h<=0||d>3840||h>2160)throw new Error(`Invalid Mode 5 frame size: ${d}x${h}.`);if(p<=0||p>256||x>8192)throw new Error(`Invalid Mode 5 tile header: ${p}/${x}.`);const g=[];let w=Ox;for(let v=0;v<x;v+=1){if(w+Ix>r.length)throw new Error("Mode 5 tile header is truncated.");const b=Jl(r,w),k=Jl(r,w+2),j=Jl(r,w+4),M=Jl(r,w+6);w+=Ix;const T=j*M*2;if(j<=0||M<=0||j>p||M>p||b+j>d||k+M>h||w+T>r.length)throw new Error(`Invalid Mode 5 tile ${v}.`);g.push({x:b,y:k,width:j,height:M,pixels:r.subarray(w,w+T)}),w+=T}if(w!==r.length)throw new Error(`Mode 5 packet has ${r.length-w} trailing bytes.`);return{keyFrame:c,width:d,height:h,tileSize:p,tiles:g}}function MS(n,a,i,r){if(!(n instanceof Uint8ClampedArray)||n.length!==a*i*4||r.width!==a||r.height!==i)throw new Error("Mode 5 canvas state does not match the packet dimensions.");let c=a,d=i,h=0,p=0;const x=new Uint32Array(n.buffer,n.byteOffset,n.byteLength>>>2);for(const g of r.tiles){const w=uy&&(g.pixels.byteOffset&1)===0?new Uint16Array(g.pixels.buffer,g.pixels.byteOffset,g.pixels.byteLength>>>1):null;let v=0;for(let b=0;b<g.height;b+=1){let k=(g.y+b)*a+g.x;for(let j=0;j<g.width;j+=1){const M=v<<1,T=w?w[v]:g.pixels[M]|g.pixels[M+1]<<8;x[k]=Km[T],v+=1,k+=1}}c=Math.min(c,g.x),d=Math.min(d,g.y),h=Math.max(h,g.x+g.width),p=Math.max(p,g.y+g.height)}return r.tiles.length>0?{x:c,y:d,width:h-c,height:p-d}:null}const xa=new WeakMap,dc=new WeakMap,Wm=new WeakMap,fc=new Set,Gi=new Set,ud=new WeakMap,Qm=new WeakMap,Xm=new WeakMap,dd=new WeakMap,vh=32,AS=2,NS=2,TS=2,RS=18,ES=40,DS=0,LS=750,dy=80,Bx=5,zS=150,_S=24,OS=180,IS=1200,BS=18,FS=.65,HS=2e3,$S=500,fy=250;let fd=!1;function US(){return typeof navigator>"u"?!1:/mac/i.test(`${navigator.platform||""} ${navigator.userAgent||""}`)}function PS(){const n=Math.max(1,Number(navigator.hardwareConcurrency||8));return Math.max(4,Math.min(16,Math.round(n/2)))}let Ki={h264DecodeAcceleration:"prefer-hardware",h264HardwareDecoderBudget:PS()};function qS(n){n.h264DecodeAcceleration&&(Ki={...Ki,h264DecodeAcceleration:n.h264DecodeAcceleration}),Number.isFinite(Number(n.h264HardwareDecoderBudget))&&(Ki.h264HardwareDecoderBudget=Math.max(1,Math.min(64,Math.round(Number(n.h264HardwareDecoderBudget)))))}function my(n,a=Ki.h264DecodeAcceleration){const i=ud.get(n);return i?.requested===a?(i.actual!=="prefer-hardware"&&Gi.delete(n),i.actual):(i&&ud.delete(n),a!=="prefer-hardware"?(Gi.delete(n),a):Gi.has(n)?"prefer-hardware":Gi.size<Ki.h264HardwareDecoderBudget?(Gi.add(n),"prefer-hardware"):"prefer-software")}function wd(n,a){return a!=="prefer-hardware"?!1:(ud.set(n,{requested:a,actual:"prefer-software"}),Gi.delete(n),!0)}function GS(n,a,i,r=64){try{let c=Qm.get(n);c||(c={canvas:document.createElement("canvas"),lastHash:"",initialized:!1},Qm.set(n,c));const d=Math.max(8,Math.min(64,Math.round(r))),h=Math.max(1,Math.round(d*Math.max(1,i)/Math.max(1,a)));(c.canvas.width!==d||c.canvas.height!==h)&&(c.canvas.width=d,c.canvas.height=h);const p=c.canvas.getContext("2d",{willReadFrequently:!0});if(!p)return{visualHash:"",visualChanged:!0};p.drawImage(n,0,0,Math.max(1,a),Math.max(1,i),0,0,d,h);const x=p.getImageData(0,0,d,h).data;let g=2166136261;for(let b=0;b<x.length;b+=4)g^=x[b],g=Math.imul(g,16777619),g^=x[b+1],g=Math.imul(g,16777619),g^=x[b+2],g=Math.imul(g,16777619);const w=(g>>>0).toString(16).padStart(8,"0"),v=!c.initialized||w!==c.lastHash;return c.initialized=!0,c.lastHash=w,{visualHash:w,visualChanged:v}}catch{return{visualHash:"",visualChanged:!0}}}function Zm(n,a,i,r=fy,c=64){let d=Xm.get(n);d||(d={lastHash:"",initialized:!1,lastCanvasSampleAt:0},Xm.set(n,d));const h=performance.now();if(d.initialized&&r>0&&h-d.lastCanvasSampleAt<r)return{visualHash:d.lastHash,visualChanged:!1};const p=GS(n,a,i,c);return d.initialized=!0,d.lastHash=p.visualHash,d.lastCanvasSampleAt=h,p}function YS(n,a){let i=dd.get(n);i||(i={lastHash:"",initialized:!1},dd.set(n,i));const r=String(a.contentHash||""),c=!i.initialized||!r||r!==i.lastHash;return i.initialized=!0,i.lastHash=r,{visualHash:r,visualChanged:c}}function hy(n,a){const i=Wm.get(n);if(i)return i;const r=n.getContext("2d",{alpha:!1,desynchronized:a==="interactive"});if(r){const c=r.getContextAttributes?.(),d={context:r,presentation:c?.desynchronized?"desync":"sync"};return Wm.set(n,d),d}return null}function VS(n){const a=String(n.frameMode||n.mode||"").toLowerCase(),i=String(n.compression||"").toLowerCase(),r=String(n.mimeType||"").toLowerCase();return a==="mode2-lzo"||i==="lzo1x"||r==="application/vnd.livedesk.lzo-rgb565"||a==="mode2-lz4"||String(n.compression||"").toLowerCase()==="lz4"||r==="application/vnd.livedesk.lz4-raw"}function KS(n){return String(n.frameMode||n.mode||"").toLowerCase()==="mode3-h264-hw"||String(n.codec||"").toLowerCase()==="h264"||String(n.mimeType||"").toLowerCase()==="video/h264"}function WS(n){const a=String(n.frameMode||n.mode||"").toLowerCase(),i=String(n.mimeType||"").toLowerCase();return a==="mode5-lzo-delta"||i==="application/vnd.livedesk.lzo-rgb565-delta"}function Fx(n,a,i){let r=i,c=a;if(r===15){let d=255;for(;d===255;){if(c>=n.length)throw new Error("Invalid LZ4 block: length overrun.");d=n[c],c+=1,r+=d}}return{length:r,cursor:c}}function QS(n,a){const i=new Uint8Array(a);let r=0,c=0;for(;r<n.length;){const d=n[r];r+=1;const h=Fx(n,r,d>>4);r=h.cursor;const p=h.length;if(r+p>n.length||c+p>i.length)throw new Error("Invalid LZ4 block: literal overrun.");if(i.set(n.subarray(r,r+p),c),r+=p,c+=p,r>=n.length)break;if(r+2>n.length)throw new Error("Invalid LZ4 block: missing offset.");const x=n[r]|n[r+1]<<8;if(r+=2,x<=0||x>c)throw new Error("Invalid LZ4 block: bad match offset.");const g=Fx(n,r,d&15);r=g.cursor;const w=g.length+4;if(c+w>i.length)throw new Error("Invalid LZ4 block: match overrun.");let v=c-x;for(let b=0;b<w;b+=1)i[c]=i[v],c+=1,v+=1}if(c!==i.length)throw new Error("Invalid LZ4 block: incomplete output.");return i}function XS(n){const a=Math.max(1,Math.floor(n.width||0)),i=Math.max(1,Math.floor(n.height||0)),r=String(n.compression||"").toLowerCase(),c=String(n.pixelFormat||n.codec||"").toLowerCase();if(r==="lzo1x"||String(n.frameMode||n.mode||"").toLowerCase()==="mode2-lzo"||String(n.mimeType||"").toLowerCase()==="application/vnd.livedesk.lzo-rgb565"){const w=Math.max(1,Math.floor(n.bytesPerPixel||2)),v=a*i*2,b=Math.floor(n.uncompressedByteLength||v);if(w!==2||b!==v)throw new Error(`Invalid mode2 RGB565 frame size: ${b} for ${a}x${i}.`);if(c&&c!=="rgb565le"&&c!=="rgb565")throw new Error(`Unsupported mode2 pixel format: ${c}`);const k=cy(new Uint8Array(n.payload),v),j=new Uint8ClampedArray(a*i*4);for(let M=0,T=0;M<k.length;M+=2,T+=4){const C=k[M]|k[M+1]<<8,A=C>>11&31,D=C>>5&63,H=C&31;j[T]=A<<3|A>>2,j[T+1]=D<<2|D>>4,j[T+2]=H<<3|H>>2,j[T+3]=255}return new ImageData(j,a,i)}const h=Math.max(1,Math.floor(n.bytesPerPixel||4)),p=Math.max(a*i*h,Math.floor(n.uncompressedByteLength||0)),x=QS(new Uint8Array(n.payload),p);if(h!==4)throw new Error(`Unsupported mode2 pixel size: ${h}`);const g=new Uint8ClampedArray(a*i*4);if(c==="rgba32"||c==="rgba")g.set(x.subarray(0,g.length));else for(let w=0,v=0;v<g.length;w+=4,v+=4)g[v]=x[w+2],g[v+1]=x[w+1],g[v+2]=x[w],g[v+3]=x[w+3];return new ImageData(g,a,i)}function Hx(n,a="smooth"){const i=window.VideoDecoder;if(!i||!window.EncodedVideoChunk)throw new Error("WebCodecs H.264 decode is not supported in this browser.");const r=xa.get(n);if(r&&r.decoder.state!=="closed"&&r.latencyMode===a)return r;r&&ws(n);let c;return c={decoder:new i({output:h=>{if(xa.get(n)!==c){h.close();return}const p=Number(h.timestamp||0);c.outputSerial+=1;let x=c.pendingFrames.get(p);if(x)c.pendingFrames.delete(p);else if(c.pendingFrames.size>0){const j=c.pendingFrames.entries().next().value;j&&(c.pendingFrames.delete(j[0]),x=j[1],c.timestampFallbacks+=1)}const g=h.displayWidth||h.codedWidth||n.width||960,w=h.displayHeight||h.codedHeight||n.height||540,v=Number(x?.frame.durationUs||0),b=Number(h.duration||0),k=Math.max(16,Math.min(250,(v>0?v:b||83333)/1e3));for(c.targetPaintIntervalMs=k,c.decodedFrames.push({videoFrame:h,pending:x,decodedAt:performance.now(),width:g,height:w,durationMs:k}),c.lastOutputAt=performance.now();c.decodedFrames.length>py(c);)md(c,c.decodedFrames.shift());gy(c),c.renderTimer!==null&&c.renderScheduledAt>0&&performance.now()-c.renderScheduledAt>$S&&(typeof document>"u"||document.visibilityState==="visible")&&(window.cancelAnimationFrame(c.renderTimer),c.renderTimer=null,c.renderScheduledAt=0),c.renderTimer!==null&&c.decodedFrames.length>=vh&&(window.cancelAnimationFrame(c.renderTimer),c.renderTimer=null,c.renderScheduledAt=0),hd(n,c)},error:()=>{xa.get(n)===c&&(wd(n,c.hardwareAcceleration),yh(c),fc.delete(n),xa.delete(n))}}),configured:!1,configKey:"",codec:"",hardwareAcceleration:my(n),latencyMode:a,keyFrameSeen:!1,droppedForLatency:0,pendingFrames:new Map,decodedFrames:[],renderTimer:null,renderScheduledAt:0,flushTimer:null,flushInFlight:!1,flushCount:0,timestampFallbacks:0,inputSerial:0,outputSerial:0,lastFlushInputSerial:0,lastOutputAt:0,lastPaintAt:0,lastInputAt:0,interactiveBufferPrimed:!1,interactiveBufferStartedAt:0,interactiveBufferWaitCount:0,interactiveBufferWaitMs:0,interactiveQueueDrainCount:0,lastInputFrameSeq:void 0,targetPaintIntervalMs:1e3/12,nextChunkTimestampUs:0,healthSampleStartedAt:performance.now(),healthInputSerial:0,healthOutputSerial:0},xa.set(n,c),fc.add(n),c}function yh(n){n.renderTimer!==null&&(window.cancelAnimationFrame(n.renderTimer),n.renderTimer=null),n.renderScheduledAt=0,n.flushTimer!==null&&(window.clearTimeout(n.flushTimer),n.flushTimer=null),n.flushInFlight=!1;for(const a of n.decodedFrames)a.videoFrame.close();n.decodedFrames=[],n.interactiveBufferPrimed=!1,n.interactiveBufferStartedAt=0}function md(n,a){a&&(a.videoFrame.close(),n.droppedForLatency+=1)}function py(n){return n.latencyMode==="interactive"?NS:String(n.decodedFrames[0]?.pending?.frame.frameMode||n.decodedFrames[0]?.pending?.frame.mode||"").toLowerCase()==="mode4-h264-atlas"?AS:vh}function gy(n,a=performance.now()){const i=py(n);for(;n.decodedFrames.length>i;)md(n,n.decodedFrames.shift());const r=n.latencyMode==="interactive"?dy:LS;let c=n.decodedFrames[0];for(;n.decodedFrames.length>1&&c?.pending&&a-c.pending.queuedAt>r;)md(n,n.decodedFrames.shift()),c=n.decodedFrames[0]}function xy(n,a){if(a.hardwareAcceleration!=="prefer-hardware"||a.flushTimer!==null||a.flushInFlight)return;const i=a.latencyMode==="interactive"?_S:zS,r=a.latencyMode==="interactive";a.flushTimer=window.setTimeout(async()=>{a.flushTimer=null;const c=performance.now();for(const[p,x]of a.pendingFrames.entries())c-x.queuedAt>HS&&a.pendingFrames.delete(p);if(xa.get(n)!==a||a.decoder.state!=="configured"||a.pendingFrames.size===0||a.inputSerial<=a.lastFlushInputSerial||!r&&a.lastOutputAt>0&&c-a.lastOutputAt<i)return;const d=a.inputSerial,h=performance.now();a.flushInFlight=!0,a.flushCount+=1;try{await a.decoder.flush(),a.lastFlushInputSerial=Math.max(a.lastFlushInputSerial,d)}catch{xa.get(n)===a&&nd(a)}finally{a.flushInFlight=!1;const p=performance.now()-h;if(r&&p>=OS&&a.hardwareAcceleration==="prefer-hardware"){fd=!0,wd(n,a.hardwareAcceleration),ws(n);return}xa.get(n)===a&&a.inputSerial>d&&a.pendingFrames.size>0&&(r||performance.now()-a.lastOutputAt>=i)&&xy(n,a)}},i)}function $x(n,a,i){const r=performance.now();try{(n.width!==i.width||n.height!==i.height)&&(n.width=i.width,n.height=i.height);const c=hy(n,a.latencyMode);if(c?.context.drawImage(i.videoFrame,0,0,i.width,i.height),i.pending){const d=performance.now(),p=a.latencyMode==="interactive"?YS(n,i.pending.frame):Zm(n,i.width,i.height,fy,64);try{a.onPaint?.(i.pending.frame,{deviceId:i.pending.frame.deviceId,frameSeq:i.pending.frame.frameSeq,mode:i.pending.frame.frameMode||i.pending.frame.mode||i.pending.frame.codec||i.pending.frame.mimeType,width:i.width,height:i.height,byteLength:i.pending.frame.byteLength,queuedForMs:Math.max(0,r-i.pending.queuedAt),decodedForMs:Math.max(0,i.decodedAt-i.pending.queuedAt),scheduledForMs:Math.max(0,r-i.decodedAt),drawMs:Math.max(0,d-r),queueSize:i.pending.queueSize,renderQueueSize:a.decodedFrames.length,droppedForLatency:a.droppedForLatency,h264DecodeAcceleration:a.hardwareAcceleration,decoderLabel:a.hardwareAcceleration,decoderFlushCount:a.flushCount,decoderTimestampFallbacks:a.timestampFallbacks,decoderInputCount:a.inputSerial,decoderOutputCount:a.outputSerial,targetPaintIntervalMs:a.targetPaintIntervalMs,canvasPresentation:c?.presentation||"sync",interactiveBufferWaitCount:a.interactiveBufferWaitCount,interactiveBufferWaitMs:a.interactiveBufferWaitMs,interactiveQueueDrainCount:a.interactiveQueueDrainCount,visualHash:p.visualHash,visualChanged:p.visualChanged,paintedAt:d})}catch{}}a.lastPaintAt=performance.now()}finally{i.videoFrame.close()}}function hd(n,a){if(a.renderTimer!==null||a.decodedFrames.length===0)return;const i=Math.max(16,Math.min(250,a.targetPaintIntervalMs||1e3/12)),r=()=>{if(a.renderTimer=null,a.renderScheduledAt=0,a.decodedFrames.length===0)return;const c=performance.now();if(gy(a,c),a.decodedFrames.length===0)return;if(a.latencyMode==="interactive"){const x=a.targetPaintIntervalMs<=ES,g=a.targetPaintIntervalMs<=20;if(g&&!a.interactiveBufferPrimed){a.interactiveBufferStartedAt<=0&&(a.interactiveBufferStartedAt=c,a.interactiveBufferWaitCount+=1);const M=a.decodedFrames.length>=TS,T=c-a.interactiveBufferStartedAt>=RS;if(!M&&!T){a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(r);return}a.interactiveBufferWaitMs+=Math.max(0,c-a.interactiveBufferStartedAt),a.interactiveBufferPrimed=!0}else g||(a.interactiveBufferPrimed=!0);const w=a.decodedFrames[0],v=w?.pending?Math.max(0,c-w.pending.queuedAt):0,b=a.lastPaintAt>0?a.lastPaintAt+i:c;if(!(!x||c+Bx>=b||v>=dy)){a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(r);return}const j=a.decodedFrames.shift();if(j)try{$x(n,a,j)}catch{}a.decodedFrames.length===0&&(a.interactiveQueueDrainCount+=1,a.interactiveBufferPrimed=!1,a.interactiveBufferStartedAt=0),hd(n,a);return}const d=a.lastPaintAt>0?a.lastPaintAt+i:c+DS;if(!(c+Bx>=d||a.decodedFrames.length>=vh-1)){a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(r);return}const p=a.decodedFrames.shift();if(p)try{$x(n,a,p)}catch{}hd(n,a)};a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(r)}function vy(n,a){if(xa.get(n)!==a||a.decoder.state==="closed")return!1;for(a.renderTimer!==null&&(window.cancelAnimationFrame(a.renderTimer),a.renderTimer=null),a.renderScheduledAt=0;a.decodedFrames.length>1;)md(a,a.decodedFrames.shift());return a.lastPaintAt=0,a.interactiveBufferPrimed=!1,a.interactiveBufferStartedAt=0,hd(n,a),!0}function bm(){if(!(typeof document>"u"||document.visibilityState!=="visible"))for(const n of fc){const a=xa.get(n);if(!a||a.decoder.state==="closed"){fc.delete(n);continue}vy(n,a)}}typeof document<"u"&&typeof window<"u"&&(document.addEventListener("visibilitychange",bm),window.addEventListener("focus",bm),window.addEventListener("pageshow",bm));function ws(n){Gi.delete(n),fc.delete(n),dd.delete(n);const a=xa.get(n);if(a){xa.delete(n);try{yh(a),a.decoder.state!=="closed"&&a.decoder.close()}catch{}}}function qo(n){n&&(ud.delete(n),Wm.delete(n),Xm.delete(n),Qm.delete(n),dd.delete(n),dc.delete(n),ws(n))}function nd(n,a=1){try{n.decoder.state!=="closed"&&n.decoder.reset()}catch{}n.configured=!1,n.configKey="",n.keyFrameSeen=!1,n.pendingFrames.clear(),yh(n),n.lastPaintAt=0,n.lastOutputAt=0,n.lastInputAt=0,n.interactiveBufferPrimed=!1,n.interactiveBufferStartedAt=0,n.lastInputFrameSeq=void 0,n.nextChunkTimestampUs=0,n.healthSampleStartedAt=performance.now(),n.healthInputSerial=n.inputSerial,n.healthOutputSerial=n.outputSerial,n.droppedForLatency+=Math.max(1,Math.min(1e4,Math.floor(a)))}function Ou(n,a,i,r){n.decoder.configure(a),n.configured=!0,n.configKey=i,n.codec=a.codec,n.hardwareAcceleration=r,n.keyFrameSeen=!1,n.nextChunkTimestampUs=0,n.lastInputFrameSeq=void 0}function ZS(n,a){if(a.latencyMode!=="interactive"||a.hardwareAcceleration!=="prefer-hardware")return!1;const i=performance.now();if(i-a.healthSampleStartedAt<IS)return!1;const r=a.inputSerial-a.healthInputSerial,c=a.outputSerial-a.healthOutputSerial;return a.healthSampleStartedAt=i,a.healthInputSerial=a.inputSerial,a.healthOutputSerial=a.outputSerial,r<BS||c/Math.max(1,r)>=FS?!1:(fd=!0,wd(n,a.hardwareAcceleration),ws(n),!0)}function Ux(n,a=1){if(!n)return!1;const i=xa.get(n);return i?(i.droppedForLatency+=Math.max(1,Math.min(1e4,Math.floor(a))),ws(n),!0):!1}function JS(n){if(!n)return!1;const a=xa.get(n);return a?vy(n,a):!1}function e0(n,a,i,r="interactive"){ws(n);const c=performance.now(),d=kS(a.payload,a.uncompressedByteLength||0),h=String(a.streamId||"mode5");let p=dc.get(n);if(!p||p.streamId!==h||p.width!==d.width||p.height!==d.height){const M=new Uint8ClampedArray(d.width*d.height*4);for(let T=3;T<M.length;T+=4)M[T]=255;p={streamId:h,width:d.width,height:d.height,rgba:M,imageData:new ImageData(M,d.width,d.height),keyFrameSeen:!1,inputSerial:0,outputSerial:0},dc.set(n,p)}if(!p)throw new Error("Mode 5 canvas state could not be initialized.");p.inputSerial+=1;const g=Number(a.streamFrameSeq||0);if(g>0&&(p.lastStreamFrameSeq=g),!d.keyFrame&&!p.keyFrameSeen)return;d.keyFrame&&(p.keyFrameSeen=!0);const w=MS(p.rgba,p.width,p.height,d),v=performance.now();(n.width!==p.width||n.height!==p.height)&&(n.width=p.width,n.height=p.height);const b=hy(n,r),k=performance.now();w&&b?.context.putImageData(p.imageData,0,0,w.x,w.y,w.width,w.height);const j=performance.now();p.outputSerial+=1,i?.(a,{deviceId:a.deviceId,frameSeq:a.frameSeq,mode:a.frameMode||a.mode||a.mimeType,width:p.width,height:p.height,byteLength:a.byteLength,queuedForMs:Math.max(0,j-c),decodedForMs:Math.max(0,v-c),scheduledForMs:0,drawMs:Math.max(0,j-k),queueSize:0,renderQueueSize:0,droppedForLatency:0,h264DecodeAcceleration:"prefer-software",decoderLabel:"lzo-rgb565-delta",decoderFlushCount:0,decoderTimestampFallbacks:0,decoderInputCount:p.inputSerial,decoderOutputCount:p.outputSerial,targetPaintIntervalMs:Math.max(1,Number(a.durationUs||0)/1e3||1e3/30),canvasPresentation:b?.presentation||"sync",interactiveBufferWaitCount:0,interactiveBufferWaitMs:0,interactiveQueueDrainCount:0,visualHash:String(a.contentHash||""),visualChanged:Number(a.deltaVisualTileCount||0)>0,paintedAt:j})}const Sm=[{code:30,maxFrameSize:1620,maxMacroblocksPerSecond:40500},{code:31,maxFrameSize:3600,maxMacroblocksPerSecond:108e3},{code:32,maxFrameSize:5120,maxMacroblocksPerSecond:216e3},{code:40,maxFrameSize:8192,maxMacroblocksPerSecond:245760},{code:41,maxFrameSize:8192,maxMacroblocksPerSecond:245760},{code:42,maxFrameSize:8704,maxMacroblocksPerSecond:522240},{code:50,maxFrameSize:22080,maxMacroblocksPerSecond:589824},{code:51,maxFrameSize:36864,maxMacroblocksPerSecond:983040},{code:52,maxFrameSize:36864,maxMacroblocksPerSecond:2073600}];function Px(n,a){for(let i=Math.max(0,a);i+3<n.length;i+=1)if(!(n[i]!==0||n[i+1]!==0)){if(n[i+2]===1)return{index:i,length:3};if(n[i+2]===0&&n[i+3]===1)return{index:i,length:4}}return null}function t0(n){const a=new Uint8Array(n);let i=0;for(;i<a.length;){const r=Px(a,i);if(!r)break;const c=r.index+r.length,d=Px(a,c),h=d?.index??a.length;if(c<h&&(a[c]&31)===7){const p=[];let x=0;for(let g=c+1;g<h;g+=1){const w=a[g];if(x>=2&&w===3){x=0;continue}p.push(w),x=w===0?x+1:0}if(p.length>=3)return`avc1.${p.slice(0,3).map(g=>g.toString(16).toUpperCase().padStart(2,"0")).join("")}`}i=d?d.index:a.length}return""}function n0(n,a,i,r,c=""){const d=Math.ceil(n/16)*Math.ceil(a/16),h=i>0?1e6/i:30,p=d*h,x=Sm.find(g=>d<=g.maxFrameSize&&p<=g.maxMacroblocksPerSecond)||Sm[Sm.length-1];return t0(r)||c||`avc1.42E0${x.code.toString(16).toUpperCase().padStart(2,"0")}`}function a0(n,a,i,r,c="smooth"){dc.delete(n);const d=String(a.h264Format||"").toLowerCase()==="avc"?"avc":"annexb",h=Math.max(1,Math.floor(a.width||960)),p=Math.max(1,Math.floor(a.height||540)),x=Math.max(1,Math.floor(a.durationUs||1e6/12));let g=Hx(n,c);const w=n0(h,p,x,a.payload,g.codec),v=String(a.frameMode||a.mode||"").toLowerCase(),b=c==="interactive"&&r==="prefer-hardware"&&US(),j=v==="mode4-h264-atlas"?"prefer-software":my(n,c==="interactive"&&(fd||b)?"prefer-software":r),M=[a.streamId||"",a.commandId||"",h,p,w,d,j,c].join("|");g.onPaint=i,g.configured&&g.decoder.state!=="configured"&&(g.configured=!1,g.configKey=""),g.configured&&g.configKey!==M&&(ws(n),g=Hx(n,c),g.onPaint=i);const T={codec:w,codedWidth:h,codedHeight:p,hardwareAcceleration:j,optimizeForLatency:!0,avc:{format:d}};g.configured||Ou(g,T,M,j);const C=a.isKeyFrame===!0||String(a.chunkType||"").toLowerCase()==="key";Number(a.frameSeq||0);const A=Number(a.streamFrameSeq||0);if(A>0&&g.lastInputFrameSeq!==void 0){if(A<=g.lastInputFrameSeq){if(!C||A===g.lastInputFrameSeq)return;nd(g,g.lastInputFrameSeq-A+1),Ou(g,T,M,j)}if(A>g.lastInputFrameSeq+1){if(nd(g,A-g.lastInputFrameSeq-1),!C)return;Ou(g,T,M,j)}}if(A>0&&(g.lastInputFrameSeq=A),!C&&!g.keyFrameSeen)return;C&&(g.keyFrameSeen=!0);const D=Number(g.decoder.decodeQueueSize||0);if(D>8){if(g.latencyMode==="interactive"&&g.hardwareAcceleration==="prefer-hardware"){fd=!0,wd(n,g.hardwareAcceleration),ws(n);return}if(nd(g),!C)return;Ou(g,T,M,j),g.keyFrameSeen=!0}const H=g.nextChunkTimestampUs;g.nextChunkTimestampUs+=x,g.pendingFrames.set(H,{frame:a,queuedAt:performance.now(),queueSize:D}),g.inputSerial+=1,g.lastInputAt=performance.now();const B=new EncodedVideoChunk({type:C?"key":"delta",timestamp:H,duration:x,data:a.payload});try{g.decoder.decode(B)}catch(q){throw ws(n),q}xy(n,g),ZS(n,g)}async function Cm(n,a,i,r,c,d="smooth"){if(WS(a)){i()||e0(n,a,r,d);return}if(KS(a)){i()||a0(n,a,r,c,d);return}if(dc.delete(n),VS(a)){ws(n);const v=XS(a);if(i())return;(n.width!==v.width||n.height!==v.height)&&(n.width=v.width,n.height=v.height);const b=n.getContext("2d"),k=performance.now();b?.putImageData(v,0,0);const j=performance.now(),M=Zm(n,v.width,v.height);r?.(a,{deviceId:a.deviceId,frameSeq:a.frameSeq,mode:a.frameMode||a.mode||a.codec||a.mimeType,width:v.width,height:v.height,byteLength:a.byteLength,queuedForMs:0,decodedForMs:0,scheduledForMs:0,drawMs:Math.max(0,j-k),queueSize:0,renderQueueSize:0,droppedForLatency:0,h264DecodeAcceleration:Ki.h264DecodeAcceleration,decoderLabel:"lzo-rgb565",decoderFlushCount:0,decoderTimestampFallbacks:0,decoderInputCount:0,decoderOutputCount:0,targetPaintIntervalMs:0,canvasPresentation:"sync",interactiveBufferWaitCount:0,interactiveBufferWaitMs:0,interactiveQueueDrainCount:0,visualHash:M.visualHash,visualChanged:M.visualChanged,paintedAt:j});return}ws(n);const h=new Blob([a.payload],{type:a.mimeType}),p=await createImageBitmap(h);if(i()){p.close();return}const x=a.width||p.width||960,g=a.height||p.height||540;(n.width!==x||n.height!==g)&&(n.width=x,n.height=g);const w=n.getContext("2d");if(w){const v=performance.now();w.clearRect(0,0,x,g),w.drawImage(p,0,0,x,g);const b=performance.now(),k=Zm(n,x,g);r?.(a,{deviceId:a.deviceId,frameSeq:a.frameSeq,mode:a.frameMode||a.mode||a.codec||a.mimeType,width:x,height:g,byteLength:a.byteLength,queuedForMs:0,decodedForMs:0,scheduledForMs:0,drawMs:Math.max(0,b-v),queueSize:0,renderQueueSize:0,droppedForLatency:0,h264DecodeAcceleration:Ki.h264DecodeAcceleration,decoderLabel:"image",decoderFlushCount:0,decoderTimestampFallbacks:0,decoderInputCount:0,decoderOutputCount:0,targetPaintIntervalMs:0,canvasPresentation:"sync",interactiveBufferWaitCount:0,interactiveBufferWaitMs:0,interactiveQueueDrainCount:0,visualHash:k.visualHash,visualChanged:k.visualChanged,paintedAt:b})}p.close()}const ac=5179,Ln=li(`http://127.0.0.1:${ac}`);function s0(n){const a=n.split(".").map(i=>Number(i));return a.length===4&&a.every(i=>Number.isInteger(i)&&i>=0&&i<=255)?a:[]}function l0(n){const a=n.trim().toLowerCase();return a==="localhost"||a==="127.0.0.1"||a==="::1"||a==="[::1]"}function i0(n){const a=n.trim().toLowerCase();return!a||a==="0.0.0.0"||a==="::"||a==="[::]"}function r0(n){const a=s0(n);return a.length===0?!1:a[0]===10||a[0]===172&&a[1]>=16&&a[1]<=31||a[0]===192&&a[1]===168}function o0(n){return n.includes(":")&&!n.startsWith("[")?`[${n}]`:n}function c0(n){const a=String(n||"").trim();if(!a)return null;const i=/^[a-z][a-z\d+.-]*:\/\//i.test(a)?a:`tcp://${a}`;try{const r=new URL(i),c=r.hostname.replace(/^\[|\]$/g,""),d=Number(r.port);return!c||!Number.isInteger(d)||d<1||d>65535||i0(c)?null:{host:c,port:d}}catch{return null}}function li(n){const a=String(n||"").trim()||`http://127.0.0.1:${ac}`,i=/^[a-z][a-z\d+.-]*:\/\//i.test(a)?a:`http://${a}`;try{const r=new URL(i);return r.port||(r.port=String(ac)),r.hash="",r.search="",r.toString().replace(/\/+$/,"")}catch{return`http://127.0.0.1:${ac}`}}function u0(n){const a=c0(n);return a?li(`http://${o0(a.host)}:${ac}`):""}function qx(n){const i=[n?.endpoint,...Array.isArray(n?.endpoint_candidates)?n.endpoint_candidates:[]].map(r=>u0(String(r||""))).filter(Boolean);return[...new Set(i)]}function sc(n=Ln){if(!(typeof window>"u"||window.location.protocol!=="https:"))try{const a=new URL(n);if(a.protocol!=="http:")return;if(l0(a.hostname))return"loopback";if(r0(a.hostname))return"local"}catch{return}}function bd(n,a=Ln){const i=new URL(n,li(a));return i.protocol=i.protocol==="https:"?"wss:":"ws:",i.toString()}async function Be(n,a,i=Ln){const r=li(i),c={...a,headers:{"Content-Type":"application/json",...a?.headers||{}},cache:"no-store"},d=sc(r);d&&(c.targetAddressSpace=d);let h;try{h=await fetch(`${r}${n}`,c)}catch(p){throw d?new Error("LiveDesk Hub is not reachable at this local network address. If Chrome shows a local network prompt, allow it; otherwise restart the Hub so port 5179 is open on the network."):p}if(!h.ok)throw new Error(`${h.status} ${h.statusText}`);return await h.json()}function Jm(n){if(!n)return"-";const a=Date.now()-Date.parse(n);return Number.isFinite(a)?a<1e3?"now":a<6e4?`${Math.round(a/1e3)}s`:a<36e5?`${Math.round(a/6e4)}m`:`${Math.round(a/36e5)}h`:"-"}async function qi(n){await navigator.clipboard.writeText(n)}const Gx="livedesk_remote_host_targets",d0="livedesk_entitlements";function f0(n){const i=(Array.isArray(n)?n:[n||Ln]).map(r=>li(r||Ln));return[...new Set(i.filter(Boolean))]}function m0(){const[n,a]=f.useState(null),[i,r]=f.useState(!0);return f.useEffect(()=>{let c=!0;Ds.auth.getSession().then(({data:h})=>{c&&(a(h.session??null),r(!1))});const{data:{subscription:d}}=Ds.auth.onAuthStateChange((h,p)=>{a(p),r(!1)});return()=>{c=!1,d.unsubscribe()}},[]),{session:n,loading:i}}function h0(n,a=!0){const[i,r]=f.useState(null),[c,d]=f.useState([]),[h,p]=f.useState(""),[x,g]=f.useState(""),[w,v]=f.useState(0),b=f.useRef(new Map),k=Array.isArray(n)?n.join(`
|
|
10
|
+
`):String(n||""),j=f.useMemo(()=>f0(n),[k]),M=f.useMemo(()=>j.find(A=>sc(A)==="loopback")||j[0]||Ln,[j]),T=f.useCallback(async()=>{if(!a){r(null),d([]),g(""),p("");return}let A=null;const D=Date.now(),H=j.filter(B=>(b.current.get(B)||0)<=D);if(H.length===0)throw new Error("No LiveDesk Hub endpoint is reachable. Retrying shortly.");for(const B of H)try{const[q,L]=await Promise.all([Be("/api/remote/status",void 0,B),Be("/api/remote/devices",void 0,B)]);if(!Array.isArray(L.devices))throw new Error("Invalid Hub devices response.");b.current.delete(B),r(q),d(L.devices),g(B),p("");return}catch(q){A=q,b.current.set(B,Date.now()+1e4)}throw g(""),A||new Error("No LiveDesk Hub endpoint is reachable.")},[a,j]),C=f.useCallback(()=>{b.current.clear(),T().catch(A=>{p(A instanceof Error?A.message:String(A))}),v(A=>A+1)},[T]);return f.useEffect(()=>{if(!a){r(null),d([]),g(""),p("");return}let A=!0;const D=async()=>{try{await T()}catch(B){A&&p(B instanceof Error?B.message:String(B))}};D();const H=window.setInterval(D,2500);return()=>{A=!1,window.clearInterval(H)}},[a,T,w]),{status:i,devices:c,error:h,refresh:C,hubBaseUrl:x||M,hubCandidates:j}}function p0(n){const[a,i]=f.useState(null),[r,c]=f.useState(""),d=n?.user?.id||"",h=f.useCallback(async()=>{if(!d){i(null);return}const{data:p,error:x}=await Ds.from(Gx).select("*").eq("user_id",d).maybeSingle();if(x){c(x.message);return}i(p),c("")},[d]);return f.useEffect(()=>{h()},[h]),f.useEffect(()=>{if(!d)return;const p=Ds.channel(`livedesk-remote-host-targets-${d.replace(/[^a-zA-Z0-9]/g,"")}`).on("postgres_changes",{event:"*",schema:"public",table:Gx,filter:`user_id=eq.${d}`},x=>i(x.new)).subscribe();return()=>{Ds.removeChannel(p)}},[d]),{target:a,error:r,refresh:h}}function g0(n){const[a,i]=f.useState(null),[r,c]=f.useState(!1),[d,h]=f.useState(""),p=n?.user?.id||"",x=f.useCallback(async()=>{if(!p){i(null),h(""),c(!1);return}c(!0);const{data:w,error:v}=await Ds.from(d0).select("*").eq("user_id",p).eq("product_key","livedesk").maybeSingle();if(v){h(v.message),c(!1);return}i(w),h(""),c(!1)},[p]);f.useEffect(()=>{x()},[x]);const g=f.useMemo(()=>!a||a.status!=="active"?!1:a.expires_at?new Date(a.expires_at).getTime()>Date.now():!0,[a]);return{entitlement:a,licensed:g,loading:r,error:d,refresh:x}}const lc={totalFrames:0,totalBytes:0,framesPerSecond:0,bytesPerSecond:0,sampleMs:0,lastUpdatedAt:0},x0=2500,v0=3e4,y0=64*1024,w0=6,b0=w0,yy=new Map;function S0(n){return yy.get(n)}const Yx={totalSent:0,totalDropped:0,sentPerSecond:0,droppedPerSecond:0,bufferedAmount:0,lastInputType:"",lastInputSeq:0,lastRoundTripMs:0,lastAgentApplyMs:0,lastUpdatedAt:0};function Vx(n){const a=Date.parse(String(n||""));if(!Number.isFinite(a))return 0;const i=Date.now()-a;return i>0&&i<=v0?i:0}function Kx(n,a,i=Ln,r={}){const[c,d]=f.useState(new Map),[h,p]=f.useState("idle"),[x,g]=f.useState(""),[w,v]=f.useState(lc),b=f.useRef(new Map),k=f.useRef(new Map),j=f.useRef(0),M=f.useRef(new Map),T=f.useRef({enabled:!1,token:"",reason:""}),C=f.useRef(new Set),[A,D]=f.useState(0),H=f.useRef(r.onFrame),B=f.useRef({totalFrames:0,totalBytes:0,sampleFrames:0,sampleBytes:0,sampleStartedAt:0}),q=f.useMemo(()=>[...n].sort().join(","),[n]),L=Number.isFinite(r.fps)?Number(r.fps):2,F=Number.isFinite(r.maxWidth)?Number(r.maxWidth):640,ue=Number.isFinite(r.maxHeight)?Number(r.maxHeight):360,W=Number.isFinite(r.quality)?Number(r.quality):45,ce=String(r.frameMode||r.mode||"mode3-h264-hw").trim()||"mode3-h264-hw",Q=r.streamPurpose==="control"?"control":"wall",se=r.forceRestart===!0,oe=String(r.forceRestartToken||"").trim(),K=String(r.restartReason||"").trim();T.current={enabled:se,token:oe,reason:K};const z=f.useMemo(()=>{const $=Object.entries(r.monitorSelections||{}).filter(([ie])=>!!ie).sort(([ie],[we])=>ie.localeCompare(we));return JSON.stringify(Object.fromEntries($))},[r.monitorSelections]);f.useEffect(()=>{H.current=r.onFrame},[r.onFrame]);const Y=f.useCallback(($,ie="livedesk-frame-socket-release")=>{$.disposed=!0;try{$.socket.readyState===WebSocket.CONNECTING||$.socket.readyState===WebSocket.OPEN?$.socket.close(1e3,ie):$.socket.close()}catch{}},[]),U=f.useCallback(()=>{const $=[...k.current.values()].map(ie=>ie.socket);if($.length===0){p("idle");return}if($.some(ie=>ie.readyState===WebSocket.OPEN)){p("open");return}if($.some(ie=>ie.readyState===WebSocket.CONNECTING)){p("connecting");return}p("closed")},[]),R=f.useCallback(($,ie,we,me)=>{if(ie.disposed||ie.socket.readyState!==WebSocket.OPEN)return!1;try{return ie.socket.send(JSON.stringify({...ie.payload,type:"restart-live",deviceIds:[$],forceRestart:!0,restartReason:we,restartToken:me})),!0}catch{return!1}},[]),J=f.useCallback(($,ie)=>{if(!$||$.byteLength<5)return;const we=Date.now(),ze=new DataView($).getUint32(0,!1);if(ze<=0||ze+4>$.byteLength)return;const Pe=new Uint8Array($.slice(4,4+ze)),de=JSON.parse(new TextDecoder().decode(Pe));if(Math.max(Vx(de.receivedAt),Vx(de.capturedAt))>x0)return;const Le=$.slice(4+ze),Fe={deviceId:String(de.deviceId||""),kind:de.kind==="thumbnail"?"thumbnail":"live",frameSeq:Number(de.frameSeq||0),streamFrameSeq:Number(de.streamFrameSeq||0)||void 0,streamId:String(de.streamId||""),commandId:de.commandId?String(de.commandId):void 0,width:Number(de.width||0),height:Number(de.height||0),sourceWidth:Number(de.sourceWidth||0)||void 0,sourceHeight:Number(de.sourceHeight||0)||void 0,mimeType:String(de.mimeType||"image/jpeg"),mode:de.mode?String(de.mode):void 0,frameMode:de.frameMode?String(de.frameMode):void 0,frameProfile:de.frameProfile?String(de.frameProfile):void 0,encoding:de.encoding?String(de.encoding):void 0,codec:de.codec?String(de.codec):void 0,compression:de.compression?String(de.compression):void 0,pixelFormat:de.pixelFormat?String(de.pixelFormat):void 0,bytesPerPixel:Number(de.bytesPerPixel||0)||0,uncompressedByteLength:Number(de.uncompressedByteLength||0)||0,h264Format:de.h264Format?String(de.h264Format):void 0,isKeyFrame:de.isKeyFrame===!0,chunkType:de.chunkType?String(de.chunkType):void 0,timestampUs:Number(de.timestampUs||0)||0,durationUs:Number(de.durationUs||0)||0,sourceGapMs:Number(de.sourceGapMs||0)||0,agentSendGapMs:Number(de.agentSendGapMs||0)||0,agentSendDurationMs:Number(de.agentSendDurationMs||0)||0,agentSendDurationFrameSeq:Number(de.agentSendDurationFrameSeq||0)||0,agentPaceMs:Number(de.agentPaceMs||0)||0,agentQueueBeforePaceMs:Number(de.agentQueueBeforePaceMs||0)||0,agentFrameAgeMs:Number(de.agentFrameAgeMs||0)||0,droppedByAgent:Number(de.droppedByAgent||0)||0,hubIngressDropped:Number(de.hubIngressDropped||0)||0,hubClientDropped:Number(de.hubClientDropped||0)||0,hardwareEncoder:de.hardwareEncoder?String(de.hardwareEncoder):void 0,platformProfile:de.platformProfile?String(de.platformProfile):void 0,monitorIndex:Number.isFinite(Number(de.monitorIndex))?Number(de.monitorIndex):void 0,monitorCount:Number.isFinite(Number(de.monitorCount))?Number(de.monitorCount):void 0,requestedFps:Number(de.requestedFps||0)||0,effectiveFps:Number(de.effectiveFps||0)||0,captureAverageMs:Number(de.captureAverageMs||0)||0,captureP95Ms:Number(de.captureP95Ms||0)||0,slowFrameCount:Number(de.slowFrameCount||0)||0,captureHelperRestarts:Number(de.captureHelperRestarts||0)||0,capturedAt:String(de.capturedAt||""),receivedAt:String(de.receivedAt||""),hubPacketAt:de.hubPacketAt?String(de.hubPacketAt):void 0,hubPacketEpochMs:Number.isFinite(Number(de.hubPacketEpochMs))?Number(de.hubPacketEpochMs):void 0,browserReceivedEpochMs:we,byteLength:Number(de.byteLength||Le.byteLength),contentHash:de.contentHash?String(de.contentHash):void 0,captureMs:Number(de.captureMs||0)||0,captureStageMs:Number(de.captureStageMs||0)||0,convertMs:Number(de.convertMs||0)||0,compressMs:Number(de.compressMs||0)||0,captureSourceSerial:Number(de.captureSourceSerial||0)||0,captureSourceSkipped:Number(de.captureSourceSkipped||0)||0,deltaTileSize:Number(de.deltaTileSize||0)||0,deltaTileCount:Number(de.deltaTileCount||0)||0,deltaVisualTileCount:Number(de.deltaVisualTileCount||0)||0,deltaRefreshTileCount:Number(de.deltaRefreshTileCount||0)||0,deltaTotalTiles:Number(de.deltaTotalTiles||0)||0,payload:Le};if(!Fe.deviceId)return;const qe={streamId:ie.lastFrameStreamId,commandId:ie.lastFrameCommandId,order:ie.lastFrameOrder},ne=Number(Fe.streamFrameSeq||Fe.frameSeq||0),ye=!!qe.commandId&&!!Fe.commandId,be=qe.streamId===Fe.streamId&&(!ye||qe.commandId===Fe.commandId),Z=qe.order;if(be&&Z>=ne&&(Z===ne||ye))return;ie.lastFrameStreamId=Fe.streamId,ie.lastFrameCommandId=Fe.commandId||"",ie.lastFrameOrder=ne;const le=B.current;le.totalFrames+=1,le.totalBytes+=Le.byteLength,le.sampleFrames+=1,le.sampleBytes+=Le.byteLength,b.current.set(Fe.deviceId,Fe),H.current?.(Fe)},[]);f.useEffect(()=>{const $=window.setInterval(()=>{const ie=performance.now(),we=B.current,me=Math.max(1,ie-we.sampleStartedAt);v({totalFrames:we.totalFrames,totalBytes:we.totalBytes,framesPerSecond:we.sampleFrames*1e3/me,bytesPerSecond:we.sampleBytes*1e3/me,sampleMs:me,lastUpdatedAt:Date.now()}),d(new Map(b.current)),we.sampleFrames=0,we.sampleBytes=0,we.sampleStartedAt=ie},2e3);return()=>{window.clearInterval($)}},[]),f.useEffect(()=>{const $=q?q.split(",").filter(Boolean):[],ie=new Set($),we=performance.now();for(const[me,ze]of k.current.entries())ie.has(me)||(Y(ze,"livedesk-device-unsubscribed"),k.current.delete(me),M.current.delete(me),b.current.delete(me));if($.length===0){for(const me of k.current.values())Y(me,"livedesk-no-devices");k.current.clear(),M.current.clear(),b.current=new Map,d(new Map),g(""),B.current={totalFrames:0,totalBytes:0,sampleFrames:0,sampleBytes:0,sampleStartedAt:0},v(lc),U();return}B.current.sampleStartedAt<=0&&(B.current.sampleStartedAt=we,v({...lc,lastUpdatedAt:Date.now()}));for(const me of $){const ze=r.monitorSelections?.[me],Pe=Number.isFinite(Number(ze))?{[me]:Number(ze)}:{},de={type:"subscribe",deviceIds:[me],autoStartLive:a,fps:L,maxWidth:F,maxHeight:ue,quality:W,mode:ce,frameMode:ce,streamPurpose:Q,monitorSelections:Pe},He=JSON.stringify(de),Le=k.current.get(me);if(Le){const ye=Le.socket.readyState===WebSocket.CONNECTING||Le.socket.readyState===WebSocket.OPEN;if(Le.payloadKey===He&&ye&&!Le.disposed)continue}const Fe=Le&&(Le.socket.readyState===WebSocket.CONNECTING||Le.socket.readyState===WebSocket.OPEN)&&!Le.disposed?Le.handoffFrom&&!Le.handoffCompleted?Le.handoffFrom:Le:void 0;Le&&Le!==Fe&&Y(Le,"livedesk-subscription-superseded");const qe=new WebSocket(bd(`/api/remote/frames/ws?devices=${encodeURIComponent(me)}`,i));qe.binaryType="arraybuffer";const ne={socket:qe,payload:de,payloadKey:He,generation:j.current+1,disposed:!1,handoffFrom:Fe,handoffCompleted:!1,lastFrameStreamId:"",lastFrameCommandId:"",lastFrameOrder:-1};j.current=ne.generation,k.current.set(me,ne),qe.addEventListener("open",()=>{if(ne.disposed||k.current.get(me)!==ne){Y(ne,"livedesk-stale-frame-socket");return}g("");const ye=T.current,be=ye.enabled&&(!ye.token||M.current.get(me)!==ye.token);qe.send(JSON.stringify({...ne.payload,forceRestart:be,restartReason:be?ye.reason:"",restartToken:be?ye.token:""})),be&&ye.token&&M.current.set(me,ye.token);const Z=ne.handoffFrom;ne.handoffFrom=void 0,ne.handoffCompleted=!0,Z&&!Z.disposed&&Y(Z,"livedesk-subscription-replaced"),U()}),qe.addEventListener("message",ye=>{if(ne.disposed||k.current.get(me)!==ne)return;if(typeof ye.data=="string"){try{const Z=JSON.parse(ye.data);if(Z?.type==="RemoteFrameSubscriptionError")g(String(Z.error||"control-stream-start-failed"));else if(Z?.type==="RemoteFrameLiveAutoStart"){const Me=(Array.isArray(Z.skipped)?Z.skipped:[]).find(je=>je?.deviceId===me);Me?g(String(Me.reason||"control-stream-start-failed")):Array.isArray(Z.started)&&Z.started.some(je=>je?.deviceId===me)&&g("")}}catch{}return}const be=ye.data instanceof ArrayBuffer?ye.data:null;be&&(g(""),J(be,ne))}),qe.addEventListener("error",()=>{ne.disposed||k.current.get(me)!==ne||(g("frame-socket-error"),p("error"))}),qe.addEventListener("close",()=>{const ye=!ne.disposed;ne.disposed=!0;const be=k.current.get(me);let Z=!1;if(be===ne){const le=ne.handoffFrom;ne.handoffFrom=void 0,le&&!le.disposed&&(le.socket.readyState===WebSocket.CONNECTING||le.socket.readyState===WebSocket.OPEN)?(k.current.set(me,le),Z=!0):k.current.delete(me)}if(U(),ye&&be===ne&&!Z){const le=window.setTimeout(()=>{C.current.delete(le),D(Me=>Me+1)},750);C.current.add(le)}})}U()},[a,Y,q,L,ce,J,i,ue,F,z,r.monitorSelections,W,A,Q,U]),f.useEffect(()=>{if(!se||!oe)return;const $=q?q.split(",").filter(Boolean):[];for(const ie of $){if(M.current.get(ie)===oe)continue;const we=k.current.get(ie);!we||!R(ie,we,K,oe)||M.current.set(ie,oe)}},[q,se,oe,K,R]),f.useEffect(()=>()=>{for(const $ of k.current.values())Y($,"livedesk-hook-unmount");k.current.clear();for(const $ of C.current)window.clearTimeout($);C.current.clear()},[Y]);const he=f.useCallback(($,ie="browser-stale")=>{const we=Array.isArray($)&&$.length>0?$:q.split(",").filter(Boolean);if(we.length===0)return!1;let me=!1;for(const ze of we){const Pe=k.current.get(ze);!Pe||Pe.socket.readyState!==WebSocket.OPEN||(me=R(ze,Pe,ie,`${Date.now()}-${Math.random().toString(36).slice(2)}`)||me)}return me},[q,R]);return{frames:c,state:h,error:x,stats:w,restartLive:he}}function C0(n,a,i=Ln,r={}){const[c,d]=f.useState(null),[h,p]=f.useState(null),[x,g]=f.useState("idle"),[w,v]=f.useState(lc),b=f.useRef(null),k=f.useRef(r.onFrame),j=f.useRef(null),M=f.useRef(0),T=f.useRef({totalFrames:0,totalBytes:0,sampleFrames:0,sampleBytes:0,sampleStartedAt:0}),C=f.useMemo(()=>[...new Set(n.filter(Boolean))].join(","),[n]),A=f.useMemo(()=>[...new Set((r.captureDeviceIds||n).filter(Boolean))].join(","),[n,r.captureDeviceIds]),D=f.useMemo(()=>JSON.stringify(r.monitorSelections||{}),[r.monitorSelections]),H=f.useMemo(()=>({deviceIds:C.split(",").filter(Boolean),captureDeviceIds:A.split(",").filter(Boolean),fps:Number(r.fps||20),width:Number(r.width||1920),height:Number(r.height||1080),tileWidth:Number(r.tileWidth||320),tileHeight:Number(r.tileHeight||180),monitorSelections:r.monitorSelections||{}}),[A,C,D,r.fps,r.height,r.monitorSelections,r.tileHeight,r.tileWidth,r.width]),B=f.useMemo(()=>JSON.stringify(H),[H]),q=f.useRef(H);q.current=H;const L=a&&H.deviceIds.length>0,F=f.useCallback(W=>W.readyState!==WebSocket.OPEN?!1:(W.send(JSON.stringify({type:"configure",...q.current})),!0),[]);f.useEffect(()=>{k.current=r.onFrame},[r.onFrame]),f.useEffect(()=>{const W=window.setInterval(()=>{const ce=T.current,Q=performance.now(),se=Math.max(1,Q-ce.sampleStartedAt);v({totalFrames:ce.totalFrames,totalBytes:ce.totalBytes,framesPerSecond:ce.sampleFrames*1e3/se,bytesPerSecond:ce.sampleBytes*1e3/se,sampleMs:se,lastUpdatedAt:Date.now()});const oe=j.current;oe&&oe.frameSeq!==M.current&&(M.current=oe.frameSeq,d(oe)),ce.sampleFrames=0,ce.sampleBytes=0,ce.sampleStartedAt=Q},1e3);return()=>window.clearInterval(W)},[]),f.useEffect(()=>{if(!L){b.current?.close(),b.current=null,d(null),j.current=null,M.current=0,p(null),g("idle"),v(lc);return}let W=!1,ce=0;const Q=()=>{if(W)return;const se=new WebSocket(bd("/api/remote/atlas/ws",i));se.binaryType="arraybuffer",b.current=se,g("connecting"),se.addEventListener("open",()=>{T.current.sampleStartedAt=performance.now(),g("open"),F(se)}),se.addEventListener("message",oe=>{if(typeof oe.data=="string"){try{const z=JSON.parse(oe.data);z?.type==="Mode4AtlasLayout"&&p({layoutVersion:Number(z.layoutVersion||0),width:Number(z.width||1920),height:Number(z.height||1080),columns:Number(z.columns||1),rows:Number(z.rows||1),tiles:Array.isArray(z.tiles)?z.tiles:[]})}catch{}return}const K=oe.data instanceof ArrayBuffer?oe.data:null;if(!(!K||K.byteLength<5))try{const z=Date.now(),U=new DataView(K).getUint32(0,!1);if(U<=0||U+4>K.byteLength)return;const R=JSON.parse(new TextDecoder().decode(new Uint8Array(K,4,U))),J=K.slice(4+U),he={deviceId:String(R.deviceId||"__livedesk_mode4_atlas__"),kind:"live",frameSeq:Number(R.frameSeq||0),streamFrameSeq:Number(R.streamFrameSeq||0)||void 0,streamId:String(R.streamId||"mode4-atlas"),commandId:R.commandId?String(R.commandId):void 0,width:Number(R.width||1920),height:Number(R.height||1080),sourceWidth:Number(R.sourceWidth||R.width||1920),sourceHeight:Number(R.sourceHeight||R.height||1080),mimeType:String(R.mimeType||"video/h264"),mode:String(R.mode||"mode4-h264-atlas"),frameMode:String(R.frameMode||"mode4-h264-atlas"),frameProfile:String(R.frameProfile||"mode4-h264-atlas-v1"),encoding:String(R.encoding||"video-atlas"),codec:String(R.codec||"h264"),compression:String(R.compression||"video/h264"),h264Format:String(R.h264Format||"annexb"),isKeyFrame:R.isKeyFrame===!0,chunkType:String(R.chunkType||""),timestampUs:Number(R.timestampUs||0),durationUs:Number(R.durationUs||0),hardwareEncoder:R.hardwareEncoder?String(R.hardwareEncoder):void 0,platformProfile:R.platformProfile?String(R.platformProfile):void 0,capturedAt:String(R.capturedAt||""),receivedAt:String(R.receivedAt||""),hubPacketAt:R.hubPacketAt?String(R.hubPacketAt):void 0,hubPacketEpochMs:Number(R.hubPacketEpochMs||0)||void 0,browserReceivedEpochMs:z,byteLength:J.byteLength,layoutVersion:Number(R.layoutVersion||0),atlasComposeMs:Number(R.atlasComposeMs||0),atlasPoolStarved:Number(R.atlasPoolStarved||0),atlasReadyTiles:Number(R.atlasReadyTiles||0),atlasTileCount:Number(R.atlasTileCount||0),payload:J},$=T.current;$.totalFrames+=1,$.totalBytes+=J.byteLength,$.sampleFrames+=1,$.sampleBytes+=J.byteLength,j.current=he,M.current===0&&(M.current=he.frameSeq,d(he)),k.current?.(he)}catch{}}),se.addEventListener("error",()=>g("error")),se.addEventListener("close",()=>{b.current===se&&(b.current=null),!W&&(g("closed"),ce=window.setTimeout(Q,1200))})};return Q(),()=>{W=!0,window.clearTimeout(ce),b.current?.close(),b.current=null}},[L,i,F]),f.useEffect(()=>{if(!L)return;const W=b.current;W&&F(W)},[B,L,F]);const ue=f.useCallback(()=>{const W=b.current;return W?F(W):!1},[F]);return{frame:c,layout:h,state:x,stats:w,refreshInputs:ue}}function j0(n,a=Ln){const i=f.useRef(null),r=f.useRef(0),c=f.useRef(0),d=f.useRef(new Map),[h,p]=f.useState("idle"),[x,g]=f.useState(""),[w,v]=f.useState(Yx),b=f.useRef({totalSent:0,totalDropped:0,sampleSent:0,sampleDropped:0,sampleStartedAt:0,lastInputType:"",lastInputSeq:0,lastRoundTripMs:0,lastAgentApplyMs:0});f.useEffect(()=>{if(!n){i.current?.close(),i.current=null,c.current=0,p("idle"),g(""),v(Yx);return}const j=new WebSocket(bd("/api/remote/input/ws",a));return i.current=j,b.current.sampleStartedAt=performance.now(),p("connecting"),g(""),j.addEventListener("open",()=>{g(""),p("open")}),j.addEventListener("message",M=>{if(typeof M.data=="string")try{const T=JSON.parse(M.data);if(T?.type==="RemoteInputError"){g(String(T.error||T.result?.error||"Remote input failed.")),p("error");return}if(T?.type!=="RemoteInputApplied")return;const C=Number(T.inputSeq||0),A=d.current.get(C);A!==void 0&&(b.current.lastRoundTripMs=Math.max(0,performance.now()-A),d.current.delete(C)),b.current.lastInputSeq=C,b.current.lastAgentApplyMs=Math.max(0,Number(T.agentApplyMs||0))}catch{}}),j.addEventListener("close",()=>p("closed")),j.addEventListener("error",()=>p("error")),()=>{j.close(),d.current.clear(),i.current===j&&(i.current=null)}},[n,a]),f.useEffect(()=>{if(!n)return;const j=window.setInterval(()=>{const M=performance.now(),T=b.current,C=Math.max(1,M-T.sampleStartedAt);v({totalSent:T.totalSent,totalDropped:T.totalDropped,sentPerSecond:T.sampleSent*1e3/C,droppedPerSecond:T.sampleDropped*1e3/C,bufferedAmount:i.current?.bufferedAmount||0,lastInputType:T.lastInputType,lastInputSeq:T.lastInputSeq,lastRoundTripMs:T.lastRoundTripMs,lastAgentApplyMs:T.lastAgentApplyMs,lastUpdatedAt:Date.now()}),T.sampleSent=0,T.sampleDropped=0,T.sampleStartedAt=M},1e3);return()=>window.clearInterval(j)},[n]);const k=f.useCallback((j,M)=>{const T=i.current;if(!T||T.readyState!==WebSocket.OPEN||!j)return!1;const C=String(M.type||"").toLowerCase(),A=C==="pointermove",H=A||C==="wheel",B=b.current;if(A&&T.bufferedAmount>y0)return B.totalDropped+=1,B.sampleDropped+=1,B.lastInputType="pointermove-drop",!1;const q=r.current+1;r.current=q;const L=Date.now(),F=!H||q-c.current>=b0;for(F&&(d.current.set(q,performance.now()),H&&(c.current=q)),A||yy.set(j,{inputSeq:q,inputType:C||"input",sentAt:performance.now()});d.current.size>256;){const ue=d.current.keys().next().value;if(ue===void 0)break;d.current.delete(ue)}return T.send(JSON.stringify({type:"input",requestId:H?"":crypto.randomUUID(),fireAndForget:H,deviceId:j,input:{...M,inputSeq:q,requestAck:F,issuedAtEpochMs:L,issuedAt:new Date(L).toISOString()}})),B.totalSent+=1,B.sampleSent+=1,B.lastInputType=C||"input",!0},[]);return{state:h,sendInput:k,stats:w,error:x}}function k0(n){const a=String(n||"").toLowerCase();return a.includes("audio/pcm")||a.includes("audio/l16")||a.includes("f32le")||a.includes("s16le")}const Iu={queuedMs:0,browserAgeMs:0,captureAgeMs:0,captureStatusAgeMs:0,silentForMs:0,captureAlive:!1,helperAlive:!1,captureRestartCount:0,localProcessingAgeMs:0,lastPacketAgeMs:0,lastAcceptedAgeMs:0,framesReceived:0,drops:0,resyncs:0,pendingDecodes:0,lastFrameSeq:0,audioContextState:"closed",stalledCount:0,automaticRestarts:0,lastUpdatedAt:0},M0=.08,A0=.25,N0=.02,Wx=300,T0=4,Bu=1500,jm=5e3,R0=2e3,E0=1e4,Fu=[0,1e3,3e3];function Qx(n){const a=Date.parse(String(n||""));return Number.isFinite(a)?Math.max(0,Date.now()-a):0}function D0(n,a,i){const r=Math.max(1,Math.min(8,Math.floor(a.channels||2))),c=Math.max(8e3,Math.min(192e3,Math.floor(a.sampleRate||48e3))),d=String(a.mimeType||"").toLowerCase(),h=d.includes("s16le")||d.includes("audio/l16"),p=h?2:4,x=Math.floor(i.byteLength/p),g=Math.floor(x/r),w=n.createBuffer(r,g,c),v=new DataView(i);for(let b=0;b<r;b+=1){const k=w.getChannelData(b);for(let j=0;j<g;j+=1){const T=(j*r+b)*p;k[j]=h?Math.max(-1,Math.min(1,v.getInt16(T,!0)/32768)):Math.max(-1,Math.min(1,v.getFloat32(T,!0)))}}return w}function L0(n,a,i=Ln){const r=f.useRef(null),c=f.useRef(0),[d,h]=f.useState("idle"),[p,x]=f.useState(null),[g,w]=f.useState(Iu),[v,b]=f.useState("");return f.useEffect(()=>{if(!a||!n){h("idle"),x(null),w(Iu),b("");return}h("connecting"),x(null),w(Iu),b("");const k=window.AudioContext||window.webkitAudioContext;if(!k){h("unsupported"),w(Iu),b("Audio playback is not supported in this browser.");return}const j=new k;r.current=j,c.current=j.currentTime;const M=new WebSocket(bd("/api/remote/audio/ws?devices="+encodeURIComponent(n),i));M.binaryType="arraybuffer";const T=new Set,C={browserAgeMs:0,captureAgeMs:0,captureStatusAgeMs:0,silentForMs:0,captureAlive:!1,helperAlive:!1,captureRestartCount:0,localProcessingAgeMs:0,lastPacketAt:0,lastAcceptedAt:0,framesReceived:0,drops:0,resyncs:0,pendingDecodes:0,lastFrameSeq:0,audioContextState:String(j.state),stalledCount:0,automaticRestarts:0,activeStreamId:"",lastCaptureStatusAt:0,lastPcmAtEpochMs:0};let A=!1,D=0,H=!1,B=0,q=0;const L=(z=!0)=>{for(const Y of T)try{Y.stop()}catch{}T.clear(),z&&(c.current=j.currentTime+M0)},F=()=>{C.audioContextState=String(j.state),!A&&(C.audioContextState==="suspended"||C.audioContextState==="interrupted"?h("suspended"):C.audioContextState==="closed"&&(h("error"),b("The browser audio context is closed. Toggle Remote Audio off and on to recover.")))},ue=async()=>{if(A||String(j.state)==="closed")return!1;try{if(String(j.state)!=="running"&&await j.resume(),C.audioContextState=String(j.state),!A&&!H&&C.audioContextState==="running"){const z=C.lastAcceptedAt>0&&performance.now()-C.lastAcceptedAt<=Bu,Y=C.lastCaptureStatusAt>0&&performance.now()-C.lastCaptureStatusAt<=jm&&C.captureAlive&&C.helperAlive;h(z?"playing":Y?"silent":"open")}return C.audioContextState==="running"}catch(z){return A||(h("suspended"),b(z instanceof Error?"Audio playback is suspended: "+z.message:"Audio playback is suspended.")),!1}},W=async()=>{if(A||H||M.readyState!==WebSocket.OPEN)return;if(B>=Fu.length){h("error"),b("Remote audio stopped sending frames. Toggle Audio off and on to retry.");return}const z=B;B+=1,H=!0,C.stalledCount+=1,C.automaticRestarts+=1,h("reconnecting");try{const Y=await Be("/api/remote/devices/"+encodeURIComponent(n)+"/audio/stop",{method:"POST",body:JSON.stringify({})},i);if(Y.ok===!1)throw new Error(Y.error||"Remote audio stop failed.");if(A)return;const U=await Be("/api/remote/devices/"+encodeURIComponent(n)+"/audio/start",{method:"POST",body:JSON.stringify({streamId:"audio-restart-"+Date.now(),mimeType:"audio/pcm;format=f32le",sampleRate:48e3,channels:2})},i);if(U.ok===!1)throw new Error(U.error||"Remote audio start failed.");const R=performance.now();D=R,C.lastPacketAt=R,C.lastAcceptedAt=0,C.lastCaptureStatusAt=0,C.lastPcmAtEpochMs=0,C.captureAlive=!1,C.helperAlive=!1,C.silentForMs=0,q=R+(Fu[z+1]??3e3),b(""),A||h("open")}catch(Y){A||(q=performance.now()+(Fu[z+1]??3e3),h("error"),b(Y instanceof Error?"Remote audio restart failed: "+Y.message:"Remote audio restart failed."))}finally{H=!1}},ce=()=>{C.drops+=1},Q=window.setInterval(()=>{if(A)return;const z=performance.now(),Y=C.lastPacketAt>0?Math.max(0,z-C.lastPacketAt):D>0?Math.max(0,z-D):0,U=C.lastAcceptedAt>0?Math.max(0,z-C.lastAcceptedAt):0,R=C.lastCaptureStatusAt>0?Math.max(0,z-C.lastCaptureStatusAt):0,J=M.readyState===WebSocket.OPEN,he=C.lastCaptureStatusAt>0,$=he&&R<=jm,ie=he&&(!C.captureAlive||!C.helperAlive)&&R>R0,we=he&&R>jm,me=!he&&D>0&&z-D>E0,ze=D>0&&(C.lastAcceptedAt<=0?z-D>Bu:U>Bu);J&&D>0&&(ie||we||me)?B>=Fu.length&&!H?(h("error"),b("Remote audio capture heartbeat stopped. Toggle Audio off and on to retry.")):!H&&z>=q?W():H||h("stalled"):J&&ze&&!H&&C.audioContextState!=="suspended"&&C.audioContextState!=="interrupted"&&h($?"silent":"open"),w({queuedMs:Math.max(0,(c.current-j.currentTime)*1e3),browserAgeMs:C.browserAgeMs,captureAgeMs:C.captureAgeMs,captureStatusAgeMs:R,silentForMs:C.silentForMs,captureAlive:C.captureAlive,helperAlive:C.helperAlive,captureRestartCount:C.captureRestartCount,localProcessingAgeMs:C.localProcessingAgeMs,lastPacketAgeMs:Y,lastAcceptedAgeMs:U,framesReceived:C.framesReceived,drops:C.drops,resyncs:C.resyncs,pendingDecodes:C.pendingDecodes,lastFrameSeq:C.lastFrameSeq,audioContextState:C.audioContextState,stalledCount:C.stalledCount,automaticRestarts:C.automaticRestarts,lastUpdatedAt:Date.now()})},250),se=()=>{F(),(String(j.state)==="suspended"||String(j.state)==="interrupted")&&ue()},oe=()=>{document.visibilityState==="visible"&&ue()},K=()=>{ue()};return j.addEventListener("statechange",se),document.addEventListener("visibilitychange",oe),window.addEventListener("pageshow",K),window.addEventListener("pointerdown",K),window.addEventListener("keydown",K),h("connecting"),b(""),F(),M.addEventListener("open",()=>{A||(D=performance.now(),C.lastPacketAt=D,C.lastAcceptedAt=0,C.lastCaptureStatusAt=0,C.lastPcmAtEpochMs=0,C.captureAlive=!1,C.helperAlive=!1,C.silentForMs=0,h("open"),M.send(JSON.stringify({type:"subscribe",deviceIds:[n]})),ue())}),M.addEventListener("message",z=>{if(typeof z.data=="string")return;const Y=z.data instanceof ArrayBuffer?z.data:null;if(!Y||Y.byteLength<5)return;const U=performance.now();C.lastPacketAt=U,(async()=>{try{const J=new DataView(Y).getUint32(0,!1);if(J<=0||J+4>Y.byteLength){ce();return}const he=new Uint8Array(Y.slice(4,4+J)),$=JSON.parse(new TextDecoder().decode(he)),ie=Y.slice(4+J),we=String($.frameKind||$.kind||"").toLowerCase();if($.type==="remote.audio.status"||we==="audio-status"){if(C.lastCaptureStatusAt=U,C.captureAlive=$.captureAlive===!0,C.helperAlive=$.helperAlive===!0,C.captureRestartCount=Math.max(0,Number($.restartCount||0)||0),C.lastPcmAtEpochMs=Math.max(0,Number($.lastPcmAtEpochMs||0)||0),C.silentForMs=Math.max(0,Number($.silentForMs||0)||0),C.captureAgeMs=C.lastPcmAtEpochMs>0?Math.max(0,Date.now()-C.lastPcmAtEpochMs):C.silentForMs,C.captureAlive&&C.helperAlive){if(B=0,q=0,!H){b("");const ze=String(j.state)==="running",Pe=C.lastAcceptedAt>0&&performance.now()-C.lastAcceptedAt<=Bu;h(ze?Pe?"playing":"silent":"suspended")}}else H||h("stalled");return}const me={deviceId:String($.deviceId||""),frameSeq:Number($.frameSeq||0),streamId:String($.streamId||""),mimeType:String($.mimeType||"audio/webm;codecs=opus"),sampleRate:Number($.sampleRate||48e3),channels:Number($.channels||2),capturedAt:String($.capturedAt||""),receivedAt:String($.receivedAt||""),byteLength:Number($.byteLength||ie.byteLength),payload:ie};if(!me.deviceId||A)return;if(performance.now()-U>Wx){ce();return}if(C.pendingDecodes>=T0){ce();return}C.pendingDecodes+=1;try{const ze=k0(me.mimeType)?D0(j,me,ie):await j.decodeAudioData(ie.slice(0));if(C.localProcessingAgeMs=Math.max(0,performance.now()-U),A)return;if(C.localProcessingAgeMs>Wx){ce();return}if(me.frameSeq>0&&me.frameSeq<=C.lastFrameSeq){ce();return}if(C.activeStreamId&&me.streamId!==C.activeStreamId&&me.frameSeq<=C.lastFrameSeq){ce();return}me.streamId&&me.streamId!==C.activeStreamId&&(C.activeStreamId=me.streamId,C.lastFrameSeq=0,L());const Pe=j.currentTime;Math.max(0,c.current-Pe)>A0&&(L(),C.resyncs+=1);const He=j.createBufferSource();He.buffer=ze,He.connect(j.destination),T.add(He),He.onended=()=>{T.delete(He),He.onended=null};const Le=Math.max(j.currentTime+N0,c.current);He.start(Le),c.current=Le+ze.duration,C.browserAgeMs=Qx(me.receivedAt),C.captureAgeMs=Qx(me.capturedAt),C.lastAcceptedAt=performance.now(),C.framesReceived+=1,C.lastFrameSeq=me.frameSeq,B=0,q=0,x(me),ue();const Fe=String(j.state)==="running";Fe&&b(""),h(Fe?"playing":"suspended")}finally{C.pendingDecodes=Math.max(0,C.pendingDecodes-1)}}catch(R){A||(h("error"),b(R instanceof Error?R.message:String(R)))}})()}),M.addEventListener("error",()=>{A||(h("error"),b("Remote audio WebSocket error."))}),M.addEventListener("close",()=>{A||h("closed")}),()=>{A=!0,window.clearInterval(Q),j.removeEventListener("statechange",se),document.removeEventListener("visibilitychange",oe),window.removeEventListener("pageshow",K),window.removeEventListener("pointerdown",K),window.removeEventListener("keydown",K),L(!1),M.close(),j.close().catch(()=>{}),r.current===j&&(r.current=null)}},[n,a,i]),{state:d,lastFrame:p,stats:g,error:v}}const eh={revision:0,settings:{connection:{usePinToAddDevices:!0,pinValidityMinutes:30,rotatePinAfterPairing:!0,allowNewDevices:!0,approveNewDevices:!0,startWithComputer:!0,keepRunningInTray:!0,showConnectionNotifications:!0},security:{accessMode:"trusted-only",requireEncryptedConnections:!0,allowInternetConnections:!1,allowLanConnections:!0,allowUnencryptedLanFallback:!1,requireNewDeviceApproval:!0,requireAdministratorForSecurityChanges:!0,visibleControlIndicator:!0,lockOnControlEnd:!0,disconnectIdleControlSessions:!0,idleControlMinutes:30,keepSessionHistory:!0,sessionHistoryDays:30},control:{allowKeyboardMouse:!0,allowSystemShortcuts:!0,allowClipboardText:!0,allowRemoteRestart:!1,reconnectAfterRemoteRestart:!0,allowSwitchingMonitors:!0,showConnectionToolbar:!0,showRemoteCursor:!0,openControlOnDoubleClick:!0,startRemoteAudioWithControl:!1,fitRemoteScreen:!0,rememberLastMonitor:!0,keepControlReadyBetweenPages:!0},wall:{performanceMode:"auto",autoStart:!0,connectedOnly:!1,keepEmptySlots:!0,showDeviceStatus:!0,showPerformanceDetails:!1,pauseHiddenTiles:!0,reduceWhenHidden:!0,autoAdjustTileQuality:!0,rememberDevicePositions:!0},filesAudio:{allowFileTransfer:!0,allowFolderSync:!1,askBeforeReceivingFiles:!0,openReceivedFolder:!1,notifyTransferComplete:!0,allowOverwrite:!1,defaultReceiveFolder:"Desktop/LiveDeskFiles",maxFileSizeBytes:1073741824,allowRemoteAudio:!0,startAudioMuted:!1,rememberVolume:!0,automaticallyRecoverAudio:!0,showAudioTroubleshooting:!1,rollingBufferEnabled:!1,recordingQuality:"standard",timelapseIntervalSeconds:10,includeRemoteCursor:!0,captureSaveLocation:"LiveDesk Captures",captureAutoDelete:"never"},agent:{enabled:!1,defaultPermissionMode:"safe-auto",askBeforeDestructive:!0,allowProcessManagement:!0,allowServiceManagement:!0,allowFileChanges:!0,allowCommandExecution:!1,allowSoftwareInstallation:!1,allowPowerActions:!1,keepAuditHistory:!0,timeoutMinutes:10},advanced:{wallFrameMode:"auto",wallFps:20,wallMaxWidth:960,wallMaxHeight:540,wallQuality:55,controlFrameMode:"mode3-h264-hw",controlFps:30,controlMaxWidth:1920,controlMaxHeight:1080,controlQuality:60,transport:"auto",allowPlainLanFallback:!1,verboseLogs:!1,frameStatistics:!1}}},z0=[{id:"connection",label:"Connection",icon:Jo},{id:"security",label:"Security",icon:Sn},{id:"control",label:"Control",icon:an},{id:"wall",label:"Wall",icon:cc},{id:"files-audio",label:"Files & Audio",icon:Or},{id:"agent",label:"Agent",icon:Vi},{id:"advanced",label:"Advanced",icon:mh}];function Fi(n,a){return n?.settings?.[a]||eh.settings[a]}function nt({icon:n,title:a,description:i,children:r,disabled:c=!1,recommended:d=!1}){return l.jsxs("div",{className:`product-setting-row ${c?"disabled":""}`,children:[l.jsx("div",{className:"product-setting-control",children:r}),n&&l.jsx("span",{className:"product-setting-icon",children:l.jsx(n,{size:17})}),l.jsxs("div",{className:"product-setting-copy",children:[l.jsx("strong",{children:a}),d&&l.jsx("em",{children:"Recommended"}),l.jsx("small",{children:i})]})]})}function mt({checked:n,onChange:a,disabled:i=!1,label:r}){return l.jsxs("label",{className:"product-switch",children:[l.jsx("input",{"aria-label":r,type:"checkbox",checked:n,disabled:i,onChange:c=>a(c.target.checked)}),l.jsx("span",{})]})}function fl({value:n,onChange:a,options:i,disabled:r=!1,label:c}){return l.jsx("select",{"aria-label":c,value:String(n),disabled:r,onChange:d=>a(d.target.value),children:i.map(([d,h])=>l.jsx("option",{value:d,children:h},d))})}function _0({hubUrl:n="",initialTab:a="connection",pin:i,wall:r,control:c,agent:d,advancedExtras:h,captureGallery:p}){const[x,g]=f.useState(a),[w,v]=f.useState(null),[b,k]=f.useState("loading"),[j,M]=f.useState("");f.useEffect(()=>{let U=!0;return k("loading"),Be("/api/settings",void 0,n).then(R=>{U&&(v({revision:Number(R.revision||0),updatedAt:R.updatedAt,settings:R.settings}),k("saved"))}).catch(R=>{U&&(M(R instanceof Error?R.message:String(R)),v(eh),k("failed"))}),()=>{U=!1}},[n]);const T=async(U,R,J)=>{const he=w||eh,$=he,ie={...he,settings:{...he.settings,[U]:{...Fi(he,U),[R]:J}}};v(ie),k("saving"),M("");try{const we=await Be("/api/settings",{method:"PATCH",body:JSON.stringify({revision:he.revision,[U]:{[R]:J}})},n);v({revision:we.revision,updatedAt:we.updatedAt,settings:we.settings}),k("saved")}catch(we){v($),k("failed"),M(we instanceof Error?we.message:String(we))}},C=(U,R)=>J=>{T(U,R,J)},A=Fi(w,"security"),D=Fi(w,"connection"),H=Fi(w,"control"),B=Fi(w,"wall"),q=Fi(w,"filesAudio"),L=Fi(w,"agent"),F=f.useMemo(()=>A.allowInternetConnections===!1?{label:"Local only",tone:"local",detail:"Internet connections are disabled."}:A.requireEncryptedConnections&&A.requireNewDeviceApproval&&A.accessMode==="trusted-only"?{label:"Protected",tone:"protected",detail:"Encrypted connections and trusted-device approval are active."}:{label:"Needs attention",tone:"attention",detail:"Review access and encryption settings before sharing this Hub."},[A]),ue=`settings-panel-${x}`,W=l.jsxs("div",{className:"settings-tab-content product-settings-content",children:[l.jsxs("section",{className:"product-settings-hero",children:[l.jsxs("div",{children:[l.jsxs("span",{className:"settings-eyebrow",children:[l.jsx(Jo,{size:14})," Connection"]}),l.jsx("h2",{children:"Connect a device"}),l.jsx("p",{children:"Use the short PIN on the computer you want to add. The PIN is temporary and can be replaced at any time."})]}),l.jsxs("div",{className:"product-save-state",role:"status",children:[l.jsx(ny,{size:14})," ",b==="saving"?"Saving":b==="failed"?"Failed":b==="loading"?"Loading":"Saved"]})]}),i,l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Connection behavior"}),l.jsx("h3",{children:"New device access"})]}),l.jsx(ec,{size:20})]}),l.jsx(nt,{icon:ec,title:"Use PIN to add new devices",description:"Allow temporary PIN pairing from the client.",recommended:!0,children:l.jsx(mt,{checked:!!D.usePinToAddDevices,onChange:C("connection","usePinToAddDevices"),label:"Use PIN to add new devices"})}),l.jsx(nt,{icon:Sn,title:"Approve new devices on this Hub",description:"Ask for approval before an unfamiliar computer becomes trusted.",children:l.jsx(mt,{checked:!!D.approveNewDevices,onChange:C("connection","approveNewDevices"),label:"Approve new devices"})}),l.jsx(nt,{icon:nn,title:"Show connection notifications",description:"Show a short notice when a computer connects or leaves.",children:l.jsx(mt,{checked:!!D.showConnectionNotifications,onChange:C("connection","showConnectionNotifications"),label:"Show connection notifications"})})]})]}),ce=l.jsxs("div",{className:"settings-tab-content product-settings-content",children:[l.jsxs("section",{className:`security-status-card ${F.tone}`,children:[l.jsxs("div",{children:[l.jsx("span",{children:"Security status"}),l.jsx("strong",{children:F.label}),l.jsx("small",{children:F.detail})]}),l.jsx(Sn,{size:28})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Access mode"}),l.jsx("h3",{children:"Who may use this Hub?"})]}),l.jsx(oc,{size:20})]}),l.jsx(nt,{icon:Sn,title:"Access mode",description:"Choose the default boundary for remote sessions.",recommended:!0,children:l.jsx(fl,{value:String(A.accessMode),onChange:C("security","accessMode"),label:"Access mode",options:[["trusted-only","Trusted devices only"],["ask-every-time","Ask every time"],["view-only","View only"],["block-remote-access","Block remote access"]]})}),l.jsx(nt,{icon:Jo,title:"Require encrypted connections",description:"External connections cannot disable this protection.",recommended:!0,children:l.jsx(mt,{checked:!!A.requireEncryptedConnections,onChange:C("security","requireEncryptedConnections"),label:"Require encrypted connections"})}),l.jsx(nt,{icon:Jo,title:"Allow internet connections",description:"Keep off unless you intentionally expose this Hub beyond the LAN.",children:l.jsx(mt,{checked:!!A.allowInternetConnections,onChange:C("security","allowInternetConnections"),label:"Allow internet connections"})}),l.jsx(nt,{icon:an,title:"Allow LAN connections",description:"Permit connections from the local network.",children:l.jsx(mt,{checked:!!A.allowLanConnections,onChange:C("security","allowLanConnections"),label:"Allow LAN connections"})}),l.jsx(nt,{icon:Sn,title:"Require approval for new devices",description:"New computers must be approved before remote access is granted.",children:l.jsx(mt,{checked:!!A.requireNewDeviceApproval,onChange:C("security","requireNewDeviceApproval"),label:"Require approval for new devices"})})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Session protection"}),l.jsx("h3",{children:"End sessions safely"})]}),l.jsx(nn,{size:20})]}),l.jsx(nt,{icon:an,title:"Show an indicator while Control is active",description:"Make active remote control visible on the local computer.",children:l.jsx(mt,{checked:!!A.visibleControlIndicator,onChange:C("security","visibleControlIndicator"),label:"Show Control indicator"})}),l.jsx(nt,{icon:oc,title:"Lock the remote computer when Control ends",description:"Protect the local screen after a Control session.",children:l.jsx(mt,{checked:!!A.lockOnControlEnd,onChange:C("security","lockOnControlEnd"),label:"Lock after Control ends"})}),l.jsx(nt,{icon:nn,title:"Disconnect idle Control sessions",description:"Automatically close inactive Control sessions.",children:l.jsx(mt,{checked:!!A.disconnectIdleControlSessions,onChange:C("security","disconnectIdleControlSessions"),label:"Disconnect idle sessions"})}),l.jsx(nt,{icon:nn,title:"Idle timeout",description:"Time before an inactive Control session closes.",disabled:!A.disconnectIdleControlSessions,children:l.jsx(fl,{value:Number(A.idleControlMinutes),onChange:U=>C("security","idleControlMinutes")(Number(U)),disabled:!A.disconnectIdleControlSessions,label:"Idle timeout",options:[["5","5 minutes"],["15","15 minutes"],["30","30 minutes"],["60","1 hour"],["1440","Never"]]})})]})]}),Q=l.jsxs("div",{className:"settings-tab-content product-settings-content",children:[l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Remote use"}),l.jsx("h3",{children:"What can a connected user do?"})]}),l.jsx(an,{size:20})]}),l.jsx(nt,{icon:an,title:"Keyboard and mouse control",description:"Allow the Hub to send keyboard and pointer input.",recommended:!0,children:l.jsx(mt,{checked:!!H.allowKeyboardMouse,onChange:C("control","allowKeyboardMouse"),label:"Keyboard and mouse control"})}),l.jsx(nt,{icon:Bb,title:"System shortcuts",description:"Allow shortcut keys such as Alt-Tab and the system key.",children:l.jsx(mt,{checked:!!H.allowSystemShortcuts,onChange:C("control","allowSystemShortcuts"),label:"System shortcuts"})}),l.jsx(nt,{icon:ec,title:"Clipboard text sharing",description:"Share plain text through the remote session.",children:l.jsx(mt,{checked:!!H.allowClipboardText,onChange:C("control","allowClipboardText"),label:"Clipboard text sharing"})}),l.jsx(nt,{icon:nn,title:"Remote restart",description:"Allow restart requests from Control.",disabled:!H.allowKeyboardMouse,children:l.jsx(mt,{checked:!!H.allowRemoteRestart,onChange:C("control","allowRemoteRestart"),disabled:!H.allowKeyboardMouse,label:"Remote restart"})}),l.jsx(nt,{icon:an,title:"Switching monitors",description:"Allow the viewer to select another connected display.",children:l.jsx(mt,{checked:!!H.allowSwitchingMonitors,onChange:C("control","allowSwitchingMonitors"),label:"Switching monitors"})})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Session behavior"}),l.jsx("h3",{children:"Make Control predictable"})]}),l.jsx(qn,{size:20})]}),l.jsx(nt,{icon:an,title:"Open Control on double-click",description:"Double-clicking a Wall tile opens its Control view.",children:l.jsx(mt,{checked:!!H.openControlOnDoubleClick,onChange:C("control","openControlOnDoubleClick"),label:"Open Control on double-click"})}),l.jsx(nt,{icon:nn,title:"Start audio with Control",description:"Keep audio muted by default for new sessions.",children:l.jsx(mt,{checked:!!H.startRemoteAudioWithControl,onChange:C("control","startRemoteAudioWithControl"),label:"Start audio with Control"})}),l.jsx(nt,{icon:an,title:"Fit remote screen to window",description:"Scale the remote display to the available Control area.",children:l.jsx(mt,{checked:!!H.fitRemoteScreen,onChange:C("control","fitRemoteScreen"),label:"Fit remote screen"})}),l.jsx(nt,{icon:nn,title:"Keep Control ready between pages",description:"Faster reconnection for 1 minute.",recommended:!0,children:l.jsx(mt,{checked:!!H.keepControlReadyBetweenPages,onChange:C("control","keepControlReadyBetweenPages"),label:"Keep Control ready between pages"})})]})]}),se=l.jsxs("div",{className:"settings-tab-content product-settings-content",children:[l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Performance mode"}),l.jsx("h3",{children:"Let LiveDesk choose the best path"})]}),l.jsx(cc,{size:20})]}),l.jsx(nt,{icon:Vi,title:"Performance mode",description:"Automatic mode balances responsiveness and image quality.",recommended:!0,children:l.jsx(fl,{value:String(B.performanceMode),onChange:C("wall","performanceMode"),label:"Performance mode",options:[["auto","Auto"],["responsive","Prioritize responsiveness"],["quality","Prioritize image quality"],["custom","Custom"]]})}),l.jsx("p",{className:"settings-help",children:"Streaming details are available under Advanced for diagnostics and development."})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Wall behavior"}),l.jsx("h3",{children:"What should the Wall show?"})]}),l.jsx(nn,{size:20})]}),[["autoStart","Start Wall automatically","Start a live view when a computer connects."],["connectedOnly","Show only connected devices","Hide disconnected slots."],["keepEmptySlots","Keep empty slots visible","Preserve the layout when a device leaves."],["showDeviceStatus","Show device status on tiles","Display compact machine status."],["showPerformanceDetails","Show performance details","Show advanced frame diagnostics on tiles."],["pauseHiddenTiles","Pause hidden tiles","Reduce capture work for tiles outside the visible area."],["reduceWhenHidden","Reduce activity when the window is hidden","Lower background work when the browser is not visible."],["autoAdjustTileQuality","Automatically adjust tile quality","Adapt tile quality to Wall size and load."]].map(([U,R,J])=>l.jsx(nt,{icon:an,title:R,description:J,children:l.jsx(mt,{checked:!!B[U],onChange:C("wall",U),label:R})},U))]})]}),oe=l.jsxs("div",{className:"settings-tab-content product-settings-content",children:[l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"File permissions"}),l.jsx("h3",{children:"Move files deliberately"})]}),l.jsx(Or,{size:20})]}),l.jsx(nt,{icon:Or,title:"Allow file transfer",description:"Permit Hub-to-device file delivery.",recommended:!0,children:l.jsx(mt,{checked:!!q.allowFileTransfer,onChange:C("filesAudio","allowFileTransfer"),label:"Allow file transfer"})}),l.jsx(nt,{icon:cc,title:"Allow folder sync",description:"Enable recurring folder synchronization.",disabled:!q.allowFileTransfer,children:l.jsx(mt,{checked:!!q.allowFolderSync,onChange:C("filesAudio","allowFolderSync"),disabled:!q.allowFileTransfer,label:"Allow folder sync"})}),l.jsx(nt,{icon:Sn,title:"Ask before receiving files",description:"Require local confirmation before a transfer is written.",children:l.jsx(mt,{checked:!!q.askBeforeReceivingFiles,onChange:C("filesAudio","askBeforeReceivingFiles"),label:"Ask before receiving files"})}),l.jsx(nt,{icon:Or,title:"Allow overwrite",description:"Permit replacing an existing destination file.",children:l.jsx(mt,{checked:!!q.allowOverwrite,onChange:C("filesAudio","allowOverwrite"),label:"Allow overwrite"})})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Audio permissions"}),l.jsx("h3",{children:"Remote sound"})]}),l.jsx(nn,{size:20})]}),l.jsx(nt,{icon:nn,title:"Allow remote audio",description:"Permit audio capture from connected computers.",recommended:!0,children:l.jsx(mt,{checked:!!q.allowRemoteAudio,onChange:C("filesAudio","allowRemoteAudio"),label:"Allow remote audio"})}),l.jsx(nt,{icon:nn,title:"Start audio muted",description:"New audio sessions begin silent.",children:l.jsx(mt,{checked:!!q.startAudioMuted,onChange:C("filesAudio","startAudioMuted"),label:"Start audio muted"})}),l.jsx(nt,{icon:nn,title:"Automatically recover audio",description:"Recover from temporary capture or transport stalls.",children:l.jsx(mt,{checked:!!q.automaticallyRecoverAudio,onChange:C("filesAudio","automaticallyRecoverAudio"),label:"Automatically recover audio"})})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Capture defaults"}),l.jsx("h3",{children:"Screen recording"})]}),l.jsx(an,{size:20})]}),l.jsx(nt,{icon:nn,title:"Keep a Last 30s buffer",description:"Keep recent video in memory only until you explicitly save it.",children:l.jsx(mt,{checked:!!q.rollingBufferEnabled,onChange:C("filesAudio","rollingBufferEnabled"),label:"Keep a Last 30s buffer"})}),l.jsx(nt,{icon:nn,title:"Recording quality",description:"Choose the WebM bitrate profile.",children:l.jsx(fl,{value:String(q.recordingQuality),onChange:C("filesAudio","recordingQuality"),label:"Recording quality",options:[["standard","Standard"],["high","High"]]})}),l.jsx(nt,{icon:nn,title:"Timelapse interval",description:"Capture one frame at the selected interval.",children:l.jsx(fl,{value:Number(q.timelapseIntervalSeconds),onChange:U=>C("filesAudio","timelapseIntervalSeconds")(Number(U)),label:"Timelapse interval",options:[["5","5 seconds"],["10","10 seconds"],["30","30 seconds"],["60","60 seconds"]]})}),l.jsx(nt,{icon:an,title:"Include remote cursor",description:"Include the cursor indicator when the source provides it.",children:l.jsx(mt,{checked:!!q.includeRemoteCursor,onChange:C("filesAudio","includeRemoteCursor"),label:"Include remote cursor"})}),l.jsx(nt,{icon:Or,title:"Capture save location",description:"Captures are stored inside the Hub capture library.",children:l.jsx(fl,{value:String(q.captureSaveLocation),onChange:C("filesAudio","captureSaveLocation"),label:"Capture save location",options:[[String(q.captureSaveLocation||"LiveDesk Captures"),"LiveDesk Captures"]]})}),l.jsx(nt,{icon:Or,title:"Automatic deletion",description:"Keep saved captures until you delete them.",children:l.jsx(fl,{value:String(q.captureAutoDelete),onChange:C("filesAudio","captureAutoDelete"),label:"Automatic deletion",options:[["never","Never"],["7-days","After 7 days"],["30-days","After 30 days"]]})})]}),p]}),K=l.jsxs("div",{className:"settings-tab-content product-settings-content",children:[l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Agent safety"}),l.jsx("h3",{children:"AI workstation operations"})]}),l.jsx(Vi,{size:20})]}),l.jsx(nt,{icon:Vi,title:"Enable AI Agent on devices",description:"Allow Agent runs to reach connected workstations.",recommended:!0,children:l.jsx(mt,{checked:!!L.enabled,onChange:C("agent","enabled"),label:"Enable AI Agent"})}),l.jsx(nt,{icon:Sn,title:"Default permission mode",description:"Safe Auto keeps destructive operations behind approval.",children:l.jsx(fl,{value:String(L.defaultPermissionMode),onChange:C("agent","defaultPermissionMode"),label:"Default Agent permission mode",options:[["ask","Ask"],["safe-auto","Safe Auto"],["full-access","Full Access"],["custom","Custom"]]})}),l.jsx(nt,{icon:Sn,title:"Ask before destructive operations",description:"Locked on for Safe Auto and destructive actions.",disabled:!L.enabled,children:l.jsx(mt,{checked:!!L.askBeforeDestructive,onChange:C("agent","askBeforeDestructive"),disabled:!L.enabled,label:"Ask before destructive operations"})}),l.jsx(nt,{icon:nn,title:"Keep Agent audit history",description:"Retain an inspectable record of Agent runs.",children:l.jsx(mt,{checked:!!L.keepAuditHistory,onChange:C("agent","keepAuditHistory"),label:"Keep Agent audit history"})}),l.jsx(nt,{icon:nn,title:"Stop Agent tasks after timeout",description:"Maximum runtime for one task.",children:l.jsx(fl,{value:Number(L.timeoutMinutes),onChange:U=>C("agent","timeoutMinutes")(Number(U)),label:"Agent task timeout",options:[["1","1 minute"],["5","5 minutes"],["10","10 minutes"],["30","30 minutes"],["60","1 hour"]]})})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Detailed permissions"}),l.jsx("h3",{children:"Capabilities"})]}),l.jsx(Sn,{size:20})]}),[["allowProcessManagement","Allow process management"],["allowServiceManagement","Allow service management"],["allowFileChanges","Allow file changes"],["allowCommandExecution","Allow command execution"],["allowSoftwareInstallation","Allow software installation"],["allowPowerActions","Allow power actions"]].map(([U,R])=>l.jsx(nt,{icon:Sn,title:R,description:U.includes("allowCommand")||U.includes("Installation")||U.includes("Power")?"Disabled by default for safety.":"Applied by the Hub and checked again by the Client.",children:l.jsx(mt,{checked:!!L[U],onChange:C("agent",U),label:R})},U))]}),l.jsx("p",{className:"settings-help",children:"The existing Codex runtime and audit controls remain available below in Advanced and the Agent diagnostics panel."})]}),Y=x==="connection"?W:x==="security"?ce:x==="control"?Q:x==="wall"?se:x==="files-audio"?oe:x==="agent"?l.jsxs(l.Fragment,{children:[K,d]}):l.jsxs("div",{className:"settings-tab-content product-settings-content",children:[h,l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Developer controls"}),l.jsx("h3",{children:"Streaming and diagnostics"})]}),l.jsx(mh,{size:20})]}),l.jsx("p",{className:"settings-help",children:"Codec, frame rate, resolution, quality, Atlas layout, and decoder preferences are intentionally kept here."}),r,c]})]});return l.jsxs("section",{className:"settings-page",children:[l.jsx("div",{className:"settings-page-tabs",role:"tablist","aria-label":"LiveDesk settings",children:z0.map(({id:U,label:R,icon:J})=>l.jsxs("button",{className:x===U?"active":"",id:`settings-tab-${U}`,role:"tab","aria-selected":x===U,"aria-controls":`settings-panel-${U}`,tabIndex:x===U?0:-1,onClick:()=>g(U),type:"button",children:[l.jsx(J,{size:16}),R]},U))}),j&&l.jsx("div",{className:"agent-settings-alert error",role:"alert",children:j}),l.jsx("section",{className:"settings-page-panel",id:ue,role:"tabpanel","aria-labelledby":`settings-tab-${x}`,tabIndex:0,children:Y})]})}function O0({children:n}){return l.jsx("div",{className:"settings-tab-content",children:n})}function I0({children:n}){return l.jsx("div",{className:"settings-tab-content",children:n})}function B0({children:n}){return l.jsx("div",{className:"settings-tab-content",children:n})}const wy={enabled:!0,provider:"codex",codexModelId:"",codexReasoningEffort:"medium",codexTaskTimeoutMs:6e5,codexMaxToolCalls:20,codexWorkingDirectory:"",codexResumeSessions:!0,codexShowDetailedEvents:!0,deterministicParserFirst:!0,generateSummary:!0,fallbackSummary:!0,includeRawDeviceDetails:!1,baseUrl:"https://opencode.ai/zen/go/v1",defaultModelId:"deepseek-v4-flash"};function Xx(n){return{...wy,...n||{}}}function F0({hubUrl:n}){const[a,i]=f.useState(wy),[r,c]=f.useState(null),[d,h]=f.useState(""),[p,x]=f.useState(""),[g,w]=f.useState(""),[v,b]=f.useState("");f.useEffect(()=>{let F=!0;return Be("/api/settings/agent",void 0,n).then(ue=>{F&&(c(ue.settings),i(Xx(ue.settings)))}).catch(ue=>{F&&b(ue instanceof Error?ue.message:String(ue))}),()=>{F=!1}},[n]);const k=(F,ue)=>i(W=>({...W,[F]:ue})),j=F=>{c(F),i(Xx(F))},M=async()=>{x("save"),b(""),w("");try{const F={...a};d.trim()&&(F.apiKey=d.trim());const ue=await Be("/api/settings/agent",{method:"PUT",body:JSON.stringify(F)},n);j(ue.settings),h(""),w("Agent settings saved.")}catch(F){b(F instanceof Error?F.message:String(F))}finally{x("")}},T=async()=>{x("reset"),b("");try{const F=await Be("/api/settings/agent/reset",{method:"POST",body:JSON.stringify({})},n);j(F.settings),w("Codex defaults restored.")}catch(F){b(F instanceof Error?F.message:String(F))}finally{x("")}},C=async()=>{x("test"),b(""),w("");try{const F=await Be("/api/settings/agent/test",{method:"POST",body:JSON.stringify({})},n),ue=await Be("/api/settings/agent",void 0,n);j(ue.settings),w(`Codex connection verified with ${F.connection?.modelName||"the configured model"}${F.connection?.latencyMs?` in ${F.connection.latencyMs} ms.`:"."}`)}catch(F){b(F instanceof Error?F.message:String(F))}finally{x("")}},A=async()=>{x("clear-key"),b("");try{const F=await Be("/api/settings/agent/api-key",{method:"DELETE"},n);j(F.settings),h(""),w("The optional OpenCode Go key was removed.")}catch(F){b(F instanceof Error?F.message:String(F))}finally{x("")}},D=r?.codexInstallation==="installed"&&r.codexAuth==="signed-in",H=r?.securityStatus,B=H?.state||"unavailable",q=B==="verified"?"Verified":B==="configured"?"Configured":"Unavailable",L=[["Codex home",H?.isolatedCodexHome],["Environment variables",H?.restrictedEnvironment],["LiveDesk MCP only",H?.livedeskMcpOnly],["Selected-device scope",H?.selectedDeviceScopeEnforced],["Fail-closed execution",H?.failClosed]];return l.jsxs("div",{className:"settings-tab-content agent-settings-content",children:[l.jsxs("header",{className:"agent-settings-header",children:[l.jsxs("div",{children:[l.jsxs("span",{className:"settings-eyebrow",children:[l.jsx(jx,{size:14})," Agent AI"]}),l.jsx("h2",{children:"Codex SDK"}),l.jsx("p",{children:"Codex owns the agent reasoning loop. LiveDesk keeps the existing task manager and exposes only safe, read-only workstation tools."})]}),l.jsxs("label",{className:"settings-toggle agent-enable-toggle",children:[l.jsx("input",{type:"checkbox",checked:a.enabled,onChange:F=>k("enabled",F.target.checked)}),l.jsx("span",{children:"Enable Agent AI"})]})]}),v&&l.jsx("div",{className:"agent-settings-alert error",role:"alert",children:v}),g&&l.jsx("div",{className:"agent-settings-alert success",role:"status",children:g}),l.jsxs("div",{className:"settings-section-grid",children:[l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Provider"}),l.jsx("h3",{children:"Codex is the default"})]}),l.jsx(ec,{size:20})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Agent provider"}),l.jsxs("select",{value:a.provider,onChange:F=>k("provider",F.target.value),children:[l.jsx("option",{value:"codex",children:"Codex SDK"}),l.jsx("option",{value:"opencode-go",children:"OpenCode Go (optional legacy)"})]})]}),l.jsxs("div",{className:"agent-connection-row",children:[l.jsx("span",{className:`agent-connection-dot ${D?"connected":r?.codexAuth==="not-signed-in"?"unavailable":""}`}),l.jsx("span",{children:r?.codexInstallation==="not-installed"?"Codex SDK not installed":r?.codexAuth==="signed-in"?"Codex CLI signed in":r?.codexAuth==="not-signed-in"?"Codex CLI sign-in required":"Codex status not tested"}),l.jsxs("button",{className:"settings-reset",onClick:()=>{C()},disabled:p!==""||a.provider!=="codex",type:"button",children:[l.jsx(Fb,{size:15})," ",p==="test"?"Testing":"Test connection"]})]}),l.jsxs("p",{className:"settings-help",children:[l.jsx(Hb,{size:12})," Authentication is owned by the installed Codex CLI. LiveDesk never asks for or stores a ChatGPT token."]}),r?.codexPath&&l.jsxs("p",{className:"settings-help",children:["CLI: ",r.codexPath]})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Codex runtime"}),l.jsx("h3",{children:"Model and reasoning"})]}),l.jsx(jx,{size:20})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Model"}),l.jsx("input",{value:a.codexModelId,onChange:F=>k("codexModelId",F.target.value),placeholder:"Codex default",disabled:a.provider!=="codex"})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Reasoning effort"}),l.jsxs("select",{value:a.codexReasoningEffort,onChange:F=>k("codexReasoningEffort",F.target.value),disabled:a.provider!=="codex",children:[l.jsx("option",{value:"minimal",children:"Minimal"}),l.jsx("option",{value:"low",children:"Low"}),l.jsx("option",{value:"medium",children:"Medium"}),l.jsx("option",{value:"high",children:"High"}),l.jsx("option",{value:"xhigh",children:"Extra high"})]})]}),l.jsxs("div",{className:"settings-field-grid",children:[l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Task timeout (ms)"}),l.jsx("input",{type:"number",min:"30000",max:"1800000",step:"10000",value:a.codexTaskTimeoutMs,onChange:F=>k("codexTaskTimeoutMs",Number(F.target.value)),disabled:a.provider!=="codex"})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Max tool calls"}),l.jsx("input",{type:"number",min:"1",max:"100",value:a.codexMaxToolCalls,onChange:F=>k("codexMaxToolCalls",Number(F.target.value)),disabled:a.provider!=="codex"})]})]})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Workspace"}),l.jsx("h3",{children:"Restricted execution context"})]}),l.jsx(Sn,{size:20})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Working directory"}),l.jsx("input",{value:r?.agentWorkspacePath||a.codexWorkingDirectory,readOnly:!0})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:a.codexResumeSessions,onChange:F=>k("codexResumeSessions",F.target.checked),disabled:a.provider!=="codex"}),l.jsx("span",{children:"Allow session resume"})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:a.codexShowDetailedEvents,onChange:F=>k("codexShowDetailedEvents",F.target.checked),disabled:a.provider!=="codex"}),l.jsx("span",{children:"Show detailed Codex events"})]}),l.jsx("p",{className:"settings-help",children:"The agent receives no project path or arbitrary filesystem directory. It can call LiveDesk MCP tools only."})]})]}),a.provider==="opencode-go"&&l.jsxs("section",{className:"settings-section-card agent-legacy-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Developer fallback"}),l.jsx("h3",{children:"OpenCode Go"})]}),l.jsx(ec,{size:20})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Base URL"}),l.jsx("input",{value:a.baseUrl,onChange:F=>k("baseUrl",F.target.value)})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"API key"}),l.jsx("input",{type:"password",value:d,onChange:F=>h(F.target.value),placeholder:r?.hasApiKey?r.apiKeyPreview:"Stored only in the Hub",autoComplete:"new-password"})]}),l.jsxs("div",{className:"settings-action-row",children:[l.jsxs("button",{className:"settings-reset",onClick:()=>{A()},disabled:p!==""||!r?.hasApiKey,type:"button",children:[l.jsx(hh,{size:15})," Clear key"]}),l.jsx("span",{className:"settings-help",children:"This provider does not run the Codex MCP tool loop."})]})]}),l.jsxs("div",{className:"settings-section-grid",children:[l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Agent behavior"}),l.jsx("h3",{children:"Predictable operation"})]}),l.jsx(qn,{size:20})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:a.deterministicParserFirst,onChange:F=>k("deterministicParserFirst",F.target.checked)}),l.jsx("span",{children:"Use deterministic parser before Codex"})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:a.generateSummary,onChange:F=>k("generateSummary",F.target.checked)}),l.jsx("span",{children:"Generate task summaries"})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:a.fallbackSummary,onChange:F=>k("fallbackSummary",F.target.checked)}),l.jsx("span",{children:"Fallback to deterministic summaries"})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:a.includeRawDeviceDetails,onChange:F=>k("includeRawDeviceDetails",F.target.checked)}),l.jsx("span",{children:"Include raw device details in summaries"})]})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Safety"}),l.jsx("h3",{children:"Locked execution boundary"})]}),l.jsx(Sn,{size:20})]}),["Arbitrary shell commands","PowerShell and Bash","Filesystem writes, deletes, and installs","Reboot, shutdown, and process termination","Network access and web search"].map(F=>l.jsxs("div",{className:"agent-safety-row",children:[l.jsx($b,{size:15}),l.jsx("span",{children:F}),l.jsx("strong",{children:"Blocked"})]},F)),L.map(([F])=>l.jsxs("div",{className:"agent-safety-row",children:[l.jsx(Sn,{size:15}),l.jsx("span",{children:F}),l.jsx("strong",{className:B==="unavailable"?"agent-safety-failed":B==="configured"?"agent-safety-configured":"agent-safety-verified",children:q})]},F)),l.jsx("p",{className:"settings-help",children:"Configured means the boundary is present but has not completed runtime verification. Test the connection or start an Agent run to verify it."})]})]}),l.jsxs("div",{className:"settings-action-row agent-settings-actions",children:[l.jsxs("button",{className:"settings-reset",onClick:()=>{T()},disabled:p!=="",type:"button",children:[l.jsx(tc,{size:15})," Reset defaults"]}),l.jsxs("button",{className:"text-button primary",onClick:()=>{M()},disabled:p!=="",type:"button",children:[l.jsx(ny,{size:15})," ",p==="save"?"Saving":"Save Agent settings"]})]})]})}new Date().valueOf();function Ls(n){const[a,i]=f.useState(n),r=f.useRef(n);return f.useEffect(()=>{if(r.current!==n){if(Array.isArray(r.current)&&Array.isArray(n)&&r.current.length===0&&n.length===0)return;r.current=n,i(n)}},[n]),[a,i]}function wh(n,a){return typeof n=="function"?typeof a=="object"?n(a):n():n}function $r(n,a="data-id"){let i=n;for(!i.tagName&&n.target&&(i=n.target);i;){if(i.getAttribute&&i.getAttribute(a))return i;i=i.parentNode}return null}function H0(n,a="data-id"){const i=$r(n,a);return i?i.getAttribute(a):null}function mc(n,a="data-id"){const i=$r(n,a);return i?Sd(i,a):null}function Sd(n,a="data-id"){const i=n.getAttribute(a);return i?$0(i):null}function Cn(n){return typeof n=="string"?":"+n:n}function $0(n){if(n.startsWith(":"))return n.substring(1);const a=n*1;return isNaN(a)?n:a}function U0(){return{detect:()=>!0,addEvent:function(n,a,i){return n.addEventListener(a,i),()=>n.removeEventListener(a,i)},addGlobalEvent:function(n,a){return document.addEventListener(n,a),()=>document.removeEventListener(n,a)},getTopNode:function(){return window.document.body}}}var va=U0();function bh(n){Object.assign(va,n)}function Zx(n,a,i){function r(c){const d=$r(c);if(!d)return;const h=Sd(d);if(typeof a=="function")return a(h,c);let p,x=c.target;for(;x!=d;){if(p=x.dataset?x.dataset.action:null,p&&a[p]){a[p](h,c);return}x=x.parentNode}a[i]&&a[i](h,c)}va.addEvent(n,i,r)}function Ur(n,a){Zx(n,a,"click"),a.dblclick&&Zx(n,a.dblclick,"dblclick")}function P0(n,a){for(let i=n.length-1;i>=0;i--)if(n[i]===a){n.splice(i,1);break}}function q0(n,a,i){for(let r=0;r<hl.length;r++){if(r===i)continue;const c=hl[r],d=c.props.parent?.();if(d&&n.contains(d)&&c.node.contains(a))return!0}return!1}var by=new Date,pd=!1,Hu=[],hl=[],Jx=n=>{const a=n.target;if(pd||!a.isConnected){pd=!1;return}for(let i=hl.length-1;i>=0;i--){const{node:r,date:c,props:d}=hl[i];if(!(c>by)&&!r.contains(a)&&r!==a&&(q0(r,a,i)||(d.callback&&d.callback(n),d.modal||n.defaultPrevented)))break}},G0=n=>{by=new Date,pd=!0;for(let a=hl.length-1;a>=0;a--){const{node:i}=hl[a];if(!i.contains(n.target)&&i!==n.target){pd=!1;break}}};function zs(n,a){Hu.length||(Hu=[va.addGlobalEvent("click",Jx,n),va.addGlobalEvent("contextmenu",Jx,n),va.addGlobalEvent("mousedown",G0,n)]),typeof a!="object"&&(a={callback:a});const i={node:n,date:new Date,props:a};return hl.push(i),{destroy(){P0(hl,i),hl.length||(Hu.forEach(r=>r()),Hu=[])}}}var $u=n=>n.indexOf("bottom")!==-1,Uu=n=>n.indexOf("left")!==-1,Pu=n=>n.indexOf("right")!==-1,km=n=>n.indexOf("top")!==-1,ev=n=>n.indexOf("fit")!==-1,Go=n=>n.indexOf("overlap")!==-1,Y0=n=>n.split("-").every(a=>["center","fit"].indexOf(a)>-1),V0=n=>{const a=n.match(/(start|center|end)/);return a?a[0]:null};function K0(n,a){let i=0;const r=va.getTopNode(n);for(;n&&n!==r;){const c=getComputedStyle(n).position;if((c==="absolute"||c==="relative"||c==="fixed")&&(i=parseInt(getComputedStyle(n).zIndex)||0),n=n.parentNode,n===a)break}return i}var fn,_n,Yo,Dn;function Sy(n,a,i="bottom",r=0,c=0){if(!n)return null;fn=r,_n=c,Yo="auto";let d=0,h=0,p=i;const x=Cy(n),g=Go(i)?va.getTopNode(n):x;if(!x)return null;const w=x.getBoundingClientRect(),v=n.getBoundingClientRect(),b=g.getBoundingClientRect(),k=window.getComputedStyle(g),j={left:0,top:0,bottom:0,right:0};for(const H in j){const B=`border-${H}-width`;j[H]=parseFloat(k.getPropertyValue(B))}if(a){const H=K0(a,x);d=Math.max(H+1,20)}if(a){if(Dn=a.getBoundingClientRect(),ev(i)&&(Yo=Dn.width+"px"),i!=="point")if(Y0(i))ev(i)?fn=0:(fn=b.width/2,h=1),_n=(b.height-v.height)/2;else{const H=Go(i)?0:1;fn=Pu(i)?Dn.right+H:Dn.left-H,_n=$u(i)?Dn.bottom+1:Dn.top;const B=V0(i);B&&(Pu(i)||Uu(i)?B==="center"?_n-=(v.height-Dn.height)/2:B==="end"&&(_n-=v.height-Dn.height):($u(i)||km(i))&&(B==="center"?fn-=(v.width-Dn.width)/2:B==="end"&&(fn-=v.width-Dn.width),Go(i)||(fn+=1)))}}else Dn={left:r,right:r,top:c,bottom:c};const M=(Uu(i)||Pu(i))&&($u(i)||km(i));Uu(i)&&(h=2);const T=fn-v.width-b.left;a&&Uu(i)&&!M&&T<0&&(fn=Dn.right,h=0,p=p.replace("left","right"));const C=fn+v.width*(1-h/2)-b.right;if(C>0)if(!Pu(i))fn=b.right-j.right-v.width;else{const H=Dn.left-b.x-v.width;a&&!M&&H>=0?(fn=Dn.left-v.width,p=p.replace("right","left")):fn-=C+j.right}h&&(fn=Math.round(fn-v.width*h/2));const A=T<0||C>0||!M;km(i)&&(_n=Dn.top-v.height,a&&_n<b.y&&A&&(_n=Dn.bottom,p=p.replace("top","bottom")));const D=_n+v.height-b.bottom;return D>0&&(a&&$u(i)&&A?(_n-=v.height+Dn.height+1,p=p.replace("bottom","top")):_n-=D+j.bottom),fn-=w.left+j.left,_n-=w.top+j.top,fn=(Go(i)?fn:Math.max(fn,0))+g.scrollLeft,_n=(Go(i)?_n:Math.max(_n,0))+g.scrollTop,Yo=Yo||"auto",{at:p,x:fn,y:_n,z:d,width:Yo}}function Cy(n){const a=va.getTopNode(n);for(n&&(n=n.parentElement);n;){const i=getComputedStyle(n).position;if(n===a||i==="relative"||i==="absolute"||i==="fixed")return n;n=n.parentNode}return null}function W0(n){const a=[];let i=n;const r=va.getTopNode(n);for(;i&&i!==r&&!i.getAttribute("data-wx-portal-root");)getComputedStyle(i).position==="absolute"&&a.push(i),i=i.parentNode;return a}var tv=new Date().valueOf();function Sh(){return tv+=1,tv}function In(n){return n<10?"0"+n:n.toString()}function Q0(n){const a=In(n);return a.length==2?"0"+a:a}function jy(n){const a=Math.floor(n/11)*11;return{start:a,end:a+11}}function Mm(n){const a=(n.getDay()+6)%7,i=new Date(n.valueOf());i.setDate(n.getDate()+(3-a)),i.setHours(0,0,0,0);const r=new Date(i.getFullYear(),0,1),c=Math.round((i.getTime()-r.getTime())/864e5);return 1+Math.floor(c/7)}var nv=["",""];function X0(n,a,i){switch(n){case"%d":return In(a.getDate());case"%m":return In(a.getMonth()+1);case"%j":return a.getDate();case"%n":return a.getMonth()+1;case"%y":return In(a.getFullYear()%100);case"%Y":return a.getFullYear();case"%D":return i.dayShort[a.getDay()];case"%l":return i.dayFull[a.getDay()];case"%M":return i.monthShort[a.getMonth()];case"%F":return i.monthFull[a.getMonth()];case"%h":return In((a.getHours()+11)%12+1);case"%g":return(a.getHours()+11)%12+1;case"%G":return a.getHours();case"%H":return In(a.getHours());case"%i":return In(a.getMinutes());case"%a":return((a.getHours()>11?i.pm:i.am)||nv)[0];case"%A":return((a.getHours()>11?i.pm:i.am)||nv)[1];case"%s":return In(a.getSeconds());case"%S":return Q0(a.getMilliseconds());case"%W":return In(Mm(a));case"%w":{const r=i.weekStart??1;if(r===1)return In(Mm(a));const c=(a.getDay()-r+7)%7,d=(1-r+7)%7,h=new Date(a.valueOf());return h.setDate(a.getDate()+(d-c)),In(Mm(h))}case"%c":{let r=a.getFullYear()+"";return r+="-"+In(a.getMonth()+1),r+="-"+In(a.getDate()),r+="T",r+=In(a.getHours()),r+=":"+In(a.getMinutes()),r+=":"+In(a.getSeconds()),r}case"%Q":return Math.floor(a.getMonth()/3)+1;default:return n}}var Z0=/%[a-zA-Z]/g;function Ir(n,a){return typeof n=="function"?n:function(i){return i?(i.getMonth||(i=new Date(i)),n.replace(Z0,r=>X0(r,i,a))):""}}function av(n){return n&&typeof n=="object"&&!Array.isArray(n)}function th(n,a){for(const i in a){const r=a[i];av(n[i])&&av(r)?n[i]=th({...n[i]},a[i]):n[i]=a[i]}return n}function gc(n){return{getGroup(a){const i=n[a];return r=>i&&i[r]||r},getRaw(){return n},extend(a,i){if(!a)return this;let r;return i?r=th({...a},n):r=th({...n},a),gc(r)}}}var J0=oy();const e1="en-US",t1={monthFull:["January","February","March","April","May","June","July","August","September","October","November","December"],monthShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayFull:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],hours:"Hours",minutes:"Minutes",done:"Done",clear:"Clear",today:"Today",am:["am","AM"],pm:["pm","PM"],weekStart:0,clockFormat:24},n1={ok:"OK",cancel:"Cancel",select:"Select","No data":"No data","Rows per page":"Rows per page","Total pages":"Total pages"},a1={timeFormat:"%H:%i",dateFormat:"%m/%d/%Y",monthYearFormat:"%F %Y",yearFormat:"%Y"},ky={core:n1,calendar:t1,formats:a1,lang:e1},Ch=f.createContext(""),My=f.createContext({}),bs=f.createContext(null),Ay=f.createContext(null),kn=Object.freeze(Object.defineProperty({__proto__:null,fieldId:Ay,helpers:My,i18n:bs,theme:Ch},Symbol.toStringTag,{value:"Module"}));function Ny(n){const a=f.useContext(Ay),[i]=f.useState(()=>n||a||Sh());return i}function ic({type:n="",css:a="",icon:i="",disabled:r=!1,title:c="",tooltip:d,text:h="",children:p,onClick:x}){const g=f.useMemo(()=>{let v=n?n.split(" ").filter(b=>b!=="").map(b=>"wx-"+b).join(" "):"";return a+(a?" ":"")+v},[n,a]),w=v=>{x&&x(v)};return l.jsxs("button",{title:c,className:`wx-2ZWgb4 wx-button ${g} ${i&&!p?"wx-icon":""}`,disabled:r,onClick:w,"data-tooltip-text":d,children:[i&&l.jsx("i",{className:"wx-2ZWgb4 "+i}),p||h||" "]})}function s1({id:n,label:a="",inputValue:i="",value:r=!1,onChange:c,disabled:d=!1,css:h=""}){const p=Ny(n),[x,g]=Ls(r),w=({target:v})=>{const b=v.checked;g(b),c&&c({value:b,inputValue:i})};return l.jsxs("div",{className:`wx-2IvefP wx-checkbox ${h}`,children:[l.jsx("input",{type:"checkbox",id:p,disabled:d,className:"wx-2IvefP wx-check",checked:x,value:i,onChange:w}),l.jsxs("label",{htmlFor:p,className:"wx-2IvefP wx-label",children:[l.jsx("span",{className:"wx-2IvefP wx-before"}),a&&l.jsx("span",{className:"wx-2IvefP wx-after",children:a})]})]})}function jh({theme:n="",target:a,children:i}){const r=f.useRef(null),c=f.useRef(null),[d,h]=f.useState(null);r.current||(r.current=document.createElement("div"));const p=f.useContext(Ch);return f.useEffect(()=>{h(a||l1(c.current)||va.getTopNode(c.current))},[c.current]),l.jsxs(l.Fragment,{children:[l.jsx("span",{ref:c,style:{display:"none"}}),c.current&&d?J0.createPortal(l.jsx("div",{className:`wx-3ZWsT0 wx-${n||p}-theme`,children:i}),d):null]})}function l1(n){const a=va.getTopNode(n);for(;n&&n!==a&&!n.getAttribute("data-wx-portal-root");)n=n.parentNode;return n}function i1({left:n=0,top:a=0,at:i="bottom",parent:r=null,width:c="auto",css:d="",onCancel:h,children:p,trackScroll:x=!1}){const[g,w]=f.useState(0),[v,b]=f.useState(0),[k,j]=f.useState("auto"),[M,T]=f.useState(!1),C=f.useRef(null),A=f.useRef(null),D=f.useRef(h);f.useEffect(()=>{D.current=h},[h]);function H(q){return r&&(c+"").indexOf("%")>-1?c.replace(/(\d+)%/,(L,F)=>(F=F*r.offsetWidth/100+"px",c.replace(L,F))):c&&c!=="auto"?c:q}const B=f.useCallback(()=>{if(!C.current)return;const q=Sy(C.current,r,i,n,a);q&&(w(q.x),b(q.y),j(H(q.width)))},[C,r,i,n,a,c]);return f.useLayoutEffect(()=>{const q=F=>{D.current&&F.target!==A.current&&C.current&&!C.current.contains(F.target)&&D.current(F)};let L;return requestAnimationFrame(()=>{B(),T(!0),x&&C.current&&(A.current=Cy(C.current),A.current&&A.current.addEventListener("scroll",q,!0)),r&&(L=new ResizeObserver(B),L.observe(r))}),()=>{x&&A.current&&A.current.removeEventListener("scroll",q,!0),L?.disconnect()}},[]),f.useLayoutEffect(()=>{B()},[r,i,n,a]),f.useEffect(()=>{const q=L=>{D.current&&D.current(L)};if(C.current)return zs(C.current,{callback:q,parent:()=>r}).destroy},[r]),l.jsx("div",{ref:C,className:["wx-37M6Fj","wx-popup",d].filter(Boolean).join(" "),style:{position:"absolute",visibility:M?"visible":"hidden",top:v+"px",left:g+"px",width:k},children:p})}function r1({position:n="bottom",align:a="start",autoFit:i=!0,onCancel:r=null,width:c="100%",css:d="",children:h}){const p=f.useRef(null),[x,g]=f.useState(n),[w,v]=f.useState(a),b=f.useRef(r);return f.useEffect(()=>{b.current=r},[r]),f.useEffect(()=>{if(i){const k=p.current;if(k){const j=k.getBoundingClientRect(),M=document.body.getBoundingClientRect();j.right>=M.right&&v("end"),j.bottom>=M.bottom&&g("top")}}},[]),f.useEffect(()=>{if(p.current){const k=j=>{b.current&&b.current(j)};return zs(p.current,k).destroy}},[]),l.jsx("div",{ref:p,className:["wx-dropdown",`wx-${x}-${w}`,d||"","wx-aaaVytZW"].filter(Boolean).join(" "),style:{width:c},children:h})}function kh({position:n="bottom",align:a="start",autoFit:i=!0,inline:r=!1,onCancel:c,width:d="100%",children:h,...p}){const[x,g]=f.useState(void 0),w=f.useRef(null),v=f.useMemo(()=>`${n}-${a}`,[n,a]);return f.useLayoutEffect(()=>{w.current&&g(w.current.parentNode)},[]),l.jsxs(l.Fragment,{children:[x&&(r?l.jsx(r1,{onCancel:c,position:n,align:a,autoFit:i,width:d,...p,children:h}):l.jsx(jh,{children:l.jsx(i1,{parent:x,at:v,onCancel:c,width:d,...p,children:h})})),l.jsx("span",{ref:w,className:"wx-portal-node wx-32GZ52"})]})}function Cd(){return gc(ky)}function o1(){let n=null,a=!1,i=!1,r,c,d,h;const p=(v,b,k,j,M)=>{r=v,c=b,d=k,h=j,i=M},x=v=>{n=v,a=n!==null,d(n)},g=(v,b)=>{if(!i&&v!==null&&r){const k=r.querySelectorAll(".wx-list > .wx-item")[v];k&&(k.scrollIntoView({block:"nearest"}),b&&b.preventDefault())}},w=(v,b)=>{const k=v===null?null:Math.max(0,Math.min(n+v,c.length-1));k!==n&&(x(k),r?g(k,b):requestAnimationFrame(()=>g(k,b)))};return{move:v=>{const b=mc(v),k=c.findIndex(j=>j.id===b);k!==n&&x(k)},keydown:(v,b)=>{switch(v.code){case"Enter":a?h():x(0);break;case"Space":a||x(0);break;case"Escape":d(n=null);break;case"Tab":d(n=null);break;case"ArrowDown":w(a?1:b||0,v);break;case"ArrowUp":w(a?-1:b||0,v);break}},init:p,navigate:w}}const sv=10,c1=f.memo(function({data:n,checkboxes:a,itemTemplate:i,value:r}){return l.jsxs(l.Fragment,{children:[a&&l.jsx(s1,{id:n.id,css:"wx-list-checkbox",value:r&&r.includes(n.id)}),i?wh(i,{option:n}):n.label]})});function lv({visibleItems:n,visibleRange:a,navIndex:i,checkboxes:r,itemTemplate:c,value:d,measureRefCallback:h}){return n.map((p,x)=>{const g=a.start+x;return l.jsx("div",{ref:x===0?h:void 0,className:`wx-233fr7 wx-item ${g===i?"wx-focus":""}`,"data-id":p.id,children:l.jsx(c1,{data:p,checkboxes:r,itemTemplate:c,value:d})},p.id)})}function jd({items:n=[],children:a,onSelect:i,onReady:r,virtualized:c=!1,checkboxes:d,multiselect:h,value:p,...x}){const g=f.useRef(),w=f.useRef(!1),v=f.useRef(o1()),[b,k]=f.useState(null),j=f.useRef(b),[M,T]=f.useState(0),[C,A]=f.useState(24),D=f.useRef(!1),H=(f.useContext(bs)||Cd()).getGroup("core"),B=f.useRef(n);f.useEffect(()=>{B.current=n},[n]);const q=f.useRef(p);f.useEffect(()=>{q.current=p},[p]);const L=f.useRef(0);f.useEffect(()=>{L.current=C},[C]);const F=f.useCallback($=>{$&&$.stopPropagation();const ie=B.current,we=q.current,me=j.current;let ze;const Pe=ie[me]?.id;h?we&&we.includes(Pe)?ze=we.filter(de=>de!==Pe):ze=[...we||[],Pe]:ze=Pe,i&&i({id:ze})},[h,i]),ue=f.useRef(F);f.useEffect(()=>{ue.current=F},[F]);const W=f.useCallback($=>{if(g.current){let ie=$*L.current-g.current.clientHeight+L.current;T(ie),g.current.scrollTop=ie}},[L.current]),ce=f.useCallback($=>{g.current=$,c&&($&&!w.current&&j.current!==null&&requestAnimationFrame(()=>{g.current&&(W(j.current),w.current=!0)}),$||(w.current=!1))},[W]),Q=f.useCallback($=>{if(!$||D.current)return;const ie=$.getBoundingClientRect().height;ie&&(A(ie),L.current=ie,D.current=!0)},[]);f.useEffect(()=>{v.current.init(g.current,n,$=>{k($),j.current=$},$=>ue.current($),c)},[n,g.current,c]),f.useEffect(()=>{const $=(we,me)=>{v.current.navigate(we,me),W(j.current)},ie=(we,me)=>{const ze=j.current,Pe=B.current;if(ze!==0&&ze!==Pe.length-1&&(we.key==="ArrowDown"||we.key==="ArrowUp")&&we.preventDefault(),v.current.keydown(we,me),g.current){const de=g.current.scrollTop<=j.current*L.current,He=g.current.scrollTop+g.current.clientHeight>=j.current*L.current+L.current;de?He||W(j.current):(g.current.scrollTop=j.current*L.current,T(g.current.scrollTop))}};r&&r({navigate:c?$:v.current.navigate,keydown:c?ie:v.current.keydown,move:v.current.move})},[]);const se=f.useRef(0),oe=f.useRef(n);oe.current!==n&&(oe.current=n,se.current+=1);const K=f.useCallback(()=>{v.current.navigate(null)},[v]),z=f.useCallback($=>{c&&T($.target.scrollTop)},[c]),Y=f.useMemo(()=>Math.ceil((g.current?.clientHeight||0)/C),[C,M]),U=f.useMemo(()=>{if(!c)return{start:0,end:n.length};if(!n.length)return{start:0,end:0};const $=Math.floor(M/C),ie=$+Y;return{start:Math.max(0,$-sv),end:Math.min(n.length,ie+sv)}},[c,n,M,C,Y]),R=f.useMemo(()=>{if(!c)return n;const{start:$,end:ie}=U;return n.slice($,ie).map(we=>({...we}))},[c,n,U]),J=U.start*C,he=n.length*C;return f.useEffect(()=>{c&&T(0)},[n,c]),f.useEffect(()=>{b===null&&(w.current=!1)},[b]),b===null?null:l.jsx(kh,{onCancel:K,...x,children:l.jsx("div",{className:"wx-233fr7 wx-list",ref:ce,onClick:F,onMouseMove:v.current.move,onScroll:z,children:n.length?c?l.jsx("div",{className:"wx-233fr7 wx-list-wrapper",style:{height:`${he}px`},children:l.jsx("div",{className:"wx-233fr7 wx-list-content",style:{transform:`translateY(${J}px)`},children:l.jsx(lv,{visibleRange:U,visibleItems:R,navIndex:b,measureRefCallback:Q,checkboxes:d,itemTemplate:a,value:p})})}):l.jsx(lv,{visibleRange:U,visibleItems:R,navIndex:b,measureRefCallback:Q,checkboxes:d,itemTemplate:a,value:p}):l.jsx("div",{className:"wx-233fr7 wx-no-data",children:H("No data")})})},se.current)}function Mh({value:n="",id:a,readonly:i=!1,focus:r=!1,select:c=!1,type:d="text",placeholder:h="",disabled:p=!1,error:x=!1,title:g="",tooltip:w,css:v="",icon:b="",clear:k=!1,onChange:j}){const M=Ny(a),[T,C]=Ls(n),A=f.useRef(null),D=f.useMemo(()=>b&&v.indexOf("wx-icon-left")===-1?"wx-icon-right "+v:v,[b,v]),H=f.useMemo(()=>b&&v.indexOf("wx-icon-left")!==-1,[b,v]);f.useEffect(()=>{const ue=setTimeout(()=>{r&&A.current&&A.current.focus(),c&&A.current&&A.current.select()},1);return()=>clearTimeout(ue)},[r,c]);const B=f.useCallback(ue=>{const W=ue.target.value;C(W),j&&j({value:W,input:!0})},[j]),q=f.useCallback(ue=>j&&j({value:ue.target.value}),[j]);function L(ue){ue.stopPropagation(),C(""),j&&j({value:""})}let F=d;return d!=="password"&&d!=="number"&&(F="text"),f.useEffect(()=>{const ue=q,W=A.current;return W.addEventListener("change",ue),()=>{W&&W.removeEventListener("change",ue)}},[q]),l.jsxs("div",{className:`wx-hQ64J4 wx-text ${D} ${x?"wx-error":""} ${p?"wx-disabled":""} ${k?"wx-clear":""}`,"data-tooltip-text":w,children:[l.jsx("input",{className:"wx-hQ64J4 wx-input",ref:A,id:M,readOnly:i,disabled:p,placeholder:h,type:F,title:g,value:T,onInput:B}),k&&!p&&T?l.jsxs(l.Fragment,{children:[l.jsx("i",{className:"wx-hQ64J4 wx-icon wxi-close",onClick:L}),H&&l.jsx("i",{className:`wx-hQ64J4 wx-icon ${b}`})]}):b?l.jsx("i",{className:`wx-hQ64J4 wx-icon ${b}`}):null]})}function u1({date:n,type:a,part:i,onShift:r}){const{calendar:c,formats:d}=f.useContext(bs).getRaw(),h=n.getFullYear(),p=f.useMemo(()=>{switch(a){case"month":return Ir(d.monthYearFormat,c)(n);case"year":return Ir(d.yearFormat,c)(n);case"duodecade":{const{start:g,end:w}=jy(h),v=Ir(d.yearFormat,c);return`${v(new Date(g,0,1))} - ${v(new Date(w,11,31))}`}default:return""}},[n,a,h,c,d]);function x(){r&&r({diff:0,type:a})}return l.jsxs("div",{className:"wx-8HQVQV wx-header",children:[i!=="right"?l.jsx("i",{className:"wx-8HQVQV wx-pager wxi-angle-left",onClick:()=>r&&r({diff:-1,type:a})}):l.jsx("span",{className:"wx-8HQVQV wx-spacer"}),l.jsx("span",{className:"wx-8HQVQV wx-label",onClick:x,children:p}),i!=="left"?l.jsx("i",{className:"wx-8HQVQV wx-pager wxi-angle-right",onClick:()=>r&&r({diff:1,type:a})}):l.jsx("span",{className:"wx-8HQVQV wx-spacer"})]})}function Ah({onClick:n,children:a}){return l.jsx("button",{className:"wx-3s8W4d wx-button",onClick:n,children:a})}function d1({value:n,current:a,part:i="",markers:r=null,css:c="",onCancel:d,onChange:h}){const p=(f.useContext(bs)||Cd()).getRaw().calendar,x=(p.weekStart||7)%7,g=p.dayShort.slice(x).concat(p.dayShort.slice(0,x)),w=(B,q,L)=>new Date(B.getFullYear(),B.getMonth()+(q||0),B.getDate()+(L||0));let v=i!=="normal";function b(B){const q=B.getDay();return q===0||q===6}function k(){const B=w(a,0,1-a.getDate());return B.setDate(B.getDate()-(B.getDay()-(x-7))%7),B}function j(){const B=w(a,1,-a.getDate());return B.setDate(B.getDate()+(6-B.getDay()+x)%7),B}const M=f.useRef(0);function T(B,q){q.timeStamp!==M.current&&(M.current=q.timeStamp,q.stopPropagation(),h&&h(new Date(B)),d&&d())}const C=f.useMemo(()=>i=="normal"?[n?w(n).valueOf():0]:n?[n.start?w(n.start).valueOf():0,n.end?w(n.end).valueOf():0]:[0,0],[i,n]),A=f.useMemo(()=>{const B=k(),q=j(),L=a.getMonth();let F=[];for(let ue=B;ue<=q;ue.setDate(ue.getDate()+1)){const W={day:ue.getDate(),in:ue.getMonth()===L,date:ue.valueOf()};let ce="";if(ce+=W.in?"":" wx-inactive",ce+=C.indexOf(W.date)>-1?" wx-selected":"",v){const Q=W.date==C[0],se=W.date==C[1];Q&&!se?ce+=" wx-left":se&&!Q&&(ce+=" wx-right"),W.date>C[0]&&W.date<C[1]&&(ce+=" wx-inrange")}if(ce+=b(ue)?" wx-weekend":"",r){const Q=r(ue);Q&&(ce+=" "+Q)}F.push({...W,css:ce})}return F},[a,C,v,r]),D=f.useRef(null);let H=f.useRef({});return H.current.click=T,f.useEffect(()=>{Ur(D.current,H.current)},[]),l.jsxs("div",{className:`wx-398RBS wx-month ${c}`,children:[l.jsx("div",{className:"wx-398RBS wx-weekdays",children:g.map(B=>l.jsx("div",{className:"wx-398RBS wx-weekday",children:B},B))}),l.jsx("div",{className:"wx-398RBS wx-days",ref:D,children:A.map(B=>l.jsx("div",{className:`wx-398RBS wx-day ${B.css} ${B.in?"":"wx-out"}`,"data-id":B.date,children:B.day},B.date))})]})}function f1({value:n,current:a,part:i,onCancel:r,onChange:c,onShift:d}){const h=f.useRef(new Date),[p,x]=Ls(n||h.current),[g,w]=Ls(a||h.current),v=f.useContext(bs).getRaw().calendar,b=v.monthShort||[],k=f.useMemo(()=>g.getMonth(),[g]),j=f.useCallback((C,A)=>{if(C!=null){A.stopPropagation();const D=new Date(g);D.setMonth(C),w(D),d&&d({current:D})}i==="normal"&&x(new Date(g)),r&&r()},[g,i,d,r]),M=f.useCallback(()=>{const C=new Date(Ty(p,i)||g);C.setMonth(g.getMonth()),C.setFullYear(g.getFullYear()),c&&c(C)},[p,g,i,c]),T=f.useCallback(C=>{const A=C.target.closest("[data-id]");if(A){const D=parseInt(A.getAttribute("data-id"),10);j(D,C)}},[j]);return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"wx-34U8T8 wx-months",onClick:T,children:b.map((C,A)=>l.jsx("div",{className:"wx-34U8T8 wx-month"+(k===A?" wx-current":""),"data-id":A,children:C},A))}),l.jsx("div",{className:"wx-34U8T8 wx-buttons",children:l.jsx(Ah,{onClick:M,children:v.done})})]})}const Am="wx-1XEF33",m1=({value:n,current:a,onCancel:i,onChange:r,onShift:c,part:d})=>{const h=f.useContext(bs).getRaw().calendar,[p,x]=Ls(a),[g,w]=Ls(n),v=f.useMemo(()=>p.getFullYear(),[p]),b=f.useMemo(()=>{const{start:C,end:A}=jy(v),D=[];for(let H=C;H<=A;++H)D.push(H);return D},[v]),k={click:j};function j(C,A){if(C){A.stopPropagation();const D=new Date(p);D.setFullYear(C),x(D),c&&c({current:D})}d==="normal"&&w(new Date(p)),i&&i()}function M(){const C=new Date(Ty(g,d)||p);C.setFullYear(p.getFullYear()),r&&r(C)}const T=f.useRef(null);return f.useEffect(()=>{T.current&&Ur(T.current,k)},[]),l.jsxs(l.Fragment,{children:[l.jsx("div",{className:Am+" wx-years",ref:T,children:b.map((C,A)=>l.jsx("div",{className:Am+` wx-year ${v==C?"wx-current":""} ${A===0?"wx-prev-decade":""} ${A===11?"wx-next-decade":""}`,"data-id":C,children:C},A))}),l.jsx("div",{className:Am+" wx-buttons",children:l.jsx(Ah,{onClick:M,children:h.done})})]})},iv={month:{component:d1,next:p1,prev:h1},year:{component:f1,next:x1,prev:g1},duodecade:{component:m1,next:y1,prev:v1}};function h1(n){return n=new Date(n),n.setMonth(n.getMonth()-1),n}function p1(n){return n=new Date(n),n.setMonth(n.getMonth()+1),n}function g1(n){return n=new Date(n),n.setFullYear(n.getFullYear()-1),n}function x1(n){return n=new Date(n),n.setFullYear(n.getFullYear()+1),n}function v1(n){return n=new Date(n),n.setFullYear(n.getFullYear()-10),n}function y1(n){return n=new Date(n),n.setFullYear(n.getFullYear()+10),n}function Ty(n,a){let i;if(a==="normal")i=n;else{const{start:r,end:c}=n;a==="left"?i=r:a=="right"?i=c:i=r&&c}return i}const w1=["clear","today"];function b1(n){if(n==="done")return-1;if(n==="clear")return null;if(n==="today")return new Date}function S1({value:n,current:a,onCurrentChange:i,part:r="normal",markers:c=null,buttons:d,css:h="",onShift:p,onChange:x}){const g=f.useContext(bs).getGroup("calendar"),[w,v]=f.useState("month"),b=Array.isArray(d)?d:d?w1:[],k=(A,D)=>{A.preventDefault(),x&&x({value:D})},j=()=>{w==="duodecade"?v("year"):w==="year"&&v("month")},M=A=>{const{diff:D,current:H}=A;if(D===0){w==="month"?v("year"):w==="year"&&v("duodecade");return}if(D){const B=iv[w];i(D>0?B.next(a):B.prev(a))}else H&&i(H);p&&p()},T=A=>{v("month"),x&&x({select:!0,value:A})},C=f.useMemo(()=>iv[w].component,[w]);return l.jsx("div",{className:`wx-2Gr4AS wx-calendar ${r!=="normal"&&r!=="both"?"wx-part":""} ${h}`,children:l.jsxs("div",{className:"wx-2Gr4AS wx-wrap",children:[l.jsx(u1,{date:a,part:r,type:w,onShift:M}),l.jsxs("div",{children:[l.jsx(C,{value:n,current:a,onCurrentChange:i,part:r,markers:c,onCancel:j,onChange:T,onShift:M}),w==="month"&&b.length>0&&l.jsx("div",{className:"wx-2Gr4AS wx-buttons",children:b.map(A=>l.jsx("div",{className:"wx-2Gr4AS wx-button-item",children:l.jsx(Ah,{onClick:D=>k(D,b1(A)),children:g(A)})},A))})]})]})})}function Nh(n){let{words:a=null,optional:i=!1,children:r}=n,c=f.useContext(bs);const d=f.useMemo(()=>{let h=c;return(!h||!h.extend)&&(h=gc(ky)),a!==null&&(h=h.extend(a,i)),h},[a,i,c]);return l.jsx(bs.Provider,{value:d,children:r})}function rv(n,a,i,r){if(!n||r){const c=a?new Date(a):new Date;c.setDate(1),i(c)}else if(n.getDate()!==1){const c=new Date(n);c.setDate(1),i(c)}}const C1=["clear","today"];function Ry({value:n,current:a,markers:i=null,buttons:r=C1,css:c="",onChange:d}){const[h,p]=Ls(n),[x,g]=Ls(a);f.useEffect(()=>{rv(x,h,g,!1)},[h,x]);const w=f.useCallback(b=>{const k=b.value;k?(p(new Date(k)),rv(x,new Date(k),g,!0)):p(null),d&&d({value:k?new Date(k):null})},[d,x]),v=f.useCallback(b=>{g(b)},[g]);return x?l.jsx(Nh,{children:l.jsx(S1,{value:h,current:x,markers:i,buttons:r,css:c,onChange:w,onCurrentChange:v})}):null}function j1(n){return n||(n={}),n.width||(n.width="unset"),n}const k1=["clear","today"];function M1({value:n,id:a,disabled:i=!1,error:r=!1,placeholder:c="",format:d="",buttons:h=k1,css:p="",title:x="",tooltip:g,editable:w=!1,clear:v=!1,onChange:b,dropdown:k={}}){const{calendar:j,formats:M}=(f.useContext(bs)||Cd()).getRaw(),T=d||M?.dateFormat;let C=typeof T=="function"?T:Ir(T,j);const[A,D]=f.useState(n),[H,B]=f.useState(!1);f.useEffect(()=>{D(n)},[n]);function q(){B(!1)}function L(W){const ce=W===A||W&&A&&W.valueOf()===A.valueOf()||!W&&!A;D(W),ce||b&&b({value:W}),setTimeout(q,1)}const F=f.useMemo(()=>A?C(A):"",[A,C]);function ue({value:W,input:ce}){if(!w&&!v||ce)return;let Q=typeof w=="function"?w(W):W?new Date(W):null;Q=isNaN(Q)?A||null:Q||null,L(Q)}return f.useEffect(()=>{const W=q;return window.addEventListener("scroll",W),()=>window.removeEventListener("scroll",W)},[]),l.jsxs("div",{className:"wx-1lKOFG wx-datepicker",onClick:()=>B(!0),children:[l.jsx(Mh,{css:`wx-date-input ${p}`,title:x,tooltip:g,value:F,id:a,readonly:!w,disabled:i,error:r,placeholder:c,onInput:q,onChange:ue,icon:"wxi-calendar",clear:v}),H&&!i&&l.jsx(kh,{onCancel:q,...j1(k),children:l.jsx(Ry,{buttons:h,value:A,onChange:W=>L(W.value)})})]})}function A1({value:n="",options:a=[],textOptions:i=null,placeholder:r="",disabled:c=!1,error:d=!1,title:h="",tooltip:p,textField:x="label",clear:g=!1,css:w="",children:v,onChange:b,dropdown:k={}}){const j=f.useRef(null),M=f.useRef(null);let[T,C]=Ls(n);function A(L){j.current=L.navigate,M.current=L.keydown}const D=f.useMemo(()=>T||T===0?(i||a).find(L=>L.id===T):null,[T,i,a]),H=f.useCallback(({id:L})=>{(L||L===0)&&(C(L),j.current(null),b&&b({value:L}))},[C,b]),B=f.useCallback(L=>{L.stopPropagation(),C(""),b&&b({value:""})},[C,b]),q=f.useCallback(()=>a.findIndex(L=>L.id===T),[a,T]);return l.jsxs("div",{className:`wx-2YgblL wx-richselect ${w} ${d?"wx-2YgblL wx-error":""} ${c?"wx-2YgblL wx-disabled":""} ${v?"":"wx-2YgblL wx-nowrap"}`,title:h,onClick:()=>j.current(q()),onKeyDown:L=>M.current(L,q()),tabIndex:0,"data-tooltip-text":p,children:[l.jsx("div",{className:"wx-2YgblL wx-label",children:D?v?v(D):D[x]:r?l.jsx("span",{className:"wx-2YgblL wx-placeholder",children:r}):" "}),g&&!c&&T?l.jsx("i",{className:"wx-2YgblL wx-icon wxi-close",onClick:B}):l.jsx("i",{className:"wx-2YgblL wx-icon wxi-angle-down"}),!c&&l.jsx(jd,{items:a,onReady:A,onSelect:H,...k,children:({option:L})=>v?v(L):L[x]})]})}const N1=({options:n=[],value:a="",css:i="",children:r,onChange:c})=>{const[d,h]=f.useState(a),p=x=>{h(x),c&&c({value:x})};return f.useEffect(()=>{h(a)},[a]),l.jsx("div",{className:`wx-0hMO7P wx-segmented ${i}`,children:n.map(x=>l.jsx("button",{className:`wx-0hMO7P wx-segment ${x.css} ${x.id===d?"wx-selected":""}`,title:x.title,onClick:()=>p(x.id),"data-tooltip-text":x.tooltip,children:r?wh(r,{option:x}):l.jsxs(l.Fragment,{children:[x.icon&&l.jsx("i",{className:`wx-0hMO7P wx-icon ${x.icon} ${x.label?"":"wx-only"}`}),x.label&&l.jsx("span",{className:"wx-0hMO7P wx-label",children:x.label})]})},x.id))})};function T1({notice:n={}}){function a(){n.remove&&n.remove()}return l.jsxs("div",{className:`wx-11sNg5 wx-notice wx-${n.type?n.type:""}`,role:"status","aria-live":"polite",children:[l.jsx("div",{className:"wx-11sNg5 wx-text",children:n.text}),l.jsx("div",{className:"wx-11sNg5 wx-button",children:l.jsx("i",{className:"wx-11sNg5 wxi-close",onClick:a})})]})}function R1({data:n=[]}){return l.jsx("div",{className:"wx-3nwoO9 wx-notices",children:n.map(a=>l.jsx(T1,{notice:a},a.id))})}function nh({title:n="",buttons:a=["cancel","ok"],header:i,children:r,footer:c,css:d="",onConfirm:h,onCancel:p}){const x=(f.useContext(bs)||Cd()).getGroup("core"),g=f.useRef(null);f.useEffect(()=>{g.current?.focus()},[]);function w(b){switch(b.code){case"Enter":{const k=b.target.tagName;if(k==="TEXTAREA"||k==="BUTTON")return;h&&h({event:b});break}case"Escape":p&&p({event:b});break}}function v(b,k){const j={event:b,button:k};k==="cancel"?p&&p(j):h&&h(j)}return l.jsx("div",{className:`wx-1FxkZa wx-modal ${d}`,ref:g,tabIndex:0,onKeyDown:w,children:l.jsxs("div",{className:"wx-1FxkZa wx-window",children:[i||(n?l.jsx("div",{className:"wx-1FxkZa wx-header",children:n}):null),l.jsx("div",{children:r}),c||a&&l.jsx("div",{className:"wx-1FxkZa wx-buttons",children:a.map(b=>l.jsx("div",{className:"wx-1FxkZa wx-button",children:l.jsx(ic,{type:`block ${b==="ok"?"primary":"secondary"}`,onClick:k=>v(k,b),children:x(b)})},b))})]})})}function E1({children:n},a){const[i,r]=f.useState(null),[c,d]=f.useState([]);return f.useImperativeHandle(a,()=>({showModal:h=>{const p={...h};return r(p),new Promise((x,g)=>{p.resolve=w=>{r(null),x(w)},p.reject=w=>{r(null),g(w)}})},showNotice:h=>{h={...h},h.id=h.id||Sh(),h.remove=()=>d(p=>p.filter(x=>x.id!==h.id)),h.expire!=-1&&setTimeout(h.remove,h.expire||5100),d(p=>[...p,h])}}),[]),l.jsxs(l.Fragment,{children:[n,i&&l.jsx(nh,{title:i.title,buttons:i.buttons,onConfirm:i.resolve,onCancel:i.reject,children:i.message}),l.jsx(R1,{data:c})]})}const D1=f.forwardRef(E1);function L1(n){let{children:a}=n,i=f.useRef();const r=f.useMemo(()=>({showNotice:c=>i.current.showNotice(c),showModal:c=>i.current.showModal(c)}),[]);return l.jsx(My.Provider,{value:r,children:l.jsx(D1,{ref:i,children:a})})}const z1=({value:n=!1,type:a="",icon:i="",disabled:r=!1,iconActive:c="",onClick:d,title:h="",tooltip:p,css:x="",text:g="",textActive:w="",children:v,active:b,onChange:k})=>{const[j,M]=Ls(n),T=f.useMemo(()=>(j?"pressed":"")+(a?" "+a:""),[j,a]),C=f.useCallback(A=>{let D=!j;d&&d(A),A.defaultPrevented||(M(D),k&&k({value:D}))},[j,d,k]);return j&&b?l.jsx(ic,{title:h,tooltip:p,text:j&&w||g,css:x,type:T,icon:j&&c||i,onClick:C,disabled:r,children:wh(b,{value:j})}):v?l.jsx(ic,{title:h,tooltip:p,text:j&&w||g,css:x,type:T,icon:j&&c||i,onClick:C,disabled:r,children:v}):l.jsx(ic,{title:h,tooltip:p,text:j&&w||g,css:x,type:T,icon:j&&c||i,onClick:C,disabled:r})};function _1(){return l.jsx(l.Fragment,{})}function ov(n){const{fonts:a=!0,children:i}=n;return l.jsx(Ch.Provider,{value:"willow",children:l.jsxs(l.Fragment,{children:[i&&i&&l.jsx("div",{className:"wx-theme wx-willow-theme",children:i}),a&&l.jsxs(l.Fragment,{children:[l.jsx("link",{rel:"preconnect",href:"https://cdn.svar.dev",crossOrigin:"true"}),l.jsx(_1,{}),l.jsx("link",{rel:"stylesheet",href:"https://cdn.svar.dev/fonts/wxi/wx-icons.css"})]})]})})}bh(va);const Th={grid:{"Add before":"Add before","Add after":"Add after",Copy:"Copy",Cut:"Cut",Paste:"Paste",Delete:"Delete","New row":"New row","Move up":"Move up","Move down":"Move down",Undo:"Undo",Redo:"Redo",selected:"selected"}};new Date().valueOf();var Ey=class{constructor(n){this._nextHandler=null,this._dispatch=n,this.exec=this.exec.bind(this)}async exec(n,a){return this._dispatch(n,a),this._nextHandler&&await this._nextHandler.exec(n,a),a}setNext(n){return this._nextHandler=n}};new Date().valueOf();var O1=class{constructor(n){const a={id:0,$level:0,data:[],parent:null},i=new Map;i.set(0,a),this._pool=i,n&&n.length&&this.parse(n,0)}parse(n,a){const i=this._pool;for(let c=0;c<n.length;c++){const d=n[c];d.parent=d.parent||a,d.data=null,i.set(d.id,d)}for(let c=0;c<n.length;c++){const d=n[c],h=i.get(d.parent);h&&(h.data||(h.data=[]),h.data.push(d))}const r=i.get(a);this.setLevel(r,r.$level+1,!1)}add(n,a){const i=this._pool.get(n.parent||0);n.$level=i.$level+1,this._pool.set(n.id,n),i.data?a===-1?i.data=[...i.data,n]:cv(i,a,n):i.data=[n]}addAfter(n,a){if(!a)return this.add(n,-1);const i=this.byId(a),r=this.byId(i.parent),c=qu(r,i.id)+1;n.parent=r.id,n.$level=r.$level+1,this.add(n,c)}remove(n){const a=this._pool.get(n);this._remove(a);const i=this._pool.get(a.parent);i.data=i.data.filter(r=>r.id!=n),this._clearBranch(i)}_remove(n){n.data&&n.data.forEach(a=>this._remove(a)),this._pool.delete(n.id)}update(n,a){let i=this._pool.get(n);const r=this._pool.get(i.parent),c=qu(r,i.id);i={...i,...a},r&&c>=0&&(r.data[c]=i,r.data=[...r.data]),this._pool.set(i.id,i)}move(n,a,i){const r=this._pool.get(n),c=a==="child",d=this._pool.get(i),h=d.$level+(c?1:0);if(!r||!d)return;const p=this._pool.get(r.parent),x=c?d:this._pool.get(d.parent);x.data||(x.data=[]);const g=qu(p,r.id);I1(p,g);const w=c?x.data.length:qu(x,d.id)+(a==="after"?1:0);if(cv(x,w,r),p.id===x.id&&g===w)return null;r.parent=x.id,r.$level!==h&&(r.$level=h,this.setLevel(r,h+1,!0)),this.update(r.id,r),this._clearBranch(p)}_clearBranch(n){n.data&&!n.data.length&&(n.open&&delete n.open,this.update(n.id,{data:null}))}toArray(){const n=[],a=this._pool.get(0).data;return a&&Dy(a,n),n}byId(n){return this._pool.get(n)}getBranch(n){return this._pool.get(n).data}forEach(n){this._pool.forEach((a,i)=>{i!==0&&n(a)})}eachChild(n,a){const i=this.byId(a);!i||!i.data||i.data.forEach((r,c)=>{n(this.byId(r.id),c),this.eachChild(n,r.id)})}setLevel(n,a,i){n.data&&(n.data=n.data.map(r=>(i&&(r={...r},this._pool.set(r.id,r)),r.$level=a,r.data&&this.setLevel(r,a+1,i),r)))}};function Dy(n,a){n.forEach(i=>{a.push(i),i.open===!0&&Dy(i.data,a)})}function I1(n,a){const i=[...n.data];i.splice(a,1),n.data=i}function cv(n,a,i){const r=[...n.data];r.splice(a,0,i),n.data=r}function qu(n,a){return n?.data.findIndex(i=>i.id===a)}var Ly=2,B1=class{constructor(a){a&&(this._writable=a.writable,this._async=a.async),this._values={},this._state={}}setState(a,i=0){const r={};return this._wrapProperties(a,this._state,this._values,"",r,i),r}getState(){return this._values}getReactive(){return this._state}_wrapProperties(a,i,r,c,d,h){for(const p in a){const x=i[p],g=r[p],w=a[p];if(x&&(g===w&&typeof w!="object"||w instanceof Date&&g instanceof Date&&g.getTime()===w.getTime()))continue;const v=c+(c?".":"")+p;x?(x.__parse(w,v,d,h)&&(r[p]=w),h&Ly?d[v]=x.__trigger:x.__trigger()):(w&&w.__reactive?i[p]=this._wrapNested(w,w,v,d):i[p]=this._wrapWritable(w),r[p]=w),d[v]=d[v]||null}}_wrapNested(a,i,r,c){const d=this._wrapWritable(a);return this._wrapProperties(a,d,i,r,c,0),d.__parse=(h,p,x,g)=>(this._wrapProperties(h,d,i,p,x,g),!1),d}_wrapWritable(a){const i=[],r=function(){for(let c=0;c<i.length;c++)i[c](a)};return{subscribe:c=>(i.push(c),this._async?setTimeout(c,1,a):c(a),()=>{const d=i.indexOf(c);d>=0&&i.splice(d,1)}),__trigger:()=>{i.length&&(this._async?setTimeout(r,1):r())},__parse:function(c){return a=c,!0}}}};function uv(n,a){return Object.defineProperty(n,"__reactive",{value:!0,enumerable:!1,writable:!1}),n}var F1=class{constructor(a,i,r,c){typeof a=="function"?this._setter=a:this._setter=a.setState.bind(a),this._routes=i,this._parsers=r,this._prev={},this._triggers=new Map,this._sources=new Map,this._routes.forEach(d=>{d.in.forEach(h=>{const p=this._triggers.get(h)||[];p.push(d),this._triggers.set(h,p)}),d.out.forEach(h=>{const p=this._sources.get(h)||{};d.in.forEach(x=>p[x]=!0),this._sources.set(h,p)})}),this._routes.forEach(d=>{d.length=Math.max(...d.in.map(h=>zy(h,this._sources,1)))}),this._bus=c}init(a){const i={};for(const r in a)if(this._prev[r]!==a[r]){const c=this._parsers[r];i[r]=c?c(a[r]):a[r]}this._prev=this._prev?{...this._prev,...a}:{...a},this.setState(i),this._bus&&this._bus.exec("init-state",i)}setStateAsync(a){const i=this._setter(a,Ly);return this._async?Object.assign(this._async.signals,i):this._async={signals:i,timer:setTimeout(this._applyState.bind(this),1)},i}_applyState(){const a=this._async;if(a){this._async=null,this._triggerUpdates(a.signals,[]);for(const i in a.signals){const r=a.signals[i];r&&r()}}}setState(a,i=[]){const r=this._setter(a);return this._triggerUpdates(r,i),r}_triggerUpdates(a,i){const r=Object.keys(a),c=!i.length;i=i||[];for(let d=0;d<r.length;d++){const h=r[d],p=this._triggers.get(h);p&&p.forEach(x=>{i.indexOf(x)==-1&&i.push(x)})}c&&this._execNext(i)}_execNext(a){for(;a.length;){a.sort((r,c)=>r.length<c.length?1:-1);const i=a[a.length-1];a.splice(a.length-1),i.exec(a)}}};function zy(n,a,i){const r=a.get(n);if(!r)return i;const c=Object.keys(r).map(d=>zy(d,a,i+1));return Math.max(...c)}var H1=class{constructor(){this._nextHandler=null,this._handlers={},this._tag=new WeakMap,this.exec=this.exec.bind(this)}on(a,i,r){let c=this._handlers[a];c?r&&r.intercept?c.unshift(i):c.push(i):c=this._handlers[a]=[i],r&&r.tag&&this._tag.set(i,r.tag)}intercept(a,i,r){this.on(a,i,{...r,intercept:!0})}detach(a){for(const i in this._handlers){const r=this._handlers[i];for(let c=r.length-1;c>=0;c--)this._tag.get(r[c])===a&&r.splice(c,1)}}async exec(a,i){const r=this._handlers[a];if(r)for(let c=0;c<r.length;c++){const d=r[c](i);if(d===!1||d&&d.then&&await d===!1)return}return this._nextHandler&&await this._nextHandler.exec(a,i),i}setNext(a){return this._nextHandler=a}};const Lr=1024;function hc(n){return n<Lr?`${n} B`:n<Lr**2?`${(n/Lr).toFixed(1)} KB`:n<Lr**3?`${(n/Lr**2).toFixed(1)} MB`:`${(n/Lr**3).toFixed(1)} GB`}function dv(n,a){a||(a={key:"name",order:"asc"});const i=n.filter(h=>h.type==="folder"),r=n.filter(h=>h.type!=="folder"),c=i.sort(fv(a)),d=r.sort(fv(a));return[...c,...d]}function $1(n,a){return typeof n=="string"?n.localeCompare(a,void 0,{numeric:!0}):typeof n=="object"?n.getTime()-a.getTime():(n??0)-(a??0)}function U1(n,a){return typeof n=="string"?-n.localeCompare(a,void 0,{numeric:!0}):typeof a=="object"?a.getTime()-n.getTime():(a??0)-(n??0)}function fv({key:n,order:a}){const i=a==="asc"?$1:U1;return(r,c)=>i(r[n],c[n])}function Rh(n,a){const i=n==="/"?1:n.split("/").length;return i>=a.length?null:a[i].id}function P1(n){return n.length>1?n[n.length-2].id:null}let q1=class extends O1{constructor(a){const i={id:"/",name:"My files",open:!0,$level:1,parent:0,ext:"",type:"folder"};super([i]),this.parse(a,"/")}parse(a,i,r){!a||!a.length||(a.forEach(c=>this.parseId(c,r?i:void 0)),super.parse(a,i))}parseId(a,i){if(a.parent===0)return;const r=a.id,c=r.lastIndexOf("/");if(a.parent=i??(c===0?"/":r.slice(0,c)),a.name=r.slice(c+1),a.type=a.type||"file",a.type!=="folder"){const d=a.name.lastIndexOf("."),h=d!==-1?a.name.slice(d+1):"";a.ext=h!=="new"?h?.toLocaleLowerCase():""}}getParents(a){const i=[];let r=this.byId(a);if(!r)return i;for(;r.id!==0;)i.push(r),r=this.byId(r.parent);return i.reverse()}findFiles(a,i="/"){const r=[],c=a.toLocaleLowerCase();return this.eachChild(d=>{d.name.toLowerCase().indexOf(c)!==-1&&r.push(d)},i),r}add(a,i){const r=this.byId(a.parent||"/"),c=a.data?[...a.data]:null;a.data=null,super.add(a,i??r.data?r.data.length:0),c&&c.forEach(d=>this.add(d))}renameFiles(a,i,r){const c=this.byId(a),d=this.normalizeFile(c,i),h=[];return d.data?.forEach(p=>h.push(this.renameFiles(p.id,d.id,r))),h.length&&(d.data=h),r[a]=d.id,d}copyFiles(a,i,r){const c={};return a.forEach(d=>{const h=this.renameFiles(d,i,c);this.add(h),r&&this.remove(d),c[d]=h.id}),c}moveFiles(a,i){if(this.byId(a[0]).parent!==i)return this.copyFiles(a,i,!0)}serialize(a="/"){const i=[],r=this.byId(a);return r?(r.data?.forEach(c=>{const{id:d,date:h,type:p,size:x,lazy:g}=c,w={id:d,date:h,type:p??"file"};g&&(w.lazy=g),x&&(w.size=x),i.push(w);const v=this.serialize(d);v.length&&i.push(...v)}),i):null}normalizeFile(a,i){const r=a.name,c=r.lastIndexOf("."),d=c!==-1?r.slice(c+1):"",h=d?`.${d}`:"";let p=c!==-1?r.slice(0,c):r,x=i+(i==="/"?"":"/")+p;for(;this.byId(x+h);){const g=".new";x+=g,p+=g}return{...a,id:x+h,name:p+h,parent:i,ext:d.toLocaleLowerCase()}}},G1=class extends B1{in;_router;constructor(a){super({writable:a,async:!1});const i=[];for(let d=0;d<2;d++)i.push({in:["data",`panels.${d}.path`],out:[`panels.${d}._crumbs`],exec:h=>{const{data:p,panels:x}=this.getState(),g=[];g[d]={_crumbs:p.getParents(x[d].path)},this.setState({panels:g},h)}}),i.push({in:["data",`panels.${d}.path`,`panels.${d}._sorts`,"search"],out:[`panels.${d}._files`],exec:h=>{const{data:p,panels:x,search:g}=this.getState();let w;g?w=p.findFiles(g,x[d].path):w=p.byId(x[d].path)?.data||[];const{path:v,_sorts:b}=x[d];w=dv(w,b[v]);const k=[];k[d]={_files:w},this.setState({panels:k},h)}}),i.push({in:["data",`panels.${d}.selected`,`panels.${d}._sorts`],out:[`panels.${d}._selected`],exec:h=>{const{data:p,panels:x}=this.getState(),g=[];x[d].selected.forEach(j=>{const M=p.byId(j);M&&g.push(M)});const{path:w,_sorts:v}=x[d],b=dv(g,v[w]),k=[];k[d]={_selected:b},this.setState({panels:k},h)}});this._router=new F1(super.setState.bind(this),i,{data:d=>new q1(d)});const r=this.in=new H1;r.on("select-file",({id:d,toggle:h,range:p,panel:x,type:g})=>{const{panels:w,activePanel:v}=this.getState();typeof x>"u"&&(x=v),d||(h=p=!1);let b=[...w[x].selected];if(h){const j=b.indexOf(d);j===-1?b.push(d):b.splice(j,1)}else if(p&&w[x]._lastSelected){const j=w[x]._files;let M=j.findIndex(A=>A.id==w[x]._lastSelected),T=j.findIndex(A=>A.id==d);T<M&&([M,T]=[T,M]);const C=j.slice(M,T+1).map(A=>A.id);b=[...new Set([...b,...C])]}else b=d?[d]:[];const k=[];k[x]={selected:b,_lastSelected:d,_selectNavigation:g==="navigation"},this.setState({panels:k})}),r.on("set-path",({id:d,panel:h,selected:p})=>{const{data:x,activePanel:g}=this.getState(),w=x.byId(d);if(w){const v=[];typeof h>"u"&&(h=g),v[h]={path:d},this.setState({panels:v}),r.exec("select-file",{panel:h}),p&&p.forEach(b=>r.exec("select-file",{id:b,panel:h,toggle:!0})),w.lazy&&r.exec("request-data",{id:d})}}),r.on("provide-data",({id:d,data:h})=>{const{mode:p,data:x}=this.getState(),g=x.byId(d);g&&(g.lazy||(g.data=[]),g.lazy=!1,x.parse(h,d,p==="search"),this.setState({data:x}))}),r.on("open-tree-folder",({id:d,mode:h})=>{const{data:p}=this.getState();p.update(d,{open:h}),this.setState({data:p})}),r.on("show-preview",({mode:d})=>{this.setState({preview:d})}),r.on("rename-file",d=>{const{id:h,name:p}=d,{data:x,panels:g}=this.getState(),w=x.byId(h);if(w.name!==p){w.name=p;const v=x.normalizeFile(w,w.parent);d.newId=v.id,v.data=null,x.add(v);let b={[h]:v.id};w.data?.forEach(j=>b={...x.moveFiles([j.id],v.id),...b});const k=g.map(j=>({selected:j.selected,_crumbs:j._crumbs,_lastSelected:j._lastSelected,_sorts:j._sorts}));x.remove(h),this._updatePanels(k,b),this.setState({data:x,panels:k})}}),r.on("create-file",d=>{const{file:h,parent:p}=d,{data:x}=this.getState(),g=x.normalizeFile(h,p);g.type=h.type||"file",d.newId=g.id,x.add(g),this.setState({data:x}),r.exec("select-file",{id:g.id})}),r.on("delete-files",({ids:d})=>{const{data:h,panels:p}=this.getState(),x=p.map(g=>({selected:g.selected,_crumbs:g._crumbs,_lastSelected:g._lastSelected,_sorts:g._sorts}));d.forEach(g=>h.remove(g)),this._updatePanels(x,{}),this.setState({data:h,panels:x})}),r.on("copy-files",d=>{const{ids:h,target:p}=d;if(this._isPlacedIntoSelf(h,p)){console.error("You cannot copy a folder into itself"),d.skipProvider=!0;return}const{data:x,panels:g,activePanel:w}=this.getState(),v=x.copyFiles(h,p);d.newIds=h.map(b=>v[b]),this.setState({data:x}),g[w].path==p&&(r.exec("select-file",{}),h.forEach(b=>{r.exec("select-file",{id:v[b],toggle:!0})}))}),r.on("move-files",d=>{const{ids:h,target:p}=d;if(this._isPlacedIntoSelf(h,p)){console.error("You cannot move a folder into itself"),d.skipProvider=!0;return}const{data:x,panels:g,activePanel:w}=this.getState(),v=x.moveFiles(h,p);if(v){d.newIds=h.map(k=>v[k]);const b=g.map(k=>({selected:k.selected,_crumbs:k._crumbs,_lastSelected:k._lastSelected,_sorts:k._sorts}));this._updatePanels(b,v,!0),this.setState({data:x,panels:b}),g[w].path==p&&(r.exec("select-file",{}),h.forEach(k=>{r.exec("select-file",{id:v[k],toggle:!0})}))}});let c=null;r.on("filter-files",({text:d})=>{if(!d){c&&this.setState({...c});return}r.exec("select-file",{});const{panels:h,mode:p}=this.getState();c||(c={panels:h,mode:p,search:""}),this.setState({mode:"search",search:d})}),r.on("set-mode",({mode:d})=>{const{activePanel:h}=this.getState(),p=[];p[h]={_selectNavigation:!1};const x={mode:d,search:"",panels:p};c=null,this.setState(x)}),r.on("set-active-panel",({panel:d})=>{this.setState({activePanel:d})}),r.on("sort-files",({key:d,order:h,panel:p,path:x})=>{const{activePanel:g,panels:w}=this.getState();p=p??g,x=x??w[p].path;const v=[];v[p]={_sorts:{...w[p]._sorts,[x]:{key:d,order:h}}},this.setState({panels:v})}),this.initOnce()}initOnce(){const a=[];for(let r=0;r<2;r++)a[r]=uv({_crumbs:[],_files:[],_selected:[],_sorts:{},path:"/",selected:[],...a[r]});const i={panels:uv(a),data:[],search:""};this._router.init(i)}init(a){const i={...a};this._router.init(i)}setState(a,i){return this._router.setState(a,i)}getFile(a){const{data:i}=this.getState();return i.byId(a)||null}serialize(a){const{data:i}=this.getState();return i.serialize(a)}_updatePanels(a,i,r){const{data:c}=this.getState();a.forEach(d=>{const h=[];d.selected.forEach(g=>{c.byId(g)?h.push(g):!r&&i[g]&&h.push(i[g])}),d.selected=h,c.byId(d._lastSelected)||(d._lastSelected=r?null:i[d._lastSelected]||null);const p={};Object.keys(d._sorts).forEach(g=>{c.byId(g)?p[g]=d._sorts[g]:i[g]&&!r&&(p[i[g]]=d._sorts[g])}),d._sorts=p;const x=d._crumbs[d._crumbs.length-1];x?.id!=="/"&&(i[x.id]?d.path=i[x.id]:c.byId(x.id)||(d.path="/"))})}_isPlacedIntoSelf(a,i){return a.some(r=>r===i||this.getState().data.getParents(i).some(c=>c.id===r))}};function Y1(n){switch(n){case"body":return[{icon:"wxi-content-paste",text:"Paste",hotkey:"Ctrl+V",id:"paste"}];case"add":return[{icon:"mdi mdi-folder-plus-outline",text:"Add new file",id:"add-file"},{icon:"mdi mdi-file-plus-outline",text:"Add new folder",id:"add-folder"},{icon:"mdi mdi-file-upload-outline",text:"Upload file",id:"upload",comp:"upload"}];case"multiselect":return[{icon:"wxi-content-copy",text:"Copy",hotkey:"Ctrl+C",id:"copy"},{icon:"wxi-content-cut",text:"Cut",hotkey:"Ctrl+X",id:"move"},{comp:"separator"},{icon:"wxi-close",text:"Delete",hotkey:"Delete",id:"delete"}];default:return[n==="folder"?null:{icon:"wxi-download",text:"Download",hotkey:"Ctrl+D",id:"download"},{icon:"wxi-content-copy",text:"Copy",hotkey:"Ctrl+C",id:"copy"},{icon:"wxi-content-cut",text:"Cut",hotkey:"Ctrl+X",id:"move"},{icon:"wxi-content-paste",text:"Paste",hotkey:"Ctrl+V",id:"paste"},{comp:"separator"},{icon:"wxi-edit",text:"Rename",hotkey:"Ctrl+R",id:"rename"},{icon:"wxi-close",text:"Delete",hotkey:"Delete",id:"delete"}].filter(a=>a!==null)}}function V1(n,a="data-id"){let i=n;for(!i.tagName&&n.target&&(i=n.target);i;){if(i.getAttribute&&i.getAttribute(a))return i;i=i.parentNode}return null}function K1(n,a="data-id"){const i=V1(n,a);return i?i.getAttribute(a):null}new Date().valueOf();function W1(n,a){const{api:i}=a;function r(d,h){const p=a.getPanel(),x=p.selected,g=h.ctrlKey||h.metaKey,w=h.shiftKey;let v;const b=x?.[0]?i.getFile(x[0]):null;x?.length?x.length>1?v=a.menuOptions("multiselect"):v=a.menuOptions(b.type,b):v=a.menuOptions("body");const k=`${g?"ctrl+":""}${w?"shift+":""}${d}`,j=v?v.find(T=>T.hotkey?.toLowerCase()===k):!1,M=a.performAction;if(j)switch(k){case"ctrl+c":M("copy");break;case"ctrl+x":M("move");break;case"ctrl+v":M("paste",b);break;case"delete":M("delete");break;case"ctrl+r":h.preventDefault(),M("rename",b);break;case"ctrl+d":h.preventDefault(),M("download",b);break;default:j.handler?.({context:b})}switch(d){case"enter":{if(g||w)break;const{_crumbs:T,_selectNavigation:C}=p;if(C){const A=P1(T);if(A){const D=Rh(A,T);i.exec("set-path",{id:A,selected:[D]})}}else if(x.length===1){const A=i.getFile(x[0]);A&&i.exec(A.type==="folder"?"set-path":"open-file",{id:A.id})}break}case"arrowup":case"arrowleft":{const{_files:T,_selected:C,path:A,_selectNavigation:D}=p;let H;if(C.length){const B=C.at(0).id,q=T.findIndex(L=>L.id===B);if(q!==-1){const L=q-1;T[L]?H=T[L].id:A!=="/"&&!(g||w)&&i.exec("select-file",{type:"navigation"})}}else{if(D)break;if(A!=="/"){i.exec("select-file",{type:"navigation"});break}H=T.at(0)?.id}H&&i.exec("select-file",{id:H,toggle:g,range:w});break}case"arrowdown":case"arrowright":{const{_files:T,_selected:C,path:A,_selectNavigation:D}=p;let H;if(C.length){const B=C.at(-1).id,q=T.findIndex(L=>L.id===B);if(q!==-1){const L=q+1;T[L]&&(H=T[L].id)}}else{if(A!=="/"&&!D){i.exec("select-file",{type:"navigation"});break}H=T.at(0)?.id}H&&i.exec("select-file",{id:H,toggle:g,range:w});break}}}function c(d){const h=d.code.replace("Key","").toLowerCase();r(h,d),h=="tab"&&setTimeout(()=>{const p=document.activeElement;p.className.indexOf("table")!=-1&&i.exec("set-active-panel",{panel:+K1(p,"data-panel")})})}return n.addEventListener("keydown",c),{destroy:()=>{n.removeEventListener("keydown",c)}}}function Q1(n,a="data-id"){let i=n;for(!i.tagName&&n.target&&(i=n.target);i;){if(i.getAttribute&&i.getAttribute(a))return i;i=i.parentNode}return null}function X1(n,a="data-id"){const i=n.getAttribute(a);return i?Z1(i):null}function Z1(n){if(n.startsWith(":"))return n.substring(1);const a=n*1;return isNaN(a)?n:a}function J1(){return{detect:()=>!0,addEvent:function(n,a,i){return n.addEventListener(a,i),()=>n.removeEventListener(a,i)},addGlobalEvent:function(n,a){return document.addEventListener(n,a),()=>document.removeEventListener(n,a)},getTopNode:function(){return window.document.body}}}var eC=J1();new Date().valueOf();function _y(n){const[a,i]=f.useState(n),r=f.useRef(n);return f.useEffect(()=>{if(r.current!==n){if(Array.isArray(r.current)&&Array.isArray(n)&&r.current.length===0&&n.length===0)return;r.current=n,i(n)}},[n]),[a,i]}function tC(n,a,i){const[r,c]=f.useState(()=>a);return n||console.warn(`Writable ${i} is not defined`),f.useEffect(()=>n?n.subscribe(h=>{c(()=>h)}):void 0,[n]),r}function Xe(n,a){const i=n.getState(),r=n.getReactiveState();return tC(r[a],i[a],a)}function nC(n,a){const i=f.useRef(a);i.current=a;const[r,c]=f.useState(1);return f.useEffect(()=>n.subscribe(h=>{i.current=h,c(p=>p+1)}),[n]),[i.current,r]}function Xa(n,a){const i=n.getState(),r=n.getReactiveState();return nC(r[a],i[a])}function Oy(n){const a={};return n.split(";").forEach(i=>{const[r,c]=i.split(":");if(c){let d=r.trim();d.indexOf("-")&&(d=d.replace(/-([a-z])/g,(h,p)=>p.toUpperCase())),a[d]=c.trim()}}),a}function Iy(n){let a=n,i=[];return{subscribe:p=>{i.push(p),p(a)},unsubscribe:p=>{i=i.filter(x=>x!==p)},set:p=>{a=p,i.forEach(x=>x(a))},update:p=>{a=p(a),i.forEach(x=>x(a))}}}function mv(n,a,i){function r(c){const d=Q1(c);if(!d)return;const h=X1(d);if(typeof a=="function")return a(h,c);let p,x=c.target;for(;x!=d;){if(p=x.dataset?x.dataset.action:null,p&&a[p]){a[p](h,c);return}x=x.parentNode}a[i]&&a[i](h,c)}return eC.addEvent(n,i,r)}function aC(n,a){const i=[mv(n,a,"click")];return a.dblclick&&i.push(mv(n,a.dblclick,"dblclick")),()=>{i.forEach(r=>r())}}function By(n,a){return n.map((i,r)=>{const c=a(i,r);return i.data&&i.data.length&&(c.data=By(i.data,a)),c}).filter(Boolean)}function Fy(n,a){const i=[];return n.forEach(r=>{if(r.data){const c=Fy(r.data,a);c.length&&i.push({...r,data:c})}else a(r)&&i.push(r)}),i}function sC(n){return By(n,(a,i)=>{const r={...a,id:a.id||Sh()};return r.type&&(r.comp=r.type),r.comp==="separator"&&n[i-1]?.comp==="separator"?null:r})}const Hy={};function lC(n){return Hy[n]||n}function iC(n,a){Hy[n]=a}function rC({onClick:n,onShow:a,option:i}){const r=f.useRef(null),c=f.useCallback(()=>{a(i.data?i.id:!1,r.current)},[a,i]),d=f.useCallback(p=>{if(i.data){p.stopPropagation(),a(i.id,r.current);return}n(p)},[n,a,i]),h=f.useMemo(()=>i&&i.comp?lC(i.comp):null,[i]);return l.jsxs("div",{ref:r,className:`wx-cDCz9rZQ wx-option ${i.css||""} ${i.disabled?"wx-disabled":""}`,"data-id":Cn(i.id),onMouseEnter:c,onClick:d,children:[i.icon?l.jsx("i",{className:`wx-cDCz9rZQ wx-icon ${i.icon}`}):null,i.comp?h?l.jsx(h,{item:i,option:i}):null:l.jsxs("span",{className:"wx-cDCz9rZQ wx-value",children:[" ",i.text," "]}),i.subtext?l.jsx("span",{className:"wx-cDCz9rZQ wx-subtext",children:i.subtext}):null,i.data?l.jsx("i",{className:"wx-cDCz9rZQ wx-sub-icon wxi-angle-right"}):null]})}function Eh({options:n,left:a=0,top:i=0,at:r="bottom",parent:c=null,mount:d=null,context:h=null,css:p="",onClick:x,onCancel:g}){const[w,v]=f.useState(-1e4),[b,k]=f.useState(-1e4),[j,M]=f.useState(20),[T,C]=f.useState(),A=f.useRef(null),[D,H]=f.useState(!1),[B,q]=f.useState(null),L=f.useCallback(()=>{const oe=Sy(A.current,c,r,a,i);oe&&(v(oe.x),k(oe.y),C(oe.width));let K=oe?.z??20;const z=c?W0(c):[];let Y=0;for(const U of z){const R=parseInt(getComputedStyle(U).zIndex,10);R>Y&&(Y=R)}Y>=K&&(K=Y+1),M(K)},[c,r,a,i]);f.useEffect(()=>{d&&d(L)},[]);const F=f.useCallback(()=>{H(!1)},[]),ue=f.useCallback((oe,K)=>{H(oe),q(K)},[]),W=f.useMemo(()=>sC(n),[n]);f.useEffect(()=>{L()},[c,L]);const ce=f.useRef(x),Q=f.useRef(g),se=f.useRef(c);return f.useEffect(()=>{ce.current=x},[x]),f.useEffect(()=>{Q.current=g},[g]),f.useEffect(()=>{se.current=c},[c]),f.useEffect(()=>{if(!A.current)return;function oe(K){Q.current?Q.current(K):ce.current&&ce.current({action:null,option:null})}return zs(A.current,{callback:oe,modal:!0,parent:()=>se.current}).destroy},[]),l.jsx("div",{ref:A,"data-wx-menu":"true",className:`wx-XMmAGqVx wx-menu ${p}`,style:{position:"absolute",top:b+"px",left:w+"px",width:T,zIndex:j},onMouseLeave:F,children:W.map(oe=>l.jsxs(f.Fragment,{children:[oe.comp==="separator"?l.jsx("div",{className:"wx-XMmAGqVx wx-separator"}):l.jsx(rC,{option:oe,onShow:ue,onClick:K=>{if(!oe.data&&!K.defaultPrevented){const z={context:h,action:oe,option:oe,event:K};oe.handler&&oe.handler(z),x&&x(z),K.stopPropagation()}}}),oe.data&&D===oe.id?l.jsx(Eh,{css:p,options:oe.data,at:"right-overlap",parent:B,context:h,onClick:x,onCancel:g}):null]},oe.id))})}const $y=f.forwardRef(function(n,a){const{options:i,at:r="bottom",resolver:c=null,dataKey:d="contextId",filter:h=null,css:p="",children:x,onClick:g}=n,[w,v]=f.useState(null),[b,k]=f.useState(null),[j,M]=f.useState(0),[T,C]=f.useState(0),A=f.useRef(null),D=f.useMemo(()=>`data-${d.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,[d]),H=f.useMemo(()=>w!==null&&h?Fy(i,F=>h(F,w)):i,[w,h,i]);function B(F){k(null),g&&g(F)}function q(F){if(A.current===F){A.current=null;return}k(null),g&&g({action:null,option:null})}const L=f.useCallback((F,ue)=>{if(!F){k(null);return}if(F.defaultPrevented)return;const W=F.target;if(W&&W.dataset&&W.dataset.menuIgnore)return;if(b&&b===W){k(null),F.preventDefault();return}M(F.clientX+1),C(F.clientY+1);let ce=typeof ue<"u"?ue:mc(W,D);c&&(ce=c(ce,F),!ce)||(v(ce),k(W),A.current=F.nativeEvent||F,F.preventDefault())},[b,D,c]);return f.useImperativeHandle(a,()=>({show:L}),[L]),l.jsxs(l.Fragment,{children:[x?l.jsx("span",{onClick:L,"data-menu-ignore":"true",children:typeof x=="function"?x():x}):null,b?l.jsx(jh,{children:l.jsx(Eh,{css:p,at:r,top:T,left:j,parent:b,context:w,onClick:B,onCancel:q,options:H},b)}):null]})}),oC=f.forwardRef(function(n,a){const{options:i,at:r="bottom",css:c="",children:d,onClick:h}=n,[p,x]=f.useState(null),g=f.useRef(null);function w(j){x(null),h&&h(j)}function v(j){if(g.current===j){g.current=null;return}x(null),h&&h({action:null,option:null})}const b=f.useCallback(j=>{x(j.target),g.current=j.nativeEvent||j,j.preventDefault()},[]);f.useImperativeHandle(a,()=>({show:b}),[b]);function k(j){let M=j.target;for(;!M.dataset.menuIgnore;)x(M),M=M.parentNode}return l.jsxs(l.Fragment,{children:[l.jsx("span",{onClick:k,"data-menu-ignore":"true",children:d}),p?l.jsx(jh,{children:l.jsx(Eh,{css:c,at:r,parent:p,options:i,onClick:w,onCancel:v})}):null]})}),cC=f.forwardRef(function(n,a){const{options:i,at:r="bottom",resolver:c=null,dataKey:d="contextId",filter:h=null,css:p="",children:x,onClick:g}=n,w=f.useRef(null),v=f.useCallback((b,k)=>{w.current.show(b,k)},[]);return f.useImperativeHandle(a,()=>({show:v}),[v]),l.jsxs(l.Fragment,{children:[x?l.jsx("span",{onContextMenu:v,"data-menu-ignore":"true",children:x}):null,l.jsx($y,{css:p,at:r,options:i,resolver:c,dataKey:d,filter:h,ref:w,onClick:g})]})}),uC={uploader:{B:"B",KB:"KB",MB:"MB",GB:"GB",TB:"TB",PB:"PB",EB:"EB","Drop files here or":"Drop files here or","select files":"select files"}};let dC=class{constructor(a,i,r,c,d){this.setFiles=a,this.setReady=i,this.setSignal=r,this.setDrag=c,d&&d.length&&this.setFiles(d)}open(a){this.setSignal(["click",a||{}])}getState(){let a="server";const i=this.files;for(let r=0;r<i.length;r++){if(i[r].status==="client")return"client";i[r].status==="error"&&(a="error")}return a}droparea(a,i){i=i||{};const r=()=>{i.dragEnter&&i.dragEnter(),this.setDrag(!0)},c=()=>{i.dragLeave&&i.dragLeave(),this.setDrag(!1)},d=p=>{p.preventDefault()},h=p=>{p.preventDefault(),this.setDrag(!1),this.setSignal(["drop",i,p]),i.dragLeave&&i.dragLeave(),i.drop&&i.drop()};return a.addEventListener("dragenter",r),a.addEventListener("dragleave",c),a.addEventListener("dragover",d,!0),a.addEventListener("drop",h,!0),()=>{a.removeEventListener("dragenter",r),a.removeEventListener("dragleave",c),a.removeEventListener("dragover",d,!0),a.removeEventListener("drop",h,!0)}}updateFile(a,i){const r=this.files.findIndex(d=>d.id===a);if(r===-1)return;const c=[...this.files];return c[r]={...c[r],...i},this.files=c,this.setFiles(this.files),this.files[r]}deleteFile(a){this.files=this.files.filter(i=>i.id!==a),this.setFiles(this.files)}addFile(a,i){i?this.files=[...this.files,a]:this.files=[a],this.setFiles(this.files)}deleteAll(){this.files=[],this.setFiles(this.files)}};function Uy(n){const[a,i]=f.useState([]),[r,c]=f.useState(Promise.resolve(null)),[d,h]=f.useState(null),[p,x]=f.useState(!1),g=f.useRef();return g.current||(g.current=new dC(i,c,h,x,n)),g.current.files=a,g.current.ready=r,g.current.signal=d,g.current.drag=p,g.current}function fC(n,a){{if(n){const i=n.getGroup(a);if(i)return i}return gc(uC).getGroup(a)}}const mC=()=>Math.random().toString(36).substr(2,9),hC=({data:n,accept:a="",multiple:i=!0,folder:r=!1,uploadURL:c="",apiOnly:d=!1,disabled:h=!1,children:p,onChange:x,onUpload:g})=>{const w=f.useRef(null),v=f.useRef(null),[b,k]=f.useState({}),j=Uy(),M=n||j,T=f.useContext(kn.i18n),C=fC(T,"uploader");f.useEffect(()=>{w.current&&r&&(w.current.webkitdirectory=!0)},[r]),f.useEffect(()=>{if(!d&&v.current&&!h)return M.droparea(v.current)},[d,h,v]);const A=W=>{const ce=new FormData;return ce.append("upload",W.file),fetch(c,{method:"POST",body:ce}).then(Q=>Q.json()).then(Q=>({id:W.id,...Q}),()=>({id:W.id,status:"error"})).catch(Q=>(console.log(Q),{id:W.id,status:"error"}))},D=(W,ce)=>{const Q=M.updateFile(W,ce),se={...Q,status:M.getState()};Q&&Q.uploaded&&Q.uploaded(se),g&&g(se),Q.temp&&M.deleteFile(Q.id)},H=W=>{if(!W)return;const ce=typeof c=="function"?c(W):A(W);M.setReady(ce.then(Q=>{Q.status=Q.status||"server",D(W.id,Q)}).catch(Q=>{D(W.id,{status:"error",error:Q})}))},B=(W,ce)=>{const Q={...ce||b,id:mC(),status:"client",name:W.name,file:W};Q.selected&&Q.selected(Q),x&&x(Q),M.addFile(Q,i),H(Q),w.current&&(w.current.value="")},q=(W,ce,Q)=>{W.isFile?W.file(se=>{B(se,Q)}):W.isDirectory&&W.createReader().readEntries(se=>{se.forEach(oe=>{q(oe,ce+oe.name+"/",Q)})})},L=W=>{Array.from(W.target.files).forEach(ce=>B(ce))},F=(W,ce)=>{Array.from(W.dataTransfer.items).forEach(Q=>{const se=Q.webkitGetAsEntry();se&&q(se,"",ce)})},ue=()=>{w.current&&w.current.click()};return f.useEffect(()=>{if(M.signal){const[W,ce,Q]=M.signal;k(ce),W==="click"?ue():W==="drop"&&F(Q,ce),M.setSignal(null)}},[M.signal]),d?l.jsxs(l.Fragment,{children:[l.jsx("input",{type:"file",className:"wx-at1A8tb8 wx-input",ref:w,onChange:L,accept:a,multiple:i,disabled:h}),p]}):l.jsxs("div",{className:`wx-at1A8tb8 wx-label ${M.drag?"wx-active":""} ${h?"wx-disabled":""}`,ref:v,children:[l.jsx("input",{type:"file",className:"wx-at1A8tb8 wx-input",ref:w,onChange:L,accept:a,multiple:i,disabled:h}),p||l.jsx("div",{className:"wx-at1A8tb8 wx-dropzone",children:l.jsxs("span",{children:[C("Drop files here or")," ",l.jsx("span",{className:"wx-at1A8tb8 wx-action",onClick:ue,children:C("select files")})]})})]})};new Date().valueOf();function pC(n,a){if(Object.keys(n).length!==Object.keys(a).length)return!1;for(const i in a){const r=n[i],c=a[i];if(!kd(r,c))return!1}return!0}function kd(n,a){if(typeof n=="number"||typeof n=="string"||typeof n=="boolean"||n===null)return n===a;if(typeof n!=typeof a||(n===null||a===null)&&n!==a||n instanceof Date&&a instanceof Date&&n.getTime()!==a.getTime())return!1;if(typeof n=="object")if(Array.isArray(n)&&Array.isArray(a)){if(n.length!==a.length)return!1;for(let i=n.length-1;i>=0;i--)if(!kd(n[i],a[i]))return!1;return!0}else return pC(n,a);return n===a}function ah(n){if(typeof n!="object"||n===null)return n;if(n instanceof Date)return new Date(n);if(n instanceof Array)return n.map(ah);const a={};for(const i in n)a[i]=ah(n[i]);return a}var Py=2,gC=class{constructor(n){n&&(this._writable=n.writable,this._async=n.async),this._values={},this._state={}}setState(n,a=0){const i={};return this._wrapProperties(n,this._state,this._values,"",i,a),i}getState(){return this._values}getReactive(){return this._state}_wrapProperties(n,a,i,r,c,d){for(const h in n){const p=a[h],x=i[h],g=n[h];if(p&&(x===g&&typeof g!="object"||g instanceof Date&&x instanceof Date&&x.getTime()===g.getTime()))continue;const w=r+(r?".":"")+h;p?(p.__parse(g,w,c,d)&&(i[h]=g),d&Py?c[w]=p.__trigger:p.__trigger()):(g&&g.__reactive?a[h]=this._wrapNested(g,g,w,c):a[h]=this._wrapWritable(g),i[h]=g),c[w]=c[w]||null}}_wrapNested(n,a,i,r){const c=this._wrapWritable(n);return this._wrapProperties(n,c,a,i,r,0),c.__parse=(d,h,p,x)=>(this._wrapProperties(d,c,a,h,p,x),!1),c}_wrapWritable(n){const a=[],i=function(){for(let r=0;r<a.length;r++)a[r](n)};return{subscribe:r=>(a.push(r),this._async?setTimeout(r,1,n):r(n),()=>{const c=a.indexOf(r);c>=0&&a.splice(c,1)}),__trigger:()=>{a.length&&(this._async?setTimeout(i,1):i())},__parse:function(r){return n=r,!0}}}},xC=class{constructor(n,a,i,r){typeof n=="function"?this._setter=n:this._setter=n.setState.bind(n),this._routes=a,this._parsers=i,this._prev={},this._triggers=new Map,this._sources=new Map,this._routes.forEach(c=>{c.in.forEach(d=>{const h=this._triggers.get(d)||[];h.push(c),this._triggers.set(d,h)}),c.out.forEach(d=>{const h=this._sources.get(d)||{};c.in.forEach(p=>h[p]=!0),this._sources.set(d,h)})}),this._routes.forEach(c=>{c.length=Math.max(...c.in.map(d=>qy(d,this._sources,1)))}),this._bus=r}init(n){const a={};for(const i in n)if(this._prev[i]!==n[i]){const r=this._parsers[i];a[i]=r?r(n[i]):n[i]}this._prev=this._prev?{...this._prev,...n}:{...n},this.setState(a),this._bus&&this._bus.exec("init-state",a)}setStateAsync(n){const a=this._setter(n,Py);return this._async?Object.assign(this._async.signals,a):this._async={signals:a,timer:setTimeout(this._applyState.bind(this),1)},a}_applyState(){const n=this._async;if(n){this._async=null,this._triggerUpdates(n.signals,[]);for(const a in n.signals){const i=n.signals[a];i&&i()}}}setState(n,a=[]){const i=this._setter(n);return this._triggerUpdates(i,a),i}_triggerUpdates(n,a){const i=Object.keys(n),r=!a.length;a=a||[];for(let c=0;c<i.length;c++){const d=i[c],h=this._triggers.get(d);h&&h.forEach(p=>{a.indexOf(p)==-1&&a.push(p)})}r&&this._execNext(a)}_execNext(n){for(;n.length;){n.sort((i,r)=>i.length<r.length?1:-1);const a=n[n.length-1];n.splice(n.length-1),a.exec(n)}}};function qy(n,a,i){const r=a.get(n);if(!r)return i;const c=Object.keys(r).map(d=>qy(d,a,i+1));return Math.max(...c)}var vC=class{constructor(){this._nextHandler=null,this._handlers={},this._tag=new WeakMap,this.exec=this.exec.bind(this)}on(n,a,i){let r=this._handlers[n];r?i&&i.intercept?r.unshift(a):r.push(a):r=this._handlers[n]=[a],i&&i.tag&&this._tag.set(a,i.tag)}intercept(n,a,i){this.on(n,a,{...i,intercept:!0})}detach(n){for(const a in this._handlers){const i=this._handlers[a];for(let r=i.length-1;r>=0;r--)this._tag.get(i[r])===n&&i.splice(r,1)}}async exec(n,a){const i=this._handlers[n];if(i)for(let r=0;r<i.length;r++){const c=i[r](a);if(c===!1||c&&c.then&&await c===!1)return}return this._nextHandler&&await this._nextHandler.exec(n,a),a}setNext(n){return this._nextHandler=n}};function yC(n){return a=>a[n]}function wC(n){return(a,i)=>a[n]=i}function si(n,a){return(a.getter||yC(a.id))(n)}function Nm(n,a,i){return(a.setter||wC(a.id))(n,i)}function bC(n,a){const i=document.createElement("a");i.href=URL.createObjectURL(n),i.download=a,document.body.appendChild(i),i.click(),document.body.removeChild(i)}function ai(n,a){let i=si(n,a)??"";return a.template?i=a.template(i,n,a):a.optionsMap&&(Array.isArray(i)?i=i.map(r=>a.optionsMap.get(r)).join(", "):i=a.optionsMap.get(i)),typeof i>"u"?"":i+""}function SC(n,a){const i=/\n|"|;|,/;let r="";const c=a.rows||`
|
|
11
|
+
`,d=a.cols||" ",h=n._columns,p=n.flatData;a.header!==!1&&h[0].header&&(r=hv("header",h,r,d,c));for(let x=0;x<p.length;x++){const g=[];for(let w=0;w<h.length;w++){let v=ai(p[x],h[w]);i.test(v)&&(v='"'+v.replace(/"/g,'""')+'"'),g.push(v)}r+=(r?c:"")+g.join(d)}return a.footer!==!1&&h[0].footer&&(r=hv("footer",h,r,d,c)),r}function hv(n,a,i,r,c){const d=/\n|"|;|,/;for(let h=0;h<a[0][n].length;h++){const p=[];for(let x=0;x<a.length;x++){let g=(a[x][n][h].text||"")+"";d.test(g)&&(g='"'+g.replace(/"/g,'""')+'"'),p.push(g)}i+=(i?c:"")+p.join(r)}return i}const CC="portrait",jC=100,kC="a4",MC={a3:{width:11.7,height:16.5},a4:{width:8.27,height:11.7},letter:{width:8.5,height:11}};function AC(n,a){const i=[];let r=[],c=0;const d=n.filter(p=>!p.hidden),h=NC(a);return d.forEach((p,x)=>{c+p.width<=h?(c+=p.width,r.push(p)):(r.length&&i.push(r),r=[p],c=p.width),x===d.length-1&&r.length&&i.push(r)}),i}function pv(n,a,i){const r=[];return n.forEach((c,d)=>{const h=c[a];for(let p=0;p<i.length;p++){r[p]||(r[p]=[]);const x={...h[p]};if(r[p][d]!==null){if(!d&&!x.rowspan&&!x.colspan){let g=1,w=n[d+g][a][p],v=x.width;for(;!w.rowspan&&!w.colspan;)g++,w=n[d+g][a][p],v+=w.width;x.colspan=g,x.width=v,x.height=i[p]}if(r[p].push(x),!x.collapsed&&x.colspan>1){let g=x.colspan-1;if(x.colspan+d>n.length){const w=x.colspan-(x.colspan+d-n.length);x.colspan=w,x.width=n.slice(d,d+g+1).reduce((v,b)=>v+b.width,0),w>1&&(g=w-1)}for(let w=0;w<g;w++)r[p].push(null)}if(x.rowspan>1){const g=x.rowspan;for(let w=1;w<g;w++)r[p+w]||(r[p+w]=[]),r[p+w].push(null)}}}if(c.collapsed)for(let p=0;p<r.length;p++){const x=r[p],g=x[d];if(g&&g.collapsed){if(x[d]=null,!p)break}else{const w=g||x.findLast(v=>v?.colspan>=1);w&&(w.colspan=w.colspan-1,w.width=w.width-c.width)}}}),r.map(c=>c.filter(d=>d&&d.colspan!==0))}function NC(n){const{mode:a,ppi:i,paper:r}=n,{width:c,height:d}=MC[r];return TC(a==="portrait"?c:d,i)}function TC(n,a){return n*a}function RC(n={}){const{mode:a,ppi:i,paper:r}=n;return{mode:a||CC,ppi:i||jC,paper:r||kC}}function Gy(n,a){return n.flexgrow?`min-width:${a}px;width:auto`:`width:${n.width}px; max-width:${n.width}px; height:${n.height}px`}function EC(n,a,i){let r=n[i.id];if(i.filter.type==="richselect"&&r){const c=i.filter.config?.options||a.find(({id:d})=>d==i.id).options;c&&(r=c.find(({id:d})=>d==r).label)}return r??""}const gv=["resize-column","hide-column","update-cell"],DC=["delete-row","update-row","update-cell"],LC=["move-item"],zC=["resize-column","move-item"];class _C{undo=[];redo=[];progress={};in;getState;setState;_previousValues={};constructor(a,i,r){this.in=a,this.getState=i,this.setState=r,this.setHandlers(),this.resetStateHistory()}getHandlers(){return{"add-row":{handler:a=>({action:"delete-row",data:{id:a.id},source:{action:"add-row",data:a}})},"delete-row":{handler:a=>{const{id:i}=a,{data:r}=this.getPrev(),c=r.findIndex(d=>d.id===i);return{action:"add-row",data:{id:i,row:r[c],before:c<r.length-1?r[c+1].id:void 0},source:{action:"delete-row",data:a}}}},"update-cell":{handler:a=>{const{id:i,column:r}=a,c=this.getRow(i),d=this.getColumn(r),h=si(c,d);return kd(h,a.value)?null:{action:"update-cell",data:{id:i,column:r,value:h},source:{action:"update-cell",data:a}}}},"update-row":{handler:a=>{const{id:i,row:r}=a,c=this.getRow(i);for(const d in r)Object.keys(c).includes(d)||(c[d]=void 0);return{action:"update-row",data:{id:i,row:c},source:{action:"update-row",data:a}}}},"copy-row":{handler:a=>{const{id:i}=a,{data:r}=this.getState(),c=r.findIndex(h=>h.id===i),d=r[c];return{action:"delete-row",data:{id:i},source:{action:"add-row",data:{id:i,row:d,before:c<r.length-1?r[c+1].id:void 0}}}}},"resize-column":{handler:a=>{const{id:i,width:r}=a,c=this.getColumn(i),{_sizes:d}=this.getState();return{action:"resize-column",data:{id:i,width:c.width??d.columnWidth},source:{action:"resize-column",data:{id:i,width:r}}}}},"hide-column":{handler:a=>{const{id:i}=a,r=this.getColumn(i);return{action:"hide-column",data:{id:i,mode:r.hidden},source:{action:"hide-column",data:a}}}},"collapse-column":{handler:a=>{const{id:i,row:r,mode:c}=a;return{action:"collapse-column",data:{id:i,row:r,mode:typeof c=="boolean"?!c:c},source:{action:"collapse-column",data:a}}}},"move-item":{handler:a=>{const{id:i,target:r,mode:c}=a,{flatData:d}=this.getPrev(),h=d.findIndex(p=>p.id===i);return{action:"move-item",data:{id:i,target:d[h+(h?-1:1)].id,mode:h?"after":"before"},source:{action:"move-item",data:{id:i,target:r,mode:c}}}}},"open-row":{handler:a=>{const{id:i,nested:r}=a;return{action:"close-row",data:{id:i,nested:r},source:{action:"open-row",data:a}}}},"close-row":{handler:a=>{const{id:i,nested:r}=a;return{action:"open-row",data:{id:i,nested:r},source:{action:"close-row",data:a}}}}}}resetHistory(){this.undo=[],this.redo=[],this.progress={},this.resetStateHistory()}getPrev(){return this._previousValues}setHandlers(){const a=this.getHandlers();for(const i in a)this.in.intercept(i,r=>{if(!(r.eventSource==="undo"||r.eventSource==="redo"||r.skipUndo)){if(zC.includes(i)){(r.inProgress&&!this.progress[i]||typeof r.inProgress!="boolean")&&(LC.includes(i)&&this.setPrev("flatData"),gv.includes(i)&&this.setPrev("columns")),this.progress[i]=r.inProgress;return}DC.includes(i)&&this.setPrev("data"),gv.includes(i)&&this.setPrev("columns")}}),this.in.on(i,r=>{if(r.eventSource==="undo"||r.eventSource==="redo"||r.skipUndo||r.inProgress)return;const c=a[i].handler(r);c&&this.addToHistory(c)})}setPrev(a){this._previousValues[a]=ah(this.getState()[a])}addToHistory(a){this.undo.push(a),this.redo=[],this.setStateHistory()}handleUndo(){if(!this.undo.length)return;const a=this.undo.pop();this.redo.push({...a.source,source:a}),this.in.exec(a.action,{...a.data,eventSource:"undo"}),this.setStateHistory()}handleRedo(){if(!this.redo.length)return;const a=this.redo.pop();this.undo.push({...a.source,source:a}),this.in.exec(a.action,{...a.data,eventSource:"redo"}),this.setStateHistory()}resetStateHistory(){this.setState({history:{undo:0,redo:0}})}setStateHistory(){this.setState({history:{undo:this.undo.length,redo:this.redo.length}})}getRow(a){const{data:i}=this.getPrev();return this.getState().tree?this.getTreeRow(i,a):i.find(r=>r.id===a)}getTreeRow(a,i){for(let r=0;r<a.length;r++){if(a[r].id===i)return a[r];if(a[r].data){const c=this.getTreeRow(a[r].data,i);if(c)return c}}return null}getColumn(a){const{columns:i}=this.getPrev();return i.find(r=>r.id===a)}}function Yy(n,a){return typeof n>"u"||n===null?-1:typeof a>"u"||a===null?1:n===a?0:n>a?1:-1}function OC(n,a){return-Yy(n,a)}function IC(n,a){if(typeof a.sort=="function")return function(r,c){const d=a.sort(r,c);return n==="asc"?d:-d};const i=n==="asc"?Yy:OC;return function(r,c){return i(si(r,a),si(c,a))}}function BC(n,a){if(!n||!n.length)return;const i=n.map(r=>{const c=a.find(d=>d.id==r.key);return IC(r.order,c)});return n.length===1?i[0]:function(r,c){for(let d=0;d<i.length;d++){const h=i[d](r,c);if(h!==0)return h}return 0}}const Gu=28,FC=20;function HC(){if(typeof document>"u")return"willow";const n=document.querySelector('[class^="wx"][class$="theme"]');return n?n.className.substring(3,n.className.length-6):"willow"}function gd(n,a,i,r,c){const d=document.createElement("div"),h=document.createElement("div"),p=document.body;c=c?`${c}px`:"auto";let x,g;h.className=a,d.classList.add(`wx-${i}-theme`),d.style.cssText=`height:auto;position:absolute;top:0px;left:100px;overflow:hidden;width=${c};white-space:nowrap;`,d.appendChild(h),p.appendChild(d),typeof n!="object"&&(n=[n]);for(let w=0;w<n.length;w++){h.innerText=n[w]+"";const v=d.getBoundingClientRect(),b=Math.ceil(v.width)+(r&&r.length?r[w]:0),k=Math.ceil(v.height);x=Math.max(x||0,b),g=Math.max(g||0,k)}return d.remove(),{width:x,height:g}}function xv(n,a,i,r,c){const d=[];for(let h=0;h<n.length;h++){const p=n[h][a],x=p.length;for(let g=0;g<x;g++){const{text:w,vertical:v,collapsed:b,rowspan:k,css:j}=p[g];if(!w){d[g]=Math.max(d[g]||0,r);continue}let M=0;if(v&&!b){let T=`wx-measure-cell-${a}`;if(T+=j?` ${j}`:"",M=gd(w,T,c).width,(k>1||!p[g+1])&&i>g+1){const C=k||i-g,A=d.slice(g,g+C).reduce((D,H)=>D+H,0);if(A<M){const D=Math.ceil((M-A)/C);for(let H=g;H<g+C;H++)d[H]=(d[H]||r)+D}continue}}d[g]=Math.max(d[g]||r,M)}}return d}function $C(n,a,i){const r=[],c=[];let d="wx-measure-cell-body";d+=n.css?` ${n.css}`:"";for(let h=0;h<a.length;h++){const p=a[h],x=ai(p,n);x&&(r.push(x),n.treetoggle?c.push(a[h].$level*Gu+(a[h].$count?Gu:0)+(n.draggable?Gu:0)):n.draggable&&c.push(Gu))}return gd(r,d,i,c).width}function UC(n,a){const i="wx-measure-cell-header",r=n.sort?FC:0;let c=n.header;if(typeof c=="string")return gd(c,i,a).width+r;let d;Array.isArray(c)||(c=[c]);for(let h=0;h<c.length;h++){const p=c[h],x=typeof p=="string"?p:p.text,g=i+(typeof p=="string"?"":` ${p.css}`);let w=gd(x,g,a).width;h===c.length-1&&(w+=r),d=Math.max(d||0,w)}return d}const PC={text:(n,a)=>n?n.toString().toLowerCase().indexOf(a.toLowerCase())!==-1:!a,richselect:(n,a)=>typeof a!="number"&&!a?!0:n==a,datepicker:(n,a)=>a?n&&GC(n,a):!0,multiselect:(n,a)=>!a||a?.length===0?!0:Array.isArray(n)?n?.some(i=>a.includes(i)):n&&a.includes(n)};function Vy(n){return PC[n]}function qC(n,a){const i=[];for(const r in n){const c=a.find(x=>x.id==r),{config:d,type:h}=c.header.find(x=>x.filter).filter,p=n[r];i.push(x=>{const g=si(x,c);return d?.handler?d.handler(g,p):Vy(h)(g,p)})}return r=>{for(let c=0;c<i.length;c++)if(!i[c](r))return!1;return!0}}function GC(n,a){return n.getFullYear()===a.getFullYear()&&n.getMonth()===a.getMonth()&&n.getDate()===a.getDate()}let YC=class extends gC{in;_router;_branches;_xlsxWorker;_historyManager;constructor(a){super({writable:a,async:!1});const i={rowHeight:37,columnWidth:160,headerHeight:36,footerHeight:36};this._router=new xC(super.setState.bind(this),[{in:["columns","sizes","_skin"],out:["_columns","_sizes"],exec:c=>{const{columns:d,sizes:h,_skin:p}=this.getState(),x=this.copyColumns(d),g=x.reduce((b,k)=>Math.max(k.header.length,b),0),w=x.reduce((b,k)=>Math.max(k.footer.length,b),0);x.forEach(this.setCollapsibleColumns);const v=this.normalizeSizes(x,h,g,w,p);for(let b=0;b<x.length;b++)this.normalizeColumns(x,b,"header",g,v),this.normalizeColumns(x,b,"footer",w,v);this.setState({_columns:x,_sizes:v},c)}},{in:["data","tree","_filterIds"],out:["flatData","_rowHeightFromData"],exec:c=>{const{data:d,tree:h,dynamic:p,_filterIds:x}=this.getState(),g=x&&new Set(x),w=h?this.flattenRows(d,[],x):g?d.filter(b=>g.has(b.id)):d,v=!p&&w.some(b=>b.rowHeight);this.setState({flatData:w,_rowHeightFromData:v},c)}}],{sizes:c=>({...i,...c})});const r=this.in=new vC;r.on("close-editor",({ignore:c})=>{const{editor:d}=this.getState();d&&(c||r.exec("update-cell",d),this.setState({editor:null}))}),r.on("open-editor",({id:c,column:d})=>{let h=this.getState().editor;h&&r.exec("close-editor",{});const p=this.getRow(c),x=d?this.getColumn(d):this.getNextEditor(p);if(x?.editor){let g=x.editor;if(typeof g=="function"&&(g=g(p,x)),!g)return;h={column:x.id,id:c,value:si(p,x)??"",renderedValue:ai(p,x),type:g.type||g},typeof g=="object"&&g.config&&(h.config=g.config,g.config.options&&(h.options=g.config.options)),x.options&&!h.options&&(h.options=x.options),this.setState({editor:h})}}),r.on("editor",({value:c})=>{let d=this.getState().editor;if(d){d={...d},d.value=c;const h=this.getColumn(d.column),p={...this.getRow(d.id)};Nm(p,h,c),d.renderedValue=ai(p,h),this.setState({editor:d})}}),r.on("add-row",c=>{const d=this.getState();let{data:h}=d;const{select:p,_filterIds:x}=d,{row:g,before:w,after:v,select:b}=c;if(c.id=g.id=c.id||g.id||Yu(),w||v){const j=w||v,M=h.findIndex(T=>T.id===j);h=[...h],h.splice(M+(v?1:0),0,c.row)}else h=[...h,c.row];const k={data:h};x&&(k._filterIds=[...x,c.id]),this.setState(k),!(typeof b=="boolean"&&!b)&&(b||p)&&r.exec("select-row",{id:g.id,show:!0})}),r.on("delete-row",c=>{const{data:d,selectedRows:h,focusCell:p,editor:x}=this.getState(),{id:g}=c,w={data:d.filter(v=>v.id!==g)};this.isSelected(g)&&(w.selectedRows=h.filter(v=>v!==g)),x?.id===g&&(w.editor=null),this.setState(w),p?.row===g&&this.in.exec("focus-cell",{eventSource:"delete-row"})}),r.on("update-cell",c=>{const d=this.getState();let{data:h}=d;h=[...h];const{tree:p}=d,{id:x,column:g,value:w}=c,v=this.getColumn(g);if(p){const b={...this._branches[x]};Nm(b,v,w);const k=this.updateTreeRow(b);b.$parent===0&&(h=k)}else{const b=h.findIndex(j=>j.id===x),k={...h[b]};Nm(k,v,w),h[b]=k}this.setState({data:h})}),r.on("update-row",c=>{let{data:d}=this.getState();const{id:h,row:p}=c,x=d.findIndex(g=>g.id===h);d=[...d],d[x]={...d[x],...p},this.setState({data:d})}),r.on("select-row",({id:c,toggle:d,range:h,mode:p,show:x,column:g})=>{const w=this.getState(),{focusCell:v}=w;let{selectedRows:b}=w;if(b.length||(h=d=!1),h){const{data:k}=this.getState();let j=k.findIndex(T=>T.id===b[b.length-1]),M=k.findIndex(T=>T.id===c);j>M&&([j,M]=[M,j]),k.slice(j,M+1).forEach(T=>{this.isSelected(T.id)||b.push(T.id)})}else if(d&&this.isSelected(c)){if(p===!0)return;b=b.filter(k=>k!==c)}else if(d){if(p===!1)return;b.push(c)}else b=[c];this.setState({selectedRows:[...b]}),v?.row!==c&&this.in.exec("focus-cell",{eventSource:"select-row"}),x&&this.in.exec("scroll",{row:c,column:g})}),this.in.on("focus-cell",c=>{const{row:d,column:h,eventSource:p}=c,{_columns:x,split:g}=this.getState();d&&h?(this.setState({focusCell:{row:d,column:h}}),p!=="click"&&((!g.left||x.findIndex(w=>w.id===c.column)>=g.left)&&(!g.right||x.findIndex(w=>w.id===c.column)<x.length-g.right)?this.in.exec("scroll",{row:d,column:h}):this.in.exec("scroll",{row:d}))):this.setState({focusCell:null})}),r.on("resize-column",c=>{const{id:d,auto:h,maxRows:p,inProgress:x}=c;if(x===!1)return;let g=c.width||0;const w=[...this.getState().columns],v=this.getColumn(d);if(h){if(h==="data"||h===!0){const{flatData:b,_skin:k}=this.getState();let j=b.length;p&&(j=Math.min(p,j));const M=b.slice(0,j);g=$C(v,M,k)}if(h==="header"||h===!0){const{_skin:b}=this.getState();g=Math.max(UC(v,b),g)}}v.width=Math.max(17,g),delete v.flexgrow,this.setState({columns:w})}),r.on("hide-column",c=>{const{id:d,mode:h}=c,p=[...this.getState().columns],x=this.getColumn(d),g=p.reduce((w,v)=>w+(v.hidden?0:1),0);!h||g>1?(x.hidden=!x.hidden,this.setState({columns:p})):c.skipUndo=!0}),r.on("sort-rows",c=>{const{key:d,add:h,sort:p}=c,x=this.getState(),{columns:g,data:w,tree:v}=x;if(p){const A=[...w];A.sort(p),this.setState({data:A});return}const{order:b="asc"}=c;let k=x.sortMarks;const j=Object.keys(k),M=j.length;!h||!M||M===1&&k[d]?k={[d]:{order:b}}:(M===1&&(k[j[0]]={...k[j[0]],index:0}),k={...k,[d]:{order:b,index:typeof h=="number"?h:k[d]?.index??M}});const T=Object.keys(k).sort((A,D)=>k[A].index-k[D].index).map(A=>({key:A,order:k[A].order}));this.setState({sortMarks:k});const C=BC(T,g);if(C){const A=[...w];v?this.sortTree(A,C):A.sort(C),this.setState({data:A})}}),r.on("filter-rows",c=>{const{value:d,key:h,filter:p}=c;if(!Object.keys(c).length){this.setState({filterValues:{},_filterIds:null});return}const x=this.getState(),{data:g,tree:w,_columns:v}=x;let b=x.filterValues;const k={};h&&(b={...b,[h]:d},k.filterValues=b);const j=p??qC(b,v);let M=[];w?M=this.filterTree(g,j,M):g.forEach(T=>{j(T)&&M.push(T.id)}),k._filterIds=M,this.setState(k)}),r.on("collapse-column",c=>{const{id:d,row:h,mode:p}=c,x=[...this.getState().columns],g=this.getColumn(d).header,w=Array.isArray(g)?g[h]:g;typeof w=="object"&&(w.collapsed=p??!w.collapsed,this.setState({columns:x}))}),r.on("move-item",c=>{const{id:d,inProgress:h}=c;let{target:p,mode:x="after"}=c;const{data:g,flatData:w,tree:v}=this.getState(),b=w.findIndex(M=>M.id===d);let k;if(x==="up"||x==="down"){if(x==="up"){if(b===0)return;k=b-1,x="before"}else if(x==="down"){if(b===w.length-1)return;k=b+1,x="after"}p=w[k]&&w[k].id}else k=w.findIndex(M=>M.id===p);if(b===-1||k===-1||h===!1)return;let j;v||(j=this.moveItem(d,p,g,x)),this.setState({data:v?this.normalizeTreeRows(j):j})}),r.on("copy-row",c=>{const{id:d,target:h,mode:p="after"}=c,x=this.getState(),{flatData:g,_filterIds:w}=x;let{data:v}=x;const b=this.getRow(d);if(!b)return;const k={...b,id:Yu()};c.id=k.id;const j=g.findIndex(T=>T.id===h);if(j===-1)return;v.splice(j+(p==="after"?1:0),0,k),v=[...v];const M={data:v};w&&(M._filterIds=[...w,k.id]),this.setState(M)}),r.on("open-row",c=>{const{id:d,nested:h}=c;this.toggleBranch(d,!0,h)}),r.on("close-row",c=>{const{id:d,nested:h}=c;this.toggleBranch(d,!1,h)}),r.on("export-data",c=>new Promise((d,h)=>{const p=c.format||"csv",x=`${c.fileName||"data"}.${p}`;if(p==="csv"){const g=SC(this.getState(),c.csv||{});c.download!==!1?bC(new Blob(["\uFEFF"+g],{type:"text/csv"}),x):c.result=g,d(!0)}else h()})),r.on("hotkey",({key:c,event:d,isInput:h})=>{switch(c){case"arrowup":{const{flatData:p,focusCell:x,select:g}=this.getState();if(d.preventDefault(),h)return;const w=x?x.column:this._getFirstVisibleColumn()?.id,v=x?this.getPrevRow(x.row)?.id:p[p.length-1]?.id;w&&v&&(this.in.exec("focus-cell",{row:v,column:w,eventSource:"key"}),g&&this.in.exec("select-row",{id:v}));break}case"arrowdown":{const{flatData:p,focusCell:x,select:g}=this.getState();if(d.preventDefault(),h)return;const w=x?x.column:this._getFirstVisibleColumn()?.id,v=x?this.getNextRow(x.row)?.id:p[0]?.id;w&&v&&(this.in.exec("focus-cell",{row:v,column:w,eventSource:"key"}),g&&this.in.exec("select-row",{id:v}));break}case"arrowright":{const{focusCell:p}=this.getState();if(h)return;if(d.preventDefault(),p){const x=this.getNextColumn(p.column,!0)?.id;x&&this.in.exec("focus-cell",{row:p.row,column:x,eventSource:"key"})}break}case"arrowleft":{const{focusCell:p}=this.getState();if(h)return;if(d.preventDefault(),p){const x=this.getPrevColumn(p.column,!0)?.id;x&&this.in.exec("focus-cell",{row:p.row,column:x,eventSource:"key"})}break}case"tab":{const{editor:p,focusCell:x,select:g}=this.getState();if(p){d.preventDefault();const w=p.column;let v=p.id,b=this.getNextEditor(this.getRow(v),this.getColumn(w));if(!b){const k=this.getNextRow(v);k&&(v=k.id,b=this.getNextEditor(k))}b&&(this.in.exec("open-editor",{id:v,column:b.id}),this.in.exec("focus-cell",{row:v,column:b.id,eventSource:"key"}),g&&!this.isSelected(v)&&this.in.exec("select-row",{id:v}))}else x&&this.in.exec("focus-cell",{eventSource:"key"});break}case"shift+tab":{const{editor:p,focusCell:x,select:g}=this.getState();if(p){d.preventDefault();const w=p.column;let v=p.id,b=this.getPrevEditor(this.getRow(v),this.getColumn(w));if(!b){const k=this.getPrevRow(v);k&&(v=k.id,b=this.getPrevEditor(k))}b&&(this.in.exec("open-editor",{id:v,column:b.id}),this.in.exec("focus-cell",{row:v,column:b.id,eventSource:"key"}),g&&!this.isSelected(v)&&this.in.exec("select-row",{id:v}))}else x&&this.in.exec("focus-cell",{eventSource:"key"});break}case"escape":{const{editor:p}=this.getState();p&&(this.in.exec("close-editor",{ignore:p.type!="multiselect"}),this.in.exec("focus-cell",{row:p.id,column:p.column,eventSource:"key"}));break}case"f2":{const{editor:p,focusCell:x}=this.getState();!p&&x&&this.in.exec("open-editor",{id:x.row,column:x.column});break}case"enter":{const{focusCell:p,tree:x}=this.getState();if(!h&&x&&p&&this.getColumn(p.column).treetoggle){const g=this.getRow(p.row);if(!g.data)return;this.in.exec(g.open?"close-row":"open-row",{id:p.row,nested:!0})}break}case"home":{const{editor:p,focusCell:x}=this.getState();if(!p&&x){d.preventDefault();const g=this._getFirstVisibleColumn()?.id;this.in.exec("focus-cell",{row:x.row,column:g,eventSource:"key"})}break}case"ctrl+home":{const{editor:p,focusCell:x,flatData:g,select:w}=this.getState();if(!p&&x){d.preventDefault();const v=g[0]?.id,b=this._getFirstVisibleColumn()?.id;v&&b&&(this.in.exec("focus-cell",{row:v,column:b,eventSource:"key"}),w&&!this.isSelected(v)&&this.in.exec("select-row",{id:v}))}break}case"end":{const{editor:p,focusCell:x}=this.getState();if(!p&&x){d.preventDefault();const g=this._getLastVisibleColumn()?.id,w=x.row;this.in.exec("focus-cell",{row:w,column:g,eventSource:"key"})}break}case"ctrl+end":{const{editor:p,focusCell:x,flatData:g,select:w}=this.getState();if(!p&&x){d.preventDefault();const v=g.at(-1).id,b=this._getLastVisibleColumn()?.id;v&&b&&(this.in.exec("focus-cell",{row:v,column:b,eventSource:"key"}),w&&!this.isSelected(v)&&this.in.exec("select-row",{id:v}))}break}case"ctrl+z":{this.in.exec("undo",{});break}case"ctrl+y":{this.in.exec("redo",{});break}}}),r.on("scroll",c=>{const{_columns:d,split:h,_sizes:p,flatData:x,dynamic:g,_rowHeightFromData:w}=this.getState();let v=-1,b=-1,k=0,j=0;if(c.column){v=0;const M=d.findIndex(T=>T.id===c.column);k=d[M].width;for(let T=h.left??0;T<M;T++){const C=d[T];C.hidden||(v+=C.width)}}if(c.row&&!g){const M=x.findIndex(T=>T.id===c.row);M>=0&&(w?(b=x.slice(0,M).reduce((T,C)=>T+(C.rowHeight||p.rowHeight),0),j=x[M].rowHeight):b=p.rowHeight*M)}this.setState({scroll:{top:b,left:v,width:k,height:j||p.rowHeight}})}),r.on("scroll-to",c=>{const d={};c.top!==void 0&&(d.scrollTop=c.top),c.left!==void 0&&(d.scrollLeft=c.left),Object.keys(d).length&&this.setState(d)}),r.on("print",c=>{const d=RC(c);this.setState({_print:d}),this.setStateAsync({_print:null})}),r.on("undo",()=>{this._historyManager?.handleUndo()}),r.on("redo",()=>{this._historyManager?.handleRedo()}),this.initOnce()}getXlsxWorker(a){if(!this._xlsxWorker){const i=window.URL.createObjectURL(new Blob([`importScripts('${a}');`],{type:"text/javascript"}));this._xlsxWorker=new Promise(r=>{const c=new Worker(i);c.addEventListener("message",d=>{d.data.type==="init"&&r(c)})})}return this._xlsxWorker}initOnce(){const a={sortMarks:{},_filterIds:null,data:[],filterValues:{},scroll:null,scrollLeft:0,scrollTop:0,editor:null,focusCell:null,_print:null,history:{undo:0,redo:0},search:null};this._router.init(a)}init(a){a.hasOwnProperty("_skin")&&!a._skin&&(a._skin=HC()),a.columns&&a.columns.forEach(i=>{i.options&&(i.optionsMap=new Map(i.options.map(r=>[r.id,r.label])))}),kd(this.getState().data,a.data)||(a.tree?a.data=this.normalizeTreeRows(a.data):a.data=this.normalizeRows(a.data),this.setState({_filterIds:null,filterValues:{},sortMarks:{},search:null}),this._historyManager&&this._historyManager.resetHistory()),a.tree&&(a.undo=!1,a.reorder=!1),a.split?.right&&(a.split.right=0),a.undo&&!this._historyManager&&(this._historyManager=new _C(this.in,this.getState.bind(this),this.setState.bind(this))),this._router.init({...a})}setState(a,i){return this._router.setState(a,i)}setStateAsync(a){this._router.setStateAsync(a)}getRow(a){const{tree:i}=this.getState();return i?this._branches[a]:this.getState().data.find(r=>r.id===a)}getRowIndex(a,i){return i||(i=this.getState().flatData),i.findIndex(r=>r.id===a)}getNextRow(a){const i=this.getState().flatData,r=this.getRowIndex(a,i);return i[r+1]}getPrevRow(a){const i=this.getState().flatData,r=this.getRowIndex(a,i);return i[r-1]}getColumn(a){return this.getState().columns.find(i=>i.id===a)}getNextColumn(a,i){const r=this.getState()._columns,c=r.findIndex(d=>d.id===a);return i?this._getFirstVisibleColumn(c+1):r[c+1]}getPrevColumn(a,i){const r=this.getState()._columns,c=r.findIndex(d=>d.id===a);return i?this._getLastVisibleColumn(c-1):r[c-1]}_getFirstVisibleColumn(a){const i=this.getState()._columns;let r=a??0;for(;r<i.length&&(i[r]?.hidden||i[r]?.collapsed);)r++;return i[r]}_getLastVisibleColumn(a){const i=this.getState()._columns;let r=a??i.length-1;for(;r<i.length&&(i[r]?.hidden||i[r]?.collapsed);)r--;return i[r]}isCellEditable(a,i){const{editor:r,hidden:c}=i;return!r||c?!1:typeof r=="function"?r(a,i):!0}getNextEditor(a,i){let r=this.getState().columns;if(i){const c=r.findIndex(d=>d.id===i.id);r=r.slice(c+1)}return r.find(c=>this.isCellEditable(a,c))}getPrevEditor(a,i){let r=this.getState().columns;if(i){const c=r.findLastIndex(d=>d.id===i.id);r=r.slice(0,c)}return r.findLast(c=>this.isCellEditable(a,c))}toggleBranch(a,i,r){let c=this._branches[a],{data:d}=this.getState();if(d=[...d],a!==0){c={...c,open:i};const h=this.updateTreeRow(c);c.$parent===0&&(d=h)}r&&c.data?.length&&c.data.forEach(h=>{const p=this.toggleKids(h,i,r);a===0&&(d=p)}),this.setState({data:d})}toggleKids(a,i,r){a={...a,open:i};const c=this.updateTreeRow(a);return r&&a.data?.length&&a.data.forEach(d=>{this.toggleKids(d,i,r)}),c}updateTreeRow(a){const i=a.id;this._branches[i]=a;const r=this._branches[a.$parent],c=r.data.findIndex(d=>d.id===i);return r.data=[...r.data],r.data[c]=a,r.data}isSelected(a){return this.getState().selectedRows.indexOf(a)!==-1}findAndRemove(a,i){for(let r=0;r<a.length;r++){if(a[r].id===i)return a.splice(r,1)[0];if(a[r].data){const c=[...a[r].data],d=this.findAndRemove(c,i);if(d)return a[r]={...a[r],data:c},d}}return null}insertItem(a,i,r,c){for(let d=0;d<a.length;d++){if(a[d].id===i){const h=a[d],p=c==="before"?d:d+1;if(h.data){if(c==="before"){const x=d>0?a[d-1]:null;return x?.data&&x.open?a[d-1]={...x,data:[...x.data,r]}:a.splice(p,0,r),!0}else if(h.open)return a[d]={...h,data:[r,...h.data]},!0}return a.splice(p,0,r),!0}if(a[d].data&&(a[d]={...a[d],data:[...a[d].data]},this.insertItem(a[d].data,i,r,c)))return!0}return!1}moveItem(a,i,r,c){const d=[...r],h=this.findAndRemove(d,a);return this.insertItem(d,i,h,c),d}copyColumns(a){const i=[];for(let r=0;r<a.length;r++){const c={...a[r]};this.copyHeaderFooter(c,"header"),this.copyHeaderFooter(c,"footer"),i[r]=c}return i}copyHeaderFooter(a,i){let r=a[i];r=Array.isArray(r)?[...r]:[r],r.forEach((c,d)=>{r[d]=typeof c=="string"?{text:c}:{...c}}),a[i]=r}setCollapsibleColumns(a,i,r){let c=a.header;for(let d=0;d<c.length;d++){const h=c[d];if(h.collapsible&&h.collapsed){if(h.collapsible!=="first"){a.collapsed=!0,a.width=36,h.vertical=!0;const x=c.length-d;c=c.slice(0,d+1),c[d].rowspan=x}const p=h.colspan;if(p){const x=c[d+1];let g=1;x&&x.colspan&&!x.collapsed&&(g=x.colspan);for(let w=g;w<p;w++){const v=r[i+w];v&&(v.hidden=!0)}}}}}normalizeColumns(a,i,r,c,d){const h=a[i];h.width||(h.width=h.flexgrow?17:d.columnWidth),h._colindex=i+1;const p=h[r],x=d[`${r}RowHeights`];for(let g=0;g<c;g++){const w=p[g];w.id=h.id,g===p.length-1&&(w.rowspan=w.rowspan?Math.min(w.rowspan,c-g):c-g);for(let v=1;v<w.rowspan;v++){p.splice(g+v,0,{_hidden:!0});for(let b=1;b<w.colspan;b++)a[i+b][r].splice(g+v,0,{})}if(w.rowspan){const v=(w.rowspan===c?x:x.slice(g,w.rowspan+g)).reduce((b,k)=>b+k,0);w.height=v,g+w.rowspan!=c&&w.height--}if(w.colspan){let v=h.width,b=h.flexgrow||0;const k=w.colspan;for(let j=1;j<k;j++){const M=a[i+j];M&&(M.hidden?w.colspan-=1:M.flexgrow?b+=M.flexgrow:v+=M.width||d.columnWidth),b?w.flexgrow=b:w.width=v}}else w.width=h.width,w.flexgrow=h.flexgrow;r==="header"&&w.filter&&typeof w.filter=="string"&&(w.filter={type:w.filter})}p.length>c&&(p.length=c),h[r]=p}normalizeRows(a){for(let i=0;i<a.length;i++)a[i].id||(a[i].id=Yu());return a}normalizeTreeRows(a,i,r){return!i&&!r&&(this._branches={0:{data:a}}),a.forEach(c=>{c.id||(c.id=Yu()),c.$level=i||0,c.$parent=r||0,this._branches[c.id]=c,c.data&&(c.data.length?(c.$count=c.data.length,this.normalizeTreeRows(c.data,c.$level+1,c.id)):(delete c.data,delete c.$count,delete c.open))}),a}sortTree(a,i){a.sort(i),a.forEach(r=>{r.data&&this.sortTree(r.data,i)})}filterTree(a,i,r){return a.forEach(c=>{i(c)&&r.push(c.id),c.data&&this.filterTree(c.data,i,r)}),r}flattenRows(a,i,r){const c=i;return a.forEach(d=>{(!r||r.includes(d.id))&&c.push(d),d.data?.length&&d.open!==!1&&this.flattenRows(d.data,c,r)}),c}createFilter(a){const{_columns:i}=this.getState(),r=[];for(const c in a){const d=i.find(g=>g.id==c),{config:h,type:p}=d.header.find(g=>g.filter).filter,x=a[c];r.push(g=>{const w=si(g,d);return h?.handler?h.handler(w,x):Vy(p)(w,x)})}return c=>{for(let d=0;d<r.length;d++)if(!r[d](c))return!1;return!0}}searchRows(a,i){a=a.trim().toLowerCase();const r={};if(!a)return r;const{flatData:c,columns:d}=this.getState(),h=i?d.filter(p=>i[p.id]):d;return c.forEach(p=>{const x={};h.forEach(g=>{const w=ai(p,g);String(w).toLowerCase().includes(a)&&(x[g.id]=!0)}),Object.keys(x).length&&(r[p.id]=x)}),r}normalizeSizes(a,i,r,c,d){const h=xv(a,"header",r,i.headerHeight,d),p=xv(a,"footer",c,i.footerHeight,d),x=h.reduce((w,v)=>w+v,0),g=p.reduce((w,v)=>w+v,0);return{...i,headerRowHeights:h,footerRowHeights:p,headerHeight:x,footerHeight:g}}},VC=new Date().valueOf();function Yu(){return"temp://"+VC++}function KC(n,a="data-id"){let i=n;for(!i.tagName&&n.target&&(i=n.target);i;){if(i.getAttribute&&i.getAttribute(a))return i;i=i.parentNode}return null}new Date().valueOf();var WC=class{constructor(){this.store=new Map}configure(n,a){this.node=a;for(const i in n)if(n[i]){const r=i.toLowerCase().replace(/[ ]/g,""),c=n[i];this.store.set(r,c)}}},Br=[],QC={subscribe:n=>{XC();const a=new WC;return Br.push(a),n(a),()=>{const i=Br.findIndex(r=>r===a);i>=0&&Br.splice(i,1)}}},vv=!1;function XC(){vv||(vv=!0,document.addEventListener("keydown",n=>{if(Br.length&&(n.ctrlKey||n.altKey||n.metaKey||n.shiftKey||n.key.length>1||n.key===" ")){const a=[];n.ctrlKey&&a.push("ctrl"),n.altKey&&a.push("alt"),n.metaKey&&a.push("meta"),n.shiftKey&&a.push("shift");let i=n.code.replace("Key","").toLocaleLowerCase();n.key===" "&&(i="space"),a.push(i);const r=a.join("+");for(let c=Br.length-1;c>=0;c--){const d=Br[c],h=d.store.get(r)||d.store.get(i);h&&d.node.contains(n.target)&&h(n,{key:r,evKey:i})}}}))}const ZC={tab:!0,"shift+tab":!0,arrowup:!0,arrowdown:!0,arrowright:!0,arrowleft:!0,enter:!0,escape:!0,f2:!0,home:!0,end:!0,"ctrl+home":!0,"ctrl+end":!0,"ctrl+z":!0,"ctrl+y":!0};function JC(n,{keys:a,exec:i}){if(!a)return;function r(h){const p=h.target;return p.tagName==="INPUT"||p.tagName==="TEXTAREA"||KC(p,"data-header-id")?.classList.contains("wx-filter")||!!p.closest(".wx-cell.wx-editor")}const c={};for(const h in a){const p=a[h];typeof p<"u"&&(typeof p=="function"?c[h]=p:p&&(c[h]=x=>{const g=r(x);i({key:h,event:x,isInput:g})}))}const d=QC.subscribe(h=>{h.configure(c,n)});return{destroy:()=>{d()}}}function ej(n,a){let i=null;a.scroll.subscribe(r=>{if(!r||r===i)return;i=r;const{left:c,top:d,height:h,width:p}=r,x=a.getHeight(),g=a.getWidth(),w=a.getScrollMargin();if(d>=0){const v=n.scrollTop;d<v?n.scrollTop=d:d+h>v+x&&(n.scrollTop=d-x+h)}if(c>=0){const v=n.scrollLeft;c<v?n.scrollLeft=c:c+p>v+g-w&&(n.scrollLeft=c-g+p+w)}}),a.scrollLeft?.subscribe?.(r=>{requestAnimationFrame(()=>{Math.abs(n.scrollLeft-r)>1&&(n.scrollLeft=r)})}),a.scrollTop?.subscribe?.(r=>{requestAnimationFrame(()=>{Math.abs(n.scrollTop-r)>1&&(n.scrollTop=r)})})}const La=f.createContext(null);function tj(n,a){const i=new ResizeObserver(r=>{requestAnimationFrame(()=>a(r[0].contentRect))});return i.observe(n.parentNode),{destroy(){i.disconnect()}}}const yv=5,nj=700;function ad(n){const a=n.getBoundingClientRect(),i=document.body,r=a.top+i.scrollTop-i.clientTop||0,c=a.left+i.scrollLeft-i.clientLeft||0;return{y:Math.round(r),x:Math.round(c),width:n.offsetWidth,height:n.offsetHeight}}function sh(n,a){const i=ad(a);return{x:n.clientX-i.x,y:n.clientY-i.y}}function aj(n,a){const i=a.current;let r=null,c,d,h=!1,p=!1;const x=document.createElement("DIV");x.className="wx-drag-zone",x.setAttribute("tabindex",-1);function g(){clearTimeout(c),c=null}function w(L){const F=$r(L);F&&(r={container:x,sourceNode:L.target,from:Sd(F),pos:sh(L,n)},d=r.pos,v(L))}function v(L){if(!r)return;const F=r.pos=sh(L,n);if(!h){if(!p&&!L?.target?.getAttribute("draggable-data")&&Math.abs(d.x-F.x)<yv&&Math.abs(d.y-F.y)<yv)return;if(B(L)===!1)return q()}if(p){const ue=window.scrollX||document.documentElement.scrollLeft||document.body.scrollLeft,W=window.scrollY||document.documentElement.scrollTop||document.body.scrollTop;r.targetNode=document.elementFromPoint(L.pageX-ue,L.pageY-W)}else r.targetNode=L.target;i.move&&i.move(L,r),x.style.left=-(r.offset?r.offset.x:0)+"px",x.style.top=r.pos.y+(r.offset?r.offset.y:0)+"px"}function b(L){x.parentNode&&x.parentNode.removeChild(x),x.innerHTML="",h&&i.end&&i.end(L,r),r=d=null,q()}function k(L){i.getReorder&&!i.getReorder()||L.button===0&&(H(L),window.addEventListener("mousemove",j),window.addEventListener("mouseup",M),w(L))}function j(L){v(L)}function M(L){b(L)}function T(L){if(i.getReorder&&!i.getReorder())return;c=setTimeout(()=>{p=!0,w(L.touches[0])},nj),H(L);function F(){c&&g(),L.target.removeEventListener("touchmove",C),L.target.removeEventListener("touchend",F),b(L)}L.target.addEventListener("touchmove",C),L.target.addEventListener("touchend",F),n.addEventListener("contextmenu",A)}function C(L){h?(L.preventDefault(),v(L.touches[0])):c&&g()}function A(L){if(h||c)return L.preventDefault(),!1}function D(L){L.preventDefault()}function H(L){if(!i.getDraggableInfo)return;const{hasDraggable:F}=i.getDraggableInfo();(!F||L.target.getAttribute("draggable-data"))&&(document.body.style.userSelect="none",document.body.style.webkitUserSelect="none")}function B(L){if(h=!0,i.start){if(i.start(L,r)===!1)return!1;n.appendChild(x),document.body.style.cursor="move"}}function q(L){h=p=!1,document.body.style.cursor="",document.body.style.userSelect="",document.body.style.webkitUserSelect="",window.removeEventListener("mousemove",j),window.removeEventListener("mouseup",M),L&&(n.removeEventListener("mousedown",k),n.removeEventListener("touchstart",T),n.removeEventListener("dragstart",D))}return n.addEventListener("mousedown",k),n.addEventListener("touchstart",T),n.addEventListener("dragstart",D),{destroy(){q(!0)}}}const sj=.004;function lj(){return{dirX:0,dirY:0,scrollSpeedFactor:1}}function ij(n,a,i,r){const{node:c,left:d,top:h,bottom:p,sense:x,xScroll:g,yScroll:w}=r,v=sh(n,c);i.scrollState||(i.scrollState=lj());let b=0,k=0;v.x<d+x?b=-1:v.x>a.width-x&&(b=1),v.y<h+Math.round(x/2)?k=-1:v.y>a.height-p-Math.round(x/2)&&(k=1),(i.scrollState.dirX!==b||i.scrollState.dirY!==k)&&(Ky(i),i.scrollState.dirX=b,i.scrollState.dirY=k),(g&&i.scrollState.dirX!==0||w&&i.scrollState.dirY!==0)&&rj(i,r,{x:i.scrollState.dirX,y:i.scrollState.dirY})}function rj(n,a,i){n.autoScrollTimer||(n.autoScrollTimer=setTimeout(()=>{n.activeAutoScroll=setInterval(oj,15,n,a,i)},250))}function Ky(n){n.scrollSpeedFactor=1,n.autoScrollTimer&&(n.autoScrollTimer=clearTimeout(n.autoScrollTimer),n.activeAutoScroll=clearInterval(n.activeAutoScroll))}function oj(n,a,i){const{x:r,y:c}=i;n.scrollSpeedFactor+=sj,r!==0&&uj(n,a,r),c!==0&&cj(n,a,c)}function cj(n,a,i){const r=a.node.scrollTop;Wy(r+Math.round(a.sense/3)*n.scrollSpeedFactor*i,"scrollTop",a)}function uj(n,a,i){const r=a.node.scrollLeft;Wy(r+Math.round(a.sense/3)*n.scrollSpeedFactor*i,"scrollLeft",a)}function Wy(n,a,i){i.node[a]=n}function Md(n,a,i,r,c,d){const h={};return n&&(h.width=`${n}px`,h.minWidth=`${n}px`),a&&(h.flexGrow=a),d&&(h.height=`${d}px`),i&&(h.position="sticky",i.left&&(h.left=`${r}px`),i.right&&(h.right=`${c}px`)),h}function Qy(n,a,i){let r="";if(n.fixed)for(const c in n.fixed){let d=n.fixed[c]===-1;!d&&n.fixed.leftSize&&a.colspan&&(d=a.colspan+n._colindex-1===n.fixed.leftSize),r+=d?"wx-shadow ":"wx-fixed "}return r+=a.rowspan>1?"wx-rowspan ":"",r+=a.colspan>1?"wx-colspan ":"",r+=a.vertical?"wx-vertical ":"",r+=i?i(n)+" ":"",r}function dj(n){const{row:a,column:i,cellStyle:r=null,columnStyle:c=null,children:d,focusable:h}=n,p=f.useContext(La),x=Xe(p,"focusCell"),g=Xe(p,"search"),w=Xe(p,"reorder"),v=f.useMemo(()=>g?.rows[a.id]&&g.rows[a.id][i.id],[g,a.id,i.id]),b=f.useMemo(()=>Md(i.width,i.flexgrow,i.fixed,i.left,i.right),[i.width,i.flexgrow,i.fixed,i.left,i.right]);function k(B,q){let L="wx-cell";return L+=i.fixed?" "+(i.fixed===-1?"wx-shadow":"wx-fixed"):"",L+=B?" "+B(i):"",L+=q?" "+q(a,i):"",L+=i.treetoggle?" wx-tree-cell":"",L}const j=f.useMemo(()=>k(c,r),[c,r,i,a]),M=f.useMemo(()=>typeof i.draggable=="function"?i.draggable(a,i)!==!1:i.draggable,[i,a]),T=f.useRef(null);f.useEffect(()=>{T.current&&h&&x?.row===a.id&&x?.column===i.id&&T.current.focus()},[x,h,a.id,i.id]);const C=f.useCallback(()=>{h&&!x&&p.exec("focus-cell",{row:a.id,column:i.id,eventSource:"focus"})},[p,h,x,a.id,i.id]);function A(B){const q=new RegExp(`(${g.value.trim()})`,"gi");return String(B).split(q).map(L=>({text:L,highlight:q.test(L)}))}const D=f.useMemo(()=>{const B=i.fixed&&i.fixed.left===-1||i.fixed.right===-1,q=i.fixed&&i.fixed.right;return[j,B?"wx-shadow":"",q?"wx-fixed-right":""].filter(Boolean).join(" ")},[j,i]),H=i.cell;return l.jsxs("div",{className:"wx-TSCaXsGV "+D,ref:T,onFocus:C,style:b,"data-row-id":Cn(a.id),"data-col-id":Cn(i.id),tabIndex:h?"0":"-1",role:"gridcell","aria-colindex":i._colindex,"aria-readonly":i.editor?void 0:!0,children:[w&&i.draggable?M?l.jsx("i",{"draggable-data":"true",className:"wx-TSCaXsGV wx-draggable wxi-drag"}):l.jsx("i",{className:"wx-TSCaXsGV wx-draggable-stub"}):null,i.treetoggle?l.jsxs(l.Fragment,{children:[l.jsx("span",{style:{marginLeft:`${a.$level*28}px`}}),a.$count?l.jsx("i",{"data-action":"toggle-row",className:`wx-TSCaXsGV wx-table-tree-toggle wxi-menu-${a.open!==!1?"down":"right"}`}):null]}):null,H?l.jsx(H,{api:p,row:a,column:i,onAction:({action:B,data:q})=>p.exec(B,q)}):d?d():v?l.jsx("span",{children:A(ai(a,i)).map(({highlight:B,text:q},L)=>B?l.jsx("mark",{className:"wx-TSCaXsGV wx-search",children:q},L):l.jsx("span",{children:q},L))}):ai(a,i)]})}function wv(n,a){let i,r;function c(p){i=p.clientX,n.style.opacity=1,document.body.style.cursor="ew-resize",document.body.style.userSelect="none",window.addEventListener("mousemove",d),window.addEventListener("mouseup",h),a&&a.down&&a.down(n)}function d(p){r=p.clientX-i,a&&a.move&&a.move(r)}function h(){n.style.opacity="",document.body.style.cursor="",document.body.style.userSelect="",a&&a.up&&a.up(r),window.removeEventListener("mousemove",d),window.removeEventListener("mouseup",h)}return n.addEventListener("mousedown",c),{destroy(){n.removeEventListener("mousedown",c)}}}function fj({filter:n,column:a,action:i,filterValue:r}){function c({value:d}){i({value:d,key:a.id})}return l.jsx(Mh,{...n.config??{},value:r,onChange:c})}function mj({filter:n,column:a,action:i,filterValue:r}){const c=f.useContext(La),d=Xe(c,"flatData"),h=f.useMemo(()=>n?.config?.options||a?.options||x(),[n,a,d]),p=f.useMemo(()=>n?.config?.template,[n]);function x(){const v=[];return d.forEach(b=>{const k=si(b,a);v.includes(k)||v.push(k)}),v.map(b=>({id:b,label:b}))}function g({value:v}){i({value:v,key:a.id})}function w(v){v.key!=="Tab"&&v.preventDefault()}return l.jsx("div",{style:{width:"100%"},onKeyDown:w,children:l.jsx(A1,{placeholder:"",clear:!0,...n?.config??{},options:h,value:r,onChange:g,children:v=>p?p(v):v.label})})}function hj({filter:n,column:a,action:i,filterValue:r}){function c({value:d}){i({value:d,key:a.id})}return l.jsx("div",{className:"wx-aaaK5VYO",style:{width:"100%"},children:l.jsx(M1,{placeholder:"",clear:!0,...n?.config??{},value:r,onChange:c})})}function Xy(n){const{value:a,options:i=[],placeholder:r="",clear:c=!1,text:d=null,template:h=null,cell:p=null,dropdown:x={},autoOpen:g=!1,onChange:w,onAction:v}=n,[b,k]=_y(a||[]),j=f.useMemo(()=>(b||[]).map(W=>i.find(ce=>ce.id===W)).filter(Boolean),[b,i]),M=f.useRef(null),T=f.useRef(null),[C,A]=f.useState(null),D=()=>{const W=b||[];if(!W.length)return 0;const ce=i.find(Q=>W.includes(Q.id));return ce?i.indexOf(ce):0};function H(W){T.current=W.navigate,A(()=>W.keydown),g&&W.navigate(D())}f.useEffect(()=>{g&&(M.current?.focus(),typeof window<"u"&&window.getSelection&&window.getSelection().removeAllRanges())},[]);function B({id:W}){k(W),w&&w({value:W})}function q(W){W.stopPropagation(),k([]),w&&w({value:[]})}function L(){T.current?.(D())}function F(){T.current?.(null)}function ue(W){C?.(W,D())}return l.jsxs("div",{ref:M,className:"wx-multiselect wx-aadNNOwy",onClick:L,onKeyDown:ue,tabIndex:0,children:[l.jsx("div",{className:"wx-label wx-aadNNOwy",children:h?h(j):p?l.jsx(p,{data:j,onAction:v}):d?l.jsx("span",{className:"wx-text wx-aadNNOwy",children:d}):j.length?l.jsx("span",{className:"wx-text wx-aadNNOwy",children:j.map(W=>W.label).join(", ")}):r?l.jsx("span",{className:"wx-placeholder wx-aadNNOwy",children:r}):" "}),c&&b?.length?l.jsx("i",{className:"wx-icon wxi-close wx-aadNNOwy",onClick:q}):l.jsx("i",{className:"wx-icon wxi-angle-down wx-aadNNOwy"}),l.jsx(jd,{items:i,onReady:H,onSelect:B,multiselect:!0,checkboxes:!0,value:b||[],onCancel:F,...x,children:({option:W})=>l.jsx("div",{className:"wx-option wx-aadNNOwy",children:h?h(W):p?l.jsx(p,{data:W,onAction:v}):W.label})})]})}function pj({filter:n,column:a,action:i,filterValue:r}){const c=f.useContext(kn.i18n)?.getGroup("grid")||gc(Th).getGroup("grid"),d=f.useMemo(()=>({clear:!0,...n?.config||{}}),[n]),h=f.useMemo(()=>d.options||a.options,[d,a]),p=f.useMemo(()=>{const w=r?.length;return w?w<3?r.map(v=>a.optionsMap.get(v)).join(", "):w+" "+c("selected"):""},[r,a,c]);function x({value:w}){i({value:w,key:a.id})}function g(w){w.key!=="Tab"&&w.preventDefault()}return l.jsx("div",{style:{width:"100%"},onKeyDown:g,children:l.jsx(Xy,{placeholder:"",...d,options:h,value:r||[],text:p,onChange:x})})}const gj={text:fj,richselect:mj,datepicker:hj,multiselect:pj};function xj({filter:n,column:a}){const i=f.useContext(La),r=Xe(i,"filterValues");function c(h){i.exec("filter-rows",h)}const d=f.useMemo(()=>gj[n.type],[n.type]);return l.jsx(d,{filter:n,column:a,action:c,filterValue:r[a.id]})}function vj(n){const{cell:a,column:i,row:r,lastRow:c,sortRow:d,columnStyle:h,bodyHeight:p,hasSplit:x}=n,g=f.useContext(La),w=Xe(g,"sortMarks"),v=f.useMemo(()=>w?w[i.id]:void 0,[w,i.id]),b=f.useRef(),k=f.useCallback(oe=>{b.current=a.flexgrow?oe.parentNode.clientWidth:a.width},[a.flexgrow,a.width]),j=f.useCallback((oe,K)=>{g.exec("resize-column",{id:a.id,width:Math.max(1,(b.current||0)+oe),inProgress:K})},[g,a.id]),M=f.useCallback(oe=>j(oe,!0),[j]),T=f.useCallback(oe=>j(oe,!1),[j]),C=f.useCallback(oe=>{if(!i.sort||a.filter)return;let K=v?.order;K&&(K=K==="asc"?"desc":"asc"),g.exec("sort-rows",{key:a.id,add:oe.ctrlKey||oe.metaKey,order:K})},[g,a.id,a.filter,i.sort,v?.order]),A=f.useCallback(oe=>{oe&&oe.stopPropagation(),g.exec("collapse-column",{id:a.id,row:r})},[g,a.id,r]),D=f.useCallback(oe=>{oe.key==="Enter"&&A()},[A]),H=f.useCallback(oe=>{oe.key==="Enter"&&!a.filter&&C(oe)},[C,a.filter]),B=f.useMemo(()=>a.collapsed&&i.collapsed,[a.collapsed,i.collapsed]),q=f.useMemo(()=>B&&!x&&a.collapsible!=="header",[B,x,a.collapsible]),L=f.useMemo(()=>q?{top:-p/2,position:"absolute"}:{},[q,p]),F=f.useMemo(()=>Md(a.width,a.flexgrow,i.fixed,i.left,a.right??i.right,a.height+(B&&q?p:0)),[a.width,a.flexgrow,i.fixed,i.left,a.right,i.right,a.height,B,q,p]),ue=f.useMemo(()=>Qy(i,a,h),[i,a,h]),W=f.useCallback(()=>Object.fromEntries(Object.entries(a).filter(([oe])=>oe!=="cell")),[a]),ce=`wx-cell ${ue} ${a.css||""} wx-collapsed`,Q=["wx-cell",ue,a.css||"",a.filter?"wx-filter":"",i.fixed&&i.fixed.right?"wx-fixed-right":""].filter(Boolean).join(" "),se=f.useRef(null);return f.useEffect(()=>{const oe=se.current;if(!oe)return;const K=wv(oe,{down:k,move:M,up:T});return()=>{typeof K=="function"&&K()}},[k,M,T,wv]),B?l.jsx("div",{className:"wx-RsQD74qC "+ce,style:F,role:"button","aria-label":`Expand column ${a.text||""}`,"aria-expanded":!a.collapsed,tabIndex:0,onKeyDown:D,onClick:A,"data-header-id":Cn(i.id),children:l.jsx("div",{className:"wx-RsQD74qC wx-text",style:L,children:a.text||""})}):l.jsxs("div",{className:"wx-RsQD74qC "+Q,style:F,onClick:C,"data-header-id":Cn(i.id),tabIndex:!a._hidden&&i.sort&&!a.filter?0:void 0,role:"columnheader","aria-colindex":i._colindex,"aria-colspan":a.colspan>1?a.colspan:void 0,"aria-rowspan":a.rowspan>1?a.rowspan:void 0,"aria-sort":!v?.order||a.filter?"none":v?.order==="asc"?"ascending":"descending",onKeyDown:H,children:[a.collapsible?l.jsx("div",{className:"wx-RsQD74qC wx-collapse",role:"button","aria-label":a.collapsed?"Expand column":"Collapse column","aria-expanded":!a.collapsed,tabIndex:0,onKeyDown:D,onClick:A,children:l.jsx("i",{className:`wx-RsQD74qC wxi-angle-${a.collapsed?"down":"right"}`})}):null,a.cell?(()=>{const oe=a.cell;return l.jsx(oe,{api:g,cell:W(),column:i,row:r,onAction:({action:K,data:z})=>g.exec(K,z)})})():a.filter?l.jsx(xj,{filter:a.filter,column:i}):l.jsx("div",{className:"wx-RsQD74qC wx-text",children:a.text||""}),i.resize&&c&&!a._hidden?l.jsx("div",{className:"wx-RsQD74qC wx-grip",role:"presentation","aria-label":"Resize column",ref:se,onClick:oe=>oe.stopPropagation(),children:l.jsx("div",{})}):null,d?l.jsx("div",{className:"wx-RsQD74qC wx-sort",children:v?l.jsxs(l.Fragment,{children:[typeof v.index<"u"?l.jsx("div",{className:"wx-RsQD74qC wx-order",children:v.index+1}):null,l.jsx("i",{className:`wx-RsQD74qC wxi-arrow-${v.order==="asc"?"up":"down"}`})]}):null}):null]})}function yj({cell:n,column:a,row:i,columnStyle:r}){const c=f.useContext(La),d=f.useMemo(()=>Md(n?.width,n?.flexgrow,a?.fixed,a?.left,n?.right??a?.right,n?.height),[n?.width,n?.flexgrow,a?.fixed,a?.left,n?.right,a?.right,n?.height]),h=f.useMemo(()=>Qy(a,n,r),[a,n,r]),p=f.useCallback(()=>Object.fromEntries(Object.entries(n||{}).filter(([g])=>g!=="cell")),[n]),x=`wx-6Sdi3Dfd wx-cell ${h||""} ${n?.css||""}`+(a?.fixed&&a?.fixed.right?" wx-fixed-right":"");return l.jsx("div",{className:x,style:d,children:!a?.collapsed&&!n?.collapsed?n?.cell?ph.createElement(n.cell,{api:c,cell:p(),column:a,row:i,onAction:({action:g,data:w})=>c.exec(g,w)}):l.jsx("div",{className:"wx-6Sdi3Dfd wx-text",children:n?.text||""}):null})}function bv({deltaLeft:n,contentWidth:a,columns:i,type:r="header",columnStyle:c,bodyHeight:d}){const h=f.useContext(La),p=Xe(h,"_sizes"),x=Xe(h,"split"),g=f.useMemo(()=>p?.[`${r}RowHeights`],[p,r]),w=f.useMemo(()=>{let M=[];if(i&&i.length){const T=i[0][r].length;for(let C=0;C<T;C++){let A=0;M.push([]),i.forEach((D,H)=>{const B={...D[r][C]};A||M[C].push(B),B.colspan>1?A=B.colspan-1:A&&A--})}}return M},[i,r]),v=f.useMemo(()=>x?.left||x?.right,[x]);function b(M){return i.find(T=>T.id===M)}function k(M,T){let C=T;return M.rowspan&&(C+=M.rowspan-1),C===w.length-1}function j(M,T,C){if(!C.sort)return!1;for(let A=w.length-1;A>=0;A--){const D=C.header[A];if(!D.filter&&!D._hidden)return T===A}return k(M,T)}return l.jsx("div",{className:`wx-sAsPVaUK wx-${r}`,style:{paddingLeft:`${n}px`,width:`${a}px`},role:"rowgroup",children:w.map((M,T)=>l.jsx("div",{className:r==="header"?"wx-sAsPVaUK wx-h-row":"wx-sAsPVaUK wx-f-row",style:{height:`${g?.[T]}px`,display:"flex"},role:"row",children:M.map(C=>{const A=b(C.id);return r==="header"?l.jsx(vj,{cell:C,columnStyle:c,column:A,row:T,lastRow:k(C,T),bodyHeight:d,sortRow:j(C,T,A),hasSplit:v},C.id):l.jsx(yj,{cell:C,columnStyle:c,column:b(C.id),row:T},C.id)})},T))})}function wj({overlay:n}){const a=f.useContext(La);function i(c){return typeof c=="function"}const r=n;return l.jsx("div",{className:"wx-1ty666CQ wx-overlay",children:i(n)?l.jsx(r,{onAction:({action:c,data:d})=>a.exec(c,d)}):n})}function bj(n){const{editor:a,onSave:i,onApply:r}=n,[c,d]=f.useState(a?.value||""),{type:h="text"}=f.useMemo(()=>a?.config||{},[a]),p=f.useRef(null);f.useEffect(()=>{p.current&&p.current.focus()},[]),f.useEffect(()=>{if(!p.current)return;const w=zs(p.current,()=>i(!0));return()=>w.destroy()},[i]);function x(){p.current&&(d(p.current.value),r(p.current.value))}function g({key:w}){w==="Enter"&&i()}return l.jsx("input",{className:"wx-e7Ao5ejY wx-text",onInput:x,onKeyDown:g,ref:p,type:h,value:c})}function Sj({editor:n,onAction:a,onSave:i,onApply:r,onCancel:c}){const[d,h]=f.useState(n?.value),[p,x]=f.useState(n?.renderedValue),[g,w]=f.useState(n?.options||[]),v=f.useMemo(()=>n?.config?.template,[n]),b=f.useMemo(()=>n?.config?.cell,[n]),k=f.useMemo(()=>n?.config?.dropdown||{},[n]),j=f.useMemo(()=>({trackScroll:!0,...k}),[k]),M=f.useMemo(()=>(g||[]).findIndex(L=>L.id===d),[g,d]),T=f.useRef(null),C=f.useRef(null),A=f.useCallback(L=>{T.current=L.navigate,C.current=L.keydown,T.current(M)},[M,T]),D=f.useCallback(L=>{const F=L?.target?.value??"";x(F);const ue=F?(n?.options||[]).filter(W=>(W.label||"").toLowerCase().includes(F.toLowerCase())):n?.options||[];w(ue),ue.length?T.current(-1/0):T.current(null)},[n]),H=f.useRef(null);f.useEffect(()=>{H.current&&H.current.focus()},[]);const B=f.useRef(i);f.useEffect(()=>{B.current=i},[i]),f.useEffect(()=>{if(!H.current)return;const L=zs(H.current,()=>B.current(!0));return()=>L.destroy()},[]),f.useEffect(()=>{h(n?.value),x(n?.renderedValue),w(n?.options||[])},[n]);const q=f.useCallback(({id:L})=>{r(L),i()},[r,i]);return l.jsxs(l.Fragment,{children:[l.jsx("input",{className:"wx-0UYfSd1x wx-input",ref:H,value:p??"",onChange:D,onKeyDown:L=>C.current?C.current(L,M):void 0}),l.jsx(jd,{items:g,onReady:A,onSelect:q,...j,onCancel:c,children:({option:L})=>v?v(L):b?l.jsx(b,{data:L,onAction:a}):L.label})]})}function Cj({editor:n,onAction:a,onSave:i,onApply:r,onCancel:c}){const[d]=f.useState(()=>n.value||new Date),{template:h,cell:p,dropdown:x={}}=n?.config||{},g=f.useMemo(()=>({trackScroll:!0,width:"auto",...x}),[x]);function w({value:j}){r(j),i()}const v=f.useRef(null),[b,k]=f.useState(null);return f.useEffect(()=>{v.current&&v.current.focus(),typeof window<"u"&&window.getSelection&&window.getSelection().removeAllRanges()},[]),f.useEffect(()=>{if(!b)return;const j=zs(b,()=>i(!0));return()=>j.destroy()},[b,i]),l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"wx-lNWNYUb6 wx-value",ref:v,tabIndex:0,onClick:c,onKeyDown:j=>j.preventDefault(),children:h?h(d):p?l.jsx(p,{data:n.value,onAction:a}):l.jsx("span",{className:"wx-lNWNYUb6 wx-text",children:n.renderedValue})}),l.jsx(kh,{...g,onCancel:c,children:l.jsx("div",{ref:k,className:"wx-lNWNYUb6",children:l.jsx(Ry,{value:d,onChange:w,buttons:n.config?.buttons})})})]})}function jj(n){const{editor:a}=n,i=n.onAction??n.onaction,r=n.onSave??n.onsave,c=n.onApply??n.onapply,d=n.onCancel??n.oncancel,h=a.config||{},{dropdown:p={}}=h,x=f.useMemo(()=>({trackScroll:!0,...p}),[p]),[g]=f.useState(a.options.find(D=>D.id===a.value)),[w]=f.useState(a.value),[v]=f.useState(a.options),b=f.useMemo(()=>v.findIndex(D=>D.id===w),[v,w]);function k({id:D}){c(D),r()}let j;const[M,T]=f.useState();function C(D){j=D.navigate,T(()=>D.keydown),j(b)}const A=f.useRef(null);return f.useEffect(()=>{A.current&&A.current.focus(),typeof window<"u"&&window.getSelection&&window.getSelection().removeAllRanges()},[]),f.useEffect(()=>{if(!A.current)return;const D=zs(A.current,()=>r(!0));return()=>D.destroy()},[r]),l.jsxs(l.Fragment,{children:[l.jsx("div",{ref:A,className:"wx-ywGRk611 wx-value",tabIndex:0,onClick:d,onKeyDown:D=>{M(D,b),D.preventDefault()},children:h.template?h.template(g):h.cell?(()=>{const D=h.cell;return l.jsx(D,{data:g,onAction:i})})():l.jsx("span",{className:"wx-ywGRk611 wx-text",children:a.renderedValue})}),l.jsx(jd,{items:v,onReady:C,onSelect:k,...x,onCancel:d,children:({option:D})=>h.template?h.template(D):h.cell?(()=>{const H=h.cell;return l.jsx(H,{data:D,onAction:i})})():D.label})]})}function kj(n){const{editor:a,onAction:i,onSave:r,onApply:c}=n,d=a?.config||{},h=a?.options??[],p=a?.value||[],x=a?.renderedValue,g=f.useMemo(()=>({trackScroll:!0,...d.dropdown||{}}),[d]);function w({value:b}){c(b)}const v=f.useRef(null);return f.useEffect(()=>{if(!v.current)return;const b=zs(v.current,()=>r(!0));return()=>b.destroy()},[r]),l.jsx("div",{ref:v,className:"wx-value wx-aacZ4gNU",onClick:()=>r(!0),children:l.jsx(Xy,{value:p,options:h,text:x,template:d.template,cell:d.cell,clear:d.clear,dropdown:g,autoOpen:!0,onChange:w,onAction:i})})}const Mj={text:bj,combo:Sj,datepicker:Cj,richselect:jj,multiselect:kj};function Aj({column:n,row:a}){const i=f.useContext(La),r=Xe(i,"editor"),c=f.useCallback((j,M)=>{i.exec("close-editor",{ignore:j}),M&&i.exec("focus-cell",{...M,eventSource:"click"})},[i]),d=f.useCallback(j=>{const M=j?null:{row:r?.id,column:r?.column};c(!1,M)},[r,c]),h=f.useCallback(()=>{c(!0,{row:r?.id,column:r?.column})},[r,c]),p=f.useCallback(j=>{i.exec("editor",{value:j})},[i]),x=f.useCallback(j=>{j.key==="Enter"&&r&&(n.editor.type==="multiselect"?p(r.value):h())},[r,n.editor,h,p]),g=f.useMemo(()=>Md(n.width,n.flexgrow,n.fixed,n.left,n.right),[n.width,n.flexgrow,n.fixed,n.left,n.right]),w=f.useMemo(()=>{let j=n.editor;if(typeof j=="function"&&(j=j(a,n)),!j)return null;let M=typeof j=="string"?j:j.type;return Mj[M]},[n,a]),v=f.useRef(null);f.useEffect(()=>{v.current&&typeof g=="string"&&v.current.setAttribute("style",g)},[g]);const b=typeof a.$parent<"u"?"gridcell":"cell",k=typeof a.$parent<"u"?!n.editor:void 0;return l.jsx("div",{className:"wx-8l724t2g wx-cell wx-editor",ref:v,style:typeof g=="object"&&g!==null?g:void 0,role:b,"aria-readonly":k,tabIndex:-1,onClick:j=>j.stopPropagation(),onDoubleClick:j=>j.stopPropagation(),onKeyDown:x,children:w?l.jsx(w,{editor:r,onSave:d,onApply:p,onCancel:h,onAction:({action:j,data:M})=>i.exec(j,M)}):null})}function Sv(n){const{columns:a,type:i,columnStyle:r}=n,c=f.useContext(La),{filterValues:d,_columns:h,_sizes:p}=c.getState();function x(g){return r?" "+r(g):""}return l.jsx(l.Fragment,{children:a.map((g,w)=>l.jsx("tr",{children:g.map(v=>{const b=h.find(M=>M.id===v.id),k=`wx-print-cell-${i}${x(b)}${v.filter?" wx-print-cell-filter":""}${v.vertical?" wx-vertical":""}`,j=v.cell;return l.jsx("th",{style:Oy(Gy(v,p.columnWidth)),className:"wx-Gy81xq2u "+k,rowSpan:v.rowspan,colSpan:v.colspan,children:j?l.jsx(j,{api:c,cell:Object.fromEntries(Object.entries(v).filter(([M])=>M!=="cell")),column:b,row:w}):v.filter?l.jsx("div",{className:"wx-Gy81xq2u wx-print-filter",children:EC(d,h,v)}):l.jsx("div",{className:"wx-Gy81xq2u wx-text",children:v.text??""})},v.id)})},w))})}function Nj(n){const{columns:a,rowStyle:i,columnStyle:r,cellStyle:c,header:d,footer:h,reorder:p}=n,x=f.useContext(La),{flatData:g,_sizes:w}=x.getState(),v=d&&pv(a,"header",w.headerRowHeights),b=h&&pv(a,"footer",w.footerRowHeights);function k(M,T){let C="";return C+=r?" "+r(T):"",C+=c?" "+c(M,T):"",C}function j(M,T){return typeof T.draggable=="function"?T.draggable(M,T)!==!1:T.draggable}return l.jsxs("table",{className:`wx-8NTMLH0z wx-print-grid ${a.some(M=>M.flexgrow)?"wx-flex-columns":""}`,children:[d?l.jsx("thead",{children:l.jsx(Sv,{columns:v,type:"header",columnStyle:r})}):null,l.jsx("tbody",{children:g.map((M,T)=>l.jsx("tr",{className:"wx-8NTMLH0z wx-row"+(i?" "+i(M):""),style:{height:`${M.rowHeight||w.rowHeight}px`},children:a.map(C=>C.collapsed?null:l.jsxs("td",{className:`wx-8NTMLH0z wx-print-cell wx-cell ${k(M,C)}`,style:Oy(Gy(C,w.columnWidth)),children:[p&&C.draggable?l.jsx("span",{className:"wx-8NTMLH0z wx-print-draggable",children:j(M,C)?l.jsx("i",{className:"wx-8NTMLH0z wxi-drag"}):null}):null,C.treetoggle?l.jsxs(l.Fragment,{children:[l.jsx("span",{style:{marginLeft:M.$level*28+"px"}}),M.$count?l.jsx("i",{className:`wx-8NTMLH0z wx-print-grid-tree-toggle wxi-menu-${M.open!==!1?"down":"right"}`}):null]}):null,C.cell?(()=>{const A=C.cell;return l.jsx(A,{api:x,row:M,column:C})})():l.jsx("span",{children:ai(M,C)})]},C.id))},T))}),h?l.jsx("tfoot",{children:l.jsx(Sv,{columns:b,type:"footer",columnStyle:r})}):null]})}function Tj(n){const{config:a,...i}=n,r=f.useContext(La),{_skin:c,_columns:d}=r.getState(),h=f.useMemo(()=>AC(d,a),[]),p=f.useRef(null);return f.useEffect(()=>{const x=document.body;x.classList.add("wx-print");const g=p.current;if(!g)return;const w=g.cloneNode(!0);x.appendChild(w);const v=`@media print { @page { size: ${a.paper} ${a.mode}; }`,b=document.createElement("style");b.setAttribute("type","text/css"),b.setAttribute("media","print"),document.getElementsByTagName("head")[0].appendChild(b),b.appendChild(document.createTextNode(v)),window.print(),b.remove(),x.classList.remove("wx-print"),w.remove()},[]),l.jsx("div",{className:`wx-4zwCKA7C wx-${c}-theme wx-print-container`,ref:p,children:h.map((x,g)=>l.jsx("div",{className:"wx-4zwCKA7C wx-print-grid-wrapper",children:l.jsx(Nj,{columns:x,...i})},g))})}function Rj(n){const{header:a,footer:i,overlay:r,multiselect:c,onreorder:d,rowStyle:h,columnStyle:p,cellStyle:x,autoRowHeight:g,resize:w,clientWidth:v,clientHeight:b,responsiveLevel:k,hotkeys:j}=n,M=f.useContext(La),T=Xe(M,"dynamic"),C=Xe(M,"_columns"),A=Xe(M,"flatData"),D=Xe(M,"split"),H=Xe(M,"_sizes"),[B,q]=Xa(M,"selectedRows"),L=Xe(M,"select"),F=Xe(M,"editor"),ue=Xe(M,"scrollLeft"),W=Xe(M,"scrollTop"),ce=Xe(M,"tree"),Q=Xe(M,"focusCell"),se=Xe(M,"_print"),oe=Xe(M,"undo"),K=Xe(M,"reorder"),z=Xe(M,"_rowHeightFromData"),[Y,U]=f.useState(0);f.useEffect(()=>{U(Ia())},[]);const[R,J]=f.useState(0),he=f.useMemo(()=>(C||[]).some(X=>!X.hidden&&X.flexgrow),[C]),$=f.useMemo(()=>H?.rowHeight||0,[H]),ie=f.useRef(null),[we,me]=f.useState(null),[ze,Pe]=f.useState(null),de=f.useMemo(()=>{let X=[],Se=0;return D&&D.left&&(X=(C||[]).slice(0,D.left).filter(De=>!De.hidden).map(De=>({...De})),X.forEach(De=>{De.fixed={left:1,leftSize:D.left},De.left=Se,Se+=De.width}),X.length&&(X[X.length-1].fixed.left=-1)),{columns:X,width:Se}},[D,C]),He=f.useMemo(()=>{let X=[],Se=0;if(D&&D.right){X=(C||[]).slice(D.right*-1).filter(De=>!De.hidden).map(De=>({...De}));for(let De=X.length-1;De>=0;De--){const Je=X[De];Je.fixed={right:1},Je.right=Se,Se+=Je.width}X.length&&(X[0].fixed={right:-1})}return{columns:X,width:Se}},[D,C]),Le=f.useMemo(()=>{const X=(C||[]).slice(D?.left||0,(C||[]).length-(D?.right??0)).filter(Se=>!Se.hidden);return X.forEach(Se=>{Se.fixed=0}),X},[C,D]),Fe=f.useMemo(()=>(C||[]).reduce((X,Se)=>(Se.hidden||(X+=Se.width),X),0),[C]),qe=1;function ne(X,Se,De){let Je=Se,Tt=X;if(Le.length){let ut=Le.length;for(let Ue=X;Ue>=0;Ue--)Le[Ue][De].forEach(at=>{at.colspan>1&&Ue>X-at.colspan&&Ue<ut&&(ut=Ue)});if(ut!==Le.length&&ut<X){for(let Ue=ut;Ue<X;Ue++)Je-=Le[Ue].width;Tt=ut}}return{index:Tt,delta:Je}}const ye=f.useMemo(()=>{let X,Se,De;const Je=ue||0,Tt=(ue||0)+(v||0);let ut=0,Ue=0,at=0,Rt=0;Le.forEach((Vt,It)=>{Je>at&&(ut=It,Rt=at),at=at+Vt.width,Tt>at&&(Ue=It+qe)});const _t={header:0,footer:0};for(let Vt=Ue;Vt>=ut;Vt--)["header","footer"].forEach(It=>{Le[Vt]&&Le[Vt][It].forEach(xl=>{const ss=xl.colspan;if(ss&&ss>1){const Cs=ss-(Ue-Vt+1);Cs>0&&(_t[It]=Math.max(_t[It],Cs))}})});const Yt=ne(ut,Rt,"header"),xt=ne(ut,Rt,"footer"),Ot=Yt.delta,vt=Yt.index,Wn=xt.delta,Qn=xt.index;return he&&Fe>(v||0)?X=Se=De=[...de.columns,...Le,...He.columns]:(X=[...de.columns,...Le.slice(ut,Ue+1),...He.columns],Se=[...de.columns,...Le.slice(vt,Ue+_t.header+1),...He.columns],De=[...de.columns,...Le.slice(Qn,Ue+_t.footer+1),...He.columns]),{data:X||[],header:Se||[],footer:De||[],d:Rt,df:Wn,dh:Ot}},[Le,de,He,ue,v,he,Fe]),be=f.useMemo(()=>a&&H?.headerHeight||0,[a,H]),Z=f.useMemo(()=>i&&H?.footerHeight||0,[i,H]),le=f.useMemo(()=>v&&b?Fe>=v:!1,[v,b,Fe]),[Me,je]=f.useState(!1),ct=f.useMemo(()=>(b||0)-be-Z-(le?Y:0),[b,be,Z,le,Y]),sn=f.useMemo(()=>Math.ceil((ct||0)/($||1))+1,[ct,$]),ke=f.useRef([]),[Ne,Oe]=f.useState(0),[Dt,Za]=f.useState(void 0),Nt=f.useMemo(()=>{let X=0,Se=0;const De=2,Je=W||0;if(g){let Ue=Je;for(;Ue>0;)Ue-=ke.current[X]||$,X++;Se=Je-Ue;for(let at=Math.max(0,X-De-1);at<X;at++)Se-=ke.current[X-at]||$;X=Math.max(0,X-De)}else{if(z){let Ue=0,at=0;for(let xt=0;xt<(A||[]).length;xt++){const Ot=A[xt].rowHeight||$;if(at+Ot>Je){Ue=xt;break}at+=Ot}X=Math.max(0,Ue-De);for(let xt=0;xt<X;xt++)Se+=A[xt].rowHeight||$;let Rt=0,_t=0;for(let xt=Ue+1;xt<(A||[]).length;xt++){const Ot=A[xt].rowHeight||$;if(Rt++,_t+Ot>ct)break;_t+=Ot}const Yt=Math.min(T?T.rowCount:(A||[]).length,Ue+Rt+De);return{d:Se,start:X,end:Yt}}X=Math.floor(Je/($||1)),X=Math.max(0,X-De),Se=X*($||0)}const Tt=T?T.rowCount:(A||[]).length,ut=Math.min(Tt,X+(sn||0)+De);return{d:Se,start:X,end:ut}},[g,z,W,$,T,A,sn,ct]),Gn=f.useMemo(()=>{const X=T?T.rowCount:(A||[]).length;if(g)return Ne+Nt.d+(X-(Dt||0))*($||0);if(!z)return X*($||0);let Se=0;for(let De=0;De<X;De++)Se+=A[De]?.rowHeight||$;return Se},[T,A,$,g,z,Ne,Nt.d,Dt]),ii=f.useRef({});ii.current={clientWidth:v,clientHeight:b,fullHeight:Gn,headerHeight:be,footerHeight:Z,fullWidth:Fe,SCROLLSIZE:Y};const Te=f.useCallback(()=>{const X=ii.current;je(X.clientWidth&&X.clientHeight?X.fullHeight+X.headerHeight+X.footerHeight>=X.clientHeight-(X.fullWidth>=X.clientWidth?X.SCROLLSIZE:0):!1)},[]);f.useEffect(()=>{const X=requestAnimationFrame(Te);return()=>window.cancelAnimationFrame(X)},[R,Te]),f.useEffect(()=>{Te()},[b,Te]);const za=f.useMemo(()=>he&&Fe<=(v||0)?(v||0)-0-(Me?Y:0):Fe,[he,Fe,v,Me,Y,le]),Ze=f.useMemo(()=>he&&Fe<=(v||0)?v||0:za<(v||0)?Fe+(Me?Y:0):-1,[he,Fe,v,za,Me,Y]),_a=f.useRef({});f.useEffect(()=>{if(T&&(_a.current.start!==Nt.start||_a.current.end!==Nt.end)){const{start:X,end:Se}=Nt;_a.current={start:X,end:Se},M&&M.exec&&M.exec("request-data",{row:{start:X,end:Se}})}},[T,Nt,M]);const Ke=f.useMemo(()=>T?A||[]:(A||[]).slice(Nt.start,Nt.end),[T,A,Nt]),yn=f.useMemo(()=>(B||[]).filter(X=>(Ke||[]).some(Se=>Se.id===X)),[q,Ke]),qt=f.useMemo(()=>Nt.start,[Nt.start]),_s=f.useRef({top:W,left:ue});_s.current={top:W,left:ue};const Gt=f.useCallback(X=>{const Se=X.target.scrollTop,De=X.target.scrollLeft,Je=_s.current;(Se!==Je.top||De!==Je.left)&&M.exec("scroll-to",{top:Se,left:De})},[M]),pl=f.useCallback(X=>{X.shiftKey&&X.preventDefault(),ie.current&&ie.current.focus&&ie.current.focus()},[]),Oa=f.useCallback(()=>!!(C||[]).find(X=>!!X.draggable),[C]),Ja=f.useRef(null),ya=f.useRef(null),es=f.useRef({dblclick:(X,Se)=>{const De={id:X,column:mc(Se,"data-col-id")};M.exec("open-editor",De)},click:(X,Se)=>{if(Se.target.closest("input")||Ja.current)return;const De=mc(Se,"data-col-id");if(Q?.id!==X&&M.exec("focus-cell",{row:X,column:De,eventSource:"click"}),L===!1)return;const Je=c&&(Se.ctrlKey||Se.metaKey),Tt=c&&Se.shiftKey;(Je||B.length>1||!B.includes(X))&&M.exec("select-row",{id:X,toggle:Je,range:Tt})},"toggle-row":X=>{const Se=M.getRow(X);M.exec(Se.open!==!1?"close-row":"open-row",{id:X})},"ignore-click":()=>!1}),ln=f.useMemo(()=>({top:be,bottom:Z,left:de.width,xScroll:le,yScroll:Me,sense:g&&ze?ze.offsetHeight:Math.max(H?.rowHeight||0,40),node:ie.current&&ie.current.firstElementChild}),[be,Z,de.width,le,Me,g,ze,H]);function Hn(X,Se){const{container:De,sourceNode:Je,from:Tt}=Se;if(Oa()&&!Je.getAttribute("draggable-data"))return!1;me(Tt),ce&&M.getRow(Tt).open&&M.exec("close-row",{id:Tt,nested:!0});const ut=$r(Je),Ue=ut.cloneNode(!0);Ue.classList.remove("wx-selected"),Ue.querySelectorAll("[tabindex]").forEach(Yt=>Yt.setAttribute("tabindex","-1")),De.appendChild(Ue),Pe(Ue);const at=(ue||0)-ye.d,Rt=Me?Y:0;De.style.width=Math.min((v||0)-Rt,he&&Fe<=(v||0)?za:za-Rt)+at+"px";const _t=ad(ut);Se.offset={x:at,y:-Math.round(_t.height/2)},ya.current||(ya.current=X.clientY)}function Yn(X,Se){const{from:De}=Se,Je=Se.pos,Tt=ad(ie.current);Je.x=Tt.x;const ut=ln.top;if(Je.y<ut)Je.y=ut;else{const Ue=Tt.height-(le&&Y>0?Y:Math.round(ln.sense/2))-ln.bottom;Je.y>Ue&&(Je.y=Ue)}if(ie.current.contains(Se.targetNode)){const Ue=$r(Se.targetNode),at=Ue&&Sd(Ue);if(at&&at!==De){Se.to=at;const Rt=g?ze?.offsetHeight:H?.rowHeight;if(ze&&((W||0)===0||Je.y>ut+Rt-1)){const _t=Ue.getBoundingClientRect(),Yt=ad(ze).y,xt=_t.y,Ot=Yt>xt?-1:1,vt=Ot===1?"after":"before",Wn=M.getState().flatData,Qn=Math.abs(Wn.findIndex(It=>It.id===De)-Wn.findIndex(It=>It.id===at)),Vt=Qn!==1?vt==="before"?"after":"before":vt;if(Qn===1&&(Ot===-1&&X.clientY>ya.current||Ot===1&&X.clientY<ya.current))return;ya.current=X.clientY,M.exec("move-item",{id:De,target:at,mode:Vt,inProgress:!0})}}d&&d({event:X,context:Se})}ij(X,Tt,Se,ln)}function gl(X,Se){const{from:De,to:Je}=Se;M.exec("move-item",{id:De,target:Je,inProgress:!1}),Ja.current=setTimeout(()=>{Ja.current=0},1),me(null),Pe(null),ya.current=null,Ky(Se)}function Ia(){const X=document.createElement("div");X.style.cssText="position:absolute;left:-1000px;width:100px;padding:0px;margin:0px;min-height:100px;overflow-y:scroll;",document.body.appendChild(X);const Se=X.offsetWidth-X.clientWidth;return document.body.removeChild(X),Se}const Ba=f.useMemo(()=>Ze>0?{width:`${Ze}px`}:void 0,[Ze]),Ss=f.useRef(null);function ts(){Promise.resolve().then(()=>{let X=0,Se=qt;const De=Ss.current;De&&(Array.from(De.children).forEach((Je,Tt)=>{ke.current[qt+Tt]=Je.offsetHeight,X+=Je.offsetHeight,Se++}),Oe(X),Za(Se))})}f.useEffect(()=>{Ke&&g&&ts()},[Ke,g,qt]);let[Vn,wa]=f.useState();f.useEffect(()=>{if(Q&&(!L||!yn.length||yn.includes(Q.row)))wa({...Q});else if(Ke.length&&ye.data.length){if(!Vn||yn.length&&!yn.includes(Vn.row)||Ke.findIndex(X=>X.id===Vn.row)===-1||ye.data.findIndex(X=>X.id===Vn.column&&!X.collapsed)===-1){const X=yn[0]||Ke[0].id,Se=ye.data.findIndex(De=>!De.collapsed);wa(Se!==-1?{row:X,column:ye.data[Se].id}:null)}}else wa(null)},[Q]);const Fa=f.useRef(null);f.useEffect(()=>{const X=ie.current;if(!X)return;const Se=tj(X,w);return()=>{typeof Se=="function"&&Se()}},[w]);const ns=f.useRef({});Object.assign(ns.current,{start:Hn,move:Yn,end:gl,getReorder:()=>K,getDraggableInfo:()=>({hasDraggable:Oa()})}),f.useEffect(()=>{const X=ie.current;return X?aj(X,ns).destroy:void 0},[K,ie.current]),f.useEffect(()=>{const X=ie.current;return X?JC(X,{keys:j!==!1&&{...ZC,"ctrl+z":oe,"ctrl+y":oe,...j},exec:Se=>M.exec("hotkey",Se)}).destroy:void 0},[M,oe,j]);const as=f.useRef({scroll:M.getReactiveState().scroll,scrollLeft:M.getReactiveState().scrollLeft,scrollTop:M.getReactiveState().scrollTop});as.current.getWidth=()=>(v||0)-(Me?Y:0),as.current.getHeight=()=>ct,as.current.getScrollMargin=()=>de.width+He.width,f.useEffect(()=>{ej(Fa.current,as.current)},[]);const Os=f.useRef(null);f.useEffect(()=>{const X=Os.current;if(!X)return;const Se=[];Se.push(zs(X,()=>Q&&M.exec("focus-cell",{eventSource:"click"})).destroy),Se.push(aC(X,es.current)),J(X.clientHeight);const De=new ResizeObserver(()=>{J(X.clientHeight)});return De.observe(X),Se.push(()=>De.disconnect()),()=>Se.forEach(Je=>Je())},[]);const Kn=`wx-grid ${k?`wx-responsive-${k}`:""}`;return f.useEffect(()=>{Q&&(Ke.some(X=>X.id===Q.row)&&ye.data.some(X=>X.id===Q.column&&!X.collapsed)||M.exec("focus-cell",{eventSource:"destroy"}))},[Q,Ke,ye.data,M]),l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"wx-4VuBwK2D "+Kn,style:{"--header-height":`${be}px`,"--footer-height":`${Z}px`,"--split-left-width":`${de.width}px`,"--split-right-width":`${He.width}px`},children:l.jsx("div",{ref:ie,className:"wx-4VuBwK2D wx-table-box",style:Ba,role:ce?"treegrid":"grid","aria-colcount":ye.data.length,"aria-rowcount":Ke.length,"aria-multiselectable":ce&&c?!0:void 0,tabIndex:-1,children:l.jsxs("div",{ref:Fa,className:"wx-4VuBwK2D wx-scroll",style:{overflowX:le?"scroll":"hidden",overflowY:Me?"scroll":"hidden"},onScroll:Gt,children:[a?l.jsx("div",{className:"wx-4VuBwK2D wx-header-wrapper",children:l.jsx(bv,{contentWidth:za,deltaLeft:ye.dh,columns:ye.header,columnStyle:p,bodyHeight:ct-+i})}):null,l.jsxs("div",{ref:Os,className:"wx-4VuBwK2D wx-body",style:{width:`${za}px`,height:`${Gn}px`},onMouseDown:X=>pl(X),children:[r?l.jsx(wj,{overlay:r}):null,l.jsx("div",{ref:Ss,className:"wx-4VuBwK2D wx-data",style:{paddingTop:`${Nt.d}px`,paddingLeft:`${ye.d}px`},children:Ke.map((X,Se)=>{const De=B.indexOf(X.id)!==-1,Je=we===X.id,Tt="wx-row"+(g?" wx-autoheight":"")+(h?" "+h(X):"")+(De?" wx-selected":"")+(Je?" wx-inactive":""),ut=g?{minHeight:`${X.rowHeight||$}px`}:{height:`${X.rowHeight||$}px`};return l.jsx("div",{className:"wx-4VuBwK2D "+Tt,"data-id":Cn(X.id),"data-context-id":Cn(X.id),style:ut,role:"row","aria-rowindex":Se,"aria-expanded":X.open,"aria-level":ce?X.$level+1:void 0,"aria-selected":ce?De:void 0,tabIndex:-1,children:ye.data.map(Ue=>Ue.collapsed?l.jsx("div",{className:"wx-4VuBwK2D wx-cell wx-collapsed"},Ue.id):F?.id===X.id&&F.column===Ue.id?l.jsx(Aj,{row:X,column:Ue},Ue.id):l.jsx(dj,{row:X,column:Ue,columnStyle:p,cellStyle:x,reorder:K,focusable:Vn?.row===X.id&&Vn?.column===Ue.id},Ue.id))},X.id)})})]}),i&&(A||[]).length?l.jsx(bv,{type:"footer",contentWidth:za,deltaLeft:ye.df,columns:ye.footer,columnStyle:p}):null]})})}),se?l.jsx(Tj,{config:se,rowStyle:h,columnStyle:p,cellStyle:x,header:a,footer:i,reorder:K}):null]})}const Ej=n=>n.split("-").map(a=>a?a.charAt(0).toUpperCase()+a.slice(1):"").join(""),Dj=f.forwardRef(function({data:n=[],columns:a=[],rowStyle:i=null,columnStyle:r=null,cellStyle:c=null,selectedRows:d,select:h=!0,multiselect:p=!1,header:x=!0,footer:g=!1,dynamic:w=null,overlay:v=null,reorder:b=!1,onReorder:k=null,autoRowHeight:j=!1,sizes:M,split:T,tree:C=!1,autoConfig:A=!1,init:D=null,responsive:H=null,sortMarks:B,undo:q=!1,hotkeys:L=null,filterValues:F,...ue},W){const ce=f.useRef();ce.current=ue;const Q=f.useMemo(()=>new YC(Iy),[]),se=f.useMemo(()=>Q.in,[Q]),oe=f.useRef(null);oe.current===null&&(oe.current=new Ey((He,Le)=>{const Fe="on"+Ej(He);ce.current&&ce.current[Fe]&&ce.current[Fe](Le)}),se.setNext(oe.current));const K=f.useMemo(()=>({getState:Q.getState.bind(Q),getReactiveState:Q.getReactive.bind(Q),getStores:()=>({data:Q}),exec:se.exec,setNext:He=>(oe.current=oe.current.setNext(He),oe.current),intercept:se.intercept.bind(se),on:se.on.bind(se),detach:se.detach.bind(se),getRow:Q.getRow.bind(Q),getColumn:Q.getColumn.bind(Q)}),[Q,se]),[z,Y]=f.useState(0),[U,R]=f.useState(0),[J,he]=f.useState(null),[$,ie]=f.useState(null),we=f.useMemo(()=>{if(A&&!a.length&&n.length){const He=n[0],Le=[];for(let Fe in He)if(Fe!=="id"&&Fe[0]!=="$"){let qe={id:Fe,header:Fe[0].toUpperCase()+Fe.slice(1)};typeof A=="object"&&(qe={...qe,...A}),Le.push(qe)}return Le}return($&&$.columns)??a},[A,a,n,$]),me=f.useMemo(()=>($&&$.sizes)??M,[$,M]),ze=f.useCallback(He=>{if(Y(He.width),R(He.height),H){const Le=Object.keys(H).map(Number).sort((Fe,qe)=>Fe-qe).find(Fe=>He.width<=Fe)??null;Le!==J&&(ie(H[Le]),he(Le))}},[H,J]),Pe=f.useContext(kn.theme),de=f.useRef(0);return f.useEffect(()=>{if(!de.current)D&&D(K);else{const He=Q.getState();Q.init({data:n,columns:we,split:T||He.split,sizes:me||He.sizes,selectedRows:d||He.selectedRows,dynamic:w,tree:C,sortMarks:B||He.sortMarks,filterValues:F||He.filterValues,undo:q,reorder:b,_skin:Pe,_select:h})}de.current++},[Q,n,we,T,me,d,w,C,B,F,q,b,Pe,h,D,K]),de.current===0&&Q.init({data:n,columns:we,split:T||{left:0},sizes:me||{},selectedRows:d||[],dynamic:w,tree:C,sortMarks:B||{},filterValues:F||{},undo:q,reorder:b,_skin:Pe,select:h}),f.useImperativeHandle(W,()=>({...K}),[K]),l.jsx(La.Provider,{value:K,children:l.jsx(Nh,{words:Th,optional:!0,children:l.jsx(Rj,{header:x,footer:g,overlay:v,rowStyle:i,columnStyle:r,cellStyle:c,onReorder:k,multiselect:p,autoRowHeight:j,clientWidth:z,clientHeight:U,responsiveLevel:J,resize:ze,hotkeys:L})})})});bh(va);const jn=f.createContext(null),Dh=f.createContext(null),Lh=f.createContext(null);function Lj({children:n}){const a=f.useContext(kn.i18n),i=f.useMemo(()=>a.getGroup("filemanager"),[a]),r=f.useContext(jn),[c]=Xa(r,"panels"),d=Xe(r,"activePanel"),h=c[d].path,[p,x]=f.useState(null),[g,w]=f.useState(null),[v,b]=f.useState(""),[k,j]=f.useState(""),[M,T]=f.useState(!1);function C(){const B=v.trim();if(!B){T(!0);return}p.add?r.exec("create-file",{file:{...p.item,name:B},parent:h}):k!==B&&r.exec("rename-file",{id:p.item.id,name:B}),A()}function A(){x(null),T(null),j(""),b("")}function D(){r.exec("delete-files",{ids:g.selected}),w(null)}const H=f.useMemo(()=>({showPrompt(B){const q=B.item.name||(B.item.type==="folder"?i("New folder"):`${i("New file")}.txt`);j(q),b(q),x({...B})},showConfirm(B){w({...B})}}),[i]);return l.jsxs(Dh.Provider,{value:H,children:[l.jsx(L1,{children:n}),p?l.jsx(nh,{title:i(`Enter ${p.item.type} name`),onConfirm:C,onCancel:A,children:l.jsx(Mh,{error:M,select:!0,focus:!0,value:v,onChange:({value:B})=>b(B)})}):null,g?l.jsx(nh,{title:i("Are you sure you want to delete these items:"),onConfirm:D,onCancel:()=>w(null),children:g.selected?l.jsx("ul",{className:"wx-gq7BMzEP wx-list",children:g.selected.map((B,q)=>l.jsx("li",{children:B},q))}):null}):null]})}let Cv={"7z":!0,rar:!0,zip:!0,css:!0,html:!0,js:!0,php:!0,md:!0,xml:!0,sql:!0,aif:!0,mid:!0,mp3:!0,waw:!0,wma:!0,doc:!0,docx:!0,txt:!0,avi:!0,mov:!0,mp4:!0,mpeg:!0,mpg:!0,pdf:!0,xls:!0,xlsx:!0,gif:!0,jpg:!0,jpeg:!0,png:!0,psd:!0,tiff:!0,svg:!0,folder:!0,file:!0,multiple:!0,search:!0,none:!0};function zj(n){const a=n.lastIndexOf("."),i=a>0&&a<n.length-1?Math.min(10,n.length-a):Math.min(5,n.length),r=n.slice(0,-i),c=n.slice(-i);return[r,c]}function _j({item:n}){const a=f.useContext(jn),i=f.useContext(kn.i18n).getGroup("filemanager"),r=f.useContext(jn).templates,[c]=Xa(a,"panels"),d=Xe(a,"activePanel"),h=Xe(a,"mode"),p=c[d].selected,x=f.useMemo(()=>r.preview(n,214,163),[r,n]),g=f.useMemo(()=>r.icon(n,"big"),[r,n]),[w,v]=f.useMemo(()=>zj(n.name),[n.name]);return l.jsx(l.Fragment,{children:n.id==="/wx-filemanager-parent-link"?h!=="search"?l.jsx("div",{className:"wx-GAOa4kDV wx-back-item",children:l.jsxs("div",{className:`wx-GAOa4kDV wx-back ${n.navigation?"wx-selected":""}`,"data-id":Cn("/wx-filemanager-parent-link"),children:[l.jsx("i",{className:"wx-GAOa4kDV wxi-arrow-left"}),l.jsx("span",{children:i("Back to parent folder")})]})}):null:l.jsxs("div",{className:`wx-GAOa4kDV wx-item ${p?.length&&p.indexOf(n.id)>=0?"wx-selected":""}`,"data-id":Cn(n.id),children:[x?l.jsx("div",{className:"wx-GAOa4kDV wx-preview wx-file-preview",children:l.jsx("img",{className:"wx-GAOa4kDV wx-card-preview",alt:i("A miniature file preview"),src:x})}):g?l.jsx("div",{className:"wx-GAOa4kDV wx-preview wx-file-icon",children:l.jsx("img",{className:"wx-GAOa4kDV wx-card-preview",alt:"",src:g})}):l.jsx("div",{className:"wx-GAOa4kDV wx-preview",children:l.jsx("i",{className:`wx-GAOa4kDV wxi-${n.type}`})}),n.type==="folder"?l.jsxs("div",{className:"wx-GAOa4kDV wx-info",children:[l.jsxs("div",{className:"wx-GAOa4kDV wx-folder-name",children:[l.jsx("span",{className:"wx-GAOa4kDV wx-type",children:i("Folder")}),l.jsxs("span",{className:"wx-GAOa4kDV wx-name",children:[l.jsx("span",{children:w}),l.jsx("span",{children:v})]})]}),l.jsx("div",{"data-action-id":Cn(n.id),className:"wx-GAOa4kDV wx-more",children:l.jsx("i",{className:"wx-GAOa4kDV wxi-dots-v"})})]}):l.jsxs("div",{className:"wx-GAOa4kDV wx-info",children:[l.jsx("div",{className:"wx-GAOa4kDV wx-file-name",children:l.jsxs("span",{className:"wx-GAOa4kDV wx-name",children:[l.jsx("span",{children:w}),l.jsx("span",{children:v})]})}),l.jsx("div",{"data-action-id":Cn(n.id),className:"wx-GAOa4kDV wx-more",children:l.jsx("i",{className:"wx-GAOa4kDV wxi-dots-v"})})]})]})})}function Zy(){const n=f.useContext(jn),a=f.useContext(kn.i18n),i=f.useMemo(()=>a.getGroup("filemanager"),[a]),[r]=Xa(n,"panels"),c=Xe(n,"activePanel"),d=Xe(n,"mode"),h=r[c]._files,p=r[c].selected,x=r[c].path,g=r[c]._crumbs,w=r[c]._selectNavigation,v=f.useCallback((A,D)=>{const H=D&&(D.ctrlKey||D.metaKey),B=D&&D.shiftKey;if(A==="/wx-filemanager-parent-link"){if(p.length&&(H||B))return;n.exec("select-file",{type:"navigation"});return}let q=A==="body"&&D?null:A;const L=D.target.className.indexOf("wx-more")!==-1||D.target.className.indexOf("wxi-dots-v")!==-1;setTimeout(()=>{n.exec("select-file",{id:q,toggle:H&&!L,range:B&&!L,panel:c})},1)},[n,p,c]),b=f.useCallback(()=>{g.length>1&&n.exec("set-path",{id:g[g.length-2].id,panel:c,selected:[g[g.length-1].id]})},[n,g,c]),k=f.useCallback(A=>{if(A==="/wx-filemanager-parent-link")return b();d==="search"&&n.exec("filter-files",{text:""});const D=h.find(H=>H.id===A);D&&(D.type=="folder"?n.exec("set-path",{id:D.id,panel:c}):n.exec("open-file",{id:D.id}))},[n,b,d,h,c]),j=f.useCallback((A,D)=>{(!p?.length||!p.filter(H=>H?.id===A).length>0)&&v(A,D)},[p,v]),M=f.useMemo(()=>x!=="/"?[{id:"/wx-filemanager-parent-link",name:i("Back to parent folder"),navigation:w},...h]:h,[x,i,w,h]),T=f.useRef(null),C=f.useRef();return f.useEffect(()=>{T.current&&(C.current?(C.current.click=v,C.current._dblclick=k,C.current.context=j):(C.current={click:v,dblclick:A=>C.current._dblclick(A),_dblclick:k,context:j},Ur(T.current,C.current)))},[v,k,j]),d=="search"&&!M.length?l.jsx("div",{className:"wx-iyjASZCY wx-not-found",children:l.jsx("div",{className:"wx-iyjASZCY wx-not-found-text",children:i("Looks like nothing is here")})}):l.jsx("div",{tabIndex:0,className:"wx-iyjASZCY "+("wx-cards"+(x!=="/"&&d!=="search"?" wx-has-back-link":"")),"data-id":Cn("body"),ref:T,children:M.map(A=>l.jsx(_j,{item:A},A.id))})}function Wi({name:n="",spin:a=!1,onClick:i}){return l.jsx("i",{"data-menu-ignore":"true",className:`wx-uwcvNSAG wx-icon wxi-${n} ${a?"wx-spin":""} ${i?"wx-clickable":""}`,onClick:()=>{i&&i()}})}function Oj(){const n=f.useContext(kn.i18n).getGroup("filemanager"),a=f.useContext(jn),i=Xe(a,"activePanel"),[r]=Xa(a,"panels"),c=f.useMemo(()=>r[i]._crumbs,[r,i]);function d(){a.exec("filter-files",{text:""})}return l.jsxs("div",{className:"wx-GDJvtROw wx-search",children:[l.jsxs("div",{className:"wx-GDJvtROw wx-toolbar",children:[l.jsx("div",{className:"wx-GDJvtROw wx-back-icon",children:l.jsx(Wi,{name:"angle-left",onClick:d})}),l.jsxs("div",{className:"wx-GDJvtROw wx-text",children:[n("Search results in")," ",Array.isArray(c)&&c.map((h,p)=>l.jsxs(f.Fragment,{children:[p?"/":null,h.id=="/"?n(h.name):h.name]},p))]})]}),l.jsx(Zy,{})]})}function Tm({narrowMode:n,extraInfo:a}){const i=f.useContext(jn),{preview:r,icon:c}=i.templates,d=f.useContext(kn.i18n),h=f.useMemo(()=>d.getGroup("filemanager"),[d]),p=f.useMemo(()=>Ir("%D, %d %F %Y, %H:%i",d.getRaw().calendar),[d]),[x,g]=Xa(i,"panels"),w=Xe(i,"activePanel"),v=Xe(i,"preview"),b=Xe(i,"search"),k=f.useMemo(()=>{const L=x&&w!=null&&x[w]?._selected?.length||0;return b&&!L},[b,g,w]),j=f.useMemo(()=>{const L=x&&w!=null?x[w]:null;return L?k?L._files:L._selected:[]},[k,g,w]),M=f.useCallback((L,F)=>(L?`${L} ${h(L>1?"folders":"folder")} `:"")+(F?`${F} ${h(F>1?"files":"file")}`:""),[h]),T=f.useCallback(()=>{i.exec("show-preview",{mode:!v})},[i,v]),C=f.useCallback(L=>L.type==="folder"?h("Folder"):L.ext||h("Unknown file"),[h]),A=f.useMemo(()=>{let L,F,ue,W,ce,Q,se,oe;if(j.length===1&&!k){F=j[0],L=F.name;const K=r(F,400,500);K?(ue=K,W=""):(W=c(F,"big"),ue=""),ce=F.type!=="folder"}else{if(F=ce=null,L="",j.length){let K=0,z=0,Y=0,U=[],R;j.forEach(he=>{typeof he.size>"u"&&(R=!0,K=void 0),R||(K+=he.size),U.push(C(he)),he.type==="folder"?z++:Y++});const J=new Set(U);Q=J.size>1?h("multiple"):[...J][0],se=M(z,Y),oe=K,k||(L=h("Multiple files"))}W=c({type:k?"search":j.length?"multiple":"none"},"big"),ue=""}return{name:L,item:F,previewSrc:ue,iconSrc:W,showDownloadIcon:ce,type:Q,totalCount:se,totalSize:oe}},[j,k,r,c,h,C,M]),D=f.useCallback(()=>{i.exec("download-file",{id:j[0].id})},[i,j]),H=f.useCallback(async L=>{if(!a||!L)return null;try{return await a(L)}catch(F){return console.log(F),null}},[a]),[B,q]=f.useState(null);return f.useEffect(()=>{let L=!1;return q(null),Promise.resolve(H(A.item)).then(F=>{L||q(F)}).catch(()=>{L||q(null)}),()=>{L=!0}},[H,A.item]),l.jsx("div",{className:"wx-O0BTtRrH wx-wrapper",children:j&&j.length?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"wx-O0BTtRrH wx-preview",children:[l.jsxs("div",{className:"wx-O0BTtRrH wx-toolbar",children:[l.jsx("div",{className:"wx-O0BTtRrH wx-name",children:A.name}),l.jsxs("div",{className:"wx-O0BTtRrH wx-icons",children:[A.showDownloadIcon?l.jsx(Wi,{name:"download",onClick:D}):null,n?l.jsx(Wi,{name:"close",onClick:T}):null]})]}),A.previewSrc?l.jsx("div",{className:"wx-O0BTtRrH wx-img-wrapper",children:l.jsx("img",{src:A.previewSrc,alt:h("A miniature file preview")})}):A.iconSrc?l.jsx("div",{className:"wx-O0BTtRrH wx-icon-wrapper",children:l.jsx("img",{src:A.iconSrc,alt:h("A miniature file preview")})}):l.jsx("div",{className:"wx-O0BTtRrH wx-icon-wrapper",children:A.item?l.jsx("i",{className:`wx-O0BTtRrH wx-icon wxi-${A.item.type}`}):l.jsx("i",{className:`wx-O0BTtRrH wx-icon wxi-${k?"search":"file-multiple-outline"}`})})]}),l.jsxs("div",{className:"wx-O0BTtRrH wx-info-panel",children:[l.jsx("div",{className:"wx-O0BTtRrH wx-title",children:h(k?"Found":"Information")}),l.jsxs("div",{className:"wx-O0BTtRrH wx-list",children:[A.item?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"wx-O0BTtRrH wx-name",children:h("Type")}),l.jsx("span",{className:"wx-O0BTtRrH wx-value",children:C(A.item)}),typeof A.item.size<"u"?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"wx-O0BTtRrH wx-name",children:h("Size")}),l.jsx("span",{className:"wx-O0BTtRrH wx-value",children:hc(A.item.size)})]}):null,l.jsx("span",{className:"wx-O0BTtRrH wx-name",children:h("Date")}),l.jsxs("span",{className:"wx-O0BTtRrH wx-value",children:[p(A.item.date)," "]})]}):l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"wx-O0BTtRrH wx-name",children:h("Count")}),l.jsx("span",{className:"wx-O0BTtRrH wx-value",children:A.totalCount}),l.jsx("span",{className:"wx-O0BTtRrH wx-name",children:h("Type")}),l.jsx("span",{className:"wx-O0BTtRrH wx-value",children:A.type}),typeof A.totalSize<"u"?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"wx-O0BTtRrH wx-name",children:h("Size")}),l.jsx("span",{className:"wx-O0BTtRrH wx-value",children:hc(A.totalSize)})]}):null]}),B?Object.entries(B).map(([L,F])=>l.jsxs(ph.Fragment,{children:[l.jsx("span",{className:"wx-O0BTtRrH wx-name",children:L}),l.jsx("span",{className:"wx-O0BTtRrH wx-value",children:F})]},L)):null]})]})]}):l.jsxs("div",{className:"wx-O0BTtRrH wx-no-info-panel",children:[l.jsxs("div",{className:"wx-O0BTtRrH wx-toolbar",children:[l.jsx("div",{className:"wx-O0BTtRrH wx-name",children:A.name}),l.jsx("div",{className:"wx-O0BTtRrH wx-icons",children:n?l.jsx(Wi,{name:"close",onClick:T}):null})]}),l.jsx("div",{className:"wx-O0BTtRrH wx-no-info-wrapper",children:l.jsxs("div",{className:"wx-O0BTtRrH wx-no-info",children:[A.previewSrc?l.jsx("div",{className:"wx-O0BTtRrH wx-img-wrapper",children:l.jsx("img",{src:A.previewSrc,alt:h("A miniature file preview")})}):A.iconSrc?l.jsx("div",{className:"wx-O0BTtRrH wx-icon-wrapper",children:l.jsx("img",{src:A.iconSrc,alt:h("A miniature file preview")})}):l.jsx("div",{className:"wx-O0BTtRrH wx-icon-wrapper",children:l.jsx("i",{className:`wx-O0BTtRrH wx-icon wxi-${k?"search":"message-question-outline"}`})}),l.jsx("span",{className:"wx-O0BTtRrH wx-text",children:k?"":h("Select file or folder to view details")})]})})]})})}function Jy({panel:n}){const a=f.useContext(jn),i=f.useContext(kn.i18n),r=f.useMemo(()=>i.getGroup("filemanager"),[i]),[c,d]=Xa(a,"panels"),h=f.useMemo(()=>c[n]._files,[d,n]),p=f.useMemo(()=>c[n]._crumbs||[],[d,n]);function x(j){const M=Rh(j,p);a.exec("set-path",{id:j,panel:n,...M&&{selected:[M]}})}const[g,w]=f.useState(null);f.useEffect(()=>{h&&w(null)},[h]);function v(){w(!0),a.exec("request-data",{id:p[p.length-1].id}),setTimeout(()=>{w(null)},5e3)}const b=f.useRef(null),k=f.useRef();return f.useEffect(()=>{k.current?k.current.click=x:(k.current={click:x},Ur(b.current,k.current))},[x]),l.jsxs("div",{className:"wx-SNY5LTYx wx-breadcrumbs","data-menu-ignore":"true",ref:b,children:[l.jsx("div",{className:"wx-SNY5LTYx wx-refresh-icon",children:l.jsx(Wi,{name:"refresh",spin:!!g,onClick:v})}),p.map((j,M)=>l.jsxs(ph.Fragment,{children:[M?l.jsx(Wi,{name:"angle-right"}):null,l.jsx("div",{className:"wx-SNY5LTYx wx-item","data-id":Cn(j.id),"data-menu-ignore":"true",children:j.id=="/"?r(j.name):j.name})]},M))]})}function Ij({row:n}){const a=f.useContext(kn.i18n),[i]=f.useState(()=>a.getGroup("filemanager")),r=f.useContext(jn).templates,[c]=f.useState(()=>r.icon(n,"small"));return l.jsx("div",{className:"wx-qgAqG6sL wx-name-cell",children:n.id==="/wx-filemanager-parent-link"?l.jsxs(l.Fragment,{children:[l.jsx("i",{className:"wx-qgAqG6sL wxi-arrow-left"}),l.jsxs("span",{className:"wx-qgAqG6sL wx-name",children:[" ",i("Back to parent folder")]})]}):l.jsxs(l.Fragment,{children:[c?l.jsx("img",{className:"wx-qgAqG6sL wx-icon",alt:"",src:c,height:"24px",width:"24px"}):l.jsx("i",{className:`wx-qgAqG6sL wxi-${n.type}`}),l.jsxs("span",{className:"wx-qgAqG6sL wx-name",children:[" ",n.name," "]})]})})}function ew({children:n}){const a=f.useContext(jn),i=Xe(a,"activePanel"),r=f.useContext(Lh),c=f.useRef(null);let d=f.useRef({});return d.current.drop=()=>{const h=c.current,p=H0(h,"data-panel");p&&p!=i&&a.exec("set-active-panel",{panel:p*1})},d.current.dragEnter=()=>{const h=c.current;h&&h.classList.toggle("wx-active")},d.current.dragLeave=()=>{const h=c.current;h&&h.classList.toggle("wx-active")},f.useEffect(()=>{const h=c.current;return r.droparea(h,d.current)},[]),l.jsx("div",{className:"wx-LT9X7tb7 wx-upload-area",ref:c,children:n})}function lh({panel:n,active:a=!1,onClick:i,onContextMenu:r}){const c=f.useContext(jn),d=f.useContext(kn.i18n),h=f.useMemo(()=>d.getGroup("filemanager"),[d]),p=f.useMemo(()=>Ir("%d %M %Y",d.getRaw().calendar),[d]),[x]=Xa(c,"panels"),g=x[n].selected,w=x[n].path,v=x[n]._crumbs,b=x[n]._sorts,k=x[n]._selectNavigation,j=x[n]._files,M=f.useMemo(()=>[{id:"name",header:h("Name"),flexgrow:3,sort:!0,resize:!0,cell:Ij},{id:"size",header:h("Size"),width:100,sort:!0,resize:!0,template:Q=>typeof Q=="number"?hc(Q):""},{id:"date",header:h("Date"),width:120,sort:!0,resize:!0,template:Q=>Q?p(Q):""}],[h,p]),T=f.useRef(null),C=f.useRef(null),A=f.useMemo(()=>k?["/wx-filemanager-parent-link"]:[...g],[k,g]);function D(Q,se){if(se&&se.target&&se.target.className&&se.target.className.indexOf("wx-grip")!==-1)return;const oe=se&&(se.ctrlKey||se.metaKey),K=se&&se.shiftKey;if(Q==="/wx-filemanager-parent-link"){if(g.length&&(oe||K))return;c.exec("select-file",{type:"navigation"});return}let z=Q==="body"&&se?null:Q;!T.current&&!C.current?c.exec("select-file",{id:z,toggle:oe,range:K,panel:n}):(T.current=null,C.current=null)}function H(){v.length>1&&c.exec("set-path",{id:v[v.length-2].id,panel:n,selected:[v[v.length-1].id]})}function B(Q){if(Q==="/wx-filemanager-parent-link")return H();const se=j.find(oe=>oe.id===Q);se&&(se.type==="folder"?c.exec("set-path",{id:se.id,panel:n}):c.exec("open-file",{id:se.id}))}function q(Q){const se=Q.key,oe=b[w];let K=oe?"asc":"desc";oe&&oe.key===se&&(K=oe.order==="asc"?"desc":"asc"),c.exec("sort-files",{key:se,order:K,panel:n,path:w})}function L(Q){Q.intercept("sort-rows",se=>(T.current=!0,q(se),!1)),Q.intercept("select-row",()=>!1),Q.on("resize-column",()=>C.current=!0),Q.intercept("hotkey",()=>!1)}const F=f.useMemo(()=>w!=="/"?[{id:"/wx-filemanager-parent-link",name:h("Back to parent folder")},...j]:j,[w,j,h]),ue=f.useMemo(()=>{if(F&&b&&b[w]){const{key:Q,order:se}=b[w];return{[Q]:{order:se}}}},[F,b,w]),W=f.useRef(null),ce=f.useRef();return f.useEffect(()=>{ce.current?(ce.current.click=D,ce.current._dblclick=B):(ce.current={click:D,dblclick:Q=>ce.current._dblclick(Q),_dblclick:B},Ur(W.current,ce.current))},[D,B]),l.jsxs("div",{onClick:i,onContextMenu:r,className:"wx-SSaVhET7 wx-wrapper",children:[l.jsx(Jy,{panel:n}),l.jsx("div",{"data-id":Cn("body"),className:`wx-SSaVhET7 wx-list ${a?"wx-active":""}`,ref:W,children:l.jsx(ew,{children:l.jsx(Dj,{init:L,data:F,columns:M,selectedRows:A,columnStyle:()=>"wx-SSaVhET7 wx-each-cell",sizes:{rowHeight:42,headerHeight:42},sortMarks:ue})})})]})}function Bj(){const n=f.useContext(jn),a=Xe(n,"activePanel");function i(r){n.exec("set-active-panel",{panel:r})}return l.jsxs("div",{className:"wx-L55BfJa2 wx-panels","data-id":Cn("body"),children:[l.jsx("div",{className:"wx-L55BfJa2 wx-item","data-panel":0,children:l.jsx(lh,{panel:0,active:a==0,onClick:()=>i(0),onContextMenu:()=>i(0)})}),l.jsx("div",{className:"wx-L55BfJa2 wx-item","data-panel":1,children:l.jsx(lh,{panel:1,active:a==1,onClick:()=>i(1),onContextMenu:()=>i(1)})})]})}function tw({folderIcon:n=!1,folder:a={}}){const i=f.useContext(jn),[r,c]=Xa(i,"panels"),d=Xe(i,"activePanel"),h=f.useMemo(()=>r[d].path,[c,d]),p=f.useContext(kn.i18n),x=f.useMemo(()=>p.getGroup("filemanager"),[p]),g=f.useMemo(()=>!!a.data?.find(k=>k.type==="folder"),[a]),w=f.useMemo(()=>a.id=="/"?x(a.name):a.name,[a,x]),v=f.useMemo(()=>a.$level>1?(a.$level-1)*20:0,[a]),b=a.open;return l.jsxs(l.Fragment,{children:[l.jsxs("li",{"data-id":Cn(a.id),className:`wx-NYfhvGIt wx-folder${h===a.id?" wx-selected":""}`,style:{paddingLeft:`${v}px`},children:[g?l.jsx("i",{className:`wx-NYfhvGIt wx-toggle wxi-${b?"angle-down":"angle-right"}`,"data-action":"toggle"}):l.jsx("span",{className:"wx-NYfhvGIt wx-toggle-placeholder"}),l.jsx("i",{className:"wx-NYfhvGIt "+(n||"wxi-folder")}),l.jsxs("span",{className:"wx-NYfhvGIt wx-name",children:[" ",w," "]})]}),b&&a.data&&a.data.length&&g?l.jsx(l.Fragment,{children:a.data.map(k=>k.type==="folder"?l.jsx(tw,{folder:k},k.id):null)}):null]})}function Fj(){const n=f.useContext(jn),[a,i]=Xa(n,"data"),[r,c]=Xa(n,"panels"),d=Xe(n,"activePanel"),h=f.useMemo(()=>r[d]._crumbs,[c,d]),p=f.useCallback(k=>{n.exec("open-tree-folder",{id:k,mode:!a.byId(k).open})},[n,i]),x=f.useCallback(k=>{const j=Rh(k,h);n.exec("set-path",{id:k,panel:d,...j&&{selected:[j]}})},[n,h,d]),[g,w]=f.useState([]);f.useEffect(()=>{w(a.byId(0).data)},[i]);const v=f.useRef(null),b=f.useRef();return f.useEffect(()=>{b.current?(b.current.click=x,b.current.toggle=p):(b.current={click:x,toggle:p},Ur(v.current,b.current))},[x,p]),l.jsx("ul",{ref:v,className:"wx-LyHJ6R6A",children:g.map(k=>k.type==="folder"?l.jsx(tw,{folder:k},k.id):null)})}function Hj(){const n=f.useContext(jn),a=f.useContext(kn.i18n),i=f.useMemo(()=>a.getGroup("filemanager"),[a]),r=Xe(n,"drive"),c=r?r.used:"",d=r?r.total:"";return c&&d?l.jsxs("div",{className:"wx-DetSyKGG wx-drive",children:[l.jsx("progress",{value:c,max:d,className:"wx-DetSyKGG wx-progress"}),l.jsxs("p",{children:[hc(c)," ",i("of")," ",hc(d)," ",i("used")]})]}):null}function $j({option:n}){const a=f.useContext(kn.i18n).getGroup("filemanager"),i=f.useContext(Lh),r=f.useCallback(()=>{i.open({})},[i]);return l.jsx("div",{className:"wx-9XiKcxq5 wx-upload-button",onClick:r,children:l.jsx("span",{children:a(n.text)})})}function Uj({readonly:n,menuOptions:a}){const i=f.useContext(kn.i18n).getGroup("filemanager"),{showPrompt:r}=f.useContext(Dh);f.useEffect(()=>{iC("upload",$j)},[]);function c({action:h}){h&&(h.id==="add-file"?r({item:{type:"file",size:0,date:new Date},add:!0}):h.id==="add-folder"&&r({item:{type:"folder",date:new Date},add:!0}))}const d=f.useMemo(()=>a("add").map(h=>(h.text=i(h.text),h)),[a,i]);return l.jsxs("div",{className:"wx-FlucfALM wx-wrapper",children:[!n&&l.jsx("div",{className:"wx-FlucfALM wx-button",children:l.jsx(oC,{options:d,at:"bottom-fit",onClick:c,children:l.jsx(ic,{type:"primary block",children:i("Add New")})})}),l.jsx("div",{className:"wx-FlucfALM wx-tree",children:l.jsx(Fj,{})}),l.jsx(Hj,{})]})}function Pj({value:n="",onSearch:a}){const[i,r]=_y(n),c=f.useContext(kn.i18n).getGroup("filemanager"),d=f.useRef(null),h=f.useMemo(()=>i!==""?"wxi-close":"wxi-search",[i]);function p(g){const w=g.target.value;r(w),a&&a({value:w})}function x(){r(""),d.current&&d.current.focus(),a&&a({value:""})}return l.jsxs("div",{className:"wx-lUZMtgT1 wx-search-input",children:[l.jsx("i",{className:`wx-lUZMtgT1 wx-icon ${h}`,onClick:x}),l.jsx("input",{type:"text",className:"wx-lUZMtgT1 wx-text",ref:d,value:i,onInput:p,placeholder:c("Search")})]})}function qj({narrowMode:n=!1,onShowTree:a}){const i=f.useContext(jn),r=f.useContext(kn.i18n).getGroup("filemanager"),c=Xe(i,"mode"),d=Xe(i,"preview"),h=Xe(i,"search"),p=[{icon:"wxi-view-sequential",id:"table"},{icon:"wxi-view-grid",id:"cards"},{icon:"wxi-view-column",id:"panels"}];function x({value:v}){i.exec("set-mode",{mode:v})}function g(v){v.preventDefault(),i.exec("show-preview",{mode:!d})}function w(v){i.exec("filter-files",{text:v.value})}return l.jsxs("div",{className:"wx-5PZQQztG wx-toolbar",children:[l.jsxs("div",{className:"wx-5PZQQztG wx-left "+(n?"wx-left-narrow":""),children:[n?c==="panels"||c==="search"?null:l.jsx("div",{className:"wx-5PZQQztG wx-sidebar-icon","data-id":Cn("toggle-tree"),children:l.jsx(Wi,{onClick:()=>a&&a(),name:"subtask"})}):l.jsx("div",{className:"wx-5PZQQztG wx-name",children:r("Files")}),l.jsx(Pj,{onSearch:w,value:h})]}),l.jsxs("div",{className:"wx-5PZQQztG wx-right",children:[n?null:l.jsx("div",{className:"wx-5PZQQztG wx-preview-icon",children:l.jsx(z1,{onClick:g,value:d,children:l.jsx("i",{className:"wx-5PZQQztG wxi-eye"})})}),l.jsx("div",{className:"wx-5PZQQztG wx-modes",children:l.jsx(N1,{value:c,options:p,onChange:x})})]})]})}function Gj(){const n=f.useContext(jn),a=Xe(n,"activePanel");return l.jsxs("div",{className:"wx-NwohNJzN wx-wrapper",children:[l.jsx(Jy,{panel:a}),l.jsx(ew,{children:l.jsx(Zy,{})})]})}function Yj({readonly:n=!1,menuOptions:a,extraInfo:i}){const r=f.useRef(null),c=f.useRef(null),[d,h]=f.useState(void 0),[p,x]=f.useState(void 0),[g,w]=f.useState(!1),v=Uy(),b=f.useContext(jn),{showPrompt:k,showConfirm:j}=f.useContext(Dh),M=f.useContext(kn.i18n),T=f.useMemo(()=>M.getGroup("filemanager"),[M]),C=Xe(b,"mode"),A=Xe(b,"preview"),D=Xe(b,"activePanel"),[H,B]=Xa(b,"panels"),q=f.useMemo(()=>(H&&D!=null?H[D]:null)?.selected??[],[B,D]),L=f.useMemo(()=>(H&&D!=null?H[D]:null)?.path,[B,D]),[F,ue]=f.useState([]);f.useEffect(()=>{const J=r.current;if(!J)return;const he=new ResizeObserver($=>{const ie=$[0]?.borderBoxSize?.[0]?.inlineSize;typeof ie=="number"&&x(ie<768)});return he.observe(J),()=>{he.disconnect()}},[]);const W=f.useCallback(()=>{w(J=>!J)},[]),ce=f.useCallback(J=>{p&&mc(J)!=="toggle-tree"&&w(!1)},[p]);f.useEffect(()=>{const J=c.current;if(J)return zs(J,ce).destroy},[ce]),f.useEffect(()=>{const J=c.current;if(!J)return;const he=new ResizeObserver(()=>{J&&h(J.clientWidth)});return he.observe(J),J&&h(J.clientWidth),()=>{he.disconnect()}},[]);const Q=f.useMemo(()=>({icon:"wxi-eye",text:"Preview",id:"preview"}),[]),se=f.useCallback(J=>{let he=p?[Q]:[];return J==="file"&&(he=[...he,...a().filter($=>$.id==="download")]),he},[p,Q,a]),oe=f.useRef(null),K=f.useCallback((J,he,$)=>{const ie=$?[he.id]:q;switch(J){case"download":b.exec("download-file",{id:he.id});break;case"copy":case"move":oe.current={action:J,ids:ie};break;case"paste":oe.current&&b.exec(oe.current.action==="copy"?"copy-files":"move-files",{ids:oe.current.ids,target:he?.type==="folder"?he.id:L});break;case"rename":k({item:he});break;case"delete":j({selected:ie});break;case"preview":b.exec("show-preview",{mode:!A});break}},[b,q,L,k,j,A]),z=f.useCallback(()=>H?.[D],[H,D]);f.useEffect(()=>{const J=r.current;if(!J)return;const he=W1(J,{api:b,menuOptions:n?se:a,performAction:K,getPanel:z});return()=>{typeof he=="function"?he():he&&typeof he.destroy=="function"&&he.destroy()}},[b,n,se,a,K,z]);const Y=f.useCallback((J,he)=>{const $=J?b.getFile(J):null,ie=he.target.closest(".tree-item.folder");let we;if(n)we=se($?.type);else{switch(J){case"body":we=a(J);break;default:if($)if(!ie&&q.length>1)we=p?[Q,...a("multiselect")]:a("multiselect");else if(J==="/")we=a("folder",$).filter(me=>me.id==="paste");else{const me=a($.type,$);me&&(we=p?[Q,...me]:me)}}C==="search"&&(we=we?.filter(me=>me.id!=="paste"))}if($?.id&&(!q.length||!q.some(me=>me===$.id))&&!ie&&b.exec("select-file",{id:$.id}),we?.length)return we.forEach(me=>{ie&&(me.hotkey=""),me.text&&(me.text=T(me.text)),me.hotkey&&(me.subtext=me.hotkey)}),ue(we),$||{}},[b,n,se,a,q,p,Q,C,T]),U=f.useCallback(J=>{const{action:he,context:$}=J;he&&K(he.id,$,!he.hotkey)},[K]);async function R(J){await Promise.resolve();const{name:he,size:$}=J.file;b.exec("create-file",{file:{name:he,size:$,date:new Date,file:J.file},parent:L})}return l.jsx("div",{className:"wx-RJbNonjJ wx-filemanager wx-flex",ref:r,"data-menu-ignore":"false",children:p&&A?l.jsx("div",{className:"wx-RJbNonjJ wx-info-narrow",children:l.jsx(Tm,{narrowMode:p,extraInfo:i})}):l.jsxs(l.Fragment,{children:[l.jsx(qj,{narrowMode:p,onShowTree:W}),l.jsx(cC,{dataKey:"id",at:"point",options:F,resolver:Y,onClick:U,children:l.jsxs($y,{dataKey:"actionId",options:F,resolver:Y,onClick:U,children:[l.jsx(hC,{data:v,apiOnly:!0,uploadURL:R}),l.jsx(Lh.Provider,{value:v,children:l.jsx("div",{className:"wx-RJbNonjJ wx-content-wrapper wx-flex",children:C!=="panels"&&C!=="search"?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"wx-RJbNonjJ "+["wx-sidebar",p?"wx-sidebar-narrow":"",g?"wx-sidebar-visible":""].filter(Boolean).join(" "),ref:c,children:l.jsx(Uj,{readonly:n,menuOptions:a})}),l.jsxs("div",{className:"wx-RJbNonjJ wx-content",style:{width:`calc(100% - ${d||0}px - 10px)`},children:[l.jsx("div",{className:`wx-RJbNonjJ wx-content-item${A?"":"-fit"}`,"data-id":Cn("body"),children:C==="table"?l.jsx(lh,{panel:D}):l.jsx(Gj,{})}),A?l.jsx("div",{className:"wx-RJbNonjJ wx-info",children:l.jsx(Tm,{extraInfo:i})}):null]})]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:`wx-RJbNonjJ wx-content-item${A?"":"-fit"}`,children:C==="panels"?l.jsx(Bj,{}):l.jsx(Oj,{})}),A?l.jsx("div",{className:"wx-RJbNonjJ wx-info",children:l.jsx(Tm,{extraInfo:i})}):null]})})})]})})]})})}const Vj=n=>n.split("-").map(a=>a?a.charAt(0).toUpperCase()+a.slice(1):"").join("");function Kj(n,a){const{type:i,ext:r}=n;if(i==="folder")return!1;let c;return i&&i!=="file"&&Cv[i]?c=i:r?c=Cv[r]?r:"file":c="unknown",`https://cdn.svar.dev/icons/filemanager/vivid/${a}/${c}.svg`}const Wj=f.forwardRef(function(n,a){const{data:i=[],mode:r="cards",drive:c=null,preview:d=!1,panels:h=null,activePanel:p=0,readonly:x=!1,menuOptions:g=Y1,extraInfo:w=null,init:v=null,icons:b=Kj,previews:k=null,...j}=n,M=f.useRef();M.current=j;const T=f.useMemo(()=>new G1(Iy),[]),C=f.useMemo(()=>T.in,[T]),A=f.useRef(null);A.current===null&&(A.current=new Ey((B,q)=>{const L="on"+Vj(B);M.current&&M.current[L]&&M.current[L](q)}),C.setNext(A.current));const D=f.useMemo(()=>({getState:T.getState.bind(T),getReactiveState:T.getReactive.bind(T),getStores:()=>({data:T}),exec:C.exec,setNext:B=>(A.current=A.current.setNext(B),A.current),intercept:C.intercept.bind(C),on:C.on.bind(C),detach:C.detach.bind(C),getFile:T.getFile.bind(T),serialize:T.serialize.bind(T),templates:{preview:k||(()=>null),icon:b==="simple"?(()=>null):b}}),[T,C]),H=f.useRef(0);return f.useEffect(()=>{if(!H.current)v&&v(D);else{const B=T.getState();T.init({data:i,mode:r,drive:c,preview:d,panels:h||B.panels||[],activePanel:p})}H.current++},[T,i,r,c,d,h,p,v,D]),H.current===0&&T.init({data:i,mode:r,drive:c,preview:d,panels:h||[],activePanel:p}),f.useImperativeHandle(a,()=>({...D}),[D]),l.jsx(jn.Provider,{value:D,children:l.jsx(Nh,{words:Th,optional:!0,children:l.jsx(Lj,{children:l.jsx(Yj,{readonly:x,menuOptions:g,extraInfo:w})})})})});function Qj({fonts:n=!0,children:a}){return a?l.jsx(ov,{fonts:n,children:a}):l.jsx(ov,{fonts:n})}bh(va);function zh(n,a){if(!n||typeof n!="object"||Array.isArray(n))throw new Error(`Invalid Hub ${a} response.`);return n}function xc(n,a,i){const r=zh(n,i);if(!Array.isArray(r[a]))throw new Error(`Invalid Hub ${i} response: ${a} must be an array.`);return r[a]}function Xj(n,a,i){const r=zh(n,i);if(!r[a]||typeof r[a]!="object"||Array.isArray(r[a]))throw new Error(`Invalid Hub ${i} response: ${a} must be an object.`);return r[a]}async function jv(n,a=!1){return xc(await Be(`/api/remote/filesystem/roots${a?"?refresh=1":""}`,void 0,n),"roots","filesystem roots")}async function Rm(n,a){const i=await Be(`/api/remote/filesystem/entries?id=${encodeURIComponent(n)}`,void 0,a);return{folder:Xj(i,"folder","filesystem entries"),entries:xc(i,"entries","filesystem entries")}}async function Zj(n,a){return Be("/api/remote/filesystem/selection/scan",{method:"POST",body:JSON.stringify({itemIds:n})},a)}async function Jj(n,a,i,r){return Be("/api/remote/files/from-hub",{method:"POST",body:JSON.stringify({itemIds:n,deviceIds:a,remoteDirectory:i})},r)}async function ek(n,a=!1){const i=await Be(`/api/remote/files/jobs?active=${a?"1":"0"}`,void 0,n);return{jobs:xc(i,"jobs","file transfer jobs")}}async function tk(n,a){return Be(`/api/remote/files/jobs/${encodeURIComponent(n)}`,void 0,a)}async function nk(n,a){return Be(`/api/remote/files/jobs/${encodeURIComponent(n)}/cancel`,{method:"POST"},a)}async function kv(n){return xc(await Be("/api/remote/filesystem/shared-folders",void 0,n),"folders","shared folders")}async function ak(n,a){return Be("/api/remote/filesystem/shared-folders",{method:"POST",body:JSON.stringify({sourceId:n})},a)}async function sk(n,a,i){return Be(`/api/remote/filesystem/shared-folders/${encodeURIComponent(n)}`,{method:"PATCH",body:JSON.stringify(a)},i)}async function lk(n,a){return Be(`/api/remote/filesystem/shared-folders/${encodeURIComponent(n)}`,{method:"DELETE"},a)}async function ik(n,a,i,r){const c=await Be(`/api/remote/filesystem/shared-folders/${encodeURIComponent(n)}/sync`,{method:"POST",body:JSON.stringify({deviceIds:a,remoteDirectory:i})},r),d=zh(c,"shared folder sync");return{ok:d.ok===!0,jobs:xc(c,"jobs","shared folder sync"),files:Number(d.files||0),totalBytes:Number(d.totalBytes||0)}}function rk(n){return{id:String(n.id),parentId:n.parent,name:n.name,type:n.type==="file"?"file":"folder",size:Number(n.size||0),modifiedAt:n.date?.toISOString()||null,displayPath:String(n.displayPath||n.name),hasChildren:n.lazy===!0||!!n.data?.length,locked:n.locked===!0}}function Mv(n){if(!Number.isFinite(n)||n<=0)return"0 B";const a=["B","KB","MB","GB","TB"];let i=n,r=0;for(;i>=1024&&r<a.length-1;)i/=1024,r+=1;return`${i.toFixed(r===0||i>=100?0:1)} ${a[r]}`}function sd(n){return n.driveType==="network"?"network":n.driveType==="removable"?"removable":"local"}function ok(n){const a=n.filter(i=>sd(i)==="local");return a.find(i=>/\bC:/i.test(`${i.name} ${i.displayPath||""}`))||a[0]||n[0]||null}function ck({hubUrl:n,roots:a,loading:i,error:r,onRefreshRoots:c,onImportFiles:d,onImportFolder:h,onSelectionChange:p,onShareItem:x,onAddSyncFolder:g,onNotice:w}){const v=f.useRef(null),b=f.useRef("/"),k=f.useRef(0),j=f.useRef([]),M=f.useRef(new Map),[T,C]=f.useState(null),[A,D]=f.useState([]),[H,B]=f.useState([]),[q,L]=f.useState(0),[F,ue]=f.useState(null),[W,ce]=f.useState(!1),[Q,se]=f.useState(""),[oe,K]=f.useState(new Set),z=a.find(ne=>ne.id===T)||null,Y=A[A.length-1]||null,U=z?Y?.svarPath||`/${z.name}`:null,R=U;f.useEffect(()=>{j.current=A,b.current=R||"/"},[R,A]);const J=f.useMemo(()=>(M.current.clear(),!z||!R||A.length===0?[]:(A.forEach(ne=>M.current.set(ne.svarPath,ne.hubId)),[...A.map((ne,ye)=>({id:ne.svarPath,parent:ye===0?"/":A[ye-1].svarPath,type:"folder",name:ne.name,date:ne.modifiedAt?new Date(ne.modifiedAt):void 0,lazy:!1})),...H.map(ne=>{const ye=`${R}/${ne.name}`;return M.current.set(ye,ne.id),{id:ye,parent:R,name:ne.name,type:ne.type==="file"?"file":"folder",...ne.type==="file"?{size:ne.size}:{},date:ne.modifiedAt?new Date(ne.modifiedAt):void 0,lazy:ne.type!=="file"&&ne.hasChildren===!0,displayPath:ne.displayPath,locked:ne.locked,driveType:ne.driveType,totalBytes:ne.totalBytes,freeBytes:ne.freeBytes}})])),[z,H,R,A]),he=ne=>M.current.get(String(ne))||String(ne),$=ne=>rk({...ne,id:he(String(ne.id)),parent:he(String(ne.parent))}),ie=async(ne,ye)=>{const be=ne[ne.length-1];if(!be)return;const Z=++k.current;ce(!0),se("");try{const le=await Rm(be.hubId,n);if(Z!==k.current)return;if(!Array.isArray(le.entries))throw new Error("Invalid Hub filesystem entries response.");const Me={...be,displayPath:le.folder.displayPath||be.displayPath,modifiedAt:le.folder.modifiedAt||be.modifiedAt},je=[...ne.slice(0,-1),Me];j.current=je,D(je),B(le.entries),L(ct=>ct+1)}catch(le){if(Z!==k.current)return;console.error("[LiveDesk FS] folder navigation failed",{folderId:be.hubId,error:le}),se(le instanceof Error?`${ye}: ${le.message}`:`${ye}: Unable to read this folder.`)}finally{Z===k.current&&ce(!1)}},we=async ne=>{const ye={svarPath:`/${ne.name}`,hubId:ne.id,name:ne.name,displayPath:ne.displayPath,modifiedAt:ne.modifiedAt},be=++k.current;C(ne.id),j.current=[ye],D([ye]),b.current=ye.svarPath,B([]),se(""),ce(!0),ue(ne.id),K(Z=>{const le=new Set(Z);return le.delete(ne.id),le});try{const Z=await Rm(ne.id,n);if(be!==k.current)return;if(!Array.isArray(Z.entries))throw new Error("Invalid Hub filesystem entries response.");const le={...ye,displayPath:Z.folder.displayPath||ye.displayPath,modifiedAt:Z.folder.modifiedAt||ye.modifiedAt};j.current=[le],D([le]),B(Z.entries),L(Me=>Me+1)}catch(Z){if(be!==k.current)return;console.error("[LiveDesk FS] getEntries failed",{rootId:ne.id,error:Z}),K(le=>new Set(le).add(ne.id)),se(Z instanceof Error?`${ne.name}: ${Z.message}`:`${ne.name}: Unable to read this drive.`),w(Z instanceof Error?`${ne.name}: ${Z.message}`:`${ne.name}: Unable to read this drive.`)}finally{be===k.current&&(ue(null),ce(!1))}},me=ne=>{const ye=j.current;ne<0||ne>=ye.length||ne===ye.length-1||ie(ye.slice(0,ne+1),ye[ne].name)},ze=(ne,ye)=>{if(ne.type!=="folder")return;const be=j.current,Z=be.findIndex(Me=>Me.svarPath===ye);if(Z<0)return;const le={svarPath:`${ye}/${ne.name}`,hubId:ne.id,name:ne.name,displayPath:ne.displayPath,modifiedAt:ne.modifiedAt};ie([...be.slice(0,Z+1),le],ne.name)},Pe=()=>me(j.current.length-2),de=ne=>{if(ne.key!=="Enter"&&ne.code!=="Enter"&&ne.code!=="NumpadEnter"||ne.target?.closest('button, input, textarea, [contenteditable="true"]'))return;const be=v.current;if(!be)return;const Z=be.getState().panels?.flatMap(Me=>Me.selected||[])||[];if(Z.length!==1)return;const le=be.getFile(String(Z[0]));le?.type==="folder"&&(ne.preventDefault(),ne.stopPropagation(),ze($(le),String(le.parent||b.current)))};f.useEffect(()=>{const ne=a.find(ye=>ye.id===T)||ok(a);if(K(ye=>new Set([...ye].filter(be=>a.some(Z=>Z.id===be)))),!ne){C(null),j.current=[],D([]),B([]);return}we(ne)},[a]);const He=ne=>{v.current=ne,ne.on("request-data",async({id:ye})=>{const be=String(ye),Z=he(be);try{const le=await Rm(Z,n);if(!Array.isArray(le.entries))throw new Error("Invalid Hub filesystem entries response.");const Me=le.entries.map(je=>{const ct=`${be}/${je.name}`;return M.current.set(ct,je.id),{id:ct,parent:be,name:je.name,type:je.type==="file"?"file":"folder",...je.type==="file"?{size:je.size}:{},date:je.modifiedAt?new Date(je.modifiedAt):void 0,lazy:je.type!=="file"&&je.hasChildren===!0,displayPath:je.displayPath,locked:je.locked,driveType:je.driveType,totalBytes:je.totalBytes,freeBytes:je.freeBytes}});await ne.exec("provide-data",{id:be,data:Me})}catch(le){console.error("[LiveDesk FS] nested getEntries failed",{id:Z,error:le}),w(le instanceof Error?le.message:"Unable to read this folder.")}}),ne.intercept("set-path",({id:ye})=>{const be=String(ye),Z=j.current.findIndex(Me=>Me.svarPath===be);if(Z>=0)return me(Z),!1;const le=ne.getFile(be);if(le?.type==="folder")return ze($(le),String(le.parent||b.current)),!1}),ne.intercept("open-file",()=>!1),ne.on("select-file",()=>{window.setTimeout(()=>{const Z=(ne.getState().panels?.flatMap(le=>le.selected||[])||[]).map(le=>ne.getFile(le)).filter(Boolean).map(le=>$(le));p(Z.map(le=>le.id),Z)},0)})},Le=(ne,ye)=>{const be=ye?$(ye):null,Z=()=>{const le=be?.type==="file"?String(ye?.parent||b.current):String(ye?.id||b.current);v.current?.exec("request-data",{id:le})};return ne==="body"?[{id:"refresh",text:"Refresh",icon:"mdi mdi-refresh",handler:Z},{id:"properties",text:"Properties",icon:"mdi mdi-information-outline",handler:()=>w("Select a file or folder to view its properties.")}]:ne==="multiselect"?[{id:"share",text:"Share to workstations",icon:"mdi mdi-share-variant",handler:()=>{(v.current?.getState().panels?.flatMap(Me=>Me.selected||[])||[]).forEach(Me=>{const je=v.current?.getFile(Me);je&&x($(je))})}},{id:"refresh",text:"Refresh",icon:"mdi mdi-refresh",handler:Z}]:be?[{id:"share",text:"Share to workstations",icon:"mdi mdi-share-variant",handler:()=>x(be)},...be.type==="folder"?[{id:"sync",text:"Add folder to Sync",icon:"mdi mdi-folder-sync-outline",handler:()=>g(be)}]:[],{id:"copy-path",text:"Copy path",icon:"mdi mdi-content-copy",handler:()=>{qi(be.displayPath||be.name)}},{id:"refresh",text:"Refresh",icon:"mdi mdi-refresh",handler:Z},{id:"properties",text:"Properties",icon:"mdi mdi-information-outline",handler:()=>w(`${be.name}
|
|
12
|
+
${be.displayPath||""}`)}]:[]},Fe=async()=>{try{await c()}catch(ne){w(ne instanceof Error?ne.message:"Unable to refresh Hub drives.")}},qe=[{id:"local",label:"Local drives",icon:Vo,roots:a.filter(ne=>sd(ne)==="local")},{id:"removable",label:"Removable drives",icon:Ub,roots:a.filter(ne=>sd(ne)==="removable")},{id:"network",label:"Network drives",icon:gh,roots:a.filter(ne=>sd(ne)==="network")}];return l.jsxs("section",{className:"hub-file-explorer-panel","aria-label":"Hub file explorer",children:[l.jsxs("div",{className:"hub-file-explorer-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Hub file explorer"}),l.jsxs("strong",{children:[l.jsx(Vo,{size:16})," Browse files on this Hub"]})]}),l.jsxs("div",{className:"hub-file-explorer-heading-actions",children:[l.jsx("button",{className:"icon-button",onClick:d,title:"Import files from this browser",type:"button",children:l.jsx(ay,{size:16})}),l.jsx("button",{className:"icon-button",onClick:h,title:"Import folder from this browser",type:"button",children:l.jsx(Pb,{size:16})}),l.jsx("button",{className:"icon-button",onClick:()=>{Fe()},title:"Refresh drives",type:"button",children:l.jsx(pc,{size:16})})]})]}),i?l.jsxs("div",{className:"hub-file-explorer-state",children:[l.jsx(Vo,{size:24}),l.jsx("strong",{children:"Connecting to LiveDesk Hub file system..."})]}):r?l.jsxs("div",{className:"hub-file-explorer-state error",role:"alert",children:[l.jsx(oc,{size:24}),l.jsx("strong",{children:r})]}):l.jsxs("div",{className:"hub-file-explorer-content",children:[l.jsxs("aside",{className:"hub-file-explorer-drive-sidebar","aria-label":"Hub drives",children:[l.jsxs("div",{className:"hub-drive-sidebar-title",children:[l.jsx(Vo,{size:15}),l.jsx("strong",{children:"This PC"})]}),qe.map(ne=>ne.roots.length>0&&l.jsxs("section",{className:"hub-drive-group",children:[l.jsxs("h3",{children:[l.jsx(ne.icon,{size:13}),ne.label]}),l.jsx("div",{className:"hub-drive-list",children:ne.roots.map(ye=>{const be=ne.icon,Z=oe.has(ye.id)||ye.locked===!0;return l.jsxs("button",{className:`hub-drive-item ${T===ye.id?"active":""} ${Z?"unavailable":""}`,onClick:()=>{we(ye)},"aria-pressed":T===ye.id,type:"button",children:[l.jsx("span",{className:"hub-drive-item-icon",children:l.jsx(be,{size:16})}),l.jsxs("span",{className:"hub-drive-item-copy",children:[l.jsx("strong",{children:ye.name}),l.jsx("small",{children:ye.displayPath||ye.name}),l.jsxs("em",{children:[Mv(ye.freeBytes||0)," free / ",Mv(ye.totalBytes||0)]})]}),F===ye.id?l.jsx(od,{className:"hub-drive-item-status spin",size:15}):Z?l.jsx(kx,{className:"hub-drive-item-status",size:15}):null]},ye.id)})})]},ne.id)),a.length===0&&l.jsxs("div",{className:"hub-drive-sidebar-empty",children:[l.jsx(oc,{size:17}),l.jsx("span",{children:"No drives available."})]})]}),l.jsxs("div",{className:"hub-file-explorer-browser",children:[l.jsxs("div",{className:"hub-file-explorer-navigation",children:[l.jsx("nav",{className:"hub-file-explorer-breadcrumbs","aria-label":"Current Hub folder",children:A.map((ne,ye)=>l.jsxs("span",{className:"hub-file-explorer-breadcrumb-item",children:[ye>0&&l.jsx(xh,{size:13,"aria-hidden":"true"}),l.jsx("button",{className:`hub-file-explorer-breadcrumb ${ye===A.length-1?"current":""}`,onClick:()=>me(ye),"aria-current":ye===A.length-1?"location":void 0,type:"button",children:ne.name})]},ne.svarPath))}),l.jsxs("div",{className:"hub-file-explorer-navigation-actions",children:[W&&l.jsx(od,{className:"hub-file-explorer-loading-icon spin",size:15,"aria-label":"Loading folder"}),l.jsx("button",{className:"icon-button",onClick:Pe,disabled:A.length<=1||W,title:"Back to parent folder",type:"button",children:l.jsx(qb,{size:16})})]})]}),Q&&l.jsxs("div",{className:"hub-file-explorer-folder-error",role:"alert",children:[l.jsx(kx,{size:15}),l.jsx("span",{children:Q})]}),l.jsx("div",{className:"hub-file-explorer-svar",onKeyDownCapture:de,children:l.jsx(Qj,{fonts:!1,children:l.jsx(Wj,{data:J,panels:U?[{path:U,selected:[]}]:void 0,readonly:!0,mode:"table",preview:!1,init:He,icons:"simple",menuOptions:Le},`${z?.id||"no-root"}:${q}`)})})]})]})]})}class uk extends f.Component{state={error:null};static getDerivedStateFromError(a){return{error:a}}componentDidCatch(a,i){console.error("[LiveDesk] Share Files runtime error",a,i.componentStack)}render(){return this.state.error?l.jsxs("section",{className:"file-share-error-boundary",role:"alert",children:[l.jsx(yd,{size:24}),l.jsx("strong",{children:"Share Files could not be opened."}),l.jsx("span",{children:this.state.error.message||"An unexpected file explorer error occurred."}),l.jsxs("button",{className:"text-button",onClick:this.props.onRetry,type:"button",children:[l.jsx(pc,{size:15})," Retry"]})]}):this.props.children}}function dk(n){return n.deviceName||n.hostname||n.deviceId}function fk({devices:n,mode:a,selectedIds:i,onModeChange:r,onToggle:c}){const d=new Set(i);return l.jsxs("section",{className:"distribution-targets",children:[l.jsxs("div",{className:"file-share-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Target"}),l.jsx("strong",{children:a==="all"?`${n.length} connected`:`${i.length} selected`})]}),l.jsxs("div",{className:"file-share-tabs compact","aria-label":"File transfer targets",children:[l.jsxs("button",{className:a==="all"?"active":"",onClick:()=>r("all"),type:"button",children:[l.jsx(sy,{size:14})," All connected"]}),l.jsxs("button",{className:a==="selected"?"active":"",onClick:()=>r("selected"),type:"button",children:[l.jsx(an,{size:14})," Selected"]})]})]}),l.jsx("div",{className:"file-share-device-list","aria-label":"Connected workstation targets",children:n.length===0?l.jsx("div",{className:"file-share-empty-inline",children:"No connected workstations."}):n.map(h=>{const p=a==="all"||d.has(h.deviceId);return l.jsxs("label",{className:`file-share-device-option ${p?"selected":""}`,children:[l.jsx("input",{type:"checkbox",checked:p,disabled:a==="all",onChange:()=>c(h.deviceId)}),l.jsx(an,{size:20,"aria-hidden":"true"}),l.jsxs("span",{children:[l.jsx("strong",{children:dk(h)}),l.jsxs("small",{children:["Slot ",h.slotNumber?String(h.slotNumber).padStart(3,"0"):"-"," / ",h.platform||"unknown OS"]})]}),l.jsx(qn,{size:17,"aria-hidden":"true"})]},h.deviceId)})})]})}function mk(n){if(!Number.isFinite(n)||n<=0)return"0 B";const a=["B","KB","MB","GB","TB"];let i=n,r=0;for(;i>=1024&&r<a.length-1;)i/=1024,r+=1;return`${i.toFixed(r===0||i>=100?0:1)} ${a[r]}`}function hk({folders:n,loading:a,busy:i,canSync:r,onSyncAll:c,onSync:d,onToggleAuto:h,onRemove:p,onAdd:x}){return l.jsxs("section",{className:"file-share-sync-panel",children:[l.jsxs("div",{className:"file-share-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Hub folders"}),l.jsx("strong",{children:"Continuous sync"})]}),l.jsxs("button",{className:"text-button compact",onClick:c,disabled:i||!r||n.length===0,type:"button",children:[l.jsx(Ju,{size:15})," ",i?"Syncing":"Sync all"]})]}),a?l.jsx("div",{className:"file-share-empty-state",children:"Loading Hub sync folders..."}):n.length===0?l.jsxs("button",{className:"file-share-empty-state interactive",onClick:x,type:"button",children:[l.jsx(Ju,{size:28}),l.jsx("strong",{children:"Add a selected Hub folder"}),l.jsx("span",{children:"Hub keeps the manifest and can sync while this browser is closed."})]}):l.jsx("div",{className:"file-share-sync-list",children:n.map(g=>l.jsxs("article",{className:`file-share-sync-row state-${g.status}`,children:[l.jsx("div",{className:"file-share-sync-icon",children:l.jsx(Ju,{size:19})}),l.jsxs("div",{className:"file-share-sync-info",children:[l.jsx("strong",{children:g.name}),l.jsx("span",{children:g.displayPath}),l.jsxs("small",{children:[g.fileCount," files / ",mk(g.totalBytes)," · ",g.lastSyncedAt?`Last sync ${Jm(g.lastSyncedAt)} ago`:g.message||"Not synced yet"]})]}),l.jsxs("label",{className:"file-share-auto-sync",children:[l.jsx("input",{type:"checkbox",checked:g.autoSync,onChange:()=>h(g)}),l.jsx("span",{children:"Auto"})]}),l.jsxs("button",{className:"text-button compact",onClick:()=>d(g),disabled:i||!r||g.status==="syncing",type:"button",children:[l.jsx(pc,{size:14})," Sync now"]}),l.jsx("button",{className:"icon-button",onClick:()=>p(g),title:"Remove sync folder",type:"button",children:l.jsx(hh,{size:15})})]},g.id))})]})}function pk(n){const i=(n.targetMode==="all"?n.devices.map(r=>r.deviceId):n.selectedTargetIds).length>0;return l.jsxs("aside",{className:"file-share-distribution-panel",children:[l.jsxs("div",{className:"file-share-distribution-head",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Distribution"}),l.jsx("strong",{children:"Hub → workstations"})]}),l.jsx(cd,{size:18})]}),l.jsxs("div",{className:"file-share-tabs",role:"tablist","aria-label":"Distribution mode",children:[l.jsx("button",{className:n.tab==="send"?"active":"",onClick:()=>n.onTabChange("send"),role:"tab","aria-selected":n.tab==="send",type:"button",children:"Send"}),l.jsx("button",{className:n.tab==="sync"?"active":"",onClick:()=>n.onTabChange("sync"),role:"tab","aria-selected":n.tab==="sync",type:"button",children:"Sync"})]}),n.tab==="send"?l.jsxs(l.Fragment,{children:[l.jsx(fk,{devices:n.devices,mode:n.targetMode,selectedIds:n.selectedTargetIds,onModeChange:n.onTargetModeChange,onToggle:n.onTargetToggle}),l.jsxs("label",{className:"file-share-destination",children:[l.jsx("span",{children:"Destination folder"}),l.jsxs("div",{children:[l.jsx(nc,{size:15}),l.jsx("input",{value:n.remoteDirectory,onChange:r=>n.onRemoteDirectoryChange(r.target.value),placeholder:"Desktop/LiveDeskFiles"})]}),l.jsx("small",{children:"Blank uses Desktop/LiveDeskFiles."})]}),l.jsxs("div",{className:"file-share-selection-summary",children:[l.jsx("span",{children:"Selected"}),l.jsx("strong",{children:n.selectedSummary})]}),l.jsxs("button",{className:"file-share-share-button",onClick:n.onShare,disabled:!n.canShare,type:"button",children:[l.jsx(cd,{size:17})," Share selected"]}),l.jsxs("button",{className:"file-share-secondary-button",onClick:n.onAddSync,disabled:!n.canAddSync,type:"button",children:[l.jsx(nc,{size:16})," Add selected folder to Sync"]})]}):l.jsx(hk,{folders:n.folders,loading:n.foldersLoading,busy:n.syncBusy,canSync:i,onSyncAll:n.onSyncAll,onSync:n.onSync,onToggleAuto:n.onToggleAuto,onRemove:n.onRemove,onAdd:n.onAddFolder})]})}function gk(n){if(!Number.isFinite(n)||n<=0)return"0 B";const a=["B","KB","MB","GB","TB"];let i=n,r=0;for(;i>=1024&&r<a.length-1;)i/=1024,r+=1;return`${i.toFixed(r===0||i>=100?0:1)} ${a[r]}`}function Av(n){return n.totalBytes>0?Math.max(0,Math.min(100,Math.round(n.sentBytes/n.totalBytes*100))):n.totalFiles>0?Math.max(0,Math.min(100,Math.round(n.completedFiles/n.totalFiles*100))):n.state==="completed"?100:0}function Nv(n){return n.state==="scanning"?"Scanning selected Hub items":n.state==="queued"?"Preparing transfer":n.state==="sending"?`${n.completedFiles}/${n.totalFiles} · ${n.currentPath||"sending"}`:n.state==="completed"?`Sent ${n.totalFiles} file${n.totalFiles===1?"":"s"} to ${n.targetCount} workstation${n.targetCount===1?"":"s"}`:n.state==="partially-failed"?`${n.failedTargets.length} workstation${n.failedTargets.length===1?"":"s"} failed`:n.state==="cancelled"?"Transfer cancelled":n.error||"Transfer failed"}function Tv(n){return["completed","partially-failed","failed","cancelled"].includes(n)}function xk({hubUrl:n,devices:a,localFeatureAccess:i,upgradeNotice:r,notice:c,remoteDirectory:d,onRemoteDirectoryChange:h,targetMode:p,selectedTargetIds:x,onTargetModeChange:g,onTargetToggle:w,filePickerRef:v,folderPickerRef:b,onBrowserFileImport:k,onBrowserFolderImport:j,onNotice:M,onTransferChange:T}){const C=Array.isArray(a)?a:[],[A,D]=f.useState([]),[H,B]=f.useState(!0),[q,L]=f.useState(""),[F,ue]=f.useState([]),[W,ce]=f.useState([]),[Q,se]=f.useState(null),[oe,K]=f.useState(!1),[z,Y]=f.useState([]),[U,R]=f.useState(!0),[J,he]=f.useState(!1),[$,ie]=f.useState("send"),[we,me]=f.useState([]),ze=f.useRef(new Set),Pe=f.useMemo(()=>p==="all"?C.map(ke=>ke.deviceId):x.filter(ke=>C.some(Ne=>Ne.deviceId===ke)),[C,x,p]),de=we.find(ke=>!Tv(ke.state)),He=W.length===1&&W[0].type==="folder"?W[0]:null,Le=W.length===0?"Select files or folders from the Hub explorer.":oe?"Calculating selection size...":Q?`${Q.files} files, ${Q.folders} folders · ${gk(Q.totalBytes)}`:`${W.length} item${W.length===1?"":"s"} selected`,Fe=ke=>{T({id:ke.jobId,state:ke.state,progress:Av(ke),message:Nv(ke)})},qe=f.useCallback(async()=>{const ke=await jv(n,!0);return D(ke),L(""),ke},[n]),ne=async()=>{try{const Ne=(await ek(n,!0)).jobs||[],Oe=await Promise.all([...ze.current].map(async Nt=>{try{return await tk(Nt,n)}catch{return null}})),Dt=[...Ne,...Oe.filter(Boolean)],Za=[...new Map(Dt.map(Nt=>[Nt.jobId,Nt])).values()];me(Za),Za.forEach(Fe),Za.filter(Nt=>Tv(Nt.state)).forEach(Nt=>ze.current.delete(Nt.jobId))}catch{}};f.useEffect(()=>{let ke=!0;B(!0),L(""),Promise.all([qe(),kv(n).then(Oe=>{ke&&Y(Oe)})]).catch(Oe=>{ke&&(L(Oe instanceof Error?"Hub file system is unavailable. Make sure LiveDesk Hub is running on this computer.":"Hub file system is unavailable."),M(Oe instanceof Error?Oe.message:"Hub file system is unavailable."))}).finally(()=>{ke&&(B(!1),R(!1))}),ne();const Ne=window.setInterval(()=>{ne()},800);return()=>{ke=!1,window.clearInterval(Ne)}},[n,qe]),f.useEffect(()=>{if(F.length===0){se(null);return}let ke=!1;return K(!0),Zj(F,n).then(Ne=>{ke||se(Ne)}).catch(Ne=>{ke||M(Ne instanceof Error?Ne.message:"Unable to calculate selected size.")}).finally(()=>{ke||K(!1)}),()=>{ke=!0}},[n,F.join("|")]);const ye=(ke,Ne)=>{ue(ke),ce(Ne)},be=ke=>{ke.forEach(Ne=>ze.current.add(Ne.jobId)),me(Ne=>[...new Map([...Ne,...ke].map(Oe=>[Oe.jobId,Oe])).values()]),ke.forEach(Fe)},Z=async()=>{if(!i){M(r);return}if(F.length===0){M("Select files or folders from the Hub explorer.");return}if(Pe.length===0){M("Choose at least one connected workstation.");return}if(de){M("A Hub transfer is already running.");return}try{const ke=await Jj(F,Pe,d.trim(),n);ze.current.add(ke.jobId),M("Hub transfer queued."),await ne()}catch(ke){M(ke instanceof Error?ke.message:"Unable to start Hub transfer.")}},le=async ke=>{const Ne=ke||He;if(!Ne||Ne.type!=="folder"){M("Select one folder to add it to Sync.");return}try{const Oe=await ak(Ne.id,n);Y(Dt=>[...Dt.filter(Za=>Za.id!==Oe.folder.id),Oe.folder]),ie("sync"),M(`${Ne.name} is ready for Hub sync.`)}catch(Oe){M(Oe instanceof Error?Oe.message:"Unable to add the Hub folder to Sync.")}},Me=async ke=>{if(Pe.length===0){M("Choose at least one connected workstation.");return}he(!0),Y(Ne=>Ne.map(Oe=>Oe.id===ke.id?{...Oe,status:"syncing"}:Oe));try{const Ne=await ik(ke.id,Pe,d.trim(),n);be(Ne.jobs||[]),M(Ne.jobs?.length?"Hub sync queued.":"No changed files to sync.");const Oe=await kv(n);Y(Oe)}catch(Ne){M(Ne instanceof Error?Ne.message:"Unable to sync the Hub folder."),Y(Oe=>Oe.map(Dt=>Dt.id===ke.id?{...Dt,status:"error",message:"Sync failed"}:Dt))}finally{he(!1)}},je=async()=>{he(!0);try{for(const ke of z)await Me(ke)}finally{he(!1)}},ct=async ke=>{try{const Ne=await sk(ke.id,{autoSync:!ke.autoSync},n);Y(Oe=>Oe.map(Dt=>Dt.id===ke.id?Ne.folder:Dt))}catch(Ne){M(Ne instanceof Error?Ne.message:"Unable to update auto sync.")}},sn=async ke=>{try{await lk(ke.id,n),Y(Ne=>Ne.filter(Oe=>Oe.id!==ke.id))}catch(Ne){M(Ne instanceof Error?Ne.message:"Unable to remove the sync folder.")}};return l.jsxs("section",{className:"livedesk-file-explorer",children:[l.jsx("input",{ref:v,className:"hidden-file-input",type:"file",multiple:!0,onChange:ke=>{ke.currentTarget.files&&k(ke.currentTarget.files),ke.currentTarget.value=""}}),l.jsx("input",{ref:b,className:"hidden-file-input",type:"file",multiple:!0,webkitdirectory:"",directory:"",onChange:ke=>{ke.currentTarget.files&&j(ke.currentTarget.files),ke.currentTarget.value=""}}),(c||q)&&l.jsxs("section",{className:"file-share-notice",role:q?"alert":void 0,children:[q||c,l.jsx("button",{className:"icon-button",onClick:()=>{L(""),B(!0),jv(n).then(ke=>D(ke)).catch(()=>L("Hub file system is unavailable.")).finally(()=>B(!1))},title:"Retry",type:"button",children:l.jsx(pc,{size:15})})]}),l.jsx("div",{className:"file-share-workspace",children:l.jsxs(uk,{onRetry:()=>window.location.reload(),children:[l.jsx(ck,{hubUrl:n,roots:A,loading:H,error:q,onRefreshRoots:qe,onImportFiles:()=>v.current?.click(),onImportFolder:()=>b.current?.click(),onSelectionChange:ye,onShareItem:ke=>{ue([ke.id]),ce([ke]),ie("send")},onAddSyncFolder:ke=>{ue([ke.id]),ce([ke]),le(ke)},onNotice:M}),l.jsx(pk,{devices:C,targetMode:p,selectedTargetIds:x,onTargetModeChange:g,onTargetToggle:w,remoteDirectory:d,onRemoteDirectoryChange:h,selectedEntries:W,selectedSummary:Le,canShare:i&&!de&&F.length>0&&Pe.length>0&&!oe,onShare:()=>{Z()},canAddSync:!!He,onAddSync:()=>{le()},tab:$,onTabChange:ie,folders:z,foldersLoading:U,syncBusy:J,onSyncAll:()=>{je()},onSync:ke=>{Me(ke)},onToggleAuto:ke=>{ct(ke)},onRemove:ke=>{sn(ke)},onAddFolder:()=>{le()}})]})}),de&&l.jsx("footer",{className:"file-share-workspace-footer",children:l.jsxs("span",{children:[Nv(de)," · ",Av(de),"% ",l.jsx("button",{className:"icon-button",onClick:()=>{nk(de.jobId,n).then(ke=>{me(Ne=>Ne.map(Oe=>Oe.jobId===ke.jobId?ke:Oe)),Fe(ke)})},title:"Cancel transfer",type:"button",children:l.jsx(Hr,{size:14})})]})})]})}const vk=f.forwardRef(function({value:a,onChange:i,onSubmit:r,onOpenSuggestedTasks:c,suggestedOpen:d=!1,suggestedTaskCount:h,disabled:p=!1},x){return l.jsxs("form",{className:"agents-composer",onSubmit:g=>{g.preventDefault(),r()},children:[l.jsxs("button",{className:`agents-suggested-trigger ${d?"active":""}`,type:"button","aria-label":h===void 0?"Open Suggested tasks":`Open Suggested tasks (${h} available)`,"aria-expanded":d,onClick:c,disabled:p,children:[l.jsx(Gb,{size:17}),h!==void 0&&l.jsx("span",{className:"agents-suggested-count","aria-hidden":"true",children:h})]}),l.jsx("textarea",{ref:x,value:a,onChange:g=>i(g.target.value.slice(0,4e3)),placeholder:"Ask LiveDesk to work across your machines...","aria-label":"Ask LiveDesk",rows:2,disabled:p}),l.jsxs("button",{className:"agents-run-button",type:"submit",disabled:p||!a.trim(),children:[p?l.jsx(od,{className:"spin",size:16}):l.jsx(cd,{size:16}),p?"Running":"Run"]})]})}),yk=["read","processControl","serviceControl","applicationControl","fileRead","fileWrite","fileDelete","shell","script","softwareInstall","network","systemPower","systemConfiguration","userAccount"];function nw(n){return n.deviceName?.trim()||n.hostname?.trim()||n.deviceId}function wk(n){return n==="running"||n==="completed"||n==="failed"||n==="cancelled"?n:"queued"}function bk(n){switch(n){case"process.list":return"Process list";case"system.health":return"System health";case"gpu.status":return"GPU status";case"disk.status":return"Disk status";case"service.status":return"Service status";case"diagnostics.collect":return"Diagnostics";case"process.control":return"Process control";case"service.control":return"Service control";case"application.launch":return"Launch application";case"application.close":return"Close application";case"file.read":return"Read file";case"file.write":return"Write file";case"file.delete":return"Delete file";case"file.list":return"List directory";case"command.run":return"Run command";case"script.run":return"Run script";case"software.install":return"Install software";case"network.status":return"Network status";case"system.power":return"Power action";case"system.configure":return"System configuration";case"logs.collect":return"Collect logs"}}function Sk(n){const a=n.match(/\[([^\]]+)\]/)?.[1]?.trim();if(a)return a;if(n.includes("comfyui"))return"comfyui";if(n.includes("ollama"))return"ollama";const i=n.match(/process(?:\s+(?:named|called))?\s+([a-z0-9._-]+)/i)?.[1];return i&&!["is","running","process"].includes(i)?i:void 0}function Ck(n){const a=n.trim().toLowerCase();return!a||/(stop|restart|kill|terminate|start|launch|close|delete|write|edit|run command|execute|install|shutdown|reboot|sleep|power|file|folder|script|application)/i.test(a)?null:/(process|프로세스|실행 중|실행중|comfyui|running|processes)/i.test(a)?{operation:"process.list",query:Sk(a)}:/(gpu|그래픽|vram|gpu 상태)/i.test(a)?{operation:"gpu.status"}:/(disk|디스크|storage|저장 공간)/i.test(a)?{operation:"disk.status"}:/(service|서비스)/i.test(a)?{operation:"service.status"}:/(diagnostic|진단|로그)/i.test(a)?{operation:"diagnostics.collect"}:/(health|system|시스템|상태)/i.test(a)?{operation:"system.health"}:null}const jk=["이 작업은 아직 지원되지 않습니다.","","현재 지원:","• 시스템 상태 확인","• GPU 상태 확인","• 디스크 상태 확인","• 프로세스 조회","• 서비스 상태 조회","• 진단 로그 수집"].join(`
|
|
13
|
+
`);function kk(n){return n&&typeof n=="object"&&!Array.isArray(n)?n:null}function Da(n){return typeof n=="number"&&Number.isFinite(n)?n:null}function Vu(n){const a=Da(n);return a===null?"":a<1024**2?`${Math.round(a/1024)}K`:a<1024**3?`${(a/1024**2).toFixed(0)}M`:`${(a/1024**3).toFixed(1)}G`}function Mk(n){const a=Da(n);return a===null?"":`${Math.round((a<=1?a:a/100)*100)}%`}function Ak(n){return!n||/^(?:[\w .-]+ )?collected(?:\.)?$/i.test(n.trim())?"":n.trim()}function xd(n,a){if(a.error)return a.error;const i=kk(a.data),r=Ak(a.result||"");if(!i)return r||a.stage||a.status;if(n==="system.health"){const c=typeof i.machine=="string"?i.machine:"",d=Vu(i.freeMemoryBytes),h=Vu(i.totalMemoryBytes),p=Da(i.totalMemoryBytes)&&Da(i.freeMemoryBytes)!==null?`${Math.round(Da(i.freeMemoryBytes)/Da(i.totalMemoryBytes)*100)}% RAM free`:"";return[c,d&&h?`RAM ${d}/${h}`:"",p,typeof i.platform=="string"?i.platform:""].filter(Boolean).join(" · ")||r||a.status}if(n==="disk.status"){const c=typeof i.root=="string"?i.root:"",d=Vu(i.freeBytes),h=Da(i.totalBytes)&&Da(i.freeBytes)!==null?`${Math.round(Da(i.freeBytes)/Da(i.totalBytes)*100)}% free`:"";return[c,d&&`${d} free`,h].filter(Boolean).join(" · ")||r||a.status}if(n==="gpu.status"){const c=typeof i.name=="string"&&i.name?i.name:"No GPU provider",d=Mk(i.usageRatio),h=Da(i.temperatureC)!==null?`${Math.round(Da(i.temperatureC))}°C`:"",p=Vu(i.freeMemoryBytes);return[c,d&&`GPU ${d}`,h,p&&`${p} free`].filter(Boolean).join(" · ")||r||a.status}if(n==="process.list"){const c=Da(i.count);return c!==null?`${c} matching process${c===1?"":"es"}`:r||a.status}if(n==="network.status"){const c=Array.isArray(i.adapters)?i.adapters.length:null;return c!==null?`${c} active adapter${c===1?"":"s"}`:r||a.status}return r||a.stage||a.status}function Rv(n,a){const i=xd(n,a);return a.status==="failed"||a.status==="cancelled"||/\b(?:warning|failed|error|offline|not running|low|timeout|timed out)\b/i.test(`${a.result||""} ${i}`)}function Nk({state:n,operation:a}){const i=n.status==="completed"?uc:n.status==="failed"||n.status==="cancelled"?Hr:n.status==="running"?od:ly,r=n.status==="running"?n.stage||"Working":n.status==="completed"?a?xd(a,n):n.result||"Completed":n.status==="failed"?n.error||"Failed":n.status==="cancelled"?"Cancelled":"Queued";return l.jsxs("div",{className:`agent-target-row status-${n.status}`,"data-agent-target-id":n.deviceId,children:[l.jsx("span",{className:"agent-target-status","aria-hidden":"true",children:l.jsx(i,{size:15})}),l.jsx("strong",{children:n.deviceName}),l.jsx("span",{className:"agent-target-state",children:n.status[0].toUpperCase()+n.status.slice(1)}),l.jsx("small",{children:r})]})}function Tk({operation:n,states:a,status:i,onCancel:r,onRetry:c,busy:d=!1}){const h=["running","queued"].includes(i),[p,x]=f.useState(!1),[g,w]=f.useState("all"),v=f.useMemo(()=>({total:a.length,completed:a.filter(D=>D.status==="completed").length,failed:a.filter(D=>D.status==="failed").length,running:a.filter(D=>D.status==="running").length,queued:a.filter(D=>D.status==="queued").length,cancelled:a.filter(D=>D.status==="cancelled").length}),[a]),b=a.filter(D=>Rv(n,D)),k=b.filter(D=>D.status==="completed").length,j=v.failed>0,M=b.length>0,T=a.filter(D=>g==="issues"?Rv(n,D):g==="running"?D.status==="running"||D.status==="queued":g==="completed"?D.status==="completed":g==="failed"?D.status==="failed":!0),C=M&&!h||i==="completed-with-failures"?"Completed with issues":i[0]?.toUpperCase()+i.slice(1),A=a.filter(D=>D.status==="completed").map(D=>xd(n,D)).filter(Boolean).filter((D,H,B)=>B.indexOf(D)===H).slice(0,2);return l.jsxs("section",{className:"agent-task-block","aria-label":"Task execution",children:[l.jsxs("div",{className:"agent-task-head",children:[l.jsxs("div",{children:[l.jsx("span",{children:"LiveDesk Agent"}),l.jsx("strong",{children:bk(n)})]}),l.jsx("span",{className:`agent-task-status status-${M?"completed-with-failures":i}`,children:C})]}),l.jsxs("div",{className:"agent-task-summary","aria-label":"Task summary",children:[l.jsxs("strong",{children:[v.total," targets"]}),l.jsxs("span",{className:"summary-completed",children:[v.completed," completed"]}),v.running>0&&l.jsxs("span",{className:"summary-running",children:[v.running," running"]}),v.queued>0&&l.jsxs("span",{children:[v.queued," queued"]}),j&&l.jsxs("span",{className:"summary-failed",children:[v.failed," failed"]}),k>0&&l.jsxs("span",{className:"summary-cancelled",children:[k," warning"]}),v.cancelled>0&&l.jsxs("span",{className:"summary-cancelled",children:[v.cancelled," cancelled"]})]}),A.length>0&&l.jsxs("div",{className:"agent-task-result-preview",title:A.join(" · "),children:[l.jsx("span",{children:"Result"}),A.join(" · ")]}),l.jsx("div",{className:"agent-target-chips","aria-label":"Target status overview",children:a.map((D,H)=>{const B=D.status==="completed"?"✓":D.status==="failed"?"×":D.status==="cancelled"?"!":D.status==="running"?"…":"·";return l.jsxs("span",{className:`agent-target-chip status-${D.status}`,title:`${D.deviceName}: ${xd(n,D)}`,"aria-label":`${H+1}. ${D.deviceName}: ${D.status}`,children:[l.jsx("b",{children:String(H+1).padStart(2,"0")}),l.jsx("span",{children:B})]},D.deviceId)})}),a.length>0&&l.jsx("div",{className:"agent-task-details-toggle",children:l.jsxs("button",{type:"button",onClick:()=>x(D=>!D),"aria-expanded":p,children:[p?l.jsx(Yb,{size:14}):l.jsx(iy,{size:14}),p?"Hide details":"Show details"]})}),p&&l.jsxs("div",{className:"agent-task-details",children:[l.jsx("div",{className:"agent-task-filters",role:"tablist","aria-label":"Task result filter",children:["all","issues","running","completed","failed"].map(D=>l.jsx("button",{className:g===D?"active":"",onClick:()=>w(D),role:"tab","aria-selected":g===D,type:"button",children:D==="all"?"All":D==="issues"?"Issues only":D[0].toUpperCase()+D.slice(1)},D))}),l.jsx("div",{className:"agent-task-rows",children:T.length>0?T.map(D=>l.jsx(Nk,{operation:n,state:D},D.deviceId)):l.jsx("small",{className:"agent-task-no-results",children:"No targets match this filter."})})]}),(h||j)&&l.jsxs("div",{className:"agent-task-actions",children:[h&&r&&l.jsxs("button",{onClick:r,disabled:d,type:"button",children:[l.jsx(Vb,{size:14})," Cancel"]}),!h&&j&&c&&l.jsxs("button",{onClick:c,disabled:d,type:"button",children:[l.jsx(tc,{size:14})," Retry failed"]})]})]})}function Rk(n){try{return JSON.stringify(n,null,2).slice(0,6e3)}catch{return"{}"}}function Ek({approval:n,busy:a=!1,onApprove:i,onReject:r}){return l.jsxs("article",{className:"agent-approval-card","aria-label":"Agent approval required",children:[l.jsxs("div",{className:"agent-approval-head",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Approval required"}),l.jsx("strong",{children:n.toolName})]}),l.jsx("span",{className:`agent-approval-risk risk-${n.risk}`,children:n.risk})]}),l.jsx("p",{children:n.description}),l.jsx("pre",{children:Rk(n.arguments)}),l.jsxs("small",{children:["Permission: ",n.permissionMode," · Scope: selected devices only · Expires in 5 minutes"]}),l.jsxs("div",{className:"agent-approval-actions",children:[l.jsxs("button",{className:"reject",disabled:a,onClick:r,type:"button",children:[l.jsx(Hr,{size:14})," Reject"]}),l.jsxs("button",{disabled:a,onClick:()=>i("once"),type:"button",children:[l.jsx(uc,{size:14})," Once"]}),l.jsx("button",{disabled:a,onClick:()=>i("same-action-this-run"),type:"button",children:"Allow same action"}),l.jsx("button",{disabled:a,onClick:()=>i("category-this-run"),type:"button",children:"Allow category"})]}),l.jsxs("div",{className:"agent-approval-scope",children:[l.jsx(yd,{size:13})," Approval is bound to this run, tool, arguments, selected devices, and policy hash."]})]})}function Dk({items:n,onCancel:a,onRetry:i,busyBatchId:r,approvals:c,onApprove:d,onReject:h,busyApprovalId:p}){return l.jsxs("section",{className:"agents-conversation","aria-live":"polite",children:[c.filter(x=>x.status==="pending").map(x=>l.jsx(Ek,{approval:x,busy:p===x.approvalId,onApprove:g=>d(x,g),onReject:()=>h(x)},x.approvalId)),n.length===0&&l.jsxs("div",{className:"agents-empty-conversation",children:[l.jsx("strong",{children:"Ask LiveDesk to work across your machines."}),l.jsx("span",{children:"Start with a read-only request such as “모든 PC에서 ComfyUI가 실행 중인지 확인해줘”."})]}),n.map(x=>{if(x.type==="task"){const g=x;return l.jsx(Tk,{operation:g.operation,states:g.states,status:g.status,onCancel:()=>a(g.batchId,g.agentRunId),onRetry:()=>i(g.batchId),busy:r===g.batchId},g.id)}return l.jsxs("article",{className:`agents-message ${x.type}`,children:[l.jsx("span",{children:x.type==="user"?"You":"LiveDesk Agent"}),l.jsx("p",{children:x.text})]},x.id)})]})}const Ev=["Recommended","Health & capacity","Processes & services","AI workloads","Files & configuration","Software & automation","Network & connectivity","Power & maintenance","Troubleshooting & recovery"],tn=["windows","macos","linux"],ti={"system.health":{label:"system health",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:tn},"gpu.status":{label:"GPU status",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:tn},"disk.status":{label:"disk status",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:tn},"process.list":{label:"process inspection",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:tn},"service.status":{label:"service inspection",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:tn},"diagnostics.collect":{label:"diagnostics collection",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:tn},"process.control":{label:"process control",permissionCategory:"processControl",readOnly:!1,risk:"high",supportedPlatforms:tn},"service.control":{label:"service control",permissionCategory:"serviceControl",readOnly:!1,risk:"high",supportedPlatforms:["windows","linux"]},"application.launch":{label:"application launch",permissionCategory:"applicationControl",readOnly:!1,risk:"medium",supportedPlatforms:tn},"application.close":{label:"application close",permissionCategory:"applicationControl",readOnly:!1,risk:"medium",supportedPlatforms:tn},"file.read":{label:"file reading",permissionCategory:"fileRead",readOnly:!0,risk:"low",supportedPlatforms:tn},"file.write":{label:"file writing",permissionCategory:"fileWrite",readOnly:!1,risk:"high",supportedPlatforms:tn},"file.delete":{label:"file deletion",permissionCategory:"fileDelete",readOnly:!1,risk:"critical",supportedPlatforms:tn},"file.list":{label:"directory listing",permissionCategory:"fileRead",readOnly:!0,risk:"low",supportedPlatforms:tn},"command.run":{label:"command execution",permissionCategory:"shell",readOnly:!1,risk:"critical",supportedPlatforms:tn},"script.run":{label:"script execution",permissionCategory:"script",readOnly:!1,risk:"high",supportedPlatforms:tn},"software.install":{label:"software installation",permissionCategory:"softwareInstall",readOnly:!1,risk:"high",supportedPlatforms:tn},"network.status":{label:"network inspection",permissionCategory:"network",readOnly:!0,risk:"low",supportedPlatforms:tn},"system.power":{label:"power control",permissionCategory:"systemPower",readOnly:!1,risk:"critical",supportedPlatforms:tn},"system.configure":{label:"system configuration",permissionCategory:"systemConfiguration",readOnly:!1,risk:"critical",supportedPlatforms:tn},"logs.collect":{label:"log collection",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:tn}};new Set(Object.keys(ti));const Lk={Recommended:["recommended","overview","fleet","요약","추천"],"Health & capacity":["health","capacity","performance","상태","성능","용량"],"Processes & services":["process","service","application","프로세스","서비스","앱"],"AI workloads":["ai","gpu","comfyui","ollama","인공지능","모델"],"Files & configuration":["file","config","directory","파일","설정","폴더"],"Software & automation":["software","install","automation","프로그램","설치","자동화"],"Network & connectivity":["network","connection","adapter","네트워크","연결","어댑터"],"Power & maintenance":["power","maintenance","restart","전원","유지보수","재시작"],"Troubleshooting & recovery":["troubleshooting","recovery","incident","문제해결","복구","장애"]},Dv=["low","medium","high","critical"];function zk(n){return n.reduce((a,i)=>{const r=ti[i].risk;return Dv.indexOf(r)>Dv.indexOf(a)?r:a},"low")}function _k(n){return tn.filter(a=>n.every(i=>ti[i].supportedPlatforms.includes(a)))}function Ee(n,a,i,r,c,d,h={}){const p=h.description||r,x=c.flatMap(w=>w.split(".")),g=[...new Set([...Lk[a],...d,...x])];return{id:n,category:a,title:i,prompt:r,description:p,requiredOperations:c,risk:h.risk||zk(c),targetSupport:h.targetSupport||"single-or-multiple",supportedPlatforms:h.supportedPlatforms||_k(c),keywords:g,recommended:h.recommended??!1,enabled:!0}}const aw=[Ee("recommended-fleet-health","Recommended","Summarize current target health","Summarize system health, GPU, and disk capacity for the current target workstations.",["system.health","gpu.status","disk.status"],["summary","overview"],{recommended:!0}),Ee("recommended-attention","Recommended","Find targets needing attention","Identify current targets with high resource use, low disk space, or service warnings.",["system.health","disk.status","service.status"],["attention","warning","monitor"],{recommended:!0}),Ee("recommended-performance-compare","Recommended","Compare selected performance","Compare CPU, memory, disk, and GPU capacity across the current targets.",["system.health","disk.status","gpu.status"],["compare","benchmark"],{recommended:!0}),Ee("recommended-gpu-vram","Recommended","Review GPU and VRAM availability","Show GPU temperature, utilization, and VRAM availability for the current targets.",["gpu.status"],["graphics","temperature","utilization"],{recommended:!0}),Ee("recommended-low-disk","Recommended","Locate low disk capacity","Find current targets with low free disk capacity and report the affected volumes.",["disk.status"],["storage","free space","capacity"],{recommended:!0}),Ee("recommended-ai-workers","Recommended","Verify ComfyUI and Ollama workers","Check whether ComfyUI and Ollama workers and their services are available on the current targets.",["process.list","service.status"],["comfyui","ollama","worker"],{recommended:!0}),Ee("recommended-recover-ai","Recommended","Recover stopped AI workers","Find stopped AI workers and relaunch the registered worker application or service on the target workstation.",["process.list","application.launch","service.control"],["recover","start","ai worker"],{targetSupport:"single",recommended:!0}),Ee("recommended-incident-diagnostics","Recommended","Collect an incident diagnostic bundle","Collect health, service, network, and recent log diagnostics for the current targets.",["diagnostics.collect","logs.collect","system.health","network.status"],["incident","report","evidence"],{recommended:!0}),Ee("health-cpu-memory","Health & capacity","Check high CPU and memory use","Find current targets with unusually high CPU or memory usage.",["system.health"],["cpu","memory","load","높은 사용량"]),Ee("health-uptime","Health & capacity","Review workstation uptime","Show uptime, boot time, and current system health for the target workstations.",["system.health"],["uptime","boot","가동시간"]),Ee("health-gpu-temperature","Health & capacity","Check GPU temperature","Check GPU temperature and thermal warnings on the current targets.",["gpu.status"],["thermal","temperature","발열"]),Ee("health-vram-usage","Health & capacity","Check VRAM usage","Report GPU memory usage and remaining VRAM on the current targets.",["gpu.status"],["vram","gpu memory","video memory"]),Ee("health-low-disk","Health & capacity","Find low disk space","Find volumes below a safe free-space threshold on the current targets.",["disk.status"],["disk","storage","free space","디스크"]),Ee("health-gpu-compare","Health & capacity","Compare GPU capacity","Compare GPU model, memory, temperature, and utilization across the current targets.",["gpu.status"],["compare","graphics","capacity"]),Ee("health-system-warnings","Health & capacity","Collect system warnings","Review health, disk, and network status for warnings that need attention.",["system.health","disk.status","network.status"],["warnings","alerts","경고"]),Ee("health-capacity-report","Health & capacity","Build a capacity report","Create a concise capacity report covering CPU, memory, GPU, disk, and network status.",["system.health","gpu.status","disk.status","network.status"],["report","capacity","inventory"]),Ee("process-find-name","Processes & services","Find a running process by name","Find process named [process name] on the current targets.",["process.list"],["find","running","name","실행 중"]),Ee("process-resource-heavy","Processes & services","Find resource-heavy processes","List the processes using the most CPU or memory on the current targets.",["process.list","system.health"],["top","cpu","memory","resource"]),Ee("process-stop-named","Processes & services","Stop a named process","Stop process named [process name] on the target workstation after checking its current state.",["process.list","process.control"],["stop","terminate","종료"],{targetSupport:"single"}),Ee("process-restart-named","Processes & services","Restart a named process","Check process named [process name] and restart it with its registered launch details when available.",["process.list","process.control"],["restart","relaunch","재시작"],{targetSupport:"single"}),Ee("process-launch-app","Processes & services","Launch a registered application","Launch the registered application [application] on the target workstation with [arguments].",["application.launch"],["launch","open","실행"],{targetSupport:"single"}),Ee("process-close-app","Processes & services","Close an application","Close application [application] on the target workstation and report whether it exited cleanly.",["application.close","process.list"],["close","exit","앱 종료"],{targetSupport:"single"}),Ee("service-status-name","Processes & services","Check a service status","Check service [service name] and report its state on the current targets.",["service.status"],["service","status","서비스 상태"]),Ee("service-restart-name","Processes & services","Restart a service safely","Check service [service name], stop it, wait for it to stop, then start it and verify the result.",["service.status","service.control"],["restart","start","stop","서비스 재시작"],{targetSupport:"single"}),Ee("ai-comfyui-status","AI workloads","Check ComfyUI availability","Check the ComfyUI process, service state, and GPU readiness on the current targets.",["process.list","service.status","gpu.status"],["comfyui","stable diffusion","image generation"]),Ee("ai-start-comfyui","AI workloads","Start ComfyUI","If ComfyUI is stopped, launch its registered application or service and verify it is running.",["process.list","application.launch","service.status"],["comfyui","start","launch"],{targetSupport:"single"}),Ee("ai-restart-ollama","AI workloads","Restart Ollama","Check Ollama, restart its registered application or service, and verify the worker is ready.",["process.list","application.close","application.launch","service.status"],["ollama","restart","llm"],{targetSupport:"single"}),Ee("ai-stable-diffusion","AI workloads","Check Stable Diffusion workers","Check Stable Diffusion or Automatic1111 processes and their GPU usage on the current targets.",["process.list","gpu.status"],["stable diffusion","automatic1111","sd"]),Ee("ai-gpu-readiness","AI workloads","Check GPU readiness for AI","Check GPU temperature, VRAM, utilization, and system health before an AI workload starts.",["gpu.status","system.health"],["readiness","inference","training"]),Ee("ai-worker-logs","AI workloads","Collect AI worker logs","Collect recent logs and relevant log files for the AI worker on the target workstation.",["logs.collect","file.list","file.read"],["logs","diagnostics","worker"],{targetSupport:"single"}),Ee("ai-llama-cpp","AI workloads","Check llama.cpp workers","Find llama.cpp or local model worker processes and inspect their recent logs.",["process.list","logs.collect"],["llama.cpp","local model","inference"]),Ee("ai-recover-orphan-python","AI workloads","Recover an orphaned Python worker","Find an orphaned Python AI worker, stop the stale process, then launch its registered worker again.",["process.list","process.control","application.launch"],["python","orphaned","recovery"],{targetSupport:"single"}),Ee("files-list-directory","Files & configuration","List a directory","List files and folders under [path] on the target workstation.",["file.list"],["directory","folder","list","목록"],{targetSupport:"single"}),Ee("files-read-config","Files & configuration","Read a configuration file","Read the relevant settings from configuration file [path] on the target workstation.",["file.read"],["config","settings","read","구성"]),Ee("files-recent-logs","Files & configuration","Find recent log files","List recent log files under [path] and summarize the latest entries.",["file.list","file.read"],["logs","recent","tail"]),Ee("files-update-config","Files & configuration","Update a configuration value","Read configuration file [path], update [change], and report the exact change made.",["file.read","file.write"],["edit","update","설정 변경"],{targetSupport:"single"}),Ee("files-delete-temp","Files & configuration","Delete temporary files","Find temporary files under [path], delete only the requested matches, and report the freed space.",["file.list","file.delete","disk.status"],["cleanup","temp","delete","정리"],{targetSupport:"single"}),Ee("files-compare-config","Files & configuration","Compare configuration files","Read configuration file [path] on the target workstation and compare it with [reference path].",["file.read"],["compare","diff","configuration"]),Ee("files-set-environment","Files & configuration","Set an environment variable","Set environment variable [name] to [value] for the target workstation and verify the resulting configuration.",["system.configure","file.read"],["environment","variable","env","환경변수"],{targetSupport:"single"}),Ee("files-archive-diagnostics","Files & configuration","Write a diagnostic manifest","Collect selected diagnostics and write a manifest file to [path] on the target workstation.",["diagnostics.collect","file.write"],["manifest","export","diagnostic file"],{targetSupport:"single"}),Ee("software-winget-install","Software & automation","Install software with winget","Install package [package name] with winget on the Windows target workstation, then verify it.",["software.install","process.list"],["winget","windows","install","설치"],{targetSupport:"single",supportedPlatforms:["windows"]}),Ee("software-apt-install","Software & automation","Install software with apt","Install package [package name] with apt on the Linux target workstation, then verify it.",["software.install","process.list"],["apt","linux","package","설치"],{targetSupport:"single",supportedPlatforms:["linux"]}),Ee("software-brew-install","Software & automation","Install software with Homebrew","Install package [package name] with brew on the macOS target workstation, then verify it.",["software.install","process.list"],["brew","homebrew","macos","설치"],{targetSupport:"single",supportedPlatforms:["macos"]}),Ee("software-npm-install","Software & automation","Install an npm package","Install npm package [package name] on the target workstation and verify the installed version.",["software.install","command.run"],["npm","node","package"],{targetSupport:"single"}),Ee("software-run-script","Software & automation","Run a registered script","Run the registered script [script path] on the target workstation and report its result.",["script.run"],["script","automation","registered"],{targetSupport:"single"}),Ee("software-run-command","Software & automation","Run a command on one target","Run command [command] on the target workstation and return its exit status and output.",["command.run"],["command","shell","terminal"],{targetSupport:"single"}),Ee("software-verify-install","Software & automation","Verify an installed tool","Check whether [application] is installed, running, and available on the PATH of the current targets.",["process.list","system.health"],["verify","installed","path"]),Ee("software-toolchain-setup","Software & automation","Set up a toolchain","Install the requested package [package name], configure [change], and verify the toolchain on the target workstation.",["software.install","system.configure","process.list"],["toolchain","setup","developer"],{targetSupport:"single"}),Ee("network-adapter-status","Network & connectivity","Check network adapters","Show adapter state, address, and link information for the current targets.",["network.status"],["adapter","ethernet","wifi","네트워크 상태"]),Ee("network-disconnected","Network & connectivity","Find disconnected targets","Find current targets with disconnected or degraded network adapters.",["network.status"],["disconnected","offline","연결 끊김"]),Ee("network-link-speed","Network & connectivity","Check link speed","Report network link speed and duplex information for the current targets.",["network.status"],["speed","bandwidth","duplex"]),Ee("network-warnings","Network & connectivity","Review network warnings","Review network status and recent logs for connectivity warnings on the current targets.",["network.status","logs.collect"],["warning","latency","packet loss"]),Ee("network-diagnostics","Network & connectivity","Collect network diagnostics","Collect network status, system diagnostics, and relevant logs for the current targets.",["network.status","diagnostics.collect","logs.collect"],["diagnostics","incident","connectivity"]),Ee("network-service-failures","Network & connectivity","Find network service failures","Check network status and relevant service states on the current targets.",["network.status","service.status"],["service","failure","dns"]),Ee("network-compare","Network & connectivity","Compare target connectivity","Compare adapter state, addresses, and link speed across the current targets.",["network.status"],["compare","inventory","connectivity"]),Ee("network-intermittent","Network & connectivity","Investigate intermittent connectivity","Investigate intermittent connectivity using network status, service state, and diagnostics evidence.",["network.status","service.status","diagnostics.collect"],["intermittent","unstable","recovery"]),Ee("power-lock","Power & maintenance","Lock the workstation","Lock the target workstation and report the resulting power action status.",["system.power"],["lock","security","잠금"],{targetSupport:"single",risk:"critical"}),Ee("power-logoff","Power & maintenance","Log off the workstation","Log off the target workstation after warning that interactive sessions will close.",["system.power"],["logoff","session","로그오프"],{targetSupport:"single",risk:"critical"}),Ee("power-sleep","Power & maintenance","Put the workstation to sleep","Put the target workstation to sleep after confirming the requested delay of [delay].",["system.power"],["sleep","suspend","절전"],{targetSupport:"single",risk:"critical"}),Ee("power-restart","Power & maintenance","Restart the workstation","Restart the target workstation after confirming that active work may be interrupted.",["system.power"],["restart","reboot","재부팅"],{targetSupport:"single",risk:"critical"}),Ee("power-shutdown","Power & maintenance","Shut down the workstation","Shut down the target workstation after confirming that active work may be interrupted.",["system.power"],["shutdown","power off","종료"],{targetSupport:"single",risk:"critical"}),Ee("power-maintenance-restart","Power & maintenance","Restart after maintenance","Check the target workstation, restart it after maintenance, and verify that it returns online.",["system.health","system.power","network.status"],["maintenance","reboot","verify"],{targetSupport:"single",risk:"critical"}),Ee("power-timezone","Power & maintenance","Set the workstation timezone","Set the target workstation timezone to [timezone] and verify the resulting system configuration.",["system.configure"],["timezone","clock","시간대"],{targetSupport:"single",risk:"critical"}),Ee("power-persistent-environment","Power & maintenance","Persist an environment variable","Persist environment variable [name] with value [value] for the target workstation and verify it.",["system.configure"],["environment","persistent","환경변수"],{targetSupport:"single",risk:"critical"}),Ee("recovery-app-wont-start","Troubleshooting & recovery","Investigate an app that will not start","Inspect [application], review its logs, launch the registered application, and verify the process.",["process.list","application.launch","logs.collect"],["app failure","start","실행 오류"],{targetSupport:"single"}),Ee("recovery-failed-service","Troubleshooting & recovery","Recover a failed service","Inspect service [service name], collect logs, restart it safely, and verify its running state.",["service.status","logs.collect","service.control"],["service failure","recover","서비스 복구"],{targetSupport:"single"}),Ee("recovery-repeated-process","Troubleshooting & recovery","Investigate a repeatedly stopping process","Inspect process [process name], collect diagnostics, stop stale instances, and relaunch the registered process.",["process.list","diagnostics.collect","process.control","application.launch"],["crash loop","process","반복 종료"],{targetSupport:"single"}),Ee("recovery-low-disk","Troubleshooting & recovery","Recover from low disk space","Inspect disk capacity, find temporary files, remove only the requested files, and verify free space.",["disk.status","file.list","file.delete"],["disk full","cleanup","저장공간 부족"],{targetSupport:"single"}),Ee("recovery-gpu-overheating","Troubleshooting & recovery","Investigate GPU overheating","Inspect GPU temperature and processes, then close the specified workload if it is causing the thermal warning.",["gpu.status","process.list","application.close"],["overheating","thermal","GPU 발열"],{targetSupport:"single"}),Ee("recovery-high-vram","Troubleshooting & recovery","Recover high VRAM usage","Inspect VRAM usage and GPU processes, then stop the specified stale workload if necessary.",["gpu.status","process.list","process.control"],["vram","memory pressure","VRAM 부족"],{targetSupport:"single"}),Ee("recovery-network-instability","Troubleshooting & recovery","Recover network instability","Collect network diagnostics, inspect network services, and report the safest recovery action for the target workstation.",["network.status","service.status","diagnostics.collect"],["network","unstable","네트워크 복구"],{targetSupport:"single"}),Ee("recovery-incident-report","Troubleshooting & recovery","Create a full incident report","Create a full incident report from health, process, service, network, and log evidence for the current targets.",["system.health","process.list","service.status","network.status","logs.collect"],["incident","report","장애 보고서"])],Em={read:"allow",processControl:"allow",serviceControl:"allow",applicationControl:"ask",fileRead:"allow",fileWrite:"allow",fileDelete:"ask",shell:"ask",script:"ask",softwareInstall:"ask",network:"allow",systemPower:"ask",systemConfiguration:"ask",userAccount:"deny"};function Ok(n,a){return n==="safe-auto"?Em:n==="full-access"?{...Em,processControl:"allow",serviceControl:"allow",applicationControl:"allow",fileDelete:"allow",shell:"allow",script:"allow",softwareInstall:"allow",systemPower:"allow",systemConfiguration:"allow"}:n==="custom"&&a?a:{...Em,processControl:"ask",serviceControl:"ask",applicationControl:"ask",fileWrite:"ask",network:"ask"}}function Ik(n,a,i){const r=Ok(a,i),c=n.requiredOperations.map(d=>r[ti[d].permissionCategory]);if(c.includes("deny")){const d=n.requiredOperations.find(h=>r[ti[h].permissionCategory]==="deny");return{state:"blocked",label:"Blocked",reason:`This task requires ${ti[d].label}, which is blocked by the current permission policy.`}}return c.includes("ask")?{state:"approval",label:"Approval required",reason:"This task requires approval before the requested changes can reach a workstation."}:n.requiredOperations.every(d=>ti[d].readOnly)?{state:"read-only",label:"Read only"}:a==="full-access"?{state:"full-access",label:"Full Access"}:{state:"auto",label:"Auto allowed"}}function Bk(n){const a=String(n||"").trim().toLowerCase();return a==="windows"||a==="win32"||a==="win32nt"?"windows":a==="macos"||a==="macosx"||a==="darwin"||a==="osx"?"macos":a==="linux"?"linux":null}function Fk(n,a,i){const r=new Set(i);return n.filter(c=>c.connected&&(a==="all"||r.has(c.deviceId)))}function Hk(n,a){const i=Bk(n.platform);if(!i||!a.supportedPlatforms.includes(i))return!1;const r=n.capabilities?.agentTools;return!Array.isArray(r)||r.length===0?a.requiredOperations.every(c=>ti[c].readOnly):a.requiredOperations.every(c=>r.includes(c))}function sw(n,a,i,r,c,d){const h=Ik(n,c,d),p=Fk(a,i,r),x=p.map(k=>k.deviceId),g={...h,available:!1,availableDeviceIds:[],unsupportedDeviceIds:x,risk:n.risk,supportedPlatforms:n.supportedPlatforms};if(p.length===0)return{...g,reason:"Select at least one connected workstation."};if(n.targetSupport==="single"&&p.length!==1)return{...g,reason:"This task supports one workstation at a time."};if(h.state==="blocked")return g;const w=p.filter(k=>Hk(k,n)),v=w.map(k=>k.deviceId),b=x.filter(k=>!v.includes(k));return w.length===0?{...g,unsupportedDeviceIds:b,reason:"No current target supports the required platform and client capabilities."}:{...g,available:!0,availableDeviceIds:v,unsupportedDeviceIds:b}}function $k(n,a,i,r,c,d){return n.filter(h=>h.enabled&&sw(h,a,i,r,c,d).available).length}const Dm="livedesk.agentPromptRecent",Lm="livedesk.agentPromptFavorites",Uk={Recommended:Vi,"Health & capacity":nn,"Processes & services":eS,"AI workloads":Jb,"Files & configuration":Zb,"Software & automation":mh,"Network & connectivity":gh,"Power & maintenance":Sn,"Troubleshooting & recovery":Xb};function Lv(n){if(typeof window>"u")return[];try{const a=JSON.parse(window.localStorage.getItem(n)||"[]");return Array.isArray(a)?a.filter(i=>typeof i=="string"):[]}catch{return[]}}function Ku(n,a){try{window.localStorage.setItem(n,JSON.stringify(a))}catch{}}function zm(n){return n==="all"?"All tasks":n==="recent"?"Recent":n==="favorites"?"Favorites":n==="read-only"?"Read only":n==="auto"?"Auto allowed":n==="approval"?"Approval required":n==="full-access"?"Full Access":n==="available"?"Available":n==="unavailable"?"Unavailable":n}function Pk(n){return n==="all"?"All":n==="recent"?"Recent":n==="favorites"?"Favorites":n==="read-only"?"Read only":n==="auto"?"Auto":n==="approval"?"Approval":n==="full-access"?"Full access":n==="available"?"Available":n==="unavailable"?"Unavailable":{Recommended:"Recommended","Health & capacity":"Health","Processes & services":"Processes","AI workloads":"AI","Files & configuration":"Files","Software & automation":"Software","Network & connectivity":"Network","Power & maintenance":"Power","Troubleshooting & recovery":"Recovery"}[n]}function qk(n,a,i){if(!i.trim())return!0;const r=i.trim().toLowerCase();return[n.title,n.prompt,n.description,n.category,n.risk,a.label,...n.keywords,...n.requiredOperations,...n.supportedPlatforms].join(" ").toLowerCase().includes(r)}function Gk(n){return`permission-${n}`}function Yk(n){return n==="low"?"Low risk":n==="medium"?"Medium risk":n==="high"?"High risk":"Critical risk"}function Vk(n){return n==="windows"?"Windows":n==="macos"?"macOS":"Linux"}function Kk({devices:n,targetMode:a,selectedIds:i,permissionMode:r,customCategories:c,onSelectPrompt:d,onClose:h}){const[p,x]=f.useState(""),[g,w]=f.useState("all"),[v,b]=f.useState(()=>Lv(Dm)),[k,j]=f.useState(()=>Lv(Lm)),[M,T]=f.useState(0),[C,A]=f.useState(""),D=f.useRef(null),H=f.useRef(null),B=f.useMemo(()=>aw.filter(K=>K.enabled),[]),q=f.useMemo(()=>new Map(B.map(K=>[K.id,sw(K,n,a,i,r,c)])),[c,n,r,i,a,B]),L=f.useMemo(()=>[...q.values()].filter(K=>K.available).length,[q]),F=f.useMemo(()=>n.filter(K=>K.connected&&(a==="all"||i.includes(K.deviceId))).length,[n,i,a]),ue=f.useMemo(()=>{const K=B.filter(z=>qk(z,q.get(z.id),p));return g==="recent"?v.map(z=>K.find(Y=>Y.id===z)).filter(z=>!!z):g==="favorites"?k.map(z=>K.find(Y=>Y.id===z)).filter(z=>!!z):g==="all"?K:K.filter(z=>{const Y=q.get(z.id);return g==="read-only"?Y.state==="read-only":g==="auto"?Y.state==="auto":g==="approval"?Y.state==="approval":g==="full-access"?Y.state==="full-access":g==="available"?Y.available:g==="unavailable"?!Y.available:z.category===g})},[q,k,g,v,p,B]),W=f.useMemo(()=>g!=="all"?[{category:zm(g),templates:ue}]:Ev.map(K=>({category:K,templates:ue.filter(z=>z.category===K)})).filter(K=>K.templates.length>0),[g,ue]);f.useEffect(()=>{T(K=>Math.min(K,Math.max(0,ue.length-1)))},[ue.length]),f.useEffect(()=>{Ku(Dm,v)},[v]),f.useEffect(()=>{Ku(Lm,k)},[k]),f.useEffect(()=>{H.current?.focus();const K=Y=>{Y.target instanceof Node&&!D.current?.contains(Y.target)&&h()},z=Y=>{Y.key==="Escape"&&(Y.preventDefault(),h())};return document.addEventListener("pointerdown",K),document.addEventListener("keydown",z),()=>{document.removeEventListener("pointerdown",K),document.removeEventListener("keydown",z)}},[h]);const ce=K=>{const z=q.get(K.id);if(!z.available){A(z.reason||"This task is not available for the current targets and permission policy.");return}const Y=[K.id,...v.filter(U=>U!==K.id)].slice(0,10);b(Y),Ku(Dm,Y),d(K.prompt),h()},Q=K=>{j(z=>{const Y=z.includes(K)?z.filter(U=>U!==K):[K,...z];return Ku(Lm,Y),Y})},se=K=>{K.key==="ArrowDown"?(K.preventDefault(),T(z=>Math.min(z+1,Math.max(0,ue.length-1)))):K.key==="ArrowUp"?(K.preventDefault(),T(z=>Math.max(z-1,0))):K.key==="Enter"&&ue[M]&&(K.preventDefault(),ce(ue[M]))};let oe=-1;return l.jsxs("section",{className:"agents-suggested-tasks",ref:D,"aria-label":"Suggested tasks",children:[l.jsxs("header",{className:"agents-suggested-header",children:[l.jsxs("div",{children:[l.jsxs("span",{className:"agents-suggested-title",children:[l.jsx(Vi,{size:15})," Suggested tasks"]}),l.jsxs("small",{children:[L," available · ",B.length," total. Choose a task, edit it, then run it."]})]}),l.jsx("button",{className:"agents-suggested-close",type:"button","aria-label":"Close suggested tasks",onClick:h,children:l.jsx(Hr,{size:16})})]}),l.jsxs("label",{className:"agents-suggested-search",children:[l.jsx(Kb,{size:15,"aria-hidden":"true"}),l.jsx("input",{ref:H,value:p,onChange:K=>x(K.target.value),onKeyDown:se,placeholder:"Search tasks...","aria-label":"Search suggested tasks"})]}),l.jsx("div",{className:"agents-suggested-filters","aria-label":"Task categories and availability filters",children:["all","recent","favorites","read-only","auto","approval","full-access","available","unavailable",...Ev].map(K=>{const z=K==="recent"?Wb:K==="favorites"?Ym:K==="all"?Vi:K==="available"?qn:K==="unavailable"?Qb:K==="read-only"||K==="auto"||K==="approval"||K==="full-access"?Sn:Uk[K];return l.jsxs("button",{className:g===K?"active":"",type:"button",title:zm(K),"aria-label":zm(K),"aria-pressed":g===K,onClick:()=>{w(K),T(0),A("")},children:[l.jsx(z,{size:12})," ",Pk(K)]},K)})}),C&&l.jsx("div",{className:"agents-suggested-notice",role:"status",children:C}),l.jsxs("div",{className:"agents-suggested-list",role:"listbox","aria-label":"Suggested tasks",children:[W.map(K=>l.jsxs("div",{className:"agents-suggested-group",children:[l.jsx("strong",{children:K.category}),K.templates.map(z=>{oe+=1;const Y=oe===M,U=k.includes(z.id),R=q.get(z.id),J=R.availableDeviceIds.length+R.unsupportedDeviceIds.length||F,he=R.available?`Available on ${R.availableDeviceIds.length} of ${J} target${J===1?"":"s"}`:`Unavailable: ${R.reason||"not supported by the current targets"}`;return l.jsxs("div",{className:`agents-suggested-item ${Y?"active":""} ${R.available?"":"unavailable"}`,children:[l.jsxs("button",{className:"agents-suggested-prompt",type:"button",role:"option","aria-selected":Y,"aria-disabled":!R.available,onClick:()=>ce(z),children:[l.jsx("span",{children:z.title}),l.jsx("small",{className:"agents-suggested-description",children:z.description}),l.jsxs("span",{className:"agents-suggested-meta",children:[l.jsx("em",{children:z.category}),l.jsx("em",{className:Gk(R.state),children:R.label}),l.jsx("em",{className:`risk-${z.risk}`,children:Yk(z.risk)}),l.jsx("em",{children:z.supportedPlatforms.map(Vk).join(" · ")}),l.jsx("em",{className:R.available?"availability-ok":"availability-unavailable",children:he}),R.available&&R.unsupportedDeviceIds.length>0&&l.jsxs("em",{className:"availability-warning",children:["Unsupported on ",R.unsupportedDeviceIds.length]})]})]}),l.jsx("button",{className:`agents-suggested-favorite ${U?"favorite":""}`,type:"button","aria-label":U?`Remove ${z.title} from favorites`:`Add ${z.title} to favorites`,"aria-pressed":U,onClick:()=>Q(z.id),children:l.jsx(Ym,{size:14,fill:U?"currentColor":"none"})})]},z.id)})]},K.category)),ue.length===0&&l.jsx("p",{className:"agents-suggested-empty",children:"No tasks match this search or current filter."})]})]})}function Wk({devices:n,mode:a,selectedIds:i,onModeChange:r,onToggle:c,permissionMode:d,onPermissionModeChange:h}){const p=n.filter(g=>g.connected),x=i.filter(g=>p.some(w=>w.deviceId===g)).length;return l.jsxs("section",{className:"agents-target-picker","aria-label":"Agent targets",children:[l.jsxs("div",{className:"agents-target-toolbar",children:[l.jsx("span",{className:"agents-section-label",children:"Targets"}),l.jsxs("div",{className:"agents-target-modes",children:[l.jsxs("button",{className:a==="all"?"active":"",onClick:()=>r("all"),type:"button",children:[l.jsx(sy,{size:14})," All connected ",l.jsx("small",{children:p.length})]}),l.jsxs("button",{className:a==="selected"?"active":"",onClick:()=>r("selected"),type:"button",children:[l.jsx(uc,{size:14})," Selected ",x]})]}),l.jsxs("label",{className:`agents-permission-picker permission-${d}`,children:[l.jsx(yd,{size:14}),l.jsx("span",{children:"Permission"}),l.jsxs("select",{value:d,onChange:g=>h(g.target.value),"aria-label":"Agent permission mode",children:[l.jsx("option",{value:"ask",children:"Ask"}),l.jsx("option",{value:"safe-auto",children:"Safe Auto"}),l.jsx("option",{value:"full-access",children:"Full Access"}),l.jsx("option",{value:"custom",children:"Custom"})]}),l.jsx(iy,{size:13,"aria-hidden":"true"})]})]}),l.jsx("div",{className:"agents-target-list",children:n.length===0?l.jsx("span",{className:"agents-target-empty",children:"No workstations discovered."}):n.map(g=>{const w=a==="all"?g.connected:i.includes(g.deviceId);return l.jsxs("label",{className:`agents-target-option ${w?"selected":""} ${g.connected?"":"offline"}`,children:[l.jsx("input",{type:"checkbox",checked:w,disabled:!g.connected||a==="all",onChange:()=>c(g.deviceId)}),l.jsx("span",{className:"agents-target-icon",children:l.jsx(an,{size:15})}),l.jsxs("span",{children:[l.jsx("strong",{children:nw(g)}),l.jsx("small",{children:g.connected?"Connected":"Offline"})]}),w&&l.jsx(uc,{className:"agents-target-check",size:15,"aria-hidden":"true"})]},g.deviceId)})})]})}async function Qk(n,a){return Be("/api/settings/agent/plan",{method:"POST",body:JSON.stringify({instruction:a})},n)}async function Xk(n,a){return Be("/api/settings/agent/run",{method:"POST",body:JSON.stringify(a)},n)}async function Zk(n,a){return Be(`/api/settings/agent/runs/${encodeURIComponent(a)}`,void 0,n)}async function Jk(n,a){return Be(`/api/settings/agent/runs/${encodeURIComponent(a)}/cancel`,{method:"POST",body:JSON.stringify({})},n)}async function eM(n){return Be("/api/settings/agent/runs/cancel-all",{method:"POST",body:JSON.stringify({})},n)}async function tM(n,a,i,r){return Be(`/api/settings/agent/runs/${encodeURIComponent(a)}/approvals/${encodeURIComponent(i)}/approve`,{method:"POST",body:JSON.stringify({scope:r})},n)}async function nM(n,a,i,r="User rejected this action."){return Be(`/api/settings/agent/runs/${encodeURIComponent(a)}/approvals/${encodeURIComponent(i)}/reject`,{method:"POST",body:JSON.stringify({reason:r})},n)}async function aM(n,a,i){return Be(`/api/settings/agent/policies/${encodeURIComponent(a)}`,{method:"PUT",body:JSON.stringify({categories:i})},n)}async function sM(n,a){return Be("/api/settings/agent/summary",{method:"POST",body:JSON.stringify(a)},n)}async function lM(n,a){return Be("/api/remote/tasks",{method:"POST",body:JSON.stringify({instruction:a.instruction,deviceIds:a.deviceIds,operation:a.operation,targetQuery:a.targetQuery,approvalLevel:"read-only"})},n)}async function iM(n,a){return Be(`/api/remote/tasks/${encodeURIComponent(a)}`,void 0,n)}async function rM(n,a){return Be(`/api/remote/tasks/${encodeURIComponent(a)}/cancel`,{method:"POST",body:JSON.stringify({})},n)}async function oM(n,a){return Be(`/api/remote/tasks/${encodeURIComponent(a)}/retry`,{method:"POST",body:JSON.stringify({failedOnly:!0})},n)}function Hi(n){return`${n}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function Wu(n,a){const i=new Map(a.map(r=>[r.deviceId,nw(r)]));return n.results.map(r=>({deviceId:r.deviceId,deviceName:r.deviceName||i.get(r.deviceId)||r.deviceId,status:wk(r.status),stage:r.stage||(r.status==="running"?"Checking processes":void 0),result:r.result,data:r.data,error:r.error,sequence:Number.isSafeInteger(r.sequence)?r.sequence:0}))}function cM(n,a){const i=new Map(a.map(r=>[r.deviceId,r]));return n.map(r=>{const c=i.get(r.deviceId);return!c||c.sequence<=r.sequence?r:c})}function uM(n,a){const i=a.filter(d=>d.status==="completed"),r=a.filter(d=>d.status==="failed");if(n.operation==="process.list"){const h=`${i.filter(p=>{const x=p.result||"";return!/not running|no process/i.test(x)&&/running|online|found/i.test(x)}).length}대에서 요청한 프로세스가 실행 중입니다.`;return r.length>0?`${h}
|
|
14
14
|
${r.map(p=>`${p.deviceName}는 ${p.error||"응답하지 않았습니다."}`).join(`
|
|
15
|
-
`)}`:h}return r.length>0?`${i.length}대 완료, ${r.length}대 실패했습니다.`:`${i.length}대 작업이 완료되었습니다.`}const cM={read:"allow",processControl:"ask",serviceControl:"ask",applicationControl:"ask",fileRead:"ask",fileWrite:"ask",fileDelete:"ask",shell:"ask",script:"ask",softwareInstall:"ask",network:"ask",systemPower:"ask",systemConfiguration:"ask",userAccount:"deny"};function uM(n){return n==="safe-auto"?"Safe Auto":n==="full-access"?"Full Access":n==="custom"?"Custom":"Ask"}function dM(n){return n.replace(/([A-Z])/g," $1").replace(/^./,a=>a.toUpperCase())}function fM({hubUrl:n,devices:a}){const[i,r]=f.useState("all"),[c,d]=f.useState([]),[h,p]=f.useState(""),[x,g]=f.useState([]),[w,v]=f.useState(""),[b,k]=f.useState(""),[j,M]=f.useState(""),[T,C]=f.useState("safe-auto"),[A]=f.useState("custom-default"),[D,H]=f.useState(cM),[B,q]=f.useState([]),[L,F]=f.useState(""),[ue,W]=f.useState(!1),[ce,Q]=f.useState(null),[se,oe]=f.useState(!1),[K,z]=f.useState(""),[Y,U]=f.useState(!1),R=f.useRef(null),J=f.useRef(new Set),he=f.useRef(new Set),$=f.useRef(new Set),ie=f.useMemo(()=>a.filter(Z=>Z.connected).map(Z=>Z.deviceId),[a]),we=f.useMemo(()=>Fk(aw,a,i,c,T,D),[D,a,T,c,i]),me=f.useCallback(Z=>{const le=Wu(Z,a);if(g(Me=>Me.map(je=>je.type==="task"&&je.batchId===Z.batchId?{...je,states:rM(je.states,le),status:Z.status}:je)),!["running","queued"].includes(Z.status)&&!J.current.has(Z.batchId)){J.current.add(Z.batchId);const Me=Hi("agent-summary");g(je=>[...je,{type:"agent",id:Me,text:oM(Z,le)}]),Z.operation&&nM(n,{instruction:Z.instructionPreview,operation:Z.operation,total:le.length,completed:le.filter(je=>je.status==="completed").length,failed:le.filter(je=>je.status==="failed").length,results:le.map(je=>({deviceName:je.deviceName,status:je.status,result:je.result,error:je.error}))}).then(je=>{!je.ok||!je.summary||g(ct=>ct.map(sn=>sn.type==="agent"&&sn.id===Me?{...sn,text:je.summary}:sn))}).catch(()=>{}),v(je=>je===Z.batchId?"":je)}},[a,n]),ze=f.useCallback(async Z=>{const le=await sM(n,Z);return me(le),le},[n,me]),Pe=f.useCallback((Z,le)=>{$.current.has(Z.batchId)||($.current.add(Z.batchId),g(Me=>[...Me,{type:"task",id:Hi("task"),batchId:Z.batchId,agentRunId:le,operation:Z.operation||"diagnostics.collect",instruction:Z.instructionPreview,states:Wu(Z,a),status:Z.status}])),me(Z)},[a,me]),de=f.useCallback(async Z=>{const le=await Qk(n,Z);for(const Me of le.taskBatches||[])Pe(Me,Z);if(q(le.approvals||[]),!["running","queued","waiting-approval"].includes(le.status)&&!he.current.has(Z)){he.current.add(Z);const Me=le.finalResponse?.trim()||(le.status==="cancelled"?"Codex 작업을 취소했습니다.":le.error?`Codex 작업이 완료되지 않았습니다: ${le.error}`:"Codex 작업이 완료되었습니다.");g(je=>[...je,{type:le.status==="failed"?"error":"agent",id:Hi("agent-run-result"),text:Me}])}return le},[Pe,n]);f.useEffect(()=>{if(!w)return;let Z=!0;const le=async()=>{try{const je=await ze(w);Z&&!["running","queued"].includes(je.status)&&v("")}catch(je){Z&&z(je instanceof Error?je.message:String(je))}};le();const Me=window.setInterval(()=>{le()},800);return()=>{Z=!1,window.clearInterval(Me)}},[w,ze]),f.useEffect(()=>{if(!b)return;let Z=!0;const le=async()=>{try{const je=await de(b);Z&&!["running","queued","waiting-approval"].includes(je.status)&&(k(""),oe(!1))}catch(je){Z&&z(je instanceof Error?je.message:String(je))}};le();const Me=window.setInterval(()=>{le()},800);return()=>{Z=!1,window.clearInterval(Me)}},[b,de]);const He=async(Z="",le,Me=!1)=>{const je=(Z||h).trim();if(!je||w||b)return;let ct=bk(je);const sn=le||(i==="all"?ie:c.filter(Ne=>ie.includes(Ne)));if(sn.length===0){z("Select at least one connected workstation.");return}if(T==="full-access"&&!se&&!Me){Q({instruction:je,targetIds:sn});return}if(g(Ne=>[...Ne,{type:"user",id:Hi("user"),text:je}]),p(""),U(!1),z(""),(i==="all"?ie:c.filter(Ne=>ie.includes(Ne))).length===0){g(Ne=>[...Ne,{type:"error",id:Hi("no-targets"),text:"연결된 대상 장비를 하나 이상 선택해 주세요."}]);return}if(!ct){try{if(T==="custom"){const Oe=await tM(n,A,D);if(!Oe.ok)throw new Error(Oe.error||"Custom Agent policy could not be saved.")}const Ne=await Wk(n,{instruction:je,deviceIds:sn,permissionMode:T,customPolicyId:A});if(!Ne.ok||!Ne.runId)throw new Error(Ne.error||"Codex Agent run could not be started.");q(Ne.approvals||[]),k(Ne.runId);return}catch(Ne){try{const Oe=await Kk(n,je);Oe.ok&&Oe.plan&&(ct={operation:Oe.plan.operation,query:Oe.plan.targetQuery})}catch{g(Oe=>[...Oe,{type:"error",id:Hi("unsupported"),text:Ne instanceof Error?Ne.message:Sk}])}}if(!ct)return}try{const Ne=await aM(n,{instruction:je,deviceIds:sn,operation:ct.operation,targetQuery:ct.query});if(!Ne.ok||!Ne.batch||!Ne.batchId)throw new Error(Ne.error||"작업을 만들지 못했습니다.");const Oe={type:"task",id:Hi("task"),batchId:Ne.batchId,operation:ct.operation,instruction:je,states:Wu(Ne.batch,a),status:Ne.batch.status};$.current.add(Ne.batchId),g(Dt=>[...Dt,Oe]),v(Ne.batchId)}catch(Ne){z(Ne instanceof Error?Ne.message:String(Ne))}},Le=async(Z,le)=>{F(Z.approvalId);try{const Me=await Jk(n,Z.runId,Z.approvalId,le);if(!Me.ok)throw new Error(Me.error||"Agent approval could not be applied.");await de(Z.runId)}catch(Me){z(Me instanceof Error?Me.message:String(Me))}finally{F("")}},Fe=async Z=>{F(Z.approvalId);try{const le=await eM(n,Z.runId,Z.approvalId);if(!le.ok)throw new Error(le.error||"Agent approval could not be rejected.");await de(Z.runId)}catch(le){z(le instanceof Error?le.message:String(le))}finally{F("")}},qe=async(Z,le)=>{M(Z);try{if(le){const je=await Xk(n,le);for(const ct of je.taskBatches||[])me(ct);k(ct=>ct===le?"":ct);return}const Me=await lM(n,Z);me(Me),v(je=>je===Z?"":je)}catch(Me){z(Me instanceof Error?Me.message:String(Me))}finally{M("")}},ne=async()=>{if(!(ue||!w&&!b)){W(!0);try{const Z=await Zk(n);if(!Z.ok)throw new Error(Z.error||"모든 Agent 작업을 취소하지 못했습니다.");v(""),k(""),q([]),g(le=>le.map(Me=>Me.type==="task"&&["queued","running"].includes(Me.status)?{...Me,status:"cancelled",states:Me.states.map(je=>["queued","running"].includes(je.status)?{...je,status:"cancelled",stage:"Cancelled",error:"Cancelled by user."}:je)}:Me))}catch(Z){z(Z instanceof Error?Z.message:String(Z))}finally{W(!1)}}},ye=async Z=>{M(Z);try{const le=await iM(n,Z);if(!le.ok||!le.batch||!le.batchId)throw new Error(le.error||"재시도하지 못했습니다.");J.current.delete(le.batchId),g(Me=>Me.map(je=>je.type==="task"&&je.batchId===Z?{...je,batchId:le.batchId,states:Wu(le.batch,a),status:le.batch.status}:je)),v(le.batchId)}catch(le){z(le instanceof Error?le.message:String(le))}finally{M("")}},be=Z=>{p(Z),U(!1),window.requestAnimationFrame(()=>R.current?.focus())};return l.jsxs("section",{className:"agents-page",children:[l.jsxs("div",{className:"agents-workspace",children:[(w||b)&&l.jsxs("div",{className:"agents-page-status",children:[l.jsxs("span",{children:[ie.length," workstations · ",uM(T)]}),l.jsx("button",{type:"button",className:"agents-stop-all",onClick:()=>{ne()},disabled:ue,children:ue?"Stopping…":"Stop all"})]}),ce&&l.jsx("div",{className:"agents-permission-modal-backdrop",role:"presentation",children:l.jsxs("section",{className:"agents-permission-modal",role:"dialog","aria-modal":"true","aria-labelledby":"full-access-title",children:[l.jsx("span",{className:"agents-permission-modal-icon",children:l.jsx(yd,{size:20})}),l.jsx("h3",{id:"full-access-title",children:"Confirm Full Access"}),l.jsx("p",{children:"Codex may change files, run commands, manage applications, and modify system state on the selected workstations. This run is still limited to the selected devices, the fixed policy, and the tool budget."}),l.jsxs("div",{className:"agents-permission-modal-actions",children:[l.jsx("button",{type:"button",onClick:()=>Q(null),children:"Cancel"}),l.jsx("button",{type:"button",className:"danger",onClick:()=>{const Z=ce;Q(null),oe(!0),He(Z.instruction,Z.targetIds,!0)},children:"Run with Full Access"})]})]})}),K&&l.jsx("div",{className:"agents-error",role:"alert",children:K}),l.jsx(Rk,{items:x,onCancel:qe,onRetry:ye,busyBatchId:j,approvals:B,onApprove:Le,onReject:Fe,busyApprovalId:L}),l.jsxs("div",{className:"agents-composer-shell",children:[Y&&l.jsx(Yk,{devices:a,targetMode:i,selectedIds:c,permissionMode:T,customCategories:D,onSelectPrompt:be,onClose:()=>U(!1)}),l.jsx(gk,{ref:R,value:h,onChange:p,onSubmit:()=>{He()},onOpenSuggestedTasks:()=>U(Z=>!Z),suggestedOpen:Y,suggestedTaskCount:we,disabled:!!w||!!b})]})]}),l.jsxs("aside",{className:"agents-target-sidebar","aria-label":"Agent targets and permissions",children:[l.jsx(Vk,{devices:a,mode:i,selectedIds:c,onModeChange:r,onToggle:Z=>d(le=>le.includes(Z)?le.filter(Me=>Me!==Z):[...le,Z]),permissionMode:T,onPermissionModeChange:Z=>{C(Z),Z!=="full-access"&&oe(!1)}}),T==="custom"&&l.jsxs("section",{className:"agents-custom-policy","aria-label":"Custom Agent permissions",children:[l.jsxs("div",{className:"agents-custom-policy-head",children:[l.jsxs("div",{children:[l.jsx("span",{className:"agents-section-label",children:"Custom policy"}),l.jsx("strong",{children:"Choose what Codex may do automatically."})]}),l.jsx("span",{children:"Denied actions never reach a device."})]}),l.jsx("div",{className:"agents-custom-policy-grid",children:xk.map(Z=>l.jsxs("label",{children:[l.jsx("span",{children:dM(Z)}),l.jsxs("select",{value:D[Z],onChange:le=>H(Me=>({...Me,[Z]:le.target.value})),children:[l.jsx("option",{value:"allow",children:"Allow automatically"}),l.jsx("option",{value:"ask",children:"Ask every time"}),l.jsx("option",{value:"deny",children:"Deny"})]})]},Z))})]})]})]})}function lw(n){return{type:n.type,deviceIds:n.deviceIds,monitorIndex:n.monitorIndex,label:n.label}}async function iw(n){try{return(await n.json()).error||`${n.status} ${n.statusText}`}catch{return`${n.status} ${n.statusText}`}}async function rw(n,a,i){const r=encodeURIComponent(JSON.stringify({kind:a.kind,fileName:a.fileName,mimeType:n.type||"application/octet-stream",durationMs:a.durationMs,target:lw(a.target)})),c=await fetch(`${li(i)}/api/captures?metadata=${r}`,{method:"POST",headers:{"Content-Type":n.type||"application/octet-stream"},body:n,cache:"no-store"});if(!c.ok)throw new Error(await iw(c));return await c.json()}async function mM(n,a){return await Be("/api/capture-sessions",{method:"POST",body:JSON.stringify({...n,target:lw(n.target)})},a)}async function hM(n,a,i,r){const c=await fetch(`${li(r)}/api/capture-sessions/${encodeURIComponent(n)}/chunks/${a}`,{method:"PUT",headers:{"Content-Type":i.type||"application/octet-stream"},body:i,cache:"no-store"});if(!c.ok)throw new Error(await iw(c));return await c.json()}async function pM(n,a,i){return await Be(`/api/capture-sessions/${encodeURIComponent(n)}/finalize`,{method:"POST",body:JSON.stringify({durationMs:a})},i)}async function zv(n,a){await Be(`/api/capture-sessions/${encodeURIComponent(n)}`,{method:"DELETE"},a)}async function gM(n){return await Be("/api/captures",void 0,n)}function _v(n,a){return`${li(a)}/api/captures/${encodeURIComponent(n)}/content`}async function xM(n,a){return await Be(`/api/captures/${encodeURIComponent(n)}`,{method:"DELETE"},a)}function vM({hubUrl:n,onToast:a}){const[i,r]=f.useState([]),[c,d]=f.useState(!0),h=f.useCallback(async()=>{d(!0);try{r((await gM(n)).captures||[])}catch(x){a(x instanceof Error?x.message:String(x))}finally{d(!1)}},[n,a]);f.useEffect(()=>{h()},[h]);const p=async x=>{const g=_v(x.id,n);if(navigator.share)try{await navigator.share({title:x.fileName,url:g});return}catch{}window.open(g,"_blank","noopener,noreferrer")};return l.jsxs("section",{className:"capture-gallery",children:[l.jsxs("header",{children:[l.jsxs("div",{children:[l.jsx("span",{className:"settings-eyebrow",children:"Capture Gallery"}),l.jsx("h2",{children:"Saved captures"})]}),l.jsxs("button",{className:"text-button",onClick:()=>{h()},type:"button",children:[l.jsx(pc,{size:15})," Refresh"]})]}),c?l.jsx("p",{className:"settings-help",children:"Loading captures..."}):i.length===0?l.jsx("p",{className:"settings-help",children:"No captures saved yet."}):l.jsx("div",{className:"capture-gallery-grid",children:i.map(x=>{const g=_v(x.id,n);return l.jsxs("article",{className:"capture-gallery-card",children:[x.mimeType.startsWith("image/")?l.jsx("img",{src:g,alt:x.target.label}):l.jsx("video",{src:g,controls:!0,preload:"metadata"}),l.jsxs("div",{className:"capture-gallery-card-body",children:[l.jsx("strong",{children:x.fileName}),l.jsxs("small",{children:[x.target.label," · ",new Date(x.createdAt).toLocaleString()," · ",Math.ceil(x.sizeBytes/1024)," KB"]}),l.jsxs("div",{children:[l.jsx("button",{className:"icon-button",title:"Open","aria-label":"Open",onClick:()=>window.open(g,"_blank","noopener,noreferrer"),type:"button",children:l.jsx(Jb,{size:15})}),l.jsx("a",{className:"icon-button",title:"Download","aria-label":"Download",href:`${g}?download=1`,download:x.fileName,children:l.jsx(eS,{size:15})}),l.jsx("button",{className:"icon-button",title:"Share","aria-label":"Share",onClick:()=>{p(x)},type:"button",children:l.jsx(tS,{size:15})}),l.jsx("button",{className:"icon-button danger",title:"Delete","aria-label":"Delete",onClick:()=>{window.confirm(`Delete ${x.fileName}?`)&&xM(x.id,n).then(()=>h()).catch(w=>a(w instanceof Error?w.message:String(w)))},type:"button",children:l.jsx(hh,{size:15})})]})]})]},x.id)})})]})}function Qu(n){if(!n)return"";const a=Math.max(0,Math.floor((Date.now()-n)/1e3)),i=Math.floor(a/3600),r=Math.floor(a%3600/60),c=a%60;return i>0?`${String(i).padStart(2,"0")}:${String(r).padStart(2,"0")}:${String(c).padStart(2,"0")}`:`${String(r).padStart(2,"0")}:${String(c).padStart(2,"0")}`}function Ov({controller:n,compact:a=!1,onFirstRollingUse:i,onError:r}){const{state:c,settings:d,videoSupported:h}=n,p=async v=>{try{await v()}catch(b){r?.(b instanceof Error?b.message:String(b))}},x=async()=>{if(d.rollingEnabled){n.setRollingEnabled(!1);return}(i?await i():window.confirm(`Keep the most recent 30 seconds in memory temporarily?
|
|
16
|
-
Nothing is saved until you press Save Last 30s.`))&&n.setRollingEnabled(!0)},g=c.recording?`Stop recording · ${Qu(c.recordingStartedAt)}`:`Start recording · ${c.targetLabel}`,w=c.timelapse?`Stop timelapse · ${Qu(c.timelapseStartedAt)}`:`Start timelapse · ${d.timelapseIntervalSeconds}s interval`;return l.jsxs("div",{className:`capture-toolbar ${a?"compact":""} ${c.recording?"recording-active":""}`,"aria-label":"Capture actions",children:[l.jsx("button",{className:"capture-action","aria-label":`Take screenshot · ${c.targetLabel}`,title:`Take screenshot · ${c.targetLabel}`,disabled:c.busy,onClick:()=>{p(n.takeScreenshot)},type:"button",children:l.jsx(nS,{size:17})}),l.jsx("button",{className:`capture-action ${c.recording?"active":""}`,"aria-label":g,title:g,disabled:!h||c.busy||c.timelapse,onClick:()=>{p(c.recording?n.stopRecording:n.startRecording)},type:"button",children:c.recording?l.jsxs(l.Fragment,{children:[l.jsx(Mx,{size:14,fill:"currentColor"}),l.jsx("span",{children:Qu(c.recordingStartedAt)})]}):l.jsx(ly,{size:18})}),l.jsxs("button",{className:"capture-action","aria-label":c.bufferEnabled?`Save last 30 seconds · ${c.bufferSeconds}s ready`:"Enable Last 30s memory buffer",title:c.bufferEnabled?`Save last 30 seconds · ${c.bufferSeconds}s ready`:"Enable Last 30s memory buffer",disabled:!h||c.recording||c.timelapse||c.busy||c.bufferEnabled&&c.bufferSeconds<1,onClick:()=>c.bufferEnabled?void p(n.saveLast30Seconds):void x(),type:"button",children:[l.jsx(aS,{size:17}),l.jsx("small",{children:"30s"})]}),l.jsx("button",{className:`capture-action ${c.timelapse?"timelapse-active":""}`,"aria-label":w,title:w,disabled:!h||c.busy||c.recording,onClick:()=>{p(c.timelapse?n.stopTimelapse:n.startTimelapse)},type:"button",children:c.timelapse?l.jsxs(l.Fragment,{children:[l.jsx(Mx,{size:14,fill:"currentColor"}),l.jsx("span",{children:Qu(c.timelapseStartedAt)})]}):l.jsx(sS,{size:17})})]})}async function yM(n,a={}){const i=n.filter(v=>v.canvas&&v.canvas.width>0&&v.canvas.height>0),r=Math.max(320,a.maxWidth||1920),c=Math.max(180,a.maxHeight||1080),d=i.length<=1?1:i.length<=4?2:i.length<=9?3:4,h=Math.max(1,Math.ceil(Math.max(1,i.length)/d)),p=Math.floor(r/d),x=Math.floor(c/h),g=document.createElement("canvas");g.width=Math.max(320,p*d),g.height=Math.max(180,x*h);const w=g.getContext("2d",{alpha:!1});if(!w)return g;w.fillStyle="#0b1220",w.fillRect(0,0,g.width,g.height),w.font="600 14px system-ui, sans-serif",w.textBaseline="bottom";for(let v=0;v<i.length;v+=1){const b=i[v],k=v%d,j=Math.floor(v/d),M=k*p,T=j*x,C=b.canvas,A=Math.min(p/C.width,x/C.height),D=Math.max(1,Math.floor(C.width*A)),H=Math.max(1,Math.floor(C.height*A)),B=M+Math.floor((p-D)/2),q=T+Math.floor((x-H)/2);w.drawImage(C,B,q,D,H),a.includeLabels!==!1&&(w.fillStyle="rgba(4, 10, 20, .74)",w.fillRect(M,T+x-28,p,28),w.fillStyle="#f8fafc",w.fillText(b.label,M+9,T+x-9))}return g}function wM(n){return n?.signature||"none"}function bM(n){return n?.label||"No capture target"}function Iv(n){return{...n,deviceIds:[...n.deviceIds],sourceCanvas:n.sourceCanvas||null}}function SM(){const n=new Date,a=i=>String(i).padStart(2,"0");return`${n.getFullYear()}${a(n.getMonth()+1)}${a(n.getDate())}_${a(n.getHours())}${a(n.getMinutes())}${a(n.getSeconds())}`}function CM(n){return n.replace(/[^a-zA-Z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"Wall"}function jM(n){return`LiveDesk_${n.type==="wall"||n.type==="selection"?"Wall":`${CM(n.label)}_Monitor-${Number(n.monitorIndex||0)+1}`}_${SM()}.png`}async function kM(n,a,i){const r=await new Promise((d,h)=>n.toBlob(p=>p?d(p):h(new Error("Screenshot could not be encoded.")),"image/png")),c=await rw(r,{kind:"screenshot",fileName:jM(a),target:a},i);try{await navigator.clipboard.write([new ClipboardItem({"image/png":r})])}catch{}return c.capture}function ow(){return["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"].find(a=>typeof MediaRecorder<"u"&&MediaRecorder.isTypeSupported(a))||""}function MM(n,a){const i=new Date().toISOString().replace(/[-:]/g,"").replace(/\.\d{3}Z$/,"").replace("T","_"),r=a.label.replace(/[^a-zA-Z0-9._-]+/g,"-").slice(0,70)||"Wall";return n==="timelapse"?`LiveDesk_Timelapse_${r}_${i}.webm`:`LiveDesk_Recording_${r}_${i}.webm`}async function cw(n){if(typeof MediaRecorder>"u"||typeof n.canvas.captureStream!="function")throw new Error("This browser does not support video recording.");const a=ow();if(!a)throw new Error("This browser does not support WebM recording.");const i=n.kind||"recording",r=await mM({kind:i,fileName:MM(i,n.target),mimeType:a,target:n.target},n.hubUrl),c=n.canvas.captureStream(n.frameRequests?0:n.fps),d=new MediaRecorder(c,{mimeType:a,videoBitsPerSecond:i==="timelapse"?2e6:4e6}),h=performance.now();let p=0,x=!1,g=null,w=Promise.resolve();return d.ondataavailable=v=>{if(!v.data||v.data.size===0)return;const b=p++;w=w.then(()=>hM(r.sessionId,b,v.data,n.hubUrl).then(()=>{})).catch(k=>{g=g||(k instanceof Error?k:new Error(String(k))),n.onError?.(g)})},d.onerror=()=>{g=new Error("Video recording stopped unexpectedly."),n.onError?.(g)},d.start(1e3),{requestFrame:()=>{c.getVideoTracks()[0]?.requestFrame?.()},stop:async()=>{if(!x){if(x=!0,await new Promise(v=>{d.addEventListener("stop",()=>v(),{once:!0}),d.stop()}),c.getTracks().forEach(v=>v.stop()),await w,g)throw await zv(r.sessionId,n.hubUrl).catch(()=>{}),g;await pM(r.sessionId,Math.max(0,performance.now()-h),n.hubUrl)}},cancel:async()=>{x||(x=!0,d.stop(),c.getTracks().forEach(v=>v.stop()),await zv(r.sessionId,n.hubUrl).catch(()=>{}))}}}class AM{recorder=null;stream=null;segments=[];totalBytes=0;targetSignature="";startedAt=0;maxDurationMs=3e4;maxBytes=128*1024*1024;get seconds(){return!this.startedAt||this.segments.length===0?0:Math.min(30,Math.max(0,(performance.now()-this.segments[0].at)/1e3))}get active(){return this.recorder!==null}async start(a,i){if(this.recorder&&this.targetSignature===i.signature)return;if(this.stop(),typeof MediaRecorder>"u"||typeof a.captureStream!="function")throw new Error("This browser does not support Last 30s.");const r=ow();if(!r)throw new Error("This browser does not support WebM recording.");this.targetSignature=i.signature,this.stream=a.captureStream(20),this.recorder=new MediaRecorder(this.stream,{mimeType:r,videoBitsPerSecond:3e6}),this.startedAt=performance.now(),this.recorder.ondataavailable=c=>{if(!c.data.size)return;const d=performance.now();for(this.segments.push({blob:c.data,at:d}),this.totalBytes+=c.data.size;this.segments.length>1&&(d-this.segments[0].at>this.maxDurationMs||this.totalBytes>this.maxBytes);){const h=this.segments.shift();this.totalBytes-=h.blob.size}},this.recorder.start(1e3)}stop(){const a=this.recorder;this.recorder=null,a&&a.state!=="inactive"&&(a.ondataavailable=null,a.stop()),this.stream?.getTracks().forEach(i=>i.stop()),this.stream=null,this.segments=[],this.totalBytes=0,this.startedAt=0}async save(a,i){if(this.segments.length===0)throw new Error("The Last 30s buffer is not ready yet.");const r=new Blob(this.segments.map(h=>h.blob),{type:this.segments[0].blob.type||"video/webm"}),d=`LiveDesk_Last30s_${a.label.replace(/[^a-zA-Z0-9._-]+/g,"-").slice(0,70)||"Wall"}_${new Date().toISOString().replace(/[-:]/g,"").replace(/\.\d{3}Z$/,"").replace("T","_")}.webm`;return await rw(r,{kind:"last-30s",fileName:d,target:a,durationMs:Math.min(3e4,this.segments.length*1e3)},i)}}async function NM(n,a,i,r,c){const d=await cw({canvas:n,target:a,kind:"timelapse",fps:30,frameRequests:!0,hubUrl:r,onError:c});d.requestFrame?.();const h=window.setInterval(()=>d.requestFrame?.(),Math.max(5,i)*1e3);return{stop:async()=>{window.clearInterval(h),await d.stop()},cancel:async()=>{window.clearInterval(h),await d.cancel()}}}const uw="livedesk.captureSettings";function TM(){const n={rollingEnabled:!1,recordingQuality:"standard",timelapseIntervalSeconds:10,includeRemoteCursor:!0};try{const a=JSON.parse(localStorage.getItem(uw)||"null");return{...n,...a&&typeof a=="object"?a:{}}}catch{return n}}function RM(n){const[a,i]=f.useState(TM),[r,c]=f.useState(0),[d,h]=f.useState(0),[p,x]=f.useState(0),[g,w]=f.useState(!1),v=f.useRef(void 0),b=f.useRef(!1),k=f.useRef(""),j=f.useRef(null),M=f.useRef(null),T=f.useRef(null),C=f.useRef(null),A=f.useRef(new AM),D=n.sourceRegistry.resolveCurrentTarget(),H=wM(D),B=bM(D),q=typeof MediaRecorder<"u"&&typeof HTMLCanvasElement<"u"&&"captureStream"in HTMLCanvasElement.prototype;f.useEffect(()=>{if(localStorage.setItem(uw,JSON.stringify(a)),!b.current)return;const U=JSON.stringify(a);U!==k.current&&(k.current=U,Be("/api/settings",{method:"PATCH",body:JSON.stringify({revision:v.current,filesAudio:{rollingBufferEnabled:a.rollingEnabled,recordingQuality:a.recordingQuality,timelapseIntervalSeconds:a.timelapseIntervalSeconds,includeRemoteCursor:a.includeRemoteCursor}})},n.hubUrl).then(R=>{v.current=Number(R.revision||v.current||0)}).catch(()=>{}))},[n.hubUrl,a]),f.useEffect(()=>{let U=!0;return Be("/api/settings",void 0,n.hubUrl).then(R=>{if(!U)return;const J=R.settings?.filesAudio||{},he=typeof J.rollingBufferEnabled=="boolean"?J.rollingBufferEnabled:a.rollingEnabled,$=J.recordingQuality==="high"?"high":"standard",ie=[5,10,30,60].includes(Number(J.timelapseIntervalSeconds))?Number(J.timelapseIntervalSeconds):a.timelapseIntervalSeconds,we=typeof J.includeRemoteCursor=="boolean"?J.includeRemoteCursor:a.includeRemoteCursor,me={rollingEnabled:he,recordingQuality:$,timelapseIntervalSeconds:ie,includeRemoteCursor:we};v.current=Number(R.revision||0),k.current=JSON.stringify(me),b.current=!0,i(me)}).catch(()=>{b.current=!0}),()=>{U=!1}},[n.hubUrl]);const L=f.useCallback(async U=>{if(U.sourceCanvas&&U.sourceCanvas.width>0&&U.sourceCanvas.height>0)return{target:Iv(U),canvas:U.sourceCanvas,cleanup:()=>{}};const R=await n.sourceRegistry.composeWall(U.deviceIds,{maxWidth:1920,maxHeight:1080,includeLabels:!0});let J=!1;const he=window.setInterval(async()=>{if(J)return;const $=await n.sourceRegistry.composeWall(U.deviceIds,{maxWidth:1920,maxHeight:1080,includeLabels:!0}).catch(()=>null);!$||J||((R.width!==$.width||R.height!==$.height)&&(R.width=$.width,R.height=$.height),R.getContext("2d")?.drawImage($,0,0))},100);return{target:Iv(U),canvas:R,cleanup:()=>{J=!0,window.clearInterval(he)}}},[n.sourceRegistry]);f.useEffect(()=>{const U=A.current;if(!a.rollingEnabled||!D||!q){U.stop(),x(0);return}let R=!1,J=null;return(async()=>{try{if(J=await L(D),R)return;await U.start(J.canvas,J.target);const $=window.setInterval(()=>x(Math.round(U.seconds)),500),ie=()=>{window.clearInterval($),J?.cleanup()};U.__cleanup=ie}catch($){R||n.onToast($ instanceof Error?$.message:String($))}})(),()=>{R=!0,U.stop(),U.__cleanup?.(),U.__cleanup=void 0,x(0)}},[L,n.onToast,a.rollingEnabled,H,q]);const F=f.useCallback(U=>i(R=>({...R,rollingEnabled:U})),[]),ue=f.useCallback(U=>i(R=>({...R,recordingQuality:U})),[]),W=f.useCallback(U=>i(R=>({...R,timelapseIntervalSeconds:U})),[]),ce=f.useCallback(async()=>{const U=n.sourceRegistry.resolveCurrentTarget();if(!U)throw new Error("화면이 준비된 후 다시 시도하세요.");w(!0);let R=null;try{R=await L(U),await kM(R.canvas,R.target,n.hubUrl),n.onToast("Screenshot saved")}finally{R?.cleanup(),w(!1)}},[L,n.hubUrl,n.onToast,n.sourceRegistry]),Q=f.useCallback(async()=>{if(T.current)throw new Error("Stop the timelapse before recording.");const U=n.sourceRegistry.resolveCurrentTarget();if(!U)throw new Error("화면이 준비된 후 다시 시도하세요.");const R=await L(U),J=await cw({canvas:R.canvas,target:R.target,fps:U.type==="control"?30:15,hubUrl:n.hubUrl,onError:he=>n.onToast(he.message)});M.current=R.cleanup,j.current=J,c(Date.now()),n.onToast("Recording started")},[L,n.hubUrl,n.onToast,n.sourceRegistry]),se=f.useCallback(async()=>{const U=j.current;if(U){w(!0);try{await U.stop(),n.onToast("Recording saved")}finally{j.current=null,M.current?.(),M.current=null,c(0),w(!1)}}},[n.onToast]),oe=f.useCallback(async()=>{if(j.current||T.current)throw new Error("Last 30s is unavailable during a recording.");const U=n.sourceRegistry.resolveCurrentTarget();if(!U)throw new Error("화면이 준비된 후 다시 시도하세요.");w(!0);try{await A.current.save(U,n.hubUrl),n.onToast("Last 30 seconds saved")}finally{w(!1)}},[n.hubUrl,n.onToast,n.sourceRegistry]),K=f.useCallback(async()=>{if(j.current)throw new Error("Stop the recording before starting a timelapse.");const U=n.sourceRegistry.resolveCurrentTarget();if(!U)throw new Error("화면이 준비된 후 다시 시도하세요.");const R=await L(U),J=await NM(R.canvas,R.target,a.timelapseIntervalSeconds,n.hubUrl,he=>n.onToast(he.message));C.current=R.cleanup,T.current=J,h(Date.now()),n.onToast("Timelapse started")},[L,n.hubUrl,n.onToast,n.sourceRegistry,a.timelapseIntervalSeconds]),z=f.useCallback(async()=>{const U=T.current;if(U){w(!0);try{await U.stop(),n.onToast("Timelapse saved")}finally{T.current=null,C.current?.(),C.current=null,h(0),w(!1)}}},[n.onToast]);return f.useEffect(()=>{const U=R=>{!j.current&&!T.current||(R.preventDefault(),R.returnValue="")};return window.addEventListener("beforeunload",U),()=>window.removeEventListener("beforeunload",U)},[]),f.useEffect(()=>()=>{A.current.stop(),j.current?.cancel(),T.current?.cancel(),M.current?.(),C.current?.()},[]),{state:f.useMemo(()=>({recording:!!j.current,recordingStartedAt:r,timelapse:!!T.current,timelapseStartedAt:d,bufferSeconds:p,bufferEnabled:a.rollingEnabled,busy:g,targetLabel:B}),[p,g,r,a.rollingEnabled,B,d]),settings:a,videoSupported:q,targetKey:H,setRollingEnabled:F,setRecordingQuality:ue,setTimelapseInterval:W,takeScreenshot:ce,startRecording:Q,stopRecording:se,saveLast30Seconds:oe,startTimelapse:K,stopTimelapse:z}}const EM=120,DM=999,Qo=5,Xo=30,LM=Number.POSITIVE_INFINITY,dw="livedesk.remoteDirectory",ih="livedesk.localHubAccessEnabled",fw="livedesk.streamSettings",mw=15,hw="livedesk.controlStreamSettings",rh=6,_m=512*1024,oh="".trim(),pw="".trim(),Bv="livedesk-adsense-script",Om=!!oh&&!!pw,zM=1e3/60,Im=1500,_M=650,OM=1800,IM=650,BM=2500,Fv=1500,Hv=15e3,FM=6e4,$v=240,HM=1024,$M=480,UM=270;function PM(n,a){if(a.deviceId!==n.deviceId)return!1;const i=Number(a.browserReceivedEpochMs);if(!Number.isFinite(i)||i<n.startedAtEpochMs)return!1;const r=Number(a.monitorIndex);if(Number.isFinite(r)&&Math.floor(r)!==n.monitorIndex)return!1;const c=String(a.frameMode||a.mode||"").trim().toLowerCase();return!c||c===n.frameMode?!0:n.frameMode==="mode5-lzo-delta"&&c==="mode3-h264-hw"}const $i={free:{name:"Free",price:"$0",limit:Qo,audience:"Personal trial",note:"5 devices with a standard ad banner."},ltd:{name:"Plus",price:"$79 LTD",ltd:"$79 LTD",limit:Xo,audience:"Creators and homelabs",note:"30 devices, no ads, personal use."},pro:{name:"Pro",price:"$199 LTD",ltd:"$199 LTD",limit:LM,audience:"Business and studios",note:"Commercial use and larger workstation walls."}},gw={"mode1-jpeg":5,"mode2-lzo":8,"mode3-h264-hw":20,"mode4-h264-atlas":20};function ys(n,a){return`${n}:${a}`}const ha={frameMode:"mode3-h264-hw",h264DecodeAcceleration:"prefer-hardware",fps:gw["mode3-h264-hw"],maxWidth:1920,maxHeight:1080,atlasTileWidth:320,atlasTileHeight:180,atlasTileSizeMode:"auto",quality:75,autoStartLive:!0,showScreenStatus:!0,visibleOnlyLive:!0,adaptiveLoadShedding:!0,adaptiveSizeByWall:!0},pa={frameMode:"mode3-h264-hw",h264DecodeAcceleration:"prefer-software",fps:30,maxWidth:1920,maxHeight:1080,quality:75,showScreenStatus:!1};function ld(n,a){if(n.length===0)return 0;const i=[...n].sort((c,d)=>c-d),r=Math.max(0,Math.min(i.length-1,Math.ceil(i.length*a)-1));return i[r]}function _h(n,a){n.push(a),n.length>$v&&n.splice(0,n.length-$v)}function Uv(n,a){n.sampleFrames=0,n.sampleStartedAt=a,n.intervalCount=0,n.intervalSumMs=0,n.minIntervalMs=Number.POSITIVE_INFINITY,n.maxIntervalMs=0,n.intervalSamplesMs.length=0,n.seqGapCount=0,n.maxSeqGap=0}function Pv(n,a,i){if(n.lastAt!==void 0){const r=Math.max(0,a-n.lastAt);n.intervalCount+=1,n.intervalSumMs+=r,n.minIntervalMs=Math.min(n.minIntervalMs,r),n.maxIntervalMs=Math.max(n.maxIntervalMs,r),_h(n.intervalSamplesMs,r)}if(n.lastFrameSeq!==void 0){const r=i-n.lastFrameSeq;r!==1&&(n.seqGapCount+=1,n.maxSeqGap=Math.max(n.maxSeqGap,Math.abs(r)))}n.lastAt=a,n.lastFrameSeq=i}function qv(n){return!n||n.intervalCount<=0?"waiting":`${Math.round(n.averageIntervalMs)}ms avg / p95 ${Math.round(n.p95IntervalMs)}ms / max ${Math.round(n.maxIntervalMs)}ms`}function qM(){const[n,a]=f.useState({framesPerSecond:0,averageIntervalMs:0,p95IntervalMs:0,maxIntervalMs:0,longTaskCount:0,longTaskMs:0});return f.useEffect(()=>{let i=0,r=performance.now(),c=0,d=0,h=[],p=0,x=0,g=null;const w=b=>{document.visibilityState==="visible"?(c+=1,d>0&&_h(h,Math.max(0,b-d)),d=b):d=0,i=window.requestAnimationFrame(w)};try{g=new PerformanceObserver(b=>{for(const k of b.getEntries())p+=1,x+=k.duration}),g.observe({entryTypes:["longtask"]})}catch{g=null}i=window.requestAnimationFrame(w);const v=window.setInterval(()=>{const b=performance.now(),k=Math.max(1,b-r),j=h.reduce((M,T)=>M+T,0);a({framesPerSecond:c*1e3/k,averageIntervalMs:h.length>0?j/h.length:0,p95IntervalMs:ld(h,.95),maxIntervalMs:h.length>0?Math.max(...h):0,longTaskCount:p,longTaskMs:x}),r=b,c=0,h=[],p=0,x=0},1e3);return()=>{window.cancelAnimationFrame(i),window.clearInterval(v),g?.disconnect()}},[]),n}function Gv(n){return!n||n.seqGapCount<=0?"none":`${n.seqGapCount} gaps / max ${n.maxSeqGap}`}function GM(n){return Number.isFinite(n)?String(n):"30+"}const id=[{id:"mode4-h264-atlas",label:"Mode 4",detail:"Hub H.264 Atlas"},{id:"mode3-h264-hw",label:"Mode 3",detail:"H.264 hardware"},{id:"mode2-lzo",label:"Mode 2",detail:"RGB565 LZO wall"},{id:"mode1-jpeg",label:"Mode 1",detail:"JPEG test"}],ch=[{id:"prefer-software",label:"Software low latency"},{id:"prefer-hardware",label:"Hardware decode"},{id:"no-preference",label:"Browser auto"}],YM=[{id:"mode3-h264-hw",label:"Mode 3 - H.264 hardware"},{id:"mode5-lzo-delta",label:"Mode 5 - LZO tile delta"}],rd=[{id:"640x360",label:"Compact",width:640,height:360},{id:"960x540",label:"Standard",width:960,height:540},{id:"1280x720",label:"HD",width:1280,height:720},{id:"1920x1080",label:"Full HD",width:1920,height:1080},{id:"2560x1440",label:"QHD",width:2560,height:1440},{id:"3840x2160",label:"4K",width:3840,height:2160}],Bm=rd.filter(n=>n.width>=1280),Fm=[{id:"auto",label:"Auto by wall size"},{id:"320x180",label:"Standard 320x180",width:320,height:180},{id:"480x270",label:"Sharp 480x270",width:480,height:270}],Oh=[1,2,5,8,12,20,30],VM=[20,30,60],Yv=[45,60,75,90],Vv={large:{maxWidth:1280,maxHeight:720},medium:{maxWidth:960,maxHeight:540},small:{maxWidth:640,maxHeight:360}},Fn={preserveConfiguredFpsDeviceCount:12,visibleRootMargin:"520px 0px 760px 0px",fallbackVisibleCounts:{large:12,medium:18,small:32},maxWallFramesPerSecond:96,maxWallBytesPerSecond:80*1024*1024,maxFrameGapMs:280,lowLoadFrameRatio:.58,lowLoadByteRatio:.52,downshiftCooldownMs:1800,recoveryCooldownMs:14e3,minFps:5},Kv=2200,KM=8e3,WM=3500,QM=7e3,XM=2,ZM=2600,JM=4200,eA=750,tA=2,Wv=4200;function Qv(n,a){return Math.min(3e4,n*2**Math.min(3,Math.max(0,a)))}function rc(n,a){const i=n.capabilities?.[a];return typeof i=="boolean"?i:/^(1|true|yes|on)$/i.test(String(i||"").trim())}function Yi(n){return n.deviceName||n.hostname||n.deviceId}function nA(){return"npx -y --prefer-online livedesk@latest client"}function aA(){return"npx -y --prefer-online livedesk@latest"}function sA(){try{return localStorage.getItem(dw)||""}catch{return""}}function lA(){try{return localStorage.getItem(ih)==="1"}catch{return!1}}function zr(n){try{n?localStorage.setItem(ih,"1"):localStorage.removeItem(ih)}catch{}}function Qa(n,a,i,r){const c=Number(n);return Number.isFinite(c)?Math.max(a,Math.min(i,Math.round(c))):r}function uh(n){const a=String(n||"").trim();return a==="mode2-lz4"||a==="lz4"?"mode2-lzo":id.some(i=>i.id===a)?a:ha.frameMode}function vd(n){const a=String(n||"").trim();return ch.some(i=>i.id===a)?a:ha.h264DecodeAcceleration}function dh(n){return n==="mode3-h264-hw"||n==="mode5-lzo-delta"?n:pa.frameMode}function xw(n){return gw[n]||12}function vw(n){return n==="mode3-h264-hw"||n==="mode4-h264-atlas"?20:30}function fh(n,a){return Qa(n,1,vw(a),xw(a))}function Qi(n){return n&&typeof n=="object"&&!Array.isArray(n)?n:{}}function Bn(n){const a=Qi(n.status),i=Qi(a.screens),r=Qi(n.capabilities),c=[a.monitorCount,a.screenCount,i.count,r.monitorCount,r.screenCount];for(const d of c){const h=Number(d);if(Number.isFinite(h)&&h>0)return Math.max(1,Math.min(64,Math.floor(h)))}return 1}function ni(n){const a=Number(n);return Number.isFinite(a)&&a>0?Math.floor(a):0}function iA(n){const a=Qi(n.status),r=[Qi(a.screens).displays,a.displays,a.monitors];for(const c of r)if(!(!Array.isArray(c)||c.length===0))return c.map(d=>Qi(d));return[]}function yw(n,a){const i=iA(n),r=i.find(x=>Number(x.index)===a)||i[a]||i[0]||{},c=ni(r.width),d=ni(r.height),h=[r.name,r.displayName,r.deviceName,r.id].find(x=>typeof x=="string"&&x.trim()),p=typeof h=="string"?h.trim():`Display ${a+1}`;return{index:a,name:p,width:c,height:d,primary:r.primary===!0||r.isPrimary===!0}}function rA(n){const a=Bn(n);return Array.from({length:a},(i,r)=>yw(n,r))}function oA(n){const a=[n.name||`Display ${n.index+1}`];return n.width>0&&n.height>0&&a.push(`${n.width}x${n.height}`),n.primary&&a.push("Primary"),a.join(" - ")}function ww(n,a){const i=yw(n,a);if(i.width>0&&i.height>0)return{width:i.width,height:i.height};const r=Qi(n.status),c=ni(r.screenWidth||r.width),d=ni(r.screenHeight||r.height);return c>0&&d>0?{width:c,height:d}:null}function bw(n){if(!n)return null;const a=ni(n.sourceWidth)||ni(n.width),i=ni(n.sourceHeight)||ni(n.height);return a>0&&i>0?{width:a,height:i}:null}function cA(n,a,i){const d=((typeof a?.monitorIndex=="number"?Pn(a.monitorIndex,Math.max(1,a.monitorCount||1)):i)===i?bw(a):null)||ww(n,i);return d?Math.max(.25,Math.min(4,d.width/d.height)):16/9}const Xu=16/9;function Pn(n,a){const i=Math.max(1,Math.min(64,Math.floor(Number(a)||1))),r=Math.floor(Number(n));return Number.isFinite(r)?Math.max(0,Math.min(i-1,r)):0}function uA(){try{const n=JSON.parse(localStorage.getItem(fw)||"{}");if(![mw,14,13,12,11].includes(Number(n.version)))return ha;const a=uh(n.frameMode),i=Qa(n.maxWidth,320,3840,ha.maxWidth),r=Qa(n.maxHeight,180,2160,ha.maxHeight);return{frameMode:a,h264DecodeAcceleration:vd(n.h264DecodeAcceleration),fps:fh(n.fps,a),maxWidth:i,maxHeight:r,atlasTileWidth:Number(n.atlasTileWidth)>=480?480:320,atlasTileHeight:Number(n.atlasTileHeight)>=270?270:180,atlasTileSizeMode:n.atlasTileSizeMode==="fixed"?"fixed":"auto",quality:Qa(n.quality,20,95,ha.quality),autoStartLive:typeof n.autoStartLive=="boolean"?n.autoStartLive:ha.autoStartLive,showScreenStatus:typeof n.showScreenStatus=="boolean"?n.showScreenStatus:ha.showScreenStatus,visibleOnlyLive:typeof n.visibleOnlyLive=="boolean"?n.visibleOnlyLive:ha.visibleOnlyLive,adaptiveLoadShedding:typeof n.adaptiveLoadShedding=="boolean"?n.adaptiveLoadShedding:ha.adaptiveLoadShedding,adaptiveSizeByWall:typeof n.adaptiveSizeByWall=="boolean"?n.adaptiveSizeByWall:ha.adaptiveSizeByWall}}catch{return ha}}function dA(n){try{localStorage.setItem(fw,JSON.stringify({...n,version:mw}))}catch{}}function fA(){try{const n=JSON.parse(localStorage.getItem(hw)||"{}"),a=Number(n.version);if(![rh,5,4,3,2,1].includes(a))return pa;const i=Qa(n.fps,20,60,pa.fps),r=a<rh;return{frameMode:r?pa.frameMode:dh(n.frameMode),h264DecodeAcceleration:r?pa.h264DecodeAcceleration:vd(n.h264DecodeAcceleration),fps:r?pa.fps:i,maxWidth:Qa(n.maxWidth,1280,3840,pa.maxWidth),maxHeight:Qa(n.maxHeight,720,2160,pa.maxHeight),quality:Qa(n.quality,20,95,pa.quality),showScreenStatus:typeof n.showScreenStatus=="boolean"?n.showScreenStatus:pa.showScreenStatus}}catch{return pa}}function mA(n){try{localStorage.setItem(hw,JSON.stringify({...n,version:rh}))}catch{}}function Hm(n,a){return n.length!==a.length?!1:n.every((i,r)=>i===a[r])}function $m(n){return[...new Set(n.filter(Boolean))].sort()}function hA(n){return Fn.fallbackVisibleCounts[n]||Fn.fallbackVisibleCounts.large}function pA(n,a,i){if(n.frameMode==="mode2-lzo")return{maxWidth:320,maxHeight:180};if(n.frameMode==="mode4-h264-atlas")return n.atlasTileSizeMode==="auto"?a==="large"?{maxWidth:480,maxHeight:270}:{maxWidth:320,maxHeight:180}:{maxWidth:n.atlasTileWidth,maxHeight:n.atlasTileHeight};if(!n.adaptiveSizeByWall)return{maxWidth:n.maxWidth,maxHeight:n.maxHeight};const r=Vv[a]||Vv.large;return{maxWidth:Math.min(n.maxWidth,r.maxWidth),maxHeight:Math.min(n.maxHeight,r.maxHeight)}}function gA(n,a=Fn.minFps){const i=[...Oh].sort((c,d)=>c-d),r=Math.max(a,Math.floor(n/2));return[...i].reverse().find(c=>c<n&&c>=a)||r}function xA(n,a){return[...Oh].sort((r,c)=>r-c).find(r=>r>n&&r<=a)||a}function Zo(n){if(!Number.isFinite(n)||n<=0)return"0 B";const a=["B","KB","MB","GB","TB"];let i=n,r=0;for(;i>=1024&&r<a.length-1;)i/=1024,r+=1;const c=r===0||i>=100?0:1;return`${i.toFixed(c)} ${a[r]}`}function Xv(n){if(!Number.isFinite(n)||!n||n<=0)return"0GB";const a=1024**4,i=1024**3;return n>=a?`${Math.max(1,Math.round(n/a))}TB`:`${Math.max(1,Math.round(n/i))}GB`}function Um(n,a){if(!Number.isFinite(n)||!n||n<=0)return"not reported";const i=Math.max(0,n-Math.max(0,Number(a||0)));return`${Xv(i)} / ${Xv(n)}`}function vA(n){const a=new Uint8Array(n),i=32768;let r="";for(let c=0;c<a.length;c+=i){const d=a.subarray(c,c+i);r+=String.fromCharCode(...d)}return btoa(r)}function Zv(n){return Array.from(n).filter(a=>a.size>=0).map(a=>{const i=a.webkitRelativePath||a.name;return{file:a,relativePath:i,fingerprint:`${a.size}:${a.lastModified}`}})}function yA(n){return n===1?"middle":n===2?"right":"left"}function Jv(n,...a){for(const i of a){const r=n?.[i];if(typeof r=="string"&&r.trim())return r.trim()}return""}function ey(n){const a=Number(n);return Number.isInteger(a)&&a>=1&&a<=DM?a:0}const wA={cpu:"CPU",memory:"MEM",disk:"Disk",gpu:"GPU",vram:"VRAM",npu:"NPU",temp:"Temp",network:"Net"};function bA(n,a,i){if(n==="online")return"Online";if(n==="busy")return"Busy";if(n==="stale")return"Stale";if(n==="offline")return"Offline";if(i==="failed")return"Task failed";const r=n==="critical"?"critical":"warn",c=a.find(h=>h.state===r)||a.find(h=>h.state==="critical"||h.state==="warn");if(!c)return n==="critical"?"Issue":"Check";const d=wA[c.id]||c.label;return c.value&&c.value!=="-"?`${d} ${c.value}`:d}function Ad(n,a){const i=a.split(".");let r=n;for(const c of i){if(r==null)return;if(Array.isArray(r)){const d=Number(c);r=Number.isInteger(d)?r[d]:void 0;continue}if(typeof r=="object"){r=r[c];continue}return}return r}function Bt(n,...a){for(const i of a){const r=Ad(n,i),c=Number(r);if(Number.isFinite(c))return c}}function ga(n,...a){for(const i of a){const r=Ad(n,i);if(typeof r=="string"&&r.trim())return r.trim();if(typeof r=="number"&&Number.isFinite(r))return String(r)}return""}function SA(n,...a){for(const i of a){const r=Ad(n,i);if(typeof r=="boolean")return r;if(/^(1|true|yes|on|online|running|ready)$/i.test(String(r||"").trim()))return!0;if(/^(0|false|no|off|offline|stopped|missing)$/i.test(String(r||"").trim()))return!1}}function ml(n){const a=Number(n);if(Number.isFinite(a))return Math.max(0,Math.min(1,a>1?a/100:a))}function Pm(n,a){if(!(typeof n!="number"||typeof a!="number"||!Number.isFinite(n)||!Number.isFinite(a)||n<=0))return ml((n-Math.max(0,a))/n)}function _r(n){return n===void 0?"-":`${Math.round(n*100)}%`}function qm(n){return n===void 0||!Number.isFinite(n)?"":n>=1e3?`${(n/1e3).toFixed(n>=1e4?0:1)}Gb/s`:`${Math.round(n)}Mb/s`}function Ui(n,a=.92,i=.78){return n===void 0?"unknown":n>=a?"critical":n>=i?"warn":"good"}function Sw(n){return!Number.isFinite(n)||!n||n<=0?"-":n<3600?`${Math.round(n/60)}m`:n<86400?`${Math.round(n/3600)}h`:`${Math.round(n/86400)}d`}function Zu(n,a,i){const r=Ad(n,`tools.${a}`),c=ga(n,`tools.${a}.status`,`tooling.${a}.status`,`${a}.status`).toLowerCase(),d=SA(n,`tools.${a}.running`,`tooling.${a}.running`,`${a}.running`),h=ga(n,`tools.${a}.version`,`tooling.${a}.version`,`${a}.version`),p=ga(n,`tools.${a}.port`,`tooling.${a}.port`,`${a}.port`);let x="unknown";return c==="busy"?x="busy":["online","running","ready","active"].includes(c)||d===!0?x="online":(["offline","stopped","missing","not-found"].includes(c)||d===!1||r===!1)&&(x="offline"),{id:a,label:i,status:x,detail:x==="offline"?"offline":h||(p?`:${p}`:x==="unknown"?"not reported":x)}}function Cw(n){const a=n.status||{},i=Bt(a,"cpu.cores","cpuCores","processorCount"),r=Bt(a,"loadavg.0","cpu.load1"),c=ml(Bt(a,"cpu.usedRatio","cpu.usageRatio","cpu.ratio","cpu.usedPct","cpu.usagePct","cpu.percent")??(i&&r!==void 0?r/Math.max(1,i):void 0)),d=Bt(a,"memory.totalBytes","totalMem"),h=Bt(a,"memory.freeBytes","freeMem"),p=ml(Bt(a,"memory.usedRatio","memory.usedPct","usedMemRatio"))??Pm(d,h),x=Bt(a,"disk.totalBytes","rootDisk.totalBytes","storage.totalBytes"),g=Bt(a,"disk.freeBytes","rootDisk.freeBytes","storage.freeBytes"),w=ml(Bt(a,"disk.usedRatio","disk.usedPct","rootDisk.usedRatio","storage.usedRatio"))??Pm(x,g),v=Bt(a,"thermal.cpuC","temperatureC","cpu.temperatureC","gpu.temperatureC"),b=ml(Bt(a,"gpu.usedRatio","gpu.usageRatio","gpu.usedPct","gpu.usagePct","gpu.percent","accelerators.gpu.usageRatio")),k=ga(a,"gpu.name","gpu.model","accelerators.gpu.name"),j=Bt(a,"gpu.memory.totalBytes","gpu.totalMemoryBytes","gpu.vramTotalBytes"),M=Bt(a,"gpu.memory.freeBytes","gpu.freeMemoryBytes","gpu.vramFreeBytes"),T=ml(Bt(a,"gpu.memory.usedRatio","gpu.vramUsedRatio"))??Pm(j,M),C=Bt(a,"gpu.temperatureC","thermal.gpuC"),A=ml(Bt(a,"npu.usedRatio","npu.usageRatio","npu.usedPct","npu.usagePct","npu.percent","accelerators.npu.usageRatio")),D=ga(a,"npu.name","npu.model","accelerators.npu.name"),H=Bt(a,"npu.tops","npu.topsInt8","accelerators.npu.tops"),B=Bt(a,"network.rxMbps","network.receiveMbps","network.downMbps"),q=Bt(a,"network.txMbps","network.transmitMbps","network.upMbps"),L=Bt(a,"network.latencyMs","network.rttMs"),F=ml(Bt(a,"network.usedRatio","network.usageRatio","network.saturationRatio")),ue=ga(a,"network.link","network.interface","network.name"),W=v===void 0?void 0:ml((v-35)/60),ce=ga(a,"workload.role","role","lane")||(rc(n,"aiAssist")?"Agent worker":rc(n,"taskDispatch")?"Task worker":"Local machine"),Q=ga(n.latestTask,"status")||ga(a,"workload.status")||"idle",se=ga(n.latestTask,"title","instructionPreview")||ga(a,"workload.title"),oe=ga(n.latestTask,"resultSummary","error","instructionPreview")||ga(a,"workload.summary"),K=[Zu(a,"ollama","Ollama"),Zu(a,"lmStudio","LM Studio"),Zu(a,"comfyui","ComfyUI"),Zu(a,"stableDiffusion","Stable Diffusion")],z=K.some($=>$.status!=="unknown"),Y=Date.parse(n.lastSeenAt||n.connectedAt||""),U=Number.isFinite(Y)?Date.now()-Y:0;let R="online";n.connected?U>5*6e4?R="stale":(v??0)>=86||(C??0)>=88||(c??0)>=.94||(b??0)>=.96||(T??0)>=.96||(A??0)>=.96||(p??0)>=.94||(w??0)>=.94||(L??0)>=200||Q==="failed"?R="critical":(v??0)>=78||(C??0)>=80||(c??0)>=.82||(b??0)>=.86||(T??0)>=.88||(A??0)>=.86||(p??0)>=.82||(w??0)>=.86||(L??0)>=80?R="warn":(["queued","running","targeted"].includes(Q)||K.some($=>$.status==="busy"))&&(R="busy"):R="offline";const J=K.filter($=>$.status==="online"||$.status==="busy").length,he=[{id:"cpu",label:"CPU",value:_r(c),detail:i?`${i} cores`:r!==void 0?`load ${r.toFixed(1)}`:"not reported",ratio:c,state:Ui(c,.92,.78)},{id:"memory",label:"RAM",value:_r(p),detail:Um(d,h),ratio:p,state:Ui(p,.92,.78)},{id:"disk",label:"DISK",value:_r(w),detail:Um(x,g),ratio:w,state:Ui(w,.92,.82)},{id:"gpu",label:"GPU",value:_r(b),detail:k||(j&&M!==void 0?`${Zo(M)} VRAM free`:C!==void 0?`${Math.round(C)}C`:"not reported"),ratio:b,state:C!==void 0&&C>=88?"critical":C!==void 0&&C>=80?"warn":Ui(b,.96,.86)},{id:"vram",label:"VRAM",value:_r(T),detail:Um(j,M),ratio:T,state:Ui(T,.96,.88)},{id:"npu",label:"NPU",value:A!==void 0?_r(A):H!==void 0?`${Math.round(H)} TOPS`:"-",detail:D||(H!==void 0?"neural engine":"not reported"),ratio:A,state:Ui(A,.96,.86)},{id:"temp",label:"TEMP",value:v===void 0?"-":`${Math.round(v)}C`,detail:J>0?`${J} local tools`:`uptime ${Sw(Bt(a,"uptimeSec"))}`,ratio:W,state:v===void 0?"unknown":v>=86?"critical":v>=78?"warn":"good"},{id:"network",label:"NET",value:qm(B)||(L!==void 0?`${Math.round(L)}ms`:ue||"-"),detail:qm(q)?`${qm(q)} up`:ue||"not reported",ratio:F,state:L!==void 0&&L>=200?"critical":L!==void 0&&L>=80?"warn":Ui(F,.9,.75)}];return{state:R,label:bA(R,he,Q),role:ce,taskLabel:se||(Q==="idle"?"idle":Q),taskStatus:Q,taskSummary:oe,tools:z?K:K.map($=>({...$,detail:"not reported"})),metrics:he}}function CA({size:n=22}){return l.jsxs("svg",{width:n,height:n,viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[l.jsx("rect",{x:"2.5",y:"4",width:"14",height:"9",rx:"1.5",stroke:"currentColor",strokeWidth:"1.7",opacity:"0.42"}),l.jsx("path",{d:"M7 16v1.5h5",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",opacity:"0.42"}),l.jsx("rect",{x:"10.5",y:"2.5",width:"14",height:"9",rx:"1.5",stroke:"currentColor",strokeWidth:"1.7",opacity:"0.62"}),l.jsx("path",{d:"M15 14.5V16h5",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",opacity:"0.62"}),l.jsx("rect",{x:"6.5",y:"8.5",width:"15",height:"10",rx:"1.7",fill:"currentColor",fillOpacity:"0.12",stroke:"currentColor",strokeWidth:"1.9"}),l.jsx("path",{d:"M12 21v1.5H9.5M16 21v1.5h2.5M9.5 22.5h9",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round"})]})}const jA=[{id:"small",label:"Small"},{id:"medium",label:"Medium"},{id:"large",label:"Large"}],kA=[{id:"wall",label:"Wall",icon:cc,accent:"blue"},{id:"control",label:"Control",icon:ed,accent:"red"},{id:"share-files",label:"Share Files",icon:Ju,accent:"green"},{id:"agents",label:"Agents",icon:Ko,accent:"violet"},{id:"sync-server",label:"Sync Server",icon:td,accent:"blue"}],MA=[{id:"doc",label:"Doc",icon:Vm,accent:"amber"},{id:"pricing",label:"Pricing",icon:Wo,accent:"green"}];function AA(n){return n.replaceAll("npx -y @livedesk/client","npx -y --prefer-online livedesk@latest client").replaceAll("npx @livedesk/client","npx -y --prefer-online livedesk@latest client").replaceAll("npx -y livedesk client","npx -y --prefer-online livedesk@latest client").replaceAll("npx livedesk client","npx -y --prefer-online livedesk@latest client").replaceAll("npx -y livedesk","npx -y --prefer-online livedesk@latest").replaceAll("npx livedesk","npx -y --prefer-online livedesk@latest")}function Ft(n){return AA(n).replace(/\bRemoteHub\b/g,"Hub client endpoint").replace(/\bManagers\b/g,"Hubs").replace(/\bManager\b/g,"Hub").replace(/\bmanager\b/g,"Hub").replace(/\bMANAGER\b/g,"HUB").replace(/매니저/g,"Hub")}function Pi(n){return n.map(a=>Ft(a))}function On(n){return{languageName:n.languageName,languageLabel:n.languageLabel,eyebrow:n.eyebrow,title:Ft(n.title),intro:Ft(n.intro),sections:[{title:Ft(n.managerTitle),body:Ft(n.managerBody),points:Pi(n.managerPoints)},{title:Ft(n.clientTitle),body:Ft(n.clientBody),points:Pi(n.clientPoints)},{title:Ft(n.syncTitle),body:Ft(n.syncBody),points:Pi(n.syncPoints)},...n.agentTitle&&n.agentBody&&n.agentPoints?[{title:Ft(n.agentTitle),body:Ft(n.agentBody),points:Pi(n.agentPoints)}]:[],{title:Ft(n.platformTitle),body:Ft(n.platformBody),points:Pi(n.platformPoints)}],sync:{title:Ft(n.syncTitle),body:Ft(n.syncBody),points:Pi(n.syncPoints)},firewall:{title:Ft(n.firewallTitle),body:Ft(n.firewallBody),points:Pi(n.firewallPoints)},commands:{title:Ft(n.commandsTitle),body:Ft(n.commandsBody),manager:Ft(n.managerCommandLabel),primary:Ft(n.clientCommandLabel),slot:Ft(n.slotCommandLabel),manual:Ft(n.manualCommandLabel)}}}const Fr={ko:On({languageName:"한국어",languageLabel:"문서 언어",eyebrow:"LiveDesk Manual",title:"한 줄로 여는 로컬 Screen Wall",intro:"LiveDesk는 매니저 PC 한 대에서 여러 작업 PC, AI 박스, 맥미니, 개발 장비를 한 화면에 모니터링하고 필요한 제어를 실행하는 npm-first 원격 작업 데크입니다.",managerTitle:"1. 매니저 실행",managerBody:"화면을 모아 볼 컴퓨터에서 LiveDesk 매니저를 실행합니다. 매니저는 UI와 로컬 서버를 같이 열고 브라우저를 http://127.0.0.1:5179 로 띄웁니다.",managerPoints:["명령은 npx -y livedesk 입니다.","매니저는 Screen Wall/API 포트 5179와 클라이언트 접속 포트 5197을 사용합니다.","기존 LiveDesk 포트가 남아 있으면 기본적으로 정리하고 새로 시작합니다. 필요하면 --no-clean 을 붙입니다."],clientTitle:"2. 워크스테이션 연결",clientBody:"모니터링할 PC에서는 Google 로그인 또는 Hub 화면의 6자리 PIN으로 연결합니다. Hub가 켜져 있지 않아도 클라이언트는 종료하지 않고 5초마다 계속 찾습니다.",clientPoints:["빈 자리에 자동 배치하려면 npx -y livedesk client 를 실행합니다.","자리 번호를 고정하려면 npx -y livedesk client 3 처럼 번호를 붙입니다.","브라우저 연결 페이지에서 Google 버튼 또는 6자리 PIN 입력 중 하나를 선택합니다."],syncTitle:"3. Sync Server와 자동 발견",syncBody:"Sync Server는 이 매니저를 현재 계정의 활성 Screen Wall로 Supabase에 등록합니다. 클라이언트는 같은 Google 계정으로 로그인한 뒤 그 기록을 읽고 접속 후보들을 순서대로 시도합니다.",syncPoints:["등록 정보에는 host instance, LAN/private 주소, public 후보 주소, pair token, 짧은 lease가 포함됩니다.","같은 LAN 후보를 먼저 쓰고, 필요하면 외부 주소 후보를 시도합니다.","매니저 위치, VPN, 방화벽, 공유기 설정이 바뀌었거나 개발 중 활성 매니저를 바꿀 때 Sync Server를 누릅니다.","이제 livedesk.pages.dev의 Chrome Local Network Access 허용은 기본 실행 경로가 아닙니다. npm 매니저 앱이 실제 서버입니다."],agentTitle:"4. Agent로 여러 장비 작업하기",agentBody:"Agents 화면은 Hub에서 실행되는 Codex 기반 Agent가 연결된 장비를 확인하고, 선택한 권한 범위 안에서 작업을 실행하는 공간입니다. 클라이언트 PC에 Codex 앱이나 Codex SDK를 설치할 필요는 없습니다.",agentPoints:["Suggested tasks에는 현재 72개의 읽기·운영 작업 템플릿이 있으며, 검색과 권한·플랫폼·capability 조건으로 실행 가능 항목을 안내합니다.","Ask, Safe Auto, Full Access, Custom 권한 모드를 선택할 수 있습니다. 위험한 변경 작업은 승인 카드와 장비 capability 검사를 거칩니다.","All connected 또는 Selected로 대상 장비를 제한하고, 결과는 장비별 상태 칩과 실제 RAM·디스크·GPU·프로세스 요약으로 확인합니다.","Agent 실행은 Hub의 격리된 runtime과 LiveDesk MCP 도구를 통해서만 장비에 전달되며, 모든 작업은 timeout·취소·tool limit·감사 로그 경계를 가집니다."],platformTitle:"5. 현재 플랫폼과 스트림 상태",platformBody:"Windows의 Wall, Control, 파일 전송, 원격 오디오와 RemoteFast 경로를 현재 기준으로 확인했습니다. macOS와 Linux는 같은 npm 명령 경로를 유지하면서 권한과 캡처 백엔드를 확장하고 있습니다.",platformPoints:["Wall은 Mode 4 H.264 Atlas와 Mode 2 LZO 경로를 제공하고, Control은 Mode 3 H.264 또는 Mode 5 LZO tile delta를 사용합니다.","원격 오디오는 선택한 장비가 capability를 광고할 때 사용할 수 있으며, 브라우저는 queue·drop·resync·automatic restart 상태를 진단합니다.","macOS: 화면 캡처와 제어에는 Screen Recording/Accessibility 권한이 필요합니다. RemoteFast 로그는 필요한 상태 중심으로 제한됩니다.","Linux: linux-x64 runtime, grim/gnome-screenshot/import/scrot 캡처, xdotool 입력 백엔드가 추가되었습니다. 오디오는 아직 비활성입니다."],firewallTitle:"방화벽과 외부 장소 연결",firewallBody:"같은 LAN 안에서는 보통 공유기 포트포워딩이 필요 없습니다. 다른 장소의 PC를 붙이려면 클라이언트가 매니저의 클라이언트 접속 포트에 도달할 수 있어야 합니다.",firewallPoints:["클라이언트 접속 포트는 TCP 5197입니다.","클라이언트 쪽은 나가는 연결이므로 보통 인바운드 포트 개방이 필요 없습니다.","다른 네트워크에서 붙일 때는 매니저 PC 방화벽에서 TCP 5197 인바운드를 허용하고, 공유기에서는 TCP 5197을 매니저 PC로 전달합니다.","Screen Wall/API 포트 5179는 매니저 UI용입니다. 외부 브라우저에서 Wall을 직접 열 필요가 있을 때만 별도로 노출을 검토합니다.","공개 인터넷에 바로 열기보다 VPN, Tailscale, ZeroTier, 고정 IP allowlist를 우선합니다."],commandsTitle:"현재 사용 명령",commandsBody:"웹사이트를 찾아가 설치 파일을 받는 방식보다 터미널 한 줄로 모든 운영체제에서 거의 같은 흐름을 쓰는 것이 LiveDesk의 기본 방향입니다.",managerCommandLabel:"매니저 시작",clientCommandLabel:"워크스테이션 연결",slotCommandLabel:"3번 슬롯에 고정",manualCommandLabel:"고급 수동 연결"}),en:On({languageName:"English",languageLabel:"Document language",eyebrow:"LiveDesk Manual",title:"Open a local Screen Wall with one command",intro:"LiveDesk is an npm-first remote work deck for monitoring many workstations, AI boxes, Mac minis, and dev machines from one manager PC.",managerTitle:"1. Run the manager",managerBody:"Run LiveDesk on the computer that will watch the screens. The manager starts the UI and local server together, then opens http://127.0.0.1:5179.",managerPoints:["The command is npx -y livedesk.","The manager uses port 5179 for the Screen Wall/API and port 5197 for client connections.","If an old LiveDesk process still owns those ports, startup cleans it by default. Add --no-clean when you want to keep it."],clientTitle:"2. Connect a workstation",clientBody:"On each monitored computer, connect with Google sign-in or the 6-digit PIN shown on the Hub screen. If no manager is online yet, the client keeps running and retries every 5 seconds.",clientPoints:["Run npx -y livedesk client for first available placement.","Run npx -y livedesk client 3 to pin the machine to slot 3.","The browser connection page lets you choose Google or a 6-digit PIN."],syncTitle:"3. Sync Server and discovery",syncBody:"Sync Server publishes this manager as the active Screen Wall for the signed-in account. Clients read that Supabase record after Google sign-in and try the endpoint candidates in order.",syncPoints:["The record includes host instance, LAN/private addresses, public endpoint candidates, pair token, and a short lease.","LAN candidates are preferred first, then public candidates if needed.","Press Sync Server after manager moves, VPN/firewall/router changes, or when this development machine should take over as active manager.","Chrome Local Network Access on livedesk.pages.dev is no longer the default runtime path. The npm manager app is the real server."],agentTitle:"4. Run multi-workstation tasks with Agent",agentBody:"The Agents page runs a Codex-based Agent in the Hub to inspect connected workstations and perform actions within the selected permission scope. Client PCs do not need the Codex app or Codex SDK installed.",agentPoints:["Suggested tasks currently contains 72 read-only and operational templates with search plus permission, platform, and capability availability checks.","Choose Ask, Safe Auto, Full Access, or Custom. Risky changes go through approval cards and explicit client capability checks.","Limit targets with All connected or Selected. Results use compact per-device status chips and show real RAM, disk, GPU, and process summaries.","Runs stay inside the Hub-isolated runtime and LiveDesk MCP tools, with timeout, cancellation, tool-call limits, and audit-log boundaries."],platformTitle:"5. Current platform and stream state",platformBody:"Windows Wall, Control, file transfer, remote audio, and the RemoteFast path are verified against the current implementation. macOS and Linux keep the same npm command path while capture and permission backends expand.",platformPoints:["Wall provides Mode 4 H.264 Atlas and Mode 2 LZO paths. Control provides Mode 3 H.264 or Mode 5 LZO tile delta.","Remote audio is available when the selected workstation advertises the capability, with queue, drop, resync, and automatic-restart diagnostics in the browser.","macOS requires Screen Recording and Accessibility permissions for capture and control. RemoteFast logs focus on actionable state.","Linux includes the linux-x64 runtime, grim/gnome-screenshot/import/scrot capture, and xdotool input backend. Audio is still disabled."],firewallTitle:"Firewall and remote locations",firewallBody:"On the same LAN, router forwarding is usually unnecessary. For another office, building, or country, clients must be able to reach the manager client port.",firewallPoints:["Client connection port: TCP 5197.","Client machines normally only need outbound access.","For remote networks, allow inbound TCP 5197 on the manager firewall and forward TCP 5197 from the router to the manager PC.","Screen Wall/API port 5179 is for the manager UI. Expose it only if a remote browser must open the Wall directly.","Prefer VPN, Tailscale, ZeroTier, or fixed-IP allowlists over public internet exposure."],commandsTitle:"Current commands",commandsBody:"The product direction is one terminal command across operating systems instead of finding a website, downloading, and installing manually.",managerCommandLabel:"Start manager",clientCommandLabel:"Connect workstation",slotCommandLabel:"Pin to slot 3",manualCommandLabel:"Advanced manual connection"}),ja:On({languageName:"日本語",languageLabel:"ドキュメント言語",eyebrow:"LiveDesk Manual",title:"1行でローカル Screen Wall を開く",intro:"LiveDesk は、複数の作業 PC、AI マシン、Mac mini、開発機を1台の manager PC から監視する npm-first のリモート作業デッキです。",managerTitle:"1. manager を実行",managerBody:"画面を集めて見るコンピューターで LiveDesk manager を実行します。UI とローカルサーバーが同時に起動し、http://127.0.0.1:5179 が開きます。",managerPoints:["コマンドは npx -y livedesk です。","Screen Wall/API は 5179、client 接続は 5197 を使います。","古い LiveDesk プロセスがポートを使っている場合は、基本的に自動で整理して起動します。"],clientTitle:"2. workstation を接続",clientBody:"監視される PC で同じ Google アカウントにログインします。manager がまだ無くても client は終了せず、5秒ごとに再試行します。",clientPoints:["空きスロットに入れるには npx -y livedesk client を実行します。","スロットを固定するには npx -y livedesk client 3 のように番号を付けます。","大量の PC でも再ログインなしで待ち続けます。"],syncTitle:"3. Sync Server と自動検出",syncBody:"Sync Server はこの manager を現在の Google アカウントの active Screen Wall として Supabase に登録します。",syncPoints:["host instance、LAN/private アドレス、public 候補、pair token、短い lease を登録します。","client は LAN 候補を優先し、必要なら public 候補も試します。","VPN、firewall、router、manager の場所が変わったら Sync Server を押します。","livedesk.pages.dev の Chrome Local Network Access は標準実行経路ではありません。npm manager アプリが実際のサーバーです。"],platformTitle:"4. 現在のプラットフォーム状態",platformBody:"Windows は live screen transfer まで確認済みです。macOS と Linux も同じ npm コマンド経路を目標に対応を広げています。",platformPoints:["Windows: 動作確認済み。","macOS: 画面取得と制御には Screen Recording/Accessibility 権限が必要です。","Linux: linux-x64 runtime、grim/gnome-screenshot/import/scrot capture、xdotool input backend を追加済み。audio は未対応です。"],firewallTitle:"Firewall と外部拠点",firewallBody:"同じ LAN なら通常 router forwarding は不要です。外部拠点では client が manager の接続ポートへ到達できる必要があります。",firewallPoints:["client 接続ポートは TCP 5197 です。","client 側は通常 outbound だけで足ります。","外部 network では manager PC の firewall で TCP 5197 inbound を許可し、router から manager PC へ forward します。","5179 は manager UI 用なので、外部ブラウザで Wall を開く必要がある時だけ公開を検討します。","公開 internet より VPN、Tailscale、ZeroTier、IP allowlist を優先してください。"],commandsTitle:"現在のコマンド",commandsBody:"Web サイトから installer を探すより、OS をまたいで terminal 1行で動かす方向です。",managerCommandLabel:"manager 起動",clientCommandLabel:"workstation 接続",slotCommandLabel:"slot 3 に固定",manualCommandLabel:"高度な手動接続"}),"zh-CN":On({languageName:"简体中文",languageLabel:"文档语言",eyebrow:"LiveDesk Manual",title:"用一条命令打开本地 Screen Wall",intro:"LiveDesk 是 npm-first 的远程工作台,用一台 manager PC 监控多台工作站、AI 主机、Mac mini 和开发机器。",managerTitle:"1. 运行 manager",managerBody:"在负责查看屏幕的电脑上运行 LiveDesk manager。它会同时启动 UI 和本地服务器,并打开 http://127.0.0.1:5179。",managerPoints:["命令是 npx -y livedesk。","Screen Wall/API 使用 5179,client 连接使用 5197。","如果旧的 LiveDesk 进程占用端口,默认会清理后重新启动。"],clientTitle:"2. 连接 workstation",clientBody:"在被监控的电脑上使用同一个 Google 账号登录。即使 manager 还没在线,client 也会继续运行并每 5 秒重试。",clientPoints:["自动放入空位: npx -y livedesk client。","固定到 3 号位置: npx -y livedesk client 3。","大量电脑也可以持续等待,不需要反复登录。"],syncTitle:"3. Sync Server 和自动发现",syncBody:"Sync Server 会把当前 manager 作为该账号的 active Screen Wall 写入 Supabase。client 登录后读取记录并依次尝试连接候选地址。",syncPoints:["记录包括 host instance、LAN/private 地址、public 候选、pair token 和短 lease。","优先尝试同一 LAN 地址,需要时再尝试外部地址。","manager 位置、VPN、防火墙或路由变化后请点击 Sync Server。","livedesk.pages.dev 的 Chrome Local Network Access 不再是默认运行方式。npm manager app 才是真正服务器。"],platformTitle:"4. 当前平台状态",platformBody:"Windows 已确认可传输实时画面。macOS 和 Linux 正按同一 npm 命令路径扩展支持。",platformPoints:["Windows: 已确认可用。","macOS: 画面捕获和控制需要 Screen Recording/Accessibility 权限。","Linux: 已加入 linux-x64 runtime、grim/gnome-screenshot/import/scrot 捕获、xdotool 输入后端。音频尚未启用。"],firewallTitle:"防火墙和外部地点",firewallBody:"同一 LAN 通常不需要路由端口转发。不同地点连接时,client 必须能访问 manager 的 client 连接端口。",firewallPoints:["client 连接端口是 TCP 5197。","client 机器通常只需要出站访问。","跨网络时,在 manager 防火墙放行 TCP 5197 入站,并在路由器转发到 manager PC。","5179 是 manager UI 端口,仅在需要远程浏览器直接打开 Wall 时考虑暴露。","优先使用 VPN、Tailscale、ZeroTier 或固定 IP allowlist。"],commandsTitle:"当前命令",commandsBody:"产品方向是跨操作系统使用一条终端命令,而不是先找网站、下载、安装。",managerCommandLabel:"启动 manager",clientCommandLabel:"连接 workstation",slotCommandLabel:"固定到 slot 3",manualCommandLabel:"高级手动连接"}),"zh-TW":On({languageName:"繁體中文",languageLabel:"文件語言",eyebrow:"LiveDesk Manual",title:"用一行指令開啟本機 Screen Wall",intro:"LiveDesk 是 npm-first 的遠端工作台,用一台 manager PC 監看多台工作站、AI 主機、Mac mini 與開發機。",managerTitle:"1. 執行 manager",managerBody:"在負責看畫面的電腦上執行 LiveDesk manager。它會同時啟動 UI 與本機伺服器,並開啟 http://127.0.0.1:5179。",managerPoints:["指令是 npx -y livedesk。","Screen Wall/API 使用 5179,client 連線使用 5197。","若舊的 LiveDesk 程序占用連接埠,預設會清理後重新啟動。"],clientTitle:"2. 連接 workstation",clientBody:"在被監看的電腦上使用同一個 Google 帳號登入。即使 manager 尚未上線,client 也會持續執行並每 5 秒重試。",clientPoints:["自動放入空位: npx -y livedesk client。","固定到 3 號位置: npx -y livedesk client 3。","大量電腦也能持續等待,不需要反覆登入。"],syncTitle:"3. Sync Server 與自動探索",syncBody:"Sync Server 會把目前 manager 登錄為此帳號的 active Screen Wall。client 登入後讀取 Supabase 記錄並依序嘗試連線候選地址。",syncPoints:["記錄包含 host instance、LAN/private 位址、public 候選、pair token 與短 lease。","優先嘗試 LAN 位址,需要時再嘗試外部位址。","manager 位置、VPN、防火牆或路由設定改變後請按 Sync Server。","livedesk.pages.dev 的 Chrome Local Network Access 不再是預設執行路徑。npm manager app 才是真正伺服器。"],platformTitle:"4. 目前平台狀態",platformBody:"Windows 已確認可傳輸即時畫面。macOS 與 Linux 也沿用相同 npm 指令路徑擴充支援。",platformPoints:["Windows: 已確認可用。","macOS: 畫面擷取與控制需要 Screen Recording/Accessibility 權限。","Linux: 已加入 linux-x64 runtime、grim/gnome-screenshot/import/scrot capture、xdotool input backend。音訊尚未啟用。"],firewallTitle:"防火牆與外部地點",firewallBody:"同一 LAN 通常不需要路由器轉發。不同地點連線時,client 必須能到達 manager 的 client 連線埠。",firewallPoints:["client 連線埠是 TCP 5197。","client 電腦通常只需要對外連線。","跨網路時,請在 manager 防火牆允許 TCP 5197 inbound,並從路由器轉發到 manager PC。","5179 是 manager UI 連接埠,只在需要遠端瀏覽器直接打開 Wall 時才考慮公開。","優先使用 VPN、Tailscale、ZeroTier 或固定 IP allowlist。"],commandsTitle:"目前指令",commandsBody:"產品方向是跨作業系統用一行 terminal 指令,而不是先找網站、下載、安裝。",managerCommandLabel:"啟動 manager",clientCommandLabel:"連接 workstation",slotCommandLabel:"固定到 slot 3",manualCommandLabel:"進階手動連線"}),es:On({languageName:"Español",languageLabel:"Idioma del documento",eyebrow:"LiveDesk Manual",title:"Abre un Screen Wall local con un comando",intro:"LiveDesk es una consola npm-first para vigilar muchas estaciones, cajas de IA, Mac mini y equipos de desarrollo desde un PC manager.",managerTitle:"1. Ejecuta el manager",managerBody:"Ejecuta LiveDesk en el equipo que verá las pantallas. El manager inicia la UI y el servidor local juntos y abre http://127.0.0.1:5179.",managerPoints:["El comando es npx -y livedesk.","El manager usa 5179 para Screen Wall/API y 5197 para conexiones client.","Si un proceso antiguo ocupa los puertos, el arranque lo limpia por defecto."],clientTitle:"2. Conecta una workstation",clientBody:"En cada equipo monitoreado, inicia sesión con la misma cuenta Google. Si el manager aún no está activo, el client sigue intentando cada 5 segundos.",clientPoints:["Usa npx -y livedesk client para el primer slot libre.","Usa npx -y livedesk client 3 para fijar el equipo al slot 3.","Los clients siguen esperando para no repetir login en muchas máquinas."],syncTitle:"3. Sync Server y descubrimiento",syncBody:"Sync Server publica este manager como Screen Wall activo para la cuenta. Los clients leen el registro en Supabase y prueban los endpoints.",syncPoints:["Incluye host instance, direcciones LAN/private, candidatos public, pair token y lease corto.","Primero se prueban candidatos LAN, luego públicos si hace falta.","Pulsa Sync Server después de cambios de manager, VPN, firewall o router.","Chrome Local Network Access en livedesk.pages.dev ya no es el flujo principal. La app npm manager es el servidor real."],platformTitle:"4. Estado de plataformas",platformBody:"Windows ya fue verificado con transferencia de pantalla. macOS y Linux siguen el mismo camino npm.",platformPoints:["Windows: verificado.","macOS: captura y control requieren permisos Screen Recording/Accessibility.","Linux: agregado linux-x64 runtime, captura grim/gnome-screenshot/import/scrot y entrada xdotool. Audio aún desactivado."],firewallTitle:"Firewall y sedes remotas",firewallBody:"En la misma LAN normalmente no hace falta port forwarding. Para otra red, los clients deben llegar al puerto client del manager.",firewallPoints:["Puerto de conexión client: TCP 5197.","Los equipos client normalmente solo necesitan salida.","Para redes remotas, permite TCP 5197 inbound en el manager y reenvía TCP 5197 al PC manager.","El puerto 5179 es para la UI del manager; expónlo solo si un navegador remoto debe abrir el Wall.","Prefiere VPN, Tailscale, ZeroTier o allowlist de IP fijas."],commandsTitle:"Comandos actuales",commandsBody:"La dirección del producto es un comando de terminal común entre sistemas, no descargar e instalar desde una web.",managerCommandLabel:"Iniciar manager",clientCommandLabel:"Conectar workstation",slotCommandLabel:"Fijar al slot 3",manualCommandLabel:"Conexión manual avanzada"}),fr:On({languageName:"Français",languageLabel:"Langue du document",eyebrow:"LiveDesk Manual",title:"Ouvrir un Screen Wall local en une commande",intro:"LiveDesk est un deck npm-first pour surveiller plusieurs postes, machines IA, Mac mini et machines dev depuis un PC manager.",managerTitle:"1. Lancer le manager",managerBody:"Lancez LiveDesk sur l’ordinateur qui observe les écrans. Le manager démarre l’UI et le serveur local, puis ouvre http://127.0.0.1:5179.",managerPoints:["La commande est npx -y livedesk.","Le manager utilise 5179 pour Screen Wall/API et 5197 pour les connexions client.","Si un ancien processus utilise les ports, le démarrage le nettoie par défaut."],clientTitle:"2. Connecter une workstation",clientBody:"Sur chaque ordinateur surveillé, connectez-vous avec le même compte Google. Si le manager n’est pas encore actif, le client réessaie toutes les 5 secondes.",clientPoints:["Utilisez npx -y livedesk client pour le premier slot libre.","Utilisez npx -y livedesk client 3 pour fixer la machine au slot 3.","Les clients continuent d’attendre pour éviter les reconnexions répétées."],syncTitle:"3. Sync Server et découverte",syncBody:"Sync Server publie ce manager comme Screen Wall actif du compte. Les clients lisent l’enregistrement Supabase et testent les endpoints.",syncPoints:["Il contient host instance, adresses LAN/private, candidats public, pair token et lease court.","Les candidats LAN sont essayés en premier, puis les candidats publics si besoin.","Cliquez Sync Server après un changement de manager, VPN, firewall ou routeur.","Chrome Local Network Access sur livedesk.pages.dev n’est plus le chemin par défaut. L’app npm manager est le vrai serveur."],platformTitle:"4. État des plateformes",platformBody:"Windows est vérifié avec transfert d’écran live. macOS et Linux suivent le même chemin npm.",platformPoints:["Windows: vérifié.","macOS: capture et contrôle nécessitent Screen Recording/Accessibility.","Linux: runtime linux-x64, capture grim/gnome-screenshot/import/scrot et entrée xdotool ajoutés. Audio désactivé."],firewallTitle:"Firewall et sites distants",firewallBody:"Sur le même LAN, le port forwarding est rarement nécessaire. Depuis un autre réseau, les clients doivent atteindre le port client du manager.",firewallPoints:["Port de connexion client: TCP 5197.","Les machines client ont normalement seulement besoin de sortie réseau.","Pour un réseau distant, autorisez TCP 5197 entrant sur le manager et redirigez TCP 5197 vers le PC manager.","Le port 5179 sert à l’UI manager; exposez-le seulement si un navigateur distant doit ouvrir le Wall.","Préférez VPN, Tailscale, ZeroTier ou allowlist IP fixes."],commandsTitle:"Commandes actuelles",commandsBody:"La direction produit est une commande terminal commune aux OS, plutôt qu’un téléchargement manuel depuis un site.",managerCommandLabel:"Démarrer manager",clientCommandLabel:"Connecter workstation",slotCommandLabel:"Fixer au slot 3",manualCommandLabel:"Connexion manuelle avancée"}),de:On({languageName:"Deutsch",languageLabel:"Dokumentsprache",eyebrow:"LiveDesk Manual",title:"Lokale Screen Wall mit einem Befehl öffnen",intro:"LiveDesk ist ein npm-first Arbeitsdeck, um viele Workstations, AI-Boxen, Mac minis und Dev-Rechner von einem Manager-PC zu überwachen.",managerTitle:"1. Manager starten",managerBody:"Starte LiveDesk auf dem Computer, der die Screens sieht. Der Manager startet UI und lokalen Server zusammen und öffnet http://127.0.0.1:5179.",managerPoints:["Der Befehl ist npx -y livedesk.","Der Manager nutzt 5179 für Screen Wall/API und 5197 für Client-Verbindungen.","Wenn alte LiveDesk-Prozesse Ports belegen, werden sie beim Start standardmäßig bereinigt."],clientTitle:"2. Workstation verbinden",clientBody:"Melde dich auf jedem überwachten Computer mit demselben Google-Konto an. Wenn kein Manager online ist, versucht der Client alle 5 Sekunden weiter.",clientPoints:["npx -y livedesk client nutzt den ersten freien Slot.","npx -y livedesk client 3 fixiert den Rechner auf Slot 3.","Clients warten weiter, damit große Setups kein wiederholtes Login brauchen."],syncTitle:"3. Sync Server und Discovery",syncBody:"Sync Server veröffentlicht diesen Manager als aktive Screen Wall des Kontos. Clients lesen den Supabase-Eintrag und testen Endpoints der Reihe nach.",syncPoints:["Enthält host instance, LAN/private Adressen, public Kandidaten, pair token und kurze lease.","LAN-Kandidaten werden zuerst versucht, danach public Kandidaten.","Nach Änderungen an Manager, VPN, Firewall oder Router Sync Server drücken.","Chrome Local Network Access auf livedesk.pages.dev ist nicht mehr der Standardpfad. Die npm Manager App ist der echte Server."],platformTitle:"4. Plattformstatus",platformBody:"Windows wurde mit Live-Screen-Transfer geprüft. macOS und Linux folgen demselben npm-Pfad.",platformPoints:["Windows: verifiziert.","macOS: Capture und Control brauchen Screen Recording/Accessibility Rechte.","Linux: linux-x64 Runtime, grim/gnome-screenshot/import/scrot Capture und xdotool Input Backend sind ergänzt. Audio ist deaktiviert."],firewallTitle:"Firewall und entfernte Standorte",firewallBody:"Im gleichen LAN ist Router-Forwarding meist unnötig. Aus anderen Netzwerken müssen Clients den Client-Port des Managers erreichen.",firewallPoints:["Client-Verbindungsport: TCP 5197.","Client-Rechner brauchen normalerweise nur ausgehenden Zugriff.","Für entfernte Netzwerke TCP 5197 inbound am Manager erlauben und vom Router zum Manager-PC forwarden.","Port 5179 ist für die Manager-UI; nur öffnen, wenn ein Remote-Browser die Wall direkt öffnen muss.","VPN, Tailscale, ZeroTier oder feste IP-Allowlists bevorzugen."],commandsTitle:"Aktuelle Befehle",commandsBody:"Die Produktlinie ist ein Terminalbefehl über Betriebssysteme hinweg, statt Website suchen, herunterladen und installieren.",managerCommandLabel:"Manager starten",clientCommandLabel:"Workstation verbinden",slotCommandLabel:"An Slot 3 fixieren",manualCommandLabel:"Erweiterte manuelle Verbindung"}),"pt-BR":On({languageName:"Português",languageLabel:"Idioma do documento",eyebrow:"LiveDesk Manual",title:"Abra um Screen Wall local com um comando",intro:"LiveDesk é um deck npm-first para monitorar várias estações, caixas de IA, Mac minis e máquinas dev a partir de um PC manager.",managerTitle:"1. Execute o manager",managerBody:"Rode LiveDesk no computador que verá as telas. O manager inicia a UI e o servidor local juntos e abre http://127.0.0.1:5179.",managerPoints:["O comando é npx -y livedesk.","O manager usa 5179 para Screen Wall/API e 5197 para conexões client.","Se um processo antigo ocupa as portas, a inicialização limpa por padrão."],clientTitle:"2. Conecte uma workstation",clientBody:"Em cada computador monitorado, entre com a mesma conta Google. Se o manager ainda não estiver online, o client tenta a cada 5 segundos.",clientPoints:["Use npx -y livedesk client para o primeiro slot livre.","Use npx -y livedesk client 3 para fixar no slot 3.","Clients continuam tentando para evitar login repetido em muitos PCs."],syncTitle:"3. Sync Server e descoberta",syncBody:"Sync Server publica este manager como Screen Wall ativo da conta. Clients leem o registro no Supabase e testam endpoints.",syncPoints:["Inclui host instance, endereços LAN/private, candidatos public, pair token e lease curto.","Candidatos LAN vêm primeiro; public depois se necessário.","Clique Sync Server após mudanças de manager, VPN, firewall ou roteador.","Chrome Local Network Access em livedesk.pages.dev não é mais o caminho padrão. O app npm manager é o servidor real."],platformTitle:"4. Estado das plataformas",platformBody:"Windows foi verificado com transferência de tela. macOS e Linux seguem o mesmo caminho npm.",platformPoints:["Windows: verificado.","macOS: captura e controle precisam de permissões Screen Recording/Accessibility.","Linux: runtime linux-x64, captura grim/gnome-screenshot/import/scrot e entrada xdotool adicionados. Áudio ainda desativado."],firewallTitle:"Firewall e locais remotos",firewallBody:"Na mesma LAN normalmente não é preciso port forwarding. Em outra rede, clients precisam alcançar a porta client do manager.",firewallPoints:["Porta client: TCP 5197.","Máquinas client normalmente só precisam de saída.","Para redes remotas, permita TCP 5197 inbound no manager e encaminhe TCP 5197 para o PC manager.","A porta 5179 é para a UI do manager; exponha apenas se um navegador remoto precisar abrir o Wall.","Prefira VPN, Tailscale, ZeroTier ou allowlist de IP fixo."],commandsTitle:"Comandos atuais",commandsBody:"A direção do produto é um comando de terminal comum entre sistemas, não baixar e instalar manualmente.",managerCommandLabel:"Iniciar manager",clientCommandLabel:"Conectar workstation",slotCommandLabel:"Fixar no slot 3",manualCommandLabel:"Conexão manual avançada"}),it:On({languageName:"Italiano",languageLabel:"Lingua documento",eyebrow:"LiveDesk Manual",title:"Apri uno Screen Wall locale con un comando",intro:"LiveDesk è un deck npm-first per monitorare workstation, box AI, Mac mini e macchine dev da un solo PC manager.",managerTitle:"1. Avvia il manager",managerBody:"Esegui LiveDesk sul computer che guarderà gli schermi. Il manager avvia UI e server locale e apre http://127.0.0.1:5179.",managerPoints:["Il comando è npx -y livedesk.","Il manager usa 5179 per Screen Wall/API e 5197 per connessioni client.","Se vecchi processi occupano le porte, l’avvio le pulisce di default."],clientTitle:"2. Connetti una workstation",clientBody:"Su ogni computer monitorato, accedi con lo stesso account Google. Se il manager non è online, il client riprova ogni 5 secondi.",clientPoints:["npx -y livedesk client usa il primo slot libero.","npx -y livedesk client 3 fissa la macchina allo slot 3.","I client continuano a provare per evitare login ripetuti."],syncTitle:"3. Sync Server e discovery",syncBody:"Sync Server pubblica questo manager come Screen Wall attivo dell’account. I client leggono Supabase e provano gli endpoint.",syncPoints:["Include host instance, indirizzi LAN/private, candidati public, pair token e lease breve.","Prima LAN, poi public se necessario.","Premi Sync Server dopo cambi di manager, VPN, firewall o router.","Chrome Local Network Access su livedesk.pages.dev non è più il percorso principale. L’app npm manager è il server reale."],platformTitle:"4. Stato piattaforme",platformBody:"Windows è verificato con trasferimento schermo live. macOS e Linux seguono lo stesso percorso npm.",platformPoints:["Windows: verificato.","macOS: capture e control richiedono permessi Screen Recording/Accessibility.","Linux: aggiunti runtime linux-x64, capture grim/gnome-screenshot/import/scrot e input xdotool. Audio disattivato."],firewallTitle:"Firewall e sedi remote",firewallBody:"Nella stessa LAN di solito non serve port forwarding. Da altre reti, i client devono raggiungere la porta client del manager.",firewallPoints:["Porta client: TCP 5197.","I client normalmente richiedono solo uscita.","Per reti remote, abilita TCP 5197 inbound sul manager e inoltra TCP 5197 al PC manager.","La porta 5179 è per la UI manager; esponila solo se un browser remoto deve aprire il Wall.","Preferisci VPN, Tailscale, ZeroTier o IP allowlist."],commandsTitle:"Comandi attuali",commandsBody:"La direzione è un comando terminale comune tra sistemi operativi, invece di download e install manuale.",managerCommandLabel:"Avvia manager",clientCommandLabel:"Connetti workstation",slotCommandLabel:"Fissa allo slot 3",manualCommandLabel:"Connessione manuale avanzata"}),id:On({languageName:"Bahasa Indonesia",languageLabel:"Bahasa dokumen",eyebrow:"LiveDesk Manual",title:"Buka Screen Wall lokal dengan satu perintah",intro:"LiveDesk adalah deck npm-first untuk memantau banyak workstation, AI box, Mac mini, dan mesin dev dari satu PC manager.",managerTitle:"1. Jalankan manager",managerBody:"Jalankan LiveDesk di komputer yang melihat layar. Manager membuka UI dan server lokal bersama, lalu membuka http://127.0.0.1:5179.",managerPoints:["Perintahnya npx -y livedesk.","Manager memakai 5179 untuk Screen Wall/API dan 5197 untuk koneksi client.","Jika proses lama memakai port itu, startup membersihkannya secara default."],clientTitle:"2. Hubungkan workstation",clientBody:"Di komputer yang dipantau, masuk dengan akun Google yang sama. Jika manager belum online, client tetap mencoba tiap 5 detik.",clientPoints:["npx -y livedesk client memakai slot kosong pertama.","npx -y livedesk client 3 mengunci mesin ke slot 3.","Client terus mencoba agar banyak PC tidak perlu login berulang."],syncTitle:"3. Sync Server dan discovery",syncBody:"Sync Server menerbitkan manager ini sebagai Screen Wall aktif untuk akun. Client membaca Supabase dan mencoba endpoint.",syncPoints:["Berisi host instance, alamat LAN/private, kandidat public, pair token, dan lease pendek.","Kandidat LAN dicoba lebih dulu, lalu public jika perlu.","Tekan Sync Server setelah perubahan manager, VPN, firewall, atau router.","Chrome Local Network Access di livedesk.pages.dev bukan jalur utama lagi. App npm manager adalah server sebenarnya."],platformTitle:"4. Status platform",platformBody:"Windows sudah diverifikasi dengan live screen transfer. macOS dan Linux mengikuti jalur npm yang sama.",platformPoints:["Windows: terverifikasi.","macOS: capture dan control perlu izin Screen Recording/Accessibility.","Linux: runtime linux-x64, capture grim/gnome-screenshot/import/scrot, dan input xdotool sudah ditambahkan. Audio belum aktif."],firewallTitle:"Firewall dan lokasi luar",firewallBody:"Di LAN yang sama biasanya tidak perlu port forwarding. Dari jaringan lain, client harus mencapai port client manager.",firewallPoints:["Port client: TCP 5197.","Mesin client biasanya hanya perlu akses keluar.","Untuk jaringan luar, izinkan TCP 5197 inbound di manager dan forward TCP 5197 ke PC manager.","Port 5179 untuk UI manager; buka hanya jika browser luar harus membuka Wall.","Utamakan VPN, Tailscale, ZeroTier, atau IP allowlist."],commandsTitle:"Perintah saat ini",commandsBody:"Arah produk adalah satu perintah terminal lintas OS, bukan download dan instal manual.",managerCommandLabel:"Mulai manager",clientCommandLabel:"Hubungkan workstation",slotCommandLabel:"Kunci ke slot 3",manualCommandLabel:"Koneksi manual lanjutan"}),vi:On({languageName:"Tiếng Việt",languageLabel:"Ngôn ngữ tài liệu",eyebrow:"LiveDesk Manual",title:"Mở Screen Wall cục bộ bằng một lệnh",intro:"LiveDesk là deck npm-first để giám sát nhiều workstation, máy AI, Mac mini và máy dev từ một PC manager.",managerTitle:"1. Chạy manager",managerBody:"Chạy LiveDesk trên máy dùng để xem màn hình. Manager khởi động UI và server cục bộ cùng lúc, rồi mở http://127.0.0.1:5179.",managerPoints:["Lệnh là npx -y livedesk.","Manager dùng 5179 cho Screen Wall/API và 5197 cho kết nối client.","Nếu tiến trình cũ giữ port, startup mặc định sẽ dọn và khởi động lại."],clientTitle:"2. Kết nối workstation",clientBody:"Trên mỗi máy được giám sát, đăng nhập cùng tài khoản Google. Nếu manager chưa online, client tiếp tục thử mỗi 5 giây.",clientPoints:["npx -y livedesk client dùng slot trống đầu tiên.","npx -y livedesk client 3 ghim máy vào slot 3.","Client tiếp tục chờ để nhiều máy không cần đăng nhập lại."],syncTitle:"3. Sync Server và tự phát hiện",syncBody:"Sync Server đăng manager này là Screen Wall đang hoạt động của tài khoản. Client đọc Supabase và thử các endpoint.",syncPoints:["Bao gồm host instance, địa chỉ LAN/private, public candidate, pair token và lease ngắn.","Ưu tiên LAN trước, sau đó thử public nếu cần.","Bấm Sync Server sau thay đổi manager, VPN, firewall hoặc router.","Chrome Local Network Access trên livedesk.pages.dev không còn là đường chạy chính. App npm manager mới là server thật."],platformTitle:"4. Trạng thái nền tảng",platformBody:"Windows đã được kiểm chứng với truyền màn hình live. macOS và Linux đi theo cùng đường npm.",platformPoints:["Windows: đã kiểm chứng.","macOS: capture và control cần quyền Screen Recording/Accessibility.","Linux: đã thêm runtime linux-x64, capture grim/gnome-screenshot/import/scrot và input xdotool. Audio chưa bật."],firewallTitle:"Firewall và địa điểm ngoài",firewallBody:"Trong cùng LAN thường không cần port forwarding. Từ mạng khác, client phải truy cập được port client của manager.",firewallPoints:["Port client: TCP 5197.","Máy client thường chỉ cần kết nối outbound.","Với mạng ngoài, cho phép TCP 5197 inbound trên manager và forward TCP 5197 tới PC manager.","Port 5179 dành cho UI manager; chỉ mở nếu trình duyệt từ xa cần mở Wall trực tiếp.","Ưu tiên VPN, Tailscale, ZeroTier hoặc allowlist IP cố định."],commandsTitle:"Lệnh hiện tại",commandsBody:"Hướng sản phẩm là một lệnh terminal dùng chung giữa các OS, thay vì tải và cài thủ công.",managerCommandLabel:"Khởi động manager",clientCommandLabel:"Kết nối workstation",slotCommandLabel:"Ghim vào slot 3",manualCommandLabel:"Kết nối thủ công nâng cao"}),th:On({languageName:"ไทย",languageLabel:"ภาษาของเอกสาร",eyebrow:"LiveDesk Manual",title:"เปิด Screen Wall ภายในด้วยคำสั่งเดียว",intro:"LiveDesk คือ deck แบบ npm-first สำหรับดู workstation, กล่อง AI, Mac mini และเครื่อง dev หลายเครื่องจาก manager PC เครื่องเดียว",managerTitle:"1. รัน manager",managerBody:"รัน LiveDesk บนเครื่องที่ใช้ดูหน้าจอ Manager จะเปิด UI และ local server พร้อมกัน แล้วเปิด http://127.0.0.1:5179",managerPoints:["คำสั่งคือ npx -y livedesk","Manager ใช้ 5179 สำหรับ Screen Wall/API และ 5197 สำหรับ client connection","ถ้า process เก่ายังใช้ port อยู่ startup จะล้างให้โดย default"],clientTitle:"2. เชื่อม workstation",clientBody:"บนเครื่องที่ต้อง monitor ให้ login ด้วย Google account เดียวกัน ถ้า manager ยังไม่ออนไลน์ client จะลองใหม่ทุก 5 วินาที",clientPoints:["npx -y livedesk client จะใช้ slot ว่างแรก","npx -y livedesk client 3 จะตรึงเครื่องไว้ที่ slot 3","Client จะรอต่อเนื่องเพื่อไม่ต้อง login ซ้ำเมื่อมีหลายเครื่อง"],syncTitle:"3. Sync Server และ discovery",syncBody:"Sync Server จะ publish manager นี้เป็น active Screen Wall ของ account แล้ว client อ่านข้อมูลจาก Supabase และลอง endpoint ต่างๆ",syncPoints:["มี host instance, LAN/private address, public candidate, pair token และ short lease","ลอง LAN ก่อน แล้วค่อยลอง public ถ้าจำเป็น","กด Sync Server หลังเปลี่ยน manager, VPN, firewall หรือ router","Chrome Local Network Access บน livedesk.pages.dev ไม่ใช่ runtime หลักแล้ว app npm manager คือ server จริง"],platformTitle:"4. สถานะ platform",platformBody:"Windows ตรวจสอบแล้วว่าส่งภาพ live ได้ macOS และ Linux ใช้เส้นทาง npm เดียวกัน",platformPoints:["Windows: verified","macOS: capture/control ต้องใช้สิทธิ์ Screen Recording/Accessibility","Linux: เพิ่ม linux-x64 runtime, grim/gnome-screenshot/import/scrot capture และ xdotool input แล้ว audio ยังปิดอยู่"],firewallTitle:"Firewall และเครื่องต่างสถานที่",firewallBody:"ใน LAN เดียวกันปกติไม่ต้อง port forwarding ถ้าอยู่คนละ network client ต้องเข้าถึง client port ของ manager ได้",firewallPoints:["Client port คือ TCP 5197","เครื่อง client ปกติต้องการ outbound เท่านั้น","ถ้าอยู่นอก network ให้เปิด TCP 5197 inbound ที่ manager และ forward TCP 5197 ไปยัง manager PC","Port 5179 เป็น UI ของ manager เปิดเฉพาะเมื่อ browser ระยะไกลต้องเปิด Wall โดยตรง","ควรใช้ VPN, Tailscale, ZeroTier หรือ IP allowlist ก่อนเปิดสู่ public internet"],commandsTitle:"คำสั่งปัจจุบัน",commandsBody:"ทิศทาง product คือคำสั่ง terminal เดียวข้าม OS ไม่ใช่ download/install จากเว็บไซต์",managerCommandLabel:"เริ่ม manager",clientCommandLabel:"เชื่อม workstation",slotCommandLabel:"ตรึง slot 3",manualCommandLabel:"manual connection ขั้นสูง"}),hi:On({languageName:"हिन्दी",languageLabel:"दस्तावेज़ भाषा",eyebrow:"LiveDesk Manual",title:"एक कमांड से local Screen Wall खोलें",intro:"LiveDesk एक npm-first remote work deck है जिससे एक manager PC से कई workstation, AI box, Mac mini और dev machines देखे जा सकते हैं।",managerTitle:"1. manager चलाएं",managerBody:"जिस computer से screens देखनी हैं उस पर LiveDesk manager चलाएं। यह UI और local server साथ में शुरू करता है और http://127.0.0.1:5179 खोलता है।",managerPoints:["कमांड है npx -y livedesk।","Manager Screen Wall/API के लिए 5179 और client connections के लिए 5197 इस्तेमाल करता है।","अगर पुराने LiveDesk ports बचे हों तो startup default रूप से साफ करता है।"],clientTitle:"2. workstation जोड़ें",clientBody:"हर monitored computer पर उसी Google account से sign in करें। Manager online न हो तब भी client बंद नहीं होता और हर 5 सेकंड retry करता है।",clientPoints:["npx -y livedesk client पहला खाली slot लेता है।","npx -y livedesk client 3 machine को slot 3 पर pin करता है।","बहुत सी machines हों तब भी बार-बार login की जरूरत नहीं रहती।"],syncTitle:"3. Sync Server और discovery",syncBody:"Sync Server इस manager को account का active Screen Wall बनाकर Supabase में publish करता है। Clients record पढ़कर endpoints try करते हैं।",syncPoints:["इसमें host instance, LAN/private addresses, public candidates, pair token और short lease होता है।","LAN candidates पहले try होते हैं, जरूरत हो तो public candidates।","Manager, VPN, firewall या router बदलने के बाद Sync Server दबाएं।","livedesk.pages.dev का Chrome Local Network Access अब default runtime नहीं है। npm manager app ही real server है।"],platformTitle:"4. Platform status",platformBody:"Windows live screen transfer के साथ verified है। macOS और Linux भी इसी npm path पर आगे बढ़ रहे हैं।",platformPoints:["Windows: verified.","macOS: capture/control के लिए Screen Recording/Accessibility permissions चाहिए।","Linux: linux-x64 runtime, grim/gnome-screenshot/import/scrot capture और xdotool input backend जोड़े गए हैं। Audio अभी disabled है।"],firewallTitle:"Firewall और remote locations",firewallBody:"Same LAN में आम तौर पर router forwarding जरूरी नहीं। दूसरे network से clients को manager client port तक पहुंचना होगा।",firewallPoints:["Client connection port: TCP 5197.","Client machines को आम तौर पर सिर्फ outbound access चाहिए।","Remote network के लिए manager firewall में TCP 5197 inbound allow करें और router से TCP 5197 manager PC पर forward करें।","5179 manager UI port है; इसे तभी expose करें जब remote browser को Wall खोलना हो।","Public internet से पहले VPN, Tailscale, ZeroTier या fixed IP allowlist बेहतर है।"],commandsTitle:"Current commands",commandsBody:"Product direction है OS के बीच एक terminal command, website से download/install नहीं।",managerCommandLabel:"Start manager",clientCommandLabel:"Connect workstation",slotCommandLabel:"Pin to slot 3",manualCommandLabel:"Advanced manual connection"}),ar:On({languageName:"العربية",languageLabel:"لغة المستند",eyebrow:"LiveDesk Manual",title:"افتح Screen Wall محلي بأمر واحد",intro:"LiveDesk هو deck بنمط npm-first لمراقبة عدة workstations وأجهزة AI وMac mini وأجهزة تطوير من كمبيوتر manager واحد.",managerTitle:"1. شغل manager",managerBody:"شغل LiveDesk على الكمبيوتر الذي سيعرض الشاشات. يبدأ manager الواجهة والخادم المحلي معا ويفتح http://127.0.0.1:5179.",managerPoints:["الأمر هو npx -y livedesk.","يستخدم manager المنفذ 5179 للواجهة/API والمنفذ 5197 لاتصالات client.","إذا بقيت عملية LiveDesk قديمة على المنافذ، يتم تنظيفها افتراضيا عند التشغيل."],clientTitle:"2. وصل workstation",clientBody:"على كل كمبيوتر تتم مراقبته، سجل الدخول بنفس حساب Google. إذا لم يكن manager متاحا، يبقى client يعمل ويحاول كل 5 ثوان.",clientPoints:["npx -y livedesk client يختار أول slot فارغ.","npx -y livedesk client 3 يثبت الجهاز في slot 3.","clients تستمر بالمحاولة لتجنب تكرار تسجيل الدخول عند كثرة الأجهزة."],syncTitle:"3. Sync Server والاكتشاف",syncBody:"Sync Server ينشر هذا manager كـ active Screen Wall للحساب. يقرأ clients سجل Supabase ويجربون endpoints بالترتيب.",syncPoints:["السجل يتضمن host instance وعناوين LAN/private وpublic candidates وpair token وlease قصير.","يتم تفضيل LAN أولا، ثم public عند الحاجة.","اضغط Sync Server بعد تغيير manager أو VPN أو firewall أو router.","Chrome Local Network Access على livedesk.pages.dev لم يعد مسار التشغيل الافتراضي. تطبيق npm manager هو الخادم الحقيقي."],platformTitle:"4. حالة المنصات",platformBody:"Windows تم التحقق منه مع نقل شاشة live. macOS وLinux يتبعان نفس مسار npm.",platformPoints:["Windows: تم التحقق.","macOS: capture/control يحتاجان أذونات Screen Recording/Accessibility.","Linux: تمت إضافة linux-x64 runtime وgrim/gnome-screenshot/import/scrot capture وxdotool input. الصوت ما زال معطلا."],firewallTitle:"Firewall والمواقع البعيدة",firewallBody:"داخل نفس LAN غالبا لا تحتاج port forwarding. من شبكة أخرى يجب أن يصل client إلى منفذ manager client.",firewallPoints:["منفذ client: TCP 5197.","أجهزة client تحتاج عادة اتصال outbound فقط.","للشبكات البعيدة، اسمح TCP 5197 inbound على manager ووجه TCP 5197 من router إلى manager PC.","المنفذ 5179 مخصص لواجهة manager؛ اكشفه فقط إذا كان متصفح بعيد يحتاج فتح Wall مباشرة.","يفضل VPN أو Tailscale أو ZeroTier أو fixed IP allowlist بدل التعريض العام."],commandsTitle:"الأوامر الحالية",commandsBody:"اتجاه المنتج هو أمر terminal واحد عبر الأنظمة، وليس تحميل وتثبيت يدوي من موقع.",managerCommandLabel:"Start manager",clientCommandLabel:"Connect workstation",slotCommandLabel:"Pin to slot 3",manualCommandLabel:"Advanced manual connection"}),tr:On({languageName:"Türkçe",languageLabel:"Belge dili",eyebrow:"LiveDesk Manual",title:"Yerel Screen Wall tek komutla açılsın",intro:"LiveDesk, tek bir manager PC üzerinden birçok workstation, AI box, Mac mini ve dev machine izlemek için npm-first bir çalışma deckidir.",managerTitle:"1. Manager çalıştır",managerBody:"Ekranları izleyecek bilgisayarda LiveDesk manager çalıştır. Manager UI ve local server birlikte başlar ve http://127.0.0.1:5179 açılır.",managerPoints:["Komut: npx -y livedesk.","Manager Screen Wall/API için 5179, client bağlantıları için 5197 kullanır.","Eski LiveDesk process portları tutuyorsa başlangıç varsayılan olarak temizler."],clientTitle:"2. Workstation bağla",clientBody:"İzlenecek bilgisayarda aynı Google hesabıyla giriş yap. Manager henüz online değilse client kapanmaz ve her 5 saniyede tekrar dener.",clientPoints:["npx -y livedesk client ilk boş slota yerleşir.","npx -y livedesk client 3 makineyi slot 3’e sabitler.","Çok makinede tekrar tekrar login gerekmesin diye client beklemeye devam eder."],syncTitle:"3. Sync Server ve discovery",syncBody:"Sync Server bu managerı hesabın active Screen Wall kaydı olarak Supabase’e yazar. Clients bu kaydı okuyup endpoint adaylarını dener.",syncPoints:["Host instance, LAN/private adresler, public adaylar, pair token ve kısa lease içerir.","Önce LAN adayları, gerekirse public adaylar denenir.","Manager, VPN, firewall veya router değişince Sync Server’a bas.","livedesk.pages.dev üzerindeki Chrome Local Network Access artık default runtime yolu değil. Gerçek server npm manager app."],platformTitle:"4. Platform durumu",platformBody:"Windows live screen transfer ile doğrulandı. macOS ve Linux aynı npm yolunu takip ediyor.",platformPoints:["Windows: doğrulandı.","macOS: capture/control için Screen Recording/Accessibility izinleri gerekir.","Linux: linux-x64 runtime, grim/gnome-screenshot/import/scrot capture ve xdotool input backend eklendi. Audio kapalı."],firewallTitle:"Firewall ve uzak konumlar",firewallBody:"Aynı LAN içinde genelde router forwarding gerekmez. Başka ağdan clients manager client portuna ulaşabilmelidir.",firewallPoints:["Client port: TCP 5197.","Client makineler normalde sadece outbound erişim ister.","Uzak ağ için manager firewall üzerinde TCP 5197 inbound aç ve routerdan TCP 5197yi manager PCye forward et.","5179 manager UI portudur; sadece uzak browser Wall açacaksa expose et.","Public internet yerine VPN, Tailscale, ZeroTier veya sabit IP allowlist tercih et."],commandsTitle:"Güncel komutlar",commandsBody:"Ürün yönü, webden indirip kurmak yerine işletim sistemleri arasında ortak tek terminal komutu.",managerCommandLabel:"Manager başlat",clientCommandLabel:"Workstation bağla",slotCommandLabel:"Slot 3’e sabitle",manualCommandLabel:"Gelişmiş manuel bağlantı"})},NA=Object.entries(Fr).map(([n,a])=>({id:n,label:a.languageName}));function TA(){if(typeof navigator>"u")return"en";const n=navigator.languages?.length?navigator.languages:[navigator.language];for(const a of n){const i=a.toLowerCase();if(Fr[a])return a;if(i.startsWith("zh-tw")||i.startsWith("zh-hk"))return"zh-TW";if(i.startsWith("pt"))return"pt-BR";const r=i.split("-")[0];if(Fr[r])return r}return"en"}function ty({index:n}){const a=n+1;return l.jsx("article",{className:"device-tile placeholder-tile","aria-label":`Empty slot ${a}`,children:l.jsxs("div",{className:"tile-screen","aria-hidden":"true",children:[l.jsx("span",{className:"slot-grid","aria-hidden":"true"}),l.jsxs("span",{className:"empty-screen",children:[l.jsx(an,{size:24}),l.jsxs("strong",{children:["Slot ",String(a).padStart(3,"0")]})]})]})})}function Gm({device:n,frame:a,selected:i,controlEnabled:r,showStatus:c,monitorIndex:d,monitorCount:h,onSelect:p,onFocusDevice:x,onOpenControl:g,onCycleMonitor:w,onCanvasReady:v,sendInput:b,presentationReady:k}){const j=f.useRef(null),M=f.useRef(null),T=f.useRef(0),C=f.useRef(null),A=Cw(n),D=["cpu","gpu","memory","vram"].map(R=>A.metrics.find(J=>J.id===R)).filter(R=>!!R),H=Pn(d,h),B=h>1,q=k??!!a,L=cA(n,a,H),F=L>=Xu?100:L/Xu*100,ue=L>=Xu?Xu/L*100:100,W={"--screen-aspect":L.toFixed(5),"--screen-content-width":`${Math.max(1,Math.min(100,F)).toFixed(3)}%`,"--screen-content-height":`${Math.max(1,Math.min(100,ue)).toFixed(3)}%`},ce=f.useCallback(R=>{j.current=R,v(n.deviceId,R)},[n.deviceId,v]),Q=R=>{const J=R.currentTarget.getBoundingClientRect();return{normalizedX:Math.max(0,Math.min(1,(R.clientX-J.left)/Math.max(1,J.width))),normalizedY:Math.max(0,Math.min(1,(R.clientY-J.top)/Math.max(1,J.height)))}},se=R=>({shiftKey:R.shiftKey,ctrlKey:R.ctrlKey,altKey:R.altKey,metaKey:R.metaKey}),oe=f.useCallback(()=>{C.current!==null&&(window.cancelAnimationFrame(C.current),C.current=null)},[]),K=f.useCallback(()=>{const R=M.current;if(!R)return;M.current=null;const J=Number(R.input.normalizedX),he=Number(R.input.normalizedY);if(!Number.isFinite(J)||!Number.isFinite(he))return;b(n.deviceId,{...R.input,normalizedX:J,normalizedY:he})&&(T.current=performance.now())},[n.deviceId,b]),z=f.useCallback(()=>{C.current===null&&(C.current=window.requestAnimationFrame(()=>{C.current=null,K()}))},[K]);f.useEffect(()=>()=>{oe(),M.current=null},[oe]);const Y=(R,J)=>{if(!r)return;const he={type:J,monitorIndex:H,...Q(R),button:yA(R.button),...se(R)};if(J==="pointermove"){const $=performance.now();M.current={input:he},$-T.current>=zM&&(oe(),K()),z();return}M.current&&(oe(),K()),b(n.deviceId,he)},U=f.useCallback(R=>{const J=document.activeElement;J instanceof HTMLElement&&R.contains(J)&&J.classList.contains("monitor-cycle-button")&&J.blur()},[]);return l.jsx("article",{className:`device-tile ${i?"selected":""} ${n.connected?"online":"offline"}`,"data-live-device-id":n.deviceId,style:W,children:l.jsxs("div",{className:`tile-screen ${q?"has-frame":"is-empty"}`,role:"button",tabIndex:r?-1:0,"aria-pressed":i,onClick:()=>{r||p()},onKeyDown:R=>{r||(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),p())},onDoubleClick:R=>{R.preventDefault(),g()},onPointerLeave:R=>U(R.currentTarget),children:[l.jsx("span",{className:`screen-content ${q?"has-frame":"is-empty"}`,children:l.jsx("canvas",{ref:ce,className:`remote-canvas ${q?"has-frame":"is-empty"}`,tabIndex:r?0:-1,onPointerDown:R=>{r&&(R.preventDefault(),R.stopPropagation(),x(),R.currentTarget.focus(),R.currentTarget.setPointerCapture(R.pointerId),Y(R,"pointerdown"))},onPointerMove:R=>{r&&R.preventDefault(),Y(R,"pointermove")},onPointerUp:R=>{r&&(R.preventDefault(),R.stopPropagation(),Y(R,"pointerup"),R.currentTarget.hasPointerCapture(R.pointerId)&&R.currentTarget.releasePointerCapture(R.pointerId))},onPointerCancel:R=>{R.currentTarget.hasPointerCapture(R.pointerId)&&R.currentTarget.releasePointerCapture(R.pointerId)},onWheel:R=>{r&&(R.preventDefault(),b(n.deviceId,{type:"wheel",monitorIndex:H,...Q(R),deltaX:R.deltaX,deltaY:R.deltaY,...se(R)}))},onKeyDown:R=>{r&&(R.preventDefault(),R.stopPropagation(),b(n.deviceId,{type:"keydown",monitorIndex:H,key:R.key,code:R.code,keyCode:R.keyCode||R.which||0,location:R.location,text:R.key.length===1?R.key:"",repeat:R.repeat,...se(R)}))},onKeyUp:R=>{r&&(R.preventDefault(),R.stopPropagation(),b(n.deviceId,{type:"keyup",monitorIndex:H,key:R.key,code:R.code,keyCode:R.keyCode||R.which||0,location:R.location,text:R.key.length===1?R.key:"",repeat:!1,...se(R)}))},onContextMenu:R=>r&&R.preventDefault()})}),!q&&l.jsx("span",{className:"empty-screen",children:l.jsx(an,{size:26})}),c&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:`tile-health-pill state-${A.state}`,children:A.label}),l.jsx("span",{className:"tile-metrics","aria-label":`${Yi(n)} status`,children:D.map(R=>l.jsxs("span",{className:`tile-metric state-${R.state}`,children:[l.jsx("b",{children:R.label}),l.jsx("em",{children:R.value}),R.ratio!==void 0&&l.jsx("i",{style:{width:`${Math.round(R.ratio*100)}%`}})]},R.id))})]}),B&&l.jsxs("span",{className:"monitor-cycle","aria-label":`${Yi(n)} display ${H+1} of ${h}`,children:[l.jsx("button",{className:"monitor-cycle-button previous",onClick:R=>{R.preventDefault(),R.stopPropagation(),w(-1),R.currentTarget.blur()},title:"Previous display",type:"button",children:l.jsx(ry,{size:18})}),l.jsxs("span",{className:"monitor-cycle-count",children:["Screen ",H+1,"/",h]}),l.jsx("button",{className:"monitor-cycle-button next",onClick:R=>{R.preventDefault(),R.stopPropagation(),w(1),R.currentTarget.blur()},title:"Next display",type:"button",children:l.jsx(xh,{size:18})})]}),i&&l.jsx("span",{className:"device-selection-check","aria-hidden":"true",children:l.jsx(uc,{size:23,strokeWidth:3.5})})]})})}function RA({visible:n}){return f.useEffect(()=>{if(!n||!Om)return;if(!document.getElementById(Bv)){const i=document.createElement("script");i.id=Bv,i.async=!0,i.crossOrigin="anonymous",i.src=`https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${encodeURIComponent(oh)}`,document.head.appendChild(i)}const a=window.setTimeout(()=>{try{window.adsbygoogle=window.adsbygoogle||[],window.adsbygoogle.push({})}catch{}},120);return()=>window.clearTimeout(a)},[n]),n?l.jsxs("aside",{className:`free-ad-banner ${Om?"adsense-ready":"house-ad"}`,"aria-label":"Advertisement",children:[l.jsx("span",{className:"ad-label",children:"Advertisement"}),Om?l.jsx("ins",{className:"adsbygoogle livedesk-ad-unit",style:{display:"block"},"data-ad-client":oh,"data-ad-slot":pw,"data-ad-format":"auto","data-full-width-responsive":"true"}):l.jsxs("div",{className:"house-ad-copy",children:[l.jsx("strong",{children:"Sponsored placement"}),l.jsx("span",{children:"Local AI gear, mini PCs, GPUs, NAS, and developer tools."})]})]}):null}function EA(){const n=qM(),{session:a,loading:i}=d0(),{target:r,error:c,refresh:d}=m0(a),h=f.useMemo(()=>{if(!r?.active)return null;const y=r.expires_at?Date.parse(r.expires_at):Number.POSITIVE_INFINITY;return Number.isFinite(y)&&y<=Date.now()?null:r},[r]),p=f.useMemo(()=>qx(h),[h]),x=f.useMemo(()=>p.length>0?[...new Set([...p,Ln])]:[Ln],[p]),[g,w]=f.useState(lA),v=f.useMemo(()=>x.some(y=>!!sc(y)),[x]),b=!v||g,{status:k,devices:j,error:M,refresh:T,hubBaseUrl:C}=f0(x,b),{entitlement:A,licensed:D,loading:H,error:B,refresh:q}=h0(a),[L,F]=f.useState([]),[ue,W]=f.useState(""),[ce,Q]=f.useState(""),[se,oe]=f.useState(""),[K,z]=f.useState(""),[Y,U]=f.useState(""),[R,J]=f.useState("idle"),[he,$]=f.useState(!1),[ie,we]=f.useState(""),[me,ze]=f.useState(!1),[Pe,de]=f.useState(!1),He=f.useRef(""),Le=f.useRef(new Map),Fe=f.useRef(0),[qe,ne]=f.useState(""),[ye,be]=f.useState(""),[Z,le]=f.useState("wall"),[Me,je]=f.useState("large"),[ct,sn]=f.useState(TA),[ke,Ne]=f.useState(!1),[Oe,Dt]=f.useState(!1),[Za,Nt]=f.useState(!1),[Gn,ii]=f.useState(sA),[Te,za]=f.useState(uA),[Xe,_a]=f.useState(fA),[Je,yn]=f.useState({}),[qt,_s]=f.useState([]),[Gt,pl]=f.useState(Te.fps),[Oa,Ja]=f.useState(""),[ya,es]=f.useState(0),ln=f.useRef(new Map),Hn=f.useRef(new Map),Yn=f.useRef(new Map),gl=f.useRef(new Map),Ia=f.useRef(new Set),Ba=f.useRef(new Map),Ss=f.useRef(0),ts=f.useRef(""),Vn=f.useRef(""),wa=f.useRef(null),Fa=f.useRef(new Map),ns=f.useRef(null),as=f.useRef(0),Os=f.useRef(new Map),[Kn,X]=f.useState({}),Se=f.useRef(new Map),[De,Ze]=f.useState({}),[Tt,ut]=f.useState(!1),Ue=f.useRef(null),at=f.useRef(null),Rt=f.useRef(0),_t=f.useRef(""),Yt=f.useRef(new Map),xt=f.useRef(new Map),Ot=f.useRef(performance.now()),vt=f.useRef(new Map),Wn=f.useRef(new Map),Qn=f.useRef(new Map),Vt=f.useRef(new Map),It=f.useRef(0),xl=f.useRef(0),ss=f.useRef(0),Cs=f.useRef(0),Pr=f.useRef(0),ri=f.useRef(new Map),ba=f.useRef(new Map),[Mn,Kt]=f.useState(null),[vc,qr]=f.useState(!1),[yc,wc]=f.useState([]),[ls,Nd]=f.useState("all"),[mn,oi]=f.useState([]),[Td,bc]=f.useState(!1),[ci,Sc]=f.useState(!0),Gr=f.useRef(null),Is=f.useRef(null),Rd=f.useRef(null),Cc=f.useRef(null),jc=f.useRef(!1),ui=f.useRef(!1),kc=f.useRef(0),di=f.useRef(0),Sa=f.useRef(0),Xn=Z==="settings",Xi=Z==="pricing",Zi=Z==="doc",Ha=Z==="share-files",Bs=Z==="agents",Yr=!Xn&&!Xi&&!Zi&&!Ha&&!Bs,Ye=Z==="control",lt=Te.frameMode==="mode4-h264-atlas",An=Y||Xe.frameMode,Ca=An==="mode5-lzo-delta"?Math.min(30,Xe.fps):Xe.fps,$a=An==="mode5-lzo-delta"?{maxWidth:Math.min(1920,Xe.maxWidth),maxHeight:Math.min(1080,Xe.maxHeight)}:{maxWidth:Xe.maxWidth,maxHeight:Xe.maxHeight};f.useEffect(()=>{if(k?.started){if(!a?.access_token){Be("/api/remote/license",{method:"DELETE"},C).catch(()=>{});return}Be("/api/remote/license/sync",{method:"POST",headers:{Authorization:`Bearer ${a.access_token}`}},C).catch(y=>{console.warn("[LiveDesk] Hub license sync failed",y)})}},[A?.updated_at,C,a?.access_token,k?.started]);const Ke=f.useMemo(()=>j.filter(y=>y.connected),[j]),is=ls==="all"?Ke.length:mn.filter(y=>Ke.some(E=>E.deviceId===y)).length,Vr=f.useMemo(()=>Ke.reduce((y,E)=>Math.max(y,ey(E.slotNumber)),0),[Ke]),Fs=Math.max(EM,Ke.length,Vr),vl=f.useMemo(()=>{const y=Array(Fs).fill(null),E=[];for(const _ of Ke){const G=ey(_.slotNumber);G>0&&G<=Fs&&!y[G-1]?y[G-1]=_:E.push(_)}for(const _ of E){const G=y.findIndex(O=>!O);G<0?y.push(_):y[G]=_}return y},[Ke]),yl=f.useMemo(()=>Ke.map(y=>y.deviceId),[Ke]),rs=f.useMemo(()=>new Set(L),[L]),Zn=f.useMemo(()=>Ke.filter(y=>rs.has(y.deviceId)),[Ke,rs]),Wt=f.useMemo(()=>j.find(y=>y.deviceId===ue)||Zn[0]||null,[j,ue,Zn]),Qt=f.useMemo(()=>j.find(y=>y.deviceId===ce)||null,[ce,j]),Hs=Qt?Pn(Je[Qt.deviceId],Bn(Qt)):0,Ae=Ye?Qt:Wt,Mc=f.useMemo(()=>new Set(mn),[mn]),Kr=f.useMemo(()=>ls==="all"?Ke.map(y=>y.deviceId):Ke.filter(y=>Mc.has(y.deviceId)).map(y=>y.deviceId),[Ke,Mc,ls]),Jn=f.useMemo(()=>Ae?Cw(Ae):null,[Ae]),fi=Ae?rc(Ae,"control"):!1,Ji=Ae?.platform==="macos"&&Ae.capabilities?.controlPermission===!1,wl=Ae?rc(Ae,"audio")||rc(Ae,"remoteAudio"):!1,At=D?A?.plan==="pro"?"pro":"ltd":"free",Ac=$i[At],er=Ac.limit,os=f.useMemo(()=>{if(!Number.isFinite(er))return new Set(Ke.map(E=>E.deviceId));const y=Ae?[Ae,...Ke.filter(E=>E.deviceId!==Ae.deviceId)]:Ke;return new Set(y.slice(0,er).map(E=>E.deviceId))},[er,Ke,Ae]),Ed=!Ae||os.has(Ae.deviceId),Dd=At==="free",Xt=Ed,bl=At==="ltd"?`Plus includes up to ${Xo} workstations. Upgrade to Pro for commercial use and larger walls.`:`Free includes up to ${Qo} workstations. Upgrade to Plus for ${Xo} devices and no ads.`,Ld=At==="free",Wr=Xt&&!!Ae,cs=Xt&&!!Ae&&fi,Nc=Xt&&!!Ae&&wl,tr=f.useMemo(()=>vl.filter(y=>!!y?.connected).slice(0,hA(Me)).map(y=>y.deviceId),[vl,Me]),$s=f.useMemo(()=>lt?yl:Te.visibleOnlyLive?qt.length>0?qt:tr:yl,[tr,lt,qt,Te.visibleOnlyLive,yl]),Sl=f.useMemo(()=>$m($s.filter(y=>os.has(y))),[os,$s]),hn=f.useMemo(()=>Sl.filter(y=>y!==Oa),[Sl,Oa]),zd=f.useMemo(()=>{const y=O=>Ke.find(pe=>pe.deviceId===O)||null,E=O=>Pn(Je[O],y(O)?Bn(y(O)):0),_=(O,pe=E(O))=>O===se&&(R==="connecting"||R==="active"||R==="warm")?Yn.current.get(O)||Hn.current.get(O)||null:lt?Fa.current.get(O)||ln.current.get(O)||null:ln.current.get(O)||null,G=(O,pe=E(O))=>{const xe=y(O);return`${xe?Yi(xe):O} · Monitor ${pe+1}`};return{resolveCurrentTarget(){if(Ye&&Qt){const Ve=Hs;return{type:"control",deviceIds:[Qt.deviceId],monitorIndex:Ve,label:`${Yi(Qt)} · Monitor ${Ve+1}`,sourceCanvas:_(Qt.deviceId,Ve),signature:`control:${Qt.deviceId}:${Ve}:${Xe.frameMode}`}}const O=Zn.map(Ve=>Ve.deviceId).filter(Ve=>hn.includes(Ve)),pe=Wt&&hn.includes(Wt.deviceId)?Wt.deviceId:"",xe=O.length>0?O:pe?[pe]:hn,Re=O.length===0&&!pe;if(xe.length===0)return null;if(xe.length===1){const Ve=xe[0],We=E(Ve);return{type:Re?"wall":O.length>1?"selection":"device",deviceIds:xe,monitorIndex:We,label:Re?"Wall":G(Ve,We),sourceCanvas:Re?null:_(Ve,We),signature:`${Re?"wall":"device"}:${Ve}:${We}:${lt?"atlas":"direct"}`}}return{type:O.length>1?"selection":"wall",deviceIds:xe,label:O.length>1?`${xe.length} selected workstations`:"Wall",sourceCanvas:null,signature:`${O.length>1?"selection":"wall"}:${xe.join(",")}:${Me}`}},getDeviceCanvas:_,composeWall(O,pe={}){return yM(O.map(xe=>{const Re=E(xe);return{deviceId:xe,label:G(xe,Re),canvas:_(xe,Re)}}),pe)}}},[Ke,Qt,se,R,Xe.frameMode,ln,lt,Je,Hs,Zn,Ye,hn,Wt,Me]),Tc=RM({hubUrl:C,sourceRegistry:zd,onToast:be}),Us=f.useMemo(()=>Xt&&se&&os.has(se)&&(R==="connecting"||R==="active"||R==="warm")?[se]:[],[se,R,Xt,os]),_d=f.useMemo(()=>$m([...Sl,...Us]),[Us,Sl]),Zt=f.useMemo(()=>pA(Te,Me),[Te,Me]),Ps=f.useCallback((y,E)=>{if(y.width<=0||y.height<=0)return!1;(E.width!==y.width||E.height!==y.height)&&(E.width=y.width,E.height=y.height);const _=E.getContext("2d",{alpha:!1});return _?(_.imageSmoothingEnabled=!0,_.imageSmoothingQuality="high",_.drawImage(y,0,0,y.width,y.height,0,0,E.width,E.height),!0):!1},[]),us=f.useCallback((y,E=!1)=>{if(!Ia.current.has(y))return!1;const _=performance.now(),G=Ba.current.get(y)||0;if(!E&&_-G<150)return!1;const O=Yn.current.get(y)||Hn.current.get(y),pe=lt?Fa.current.get(y):ln.current.get(y);return!O||!pe||!Ps(O,pe)?!1:(Ba.current.set(y,_),!0)},[lt,Ps]);f.useEffect(()=>{ts.current=Oa},[Oa]);const Od=f.useCallback((y,E)=>{const _=ln.current.get(y);if(_&&_!==E&&qo(_),E){ln.current.set(y,E),us(y,!0);return}ln.current.delete(y)},[us]),Id=f.useCallback((y,E)=>{const _=Hn.current.get(y);if(_&&_!==E&&qo(_),E){Hn.current.set(y,E);const G=Yn.current.get(y);G&&Ps(G,E);return}Hn.current.delete(y)},[Ps]),nr=f.useCallback((y,E,_)=>{const G=performance.now(),O=ys(y,_.deviceId);let pe=_;if(y==="control"&&_.visualChanged){const Re=w0(_.deviceId),Ve=ri.current.get(_.deviceId)||0,We=Re?G-Re.sentAt:Number.POSITIVE_INFINITY;Re&&Re.inputSeq>Ve&&We<=Fv&&(pe={..._,inputFeedbackSeq:Re.inputSeq,inputFeedbackMs:Math.max(0,We),inputFeedbackAt:G},ri.current.set(_.deviceId,Re.inputSeq))}xt.current.set(O,G);const xe=Os.current.get(O)||{totalFrames:0,totalChangedFrames:0,sampleFrames:0,sampleChangedFrames:0,sampleStartedAt:G,intervalCount:0,intervalSumMs:0,minIntervalMs:Number.POSITIVE_INFINITY,maxIntervalMs:0,intervalSamplesMs:[],seqGapCount:0,maxSeqGap:0,sampleDecoderInputBase:0,sampleDecoderOutputBase:0};y==="control"&&pe.inputFeedbackMs===void 0&&xe.lastInfo?.inputFeedbackMs!==void 0&&xe.lastInfo.inputFeedbackAt!==void 0&&G-xe.lastInfo.inputFeedbackAt<=Fv&&(pe={...pe,inputFeedbackSeq:xe.lastInfo.inputFeedbackSeq,inputFeedbackMs:xe.lastInfo.inputFeedbackMs,inputFeedbackAt:xe.lastInfo.inputFeedbackAt}),xe.totalFrames+=1,xe.sampleFrames+=1,Pv(xe,G,pe.frameSeq),pe.visualChanged&&(xe.totalChangedFrames+=1,xe.sampleChangedFrames+=1),xe.lastInfo=pe,Os.current.set(O,xe)},[]),ar=f.useCallback((y,E)=>{nr("wall",y,E);const _=he&&se===y.deviceId;ts.current!==y.deviceId&&!_&&(Ia.current.delete(y.deviceId),Ba.current.delete(y.deviceId))},[se,he,nr]),Rc=f.useCallback((y,E)=>{nr("control",y,E),we(pe=>pe&&"");const _=Yn.current.get(y.deviceId),G=Hn.current.get(y.deviceId);_&&_.width>0&&_.height>0&&(G&&Ps(_,G),gl.current.set(y.deviceId,{...y,payload:new ArrayBuffer(0),byteLength:0}),Ia.current.add(y.deviceId),y.deviceId===se&&($(!0),J(pe=>pe==="connecting"?"active":pe)),us(y.deviceId));const O=Ue.current;!O||!PM(O,y)||ut(!0)},[se,Ps,us,nr]);f.useEffect(()=>{const y=window.setInterval(()=>{const E=performance.now(),_={};for(const[G,O]of Os.current.entries()){const pe=Math.max(1,E-O.sampleStartedAt);_[G]={totalFrames:O.totalFrames,totalChangedFrames:O.totalChangedFrames,framesPerSecond:O.sampleFrames*1e3/pe,changedFramesPerSecond:O.sampleChangedFrames*1e3/pe,averageIntervalMs:O.intervalCount>0?O.intervalSumMs/O.intervalCount:0,minIntervalMs:Number.isFinite(O.minIntervalMs)?O.minIntervalMs:0,maxIntervalMs:O.maxIntervalMs,p95IntervalMs:ld(O.intervalSamplesMs,.95),intervalCount:O.intervalCount,seqGapCount:O.seqGapCount,maxSeqGap:O.maxSeqGap,decoderInputFps:Math.max(0,(Number(O.lastInfo?.decoderInputCount||0)-O.sampleDecoderInputBase)*1e3/pe),decoderOutputFps:Math.max(0,(Number(O.lastInfo?.decoderOutputCount||0)-O.sampleDecoderOutputBase)*1e3/pe),sampleMs:pe,lastInfo:O.lastInfo},O.sampleDecoderInputBase=Number(O.lastInfo?.decoderInputCount||0),O.sampleDecoderOutputBase=Number(O.lastInfo?.decoderOutputCount||0),O.sampleChangedFrames=0,Uv(O,E)}X(_)},1e3);return()=>window.clearInterval(y)},[]);const js=f.useCallback((y,E)=>{const _=performance.now(),G=ys(y,E.deviceId);Yt.current.set(G,_),ba.current.delete(G),y==="control"&&Wn.current.delete(G);const O=Se.current.get(G)||{totalFrames:0,sampleFrames:0,sampleStartedAt:_,intervalCount:0,intervalSumMs:0,minIntervalMs:Number.POSITIVE_INFINITY,maxIntervalMs:0,intervalSamplesMs:[],seqGapCount:0,maxSeqGap:0,sampleBytes:0,sampleH264Frames:0,sampleTinyFrames:0,sampleRepeatedFrames:0,sourceSendIntervalsMs:[]};if(O.totalFrames+=1,O.sampleFrames+=1,O.sampleBytes+=Math.max(0,Number(E.byteLength||0)),String(E.frameMode||E.mode||E.codec||E.mimeType||"").toLowerCase().includes("h264")){O.sampleH264Frames+=1,Number(E.byteLength||0)<=HM&&(O.sampleTinyFrames+=1);const Ve=String(E.contentHash||"");Ve&&O.lastContentHash===Ve&&(O.sampleRepeatedFrames+=1),O.lastContentHash=Ve}const Re=Number(E.agentSendGapMs||0);Re>0&&Re<1e3&&_h(O.sourceSendIntervalsMs,Re),O.lastFrame=E,Pv(O,_,E.frameSeq),Se.current.set(G,O)},[]);f.useEffect(()=>{const y=window.setInterval(()=>{const E=performance.now(),_={};for(const[G,O]of Se.current.entries()){const pe=Math.max(1,E-O.sampleStartedAt);_[G]={totalFrames:O.totalFrames,framesPerSecond:O.sampleFrames*1e3/pe,averageIntervalMs:O.intervalCount>0?O.intervalSumMs/O.intervalCount:0,minIntervalMs:Number.isFinite(O.minIntervalMs)?O.minIntervalMs:0,maxIntervalMs:O.maxIntervalMs,p95IntervalMs:ld(O.intervalSamplesMs,.95),intervalCount:O.intervalCount,seqGapCount:O.seqGapCount,maxSeqGap:O.maxSeqGap,averageFrameBytes:O.sampleFrames>0?O.sampleBytes/O.sampleFrames:0,tinyFrameRatio:O.sampleH264Frames>0?O.sampleTinyFrames/O.sampleH264Frames:0,repeatedFrameRatio:O.sampleH264Frames>0?O.sampleRepeatedFrames/O.sampleH264Frames:0,sourceSendAverageMs:O.sourceSendIntervalsMs.length>0?O.sourceSendIntervalsMs.reduce((xe,Re)=>xe+Re,0)/O.sourceSendIntervalsMs.length:0,sourceSendP95Ms:ld(O.sourceSendIntervalsMs,.95),sourceSendSampleCount:O.sourceSendIntervalsMs.length,sampleMs:pe,lastFrame:O.lastFrame},O.sampleBytes=0,O.sampleH264Frames=0,O.sampleTinyFrames=0,O.sampleRepeatedFrames=0,O.sourceSendIntervalsMs.length=0,Uv(O,E)}Ze(_)},1e3);return()=>window.clearInterval(y)},[]);const Cl=f.useCallback(y=>{js("wall",y);const E=ln.current.get(y.deviceId);E&&Cm(E,y,()=>ln.current.get(y.deviceId)!==E,ar,Te.h264DecodeAcceleration).catch(()=>{})},[ar,js,Te.h264DecodeAcceleration]),Ec=f.useCallback(y=>{js("control",y);let E=Yn.current.get(y.deviceId);E||(E=document.createElement("canvas"),E.setAttribute("aria-hidden","true"),Yn.current.set(y.deviceId,E));const _=E;Cm(_,y,()=>Yn.current.get(y.deviceId)!==_,Rc,Xe.h264DecodeAcceleration,"interactive").catch(G=>{we(G instanceof Error?G.message:String(G||"Control H.264 decode failed"))})},[Xe.h264DecodeAcceleration,Rc,js]),Dc=f.useCallback(y=>{const E=wa.current;E&&E!==y&&qo(E),wa.current=y,It.current=0,xl.current=0,ss.current=0,Cs.current=0,Pr.current=0,as.current=0},[]),qs=f.useCallback(()=>{const y=wa.current,E=ns.current;if(!(!y||!E||y.width<=0||y.height<=0||as.current!==E.layoutVersion))for(const _ of E.tiles){const G=Fa.current.get(_.deviceId);if(!G||_.width<=0||_.height<=0)continue;const O=Math.max(1,Math.round(_.width)),pe=Math.max(1,Math.round(_.height)),xe=$M,Re=UM;(G.width!==xe||G.height!==Re)&&(G.width=xe,G.height=Re);const Ve=G.getContext("2d",{alpha:!1});if(Ve){Ve.imageSmoothingEnabled=!0,Ve.imageSmoothingQuality="high";try{Ve.drawImage(y,Math.round(_.x),Math.round(_.y),O,pe,0,0,xe,Re)}catch{}}}},[]),Lc=f.useCallback((y,E)=>{if(E){Fa.current.set(y,E),window.requestAnimationFrame(qs),window.requestAnimationFrame(()=>us(y,!0));return}Fa.current.delete(y)},[qs,us]),Qr=f.useCallback((y,E)=>{ss.current=performance.now(),as.current=Number(y.layoutVersion||0),qs();const _=ns.current?.tiles||[],G=_.length>0?Math.round(y.byteLength/_.length):y.byteLength;for(const O of _){const pe={...y,deviceId:O.deviceId,width:O.width,height:O.height,sourceWidth:O.width,sourceHeight:O.height,byteLength:G};ar(pe,{...E,deviceId:O.deviceId,width:O.width,height:O.height,byteLength:G}),ts.current===O.deviceId&&us(O.deviceId,!0)}},[ar,qs,us]),zc=f.useCallback(y=>{const E=performance.now();It.current<=0&&(It.current=E),xl.current=E;const _=wa.current;if(!_)return;const G=ns.current?.tiles||[],O=G.length>0?Math.round(y.byteLength/G.length):y.byteLength;for(const pe of G)js("wall",{...y,deviceId:pe.deviceId,width:pe.width,height:pe.height,sourceWidth:pe.width,sourceHeight:pe.height,byteLength:O});Cm(_,y,()=>wa.current!==_,Qr).catch(()=>{})},[Qr,js]),jl=f.useMemo(()=>({fps:Gt,maxWidth:Zt.maxWidth,maxHeight:Zt.maxHeight,quality:Te.quality,mode:Te.frameMode,frameMode:Te.frameMode,streamPurpose:"wall",monitorSelections:Je,onFrame:Cl}),[Gt,Cl,Zt,Je,Te]),Bd=f.useMemo(()=>({fps:Ca,maxWidth:$a.maxWidth,maxHeight:$a.maxHeight,quality:Xe.quality,mode:An,frameMode:An,streamPurpose:"control",forceRestart:K!=="",forceRestartToken:K,restartReason:K?"control-session-start":"",monitorSelections:Je,onFrame:Ec}),[K,Xe.quality,Ec,Ca,An,$a.maxHeight,$a.maxWidth,Je]),{frames:_c,state:mi,stats:ds,restartLive:hi}=Kx(lt?[]:hn,!lt&&Te.autoStartLive&&hn.length>0,C,jl),{frame:Ua,layout:ja,state:Xr,stats:sr,refreshInputs:Zr}=b0($s,lt&&Te.autoStartLive&&$s.length>0,C,{fps:20,width:1920,height:1080,tileWidth:Zt.maxWidth,tileHeight:Zt.maxHeight,captureDeviceIds:hn,monitorSelections:Je,onFrame:zc});f.useEffect(()=>{ns.current=ja,ja&&window.requestAnimationFrame(qs)},[ja,qs]),f.useEffect(()=>{if(!lt||Xr!=="open"){It.current=0,xl.current=0,ss.current=0;return}const y=window.setInterval(()=>{const E=wa.current,_=performance.now();if(!E||document.visibilityState!=="visible"||_-Ot.current<Im)return;const G=xl.current,O=It.current;if(G<=0||O<=0||_-G>500)return;const pe=ss.current||O,xe=_-pe;if(xe>=OM&&_-Pr.current>=BM){Ux(E)&&(Pr.current=_,Cs.current=_);return}xe>=_M&&_-Cs.current>=IM&&XS(E)&&(Cs.current=_)},250);return()=>window.clearInterval(y)},[Xr,lt]);const{frames:lr,state:pi,error:ks,stats:Oc,restartLive:gi}=Kx(Us,Us.length>0,C,Bd),xi=f.useMemo(()=>{const y=new Map(_c);if(lt&&Ua){const E=new Map((ja?.tiles||[]).map(G=>[G.deviceId,G])),_=Math.max(1,E.size);for(const G of $s){const O=E.get(G);y.set(G,{...Ua,deviceId:G,width:O?.width||Zt.maxWidth,height:O?.height||Zt.maxHeight,sourceWidth:O?.width||Zt.maxWidth,sourceHeight:O?.height||Zt.maxHeight,byteLength:Math.round(Ua.byteLength/_)})}}for(const[E,_]of lr.entries())y.set(E,_);for(const E of $s){if(!Ia.current.has(E)||y.has(E))continue;const _=gl.current.get(E);_&&y.set(E,_)}return y},[Ua,ja,lr,Zt,lt,_c,$s,ya]),Jr=Ye&&Us.length>0?pi:lt?Xr:mi,eo=Ye&&Us.length>0?Oc:lt?sr:ds;f.useCallback((y,E="browser-stale")=>{const _=hi(y,E),G=gi(y,E);return _||G},[gi,hi]),f.useEffect(()=>{lt&&!Ye&&Zr()},[lt,Zr,Ye]);const ir=f.useCallback((y,E,_)=>{const G=E==="control"?Yn.current.get(y)||null:ln.current.get(y)||null;if(!G||!Ux(G))return!1;const O=performance.now();return Vt.current.set(ys(E,y),O),!0},[]),rr=f.useCallback(y=>{if(An!=="mode3-h264-hw"||!se||Y==="mode5-lzo-delta")return!1;const E=ys("control",se),_=performance.now();Qn.current.set(E,_),Yt.current.delete(E),xt.current.delete(E),vt.current.delete(E),Wn.current.delete(E),ba.current.delete(E),U("mode5-lzo-delta"),z(`control-mode5-fallback-${se}-${Date.now()}`),$(!1),ut(!1);const G=y==="no first frame"||y==="control-first-frame-timeout";return we(O=>O||(G?`Control frame transport timeout; retrying Control with Mode 5 (${y})`:`H.264 decode failed; retrying Control with Mode 5 (${y})`)),J("connecting"),!0},[se,Y,An]);f.useEffect(()=>{const y=Ye?Qt:null;if(y){Ue.current={deviceId:y.deviceId,monitorIndex:Hs,frameMode:An,startedAtEpochMs:Date.now()},ut(se===y.deviceId&&he);return}Ue.current=null,ut(!1)},[Qt?.sessionId,ce,se,he,An,Hs,Ye]);const to=f.useCallback(async y=>{const E=lt,_=j.find(xe=>xe.deviceId===y),G=Pn(Je[y],_?Bn(_):1),O=E?{fps:8,maxWidth:Zt.maxWidth,maxHeight:Zt.maxHeight,quality:60,mode:"mode2-lzo",frameMode:"mode2-lzo",streamPurpose:"atlas",monitorIndex:G}:{fps:Gt,maxWidth:Zt.maxWidth,maxHeight:Zt.maxHeight,quality:Te.quality,mode:Te.frameMode,frameMode:Te.frameMode,streamPurpose:"wall",monitorIndex:G},pe=await Be(`/api/remote/devices/${encodeURIComponent(y)}/live/start`,{method:"POST",body:JSON.stringify(O)},C);if(pe?.ok===!1)throw new Error(pe.error||"wall-stream-start-failed");return pe},[Gt,j,Zt.maxHeight,Zt.maxWidth,C,lt,Je,Te.frameMode,Te.quality]),zn=f.useCallback(async y=>{const E=await Be(`/api/remote/devices/${encodeURIComponent(y)}/live/stop`,{method:"POST",body:JSON.stringify({streamPurpose:lt?"atlas":"wall",reason:"control-active"})},C);if(E?.ok===!1)throw new Error(E.error||"wall-stream-stop-failed");return E},[C,lt]),Pa=f.useCallback(async(y,E="control-session-stop")=>{const _=await Be(`/api/remote/devices/${encodeURIComponent(y)}/live/stop`,{method:"POST",body:JSON.stringify({streamPurpose:"control",reason:E})},C);if(_?.ok===!1)throw new Error(_.error||"control-stream-stop-failed");return _},[C]),Gs=f.useCallback(y=>{const E=Yn.current.get(y);E&&(qo(E),Yn.current.delete(y));const _=Hn.current.get(y);_&&qo(_),gl.current.delete(y),Ia.current.delete(y),Ba.current.delete(y)},[]);f.useEffect(()=>{if(!Ye)return;const y=ce&&Ke.find(O=>O.deviceId===ce)||null;if(!Xt||!y)return;if(se===y.deviceId&&(R==="active"||R==="warm"||R==="connecting")){J(O=>O==="warm"?"active":O);return}if(_t.current===y.deviceId)return;const E=++Rt.current,_=se;_t.current=y.deviceId,(async()=>{if(_){if(J("stopping"),await Pa(_,"control-session-switch").catch(()=>{}),E!==Rt.current)return;Gs(_)}if(E!==Rt.current)return;const O=ys("control",y.deviceId),pe=`control-session-${E}-${y.deviceId}`;Qn.current.set(O,performance.now()),Yt.current.delete(O),xt.current.delete(O),ba.current.delete(O),Wn.current.delete(O),U(""),we(""),z(pe),oe(y.deviceId),$(!1),J("connecting"),Rt.current===E&&_t.current===y.deviceId&&(_t.current="")})()},[Ke,ce,se,R,Xt,Gs,Ye,Pa]),f.useEffect(()=>{if(!se||Ke.some(_=>_.deviceId===se))return;const y=se,E=++Rt.current;J("stopping"),Pa(y,"control-device-disconnected").catch(()=>{}).finally(()=>{E===Rt.current&&(Gs(y),$(!1),z(""),U(""),we(""),oe(_=>_===y?"":_),J("idle"))})},[Ke,se,Gs,Pa]),f.useEffect(()=>{if(at.current!==null&&(window.clearTimeout(at.current),at.current=null),!se||R==="idle"||R==="stopping"||R==="error"||Ye||Z==="wall"){se&&!Ye&&Z==="wall"&&J(_=>_==="warm"||_==="active"?"active":_);return}J(_=>_==="idle"||_==="stopping"?_:"warm");const y=se,E=++Rt.current;return at.current=window.setTimeout(()=>{at.current=null,J("stopping"),Pa(y,"control-session-warm-timeout").catch(()=>{}).finally(()=>{E===Rt.current&&(Gs(y),$(!1),z(""),U(""),we(""),oe(_=>_===y?"":_),J("idle"))})},FM),()=>{at.current!==null&&(window.clearTimeout(at.current),at.current=null)}},[Z,se,R,Gs,Ye,Pa]),f.useEffect(()=>()=>{at.current!==null&&window.clearTimeout(at.current)},[]),f.useEffect(()=>{const y=++Ss.current,E=he&&(R==="active"||R==="warm")&&se?se:"",_=ts.current;if(Vn.current||!E&&!_||E&&E===_)return;(async()=>{Vn.current=E||_;try{if(_&&_!==E){if(await to(_),y!==Ss.current)return;ts.current="",Ja("")}if(!E||y!==Ss.current)return;if(await zn(E),y!==Ss.current){await to(E).catch(()=>{});return}ts.current=E,Ja(E),Ia.current.add(E),be(_&&_!==E?`Wall paused for Control: ${E}`:"")}catch(O){y===Ss.current&&be(O instanceof Error?O.message:String(O))}finally{Vn.current===(E||_)&&(Vn.current="")}})()},[se,he,R,lt,to,zn]);const{state:vi,sendInput:kl,stats:ka,error:yi}=S0(cs&&me,C);f.useEffect(()=>{yi&&Ye&&me&&be(yi)},[me,yi,Ye]);const{state:no,lastFrame:Ys,stats:pn,error:Ml}=E0(Ae?.deviceId||"",Nc&&Pe,C);f.useEffect(()=>{if(!Ye||!me||!cs||!Ae)return;const y=(G,O)=>{const pe=G.target,xe=pe?.tagName?.toLowerCase();pe?.isContentEditable||xe==="input"||xe==="textarea"||xe==="select"||(G.preventDefault(),G.stopPropagation(),kl(Ae.deviceId,{type:O,monitorIndex:Pn(Je[Ae.deviceId],Bn(Ae)),key:G.key,code:G.code,keyCode:G.keyCode||G.which||0,location:G.location,text:G.key.length===1?G.key:"",repeat:O==="keydown"?G.repeat:!1,shiftKey:G.shiftKey,ctrlKey:G.ctrlKey,altKey:G.altKey,metaKey:G.metaKey}))},E=G=>y(G,"keydown"),_=G=>y(G,"keyup");return window.addEventListener("keydown",E),window.addEventListener("keyup",_),()=>{window.removeEventListener("keydown",E),window.removeEventListener("keyup",_)}},[cs,me,Je,Ae,kl,Ye]),f.useEffect(()=>{const y=()=>{document.visibilityState==="visible"&&(Ot.current=performance.now())};return document.addEventListener("visibilitychange",y),window.addEventListener("pageshow",y),()=>{document.removeEventListener("visibilitychange",y),window.removeEventListener("pageshow",y)}},[]),f.useEffect(()=>{if(!se||R!=="connecting"&&R!=="active"&&R!=="warm"||pi!=="open")return;const y=se,E=ys("control",y),_=window.setInterval(()=>{const G=performance.now();if(document.visibilityState!=="visible"||G-Ot.current<Im)return;const O=Yt.current.get(E)||0,pe=xt.current.get(E)||0,xe=vt.current.get(E)||0,Re=Qn.current.get(E)||G;Qn.current.has(E)||Qn.current.set(E,Re);const Ve=O<=0,We=Ve?G-Re>KM:G-O>Kv,yt=O>0&&(pe<=0||G-pe>Kv);if(!We&&yt){const oa=Vt.current.get(E)||0;G-oa>=Wv&&ir(y,"control","decoder-paint-stale");return}if(!We)return;const $t=Wn.current.get(E)||0;if($t>0){if(G-$t<QM)return;Wn.current.delete(E)}const ra=ba.current.get(E)||0;if(ra>=XM){if(rr(Ve?"no first frame":"stale stream"))return;$(!1),ut(!1),J("error");return}if(G-xe<Qv(WM,ra))return;gi([y],Ve?"control-first-frame-timeout":"control-receive-stale")&&(vt.current.set(E,G),Wn.current.set(E,G),Qn.current.set(E,G),ba.current.set(E,ra+1))},650);return()=>window.clearInterval(_)},[pi,se,R,rr,ir,gi]),f.useEffect(()=>{!ie||An!=="mode3-h264-hw"||rr(ie)},[ie,An,rr]),f.useEffect(()=>{!Ye||!se||!ks||J(y=>y==="error"?y:"error")},[ks,se,Ye]),f.useEffect(()=>{if(lt||mi!=="open"||!Te.autoStartLive||hn.length===0)return;const y=window.setInterval(()=>{const E=performance.now();if(document.visibilityState!=="visible"||E-Ot.current<Im)return;const _=1e3/Math.max(1,Gt||Te.fps||1),G=Math.max(ZM,Math.ceil(_*4)),O=[];for(const pe of hn){if(O.length>=tA)break;const xe=ys("wall",pe),Re=Yt.current.get(xe)||0;if(Re<=0)continue;const Ve=vt.current.get(xe)||0,We=xt.current.get(xe)||0,yt=E-Re>G,$t=We<=0||E-We>G;if(!yt&&$t){const ps=Vt.current.get(xe)||0;E-ps>=Wv&&ir(pe,"wall","decoder-paint-stale");continue}if(!yt)continue;const ra=ba.current.get(xe)||0;E-Ve>=Qv(JM,ra)&&O.push(pe)}if(O.length>0&&hi(O,"wall-frame-stale"))for(const pe of O){const xe=ys("wall",pe);vt.current.set(xe,E),ba.current.set(xe,(ba.current.get(xe)||0)+1)}},eA);return()=>window.clearInterval(y)},[Gt,lt,ir,hi,Te.autoStartLive,Te.fps,hn,mi]),f.useEffect(()=>{pl(Te.fps),di.current=Date.now(),Sa.current=0},[Te.fps,Te.frameMode,Te.adaptiveLoadShedding]),f.useEffect(()=>{US({h264DecodeAcceleration:Te.h264DecodeAcceleration})},[Te.h264DecodeAcceleration]),f.useEffect(()=>{if(!Xt||Ye||!Te.visibleOnlyLive){_s([]);return}const y=Gr.current;if(!y||typeof IntersectionObserver>"u"){_s(tr);return}const E=Array.from(y.querySelectorAll("[data-live-device-id]"));if(E.length===0){_s([]);return}const _=new Map,G=()=>{const pe=$m(E.map(xe=>String(xe.dataset.liveDeviceId||"")).filter(xe=>(_.get(xe)||0)>0));_s(xe=>Hm(xe,pe)?xe:pe)},O=new IntersectionObserver(pe=>{for(const xe of pe){const Re=String(xe.target.dataset.liveDeviceId||"");Re&&_.set(Re,xe.isIntersecting?xe.intersectionRatio||.01:0)}G()},{root:null,rootMargin:Fn.visibleRootMargin,threshold:[0,.01,.2,.6,1]});return E.forEach(pe=>O.observe(pe)),G(),()=>O.disconnect()},[tr,Xt,Ye,vl,Te.visibleOnlyLive,Me]),f.useEffect(()=>{if(lt||!Te.adaptiveLoadShedding||!Te.autoStartLive||hn.length===0)return;const y=Te.fps;if(hn.length<=Fn.preserveConfiguredFpsDeviceCount){Gt!==y&&(pl(y),di.current=Date.now(),Sa.current=0);return}if(mi!=="open"||ds.sampleMs<500)return;const E=Date.now(),_=hn.length*Gt,G=ds.framesPerSecond,O=ds.bytesPerSecond,pe=Math.max(0,...hn.map(yt=>De[ys("wall",yt)]?.maxIntervalMs||0)),xe=Math.max(0,...hn.map(yt=>Kn[ys("wall",yt)]?.maxIntervalMs||0)),Re=_>8&&G>0&&G<_*.72;if(G>Fn.maxWallFramesPerSecond||O>Fn.maxWallBytesPerSecond||pe>Fn.maxFrameGapMs||xe>Fn.maxFrameGapMs||Re){Sa.current=0;const yt=Fn.minFps;if(E-di.current>=Fn.downshiftCooldownMs&&Gt>yt){const $t=Math.max(yt,gA(Gt,yt));$t<Gt&&(pl($t),di.current=E)}return}const We=G<Fn.maxWallFramesPerSecond*Fn.lowLoadFrameRatio&&O<Fn.maxWallBytesPerSecond*Fn.lowLoadByteRatio;if(!We||Gt>=y){We||(Sa.current=0);return}if(!Sa.current){Sa.current=E;return}if(E-Sa.current>=Fn.recoveryCooldownMs){const yt=Math.min(y,xA(Gt,y));yt>Gt&&(pl(yt),di.current=E,Sa.current=0)}},[Gt,lt,Kn,De,hn.length,hn,mi,ds.bytesPerSecond,ds.framesPerSecond,ds.lastUpdatedAt,ds.sampleMs,Te.adaptiveLoadShedding,Te.autoStartLive,Te.frameMode,Te.fps]),f.useEffect(()=>{const y=new URLSearchParams(window.location.search).get("checkout");if(y==="success"){be("Checkout returned. Waiting for Dodo confirmation."),q();const E=window.setInterval(()=>{q()},4e3),_=window.setTimeout(()=>{window.clearInterval(E)},45e3);return()=>{window.clearInterval(E),window.clearTimeout(_)}}y==="cancelled"&&be("Checkout cancelled.")},[q]),f.useEffect(()=>{!Xt&&me&&ze(!1),!Xt&&Pe&&de(!1)},[Pe,me,Xt]),f.useEffect(()=>{const y=Ae?.deviceId||"",E=He.current;if(He.current=y,!E||E===y)return;const _=++Fe.current,G=y?`audio-${Date.now()}-${Math.random().toString(36).slice(2,8)}`:"";y&&Pe&&Le.current.set(y,G);let O=!0;return(async()=>{try{const xe=Le.current.get(E);if(Le.current.delete(E),await Be(`/api/remote/devices/${encodeURIComponent(E)}/audio/stop`,{method:"POST",body:JSON.stringify(xe?{streamId:xe}:{})},C),!O||_!==Fe.current||!Pe||!y||!Xt||!wl)return;const Re=await Be(`/api/remote/devices/${encodeURIComponent(y)}/audio/start`,{method:"POST",body:JSON.stringify({streamId:G,mimeType:"audio/pcm;format=f32le",sampleRate:48e3,channels:2})},C);if(Re.ok===!1)throw new Error(Re.error||"Remote audio start failed.")}catch(xe){O&&(Le.current.delete(y),de(!1),be(xe instanceof Error?xe.message:String(xe)))}})(),()=>{O=!1}},[Pe,Xt,C,wl,Ae?.deviceId]),f.useEffect(()=>{const y=Ke.map(G=>G.deviceId),E=new Set(y),_=new Map(Ke.map(G=>[G.deviceId,G]));F(G=>{const O=G.filter(pe=>E.has(pe));return Hm(G,O)?G:O}),W(G=>G&&E.has(G)?G:""),Q(G=>G&&E.has(G)?G:""),yn(G=>{let O=!1;const pe={};for(const[xe,Re]of Object.entries(G)){if(!E.has(xe)){O=!0;continue}const Ve=_.get(xe),We=Pn(Re,Ve?Bn(Ve):1);pe[xe]=We,We!==Re&&(O=!0)}return O?pe:G}),oi(G=>{const O=G.filter(pe=>E.has(pe));return Hm(G,O)?G:O})},[Ke,Fs]),f.useEffect(()=>{wc([]),Sc(!1)},[us]),f.useEffect(()=>{!Ha||ls!=="selected"||mn.length>0||Zn.length===0||oi(Zn.map(y=>y.deviceId))},[Zn,mn.length,ls,Ha]),f.useEffect(()=>{try{localStorage.setItem(dw,Gn)}catch{}},[Gn]),f.useEffect(()=>{dA(Te)},[Te]),f.useEffect(()=>{mA(Xe)},[Xe]);const wi=f.useCallback(async()=>{const y=new Set(x);y.add(Ln);try{const pe=await Be("/api/remote/status",void 0,Ln);qx({endpoint:pe.agentEndpoint,endpoint_candidates:[...pe.agentEndpointCandidates||[],...pe.hostTargetEndpointCandidates||[]]}).forEach(xe=>y.add(xe))}catch{}const E=[...y].sort((pe,xe)=>{const Re=Ve=>{const We=sc(Ve);return We==="local"?0:We==="loopback"?1:2};return Re(pe)-Re(xe)||pe.localeCompare(xe)});let _=!1,G="",O=!1;try{for(const pe of E){const xe=sc(pe);try{if(await Be("/api/health",void 0,pe),xe==="local")return w(!0),zr(!0),pe;xe==="loopback"&&(_=!0,G=pe)}catch{xe==="local"&&(O=!0)}}return _?(O&&be("LiveDesk Hub is reachable on this PC, but not through the LAN address yet. Restart LiveDesk Hub to bind 5179 on the network."),w(!0),zr(!0),G||Ln):(w(!1),zr(!1),"")}catch{return w(!1),zr(!1),""}},[x]),bi=async()=>{ne("auth"),Dt(!1),await wi();const{error:y}=await Ds.auth.signInWithOAuth({provider:"google",options:{redirectTo:window.location.origin}});y&&(be(y.message),ne(""))},Vs=async()=>{ne("auth"),Dt(!1),await Ds.auth.signOut(),ne("")};f.useEffect(()=>{if(!Oe)return;const y=_=>{_.target instanceof Element&&(_.target.closest(".account-popover, .rail-account")||Dt(!1))},E=_=>{_.key==="Escape"&&Dt(!1)};return window.addEventListener("pointerdown",y),window.addEventListener("keydown",E),()=>{window.removeEventListener("pointerdown",y),window.removeEventListener("keydown",E)}},[Oe]);const Ma=f.useCallback(async(y={})=>{const E=y.silent===!0,_=y.takeover===!0,G=y.requestLocalAccess===!0,O=G?await wi():"";if(!a?.user){E||be("Sign in before publishing this host.");return}if(!ui.current){ui.current=!0,E||ne("host");try{const pe=O||C||Ln,xe=k||await Be("/api/remote/status",void 0,pe);if(!xe.started)throw new Error("Start LiveDesk on this computer before syncing the server.");const Re=`livedesk-${a.user.id}`,Ve=await Be("/api/remote/host-target",{method:"POST",body:JSON.stringify({nodeId:Re,leaseMs:6e4,takeover:_})},pe);if(!Ve.ok)throw new Error(Ve.error||"host-target-failed");const We=await Be("/api/remote/status",void 0,pe),yt=await Be("/api/remote/registry-credentials",void 0,pe),$t=Ve.hostTarget||{},ra=We.hostTargetEndpointCandidates||We.agentEndpointCandidates||xe.agentEndpointCandidates||[We.agentEndpoint||xe.agentEndpoint].filter(Boolean),{data:ps,error:oa}=await Ds.rpc("set_livedesk_remote_host_target",{p_node_id:Re,p_lease_id:String($t.leaseId||We.hostTargetLeaseId||crypto.randomUUID()),p_host_instance_id:We.hostInstanceId||Re,p_endpoint:We.hostTargetEndpoint||We.agentEndpoint||xe.agentEndpoint,p_pair_token:yt.pairToken||"",p_manager_package:"@livedesk/hub",p_manager_version:We.managerVersion||"0.1.0",p_agent_package:"@livedesk/client",p_activated_at:new Date().toISOString(),p_expires_at:new Date(Date.now()+6e4).toISOString(),p_takeover:_,p_endpoint_candidates:ra,p_pairing_pin:yt.pairingPin||We.pairingPin||""});if(oa)throw oa;const gs=Array.isArray(ps)?ps[0]:ps;if(gs&&gs.ok===!1)throw new Error(gs.reason||"registry-rejected");E||(be("Host published."),(G||v)&&(w(!0),zr(!0)),T()),d()}catch(pe){if(!E){const xe=pe instanceof Error?pe.message:String(pe);xe.includes("local network access")&&(w(!1),zr(!1)),be(xe)}}finally{ui.current=!1,E||ne("")}}},[C,v,T,d,wi,a,k]),ao=f.useCallback(async()=>{if(!qe){ne("pin");try{const E=await Be("/api/remote/pairing-pin",{method:"POST"},C||Ln);if(!E.ok)throw new Error(E.error||"pin-rotation-failed");await T(),a?.user&&await Ma({silent:!0,takeover:!0}),be("New PIN published.")}catch(y){be(y instanceof Error?y.message:String(y))}finally{ne("")}}},[qe,C,Ma,T,a]);f.useEffect(()=>{if(!a?.user||!k?.started||M)return;const y=r?.expires_at?Date.parse(r.expires_at):Number.POSITIVE_INFINITY,E=r?.active===!0&&(!r.expires_at||!Number.isFinite(y)||y>Date.now()),_=!!r?.host_instance_id&&!!k.hostInstanceId&&r.host_instance_id===k.hostInstanceId;if(E&&!_)return;let G=!1;const O=()=>{if(G)return;const xe=Date.now();xe-kc.current<25e3||(kc.current=xe,Ma({silent:!0}))};O();const pe=window.setInterval(O,3e4);return()=>{G=!0,window.clearInterval(pe)}},[M,Ma,a?.user?.id,k?.agentEndpoint,k?.hostInstanceId,k?.started,r?.active,r?.expires_at,r?.host_instance_id]);const Ks=f.useCallback(y=>{y&&(W(y),F(E=>E.includes(y)?E:[...E,y]))},[]),Ms=f.useCallback(y=>{if(!y)return;const E=rs.has(y);W(_=>E&&_===y?"":y),F(_=>E?_.filter(G=>G!==y):_.includes(y)?_:[..._,y])},[rs]),Al=f.useCallback(()=>{F([]),W("")},[Ps]),so=f.useCallback(()=>{F(Ke.map(y=>y.deviceId)),W("")},[Ke]),or=f.useCallback((y,E)=>{const _=Ke.find(O=>O.deviceId===y);if(!_)return;const G=Bn(_);G<=1||(yn(O=>{const xe=(Pn(O[y],G)+E+G)%G;return{...O,[y]:xe}}),Ye?(ut(!1),Q(y)):Ks(y))},[Ke,Ks,Ye]);f.useEffect(()=>{const y=E=>{if(Ye&&me&&cs)return;const _=E.target,G=_?.tagName?.toLowerCase();_?.isContentEditable||G==="input"||G==="textarea"||G==="select"||((E.ctrlKey||E.metaKey)&&E.key.toLowerCase()==="a"&&(E.preventDefault(),so()),E.key==="Escape"&&Al())};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[cs,Al,me,so,Ye]);const Ic=async(y,E={})=>{if(!os.has(y)){be(bl);return}const _=E.focused||Ye;_?(ut(!1),Q(y)):Ks(y);try{const G=Ke.find(xe=>xe.deviceId===y),O=_?{maxWidth:Xe.maxWidth,maxHeight:Xe.maxHeight}:Zt,pe=Pn(E.monitorIndex??Je[y],G?Bn(G):1);await Be(`/api/remote/devices/${encodeURIComponent(y)}/live/start`,{method:"POST",body:JSON.stringify({fps:_?Xe.fps:Gt,maxWidth:O.maxWidth,maxHeight:O.maxHeight,quality:_?Xe.quality:Te.quality,mode:_?Xe.frameMode:Te.frameMode,frameMode:_?Xe.frameMode:Te.frameMode,streamPurpose:_?"control":"wall",monitorIndex:pe})},C),T()}catch(G){be(G instanceof Error?G.message:String(G))}},Fd=(y,E)=>{const _=Ke.find(O=>O.deviceId===y),G=Pn(E,_?Bn(_):1);yn(O=>({...O,[y]:G})),Ye?(ut(!1),Q(y)):Ks(y)},lo=async y=>{if(ut(!1),Q(y),le("control"),!os.has(y)){ze(!1),be(bl);return}ze(!0)},Bc=async()=>{if(!Ae){be("Select a workstation before playing audio.");return}if(!Xt){be(bl);return}if(!wl){be("Selected workstation does not report remote audio support yet.");return}const y=!Pe,E=y?`audio-${Date.now()}-${Math.random().toString(36).slice(2,8)}`:Le.current.get(Ae.deviceId);y&&E?Le.current.set(Ae.deviceId,E):y||Le.current.delete(Ae.deviceId),de(y);try{await Be(`/api/remote/devices/${encodeURIComponent(Ae.deviceId)}/audio/${y?"start":"stop"}`,{method:"POST",body:JSON.stringify({...E?{streamId:E}:{},mimeType:"audio/pcm;format=f32le",sampleRate:48e3,channels:2})},C)}catch(_){y&&Le.current.delete(Ae.deviceId),de(!1),be(_ instanceof Error?_.message:String(_))}},io=async(y,E,_="files")=>{const G=y.filter(Re=>Re.file.size>=0);if(G.length===0)return{files:0,bytes:0};if(!Xt)throw new Error(bl);if(E.length===0)throw new Error("Select at least one connected workstation.");const O=crypto.randomUUID(),pe=G.reduce((Re,Ve)=>Re+Ve.file.size,0);let xe=0;Kt({id:O,status:"reading",progress:1,message:`Preparing ${G.length} ${_}`});try{for(let Re=0;Re<G.length;Re+=1){const Ve=G[Re],We=Ve.file,yt=Math.max(1,Math.ceil(We.size/_m));for(let $t=0;$t<yt;$t+=1){const ra=$t*_m,ps=Math.min(We.size,ra+_m),oa=We.size===0?new ArrayBuffer(0):await We.slice(ra,ps).arrayBuffer(),gs=$t===yt-1;Kt({id:O,status:"sending",progress:Math.max(2,Math.min(98,Math.round(xe/Math.max(1,pe)*96))),message:`${Re+1}/${G.length} ${Ve.relativePath}`});const el=await Be("/api/remote/files/chunk",{method:"POST",body:JSON.stringify({transferId:O,deviceIds:E,remoteDirectory:Gn.trim(),name:We.name,relativePath:Ve.relativePath,size:We.size,type:We.type,lastModified:We.lastModified,offset:ra,totalBytes:We.size,final:gs,dataBase64:vA(oa)})},C);if(!el.ok||el.queued!==E.length)throw new Error(el.error||`file-chunk-not-queued-${el.queued}/${E.length}`);xe+=oa.byteLength,await new Promise(Di=>window.setTimeout(Di,0))}}return Kt({id:O,status:"queued",progress:100,message:`Sent ${G.length} file${G.length===1?"":"s"} to ${E.length} workstation${E.length===1?"":"s"}`}),window.setTimeout(()=>{Kt(Re=>Re?.id===O&&Re.status==="queued"?null:Re)},4500),{files:G.length,bytes:pe}}catch(Re){throw Kt({id:O,status:"failed",progress:100,message:Re instanceof Error?Re.message:String(Re)}),Re}},cr=async y=>{const E=Zn.length>0?Zn.map(_=>_.deviceId):Ae?[Ae.deviceId]:[];try{await io(Zv(y),E)}catch(_){be(_ instanceof Error?_.message:String(_))}},ea=async y=>{try{await io(Zv(y),Kr)}catch(E){be(E instanceof Error?E.message:String(E))}};f.useEffect(()=>{jc.current=!1},[]);const ur=y=>{y.preventDefault(),y.stopPropagation(),qr(!1),cr(y.dataTransfer.files)},Nn=async(y="ltd")=>{if(!a){be("Sign in with Google before checkout.");return}if(D&&y===At){be("LiveDesk license is already active.");return}if(D&&At==="pro"){be("LiveDesk Pro is already active.");return}ne("checkout");try{const{data:E,error:_}=await Ds.functions.invoke("dodo-checkout",{body:{plan:y}});if(_)throw _;if(!E?.checkout_url)throw new Error("Checkout function did not return a checkout URL.");window.location.assign(E.checkout_url)}catch(E){be(E instanceof Error?E.message:String(E)),ne("")}},$n=nA(),Nl=aA(),dr=Ke.length,Tl=_d.filter(y=>xi.has(y)).length,Si=Jr==="open"&&eo.sampleMs>0?`${eo.framesPerSecond.toFixed(1)} fps`:Jr,Ce=Ae?Ye?lr.get(Ae.deviceId):xi.get(Ae.deviceId):void 0,Ci=Ae?Pn(Je[Ae.deviceId],Bn(Ae)):0,ji=Ae?rA(Ae):[],Rl=typeof Ce?.monitorIndex=="number"?Pn(Ce.monitorIndex,Math.max(1,Ce.monitorCount||1)):Ci,Tn=(Ce&&Rl===Ci?bw(Ce):null)||(Ae?ww(Ae,Ci):null),ro=Tn?`${Tn.width}x${Tn.height}`:"-",ta=Ae?ys(Ye?"control":"wall",Ae.deviceId):"",rn=ta?De[ta]:void 0,wn=ta?Kn[ta]:void 0,et=wn?.lastInfo,oo=rn&&rn.sampleMs>0?`${rn.framesPerSecond.toFixed(1)} fps`:"waiting",Fc=rn?`#${rn.totalFrames} / ${oo}`:"waiting",co=wn&&wn.sampleMs>0?`${wn.framesPerSecond.toFixed(1)} fps`:"waiting",Hc=wn&&wn.sampleMs>0?`${wn.changedFramesPerSecond.toFixed(1)} fps`:"waiting",na=et?`#${et.frameSeq} ${et.decoderLabel} q${et.queueSize} r${et.renderQueueSize} d${et.droppedForLatency} f${et.decoderFlushCount} t${et.decoderTimestampFallbacks} io${et.decoderInputCount}/${et.decoderOutputCount} ${et.visualChanged?"changed":"same"}`:"waiting",El=et?`${Math.round(et.queuedForMs)}ms total / ${Math.round(et.decodedForMs)}ms decode / ${Math.round(et.scheduledForMs)}ms pace / ${et.drawMs.toFixed(1)}ms draw`:"-",Dl=et?.targetPaintIntervalMs?`${et.targetPaintIntervalMs.toFixed(1)}ms / ${(1e3/et.targetPaintIntervalMs).toFixed(1)} fps`:"-",fr=wn?`${wn.decoderInputFps.toFixed(1)} in / ${wn.decoderOutputFps.toFixed(1)} out fps`:"waiting",ki=et?.canvasPresentation||"-",aa=et?`${et.interactiveBufferWaitCount} waits / ${Math.round(et.interactiveBufferWaitMs)}ms / ${et.interactiveQueueDrainCount} drains`:"waiting",sa=n.framesPerSecond>0?`${n.framesPerSecond.toFixed(1)} fps / p95 ${n.p95IntervalMs.toFixed(1)}ms / max ${n.maxIntervalMs.toFixed(1)}ms / long ${n.longTaskCount} (${Math.round(n.longTaskMs)}ms)`:"waiting",As=rn?Ce?.frameMode==="mode5-lzo-delta"?`${Zo(rn.averageFrameBytes)} avg / visual ${Ce.deltaVisualTileCount||0} + refresh ${Ce.deltaRefreshTileCount||0} / ${Ce.deltaTotalTiles||0}`:`${Zo(rn.averageFrameBytes)} avg / tiny ${Math.round(rn.tinyFrameRatio*100)}% / repeat ${Math.round(rn.repeatedFrameRatio*100)}%`:"waiting",qa=rn&&rn.sourceSendSampleCount>0?`${rn.sourceSendAverageMs.toFixed(1)}ms avg / p95 ${rn.sourceSendP95Ms.toFixed(1)}ms`:"waiting",Ga=qv(rn),fs=qv(wn),$c=rn&&wn?`rx ${Gv(rn)} / paint ${Gv(wn)}`:"waiting",Mi=Ce?Ce.frameMode||Ce.mode||Ce.codec||Ce.mimeType:Ye?Xe.frameMode:Te.frameMode,Ai=Ye?Xe.frameMode:Te.frameMode,Uc=Mi!==Ai?`${Ai} -> ${Mi}`:Ai,gn=Ce?`${Ce.width}x${Ce.height} ${Zo(Ce.byteLength)}`:Ye?`${$a.maxWidth}x${$a.maxHeight}`:`${Te.maxWidth}x${Te.maxHeight}`,kt=Ce?Ce.frameMode==="mode2-lzo"?"independent":`${Ce.isKeyFrame?"key":String(Ce.chunkType||"delta")}`:"-",it=Ce&&Ce.monitorCount?`${(Ce.monitorIndex??0)+1}/${Ce.monitorCount}`:"-",Ns=Ce?[`src ${Math.round(Ce.sourceGapMs||0)}ms`,`gap ${Math.round(Ce.agentSendGapMs||0)}ms`,`tx ${Math.round(Ce.agentSendDurationMs||0)}ms`,`pace ${Math.round(Ce.agentPaceMs||0)}ms`,`queue ${Math.round(Ce.agentQueueBeforePaceMs||0)}ms`,`age ${Math.round(Ce.agentFrameAgeMs||0)}ms`,Ce.browserReceivedEpochMs&&Ce.receivedAt?`hub ${Math.max(0,Math.round(Ce.browserReceivedEpochMs-Date.parse(Ce.receivedAt)))}ms`:"",Ce.browserReceivedEpochMs&&Ce.hubPacketEpochMs?`sock ${Math.max(0,Math.round(Ce.browserReceivedEpochMs-Ce.hubPacketEpochMs))}ms`:"",Ce.droppedByAgent?`drop ${Ce.droppedByAgent}`:"",Ce.hubIngressDropped?`ingress-drop ${Ce.hubIngressDropped}`:"",Ce.hubClientDropped?`ws-drop ${Ce.hubClientDropped}`:"",Ce.captureStageMs?`capture ${Math.round(Ce.captureStageMs)}ms`:"",Ce.requestedFps?`req ${Math.round(Ce.requestedFps)}fps`:"",Ce.effectiveFps?`eff ${Math.round(Ce.effectiveFps)}fps`:"",Ce.captureAverageMs?`avg ${Math.round(Ce.captureAverageMs)}ms`:"",Ce.captureP95Ms?`p95 ${Math.round(Ce.captureP95Ms)}ms`:"",Ce.slowFrameCount?`slow ${Math.round(Ce.slowFrameCount)}`:"",Ce.captureHelperRestarts?`helper ${Math.round(Ce.captureHelperRestarts)}`:"",Ce.convertMs?`rgb565 ${Math.round(Ce.convertMs)}ms`:"",Ce.compressMs?`lzo ${Math.round(Ce.compressMs)}ms`:"",Ce.captureSourceSerial?`cap #${Ce.captureSourceSerial}`:"",Ce.captureSourceSkipped?`cap skip ${Ce.captureSourceSkipped}`:"",Ce.frameMode==="mode5-lzo-delta"?`tiles ${Ce.deltaVisualTileCount||0}+${Ce.deltaRefreshTileCount||0}/${Ce.deltaTotalTiles||0}@${Ce.deltaTileSize||0}`:"",Ce.platformProfile||Ce.hardwareEncoder||"-",Ce.atlasComposeMs?`atlas ${Ce.atlasComposeMs.toFixed(1)}ms`:"",Ce.atlasPoolStarved?`pool ${Ce.atlasPoolStarved}`:"",Ce.atlasTileCount?`tiles ${Ce.atlasReadyTiles||0}/${Ce.atlasTileCount}`:"",et?.inputFeedbackMs!==void 0&&et.inputFeedbackAt!==void 0&&performance.now()-et.inputFeedbackAt<=Hv?`feedback ${Math.round(et.inputFeedbackMs)}ms`:"",Ce.contentHash?`enc ${Ce.contentHash.slice(0,6)}`:"",et?.visualHash?`pix ${et.visualHash.slice(0,6)}`:""].filter(Boolean).join(" / "):"-",la=vi==="open"?[`${ka.sentPerSecond.toFixed(1)} hz`,ka.lastInputSeq>0?`rtt ${Math.round(ka.lastRoundTripMs)}ms`:"",ka.lastInputSeq>0?`apply ${ka.lastAgentApplyMs.toFixed(1)}ms`:"",ka.droppedPerSecond>0?`drop ${ka.droppedPerSecond.toFixed(1)}/s`:"",ka.bufferedAmount>0?`buf ${Zo(ka.bufferedAmount)}`:"",ka.lastInputType||"ready"].filter(Boolean).join(" / "):vi,uo=et?.inputFeedbackMs!==void 0&&et.inputFeedbackAt!==void 0&&performance.now()-et.inputFeedbackAt<=Hv?`${Math.round(et.inputFeedbackMs)}ms / input #${et.inputFeedbackSeq||0}`:"waiting for changed frame",Ts=Pe?[no,`context ${pn.audioContextState}`,`queue ${Math.round(pn.queuedMs)}ms`,`last ${Math.round(pn.lastPacketAgeMs)}ms`,`accepted ${Math.round(pn.lastAcceptedAgeMs)}ms`,`process ${Math.round(pn.localProcessingAgeMs)}ms`,`remote ${Math.round(pn.browserAgeMs)}/${Math.round(pn.captureAgeMs)}ms`,`heartbeat ${Math.round(pn.captureStatusAgeMs)}ms`,`capture ${pn.captureAlive&&pn.helperAlive?"alive":"down"}`,`drop ${pn.drops}`,`resync ${pn.resyncs}`,`restart ${pn.automaticRestarts}`,pn.pendingDecodes>0?`decode ${pn.pendingDecodes}`:"",Ys?`#${Ys.frameSeq}`:"waiting"].filter(Boolean).join(" / "):"off",Pc=Ce?`#${Ce.frameSeq} ${Jm(Ce.receivedAt||Ce.capturedAt)}`:"waiting",Ws=Math.max(0,eo.bytesPerSecond*8/1e6),Qs=Ua?.atlasReadyTiles??Tl,ms=Ua?.atlasTileCount??Tl,fo=Qs===ms?`${ms} tiles`:`${Qs}/${ms} tiles`,Ni=Ye?`1 stream / ${Si} / ${Ws.toFixed(Ws>=10?0:1)}Mbps`:lt?`1 stream / ${fo} / ${Si} / ${Ws.toFixed(Ws>=10?0:1)}Mbps`:`${Tl} screens / ${Si} / ${Ws.toFixed(Ws>=10?0:1)}Mbps`,mr=M?"offline":k?.started?"online":"starting",Ya=Zn.length,hs=Ye?Ae?Yi(Ae):"No workstation":Ya===0?"No workstation":Ya>1?`${Ya} selected`:Ae?Yi(Ae):"No workstation",Lt=Fr[ct]||Fr.en,ia=Lt.sync||Fr.en.sync,hr=i||H?"checking":D?At==="pro"?"Pro LTD active":`Plus LTD ${Ke.length}/${Xo}`:Dd?`Free ${Ke.length}/${Qo}`:`Upgrade ${Ke.length}/${Qo}`,mo=At==="pro"?"Pro active":qe==="checkout"?"Opening":At==="ltd"?"Pro $199":"Plus $79",pr=D?At==="pro"?"Pro active":"Upgrade to Pro LTD":a?qe==="checkout"?"Opening checkout":At==="ltd"?"Buy Pro LTD":"Buy Plus LTD":qe==="auth"?"Opening Google":"Sign in to buy",Xs=At==="pro"||qe==="checkout"||qe==="auth"||i||H,on=a?.user.user_metadata,Zs=Jv(on,"avatar_url","picture"),Ll=Jv(on,"full_name","name")||a?.user.email||"Google",qc=Ll.slice(0,1).toUpperCase(),Hd=k?.started?"Local app ready":"Start LiveDesk",$d=r?.active?"Published":a?"Not published":"Sign in required",Ht=/^\d{6}$/.test(k?.pairingPin||"")?k?.pairingPin:"------",ho=rd.find(y=>y.width===Te.maxWidth&&y.height===Te.maxHeight)?.id||`${Te.maxWidth}x${Te.maxHeight}`,Ri=Te.atlasTileSizeMode==="auto"?"auto":Fm.find(y=>y.width===Te.atlasTileWidth&&y.height===Te.atlasTileHeight)?.id||"320x180",Ei=Bm.find(y=>y.width===Xe.maxWidth&&y.height===Xe.maxHeight)?.id||`${Xe.maxWidth}x${Xe.maxHeight}`,po=id.find(y=>y.id===Te.frameMode)||id[0],xn=y=>{za(E=>{const _=y.frameMode?uh(y.frameMode):E.frameMode,G=y.frameMode!==void 0&&_!==E.frameMode;return{...E,...y,frameMode:_,fps:fh(y.fps??(G?xw(_):E.fps),_)}})},zl=y=>{const E=rd.find(_=>_.id===y);E&&xn({maxWidth:E.width,maxHeight:E.height})},Ud=y=>{if(y==="auto"){xn({atlasTileSizeMode:"auto"});return}const E=Fm.find(_=>_.id===y);!E?.width||!E?.height||xn({atlasTileSizeMode:"fixed",atlasTileWidth:E.width,atlasTileHeight:E.height})},Js=y=>{y.frameMode!==void 0&&(U(""),we("")),_a(E=>{const _=y.frameMode?dh(y.frameMode):E.frameMode,G=y.frameMode!==void 0&&_!==E.frameMode,O=y.fps??(G?30:E.fps),pe=y.maxWidth??E.maxWidth,xe=y.maxHeight??E.maxHeight;return{...E,...y,frameMode:_,fps:Qa(O,20,_==="mode5-lzo-delta"?30:60,_==="mode5-lzo-delta"?30:60),maxWidth:_==="mode5-lzo-delta"?Math.min(1920,pe):pe,maxHeight:_==="mode5-lzo-delta"?Math.min(1080,xe):xe}})},Pd=y=>{const E=Bm.find(_=>_.id===y);E&&Js({maxWidth:E.width,maxHeight:E.height})},gr=y=>{if(y==="control"){const E=Qt||Wt;if(E&&(ut(!1),Q(E.deviceId)),le(y),!Xt){ze(!1),be(bl);return}ze(!0);return}y==="wall"&&es(E=>E+1),le(y),ze(!1)};return l.jsxs("main",{className:"app-shell",children:[l.jsxs("aside",{className:"tool-rail","aria-label":"LiveDesk tools",children:[l.jsx("div",{className:"rail-brand",title:"LiveDesk",children:l.jsx(CA,{size:25})}),l.jsx("nav",{className:"rail-tools",children:kA.map(y=>{const E=y.icon;return l.jsxs("button",{className:`rail-tool ${y.id==="sync-server"?"sync-server":""} ${Z===y.id?"active":""} accent-${y.accent}`,onClick:()=>y.id==="sync-server"?void Ma({takeover:!0,requestLocalAccess:!0}):gr(y.id),title:y.label,type:"button",children:[l.jsx(E,{size:19}),l.jsx("span",{children:y.label})]},y.id)})}),l.jsxs("div",{className:"rail-footer",children:[MA.map(y=>{const E=y.icon;return l.jsxs("button",{className:`rail-tool compact ${Z===y.id?"active":""} accent-${y.accent}`,onClick:()=>gr(y.id),title:y.label,type:"button",children:[l.jsx(E,{size:18}),l.jsx("span",{children:y.label})]},y.id)}),l.jsxs("button",{className:`rail-tool compact local-settings ${Xn?"active":""}`,onClick:()=>{le("settings"),Dt(!1),ze(!1),Ne(!1)},title:"Settings",type:"button",children:[l.jsx(lS,{size:18}),l.jsx("span",{children:"Settings"})]}),l.jsxs("button",{className:`rail-account ${a?"signed-in":""}`,onClick:()=>{Dt(y=>!y)},disabled:i||qe==="auth","aria-expanded":Oe,title:a?`Account: ${a.user.email||Ll}`:"Sign in with Google",type:"button",children:[a?Zs?l.jsx("img",{src:Zs,alt:Ll,referrerPolicy:"no-referrer"}):l.jsx("span",{className:"avatar-fallback",children:qc}):l.jsx(pm,{size:18}),l.jsx("span",{children:a?"Account":"Google"})]}),Oe&&l.jsxs("section",{className:"account-popover",role:"dialog","aria-label":"LiveDesk account",children:[l.jsxs("div",{className:"account-popover-head",children:[l.jsx("div",{className:"account-popover-avatar",children:a&&Zs?l.jsx("img",{src:Zs,alt:Ll,referrerPolicy:"no-referrer"}):a?l.jsx("span",{children:qc}):l.jsx(pm,{size:18})}),l.jsxs("div",{children:[l.jsx("strong",{children:a?Ll:"Account"}),l.jsx("p",{children:a?.user.email||"Not signed in"})]})]}),l.jsxs("dl",{className:"account-popover-facts",children:[l.jsx("dt",{children:"User"}),l.jsx("dd",{children:a?.user.email||"Not signed in"}),l.jsx("dt",{children:"Network"}),l.jsx("dd",{children:Hd}),l.jsx("dt",{children:"Access"}),l.jsx("dd",{children:$d}),l.jsx("dt",{children:"Plan"}),l.jsx("dd",{children:hr}),l.jsx("dt",{children:"Ads"}),l.jsx("dd",{children:At==="free"?"Standard banner":"Removed"})]}),a?l.jsxs("button",{className:"account-popover-action",onClick:Vs,disabled:qe==="auth",type:"button",children:[l.jsx(iS,{size:16}),"Logout"]}):l.jsxs("button",{className:"account-popover-action primary",onClick:bi,disabled:qe==="auth",type:"button",children:[l.jsx(pm,{size:16}),"Sign in with Google"]})]})]})]}),l.jsxs("section",{className:`desk-stage ${Yr&&!ke?"dock-open":""} ${Ye?"control-stage":""}`,children:[l.jsxs("header",{className:"topbar",children:[l.jsxs("div",{className:"brand",children:[l.jsx("span",{className:"brand-mark",children:l.jsx(nn,{size:18})}),l.jsxs("div",{children:[l.jsx("h1",{children:"LiveDesk"}),l.jsx("p",{children:"Control wall for local machines"})]})]}),Ha&&!Ye&&l.jsxs("div",{className:"file-share-top-route","aria-label":"File distribution route",children:[l.jsxs("div",{children:[l.jsx(Vo,{size:17}),l.jsxs("span",{children:[l.jsx("small",{children:"Source"}),l.jsx("strong",{children:"LiveDesk Hub"})]})]}),l.jsx(gh,{size:15}),l.jsx(rS,{size:16}),l.jsxs("div",{children:[l.jsx("span",{className:"file-share-top-route-laptops",children:"▣ ▣ ▣"}),l.jsxs("span",{children:[l.jsx("small",{children:"Destination"}),l.jsxs("strong",{children:[is," workstation",is===1?"":"s"]}),l.jsx("em",{children:Gn.trim()||"Desktop/LiveDeskFiles"})]})]})]}),Yr&&!Ye&&l.jsxs("div",{className:"top-actions",children:[l.jsx(Ov,{controller:Tc,onError:be}),l.jsx("span",{className:"top-actions-divider","aria-hidden":"true"}),l.jsx("div",{className:"segmented-control","aria-label":"Screen size",children:jA.map(y=>l.jsx("button",{className:Me===y.id?"active":"",onClick:()=>je(y.id),type:"button",children:y.label},y.id))})]}),Ye&&l.jsx("div",{className:"top-actions",children:l.jsx(Ov,{controller:Tc,onError:be})})]}),Zi?l.jsxs("section",{className:"doc-page",lang:ct,dir:ct==="ar"?"rtl":"ltr",children:[l.jsxs("section",{className:"doc-hero",children:[l.jsxs("div",{className:"doc-hero-copy",children:[l.jsxs("span",{className:"pricing-eyebrow",children:[l.jsx(Vm,{size:16}),Lt.eyebrow]}),l.jsx("h2",{children:Lt.title}),l.jsx("p",{children:Lt.intro})]}),l.jsxs("label",{className:"doc-language-picker",children:[l.jsxs("span",{children:[l.jsx(oS,{size:17}),Lt.languageLabel]}),l.jsx("select",{value:ct,onChange:y=>sn(y.target.value),children:NA.map(y=>l.jsx("option",{value:y.id,children:y.label},y.id))})]})]}),l.jsx("section",{className:"doc-grid",children:Lt.sections.map((y,E)=>{const G=[Ax,Ko,td,Sn,Jo][E]||Vm;return l.jsxs("article",{className:"doc-card",children:[l.jsx("div",{className:"doc-card-icon",children:l.jsx(G,{size:19})}),l.jsxs("div",{children:[l.jsx("h3",{children:y.title}),l.jsx("p",{children:y.body}),l.jsx("ul",{children:y.points.map(O=>l.jsx("li",{children:O},O))})]})]},y.title)})}),ia&&l.jsxs("section",{className:"doc-sync",children:[l.jsxs("div",{className:"doc-sync-head",children:[l.jsx(td,{size:20}),l.jsxs("div",{children:[l.jsx("h3",{children:ia.title}),l.jsx("p",{children:ia.body})]})]}),l.jsx("ul",{children:ia.points.map(y=>l.jsx("li",{children:y},y))})]}),l.jsxs("section",{className:"doc-firewall",children:[l.jsxs("div",{className:"doc-firewall-head",children:[l.jsx(Sn,{size:20}),l.jsxs("div",{children:[l.jsx("h3",{children:Lt.firewall.title}),l.jsx("p",{children:Lt.firewall.body})]})]}),l.jsx("ul",{children:Lt.firewall.points.map(y=>l.jsx("li",{children:y},y))})]}),l.jsxs("section",{className:"doc-command-panel",children:[l.jsxs("div",{className:"doc-command-head",children:[l.jsx(Ko,{size:20}),l.jsxs("div",{children:[l.jsx("h3",{children:Lt.commands.title}),l.jsx("p",{children:Lt.commands.body})]})]}),l.jsxs("div",{className:"doc-command-list",children:[Lt.commands.manager&&l.jsxs("div",{className:"doc-command-row",children:[l.jsx("span",{children:Lt.commands.manager}),l.jsx("code",{children:Nl}),l.jsx("button",{className:"icon-button",onClick:()=>qi(Nl),title:"Copy command",type:"button",children:l.jsx(Bi,{size:16})})]}),l.jsxs("div",{className:"doc-command-row",children:[l.jsx("span",{children:Lt.commands.primary}),l.jsx("code",{children:$n}),l.jsx("button",{className:"icon-button",onClick:()=>qi($n),title:"Copy command",type:"button",children:l.jsx(Bi,{size:16})})]}),l.jsxs("div",{className:"doc-command-row",children:[l.jsx("span",{children:Lt.commands.slot}),l.jsx("code",{children:`${$n} 3`}),l.jsx("button",{className:"icon-button",onClick:()=>qi(`${$n} 3`),title:"Copy command",type:"button",children:l.jsx(Bi,{size:16})})]})]})]})]}):Bs?l.jsx(fM,{hubUrl:C,devices:j}):Ha?l.jsx(pk,{hubUrl:C,devices:Ke,localFeatureAccess:Xt,upgradeNotice:bl,notice:ye,remoteDirectory:Gn,onRemoteDirectoryChange:ii,targetMode:ls,selectedTargetIds:mn,onTargetModeChange:Nd,onTargetToggle:y=>oi(E=>E.includes(y)?E.filter(_=>_!==y):[...E,y]),filePickerRef:Rd,folderPickerRef:Cc,onBrowserFileImport:y=>{ea(y)},onBrowserFolderImport:y=>{ea(y)},onNotice:be,onTransferChange:y=>{if(!y){Kt(null);return}const E=y.state==="failed"||y.state==="partially-failed"||y.state==="cancelled"?"failed":y.state==="completed"?"queued":y.state==="sending"?"sending":"reading";Kt({id:y.id,status:E,progress:y.progress,message:y.message}),["completed","partially-failed","failed","cancelled"].includes(y.state)&&window.setTimeout(()=>Kt(_=>_?.id===y.id?null:_),4500)}}):Xn?l.jsx(L0,{hubUrl:C,pin:l.jsxs(z0,{children:[(M||c||B||ye)&&l.jsx("section",{className:"notice-band",children:M||c||B||ye}),l.jsxs("div",{className:"settings-section-grid",children:[l.jsxs("section",{className:"settings-section-card settings-pairing-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Pair a workstation"}),l.jsx("h3",{children:"Connect another local PC"})]}),l.jsx(an,{size:20})]}),l.jsxs("div",{className:"settings-pin-display",children:[l.jsx("span",{children:"Hub PIN"}),l.jsx("strong",{children:Ht}),l.jsxs("button",{className:"text-button ghost compact",onClick:ao,disabled:!k?.started||qe==="pin",type:"button",children:[l.jsx(oc,{size:15}),qe==="pin"?"Creating":"New PIN"]})]})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Hub status"}),l.jsx("h3",{children:mr})]}),l.jsx("span",{className:`settings-status-dot state-${mr}`})]}),l.jsxs("dl",{className:"settings-facts",children:[l.jsx("dt",{children:"Address"}),l.jsx("dd",{children:C||"-"}),l.jsx("dt",{children:"Connected workstations"}),l.jsxs("dd",{children:[dr,"/",Fs]}),l.jsx("dt",{children:"Sync access"}),l.jsx("dd",{children:k?.started?"Local app ready":"Start Hub first"}),l.jsx("dt",{children:"Plan"}),l.jsx("dd",{children:hr})]}),l.jsxs("div",{className:"settings-action-row",children:[l.jsxs("button",{className:"text-button primary",onClick:()=>Ma({takeover:!0,requestLocalAccess:!0}),disabled:!a||qe==="host",type:"button",children:[l.jsx(td,{size:16}),"Sync access"]}),l.jsxs("button",{className:"text-button buy",onClick:()=>Nn(At==="ltd"?"pro":"ltd"),disabled:qe==="checkout"||At==="pro",type:"button",children:[l.jsx(Wo,{size:16}),mo]})]})]})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"File transfer"}),l.jsx("h3",{children:"Client destination folder"})]}),l.jsx(nc,{size:20})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Remote folder"}),l.jsx("input",{value:Gn,onChange:y=>ii(y.target.value),placeholder:"Desktop/LiveDeskFiles"})]}),l.jsx("p",{className:"settings-help",children:"Blank uses Desktop/LiveDeskFiles on each workstation."})]})]}),wall:l.jsx(_0,{children:l.jsxs("div",{className:"settings-section-grid",children:[l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Wall stream"}),l.jsx("h3",{children:"Frame delivery"})]}),l.jsx(cc,{size:20})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Frame mode"}),l.jsx("select",{value:Te.frameMode,onChange:y=>xn({frameMode:uh(y.target.value)}),children:id.map(y=>l.jsxs("option",{value:y.id,children:[y.label," - ",y.detail]},y.id))})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"H.264 decode"}),l.jsx("select",{value:Te.h264DecodeAcceleration,onChange:y=>xn({h264DecodeAcceleration:vd(y.target.value)}),children:ch.map(y=>l.jsx("option",{value:y.id,children:y.label},y.id))})]}),l.jsxs("div",{className:"settings-field-grid",children:[l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"FPS"}),l.jsx("select",{value:Te.fps,onChange:y=>xn({fps:fh(y.target.value,Te.frameMode)}),children:Oh.filter(y=>y<=vw(Te.frameMode)).map(y=>l.jsx("option",{value:y,children:y},y))})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:lt?"Atlas tile":"Resolution"}),l.jsx("select",{value:lt?Ri:ho,onChange:y=>lt?Ud(y.target.value):zl(y.target.value),children:(lt?Fm:rd).map(y=>l.jsx("option",{value:y.id,children:y.label},y.id))})]})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Quality"}),l.jsx("select",{value:Te.quality,onChange:y=>xn({quality:Qa(y.target.value,20,95,ha.quality)}),children:Yv.map(y=>l.jsx("option",{value:y,children:y},y))})]})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Wall behavior"}),l.jsx("h3",{children:"Visibility and load"})]}),l.jsx(nn,{size:20})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:Te.autoStartLive,onChange:y=>xn({autoStartLive:y.target.checked})}),l.jsx("span",{children:"Auto live on connected screens"})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:Te.visibleOnlyLive,onChange:y=>xn({visibleOnlyLive:y.target.checked})}),l.jsx("span",{children:"Stream visible tiles first"})]}),!lt&&l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:Te.adaptiveSizeByWall,onChange:y=>xn({adaptiveSizeByWall:y.target.checked})}),l.jsx("span",{children:"Fit stream size to Wall"})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:Te.adaptiveLoadShedding,onChange:y=>xn({adaptiveLoadShedding:y.target.checked})}),l.jsx("span",{children:"Reduce FPS under load"})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:Te.showScreenStatus,onChange:y=>xn({showScreenStatus:y.target.checked})}),l.jsx("span",{children:"Screen status overlay"})]}),l.jsxs("div",{className:"settings-summary",children:[l.jsx("span",{children:po.label}),l.jsxs("strong",{children:[Zt.maxWidth,"x",Zt.maxHeight," / ",Gt,"fps"]})]}),l.jsxs("button",{className:"settings-reset",onClick:()=>za(ha),type:"button",children:[l.jsx(tc,{size:15})," Reset Wall settings"]})]})]})}),control:l.jsx(O0,{children:l.jsxs("div",{className:"settings-section-grid",children:[l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Control stream"}),l.jsx("h3",{children:"Low-latency delivery"})]}),l.jsx(ed,{size:20})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Frame mode"}),l.jsx("select",{value:Xe.frameMode,onChange:y=>Js({frameMode:dh(y.target.value)}),children:YM.map(y=>l.jsx("option",{value:y.id,children:y.label},y.id))})]}),Xe.frameMode==="mode3-h264-hw"&&l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"H.264 decode"}),l.jsx("select",{value:Xe.h264DecodeAcceleration,onChange:y=>Js({h264DecodeAcceleration:vd(y.target.value)}),children:ch.map(y=>l.jsx("option",{value:y.id,children:y.label},y.id))})]}),l.jsxs("div",{className:"settings-field-grid",children:[l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"FPS"}),l.jsx("select",{value:Xe.fps,onChange:y=>Js({fps:Qa(y.target.value,20,60,pa.fps)}),children:VM.filter(y=>Xe.frameMode==="mode3-h264-hw"||y<=30).map(y=>l.jsx("option",{value:y,children:y},y))})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Resolution"}),l.jsx("select",{value:Ei,onChange:y=>Pd(y.target.value),children:Bm.filter(y=>Xe.frameMode==="mode3-h264-hw"||y.width<=1920).map(y=>l.jsx("option",{value:y.id,children:y.label},y.id))})]})]}),Xe.frameMode==="mode3-h264-hw"&&l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Quality"}),l.jsx("select",{value:Xe.quality,onChange:y=>Js({quality:Qa(y.target.value,20,95,pa.quality)}),children:Yv.map(y=>l.jsx("option",{value:y,children:y},y))})]})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Control behavior"}),l.jsx("h3",{children:"Session display"})]}),l.jsx(an,{size:20})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:Xe.showScreenStatus,onChange:y=>Js({showScreenStatus:y.target.checked})}),l.jsx("span",{children:"Screen status overlay"})]}),l.jsxs("div",{className:"settings-summary control",children:[l.jsx("span",{children:Xe.frameMode==="mode5-lzo-delta"?"Mode 5 tile delta":"Mode 3 H.264"}),l.jsxs("strong",{children:[$a.maxWidth,"x",$a.maxHeight," / ",Ca,"fps"]})]}),l.jsxs("button",{className:"settings-reset",onClick:()=>_a(pa),type:"button",children:[l.jsx(tc,{size:15})," Reset Control settings"]})]})]})}),agent:l.jsx(I0,{hubUrl:C}),captureGallery:l.jsx(vM,{hubUrl:C,onToast:be}),advancedExtras:l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Connection commands"}),l.jsx("h3",{children:"Developer setup"})]}),l.jsx(Bi,{size:20})]}),l.jsxs("div",{className:"settings-command-list",children:[l.jsxs("div",{className:"settings-command-row",children:[l.jsx("span",{children:"Client"}),l.jsx("code",{children:$n}),l.jsx("button",{className:"icon-button",onClick:()=>qi($n),title:"Copy client command",type:"button",children:l.jsx(Bi,{size:16})})]}),l.jsxs("div",{className:"settings-command-row",children:[l.jsx("span",{children:"Slot example"}),l.jsx("code",{children:`${$n} 3`}),l.jsx("button",{className:"icon-button",onClick:()=>qi(`${$n} 3`),title:"Copy slot command",type:"button",children:l.jsx(Bi,{size:16})})]}),l.jsxs("div",{className:"settings-command-row",children:[l.jsx("span",{children:"Hub"}),l.jsx("code",{children:Nl}),l.jsx("button",{className:"icon-button",onClick:()=>qi(Nl),title:"Copy Hub command",type:"button",children:l.jsx(Bi,{size:16})})]})]})]})}):Xi?l.jsxs("section",{className:"pricing-page",children:[l.jsxs("header",{className:"pricing-header",children:[l.jsxs("div",{children:[l.jsxs("span",{className:"pricing-eyebrow",children:[l.jsx(Ym,{size:15})," LiveDesk plans"]}),l.jsx("h2",{children:"Choose the plan that fits your wall"}),l.jsx("p",{children:"Start free with a local screen wall. Upgrade when you need ad-free monitoring, more workstations, or commercial controls."})]}),l.jsx("button",{className:"pricing-close",onClick:()=>gr("wall"),title:"Close pricing",type:"button",children:l.jsx(Hr,{size:18})})]}),(B||ye)&&l.jsx("section",{className:"notice-band",children:B||ye}),l.jsxs("div",{className:"pricing-status","aria-live":"polite",children:[l.jsx("span",{children:"Current plan"}),l.jsx("strong",{children:Ac.name}),l.jsxs("small",{children:[Ke.length,"/",GM(er)," connected devices"]})]}),l.jsxs("div",{className:"pricing-cards","aria-label":"LiveDesk plans",children:[l.jsxs("article",{className:`pricing-plan-card ${At==="free"?"current":""}`,children:[l.jsxs("div",{className:"pricing-plan-topline",children:[l.jsx("span",{className:"pricing-plan-badge free",children:"Free"}),l.jsx("strong",{children:"$0"})]}),l.jsx("p",{className:"pricing-plan-audience",children:$i.free.audience}),l.jsx("h3",{children:"Monitor your local wall"}),l.jsx("p",{children:$i.free.note}),l.jsxs("ul",{children:[l.jsxs("li",{children:[l.jsx(qn,{size:16})," Up to ",Qo," devices"]}),l.jsxs("li",{children:[l.jsx(qn,{size:16})," Live view and local control"]}),l.jsxs("li",{children:[l.jsx(qn,{size:16})," Standard ad-supported banner"]})]}),l.jsx("span",{className:"pricing-current-label",children:At==="free"?"Current plan":"Included for everyone"})]}),l.jsxs("article",{className:`pricing-plan-card featured ${At==="ltd"?"current":""}`,children:[l.jsxs("div",{className:"pricing-plan-topline",children:[l.jsxs("span",{className:"pricing-plan-badge plus",children:[l.jsx(cS,{size:14})," Plus"]}),l.jsx("strong",{children:"$5"})]}),l.jsx("p",{className:"pricing-plan-audience",children:$i.ltd.audience}),l.jsx("h3",{children:"Ad-free monitoring"}),l.jsx("p",{children:"More room for personal AI workstations without the standard banner."}),l.jsxs("ul",{children:[l.jsxs("li",{children:[l.jsx(qn,{size:16})," Up to ",Xo," devices"]}),l.jsxs("li",{children:[l.jsx(qn,{size:16})," No standard ad banner"]}),l.jsxs("li",{children:[l.jsx(qn,{size:16})," ",$i.ltd.ltd]})]}),l.jsxs("button",{className:"pricing-plan-button",onClick:a?()=>Nn("ltd"):bi,disabled:At!=="free"||qe==="checkout"||qe==="auth"||i||H,type:"button",children:[l.jsx(Wo,{size:16}),At==="free"?a?"Choose Plus":"Sign in for Plus":"Plus active"]})]}),l.jsxs("article",{className:`pricing-plan-card pro ${At==="pro"?"current":""}`,children:[l.jsxs("div",{className:"pricing-plan-topline",children:[l.jsxs("span",{className:"pricing-plan-badge pro",children:[l.jsx(Sn,{size:14})," Pro"]}),l.jsx("strong",{children:"$15"})]}),l.jsx("p",{className:"pricing-plan-audience",children:$i.pro.audience}),l.jsx("h3",{children:"For serious operations"}),l.jsx("p",{children:"Commercial-ready monitoring for larger AI labs, studios, and teams."}),l.jsxs("ul",{children:[l.jsxs("li",{children:[l.jsx(qn,{size:16})," 30+ workstation walls"]}),l.jsxs("li",{children:[l.jsx(qn,{size:16})," Commercial use included"]}),l.jsxs("li",{children:[l.jsx(qn,{size:16})," ",$i.pro.ltd]})]}),l.jsxs("button",{className:"pricing-plan-button",onClick:a?()=>Nn("pro"):bi,disabled:At==="pro"||qe==="checkout"||qe==="auth"||i||H,type:"button",children:[l.jsx(Wo,{size:16}),At==="pro"?"Pro active":a?"Choose Pro":"Sign in for Pro"]})]})]}),l.jsxs("section",{className:"pricing-includes",children:[l.jsxs("div",{children:[l.jsx(an,{size:17}),l.jsx("span",{children:"Screen wall"}),l.jsx("strong",{children:"120+ slots"})]}),l.jsxs("div",{children:[l.jsx(ed,{size:17}),l.jsx("span",{children:"Focused control"}),l.jsx("strong",{children:"Local-first"})]}),l.jsxs("div",{children:[l.jsx(Nx,{size:17}),l.jsx("span",{children:"Remote audio"}),l.jsx("strong",{children:"Available"})]}),l.jsxs("div",{children:[l.jsx(nc,{size:17}),l.jsx("span",{children:"File transfer"}),l.jsx("strong",{children:"Included"})]})]}),l.jsxs("p",{className:"pricing-note",children:[l.jsx(qn,{size:15})," Commercial use requires Pro. Plus LTD is for personal, creator, and homelab use."]}),l.jsxs("button",{className:"pricing-primary-cta",onClick:a?()=>Nn(At==="ltd"?"pro":"ltd"):bi,disabled:Xs,type:"button",children:[l.jsx(Wo,{size:18}),pr]})]}):l.jsx(l.Fragment,{children:l.jsxs("section",{className:`monitor-layout ${ke?"dock-collapsed":""}`,children:[l.jsxs("section",{ref:Gr,className:`screen-wall-panel ${vc?"drop-active":""}`,onClick:y=>{y.currentTarget===y.target&&Al()},onDragEnter:y=>{y.preventDefault(),qr(!0)},onDragOver:y=>{y.preventDefault(),y.dataTransfer.dropEffect="copy"},onDragLeave:y=>{y.currentTarget===y.target&&qr(!1)},onDrop:ur,children:[lt&&l.jsx("canvas",{ref:Dc,className:"atlas-source-canvas",width:ja?.width||1920,height:ja?.height||1080,"aria-hidden":"true"}),Ye?l.jsx("section",{className:"control-focus",children:l.jsxs("div",{className:"control-wall",children:[Ae&&ji.length>1&&l.jsx("div",{className:"control-monitor-tabs","aria-label":"Select monitor",children:ji.map(y=>l.jsxs("button",{className:y.index===Ci?"active":"",onClick:()=>Fd(Ae.deviceId,y.index),title:oA(y),type:"button",children:[l.jsx("span",{children:y.name||`Display ${y.index+1}`}),y.width>0&&y.height>0&&l.jsxs("small",{children:[y.width,"x",y.height]})]},y.index))}),Ae?l.jsx(Gm,{device:Ae,frame:Ce,selected:!1,controlEnabled:cs&&me,showStatus:Xe.showScreenStatus,monitorIndex:Pn(Je[Ae.deviceId],Bn(Ae)),monitorCount:Bn(Ae),onSelect:()=>{},onFocusDevice:()=>Q(Ae.deviceId),onOpenControl:()=>lo(Ae.deviceId),onCycleMonitor:y=>or(Ae.deviceId,y),onCanvasReady:Id,sendInput:kl,presentationReady:Tt},Ae.deviceId):l.jsxs("div",{className:"control-empty",children:[l.jsx(an,{size:30}),l.jsx("strong",{children:"No workstation"}),l.jsx("span",{children:"Open a workstation from the Wall."})]}),Ae&&!Tt&&l.jsxs("div",{className:"control-connection-overlay",role:"status","aria-live":"polite",children:[R!=="error"&&l.jsx("span",{className:"control-connection-spinner","aria-hidden":"true"}),l.jsx("strong",{children:R==="error"?"Connection failed":"Connecting"}),l.jsx("small",{children:R==="error"?ks||ie?`Control stream: ${ks||ie}`:"No control frame was received. Reopen Control to retry.":ks||ie?`Control stream: ${ks||ie}`:Jr==="open"?"Preparing the first control frame":"Opening the Control stream"})]})]})}):lt?l.jsx("div",{className:`screen-wall atlas-slot-wall size-${Me}`,onClick:y=>{y.currentTarget===y.target&&Al()},children:vl.map((y,E)=>y?l.jsx(Gm,{device:y,frame:xi.get(y.deviceId),selected:rs.has(y.deviceId),controlEnabled:!1,showStatus:Te.showScreenStatus,monitorIndex:Pn(Je[y.deviceId],Bn(y)),monitorCount:Bn(y),onSelect:()=>Ms(y.deviceId),onFocusDevice:()=>Ks(y.deviceId),onOpenControl:()=>lo(y.deviceId),onCycleMonitor:_=>or(y.deviceId,_),onCanvasReady:Lc,sendInput:kl},y.deviceId):l.jsx(ty,{index:E},`slot-${E}`))}):l.jsx("div",{className:`screen-wall size-${Me}`,onClick:y=>{y.currentTarget===y.target&&Al()},children:vl.map((y,E)=>y?l.jsx(Gm,{device:y,frame:xi.get(y.deviceId),selected:rs.has(y.deviceId),controlEnabled:cs&&me&&Ae?.deviceId===y.deviceId,showStatus:Te.showScreenStatus,monitorIndex:Pn(Je[y.deviceId],Bn(y)),monitorCount:Bn(y),onSelect:()=>Ms(y.deviceId),onFocusDevice:()=>Ks(y.deviceId),onOpenControl:()=>lo(y.deviceId),onCycleMonitor:_=>or(y.deviceId,_),onCanvasReady:Od,sendInput:kl},y.deviceId):l.jsx(ty,{index:E},`slot-${E}`))}),l.jsx(RA,{visible:Ld&&!Ye})]}),!Xn&&l.jsxs("aside",{className:`right-dock actions-mode ${ke?"collapsed":""}`,"aria-label":"LiveDesk tools",children:[l.jsx("button",{className:"dock-toggle",onClick:()=>Ne(y=>!y),"aria-label":ke?"Show control panel":"Hide control panel",title:ke?"Show control panel":"Hide control panel",type:"button",children:ke?l.jsx(ry,{size:18}):l.jsx(xh,{size:18})}),!ke&&l.jsxs(l.Fragment,{children:[l.jsxs("section",{className:"action-dock",children:[l.jsxs("div",{className:"action-context",children:[l.jsx("span",{children:Ye?"Control target":Ya>0?"Selection":"No selection"}),l.jsx("strong",{children:hs})]}),l.jsx("input",{ref:Is,className:"hidden-file-input",type:"file",multiple:!0,onChange:y=>{y.currentTarget.files&&cr(y.currentTarget.files),y.currentTarget.value=""}}),(M||ye)&&l.jsx("div",{className:"notice-band compact",children:l.jsx("span",{children:M||ye})}),l.jsxs("div",{className:"action-grid",children:[l.jsxs("button",{className:"action-tile primary",onClick:()=>Ae&&Ic(Ae.deviceId),disabled:!Wr,type:"button",children:[l.jsx(Tx,{size:21}),l.jsx("span",{children:"Live"})]}),l.jsxs("button",{className:`action-tile ${me?"active":""}`,onClick:()=>ze(y=>!y),disabled:!cs,title:Ji?"Allow Accessibility for the terminal app that starts LiveDesk, then restart the Mac client.":cs?"Remote keyboard and mouse control":"Remote control is not available on this workstation",type:"button",children:[l.jsx(ed,{size:21}),l.jsx("span",{children:vi!=="idle"?vi:"Control"})]}),l.jsxs("button",{className:`action-tile ${Pe?"active":""}`,onClick:Bc,disabled:!Nc,type:"button",title:wl?"Remote PC audio":"Remote audio is not supported by this workstation yet",children:[l.jsx(Nx,{size:21}),l.jsx("span",{children:Pe&&no!=="idle"?no:"Audio"})]}),l.jsxs("button",{className:"action-tile",onClick:()=>Is.current?.click(),disabled:!Xt||(Ye?!Ae:Zn.length===0),type:"button",title:"File transfer",children:[l.jsx(nc,{size:21}),l.jsx("span",{children:"Files"})]}),l.jsxs("button",{className:"action-tile",disabled:!0,type:"button",title:"Reboot",children:[l.jsx(tc,{size:21}),l.jsx("span",{children:"Reboot"})]}),l.jsxs("button",{className:"action-tile",disabled:!0,type:"button",title:"Power",children:[l.jsx(uS,{size:21}),l.jsx("span",{children:"Power"})]}),l.jsxs("button",{className:"action-tile",disabled:!0,type:"button",title:"Terminal",children:[l.jsx(Ko,{size:21}),l.jsx("span",{children:"Shell"})]})]})]}),Ae&&Jn&&l.jsxs("section",{className:"side-panel selected-panel",children:[l.jsxs("div",{className:"machine-detail-head",children:[l.jsxs("div",{className:"panel-title",children:[l.jsx(an,{size:17}),l.jsx("h2",{children:"Machine detail"})]}),l.jsx("span",{className:`machine-health state-${Jn.state}`,children:Jn.label})]}),l.jsxs("div",{className:"machine-title",children:[l.jsx("strong",{children:Yi(Ae)}),l.jsx("span",{children:Jn.role})]}),l.jsx("div",{className:"machine-metric-grid",children:Jn.metrics.map(y=>l.jsxs("article",{className:`machine-metric state-${y.state}`,children:[l.jsx("span",{children:y.label}),l.jsx("strong",{children:y.value}),l.jsx("small",{children:y.detail}),y.ratio!==void 0&&l.jsx("i",{children:l.jsx("b",{style:{width:`${Math.round(y.ratio*100)}%`}})})]},y.id))}),l.jsxs("section",{className:"machine-section",children:[l.jsxs("div",{className:"machine-section-title",children:[l.jsx(nn,{size:15}),l.jsx("span",{children:"Stream"})]}),l.jsxs("dl",{className:"facts compact",children:[l.jsx("dt",{children:"Frames"}),l.jsx("dd",{children:Fc}),l.jsx("dt",{children:Ye?"Control RX":lt?"Atlas RX":"Wall RX"}),l.jsx("dd",{children:Ni}),l.jsx("dt",{children:"Painted"}),l.jsx("dd",{children:co}),l.jsx("dt",{children:Ye?"Encoded changes":"Visual samples"}),l.jsx("dd",{children:Hc}),l.jsx("dt",{children:"Decoder"}),l.jsx("dd",{children:na}),l.jsx("dt",{children:"Decoder IO"}),l.jsx("dd",{children:fr}),l.jsx("dt",{children:"Canvas"}),l.jsx("dd",{children:ki}),l.jsx("dt",{children:"Control buffer"}),l.jsx("dd",{children:aa}),l.jsx("dt",{children:"Browser RAF"}),l.jsx("dd",{children:sa}),l.jsx("dt",{children:"Latency"}),l.jsx("dd",{children:El}),l.jsx("dt",{children:"Cadence"}),l.jsx("dd",{children:Dl}),l.jsx("dt",{children:"Source send"}),l.jsx("dd",{children:qa}),l.jsx("dt",{children:"Packet mix"}),l.jsx("dd",{children:As}),l.jsx("dt",{children:"Receive gap"}),l.jsx("dd",{children:Ga}),l.jsx("dt",{children:"Paint gap"}),l.jsx("dd",{children:fs}),l.jsx("dt",{children:"Seq gap"}),l.jsx("dd",{children:$c}),l.jsx("dt",{children:"Selected"}),l.jsx("dd",{children:Pc}),l.jsx("dt",{children:"Requested"}),l.jsx("dd",{children:Uc}),l.jsx("dt",{children:"Mode"}),l.jsx("dd",{children:Mi}),l.jsx("dt",{children:"Chunk"}),l.jsx("dd",{children:kt}),l.jsx("dt",{children:"Size"}),l.jsx("dd",{children:gn}),l.jsx("dt",{children:"Native"}),l.jsx("dd",{children:ro}),l.jsx("dt",{children:"Monitor"}),l.jsx("dd",{children:it}),l.jsx("dt",{children:"Source"}),l.jsx("dd",{children:Ns}),l.jsx("dt",{children:"Input"}),l.jsx("dd",{children:la}),l.jsx("dt",{children:"Audio"}),l.jsx("dd",{children:Ts}),Ye&&l.jsxs(l.Fragment,{children:[l.jsx("dt",{children:"Visual feedback"}),l.jsx("dd",{children:uo})]})]})]}),l.jsxs("section",{className:"machine-section",children:[l.jsxs("div",{className:"machine-section-title",children:[l.jsx(Ko,{size:15}),l.jsx("span",{children:"Local services"})]}),l.jsx("div",{className:"tool-probe-list",children:Jn.tools.map(y=>l.jsxs("span",{className:`tool-probe state-${y.status}`,children:[l.jsx("b",{children:y.label}),l.jsx("em",{children:y.detail})]},y.id))})]}),l.jsxs("section",{className:"machine-section",children:[l.jsxs("div",{className:"machine-section-title",children:[l.jsx(cd,{size:15}),l.jsx("span",{children:"Workload"})]}),l.jsxs("div",{className:"workload-card",children:[l.jsx("strong",{children:Jn.taskLabel}),l.jsx("span",{children:Jn.taskStatus}),Jn.taskSummary&&l.jsx("p",{children:Jn.taskSummary})]})]}),l.jsxs("div",{className:"machine-section",children:[l.jsxs("div",{className:"machine-section-title",children:[l.jsx(Ax,{size:15}),l.jsx("span",{children:"System"})]}),l.jsxs("dl",{className:"facts compact",children:[l.jsx("dt",{children:"Platform"}),l.jsxs("dd",{children:[Ae.platform||"-"," ",Ae.arch||""]}),l.jsx("dt",{children:"Release"}),l.jsx("dd",{children:ga(Ae.status,"release")||"-"}),l.jsx("dt",{children:"Uptime"}),l.jsx("dd",{children:Sw(Bt(Ae.status,"uptimeSec"))}),l.jsx("dt",{children:"Last seen"}),l.jsx("dd",{children:Jm(Ae.lastSeenAt||Ae.connectedAt)}),l.jsx("dt",{children:"Agent"}),l.jsx("dd",{children:Ae.agentVersion||"-"}),l.jsx("dt",{children:"Address"}),l.jsx("dd",{children:Ae.remoteAddress||"-"})]})]}),Ml&&l.jsx("p",{className:"panel-warning",children:Ml}),l.jsxs("button",{className:"text-button full",onClick:()=>Ae&&Ic(Ae.deviceId),disabled:!Wr,type:"button",children:[l.jsx(Tx,{size:16}),"Start live"]})]})]})]})]})})]}),Mn&&l.jsxs("aside",{className:`transfer-bar state-${Mn.status}`,"aria-live":"polite",children:[l.jsx("span",{className:"transfer-bar-icon","aria-hidden":"true",children:Mn.status==="queued"?l.jsx(qn,{size:18}):Mn.status==="failed"?l.jsx(Hr,{size:18}):l.jsx(ay,{size:18})}),l.jsxs("div",{className:"transfer-bar-copy",children:[l.jsx("p",{children:Mn.message}),l.jsx("div",{className:"transfer-bar-track",children:l.jsx("span",{style:{width:`${Math.max(0,Math.min(100,Mn.progress))}%`}})})]}),l.jsxs("strong",{children:[Math.max(0,Math.min(100,Mn.progress)),"%"]})]})]})}vS.createRoot(document.getElementById("root")).render(l.jsx(f.StrictMode,{children:l.jsx(EA,{})}));
|
|
15
|
+
`)}`:h}return r.length>0?`${i.length}대 완료, ${r.length}대 실패했습니다.`:`${i.length}대 작업이 완료되었습니다.`}const dM={read:"allow",processControl:"ask",serviceControl:"ask",applicationControl:"ask",fileRead:"ask",fileWrite:"ask",fileDelete:"ask",shell:"ask",script:"ask",softwareInstall:"ask",network:"ask",systemPower:"ask",systemConfiguration:"ask",userAccount:"deny"};function fM(n){return n==="safe-auto"?"Safe Auto":n==="full-access"?"Full Access":n==="custom"?"Custom":"Ask"}function mM(n){return n.replace(/([A-Z])/g," $1").replace(/^./,a=>a.toUpperCase())}function hM({hubUrl:n,devices:a}){const[i,r]=f.useState("all"),[c,d]=f.useState([]),[h,p]=f.useState(""),[x,g]=f.useState([]),[w,v]=f.useState(""),[b,k]=f.useState(""),[j,M]=f.useState(""),[T,C]=f.useState("safe-auto"),[A]=f.useState("custom-default"),[D,H]=f.useState(dM),[B,q]=f.useState([]),[L,F]=f.useState(""),[ue,W]=f.useState(!1),[ce,Q]=f.useState(null),[se,oe]=f.useState(!1),[K,z]=f.useState(""),[Y,U]=f.useState(!1),R=f.useRef(null),J=f.useRef(new Set),he=f.useRef(new Set),$=f.useRef(new Set),ie=f.useMemo(()=>a.filter(Z=>Z.connected).map(Z=>Z.deviceId),[a]),we=f.useMemo(()=>$k(aw,a,i,c,T,D),[D,a,T,c,i]),me=f.useCallback(Z=>{const le=Wu(Z,a);if(g(Me=>Me.map(je=>je.type==="task"&&je.batchId===Z.batchId?{...je,states:cM(je.states,le),status:Z.status}:je)),!["running","queued"].includes(Z.status)&&!J.current.has(Z.batchId)){J.current.add(Z.batchId);const Me=Hi("agent-summary");g(je=>[...je,{type:"agent",id:Me,text:uM(Z,le)}]),Z.operation&&sM(n,{instruction:Z.instructionPreview,operation:Z.operation,total:le.length,completed:le.filter(je=>je.status==="completed").length,failed:le.filter(je=>je.status==="failed").length,results:le.map(je=>({deviceName:je.deviceName,status:je.status,result:je.result,error:je.error}))}).then(je=>{!je.ok||!je.summary||g(ct=>ct.map(sn=>sn.type==="agent"&&sn.id===Me?{...sn,text:je.summary}:sn))}).catch(()=>{}),v(je=>je===Z.batchId?"":je)}},[a,n]),ze=f.useCallback(async Z=>{const le=await iM(n,Z);return me(le),le},[n,me]),Pe=f.useCallback((Z,le)=>{$.current.has(Z.batchId)||($.current.add(Z.batchId),g(Me=>[...Me,{type:"task",id:Hi("task"),batchId:Z.batchId,agentRunId:le,operation:Z.operation||"diagnostics.collect",instruction:Z.instructionPreview,states:Wu(Z,a),status:Z.status}])),me(Z)},[a,me]),de=f.useCallback(async Z=>{const le=await Zk(n,Z);for(const Me of le.taskBatches||[])Pe(Me,Z);if(q(le.approvals||[]),!["running","queued","waiting-approval"].includes(le.status)&&!he.current.has(Z)){he.current.add(Z);const Me=le.finalResponse?.trim()||(le.status==="cancelled"?"Codex 작업을 취소했습니다.":le.error?`Codex 작업이 완료되지 않았습니다: ${le.error}`:"Codex 작업이 완료되었습니다.");g(je=>[...je,{type:le.status==="failed"?"error":"agent",id:Hi("agent-run-result"),text:Me}])}return le},[Pe,n]);f.useEffect(()=>{if(!w)return;let Z=!0;const le=async()=>{try{const je=await ze(w);Z&&!["running","queued"].includes(je.status)&&v("")}catch(je){Z&&z(je instanceof Error?je.message:String(je))}};le();const Me=window.setInterval(()=>{le()},800);return()=>{Z=!1,window.clearInterval(Me)}},[w,ze]),f.useEffect(()=>{if(!b)return;let Z=!0;const le=async()=>{try{const je=await de(b);Z&&!["running","queued","waiting-approval"].includes(je.status)&&(k(""),oe(!1))}catch(je){Z&&z(je instanceof Error?je.message:String(je))}};le();const Me=window.setInterval(()=>{le()},800);return()=>{Z=!1,window.clearInterval(Me)}},[b,de]);const He=async(Z="",le,Me=!1)=>{const je=(Z||h).trim();if(!je||w||b)return;let ct=Ck(je);const sn=le||(i==="all"?ie:c.filter(Ne=>ie.includes(Ne)));if(sn.length===0){z("Select at least one connected workstation.");return}if(T==="full-access"&&!se&&!Me){Q({instruction:je,targetIds:sn});return}if(g(Ne=>[...Ne,{type:"user",id:Hi("user"),text:je}]),p(""),U(!1),z(""),(i==="all"?ie:c.filter(Ne=>ie.includes(Ne))).length===0){g(Ne=>[...Ne,{type:"error",id:Hi("no-targets"),text:"연결된 대상 장비를 하나 이상 선택해 주세요."}]);return}if(!ct){try{if(T==="custom"){const Oe=await aM(n,A,D);if(!Oe.ok)throw new Error(Oe.error||"Custom Agent policy could not be saved.")}const Ne=await Xk(n,{instruction:je,deviceIds:sn,permissionMode:T,customPolicyId:A});if(!Ne.ok||!Ne.runId)throw new Error(Ne.error||"Codex Agent run could not be started.");q(Ne.approvals||[]),k(Ne.runId);return}catch(Ne){try{const Oe=await Qk(n,je);Oe.ok&&Oe.plan&&(ct={operation:Oe.plan.operation,query:Oe.plan.targetQuery})}catch{g(Oe=>[...Oe,{type:"error",id:Hi("unsupported"),text:Ne instanceof Error?Ne.message:jk}])}}if(!ct)return}try{const Ne=await lM(n,{instruction:je,deviceIds:sn,operation:ct.operation,targetQuery:ct.query});if(!Ne.ok||!Ne.batch||!Ne.batchId)throw new Error(Ne.error||"작업을 만들지 못했습니다.");const Oe={type:"task",id:Hi("task"),batchId:Ne.batchId,operation:ct.operation,instruction:je,states:Wu(Ne.batch,a),status:Ne.batch.status};$.current.add(Ne.batchId),g(Dt=>[...Dt,Oe]),v(Ne.batchId)}catch(Ne){z(Ne instanceof Error?Ne.message:String(Ne))}},Le=async(Z,le)=>{F(Z.approvalId);try{const Me=await tM(n,Z.runId,Z.approvalId,le);if(!Me.ok)throw new Error(Me.error||"Agent approval could not be applied.");await de(Z.runId)}catch(Me){z(Me instanceof Error?Me.message:String(Me))}finally{F("")}},Fe=async Z=>{F(Z.approvalId);try{const le=await nM(n,Z.runId,Z.approvalId);if(!le.ok)throw new Error(le.error||"Agent approval could not be rejected.");await de(Z.runId)}catch(le){z(le instanceof Error?le.message:String(le))}finally{F("")}},qe=async(Z,le)=>{M(Z);try{if(le){const je=await Jk(n,le);for(const ct of je.taskBatches||[])me(ct);k(ct=>ct===le?"":ct);return}const Me=await rM(n,Z);me(Me),v(je=>je===Z?"":je)}catch(Me){z(Me instanceof Error?Me.message:String(Me))}finally{M("")}},ne=async()=>{if(!(ue||!w&&!b)){W(!0);try{const Z=await eM(n);if(!Z.ok)throw new Error(Z.error||"모든 Agent 작업을 취소하지 못했습니다.");v(""),k(""),q([]),g(le=>le.map(Me=>Me.type==="task"&&["queued","running"].includes(Me.status)?{...Me,status:"cancelled",states:Me.states.map(je=>["queued","running"].includes(je.status)?{...je,status:"cancelled",stage:"Cancelled",error:"Cancelled by user."}:je)}:Me))}catch(Z){z(Z instanceof Error?Z.message:String(Z))}finally{W(!1)}}},ye=async Z=>{M(Z);try{const le=await oM(n,Z);if(!le.ok||!le.batch||!le.batchId)throw new Error(le.error||"재시도하지 못했습니다.");J.current.delete(le.batchId),g(Me=>Me.map(je=>je.type==="task"&&je.batchId===Z?{...je,batchId:le.batchId,states:Wu(le.batch,a),status:le.batch.status}:je)),v(le.batchId)}catch(le){z(le instanceof Error?le.message:String(le))}finally{M("")}},be=Z=>{p(Z),U(!1),window.requestAnimationFrame(()=>R.current?.focus())};return l.jsxs("section",{className:"agents-page",children:[l.jsxs("div",{className:"agents-workspace",children:[(w||b)&&l.jsxs("div",{className:"agents-page-status",children:[l.jsxs("span",{children:[ie.length," workstations · ",fM(T)]}),l.jsx("button",{type:"button",className:"agents-stop-all",onClick:()=>{ne()},disabled:ue,children:ue?"Stopping…":"Stop all"})]}),ce&&l.jsx("div",{className:"agents-permission-modal-backdrop",role:"presentation",children:l.jsxs("section",{className:"agents-permission-modal",role:"dialog","aria-modal":"true","aria-labelledby":"full-access-title",children:[l.jsx("span",{className:"agents-permission-modal-icon",children:l.jsx(yd,{size:20})}),l.jsx("h3",{id:"full-access-title",children:"Confirm Full Access"}),l.jsx("p",{children:"Codex may change files, run commands, manage applications, and modify system state on the selected workstations. This run is still limited to the selected devices, the fixed policy, and the tool budget."}),l.jsxs("div",{className:"agents-permission-modal-actions",children:[l.jsx("button",{type:"button",onClick:()=>Q(null),children:"Cancel"}),l.jsx("button",{type:"button",className:"danger",onClick:()=>{const Z=ce;Q(null),oe(!0),He(Z.instruction,Z.targetIds,!0)},children:"Run with Full Access"})]})]})}),K&&l.jsx("div",{className:"agents-error",role:"alert",children:K}),l.jsx(Dk,{items:x,onCancel:qe,onRetry:ye,busyBatchId:j,approvals:B,onApprove:Le,onReject:Fe,busyApprovalId:L}),l.jsxs("div",{className:"agents-composer-shell",children:[Y&&l.jsx(Kk,{devices:a,targetMode:i,selectedIds:c,permissionMode:T,customCategories:D,onSelectPrompt:be,onClose:()=>U(!1)}),l.jsx(vk,{ref:R,value:h,onChange:p,onSubmit:()=>{He()},onOpenSuggestedTasks:()=>U(Z=>!Z),suggestedOpen:Y,suggestedTaskCount:we,disabled:!!w||!!b})]})]}),l.jsxs("aside",{className:"agents-target-sidebar","aria-label":"Agent targets and permissions",children:[l.jsx(Wk,{devices:a,mode:i,selectedIds:c,onModeChange:r,onToggle:Z=>d(le=>le.includes(Z)?le.filter(Me=>Me!==Z):[...le,Z]),permissionMode:T,onPermissionModeChange:Z=>{C(Z),Z!=="full-access"&&oe(!1)}}),T==="custom"&&l.jsxs("section",{className:"agents-custom-policy","aria-label":"Custom Agent permissions",children:[l.jsxs("div",{className:"agents-custom-policy-head",children:[l.jsxs("div",{children:[l.jsx("span",{className:"agents-section-label",children:"Custom policy"}),l.jsx("strong",{children:"Choose what Codex may do automatically."})]}),l.jsx("span",{children:"Denied actions never reach a device."})]}),l.jsx("div",{className:"agents-custom-policy-grid",children:yk.map(Z=>l.jsxs("label",{children:[l.jsx("span",{children:mM(Z)}),l.jsxs("select",{value:D[Z],onChange:le=>H(Me=>({...Me,[Z]:le.target.value})),children:[l.jsx("option",{value:"allow",children:"Allow automatically"}),l.jsx("option",{value:"ask",children:"Ask every time"}),l.jsx("option",{value:"deny",children:"Deny"})]})]},Z))})]})]})]})}function lw(n){return{type:n.type,deviceIds:n.deviceIds,monitorIndex:n.monitorIndex,label:n.label}}async function iw(n){try{return(await n.json()).error||`${n.status} ${n.statusText}`}catch{return`${n.status} ${n.statusText}`}}async function rw(n,a,i){const r=encodeURIComponent(JSON.stringify({kind:a.kind,fileName:a.fileName,mimeType:n.type||"application/octet-stream",durationMs:a.durationMs,target:lw(a.target)})),c=await fetch(`${li(i)}/api/captures?metadata=${r}`,{method:"POST",headers:{"Content-Type":n.type||"application/octet-stream"},body:n,cache:"no-store"});if(!c.ok)throw new Error(await iw(c));return await c.json()}async function pM(n,a){return await Be("/api/capture-sessions",{method:"POST",body:JSON.stringify({...n,target:lw(n.target)})},a)}async function gM(n,a,i,r){const c=await fetch(`${li(r)}/api/capture-sessions/${encodeURIComponent(n)}/chunks/${a}`,{method:"PUT",headers:{"Content-Type":i.type||"application/octet-stream"},body:i,cache:"no-store"});if(!c.ok)throw new Error(await iw(c));return await c.json()}async function xM(n,a,i){return await Be(`/api/capture-sessions/${encodeURIComponent(n)}/finalize`,{method:"POST",body:JSON.stringify({durationMs:a})},i)}async function zv(n,a){await Be(`/api/capture-sessions/${encodeURIComponent(n)}`,{method:"DELETE"},a)}async function vM(n){return await Be("/api/captures",void 0,n)}function _v(n,a){return`${li(a)}/api/captures/${encodeURIComponent(n)}/content`}async function yM(n,a){return await Be(`/api/captures/${encodeURIComponent(n)}`,{method:"DELETE"},a)}function wM({hubUrl:n,onToast:a}){const[i,r]=f.useState([]),[c,d]=f.useState(!0),h=f.useCallback(async()=>{d(!0);try{r((await vM(n)).captures||[])}catch(x){a(x instanceof Error?x.message:String(x))}finally{d(!1)}},[n,a]);f.useEffect(()=>{h()},[h]);const p=async x=>{const g=_v(x.id,n);if(navigator.share)try{await navigator.share({title:x.fileName,url:g});return}catch{}window.open(g,"_blank","noopener,noreferrer")};return l.jsxs("section",{className:"capture-gallery",children:[l.jsxs("header",{children:[l.jsxs("div",{children:[l.jsx("span",{className:"settings-eyebrow",children:"Capture Gallery"}),l.jsx("h2",{children:"Saved captures"})]}),l.jsxs("button",{className:"text-button",onClick:()=>{h()},type:"button",children:[l.jsx(pc,{size:15})," Refresh"]})]}),c?l.jsx("p",{className:"settings-help",children:"Loading captures..."}):i.length===0?l.jsx("p",{className:"settings-help",children:"No captures saved yet."}):l.jsx("div",{className:"capture-gallery-grid",children:i.map(x=>{const g=_v(x.id,n);return l.jsxs("article",{className:"capture-gallery-card",children:[x.mimeType.startsWith("image/")?l.jsx("img",{src:g,alt:x.target.label}):l.jsx("video",{src:g,controls:!0,preload:"metadata"}),l.jsxs("div",{className:"capture-gallery-card-body",children:[l.jsx("strong",{children:x.fileName}),l.jsxs("small",{children:[x.target.label," · ",new Date(x.createdAt).toLocaleString()," · ",Math.ceil(x.sizeBytes/1024)," KB"]}),l.jsxs("div",{children:[l.jsx("button",{className:"icon-button",title:"Open","aria-label":"Open",onClick:()=>window.open(g,"_blank","noopener,noreferrer"),type:"button",children:l.jsx(tS,{size:15})}),l.jsx("a",{className:"icon-button",title:"Download","aria-label":"Download",href:`${g}?download=1`,download:x.fileName,children:l.jsx(nS,{size:15})}),l.jsx("button",{className:"icon-button",title:"Share","aria-label":"Share",onClick:()=>{p(x)},type:"button",children:l.jsx(aS,{size:15})}),l.jsx("button",{className:"icon-button danger",title:"Delete","aria-label":"Delete",onClick:()=>{window.confirm(`Delete ${x.fileName}?`)&&yM(x.id,n).then(()=>h()).catch(w=>a(w instanceof Error?w.message:String(w)))},type:"button",children:l.jsx(hh,{size:15})})]})]})]},x.id)})})]})}function Qu(n){if(!n)return"";const a=Math.max(0,Math.floor((Date.now()-n)/1e3)),i=Math.floor(a/3600),r=Math.floor(a%3600/60),c=a%60;return i>0?`${String(i).padStart(2,"0")}:${String(r).padStart(2,"0")}:${String(c).padStart(2,"0")}`:`${String(r).padStart(2,"0")}:${String(c).padStart(2,"0")}`}function Ov({controller:n,compact:a=!1,onFirstRollingUse:i,onError:r}){const{state:c,settings:d,videoSupported:h}=n,p=async v=>{try{await v()}catch(b){r?.(b instanceof Error?b.message:String(b))}},x=async()=>{if(d.rollingEnabled){n.setRollingEnabled(!1);return}(i?await i():window.confirm(`Keep the most recent 30 seconds in memory temporarily?
|
|
16
|
+
Nothing is saved until you press Save Last 30s.`))&&n.setRollingEnabled(!0)},g=c.recording?`Stop recording · ${Qu(c.recordingStartedAt)}`:`Start recording · ${c.targetLabel}`,w=c.timelapse?`Stop timelapse · ${Qu(c.timelapseStartedAt)}`:`Start timelapse · ${d.timelapseIntervalSeconds}s interval`;return l.jsxs("div",{className:`capture-toolbar ${a?"compact":""} ${c.recording?"recording-active":""}`,"aria-label":"Capture actions",children:[l.jsx("button",{className:"capture-action","aria-label":`Take screenshot · ${c.targetLabel}`,title:`Take screenshot · ${c.targetLabel}`,disabled:c.busy,onClick:()=>{p(n.takeScreenshot)},type:"button",children:l.jsx(sS,{size:17})}),l.jsx("button",{className:`capture-action ${c.recording?"active":""}`,"aria-label":g,title:g,disabled:!h||c.busy||c.timelapse,onClick:()=>{p(c.recording?n.stopRecording:n.startRecording)},type:"button",children:c.recording?l.jsxs(l.Fragment,{children:[l.jsx(Mx,{size:14,fill:"currentColor"}),l.jsx("span",{children:Qu(c.recordingStartedAt)})]}):l.jsx(ly,{size:18})}),l.jsxs("button",{className:"capture-action","aria-label":c.bufferEnabled?`Save last 30 seconds · ${c.bufferSeconds}s ready`:"Enable Last 30s memory buffer",title:c.bufferEnabled?`Save last 30 seconds · ${c.bufferSeconds}s ready`:"Enable Last 30s memory buffer",disabled:!h||c.recording||c.timelapse||c.busy||c.bufferEnabled&&c.bufferSeconds<1,onClick:()=>c.bufferEnabled?void p(n.saveLast30Seconds):void x(),type:"button",children:[l.jsx(lS,{size:17}),l.jsx("small",{children:"30s"})]}),l.jsx("button",{className:`capture-action ${c.timelapse?"timelapse-active":""}`,"aria-label":w,title:w,disabled:!h||c.busy||c.recording,onClick:()=>{p(c.timelapse?n.stopTimelapse:n.startTimelapse)},type:"button",children:c.timelapse?l.jsxs(l.Fragment,{children:[l.jsx(Mx,{size:14,fill:"currentColor"}),l.jsx("span",{children:Qu(c.timelapseStartedAt)})]}):l.jsx(iS,{size:17})})]})}async function bM(n,a={}){const i=n.filter(v=>v.canvas&&v.canvas.width>0&&v.canvas.height>0),r=Math.max(320,a.maxWidth||1920),c=Math.max(180,a.maxHeight||1080),d=i.length<=1?1:i.length<=4?2:i.length<=9?3:4,h=Math.max(1,Math.ceil(Math.max(1,i.length)/d)),p=Math.floor(r/d),x=Math.floor(c/h),g=document.createElement("canvas");g.width=Math.max(320,p*d),g.height=Math.max(180,x*h);const w=g.getContext("2d",{alpha:!1});if(!w)return g;w.fillStyle="#0b1220",w.fillRect(0,0,g.width,g.height),w.font="600 14px system-ui, sans-serif",w.textBaseline="bottom";for(let v=0;v<i.length;v+=1){const b=i[v],k=v%d,j=Math.floor(v/d),M=k*p,T=j*x,C=b.canvas,A=Math.min(p/C.width,x/C.height),D=Math.max(1,Math.floor(C.width*A)),H=Math.max(1,Math.floor(C.height*A)),B=M+Math.floor((p-D)/2),q=T+Math.floor((x-H)/2);w.drawImage(C,B,q,D,H),a.includeLabels!==!1&&(w.fillStyle="rgba(4, 10, 20, .74)",w.fillRect(M,T+x-28,p,28),w.fillStyle="#f8fafc",w.fillText(b.label,M+9,T+x-9))}return g}function SM(n){return n?.signature||"none"}function CM(n){return n?.label||"No capture target"}function Iv(n){return{...n,deviceIds:[...n.deviceIds],sourceCanvas:n.sourceCanvas||null}}function jM(){const n=new Date,a=i=>String(i).padStart(2,"0");return`${n.getFullYear()}${a(n.getMonth()+1)}${a(n.getDate())}_${a(n.getHours())}${a(n.getMinutes())}${a(n.getSeconds())}`}function kM(n){return n.replace(/[^a-zA-Z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"Wall"}function MM(n){return`LiveDesk_${n.type==="wall"||n.type==="selection"?"Wall":`${kM(n.label)}_Monitor-${Number(n.monitorIndex||0)+1}`}_${jM()}.png`}async function AM(n,a,i){const r=await new Promise((d,h)=>n.toBlob(p=>p?d(p):h(new Error("Screenshot could not be encoded.")),"image/png")),c=await rw(r,{kind:"screenshot",fileName:MM(a),target:a},i);try{await navigator.clipboard.write([new ClipboardItem({"image/png":r})])}catch{}return c.capture}function ow(){return["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"].find(a=>typeof MediaRecorder<"u"&&MediaRecorder.isTypeSupported(a))||""}function NM(n,a){const i=new Date().toISOString().replace(/[-:]/g,"").replace(/\.\d{3}Z$/,"").replace("T","_"),r=a.label.replace(/[^a-zA-Z0-9._-]+/g,"-").slice(0,70)||"Wall";return n==="timelapse"?`LiveDesk_Timelapse_${r}_${i}.webm`:`LiveDesk_Recording_${r}_${i}.webm`}async function cw(n){if(typeof MediaRecorder>"u"||typeof n.canvas.captureStream!="function")throw new Error("This browser does not support video recording.");const a=ow();if(!a)throw new Error("This browser does not support WebM recording.");const i=n.kind||"recording",r=await pM({kind:i,fileName:NM(i,n.target),mimeType:a,target:n.target},n.hubUrl),c=n.canvas.captureStream(n.frameRequests?0:n.fps),d=new MediaRecorder(c,{mimeType:a,videoBitsPerSecond:i==="timelapse"?2e6:4e6}),h=performance.now();let p=0,x=!1,g=null,w=Promise.resolve();return d.ondataavailable=v=>{if(!v.data||v.data.size===0)return;const b=p++;w=w.then(()=>gM(r.sessionId,b,v.data,n.hubUrl).then(()=>{})).catch(k=>{g=g||(k instanceof Error?k:new Error(String(k))),n.onError?.(g)})},d.onerror=()=>{g=new Error("Video recording stopped unexpectedly."),n.onError?.(g)},d.start(1e3),{requestFrame:()=>{c.getVideoTracks()[0]?.requestFrame?.()},stop:async()=>{if(!x){if(x=!0,await new Promise(v=>{d.addEventListener("stop",()=>v(),{once:!0}),d.stop()}),c.getTracks().forEach(v=>v.stop()),await w,g)throw await zv(r.sessionId,n.hubUrl).catch(()=>{}),g;await xM(r.sessionId,Math.max(0,performance.now()-h),n.hubUrl)}},cancel:async()=>{x||(x=!0,d.stop(),c.getTracks().forEach(v=>v.stop()),await zv(r.sessionId,n.hubUrl).catch(()=>{}))}}}class TM{recorder=null;stream=null;segments=[];totalBytes=0;targetSignature="";startedAt=0;maxDurationMs=3e4;maxBytes=128*1024*1024;get seconds(){return!this.startedAt||this.segments.length===0?0:Math.min(30,Math.max(0,(performance.now()-this.segments[0].at)/1e3))}get active(){return this.recorder!==null}async start(a,i){if(this.recorder&&this.targetSignature===i.signature)return;if(this.stop(),typeof MediaRecorder>"u"||typeof a.captureStream!="function")throw new Error("This browser does not support Last 30s.");const r=ow();if(!r)throw new Error("This browser does not support WebM recording.");this.targetSignature=i.signature,this.stream=a.captureStream(20),this.recorder=new MediaRecorder(this.stream,{mimeType:r,videoBitsPerSecond:3e6}),this.startedAt=performance.now(),this.recorder.ondataavailable=c=>{if(!c.data.size)return;const d=performance.now();for(this.segments.push({blob:c.data,at:d}),this.totalBytes+=c.data.size;this.segments.length>1&&(d-this.segments[0].at>this.maxDurationMs||this.totalBytes>this.maxBytes);){const h=this.segments.shift();this.totalBytes-=h.blob.size}},this.recorder.start(1e3)}stop(){const a=this.recorder;this.recorder=null,a&&a.state!=="inactive"&&(a.ondataavailable=null,a.stop()),this.stream?.getTracks().forEach(i=>i.stop()),this.stream=null,this.segments=[],this.totalBytes=0,this.startedAt=0}async save(a,i){if(this.segments.length===0)throw new Error("The Last 30s buffer is not ready yet.");const r=new Blob(this.segments.map(h=>h.blob),{type:this.segments[0].blob.type||"video/webm"}),d=`LiveDesk_Last30s_${a.label.replace(/[^a-zA-Z0-9._-]+/g,"-").slice(0,70)||"Wall"}_${new Date().toISOString().replace(/[-:]/g,"").replace(/\.\d{3}Z$/,"").replace("T","_")}.webm`;return await rw(r,{kind:"last-30s",fileName:d,target:a,durationMs:Math.min(3e4,this.segments.length*1e3)},i)}}async function RM(n,a,i,r,c){const d=await cw({canvas:n,target:a,kind:"timelapse",fps:30,frameRequests:!0,hubUrl:r,onError:c});d.requestFrame?.();const h=window.setInterval(()=>d.requestFrame?.(),Math.max(5,i)*1e3);return{stop:async()=>{window.clearInterval(h),await d.stop()},cancel:async()=>{window.clearInterval(h),await d.cancel()}}}const uw="livedesk.captureSettings";function EM(){const n={rollingEnabled:!1,recordingQuality:"standard",timelapseIntervalSeconds:10,includeRemoteCursor:!0};try{const a=JSON.parse(localStorage.getItem(uw)||"null");return{...n,...a&&typeof a=="object"?a:{}}}catch{return n}}function DM(n){const[a,i]=f.useState(EM),[r,c]=f.useState(0),[d,h]=f.useState(0),[p,x]=f.useState(0),[g,w]=f.useState(!1),v=f.useRef(void 0),b=f.useRef(!1),k=f.useRef(""),j=f.useRef(null),M=f.useRef(null),T=f.useRef(null),C=f.useRef(null),A=f.useRef(new TM),D=n.sourceRegistry.resolveCurrentTarget(),H=SM(D),B=CM(D),q=typeof MediaRecorder<"u"&&typeof HTMLCanvasElement<"u"&&"captureStream"in HTMLCanvasElement.prototype;f.useEffect(()=>{if(localStorage.setItem(uw,JSON.stringify(a)),!b.current)return;const U=JSON.stringify(a);U!==k.current&&(k.current=U,Be("/api/settings",{method:"PATCH",body:JSON.stringify({revision:v.current,filesAudio:{rollingBufferEnabled:a.rollingEnabled,recordingQuality:a.recordingQuality,timelapseIntervalSeconds:a.timelapseIntervalSeconds,includeRemoteCursor:a.includeRemoteCursor}})},n.hubUrl).then(R=>{v.current=Number(R.revision||v.current||0)}).catch(()=>{}))},[n.hubUrl,a]),f.useEffect(()=>{let U=!0;return Be("/api/settings",void 0,n.hubUrl).then(R=>{if(!U)return;const J=R.settings?.filesAudio||{},he=typeof J.rollingBufferEnabled=="boolean"?J.rollingBufferEnabled:a.rollingEnabled,$=J.recordingQuality==="high"?"high":"standard",ie=[5,10,30,60].includes(Number(J.timelapseIntervalSeconds))?Number(J.timelapseIntervalSeconds):a.timelapseIntervalSeconds,we=typeof J.includeRemoteCursor=="boolean"?J.includeRemoteCursor:a.includeRemoteCursor,me={rollingEnabled:he,recordingQuality:$,timelapseIntervalSeconds:ie,includeRemoteCursor:we};v.current=Number(R.revision||0),k.current=JSON.stringify(me),b.current=!0,i(me)}).catch(()=>{b.current=!0}),()=>{U=!1}},[n.hubUrl]);const L=f.useCallback(async U=>{if(U.sourceCanvas&&U.sourceCanvas.width>0&&U.sourceCanvas.height>0)return{target:Iv(U),canvas:U.sourceCanvas,cleanup:()=>{}};const R=await n.sourceRegistry.composeWall(U.deviceIds,{maxWidth:1920,maxHeight:1080,includeLabels:!0});let J=!1;const he=window.setInterval(async()=>{if(J)return;const $=await n.sourceRegistry.composeWall(U.deviceIds,{maxWidth:1920,maxHeight:1080,includeLabels:!0}).catch(()=>null);!$||J||((R.width!==$.width||R.height!==$.height)&&(R.width=$.width,R.height=$.height),R.getContext("2d")?.drawImage($,0,0))},100);return{target:Iv(U),canvas:R,cleanup:()=>{J=!0,window.clearInterval(he)}}},[n.sourceRegistry]);f.useEffect(()=>{const U=A.current;if(!a.rollingEnabled||!D||!q){U.stop(),x(0);return}let R=!1,J=null;return(async()=>{try{if(J=await L(D),R)return;await U.start(J.canvas,J.target);const $=window.setInterval(()=>x(Math.round(U.seconds)),500),ie=()=>{window.clearInterval($),J?.cleanup()};U.__cleanup=ie}catch($){R||n.onToast($ instanceof Error?$.message:String($))}})(),()=>{R=!0,U.stop(),U.__cleanup?.(),U.__cleanup=void 0,x(0)}},[L,n.onToast,a.rollingEnabled,H,q]);const F=f.useCallback(U=>i(R=>({...R,rollingEnabled:U})),[]),ue=f.useCallback(U=>i(R=>({...R,recordingQuality:U})),[]),W=f.useCallback(U=>i(R=>({...R,timelapseIntervalSeconds:U})),[]),ce=f.useCallback(async()=>{const U=n.sourceRegistry.resolveCurrentTarget();if(!U)throw new Error("화면이 준비된 후 다시 시도하세요.");w(!0);let R=null;try{R=await L(U),await AM(R.canvas,R.target,n.hubUrl),n.onToast("Screenshot saved")}finally{R?.cleanup(),w(!1)}},[L,n.hubUrl,n.onToast,n.sourceRegistry]),Q=f.useCallback(async()=>{if(T.current)throw new Error("Stop the timelapse before recording.");const U=n.sourceRegistry.resolveCurrentTarget();if(!U)throw new Error("화면이 준비된 후 다시 시도하세요.");const R=await L(U),J=await cw({canvas:R.canvas,target:R.target,fps:U.type==="control"?30:15,hubUrl:n.hubUrl,onError:he=>n.onToast(he.message)});M.current=R.cleanup,j.current=J,c(Date.now()),n.onToast("Recording started")},[L,n.hubUrl,n.onToast,n.sourceRegistry]),se=f.useCallback(async()=>{const U=j.current;if(U){w(!0);try{await U.stop(),n.onToast("Recording saved")}finally{j.current=null,M.current?.(),M.current=null,c(0),w(!1)}}},[n.onToast]),oe=f.useCallback(async()=>{if(j.current||T.current)throw new Error("Last 30s is unavailable during a recording.");const U=n.sourceRegistry.resolveCurrentTarget();if(!U)throw new Error("화면이 준비된 후 다시 시도하세요.");w(!0);try{await A.current.save(U,n.hubUrl),n.onToast("Last 30 seconds saved")}finally{w(!1)}},[n.hubUrl,n.onToast,n.sourceRegistry]),K=f.useCallback(async()=>{if(j.current)throw new Error("Stop the recording before starting a timelapse.");const U=n.sourceRegistry.resolveCurrentTarget();if(!U)throw new Error("화면이 준비된 후 다시 시도하세요.");const R=await L(U),J=await RM(R.canvas,R.target,a.timelapseIntervalSeconds,n.hubUrl,he=>n.onToast(he.message));C.current=R.cleanup,T.current=J,h(Date.now()),n.onToast("Timelapse started")},[L,n.hubUrl,n.onToast,n.sourceRegistry,a.timelapseIntervalSeconds]),z=f.useCallback(async()=>{const U=T.current;if(U){w(!0);try{await U.stop(),n.onToast("Timelapse saved")}finally{T.current=null,C.current?.(),C.current=null,h(0),w(!1)}}},[n.onToast]);return f.useEffect(()=>{const U=R=>{!j.current&&!T.current||(R.preventDefault(),R.returnValue="")};return window.addEventListener("beforeunload",U),()=>window.removeEventListener("beforeunload",U)},[]),f.useEffect(()=>()=>{A.current.stop(),j.current?.cancel(),T.current?.cancel(),M.current?.(),C.current?.()},[]),{state:f.useMemo(()=>({recording:!!j.current,recordingStartedAt:r,timelapse:!!T.current,timelapseStartedAt:d,bufferSeconds:p,bufferEnabled:a.rollingEnabled,busy:g,targetLabel:B}),[p,g,r,a.rollingEnabled,B,d]),settings:a,videoSupported:q,targetKey:H,setRollingEnabled:F,setRecordingQuality:ue,setTimelapseInterval:W,takeScreenshot:ce,startRecording:Q,stopRecording:se,saveLast30Seconds:oe,startTimelapse:K,stopTimelapse:z}}const LM=120,zM=999,Qo=5,Xo=30,_M=Number.POSITIVE_INFINITY,dw="livedesk.remoteDirectory",ih="livedesk.localHubAccessEnabled",fw="livedesk.streamSettings",mw=15,hw="livedesk.controlStreamSettings",rh=6,pw="livedesk.wallMonitorSelections",gw=1,_m=512*1024,oh="".trim(),xw="".trim(),Bv="livedesk-adsense-script",Om=!!oh&&!!xw,OM=1e3/60,Im=1500,IM=650,BM=1800,FM=650,HM=2500,Fv=1500,Hv=15e3,$M=6e4,$v=240,UM=1024,PM=480,qM=270;function GM(n,a){if(a.deviceId!==n.deviceId)return!1;const i=Number(a.browserReceivedEpochMs);if(!Number.isFinite(i)||i<n.startedAtEpochMs)return!1;const r=Number(a.monitorIndex);if(Number.isFinite(r)&&Math.floor(r)!==n.monitorIndex)return!1;const c=String(a.frameMode||a.mode||"").trim().toLowerCase();return!c||c===n.frameMode?!0:n.frameMode==="mode5-lzo-delta"&&c==="mode3-h264-hw"}const $i={free:{name:"Free",price:"$0",limit:Qo,audience:"Personal trial",note:"5 devices with a standard ad banner."},ltd:{name:"Plus",price:"$79 LTD",ltd:"$79 LTD",limit:Xo,audience:"Creators and homelabs",note:"30 devices, no ads, personal use."},pro:{name:"Pro",price:"$199 LTD",ltd:"$199 LTD",limit:_M,audience:"Business and studios",note:"Commercial use and larger workstation walls."}},vw={"mode1-jpeg":5,"mode2-lzo":8,"mode3-h264-hw":20,"mode4-h264-atlas":20};function ys(n,a){return`${n}:${a}`}const ha={frameMode:"mode3-h264-hw",h264DecodeAcceleration:"prefer-hardware",fps:vw["mode3-h264-hw"],maxWidth:1920,maxHeight:1080,atlasTileWidth:320,atlasTileHeight:180,atlasTileSizeMode:"auto",quality:75,autoStartLive:!0,showScreenStatus:!0,visibleOnlyLive:!0,adaptiveLoadShedding:!0,adaptiveSizeByWall:!0},pa={frameMode:"mode3-h264-hw",h264DecodeAcceleration:"prefer-software",fps:30,maxWidth:1920,maxHeight:1080,quality:75,showScreenStatus:!1};function ld(n,a){if(n.length===0)return 0;const i=[...n].sort((c,d)=>c-d),r=Math.max(0,Math.min(i.length-1,Math.ceil(i.length*a)-1));return i[r]}function _h(n,a){n.push(a),n.length>$v&&n.splice(0,n.length-$v)}function Uv(n,a){n.sampleFrames=0,n.sampleStartedAt=a,n.intervalCount=0,n.intervalSumMs=0,n.minIntervalMs=Number.POSITIVE_INFINITY,n.maxIntervalMs=0,n.intervalSamplesMs.length=0,n.seqGapCount=0,n.maxSeqGap=0}function Pv(n,a,i){if(n.lastAt!==void 0){const r=Math.max(0,a-n.lastAt);n.intervalCount+=1,n.intervalSumMs+=r,n.minIntervalMs=Math.min(n.minIntervalMs,r),n.maxIntervalMs=Math.max(n.maxIntervalMs,r),_h(n.intervalSamplesMs,r)}if(n.lastFrameSeq!==void 0){const r=i-n.lastFrameSeq;r!==1&&(n.seqGapCount+=1,n.maxSeqGap=Math.max(n.maxSeqGap,Math.abs(r)))}n.lastAt=a,n.lastFrameSeq=i}function qv(n){return!n||n.intervalCount<=0?"waiting":`${Math.round(n.averageIntervalMs)}ms avg / p95 ${Math.round(n.p95IntervalMs)}ms / max ${Math.round(n.maxIntervalMs)}ms`}function YM(){const[n,a]=f.useState({framesPerSecond:0,averageIntervalMs:0,p95IntervalMs:0,maxIntervalMs:0,longTaskCount:0,longTaskMs:0});return f.useEffect(()=>{let i=0,r=performance.now(),c=0,d=0,h=[],p=0,x=0,g=null;const w=b=>{document.visibilityState==="visible"?(c+=1,d>0&&_h(h,Math.max(0,b-d)),d=b):d=0,i=window.requestAnimationFrame(w)};try{g=new PerformanceObserver(b=>{for(const k of b.getEntries())p+=1,x+=k.duration}),g.observe({entryTypes:["longtask"]})}catch{g=null}i=window.requestAnimationFrame(w);const v=window.setInterval(()=>{const b=performance.now(),k=Math.max(1,b-r),j=h.reduce((M,T)=>M+T,0);a({framesPerSecond:c*1e3/k,averageIntervalMs:h.length>0?j/h.length:0,p95IntervalMs:ld(h,.95),maxIntervalMs:h.length>0?Math.max(...h):0,longTaskCount:p,longTaskMs:x}),r=b,c=0,h=[],p=0,x=0},1e3);return()=>{window.cancelAnimationFrame(i),window.clearInterval(v),g?.disconnect()}},[]),n}function Gv(n){return!n||n.seqGapCount<=0?"none":`${n.seqGapCount} gaps / max ${n.maxSeqGap}`}function VM(n){return Number.isFinite(n)?String(n):"30+"}const id=[{id:"mode4-h264-atlas",label:"Mode 4",detail:"Hub H.264 Atlas"},{id:"mode3-h264-hw",label:"Mode 3",detail:"H.264 hardware"},{id:"mode2-lzo",label:"Mode 2",detail:"RGB565 LZO wall"},{id:"mode1-jpeg",label:"Mode 1",detail:"JPEG test"}],ch=[{id:"prefer-software",label:"Software low latency"},{id:"prefer-hardware",label:"Hardware decode"},{id:"no-preference",label:"Browser auto"}],KM=[{id:"mode3-h264-hw",label:"Mode 3 - H.264 hardware"},{id:"mode5-lzo-delta",label:"Mode 5 - LZO tile delta"}],rd=[{id:"640x360",label:"Compact",width:640,height:360},{id:"960x540",label:"Standard",width:960,height:540},{id:"1280x720",label:"HD",width:1280,height:720},{id:"1920x1080",label:"Full HD",width:1920,height:1080},{id:"2560x1440",label:"QHD",width:2560,height:1440},{id:"3840x2160",label:"4K",width:3840,height:2160}],Bm=rd.filter(n=>n.width>=1280),Fm=[{id:"auto",label:"Auto by wall size"},{id:"320x180",label:"Standard 320x180",width:320,height:180},{id:"480x270",label:"Sharp 480x270",width:480,height:270}],Oh=[1,2,5,8,12,20,30],WM=[20,30,60],Yv=[45,60,75,90],Vv={large:{maxWidth:1280,maxHeight:720},medium:{maxWidth:960,maxHeight:540},small:{maxWidth:640,maxHeight:360}},Fn={preserveConfiguredFpsDeviceCount:12,visibleRootMargin:"520px 0px 760px 0px",fallbackVisibleCounts:{large:12,medium:18,small:32},maxWallFramesPerSecond:96,maxWallBytesPerSecond:80*1024*1024,maxFrameGapMs:280,lowLoadFrameRatio:.58,lowLoadByteRatio:.52,downshiftCooldownMs:1800,recoveryCooldownMs:14e3,minFps:5},Kv=2200,QM=8e3,XM=3500,ZM=7e3,JM=2,eA=2600,tA=4200,nA=750,aA=2,Wv=4200;function Qv(n,a){return Math.min(3e4,n*2**Math.min(3,Math.max(0,a)))}function rc(n,a){const i=n.capabilities?.[a];return typeof i=="boolean"?i:/^(1|true|yes|on)$/i.test(String(i||"").trim())}function Yi(n){return n.deviceName||n.hostname||n.deviceId}function sA(){return"npx -y --prefer-online livedesk@latest client"}function lA(){return"npx -y --prefer-online livedesk@latest"}function iA(){try{return localStorage.getItem(dw)||""}catch{return""}}function rA(){try{return localStorage.getItem(ih)==="1"}catch{return!1}}function zr(n){try{n?localStorage.setItem(ih,"1"):localStorage.removeItem(ih)}catch{}}function Qa(n,a,i,r){const c=Number(n);return Number.isFinite(c)?Math.max(a,Math.min(i,Math.round(c))):r}function uh(n){const a=String(n||"").trim();return a==="mode2-lz4"||a==="lz4"?"mode2-lzo":id.some(i=>i.id===a)?a:ha.frameMode}function vd(n){const a=String(n||"").trim();return ch.some(i=>i.id===a)?a:ha.h264DecodeAcceleration}function dh(n){return n==="mode3-h264-hw"||n==="mode5-lzo-delta"?n:pa.frameMode}function yw(n){return vw[n]||12}function ww(n){return n==="mode3-h264-hw"||n==="mode4-h264-atlas"?20:30}function fh(n,a){return Qa(n,1,ww(a),yw(a))}function Qi(n){return n&&typeof n=="object"&&!Array.isArray(n)?n:{}}function Bn(n){const a=Qi(n.status),i=Qi(a.screens),r=Qi(n.capabilities),c=[a.monitorCount,a.screenCount,i.count,r.monitorCount,r.screenCount];for(const d of c){const h=Number(d);if(Number.isFinite(h)&&h>0)return Math.max(1,Math.min(64,Math.floor(h)))}return 1}function ni(n){const a=Number(n);return Number.isFinite(a)&&a>0?Math.floor(a):0}function oA(n){const a=Qi(n.status),r=[Qi(a.screens).displays,a.displays,a.monitors];for(const c of r)if(!(!Array.isArray(c)||c.length===0))return c.map(d=>Qi(d));return[]}function bw(n,a){const i=oA(n),r=i.find(x=>Number(x.index)===a)||i[a]||i[0]||{},c=ni(r.width),d=ni(r.height),h=[r.name,r.displayName,r.deviceName,r.id].find(x=>typeof x=="string"&&x.trim()),p=typeof h=="string"?h.trim():`Display ${a+1}`;return{index:a,name:p,width:c,height:d,primary:r.primary===!0||r.isPrimary===!0}}function cA(n){const a=Bn(n);return Array.from({length:a},(i,r)=>bw(n,r))}function uA(n){const a=[n.name||`Display ${n.index+1}`];return n.width>0&&n.height>0&&a.push(`${n.width}x${n.height}`),n.primary&&a.push("Primary"),a.join(" - ")}function Sw(n,a){const i=bw(n,a);if(i.width>0&&i.height>0)return{width:i.width,height:i.height};const r=Qi(n.status),c=ni(r.screenWidth||r.width),d=ni(r.screenHeight||r.height);return c>0&&d>0?{width:c,height:d}:null}function Cw(n){if(!n)return null;const a=ni(n.sourceWidth)||ni(n.width),i=ni(n.sourceHeight)||ni(n.height);return a>0&&i>0?{width:a,height:i}:null}function dA(n,a,i){const d=((typeof a?.monitorIndex=="number"?Pn(a.monitorIndex,Math.max(1,a.monitorCount||1)):i)===i?Cw(a):null)||Sw(n,i);return d?Math.max(.25,Math.min(4,d.width/d.height)):16/9}const Xu=16/9;function Pn(n,a){const i=Math.max(1,Math.min(64,Math.floor(Number(a)||1))),r=Math.floor(Number(n));return Number.isFinite(r)?Math.max(0,Math.min(i-1,r)):0}function fA(){try{const n=localStorage.getItem(pw);if(!n)return{};const a=JSON.parse(n),i=a&&typeof a=="object"&&!Array.isArray(a)?a.selections:void 0;if(Number(a?.version)!==gw||!i||typeof i!="object"||Array.isArray(i))return{};const r={};for(const[c,d]of Object.entries(i)){const h=c.trim(),p=Math.floor(Number(d));!h||!Number.isFinite(p)||(r[h]=Math.max(0,Math.min(63,p)))}return r}catch{return{}}}function mA(n){try{localStorage.setItem(pw,JSON.stringify({version:gw,selections:n}))}catch{}}function hA(){try{const n=JSON.parse(localStorage.getItem(fw)||"{}");if(![mw,14,13,12,11].includes(Number(n.version)))return ha;const a=uh(n.frameMode),i=Qa(n.maxWidth,320,3840,ha.maxWidth),r=Qa(n.maxHeight,180,2160,ha.maxHeight);return{frameMode:a,h264DecodeAcceleration:vd(n.h264DecodeAcceleration),fps:fh(n.fps,a),maxWidth:i,maxHeight:r,atlasTileWidth:Number(n.atlasTileWidth)>=480?480:320,atlasTileHeight:Number(n.atlasTileHeight)>=270?270:180,atlasTileSizeMode:n.atlasTileSizeMode==="fixed"?"fixed":"auto",quality:Qa(n.quality,20,95,ha.quality),autoStartLive:typeof n.autoStartLive=="boolean"?n.autoStartLive:ha.autoStartLive,showScreenStatus:typeof n.showScreenStatus=="boolean"?n.showScreenStatus:ha.showScreenStatus,visibleOnlyLive:typeof n.visibleOnlyLive=="boolean"?n.visibleOnlyLive:ha.visibleOnlyLive,adaptiveLoadShedding:typeof n.adaptiveLoadShedding=="boolean"?n.adaptiveLoadShedding:ha.adaptiveLoadShedding,adaptiveSizeByWall:typeof n.adaptiveSizeByWall=="boolean"?n.adaptiveSizeByWall:ha.adaptiveSizeByWall}}catch{return ha}}function pA(n){try{localStorage.setItem(fw,JSON.stringify({...n,version:mw}))}catch{}}function gA(){try{const n=JSON.parse(localStorage.getItem(hw)||"{}"),a=Number(n.version);if(![rh,5,4,3,2,1].includes(a))return pa;const i=Qa(n.fps,20,60,pa.fps),r=a<rh;return{frameMode:r?pa.frameMode:dh(n.frameMode),h264DecodeAcceleration:r?pa.h264DecodeAcceleration:vd(n.h264DecodeAcceleration),fps:r?pa.fps:i,maxWidth:Qa(n.maxWidth,1280,3840,pa.maxWidth),maxHeight:Qa(n.maxHeight,720,2160,pa.maxHeight),quality:Qa(n.quality,20,95,pa.quality),showScreenStatus:typeof n.showScreenStatus=="boolean"?n.showScreenStatus:pa.showScreenStatus}}catch{return pa}}function xA(n){try{localStorage.setItem(hw,JSON.stringify({...n,version:rh}))}catch{}}function Hm(n,a){return n.length!==a.length?!1:n.every((i,r)=>i===a[r])}function $m(n){return[...new Set(n.filter(Boolean))].sort()}function vA(n){return Fn.fallbackVisibleCounts[n]||Fn.fallbackVisibleCounts.large}function yA(n,a,i){if(n.frameMode==="mode2-lzo")return{maxWidth:320,maxHeight:180};if(n.frameMode==="mode4-h264-atlas")return n.atlasTileSizeMode==="auto"?a==="large"?{maxWidth:480,maxHeight:270}:{maxWidth:320,maxHeight:180}:{maxWidth:n.atlasTileWidth,maxHeight:n.atlasTileHeight};if(!n.adaptiveSizeByWall)return{maxWidth:n.maxWidth,maxHeight:n.maxHeight};const r=Vv[a]||Vv.large;return{maxWidth:Math.min(n.maxWidth,r.maxWidth),maxHeight:Math.min(n.maxHeight,r.maxHeight)}}function wA(n,a=Fn.minFps){const i=[...Oh].sort((c,d)=>c-d),r=Math.max(a,Math.floor(n/2));return[...i].reverse().find(c=>c<n&&c>=a)||r}function bA(n,a){return[...Oh].sort((r,c)=>r-c).find(r=>r>n&&r<=a)||a}function Zo(n){if(!Number.isFinite(n)||n<=0)return"0 B";const a=["B","KB","MB","GB","TB"];let i=n,r=0;for(;i>=1024&&r<a.length-1;)i/=1024,r+=1;const c=r===0||i>=100?0:1;return`${i.toFixed(c)} ${a[r]}`}function Xv(n){if(!Number.isFinite(n)||!n||n<=0)return"0GB";const a=1024**4,i=1024**3;return n>=a?`${Math.max(1,Math.round(n/a))}TB`:`${Math.max(1,Math.round(n/i))}GB`}function Um(n,a){if(!Number.isFinite(n)||!n||n<=0)return"not reported";const i=Math.max(0,n-Math.max(0,Number(a||0)));return`${Xv(i)} / ${Xv(n)}`}function SA(n){const a=new Uint8Array(n),i=32768;let r="";for(let c=0;c<a.length;c+=i){const d=a.subarray(c,c+i);r+=String.fromCharCode(...d)}return btoa(r)}function Zv(n){return Array.from(n).filter(a=>a.size>=0).map(a=>{const i=a.webkitRelativePath||a.name;return{file:a,relativePath:i,fingerprint:`${a.size}:${a.lastModified}`}})}function CA(n){return n===1?"middle":n===2?"right":"left"}function Jv(n,...a){for(const i of a){const r=n?.[i];if(typeof r=="string"&&r.trim())return r.trim()}return""}function ey(n){const a=Number(n);return Number.isInteger(a)&&a>=1&&a<=zM?a:0}const jA={cpu:"CPU",memory:"MEM",disk:"Disk",gpu:"GPU",vram:"VRAM",npu:"NPU",temp:"Temp",network:"Net"};function kA(n,a,i){if(n==="online")return"Online";if(n==="busy")return"Busy";if(n==="stale")return"Stale";if(n==="offline")return"Offline";if(i==="failed")return"Task failed";const r=n==="critical"?"critical":"warn",c=a.find(h=>h.state===r)||a.find(h=>h.state==="critical"||h.state==="warn");if(!c)return n==="critical"?"Issue":"Check";const d=jA[c.id]||c.label;return c.value&&c.value!=="-"?`${d} ${c.value}`:d}function Ad(n,a){const i=a.split(".");let r=n;for(const c of i){if(r==null)return;if(Array.isArray(r)){const d=Number(c);r=Number.isInteger(d)?r[d]:void 0;continue}if(typeof r=="object"){r=r[c];continue}return}return r}function Bt(n,...a){for(const i of a){const r=Ad(n,i),c=Number(r);if(Number.isFinite(c))return c}}function ga(n,...a){for(const i of a){const r=Ad(n,i);if(typeof r=="string"&&r.trim())return r.trim();if(typeof r=="number"&&Number.isFinite(r))return String(r)}return""}function MA(n,...a){for(const i of a){const r=Ad(n,i);if(typeof r=="boolean")return r;if(/^(1|true|yes|on|online|running|ready)$/i.test(String(r||"").trim()))return!0;if(/^(0|false|no|off|offline|stopped|missing)$/i.test(String(r||"").trim()))return!1}}function ml(n){const a=Number(n);if(Number.isFinite(a))return Math.max(0,Math.min(1,a>1?a/100:a))}function Pm(n,a){if(!(typeof n!="number"||typeof a!="number"||!Number.isFinite(n)||!Number.isFinite(a)||n<=0))return ml((n-Math.max(0,a))/n)}function _r(n){return n===void 0?"-":`${Math.round(n*100)}%`}function qm(n){return n===void 0||!Number.isFinite(n)?"":n>=1e3?`${(n/1e3).toFixed(n>=1e4?0:1)}Gb/s`:`${Math.round(n)}Mb/s`}function Ui(n,a=.92,i=.78){return n===void 0?"unknown":n>=a?"critical":n>=i?"warn":"good"}function jw(n){return!Number.isFinite(n)||!n||n<=0?"-":n<3600?`${Math.round(n/60)}m`:n<86400?`${Math.round(n/3600)}h`:`${Math.round(n/86400)}d`}function Zu(n,a,i){const r=Ad(n,`tools.${a}`),c=ga(n,`tools.${a}.status`,`tooling.${a}.status`,`${a}.status`).toLowerCase(),d=MA(n,`tools.${a}.running`,`tooling.${a}.running`,`${a}.running`),h=ga(n,`tools.${a}.version`,`tooling.${a}.version`,`${a}.version`),p=ga(n,`tools.${a}.port`,`tooling.${a}.port`,`${a}.port`);let x="unknown";return c==="busy"?x="busy":["online","running","ready","active"].includes(c)||d===!0?x="online":(["offline","stopped","missing","not-found"].includes(c)||d===!1||r===!1)&&(x="offline"),{id:a,label:i,status:x,detail:x==="offline"?"offline":h||(p?`:${p}`:x==="unknown"?"not reported":x)}}function kw(n){const a=n.status||{},i=Bt(a,"cpu.cores","cpuCores","processorCount"),r=Bt(a,"loadavg.0","cpu.load1"),c=ml(Bt(a,"cpu.usedRatio","cpu.usageRatio","cpu.ratio","cpu.usedPct","cpu.usagePct","cpu.percent")??(i&&r!==void 0?r/Math.max(1,i):void 0)),d=Bt(a,"memory.totalBytes","totalMem"),h=Bt(a,"memory.freeBytes","freeMem"),p=ml(Bt(a,"memory.usedRatio","memory.usedPct","usedMemRatio"))??Pm(d,h),x=Bt(a,"disk.totalBytes","rootDisk.totalBytes","storage.totalBytes"),g=Bt(a,"disk.freeBytes","rootDisk.freeBytes","storage.freeBytes"),w=ml(Bt(a,"disk.usedRatio","disk.usedPct","rootDisk.usedRatio","storage.usedRatio"))??Pm(x,g),v=Bt(a,"thermal.cpuC","temperatureC","cpu.temperatureC","gpu.temperatureC"),b=ml(Bt(a,"gpu.usedRatio","gpu.usageRatio","gpu.usedPct","gpu.usagePct","gpu.percent","accelerators.gpu.usageRatio")),k=ga(a,"gpu.name","gpu.model","accelerators.gpu.name"),j=Bt(a,"gpu.memory.totalBytes","gpu.totalMemoryBytes","gpu.vramTotalBytes"),M=Bt(a,"gpu.memory.freeBytes","gpu.freeMemoryBytes","gpu.vramFreeBytes"),T=ml(Bt(a,"gpu.memory.usedRatio","gpu.vramUsedRatio"))??Pm(j,M),C=Bt(a,"gpu.temperatureC","thermal.gpuC"),A=ml(Bt(a,"npu.usedRatio","npu.usageRatio","npu.usedPct","npu.usagePct","npu.percent","accelerators.npu.usageRatio")),D=ga(a,"npu.name","npu.model","accelerators.npu.name"),H=Bt(a,"npu.tops","npu.topsInt8","accelerators.npu.tops"),B=Bt(a,"network.rxMbps","network.receiveMbps","network.downMbps"),q=Bt(a,"network.txMbps","network.transmitMbps","network.upMbps"),L=Bt(a,"network.latencyMs","network.rttMs"),F=ml(Bt(a,"network.usedRatio","network.usageRatio","network.saturationRatio")),ue=ga(a,"network.link","network.interface","network.name"),W=v===void 0?void 0:ml((v-35)/60),ce=ga(a,"workload.role","role","lane")||(rc(n,"aiAssist")?"Agent worker":rc(n,"taskDispatch")?"Task worker":"Local machine"),Q=ga(n.latestTask,"status")||ga(a,"workload.status")||"idle",se=ga(n.latestTask,"title","instructionPreview")||ga(a,"workload.title"),oe=ga(n.latestTask,"resultSummary","error","instructionPreview")||ga(a,"workload.summary"),K=[Zu(a,"ollama","Ollama"),Zu(a,"lmStudio","LM Studio"),Zu(a,"comfyui","ComfyUI"),Zu(a,"stableDiffusion","Stable Diffusion")],z=K.some($=>$.status!=="unknown"),Y=Date.parse(n.lastSeenAt||n.connectedAt||""),U=Number.isFinite(Y)?Date.now()-Y:0;let R="online";n.connected?U>5*6e4?R="stale":(v??0)>=86||(C??0)>=88||(c??0)>=.94||(b??0)>=.96||(T??0)>=.96||(A??0)>=.96||(p??0)>=.94||(w??0)>=.94||(L??0)>=200||Q==="failed"?R="critical":(v??0)>=78||(C??0)>=80||(c??0)>=.82||(b??0)>=.86||(T??0)>=.88||(A??0)>=.86||(p??0)>=.82||(w??0)>=.86||(L??0)>=80?R="warn":(["queued","running","targeted"].includes(Q)||K.some($=>$.status==="busy"))&&(R="busy"):R="offline";const J=K.filter($=>$.status==="online"||$.status==="busy").length,he=[{id:"cpu",label:"CPU",value:_r(c),detail:i?`${i} cores`:r!==void 0?`load ${r.toFixed(1)}`:"not reported",ratio:c,state:Ui(c,.92,.78)},{id:"memory",label:"RAM",value:_r(p),detail:Um(d,h),ratio:p,state:Ui(p,.92,.78)},{id:"disk",label:"DISK",value:_r(w),detail:Um(x,g),ratio:w,state:Ui(w,.92,.82)},{id:"gpu",label:"GPU",value:_r(b),detail:k||(j&&M!==void 0?`${Zo(M)} VRAM free`:C!==void 0?`${Math.round(C)}C`:"not reported"),ratio:b,state:C!==void 0&&C>=88?"critical":C!==void 0&&C>=80?"warn":Ui(b,.96,.86)},{id:"vram",label:"VRAM",value:_r(T),detail:Um(j,M),ratio:T,state:Ui(T,.96,.88)},{id:"npu",label:"NPU",value:A!==void 0?_r(A):H!==void 0?`${Math.round(H)} TOPS`:"-",detail:D||(H!==void 0?"neural engine":"not reported"),ratio:A,state:Ui(A,.96,.86)},{id:"temp",label:"TEMP",value:v===void 0?"-":`${Math.round(v)}C`,detail:J>0?`${J} local tools`:`uptime ${jw(Bt(a,"uptimeSec"))}`,ratio:W,state:v===void 0?"unknown":v>=86?"critical":v>=78?"warn":"good"},{id:"network",label:"NET",value:qm(B)||(L!==void 0?`${Math.round(L)}ms`:ue||"-"),detail:qm(q)?`${qm(q)} up`:ue||"not reported",ratio:F,state:L!==void 0&&L>=200?"critical":L!==void 0&&L>=80?"warn":Ui(F,.9,.75)}];return{state:R,label:kA(R,he,Q),role:ce,taskLabel:se||(Q==="idle"?"idle":Q),taskStatus:Q,taskSummary:oe,tools:z?K:K.map($=>({...$,detail:"not reported"})),metrics:he}}function AA({size:n=22}){return l.jsxs("svg",{width:n,height:n,viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[l.jsx("rect",{x:"2.5",y:"4",width:"14",height:"9",rx:"1.5",stroke:"currentColor",strokeWidth:"1.7",opacity:"0.42"}),l.jsx("path",{d:"M7 16v1.5h5",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",opacity:"0.42"}),l.jsx("rect",{x:"10.5",y:"2.5",width:"14",height:"9",rx:"1.5",stroke:"currentColor",strokeWidth:"1.7",opacity:"0.62"}),l.jsx("path",{d:"M15 14.5V16h5",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",opacity:"0.62"}),l.jsx("rect",{x:"6.5",y:"8.5",width:"15",height:"10",rx:"1.7",fill:"currentColor",fillOpacity:"0.12",stroke:"currentColor",strokeWidth:"1.9"}),l.jsx("path",{d:"M12 21v1.5H9.5M16 21v1.5h2.5M9.5 22.5h9",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round"})]})}const NA=[{id:"small",label:"Small"},{id:"medium",label:"Medium"},{id:"large",label:"Large"}],TA=[{id:"wall",label:"Wall",icon:cc,accent:"blue"},{id:"control",label:"Control",icon:ed,accent:"red"},{id:"share-files",label:"Share Files",icon:Ju,accent:"green"},{id:"agents",label:"Agents",icon:Ko,accent:"violet"},{id:"sync-server",label:"Sync Server",icon:td,accent:"blue"}],RA=[{id:"doc",label:"Doc",icon:Vm,accent:"amber"},{id:"pricing",label:"Pricing",icon:Wo,accent:"green"}];function EA(n){return n.replaceAll("npx -y @livedesk/client","npx -y --prefer-online livedesk@latest client").replaceAll("npx @livedesk/client","npx -y --prefer-online livedesk@latest client").replaceAll("npx -y livedesk client","npx -y --prefer-online livedesk@latest client").replaceAll("npx livedesk client","npx -y --prefer-online livedesk@latest client").replaceAll("npx -y livedesk","npx -y --prefer-online livedesk@latest").replaceAll("npx livedesk","npx -y --prefer-online livedesk@latest")}function Ft(n){return EA(n).replace(/\bRemoteHub\b/g,"Hub client endpoint").replace(/\bManagers\b/g,"Hubs").replace(/\bManager\b/g,"Hub").replace(/\bmanager\b/g,"Hub").replace(/\bMANAGER\b/g,"HUB").replace(/매니저/g,"Hub")}function Pi(n){return n.map(a=>Ft(a))}function On(n){return{languageName:n.languageName,languageLabel:n.languageLabel,eyebrow:n.eyebrow,title:Ft(n.title),intro:Ft(n.intro),sections:[{title:Ft(n.managerTitle),body:Ft(n.managerBody),points:Pi(n.managerPoints)},{title:Ft(n.clientTitle),body:Ft(n.clientBody),points:Pi(n.clientPoints)},{title:Ft(n.syncTitle),body:Ft(n.syncBody),points:Pi(n.syncPoints)},...n.agentTitle&&n.agentBody&&n.agentPoints?[{title:Ft(n.agentTitle),body:Ft(n.agentBody),points:Pi(n.agentPoints)}]:[],{title:Ft(n.platformTitle),body:Ft(n.platformBody),points:Pi(n.platformPoints)}],sync:{title:Ft(n.syncTitle),body:Ft(n.syncBody),points:Pi(n.syncPoints)},firewall:{title:Ft(n.firewallTitle),body:Ft(n.firewallBody),points:Pi(n.firewallPoints)},commands:{title:Ft(n.commandsTitle),body:Ft(n.commandsBody),manager:Ft(n.managerCommandLabel),primary:Ft(n.clientCommandLabel),slot:Ft(n.slotCommandLabel),manual:Ft(n.manualCommandLabel)}}}const Fr={ko:On({languageName:"한국어",languageLabel:"문서 언어",eyebrow:"LiveDesk Manual",title:"한 줄로 여는 로컬 Screen Wall",intro:"LiveDesk는 매니저 PC 한 대에서 여러 작업 PC, AI 박스, 맥미니, 개발 장비를 한 화면에 모니터링하고 필요한 제어를 실행하는 npm-first 원격 작업 데크입니다.",managerTitle:"1. 매니저 실행",managerBody:"화면을 모아 볼 컴퓨터에서 LiveDesk 매니저를 실행합니다. 매니저는 UI와 로컬 서버를 같이 열고 브라우저를 http://127.0.0.1:5179 로 띄웁니다.",managerPoints:["명령은 npx -y livedesk 입니다.","매니저는 Screen Wall/API 포트 5179와 클라이언트 접속 포트 5197을 사용합니다.","기존 LiveDesk 포트가 남아 있으면 기본적으로 정리하고 새로 시작합니다. 필요하면 --no-clean 을 붙입니다."],clientTitle:"2. 워크스테이션 연결",clientBody:"모니터링할 PC에서는 Google 로그인 또는 Hub 화면의 6자리 PIN으로 연결합니다. Hub가 켜져 있지 않아도 클라이언트는 종료하지 않고 5초마다 계속 찾습니다.",clientPoints:["빈 자리에 자동 배치하려면 npx -y livedesk client 를 실행합니다.","자리 번호를 고정하려면 npx -y livedesk client 3 처럼 번호를 붙입니다.","브라우저 연결 페이지에서 Google 버튼 또는 6자리 PIN 입력 중 하나를 선택합니다."],syncTitle:"3. Sync Server와 자동 발견",syncBody:"Sync Server는 이 매니저를 현재 계정의 활성 Screen Wall로 Supabase에 등록합니다. 클라이언트는 같은 Google 계정으로 로그인한 뒤 그 기록을 읽고 접속 후보들을 순서대로 시도합니다.",syncPoints:["등록 정보에는 host instance, LAN/private 주소, public 후보 주소, pair token, 짧은 lease가 포함됩니다.","같은 LAN 후보를 먼저 쓰고, 필요하면 외부 주소 후보를 시도합니다.","매니저 위치, VPN, 방화벽, 공유기 설정이 바뀌었거나 개발 중 활성 매니저를 바꿀 때 Sync Server를 누릅니다.","이제 livedesk.pages.dev의 Chrome Local Network Access 허용은 기본 실행 경로가 아닙니다. npm 매니저 앱이 실제 서버입니다."],agentTitle:"4. Agent로 여러 장비 작업하기",agentBody:"Agents 화면은 Hub에서 실행되는 Codex 기반 Agent가 연결된 장비를 확인하고, 선택한 권한 범위 안에서 작업을 실행하는 공간입니다. 클라이언트 PC에 Codex 앱이나 Codex SDK를 설치할 필요는 없습니다.",agentPoints:["Suggested tasks에는 현재 72개의 읽기·운영 작업 템플릿이 있으며, 검색과 권한·플랫폼·capability 조건으로 실행 가능 항목을 안내합니다.","Ask, Safe Auto, Full Access, Custom 권한 모드를 선택할 수 있습니다. 위험한 변경 작업은 승인 카드와 장비 capability 검사를 거칩니다.","All connected 또는 Selected로 대상 장비를 제한하고, 결과는 장비별 상태 칩과 실제 RAM·디스크·GPU·프로세스 요약으로 확인합니다.","Agent 실행은 Hub의 격리된 runtime과 LiveDesk MCP 도구를 통해서만 장비에 전달되며, 모든 작업은 timeout·취소·tool limit·감사 로그 경계를 가집니다."],platformTitle:"5. 현재 플랫폼과 스트림 상태",platformBody:"Windows의 Wall, Control, 파일 전송, 원격 오디오와 RemoteFast 경로를 현재 기준으로 확인했습니다. macOS와 Linux는 같은 npm 명령 경로를 유지하면서 권한과 캡처 백엔드를 확장하고 있습니다.",platformPoints:["Wall은 Mode 4 H.264 Atlas와 Mode 2 LZO 경로를 제공하고, Control은 Mode 3 H.264 또는 Mode 5 LZO tile delta를 사용합니다.","원격 오디오는 선택한 장비가 capability를 광고할 때 사용할 수 있으며, 브라우저는 queue·drop·resync·automatic restart 상태를 진단합니다.","macOS: 화면 캡처와 제어에는 Screen Recording/Accessibility 권한이 필요합니다. RemoteFast 로그는 필요한 상태 중심으로 제한됩니다.","Linux: linux-x64 runtime, grim/gnome-screenshot/import/scrot 캡처, xdotool 입력 백엔드가 추가되었습니다. 오디오는 아직 비활성입니다."],firewallTitle:"방화벽과 외부 장소 연결",firewallBody:"같은 LAN 안에서는 보통 공유기 포트포워딩이 필요 없습니다. 다른 장소의 PC를 붙이려면 클라이언트가 매니저의 클라이언트 접속 포트에 도달할 수 있어야 합니다.",firewallPoints:["클라이언트 접속 포트는 TCP 5197입니다.","클라이언트 쪽은 나가는 연결이므로 보통 인바운드 포트 개방이 필요 없습니다.","다른 네트워크에서 붙일 때는 매니저 PC 방화벽에서 TCP 5197 인바운드를 허용하고, 공유기에서는 TCP 5197을 매니저 PC로 전달합니다.","Screen Wall/API 포트 5179는 매니저 UI용입니다. 외부 브라우저에서 Wall을 직접 열 필요가 있을 때만 별도로 노출을 검토합니다.","공개 인터넷에 바로 열기보다 VPN, Tailscale, ZeroTier, 고정 IP allowlist를 우선합니다."],commandsTitle:"현재 사용 명령",commandsBody:"웹사이트를 찾아가 설치 파일을 받는 방식보다 터미널 한 줄로 모든 운영체제에서 거의 같은 흐름을 쓰는 것이 LiveDesk의 기본 방향입니다.",managerCommandLabel:"매니저 시작",clientCommandLabel:"워크스테이션 연결",slotCommandLabel:"3번 슬롯에 고정",manualCommandLabel:"고급 수동 연결"}),en:On({languageName:"English",languageLabel:"Document language",eyebrow:"LiveDesk Manual",title:"Open a local Screen Wall with one command",intro:"LiveDesk is an npm-first remote work deck for monitoring many workstations, AI boxes, Mac minis, and dev machines from one manager PC.",managerTitle:"1. Run the manager",managerBody:"Run LiveDesk on the computer that will watch the screens. The manager starts the UI and local server together, then opens http://127.0.0.1:5179.",managerPoints:["The command is npx -y livedesk.","The manager uses port 5179 for the Screen Wall/API and port 5197 for client connections.","If an old LiveDesk process still owns those ports, startup cleans it by default. Add --no-clean when you want to keep it."],clientTitle:"2. Connect a workstation",clientBody:"On each monitored computer, connect with Google sign-in or the 6-digit PIN shown on the Hub screen. If no manager is online yet, the client keeps running and retries every 5 seconds.",clientPoints:["Run npx -y livedesk client for first available placement.","Run npx -y livedesk client 3 to pin the machine to slot 3.","The browser connection page lets you choose Google or a 6-digit PIN."],syncTitle:"3. Sync Server and discovery",syncBody:"Sync Server publishes this manager as the active Screen Wall for the signed-in account. Clients read that Supabase record after Google sign-in and try the endpoint candidates in order.",syncPoints:["The record includes host instance, LAN/private addresses, public endpoint candidates, pair token, and a short lease.","LAN candidates are preferred first, then public candidates if needed.","Press Sync Server after manager moves, VPN/firewall/router changes, or when this development machine should take over as active manager.","Chrome Local Network Access on livedesk.pages.dev is no longer the default runtime path. The npm manager app is the real server."],agentTitle:"4. Run multi-workstation tasks with Agent",agentBody:"The Agents page runs a Codex-based Agent in the Hub to inspect connected workstations and perform actions within the selected permission scope. Client PCs do not need the Codex app or Codex SDK installed.",agentPoints:["Suggested tasks currently contains 72 read-only and operational templates with search plus permission, platform, and capability availability checks.","Choose Ask, Safe Auto, Full Access, or Custom. Risky changes go through approval cards and explicit client capability checks.","Limit targets with All connected or Selected. Results use compact per-device status chips and show real RAM, disk, GPU, and process summaries.","Runs stay inside the Hub-isolated runtime and LiveDesk MCP tools, with timeout, cancellation, tool-call limits, and audit-log boundaries."],platformTitle:"5. Current platform and stream state",platformBody:"Windows Wall, Control, file transfer, remote audio, and the RemoteFast path are verified against the current implementation. macOS and Linux keep the same npm command path while capture and permission backends expand.",platformPoints:["Wall provides Mode 4 H.264 Atlas and Mode 2 LZO paths. Control provides Mode 3 H.264 or Mode 5 LZO tile delta.","Remote audio is available when the selected workstation advertises the capability, with queue, drop, resync, and automatic-restart diagnostics in the browser.","macOS requires Screen Recording and Accessibility permissions for capture and control. RemoteFast logs focus on actionable state.","Linux includes the linux-x64 runtime, grim/gnome-screenshot/import/scrot capture, and xdotool input backend. Audio is still disabled."],firewallTitle:"Firewall and remote locations",firewallBody:"On the same LAN, router forwarding is usually unnecessary. For another office, building, or country, clients must be able to reach the manager client port.",firewallPoints:["Client connection port: TCP 5197.","Client machines normally only need outbound access.","For remote networks, allow inbound TCP 5197 on the manager firewall and forward TCP 5197 from the router to the manager PC.","Screen Wall/API port 5179 is for the manager UI. Expose it only if a remote browser must open the Wall directly.","Prefer VPN, Tailscale, ZeroTier, or fixed-IP allowlists over public internet exposure."],commandsTitle:"Current commands",commandsBody:"The product direction is one terminal command across operating systems instead of finding a website, downloading, and installing manually.",managerCommandLabel:"Start manager",clientCommandLabel:"Connect workstation",slotCommandLabel:"Pin to slot 3",manualCommandLabel:"Advanced manual connection"}),ja:On({languageName:"日本語",languageLabel:"ドキュメント言語",eyebrow:"LiveDesk Manual",title:"1行でローカル Screen Wall を開く",intro:"LiveDesk は、複数の作業 PC、AI マシン、Mac mini、開発機を1台の manager PC から監視する npm-first のリモート作業デッキです。",managerTitle:"1. manager を実行",managerBody:"画面を集めて見るコンピューターで LiveDesk manager を実行します。UI とローカルサーバーが同時に起動し、http://127.0.0.1:5179 が開きます。",managerPoints:["コマンドは npx -y livedesk です。","Screen Wall/API は 5179、client 接続は 5197 を使います。","古い LiveDesk プロセスがポートを使っている場合は、基本的に自動で整理して起動します。"],clientTitle:"2. workstation を接続",clientBody:"監視される PC で同じ Google アカウントにログインします。manager がまだ無くても client は終了せず、5秒ごとに再試行します。",clientPoints:["空きスロットに入れるには npx -y livedesk client を実行します。","スロットを固定するには npx -y livedesk client 3 のように番号を付けます。","大量の PC でも再ログインなしで待ち続けます。"],syncTitle:"3. Sync Server と自動検出",syncBody:"Sync Server はこの manager を現在の Google アカウントの active Screen Wall として Supabase に登録します。",syncPoints:["host instance、LAN/private アドレス、public 候補、pair token、短い lease を登録します。","client は LAN 候補を優先し、必要なら public 候補も試します。","VPN、firewall、router、manager の場所が変わったら Sync Server を押します。","livedesk.pages.dev の Chrome Local Network Access は標準実行経路ではありません。npm manager アプリが実際のサーバーです。"],platformTitle:"4. 現在のプラットフォーム状態",platformBody:"Windows は live screen transfer まで確認済みです。macOS と Linux も同じ npm コマンド経路を目標に対応を広げています。",platformPoints:["Windows: 動作確認済み。","macOS: 画面取得と制御には Screen Recording/Accessibility 権限が必要です。","Linux: linux-x64 runtime、grim/gnome-screenshot/import/scrot capture、xdotool input backend を追加済み。audio は未対応です。"],firewallTitle:"Firewall と外部拠点",firewallBody:"同じ LAN なら通常 router forwarding は不要です。外部拠点では client が manager の接続ポートへ到達できる必要があります。",firewallPoints:["client 接続ポートは TCP 5197 です。","client 側は通常 outbound だけで足ります。","外部 network では manager PC の firewall で TCP 5197 inbound を許可し、router から manager PC へ forward します。","5179 は manager UI 用なので、外部ブラウザで Wall を開く必要がある時だけ公開を検討します。","公開 internet より VPN、Tailscale、ZeroTier、IP allowlist を優先してください。"],commandsTitle:"現在のコマンド",commandsBody:"Web サイトから installer を探すより、OS をまたいで terminal 1行で動かす方向です。",managerCommandLabel:"manager 起動",clientCommandLabel:"workstation 接続",slotCommandLabel:"slot 3 に固定",manualCommandLabel:"高度な手動接続"}),"zh-CN":On({languageName:"简体中文",languageLabel:"文档语言",eyebrow:"LiveDesk Manual",title:"用一条命令打开本地 Screen Wall",intro:"LiveDesk 是 npm-first 的远程工作台,用一台 manager PC 监控多台工作站、AI 主机、Mac mini 和开发机器。",managerTitle:"1. 运行 manager",managerBody:"在负责查看屏幕的电脑上运行 LiveDesk manager。它会同时启动 UI 和本地服务器,并打开 http://127.0.0.1:5179。",managerPoints:["命令是 npx -y livedesk。","Screen Wall/API 使用 5179,client 连接使用 5197。","如果旧的 LiveDesk 进程占用端口,默认会清理后重新启动。"],clientTitle:"2. 连接 workstation",clientBody:"在被监控的电脑上使用同一个 Google 账号登录。即使 manager 还没在线,client 也会继续运行并每 5 秒重试。",clientPoints:["自动放入空位: npx -y livedesk client。","固定到 3 号位置: npx -y livedesk client 3。","大量电脑也可以持续等待,不需要反复登录。"],syncTitle:"3. Sync Server 和自动发现",syncBody:"Sync Server 会把当前 manager 作为该账号的 active Screen Wall 写入 Supabase。client 登录后读取记录并依次尝试连接候选地址。",syncPoints:["记录包括 host instance、LAN/private 地址、public 候选、pair token 和短 lease。","优先尝试同一 LAN 地址,需要时再尝试外部地址。","manager 位置、VPN、防火墙或路由变化后请点击 Sync Server。","livedesk.pages.dev 的 Chrome Local Network Access 不再是默认运行方式。npm manager app 才是真正服务器。"],platformTitle:"4. 当前平台状态",platformBody:"Windows 已确认可传输实时画面。macOS 和 Linux 正按同一 npm 命令路径扩展支持。",platformPoints:["Windows: 已确认可用。","macOS: 画面捕获和控制需要 Screen Recording/Accessibility 权限。","Linux: 已加入 linux-x64 runtime、grim/gnome-screenshot/import/scrot 捕获、xdotool 输入后端。音频尚未启用。"],firewallTitle:"防火墙和外部地点",firewallBody:"同一 LAN 通常不需要路由端口转发。不同地点连接时,client 必须能访问 manager 的 client 连接端口。",firewallPoints:["client 连接端口是 TCP 5197。","client 机器通常只需要出站访问。","跨网络时,在 manager 防火墙放行 TCP 5197 入站,并在路由器转发到 manager PC。","5179 是 manager UI 端口,仅在需要远程浏览器直接打开 Wall 时考虑暴露。","优先使用 VPN、Tailscale、ZeroTier 或固定 IP allowlist。"],commandsTitle:"当前命令",commandsBody:"产品方向是跨操作系统使用一条终端命令,而不是先找网站、下载、安装。",managerCommandLabel:"启动 manager",clientCommandLabel:"连接 workstation",slotCommandLabel:"固定到 slot 3",manualCommandLabel:"高级手动连接"}),"zh-TW":On({languageName:"繁體中文",languageLabel:"文件語言",eyebrow:"LiveDesk Manual",title:"用一行指令開啟本機 Screen Wall",intro:"LiveDesk 是 npm-first 的遠端工作台,用一台 manager PC 監看多台工作站、AI 主機、Mac mini 與開發機。",managerTitle:"1. 執行 manager",managerBody:"在負責看畫面的電腦上執行 LiveDesk manager。它會同時啟動 UI 與本機伺服器,並開啟 http://127.0.0.1:5179。",managerPoints:["指令是 npx -y livedesk。","Screen Wall/API 使用 5179,client 連線使用 5197。","若舊的 LiveDesk 程序占用連接埠,預設會清理後重新啟動。"],clientTitle:"2. 連接 workstation",clientBody:"在被監看的電腦上使用同一個 Google 帳號登入。即使 manager 尚未上線,client 也會持續執行並每 5 秒重試。",clientPoints:["自動放入空位: npx -y livedesk client。","固定到 3 號位置: npx -y livedesk client 3。","大量電腦也能持續等待,不需要反覆登入。"],syncTitle:"3. Sync Server 與自動探索",syncBody:"Sync Server 會把目前 manager 登錄為此帳號的 active Screen Wall。client 登入後讀取 Supabase 記錄並依序嘗試連線候選地址。",syncPoints:["記錄包含 host instance、LAN/private 位址、public 候選、pair token 與短 lease。","優先嘗試 LAN 位址,需要時再嘗試外部位址。","manager 位置、VPN、防火牆或路由設定改變後請按 Sync Server。","livedesk.pages.dev 的 Chrome Local Network Access 不再是預設執行路徑。npm manager app 才是真正伺服器。"],platformTitle:"4. 目前平台狀態",platformBody:"Windows 已確認可傳輸即時畫面。macOS 與 Linux 也沿用相同 npm 指令路徑擴充支援。",platformPoints:["Windows: 已確認可用。","macOS: 畫面擷取與控制需要 Screen Recording/Accessibility 權限。","Linux: 已加入 linux-x64 runtime、grim/gnome-screenshot/import/scrot capture、xdotool input backend。音訊尚未啟用。"],firewallTitle:"防火牆與外部地點",firewallBody:"同一 LAN 通常不需要路由器轉發。不同地點連線時,client 必須能到達 manager 的 client 連線埠。",firewallPoints:["client 連線埠是 TCP 5197。","client 電腦通常只需要對外連線。","跨網路時,請在 manager 防火牆允許 TCP 5197 inbound,並從路由器轉發到 manager PC。","5179 是 manager UI 連接埠,只在需要遠端瀏覽器直接打開 Wall 時才考慮公開。","優先使用 VPN、Tailscale、ZeroTier 或固定 IP allowlist。"],commandsTitle:"目前指令",commandsBody:"產品方向是跨作業系統用一行 terminal 指令,而不是先找網站、下載、安裝。",managerCommandLabel:"啟動 manager",clientCommandLabel:"連接 workstation",slotCommandLabel:"固定到 slot 3",manualCommandLabel:"進階手動連線"}),es:On({languageName:"Español",languageLabel:"Idioma del documento",eyebrow:"LiveDesk Manual",title:"Abre un Screen Wall local con un comando",intro:"LiveDesk es una consola npm-first para vigilar muchas estaciones, cajas de IA, Mac mini y equipos de desarrollo desde un PC manager.",managerTitle:"1. Ejecuta el manager",managerBody:"Ejecuta LiveDesk en el equipo que verá las pantallas. El manager inicia la UI y el servidor local juntos y abre http://127.0.0.1:5179.",managerPoints:["El comando es npx -y livedesk.","El manager usa 5179 para Screen Wall/API y 5197 para conexiones client.","Si un proceso antiguo ocupa los puertos, el arranque lo limpia por defecto."],clientTitle:"2. Conecta una workstation",clientBody:"En cada equipo monitoreado, inicia sesión con la misma cuenta Google. Si el manager aún no está activo, el client sigue intentando cada 5 segundos.",clientPoints:["Usa npx -y livedesk client para el primer slot libre.","Usa npx -y livedesk client 3 para fijar el equipo al slot 3.","Los clients siguen esperando para no repetir login en muchas máquinas."],syncTitle:"3. Sync Server y descubrimiento",syncBody:"Sync Server publica este manager como Screen Wall activo para la cuenta. Los clients leen el registro en Supabase y prueban los endpoints.",syncPoints:["Incluye host instance, direcciones LAN/private, candidatos public, pair token y lease corto.","Primero se prueban candidatos LAN, luego públicos si hace falta.","Pulsa Sync Server después de cambios de manager, VPN, firewall o router.","Chrome Local Network Access en livedesk.pages.dev ya no es el flujo principal. La app npm manager es el servidor real."],platformTitle:"4. Estado de plataformas",platformBody:"Windows ya fue verificado con transferencia de pantalla. macOS y Linux siguen el mismo camino npm.",platformPoints:["Windows: verificado.","macOS: captura y control requieren permisos Screen Recording/Accessibility.","Linux: agregado linux-x64 runtime, captura grim/gnome-screenshot/import/scrot y entrada xdotool. Audio aún desactivado."],firewallTitle:"Firewall y sedes remotas",firewallBody:"En la misma LAN normalmente no hace falta port forwarding. Para otra red, los clients deben llegar al puerto client del manager.",firewallPoints:["Puerto de conexión client: TCP 5197.","Los equipos client normalmente solo necesitan salida.","Para redes remotas, permite TCP 5197 inbound en el manager y reenvía TCP 5197 al PC manager.","El puerto 5179 es para la UI del manager; expónlo solo si un navegador remoto debe abrir el Wall.","Prefiere VPN, Tailscale, ZeroTier o allowlist de IP fijas."],commandsTitle:"Comandos actuales",commandsBody:"La dirección del producto es un comando de terminal común entre sistemas, no descargar e instalar desde una web.",managerCommandLabel:"Iniciar manager",clientCommandLabel:"Conectar workstation",slotCommandLabel:"Fijar al slot 3",manualCommandLabel:"Conexión manual avanzada"}),fr:On({languageName:"Français",languageLabel:"Langue du document",eyebrow:"LiveDesk Manual",title:"Ouvrir un Screen Wall local en une commande",intro:"LiveDesk est un deck npm-first pour surveiller plusieurs postes, machines IA, Mac mini et machines dev depuis un PC manager.",managerTitle:"1. Lancer le manager",managerBody:"Lancez LiveDesk sur l’ordinateur qui observe les écrans. Le manager démarre l’UI et le serveur local, puis ouvre http://127.0.0.1:5179.",managerPoints:["La commande est npx -y livedesk.","Le manager utilise 5179 pour Screen Wall/API et 5197 pour les connexions client.","Si un ancien processus utilise les ports, le démarrage le nettoie par défaut."],clientTitle:"2. Connecter une workstation",clientBody:"Sur chaque ordinateur surveillé, connectez-vous avec le même compte Google. Si le manager n’est pas encore actif, le client réessaie toutes les 5 secondes.",clientPoints:["Utilisez npx -y livedesk client pour le premier slot libre.","Utilisez npx -y livedesk client 3 pour fixer la machine au slot 3.","Les clients continuent d’attendre pour éviter les reconnexions répétées."],syncTitle:"3. Sync Server et découverte",syncBody:"Sync Server publie ce manager comme Screen Wall actif du compte. Les clients lisent l’enregistrement Supabase et testent les endpoints.",syncPoints:["Il contient host instance, adresses LAN/private, candidats public, pair token et lease court.","Les candidats LAN sont essayés en premier, puis les candidats publics si besoin.","Cliquez Sync Server après un changement de manager, VPN, firewall ou routeur.","Chrome Local Network Access sur livedesk.pages.dev n’est plus le chemin par défaut. L’app npm manager est le vrai serveur."],platformTitle:"4. État des plateformes",platformBody:"Windows est vérifié avec transfert d’écran live. macOS et Linux suivent le même chemin npm.",platformPoints:["Windows: vérifié.","macOS: capture et contrôle nécessitent Screen Recording/Accessibility.","Linux: runtime linux-x64, capture grim/gnome-screenshot/import/scrot et entrée xdotool ajoutés. Audio désactivé."],firewallTitle:"Firewall et sites distants",firewallBody:"Sur le même LAN, le port forwarding est rarement nécessaire. Depuis un autre réseau, les clients doivent atteindre le port client du manager.",firewallPoints:["Port de connexion client: TCP 5197.","Les machines client ont normalement seulement besoin de sortie réseau.","Pour un réseau distant, autorisez TCP 5197 entrant sur le manager et redirigez TCP 5197 vers le PC manager.","Le port 5179 sert à l’UI manager; exposez-le seulement si un navigateur distant doit ouvrir le Wall.","Préférez VPN, Tailscale, ZeroTier ou allowlist IP fixes."],commandsTitle:"Commandes actuelles",commandsBody:"La direction produit est une commande terminal commune aux OS, plutôt qu’un téléchargement manuel depuis un site.",managerCommandLabel:"Démarrer manager",clientCommandLabel:"Connecter workstation",slotCommandLabel:"Fixer au slot 3",manualCommandLabel:"Connexion manuelle avancée"}),de:On({languageName:"Deutsch",languageLabel:"Dokumentsprache",eyebrow:"LiveDesk Manual",title:"Lokale Screen Wall mit einem Befehl öffnen",intro:"LiveDesk ist ein npm-first Arbeitsdeck, um viele Workstations, AI-Boxen, Mac minis und Dev-Rechner von einem Manager-PC zu überwachen.",managerTitle:"1. Manager starten",managerBody:"Starte LiveDesk auf dem Computer, der die Screens sieht. Der Manager startet UI und lokalen Server zusammen und öffnet http://127.0.0.1:5179.",managerPoints:["Der Befehl ist npx -y livedesk.","Der Manager nutzt 5179 für Screen Wall/API und 5197 für Client-Verbindungen.","Wenn alte LiveDesk-Prozesse Ports belegen, werden sie beim Start standardmäßig bereinigt."],clientTitle:"2. Workstation verbinden",clientBody:"Melde dich auf jedem überwachten Computer mit demselben Google-Konto an. Wenn kein Manager online ist, versucht der Client alle 5 Sekunden weiter.",clientPoints:["npx -y livedesk client nutzt den ersten freien Slot.","npx -y livedesk client 3 fixiert den Rechner auf Slot 3.","Clients warten weiter, damit große Setups kein wiederholtes Login brauchen."],syncTitle:"3. Sync Server und Discovery",syncBody:"Sync Server veröffentlicht diesen Manager als aktive Screen Wall des Kontos. Clients lesen den Supabase-Eintrag und testen Endpoints der Reihe nach.",syncPoints:["Enthält host instance, LAN/private Adressen, public Kandidaten, pair token und kurze lease.","LAN-Kandidaten werden zuerst versucht, danach public Kandidaten.","Nach Änderungen an Manager, VPN, Firewall oder Router Sync Server drücken.","Chrome Local Network Access auf livedesk.pages.dev ist nicht mehr der Standardpfad. Die npm Manager App ist der echte Server."],platformTitle:"4. Plattformstatus",platformBody:"Windows wurde mit Live-Screen-Transfer geprüft. macOS und Linux folgen demselben npm-Pfad.",platformPoints:["Windows: verifiziert.","macOS: Capture und Control brauchen Screen Recording/Accessibility Rechte.","Linux: linux-x64 Runtime, grim/gnome-screenshot/import/scrot Capture und xdotool Input Backend sind ergänzt. Audio ist deaktiviert."],firewallTitle:"Firewall und entfernte Standorte",firewallBody:"Im gleichen LAN ist Router-Forwarding meist unnötig. Aus anderen Netzwerken müssen Clients den Client-Port des Managers erreichen.",firewallPoints:["Client-Verbindungsport: TCP 5197.","Client-Rechner brauchen normalerweise nur ausgehenden Zugriff.","Für entfernte Netzwerke TCP 5197 inbound am Manager erlauben und vom Router zum Manager-PC forwarden.","Port 5179 ist für die Manager-UI; nur öffnen, wenn ein Remote-Browser die Wall direkt öffnen muss.","VPN, Tailscale, ZeroTier oder feste IP-Allowlists bevorzugen."],commandsTitle:"Aktuelle Befehle",commandsBody:"Die Produktlinie ist ein Terminalbefehl über Betriebssysteme hinweg, statt Website suchen, herunterladen und installieren.",managerCommandLabel:"Manager starten",clientCommandLabel:"Workstation verbinden",slotCommandLabel:"An Slot 3 fixieren",manualCommandLabel:"Erweiterte manuelle Verbindung"}),"pt-BR":On({languageName:"Português",languageLabel:"Idioma do documento",eyebrow:"LiveDesk Manual",title:"Abra um Screen Wall local com um comando",intro:"LiveDesk é um deck npm-first para monitorar várias estações, caixas de IA, Mac minis e máquinas dev a partir de um PC manager.",managerTitle:"1. Execute o manager",managerBody:"Rode LiveDesk no computador que verá as telas. O manager inicia a UI e o servidor local juntos e abre http://127.0.0.1:5179.",managerPoints:["O comando é npx -y livedesk.","O manager usa 5179 para Screen Wall/API e 5197 para conexões client.","Se um processo antigo ocupa as portas, a inicialização limpa por padrão."],clientTitle:"2. Conecte uma workstation",clientBody:"Em cada computador monitorado, entre com a mesma conta Google. Se o manager ainda não estiver online, o client tenta a cada 5 segundos.",clientPoints:["Use npx -y livedesk client para o primeiro slot livre.","Use npx -y livedesk client 3 para fixar no slot 3.","Clients continuam tentando para evitar login repetido em muitos PCs."],syncTitle:"3. Sync Server e descoberta",syncBody:"Sync Server publica este manager como Screen Wall ativo da conta. Clients leem o registro no Supabase e testam endpoints.",syncPoints:["Inclui host instance, endereços LAN/private, candidatos public, pair token e lease curto.","Candidatos LAN vêm primeiro; public depois se necessário.","Clique Sync Server após mudanças de manager, VPN, firewall ou roteador.","Chrome Local Network Access em livedesk.pages.dev não é mais o caminho padrão. O app npm manager é o servidor real."],platformTitle:"4. Estado das plataformas",platformBody:"Windows foi verificado com transferência de tela. macOS e Linux seguem o mesmo caminho npm.",platformPoints:["Windows: verificado.","macOS: captura e controle precisam de permissões Screen Recording/Accessibility.","Linux: runtime linux-x64, captura grim/gnome-screenshot/import/scrot e entrada xdotool adicionados. Áudio ainda desativado."],firewallTitle:"Firewall e locais remotos",firewallBody:"Na mesma LAN normalmente não é preciso port forwarding. Em outra rede, clients precisam alcançar a porta client do manager.",firewallPoints:["Porta client: TCP 5197.","Máquinas client normalmente só precisam de saída.","Para redes remotas, permita TCP 5197 inbound no manager e encaminhe TCP 5197 para o PC manager.","A porta 5179 é para a UI do manager; exponha apenas se um navegador remoto precisar abrir o Wall.","Prefira VPN, Tailscale, ZeroTier ou allowlist de IP fixo."],commandsTitle:"Comandos atuais",commandsBody:"A direção do produto é um comando de terminal comum entre sistemas, não baixar e instalar manualmente.",managerCommandLabel:"Iniciar manager",clientCommandLabel:"Conectar workstation",slotCommandLabel:"Fixar no slot 3",manualCommandLabel:"Conexão manual avançada"}),it:On({languageName:"Italiano",languageLabel:"Lingua documento",eyebrow:"LiveDesk Manual",title:"Apri uno Screen Wall locale con un comando",intro:"LiveDesk è un deck npm-first per monitorare workstation, box AI, Mac mini e macchine dev da un solo PC manager.",managerTitle:"1. Avvia il manager",managerBody:"Esegui LiveDesk sul computer che guarderà gli schermi. Il manager avvia UI e server locale e apre http://127.0.0.1:5179.",managerPoints:["Il comando è npx -y livedesk.","Il manager usa 5179 per Screen Wall/API e 5197 per connessioni client.","Se vecchi processi occupano le porte, l’avvio le pulisce di default."],clientTitle:"2. Connetti una workstation",clientBody:"Su ogni computer monitorato, accedi con lo stesso account Google. Se il manager non è online, il client riprova ogni 5 secondi.",clientPoints:["npx -y livedesk client usa il primo slot libero.","npx -y livedesk client 3 fissa la macchina allo slot 3.","I client continuano a provare per evitare login ripetuti."],syncTitle:"3. Sync Server e discovery",syncBody:"Sync Server pubblica questo manager come Screen Wall attivo dell’account. I client leggono Supabase e provano gli endpoint.",syncPoints:["Include host instance, indirizzi LAN/private, candidati public, pair token e lease breve.","Prima LAN, poi public se necessario.","Premi Sync Server dopo cambi di manager, VPN, firewall o router.","Chrome Local Network Access su livedesk.pages.dev non è più il percorso principale. L’app npm manager è il server reale."],platformTitle:"4. Stato piattaforme",platformBody:"Windows è verificato con trasferimento schermo live. macOS e Linux seguono lo stesso percorso npm.",platformPoints:["Windows: verificato.","macOS: capture e control richiedono permessi Screen Recording/Accessibility.","Linux: aggiunti runtime linux-x64, capture grim/gnome-screenshot/import/scrot e input xdotool. Audio disattivato."],firewallTitle:"Firewall e sedi remote",firewallBody:"Nella stessa LAN di solito non serve port forwarding. Da altre reti, i client devono raggiungere la porta client del manager.",firewallPoints:["Porta client: TCP 5197.","I client normalmente richiedono solo uscita.","Per reti remote, abilita TCP 5197 inbound sul manager e inoltra TCP 5197 al PC manager.","La porta 5179 è per la UI manager; esponila solo se un browser remoto deve aprire il Wall.","Preferisci VPN, Tailscale, ZeroTier o IP allowlist."],commandsTitle:"Comandi attuali",commandsBody:"La direzione è un comando terminale comune tra sistemi operativi, invece di download e install manuale.",managerCommandLabel:"Avvia manager",clientCommandLabel:"Connetti workstation",slotCommandLabel:"Fissa allo slot 3",manualCommandLabel:"Connessione manuale avanzata"}),id:On({languageName:"Bahasa Indonesia",languageLabel:"Bahasa dokumen",eyebrow:"LiveDesk Manual",title:"Buka Screen Wall lokal dengan satu perintah",intro:"LiveDesk adalah deck npm-first untuk memantau banyak workstation, AI box, Mac mini, dan mesin dev dari satu PC manager.",managerTitle:"1. Jalankan manager",managerBody:"Jalankan LiveDesk di komputer yang melihat layar. Manager membuka UI dan server lokal bersama, lalu membuka http://127.0.0.1:5179.",managerPoints:["Perintahnya npx -y livedesk.","Manager memakai 5179 untuk Screen Wall/API dan 5197 untuk koneksi client.","Jika proses lama memakai port itu, startup membersihkannya secara default."],clientTitle:"2. Hubungkan workstation",clientBody:"Di komputer yang dipantau, masuk dengan akun Google yang sama. Jika manager belum online, client tetap mencoba tiap 5 detik.",clientPoints:["npx -y livedesk client memakai slot kosong pertama.","npx -y livedesk client 3 mengunci mesin ke slot 3.","Client terus mencoba agar banyak PC tidak perlu login berulang."],syncTitle:"3. Sync Server dan discovery",syncBody:"Sync Server menerbitkan manager ini sebagai Screen Wall aktif untuk akun. Client membaca Supabase dan mencoba endpoint.",syncPoints:["Berisi host instance, alamat LAN/private, kandidat public, pair token, dan lease pendek.","Kandidat LAN dicoba lebih dulu, lalu public jika perlu.","Tekan Sync Server setelah perubahan manager, VPN, firewall, atau router.","Chrome Local Network Access di livedesk.pages.dev bukan jalur utama lagi. App npm manager adalah server sebenarnya."],platformTitle:"4. Status platform",platformBody:"Windows sudah diverifikasi dengan live screen transfer. macOS dan Linux mengikuti jalur npm yang sama.",platformPoints:["Windows: terverifikasi.","macOS: capture dan control perlu izin Screen Recording/Accessibility.","Linux: runtime linux-x64, capture grim/gnome-screenshot/import/scrot, dan input xdotool sudah ditambahkan. Audio belum aktif."],firewallTitle:"Firewall dan lokasi luar",firewallBody:"Di LAN yang sama biasanya tidak perlu port forwarding. Dari jaringan lain, client harus mencapai port client manager.",firewallPoints:["Port client: TCP 5197.","Mesin client biasanya hanya perlu akses keluar.","Untuk jaringan luar, izinkan TCP 5197 inbound di manager dan forward TCP 5197 ke PC manager.","Port 5179 untuk UI manager; buka hanya jika browser luar harus membuka Wall.","Utamakan VPN, Tailscale, ZeroTier, atau IP allowlist."],commandsTitle:"Perintah saat ini",commandsBody:"Arah produk adalah satu perintah terminal lintas OS, bukan download dan instal manual.",managerCommandLabel:"Mulai manager",clientCommandLabel:"Hubungkan workstation",slotCommandLabel:"Kunci ke slot 3",manualCommandLabel:"Koneksi manual lanjutan"}),vi:On({languageName:"Tiếng Việt",languageLabel:"Ngôn ngữ tài liệu",eyebrow:"LiveDesk Manual",title:"Mở Screen Wall cục bộ bằng một lệnh",intro:"LiveDesk là deck npm-first để giám sát nhiều workstation, máy AI, Mac mini và máy dev từ một PC manager.",managerTitle:"1. Chạy manager",managerBody:"Chạy LiveDesk trên máy dùng để xem màn hình. Manager khởi động UI và server cục bộ cùng lúc, rồi mở http://127.0.0.1:5179.",managerPoints:["Lệnh là npx -y livedesk.","Manager dùng 5179 cho Screen Wall/API và 5197 cho kết nối client.","Nếu tiến trình cũ giữ port, startup mặc định sẽ dọn và khởi động lại."],clientTitle:"2. Kết nối workstation",clientBody:"Trên mỗi máy được giám sát, đăng nhập cùng tài khoản Google. Nếu manager chưa online, client tiếp tục thử mỗi 5 giây.",clientPoints:["npx -y livedesk client dùng slot trống đầu tiên.","npx -y livedesk client 3 ghim máy vào slot 3.","Client tiếp tục chờ để nhiều máy không cần đăng nhập lại."],syncTitle:"3. Sync Server và tự phát hiện",syncBody:"Sync Server đăng manager này là Screen Wall đang hoạt động của tài khoản. Client đọc Supabase và thử các endpoint.",syncPoints:["Bao gồm host instance, địa chỉ LAN/private, public candidate, pair token và lease ngắn.","Ưu tiên LAN trước, sau đó thử public nếu cần.","Bấm Sync Server sau thay đổi manager, VPN, firewall hoặc router.","Chrome Local Network Access trên livedesk.pages.dev không còn là đường chạy chính. App npm manager mới là server thật."],platformTitle:"4. Trạng thái nền tảng",platformBody:"Windows đã được kiểm chứng với truyền màn hình live. macOS và Linux đi theo cùng đường npm.",platformPoints:["Windows: đã kiểm chứng.","macOS: capture và control cần quyền Screen Recording/Accessibility.","Linux: đã thêm runtime linux-x64, capture grim/gnome-screenshot/import/scrot và input xdotool. Audio chưa bật."],firewallTitle:"Firewall và địa điểm ngoài",firewallBody:"Trong cùng LAN thường không cần port forwarding. Từ mạng khác, client phải truy cập được port client của manager.",firewallPoints:["Port client: TCP 5197.","Máy client thường chỉ cần kết nối outbound.","Với mạng ngoài, cho phép TCP 5197 inbound trên manager và forward TCP 5197 tới PC manager.","Port 5179 dành cho UI manager; chỉ mở nếu trình duyệt từ xa cần mở Wall trực tiếp.","Ưu tiên VPN, Tailscale, ZeroTier hoặc allowlist IP cố định."],commandsTitle:"Lệnh hiện tại",commandsBody:"Hướng sản phẩm là một lệnh terminal dùng chung giữa các OS, thay vì tải và cài thủ công.",managerCommandLabel:"Khởi động manager",clientCommandLabel:"Kết nối workstation",slotCommandLabel:"Ghim vào slot 3",manualCommandLabel:"Kết nối thủ công nâng cao"}),th:On({languageName:"ไทย",languageLabel:"ภาษาของเอกสาร",eyebrow:"LiveDesk Manual",title:"เปิด Screen Wall ภายในด้วยคำสั่งเดียว",intro:"LiveDesk คือ deck แบบ npm-first สำหรับดู workstation, กล่อง AI, Mac mini และเครื่อง dev หลายเครื่องจาก manager PC เครื่องเดียว",managerTitle:"1. รัน manager",managerBody:"รัน LiveDesk บนเครื่องที่ใช้ดูหน้าจอ Manager จะเปิด UI และ local server พร้อมกัน แล้วเปิด http://127.0.0.1:5179",managerPoints:["คำสั่งคือ npx -y livedesk","Manager ใช้ 5179 สำหรับ Screen Wall/API และ 5197 สำหรับ client connection","ถ้า process เก่ายังใช้ port อยู่ startup จะล้างให้โดย default"],clientTitle:"2. เชื่อม workstation",clientBody:"บนเครื่องที่ต้อง monitor ให้ login ด้วย Google account เดียวกัน ถ้า manager ยังไม่ออนไลน์ client จะลองใหม่ทุก 5 วินาที",clientPoints:["npx -y livedesk client จะใช้ slot ว่างแรก","npx -y livedesk client 3 จะตรึงเครื่องไว้ที่ slot 3","Client จะรอต่อเนื่องเพื่อไม่ต้อง login ซ้ำเมื่อมีหลายเครื่อง"],syncTitle:"3. Sync Server และ discovery",syncBody:"Sync Server จะ publish manager นี้เป็น active Screen Wall ของ account แล้ว client อ่านข้อมูลจาก Supabase และลอง endpoint ต่างๆ",syncPoints:["มี host instance, LAN/private address, public candidate, pair token และ short lease","ลอง LAN ก่อน แล้วค่อยลอง public ถ้าจำเป็น","กด Sync Server หลังเปลี่ยน manager, VPN, firewall หรือ router","Chrome Local Network Access บน livedesk.pages.dev ไม่ใช่ runtime หลักแล้ว app npm manager คือ server จริง"],platformTitle:"4. สถานะ platform",platformBody:"Windows ตรวจสอบแล้วว่าส่งภาพ live ได้ macOS และ Linux ใช้เส้นทาง npm เดียวกัน",platformPoints:["Windows: verified","macOS: capture/control ต้องใช้สิทธิ์ Screen Recording/Accessibility","Linux: เพิ่ม linux-x64 runtime, grim/gnome-screenshot/import/scrot capture และ xdotool input แล้ว audio ยังปิดอยู่"],firewallTitle:"Firewall และเครื่องต่างสถานที่",firewallBody:"ใน LAN เดียวกันปกติไม่ต้อง port forwarding ถ้าอยู่คนละ network client ต้องเข้าถึง client port ของ manager ได้",firewallPoints:["Client port คือ TCP 5197","เครื่อง client ปกติต้องการ outbound เท่านั้น","ถ้าอยู่นอก network ให้เปิด TCP 5197 inbound ที่ manager และ forward TCP 5197 ไปยัง manager PC","Port 5179 เป็น UI ของ manager เปิดเฉพาะเมื่อ browser ระยะไกลต้องเปิด Wall โดยตรง","ควรใช้ VPN, Tailscale, ZeroTier หรือ IP allowlist ก่อนเปิดสู่ public internet"],commandsTitle:"คำสั่งปัจจุบัน",commandsBody:"ทิศทาง product คือคำสั่ง terminal เดียวข้าม OS ไม่ใช่ download/install จากเว็บไซต์",managerCommandLabel:"เริ่ม manager",clientCommandLabel:"เชื่อม workstation",slotCommandLabel:"ตรึง slot 3",manualCommandLabel:"manual connection ขั้นสูง"}),hi:On({languageName:"हिन्दी",languageLabel:"दस्तावेज़ भाषा",eyebrow:"LiveDesk Manual",title:"एक कमांड से local Screen Wall खोलें",intro:"LiveDesk एक npm-first remote work deck है जिससे एक manager PC से कई workstation, AI box, Mac mini और dev machines देखे जा सकते हैं।",managerTitle:"1. manager चलाएं",managerBody:"जिस computer से screens देखनी हैं उस पर LiveDesk manager चलाएं। यह UI और local server साथ में शुरू करता है और http://127.0.0.1:5179 खोलता है।",managerPoints:["कमांड है npx -y livedesk।","Manager Screen Wall/API के लिए 5179 और client connections के लिए 5197 इस्तेमाल करता है।","अगर पुराने LiveDesk ports बचे हों तो startup default रूप से साफ करता है।"],clientTitle:"2. workstation जोड़ें",clientBody:"हर monitored computer पर उसी Google account से sign in करें। Manager online न हो तब भी client बंद नहीं होता और हर 5 सेकंड retry करता है।",clientPoints:["npx -y livedesk client पहला खाली slot लेता है।","npx -y livedesk client 3 machine को slot 3 पर pin करता है।","बहुत सी machines हों तब भी बार-बार login की जरूरत नहीं रहती।"],syncTitle:"3. Sync Server और discovery",syncBody:"Sync Server इस manager को account का active Screen Wall बनाकर Supabase में publish करता है। Clients record पढ़कर endpoints try करते हैं।",syncPoints:["इसमें host instance, LAN/private addresses, public candidates, pair token और short lease होता है।","LAN candidates पहले try होते हैं, जरूरत हो तो public candidates।","Manager, VPN, firewall या router बदलने के बाद Sync Server दबाएं।","livedesk.pages.dev का Chrome Local Network Access अब default runtime नहीं है। npm manager app ही real server है।"],platformTitle:"4. Platform status",platformBody:"Windows live screen transfer के साथ verified है। macOS और Linux भी इसी npm path पर आगे बढ़ रहे हैं।",platformPoints:["Windows: verified.","macOS: capture/control के लिए Screen Recording/Accessibility permissions चाहिए।","Linux: linux-x64 runtime, grim/gnome-screenshot/import/scrot capture और xdotool input backend जोड़े गए हैं। Audio अभी disabled है।"],firewallTitle:"Firewall और remote locations",firewallBody:"Same LAN में आम तौर पर router forwarding जरूरी नहीं। दूसरे network से clients को manager client port तक पहुंचना होगा।",firewallPoints:["Client connection port: TCP 5197.","Client machines को आम तौर पर सिर्फ outbound access चाहिए।","Remote network के लिए manager firewall में TCP 5197 inbound allow करें और router से TCP 5197 manager PC पर forward करें।","5179 manager UI port है; इसे तभी expose करें जब remote browser को Wall खोलना हो।","Public internet से पहले VPN, Tailscale, ZeroTier या fixed IP allowlist बेहतर है।"],commandsTitle:"Current commands",commandsBody:"Product direction है OS के बीच एक terminal command, website से download/install नहीं।",managerCommandLabel:"Start manager",clientCommandLabel:"Connect workstation",slotCommandLabel:"Pin to slot 3",manualCommandLabel:"Advanced manual connection"}),ar:On({languageName:"العربية",languageLabel:"لغة المستند",eyebrow:"LiveDesk Manual",title:"افتح Screen Wall محلي بأمر واحد",intro:"LiveDesk هو deck بنمط npm-first لمراقبة عدة workstations وأجهزة AI وMac mini وأجهزة تطوير من كمبيوتر manager واحد.",managerTitle:"1. شغل manager",managerBody:"شغل LiveDesk على الكمبيوتر الذي سيعرض الشاشات. يبدأ manager الواجهة والخادم المحلي معا ويفتح http://127.0.0.1:5179.",managerPoints:["الأمر هو npx -y livedesk.","يستخدم manager المنفذ 5179 للواجهة/API والمنفذ 5197 لاتصالات client.","إذا بقيت عملية LiveDesk قديمة على المنافذ، يتم تنظيفها افتراضيا عند التشغيل."],clientTitle:"2. وصل workstation",clientBody:"على كل كمبيوتر تتم مراقبته، سجل الدخول بنفس حساب Google. إذا لم يكن manager متاحا، يبقى client يعمل ويحاول كل 5 ثوان.",clientPoints:["npx -y livedesk client يختار أول slot فارغ.","npx -y livedesk client 3 يثبت الجهاز في slot 3.","clients تستمر بالمحاولة لتجنب تكرار تسجيل الدخول عند كثرة الأجهزة."],syncTitle:"3. Sync Server والاكتشاف",syncBody:"Sync Server ينشر هذا manager كـ active Screen Wall للحساب. يقرأ clients سجل Supabase ويجربون endpoints بالترتيب.",syncPoints:["السجل يتضمن host instance وعناوين LAN/private وpublic candidates وpair token وlease قصير.","يتم تفضيل LAN أولا، ثم public عند الحاجة.","اضغط Sync Server بعد تغيير manager أو VPN أو firewall أو router.","Chrome Local Network Access على livedesk.pages.dev لم يعد مسار التشغيل الافتراضي. تطبيق npm manager هو الخادم الحقيقي."],platformTitle:"4. حالة المنصات",platformBody:"Windows تم التحقق منه مع نقل شاشة live. macOS وLinux يتبعان نفس مسار npm.",platformPoints:["Windows: تم التحقق.","macOS: capture/control يحتاجان أذونات Screen Recording/Accessibility.","Linux: تمت إضافة linux-x64 runtime وgrim/gnome-screenshot/import/scrot capture وxdotool input. الصوت ما زال معطلا."],firewallTitle:"Firewall والمواقع البعيدة",firewallBody:"داخل نفس LAN غالبا لا تحتاج port forwarding. من شبكة أخرى يجب أن يصل client إلى منفذ manager client.",firewallPoints:["منفذ client: TCP 5197.","أجهزة client تحتاج عادة اتصال outbound فقط.","للشبكات البعيدة، اسمح TCP 5197 inbound على manager ووجه TCP 5197 من router إلى manager PC.","المنفذ 5179 مخصص لواجهة manager؛ اكشفه فقط إذا كان متصفح بعيد يحتاج فتح Wall مباشرة.","يفضل VPN أو Tailscale أو ZeroTier أو fixed IP allowlist بدل التعريض العام."],commandsTitle:"الأوامر الحالية",commandsBody:"اتجاه المنتج هو أمر terminal واحد عبر الأنظمة، وليس تحميل وتثبيت يدوي من موقع.",managerCommandLabel:"Start manager",clientCommandLabel:"Connect workstation",slotCommandLabel:"Pin to slot 3",manualCommandLabel:"Advanced manual connection"}),tr:On({languageName:"Türkçe",languageLabel:"Belge dili",eyebrow:"LiveDesk Manual",title:"Yerel Screen Wall tek komutla açılsın",intro:"LiveDesk, tek bir manager PC üzerinden birçok workstation, AI box, Mac mini ve dev machine izlemek için npm-first bir çalışma deckidir.",managerTitle:"1. Manager çalıştır",managerBody:"Ekranları izleyecek bilgisayarda LiveDesk manager çalıştır. Manager UI ve local server birlikte başlar ve http://127.0.0.1:5179 açılır.",managerPoints:["Komut: npx -y livedesk.","Manager Screen Wall/API için 5179, client bağlantıları için 5197 kullanır.","Eski LiveDesk process portları tutuyorsa başlangıç varsayılan olarak temizler."],clientTitle:"2. Workstation bağla",clientBody:"İzlenecek bilgisayarda aynı Google hesabıyla giriş yap. Manager henüz online değilse client kapanmaz ve her 5 saniyede tekrar dener.",clientPoints:["npx -y livedesk client ilk boş slota yerleşir.","npx -y livedesk client 3 makineyi slot 3’e sabitler.","Çok makinede tekrar tekrar login gerekmesin diye client beklemeye devam eder."],syncTitle:"3. Sync Server ve discovery",syncBody:"Sync Server bu managerı hesabın active Screen Wall kaydı olarak Supabase’e yazar. Clients bu kaydı okuyup endpoint adaylarını dener.",syncPoints:["Host instance, LAN/private adresler, public adaylar, pair token ve kısa lease içerir.","Önce LAN adayları, gerekirse public adaylar denenir.","Manager, VPN, firewall veya router değişince Sync Server’a bas.","livedesk.pages.dev üzerindeki Chrome Local Network Access artık default runtime yolu değil. Gerçek server npm manager app."],platformTitle:"4. Platform durumu",platformBody:"Windows live screen transfer ile doğrulandı. macOS ve Linux aynı npm yolunu takip ediyor.",platformPoints:["Windows: doğrulandı.","macOS: capture/control için Screen Recording/Accessibility izinleri gerekir.","Linux: linux-x64 runtime, grim/gnome-screenshot/import/scrot capture ve xdotool input backend eklendi. Audio kapalı."],firewallTitle:"Firewall ve uzak konumlar",firewallBody:"Aynı LAN içinde genelde router forwarding gerekmez. Başka ağdan clients manager client portuna ulaşabilmelidir.",firewallPoints:["Client port: TCP 5197.","Client makineler normalde sadece outbound erişim ister.","Uzak ağ için manager firewall üzerinde TCP 5197 inbound aç ve routerdan TCP 5197yi manager PCye forward et.","5179 manager UI portudur; sadece uzak browser Wall açacaksa expose et.","Public internet yerine VPN, Tailscale, ZeroTier veya sabit IP allowlist tercih et."],commandsTitle:"Güncel komutlar",commandsBody:"Ürün yönü, webden indirip kurmak yerine işletim sistemleri arasında ortak tek terminal komutu.",managerCommandLabel:"Manager başlat",clientCommandLabel:"Workstation bağla",slotCommandLabel:"Slot 3’e sabitle",manualCommandLabel:"Gelişmiş manuel bağlantı"})},DA=Object.entries(Fr).map(([n,a])=>({id:n,label:a.languageName}));function LA(){if(typeof navigator>"u")return"en";const n=navigator.languages?.length?navigator.languages:[navigator.language];for(const a of n){const i=a.toLowerCase();if(Fr[a])return a;if(i.startsWith("zh-tw")||i.startsWith("zh-hk"))return"zh-TW";if(i.startsWith("pt"))return"pt-BR";const r=i.split("-")[0];if(Fr[r])return r}return"en"}function ty({index:n}){const a=n+1;return l.jsx("article",{className:"device-tile placeholder-tile","aria-label":`Empty slot ${a}`,children:l.jsxs("div",{className:"tile-screen","aria-hidden":"true",children:[l.jsx("span",{className:"slot-grid","aria-hidden":"true"}),l.jsxs("span",{className:"empty-screen",children:[l.jsx(an,{size:24}),l.jsxs("strong",{children:["Slot ",String(a).padStart(3,"0")]})]})]})})}function Gm({device:n,frame:a,selected:i,controlEnabled:r,showStatus:c,monitorIndex:d,monitorCount:h,onSelect:p,onFocusDevice:x,onOpenControl:g,onCycleMonitor:w,onCanvasReady:v,sendInput:b,presentationReady:k}){const j=f.useRef(null),M=f.useRef(null),T=f.useRef(0),C=f.useRef(null),A=kw(n),D=["cpu","gpu","memory","vram"].map(R=>A.metrics.find(J=>J.id===R)).filter(R=>!!R),H=Pn(d,h),B=h>1,q=k??!!a,L=dA(n,a,H),F=L>=Xu?100:L/Xu*100,ue=L>=Xu?Xu/L*100:100,W={"--screen-aspect":L.toFixed(5),"--screen-content-width":`${Math.max(1,Math.min(100,F)).toFixed(3)}%`,"--screen-content-height":`${Math.max(1,Math.min(100,ue)).toFixed(3)}%`},ce=f.useCallback(R=>{j.current=R,v(n.deviceId,R)},[n.deviceId,v]),Q=R=>{const J=R.currentTarget.getBoundingClientRect();return{normalizedX:Math.max(0,Math.min(1,(R.clientX-J.left)/Math.max(1,J.width))),normalizedY:Math.max(0,Math.min(1,(R.clientY-J.top)/Math.max(1,J.height)))}},se=R=>({shiftKey:R.shiftKey,ctrlKey:R.ctrlKey,altKey:R.altKey,metaKey:R.metaKey}),oe=f.useCallback(()=>{C.current!==null&&(window.cancelAnimationFrame(C.current),C.current=null)},[]),K=f.useCallback(()=>{const R=M.current;if(!R)return;M.current=null;const J=Number(R.input.normalizedX),he=Number(R.input.normalizedY);if(!Number.isFinite(J)||!Number.isFinite(he))return;b(n.deviceId,{...R.input,normalizedX:J,normalizedY:he})&&(T.current=performance.now())},[n.deviceId,b]),z=f.useCallback(()=>{C.current===null&&(C.current=window.requestAnimationFrame(()=>{C.current=null,K()}))},[K]);f.useEffect(()=>()=>{oe(),M.current=null},[oe]);const Y=(R,J)=>{if(!r)return;const he={type:J,monitorIndex:H,...Q(R),button:CA(R.button),...se(R)};if(J==="pointermove"){const $=performance.now();M.current={input:he},$-T.current>=OM&&(oe(),K()),z();return}M.current&&(oe(),K()),b(n.deviceId,he)},U=f.useCallback(R=>{const J=document.activeElement;J instanceof HTMLElement&&R.contains(J)&&J.classList.contains("monitor-cycle-button")&&J.blur()},[]);return l.jsx("article",{className:`device-tile ${i?"selected":""} ${n.connected?"online":"offline"}`,"data-live-device-id":n.deviceId,style:W,children:l.jsxs("div",{className:`tile-screen ${q?"has-frame":"is-empty"}`,role:"button",tabIndex:r?-1:0,"aria-pressed":i,onClick:()=>{r||p()},onKeyDown:R=>{r||(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),p())},onDoubleClick:R=>{R.preventDefault(),g()},onPointerLeave:R=>U(R.currentTarget),children:[l.jsx("span",{className:`screen-content ${q?"has-frame":"is-empty"}`,children:l.jsx("canvas",{ref:ce,className:`remote-canvas ${q?"has-frame":"is-empty"}`,tabIndex:r?0:-1,onPointerDown:R=>{r&&(R.preventDefault(),R.stopPropagation(),x(),R.currentTarget.focus(),R.currentTarget.setPointerCapture(R.pointerId),Y(R,"pointerdown"))},onPointerMove:R=>{r&&R.preventDefault(),Y(R,"pointermove")},onPointerUp:R=>{r&&(R.preventDefault(),R.stopPropagation(),Y(R,"pointerup"),R.currentTarget.hasPointerCapture(R.pointerId)&&R.currentTarget.releasePointerCapture(R.pointerId))},onPointerCancel:R=>{R.currentTarget.hasPointerCapture(R.pointerId)&&R.currentTarget.releasePointerCapture(R.pointerId)},onWheel:R=>{r&&(R.preventDefault(),b(n.deviceId,{type:"wheel",monitorIndex:H,...Q(R),deltaX:R.deltaX,deltaY:R.deltaY,...se(R)}))},onKeyDown:R=>{r&&(R.preventDefault(),R.stopPropagation(),b(n.deviceId,{type:"keydown",monitorIndex:H,key:R.key,code:R.code,keyCode:R.keyCode||R.which||0,location:R.location,text:R.key.length===1?R.key:"",repeat:R.repeat,...se(R)}))},onKeyUp:R=>{r&&(R.preventDefault(),R.stopPropagation(),b(n.deviceId,{type:"keyup",monitorIndex:H,key:R.key,code:R.code,keyCode:R.keyCode||R.which||0,location:R.location,text:R.key.length===1?R.key:"",repeat:!1,...se(R)}))},onContextMenu:R=>r&&R.preventDefault()})}),!q&&l.jsx("span",{className:"empty-screen",children:l.jsx(an,{size:26})}),c&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:`tile-health-pill state-${A.state}`,children:A.label}),l.jsx("span",{className:"tile-metrics","aria-label":`${Yi(n)} status`,children:D.map(R=>l.jsxs("span",{className:`tile-metric state-${R.state}`,children:[l.jsx("b",{children:R.label}),l.jsx("em",{children:R.value}),R.ratio!==void 0&&l.jsx("i",{style:{width:`${Math.round(R.ratio*100)}%`}})]},R.id))})]}),B&&l.jsxs("span",{className:"monitor-cycle","aria-label":`${Yi(n)} display ${H+1} of ${h}`,children:[l.jsx("button",{className:"monitor-cycle-button previous",onClick:R=>{R.preventDefault(),R.stopPropagation(),w(-1),R.currentTarget.blur()},title:"Previous display",type:"button",children:l.jsx(ry,{size:18})}),l.jsxs("span",{className:"monitor-cycle-count",children:["Screen ",H+1,"/",h]}),l.jsx("button",{className:"monitor-cycle-button next",onClick:R=>{R.preventDefault(),R.stopPropagation(),w(1),R.currentTarget.blur()},title:"Next display",type:"button",children:l.jsx(xh,{size:18})})]}),i&&l.jsx("span",{className:"device-selection-check","aria-hidden":"true",children:l.jsx(uc,{size:23,strokeWidth:3.5})})]})})}function zA({visible:n}){return f.useEffect(()=>{if(!n||!Om)return;if(!document.getElementById(Bv)){const i=document.createElement("script");i.id=Bv,i.async=!0,i.crossOrigin="anonymous",i.src=`https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${encodeURIComponent(oh)}`,document.head.appendChild(i)}const a=window.setTimeout(()=>{try{window.adsbygoogle=window.adsbygoogle||[],window.adsbygoogle.push({})}catch{}},120);return()=>window.clearTimeout(a)},[n]),n?l.jsxs("aside",{className:`free-ad-banner ${Om?"adsense-ready":"house-ad"}`,"aria-label":"Advertisement",children:[l.jsx("span",{className:"ad-label",children:"Advertisement"}),Om?l.jsx("ins",{className:"adsbygoogle livedesk-ad-unit",style:{display:"block"},"data-ad-client":oh,"data-ad-slot":xw,"data-ad-format":"auto","data-full-width-responsive":"true"}):l.jsxs("div",{className:"house-ad-copy",children:[l.jsx("strong",{children:"Sponsored placement"}),l.jsx("span",{children:"Local AI gear, mini PCs, GPUs, NAS, and developer tools."})]})]}):null}function _A(){const n=YM(),{session:a,loading:i}=m0(),{target:r,error:c,refresh:d}=p0(a),h=f.useMemo(()=>{if(!r?.active)return null;const y=r.expires_at?Date.parse(r.expires_at):Number.POSITIVE_INFINITY;return Number.isFinite(y)&&y<=Date.now()?null:r},[r]),p=f.useMemo(()=>qx(h),[h]),x=f.useMemo(()=>p.length>0?[...new Set([...p,Ln])]:[Ln],[p]),[g,w]=f.useState(rA),v=f.useMemo(()=>x.some(y=>!!sc(y)),[x]),b=!v||g,{status:k,devices:j,error:M,refresh:T,hubBaseUrl:C}=h0(x,b),{entitlement:A,licensed:D,loading:H,error:B,refresh:q}=g0(a),[L,F]=f.useState([]),[ue,W]=f.useState(""),[ce,Q]=f.useState(""),[se,oe]=f.useState(""),[K,z]=f.useState(""),[Y,U]=f.useState(""),[R,J]=f.useState("idle"),[he,$]=f.useState(!1),[ie,we]=f.useState(""),[me,ze]=f.useState(!1),[Pe,de]=f.useState(!1),He=f.useRef(""),Le=f.useRef(new Map),Fe=f.useRef(0),[qe,ne]=f.useState(""),[ye,be]=f.useState(""),[Z,le]=f.useState("wall"),[Me,je]=f.useState("large"),[ct,sn]=f.useState(LA),[ke,Ne]=f.useState(!1),[Oe,Dt]=f.useState(!1),[Za,Nt]=f.useState(!1),[Gn,ii]=f.useState(iA),[Te,za]=f.useState(hA),[Ze,_a]=f.useState(gA),[Ke,yn]=f.useState(fA),[qt,_s]=f.useState([]),[Gt,pl]=f.useState(Te.fps),[Oa,Ja]=f.useState(""),[ya,es]=f.useState(0),ln=f.useRef(new Map),Hn=f.useRef(new Map),Yn=f.useRef(new Map),gl=f.useRef(new Map),Ia=f.useRef(new Set),Ba=f.useRef(new Map),Ss=f.useRef(0),ts=f.useRef(""),Vn=f.useRef(""),wa=f.useRef(null),Fa=f.useRef(new Map),ns=f.useRef(null),as=f.useRef(0),Os=f.useRef(new Map),[Kn,X]=f.useState({}),Se=f.useRef(new Map),[De,Je]=f.useState({}),[Tt,ut]=f.useState(!1),Ue=f.useRef(null),at=f.useRef(null),Rt=f.useRef(0),_t=f.useRef(""),Yt=f.useRef(new Map),xt=f.useRef(new Map),Ot=f.useRef(performance.now()),vt=f.useRef(new Map),Wn=f.useRef(new Map),Qn=f.useRef(new Map),Vt=f.useRef(new Map),It=f.useRef(0),xl=f.useRef(0),ss=f.useRef(0),Cs=f.useRef(0),Pr=f.useRef(0),ri=f.useRef(new Map),ba=f.useRef(new Map),[Mn,Kt]=f.useState(null),[vc,qr]=f.useState(!1),[yc,wc]=f.useState([]),[ls,Nd]=f.useState("all"),[mn,oi]=f.useState([]),[Td,bc]=f.useState(!1),[ci,Sc]=f.useState(!0),Gr=f.useRef(null),Is=f.useRef(null),Rd=f.useRef(null),Cc=f.useRef(null),jc=f.useRef(!1),ui=f.useRef(!1),kc=f.useRef(0),di=f.useRef(0),Sa=f.useRef(0),Xn=Z==="settings",Xi=Z==="pricing",Zi=Z==="doc",Ha=Z==="share-files",Bs=Z==="agents",Yr=!Xn&&!Xi&&!Zi&&!Ha&&!Bs,Ye=Z==="control",lt=Te.frameMode==="mode4-h264-atlas",An=Y||Ze.frameMode,Ca=An==="mode5-lzo-delta"?Math.min(30,Ze.fps):Ze.fps,$a=An==="mode5-lzo-delta"?{maxWidth:Math.min(1920,Ze.maxWidth),maxHeight:Math.min(1080,Ze.maxHeight)}:{maxWidth:Ze.maxWidth,maxHeight:Ze.maxHeight};f.useEffect(()=>{if(k?.started){if(!a?.access_token){Be("/api/remote/license",{method:"DELETE"},C).catch(()=>{});return}Be("/api/remote/license/sync",{method:"POST",headers:{Authorization:`Bearer ${a.access_token}`}},C).catch(y=>{console.warn("[LiveDesk] Hub license sync failed",y)})}},[A?.updated_at,C,a?.access_token,k?.started]);const We=f.useMemo(()=>j.filter(y=>y.connected),[j]),is=ls==="all"?We.length:mn.filter(y=>We.some(E=>E.deviceId===y)).length,Vr=f.useMemo(()=>We.reduce((y,E)=>Math.max(y,ey(E.slotNumber)),0),[We]),Fs=Math.max(LM,We.length,Vr),vl=f.useMemo(()=>{const y=Array(Fs).fill(null),E=[];for(const _ of We){const G=ey(_.slotNumber);G>0&&G<=Fs&&!y[G-1]?y[G-1]=_:E.push(_)}for(const _ of E){const G=y.findIndex(O=>!O);G<0?y.push(_):y[G]=_}return y},[We]),yl=f.useMemo(()=>We.map(y=>y.deviceId),[We]),rs=f.useMemo(()=>new Set(L),[L]),Zn=f.useMemo(()=>We.filter(y=>rs.has(y.deviceId)),[We,rs]),Wt=f.useMemo(()=>j.find(y=>y.deviceId===ue)||Zn[0]||null,[j,ue,Zn]),Qt=f.useMemo(()=>j.find(y=>y.deviceId===ce)||null,[ce,j]),Hs=Qt?Pn(Ke[Qt.deviceId],Bn(Qt)):0,Ae=Ye?Qt:Wt,Mc=f.useMemo(()=>new Set(mn),[mn]),Kr=f.useMemo(()=>ls==="all"?We.map(y=>y.deviceId):We.filter(y=>Mc.has(y.deviceId)).map(y=>y.deviceId),[We,Mc,ls]),Jn=f.useMemo(()=>Ae?kw(Ae):null,[Ae]),fi=Ae?rc(Ae,"control"):!1,Ji=Ae?.platform==="macos"&&Ae.capabilities?.controlPermission===!1,wl=Ae?rc(Ae,"audio")||rc(Ae,"remoteAudio"):!1,At=D?A?.plan==="pro"?"pro":"ltd":"free",Ac=$i[At],er=Ac.limit,os=f.useMemo(()=>{if(!Number.isFinite(er))return new Set(We.map(E=>E.deviceId));const y=Ae?[Ae,...We.filter(E=>E.deviceId!==Ae.deviceId)]:We;return new Set(y.slice(0,er).map(E=>E.deviceId))},[er,We,Ae]),Ed=!Ae||os.has(Ae.deviceId),Dd=At==="free",Xt=Ed,bl=At==="ltd"?`Plus includes up to ${Xo} workstations. Upgrade to Pro for commercial use and larger walls.`:`Free includes up to ${Qo} workstations. Upgrade to Plus for ${Xo} devices and no ads.`,Ld=At==="free",Wr=Xt&&!!Ae,cs=Xt&&!!Ae&&fi,Nc=Xt&&!!Ae&&wl,tr=f.useMemo(()=>vl.filter(y=>!!y?.connected).slice(0,vA(Me)).map(y=>y.deviceId),[vl,Me]),$s=f.useMemo(()=>lt?yl:Te.visibleOnlyLive?qt.length>0?qt:tr:yl,[tr,lt,qt,Te.visibleOnlyLive,yl]),Sl=f.useMemo(()=>$m($s.filter(y=>os.has(y))),[os,$s]),hn=f.useMemo(()=>Sl.filter(y=>y!==Oa),[Sl,Oa]),zd=f.useMemo(()=>{const y=O=>We.find(pe=>pe.deviceId===O)||null,E=O=>Pn(Ke[O],y(O)?Bn(y(O)):0),_=(O,pe=E(O))=>O===se&&(R==="connecting"||R==="active"||R==="warm")?Yn.current.get(O)||Hn.current.get(O)||null:lt?Fa.current.get(O)||ln.current.get(O)||null:ln.current.get(O)||null,G=(O,pe=E(O))=>{const xe=y(O);return`${xe?Yi(xe):O} · Monitor ${pe+1}`};return{resolveCurrentTarget(){if(Ye&&Qt){const Ve=Hs;return{type:"control",deviceIds:[Qt.deviceId],monitorIndex:Ve,label:`${Yi(Qt)} · Monitor ${Ve+1}`,sourceCanvas:_(Qt.deviceId,Ve),signature:`control:${Qt.deviceId}:${Ve}:${Ze.frameMode}`}}const O=Zn.map(Ve=>Ve.deviceId).filter(Ve=>hn.includes(Ve)),pe=Wt&&hn.includes(Wt.deviceId)?Wt.deviceId:"",xe=O.length>0?O:pe?[pe]:hn,Re=O.length===0&&!pe;if(xe.length===0)return null;if(xe.length===1){const Ve=xe[0],Qe=E(Ve);return{type:Re?"wall":O.length>1?"selection":"device",deviceIds:xe,monitorIndex:Qe,label:Re?"Wall":G(Ve,Qe),sourceCanvas:Re?null:_(Ve,Qe),signature:`${Re?"wall":"device"}:${Ve}:${Qe}:${lt?"atlas":"direct"}`}}return{type:O.length>1?"selection":"wall",deviceIds:xe,label:O.length>1?`${xe.length} selected workstations`:"Wall",sourceCanvas:null,signature:`${O.length>1?"selection":"wall"}:${xe.join(",")}:${Me}`}},getDeviceCanvas:_,composeWall(O,pe={}){return bM(O.map(xe=>{const Re=E(xe);return{deviceId:xe,label:G(xe,Re),canvas:_(xe,Re)}}),pe)}}},[We,Qt,se,R,Ze.frameMode,ln,lt,Ke,Hs,Zn,Ye,hn,Wt,Me]),Tc=DM({hubUrl:C,sourceRegistry:zd,onToast:be}),Us=f.useMemo(()=>Xt&&se&&os.has(se)&&(R==="connecting"||R==="active"||R==="warm")?[se]:[],[se,R,Xt,os]),_d=f.useMemo(()=>$m([...Sl,...Us]),[Us,Sl]),Zt=f.useMemo(()=>yA(Te,Me),[Te,Me]),Ps=f.useCallback((y,E)=>{if(y.width<=0||y.height<=0)return!1;(E.width!==y.width||E.height!==y.height)&&(E.width=y.width,E.height=y.height);const _=E.getContext("2d",{alpha:!1});return _?(_.imageSmoothingEnabled=!0,_.imageSmoothingQuality="high",_.drawImage(y,0,0,y.width,y.height,0,0,E.width,E.height),!0):!1},[]),us=f.useCallback((y,E=!1)=>{if(!Ia.current.has(y))return!1;const _=performance.now(),G=Ba.current.get(y)||0;if(!E&&_-G<150)return!1;const O=Yn.current.get(y)||Hn.current.get(y),pe=lt?Fa.current.get(y):ln.current.get(y);return!O||!pe||!Ps(O,pe)?!1:(Ba.current.set(y,_),!0)},[lt,Ps]);f.useEffect(()=>{ts.current=Oa},[Oa]);const Od=f.useCallback((y,E)=>{const _=ln.current.get(y);if(_&&_!==E&&qo(_),E){ln.current.set(y,E),us(y,!0);return}ln.current.delete(y)},[us]),Id=f.useCallback((y,E)=>{const _=Hn.current.get(y);if(_&&_!==E&&qo(_),E){Hn.current.set(y,E);const G=Yn.current.get(y);G&&Ps(G,E);return}Hn.current.delete(y)},[Ps]),nr=f.useCallback((y,E,_)=>{const G=performance.now(),O=ys(y,_.deviceId);let pe=_;if(y==="control"&&_.visualChanged){const Re=S0(_.deviceId),Ve=ri.current.get(_.deviceId)||0,Qe=Re?G-Re.sentAt:Number.POSITIVE_INFINITY;Re&&Re.inputSeq>Ve&&Qe<=Fv&&(pe={..._,inputFeedbackSeq:Re.inputSeq,inputFeedbackMs:Math.max(0,Qe),inputFeedbackAt:G},ri.current.set(_.deviceId,Re.inputSeq))}xt.current.set(O,G);const xe=Os.current.get(O)||{totalFrames:0,totalChangedFrames:0,sampleFrames:0,sampleChangedFrames:0,sampleStartedAt:G,intervalCount:0,intervalSumMs:0,minIntervalMs:Number.POSITIVE_INFINITY,maxIntervalMs:0,intervalSamplesMs:[],seqGapCount:0,maxSeqGap:0,sampleDecoderInputBase:0,sampleDecoderOutputBase:0};y==="control"&&pe.inputFeedbackMs===void 0&&xe.lastInfo?.inputFeedbackMs!==void 0&&xe.lastInfo.inputFeedbackAt!==void 0&&G-xe.lastInfo.inputFeedbackAt<=Fv&&(pe={...pe,inputFeedbackSeq:xe.lastInfo.inputFeedbackSeq,inputFeedbackMs:xe.lastInfo.inputFeedbackMs,inputFeedbackAt:xe.lastInfo.inputFeedbackAt}),xe.totalFrames+=1,xe.sampleFrames+=1,Pv(xe,G,pe.frameSeq),pe.visualChanged&&(xe.totalChangedFrames+=1,xe.sampleChangedFrames+=1),xe.lastInfo=pe,Os.current.set(O,xe)},[]),ar=f.useCallback((y,E)=>{nr("wall",y,E);const _=he&&se===y.deviceId;ts.current!==y.deviceId&&!_&&(Ia.current.delete(y.deviceId),Ba.current.delete(y.deviceId))},[se,he,nr]),Rc=f.useCallback((y,E)=>{nr("control",y,E),we(pe=>pe&&"");const _=Yn.current.get(y.deviceId),G=Hn.current.get(y.deviceId);_&&_.width>0&&_.height>0&&(G&&Ps(_,G),gl.current.set(y.deviceId,{...y,payload:new ArrayBuffer(0),byteLength:0}),Ia.current.add(y.deviceId),y.deviceId===se&&($(!0),J(pe=>pe==="connecting"?"active":pe)),us(y.deviceId));const O=Ue.current;!O||!GM(O,y)||ut(!0)},[se,Ps,us,nr]);f.useEffect(()=>{const y=window.setInterval(()=>{const E=performance.now(),_={};for(const[G,O]of Os.current.entries()){const pe=Math.max(1,E-O.sampleStartedAt);_[G]={totalFrames:O.totalFrames,totalChangedFrames:O.totalChangedFrames,framesPerSecond:O.sampleFrames*1e3/pe,changedFramesPerSecond:O.sampleChangedFrames*1e3/pe,averageIntervalMs:O.intervalCount>0?O.intervalSumMs/O.intervalCount:0,minIntervalMs:Number.isFinite(O.minIntervalMs)?O.minIntervalMs:0,maxIntervalMs:O.maxIntervalMs,p95IntervalMs:ld(O.intervalSamplesMs,.95),intervalCount:O.intervalCount,seqGapCount:O.seqGapCount,maxSeqGap:O.maxSeqGap,decoderInputFps:Math.max(0,(Number(O.lastInfo?.decoderInputCount||0)-O.sampleDecoderInputBase)*1e3/pe),decoderOutputFps:Math.max(0,(Number(O.lastInfo?.decoderOutputCount||0)-O.sampleDecoderOutputBase)*1e3/pe),sampleMs:pe,lastInfo:O.lastInfo},O.sampleDecoderInputBase=Number(O.lastInfo?.decoderInputCount||0),O.sampleDecoderOutputBase=Number(O.lastInfo?.decoderOutputCount||0),O.sampleChangedFrames=0,Uv(O,E)}X(_)},1e3);return()=>window.clearInterval(y)},[]);const js=f.useCallback((y,E)=>{const _=performance.now(),G=ys(y,E.deviceId);Yt.current.set(G,_),ba.current.delete(G),y==="control"&&Wn.current.delete(G);const O=Se.current.get(G)||{totalFrames:0,sampleFrames:0,sampleStartedAt:_,intervalCount:0,intervalSumMs:0,minIntervalMs:Number.POSITIVE_INFINITY,maxIntervalMs:0,intervalSamplesMs:[],seqGapCount:0,maxSeqGap:0,sampleBytes:0,sampleH264Frames:0,sampleTinyFrames:0,sampleRepeatedFrames:0,sourceSendIntervalsMs:[]};if(O.totalFrames+=1,O.sampleFrames+=1,O.sampleBytes+=Math.max(0,Number(E.byteLength||0)),String(E.frameMode||E.mode||E.codec||E.mimeType||"").toLowerCase().includes("h264")){O.sampleH264Frames+=1,Number(E.byteLength||0)<=UM&&(O.sampleTinyFrames+=1);const Ve=String(E.contentHash||"");Ve&&O.lastContentHash===Ve&&(O.sampleRepeatedFrames+=1),O.lastContentHash=Ve}const Re=Number(E.agentSendGapMs||0);Re>0&&Re<1e3&&_h(O.sourceSendIntervalsMs,Re),O.lastFrame=E,Pv(O,_,E.frameSeq),Se.current.set(G,O)},[]);f.useEffect(()=>{const y=window.setInterval(()=>{const E=performance.now(),_={};for(const[G,O]of Se.current.entries()){const pe=Math.max(1,E-O.sampleStartedAt);_[G]={totalFrames:O.totalFrames,framesPerSecond:O.sampleFrames*1e3/pe,averageIntervalMs:O.intervalCount>0?O.intervalSumMs/O.intervalCount:0,minIntervalMs:Number.isFinite(O.minIntervalMs)?O.minIntervalMs:0,maxIntervalMs:O.maxIntervalMs,p95IntervalMs:ld(O.intervalSamplesMs,.95),intervalCount:O.intervalCount,seqGapCount:O.seqGapCount,maxSeqGap:O.maxSeqGap,averageFrameBytes:O.sampleFrames>0?O.sampleBytes/O.sampleFrames:0,tinyFrameRatio:O.sampleH264Frames>0?O.sampleTinyFrames/O.sampleH264Frames:0,repeatedFrameRatio:O.sampleH264Frames>0?O.sampleRepeatedFrames/O.sampleH264Frames:0,sourceSendAverageMs:O.sourceSendIntervalsMs.length>0?O.sourceSendIntervalsMs.reduce((xe,Re)=>xe+Re,0)/O.sourceSendIntervalsMs.length:0,sourceSendP95Ms:ld(O.sourceSendIntervalsMs,.95),sourceSendSampleCount:O.sourceSendIntervalsMs.length,sampleMs:pe,lastFrame:O.lastFrame},O.sampleBytes=0,O.sampleH264Frames=0,O.sampleTinyFrames=0,O.sampleRepeatedFrames=0,O.sourceSendIntervalsMs.length=0,Uv(O,E)}Je(_)},1e3);return()=>window.clearInterval(y)},[]);const Cl=f.useCallback(y=>{js("wall",y);const E=ln.current.get(y.deviceId);E&&Cm(E,y,()=>ln.current.get(y.deviceId)!==E,ar,Te.h264DecodeAcceleration).catch(()=>{})},[ar,js,Te.h264DecodeAcceleration]),Ec=f.useCallback(y=>{js("control",y);let E=Yn.current.get(y.deviceId);E||(E=document.createElement("canvas"),E.setAttribute("aria-hidden","true"),Yn.current.set(y.deviceId,E));const _=E;Cm(_,y,()=>Yn.current.get(y.deviceId)!==_,Rc,Ze.h264DecodeAcceleration,"interactive").catch(G=>{we(G instanceof Error?G.message:String(G||"Control H.264 decode failed"))})},[Ze.h264DecodeAcceleration,Rc,js]),Dc=f.useCallback(y=>{const E=wa.current;E&&E!==y&&qo(E),wa.current=y,It.current=0,xl.current=0,ss.current=0,Cs.current=0,Pr.current=0,as.current=0},[]),qs=f.useCallback(()=>{const y=wa.current,E=ns.current;if(!(!y||!E||y.width<=0||y.height<=0||as.current!==E.layoutVersion))for(const _ of E.tiles){const G=Fa.current.get(_.deviceId);if(!G||_.width<=0||_.height<=0)continue;const O=Math.max(1,Math.round(_.width)),pe=Math.max(1,Math.round(_.height)),xe=PM,Re=qM;(G.width!==xe||G.height!==Re)&&(G.width=xe,G.height=Re);const Ve=G.getContext("2d",{alpha:!1});if(Ve){Ve.imageSmoothingEnabled=!0,Ve.imageSmoothingQuality="high";try{Ve.drawImage(y,Math.round(_.x),Math.round(_.y),O,pe,0,0,xe,Re)}catch{}}}},[]),Lc=f.useCallback((y,E)=>{if(E){Fa.current.set(y,E),window.requestAnimationFrame(qs),window.requestAnimationFrame(()=>us(y,!0));return}Fa.current.delete(y)},[qs,us]),Qr=f.useCallback((y,E)=>{ss.current=performance.now(),as.current=Number(y.layoutVersion||0),qs();const _=ns.current?.tiles||[],G=_.length>0?Math.round(y.byteLength/_.length):y.byteLength;for(const O of _){const pe={...y,deviceId:O.deviceId,width:O.width,height:O.height,sourceWidth:O.width,sourceHeight:O.height,byteLength:G};ar(pe,{...E,deviceId:O.deviceId,width:O.width,height:O.height,byteLength:G}),ts.current===O.deviceId&&us(O.deviceId,!0)}},[ar,qs,us]),zc=f.useCallback(y=>{const E=performance.now();It.current<=0&&(It.current=E),xl.current=E;const _=wa.current;if(!_)return;const G=ns.current?.tiles||[],O=G.length>0?Math.round(y.byteLength/G.length):y.byteLength;for(const pe of G)js("wall",{...y,deviceId:pe.deviceId,width:pe.width,height:pe.height,sourceWidth:pe.width,sourceHeight:pe.height,byteLength:O});Cm(_,y,()=>wa.current!==_,Qr).catch(()=>{})},[Qr,js]),jl=f.useMemo(()=>({fps:Gt,maxWidth:Zt.maxWidth,maxHeight:Zt.maxHeight,quality:Te.quality,mode:Te.frameMode,frameMode:Te.frameMode,streamPurpose:"wall",monitorSelections:Ke,onFrame:Cl}),[Gt,Cl,Zt,Ke,Te]),Bd=f.useMemo(()=>({fps:Ca,maxWidth:$a.maxWidth,maxHeight:$a.maxHeight,quality:Ze.quality,mode:An,frameMode:An,streamPurpose:"control",forceRestart:K!=="",forceRestartToken:K,restartReason:K?"control-session-start":"",monitorSelections:Ke,onFrame:Ec}),[K,Ze.quality,Ec,Ca,An,$a.maxHeight,$a.maxWidth,Ke]),{frames:_c,state:mi,stats:ds,restartLive:hi}=Kx(lt?[]:hn,!lt&&Te.autoStartLive&&hn.length>0,C,jl),{frame:Ua,layout:ja,state:Xr,stats:sr,refreshInputs:Zr}=C0($s,lt&&Te.autoStartLive&&$s.length>0,C,{fps:20,width:1920,height:1080,tileWidth:Zt.maxWidth,tileHeight:Zt.maxHeight,captureDeviceIds:hn,monitorSelections:Ke,onFrame:zc});f.useEffect(()=>{ns.current=ja,ja&&window.requestAnimationFrame(qs)},[ja,qs]),f.useEffect(()=>{if(!lt||Xr!=="open"){It.current=0,xl.current=0,ss.current=0;return}const y=window.setInterval(()=>{const E=wa.current,_=performance.now();if(!E||document.visibilityState!=="visible"||_-Ot.current<Im)return;const G=xl.current,O=It.current;if(G<=0||O<=0||_-G>500)return;const pe=ss.current||O,xe=_-pe;if(xe>=BM&&_-Pr.current>=HM){Ux(E)&&(Pr.current=_,Cs.current=_);return}xe>=IM&&_-Cs.current>=FM&&JS(E)&&(Cs.current=_)},250);return()=>window.clearInterval(y)},[Xr,lt]);const{frames:lr,state:pi,error:ks,stats:Oc,restartLive:gi}=Kx(Us,Us.length>0,C,Bd),xi=f.useMemo(()=>{const y=new Map(_c);if(lt&&Ua){const E=new Map((ja?.tiles||[]).map(G=>[G.deviceId,G])),_=Math.max(1,E.size);for(const G of $s){const O=E.get(G);y.set(G,{...Ua,deviceId:G,width:O?.width||Zt.maxWidth,height:O?.height||Zt.maxHeight,sourceWidth:O?.width||Zt.maxWidth,sourceHeight:O?.height||Zt.maxHeight,byteLength:Math.round(Ua.byteLength/_)})}}for(const[E,_]of lr.entries())y.set(E,_);for(const E of $s){if(!Ia.current.has(E)||y.has(E))continue;const _=gl.current.get(E);_&&y.set(E,_)}return y},[Ua,ja,lr,Zt,lt,_c,$s,ya]),Jr=Ye&&Us.length>0?pi:lt?Xr:mi,eo=Ye&&Us.length>0?Oc:lt?sr:ds;f.useCallback((y,E="browser-stale")=>{const _=hi(y,E),G=gi(y,E);return _||G},[gi,hi]),f.useEffect(()=>{lt&&!Ye&&Zr()},[lt,Zr,Ye]);const ir=f.useCallback((y,E,_)=>{const G=E==="control"?Yn.current.get(y)||null:ln.current.get(y)||null;if(!G||!Ux(G))return!1;const O=performance.now();return Vt.current.set(ys(E,y),O),!0},[]),rr=f.useCallback(y=>{if(An!=="mode3-h264-hw"||!se||Y==="mode5-lzo-delta")return!1;const E=ys("control",se),_=performance.now();Qn.current.set(E,_),Yt.current.delete(E),xt.current.delete(E),vt.current.delete(E),Wn.current.delete(E),ba.current.delete(E),U("mode5-lzo-delta"),z(`control-mode5-fallback-${se}-${Date.now()}`),$(!1),ut(!1);const G=y==="no first frame"||y==="control-first-frame-timeout";return we(O=>O||(G?`Control frame transport timeout; retrying Control with Mode 5 (${y})`:`H.264 decode failed; retrying Control with Mode 5 (${y})`)),J("connecting"),!0},[se,Y,An]);f.useEffect(()=>{const y=Ye?Qt:null;if(y){Ue.current={deviceId:y.deviceId,monitorIndex:Hs,frameMode:An,startedAtEpochMs:Date.now()},ut(se===y.deviceId&&he);return}Ue.current=null,ut(!1)},[Qt?.sessionId,ce,se,he,An,Hs,Ye]);const to=f.useCallback(async y=>{const E=lt,_=j.find(xe=>xe.deviceId===y),G=Pn(Ke[y],_?Bn(_):1),O=E?{fps:8,maxWidth:Zt.maxWidth,maxHeight:Zt.maxHeight,quality:60,mode:"mode2-lzo",frameMode:"mode2-lzo",streamPurpose:"atlas",monitorIndex:G}:{fps:Gt,maxWidth:Zt.maxWidth,maxHeight:Zt.maxHeight,quality:Te.quality,mode:Te.frameMode,frameMode:Te.frameMode,streamPurpose:"wall",monitorIndex:G},pe=await Be(`/api/remote/devices/${encodeURIComponent(y)}/live/start`,{method:"POST",body:JSON.stringify(O)},C);if(pe?.ok===!1)throw new Error(pe.error||"wall-stream-start-failed");return pe},[Gt,j,Zt.maxHeight,Zt.maxWidth,C,lt,Ke,Te.frameMode,Te.quality]),zn=f.useCallback(async y=>{const E=await Be(`/api/remote/devices/${encodeURIComponent(y)}/live/stop`,{method:"POST",body:JSON.stringify({streamPurpose:lt?"atlas":"wall",reason:"control-active"})},C);if(E?.ok===!1)throw new Error(E.error||"wall-stream-stop-failed");return E},[C,lt]),Pa=f.useCallback(async(y,E="control-session-stop")=>{const _=await Be(`/api/remote/devices/${encodeURIComponent(y)}/live/stop`,{method:"POST",body:JSON.stringify({streamPurpose:"control",reason:E})},C);if(_?.ok===!1)throw new Error(_.error||"control-stream-stop-failed");return _},[C]),Gs=f.useCallback(y=>{const E=Yn.current.get(y);E&&(qo(E),Yn.current.delete(y));const _=Hn.current.get(y);_&&qo(_),gl.current.delete(y),Ia.current.delete(y),Ba.current.delete(y)},[]);f.useEffect(()=>{if(!Ye)return;const y=ce&&We.find(O=>O.deviceId===ce)||null;if(!Xt||!y)return;if(se===y.deviceId&&(R==="active"||R==="warm"||R==="connecting")){J(O=>O==="warm"?"active":O);return}if(_t.current===y.deviceId)return;const E=++Rt.current,_=se;_t.current=y.deviceId,(async()=>{if(_){if(J("stopping"),await Pa(_,"control-session-switch").catch(()=>{}),E!==Rt.current)return;Gs(_)}if(E!==Rt.current)return;const O=ys("control",y.deviceId),pe=`control-session-${E}-${y.deviceId}`;Qn.current.set(O,performance.now()),Yt.current.delete(O),xt.current.delete(O),ba.current.delete(O),Wn.current.delete(O),U(""),we(""),z(pe),oe(y.deviceId),$(!1),J("connecting"),Rt.current===E&&_t.current===y.deviceId&&(_t.current="")})()},[We,ce,se,R,Xt,Gs,Ye,Pa]),f.useEffect(()=>{if(!se||We.some(_=>_.deviceId===se))return;const y=se,E=++Rt.current;J("stopping"),Pa(y,"control-device-disconnected").catch(()=>{}).finally(()=>{E===Rt.current&&(Gs(y),$(!1),z(""),U(""),we(""),oe(_=>_===y?"":_),J("idle"))})},[We,se,Gs,Pa]),f.useEffect(()=>{if(at.current!==null&&(window.clearTimeout(at.current),at.current=null),!se||R==="idle"||R==="stopping"||R==="error"||Ye||Z==="wall"){se&&!Ye&&Z==="wall"&&J(_=>_==="warm"||_==="active"?"active":_);return}J(_=>_==="idle"||_==="stopping"?_:"warm");const y=se,E=++Rt.current;return at.current=window.setTimeout(()=>{at.current=null,J("stopping"),Pa(y,"control-session-warm-timeout").catch(()=>{}).finally(()=>{E===Rt.current&&(Gs(y),$(!1),z(""),U(""),we(""),oe(_=>_===y?"":_),J("idle"))})},$M),()=>{at.current!==null&&(window.clearTimeout(at.current),at.current=null)}},[Z,se,R,Gs,Ye,Pa]),f.useEffect(()=>()=>{at.current!==null&&window.clearTimeout(at.current)},[]),f.useEffect(()=>{const y=++Ss.current,E=he&&(R==="active"||R==="warm")&&se?se:"",_=ts.current;if(Vn.current||!E&&!_||E&&E===_)return;(async()=>{Vn.current=E||_;try{if(_&&_!==E){if(await to(_),y!==Ss.current)return;ts.current="",Ja("")}if(!E||y!==Ss.current)return;if(await zn(E),y!==Ss.current){await to(E).catch(()=>{});return}ts.current=E,Ja(E),Ia.current.add(E),be(_&&_!==E?`Wall paused for Control: ${E}`:"")}catch(O){y===Ss.current&&be(O instanceof Error?O.message:String(O))}finally{Vn.current===(E||_)&&(Vn.current="")}})()},[se,he,R,lt,to,zn]);const{state:vi,sendInput:kl,stats:ka,error:yi}=j0(cs&&me,C);f.useEffect(()=>{yi&&Ye&&me&&be(yi)},[me,yi,Ye]);const{state:no,lastFrame:Ys,stats:pn,error:Ml}=L0(Ae?.deviceId||"",Nc&&Pe,C);f.useEffect(()=>{if(!Ye||!me||!cs||!Ae)return;const y=(G,O)=>{const pe=G.target,xe=pe?.tagName?.toLowerCase();pe?.isContentEditable||xe==="input"||xe==="textarea"||xe==="select"||(G.preventDefault(),G.stopPropagation(),kl(Ae.deviceId,{type:O,monitorIndex:Pn(Ke[Ae.deviceId],Bn(Ae)),key:G.key,code:G.code,keyCode:G.keyCode||G.which||0,location:G.location,text:G.key.length===1?G.key:"",repeat:O==="keydown"?G.repeat:!1,shiftKey:G.shiftKey,ctrlKey:G.ctrlKey,altKey:G.altKey,metaKey:G.metaKey}))},E=G=>y(G,"keydown"),_=G=>y(G,"keyup");return window.addEventListener("keydown",E),window.addEventListener("keyup",_),()=>{window.removeEventListener("keydown",E),window.removeEventListener("keyup",_)}},[cs,me,Ke,Ae,kl,Ye]),f.useEffect(()=>{const y=()=>{document.visibilityState==="visible"&&(Ot.current=performance.now())};return document.addEventListener("visibilitychange",y),window.addEventListener("pageshow",y),()=>{document.removeEventListener("visibilitychange",y),window.removeEventListener("pageshow",y)}},[]),f.useEffect(()=>{if(!se||R!=="connecting"&&R!=="active"&&R!=="warm"||pi!=="open")return;const y=se,E=ys("control",y),_=window.setInterval(()=>{const G=performance.now();if(document.visibilityState!=="visible"||G-Ot.current<Im)return;const O=Yt.current.get(E)||0,pe=xt.current.get(E)||0,xe=vt.current.get(E)||0,Re=Qn.current.get(E)||G;Qn.current.has(E)||Qn.current.set(E,Re);const Ve=O<=0,Qe=Ve?G-Re>QM:G-O>Kv,yt=O>0&&(pe<=0||G-pe>Kv);if(!Qe&&yt){const oa=Vt.current.get(E)||0;G-oa>=Wv&&ir(y,"control","decoder-paint-stale");return}if(!Qe)return;const $t=Wn.current.get(E)||0;if($t>0){if(G-$t<ZM)return;Wn.current.delete(E)}const ra=ba.current.get(E)||0;if(ra>=JM){if(rr(Ve?"no first frame":"stale stream"))return;$(!1),ut(!1),J("error");return}if(G-xe<Qv(XM,ra))return;gi([y],Ve?"control-first-frame-timeout":"control-receive-stale")&&(vt.current.set(E,G),Wn.current.set(E,G),Qn.current.set(E,G),ba.current.set(E,ra+1))},650);return()=>window.clearInterval(_)},[pi,se,R,rr,ir,gi]),f.useEffect(()=>{!ie||An!=="mode3-h264-hw"||rr(ie)},[ie,An,rr]),f.useEffect(()=>{!Ye||!se||!ks||J(y=>y==="error"?y:"error")},[ks,se,Ye]),f.useEffect(()=>{if(lt||mi!=="open"||!Te.autoStartLive||hn.length===0)return;const y=window.setInterval(()=>{const E=performance.now();if(document.visibilityState!=="visible"||E-Ot.current<Im)return;const _=1e3/Math.max(1,Gt||Te.fps||1),G=Math.max(eA,Math.ceil(_*4)),O=[];for(const pe of hn){if(O.length>=aA)break;const xe=ys("wall",pe),Re=Yt.current.get(xe)||0;if(Re<=0)continue;const Ve=vt.current.get(xe)||0,Qe=xt.current.get(xe)||0,yt=E-Re>G,$t=Qe<=0||E-Qe>G;if(!yt&&$t){const ps=Vt.current.get(xe)||0;E-ps>=Wv&&ir(pe,"wall","decoder-paint-stale");continue}if(!yt)continue;const ra=ba.current.get(xe)||0;E-Ve>=Qv(tA,ra)&&O.push(pe)}if(O.length>0&&hi(O,"wall-frame-stale"))for(const pe of O){const xe=ys("wall",pe);vt.current.set(xe,E),ba.current.set(xe,(ba.current.get(xe)||0)+1)}},nA);return()=>window.clearInterval(y)},[Gt,lt,ir,hi,Te.autoStartLive,Te.fps,hn,mi]),f.useEffect(()=>{pl(Te.fps),di.current=Date.now(),Sa.current=0},[Te.fps,Te.frameMode,Te.adaptiveLoadShedding]),f.useEffect(()=>{qS({h264DecodeAcceleration:Te.h264DecodeAcceleration})},[Te.h264DecodeAcceleration]),f.useEffect(()=>{if(!Xt||Ye||!Te.visibleOnlyLive){_s([]);return}const y=Gr.current;if(!y||typeof IntersectionObserver>"u"){_s(tr);return}const E=Array.from(y.querySelectorAll("[data-live-device-id]"));if(E.length===0){_s([]);return}const _=new Map,G=()=>{const pe=$m(E.map(xe=>String(xe.dataset.liveDeviceId||"")).filter(xe=>(_.get(xe)||0)>0));_s(xe=>Hm(xe,pe)?xe:pe)},O=new IntersectionObserver(pe=>{for(const xe of pe){const Re=String(xe.target.dataset.liveDeviceId||"");Re&&_.set(Re,xe.isIntersecting?xe.intersectionRatio||.01:0)}G()},{root:null,rootMargin:Fn.visibleRootMargin,threshold:[0,.01,.2,.6,1]});return E.forEach(pe=>O.observe(pe)),G(),()=>O.disconnect()},[tr,Xt,Ye,vl,Te.visibleOnlyLive,Me]),f.useEffect(()=>{if(lt||!Te.adaptiveLoadShedding||!Te.autoStartLive||hn.length===0)return;const y=Te.fps;if(hn.length<=Fn.preserveConfiguredFpsDeviceCount){Gt!==y&&(pl(y),di.current=Date.now(),Sa.current=0);return}if(mi!=="open"||ds.sampleMs<500)return;const E=Date.now(),_=hn.length*Gt,G=ds.framesPerSecond,O=ds.bytesPerSecond,pe=Math.max(0,...hn.map(yt=>De[ys("wall",yt)]?.maxIntervalMs||0)),xe=Math.max(0,...hn.map(yt=>Kn[ys("wall",yt)]?.maxIntervalMs||0)),Re=_>8&&G>0&&G<_*.72;if(G>Fn.maxWallFramesPerSecond||O>Fn.maxWallBytesPerSecond||pe>Fn.maxFrameGapMs||xe>Fn.maxFrameGapMs||Re){Sa.current=0;const yt=Fn.minFps;if(E-di.current>=Fn.downshiftCooldownMs&&Gt>yt){const $t=Math.max(yt,wA(Gt,yt));$t<Gt&&(pl($t),di.current=E)}return}const Qe=G<Fn.maxWallFramesPerSecond*Fn.lowLoadFrameRatio&&O<Fn.maxWallBytesPerSecond*Fn.lowLoadByteRatio;if(!Qe||Gt>=y){Qe||(Sa.current=0);return}if(!Sa.current){Sa.current=E;return}if(E-Sa.current>=Fn.recoveryCooldownMs){const yt=Math.min(y,bA(Gt,y));yt>Gt&&(pl(yt),di.current=E,Sa.current=0)}},[Gt,lt,Kn,De,hn.length,hn,mi,ds.bytesPerSecond,ds.framesPerSecond,ds.lastUpdatedAt,ds.sampleMs,Te.adaptiveLoadShedding,Te.autoStartLive,Te.frameMode,Te.fps]),f.useEffect(()=>{const y=new URLSearchParams(window.location.search).get("checkout");if(y==="success"){be("Checkout returned. Waiting for Dodo confirmation."),q();const E=window.setInterval(()=>{q()},4e3),_=window.setTimeout(()=>{window.clearInterval(E)},45e3);return()=>{window.clearInterval(E),window.clearTimeout(_)}}y==="cancelled"&&be("Checkout cancelled.")},[q]),f.useEffect(()=>{!Xt&&me&&ze(!1),!Xt&&Pe&&de(!1)},[Pe,me,Xt]),f.useEffect(()=>{const y=Ae?.deviceId||"",E=He.current;if(He.current=y,!E||E===y)return;const _=++Fe.current,G=y?`audio-${Date.now()}-${Math.random().toString(36).slice(2,8)}`:"";y&&Pe&&Le.current.set(y,G);let O=!0;return(async()=>{try{const xe=Le.current.get(E);if(Le.current.delete(E),await Be(`/api/remote/devices/${encodeURIComponent(E)}/audio/stop`,{method:"POST",body:JSON.stringify(xe?{streamId:xe}:{})},C),!O||_!==Fe.current||!Pe||!y||!Xt||!wl)return;const Re=await Be(`/api/remote/devices/${encodeURIComponent(y)}/audio/start`,{method:"POST",body:JSON.stringify({streamId:G,mimeType:"audio/pcm;format=f32le",sampleRate:48e3,channels:2})},C);if(Re.ok===!1)throw new Error(Re.error||"Remote audio start failed.")}catch(xe){O&&(Le.current.delete(y),de(!1),be(xe instanceof Error?xe.message:String(xe)))}})(),()=>{O=!1}},[Pe,Xt,C,wl,Ae?.deviceId]),f.useEffect(()=>{const y=We.map(G=>G.deviceId),E=new Set(y),_=new Map(We.map(G=>[G.deviceId,G]));F(G=>{const O=G.filter(pe=>E.has(pe));return Hm(G,O)?G:O}),W(G=>G&&E.has(G)?G:""),Q(G=>G&&E.has(G)?G:""),yn(G=>{let O=!1;const pe={};for(const[xe,Re]of Object.entries(G)){const Ve=_.get(xe);if(!Ve){pe[xe]=Re;continue}const Qe=Pn(Re,Ve?Bn(Ve):1);pe[xe]=Qe,Qe!==Re&&(O=!0)}return O?pe:G}),oi(G=>{const O=G.filter(pe=>E.has(pe));return Hm(G,O)?G:O})},[We,Fs]),f.useEffect(()=>{wc([]),Sc(!1)},[us]),f.useEffect(()=>{!Ha||ls!=="selected"||mn.length>0||Zn.length===0||oi(Zn.map(y=>y.deviceId))},[Zn,mn.length,ls,Ha]),f.useEffect(()=>{try{localStorage.setItem(dw,Gn)}catch{}},[Gn]),f.useEffect(()=>{pA(Te)},[Te]),f.useEffect(()=>{xA(Ze)},[Ze]),f.useEffect(()=>{mA(Ke)},[Ke]);const wi=f.useCallback(async()=>{const y=new Set(x);y.add(Ln);try{const pe=await Be("/api/remote/status",void 0,Ln);qx({endpoint:pe.agentEndpoint,endpoint_candidates:[...pe.agentEndpointCandidates||[],...pe.hostTargetEndpointCandidates||[]]}).forEach(xe=>y.add(xe))}catch{}const E=[...y].sort((pe,xe)=>{const Re=Ve=>{const Qe=sc(Ve);return Qe==="local"?0:Qe==="loopback"?1:2};return Re(pe)-Re(xe)||pe.localeCompare(xe)});let _=!1,G="",O=!1;try{for(const pe of E){const xe=sc(pe);try{if(await Be("/api/health",void 0,pe),xe==="local")return w(!0),zr(!0),pe;xe==="loopback"&&(_=!0,G=pe)}catch{xe==="local"&&(O=!0)}}return _?(O&&be("LiveDesk Hub is reachable on this PC, but not through the LAN address yet. Restart LiveDesk Hub to bind 5179 on the network."),w(!0),zr(!0),G||Ln):(w(!1),zr(!1),"")}catch{return w(!1),zr(!1),""}},[x]),bi=async()=>{ne("auth"),Dt(!1),await wi();const{error:y}=await Ds.auth.signInWithOAuth({provider:"google",options:{redirectTo:window.location.origin}});y&&(be(y.message),ne(""))},Vs=async()=>{ne("auth"),Dt(!1),await Ds.auth.signOut(),ne("")};f.useEffect(()=>{if(!Oe)return;const y=_=>{_.target instanceof Element&&(_.target.closest(".account-popover, .rail-account")||Dt(!1))},E=_=>{_.key==="Escape"&&Dt(!1)};return window.addEventListener("pointerdown",y),window.addEventListener("keydown",E),()=>{window.removeEventListener("pointerdown",y),window.removeEventListener("keydown",E)}},[Oe]);const Ma=f.useCallback(async(y={})=>{const E=y.silent===!0,_=y.takeover===!0,G=y.requestLocalAccess===!0,O=G?await wi():"";if(!a?.user){E||be("Sign in before publishing this host.");return}if(!ui.current){ui.current=!0,E||ne("host");try{const pe=O||C||Ln,xe=k||await Be("/api/remote/status",void 0,pe);if(!xe.started)throw new Error("Start LiveDesk on this computer before syncing the server.");const Re=`livedesk-${a.user.id}`,Ve=await Be("/api/remote/host-target",{method:"POST",body:JSON.stringify({nodeId:Re,leaseMs:6e4,takeover:_})},pe);if(!Ve.ok)throw new Error(Ve.error||"host-target-failed");const Qe=await Be("/api/remote/status",void 0,pe),yt=await Be("/api/remote/registry-credentials",void 0,pe),$t=Ve.hostTarget||{},ra=Qe.hostTargetEndpointCandidates||Qe.agentEndpointCandidates||xe.agentEndpointCandidates||[Qe.agentEndpoint||xe.agentEndpoint].filter(Boolean),{data:ps,error:oa}=await Ds.rpc("set_livedesk_remote_host_target",{p_node_id:Re,p_lease_id:String($t.leaseId||Qe.hostTargetLeaseId||crypto.randomUUID()),p_host_instance_id:Qe.hostInstanceId||Re,p_endpoint:Qe.hostTargetEndpoint||Qe.agentEndpoint||xe.agentEndpoint,p_pair_token:yt.pairToken||"",p_manager_package:"@livedesk/hub",p_manager_version:Qe.managerVersion||"0.1.0",p_agent_package:"@livedesk/client",p_activated_at:new Date().toISOString(),p_expires_at:new Date(Date.now()+6e4).toISOString(),p_takeover:_,p_endpoint_candidates:ra,p_pairing_pin:yt.pairingPin||Qe.pairingPin||""});if(oa)throw oa;const gs=Array.isArray(ps)?ps[0]:ps;if(gs&&gs.ok===!1)throw new Error(gs.reason||"registry-rejected");E||(be("Host published."),(G||v)&&(w(!0),zr(!0)),T()),d()}catch(pe){if(!E){const xe=pe instanceof Error?pe.message:String(pe);xe.includes("local network access")&&(w(!1),zr(!1)),be(xe)}}finally{ui.current=!1,E||ne("")}}},[C,v,T,d,wi,a,k]),ao=f.useCallback(async()=>{if(!qe){ne("pin");try{const E=await Be("/api/remote/pairing-pin",{method:"POST"},C||Ln);if(!E.ok)throw new Error(E.error||"pin-rotation-failed");await T(),a?.user&&await Ma({silent:!0,takeover:!0}),be("New PIN published.")}catch(y){be(y instanceof Error?y.message:String(y))}finally{ne("")}}},[qe,C,Ma,T,a]);f.useEffect(()=>{if(!a?.user||!k?.started||M)return;const y=r?.expires_at?Date.parse(r.expires_at):Number.POSITIVE_INFINITY,E=r?.active===!0&&(!r.expires_at||!Number.isFinite(y)||y>Date.now()),_=!!r?.host_instance_id&&!!k.hostInstanceId&&r.host_instance_id===k.hostInstanceId;if(E&&!_)return;let G=!1;const O=()=>{if(G)return;const xe=Date.now();xe-kc.current<25e3||(kc.current=xe,Ma({silent:!0}))};O();const pe=window.setInterval(O,3e4);return()=>{G=!0,window.clearInterval(pe)}},[M,Ma,a?.user?.id,k?.agentEndpoint,k?.hostInstanceId,k?.started,r?.active,r?.expires_at,r?.host_instance_id]);const Ks=f.useCallback(y=>{y&&(W(y),F(E=>E.includes(y)?E:[...E,y]))},[]),Ms=f.useCallback(y=>{if(!y)return;const E=rs.has(y);W(_=>E&&_===y?"":y),F(_=>E?_.filter(G=>G!==y):_.includes(y)?_:[..._,y])},[rs]),Al=f.useCallback(()=>{F([]),W("")},[Ps]),so=f.useCallback(()=>{F(We.map(y=>y.deviceId)),W("")},[We]),or=f.useCallback((y,E)=>{const _=We.find(O=>O.deviceId===y);if(!_)return;const G=Bn(_);G<=1||(yn(O=>{const xe=(Pn(O[y],G)+E+G)%G;return{...O,[y]:xe}}),Ye?(ut(!1),Q(y)):Ks(y))},[We,Ks,Ye]);f.useEffect(()=>{const y=E=>{if(Ye&&me&&cs)return;const _=E.target,G=_?.tagName?.toLowerCase();_?.isContentEditable||G==="input"||G==="textarea"||G==="select"||((E.ctrlKey||E.metaKey)&&E.key.toLowerCase()==="a"&&(E.preventDefault(),so()),E.key==="Escape"&&Al())};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[cs,Al,me,so,Ye]);const Ic=async(y,E={})=>{if(!os.has(y)){be(bl);return}const _=E.focused||Ye;_?(ut(!1),Q(y)):Ks(y);try{const G=We.find(xe=>xe.deviceId===y),O=_?{maxWidth:Ze.maxWidth,maxHeight:Ze.maxHeight}:Zt,pe=Pn(E.monitorIndex??Ke[y],G?Bn(G):1);await Be(`/api/remote/devices/${encodeURIComponent(y)}/live/start`,{method:"POST",body:JSON.stringify({fps:_?Ze.fps:Gt,maxWidth:O.maxWidth,maxHeight:O.maxHeight,quality:_?Ze.quality:Te.quality,mode:_?Ze.frameMode:Te.frameMode,frameMode:_?Ze.frameMode:Te.frameMode,streamPurpose:_?"control":"wall",monitorIndex:pe})},C),T()}catch(G){be(G instanceof Error?G.message:String(G))}},Fd=(y,E)=>{const _=We.find(O=>O.deviceId===y),G=Pn(E,_?Bn(_):1);yn(O=>({...O,[y]:G})),Ye?(ut(!1),Q(y)):Ks(y)},lo=async y=>{if(ut(!1),Q(y),le("control"),!os.has(y)){ze(!1),be(bl);return}ze(!0)},Bc=async()=>{if(!Ae){be("Select a workstation before playing audio.");return}if(!Xt){be(bl);return}if(!wl){be("Selected workstation does not report remote audio support yet.");return}const y=!Pe,E=y?`audio-${Date.now()}-${Math.random().toString(36).slice(2,8)}`:Le.current.get(Ae.deviceId);y&&E?Le.current.set(Ae.deviceId,E):y||Le.current.delete(Ae.deviceId),de(y);try{await Be(`/api/remote/devices/${encodeURIComponent(Ae.deviceId)}/audio/${y?"start":"stop"}`,{method:"POST",body:JSON.stringify({...E?{streamId:E}:{},mimeType:"audio/pcm;format=f32le",sampleRate:48e3,channels:2})},C)}catch(_){y&&Le.current.delete(Ae.deviceId),de(!1),be(_ instanceof Error?_.message:String(_))}},io=async(y,E,_="files")=>{const G=y.filter(Re=>Re.file.size>=0);if(G.length===0)return{files:0,bytes:0};if(!Xt)throw new Error(bl);if(E.length===0)throw new Error("Select at least one connected workstation.");const O=crypto.randomUUID(),pe=G.reduce((Re,Ve)=>Re+Ve.file.size,0);let xe=0;Kt({id:O,status:"reading",progress:1,message:`Preparing ${G.length} ${_}`});try{for(let Re=0;Re<G.length;Re+=1){const Ve=G[Re],Qe=Ve.file,yt=Math.max(1,Math.ceil(Qe.size/_m));for(let $t=0;$t<yt;$t+=1){const ra=$t*_m,ps=Math.min(Qe.size,ra+_m),oa=Qe.size===0?new ArrayBuffer(0):await Qe.slice(ra,ps).arrayBuffer(),gs=$t===yt-1;Kt({id:O,status:"sending",progress:Math.max(2,Math.min(98,Math.round(xe/Math.max(1,pe)*96))),message:`${Re+1}/${G.length} ${Ve.relativePath}`});const el=await Be("/api/remote/files/chunk",{method:"POST",body:JSON.stringify({transferId:O,deviceIds:E,remoteDirectory:Gn.trim(),name:Qe.name,relativePath:Ve.relativePath,size:Qe.size,type:Qe.type,lastModified:Qe.lastModified,offset:ra,totalBytes:Qe.size,final:gs,dataBase64:SA(oa)})},C);if(!el.ok||el.queued!==E.length)throw new Error(el.error||`file-chunk-not-queued-${el.queued}/${E.length}`);xe+=oa.byteLength,await new Promise(Di=>window.setTimeout(Di,0))}}return Kt({id:O,status:"queued",progress:100,message:`Sent ${G.length} file${G.length===1?"":"s"} to ${E.length} workstation${E.length===1?"":"s"}`}),window.setTimeout(()=>{Kt(Re=>Re?.id===O&&Re.status==="queued"?null:Re)},4500),{files:G.length,bytes:pe}}catch(Re){throw Kt({id:O,status:"failed",progress:100,message:Re instanceof Error?Re.message:String(Re)}),Re}},cr=async y=>{const E=Zn.length>0?Zn.map(_=>_.deviceId):Ae?[Ae.deviceId]:[];try{await io(Zv(y),E)}catch(_){be(_ instanceof Error?_.message:String(_))}},ea=async y=>{try{await io(Zv(y),Kr)}catch(E){be(E instanceof Error?E.message:String(E))}};f.useEffect(()=>{jc.current=!1},[]);const ur=y=>{y.preventDefault(),y.stopPropagation(),qr(!1),cr(y.dataTransfer.files)},Nn=async(y="ltd")=>{if(!a){be("Sign in with Google before checkout.");return}if(D&&y===At){be("LiveDesk license is already active.");return}if(D&&At==="pro"){be("LiveDesk Pro is already active.");return}ne("checkout");try{const{data:E,error:_}=await Ds.functions.invoke("dodo-checkout",{body:{plan:y}});if(_)throw _;if(!E?.checkout_url)throw new Error("Checkout function did not return a checkout URL.");window.location.assign(E.checkout_url)}catch(E){be(E instanceof Error?E.message:String(E)),ne("")}},$n=sA(),Nl=lA(),dr=We.length,Tl=_d.filter(y=>xi.has(y)).length,Si=Jr==="open"&&eo.sampleMs>0?`${eo.framesPerSecond.toFixed(1)} fps`:Jr,Ce=Ae?Ye?lr.get(Ae.deviceId):xi.get(Ae.deviceId):void 0,Ci=Ae?Pn(Ke[Ae.deviceId],Bn(Ae)):0,ji=Ae?cA(Ae):[],Rl=typeof Ce?.monitorIndex=="number"?Pn(Ce.monitorIndex,Math.max(1,Ce.monitorCount||1)):Ci,Tn=(Ce&&Rl===Ci?Cw(Ce):null)||(Ae?Sw(Ae,Ci):null),ro=Tn?`${Tn.width}x${Tn.height}`:"-",ta=Ae?ys(Ye?"control":"wall",Ae.deviceId):"",rn=ta?De[ta]:void 0,wn=ta?Kn[ta]:void 0,et=wn?.lastInfo,oo=rn&&rn.sampleMs>0?`${rn.framesPerSecond.toFixed(1)} fps`:"waiting",Fc=rn?`#${rn.totalFrames} / ${oo}`:"waiting",co=wn&&wn.sampleMs>0?`${wn.framesPerSecond.toFixed(1)} fps`:"waiting",Hc=wn&&wn.sampleMs>0?`${wn.changedFramesPerSecond.toFixed(1)} fps`:"waiting",na=et?`#${et.frameSeq} ${et.decoderLabel} q${et.queueSize} r${et.renderQueueSize} d${et.droppedForLatency} f${et.decoderFlushCount} t${et.decoderTimestampFallbacks} io${et.decoderInputCount}/${et.decoderOutputCount} ${et.visualChanged?"changed":"same"}`:"waiting",El=et?`${Math.round(et.queuedForMs)}ms total / ${Math.round(et.decodedForMs)}ms decode / ${Math.round(et.scheduledForMs)}ms pace / ${et.drawMs.toFixed(1)}ms draw`:"-",Dl=et?.targetPaintIntervalMs?`${et.targetPaintIntervalMs.toFixed(1)}ms / ${(1e3/et.targetPaintIntervalMs).toFixed(1)} fps`:"-",fr=wn?`${wn.decoderInputFps.toFixed(1)} in / ${wn.decoderOutputFps.toFixed(1)} out fps`:"waiting",ki=et?.canvasPresentation||"-",aa=et?`${et.interactiveBufferWaitCount} waits / ${Math.round(et.interactiveBufferWaitMs)}ms / ${et.interactiveQueueDrainCount} drains`:"waiting",sa=n.framesPerSecond>0?`${n.framesPerSecond.toFixed(1)} fps / p95 ${n.p95IntervalMs.toFixed(1)}ms / max ${n.maxIntervalMs.toFixed(1)}ms / long ${n.longTaskCount} (${Math.round(n.longTaskMs)}ms)`:"waiting",As=rn?Ce?.frameMode==="mode5-lzo-delta"?`${Zo(rn.averageFrameBytes)} avg / visual ${Ce.deltaVisualTileCount||0} + refresh ${Ce.deltaRefreshTileCount||0} / ${Ce.deltaTotalTiles||0}`:`${Zo(rn.averageFrameBytes)} avg / tiny ${Math.round(rn.tinyFrameRatio*100)}% / repeat ${Math.round(rn.repeatedFrameRatio*100)}%`:"waiting",qa=rn&&rn.sourceSendSampleCount>0?`${rn.sourceSendAverageMs.toFixed(1)}ms avg / p95 ${rn.sourceSendP95Ms.toFixed(1)}ms`:"waiting",Ga=qv(rn),fs=qv(wn),$c=rn&&wn?`rx ${Gv(rn)} / paint ${Gv(wn)}`:"waiting",Mi=Ce?Ce.frameMode||Ce.mode||Ce.codec||Ce.mimeType:Ye?Ze.frameMode:Te.frameMode,Ai=Ye?Ze.frameMode:Te.frameMode,Uc=Mi!==Ai?`${Ai} -> ${Mi}`:Ai,gn=Ce?`${Ce.width}x${Ce.height} ${Zo(Ce.byteLength)}`:Ye?`${$a.maxWidth}x${$a.maxHeight}`:`${Te.maxWidth}x${Te.maxHeight}`,kt=Ce?Ce.frameMode==="mode2-lzo"?"independent":`${Ce.isKeyFrame?"key":String(Ce.chunkType||"delta")}`:"-",it=Ce&&Ce.monitorCount?`${(Ce.monitorIndex??0)+1}/${Ce.monitorCount}`:"-",Ns=Ce?[`src ${Math.round(Ce.sourceGapMs||0)}ms`,`gap ${Math.round(Ce.agentSendGapMs||0)}ms`,`tx ${Math.round(Ce.agentSendDurationMs||0)}ms`,`pace ${Math.round(Ce.agentPaceMs||0)}ms`,`queue ${Math.round(Ce.agentQueueBeforePaceMs||0)}ms`,`age ${Math.round(Ce.agentFrameAgeMs||0)}ms`,Ce.browserReceivedEpochMs&&Ce.receivedAt?`hub ${Math.max(0,Math.round(Ce.browserReceivedEpochMs-Date.parse(Ce.receivedAt)))}ms`:"",Ce.browserReceivedEpochMs&&Ce.hubPacketEpochMs?`sock ${Math.max(0,Math.round(Ce.browserReceivedEpochMs-Ce.hubPacketEpochMs))}ms`:"",Ce.droppedByAgent?`drop ${Ce.droppedByAgent}`:"",Ce.hubIngressDropped?`ingress-drop ${Ce.hubIngressDropped}`:"",Ce.hubClientDropped?`ws-drop ${Ce.hubClientDropped}`:"",Ce.captureStageMs?`capture ${Math.round(Ce.captureStageMs)}ms`:"",Ce.requestedFps?`req ${Math.round(Ce.requestedFps)}fps`:"",Ce.effectiveFps?`eff ${Math.round(Ce.effectiveFps)}fps`:"",Ce.captureAverageMs?`avg ${Math.round(Ce.captureAverageMs)}ms`:"",Ce.captureP95Ms?`p95 ${Math.round(Ce.captureP95Ms)}ms`:"",Ce.slowFrameCount?`slow ${Math.round(Ce.slowFrameCount)}`:"",Ce.captureHelperRestarts?`helper ${Math.round(Ce.captureHelperRestarts)}`:"",Ce.convertMs?`rgb565 ${Math.round(Ce.convertMs)}ms`:"",Ce.compressMs?`lzo ${Math.round(Ce.compressMs)}ms`:"",Ce.captureSourceSerial?`cap #${Ce.captureSourceSerial}`:"",Ce.captureSourceSkipped?`cap skip ${Ce.captureSourceSkipped}`:"",Ce.frameMode==="mode5-lzo-delta"?`tiles ${Ce.deltaVisualTileCount||0}+${Ce.deltaRefreshTileCount||0}/${Ce.deltaTotalTiles||0}@${Ce.deltaTileSize||0}`:"",Ce.platformProfile||Ce.hardwareEncoder||"-",Ce.atlasComposeMs?`atlas ${Ce.atlasComposeMs.toFixed(1)}ms`:"",Ce.atlasPoolStarved?`pool ${Ce.atlasPoolStarved}`:"",Ce.atlasTileCount?`tiles ${Ce.atlasReadyTiles||0}/${Ce.atlasTileCount}`:"",et?.inputFeedbackMs!==void 0&&et.inputFeedbackAt!==void 0&&performance.now()-et.inputFeedbackAt<=Hv?`feedback ${Math.round(et.inputFeedbackMs)}ms`:"",Ce.contentHash?`enc ${Ce.contentHash.slice(0,6)}`:"",et?.visualHash?`pix ${et.visualHash.slice(0,6)}`:""].filter(Boolean).join(" / "):"-",la=vi==="open"?[`${ka.sentPerSecond.toFixed(1)} hz`,ka.lastInputSeq>0?`rtt ${Math.round(ka.lastRoundTripMs)}ms`:"",ka.lastInputSeq>0?`apply ${ka.lastAgentApplyMs.toFixed(1)}ms`:"",ka.droppedPerSecond>0?`drop ${ka.droppedPerSecond.toFixed(1)}/s`:"",ka.bufferedAmount>0?`buf ${Zo(ka.bufferedAmount)}`:"",ka.lastInputType||"ready"].filter(Boolean).join(" / "):vi,uo=et?.inputFeedbackMs!==void 0&&et.inputFeedbackAt!==void 0&&performance.now()-et.inputFeedbackAt<=Hv?`${Math.round(et.inputFeedbackMs)}ms / input #${et.inputFeedbackSeq||0}`:"waiting for changed frame",Ts=Pe?[no,`context ${pn.audioContextState}`,`queue ${Math.round(pn.queuedMs)}ms`,`last ${Math.round(pn.lastPacketAgeMs)}ms`,`accepted ${Math.round(pn.lastAcceptedAgeMs)}ms`,`process ${Math.round(pn.localProcessingAgeMs)}ms`,`remote ${Math.round(pn.browserAgeMs)}/${Math.round(pn.captureAgeMs)}ms`,`heartbeat ${Math.round(pn.captureStatusAgeMs)}ms`,`capture ${pn.captureAlive&&pn.helperAlive?"alive":"down"}`,`drop ${pn.drops}`,`resync ${pn.resyncs}`,`restart ${pn.automaticRestarts}`,pn.pendingDecodes>0?`decode ${pn.pendingDecodes}`:"",Ys?`#${Ys.frameSeq}`:"waiting"].filter(Boolean).join(" / "):"off",Pc=Ce?`#${Ce.frameSeq} ${Jm(Ce.receivedAt||Ce.capturedAt)}`:"waiting",Ws=Math.max(0,eo.bytesPerSecond*8/1e6),Qs=Ua?.atlasReadyTiles??Tl,ms=Ua?.atlasTileCount??Tl,fo=Qs===ms?`${ms} tiles`:`${Qs}/${ms} tiles`,Ni=Ye?`1 stream / ${Si} / ${Ws.toFixed(Ws>=10?0:1)}Mbps`:lt?`1 stream / ${fo} / ${Si} / ${Ws.toFixed(Ws>=10?0:1)}Mbps`:`${Tl} screens / ${Si} / ${Ws.toFixed(Ws>=10?0:1)}Mbps`,mr=M?"offline":k?.started?"online":"starting",Ya=Zn.length,hs=Ye?Ae?Yi(Ae):"No workstation":Ya===0?"No workstation":Ya>1?`${Ya} selected`:Ae?Yi(Ae):"No workstation",Lt=Fr[ct]||Fr.en,ia=Lt.sync||Fr.en.sync,hr=i||H?"checking":D?At==="pro"?"Pro LTD active":`Plus LTD ${We.length}/${Xo}`:Dd?`Free ${We.length}/${Qo}`:`Upgrade ${We.length}/${Qo}`,mo=At==="pro"?"Pro active":qe==="checkout"?"Opening":At==="ltd"?"Pro $199":"Plus $79",pr=D?At==="pro"?"Pro active":"Upgrade to Pro LTD":a?qe==="checkout"?"Opening checkout":At==="ltd"?"Buy Pro LTD":"Buy Plus LTD":qe==="auth"?"Opening Google":"Sign in to buy",Xs=At==="pro"||qe==="checkout"||qe==="auth"||i||H,on=a?.user.user_metadata,Zs=Jv(on,"avatar_url","picture"),Ll=Jv(on,"full_name","name")||a?.user.email||"Google",qc=Ll.slice(0,1).toUpperCase(),Hd=k?.started?"Local app ready":"Start LiveDesk",$d=r?.active?"Published":a?"Not published":"Sign in required",Ht=/^\d{6}$/.test(k?.pairingPin||"")?k?.pairingPin:"------",ho=rd.find(y=>y.width===Te.maxWidth&&y.height===Te.maxHeight)?.id||`${Te.maxWidth}x${Te.maxHeight}`,Ri=Te.atlasTileSizeMode==="auto"?"auto":Fm.find(y=>y.width===Te.atlasTileWidth&&y.height===Te.atlasTileHeight)?.id||"320x180",Ei=Bm.find(y=>y.width===Ze.maxWidth&&y.height===Ze.maxHeight)?.id||`${Ze.maxWidth}x${Ze.maxHeight}`,po=id.find(y=>y.id===Te.frameMode)||id[0],xn=y=>{za(E=>{const _=y.frameMode?uh(y.frameMode):E.frameMode,G=y.frameMode!==void 0&&_!==E.frameMode;return{...E,...y,frameMode:_,fps:fh(y.fps??(G?yw(_):E.fps),_)}})},zl=y=>{const E=rd.find(_=>_.id===y);E&&xn({maxWidth:E.width,maxHeight:E.height})},Ud=y=>{if(y==="auto"){xn({atlasTileSizeMode:"auto"});return}const E=Fm.find(_=>_.id===y);!E?.width||!E?.height||xn({atlasTileSizeMode:"fixed",atlasTileWidth:E.width,atlasTileHeight:E.height})},Js=y=>{y.frameMode!==void 0&&(U(""),we("")),_a(E=>{const _=y.frameMode?dh(y.frameMode):E.frameMode,G=y.frameMode!==void 0&&_!==E.frameMode,O=y.fps??(G?30:E.fps),pe=y.maxWidth??E.maxWidth,xe=y.maxHeight??E.maxHeight;return{...E,...y,frameMode:_,fps:Qa(O,20,_==="mode5-lzo-delta"?30:60,_==="mode5-lzo-delta"?30:60),maxWidth:_==="mode5-lzo-delta"?Math.min(1920,pe):pe,maxHeight:_==="mode5-lzo-delta"?Math.min(1080,xe):xe}})},Pd=y=>{const E=Bm.find(_=>_.id===y);E&&Js({maxWidth:E.width,maxHeight:E.height})},gr=y=>{if(y==="control"){const E=Qt||Wt;if(E&&(ut(!1),Q(E.deviceId)),le(y),!Xt){ze(!1),be(bl);return}ze(!0);return}y==="wall"&&es(E=>E+1),le(y),ze(!1)};return l.jsxs("main",{className:"app-shell",children:[l.jsxs("aside",{className:"tool-rail","aria-label":"LiveDesk tools",children:[l.jsx("div",{className:"rail-brand",title:"LiveDesk",children:l.jsx(AA,{size:25})}),l.jsx("nav",{className:"rail-tools",children:TA.map(y=>{const E=y.icon;return l.jsxs("button",{className:`rail-tool ${y.id==="sync-server"?"sync-server":""} ${Z===y.id?"active":""} accent-${y.accent}`,onClick:()=>y.id==="sync-server"?void Ma({takeover:!0,requestLocalAccess:!0}):gr(y.id),title:y.label,type:"button",children:[l.jsx(E,{size:19}),l.jsx("span",{children:y.label})]},y.id)})}),l.jsxs("div",{className:"rail-footer",children:[RA.map(y=>{const E=y.icon;return l.jsxs("button",{className:`rail-tool compact ${Z===y.id?"active":""} accent-${y.accent}`,onClick:()=>gr(y.id),title:y.label,type:"button",children:[l.jsx(E,{size:18}),l.jsx("span",{children:y.label})]},y.id)}),l.jsxs("button",{className:`rail-tool compact local-settings ${Xn?"active":""}`,onClick:()=>{le("settings"),Dt(!1),ze(!1),Ne(!1)},title:"Settings",type:"button",children:[l.jsx(rS,{size:18}),l.jsx("span",{children:"Settings"})]}),l.jsxs("button",{className:`rail-account ${a?"signed-in":""}`,onClick:()=>{Dt(y=>!y)},disabled:i||qe==="auth","aria-expanded":Oe,title:a?`Account: ${a.user.email||Ll}`:"Sign in with Google",type:"button",children:[a?Zs?l.jsx("img",{src:Zs,alt:Ll,referrerPolicy:"no-referrer"}):l.jsx("span",{className:"avatar-fallback",children:qc}):l.jsx(pm,{size:18}),l.jsx("span",{children:a?"Account":"Google"})]}),Oe&&l.jsxs("section",{className:"account-popover",role:"dialog","aria-label":"LiveDesk account",children:[l.jsxs("div",{className:"account-popover-head",children:[l.jsx("div",{className:"account-popover-avatar",children:a&&Zs?l.jsx("img",{src:Zs,alt:Ll,referrerPolicy:"no-referrer"}):a?l.jsx("span",{children:qc}):l.jsx(pm,{size:18})}),l.jsxs("div",{children:[l.jsx("strong",{children:a?Ll:"Account"}),l.jsx("p",{children:a?.user.email||"Not signed in"})]})]}),l.jsxs("dl",{className:"account-popover-facts",children:[l.jsx("dt",{children:"User"}),l.jsx("dd",{children:a?.user.email||"Not signed in"}),l.jsx("dt",{children:"Network"}),l.jsx("dd",{children:Hd}),l.jsx("dt",{children:"Access"}),l.jsx("dd",{children:$d}),l.jsx("dt",{children:"Plan"}),l.jsx("dd",{children:hr}),l.jsx("dt",{children:"Ads"}),l.jsx("dd",{children:At==="free"?"Standard banner":"Removed"})]}),a?l.jsxs("button",{className:"account-popover-action",onClick:Vs,disabled:qe==="auth",type:"button",children:[l.jsx(oS,{size:16}),"Logout"]}):l.jsxs("button",{className:"account-popover-action primary",onClick:bi,disabled:qe==="auth",type:"button",children:[l.jsx(pm,{size:16}),"Sign in with Google"]})]})]})]}),l.jsxs("section",{className:`desk-stage ${Yr&&!ke?"dock-open":""} ${Ye?"control-stage":""}`,children:[l.jsxs("header",{className:"topbar",children:[l.jsxs("div",{className:"brand",children:[l.jsx("span",{className:"brand-mark",children:l.jsx(nn,{size:18})}),l.jsxs("div",{children:[l.jsx("h1",{children:"LiveDesk"}),l.jsx("p",{children:"Control wall for local machines"})]})]}),Ha&&!Ye&&l.jsxs("div",{className:"file-share-top-route","aria-label":"File distribution route",children:[l.jsxs("div",{children:[l.jsx(Vo,{size:17}),l.jsxs("span",{children:[l.jsx("small",{children:"Source"}),l.jsx("strong",{children:"LiveDesk Hub"})]})]}),l.jsx(gh,{size:15}),l.jsx(cS,{size:16}),l.jsxs("div",{children:[l.jsx("span",{className:"file-share-top-route-laptops",children:"▣ ▣ ▣"}),l.jsxs("span",{children:[l.jsx("small",{children:"Destination"}),l.jsxs("strong",{children:[is," workstation",is===1?"":"s"]}),l.jsx("em",{children:Gn.trim()||"Desktop/LiveDeskFiles"})]})]})]}),Yr&&!Ye&&l.jsxs("div",{className:"top-actions",children:[l.jsx(Ov,{controller:Tc,onError:be}),l.jsx("span",{className:"top-actions-divider","aria-hidden":"true"}),l.jsx("div",{className:"segmented-control","aria-label":"Screen size",children:NA.map(y=>l.jsx("button",{className:Me===y.id?"active":"",onClick:()=>je(y.id),type:"button",children:y.label},y.id))})]}),Ye&&l.jsx("div",{className:"top-actions",children:l.jsx(Ov,{controller:Tc,onError:be})})]}),Zi?l.jsxs("section",{className:"doc-page",lang:ct,dir:ct==="ar"?"rtl":"ltr",children:[l.jsxs("section",{className:"doc-hero",children:[l.jsxs("div",{className:"doc-hero-copy",children:[l.jsxs("span",{className:"pricing-eyebrow",children:[l.jsx(Vm,{size:16}),Lt.eyebrow]}),l.jsx("h2",{children:Lt.title}),l.jsx("p",{children:Lt.intro})]}),l.jsxs("label",{className:"doc-language-picker",children:[l.jsxs("span",{children:[l.jsx(uS,{size:17}),Lt.languageLabel]}),l.jsx("select",{value:ct,onChange:y=>sn(y.target.value),children:DA.map(y=>l.jsx("option",{value:y.id,children:y.label},y.id))})]})]}),l.jsx("section",{className:"doc-grid",children:Lt.sections.map((y,E)=>{const G=[Ax,Ko,td,Sn,Jo][E]||Vm;return l.jsxs("article",{className:"doc-card",children:[l.jsx("div",{className:"doc-card-icon",children:l.jsx(G,{size:19})}),l.jsxs("div",{children:[l.jsx("h3",{children:y.title}),l.jsx("p",{children:y.body}),l.jsx("ul",{children:y.points.map(O=>l.jsx("li",{children:O},O))})]})]},y.title)})}),ia&&l.jsxs("section",{className:"doc-sync",children:[l.jsxs("div",{className:"doc-sync-head",children:[l.jsx(td,{size:20}),l.jsxs("div",{children:[l.jsx("h3",{children:ia.title}),l.jsx("p",{children:ia.body})]})]}),l.jsx("ul",{children:ia.points.map(y=>l.jsx("li",{children:y},y))})]}),l.jsxs("section",{className:"doc-firewall",children:[l.jsxs("div",{className:"doc-firewall-head",children:[l.jsx(Sn,{size:20}),l.jsxs("div",{children:[l.jsx("h3",{children:Lt.firewall.title}),l.jsx("p",{children:Lt.firewall.body})]})]}),l.jsx("ul",{children:Lt.firewall.points.map(y=>l.jsx("li",{children:y},y))})]}),l.jsxs("section",{className:"doc-command-panel",children:[l.jsxs("div",{className:"doc-command-head",children:[l.jsx(Ko,{size:20}),l.jsxs("div",{children:[l.jsx("h3",{children:Lt.commands.title}),l.jsx("p",{children:Lt.commands.body})]})]}),l.jsxs("div",{className:"doc-command-list",children:[Lt.commands.manager&&l.jsxs("div",{className:"doc-command-row",children:[l.jsx("span",{children:Lt.commands.manager}),l.jsx("code",{children:Nl}),l.jsx("button",{className:"icon-button",onClick:()=>qi(Nl),title:"Copy command",type:"button",children:l.jsx(Bi,{size:16})})]}),l.jsxs("div",{className:"doc-command-row",children:[l.jsx("span",{children:Lt.commands.primary}),l.jsx("code",{children:$n}),l.jsx("button",{className:"icon-button",onClick:()=>qi($n),title:"Copy command",type:"button",children:l.jsx(Bi,{size:16})})]}),l.jsxs("div",{className:"doc-command-row",children:[l.jsx("span",{children:Lt.commands.slot}),l.jsx("code",{children:`${$n} 3`}),l.jsx("button",{className:"icon-button",onClick:()=>qi(`${$n} 3`),title:"Copy command",type:"button",children:l.jsx(Bi,{size:16})})]})]})]})]}):Bs?l.jsx(hM,{hubUrl:C,devices:j}):Ha?l.jsx(xk,{hubUrl:C,devices:We,localFeatureAccess:Xt,upgradeNotice:bl,notice:ye,remoteDirectory:Gn,onRemoteDirectoryChange:ii,targetMode:ls,selectedTargetIds:mn,onTargetModeChange:Nd,onTargetToggle:y=>oi(E=>E.includes(y)?E.filter(_=>_!==y):[...E,y]),filePickerRef:Rd,folderPickerRef:Cc,onBrowserFileImport:y=>{ea(y)},onBrowserFolderImport:y=>{ea(y)},onNotice:be,onTransferChange:y=>{if(!y){Kt(null);return}const E=y.state==="failed"||y.state==="partially-failed"||y.state==="cancelled"?"failed":y.state==="completed"?"queued":y.state==="sending"?"sending":"reading";Kt({id:y.id,status:E,progress:y.progress,message:y.message}),["completed","partially-failed","failed","cancelled"].includes(y.state)&&window.setTimeout(()=>Kt(_=>_?.id===y.id?null:_),4500)}}):Xn?l.jsx(_0,{hubUrl:C,pin:l.jsxs(O0,{children:[(M||c||B||ye)&&l.jsx("section",{className:"notice-band",children:M||c||B||ye}),l.jsxs("div",{className:"settings-section-grid",children:[l.jsxs("section",{className:"settings-section-card settings-pairing-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Pair a workstation"}),l.jsx("h3",{children:"Connect another local PC"})]}),l.jsx(an,{size:20})]}),l.jsxs("div",{className:"settings-pin-display",children:[l.jsx("span",{children:"Hub PIN"}),l.jsx("strong",{children:Ht}),l.jsxs("button",{className:"text-button ghost compact",onClick:ao,disabled:!k?.started||qe==="pin",type:"button",children:[l.jsx(oc,{size:15}),qe==="pin"?"Creating":"New PIN"]})]})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Hub status"}),l.jsx("h3",{children:mr})]}),l.jsx("span",{className:`settings-status-dot state-${mr}`})]}),l.jsxs("dl",{className:"settings-facts",children:[l.jsx("dt",{children:"Address"}),l.jsx("dd",{children:C||"-"}),l.jsx("dt",{children:"Connected workstations"}),l.jsxs("dd",{children:[dr,"/",Fs]}),l.jsx("dt",{children:"Sync access"}),l.jsx("dd",{children:k?.started?"Local app ready":"Start Hub first"}),l.jsx("dt",{children:"Plan"}),l.jsx("dd",{children:hr})]}),l.jsxs("div",{className:"settings-action-row",children:[l.jsxs("button",{className:"text-button primary",onClick:()=>Ma({takeover:!0,requestLocalAccess:!0}),disabled:!a||qe==="host",type:"button",children:[l.jsx(td,{size:16}),"Sync access"]}),l.jsxs("button",{className:"text-button buy",onClick:()=>Nn(At==="ltd"?"pro":"ltd"),disabled:qe==="checkout"||At==="pro",type:"button",children:[l.jsx(Wo,{size:16}),mo]})]})]})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"File transfer"}),l.jsx("h3",{children:"Client destination folder"})]}),l.jsx(nc,{size:20})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Remote folder"}),l.jsx("input",{value:Gn,onChange:y=>ii(y.target.value),placeholder:"Desktop/LiveDeskFiles"})]}),l.jsx("p",{className:"settings-help",children:"Blank uses Desktop/LiveDeskFiles on each workstation."})]})]}),wall:l.jsx(I0,{children:l.jsxs("div",{className:"settings-section-grid",children:[l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Wall stream"}),l.jsx("h3",{children:"Frame delivery"})]}),l.jsx(cc,{size:20})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Frame mode"}),l.jsx("select",{value:Te.frameMode,onChange:y=>xn({frameMode:uh(y.target.value)}),children:id.map(y=>l.jsxs("option",{value:y.id,children:[y.label," - ",y.detail]},y.id))})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"H.264 decode"}),l.jsx("select",{value:Te.h264DecodeAcceleration,onChange:y=>xn({h264DecodeAcceleration:vd(y.target.value)}),children:ch.map(y=>l.jsx("option",{value:y.id,children:y.label},y.id))})]}),l.jsxs("div",{className:"settings-field-grid",children:[l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"FPS"}),l.jsx("select",{value:Te.fps,onChange:y=>xn({fps:fh(y.target.value,Te.frameMode)}),children:Oh.filter(y=>y<=ww(Te.frameMode)).map(y=>l.jsx("option",{value:y,children:y},y))})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:lt?"Atlas tile":"Resolution"}),l.jsx("select",{value:lt?Ri:ho,onChange:y=>lt?Ud(y.target.value):zl(y.target.value),children:(lt?Fm:rd).map(y=>l.jsx("option",{value:y.id,children:y.label},y.id))})]})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Quality"}),l.jsx("select",{value:Te.quality,onChange:y=>xn({quality:Qa(y.target.value,20,95,ha.quality)}),children:Yv.map(y=>l.jsx("option",{value:y,children:y},y))})]})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Wall behavior"}),l.jsx("h3",{children:"Visibility and load"})]}),l.jsx(nn,{size:20})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:Te.autoStartLive,onChange:y=>xn({autoStartLive:y.target.checked})}),l.jsx("span",{children:"Auto live on connected screens"})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:Te.visibleOnlyLive,onChange:y=>xn({visibleOnlyLive:y.target.checked})}),l.jsx("span",{children:"Stream visible tiles first"})]}),!lt&&l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:Te.adaptiveSizeByWall,onChange:y=>xn({adaptiveSizeByWall:y.target.checked})}),l.jsx("span",{children:"Fit stream size to Wall"})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:Te.adaptiveLoadShedding,onChange:y=>xn({adaptiveLoadShedding:y.target.checked})}),l.jsx("span",{children:"Reduce FPS under load"})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:Te.showScreenStatus,onChange:y=>xn({showScreenStatus:y.target.checked})}),l.jsx("span",{children:"Screen status overlay"})]}),l.jsxs("div",{className:"settings-summary",children:[l.jsx("span",{children:po.label}),l.jsxs("strong",{children:[Zt.maxWidth,"x",Zt.maxHeight," / ",Gt,"fps"]})]}),l.jsxs("button",{className:"settings-reset",onClick:()=>za(ha),type:"button",children:[l.jsx(tc,{size:15})," Reset Wall settings"]})]})]})}),control:l.jsx(B0,{children:l.jsxs("div",{className:"settings-section-grid",children:[l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Control stream"}),l.jsx("h3",{children:"Low-latency delivery"})]}),l.jsx(ed,{size:20})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Frame mode"}),l.jsx("select",{value:Ze.frameMode,onChange:y=>Js({frameMode:dh(y.target.value)}),children:KM.map(y=>l.jsx("option",{value:y.id,children:y.label},y.id))})]}),Ze.frameMode==="mode3-h264-hw"&&l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"H.264 decode"}),l.jsx("select",{value:Ze.h264DecodeAcceleration,onChange:y=>Js({h264DecodeAcceleration:vd(y.target.value)}),children:ch.map(y=>l.jsx("option",{value:y.id,children:y.label},y.id))})]}),l.jsxs("div",{className:"settings-field-grid",children:[l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"FPS"}),l.jsx("select",{value:Ze.fps,onChange:y=>Js({fps:Qa(y.target.value,20,60,pa.fps)}),children:WM.filter(y=>Ze.frameMode==="mode3-h264-hw"||y<=30).map(y=>l.jsx("option",{value:y,children:y},y))})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Resolution"}),l.jsx("select",{value:Ei,onChange:y=>Pd(y.target.value),children:Bm.filter(y=>Ze.frameMode==="mode3-h264-hw"||y.width<=1920).map(y=>l.jsx("option",{value:y.id,children:y.label},y.id))})]})]}),Ze.frameMode==="mode3-h264-hw"&&l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Quality"}),l.jsx("select",{value:Ze.quality,onChange:y=>Js({quality:Qa(y.target.value,20,95,pa.quality)}),children:Yv.map(y=>l.jsx("option",{value:y,children:y},y))})]})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Control behavior"}),l.jsx("h3",{children:"Session display"})]}),l.jsx(an,{size:20})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:Ze.showScreenStatus,onChange:y=>Js({showScreenStatus:y.target.checked})}),l.jsx("span",{children:"Screen status overlay"})]}),l.jsxs("div",{className:"settings-summary control",children:[l.jsx("span",{children:Ze.frameMode==="mode5-lzo-delta"?"Mode 5 tile delta":"Mode 3 H.264"}),l.jsxs("strong",{children:[$a.maxWidth,"x",$a.maxHeight," / ",Ca,"fps"]})]}),l.jsxs("button",{className:"settings-reset",onClick:()=>_a(pa),type:"button",children:[l.jsx(tc,{size:15})," Reset Control settings"]})]})]})}),agent:l.jsx(F0,{hubUrl:C}),captureGallery:l.jsx(wM,{hubUrl:C,onToast:be}),advancedExtras:l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Connection commands"}),l.jsx("h3",{children:"Developer setup"})]}),l.jsx(Bi,{size:20})]}),l.jsxs("div",{className:"settings-command-list",children:[l.jsxs("div",{className:"settings-command-row",children:[l.jsx("span",{children:"Client"}),l.jsx("code",{children:$n}),l.jsx("button",{className:"icon-button",onClick:()=>qi($n),title:"Copy client command",type:"button",children:l.jsx(Bi,{size:16})})]}),l.jsxs("div",{className:"settings-command-row",children:[l.jsx("span",{children:"Slot example"}),l.jsx("code",{children:`${$n} 3`}),l.jsx("button",{className:"icon-button",onClick:()=>qi(`${$n} 3`),title:"Copy slot command",type:"button",children:l.jsx(Bi,{size:16})})]}),l.jsxs("div",{className:"settings-command-row",children:[l.jsx("span",{children:"Hub"}),l.jsx("code",{children:Nl}),l.jsx("button",{className:"icon-button",onClick:()=>qi(Nl),title:"Copy Hub command",type:"button",children:l.jsx(Bi,{size:16})})]})]})]})}):Xi?l.jsxs("section",{className:"pricing-page",children:[l.jsxs("header",{className:"pricing-header",children:[l.jsxs("div",{children:[l.jsxs("span",{className:"pricing-eyebrow",children:[l.jsx(Ym,{size:15})," LiveDesk plans"]}),l.jsx("h2",{children:"Choose the plan that fits your wall"}),l.jsx("p",{children:"Start free with a local screen wall. Upgrade when you need ad-free monitoring, more workstations, or commercial controls."})]}),l.jsx("button",{className:"pricing-close",onClick:()=>gr("wall"),title:"Close pricing",type:"button",children:l.jsx(Hr,{size:18})})]}),(B||ye)&&l.jsx("section",{className:"notice-band",children:B||ye}),l.jsxs("div",{className:"pricing-status","aria-live":"polite",children:[l.jsx("span",{children:"Current plan"}),l.jsx("strong",{children:Ac.name}),l.jsxs("small",{children:[We.length,"/",VM(er)," connected devices"]})]}),l.jsxs("div",{className:"pricing-cards","aria-label":"LiveDesk plans",children:[l.jsxs("article",{className:`pricing-plan-card ${At==="free"?"current":""}`,children:[l.jsxs("div",{className:"pricing-plan-topline",children:[l.jsx("span",{className:"pricing-plan-badge free",children:"Free"}),l.jsx("strong",{children:"$0"})]}),l.jsx("p",{className:"pricing-plan-audience",children:$i.free.audience}),l.jsx("h3",{children:"Monitor your local wall"}),l.jsx("p",{children:$i.free.note}),l.jsxs("ul",{children:[l.jsxs("li",{children:[l.jsx(qn,{size:16})," Up to ",Qo," devices"]}),l.jsxs("li",{children:[l.jsx(qn,{size:16})," Live view and local control"]}),l.jsxs("li",{children:[l.jsx(qn,{size:16})," Standard ad-supported banner"]})]}),l.jsx("span",{className:"pricing-current-label",children:At==="free"?"Current plan":"Included for everyone"})]}),l.jsxs("article",{className:`pricing-plan-card featured ${At==="ltd"?"current":""}`,children:[l.jsxs("div",{className:"pricing-plan-topline",children:[l.jsxs("span",{className:"pricing-plan-badge plus",children:[l.jsx(dS,{size:14})," Plus"]}),l.jsx("strong",{children:"$5"})]}),l.jsx("p",{className:"pricing-plan-audience",children:$i.ltd.audience}),l.jsx("h3",{children:"Ad-free monitoring"}),l.jsx("p",{children:"More room for personal AI workstations without the standard banner."}),l.jsxs("ul",{children:[l.jsxs("li",{children:[l.jsx(qn,{size:16})," Up to ",Xo," devices"]}),l.jsxs("li",{children:[l.jsx(qn,{size:16})," No standard ad banner"]}),l.jsxs("li",{children:[l.jsx(qn,{size:16})," ",$i.ltd.ltd]})]}),l.jsxs("button",{className:"pricing-plan-button",onClick:a?()=>Nn("ltd"):bi,disabled:At!=="free"||qe==="checkout"||qe==="auth"||i||H,type:"button",children:[l.jsx(Wo,{size:16}),At==="free"?a?"Choose Plus":"Sign in for Plus":"Plus active"]})]}),l.jsxs("article",{className:`pricing-plan-card pro ${At==="pro"?"current":""}`,children:[l.jsxs("div",{className:"pricing-plan-topline",children:[l.jsxs("span",{className:"pricing-plan-badge pro",children:[l.jsx(Sn,{size:14})," Pro"]}),l.jsx("strong",{children:"$15"})]}),l.jsx("p",{className:"pricing-plan-audience",children:$i.pro.audience}),l.jsx("h3",{children:"For serious operations"}),l.jsx("p",{children:"Commercial-ready monitoring for larger AI labs, studios, and teams."}),l.jsxs("ul",{children:[l.jsxs("li",{children:[l.jsx(qn,{size:16})," 30+ workstation walls"]}),l.jsxs("li",{children:[l.jsx(qn,{size:16})," Commercial use included"]}),l.jsxs("li",{children:[l.jsx(qn,{size:16})," ",$i.pro.ltd]})]}),l.jsxs("button",{className:"pricing-plan-button",onClick:a?()=>Nn("pro"):bi,disabled:At==="pro"||qe==="checkout"||qe==="auth"||i||H,type:"button",children:[l.jsx(Wo,{size:16}),At==="pro"?"Pro active":a?"Choose Pro":"Sign in for Pro"]})]})]}),l.jsxs("section",{className:"pricing-includes",children:[l.jsxs("div",{children:[l.jsx(an,{size:17}),l.jsx("span",{children:"Screen wall"}),l.jsx("strong",{children:"120+ slots"})]}),l.jsxs("div",{children:[l.jsx(ed,{size:17}),l.jsx("span",{children:"Focused control"}),l.jsx("strong",{children:"Local-first"})]}),l.jsxs("div",{children:[l.jsx(Nx,{size:17}),l.jsx("span",{children:"Remote audio"}),l.jsx("strong",{children:"Available"})]}),l.jsxs("div",{children:[l.jsx(nc,{size:17}),l.jsx("span",{children:"File transfer"}),l.jsx("strong",{children:"Included"})]})]}),l.jsxs("p",{className:"pricing-note",children:[l.jsx(qn,{size:15})," Commercial use requires Pro. Plus LTD is for personal, creator, and homelab use."]}),l.jsxs("button",{className:"pricing-primary-cta",onClick:a?()=>Nn(At==="ltd"?"pro":"ltd"):bi,disabled:Xs,type:"button",children:[l.jsx(Wo,{size:18}),pr]})]}):l.jsx(l.Fragment,{children:l.jsxs("section",{className:`monitor-layout ${ke?"dock-collapsed":""}`,children:[l.jsxs("section",{ref:Gr,className:`screen-wall-panel ${vc?"drop-active":""}`,onClick:y=>{y.currentTarget===y.target&&Al()},onDragEnter:y=>{y.preventDefault(),qr(!0)},onDragOver:y=>{y.preventDefault(),y.dataTransfer.dropEffect="copy"},onDragLeave:y=>{y.currentTarget===y.target&&qr(!1)},onDrop:ur,children:[lt&&l.jsx("canvas",{ref:Dc,className:"atlas-source-canvas",width:ja?.width||1920,height:ja?.height||1080,"aria-hidden":"true"}),Ye?l.jsx("section",{className:"control-focus",children:l.jsxs("div",{className:"control-wall",children:[Ae&&ji.length>1&&l.jsx("div",{className:"control-monitor-tabs","aria-label":"Select monitor",children:ji.map(y=>l.jsxs("button",{className:y.index===Ci?"active":"",onClick:()=>Fd(Ae.deviceId,y.index),title:uA(y),type:"button",children:[l.jsx("span",{children:y.name||`Display ${y.index+1}`}),y.width>0&&y.height>0&&l.jsxs("small",{children:[y.width,"x",y.height]})]},y.index))}),Ae?l.jsx(Gm,{device:Ae,frame:Ce,selected:!1,controlEnabled:cs&&me,showStatus:Ze.showScreenStatus,monitorIndex:Pn(Ke[Ae.deviceId],Bn(Ae)),monitorCount:Bn(Ae),onSelect:()=>{},onFocusDevice:()=>Q(Ae.deviceId),onOpenControl:()=>lo(Ae.deviceId),onCycleMonitor:y=>or(Ae.deviceId,y),onCanvasReady:Id,sendInput:kl,presentationReady:Tt},Ae.deviceId):l.jsxs("div",{className:"control-empty",children:[l.jsx(an,{size:30}),l.jsx("strong",{children:"No workstation"}),l.jsx("span",{children:"Open a workstation from the Wall."})]}),Ae&&!Tt&&l.jsxs("div",{className:"control-connection-overlay",role:"status","aria-live":"polite",children:[R!=="error"&&l.jsx("span",{className:"control-connection-spinner","aria-hidden":"true"}),l.jsx("strong",{children:R==="error"?"Connection failed":"Connecting"}),l.jsx("small",{children:R==="error"?ks||ie?`Control stream: ${ks||ie}`:"No control frame was received. Reopen Control to retry.":ks||ie?`Control stream: ${ks||ie}`:Jr==="open"?"Preparing the first control frame":"Opening the Control stream"})]})]})}):lt?l.jsx("div",{className:`screen-wall atlas-slot-wall size-${Me}`,onClick:y=>{y.currentTarget===y.target&&Al()},children:vl.map((y,E)=>y?l.jsx(Gm,{device:y,frame:xi.get(y.deviceId),selected:rs.has(y.deviceId),controlEnabled:!1,showStatus:Te.showScreenStatus,monitorIndex:Pn(Ke[y.deviceId],Bn(y)),monitorCount:Bn(y),onSelect:()=>Ms(y.deviceId),onFocusDevice:()=>Ks(y.deviceId),onOpenControl:()=>lo(y.deviceId),onCycleMonitor:_=>or(y.deviceId,_),onCanvasReady:Lc,sendInput:kl},y.deviceId):l.jsx(ty,{index:E},`slot-${E}`))}):l.jsx("div",{className:`screen-wall size-${Me}`,onClick:y=>{y.currentTarget===y.target&&Al()},children:vl.map((y,E)=>y?l.jsx(Gm,{device:y,frame:xi.get(y.deviceId),selected:rs.has(y.deviceId),controlEnabled:cs&&me&&Ae?.deviceId===y.deviceId,showStatus:Te.showScreenStatus,monitorIndex:Pn(Ke[y.deviceId],Bn(y)),monitorCount:Bn(y),onSelect:()=>Ms(y.deviceId),onFocusDevice:()=>Ks(y.deviceId),onOpenControl:()=>lo(y.deviceId),onCycleMonitor:_=>or(y.deviceId,_),onCanvasReady:Od,sendInput:kl},y.deviceId):l.jsx(ty,{index:E},`slot-${E}`))}),l.jsx(zA,{visible:Ld&&!Ye})]}),!Xn&&l.jsxs("aside",{className:`right-dock actions-mode ${ke?"collapsed":""}`,"aria-label":"LiveDesk tools",children:[l.jsx("button",{className:"dock-toggle",onClick:()=>Ne(y=>!y),"aria-label":ke?"Show control panel":"Hide control panel",title:ke?"Show control panel":"Hide control panel",type:"button",children:ke?l.jsx(ry,{size:18}):l.jsx(xh,{size:18})}),!ke&&l.jsxs(l.Fragment,{children:[l.jsxs("section",{className:"action-dock",children:[l.jsxs("div",{className:"action-context",children:[l.jsx("span",{children:Ye?"Control target":Ya>0?"Selection":"No selection"}),l.jsx("strong",{children:hs})]}),l.jsx("input",{ref:Is,className:"hidden-file-input",type:"file",multiple:!0,onChange:y=>{y.currentTarget.files&&cr(y.currentTarget.files),y.currentTarget.value=""}}),(M||ye)&&l.jsx("div",{className:"notice-band compact",children:l.jsx("span",{children:M||ye})}),l.jsxs("div",{className:"action-grid",children:[l.jsxs("button",{className:"action-tile primary",onClick:()=>Ae&&Ic(Ae.deviceId),disabled:!Wr,type:"button",children:[l.jsx(Tx,{size:21}),l.jsx("span",{children:"Live"})]}),l.jsxs("button",{className:`action-tile ${me?"active":""}`,onClick:()=>ze(y=>!y),disabled:!cs,title:Ji?"Allow Accessibility for the terminal app that starts LiveDesk, then restart the Mac client.":cs?"Remote keyboard and mouse control":"Remote control is not available on this workstation",type:"button",children:[l.jsx(ed,{size:21}),l.jsx("span",{children:vi!=="idle"?vi:"Control"})]}),l.jsxs("button",{className:`action-tile ${Pe?"active":""}`,onClick:Bc,disabled:!Nc,type:"button",title:wl?"Remote PC audio":"Remote audio is not supported by this workstation yet",children:[l.jsx(Nx,{size:21}),l.jsx("span",{children:Pe&&no!=="idle"?no:"Audio"})]}),l.jsxs("button",{className:"action-tile",onClick:()=>Is.current?.click(),disabled:!Xt||(Ye?!Ae:Zn.length===0),type:"button",title:"File transfer",children:[l.jsx(nc,{size:21}),l.jsx("span",{children:"Files"})]}),l.jsxs("button",{className:"action-tile",disabled:!0,type:"button",title:"Reboot",children:[l.jsx(tc,{size:21}),l.jsx("span",{children:"Reboot"})]}),l.jsxs("button",{className:"action-tile",disabled:!0,type:"button",title:"Power",children:[l.jsx(fS,{size:21}),l.jsx("span",{children:"Power"})]}),l.jsxs("button",{className:"action-tile",disabled:!0,type:"button",title:"Terminal",children:[l.jsx(Ko,{size:21}),l.jsx("span",{children:"Shell"})]})]})]}),Ae&&Jn&&l.jsxs("section",{className:"side-panel selected-panel",children:[l.jsxs("div",{className:"machine-detail-head",children:[l.jsxs("div",{className:"panel-title",children:[l.jsx(an,{size:17}),l.jsx("h2",{children:"Machine detail"})]}),l.jsx("span",{className:`machine-health state-${Jn.state}`,children:Jn.label})]}),l.jsxs("div",{className:"machine-title",children:[l.jsx("strong",{children:Yi(Ae)}),l.jsx("span",{children:Jn.role})]}),l.jsx("div",{className:"machine-metric-grid",children:Jn.metrics.map(y=>l.jsxs("article",{className:`machine-metric state-${y.state}`,children:[l.jsx("span",{children:y.label}),l.jsx("strong",{children:y.value}),l.jsx("small",{children:y.detail}),y.ratio!==void 0&&l.jsx("i",{children:l.jsx("b",{style:{width:`${Math.round(y.ratio*100)}%`}})})]},y.id))}),l.jsxs("section",{className:"machine-section",children:[l.jsxs("div",{className:"machine-section-title",children:[l.jsx(nn,{size:15}),l.jsx("span",{children:"Stream"})]}),l.jsxs("dl",{className:"facts compact",children:[l.jsx("dt",{children:"Frames"}),l.jsx("dd",{children:Fc}),l.jsx("dt",{children:Ye?"Control RX":lt?"Atlas RX":"Wall RX"}),l.jsx("dd",{children:Ni}),l.jsx("dt",{children:"Painted"}),l.jsx("dd",{children:co}),l.jsx("dt",{children:Ye?"Encoded changes":"Visual samples"}),l.jsx("dd",{children:Hc}),l.jsx("dt",{children:"Decoder"}),l.jsx("dd",{children:na}),l.jsx("dt",{children:"Decoder IO"}),l.jsx("dd",{children:fr}),l.jsx("dt",{children:"Canvas"}),l.jsx("dd",{children:ki}),l.jsx("dt",{children:"Control buffer"}),l.jsx("dd",{children:aa}),l.jsx("dt",{children:"Browser RAF"}),l.jsx("dd",{children:sa}),l.jsx("dt",{children:"Latency"}),l.jsx("dd",{children:El}),l.jsx("dt",{children:"Cadence"}),l.jsx("dd",{children:Dl}),l.jsx("dt",{children:"Source send"}),l.jsx("dd",{children:qa}),l.jsx("dt",{children:"Packet mix"}),l.jsx("dd",{children:As}),l.jsx("dt",{children:"Receive gap"}),l.jsx("dd",{children:Ga}),l.jsx("dt",{children:"Paint gap"}),l.jsx("dd",{children:fs}),l.jsx("dt",{children:"Seq gap"}),l.jsx("dd",{children:$c}),l.jsx("dt",{children:"Selected"}),l.jsx("dd",{children:Pc}),l.jsx("dt",{children:"Requested"}),l.jsx("dd",{children:Uc}),l.jsx("dt",{children:"Mode"}),l.jsx("dd",{children:Mi}),l.jsx("dt",{children:"Chunk"}),l.jsx("dd",{children:kt}),l.jsx("dt",{children:"Size"}),l.jsx("dd",{children:gn}),l.jsx("dt",{children:"Native"}),l.jsx("dd",{children:ro}),l.jsx("dt",{children:"Monitor"}),l.jsx("dd",{children:it}),l.jsx("dt",{children:"Source"}),l.jsx("dd",{children:Ns}),l.jsx("dt",{children:"Input"}),l.jsx("dd",{children:la}),l.jsx("dt",{children:"Audio"}),l.jsx("dd",{children:Ts}),Ye&&l.jsxs(l.Fragment,{children:[l.jsx("dt",{children:"Visual feedback"}),l.jsx("dd",{children:uo})]})]})]}),l.jsxs("section",{className:"machine-section",children:[l.jsxs("div",{className:"machine-section-title",children:[l.jsx(Ko,{size:15}),l.jsx("span",{children:"Local services"})]}),l.jsx("div",{className:"tool-probe-list",children:Jn.tools.map(y=>l.jsxs("span",{className:`tool-probe state-${y.status}`,children:[l.jsx("b",{children:y.label}),l.jsx("em",{children:y.detail})]},y.id))})]}),l.jsxs("section",{className:"machine-section",children:[l.jsxs("div",{className:"machine-section-title",children:[l.jsx(cd,{size:15}),l.jsx("span",{children:"Workload"})]}),l.jsxs("div",{className:"workload-card",children:[l.jsx("strong",{children:Jn.taskLabel}),l.jsx("span",{children:Jn.taskStatus}),Jn.taskSummary&&l.jsx("p",{children:Jn.taskSummary})]})]}),l.jsxs("div",{className:"machine-section",children:[l.jsxs("div",{className:"machine-section-title",children:[l.jsx(Ax,{size:15}),l.jsx("span",{children:"System"})]}),l.jsxs("dl",{className:"facts compact",children:[l.jsx("dt",{children:"Platform"}),l.jsxs("dd",{children:[Ae.platform||"-"," ",Ae.arch||""]}),l.jsx("dt",{children:"Release"}),l.jsx("dd",{children:ga(Ae.status,"release")||"-"}),l.jsx("dt",{children:"Uptime"}),l.jsx("dd",{children:jw(Bt(Ae.status,"uptimeSec"))}),l.jsx("dt",{children:"Last seen"}),l.jsx("dd",{children:Jm(Ae.lastSeenAt||Ae.connectedAt)}),l.jsx("dt",{children:"Agent"}),l.jsx("dd",{children:Ae.agentVersion||"-"}),l.jsx("dt",{children:"Address"}),l.jsx("dd",{children:Ae.remoteAddress||"-"})]})]}),Ml&&l.jsx("p",{className:"panel-warning",children:Ml}),l.jsxs("button",{className:"text-button full",onClick:()=>Ae&&Ic(Ae.deviceId),disabled:!Wr,type:"button",children:[l.jsx(Tx,{size:16}),"Start live"]})]})]})]})]})})]}),Mn&&l.jsxs("aside",{className:`transfer-bar state-${Mn.status}`,"aria-live":"polite",children:[l.jsx("span",{className:"transfer-bar-icon","aria-hidden":"true",children:Mn.status==="queued"?l.jsx(qn,{size:18}):Mn.status==="failed"?l.jsx(Hr,{size:18}):l.jsx(ay,{size:18})}),l.jsxs("div",{className:"transfer-bar-copy",children:[l.jsx("p",{children:Mn.message}),l.jsx("div",{className:"transfer-bar-track",children:l.jsx("span",{style:{width:`${Math.max(0,Math.min(100,Mn.progress))}%`}})})]}),l.jsxs("strong",{children:[Math.max(0,Math.min(100,Mn.progress)),"%"]})]})]})}wS.createRoot(document.getElementById("root")).render(l.jsx(f.StrictMode,{children:l.jsx(_A,{})}));
|